Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@云盘君.简@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoi5LqR55uY5ZCbLueugCIsImF1dGhvciI6IuWwj+ajieiihPCfjJ4mQExveURnSWsiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjoxNDYsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoiYWxsIiwiY2xhc3NfdXJsIjoiIiwiYXJlYV9uYW1lIjoiIiwiYXJlYV91cmwiOiIiLCJzb3J0X25hbWUiOiIiLCJ5ZWFyX25hbWUiOiIiLCJzb3J0X3VybCI6IiIsInllYXJfdXJsIjoiIiwiZmluZF9ydWxlIjoianM6JC5yZXF1aXJlKFwiTWFpblwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zZWFyY2hUZXJtcz0qKiIsImdyb3VwIjoi4p6K4pOR6ZuG5ZCIIiwic2VhcmNoRmluZCI6ImpzOlxuc2V0UmVzdWx0KFt7XG4gICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5pCc57SiXCIgKyBNWV9LRVlXT1JELFxuICAgIHVybDogXCJoaWtlcjovL3BhZ2Uvc291I25vSGlzdG9yeSM/cD1meXBhZ2VcIixcbiAgICBleHRyYToge1xuICAgICAgICBwYWdlVGl0bGU6IFwi5pCc57SiXCIgKyBNWV9LRVlXT1JELFxuICAgICAgICBzZWFyY2hUZXJtczogTVlfS0VZV09SRCxcbiAgICAgICAgaGlkZVNldHRpbmc6IHRydWVcbiAgICB9XG59XSk7IiwiZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsImRldGFpbF9maW5kX3J1bGUiOiIiLCJzZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsInNkZXRhaWxfZmluZF9ydWxlIjoiI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4gICAgcnVsZSA9IGdldENvbXBsZXRlUnVsZShydWxlKTtcXG4gICAgbGV0IGxpc3QgPSBydWxlLmZpbmQocywgcGFnZSk7XFxuICAgIGlmICghbGlzdCkgcmV0dXJuIFtdO1xcblxcbiAgICBsZXQgZGVzY1RpcHMgPSBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIHJ1bGUubmFtZS5mb250Y29sb3IoXFxcIiNmMTNiNjZhXFxcIikgKyBcXFwiJm5ic3A7XFxcIjtcXG4gICAgbGV0IHJlc0xpc3QgPSBbXTtcXG5cXG4gICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xcbiAgICAgICAgaWYgKGl0LnNraXApIHtcXG4gICAgICAgICAgICByZXNMaXN0LnB1c2goaXQpO1xcbiAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHNlYXJjaE1vZGUgJiYgIXNlYXJjaENvbnRhaW5zKGl0LnRpdGxlLCBzLCB0cnVlKSkgY29udGludWU7XFxuICAgICAgICBpZiAocnVsZS5maW5kQWxpVXJsKSB7XFxuICAgICAgICAgICAgaXQudXJsID0gJChpdC51cmwpLmxhenlSdWxlKHRvUmVkaXJlY3RUcmVhdGluZywge1xcbiAgICAgICAgICAgICAgICBmaW5kQWxpVXJsOiBydWxlLmZpbmRBbGlVcmwsXFxuICAgICAgICAgICAgICAgIGJhc2ljVXJsOiBydWxlLmJhc2ljVXJsLFxcbiAgICAgICAgICAgICAgICBuYW1lOiBydWxlLm5hbWUsXFxuICAgICAgICAgICAgICAgIGFsaVVybDogaXQudXJsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGl0LnVybCA9ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUodG9SZWRpcmVjdCwgaXQudXJsLCBpdC5zaGFyZVB3ZCB8fCBcXFwiXFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICByZXNMaXN0LnB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OiOt+WPluezu+e7n+WJqui0tOadv1xcbiAgICAgICAgICAgIGxldCBjbGlwYm9hcmQgPSBjb250ZXh0LmdldFN5c3RlbVNlcnZpY2UoQ29udGV4dC5DTElQQk9BUkRfU0VSVklDRSk7XFxuICAgICAgICAgICAgLy8g6L+U5Zue5pWw5o2uXFxuICAgICAgICAgICAgbGV0IGNsaXBEYXRhID0gY2xpcGJvYXJkLmdldFByaW1hcnlDbGlwKCk7XFxuICAgICAgICAgICAgaWYgKGNsaXBEYXRhICE9IG51bGwgJiYgY2xpcERhdGEuZ2V0SXRlbUNvdW50KCkgPiAwKSB7XFxuICAgICAgICAgICAgICAgIC8vIOS7juaVsOaNrumbhuS4reiOt+WPlu+8iOeymOi0tO+8ieesrOS4gOadoeaWh+acrOaVsOaNrlxcbiAgICAgICAgICAgICAgICBsZXQgdGV4dCA9IGNsaXBEYXRhLmdldEl0ZW1BdCgwKS5nZXRUZXh0KCk7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0ICE9IG51bGwpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcodGV4dC50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgdGV4dCA9IGdldENvcHkoKSB8fCBcXFwiXFxcIjtcXG4gICAgbGV0IHVybCA9IGFsaXRlc3QubWF0Y2hBbGlVcmwodGV4dCk7XFxuICAgIGlmICh1cmwpIHtcXG4gICAgICAgIGxldCBjYWNoZSA9IGdldEl0ZW0oXFxcImNsaXBib2FyZENhY2hlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKHVybCAhPT0gY2FjaGUpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnTxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLmo4DmtYvliLDliarotLTmnb/lkKvmnInpmL/ph4zpk77mjqXmmK/lkKbmiZPlvIA/XFxcXG5cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlucHV0LCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShpZCArIFxcXCJjbGlwYm9hcmRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpICsgXFxcIiZzaGFyZVB3ZD1cXFwiO1xcbiAgICAgICAgICAgICAgICB9LCB1cmwsIGlkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcImNsaXBib2FyZFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IFxcXCLmiZPlvIDpk77mjqVcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJjbGlwYm9hcmRDYWNoZVxcXCIsIHVybCk7XFxuICAgICAgICB9XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0UHJlcG9zZSgpIHtcXG4gICAgaWYgKG9wZW5Nb2RlID09IFxcXCLmnKzlnLDop6PmnpBcXFwiKSB7XFxuICAgICAgICBsZXQgYWxpVG9rZW5zRmlsZXBhdGggPSAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS90b2tlblBhdGhcXFwiKS5hbGlUb2tlbnNGaWxlcGF0aDtcXG4gICAgICAgIGxldCBhID0gZmV0Y2goYWxpVG9rZW5zRmlsZXBhdGgpO1xcbiAgICAgICAgaWYgKCFhIHx8IGEgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwicmljaF90ZXh0XFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4gJC5yZXF1aXJlKFxcXCJsb2dpbk1vZGVcXFwiKSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKrmo4DmtYvliLDnmbvlvZXkv6Hmga/vvIzngrnmiJHot7PovaznmbvlvZXotKblj7fpobXpnaLvvIznmbvlvZXpmL/ph4zkupHnm5jotKblj7flkI7mlrnlj6/kvb/nlKjmnKzlnLDop6PmnpDmqKHlvI9cXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBcXFwi55m75b2V6Zi/6YeM5LqR55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgYWRkTGlzdGVuZXIoXFxcIm9uQ2xvc2VcXFwiLCAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICA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BcXFwi6KeE5YiZ566h55CGXFxcIiwgXFxcIuaUr+aMgeS9nOiAhVxcXCJdLCAxLCBcXFwi5LqR566A6K6+572uXFxcIikuc2VsZWN0KChpZHMpID0+IHtcXG4gICAgICAgICAgICBpZiAoXFxcIuinhOWImeeuoeeQhlxcXCIgPT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZU1hbmFnZSNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoXFxcIuaUr+aMgeS9nOiAhVxcXCIgPT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvRG9uYXRlLnYjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKFxcXCLnmbvlvZXpmL/ph4zotKblj7dcXFwiID09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcImxvZ2luTW9kZVxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoXFxcIueZu+W9leS/oeaBr1xcXCIgPT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgY29uc3Qge1xcbiAgICAgICAgICAgICAgICAgICAgb3BlblRva2Vuc0ZpbGVwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgYWxpVG9rZW5zRmlsZXBhdGhcXG4gICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwidG9rZW5QYXRoXFxcIik7XFxuICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KGFsaVRva2Vuc0ZpbGVwYXRoKSkgcmV0dXJuIFxcXCJ0b2FzdDovL+i/mOacqueZu+mZhlxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCBhbGkgPSByZXF1ZXN0KGFsaVRva2Vuc0ZpbGVwYXRoKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaSA9IEpTT04ucGFyc2UoYWxpKTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlRmlsZShhbGlUb2tlbnNGaWxlcGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6I635Y+W5aSx6LSlXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn55m75b2V5L+h5oGvJyxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLnlKjmiLc6XFxcIiArIChhbGkubmlja19uYW1lIHx8IGFsaS51c2VyX25hbWUgfHwgXFxcIlRva2Vu55m75b2VXFxcIikgKyBcXFwiXFxcXG5Ub2tlbjpcXFwiICsgYWxpLnJlZnJlc2hfdG9rZW4gKyBcXFwiXFxcXG4o5Y+W5raI77ya5rOo6ZSA55m75b2V77yb56Gu5a6a77ya5aSN5Yi2VG9rZW4pXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbmZpcm06ICQudG9TdHJpbmcoKHRva2VuKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIHRva2VuO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYWxpLnJlZnJlc2hfdG9rZW4pLFxcbiAgICAgICAgICAgICAgICAgICAgY2FuY2VsOiAkLnRvU3RyaW5nKChwYXRoMSwgcGF0aDIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5rOo6ZSA55m75b2VXFxcIikuY29uZmlybSgocGF0aDEsIHBhdGgyKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUZpbGUocGF0aDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVGaWxlKHBhdGgyKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suaIkOWKn+mAgOWHuueZu+mZhlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgcGF0aDEsIHBhdGgyKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGFsaVRva2Vuc0ZpbGVwYXRoLCBvcGVuVG9rZW5zRmlsZXBhdGgpXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlucHV0ID0gaW5wdXQucmVwbGFjZShcXFwi5qih5byP77yaXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcIm9wZW5Nb2RlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWRzLCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6+572ufFxcXCIgKyBpbnB1dFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6Y5pa5QVBQXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5Yqf77yM6K+356Gu5L+d5omL5py65pyJ5a6J6KOF6Zi/6YeM5LqR55uY562J5a6Y5pa5QVBQXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LCBpZCArIFxcXCJtb2RlXFxcIiksXFxuICAgICAgICBjb2xfdHlwZTogXFxcImljb25fMl9yb3VuZFxcXCIsXFxuICAgICAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9tZW51NlxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBpZCArIFxcXCJtb2RlXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiAn5pCc57SiJyxcXG4gICAgICAgIGRlc2M6ICfor7fovpPlhaXlhbPplK7or40v6ZO+5o6lJyxcXG4gICAgICAgIGNvbF90eXBlOiAnaW5wdXQnLFxcbiAgICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICBpZiAoJC5yZXF1aXJlKFxcXCJhbGl0ZXN0XFxcIikudGVzdChpbnB1dCkpIHtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwic1xcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9hbGl5dW4/cGFnZT1meXBhZ2UmcmVhbHVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KSArIFxcXCImc2hhcmVQd2Q9XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcInNcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIG9uQ2hhbmdlOiBcXFwicHV0TXlWYXIoJ3JlZnMnLGlucHV0KVxcXCIsXFxuICAgICAgICAgICAgaWQ6IGlkICsgXFxcInNzXFxcIixcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHMsXFxuICAgICAgICAgICAgcGFnZVRpdGxlOiBcX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tKFxcXCJydWxlR3JvdXBcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJydWxlXFxcIik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCJcXG4gICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCJcXFwiID09IHIgPyBcXFwi4oCc4oCc5YWo6YOo4oCd4oCdXFxcIiA6IFxcXCLlhajpg6hcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChzLCBpZCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBxciA9IGdldEl0ZW0oXFxcInJ1bGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJydWxlXFxcIik7XFxuICAgICAgICAgICAgaWYgKHMpIHtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCLlhajpg6hcXFwiICsgaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc5YWo6YOo4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgaWYgKHFyKSB7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgcXIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogcXJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBzLCBpZCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcIuWFqOmDqFxcXCIgKyBpZFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZm9yIChsZXQgW2l0LCBiYXNpY1VybF0gb2YgcnVsZXMpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IGl0ID09IHIgPyBcXFwi4oCc4oCcXFxcIiArIGl0ICsgXFxcIuKAneKAnVxcXCIgOiBpdCxcXG4gICAgICAgICAgICB1cmw6ICQoKGJhc2ljVXJsIHx8IFxcXCJcXFwiKSArIFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChyLCBzLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgcXIgPSBnZXRJdGVtKFxcXCJydWxlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlXFxcIiwgcik7XFxuICAgICAgICAgICAgICAgIGlmIChzKSB7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShxciA/IChpZCArIHFyKSA6IChcXFwi5YWo6YOoXFxcIiArIGlkKSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBxciB8fCBcXFwi5YWo6YOoXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgciwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHIgKyBcXFwi4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICAgICAg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ICAgICAgIHRpdGxlOiBcXFwi5Yqg6L2956ysXFxcIiArIHAgKyBcXFwi6aG15Lit77yM6L+b5bqm77yaMS9cXFwiICsgZGF0YS5sZW5ndGgsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBpZDogcGFnZWlkXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgc2V0UmVzdWx0KGQpO1xcbiAgICBpZiAoZGF0YS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAvL+Wkmue6v+eoi+WKoOi9vSAgICAgICAgXFxuICAgICAgICBsZXQgcmVhbFBhZ2UgPSBcXFwiXFxcIiA9PSByID8gMSA6IHA7XFxuICAgICAgICBsZXQgdGFza3MgPSBkYXRhLm1hcChpdCA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgZnVuYzogZnVuY3Rpb24ocnVsZSkge1xcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJkYXRhXFxcIikuY2FycnlSdWxlKHJ1bGUsIHMsIHJlYWxQYWdlLCBzZWFyY2hNb2RlKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2cocnVsZS5uYW1lICsgXFxcIjpcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvKmlmKGRhdGEubGVuZ3RoPT09MSYmcD09PTEpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOlxcXCLigJzigJxcXFwiK3J1bGUubmFtZStcXFwiIEVSUk9S4oCd4oCdXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDpcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1dO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgLy9yZXR1cm4gcnVsZS5maW5kKHMsIHJlYWxQYWdlKTtcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgcGFyYW06IGl0LFxcbiAgICAgICAgICAgICAgICBpZDogXFxcInJ1bGVAXFxcIiArIGl0Lm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgICAgIGJhdGNoRXhlY3V0ZSh0YXNrcywge1xcbiAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKHBhcmFtLCBpZCwgZXJyb3IsIHJlc3VsdCkge1xcbiAgICAgICAgICAgICAgICBwYXJhbS5pICs9IDE7XFxuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHJlc3VsdCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQmVmb3JlKHBhZ2VpZCwgcmVzdWx0KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAocGFyYW0uaSA9PT0gcGFyYW0uYWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXJlc3VsdCB8fCAhcmVzdWx0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUJlZm9yZShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjotYTmupDpg73msqHmnInlk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJfbm90aGF2ZVxcXCJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShwYWdlaWQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWKoOi9veesrFxcXCIgKyBNWV9QQUdFICsgXFxcIumhteS4re+8jOi/m+W6pu+8mlxcXCIgKyAocGFyYW0uaSArIDEpICsgXFxcIi9cXFwiICsgcGFyYW0uYWxsLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICBhbGw6IGRhdGEubGVuZ3RoLFxcbiAgICAgICAgICAgICAgICBpOiAwLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0SGlzdG9yeSgpIHtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiAnPHNwYW4gc3R5bGU9XFxcImNvbG9yOiNmZjY2MDFcXFwiPjxiPuWOhuWPsuiusOW9lTwvYj48L3NwYW4+JyxcXG4gICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX2Nsb2NrXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYXZhdGFyXFxcIixcXG4gICAgICAgIHVybDogJChbXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIsIFxcXCLmiZPlvIDop4LnnIvorrDlvZVcXFwiXSkuc2VsZWN0KChpZCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruWumua4hemZpOWFqOmDqOaQnOe0ouiusOW9le+8n1xcXCIpLmNvbmZpcm0oKGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhpZCArIFxcXCI6a2V5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSwgaWQpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9oaXN0b3J5P3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICBsZXQgaSA9IDA7XFxuICAgIGZvciAobGV0IGtleSBvZiBoaXN0b3J5KSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBrZXksXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpZCwga2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBleHRyYSA9IGZpbmRJdGVtKGlkICsgXFxcInNzXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIGV4dHJhLmRlZmF1bHRWYWx1ZSA9IGtleTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh7XFxuICAgICAgICAgICAgICAgICAgICBleHRyYTogZXh0cmFcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgaWQsIGtleSksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJmbGV4X2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcIjprZXk6XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgY2xzOiBpZCArIFxcXCI6a2V5XFxcIixcXG4gICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaTlhbPplK7or406XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpZCwga2V5LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpc3Rvcnkuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBoaXN0b3J5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKGlkICsgXFxcIjprZXk6XFxcIiArIGtleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy90b2FzdCgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgaWQsIGtleSwgaSlcXG4gICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBpZiAoaGlzdG9yeS5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRUcmVuZGluZ1RhYkVuZCgpIHtcXG4gICAgbGV0IGhvdENsYXNzID0ge1xcbiAgICAgICAgXFxcIueZvuW6plxcXCI6IHtcXG4gICAgICAgICAgICBcXFwi55S16KeG5YmnXFxcIjogXFxcInRlbGVwbGF5XFxcIixcXG4gICAgICAgICAgICBcXFwi55S15b2xXFxcIjogXFxcIm1vdmllXFxcIlxcbiA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ly/lt7LliIfmjaLkuLpcXFwiICsgaW5wdXQ7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYXZhdGFyXFxcIixcXG4gICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX2ZpcmVcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5YiH5o2i5pWw5o2u5rqQXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGRhdGFTb3VyY2UpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGRhdGFTb3VyY2UsIDEsIFxcXCLliIfmjaLmlbDmja7mupBcXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImRhdGFTb3VyY2VcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJob3RrZXlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNouS4ulxcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9LCBkYXRhU291cmNlKVxcbiAgICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmraPlnKjliqDovb0uLi5cXFwiLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOmhvdGtleVxcXCIsXFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIGxldCBzZCA9IFtdO1xcbiAgICBsZXQgc2V0U2VhcmNoS2V5ID0gbmFtZSA9PiB7XFxuICAgICAgICBwdXRNeVZhcigncycsIG5hbWUpO1xcbiAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIHJldHVybiAnaGlrZXI6Ly9lbXB0eSdcXG4gICAgfTtcXG5cXG4gICAgbGV0IGdldFRpdGxlID0gKGksIG5hbWUpID0+IHtcXG4gICAgICAgIGxldCBjb2xvcjtcXG4gICAgICAgIHN3aXRjaCAoaSkge1xcbiAgICAgICAgICAgIGNhc2UgMDpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiI2ZmMzMwMFxcXCI7XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgMTpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiI2ZmNjYwMFxcXCI7XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgMjpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiI2ZmOTkwMFxcXCJcXG4gICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgZGVmYXVsdDpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiYmxhY2tcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIFxcXCLigJzigJzigJ3igJ1cXFwiICsgU3RyaW5nKGkgKyAxKS5mb250Y29sb3IoY29sb3IpICsgXFxcIlxcXFx0XFxcXHRcXFxcdFxcXCIgKyBuYW1lO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBzd2l0Y2ggKHNlbGVjdHNvdXJjZSkge1xcbiAgICAgICAgICAgIGNhc2UgXFxcIueZvuW6plxcXCI6XFxuICAgICAgICAgICAgICAgIHZhciBqc29uID0gcmVxdWVzdCgnaHR0cHM6Ly90b3AuYmFpZHUuY29tL2FwaS9ib2FyZD9wbGF0Zm9ybT13aXNlJnRhYj0nICsgdGFia2V5ICsgJyZ0YWc9JTdCJTIyY2F0ZWdvcnklMjI6JTIyJUU1JTg1JUE4JUU5JTgzJUE4JUU3JUIxJUJCJUU1JTlFJThCJTIyJTdEJywge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICdVc2VyLUFnZW50JzogJ01vemlsbGEvNS4wIChMaW51eDsgQW5kcm9pZCA2LjA7IE5leHVzIDUgQnVpbGQvTVJBNThOKSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTkuMC40ODQ0LjUxIE1vYmlsZSBTYWZhcmkvNTM3LjM2JyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAnSG9zdCc6ICd0b3AuYmFpZHUuY29tJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAnQWNjZXB0JzogJ2FwcGxpY2F0aW9uL2pzb24sIHRleHQvcGxhaW4sICovKicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1MYW5ndWFnZSc6ICd6aC1DTix6aDtxPTAuOSxlbi1VUztxPTAuOCxlbjtxPTAuNycsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1FbmNvZGluZyc6ICdnemlwLCBkZWZsYXRlLCBicicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly90b3AuYmFpZHUuY29tL2JvYXJkP3RhYj1ub3ZlbCcsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAvL3ZhciBzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBKU09OLnBhcnNlKGpzb24pLmRhdGEuY2FyZHNbMF0uY29udGVudDtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0ZW0ud29yZCArICcgKCcgKyBpdGVtLnNob3dbMl0gKyAnKSc7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGVzID0gaXRlbS5kZXNjO1xcbiAgICAgICAgICAgICAgICAgICAgc2QucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGdldFRpdGxlKGksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZShzZXRTZWFyY2hLZXksIGl0ZW0ud29yZCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaXRlbS5pbWcsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJtb3ZpZV8xX3ZlcnRpY2FsX3BpY1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgXFxcIuWkuOWFi1xcXCI6XFxuICAgICAgICAgICAgICAgIHZhciBqc29uID0gcmVxdWVzdChcXFwiaHR0cHM6Ly9uZXdzLm15cXVhcmsuY24vdjIvdG9wbGlzdC9tb3ZpZT8mY2hhbm5lbD1cXFwiICsgdGFia2V5ICsgXFxcIiZyYW5rX3R5cGU9JUU2JTlDJTgwJUU3JTgzJUFEXFxcIik7XFxuICAgICAgICAgICAg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AgIFxcXCJcXFxcblxcXCIgKyBwZGZoKGl0ZW0sIFxcXCJ5ZWFyJiZUZXh0XFxcIikgKyBcXFwiwrdcXFwiICsgcGRmaChpdGVtLCBcXFwiaF9hcmVhJiZUZXh0XFxcIikgKyBcXFwiwrdcXFwiICsgcGRmaChpdGVtLCBcXFwiY2F0ZWdvcnkmJlRleHRcXFwiKS5yZXBsYWNlKFxcXCIsXFxcIiwgXFxcIsK3XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBzZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZ2V0VGl0bGUoaSwgbmFtZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKHNldFNlYXJjaEtleSwgbmFtZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogcGRmaChpdGVtLCBcXFwiaF9zcmMmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcIm1vdmllXzFfdmVydGljYWxfcGljXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICB9XFxuICAgICAgICBhZGRJdGVtQWZ0ZXIoaWQgKyBcXFwiOmhvdGtleVxcXCIsIHNkKTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH0gZmluYWxseSB7XFxuICAgICAgICBkZWxldGVJdGVtKGlkICsgXFxcIjpob3RrZXlcXFwiKTtcXG4gICAgfVxcbn1cXG5sZXQgciA9IGdldEl0ZW0oXFxcInJ1bGVcXFwiLCBcXFwiXFxcIik7XFxubGV0IGhpZGVTZXR0aW5nID0gTVlfUEFSQU1TLmhpZGVTZXR0aW5n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107XFxuXFxubGV0IG9wZW5Nb2RlID0gZ2V0SXRlbShcXFwib3Blbk1vZGVcXFwiKTtcXG5sZXQgcnVsZSA9IE1ZX1JVTEUudGl0bGU7XFxubGV0IHVybCA9IGRlY29kZVVSSUNvbXBvbmVudChnZXRQYXJhbShcXFwid2ViVXJsXFxcIixcXFwiXFxcIikpO1xcblxcbmZ1bmN0aW9uIGludGVyY2VwdChydWxlLCBvcmlnaW4sIG9wZW5Nb2RlKSB7XFxuICAgIGxldCBob3N0ID0gb3JpZ2luLnJlcGxhY2UobmV3IFJlZ0V4cChcXFwiaHR0cDovL3xodHRwczovL1xcXCIpLCBcXFwiXFxcIikuc3BsaXQoXFxcIi9cXFwiKVswXTtcXG4gICAgbGV0IGhvc3RzID0gaG9zdC5zcGxpdChcXFwiLlxcXCIpO1xcbiAgICBpZiAoaG9zdHMubGVuZ3RoID4gMikge1xcbiAgICAgICAgaG9zdCA9IGhvc3RzW2hvc3RzLmxlbmd0aCAtIDJdICsgXFxcIi5cXFwiICsgaG9zdHNbaG9zdHMubGVuZ3RoIC0gMV07XFxuICAgIH1cXG4gICAgaWYgKGlucHV0LnN0YXJ0c1dpdGgoXFxcIm1hZ25ldFxcXCIpKSB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuajgOa1i+WIsOaWsOeahOejgemTvuWcsOWdgO+8jOeCueWHu+ehruWumuaMiemSruWNs+WPr+aSreaUvu+8jOeCueWHu+WPlua2iOaMiemSruWPr+S7peWkjeWItumTvuaOpVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBtYWc7XFxuICAgICAgICAgICAgfSwgaW5wdXQpLFxcbiAgICAgICAgICAgIGNhbmNlbDogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgIC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ICAgICAgICByZXR1cm4gJC50b1N0cmluZygodXJsLCBydWxlKSA9PiB7XFxuICAgICAgICAgICAgZnlfYnJpZGdlX2FwcC5wbGF5VmlkZW8odXJsKTtcXG4gICAgICAgIH0sIGlucHV0LCBydWxlKTtcXG4gICAgfSBlbHNlIGlmICghaW5wdXQuaW5jbHVkZXMoaG9zdCkgJiYgaW5wdXQuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICBsb2coaW5wdXQpO1xcbiAgICAgICAgcmV0dXJuICQudG9TdHJpbmcoKHVybCwgcnVsZSkgPT4ge1xcbiAgICAgICAgICAgIGZ5X2JyaWRnZV9hcHAub3BlbihKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K+m5oOFXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIrZW5jb2RlVVJJQ29tcG9uZW50KHVybCkrXFxcIiZydWxlPVxcXCIrcnVsZSxcXG4gICAgICAgICAgICB9KSlcXG4gICAgICAgIH0sIGlucHV0LCBydWxlKTtcXG4gICAgfSBlbHNlIGlmICghaW5wdXQuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICBsb2coaW5wdXQpO1xcbiAgICAgICAgLy/og73llKTotbdBUFDnmoTnmb3lkI3ljZVcXG4gICAgICAgIGxldCB3aGl0ZSA9IFtcXG4gICAgICAgICAgICBcXFwicWtsaW5rXFxcIixcXG4gICAgICAgICAgICBcXFwiYmRuZXRkaXNrXFxcIixcXG4gICAgICAgICAgICBcXFwieHVubGVpYXBwXFxcIixcXG4gICAgICAgICAgICBcXFwic21hcnRkcml2ZVxcXCJcXG4gICAgICAgIF07XFxuICAgICAgICBsZXQgaW5XaGl0ZSA9IHdoaXRlLmZpbHRlcihpdCA9PiBpbnB1dC5zdGFydHNXaXRoKGl0KSkubGVuZ3RoID4gMD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BbXTtcXG4gICAgICAgICAgICBhbGl1cmwgPSBwbGF5VXJsTGlzdC5maW5kKHYgPT4gdi50ZW1wbGF0ZV9pZCA9PSBsaW5lKS51cmw7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgdGhyb3cgZTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBhbGl1cmw7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZ2V0TTN1OENvbnRlbnQocGxheXVybCkge1xcblxcbiAgICAgICAgLy9sb2coXFxcIuaIkeWcqOS7o+eQhlxcXCIgKyBwbGF5dXJsKTtcXG4gICAgICAgIGxldCBob21lID0gcGxheXVybC5zcGxpdChcXFwibWVkaWEubTN1OFxcXCIpWzBdO1xcbiAgICAgICAgbGV0IGYgPSBmZXRjaChwbGF5dXJsLCB7XFxuICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGltZW91dDogMzAwMFxcbiAgICAgICAgfSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICBsZXQgZmYgPSBmLm1hcChpdCA9PiB7XFxuICAgICAgICAgICAgaWYgKGl0LnN0YXJ0c1dpdGgoXFxcIm1lZGlhLVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiL3Byb3h5P3VybD1cXFwiICsgYmFzZTY0RW5jb2RlKGhvbWUgKyBpdCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBpdDtcXG4gICAgICAgIH0pLmpvaW4oXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAvL2xvZygndWZpZC0nICsgZmlsZWlkKTtcXG4gICAgICAgIHdyaXRlRmlsZShcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvXFxcIiArIGZpbGVJZCArIFxcXCIubTN1OFxcXCIsIGZmKTtcXG4gICAgICAgIHJldHVybiBmZjtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiB1cGRhdGVUc1VybCh1cmwpIHtcXG4gICAgICAgIGxldCBmaWQgPSB1cmwuc3BsaXQoJyZmPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICAvL2xvZygnc2ZpZC0nICsgZmlkKTtcXG4gICAgICAgIGxldCBmID0gZmV0Y2goJ2hpa2VyOi8vZmlsZXMvX2NhY2hlLycgKyBmaWQgKyAnLm0zdTgnKS5zcGxpdChcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgaWYgKGl0ICYmIGl0LnN0YXJ0c1dpdGgoJy9wcm94eT91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGZ1cmwgPSBiYXNlNjREZWNvZGUoaXQucmVwbGFjZSgnL3Byb3h5P3VybD0nLCAnJykpO1xcbiAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgZXhwaXJlcyA9IHVybC5zcGxpdCgneC1vc3MtZXhwaXJlcz0nKVsxXS5zcGxpdCgnJicpWzBdO1xcbiAgICAgICAgY29uc3QgbGFzdHRpbWUgPSBwYXJzZUludChleHBpcmVzKSAtIERhdGUubm93KCkgLyAxMDAwO1xcbiAgICAgICAgaWYgKGxhc3R0aW1lIDwgNjApIHtcXG4gICAgICAgICAgICAvL2xvZygn6L+H5pyf5pu05pawJylcXG4gICAgICAgICAgICBsZXQgbGluZSA9IHVybC5zcGxpdCgnL21lZGlhJylbMF07IC8v5Y+W5LmL5YmN5pKt5pS+55qEdHPmrrXnur/ot69cXG4gICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcobGluZS5sYXN0SW5kZXhPZignLycpICsgMSk7XFxuICAgICAgICAgICAgbGV0IGYgPSBnZXRNM3U4Q29udGVudChnZXRBbGlQbGF5VXJsKGZpZCwgbGluZSkpLnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZnVybCA9IGJhc2U2NERlY29kZShpdC5yZXBsYWNlKCcvcHJveHk/dXJsPScsICcnKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGZ1cmw7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHVybDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHVybCA9IGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKTtcXG4gICAgICAgIGlmICh1cmwuaW5jbHVkZXMoXFxcI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PRylcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IG1vdW50c3ViID0gc3RvcmFnZTAuZ2V0TXlWYXIoJ21vdW50emltdScsIHt9KTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhtb3VudHN1YikubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHppbXUgPSBtb3VudHN1YjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBzdWJ0aXRsZTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyh6aW11IHx8IHt9KS5sZW5ndGggPiAwICYmIHBsYXlMaXN0ICYmIHBsYXlMaXN0LnVybHMgJiYgcGxheUxpc3QudXJscy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgxMDApO1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHZhciB6bXVybCA9IGFsaUFjY2Vzc0FwaS5nZXRGaWxlVG9Eb3duVXJsKHppbXUuZmlsZV9pZCk7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gJ2hpa2VyOi8vZmlsZXMvY2FjaGUv5LqR55uY5ZCbL3N1Yi4nICsgemltdS5leHQ7XFxuICAgICAgICAgICAgICAgIGRvd25sb2FkRmlsZSh6bXVybCwgcGF0aCwge1xcbiAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLydcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHN1YnRpdGxlID0gZ2V0UGF0aChwYXRoKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLlrZfluZXliqDovb3lpLHotKVcXFwiKTtcXG4gICAgICAgICAgICAgICAgbG9nKGUubWVzc2FnZSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IG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pO1xcbiAgICBpZiAoTVlfUEFHRSA9PT0gMSkge1xcbiAgICAgICAgaWYgKCFnZXRNeVZhcihcXFwibW91bnR6aW11XFxcIiwgXFxcIlxcXCIpKSB7XFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcIm1vdW50emltdVxcXCIsIHt9KTtcXG4gICAgICAgICAgICBhZGRMaXN0ZW5lcihcXFwib25DbG9zZVxcXCIsICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJtb3VudHppbXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwiYWxpU2hhcmVUb2tlblxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhclZhcihcXFwiZG1fc2hhcmVcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwiZG1saXN0XFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImxpc3RTZWFyY2hLZXlcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwiZG1fbGlzdFVybExpc3RcXFwiKTtcXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICB9XFxuICAgICAgICBzZXRNYXJrZXIoKTtcXG4gICAgICAgIGlmIChyZWFsdXJsICYmICFpc1NlYXJjaCkge1xcbiAgICAgICAgICAgIGxldCBzaGFyZUluZm8gPSBhbGlTaGFyZUFwaS5nZXRTaGFyZUluZm8oKTtcXG4gICAgICAgICAgICBsZXQgZmlsZUluZm8gPSBzaGFyZUluZm8uZmlsZV9pbmZvcyB8fCBbXTtcXG4gICAgICAgICAgICBpZiAoZmlsZUluZm8ubGVuZ3RoID09PSAxICYmIGZpbGVJbmZvWzBdLnR5cGUgPT09IFxcXCJmb2xkZXJcXFwiICYmICFmaWxlSWQpIHtcXG4gICAgICAgICAgICAgICAgZmlsZUlkID0gZmlsZUluZm9bMF0uZmlsZV9pZDtcXG4gICAgICAgICAgICAgICAgc2V0UGFnZVRpdGxlKGZpbGVJbmZvWzBdLmZpbGVfbmFtZSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2V0UGFnZVRpdGxlKHNoYXJlSW5mby5zaGFyZV9uYW1lKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGRlYWRsaW5lID0gXFxcIuawuOS5heacieaViFxcXCI7XFxuXFxuICAgICAgICAgICAgaWYgKHNoYXJlSW5mby5leHBpcmF0aW9uKSB7XFxuICAgICAgICAgICAgICAgIGRlYWRsaW5lID0gXFxcIuacieaViOiHs++8mlxcXCIgKyBmb3JtYXREYXRlKHNoYXJlSW5mby5leHBpcmF0aW9uKTtcXG4gICAgICAgICAgICAgICAgLy9zaGFyZUluZm8udXBkYXRlZF9hdFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IChzaGFyZUluZm8uY3JlYXRvcl9uYW1lIHx8IHNoYXJlSW5mby5jcmVhdG9yX3Bob25lKSArIFxcXCImbmJzcDsmbmJzcDtcXFwiICsgZGVhZGxpbmUuc21hbGwoKSxcXG4gICAgICAgICAgICAgICAgdXJsOiByZWFsdXJsICsgXFxcIiNub0hpc3RvcnkjXFxcIixcXG4gICAgICAgICAgICAgICAgaW1nOiBzaGFyZUluZm8uYXZhdGFyIHx8IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3Vua25vd25cXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC50cmltKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5YWz6ZSu6K+NXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1biNub0hpc3RvcnkjI2Z1bGxUaGVtZSM/cGFnZT1meXBhZ2Umc2VhcmNoS2V5PVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBvbkNoYW5nZTogXFxcInB1dE15VmFyKCdsaXN0U2VhcmNoS2V5JyxpbnB1dClcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgc2VhcmNoS2V5ICsgXFxcIuKAneKAneeahOaQnOe0oue7k+aenFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmdW5jSXRlbXMgPSBbXTtcXG4gICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc3R5bGUsXFxuICAgICAgICAgICAgdXJsOiAkKHN0eWxlcywgMSwgXFxcIuaOkuW4g+agt+W8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImFsaXl1bl9zdHlsZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNolxcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ljb24uc3ZnXFxcIlxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBvcmRlck5hbWUsXFxuICAgICAgICAgICAgdXJsOiAkKG9yZGVyc0tleXMsIDIsIFxcXCLmjpLluo/mlrnlvI9cXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fb3JkZXJcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liIfmjaLmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9zb3J0LnN2Z1xcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogcGxheU1v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BhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNouS4ulxcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICAgICAgfSwgb3BlbkFQSUxpc3QpLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfYXBpLnN2Z1xcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoIWlzU2VhcmNoKSB7XFxuICAgICAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWKn+iDvVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChbXFxcIui9rOWtmOS6keebmFxcXCIsIFxcXCLnmbvpmYbotKblj7dcXFwiLCBcXFwi5aSN5Yi25YiG5Lqr6ZO+5o6lXFxcIiwgXFxcIuafpeeci+aJi+WKqOaMgui9veWtl+W5lVxcXCIsIFxcXCLojrflj5blvLnluZXmkJzntKLop4TliJlcXFwiLCBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIiwgXFxcIuaOqOmAgeWIsFRWQm94XFxcIiwgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCIsIFxcXCLojrflj5bmipXlsY9JUFxcXCIsIFxcXCLmnoHpgJ/ljp/nlLvkuIvovb3nur/nqItcXFwiXSwgMiwgXFxcIuabtOWkmuWKn+iDvVxcXCIpLnNlbGVjdCgoc2hhcmVJZCwgc2hhcmVQd2QsIGZpbGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnB1dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIui9rOWtmOS6keebmFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgc21hcnRkcml2ZTovL3NoYXJlL2Jyb3dzZT9zaGFyZUlkPSR7c2hhcmVJZH0mc2hhcmVQd2Q9JHtzaGFyZVB3ZHx8XFxcIlxcXCJ9YDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLnmbvpmYbotKblj7dcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9sb2dpbiNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuWkjeWItuWIhuS6q+mTvuaOpVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi5aSN5Yi26ZO+5o6lXFxcIiwgXFxcIuWkjeWItua1t+mYlOWPo+S7pFxcXCJdLCAxLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KCh1cmwpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIuWkjeWItumTvuaOpVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgdXJsO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly/pmL/ph4zkupHnm5jliIbkuqvlj6Pku6TjgIxcXFwiICsgZ2V0UGFnZVRpdGxlKCkgKyBcXFwi44CNXFxcXG5cXFwiICsgdXJsICsgXFxcIiBAaW1wb3J0PWpzOmBoaWtlcjovL3BhZ2UvYWxpeXVuP3JlYWx1cmw9JHtpbnB1dC50cmltKCl9JnJ1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiYDtcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXFxcIiArIHNoYXJlSWQgKyAoZmlsZUlkID8gXFxcIi9mb2xkZXIvXFxcIiArIGZpbGVJZCA6IFxcXCJcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZG1Nb3VudCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuafpeeci+aJi+WKqOaMgui9veWtl+W5lVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB6bSA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0aXAgPSB6bS5uYW1lID8gXFxcIuW9k+WJjeWtl+W5leaWh+S7tlxcXFxuXFxcIiArIHptLm5hbWUgKyBcXFwiLlxcXCIgKyB6bS5leHQgOiBcXFwi6L+Y5pyq5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogJ+aJi+WKqOaMgui9veWtl+W5lScsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB0aXAgKyBcXFwiXFxcXG4o54K55Ye75Y+W5raI5Y+v5Lul5riF6Zmk5oyC6L295a2X5bmVKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJtb3VudHppbXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5riF6Zmk5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5blvLnluZXmkJzntKLop4TliJlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJqc1xcXCI6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbG9hZERtP3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiJnRpdGxlPVxcXCIpICsgXFxcIitlbmNvZGVVUklDb21wb25lbnQocGxheWRhdGEudGl0bGUuc3BsaXQoJy0nKVswXSk7XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogTVlfUlVMRS50aXRsZSArIFxcXCLlvLnluZXmkJzntKJcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoXFxcIu+/pXByb2plY3Rpb25fc2NyZWVu77+lXFxcIiArIEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmjqjpgIHliLBUVkJveFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3R2Ym94UHVzaCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIiwgXFxcIuaQnOe0ouWwgemdolxcXCJdLCAxKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K+36L6T5YWl5Zu+54mH5Zyw5Z2AXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWcsOWdgFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFBhZ2VQaWNVcmwoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZnJvbnRDb3ZlciNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5bmipXlsY9JUFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpcCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpLmdldElQdjRBZGRyZXNzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpcC5zdGFydHNXaXRoKFxcXCIxOTIuMTY4LlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuivpUlQ6YCC55So5LqO5rWB6YePK+eDreeCueeahOaKleWxj1xcXFxu6K+35pu/5o2i6ZO+5o6l5Lit55qEMC4wLjAuMFxcXCIpLmNvbmZpcm0oKGlwKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGlwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXApO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuiOt+WPluWksei0pemdnueos+WumklQLOivt+W8gOWQr+eDreeCueWGjeS9v+eUqFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5p6B6YCf5Y6f55S75LiL6L2957q/56iLXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoZ2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBcXFwiMjBcXFwiKSwgXFxcIuivt+i+k+WFpTMtMzLkuYvpl7TnmoTmlbTmlbBcXFwiKS5pbnB1dCgoKT0+e1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNwZWVkVGhyZWFkPXBhcnNlSW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKHNwZWVkVGhyZWFkPDN8fHNwZWVkVGhyZWFkPjMyKXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNwZWVkVGhyZWFkXFxcIixTdHJpbmcoc3BlZWRUaHJlYWQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgc2hhcmVJZCwgc2hhcmVQd2QsIGZpbGVJZCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9maWxlaW50by5zdmdcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZUlkOiBwYWdlSWQsXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBzaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgZm9sZGVyTmFtZTogZ2V0UGFnZVRp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fk4JcXFwiXFxuICAgIH07XFxuXFxuICAgIGZ1bmN0aW9uIGdldEhlYWQodHlwZSwgZXh0KSB7XFxuICAgICAgICBsZXQgaGVhZCA9IHRpdGxlSGVhZFt0eXBlXTtcXG4gICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGV4dCkpIHtcXG4gICAgICAgICAgICBoZWFkID0gXFxcIvCflbhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGhlYWQgfHwgXFxcIuKdk1xcXCI7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZ2V0UHJldmlld1BpYyhmaWxlSXRlbSkge1xcbiAgICAgICAgaWYgKGZpbGVJdGVtLnRodW1ibmFpbCkge1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJodHRwczovL2VtcHR5P1xcXCIgKyBmaWxlSXRlbS5maWxlX2lkKS5pbWFnZSgocGljKSA9PiB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2gocGljLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRTdHJlYW06IHRydWVcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGZpbGVJdGVtLnRodW1ibmFpbCk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgbGV0IGZvbGRlclN0eWxlLCBmaWxlU3R5bGU7XFxuICAgIGxldCBmaWx0ZXJUeXBlID0gW107XFxuICAgIGlmIChzdHlsZSA9PT0gXFxcIui/veWJp1xcXCIpIHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwibW92aWVfMlxcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcInZpZGVvXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwi6L+95Ymn5qih5byP5Y+q5pi+56S65paH5Lu25aS55ZKM6KeG6aKRXFxcIi5zbWFsbCgpLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSBpZiAoc3R5bGUgPT09IFxcXCLnnIvlm75cXFwiKSB7XFxuICAgICAgICBmb2xkZXJTdHlsZSA9IFxcXCJhdmF0YXJcXFwiO1xcbiAgICAgICAgZmlsZVN0eWxlID0gXFxcImNhcmRfcGljXzNcXFwiO1xcbiAgICAgICAgZmlsdGVyVHlwZS5wdXNoKFxcXCJpbWFnZVxcXCIpO1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIueci+WbvuaooeW8j+WPquaYvuekuuaWh+S7tuWkueWSjOWbvueJh1xcXCIuc21hbGwoKS5mb250Y29sb3IoXFxcImdyZXlcXFwiKSxcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgIH1cXG4gICAg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U1TLnNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChmaWx0ZXJUeXBlLmxlbmd0aCA+IDAgJiYgIWZpbHRlclR5cGUuaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdWJ0aXRsZSwgbG9uZ2MsIGNscztcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBmaWxlSXRlbS5uYW1lO1xcbiAgICAgICAgICAgIGxldCBuYW1lTm90RXh0ID0gZmlsZUl0ZW0ubmFtZS5yZXBsYWNlKCcuJyArIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCAnJyk7XFxuICAgICAgICAgICAgaWYgKHN1YkV4dHMuaW5jbHVkZXMoZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pKSB7XFxuICAgICAgICAgICAgICAgIGxvbmdjID0gW3tcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5oyC6L295a2X5bmVXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh6bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdtb3VudHppbXUnLCB6bSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+aMgui9veWujOaIkO+8jOW9k+WJjeWtl+W5leaWh+S7tjogJyArIHptLm5hbWUgKyAnLicgKyB6bS5leHQ7XFxuICAgICAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0OiBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2lkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IG5hbWVOb3RFeHRcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGNhdGUgPT09IFxcXCJ2aWRlb1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHppbXVsaXN0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgc3VidGl0bGUgPSB6aW11bGlzdC5maW5kKHYgPT4gdi5uYW1lLmluY2x1ZGVzKG5hbWVOb3RFeHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjbHMgPSBcXFwicGxheWxpc3QgdlxcXCIgKyBwYWdlSWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChmaWxlU3R5bGUgPT09IFxcXCJ0ZXh0XzFcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGRlc2MgKz0gXFxcIlxcXFx0XFxcXHRcXFwiICsgZm9ybWF0U2l6ZShmaWxlSXRlbS5zaXplKTtcXG4gICAgICAgICAgICAgICAgdGl0bGUgPSBnZXRIZWFkKGNhdGUsIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uKSArIHRpdGxlO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoW1xcXCJ2aWRlb1xcXCIsIFxcXCJpbWFnZVxcXCJdLmluY2x1ZGVzKGNhdGUpKSB7XFxuICAgICAgICAgICAgICAgIHBpY191cmwgPSBnZXRQcmV2aWV3UGljKGZpbGVJdGVtKSB8fCBwaWNfdXJsO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub1ByZSNcXFwiKS5sYXp5UnVsZSgoc2hhcmVJZCwgc2hhcmVQd2QsIHNoYXJlVG9rZW4sIGZpbGVJZCwgY2F0ZSwgc3VidGl0bGUpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS9hbGlsYXp5XFxcIikoc2hhcmVJZCwgc2hhcmVQd2QsIHNoYXJlVG9rZW4sIGZpbGVJZCwgY2F0ZSwgc3VidGl0bGUpO1xcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUlkLCBzaGFyZVB3ZCwgTVlfUEFSQU1TLnNoYXJlVG9rZW4sIGZpbGVJdGVtLmZpbGVfaWQsIGNhdGUsIHN1YnRpdGxlKSxcXG4gICAgICAgICAgICAgICAgZGVzYzogZGVzYyxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogcGljX3VybCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBsb25nYyxcXG4gICAgICAgICAgICAgICAgICAgIGNsczogY2xzLFxcbiAgICAgICAgICAgICAgICAgICAgLy9pbmhlcml0VGl0bGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBmaWxlU3R5bGVcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBpZiAoY29udHMubGVuZ3RoID09PSA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hbGlkUmVzb3VyY2UuU2hhcmVQd2RcXFwiKSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K+36L6T5YWl5o+Q5Y+W56CBXFxcIixcXG4gICAgICAgICAgICAgICAgZGVzYzogc2hhcmVQd2QgPyBcXFwi4oCc4oCc5o+Q5Y+W56CB6ZSZ6K+v4oCd4oCdXFxcIiA6IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoKS5pbnB1dCgoTVlfUEFSQU1TKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRQYWdlUGFyYW1zKE9iamVjdC5hc3NpZ24oe30sIE1ZX1BBUkFNUywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBpbnB1dFxcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSwgTVlfUEFSQU1TKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIlxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpZiAoZS5zaWduaWZpY2FuY2UgPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBlLm1lc3NhZ2UuYmlnKCkuYmlnKCkuZm9udGNvbG9yKFxcXCJyZWRcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0X2NlbnRlcl8xJyxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChlLnNpZ25pZmljYW5jZSA9PT0gMykge1xcbiAgICAgICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIGUubWVzc2FnZS5iaWcoKS5mb250Y29sb3IoXFxcImdyZWVuXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMSdcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcblxcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgbG9nKFxcXCLliJfooajliqDovb3lpLHotKUjXFxcXG7plJnor6/kv6Hmga8+XFxcIiArIGUudG9TdHJpbmcoKSArIFxcXCJcXFxcbumUmeivr+ihjD5cXFwiICsgZS5saW5lTnVtYmVyKTtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiAn5qyn5qyn77yM5oql6ZSZ5LqG44CC5Zyo5Yi35paw5Yeg5qyh77yf5oiW6ICF5pu05o2i5paH5Lu25aS544CCJyxcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBkZXNjOiBlLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0X2NlbnRlcl8xJ1xcbiAgICAgICAgfSk7XFxuICAgICAgICAvL3Rocm93IGU7XFxuICAgIH1cXG59XFxuc2F2ZU15UGFDYWNoZSgpO1xcbnNldFJlc3VsdChpdGVtcyk7XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLnmbvlvZXotKblj7dcIixcInBhdGhcIjpcImxvZ2luXCIsXCJydWxlXCI6XCJqczpcXG52YXIgZCA9IFt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1hbGl5dW5fZHJpdmUmZnJvbVNpdGU9NTImX2J4LXY9Mi4yLjNcXFwiLCB7XFxuICAgICAgICAgICAgICAgIGJvZHk6IGJvZHlcXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgbGV0IHFyQ29kZVN0YXR1cyA9IHJlc3VsdC5jb250ZW50LmRhdGEucXJDb2RlU3RhdHVzO1xcblxcbiAgICAgICAgICAgIGlmIChxckNvZGVTdGF0dXMgPT09IFxcXCJDT05GSVJNRURcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGlmIChyZXN1bHQuY29udGVudC5kYXRhLmJpekV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGluZm8gPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShyZXN1bHQuY29udGVudC5kYXRhLmJpekV4dCkpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaVRva2Vuc0ZpbGVwYXRoID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL3BhZ2UvdG9rZW5QYXRoXFxcIikuYWxpVG9rZW5zRmlsZXBhdGg7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgYWxpVG9rZW4gPSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogaW5mby5wZHNfbG9naW5fcmVzdWx0LnJlZnJlc2hUb2tlblxcbiAgICAgICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShhbGlUb2tlbnNGaWxlcGF0aCwgSlNPTi5zdHJpbmdpZnkoYWxpVG9rZW4pKTtcXG4gICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwibG9naW55XFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi55m75b2V5oiQ5YqfKOeCueWHu+i/lOWbnilcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2tIb21lKFxcXCLnmbvlvZXmiJDlip9cXFwiLCB0cnVlKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2tIb21lKFxcXCLnmbvlvZXlpLHotKUs6K+35bCd6K+V5YW25LuW55qE5pa55rOVXFxcIik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocXJDb2RlU3RhdHVzID09PSBcXFwiQ0FOQ0VMRURcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGJhY2tIb21lKFxcXCLlj5bmtojnmbvlvZXmjojmnYNcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoW1xcXCJORVdcXFwiLCBcXFwiU0NBTkVEXFxcIl0uaW5jbHVkZXMocXJDb2RlU3RhdHVzKSkge1xcbiAgICAgICAgICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDI1MDApO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGJhY2tIb21lKFxcXCLotoXml7ZcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAg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ZGVmaW5lUHJvcGVydHkodGhpcywgXFxcIm9wZW5Ub29sc1xcXCIsIHtcXG4gICAgICAgIGdldCgpe1xcbiAgICAgICAgICAgIGlmICh0aGlzLl9vcGVuVG9vbHMpIHJldHVybiBfb3BlblRvb2xzO1xcbiAgICAgICAgICAgIGxldCBPcGVuQXBpVG9vbHM7XFxuICAgICAgICAgICAgc3dpdGNoIChnZXRJdGVtKFxcXCJvcGVuQXBpTW9kZVxcXCIsIFxcXCIwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiMVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfYWxpeXVuZHJpdmVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCIyXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV90dmJveFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjNcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX1hCWVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjBcXFwiOlxcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX2FsaXN0XFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMuX29wZW5Ub29scyA9IG5ldyBPcGVuQXBpVG9vbHModGhpcyk7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX29wZW5Ub29sczt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ICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZkRyaXZlSWQgPSB0aGlzLmFsaVRva2Vucy5kZWZhdWx0X2RyaXZlX2lkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhcXFwi55So5oi35L+h5oGv6I635Y+W5aSx6LSl77yaXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICB0aGlzLnJlZnJlc2hBY2Nlc3NDYWxsQmFjayhyZXN1bHQsIHRoaXMpO1xcbiAgICAgICAgcmV0dXJuIHRoaXMuYWxpVG9rZW5zO1xcbiAgICB9LFxcbiAgICBnZXRVc2VySW5mbygpIHtcXG4gICAgICAgIGxldCBpbmZvID0gdGhpcy5wb3N0QXBpKFxcXCJodHRwczovL3VzZXIuYWxpeXVuZHJpdmUuY29tL3YyL3VzZXIvZ2V0XFxcIikuaGVhZGVycyh7XFxuICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICBcXFwiYXV0aG9yaXphdGlvblxcXCI6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgfSkuZXJyb3JXaXRoUmV0cnkoKGUsIF8sIGh0dHApID0+IHtcXG4gICAgICAgICAgICB0aGlzLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtc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mIChvcGVuUmVzdWx0LnJlZnJlc2hfdG9rZW4pIHtcXG4gICAgICAgICAgICAgICAgdGhpcy5jYWNoZU9wZW5Ub2tlbihvcGVuUmVzdWx0KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMub3BlblRva2VucztcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIui/lOWbnue7k+aenOaXoFRva2VuXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwiT3BlblRva2Vu6I635Y+W5aSx6LSlOlxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICBfY2xvdWRGaWxlT3BlcmF0ZShib2R5LCBjbG91ZEZpbGVJZCwgb3BlcmF0ZVVybCkge1xcbiAgICAgICAgbGV0IHJlc3VsdCA9IHRoaXMucG9zdEFwaSgnaHR0cHM6Ly9hcGkuYWxpeXVuZHJpdmUuY29tL2Fkcml2ZS92Mi9iYXRjaCcpLmJvZHkoe1xcbiAgICAgICAgICAgIFxcXCJyZXF1ZXN0c1xcXCI6IFt7XFxuICAgICAgICAgICAgICAgIFxcXCJib2R5XFxcIjogYm9keSxcXG4gICAgICAgICAgICAgICAgXFxcImhlYWRlcnNcXFwiOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29udGVudC1UeXBlXFxcIjogXFxcImFwcGxpY2F0aW9uL2pzb25cXFwiXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIFxcXCJpZFxcXCI6IGNsb3VkRmlsZUlkIHx8IFxcXCIwXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIm1ldGhvZFxcXCI6IFxcXCJQT1NUXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInVybFxcXCI6IG9wZXJhdGVVcmxcXG4gICAgICAgICAgICB9XSxcXG4gICAgICAgICAgICBcXFwicmVzb3VyY2VcXFwiOiBcXFwiZmlsZVxcXCJcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLycsXFxuICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgLy9nZXRBY2Nlc3NUb2tlblxcbiAgICAgICAgICAgICd4LWNhbmFyeSc6ICdjbGllbnQ9d2ViLGFwcD1zaGFyZSx2ZXJzaW9uPXYyLjMuMScsXFxuICAgICAgICAgICAgJ3gtc2hhcmUtdG9rZW4nOiB0aGlzLnNoYXJlVG9rZW5cXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGUuY29kZSA9PT0gXFxcIlF1b3RhRXhoYXVzdGVkLkRyaXZlXFxcIikge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBlO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAoIXRoaXMudHJ5U29sdmUoZSkpIHtcXG4gICAgICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgYm9keSA9IGh0dHAub3B0aW9ucy5ib2R5LnJlcXVlc3RzWzBdLmJvZHk7XFxuICAgICAgICAgICAgaWYgKGJvZHkuZHJpdmVfaWQpIHtcXG4gICAgICAgICAgICAgICAgYm9keS5kcml2ZV9pZCA9IHRoaXMuZGVmRHJpdmVJZFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoYm9keS50b19kcml2ZV9pZCkge1xcbiAgICAgICAgICAgICA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JyxcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMub3BlblRva2Vucy5BY2Nlc3NUb2tlbk9wZW5cXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KDIsIChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgLy90aGlzLndhaXRTbGVlcCgzMCkudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMzApLnRyeU9wZW5BcGlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmRlZkRyaXZlSWQsXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5vcGVuVG9rZW5zLkFjY2Vzc1Rva2VuT3BlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGlmICghZmlsZUluZm8udXJsIHx8IGZpbGVJbmZvLmNvZGUpIHRocm93IG5ldyBFcnJvcihcXFwi5LiL6L296ZO+5o6l6I635Y+W5aSx6LSlXFxcXG5cXFwiICsgZmlsZUluZm8uY29kZSArIFxcXCI6XFxcIiArIGZpbGVJbmZvLm1lc3NhZ2UpO1xcbiAgICAgICAgcmV0dXJuIGZpbGVJbmZvLnVybDtcXG4gICAgfSxcXG4gICAgZGVsZXRlZUNsb3VkRmlsZShjbG91ZEZpbGVJZCkge1xcbiAgICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2Nsb3VkRmlsZU9wZXJhdGUoe1xcbiAgICAgICAgICAgIFxcXCJkcml2ZV9pZFxcXCI6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2l0aFJldHJ5KDMsIChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGUubWVzc2FnZSA9PT0gXFxcIngtZGV2aWNlLWlkIGVtcHR5XFxcIikge1xcbiAgICAgICAgICAgICAgICB0aGlzLndhaXRTbGVlcCgyMCkucmVmcmVzaEFjY2Vzc1Rva2VuKCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoNTApO1xcbiAgICAgICAgICAgIG5ld1NpZ24gPSBjYWxjdWxhdGVOZXdTaWduKCk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInB1YktleVxcXCI6IG5ld1NpZ24ucHViS2V5XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICAgICAgJ1gtU2hhcmUtVG9rZW4nOiB0aGlzLnNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICAneC1kZXZpY2UtaWQnOiB0aGlzLmFsaVRva2Vucy5kZXZpY2VfaWQsXFxuICAgICAgICAgICAgICAgICAgICAneC1zaWduYXR1cmUnOiBuZXdTaWduLnNpZ25hdHVyZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5lcnJvcigoZXJyLCByZXMpID0+IHtcXG4gICAgICAgICAgICByZXR1cm4ge307XFxuICAgICAgICB9KS5zdWNjZXNzKChib2R5KSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuIGJvZHk7XFxuICAgICAgICB9KS5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gICB0cnkge1xcbiAgICAgICAgICAgIGlmIChyZXMuc3RhdHVzQ29kZSA+PSAyMDAgJiYgcmVzLnN0YXR1c0NvZGUgPD0gMzAwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBib2R5ID0gcmVzLmJvZHk7XFxuICAgICAgICAgICAgICAgIGlmICh0b0pzb24pIHtcXG4gICAgICAgICAgICAgICAgICAgIGJvZHkgPSBKU09OLnBhcnNlKGJvZHkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnN1Y2Nlc3NDYWxsYmFjayhib2R5LCByZXMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihTdHJpbmcocmVzLnN0YXR1c0NvZGUpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlcnIpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBlcnIgPSB0aGlzLmVycm9yVHlwZUNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmICh0aGlzLnJldHJ5Q291bnQpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHRyeVJlc3VsdCA9IHRoaXMuZXJyb3JDYWxsYmFja1dpdGhSZXRyeShlcnIsIHJlcywgdGhpcyk7XFxuICAgICAgICAgICAgICAgIGlmICh0cnlSZXN1bHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmV0cnlDb3VudC0tO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3RhcnQodG9Kc29uKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmV0cnlDb3VudCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5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GF0YS5jb21tZW50cykge1xcbiAgICAgICAgLy9kTWNvbnRleHQgKz0gYDxkIHA9XFxcIiR7TWF0aC5yb3VuZCh0aW1lcG9pbnQpfSwke2N0fSwke3NpemV9LCR7Y29sb3J9LDBcXFwiPiR7Y29udGVudH08L2Q+XFxcXG5gO1xcbiAgICAgICAgbGV0IHBhcmFtVGV4dCA9IGNvbW1lbnQucDtcXG4gICAgICAgIGxldCBjb21tZW50VGV4dCA9IGNvbW1lbnQubTtcXG4gICAgICAgIGlmIChwYXJhbVRleHQgPT0gbnVsbCB8fCBjb21tZW50VGV4dCA9PSBudWxsKSBjb250aW51ZTtcXG4gICAgICAgIGxldCBwYXJhbXMgPSBwYXJhbVRleHQuc3BsaXQoXFxcIixcXFwiKTtcXG4gICAgICAgIGxldCBwYXJhbXNUID0gW107XFxuICAgICAgICBmb3IgKGxldCBpIGluIHBhcmFtcykge1xcbiAgICAgICAgICAgIC8qaWYgKGkgPT0gMCkge1xcbiAgICAgICAgICAgICAgICBwYXJhbXNULnB1c2gocGFyc2VJbnQocGFyYW1zW2ldKSk7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgIGlmIChpID09IDIpIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIyNVxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgICAgIC8v6aKc6Imy5YC85Li6MOaXtu+8jOm7mOiupOiuvue9ruS4uueZveiJslxcbiAgICAgICAgICAgICAgICBpZiAocGFyYW1zW2ldID09IFxcXCIwXFxcIiB8fCBwYXJhbXNbaV0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIxNjc3NzIxNVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWVcXG4gICAgICAgICAgICAg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ICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgIH0sIE1ZX1BBUkFNUyksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YaF572u5pCc57SiVFxcXCIsXFxuICAgIHVybDogJChrZXksIFxcXCLmoLzlvI/vvJrmkJzntKLlhbPplK7or41b5Zue6L2mXembhuaVsFxcXCIpLmlucHV0KChvbmx5RG93bmxvYWQpID0+IHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOaQnOe0ouW5tuS4i+i9vS4uLlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBbbmFtZSwgcG9zXSA9IGlucHV0LnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGlmICghbmFtZSB8fCAhcG9zKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IFxcXCLmoLzlvI/plJnor69cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgdXJsSW5mbyA9IGZldGNoKGJ1aWxkVXJsKFxcXCJodHRwczovL2F6dXJlLmxldXNlLnRvcC9zZWFyY2hkbVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwibmFtZVxcXCI6IG5hbWUsXFxuICAgICAgICAgICAgICAgICAgICBcXFwicG9zXFxcIjogcG9zXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgdXJsSW5mbyA9IEpTT04ucGFyc2UodXJsSW5mbyk7XFxuICAgICAgICAgICAgaWYgKCF1cmxJbmZvLnVybCkgdGhyb3cgXFxcIuaaguaXtuayoeacieaJvuWIsOivpeinhumikeeahOW8ueW5lVxcXCI7XFxuICAgICAgICAgICAgbGV0IHhtbCA9IGZldGNoKGJ1aWxkVXJsKFxcXCJodHRwczovL2F6dXJlLmxldXNlLnRvcC9kYW5tdVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zOiB1cmxJbmZvXFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgaWYgKCF4bWwpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgXFxcIui/mOayoeacieW8ueW5leWTn35cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGF0aCA9IFxcXCJoaWtlcjovL2ZpbGVzL2NhY2hlL2Rhbm11L1xcXCIgKyB1cmxJbmZvLnBsYXRmb3JtICsgXFxcIl9cXFwiICsgbmFtZSArIFxcXCJfXFxcIiArIHBvcyArIFxcXCIueG1sXFxcIjtcXG4gICAgICAgICAgICB3cml0ZUZpbGUocGF0aCwgJzw/eG1sIHZlcnNpb249XFxcIjEuMFxcXCIgZW5jb2Rpbmc9XFxcIlVURi04XFxcIj8+XFxcXG4nICsgeG1sKTtcXG4gICAgICAgICAgICBpZiAob25seURvd25sb2FkKSByZXR1cm4gXFxcInRvYXN0Oi8v5LiL6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICByZWZyZXNoVmlkZW9Vcmwoe1xcbiAgICAgICAgICAgICAgICBkYW5tdTogcGF0aFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liqDovb3lrozmiJBcXFwiO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL1xcXCIgKyBlLnRvU3RyaW5nKCk7XFxuICAgICAgICB9XFxuICAgIH0sIG9ubHlEb3dubG9hZCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwiZG3nm5LlrZDmkJzntKJcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGtleSwgb25seURvd25sb2FkKSA9PiB7XFxuICAgICAgICBsZXQgZG0gPSBnZXRWYXIoXFxcImRtX3NoYXJlXFxcIik7XFxuICAgICAgICBpZiAoZG0gJiYgIW9ubHlEb3dubG9hZCkge1xcbiAgICAgICAgICAgIGNsZWFyVmFyKFxcXCJkbV9zaGFyZVxcXCIpO1xcbiAgICAgICAgICAgIHJlZnJlc2hWaWRlb1VybCh7XFxuICAgICAgICAgICAgICAgIGRhbm11OiBkbVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liqDovb3lrozmiJBcXFwiO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICByZXR1cm4gJChrZXksIFxcXCJkbeebkuWtkOaQnOe0olxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuS4i+i9veWujOaIkOW8ueW5leWQjuivt+mHjeaWsOeCueWHu+aQnOe0olxcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vc2VhcmNoP3J1bGU9ZG3nm5LlrZAmcz1cXFwiICsgaW5wdXQ7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH0sIGtleSwgb25seURvd25sb2FkKSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiXFxufSk7XFxuXFxuZnVuY3Rpb24gc2VhcmNoKGQsIG5hbWUpIHtcXG4gICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpb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+k+WFpeinhOWumuiMg+WbtOWGheeahOaVsOWtl1xcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gYSAtIDEsIGogPSAxOyBpIDwgYjsgaSsrLCBqKyspIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZXBpc29kZSA9IGVwaXNvZGVzW2ldO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkbVRpdGxlID0gYW5pbWVUaXRsZSArIFxcXCJfXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjkuIvovb3vvJpcXFwiICsgZXBpc29kZS5lcGlzb2RlVGl0bGUgKyBcXFwiXFxcXHQoXFxcIiArIGogKyBcXFwiL1xcXCIgKyAoYiAtIGEgKyAxKSArIFxcXCIpXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGFubXUuZG93bmxvYWREYW5NdShlcGlzb2RlLmVwaXNvZGVJZCwgZG1UaXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lk6blk6bkuIvovb3lpLHotKUuLi5cXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuIvovb3lrozmiJ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cXCJ0b2FzdDovL+i/mOayoeacieW8ueW5leWTn35cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFZpZGVvVXJsKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkYW5tdTogcGF0aFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liqDovb3lrozmiJBcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBNWV9QQVJBTVMuZHVybCwgZG1UaXRsZSwgb25seURvd25sb2FkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5by65Yi25LiL6L29XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoZXBpc29kZVRpdGxlLCBlcGlzb2RlSWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuivt+etieW+hVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGFubXUuZG93bmxvYWREYW5NdShlcGlzb2RlSWQsIGVwaXNvZGVUaXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/ph43mlrDkuIvovb3lrozmiJDvvIzljZXlh7vmjILovb3jgIJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGRtVGl0bGUsIGVwaXNvZGUuZXBpc29kZUlkKVxcbiAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVfYmxhbmtcXFwiXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBpZiAoIWRtTGlzdC5hbmltZXMubGVuZ3RoKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5rKh5pyJ5om+5Yiw5LiOW1xcXCIgKyBuYW1lICsgXFxcIl3nm7jlhbPnmoTlvLnluZVcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGRlc2M6IFxcXCLmkJzkuI3liLDmgI7kuYjlip7vvJ9cXFxcbuajgOafpeWQjeensOaYr+WQpuato+ehru+8m+WPr+S7peWwneivleWIoOmZpOmDqOWIhumZkOWumuivje+8jOWmguesrOS4gOWto+etie+8m+iAjOS4lOWPquiDveaQnOe0oueVquWJp+WTpu+8geWFtuS7luW8ueW5leWPr+eUqGRt55uS5a2Q44CCXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5sZXQgbmFtZSA9IGdldFBhcmFtKFxcXCJuYW1lXFxcIiwgTVlfUEFSQU1TLm5hbWUpO1xcbmlmIChuYW1lKSB7XFxuICAgIHRyeSB7XFxuICAgICAgICBzZWFyY2goZCwgbmFtZSk7XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJxFUlJPUuKAneKAnVxcXCIsXFxuICAgICAgICAgICAgZGVzYzogZS50b1N0cmluZygpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59XFxuc2V0UmVzdWx0KGQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi5YWs5byA5bel5YW3XCIsXCJwYXRoXCI6XCJhbGlVdGlsXCIsXCJydWxlXCI6XCIvL+aPkOS+m+e7meinhOWImeS9v+eUqOeahOW4uOeUqOWHveaVsFxcbiQuZXhwb3J0cyA9IHtcXG4gICAgY2hlY2thbGkocmVhbHVybCkge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBpZiAocmVhbHVybC5pbmNsdWRlcyhcXFwiY29tL3MvXFxcIikgJiYgcmVhbHVybCAhPSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgc2hhcmVJZCA9IHJlYWx1cmwuc3BsaXQoXFxcIj9cXFwiKVswXS5zcGxpdChcXFwiL1xcXCIpWzRdO1xcbiAgICAgICAgICAgICAgICBsZXQgc2hhcmUgPSBmZXRjaChcXFwiaHR0cHM6Ly9hcGkuYWxpeXVuZHJpdmUuY29tL2Fkcml2ZS92My9zaGFyZV9saW5rL2dldF9zaGFyZV9ieV9hbm9ueW1vdXNcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgJ2NvbnRlbnQtdHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJzaGFyZV9pZFxcXCI6IHNoYXJlSWRcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgaWYgKHNoYXJlLmluY2x1ZGVzKFxcXCJzaGFyZV9saW5rIGlzXFxcIikgfHwgc2hhcmUuaW5jbHVkZXMoXFxcInNoYXJlX2xpbmsgY2Fubm90XFxcIikpIHJldHVybiBmYWxzZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgIH0sXFxuICAgIGJ5dGVzVG9TaXplKHNpemUpIHtcXG4gICAgICAgIGlmICghc2l6ZSkge1xcbiAgICAgICAgICAgIHJldHVybiAnMCc7XFxuICAgICAgICB9XFxuICAgICAgICBjb25zdCB1bml0cyA9IFsnQicsICdLQicsICdNQicsICdHQicsICdUQicsICdQQicsICdFQicsICdaQicsICdZQiddO1xcbiAgICAgICAgbGV0IGkgPSAwO1xcbiAgICAgICAgd2hpbGUgKHNpemUgPj0gMTAyNCkge1xcbiAgICAgICAgICAgIHNpemUgLz0gMTAyNDtcXG4gICAgICAgICAgICBpKys7XFxuICAgICAgICB9XFxuICAgICAgICBzaXplID0gaSA/IE51bWJlcihzaXplLnRvRml4ZWQoMikpIDogc2l6ZTtcXG4gICAgICAgIHJldHVybiBgJHtzaXplfSAke3VuaXRzW2ldfWA7XFxuICAgIH0sXFxuICAgIGdldENyeXB0b0pTKCkge1xcbiAgICAgICAgaWYgKHR5cGVvZiBDcnlwdG9KUyA9PT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICBldmFsKGdldENyeXB0b0pTKCkpO1xcbiAgICAgICAgICAgIHJldHVybiBDcnlwdG9KUztcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBDcnlwdG9KUztcXG4gICAgfSxcXG4gICAgbWF0Y2hBbGlVcmwodGV4dCwgaXNHKSB7XFxuICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJhbGl0ZXN0XFxcIikubWF0Y2hBbGlVcmwodGV4dCwgaXNHKTtcXG4gICAgfSxcXG4gICAgZ2V0SVB2NEFkZHJlc3MoKSB7XFxuICAgICAgICBjb25zdCBOZXR3b3JrSW50ZXJmYWNlID0gamF2YS5uZXQuTmV0d29ya0ludGVyZmFjZTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgZW4gPSBOZXR3b3JrSW50ZXJmYWNlLmdldE5ldHdvcmtJbnRlcmZhY2VzKCk7IGVuLmhhc01vcmVFbGVtZW50cygpOykge1xcbiAgICAgICAgICAgICAgICBsZXQgaW50ZiA9IGVuLm5leHRFbGVtZW50KCk7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGVudW1JcEFkZHIgPSBpbnRmLmdldEluZXRBZGRyZXNzZXMoKTsgZW51bUlwQWRkci5oYXNNb3JlRWxlbWVudHMoKTspIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbmV0QWRkcmVzcyA9IGVudW1JcEFkZHIubmV4dEVsZW1lbnQoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghaW5ldEFkZHJlc3MuaXNMb29wYmFja0FkZHJlc3MoKSAmJiBpbmV0QWRkcmVzcyBpbnN0YW5jZW9mIGphdmEubmV0LkluZXQ0QWRkcmVzcykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoaW5ldEFkZHJlc3MuZ2V0SG9zdEFkZHJlc3MoKSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChleCkge1xcbiAgICAgICAgICAgIGxvZyhleC50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgIC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9lbXB0eVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBjb250ZW50LnRyaW0oKS5yZXBsYWNlKC9cXFxcblxcXFxzKj8vZywgXFxcIjxicj5cXFwiKSxcXG4gICAgICAgIFxcXCJjb2xfdHlwZVxcXCI6IFxcXCJyaWNoX3RleHRcXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgfSwge1xcbiAgICAgICAgdGl0bGU6IHRpbWUgKyBcXFwi56eS5ZCO57un57utXFxcIixcXG4gICAgICAgIHVybDogXFxcInRvYXN0Oi8v6K+36K6k55yf6ZiF6K+75Lul5LiK5YaF5a65XFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBpZCArIFxcXCJ0aW1lclxcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGlmICh1cGRhdGVJbmZvKSB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaWsOWGheWuuVxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogdXBkYXRlSW5mbyxcXG4gICAgICAgICAgICBjb25maXJtKCl7fSxcXG4gICAgICAgICAgICBjYW5jZWwoKXt9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIHdoaWxlICh0aW1lICE9IDApIHtcXG4gICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwMCk7XFxuICAgICAgICB0aW1lIC09IDE7XFxuICAgICAgICB1cGRhdGVJdGVtKGlkICsgXFxcInRpbWVyXFxcIiwge1xcbiAgICAgICAgICA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ICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGFsbC51cmwgPSBcXFwidG9hc3Q6Ly/msqHmnInop4bpopHml6Dms5XmjqjpgIFcXFwiO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgbGlzdC5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgIHYuY29sX3R5cGUgPSB2LnR5cGU7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSB2LmV4dHJhLnBhZ2VUaXRsZTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gbmFtZS5yZXBsYWNlKC9cXFxcIy9nLCAnXycpLnJlcGxhY2UoL1xcXFwkL2csICdfJykgKyBcXFwiJHZpZGVvfFxcXCIgKyB2LmV4dHJhLmlkO1xcbiAgICAgICAgICAgIGFsbFVybHMucHVzaCh1cmwpO1xcbiAgICAgICAgICAgIHYudXJsID0gZ2V0UHVzaChuYW1lLCB1cmwpO1xcbiAgICAgICAgICAgIHYuZXh0cmEuY2xzID0gdi5leHRyYS5pZCA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICBkLnB1c2godik7XFxuICAgICAgICB9KTtcXG4gICAgICAgIGFsbC51cmwgPSBnZXRQdXNoKGZvbGRlck5hbWUsIGFsbFVybHMuam9pbihcXFwiI1xcXCIpKTtcXG4gICAgfVxcbiAgICBzZXRSZXN1bHQoZCk7XFxufSkoKTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuWwgemdouaQnOe0olwiLFwicGF0aFwiOlwiZnJvbnRDb3ZlclwiLFwicnVsZVwiOlwianM6XFxubGV0IGQgPSBbXTt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FxcIiArIGdldFBhc3MocnVsZXMubGVuZ3RoLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBcXFwiaGlrZXI6Ly9maWxlcy9ydWxlcy9Mb3lEZ0lrL3NoYXJlL+S6keeugOaQnOe0ouW8leaTjuinhOWImeOAjFxcXCIgKyBydWxlcy5sZW5ndGggKyBcXFwi44CN5p2hLlxcXCIgKyAoaW5wdXQgPT09IFxcXCJISUtFUlxcXCIgPyBcXFwiaGlrZXJcXFwiIDogXFxcInR4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGdldFBhc3MocnVsZXMubGVuZ3RoLCBydWxlYjY0LCBcXFwiYVxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtNCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBleHQ7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0R3JvdXBKc29uKGV4dCk7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZXMubGVuZ3RoKSByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5a2Y5Zyo6K+l57uEXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYudXNlciA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmRleGNbMV0pO1xcblxcbiAgICB9LCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hbGxfNFxcXCIsXFxuICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3NoYXJlX2dyZWVuXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi6YeN572uXFxcIixcXG4gICAgdXJsOiAkKFxcXCLkvaDnoa7lrprph43nva7vvJ9cXFxcbuivpeaTjeS9nOS8muWIoOmZpOeOsOacieinhOWIme+8jOaBouWkjeiHquW4puinhOWImeOAglxcXCIpLmNvbmZpcm0oKHBhdGgpID0+IHtcXG4gICAgICAgIGRlbGV0ZUZpbGUocGF0aCk7XFxuICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XF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1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi572u6aG2XFxcIiwgXFxcIue9ruW6lVxcXCIsIFxcXCLmlLnlkI1cXFwiLCBcXFwi5Yig6ZmkXFxcIl0pLnNlbGVjdCgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChcXFwi5pS55ZCNXFxcIiA9PT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpdCwgXFxcIuivt+i+k+WFpeaWsOWQjeensFxcXCIpLmlucHV0KChpdCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVzLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXQgPT09IHYuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2Lmdyb3VwID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChcXFwi5Yig6ZmkXFxcIiA9PT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi5piv5ZCm5Yig6Zmk6K+l57uE5pCc57Si5byV5pOO77yaXFxcIiArIGl0KS5jb25maXJtKChpdCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMuZmlsdGVyKHYgPT4gdi5ncm91cCAhPT0gaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRnUnVsZXMgPSBbXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB0eFJ1bGVzID0gW107XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5mb3JFYWNoKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ID09PSB2Lmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRnUnVsZXMucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eFJ1bGVzLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGdSdWxlcyA9IHRnUnVsZXMuY29uY2F0KHR4UnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0Z1J1bGVzID0gdHhSdWxlcy5jb25jYXQodGdSdWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbih0Z1J1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgIH0sIGl0LCBncm91cCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxuICAgIH0pO1xcbn1cXG5cXG5sZXQgY291bnQgPSBkLmxlbmd0aDtcXG5cXG5mb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgaWYgKGdyb3VwICYmIGdyb3VwICE9PSBpdC5ncm91cCkgY29udGludWU7XFxuICAgIGxldCB1c2VyID0gaXQudXNlciB8fCB7fTtcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdWycgKyBpICsgJ108Yj4gICcgKyBpdC5uYW1lICsgKGl0Lmdyb3VwID8gXFxcInxcXFwiICsgaXQuZ3JvdXAuc21hbGwoKSA6IFxcXCJcXFwiKSArICc8Yj4nICsgKGl0LmZvcmJpZGRlbiA/IFxcXCIgI+KAnOKAnOemgeeUqOKAne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KChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKClbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS51c2VyID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlKSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChuYW1lLCBydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG55WM77yM44CMXFxcIiArIG5hbWUgKyBcXFwi44CN5LqR566A5pCc57Si5byV5pOO77yM5aSN5Yi25pW05p2h5Y+j5Luk5omT5byA6L2v5Lu25bCx5Lya6Ieq5Yqo5a+85YWlJFxcXCIgKyBydWxlICsgXFxcIiRcXFwiICsgdHlwZSArIFxcXCJAaW1wb3J0PWpzOiQucmVxdWlyZSgnaW1wb3J0P3J1bGU9JytcXFwiICsgSlNPTi5zdHJpbmdpZnkoTVlfUlVMRS50aXRsZSkgKyBcXFwiKShpbnB1dClcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLlrozmlbTlj6Pku6RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCBydWxlYjY0LCBcXFwiYVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBpZiAoZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgICAgIG5ld0luZGV4ID0gcnVsZXMuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICAgICAgbmV3SW5kZXggPSBuZXdJbmRleCA9PT0gLTEgPyAwIDogbmV3SW5kZXg7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gIXJ1bGUuZm9yYmlkZGVuO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL1xcXCIgKyAocnVsZS5mb3JiaWRkZW4gPyBcXFwi56aB55SoXFxcIiA6IFxcXC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ge307XFxuICAgICAgICBiYWNrKCk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl6ZSZ6K+vXFxcIik7XFxuICAgIH1cXG59IGVsc2UgaWYgKGluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgIG9iaiA9IGFycltpbmRleF07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi57yW6L6R6KeE5YiZOlxcXCIgKyBvYmoubmFtZSk7XFxuICAgIGlmIChvYmoubGFzdE1vZGlmeSkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuS4iuasoeS/ruaUue+8mlxcXCIgKyAkLmRhdGVGb3JtYXQob2JqLmxhc3RNb2RpZnksIFxcXCJ5eXl5LU1NLWRkwqBISDptbTpzc1xcXCIpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59IGVsc2Uge1xcbiAgICBvYmogPSB7XFxuICAgICAgICBwYWdlOiB0cnVlXFxuICAgIH07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi5paw5bu66KeE5YiZXFxcIik7XFxufVxcblxcbmQucHVzaCh7XFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5ZCN5a2XKOW/heWhqylcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19uYW1lXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5uYW1lLFxcbiAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICB9XFxufSk7XFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLpgInmi6lcXFwiLFxcbiAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgZGVzYzogXFxcIuWIhue7hCjpgInloaspXFxcIixcXG4gICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGxldCBncm91cCA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEdyb3VwTmFtZXMoKTtcXG4gICAgICAgIGlmICghZ3JvdXAubGVuZ3RoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoZ3JvdXApLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgbGV0IGV4dHJhID0gZmluZEl0ZW0oXFxcInJ1bGVFZGl0R3JvdXBcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJydWxlRWRpdEdyb3VwXFxcIiwge1xcbiAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbihleHRyYSwge1xcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19ncm91cFxcXCIsIGlucHV0KTtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgaWQ6IFxcXCJydWxlRWRpdEdyb3VwXFxcIixcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogb2JqLmdyb3VwLFxcbiAgICB9XFxufSk7XFxuZC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XFxcIuehruWumuimgeWIoOmZpOatpOinhOWImeWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liKDpmaTmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIGluZGV4KVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgIH0sIGluZGV4LCB1cmxJbmRleCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIua1i+ivlVxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZShwYWdlID0+IHtcXG4gICAgICAgIGxldCB0ZXN0S2V5d29yZCA9IGdldEl0ZW0oXFxcInRlc3RLZXl3b3JkXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgcmV0dXJuICQodGVzdEtleXdvcmQsIFxcXCLor7fovpPlhaXlhbPplK7or41cXFwiKS5pbnB1dCgocGFnZSkgPT4ge1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcInRlc3RLZXl3b3JkXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcInBzX25hbWVcXFwiLCBcXFwiXFxcIik7XFxu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cXFwiLCBwYWdlID8gXFxcIjFcXFwiIDogXFxcIlxcXCIpLFxcbiAgICAgICAgICAgIHJlZ2lzdGVyVXJsOiBnZXRNeVZhcihcXFwicHNfcmVnaXN0ZXJVcmxcXFwiLCBcXFwiXFxcIikgfHwgdW5kZWZpbmVkLFxcbiAgICAgICAgICAgIGxhc3RNb2RpZnk6IERhdGUubm93KCksXFxuICAgICAgICAgICAgZ3JvdXA6IGdldE15VmFyKFxcXCJwc19ncm91cFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeinhOWImVxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeinhOWImVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgb2JqMSk7XFxuICAgICAgICAgICAgYXJ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h7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWJjeW+gOazqOWGjFxcXCIsXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCJoaWtlcjovL2VtcHR5I25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCIpLnJ1bGUoKHJlZ2lzdGVyVXJsKT0+e1xcbiAgICAgICAgICAgICAgICBzZXRSZXN1bHQoW3tcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJ4NV93ZWJ2aWV3X3NpbmdsZVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6cmVnaXN0ZXJVcmwsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOlxcXCJmbG9hdCYmMTAwJVxcXCJcXG4gICAgICAgICAgICAgICAgfV0pO1xcbiAgICAgICAgICAgIH0sIHJlZ2lzdGVyVXJsKSxcXG4gICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogXFxcIuazqOWGjOi0puWPtzpcXFwiICsgb2JqLm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBvYmogPSBvYmoudXNlciB8fCB7fTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIueUqOaIt+WQjVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouYWNjb3VudCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogXFxcInBhc3N3b3JkXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19wYXNzd29yZFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5wYXNzd29yZCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIumineWkllxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHR5cGU6IFxcXCJ0ZXh0YXJlYVxcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfZXh0cmFcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouZXh0cmEsXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICBoZWlnaHQ6IC0xXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBhY2NvdW50ID0gZ2V0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IHBhc3N3b3JkID0gZ2V0TXlWYXIoXFxcInBzX3Bhc3N3b3JkXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBleHRyYSA9IGdldE15VmFyKFxcXCJwc19leHRyYVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAvKmlmICghKGFjY291bnR8fHBhc3N3b3JkfHxleHRyYSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveWFqOmDqOS4uuepulxcXCI7XFxuICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgaXRlbSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgaXRlbS51c2VyID0ge307XFxuICAgICAgICAgICAgaXRlbS51c2VyLmFjY291bnQgPSBhY2NvdW50XFxuICAgICAgICAgICAgaXRlbS51c2VyLnBhc3N3b3JkID0gcGFzc3dvcmQ7XFxuICAgICAgICAgICAgaXRlbS51c2VyLmV4dHJhID0gZXh0cmE7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9pZOmUmeivr1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgaXRlbSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgICAgICByZX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0gJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG5ld0kgPSAwO1xcbiAgICAgICAgZm9yIChsZXQgcnVsZSBvZiBydWxlcykge1xcbiAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lm5hbWUgPT09IHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID4gLTEpIHtcXG4gICAgICAgICAgICAgICAgcnVsZSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFwiICsgaW5kZXggKyBcXFwiJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIuaWsOWinu+8mlxcXCIgKyBuZXdJICsgXFxcIiDopobnm5bmm7TmlrDvvJpcXFwiICsgKHJ1bGVzLmxlbmd0aCAtIG5ld0kpKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl5aSx6LSlXFxcIik7XFxuICAgIH1cXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLop4TliJnliJfooahcIixcInBhdGhcIjpcInJ1bGVzXCIsXCJydWxlXCI6XCJqczpcXG4kLmV4cG9ydHMgPSBbe1xcbiAgICAgICAgbmFtZTogXFxcIuWwj+S6kVxcXCIsXFxuICAgICAgICBwYWd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V0IHRpbWUgPSAvXFxcXGR7NH0oLVxcXFxkezJ9KXsyfSBcXFxcZHsyfShcXFxcOlxcXFxkezJ9KXsyfS8uZXhlYyhwZGZoKGl0ZW0sIFxcXCIubGF5dWktY2FyZC1ib2R5JiZUZXh0XFxcIikpIHx8IFtdO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgLy9kZXNjOiB0aW1lWzBdLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBiYXNlNjREZWNvZGUocGRmaChpdGVtLCBcXFwiYSYmdXJsXFxcIikpXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgbmFtZTogXFxcIua3t+WQiOebmFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZChzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS5odW5oZXBhbi5jb20vdjEvc2VhcmNoXFxcIjtcXG4gICAgICAgICAgICBsZXQganNvbiA9IHBvc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFJlZmVyZXI6IFxcXCJodHRwczovL2h1bmhlcGFuLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJxXFxcIjogcyxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwYWdlXFxcIjogcGFnZSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJzaXplXFxcIjogMTVcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShqc29uKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IGpzb24uZGF0YS5saXN0O1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgIGlmIChpdC5kaXNrX3R5cGUgIT09IFxcXCJBTFlcXFwiIHx8IGl0LnNoYXJlX3VzZXIgPT09IFxcXCLkuLYqKirkuLZcXFwiKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC5kaXNrX25hbWUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBwZChpdCwgXFxcImltZyYmc3JjXFxcIiwgdXJsKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXQubGluayxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LnVwZGF0ZV90aW1lICsgXFxcIlxcXFxuXFxcIiArIGl0LmxpbmssXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgbmFtZTogXFxcIui1hOa6kOW4rlxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZChzLCBwYWdlKSB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gc2VhcmNoKCkge1xcbiAgICAgICAgICAgICAgICBsZXQgcnRuTGlzdCA9IFtdO1xcbiAgICAgICAgICAgICAgICBsZXQgcmVzcCA9IHJlcXVlc3QoXFxcImh0dHBzOi8venliLnVweXVuc28uY29tL3YxNS9zZWFyY2g/a2V5d29yZD1cXFwiICsgZW5fYWVzKHMpICsgXFxcIiZzX3R5cGU9MiZwYWdlPVxcXCIgKyBwYWdlICsgXFxcIiZhdGs9JmRpZD1cXFwiICsgZ2VuZXJhdGVSYW5kb21IZXhTdHJpbmcoNjQpLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcInVzZXItYWdlbnRcXFwiOiBcXFwiTW96aWxsYS81LjAgKExpbnV4OyBBbmRyb2lkIDEwOyBSZWRtaSBOb3RlIDcgQnVpbGQvUUtRMS4xOTA5MTAuMDAyOyB3dikgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgVmVyc2lvbi80LjAgQ2hyb21lLzgxLjAuNDA0NC4xMzggTW9iaWxlIFNhZmFyaS81MzcuMzYgdW5pLWFwcCBIdG1sNVBsdXMvMS4wIChJbW1lcnNlZC8yOS4wOTA5MSlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGxldCByZXNwRGF0YSA9IGRlX2FlcyhyZXNwKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzb25EYXRhID0gSlNPTi5wYXJzZShyZXNwRGF0YSkgfHwge307XFxuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBqc29uRGF0YS5yZXN1bHQgfHwge307XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9IHJlc3VsdC5pdGVtcyB8fCBbXTtcXG5cXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpdGVtcy5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBpdGVtc1tpXTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50ID0gaXRlbS5jb250ZW50IHx8IFtdO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID09IDAgfHwgIWl0ZW0ucGFnZV91cmwpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IGRlX2FlcyhpdGVtLnBhZ2VfdXJsKSB8fCBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghdXJsKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgICAgIHJ0bkxpc3QucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IChpdGVtLnRpdGxlLmxlbmd0aCA+IDMwID8gaXRlbS50aXRsZS5zbGljZSgwLCAyNykgKyBcXFwiLi4uXFxcIiA6IGl0ZW0udGl0bGUpIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLliIbkuqvml7bpl7TvvJpcXFwiICsgaXRlbS5pbnNlcnRfdGltZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHVybFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHJ0bkxpc3Q7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGdlbmVyYXRlUmFuZG9tSGV4U3RyaW5nKGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBsZXQgcmVzdWx0ID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIGNvbnN0IGNoYXJhY3RlcnMgPSBcXFwiMDEyMzQ1Njc4OWFiY2RlZlxcXCI7XFxuICAgICAgICAgICAgICAgIGNvbnN0IGNoYXJhY3RlcnNMZW5ndGggPSBjaGFyYWN0ZXJzLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9IGNoYXJhY3RlcnMuY2hhckF0KE1hdGguZmxvb3IoTWF0aC5yYW5kb20oKSAqIGNoYXJhY3RlcnNMZW5ndGgpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBDcnlwdG9KUyA9IGFsaVV0aWwuZ2V0Q3J5cHRvSlMoKTtcXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBlbl9hZXMoZSkge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IFxcXCJxcTE5MjA1MjA0NjBxcXp6XFxcIjtcXG4gICAgICAgICAgICAgICAgLy8gZW5fYWVzXFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShpKTtcXG4gICAgICAgICAgICAgICAgdmFyIHQgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShlKSxcXG4gICAgICAgICAgICAgICAgICAgIHIgPSBDcnlwdG9KUy5BRVMuZW5jcnlwdCh0LCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpdjoga2V5LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiByLmNpcGhlcnRleHQudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZGVfYWVzKHZ2KSB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gXFxcInFxMTkyMDUyMDQ2MHFxenpcXFwiO1xcbiAgICAgICAgICAgICAgICAvLyBkZV9hZXNcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGkpO1xcbiAgICAgICAgICAgICAgICBsZXQgaGV4VmFsID0gQ3J5cHRvSlMuZW5jLkhleC5wYXJzZSh2diksXFxuICAgICAgICAgICAgICAgICAgICB2YWwgPSBDcnlwdG9KUy5lbmMuQmFzZTY0LnN0cmluZ2lmeShoZXhWYWwpLFxcbiAgICAgICAgICAgICAgICAgICAgZGVjcnlwdGVkID0gQ3J5cHRvSlMuQUVTLmRlY3J5cHQodmFsLCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpdjoga2V5LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBkZWNyeXB0ZWQudG9TdHJpbmcoQ3J5cHRvSlMuZW5jLlV0ZjgpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gc2VhcmNoKCk7XFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIG5hbWU6IFxcXCLkupHnm5jotYTmupBcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vcmVzLnl1bnBhbi53aW4vP1BhZ2VJbmRleD1cXFwiICsgcGFnZSArIFxcXCImUGFnZVNpemU9MTImS2V5d29yZD1cXFwiICsgcyArIFxcXCImVHlwZT0mVGFnPVxcXCI7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3Jlcy55dW5wYW4ud2luL1xcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCJtYWluJiYuY2FyZFxcXCIpO1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGRmaChpdCwgXFxcIi5jYXJkLWxpbmssMSYmb25jbGlja1xcXCIpLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgICAgICB1ID0gdS5sZW5ndGggPiAwID8gdVswXSA6IHVybDtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBwZGZoKGl0LCBcXFwiLmNhcmQtdGl0bGUmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBkKGl0LCBcXFwiaW1nJiZzcmNcXFwiLCB1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGRmaChpdCwgXFxcIi5jYXJkLXRleHQsLTEmJlRleHRcXFwiKSArIFxcXCJcXFxcblxcXCIgKyB1LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCJVUOS6keaQnFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9hcGkudXB5dW5zbzIuY29tL3NlYXJjaD9rZXl3b3JkPVxcXCIgKyBzICsgXFxcIiZwYWdlPVxcXCIgKyBwYWdlICsgXFxcIiZzX3R5cGU9MVxcXCI7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy51cHl1bnNvLmNvbVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogXFxcImNvZGU9MTkxOVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIC8vbG9nKGJhc2U2NERlY29kZShodG1sKSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKGh0bWwpKS5yZXN1bHQuaXRlbXM7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGlmICghYXJyKSByZXR1cm4gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IGl0LnBhZ2VfdXJsO1xcbiAgICAgICAgICAgICAgICAvL3UgPSB1Lmxlbmd0aCA+IDAgPyB1WzBdIDogdXJsO1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwiXFxcXG5cXFwiICsgKHUpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLnjKvni7jnm5jmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogZmFsc2UsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3d3dy5hbGlwYW5zb3UuY29tL3NlYXJjaD9rPVxcXCIgKyBzLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb20vc2VhcmNoP2s9XFxcIiArIHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCIjYXBwJiZhXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IFxcXCI8ZGl2PlxcXCIgKyBhcnJbaV0gKyBcXFwiPC9kaXY+XFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZGZoKGl0LCBcXFwiYSYmaHJlZlxcXCIpO1xcbiAgICAgICAgICAgICAgICAvL2xvZyh1KTtcXG4gICAgICAgICAgICAgICAgaWYgKCF1LmluY2x1ZGVzKFxcXCIvcy9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdSA9IFxcXCJodHRwczovL3d3dy5hbGlwYW5zb3UuY29tXFxcIiArIHUucmVwbGFjZShcXFwiL3MvXFxcIiwgXFxcIi9jdi9cXFwiKTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBwZGZoKGl0LCBcXFwidGVtcGxhdGUmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHBkZmgoaXQsIFxcXCJ0ZW1wbGF0ZSwxJiZUZXh0XFxcIiksXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KGlucHV0LCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBcXFwibm9fc2hvd19kb25hdGU9MVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IGlucHV0LnJlcGxhY2UoXFxcIi9jdi9cXFwiLCBcXFwiL3MvXFxcIilcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgcmVkaXJlY3Q6IGZhbHNlXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgaHRtbCA9IHBhcnNlRG9tRm9ySHRtbChodG1sLCAnYSYmaHJlZicpO1xcbiAgICAgICAgICAgIGlmIChodG1sLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGh0bWw7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGlucHV0O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuaYk+aQnFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgcmVnaXN0ZXJVcmw6IFxcXCJodHRwczovL3lpc28uZnVuXFxcIixcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBDcnlwdG9KUyA9IGFsaVV0aWwuZ2V0Q3J5cHRvSlMoKTtcXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBrZXllbihzdHIpIHtcXG4gICAgICAgICAgICAgICAgdmFyIGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKFxcXCI0T1RvU2NVRk9hZVZUckhFXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICBpdiA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKFxcXCI5Q0xHYW8xdkhLcW0xN096XFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBlbmNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdCh7XFxuICAgICAgICAgICAgICAgICAgICBjaXBoZXJ0ZXh0OiBDcnlwdG9KUy5lbmMuQmFzZTY0LnBhcnNlKHN0cilcXG4gICAgICAgICAgICAgICAgfSwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICBpdjogaXYsXFxuICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIHBhZGRpbmc6IENyeXB0b0pTLnBhZC5Qa2NzN1xcbiAgICAgICAgICAgICAgICB9KS50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlbmNyeXB0ZWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChcXFwiaHR0cHM6Ly95aXNvLmZ1bi9hcGkvc2VhcmNoP25hbWU9XFxcIiArIHMgKyBcXFwiJnBhZ2VObz1cXFwiICsgcGFnZSwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3lpc28uZnVuL2luZm8/c2VhcmNoS2V5PVxcXCIgKyBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IGdldEl0ZW0oJ3lpc291Y29va2UnLCAnJylcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIC8vbG9nKGh0bWwpO1xcbiAgICAgICAgICAgIGlmIChodG1sLmluY2x1ZGVzKCfnmbvlvZXnlKjmiLfml6DpmZDliLYnKSkge1xcbiAgICAgICAgICAgICAgICB2YXIgaSA9IDA7XFxuICAgICAgICAgICAgICAgIGRvIHtcXG4gICAgICAgICAgICAgICAgICAgIHZhciB0eWltZ2xpbiA9ICdodHRwczovL3lpc28uZnVuL2FwaS91c2VyL2xvZ2luL2NhcHRjaGE/dD0nICsgcGFyc2VJbnQobmV3IERhdGUoKS5nZXRUaW1lKCkpICsgJyc7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaW1nID0gY29udmVydEJhc2U2NEltYWdlKHR5aW1nbGluKS5zcGxpdCgnLCcpWzFdO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvZCA9IHJlcXVlc3QoJ2h0dHBzOi8vYXBpLnhob2ZlLnRvcC9vY3IvYjY0L3RleHQnLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnQ29udGVudC1UeXBlJzogJ3RleHQvcGxhaW4nXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBib2R5OiBpbWcsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgdmFyIHZlciA9IEpTT04ucGFyc2UocmVxdWVzdCgnaHR0cHM6Ly95aXNvLmZ1bi9hcGkvdXNlci9sb2dpbicsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdjb250ZW50LXR5cGUnOiAnYXBwbGljYXRpb24vanNvbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdyZWZlcmVyJzogJ2h0dHBzOi8veWlzby5mdW4vbG9naW4nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnQ29va2llJzogZ2V0Q29va2llKHR5aW1nbGluKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwidXNlck5hbWVcXFwiOiB1c2VyLmFjY291bnQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJwYXNzd29yZFxcXCI6IHVzZXIucGFzc3dvcmQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJjb2RlXFxcIjogY29kXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZlci5jb2RlID09IDIwMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvZygn5piT5pCc55m75YWl6aqM6K+B5oiQ5YqfJyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbSgneWlzb3Vjb29rZScsIGdldENvb2tpZSgnaHR0cHM6Ly95aXNvLmZ1bicpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBodG1sID0gcmVxdWVzdChcXFwiaHR0cHM6Ly95aXNvLmZ1bi9hcGkvc2VhcmNoP25hbWU9XFxcIiArIHMgKyBcXFwiJnBhZ2VObz1cXFwiICsgcGFnZSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3lpc28uZnVuL2luZm8/c2VhcmNoS2V5PVxcXCIgKyBzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IGdldEl0ZW0oJ3lpc291Y29va2UnLCAnJylcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaSsrO1xcbiAgICAgICAgICAgICAgICB9IHdoaWxlIChpIDwgNCk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBhcnIgPSBKU09OLnBhcnNlKGh0bWwpLmRhdGEubGlzdDtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IGtleWVuKGl0LnVybCk7XFxuICAgICAgICAgICAgICAgIC8vbG9nKHUpO1xcbiAgICAgICAgICAgICAgICBpZiAodSA9PSBudWxsIHx8ICF1LmluY2x1ZGVzKFxcXCJhbGl5dW5cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC5uYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogKGl0LmdtdFNoYXJlIHx8IGl0LmdtdENyZWF0ZSkgKyBcXFwiXFxcXG5cXFwiICsgKHUpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLlsI/nurjmnaFcXFwiLFxcbiAgICAgICAgcGFnZTogZmFsc2UsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBnZXR0b2tlbigpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKCd4enl0b2tlbicsICcnKS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRva2VuID0gSlNPTi5wYXJzZShwb3N0KCdodHRwczovL2dpdGNhZmUubmV0L3Rvb2wvYWxpcGFwZXIvJywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly91LmdpdGNhZmUuaW5rLydcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiAnZ2V0X3Rva2VuJ1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pKS5kYXRhO1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoJ3h6dHRva2VuJywgdG9rZW4pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBnZXRNeVZhcigneHp0dG9rZW4nLCAnJyk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGNhdF9jb2RlKGEpIHtcXG4gICAgICAgICAgICAgICAgdmFyIGQsIGUsIGIgPSBbXFxcIuWNjuivreeUteinhlxcXCIsIFxcXCLml6Xpn6nnlLXop4ZcXFwiLCBcXFwi5qyn576O55S16KeGXFxcIiwgXFxcIuWFtuS7lueUteinhlxcXCIsIFxcXCLljY7or63nlLXlvbFcXFwiLCBcXFwi5pel6Z+p55S15b2xXFxcIiwgXFxcIuasp+e+jueUteW9sVxcXCIsIFxcXCLlhbbku5bnlLXlvbFcXFwiLCBcXFwi5Y2O6K+t5Yqo5ryrXFxcIiwgXFxcIuaXpemfqeWKqOa8q1xcXCIsIFxcXCLmrKfnvo7liqjmvKtcXFwiLCBcXFwi57qq5b2V54mHXFxcIiwgXFxcIue7vOiJuueJh1xcXCIsIFxcXCLmlZnogrLln7norq1cXFwiLCBcXFwi5YW25LuW6KeG6aKRXFxcIiwgXFxcIuWNjuivremfs+S5kFxcXCIsIFxcXCLml6Xpn6npn7PkuZBcXFwiLCBcXFwi5qyn576O6Z+z5LmQXFxcIiwgXFxcIuWFtuS7lumfs+S5kFxcXCIsIFxcXCLlqLHkuZDova/ku7ZcXFwiLCBcXFwi57O757uf6L2v5Lu2X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ICAgICAgICBpZiAoY1tkXSA9PSBhKSByZXR1cm4gYltkXTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHBvc3QoXFxcImh0dHBzOi8vZ2l0Y2FmZS5uZXQvdG9vbC9hbGlwYXBlci9cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vdS5naXRjYWZlLmluay8nXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgIGFjdGlvbjogXFxcInNlYXJjaFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBmcm9tOiBcXFwid2ViXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHRva2VuOiBnZXR0b2tlbigpLFxcbiAgICAgICAgICAgICAgICAgICAga2V5d29yZDogc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IEpTT04ucGFyc2UoaHRtbCk7XFxuICAgICAgICAgICAgaWYgKGxpc3QuZGF0YSkge1xcbiAgICAgICAgICAgICAgICBsaXN0ID0gbGlzdC5kYXRhO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gbGlzdFtpXVxcbiAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBpdC50aXRsZTtcXG4gICAgICAgICAgICAgICAgbGV0IG11cmwgPSAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvJyArIGl0LmFsaWtleVxcbiAgICAgICAgICAgICAgICBpZiAoIWFsaVV0aWwuY2hlY2thbGkobXVybCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmICh0aXRsZS5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKImiBcXFwiICsgdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogY2F0X2NvZGUoaXQuY2F0KSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXM6IGl0LmRlc1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBtdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIueOqeWBtuWTpeWTpVxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgYmFzaWNVcmw6IFxcXCJodHRwOi8vd29nZy54eXpcXFwiLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBiYXNpY1VybCArIFxcXCIvaW5kZXgucGhwL3ZvZHNlYXJjaC9cXFwiICsgcyArIFxcXCItLS0tLS0tLS0tXFxcIiArIHBhZ2UgKyBcXFwiLS0tLmh0bWxcXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwpO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsIFxcXCIubW9kdWxlLWl0ZW1zJiYubW9kdWxlLXNlYXJjaC1pdGVtXFxcIik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHV0aXRsZSA9IHBkZmgoaXQsIFxcXCJoMyYmYSYmVGV4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdXNlcmlhbCA9IHBkZmgoaXQsIFxcXCIudmlkZW8tc2VyaWFsJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwZGZoKGl0LCBcXFwiaW1nJiZkYXRhLXNyY1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkKGl0LCBcXFwiaDMmJmEmJmhyZWZcXFwiLCBiYXNpY1VybCk7XFxuICAgICAgICAgICAgICAgIGJldC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB1dGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiB1aW1hZ2UsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiB1c2VyaWFsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGRmYShyZXF1ZXN0KGlucHV0KSwgXFxcImJvZHkmJi5tb2R1bGUtcm93LXRleHQuY29weVxcXCIpLm1hcCh2ID0+IHBkZmgodiwgXFxcImEmJmRhdGEtY2xpcGJvYXJkLXRleHRcXFwiKSk7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLpmL/ph4zkupHnm5jnvZFcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGJhc2ljVXJsOiBcXFwiaHR0cHM6Ly93d3cuYWx5cHcuY25cXFwiLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBiYXNpY1VybCArIFxcXCIvc2VhcmNoLnBocD9xPVxcXCIgKyBzICsgXFxcIiZwYWdlPVxcXCIgKyBwYWdlO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwsIHt9KTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGRmYShodG1sLCBcXFwiLmxpc3QmJmxpXFxcIik7XFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHV0aXRsZSA9IHBkZmgoaXQsIFxcXCJhJiZ0aXRsZVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdXNlcmlhbCA9IHBkZmgoaXQsIFxcXCIuZmEtY2xvY2stbyYmVGV4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdWltYWdlID0gcGRmaChpdCwgXFxcImltZyYmc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGQoaXQsIFxcXCJhJiZocmVmXFxcIiwgYmFzaWNVcmwpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXV0aXRsZS5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHV0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHVpbWFnZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHVzZXJpYWxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIHJldHVybiBwZGZhKHJlcXVlc3QoaW5wdXQpLCBcXFwiYm9keSYmYVtocmVmXj1odHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy9dXFxcIikubWFwKHYgPT4gcGRmaCh2LCBcXFwiYSYmaHJlZlxcXCIpKTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuWcn+aLqOm8oFxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IGZldGNoKCdodHRwczovL3d3dy50YnNkeS5jb20vc2VhcmNoLmh0bWw/a2V5d29yZD0nICsgcyArICcmY2F0ZWdvcnk9OTgzOTIwJmRhdGFfdHlwZT05ODc5MTAnLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUFcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxldCBhcnIgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsICcuc2VhcmNoX3Jlc3VsdF9uZXRkaXNrX2xpc3QmJmEnKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgLy9sb2coaXQpO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBhcnNlRG9tRm9ySHRtbChpdCwgJ2EmJmhyZWYnKTtcXG4gICAgICAgICAgICAgICAgbGV0IHRpdCA9IHBhcnNlRG9tRm9ySHRtbChpdCwgJy5uZXRkaXNrX2l0ZW1fZGV0YWlsX25hbWUmJlRleHQnKTtcXG4gICAgICAgICAgICAgICAgaWYgKCF0aXQuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIC8vbG9nKHUpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdCxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCJcXFxcblxcXCIgKyB1LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLpmL/ph4zmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCgnaHR0cHM6Ly9hbGlzby5jYy9zLycgKyBzICsgJy0nICsgcGFnZSArICctMC5odG1sJywge30pO1xcblxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCAnLnNlYXJjaC1yZXN1bHQmJi5yZXNvdXJjZS1pdGVtJyk7XFxuICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBsaXN0Lmxlbmd0aDsgaisrKSB7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gbGlzdFtqXTtcXG4gICAgICAgICAgICAgICAgbGV0IHRpdCA9IHBhcnNlRG9tRm9ySHRtbCh1LCAnaDMmJlRleHQnKTtcXG4gICAgICAgICAgICAgICAgaWYgKCF0aXQuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0LFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBwYXJzZURvbSh1LCAnaDMmJmEmJmhyZWYnLCAnaHR0cHM6Ly9hbGlzby5jYy8nKSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHBhcnNlRG9tRm9ySHRtbCh1LCAnLnRpbWUmJlRleHQnKSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBldmFsKGdldENyeXB0b0pTKCkpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGRlY3J5KHN0cikge1xcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjlFQjIwRERGRDZBRkJENjhcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGVuY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHN0ciwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICBpdjoga2V5LFxcbiAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICBwYWRkaW5nOiBDcnlwdG9KUy5wYWQuUGtjczd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HQoc3RyLCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuRUNCLFxcbiAgICAgICAgICAgICAgICAgICAgcGFkZGluZzogQ3J5cHRvSlMucGFkLlBrY3M3XFxuICAgICAgICAgICAgICAgIH0pLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVuY3J5cHRlZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9hcGkvYmJzL2FwaS9nZXRkYXRhP2tleT1cXFwiICsgcyArIFxcXCImdHlwZT12aWRlb1xcXCIsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBkZWNyeShKU09OLnBhcnNlKGh0bWwpLmRhdGEpO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBKU09OLnBhcnNlKGpzb24pO1xcblxcbiAgICAgICAgICAgIGxldCBiZXQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1cmwgPSBpdC5waWQ7XFxuICAgICAgICAgICAgICAgIGJldC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHVybDogXFxcImh0dHBzOi8vd3d3Lnl1bnBhbmZlbnhpYW5nLmNuL2FwaS9iYnMvYXBpL2dldGFydGljbGU/aWQ9XFxcIiArIHVybCxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LmNyZWF0ZXRpbWVcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KGlucHV0LCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3Lnl1bnBhbmZlbnhpYW5nLmNuL1xcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pKS5kYXRhO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5kb3dubG9hZC5zcGxpdChcXFwiQFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBhbGlzdCA9IG5ldyBTZXQoKTtcXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGxpc3QubGVuZ3RoOyBqKyspIHtcXG4gICAgICAgICAgICAgICAgYWxpc3QuYWRkKFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy9cXFwiICsgbGlzdFtqXSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBBcnJheS5mcm9tKGFsaXN0KTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuebmOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIHBhZ2UgPSAocGFnZSAtIDEpICogMTA7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL3d3dy5wYW5zZWFyY2gubWUvc2VhcmNoP2tleXdvcmQ9XFxcIiArIHMgKyBcXFwiJm9mZnNldD1cXFwiICsgcGFnZSArIFxcXCImcGFuPWFsaXl1bmRyaXZlXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7fSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgJy5ncmlkJiYuc2hhZG93OmhhcyhhW2hyZWZePWh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL10pJyk7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwYXJzZURvbUZvckh0bWwoaXQsICdhW2hyZWZePWh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL10mJmhyZWYnKTtcXG4gICAgICAgICAgICAgICAgbGV0IHBpY191cmwgPSBwYXJzZURvbUZvckh0bWwoaXQsICdpbWcmJnNyYycpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBhcnNlRG9tRm9ySHRtbChpdCwgJy5icmVhay1hbGwmJlRleHQnKS5zcGxpdCgnaHR0cCcpWzBdLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGljX3VybCA9PT0gXFxcIi9mYXZpY29uLnBuZ1xcXCIgPyBcXFwiaHR0cHM6Ly93d3cucGFuc2VhcmNoLm1lL1xcXCIgKyBwaWNfdXJsIDogcGljX3VybCxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHBhcnNlRG9tRm9ySHRtbChpdCwgJ3AmJlRleHQnKSArIFxcXCJcXFxcblxcXCIgKyB1LFxcbiAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCJET1ZY5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9hcGkuZG92eC50ay9hbGkvc2VhcmNoP3dkPVxcXCIgKyBzO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwpO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBKU09OLnBhcnNlKGh0bWwpLmxpc3Q7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBpdC52b2RfY29udGVudDtcXG4gICAgICAgICAgICAgICAgaWYgKCF1LmluY2x1ZGVzKFxcXCJhbGl5dW5kcml2ZVxcXCIpIHx8ICFhbGlVdGlsLmNoZWNrYWxpKHUpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLiiJogXFxcIiArIGl0LnZvZF9uYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3Vyb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GljYXRpb24vc2lnbmVkLWV4Y2hhbmdlO3Y9YjM7cT0wLjlcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGRmYShodG1sLCBcXFwiYm9keSYmYVxcXCIpO1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGQoaXQsIFxcXCJhJiZocmVmXFxcIiwgdXJsKTtcXG4gICAgICAgICAgICAgICAgbGV0IHQgPSBwZGZoKGl0LCBcXFwiYSYmVGV4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICBpZiAoaXQuaW5jbHVkZXMoXFxcIk5leHQgcGFnZVxcXCIpIHx8IGl0LmluY2x1ZGVzKFxcXCLkuIvkuIDpobVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHUyID0gcGQoaXQsIFxcXCJhJiZocmVmXFxcIiwgdXJsKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vbG9nKFxcXCJuZXh0IHBhZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vbG9nKHUyKTtcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJiaW5nXFxcIiwgdTIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmICh1ID09IG51bGwgfHwgdCA9PSBudWxsIHx8ICFpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKCFpdC5pbmNsdWRlcyhcXFwi572R55uYXFxcIikgJiYgIWl0LmluY2x1ZGVzKFxcXCLkupHnm5hcXFwiKSAmJlxcbiAgICAgICAgICAgICAgICAgICAgIWl0LmluY2x1ZGVzKFxcXCJhbGl5dW5kcml2ZVxcXCIpICYmICFpdC5pbmNsdWRlcyhcXFwieXVucGFuXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmICh1LnN0YXJ0c1dpdGgoXFxcImh0dHBzOi8vY24uYmluZy5jb20vXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBkb20gPSBnZXRIb21lKHUpLnJlcGxhY2UoXFxcImh0dHA6Ly9cXFwiLCBcXFwiXFxcIikucmVwbGFjZShcXFwiaHR0cHM6Ly9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBfbGlua3MgPSB0Lm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IG51bGw7XFxuICAgICAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBjID0gX2xpbmtzWzFdO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKF9saW5rcy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICBjID0gX2xpbmtzWzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdCxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IGRvbSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogYyAhPSBudWxsID8gYyA6IHUsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLov5vlhaXnvZHnq5lcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgaWYgKGlucHV0LmluY2x1ZGVzKFxcXCJhbGl5dW5kcml2ZVxcXCIpKSByZXR1cm4gaW5wdXQ7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KGlucHV0KTtcXG4gICAgICAgICAgICB2YXIgX2xpbmtzID0gaHRtbC5tYXRjaCgvaHR0cHM6XFxcXC9cXFxcLyh3d3dcXFxcLmFsaXl1bmRyaXZlXFxcXC5jb21cXFxcL3N8YWx5d3BcXFxcLm5ldClcXFxcL1xcXFx3Ki9nKSB8fCBbXTtcXG4gICAgICAgICAgICBpZiAoX2xpbmtzLmxlbmd0aCA+IDEgJiYgX2xpbmtzWzFdLnJlcGxhY2UoX2xpbmtzWzBdLCBcXFwiXFxcIikucmVwbGFjZSgvW2EtekEtWjAtOV0rL2csIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gX2xpbmtzWzFdO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIF9saW5rc1swXTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6ICdDQ09GJyxcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXVxcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSBmZXRjaCgnaHR0cHM6Ly9wYW4uY2NvZi5jYy9hcGkvc2VhcmNoJywge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiY29udGVudC10eXBlXFxcIjogJ2FwcGxpY2F0aW9uL2pzb24nLFxcbiAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly9wYW4uY2NvZi5jYy9zZWFyY2g/a2V5d29yZD0nICsgc1xcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwicGFnZVNpemVcXFwiOiAyMCxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwYWdlTnVtXFxcIjogcGFnZSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJrZXl3b3JkXFxcIjogcyxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJmcm9tTW9iaWxlXFxcIjogdHJ1ZVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBKU09OLnBhcnNlKGh0bWwpXFxuICAgICAgICAgICAgICAgIC5kYXRhLnJvd3NcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gaXQuZmlsZU5hbWVcXG4gICAgICAgICAgICAgICAgbGV0IG11cmwgPSBpdC51cmxcXG4gICAgICAgICAgICAgICAgbGV0IHR5cGUgPSBpdC50eXBlLnJlcGxhY2UoL2ZvbGRlci8sICfmlofku7blpLknKS5yZXBsYWNlKC9maWxlLywgJ+aWh+S7ticpXFxuICAgICAgICAgICAgICAgIGlmICh0aXRsZS5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogJ+aWh+S7tuexu+Wei++8micgKyB0eXBlICsgJ++8jOaWh+S7tuWkp+Wwj++8micgKyBhbGlVdGlsLmJ5dGVzVG9TaXplKGl0LnNpemUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogbXVybFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZFxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiAn6Zi/6YeM5bCP56uZJyxcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGhvbWUgPSBcXFwiaHR0cHM6Ly9wYW42NjYubmV0XFxcIjtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChidWlsZFVybChob21lICsgXFxcIi9hcGkvZGlzY3Vzc2lvbnNcXFwiLCB7XFxuICAgICAgICAgICAgICAgIFxcXCJpbmNsdWRlXFxcIjogXFxcInVzZXIsbGFzdFBvc3RlZFVzZXIsbW9zdFJlbGV2YW50UG9zdCxtb3N0UmVsZXZhbnRQb3N0LnVzZXIsdGFncyx0YWdzLnBhcmVudCxmaXJzdFBvc3RcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwiZmlsdGVyW3FdXFxcIjogcyAvKiArIFxcXCIgdGFnOnZpZGVvLGNvbWljXFxcIiovICxcXG4gICAgICAgICAgICAgICAgLy9cXFwiZmlsdGVyW3RhZ11cXFwiOiBcXFwidmlkZW8sY29taWNcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwicGFnZVtvZmZzZXRdXFxcIjogMjAgKiAocGFnZSAtIDEpXFxuICAgICAgICAgICAgfSksIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcImNvbnRlbnQtdHlwZVxcXCI6IFxcXCJhcHBsaWNhdGlvbi9qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vcGFuNjY2Lm5ldC8/cT1cXFwiICsgc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBKU09OLnBhcnNlKGh0bWwpLmRhdGE7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtID0gbGlzdFtpXS5hdHRyaWJ1dGVzO1xcbiAgICAgICAgICAgICAgICBsZXQgdXJsID0gaG9tZSArIFxcXCIvZC9cXFwiICsgaXRlbS5zbHVnO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiAn5Y+R5biD5pe26Ze077yaJyArICQuZGF0ZUZvcm1hdChuZXcgRGF0ZShpdGVtLmNyZWF0ZWRBdCksIFxcXCJ5eXl5LU1NLWRkIEhIOm1tOnNzXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui/m+WFpeW4luWtkFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQodXJsKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcGRmaChyZXF1ZXN0KGlucHV0KSwgXFxcIlRleHRcXFwiKTtcXG4gICAgICAgICAgICBsZXQgX2xpbmtzID0gaHRtbC5tYXRjaCgvaHR0cHM6XFxcXC9cXFxcLyh3d3dcXFxcLmFsaXl1bmRyaXZlXFxcXC5jb21cXFxcL3N8YWx5d3BcXFxcLm5ldClcXFxcL1xcXFx3Ki9nKSB8fCBbXTtcXG4gICAgICAgICAgICBsZXQgc2hhcmVQd2QgPSBodG1sLm1hdGNoKC/mj5Dlj5bnoIFbOu+8ml1cXFxccyo/KFxcXFx3ezR9KS8pO1xcbiAgICAgICAgICAgIHNoYXJlUHdkID0gQXJyYXkuaXNBcnJheShzaGFyZVB3ZCkgJiYgc2hhcmVQd2QubGVuZ3RoID4gMCA/IHNoYXJlUHdkWzFdIDogXFxcIlxcXCI7XFxuICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaVVybDogX2xpbmtzWzFdLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpVXJsOiBfbGlua3NbMF0sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2RcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6ICfkupHnm5jliIbkuqvnpL7ljLonLFxc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aSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBsaXN0W2ldLmF0dHJpYnV0ZXM7XFxuICAgICAgICAgICAgICAgIGxldCB1cmwgPSBob21lICsgXFxcIi9kL1xcXCIgKyBpdGVtLnNsdWc7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6ICflj5HluIPml7bpl7TvvJonICsgJC5kYXRlRm9ybWF0KG5ldyBEYXRlKGl0ZW0uY3JlYXRlZEF0KSwgXFxcInl5eXktTU0tZGQgSEg6bW06c3NcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L+b5YWl5biW5a2QXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudCh1cmwpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSBwZGZoKHJlcXVlc3QoaW5wdXQpLCBcXFwiVGV4dFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBfbGlua3MgPSBodG1sLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgIGxldCBzaGFyZVB3ZCA9IGh0bWwubWF0Y2goL+aPkOWPlueggVs677yaXVxcXFxzKj8oXFxcXHd7NH0pLyk7XFxuICAgICAgICAgICAgc2hhcmVQd2QgPSBBcnJheS5pc0FycmF5KHNoYXJlUHdkKSAmJiBzaGFyZVB3ZC5sZW5ndGggPiAwID8gc2hhcmVQd2RbMV0gOiBcXFwiXFxcIjtcXG4gICAgICAgICAgICBpZiAoX2xpbmtzLmxlbmd0aCA+IDEgJiYgX2xpbmtzWzFdLnJlcGxhY2UoX2xpbmtzWzBdLCBcXFwiXFxcIikucmVwbGFjZSgvW2EtekEtWjAtOV0rL2csIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpVXJsOiBfbGlua3NbMV0sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2RcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9saW5rcy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1swXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgbmFtZTogXFxcIueIseeci+e+juWJp1xcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly93d3cuMmttai5jbi9zZWFyY2gucGhwP3E9XFxcIiArIHMgKyBcXFwiJnBhZ2UvXFxcIiArIHBhZ2UgKyBcXFwiL1xcXCI7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgXFxcIi5saXN0LWl0JiZsaVxcXCIpO1xcblxcbiAgICAgICAgICAgIGxldCBiZXQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1dGl0bGUgPSBwYXJzZURvbUZvckh0bWwoaXQsIFxcXCJhJiZ0aXRsZVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdXNlcmlhbCA9IHBhcnNlRG9tRm9ySHRtbChpdCwgXFxcIi5pbmZvJiZzcGFuOm5vdCg6aGFzKGEpKS0taSYmVGV4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdWltYWdlID0gcGFyc2VEb20oaXQsIFxcXCJpbWcmJnNyY1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBhcnNlRG9tKGl0LCBcXFwiYSYmaHJlZlxcXCIpO1xcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdXRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogdWltYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogdXNlcmlhbFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG5cXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBkZmEocmVxdWVzdChpbnB1dCksIFxcXCJib2R5JiYjZG93bmxvYWRcXFwiKS5tYXAodiA9PiBwZGZoKHYsIFxcXCIuZG93biYmaHJlZlxcXCIpKTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuWlh+WmmeaQnOe0olxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZChzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybDtcXG4gICAgICAgICAgICBpZiAocGFnZSA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICB1cmwgPSBidWlsZFVybChcXFwiaHR0cHM6Ly93d3cubWFnaWNhbHNlYXJjaC50b3AvYXBpL3BzaG91L2dldERhdGFcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB3b3JkOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogXFxcIumYv+mHjOe9keebmFxcXCJcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gYnVpbGRVcmwoXFxcImh0dHBzOi8vd3d3Lm1hZ2ljYWxzZWFyY2gudG9wL2FwaS9wc2hvdS9nZXROZXh0UGFnZVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHVybDogXFxcImh0dHBzOi8vYXBpLnVweXVuc28yLmNvbS9zZWFyY2g/c190eXBlPTJAcGFnZT1cXFwiICsgcGFnZSArIFxcXCJAa2V5d29yZD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHMpLFxcbiAgICAgICAgICAgICAgICAgICAgd2Vic2l0ZTogXFxcIumYv+mHjOe9keebmFxcXCJcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByZXN1bHQgPSByZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBSZWZlcmVyOiBidWlsZFVybChcXFwiaHR0cHM6Ly93d3cubWFnaWNhbHNlYXJjaC50b3Avc2VhcmNoXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHdvcmQ6IHMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY3BhZ2U6IDBcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXN1bHQgPSBKU09OLnBhcnNlKEpTT04ucGFyc2UocmVzdWx0KSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSByZXN1bHQucmVzdWx0Lml0ZW1zO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xcbiAgICAgICAgICAgICAgICBpZiAoaXQuaWQgPT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwi5pel5pyf77yaXFxcIiArIGl0Lmluc2VydF90aW1lICsgXFxcIlxcXFxu6Lev5b6E77yaXFxcIiArIGl0LnBhdGgsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGl0LnBhZ2VfdXJsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcX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cbiAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgbGV0IG51bSA9IGNobk51bUNoYXJbc3RyW2ldXTtcXG4gICAgICAgIGlmICh0eXBlb2YgbnVtICE9PSAndW5kZWZpbmVkJykge1xcbiAgICAgICAgICAgIG51bWJlciA9IG51bTtcXG4gICAgICAgICAgICBpZiAoaSA9PT0gc3RyLmxlbmd0aCAtIDEpIHtcXG4gICAgICAgICAgICAgICAgc2VjdGlvbiArPSBudW1iZXI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgdW5pdCA9IGNobk5hbWVWYWx1ZVtzdHJbaV1dLnZhbHVlO1xcbiAgICAgICAgICAgIHNlY1VuaXQgPSBjaG5OYW1lVmFsdWVbc3RyW2ldXS5zZWNVbml0O1xcbiAgICAgICAgICAgIGlmIChzZWNVbml0KSB7XFxuICAgICAgICAgICAgICAgIHNlY3Rpb24gPSAoc2VjdGlvbiArIG51bWJlcikgKiB1bml0O1xcbiAgICAgICAgICAgICAgICBydG4gKz0gc2VjdGlvbjtcXG4gICAgICAgICAgICAgICAgc2VjdGlvbiA9IDA7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2VjdGlvbiArPSAobnVtYmVyICogdW5pdCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG51bWJlciA9IDA7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgcmV0dXJuIHJ0biArIHNlY3Rpb247XFxufVxcblxcbmZ1bmN0aW9uIG5hbWVDb21wYXJlKGEsIGIpIHtcXG4gICAgaWYgKGEgPT0gbnVsbCB8fCBiID09IG51bGwpXFxuICAgICAgICByZXR1cm4gYSA9PSBudWxsID8gYiA9PSBudWxsID8gMCA6IC0xIDogMTtcXG5cXG4gICAgYSA9IGEucmVwbGFjZSgvKFvpm7bkuIDkuozkuInlm5vkupTlha3kuI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ICBib2R5OiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiZ3JhbnRfdHlwZVxcXCI6IFxcXCJhdXRob3JpemF0aW9uX2NvZGVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcImNvZGVcXFwiOiBjb2RlLFxcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG4gICAgICAgICAgICByZXR1cm4gZGF0YVtcXFwicmVmcmVzaF90b2tlblxcXCJdO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHJlcyA9IHBvc3QoXFxcImh0dHBzOi8vYWxpeXVuZHJpdmUtb2F1dGgubWVzc2Vuc2UubWUvb2F1dGgvYXV0aG9yaXplL3FyY29kZVxcXCIsIHtcXG4gICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIFxcXCJzY29wZXNcXFwiOiBbXFxcInVzZXI6YmFzZVxcXCIsIFxcXCJmaWxlOmFsbDpyZWFkXFxcIiwgXFxcImZpbGU6YWxsOndyaXRlXFxcIl0sXFxuICAgICAgICAgICAgICAgIFxcXCJ3aWR0aFxcXCI6IDMwMCxcXG4gICAgICAgICAgICAgICAgXFxcImhlaWdodFxcXCI6IDMwMCxcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgIH0pO1xcbiAgICAgICAgbGV0IGRhdGEgPSBKU09OLnBhcnNlKHJlcyk7XFxuICAgICAgICBsZXQgc2lkID0gZGF0YVtcXFwic2lkXFxcIl07XFxuICAgICAgICBsZXQgcXJjb2RlX3VybCA9IGRhdGFbXFxcInFyQ29kZVVybFxcXCJdO1xcbiAgICAgICAgdXBkYXRlSXRlbShcXFwiaW5mb091dHB1dFxcXCIsIHtcXG4gICAgICAgICAgICBwaWNfdXJsOiBxcmNvZGVfdXJsLFxcbiAgICAgICAgICAgIHVybDogcXJjb2RlX3VybCArIFxcXCIjLmpwZ1xcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJwaWNfMV9mdWxsXFxcIlxcbiAgICAgICAgfSk7XFxuICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcImluZm9PdXRwdXRcXFwiLCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJjigJjigJnigJlcXFwiICsgXFxcIuS9v+eUqOmYv+mHjOS6keebmCBBcHAg5omr56CBXFxcIi5mb250Y29sb3IoXFxcImdyZXlcXFwiKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGNsczogXFxcImxvZ2luXFxcIlxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgICAgZGVsZXRlSXRlbShcXFwiZ2V0UUNcXFwiKTtcXG4gICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICBsZXQgcmVmcmVzaF90b2tlbjtcXG4gICAgICAgIHdoaWxlICh0cnVlKSB7XFxuICAgICAgICAgICAgbGV0IGRhdGE7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgZGF0YSA9IGdldF9xcmNvZGVfc3RhdHVzKHNpZCk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5p+l6K+i5omr56CB57uT5p6c6LaF5pe2LCDlj6/og73mmK/op6blj5HkuobpmL/ph4zkupHnm5jmjqXlj6PpmZDliLYsIOivt+eojeWQjuWGjeivlS5cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgc3RhdHVzID0gZGF0YVtcXFwic3RhdHVzXFxcIl07XFxuICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBcXFwiTG9naW5TdWNjZXNzXFxcIikge1xcbiAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuID0gZ2V0X3JlZnJlc2hfdG9rZW4oZGF0YVtcXFwiYXV0aENvZGVcXFwiXSk7XFxuICAgICAgICAgICAgICAgIGJyZWFrXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0dXMgPT0gXFxcIlFSQ29kZUV4cGlyZWRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuoznu7TnoIHlt7Lov4fmnJ8sIOivt+WIt+aWsOmhtemdouWQjumHjeivlVxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmICghZ2V0TXlWYXIoXFxcIkxvZ2dpbmdpblxcXCIsIFxcXCJcXFwiKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vY2FuY2VsXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgxNTAwKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChyZWZyZXNoX3Rva2VuKSB7XFxuICAgICAgICAgICAgY29uc3Qge1xcbiAgICAgICAgICAgICAgICBvcGVuVG9rZW5zRmlsZXBhdGgsXFxuICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwidG9rZW5QYXRoXFxcIik7XFxuICAgICAgICAgICAgbGV0IG9wZW4gPSB7XFxuICAgICAgICAgICAgICAgIFJlZnJlc2hUb2tlbk9wZW46IHJlZnJlc2hfdG9rZW4sXFxuICAgICAgICAgICAgICAgIGlzVjI6IHRydWVcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIHdyaXRlRmlsZShvcGVuVG9rZW5zRmlsZXBhdGgsIEpTT04uc3RyaW5naWZ5KG9wZW4pKTtcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcImluZm9PdXRwdXRcXFwiLCB7XFxuICAgICAgICAgICAgICAgIHRpdGxl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OiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMuJHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgICAgICd4LXNoYXJlLXRva2VuJzogdGhpcy4kdGhpcy5zaGFyZVRva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgbGV0IGNvZGUgPSByZXN1bHQucmVkaXJlY3RVcmkuc3BsaXQoXFxcImNvZGU9XFxcIilbMV07XFxuICAgICAgICByZXR1cm4gY29kZTtcXG4gICAgfSxcXG4gICAgZ2V0VG9rZW4oYm9keSkge1xcbiAgICAgICAgbGV0IGpzb24gPSBwb3N0KCdodHRwczovL2FwaS54aG9mZS50b3AvYWxpc3QvYWxpX29wZW4vY29kZScsIHtcXG4gICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICdVc2VyLUFnZW50JzogUENfVUEsXFxuICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeShib2R5KSxcXG4gICAgICAgIH0pO1xcbiAgICAgICAgaWYgKCFqc29uKSB7XFxuICAgICAgICAgICAganNvbiA9IHBvc3QoJ2h0dHBzOi8vYXBpLWNmLm5uLmNpL2FsaXN0L2FsaV9vcGVuL2NvZGUnLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGpzb24uaW5jbHVkZXMoJ1RvbyBNYW55IFJlcXVl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FuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMuJHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gZ2V0X3FyY29kZV9jb2RlKHNpZCk7XFxuICAgIH0sXFxuICAgIGdldFRva2VuKGJvZHkpIHtcXG4gICAgICAgIGxldCByZXMgPSBwb3N0KFxcXCJodHRwczovL29wZW5hcGkuYWxpeXVuZHJpdmUuY29tL29hdXRoL2FjY2Vzc190b2tlblxcXCIsIHtcXG4gICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeShib2R5KSxcXG4gICAgICAgIH0pO1xcbiAgICAgICAgbGV0IGRhdGEgPSBKU09OLnBhcnNlKHJlcyk7XFxuXFxuICAgICAgICByZXR1cm4gZGF0YTtcXG4gICAgfSxcXG4gICAgZ2V0T3BlblRva2VuKCkge1xcbiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0VG9rZW4oe1xcbiAgICAgICAgICAgIGNvZGU6IHRoaXMuZ2V0T3BlblRva2VuQ29kZSgpLFxcbiAgICAgICAgICAgIGdyYW50X3R5cGU6IFxcXCJhdXRob3JpemF0aW9uX2NvZGVcXFwiLFxcbiAgICAgICAgICAgIGNsaWVudF9zZWNyZXQ6IHRoaXMuY2xpZW50X3NlY3JldCxcXG4gICAgICAgICAgICBjbGllbnRfaWQ6IHRoaXMuY2xpZW50X2lkLFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIHJlZnJlc2hPcGVuVG9rZW4oKSB7XFxuICAgICAgICByZXR1cm4gdGhpcy5nZXRUb2tlbih7XFxuICAgICAgICAgICAgZ3JhbnRfdHlwZTogXFxcInJlZnJlc2hfdG9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bCB8fCBcXFwidGV4dF8zXFxcIjtcXG4gICAgdGhpcy50b05leHRQYWdlID0gZnVuY3Rpb24oKSB7XFxuICAgICAgICByZXR1cm4gJCgpLnJ1bGUoKGxpc3QsIGNvbF90eXBlKSA9PiB7XFxuICAgICAgICAgICAgc2V0UmVzdWx0KGxpc3QubWFwKHYgPT4gKHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGUsXFxuICAgICAgICAgICAgICAgIHVybDogJCgpLmxhenlSdWxlKHYgPT4gJC5yZXF1aXJlKFxcXCJyZWRpcmVjdFxcXCIpLmRlYWxSZXN1bHQodiksIHYpLFxcbiAgICAgICAgICAgICAgICB0aXRsZTogdi50aXRsZSB8fCB2LmFsaVVybC5yZXBsYWNlKC9odHRwLio/XFxcXC9zXFxcXC8vLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9KSkpO1xcbiAgICAgICAgfSwgbGlzdCwgY29sKTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRFcnJvclBvcChuYW1lKSB7XFxuICAgIHJldHVybiAkKFxcXCLmkJzntKLlvJXmk47jgIxcXFwiICsgbmFtZSArIFxcXCLjgI3lpLHmlYjor7fogZTns7vmkJzntKLlvJXmk47kvZzogIXkv67lpI3miJbliKDpmaRcXFxcblxcXFxu5byV5pOO5L2c6ICF5Y+v5Lul5Y675a6Y5pa56aKR6YGT6K+i6ZeuXFxcXG7ngrnlh7vnoa7lrprlv6vpgJ/liKDpmaRcXFwiKS5jb25maXJtKChuYW1lKSA9PiB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpFxcXCIgKyBuYW1lICsgXFxcIuWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobmFtZSkgPT4ge1xc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ZXh0cmEvaTIvTzFDTjAxRE9ZY3M3MXYzQjZiT2VtVk1fISE2MDAwMDAwMDA2MTE2LTItdHBzLTUxMi01MTIucG5nIiwicHJveHkiOiIifQ==
Add Comment
Please, Sign In to add comment