xiaomianao666

小程序:DrpyHiker

Aug 11th, 2024
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IkRycHlIaWtlciIsImF1dGhvciI6IkBMb3lEZ0lrJnpldGFscGhhIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6NDksImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoidmlkZW8iLCJjbGFzc191cmwiOiIiLCJhcmVhX25hbWUiOiIiLCJhcmVhX3VybCI6IiIsInNvcnRfbmFtZSI6IiIsInllYXJfbmFtZSI6IiIsInNvcnRfdXJsIjoiIiwieWVhcl91cmwiOiIiLCJmaW5kX3J1bGUiOiJqczokLnJlcXVpcmUoXCJNaWFuTG9hZFwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zPSoqJnBhZ2U9ZnlwYWdlIiwiZ3JvdXAiOiIj77iP4oOj5Lmd55+zIiwic2VhcmNoRmluZCI6ImpzOlxuKGZ1bmN0aW9uICgpIHtcbiAgbGV0IHtcbiAgICB1aV9jb25maWcsXG4gIH0gPSAkLnJlcXVpcmUoXCJVSU1hbmFnZVwiKTtcbiAgdWlfY29uZmlnPXVpX2NvbmZpZy55aTtcblxuICBsZXQgc21vZGUgPSBOdW1iZXIoZ2V0SXRlbShcInNtb2RlXCIsIFwiMFwiKSk7XG4gIGxldCB0ZW1zbW9kZSA9IGdldE15VmFyKFwidGVtc21vZGVcIiwgXCJcIik7XG4gIGlmICh0ZW1zbW9kZSkge1xuICAgIHNtb2RlID0gTnVtYmVyKHRlbXNtb2RlKTtcbiAgICBjbGVhck15VmFyKFwidGVtc21vZGVcIik7XG4gIH1cbiAgaWYgKCFma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y2ggKGVycm9yKSB7XG4gICAgICAgICAgICAvL2xvZyhlcnJvci5tZXNzYWdlKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgfSwgc291cmNlLCBpZCwgTVlfUlVMRS50aXRsZSk7XG4gICAgICAgIGNpZCA9IGlkO1xuICAgICAgfVxuXG4gICAgICBkLnB1c2goe1xuICAgICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzICsgXCLCt1wiICsgc291cmNlLm5hbWUsXG4gICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICB1cmw6IHVybCxcbiAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgIGlkOiBjaWQsXG4gICAgICAgICAgdm9kSWQ6IGlkLFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXG4gICAgICAgICAgc2tleTogc291cmNlLmtleSxcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuICAgIHNldFJlc3VsdChkKTtcbiAgfSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgIHVybDogXCJoaWtlcjovL3NlYXJjaD9zPVwiICsgTVlfS0VZV09SRCxcbiAgICAgIGV4dHJhOiB7XG4gICAgICAgIGRlbGVnYXRlT25seVNlYXJjaDogdHJ1ZSxcbiAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIiwgXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXCJzbW9kZVwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbG93U2VhcmNoU291cmNlKHNtb2RlID09PSAyKTtcblxuICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xuXG4gICAgICAgICAgICBsZXQgbGlzdGkgPSBsaXN0LmZpbmRJbmRleCh4ID0+IHgua2V5ID09IHNvdXJjZS5rZXkpO1xuXG4gICAgICAgICAgICBsZXQgc2VhcmNoc29ydCA9IE51bWJlcihnZXRJdGVtKFwic2VhcmNoc29ydFwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IHtcbiAgICAgICAgICAgICAgbmF0dXJhbFNvcnQsXG4gICAgICAgICAgICAgIHVzaW5nU29ydFxuICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcIm1ldGhvZHNcIik7XG5cbiAgICAgICAgICAgIGlmIChzZWFyY2hzb3J0ID4gMCkge1xuICAgICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA9PSAxKSB7XG4gICAgICAgICAgICAgICAgbmF0dXJhbFNvcnQobGlzdCwgXCJuYW1lXCIpO1xuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlYXJjaHNvcnQgPT0gMikge1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5zZXRrZXkoXCJuYW1lXCIpO1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdClcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoc291cmNlLnNlYXJjaGFibGUgJiYgbGlzdGkgIT0gLTEpIHtcbiAgICAgICAgICAgICAgbGlzdC5zcGxpY2UobGlzdC5pbmRleE9mKHNvdXJjZSksIDEpO1xuICAgICAgICAgICAgICBsaXN0LnVuc2hpZnQoc291cmNlKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHJ1bGVzID0gW107XG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XG4gICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xuICAgICAgICAgICAgICAgIHRpdGxlOiBpdC5uYW1lLFxuICAgICAgICAgICAgICAgIHNlYXJjaF91cmw6IFwiaGlrZXI6Ly9lbXB0eT9wYWdlPWZ5cGFnZSZzZWFyY2hUZXJtcz0qKlwiLFxuICAgICAgICAgICAgICAgIHNlYXJjaEZpbmQ6IFwianM6XCIgKyAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICBsZXQge1xuICAgICAgICAgICAgICAgICAgICB1aV9jb25maWcsXG4gICAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFwiVUlNYW5hZ2VcIik7XG4gICAgICAgICAgICAgICAgICB1aV9jb25maWc9dWlfY29uZmlnLnlpO1xuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpLmdldChpdGVtLmtleSk7XG4gICAgICAgICAgICAgICAgICBsZXQgaG9tZUxpc3QgPSBKU09OLnBhcnNlKGRycHkuc2VhcmNoKE1ZX0tFWVdPUkQsIGZhbHNlLCBNWV9QQUdFKSkubGlzdCB8fCBbXTtcbiAgICAgICAgICAgICAgICAgIGxldCBza2lwRXIgPSBkcnB5LmdldFJ1bGUoXCLkuoznuqdcIikgPT09IFwiKlwiICYmIGdldEl0ZW0oXCJza2lwRXJcIiwgXCJcIik7XG4gICAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xuICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaG9tZUxpc3QpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNpZDtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGlkID0gU3RyaW5nKGl0LnZvZF9pZCk7XG4gICAgICAgICAgICAgICAgICAgIGxldCB1cmwgPSBcImhpa2VyOi8vcGFnZS9kZXRhaWxlZFwiK3VpX2NvbmZpZy5tYXJrO1xuICAgICAgICAgICAgICAgICAgICBpZiAoc2tpcEVyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgdXJsID0gJCgpLmxhenlSdWxlKChzb3VyY2UsIGlkLCBteSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBEcnB5TWFuYWdlLmdldEJ5U291cmNlKHNvdXJjZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IEpTT04ucGFyc2UoZHJweS5kZXRhaWwoaWQpKS5saXN0WzBdLnZvZF9wbGF5X3VybC5zcGxpdChcIiRcIilbMV07ICAgICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coZS5tZXNzYWdlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gaWQuc3BsaXQoXCJAQFwiKVswXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSAkLnJlcXVpcmUoXCJ2aWRlb1VybFwiKS5wYXJzZSh1cmwsIGlkLCBzb3VyY2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coZXJyb3IubWVzc2FnZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICAgIH0sIGl0ZW0sIGlkLE1ZX1JVTEUuX3RpdGxlKTtcbiAgICAgICAgICAgICAgICAgICAgICBjaWQgPSBpZDtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnZvZF9uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICAgICAgICAgICAgICAgIHVybDogdXJsLFxuICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZDogY2lkLFxuICAgICAgICAgICAgICAgICAgICAgICAgdm9kSWQ6IGlkLFxuICAgICAgICAgICAgICAgICAgICAgICAgaXNQb2x5bWVyaXplOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICAgICAgc25hbWU6IGl0ZW0ubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNrZXk6IGl0ZW0ua2V5LFxuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICBzZX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gIH1cXG4gICAgICB9XFxuICAgICAgbGV0IHIgPSBcXFwiXFxcIjtcXG4gICAgICBpZiAoaXNGaWxlKSB7XFxuICAgICAgICByID0gcmVhZEZpbGVUb1N0cmluZyh1cmwucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKSk7XFxuICAgICAgfSBlbHNlIHtcXG4gICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxuICAgICAgfVxcbiAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcbiAgICAgICAgcmVzLmNvbnRlbnQgPSByLmJvZHk7XFxuICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXG4gICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgfVxcbiAgICAgIH0gZWxzZSB7XFxuICAgICAgICByZXMuY29udGVudCA9IHI7XFxuICAgICAgfVxcbiAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICB9XFxuICAgICAgcmV0dXJuIHJlcztcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgIGxvZyhcXFwiRXJyb3JcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgfVxcbiAgfVxcbiAgLypcXG4gIGNvbnN0IEppbkphID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2Nkbi5ib290Y2RuLm5ldC9hamF4L2xpYnMvbXVzdGFjaGUuanMvNC4xLjAvbXVzdGFjaGUuanNcXFwiKTtcXG4gXFxuICBjb25zdCBKUCA9ICQucmVxdWlyZSh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xsXFxcIlxcbiAgICAgICAgICB9KSxcXG4gICAgICAgICAgc3VybDogdWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSxcXG4gICAgICAgICAgdXJsOiBpc05vdmVsID8gXFxcImhpa2VyOi8vcGFnZS9ub3ZlbCNhdXRvUGFnZSMjcmVhZFRoZW1lI1xcXCIgOiAodWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5KSxcXG4gICAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxuICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9KSovXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgZnJvbTogZnJvbVtpXSxcXG4gICAgICAgICAgICBzb3VyY2U6IHNvdXJjZSxcXG4gICAgICAgICAgICBpZDogdWlkLFxcbiAgICAgICAgICAgIGJsb2NrUnVsZXM6IFsnYmIuKi5wbmcnLCAnLmpwZycsIFxcXCJobVxcXFwuYmFpZHVcXFxcLmNvbVxcXFwvaG0uanNcXFwiXSxcXG4gICAgICAgICAgICB2aWRlb0V4Y2x1ZGVSdWxlczogWyc/dXJsPSddLFxcbiAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgIH1cXG4g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nRyYW5zZm9ybUtleXMoe1xcbiAgICAgICAgICBcXFwic3VybFxcXCI6IFxcXCJ1cmxcXFwiLFxcbiAgICAgICAgICBcXFwic3RpdGxlXFxcIjogXFxcInRpdGxlXFxcIlxcbiAgICAgICAgfSk7XFxuICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShjaGFwdGVyTGlzdCkpO1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLkuIvovb1cXFwiICsgc3R5cGUsXFxuICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9kb3dubG9hZC52aWV3I25vUmVjb3JkSGlzdG9yeSMjbm9SZWZyZXNoIz9ydWxlPeacrOWcsOi1hOa6kOeuoeeQhicsXFxuICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgY2hhcHRlckxpc3Q6IFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIixcXG4gICAgICAgICAgICBpbmZvOiB7XFxuICAgICAgICAgICAgICBib29rTmFtZTogaW5mby52b2RfbmFtZSwgLy/mvKvnlLvlkI3np7AsXFxuICAgICAgICAgICAgICBydWxlTmFtZTogTVlfUlVMRS50aXRsZSxcXG4gICAgICAgICAgICAgIGJvb2tUb3BQaWM6IGluZm8udm9kX3BpYyxcXG4gICAgICAgICAgICAgIHBhcnNlQ29kZTogZG93bmxvYWRsYXp5LFxcbiAgICAgICAgICAgICAgYm9va0lkOiBNWV9QQVJBTVMuc25hbWUsXFxuICAgICAgICAgICAgICB0eXBlOiBzdHlwZSA9PT0gXFxcIua8q+eUu1xcXCIgPyBcXFwiY29taWNcXFwiIDogXFxcIm5vdmVsXFxcIixcXG4gICAgICAgICAgICB9LFxcbi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WUsXFxuICAgICAgICBwYWdlOiBwYWdlbnVtLFxcbiAgICAgICAgZGF0ZTogbmV3IERhdGUoKS5nZXRUaW1lKClcXG4gICAgICB9KTtcXG4gICAgICBsZXQgdGVtcCA9IHtcXG4gICAgICAgIGNvbF90eXBlOiAndGV4dF8xJyxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBhZ2VuYXZcXFwiXFxuICAgICAgICB9XFxuICAgICAgfVxcblxcbiAgICAgIHRwbGF5ID0gcGxheXAubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBsZXQgb2JqID0gT2JqZWN0LmFzc2lnbih7fSwgdGVtcCwge1xcbiAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyAocGFnZW51bSA9PSBpID8geC5mb250Y29sb3IoZXIu57q/6Lev6aKc6ImyKSA6IHgpLFxcbiAgICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGksIGlkLCBwYWdlbnVtKSA9PiB7XFxuICAgICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgcGFnZW51bSkgPT0gaSkge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgbGV0IGVyciA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmVyUmVmcmVzaDtcXG4gICAgICAgICAgICByZXR1cm4gZXJyKGxvY2F0aW9uKTtcXG4gICAgICAgICAgfSwgaSwgaWQ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cGNvdW50IC0gMTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBsZXQgZXJyID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZXJSZWZyZXNoO1xcbiAgICAgICAgICByZXR1cm4gZXJyKGxvY2F0aW9uKTtcXG4gICAgICAgIH0sIGlkLCBwY291bnQsIFN0cmluZyhwYWdlbnVtKSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCIsXFxuICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VAdXBcXFwiXFxuICAgICAgICB9XFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShwbGF5cFtwYWdlbnVtXSwge1xcbiAgICAgICAgICBjOiBmY1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkLCBwYWdlbnVtKSA9PiB7XFxuICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgcGFnZW51bSk7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBpZiAocGNvdW50ID09IDEpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2Vy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VhcnJcXFwiLFxcbiAgICAgICAgfVxcbiAgICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiBmb250c3R5bGUoJ+S4i+S4gOmhtScsIHtcXG4gICAgICAgICAgYzogZmNcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpZCkgPT4ge1xcbiAgICAgICAgICBsZXQgbG9jYXRpb24gPSBnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgbGV0IGVmID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZ2V0RUluZm8oKTtcXG4gICAgICAgICAgbGV0IHBjb3VudCA9IGVmLm1heFtsb2NhdGlvbl07XFxuICAgICAgICAgIGxldCBwYWdlbnVtID0gZWYucGFnZW51bTtcXG4gICAgICAgICAgaWYgKHBjb3VudCA9PSAxKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgfVxcblxcbiAgICAgICAgICBpZiAocGFnZW51bSA+PSBwY291bnQgLSAxKSB7XFxuICAgICAgICAgICAgcGFnZW51bSA9IDA7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgcGFnZW51bSsrO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKHBhZ2VudW0pKTtcXG4gICAgICAgICAgbGV0IGVyciA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmVyUmVmcmVzaDtcXG4gICAgICAgICAgcmV0dXJuIGVycihsb2NhdGlvbik7XFxuICAgICAgICB9LCBpZCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZV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gICAgICB9KVxcbiAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJwbGF5cGFnZUBwYWdlYXJyXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBwYWdlb2JqWzFdLnRpdGxlLFxcbiAgICAgICAgICB9KVxcbiAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJwbGF5cGFnZUBuZXh0XFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBwYWdlb2JqWzJdLnRpdGxlLFxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGVyLuWIhumhteWvvOiIqikge1xcbiAgICAgICAgICBpZiAoIWVyLuS6jOe6p+WIt+aWsCkge1xcbiAgICAgICAgICAgIGxldCBwbiA9IGZpbmRJdGVtc0J5Q2xzKFxcXCJwYWdlbmF2XFxcIilcXG4gICAgICAgICAgICBpZiAocG4ubGVuZ3RoID4gcGxheXAubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICBwbiA9IHBuLnNsaWNlKHBsYXlwLmxlbmd0aClcXG4gICAgICAgICAgICAgIHBuLm1hcCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgZGVsZXRlSXRlbSh4LmV4dHJhLmlkKVxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHBuLmxlbmd0aCA8IHBsYXlwLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgbGV0IHBpZCA9IHBuLmF0KC0xKTtcXG4gICAgICAgICAgICAgIGxldCBhZGQgPSB0cGxheS5zbGljZShwbi5sZW5ndGgpO1xcbiAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKHBpZC5leHRyYS5pZCwgYWRkKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdHBsYXkuZm9yRWFjaCgoeCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwicGFnZW51bVxcXCIgKyBpLCB7XFxuICAgICAgICAgICA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FyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgIGlmIChlci7nur/ot6/moLflvI8gIT0gXFxcInNlbGVjdFxcXCIpIHtcXG4gICAgICAgIGZvciAobGV0IGkgaW4gZnJvbSkge1xcbiAgICAgICAgICBsZXQgaWNvbmltZyA9IGVyLue6v+i3r+agt+W8jy5pbmNsdWRlcyhcXFwiaWNvblxcXCIpID8gZmluZEljb24oZnJvbVtpXSkgOiBcXFwiXFxcIjtcXG4gICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogKGkgPT0gY2kgPyBmb250c3R5bGUoZnJvbVtpXSwge1xcbiAgICAgICAgICAgICAgYzogZXIu57q/6Lev6aKc6ImyLFxcbiAgICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICAgIH0sIGVyLue6v+i3r+agt+W8jykgOiBmb250c3R5bGUoZnJvbVtpXSwge1xcbiAgICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICAgIH0sIGVyLue6v+i3r+agt+W8jykpLFxcbiAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaSwgaWQpID0+IHtcXG4gICAgICAgICAgICAgIGlmIChnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBwdXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICAgIGxldCBlcnIgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5lclJlZnJlc2g7XFxuICAgICAgICAgICAgICBlcnIoaSk7XFxuICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0sIGksIGlkKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgY2xzOiBcXFwibG9jYXRpb25AXFxcIixcXG4gICAgICAgICAgICAgIGlkOiBcXFwibG9jYXRpb25AXFxcIiArIGlcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGltZzogaWNvbmltZyxcXG4gICAgICAgICAgICBjb2xfdHlwZTogZXIu57q/6Lev5qC35byPXFxuICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgIH0gZWxzZSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICB0aXRsZTogZnJvbVtjaV0sXFxuICAgICAgICAgIGRlc2M6IGZyb20ubGVuZ3RoICsgXFxcIuadoee6v+i3r1xcXCIsXFxuICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgZm9udHN0eWxlLFxcbiAgICAgICAgICAgICAgZ2V0RUluZm8sXFxuICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpO1xcbiAgICAgICAgICAgIGxldCBlZiA9IGdldEVJbmZvKCk7XFxuXFxuICAgICAgICAgICAgbGV0IGZyb20gPSBlZi5mcm9tO1xcbiAgICAgICAgICAgIGxldCBtYXggPSBlZi5wbGF5cztcXG5cXG4gICAgICAgICAgICBsZXQgY2kgPSBnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICBsZXQgc2hvd2kgPSBnZXRNeVZhcihcXFwic2hvd2lcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IHRmcm9tID0gZnJvbS5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiBjaSA9PSBpID8gZm9udHN0eWxlKHggKyBcXFwiW1xcXCIgKyBtYXhbaV0gKyBcXFwiXVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgYzogJC5lcl91aS7nur/ot6/popzoibIsXFxuICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgIH0pIDogZm9udHN0eWxlKHggKyBcXFwiW1xcXCIgKyBtYXhbaV0gKyBcXFwiXVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGlmIChzaG93aSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInNob3dpXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgIGxldCBzaG93ID0gMTtcXG4gICAgICAgICAgICAgIGxldCBudW0gPSB0ZnJvbS5sZW5ndGg7XFxuICAgICAgICAgICAgICBpZiAobnVtIDwgOCkge1xcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChudW0gPiA4ICYmIG51bSA8PSAxMikge1xcbiAgICAgICAgICAgICAgICBzaG93ID0gMjtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHNob3cgPSAzO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICByZXR1cm4gJCh0ZnJvbSwgc2hvdykuc2VsZWN0KChjaSwgZiwgaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgTVlfVVJMPVxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICBlclJlZnJlc2hcXG4gICAgICAgICAgICAgICAgfT0kLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKTtcXG4gICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgICAgZmluZEljb25cXG4gICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwibWV0aG9kc19lclxcXCIpO1xcbiAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBNWV9JTkRFWDtcXG4gICAgICAgICAgICAgICAgaWYgKGkgPT0gY2kpIHtcXG4gICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBuYW1lID0gZltpXTtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICAgIGVyUmVmcmVzaChpKTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IGljb25pbWcgPSBmaW5kSWNvbihuYW1lLCAkLmVyX3VpKTtcXG5cXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwibG9jYXRpb25AXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgIHRpdGxlOiBuYW1lLFxcbiAgICAgICAgICAgICAgICAgIGltZzogaWNvbmltZyxcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwic2hvd2lcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH0sIGNpLCBmcm9tLCBpZClcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwic2hvd2lcXFwiKTtcXG4gICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9LCBpZCksXFxuICAgICAgICAgIGltZzogZXIu57q/6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c2gjXFxcIixcXG4gICAgY29sX3R5cGU6IFxcXCJpY29uX3NtYWxsXzRcXFwiLFxcbiAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9kb21haW5fY29uZmlnXFxcIixcXG4gICAgZXh0cmE6IHtcXG4gICAgICAgIHBhZ2VUaXRsZTogXFxcIuaWsOWinuino+aekFxcXCJcXG4gICAgfVxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YiG5LqrXFxcIixcXG4gICAgdXJsOiAkKFxcXCItMVxcXCIsIFxcXCLovpPlhaXkvaDopoHliIbkuqvop6PmnpDnmoTluo/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG5cXG4gICAgICAgIHJldHVybiAkKFtc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ICfigJzigJzigJ3igJ0nICsgKGZsYWdpLmluY2x1ZGVzKGYpID8gZi5mb250Y29sb3IoXFxcIiMxM0I2MUJcXFwiKSA6IGYpLFxcbiAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoZikgPT4ge1xcbiAgICAgICAgICAgIGxldCBmbGFnaSA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJmbGFnaVxcXCIsIFtcXFwi5YWo6YOoXFxcIl0pO1xcbiAgICAgICAgICAgIGlmICgvKOWFqOmDqHzlt7LnpoHnlKgpLy50ZXN0KGYpKSB7XFxuICAgICAgICAgICAgICAgIGZsYWdpID0gW2ZdXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgZmxhZ2kgPSBmbGFnaS5maWx0ZXIoeCA9PiAhLyjlhajpg6h85bey56aB55SoKS8udGVzdCh4KSk7XFxuICAgICAgICAgICAgICAgIGlmIChmbGFnaS5pbmNsdWRlcyhmKSkge1xcbiAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBmbGFnaS5maWx0ZXIoeCA9PiB4ICE9IGYpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZsYWdpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBbXFxcIuWFqOmDqFxcXCJdXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBmbGFnaS5wdXNoKGYpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImZsYWdpXFxcIiwgZmxhZ2kpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XF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0sIDEsIFxcXCLmk43kvZzvvJpcXFwiICsgaXQubmFtZSkuc2VsZWN0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi57yW6L6RXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSMjbm9SZWZyZXNoI1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIhuS6q1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG9wcyA9IGdldFBhc3RlcygpO1xcbiAgICAgICAgICAgICAgICBvcHMudW5zaGlmdChcXFwi5a6M5pW05Y+j5LukXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKG9wcywgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUudXNlciA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGViNjQgPSBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobmFtZSwgcnVsZSwgdHlwZSkgPT4gXFxcIua1t+mYlOinhueVjO+8jOOAjFxcXCIgKyBuYW1lICsgXFxcIuOAjURSUFnop6PmnpDvvIzlpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHJ1bGUgKyBcXFwiJFxcXCIgKyB0eXBlICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuWujOaVtOWPo+S7pFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHJ1bGViNjQsIFxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSAhcnVsZS5mb3JiaWRkZW47XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXCLnpoHnlKhcXFwiIDogXFxcIuWQr+eUqFxcXCIpICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGksIGxlbmd0aCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGk6IGksXFxuICAgICAgICAgICAgcGFnZVRpdGxlOiBpdC5uYW1lXFxuICAgICAgICB9XF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TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19qc1xcXCIsIGlucHV0KTtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouanMsXFxuICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICB9XFxufSk7XFxuZC5wdXNoKHtcXG4gICAgY29sX3R5cGU6IFxcXCJsaW5lX2JsYW5rXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5Yig6ZmkXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgdXJsSW5kZXgpID0+IHtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mraTpobnml6Dms5XliKDpmaRcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHVybEluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ato+WcqOabtOaWsOino+aekO+8jOWIoOmZpOivt+S7juino+aekOeuoeeQhui/m+WFpVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICA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HlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBtZXRob2QgPSBnZXRNeVZhcihcXFwicHNfbWV0aG9kXFxcIiwgXFxcIkdFVFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBqc29uUGF0aCA9IGdldE15VmFyKFxcXCJwc19qc29uUGF0aFxcXCIsIFxcXCJcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcbiAgICAgICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICAgICAgaWYgKGhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgICAgICBqc1xcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXG4gICAgICAgIH0pO1xcbiAgICB9KSxcXG4gICAgY29sX3R5cGU6IFxc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gZmxhZyxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgIGpzXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1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dHJ1ZSZpbmRleD1cXFwiICsgaW5kZXggKyBcXFwiJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgdG9hc3Q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b2FzdDovL+WPr+iDveWIoOW6k+S6hlxcXCI7XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC5uYW1lO1xcbiAgICAgICAgICAgIGxldCBzcGF0aCA9IGl0LnBhdGg7XFxuICAgICAgICAgICAgaWYgKCFuYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkgY29udGludWU7XFxuICAgICAgICAgICAgbmFtZSA9IG5hbWUuc2xpY2UoMCwgbmFtZS5sYXN0SW5kZXhPZihcXFwiLlxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKGBodHRwczovL3Jhdy5naXRtaXJyb3IuY29tLyR7cm9wZX0vbWFzdGVyLyR7c3BhdGh9YCk7XFxuICAgICAgICAgICAgaWYgKCEoKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpICYmICFmaWxlRXhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICAgICAgICAgJ2FwaSc6ICcuLi9saWJzL2RycHkyLmpzJyxcXG4gICAgICAgICAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdxdWlja1NlYXJjaCc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogXFxcIi4vXFxcIiArIGl0Lm5h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AgICAgICAgcnVsZSA9IHJlcXVlc3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgbmFtZXMucHVzaChuYW1lKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgZGVsZXRlbG9zZShuYW1lcywgcGF0aCk7XFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcImluZGV4Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShqc29uKSk7XFxuICAgIC8vd3JpdGVGaWxlKHBhdGgucmVwbGFjZSgvXFxcXC5qcyQvLCcuanNvbicpLCBKU09OLnN0cmluZ2lmeShqc29uKSk7XFxuICAgIHJldHVybiBcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFwiICsgY291bnQgKyBcXFwi5LiqXFxcIjtcXG59XFxuJC5leHBvcnRzLnBhcnNlVXJsID0gZnVuY3Rpb24gKHVybCwgcGF0aCkge1xcbiAgICBwYXRoID0gYmFzZTY0RGVjb2RlKHBhdGgpO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cmNlTGlzdD1bXTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoZmV0Y2goY29uZmlnLnBhdGgpIHx8IFxcXCJ7fVxcXCIpKTtcXG4gICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwgIWpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGlmIChqc29uLmhhc093blByb3BlcnR5KFxcXCJzaXRlc1xcXCIpICYmIGpzb24uc2l0ZXMuaGFzT3duUHJvcGVydHkoXFxcImRhdGFcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAganNvbi5zaXRlcyA9IGpzb24uc2l0ZXMuZGF0YTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5LuO572R57uc6I635Y+W55qE6YWN572u5paH5Lu25Li656m677yM6K+35qOA5p+l572R57ucXFxcIik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGlmIChzb3VyY2VMaXN0WzBdLmhhc093blByb3BlcnR5KFxcXCJpZFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHNvdXJjZUxpc3QgPSBzb3VyY2VMaXN0Lm1hcChpdGVtID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmhhc093blByb3BlcnR5KFxcXCJpZFxcXCIpICYmICFpdGVtLmhhc093blByb3BlcnR5KFxcXCJrZXlcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1bXFxcImtleVxcXCJdID0gaXRlbVtcXFwiaWRcXFwiXTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJpbmRleFxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBmaWxlID0gdm9pZCAwO1xcbiAgICAgICAgbGV0IGN1cnJlbnRTb3VyY2UsIHNlYXJjaEFsbG93O1xcbiAgICAgICAgaWYgKGNvbmZpZy5jS2V5KSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3QuZmluZCh2ID0+IHYua2V5ID09PSBjb25maWcuY0tleSk7XFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50U291cmNlKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgICAgICAvL2N1cnJlbnRDb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgLy9jb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IEpTT04ucGFyc2UoZmV0Y2goc2VhcmNoQWxsb3dQYXRoKSB8fCBcXFwiW11cXFwiKTtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBkZWxldGVGaWxlKHNlYXJjaEFsbG93UGF0aCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxvYWRFcnJvciA9IHZvaWQgMDtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyxcXG4gICAgICAgICAgICBzb3VyY2VMaXN0XFxuICAgICAgICB9O1xcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIGxvYWRFcnJvciA9IGU7XFxuICAgIH1cXG5cXG4gICAgcmV0dXJuIG51bGw7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlMb2NhbChkaXJGaWxlKSB7XFxuICAgIGxldCBsaXN0ID0gZGlyRmlsZS5saXN0RmlsZXMoKTtcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuXFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGxldCBuYW1lID0gU3RyaW5nKGl0LmdldE5hbWUoKSk7XFxuICAgICAgICBsZXQgcGF0aCA9IGl0LmdldFBhdGgoKTtcXG4gICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikgfHwgaXQuaXNEaXJlY3RvcnkoKSkgY29udGludWU7XFxuICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ2V4dCc6IGAke3BhdGh9YCxcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgbWFwcGluZyA9IGdldExvYWNsTWFwcGluZyhTdHJpbmcoZGlyRmlsZS5nZXRQYXRoKCkpKTtcXG5cXG4gICAgICAgIGlmIChtYXBwaW5nLmxlbmd0aCkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIG1hcHBpbmcpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gcnVsZXMuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBpdC5rZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBydWxlc1tpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShpbmRleCwgMCwgT2JqZWN0LmFzc2lnbih7fSwgaXRlbSwge1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7aXQudG9rZXl9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7aXQudG9rZXl9YCxcXG4gICAgICAgICAgICAgICAgICAgICdleHQnOiBpdGVtLmV4dCArIFxcXCI/XFxcIiArIGl0LnBhcmFtcyxcXG4gICAgICAgICAgICAgICAgICAgIGRlbDogdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgaXRlbS5kZWwgPSB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBydWxlcyA9IHJ1bGVzLmZpbHRlcih2ID0+ICF2LmRlbCk7XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgfVxcbiAgICByZXR1cm4gcnVsZXM7XFxufVxcblxcbmZ1bmN0aW9uIGdldExvYWNsTWFwcGluZyhkaXJGaWxlKSB7XFxuICAgIC8va2V5QHBhcmFtc0B0eXBlXFxuICAgIGxldCBtYXBwaW5nUGF0aCA9IFxcXCJmaWxlOi8vXFxcIiArIGpvaW5VcmwoZGlyRmlsZSwgXFxcIi4vXFxc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ZXcgamF2YS5pby5GaWxlKHBhdGgucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKSk7XFxuXFxuICAgICAgICAgICAgICAgIGlmICghKGZpbGUuZXhpc3RzKCkgJiYgZmlsZS5pc0RpcmVjdG9yeSgpKSkgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBmaWxlLmxpc3RGaWxlcygpKSB7XFxuICAgICAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKFN0cmluZyhpdC5nZXROYW1lKCkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkaXJuYW1lKHBhKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gam9pblVybChqc1BhdGgsIHBhKTtcXG4gICAgICAgICAgICAgICAgbGV0IG5hbWVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBmaWxlID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG5cXG4gICAgICAgICAgICAgICAgaWYgKCEoZmlsZS5leGlzdHMoKSAmJiBmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGRpckZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdC5pc0RpcmVjdG9yeSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBwYXRocztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHN0YXQoKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAg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ICAgICAgICBpZiAob2JqLnVybC5zdGFydHNXaXRoKFxcXCJmaWxlOlxcXCIpKSB7XFxuICAgICAgICAgIGxldCBjb2RlID0gXFxcIm5vXFxcIjtcXG4gICAgICAgICAgbGV0IHBhdGggPSBvYmoudXJsLnJlcGxhY2UoXFxcImZpbGU6Ly9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgIGxldCBkaXIgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcbiAgICAgICAgICBpZiAoZGlyLmlzRGlyZWN0b3J5KCkpIHtcXG4gICAgICAgICAgICBsZXQgZmxpc3QgPSBkaXIubGlzdEZpbGVzKCk7XFxuICAgICAgICAgICAgZm9yICh2YXIgZiBvZiBmbGlzdCkge1xcbiAgICAgICAgICAgICAgLy8g5qOA5p+l5paH5Lu25ZCN5piv5ZCm5LulLmpz57uT5bC+XFxuICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBqc0ZpbGVzLnB1c2goZik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7IH1cXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcblxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgIH1cXG4gICAgICB9O1xcbiAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxuICAgICAgYmUodGFza3MsIHtcXG4gICAgICAgIGZ1bmM6IGZ1bmN0aW9uIChvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICBsZXQgcmVnZXggPSAvKOWQjeensDouKj8pKFxcXFxzKyk/XFxcXG4vZztcXG4gICAgICAgIGxldCB0aXRsZSA9IFxcXCLlkI3np7A6XFxcIiArIHBbeC5pbmRleF0ubmFtZSArIFxcXCIgXFxcIjtcXG4gICAgICAgIGxldCB1cmwgPSBwW3guaW5kZXhdLnBhdGg7XFxuICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICBsZXQgY291bnQgPSB4LmNvdW50ICE9IDAgPyBcXFwiIOa6kOaVsOmHjzpcXFwiICsgeC5jb3VudCA6IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKC9uby8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGU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oKSksXFxuICAgICAgICBjb2w6IDIsXFxuICAgICAgICBqczogJC50b1N0cmluZyhuYW1lID0+IHtcXG4gICAgICAgICAgY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgIGxldCBzb3VyY2UgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSk7XFxuICAgICAgICAgIGxldCBwYXRoID0gcnVudGltZUNvbmZpZy5nZXRBYnNvbHV0ZVBhdGgoc291cmNlLmV4dCk7XFxuICAgICAgICAgIGxldCBwbmFtZSA9IHBhdGguc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSk7XFxuICAgICAgICAgIGxldCBydWxlID0gZmV0Y2gocGF0aCk7XFxuICAgICAgICAgIGxldCBlbmNvZGVNb2RlID0gZ2V0SXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICBpZiAoZW5jb2RlTW9kZSAmJiAvdmFyIHJ1bGV8W1xcXFx1NEUwMC1cXFxcdTlGQTVdK3xmdW5jdGlvbnxsZXQgfHZhciB8Y29uc3QgfFxcXFwofFxcXFwpfFxcXCJ8Jy8udGVzdChydWxlKSkge1xcbiAgICAgICAgICAgIGlmIChlbmNvZGVNb2RlID09PSBcXFwiR3ppcFxcXCIpIHtcXG4gICAgICAgICAgICAgIGxldCBHWklQID0gJC5yZXF1aXJlKFxcXCJHWklQXFxcIik7XFxuICAgICAgICAgICAgICBydWxlID0gR1pJUC56aXAocnVsZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChlbmNvZGVNb2RlID09PSBcXFwiQmFzZTY0XFxcIikge1xcbiAgICAgICAgICAgICAgcnVsZSA9IGJhc2U2NEVuY29kZShydWxlKTtcXG4gICAgICAgIC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gICAgICAgIG5hdHVyYWxTb3J0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5L2/55So5o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBsZXQgdXNpbmdzdCA9IGdldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgaWYgKHVzaW5nc3QgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIHVzaW5nc3QgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocyA9PSBcXFwi5Yi35paw6YWN572uXFxcIikge1xcbiAgICAgICAgICAgIGhpa2VyUG9wLnJ1bk9uTmV3VGhyZWFkKCgpID0+IHtcXG4gICAgICAgICAgICAgIGZ1bmN0aW9uIGFycmF5RGlmZmVyZW5jZShhcnIxLCBhcnIyKSB7XFxuICAgICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLmZpbHRlcihpdGVtID0+ICFtYXAuaGFzKGl0ZW0ua2V5KSk7XFxuICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgICBpZiAoIXJ1bnRpbWVDb25maWcuaW5pdERlZmF1bHQoKSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5Yi35paw5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5ydW5PblVJVGhyZWFkKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKFxcXCLpgInmi6nop4bpopHmupAg5b2T5YmN5YWxOlxcXCIgKyBtYW5hZ2UubGlzdC5sZW5ndGggKyBcXFwi5Liq6KeG6aKR5rqQXFxcIik7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICB9IGVsc2UgaWYgKHMuaW5jbHVkZXMoXFxcIumdkuWwkeW5tOaooeW8j1xcXCIpKSB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gc2VsZWN0KCkge1xcbiAgICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgICBcXFwidGl0bGVcXFwiOiBcXFwi6YCJ5oupXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIm9wdGlvbnNcXFwiOiBbXFxcIuS4tOaXtuWFs+mXrVxcXCIsIFxcXCLlhbPpl61cXFwiLCBcXFwi6K6+572u5a+G56CBXFxcIl0sXFxuICAgICAgICAgICAgICAgIGNvbDogMSxcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcblxcbiAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5Li05pe25YWz6ZetXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInRlbXBMZWFjaFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09IFxcXCLlhbPpl61cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImxlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K6+572u5a+G56CBXFxcXG7mjIfnurnkuI3og73nlKjml7bmnInmlYhcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImxlYWNoUGFzc1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kvb/nlKjpu5jorqTlr4bnoIFcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGxlYWNoUGFzcyA9IGdldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAocy5pbmNsdWRlcyhcXFwi5YWz6ZetXFxcIikpIHtcXG5cXG4gICAgICAgICAgICAgIGlmIChoaWtlclBvcC5jYW5CaW9tZXRyaWMoKSAhPT0gMCAmJiAhbGVhY2hQYXNzKSB7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr7nva7lr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGhpbnQ6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHkuI3og73kuLrnqbpcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hQYXNzXFxcIiwgdGV4dCk7XFxuICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidGVtcExlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmiZPlvIDov4fmu6RcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidGVtcExlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmiZPlvIDov4fmu6RcXFwiKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgaWYgKGhpa2VyUG9wLmNhbkJpb21ldHJpYygpICE9PSAwKSB7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgY29udGVudDogXFxcIui+k+WFpeWvhueggei/m+ihjOWFs+mXrVxcXCIsXFxuICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLovpPlhaXlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGhpbnQ6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQgPT09IGxlYWNoUGFzcyB8fCAoIWxlYWNoUGFzcyAmJiB0ZXh0ID09PSBTdHJpbmcocHMpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHplJnor69cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AuY2hlY2tCeUJpb21ldHJpYygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgaGlrZXJQb3AucnVuT25OZXdUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2VsZWN0KCk7XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwb3AuZGlzbWlzcygpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnvJbnoIHnsbvlnotcXFwiLFxcbiAgICAgICAgICAgICAgb3B0aW9uczogW1xcXCLkuI3nvJbnoIFcXFwiLCBcXFwiR3ppcFxcXCIsIFxcXCJCYXNlNjRcXFwiLCBcXFwiQUVTXFxcIl0sXFxuICAgICAgICAgICAgICBjb2w6IDEsXFxuICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgaW5wdXQ7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgIH0pO1xcbiAgICB9XFxuICB9KTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJkcnB5566h55CGXCIsXCJwYXRoXCI6XCJEcnB5TWFuYWdlXCIsXCJydWxlXCI6XCJqczpcXG5jb25zdCBKU0VuZ2luZSA9IGNvbS5leGFtcGxlLmhpa2Vydmlldy5zZXJ2aWNlLnBhcnNlci5KU0VuZ2luZTtcXG5jb25zdCBydW50aW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gaWYgKHNvdXJjZS50eXBlID09PSA0KSB7XFxuICAgICAgICBsZXQgdDQgPSBuZXcgVDRBZGFwdGVyKHNvdXJjZSk7XFxuICAgICAgICB0NC5pbml0KCk7XFxuICAgICAgICBkcnB5TWFwLnNldChzb3VyY2Uua2V5LCB0NCk7XFxuICAgICAgICByZXR1cm4gdDQ7XFxuICAgIH0gZWxzZSBpZiAoc291cmNlLnR5cGUgPT09IDEpIHtcXG4gICAgICAgIGxldCB0MSA9IG5ldyBUMUFkYXB0ZXIoc291cmNlKTtcXG4gICAgICAgIHQxLmluaXQoKTtcXG4gICAgICAgIGRycHlNYXAuc2V0KHNvdXJjZS5rZXksIHQxKTtcXG4gICAgICAgIHJldHVybiB0MTtcXG4gICAgfSBlbHNlIGlmIChzb3VyY2UudHlwZSA9PT0gMCkge1xcbiAgICAgICAgbGV0IFQwQWRhcHRlciA9ICQucmVxdWlyZShcXFwiVDBBZGFwdGVyXFxcIik7XFxuICAgICAgICBsZXQgdDAgPSBuZXcgVDBBZGFwdGVyKHNvdXJjZSk7XFxuICAgICAgICB0MC5pbml0KCk7XFxuICAgICAgICBkcnB5TWFwLnNldChzb3VyY2Uua2V5LCB0MCk7XFxuICAgICAgICByZXR1cm4gdDA7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICByZXR1cm4gY3JlYXRlVDMoc291cmNlKTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBnZXQoa2V5KSB7XFxuICAgIHJldHVybiBzeW5jKCgpID0+IHtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZXMoKS5maW5kKHYgPT4gdi5rZXkgPT09IGtleSk7XFxuICAgICAgICBsZXQgZHJweSA9IGNyZWF0ZU5ld0RycHkoc291cmNlKTtcXG5cXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcbi8vc291cmNlLmV4dOW/hemhu+S4uue7neWvuei3r+W+hFxcbmZ1bmN0aW9uIGdldEJ5U291cmNlKHNvdXJjZSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICBsZXQga2V5ID0gc291cmNlLmtleTtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBkcnB5ID0gY3JlYXRlTmV3RHJweShzb3VyY2UpO1xcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcnVuUHJveHkoZHJweSwgYXJncykge1xcbiAgICBpZiAodHlwZW9mIGRycHkucHJveHkgPT09IFxcXCJmdW5jdGlvblxcXCIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTEgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLmFjcXVpcmUoKTtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMiA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjHnrYnlvoXml7bpl7Q6XFxcIiArICh0aW1lMiAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcbiAgICAgICAgICAgIGxldCByZXMgPSBkcnB5LnByb3h5LmFwcGx5KGRycHksIGFyZ3MpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMuaJp+ihjOS7o+eQhuiAl+aXtjpcXFwiICsgKHRpbWUzIC0gdGltZTIpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjPmgLvogJfml7bogJfml7Y6XFxcIiArICh0aW1lMyAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcblxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxuICAgICAgICB9IGZpbmFsbHkge1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLnJlbGVhc2UoKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBkZWwoa2V5KSB7XFxuICAgIHN5bmMoKCkgPT4ge1xcbiAgICAgICAgLy9sb2coXFxcIuWIoOmZpFxcXCIgKyBrZXkpO1xcbiAgICAgICAgZHJweU1hcC5kZWxldGUoa2V5KTtcXG4gICAgICAgIC8qaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICBcXG4gICAgICAgIH0qL1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcbmxldCBpc0luaXRIb21lID0gZmFsc2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aGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG5cXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXG4gICAgICAgICAgICAgICAgbnVtZXJpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgc2Vuc2l0aXZpdHk6ICdiYXNlJ1xcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnJldmVyc2UoKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKHBvcFRpdGxlKHNlYXJjaEFsbG93Lmxlbmd0aCkpO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxuICAgICAgICAgICAgbGV0IHRlbWxpc3QgPSBzZWFyY2hBbGxvdy5zbGljZSgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKHRlbWxpc3QuaW5jbHVkZXModi5rZXkpKSByZXR1cm47XFxuICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBtYW5hZ2Uuc2V0VG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XFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV9vYmogPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcbiAgICAgICAgICAgICAgICAvL3N0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX3RlbXBcXFwiLCBjYXRlX3RlbXApO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCBjYXRlX29iaik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxc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hbWU7XFxuICAgICAgICB9LCBuYW1lKTtcXG4gICAgICB9IGVsc2UgaWYgKHNraXBFcikge1xcbiAgICAgICAgdXJsID0gJCgpLmxhenlSdWxlKChzb3VyY2UsIGlkKSA9PiB7XFxuICAgICAgICAgIGxldCB1cmw7XFxuICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcXG4gICAgICAgICAgICB1cmwgPSBKU09OLnBhcnNlKGRycHkuZGV0YWlsKGlkKSkubGlzdFswXS52b2RfcGxheV91cmwuc3BsaXQoXFxcIiRcXFwiKVsxXTtcXG4gICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHVybCA9IGlkLnNwbGl0KFxcXCJAQFxcXCIpWzBdO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucGFyc2UodXJsLCBpZCwgc291cmNlKTtcXG4gICAgICAgIH0sIHNvdXJjZSwgaWQpO1xcbiAgICAgICAgY2lkID0gaWQ7XFxuICAgICAgfVxcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogbmFtZSxcXG4gICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxcbiAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICBpbWc6IGl0LnZvZF9waWMsXFxuICAgICAgICBjb2xfdHlwZTogaG9tZUxpc3RDb2wsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXFxuICAgICAgICAgIHZvZElkOiBpZCxcXG4gICAgICAgICAgc25hbWU6IHNvdXJjZS5uYW1lLFxcbiAgICAgICAgICBza2V5OiBzb3VyY2Uua2V5L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CJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSlcXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIuafpeeci+a6kOS7o+eggVxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgbGV0IGNvZGUgPSBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5ydW5NYWluKFxcXCJsZXQgbWFpbj1cXFwiICsgJC50b1N0cmluZygoZXh0KSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuICgpID0+IGdldE9yaWdpbmFsSnMocmVxdWVzdChleHQsIHtcXG4gICAgICAgICAgICAgICdtZXRob2QnOiAnR0VUJ1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgfSwgcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlUGF0aCgpKSk7XFxuXFxuICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL3ZpZXdTb3VyY2VDb2RlLmpzXFxcIjtcXG4gICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGNvZGUpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICB9KVxcbiAgICAgIH1dLmNvbmNhdChjb25maWcudHlwZSA9PT0gXFxcImxvY2FsRGlyXFxcIiA/IFt7XFxuICAgICAgICB0aXRsZTogXFxcIue8lui+keWPguaVsOaYoOWwhOihqFxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygocGF0aCkgPT4ge1xcbiAgICAgICAgICBwYXRoICs9IFxcXCIvLm1hcHBpbmcudHh0XFxcIjtcXG4gICAgICAgICAgaWYgKGZpbGVFeGlzdChwYXRoKSkge1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLkv53lrZjlkI7liLfmlrDphY3nva7miJbph43lkK/miY3kvJrnlJ/mlYhcXFwiKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgcmV0dXJuICQoXFxcIuS4jeWtmOWcqOaYoOWwhOaWh+S7tuaYr+WQpuWIm+W7uu+8n1xcXCIpLmNvbmZpcm0ocGF0aCA9PiB7XFxuICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgdG9hc3QoXFxcIuS/neWtmOWQjuWIt+aWsOmFjee9ruaIlumHjeWQr+aJjeS8mueUn+aViFxcXCIpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJlZGl0RmlsZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgIH0sIHBhdGgpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LCBjb25maWcucGF0aClcXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIuacrOWcsOeuoeeQhlxcXCIsXFxuICAgICAgICBqczogXFxcIidoaWtlcjovL3BhZ2UvTG9jYWxEaXIjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjJ1xcXCJcXG4gICAgICB9XSA6IFtdKVxcbiAgICB9XFxuICB9KTtcXG5cXG4gIHVpb2JqLnB1c2goe1xcbiAgICBpbmRleDogMSxcXG4gICAga2V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ID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJnaXRodWJyYXdcXFwiLCBkZWYpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJnaXRodWJyYXdcXFwiLCB0ZXh0KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGlmICghcnVudGltZUNvbmZpZy5pbml0RGVmYXVsdCgpKSB7XFxuICAgICAgICAgICAgICB0b2FzdChcXFwi5Yi35paw5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5bey5L+d5a2YXFxcIik7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgfSBlbHNlIGlmIChpbnB1dC5pbmNsdWRlcyhcXFwi5Li76aKYXFxcIikpIHtcXG4gICAgICAgIGxldCBjdGhlbWUgPSBnZXRJdGVtKFxcXCJ0aGVtZVxcXCIsIFxcXCLpu5jorqRcXFwiKTtcXG4gICAgICAgIGxldCBzID0gJC50aGVtZXM7XFxuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKHMpO1xcbiAgICAgICAgaWYgKGtleXMubGVuZ3RoIDwgMikge1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5rKh5pyJ5YW25LuW5Li76aKYXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChrZXlzLmxlbmd0aCA9PSAyKSB7XFxuICAgICAgICAgIGxldCBuYW1lID0ga2V5c1swXTtcXG4gICAgICAgICAgaWYgKGN0aGVtZSA9PSBrZXlzWzBdKSB7XFxuICAgICAgICAgICAgbmFtZSA9IGtleXNbMV07XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgc2V0SXRlbShcXFwidGhlbWVcXFwiLCBuYW1lKTtcXG4gICAgICAgICAgbGV0IHRoZW1lID0gJC50aGVtZXNbbmFtZV07XFxuICAgICAgICAgICQudWlUaGVtZS5zZXQodGhlbWUpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICB9XFxuICAgICAgICBsZXQgdGhlbWVzID0gT2JqZWN0LmtleXMocykubWFwKHggPT4ge1xcbiAgICAgICAgICByZXR1cm4geCA9PSBjdGhlbWUgPyAn4oCc4oCc4oCd4oCdJyArIHguZm9udGNvbG9yKFxcXCJyZWRcXFwiKSA6IHg7XFxuICAgICAgICB9KTtcXG4gICAgICAgIHJldHVybiAkKHRoZW1lcykuc2VsZWN0KCh0aGVtZXMpID0+IHtcXG4gICAgICAgICAgbGV0IG5hbWUgPSB0aGVtZXNbTVlfSU5ERVhdO1xcbiAgICAgICAgICBzZXRJdGVtKFxcXCJ0aGVtZVxcXCIsIG5hbWUpO1xcbiAgICAgICAgICBsZXQgdGhlbWUgPSAkLnRoZW1lc1tuYW1lXTtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldCh0aGVtZSk7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9LCB0aGVtZXMpXFxuICAgICAgfVxcbiAgICB9KSxcXG4gICAgaW1nOiB1aV9jb25maWcuaWNvbnMu6K6+572uLFxcbiAgICBjb2xfdHlwZTogdWlfY29uZmlnLmNvbCxcXG4gIH0pO1xcbiAgdWlvYmoucHVzaCh7XFxuICAgIGluZGV4OiAzLFxcbiAgICBrZXk6IFxcXCLljoblj7JcXFwiLFxcbiAgICB0aXRsZTogXFxcIuWOhuWPslxcXCIsXFxuICAgIGNvbF90eXBlOiB1aV9jb25maWcuY29sLFxcbiAgICBpbWc6IHVpX2NvbmZpZy5pY29ucy7ljoblj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r5o6S6ZmkXFxuICAgICAgaWYgKCEoZXhjLmhhc093blByb3BlcnR5KGtleSkgJiYgZXhjW2tleV0gPT09IHRydWUpKSB7XFxuICAgICAgICAvLyDlpoLmnpzpobblsYLplK7lr7nlupTnmoTlgLzmmK/lr7nosaHvvIzlubbkuJTmnInlrZDmjpLpmaTop4TliJnvvIzliJnpgJLlvZLosIPnlKggZGVlcE9taXRcXG4gICAgICAgIGlmICh0eXBlb2Ygc291cmNlW2tleV0gPT09ICdvYmplY3QnICYmIHNvdXJjZVtrZXldICE9PSBudWxsICYmIGV4Y1trZXldKSB7XFxuICAgICAgICAgIHJlc3VsdFtrZXldID0gZGVlcE9taXQoc291cmNlW2tleV0sIGV4Y1trZXldKTtcXG4gICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHNvdXJjZVtrZXldICE9PSAnb2JqZWN0JyB8fCBzb3VyY2Vba2V5XSA9PT0gbnVsbCB8fCAhZXhjW2tleV0pIHtcXG4gICAgICAgICAgLy8g5aaC5p6c6aG25bGC6ZSu5a+55bqU55qE5YC85LiN5piv5a+56LGh77yM5oiW6ICF5rKh5pyJ5a2Q5o6S6Zmk6KeE5YiZ77yM55u05o6l5aSN5Yi25YC8XFxuICAgICAgICAgIHJlc3VsdFtrZXldID0gc291cmNlW2tleV07XFxuICAgICAgICB9XFxuICAgICAgfVxcbiAgICB9XFxuICB9XFxuICByZXR1cm4gcmVzdWx0O1xcbn1cXG5cXG4vKipcXG4gKiDliKTmlq3kuKTkuKrlr7nosaHmmK/lkKbnm7jnrYnvvIzlv73nlaXmjIflrprnmoTplK7jgIJcXG4gKiBAcGFyYW0geyp9IHggLSDnrKzkuIDkuKrlr7nosaHjgIJcXG4gKiBAcGFyYW0geyp9IHkgLSDnrKzkuozkuKrlr7nosaHjgIJcXG4gKiBAcGFyYW0ge0FycmF5fSBleGNsdWRlS2V5cyAtIOmcgOimgeW/veeVpeavlOi+g+eahOmUruaVsOe7hOOAglxcbiAqIEByZXR1cm5zIHtib29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eShvYmosIHBhdGgsIHZhbHVlKSB7XFxuICAgICAgICB2YXIgcGFydHMgPSBwYXRoLnNwbGl0KCcuJyk7XFxuICAgICAgICB2YXIgY3VycmVudCA9IG9iajtcXG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcGFydHMubGVuZ3RoIC0gMTsgaSsrKSB7XFxuICAgICAgICAgIHZhciBwYXJ0ID0gcGFydHNbaV07XFxuICAgICAgICAgIGlmICghY3VycmVudFtwYXJ0XSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRbcGFydF0gPSB7fTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtwYXJ0XTtcXG4gICAgICAgIH1cXG4gICAgICAgIGN1cnJlbnRbcGFydHNbcGFydHMubGVuZ3RoIC0gMV1dID0gdmFsdWU7XFxuICAgICAgfSxcXG4gICAgICBnZXQoKSB7XFxuICAgICAgICBsZXQgdWMgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB0aGlzLnVjKTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyh1YykubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgdWMgPSB0aGlzLmRlZjtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiB1YztcXG4gICAgICB9LFxcbiAgICAgIHNldCh2YWx1ZSwga2V5KSB7XFxuICAgICAgICBsZXQgdWMgPSB0aGlzLmdldCgpO1xcbiAgICAgICAgaWYgKGtleSkge1xcbiAgICAgICAgICB0aGlzLmRlZXBPYmplY3RQcm9wZXJ0eSh1Yywga2V5LCB2YWx1ZSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB1YyA9IHZhbHVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWMpO1xcbiAgICAgIH0sXFxuICAgICAgZ2V0SW5kZXhzKCkge1xcbiAgICAgICA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nRcXFwiKSB8fCBpdGVtLnRpdGxlLmluY2x1ZGVzKFxcXCLinqHvuI9cXFwiKSkge1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUucmVwbGFjZSgv4oCYfOKAmXzigJx84oCdfDxbXj5dKz4vZywgXFxcIlxcXCIpLnJlcGxhY2UoXFxcIuKeoe+4j1xcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9XFxuXFxuICAgICAgICAgIGxldCBjdXJyZW50ID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgIGlmIChPYmplY3Qua2V5cyhjdXJyZW50KS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogY3VycmVudC50aXRsZSxcXG4gICAgICAgICAgICAgIHBpYzogY3VycmVudC5waWMgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBkZXNjOiBjdXJyZW50LmRlc2MgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBjb2xfdHlwZTogY3VycmVudC50eXBlLFxcbiAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGl0ZW0uZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAga2V5OiBjdXJyZW50LmV4dHJhLmtleSxcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGN1cnJlbnQuZXh0cmEuaW5kZXhcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShjdXJyZW50LmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaXRlbS50aXRsZSxcXG4gICAgICAgICAgICAgIHBpYzogaXRlbS5waWMgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBkZXNjOiBpdGVtLmRlc2MgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICBjb2xfdHlwZTogaXRlbS50eXBlLFxcbiAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGN1cnJlbnQuZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAga2V5OiBpdGVtLmV4dHJhLmtleSxcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGl0ZW0uZXh0cmEuaW5kZXhcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IG5hcnIgPSAkLnN3YXBBcnJheUVsZW1lbnRzKGluZGV4cywgY3VycmVudC5leHRyYS5pbmRleCwgaXRlbS5leHRyYS5pbmRleCk7XFxuXFxuICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQobmFyciwgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidWlfY3VycmVudFxcXCIpO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBoID0gJ+KAnOKAnOKAneKAnSc7XFxuICAgICAgICAgICAgbGV0IHRpdGxlID0gaXRlbS50aXRsZTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi6YCJ5oup56e75Yqo55qE55uu5qCHXFxcIik7XFxuICAgICAgICAgICAgaWYgKC90ZXh0X2ljb258YXZhdGFyfGljb25fc21hbGxfMy8udGVzdChpdGVtLnR5cGUpKSB7XFxuICAgICAgICAgICAgICBoID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICB0aXRsZSA9IHRpdGxlLmZvbnRjb2xvcihcXFwiI2ZmZlxcXCIpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoL2ljb25fMV9zZWFyY2gvLnRlc3QoaXRlbS50eXBlKSkge1xcbiAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgdGl0bGUgPSBcXFwi4p6h77iPXFxcIiArIHRpdGxlO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICB0aXRsZSA9IHRpdGxlLmZvbnRjb2xvcihcXFwiI2ZmZlxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB1cGRhdGVJdGVtKGl0ZW0uZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBoICsgdGl0bGUsXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwidWlfY3VycmVudFxcXCIsIGl0ZW0pO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpKVxcbiAgICAgICAgaXRlbVtcXFwiZXh0cmFcXFwiXSA9IHtcXG4gICAgICAgICAga2V5OiBpdGVtLmtleSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIsXFxuICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIgKyBpLFxcbiAgICAgICAgICBpbmRleDogaXRlbS5pbmRleCxcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChpdGVtLmtleSAhPSBcXFwi6K6+572uXFxcIikge1xcbiAgICAgICAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6ZmkXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcImluZGV4XFxcIl0gPSAtMTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgfSwgaXRlbS5rZXkpXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoIS9pY29uXzFfc2VhcmNofGF2YXRhci8udGVzdChpdGVtLmNvbF90eXBlKSkge1xcbiAgICAgICAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5pu05o2i5Zu+5qCHXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSkgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuICQoaXRlbS5pbWcpLmlucHV0KChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBpdGVtLmtleTtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICBsZXQgayA9IGtleTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICBpZiAoa2V5ID09IFxcXCLmkJzntKLmqKHlvI9cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBrID0gXFxcIuaQnOe0olxcXCI7XFxuICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICQudWlUaGVtZS5zZXQoaW5wdXQsIFxcXCJ5aS5pY29ucy5cXFwiICsgayk7XFxuICAgICAgICAgICAgICAgICAgLy9pdGVtc1tpXVtcXFwiaW1nXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCwgeyBwaWM6IGlucHV0IH0pXFxuICAgICAgICAgICAgICB9LCBpdGVtKVxcbiAgICAgICAgICAgIH0sIGl0ZW0pXFxuICAgICAgICAgIH0pXFxuICAgICAgICAgIGlmIChpdGVtLmtleSAhPSBcXFwi5o2i5rqQXFxcIiAmJiBpdGVtLmtleSAhPSBcXFwi5pCc57Si5qih5byPXFxcIikge1xcbiAgICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogXFxcIuS/ruaUueWQjeensFxcXCIsXFxuICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiKS5pbnB1dCgoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJ0aXRsZVxcXCJdID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICBsZXQgaWQgPSBmaW5kSXRlbXNCeUNscyhNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIpLmZpbHRlcih4ID0+IHguZXh0cmEua2V5ID09IGtleSlbMF0uZXh0cmEuaWQ7XFxuICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCwgeyB0aXRsZTogaW5wdXQgfSlcXG4gICAgICAgICAgICAgICAgfSwga2V5KVxcbiAgICAgICAgICAgICAgfSwgaXRlbS5rZXkpXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaXRlbS5leHRyYS5Mb25nQ2xpY2sgPSBsb25nY2xpY2tzO1xcbiAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgfSlcXG4gICAgfSBlbHNlIHtcXG4gICAgICB1aW9iaiA9IHVpb2JqLm1hcCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgaXRlbS5leHRyYSA9IHtcXG4gICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9XFxuICAgIGQgPSBkLmNvbmNhdCh1aW9iaik7XFxuXFxuICAgIGlmIChpbmRleHMuc29tZSh4ID0+IHguaW5kZXggPT0gLTEpICYmIHVpbW9kZSkge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuW3suenu+mZpFxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxc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4gICAgICB0aXRsZTogXFxcIui/mOWOn1xcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbiAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoZGVmKSA9PiB7XFxuICAgICAgICByZXR1cm4gJChcXFwi5piv5ZCm5oGi5aSN6K6+572uXFxcIikuY29uZmlybSgoZGVmKSA9PiB7XFxuICAgICAgICAgICQudWlDb25maWcuc2V0KGRlZi55aSwgXFxcInlpXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+i/mOWOn+WujOaIkFxcXCI7XFxuICAgICAgICB9LCBkZWYpXFxuICAgICAgfSwgZGVmKSxcXG4gICAgfSwge1xcbiAgICAgIHRpdGxlOiBcXFwi56Gu6K6kXFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIExvbmdDbGljazogW3tcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlpI3liLZcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHVjID0gJC51aUNvbmZpZy5nZXQoKTtcXG4gICAgICAgICAgICBjb3B5KEpTT04uc3RyaW5naWZ5KHVjLnlpKSk7XFxuICAgICAgICAgIH0pLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWvvOWFpVxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSAkLnVpQ29uZmlnLmdldCgpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIikuaW5wdXQoKHVjKSA9PiB7XFxuICAgICAgICAgICAgICB2YXIgeWkgPSB7fTtcXG4gICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHlpID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgICAgIGlmICh5aS5oYXNPd25Qcm9wZXJ0eShcXFwidWlcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgIHVjLnlpID0geWk7XFxuICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWMpO1xcbiAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgdWMpXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9XVxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuWktOmDqOe7hOS7tuagt+W8jzpcXFwiICsgdWlfY29uZmlnLnlpLmNvbCxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgIHVpX2NvbmZpZyA9IHN0b3JhZ2UwLmdldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVpX2NvbmZpZyk7XFxuICAgICAgICBsZXQgYWxsX2NvbHMgPSBbJyddLmNvbmNhdChnZXRDb2xUeXBlcygpKTtcXG4gICAgICAgIGFsbF9jb2xz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KyBcXFwiX3lpY29sXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIlxcbiAgICAgIH1cXG4gICAgfSlcXG5cXG4gICAgbGV0IGRvYmogPSB7fTtcXG4gICAgJC51aUNvbmZpZy5nZXQoKS55aS51aS5maWx0ZXIoeCA9PiB4LmluZGV4ICE9IC0xKS5tYXAoaXQgPT4ge1xcbiAgICAgIGRvYmpbaXQua2V5XSA9IHRydWVcXG4gICAgfSlcXG5cXG4gICAgT2JqZWN0LmVudHJpZXMoZGVlcE9taXQodWlfdGhlbWUueWkuaWNvbnMsIGRvYmopKS5mb3JFYWNoKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IGtleSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaWNvbl81XFxcIixcXG4gICAgICAgIGltZzogdmFsdWUsXFxuICAgICAgICB1cmw6ICQodmFsdWUpLmlucHV0KChrKSA9PiB7XFxuICAgICAgICAgICQudWlUaGVtZS5zZXQoaW5wdXQsIFxcXCJ5aS5pY29ucy5cXFwiICsgayk7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBrZXkpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgZGVmYXVsdFZhbHVlOiB2YWx1ZVxcbiAgICAgICAgfVxcbiAgICAgIH0pXFxuICAgIH0pXFxuXFx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cXG4gICAgICAgIHR5cGU6IFxcXCJudW1iZXJcXFwiLFxcbiAgICAgIH1cXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIue6v+i3r+agt+W8jzogXFxcIiArIHVpX2NvbmZpZy5lci7nur/ot6/moLflvI8sXFxuICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBsZXQgY29sID0gJC51aUNvbmZpZy5nZXQoKS5lci7nur/ot6/moLflvI87XFxuICAgICAgICBsZXQgY29scyA9IFtcXFwiXFxcIl0uY29uY2F0KGdldENvbFR5cGVzKCkpO1xcbiAgICAgICAgY29scyA9IGNvbHMuZmlsdGVyKHggPT4gL3RleHRffGJ1dHRvbnxfZmlsbHxpY29uL2cudGVzdCh4KS8qJiF4LmluY2x1ZGVzKFxcXCJpY29uXFxcIikqLyk7XFxuICAgICAgICBjb2xzLnVuc2hpZnQoXFxcInNlbGVjdFxcXCIpO1xcbiAgICAgICAgY29scyA9IGNvbHMubWFwKHggPT4geCA9PSBjb2wgPyBcXFwi4p6h77iPXFxcIiArIHggOiB4KTtcXG4gICAgICAgIHJldHVybiAkKGNvbHMsIDIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgIGlucHV0ID0gaW5wdXQucmVwbGFjZShcXFwi4p6h77iPXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAkLnVpQ29uZmlnLnNldChpbnB1dCwgXFxcImVyLue6v+i3r+agt+W8j1xcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICB9KVxcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy5lci7nur/ot6/moLflvI8sXFxuICAgICAgICBsaW5lVmlza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B7XFxuICAgICAgICBsZXQgeyBpc1ZhbGlkQ29sb3IgfSA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpO1xcbiAgICAgICAgaWYgKGlzVmFsaWRDb2xvcihpbnB1dCkpIHtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcImVyLue6v+i3r+minOiJslxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWl5q2j56Gu55qE6aKc6Imy5YC8XFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy5lci7nur/ot6/popzoibJcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmtYXmnaXmupDoibJcXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgIGRlc2M6IFxcXCLlrZfkvZPpopzoibI76IOM5pmv6aKc6ImyXFxcIixcXG4gICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgaWYgKGlucHV0LmluY2x1ZGVzKFxcXCI7XFxcIikpIHtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcImVyLua1headpea6kOiJslxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWl5q2j56Gu5pWw5YC8XFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy5lci7mtYXmnaXmupDoibJcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmt7HmnaXmupDoibJcXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgIGRlc2M6IFxcXCLlrZfkvZPpopzoibI76IOM5pmv6aKc6ImyXFxcIixcXG4gICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgaWYgKGlucHV0LmluY2x1ZGVzKFxcXCI7XFxcIikpIHtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcImVyLua3seadpea6kOiJslxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWl5q2j56Gu5pWw5YC8XFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy5lci7mt7HmnaXmupDoibJcXG4gICAgICB9XFxuICAgIH0pXFxuXFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLnur/ot6/popzoibJcXFwiLFxcbiAgICAgIGltZzogdWlfY29uZmlnLmVyLue6v+i3r+minOiJsixcXG4gICAgICB1cmw6IFxcXCJ0b2FzdDovL+e6v+i3r+minOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpY29uXzNfZmlsbFxcXCIsXFxuICAgIH0pXFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLnroDku4vmoLflvI86IFxcXCIgKyB1aV9jb25maWcuZXIu566A5LuL5qC35byPLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG4gICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgbGV0IGNvbCA9ICQudWlUaGVtZS5nZXQoKS5lci7nroDku4vmoLflvI87XFxuICAgICAgICBsZXQgY29scyA9IFtcXFwiMFxcXCIsIFxcXCIxXFxcIl07XFxuICAgICAgICBjb2xzID0gY29scy5tYXAoeCA9PiB4ID09IGNvbCA/IFxcXCLinqHvuI9cXFwiICsgeCA6IHgpO1xcbiAgICAgICAgcmV0dXJuICQoY29scywgMikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgaW5wdXQgPSBpbnB1dC5yZXBsYWNlKFxcXCLinqHvuI9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICQudWlUaGVtZS5zZXQoaW5wdXQsIFxcXCJlci7nroDku4vmoLflvI9cXFwiKTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgfSlcXG4gICAgICB9KSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgfVxcbiAgICB9KVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5YiG6aG16YC76L6RXFxcIixcXG4gICAgICBpbWc6IGJ1dHRvbkltZygoIXVpX2NvbmZpZy5lci7liIbpobXpgLvovpEgfHwgdWlfY29uZmlnLmVyLuWIhumhtemAu+i+kSA9PSBcXFwiMFxcXCIgPyBmYWxzZSA6IHRydWUpKSxcXG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgbGV0IHBhID0gJC51aUNvbmZpZy5nZXQoKS5lci7liIbpobXpgLvovpE7XFxuICAgICAgICBpZiAocGEgPT0gdW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cIixcXG4gICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIGxldCB1YyA9ICQudWlDb25maWcuZ2V0KCk7XFxuICAgICAgICAgICAgY29weShKU09OLnN0cmluZ2lmeSh1Yy5lcikpO1xcbiAgICAgICAgICB9KSxcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlr7zlhaVcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHVjID0gJC51aUNvbmZpZy5nZXQoKTtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwie3tjbGlwYm9hcmR9fVxcXCIpLmlucHV0KCh1YykgPT4ge1xcbiAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgdWMuZXIgPSBKU09OLnBhcnNlKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmoLzlvI/plJnor69cXFwiKVxcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHVjKVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfV1cXG4gICAgICB9XFxuICAgIH0pXFxuICB9XFxuICBzZXRSZXN1bHQoZCk7XFxufVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiTG9jYWxQcm94eVwiLFwicGF0aFwiOlwiTG9jYWxQcm94eVwiLFwicnVsZVwiOlwiZnVuY3Rpb24gcHJveHkoKSB7XFxuICAgIGZ1bmN0aW9uIHBhcnNlVmlkZW8oTVlfUEFSQU1TLCB0aXRsZSkge1xcbiAgICAgICAgZnVuY3Rpb24gdG9QYXRoKHZhbHVlKSB7XFxuICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gJ3N0cmluZycpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFtdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGF0aCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgbGV0IGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICBsZXQgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2YWx1ZS5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoZXNjYXBlKSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXFxcXFxcXFwnKSB7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGN1cnJlbnQpIHtcXG4gICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcGF0aDtcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxuICAgICAgICAgICAgaWYgKCFvYmogfHwgIUFycmF5LmlzQXJyYXkocGF0aCkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHBhdGgubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gb2JqO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IG51bGwgfHwgY3VycmVudCA9PT0gdW5kZWZpbmVkIHx8IHR5cGVvZiBjdXJyZW50ICE9PSAnb2JqZWN0Jykge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtrZXldO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gY3VycmVudDtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJ1blR5cGUgPSBNWV9QQVJBTVMucnVuVHlwZVswXTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKSk7XFxuICAgICAgICAgICAgaWYgKHJ1blR5cGUgPT0gXFxcIkpTT05cXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJhbSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcGFyYW0uaGVhZGVycyB8fCB7fSxcXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZDogcGFyYW0ubWV0aG9kIHx8IHZvaWQgMFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBPYmplY3QuYXNzaWduKHt9LCBwYXJhbS5oZWFkZXJzIHx8IHt9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogZ2V0SnNvbihqc29uLCB0b1BhdGgocGFyYW0uanNvblBhdGgpKSxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PSBcXFwiSlNcXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJzZTtcXG4gICAgICAgICAgICAgICAgaWYgKE1ZX1BBUkFNUy5pbmRleCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgdGl0bGUpLmdldEpzb24oKVtNWV9QQVJBTVMuaW5kZXhbMF1dO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShkZWNvZGVVUklDb21wb25lbnQoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCByZXMgPSBuZXcgRnVuY3Rpb24oXFxcInVybFxcXCIsIFxcXCJzZWxmXFxcIiwgcGFyc2UuanMpKHVybCwgcGFyc2UpO1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcyA9PT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogcmVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoJC50eXBlKHJlcykgPT09IFxcXCJvYmplY3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiByZXNcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICA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77yM6YCS5b2S6LCD55SoZXhjbHVkZUtleXNcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaXRlbSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gaXRlbS5leGNsdWRlS2V5cyhleGNsdWRlLCBrZXlzLCByZW5hbWVDYWxsYmFjayk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGl0ZW0gPT09ICdvYmplY3QnICYmIGl0ZW0gIT09IG51bGwpIHtcXG4gICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrlr7nosaHvvIzkvb/nlKhPYmplY3QuZnJvbUVudHJpZXPlkoxPYmplY3QuZW50cmllc+adpeWkhOeQhumUrlxcbiAgICAgICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyhpdGVtKTtcXG4gICAgICAgICAgICBjb25zdCBwcm9jZXNzZWRFbnRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgLy8g5aaC5p6c5pyJ6YeN5ZG95ZCN5Zue6LCD5Ye95pWw77yM5YiZ6LCD55So5a6DXFxuICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbmFtZUNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIHJldHVybiBba2V5LCB2YWx1ZV07XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgY29uc3QgZmlsdGVyZWRFbnRyaWVzID0gc2hvdWxkRXhjbHVkZSA/XFxuICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+ICFrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSkgOlxcbiAgICAgICAgICAgICAgcHJvY2V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AgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muWinuWKoHVp566h55CG44CCXFxcIixcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrkuLvpobXlop7liqDot7Pov4flvaLlvI8oKinkuoznuqfpgInpobnjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muino+aekOeuoeeQhuWinuWKoGZsYWfliIbnsbvjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5LyY5LyY5YyW6K6i6ZiF5pu05paw562W55Wl44CCXFxcIixcXG4gICAgXVxcbn0sIHtcXG4gICAgdGl0bGU6IFxcXCIyMDI0LzA2LzEyICBNYXhWZXJzaW9uIDI2XFxcIixcXG4gICAgcmVjb3JkczogW1xcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muWcqOaNoua6kOeVjOmdoueahOiPnOWNleWPr+S7peW8gOWQr+WIhuS6q+aXtuaYr+WQpuS9v+eUqOe8lueggeOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrlnKjpgInmupDnlYzpnaLliLfmlrDphY3nva7lkI7kvJrlkIzmraXmm7TmlrDmlbDph4/mmL7npLrjgIJcXFwiLFxcbiAgICBdXFxufSwge1xcbiAgICB0aXRsZTogXFxcIjIwMjQvMDYvMTAgIE1heFZlcnNpb24gMjVcXFwiLFxcbiAgICByZWNvcmRzOiBbXFxuICAgICAgICBcXFwi4oCY4oCYbmV34oCZ4oCZ77ya5aKe5Yqg5pu05paw5pel5b+X44CCXFxcIixcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrpgInmupDplb/mjInoj5zljZXvvIzlop7liqDot7PovaznvZHpobXvvIzmn6XnnIvmupDnoIHjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjee8lui+keino+aekOeVjOmdoua1i+ivlWpz6Kej5p6Q5LiA55u05aSx6LSl44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI1naXRodWLorqLpmIXvvIzkvJrliKDpmaTlhajpg6jop4TliJnmlofku7bjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeino+aekOiwg+eUqOWksei0peOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5pu05o2i6YWN572u5pe25rKh5pyJ5Y+K5pe25riF56m6ZHJweee8k+WtmOOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlLnorqLpmIXmm7TmlrDnrZbnlaXvvIzkvJrliKDpmaTmnKzlnLDlpLHmlYjmupDjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5pu05pawZHJweTIuanPjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5LyY5YyW6Kej5p6QZmxhZ+WMuemFjeOAglxcXCIsXFxuXFxuICAgIF1cXG59LCB7XFxuICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8wOSBNYXhWZXJzaW9uIDIwXFxcIixcXG4gICAgcmVjb3JkczogW1xcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muaUr+aMgXByb3h5X3J1bGXku6PnkIbjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeS6keebmOmTvuaOpeS4jeiwg+WPluS6keebmOeugOOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5ZOU5ZOp5b2x6KeG5LiN6IO95L2/55So6Kej5p6Q44CCXFxcIixcXG4gICAgXVxcbn1dO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiVDTpgILphY3lmahcIixcInBhdGhcIjpcIlQ0QWRhcHRlclwiLFwicnVsZVwiOlwiZnVuY3Rpb24gVD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AgICBleHRlbmQ6IHRoaXMuZXh0LFxcbiAgICAgICAgICAgIGV4dDogZXh0ZW5kID8gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KGV4dGVuZCkpIDogXFxcIlxcXCJcXG4gICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgcmVkaXJlY3Q6IHRoaXMucmVkaXJlY3RcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBkZXRhaWwodm9kX3VybCkge1xcbiAgICAgICAgcmV0dXJuIGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgYWM6IFxcXCJkZXRhaWxcXFwiLFxcbiAgICAgICAgICAgIGlkczogdm9kX3VybCxcXG4gICAgICAgICAgICBleHRlbmQ6IHRoaXMuZXh0LFxcbiAgICAgICAgfSksIHtcXG4gICAgICAgICAgICByZWRpcmVjdDogdGhpcy5yZWRpcmVjdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIHBsYXkoZmxhZywgaWQpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIC8vYWM6IFxcXCJkZXRhaWxcXFwiLFxcbiAgICAgICAgICAgIGZsYWc6IGZsYWcsXFxuICAgICAgICAgICAgcGxheTogaWRcXG4gICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgcmVkaXJlY3Q6IHRoaXMucmVkaXJlY3RcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBzZWFyY2god2QsIHF1aWNrLCBwZykge1xcbiAgICAgICAgcmV0dXJuIGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgd2Q6IHdkLFxcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICAgICAgcGc6IHBnXFxuICAgICAgICB9KSwge1xcbiAgICAgICAgICAgIHJlZGlyZWN0OiB0aGlzLnJlZGlyZWN0XFx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ShkYXRhLmxpc3QpIHx8ICFkYXRhLmxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgZGVsZXRlIHRoaXMucnVsZS7mjqjojZA7XFxuICAgICAgICAgICAgZGF0YS5saXN0ID0gW107XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIGdldEhvbWVEYXRhKCkge1xcbiAgICAgICAgaWYgKHRoaXMuY2FjaGVDbGFzcykgcmV0dXJuIHRoaXMuY2FjaGVDbGFzcztcXG4gICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwiY2xhc3NcXFwiXFxuICAgICAgICB9KSkucmVwbGFjZSgvXFxcXDwuKj94bWwuKj9cXFxcPi8sIFxcXCJcXFwiKTtcXG4gICAgICAgIGxldCBob21lID0ge1xcbiAgICAgICAgICAgIGxpc3Q6IFtdLFxcbiAgICAgICAgICAgIGNsYXNzOiBbXVxcbiAgICAgICAgfTtcXG4gICAgICAgIGxldCBob21lWG1sID0gbmV3IFhNTCh4bWwpO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgaG9tZS5saXN0LnB1c2goe1xcbiAgICAgICAgICAgICAgICB2b2RfaWQ6IGl0ZW0uaWQudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX25hbWU6IGl0ZW0ubmFtZS50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfdGltZTogaXRlbS5sYXN0LnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHR5cGVfaWQ6IGl0ZW0udGlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9yZW1hcmtzOiBpdGVtLm5vdGUudG9TdHJpbmcoKVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0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FxuICAgICAgICB9KSkucmVwbGFjZSgvXFxcXDwuKj94bWwuKj9cXFxcPi8sIFxcXCJcXFwiKTtcXG4gICAgICAgIGxldCBob21lWG1sID0gbmV3IFhNTCh4bWwpO1xcbiAgICAgICAgbGV0IGxpc3QgPSBbXTtcXG4gICAgICAgIGZvciBlYWNoKGxldCBpdGVtIGluIGhvbWVYbWwubGlzdC52aWRlbykge1xcbiAgICAgICAgICAgIGxpc3QucHVzaCh7XFxuICAgICAgICAgICAgICAgIHZvZF9pZDogaXRlbS5pZC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfbmFtZTogaXRlbS5uYW1lLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF90aW1lOiBpdGVtLmxhc3QudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3BpYzogaXRlbS5waWMudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGl0ZW0ubm90ZS50b1N0cmluZygpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3RcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBkZXRhaWwodm9kX3VybCkge1xcbiAgICAgICAgbGV0IHhtbCA9IGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgYWM6IFxcXCJkZXRhaWxcXFwiLFxcbiAgICAgICAgICAgIGlkczogdm9kX3VybCxcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBsZXQgbGlzdCA9IFtdO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgbGV0IHJlc2l0ZW0gPSB7XFxuICAgICAgICAgICAgICAgIHZvZF9pZDogaXRlbS5pZC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfbmFtZTogaXRlbS5uYW1lLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF90aW1lOiBpdGVtLmxhc3QudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3BpYzogaXRlbS5waWMudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGl0ZW0ubm90ZS50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfY29udGVudDogaXRlbS5kZXMudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX2FjdG9yOiBpdGVtLmFjdG9yLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9kaXJlY3RvcjogaXRlbS5kaXJlY3Rvci50b1N0cmluZygpLFxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgbGV0IGZyb20gPSBbXTtcXG4gICAgICAgICAgICBsZXQgcGxheSA9IFtdO1xcbiAgICAgICAgICAgIGZvciBlYWNoKGxldCBwbGF5TGlzdEl0ZW0gaW4gaXRlbS5kbC5kZCkge1xcbiAgICAgICAgICAgICAgICBmcm9tLnB1c2gocGxheUxpc3RJdGVtLkBmbGFnKTtcXG4gICAgICAgICAgICAgICAgcGxheS5wdXNoKHBsYXlMaXN0SXRlbS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmVzaXRlbS52b2RfcGxheV9mcm9tID0gZnJvbS5qb2luKFxcXCIkJCRcXFwiKTtcXG4gICAgICAgICAgICByZXNpdGVtLnZvZF9wbGF5X3VybCA9IHBsYXkuam9pbihcXFwiJCQkXFxcIik7XFxuICAgICAgICAgICAgbGlzdC5wdXNoKHJlc2l0ZW0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICBsaXN0XFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgcGxheShmbGFnLCBpbnB1dCkge1xcbiAgICAgICAgbGV0IHBhcnNlX3VybCA9IHRoaXMuc291cmNlLnBsYXl1cmwgfHwgXFxcIlxcXCI7XFxuICAgICAgICBpZiAoL1xcXFwuKG0zdTh8bXA0KS8udGVzdChpbnB1dCkpIHtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBwYXJzZTogMCxcXG4gICAgICAgICAgICAgICAgdXJsOiBpbnB1dFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpZiAocGFyc2VfdXJsLnN0YXJ0c1dpdGgoJ2pzb246JykpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHB1cmwgPSBwYXJzZV91cmwucmVwbGFjZSgnanNvbjonLCAnJykgKyBpbnB1dDtcXG4gICAgICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHB1cmwpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJzZTogMCxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IEpTT04ucGFyc2UoaHRtbCkudXJsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJzZTogMSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZTogMSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogcGFyc2VfdXJsICsgaW5wdXRcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICBzZWFyY2god2QsIHF1aWNrLCBwZykge1xcbiAgICAgICAgbGV0IHhtbCA9IGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgd2Q6IHdkLFxcbiAgICAgICAgICAgIHBnOiBcXFwiXFxcIiArIHBnXFxuICAgICAgICB9KSkucmVwbGFjZSgvXFxcXDwuKj94bWwuKj9cXFxcPi8sIFxcXCJcXFwiKTtcXG4gICAgICAgIGxldCBob21lWG1sID0gbmV3IFhNTCh4bWwpO1xcbiAgICAgICAgbGV0IGxpc3QgPSBbXTtcXG4gICAgICAgIGZvciBlYWNoKGxldCBpdGVtIGluIGhvbWVYbWwubGlzdC52aWRlbykge1xcbiAgICAgICAgICAgIGxpc3QucHVzaCh7XFxuICAgICAgICAgICAgICAgIHZvZF9pZDogaXRlbS5pZC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfbmFtZTogaXRlbS5uYW1lLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF90aW1lOiBpdGVtLmxhc3QudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3BpYzogaXRlbS5waWMudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGl0ZW0ubm90ZS50b1N0cmluZygpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3RcXG4gIC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mV0dXJuIGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgYWM6IFxcXCJ2aWRlb2xpc3RcXFwiLFxcbiAgICAgICAgICAgIHQ6IHRpZCxcXG4gICAgICAgICAgICBwZzogXFxcIlxcXCIgKyBwZ1xcbiAgICAgICAgfSkpO1xcbiAgICB9LFxcbiAgICBkZXRhaWwodm9kX3VybCkge1xcbiAgICAgICAgcmV0dXJuIGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgYWM6IFxcXCJkZXRhaWxcXFwiLFxcbiAgICAgICAgICAgIGlkczogdm9kX3VybCxcXG4gICAgICAgIH0pKTtcXG4gICAgfSxcXG4gICAgcGxheShmbGFnLCBpbnB1dCkge1xcbiAgICAgICAgbGV0IHBhcnNlX3VybCA9IHRoaXMuc291cmNlLnBsYXl1cmwgfHwgXFxcIlxcXCI7XFxuICAgICAgICBpZiAoL1xcXFwuKG0zdTh8bXA0KS8udGVzdChpbnB1dCkpIHtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBwYXJzZTogMCxcXG4gICAgICAgICAgICAgICAgdXJsOiBpbnB1dFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpZiAocGFyc2VfdXJsLnN0YXJ0c1dpdGgoJ2pzb246JykpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHB1cmwgPSBwYXJzZV91cmwucmVwbGFjZSgnanNvbjonLCAnJykgKyBpbnB1dDtcXG4gICAgICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHB1cmwpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJzZTogMCxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IEpTT04ucGFyc2UoaHRtbCkudXJsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJzZTogMSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZTogMSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogcGFyc2VfdXJsICsgaW5wdXRcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICBzZWFyY2god2QsIHF1aWNrLCBwZykge1xcbiAgICAgICAgcmV0dXJuIGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgd2Q6IHdkLFxcbiAgICAgICAgICAgIHBnOiBcXFwiXFxcIiArIHBnXFxuICAgICAgICB9KSk7XFxuICAgIH0sXFxuICAgIGdldFJ1bGUoa2V5KSB7XFxuICAgICAgICByZXR1cm4ga2V5ID8gdGhpcy5ydWxlW2tleV0gOiB0aGlzLnJ1bGU7XFxuICAgIH0sXFxuICAgIHJ1bk1haW4oKSB7XFxuICAgICAgICByZXR1cm4gXFxcIlxcXCI7XFxuICAgIH1cXG59KTtcXG4kLmV4cG9ydHMgPSBUMUFkYXB0ZXI7XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLkuoznuqfmlrnms5VcIixcInBhdGhcIjpcIm1ldGhvZHNfZXJcIixcInJ1bGVcIjpcIm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FxcXCLlr7zlhaVcXFwiKSB7XFxuICAgICAgICByZXR1cm4gJChcXFwie3tjbGlwYm9hcmR9fVxcXCIsIFxcXCLor7fovpPlhaXkuLvpophqc29uXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBqc29uID0gJC5fdGhlbWUuZ2V0KCk7XFxuICAgICAgICAgICAgbGV0IG9iaiA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgIGxldCBzdWNjZXNzID0gZmFsc2U7XFxuICAgICAgICAgICAgT2JqZWN0LmVudHJpZXMob2JqKS5mb3JFYWNoKChbaywgdl0pID0+IHtcXG4gICAgICAgICAgICAgIGlmICghanNvbi5oYXNPd25Qcm9wZXJ0eShrKSkge1xcbiAgICAgICAgICAgICAgICAkLl90aGVtZS5zZXQoaywgdik7XFxuICAgICAgICAgICAgICAgIHN1Y2Nlc3MgPSB0cnVlO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcImtleTpcXFwiICsgayArIFxcXCIg5bey57uP5a2Y5ZyoLOi3s+i/h1xcXCIpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgaWYgKHN1Y2Nlc3MpIHtcXG4gICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5a+85YWl5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5qC85byP6ZSZ6K+vXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICB9XFxuICAgICAgaWYgKHggPT0gXFxcIuaUueWQjVxcXCIpIHtcXG4gICAgICAgIGlmICgvXijpu5jorqR85b2T5YmNKSQvLnRlc3QobmspKSB7XFxuICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3og73mlLnlkI1cXFwiO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgcmV0dXJuICQoXFxcIuaWsOWQjeensFxcXCIpLmlucHV0KChrKSA9PiB7XFxuICAgICAgICAgICAgbGV0IG9iaiA9ICQuX3RoZW1lLmdldCgpO1xcbiAgICAgICAgICAgIGxldCBuZXdPYmogPSBPYmplY3Qua2V5cyhvYmopLnJlZHVjZSgoYWNjLCBrZXkpID0+IHtcXG4gICAgICAgICAgICAgIGlmIChrZXkgPT09IGspIHtcXG4gICAgICAgICAgICAgICAgYWNjW2lucHV0XSA9IG9ialtrZXldO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgYWNjW2tleV0gPSBvYmpba2V5XTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIHJldHVybiBhY2M7XFxuICAgICAgICAgICAgfSwge30pO1xcbiAgICAgICAgICAgICQuX3RoZW1lLnNhdmUoSlNPTi5zdHJpbmdpZnkobmV3T2JqKSk7XFxuICAgICAgICAgICAgcHV0TXlWYXIoJC5teV91cmwgKyBcXFwiblxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICB9LCBuaylcXG4gICAgICAgIH1cXG4gICAgICB9XFxuICAgICAgaWYgKHggPT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgIGlmICgvXijpu5jorqR85b2T5YmNKSQvLnRlc3QobmspKSB7XFxuICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3og73liKDpmaRcXFwiO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpFxcXCIpLmNvbmZpcm0oKGspID0+IHtcXG4gICAgICAgICAgICAvKipcXG4gICAgICAgICAgICAgKiDojrflj5blr7nosaHkuK3nu5nlrprplK7nmoTliY3kuIDkuKrmiJblkI7kuIDkuKrplK7jgIJcXG5cXG4gICAgICAgICAgICAgKiDmraTlh73mlbDnlKjkuo7pgY3ljoblr7nosaHnmoTplK7vvIzmoLnmja7nu5nlrprnmoTplK7mib7liLDlhbbliY3kuIDkuKrmiJblkI7kuIDkuKrplK7jgIJcXG4gICAgICAgICAgICAgKiDlpoLmnpznu5nlrprnmoTplK7kuI3lrZjlnKjkuo7lr7nosaHkuK3vvIzlh73mlbDlsIblsJ3or5Xmib7liLDlpKfkuo7nu5nlrprplK7nmoTnrKzkuIDkuKrplK7jgIJcXG4gICAgICAgICAgICAgKiDlpoLmnpzlr7nosaHkuK3msqHmnInlpKfkuo7nu5nlrprplK7nmoTplK7vvIzliJnov5Tlm57lr7nosaHnmoTmnIDlkI7kuIDkuKrplK7jgIJcXG4gICAgICAgICAgICAgKiBcXG4gICAgICAgICAgICAgKiBAcGFyYW0ge09iamVjdH0gb2JqIOimgemBjeWOhueahOWvueixoeOAglxcbiAgICAgICAgICAgICAqIEBwYXJhbSB7c3RyaW5nfSBrZXkg6KaB5p+l5om+5YmN5LiA5Liq5oiW5ZCO5LiA5Liq6ZSu55qE6ZSu44CCXFxuICAgICAgICAgICAgICogQHJldHVybnMge3N0cmluZ30g6L+U5Zue5om+5Yiw55qE5YmN5LiA5Liq5oiW5ZCO5LiA5Liq6ZSu44CCXFxuICAgICAgICAgICAgICovXFxuICAgICAgICAgICAgZnVuY3Rpb24gZ2V0UHJldmlvdXNPck5leHRLZXkob2JqLCBrZXkpIHtcXG4gICAgICAgICAgICAgIGNvbnN0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xcbiAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSBrZXlzLmluZGV4T2Yoa2V5KTtcXG4gICAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIC8vIOWmguaenOmUruWtmOWcqO+8jOi/lOWbnuWJjeS4gOS4qumUrlxcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5kZXggPiAwID8ga2V5c1tpbmRleCAtIDFdIDoga2V5c1tpbmRleCArIDFdOyAvLyDlpoLmnpzmmK/nrKzkuIDkuKrplK7vvIzov5Tlm57kuIvkuIDkuKrplK5cXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIC8vIOWmguaenOmUruS4jeWtmOWcqO+8jOi/lOWbnuS4i+S4gOS4qumUrlxcbiAgICAgICAgICAgICAgICBjb25zdCBuZXh0SW5kZXggPSBrZXlzLmZpbmRJbmRleChrID0+IGsgPiBrZXkpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gbmV4dEluZGV4ID4gLTEgPyBrZXlzW25leHRJbmRleF0gOiBrZXlzW2tleXMubGVuZ3RoIC0gMV07IC8vIOWmguaenOayoeacieS4i+S4gOS4qumUru+8jOi/lOWbnuacgOWQjuS4gOS4qumUrlxcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBsZXQgb2JqID0gJC5fdGhlbWUuZ2V0KCk7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBnZXRQcmV2aW91c09yTmV4dEtleShvYmosIGspO1xcbiAgICAgICAgICAgIGRlbGV0ZSBvYmpba107XFxuICAgICAgICAgICAgJC5fdGhlbWUuc2F2ZShKU09OLnN0cmluZ2lmeShvYmopKTtcXG5cXG4gICAgICAgICAgICBwdXRNeVZhcigkLm15X3VybCArIFxcXCJuXFxcIiwgbmFtZSk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgfSwgbmspXFxuICAgICAgICB9XFxuICAgICAgfVxcbiAgICB9LCB4LCBuaywgaXRlbSlcXG4gIH0pXFxufSlcXG5kLnB1c2goe1xcbiAgY29sX3R5cGU6IFxcXCJiaWdfYmxhbmtfYmxvY2tcXFwiXFxufSlcXG5cXG5PYmplY3Qua2V5cyhqc29uKS5mb3JFYWNoKChrLCBpKSA9PiB7XFxuICBsZXQgbG9uZ2NsaWNrcyA9IFtdO1xcbiAgaWYgKCEvXijpu5jorqR85b2T5YmNKSQvLnRlc3QoaykpIHtcXG4gICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuaUueWQjVxcXCIsXFxuICAgICAganM6ICQudG9TdHJpbmcoKGspID0+IHtcXG4gICAgICAgIHJldHVybiAkKFxcXCLmlrDlkI3np7BcXFwiKS5pbnB1dCgoaykgPT4ge1xcbiAgICAgICAgICBsZXQgb2JqID0gJC5fdGhlbWUuZ2V0KCk7XFxuICAgICAgICAgIGxldCBuZXdPYmogPSBPYmplY3Qua2V5cyhvYmopLnJlZHVjZSgoYWNjLCBrZXkpID0+IHtcXG4gICAgICAgICAgICBpZiAoa2V5ID09PSBrKSB7XFxuICAgICAgICAgICAgICBhY2NbaW5wdXRdID0gb2JqW2tleV07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIGFjY1trZXldID0gb2JqW2tleV07XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBhY2M7XFxuICAgICAgICAgIH0sIHt9KTtcXG4gICAgICAgICAgJC5fdGhlbWUuc2F2ZShKU09OLnN0cmluZ2lmeShuZXdPYmopKTtcXG4gICAgICAgICAgcHV0TXlWYXIoJC5teV91cmwgKyBcXFwiblxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIH0sIGspXFxuICAgICAgfSwgaylcXG4gICAgfSlcXG4gIH1cXG4gIGQucHVzaCh7XFxuICAgIHRpdGxlOiBuayA9PSBrID8gJ+KAnOKAnOKAneKAnScgKyBrLmZvbnRjb2xvcihcXFwicmVkXFxcIikgOi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