Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjo0NiwiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1pYW5Mb2FkXCIpOyIsInNlYXJjaF91cmwiOiJoaWtlcjovL2VtcHR5P3M9KiomcGFnZT1meXBhZ2UiLCJncm91cCI6IuKRoOiHqueUqCIsInNlYXJjaEZpbmQiOiJqczpcbihmdW5jdGlvbiAoKSB7XG4gIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgbGV0IHRlbXNtb2RlID0gZ2V0TXlWYXIoXCJ0ZW1zbW9kZVwiLCBcIlwiKTtcbiAgaWYgKHRlbXNtb2RlKSB7XG4gICAgc21vZGUgPSBOdW1iZXIodGVtc21vZGUpO1xuICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgfVxuICBpZiAoIWZpbGVFeGlzdChcImhpa2VyOi8vZmlsZXMvZGF0YS9cIiArIE1ZX1JVTEUudGl0bGUgKyBcIi9saWJzX2hpa2VyL2RycHkyLmpzXCIpKSByZXR1cm4gc2V0UmVzdWx0KFt7XG4gICAgdGl0bGU6IFwi6K+35YmN5b6A5bCP56iL5bqP5Li76aG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ICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzICsgXCLCt1wiICsgc291cmNlLm5hbWUsXG4gICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgdm9kSWQ6IFN0cmluZyhpdC52b2RfaWQpLFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXG4gICAgICAgICAgc2tleTogc291cmNlLmtleSxcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuICAgIHNldFJlc3VsdChkKTtcbiAgfSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgIHVybDogXCJoaWtlcjovL3NlYXJjaD9zPVwiICsgTVlfS0VZV09SRCxcbiAgICAgIGV4dHJhOiB7XG4gICAgICAgIGRlbGVnYXRlT25seVNlYXJjaDogdHJ1ZSxcbiAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIiwgXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXCJzbW9kZVwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbG93U2VhcmNoU291cmNlKHNtb2RlPT09Mik7XG5cbiAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcblxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcblxuICAgICAgICAgICAgbGV0IHNlYXJjaHNvcnQgPSBOdW1iZXIoZ2V0SXRlbShcInNlYXJjaHNvcnRcIiwgXCIwXCIpKTtcbiAgICAgICAgICAgIGxldCB7XG4gICAgICAgICAgICAgIG5hdHVyYWxTb3J0LFxuICAgICAgICAgICAgICB1c2luZ1NvcnRcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXCJtZXRob2RzXCIpO1xuXG4gICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA+IDApIHtcbiAgICAgICAgICAgICAgaWYgKHNlYXJjaHNvcnQgPT0gMSkge1xuICAgICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QsIFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChzZWFyY2hzb3J0ID09IDIpIHtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuc2V0a2V5KFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xuICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpLmdldChpdGVtLmtleSk7XG5cbiAgICAgICAgICAgICAgICAgIGxldCBob21lTGlzdCA9IEpTT04ucGFyc2UoZHJweS5zZWFyY2goTVlfS0VZV09SRCwgZmFsc2UsIE1ZX1BBR0UpKS5saXN0IHx8IFtdO1xuICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcbiAgICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnZvZF9uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICAgICAgICAgICAgICAgIHVybDogXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWQjaW1tZXJzaXZlVGhlbWUjXCIsXG4gICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZvZElkOiBTdHJpbmcoaXQudm9kX2lkKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlzUG9seW1lcml6ZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNuYW1lOiBpdGVtLm5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBza2V5OiBpdGVtLmtleSxcbiAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgc2V0UmVzdWx0KGQpO1xuICAgICAgICAgICAgICAgIH0sIGl0KVxuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShydWxlcyk7XG4gICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XG4gICAgICAgICAgfVxuICAgICAgICB9KVxuICAgICAgfVxuICAgIH1dKTtcbiAgfVxufSkoKSIsImRldGFpbF9jb2xfdHlwZSI6Im1vdmllXzEiLCJkZXRhaWxfZmluZF9ydWxlIjoiIiwic2RldGFpbF9jb2xfdHlwZSI6Im1vdmllXzEiLCJzZGV0YWlsX2ZpbmRfcnVsZSI6IiIsInVhIjoibW9iaWxlIiwicHJlUnVsZSI6Ii8qPCQ+XG5AaW5jbHVkZSBzdGFydFxuaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzVlOGYwLTIyZTgtNTI3MC1hOWQxLTgyNmY1M2YxNzdhZFxuQGluY2x1ZGUgZW5kXG48JD4qL1xuIiwicGFnZXMiOiJbe1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHlcIixcInBhdGhcIjpcImRycHlcIixcInJ1bGVcIjpcImNvbnN0IHNrZXkgPSBtb2R1bGUuaW1wb3J0UGFyYW07XFxuXFxuZnVuY3Rpb24gaW5pd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FxcbiAgICAgICAgICB9KSovXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgZnJvbTogZnJvbVtpXSxcXG4gICAgICAgICAgICBzb3VyY2U6IHNvdXJjZSxcXG4gICAgICAgICAgICBpZDogdWlkLFxcbiAgICAgICAgICAgIGJsb2NrUnVsZXM6IFsnYmIuKi5wbmcnLCAnLmpwZycsIFxcXCJobVxcXFwuYmFpZHVcXFxcLmNvbVxcXFwvaG0uanNcXFwiXSxcXG4gICAgICAgICAgICB2aWRlb0V4Y2x1ZGVSdWxlczogWyc/dXJsPSddLFxcbiAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgIH1cXG4gICAgICAgIH07XFxuICAgICAgfSk7XFxuXFxuICAgICAgaWYgKChzdHlwZSA9PSBcXFwi5ryr55S7XFxcIiB8fCBzdHlwZSA9PSBcXFwi5bCP6K+0XFxcIikgJiYgaSA9PSAwKSB7XFxuXFxuICAgICAgICB2YXIgZG93bmxvYWRsYXp5ID0gJC50b1N0cmluZygoa2V5LCBza2V5LCB0aXRsZSkgPT4ge1xcbiAgICAgICAgICBsZXQgZHJweTtcXG4gICAgICAgICAgaWYgKCQuaGlrZXJbXFxcIl9fZHJweV9fXFxcIl0pIHtcXG4gICAgICAgICAgICBkcnB5ID0gJC5oaWtlcltcXFwiX19kcnB5X19cXFwiXTtcXG5cXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgR01cXG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTE2JmF1dGg9MWQzNWU4ZjAtMjJlOC01MjcwLWE5ZDEtODI2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WtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIixcXG4gICAgICAgICAgICBpbmZvOiB7XFxuICAgICAgICAgICAgICBib29rTmFtZTogaW5mby52b2RfbmFtZSwgLy/mvKvnlLvlkI3np7AsXFxuICAgICAgICAgICAgICBydWxlTmFtZTogTVlfUlVMRS50aXRsZSxcXG4gICAgICAgICAgICAgIGJvb2tUb3BQaWM6IGluZm8udm9kX3BpYyxcXG4gICAgICAgICAgICAgIHBhcnNlQ29kZTogZG93bmxvYWRsYXp5LFxcbiAgICAgICAgICAgICAgYm9va0lkOiBNWV9QQVJBTVMuc25hbWUsXFxuICAgICAgICAgICAgICB0eXBlOiBzdHlwZSA9PT0gXFxcIua8q+eUu1xcXCIgPyBcXFwiY29taWNcXFwiIDogXFxcIm5vdmVsXFxcIixcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRlZmF1bHRWaWV3OiBcXFwiMVxcXCJcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICB0aXRsZTogXFxcIuacrOWcsOS5puaetlxcXCIsXFxuICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9Cb29rcmFjay52aWV3I25vUmVjb3JkSGlzdG9yeSM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYmcnVsZU5hbWU9JyArIE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgY29sX3R5cGU6ICdibGFua19ibG9jaydcXG4gICAgICAgIH0pO1xcbiAgICAgIH1cXG5cXG4gICAgIC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vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSwgaWQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgICBsZXQgbG9jYXRpb24gPSBnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBwYWdlbnVtKSA9PSBpKSB7XFxuICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH0sIGksIGlkLCBwYWdlbnVtKSxcXG4gICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIHRlbXAuZXh0cmEsIHtcXG4gICAgICAgICAgICBpZDogXFxcInBhZ2VudW1cXFwiICsgaSxcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH0pXFxuICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgIH0pXFxuXFxuICAgICAgbGV0IGZjID0gXFxcIlxcXCI7XFxuICAgICAgaWYgKCEocGxheXAgJiYgcGxheXAubGVuZ3RoID4gMSkpIHtcXG4gICAgICAgIGZjID0gXFxcImdyZXlcXFwiO1xcbiAgICAgIH1cXG5cXG4gICAgICBsZXQgcGFnZW9iaiA9IFt7XFxuICAgICAgICB0aXRsZTogZm9udHN0eWxlKCfkuIrkuIDpobUnLCB7XFxuICAgICAgICAgIGM6IGZjXFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgIHVybDogJ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tXSwge1xcbiAgICAgICAgICBjOiBmY1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkLCBwYWdlbnVtKSA9PiB7XFxuICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgcGFnZW51bSk7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBpZiAocGNvdW50ID09IDEpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGxldCBwbGF5cCA9IGVmLnBsYXlwO1xcbiAgICAgICAgICBsZXQgcGFnZWFyciA9IHBsYXlwLm1hcCgoeCwgaSkgPT4gaSA9PSBwYWdlbnVtID8gJ+KAnOKAnOKAneKAnScgKyB4LmZvbnRjb2xvcihcXFwiI2ZmYTUwMFxcXCIpIDogeCk7XFxuICAgICAgICAgIHJldHVybiAkKHBhZ2VhcnIsIDMpLnNlbGVjdCgobG9jYXRpb24pID0+IHtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4geyB9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICB9LCBsb2NhdGlvbilcXG4gICAgICAgIH0sIGlkLCBwYWdlbnVtKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZUBwYWdlYXJyXFxcIixcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogZm9udHN0eWxlKCfkuIvkuIDpobUnLCB7XFxuICAgICAgICAgIGM6IGZjXFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGVmLnBhZ2VudW07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgaWYgKHBhZ2VudW0gPj0gcGNvdW50IC0gMSkge1xcbiAgICAgICAgICAgIHBhZ2VudW0gPSAwO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHBhZ2VudW0rKztcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKC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lID0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgaWYgKGlpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcInJlZFxcXCIpO1xcbiAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgfSwgaSksXFxuICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgdGVtcC5leHRyYSwge1xcbiAgICAgICAgICAgICBpZDogXFxcInBhZ2VudW1cXFwiICsgaSxcXG4gICAgICAgICAgIH0pXFxuICAgICAgICAgfSlcXG4gICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgICB9KVxcbiAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIHBsYXlwKSovXFxuICAgIH0gZWxzZSB7XFxuICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwYWdlbmF2XFxcIik7XFxuICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpO1xcbiAgICAgIHB1dE15VmFyKFxcXCJub3BhZ2VcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICB9XFxuICAgIGlmIChnZXRNeVZhcihcXFwicGxheWxpc3RfcmVhZHlcXFwiLCBcXFwiMFxcXCIpID09IFxcXCIxXFxcIikge1xcbiAgICAgIGxldCBvbGRJZHMgPSAoZmluZEl0ZW1zQnlDbHMoJ3BsYXlsaXN0JykgfHwgW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iAgICB1cmw6ICQoXFxcIi0xXFxcIiwgXFxcIui+k+WFpeS9oOimgeWIhuS6q+ino+aekOeahOW6j+WPt1xcXFxuLTHlhajpg6jvvIwtMuW3suWQr+eUqOeahO+8jC0z5bey56aB55So55qEXFxcIikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcblxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcbiAgICAgICAgICAgICAgICBsZXQ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ICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdXAocnVsZXMpO1xcbiAgICAgICAgfSwgbW8sIGluZGV4cywgaW5kZXhjWzFdKTtcXG5cXG4gICAgfSwgbGVuZ3RoKSxcXG4gICAgY29sX3R5cGU6IFxcXCJpY29uX3NtYWxsXzRcXFwiLFxcbiAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9zaGFyZV9ncmVlblxcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIumHjee9rlxcXC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LnRlc3QoZikpIHtcXG4gICAgICAgICAgICAgICAgZmxhZ2kgPSBbZl1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBmbGFnaSA9IGZsYWdpLmZpbHRlcih4ID0+ICEvKOWFqOmDqHzlt7LnpoHnlKgpLy50ZXN0KHgpKTtcXG4gICAgICAgICAgICAgICAgaWYgKGZsYWdpLmluY2x1ZGVzKGYpKSB7XFxuICAgICAgICAgICAgICAgICAgICBmbGFnaSA9IGZsYWdpLmZpbHRlcih4ID0+IHggIT0gZik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZmxhZ2kubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmbGFnaSA9IFtcXFwi5YWo6YOoXFxcIl1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGZsYWdpLnB1c2goZilcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiZmxhZ2lcXFwiLCBmbGFnaSk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgZilcXG4gICAgfSlcXG59KVxcbmZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHtcXG4gICAgbGV0IGl0ID0gYXJyW2ldO1xcblxcbiAgICBsZXQgZmxhZyA9IGl0LmZsYWcuc3BsaXQoXFxcInxcXFwiKTtcXG4gICAgaWYgKGZsYWdpLmxlbmd0aCA+IDAgJiYgIVtcXFwi5YWo6YOoXFxcIiwgXFxcIuW3suemgeeUqFxcXCJdLmluY2x1ZGVzKGZsYWdpWzBdKSkge1xcbiAgICAgICAgaWYgKCFmbGFnaS5ldmVyeShmID0+IG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0gZ2V0UGFzdGVzKCk7XFxuICAgICAgICAgICAgICAgIG9wcy51bnNoaWZ0KFxcXCLlrozmlbTlj6Pku6RcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQob3BzLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKClbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS51c2VyID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlKSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChuYW1lLCBydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG55WM77yM44CMXFxcIiArIG5hbWUgKyBcXFwi44CNRFJQWeino+aekO+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliKDpmaRcXFwiICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7X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GlwID0gaW5kZXggIT09IHZvaWQoMCkgPyBcXFwi5pu05paw6Kej5p6QXFxcIiA6IFxcXCLlr7zlhaXop6PmnpBcXFwiO1xcbiAgICAgICAgc2V0UGFnZVRpdGxlKHRpcCArIFxcXCI6XFxcIiArIG9iai5uYW1lKTtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJjigJhcXFwiICsgdGlwICsgXFxcIuKAmeKAmVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgb2JqID0ge307XFxuICAgICAgICBiYWNrKCk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl6ZSZ6K+vXFxcIik7XFxuICAgIH1cXG59IGVsc2UgaWYgKGluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgIG9iaiA9IGFycltpbmRleF07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi57yW6L6R6Kej5p6QOlxcXCIgKyBvYmoubmFtZSk7XFxufSBlbHNlIHtcXG4gICAgb2JqID0ge1xcbiAgICAgICAgcnVuVHlwZTogXFxcIldFQlxcXCIsXFxuICAgICAgICBtZXRob2Q6IFxcXCJHRVRcXFwiXFxuICAgIH07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi5paw5bu66Kej5p6QXFxcIik7XFxufVxcblxcbmQucHVzaCh7XFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5ZCN5a2XKOW/heWhqylcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgb25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cXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgICAgICBpZiAoaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4LCBpc0ltcG9ydCkgPT4ge1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIW5hbWUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFwicHNfdXJsXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghdXJsKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmxhZyA9IGdldE15VmFyKFxcXCJwc19mbGFnXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmbGFnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOagh+ivhuS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IGdldE15VmFyKFxcXCJwc19oZWFkZXJzXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIGlmKHR5cGVvZiBoZWFkZXJzIT09XFxcIm9iamVjdFxcXCIpIHRocm93IG5ldyBFcnJvcihcXFwi6ZSZ6K+v57G75Z6L77yM5b+F6aG75Li6T2JqZWN0XFxcIik7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcbiAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIG9iajEpO1xcbiAgICA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sZVRpdGxlID0gZ2V0UGFyYW0oXFxcInJ1bGVcXFwiKTtcXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgbmV3SSA9IDA7XFxuICAgICAgICBmb3IgKGxldCBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5paw5aKe77yaXFxcIiArIG5ld0kgKyBcXFwiIOimhuebluabtOaWsO+8mlxcXCIgKyAocnVsZXMubGVuZ3RoIC0gbmV3SSkpO1xcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIHRvYXN0KFxcXCLlr7zlhaXlpLHotKVcXFwiKTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBpbXBvcnRSdWxlKHBhc3MpIHtcXG4gICAgdHJ5IHtcXG4gICAgICAgIGxldCBbXywgcnVsZSwgcG5hbWVdID0gcGFzcy5zcGxpdChcXFwiJFxcXCIpO1xcb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Xhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICAgICAgICAgJ2FwaSc6ICcuLi9saWJzL2RycHkyLmpzJyxcXG4gICAgICAgICAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdxdWlja1NlYXJjaCc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogXFxcIi4vXFxcIiArIGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIG5hbWVzLnB1c2goaXQubmFtZSk7XFxuICAgIH1cXG4gICAgZGVsZXRlbG9zZShuYW1lcywgcGF0aClcXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgIHNpdGVzOiBydWxlc1xcbiAgICB9KSk7XFxuXFxuICAgIHJldHVybiBcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFwiICsgY291bnQgKyBcXFwi5LiqXFxcIjs7XFxufVxcblxcbmZ1bmN0aW9uIGRlbGV0ZWxvc2UobmFtZXMsIHBhd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5leHQuZW5kc1dpdGgoXFxcIi5qc1xcXCIpID8gZGVjb2RlVVJJQ29tcG9uZW50KGl0LmV4dC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKSkgOiAoaXQubmFtZSArIFxcXCIuanNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGU7XFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGl0LmV4dCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChqb2luVXJsKHVybCwgaXQuZXh0KSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcIi4vXFxcIiArIG5hbWU7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKG5hbWUpO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBkZWxldGVsb3NlKG5hbWVzLCBwYXRoKTtcXG4gICA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iO1xcbiAgICAgICAgICAgIC8vc291cmNlTGlzdD1bXTtcXG4gICAgICAgIH0gZWxzZSBpZiAoY29uZmlnLnBhdGguc3RhcnRzV2l0aChcXFwiaHR0cHM6Ly9naXRodWIuY29tXFxcIikpIHtcXG4gICAgICAgICAgICBzb3VyY2VMaXN0ID0gZ2VuZXJhdGVDb25maWdCeUdpdGh1Yihjb25maWcucGF0aCk7XFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFwiZ2l0aHViRGlyXFxcIjtcXG4gICAgICAgICAgICAvL3NvdXJjZUxpc3Q9W107XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGZldGNoKGNvbmZpZy5wYXRoKSB8fCBcXFwie31cXFwiKSk7XFxuICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8ICFqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgaWYoanNvbi5oYXNPd25Qcm9wZXJ0eShcXFwic2l0ZXNcXFwiKSYmanNvbi5zaXRlcy5oYXNPd25Qcm9wZXJ0eShcXFwiZGF0YVxcXCIpKXtcXG4gICAgICAgICAgICAgICAganNvbi5zaXRlcz1qc29uLnNpdGVzLmRhdGE7XFxuICAgICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLku47nvZHnu5zojrflj5bnmoTphY3nva7mlofku7bkuLrnqbrvvIzor7fmo4Dmn6XnvZHnu5xcXFwiKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAvL2NvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gSlNPTi5wYXJzZShmZXRjaChzZWFyY2hBbGxvd1BhdGgpIHx8IFxcXCJbXVxcXCIpO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGRlbGV0ZUZpbGUoc2VhcmNoQWxsb3dQYXRoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgbG9hZEVycm9yID0gdm9pZCAwO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlLFxcbiAgICAgICAgICAgIHNlYXJjaEFsbG93LFxcbiAgICAgICAgICAgIHNvdXJjZUxpc3RcXG4gICAgICAgIH07XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgbG9hZEVycm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BsZXQgaW5kZXggPSBydWxlcy5maW5kSW5kZXgodiA9PiB2Lm5hbWUgPT09IGl0LmtleSk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IHJ1bGVzW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKGluZGV4LCAwLCBPYmplY3QuYXNzaWduKHt9LCBpdGVtLCB7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtpdC50b2tleX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBgJHtpdC50b2tleX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IGl0ZW0uZXh0ICsgXFxcIj9cXFwiICsgaXQucGFyYW1zLFxcbiAgICAgICAgICAgICAgICAgICAgZGVsOiB2b2lkIDBcXG4gICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICBpdGVtLmRlbCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMuZmlsdGVyKHYgPT4gIXYuZGVsKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICB9XFxuICAgIHJldHVybiBydWxlcztcXG59XFxuXFxuZnVuY3Rpb24gZ2V0TG9hY2xNYXBwaW5nKGRpckZpbGUpIHtcXG4gICAgLy9rZXlAcGFyYW1zQHR5cGVcXG4gICAgbGV0IG1hcHBpbmdQYXRoID0gXFxcImZpbGU6Ly9cXFwiICsgam9pblVybChkaXJGaWxlLCBcXFwiLi9cXFwiKSArIFxcXCIvLm1hcHBpbmcudHh0XFxcIjtcXG4gICAgbGV0IG1hcHBpbmcgPSBbXTtcXG4gICAgaWYgKCFmaWxlRXhpc3QobWFwcGluZ1BhdGgpKSByZXR1cm4gbWFwcGluZztcXG4gICAgdHJ5IHtcXG4gICAgICAgIGxldCBtYXBwaW5nVHh0ID0gZmV0Y2gobWFwcGluZ1BhdGgpO1xcbiAgICAgICAgbWFwcGluZ1R4dC5zcGxpdChcXFwiXFxcXG5cXFwiKS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgIGxldCBba2V5LCBwYXJhbXMsIHRva2V5LCB0eXBlXSA9IHYuc3BsaXQoXFxcIkBcXFwiKTtcXG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gXFxcImJhc2U2NFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zID0gYmFzZTY0RGVjb2RlKHBhcmFtcyk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlID09PSBcXFwidXJpXFxcIikge1xcbiAgICAgICAgICAgICAgICBwYXJhbXMgPSBkZWNvZGVVUklDb21wb25lbnQocGFyYW1zKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbWFwcGluZy5wdXNoKHtcXG4gICAgICAgICAgICAgICAga2V5LFxcbiAgICAgICAgICAgICAgICBwYXJhbXMsXFxuICAgICAgICAgICAgICAgIHRva2V5OiB0b2tleSB8fCBrZXlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0pO1xcblxcbiAgICB9IGNhdGNoIChlKSB7IH1cXG4gICAgcmV0dXJuIG1hcHBpbmc7XFxufVxcbmZ1bmN0aW9uIGV2YWxKcyhjb2RlLCBnbG9iYWwpIHtcXG4gICAgbGV0IENvbnRleHQgPSBvcmcubW96aWxsYS5qYXZhc2NyaXB0LkNvbnRleHQ7XFxuICAgIGxldCBjeCA9IENvbnRleHQuZ2V0Q3VycmVudENvbnRleHQoKTtcXG4gICAgLy9sZXQgZ2xvYmFsID0gb3JnLm1vemlsbGEuamF2YXNjcmlwdC5TY3JpcHRhYmxlT2JqZWN0LmdldFRvcExldmVsU2NvcGUodGhpcyk7XFxuICAgIC8qaWYoIWN4LmdldExhbmd1YWdlVmVyc2lvbigpKXtcXG4gICAgICAgIGN4L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kpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBuYW1lcztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRpcm5hbWUocGEpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHBhdGggPSBqb2luVXJsKGpzUGF0aCwgcGEpO1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGZpbGUgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcblxcbiAgICAgICAgICAgICAgICBpZiAoIShmaWxlLmV4aXN0cygpICYmIGZpbGUuaXNEaXJlY3RvcnkoKSkpIHJldHVybiBuYW1lcztcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgZGlyRmlsZS5saXN0RmlsZXMoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0LmlzRGlyZWN0b3J5KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZXMucHVzaChTdHJpbmcoaXQuZ2V0TmFtZSgpKSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhdGhzO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgc3RhdCgpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICAgIGxvZzogbG9nLFxcbiAgICAgICAgcGF0aDoganNQYXRoLFxcbiAgICAgICAgcGF0aF9kaXI6IGpvaW5VcmwoanNQYXRoLCBcXFwiLi9cXFwiKVxcbiAg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BbXFxuICAgICAgICBcXFwi56ys5LiA56m6KOWQjeensCk65pa55L6/5LiL5qyh5om+5YiwXFxcIixcXG4gICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzlnLDntKLlvJXlnLDlnYBdOumAieaLqUpTT04vVVJM6YCJ6aG577yM54K55Ye75peB6L6555qE6YCJ5oup5Y+v5Lul5rWP6KeI5pys5Zyw5paH5Lu26YCJ5oup5pys5Zyw5YyF55qELmpzb27ntKLlvJXmlofku7bljbPlj6/jgIJcXFxcbijms6jmhI/vvJrkvb/nlKjmraTnp43mlrnlvI/vvIzlnKjmnKzlnLDmlofku7blpLnlhoXmlrDlop7miJbliKDpmaQuanPmupDml7bpnIDopoHoh6rooYzphY3nva4uanNvbuaWh+S7tilcXFwiLFxcbiAgICAgICAgXFxcIuesrOS6jOepuijot6/lvoQpW+Whq+acrOWhq+i/nOeoi+WcsOWdgF0655u05o6l5aGr5YaZ6L+c56iL6ZO+5o6l5Y2z5Y+v5LiA6Iis5piv5LulaHR0cOW8gOWktC5qc29u57uT5bC+77yM5Lmf5Y+v5Y+v5Lul6L6T5YWlZ2l0aHVi5LuT5bqT55qE5paH5Lu25aS55Zyw5Z2A44CC5q2k56eN5pa55byP5Y+v5Lul5L+d5oyB5LiO6L+c56iL6YWN572u6ICF5ZCM5q2l5pu05paw77yM5L2G5LiN5aaC5pys5Zyw5b+r44CCXFxcIixcXG4gICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzlnLDmlofku7blpLnlnLDlnYBdOumAieaLqeaWh+S7tuWkuemAiemhue+8jOWPr+S7peebtOaOpei+k+WFpWpz5rqQ5omA5ZyoI+aWh+S7tuWkuSEhISPnmoTot6/lvoTvvIzkuZ/lj6/ku6Xngrnlh7vml4HovrnpgInmi6nmtY/op4jmnKzlnLDot6/lvoTpgInmi6kj5paH5Lu25aS5ISEhI++8jOS9v+eUqOivpeenjeaWueazle+8jOWcqOaWh+S7tuWkueaWsOWinuaIluW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ICAgICAgICAgICAgLy8g5qOA5p+l5paH5Lu25ZCN5piv5ZCm5LulLmpz57uT5bC+XFxuICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBqc0ZpbGVzLnB1c2goZik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7IH1cXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcblxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgIH1cXG4gICAgICB9O1xcbiAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxuICAgICAgYmUodGFza3MsIHtcXG4gICAgICAgIGZ1bmM6IGZ1bmN0aW9uIChvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAg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biAgICAgICAgY2xlYXJJdGVtKFxcXCJub19sb2FkaW5nXFxcIik7XFxuICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgbGV0IHtcXG4gICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgbmFtZVxcbiAgICAgICAgfSA9IGl0ZW07XFxuICAgICAgICBpZiAocGF0aC5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOWKoOi9vemFjee9ri4uLlxcXCIpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgIG5hbWUsXFxuICAgICAgICB9KSkge1xcblxcbiAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICBEcnB5TWFuYWdlLmNsZWFyKCk7XFxuICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAkLnJlcXVpcmUoXFxcIkNoYW5nZVNvdXJjZVBvcFxcXCIpLnNob3coMTAwKTtcXG4gICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liIfmjaLlpLHotKVcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgIH0sIGl0ZW0pLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgaWQ6ICdwYXRoJyArIG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ICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgbmF0dXJhbCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLkvb/nlKjmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIGxldCB1c2luZ3N0ID0gZ2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAodXNpbmdzdCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgdXNpbmdzdCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChzID09IFxcXCLliLfmlrDphY3nva5cXFwiKSB7XFxuICAgICAgICAgICAgaGlrZXJQb3AucnVuT25OZXdUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXG4gICAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXG4gICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgIGlmICghcnVudGltZUNvbmZpZy5pbml0RGVmYXVsdCgpKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLliLfmlrDlpLHotKVcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuXFxuICAgICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcbiAgICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXG5cXG4gICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxuICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICBsb2coXFxcIuaWsOWinjpcXFwiICsgYWxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCLmlrDlop5cXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICBkbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3Quc3BsaWNlKG1hbmFnZS5saXN0LmluZGV4T2YoeC5uYW1lKSwgMSk7XFxuICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICBsb2coXFxcIuenu+mZpDpcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCIg56e76ZmkXFxcIiArIGRsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLnJ1bk9uVUlUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2Uuc2V0VGl0bGUoXFxcIumAieaLqeinhumikea6kCDlvZPliY3lhbE6XFxcIiArIG1hbmFnZS5saXN0Lmxlbmd0aCArIFxcXCLkuKrop4bpopHmupBcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXCIg5pu05aSa6K+m5oOF55yLbG9nXFxcIik7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5bey5Yi35pawXFxcIik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi6Z2S5bCR5bm05qih5byPXFxcIikpIHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBzZWxlY3QoKSB7XFxuICAgICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICAgICAgICAgIFxcXCJ0aXRsZVxcXCI6IFxcXCLpgInmi6lcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwib3B0aW9uc1xcXCI6IFtcXFwi5Li05pe25YWz6ZetXFxcIiwgXFxcIuWFs+mXrVxcXCIsIFxcXCLorr7nva7lr4bnoIFcXFwiXSxcXG4gICAgICAgICAgICAgICAgY29sOiAxLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuXFxuICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLkuLTml7blhbPpl61cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwidGVtcExlYWNoXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT0gXFxcIuWFs+mXrVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibGVhY2hcXFwiKTtcXG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIsIFxcXCLorr7nva7lr4bnoIFcXFxcbuaMh+e6ueS4jeiDveeUqOaXtuacieaViFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hQYXNzXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibGVhY2hQYXNzXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S9v+eUqOm7mOiupOWvhueggVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgbGVhY2hQYXNzID0gZ2V0SXRlbShcXFwibGVhY2hQYXNzXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmIChzLmluY2x1ZGVzKFxcXCLlhbPpl61cXFwiKSkge1xcblxcbiAgICAgICAgICAgICAgaWYgKGhpa2VyUG9wLmNhbkJpb21ldHJpYygpICE9PSAwICYmICFsZWFjaFBhc3MpIHtcXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuiuvue9ruWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgaGludDogXFxcIuWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXRleHQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WvhueggeS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJsZWFjaFBhc3NcXFwiLCB0ZXh0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ0ZW1wTGVhY2hcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuaJk+W8gOi/h+a7pFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ0ZW1wTGVhY2hcXFwiKTtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuaJk+W8gOi/h+a7pFxcXCIpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBpZiAoaGlrZXJQb3AuY2FuQmlvbWV0cmljKCkgIT09IDApIHtcXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICBjb250ZW50OiBcXFwi6L6T5YWl5a+G56CB6L+b6KGM5YWz6ZetXFxcIixcXG4gICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui+k+WFpeWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgaGludDogXFxcIuWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dCA9PT0gbGVhY2hQYXNzIHx8ICghbGVhY2hQYXNzICYmIHRleHQgPT09IFN0cmluZyhwcykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdCgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WvhueggemUmeivr1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5jaGVja0J5QmlvbWV0cmljKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICBoaWtlclBvcC5ydW5Pbk5ld1RocmVhZCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHBvcC5kaXNtaXNzKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICAgICAgICB0aXRsZTogXFxcIue8lueggeexu+Wei1xcXCIsXFxuICAgICAgICAgICAgICBvcHRpb25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8vc291cmNlLmV4dOW/hemhu+S4uue7neWvuei3r+W+hFxcbmZ1bmN0aW9uIGdldEJ5U291cmNlKHNvdXJjZSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICBsZXQga2V5ID0gc291cmNlLmtleTtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBkcnB5ID0gY3JlYXRlTmV3RHJweShzb3VyY2UpO1xcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcnVuUHJveHkoZHJweSwgYXJncykge1xcbiAgICBpZiAodHlwZW9mIGRycHkucHJveHkgPT09IFxcXCJmdW5jdGlvblxcXCIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTEgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLmFjcXVpcmUoKTtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMiA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjHnrYnlvoXml7bpl7Q6XFxcIiArICh0aW1lMiAtIHRpbWUxKSArI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hbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICBjYW5TZWFyY2hTb3VyY2UuZm9yRWFjaCgodiwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxuICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgIH0sXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nKGEubmFtZSkubG9jYWxlQ29tcGFyZShTdHJpbmcoYi5uYW1lKSwgdW5kZWZpbmVkLCB7XFxuICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNCkge1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICghc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpKSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShwb3BUaXRsZShzZWFyY2hBbGxvdy5sZW5ndGgpKTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICh0ZW1saXN0LmluY2x1ZGVzKHYua2V5KSkgcmV0dXJuO1xcbiAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKHBvcFRpdGxlKHNlYXJjaEFsbG93Lmxlbmd0aCkpO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgfSk7XFxu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ICAgICAgaWYgKGNhdGVfdGVtcFtpbmRleF0gPT0gaSkge1xcbiAgICAgICAgICAgIHQgPSBcXFwiPGI+PGZvbnQgY29sb3I9XFxcIiArIGNvbG9yICsgXFxcIj5cXFwiICsgdCArIFxcXCI8L2ZvbnQ+PC9iPlxcXCI7XFxuICAgICAgICAgICAgZmxbeC5rZXldID0gaXQudjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoY2F0ZV90ZW1wW2luZGV4XSA9PSBcXFwiLTFcXFwiKSB7XFxuICAgICAgICAgICAgZmxbeC5rZXldID0gXFxcInVuZGVmaW5lZFxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGZvbGQgPT0gMSkge1xcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIHQsXFxuICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBvLmk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJpc19kZWZcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV9vYmogPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcbiAgICAgICAgICAgICAgICAvL3N0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX3RlbXBcXFwiLCBjYXRlX3RlbXApO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCBjYXRlX29iaik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCxcXG4gICAgICAgICAgICAgICAgY2F0ZV90ZW1wOiBjYXRlX3RlbXAsXFxuICAgICAgICAgICAgICAgIGk6IGksXFxuICAgICAgICAgICAgICAgIGNhdGU6IGNhdGVcXG4gICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgIH0pXFxuICAgIH1cXG4gIH1cXG59XFxuXFxuZnVuY3Rpb24gZ2V0RmwoKSB7XFxuICBmbCA9IE9iamVjdC5rZXlz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zcGxpdChcXFwiJFxcXCIpWzFdO1xcbiAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgdXJsID0gaWQuc3BsaXQoXFxcIkBAXFxcIilbMF07XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wYXJzZSh1cmwsIGlkLCBzb3VyY2UpO1xcbiAgICAgICAgfSwgc291cmNlLCBpZCk7XFxuICAgICAgICBjaWQgPSBpZDtcXG4gICAgICB9XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBuYW1lLFxcbiAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXFxuICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgIGNvbF90eXBlOiBob21lTGlzdENvbCxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgICAgdm9kSWQ6IGlkLFxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXFxuICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXksXFxuICAgICAgICAgIGlkOiBjaWQsXFxuICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuiBmuWQiOaQnOe0olxcXCIsXFxuICAgICAgICAgICAganM6IFxcXCJwdXRNeVZhcigndGVtc21vZGUnLCAnMScpOydoaWtlcjovL3NlYXJjaD9ydWxlPScgKyBNWV9SVUxFLnRpdGxlICsgJyZzPVxcXCIgKyBuYW1lICsgXFxcIic7XFxcIlxcbiAgICAgICAgICB9XVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICB9XFxuICB9XFxuICBkZWxldGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwibG9hZFxcXCIpO1xcbn1cXG5cXG5mdW5jdGlvbiBzZXREcnB5UGF0aChkKS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maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5pbml0KHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpKTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIH0pXFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLph43ovb3mupBcXFwiLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSlcXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIuafpeeci+a6kOS7o+eggVxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgbGV0IGNvZGUgPSBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5ydW5NYWluKFxcXCJsZXQgbWFpbj1cXFwiICsgJC50b1N0cmluZygoZXh0KSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuICgpID0+IGdldE9yaWdpbmFsSnMocmVxdWVzdChleHQsIHtcXG4gICAgICAgICAgICAgICdtZXRob2QnOiAnR0VUJ1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgfSwgcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlUGF0aCgpKSk7XFxuXFxuICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL3ZpZXdTb3VyY2VDb2RlLmpzXFxcIjtcXG4gICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGNvZGUpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICB9KVxcbiAgICAgIH1dLmNvbmNhdChjb25maWcudHlwZSA9PT0gXFxcImxvY2FsRGlyXFxcIiA/IFt7XFxuICAgICAgICB0aXRsZTogXFxcIue8lui+keWPguaVsOaYoOWwhOihqFxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygocGF0aCkgPT4ge1xcbiAgICAgICAgICBwYXRoICs9IFxcXCIvLm1hcHBpbmcudHh0XFxcIjtcXG4gICAgICAgICAgaWYgKGZpbGVFeGlzdChwYXRoKSkge1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLkv53lrZjlkI7liLfmlrDphY3nva7miJbph43lkK/miY3kvJrnlJ/mlYhcXFwiKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgcmV0dXJuICQoXFxcIuS4jeWtmOWcqOaYoOWwhOaWh+S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XCJHaXRIdWJSQVflnLDlnYBcXFwiKSB7XFxuICAgICAgICBjb25zdCBoaWtlclBvcCA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9Njk2NlxcXCIpO1xcbiAgICAgICAgbGV0IGRlZiA9IFxcXCJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb21cXFwiO1xcbiAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLovpPlhaXlnLDlnYBcXFwiLFxcbiAgICAgICAgICBoaW50OiBcXFwi5Li656m66buY6K6kXFxcIixcXG4gICAgICAgICAgY29udGVudDogXFxcIum7mOiupDpcXFwiICsgZGVmLFxcbiAgICAgICAgICBkZWZhdWx0VmFsdWU6IGdldEl0ZW0oXFxcImdpdGh1YnJhd1xcXCIsIGRlZiksXFxuICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgIGlmICh0ZXh0ID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJnaXRodWJyYXdcXFwiLCBkZWYpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJnaXRodWJyYXdcXFwiLCB0ZXh0KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGlmICghcnVudGltZUNvbmZpZy5pbml0RGVmYXVsdCgpKSB7XFxuICAgICAgICAgICAgICB0b2FzdChcXFwi5Yi35paw5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5bey5L+d5a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dWlDb25maWc6IHtcXG4gICAgICB1YzogdWlfY29uZmlnLFxcbiAgICAgIGRlZjogZGVmLFxcbiAgICAgIGRlZXBPYmplY3RQcm9wZXJ0eShvYmosIHBhdGgsIHZhbHVlKSB7XFxuICAgICAgICB2YXIgcGFydHMgPSBwYXRoLnNwbGl0KCcuJyk7XFxuICAgICAgICB2YXIgY3VycmVudCA9IG9iajtcXG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcGFydHMubGVuZ3RoIC0gMTsgaSsrKSB7XFxuICAgICAgICAgIHZhciBwYXJ0ID0gcGFydHNbaV07XFxuICAgICAgICAgIGlmICghY3VycmVudFtwYXJ0XSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRbcGFydF0gPSB7fTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtwYXJ0XTtcXG4gICAgICAgIH1cXG4gICAgICAgIGN1cnJlbnRbcGFydHNbcGFydHMubGVuZ3RoIC0gMV1dID0gdmFsdWU7XFxuICAgICAgfSxcXG4gICAgICBnZXQoKSB7XFxuICAgICAgICBsZXQgdWMgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB0aGlzLnVjKTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyh1YykubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgdWMgPSB0aGlzLmRlZjtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiB1YztcXG4gICAgICB9LFxcbiAgICAgIHNldCh2YWx1ZSwga2V5KSB7XFxuICAgICAgICBsZXQgdWMgPSB0aGlzLmdldCgpO1xcbiAgICAgICAgaWYgKGtleSkge1xcbiAgICAgICAgICB0aGlzLmRlZXBPYmplY3RQcm9wZXJ0eSh1Yywga2V5LCB2YWx1ZSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB1YyA9IHZhbHVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgc3RvcmFn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gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9XFxuXFxuICAgICAgICAgIGxldCBjdXJyZW50ID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgIGlmIChPYmplY3Qua2V5cyhjdXJyZW50KS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogY3VycmVudC50aXRsZSxcXG4gICAgICAgICAgICAgIHBpYzogY3VycmVudC5waWMgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBkZXNjOiBjdXJyZW50LmRlc2MgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBjb2xfdHlwZTogY3VycmVudC50eXBlLFxcbiAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGl0ZW0uZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAga2V5OiBjdXJyZW50LmV4dHJhLmtleSxcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGN1cnJlbnQuZXh0cmEuaW5kZXhcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShjdXJyZW50LmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaXRlbS50aXRsZSxcXG4gICAgICAgICAgICAgIHBpYzogaXRlbS5waWMgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBkZXNjOiBpdGVtLmRlc2MgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBjb2xfdHlwZTogaXRlbS50eXBlLFxcbiAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGN1cnJlbnQuZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAga2V5OiBpdGVtLmV4dHJhLmtleSxcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGl0ZW0uZXh0cmEuaW5kZXhcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IG5hcnIgPSAkLnN3YXBBcnJheUVsZW1lbnRzKGluZGV4cywgY3VycmVudC5leHRyYS5pbmRleCwgaXRlbS5leHRyYS5pbmRleCk7XFxuXFxuICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQobmFyciwgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidWlfY3VycmVudFxcXCIpO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBoID0gJ+KAnOKAnOKAneKAnSc7XFxuICAgICAgICAgICAgbGV0IHRpdGxlID0gaXRlbS50aXRsZTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi6YCJ5oup56e75Yqo55qE55uu5qCHXFxcIik7XFxuICAgICAgICAgICAgaWYgKC90ZXh0X2ljb258YXZhdGFyfGljb25fc21hbGxfMy8udGVzdChpdGVtLnR5cGUpKSB7XFxuICAgICAgICAgICAgICBoID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICB0aXRsZSA9IHRpdGxlLmZvbnRjb2xvcihcXFwiI2ZmZlxcXCIpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoL2ljb25fMV9zZWFyY2gvLnRlc3QoaXRlbS50eXBlKSkge1xcbiAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgdGl0bGUgPSBcXFwi4p6h77iPXFxcIiArIHRpdGxlO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICB0aXRsZSA9IHRpdGxlLmZvbnRjb2xvcihcXFwiI2ZmZlxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB1cGRhdGVJdGVtKGl0ZW0uZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBoICsgdGl0bGUsXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwidWlfY3VycmVudFxcXCIsIGl0ZW0pO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpKVxcbiAgICAgICAgaXRlbVtcXFwiZXh0cmFcXFwiXSA9IHtcXG4gICAgICAgICAga2V5OiBpdGVtLmtleSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIsXFxuICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIgKyBpLFxcbiAgICAgICAgICBpbmRleDogaXRlbS5pbmRleCxcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChpdGVtLmtleSAhPSBcXFwi6K6+572uXFxcIikge1xcbiAgICAgICAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6ZmkXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcImluZGV4XFxcIl0gPSAtMTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgfSwgaXRlbS5rZXkpXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoIS9pY29uXzFfc2VhcmNofGF2YXRhci8udGVzdChpdGVtLmNvbF90eXBlKSkge1xcbiAgICAgICAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5pu05o2i5Zu+5qCHXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIikuaW5wdXQoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcImltZ1xcXCJdID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgaWQgPSBmaW5kSXRlbXNCeUNscyhNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIpLmZpbHRlcih4ID0+IHguZXh0cmEua2V5ID09IGtleSlbMF0uZXh0cmEuaWQ7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWQsIHsgcGljOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgfSwga2V5KVxcbiAgICAgICAgICAgIH0sIGl0ZW0ua2V5KVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuaNoua6kFxcXCIgJiYgaXRlbS5rZXkgIT0gXFxcIuaQnOe0ouaooeW8j1xcXCIpIHtcXG4gICAgICAgICAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLkv67mlLnlkI3np7BcXFwiLFxcbiAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIikuaW5wdXQoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwidGl0bGVcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA9PSBrZXkpWzBdLmV4dHJhLmlkO1xcbiAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWQsIHsgdGl0bGU6IGlucHV0IH0pXFxuICAgICAgICAgICAgICAgIH0sIGtleSlcXG4gICAgICAgICAgICAgIH0sIGl0ZW0ua2V5KVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGl0ZW0uZXh0cmEuTG9uZ0NsaWNrID0gbG9uZ2NsaWNrcztcXG4gICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgIH0pXFxuICAgIH0gZWxzZSB7XFxuICAgICAgdWlvYmogPSB1aW9iai5tYXAoKGl0ZW0sIGkpID0+IHtc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lbXNbaV1bXFxcImluZGV4XFxcIl0gPSBpbmRleDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpdGVtLmtleSwgb2JqLmluZGV4KVxcbiAgICAgICAgb2JqLnRpdGxlID0gb2JqLmtleTtcXG4gICAgICAgIGlmIChvYmouZXh0cmEgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgIG9iai5leHRyYSA9IHt9O1xcbiAgICAgICAgfVxcbiAgICAgICAgb2JqLmV4dHJhLmlkID0gTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgb2JqLmtleTtcXG4gICAgICAgIG9iai5leHRyYS5jbHMgPSBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCI7XFxuXFxuICAgICAgICBpZiAob2JqLmNvbF90eXBlID09IFxcXCJpbnB1dFxcXCIpIHtcXG4gICAgICAgICAgb2JqLmNvbF90eXBlID0gXFxcImljb25fMV9zZWFyY2hcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgZC5wdXNoKG9iailcXG4gICAgICB9KVxcbiAgICB9XFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIlxcbiAgICB9LCB7XFxuICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgKHVpbW9kZSA/IFxcXCLkv67mlLlcXFwiLmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiBcXFwi5L+u5pS5XFxcIiksXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGxldCB1aW1vZGUgPSBnZXRNeVZhcihcXFwidWltb2RlXFxcIiwgXFxcIjBcXFwiKTt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XG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICB9KSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgTG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWkjeWItlxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICBjb3B5KEpTT04uc3RyaW5naWZ5KHVpX2NvbmZpZy55aSkpO1xcbiAgICAgICAgICB9LCB1aV9jb25maWcpLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWvvOWFpVxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIikuaW5wdXQoKHVjKSA9PiB7XFxuICAgICAgICAgICAgICB2YXIgeWkgPSB7fTtcXG4gICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHlpID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgICAgIGlmICh5aS5oYXNPd25Qcm9wZXJ0eShcXFwidWlcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgIHVjLnlpID0geWk7XFxuICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWMpO1xcbiAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgdWMpXFxuICAgICAgICAgIH0sIHVpX2NvbmZpZylcXG4gICAgICAgIH1dXFxuICAgICAgfVxcbiAgICB9KVxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZykgPT4ge1xcbiAgICAgICAgdWlfY29uZmlnID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgIGxldCBhbGxfY29scyA9IFsnJ10uY29uY2F0KGdldENvbFR5cGVzKCkpO1xcbiAgICAgICAgYWxsX2NvbHMgPSBhbGxfY29scy5maWx0ZXIoeCA9PlxcbiAgICAgICAgICAvKGljb24pLy50ZXN0KHgpICYmIHggIT0gJ3RleHRfaWNvbicgJiZcXG4gICAgICAgICAgeCAhPSBcXFwiaWNvbl8xX3NlYXJjaFxcXCIpO1xcbiAgICAgICAgLy9sb2coYWxsX2NvbHMpXFxuICAgICAgICBsZXQgY29sID0gdWlfY29uZmlnLnlpLmNvbDtcXG4gICAgICAgIGxldCDmjInpkq7moLflvI8gPSBhbGxfY29scy5tYXAoKGl0KSA9PiB7XFxuICAgICAgICAgIHJldHVybiBpdCA9PT0gY29sID8gJ+Keoe+4jycgKyBpdCA6IGl0O1xcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgdGlwcyA9ICfor7fpgInmi6nlpLTpg6jmjInpkq7moLflvI8nO1xcbiAgICAgICAgcmV0dXJuICQo5oyJ6ZKu5qC35byPLCAyLCB0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AgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICB9KSxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfaWNvblxcXCJcXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuWIhumhteWvvOiIqlxcXCIsXFxuICAgICAgaW1nOiBidXR0b25JbWcodWlfY29uZmlnLmVyLuWIhumhteWvvOiIqiksXFxuICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2ljb25cXFwiLFxcbiAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBsZXQgcGEgPSAkLnVpQ29uZmlnLmdldCgpLmVyLuWIhumhteWvvOiIqjtcXG4gICAgICAgIGxvZyhwYSlcXG4gICAgICAgIGlmIChwYSkge1xcbiAgICAgICAgICBwYSA9IGZhbHNlO1xcbiAgICAgICAgfSBlbHNlIGlmICghcGEpIHtcXG4gICAgICAgICAgcGEgPSB0cnVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICQudWlDb25maWcuc2V0KHBhLCBcXFwiZXIu5YiG6aG15a+86IiqXFxcIik7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pXFxuICAgIH0pXFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLov5jljp9cXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZywgZGVmKSA9PiB7XFxuICAgICAgICByZXR1cm4gJChcXFwi5piv5ZCm5oGi5aSN6K6+572uXFxcIikuY29uZmlybSgodWlfY29uZmlnLCBkZWYpID0+IHtcXG4gICAgICAgICAgdWlfY29uZmlnLmVyID0gZ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gICAgbGV0IGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZhbHVlLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxuICAgICAgICAgICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBwYXRoO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgICAgICAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBwYXRoW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W2tleV07XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBjdXJyZW50O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IE1ZX1BBUkFNUy5ydW5UeXBlWzBdO1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pKTtcXG4gICAgICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFwiSlNPTlxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBwYXJhbS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IE9iamVjdC5hc3NpZ24oe30sIHBhcmFtLmhlYWRlcnMgfHwge30sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiBnZXRKc29uKGpzb24sIHRvUGF0aChwYXJhbS5qc29uUGF0aCkpLFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09IFxcXCJKU1xcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcnNlO1xcbiAgICAgICAgICAgICAgICBpZiAoTVlfUEFSQU1TLmluZGV4KSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyB0aXRsZSkuZ2V0SnNvbigpW01ZX1BBUkFNUy5pbmRleFswXV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKGRlY29kZVVSSUNvbXBvbmVudChNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IHJlcyA9IG5ldyBGdW5jdGlvbihcXFwidXJsXFxcIiwgXFxcInNlbGZcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzID09PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiByZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgkLnR5cGUocmVzKSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZG9KcyhNWV9QQVJBTVMsIHRpdGxlLCBna2V5KSB7XFxuICAgICAgICBsZXQge1xcbiAgICAgICAgICAgIEdNXFxuICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEuc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udWxsKSB7XFxuICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICAgICAgICAgIC8vIOWmguaenOaciemHjeWRveWQjeWbnuiwg+WHveaVsO+8jOWImeiwg+eUqOWug1xcbiAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZW5hbWVDYWxsYmFjayA9PT0gJ2Z1bmN0aW9uJykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gW3JlbmFtZUNhbGxiYWNrKGtleSwgdmFsdWUpLCB2YWx1ZV07XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICByZXR1cm4gW2tleSwgdmFsdWVdO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGNvbnN0IGZpbHRlcmVkRW50cmllcyA9IHNob3VsZEV4Y2x1ZGUgP1xcbiAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx0ZXIoKFtrZXldKSA9PiAha2V5c1RvSGFuZGxlLmluY2x1ZGVzKGtleSkpIDpcXG4gICAgICAgICAgICAgIHByb2Nlc3NlZEVudHJpZXMuZmlsdGVyKChba2V5XSkgPT4ga2V5c1RvSGFuZGxlLmluY2x1ZGVzKGtleSkpO1xcbiAgICAgICAgICAgIHJldHVybiBPYmplY3QuZnJvbUVudHJpZXMoZmlsdGVyZWRFbnRyaWVzKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDkuI3mmK/lr7nosaHmiJbmlbDnu4TvvIznm7TmjqXov5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ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB0eXBlX2lkOiBpdGVtLnRpZC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKClcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGZvciBlYWNoKGxldCBpdGVtIGluIGhvbWVYbWwuY2xhc3MudHkpIHtcXG4gICAgICAgICAgICBob21lLmNsYXNzLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0eXBlX2lkOiBpdGVtLkBpZCxcXG4gICAgICAgICAgICAgICAgdHlwZV9uYW1lOiBpdGVtLnRvU3RyaW5nKCksXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShob21lLmNsYXNzKSAmJiBBcnJheS5pc0FycmF5KHRoaXMuY2F0ZWdvcnlmaWx0ZXIpKSB7XFxuICAgICAgICAgICAgaG9tZS5jbGFzcyA9IGhvbWUuY2xhc3MuZmlsdGVyKHYgPT4gdGhpcy5jYXRlZ29yeWZpbHRlci5pbmNsdWRlcyh2LnR5cGVfbmFtZSkpXFxuICAgICAgICB9XFxuXFxuICAgICAgICB0aGlzLmNhY2hlQ2xhc3MgPSBob21lO1xcblxcbiAgICAgICAgcmV0dXJuIGhvbWU7XFxuICAgIH0sXFxuICAgIGhvbWVWb2QoKSB7XFxuICAgICAgICBsZXQgZGF0YSA9IHRoaXMuZ2V0SG9tZURhdGEoKTtcXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgbGlzdDogZGF0YS5saXN0IHx8IFtdXFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgaG9tZSgpIHtcXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh0aGlzLmdldEhvbWVEYXRhKCkpO1xcbiAgICB9LFxcbiAgICBjYXRlZ29yeSh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mwsXFxuICAgICAgICB9KSkucmVwbGFjZSgvXFxcXDwuKj94bWwuKj9cXFxcPi8sIFxcXCJcXFwiKTtcXG4gICAgICAgIGxldCBob21lWG1sID0gbmV3IFhNTCh4bWwpO1xcbiAgICAgICAgbGV0IGxpc3QgPSBbXTtcXG4gICAgICAgIGZvciBlYWNoKGxldCBpdGVtIGluIGhvbWVYbWwubGlzdC52aWRlbykge1xcbiAgICAgICAgICAgIGxldCByZXNpdGVtID0ge1xcbiAgICAgICAgICAgICAgICB2b2RfaWQ6IGl0ZW0uaWQudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX25hbWU6IGl0ZW0ubmFtZS50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfdGltZTogaXRlbS5sYXN0LnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9waWM6IGl0ZW0ucGljLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9yZW1hcmtzOiBpdGVtLm5vdGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX2NvbnRlbnQ6IGl0ZW0uZGVzLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9hY3RvcjogaXRlbS5hY3Rvci50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfZGlyZWN0b3I6IGl0ZW0uZGlyZWN0b3IudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGxldCBmcm9tID0gW107XFxuICAgICAgICAgICAgbGV0IHBsYXkgPSBbXTtcXG4gICAgICAgICAgICBmb3IgZWFjaChsZXQgcGxheUxpc3RJdGVtIGluIGl0ZW0uZGwuZGQpIHtcXG4gICAgICAgICAgICAgICAgZnJvbS5wdXNoKHBsYXlMaXN0SXRlbS5AZmxhZyk7XFxuICAgICAgICAgICAgICAgIHBsYXkucHVzaChwbGF5TGlzdEl0ZW0udG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJlc2l0ZW0udm9kX3BsYXlfZnJvbSA9IGZyb20uam9pbihcXFwiJCQkXFxcIik7XFxuICAgICAgICAgICAgcmVzaXRlbS52b2RfcGxheV91cmwgPSBwbGF5LmpvaW4oXFxcIiQkJFxcXCIpO1xcbiAgICAgICAgICAgIGxpc3QucHVzaChyZXNpdGVtKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgbGlzdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIHBsYXkoZmxhZywgaW5wdXQpIHtcXG4gICAgICAgIGxldCBwYXJzZV91cmwgPSB0aGlzLnNvdXJjZS5wbGF5dXJsIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKC9cXFxcLihtM3U4fG1wNCkvLnRlc3QoaW5wdXQpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaWYgKHBhcnNlX3VybC5zdGFydHNXaXRoKCdqc29uOicpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwdXJsID0gcGFyc2VfdXJsLnJlcGxhY2UoJ2pzb246JywgJycpICsgaW5wdXQ7XFxuICAgICAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChwdXJsKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBKU09OLnBhcnNlKGh0bWwpLnVybFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBpbnB1dFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDEsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHBhcnNlX3VybCArIGlucHV0XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgc2VhcmNoKHdkLCBxdWljaywgcGcpIHtcXG4gICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIHdkOiB3ZCxcXG4gICAgICAgICAgICBwZzogXFxcIlxcXCIgKyBwZ1xcbiAgICAgICAgfSkpLnJlcGxhY2UoL1xcXFw8Lio/eG1sLio/XFxcXD4vLCBcXFwiXFxcIik7XFxuICAgICAgICBsZXQgaG9tZVhtbCA9IG5ldyBYTUwoeG1sKTtcXG4gICAgICAgIGxldCBsaXN0ID0gW107XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmxpc3QudmlkZW8pIHtcXG4gICAgICAgICAgICBsaXN0LnB1c2goe1xcbiAgICAgICAgICAgICAgICB2b2RfaWQ6IGl0ZW0uaWQudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX25hbWU6IGl0ZW0ubmFtZS50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfdGltZTogaXRlbS5sYXN0LnRvU3RyaW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1xcbiAgICAgICAgICAgIGxpc3Q6IGRhdGEubGlzdCB8fCBbXVxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGhvbWUoKSB7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkodGhpcy5nZXRIb21lRGF0YSgpKTtcXG4gICAgfSxcXG4gICAgY2F0ZWdvcnkodGlkLCBwZywgZmlsdGVyLCBleHRlbmQpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwidmlkZW9saXN0XFxcIixcXG4gICAgICAgICAgICB0OiB0aWQsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKTtcXG4gICAgfSxcXG4gICAgZGV0YWlsKHZvZF91cmwpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwiZGV0YWlsXFxcIixcXG4gICAgICAgICAgICBpZHM6IHZvZF91cmwsXFxuICAgICAgICB9KSk7XFxuICAgIH0sXFxuICAgIHBsYXkoZmxhZywgaW5wdXQpIHtcXG4gICAgICAgIGxldCBwYXJzZV91cmwgPSB0aGlzLnNvdXJjZS5wbGF5dXJsIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKC9cXFxcLihtM3U4fG1wNCkvLnRlc3QoaW5wdXQpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaWYgKHBhcnNlX3VybC5zdGFydHNXaXRoKCdqc29uOicpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwdXJsID0gcGFyc2VfdXJsLnJlcGxhY2UoJ2pzb246JywgJycpICsgaW5wdXQ7XFxuICAgICAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChwdXJsKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBKU09OLnBhcnNlKGh0bWwpLnVybFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBpbnB1dFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDEsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHBhcnNlX3VybCArIGlucHV0XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgc2VhcmNoKHdkLCBxdWljaywgcGcpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIHdkOiB3ZCxcXG4gICAgICAgICAgICBwZzogXFxcIlxcXCIgKyBwZ1xcbiAgICAgICAgfSkpO1xcbiAgICB9LFxcbiAgICBnZXRSdWxlKGtleSkge1xcbiAgICAgICAgcmV0dXJuIGtleSA/IHRoaXMucnVsZVtrZXldIDogdGhpcy5ydWxlO1xcbiAgICB9LFxcbiAgICBydW5NYWluKCkge1xcbiAgICAgICAgcmV0dXJuIFxcXCJcXFwiO1xcbiAgICB9XFxufSk7XFxuJC5leHBvcnRzID0gVDFBZGFwdGVyO1wifV0iLCJpY29uIjoiIiwicHJveHkiOiIifQ==
Add Comment
Please, Sign In to add comment