Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@云盘君.简@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IuS6keebmOWQmy7nroAiLCJhdXRob3IiOiLlsI/mo4noooTwn4yeJkBMb3lEZ0lrIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6MTc4LCJjb2xfdHlwZSI6Im1vdmllXzMiLCJjbGFzc19uYW1lIjoiIiwidHlwZSI6ImFsbCIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1haW5cIik7Iiwic2VhcmNoX3VybCI6Imhpa2VyOi8vZW1wdHk/c2VhcmNoVGVybXM9KioiLCJncm91cCI6IuKRoOe9keebmCIsInNlYXJjaEZpbmQiOiJqczpcbmxldCBpc2REZWxlZ2F0ZSA9ICEhZ2V0SXRlbShcImlzZERlbGVnYXRlXCIsIFwiXCIpO1xuaWYgKGlzZERlbGVnYXRlKSB7XG4gICAgc2V0UmVzdWx0KFt7XG4gICAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgICAgdXJsOiBcImhpa2VyOi8vc2VhcmNoP3M9XCIgKyBNWV9LRVlXT1JELFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgZGVsZWdhdGVPbmx5U2VhcmNoOiB0cnVlLFxuICAgICAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlR3JvdXAgPSBnZXRJdGVtKFwicnVsZUdyb3VwXCIsIFwiXCIpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9ICQucmVxdWlyZShcImRhdGFcIikuZ2V0QWxsRGF0YShydWxlR3JvdXApO1xuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgZGF0YSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKHJ1bGUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UmVzdWx0KCQucmVxdWlyZShcImRhdGFcIikuY2FycnlTUnVsZShydWxlLCBNWV9LRVlXT1JELCBNWV9QQUdFLCBnZXRTZWFyY2hNb2RlKCkpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBpdClcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShydWxlcyk7XG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9XG4gICAgfV0pO1xufSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5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MV92ZXJ0aWNhbF9waWNcXFwiIDogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe1xcbiAgICAgICAgICAgICAgICBpbmhlcml0VGl0bGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZVxcbiAgICAgICAgICAgIH0sIGl0LmV4dHJhKVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIHJlc0xpc3Q7XFxufVxcbiQuZXhwb3J0cy5jYXJyeVNSdWxlID0gZnVuY3Rpb24ocnVsZSwgcywgcGFnZSwgc2VhcmNoTW9kZSkge1xcbiAgICBydWxlID0gZ2V0Q29tcGxldGVSdWxlKHJ1bGUpO1xcbiAgICBsZXQgbGlzdCA9IHJ1bGUuZmluZChzLCBwYWdlKTtcXG4gICAgaWYgKCFsaXN0KSByZXR1cm4gW107XFxuICAgIGxldCByZXNMaXN0ID0gW107XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGlmIChpdC5za2lwKSB7XFxuICAgICAgICAgICAgcmVzTGlzdC5wdXNoKGl0KTtcXG4gICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChzZWFyY2hNb2RlICYmICFzZWFyY2hDb250YWlucyhpdC50aXRsZSwgcywgdHJ1ZSkpIGNvbnRpbnVlO1xcbiAgICAgICAgaWYgKHJ1bGUuZmluZEFsaVVybCkge1xcbiAgICAgICAgICAgIGl0LnVybCA9ICQoaXQudXJsKS5sYXp5UnVsZSh0b1JlZGlyZWN0VHJlYXRpbmcsIHtcXG4gICAgICAgICAgICAgICAgZmluZEFsaVVybDogcnVsZS5maW5kQWxpVXJsLFxcbiAgICAgICAgICAgICAgICBiYXNpY1VybDogcnVsZS5iYXNpY1VybCxcXG4gICAgICAgICAgICAgICAgbmFtZTogcnVsZS5uYW1lLFxcbiAgICAgICAgICAgICAgICBhdXRob3I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xldCBjbGlwYm9hcmQgPSBjb250ZXh0LmdldFN5c3RlbVNlcnZpY2UoQ29udGV4dC5DTElQQk9BUkRfU0VSVklDRSk7XFxuICAgICAgICAgICAgLy8g6L+U5Zue5pWw5o2uXFxuICAgICAgICAgICAgbGV0IGNsaXBEYXRhID0gY2xpcGJvYXJkLmdldFByaW1hcnlDbGlwKCk7XFxuICAgICAgICAgICAgaWYgKGNsaXBEYXRhICE9IG51bGwgJiYgY2xpcERhdGEuZ2V0SXRlbUNvdW50KCkgPiAwKSB7XFxuICAgICAgICAgICAgICAgIC8vIOS7juaVsOaNrumbhuS4reiOt+WPlu+8iOeymOi0tO+8ieesrOS4gOadoeaWh+acrOaVsOaNrlxcbiAgICAgICAgICAgICAgICBsZXQgdGV4dCA9IGNsaXBEYXRhLmdldEl0ZW1BdCgwKS5nZXRUZXh0KCk7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0ICE9IG51bGwpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcodGV4dC50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgdGV4dCA9IGdldENvcHkoKSB8fCBcXFwiXFxcIjtcXG4gICAgbGV0IHVybCA9IGFsaXRlc3QubWF0Y2hBbGlVcmwodGV4dCk7XFxuICAgIGlmICh1cmwpIHtcXG4gICAgICAgIGxldCBjYWNoZSA9IGdldEl0ZW0oXFxcImNsaXBib2FyZENhY2hlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKHVybCAhPT0gY2FjaGUpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnTxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLmo4DmtYvliLDliarotLTmnb/lkKvmnInpmL/ph4zpk77mjqXmmK/lkKbmiZPlvIA/XFxcXG5cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlucHV0LCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShpZCArIFxcXCJjbGlwYm9hcmRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpICsgXFxcIiZzaGFyZVB3ZD1cXFwiO1xcbiAgICAgICAgICAgICAgICB9LCB1cmwsIGlkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcImNsaXBib2FyZFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IFxcXCLmiZPlvIDpk77mjqVcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJjbGlwYm9hcmRDYWNoZVxcXCIsIHVybCk7XFxuICAgICAgICB9XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0UHJlcG9zZSgpIHtcXG4gICAgaWYgKG9wZW5Nb2RlID09IFxcXCLmnKzlnLDop6PmnpBcXFwiKSB7XFxuICAgICAgICBsZXQgYWxpVG9rZW5zRmlsZXBhdGggPSAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS90b2tlblBhdGhcXFwiKS5hbGlUb2tlbnNGaWxlcGF0aDtcXG4gICAgICAgIGxldCBhID0gZmV0Y2goYWxpVG9rZW5zRmlsZXBhdGgpO1xcbiAgICAgICAgaWYgKCFhIHx8IGEgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwicmljaF90ZXh0XFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4gJC5yZXF1aXJlKFxcXCJsb2dpbk1vZGVcXFwiKSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKrmo4DmtYvliLDnmbvlvZXkv6Hmga/vvIzngrnmiJHot7PovaznmbvlvZXotKblj7fpobXpnaLvvIznmbvlvZXpmL/ph4zkupHnm5jotKblj7flkI7mlrnlj6/kvb/nlKjmnKzlnLDop6PmnpDmqKHlvI9cXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBcXFwi55m75b2V6Zi/6YeM5LqR55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgYWRkTGlzdGVuZXIoXFxcIm9uQ2xvc2VcXFwiLCAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGNsZWFyTXlWYXIoXFxcInNcXFwiKTtcXG4gICAg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VVUklDb21wb25lbnQocGxheWRhdGEudGl0bGUuc3BsaXQoJy0nKVswXSk7XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogTVlfUlVMRS50aXRsZSArIFxcXCLlvLnluZXmkJzntKJcXFwiXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoXFxcIu+/pXByb2plY3Rpb25fc2NyZWVu77+lXFxcIiArIEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKFxcXCLmkq3mlL7mqKHlvI9cXFwiID09PSBpbnB1dCkge1xcbiAgICAgICAgICAgICAgICBsZXQgbW9kZXMgPSBbXFxcIui9rOeggVxcXCIsIFxcXCLljp/nlLtcXFwiLCBcXFwi5Y6f6L2sXFxcIl07XFxuICAgICAgICAgICAgICAgIGxldCBtb2RlID0gZ2V0SXRlbShcXFwiYWxpeXVuX3BsYXlNb2RlXFxcIiwgbW9kZXNbMF0pO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBtb2Rlcy5pbmRleE9mKG1vZGUpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChtb2RlcywgMSwgXFxcIuaSreaUvuaooeW8j1xcXCIsIGluZGV4KS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXVuX3BsYXlNb2RlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WIh+aNouaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoXFxcIueZu+W9leS/oeaBr1xcXCIgPT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgY29uc3Qge1xcbiAgICAgICAgICAgICAgICAgICAgb3BlblRva2Vuc0ZpbGVwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgYWxpVG9rZW5zRmlsZXBhdGhcXG4gICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwidG9rZW5QYXRoXFxcIik7XFxuICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KGFsaVRva2Vuc0ZpbGVwYXRoKSkgcmV0dXJuIFxcXCJ0b2FzdDovL+i/mOacqueZu+mZhlxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCBhbGkgPSByZXF1ZXN0KGFsaVRva2Vuc0ZpbGVwYXRoKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaSA9IEpTT04ucGFyc2UoYWxpKTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlRmlsZShhbGlUb2tlbnNGaWxlcGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6I635Y+W5aSx6LSlXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn55m75b2V5L+h5oGvJyxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLnlKjmiLc6XFxcIiArIChhbGkubmlja19uYW1lIHx8IGFsaS51c2VyX25hbWUgfHwgXFxcIlRva2Vu55m75b2VXFxcIikgKyBcXFwiXFxcXG5Ub2tlbjpcXFwiICsgYWxpLnJlZnJlc2hfdG9rZW4gKyBcXFwiXFxcXG4o5Y+W5raI77ya5rOo6ZSA55m75b2V77yb56Gu5a6a77ya5aSN5Yi2VG9rZW4pXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbmZpcm06ICQudG9TdHJpbmcoKHRva2VuKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIHRva2VuO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYWxpLnJlZnJlc2hfdG9rZW4pLFxcbiAgICAgICAgICAgICAgICAgICAgY2FuY2VsOiAkLnRvU3RyaW5nKChwYXRoMSwgcGF0aDIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5rOo6ZSA55m75b2VXFxcIikuY29uZmlybSgocGF0aDEsIHBhdGgyKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUZpbGUocGF0aDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVGaWxlKHBhdGgyKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suaIkOWKn+mAgOWHuueZu+mZhlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgcGF0aDEsIHBhdGgyKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGFsaVRva2Vuc0ZpbGVwYXRoLCBvcGVuVG9rZW5zRmlsZXBhdGgpXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlucHV0ID0gaW5wdXQucmVwbGFjZShcXFwi5qih5byP77yaXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcIm9wZW5Nb2RlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWRzLCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6+572ufFxcXCIgKyBpbnB1dFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6Y5pa5QVBQXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5Yqf77yM6K+356Gu5L+d5omL5py65pyJ5a6J6KOF6Zi/6YeM5LqR55uY562J5a6Y5pa5QVBQXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LCBpZCArIFxcXCJtb2RlXFxcIiksXFxuICAgICAgICBjb2xfdHlwZTogXFxcImljb25fM19yb3VuZF9maWxsXFxcIixcXG4gICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX21lbnU2XFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IGlkICsgXFxcIm1vZGVcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6ICfmkJzntKInLFxcbiAgICAgICAgZGVzYzogJ+ivt+i+k+WFpeWFs+mUruivjS/pk77mjqUnLFxcbiAgICAgICAgY29sX3R5cGU6ICdpbnB1dCcsXFxuICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgIGlmICgkLnJlcXVpcmUoXFxcImFsaXRlc3RcXFwiKS50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJzXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpICsgXFxcIiZzaGFyZVB3ZD1cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwic1xcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICByZ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E7XFxuICAgICAgICAgICAgZ3JvdXAudW5zaGlmdChcXFwi8J+SoeWFqOmDqPCfkqFcXFwiKTtcXG4gICAgICAgICAgICBsZXQgc2VsZWN0TnVtID0gJC5yZXF1aXJlKFxcXCJkYXRhXFxcIikuZmluZE1vZHVsbyhncm91cC5sZW5ndGgpO1xcbiAgICAgICAgICAgIHJldHVybiAkKGdyb3VwLCBzZWxlY3ROdW0sIFxcXCLor7fpgInmi6nliIbnu4RcXFwiLCBpbmRleCkuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKCFNWV9JTkRFWCkge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZUdyb3VwXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZUdyb3VwXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiBcXFwiXFxcIiA9PSByID8gXFxcIuKAnOKAnOWFqOmDqOKAneKAnVxcXCIgOiBcXFwi5YWo6YOoXFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgocywgaWQpID0+IHtcXG4gICAgICAgICAgICBsZXQgcXIgPSBnZXRJdGVtKFxcXCJydWxlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgICAgIGlmIChzKSB7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwi5YWo6YOoXFxcIiArIGlkLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOWFqOmDqOKAneKAnVxcXCJcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGlmIChxcikge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCArIHFyLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHFyXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgcywgaWQpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IFxcXCLlhajpg6hcXFwiICsgaWRcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGZvciAobGV0IFtpdCwgYmFzaWNVcmxdIG9mIHJ1bGVzKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBpdCA9PSByID8gXFxcIuKAnOKAnFxcXCIgKyBpdCArIFxcXCLigJ3igJ1cXFwiIDogaXQsXFxuICAgICAgICAgICAgdXJsOiAkKChnZXRIb21lKGJhc2ljVXJsKSB8fCBcXFwiXFxcIikgKyBcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgociwgcywgaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IHFyID0gZ2V0SXRlbShcXFwicnVsZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZVxcXCIsIHIpO1xcbiAgICAgICAgICAgICAgICBpZiAocykge1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0ocXIgPyAoaWQgKyBxcikgOiAoXFxcIuWFqOmDqFxcXCIgKyBpZCksIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogcXIgfHwgXFxcIuWFqOmDqFxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCArIHIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyByICsgXFxcIuKAneKAnVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgaXQsIHMsIGlkKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBpZCArIGl0XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG5cXG59XFxuXFxuZnVuY3Rpb24gcmVjb3JkKCkge1xcbiAgICBsZXQgaGlzdG9yeSA9IHN0b3JhZ2UwLmdldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBbXSk7XFxuICAgIGxldCBpaSA9IGhpc3RvcnkuaW5kZXhPZihzKTtcXG4gICAgaWYgKGlpID4gLTEpIHtcXG4gICAgICAgIGhpc3Rvcnkuc3BsaWNlKGlpLCAxKTtcXG4gICAgfVxcbiAgICBpZiAoaGlzdG9yeS5sZW5ndGggPiAyMCkge1xcbiAgICAgICAg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SB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiZGF0YVxcXCIpLmNhcnJ5UnVsZShydWxlLCBzLCByZWFsUGFnZSwgc2VhcmNoTW9kZSk7XFxuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9nKHJ1bGUubmFtZSArIFxcXCI6XFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLyppZihkYXRhLmxlbmd0aD09PTEmJnA9PT0xKXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTpcXFwi4oCc4oCcXFxcIitydWxlLm5hbWUrXFxcIiBFUlJPUuKAneKAnVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBlLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTpcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6XFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6e1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuIHJ1bGUuZmluZChzLCByZWFsUGFnZSk7XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIHBhcmFtOiBpdCxcXG4gICAgICAgICAgICAgICAgaWQ6IFxcXCJydWxlQFxcXCIgKyBpdC5uYW1lXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuXFxuICAgICAgICBiYXRjaEV4ZWN1dGUodGFza3MsIHtcXG4gICAgICAgICAgICBmdW5jOiBmdW5jdGlvbihwYXJhbSwgaWQsIGVycm9yLCByZXN1bHQpIHtcXG4gICAgICAgICAgICAgICAgcGFyYW0uaSArPSAxO1xcbiAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZXN1bHQpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKFxcXCJfbm90aGF2ZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUJlZm9yZShwYWdlaWQsIHJlc3VsdCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHBhcmFtLmkgPT09IHBhcmFtLmFsbCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFyZXN1bHQgfHwgIXJlc3VsdC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKFxcXCJfbm90aGF2ZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1CZWZvcmUocGFnZWlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6LWE5rqQ6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBcXFwiX25vdGhhdmVcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0ocGFnZWlkKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0ocGFnZWlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliqDovb3nrKxcXFwiICsgTVlfUEFHRSArIFxcXCLpobXkuK3vvIzov5vluqbvvJpcXFwiICsgKHBhcmFtLmkgKyAxKSArIFxcXCIvXFxcIiArIHBhcmFtLmFsbCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICAgICAgYWxsOiBkYXRhLmxlbmd0aCxcXG4gICAgICAgICAgICAgICAgaTogMCxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICB9XFxufVxcblxcbmZ1bmN0aW9uIHNldEhpc3RvcnkoKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogJzxzcGFuIHN0eWxlPVxcXCJjb2xvcjojZmY2NjAxXFxcIj48Yj7ljoblj7LorrDlvZU8L2I+PC9zcGFuPicsXFxuICAgICAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9jbG9ja1xcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgICAgICB1cmw6ICQoW1xcXCLmuIXpmaTmkJzntKLorrDlvZVcXFwiLCBcXFwi5omT5byA6KeC55yL6K6w5b2VXFxcIl0pLnNlbGVjdCgoaWQpID0+IHtcXG4gICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLmuIXpmaTmkJzntKLorrDlvZVcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7lrprmuIXpmaTlhajpg6jmkJzntKLorrDlvZXvvJ9cXFwiKS5jb25maXJtKChpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoaWQgKyBcXFwiOmtleVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKGlkICsgXFxcIjpzZWFyY2hIaXN0b3J5XFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBpZCArIFxcXCI6a2V5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0sIGlkKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vaGlzdG9yeT9ydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGlkKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IGlkICsgXFxcIjpzZWFyY2hIaXN0b3J5XFxcIixcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIGxldCBoaXN0b3J5ID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIFtdKTtcXG4gICAgbGV0IGkgPSAwO1xcbiAgICBmb3IgKGxldCBrZXkgb2YgaGlzdG9yeSkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZToga2V5LFxcbiAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQsIGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgZXh0cmEgPSBmaW5kSXRlbShpZCArIFxcXCJzc1xcXCIpLmV4dHJhO1xcbiAgICAgICAgICAgICAgICBleHRyYS5kZWZhdWx0VmFsdWUgPSBrZXk7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oe1xcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IGV4dHJhXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0sIGlkLCBrZXkpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiZmxleF9idXR0b25cXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBpZCArIFxcXCI6a2V5OlxcXCIgKyBrZXksXFxuICAgICAgICAgICAgICAgIGNsczogaWQgKyBcXFwiOmtleVxcXCIsXFxuICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6Zmk5YWz6ZSu6K+NOlxcXCIgKyBrZXksXFxuICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoaWQsIGtleSwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBoaXN0b3J5ID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIFtdKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoaXN0b3J5LnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgaGlzdG9yeSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShpZCArIFxcXCI6a2V5OlxcXCIgKyBrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGlkLCBrZXksIGkpXFxuICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgaWYgKGhpc3RvcnkubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgY2xzOiBpZCArIFxcXCI6a2V5XFxcIixcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0VHJlbmRpbmdUYWJFbmQoKSB7XFxuICAgIGxldCBob3RDbGFzcyA9IHtcXG4gICAgICAgIFxcXCLnmb7luqZcXFwiOiB7XFxuICAgICAgICAgICAgXFxcIueUteinhuWJp1xcXCI6IFxcXCJ0ZWxlcGxheVxcXCIsXFxuICAgICAgICAgICAgXFxcIueUteW9sVxcXCI6IFxcXCJtb3ZpZVxcXCJcXG4gICAgICAgIH0sXFxuICAgICAgICBcXFwi5aS45YWLXFxcIjoge1xcbiAgICAgICAgICAgIFxcXCLnlLXop4bliadcXFwiOiBcXFwi55S16KeG5YmnXFxcIixcXG4gICAgICAgICAgICBcXFwi55S15b2xXFxcIjogXFxcIueUteW9sVxcXCIsXFxuICAgICAgICAgICAgXFxcIuWKqOa8q1xcXCI6IFxcXCLliqjmvKtcXFwiLFxcbiAgICAgICAgICAgIFxcXCLnu7zoibpcXFwiOiBcXFwi57u86Im6XFxcIlxcbiAgICAgICAgfVxcbiAgICB9O1xcbiAgICBsZXQgZGF0YVNvdXJjZSA9IE9iamVjdC5rZXlzKGhvdENsYXNzKTtcXG4gICAgbGV0IHNlbGVjdHNvdXJjZSA9IGdldEl0ZW0oXFxcImRhdGFTb3VyY2VcXFwiLCBkYXRhU291cmNlWzBdKTtcXG4gICAgbGV0IGhvdGtleXMgPSBPYmplY3Qua2V5cyhob3RDbGFzc1tzZWxlY3Rzb3VyY2VdKTtcXG4gICAgbGV0IHNlbGVjdGtleSA9IGdldEl0ZW0oXFxcImhvdGtleVxcXCIsIGhvdGtleXNbMF0pO1xcbiAgICBsZXQgdGFia2V5ID0gaG90Q2xhc3Nbc2VsZWN0c291cmNlXVtzZWxlY3RrZXldO1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6ICc8c3BhbiBzdHlsZT1cXFwiY29sb3I6I2ZmNjYwMVxcXCI+PGI+JyArIHNlbGVjdHNvdXJjZSArIHNlbGVjdGtleSArICfng63mkJw8L2I+PC9zcGFuPicsXFxuICAgICAgICB1cmw6ICQoaG90a2V5cywgMSwgXFxcIuWIh+aNoueDreaQnFxcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwiaG90a2V5XFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2i5Li6XFxcIiArIGlucHV0O1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgICAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9maXJlXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIh+aNouaVsOaNrua6kFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChkYXRhU291cmNlKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChkYXRhU291cmNlLCAxLCBcXFwi5YiH5o2i5pWw5o2u5rqQXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJkYXRhU291cmNlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwiaG90a2V5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliIfmjaLkuLpcXFwiICsgaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSwgZGF0YVNvdXJjZSlcXG4gICAgICAgICAgICB9XVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5q2j5Zyo5Yqg6L29Li4uXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IGlkICsgXFxcIjpob3RrZXlcXFwiLFxcbiAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgc2V0UmVzdWx0KGQpO1xcbiAgICBsZXQgc2QgPSBbXTtcXG4gICAgbGV0IHNldFNlYXJjaEtleSA9IG5hbWUgPT4ge1xcbiAgICAgICAgcHV0TXlWYXIoJ3MnLCBuYW1lKTtcXG4gICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICByZXR1cm4gJ2hpa2VyOi8vZW1wdHknXFxuICAgIH07XFxuXFxuICAgIGxldCBnZXRUaXRsZSA9IChpLCBuYW1lKSA9PiB7XFxuICAgICAgICBsZXQgY29sb3I7XFxuICAgICAgICBzd2l0Y2ggKGkpIHtcXG4gICAgICAgICAgICBjYXNlIDA6XFxuICAgICAgICAgICAgICAgIGNvbG9yID0gXFxcIiNmZjMzMDBcXFwiO1xcbiAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICBjYXNlIDE6XFxuICAgICAgICAgICAgICAgIGNvbG9yID0g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FxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdCc6ICdhcHBsaWNhdGlvbi9qc29uLCB0ZXh0L3BsYWluLCAqLyonLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICdBY2NlcHQtTGFuZ3VhZ2UnOiAnemgtQ04semg7cT0wLjksZW4tVVM7cT0wLjgsZW47cT0wLjcnLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICdBY2NlcHQtRW5jb2RpbmcnOiAnZ3ppcCwgZGVmbGF0ZSwgYnInLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vdG9wLmJhaWR1LmNvbS9ib2FyZD90YWI9bm92ZWwnLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgLy92YXIgcyA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgICAgIHZhciBsaXN0ID0gSlNPTi5wYXJzZShqc29uKS5kYXRhLmNhcmRzWzBdLmNvbnRlbnQ7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBsaXN0W2ldO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5hbWUgPSBpdGVtLndvcmQgKyAnICgnICsgaXRlbS5zaG93WzJdICsgJyknO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRlcyA9IGl0ZW0uZGVzYztcXG4gICAgICAgICAgICAgICAgICAgIHNkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRUaXRsZShpLCBuYW1lKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoc2V0U2VhcmNoS2V5LCBpdGVtLndvcmQpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGRlcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0ZW0uaW1nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibW92aWVfMV92ZXJ0aWNhbF9waWNcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICBjYXNlIFxcXCLlpLjlhYtcXFwiOlxcbiAgICAgICAgICAgICAgICB2YXIganNvbiA9IHJlcXVlc3QoXFxcImh0dHBzOi8vbmV3cy5teXF1YXJrLmNuL3YyL3RvcGxpc3QvbW92aWU/JmNoYW5uZWw9XFxcIiArIHRhYmtleSArIFxcXCImcmFua190eXBlPSVFNiU5QyU4MCVFNyU4MyVBRFxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgeG1sRGF0YSA9IChKU09OLnBhcnNlKGpzb24pLmRhdGEgfHwgXFxcIlxcXCIpLnJlcGxhY2UoL3RpdGxlPi9nLCBcXFwiaF90aXRsZT5cXFwiKS5yZXBsYWNlKC9zcmM+L2csIFxcXCJoX3NyYz5cXFwiKS5yZXBsYWNlKC9hcmVhPi9nLCBcXFwiaF9hcmVhXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBsaXN0ID0gcGRmYSh4bWxEYXRhLCBcXFwiYm9keSYmaXRlbVxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgZ2V0VGV4dCA9IHQgPT4gdDtcXG4gICAgICAgICAgICAgICAgdmFyIHRyZW5kID0gW1xcXCLjhKdcXFwiLCBcXFwi4oaRXFxcIiwgXFxcIuKGk1xcXCJdO1xcbiAgICAgICAgICAgICAgICAvL3ZhciBzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IHBkZmgoaXRlbSwgXFxcImhfdGl0bGUmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkZXMgPSBcXFwi54Ot5bqm77yaXFxcIiArIHBkZmgoaXRlbSwgXFxcImhvdF9zY29yZSYmVGV4dFxcXCIpICsgXFxcIiBcXFwiICsgdHJlbmQuYXQocGRmaChpdGVtLCBcXFwiaG90X3RyZW5kJiZUZXh0XFxcIikpICtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiXFxcXG7or4TliIbvvJpcXFwiICsgcGRmaChpdGVtLCBcXFwic2NvcmVfYXZnJiZUZXh0XFxcIikucmVwbGFjZSgvXjAkLywgXFxcIuaaguaXoOivhOWIhlxcXCIpICtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiXFxcXG5cXFwiICsgcGRmaChpdGVtLCBcXFwieWVhciYmVGV4dFxcXCIpICsgXFxcIsK3XFxcIiArIHBkZmgoaXRlbSwgXFxcImhfYXJlYSYmVGV4dFxcXCIpICsgXFxcIsK3XFxcIiArIHBkZmgoaXRlbSwgXFxcImNhdGVnb3J5JiZUZXh0XFxcIikucmVwbGFjZShcXFwiLFxcXCIsIFxcXCLCt1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgc2QucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGdldFRpdGxlKGksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZShzZXRTZWFyY2hLZXksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGRlcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IHBkZmgoaXRlbSwgXFxcImhfc3JjJiZUZXh0XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxc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b2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpLnNwbGl0KFxcXCImXFxcIilbMF0pO1xcbiAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgZXhwaXJlcyA9IHVybC5zcGxpdCgneC1vc3MtZXhwaXJlcz0nKVsxXS5zcGxpdCgnJicpWzBdO1xcbiAgICAgICAgY29uc3QgbGFzdHRpbWUgPSBwYXJzZUludChleHBpcmVzKSAtIERhdGUubm93KCkgLyAxMDAwO1xcbiAgICAgICAgaWYgKGxhc3R0aW1lIDwgNjApIHtcXG4gICAgICAgICAgICAvL2xvZygn6L+H5pyf5pu05pawJylcXG4gICAgICAgICAgICBsZXQgbGluZSA9IHVybC5zcGxpdCgnL21lZGlhJylbMF07IC8v5Y+W5LmL5YmN5pKt5pS+55qEdHPmrrXnur/ot69cXG4gICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcobGluZS5sYXN0SW5kZXhPZignLycpICsgMSk7XFxuICAgICAgICAgICAgbGV0IGYgPSBnZXRNM3U4Q29udGVudChnZXRBbGlQbGF5VXJsKGZpZCwgbGluZSkpLnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZnVybCA9IGJhc2U2NERlY29kZShpdC5yZXBsYWNlKCcvcHJveHk/dXJsPScsICcnKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGZ1cmw7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHVybDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHVybCA9IGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKTtcXG4gICAgICAgIGlmICh1cmwuaW5jbHVkZXMoXFxcIi50c1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiB1cGRhdGVUc1VybCh1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHRlbXBsYXRlSWQgPSBNWV9QQVJBTVMudGVtcGxhdGVJZFswXTtcXG4gICAgICAgICAgICBpZihmaWxlRXhpc3QoY2FjaGVGaWxlUGF0aCkpe1xcbiAgICAgICAgICAg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jtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aSreaUvuWksei0pe+8jOmUmeivr+S/oeaBr+W3suaJk+WNsOOAglxcXFxu6K+35p+l55yL5pel5b+XKExPRylcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IG1vdW50c3ViID0gc3RvcmFnZTAuZ2V0TXlWYXIoJ21vdW50emltdScsIHt9KTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhtb3VudHN1YikubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHppbXUgPSBtb3VudHN1YjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBzdWJ0aXRsZTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyh6aW11IHx8IHt9KS5sZW5ndGggPiAwICYmIHBsYXlMaXN0ICYmIHBsYXlMaXN0LnVybHMgJiYgcGxheUxpc3QudXJscy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgxMDApO1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHZhciB6bXVybCA9IGFsaUFjY2Vzc0FwaS5nZXRWaWRlb1RlbVBsYXlVcmwoemltdS5maWxlX2lkKTtcXG4gICAgICAgICAgICAgICAgbGV0IHBhdGggPSAnaGlrZXI6Ly9maWxlcy9jYWNoZS/kupHnm5jlkJsvc3ViLicgKyB6aW11LmV4dDtcXG4gICAgICAgICAgICAgICAgZG93bmxvYWRGaWxlKHptdXJsLCBwYXRoLCB7XFxuICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgc3VidGl0bGUgPSBnZXRQYXRoKHBhdGgpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgIC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hcmVBcGkuZ2V0U2hhcmVJbmZvKCk7XFxuICAgICAgICAgICAgbGV0IGZpbGVJbmZvID0gc2hhcmVJbmZvLmZpbGVfaW5mb3MgfHwgW107XFxuICAgICAgICAgICAgaWYgKGZpbGVJbmZvLmxlbmd0aCA9PT0gMSAmJiBmaWxlSW5mb1swXS50eXBlID09PSBcXFwiZm9sZGVyXFxcIiAmJiAhZmlsZUlkKSB7XFxuICAgICAgICAgICAgICAgIGZpbGVJZCA9IGZpbGVJbmZvWzBdLmZpbGVfaWQ7XFxuICAgICAgICAgICAgICAgIHNldE15UGFDYWNoZShcXFwiZmlsZUlkXFxcIiwgZmlsZUlkKTtcXG4gICAgICAgICAgICAgICAgc2V0UGFnZVRpdGxlKGZpbGVJbmZvWzBdLmZpbGVfbmFtZSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2V0UGFnZVRpdGxlKHNoYXJlSW5mby5zaGFyZV9uYW1lKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGRlYWRsaW5lID0gXFxcIuawuOS5heacieaViFxcXCI7XFxuXFxuICAgICAgICAgICAgaWYgKHNoYXJlSW5mby5leHBpcmF0aW9uKSB7XFxuICAgICAgICAgICAgICAgIGRlYWRsaW5lID0gXFxcIuacieaViOiHs++8mlxcXCIgKyBmb3JtYXREYXRlKHNoYXJlSW5mby5leHBpcmF0aW9uKTtcXG4gICAgICAgICAgICAgICAgLy9zaGFyZUluZm8udXBkYXRlZF9hdFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IChzaGFyZUluZm8uY3JlYXRvcl9uYW1lIHx8IHNoYXJlSW5mby5jcmVhdG9yX3Bob25lKSArIFxcXCImbmJzcDsmbmJzcDtcXFwiICsgZGVhZGxpbmUuc21hbGwoKSxcXG4gICAgICAgICAgICAgICAgdXJsOiByZWFsdXJsICsgXFxcIiNub0hpc3RvcnkjXFxcIixcXG4gICAgICAgICAgICAgICAgaW1nOiBzaGFyZUluZm8uYXZhdGFyIHx8IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3Vua25vd25cXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC50cmltKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5YWz6ZSu6K+NXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1biNub0hpc3RvcnkjI2Z1bGxUaGVtZSM/cGFnZT1meXBhZ2Umc2VhcmNoS2V5PVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBvbkNoYW5nZTogXFxcInB1dE15VmFyKCdsaXN0U2VhcmNoS2V5JyxpbnB1dClcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgc2VhcmNoS2V5ICsgXFxcIuKAneKAneeahOaQnOe0oue7k+aenFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmdW5jSXRlbXMgPSBbXTtcXG4gICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc3R5bGUsXFxuICAgICAgICAgICAgdXJsOiAkKHN0eWxlcywgMSwgXFxcIuaOkuW4g+agt+W8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImFsaXl1bl9zdHlsZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNolxcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ljb24uc3ZnXFxcIlxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBvcmRlck5hbWUsXFxuICAgICAgICAgICAgdXJsOiAkKG9yZGVyc0tleXMsIDIsIFxcXCLmjpLluo/mlrnlvI9cXFwiKS5zZW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6L295pys5Zyw5by55bmVXFxcIiwgXFxcIuaOqOmAgeWIsFRWQm94XFxcIiwgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCIsIFxcXCLojrflj5bmipXlsY9JUFxcXCIgLCBcXFwi5p6B6YCf5Y6f55S75LiL6L2957q/56iLXFxcIiAsIFxcXCLovazlrZjlvZPliY3mlofku7blpLlcXFwiXSwgMiwgXFxcIuabtOWkmuWKn+iDvVxcXCIpLnNlbGVjdCgoc2hhcmVJZCwgc2hhcmVQd2QsIGZpbGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnB1dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIui9rOWtmOS6keebmFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgc21hcnRkcml2ZTovL3NoYXJlL2Jyb3dzZT9zaGFyZUlkPSR7c2hhcmVJZH0mc2hhcmVQd2Q9JHtzaGFyZVB3ZHx8XFxcIlxcXCJ9YDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLnmbvpmYbotKblj7dcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9sb2dpbiNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuWkjeWItuWIhuS6q+mTvuaOpVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi5aSN5Yi26ZO+5o6lXFxcIiwgXFxcIuWkjeWItua1t+mYlOWPo+S7pFxcXCJdLCAxLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KCh1cmwpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIuWkjeWItumTvuaOpVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgdXJsO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly/pmL/ph4zkupHnm5jliIbkuqvlj6Pku6TjgIxcXFwiICsgZ2V0UGFnZVRpdGxlKCkgKyBcXFwi44CNXFxcXG5cXFwiICsgdXJsICsgXFxcIiBAaW1wb3J0PWpzOmBoaWtlcjovL3BhZ2UvYWxpeXVuP3JlYWx1cmw9JHtpbnB1dC50cmltKCl9JnJ1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiYDtcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXFxcIiArIHNoYXJlSWQgKyAoZmlsZUlkID8gXFxcIi9mb2xkZXIvXFxcIiArIGZpbGVJZCA6IFxcXCJcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZG1Nb3VudCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuafpeeci+aJi+WKqOaMgui9veWtl+W5lVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB6bSA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0aXAgPSB6bS5uYW1lID8gXFxcIuW9k+WJjeWtl+W5leaWh+S7tlxcXFxuXFxcIiArIHptLm5hbWUgKyBcXFwiLlxcXCIgKyB6bS5leHQgOiBcXFwi6L+Y5pyq5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogJ+aJi+WKqOaMgui9veWtl+W5lScsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB0aXAgKyBcXFwiXFxcXG4o54K55Ye75Y+W5raI5Y+v5Lul5riF6Zmk5oyC6L295a2X5bmVKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJtb3VudHppbXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5riF6Zmk5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5blvLnluZXmkJzntKLop4TliJlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJqc1xcXCI6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbG9hZERtP3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiJnRpdGxlPVxcXCIpICsgXFxcIitlbmNvZGVVUklDb21wb25lbnQocGxheWRhdGEudGl0bGUuc3BsaXQoJy0nKVswXSk7XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogTVlfUlVMRS50aXRsZSArIFxcXCLlvLnluZXmkJzntKJcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoXFxcIu+/pXByb2plY3Rpb25fc2NyZWVu77+lXFxcIiArIEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmjqjpgIHliLBUVkJveFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3R2Ym94UHVzaCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIiwgXFxcIuaQnOe0ouWwgemdolxcXCJdLCAxKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K+36L6T5YWl5Zu+54mH5Zyw5Z2AXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWcsOWdgFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFBhZ2VQaWNVcmwoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZnJvbnRDb3ZlciNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5bmipXlsY9JUFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpcCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpLmdldElQdjRBZGRyZXNzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpcC5zdGFydHNXaXRoKFxcXCIxOTIuMTY4LlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuivpUlQ6YCC55So5LqO5rWB6YePK+eDreeCueeahOaKleWxj1xcXFxu6K+35pu/5o2i6ZO+5o6l5Lit55qEMC4wLjAuMFxcXCIpLmNvbmZpcm0oKGlwKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGlwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXApO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXAgKyBcXFwiXFxcXG7ojrflj5blpLHotKXpnZ7nqLPlrppJUCzor7flvIDlkK/ng63ngrnlho3kvb/nlKgs6K+lSVDlj6/og73kvJrlj5gs5LiN6IO95oqV5bGPXFxcIikuY29uZmlybSgoKSA9PiB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmnoHpgJ/ljp/nlLvkuIvovb3nur/nqItcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChnZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFxcXCIxMFxcXCIpLCBcXFwi6K+36L6T5YWlMy0zMuS5i+mXtOeahOaVtOaVsFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzcGVlZFRocmVhZCA9IHBhcnNlSW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzcGVlZFRocmVhZCA8IDMgfHwgc3BlZWRUaHJlYWQgPiAzMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7kuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBTdHJpbmcoc3BlZWRUaHJlYWQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLovazlrZjlvZPliY3mlofku7blpLlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9teWFsaXl1biNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/cGFnZT1meXBhZ2VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUlkLCBzaGFyZVB3ZCwgZmlsZUlkKSxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ZpbGVpbnRvLnN2Z1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcjogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGZvbGRlck5hbWU6IGdldFBhZ2VUaXRsZSgpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCJBTExcXFwiLCBcXFwi6Lez6L+H5paH5Lu2XFxcIl1bTnVtYmVyKHNraXBGaWxlKV0sXFxuICAgICAgICAgICAgIC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dGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGZpbGVJdGVtLnRodW1ibmFpbCk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgbGV0IGZvbGRlclN0eWxlLCBmaWxlU3R5bGU7XFxuICAgIGxldCBmaWx0ZXJUeXBlID0gW107XFxuICAgIGlmIChzdHlsZSA9PT0gXFxcIui/veWJp1xcXCIpIHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwibW92aWVfMlxcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcInZpZGVvXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwi6L+95Ymn5qih5byP5Y+q5pi+56S65paH5Lu25aS55ZKM6KeG6aKRXFxcIi5zbWFsbCgpLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSBpZiAoc3R5bGUgPT09IFxcXCLnnIvlm75cXFwiKSB7XFxuICAgICAgICBmb2xkZXJTdHlsZSA9IFxcXCJhdmF0YXJcXFwiO1xcbiAgICAgICAgZmlsZVN0eWxlID0gXFxcImNhcmRfcGljXzNcXFwiO1xcbiAgICAgICAgZmlsdGVyVHlwZS5wdXNoKFxcXCJpbWFnZVxcXCIpO1xcbiAgICAgIC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ICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvYWxpeXVuP3BhZ2U9ZnlwYWdlJyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGZvbGRlclN0eWxlLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBmb3JtYXREYXRlKGZpbGVJdGVtLnVwZGF0ZWRfYXQpLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IE1ZX1BBUkFNUy5zaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgZmlsZUlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXI6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui9rOWtmFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIilcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSBpZiAobm9Ta2lwRmlsZSkge1xcbiAgICAgICAgICAgIGlmIChmaWx0ZXJUeXBlLmxlbmd0aCA+IDAgJiYgIWZpbHRlclR5cGUuaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdWJ0aXRsZSwgY2xzLCBsb25nYyA9IFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L2s5a2YXFxcIixcXG4gICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIilcXG4gICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBmaWxlSXRlbS5uYW1lO1xcbiAgICAgICAgICAgIGxldCBuYW1lTm90RXh0ID0gZmlsZUl0ZW0ubmFtZS5yZXBsYWNlKCcuJyArIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCAnJyk7XFxuICAgICAgICAgICAgaWYgKHN1YkV4dHMuaW5jbHVkZXMoZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pKSB7XFxuICAgICAgICAgICAgICAgIGxvbmdjLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjILovb3lrZfluZVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHptKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ21vdW50emltdScsIHptKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3RvYXN0Oi8v5oyC6L295a6M5oiQ77yM5b2T5YmN5a2X5bmV5paH5Lu2OiAnICsgem0ubmFtZSArICcuJyArIHptLmV4dDtcXG4gICAgICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHQ6IGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVfaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogbmFtZU5vdEV4dFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY2F0ZSA9PT0gXFxcInZpZGVvXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAoemltdWxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IHppbXVsaXN0LmZpbmQodiA9PiB2Lm5hbWUuaW5jbHVkZXMobmFtZU5vdEV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNscyA9IFxcXCJwbGF5bGlzdCB2XFxcIiArIHBhZ2VJZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGZpbGVTdHlsZSA9PT0gXFxcInRleHRfMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgZGVzYyArPSBcXFwiXFxcXHRcXFxcdFxcXCIgKyBmb3JtYXRTaXplKGZpbGVJdGVtLnNpemUpO1xcbiAgICAgICAgICAgICAgICB0aXRsZSA9IGdldEhlYWQoY2F0ZSwgZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChbXFxcInZpZGVvXFxcIiwgXFxcImltYWdlXFxcIl0uaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgcGljX3VybCA9IGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHx8IHBpY191cmw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vUHJlI1xcXCIpLmxhenlSdWxlKChzaGFyZUlkLCBzaGFyZVB3ZCwgc2hhcmVUb2tlbiwgZmlsZUlkLCBjYXRlLCBzdWJ0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiaGlrZXI6Ly9wYWdlL2FsaWxhenlcXFwiKShzaGFyZUlkLCBzaGFyZVB3ZCwgc2hhcmVUb2tlbiwgZmlsZUlkLCBjYXRlLCBzdWJ0aXRsZSk7XFxuICAgICAgICAgICAgICAgIH0sIHNoYXJlSWQsIHNoYXJlUHdkLCBNWV9QQVJBTVMuc2hhcmVUb2tlbiwgZmlsZUl0ZW0uZmlsZV9pZCwgY2F0ZSwgc3VidGl0bGUpLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcjogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSW5mbzoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJZDogcGFnZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUl0ZW0uZmlsZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZUlkOiBzaGFyZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogbG9uZ2MsXFxuICAgICAgICAgICAgICAgICAgICBjbHM6IGNscyxcXG4gICAgICAgICAgICAgICAgICAgIC8vaW5oZXJpdFRpdGxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogZmlsZVN0eWxlXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgaWYgKGNvbnRzLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5LqG5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59XFxuXFxubGV0IGl0ZW1zID0gW107XFxudHJ5IHtcXG4gICAgaWYgKE1ZX1BBR0UgPiAxICYmICFNWV9QQVJBTVMubWFya2VyKSB7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInkuoblk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIGxvYWQoaXRlbXMpO1xcbiAgICB9XFxufSBjYXRjaCAoZSkge1xcbiAgICBpZiAoZS5uYW1lID09PSBcXFwiQWxpRXJyb3JcXFwiKSB7XFxuICAgICAgICBpZiAoZS5jb2RlID09PSBcXFwiSW52YWxpZFJlc291cmNlLlNoYXJlUHdkXFxcIikge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuivt+i+k+WFpeaPkOWPlueggVxcXCIsXFxuICAgICAgICAgICAgICAgIGRlc2M6IHNoYXJlUHdkID8gXFxcIuKAnOKAnOaPkOWPlueggemUmeivr+KAneKAnVxcXCIgOiBcXFwiXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKCkuaW5wdXQoKE1ZX1BBUkFNUykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0UGFnZVBhcmFtcyhPYmplY3QuYXNzaWduKHt9LCBNWV9QQVJBTVMsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0sIE1ZX1BBUkFNUyksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaWYgKGUuc2lnbmlmaWNhbmNlID09PSAxKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgZS5tZXNzYWdlLmJpZygpLmJpZygpLmZvbnRjb2xvcihcXFwicmVkXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMScsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZS5zaWduaWZpY2FuY2UgPT09IDMpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBlLm1lc3NhZ2UuYmlnKCkuZm9udGNvbG9yKFxcXCJncmVlblxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudGVyXzEnXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG5cXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIGxvZyhcXFwi5YiX6KGo5Yqg6L295aSx6LSlI1xcXFxu6ZSZ6K+v5L+h5oGvPlxcXCIgKyBlLnRvU3RyaW5nKCkgKyBcXFwiXFxcXG7plJnor6/ooYw+XFxcIiArIGUubGluZU51bWJlcik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogJ+asp+asp++8jOaKpemUmeS6huOAguWcqOWIt+aWsOWHoOasoe+8n+aIluiAheabtOaNouaWh+S7tuWkueOAgicsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgZGVzYzogZS50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uICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUoYWxpVG9rZW5zRmlsZXBhdGgsIEpTT04uc3RyaW5naWZ5KGFsaVRva2VuKSk7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcImxvZ2lueVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIueZu+W9leaIkOWKnyjngrnlh7vov5Tlm54pXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi55m75b2V5oiQ5YqfXFxcIiwgdHJ1ZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi55m75b2V5aSx6LSlLOivt+WwneivleWFtuS7lueahOaWueazlVxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHFyQ29kZVN0YXR1cyA9PT0gXFxcIkNBTkNFTEVEXFxcIikge1xcbiAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi5Y+W5raI55m75b2V5o6I5p2DXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKFtcXFwiTkV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hdGg7XFxuXFxuICAgIHZhciBqcyA9ICQudG9TdHJpbmcoKGlzUmVmcmVzaCwgYWxpVG9rZW5zRmlsZXBhdGgpID0+IHtcXG4gICAgICAgIHNldEludGVydmFsKCgpID0+IHtcXG4gICAgICAgICAgICB2YXIgdG9rZW4gPSBKU09OLnBhcnNlKGxvY2FsU3RvcmFnZS5nZXRJdGVtKCd0b2tlbicpKTtcXG4gICAgICAgICAgICBpZiAodG9rZW4gJiYgdG9rZW4udXNlcl9pZCkge1xcbiAgICAgICAgICAgICAgICBsZXQgdG9rZW5fdXJsID0gYWxpVG9rZW5zRmlsZXBhdGg7XFxuICAgICAgICAgICAgICAgIGZ5X2JyaWRnZV9hcHAud3JpdGVGaWxlKHRva2VuX3VybCwgSlNPTi5zdHJpbmdpZnkodG9rZW4pKTtcXG4gICAgICAgICAgICAgICAgbG9jYWxTdG9yYWdlLmNsZWFyKCk7XFxuICAgICAgICAgICAgICAgIGZ5X2JyaWRnZV9hcHAuYmFjayhpc1JlZnJlc2gpO1xcbiAgICAgICAgICAgICAgICBmeV9icmlkZ2VfYXBwLnRvYXN0KCdUT0tFTuiOt+WPluaIkOWKn++8jOivt+WLv+azhOa8j+S4quS6uumakOenge+8ge+8ge+8gScpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgMzAwKTtcXG4gICAgfSwgaXNSZWZyZXNoLCBhbGlUb2tlbnNGaWxlcGF0aCk7XFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgIGNvbF90eXBlOiAneDVfd2Vidmlld19zaW5nbGUnLFxcbiAgICAgICAgZGVzYzogJzEwMCUmJmZsb2F0JyxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgY2FuQmFjazogZmFsc2UsXFxuICAgICAgICAgICAganM6IGpzLFxcbiAgICAgICAgICAgIHVybEludGVyY2VwdG9yOiAkLnRvU3RyaW5nKCg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Lm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjJcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX3R2Ym94XFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiM1xcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfWEJZXFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiNFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfdHZcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCIwXFxcIjpcXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV9hbGlzdFxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB0aGlzLl9vcGVuVG9vbHMgPSBuZXcgT3BlbkFwaVRvb2xzKHRoaXMpO1xcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9vcGVuVG9vbHM7XFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgXFxcIm9wZW5Ub2tlbnNcXFwiLCB7XFxuICAgICAgICBnZXQoKSB7XFxuICAgIC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9yKChlcnIpID0+IHtcXG4gICAgICAgICAgICB0aHJvdyBlcnI7XFxuICAgICAgICB9KS5lcnJvclR5cGUoKGVyciwgcmVzKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IHt9O1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHJlc3VsdCA9IEpTT04ucGFyc2UocmVzLmJvZHkpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVycjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJib2R5ID0gKHJlc3VsdC5jb2RlID8gcmVzdWx0IDogKHJlc3VsdCAmJiByZXN1bHQucmVzcG9uc2VzICYmIHJlc3VsdC5yZXNwb25zZXNbMF0gJiYgcmVzdWx0LnJlc3BvbnNlc1swXS5ib2R5KSkgfHwge307XFxuICAgICAgICAgICAgaWYgKHJib2R5LmNvZGUpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IHJib2R5LmRpc3BsYXlfbWVzc2FnZSB8fCByYm9keS5tZXNzYWdlO1xcbiAgICAgICAgICAgICAgICBsZXQgZXJyb3IgPSBuZXcgRXJyb3IoYXBpICsgXFxcIj0+XFxcIiArIHJib2R5LmNvZGUgKyBcXFwiOlxcXCIgKyBtc2cpO1xcbiAgICAgICAgICAgICAgICBlcnJvci5jb2RlID0gcmJvZHkuY29kZTtcXG4gICAgICAgICAgICAgICAgZXJyb3IuanVkZ2VNc2cgPSBtc2c7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlcnJvcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGVycjtcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBzZXRNeURyaXZpZFR5cGUoaXNCYWNrdXApIHtcXG4gICAgICAgIHRoaXMubXlEcml2aWRUeXBlID0gISFpc0JhY2t1cDtcXG4gICAgICAgIHJldHVybiB0aGlz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LCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGUuY29kZSA9PT0gXFxcIlF1b3RhRXhoYXVzdGVkLkRyaXZlXFxcIikge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBlO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAoIXRoaXMudHJ5U29sdmUoZSkpIHtcXG4gICAgICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgYm9keSA9IGh0dHAub3B0aW9ucy5ib2R5LnJlcXVlc3RzWzBdLmJvZHk7XFxuICAgICAgICAgICAgaWYgKGJvZHkuZHJpdmVfaWQpIHtcXG4gICAgICAgICAgICAgICAgYm9keS5kcml2ZV9pZCA9IHRoaXMuZ2V0TXlEcml2aWQoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGJvZHkudG9fZHJpdmVfaWQpIHtcXG4gICAgICAgICAgICAgICAgYm9keS50b19kcml2ZV9pZCA9IHRoaXMuZ2V0TXlEcml2aWQoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgICAgICAneC1zaGFyZS10b2tlbic6IHRoaXMuc2hhcmVUb2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgIH0sXFxuICAgIGNvcHlGaWxlVG9DbG91ZEZpbGUoZmlsZUlkLCBwYXJlbnRGaW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AgICAgICAgICBlLmNvZGUgPSBib2R5LmNvZGU7XFxuICAgICAgICAgICAgdGhyb3cgZTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiByZXN1bHQucmVzcG9uc2VzWzBdLmJvZHkuZmlsZV9pZDtcXG4gICAgfSxcXG4gICAgb3BlbkNsb3VkRmlsZVRvRG93blVybChjbG91ZEZpbGVJZCkge1xcbiAgICAgICAgbGV0IGZpbGVJbmZvID0gdGhpcy5wb3N0QXBpKCdodHRwczovL29wZW4uYWxpeXVuZHJpdmUuY29tL2Fkcml2ZS92MS4wL29wZW5GaWxlL2dldERvd25sb2FkVXJsJykuYm9keSh7XFxuICAgICAgICAgICAgJ2ZpbGVfaWQnOiBjbG91ZEZpbGVJZCxcXG4gICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKClcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLm9wZW5Ub2tlbnMuQWNjZXNzVG9rZW5PcGVuXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgyLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIC8vdGhpcy53YWl0U2xlZXAoMzApLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDMwKS50cnlPcGVuQXBpU29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBo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FxcbiAgICAgICAgICAgICdkcml2ZV9pZCc6IHRoaXMuZ2V0TXlEcml2aWQoKSxcXG4gICAgICAgICAgICBcXFwiY2F0ZWdvcnlcXFwiOiBcXFwibGl2ZV90cmFuc2NvZGluZ1xcXCIsXFxuICAgICAgICAgICAgXFxcInRlbXBsYXRlX2lkXFxcIjogXFxcIlxcXCIsXFxuICAgICAgICAgICAgXFxcImdldF9zdWJ0aXRsZV9pbmZvXFxcIjogdHJ1ZSxcXG4gICAgICAgICAgICBcXFwidXJsX2V4cGlyZV9zZWNcXFwiOiAxNDQwMCxcXG4gICAgICAgICAgICBcXFwid2l0aF9wbGF5X2N1cnNvclxcXCI6IHRydWVcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLm9wZW5Ub2tlbnMuQWNjZXNzVG9rZW5PcGVuXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgyLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIC8vdGhpcy53YWl0U2xlZXAoMzApLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDMwKS50cnlPcGVuQXBpU29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMub3BlblRva2Vucy5BY2Nlc3NUb2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gICAgICAgICB0aGlzLndhaXRTbGVlcCgyMCkucmVmcmVzaEFjY2Vzc1Rva2VuKCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoNTApO1xcbiAgICAgICAgICAgIG5ld1NpZ24gPSBjYWxjdWxhdGVOZXdTaWduKCk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInB1YktleVxcXCI6IG5ld1NpZ24ucHViS2V5XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICAgICAgJ1gtU2hhcmUtVG9rZW4nOiB0aGlzLnNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICAneC1kZXZpY2UtaWQnOiB0aGlzLmFsaVRva2Vucy5kZXZpY2VfaWQsXFxuICAgICAgICAgICAgICAgICAgICAneC1zaWduYXR1cmUnOiBuZXdTaWduLnNpZ25hdHVyZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5lcnJvcigoZXJyLCByZXMpID0+IHtcXG4gICAgICAgICAgICByZXR1cm4ge307XFxuICAgICAgICB9KS5zdWNjZXNzKChib2R5KSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuIGJvZHk7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGlmIChyZXN1bHQuc3VjY2Vzcykge1xcbiAgICAgICAgICAgIHJldHVybiBuZXdTaWduO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAg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ldmljZS1pZCc6IHRoaXMuYWxpVG9rZW5zLmRldmljZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgICd4LXNpZ25hdHVyZSc6IHNpZ24uc2lnbmF0dXJlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgcmV0dXJuIGpzb24udmlkZW9fcHJldmlld19wbGF5X2luZm8ubGl2ZV90cmFuc2NvZGluZ190YXNrX2xpc3QucmV2ZXJzZSgpO1xcbiAgICB9LFxcbiAgICBnZXRNeURyaXZpZCgpIHtcXG4gICAgICAgIHJldHVybiAodGhpcy5teURyaXZpZFR5cGUgPyB0aGlzLmFsaVRva2Vucy5kZWZhdWx0X2RyaXZlX2lkIDogdGhpcy5hbGlUb2tlbnMucmVzb3VyY2VfZHJpdmVfaWQpIHx8IHRoaXMuZGVmRHJpdmVJZDtcXG4gICAgfSxcXG4gICAgZ2V0TGlzdEZpbGUoZmlsZUlkLCBtYXJrZXIsIG9yZGVyQnksIG9yZGVyRGlyZWN0aW9uKSB7XFxuICAgICAgICBsZXQgcmVzdWx0ID0gdGhpcy5wb3N0QXBpKFxcXCJodHRwczovL29wZW4uYWxpeXVuZHJpdmUuY29tL2Fkcml2ZS92MS4wL29wZW5GaWxlL2xpc3RcXFwiKS5ib2R5KHtcXG4gICAgICAgICAgICBcXFwiZHJpdmVfaWRcXFwiOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgXFxcInBhcmVudF9maWxlX2lkXFxcIjogZmlsZUlkIHx8IFxcXCJyb290XFxcIixcXG4gICAgICAgICAgICBcXFwibGltaXRcXFwiOiAxMDAsXFxuICAgICAgICAgICAgXFxcImFsbFxcXCI6IHRydWUsXFxuICAgICAgICAgICAgXFxcInVybF9leHBpcmVfc2VjXFxcIjogODY0MDAsXFxuICAgICAgICAgICAgXFxcImltYWd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wiICsgb3JkZXJEaXJlY3Rpb24sXFxuICAgICAgICAgICAgXFxcIm1hcmtlclxcXCI6IG1hcmtlciB8fCB1bmRlZmluZWRcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGtcXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KDIsIChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIC8vdGhpcy53YWl0U2xlZXAoMzApLnRyeU9wZW5BcGlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKHJlc3VsdCkubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgcmVzdWx0Lml0ZW1zID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gcmVzdWx0O1xcbiAgICB9LFxcbiAgICBzaWduSW5SZXdhcmQoKSB7X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dLmlzUmV3YXJkO1xcbiAgICAgICAgaWYgKGlzUmV3YXJkKSB7XFxuICAgICAgICAgICAgbGV0IHJld2FyZCA9IHNpbERhdGEucmVzdWx0LnNpZ25JbkxvZ3NbZGF5IC0gMV0ucmV3YXJkO1xcbiAgICAgICAgICAgIGlmIChyZXdhcmQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJld25vdGljZSA9IHJld2FyZC5ub3RpY2U7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwi5LuK5aSp5bey57uP562+5Yiw77yM6K+35LiN6KaB6YeN5aSN562+5Yiw77yBXFxcXG5cXFwiICsgcmV3bm90aWNlO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIC8v5rKh5pyJ5aWW5Yqx77yM5Y+q5pyJ5bm46L+Q562+5ZCN54mHXFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwi5LuK5aSp5bey57uP562+5Yiw77yM6K+35LiN6KaB6YeN5aSN562+5Yiw77yBXFxcXG7ku4rml6Xlpb3ov5Dnrb46XFxcIiArIHNpbERhdGEucmVzdWx0LmJsZXNzaW5nO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHNpckRhdGEgPSB0aGlzLnBvc3RBcGkoJ2h0dHBzOi8vbWVtYmVyLmFsaXl1bmRyaXZlLmNvbS92MS9hY3Rpdml0eS9zaWduX2luX3Jld2FyZCcpLmJvZHkoe1xcbiAgICAgICAgICAgICAgICBcXFwic2lnbkluRGF5XFxcIjogZGF5XFxuICAgICAgICAgICAgfSkuaGVhZGVycyh7XFxuICAgICAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICAnQ29udGVudC1UeXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nXFxuICAgICAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICAgICAg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dGlvbnMuYm9keSA9PT0gXFxcIm9iamVjdFxcXCIgJiYgdGhpcy5fYm9keVRvU3RyaW5nKSB7XFxuICAgICAgICAgICAgb3B0aW9ucy5ib2R5ID0gSlNPTi5zdHJpbmdpZnkob3B0aW9ucy5ib2R5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHZhciByZXMgPSBKU09OLnBhcnNlKHRoaXMuc3RhcnRSZXF1ZXN0KHRoaXMudXJsLCBvcHRpb25zKSk7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmIChyZXMuc3RhdHVzQ29kZSA+PSAyMDAgJiYgcmVzLnN0YXR1c0NvZGUgPD0gMzAwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBib2R5ID0gcmVzLmJvZHk7XFxuICAgICAgICAgICAgICAgIGlmICh0b0pzb24pIHtcXG4gICAgICAgICAgICAgICAgICAgIGJvZHkgPSBKU09OLnBhcnNlKGJvZHkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnN1Y2Nlc3NDYWxsYmFjayhib2R5LCByZXMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihTdHJpbmcocmVzLnN0YXR1c0NvZGUpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlcnIpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBlcnIgPSB0aGlzLmVycm9yVHlwZUNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmICh0aGlzLnJldHJ5Q291bnQpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHRyeVJlc3VsdCA9IHRoaXMuZXJyb3JDYWxsYmFja1dpdGhSZXRyeShlcnIsIHJlcywgdGhpcyk7XFxuICAgICAgICAgICAgICAgIGlmICh0cnlSZXN1bHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmV0cnlDb3VudC0tO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3RhcnQodG9Kc29uKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmV0cnlDb3VudCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lcnJvckNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmVycm9yQ2FsbGJhY2soZXJyLCByZXMpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgc2V0T3B0aW9ucyhvcHRpb25zKSB7XFxuICAgICAgICB0aGlzLm9wdGlvbnMgPSBPYmplY3QuYXNzaWduKHt9LCBvcHRpb25zLCB7XFxuICAgICAgICAgICAgd2l0aEhlYWRlcnM6IHRydWVcXG4gICAgICAgIH0pO1xcbiAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgIH0sXFxuICAgIG1lcmdlSGVhZEFuZEJvZHkob3B0aW9ucykge1xcbiAgICAgICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307XFxuICAgICAgICB0aGlzLm9wdGlvbnMuaGVhZGVycyA9IE9iamVjdC5hc3NpZ24odGhpcy5vcHRpb25zLmhlYWRlcnMsIG9wdGlvbnMuaGVhZGVycyk7XFxuICAgICAgICBpZiAodHlwZW9mIHRoaXMub3B0aW9ucy5ib2R5ID09PSBcXFwib2JqZWN0XFxcIiAmJiB0eXBlb2Ygb3B0aW9ucy5ib2R5ID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgIHRoaXMub3B0aW9ucy5ib2R5ID0gT2JqZWN0LmFzc2lnbih0aGlzLm9wd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AgIH0pKSk7XFxuICAgIGxldCBkTWNvbnRleHQgPSBcXFwiXFxcIjtcXG4gICAgLy9sZXQgZnBzbSA9IGdldFJlZnJlc2hSYXRlKCkvNjAqMC45NTtcXG4gICAgLy9kYW5NdURhdGEuY29tbWVudHMuc29ydCgodix4KT0+di5wLnNwbGl0KFxcXCIsXFxcIilbMF0teC5wLnNwbGl0KFxcXCIsXFxcIilbMF0pO1xcbiAgICBmb3IgKGxldCBjb21tZW50IG9mIGRhbk11RGF0YS5jb21tZW50cykge1xcbiAgICAgICAgLy9kTWNvbnRleHQgKz0gYDxkIHA9XFxcIiR7TWF0aC5yb3VuZCh0aW1lcG9pbnQpfSwke2N0fSwke3NpemV9LCR7Y29sb3J9LDBcXFwiPiR7Y29udGVudH08L2Q+XFxcXG5gO1xcbiAgICAgICAgbGV0IHBhcmFtVGV4dCA9IGNvbW1lbnQucDtcXG4gICAgICAgIGxldCBjb21tZW50VGV4dCA9IGNvbW1lbnQubTtcXG4gICAgICAgIGlmIChwYXJhbVRleHQgPT0gbnVsbCB8fCBjb21tZW50VGV4dCA9PSBudWxsKSBjb250aW51ZTtcXG4gICAgICAgIGxldCBwYXJhbXMgPSBwYXJhbVRleHQuc3BsaXQoXFxcIixcXFwiKTtcXG4gICAgICAgIGxldCBwYXJhbXNUID0gW107XFxuICAgICAgICBmb3IgKGxldCBpIGluIHBhcmFtcykge1xcbiAgICAgICAgICAgIC8qaWYgKGkgPT0gMCkge1xcbiAgICAgICAgICAgICAgICBwYXJhbXNULnB1c2gocGFyc2VJbnQocGFyYW1zW2ldKSk7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgIGlmIChpID09IDIpIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIyNVxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgICAgIC8v6aKc6Imy5YC85Li6MOaXtu+8jOm7mOiupOiuvue9ruS4uueZveiJslxcbiAgICAgICAgICAgICAgICBpZiAocGFyYW1zW2ldID09IFxcXCIwXFxcIiB8fCBwYXJhbXNbaV0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIxNjc3NzIxNVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWVcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcGFyYW1zVC5wdXNoKHBhcmFtc1tpXSk7XFxuICAgICAgICB9XFxuICAgICAgICBwYXJhbXNULnB1c2goXFxcIjBcXFwiKTtcXG4gICAgICAgIGxldCB0aW1lcz1wYXJzZUludChwYXJhbXNbMF0vNjApK1xcXCI6XFxcIitwYXJzZUludChwYXJhbXNbMF0lNjApO1xcbiAgICAgICAgZE1jb250ZXh0ICs9IGA8ZCBwPVxcXCIke3BhcmFtc1Quam9pbignLCcpfVxcXCI+JHtlbmNvZGVIdG1sKGNvbW1lbnRUZXh0KStcXFwiI1xcXCIrdGltZXN9PC9kPlxcXFxuYDtcXG4gICAgfVxcbiAgICBpZiAoIWRNY29udGV4dCkgcmV0dXJuO1xcbiAgICBkTWNvbnRleHQgPSBgPD94bWwgdmVyc2lvbj1cXFwiMS4wXFxcIiBlbmNvZGluZz1cXFwiVVRGLThcXFwiPz48aT5cXFxcbiR7ZE1jb250ZXh0fTwvaT5gO1xcbiAgICBsZXQgcGF0aCA9IHNldmVQYXRoICsgbmFtZS5yZXBsYWNlKC9cXFxcLy9nLCBcXFwiX1xcXCIpICsgXFxcIl9cXFwiICsgZXBpc29kZUlkICsgXFxcIi54bWxcXFwiO1xcbiAgICB3cml0ZUZpbGUocGF0aCwgZE1jb250ZXh0KTtcXG4gICAgcmV0dXJuIHBhdGg7XFxufVxcbiQuZXhwb3J0cy5nZX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cXG4gICAgdGl0bGU6IFxcXCLlhoXnva7mkJzntKJQXFxcIixcXG4gICAgdXJsOiAkKGtleSwgXFxcIuivt+aQnOe0oueVquWJp+WQjeensFxcXCIpLmlucHV0KChNWV9QQVJBTVMpID0+IHtcXG4gICAgICAgIHNldFBhZ2VQYXJhbXMoT2JqZWN0LmFzc2lnbihNWV9QQVJBTVMsIHtcXG4gICAgICAgICAgICBuYW1lOiBpbnB1dCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgIH0sIE1ZX1BBUkFNUyksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YaF572u5pCc57SiVFxcXCIsXFxuICAgIHVybDogJChrZXksIFxcXCLmoLzlvI/vvJrmkJzntKLlhbPplK7or41b5Zue6L2mXembhuaVsFxcXCIpLmlucHV0KChvbmx5RG93bmxvYWQpID0+IHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOaQnOe0ouW5tuS4i+i9vS4uLlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBbbmFtZSwgcG9zXSA9IGlucHV0LnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGlmICghbmFtZSB8fCAhcG9zKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IFxcXCLmoLzlvI/plJnor69cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgdXJsSW5mbyA9IGZldGNoKGJ1aWxkVXJsKFxcXCJodHRwczovL2F6dXJlLmxldXNlLnRvcC9zZWFyY2hkbVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwibmFtZVxcXCI6IG5hbWUsXFxuICAgICAgICAgICAgICAgICAgICBcXFwicG9zXFxcIjogcG9zXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgdXJsSW5mbyA9IEpTT04ucGFyc2UodXJsSW5mbyk7XFxuICAgICAgICAgICAgaWYgKCF1cmxJbmZvLnVybCkgdGhyb3cgXFxcIuaaguaXtuayoeacieaJvuWIsOivpeinhumikeeahOW8ueW5lVxcXCI7XFxuICAgICAgICAgICAgbGV0IHhtbCA9IGZldGNoKGJ1aWxkVXJsKFxcXCJodHRwczovL2F6dXJlLmxldXNlLnRvcC9kYW5tdVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zOiB1cmxJbmZvXFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgaWYgKCF4bWwpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgXFxcIui/mOayoeacieW8ueW5leWTn35cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGF0aCA9IFxcXCJoaWtlcjovL2ZpbGVzL2NhY2hlL2Rhbm11L1xcXCIgKyB1cmxJbmZvLnBsYXRmb3JtICsgXFxcIl9cXFwiICsgbmFtZSArIFxcXCJfXFxcIiArIHBvcyArIFxcXCIueG1sXFxcIjtcXG4gICAgICAgICAgICB3cml0ZUZpbGUocGF0aCwgJzw/eG1sIHZlcnNpb249XFxcIjEuMFxcXCIgZW5jb2Rpbmc9XFxcIlVURi04XFxcIj8+XFxcXG4nICsgeG1sKTtcXG4gICAgICAgICAgICBpZiAob25seURvd25sb2FkKSByZXR1cm4gXFxcInRvYXN0Oi8v5LiL6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICByZWZyZXNoVmlkZW9Vcmwoe1xcbiAgICAgICAgICAgICAgICBkYW5tdTogcGF0aFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9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gTnVtYmVyLmlzTmFOKGIpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K+35oyJ5qC85byP6L6T5YWl5pWw5a2XXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoYSA8IDEgfHwgYiA+IGVwaXNvZGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeinhOWumuiMg+WbtOWGheeahOaVsOWtl1xcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gYSAtIDEsIGogPSAxOyBpIDwgYjsgaSsrLCBqKyspIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZXBpc29kZSA9IGVwaXNvZGVzW2ldO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkbVRpdGxlID0gYW5pbWVUaXRsZSArIFxcXCJfXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjkuIvovb3vvJpcXFwiICsgZXBpc29kZS5lcGlzb2RlVGl0bGUgKyBcXFwiXFxcXHQoXFxcIiArIGogKyBcXFwiL1xcXCIgKyAoYiAtIGEgKyAxKSArIFxcXCIpXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGFubXUuZG93bmxvYWREYW5NdShlcGlzb2RlLmVwaXNvZGVJZCwgZG1UaXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhlLnRvU3R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HwgZGFubXUuZG93bmxvYWREYW5NdShpbnB1dCwgdGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKG9ubHlEb3dubG9hZCkgcmV0dXJuIFxcXCJ0b2FzdDovL+S4i+i9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGFubXVUZXh0ID0gZmV0Y2gocGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWRhbm11VGV4dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+i/mOayoeacieW8ueW5leWTn35cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFZpZGVvVXJsKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkYW5tdTogcGF0aFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liqDovb3lrozmiJBcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBNWV9QQVJBTVMuZHVybCwgZG1UaXRsZSwgb25seURvd25sb2FkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5by65Yi25LiL6L29XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoZXBpc29kZVRpdGxlLCBlcGlzb2RlSWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuivt+etieW+hVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGFubXUuZG93bmxvYWREYW5NdShlcGlzb2RlSWQsIGVwaXNvZGVUaXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/ph43mlrDkuIvovb3lrozmiJDvvIzljZXlh7vmjILovb3jgIJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGRtVGl0bGUsIGVwaXNvZGUuZXBpc29kZUlkKVxcbiAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVfYmxhbmtcXFwiXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBpZiAoIWRtTGlzdC5hbmltZXMubGVuZ3RoKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5rKh5pyJ5om+5Yiw5LiOW1xcXCIgKyBuYW1lICsgXFxcIl3nm7jlhbPnmoTlvLnluZVcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGRlc2M6IFxcXCLmkJzkuI3liLDmgI7kuYjlip7vvJ9cXFxcbuajgOafpeWQjeensOaYr+WQpuato+ehru+8m+WPr+S7peWwneivleWIoOmZpOmDqOWIhumZkOWumuivje+8jOWmguesrOS4gOWto+etie+8m+iAjOS4lOWPquiDveaQnOe0oueVquWJp+WTpu+8geWFtuS7luW8ueW5leWPr+eUqGRt55uS5a2Q44CCXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5sZX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6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJzaGFyZV9pZFxcXCI6IHNoYXJlSWRcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgaWYgKHNoYXJlLmluY2x1ZGVzKFxcXCJzaGFyZV9saW5rIGlzXFxcIikgfHwgc2hhcmUuaW5jbHVkZXMoXFxcInNoYXJlX2xpbmsgY2Fubm90XFxcIikpIHJldHVybiBmYWxzZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgIH0sXFxuICAgIGJ5dGVzVG9TaXplKHNpemUpIHtcXG4gICAgICAgIGlmICghc2l6ZSkge1xcbiAgICAgICAgICAgIHJldHVybiAnMCc7XFxuICAgICAgICB9XFxuICAgICAgICBjb25zdCB1bml0cyA9IFsnQicsICdLQicsICdNQicsICdHQicsICdUQicsICdQQicsICdFQicsICdaQicsICdZQiddO1xcbiAgICAgICAgbGV0IGkgPSAwO1xcbiAgICAgICAgd2hpbGUgKHNpemUgPj0gMTAyNCkge1xcbiAgICAgICAgICAgIHNpemUgLz0gMTAyNDtcXG4gICAgICAgICAgICBpKys7XFxuICAgICAgICB9XFxuICAgICAgICBzaXplID0gaSA/IE51bWJlcihzaXplLnRvRml4ZWQoMikpIDogc2l6ZTtcXG4gICAgICAgIHJldHVybiBgJHtzaXplfSAke3VuaXRzW2ldfWA7XFxuICAgIH0sXFxuICAgIGdldENyeXB0b0pTKCkge1xcbiAgICAgICAgaWYgKHR5cGVvZiBDcnlwdG9KUyA9PT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICBldmFsKGdldENyeXB0b0pTKCkpO1xcbiAgICAgICAgICAgIHJldHVybiBDcnlwdG9KUztcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBDcnlwdG9KUztcXG4gICAgfSxcXG4gICAgbWF0Y2hBbGlVcmwodGV4dCwgaXNHKSB7XFxuICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJhbGl0ZXN0XFxcIikubWF0Y2hBbGlVcmwodGV4dCwgaXNHKTtcXG4gICAgfSxcXG4gICAgZ2V0SVB2NEFkZHJlc3MoKSB7XFxuICAgICAgICBjb25zdCBOZXR3b3JrSW50ZXJmYWNlID0gamF2YS5uZXQuTmV0d29ya0ludGVyZmFjZTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgZW4gPSBOZXR3b3JrSW50ZXJmYWNlLmdldE5ldHdvcmtJbnRlcmZhY2VzKCk7IGVuLmhhc01vcmVFbGVtZW50cygpOykge1xcbiAgICAgICAgICAgICAgICBsZXQgaW50ZiA9IGVuLm5leHRFbGVtZW50KCk7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGVudW1JcEFkZHIgPSBpbnRmLmdldEluZXRBZGRyZXNzZXMoKTsgZW51bUlwQWRkci5oYXNNb3JlRWxlbWVudHMoKTspIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbmV0QWRkcmVzcyA9IGVudW1JcEFkZHIubmV4dEVsZW1lbnQoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghaW5ldEFkZHJlc3MuaXNMb29wYmFja0FkZHJlc3MoKSAmJiBpbmV0QWRkcmVzcyBpbnN0YW5jZW9mIGphdmEubmV0LkluZXQ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HMoXFxcInZcXFwiICsgcGFnZUlkKTtcXG4gICAgaWYgKCFBcnJheS5pc0FycmF5KGxpc3QpIHx8IGxpc3QubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAvKnRvYXN0KFxcXCLov5jmsqHmnInliqDovb3lrozmiJDnmoTop4bpopFcXFwiKTtcXG4gICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgcmV0dXJuOyovXFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ov5jmnKjmnInop4bpopHlk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBhbGwudXJsID0gXFxcInRvYXN0Oi8v5rKh5pyJ6KeG6aKR5peg5rOV5o6o6YCBXFxcIjtcXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIGxpc3QuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICB2LmNvbF90eXBlID0gdi50eXBlO1xcbiAgICAgICAgICAgIGxldCBuYW1lID0gdi5leHRyYS5wYWdlVGl0bGU7XFxuICAgICAgICAgICAgbGV0IHVybCA9IG5hbWUucmVwbGFjZSgvXFxcXCMvZywgJ18nKS5yZXBsYWNlKC9cXFxcJC9nLCAnXycpICsgXFxcIiR2aWRlb3xcXFwiICsgdi5leHRyYS5pZDtcXG4gICAgICAgICAgICBhbGxVcmxzLnB1c2godXJsKTtcXG4gICAgICAgICAgICB2LnVybCA9IGdldFB1c2gobmFtZSwgdXJsK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1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcbiAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChsZW5ndGgsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzkupHnroDmkJzntKLlvJXmk47vvIzlhbHjgIxcXFwiICsgbGVuZ3RoICsgXFxcIuOAjeadoe+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKGdldFBhc3RlcygpLmluY2x1ZGVzKGlucHV0KSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGVzLmxlbmd0aCwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvcnVsZXMvTG95RGdJay9zaGFyZS/kupHnroDmkJzntKLlvJXmk47op4TliJnjgIxcXFwiICsgcnVsZXMubGVuZ3RoICsgXFxcIuOAjeadoS5cXFwiICsgKGlucHV0ID09PSBcXFwiSElLRVJcXFwiID8gXFxcImhpa2VyXFxcIiA6IFxcXCJ0eHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCBnZXRQYXNzKHJ1bGVzLmxlbmd0aCwgcnVsZWI2NCwgXFxcImFcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInNoYXJlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJ1bGVzO1xcbiAgICAgICAgICAgIGlmIChtbyA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTIpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRVc2VmdWxKc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTMpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRGb3JiaWRkZW5Kc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gZXh0O1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEdyb3VwSnNvbihleHQpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGVzLmxlbmd0aCkgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWtmOWcqOivpee7hFxcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCkuZmlsdGVyKCh2LCBpKSA9PiBpbmRleHMuaW5jbHVkZXMoaSkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBydWxlcyA9IHJ1bGVzLm1hcCgodikgPT4ge1xcbiAgICAgICAgICAgICAgICB2LnVzZXIgPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHYuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdXAocnVsZXMpO1xcbiAgICAgICAgfSwgbW8sIGluZGV4cywgaW5kZXhjWzFdKTtcXG5cXG4gICAgfSw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KSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogaXQgPT09IGdyb3VwID8gXFxcIuKAnOKAnFxcXCIgKyBpdCArIFxcXCLigJ3igJ1cXFwiIDogaXQsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGl0LCBncm91cCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChncm91cCAhPT0gaXQpIHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIsIGl0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIue9rumhtlxcXCIsIFxcXCLnva7lupVcXFwiLCBcXFwi5pS55ZCNXFxcIiwgXFxcIuWIoOmZpFxcXCJdKS5zZWxlY3QoKGl0KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoXFxcIuaUueWQjVxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXQsIFxcXCLor7fovpPlhaXmlrDlkI3np7BcXFwiKS5pbnB1dCgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ID09PSB2Lmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdi5ncm91cCA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoXFxcIuWIoOmZpFxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuaYr+WQpuWIoOmZpOivpee7hOaQnOe0ouW8leaTju+8mlxcXCIgKyBpdCkuY29uZmlybSgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcyA9IHJ1bGVzLmZpbHRlcih2ID0+IHYuZ3JvdXAgIT09IGl0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB0Z1J1bGVzID0gW10sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcyA9IFtdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuZm9yRWFjaCgodikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdCA9PT0gdi5ncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0Z1J1bGVzLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcy5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRnUnVsZXMgPSB0Z1J1bGVzLmNvbmNhdCh0eFJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGdSdWxlcyA9IHR4UnVsZXMuY29uY2F0KHRnUnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24odGdSdWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICB9LCBpdCwgZ3JvdXApLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIlxcbiAgICB9KTtcXG59XFxuXFxubGV0IGNvdW50ID0gZC5sZW5ndGg7XFxu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nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuWujOaVtOWPo+S7pFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHJ1bGViNjQsIFxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGlmIChncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgbmV3SW5kZXggPSBydWxlcy5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgICAgICBuZXdJbmRleCA9IG5ld0luZGV4ID09PSAtMSA/IDAgOiBuZXdJbmRleDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gIXJ1bGUuZm9yYmlkZGVuO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL1xcXCIgKyAocnVsZS5mb3JiaWRkZW4gPyBcXFwi56aB55SoXFxcIiA6IFxcXCLlkK/nlKhcXFwiKSArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LCBpLC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BnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgZmluZCA9IGdldE15VmFyKFxcXCJwc19maW5kXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmICghZmluZCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pCc57Si6KeE5YiZ5LiN6IO95Li656m6XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgdGVzdFJ1bGUgPSB7XFxuICAgICAgICAgICAgICAgIG5hbWU6IG5hbWUsXFxuICAgICAgICAgICAgICAgIGZpbmQ6IGZpbmQsXFxuICAgICAgICAgICAgICAgIGJhc2ljVXJsOiBnZXRNeVZhcihcXFwicHNfYmFzaWNVcmxcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgICAgIGZpbmRBbGlVcmw6IGdldE15VmFyKFxcXCJwc19maW5kQWxpVXJsXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgICAgICAgICBwYWdlOiAhIWdldE15VmFyKFxcXCJwc19wYWdlXFxcIiwgcGFnZSA/IFxcXCIxXFxcIiA6IFxcXCJcXFwiKSxcXG4gICAgICAgICAgICAgICAgcnVsZVR5cGU6IGdldE15VmFyKFxcXCJwc19ydWxlVHlwZVxcXCIsIFxcXCJcXFwiKSxcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJoaWtlcjovL2VtcHR5I25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5Iz9meXBhZ2VcXFwiKS5ydWxlKCh0ZXN0UnVsZSwga2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChNWV9QQUdFID4gMSAmJiAhdGVzdFJ1bGUucGFnZSkgc2V0UmVzdWx0KFtdKTtcXG4gICAgICAgICAgICAgICAgc2V0UmVzdWx0KCQucmVxdWlyZShcXFwiZGF0YVxcXCIpLmNhcnJ5UnVsZSh0ZXN0UnVsZSwga2V5LCBNWV9QQUdFLCAwKSk7XFxuICAgICAgICAgICAgfSwgdGVzdFJ1bGUsIGlucHV0KTtcXG4gICAgICAgIH0sIHBhZ2UpO1xcbiAgICB9LCBvYmoucGFnZSksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIHBhZ2UsIGlzSW1wb3J0KSA9PiB7XFxuICAgICAgICBsZXQgbmFtZSA9IGdldE15VmFyKFxcXCJwc19uYW1lXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFuYW1lKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WQjeWtl+W+l+acieS4gOS4quWQp1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmluZCA9IGdldE15VmFyKFxcXCJwc19maW5kXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmaW5kKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aQnOe0ouinhOWImeS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG9iajEgPSB7XFxuICAgICAgICAgICAgbmFtZTogbmFtZSxcXG4gICAgICAgICAgICBhdXRob3I6IGdldE15VmFyKFxcXCJwc19hdXRob3JcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgZmluZDogZmluZCxcXG4gICAgICAgICAgICBiYXNpY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AgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeinhOWImVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgb2JqMSk7XFxuICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgb2JqMSk7XFxuICAgICAgICB9XFxuICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv53lrZjmiJDlip9cXFwiO1xcbiAgICB9LCBpbmRleCwgb2JqLnBhZ2UsIGlzSW1wb3J0KSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbn0pO1xcblxcbnNldFJlc3V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cXCJ4NV93ZWJ2aWV3X3NpbmdsZVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6cmVnaXN0ZXJVcmwsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOlxcXCJmbG9hdCYmMTAwJVxcXCJcXG4gICAgICAgICAgICAgICAgfV0pO1xcbiAgICAgICAgICAgIH0sIHJlZ2lzdGVyVXJsKSxcXG4gICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogXFxcIuazqOWGjOi0puWPtzpcXFwiICsgb2JqLm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBvYmogPSBvYmoudXNlciB8fCB7fTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIueUqOaIt+WQjVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouYWNjb3VudCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogXFxcInBhc3N3b3JkXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19wYXNzd29yZFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5wYXNzd29yZCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIumineWkllxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHR5cGU6IFxcXCJ0ZXh0YXJlYVxcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfZXh0cmFcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouZXh0cmEsXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICBoZWlnaHQ6IC0xXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBhY2NvdW50ID0gZ2V0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IHBhc3N3b3JkID0gZ2V0TXlWYXIoXFxcInBzX3Bhc3N3b3JkXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBleHRyYSA9IGdldE15VmFyKFxcXCJwc19leHRyYVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAvKmlmICghKGFjY291bnR8fHBhc3N3b3JkfHxleHRyYSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveWFqOmDqOS4uuepulxcXCI7XFxuICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgaXRlbSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgaXRlbS51c2VyID0ge307XFxuICAgICAgICAgICAgaXRlbS51c2VyLmFjY291bnQgPSBhY2NvdW50XFxuICAgICAgICAgICAgaXRlbS51c2VyLnBhc3N3b3JkID0gcGFzc3dvcmQ7XFxuICAgICAgICAgICAgaXRlbS51c2VyLmV4dHJhID0gZXh0cmE7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9pZOmUmeivr1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgaXRlbSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+d5a2Y5oiQ5YqfXFxcIjtcXG4gICAgICAgIH0sIGluZGV4KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgIH0pO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxufSkoKVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi6KeE5YiZ5a+85YWlXCIsXCJwYXRoXCI6XCJpbXBvcnRcIixcInJ1bGVcIjpcImpzOlxcbmZ1bmN0aW9uIHNhdm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XG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZy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gICAgICAgICAgIGxldCBqc29uID0gcG9zdChiYXNpY1VybCArIGFwaSwge1xcbiAgICAgICAgICAgICAgICBib2R5OiBcXFwiZGF0YT1cXFwiICsgYXBpLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBSZWZlcmVyOiBcXFwiaHR0cHM6Ly93d3cueXVuc28ubmV0L2luZGV4L3VzZXIvcz93ZD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHMpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IEpTT04ucGFyc2UoanNvbikuZGF0YTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHBkZmEoaHRtbCwgXFxcImJvZHkmJi5sYXl1aS1jYXJkOmhhcyhhKVxcXCIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaXRlbSBvZiBsaXN0KSB7XFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IHBkZmgoaXRlbSwgXFxcImEmJlRleHRcXFwiKS5yZXBsYWNlKFxcXCIj5paH5Lu25aS5IFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgLy9sZXQgdGltZSA9IC9cXFxcZHs0fSgtXFxcXGR7Mn0pezJ9IFxcXFxkezJ9KFxcXFw6XFxcXGR7Mn0pezJ9Ly5leGVjKHBkZmgoaXRlbSwgXFxcIi5sYXl1aS1jYXJkLWJvZHkmJlRleHRcXFwiKSkgfHwgW107XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAvL2Rlc2M6IHRpbWVbMF0sXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGJhc2U2NERlY29kZShwZGZoKGl0ZW0sIFxcXCJhJiZ1cmxcXFwiKSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi5re35ZCI55uYXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLmh1bmhlcGFuLmNvbS92MS9zZWFyY2hcXFwiO1xcbiAgICAgICAgICAgIGxldCBqc29uID0gcG9zdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgUmVmZXJlcjogXFxcImh0dHBzOi8vaHVuaGVwYW4uY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInFcXFwiOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VcXFwiOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInNpemVcXFwiOiAxNVxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKGpzb24pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5kYXRhLmxpc3Q7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmRpc2tfdHlwZSAhPT0gXFxcIkFMWVxcXCIgfHwgaXQuc2hhcmVfdXNlciA9PT0gXFxcIuS4tioqKuS4tlxcXCIpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LmRpc2tfbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBkKGl0LCBcXFwiaW1nJiZzcmNcXFwiLCB1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpdC5saW5rLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudXBkYXRlX3RpbWUgKyBcXFwiXFxcXG5cXFwiICsgaXQubGluayxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi6LWE5rqQ5biuXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBzZWFyY2goKSB7XFxuICAgICAgICAgICAgICAgIGxldCBydG5MaXN0ID0gW107XFxuICAgICAgICAgICAgICAgIGxldCByZXNwID0gcmVxdWVzdChcXFwiaHR0cHM6Ly96eWIudXB5dW5zby5jb20vdjE1L3NlYXJjaD9rZXl3b3JkPVxcXCIgKyBlbl9hZXMocykgKyBcXFwiJnNfdHlwZT0yJnBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiJmF0az0mZGlkPVxcXCIgKyBnZW5lcmF0ZVJhbmRvbUhleFN0cmluZyg2NCksIHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwidXNlci1hZ2VudFxcXCI6IFxcXCJNb3ppbGxhLzUuMCAoTGludXg7IEFuZHJvaWQgMTA7IFJlZG1pIE5vdGUgNyBCdWlsZC9RS1ExLjE5MDkxMC4wMDI7IHd2KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBWZXJzaW9uLzQuMCBDaHJvbWUvODEuMC40MDQ0LjEzOCBNb2JpbGUgU2FmYXJpLzUzNy4zNiB1bmktYXBwIEh0bWw1UGx1cy8xLjAgKEltbWVyc2VkLzI5LjA5MDkxKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3BEYXRhID0gZGVfYWVzKHJlc3ApO1xcbiAgICAgICAgICAgICAgICBsZXQganNvbkRhdGEgPSBKU09OLnBhcnNlKHJlc3BEYXRhKSB8fCB7fTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IGpzb25EYXRhLnJlc3VsdCB8fCB7fTtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gcmVzdWx0Lml0ZW1zIHx8IFtdO1xcblxcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGl0ZW1zLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGl0ZW1zW2ldO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSBpdGVtLmNvbnRlbnQgfHwgW107XFxuICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudC5sZW5ndGggPT0gMCB8fCAhaXRlbS5wYWdlX3VybCkgY29udGludWU7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdXJsID0gZGVfYWVzKGl0ZW0ucGFnZV91cmwpIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF1cmwpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICAgICAgcnRuTGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogKGl0ZW0udGl0bGUubGVuZ3RoID4gMzAgPyBpdGVtLnRpdGxlLnNsaWNlKDAsIDI3KSArIFxcXCIuLi5cXFwiIDogaXRlbS50aXRsZSkgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIuWIhuS6q+aXtumXtO+8mlxcXCIgKyBpdGVtLmluc2VydF90aW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICByZXR1cm4gcnRuTGlzdDtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJhdGVSYW5kb21IZXhTdHJpbmcobGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVycyA9IFxcXCIwMTIzNDU2Nzg5YWJjZGVmXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVyc0xlbmd0aCA9IGNoYXJhY3RlcnMubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gY2hhcmFjdGVycy5jaGFyQXQoTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogY2hhcmFjdGVyc0xlbmd0aCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGVuX2FlcyhlKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gXFxcInFxMTkyMDUyMDQ2MHFxenpcXFwiO1xcbiAgICAgICAgICAgICAgICAvLyBlbl9hZXNcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGkpO1xcbiAgICAgICAgICAgICAgICB2YXIgdCA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGUpLFxcbiAgICAgICAgICAgICAgICAgICAgciA9IENyeXB0b0pTLkFFUy5lbmNyeXB0KHQsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHIuY2lwaGVydGV4dC50b1N0cmluZygpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBkZV9hZXModnYpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBcXFwicXExOTIwNTIwNDYwcXF6elxcXCI7XFxuICAgICAgICAgICAgICAgIC8vIGRlX2Flc1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoaSk7XFxuICAgICAgICAgICAgICAgIGxldCBoZXhWYWwgPSBDcnlwdG9KUy5lbmMuSGV4LnBhcnNlKHZ2KSxcXG4gICAgICAgICAgICAgICAgICAgIHZhbCA9IENyeXB0b0pTLmVuYy5CYXNlNjQuc3RyaW5naWZ5KGhleFZhbCksXFxuICAgICAgICAgICAgICAgICAgICBkZWNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdCh2YWwsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGRlY3J5cHRlZC50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBzZWFyY2goKTtcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgbmFtZTogXFxcIuS6keebmOi1hOa6kFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9yZXMueXVucGFuLndpbi8/UGFnZUluZGV4PVxcXCIgKyBwYWdlICsgXFxcIiZQYWdlU2l6ZT0xMiZLZXl3b3JkPVxcXCIgKyBzICsgXFxcIiZUeXBlPSZUYWc9XFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vcmVzLnl1bnBhbi53aW4vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIm1haW4mJi5jYXJkXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZGZoKGl0LCBcXFwiLmNhcmQtbGluaywxJiZvbmNsaWNrXFxcIikubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgICAgIHUgPSB1Lmxlbmd0aCA+IDAgPyB1WzBdIDogdXJsO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCIuY2FyZC10aXRsZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGQoaXQsIFxcXCJpbWcmJnNyY1xcXCIsIHVybCksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwZGZoKGl0LCBcXFwiLmNhcmQtdGV4dCwtMSYmVGV4dFxcXCIpICsgXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIlVQ5LqR5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS51cHl1bnNvMi5jb20vc2VhcmNoP2tleXdvcmQ9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiJnNfdHlwZT0xXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LnVweXVuc28uY29tXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBcXFwiY29kZT0xOTE5XFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coYmFzZTY0RGVjb2RlKGh0bWwpKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUoaHRtbCkpLnJlc3VsdC5pdGVtcztcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgaWYgKCFhcnIpIHJldHVybiBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gaXQucGFnZV91cmw7XFxuICAgICAgICAgICAgICAgIC8vdSA9IHUubGVuZ3RoID4gMCA/IHVbMF0gOiB1cmw7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIueMq+eLuOebmOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb20vc2VhcmNoP2s9XFxcIiArIHMsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbS9zZWFyY2g/az1cXFwiICsgc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIiNhcHAmJmFcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gXFxcIjxkaXY+XFxcIiArIGFycltpXSArIFxcXCI8L2Rpdj5cXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkZmgoaXQsIFxcXCJhJiZocmVmXFxcIik7XFxuICAgICAgICAgICAgICAgIC8vbG9nKHUpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcIi9zL1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB1ID0gXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb21cXFwiICsgdS5yZXBsYWNlKFxcXCIvcy9cXFwiLCBcXFwiL2N2L1xcXCIpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCJ0ZW1wbGF0ZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGRmaChpdCwgXFxcInRlbXBsYXRlLDEmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IFxcXCJub19zaG93X2RvbmF0ZT0xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogaW5wdXQucmVwbGFjZShcXFwiL2N2L1xcXCIsIFxcXCIvcy9cXFwiKVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICByZWRpcmVjdDogZmFsc2VcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBodG1sID0gcGFyc2VEb21Gb3JIdG1sKGh0bWwsICdhJiZocmVmJyk7XFxuICAgICAgICAgICAgaWYgKGh0bWwubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaHRtbDtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5piT5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICByZWdpc3RlclVybDogXFxcImh0dHBzOi8veWlzby5mdW5cXFwiLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGtleWVuKHN0cikge1xcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjRPVG9TY1VGT2FlVlRySEVcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIGl2ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjlDTEdhbzF2SEtxbTE3T3pcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGVuY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHtcXG4gICAgICAgICAgICAgICAgICAgIGNpcGhlcnRleHQ6IENyeXB0b0pTLmVuYy5CYXNlNjQucGFyc2Uoc3RyKVxcbiAgICAgICAgICAgICAgICB9LCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBpdixcXG4gICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgcGFkZGluZzogQ3J5cHRvSlMucGFkLlBrY3M3XFxuICAgICAgICAgICAgICAgIH0pLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVuY3J5cHRlZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coaHRtbCk7XFxuICAgICAgICAgICAgaWYgKGh0bWwuaW5jbHVkZXMoJ+eZu+W9leeUqOaIt+aXoOmZkOWIticpKSB7XFxuICAgICAgICAgICAgICAgIHZhciBpID0gMDtcXG4gICAgICAgICAgICAgICAgZG8ge1xcbiAgICAgICAgICAgICAgICAgICAgdmFyIHR5aW1nbGluID0gJ2h0dHBzOi8veWlzby5mdW4vYXBpL3VzZXIvbG9naW4vY2FwdGNoYT90PScgKyBwYXJzZUludChuZXcgRGF0ZSgpLmdldFRpbWUoKSkgKyAnJztcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbWcgPSBjb252ZXJ0QmFzZTY0SW1hZ2UodHlpbWdsaW4pLnNwbGl0KCcsJylbMV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29kID0gcmVxdWVzdCgnaHR0cHM6Ly9hcGkueGhvZmUudG9wL29jci9iNjQvdGV4dCcsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAndGV4dC9wbGFpbidcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHk6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgdmVyID0gSlNPTi5wYXJzZShyZXF1ZXN0KCdodHRwczovL3lpc28uZnVuL2FwaS91c2VyL2xvZ2luJywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2NvbnRlbnQtdHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ3JlZmVyZXInOiAnaHR0cHM6Ly95aXNvLmZ1bi9sb2dpbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb29raWUnOiBnZXRDb29raWUodHlpbWdsaW4pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJ1c2VyTmFtZVxcXCI6IHVzZXIuYWNjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcInBhc3N3b3JkXFxcIjogdXNlci5wYXNzd29yZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcImNvZGVcXFwiOiBjb2RcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodmVyLmNvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCfmmJPmkJznmbvlhaXpqozor4HmiJDlip8nKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKCd5aXNvdWNvb2tlJywgZ2V0Q29va2llKCdodHRwczovL3lpc28uZnVuJykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpKys7XFxuICAgICAgICAgICAgICAgIH0gd2hpbGUgKGkgPCA0KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoaHRtbCkuZGF0YS5saXN0O1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0ga2V5ZW4oaXQudXJsKTtcXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGlmICh1ID09IG51bGwgfHwgIXUuaW5jbHVkZXMoXFxcImFsaXl1blxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiAoaXQuZ210U2hhcmUgfHwgaXQuZ210Q3JlYXRlKSArIFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuWwj+e6uOadoVxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGdldHRva2VuKCkge1xcbiAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoJ3h6eXRva2VuJywgJycpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdG9rZW4gPSBKU09OLnBhcnNlKHBvc3QoJ2h0dHBzOi8vZ2l0Y2FmZS5uZXQvdG9vbC9hbGlwYXBlci8nLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3UuZ2l0Y2FmZS5pbmsvJ1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246ICdnZXRfdG9rZW4nXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSkpLmRhdGE7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcigneHp0dG9rZW4nLCB0b2tlbik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIGdldE15VmFyKCd4enR0b2tlbicsICcnKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgZnV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cXG4gICAgICAgICAgICAgICAgICAgIGZyb206IFxcXCJ3ZWJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IGdldHRva2VuKCksXFxuICAgICAgICAgICAgICAgICAgICBrZXl3b3JkOiBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKTtcXG4gICAgICAgICAgICBpZiAobGlzdC5kYXRhKSB7XFxuICAgICAgICAgICAgICAgIGxpc3QgPSBsaXN0LmRhdGE7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldXFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0LnRpdGxlO1xcbiAgICAgICAgICAgICAgICBsZXQgbXVybCA9ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy8nICsgaXQuYWxpa2V5XFxuICAgICAgICAgICAgICAgIGlmICghYWxpVXRpbC5jaGVja2FsaShtdXJsKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oiaIFxcXCIgKyB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBjYXRfY29kZShpdC5jYXQpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlczogaXQuZGVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IG11cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi546p5YG25ZOl5ZOlXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBiYXNpY1VybDogXFxcImh0dHA6Ly93b2dnLnh5elxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9pbmRleC5waHAvdm9kc2VhcmNoL1xcXCIgKyBzICsgXFxcIi0tLS0tLS0tLS1cXFwiICsgcGFnZSArIFxcXCItLS0uaHRtbFxcXCI7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgXFxcIi5tb2R1bGUtaXRlbXMmJi5tb2R1bGUtc2VhcmNoLWl0ZW1cXFwiKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImgzJiZhJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi52aWRlby1zZXJpYWwmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBkZmgoaXQsIFxcXCJpbWcmJmRhdGEtc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGQoaXQsIFxcXCJoMyYmYSYmaHJlZlxcXCIsIGJhc2ljVXJsKTtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHV0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHVpbWFnZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHVzZXJpYWxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIHJldHVybiBwZGZhKHJlcXVlc3QoaW5wdXQpLCBcXFwiYm9keSYmLm1vZHVsZS1yb3ctdGV4dC5jb3B5XFxcIikubWFwKHYgPT4gcGRmaCh2LCBcXFwiYSYmZGF0YS1jbGlwYm9hcmQtdGV4dFxcXCIpKTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOS6keebmOe9kVxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgYmFzaWNVcmw6IFxcXCJodHRwczovL3d3dy5hbHlwdy5jblxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9zZWFyY2gucGhwP3E9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2U7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge30pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCIubGlzdCYmbGlcXFwiKTtcXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImEmJnRpdGxlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi5mYS1jbG9jay1vJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwZGZoKGl0LCBcXFwiaW1nJiZzcmNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCBiYXNpY1VybCk7XFxuICAgICAgICAgICAgICAgIGlmICghdXRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdXRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogdWltYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogdXNlcmlhbFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBkZmEocmVxdWVzdChpbnB1dCksIFxcXCJib2R5JiZhW2hyZWZePWh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL11cXFwiKS5tYXAodiA9PiBwZGZoKHYsIFxcXCJhJiZocmVmXFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5Zyf5ouo6bygXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gZmV0Y2goJ2h0dHBzOi8vd3d3LnRic2R5LmNvbS9zZWFyY2guaHRtbD9rZXl3b3JkPScgKyBzICsgJyZjYXRlZ29yeT05ODM5MjAmZGF0YV90eXBlPTk4NzkxMCcsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgJy5zZWFyY2hfcmVzdWx0X25ldGRpc2tfbGlzdCYmYScpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhpdCk7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnYSYmaHJlZicpO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnLm5ldGRpc2tfaXRlbV9kZXRhaWxfbmFtZSYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0LFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KCdodHRwczovL2FsaXNvLmNjL3MvJyArIHMgKyAnLScgKyBwYWdlICsgJy0wLmh0bWwnLCB7fSk7XFxuXFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsICcuc2VhcmNoLXJlc3VsdCYmLnJlc291cmNlLWl0ZW0nKTtcXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGxpc3QubGVuZ3RoOyBqKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBsaXN0W2pdO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKHUsICdoMyYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXQsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHBhcnNlRG9tKHUsICdoMyYmYSYmaHJlZicsICdodHRwczovL2FsaXNvLmNjLycpLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGFyc2VEb21Gb3JIdG1sKHUsICcudGltZSYmVGV4dCcpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGV2YWwoZ2V0Q3J5cHRvSlMoKSk7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZGVjcnkoc3RyKSB7XFxuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShcXFwiOUVCMjBEREZENkFGQkQ2OFxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgZW5jcnlwdGVkID0gQ3J5cHRvSlMuQUVTLmRlY3J5cHQoc3RyLCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIHBhZGRpbmc6IENyeXB0b0pTLnBhZC5Qa2NzN1xcbiAgICAgICAgICAgICAgICB9KS50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlbmNyeXB0ZWQ7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChpbnB1dCk7XFxuICAgICAgICAgICAgbGV0IGJ1dCA9IHBhcnNlRG9tKGh0bWwsICcuYnV0dG9uJiZocmVmJywgJ2h0dHBzOi8vYWxpc28uY2MvJyk7XFxuICAgICAgICAgICAgLy9sb2coYnV0KTtcXG4gICAgICAgICAgICBsZXQgZ290ID0gcmVxdWVzdChidXQpO1xcbiAgICAgICAgICAgIC8vbG9nKGdvdCk7XFxuICAgICAgICAgICAgZXZhbChwYXJzZURvbUZvckh0bWwoZ290LCAnaGVhZCYm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gICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQganNvbiA9IGRlY3J5KEpTT04ucGFyc2UoaHRtbCkuZGF0YSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoanNvbik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGl0LnBpZDtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vYXBpL2Jicy9hcGkvZ2V0YXJ0aWNsZT9pZD1cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQuY3JlYXRldGltZVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSkpLmRhdGE7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLmRvd25sb2FkLnNwbGl0KFxcXCJAXFxcIik7XFxuICAgICAgICAgICAgbGV0IGFsaXN0ID0gbmV3IFNldCgpO1xcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbGlzdC5sZW5ndGg7IGorKykge1xcbiAgICAgICAgICAgICAgICBhbGlzdC5hZGQoXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL1xcXCIgKyBsaXN0W2pdKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIEFycmF5LmZyb20oYWxpc3QpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi55uY5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgcGFnZSA9IChwYWdlIC0gMSkgKiAxMDtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vd3d3LnBhbnNlYXJjaC5tZS9zZWFyY2g/a2V5d29yZD1cXFwiICsgcyArIFxcXCImb2Zmc2V0PVxcXCIgKyBwYWdlICsgXFxcIiZwYW49YWxpeXVuZHJpdmVcXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwsIHt9KTtcXG5cXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCAnLmdyaWQmJi5zaGFkb3c6aGFzKGFbaHJlZl49aHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXSknKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBhcnNlRG9tRm9ySHRtbChpdCwgJ2FbaHJlZl49aHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXSYmaHJlZicpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGljX3VybCA9IHBhcnNlRG9tRm9ySHRtbChpdCwgJ2ltZyYmc3JjJyk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGFyc2VEb21Gb3JIdG1sKGl0LCAnLmJyZWFrLWFsbCYmVGV4dCcpLnNwbGl0KCdodHRwJylbMF0sXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsID09PSBcXFwiL2Zhdmljb24ucG5nXFxcIiA/IFxcXCJodHRwczovL3d3dy5wYW5zZWFyY2gubWUvXFxcIiArIHBpY191cmwgOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGFyc2VEb21Gb3JIdG1sKGl0LCAncCYmVGV4dCcpICsgXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIkRPVljmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogZmFsc2UsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS5kb3Z4LnRrL2FsaS9zZWFyY2g/d2Q9XFxcIiArIHM7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoaHRtbCkubGlzdDtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IGl0LnZvZF9jb250ZW50O1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikgfHwgIWFsaVV0aWwuY2hlY2thbGkodSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKImiBcXFwiICsgaXQudm9kX25hbWUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuW/heW6lFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9jbi5iaW5nLmNvbS9zZWFyY2g/cT1cXFwiICsgcyArIFxcXCIrYWxpeXVuZHJpdmUmcXM9ZHMmZm9ybT1RQlJFXFxcIjtcXG4gICAgICAgICAgICBpZiAocGFnZSAhPSAxKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGdldE15VmFyKFxcXCJiaW5nXFxcIiwgdXJsKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL2NuLmJpbmcuY29tL1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAvL1xcXCJYLVJlcXVlc3RlZC1XaXRoXFxcIjogXFxcImNvbS5leGFtcGxlLmhpa2Vydmlld1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQWNjZXB0XFxcIjogXFxcInRleHQvaHRtbCxhcHBsaWNhdGlvbi94aHRtbCt4bWwsYXBwbGljYXRpb24veG1sO3E9MC45LGltYWdlL2F2aWYsaW1hZ2Uvd2VicCxpbWFnZS9hcG5nLCovKjtxPTAuOCxhcHBsaWNhdGlvbi9zaWduZWQtZXhjaGFuZ2U7dj1iMztxPTAuOVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCJib2R5JiZhXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgICAgICBsZXQgdCA9IHBkZmgoaXQsIFxcXCJhJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGlmIChpdC5pbmNsdWRlcyhcXFwiTmV4dCBwYWdlXFxcIikgfHwgaXQuaW5jbHVkZXMoXFxcIuS4i+S4gOmhtVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdTIgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2coXFxcIm5leHQgcGFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2codTIpO1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImJpbmdcXFwiLCB1Mik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHUgPT0gbnVsbCB8fCB0ID09IG51bGwgfHwgIWl0LmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoIWl0LmluY2x1ZGVzKFxcXCLnvZHnm5hcXFwiKSAmJiAhaXQuaW5jbHVkZXMoXFxcIuS6keebmFxcXCIpICYmXFxuICAgICAgICAgICAgICAgICAgICAhaXQuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikgJiYgIWl0LmluY2x1ZGVzKFxcXCJ5dW5wYW5cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHUuc3RhcnRzV2l0aChcXFwiaHR0cHM6Ly9jbi5iaW5nLmNvbS9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGRvbSA9IGdldEhvbWUodSkucmVwbGFjZShcXFwiaHR0cDovL1xcXCIsIFxcXCJcXFwiKS5yZXBsYWNlKFxcXCJodHRwczovL1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IF9saW5rcyA9IHQubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgICAgIGxldCBjID0gbnVsbDtcXG4gICAgICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGMgPSBfbGlua3NbMV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIGMgPSBfbGlua3NbMF07XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogZG9tLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBjICE9IG51bGwgPyBjIDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui/m+WFpee9keermVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQodSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBpZiAoaW5wdXQuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikpIHJldHVybiBpbnB1dDtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoaW5wdXQpO1xcbiAgICAgICAgICAgIHZhciBfbGlua3MgPSBodG1sLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBfbGlua3NbMV07XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gX2xpbmtzWzBdO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ0NDT0YnLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdXFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IGZldGNoKCdodHRwczovL3Bhbi5jY29mLmNjL2FwaS9zZWFyY2gnLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiAnYXBwbGljYXRpb24vanNvbicsXFxuICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3Bhbi5jY29mLmNjL3NlYXJjaD9rZXl3b3JkPScgKyBzXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwYWdlU2l6ZVxcXCI6IDIwLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VOdW1cXFwiOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcImtleXdvcmRcXFwiOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcImZyb21Nb2JpbGVcXFwiOiB0cnVlXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IEpTT04ucGFyc2UoaHRtbClcXG4gICAgICAgICAgICAgICAgLmRhdGEucm93c1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBpdC5maWxlTmFtZVxcbiAgICAgICAgICAgICAgICBsZXQgbXVybCA9IGl0LnVybFxcbiAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IGl0LnR5cGUucmVwbGFjZSgvZm9sZGVyLywgJ+aWh+S7tuWkuScpLnJlcGxhY2UoL2ZpbGUvLCAn5paH5Lu2JylcXG4gICAgICAgICAgICAgICAgaWYgKHRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiAn5paH5Lu257G75Z6L77yaJyArIHR5cGUgKyAn77yM5paH5Lu25aSn5bCP77yaJyArIGFsaVV0aWwuYnl0ZXNUb1NpemUoaXQuc2l6ZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBtdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkXFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6ICfpmL/ph4zlsI/nq5knLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgaG9tZSA9IFxcXCJodHRwczovL3BhbjY2Ni5uZXRcXFwiO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KGJ1aWxkVXJsKGhvbWUgKyBcXFwiL2FwaS9kaXNjdXNzaW9uc1xcXCIsIHtcXG4gICAgICAgICAgICAgICAgXFxcImluY2x1ZGVcXFwiOiBcXFwidXNlcixsYXN0UG9zdGVkVXNlcixtb3N0UmVsZXZhbnRQb3N0LG1vc3RSZWxldmFudFBvc3QudXNlcix0YWdzLHRhZ3MucGFyZW50LGZpcnN0UG9zdFxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJmaWx0ZXJbcV1cXFwiOiBzIC8qICsgXFxcIiB0YWc6dmlkZW8sY29taWNcXFwiKi8gLFxcbiAgICAgICAgICAgICAgICAvL1xcXCJmaWx0ZXJbdGFnXVxcXCI6IFxcXCJ2aWRlbyxjb21pY1xcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJwYWdlW29mZnNldF1cXFwiOiAyMCAqIChwYWdlIC0gMSlcXG4gICAgICAgICAgICB9KSwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiY29udGVudC10eXBlXFxcIjogXFxcImFwcGxpY2F0aW9uL2pzb25cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly9wYW42NjYubmV0Lz9xPVxcXCIgKyBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IEpTT04ucGFyc2UoaHRtbCkuZGF0YTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBsaXN0W2ldLmF0dHJpYnV0ZXM7XFxuICAgICAgICAgICAgICAgIGxldCB1cmwgPSBob21lICsgXFxcIi9kL1xcXCIgKyBpdGVtLnNsdWc7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6ICflj5HluIPml7bpl7TvvJonICsgJC5kYXRlRm9ybWF0KG5ldyBEYXRlKGl0ZW0uY3JlYXRlZEF0KSwgXFxcInl5eXktTU0tZGQgSEg6bW06c3NcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L+b5YWl5biW5a2QXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudCh1cmwpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSBwZGZoKHJlcXVlc3QoaW5wdXQpLCBcXFwiVGV4dFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBfbGlua3MgPSBodG1sLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgIGxldCBzaGFyZVB3ZCA9IGh0bWwubWF0Y2goL+aPkOWPlueggVs677yaXVxcXFxzKj8oXFxcXHd7NH0pLyk7XFxuICAgICAgICAgICAgc2hhcmVQd2QgPSBBcnJheS5pc0FycmF5KHNoYXJlUHdkKSAmJiBzaGFyZVB3ZC5sZW5ndGggPiAwID8gc2hhcmVQd2RbMV0gOiBcXFwiXFxcIjtcXG4gICAgICAgICAgICBpZiAoX2xpbmtzLmxlbmd0aCA+IDEgJiYgX2xpbmtzWzFdLnJlcGxhY2UoX2xpbmtzWzBdLCBcXFwiXFxcIikucmVwbGFjZSgvW2EtekEtWjAtOV0rL2csIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpVXJsOiBfbGlua3NbMV0sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2RcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9saW5rcy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1swXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ+S6keebmOWIhuS6q+ekvuWMuicsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBob21lID0gXFxcImh0dHBzOi8veXVucGFuMS5jY1xcXCI7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYnVpbGRVcmwoaG9tZSArIFxcXCIvYXBpL2Rpc2N1c3Npb25zXFxcIiwge1xcbiAgICAgICAgICAgICAgICBcXFwiaW5jbHVkZVxcXCI6IFxcXCJ1c2VyLGxhc3RQb3N0ZWRVc2VyLG1vc3RSZWxldmFudFBvc3QsbW9zdFJlbGV2YW50UG9zdC51c2VyLHRhZ3MsdGFncy5wYXJlbnQsZmlyc3RQb3N0XFxcIixcXG4gICAgICAgICAgICAgICAgXFxcImZpbHRlcltxXVxcXCI6IHMgLyogKyBcXFwiIHRhZzp2aWRlbyxjb21pY1xcXCIqLyAsXFxuICAgICAgICAgICAgICAgIC8vXFxcImZpbHRlclt0YWddXFxcIjogXFxcInZpZGVvLGNvbWljXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInBhZ2Vbb2Zmc2V0XVxcXCI6IDIwICogKHBhZ2UgLSAxKVxcbiAgICAgICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiBcXFwiYXBwbGljYXRpb24vanNvblxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3BhbjY2Ni5uZXQvP3E9XFxcIiArIHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKS5kYXRhO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV0uYXR0cmlidXRlcztcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGhvbWUgKyBcXFwiL2QvXFxcIiArIGl0ZW0uc2x1ZztcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogJ+WPkeW4g+aXtumXtO+8micgKyAkLmRhdGVGb3JtYXQobmV3IERhdGUoaXRlbS5jcmVhdGVkQXQpLCBcXFwieXl5eS1NTS1kZCBISDptbTpzc1xcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLov5vlhaXluJblrZBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHVybCkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHBkZmgocmVxdWVzdChpbnB1dCksIFxcXCJUZXh0XFxcIik7XFxuICAgICAgICAgICAgbGV0IF9saW5rcyA9IGh0bWwubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgbGV0IHNoYXJlUHdkID0gaHRtbC5tYXRjaCgv5o+Q5Y+W56CBWzrvvJpdXFxcXHMqPyhcXFxcd3s0fSkvKTtcXG4gICAgICAgICAgICBzaGFyZVB3ZCA9IEFycmF5LmlzQXJyYXkoc2hhcmVQd2QpICYmIHNoYXJlUHdkLmxlbmd0aCA+IDAgPyBzaGFyZVB3ZFsxXSA6IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1sxXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaVVybDogX2xpbmtzWzBdLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi54ix55yL576O5YmnXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL3d3dy4ya21qLmNuL3NlYXJjaC5waHA/cT1cXFwiICsgcyArIFxcXCImcGFnZS9cXFwiICsgcGFnZSArIFxcXCIvXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCBcXFwiLmxpc3QtaXQmJmxpXFxcIik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHV0aXRsZSA9IHBhcnNlRG9tRm9ySHRtbChpdCwgXFxcImEmJnRpdGxlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGFyc2VEb21Gb3JIdG1sKGl0LCBcXFwiLmluZm8mJnNwYW46bm90KDpoYXMoYSkpLS1pJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwYXJzZURvbShpdCwgXFxcImltZyYmc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb20oaXQsIFxcXCJhJiZocmVmXFxcIik7XFxuICAgICAgICAgICAgICAgIGJldC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB1dGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiB1aW1hZ2UsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiB1c2VyaWFsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcblxcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGRmYShyZXF1ZXN0KGlucHV0KSwgXFxcImJvZHkmJiNkb3dubG9hZFxcXCIpLm1hcCh2ID0+IHBkZmgodiwgXFxcIi5kb3duJiZocmVmXFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5aWH5aaZ5pCc57SiXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsO1xcbiAgICAgICAgICAgIGlmIChwYWdlID09PSAxKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9hcGkvcHNob3UvZ2V0RGF0YVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHdvcmQ6IHMsXFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBcXFwi6Zi/6YeM572R55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cmwgPSBidWlsZFVybChcXFwiaHR0cHM6Ly93d3cubWFnaWNhbHNlYXJjaC50b3AvYXBpL3BzaG91L2dldE5leHRQYWdlXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaHR0cHM6Ly9hcGkudXB5dW5zbzIuY29tL3NlYXJjaD9zX3R5cGU9MkBwYWdlPVxcXCIgKyBwYWdlICsgXFxcIkBrZXl3b3JkPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQocyksXFxuICAgICAgICAgICAgICAgICAgICB3ZWJzaXRlOiBcXFwi6Zi/6YeM572R55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFJlZmVyZXI6IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9zZWFyY2hcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgd29yZDogcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjcGFnZTogMFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJlc3VsdCA9IEpTT04ucGFyc2UoSlNPTi5wYXJzZShyZXN1bHQpKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJlc3VsdC5yZXN1bHQuaXRlbXM7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XFxuICAgICAgICAgICAgICAgIGlmIChpdC5pZCA9PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLml6XmnJ/vvJpcXFwiICsgaXQuaW5zZXJ0X3RpbWUgKyBcXFwiXFxcXG7ot6/lvoTvvJpcXFwiICsgaXQucGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXQucGFnZV91cmxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9XFxuXTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuaWh+S7tuaOkuW6j1wiLFwicGF0aFwiOlwiRmlsZVNvcnRpbmdcIixcInJ1bGVcIjpcImxldCBjaG5OdW1DaGFyID0ge1xcbiAgICDpm7Y6IDAsXFxuICAgIOS4gDogMSxcXG4gICAg5LqMOiAyLFxcbiAgICDkuIk6IDMsXFxuICAgIOWbmzogNCxcXG4gICAg5LqUOiA1LFxcbiAgICDlha06IDYsXFxuICAgIOS4gzogNyxcXG4gICAg5YWrOiA4LFxcbiAgICDkuZ06IDlcXG59O1xcblxcbmxldCBjaG5OYW1lVmFsdWUgPSB7XFxuICAgIOWNgToge1xcbiAgICAgICAgdmFsdWU6IDEwLFxcbiAgICAgICAgc2VjVW5pdDogZmFsc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XFxuICAgICAgICBpZiAoY21wID09PSAwKSB7XFxuICAgICAgICAgICAgbGV0IHJlZ2V4ID0gL1thLXpBLVowLTldL1xcbiAgICAgICAgICAgIGxldCBzMSA9IFN0cmluZyhzcGxpdDFbaV0pXFxuICAgICAgICAgICAgbGV0IHMyID0gU3RyaW5nKHNwbGl0MltpXSlcXG4gICAgICAgICAgICBpZiAocmVnZXgudGVzdChzMSkgfHwgcmVnZXgudGVzdChzMikpIHtcXG4gICAgICAgICAgICAgICAgY21wID0gbmV3IGphdmEubGFuZy5TdHJpbmcoc3BsaXQxW2ldKS5jb21wYXJlVG8obmV3IGphdmEubGFuZy5TdHJpbmcoc3BsaXQyW2ldKSk7XFxuICAgICAgICAgICAgICAgIC8vIGNtcCA9IHMxLmxvY2FsZUNvbXBhcmUoczIsICdlbicpXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgY21wID0gczEubG9jYWxlQ29tcGFyZShzMiwgJ3poJylcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuXFxuICAgICAgICBpZiAoY21wICE9PSAwKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGNtcDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgbGVuZ3RoQ21wID0gc3BsaXQxLmxlbmd0aCAtIHNwbGl0Mi5sZW5ndGg7XFxuICAgIC8vIGlmIChsZW5ndGhDbXAgIT09IDApIGxlbmd0aENtcCA9IGxlbmd0aENtcCA+IDAgPyAtMSA6IDE7XFxuICAgIHJldHVybiBsZW5ndGhDbXA7XFxufVxcbiQuZXhwb3J0cy5uYW1lQ29tcGFyZSA9IG5hbWVDb21wYXJlO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi55m75b2V5pa55byPXCIsXCJwYXRoXCI6XCJsb2dpbk1vZGVcIixcInJ1bGVcIjpcIiQuZXhwb3J0cyA9ICQoW1xcXCJBUFDmjojmnYPnmbvlvZVcXFwiL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RlXFxcIiwge1xcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgXFxcInNjb3Blc1xcXCI6IFtcXFwidXNlcjpiYXNlXFxcIiwgXFxcImZpbGU6YWxsOnJlYWRcXFwiLCBcXFwiZmlsZTphbGw6d3JpdGVcXFwiXSxcXG4gICAgICAgICAgICAgICAgXFxcIndpZHRoXFxcIjogMzAwLFxcbiAgICAgICAgICAgICAgICBcXFwiaGVpZ2h0XFxcIjogMzAwLFxcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG4gICAgICAgIGxldCBzaWQgPSBkYXRhW1xcXCJzaWRcXFwiXTtcXG4gICAgICAgIGxldCBxcmNvZGVfdXJsID0gZGF0YVtcXFwicXJDb2RlVXJsXFxcIl07XFxuICAgICAgICB1cGRhdGVJdGVtKFxcXCJpbmZvT3V0cHV0XFxcIiwge1xcbiAgICAgICAgICAgIHBpY191cmw6IHFyY29kZV91cmwsXFxuICAgICAgICAgICAgdXJsOiBxcmNvZGVfdXJsICsgXFxcIiMuanBnXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInBpY18xX2Z1bGxcXFwiXFxuICAgICAgICB9KTtcXG4gICAgICAgIGFkZEl0ZW1BZnRlcihcXFwiaW5mb091dHB1dFxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAmOKAmOKAmeKAmVxcXCIgKyBcXFwi5L2/55So6Zi/6YeM5LqR55uYIEFwcCDmiavnoIFcXFwiLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgY2xzOiBcXFwibG9naW5cXFwiXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBkZWxldGVJdGVtKFxcXCJnZXRRQ1xcXCIpO1xcbiAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgIGxldCByZWZyZXNoX3Rva2VuO1xcbiAgICAgICAgd2hpbGUgKHRydWUpIHtcXG4gICAgICAgICAgICBsZXQgZGF0YTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBkYXRhID0gZ2V0X3FyY29kZV9zdGF0dXMoc2lkKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mn6Xor6LmiavnoIHnu5PmnpzotoXml7YsIOWPr+iDveaYr+inpuWPkeS6humYv+mHjOS6keebmOaOpeWPo+mZkOWItiwg6K+356iN5ZCO5YaN6K+VLlxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdGF0dXMgPSBkYXRhW1xcXCJzdGF0dXNcXFwiXTtcXG4gICAgICAgICAgICBpZiAoc3RhdHVzID09IFxcXCJMb2dpblN1Y2Nlc3NcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW4gPSBnZXRfcmVmcmVzaF90b2tlbihkYXRhW1xcXCJhdXRoQ29kZVxcXCJdKTtcXG4gICAgICAgICAgICAgICAgYnJlYWtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHN0YXR1cyA9PSBcXFwiUVJDb2RlRXhwaXJlZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S6jOe7tOeggeW3sui/h+acnywg6K+35Yi35paw6aG16Z2i5ZCO6YeN6K+VXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKCFnZXRNeVZhcihcXFwiTG9nZ2luZ2luXFxcIiwgXFxcIlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9jYW5jZWxcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDE1MDApO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJlZnJlc2hfdG9rZW4pIHtcXG4gICAgICAgICAgICBjb25zdCB7XFxuICAgICAgICAgICAgICAgIG9wZW5Ub2tlbnNGaWxlcGF0aCxcXG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJ0b2tlblBhdGhcXFwiKTtcXG4gICAgICAgICAgICBsZXQgb3BlbiA9IHtcXG4gICAgICAgICAgICAgICAgUmVmcmVzaFRva2VuT3BlbjogcmVmcmVzaF90b2tlbixcXG4gICAgICAgICAgICAgICAgaXNWMjogdHJ1ZVxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgd3JpdGVGaWxlKG9wZW5Ub2tlbnNGaWxlcGF0aCwgSlNPTi5zdHJpbmdpZnkob3BlbikpO1xcbiAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwiaW5mb091dHB1dFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnmbvlvZXmiJDlip8o54K55Ye76L+U5ZueKVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDokKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpPT57XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwibG9naW5cXFwiKTtcXG5cXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v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sZXQganNvbiA9IHBvc3QoJ2h0dHBzOi8vYXBpLnhob2ZlLnRvcC9hbGlzdC9hbGlfb3Blbi9jb2RlJywge1xcbiAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLydcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBpZiAoIWpzb24pIHtcXG4gICAgICAgICAgICBqc29uID0gcG9zdCgnaHR0cHM6Ly9hcGktY2Yubm4uY2kvYWxpc3QvYWxpX29wZW4vY29kZScsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoanNvbi5pbmNsdWRlcygnVG9vIE1hbnkgUmVxdWVzdHMnKSB8fCBqc29uLmluY2x1ZGVzKFxcXCI1MDIgQmFkIEdhdGV3YXlcXFwiKSkge1xcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi6aKR57mB6K+35rGC5pqC5pe26KKr5bCB56aBXFxcXG5cXFwiICsganNvbik7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBvcGVuUmVzdWx0ID0gSlNPTi5wYXJzZShqc29uKTtcXG4gICAgICAgICAgICByZXR1cm4gb3BlblJlc3VsdDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgZ2V0T3BlblRva2VuKCkge1xcbiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0VG9rZW4oe1xcbiAgICAgICAgICAgIGNvZGU6IHRoaXMuZ2V0T3Blbl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NzX3Rva2VuXFxcIiwge1xcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG5cXG4gICAgICAgIHJldHVybiBkYXRhO1xcbiAgICB9LFxcbiAgICBnZXRPcGVuVG9rZW4oKSB7XFxuICAgICAgICByZXR1cm4gdGhpcy5nZXRUb2tlbih7XFxuICAgICAgICAgICAgY29kZTogdGhpcy5nZXRPcGVuVG9rZW5Db2RlKCksXFxuICAgICAgICAgICAgZ3JhbnRfdHlwZTogXFxcImF1dGhvcml6YXRpb25fY29kZVxcXCIsXFxuICAgICAgICAgICAgY2xpZW50X3NlY3JldDogdGhpcy5jbGllbnRfc2VjcmV0LFxcbiAgICAgICAgICAgIGNsaWVudF9pZDogdGhpcy5jbGllbnRfaWQsXFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgcmVmcmVzaE9wZW5Ub2tlbigpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLmdldFRva2VuKHtcXG4gICAgICAgICAgICBncmFudF90eXBlOiBcXFwicmVmcmVzaF90b2tlblxcXCIsXFxuICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogdGhpcy4kdGhpcy5vcGVuVG9rZW5zLlJlZnJlc2hUb2tlbk9wZW4sXFxuICAgICAgICAgICAgY2xpZW50X3NlY3JldDogdGhpcy5jbGllbnRfc2VjcmV0LFxcbiAgICAgICAgICAgIGNsaWVudF9pZDogdGhpcy5jbGllbnRfaWQsXFxuICAgICAgICB9KTtcXG4gICAgfVxcbn0pO1xcbiQuZXhwb3J0cyA9IE9wZW5BcGk7XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLpk77mjqXlrprlkJFcIixcInBhdGhcIjpcInJlZGlyZWN0XCIsXCJydWxlXCI6XCJqczpcXG5jb25zdCBvcGVuTW9kZSA9IGdldEl0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cXFwvLywgXFxcIlxcXCIpXFxuICAgICAgICAgICAgfSkpKTtcXG4gICAgICAgIH0sIGxpc3QsIGNvbCk7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0RXJyb3JQb3AobmFtZSwgYXV0aG9yKSB7XFxuICAgIHJldHVybiAkKFxcXCLmkJzntKLlvJXmk47jgIxcXFwiICsgbmFtZSArIFxcXCLjgI3lpLHmlYjor7fogZTns7vmkJzntKLlvJXmk47kvZzogIVcXFwiICsgKGF1dGhvciA/IFxcXCJbXFxcIiArIGF1dGhvciArIFxcXCJdXFxcIiA6IFxcXCJcXFwiKSArIFxcXCLkv67lpI3miJbliKDpmaRcXFxcblxcXFxu5byV5pOO5L2c6ICF5Y+v5Lul5Y675a6Y5pa56aKR6YGT6K+i6ZeuXFxcXG7ngrnlh7vnoa7lrprlv6vpgJ/liKDpmaRcXFwiKS5jb25maXJtKChuYW1lKSA9PiB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpFxcXCIgKyBuYW1lICsgXFxcIuWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobmFtZSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBuYW1lKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicn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RydWU7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcbiAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICB9XFxuICAgIHJldHVybiBwYXRoO1xcbn1cXG5cXG5mdW5jdGlvbiBnZXRKc29uKG9iaiwgcGF0aCkge1xcbiAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgfVxcbiAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIHJldHVybiBvYmo7XFxuICAgIH1cXG4gICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgbGV0IGtleSA9IHBhdGhbaV07XFxuXFxuICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgIH1cXG4gICAgICAgIGN1cnJlbnQgPSBjdXJyZ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XCJsaXN0U2VhcmNoS2V5XFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImRtX2xpc3RVcmxMaXN0XFxcIik7XFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgc2V0TWFya2VyKCk7XFxuICAgICAgICBpZiAoTVlfUEFSQU1TLmlzSG9tZSkge1xcbiAgICAgICAgICAgIC8vc2lnbkluUmV3YXJkKGFsaUFjY2Vzc0FwaSk7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5aSH5Lu955uYXFxcIiArIFtcXFwiXFxcIiwgXFxcIuKImlxcXCJdW051bWJlcihpc0JhY2t1cERyaXZpZCldLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibXlBbGlQYW5Ecml2aWRcXFwiLCBcXFwidHJ1ZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6LWE5rqQ55uYXFxcIiArIFtcXFwi4oiaXFxcIiwgXFxcIlxcXCJdW051bWJlcihpc0JhY2t1cERyaXZpZCldLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibXlB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ICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUluZm8sIGlzQmFja3VwRHJpdmlkLCBmaWxlSWQpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCFpc1NlYXJjaCkge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaQnOe0olxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXlhbPplK7or41cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNmdWxsVGhlbWUjP3BhZ2U9ZnlwYWdlJnNlYXJjaEtleT1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6IFxcXCJwdXRNeVZhcignbGlzdFNlYXJjaEtleScsaW5wdXQpXFxcIixcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgc2VhcmNoS2V5ICsgXFxcIuKAneKAneeahOaQnOe0oue7k+aenFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmdW5jSXRlbXMgPSBbXTtcXG4gICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc3R5bGUsXFxuICAgICAgICAgICAgdXJsOiAkKHN0eWxlcywgMSwgXFxcIuaOkuW4g+agt+W8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImFsaXl1bl9zdHlsZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNolxcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ljb24uc3ZnXFxcIlxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBvcmRlck5hbWUsXFxuICAgICAgICAgICAgdXJsOiAkKG9yZGVyc0tleXMsIDIsIFxcXCLmjpLluo/mlrnlvI9cXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fb3JkZXJcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAg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ub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuafpeeci+aJi+WKqOaMgui9veWtl+W5lVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB6bSA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0aXAgPSB6bS5uYW1lID8gXFxcIuW9k+WJjeWtl+W5leaWh+S7tlxcXFxuXFxcIiArIHptLm5hbWUgKyBcXFwiLlxcXCIgKyB6bS5leHQgOiBcXFwi6L+Y5pyq5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogJ+aJi+WKqOaMgui9veWtl+W5lScsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB0aXAgKyBcXFwiXFxcXG4o54K55Ye75Y+W5raI5Y+v5Lul5riF6Zmk5oyC6L295a2X5bmVKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJtb3VudHppbXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5riF6Zmk5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5blvLnluZXmkJzntKLop4TliJlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJqc1xcXCI6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbG9hZERtP3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiJnRpdGxlPVxcXCIpICsgXFxcIitlbmNvZGVVUklDb21wb25lbnQocGxheWRhdGEudGl0bGUuc3BsaXQoJy0nKVswXSk7XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogTVlfUlVMRS50aXRsZSArIFxcXCLlvLnluZXmkJzntKJcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoXFxcIu+/pXByb2plY3Rpb25fc2NyZWVu77+lXFxcIiArIEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmjqjpgIHliLBUVkJveFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3R2Ym94UHVzaCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIiwgXFxcIuaQnOe0ouWwgemdolxcXCJdLCAxKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K+36L6T5YWl5Zu+54mH5Zyw5Z2AXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWcsOWdgFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFBhZ2VQaWNVcmwoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZnJvbnRDb3ZlciNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5bmipXlsY9JUFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpcCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpLmdldElQdjRBZGRyZXNzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpcC5zdGFydHNXaXRoKFxcXCIxOTIuMTY4LlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuivpUlQ6YCC55So5LqO5rWB6YePK+eDreeCueeahOaKleWxj1xcXFxu6K+35pu/5o2i6ZO+5o6l5Lit55qEMC4wLjAuMFxcXCIpLmNvbmZpcm0oKGlwKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGlwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXApO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXAgKyBcXFwiXFxcXG7ojrflj5blpLHotKXpnZ7nqLPlrppJUCzor7flvIDlkK/ng63ngrnlho3kvb/nlKgs6K+lSVDlj6/og73kvJrlj5gs5LiN6IO95oqV5bGPXFxcIikuY29uZmlybSgoKSA9PiB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmnoHpgJ/ljp/nlLvkuIvovb3nur/nqItcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChnZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFxcXCIxMFxcXCIpLCBcXFwi6K+36L6T5YWlMy0zMuS5i+mXtOeahOaVtOaVsFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzcGVlZFRocmVhZCA9IHBhcnNlSW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzcGVlZFRocmVhZCA8IDMgfHwgc3BlZWRUaHJlYWQgPiAzMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7kuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBTdHJpbmcoc3BlZWRUaHJlYWQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9maWxlaW50by5zdmdcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZUlkOiBwYWdlSWQsXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZvbGRlck5hbWU6IGdldFBhZ2VUaXRsZSgpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCJBTExcXFwiLCBcXFwi5LuF5paH5Lu2XFxcIiwgXFxcIuS7heaWh+S7tuWkuVxcXCJdW3NraXBGaWxlXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFtcXFwiQUxMXFxcIiwgXFxcIuS7heaWh+S7tlxcXCIsIFxcXCLku4Xmlofku7blpLlcXFwiXSkuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm15c2tpcEZpbGVcXFwiLCBTdHJpb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AgICAgIHZpZGVvOiBcXFwi8J+OrFxcXCIsXFxuICAgICAgICBhdWRpbzogXFxcIvCfjrVcXFwiLFxcbiAgICAgICAgZG9jOiBcXFwi8J+TkVxcXCIsXFxuICAgICAgICBpbWFnZTogXFxcIvCflrxcXFwiLFxcbiAgICAgICAgemlwOiBcXFwi8J+TplxcXCIsXFxuICAgICAgICBmb2xkZXI6IFxcXCLwn5OCXFxcIlxcbiAgICB9O1xcblxcbiAgICBmdW5jdGlvbiBnZXRIZWFkKHR5cGUsIGV4dCkge1xcbiAgICAgICAgbGV0IGhlYWQgPSB0aXRsZUhlYWRbdHlwZV07XFxuICAgICAgICBpZiAoc3ViRXh0cy5pbmNsdWRlcyhleHQpKSB7XFxuICAgICAgICAgICAgaGVhZCA9IFxcXCLwn5W4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBoZWFkIHx8IFxcXCLinZNcXFwiO1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHtcXG4gICAgICAgIGlmIChmaWxlSXRlbS50aHVtYm5haWwpIHtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwiaHR0cHM6Ly9lbXB0eT9cXFwiICsgZmlsZUl0ZW0uZmlsZV9pZCkuaW1hZ2UoKHBpYykgPT4ge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoKHBpYywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0U3RyZWFtOiB0cnVlXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBmaWxlSXRlbS50aHVtYm5haWwpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuXFxuICAgIGZ1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m8sXFxuICAgICAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpOaWh+S7tuWkuVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoZGVsZXRlREZpbGUsIGZpbGVJdGVtLmZpbGVfaWQsIGlzQmFja3VwRHJpdmlkLCBmaWxlSXRlbS5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIGlmIChub1NraXBGaWxlKSB7XFxuICAgICAgICAgICAgaWYgKGZpbHRlclR5cGUubGVuZ3RoID4gMCAmJiAhZmlsdGVyVHlwZS5pbmNsdWRlcyhjYXRlKSkge1xcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHN1YnRpdGxlLCBjbHMsIGxvbmdjID0gW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaTmlofku7ZcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhkZWxldGVERmlsZSwgZmlsZUl0ZW0uZmlsZV9pZCwgaXNCYWNrdXBEcml2aWQsIGZpbGVJdGVtLm5hbWUpXFxuICAgICAgICAgICAgfV07XFxuICAgICAgICAgICAgbGV0IHRpdGxlID0gZmlsZUl0ZW0ubmFtZTtcXG4gICAgICAgICAgICBsZXQgbmFtZU5vdEV4dCA9IGZpbGVJdGVtLm5hbWUucmVwbGFjZSgnLicgKyBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbiwgJycpO1xcbiAgICAgICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uKSkge1xcbiAgICAgICAgICAgICAgICBsb25nYy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5oyC6L295a2X5bmVXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh6bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdtb3VudHppbXUnLCB6bSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+aMgui9veWujOaIkO+8jOW9k+WJjeWtl+W5leaWh+S7tjogJyArIHptLm5hbWUgKyAnLicgKyB6bS5leHQ7XFxuICAgICAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0OiBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2lkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IG5hbWVOb3RFeHRcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGNhdGUgPT09IFxcXCJ2aWRlb1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHppbXVsaXN0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgc3VidGl0bGUgPSB6aW11bGlzdC5maW5kKHYgPT4gdi5uYW1lLmluY2x1ZGVzKG5hbWVOb3RFeHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjbHMgPSBcXFwicGxheWxpc3QgdlxcXCIgKyBwYWdlSWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChmaWxlU3R5bGUgPT09IFxcXCJ0ZXh0XzFcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGRlc2MgKz0gXFxcIlxcXFx0XF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NlLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBmaWxlU3R5bGVcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBpZiAoY29udHMubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInkuoblk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5sZXQgaXRlbXMgPSBbXTtcXG50cnkge1xcbiAgICBpZiAoTVlfUEFHRSA+IDEgJiYgIU1ZX1BBUkFNUy5tYXJrZXIpIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieS6huWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHN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GlvbiBnZXRNM3U4Q29udGVudChwbGF5dXJsKSB7XFxuICAgICAgICAvL21lZGlhLm0zdThcXG4gICAgICAgIGxldCBob21lID0gcGxheXVybC5zcGxpdChzdWZmaXgpWzBdO1xcbiAgICAgICAgbGV0IGYgPSBmZXRjaChwbGF5dXJsLCB7XFxuICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGltZW91dDogMzAwMFxcbiAgICAgICAgfSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICBsZXQgZmYgPSBmLm1hcChpdCA9PiB7XFxuICAgICAgICAgICAgaWYgKGl0LnN0YXJ0c1dpdGgoXFxcIm1lZGlhLVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiL3Byb3h5P3VybD1cXFwiICsgYmFzZTY0RW5jb2RlKGhvbWUgKyBpdCkrXFxcIiZ0aW1lc3RhbXA9XFxcIitNWV9QQVJBTVMudGltZXN0YW1wWzBdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gaXQ7XFxuICAgICAgICB9KS5qb2luKFxcXCJcXFxcblxcXCIpO1xcblxcbiAgICAgICAgd3JpdGVGaWxlKGNhY2hlRmlsZVBhdGgsIGZmKTtcXG4gICAgICAgIHJldHVybiBmZjtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiB1cGRhdGVUc1VybCh1cmwpIHtcXG4gICAgICAgIGxldCBmaWQgPSB1cmwuc3BsaXQoJyZmPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICAvL2xvZygnc2ZpZC0nICsgZmlkKTtcXG4gICAgICAgIGxldCBmID0gZmV0Y2goY2FjaGVGaWxlUGF0aCkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICBmLmZvckVhY2goaXQgPT4ge1xcbiAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpLnNwbGl0KFxcXCImXFxcIilbMF0pO1xcbiAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgZXhwaXJlcyA9IHVybC5zcGxpdCgneC1vc3MtZXhwaXJlcz0nKVsxXS5zcGxpdCgnJicpWzBdO1xcbiAgICAgICAgY29uc3QgbGFzdHRpbWUgPSBwYXJzZUludChleHBpcmVzKSAtIERhdGUubm93KCkgLyAxMDAwO1xcbiAgICAgICAgaWYgKGxhc3R0aW1lIDwgNjApIHtcXG4gICAgICAgICAgICAvL2xvZygn6L+H5pyf5pu05pawJylcXG4gICAgICAgICAgICBsZXQgbGluZSA9IHVybC5zcGxpdCgnL21lZGlhJylbMF07IC8v5Y+W5LmL5YmN5pKt5pS+55qEdHPmrrXnur/ot69cXG4gICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcobGluZS5sYXN0SW5kZXhPZignLycpICsgMSk7XFxuICAgICAgICAgICAgbGV0IGYgPSBnZXRNM3U4Q29udGVudChnZXRBbGlQbGF5VXJsKGZpZCwgbGluZSkpLnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZnVybCA9IGJhc2U2NERlY29kZShpdC5yZXBsYWNlKCcvcHJveHk/dXJsPScsICcnKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGZ1cmw7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHVybDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHVybCA9IGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKTtcXG4gICAgICAgIGlmICh1cmwuaW5jbHVkZXMoXFxcIi50c1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiB1cGRhdGVUc1VybCh1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAg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1vZGUgKyBcXFwi5pKt5pS+5aSx6LSlI1xcXFxu6ZSZ6K+v5L+h5oGvPlxcXCIgKyBlLnRvU3RyaW5nKCkgKyBcXFwiXFxcXG7plJnor6/ooYw+XFxcIiArIGUubGluZU51bWJlcik7XFxuICAgICAgICAgICAgaWYgKGUuY29kZSA9PT0gXFxcIkludmFsaWRQYXJhbWV0ZXIuUmVmcmVzaFRva2VuXFxcIikge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi55m76ZmG6L+H5pyf77yM6K+36YeN5paw55m76ZmGXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2xvZ2luI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5Iz9ub1JlZnJlc2g9MVxcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChlLmNvZGUgPT09IFxcXCJRdW90YUV4aGF1c3RlZC5Ecml2ZVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+e9keebmOepuumXtOS4jei2s++8jOaXoOazleaSreaUvuivt+a4heeQhuOAglxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mkq3mlL7lpLHotKXvvIzplJnor6/kv6Hmga/lt7LmiZPljbDjgIJcXFxcbuivt+afpeeci+aXpeW/lyhMT0cpXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBtb3VudHN1YiA9IHN0b3JhZ2UwLmdldE15VmFyKCdtb3VudHppbXUnLCB7fSk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMobW91bnRzdWIpLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICB6aW11ID0gbW91bnRzdWI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc3VidGl0bGU7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMoemltdSB8fCB7fSkubGVuZ3RoID4gMCAmJiBwbGF5TGlzdCAmJiBwbGF5TGlzdC51cmxzICYmIHBsYXlMaXN0LnVybHMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwKTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB2YXIgem11cmwgPSBhbGlBY2Nlc3NBcGkub3BlbkNsb3VkRmlsZVRvRG93blVybCh6aW11LmZpbGVfaWQpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9ICdoaWtlcjovL2ZpbGVzL2NhY2hlL+S6keebmOWQmy9zdWIuJyArIHppbXUuZXh0O1xcbiAgICAgICAgICAgICAgICBkb3dubG9hZEZpbGUoem11cmwsIHBhdGgsIHtcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IGdldFBhdGgocGF0aCk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5a2X5bmV5Yqg6L295aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxvZyhlLm1lc3NhZ2UpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBkbWxpc3QgPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiZG1saXN0XFxcIiwgW10pO1xcbiAgICAgICAgbGV0IGRtbGlzdF9jYWNoZSA9IGdldE15VmFyKFxcXCJkbWxpc3RfY2FjaGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICBpZiAoZG1saXN0X2NhY2hlICYmIGRtbGlzdF9jYWNoZS5zdGFydHNXaXRoKGZpbGVJZCArIFxcXCIjXFxcIikpIHtcXG4gICAgICAgICAgICBwbGF5TGlzdC5kYW5tdSA9IGRtbGlzdF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ICAgfVxcbn0pO1xcbiQuZXhwb3J0cyA9IE9wZW5BcGk7XCJ9XSIsImljb24iOiJodHRwczovL2ltZy5hbGljZG4uY29tL2ltZ2V4dHJhL2kyL08xQ04wMURPWWNzNzF2M0I2Yk9lbVZNXyEhNjAwMDAwMDAwNjExNi0yLXRwcy01MTItNTEyLnBuZyIsInByb3h5IjoiIn0=
Add Comment
Please, Sign In to add comment