xiaomianao666

小程序:DrpyHiker

Jun 13th, 2024
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjoyNywiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1pYW5Mb2FkXCIpOyIsInNlYXJjaF91cmwiOiJoaWtlcjovL2VtcHR5P3M9KiomcGFnZT1meXBhZ2UiLCJncm91cCI6IuKRoOW4uOeUqCIsInNlYXJjaEZpbmQiOiJqczpcbihmdW5jdGlvbiAoKSB7XG4gIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgbGV0IHRlbXNtb2RlID0gZ2V0TXlWYXIoXCJ0ZW1zbW9kZVwiLCBcIlwiKTtcbiAgaWYgKHRlbXNtb2RlKSB7XG4gICAgc21vZGUgPSBOdW1iZXIodGVtc21vZGUpO1xuICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgfVxuICBpZiAoIWZpbGVFeGlzdChcImhpa2VyOi8vZmlsZXMvZGF0YS9cIiArIE1ZX1JVTEUudGl0bGUgKyBcIi9saWJzX2hpa2VyL2RycHkyLmpzXCIpKSByZXR1cm4gc2V0UmVzdWx0KFt7XG4gICAgdG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uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcblxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcblxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xuICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpLmdldChpdGVtLmtleSk7XG5cbiAgICAgICAgICAgICAgICAgIGxldCBob21lTGlzdCA9IEpTT04ucGFyc2UoZHJweS5zZWFyY2goTVlfS0VZV09SRCwgZmFsc2UsIE1ZX1BBR0UpKS5saXN0IHx8IFtdO1xuICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcbiAgICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnZvZF9uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICAgICAgICAgICAgICAgIHVybDogXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWQjaW1tZXJzaXZlVGhlbWUjXCIsXG4gICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZvZElkOiBpdC52b2RfaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgICBzbmFtZTogaXRlbS5uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2tleTogaXRlbS5rZXksXG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIHNldFJlc3VsdChkKTtcbiAgICAgICAgICAgICAgICB9LCBpdClcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkocnVsZXMpO1xuICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSlcbiAgICAgIH1cbiAgICB9XSk7XG4gIH1cbn0pKCkiLCJkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwiZGV0YWlsX2ZpbmRfcnVsZSI6IiIsInNkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwic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ZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICBvYmoudG9IZXggPSB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmouaGVhZGVycyA9IE9iamVjdC5hc3NpZ24oe1xcbiAgICAgICAgICAgICAgICBDb29raWU6IFxcXCIjbm9Db29raWUjXFxcIlxcbiAgICAgICAgICAgIH0sIG9iai5oZWFkZXJzKTtcXG4gICAgICAgICAgICBpZiAodXJsID09PSBcXFwiaHR0cHM6Ly9hcGkubm4uY2kvb2NyL2I2NC90ZXh0XFxcIiAmJiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1tcXFwiQ29udGVudC1UeXBlXFxcIl0gPSBcXFwidGV4dC9wbGFpblxcXCI7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmICh1cmwuc3RhcnRzV2l0aChcXFwiZmlsZTovL1xcXCIpICYmICh1cmwuaW5jbHVkZXMoXFxcIj90eXBlPVxcXCIpIHx8IHVybC5pbmNsdWRlcyhcXFwiP3BhcmFtcz1cXFwiKSkpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gdXJsLnNsaWNlKDAsIHVybC5sYXN0SW5kZXhPZihcXFwiP1xcXCIpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgZm9yIChsZXQga2V5IGluIG9iai5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygb2JqLmhlYWRlcnNba2V5XSAhPT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW2tleV0gPSBTdHJpbmcob2JqLmhlYWRlcnNba2V5XSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHIgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAvKiBpZiAoU3RyaW5nKG9iai5tZXRob2QpLnRvTG93ZXJDYXNlKCkgPT09IFxcXCJwb3N0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgciA9ICRwb3N0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcbiAgICAgICAgICAgICAgICByID0gSlNPTi5wYXJzZShyKTtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByLmJvZHk7XFxuICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IFtrLCB2XSBvZiBPYmplY3QuZW50cmllcyhyLmhlYWRlcnMgfHwge30pKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXMuaGVhZGVyc1trXSA9IHZbMF07XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlSGV4KHJlcy5jb250ZW50KS50b0Jhc2U2NChfYmFzZTY0Lk5PX1dSQVApO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcmVzO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhcXFwiRXJyb3JcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICAvKlxcbiAgICBjb25zdCBKaW5KYSA9ICQucmVxdWlyZShcXFwiaHR0cHM6Ly9jZG4uYm9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gICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5pWw57uE77yM6YCS5b2S6LCD55SodHJhbnNmb3JtS2V5c1xcbiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xcbiAgICAgICAgICAgIHJldHVybiBpdGVtLnRyYW5zZm9ybUtleXMoa2V5TWFwcGluZyk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGl0ZW0gPT09ICdvYmplY3QnICYmIGl0ZW0gIT09IG51bGwpIHtcXG4gICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrlr7nosaHvvIzkvb/nlKhPYmplY3QuZnJvbUVudHJpZXPlkoxPYmplY3QuZW50cmllc+adpeWkhOeQhumUrlxcbiAgICAgICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyhpdGVtKTtcXG4gICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1lZEVudHJpZXMgPSBlbnRyaWVzLm1hcCgoW2tleSwgdmFsdWVdKSA9PiB7XFxuICAgICAgICAgICAgICBjb25zdCBuZXdLZXkgPSBrZXlNYXBwaW5nW2tleV0gfHwga2V5OyAvLyDlpoLmnpzplK7lnKjmmKDlsITkuK3vvIzkvb/nlKjmlrDplK7vvJvlkKbliJnkvb/nlKjljp/lp4vplK5cXG4gICAgICAgICAgICAgIHJldHVybiBbbmV3S2V5LCB2YWx1ZV07XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5mcm9tRW50cmllcyh0cmFuc2Zvcm1lZEVudHJpZXMpO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICB9LFxcbiAgICA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IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21vdmllLzE0Ni5zdmdcXFwiO1xcbiAgICAgIH0gZWxzZSBpZiAodGMgPj0gMTIgJiYgdGMgPCAxNSkge1xcbiAgICAgICAgY29sID0gXFxcInRleHRfM1xcXCI7XFxuICAgICAgfSBlbHNlIGlmICh0YyA+PSAxNSkge1xcbiAgICAgICAgY29sID0gXFxcInRleHRfMlxcXCI7XFxuICAgICAgICB0ZXh0YWxpZ24gPSBcXFwibGVmdFxcXCI7XFxuICAgICAgfVxcbiAgICAgIGxldCBwbGF5b2JqID0gdC5zcGxpdChcXFwiI1xcXCIpLm1hcCgoaikgPT4ge1xcbiAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICBsZXQgdWlkID0gKGtbMV0gfHwga1swXSk7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBzdGl0bGU6IHQsXFxuICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgfSksXFxuICAgICAgICAgIHN1cmw6IHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0sXFxuICAgICAgICAgIHVybDogaXNOb3ZlbCA/IFxcXCJoaWtlcjovL3BhZ2Uvbm92ZWwjYXV0b1BhZ2UjI3JlYWRUaGVtZSNcXFwiIDogKHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0gKyBwbGF5TGF6eS5yZXBsYWNlKCdcXFwiaWRcXFwiJywgJ1xcXCInICsgdWlkICsgJ1xcXCInKSksXFxuICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcbiAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgIGlkOiBrWzFdLFxcbiAgICAgICAgICAgIC8vbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgfSkqL1xcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9XFxuICAgICAgICB9O1xcbiAgICAgIH0pO1xcblxcbiAgICAgIGlmIChzdHlwZSA9PSBcXFwi5ryr55S7XFxcIiB8fCBzdHlwZSA9PSBcXFwi5bCP6K+0XFxcIikge1xcblxcbiAgICAgICAgdmFyIGRvd25sb2FkbGF6eSA9ICQudG9TdHJpbmcoKGtleSwgc2tleSwgdGl0bGUpID0+IHtcXG4gICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICBHTVxcbiAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTE2JmF1dGg9MWQzNWU4ZjAtMjJlOC01MjcwLWE5ZDEtODI2ZjUzZjE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gICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICB1cmw6ICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbikgPT4ge1xcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICB9LCBsb2NhdGlvbiksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtKys7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9XSlcXG4gICAgICAvKnBsYXlwID0gcGxheXAubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIHRlbXAsIHtcXG4gICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIChwYWdlbnVtID09IGkgPyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KSxcXG4gICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSkgPT4ge1xcbiAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiKSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5bGlzdFxcXCIpO1xcbiAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlsaXN0c1xcXCIsICQudGVtcF9saXN0W2ldKTtcXG4gICAgICA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iAgICAgICAgICB0aXRsZTogc29baWldXFxuICAgICAgICB9KVxcbiAgICAgICAgdmFyIHBsYXlzID0gZmluZEl0ZW1zQnlDbHMoXFxcInBsYXlsaXN0XFxcIikucmV2ZXJzZSgpLm1hcCh4ID0+IHtcXG4gICAgICAgICAgeC5jb2xfdHlwZSA9IHgudHlwZTtcXG4gICAgICAgICAgcmV0dXJuIHg7XFxuICAgICAgICB9KTtcXG4gICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgcGxheXMpO1xcblxcbiAgICAgICAgcHV0TXlWYXIoXFxcInNvcnRpXFxcIiwgaWkpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICB9LCBzb3J0b2JqKSxcXG4gICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBpZDogXFxcIkBzb3J0XFxcIixcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGZvciAobGV0IGkgaW4gZnJvbSkge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogZnJvbVtpXSxcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaSwgaWQpID0+IHtcXG4gICAgICAgICAgaWYgKGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHB1dE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkoaSk7X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0VSXFxcIiA/IFxcXCJoaWtlclxcXCIgOiBcXFwidHh0XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCwgZ2V0UGFzcyhydWxlcy5sZW5ndGgsIHJ1bGViNjQsIFxcXCJhXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJzaGFyZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBydWxlcztcXG4gICAgICAgICAgICBpZiAobW8gPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0yKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0zKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0Rm9yYmlkZGVuSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpLmZpbHRlcigodiwgaSkgPT4gaW5kZXhzLmluY2x1ZGVzKGkpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5tYXAoKHYpID0+IHtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAg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KGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuWujOaVtOWPo+S7pFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHJ1bGViNjQsIFxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSAhcnVsZS5mb3JiaWRkZW47XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXCLnpoHnlKhcXFwiIDogXFxcIuWQr+eUqFxcXCIpICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGksIGxlbmd0aCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGk6IGksXFxuICAgICAgICAgICAgcGFnZVRpdGxlOiBpdC5uYW1lXFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cXG5jb3VudFRpdGxlLnRpdGxlID0gJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPuino+aekOWIl+ihqDxiPiAoJyArICgoZC5sZW5ndGggLSB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BnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgICAgICBsZXQganMgPSBnZXRNeVZhcihcXFwicHNfanNcXFwiLCBcXFwiXFxcIikgfHwgdm9pZCAwO1xcbiAgICAgICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzID0gSlNPTi5wYXJzZShoZWFkZXJzKTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoZWFkZXJz5qC85byP6ZSZ6K+vOlxcXCIgKyBlLnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wcmVwYXJlUGFyc2VzKFt7XFxuICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICAgICAganNcXG4gICAgICAgICAgICB9XSwgaW5wdXQsbnVsbCwgdHJ1ZSk7XFxuICAgICAgICB9KTtcXG4gICAgfSksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIGlzSW1wb3J0KSA9PiB7XFxuICAgICAgICBsZXQgbmFtZSA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ICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBydW5UeXBlID0gZ2V0TXlWYXIoXFxcInBzX3J1blR5cGVcXFwiLCBcXFwiV0VCXFxcIik7XFxuICAgICAgICBsZXQgbWV0aG9kID0gZ2V0TXlWYXIoXFxcInBzX21ldGhvZFxcXCIsIFxcXCJHRVRcXFwiKTtcXG4gICAgICAgIGxldCBqc29uUGF0aCA9IGdldE15VmFyKFxcXCJwc19qc29uUGF0aFxcXCIsIFxcXCJcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcbiAgICAgICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcInBzX2pzXFxcIiwgXFxcIlxcXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgIGlmIChydW5UeXBlID09PSBcXFwiSlNPTlxcXCIgJiYgIWpzb25QYXRoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pTT07mqKHlvI/kuIvlv4Xpobvloatqc29uUGF0aFxcXCI7XFxuICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT09IFxcXCJKU1xcXCIgJiYgIWpzKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pT5qih5byP5LiL5b+F6aG75aGranNcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBvYmoxID0ge1xcbiAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICBqc1xcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgICAgI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ICAgICBydWxlcyA9IFtydWxlc107XFxuICAgICAgICB9XFxuICAgICAgICAvL3J1bGVzLnJldmVyc2UoKTtcXG4gICAgICAgIE1ZX1VSTCA9IG1vZHVsZS5pZDtcXG4gICAgICAgIGxldCBydWxlVGl0bGUgPSBnZXRQYXJhbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXG4gICAgICAgIGZvciAobGV0IHJ1bGUgb2YgcnVsZXMpIHtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA+IDEpIHtcXG4gICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLmlrDlop7vvJpcXFwiICsgbmV3SSArIFxcXCIg6KaG55uW5pu05paw77yaXFxcIiArIChydWxlcy5sZW5ndGggLSBuZXdJKSk7XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgdG9hc3QoXFxcIuWvvOWFpeWksei0pVxcXCIpO1xcbiA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QpO1xcbiAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICBsZXQgcnVsZXMgPSBbXTtcXG4gICAgbGV0IGNvdW50ID0gMDtcXG4gICAgbGV0IG5hbWVzID0gW107XFxuICAgIGlmIChsaXN0Lmxlbmd0aCA9PT0gMCkgcmV0dXJuIFxcXCJ0b2FzdDovL+WPr+iDveWIoOW6k+S6hlxcXCI7XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC5uYW1lO1xcbiAgICAgICAgICAgIGxldCBzcGF0aCA9IGl0LnBhdGg7XFxuICAgICAgICAgICAgaWYgKCFuYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkgY29udGludWU7XFxuICAgICAgICAgICAgbmFtZSA9IG5hbWUuc2xpY2UoMCwgbmFtZS5sYXN0SW5kZXhPZihcXFwiLlxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKGBodHRwczovL3Jhdy5naXRtaXJyb3IuY29tLyR7cm9wZX0vbWFzdGVyLyR7c3BhdGh9YCk7XFxuICAgICAgICAgICAgaWYgKCEoKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpICYmICFmaWxlRXhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICAgICAgICAgJ2FwaSc6ICcuLi9saWJzL2RycHkyLmpzJ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gICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpdC5leHQgPSBcXFwiLi9cXFwiICsgbmFtZTtcXG4gICAgICAgICAgICAgICAgaWYgKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgbmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIG5hbWVzLnB1c2gobmFtZSk7XFxuICAgICAgICAgICAgICAgIGNvdW50Kys7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaSsrO1xcbiAgICB9XFxuICAgIGRlbGV0ZWxvc2UobmFtZXMsIHBhdGgpO1xcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIGNvdW50ICsgXFxcIuS4qlxcXCI7XFxufVxcbiQuZXhwb3J0cy5wYXJzZVVybCA9IGZ1bmN0aW9uICh1cmwsIHBhdGgpIHtcXG4gICAgcGF0aCA9IGJhc2U2NERlY29kZShwYXRoKTtcXG4gICAgcGF0aCA9IHBhdGguZW5kc1dpdGgoXFxcIi9cXFwiKSA/I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Chjb25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJjaEFsbG93UGF0aCkgfHwgXFxcIltdXFxcIik7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZGVsZXRlRmlsZShzZWFyY2hBbGxvd1BhdGgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UsXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxuICAgICAgICAgICAgc291cmNlTGlzdFxcbiAgICAgICAgfTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIG51bGw7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlMb2NhbChkaXJGaWxlKSB7XFxuICAgIGxldCBsaXN0ID0gZGlyRmlsZS5saXN0RmlsZX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gaGlrZXJQb3AuaW5mb0JvdHRvbSh7XFxuICAgICAgY29udGVudDogXFxcIuivpue7hlxcXCIsXFxuICAgICAgb3B0aW9uczogW1xcbiAgICAgICAgXFxcIuesrOS4gOepuijlkI3np7ApOuaWueS+v+S4i+asoeaJvuWIsFxcXCIsXFxuICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5Zyw57Si5byV5Zyw5Z2AXTrpgInmi6lKU09OL1VSTOmAiemhue+8jOeCueWHu+aXgei+ueeahOmAieaLqeWPr+S7pea1j+iniOacrOWcsOaWh+S7tumAieaLqeacrOWcsOWMheeahC5qc29u57Si5byV5paH5Lu25Y2z5Y+v44CCXFxcXG4o5rOo5oSP77ya5L2/55So5q2k56eN5pa55byP77yM5Zyo5pys5Zyw5paH5Lu25aS55YaF5paw5aKe5oiW5Yig6ZmkLmpz5rqQ5pe26ZyA6KaB6Ieq6KGM5Yia5YiaLmpzb27phY3nva7mlofku7YpXFxcIixcXG4gICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzloavov5znqIvlnLDlnYBdOuebtOaOpeWhq+WGmei/nOeoi+mTvuaOpeWNs+WPr+S4gOiIrOaYr+S7pWh0dHDlvIDlpLQuanNvbue7k+Wwvu+8jOS5n+WPr+WPr+S7pei+k+WFpWdpdGh1YuS7k+W6k+eahOaWh+S7tuWkueWcsOWdgOOAguatpOenjeaWueW8j+WPr+S7peS/neaMgeS4jui/nOeoi+mFjee9ruiAheWQjOatpeabtOaWsO+8jOS9huS4jeWmguacrOWcsOW/q+OAglxcXCIsXFxuICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5Zyw5paH5Lu25aS55Zyw5Z2AXTrpgInmi6nmlofku7blpLnpgInpobnvvIzlj6/ku6Xnm7TmjqXovpPlhaVqc+a6kOaJgOWcqCPmlofku7blpLkhISEj55qE6Lev5b6E77yM5Lmf5Y+v5Lul54K55Ye75peB6L656YCJ5oup5rWP6KeI5pys5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ZCm5LulLmpz57uT5bC+XFxuICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBqc0ZpbGVzLnB1c2goZik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7IH1cXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcblxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgIH1cXG4gICAgICB9O1xcbiAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxuICAgICAgYmUodGFza3MsIHtcXG4gICAgICAgIGZ1bmM6IGZ1bmN0aW9uIChvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgLy9sb2cocmV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GEubG9jYWxlQ29tcGFyZShiLCB1bmRlZmluZWQsIHtcXG4gICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXG4gICAgfSk7XFxuICB9XFxuICAvL+S9v+eUqOaOkuW6j1xcbiAgbGV0IHVzaW5nU29ydCA9IHtcXG4gICAgbmFtZTogXFxcInVzaW5nU29ydC5qc29uXFxcIixcXG4gICAgcGF0aDogXFxcImhpa2VyOi8vZmlsZXMvcnVsZXMvRHJweUhpa2VyL1xcXCIsXFxuICAgIHNhdmUoY29udGVudCkge1xcbiAgICAgIHNhdmVGaWxlKHRoaXMucGF0aCArIHRoaXMubmFtZSwgY29udGVudCk7XFxuICAgIH0sXFxuICAgIGluaXQoKSB7XFxuICAgICAgbGV0IGpzb24gPSB7fTtcXG4gICAgICBpZiAoIWZpbGVFeGlzdCh0aGlzLnBhdGggKyB0aGlzLm5hbWUpKSB7XFxuICAgICAgICB0aGlzLnNhdmUoXFxcInt9XFxcIik7XFxuICAgICAgfVxcbiAgICAgIHRyeSB7XFxuICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZSh0aGlzLnBhdGggKyB0aGlzLm5hbWUpKTtcXG4gICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBqc29uID0ge307XFxuICAgICAgICB0aGlzLnNhdmUoXFxcInt9XFxcIik7XFxuICAgICAgfVxcbiAgICAgIHJldHVybiBqc29uO1xcbiAgICB9LFxcbiAgICBzb3J0S2V5c0J5VXNhZ2UoanNvbiwga2V5cykge1xcbiAgICAgIHJldHVybiBrZXlzLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgIGEgPSBhLnJlcGxhY2UoL1vigJnigJhdL2csIFxcXCJcXFwiKTtcXG4gICAgICAgIGIgPSBiLnJlcGxhY2UoL1vigJnigJhdL2csIFxcXCJcXFwiKTtcXG4gICAgICAgIGxldCBBID0ganNvblthXSB8fCAwO1xcbiAgICAgICAgbGV0IEIg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1xcbiAgICAgICAgICAgIGxldCBuYXR1cmFsID0gZ2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAobmF0dXJhbCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIGxpc3Quc29ydChuYXR1cmFsU29ydCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgbmF0dXJhbCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLkvb/nlKjmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIGxldCB1c2luZ3N0ID0gZ2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAodXNpbmdzdCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgdXNpbmdzdCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChzID09IFxcXCLliLfmlrDphY3nva5cXFwiKSB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXG4gICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxuICAgICAgICAgICAgICByZXR1cm4gYXJyMS5maWx0ZXIoaXRlbSA9PiAhbWFwLmhhcyhpdGVtLmtleSkpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcbiAgICAgICAgICAgIC8vbG9nKENrZXkpXFxuICAgICAgICAgICAgbGV0IGNmZyA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpXFxuICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICBuYW1lXFxuICAgICAgICAgICAgfSA9IGNmZztcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50U291cmNlKENrZXkpO1xcbiAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuXFxuICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcblxcbiAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBsb2coXFxcIuaWsOWinjpcXFwiICsgYWxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgaWYgKGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIiDnp7vpmaRcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICBtYW5hZ2Uuc2V0VGl0bGUoXFxcIumAieaLqeinhumikea6kCDlvZPliY3lhbE6XFxcIiArIG1hbmFnZS5saXN0Lmxlbmd0aCArIFxcXCLkuKrop4bpopHmupBcXFwiKTtcXG4gICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXCIg5pu05aSa6K+m5oOF55yLbG9nXFxcIik7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHRvYXN0KFxcXCLlt7LliLfmlrBcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnvJbnoIHnsbvlnotcXF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xzZSk7XFxufVxcblxcbmZ1bmN0aW9uIGdldChrZXkpIHtcXG4gICAgcmV0dXJuIHN5bmMoKCkgPT4ge1xcbiAgICAgICAgLy9sb2coZHJweU1hcC5zaXplKVxcbiAgICAgICAgaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChkcnB5TWFwLnNpemUgPj0gNSkge1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlcygpLmZpbmQodiA9PiB2LmtleSA9PT0ga2V5KTtcXG4gICAgICAgIGNyZWF0ZURycHkoa2V5KTtcXG4gICAgICAgIGxldCBkcnB5ID0gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIGRycHkuaW5pdChydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KSk7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmIChkcnB5LmdldFJ1bGUoXFxcInByb3h5X3J1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgUHJveHkgPSAkLnJlcXVpcmUoXFxcIkxvY2FsUHJveHlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHByb3h5VXJsID0gUHJveHkuc3RhcnRQcm94eShNWV9SVUxFLnRpdGxlLCBHTS5nZXRTZWxmS2V5KCkpO1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiUHJveHlfVXJsXFxcIiwgcHJveHlVcmwpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcbi8vc291cmNlLmV4dOW/hemhu+S4uue7neWvuei3r+W+hFxcbmZ1bmN0aW9uIGdldEJ5U291cmNlKHNvdXJjZSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICBsZXQga2V5ID0gc291cmNlLmtleTtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGNyZWF0ZURycHkoa2V5KTtcXG4gICAgICAgIGxldCBkcnB5ID0gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIGRycHkuaW5pdChzb3VyY2UuZXh0KTtcXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcblxcbmZ1bmN0aW9uIHB1dChrZXksIGRycHkpIHtcXG4gICAgc3luYygoKSA9PiBkcnB5TWFwLnNldChrZXksIGRycHkpLCB0aGlzKS5jYWxsKCk7XFxufVxcblxcbmZ1bmN0aW9uIHJ1blByb3h5KGRycHksIGFyZ3MpIHtcXG4gICAgaWYgKHR5cGVvZiBkcnB5LnByb3h5ID09PSBcXFwiZnVuY3Rpb25cXFwiKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUxID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICBwcm94eVNlbW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ICAgICAgICAgIGlmIChpID09PSAwKSB7XFxuICAgICAgICAgICAgc3BlbiA9IHNwZW4gPT0gMyA/IDEgOiAzO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2VDb2x1bW5zKHNwZW4pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDEpIHtcXG4gICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgY29udGVudDogXFxcIui+k+WFpeWFs+mUruWtlyDnqbrmmL7npLrlhajpg6hcXFwiLFxcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFwi4oCc4oCc4oCd4oCdXFxcIiArICh2Lm5hbWUgKyBcXFwiXFxcIikuZm9udGNvbG9yKFxcXCIjMDA5OTY2XFxcIikgOiB2Lm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcblxcblxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2Uuc29ydCgoYSwgYikgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcblxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxuICAgICAgICAgICAgbGV0IHRlbWxpc3QgPSBzZWFyY2hBbGxvdy5zbGljZSgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKHRlbWxpc3QuaW5jbHVkZXModi5rZX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ZmxbeC5rZXldID0gXFxcInVuZGVmaW5lZFxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGZvbGQgPT0gMSkge1xcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIHQsXFxuICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBvLmk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJpc19kZWZcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV9vYmogPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICA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2VyOi8vc2VhcmNoP3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiJnM9XFxcIiArIG5hbWU7XFxuICAgICAgICB9LCBuYW1lKVxcbiAgICAgIH1cXG4gICAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IG5hbWUsXFxuICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcXG4gICAgICAgIHVybDogdXJsLFxcbiAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcXG4gICAgICAgIGNvbF90eXBlOiBob21lTGlzdENvbCxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgICAgdm9kSWQ6IGlkLFxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXFxuICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXksXFxuICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuiBmuWQiOaQnOe0olxcXCIsXFxuICAgICAgICAgICAganM6IFxcXCJwdXRNeVZhcigndGVtc21vZGUnLCAnMScpOydoaWtlcjovL3NlYXJjaD9ydWxlPScgKyBNWV9SVUxFLnRpdGxlICsgJyZzPVxcXCIgKyBuYW1lICsgXFxcIic7XFxcIlxcbiAgICAgICAgICB9XVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICB9XFxuICB9XFxuICBkZWxldGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwibG9hZFxcXCIpO1xcbn1cXG5cXG5mdW5jdGlvbiBzZXREcnB5UGF0aChkKSB7XFxuICBkLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIue8uuWwkei/kOihjOW6k1xcXFxu6K+l5bCP56iL5bqP5LiN6IO96YCa6L+H5LqR5Ymq6LS05p2/5YiG5Lqr77yM5Y+q6IO96YCa6L+H5omT5YyF5YiG5LqrXFxcIixcXG4gICAgZGVzYzogXFxcIuWwhui/kOih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AgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLph43ovb3mupBcXFwiLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSlcXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIuafpeeci+a6kOS7o+eggVxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgbGV0IGNvZGUgPSBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5ydW5NYWluKFxcXCJsZXQgbWFpbj1cXFwiICsgJC50b1N0cmluZygoZXh0KSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuICgpID0+IGdldE9yaWdpbmFsSnMocmVxdWVzdChleHQsIHtcXG4gICAgICAgICAgICAgICdtZXRob2QnOiAnR0VUJ1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAg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oXFxcImh0dHA6Ly9oaWtlci5ub2tpYS5wcmVzcy9oaWtlcnVsZS9ydWxlbGlzdC5qc29uP2lkPTY5NjZcXFwiKTtcXG4gICAgICAgICAgICBoaWtlclBvcC51cGRhdGVSZWNvcmRzQm90dG9tKFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8xMiAgTWF4VmVyc2lvbiAyNlxcXCIsXFxuICAgICAgICAgICAgICAgIHJlY29yZHM6IFtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrlnKjmjaLmupDnlYzpnaLnmoToj5zljZXlj6/ku6XlvIDlkK/liIbkuqvml7bmmK/lkKbkvb/nlKjnvJbnoIHjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIm9wdGltaXpl77ya5Zyo6YCJ5rqQ55WM6Z2i5Yi35paw6YWN572u5ZCO5Lya5ZCM5q2l5pu05paw5pWw6YeP5pi+56S644CCXFxcIixcXG4gICAgICAgICAgICAgICAgXVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCIyMDI0LzA2LzEwICBNYXhWZXJzaW9uIDI1XFxcIixcXG4gICAgICAgICAgICAgICAgcmVjb3JkczogW1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muWinuWKoOabtOaWsOaXpeW/l+OAglxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwi4oCY4oCYbmV34oCZ4oCZ77ya6YCJ5rqQ6ZW/5oyJ6I+c5Y2V77yM5aKe5Yqg6Lez6L2s572R6aG177yM5p+l55yL5rqQ56CB44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3nvJbovpHop6PmnpDnlYzpnaLmtYvor5Vqc+ino+aekOS4gOebtOWksei0peOAglxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSNZ2l0aHVi6K6i6ZiF77yM5Lya5Yig6Zmk5YWo6YOo6KeE5YiZ5paH5Lu244CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3op6PmnpDosIPnlKjlpLHotKXjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeabtOaNoumFjee9ruaXtuayoeacieWPiuaXtua4heepumRycHnnvJPlrZjjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIm9wdGltaXpl77ya5pu05pS56K6i6ZiF5pu05paw562W55Wl77yM5Lya5Yig6Zmk5pys5Zyw5aSx5pWI5rqQ44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJvcHRpbWl6Ze+8muabtOaWsGRycHkyLmpz44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJvcHRpbWl6Ze+8muS8mOWMluino+aekGZsYWfljLnphY3jgIJcXFwiLFxcblxcbiAgICAgICAgICAgICAgICBdXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIjIwMjQvMDYvMDkgTWF4VmVyc2lvbiAyMFxcXCIsXFxuICAgICAgICAgICAgICAgIHJlY29yZHM6IFtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrmlK/mjIFwcm94eV9ydWxl5Luj55CG44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3kupHnm5jpk77mjqXkuI3osIPlj5bkupHnm5jnroDjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeWTlOWTqeW9seinhuS4jeiDveS9v+eUqOino+aekOOAglxcXCIsXFxuICAgICAgICAgICAgICAgIF1cXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8wOCBNYXhWZXJzaW9uIDE4XFxcIixcXG4gICAgICAgICAgICAgICAgcmVjb3JkczogW1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIm9wdGltaXpl77ya5LyY5YyW6K6+572u6I+c5Y2V5o6S54mI77yM6YOo5YiG55WM6Z2i5aKe5Yqg5o+Q56S644CCXFxcIixcXG4gICAgICAgICAgICAgICAgXVxcbiAgICAgICAgICAgIH1dKTtcXG5cXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIlxcbiAgICB9LCB7XFxuICAgICAgICB0aXRsZTogdGltZSArIFxcXCLnp5LlkI7nu6fnu61cXFwiLFxcbiAgICAgICAgdXJsOiBcXFwidG9hc3Q6Ly/or7forqTnnJ/pmIXor7vku6XkuIrlhoXlrrlcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IGlkICsgXFxcInRpbWVyXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgc2V0UmVzdWx0KGQpO1xcbiAgICB3aGlsZSAodGltZSAhPSAwKSB7XFxuICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDEwMDApO1xcbiAgICAgICAgdGltZSAtPSAxO1xcbiAgICAgICAgdXBkYXRlSXRlbShpZCArIFxcXCJ0aW1lclxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogdGltZSArIFxcXCLnp5LlkI7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yZGVy5pWw57uE5p2l6YeN5paw5o6S5YiXYXJyYXnmlbDnu4RcXG4gICAgb3JkZXIuZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgaWYgKGl0ZW0uaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgLy8g5aaC5p6caW5kZXjmmK8tMe+8jOWwhmtleea3u+WKoOWIsOenu+mZpOWIl+ihqOS4rVxcbiAgICAgICAgICAgIHJlbW92ZWRLZXlzLmFkZChpdGVtLmtleSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIC8vIOWmguaenGluZGV45LiN5pivLTHvvIzliJnlsIblr7nosaHmt7vliqDliLDnu5PmnpzmlbDnu4TkuK3nmoTmjIflrprkvY3nva5cXG4gICAgICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuXFxuICAgICAgICAgICAgaWYgKGl0ZW0uaGFzT3duUHJvcGVydHkoXFxcImltZ1xcXCIpICYmIGl0ZW0uaW1nKSB7XFxuICAgICAgICAgICAgICAgIG9iai5pbWcgPSBpdGVtLmltZ1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoaXRlbS5oYXNPd25Qcm9wZXJ0eShcXFwidGl0bGVcXFwiKSAmJiBpdGVtLnRpdGxlKSB7XFxuICAgICAgICAgICAgICAgIG9iai50aXRsZSA9IGl0ZW0udGl0bGU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmopIHtcXG4gICAgICAgICAgICAgICAgcmVvcmRlcmVkQXJyYXlbaV0gPSBvYmo7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgLy8g5re75Yqg6YKj5Lqb5LiN5Zyob3JkZXLmlbDnu4TkuK3nmoTlr7nosaHvvIzlubbmjpLpmaTnp7vpmaTliJfooajkuK3nmoTpoblcXG4gICAgYXJyYXkuZm9yRWFjaChvYmogPT4ge1xcbiAgICAgICAga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cIikgOiB4KSxcXG4gICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGl0KSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJ1aV9uYXZpXFxcIiwgaXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0sIHgpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIlxcbiAgICAgICAgfSlcXG4gICAgfSlcXG5cXG4gICAgaWYgKHVpX25hdmkgPT0gXFxcIuS4gOe6p1xcXCIpIHtcXG4gICAgICAgIHZhciB1aW9iaiA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJ1aW9ialxcXCIsIFtdKTtcXG4gICAgICAgIHZhciBzdWlvYmogPSB1aW9iai5zbGljZSgpO1xcbiAgICAgICAgbGV0IGl0ZW1zID0gdWlvYmoubWFwKGl0ZW0gPT4ge1xcbiAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgIGtleTogaXRlbS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpdGVtLmluZGV4XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgdWltb2RlID0gZ2V0TXlWYXIoXFxcInVpbW9kZVxcXCIsIFxcXCIwXFxcIikgPT0gXFxcIjBcXFwiID8gZmFsc2UgOiB0cnVlO1xcbiAgICAgICAgaWYgKHVpX2NvbmZpZy55aS51aS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgIHVpX2NvbmZpZy55aS51aSA9IGl0ZW1zXFxuICAgICAgICB9XFxuXFxuICAgICAgICBsZXQgaW5kZXhzID0gdWlfY29uZmlnLnlpLnVpO1xcblxcbiAgICAgICAgdWlvYmogPSB1aW9iai5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgaWYgKCEvKGljb25fMV9zZWFyY2h8YXZhdGFyfGlucHV0KS8udGVzdChpdGVtLmNvbF90eXBlKSkge1xcbiAgICAgICAgICAgICAgICBpdGVtLmNvbF90eXBlID0gdWlfY29uZmlnLnlpLmNvbDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgICB9KVxcblxcbiAgICAgICAgdWlvYmogPSByZW9yZGVyQXJyYXlCeU9yZGVyKHVpb2JqLCBpbmRleHMpO1xcblxcbiAgICAgICAgaWYgKHVpbW9kZSkge1xcbiAgICAgICAgICAgIHVpb2JqID0gdWlvYmoubWFwKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBsb25nY2xpY2tzID0gW107XFxuICAgICAgICAgICAgICAgIGl0ZW0udGl0bGUgPSBpdGVtLmtleTtcXG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0uY29sX3R5cGUgPT0gXFxcImlucHV0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgaXRlbS5jb2xfdHlwZSA9IFxcXCJpY29uXzFfc2VhcmNoXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpdGVtLnVybCA9ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGksIHVpX2NvbmZpZywgaW5kZXhzKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICB1aV9jb25maWcgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHVpX2NvbmZpZy55aS51aS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXhzID0gdWlfY29uZmlnLnlpLnVpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBmaW5kSXRlbShNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIgKyBpKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLnRpdGxlLmluY2x1ZGVzKFxcXCJmb250XFxcIikgfHwgaXRlbS50aXRsZS5pbmNsdWRlcyhcXFwi4p6h77iPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGl0ZW0uZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUucmVwbGFjZSgv4oCYfOKAmXzigJx84oCdfDxbXj5dKz4vZywgXFxcIlxcXCIpLnJlcGxhY2UoXFxcIuKeoe+4j1xcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwidWlfY3VycmVudFxcXCIsIHt9KTtcXG5cXG4gICAgICAgICAgICAgICAgICAgIGlmIChPYmplY3Qua2V5cyhjdXJyZW50KS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBjdXJyZW50LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaWM6IGN1cnJlbnQucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBjdXJyZW50LmRlc2MgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBjdXJyZW50LnR5cGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBpdGVtLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXk6IGN1cnJlbnQuZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXg6IGN1cnJlbnQuZXh0cmEuaW5kZXhcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGN1cnJlbnQuZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpYzogaXRlbS5waWMgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0ZW0uZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IGl0ZW0udHlwZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGN1cnJlbnQuZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleTogaXRlbS5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleDogaXRlbS5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBuYXJyID0gJC5zd2FwQXJyYXlFbGVtZW50cyhpbmRleHMsIGN1cnJlbnQuZXh0cmEuaW5kZXgsIGl0ZW0uZXh0cmEuaW5kZXgpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZy55aS51aSA9IG5hcnI7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBoID0gJ+KAnOKAnOKAneKAnSc7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gaXRlbS50aXRsZTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChcXFwi6YCJ5oup56e75Yqo55qE55uu5qCHXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC90ZXh0X2ljb258YXZhdGFyfGljb25fc21hbGxfMy8udGVzdChpdGVtLnR5cGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKC9pY29uXzFfc2VhcmNoLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSA9IFxcXCLinqHvuI9cXFwiICsgdGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBoICsgdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwidWlfY3VycmVudFxcXCIsIGl0ZW0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgaSwgdWlfY29uZmlnLCBpbmRleHMpXFxuICAgICAgICAgICAgICAgIGl0ZW1bXFxcImV4dHJhXFxcIl0gPSB7XFxuICAgICAgICAgICAgICAgICAgICBrZXk6IGl0ZW0ua2V5LFxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgICAgICAgICAgIGluZGV4OiBpdGVtLmluZGV4LFxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChpdGVtLmtleSAhPSBcXFwi6K6+572uXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSwgdWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9IHVpX2NvbmZpZy55aS51aTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcImluZGV4XFxcIl0gPSAtMTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aV9jb25maWcueWkudWkgPSBpdGVtcztcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBpdGVtLmtleSwgdWlfY29uZmlnKVxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoIS9pY29uXzFfc2VhcmNofGF2YXRhci8udGVzdChpdGVtLmNvbF90eXBlKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNouWbvuagh1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSwgdWlfY29uZmlnLCBpbmRleHMpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXksIHVpX2NvbmZpZywgaW5kZXhzKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aV9jb25maWcgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVpX2NvbmZpZy55aS51aS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXhzID0gdWlfY29uZmlnLnlpLnVpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gaW5kZXhzO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW1nXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZy55aS51aSA9IGl0ZW1zO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaWM6IGlucHV0XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBrZXksIHVpX2NvbmZpZywgaW5kZXhzKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0ZW0ua2V5LCB1aV9jb25maWcsIGluZGV4cylcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuaNoua6kFxcXCIgJiYgaXRlbS5rZXkgIT0gXFxcIuaQnOe0ouaooeW8j1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuS/ruaUueWQjeensFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXksIHVpX2NvbmZpZywgaW5kZXhzKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIikuaW5wdXQoKGtleSwgdWlfY29uZmlnLCBpbmRleHMpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aV9jb25maWcgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1aV9jb25maWcueWkudWkubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleHMgPSB1aV9jb25maWcueWkudWk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9IGluZGV4cztcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcInRpdGxlXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlfY29uZmlnLnlpLnVpID0gaXRlbXM7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaWQgPSBmaW5kSXRlbXNCeUNscyhNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIpLmZpbHRlcih4ID0+IHguZXh0cmEua2V5ID09IGtleSlbMF0uZXh0cmEuaWQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwga2V5LCB1aV9jb25maWcsIGluZGV4cylcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXRlbS5rZXksIHVpX2NvbmZpZywgaW5kZXhzKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXRlbS5leHRyYS5Mb25nQ2xpY2sgPSBsb25nY2xpY2tzO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICB1aW9iaiA9IHVpb2JqLm1hcCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICBpdGVtLmV4dHJhID0ge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgICAgICAgICAgICBjbHM6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgICAgICBkID0gZC5jb25jYXQodWlvYmopO1xcblxcbiAgICAgICAgaWYgKGluZGV4cy5zb21lKHggPT4geC5pbmRleCA9PSAtMSkgJiYgdWltb2RlKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLlt7Lnp7vpmaRcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBpbmRleHMuZmlsdGVyKHggPT4geC5pbmRleCA9PSAtMSkuZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgbWFwID0gbmV3IE1hcChzdWlvYmoubWFwKG9iaiA9PiBbb2JqLmtleSwgb2JqXSkpO1xcbiAgICAgICAgICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuICAgICAgICAgICAgICAgIG9iai51cmwgPSAkKFxcXCJcXFwiKS5sYXp5UnVsZSgoa2V5LCB1aV9jb25maWcsIGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSB1aV9jb25maWcueWkudWk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gaW5kZXg7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGl0ZW0ua2V5LCB1aV9jb25maWcsIG9iai5pbmRleClcXG4gICAgICAgICAgICAgICAgb2JqLnRpdGxlID0gb2JqLmtleTtcXG4gICAgICAgICAgICAgICAgaWYgKG9iai5leHRyYSA9PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9iai5leHRyYSA9IHt9O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG9iai5leHRyYS5pZCA9IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIG9iai5rZXk7XFxuICAgICAgICAgICAgICAgIG9iai5leHRyYS5jbHMgPSBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCI7XFxuXFxuICAgICAgICAgICAgICAgIGlmIChvYmouY29sX3R5cGUgPT0gXFxcImlucHV0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgb2JqLmNvbF90eXBlID0gXFxcImljb25fMV9zZWFyY2hcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaChvYmopXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIlxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArICh1aW1vZGUgPyBcXFwi5L+u5pS5XFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogXFxcIuS/ruaUuVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1vZGUgPSBnZXRNeVZhcihcXFwidWltb2RlXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInVpbW9kZVxcXCIsIHVpbW9kZSA9PSBcXFwiMFxcXCIgPyBcXFwiMVxcXCIgOiBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS5XFxcIiArICh1aW1vZGUgPT0gXFxcIjBcXFwiID8gXFxcIuW8gOWQrzrngrnlh7vmjInpkq7kuqTmjaLkvY3nva4s6ZW/5oyJ5oyJ6ZKu5L+u5pS55oiW6ICF5Yig6ZmkXFxcIiA6IFxcXCLlhbPpl61cXFwiKTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLov5jljp9cXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG4gICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZywgZGVmKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLmmK/lkKbmgaLlpI3orr7nva5cXFwiKS5jb25maXJtKCh1aV9jb25maWcsIGRlZikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgdWlfY29uZmlnLnlpID0gZGVmLnlpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVpX2NvbmZpZyk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5Y6f5a6M5oiQXFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgdWlfY29uZmlnLCBkZWYpXFxuICAgICAgICAgICAgfSwgdWlfY29uZmlnLCBkZWYpLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi56Gu6K6kXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIExvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5aSN5Yi2XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3B5KEpTT04uc3RyaW5naWZ5KHVpX2NvbmZpZy55aSkpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLlr7zlhaVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHVpX2NvbmZpZykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1YyA9IHN0b3JhZ2UwLmdldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVpX2NvbmZpZyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcInt7Y2xpcGJvYXJkfX1cXFwiKS5pbnB1dCgodWMpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHlpID0ge307XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5aSA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHlpLmhhc093blByb3BlcnR5KFxcXCJ1aVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWMueWkgPSB5aTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1Yyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCB1YylcXG4gICAgICAgICAgICAgICAgICAgIH0sIHVpX2NvbmZpZylcXG4gICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWktOmDqOe7hOS7tuagt+W8jzpcXFwiICsgdWlfY29uZmlnLnlpLmNvbCxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICAgICAgdWlfY29uZmlnID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICAgICAgbGV0IGFsbF9jb2xzID0gWycnXS5jb25jYXQoZ2V0Q29sVHlwZXMoKSk7XFxuICAgICAgICAgICAgICAgIGFsbF9jb2xzID0gYWxsX2NvbHMuZmlsdGVyKHggPT5cXG4gICAgICAgICAgICAgICAgICAgIC8oaWNvbikvLnRlc3QoeCkgJiYgeCAhPSAndGV4dF9pY29uJyAmJlxcbiAgICAgICAgICAgICAgICAgICAgeCAhPSBcXFwiaWNvbl8xX3NlYXJjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhhbGxfY29scylcXG4gICAgICAgICAgICAgICAgbGV0IGNvbCA9IHVpX2NvbmZpZy55aS5jb2w7XFxuICAgICAgICAgICAgICAgIGxldCDmjInpkq7moLflvI8gPSBhbGxfY29scy5tYXAoKGl0KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQgPT09IGNvbCA/ICfinqHvuI8nICsgaXQgOiBpdDtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGxldCB0aXBzID0gJ+ivt+mAieaLqeWktOmDqOaMiemSruagt+W8jyc7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKOaMiemSruagt+W8jywgMiwgdGlwcykuc2VsZWN0KCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQucmVwbGFjZShcXFwi4p6h77iPXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG9ianMgPSAoZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKSB8fCBbXSkuZmlsdGVyKHggPT4gIS8oaWNvbl8xX3NlYXJjaHxhdmF0YXJ8aW5wdXQpLy50ZXN0KHgudHlwZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgb2Jqcy5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oeC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogaW5wdXQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZy55aS5jb2wgPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVpX2NvbmZpZyk7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXFxcIl95aWNvbFxcXCJcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICB9XFxuXFxuICAgIGlmICh1aV9uYXZpID09IFxcXCLkuoznuqdcXFwiKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5q+P6aG15pWw6YePXFxcIixcXG4gICAgICAgICAgICBkZXNjOiBcXFwiMOWImeihqOekuuS4jeWIhumhtVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICAgICAgdXJsOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKFN0cmluZyhpbnB1dCkubGVuZ3RoID4gMykge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpTPkvY3mlbDlrZfku6XlhoVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaW5wdXQpLmxlbmd0aCA8IDIgJiYgaW5wdXQgIT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpTLkvY3mlbDlrZfku6XkuIpcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHVpX2NvbmZpZy5lci7liIbpobUgPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL1xcXCIgKyAoaW5wdXQgPiAwID8gXFxcIuavj+mhteaVsOmHj+iuvue9ruS4ujpcXFwiICsgaW5wdXQgOiBcXFwi5LiN5YiG6aG1XFxcIik7XFxuICAgICAgICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGlucHV0KS5sZW5ndGggPiAzKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuivt+i+k+WFpTPkvY3mlbDlrZfku6XlhoVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGlucHV0KS5sZW5ndGggPCAyICYmIGlucHV0ICE9IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWlMuS9jeaVsOWtl+S7peS4ilxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZy5lci7liIbpobUgPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVpX2NvbmZpZyk7XFxuICAgICAgICAgICAgICAgIH0sIHVpX2NvbmZpZyksXFxuICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLuWIhumhtSxcXG4gICAgICAgICAgICAgICAgdHlwZTogXFxcIm51bWJlclxcXCIsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG5cXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLljoblj7LorrDlvZVcXFwiLFxcbiAgICAgICAgICAgIGRlc2M6IFxcXCLpu5jorqQyMDBcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgICAgIHVybDogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaW5wdXQpLmxlbmd0aCA+IDMpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaUz5L2N5pWw5a2X5Lul5YaFXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGlucHV0KS5sZW5ndGggPCAyKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWlMuS9jeaVsOWtl+S7peS4ilxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdWlfY29uZmlnLmVyLuWOhuWPsuiusOW9lSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Y6G5Y+y6K6w5b2V6K6+572u5Li6OlxcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICB9LCB1aV9jb25maWcpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLuWOhuWPsuiusOW9lSxcXG4gICAgICAgICAgICAgICAgdHlwZTogXFxcIm51bWJlclxcXCIsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLov5jljp9cXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZywgZGVmKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLmmK/lkKbmgaLlpI3orr7nva5cXFwiKS5jb25maXJtKCh1aV9jb25maWcsIGRlZikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgdWlfY29uZmlnLmVyID0gZGVmLmVyO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVpX2NvbmZpZyk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5Y6f5a6M5oiQXFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgdWlfY29uZmlnLCBkZWYpXFxuICAgICAgICAgICAgfSwgdWlfY29uZmlnLCBkZWYpLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi56Gu6K6kXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwicGxheWxpc3RfcmVhZHlcXFwiKTtcXG4gICAgICAgICAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICB9KVxcbiAgICB9XFxuICAgIHNldFJlc3VsdChkKTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJMb2NhbFByb3h5XCIsXCJwYXRoXCI6XCJMb2NhbFByb3h5XCIsXCJydWxlXCI6XCJmdW5jdGlvbiBwcm94eSgpIHtcXG4gICAgZnVuY3Rpb24gcGFyc2VWaWRlbyhNWV9QQVJBTVMsIHRpdGxlKSB7XFxuICAgICAgICBmdW5jdGlvbiB0b1BhdGgodmFsdWUpIHtcXG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnc3RyaW5nJykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gW107XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwYXRoID0gW107XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZhbHVlLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxuICAgICAgICAgICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBwYXRoO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgICAgICAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBwYXRoW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W2tleV07XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBjdXJyZW50O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IE1ZX1BBUkFNUy5ydW5UeXBlWzBdO1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pKTtcXG4gICAgICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFwiSlNPTlxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBwYXJhbS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IE9iamVjdC5hc3NpZ24oe30sIHBhcmFtLmhlYWRlcnMgfHwge30sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiBnZXRKc29uKGpzb24sIHRvUGF0aChwYXJhbS5qc29uUGF0aCkpLFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09IFxcXCJKU1xcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcnNlO1xcbiAgICAgICAgICAgICAgICBpZiAoTVlfUEFSQU1TLmluZGV4KSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyB0aXRsZSkuZ2V0SnNvbigpW01ZX1BBUkFNUy5pbmRleFswXV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKGRlY29kZVVSSUNvbXBvbmVudChNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IHJlcyA9IG5ldyBGdW5jdGlvbihcXFwidXJsXFxcIiwgXFxcInNlbGZcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzID09PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiByZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgkLnR5cGUocmVzKSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3Rhd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