xiaomianao666

小程序:DrpyHiker

Jul 15th, 2024
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IkRycHlIaWtlciIsImF1dGhvciI6IkBMb3lEZ0lrJnpldGFscGhhIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6NDksImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoidmlkZW8iLCJjbGFzc191cmwiOiIiLCJhcmVhX25hbWUiOiIiLCJhcmVhX3VybCI6IiIsInNvcnRfbmFtZSI6IiIsInllYXJfbmFtZSI6IiIsInNvcnRfdXJsIjoiIiwieWVhcl91cmwiOiIiLCJmaW5kX3J1bGUiOiJqczokLnJlcXVpcmUoXCJNaWFuTG9hZFwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zPSoqJnBhZ2U9ZnlwYWdlIiwiZ3JvdXAiOiLlvIDlj5HkuK3lv4MiLCJzZWFyY2hGaW5kIjoianM6XG4oZnVuY3Rpb24gKCkge1xuICBsZXQge1xuICAgIHVpX2NvbmZpZyxcbiAgfSA9ICQucmVxdWlyZShcIlVJTWFuYWdlXCIpO1xuICB1aV9jb25maWc9dWlfY29uZmlnLnlpO1xuXG4gIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgbGV0IHRlbXNtb2RlID0gZ2V0TXlWYXIoXCJ0ZW1zbW9kZVwiLCBcIlwiKTtcbiAgaWYgKHRlbXNtb2RlKSB7XG4gICAgc21vZGUgPSBOdW1iZXIodGVtc21vZGUpO1xuICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgfVxuICBpZi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IpIHtcbiAgICAgICAgICAgIC8vbG9nKGVycm9yLm1lc3NhZ2UpO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICB9LCBzb3VyY2UsIGlkLCBNWV9SVUxFLnRpdGxlKTtcbiAgICAgICAgY2lkID0gaWQ7XG4gICAgICB9XG5cbiAgICAgIGQucHVzaCh7XG4gICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MgKyBcIsK3XCIgKyBzb3VyY2UubmFtZSxcbiAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgIHVybDogdXJsLFxuICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgaWQ6IGNpZCxcbiAgICAgICAgICB2b2RJZDogaWQsXG4gICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcbiAgICAgICAgICBza2V5OiBzb3VyY2Uua2V5LFxuICAgICAgICB9XG4gICAgICB9KTtcbiAgICB9XG4gICAgc2V0UmVzdWx0KGQpO1xuICB9IGVsc2Uge1xuICAgIHNldFJlc3VsdChbe1xuICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5pCc57SiXCIgKyBNWV9LRVlXT1JELFxuICAgICAgdXJsOiBcImhpa2VyOi8vc2VhcmNoP3M9XCIgKyBNWV9LRVlXT1JELFxuICAgICAgZXh0cmE6IHtcbiAgICAgICAgZGVsZWdhdGVPbmx5U2VhcmNoOiB0cnVlLFxuICAgICAgICBydWxlczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFwicnVudGltZUNvbmZpZ1wiLCBcInJ1bnRpbWVDb25maWdcIik7XG4gICAgICAgICAgICBsZXQgc21vZGUgPSBOdW1iZXIoZ2V0SXRlbShcInNtb2RlXCIsIFwiMFwiKSk7XG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsb3dTZWFyY2hTb3VyY2Uoc21vZGUgPT09IDIpO1xuXG4gICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG5cbiAgICAgICAgICAgIGxldCBsaXN0aSA9IGxpc3QuZmluZEluZGV4KHggPT4geC5rZXkgPT0gc291cmNlLmtleSk7XG5cbiAgICAgICAgICAgIGxldCBzZWFyY2hzb3J0ID0gTnVtYmVyKGdldEl0ZW0oXCJzZWFyY2hzb3J0XCIsIFwiMFwiKSk7XG4gICAgICAgICAgICBsZXQge1xuICAgICAgICAgICAgICBuYXR1cmFsU29ydCxcbiAgICAgICAgICAgICAgdXNpbmdTb3J0XG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFwibWV0aG9kc1wiKTtcblxuICAgICAgICAgICAgaWYgKHNlYXJjaHNvcnQgPiAwKSB7XG4gICAgICAgICAgICAgIGlmIChzZWFyY2hzb3J0ID09IDEpIHtcbiAgICAgICAgICAgICAgICBuYXR1cmFsU29ydChsaXN0LCBcIm5hbWVcIik7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2VhcmNoc29ydCA9PSAyKSB7XG4gICAgICAgICAgICAgICAgdXNpbmdTb3J0LnNldGtleShcIm5hbWVcIik7XG4gICAgICAgICAgICAgICAgdXNpbmdTb3J0LmdldChsaXN0KVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChzb3VyY2Uuc2VhcmNoYWJsZSAmJiBsaXN0aSAhPSAtMSkge1xuICAgICAgICAgICAgICBsaXN0LnNwbGljZShsaXN0LmluZGV4T2Yoc291cmNlKSwgMSk7XG4gICAgICAgICAgICAgIGxpc3QudW5zaGlmdChzb3VyY2UpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcbiAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgIGxldCB7XG4gICAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZyxcbiAgICAgICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXCJVSU1hbmFnZVwiKTtcbiAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZz11aV9jb25maWcueWk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIikuZ2V0KGl0ZW0ua2V5KTtcbiAgICAgICAgICAgICAgICAgIGxldCBob21lTGlzdCA9IEpTT04ucGFyc2UoZHJweS5zZWFyY2goTVlfS0VZV09SRCwgZmFsc2UsIE1ZX1BBR0UpKS5saXN0IHx8IFtdO1xuICAgICAgICAgICAgICAgICAgbGV0IHNraXBFciA9IGRycHkuZ2V0UnVsZShcIuS6jOe6p1wiKSA9PT0gXCIqXCIgJiYgZ2V0SXRlbShcInNraXBFclwiLCBcIlwiKTtcbiAgICAgICAgICAgICAgICAgIGxldCBkID0gW107XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBob21lTGlzdCkge1xuICAgICAgICAgICAgICAgICAgICBsZXQgY2lkO1xuICAgICAgICAgICAgICAgICAgICBsZXQgaWQgPSBTdHJpbmcoaXQudm9kX2lkKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkXCIrdWlfY29uZmlnLm1hcms7XG4gICAgICAgICAgICAgICAgICAgIGlmIChza2lwRXIpIHtcbiAgICAgICAgICAgICAgICAgICAgICB1cmwgPSAkKCkubGF6eVJ1bGUoKHNvdXJjZSwgaWQsIG15KSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdXJsO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gSlNPTi5wYXJzZShkcnB5LmRldGFpbChpZCkpLmxpc3RbMF0udm9kX3BsYXlfdXJsLnNwbGl0KFwiJFwiKVsxXTsgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhlLm1lc3NhZ2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBpZC5zcGxpdChcIkBAXCIpWzBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9ICQucmVxdWlyZShcInZpZGVvVXJsXCIpLnBhcnNlKHVybCwgaWQsIHNvdXJjZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhlcnJvci5tZXNzYWdlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgfSwgaXRlbSwgaWQsTVlfUlVMRS5fdGl0bGUpO1xuICAgICAgICAgICAgICAgICAgICAgIGNpZCA9IGlkO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXG4gICAgICAgICAgICAgICAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsXG4gICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBjaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICB2b2RJZDogaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgICBzbmFtZTogaXRlbS5uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2tleTogaXRlbS5rZXksXG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIHNldFJlc3VsdChkKTtcbiA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cXFwiXFxuICAgICAgICAgIH0pLFxcbiAgICAgICAgICBzdXJsOiB1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldLFxcbiAgICAgICAgICB1cmw6IGlzTm92ZWwgPyBcXFwiaGlrZXI6Ly9wYWdlL25vdmVsI2F1dG9QYWdlIyNyZWFkVGhlbWUjXFxcIiA6ICh1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkpLFxcbiAgICAgICAgICBjb2xfdHlwZTogY29sLFxcbiAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgLypleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgZXh0cmEsIHtcXG4gICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IGRlY29kZVVSSUNvbXBvbmVudChrWzFdKSxcXG4gICAgICAgICAgICBpZDoga1sxXSxcXG4gICAgICAgICAgICAvL2xpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgIH0pKi9cXG4gICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBmcm9tOiBmcm9tW2ldLFxcbiAgICAgICAgICAgIHNvdXJjZTogc291cmNlLFxcbiAgICAgICAgICAgIGlkOiB1aWQsXFxuICAgICAgICAgICAgYmxvY2tSdWxlczogWydiYi4qLnBuZycsICcuanBnJywgXFxcImhtXFxcXC5iYWlkdVxcXFwuY29tXFxcXC9obS5qc1xcXCJdLFxcbiAgICAgICAgICAgIHZpZGVvRXhjbHVkZVJ1bGVzOiBbJz91cmw9J10sXFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgfVxcbiAgICAgICAgfTtc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NlKGRycHkucGxheShpbnB1dFsxXSwgaW5wdXRbMF0pKTtcXG4gICAgICAgICAgaWYgKHJlc3VsdC51cmwuc3RhcnRzV2l0aChcXFwicGljczovL1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdC51cmw7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocmVzdWx0LnVybC5zdGFydHNXaXRoKFxcXCJub3ZlbDovL1xcXCIpKSB7XFxuICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSBKU09OLnBhcnNlKHJlc3VsdC51cmwucmVwbGFjZShcXFwibm92ZWw6Ly9cXFwiLCBcXFwiXFxcIikpLmNvbnRlbnQ7XFxuICAgICAgICAgICAgbGV0IGNtZDUgPSBtZDUoY29udGVudCk7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gMDtcXG4gICAgICAgICAgICBpZiAoKGluZGV4ID0gJC5oaWtlcltcXFwiX190ZXN0X19cXFwiXS5pbmRleE9mKGNtZDUpKSAhPT0gLTEpIHtcXG4gICAgICAgICAgICAgIGxvZyhcXFwi6YeN5aSN77yaXFxcIiArIGlucHV0ICsgXFxcIj0+XFxcIiArIGluZGV4KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgJC5oaWtlcltcXFwiX190ZXN0X19cXFwiXS5wdXNoKGNtZDUpO1xcbiAgICAgICAgICAgIHJldHVybiBjb250ZW50O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5ryr55S75oiW5q2j5paH6I635Y+W5aSx6LSlXFxcIik7XFxuICAgICAgICB9LCBHTS5nZXRTZWxmS2V5KCksIE1ZX1BBUkFNUy5za2V5LCBNWV9SVUxFLnRpdGxlKTtcXG5cXG4gICAgICAgIGxldCBjaGFwdGVyTGlzdCA9IHBsYXlvYmouZXhjbHVkZUtleXMoW1xcXCJzdXJsXFxcIiwgXFxcInN0aXRsZVxcXCJdLCBmYWxzZSkudHJhbnNmb3JtS2V5cyh7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gICAgICB9LCBpLCBpZCwgcGFnZW51bSksXFxuICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLmV4dHJhLCB7XFxuICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIiArIGksXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9KVxcbiAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICB9KVxcblxcbiAgICAgIGxldCBmYyA9IFxcXCJcXFwiO1xcbiAgICAgIGlmICghKHBsYXlwICYmIHBsYXlwLmxlbmd0aCA+IDEpKSB7XFxuICAgICAgICBmYyA9IFxcXCJncmV5XFxcIjtcXG4gICAgICB9XFxuXFxuICAgICAgbGV0IHBhZ2VvYmogPSBbe1xcbiAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSgn5LiK5LiA6aG1Jywge1xcbiAgICAgICAgICBjOiBmY1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkLCBwY291bnQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGVmLnBhZ2VudW07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcbiAgICAgICAgICAgIHBhZ2VudW0gPSBwY291bnQgLSAxO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHBhZ2VudW0tLTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgIGxldCBlcnIgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5lclJlZnJlc2g7XFxuICAgICAgICAgIHJldHVybiBlcnIobG9jYXRpb24pO1xcbiAgICAgICAgfSwgaWQsIHBjb3VudCwgU3RyaW5nKHBhZ2VudW0pKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZUB1cFxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogZm9udHN0eWxlKHBsYXlwW3BhZ2VudW1dLCB7XFxuICAgICAgICAgIGM6IGZjXFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBwYWdlbnVtKTtcXG4gICAgICAgICAgbGV0IGVmID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZ2V0RUluZm8oKTtcXG4gICAgICAgICAgbGV0IHBjb3VudCA9IGVmLm1heFtsb2NhdGlvbl07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgbGV0IHBsYXlwID0gZWYucGxheXA7XFxuICAgICAgICAgIGxldCBlciA9ICQucmVxdWlyZShcXFwiVUlNYW5hZ2VcXFwiKS51aV9jb25maWcuZXI7XFxuICAgICAgICAgIGxldCBwYWdlYXJyID0gcGxheXAubWFwKCh4LCBpKSA9PiBpID09IHBhZ2VudW0gPyAn4oCc4oCc4oCd4oCdJyArIHguZm9udGNvbG9yKGVyLue6v+i3r+minOiJsikgOiB4KTtcXG4gICAgICAgICAgcmV0dXJuICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbiwgZXIpID0+IHtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgIGlmIChlci7kuoznuqfliLfmlrApIHtcXG4gICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInBsYXlsaXN0X3JlYWR5XFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4geyB9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH0sIGxvY2F0aW9uLCBlcilcXG4gICAgICAgIH0sIGlkLCBwYWdlbnVtKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZUBwYWdlYXJyXFxcIixcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogZm9udHN0eWxlKCfkuIvkuIDpobUnLCB7XFxuICAgICAgICAgIGM6IGZjXFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGVmLnBhZ2VudW07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgaWYgKHBhZ2VudW0gPj0gcGNvdW50IC0gMSkge1xcbiAgICAgICAgICAgIHBhZ2VudW0gPSAwO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHBhZ2VudW0rKztcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgIGxldCBlcnIgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5lclJlZnJlc2g7XFxuICAgICAgICAgIHJldHVybiBlcnIobG9jYXRpb24pO1xcbiAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiLFxcbiAgICAgICAgICBpZDogXFxcInBsYXlwYWdlQG5leHRcXFwiXFxuICAgICAgICB9XFxuICAgICAgfV1cXG5cXG4gICAgICBpZ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sxXS50aXRsZSxcXG4gICAgICAgICAgfSlcXG4gICAgICAgICAgdXBkYXRlSXRlbShcXFwicGxheXBhZ2VAbmV4dFxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogcGFnZW9ialsyXS50aXRsZSxcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChlci7liIbpobXlr7zoiKopIHtcXG4gICAgICAgICAgaWYgKCFlci7kuoznuqfliLfmlrApIHtcXG4gICAgICAgICAgICBsZXQgcG4gPSBmaW5kSXRlbXNCeUNscyhcXFwicGFnZW5hdlxcXCIpXFxuICAgICAgICAgICAgaWYgKHBuLmxlbmd0aCA+IHBsYXlwLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgcG4gPSBwbi5zbGljZShwbGF5cC5sZW5ndGgpXFxuICAgICAgICAgICAgICBwbi5tYXAoeCA9PiB7XFxuICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oeC5leHRyYS5pZClcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChwbi5sZW5ndGggPCBwbGF5cC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgIGxldCBwaWQgPSBwbi5hdCgtMSk7XFxuICAgICAgICAgICAgICBsZXQgYWRkID0gdHBsYXkuc2xpY2UocG4ubGVuZ3RoKTtcXG4gICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihwaWQuZXh0cmEuaWQsIGFkZCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRwbGF5LmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInBhZ2VudW1cXFwiICsgaSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogeC50aXRsZSxcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgIH1cXG5cXG4gICAgICAvLyBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIFt7XFxuICAgICAgLy8gICB0aXRsZTogJ+S4iuS4gOmhtScsXFxuICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgLy8gICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAvLyAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgLy8gICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAvLyAgICAgfSBlbHNlIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtLS07XFxuICAgICAgLy8gICAgIH1cXG4gICAgICAvLyAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIC8vICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgLy8gICBleHRyYToge1xcbiAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAvLyAgIH1cXG4gICAgICAvLyB9LCB7XFxuICAgICAgLy8gICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgLy8gICB1cmw6ICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbikgPT4ge1xcbiAgICAgIC8vICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgLy8gICB9LCBsb2NhdGlvbiksXFxuICAgICAgLy8gICBleHRyYToge1xcbiAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAvLyAgIH1cXG4gICAgICAvLyB9LCB7XFxuICAgICAgLy8gICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgLy8gICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAvLyAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgLy8gICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAvLyAgICAgfSBlbHNlIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtKys7XFxuICAgICAgLy8gICAgIH1cXG4gICAgICAvLyAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIC8vICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgLy8gICBleHRyYToge1xcbiAgICAgIC8vICAg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vI8uaW5jbHVkZXMoXFxcImljb25cXFwiKSA/IGZpbmRJY29uKGZyb21baV0pIDogXFxcIlxcXCI7XFxuICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IChpID09IGNpID8gZm9udHN0eWxlKGZyb21baV0sIHtcXG4gICAgICAgICAgICAgIGM6IGVyLue6v+i3r+minOiJsixcXG4gICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICB9LCBlci7nur/ot6/moLflvI8pIDogZm9udHN0eWxlKGZyb21baV0sIHtcXG4gICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICB9LCBlci7nur/ot6/moLflvI8pKSxcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGksIGlkKSA9PiB7XFxuICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgcHV0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICBsZXQgZXJyID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZXJSZWZyZXNoO1xcbiAgICAgICAgICAgICAgZXJyKGkpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBpLCBpZCksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgIGNsczogXFxcImxvY2F0aW9uQFxcXCIsXFxuICAgICAgICAgICAgICBpZDogXFxcImxvY2F0aW9uQFxcXCIgKyBpXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBpbWc6IGljb25pbWcsXFxuICAgICAgICAgICAgY29sX3R5cGU6IGVyLue6v+i3r+agt+W8j1xcbiAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICB9IGVsc2Uge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgdGl0bGU6IGZyb21bY2ldLFxcbiAgICAgICAgICBkZXNjOiBmcm9tLmxlbmd0aCArIFxcXCLmnaHnur/ot69cXFwiLFxcbiAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgIGZvbnRzdHlsZSxcXG4gICAgICAgICAgICAgIGdldEVJbmZvLFxcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKTtcXG4gICAgICAgICAgICBsZXQgZWYgPSBnZXRFSW5mbygpO1xcblxcbiAgICAgICAgICAgIGxldCBmcm9tID0gZWYuZnJvbTtcXG4gICAgICAgICAgICBsZXQgbWF4ID0gZWYucGxheXM7XFxuXFxuICAgICAgICAgICAgbGV0IGNpID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgbGV0IHNob3dpID0gZ2V0TXlWYXIoXFxcInNob3dpXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCB0ZnJvbSA9IGZyb20ubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gY2kgPT0gaSA/IGZvbnRzdHlsZSh4ICsgXFxcIltcXFwiICsgbWF4W2ldICsgXFxcIl1cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGM6ICQuZXJfdWku57q/6Lev6aKc6ImyLFxcbiAgICAgICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgICAgICB9KSA6IGZvbnRzdHlsZSh4ICsgXFxcIltcXFwiICsgbWF4W2ldICsgXFxcIl1cXFwiLCB7XFxuICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBpZiAoc2hvd2kgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJzaG93aVxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICBsZXQgc2hvdyA9IDE7XFxuICAgICAgICAgICAgICBsZXQgbnVtID0gdGZyb20ubGVuZ3RoO1xcbiAgICAgICAgICAgICAgaWYgKG51bSA8IDgpIHtcXG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAobnVtID4gOCAmJiBudW0gPD0gMTIpIHtcXG4gICAgICAgICAgICAgICAgc2hvdyA9IDI7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBzaG93ID0gMztcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgcmV0dXJuICQodGZyb20sIHNob3cpLnNlbGVjdCgoY2ksIGYsIGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgIE1ZX1VSTD1cXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgICAgZXJSZWZyZXNoXFxuICAgICAgICAgICAgICAgIH09JC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgIGZpbmRJY29uXFxuICAgICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNfZXJcXFwiKTtcXG4gICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgIGxldCBpID0gTVlfSU5ERVg7XFxuICAgICAgICAgICAgICAgIGlmIChpID09IGNpKSB7XFxuICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGZbaV07XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgICBlclJlZnJlc2goaSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBpY29uaW1nID0gZmluZEljb24obmFtZSwgJC5lcl91aSk7XFxuXFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxvY2F0aW9uQFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICB0aXRsZTogbmFtZSxcXG4gICAgICAgICAgICAgICAgICBpbWc6IGljb25pbWcsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInNob3dpXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICB9LCBjaSwgZnJvbSwgaWQpXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInNob3dpXFxcIik7XFxuICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgICBpbWc6IGVyLue6v+i3r+agt+W8jy5pbmNsdWRlcyhcXFwic2VsZWN0XFxcIikgPyBmaW5kSWNvbihmcm9tW2NpXSkgOiBcXFwiXFxcIixcXG4gICAgICAgICAgY29sX3R5cGU6ICdhdmF0YXInLFxcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFw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UGFzcyhydWxlcy5sZW5ndGgsIHJ1bGViNjQsIFxcXCJhXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJzaGFyZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBydWxlcztcXG4gICAgICAgICAgICBpZiAobW8gPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0yKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0zKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0Rm9yYmlkZGVuSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpLmZpbHRlcigodiwgaSkgPT4gaW5kZXhzLmluY2x1ZGVzKGkpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5tYXAoKHYpID0+IHtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmRleGNbMV0pO1xcblxcbiAgICB9LCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hb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ICAgICAgICAgICBsZXQgZmxhZ2kgPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiZmxhZ2lcXFwiLCBbXFxcIuWFqOmDqFxcXCJdKTtcXG4gICAgICAgICAgICBpZiAoLyjlhajpg6h85bey56aB55SoKS8udGVzdChmKSkge1xcbiAgICAgICAgICAgICAgICBmbGFnaSA9IFtmXVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGZsYWdpID0gZmxhZ2kuZmlsdGVyKHggPT4gIS8o5YWo6YOofOW3suemgeeUqCkvLnRlc3QoeCkpO1xcbiAgICAgICAgICAgICAgICBpZiAoZmxhZ2kuaW5jbHVkZXMoZikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGZsYWdpID0gZmxhZ2kuZmlsdGVyKHggPT4geCAhPSBmKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChmbGFnaS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdpID0gW1xcXCLlhajpg6hcXFwiXVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgZmxhZ2kucHVzaChmKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJmbGFnaVxcXCIsIGZsYWdpKTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBmKVxcbiAgICB9KVxcbn0pXFxuZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xcbiAgICBsZXQgaXQgPSBhcnJbaV07XFxuXFxuICAgIGxldCBmbGFnID0gaXQuZmxhZy5zcGxpdChcXFwifFxcXCIpO1xcbiAgICBpZiAoZmxhZ2kub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Pku6RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCBydWxlYjY0LCBcXFwiYVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oc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GluZV9ibGFua1xcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIHVybEluZGV4KSA9PiB7XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5q2k6aG55peg5rOV5Yig6ZmkXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICh1cmxJbmRleCAhPT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mraPlnKjmm7TmlrDop6PmnpDvvIzliKDpmaTor7fku47op6PmnpDnrqHnkIbov5vlhaVcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmuKnppqjmj5DnpLpcXFwiLFxcbiAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLnoa7lrpropoHliKDpmaTmraTop6PmnpDlkJfvvJ/ms6jmhI/liKDpmaTlkI7ml6Dms5XmgaLlpI1cXFwiLFxcbiAgICAgICAgICAgIGNvbmZpcm06ICQudG9TdHJpbmcoKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgICAgICBiYWNrKHRydWUpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Yig6Zmk5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICB9LCBpbmRleClc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XRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgICAgICBsZXQganMgPSBnZXRNeVZhcihcXFwicHNfanNcXFwiLCBcXFwiXFxcIikgfHwgdm9pZCAwO1xcbiAgICAgICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzID0gSlNPTi5wYXJzZShoZWFkZXJzKTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoZWFkZXJz5qC85byP6ZSZ6K+vOlxcXCIgKyBlLnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wcmVwYXJlUGFyc2VzKFt7XFxuICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICAgICAganNcXG4gICAgICAgICAgICB9XSwgaW5wdXQsbnVsbCwgdHJ1ZSk7XFxuICAgICAgICB9KTtcXG4gICAgfSksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIGlzSW1wb3J0KSA9PiB7XFxuICAgICAgICBsZXQgbmFtZSA9IG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ICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBydW5UeXBlID0gZ2V0TXlWYXIoXFxcInBzX3J1blR5cGVcXFwiLCBcXFwiV0VCXFxcIik7XFxuICAgICAgICBsZXQgbWV0aG9kID0gZ2V0TXlWYXIoXFxcInBzX21ldGhvZFxcXCIsIFxcXCJHRVRcXFwiKTtcXG4gICAgICAgIGxldCBqc29uUGF0aCA9IGdldE15VmFyKFxcXCJwc19qc29uUGF0aFxcXCIsIFxcXCJcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcbiAgICAgICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcInBzX2pzXFxcIiwgXFxcIlxcXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgIGlmIChydW5UeXBlID09PSBcXFwiSlNPTlxcXCIgJiYgIWpzb25QYXRoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pTT07mqKHlvI/kuIvlv4Xpobvloatqc29uUGF0aFxcXCI7XFxuICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT09IFxcXCJKU1xcXCIgJiYgIWpzKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pT5qih5byP5LiL5b+F6aG75aGranNcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBvYmoxID0ge1xcbiAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICBqc1xcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgICAgIH1c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ICBydWxlcyA9IFtydWxlc107XFxuICAgICAgICB9XFxuICAgICAgICAvL3J1bGVzLnJldmVyc2UoKTtcXG4gICAgICAgIE1ZX1VSTCA9IG1vZHVsZS5pZDtcXG4gICAgICAgIGxldCBydWxlVGl0bGUgPSBnZXRQYXJhbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXG4gICAgICAgIGZvciAobGV0IHJ1bGUgb2YgcnVsZXMpIHtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA+IDEpIHtcXG4gICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLmlrDlop7vvJpcXFwiICsgbmV3SSArIFxcXCIg6KaG55uW5pu05paw77yaXFxcIiArIChydWxlcy5sZW5ndGggLSBuZXdJKSk7XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgdG9hc3QoXFxcIuWvvOWFpeWksei0pVxcXCIpO1xcbiAgICB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vbnRpbnVlO1xcbiAgICAgICAgICAgIG5hbWUgPSBuYW1lLnNsaWNlKDAsIG5hbWUubGFzdEluZGV4T2YoXFxcIi5cXFwiKSk7XFxuICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChgaHR0cHM6Ly9yYXcuZ2l0bWlycm9yLmNvbS8ke3JvcGV9L21hc3Rlci8ke3NwYXRofWApO1xcbiAgICAgICAgICAgIGlmICghKCghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSAmJiAhZmlsZUV4aXN0KHBhdGggKyBpdC5uYW1lKSkpIHtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOiAnLi4vbGlicy9kcnB5Mi5qcycsXFxuICAgICAgICAgICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAncXVpY2tTZWFyY2gnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IFxcXCIuL1xcXCIgKyBpdC5uYW1lLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBuYW1lcy5wdXNoKGl0Lm5hbWUpO1xcbiAgICB9XFxu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BsZXQgY291bnQgPSAwO1xcbiAgICBsZXQgaSA9IDA7XFxuICAgIGxldCBuYW1lcyA9IFtdO1xcbiAgICBmb3IgKGxldCBpdCBvZiBhcnIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKChTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIubWluLmpzXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLmpzXFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuYW1lID0gaXQuZXh0LmVuZHNXaXRoKFxcXCIuanNcXFwiKSA/IGRlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSkpIDogKGl0Lm5hbWUgKyBcXFwiLmpzXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcbiAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGl0LmV4dCkuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgbmFtZXMucHVzaChuYW1lKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgZGVsZXRlbG9zZShuYW1lcywgcGF0aCk7XFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcImluZGV4Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShqc29uKSk7XFxuICAgIHJldHVybiBcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFwiICsgY291bnQgKyBcXFwi5LiqXFxcIjtcXG59XFxuJC5leHBvcnRzLnBhcnNlVXJsID0gZnVuY3Rpb24gKHVybCwgcGF0aCkge1xcbiAgICBwYXRoID0gYmFzZTY0RGVjb2RlKHBhdGgpO1xcbiAgICBwYXRoID0gcGF0aC5lbmRzV2l0aChcXFwiL1xcXCIpID8gcGF0aCA6IHBhdGggKyBcXFwiL1xcXCI7XFxuICAgIHRyeSB7XFxuICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImh0dHBzOi8vZ2l0aHViLmNvbS9oamRobngvXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gZ2VuZXJhdGVDb25maWdCeUdpdGh1Yih1cmwsIHBhdGgpO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICByZXR1cm4gZ2VuZXJhdGVDb25maWdCeUluZGV4KHVybCwgcGF0aCk7XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJlcnJvcjpcXFwiICsgZS50b1N0cmluZygpO1xcbi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gIHRocm93IG5ldyBFcnJvcihcXFwi5LuO572R57uc6I635Y+W55qE6YWN572u5paH5Lu25Li656m677yM6K+35qOA5p+l572R57ucXFxcIik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGlmIChzb3VyY2VMaXN0WzBdLmhhc093blByb3BlcnR5KFxcXCJpZFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHNvdXJjZUxpc3QgPSBzb3VyY2VMaXN0Lm1hcChpdGVtID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmhhc093blByb3BlcnR5KFxcXCJpZFxcXCIpICYmICFpdGVtLmhhc093blByb3BlcnR5KFxcXCJrZXlcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1bXFxcImtleVxcXCJdID0gaXRlbVtcXFwiaWRcXFwiXTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJpbmRleFxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBmaWxlID0gdm9pZCAwO1xcbiAgICAgICAgbGV0IGN1cnJlbnRTb3VyY2UsIHNlYXJjaEFsbG93O1xcbiAgICAgICAgaWYgKGNvbmZpZy5jS2V5KSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3QuZmluZCh2ID0+IHYua2V5ID09PSBjb25maWcuY0tleSk7XFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50U291cmNlKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgICAgICAvL2N1cnJlbnRDb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgLy9jb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IEpTT04ucGFyc2UoZmV0Y2goc2VhcmNoQWxsb3dQYXRoKSB8fCBcXFwiW11cXFwiKTtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBkZWxldGVGaWxlKHNlYXJjaEFsbG93UGF0aCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxvYWRFcnJvciA9IHZvaWQgMDtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyxcXG4gICAgICAgICAgICBzb3VyY2VMaXN0XFxuICAgICAgICB9O1xcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIGxvYWRFcnJvciA9IGU7XFxuICAgIH1cXG5cXG4gICAgcmV0dXJuIG51bGw7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlMb2NhbChkaXJGaWxlKSB7XFxuICAgIGxldCBsaXN0ID0gZGlyRmlsZS5saXN0RmlsZXMoKTtcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuXFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGxldCBuYW1lID0gU3RyaW5nKGl0LmdldE5hbWUoKSk7XFxuICAgICAgICBsZXQgcGF0aCA9IGl0LmdldFBhdGgoKTtcXG4gICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikgfHwgaXQuaXNEaXJlY3RvcnkoKSkgY29udGludWU7XFxuICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ2V4dCc6IGAke3BhdGh9YCxcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgbWFwcGluZyA9IGdldExvYWNsTWFwcGluZyhTdHJpbmcoZGlyRmlsZS5nZXRQYXRoKCkpKTtcXG5cXG4gICAgICAgIGlmIChtYXBwaW5nLmxlbmd0aCkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIG1hcHBpbmcpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gcnVsZXMuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBpdC5rZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBydWxlc1tpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShpbmRleCwgMCwgT2JqZWN0LmFzc2lnbih7fSwgaXRlbSwge1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7aXQudG9rZXl9YCxcXG4gICAgICAgICA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xuXFxuICAgIGxldCBtYWluID0gZXZhbEpzKHJlcXVlc3QoanNQYXRoKS5yZXBsYWNlKC9hc3luY1xcXFxzKj9mdW5jdGlvblxcXFxzKj9tYWluL2csIFxcXCJmdW5jdGlvbiBtYWluXFxcIikgKyBcXFwiXFxcXG47bWFpbjtcXFwiLCB7XFxuICAgICAgICBwYXRoTGliOiB7XFxuICAgICAgICAgICAgam9pbjogam9pblVybCxcXG4gICAgICAgICAgICByZWFkRmlsZShwYXRoKSB7XFxuICAgICAgICAgICAgICAgIHBhdGggPSBwYXRoLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSA/IHBhdGggOiAoXFxcImZpbGU6Ly9cXFwiICsgcGF0aCk7XFxuXFxuICAgICAgICAgICAgICAgIHJldHVybiBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHJlYWREaXIocGF0aCkge1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGZpbGUgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKSk7XFxuXFxuICAgICAgICAgICAgICAgIGlmICghKGZpbGUuZXhpc3RzKCkgJiYgZmlsZS5pc0RpcmVjdG9yeSgpKSkgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBmaWxlLmxpc3RGaWxlcygpKSB7XFxuICAgICAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKFN0cmluZyhpdC5nZXROYW1lKCkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkaXJuYW1lKHBhKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gam9pblVybChqc1BhdGgsIHBhKTtcXG4gICAgICAgICAgICAgICAgbGV0IG5hbWVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBmaWxlID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG5cXG4gICAgICAgICAgICAgICAgaWYgKCEoZmlsZS5leGlzdHMoKSAmJiBmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGRpckZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdC5pc0RpcmVjdG9yeSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBwYXRocztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHN0YXQoKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgICBsb2c6IGxvZyxcXG4gICAgICAgIHBhdGg6IGpzUGF0aCxcXG4gICAgICAgIHBhdGhfZGlyOiBqb2luVXJsKGpzUGF0aCwgXFxcIi4vXFxcIilcXG4gICAgfSk7XFxuICAgIGxldCBqc29uVGV4dCA9IG1haW4oKTtcXG4gICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGpzb25UZXh0KTtcXG5cXG4gICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbikpIHtcXG4gICAgICAgIHJldHVybiBmaWx0ZXJPdGhlcihqc29uKTtcXG4gICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpICYmIGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICB3cml0ZUZpbGUoam9pblVybChqc1BhdGgsIFxcXCIuL2luZGV4Lmpzb25cXFwiKSwganNvbl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AgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7IH1cXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcblxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgIH1cXG4gICAgICB9O1xcbiAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxuICAgICAgYmUodGFza3MsIHtcXG4gICAgICAgIGZ1bmM6IGZ1bmN0aW9uIChvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICBsZXQgcmVnZXggPSAvKOWQjeensDouKj8pKFxcXFxzKyk/XFxcXG4vZztcXG4gICAgICAgIGxldCB0aXRsZSA9IFxcXCLlkI3np7A6XFxcIiArIHBbeC5pbmRleF0ubmFtZSArIFxcXCIgXFxcIjtc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ICAgIGlmIChlbmNvZGVNb2RlID09PSBcXFwiR3ppcFxcXCIpIHtcXG4gICAgICAgICAgICAgIGxldCBHWklQID0gJC5yZXF1aXJlKFxcXCJHWklQXFxcIik7XFxuICAgICAgICAgICAgICBydWxlID0gR1pJUC56aXAocnVsZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChlbmNvZGVNb2RlID09PSBcXFwiQmFzZTY0XFxcIikge1xcbiAgICAgICAgICAgICAgcnVsZSA9IGJhc2U2NEVuY29kZShydWxlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGVuY29kZU1vZGUgPT09IFxcXCJBRVNcXFwiKSB7XFxuICAgICAgICAgICAgICBjb25zdCBDcnlwdG9VdGlsID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2Fzc2V0cy9jcnlwdG8tamF2YS5qc1xcXCIpO1xcbiAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChcXFwiNjg2QTY0Njg2RTc4MEEwQTBBMEEwQTBBMEEwQTBBMEFcXFwiKTtcXG4gICAgICAgICAgICAgIGxldCBpdiA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChcXFwiNjQ3QTc5Nzk2NDczMEEwQTBBMEEwQTBBMEEwQTBBMEFcXFwiKTtcXG4gICAgICAgICAgICAgIGxldCB0ZXh0RGF0YSA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZVVURjgocnVsZSk7XFxuICAgICAgICAgICAgICBsZXQgZW5jcnlwdGVkMCA9IENyeXB0b1V0aWwuQUVTLmVuY3J5cHQodGV4dERhdGEsIGtleSwge1xcbiAgICAgICAgICAgICAgICBtb2RlOiBcXFwiQUVTL0NCQy9QS0NTN1BhZGRpbmdcXFwiLFxcbiAgICAgICAgICAgICAgICBpdjogaXZcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgcnVsZSA9IGVuY3J5cHRlZDAudG9CYXNlNjQoX2Jhc2U2NC5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oh6rnhLbmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIGxldCBuYXR1cmFsID0gZ2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAobmF0dXJhbCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5L2/55So5o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBsZXQgdXNpbmdzdCA9IGdldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgaWYgKHVzaW5nc3QgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIHVzaW5nc3QgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocyA9PSBcXFwi5Yi35paw6YWN572uXFxcIikge1xcbiAgICAgICAgICAgIGhpa2VyUG9wLnJ1bk9uTmV3VGhyZWFkKCgpID0+IHtcXG4gICAgICAgICAgICAgIGZ1bmN0aW9uIGFycmF5RGlmZmVyZW5jZShhcnIxLCBhcnIyKSB7XFxuICAgICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLmZpbHRlcihpdGVtID0+ICFtYXAuaGFzKGl0ZW0ua2V5KSk7XFxuICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgICBpZiAoIXJ1bnRpbWVDb25maWcuaW5pdERlZmF1bHQoKSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5Yi35paw5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5ydW5PblVJVGhyZWFkKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKFxcXCLpgInmi6nop4bpopHmupAg5b2T5YmN5YWxOlxcXCIgKyBtYW5hZ2UubGlzdC5sZW5ndGggKyBcXFwi5Liq6KeG6aKR5rqQXFxcIik7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICB9IGVsc2UgaWYgKHMuaW5jbHVkZXMoXFxcIumdkuWwkeW5tOaooeW8j1xcXCIpKSB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gc2VsZWN0KCkge1xcbiAgICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgICBcXFwidGl0bGVcXFwiOiBcXFwi6YCJ5oupXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIm9wdGlvbnNcXFwiOiBbXFxcIuS4tOaXtuWFs+mXrVxcXCIsIFxcXCLlhbPpl61cXFwiLCBcXFwi6K6+572u5a+G56CBXFxcIl0sXFxuICAgICAgICAgICAgICAgIGNvbDogMSxcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcblxcbiAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5Li05pe25YWz6ZetXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInRlbXBMZWFjaFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09IFxcXCLlhbPpl61cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImxlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K6+572u5a+G56CBXFxcXG7mjIfnurnkuI3og73nlKjml7bmnInmlYhcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImxlYWNoUGFzc1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kvb/nlKjpu5jorqTlr4bnoIFcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGxlYWNoUGFzcyA9IGdldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAocy5pbmNsdWRlcyhcXFwi5YWz6ZetXFxcIikpIHtcXG5cXG4gICAgICAgICAgICAgIGlmIChoaWtlclBvcC5jYW5CaW9tZXRyaWMoKSAhPT0gMCAmJiAhbGVhY2hQYXNzKSB7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr7nva7lr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGhpbnQ6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHkuI3og73kuLrnqbpcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hQYXNzXFxcIiwgdGV4dCk7XFxuICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidGVtcExlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmiZPlvIDov4fmu6RcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidGVtcExlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmiZPlvIDov4fmu6RcXFwiKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgaWYgKGhpa2VyUG9wLmNhbkJpb21ldHJpYygpICE9PSAwKSB7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgY29udGVudDogXFxcIui+k+WFpeWvhueggei/m+ihjOWFs+mXrVxcXCIsXFxuICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLovpPlhaXlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGhpbnQ6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQgPT09IGxlYWNoUGFzcyB8fCAoIWxlYWNoUGFzcyAmJiB0ZXh0ID09PSBTdHJpbmcocHMpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHplJnor69cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AuY2hlY2tCeUJpb21ldHJpYygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgaGlrZXJQb3AucnVuT25OZXdUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2VsZWN0KCk7XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwb3AuZGlzbWlzcygpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnvJbnoIHnsbvlnotcXFwiLFxcbiAgICAgICAgICAgICAgb3B0aW9uczogW1xcXCLkuI3nvJbnoIFcXFwiLCBcXFwiR3ppcFxcXCIsIFxcXCJCYXNlNjRcXFwiLCBcXFwiQUVTXFxcIl0sXFxuICAgICAgICAgICAgICBjb2w6IDEsXFxuICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgaW5wdXQ7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAg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SB7XFxuICAgIHJldHVybiBzeW5jKCgpID0+IHtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZXMoKS5maW5kKHYgPT4gdi5rZXkgPT09IGtleSk7XFxuICAgICAgICBsZXQgZHJweSA9IGNyZWF0ZU5ld0RycHkoc291cmNlKTtcXG5cXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcbi8vc291cmNlLmV4dOW/hemhu+S4uue7neWvuei3r+W+hFxcbmZ1bmN0aW9uIGdldEJ5U291cmNlKHNvdXJjZSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICBsZXQga2V5ID0gc291cmNlLmtleTtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBkcnB5ID0gY3JlYXRlTmV3RHJweShzb3VyY2UpO1xcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcnVuUHJveHkoZHJweSwgYXJncykge1xcbiAgICBpZiAodHlwZW9mIGRycHkucHJveHkgPT09IFxcXCJmdW5jdGlvblxcXCIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTEgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLmFjcXVpcmUoKTtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMiA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjHnrYnlvoXml7bpl7Q6XFxcIiArICh0aW1lMiAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcbiAgICAgICAgICAgIGxldCByZXMgPSBkcnB5LnByb3h5LmFwcGx5KGRycHksIGFyZ3MpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMuaJp+ihjOS7o+eQhuiAl+aXtjpcXFwiICsgKHRpbWUzIC0gdGltZTIpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjPmgLvogJfml7bogJfml7Y6XFxcIiArICh0aW1lMyAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcblxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxuICAgICAgICB9IGZpbmFsbHkge1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLnJlbGVhc2UoKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbn1cX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xcbiAgICAgICAgdGl0bGU6IFxcXCLor7fpgInmi6lcXFwiLFxcbiAgICAgICAgY2xpY2socywgaSkge1xcbiAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcbiAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogKHNwZW4gPT0gMiA/IDMgOiAyKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAxKSB7XFxuICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG5cXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS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cmw6IHJ1bGUuaG9tZVVybCxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmuIXpmaR1aeiuvue9rlxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgdWlfY2xlYXIsXFxuICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJVSU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgdWlfY2xlYXIoXFxcInlpXFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgICAgfSk7Ki9cXG4gICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIue9keermeiuv+mXruW8guW4uFxcXCIpO1xcbiAgICAgIC8vc2V0UmVzdWx0KGxheW91dCk7XFxuICAgIH1lbHNle1xcbiAgICAgIGxldCBob21lPUpTT04ucGFyc2UoZHJweS5ob21lKCkpO1xcbiAgICAgIGlmKGhvbWUuY2xhc3MubGVuZ3RoPT0wKXtcXG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi6K6/6Zeu5q2j5bi4LOWIhuexu+aVsOaNruiOt+WPluW8guW4uCDlj6/lsJ3or5XliLfmlrDmupBcXFwiKTtcXG4gICAgICB9XFxuICAgIH1cXG4gIH1cXG4gIFxcbiAgaWYgKE9iamVjdC5rZXlzKHJ1bGUpLmxlbmd0aCA9PT0gMCkge1xcbiAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIuinhOWImeWKoOi9veWksei0pVxcXCIpO1xcbiAgfVxcbiAgXFxuICBpZiAoKHJ1bGUu5LiA57qnID09IFxcXCJcXFwiIHx8I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WYgKGZvbGQgPT0gMSkge1xcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIHQsXFxuICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBvLmk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJpc19kZWZcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV9vYmogPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICA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G9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBjbGVhck15VmFyKFxcXCJsaW5rc1xcXCIpO1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSlcXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIuafpeeci+a6kOS7o+eggVxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgbGV0IGNvZGUgPSBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5ydW5NYWluKFxcXCJsZXQgbWFpbj1cXFwiICsgJC50b1N0cmluZygoZXh0KSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuICgpID0+IGdldE9yaWdpbmFsSnMocmVxdWVzdChleHQsIHtcXG4gICAgICAgICAgICAgICdtZXRob2QnOiAnR0VUJ1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgfSwgcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlUGF0aCgpKSk7XFxuXFxuICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL3ZpZXdTb3VyY2VDb2RlLmpzXFxcIjtcXG4gICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGNvZGUpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICB9KVxcbiAgICAgIH1dLmNvbmNhdChjb25maWcudHlwZSA9PT0gXFxcImxvY2FsRGlyXFxcIiA/IFt7XFxuICAgICAgICB0aXRsZTogXFxcIue8lui+keWPguaVsOaYoOWwhOihqFxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygocGF0aCkgPT4ge1xcbiAgICAgICAgICBwYXRoICs9IFxcXCIvLm1hcHBpbmcudHh0XFxcIjtcXG4gICAgICAgICAgaWYgKGZpbGVFeGlzdChwYXRoKSkge1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLkv53lrZjlkI7liLfmlrDphY3nva7miJbph43lkK/miY3kvJrnlJ/mlYhcXFwiKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgcmV0dXJuICQoXFxcIuS4jeWtmOWcqOaYoOWwhOaWh+S7tuaYr+WQpuWIm+W7uu+8n1xcXCIpLmNvbmZpcm0ocGF0aCA9PiB7XFxuICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgdG9hc3QoXFxcIuS/neWtmOWQjuWIt+aWsOmFjee9ruaIlumHjeWQr+aJjeS8mueUn+aViFxcXCIpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJlZGl0RmlsZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgIH0sIHBhdGgpO1xcbiAgICAgICA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B0aXRsZTogXFxcIui+k+WFpeWcsOWdgFxcXCIsXFxuICAgICAgICAgIGhpbnQ6IFxcXCLkuLrnqbrpu5jorqRcXFwiLFxcbiAgICAgICAgICBjb250ZW50OiBcXFwi6buY6K6kOlxcXCIgKyBkZWYsXFxuICAgICAgICAgIGRlZmF1bHRWYWx1ZTogZ2V0SXRlbShcXFwiZ2l0aHVicmF3XFxcIiwgZGVmKSxcXG4gICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgaWYgKHRleHQgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcImdpdGh1YnJhd1xcXCIsIGRlZik7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcImdpdGh1YnJhd1xcXCIsIHRleHQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgaWYgKCFydW50aW1lQ29uZmlnLmluaXREZWZhdWx0KCkpIHtcXG4gICAgICAgICAgICAgIHRvYXN0KFxcXCLliLfmlrDlpLHotKVcXFwiKTtcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLlt7Lkv53lrZhcXFwiKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICB9IGVsc2UgaWYgKGlucHV0LmluY2x1ZGVzKFxcXCLkuLvpophcXFwiKSkge1xcbiAgICAgICAgbGV0IGN0aGVtZSA9IGdldEl0ZW0oXFxcInRoZW1lXFxcIiwgXFxcIum7mOiupFxcXCIpO1xcbiAgICAgICAgbGV0IHMgPSAkLnRoZW1lcztcXG4gICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMocyk7XFxuICAgICAgICBpZi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lvI/mjIflrprjgIJcXG4gKiBAcmV0dXJucyB7T2JqZWN0fSAtIOi/lOWbnuS4gOS4quaWsOeahOWvueixoe+8jOS4jeWMheWQq+aMh+WumuimgeaOkumZpOeahOWxnuaAp+OAglxcbiAqL1xcbmZ1bmN0aW9uIGRlZXBPbWl0KHNvdXJjZSwgZXhjKSB7XFxuICBjb25zdCByZXN1bHQgPSB7fTtcXG4gIC8vIOmBjeWOhumhtuWxgumUrlxcbiAgZm9yIChsZXQga2V5IGluIHNvdXJjZSkge1xcbiAgICBpZiAoc291cmNlLmhhc093blByb3BlcnR5KGtleSkpIHtcXG4gICAgICAvLyDmo4Dmn6XpobblsYLplK7mmK/lkKblupTor6XooqvmjpLpmaRcXG4gICAgICBpZiAoIShleGMuaGFzT3duUHJvcGVydHkoa2V5KSAmJiBleGNba2V5XSA9PT0gdHJ1ZSkpIHtcXG4gICAgICAgIC8vIOWmguaenOmhtuWxgumUruWvueW6lOeahOWAvOaYr+Wvueixoe+8jOW5tuS4lOacieWtkOaOkumZpOinhOWIme+8jOWImemAkuW9kuiwg+eUqCBkZWVwT21pdFxcbiAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2Vba2V5XSA9PT0gJ29iamVjdCcgJiYgc291cmNlW2tleV0gIT09IG51bGwgJiYgZXhjW2tleV0pIHtcXG4gICAgICAgICAgcmVzdWx0W2tleV0gPSBkZWVwT21pdChzb3VyY2Vba2V5XSwgZXhjW2tleV0pO1xcbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2Ygc291cmNlW2tleV0gIT09ICdvYmplY3QnIHx8IHNvdXJjZVtrZXldID09PSBudWxsIHx8ICFleGNba2V5XSkge1xcbiAgICAgICAgICAvLyDlpoLmnpzpobblsYLplK7lr7nlupTnmoTlgLzkuI3mmK/lr7nosaHvvIzmiJbogIXmsqHmnInlrZDmjpLpmaTop4TliJnvvIznm7TmjqXlpI3liLblgLxcXG4gICAgICAgICAgcmVzdWx0W2tleV0gPSBzb3VyY2Vba2V5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AgICAgcGljOiBjdXJyZW50LnBpYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGRlc2M6IGN1cnJlbnQuZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBjdXJyZW50LnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgaXRlbS5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGN1cnJlbnQuZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogY3VycmVudC5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKGN1cnJlbnQuZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgcGljOiBpdGVtLnBpYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGRlc2M6IGl0ZW0uZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBpdGVtLnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgY3VycmVudC5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGl0ZW0uZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogaXRlbS5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBsZXQgbmFyciA9ICQuc3dhcEFycmF5RWxlbWVudHMoaW5kZXhzLCBjdXJyZW50LmV4dHJhLmluZGV4LCBpdGVtLmV4dHJhLmluZGV4KTtcXG5cXG4gICAgICAgICAgICAkLnVpQ29uZmlnLnNldChuYXJyLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIik7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGggPSAn4oCc4oCc4oCd4oCdJztcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBpdGVtLnRpdGxlO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLpgInmi6nnp7vliqjnmoTnm67moIdcXFwiKTtcXG4gICAgICAgICAgICBpZiAoL3RleHRfaWNvbnxhdmF0YXJ8aWNvbl9zbWFsbF8zLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICgvaWNvbl8xX3NlYXJjaC8udGVzdChpdGVtLnR5cGUpKSB7XFxuICAgICAgICAgICAgICBoID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICB0aXRsZSA9IFxcXCLinqHvuI9cXFwiICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGggKyB0aXRsZSxcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIiwgaXRlbSk7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGkpXFxuICAgICAgICBpdGVtW1xcXCJleHRyYVxcXCJdID0ge1xcbiAgICAgICAgICBrZXk6IGl0ZW0ua2V5LFxcbiAgICAgICAgICBjbHM6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIixcXG4gICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgIGluZGV4OiBpdGVtLmluZGV4LFxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLorr7nva5cXFwiKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW5kZXhcXFwiXSA9IC0xO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghL2ljb25fMV9zZWFyY2h8YXZhdGFyLy50ZXN0KGl0ZW0uY29sX3R5cGUpKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmm7TmjaLlm77moIdcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gJChpdGVtLmltZykuaW5wdXQoKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IGl0ZW0ua2V5O1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgIGxldCBrID0ga2V5O1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgIGlmIChrZXkgPT0gXFxcIuaQnOe0ouaooeW8j1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGsgPSBcXFwi5pCc57SiXFxcIjtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcInlpLmljb25zLlxcXCIgKyBrKTtcXG4gICAgICAgICAgICAgICAgICAvL2l0ZW1zW2ldW1xcXCJpbWdcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA9PSBrZXkpWzBdLmV4dHJhLmlkO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHBpYzogaW5wdXQgfSlcXG4gICAgICAgICAgICAgIH0sIGl0ZW0pXFxuICAgICAgICAgICAgfSwgaXRlbSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLmjaLmupBcXFwiICYmIGl0ZW0ua2V5ICE9IFxcXCLmkJzntKLmqKHlvI9cXFwiKSB7XFxuICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi5L+u5pS55ZCN56ewXFxcIixcXG4gICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcInRpdGxlXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHRpdGxlOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpdGVtLmV4dHJhLkxvbmdDbGljayA9IGxvbmdjbGlja3M7XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIHVpb2JqID0gdWlvYmoubWFwKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBpdGVtLmV4dHJhID0ge1xcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCJcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgIH0pXFxuICAgIH1cXG4gICAgZCA9IGQuY29uY2F0KHVpb2JqKTtcXG5cXG4gICAgaWYgKGluZGV4cy5zb21lKHggPT4geC5pbmRleCA9PSAtMSkgJiYgdWltb2RlKSB7XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5bey56e76ZmkXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICAgIH0pXFxuICAgICAgaW5kZXhzLmZpbHRlcih4ID0+IHguaW5kZXggPT0gLTEpLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBtYXAgPSBuZXcgTWFwKHN1aW9iai5tYXAob2JqID0+IFtvYmoua2V5LCBvYmpdKSk7XFxuICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuICAgICAgICBvYmoudXJsID0gJChcXFwiXFxcIikubGF6eVJ1bGUoKGtleSwgaW5kZXgpID0+IHtcXG4gICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0ga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VxcXCJcXG4gICAgICB9KSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgTG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWkjeWItlxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSAkLnVpQ29uZmlnLmdldCgpO1xcbiAgICAgICAgICAgIGNvcHkoSlNPTi5zdHJpbmdpZnkodWMueWkpKTtcXG4gICAgICAgICAgfSksXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgIHRpdGxlOiBcXFwi5a+85YWlXFxcIixcXG4gICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHZhciB1YyA9ICQudWlDb25maWcuZ2V0KCk7XFxuICAgICAgICAgICAgcmV0dXJuICQoXFxcInt7Y2xpcGJvYXJkfX1cXFwiKS5pbnB1dCgodWMpID0+IHtcXG4gICAgICAgICAgICAgIHZhciB5aSA9IHt9O1xcbiAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgeWkgPSBKU09OLnBhcnNlKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgaWYgKHlpLmhhc093blByb3BlcnR5KFxcXCJ1aVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgdWMueWkgPSB5aTtcXG4gICAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1Yyk7XFxuICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5qC85byP6ZSZ6K+vXFxcIilcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCB1YylcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1dXFxuICAgICAgfVxcb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50aXRsZSArIFxcXCJfdWlcXFwiKSB8fCBbXSkuZmlsdGVyKHggPT4gIS8oaWNvbl8xX3NlYXJjaHxhdmF0YXJ8aW5wdXQpLy50ZXN0KHgudHlwZSkpO1xcbiAgICAgICAgICBvYmpzLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbSh4LmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICBjb2xfdHlwZTogaW5wdXQsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0pO1xcbiAgICAgICAgICAkLnVpQ29uZmlnLnNldChpbnB1dCwgXFxcInlpLmNvbFxcXCIpXFxuICAgICAgICAgIHVwZGF0ZUl0ZW0oTVlfUlVMRS50aXRsZSArIFxcXCJfeWljb2xcXFwiLCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLlpLTpg6jnu4Tku7bmoLflvI86XFxcIiArIHVpX2NvbmZpZy55aS5jb2xcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH0sIHVpX2NvbmZpZylcXG4gICAgICB9LCB1aV9jb25maWcpLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfeWljb2xcXFwiXFxuICAgICAgfVxcbiAgICB9KVxcblxcbiAgICBsZXQgZG9iaiA9IHt9O1xcbiAgICAkLnVpQ29uZmlnLmdldCgpLnlpLnVpLmZpbHRlcih4ID0+IHguaW5kZXggIT0gLTEpLm1hcChpdCA9PiB7XFxuICAgICAgZG9ialtpdC5rZXldID0gdHJ1ZVxcbiAgICB9KVxcblxcbiAgICBPYmplY3QuZW50cmllcyhkZWVwT21pdCh1aV90aGVtZS55aS5pY29ucywgZG9iaikpLmZvckVhY2goKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZToga2V5LFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpY29uXzVcXFwiLFxcbiAgICAgICAgaW1nOiB2YWx1ZSxcXG4gICAgICAgIHVybDogJCh2YWx1ZSkuaW5wdXQoKGspID0+IHtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcInlpLmljb25zLlxcXCIgKyBrKTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGtleSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBkZWZhdWx0VmFsdWU6IHZhbHVlXFxuICAgICAgICB9XFxuICAgICAgfSlcXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuWIhuexu+minOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGxldCB7IGlzVmFsaWRDb2xvciB9ID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICBpZiAoaXNWYWxpZENvbG9yKGlucHV0KSkge1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwieWku5YiG57G76aKc6ImyXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWl5q2j56Gu55qE6aKc6Imy5YC8XFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy55aS7liIbnsbvpopzoibJcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmjaLmupDpopzoibJcXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICBsZXQgeyBpc1ZhbGlkQ29sb3IgfSA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpO1xcbiAgICAgICAgaWYgKGlzVmFsaWRDb2xvcihpbnB1dCkpIHtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcInlpLuaNoua6kOminOiJslxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgdG9hc3QoXFxcIuivt+i+k+WFpeato+ehrueahOminOiJsuWAvFxcXCIpO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICB9KSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgZGVmYXVsdFZhbHVlOiB1aV9jb25maWcueWku5o2i5rqQ6aKc6ImyXFxuICAgICAgfVxcbiAgICB9KVxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5YiG57G76aKc6ImyXFxcIixcXG4gICAgICBpbWc6IHVpX2NvbmZpZy55aS7liIbnsbvpopzoibIgPT0gXFxcInJhbmRvbVxcXCIgPyBnZXRSYW5nZUNvbG9ycygpIDogdWlfY29uZmlnLnlpLuWIhuexu+minOiJsixcXG4gICAgICB1cmw6IFxcXCJ0b2FzdDovL+WIhuexu+minOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpY29uXzNfZmlsbFxcXCIsXFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmjaLmupDpopzoibJcXFwiLFxcbiAgICAgIGltZzogdWlfY29uZmlnLnlpLuaNoua6kOminOiJsiA9PS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scywgMikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgaW5wdXQgPSBpbnB1dC5yZXBsYWNlKFxcXCLinqHvuI9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICQudWlDb25maWcuc2V0KGlucHV0LCBcXFwiZXIu57q/6Lev5qC35byPXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgIH0pXFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLue6v+i3r+agt+W8jyxcXG4gICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIntsaW5lc30657q/6LevXFxcXHRcXFxcdHtsaW5lfTrlvZPliY3luo/lj7dcXFxcdFxcXFx0e2Zvcm19OuW9k+WJjee6v+i3r+WQjeensFxcXFx0XFxcXHR7cGxheXN9OuaAu+aVsHtzcGFnZX065b2T5YmN57+76aG1XFxcXHRcXFxcdHttYXh9OuacgOWkp+mhteaVsFxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJyaWNoX3RleHRcXFwiLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICB0ZXh0U2l6ZTogXFxcIjE1XFxcIixcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLnur/ot6/mmL7npLpcXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwiZXIu57q/6Lev5pi+56S6XFxcIik7XFxuICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXF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AgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGtleSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBkZWZhdWx0VmFsdWU6IHZhbHVlXFxuICAgICAgICB9XFxuICAgICAgfSlcXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIue6v+i3r+minOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGxldCB7IGlzVmFsaWRDb2xvciB9ID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICBpZiAoaXNWYWxpZENvbG9yKGlucHV0KSkge1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwiZXIu57q/6Lev6aKc6ImyXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIHRvYXN0KFxcXCLor7fovpPlhaXmraPnoa7nmoTpopzoibLlgLxcXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLue6v+i3r+minOiJslxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIua1headpea6kOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgZGVzYzogXFxcIuWtl+S9k+minOiJsjvog4zmma/popzoibJcXFwiLFxcbiAgICAgIHVybDogJC50b1N0cmluZygoK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VyLua3seadpea6kOiJslxcbiAgICAgIH1cXG4gICAgfSlcXG5cXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIue6v+i3r+minOiJslxcXCIsXFxuICAgICAgaW1nOiB1aV9jb25maWcuZXIu57q/6Lev6aKc6ImyLFxcbiAgICAgIHVybDogXFxcInRvYXN0Oi8v57q/6Lev6aKc6ImyXFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcImljb25fM19maWxsXFxcIixcXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIueugOS7i+agt+W8jzogXFxcIiArIHVpX2NvbmZpZy5lci7nroDku4vmoLflvI8sXFxuICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbiAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBsZXQgY29sID0gJC51aVRoZW1lLmdldCgpLmVyLueugOS7i+agt+W8jztcXG4gICAgICAgIGxldCBjb2xzID0gW1xcXCIwXFxcIiwgXFxcIjFcXFwiXTtcXG4gICAgICAgIGNvbHMgPSBjb2xzLm1hcCh4ID0+IHggPT0gY29sID8gXFxcIuKeoe+4j1xcXCIgKyB4IDogeCk7XFxuICAgICAgICByZXR1cm4gJChjb2xzLCAyKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICBpbnB1dCA9IGlucHV0LnJlcGxhY2UoXFxcIuKeoe+4j1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcImVyLueugOS7i+agt+W8j1xcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICB9KVxcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICB9XFxuICAgIH0pXFxuXFxuICA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fMlxcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGNsZWFyTXlWYXIoXFxcInBsYXlsaXN0X3JlYWR5XFxcIik7XFxuICAgICAgICBjbGVhck15VmFyKFxcXCJub3BhZ2VcXFwiKTtcXG4gICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIExvbmdDbGljazogW3tcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlpI3liLZcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHVjID0gJC51aUNvbmZpZy5nZXQoKTtcXG4gICAgICAgICAgICBjb3B5KEpTT04uc3RyaW5naWZ5KHVjLmVyKSk7XFxuICAgICAgICAgIH0pLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWvvOWFpVxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSAkLnVpQ29uZmlnLmdldCgpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIikuaW5wdXQoKHVjKSA9PiB7XFxuICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB1Yy5lciA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1Yyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgdWMpXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9XVxcbiAgICAgIH1cXG4gICAgfSlcXG4gIH1cXG4gIHNldFJlc3VsdChkKTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJMb2NhbFByb3h5XCIsXCJwYXRoXCI6XCJMb2NhbFByb3h5XCIsXCJydWxlXCI6XCJmdW5jdGlvbiBwcm94eSgpIHtcXG4gICAgZnVuY3Rpb24gcGFyc2VWaWRlbyhNWV9QQVJBTVMsIHRpdGxlKSB7XFxuICAgICAgICBmdW5jdGlvbiB0b1BhdGgodmFsdWUpIHtcXG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnc3RyaW5nJykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gW107XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwYXRoID0gW107XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZhbHVlLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxuICAgICAgICAgICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBwYXRoO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgICAgICAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBwYXRoW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W2tleV07XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBjdXJyZW50O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IE1ZX1BBUkFNUy5ydW5UeXBlWzBdO1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pKTtcXG4gICAgICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFwiSlNPTlxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBwYXJhbS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IE9iamVjdC5hc3NpZ24oe30sIHBhcmFtLmhlYWRlcnMgfHwge30sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiBnZXRKc29uKGpzb24sIHRvUGF0aChwYXJhbS5qc29uUGF0aCkpLFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09IFxcXCJKU1xcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcnNlO1xcbiAgICAgICAgICAgICAgICBpZiAoTVlfUEFSQU1TLmluZGV4KSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyB0aXRsZSkuZ2V0SnNvbigpW01ZX1BBUkFNUy5pbmRleFswXV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKGRlY29kZVVSSUNvbXBvbmVudChNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IHJlcyA9IG5ldyBGdW5jdGlvbihcXFwidXJsXFxcIiwgXFxcInNlbGZcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzID09PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiByZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICA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IsXFxuICAgIHJlY29yZHM6IFtcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrlop7liqDmm7TmlrDml6Xlv5fjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8mumAiea6kOmVv+aMieiPnOWNle+8jOWinuWKoOi3s+i9rOe9kemhte+8jOafpeeci+a6kOeggeOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN57yW6L6R6Kej5p6Q55WM6Z2i5rWL6K+VanPop6PmnpDkuIDnm7TlpLHotKXjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjWdpdGh1YuiuoumYhe+8jOS8muWIoOmZpOWFqOmDqOinhOWImeaWh+S7tuOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN6Kej5p6Q6LCD55So5aSx6LSl44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3mm7TmjaLphY3nva7ml7bmsqHmnInlj4rml7bmuIXnqbpkcnB557yT5a2Y44CCXFxcIixcXG4gICAgICAgIFxcXCJvcHRpbWl6Ze+8muabtOaUueiuoumYheabtOaWsOetlueVpe+8jOS8muWIoOmZpOacrOWcsOWkseaViOa6kOOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlrBkcnB5Mi5qc+OAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrkvJjljJbop6PmnpBmbGFn5Yy56YWN44CCXFxcIixcXG5cXG4gICAgXVxcbn0sIHtcXG4gICAgdGl0bGU6IFxcXCIyMDI0LzA2LzA5IE1heFZlcnNpb24gMjBcXFwiLFxcbiAgICByZWNvcmRzOiBbXFxuICAgICAgICBcXFwi4oCY4oCYbmV34oCZ4oCZ77ya5pSv5oyBcHJveHlfcnVsZeS7o+eQhuOAglxcXCIsXFxuIC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uexu+WeiyA9IGRhdGEudHlwZSB8fCBcXFwi5b2x6KeGXFxcIjtcXG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KGRhdGEubGlzdCkgJiYgZGF0YS5saXN0Lmxlbmd0aCA9PT0gMSAmJiBkYXRhLmxpc3RbMF0udm9kX25hbWUgPT09IFxcXCLmtYvor5VcXFwiKSB7XFxuICAgICAgICAgICAgZGVsZXRlIHRoaXMucnVsZS7mjqjojZA7XFxuICAgICAgICAgICAgZGF0YS5saXN0ID0gW107XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIGdldEhvbWVEYXRhKCkge1xcbiAgICAgICAgaWYgKHRoaXMuY2FjaGVDbGFzcykgcmV0dXJuIHRoaXMuY2FjaGVDbGFzcztcXG4gICAgICAgIGxldCBob21lID0gSlNPTi5wYXJzZShmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICAgICAgZmlsdGVyOiBcXFwidHJ1ZVxcXCJcXG4gICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgcmVkaXJlY3Q6IHRoaXMucmVkaXJlY3RcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIHRoaXMuY2FjaGVDbGFzcyA9IGhvbWU7XFxuXFxuICAgICAgICByZXR1cm4gaG9tZTtcXG4gICAgfSxcXG4gICAgaG9tZVZvZCgpIHtcXG4gICAgICAgIC8qaWYodGhpcy52b2RDb3VudCl7XFxuICAgICAgICAgICAgdGhpcy5pbml0KCk7XFxuICAgICAgICB9Ki9cXG4gICAgICAgIGxldCBkYXRhID0gdGhpcy5nZXRIb21lRGF0YSgpO1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICBsaXN0OiBkYXRhLmxpc3QgfHwgW11cXG4gICAgICAgIH0pO1xcbiAgICAgICAgdGhpcy52b2RDb3VudCsrO1xcbiAgICB9LFxcbiAgICBob21lKCkge1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHRoaXMuZ2V0SG9tZURhdGEoKSk7XFxuICAgIH0sXFxuICAgIGNhdGVnb3J5KHRpZCwgcGcsIGZpbHRlciwgZXh0ZW5kKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcInZpZGVvbGlzdFxcXCIsXFxuICAgICAgICAgICAgdDogdGlkLFxcbiAgICAgICAgICAgIHBnOiBcXFwiXFxcIiArIHBnLFxcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICAgICAgZXh0OiBleHRlbmQgPyBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkoZXh0ZW5kKSkgOiBcXFwiXFxcIlxcbiAgICAgICAgfSksIHtcXG4gICAgICAgICAgICByZWRpcmVjdDogdGhpcy5yZWRpcmVjdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICB9KSwge1xcbiAgICAgICAgICAgIHJlZGlyZWN0OiB0aGlzLnJlZGlyZWN0XFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgcGxheShmbGFnLCBpZCkge1xcbiAgICAgICAgcmV0dXJuIGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgLy9hYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgZmxhZzogZmxhZyxcXG4gICAgICAgICAgICBwbGF5OiBpZFxcbiAgICAgICAgfSksIHtcXG4gICAgICAgICAgICByZWRpcmVj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TogaXRlbS5uYW1lLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF90aW1lOiBpdGVtLmxhc3QudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdHlwZV9pZDogaXRlbS50aWQudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGl0ZW0ubm90ZS50b1N0cmluZygpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmNsYXNzLnR5KSB7XFxuICAgICAgICAgICAgaG9tZS5jbGFzcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdHlwZV9pZDogaXRlbS5AaWQsXFxuICAgICAgICAgICAgICAgIHR5cGVfbmFtZTogaXRlbS50b1N0cmluZygpLFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaG9tZS5jbGFzcykgJiYgQXJyYXkuaXNBcnJheSh0aGlzLmNhdGVnb3J5ZmlsdGVyKSkge1xcbiAgICAgICAgICAgIGhvbWUuY2xhc3MgPSBob21lLmNsYXNzLmZpbHRlcih2ID0+IHRoaXMuY2F0ZWdvcnlmaWx0ZXIuaW5jbHVkZXModi50eXBlX25hbWUpKVxcbiAgICAgICAgfVxcblxcbiAgICAgICAgdGhpcy5jYWNoZUNsYXNzID0gaG9tZTtcXG5cXG4gICAgICAgIHJldHVybiBob21lO1xcbiAgICB9LFxcbiAgICBob21lVm9kKCkge1xcbiAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmdldEhvbWVEYXRhKCk7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3Q6IGRhdGEubGlzdCB8fCBbXVxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGhvbWUoKSB7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkodGhpcy5nZXRIb21lRGF0YSgpKTtcXG4gICAgfSxcXG4gICAgY2F0ZWdvcnkodGlkLCBwZywgZmlsdGVyLCBleHRlbmQpIHtcXG4gICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwidmlkZW9saXN0XFxcIixcXG4gICAgICAgICAgICB0OiB0aWQsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBsZXQgbGlzdCA9IFtdO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgbGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKClcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgbGlzdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgfSkpLnJlcGxhY2UoL1xcXFw8Lio/eG1sLio/XFxcXD4vLCBcXFwiXFxcIik7XFxuICAgICAgICBsZXQgaG9tZVhtbCA9IG5ldyBYTUwoeG1sKTtcXG4gICAgICAgIGxldCBsaXN0ID0gW107XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmxpc3QudmlkZW8pIHtcXG4gICAgICAgICAgICBsZXQgcmVzaXRlbSA9IHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9jb250ZW50OiBpdGVtLmRlcy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfYWN0b3I6IGl0ZW0uYWN0b3IudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX2RpcmVjdG9yOiBpdGVtLmRpcmVjdG9yLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICBsZXQgZnJvbSA9IFtdO1xcbiAgICAgICAgICAgIGxldCBwbGF5ID0gW107XFxuICAgICAgICAgICAgZm9yIGVhY2gobGV0IHBsYXlMaXN0SXRlbSBpbiBpdGVtLmRsLmRkKSB7XFxuICAgICAgICAgICAgICAgIGZyb20ucHVzaChwbGF5TGlzdEl0ZW0uQGZsYWcpO1xcbiAgICAgICAgICAgICAgICBwbGF5LnB1c2gocGxheUxpc3RJdGVtLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXNpdGVtLnZvZF9wbGF5X2Zyb20gPSBmcm9tLmpvaW4oXFxcIiQkJFxcXCIpO1xcbiAgICAgICAgICAgIHJlc2l0ZW0udm9kX3BsYXlfdXJsID0gcGxheS5qb2luKFxcXCIkJCRcXFwiKTtcXG4gICAgICAgICAgICBsaXN0LnB1c2gocmVzaXRlbSk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3RcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBwbGF5KGZsYWcsIGlucHV0KSB7XFxuICAgICAgICBsZXQgcGFyc2VfdXJsID0gdGhpcy5zb3VyY2UucGxheXVybCB8fCBcXFwiXFxcIjtcXG4gICAgICAgIGlmICgvXFxcXC4obTN1OHxtcDQpLy50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChwYXJzZV91cmwuc3RhcnRzV2l0aCgnanNvbjonKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgcHVybCA9IHBhcnNlX3VybC5yZXBsYWNlKCdqc29uOicsICcnKSArIGlucHV0O1xcbiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QocHVybCk7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogSlNPTi5wYXJzZShodG1sKS51cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBwYXJzZV91cmwgKyBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNlYXJjaCh3ZCwgcXVpY2ssIHBnKSB7XFxuICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICB3ZDogd2QsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBsZXQgbGlzdCA9IFtdO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgbGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9Td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cy5nZXRIb21lRGF0YSgpO1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICBsaXN0OiBkYXRhLmxpc3QgfHwgW11cXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBob21lKCkge1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHRoaXMuZ2V0SG9tZURhdGEoKSk7XFxuICAgIH0sXFxuICAgIGNhdGVnb3J5KHRpZCwgcGcsIGZpbHRlciwgZXh0ZW5kKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcInZpZGVvbGlzdFxcXCIsXFxuICAgICAgICAgICAgdDogdGlkLFxcbiAgICAgICAgICAgIHBnOiBcXFwiXFxcIiArIHBnXFxuICAgICAgICB9KSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgfSkpO1xcbiAgICB9LFxcbiAgICBwbGF5KGZsYWcsIGlucHV0KSB7XFxuICAgICAgICBsZXQgcGFyc2VfdXJsID0gdGhpcy5zb3VyY2UucGxheXVybCB8fCBcXFwiXFxcIjtcXG4gICAgICAgIGlmICgvXFxcXC4obTN1OHxtcDQpLy50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChwYXJzZV91cmwuc3RhcnRzV2l0aCgnanNvbjonKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgcHVybCA9IHBhcnNlX3VybC5yZXBsYWNlKCdqc29uOicsICcnKSArIGlucHV0O1xcbiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QocHVybCk7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogSlNPTi5wYXJzZShodG1sKS51cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBwYXJzZV91cmwgKyBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNlYXJjaCh3ZCwgcXVpY2ssIHBnKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICB3ZDogd2QsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKTtcXG4gICAgfSxcXG4gICAgZ2V0UnVsZShrZXkpIHtcXG4gICAgICAgIHJldHV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XCLlr7zlh7pcXFwiKSB7XFxuICAgICAgICByZXR1cm4gJChuaykuaW5wdXQoKGl0ZW0pID0+IHtcXG4gICAgICAgICAgbGV0IG9iaiA9IHt9O1xcbiAgICAgICAgICBvYmpbaW5wdXRdID0gaXRlbTtcXG4gICAgICAgICAgY29weShKU09OLnN0cmluZ2lmeShvYmopKVxcbiAgICAgICAgfSwgaXRlbSlcXG4gICAgICB9XFxuICAgICAgaWYgKHggPT0gXFxcIuWvvOWFpVxcXCIpIHtcXG4gICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIiwgXFxcIuivt+i+k+WFpeS4u+mimGpzb25cXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSAkLl90aGVtZS5nZXQoKTtcXG4gICAgICAgICAgICBsZXQgb2JqID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgbGV0IHN1Y2Nlc3MgPSBmYWxzZTtcXG4gICAgICAgICAgICBPYmplY3QuZW50cmllcyhvYmopLmZvckVhY2goKFtrLCB2XSkgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKCFqc29uLmhhc093blByb3BlcnR5KGspKSB7XFxuICAgICAgICAgICAgICAgICQuX3RoZW1lLnNldChrLCB2KTtcXG4gICAgICAgICAgICAgICAgc3VjY2VzcyA9IHRydWU7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwia2V5OlxcXCIgKyBrICsgXFxcIiDlt7Lnu4/lrZjlnKgs6Lez6L+HXFxcIik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBpZiAoc3VjY2Vzcykge1xcbiAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr7zlhaXmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/moLzlvI/plJnor69cXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgIH1cXG4gICAgICBpZiAoeCA9PSBcXFwi5pS55ZCNXFxcIikge1xcbiAgICAgICAgaWYgKC9eKOm7mOiupHzlvZPliY0pJC8udGVzdChuaykpIHtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveaUueWQjVxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICByZXR1cm4gJChcXFwi5paw5ZCN56ewXFxcIikuaW5wdXQoKGspID0+IHtcXG4gICAgICAgICAgICBsZXQgb2JqID0gJC5fdGhlbWUuZ2V0KCk7XFxuICAgICAgICAgICAgbGV0IG5ld09iaiA9IE9iamVjdC5rZXlzKG9iaikucmVkdWNlKChhY2MsIGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKGtleSA9PT0gaykge1xcbiAgICAgICAgICAgICAgICBhY2NbaW5wdXRdID0gb2JqW2tleV07XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBhY2Nba2V5XSA9IG9ialtrZXldO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgcmV0dXJuIGFjYztcXG4gICAgICAgICAgICB9LCB7fSk7XFxuICAgICAgICAgICAgJC5fdGhlbWUuc2F2ZShKU09OLnN0cmluZ2lmeShuZXdPYmopKTtcXG4gICAgICAgICAgICBwdXRNeVZhcigkLm15X3VybCArIFxcXCJuXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIH0sIG5rKVxcbiAgICAgICAgfVxcbiAgICAgIH1cXG4gICAgICBpZiAoeCA9PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgaWYgKC9eKOm7mOiupHzlvZPliY0pJC8udGVzdChuaykpIHtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveWIoOmZpFxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6ZmkXFxcIikuY29uZmlybSgoaykgPT4ge1xcbiAgICAgICAgICAgIC8qKlxcbiAgICAgICAgICAgICAqIOiOt+WPluWvueixoeS4ree7meWumumUrueahOWJjeS4gOS4quaIluWQjuS4gOS4qumUruOAglxcblxcbiAgICAgICAgICAgICAqIOatpOWHveaVsOeUqOS6jumBjeWOhuWvueixoeeahOmUru+8jOagueaNrue7meWumueahOmUruaJvuWIsOWFtuWJjeS4gOS4quaIluWQjuS4gOS4qumUruOAglxcbiAgICAgICAgICAgICAqIOWmguaenOe7meWumueahOmUruS4jeWtmOWcqOS6juWvueixoeS4re+8jOWHveaVsOWwhuWwneivleaJvuWIsOWkp+S6jue7meWumumUrueahOesrOS4gOS4qumUruOAglxcbiAgICAgICAgICAgICAqIOWmguaenOWvueixoeS4reayoeacieWkp+S6jue7meWumumUrueahOmUru+8jOWImei/lOWbnuWvueixoeeahOacgOWQjuS4gOS4qumUruOAglxcbiAgICAgICAgICAgICAqIFxcbiAgICAgICAgICAgICAqIEBwYXJhbSB7T2JqZWN0fSBvYmog6KaB6YGN5Y6G55qE5a+56LGh44CCXFxuICAgICAgICAgICAgICogQHBhcmFtIHtzdHJpbmd9IGtleSDopoHmn6Xmib7liY3kuIDkuKrmiJblkI7kuIDkuKrplK7nmoTplK7jgIJcXG4gICAgICAgICAgICAgKiBAcmV0dXJucyB7c3RyaW5nfSDov5Tlm57mib7liLDnmoTliY3kuIDkuKrmiJblkI7kuIDkuKrplK7jgIJcXG4gICAgICAgICAgICAgKi9cXG4gICAgICAgICAgICBmdW5jdGlvbiBnZXRQcmV2aW91c09yTmV4dEtleShvYmosIGtleSkge1xcbiAgICAgICAgICAgICAgY29uc3Qga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XFxuICAgICAgICAgICAgICBjb25zdCBpbmRleCA9IGtleXMuaW5kZXhPZihrZXkpO1xcbiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gLTEpIHtcXG4gICAgICAgICAgICAgICAgLy8g5aaC5p6c6ZSu5a2Y5Zyo77yM6L+U5Zue5YmN5LiA5Liq6ZSuXFxuICAgICAgICAgICAgICAgIHJldHVybiBpbmRleCA+IDAgPyBrZXlzW2luZGV4IC0gMV0gOiBrZXlzW2luZGV4ICsgMV07IC8vIOWmguaenOaYr+esrOS4gOS4qumUru+8jOi/lOWbnuS4i+S4gOS4qumUrlxcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgLy8g5aaC5p6c6ZSu5LiN5a2Y5Zyo77yM6L+U5Zue5LiL5LiA5Liq6ZSuXFxuICAgICAgICAgICAgICAgIGNvbnN0IG5leHRJbmRleCA9IGtleXMuZmluZEluZGV4KGsgPT4gayA+IGtleSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBuZXh0SW5kZXggPiAtMSA/IGtleXNbbmV4dEluZGV4XSA6IGtleXNba2V5cy5sZW5ndGggLSAxXTsgLy8g5aaC5p6c5rKh5pyJ5LiL5LiA5Liq6ZSu77yM6L+U5Zue5pyA5ZCO5LiA5Liq6ZSuXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBvYmogPSAkLl90aGVtZS5nZXQoKTtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IGdldFByZXZpb3VzT3JOZXh0S2V5KG9iaiwgayk7XFxuICAgICAgICAgICAgZGVsZXRlIG9ialtrXTtcXG4gICAgICAgICAgICAkLl90aGVtZS5zYXZlKEpTT04uc3RyaW5naWZ5KG9iaikpO1xcblxcbiAgICAgICAgICAgIHB1dE15VmFyKCQubXlfdXJsICsgXFxcIm5cXFwiLCBuYW1lKTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICB9LCBuaylcXG4gICAgICAgIH1cXG4gICAgICB9XFxuICAgIH0sIHgsIG5rLCBpdGVtKVxcbiAgfSlcXG59KVxcbmQucHVzaCh7XFxuICBjb2xfdHlwZTogXFxcImJpZ19ibGFua19ibG9ja1xcXCJcXG59KVxcblxcbk9iamVjdC5rZXlzKGpzb24pLmZvckVhY2goKGssIGkpID0+IHtcXG4gIGxldCBsb25nY2xpY2tzID0gW107XFxuICBpZiAoIS9eKOm7mOiupHzlvZPliY0pJC8udGVzdChrKSkge1xcbiAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5pS55ZCNXFxcIixcXG4gICAgICBqczogJC50b1N0cmluZygoaykgPT4ge1xcbiAgICAgICAgcmV0dXJuICQoXFxcIuaWsOWQjeensFxcXCIpLmlucHV0KChrKSA9PiB7XFxuICAgICAgICAgIGxldCBvYmogPSAkLl90aGVtZS5nZXQoKTtcXG4gICAgICAgICAgbGV0IG5ld09iaiA9IE9iamVjdC5rZXlzKG9iaikucmVkdWNlKChhY2MsIGtleSkgPT4ge1xcbiAgICAgICAgICAgIGlmIChrZXkgPT09IGspIHtcXG4gICAgICAgICAgICAgIGFjY1tpbnB1dF0gPSBvYmpba2V5XTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgYWNjW2tleV0gPSBvYmpba2V5XTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGFjYztcXG4gICAgICAgICAgfSwge30pO1xcbiAgICAgICAgICAkLl90aGVtZS5zYXZlKEpTT04uc3RyaW5naWZ5KG5ld09iaikpO1xcbiAgICAgICAgICBwdXRNeVZhcigkLm15X3VybCArIFxcXCJuXFxcIiwgaW5wdXQpO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