Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjo0LCJjb2xfdHlwZSI6Im1vdmllXzMiLCJjbGFzc19uYW1lIjoiIiwidHlwZSI6InZpZGVvIiwiY2xhc3NfdXJsIjoiIiwiYXJlYV9uYW1lIjoiIiwiYXJlYV91cmwiOiIiLCJzb3J0X25hbWUiOiIiLCJ5ZWFyX25hbWUiOiIiLCJzb3J0X3VybCI6IiIsInllYXJfdXJsIjoiIiwiZmluZF9ydWxlIjoianM6XG5mdW5jdGlvbiBsb2FkKGQsIGRycHksIHNvdXJjZSkge1xuICAgIGxldCBwYWdlID0gTVlfUEFHRTtcbiAgICBsZXQgY2F0ZWdvcnlzID0gJC5yZXF1aXJlKFwiY2F0ZWdvcnlzXCIpO1xuICAgIGNhdGVnb3J5cy5nZXRjYXRlZ29yeXMoZCwgZHJweSwgcGFnZSk7XG4gICAgbGV0IHtcbiAgICAgICAgY2F0ZSxcbiAgICAgICAgaG9tZWxpc3RcbiAgICB9ID0gY2F0ZWdvcnlzLmdldGNhdGVsaXN0KCk7XG4gICAgaWYgKGdldE15VmFyKFwibGlua3NcIiwgXCJcIikgPT0gXCIxXCIpIHtcbiAgICAgICAgc2V0UHJlUmVzdWx0KGQpO1xuICAgICAgICBkLmxlbmd0aCA9IDA7XG4gICAgfVxuICAgIGxldCBmbCA9IGNhdGVnb3J5cy5nZXRmbCgpO1xuXG4gICAgbGV0IGxpc3QgPSBbXTtcbiAgICBpZiAoY2F0ZSA9PSBcImhvbWVcIikge1xuICAgICAgICBpZiAocGFnZSA9PSAxKSB7XG4gICAgICAgICAgICBsaXN0ID0gaG9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iB1cmwsXG4gICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogaG9tZUxpc3RDb2wsXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICB2b2RJZDogaWQsXG4gICAgICAgICAgICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgc2tleTogc291cmNlLmtleSxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFwi6IGa5ZCI5pCc57SiXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogXCJwdXRNeVZhcigndGVtc21vZGUnLCAnMScpOydoaWtlcjovL3NlYXJjaD9ydWxlPScgKyBNWV9SVUxFLnRpdGxlICsgJyZzPVwiICsgbmFtZSArIFwiJztcIlxuICAgICAgICAgICAgICAgICAgICB9XVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxufVxuXG5mdW5jdGlvbiBzZXREcnB5UGF0aChkKSB7XG4gICAgZC5wdXNoKHtcbiAgICAgICAgdGl0bGU6IFwi57y65bCR6L+Q6KGM5bqTXFxu6K+l5bCP56iL5bqP5LiN6IO96YCa6L+H5LqR5Ymq6LS05p2/5YiG5Lqr77yM5Y+q6IO96YCa6L+H5omT5YyF5YiG5LqrXCIsXG4gICAgICAgIGRlc2M6IFwi5bCG6L+Q6KGM5bqT5pS+5YWlXCIgKyBnZXRQYXRoKFwiaGlrZXI6Ly9maWxlcy9kYXRhL1wiICsgTVlfUlVMRS50aXRsZSArIFwiL2xpYnNfaGlrZXIvZHJweTIuanNcIiksXG4gICAgICAgIGNvbF90eXBlOiBcInRleHRfY2VudGVyXzFcIixcbiAgICAgICAgdXJsOiBcImhpa2VyOi8vZW1wdHlcIlxuICAgIH0pO1xufVxuXG5mdW5jdGlvbiBzZXRIaWVkKGQsIG5hbWUsIGNvbmZpZykge1xuICAgIGxldCBmaWxlU2VsZWN0ID0gJC5yZXF1aXJlKFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NTA5OVwiKTtcbiAgICBkLnB1c2goe1xuICAgICAgICB0aXRsZTogbmFtZSB8fCBcIlwiLFxuICAgICAgICBjb2xfdHlwZTogJ2ljb25fM19yb3VuZF9maWxsJyxcbiAgICAgICAgaW1nOiAnaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9zeXN0ZW0vMTMwLnBuZycsXG4gICAgICAgIHVybDogJChcIiNub0xvYWRpbmcjXCIpLmxhenlSdWxlKCgpID0+IHtcbiAgICAgICAgICAgICQucmVxdWlyZShcIkNoYW5nZVNvdXJjZVBvcFwiKS5zaG93KCk7XG4gICAgICAgICAgICByZXR1cm4gXCJoaWtlcjovL2VtcHR5XCI7XG4gICAgICAgIH0pLFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgY3BhdGg6IGNvbmZpZy5wYXRoLFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIuabtOaNoumFjee9rlwiLFxuICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXCIpXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwi5Yi35paw5rqQXCIsXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIik7XG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpO1xuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5pbml0KHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpKTtcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIuWujOWFqOWIt+aWsOa6kFwiLFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKTtcbiAgICAgICAgICAgICAgICAgICAgRHJweU1hbmFnZS5kZWwoc291cmNlLmtleSk7XG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1dLmNvbmNhdChjb25maWcudHlwZSA9PT0gXCJsb2NhbERpclwiID8gW3tcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLmnKzlnLDnrqHnkIZcIixcbiAgICAgICAgICAgICAgICBqczogXCInaGlrZXI6Ly9wYWdlL0xvY2FsRGlyI25vUmVjb3Jk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AgIGlkOiBNWV9SVUxFLnRpdGxlICsgXCJAc2VhcmNoX21vZGVcIixcbiAgICAgICAgICAgIGxvbmdDbGljazogW3tcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLmjIflrprmkJzntKLmupBcIixcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcIlNlYXJjaEFsbG93UG9wXCIpLnNob3coKTtcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfV1cbiAgICAgICAgfVxuICAgIH0pO1xuICAgIGQucHVzaCh7XG4gICAgICAgIHRpdGxlOiBcIuiuvue9rlwiLFxuICAgICAgICB1cmw6ICQoW1wi6Kej5p6Q566h55CGXCIsIFwi5a6Y5pa55by55bmVXCIsIFwiZHJweeiwg+ivleaXpeW/lzpcIiArIChnZXRJdGVtKFwidXNlTG9nXCIsIFwiXCIpID09IFwiXCIgPyBcIuWFs+mXrVwiIDogXCLlvIDlkK9cIiksIFwi5Yib5bu66K6i6ZiF5Zyw5Z2AXCIsIFwi5YiH5o2i5YiX6KGo5qC35byPXCJdLCAxLCBcIuiuvue9rlwiKS5zZWxlY3QoKCkgPT4ge1xuICAgICAgICAgICAgaWYgKFwi6Kej5p6Q566h55CGXCIgPT0gaW5wdXQpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gXCJoaWtlcjovL3BhZ2UvcnVsZU1hbmFnZSNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcIjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoXCLlrpjmlrnlvLnluZVcIiA9PT0gaW5wdXQpIHtcbiAgICAgICAgICAgICAgICBsZXQgdXNlRGFubXUgPSAhIWdldEl0ZW0oXCJ1c2VEYW5tdVwiLCBcIlwiKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcIuW9k+S4uuWumOa6kOaXtuWMuemFjeW8ueW5lSjpnIDopoFkYW5tdeebkuWtkOaUr+aMgSlcXG7lvZPliY06XCIgKyB1c2VEYW5tdSArIFwiXFxu54K55Ye756Gu5a6a5Y2z5Y+vXCIgKyAodXNlRGFubXUgPyBcIuWFs+mXrVwiIDogXCLlvIDlkK9cIikpLmNvbmZpcm0oKHVzZURhbm11KSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXCJ1c2VEYW5tdVwiLCB1c2VEYW5tdSA/IFwiXCIgOiBcIjFcIik7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcInRvYXN0Oi8vXCIgKyAodXNlRGFubXUgPyBcIuW3suWFs+mXrVwiIDogXCLlt7LlvIDlkK9cIik7XG4gICAgICAgICAgICAgICAgfSwgdXNlRGFubXUpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dC5pbmNsdWRlcyhcImRycHnosIPor5Xml6Xlv5dcIikpIHtcbiAgICAgICAgICAgICAgICBsZXQgdXNlTG9nID0gISFnZXRJdGVtKFwidXNlTG9nXCIsIFwiXCIpO1xuICAgICAgICAgICAgICAgIHJldHVybiAkKFwi5byA5ZCv5pel5b+X6L6F5Yqp6LCD6K+V77yM5pmu6YCa5L2/55So5LiN6ZyA6KaB5byA5ZCvXFxu5b2T5YmNOlwiICsgdXNlTG9nICsgXCJcXG7ngrnlh7vnoa7lrprljbPlj69cIiArICh1c2VMb2cgPyBcIuWFs+mXrVwiIDogXCLlvIDlkK9cIikpLmNvbmZpcm0oKHVzZUxvZykgPT4ge1xuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFwidXNlTG9nXCIsIHVzZUxvZyA/IFwiXCIgOiBcIjFcIik7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFwicnVudGltZUNvbmZpZ1wiKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXCJ0b2FzdDovL1wiICsgKHVzZUxvZyA/IFwi5bey5YWz6ZetXCIgOiBcIuW3suW8gOWQr1wiKTtcbiAgICAgICAgICAgICAgICB9LCB1c2VMb2cpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXCLliJvlu7rorqLpmIXlnLDlnYBcIikge1xuICAgICAgICAgICAgICAgIHJldHVybiBcImhpa2VyOi8vcGFnZS9jcmVhdGVTdWJzY3JpcHRpb24jbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXCI7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGxldCBjb2xsaXN0ID0gW1wibW92aWVfM19tYXJxdWVlXCIsIFwibW92aWVfM1wiLCBcIm1vdmllXzJcIiwgXCJtb3ZpZV8xXCIsIFwidGV4dF8xXCJdO1xuICAgICAgICAgICAgICAgIGxldCBob21lTGlzdENvbCA9IGdldEl0ZW0oXCJob21lTGlzdENvbFwiLCBcIm1vdmllXzNfbWFycXVlZVwiKTtcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBjb2xsaXN0LmluZGV4T2YoaG9tZUxpc3RDb2wpO1xuICAgICAgICAgICAgICAgIHJldHVybiAkKGNvbGxpc3QsIDEsIFwi6YCJ5oup5qC35byPXCIsIGluZGV4KS5zZWxlY3QoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFwiaG9tZUxpc3RDb2xcIiwgaW5wdXQpO1xuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSxcbiAgICAgICAgcGljX3VybDogXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21lc3N5LzMwLnN2Z1wiLFxuICAgICAgICBjb2xfdHlwZTogXCJpY29uXzNfcm91bmRfZmlsbFwiLFxuICAgIH0pO1xuICAgIGQucHVzaCh7XG4gICAgICAgIHRpdGxlOiAn5pCc57SiJyxcbiAgICAgICAgLy9kZXNjOiAnJyxcbiAgICAgICAgZGVzYzogJ+imgeaQnOeCueS7gOS5iCcsXG4gICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICByZXR1cm4gJ2hpa2VyOi8vc2VhcmNoP3J1bGU9JyArIE1ZX1JVTEUudGl0bGUgKyBcIiZzPVwiICsgaW5wdXQ7XG4gICAgICAgIH0pLFxuICAgICAgICBjb2xfdHlwZTogJ2lucHV0JyxcbiAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogZ2V0TXlWYXIoXCJrZXl3b3JkXCIsIFwiXCIpLFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHB1dE15VmFyKFwia2V5d29yZFwiLCBpbnB1dClcbiAgICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICB9KVxufVxubGV0IGQgPSBbXTtcblxubGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXCJydW50aW1lQ29uZmlnXCIpO1xubGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpO1xuRHJweU1hbmFnZS5pbml0UGFnZShcImhvbWVcIik7XG5hZGRMaXN0ZW5lcihcIm9uQ2xvc2VcIiwoKT0+e1xuICAgIGNsZW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AgICBpZiAoTVlfUEFHRSA9PT0gMSkge1xuICAgICAgICAgICAgaWYgKHNvdXJjZSA9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBzZXRIaWVkKGQpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzZXRIaWVkKGQsIHNvdXJjZS5uYW1lLCBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKSB8fCB7fSk7XG4gICAgICAgIH1cbiAgICAgICAgLy9sb2coRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkpXG4gICAgICAgIGlmIChnZXRNeVZhcihcImxpbmtzXCIsIFwiXCIpID09IFwiXCIpIHtcbiAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6ICfliqDovb3kuK0uLi4nLFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMScsXG4gICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vZW1wdHlcIixcbiAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXCJsb2FkXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICAgICAgc2V0UHJlUmVzdWx0KGQpXG4gICAgICAgIH1cbiAgICAgICAgaWYgKHNvdXJjZSkge1xuICAgICAgICAgICAgbG9hZChkLCBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KSwgc291cmNlKTtcbiAgICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICAgIHNldERycHlQYXRoKGQpO1xuICAgIH1cblxufSBjYXRjaCAoZSkge1xuICAgIGQucHVzaCh7XG4gICAgICAgIHRpdGxlOiBcIuKAnOKAnFwiICsgZS50b1N0cmluZygpICsgXCLigJ3igJ1cIixcbiAgICAgICAgZGVzYzogZS5saW5lT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OiBpdC52b2RfY29udGVudCxcbiAgICAgICAgdXJsOiBcImhpa2VyOi8vcGFnZS9kZXRhaWxlZCNpbW1lcnNpdmVUaGVtZSNcIixcbiAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgIHZvZElkOiBpdC52b2RfaWQsXG4gICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcbiAgICAgICAgICBza2V5OiBzb3VyY2Uua2V5XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cbiAgICBzZXRSZXN1bHQoZCk7XG4gIH0gZWxzZSB7XG4gICAgc2V0UmVzdWx0KFt7XG4gICAgICB0aXRsZTogXCLngrnmiJHlvIDlp4vogZrlkIjmkJzntKJcIiArIE1ZX0tFWVdPUkQsXG4gICAgICB1cmw6IFwiaGlrZXI6Ly9zZWFyY2g/cz1cIiArIE1ZX0tFWVdPUkQsXG4gICAgICBleHRyYToge1xuICAgICAgICBkZWxlZ2F0ZU9ubHlTZWFyY2g6IHRydWUsXG4gICAgICAgIHJ1bGVzOiAkLnRvU3RyaW5nKCgpID0+IHtcbiAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXCJydW50aW1lQ29uZmlnXCIsIFwicnVudGltZUNvbmZpZ1wiKTtcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxvd1NlYXJjaFNvdXJjZSgpO1xuICAgICAgICAgICAgXG4gICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG4gIFxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcbiAgICAgICAgICAgIFxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xuICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpLmdldChpdGVtLmtleSk7XG5cbiAgICAgICAgICAgICAgICAgIGxldCBob21lTGlzdCA9IEpTT04ucGFyc2UoZHJweS5zZWFyY2goTVlfS0VZV09SRCwgZmFsc2UsIE1ZX1BBR0UpKS5saXN0IHx8IFtdO1xuICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcbiAgICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnZvZF9uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICAgICAgICAgICAgICAgIHVybDogXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWQjaW1tZXJzaXZlVGhlbWUjXCIsXG4gICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZvZElkOiBpdC52b2RfaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgICBzbmFtZTogaXRlbS5uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2tleTogaXRlbS5rZXksXG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIHNldFJlc3VsdChkKTtcbiAgICAgICAgICAgICAgICB9LCBpdClcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkocnVsZXMpO1xuICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSlcbiAgICAgIH1cbiAgICB9XSk7XG4gIH1cbn0pKCkiLCJkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwiZGV0YWlsX2ZpbmRfcnVsZSI6IiIsInNkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwic2RldGFpbF9maW5kX3J1bGUiOiIiLCJ1YSI6Im1vYmlsZSIsInByZVJ1bGUiOiIvKjwkPlxuQGluY2x1ZGUgc3RhcnRcbmh0dHA6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ICAgICAgfVxcbiAgICB9O1xcbiAgICBldmFsKGdldENyeXB0b0pTKCkpO1xcbiAgICBnbG9iYWxUaGlzLkNyeXB0b0pTID0gQ3J5cHRvSlM7XFxuXFxuICAgIGxldCAkcmVxdWVzdCA9IHJlcXVlc3Q7XFxuICAgIGxldCAkcG9zdCA9IHBvc3Q7XFxuICAgIGdsb2JhbFRoaXMucmVxID0gZnVuY3Rpb24gKHVybCwgY29iaikge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcmVzID0ge307XFxuICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIGNvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmouZGF0YSkge1xcbiAgICAgICAgICAgICAgICBvYmouYm9keSA9IG9iai5kYXRhO1xcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqLmRhdGE7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoXFxcInJlZGlyZWN0XFxcIikpIG9iai5yZWRpcmVjdCA9ICEhb2JqLnJlZGlyZWN0O1xcbiAgICAgICAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICAgICAgICAgIG9iai50b0hleCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iai5oZWFkZXJzID0gT2JqZWN0LmFzc2lnbih7XFxuICAgICAgICAgICAgICAgIENvb2tpZTogXFxcIiNub0Nvb2tpZSNcXFwiXFxuICAgICAgICAgICAgfSwgb2JqLmhlYWRlcnMpO1xcbiAgICAgICAgICAgIGlmICh1cmwgPT09IFxcXCJodHRwczovL2FwaS5ubi5jaS9vY3IvYjY0L3RleHRcXFwiICYmIG9iai5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW1xcXCJDb250ZW50LVR5cGVcXFwiXSA9IFxcXCJ0ZXh0L3BsYWluXFxcIjtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKHVybC5zdGFydHNXaXRoKFxcXCJmaWxlOi8vXFxcIikgJiYgKHVybC5pbmNsdWRlcyhcXFwiP3R5cGU9XFxcIikgfHwgdXJsLmluY2x1ZGVzKFxcXCI/cGFyYW1zPVxcXCIpKSkge1xcbiAgICAgICAgICAgICAgICB1cmwgPSB1cmwuc2xpY2UoMCwgdXJsLmxhc3RJbmRleE9mKFxcXCI/XFxcIikpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBmb3IgKGxldCBrZXkgaW4gb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBvYmouaGVhZGVyc1trZXldICE9PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNba2V5XSA9IFN0cmluZyhvYmouaGVhZGVyc1trZXldKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgciA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIC8qIGlmIChTdHJpbmcob2JqLm1ldGhvZCkudG9Mb3dlckNhc2UoKSA9PT0gXFxcInBvc3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICBpZiAob2JqLndpdGhIZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHIuYm9keTtcXG4gICAgICAgICAgICAgICAgcmVzLmhlYWRlcnMgPSB7fTtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzW2tdID0gdlswXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VIZXgocmVzLmNvbnRlbnQpLnRvQmFzZTY0KF9iYXNlNjQuTk9fV1JBUCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKFxcXCJFcnJvclxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIC8qXFxuICAgIGNvbnN0IEppbkphID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2Nkbi5ib290Y2RuLm5ldC9hamF4L2xpYnMvbXVzdGFjaGUuanMvNC4xLjAvbXVzdGFjaGUuanNcXFwiKTtcXG4gIFxcbiAgICBjb25zdCBKUCA9ICQucmVxdWlyZShcXFwiaHR0cHM6Ly9qc29ucGF0aC1wbHVzLmdpdGh1Yi5pby9KU09OUGF0aC9kaXN0L2luZGV4LWJyb3dzZXItdW1kLmNqc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmNoZWVyaW8gPSB7XFxuICAgICAgICBqaW5qYTIodGVtcGxhdGUsIG9iaikge1xcbiAgICAgICAgICAgIFxcbiAgICAgICAgICAgIHJldHVybiAkLmxvZyhKaW5KYS5yZW5kZXIodGVtcGxhdGUsIG9iaikpO1xcbiAgICAgICAgfSxcXG4gICAgICAgI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XFxcIiNcXFwiKS5tYXAoKGopID0+IHtcXG4gICAgICAgIGxldCBrID0gai5zcGxpdChcXFwiJFxcXCIpO1xcbiAgICAgICAgbGV0IHQgPSBrWzBdO1xcbiAgICAgICAgbGV0IHVpZCA9IChrWzFdfHxrWzBdKTtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgfSksXFxuICAgICAgICAgIHVybDogIHVpZCsgXFxcIiNcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5LnJlcGxhY2UoJ1xcXCJpZFxcXCInLCAnXFxcIicgK3VpZCArICdcXFwiJyksXFxuICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcbiAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgIGlkOiBrWzFdLFxcbiAgICAgICAgICAgIC8vbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgfSkqL1xcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiB1aWQsXFxuICAgICAgICAgICAgYmxvY2tSdWxlczogWydiYi4qLnBuZycsICcuanBnJywgXFxcImhtXFxcXC5iYWlkdVxcXFwuY29tXFxcXC9obS5qc1xcXCJdLFxcbiAgICAgICAgICAgIHZpZGVvRXhjbHVkZVJ1bGVzOiBbJz91cmw9J10sXFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdG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KSA9PiB7XFxuICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwicGFnZW51bVxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgJC50ZW1wX2xpc3RbaV0pO1xcbiAgICAgICAgICAgICBmaW5kSXRlbXNCeUNscyhcXFwicGxheXBhZ2VcXFwiKS5mb3JFYWNoKCh4LCBpaSkgPT4ge1xcbiAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IHgudGl0bGUucmVwbGFjZSgv4oCYfOKAmXzigJx84oCdfDxbXj5dKz4vZywgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgIGlmIChpaSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICB0aXRsZSA9ICfigJzigJzigJ3igJ0nICsgdGl0bGUuZm9udGNvbG9yKFxcXCJyZWRcXFwiKTtcXG4gICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh4LmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgIH0sIGkpLFxcbiAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIHRlbXAuZXh0cmEsIHtcXG4gICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIiArIGksXFxuICAgICAgICAgICB9KVxcbi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WxlcztcXG4gICAgICAgICAgICBpZiAobW8gPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0yKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0zKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0Rm9yYmlkZGVuSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpLmZpbHRlcigodiwgaSkgPT4gaW5kZXhzLmluY2x1ZGVzKGkpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5tYXAoKHYpID0+IHtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmRleGNbMV0pO1xcblxcbiAgICB9LCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hbGxfNFxcXCIsXFxuICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3NoYXJlX2dyZWVuXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi6YeN572uXFxcIixcXG4gICAgdXJsOiAkKFxcXCLkvaDnoa7lrprph43nva7vvJ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j5LukXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKG9wcywgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUudXNlciA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGViNjQgPSBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobmFtZSwgcnVsZSwgdHlwZSkgPT4gXFxcIua1t+mYlOinhueVjO+8jOOAjFxcXCIgKyBuYW1lICsgXFxcIuOAjURSUFnop6PmnpDvvIzlpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHJ1bGUgKyBcXFwiJFxcXCIgKyB0eXBlICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuWujOaVtOWPo+S7pFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHJ1bGViNjQsIFxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSAhcnVsZS5mb3JiaWRkZW47XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXCLnpoHnlKhcXFwiIDogXFxcIuWQr+eUqFxcXCIpICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGksIGxlbmd0aCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGk6IGksXFxuICAgICAgICAgICAgcGFnZVRpdGxlOiBpdC5uYW1lXFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cXG5jb3VudFRpdGxlLnRpdGxlID0gJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPuino+aekOWIl+ihqDxiPiAoJyArICgoZC5sZW5ndGggLSBjb3VudCkgKyBcXFwiL1xcXCIgKyBsZW5ndGgpLmZvbnRjb2xvcihcXFwiI2ZmNjYwMVxcXCIpICsgXFxcIilcXFwiO1xcbnNldFJlc3VsdChkKTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuino+aekOe8lui+kVwiLFwicGF0aFwiOlwicnVsZUVkaXRcIixcInJ1bGVcIjpcImpzOlxcbnZhciBkID0gW107XFxuXFxuYWRkTGlzdGVuZXIoXFxcIm9uQ2xvc2VcXF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1dCk7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogb2JqLm5hbWUsXFxuICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgIH1cXG59KTtcXG5cXG5cXG5kLnB1c2goe1xcbiAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgZGVzYzogXFxcIuino+aekHVybCjlv4XloaspXFxcIixcXG4gICAgZXh0cmE6IHtcXG4gICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfdXJsXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai51cmwsXFxuICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICB9XFxufSk7XFxuZC5wdXNoKHtcXG4gICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgIGRlc2M6IFxcXCJmbGFnKOW/heWhqylcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgdHlwZTogXFxcInRleHRhcmVhXFxcIixcXG4gICAgICAgIGhlaWdodDogMixcXG4gICAgICAgIGhpZ2hsaWdodDogdHJ1ZSxcXG4gICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfZmxhZ1xcXCIsIGlucHV0KTtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouZmxhZyxcXG4gICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2UsXFxuICAgIH1cXG59KTtcXG5kLnB1c2goe1xcbiAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgZGVzYzogXFxcImhlYWRlcnMo6YCJ5aGrKVxcXCIsXFxuICAgIGV4dHJhOiB7XFxuICAgICAgICB0eXBlOiBcXFwidG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AgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liKDpmaTmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIGluZGV4KVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgIH0sIGluZGV4LCB1cmxJbmRleCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIua1i+ivlVxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBsZXQgdGVzdEtleXdvcmQgPSBnZXRJdGVtKFxcXCJ0ZXN0VXJsXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgcmV0dXJuICQodGVzdEtleXdvcmQsIFxcXCLor7fovpPlhaXlvbHop4bnvZHnq5nlnLDlnYBcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidGVzdFVybFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gZ2V0TXlWYXIoXFxcInBzX3VybFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IGdldE15VmFyKFxcXCJwc19uYW1lXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBmbGFnID0gZ2V0TXlWYXIoXFxcInBzX2ZsYWdcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IGhlYWRlcnMgPSBnZXRNeVZhcihcXFwicHNfaGVhZGVyc1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBtZXRob2QgPSBnZXRNeVZhcihcXFwicHNfbWV0aG9kXFxcIiwgXFxcIkdFVFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBqc29uUGF0aCA9IGdldE15VmFyKFxcXCJwc19qc29uUGF0aFxcXCIsIFxcXCJcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcbiAgICAgICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICAgICAgaWYgKGhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgICAgICBqc1xcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXG4gICAgICAgIH0pO1xcbiAgICB9KSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5L+d5a2YXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgaXNJbXBvcnQpID0+IHtcXG4gICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcInBzX25hbWVcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCFuYW1lKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WQjeWtl+W+l+acieS4gOS4quWQp1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgdXJsID0gZ2V0TXlWYXIoXFxcInBzX3VybFxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIXVybCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/op6PmnpDlnLDlnYDkuI3og73kuLrnqbpcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGZsYWcgPSBnZXRNeVZhcihcXFwicHNfZmxhZ1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgIGlmICghZmxhZykge1xcbiAgICAgICAgICAgIHJldHVybiBcX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W8j+S4i+W/hemhu+Whq2pzb25QYXRoXFxcIjtcXG4gICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PT0gXFxcIkpTXFxcIiAmJiAhanMpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlPmqKHlvI/kuIvlv4Xpobvloatqc1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG9iajEgPSB7XFxuICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgIGpzXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcbiAgICAgICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBvYmoxKTtcXG4gICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBvYmoxKTtcXG4gICAgICAgIH1cXG4gICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICBiYWNrKHRydWUpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S/neWtmOaIkOWKn1xcXCI7XFxuICAgIH0sIGluZGV4LCBpc0ltcG9ydCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5zZXRSZXN1bHQoZCk7XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLop6PmnpDlr7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LTEpIHtcXG4gICAgICAgICAgICAgICAgcnVsZSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFwiICsgaW5kZXggKyBcXFwiJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl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tZTtcXG4gICAgICAgICAgICBsZXQgc3BhdGggPSBpdC5wYXRoO1xcbiAgICAgICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIG5hbWUgPSBuYW1lLnNsaWNlKDAsIG5hbWUubGFzdEluZGV4T2YoXFxcIi5cXFwiKSk7XFxuICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChgaHR0cHM6Ly9yYXcuZ2l0bWlycm9yLmNvbS8ke3JvcGV9L21hc3Rlci8ke3NwYXRofWApO1xcbiAgICAgICAgICAgIGlmICghKCghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSAmJiAhZmlsZUV4aXN0KHBhdGggKyBpdC5uYW1lKSkpIHtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOicuLi9saWJzL2RycHkyLmpzJyxcXG4gICAgICAgICAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdxdWlja1NlYXJjaCc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogXFxcIi4vXFxcIiArIGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2co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3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG4gICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aIkOWKn+abtOaWsFxcXCIgKyBjb3VudCArIFxcXCLkuKpcXFwiO1xcbn1cXG4kLmV4cG9ydHMucGFyc2VVcmwgPSBmdW5jdGlvbih1cmwsIHBhdGgpIHtcXG4gICAgcGF0aCA9IGJhc2U2NERlY29kZShwYXRoKTtcXG4gICAgcGF0aCA9IHBhdGguZW5kc1dpdGgoXFxcIi9cXFwiKSA/IHBhdGggOiBwYXRoICsgXFxcIi9cXFwiO1xcbiAgICB0cnkge1xcbiAgICAgICAgaWYgKHVybC5zdGFydHNXaXRoKFxcXCJodHRwczovL2dpdGh1Yi5jb20vaGpkaG54L1xcXCIpKSB7XFxuICAgICAgICAgIC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wiXFxcIikpKS5pc0RpcmVjdG9yeSgpKSB7XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGdlbmVyYXRlQ29uZmlnQnlMb2NhbChmaWxlKTtcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJsb2NhbERpclxcXCI7XFxuICAgICAgICB9IGVsc2UgaWYgKGNvbmZpZy5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBzOi8vZ2l0aHViLmNvbVxcXCIpKSB7XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGdlbmVyYXRlQ29uZmlnQnlHaXRodWIoY29uZmlnLnBhdGgpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImdpdGh1YkRpclxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGZldGNoKGNvbmZpZy5wYXRoKSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8ICFqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAvL2NvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gSlNPTi5wYXJzZShmZXRjaChzZWFyY2hBbGxvd1BhdGgpIHx8IFxcXCJbXVxcXCIpO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGRlbGV0ZUZpbGUoc2VhcmNoQWxsb3dQYXRoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlLFxcbiAgICAgICAgICAgIHNlYXJjaEFsbG93LFxcbiAgICAgICAgICAgIHNvdXJjZUxpc3RcXG4gICAgICAgIH07XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICB9XFxuICAgIHJldHVybiBudWxsO1xcbn1cXG5cXG5mdW5jdGlvbiBnZW5lcmF0ZUNvbmZpZ0J5TG9jYWwoZGlyRmlsZSkge1xcbiAgICBsZXQgbGlzdCA9IGRpckZpbGUubGlzdEZpbGVzKCk7XFxuICAgIGxldCBydWxlcyA9IFtdO1xcbiAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XFxuICAgICAgICBsZXQgbmFtZSA9IFN0cmluZyhpdC5nZXROYW1lKCkpO1xcbiAgICAgICAgbGV0IHB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uanNcXFwiKSB8fCBTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIuanNcXFwiKSlcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChvYmoudXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6XFxcIikpIHtcXG4gICAgICAgICAgbGV0IGNvZGUgPSBcXFwibm9cXFwiO1xcbiAgICAgICAgICBsZXQgcGF0aCA9IG9iai51cmwucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgbGV0IGRpciA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxuICAgICAgICAgIGlmIChkaXIuaXNEaXJlY3RvcnkoKSkge1xcbiAgICAgICAgICAgIGxldCBmbGlzdCA9IGRpci5saXN0RmlsZXMoKTtcXG4gICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxuICAgICAgICAgICAgICAvLyDmo4Dmn6Xmlofku7blkI3mmK/lkKbku6UuanPnu5PlsL5cXG4gICAgICAgICAgICAgIGlmIChmLmlzRmlsZSgpICYmIGYuZ2V0TmFtZSgpLnRvTG93ZXJDYXNlKCkuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcbiAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge31cXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcbiAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcbiAgICAgICAgICAgIHVybDogb2JqLnVybCxcXG4gICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgY29kZTogY29kZSxcXG4gICAgICAgICAgICBpbmRleDogb2JqLmlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgdmFyIGogPSBKU09OLnBhcnNlKGZldGNoKG9iai51cmwsIHtcXG4gICAgICAgICAgd2l0aEhlYWRlcnM6IHRydWUsXFxuICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxuICAgICAgICB9KSk7XFxuICAgICAgICBsZXQgZSA9IERhdGUubm93KCk7XFxuICAgICAgICBsZXQgYyA9IGUgLSBzO1xcbiAgICAgICAgaWYgKG9iai51cmwuaW5jbHVkZXMoXFxcImdpdGh1Yi5jb21cXFwiKSAmJiBqLnN0YXR1c0NvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgdmFyIGh0bWwgPSBqLmJvZHk7XFxuICAgICAgICAgICAgdmFyIGpzb24gPSBKU09OLnBhcnNlKHBkZmgoaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICAgICAgICAgIGNvdW50ID0gbGlzdC5maWx0ZXIoeCA9PiB4Lm5hbWUuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKS5sZW5ndGg7XFxuICAgICAgICAgIH0gY2F0Y2gge31cXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuXFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICB0aW1lOiBjLFxcbiAgICAgICAgICB1cmw6IGoudXJsLFxcbiAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXG4gICAgICAgICAgaW5kZXg6IG9iai5pLFxcbiAgICAgICAgfVxcbiAgICAgIH07XFxuICAgICAgbGV0IHRhc2tzID0gbGlzdC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgIGkgPSBpICsgMTtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIGZ1bmM6IHRhc2ssXFxuICAgICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgICAgdXJsOiB4LFxcbiAgICAgICAgICAgIGk6IGkgLSAxLFxcbiAgICAgICAgICB9LFxcbiAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxuICAgICAgICB9XFxuICAgICAgfSk7XFxuICAgICAgdmFyIGNvdW50ID0gc3VjY2VzcyA9IHRhc2tzLmxlbmd0aDtcXG4gICAgICBiZSh0YXNrcywge1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jdXJyZW50Y29uZmlnLmhhc093blByb3BlcnR5KFxcXCJwYXRoXFxcIikpIHtcXG4gICAgICBpZiAoaXRlbS5wYXRoID09IGN1cnJlbnRjb25maWcucGF0aCkge1xcbiAgICAgICAgY3VycmVudCA9IFxcXCLinqHvuI9cXFwiO1xcbiAgICAgIH1cXG4gICAgfVxcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD5cXFwiICsgY3VycmVudCArIFxcXCLlkI3np7A6XFxcIiArIGl0ZW0ubmFtZSArIFxcXCJcXFxcbui3r+W+hDpcXFwiICsgaXRlbS5wYXRoICsgXFxcIjwvc21hbGw+XFxcIixcXG4gICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoaXRlbSA9PiB7XFxuICAgICAgICBjbGVhckl0ZW0oXFxcIm5vX2xvYWRpbmdcXFwiKTtcXG4gICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICBsZXQge1xcbiAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICBuYW1lXFxuICAgICAgICB9ID0gaXRlbTtcXG4gICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgbmFtZSxcXG4gICAgICAgIH0pKSB7XFxuICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO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Y2sobWFuYWdlKSB7XFxuICAgICAgaGlrZXJQb3Auc2VsZWN0Q2VudGVyKHtcXG4gICAgICAgIG9wdGlvbnM6IFtcXFwi5pS55Y+Y5qC35byPXFxcIiwgXFxcIuetm+mAiea6kFxcXCIsIFxcXCLoh6rnhLbmjpLluo86XFxcIiArIChnZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpID09IFxcXCJcXFwiID8gXFxcIuWFs+mXrVxcXCIgOiBcXFwi5ZCv55SoXFxcIiksIFxcXCLlgJLluo9cXFwiLCBcXFwi5Yi35paw6YWN572uXFxcIl0sXFxuICAgICAgICBjb2x1bW5zOiAyLFxcbiAgICAgICAgdGl0bGU6IFxcXCLor7fpgInmi6lcXFwiLFxcbiAgICAgICAgY2xpY2socywgaSkge1xcbiAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcbiAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogMztcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAxKSB7XFxuICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZdcXFwiLFxcbiAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpLm1hcCh4ID0+IHgubmFtZSk7XFxuICAgICAgICAgICAgICAgIGxldCBmbGlzdCA9IGxpc3QuZmlsdGVyKHggPT4geC5pbmNsdWRlcyh0ZXh0KSk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBsZXQgbmF0dXJhbCA9IGdldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgaWYgKG5hdHVyYWwgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICBsaXN0LnNvcnQobmF0dXJhbFNvcnQpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIG5hbWVzLnJldmVyc2UoKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXG4gICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxuICAgICAgICAgICAgICByZXR1cm4gYXJyMS5maWx0ZXIoaXRlbSA9PiAhbWFwLmhhcyhpdGVtLmtleSkpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcbiAgICAgICAgICAgIC8vbG9nKENrZXkpXFxuICAgICAgICAgICAgbGV0IGNmZyA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpXFxuICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICBuYW1lXFxuICAgICAgICAgICAgfSA9IGNmZztcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50U291cmNlKENrZXkpO1xcbiAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuXFxuICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcblxcbiAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBsb2coXFxcIuaWsOWinjpcXFwiICsgYWxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgaWYgKGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIiDnp7vpmaRcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICB0b2FzdChcXFwi5bey5Yi35pawXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgIH0pO1xcbiAgICB9XFxuICB9KTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJkcnB5566h55CGXCIsXCJwYXRoXCI6XCJEcnB5TWFuYWdlXCIsXCJydWxlXCI6XCJqczpcXG5jb25zdCBKU0VuZ2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AgICAgICAgICBjb250ZW50OiBcXFwi6L6T5YWl5YWz6ZSu5a2XIOepuuaYvuekuuWFqOmDqFxcXCIsXFxuICAgICAgICAgICAgICB0aXRsZTogXFxcIuetm+mAiea6kFxcXCIsXFxuICAgICAgICAgICAgICBoaW50OiBcXFwi5rqQ5YWz6ZSu5a2XIOWkmuS4queUqHzpmpTlvIBcXFwiLFxcbiAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICBjYW5TZWFyY2hTb3VyY2UuZm9yRWFjaCgodiwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxuICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgIH0sXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuXFxuXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nKGEubmFtZSkubG9jYWxlQ29tcGFyZShTdHJpbmcoYi5uYW1lKSwgdW5kZWZpbmVkLCB7XFxuICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5yZXZlcnNlKCk7XFxuXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNCkge1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICghc2VhcmNoQWxsb3cuaW5jbHVkZXModikpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDUpIHtcXG4gICAgICAgICAgICBsZXQgdGVtbGlzdCA9IHNlYXJjaEFsbG93LnNsaWNlKCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybjtcXG4gICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW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2YXIgY2F0ZV90ZW1wID0gY2F0ZV9vYmpbY2F0ZV07XFxuICAgICAgLy92YXIgZmlsdGVyX2RlZj1zdG9yYWdlMC5nZXRJdGVtKFxcXCJmaWx0ZXJfZGVmXFxcIiwge30pO1xcbiAgICAgIGNsYXNzaWZ5LmZvckVhY2goKHgsIGluZGV4KSA9PiB7XFxuICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICB9KVxcbiAgICAgICAgeC52YWx1ZS5mb3JFYWNoKChpdCwgaSkgPT4ge1xcbiAgICAgICAgICBsZXQgdCA9IGl0Lm47XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IGkpIHtcXG4gICAgICAgICAgICB0ID0gXFxcIjxiPjxmb250IGNvbG9yPVxcXCIgKyBjb2xvciArIFxcXCI+XFxcIiArIHQgKyBcXFwiPC9mb250PjwvYj5cXFwiO1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IGl0LnY7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGNhdGVfdGVtcFtpbmRleF0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IFxcXCJ1bmRlZmluZWRcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChmb2xkID09IDEpIHtcXG4gICAgICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyB0LFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gby5pO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiaXNfZGVmXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwge30pO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIGlmIChjYXRlX3RlbXAuY29uc3RydWN0b3IgIT0gQXJyYXkpIHtcXG4gICAgICAgICAgICAgICAgICBjYXRlX3RlbXAgPSBbXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmluZGV4O1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgLy9sb2coYylcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVfdGVtcClcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV90ZW1wXFxcIiwgY2F0ZV90ZW1wKTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwgY2F0ZV9vYmopO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICBpbmR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