Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:二级页面详情¥page_detail¥创建配置@@eyJkYXRhIjoie1wiYXNzb2NpYXRlZE1vZGVsc01hcEZvckpvaW5UYWJsZVwiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhGS1wiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhvdXRGS1wiOnt9LFwiZmllbGRzVG9TZXRUb0RlZmF1bHRcIjpbXSxcImdtdE1vZGlmaWVkXCI6MCxcImlkXCI6MCxcImxhc3RfY2hhcHRlcl9ydWxlXCI6XCJcIixcImxpc3RUb0NsZWFyQXNzb2NpYXRlZEZLXCI6W10sXCJsaXN0VG9DbGVhclNlbGZGS1wiOltdLFwicGFnZUxpc3RcIjpbe1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHlcIixcInBhdGhcIjpcImRycHlcIixcInJ1bGVcIjpcImZ1bmN0aW9uIGluaXRIaWtlcigpIHtcXG4gICAgY29uc3QgaXNDbG9zZUxvZyA9ICFnZXRJdGVtKFxcXCJ1c2VMb2dcXFwiLCBcXFwiXFxcIik7XFxuICAgIGNvbnN0IGxvY2FsS2V5ID0gXFxcImRycHlcXFwiO1xcbiAgICBjb25zdCBDcnlwdG9VdGlsID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2Fzc2V0cy9jcnlwdG8tamF2YS5qc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmxvY2FsID0ge1xcbiAgICAgICAgc2V0KHJ1bGVrZXksIGssIHYpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKGxvY2FsS2V5ICsgXFxcIkBcXFwiICsgcnVsZWtleSArIFxcXCJAXFxcIiArIGssIHYpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldChydWxla2V5LCBrLCB2KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHN0b3JhZ2UwLmdld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Q29va2llOiBcXFwiI25vQ29va2llI1xcXCJcXG4gICAgICAgICAgICB9LCBvYmouaGVhZGVycyk7XFxuICAgICAgICAgICAgaWYgKHVybCA9PT0gXFxcImh0dHBzOi8vYXBpLm5uLmNpL29jci9iNjQvdGV4dFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNbXFxcIkNvbnRlbnQtVHlwZVxcXCJdID0gXFxcInRleHQvcGxhaW5cXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5qcy80LjEuMC9tdXN0YWNoZS5qc1xcXCIpO1xcbiAgXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2pzb25wYXRoLXBsdXMuZ2l0aHViLmlvL0pTT05QYXRoL2Rpc3QvaW5kZXgtYnJvd3Nlci11bWQuY2pzXFxcIik7XFxuICAgIGdsb2JhbFRoaXMuY2hlZXJpbyA9IHtcXG4gICAgICAgIGppbmphMih0ZW1wbGF0ZSwgb2JqKSB7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuICQubG9nKEppbkphLnJlbmRlcih0ZW1wbGF0ZSwgb2JqKSk7XFxuICAgICAgICB9LFxcbiAgICAgICAganAocGF0aCwganNvbikge1xcbiAgICAgICAgICAgIHJldHVybiBKUC5KU09OUGF0aCh7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIGpzb25cXG4gICAgICAgICAgICB9KVswXTtcXG4gICAgICAgIH1cXG4gICAgfSovXFxuICAgIGdsb2JhbFRoaXMucGRmYSA9IF9wZGZhO1xcbiAgICBnbG9iYWxUaGlzLnBkID0gX3BkO1xcbiAgICBnbG9iYWxUaGlzLnBkZmggPSBfcGRmaDtcXG4gICAgU3RyaW5nLnByb3RvdHlwZS5yZXBsYWNlQWxsID0gZnVuY3Rpb24gKHNlYXJjaCwgcmVwbGFjZW1lbnQpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLnNwbGl0KHNlYXJjaCkuam9pbihyZXBsYWNlbWVudCk7XFxuICAgIH07XFxuICAgIGxldCAkdG9TdHJpbmcgPSBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmc7XFxuICAgIEZ1bmN0aW9uLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uICgpIHtcXG4gICAgICAgIHJldHVybiAkdG9TdHJpbmcuYXBwbHkodGhpcykudHJpbSgpO1xcbiAgICB9O1xcbiAgICBpZiAoaXNDbG9zZUxvZykge1xcbiAgICAgICAgLy8g6YeN5YaZY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgIGNvbnNvbGUubG9nID0gZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgIC8vIOajgOafpeS8oOWFpeWPguaVsOeahOaVsOmHj1xcbiAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzlj4LmlbDmlbDph4/lpKfkuo4x77yM6LCD55So5Y6f5aeL55qEY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgICAgICAgICAgLy9vcmlnaW5hbExvZy5hcHBseShjb25zb2xlLCBhcmd1bWVudHMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgLy8g5aaC5p6c5Y+C5pWw5Y+q5pyJ5LiA5Liq77yM5YiZ5LiN5YGa5Lu75L2V5pON5L2cXFxuICAgICAgICB9O1xcbiAgICB9XFxufVxcbmluaXRIaWtlcigpO1xcbmNvbnN0IGRycHlQYXRoID0gZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIik7XFxuXFxuaWYgKCFmaWxlRXhpc3QoZHJweVBhdGgpKSB7XFxuICAgIHRocm93IG5ldyBFcnJvcihcXFwi57y65bCRZHJweS5qc+i/kOihjOW6k1xcXCIpO1xcbn1cXG5sZXQgZHJweSA9ICQucmVxdWlyZShkcnB5UGF0aCk7XFxuLypcXG5sZXQgY3VycmVudFBhdGggPSBcXFwiXFxcIjtcXG5sZXQgJGluaXQgPSBkcnB5LmluaXQ7XFxuZHJweS5pbml0ID0gZnVuY3Rpb24oZXh0KSB7XFxuICAgIGlmIChleHQgPT09IGN1cnJlbnRQYXRoKSByZXR1cm47XFxuICAgICRpbml0LmNhbGwodGhpcywgZXh0KTtcXG4gICAgY3VycmVudFBhdGggPSBleHQ7XFxufSovXFxuJC5leHBvcnRzID0gZHJweTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzFfdmVydGlj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gdmFyIHRpdGxlID0gZmluZEl0ZW0oJ2Rlc2MnKS50aXRsZTtcXG4gICAgICB2YXIgcmUgPSAvKDxcXFxcL3NtYWxsPjxicj4uKj8+KS4rL2c7XFxuICAgICAgdmFyIGV4cCA9ICflsZXlvIA6JztcXG4gICAgICB2YXIgcmV0ID0gJ+aUtui1tzonO1xcbiAgICAgIGlmIChzaG93ID09ICcxJykge1xcbiAgICAgICAgdXBkYXRlSXRlbSgnZGVzYycsIHtcXG4gICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxuICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBzZGMgKyAnPC9zbWFsbD4nKVxcbiAgICAgICAgICAgIC5yZXBsYWNlKC8oPFxcXFwvc21hbGw+PGJyPlxcXFw8Zm9udCBjb2xvcj1cXFwiKS4qPyhcXFwiPikvLCAnJDEnICsgY3MuaGlkZSArICckMicpXFxuXFxuICAgICAgICB9KVxcbiAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMCcpO1xcbiAgICAgIH0gZWxzZSB7XFxuICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICB0aXRsZTogdGl0bGVcXG4gICAgICAgICAgICAucmVwbGFjZShleHAsIHJldClcXG4gICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIGRjICsgJzwvc21hbGw+JylcXG4gICAgICAgICAgICAucmVwbGFjZSgvKDxcXFxcL3NtYWxsPjxicj5cXFxcPGZvbnQgY29sb3I9XFxcIikuKj8oXFxcIj4pLywgJyQxJyArIGNzLnNob3cgKyAnJDInKVxcbiAgICAgICAgfSlcXG4gICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0obSwgJzEnKTtcXG4gICAgICB9XFxuICAgICAgcmV0dXJuIGBoaWtlcjovL2VtcHR5YFxcbiAgICB9LCBkZXNjLCBzZGVzYywgbWFyaywgY29sb3JzKVxcbiAgICB2YXI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IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICBsZXQgdWlkID0gKGtbMV18fGtbMF0pO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxuICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICB9KSxcXG4gICAgICAgICAgdXJsOiAgdWlkKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkucmVwbGFjZSgnXFxcImlkXFxcIicsICdcXFwiJyArdWlkICsgJ1xcXCInKSxcXG4gICAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxuICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9KSovXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzO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ikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICB1cmw6ICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbikgPT4ge1xcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICB9LCBsb2NhdGlvbiksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtKys7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9XSlcXG4gICAgICAvKnBsYXlwID0gcGxheXAubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIHRlbXAsIHtcXG4gICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIChwYWdlbnVtID09IGkgPyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KSxcXG4gICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSkgPT4ge1xcbiAgICAgICAgICAgICBpZ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ICB1cmw6ICQoXFxcIi0xXFxcIiwgXFxcIui+k+WFpeS9oOimgeWIhuS6q+ino+aekOeahOW6j+WPt1xcXFxuLTHlhajpg6jvvIwtMuW3suWQr+eUqOeahO+8jC0z5bey56aB55So55qEXFxcIikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcbiAgICAgICAgICAgICAgICBsZXQgZ2V0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ICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdXAocnVsZXMpO1xcbiAgICAgICAgfSwgbW8sIGluZGV4cywgaW5kZXhjWzFdKTtcXG5cXG4gICAgfSwgbGVuZ3RoKSxcXG4gICAgY29sX3R5cGU6IFxcXCJpY29uX3NtYWxsXzRcXFwiLFxcbiAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9zaGFyZV9ncmVlblxcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIumHjee9rlxcXCIsXFxu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AgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgICAgIH0sI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wi5pu05paw6Kej5p6QXFxcIiA6IFxcXCLlr7zlhaXop6PmnpBcXFwiO1xcbiAgICAgICAgc2V0UGFnZVRpdGxlKHRpcCArIFxcXCI6XFxcIiArIG9iai5uYW1lKTtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJjigJhcXFwiICsgdGlwICsgXFxcIuKAmeKAmVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgb2JqID0ge307XFxuICAgICAgICBiYWNrKCk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl6ZSZ6K+vXFxcIik7XFxuICAgIH1cXG59IGVsc2UgaWYgKGluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgIG9iaiA9IGFycltpbmRleF07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi57yW6L6R6Kej5p6QOlxcXCIgKyBvYmoubmFtZSk7XFxufSBlbHNlIHtcXG4gICAgb2JqID0ge1xcbiAgICAgICAgcnVuVHlwZTogXFxcIldFQlxcXCIsXFxuICAgICAgICBtZXRob2Q6IFxcXCJHRVRcXFwiXFxuICAgIH07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi5paw5bu66Kej5p6QXFxcIik7XFxufVxcblxcbmQucHVzaCh7XFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5ZCN5a2XKOW/heWhqylcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge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gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wcmVwYXJlUGFyc2VzKFt7XFxuICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICAgICAganNcXG4gICAgICAgICAgICB9XSwgaW5wdXQsbnVsbCwgdHJ1ZSk7XFxuICAgICAgICB9KTtcXG4gICAgfSksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIGlzSW1wb3J0KSA9PiB7XFxuICAgICAgICBsZXQgbmFtZSA9IGdldE15VmFyKFxcXCJwc19uYW1lXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghbmFtZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lkI3lrZflvpfmnInkuIDkuKrlkKdcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHVybCA9IGdldE15VmFyKFxcXCJwc191cmxcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCF1cmwpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6Kej5p6Q5Zyw5Z2A5LiN6IO95Li656m6XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmbGFnID0gZ2V0TXlWYXIoXFxcInB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lxcXCIgJiYgIWpzb25QYXRoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pTT07mqKHlvI/kuIvlv4Xpobvloatqc29uUGF0aFxcXCI7XFxuICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT09IFxcXCJKU1xcXCIgJiYgIWpzKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pT5qih5byP5LiL5b+F6aG75aGranNcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBvYmoxID0ge1xcbiAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICBqc1xcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgb2JqMSk7XFxuICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgb2JqMSk7XFxuICAgICAgICB9XFxuICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv53lrZjmiJDlip9cXFwiO1xcbiAgICB9LCBpbmRleCwgaXNJbXBvcnQpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuc2V0UmVzdWx0KGQpO1wifSx7XCJ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WUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAg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ICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogXFxcIlxcXCIsXFxuICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcImRycHlIaWtlcl9zdWJuYW1lX2lucHV0XFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBpZDogXFxcImRycHlIaWtlcl9zdWJuYW1lX2lucHV0XFxcIlxcbiAgICB9XFxufSk7XFxubGV0IHBhdGggPSBqb2luVXJsKGdldFBhdGgoXFxcImhpa2VyOi8vZmlsZXMvXFxcIiksIFxcXCIuLi9cXFwiLnJlcGVhdCg1KSkuc2xpY2UoNyk7XFxubGF5b3V0LnB1c2goe1xcbiAgICB0aXRsZTogXFxcIumAieaLqVxcXCIsXFxuICAgIHVybDogSlNPTi5zdHJpbmdpZnkoZi5maWxlU2VsZWN0aW9uVXJpKHtcXG4gICAgICAgIGNhbGxiYWNrOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBsZXQgdGFyZ2V0ID0gZmluZEl0ZW0oXFxcImRycHlIaWtlcl9zdWJfaW5wdXRcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJkcnB5SGlrZXJfc3ViX2lucHV0XFxcIiwge1xcbiAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih0YXJnZXQsIHtcXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSksXFxuICAgICAgICByb290RGlyUGF0aDogcGF0aCxcXG4gICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgcGF0dGVybjogMVxcbiAgICB9KSksXFxuICA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9pbihcXFwiL1xcXCIpO1xcbiAgICBsZXQgaHRtbCA9IGZldGNoKHVybCk7XFxuICAgIFxcbiAgICBsZXQganNvblRleHQgPSBwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKTtcXG4gICAgXFxuICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShqc29uVGV4dCk7XFxuICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgIGxldCBydWxlcyA9IFtdO1xcbiAgICBsZXQgY291bnQgPSAwO1xcbiAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBuYW1lID0gaXQubmFtZTtcXG4gICAgICAgICAgICBsZXQgc3BhdGggPSBpdC5wYXRoO1xcbiAgICAgICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIG5hbWUgPSBuYW1lLnNsaWNlKDAsIG5hbWUubGFzdEluZGV4T2YoXFxcIi5cXFwiKSk7XFxuICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChgaHR0cHM6Ly9yYXcuZ2l0bWlycm9yLmNvbS8ke3JvcGV9L21hc3Rlci8ke3NwYXRofWApO1xcbiAgICAgICAgICAgIGlmICghKCghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSAmJiAhZmlsZUV4aXN0KHBhdGggKyBpdC5uYW1lKSkpIHtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOicuLi9saWJzL2RycHkyLmpzJyxcXG4gICAgICAgICAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdxdWlja1NlYXJjaCc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogXFxcIi4vXFxcIiArIGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoe3NpdGVzOnJ1bGVzfSkpO1xcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIGNvdW50ICsgXFxcIuS4qlxcXCI7O1xcbn1cXG5cXG5mdW5jdGlvbiBnZW5lcmF0ZUNvbmZpZ0J5SW5kZXgodXJsLCBwYXRoKSB7XFxuICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKHJlcXVlc3QodXJsKSkpO1xcbiAgICBsZXQgYXJyID0ganNvbi5zaXRlcztcXG4gICAgbGV0IGNvdW50ID0gMDtcXG4gICAgbGV0IGkgPSAwO1xcbiAgICBmb3IgKGxldCBpdCBvZiBhcnIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKChTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIubWluLmpzXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLmpzXFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuYW1lID0gaXQuZXh0LmVuZHNXaXRoKFxcXCIuanNcXFwiKSA/IGRlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSkpIDogKGl0Lm5hbWUgKyBcXFwiLmpzXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcbiAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGl0LmV4dCkuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgd3JpdGVGaWx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sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHNvdXJjZUxpc3QgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKTtcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJpbmRleFxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBmaWxlID0gdm9pZCAwO1xcbiAgICAgICAgbGV0IGN1cnJlbnRTb3VyY2UsIHNlYXJjaEFsbG93O1xcbiAgICAgICAgaWYgKGNvbmZpZy5jS2V5KSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3QuZmluZCh2ID0+IHYua2V5ID09PSBjb25maWcuY0tleSk7XFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50U291cmNlKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgICAgICAvL2N1cnJlbnRDb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgLy9jb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IEpTT04ucGFyc2UoZmV0Y2goc2VhcmNoQWxsb3dQYXRoKSB8fCBcXFwiW11cXFwiKTtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBkZWxldGVGaWxlKHNlYXJjaEFsbG93UGF0aCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiB7XFxuICAgICAg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bGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBqc0ZpbGVzLnB1c2goZik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXG4gICAgICAgICAgICB1cmw6IG9iai51cmwsXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxuICAgICAgICAgICAgaW5kZXg6IG9iai5pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcbiAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcbiAgICAgICAgfSkpO1xcbiAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgbGV0IGMgPSBlIC0gcztcXG4gICAgICAgIGlmIChvYmoudXJsLmluY2x1ZGVzKFxcXCJnaXRodWIuY29tXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcbiAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcbiAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkubGVuZ3RoO1xcbiAgICAgICAgICB9IGNhdGNoIHt9XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhqLmJvZHkpIHx8IFxcXCJ7fVxcXCIpO1xcbiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7fVxcblxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgIH1cXG4gICAgICB9O1xcbiAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxuICAgICAgYmUodGFza3MsIHtcXG4gICAgICAgIGZ1bmM6IGZ1bmN0aW9uKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxuICAgICAgICAgIG9iai5yZXN1bHRzLnB1c2godGFza1Jlc3VsdClcXG4gICAgICAgICAgY291bnQgPSBjb3VudCAtIDE7XFxuICAgICAgICAgIGlmIChjb3VudCA+IDApIHtcXG4gICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5qOA5rWL5LitLi4u5Ymp5L2Z5Zyw5Z2A77yaXFxcIiArIGNvdW50KVxcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICBoaTogJ2NjYycsXFxuICAgICAgICAgIHJlc3VsdHM6IHJlc3VsdHNcXG4gICAgICAgIH1cXG4gICAgICB9LCBzdWNjZXNzKTtcXG4gICAgICAvL2xvZyhyZXN1bHRzKVxcbiAgICAgIHJlc3VsdHMgPSByZXN1bHRzLmZpbHRlcihmID0+IGYpO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tlclBvcC5SZXNFeHRyYUlucHV0Qm94KHtcXG4gICAgICAgICAgICBoaW50OiBcXFwi5rqQ5YWz6ZSu5a2XXFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIm9rXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZSh0ZXh0LCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgLy9sb2coXFxcIm9uQ2hhbmdlOlxcXCIrdGV4dClcXG4gICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbmFtZXMuZmlsdGVyKHggPT4geC5pbmNsdWRlcyh0ZXh0KSk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBjbGljayhzLCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgLy90b2FzdChzKTtcXG4gICAgICAgICAgICAgICAgLy9sb2cobWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfSksXFxuICAgICAgICBsb25nQ2xpY2socywgaSkge1xcbiAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliIbkuqvop4bpopHmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIkpT5paH5Lu25YiG5LqrXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSxcXG4gICAgICAgICAgICAgICAgY29sOiAyLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhuYW1lID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBuYW1lID0gcGF0aC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlPWZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYoIXJ1bGUpIHJldHVybiBcXFwidG9hc3Q6Ly/ojrflj5blpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE1ZX0lOREVYID09PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9cXFwiICsgcG5hbWUsIGZldGNoKHBhdGgpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInNoYXJlOi8vaGlrZXI6Ly9maWxlcy9fY2FjaGUvXFxcIiArIHBuYW1lO1xcbiAgICAgICAgICAgICAgICAgICAgfWVsc2V7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybD1zaGFyZVBhc3RlKGJhc2U2NEVuY29kZShydWxlKSwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ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xcbiAgICAgICAgICAgICAgICBjbGljayhzLCBpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogMztcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaW50OiBcXFwi5rqQ5YWz6ZSu5a2XXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKS5tYXAoeCA9PiB4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbGlzdC5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5hdHVyYWwgPSBnZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXR1cmFsID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3Quc29ydChuYXR1cmFsU29ydCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lcy5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBhcnJheURpZmZlcmVuY2UoYXJyMSwgYXJyMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKGFycjIubWFwKGl0ZW0gPT4gW2l0ZW0ua2V5LCBpdGVtXSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5maWx0ZXIoaXRlbSA9PiAhbWFwLmhhcyhpdGVtLmtleSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKENrZXkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNmZyA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjZmc7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRTb3VyY2UoQ2tleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5zb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDAgfHwgZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuaWsOWinjpcXFwiICsgYWxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIuaWsOWinlxcXCIgKyBhbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuenu+mZpDpcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIiDnp7vpmaRcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLlt7LliLfmlrBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHnnrqHnkIZcIixcInBhdGhcIjpcIkRycHlNYW5hZ2VcIixcInJ1bGVcIjpcImpzOlxcbmNvbnN0IEpTRW5naW5lID0gY29tLmV4YW1wbGUuaGlrZXJ2aWV3LnNlcnZpY2UucGFyc2VyLkpTRW5naW5lO1xcbmNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG5jb25zd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Nhc2UgXFxcImVyXFxcIjpcXG4gICAgICAgICAgICBpc0luaXRlclBhZ2UgPSB0cnVlO1xcbiAgICB9XFxuICAgIGFkZExpc3RlbmVyKFxcXCJvbkNsb3NlXFxcIiwgJC50b1N0cmluZygoR01rZXksIHR5cGUpID0+IHtcXG4gICAgICAgIGxvZyhcXFwib25DbG9zZVxcXCIpO1xcbiAgICAgICAgR00uaGFzKEdNa2V5LCBEcnB5TWFuYWdlID0+IHtcXG4gICAgICAgICAgICBsb2coXFxcIuaciUdNa2V5XFxcIik7XFxuICAgICAgICAgICAgRHJweU1hbmFnZS5jbGVhcih0eXBlKTtcXG4gICAgICAgIH0pO1xcbiAgICB9LCBHTWtleSwgdHlwZSkpO1xcbn1cXG5cXG5mdW5jdGlvbiBjbGVhcih0eXBlKSB7XFxuICAgIHN3aXRjaCAodHlwZSkge1xcbiAgICAgICAgY2FzZSBcXFwiaG9tZVxcXCI6XFxuICAgICAgICAgICAgaXNJbml0SG9tZSA9IGZhbHNlO1xcbiAgICAgICAgLy9jYXNlIFxcXCJzZWFyY2hcXFwiOlxcbiAgICAgICAgLy8gICAgaXNJbml0U2VhcmNoID0gZmFsc2U7XFxuICAgICAgICBjYXNlIFxcXCJlclxcXCI6XFxuICAgICAgICAgICAgaXNJbml0ZXJQYWdlID0gZmFsc2U7XFxuICAgIH1cXG5cXG4gICAgaWYgKCFpc0luaXRIb21lICYmICFpc0luaXRFclBhZ2UpIHtcXG4gICAgICAgIGxvZyhcXFwi5byA5aeL5riF55CGXFxcIik7XFxuICAgICAgICBkcnB5TWFwLmNsZWFyKCk7XFxuICAgICAgICBHTS5jbGVhcihHTWtleSk7XFxuICAgIH1cXG59XFxuJC5leHBvcnRzID0ge1xcbiAgICBpbml0UGFnZSxcXG4gICAgZ2V0LFxcbiAgICBnZXRCeVNvdXJjZSxcXG4gICAgZGVsLFxcbiAgICBjbGVhcixcXG4gICAgcHV0XFxufVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiL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Sa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG5cXG5cXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXG4gICAgICAgICAgICAgICAgbnVtZXJpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgc2Vuc2l0aXZpdHk6ICdiYXNlJ1xcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnJldmVyc2UoKTtcXG5cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2KSkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICh0ZW1saXN0LmluY2x1ZGVzKHYua2V5KSkgcmV0dXJuO1xcbiAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICB9KTtcXG4gICAgfVxcbiAgfSk7XFxufVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi5YiG57G7XCIsXCJwYXRoXCI6XCJjYXRlZ29y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vYmpbY2F0ZV07XFxuICAgICAgLy92YXIgZmlsdGVyX2RlZj1zdG9yYWdlMC5nZXRJdGVtKFxcXCJmaWx0ZXJfZGVmXFxcIiwge30pO1xcbiAgICAgIGNsYXNzaWZ5LmZvckVhY2goKHgsIGluZGV4KSA9PiB7XFxuICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICB9KVxcbiAgICAgICAgeC52YWx1ZS5mb3JFYWNoKChpdCwgaSkgPT4ge1xcbiAgICAgICAgICBsZXQgdCA9IGl0Lm47XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IGkpIHtcXG4gICAgICAgICAgICB0ID0gXFxcIjxiPjxmb250IGNvbG9yPVxcXCIgKyBjb2xvciArIFxcXCI+XFxcIiArIHQgKyBcXFwiPC9mb250PjwvYj5cXFwiO1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IGl0LnY7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGNhdGVfdGVtcFtpbmRleF0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IFxcXCJ1bmRlZmluZWRcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChmb2xkID09IDEpIHtcXG4gICAgICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyB0LFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gby5pO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiaXNfZGVmXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwge30pO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIGlmIChjYXRlX3RlbXAuY29uc3RydWN0b3IgIT0gQXJyYXkpIHtcXG4gICAgICAgICAgICAgICAgICBjYXRlX3RlbXAgPSBbXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmluZGV4O1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgLy9sb2coYylcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVfdGVtcClcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV90ZW1wXFxcIiwgY2F0ZV90ZW1wKTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwgY2F0ZV9vYmopO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXFxuICAgICAgICAgICAgICA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0RpcmVjdG9yeSgpKSB7XFxuICAgICAgICAgICAgbGV0IGZsaXN0ID0gZGlyLmxpc3RGaWxlcygpO1xcbiAgICAgICAgICAgIGZvciAodmFyIGYgb2YgZmxpc3QpIHtcXG4gICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIHtcXG4gICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG5cXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICB9XFxuICAgICAgfTtcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgIC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biAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZShpdGVtID0+IHtcXG4gICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgIGxldCB7XFxuICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgIG5hbWVcXG4gICAgICAgIH0gPSBpdGVtO1xcbiAgICAgICAgaWYgKHBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjliqDovb3phY3nva4uLi5cXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICBuYW1lLFxcbiAgICAgICAgfSkpIHtcXG4gICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuY2xlYXIoKTtcXG4gICAgICAgICAgJC5yZXF1aXJlKFxcXCJDaGFuZ2VTb3VyY2VQb3BcXFwiKS5zaG93KDEwMCk7XFxuICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5aSx6LSlXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICB9LCBpdGVtKSxcXG4gICAgICBjb2xfdHlwZTogXFxc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ICE9PSBcXFxcXFxcInN0cmluZ1xcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW2tleV0gPSBTdHJpbmcob2JqLmhlYWRlcnNba2V5XSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgbGV0IHIgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFxcXFxcInBvc3RcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxcXG4gICAgICAgICAgICAgfSovXFxcXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcXFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcXFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcXFxuICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXFxcbiAgICAgICAgICAgIC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mIChpbnB1dCA9PSBcXFxcXFxcIuWujOaVtOWPo+S7pFxcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJjb3B5Oi8vXFxcXFxcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcXFxcXCJhXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImNvcHk6Ly9cXFxcXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFxcXFxcImJcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFxcXFxcIuenu+WKqFxcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFxcXFxcIlxcXFxcXFwiLCBcXFxcXFxcIui+k+WFpeS9jee9rlxcXFxcXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5nZXRKc29uKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXFxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXFxcXFwi572u6aG2XFxcXFxcXCIpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcXFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpO1xcXFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXFxcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcXFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcXFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXFxcXFwi5Yig6ZmkXFxcXFxcXCIpIHtcXFxcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFxcXFxcIuehruiupOWIoOmZpO+8n1xcXFxcXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLmdldEpzb24oKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcXFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXFxcXFwiICsgcnVsZS5uYW1lO1xcXFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpO1xcXFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXFxcbiAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9ICFydWxlLmZvcmJpZGRlbjtcXFxcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLnNhdmVKc29uKGFycik7XFxcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcXFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly9cXFxcXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXFxcXFwi56aB55SoXFxcXFxcXCIgOiBcXFxcXFxcIuWQr+eUqFxcXFxcXFwiKSArIHJ1bGUubmFt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cXFxcbiAgICAgICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXFxcXFwicHNfanNcXFxcXFxcIiwgXFxcXFxcXCJcXFxcXFxcIikgfHwgdm9pZCAwO1xcXFxuICAgICAgICAgICAgaWYgKGhlYWRlcnMpIHtcXFxcbiAgICAgICAgICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzID0gSlNPTi5wYXJzZShoZWFkZXJzKTtcXFxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcXFxcXCIgKyBlLnRvU3RyaW5nKCk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFxcXFxcInZpZGVvVXJsXFxcXFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXFxcbiAgICAgICAgICAgICAgICBuYW1lLFxcXFxuICAgICAgICAgICAgICAgIHVybCxcXFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxcXG4gICAgICAgICAgICAgICAganNcXFxcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXFxcbiAgICAgICAgfSk7XFxcXG4gICAgfSksXFxcXG4gICAgY29sX3R5cGU6IFxcXFxcXFwidGV4dF8zXFxcXFxcXCIsXFxcXG59KTtcXFxcblxcXFxuZC5wdXNoKHtcXFxcbiAgICB0aXRsZTogXFxcXFxcXCLkv53lrZhcXFxcXFxcIixcXFxcbiAgICB1cmw6ICQoXFxcXFxcXCIjbm9Mb2FkaW5nI1xcXFxcXFwi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idG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcXFxcXCI7XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpO1xcXFxuICAgICAgICBsZXQgb2JqMSA9IHtcXFxcbiAgICAgICAgICAgIG5hbWUsXFxcXG4gICAgICAgICAgICB1cmwsXFxcXG4gICAgICAgICAgICBmbGFnLFxcXFxuICAgICAgICAgICAgaGVhZGVycyxcXFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxcXG4gICAgICAgICAgICBtZXRob2QsXFxcXG4gICAgICAgICAgICBqc29uUGF0aCxcXFxcbiAgICAgICAgICAgIGpzXFxcXG4gICAgICAgIH07XFxcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcXFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcXFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXFxcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcXFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBvYmoxKTtcXFxcbiAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIG9iajEpO1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuc2F2ZUpzb24oYXJyKTtcXFxcbiAgICAgICAgYmFjayh0cnVlKTtcXFxcbiAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/kv53lrZjmiJDlip9cXFxcXFxcIjtcXFxcbiAgICB9LCBpbmRleCwgaXNJbXBvcnQpLFxcXFxuICAgIGNvbF90eXBlOiBcXFxcXFxcInRleHRfM1xcXFxcXFwiLFxcXFxufSk7XFxcXG5cXFxcbnNldFJlc3VsdChkK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XRKc29uKCk7XFxcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXFxcbiAgICAgICAgZm9yIChsZXQgcnVsZSBvZiBydWxlcykge1xcXFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxcXG4gICAgICAgICAgICAgICAgcnVsZSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFxcXFxcIiArIGluZGV4ICsgXFxcXFxcXCImcnVsZT1cXFxcXFxcIiArIHJ1bGVUaXRsZTtcXFxcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFxcXFxcIuW3suabtOaWsOinhOWIme+8mlxcXFxcXFwiICsgcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIG5ld0krKztcXFxcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoc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W4uanNcXFxcXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcXFxcXCJkcnB5Mi5qc1xcXFxcXFwiKSkpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0LmV4dC5lbmRzV2l0aChcXFxcXFxcIi5qc1xcXFxcXFwiKSA/IGRlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcXFxcXCIvXFxcXFxcXCIpLmF0KC0xKSkgOiAoaXQubmFtZSArIFxcXFxcXFwiLmpzXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcXFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXFxcXFwiaHR0cFxcXFxcXFwiKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcXFxcXCIuL1xcXFxcXFwiICsgbmFtZTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcXFxcXCJydWxlXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcXFxuICAgICAgICAgICAgICAgIH07XFxcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXFxcbiAgICAg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gICBpZiAob2JqLnVybC5zdGFydHNXaXRoKFxcXFxcXFwiZmlsZTpcXFxcXFxcIikpIHtcXFxcbiAgICAgICAgICBsZXQgY29kZSA9IFxcXFxcXFwibm9cXFxcXFxcIjtcXFxcbiAgICAgICAgICBsZXQgcGF0aCA9IG9iai51cmwucmVwbGFjZShcXFxcXFxcImZpbGU6Ly9cXFxcXFxcIiwgXFxcXFxcXCJcXFxcXFxcIik7XFxcXG4gICAgICAgICAgbGV0IGRpciA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxcXG4gICAgICAgICAgaWYgKGRpci5pc0RpcmVjdG9yeSgpKSB7XFxcXG4gICAgICAgICAgICBsZXQgZmxpc3QgPSBkaXIubGlzdEZpbGVzKCk7XFxcXG4gICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxcXG4gICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcXFxuICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXFxcXFwiLmpzXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcXFxuICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxcXG4gICAgICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxcXG4gICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxcXG4gICAgICAgICAgICBjb2RlID0gXFxcXFxcXCJva1xcXFxcXFwiO1xcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcXFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXFxcbiAgICAgICAgICAgIGNvZGUgPSBcXFxcXFxcIm9rXFxcXFxcXCI7XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcXFxuICAgICAgICAgICAgY29kZTogY29kZSxcXFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcXFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcXFxuICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxcXG4gICAgICAgIH0pKTtcXFxcbiAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcXFxuICAgICAgICBsZXQgYyA9IGUgLSBzO1xcXFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFxcXFxcImdpdGh1Yi5jb21cXFxcXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcXFxuICAgICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXFxcbiAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXFxcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcXFxcXCIpKTtcXFxcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxcXG4gICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXFxcXFwiLmpzXFxcXFxcXCIpKS5sZW5ndGg7XFxcXG4gICAgICAgICAgfSBjYXRjaCB7fVxcXFxuICAgICAgICB9XFxcXG4gICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFxcXFxcInt9XFxcXFxcXCIpO1xcXFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXFxcbiAgICAgICAgICB9XFxcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxcXG5cXFxcbiAgICAgICAgcmV0dXJuIHtcXFxcbiAgICAgICAgICB0aW1lOiBjLFxcXFxuICAgICAgICAgIHVybDogai51cmwsXFxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcXFxuICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxcXG4gICAgICAgIH1cXFxcbiAgICAgIH07XFxcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcXFxuICAgICAgICBpID0gaSArIDE7XFxcXG4gICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgZnVuYzogdGFzayxcXFxcbiAgICAgICAgICBwYXJhbToge1xcXFxuICAg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cXFxuICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwib2tcXFxcXFxcIixcXFxcbiAgICAgICAgICAgIG9uQ2hhbmdlKHRleHQsIG1hbmFnZSkge1xcXFxuICAgICAgICAgICAgICAgIC8vbG9nKFxcXFxcXFwib25DaGFuZ2U6XFxcXFxcXCIrdGV4dClcXFxcbiAgICAgICAgICAgICAgICBsZXQgZmxpc3QgPSBuYW1lcy5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXFxcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxcXG4gICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcXFxuICAgICAgICAgICAgfSxcXFxcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogXFxcXFxcXCJcXFxcXFxcIixcXFxcbiAgICAgICAgICAgIGNsaWNrKHMsIG1hbmFnZSkge1xcXFxuICAgICAgICAgICAgICAgIC8vdG9hc3Qocyk7XFxcXG4gICAgICAgICAgICAgICAgLy9sb2cobWFuYWdlLmxpc3QpO1xcXFxuICAgICAgICAgICAgfSxcXFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXFxcbiAgICAgICAgfSksXFxcXG4gICAgICAgIGxvbmdDbGljayhzLCBpKSB7XFxcXG4gICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwi5YiG5Lqr6KeG6aKR5rqQXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgICAgb3B0aW9uczogW1xcXFxcXFwiSlPmlofku7bliIbkuqtcXFxcXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSxcXFxcbiAgICAgICAgICAgICAgICBjb2w6IDIsXFxcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcobmFtZSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcXFxcXCJydW50aW1lQ29uZmlnXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gcnVudGltZUNvbmZpZy5nZXRBYnNvbHV0ZVBhdGgoc291cmNlLmV4dCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwbmFtZSA9IHBhdGguc3BsaXQoXFxcXFxcXCIvXFxcXFxcXCIpLmF0KC0xKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGU9ZmV0Y2gocGF0aCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmKCFydWxlKSByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+iOt+WPluWksei0pVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShcXFxcXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL1xcXFxcXFwiICsgcG5hbWUsIGZldGNoKHBhdGgpKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInNoYXJlOi8vaGlrZXI6Ly9maWxlcy9fY2FjaGUvXFxcXFxcXCIgKyBwbmFtZTtcXFxcbiAgICAgICAgICAgICAgICAgICAgfWVsc2V7X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4gICAgICAgICAgICAgICAgb3B0aW9uczogW1xcXFxcXFwi5pS55Y+Y5qC35byPXFxcXFxcXCIsIFxcXFxcXFwi562b6YCJ5rqQXFxcXFxcXCIsIFxcXFxcXFwi6Ieq54S25o6S5bqPOlxcXFxcXFwiICsgKGdldEl0ZW0oXFxcXFxcXCJuYXR1cmFsXFxcXFxcXCIsIFxcXFxcXFwiXFxcXFxcXCIpID09IFxcXFxcXFwiXFxcXFxcXCIgPyBcXFxcXFxcIuWFs+mXrVxcXFxcXFwiIDogXFxcXFxcXCLlkK/nlKhcXFxcXFxcIiksIFxcXFxcXFwi5YCS5bqPXFxcXFxcXCIsIFxcXFxcXFwi5Yi35paw6YWN572uXFxcXFxcXCJdLFxcXFxuICAgICAgICAgICAgICAgIGNvbHVtbnM6IDIsXFxcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwi6K+36YCJ5oupXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgICAgY2xpY2socywgaSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgc3BlbiA9IHNwZW4gPT0gMyA/IDEgOiAzO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZUNvbHVtbnMoc3Blbik7XFxcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMSkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBcXFxcXFxcIui+k+WFpeWFs+mUruWtlyDnqbrmmL7npLrlhajpg6hcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcXFxcXCLnrZvpgInmupBcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaW50OiBcXFxcXFxcIua6kOWFs+mUruWtl1xcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXFxcXFwicnVudGltZUNvbmZpZ1xcXFxcXFwiLCBcXFxcXFxcInJ1bnRpbWVDb25maWdcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKS5tYXAoeCA9PiB4Lm5hbWUpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmxpc3QgPSBsaXN0LmZpbHRlcih4ID0+IHguaW5jbHVkZXModGV4dCkpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXFxcXFwiICsgdGV4dDtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxcXFxuXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBuYXR1cmFsID0gZ2V0SXRlbShcXFxcXFxcIm5hdHVyYWxcXFxcXFxcIiwgXFxcXFxcXCJcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobmF0dXJhbCA9PSBcXFxcXFxcIlxcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0LnNvcnQobmF0dXJhbFNvcnQpLmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFxcXFxcIm5hdHVyYWxcXFxcXFxcIiwgbmF0dXJhbCA/IFxcXFxcXFwiXFxcXFxcXCIgOiBcXFxcXFxcIjFcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lcy5yZXZlcnNlKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBhcnJheURpZmZlcmVuY2UoYXJyMSwgYXJyMikge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXFxcblxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcXFxcXCJydW50aW1lQ29uZmlnXFxcXFxcXCIsIFxcXFxcXFwicnVudGltZUNvbmZpZ1xcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coQ2tleSlcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjZmc7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50U291cmNlKENrZXkpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5zb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXFxcblxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxcXG5cXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcXFxcXCJcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLmlrDlop46XFxcXFxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcXFxcXCIsXFxcXFxcXCIpKVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtc2cgKz0gXFxcXFxcXCLmlrDlop5cXFxcXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXFxcXFwi5Liq5rqQXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKFxcXFxcXFwi56e76ZmkOlxcXFxcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXFxcXFwiLFxcXFxcXFwiKSlcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXFxcXFwiIOenu+mZpFxcXFxcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcXFxcXCLkuKrmupBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXFxcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcXFxcXCLlt7LliLfmlrBcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICB9LFxcXFxuICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgIH1cXFxcbiAgICB9KTtcXFxcbn1cXFwifSx7XFxcImNvbF90eXBlXFxcIjpcXFwibW92aWVfM1xcXCIsXFxcIm5hbWVcXFwiOlxcXCJkcnB5566h55CGXFxcIixcXFwicGF0aFxcXCI6XFxcIkRycHlNYW5hZ2VcXFwiLFxcXCJydWxlXFxcIjpcXFwianM6XFxcXG5jb25zdCBKU0VuZ2luZSA9IGNvbS5leGFtcGxlLmhpa2Vydmlldy5zZXJ2aWNlLnBhcnNlci5KU0VuZ2luZTtcXFxcbmNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcXFxcXCJydW50a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6ZSu5a2XIOepuuaYvuekuuWFqOmDqFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICB0aXRsZTogXFxcXFxcXCLnrZvpgInmupBcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgaGludDogXFxcXFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXFxcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXFxcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcXFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFxcXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcXFxcXCLigJzigJzigJ3igJ1cX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xuICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXFxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXFxcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcXFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5yZXZlcnNlKCk7XFxcXG5cXFxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXFxcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNCkge1xcXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcXFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxcXG4gICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDUpIHtcXFxcbiAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXFxcbiAgICAgICAgICAgIHNlYXJjaEFsbG93Lmxlbmd0aCA9IDA7XFxcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxcXG4gICAgICAgICAgICAgIGlmICh0ZW1saXN0LmluY2x1ZGVzKHYua2V5KSkgcmV0dXJuO1xcXFxuICAgICAg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mb2xkID09IDEpIHtcXFxcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXFxcbiAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgdCxcXFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXFxcXFwiI25vTG9hZGluZyNcXFxcXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgaSA9IG8uaTtcXFxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFxcXFxcImlzX2RlZlxcXFxcXFwiLCBcXFxcXFxcIjFcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcXFxcXCJjYXRlX29ialxcXFxcXFwiLCB7fSk7XFxcXG5cXFxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcXFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXFxcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXFxcXFwiXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcXFxcXCJjYXRlX3RlbXBcXFxcXFxcIiwgY2F0ZV90ZW1wKTtcXFxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFxcXFxcImNhdGVfb2JqXFxcXFxcXCIsIGNhdGVfb2JqKTtcXFxcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgfSwge1xcXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCxcXFxcbiAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXFxcbiAgICAgICAgICAgICAgICBpOiBpLFxcXFxuICAgICAgICAgICAgICAgIGNhdGU6IGNhdGVcXFxcbiAgICAgICAgICAgICAgfSksXFxcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxcXG4gICAgICAgICAgICB9KVxcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgfSlcXFxcbiAgICAgIH0pXFxcXG4gICAgfVxcXFxuICB9XFxcXG59XFxcXG5cXFxcbmZ1bmN0aW9uIGdldEZsKCkge1xcXFxuICBmbCA9IE9iamVjdC5rZXlzKGZsKS5maWx0ZXIoa2V5ID0+IGZsW2tleV0gIT09IFxcXFxcXFwidW5kZWZpbmVkXFxcXFxcXCIpLnJlZHVjZSgocmVzLCBrZXkpID0+IHtcXFxcbiAgICByZXNba2V5XSA9IGZsW2tleV07XFxcXG4gICAgcmV0dXJu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