Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjoxMywiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOlxuZnVuY3Rpb24gbG9hZChkLCBkcnB5LCBzb3VyY2UsIGhhc0hhZWQpIHtcbiAgICBsZXQgcGFnZSA9IE1ZX1BBR0U7XG4gICAgbGV0IGNhdGVnb3J5cyA9ICQucmVxdWlyZShcImNhdGVnb3J5c1wiKTtcbiAgICBjYXRlZ29yeXMuZ2V0Y2F0ZWdvcnlzKGQsIGRycHksIHBhZ2UsIGhhc0hhZWQpO1xuICAgIGxldCB7XG4gICAgICAgIGNhdGUsXG4gICAgICAgIGhvbWVsaXN0XG4gICAgfSA9IGNhdGVnb3J5cy5nZXRjYXRlbGlzdCgpO1xuICAgIGlmIChnZXRNeVZhcihcImxpbmtzXCIsIFwiXCIpID09IFwiMVwiICYmICFoYXNIYWVkKSB7XG4gICAgICAgIHNldFByZVJlc3VsdChkKTtcbiAgICAgICAgZC5sZW5ndGggPSAwO1xuICAgIH1cbiAgICBsZXQgZmwgPSBjYXRlZ29yeXMuZ2V0ZmwoKTtcbiAgICBsZXQgaG9tZUxpc3RDb2wgPSBnZXRJdGVtKFwiaG9tZUxpc3RDb2xcIiwgXCJtb3ZpZV8zX21hcnF1ZWVcIik7XG5cbiAgICBsZXQgbGlzdCA9IFtdO1xuICAgIGlmIChjYXRlID09IFwiaG9tZVwiKSB7XG4gICAgICAgIGlmIChwYWdlID09IDEpIHtcbiAgICAgICAgICAgIGxpc3QgPSBob21lbGlzdDtcbiAgICAgICAgfVxuICAgICAgICBpZiAobGlzdCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICBsaXN0ID0gW107XG4gICAgICAgICAgICBjbGVhck15VmFyKFwiaXNob21lXCIpO1xuICAgICAgICB9XG4gICAgICAgIGlmKGxpc3QubGVuZ3RoPjAmJiFsaXN0LmF0KDApLnZvZF9waWMmJiFsaXN0LmF0KC0xKS52b2RfcGljKXtcbiAgICAgICAgICAgIGhvbWVMaXN0Q29sPVwidGV4dF8xXCI7XG4gICAgICAgIH1cbiAgICB9IGVsc2Uge1xuICAgICAgICBsaXN0ID0gSlNPTi5wYXJzZShkcnB5LmNhdGVnb3J5KFN0cmluZyhjYXRlKSwgcGFnZSwgdHJ1ZSwgZmwpKS5saXN0O1xuICAgIH1cbiAgICBcbiAgICBpZiAobGlzdC5sZW5ndGgpIHtcbiAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xuICAgICAgICAgICAgbGV0IGlkID0gU3RyaW5nKGl0LnZvZF9pZCk7XG4gICAgICAgICAgICAvL2xvZyhpdClcbiAgICAgICAgICAgIGxldCBuYW1lID0gaXQudm9kX25hbWU7XG4gICAgICAgICAgICB1cmwgPSBcImhpa2VyOi8vcGFnZS9kZXRhaWxlZCNpbW1lcnNpdmVUaGVtZSNcIjtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgaWQgPT09IFwic3RyaW5nXCIgJiYgaWQuaW5jbHVkZXMoXCJtc2VhcmNoOlwiKSB8fCBpZCA9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICB1cmwgPSAkKFwiXCIpLmxhenlSdWxlKChuYW1lKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFwidGVtc21vZGVcIiwgXCIxXCIpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXCJoaWtlcjovL3NlYXJjaD9ydWxlPVwiICsgTVlfUlVMRS50aXRsZSArIFwiJnM9XCIgKyBuYW1lO1xuICAgICAgICAgICAgICAgIH0sIG5hbWUpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgIHRpdGxlOiBuYW1lLFxuICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxuICAgICAgICAgICAgICAgIHVybDogdXJsLFxuICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGhvbWVMaXN0Q29sLFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgdm9kSWQ6IGlkLFxuICAgICAgICAgICAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXG4gICAgICAgICAgICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXksXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcIuiBmuWQiOaQnOe0olwiLFxuICAgICAgICAgICAgICAgICAgICAgICAganM6IFwicHV0TXlWYXIoJ3RlbXNtb2RlJywgJzEnKTsnaGlrZXI6Ly9zZWFyY2g/cnVsZT0nICsgTVlfUlVMRS50aXRsZSArICcmcz1cIiArIG5hbWUgKyBcIic7XCJcbiAgICAgICAgICAgICAgICAgICAgfV1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBkZWxldGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcImxvYWRcIik7XG59XG5cbmZ1bmN0aW9uIHNldERycHlQYXRoKGQpIHtcbiAgICBkLnB1c2goe1xuICAgICAgICB0aXRsZTogXCLnvLrlsJHov5DooYzlupNcXG7or6XlsI/nqIvluo/kuI3og73pgJrov4fkupHliarotLTmnb/liIbkuqvvvIzlj6rog73pgJrov4fmiZPljIXliIbkuqtcIixcbiAgICAgICAgZGVzYzogXCLlsIbov5DooYzlupPmlL7lhaVcIiArIGdldFBhdGgoXCJoaWtlcjovL2ZpbGVzL2RhdGEvXCIgKyBNWV9SVUxFLnRpdGxlICsgXCIvbGlic19oaWtlci9kcnB5Mi5qc1wiKSxcbiAgICAgICAgY29sX3R5cGU6IFwidGV4dF9jZW50ZXJfMVwiLFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9lbXB0eVwiXG4gICAgfSk7XG59XG5cbmZ1bmN0aW9uIHNldEhpZWQoZCwgbmFtZSwgY29uZmlnKSB7XG4gICAgbGV0IGZpbGVTZWxlY3QgPSAkLnJlcXVpcmUoXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD01MDk5XCIpO1xuICAgIGQucHVzaCh7XG4gICAgICAgIHRpdGxlOiBuYW1lIHx8IFwiXCIsXG4gICAgICAgIGNvbF90eXBlOiAnaWNvbl8zX3JvdW5kX2ZpbGwnLFxuICAgICAgICBpbWc6ICdodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS8xMzAucG5nJyxcbiAgICAgICAgdXJsOiAkKFwiI25vTG9hZGluZyNcIikubGF6eVJ1bGUoKCkgPT4ge1xuICAgICAgICAgICAgJC5yZXF1aXJlKFwiQ2hhbmdlU291cmNlUG9wXCIpLnNob3coKTtcbiAgICAgICAgICAgIHJldHVybiBcImhpa2VyOi8vZW1wdHlcIjtcbiAgICAgICAgfSksXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICBjcGF0aDogY29uZmlnLnBhdGgsXG4gICAgICAgICAgICBsb25nQ2xpY2s6IFt7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwi5pu05o2i6YWN572uXCIsXG4gICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZUNvbmZpZyNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcIilcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLliLfmlrDmupBcIixcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFwicnVudGltZUNvbmZpZ1wiKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIik7XG4gICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLmluaXQocnVudGltZUNvbmZpZy5nZXRBYnNvbHV0ZVBhdGgoc291cmNlLmV4dCkpO1xuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwi5a6M5YWo5Yi35paw5rqQXCIsXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIik7XG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5h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6IGa5ZCIXCJdW01ZX0lOREVYXSxcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIHJldHVybiBcImhpa2VyOi8vZW1wdHlcIjtcbiAgICAgICAgICAgICAgICAvL3JlZnJlc2hQYWdlKCk7XG4gICAgICAgICAgICB9LCBNWV9SVUxFLnRpdGxlKVxuICAgICAgICB9KSxcbiAgICAgICAgcGljX3VybDogXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21lc3N5LzI1LnN2Z1wiLFxuICAgICAgICBjb2xfdHlwZTogXCJpY29uXzNfcm91bmRfZmlsbFwiLFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcIkBzZWFyY2hfbW9kZVwiLFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIuaMh+WumuaQnOe0oua6kFwiLFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFwiU2VhcmNoQWxsb3dQb3BcIikuc2hvdygpO1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XVxuICAgICAgICB9XG4gICAgfSk7XG4gICAgZC5wdXNoKHtcbiAgICAgICAgdGl0bGU6IFwi6K6+572uXCIsXG4gICAgICAgIHVybDogJChbXCLop6PmnpDnrqHnkIZcIiwgXCLlrpjmlrnlvLnluZVcIiwgXCJkcnB56LCD6K+V5pel5b+XOlwiICsgKGdldEl0ZW0oXCJ1c2VMb2dcIiwgXCJcIikgPT0gXCJcIiA/IFwi5YWz6ZetXCIgOiBcIuW8gOWQr1wiKSwgXCLliJvlu7rorqLpmIXlnLDlnYBcIiwgXCLliIfmjaLliJfooajmoLflvI9cIiwgXCLmm7TmjaLphY3nva5cIiwgXCLop4bpopHmupDpu5jorqTkv53lrZjot6/lvoRcIl0sIDEsIFwi6K6+572uXCIpLnNlbGVjdCgoKSA9PiB7XG4gICAgICAgICAgICBpZiAoXCLop6PmnpDnrqHnkIZcIiA9PSBpbnB1dCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBcImhpa2VyOi8vcGFnZS9ydWxlTWFuYWdlI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1wiO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChcIuWumOaWueW8ueW5lVwiID09PSBpbnB1dCkge1xuICAgICAgICAgICAgICAgIGxldCB1c2VEYW5tdSA9ICEhZ2V0SXRlbShcInVzZURhbm11XCIsIFwiXCIpO1xuICAgICAgICAgICAgICAgIHJldHVybiAkKFwi5b2T5Li65a6Y5rqQ5pe25Yy56YWN5by55bmVKOmcgOimgWRhbm1155uS5a2Q5pSv5oyBKVxcbuW9k+WJjTpcIiArIHVzZURhbm11ICsgXCJcXG7ngrnlh7vnoa7lrprljbPlj69cIiArICh1c2VEYW5tdSA/IFwi5YWz6ZetXCIgOiBcIuW8gOWQr1wiKSkuY29uZmlybSgodXNlRGFubXUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcInVzZURhbm11XCIsIHVzZURhbm11ID8gXCJcIiA6IFwiMVwiKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFwidG9hc3Q6Ly9cIiArICh1c2VEYW5tdSA/IFwi5bey5YWz6ZetXCIgOiBcIuW3suW8gOWQr1wiKTtcbiAgICAgICAgICAgICAgICB9LCB1c2VEYW5tdSk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0LmluY2x1ZGVzKFwiZHJweeiwg+ivleaXpeW/l1wiKSkge1xuICAgICAgICAgICAgICAgIGxldCB1c2VMb2cgPSAhIWdldEl0ZW0oXCJ1c2VMb2dcIiwgXCJcIik7XG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXCLlvIDlkK/ml6Xlv5fovoXliqnosIPor5XvvIzmma7pgJrkvb/nlKjkuI3pnIDopoHlvIDlkK9cXG7lvZPliY06XCIgKyB1c2VMb2cgKyBcIlxcbueCueWHu+ehruWumuWNs+WPr1wiICsgKHVzZUxvZyA/IFwi5YWz6ZetXCIgOiBcIuW8gOWQr1wiKSkuY29uZmlybSgodXNlTG9nKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXCJ1c2VMb2dcIiwgdXNlTG9nID8gXCJcIiA6IFwiMVwiKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcInRvYXN0Oi8vXCIgKyAodXNlTG9nID8gXCLlt7LlhbPpl61cIiA6IFwi5bey5byA5ZCvXCIpO1xuICAgICAgICAgICAgICAgIH0sIHVzZUxvZyk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcIuWIm+W7uuiuoumYheWcsOWdgFwiKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZVN1YnNjcmlwdGlvbiNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcIjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFwi5YiH5o2i5YiX6KG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kLnB1c2goe1xuICAgICAgICB0aXRsZTogJ+aQnOe0oicsXG4gICAgICAgIC8vZGVzYzogJycsXG4gICAgICAgIGRlc2M6ICfopoHmkJzngrnku4DkuYgnLFxuICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgICAgcmV0dXJuICdoaWtlcjovL3NlYXJjaD9ydWxlPScgKyBNWV9SVUxFLnRpdGxlICsgXCImcz1cIiArIGlucHV0O1xuICAgICAgICB9KSxcbiAgICAgICAgY29sX3R5cGU6ICdpbnB1dCcsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IGdldE15VmFyKFwia2V5d29yZFwiLCBcIlwiKSxcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcImtleXdvcmRcIiwgaW5wdXQpXG4gICAgICAgICAgICB9KVxuICAgICAgICB9XG4gICAgfSlcbn1cbmxldCBkID0gW107XG5cbmxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFwicnVudGltZUNvbmZpZ1wiKTtcbmxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKTtcbkRycHlNYW5hZ2UuaW5pdFBhZ2UoXCJob21lXCIpO1xuYWRkTGlzdGVuZXIoXCJvbkNsb3NlXCIsICgpID0+IHtcbiAgICBjbGVhck15VmFyKFwibGlua3NcIik7XG59KTtcbnRyeSB7XG4gICAgaWYgKGFuZHJvaWQub3MuQnVpbGQuVkVSU0lPTi5TREtfSU5UID49IDMwICYmICFhbmRyb2lkLm9zLkVudmlyb25tZW50LmlzRXh0ZXJuYWxTdG9yYWdlTWFuYWdlcigpKSB7XG4gICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICB0aXRsZTogXCLigJjigJjmj5DnpLrigJnigJlcIixcbiAgICAgICAgICAgIGRlc2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ICAgICAgLy9sb2coRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkpXG4gICAgICAgIGxldCBoYXNIYWVkID0gZmFsc2U7XG4gICAgICAgIGlmIChnZXRNeVZhcihcImxpbmtzXCIsIFwiXCIpID09IFwiXCIpIHtcbiAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6ICfliqDovb3kuK0uLi4nLFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMScsXG4gICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vZW1wdHlcIixcbiAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXCJsb2FkXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHNldFByZVJlc3VsdChkKTtcbiAgICAgICAgICAgIGQubGVuZ3RoID0gMDtcbiAgICAgICAgICAgIGhhc0hhZWQgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzb3VyY2UpIHtcbiAgICAgICAgICAgIGxvYWQoZCwgRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSksIHNvdXJjZSwgaGFzSGFlZCk7XG4gICAgICAgIH1cbiAgICB9IGVsc2Uge1xuICAgICAgICBzZXREcnB5UGF0aChkKTtcbiAgICB9XG5cbn0gY2F0Y2ggKGUpIHtcblxuICAgIGQucHVzaCh7XG4gICAgICAgIHRpdGxlOiBcIuKAnOKAnFwiICsgZS50b1N0cmluZygpICsgXCLigJ3igJ1cIixcbiAgICAgICAgZGVzYzogZS5saW5lTnVtYmVyLFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9lbXB0eVwiLFxuICAgICAgICBjb2xfdHlwZTogXCJ0ZXh0X2NlbnRlcl8xXCJcbiAgICB9KTtcbiAgICBk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lcnNpdmVUaGVtZSNcIixcbiAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgIHZvZElkOiBpdC52b2RfaWQsXG4gICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcbiAgICAgICAgICBza2V5OiBzb3VyY2Uua2V5XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cbiAgICBzZXRSZXN1bHQoZCk7XG4gIH0gZWxzZSB7XG4gICAgc2V0UmVzdWx0KFt7XG4gICAgICB0aXRsZTogXCLngrnmiJHlvIDlp4vogZrlkIjmkJzntKJcIiArIE1ZX0tFWVdPUkQsXG4gICAgICB1cmw6IFwiaGlrZXI6Ly9zZWFyY2g/cz1cIiArIE1ZX0tFWVdPUkQsXG4gICAgICBleHRyYToge1xuICAgICAgICBkZWxlZ2F0ZU9ubHlTZWFyY2g6IHRydWUsXG4gICAgICAgIHJ1bGVzOiAkLnRvU3RyaW5nKCgpID0+IHtcbiAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXCJydW50aW1lQ29uZmlnXCIsIFwicnVudGltZUNvbmZpZ1wiKTtcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxvd1NlYXJjaFNvdXJjZSgpO1xuICAgICAgICAgICAgXG4gICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG4gIFxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcbiAgICAgICAgICAgIFxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xuICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpLmdldChpdGVtLmtleSk7XG5cbiAgICAgICAgICAgICAgICAgIGxldCBob21lTGlzdCA9IEpTT04ucGFyc2UoZHJweS5zZWFyY2goTVlfS0VZV09SRCwgZmFsc2UsIE1ZX1BBR0UpKS5saXN0IHx8IFtdO1xuICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcbiAgICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnZvZF9uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICAgICAgICAgICAgICAgIHVybDogXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWQjaW1tZXJzaXZlVGhlbWUjXCIsXG4gICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZvZElkOiBpdC52b2RfaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgICBzbmFtZTogaXRlbS5uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2tleTogaXRlbS5rZXksXG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIHNldFJlc3VsdChkKTtcbiAgICAgICAgICAgICAgICB9LCBpdClcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkocnVsZXMpO1xuICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSlcbiAgICAgIH1cbiAgICB9XSk7XG4gIH1cbn0pKCkiLCJkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwiZGV0YWlsX2ZpbmRfcnVsZSI6IiIsInNkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwic2RldGFpbF9maW5kX3J1bGUiOiIiLCJ1YSI6Im1vYmlsZSIsInByZVJ1bGUiOiIvKjwkPlxuQGluY2x1ZGUgc3RhcnRcbmh0dHA6Ly9oaWtlci5ub2tpYS5wcmVzcy9oaWtlcnVsZS9ydWxlbGlzdC5qc29uP2lkPTY5MTYmYXV0a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LkNyeXB0b0pTID0gQ3J5cHRvSlM7XFxuXFxuICAgIGxldCAkcmVxdWVzdCA9IHJlcXVlc3Q7XFxuICAgIGxldCAkcG9zdCA9IHBvc3Q7XFxuICAgIGdsb2JhbFRoaXMucmVxID0gZnVuY3Rpb24gKHVybCwgY29iaikge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcmVzID0ge307XFxuICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIGNvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmouZGF0YSkge1xcbiAgICAgICAgICAgICAgICBvYmouYm9keSA9IG9iai5kYXRhO1xcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqLmRhdGE7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoXFxcInJlZGlyZWN0XFxcIikpIG9iai5yZWRpcmVjdCA9ICEhb2JqLnJlZGlyZWN0O1xcbiAgICAgICAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICAgICAgICAgIG9iai50b0hleCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iai5oZWFkZXJzID0gT2JqZWN0LmFzc2lnbih7XFxuICAgICAgICAgICAgICAgIENvb2tpZTogXFxcIiNub0Nvb2tpZSNcXFwiXFxuICAgICAgICAgICAgfSwgb2JqLmhlYWRlcnMpO1xcbiAgICAgICAgICAgIGlmICh1cmwgPT09IFxcXCJodHRwczovL2FwaS5ubi5jaS9vY3IvYjY0L3RleHRcXFwiICYmIG9iai5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW1xcXCJDb250ZW50LVR5cGVcXFwiXSA9IFxcXCJ0ZXh0L3BsYWluXFxcIjtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKHVybC5zdGFydHNXaXRoKFxcXCJmaWxlOi8vXFxcIikgJiYgKHVybC5pbmNsdWRlcyhcXFwiP3R5cGU9XFxcIikgfHwgdXJsLmluY2x1ZGVzKFxcXCI/cGFyYW1zPVxcXCIpKSkge1xcbiAgICAgICAgICAgICAgICB1cmwgPSB1cmwuc2xpY2UoMCwgdXJsLmxhc3RJbmRleE9mKFxcXCI/XFxcIikpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBmb3IgKGxldCBrZXkgaW4gb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBvYmouaGVhZGVyc1trZXldICE9PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNba2V5XSA9IFN0cmluZyhvYmouaGVhZGVyc1trZXldKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgciA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIC8qIGlmIChTdHJpbmcob2JqLm1ldGhvZCkudG9Mb3dlckNhc2UoKSA9PT0gXFxcInBvc3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICBpZiAob2JqLndpdGhIZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHIuYm9keTtcXG4gICAgICAgICAgICAgICAgcmVzLmhlYWRlcnMgPSB7fTtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzW2tdID0gdlswXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VIZXgocmVzLmNvbnRlbnQpLnRvQmFzZTY0KF9iYXNlNjQuTk9fV1JBUCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKFxcXCJFcnJvclxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIC8qXFxuICAgIGNvbnN0IEppbkphID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2Nkbi5ib290Y2RuLm5ldC9hamF4L2xpYnMvbXVzdGFjaGUuanMvNC4xLjAvbXVzdGFjaGUuanNcXFwiKTtcXG4gIFxcbiAgICBjb25zdCBKUCA9ICQucmVxdWlyZShcXFwiaHR0cHM6Ly9qc29ucGF0aC1wbHVzLmdpdGh1Yi5pby9KU09OUGF0aC9kaXN0L2luZGV4LWJyb3dzZXItdW1kLmNqc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmNoZWVyaW8gPSB7XFxuICAgICAgICBqaW5qYTIodGVtcGxhdGUsIG9iaikge1xcbiAgICAgICAgICAgIFxcbiAgICAgICAgICAgIHJldHVybiAkLmxvZyhKaW5KYS5yZW5kZXIodGVtcGxhdGUsIG9iaikpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGpwKHBhdGgsIGpzb24pIHtcXG4gICAgICAgICAgICByZXR1cm4gSlAuSlNPTlBhdGgoe1xcbiAgICAg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AgICAgICAgdGV4dCA9IG9wZW5UYWdzICsgdGV4dCArIGNsb3NlVGFncztcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBoICsgdGV4dDtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBmaW5kTG9uZ2VzdEVsZW1lbnQoYXJyKSB7XFxuICAgICAgICByZXR1cm4gYXJyLnJlZHVjZSgoYSwgYikgPT4gYS5sZW5ndGggPiBiLmxlbmd0aCA/IGEgOiBiKTtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBjb3VudFRvdGFsQnl0ZXModGV4dCkge1xcbiAgICAgICAgdmFyIGNvdW50ID0gMDtcXG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgdGV4dC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgIHZhciBjb2RlID0gdGV4dC5jaGFyQ29kZUF0KGkpO1xcbiAgICAgICAgICAgIGlmIChjb2RlID49IDB4MDEwMCkgeyAvLyDlj4zlrZfoioLlrZfnrKbnmoQgVW5pY29kZSDnvJbnoIHlpKfkuo4gMjU1XFxuICAgICAgICAgICAgICAgIGNvdW50ICs9IDI7IC8vIOWPjOWtl+iKguWtl+espuiuoeaVsOS4ujJcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBjb3VudCArPSAxOyAvLyDljZXlrZfoioLlrZfnrKborqHmlbDkuLoxXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGNvdW50O1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGNhY2hlU2hvd1RpcHMoKSB7XFxuICAgICAgICAvKmlmIChzdG9yYWdlMC5nZXRNeVZhcihpZCArIFxcXCJlcmluZm9cXFwiKSkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUoXFxcIuW9k+WJjeS4uue8k+WtmCzngrnmiJHliLfmlrBcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICBjOiBcXFwiZ3JleVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKGlkICsgXFxcImVyaW5mb1xcXCIpXFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBpZCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICB9Ki9cXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBzdWJzdHIoc3RyLCBtYXhMZW5ndGgpIHtcXG4gICAgICAgIGxldCBsZW4gPSAwO1xcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzdHIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICBpZiAoc3RyLmNoYXJDb2RlQXQoaSkgPiAyNTUpIHtcXG4gICAgICAgICAgICAgICAgbGVuICs9IDI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbGVuKys7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChsZW4gPiBtYXhMZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHN0ci5zbGljZSgwLCBpKSArICcuLi4nO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBzdHI7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gc2V0RGVzYyhkZXNjLCBudW0pIHtcXG4gICAgICAgIGlmIChkZXNjID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgIH1cXG4gICAgICAgIGRlc2MgPSBkZXNjLmNvbnN0cnVjdG9yID09IEFycmF5ID8gZGVzYy5qb2luKCc8YnI+JykgOiBkZXNjO1xcbiAgICAgICAgaWYgKGRlc2MucmVwbGFjZSgvKDxicj58XFxcXHMrKS9nLCAnJykubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ2JpZ19ibGFua19ibG9jaydcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmlnX2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgY29uc3QgbWFyayA9ICdkZXNjJztcXG4gICAgICAgIG51bSA9IHR5cGVvZihudW0pID09ICd1bmRlZmluZWQnID8gMTAwIDogbnVtXFxuICAgICAgICBkZXNjID0gZGVzYy5zdGFydHNXaXRoKCfjgIDjgIAnKSA/IGRlc2MgOiAn44CA44CAJyArIGRlc2M7XFxuICAgICAgICBkZXNjID0gZGVzYy5yZXBsYWNlKC8nL2csIFxcXCImIzM5O1xcXCIpO1xcbiAgICAgICAgZGVzYyA9IGRlc2MucmVwbGFjZSgvXFxcXHJcXFxcbi9nLCBcXFwiPGJyPlxcXCIpO1xcbiAgICAgICAgZGVzYyA9IGRlc2MucmVwbGFjZSgvXFxcXG4vZywgXFxcIjxicj5cXFwiKTtcXG4gICAgICAgIGxldCBzZGVzYyA9IHN1YnN0cihkZXNjLCBudW0pO1xcblxcbiAgICAgICAgdmFyIGNvbG9ycyA9IHtcXG4gICAgICAgICAgICBzaG93OiBcXFwiYmxhY2tcXFwiLFxcbiAgICAgICAgICAgIGhpZGU6IFxcXCJncmV5XFxcIlxcbiAgICAgICAgfVxcblxcbiAgICAgICAgdmFyIGxhenkgPSAkKGAjbm9Mb2FkaW5nI2ApLmxhenlSdWxlKChkYywgc2RjLCBtLCBjcykgPT4ge1xcbiAgICAgICAgICAgIHZhciBzaG93ID0gc3RvcmFnZTAuZ2V0SXRlbShtLCAnMCcpO1xcbiAgICAgICAgICAgIHZhciB0aXRsZSA9IGZpbmRJdGVtKCdkZXNjJykudGl0bGU7XFxuICAgICAgICAgICAgdmFyIHJlID0gLyg8XFxcXC9zbWFsbD48YnI+Lio/PikuKy9nO1xcbiAgICAgICAgICAgIHZhciBleHAgPSAn5bGV5byAOic7XFxuICAgICAgICAgICAgdmFyIHJldCA9ICfmlLbotbc6JztcXG4gICAgICAgICAgICBpZiAoc2hvdyA9PSAnMScpIHtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSgnZGVzYycsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZVxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKHJldCwgZXhwKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKHJlLCAnJDEnICsgc2RjICsgJzwvc21hbGw+JylcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvKDxcXFxcL3NtYWxsPjxicj5cXFxcPGZvbnQgY29sb3I9XFxcIikuKj8oXFxcIj4pLywgJyQxJyArIGNzLmhpZGUgKyAnJDInKVxcblxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKG0sICcwJyk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSgnZGVzYycsIHtcXG4gICAgIC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XBlb2YgZXhjbHVkZSA9PT0gJ2Jvb2xlYW4nID8gZXhjbHVkZSA6IHRydWU7XFxuICAgICAgICAgICAgICAgIGNvbnN0IGtleXNUb0hhbmRsZSA9IEFycmF5LmlzQXJyYXkoa2V5cykgPyBrZXlzIDogW107XFxuXFxuICAgICAgICAgICAgICAgIC8vIOS9v+eUqEFycmF5LnByb3RvdHlwZS5tYXDpgY3ljobmlbDnu4TkuK3nmoTmr4/kuKrlhYPntKBcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWFwKGl0ZW0gPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5pWw57uE77yM6YCS5b2S6LCD55SoZXhjbHVkZUtleXNcXG4gICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGl0ZW0pKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0uZXhjbHVkZUtleXMoZXhjbHVkZSwga2V5cywgcmVuYW1lQ2FsbGJhY2spO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gJ29iamVjdCcgJiYgaXRlbSAhPT0gbnVsbCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOaYr+S4gOS4quWvueixoe+8jOS9v+eUqE9iamVjdC5mcm9tRW50cmllc+WSjE9iamVjdC5lbnRyaWVz5p2l5aSE55CG6ZSuXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW50cmllcyA9IE9iamVjdC5lbnRyaWVzKGl0ZW0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb2Nlc3NlZEVudHJpZXMgPSBlbnRyaWVzLm1hcCgoW2tleSwgdmFsdWVdKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOaciemHjeWRveWQjeWbnuiwg+WHveaVsO+8jOWImeiwg+eUqOWug1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbmFtZUNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3JlbmFtZUNhbGxiYWNrKGtleSwgdmFsdWUpLCB2YWx1ZV07XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtrZXksIHZhbHVlXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWx0ZXJlZEVudHJpZXMgPSBzaG91bGRFeGNsdWRlID9cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx0ZXIoKFtrZXldKSA9PiAha2V5c1RvSGFuZGxlLmluY2x1ZGVzKGtleSkpIDpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx0ZXIoKFtrZXldKSA9PiBrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5mcm9tRW50cmllcyhmaWx0ZXJlZEVudHJpZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDkuI3mmK/lr7nosaHmiJbmlbDnu4TvvIznm7TmjqXov5Tlm55cXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSwgLy8g6K6+572u5Li65LiN5Y+v5p6a5Li+XFxuICAgICAgICB9LFxcbiAgICAgICAgdHJhbnNmb3JtS2V5czoge1xcbiAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbihrZXlNYXBwaW5nKSB7XFxuICAgICAgICAgICAgICAgIC8vIOS9v+eUqEFycmF5LnByb3RvdHlwZS5tYXDpgY3ljobmlbDnu4TkuK3nmoTmr4/kuKrlhYPntKBcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWFwKGl0ZW0gPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5pWw57uE77yM6YCS5b2S6LCD55SodHJhbnNmb3JtS2V5c1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaXRlbSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS50cmFuc2Zvcm1LZXlzKGtleU1hcHBpbmcpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gJ29iamVjdCcgJiYgaXRlbSAhPT0gbnVsbCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOaYr+S4gOS4quWvueixoe+8jOS9v+eUqE9iamVjdC5mcm9tRW50cmllc+WSjE9iamVjdC5lbnRyaWVz5p2l5aSE55CG6ZSuXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW50cmllcyA9IE9iamVjdC5lbnRyaWVzKGl0ZW0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybWVkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmV3S2V5ID0ga2V5TWFwcGluZ1trZXldIHx8IGtleTsgLy8g5aaC5p6c6ZSu5Zyo5pig5bCE5Lit77yM5L2/55So5paw6ZSu77yb5ZCm5YiZ5L2/55So5Y6f5aeL6ZSuXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbbmV3S2V5LCB2YWx1ZV07XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5mcm9tRW50cmllcyh0cmFuc2Zvcm1lZEVudHJpZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDkuI3mmK/lr7nosaHmiJbmlbDnu4TvvIznm7TmjqXov5Tlm55cXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSwgLy8g6K6+572u5Li65LiN5Y+v5p6a5Li+XFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBsZXQgc29ydG9iaiA9IFtcXG4gICAgICAgIGZvbnRzdHlsZShcXFwi5q2j5bqPXFxcIiwge1xcbiAgICAgICAgICAgIGM6IFxcXCIjMUFBRDE5XFxcIixcXG4gICAgICAgICAgICB0YWdzOiBcXFwiYlxcXCJcXG4gICAgICAgIH0pLFxcbiAgICAgICAgZm9udHN0eWxlKFxcXCLpgIbluo9cXFwiLCB7XFxuICAgICAgICAgICAgYzogXFxcIiNGRjAwMDBcXFwiLFxcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJiXFxcIlxcbiAgICAgICAgfSlcXG4gICAgXVxcbiAgICAvL+aWueazlVxcblxcbiAgICB2YXIgc29ydGkgPSBnZXRNeVZhcihcXFwic29ydGlcXFwiLCBcXFwiMFxcXCIpO1xcblxcbiAgICAvL2xvZyhzb3J0b2JqKVxcbiAgICAkLmV4dGVuZCh7XFxuICAgICAgICBzcGxpdFBhZ2UodG90YWxJdGVtcywgcGFnZVNpemUpIHtcXG4gICAgICAgICAgICBwYWdlU2l6ZSA9IHBhZ2VTaXplIHx8IDUwO1xcbiAgICAgICAgICAgIGxldCByZXN1bHQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8PSB0b3RhbEl0ZW1zOyBpICs9IHBhZ2VTaXplKSB7XFxuICAgICAgICAgICAgICAgIGxldCBlbmQgPSBpICsgcGFnZVNpemUgLSAxO1xcbiAgICAgICAgICAgICAgICBpZiAoZW5kID4gdG90YWxJdGVtcykge1xcbiAgICAgICAgICAgICAgICAgICAgZW5kID0gdG90YWxJdGVtcztcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXN1bHQucHVzaChgJHtpfS0ke2VuZH1gKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcXG4gICAgICAgIH0sXFxuICAgICAgICBzcGxpdEFycmF5QnlSYW5nZXMoYXJyYXksIHJhbmdlcykge1xcbiAgICAgICAgICAgIC8vIOagueaNruiMg+WbtOaLhuWIhuaVsOe7hFxcbiAgICAgICAgICAgIHZhciByZXN1bHQgPSByYW5nZXMubWFwKGZ1bmN0aW9uKHJhbmdlKSB7XFxuICAgICAgICAgICAgICAgIHZhciBwYXJ0cyA9IHJhbmdlLnNwbGl0KCctJykubWFwKE51bWJlcik7XFxuICAgICAgICAgICAgICAgIHZhciBzdGFydCA9IHBhcnRzWzBdIC0gMTsgLy8g5YePMeaYr+WboOS4uuaVsOe7hOe0ouW8leS7jjDlvIDlp4tcXG4gICAgICAgICAgICAgICAgdmFyIGVuZCA9IHBhcnRzWzFdIC0gMTtcXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLnNsaWNl5p2l6I635Y+W5a2Q5pWw57uEXFxuICAgICAgICAgICAgICAgIHJldHVybiBhcnJheS5zbGljZShzdGFydCwgZW5kICsgMSk7IC8vIOWMheaLrOe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wuY29tfHNvaHVcXFxcLmNvbXxpeGlndWFcXFxcLmNvbXxwcHR2XFxcXC5jb218bWlndXZpZGVvXFxcXC5jb218bGVcXFxcLmNvbXwxOTA1XFxcXC5jb218ZnVuXFxcXC50dicpO1xcbiAgICAgICAgICAgIHJldHVybiBmbGFnLnRlc3QodXJsKTtcXG4gICAgICAgICAgfVxcblxcbiAgICAgICAgICBsZXQgZHJweSA9IEdNLmRlZmluZU1vZHVsZShcXFwiZHJweVxcXCIsIFxcXCJkcnB5XFxcIik7XFxuICAgICAgICAgIGlucHV0ID0gaW5wdXQuc3BsaXQoXFxcIiNcXFwiKTtcXG4gICAgICAgICAgbGV0IHBsYXkgPSBKU09OLnBhcnNlKGRycHkucGxheShpbnB1dFsxXSwgaW5wdXRbMF0ucmVwbGFjZShcXFwidHZib3gteGc6XFxcIiwgXFxcIlxcXCIpLCBbXSkpO1xcbiAgICAgICAgICBsb2cocGxheSlcXG4gICAgICAgICAgbG9nKFxcXCJwbGF5LnVybFxcXCIpXFxuICAgICAgICAgIGxldCBwYXJzZV9vYmogPSB7XFxuICAgICAgICAgICAgZGVmX3JlZ2V4OiBTdHJpbmcucmF3YFxcXFwuKG1wNHxtM3U4KXxjbi90b3NgLFxcbiAgICAgICAgICB9O1xcblxcbiAgICAgICAgICBpZiAocGxheS51cmwuaW5jbHVkZXMoXFxcInByb3h5P2RvXFxcIikpIHtcXG4gICAgICAgICAgICBNWV9VUkwgPSBwbGF5LnVybDtcXG4gICAgICAgICAgICBwbGF5LnVybCA9IGRlY29kZVVSSUNvbXBvbmVudChnZXRQYXJhbShcXFwidXJsXFxcIiwgXFxcIlxcXCIpKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAocGxheS51cmwuc3RhcnRzV2l0aChcXFwiaHR0cHM6Ly9wYW4ucXVhcmsuY24vXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vc2VhcmNoP3M9XFxcIiArIHBsYXkudXJsICsgXFxcIiZydWxlPXVja2vkupFcXFwiXFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKHBsYXkudXJsLnN0YXJ0c1dpdGgoJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zLycpIHx8IHBsYXkudXJsLnN0YXJ0c1dpdGgoXFxcImh0dHBzOi8vd3d3LmFsaXBhbi5jb20vcy9cXFwiKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9ydWxlPeS6keebmOWQmy7nroAmcGFnZT1meXBhZ2UmcmVhbHVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHBsYXkudXJsKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAocGxheS5wYXJzZSA9PT0gMSkge1xcbiAgICAgICAgICAgIGlmIChwbGF5LnVybC5zdGFydHNXaXRoKFxcXCJtYWduZXQ6XFxcIikpIHtcXG4gICAgICAgICAgICAgIHJldHVybiBwbGF5LnVybDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGlzb2ZmaWNpYWwocGxheS51cmwpKSB7XFxuICAgICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJoaWtlcjovL3BhZ2UvbXVsUGFyc2U/cnVsZT3phY3nva7liqnmiYtcXFwiKS5tdWxQYXJzZShwbGF5LnVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwidmlkZW86Ly9cXFwiICsgcGxheS51cmw7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocGxheS5wYXJzZSA9PT0gMCkge1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5LnVybDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSk7Ki9cXG4gICAgfVxcblxcbiAgICBsZXQgcGxheUxhenkgPSAkKFxcXCJcXFwiKS5sYXp5UnVsZSgoaWQsIHNvdXJjZSkgPT4ge1xcbiAgICAgICAgcmV0dXJu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xcInRleHRfMVxcXCI7XFxuICAgICAgICAgICAgICAgIGltZyA9IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21vdmllLzE0Ni5zdmdcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGMgPj0gMTIgJiYgdGMgPCAxNSkge1xcbiAgICAgICAgICAgICAgICBjb2wgPSBcXFwidGV4dF8zXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRjID49IDE1KSB7XFxuICAgICAgICAgICAgICAgIGNvbCA9IFxcXCJ0ZXh0XzJcXFwiO1xcbiAgICAgICAgICAgICAgICB0ZXh0YWxpZ24gPSBcXFwibGVmdFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwbGF5b2JqID0gdC5zcGxpdChcXFwiI1xcXCIpLm1hcCgoaikgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgayA9IGouc3BsaXQoXFxcIiRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHQgPSBrWzBdO1xcbiAgICAgICAgICAgICAgICBsZXQgdWlkID0gKGtbMV0gfHwga1swXSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBzdGl0bGU6IHQsXFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogZm9udHN0eWxlKHQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgICAgIHN1cmw6IHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0sXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGlzTm92ZWw/XFxcImhpa2VyOi8vcGFnZS9ub3ZlbCNhdXRvUGFnZSMjcmVhZFRoZW1lI1xcXCI6KHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0gKyBwbGF5TGF6eS5yZXBsYWNlKCdcXFwiaWRcXFwiJywgJ1xcXCInICsgdWlkICsgJ1xcXCInKSksXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogY29sLFxcbiAgICAgICAgICAgICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgICAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcbiAgICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IGRlY29kZVVSSUNvbXBvbmVudChrWzFdKSxcXG4gICAgICAgICAgICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgICAgICAgICAgIC8vbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfSkqL1xcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmcm9tOiBmcm9tW2ldLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogc291cmNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiB1aWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tSdWxlczogWydiYi4qLnBuZycsICcuanBnJywgXFxcImhtXFxcXC5iYWlkdVxcXFwuY29tXFxcXC9obS5qc1xcXCJdLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZpZGVvRXhjbHVkZVJ1bGVzOiBbJz91cmw9J10sXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBpZiAoc3R5cGUgPT0gXFxcIua8q+eUu1xcXCIgfHwgc3R5cGUgPT0gXFxcIuWwj+ivtFxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgdmFyIGRvd25sb2FkbGF6eSA9ICQudG9TdHJpbmcoKGtleSwgc2tleSwgdGl0bGUpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgR01cXG4gICAgICAgICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcImh0dHA6Ly9oaWtlci5ub2tpYS5wcmVzcy9oaWtlcnVsZS9ydWxlbGlzdC5qc29uP2lkPTY5MTYmYXV0aD0xZDM1ZThmMC0yMmU4LTUyNzAtYTlkMS04MjZmNTNmMTc3YWRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIEdNLnNldFNlbGZLZXkoa2V5KTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIixcXFwiRHJweU1hbmFnZT9ydWxlPVxcXCIrdGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBEcnB5TWFuYWdlLmdldChza2V5KTtcXG4gICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQuc3BsaXQoXFxcIiNcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBKU09OLnBhcnNlKGRycHkucGxheShpbnB1dFsxXSwgaW5wdXRbMF0pKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHQudXJsLnN0YXJ0c1dpdGgoXFxcInBpY3M6Ly9cXFwiKSkgcmV0dXJuIHJlc3VsdC51cmw7XFxuICAgICAgICAgICAgICAgICAgICBlbHNlIGlmIChyZXN1bHQudXJsLnN0YXJ0c1dpdGgoXFxcIm5vdmVsOi8vXFxcIikpIHJldHVybiBKU09OLnBhcnNlKHJlc3VsdC51cmwucmVwbGFjZShcXFwibm92ZWw6Ly9cXFwiLCBcXFwiXFxcIikpLmNvbnRlbnQ7XFxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIua8q+eUu+aIluato+aWh+iOt+WPluWksei0pVxcXCIpO1xcbiAgICAgICAgICAgICAgICB9LCBHTS5nZXRTZWxmS2V5KCksIE1ZX1BBUkFNUy5za2V5LCBNWV9SVUxFLnRpdGxlKTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IGNoYXB0ZXJMaXN0ID0gcGxheW9iai5leGNsdWRlS2V5cyhbXFxcInN1cmxcXFwiLCBcXFwic3RpdGxlXFxcIl0sIGZhbHNlKS50cmFuc2Zvcm1LZXlzKHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJzdXJsXFxcIjogXFxcInVybFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwic3RpdGxlXFxcIjogXFxcInRpdGxlXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoY2hhcHRlckxpc3QpKTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5LiL6L29XFxcIiArIHN0eXBlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiAnaGlrZXI6Ly9wYWdlL2Rvd25sb2FkLnZpZXcjbm9SZWNvcmRIaXN0b3J5IyNub1JlZnJlc2gjP3J1bGU95pys5Zyw6LWE5rqQ566h55CGJyxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoYXB0ZXJMaXN0OiBcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvZHJfZG93X2xpc3QuanNvblxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5mbzoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29rTmFtZTogaW5mby52b2RfbmFtZSwgLy/mvKvnlLvlkI3np7AsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVOYW1lOiBcXFwiRFJQWVxcXCIgKyBNWV9QQVJBTVMuc25hbWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tUb3BQaWM6IGluZm8udm9kX3BpYyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VDb2RlOiBkb3dubG9hZGxhenksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHN0eXBlID09PSBcXFwi5ryr55S7XFxcIiA/IFxcXCJjb21pY1xcXCIgOiBcXFwibm92ZWxcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZpZXc6IFxcXCIxXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pys5Zyw5Lmm5p62XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9Cb29rcmFjay52aWV3I25vUmVjb3JkSGlzdG9yeSM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYmcnVsZU5hbWU9JyArIFxcXCJEUlBZXFxcIiArIE1ZX1BBUkFNUy5zbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHN0eXBlID09PSBcXFwi5ryr55S7XFxcIiA/IFxcXCJjb21pY1xcXCIgOiBcXFwibm92ZWxcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcGxheW9iaiA9ICQuc3BsaXRBcnJheUJ5UmFuZ2VzKHBsYXlvYmosIHBhZ2VzKTtcXG4gICAgICAgICAgICByZXR1cm4gcGxheW9iajtcXG4gICAgICAgIH0pO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmmoLml6Dmkq3mlL7mupDmiJbmkq3mlL7liJfooajlrprkvY3plJnor69cXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBNWV9QQVJBTVMudm9kSWQsXFxuICAgICAgICB9KTtcXG4gICAgICAgIGNhY2hlU2hvd1RpcHMoKTtcXG4gICAgICAgIHNldFJlc3VsdChkKTtcXG4gICAgfVxcblxcblxcbiAgICBsZXQgY3VycmVudExvY2F0aW9uID0gMDtcXG5cXG4gICAgZnVuY3Rpb24gcmVub3ZhdGVMaXN0KGxvY2F0aW9uKSB7XFxuICAgICAgICAvL2RlbGV0ZUl0ZW1CeUNscyhcXFwicGxheXBhZ2VcXFwiKTtcXG4gICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgIGlmIChwbGF5VXJsTGlzdC5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgbGV0IHBjb3VudCA9IHBsYXlVcmxMaXN0W2xvY2F0aW9uXS5sZW5ndGg7XFxuICAgICAgICBsZXQgbGlzdCA9IHBsYXlVcmxMaXN0W2xvY2F0aW9uXVtwYWdlbnVtXTtcXG4gICAgICAgIGlmICghbGlzdCkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBwYWdlbnVtOyBpID49IDA7IGktLSkge1xcbiAgICAgICAgICAgICAgICBsaXN0ID0gcGxheVVybExpc3RbbG9jYXRpb25dW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAobGlzdCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IGk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChnZXRNeVZhcihcXFwic29ydGlcXFwiLCBcXFwiMFxcXCIpID09IDEpIHtcXG4gICAgICAgICAgICBsaXN0LnJldmVyc2UoKTtcXG4gICAgICAgIH1cXG4gICAgICAgICQuZXh0ZW5kKHtcXG4gICAgICAgICAgICB0ZW1wX2xpc3Q6IHBsYXlVcmxMaXN0W2xvY2F0aW9uXSxcXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgcGxheXAgPSBwbGF5cGFnZXNbbG9jYXRpb25dO1xcblxcbiAgICAgICAgaWYgKHBsYXlwICYmIHBsYXlwLmxlbmd0aCA+IDEpIHtcXG4gICAgICAgICAgICBsZXQgdGVtcCA9IHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0XzEnLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhZ2VhcnIgPSBwbGF5cC5tYXAoKHgsIGkpID0+IGkgPT0gcGFnZW51bSA/ICfigJzigJzigJ3igJ0nICsgeC5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogeCk7XFxuICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpXFxuICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5cGFnZWxpbmVcXFwiLCBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+S4iuS4gOmhtScsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bS0tO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHBsYXlwW3BhZ2VudW1dLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChwYWdlYXJyLCAzKS5zZWxlY3QoKGxvY2F0aW9uKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICB9LCBsb2NhdGlvbiksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6ICfkuIvkuIDpobUnLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgobG9jYXRpb24sIHBjb3VudCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAocGFnZW51bSA+PSBwY291bnQgLSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IDA7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0rKztcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKHBhZ2VudW0pKTtcXG4gICAgICAgICAgICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4ge30pKGxvY2F0aW9uKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGxvY2F0aW9uLCBwY291bnQpLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XSlcXG4gICAgICAgICAgICAvKnBsYXlwID0gcGxheXAubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIHRlbXAsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIChwYWdlbnVtID09IGkgPyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KSxcXG4gICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiKSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5bGlzdFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlsaXN0c1xcXCIsICQudGVtcF9saXN0W2ldKTtcXG4gICAgICAgICAgICAgICAgICAgZmluZEl0ZW1zQnlDbHMoXFxcInBsYXlwYWdlXFxcIikuZm9yRWFjaCgoeCwgaWkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSB4LnRpdGxlLnJlcGxhY2UoL+KAmHzigJl84oCcfOKAnXw8W14+XSs+L2csIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICBpZiAoaWkgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSAn4oCc4oCc4oCd4oCdJyArIHRpdGxlLmZvbnRjb2xvcihcXFwicmVkXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oeC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICB9LCBpKSxcXG4gICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgIGlkOiBcXFwicGFnZW51bVxcXCIgKyBpLFxcbiAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheXBhZ2VsaW5lXFxcIiwgcGxheXApKi9cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChsaXN0KSB7XFxuICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCBsaXN0KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxvY2F0aW9uQFxcXCIgKyBjdXJyZW50TG9jYXRpb24sIHtcXG4gICAgICAgICAgICB0aXRsZTogZnJvbVtjdXJyZW50TG9jYXRpb25dLFxcbiAgICAgICAgfSk7XFxuICAgICAgICB1cGRhdGVJdGVtKFxcXCJsb2NhdGlvbkBcXFwiICsgbG9jYXRpb24sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyBmcm9tW2xvY2F0aW9uXSArIFxcXCLigJ3igJ1cXFwiLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBjdXJyZW50TG9jYXRpb24gPSBsb2NhdGlvbjtcXG4gICAgfVxcblxcbiAgICBHTS5wdXQoXFxcInJlbm92YXRlTGlzdFxcXCIsIHJlbm92YXRlTGlzdCk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImJpZ19ibGFua19ibG9ja1xcXCJcXG4gICAgfSk7XFxuICAgIGlmIChmcm9tLmxlbmd0aCkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImJpZ19ibGFua19ibG9ja1xcXCIsXFxuICAgICAgICB9KVxcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc29ydG9ialtzb3J0aV0sXFxuICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChzbykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgc2kgPSBnZXRNeVZhcihcXFwic29ydGlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgaWkgPSAoc2kgPT0gXFxcIjBcXFwiID8gXFxcIjFcXFwiIDogXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwiQHNvcnRcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogc29baWldXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHZhciBwbGF5cyA9IGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5bGlzdFxcXCIpLnJldmVyc2UoKS5tYXAoeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICB4LmNvbF90eXBlID0geC50eXBlO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHg7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgcGxheXMpO1xcblxcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwic29ydGlcXFwiLCBpaSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgc29ydG9iaiksXFxuICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBpZDogXFxcIkBzb3J0XFxcIixcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgICAgZm9yIChsZXQgaSBpbiBmcm9tKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGZyb21baV0sXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaSwgaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkoaSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBpLCBpZCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpZDogXFxcImxvY2F0aW9uQFxcXCIgKyBpXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICAvL2NvbnNvbGUubG9nKHBsYXlVcmxMaXN0KTtcXG4gICAgLyppZiAocGxheVVybExpc3QubGVuZ3RoKSB7XFxuICAgICAgdmFyIGVqb2JqID0ge1xcbiAgICAgICAgXFxcImxpc3RcXFwiOiBwbGF5VXJsTGlzdCxcXG4gICAgICAgIFxcXCJ0YWJcXFwiOiBmcm9tLm1hcCgoeCwgaSkgPT4gZnJvbVtpXSlcXG4gICAgICB9O1xcbiAgICAgIOWIneWni+WMlihkLCBlam9iailcXG4gICAgfSBlbHNlIHtcXG4gICAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmmoLml6Dmkq3mlL7mupBcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbiAgICAgICAgdXJsOiBNWV9QQVJBTVMudm9kSWQsXFxuICAgICAgfSk7XFxuICAgIH0qL1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VsaW5lXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KVxcblxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IFxcXCJwbGF5bGlzdHNcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwicGxheWxpc3RzRU5EXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgY2FjaGVTaG93VGlwcygpO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIHJlbm92YXRlTGlzdChnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKSk7XFxufSkoKVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi6Kej5p6Q5paH5Lu2XCIsXCJwYXRoXCI6XCJjb25maWdzXCIsXCJydWxlXCI6XCJjb25zdCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvcnVsZXMvTG95RGdJay9wYXJzZXMuanNvblxcXCI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ydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG55WM77yM44CMXFxcIiArIG5hbWUgKyBcXFwi44CNRFJQWeino+aekO+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliKDpmaRcXFwiICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBhcnJbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9ICFydWxlLmZvcmJpZGRlbjtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgKHJ1bGUuZm9yYmlkZGVuID8gXFxcIuemgeeUqFxcXCIgOiBcXFwi5ZCv55SoXFxcIikgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgaSwgbGVuZ3RoKSx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widGV4dGFyZWFcXFwiLFxcbiAgICAgICAgaGVpZ2h0OiAzLFxcbiAgICAgICAgaGlnaGxpZ2h0OiB0cnVlLFxcbiAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19qc1xcXCIsIGlucHV0KTtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouanMsXFxuICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICB9XFxufSk7XFxuZC5wdXNoKHtcXG4gICAgY29sX3R5cGU6IFxcXCJsaW5lX2JsYW5rXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5Yig6ZmkXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgdXJsSW5kZXgpID0+IHtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mraTpobnml6Dms5XliKDpmaRcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHVybEluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ato+WcqOabtOaWsOino+aekO+8jOWIoOmZpOivt+S7juino+aekOeuoeeQhui/m+WFpVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liKDpmaTmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIGluZGV4KVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgIH0sIGluZGV4LCB1cmxJbmRleCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIua1i+ivlVxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBsZXQgdGVzdEtleXdvcmQgPSBnZXRJdGVtKFxcXCJ0ZXN0VXJsXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgcmV0dXJuICQodGVzdEtleXdvcmQsIFxcXCLor7fovpPlhaXlvbHop4bnvZHnq5nlnLDlnYBcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidGVzdFVybFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gZ2V0TXlWYXIoXFxcInBzX3VybFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IGdldE15VmFyKFxcXCJwc19uYW1lXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBmbGFnID0gZ2V0TXlWYXIoXFxcInBzX2ZsYWdcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IGhlYWRlcnMgPSBnZXRNeVZhcihcXFwicHNfaGVhZGVyc1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBtZXRob2QgPSBnZXRNeVZhcihcXFwicHNfbWV0aG9kXFxcIiwgXFxcIkdFVFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBqc29uUGF0aCA9IGdldE15VmFyKFxcXCJwc19qc29uUGF0aFxcXCIsIFxcXCJcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcbiAgICAgICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICAgICAgaWYgKGhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAg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maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG9iajEgPSB7XFxuICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgIGpzXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4g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uICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFwiICsgaW5kZXggKyBcXFwiJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID4gMSk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94eSh0aXRsZSkge1xcbiAgICBmdW5jdGlvbiB0b1BhdGgodmFsdWUpIHtcXG4gICAgICAgIGlmICh0eXBlb2YgdmFsdWUgIT09ICdzdHJpbmcnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHBhdGggPSBbXTtcXG4gICAgICAgIGxldCBjdXJyZW50ID0gJyc7XFxuICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgbGV0IGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2YWx1ZS5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxuICAgICAgICAgICAgaWYgKGVzY2FwZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1xcXFxcXFxcJykge1xcbiAgICAgICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxuICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGN1cnJlbnQpIHtcXG4gICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gcGF0aDtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBnZXRKc29uKG9iaiwgcGF0aCkge1xcbiAgICAgICAgaWYgKCFvYmogfHwgIUFycmF5LmlzQXJyYXkocGF0aCkpIHtcXG4gICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHBhdGgubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBjdXJyZW50ID0gb2JqO1xcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgbGV0IGtleSA9IHBhdGhbaV07XFxuICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IG51bGwgfHwgY3VycmVudCA9PT0gdW5kZWZpbmVkIHx8IHR5cGVvZiBjdXJyZW50ICE9PSAnb2JqZWN0Jykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtrZXldO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGN1cnJlbnQ7XFxuICAgIH1cXG4gICAgdHJ5IHtcXG4gICAgICAgIGxldCBydW5UeXBlID0gTVlfUEFSQU1TLnJ1blR5cGVbMF07XFxuICAgICAgICBsZXQgdXJsID0gZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKSk7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFwiSlNPTlxcXCIpIHtcXG5cXG4gICAgICAgICAgICBsZXQgcGFyYW0gPSBKU09OLnBhcnNlKGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiBwYXJhbS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgICAgICAgICAgICBtZXRob2Q6IHBhcmFtLm1ldGhvZCB8fCB2b2lkIDBcXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiBPYmplY3QuYXNzaWduKHt9LCBwYXJhbS5oZWFkZXJzIHx8IHt9LCB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiBnZXRKc29uKGpzb24sIHRvUGF0aChwYXJhbS5qc29uUGF0aCkpLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09IFxcXCJKU1xcXCIpIHtcXG5cXG4gICAgICAgICAgICBsZXQgcGFyc2U7XFxuICAgICAgICAgICAgaWYgKE1ZX1BBUkFNUy5pbmRleCkge1xcbiAgICAgICAgICAgICAgICBwYXJzZSA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyB0aXRsZSkuZ2V0SnNvbigpW01ZX1BBUkFNUy5pbmRleFswXV07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcGFyc2UgPSBKU09OLnBhcnNlKGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcmVzID0gbmV3IEZ1bmN0aW9uKFxcXCJ1cmxcXFwiLCBcXFwic2VsZlxcXCIsIHBhcnNlLmpzKSh1cmwsIHBhcnNlKTtcXG4gICAgICAgICAgICBpZiAodHlwZW9mIHJlcyA9PT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiByZXNcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICgkLnR5cGUocmVzKSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHJlc1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICB9XFxufVxcblxcbmZ1bmN0aW9uIHByZXBhcmVQYXJzZXMocGFyc2VzLCB1cmwsIHBsYXlsaXN0LCBpc1Rlc3QpIHtcXG4gICAgcGxheWxpc3QgPSBwbGF5bGlzdCB8fCB7XFxuICAgICAgICB1cmxzOiBbXSxcXG4gICAgICAgIG5hbWVzOiBbXSxcXG4gICAgICAgIGhlYWRlcnM6IFtdLFxcbiAgICAgICAgaXM6IFxcXCIjaXNWaWRlbz10cnVlI1xcXCIsXFxuICAgIH07XFxuICAgIGxldCBwcm94eVVybCA9IHN0YXJ0UHJveHlTZXJ2ZXIoJC50b1N0cmluZyhwcm94eSwgTVlfUlVMRS50aXRsZSkpO1xcbiAgICBwYXJzZXMuZm9yRWFjaCgodiwgaSkgPT4ge1xcbiAgICAgICAgaWYgKHYuZm9yYmlkZGVuKSByZXR1cm47XFxuICAgICAgICBwbGF5bGlzdC5uYW1lcy5wdXNoKHYubmFtZSk7XFxuICAgICAgICBpZiAodi5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgcGxheWxpc3QuaGVhZGVycy5wdXNoKHYuaGVhZGVycyk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAodi5ydW5UeXBlID09PSBcXFwiSlNPTlxcXCIpIHtcXG4gICAgICAgICAgICBsZXQgcGFyYW0gPSB7XFxuICAgICAgICAgICAgICAgIC8vdXJsOiB2LnVybCxcXG4gICAgICAgICAgICAgICAgbWV0aG9kOiB2Lm1ldGhvZCxcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogdi5oZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aDogdi5qc29uUGF0aFxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgcGxheWxpc3QudXJscy5wdXNoKHByb3h5VXJsICsgXFxcIj9ydW5UeXBlPUpTT04mdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoYmFzZTY0RW5jb2RlKHYudXJsICsgdXJsKSkgKyBcXFwiJnBhcmFtPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHBhcmFtKSkpKTtcXG4gICAgICAgIH0gZWxzZSBpZiAodi5ydW5UeXBlID09PSBcXFwiSlNcXFwiKSB7XFxuICAgICAgICAgICAgcGxheWxpc3QudXJscy5wdXNoKHByb3h5VXJsICsgXFxcIj9ydW5UeXBlPUpTJnVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGJhc2U2NEVuY29kZSh1cmwpKSArIChpc1Rlc3QgPyBcXF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nZT1meXBhZ2UmcmVhbHVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHBsYXkudXJsKTtcXG4gICAgfVxcbiAgICBpZiAocGxheS51cmwuc3RhcnRzV2l0aChcXFwicGljczovL1xcXCIpKSB7XFxuICAgICAgICByZXR1cm4gcGxheS51cmw7XFxuICAgIH1cXG4gICAgaWYgKHBsYXkudXJsLnN0YXJ0c1dpdGgoXFxcIm5vdmVsOi8vXFxcIikpIHtcXG4gICAgICAgIHJldHVybiAkKFxcXCJoaWtlcjovL2VtcHR5I3JlYWRUaGVtZSNcXFwiKS5ydWxlKChkYXRhKSA9PiB7XFxuICAgICAgICAgICAgbGV0IGRhdGEgPSBKU09OLnBhcnNlKGRhdGEpO1xcbiAgICAgICAgICAgIGxldCBsYXlvdXQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgY29udGVudCA9IFxcXCLjgIDjgIBcXFwiICsgZGF0YS5jb250ZW50LnNwbGl0KC8oXFxcXG58XFxcXHIpKy8pLmZpbHRlcihpdCA9PiBpdC50cmltKCkubGVuZ3RoID4gMSkubWFwKGl0ID0+IGl0LnRyaW0oKSkuam9pbihcXFwiPGJyPuOAgOOAgFxcXCIpO1xcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJyaWNoX3RleHRcXFwiLFxcbiAgICAgICAgICAgICAgICB0aXRsZTogKFxcXCI8c3Ryb25nPlxcXCIgKyBkYXRhLnRpdGxlICsgXFxcIjwvc3Ryb25nPlxcXCIpLmJpZygpLFxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGNvbnRlbnQsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAncmljaF90ZXh0JyxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIHRleHRTaXplOiAxOCxcXG4gICAgICAgICAgICAgICAgICAgIGNsaWNrOiB0cnVlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBzZXRSZXN1bHQobGF5b3V0KTtcXG4gICAgICAgIH0sIHBsYXkudXJsLnJlcGxhY2UoXFxcIm5vdmVsOi8vXFxcIixcXFwiXFxcIikpO1xcbiAgICB9XFxuICAgIGlmIChwbGF5LnBhcnNlID09PSAxKSB7XFxuICAgICAgICBpZiAocGxheS51cmwuc3RhcnRzV2l0aChcXFwibWFnbmV0OlxcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBsYXkudXJsO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGlzb2ZmaWNpYWwocGxheS51cmwpICYmIChwbGF5LmZsYWcgfHwgaW5wdXRbMV0pKSB7XFxuICAgICAgICAgICAgcmV0dXJuIHVzZVBhcnNlcyhwbGF5LnVybCk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcInZpZGVvOi8vXFxcIiArIHBsYXkudXJsO1xcbiAgICB9IGVsc2UgaWYgKHBsYXkucGFyc2UgPT09IDApIHtcXG4gICAgICAgIGlmIChwbGF5LnVybC5zdGFydHNXaXRoKFxcXCJtYWduZXQ6XFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGxheS51cmw7XFxuICAgICAgICB9XFxuICAgICAgICAvL2xvZyhwbGF5KVxcbiAgICAgICAgdmFyIHBsYXlvYmogPSB7fTtcXG4gICAgICAgIHBsYXlvYmoudXJscyA9IFtwbGF5LnVybCArIFxcXCIjaXNWaWRlbz10cnVlI1xcXCJdO1xcbiAgICAgICAgaWYgKHBsYXkuaGFzT3duUHJvcGVydHkoXFxcImhlYWRlclxcXCIpKSB7XFxuICAgICAgICAgICAgcGxheW9ialtcXFwiaGVhZGVyc1xcXCJdID0gcGxheS5oZWFkZXI7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocGxheS5oYXNPd25Qcm9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KTtcXG4gICAgXFxuICAgIGxldCBqc29uVGV4dCA9IHBkZmgoaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpO1xcbiAgICBcXG4gICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGpzb25UZXh0KTtcXG4gICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuICAgIGxldCBjb3VudCA9IDA7XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC5uYW1lO1xcbiAgICAgICAgICAgIGxldCBzcGF0aCA9IGl0LnBhdGg7XFxuICAgICAgICAgICAgaWYgKCFuYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkgY29udGludWU7XFxuICAgICAgICAgICAgbmFtZSA9IG5hbWUuc2xpY2UoMCwgbmFtZS5sYXN0SW5kZXhPZihcXFwiLlxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKGBodHRwczovL3Jhdy5naXRtaXJyb3IuY29tLyR7cm9wZX0vbWFzdGVyLyR7c3BhdGh9YCk7XFxuICAgICAgICAgICAgaWYgKCEoKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpICYmICFmaWxlRXhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgIC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gICAgICAgICAgbGV0IG5hbWUgPSBpdC5leHQuZW5kc1dpdGgoXFxcIi5qc1xcXCIpID8gZGVjb2RlVVJJQ29tcG9uZW50KGl0LmV4dC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKSkgOiAoaXQubmFtZSArIFxcXCIuanNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGU7XFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGl0LmV4dCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChqb2luVXJsKHVybCwgaXQuZXh0KSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcIi4vXFxcIiArIG5hbWU7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5z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R1cm4gbnVsbDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAvL2NvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gSlNPTi5wYXJzZShmZXRjaChzZWFyY2hBbGxvd1BhdGgpIHx8IFxcXCJbXVxcXCIpO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGRlbGV0ZUZpbGUoc2VhcmNoQWxsb3dQYXRoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlLFxcbiAgICAgICAgICAgIHNlYXJja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5qc1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcbiAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge31cXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcbiAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcbiAgICAgICAgICAgIHVybDogb2JqLnVybCxcXG4gICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgY29kZTogY29kZSxcXG4gICAgICAgICAgICBpbmRleDogb2JqLmlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgdmFyIGogPSBKU09OLnBhcnNlKGZldGNoKG9iai51cmwsIHtcXG4gICAgICAgICAgd2l0aEhlYWRlcnM6IHRydWUsXFxuICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxuICAgICAgICB9KS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AgICAgICBuYW1lXFxuICAgICAgICB9ID0gaXRlbTtcXG4gICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgbmFtZSxcXG4gICAgICAgIH0pKSB7XFxuICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICBEcnB5TWFuYWdlLmNsZWFyKCk7XFxuICAgICAgICAgICQucmVxdWlyZShcXFwiQ2hhbmdlU291cmNlUG9wXFxcIikuc2hvdygxMDApO1xcbiAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WIh+aNouWksei0pVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgfSwgaXRlbSksXFxuICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBpZDogJ3BhdGgnICsgaSxcXG4gICAgICAgIGxvbmdDbGljazogbG9uZ0NcXG4gICAgICB9XFxuICAgIH0pXFxuICB9KVxcbn1cXG5cXG5cXG5zZXRSZXN1bHQobGF5b3V0KTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuaNoua6kOW8ueeql1wiLFwicGF0aFwiOlwiQ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QgPSBuYW1lcy5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXG4gICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgfSk7XFxuICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgfSxcXG4gICAgICBkZWZhdWx0VmFsdWU6IFxcXCJcXFwiLFxcbiAgICAgIGNsaWNrKHMsIG1hbmFnZSkge1xcbiAgICAgICAgLy90b2FzdChzKTtcXG4gICAgICAgIC8vbG9nKG1hbmFnZS5saXN0KTtcXG4gICAgICB9LFxcbiAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXG4gICAgfSksIFxcbiAgICBsb25nQ2xpY2socywgaSkge1xcbiAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliIbkuqvop4bpopHmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIkpT5paH5Lu25YiG5LqrXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSxcXG4gICAgICAgICAgICAgICAgY29sOiAyLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhuYW1lID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0a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HRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCkubWFwKHggPT4geC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbGlzdC5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZmxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgIH0sXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIGxldCBuYXR1cmFsID0gZ2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAobmF0dXJhbCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIGxpc3Quc29ydChuYXR1cmFsU29ydCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgbmF0dXJhbCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgbmFtZXMucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBhcnJheURpZmZlcmVuY2UoYXJyMSwgYXJyMikge1xcbiAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXG4gICAgICAgICAgICAgIHJldHVybiBhcnIxLmZpbHRlcihpdGVtID0+ICFtYXAuaGFzKGl0ZW0ua2V5KSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgbGV0IENrZXkgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKS5rZXk7XFxuICAgICAgICAgICAgLy9sb2coQ2tleSlcXG4gICAgICAgICAgICBsZXQgY2ZnID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50Q29uZmlnKClcXG4gICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgIG5hbWVcXG4gICAgICAgICAgICB9ID0gY2ZnO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRTb3VyY2UoQ2tleSk7XFxuICAgICAgICAgICAgbGV0IG5zb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG5cXG4gICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcbiAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDAgfHwgZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgYWxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGxvZyhcXFwi5paw5aKeOlxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgbXNnICs9IFxcXCLmlrDlop5cXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICBkbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBsb2coXFxcIuenu+mZpDpcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXCIg5pu05aSa6K+m5oOF55yLbG9nXFxcIik7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHRvYXN0KFxcXCLlt7LliLfmlrBcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgfSk7XFxuICAgIH1cXG4gIH0pO1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2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAxKSB7XFxuICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG5cXG5cXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXG4gICAgICAgICAgICAgICAgbnVtZXJpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgc2Vuc2l0aXZpdHk6ICdiYXNlJ1xcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnJldmVyc2UoKTtcXG5cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2KSkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICh0ZW1saXN0LmluY2x1ZGVzKHYua2V5KSkgcmV0dXJuO1xcbiAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0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ICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyB0LFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gby5pO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiaXNfZGVmXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwge30pO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIGlmIChjYXRlX3RlbXAuY29uc3RydWN0b3IgIT0gQXJyYXkpIHtcXG4gICAgICAgICAgICAgICAgICBjYXRlX3RlbXAgPSBbXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmluZGV4O1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgLy9sb2coYylcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVfdGVtcClcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcih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