Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@云盘君.简@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoi5LqR55uY5ZCbLueugCIsImF1dGhvciI6IuWwj+ajieiihPCfjJ4mQExveURnSWsiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjoxODAsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoiYWxsIiwiY2xhc3NfdXJsIjoiIiwiYXJlYV9uYW1lIjoiIiwiYXJlYV91cmwiOiIiLCJzb3J0X25hbWUiOiIiLCJ5ZWFyX25hbWUiOiIiLCJzb3J0X3VybCI6IiIsInllYXJfdXJsIjoiIiwiZmluZF9ydWxlIjoianM6JC5yZXF1aXJlKFwiTWFpblwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zZWFyY2hUZXJtcz0qKiIsImdyb3VwIjoiSue9keebmOejgeWKmyIsInNlYXJjaEZpbmQiOiJqczpcbmxldCBpc2REZWxlZ2F0ZSA9ICEhZ2V0SXRlbShcImlzZERlbGVnYXRlXCIsIFwiXCIpO1xuaWYgKGlzZERlbGVnYXRlKSB7XG4gICAgc2V0UmVzdWx0KFt7XG4gICAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgICAgdXJsOiBcImhpa2VyOi8vc2VhcmNoP3M9XCIgKyBNWV9LRVlXT1JELFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgZGVsZWdhdGVPbmx5U2VhcmNoOiB0cnVlLFxuICAgICAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlR3JvdXAgPSBnZXRJdGVtKFwicnVsZUdyb3VwXCIsIFwiXCIpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9ICQucmVxdWlyZShcImRhdGFcIikuZ2V0QWxsRGF0YShydWxlR3JvdXApO1xuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgZGF0YSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKHJ1bGUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UmVzdWx0KCQucmVxdWlyZShcImRhdGFcIikuY2FycnlTUnVsZShydWxlLCBNWV9LRVlXT1JELCBNWV9QQUdFLCBnZXRTZWFyY2hNb2RlKCkpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBpdClcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShydWxlcyk7XG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9XG4gICAgfV0pO1xufSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5pCc57SiXCIgKyBNWV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waWNcXFwiIDogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe1xcbiAgICAgICAgICAgICAgICBpbmhlcml0VGl0bGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZVxcbiAgICAgICAgICAgIH0sIGl0LmV4dHJhKVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIHJlc0xpc3Q7XFxufVxcbiQuZXhwb3J0cy5jYXJyeVNSdWxlID0gZnVuY3Rpb24ocnVsZSwgcywgcGFnZSwgc2VhcmNoTW9kZSkge1xcbiAgICBydWxlID0gZ2V0Q29tcGxldGVSdWxlKHJ1bGUpO1xcbiAgICBsZXQgbGlzdCA9IHJ1bGUuZmluZChzLCBwYWdlKTtcXG4gICAgaWYgKCFsaXN0KSByZXR1cm4gW107XFxuICAgIGxldCByZXNMaXN0ID0gW107XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGlmIChpdC5za2lwKSB7XFxuICAgICAgICAgICAgcmVzTGlzdC5wdXNoKGl0KTtcXG4gICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChzZWFyY2hNb2RlICYmICFzZWFyY2hDb250YWlucyhpdC50aXRsZSwgcywgdHJ1ZSkpIGNvbnRpbnVlO1xcbiAgICAgICAgaWYgKHJ1bGUuZmluZEFsaVVybCkge1xcbiAgICAgICAgICAgIGl0LnVybCA9ICQoaXQudXJsKS5sYXp5UnVsZSh0b1JlZGlyZWN0VHJlYXRpbmcsIHtcXG4gICAgICAgICAgICAgICAgZmluZEFsaVVybDogcnVsZS5maW5kQWxpVXJsLFxcbiAgICAgICAgICAgICAgICBiYXNpY1VybDogcnVsZS5iYXNpY1VybCxcXG4gICAgICAgICAgICAgICAgbmFtZTogcnVsZS5uYW1lLFxcbiAgICAgICAgICAgICAgICBhdXRob3I6IHJ1bGUuYXV0aG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gPSBjb250ZXh0LmdldFN5c3RlbVNlcnZpY2UoQ29udGV4dC5DTElQQk9BUkRfU0VSVklDRSk7XFxuICAgICAgICAgICAgLy8g6L+U5Zue5pWw5o2uXFxuICAgICAgICAgICAgbGV0IGNsaXBEYXRhID0gY2xpcGJvYXJkLmdldFByaW1hcnlDbGlwKCk7XFxuICAgICAgICAgICAgaWYgKGNsaXBEYXRhICE9IG51bGwgJiYgY2xpcERhdGEuZ2V0SXRlbUNvdW50KCkgPiAwKSB7XFxuICAgICAgICAgICAgICAgIC8vIOS7juaVsOaNrumbhuS4reiOt+WPlu+8iOeymOi0tO+8ieesrOS4gOadoeaWh+acrOaVsOaNrlxcbiAgICAgICAgICAgICAgICBsZXQgdGV4dCA9IGNsaXBEYXRhLmdldEl0ZW1BdCgwKS5nZXRUZXh0KCk7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0ICE9IG51bGwpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcodGV4dC50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgdGV4dCA9IGdldENvcHkoKSB8fCBcXFwiXFxcIjtcXG4gICAgbGV0IHVybCA9IGFsaXRlc3QubWF0Y2hBbGlVcmwodGV4dCk7XFxuICAgIGlmICh1cmwpIHtcXG4gICAgICAgIGxldCBjYWNoZSA9IGdldEl0ZW0oXFxcImNsaXBib2FyZENhY2hlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKHVybCAhPT0gY2FjaGUpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnTxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLmo4DmtYvliLDliarotLTmnb/lkKvmnInpmL/ph4zpk77mjqXmmK/lkKbmiZPlvIA/XFxcXG5cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlucHV0LCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShpZCArIFxcXCJjbGlwYm9hcmRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpICsgXFxcIiZzaGFyZVB3ZD1cXFwiO1xcbiAgICAgICAgICAgICAgICB9LCB1cmwsIGlkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcImNsaXBib2FyZFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IFxcXCLmiZPlvIDpk77mjqVcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJjbGlwYm9hcmRDYWNoZVxcXCIsIHVybCk7XFxuICAgICAgICB9XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0UHJlcG9zZSgpIHtcXG4gICAgaWYgKG9wZW5Nb2RlID09IFxcXCLmnKzlnLDop6PmnpBcXFwiKSB7XFxuICAgICAgICBsZXQgYWxpVG9rZW5zRmlsZXBhdGggPSAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS90b2tlblBhdGhcXFwiKS5hbGlUb2tlbnNGaWxlcGF0aDtcXG4gICAgICAgIGxldCBhID0gZmV0Y2goYWxpVG9rZW5zRmlsZXBhdGgpO1xcbiAgICAgICAgaWYgKCFhIHx8IGEgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwicmljaF90ZXh0XFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4gJC5yZXF1aXJlKFxcXCJsb2dpbk1vZGVcXFwiKSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKrmo4DmtYvliLDnmbvlvZXkv6Hmga/vvIzngrnmiJHot7PovaznmbvlvZXotKblj7fpobXpnaLvvIznmbvlvZXpmL/ph4zkupHnm5jotKblj7flkI7mlrnlj6/kvb/nlKjmnKzlnLDop6PmnpDmqKHlvI9cXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBcXFwi55m75b2V6Zi/6YeM5LqR55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgYWRkTGlzdGVuZXIoXFxcIm9uQ2xvc2VcXFwiLCAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGNsZWFyTXlWYXIoXFxcInNcXFwiKTtcXG4gICAgfSkpO1xcbiAgICBhZ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xheWRhdGEudGl0bGUuc3BsaXQoJy0nKVswXSk7XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogTVlfUlVMRS50aXRsZSArIFxcXCLlvLnluZXmkJzntKJcXFwiXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoXFxcIu+/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/pk77mjqUnLFxcbiAgICAgICAgY29sX3R5cGU6ICdpbnB1dCcsXFxuICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgIGlmICgkLnJlcXVpcmUoXFxcImFsaXRlc3RcXFwiKS50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJzXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpICsgXFxcIiZzaGFyZVB3ZD1cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwic1xcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO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AgZ3JvdXAudW5zaGlmdChcXFwi8J+SoeWFqOmDqPCfkqFcXFwiKTtcXG4gICAgICAgICAgICBsZXQgc2VsZWN0TnVtID0gJC5yZXF1aXJlKFxcXCJkYXRhXFxcIikuZmluZE1vZHVsbyhncm91cC5sZW5ndGgpO1xcbiAgICAgICAgICAgIHJldHVybiAkKGdyb3VwLCBzZWxlY3ROdW0sIFxcXCLor7fpgInmi6nliIbnu4RcXFwiLCBpbmRleCkuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKCFNWV9JTkRFWCkge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZUdyb3VwXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZUdyb3VwXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiBcXFwiXFxcIiA9PSByID8gXFxcIuKAnOKAnOWFqOmDqOKAneKAnVxcXCIgOiBcXFwi5YWo6YOoXFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgocywgaWQpID0+IHtcXG4gICAgICAgICAgICBsZXQgcXIgPSBnZXRJdGVtKFxcXCJydWxlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgICAgIGlmIChzKSB7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwi5YWo6YOoXFxcIiArIGlkLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOWFqOmDqOKAneKAnVxcXCJcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGlmIChxcikge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCArIHFyLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHFyXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgcywgaWQpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IFxcXCLlhajpg6hcXFwiICsgaWRcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGZvciAobGV0IFtpdCwgYmFzaWNVcmxdIG9mIHJ1bGVzKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBpdCA9PSByID8gXFxcIuKAnOKAnFxcXCIgKyBpdCArIFxcXCLigJ3igJ1cXFwiIDogaXQsXFxuICAgICAgICAgICAgdXJsOiAkKChnZXRIb21lKGJhc2ljVXJsKSB8fCBcXFwiXFxcIikgKyBcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgociwgcywgaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IHFyID0gZ2V0SXRlbShcXFwicnVsZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZVxcXCIsIHIpO1xcbiAgICAgICAgICAgICAgICBpZiAocykge1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0ocXIgPyAoaWQgKyBxcikgOiAoXFxcIuWFqOmDqFxcXCIgKyBpZCksIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogcXIgfHwgXFxcIuWFqOmDqFxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCArIHIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyByICsgXFxcIuKAneKAnVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgaXQsIHMsIGlkKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBpZCArIGl0XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG5cXG59XFxuXFxuZnVuY3Rpb24gcmVjb3JkKCkge1xcbiAgICBsZXQgaGlzdG9yeSA9IHN0b3JhZ2UwLmdldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBbXSk7XFxuICAgIGxldCBpaSA9IGhpc3RvcnkuaW5kZXhPZihzKTtcXG4gICAgaWYgKGlpID4gLTEpIHtcXG4gICAgICAgIGhpc3Rvcnkuc3BsaWNlKGlpLCAxKTtcXG4gICAgfVxcbiAgICBpZiAoaGlzdG9yeS5sZW5ndGggPiAyMCkge1xcbiAgICAgICAgaGlzdG9yeS5zcGxp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ICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiZGF0YVxcXCIpLmNhcnJ5UnVsZShydWxlLCBzLCByZWFsUGFnZSwgc2VhcmNoTW9kZSk7XFxuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9nKHJ1bGUubmFtZSArIFxcXCI6XFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLyppZihkYXRhLmxlbmd0aD09PTEmJnA9PT0xKXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTpcXFwi4oCc4oCcXFxcIitydWxlLm5hbWUrXFxcIiBFUlJPUuKAneKAnVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBlLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTpcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6XFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6e1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuIHJ1bGUuZmluZChzLCByZWFsUGFnZSk7XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIHBhcmFtOiBpdCxcXG4gICAgICAgICAgICAgICAgaWQ6IFxcXCJydWxlQFxcXCIgKyBpdC5uYW1lXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuXFxuICAgICAgICBiYXRjaEV4ZWN1dGUodGFza3MsIHtcXG4gICAgICAgICAgICBmdW5jOiBmdW5jdGlvbihwYXJhbSwgaWQsIGVycm9yLCByZXN1bHQpIHtcXG4gICAgICAgICAgICAgICAgcGFyYW0uaSArPSAxO1xcbiAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZXN1bHQpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKFxcXCJfbm90aGF2ZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUJlZm9yZShwYWdlaWQsIHJlc3VsdCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHBhcmFtLmkgPT09IHBhcmFtLmFsbCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFyZXN1bHQgfHwgIXJlc3VsdC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKFxcXCJfbm90aGF2ZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1CZWZvcmUocGFnZWlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6LWE5rqQ6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBcXFwiX25vdGhhdmVcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0ocGFnZWlkKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0ocGFnZWlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliqDovb3nrKxcXFwiICsgTVlfUEFHRSArIFxcXCLpobXkuK3vvIzov5vluqbvvJpcXFwiICsgKHBhcmFtLmkgKyAxKSArIFxcXCIvXFxcIiArIHBhcmFtLmFsbCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICAgICAgYWxsOiBkYXRhLmxlbmd0aCxcXG4gICAgICAgICAgICAgICAgaTogMCxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICB9XFxufVxcblxcbmZ1bmN0aW9uIHNldEhpc3RvcnkoKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogJzxzcGFuIHN0eWxlPVxcXCJjb2xvcjojZmY2NjAxXFxcIj48Yj7ljoblj7LorrDlvZU8L2I+PC9zcGFuPicsXFxuICAgICAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9jbG9ja1xcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgICAgICB1cmw6ICQoW1xcXCLmuIXpmaTmkJzntKLorrDlvZVcXFwiLCBcXFwi5omT5byA6KeC55yL6K6w5b2VXFxcIl0pLnNlbGVjdCgoaWQpID0+IHtcXG4gICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLmuIXpmaTmkJzntKLorrDlvZVcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7lrprmuIXpmaTlhajpg6jmkJzntKLorrDlvZXvvJ9cXFwiKS5jb25maXJtKChpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoaWQgKyBcXFwiOmtleVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKGlkICsgXFxcIjpzZWFyY2hIaXN0b3J5XFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBpZCArIFxcXCI6a2V5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0sIGlkKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vaGlzdG9yeT9ydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGlkKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IGlkICsgXFxcIjpzZWFyY2hIaXN0b3J5XFxcIixcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIGxldCBoaXN0b3J5ID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIFtdKTtcXG4gICAgbGV0IGkgPSAwO1xcbiAgICBmb3IgKGxldCBrZXkgb2YgaGlzdG9yeSkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZToga2V5LFxcbiAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQsIGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgZXh0cmEgPSBmaW5kSXRlbShpZCArIFxcXCJzc1xcXCIpLmV4dHJhO1xcbiAgICAgICAgICAgICAgICBleHRyYS5kZWZhdWx0VmFsdWUgPSBrZXk7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oe1xcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IGV4dHJhXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0sIGlkLCBrZXkpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiZmxleF9idXR0b25cXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBpZCArIFxcXCI6a2V5OlxcXCIgKyBrZXksXFxuICAgICAgICAgICAgICAgIGNsczogaWQgKyBcXFwiOmtleVxcXCIsXFxuICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6Zmk5YWz6ZSu6K+NOlxcXCIgKyBrZXksXFxuICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoaWQsIGtleSwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBoaXN0b3J5ID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIFtdKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoaXN0b3J5LnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgaGlzdG9yeSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShpZCArIFxcXCI6a2V5OlxcXCIgKyBrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGlkLCBrZXksIGkpXFxuICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgaWYgKGhpc3RvcnkubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieWTpn5+flxcXCI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dGFia2V5ID0gaG90Q2xhc3Nbc2VsZWN0c291cmNlXVtzZWxlY3RrZXldO1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6ICc8c3BhbiBzdHlsZT1cXFwiY29sb3I6I2ZmNjYwMVxcXCI+PGI+JyArIHNlbGVjdHNvdXJjZSArIHNlbGVjdGtleSArICfng63mkJw8L2I+PC9zcGFuPicsXFxuICAgICAgICB1cmw6ICQoaG90a2V5cywgMSwgXFxcIuWIh+aNoueDreaQnFxcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwiaG90a2V5XFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2i5Li6XFxcIiArIGlucHV0O1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgICAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9maXJlXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIh+aNouaVsOaNrua6kFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChkYXRhU291cmNlKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChkYXRhU291cmNlLCAxLCBcXFwi5YiH5o2i5pWw5o2u5rqQXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJkYXRhU291cmNlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwiaG90a2V5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVm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AgICAgICAgICAgJ0FjY2VwdCc6ICdhcHBsaWNhdGlvbi9qc29uLCB0ZXh0L3BsYWluLCAqLyonLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICdBY2NlcHQtTGFuZ3VhZ2UnOiAnemgtQ04semg7cT0wLjksZW4tVVM7cT0wLjgsZW47cT0wLjcnLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICdBY2NlcHQtRW5jb2RpbmcnOiAnZ3ppcCwgZGVmbGF0ZSwgYnInLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vdG9wLmJhaWR1LmNvbS9ib2FyZD90YWI9bm92ZWwnLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgLy92YXIgcyA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgICAgIHZhciBsaXN0ID0gSlNPTi5wYXJzZShqc29uKS5kYXRhLmNhcmRzWzBdLmNvbnRlbnQ7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBsaXN0W2ldO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5hbWUgPSBpdGVtLndvcmQgKyAnICgnICsgaXRlbS5zaG93WzJdICsgJyknO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRlcyA9IGl0ZW0uZGVzYztcXG4gICAgICAgICAgICAgICAgICAgIHNkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRUaXRsZShpLCBuYW1lKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoc2V0U2VhcmNoS2V5LCBpdGVtLndvcmQpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGRlcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0ZW0uaW1nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibW92aWVfMV92ZXJ0aWNhbF9waWNcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICBjYXNlIFxcXCLlpLjlhYtcXFwiOlxcbiAgICAgICAgICAgICAgICB2YXIganNvbiA9IHJlcXVlc3QoXFxcImh0dHBzOi8vbmV3cy5teXF1YXJrLmNuL3YyL3RvcGxpc3QvbW92aWU/JmNoYW5uZWw9XFxcIiArIHRhYmtleSArIFxcXCImcmFua190eXBlPSVFNiU5QyU4MCVFNyU4MyVBRFxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgeG1sRGF0YSA9IChKU09OLnBhcnNlKGpzb24pLmRhdGEgfHwgXFxcIlxcXCIpLnJlcGxhY2UoL3RpdGxlPi9nLCBcXFwiaF90aXRsZT5cXFwiKS5yZXBsYWNlKC9zcmM+L2csIFxcXCJoX3NyYz5cXFwiKS5yZXBsYWNlKC9hcmVhPi9nLCBcXFwiaF9hcmVhXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBsaXN0ID0gcGRmYSh4bWxEYXRhLCBcXFwiYm9keSYmaXRlbVxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgZ2V0VGV4dCA9IHQgPT4gdDtcXG4gICAgICAgICAgICAgICAgdmFyIHRyZW5kID0gW1xcXCLjhKdcXFwiLCBcXFwi4oaRXFxcIiwgXFxcIuKGk1xcXCJdO1xcbiAgICAgICAgICAgICAgICAvL3ZhciBzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IHBkZmgoaXRlbSwgXFxcImhfdGl0bGUmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkZXMgPSBcXFwi54Ot5bqm77yaXFxcIiArIHBkZmgoaXRlbSwgXFxcImhvdF9zY29yZSYmVGV4dFxcXCIpICsgXFxcIiBcXFwiICsgdHJlbmQuYXQocGRmaChpdGVtLCBcXFwiaG90X3RyZW5kJiZUZXh0XFxcIikpICtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiXFxcXG7or4TliIbvvJpcXFwiICsgcGRmaChpdGVtLCBcXFwic2NvcmVfYXZnJiZUZXh0XFxcIikucmVwbGFjZSgvXjAkLywgXFxcIuaaguaXoOivhOWIhlxcXCIpICtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiXFxcXG5cXFwiICsgcGRmaChpdGVtLCBcXFwieWVhciYmVGV4dFxcXCIpICsgXFxcIsK3XFxcIiArIHBkZmgoaXRlbSwgXFxcImhfYXJlYSYmVGV4dFxcXCIpICsgXFxcIsK3XFxcIiArIHBkZmgoaXRlbSwgXFxcImNhdGVnb3J5JiZUZXh0XFxcIikucmVwbGFjZShcXFwiLFxcXCIsIFxcXCLCt1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgc2QucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGdldFRpdGxlKGksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZShzZXRTZWFyY2hLZXksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGRlcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IHBkZmgoaXRlbSwgXFxcImhfc3JjJiZUZXh0XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJtb3ZpZV8xX3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Y2UoJy9wcm94eT91cmw9JywgJycpLnNwbGl0KFxcXCImXFxcIilbMF0pO1xcbiAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgZXhwaXJlcyA9IHVybC5zcGxpdCgneC1vc3MtZXhwaXJlcz0nKVsxXS5zcGxpdCgnJicpWzBdO1xcbiAgICAgICAgY29uc3QgbGFzdHRpbWUgPSBwYXJzZUludChleHBpcmVzKSAtIERhdGUubm93KCkgLyAxMDAwO1xcbiAgICAgICAgaWYgKGxhc3R0aW1lIDwgNjApIHtcXG4gICAgICAgICAgICAvL2xvZygn6L+H5pyf5pu05pawJylcXG4gICAgICAgICAgICBsZXQgbGluZSA9IHVybC5zcGxpdCgnL21lZGlhJylbMF07IC8v5Y+W5LmL5YmN5pKt5pS+55qEdHPmrrXnur/ot69cXG4gICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcobGluZS5sYXN0SW5kZXhPZignLycpICsgMSk7XFxuICAgICAgICAgICAgbGV0IGYgPSBnZXRNM3U4Q29udGVudChnZXRBbGlQbGF5VXJsKGZpZCwgbGluZSkpLnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZnVybCA9IGJhc2U2NERlY29kZShpdC5yZXBsYWNlKCcvcHJveHk/dXJsPScsICcnKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGZ1cmw7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHVybDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHVybCA9IGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKTtcXG4gICAgICAgIGlmICh1cmwuaW5jbHVkZXMoXFxcIi50c1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiB1cGRhdGVUc1VybCh1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHRlbXBsYXRlSWQgPSBNWV9QQVJBTVMudGVtcGxhdGVJZFswXTtcXG4gICAgICAgICAgICBpZihmaWxlRXhpc3QoY2FjaGVGaWxlUGF0aCkpe1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2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ICB9XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aSreaUvuWksei0pe+8jOmUmeivr+S/oeaBr+W3suaJk+WNsOOAglxcXFxu6K+35p+l55yL5pel5b+XKExPRylcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IG1vdW50c3ViID0gc3RvcmFnZTAuZ2V0TXlWYXIoJ21vdW50emltdScsIHt9KTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhtb3VudHN1YikubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHppbXUgPSBtb3VudHN1YjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBzdWJ0aXRsZTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyh6aW11IHx8IHt9KS5sZW5ndGggPiAwICYmIHBsYXlMaXN0ICYmIHBsYXlMaXN0LnVybHMgJiYgcGxheUxpc3QudXJscy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgxMDApO1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHZhciB6bXVybCA9IGFsaUFjY2Vzc0FwaS5nZXRWaWRlb1RlbVBsYXlVcmwoemltdS5maWxlX2lkKTtcXG4gICAgICAgICAgICAgICAgbGV0IHBhdGggPSAnaGlrZXI6Ly9maWxlcy9jYWNoZS/kupHnm5jlkJsvc3ViLicgKyB6aW11LmV4dDtcXG4gICAgICAgICAgICAgICAgZG93bmxvYWRGaWxlKHptdXJsLCBwYXRoLCB7XFxuICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgc3VidGl0bGUgPSBnZXRQYXRoKHBhdGgpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIu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gc3R5bGVzID0gW1xcXCJ0ZXh0XzFcXFwiLCBcXFwibW92aWVfMlxcXCIsIFxcXCJjYXJkX3BpY18zXFxcIiwgXFxcImF2YXRhclxcXCIsIFxcXCLov73liadcXFwiLCBcXFwi55yL5Zu+XFxcIl07XFxuICAgIGxldCBzdHlsZSA9IGdldEl0ZW0oXFxcImFsaXl1bl9zdHlsZVxcXCIsIHN0eWxlc1swXSk7XFxuICAgIGlmIChNWV9QQUdFID09PSAxKSB7XFxuICAgICAgICBpZiAoIWdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCBcXFwiXFxcIikpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwibW91bnR6aW11XFxcIiwge30pO1xcbiAgICAgICAgICAgIGFkZExpc3RlbmVyKFxcXCJvbkNsb3NlXFxcIiwgJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcIm1vdW50emltdVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJhbGlTaGFyZVRva2VuXFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyVmFyKFxcXCJkbV9zaGFyZVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJkbWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwibGlzdFNlYXJjaEtleVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJkbV9saXN0VXJsTGlzdFxcXCIpO1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHNldE1hcmtlcigpO1xcbiAgICAgICAgaWYgKHJlYWx1cmwgJiYgIWlzU2VhcmNoKSB7XFxuICAgICAgICAgICAgbGV0IHNoYXJlSW5mbyA9IGFsaVNoYXJlQXBpLmdldFNoYXJlSW5mbygpO1xcbiAgICAgICAgICAgIGxldCBmaWxlSW5mbyA9IHNoYXJlSW5mby5maWxlX2luZm9zIHx8IFtdO1xcbiAgICAgICAgICAgIGlmIChmaWxlSW5mby5sZW5ndGggPT09IDEgJiYgZmlsZUluZm9bMF0udHlwZSA9PT0gXFxcImZvbGRlclxcXCIgJiYgIWZpbGVJZCkge1xcbiAgICAgICAgICAgICAgICBmaWxlSWQgPSBmaWxlSW5mb1swXS5maWxlX2lkO1xcbiAgICAgICAgICAgICAgICBzZXRNeVBhQ2FjaGUoXFxcImZpbGVJZFxcXCIsIGZpbGVJZCk7XFxuICAgICAgICAgICAgICAgIHNldFBhZ2VUaXRsZShmaWxlSW5mb1swXS5maWxlX25hbWUpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHNldFBhZ2VUaXRsZShzaGFyZUluZm8uc2hhcmVfbmFtZSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBkZWFkbGluZSA9IFxcXCLmsLjkuYXmnInmlYhcXFwiO1xcblxcbiAgICAgICAgICAgIGlmIChzaGFyZUluZm8uZXhwaXJhdGlvbikge1xcbiAgICAgICAgICAgICAgICBkZWFkbGluZSA9IFxcXCLmnInmlYjoh7PvvJpcXFwiICsgZm9ybWF0RGF0ZShzaGFyZUluZm8uZXhwaXJhdGlvbik7XFxuICAgICAgICAgICAgICAgIC8vc2hhcmVJbmZvLnVwZGF0ZWRfYXRcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAoc2hhcmVJbmZvLmNyZWF0b3JfbmFtZSB8fCBzaGFyZUluZm8uY3JlYXRvcl9waG9uZSkgKyBcXFwiJm5ic3A7Jm5ic3A7XFxcIiArIGRlYWRsaW5lLnNtYWxsKCksXFxuICAgICAgICAgICAgICAgIHVybDogcmVhbHVybCArIFxcXCIjbm9IaXN0b3J5I1xcXCIsXFxuICAgICAgICAgICAgICAgIGltZzogc2hhcmVJbmZvLmF2YXRhciB8fCBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl91bmtub3duXFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJhdmF0YXJcXFwiXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoIWlzU2VhcmNoKSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pCc57SiXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWFs+mUruivjVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9hbGl5dW4jbm9IaXN0b3J5IyNmdWxsVGhlbWUjP3BhZ2U9ZnlwYWdlJnNlYXJjaEtleT1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6IFxcXCJwdXRNeVZhcignbGlzdFNlYXJjaEtleScsaW5wdXQpXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBzaGFyZVRva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHNlYXJjaEtleSArIFxcXCLigJ3igJ3nmoTmkJzntKLnu5PmnpxcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZnVuY0l0ZW1zID0gW107XFxuICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IHN0eWxlLFxcbiAgICAgICAgICAgIHVybDogJChzdHlsZXMsIDEsIFxcXCLmjpLluIPmoLflvI9cXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fc3R5bGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliIfmjaJcXFwiO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9pY29uLnN2Z1xcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogb3JkZXJOYW1lLFxcbiAgICAgICAgICAgIHVybDogJChvcmRlcnNLZXlzLCAyLCBcXFwi5o6S5bqP5pa55byPXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXV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orr7nva7mlLbol4/lsIHpnaJcXFwiLCBcXFwi6I635Y+W5oqV5bGPSVBcXFwiICwgXFxcIuaegemAn+WOn+eUu+S4i+i9vee6v+eoi1xcXCIgLCBcXFwi6L2s5a2Y5b2T5YmN5paH5Lu25aS5XFxcIl0sIDIsIFxcXCLmm7TlpJrlip/og71cXFwiKS5zZWxlY3QoKHNoYXJlSWQsIHNoYXJlUHdkLCBmaWxlSWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLovazlrZjkupHnm5hcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHNtYXJ0ZHJpdmU6Ly9zaGFyZS9icm93c2U/c2hhcmVJZD0ke3NoYXJlSWR9JnNoYXJlUHdkPSR7c2hhcmVQd2R8fFxcXCJcXFwifWA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi55m76ZmG6LSm5Y+3XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbG9naW4jbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLlpI3liLbliIbkuqvpk77mjqVcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIuWkjeWItumTvuaOpVxcXCIsIFxcXCLlpI3liLbmtbfpmJTlj6Pku6RcXFwiXSwgMSwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgodXJsKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLlpI3liLbpk77mjqVcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIHVybDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8v6Zi/6YeM5LqR55uY5YiG5Lqr5Y+j5Luk44CMXFxcIiArIGdldFBhZ2VUaXRsZSgpICsgXFxcIuOAjVxcXFxuXFxcIiArIHVybCArIFxcXCIgQGltcG9ydD1qczpgaGlrZXI6Ly9wYWdlL2FsaXl1bj9yZWFsdXJsPSR7aW5wdXQudHJpbSgpfSZydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcImA7XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL1xcXCIgKyBzaGFyZUlkICsgKGZpbGVJZCA/IFxcXCIvZm9sZGVyL1xcXCIgKyBmaWxlSWQgOiBcXFwiXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaJuemHj+aMgui9veacrOWcsOW8ueW5lVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2RtTW91bnQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmn6XnnIvmiYvliqjmjILovb3lrZfluZVcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgem0gPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwibW91bnR6aW11XFxcIiwge30pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGlwID0gem0ubmFtZSA/IFxcXCLlvZPliY3lrZfluZXmlofku7ZcXFxcblxcXCIgKyB6bS5uYW1lICsgXFxcIi5cXFwiICsgem0uZXh0IDogXFxcIui/mOacquaJi+WKqOaMgui9veWtl+W5lVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6ICfmiYvliqjmjILovb3lrZfluZUnLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudDogdGlwICsgXFxcIlxcXFxuKOeCueWHu+WPlua2iOWPr+S7pea4hemZpOaMgui9veWtl+W5lSlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsOiAoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwibW91bnR6aW11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sua4hemZpOaJi+WKqOaMgui9veWtl+W5lVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6I635Y+W5by55bmV5pCc57Si6KeE5YiZXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwianNcXFwiOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL2xvYWREbT9ydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIiZ0aXRsZT1cXFwiKSArIFxcXCIrZW5jb2RlVVJJQ29tcG9uZW50KHBsYXlkYXRhLnRpdGxlLnNwbGl0KCctJylbMF0pO1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwibmFtZVxcXCI6IE1ZX1JVTEUudGl0bGUgKyBcXFwi5by55bmV5pCc57SiXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInJ1bGU6Ly9cXFwiICsgYmFzZTY0RW5jb2RlKFxcXCLvv6Vwcm9qZWN0aW9uX3NjcmVlbu+/pVxcXCIgKyBKU09OLnN0cmluZ2lmeShydWxlKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5o6o6YCB5YiwVFZCb3hcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS90dmJveFB1c2gjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLorr7nva7mlLbol4/lsIHpnaJcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIuiuvue9ruWwgemdouWcsOWdgFxcXCIsIFxcXCLmkJzntKLlsIHpnaJcXFwiXSwgMSkuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIuiuvue9ruWwgemdouWcsOWdgFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIiwgXFxcIuivt+i+k+WFpeWbvueJh+WcsOWdgFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC50cmltKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXlnLDlnYBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRQYWdlUGljVXJsKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S/ruaUueaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2Zyb250Q292ZXIjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6I635Y+W5oqV5bGPSVBcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaXAgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKS5nZXRJUHY0QWRkcmVzcygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXAuc3RhcnRzV2l0aChcXFwiMTkyLjE2OC5cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXAgKyBcXFwiXFxcXG7or6VJUOmAgueUqOS6jua1gemHjyvng63ngrnnmoTmipXlsY9cXFxcbuivt+abv+aNoumTvuaOpeS4reeahDAuMC4wLjBcXFwiKS5jb25maXJtKChpcCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBpcDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGlwKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGlwICsgXFxcIlxcXFxu6I635Y+W5aSx6LSl6Z2e56iz5a6aSVAs6K+35byA5ZCv54Ot54K55YaN5L2/55SoLOivpUlQ5Y+v6IO95Lya5Y+YLOS4jeiDveaKleWxj1xcXCIpLmNvbmZpcm0oKCkgPT4ge30pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5p6B6YCf5Y6f55S75LiL6L2957q/56iLXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoZ2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBcXFwiMTBcXFwiKSwgXFxcIuivt+i+k+WFpTMtMzLkuYvpl7TnmoTmlbTmlbBcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3BlZWRUaHJlYWQgPSBwYXJzZUludChpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3BlZWRUaHJlYWQgPCAzIHx8IHNwZWVkVGhyZWFkID4gMzIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNwZWVkVGhyZWFkXFxcIiwgU3RyaW5nKHNwZWVkVGhyZWFkKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6L2s5a2Y5b2T5YmN5paH5Lu25aS5XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgc2hhcmVJZCwgc2hhcmVQd2QsIGZpbGVJZCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9maWxlaW50by5zdmdcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZUlkOiBwYWdlSWQsXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBzaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXI6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBmb2xkZXJOYW1lOiBnZXRQYWdlVGl0bGUoKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFtcXFwiQUxMXFxcIiwgXFxcIui3s+i/h+aWh+S7tlxcXCJdW051bWJlcihza2lwRmlsZSldLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHNraXBGaWxlKSA9PiB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1lLmVuZHNXaXRoKFxcXCIuY2hzXFxcIikpKTtcXG4gICAgLy9lbmRcXG4gICAgbGV0IHRpdGxlSGVhZCA9IHtcXG4gICAgICAgIHZpZGVvOiBcXFwi8J+OrFxcXCIsXFxuICAgICAgICBhdWRpbzogXFxcIvCfjrVcXFwiLFxcbiAgICAgICAgZG9jOiBcXFwi8J+TkVxcXCIsXFxuICAgICAgICBpbWFnZTogXFxcIvCflrxcXFwiLFxcbiAgICAgICAgemlwOiBcXFwi8J+TplxcXCIsXFxuICAgICAgICBmb2xkZXI6IFxcXCLwn5OCXFxcIlxcbiAgICB9O1xcblxcbiAgICBmdW5jdGlvbiBnZXRIZWFkKHR5cGUsIGV4dCkge1xcbiAgICAgICAgbGV0IGhlYWQgPSB0aXRsZUhlYWRbdHlwZV07XFxuICAgICAgICBpZiAoc3ViRXh0cy5pbmNsdWRlcyhleHQpKSB7XFxuICAgICAgICAgICAgaGVhZCA9IFxcXCLwn5W4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBoZWFkIHx8IFxcXCLinZNcXFwiO1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHtcXG4gICAgICAgIGlmIChmaWxlSXRlbS50aHVtYm5haWwpIHtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwiaHR0cHM6Ly9lbXB0eT9cXFwiICsgZmlsZUl0ZW0uZmlsZV9pZCkuaW1hZ2UoKHBpYykgPT4ge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoKHBpYywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0U3RyZWFtOiB0cnVlXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XFxuICAgICAgICAgICAgICA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gICAgICAgICAgICAgICAgdXJsOiAnaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZScsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBmb2xkZXJTdHlsZSxcXG4gICAgICAgICAgICAgICAgZGVzYzogZm9ybWF0RGF0ZShmaWxlSXRlbS51cGRhdGVkX2F0KSxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogcGljX3VybCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBNWV9QQVJBTVMuc2hhcmVUb2tlbixcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUl0ZW0uZmlsZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZCxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgbm9QaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLovazlrZhcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL215YWxpeXVuI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9wYWdlPWZ5cGFnZVxcXCIpXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2UgaWYgKG5vU2tpcEZpbGUpIHtcXG4gICAgICAgICAgICBpZiAoZmlsdGVyVHlwZS5sZW5ndGggPiAwICYmICFmaWx0ZXJUeXBlLmluY2x1ZGVzKGNhdGUpKSB7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgc3VidGl0bGUsIGNscywgbG9uZ2MgPSBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui9rOWtmFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL215YWxpeXVuI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9wYWdlPWZ5cGFnZVxcXCIpXFxuICAgICAgICAgICAgfV07XFxuICAgICAgICAgICAgbGV0IHRpdGxlID0gZmlsZUl0ZW0ubmFtZTtcXG4gICAgICAgICAgICBsZXQgbmFtZU5vdEV4dCA9IGZpbGVJdGVtLm5hbWUucmVwbGFjZSgnLicgKyBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbiwgJycpO1xcbiAgICAgICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uKSkge1xcbiAgICAgICAgICAgICAgICBsb25nYy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5oyC6L295a2X5bmVXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh6bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdtb3VudHppbXUnLCB6bSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+aMgui9veWujOaIkO+8jOW9k+WJjeWtl+W5leaWh+S7tjogJyArIHptLm5hbWUgKyAnLicgKyB6bS5leHQ7XFxuICAgICAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0OiBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2lkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IG5hbWVOb3RFeHRcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGNhdGUgPT09IFxcXCJ2aWRlb1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHppbXVsaXN0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgc3VidGl0bGUgPSB6aW11bGlzdC5maW5kKHYgPT4gdi5uYW1lLmluY2x1ZGVzKG5hbWVOb3RFeHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjbHMgPSBcXFwicGxheWxpc3QgdlxcXCIgKyBwYWdlSWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChmaWxlU3R5bGUgPT09IFxcXCJ0ZXh0XzFcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGRlc2MgKz0gXFxcIlxcXFx0XFxcXHRcXFwiICsgZm9ybWF0U2l6ZShmaWxlSXRlbS5zaXplKTtcXG4gICAgICAgICAgICAgICAgdGl0bGUgPSBnZXRIZWFkKGNhdGUsIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uKSArIHRpdGxlO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoW1xcXCJ2aWRlb1xcXCIsIFxcXCJpbWFnZVxcXCJdLmluY2x1ZGVzKGNhdGUpKSB7XFxuICAgICAgICAgICAgICAgIHBpY191cmwgPSBnZXRQcmV2aWV3UGljKGZpbGVJdGVtKSB8fCBwaWNfdXJsO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub1ByZSNcXFwiKS5sYXp5UnVsZSgoc2hhcmVJZCwgc2hhcmVQd2QsIHNoYXJlVG9rZW4sIGZpbGVJZCwgY2F0ZSwgc3VidGl0bGUpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS9hbGlsYXp5XFxcIikoc2hhcmVJZCwgc2hhcmVQd2QsIHNoYXJlVG9rZW4sIGZpbGVJZCwgY2F0ZSwgc3VidGl0bGUpO1xcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUlkLCBzaGFyZVB3ZCwgTVlfUEFSQU1TLnNoYXJlVG9rZW4sIGZpbGVJdGVtLmZpbGVfaWQsIGNhdGUsIHN1YnRpdGxlKSxcXG4gICAgICAgICAgICAgICAgZGVzYzogZGVzYyxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogcGljX3VybCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXI6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUluZm86IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBzaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZCxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IGxvbmdjLFxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBjbHMsXFxuICAgICAgICAgICAgICAgICAgICAvL2luaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWVcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGZpbGVTdHlsZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGlmIChjb250cy5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieS6huWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9XFxufVxcblxcbmxldCBpdGVtcyA9IFtdO1xcbnRyeSB7XFxuICAgIGlmIChNWV9QQUdFID4gMSAmJiAhTVlfUEFSQU1TLm1hcmtlcikge1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5LqG5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBsb2FkKGl0ZW1zKTtcXG4gICAgfVxcbn0gY2F0Y2ggKGUpIHtcXG4gICAgaWYgKGUubmFtZSA9PT0gXFxcIkFsaUVycm9yXFxcIikge1xcbiAgICAgICAgaWYgKGUuY29kZSA9PT0gXFxcIkludmFsaWRSZXNvdXJjZS5TaGFyZVB3ZFxcXCIpIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLor7fovpPlhaXmj5Dlj5bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBzaGFyZVB3ZCA/IFxcXCLigJzigJzmj5Dlj5bnoIHplJnor6/igJ3igJ1cXFwiIDogXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJCgpLmlucHV0KChNWV9QQVJBTVMpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldFBhZ2VQYXJhbXMoT2JqZWN0LmFzc2lnbih7fSwgTVlfUEFSQU1TLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IGlucHV0XFxuICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9LCBNWV9QQVJBTVMpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChlLnNpZ25pZmljYW5jZSA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIGUubWVzc2FnZS5iaWcoKS5iaWcoKS5mb250Y29sb3IoXFxcInJlZFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudGVyXzEnLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGUuc2lnbmlmaWNhbmNlID09PSAzKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgZS5tZXNzYWdlLmJpZygpLmZvbnRjb2xvcihcXFwiZ3JlZW5cXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0X2NlbnRlcl8xJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuXFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBsb2coXFxcIuWIl+ihqOWKoOi9veWksei0pSNcXFxcbumUmeivr+S/oeaBrz5cXFwiICsgZS50b1N0cmluZygpICsgXFxcIlxcXFxu6ZSZ6K+v6KGMPlxcXCIgKyBlLmxpbmVOdW1iZXIpO1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICfmrKfmrKfvvIzmiqXplJnkuobjgILlnKjliLfmlrDlh6DmrKHvvJ/miJbogIXmm7TmjaLmlofku7blpLnjgIInLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGRlc2M6IGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudG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ldCBlcnJvckNvdW50ID0gMDtcXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCAzMDsgaSsrKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCByZXN1bHQgPSBKU09OLnBhcnNlKHBvc3QoXFxcImh0dHBzOi8vcGFzc3BvcnQuYWxpeXVuZHJpdmUuY29tL25ld2xvZ2luL3FyY29kZS9xdWVyeS5kbz9hcHBOYW1lPWFsaXl1bl9kcml2ZSZmcm9tU2l0ZT01MiZfYngtdj0yLjIuM1xcXCIsIHtcXG4gICAgICAgICAgICAgICAgYm9keTogYm9keVxcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICBsZXQgcXJDb2RlU3RhdHVzID0gcmVzdWx0LmNvbnRlbnQuZGF0YS5xckNvZGVTdGF0dXM7XFxuXFxuICAgICAgICAgICAgaWYgKHFyQ29kZVN0YXR1cyA9PT0gXFxcIkNPTkZJUk1FRFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHJlc3VsdC5jb250ZW50LmRhdGEuYml6RXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaW5mbyA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKHJlc3VsdC5jb250ZW50LmRhdGEuYml6RXh0KSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgYWxpVG9rZW5zRmlsZXBhdGggPSAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS90b2tlblBhdGhcXFwiKS5hbGlUb2tlbnNGaWxlcGF0aDtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBhbGlUb2tlbiA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiBpbmZvLnBkc19sb2dpbl9yZXN1bHQucmVmcmVzaFRva2VuXFxuICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKGFsaVRva2Vuc0ZpbGVwYXRoLCBKU09OLnN0cmluZ2lmeShhbGlUb2tlbikpO1xcbiAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJsb2dpbnlcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnmbvlvZXmiJDlip8o54K55Ye76L+U5ZueKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgYmFja0hvbWUoXFxcIueZu+W9leaIkOWKn1xcXCIsIHRydWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYmFja0hvbWUoXFxcIueZu+W9leWksei0pSzor7flsJ3or5Xlhbbku5bnmoTmlrnms5VcXFwiKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChxckNvZGVTdGF0dXMgPT09IFxcXCJDQU5DRUxFRFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgYmFja0hvbWUoXFxcIuWPlua2iOeZu+W9leaOiOadg1xcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChbXFxcIk5FV1xcXCIsIFxcXCJTQ0FORURcXFwiXS5pbmNsdWRlcyhxckNvZGVTdGF0dXMpKSB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AgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCIyXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV90dmJveFxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjNcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX1hCWVxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjRcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX3R2XFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiMFxcXCI6XFxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfYWxpc3RcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdGhpcy5fb3BlblRvb2xzID0gbmV3IE9wZW5BcGlUb29scyh0aGlzKTtcXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fb3BlblRvb2xzO1xcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsIFxcXCJvcGVuVG9rZW5zXFxcIiwge1xcbiAgICAgICAgZ2V0KCkge1xcbiAgICAgICAgICAgIGlmICh0aGlzLl9vcGVuVG9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ICAgdGhyb3cgZXJyO1xcbiAgICAgICAgfSkuZXJyb3JUeXBlKChlcnIsIHJlcykgPT4ge1xcbiAgICAgICAgICAgIGxldCByZXN1bHQgPSB7fTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICByZXN1bHQgPSBKU09OLnBhcnNlKHJlcy5ib2R5KTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlcnI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByYm9keSA9IChyZXN1bHQuY29kZSA/IHJlc3VsdCA6IChyZXN1bHQgJiYgcmVzdWx0LnJlc3BvbnNlcyAmJiByZXN1bHQucmVzcG9uc2VzWzBdICYmIHJlc3VsdC5yZXNwb25zZXNbMF0uYm9keSkpIHx8IHt9O1xcbiAgICAgICAgICAgIGlmIChyYm9keS5jb2RlKSB7XFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSByYm9keS5kaXNwbGF5X21lc3NhZ2UgfHwgcmJvZHkubWVzc2FnZTtcXG4gICAgICAgICAgICAgICAgbGV0IGVycm9yID0gbmV3IEVycm9yKGFwaSArIFxcXCI9PlxcXCIgKyByYm9keS5jb2RlICsgXFxcIjpcXFwiICsgbXNnKTtcXG4gICAgICAgICAgICAgICAgZXJyb3IuY29kZSA9IHJib2R5LmNvZGU7XFxuICAgICAgICAgICAgICAgIGVycm9yLmp1ZGdlTXNnID0gbXNnO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZXJyb3I7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBlcnI7XFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgc2V0TXlEcml2aWRUeXBlKGlzQmFja3VwKSB7XFxuICAgICAgICB0aGlzLm15RHJpdmlkVHlwZSA9ICEhaXNCYWNrdXA7XFxuICAgICAgICByZXR1cm4gdGhpcztcXG4gICAgfSxcXG4gICAgdHJ5U29sdmUoZSkge1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9rZW47XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmICgob3JpZ2luRGVmZERyaXZlSWQgIT09IHRoaXMuYWxpVG9rZW5zLmRlZmF1bHRfZHJpdmVfaWQpIHx8IHRoaXMuYWxpVG9rZW5zLnJlc291cmNlX2RyaXZlX2lkID09PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc291cmNlX2RyaXZlX2lkID0gdGhpcy5nZXRVc2VySW5mbygpLnJlc291cmNlX2RyaXZlX2lkO1xcbiAgICAgICAgICAgICAgICB0aGlzLmFsaVRva2Vucy5yZXNvdXJjZV9kcml2ZV9pZCA9IHJlc291cmNlX2RyaXZlX2lkO1xcbiAgICAgICAgICAgICAgICBpZiAocmVzb3VyY2VfZHJpdmVfaWQpIHtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmRHJpdmVJZCA9IHJlc291cmNlX2RyaXZlX2lkO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWZEcml2ZUlkID0gdGhpcy5hbGlUb2tlbnMuZGVmYXVsdF9kcml2ZV9pZDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIueUqOaIt+S/oeaBr+iOt+WPluWksei0pe+8mlxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgdGhpcy5yZWZyZXNoQWNjZXNzQ2FsbEJhY2socmVzdWx0LCB0aGlzKTtcXG4gICAgICAgIHJldHVybiB0aGlzLmFsaVRva2VucztcXG4gICAgfSxcXG4gICAgZ2V0VXNlckluZm8oKSB7XFxuICAgICAgICBsZXQgaW5mbyA9IHRoaXMucG9zdEFwaShcXFwiaHR0cHM6Ly91c2VyLmFsaXl1bmRyaXZlLmNvbS92Mi91c2VyL2dldFxcXCIpL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RdW90YUV4aGF1c3RlZC5Ecml2ZVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgZTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKCF0aGlzLnRyeVNvbHZlKGUpKSB7XFxuICAgICAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDIwKS5yZWZyZXNoQWNjZXNzVG9rZW4oKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGJvZHkgPSBodHRwLm9wdGlvbnMuYm9keS5yZXF1ZXN0c1swXS5ib2R5O1xcbiAgICAgICAgICAgIGlmIChib2R5LmRyaXZlX2lkKSB7XFxuICAgICAgICAgICAgICAgIGJvZHkuZHJpdmVfaWQgPSB0aGlzLmdldE15RHJpdmlkKCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChib2R5LnRvX2RyaXZlX2lkKSB7XFxuICAgICAgICAgICAgICAgIGJvZHkudG9fZHJpdmVfaWQgPSB0aGlzLmdldE15RHJpdmlkKCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtc2hhcmUtdG9rZW4nOiB0aGlzLnNoYXJlVG9rZW5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gcmVzdWx0O1xcbiAgICB9LFxcbiAgICBjb3B5RmlsZVRvQ2xvdWRGaWxlKGZpbGVJZCwgcGFyZW50RmlsZUlkLCByZXRyeSkge1xcbiAgICAgICAgbGV0IHJlc3VsdCA9IHRo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2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB0aGlzLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDUwKTtcXG4gICAgICAgICAgICBuZXdTaWduID0gY2FsY3VsYXRlTmV3U2lnbigpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwdWJLZXlcXFwiOiBuZXdTaWduLnB1YktleVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgICAgICdYLVNoYXJlLVRva2VuJzogdGhpcy5zaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtZGV2aWNlLWlkJzogdGhpcy5hbGlUb2tlbnMuZGV2aWNlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtc2lnbmF0dXJlJzogbmV3U2lnbi5zaWduYXR1cmVcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuZXJyb3IoKGVyciwgcmVzKSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuIHt9O1xcbiAgICAgICAgfSkuc3VjY2VzcygoYm9keSkgPT4ge1xcbiAgICAgICAgICAgIHJldHVybiBib2R5O1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICBpZiAocmVzdWx0LnN1Y2Nlc3MpIHtcXG4gICAgICAgICAgICByZXR1cm4gbmV3U2lnbjtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgd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SArIFxcXCIgXFxcIiArIG9yZGVyRGlyZWN0aW9uLFxcbiAgICAgICAgICAgIFxcXCJtYXJrZXJcXFwiOiBtYXJrZXIgfHwgdW5kZWZpbmVkXFxuICAgICAgICB9KS5oZWFkZXJzKHtcXG4gICAgICAgICAgICAnVXNlci1BZ2VudCc6IFBDX1VBLFxcbiAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nLFxcbiAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgyLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDIwKS5yZWZyZXNoQWNjZXNzVG9rZW4oKTtcXG4gICAgICAgICAgICAvL3RoaXMud2FpdFNsZWVwKDMwKS50cnlPcGVuQXBpU29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUa1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhyZXN1bHQpLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgIHJlc3VsdC5pdGVtcyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcXG4gICAgfSxcXG4gICAgc2lnbkluUmV3YXJkKCkge1xcbiAgICAgICAgbGV0IHNpbERhdGEgPSB0aGlzLnBvc3RBcGkoJ2h0dHBzOi8vbWVtYmVyLmFsaXl1bmRyaXZlLmNvbS92MS9hY3Rpdml0eS9zaWduX2luX2xpc3QnKS5ib2R5KHtcXG4gICAgICAgICAgICAnZ3JhbnRfdHlwZSc6ICdyZWZyZXNoX3Rva2VuJyxcXG4gICAgICAgICAgICAncmVmcmVzaF90b2tlbic6IHRoaXMuYWxpVG9rZW5zLnJlZnJlc2hfdG9rZW5cXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAnYXBwbGljYXRpb24vanNvbidcXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgdGhpcy50cnlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG5cXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ3JlZnJlc2hfdG9rZW4nOiB0aGlzLmFsaVRva2Vucy5yZWZyZXNoX3Rva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgbGV0IGRheSA9IHNpbERhdGEucmVzdWx0LnNpZ25JbkNvdW50O1xcbiAgICAgICAgbGV0IGlzUmV3YXJkID0gc2lsRGF0YS5yZXN1bHQuc2lnbkluTG9nc1tkYXkgLSAxXS5pc1Jld2FyZDtcXG4gICAgICAgIGlmIChpc1Jld2FyZCkge1xcbiAgICAgICAgICAgIGxldCByZXdhcmQgPSBzaWxEYXRhLnJlc3VsdC5zaWduSW5Mb2dzW2RheSAtIDFdLnJld2FyZDtcXG4gICAgICAgICAgICBpZiAocmV3YXJkKSB7XFxuICAgICAgICAgICAgICAgIGxldCByZXdub3RpY2UgPSByZXdhcmQubm90aWNlO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcIuS7iuWkqeW3sue7j+etvuWIsO+8jOivt+S4jeimgemHjeWkjeetvuWIsO+8gVxcXFxuXFxcIiArIHJld25vdGljZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAvL+ayoeacieWlluWKse+8jOWPquacieW5uOi/kOetvuWQjeeJh1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcIuS7iuWkqeW3sue7j+etvuWIsO+8jOivt+S4jeimgemHjeWkjeetvuWIsO+8gVxcXFxu5LuK5pel5aW96L+Q562+OlxcXCIgKyBzaWxEYXRhLnJlc3VsdC5ibGVzc2luZztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBzaXJEYXRhID0gdGhpcy5wb3N0QXBpKCdodHRwczovL21lbWJlci5hbGl5dW5kcml2ZS5jb20vdjEvYWN0aXZpdHkvc2lnbl9pbl9yZXdhcmQnKS5ib2R5KHtcXG4gICAgICAgICAgICAgICAgXFxcInNpZ25JbkRheVxcXCI6IGRheVxcbiAgICAgICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJ1xcbiAgICAgICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgIC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YgKHR5cGVvZiBvcHRpb25zLmJvZHkgPT09IFxcXCJvYmplY3RcXFwiICYmIHRoaXMuX2JvZHlUb1N0cmluZykge1xcbiAgICAgICAgICAgIG9wdGlvbnMuYm9keSA9IEpTT04uc3RyaW5naWZ5KG9wdGlvbnMuYm9keSk7XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgcmVzID0gSlNPTi5wYXJzZSh0aGlzLnN0YXJ0UmVxdWVzdCh0aGlzLnVybCwgb3B0aW9ucykpO1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBpZiAocmVzLnN0YXR1c0NvZGUgPj0gMjAwICYmIHJlcy5zdGF0dXNDb2RlIDw9IDMwMCkge1xcbiAgICAgICAgICAgICAgICBsZXQgYm9keSA9IHJlcy5ib2R5O1xcbiAgICAgICAgICAgICAgICBpZiAodG9Kc29uKSB7XFxuICAgICAgICAgICAgICAgICAgICBib2R5ID0gSlNPTi5wYXJzZShib2R5KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zdWNjZXNzQ2FsbGJhY2soYm9keSwgcmVzKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoU3RyaW5nKHJlcy5zdGF0dXNDb2RlKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgZXJyID0gdGhpcy5lcnJvclR5cGVDYWxsYmFjayhlcnIsIHJlcyk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodGhpcy5yZXRyeUNvdW50KSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCB0cnlSZXN1bHQgPSB0aGlzLmVycm9yQ2FsbGJhY2tXaXRoUmV0cnkoZXJyLCByZXMsIHRoaXMpO1xcbiAgICAgICAgICAgICAgICBpZiAodHJ5UmVzdWx0KSB7XFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJldHJ5Q291bnQtLTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnN0YXJ0KHRvSnNvbik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJldHJ5Q291bnQgPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZXJyb3JDYWxsYmFjayhlcnIsIHJlcyk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lcnJvckNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNldE9wdGlvbnMob3B0aW9ucykge1xcbiAgICAgICAgdGhpcy5vcHRpb25zID0gT2JqZWN0LmFzc2lnbih7fSwgb3B0aW9ucywge1xcbiAgICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlXFxuICAgICAgICB9KTtcXG4gICAgICAgIHJldHVybiB0aGlzO1xcbiAgICB9LFxcbiAgICBtZXJnZUhlYWRBbmRCb2R5KG9wdGlvbnMpIHtcXG4gICAgICAgIG9wdGlvbnMgPSBvcHRpb25zIHx8IHt9O1xcbiAgICAgICAgdGhpcy5vcHRpb25zLmhlYWRlcnMgPSBPYmplY3QuYXNzaWduKHRoaXMub3B0aW9ucy5oZWFkZXJzLCBvcHRpb25zLmhlYWRlcnMpO1xcbiAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9wdGlvbnMuYm9keSA9PT0gXFxcIm9iamVjdFxcXCIgJiYgdHlwZW9mIG9wdGlvbnMuYm9keSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICB0aGlzLm9wdGlvbnMuYm9keSA9IE9iamVjd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29udmVydDogMVxcbiAgICB9KSkpO1xcbiAgICBsZXQgZE1jb250ZXh0ID0gXFxcIlxcXCI7XFxuICAgIC8vbGV0IGZwc20gPSBnZXRSZWZyZXNoUmF0ZSgpLzYwKjAuOTU7XFxuICAgIC8vZGFuTXVEYXRhLmNvbW1lbnRzLnNvcnQoKHYseCk9PnYucC5zcGxpdChcXFwiLFxcXCIpWzBdLXgucC5zcGxpdChcXFwiLFxcXCIpWzBdKTtcXG4gICAgZm9yIChsZXQgY29tbWVudCBvZiBkYW5NdURhdGEuY29tbWVudHMpIHtcXG4gICAgICAgIC8vZE1jb250ZXh0ICs9IGA8ZCBwPVxcXCIke01hdGgucm91bmQodGltZXBvaW50KX0sJHtjdH0sJHtzaXplfSwke2NvbG9yfSwwXFxcIj4ke2NvbnRlbnR9PC9kPlxcXFxuYDtcXG4gICAgICAgIGxldCBwYXJhbVRleHQgPSBjb21tZW50LnA7XFxuICAgICAgICBsZXQgY29tbWVudFRleHQgPSBjb21tZW50Lm07XFxuICAgICAgICBpZiAocGFyYW1UZXh0ID09IG51bGwgfHwgY29tbWVudFRleHQgPT0gbnVsbCkgY29udGludWU7XFxuICAgICAgICBsZXQgcGFyYW1zID0gcGFyYW1UZXh0LnNwbGl0KFxcXCIsXFxcIik7XFxuICAgICAgICBsZXQgcGFyYW1zVCA9IFtdO1xcbiAgICAgICAgZm9yIChsZXQgaSBpbiBwYXJhbXMpIHtcXG4gICAgICAgICAgICAvKmlmIChpID09IDApIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKHBhcnNlSW50KHBhcmFtc1tpXSkpO1xcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICBpZiAoaSA9PSAyKSB7XFxuICAgICAgICAgICAgICAgIHBhcmFtc1QucHVzaChcXFwiMjVcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGkgPT0gMykge1xcbiAgICAg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jogbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwb3NcXFwiOiBwb3NcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICB1cmxJbmZvID0gSlNPTi5wYXJzZSh1cmxJbmZvKTtcXG4gICAgICAgICAgICBpZiAoIXVybEluZm8udXJsKSB0aHJvdyBcXFwi5pqC5pe25rKh5pyJ5om+5Yiw6K+l6KeG6aKR55qE5by55bmVXFxcIjtcXG4gICAgICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwoXFxcImh0dHBzOi8vYXp1cmUubGV1c2UudG9wL2Rhbm11XFxcIiwge1xcbiAgICAgICAgICAgICAgICBwYXJhbXM6IHVybEluZm9cXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICBpZiAoIXhtbCkge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBcXFwi6L+Y5rKh5pyJ5by55bmV5ZOfflxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvY2FjaGUvZGFubXUvXFxcIiArIHVybEluZm8ucGxhdGZvcm0gKyBcXFwiX1xcXCIgKyBuYW1lICsgXFxcIl9cXFwiICsgcG9zICsgXFxcIi54bWxcXFwiO1xcbiAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCAnPD94bWwgdmVyc2lvbj1cXFwiMS4wXFxcIiBlbmNvZGluZz1cXFwiVVRGLThcXFwiPz5cXFxcbicgKyB4bWwpO1xcbiAgICAgICAgICAgIGlmIChvbmx5RG93bmxvYWQpIHJldHVybiBcXFwidG9hc3Q6Ly/kuIvovb3lrozmiJBcXFwiO1xcbiAgICAgICAgICAgIHJlZnJlc2hWaWRlb1VybCh7XFxuICAgICAgICAgICAgICAgIGRhbm11OiBwYXRoXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WKoOi9veWujOaIkFxcXCI7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgIH1cXG4gICAgfSwgb25seURvd25sb2FkKSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiXFxufSk7XFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCJkbeebkuWtkOaQnOe0olxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoa2V5LCBvbmx5RG93bmxvYWQpID0+IHtcXG4gICAgICAgIGxldCBkbSA9IGdldFZhcihcXFwiZG1fc2hhcmVcXFwiKTtcXG4gICAgICAgIGlmIChkbSAmJiAhb25seURvd25sb2FkKSB7XFxuICAgICAgICAgICAgY2xlYXJWYXIoXFxcImRtX3NoYXJlXFxcIik7XFxuICAgICAgICAgICAgcmVmcmVzaFZpZGVvVXJsKHtcXG4gICAgICAgICAgICAgICAgZGFubXU6IGRtXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WKoOi9veWujOaIkFxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHJldHVybiAkKGtleSwgXFxcImRt55uS5a2Q5pCc57SiXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5LiL6L295a6M5oiQ5by55bmV5ZCO6K+36YeN5paw54K55Ye75pCc57SiXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9zZWFyY2g/c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G4gICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihhKSB8fCBOdW1iZXIuaXNOYU4oYikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/or7fmjInmoLzlvI/ovpPlhaXmlbDlrZdcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChhIDwgMSB8fCBiID4gZXBpc29kZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl6KeE5a6a6IyD5Zu05YaF55qE5pWw5a2XXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSBhIC0gMSwgaiA9IDE7IGkgPCBiOyBpKyssIGorKykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcGlzb2RlID0gZXBpc29kZXNbaV07XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRtVGl0bGUgPSBhbmltZVRpdGxlICsgXFxcIl9cXFwiICsgZXBpc29kZS5lcGlzb2RlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOS4i+i9ve+8mlxcXCIgKyBlcGlzb2RlLmVwaXNvZGVUaXRsZSArIFxcXCJcXFxcdChcXFwiICsgaiArIFxcXCIvXFxcIiArIChiIC0gYSArIDEpICsgXFxcIilcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkYW5tdS5kb3dubG9hZERhbk11KGVwaXNvZGUuZXBpc29kZUlkLCBkbVRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WTpuWTpuS4i+i9veWksei0pS4uLlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4i+i9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgfSwgYW5pbWUuYW5pbWVUaXRsZSwgYW5pbWUuZXBpc29kZXMpLFxcbiAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21vdmllLzE0LnN2Z1xcXCJcXG4gICAgICAgIH0pO1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgICAgICB9KTtcXG4gICAgICAgIGZvciAobGV0IGVwaXNvZGUgb2YgYW5pbWUuZXBpc29kZXMpIHtcXG4gICAgICAgICAgICBsZXQgZG1UaXRsZSA9IGFuaW1lLmFuaW1lVGl0bGUgKyBcXFwiX1xcXCIgKyBlcGlzb2RlLmVwaXNvZGVUaXRsZTtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZXBpc29kZS5lcGlzb2RlVGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJChlcGlzb2RlLmVwaXNvZGVJZCkubGF6eVJ1bGUoKHVybCwgdGl0bGUsIG9ubHlEb3dubG9hZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGRhbm11LmdldExvY2FsRGFuTXUoaW5wdXQsIHRpdGxlKSB8fCBkYW5tdS5kb3dubG9hZERhbk11KGlucHV0LCB0aXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAob25seURvd25sb2FkKSByZXR1cm4gXFxcInRvYXN0Oi8v5LiL6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkYW5tdVRleHQgPSBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZGFubXVUZXh0KSByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5rKh5pyJ5by55bmV5ZOfflxcXCI7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoVmlkZW9Vcmwoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11OiBwYXRoXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WKoOi9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIE1ZX1BBUkFNUy5kdXJsLCBkbVRpdGxlLCBvbmx5RG93bmxvYWQpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLlvLrliLbkuIvovb1cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChlcGlzb2RlVGl0bGUsIGVwaXNvZGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi6K+3562J5b6FXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhbm11ID0gJC5yZXF1aXJlKFxcXCJkYW5tdVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYW5tdS5kb3dubG9hZERhbk11KGVwaXNvZGVJZCwgZXBpc29kZVRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+mHjeaWsOS4i+i9veWujOaIkO+8jOWNleWHu+aMgui9veOAglxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgZG1UaXRsZSwgZXBpc29kZS5lcGlzb2RlSWQpXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZV9ibGFua1xcXCJcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIGlmICghZG1MaXN0LmFuaW1lcy5sZW5ndGgpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmsqHmnInmib7liLDkuI5bXFxcIiArIG5hbWUgKyBcXFwiXeebuOWFs+eahOW8ueW5lVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgZGVzYzogXFxcIuaQnOS4jeWIsOaAjuS5iOWKnu+8n1xcXFxu5qOA5p+l5ZCN56ew5piv5ZCm5q2j56Gu77yb5Y+v5Lul5bCd6K+V5Yig6Zmk6YOo5YiG6ZmQ5a6a6K+N77yM5aaC56ys5LiA5a2j562J77yb6ICM5LiU5Y+q6IO95pCc57Si55Wq5Ymn5ZOm77yB5YW25LuW5by55bmV5Y+v55SoZG3nm5LlrZDjgIJcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZX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IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAnY29udGVudC10eXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJVc2VyLUFnZW50XFxcIjogUENfVUEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcInNoYXJlX2lkXFxcIjogc2hhcmVJZFxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBpZiAoc2hhcmUuaW5jbHVkZXMoXFxcInNoYXJlX2xpbmsgaXNcXFwiKSB8fCBzaGFyZS5pbmNsdWRlcyhcXFwic2hhcmVfbGluayBjYW5ub3RcXFwiKSkgcmV0dXJuIGZhbHNlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgfSxcXG4gICAgYnl0ZXNUb1NpemUoc2l6ZSkge1xcbiAgICAgICAgaWYgKCFzaXplKSB7XFxuICAgICAgICAgICAgcmV0dXJuICcwJztcXG4gICAgICAgIH1cXG4gICAgICAgIGNvbnN0IHVuaXRzID0gWydCJywgJ0tCJywgJ01CJywgJ0dCJywgJ1RCJywgJ1BCJywgJ0VCJywgJ1pCJywgJ1lCJ107XFxuICAgICAgICBsZXQgaSA9IDA7XFxuICAgICAgICB3aGlsZSAoc2l6ZSA+PSAxMDI0KSB7XFxuICAgICAgICAgICAgc2l6ZSAvPSAxMDI0O1xcbiAgICAgICAgICAgIGkrKztcXG4gICAgICAgI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vYj5cXG4gICAg5b2T5YmN54mI5pys77yaJHtNWV9SVUxFLnZlcnNpb259XFxuICAgIOWmguaenOS9oOaDs+S/neaMgeacgOaWsOeJiOivtyR7XFxcIuiuoumYheatpOinhOWImVxcXCIubGluayhcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoc3ViUGFzcykpfVxcbiAgICBgO1xcbiAgICBsZXQgdXBkYXRlSW5mbyA9IFxcXCLkv67lpI3lvLnluZXmjILovb3pl67pophcXFwiO1xcbiAgICBcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdPHN0cm9uZz7kvb/nlKjliY3pobvnn6U8L3N0cm9uZz5cXFwiLmJpZygpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogY29udGVudC50cmltKCkucmVwbGFjZSgvXFxcXG5cXFxccyo/L2csIFxcXCI8YnI+XFxcIiksXFxuICAgICAgICBcXFwiY29sX3R5cGVcXFwiOiBcXFwicmljaF90ZXh0XFxcIlxcbiAgICB9LCB7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiB0aW1lICsgXFxcIuenkuWQjue7p+e7rVxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJ0b2FzdDovL+ivt+iupOecn+mYheivu+S7peS4iuWGheWuuVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyB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77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahO+8jC00LOe7hOWQjeWIhuS6q+e7hO+8jOWkmuS4queUqCfvvIwn6ZqU5byAXFxcIikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcbiAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChsZW5ndGgsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzkupHnroDmkJzntKLlvJXmk47vvIzlhbHjgIxcXFwiICsgbGVuZ3RoICsgXFxcIuOAjeadoe+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKGdldFBhc3RlcygpLmluY2x1ZGVzKGlucHV0KSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGVzLmxlbmd0aCwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvcnVsZXMvTG95RGdJay9zaGFyZS/kupHnroDmkJzntKLlvJXmk47op4TliJnjgIxcXFwiICsgcnVsZXMubGVuZ3RoICsgXFxcIuOAjeadoS5cXFwiICsgKGlucHV0ID09PSBcXFwiSElLRVJcXFwiID8gXFxcImhpa2VyXFxcIiA6IFxcXCJ0eHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCBnZXRQYXNzKHJ1bGVzLmxlbmd0aCwgcnVsZWI2NCwgXFxcImFcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInNoYXJlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB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ikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgW3N0YXJ0LCBlbmRdID0gaW5wdXQuc3BsaXQoLyx877yMLyk7XFxuICAgICAgICAgICAgICAgIHN0YXJ0ID0gcGFyc2VJbnQoc3RhcnQpLCBlbmQgPSBwYXJzZUludChlbmQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKHN0YXJ0KSB8fCBOdW1iZXIuaXNOYU4oZW5kKSB8fCBzdGFydCA8IDAgfHwgZW5kID4gbGVuZ3RoIC0gMSB8fCBzdGFydCA+IGVuZCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aVsOWtl+S4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IG51bWJlciA9IGVuZCAtIHN0YXJ0ICsgMTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8mltcXFwiICsgc3RhcnQgKyBcXFwiLFxcXCIgKyBlbmQgKyBcXFwiXVxcXFxu5YWxXFxcIiArIG51bWJlciArIFxcXCLmnaHmkJzntKLlvJXmk45cXFwiKS5jb25maXJtKChzdGFydCwgbnVtYmVyKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2Uoc3RhcnQsIG51bWJlcik7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIHN0YXJ0LCBudW1iZXIpO1xcbiAgICAgICAgICAgIH0sIGxlbmd0aCk7XFxuICAgICAgICB9XFxuICAgIH0sIGdyb3VwLCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxufSk7XFxuZm9yIChsZXQgaXQgb2YgZ3JvdXBzKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogaXQgPT09IGdyb3VwID8gXFxcIuKAnOKAnFxcXCIgKyBpdCArIFxcXCLigJ3igJ1cXFwiIDogaXQsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGl0LCBncm91cCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChncm91cCAhPT0gaXQpIHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIsIGl0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIue9rumhtlxcXCIsIFxcXCLnva7lupVcXFwiLCBcXFwi5pS55ZCNXFxcIiwgXFxcIuWIoOmZpFxcXCJdKS5zZWxlY3QoKGl0KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoXFxcIuaUueWQjVxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXQsIFxcXCLor7fovpPlhaXmlrDlkI3np7BcXFwiKS5pbnB1dCgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ID09PSB2Lmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdi5ncm91cCA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoXFxcIuWIoOmZpFxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuaYr+WQpuWIoOmZpOivpee7hOaQnOe0ouW8leaTju+8mlxcXCIgKyBpdCkuY29uZmlybSgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcyA9IHJ1bGVzLmZpbHRlcih2ID0+IHYuZ3JvdXAgIT09IGl0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB0Z1J1bGVzID0gW10sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcyA9IFtdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuZm9yRWFjaCgodikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdCA9PT0gdi5ncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0Z1J1bGVzLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcy5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRnUnVsZXMgPSB0Z1J1bGVzLmNvbmNhdCh0eFJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGdSdWxlcyA9IHR4UnVsZXMuY29uY2F0KHRnUnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24odGdSdWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICA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ZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHJ1bGUgKyBcXFwiJFxcXCIgKyB0eXBlICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuWujOaVtOWPo+S7pFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHJ1bGViNjQsIFxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGlmIChncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgbmV3SW5kZXggPSBydWxlcy5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgICAgICBuZXdJbmRleCA9IG5ld0luZGV4ID09PSAtMSA/IDAgOiBuZXdJbmRleDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gIXJ1bGUuZm9yYmlkZGVuO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2Fzd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WFs+mUruivjVxcXCIpLmlucHV0KChwYWdlKSA9PiB7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidGVzdEtleXdvcmRcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgZmluZCA9IGdldE15VmFyKFxcXCJwc19maW5kXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmICghZmluZCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pCc57Si6KeE5YiZ5LiN6IO95Li656m6XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgdGVzdFJ1bGUgPSB7XFxuICAgICAgICAgICAgICAgIG5hbWU6IG5hbWUsXFxuICAgICAgICAgICAgICAgIGZpbmQ6IGZpbmQsXFxuICAgICAgICAgICAgICAgIGJhc2ljVXJsOiBnZXRNeVZhcihcXFwicHNfYmFzaWNVcmxcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgICAgIGZpbmRBbGlVcmw6IGdldE15VmFyKFxcXCJwc19maW5kQWxpVXJsXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgICAgICAgICBwYWdlOiAhIWdldE15VmFyKFxcXCJwc19wYWdlXFxcIiwgcGFnZSA/IFxcXCIxXFxcIiA6IFxcXCJcXFwiKSxcXG4gICAgICAgICAgICAgICAgcnVsZVR5cGU6IGdldE15VmFyKFxcXCJwc19ydWxlVHlwZVxcXCIsIFxcXCJcXFwiKSxcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJoaWtlcjovL2VtcHR5I25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5Iz9meX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ogbmFtZSxcXG4gICAgICAgICAgICBhdXRob3I6IGdldE15VmFyKFxcXCJwc19hdXRob3JcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgZmluZDogZmluZCxcXG4gICAgICAgICAgICBiYXNpY1VybDogZ2V0TXlWYXIoXFxcInBzX2Jhc2ljVXJsXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgICAgIGZpbmRBbGlVcmw6IGdldE15VmFyKFxcXCJwc19maW5kQWxpVXJsXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgICAgIHBhZ2U6ICEhZ2V0TXlWYXIoXFxcInBzX3BhZ2VcXFwiLCBwYWdlID8gXFxcIjFcXFwiIDogXFxcIlxcXCIpLFxcbiAgICAgICAgICAgIHJlZ2lzdGVyVXJsOiBnZXRNeVZhcihcXFwicHNfcmVnaXN0ZXJVcmxcXFwiLCBcXFwiXFxcIikgfHwgdW5kZWZpbmVkLFxcbiAgICAgICAgICAgIGxhc3RNb2RpZnk6IERhdGUubm93KCksXFxuICAgICAgICAgICAgZ3JvdXA6IGdldE15VmFyKFxcXCJwc19ncm91cFxcXCIsIFxcXCJcXFwiKSxcXG4gICAgICAgICAgICBydWxlVHlwZTogZ2V0TXlWYXIoXFxcInBzX3J1bGVUeXBlXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeinhOWImVxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeinhOWImVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgb2JqMSk7XFxuICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgb2JqMSk7XFxuICAgICAgICB9XFxuICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv53lrZ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eSMjbm9IaXN0b3J5I1xcXCIpLnJ1bGUoKHJlZ2lzdGVyVXJsKT0+e1xcbiAgICAgICAgICAgICAgICBzZXRSZXN1bHQoW3tcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJ4NV93ZWJ2aWV3X3NpbmdsZVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6cmVnaXN0ZXJVcmwsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOlxcXCJmbG9hdCYmMTAwJVxcXCJcXG4gICAgICAgICAgICAgICAgfV0pO1xcbiAgICAgICAgICAgIH0sIHJlZ2lzdGVyVXJsKSxcXG4gICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogXFxcIuazqOWGjOi0puWPtzpcXFwiICsgb2JqLm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBvYmogPSBvYmoudXNlciB8fCB7fTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIueUqOaIt+WQjVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouYWNjb3VudCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogXFxcInBhc3N3b3JkXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19wYXNzd29yZFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5wYXNzd29yZCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIumineWkllxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHR5cGU6IFxcXCJ0ZXh0YXJlYVxcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfZXh0cmFcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouZXh0cmEsXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICBoZWlnaHQ6IC0xXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBhY2NvdW50ID0gZ2V0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IHBhc3N3b3JkID0gZ2V0TXlWYXIoXFxcInBzX3Bhc3N3b3JkXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBleHRyYSA9IGdldE15VmFyKFxcXCJwc19leHRyYVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAvKmlmICghKGFjY291bnR8fHBhc3N3b3JkfHxleHRyYSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveWFqOmDqOS4uuepulxcXCI7XFxuICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgaXRlbSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgaXRlbS51c2VyID0ge307XFxuICAgICAgICAgICAgaXRlbS51c2VyLmFjY291bnQgPSBhY2NvdW50XFxuICAgICAgICAgICAgaXRlbS51c2VyLnBhc3N3b3JkID0gcGFzc3dvcmQ7XFxuICAgICAgICAgICAgaXRlbS51c2VyLmV4dHJhID0gZXh0cmE7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9pZOmUmeivr1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgaXRlbSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+d5a2Y5oiQ5YqfXFxcIjtcXG4gICAgICAgIH0sIGluZGV4KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgIH0pO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxufSkoKVwifSx7X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ZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5paw5aKe77yaXFxcIiArIG5ld0kgKyBcXFwiIOimhuebluabtOaWsO+8mlxcXCIgKyAocnVsZXMubGVuZ3RoIC0gbmV3SSkpO1xcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIHRvYXN0KFxcXCLlr7zlhaXlpLHotKVcXFwiKTtcXG4gICAgfVxcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuinhOWImeWIl+ihqFwiLFwicGF0aFwiOlwicnVsZXNcIixcInJ1bGVcIjpcImpzOlxcbiQuZXhwb3J0cyA9IFt7XFxuICAgICAgICBuYW1lOiBcXFwi5bCP5LqRXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgYmFzaWNVcmwgPSBcXFwiaHR0cHM6Ly93d3cueXVuc28ubmV0XFxcIjtcXG4gICAgICAgICAgICBsZXQgYXBpID0gXFxcIi9hcGkvdmFsaWRhdGUvc2VhcmNoP3dkPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQocykgKyB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uICAgICAgICAgICAgICAgICAgICAvL2Rlc2M6IHRpbWVbMF0sXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGJhc2U2NERlY29kZShwZGZoKGl0ZW0sIFxcXCJhJiZ1cmxcXFwiKSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi5re35ZCI55uYXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLmh1bmhlcGFuLmNvbS92MS9zZWFyY2hcXFwiO1xcbiAgICAgICAgICAgIGxldCBqc29uID0gcG9zdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgUmVmZXJlcjogXFxcImh0dHBzOi8vaHVuaGVwYW4uY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInFcXFwiOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VcXFwiOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInNpemVcXFwiOiAxNVxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKGpzb24pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5kYXRhLmxpc3Q7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmRpc2tfdHlwZSAhPT0gXFxcIkFMWVxcXCIgfHwgaXQuc2hhcmVfdXNlciA9PT0gXFxcIuS4tioqKuS4tlxcXCIpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LmRpc2tfbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBkKGl0LCBcXFwiaW1nJiZzcmNcXFwiLCB1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpdC5saW5rLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudXBkYXRlX3RpbWUgKyBcXFwiXFxcXG5cXFwiICsgaXQubGluayxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi6LWE5rqQ5biuXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBzZWFyY2goKSB7XFxuICAgICAgICAgICAgICAgIGxldCBydG5MaXN0ID0gW107XFxuICAgICAgICAgICAgICAgIGxldCByZXNwID0gcmVxdWVzdChcXFwiaHR0cHM6Ly96eWIudXB5dW5zby5jb20vdjE1L3NlYXJjaD9rZXl3b3JkPVxcXCIgKyBlbl9hZXMocykgKyBcXFwiJnNfdHlwZT0yJnBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiJmF0az0mZGlkPVxcXCIgKyBnZW5lcmF0ZVJhbmRvbUhleFN0cmluZyg2NCksIHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwidXNlci1hZ2VudFxcXCI6I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nRuTGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogKGl0ZW0udGl0bGUubGVuZ3RoID4gMzAgPyBpdGVtLnRpdGxlLnNsaWNlKDAsIDI3KSArIFxcXCIuLi5cXFwiIDogaXRlbS50aXRsZSkgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIuWIhuS6q+aXtumXtO+8mlxcXCIgKyBpdGVtLmluc2VydF90aW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICByZXR1cm4gcnRuTGlzdDtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJhdGVSYW5kb21IZXhTdHJpbmcobGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVycyA9IFxcXCIwMTIzNDU2Nzg5YWJjZGVmXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVyc0xlbmd0aCA9IGNoYXJhY3RlcnMubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gY2hhcmFjdGVycy5jaGFyQXQoTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogY2hhcmFjdGVyc0xlbmd0aCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGVuX2FlcyhlKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gXFxcInFxMTkyMDUyMDQ2MHFxenpcXFwiO1xcbiAgICAgICAgICAgICAgICAvLyBlbl9hZXNcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGkpO1xcbiAgICAgICAgICAgICAgICB2YXIgdCA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGUpLFxcbiAgICAgICAgICAgICAgICAgICAgciA9IENyeXB0b0pTLkFFUy5lbmNyeXB0KHQsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHIuY2lwaGVydGV4dC50b1N0cmluZygpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBkZV9hZXModnYpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBcXFwicXExOTIwNTIwNDYwcXF6elxcXCI7XFxuICAgICAgICAgICAgICAgIC8vIGRlX2Flc1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoaSk7XFxuICAgICAgICAgICAgICAgIGxldCBoZXhWYWwgPSBDcnlwdG9KUy5lbmMuSGV4LnBhcnNlKHZ2KSxcXG4gICAgICAgICAgICAgICAgICAgIHZhbCA9IENyeXB0b0pTLmVuYy5CYXNlNjQuc3RyaW5naWZ5KGhleFZhbCksXFxuICAgICAgICAgICAgICAgICAgICBkZWNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdCh2YWwsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGRlY3J5cHRlZC50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBzZWFyY2goKTtcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgbmFtZTogXFxcIuS6keebmOi1hOa6kFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9yZXMueXVucGFuLndpbi8/UGFnZUluZGV4PVxcXCIgKyBwYWdlICsgXFxcIiZQYWdlU2l6ZT0xMiZLZXl3b3JkPVxcXCIgKyBzICsgXFxcIiZUeXBlPSZUYWc9XFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vcmVzLnl1bnBhbi53aW4vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIm1haW4mJi5jYXJkXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZGZoKGl0LCBcXFwiLmNhcmQtbGluaywxJiZvbmNsaWNrXFxcIikubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgICAgIHUgPSB1Lmxlbmd0aCA+IDAgPyB1WzBdIDogdXJsO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCIuY2FyZC10aXRsZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGQoaXQsIFxcXCJpbWcmJnNyY1xcXCIsIHVybCksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwZGZoKGl0LCBcXFwiLmNhcmQtdGV4dCwtMSYmVGV4dFxcXCIpICsgXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIlVQ5LqR5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS51cHl1bnNvMi5jb20vc2VhcmNoP2tleXdvcmQ9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiJnNfdHlwZT0xXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LnVweXVuc28uY29tXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBcXFwiY29kZT0xOTE5XFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coYmFzZTY0RGVjb2RlKGh0bWwpKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUoaHRtbCkpLnJlc3VsdC5pdGVtcztcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgaWYgKCFhcnIpIHJldHVybiBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gaXQucGFnZV91cmw7XFxuICAgICAgICAgICAgICAgIC8vdSA9IHUubGVuZ3RoID4gMCA/IHVbMF0gOiB1cmw7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIueMq+eLuOebmOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb20vc2VhcmNoP2s9XFxcIiArIHMsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbS9zZWFyY2g/az1cXFwiICsgc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIiNhcHAmJmFcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gXFxcIjxkaXY+XFxcIiArIGFycltpXSArIFxcXCI8L2Rpdj5cXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkZmgoaXQsIFxcXCJhJiZocmVmXFxcIik7XFxuICAgICAgICAgICAgICAgIC8vbG9nKHUpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcIi9zL1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB1ID0gXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb21cXFwiICsgdS5yZXBsYWNlKFxcXCIvcy9cXFwiLCBcXFwiL2N2L1xcXCIpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCJ0ZW1wbGF0ZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGRmaChpdCwgXFxcInRlbXBsYXRlLDEmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IFxcXCJub19zaG93X2RvbmF0ZT0xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogaW5wdXQucmVwbGFjZShcXFwiL2N2L1xcXCIsIFxcXCIvcy9cXFwiKVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICByZWRpcmVjdDogZmFsc2VcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBodG1sID0gcGFyc2VEb21Gb3JIdG1sKGh0bWwsICdhJiZocmVmJyk7XFxuICAgICAgICAgICAgaWYgKGh0bWwubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaHRtbDtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5piT5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICByZWdpc3RlclVybDogXFxcImh0dHBzOi8veWlzby5mdW5cXFwiLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGtleWVuKHN0cikge1xcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjRPVG9TY1VGT2FlVlRySEVcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIGl2ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjlDTEdhbzF2SEtxbTE3T3pcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGVuY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHtcXG4gICAgICAgICAgICAgICAgICAgIGNpcGhlcnRleHQ6IENyeXB0b0pTLmVuYy5CYXNlNjQucGFyc2Uoc3RyKVxcbiAgICAgICAgICAgICAgICB9LCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBpdixcXG4gICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgcGFkZGluZzogQ3J5cHRvSlMucGFkLlBrY3M3XFxuICAgICAgICAgICAgICAgIH0pLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVuY3J5cHRlZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coaHRtbCk7XFxuICAgICAgICAgICAgaWYgKGh0bWwuaW5jbHVkZXMoJ+eZu+W9leeUqOaIt+aXoOmZkOWIticpKSB7XFxuICAgICAgICAgICAgICAgIHZhciBpID0gMDtcXG4gICAgICAgICAgICAgICAgZG8ge1xcbiAgICAgICAgICAgICAgICAgICAgdmFyIHR5aW1nbGluID0gJ2h0dHBzOi8veWlzby5mdW4vYXBpL3VzZXIvbG9naW4vY2FwdGNoYT90PScgKyBwYXJzZUludChuZXcgRGF0ZSgpLmdldFRpbWUoKSkgKyAnJztcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbWcgPSBjb252ZXJ0QmFzZTY0SW1hZ2UodHlpbWdsaW4pLnNwbGl0KCcsJylbMV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29kID0gcmVxdWVzdCgnaHR0cHM6Ly9hcGkueGhvZmUudG9wL29jci9iNjQvdGV4dCcsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAndGV4dC9wbGFpbidcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHk6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgdmVyID0gSlNPTi5wYXJzZShyZXF1ZXN0KCdodHRwczovL3lpc28uZnVuL2FwaS91c2VyL2xvZ2luJywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2NvbnRlbnQtdHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ3JlZmVyZXInOiAnaHR0cHM6Ly95aXNvLmZ1bi9sb2dpbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb29raWUnOiBnZXRDb29raWUodHlpbWdsaW4pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJ1c2VyTmFtZVxcXCI6IHVzZXIuYWNjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcInBhc3N3b3JkXFxcIjogdXNlci5wYXNzd29yZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcImNvZGVcXFwiOiBjb2RcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodmVyLmNvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCfmmJPmkJznmbvlhaXpqozor4HmiJDlip8nKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKCd5aXNvdWNvb2tlJywgZ2V0Q29va2llKCdodHRwczovL3lpc28uZnVuJykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpKys7XFxuICAgICAgICAgICAgICAgIH0gd2hpbGUgKGkgPCA0KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoaHRtbCkuZGF0YS5saXN0O1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0ga2V5ZW4oaXQudXJsKTtcXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGlmICh1ID09IG51bGwgfHwgIXUuaW5jbHVkZXMoXFxcImFsaXl1blxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiAoaXQuZ210U2hhcmUgfHwgaXQuZ210Q3JlYXRlKSArIFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuWwj+e6uOadoVxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGdldHRva2VuKCkge1xcbiAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoJ3h6eXRva2VuJywgJycpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdG9rZW4gPSBKU09OLnBhcnNlKHBvc3QoJ2h0dHBzOi8vZ2l0Y2FmZS5uZXQvdG9vbC9hbGlwYXBlci8nLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3UuZ2l0Y2FmZS5pbmsvJ1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246ICdnZXRfdG9rZW4nXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSkpLmRhdGE7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcigneHp0dG9rZW4nLC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cHM6Ly91LmdpdGNhZmUuaW5rLydcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBcXFwic2VhcmNoXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGZyb206IFxcXCJ3ZWJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IGdldHRva2VuKCksXFxuICAgICAgICAgICAgICAgICAgICBrZXl3b3JkOiBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKTtcXG4gICAgICAgICAgICBpZiAobGlzdC5kYXRhKSB7XFxuICAgICAgICAgICAgICAgIGxpc3QgPSBsaXN0LmRhdGE7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldXFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0LnRpdGxlO1xcbiAgICAgICAgICAgICAgICBsZXQgbXVybCA9ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy8nICsgaXQuYWxpa2V5XFxuICAgICAgICAgICAgICAgIGlmICghYWxpVXRpbC5jaGVja2FsaShtdXJsKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oiaIFxcXCIgKyB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBjYXRfY29kZShpdC5jYXQpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlczogaXQuZGVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IG11cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi546p5YG25ZOl5ZOlXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBiYXNpY1VybDogXFxcImh0dHA6Ly93b2dnLnh5elxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9pbmRleC5waHAvdm9kc2VhcmNoL1xcXCIgKyBzICsgXFxcIi0tLS0tLS0tLS1cXFwiICsgcGFnZSArIFxcXCItLS0uaHRtbFxcXCI7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgXFxcIi5tb2R1bGUtaXRlbXMmJi5tb2R1bGUtc2VhcmNoLWl0ZW1cXFwiKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImgzJiZhJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi52aWRlby1zZXJpYWwmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBkZmgoaXQsIFxcXCJpbWcmJmRhdGEtc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGQoaXQsIFxcXCJoMyYmYSYmaHJlZlxcXCIsIGJhc2ljVXJsKTtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHV0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHVpbWFnZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHVzZXJpYWxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIHJldHVybiBwZGZhKHJlcXVlc3QoaW5wdXQpLCBcXFwiYm9keSYmLm1vZHVsZS1yb3ctdGV4dC5jb3B5XFxcIikubWFwKHYgPT4gcGRmaCh2LCBcXFwiYSYmZGF0YS1jbGlwYm9hcmQtdGV4dFxcXCIpKTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOS6keebmOe9kVxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgYmFzaWNVcmw6IFxcXCJodHRwczovL3d3dy5hbHlwdy5jblxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9zZWFyY2gucGhwP3E9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2U7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge30pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCIubGlzdCYmbGlcXFwiKTtcXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImEmJnRpdGxlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi5mYS1jbG9jay1vJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwZGZoKGl0LCBcXFwiaW1nJiZzcmNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCBiYXNpY1VybCk7XFxuICAgICAgICAgICAgICAgIGlmICghdXRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdXRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogdWltYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogdXNlcmlhbFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBkZmEocmVxdWVzdChpbnB1dCksIFxcXCJib2R5JiZhW2hyZWZePWh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL11cXFwiKS5tYXAodiA9PiBwZGZoKHYsIFxcXCJhJiZocmVmXFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5Zyf5ouo6bygXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gZmV0Y2goJ2h0dHBzOi8vd3d3LnRic2R5LmNvbS9zZWFyY2guaHRtbD9rZXl3b3JkPScgKyBzICsgJyZjYXRlZ29yeT05ODM5MjAmZGF0YV90eXBlPTk4NzkxMCcsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgJy5zZWFyY2hfcmVzdWx0X25ldGRpc2tfbGlzdCYmYScpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhpdCk7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnYSYmaHJlZicpO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnLm5ldGRpc2tfaXRlbV9kZXRhaWxfbmFtZSYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0LFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KCdodHRwczovL2FsaXNvLmNjL3MvJyArIHMgKyAnLScgKyBwYWdlICsgJy0wLmh0bWwnLCB7fSk7XFxuXFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsICcuc2VhcmNoLXJlc3VsdCYmLnJlc291cmNlLWl0ZW0nKTtcXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGxpc3QubGVuZ3RoOyBqKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBsaXN0W2pdO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKHUsICdoMyYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXQsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHBhcnNlRG9tKHUsICdoMyYmYSYmaHJlZicsICdodHRwczovL2FsaXNvLmNjLycpLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGFyc2VEb21Gb3JIdG1sKHUsICcudGltZSYmVGV4dCcpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGV2YWwoZ2V0Q3J5cHRvSlMoKSk7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZGVjcnkoc3RyKSB7XFxuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShcXFwiOUVCMjBEREZENkFGQkQ2OFxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgZW5jcnlwdGVkID0gQ3J5cHRvSlMuQUVTLmRlY3J5cHQoc3RyLCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIHBhZGRpbmc6IENyeXB0b0pTLnBhZC5Qa2NzN1xcbiAgICAgICAgICAgICAgICB9KS50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlbmNyeXB0ZWQ7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChpbnB1dCk7XFxuICAgICAgICAgICAgbGV0IGJ1dCA9IHBhcnNlRG9tKGh0bWwsICcuYnV0dG9uJiZocmVmJywgJ2h0dHBzOi8vYWxpc28uY2MvJyk7XFxuICAgICAgICAgICAgLy9sb2coYnV0KTtcX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HBzOi8vd3d3Lnl1bnBhbmZlbnhpYW5nLmNuL2FwaS9iYnMvYXBpL2dldGRhdGE/a2V5PVxcXCIgKyBzICsgXFxcIiZ0eXBlPXZpZGVvXFxcIiwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQganNvbiA9IGRlY3J5KEpTT04ucGFyc2UoaHRtbCkuZGF0YSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoanNvbik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGl0LnBpZDtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vYXBpL2Jicy9hcGkvZ2V0YXJ0aWNsZT9pZD1cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQuY3JlYXRldGltZVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSkpLmRhdGE7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLmRvd25sb2FkLnNwbGl0KFxcXCJAXFxcIik7XFxuICAgICAgICAgICAgbGV0IGFsaXN0ID0gbmV3IFNldCgpO1xcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbGlzdC5sZW5ndGg7IGorKykge1xcbiAgICAgICAgICAgICAgICBhbGlzdC5hZGQoXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL1xcXCIgKyBsaXN0W2pdKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIEFycmF5LmZyb20oYWxpc3QpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi55uY5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgcGFnZSA9IChwYWdlIC0gMSkgKiAxMDtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vd3d3LnBhbnNlYXJjaC5tZS9zZWFyY2g/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+S7tuaOkuW6j1wiLFwicGF0aFwiOlwiRmlsZVNvcnRpbmdcIixcInJ1bGVcIjpcImxldCBjaG5OdW1DaGFyID0ge1xcbiAgICDpm7Y6IDAsXFxuICAgIOS4gDogMSxcXG4gICAg5LqMOiAyLFxcbiAgICDkuIk6IDMsXFxuICAgIOWbmzogNCxcXG4gICAg5LqUOiA1LFxcbiAgICDlha06IDYsXFxuICAgIOS4gzogNyxcXG4gICAg5YWr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CA9IG5ldyBqYXZhLm1hdGguQmlnSW50ZWdlcihzcGxpdDFbaV0pLmNvbXBhcmVUbyhuZXcgamF2YS5tYXRoLkJpZ0ludGVnZXIoc3BsaXQyW2ldKSk7XFxuICAgICAgICB9XFxuXFxuICAgICAgICBpZiAoY21wID09PSAwKSB7XFxuICAgICAgICAgICAgbGV0IHJlZ2V4ID0gL1thLXpBLVowLTldL1xcbiAgICAgICAgICAgIGxldCBzMSA9IFN0cmluZyhzcGxpdDFbaV0pXFxuICAgICAgICAgICAgbGV0IHMyID0gU3RyaW5nKHNwbGl0MltpXSlcXG4gICAgICAgICAgICBpZiAocmVnZXgudGVzdChzMSkgfHwgcmVnZXgudGVzdChzMikpIHtcXG4gICAgICAgICAgICAgICAgY21wID0gbmV3IGphdmEubGFuZy5TdHJpbmcoc3BsaXQxW2ldKS5jb21wYXJlVG8obmV3IGphdmEubGFuZy5TdHJpbmcoc3BsaXQyW2ldKSk7XFxuICAgICAgICAgICAgICAgIC8vIGNtcCA9IHMxLmxvY2FsZUNvbXBhcmUoczIsICdlbicpXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgY21wID0gczEubG9jYWxlQ29tcGFyZShzMiwgJ3poJylcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuXFxuICAgICAgICBpZiAoY21wICE9PSAwKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGNtcDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgbGVuZ3RoQ21wID0gc3BsaXQxLmxlbmd0aCAtIHNwbGl0Mi5sZW5ndGg7XFxuICAgIC8vIGlmIChsZW5ndGhDbXAgIT09IDApIGxlbmd0aENtcCA9IGxlbmd0aENtcCA+IDAgPyAtMSA6IDE7XFxuICAgIHJldHVybiBsZW5ndGhDbXA7XFxufVxcbiQuZXhwb3J0cy5uYW1lQ29tcGFyZSA9IG5hbWVDb21wYXJlO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM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F90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgY2xzOiBcXFwibG9naW5cXFwiXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBkZWxldGVJdGVtKFxcXCJnZXRRQ1xcXCIpO1xcbiAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgIGxldCByZWZyZXNoX3Rva2VuO1xcbiAgICAgICAgd2hpbGUgKHRydWUpIHtcXG4gICAgICAgICAgICBsZXQgZGF0YTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBkYXRhID0gZ2V0X3FyY29kZV9zdGF0dXMoc2lkKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mn6Xor6LmiavnoIHnu5PmnpzotoXml7YsIOWPr+iDveaYr+inpuWPkeS6humYv+mHjOS6keebmOaOpeWPo+mZkOWItiwg6K+356iN5ZCO5YaN6K+VLlxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdGF0dXMgPSBkYXRhW1xcXCJzdGF0dXNcXFwiXTtcXG4gICAgICAgICAgICBpZiAoc3RhdHVzID09IFxcXCJMb2dpblN1Y2Nlc3NcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW4gPSBnZXRfcmVmcmVzaF90b2tlbihkYXRhW1xcXCJhdXRoQ29kZVxcXCJdKTtcXG4gICAgICAgICAgICAgICAgYnJlYWtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHN0YXR1cyA9PSBcXFwiUVJDb2RlRXhwaXJlZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S6jOe7tOeggeW3sui/h+acnywg6K+35Yi35paw6aG16Z2i5ZCO6YeN6K+VXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKCFnZXRNeVZhcihcXFwiTG9nZ2luZ2luXFxcIiwgXFxcIlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9jYW5jZWxcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDE1MDApO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJlZnJlc2hfdG9rZW4pIHtcXG4gICAgICAgICAgICBjb25zdCB7XFxuICAgICAgICAgICAgICAgIG9wZW5Ub2tlbnNGaWxlcGF0aCxcXG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJ0b2tlblBhdGhcXFwiKTtcXG4gICAgICAgICAgICBsZXQgb3BlbiA9IHtcXG4gICAgICAgICAgICAgICAgUmVmcmVzaFRva2VuT3BlbjogcmVmcmVzaF90b2tlbixcXG4gICAgICAgICAgICAgICAgaXNWMjogdHJ1ZVxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgd3JpdGVGaWxlKG9wZW5Ub2tlbnNGaWxlcGF0aCwgSlNPTi5zdHJpbmdpZnkob3BlbikpO1xcbiAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwiaW5mb091dHB1dFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnmbvlvZXmiJDlip8o54K55Ye76L+U5ZueKVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDokKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpPT57XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzF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ZWFkLGZpbGU6YWxsOndyaXRlJnN0YXRlPScpLmJvZHkoe1xcbiAgICAgICAgICAgIFxcXCJhdXRob3JpemVcXFwiOiAxLFxcbiAgICAgICAgICAgIFxcXCJzY29wZVxcXCI6IFxcXCJ1c2VyOmJhc2UsZmlsZTphbGw6cmVhZCxmaWxlOmFsbDp3cml0ZVxcXCJcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLiR0aGlzLnJlYWNjZXNzVGssIC8vZ2V0QWNjZXNzVG9rZW5cXG4gICAgICAgICAgICAneC1jYW5hcnknOiAnY2xpZW50PXdlYixhcHA9c2hhcmUsdmVyc2lvbj12Mi4zLjEnLFxcbiAgICAgICAgICAgICd4LXNoYXJlLXRva2VuJzogdGhpcy4kdGhpcy5zaGFyZVRva2VuXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMuJHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLiR0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgICAgICAneC1zaGFyZS10b2tlbic6IHRoaXMuJHRoaXMuc2hhcmVUb2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGxldCBjb2RlID0gcmVzdWx0LnJlZGlyZWN0VXJpLnNwbGl0KFxcXCJjb2RlPVxcXCIpWzFdO1xcbiAgICAgICAgcmV0dXJuIGNvZGU7XFxuICAgIH0sXFxuICAgIGdldFRva2VuKGJvZHkpIHtcXG4gICAgICAgIGxldCBqc29uID0gcG9zdCgnaHR0cHM6Ly9hcGkueGhvZmUudG9wL2FsaXN0L2FsaV9vcGVuL2NvZGUnLCB7XFxuICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAnVXNlci1BZ2VudCc6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJ1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksXFxuICAgICAgICB9KTtcXG4gICAgICAgIGlmICghanNvbikge1xcbiAgICAgICAgICAgIGpzb24gPSBwb3N0KCdodHRwczovL2FwaS1jZi5ubi5jaS9hbGlzdC9hbGlfb3Blbi9jb2RlJywge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnVXNlci1BZ2VudCc6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLydcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoanNvbi5pbmNsdWRlcygnVG9vIE1hbnkgUmVxdWVzdHMnKSB8fCBqc29uLmluY2x1ZGVzKFxcXCI1MDIgQmFkIEdhdGV3YXlcXFwiKSkge1xcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi6aKR57mB6K+35rGC5pqC5pe26KKr5bCB56aBXFxcXG5cXFwiICsganNvbik7XFxuIC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ICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiBnZXRfcXJjb2RlX2NvZGUoc2lkKTtcXG4gICAgfSxcXG4gICAgZ2V0VG9rZW4oYm9keSkge1xcbiAgICAgICAgbGV0IHJlcyA9IHBvc3QoXFxcImh0dHBzOi8vb3BlbmFwaS5hbGl5dW5kcml2ZS5jb20vb2F1dGgvYWNjZXNzX3Rva2VuXFxcIiwge1xcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG5cXG4gICAgICAgIHJldHVybiBkYXRhO1xcbiAgICB9LFxcbiAgICBnZXRPcGVuVG9rZW4oKSB7XFxuICAgICAgICByZXR1cm4gdGhpcy5nZXRUb2tlbih7XFxuICAgICAgICAgICAgY29kZTogdGhpcy5nZXRPcGVuVG9rZW5Db2RlKCksXFxuICAgICAgICAgICAgZ3JhbnRfdHlwZTogXFxcImF1dGhvcml6YXRpb25fY29kZVxcXCIsXFxuICAgICAgICAgICAgY2xpZW50X3NlY3JldDogdGhpcy5jbGllbnRfc2VjcmV0LFxcbiAgICAgICAgICAgIGNsaWVudF9pZDogdGhpcy5jbGllbnRfaWQsXFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgcmVmcmVzaE9wZW5Ub2tlbigpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLmdldFRva2VuKHtcXG4gICAgICAgICAgICBncmFudF90eXBlOiBcXFwicmVmcmVzaF90b2tlblxcXCIsXFxuICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogdGhpcy4kdGhpcy5vcGVuVG9rZW5zLlJlZnJlc2hUb2tlbk9wZW4sXFxuICAgICAgICAgICAgY2xpZW50X3NlY3JldDogdGhpcy5jbGllbnRfc2VjcmV0LFxcbiAgIC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VsdChsaXN0Lm1hcCh2ID0+ICh7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoKS5sYXp5UnVsZSh2ID0+ICQucmVxdWlyZShcXFwicmVkaXJlY3RcXFwiKS5kZWFsUmVzdWx0KHYpLCB2KSxcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHYudGl0bGUgfHwgdi5hbGlVcmwucmVwbGFjZSgvaHR0cC4qP1xcXFwvc1xcXFwvLywgXFxcIlxcXCIpXFxuICAgICAgICAgICAgfSkpKTtcXG4gICAgICAgIH0sIGxpc3QsIGNvbCk7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0RXJyb3JQb3AobmFtZSwgYXV0aG9yKSB7XFxuICAgIHJldHVybiAkKFxcXCLmkJzntKLlvJXmk47jgIxcXFwiICsgbmFtZSArIFxcXCLjgI3lpLHmlYjor7fogZTns7vmkJzntKLlvJXmk47kvZzogIVcXFwiICsgKGF1dGhvciA/IFxcXCJbXFxcIiArIGF1dGhvciArIFxcXCJdXFxcIiA6IFxcXCJcXFwiKSArIFxcXCLkv67lpI3miJbliKDpmaRcXFxcblxcXFxu5byV5pOO5L2c6ICF5Y+v5Lul5Y675a6Y5pa56aKR6YGT6K+i6ZeuXFxcXG7ngrnlh7vnoa7lrprlv6vpgJ/liKDpmaRcXFwiKS5jb25maXJtKChuYW1lKSA9PiB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpFxcXCIgKyBuYW1lICsgXFxcIuWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobmFtZSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWd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HZhbHVlLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcbiAgICAgICAgaWYgKGVzY2FwZSkge1xcbiAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1xcXFxcXFxcJykge1xcbiAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcbiAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICB9XFxuICAgIHJldHVybiBwYXRoO1xcbn1cXG5cXG5mdW5jdGlvbiBnZXRKc29uKG9iaiwgcGF0aCkge1xcbiAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgfVxcbiAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIHJldHVybiBvYmo7XFxuICAgIH1cXG4gICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0a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gICAgICAgY2xlYXJNeVZhcihcXFwibW91bnR6aW11XFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImFsaVNoYXJlVG9rZW5cXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJWYXIoXFxcImRtX3NoYXJlXFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImRtbGlzdFxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJsaXN0U2VhcmNoS2V5XFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImRtX2xpc3RVcmxMaXN0XFxcIik7XFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgc2V0TWFya2VyKCk7XFxuICAgICAgICBpZiAoTVlfUEFSQU1TLmlzSG9tZSkge1xcbiAgICAgICAgICAgIC8vc2lnbkluUmV3YXJkKGFsaUFjY2Vzc0FwaSk7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5aSH5Lu955uYXFxcIiArIFtcXFwiXFxcIiwgXFxcIuKImlxcXCJdW051bWJlcihpc0JhY2t1cERyaXZpZCldLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibXlBbGlQYW5Ecml2aWRcXFwiLCBcXFwidHJ1ZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAg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hcmVUb2tlbik7XFxuICAgICAgICAgICAgICAgICAgICBhbGlBY2Nlc3NBcGkuc2V0TXlEcml2aWRUeXBlKGlzQmFja3VwRHJpdmlkKTtcXG4gICAgICAgICAgICAgICAgICAgIGFsaUFjY2Vzc0FwaS5jb3B5RmlsZVRvQ2xvdWRGaWxlKHNoYXJlSW5mby5maWxlSWQsIGZpbGVJZCk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrVG9Ib21lKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUluZm8sIGlzQmFja3VwRHJpdmlkLCBmaWxlSWQpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCFpc1NlYXJjaCkge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaQnOe0olxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXlhbPplK7or41cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNmdWxsVGhlbWUjP3BhZ2U9ZnlwYWdlJnNlYXJjaEtleT1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6IFxcXCJwdXRNeVZhcignbGlzdFNlYXJjaEtleScsaW5wdXQpXFxcIixcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgc2VhcmNoS2V5ICsgXFxcIuKAneKAneeahOaQnOe0oue7k+aenFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmdW5jSXRlbXMgPSBbXTtcXG4gICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc3R5bGUsXFxuICAgICAgICAgICAgdXJsOiAkKHN0eWxlcywgMSwgXFxcIuaOkuW4g+agt+W8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImFsaXl1bl9zdHlsZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNolxcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ljb24uc3ZnXFxcIlxcbiAgICAgICAgfSwge1xc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XFwiXSwgMiwgXFxcIuabtOWkmuWKn+iDvVxcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZG1Nb3VudCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuafpeeci+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/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9maWxlaW50by5zdmdcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZUlkOiBwYWdlSWQsXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZvbGRlck5hbWU6IGdldFBhZ2VUaXRsZSgpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCJBTExcXFwiLC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IHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwibW92aWVfMlxcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcInZpZGVvXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwi6L+95Ymn5qih5byP5Y+q5pi+56S65paH5Lu25aS55ZKM6KeG6aKRXFxcIi5zbWFsbCgpLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSBpZiAoc3R5bGUgPT09IFxcXCLnnIvlm75cXFwiKSB7XFxuICAgICAgICBmb2xkZXJTdHlsZSA9IFxcXCJhdmF0YXJcXFwiO1xcbiAgICAgICAgZmlsZVN0eWxlID0gXFxcImNhcmRfcGljXzNcXFwiO1xcbiAgICAgICAgZmlsdGVyVHlwZS5wdXNoKFxcXCJpbWFnZVxcXCIpO1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIueci+WbvuaooeW8j+WPquaYvuekuuaWh+S7tuWkueWSjOWbvueJh1xcXCIuc21hbGwoKS5mb250Y29sb3IoXFxcImdyZXlcXFwiKSxcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGV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ICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgZmlsZUlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgaXNCYWNrdXBEcml2aWQsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUluZm8sXFxuICAgICAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpOaWh+S7tuWkuVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoZGVsZXRlREZpbGUsIGZpbGVJdGVtLmZpbGVfaWQsIGlzQmFja3VwRHJpdmlkLCBmaWxlSXRlbS5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIGlmIChub1NraXBGaWxlKSB7XFxuICAgICAgICAgICAgaWYgKGZpbHRlclR5cGUubGVuZ3RoID4gMCAmJiAhZmlsdGVyVHlwZS5pbmNsdWRlcyhjYXRlKSkge1xcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHN1YnRpdGxlLCBjbHMsIGxvbmdjID0gW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaTmlofku7ZcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhkZWxldGVERmlsZSwgZmlsZUl0ZW0uZmlsZV9pZCwgaXNCYWNrdXBEcml2aWQsIGZpbGVJdGVtLm5hbWUpXFxuICAgICAgICAgICAgfV07XFxuICAgICAgICAgICAgbGV0IHRpdGxlID0gZmlsZUl0ZW0ubmFtZTtcXG4gICAgICAgICAgICBsZXQgbmFtZU5vdEV4dCA9IGZpbGVJdGVtLm5hbWUucmVwbGFjZSgnLicgKyBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbiwgJycpO1xcbiAgICAgICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uKSkge1xcbiAgICAgICAgICAgICAgICBsb25nYy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5oyC6L295a2X5bmVXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh6bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdtb3VudHppbXUnLCB6bSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+aMgui9veWujOaIkO+8jOW9k+WJjeWtl+W5leaWh+S7tjogJyArIHptLm5hbWUgKyAnLicgKyB6bS5leHQ7XFxuICAgICAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0OiBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2lkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IG5hbWVOb3RFeHRcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGNhdGUgPT09IFxcXCJ2aWRlb1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHppbXVsaXN0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgc3VidGl0bGUgPSB6aW11bGlzdC5maW5kKHYgPT4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cXG4gICAgICAgICAgICAgICAgcGljX3VybDogcGljX3VybCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBsb25nYyxcXG4gICAgICAgICAgICAgICAgICAgIGNsczogY2xzLFxcbiAgICAgICAgICAgICAgICAgICAgLy9pbmhlcml0VGl0bGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBmaWxlU3R5bGVcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBpZiAoY29udHMubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInkuoblk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5sZXQgaXRlbXMgPSBbXTtcXG50cnkge1xcbiAgICBpZiAoTVlfUEFHRSA+IDEgJiYgIU1ZX1BBUkFNUy5tYXJrZXIpIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfM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gICBhbGl1cmwgPSBwbGF5VXJsTGlzdC5maW5kKHYgPT4gdi50ZW1wbGF0ZV9pZCA9PSBsaW5lKVt1cmxuYW1lXTtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICB0aHJvdyBlO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGFsaXVybDtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBnZXRNM3U4Q29udGVudChwbGF5dXJsKSB7XFxuICAgICAgICAvL21lZGlhLm0zdThcXG4gICAgICAgIGxldCBob21lID0gcGxheXVybC5zcGxpdChzdWZmaXgpWzBdO1xcbiAgICAgICAgbGV0IGYgPSBmZXRjaChwbGF5dXJsLCB7XFxuICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGltZW91dDogMzAwMFxcbiAgICAgICAgfSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICBsZXQgZmYgPSBmLm1hcChpdCA9PiB7XFxuICAgICAgICAgICAgaWYgKGl0LnN0YXJ0c1dpdGgoXFxcIm1lZGlhLVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiL3Byb3h5P3VybD1cXFwiICsgYmFzZTY0RW5jb2RlKGhvbWUgKyBpdCkrXFxcIiZ0aW1lc3RhbXA9XFxcIitNWV9QQVJBTVMudGltZXN0YW1wWzBdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gaXQ7XFxuICAgICAgICB9KS5qb2luKFxcXCJcXFxcblxcXCIpO1xcblxcbiAgICAgICAgd3JpdGVGaWxlKGNhY2hlRmlsZVBhdGgsIGZmKTtcXG4gICAgICAgIHJldHVybiBmZjtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiB1cGRhdGVUc1VybCh1cmwpIHtcXG4gICAgICAgIGxldCBmaWQgPSB1cmwuc3BsaXQoJyZmPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICAvL2xvZygnc2ZpZC0nICsgZmlkKTtcXG4gICAgICAgIGxldCBmID0gZmV0Y2goY2FjaGVGaWxlUGF0aCkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICBmLmZvckVhY2goaXQgPT4ge1xcbiAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpLnNwbGl0KFxcXCImXFxcIilbMF0pO1xcbiAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgZXhwaXJlcyA9IHVybC5zcGxpdCgneC1vc3MtZXhwaXJlcz0nKVsxXS5zcGxpdCgnJicpWzBdO1xcbiAgICAgICAgY29uc3QgbGFzdHRpbWUgPSBwYXJzZUludChleHBpcmVzKSAtIERhdGUubm93KCkgLyAxMDAwO1xcbiAgICAgICAgaWYgKGxhc3R0aW1lIDwgNjApIHtcXG4gICAgICAgICAgICAvL2xvZygn6L+H5pyf5pu05pawJylcXG4gICAgICAgICAgICBsZXQgbGluZSA9IHVybC5zcGxpdCgnL21lZGlhJylbMF07IC8v5Y+W5LmL5YmN5pKt5pS+55qEdHPmrrXnur/ot69cXG4gICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcobGluZS5sYXN0SW5kZXhPZignLycpICsgMSk7XFxuICAgICAgICAgICAgbGV0IGYgPSBnZXRNM3U4Q29udGVudChnZXRBbGlQbGF5VXJsKGZpZCwgbGluZSkpLnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZnVybCA9IGJhc2U2NERlY29kZShpdC5yZXBsYWNlKCcvcHJveHk/dXJsPScsICcnKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGZ1cmw7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHVybDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHVybCA9IGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKTtcXG4gICAgICAgIGlmICh1cmwuaW5jbHVkZXMoXFxcIi50c1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiB1cGRhdGVUc1VybCh1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHRlbXBsYXRlSWQgPSBNWV9QQVJBTVMudGVtcGxhdGVJZFswXTtcXG4gICAgICAgICAgICBpZihmaWxlRXhpc3QoY2FjaGVGaWxlUGF0aCkpe1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TTN1OENvbnRlbnQoZ2V0QWxpUGxheVVybChmaWxlSWQsIHRlbXBsYXRlSWQpKTtcXG4gICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGdldE0zdThDb250ZW50KHVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coXFxcIiPku6PnkIbmkq3mlL7lpLHotKUjXFxcXG7plJnor6/kv6Hmga8+XFxcIiArIGUudG9TdHJpbmcoKSArIFxcXCJcXFxcbumUmeivr+ihjD5cXFwiICsgZS5saW5lTnVtYmVyKTtcXG4gICAgfVxcbn1cXG5jb25zdCB0cmFuc2NvZGluZyA9IHtcXG4gICAgVUhEOiBcXFwiNEsg6LaF5riFXFxcIixcXG4gICAgUUhEOiBcXFwiMksg6LaF5riFXFxcIixcXG4gICAgRkhEOiBcXFwiMTA4MCDlhajpq5jmuIVcXFwiLFxcbiAgICBIRDogXFxcIjcyMCDpq5jmuIVcXFwiLFxcbiAgICBTRDogXFxcIjU0MCDm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3VudHN1YiA9IHN0b3JhZ2UwLmdldE15VmFyKCdtb3VudHppbXUnLCB7fSk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMobW91bnRzdWIpLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICB6aW11ID0gbW91bnRzdWI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc3VidGl0bGU7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMoemltdSB8fCB7fSkubGVuZ3RoID4gMCAmJiBwbGF5TGlzdCAmJiBwbGF5TGlzdC51cmxzICYmIHBsYXlMaXN0LnVybHMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwKTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB2YXIgem11cmwgPSBhbGlBY2Nlc3NBcGkub3BlbkNsb3VkRmlsZVRvRG93blVybCh6aW11LmZpbGVfaWQpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9ICdoaWtlcjovL2ZpbGVzL2NhY2hlL+S6keebmOWQmy9zdWIuJyArIHppbXUuZXh0O1xcbiAgICAgICAgICAgICAgICBkb3dubG9hZEZpbGUoem11cmwsIHBhdGgsIHtcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IGdldFBhdGgocGF0aCk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5a2X5bmV5Yqg6L295aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxvZyhlLm1lc3NhZ2UpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBkbWxpc3QgPSBzdG9yYWdlMC5nZXRNeVZhcihcXFw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ICAgICAgICAgICAgdGl0bGU6IGVwaXNvZGUuZXBpc29kZVRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJChlcGlzb2RlLmVwaXNvZGVJZCkubGF6eVJ1bGUoKHRpdGxlKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhbm11ID0gJC5yZXF1aXJlKFxcXCJkYW5tdVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGRhbm11LmdldExvY2FsRGFuTXUoaW5wdXQsIHRpdGxlKSB8fCBkYW5tdS5kb3dubG9hZERhbk11KGlucHV0LCB0aXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYW5tdVRleHQgPSBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFkYW5tdVRleHQpIHJldHVybiBcXFwidG9hc3Q6Ly/ov5jmsqHmnInlvLnluZXlk59+XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhdGg7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgZG1UaXRsZSksXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgICAgICB9LCBhbmltZS5lcGlzb2RlcywgYW5pbWUuYW5pbWVUaXRsZSksXFxuICAgICAgICB9KTtcXG5cXG4gICAgfVxcbiAgICByZXR1cm4gZDtcXG59XFxuc2VhcmNoKGlucHV0KVwifV0iLCJpY29uIjoiaHR0cHM6Ly9pbWcuYWxpY2RuLmNvbS9pbWdleHRyYS9pMi9PMUNOMDFET1ljczcxdjNCNmJPZW1WTV8hITYwMDAwMDAwMDYxMTYtMi10cHMtNTEyLTUxMi5wbmciLCJwcm94eSI6IiJ9
Add Comment
Please, Sign In to add comment