Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IkRycHlIaWtlciIsImF1dGhvciI6IkBMb3lEZ0lrJnpldGFscGhhIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6NDAsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoidmlkZW8iLCJjbGFzc191cmwiOiIiLCJhcmVhX25hbWUiOiIiLCJhcmVhX3VybCI6IiIsInNvcnRfbmFtZSI6IiIsInllYXJfbmFtZSI6IiIsInNvcnRfdXJsIjoiIiwieWVhcl91cmwiOiIiLCJmaW5kX3J1bGUiOiJqczokLnJlcXVpcmUoXCJNaWFuTG9hZFwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zPSoqJnBhZ2U9ZnlwYWdlIiwiZ3JvdXAiOiLikaDmjqjojZAiLCJzZWFyY2hGaW5kIjoianM6XG4oZnVuY3Rpb24gKCkge1xuICBsZXQgc21vZGUgPSBOdW1iZXIoZ2V0SXRlbShcInNtb2RlXCIsIFwiMFwiKSk7XG4gIGxldCB0ZW1zbW9kZSA9IGdldE15VmFyKFwidGVtc21vZGVcIiwgXCJcIik7XG4gIGlmICh0ZW1zbW9kZSkge1xuICAgIHNtb2RlID0gTnVtYmVyKHRlbXNtb2RlKTtcbiAgICBjbGVhck15VmFyKFwidGVtc21vZGVcIik7XG4gIH1cbiAgaWYgKCFmaWxlRXhpc3QoXCJoaWtlcjovL2ZpbGVzL2RhdGEvXCIgKyBNWV9SVUxFLnRpdGxlICsgXCIvbGlic19oaWtlci9kcnB5Mi5qc1wiKSkgcmV0dXJuIHNldFJlc3VsdChbe1xuICAgIHRpdGxlOiBcIuivt+WJjeW+g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YXJjaFNvdXJjZShzbW9kZT09PTIpO1xuXG4gICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG5cbiAgICAgICAgICAgIGxldCBsaXN0aSA9IGxpc3QuZmluZEluZGV4KHggPT4geC5rZXkgPT0gc291cmNlLmtleSk7XG5cbiAgICAgICAgICAgIGlmIChzb3VyY2Uuc2VhcmNoYWJsZSAmJiBsaXN0aSAhPSAtMSkge1xuICAgICAgICAgICAgICBsaXN0LnNwbGljZShsaXN0LmluZGV4T2Yoc291cmNlKSwgMSk7XG4gICAgICAgICAgICAgIGxpc3QudW5zaGlmdChzb3VyY2UpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IHNlYXJjaHNvcnQgPSBOdW1iZXIoZ2V0SXRlbShcInNlYXJjaHNvcnRcIiwgXCIwXCIpKTtcbiAgICAgICAgICAgIGxldCB7XG4gICAgICAgICAgICAgIG5hdHVyYWxTb3J0LFxuICAgICAgICAgICAgICB1c2luZ1NvcnRcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXCJtZXRob2RzXCIpO1xuXG4gICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA+IDApIHtcbiAgICAgICAgICAgICAgaWYgKHNlYXJjaHNvcnQgPT0gMSkge1xuICAgICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QsIFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChzZWFyY2hzb3J0ID09IDIpIHtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuc2V0a2V5KFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHJ1bGVzID0gW107XG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XG4gICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xuICAgICAgICAgICAgICAgIHRpdGxlOiBpdC5uYW1lLFxuICAgICAgICAgICAgICAgIHNlYXJjaF91cmw6IFwiaGlrZXI6Ly9lbXB0eT9wYWdlPWZ5cGFnZSZzZWFyY2hUZXJtcz0qKlwiLFxuICAgICAgICAgICAgICAgIHNlYXJjaEZpbmQ6IFwianM6XCIgKyAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIikuZ2V0KGl0ZW0ua2V5KTtcblxuICAgICAgICAgICAgICAgICAgbGV0IGhvbWVMaXN0ID0gSlNPTi5wYXJzZShkcnB5LnNlYXJjaChNWV9LRVlXT1JELCBmYWxzZSwgTVlfUEFHRSkpLmxpc3QgfHwgW107XG4gICAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xuICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaG9tZUxpc3QpIHtcbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXG4gICAgICAgICAgICAgICAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vcGFnZS9kZXRhaWxlZCNpbW1lcnNpdmVUaGVtZSNcIixcbiAgICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcIm1vdmllXzNcIixcbiAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdm9kSWQ6IFN0cmluZyhpdC52b2RfaWQpLFxuICAgICAgICAgICAgICAgICAgICAgICAgaXNQb2x5bWVyaXplOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICAgICAgc25hbWU6IGl0ZW0ubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNrZXk6IGl0ZW0ua2V5LFxuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICBzZXRSZXN1bHQoZCk7XG4gICAgICAgICAgICAgICAgfSwgaXQpXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHJ1bGVzKTtcbiAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pXG4gICAgICB9XG4gICAgfV0pO1xuICB9XG59KSgpIiwiZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsImRldGFpbF9maW5kX3J1bGUiOiIiLCJzZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsInNkZXRhaWxfZmluZF9ydWxlIjoiIiwidWEiOiJtb2JpbGUiLCJwcmVSdWxlIjoiLyo8JD5cbkBpbmNsdWRlIHN0YXJ0XG5odHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTE2JmF1dGg9MWQzNWU4ZjAtMjJlOC01MjcwLWE5ZDEtODI2ZjUzZjE3N2FkXG5AaW5jbHVkZSBlbmRcbjwkPiovXG4iLCJwYWdlcyI6Ilt7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiZHJweVwiLFwicGF0aFwiOlwiZHJweVwiLFwicnVsZVwiOlwiY29uc3Qgc2tleSA9IG1vZHVsZS5pbXBvcnRQYXJhbTtcXG5cXG5m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IH1cXG4gICAgZXZhbChnZXRDcnlwdG9KUygpKTtcXG4gICAgZ2xvYmFsVGhpcy5DcnlwdG9KUyA9IENyeXB0b0pTO1xcblxcbiAgICBsZXQgJHJlcXVlc3QgPSByZXF1ZXN0O1xcbiAgICBsZXQgJHBvc3QgPSBwb3N0O1xcbiAgICBnbG9iYWxUaGlzLnJlcSA9IGZ1bmN0aW9uKHVybCwgY29iaikge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcmVzID0ge307XFxuICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIGNvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmouZGF0YSkge1xcbiAgICAgICAgICAgICAgICBvYmouYm9keSA9IG9iai5kYXRhO1xcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqLmRhdGE7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoXFxcInJlZGlyZWN0XFxcIikpIG9iai5yZWRpcmVjdCA9ICEhb2JqLnJlZGlyZWN0O1xcbiAgICAgICAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICAgICAgICAgIG9iai50b0hleCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iai5oZWFkZXJzID0gT2JqZWN0LmFzc2lnbih7XFxuICAgICAgICAgICAgICAgIENvb2tpZTogXFxcIiNub0Nvb2tpZSNcXFwiXFxuICAgICAgICAgICAgfSwgb2JqLmhlYWRlcnMpO1xcbiAgICAgICAgICAgIGlmICh1cmwgPT09IFxcXCJodHRwczovL2FwaS5ubi5jaS9vY3IvYjY0L3RleHRcXFwiICYmIG9iai5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW1xcXCJDb250ZW50LVR5cGVcXFwiXSA9IFxcXCJ0ZXh0L3BsYWluXFxcIjtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKHVybC5zdGFydHNXaXRoKFxcXCJmaWxlOi8vXFxcIikgJiYgKHVybC5pbmNsdWRlcyhcXFwiP3R5cGU9XFxcIikgfHwgdXJsLmluY2x1ZGVzKFxcXCI/cGFyYW1zPVxcXCIpKSkge1xcbiAgICAgICAgICAgICAgICB1cmwgPSB1cmwuc2xpY2UoMCwgdXJsLmxhc3RJbmRleE9mKFxcXCI/XFxcIikpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBmb3IgKGxldCBrZXkgaW4gb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBvYmouaGVhZGVyc1trZXldICE9PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNba2V5XSA9IFN0cmluZyhvYmouaGVhZGVyc1trZXldKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgciA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIC8qIGlmIChTdHJpbmcob2JqLm1ldGhvZCkudG9Mb3dlckNhc2UoKSA9PT0gXFxcInBvc3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICBpZiAob2JqLndpdGhIZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHIuYm9keTtcXG4gICAgICAgICAgICAgICAgcmVzLmhlYWRlcnMgPSB7fTtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzW2tdID0gdlswXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VIZXgocmVzLmNvbnRlbnQpLnRvQmFzZTY0KF9iYXNlNjQuTk9fV1JBUCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKFxcXCJFcnJvclxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIC8qXFxuICAgIGNvbnN0IEppbkphID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2Nkbi5ib290Y2RuLm5ldC9hamF4L2xpYnMvbXVzdGFjaGUuanMvNC4xLjAvbXVzdGFjaGUuanNcXFwiKTtcXG4gIFxcbiAgICBjb25zdCBKUCA9ICQucmVxdWlyZShcXFwiaHR0cHM6Ly9qc29ucGF0aC1wbHVzLmdpdGh1Yi5pby9KU09OUGF0aC9kaXN0L2luZGV4LWJyb3dzZXItdW1kLmNqc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmNoZWVyaW8gPSB7XFxuICAgICAgICBqaW5qYTIodGVtcGxhdGUsIG9iaikge1xcbiAgICAgICAgICAgIFxcbiAgICAgICAgICAgIHJldHVybiAkLmxvZyhKaW5KYS5yZW5kZXIodGVtcGxhdGUsIG9iaikpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGpwKHBhdGgsIGp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IT0gLTEpIHtcXG4gICAgICAgIHJldHVybiBqc29uW2luZGV4XS5wYWdlO1xcbiAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgbWF4Y291bnQgPSBlci7ljoblj7LorrDlvZU7XFxuICAgIGlmIChtb2RlID09IFxcXCJzZXRcXFwiKSB7XFxuICAgICAgaWYgKGpzb24ubGVuZ3RoID49IG1heGNvdW50KSB7XFxuICAgICAgICBqc29uID0ganNvbi5zbGljZSgwLCBtYXhjb3VudCAtIDEpO1xcbiAgICAgIH1cXG4gICAgICBsZXQgaW5kZXggPSBqc29uLmZpbmRJbmRleChvYmogPT4gb2JqLnNrZXkgPT09IHNrZXkgJiYgb2JqLmlkID09PSBpZCk7XFxuICAgICAgaWYgKGluZGV4ICE9IC0xKSB7XFxuICAgICAgICBpZiAoanNvbltpbmRleF0ucGFnZSAhPSB2YWx1ZS5wYWdlKSB7XFxuICAgICAgICAgIGpzb25baW5kZXhdLnBhZ2UgPSB2YWx1ZS5wYWdlO1xcbiAgICAgICAgICBzYXZlRmlsZShuYW1lLCBKU09OLnN0cmluZ2lmeShqc29uKSwgMCk7XFxuICAgICAgICB9O1xcbiAgICAgIH0gZWxzZSB7XFxuICAgICAgICBqc29uLnB1c2goe1xcbiAgICAgICAgICBza2V5OiBza2V5LFxcbiAgICAgICAgICBpZDogaWQsXFxuICAgICAgICAgIHRpdGxlOiB2YWx1ZS50aXRsZSxcXG4gICAgICAgICAgcGFnZTogdmFsdWUucGFnZSxcXG4gICAgICAgIH0pXFxuICAgICAgICBzYXZlRmlsZShuYW1lLCBKU09OLnN0cmluZ2lmeShqc29uKSwgMCk7XFxuICAgICAgfVxcbiAgICB9XFxuICB9XFxuXFxuICAvL+aWueazlVxcbiAgZnVuY3Rpb24gZm9udHN0eWxlKHRleHQsIHBhcmFtcykge1xcbiAgICBwYXJhbXMgPSBwYXJhbXMgfHwgdW5kZWZpbmVkO1xcbiAgICB2YXIgaCA9IHBhcmFtcy5oICE9PSBmYWxzZSA/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KSA9PiB7XFxuICAgICAgICBsZXQgayA9IGouc3BsaXQoXFxcIiRcXFwiKTtcXG4gICAgICAgIGxldCB0ID0ga1swXTtcXG4gICAgICAgIGxldCB1aWQgPSAoa1sxXSB8fCBrWzBdKTtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHN0aXRsZTogdCxcXG4gICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxuICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICB9KSxcXG4gICAgICAgICAgc3VybDogdWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSxcXG4gICAgICAgICAgdXJsOiBpc05vdmVsID8gXFxcImhpa2VyOi8vcGFnZS9ub3ZlbCNhdXRvUGFnZSMjcmVhZFRoZW1lI1xcXCIgOiAodWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5KSxcXG4gICAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxuICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9KSovXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgZnJvbTogZnJvbVtpXSxcXG4gICAgICAgICAgICBzb3VyY2U6IHNvdXJjZSxcXG4gICAgICAgICAgICBpZDogdWlkLFxcbiAgICAgICAgICAgIGJsb2NrUnVsZXM6IFsnYmIuKi5wbmcnLCAnLmpwZycsIFxcXCJobV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AgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGNoYXB0ZXJMaXN0OiBcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvZHJfZG93X2xpc3QuanNvblxcXCIsXFxuICAgICAgICAgICAgaW5mbzoge1xcbiAgICAgICAgICAgICAgYm9va05hbWU6IGluZm8udm9kX25hbWUsIC8v5ryr55S75ZCN56ewLFxcbiAgICAgICAgICAgICAgcnVsZU5hbWU6IE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgICAgICBib29rVG9wUGljOiBpbmZvLnZvZF9waWMsXFxuICAgICAgICAgICAgICBwYXJzZUNvZGU6IGRvd25sb2FkbGF6eSxcXG4gICAgICAgICAgICAgIGJvb2tJZDogTVlfUEFSQU1TLnNuYW1lLFxcbiAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkZWZhdWx0VmlldzogXFxcIjFcXFwiXFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLmnKzlnLDkuabmnrZcXFwiLFxcbiAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvQm9va3JhY2sudmlldyNub1JlY29yZEhpc3RvcnkjP3J1bGU95pys5Zyw6LWE5rqQ566h55CGJnJ1bGVOYW1lPScgKyBNWV9SVUxFLnRpdGxlLFxcbiAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHR5cGU6IHN0eXBlID09PSBcXFwi5ryr55S7XFxcIiA/IFxcXCJjb21pY1xcXCIgOiBcXFwibm92ZWxcXFwiLFxcbiAgICAgICAgICB9XFxuICAgICAgICB9LCB7XFxuICAgICAgICAgIGNvbF90eXB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ICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKE1ZX0lOREVYKSk7XFxuICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4geyB9KShsb2NhdGlvbik7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgIH0sIGxvY2F0aW9uKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgfVxcbiAgICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiAn5LiL5LiA6aG1JyxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgobG9jYXRpb24sIHBjb3VudCkgPT4ge1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgaWYgKHBhZ2VudW0gPj0gcGNvdW50IC0gMSkge1xcbiAgICAgICAgICAgIHBhZ2VudW0gPSAwO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHBhZ2VudW0rKztcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4geyB9KShsb2NhdGlvbik7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBsb2NhdGlvbiwgcGNvdW50KSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgfVxcbiAgICAgIH1dKVxcbiAgICAgIC8qcGxheXAgPSBwbGF5cC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgICBsZXQgb2JqID0gT2JqZWN0LmFzc2lnbih7fSwgdGVtcCwge1xcbiAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgKHBhZ2VudW0gPT0gaSA/IHguZm9udGNvbG9yKFxcXCJyZWRcXFwiKSA6IHgpLFxcbiAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChpKSA9PiB7XFxuICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwicGFnZW51bVxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgJC50ZW1wX2xpc3RbaV0pO1xcbiAgICAgICAgICAgICBmaW5kSXRlbXNCeUNscyhcXFwicGxheXBhZ2VcXFwiKS5mb3JFYWNoKCh4LCBpaSkgPT4ge1xcbiAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IHgudGl0bGUucmVwbGFjZSgv4oCYfOKAmXzigJx84oCdfDxbXj5dKz4vZywgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgIGlmIChpaSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICB0aXRsZSA9ICfigJzigJzigJ3igJ0nICsgdGl0bGUuZm9udGNvbG9yKFxcXCJyZWRcXFwiKTtcXG4gICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh4LmV4dHJhLmlkLCB7XFxuICAgICA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ID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG5cXG4gICAgICAgIHJldHVybiAkKFtcXFwiSElLRVJcXFwiLCBcXFwiVFhUXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSwgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgobW8sIGluZGV4cywgZXh0KSA9PiB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gdXAocnVsZXMpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGViNjQgPSBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkocnVsZXMpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobGVuZ3RoLCBydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG55WM77yMRFJQWeino+aekO+8jOWFseOAjFxcXCIgKyBsZW5ndGggKyBcXFwi44CN5p2h77yM5aSN5Yi25pW05p2h5Y+j5Luk5om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2kgPSBmbGFnaS5maWx0ZXIoeCA9PiAhLyjlhajpg6h85bey56aB55SoKS8udGVzdCh4KSk7XFxuICAgICAgICAgICAgICAgIGlmIChmbGFnaS5pbmNsdWRlcyhmKSkge1xcbiAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBmbGFnaS5maWx0ZXIoeCA9PiB4ICE9IGYpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZsYWdpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBbXFxcIuWFqOmDqFxcXCJdXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBmbGFnaS5wdXNoKGYpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImZsYWdpXFxcIiwgZmxhZ2kpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGYpXFxuICAgIH0pXFxufSlcXG5mb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgIGxldCBpdCA9IGFycltpXTtcXG5cXG4gICAgbGV0IGZsYWcgPSBpdC5mbGFnLnNwbGl0KFxcXCJ8XFxcIik7XFxuICAgIGlmIChmbGFnaS5sZW5ndGggPiAwICYmICFbXFxcIuWFqOmDqFxcXCIsIFxcXCLlt7LnpoHnlKhcXFwiXS5pbmNsdWRlcyhmbGFnaVswXSkpIHtcXG4gICAgICAgIGlmICghZmxhZ2kuZXZlcnkoZiA9PiBmbGFnLmluY2x1ZGVzKGYpKSkge1xcbiAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGlmIChbXFxcIuW3suem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pbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAk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AgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mraTpobnml6Dms5XliKDpmaRcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHVybEluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ato+WcqOabtOaWsOino+aekO+8jOWIoOmZpOivt+S7juino+aekOeuoeeQhui/m+WFpVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liKDpmaTmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIGluZGV4KVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgIH0sIGluZGV4LCB1cmxJbmRleCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIua1i+ivlVxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5Un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gPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgICAgICBqc1xcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXG4gICAgICAgIH0pO1xcbiAgICB9KSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5L+d5a2YXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgaXNJbXBvcnQpID0+IHtcXG4gICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcInBzX25hbWVcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCFuYW1lKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WQjeWtl+W+l+acieS4gOS4quWQp1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgdXJsID0gZ2V0TXlWYXIoXFxcInBzX3VybFxcXCIsIFxcXCJcXFwiKS50cm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pzb25QYXRoXFxcIiwgXFxcIlxcXCIpLnRyaW0oKSB8fCB2b2lkIDA7XFxuICAgICAgICBsZXQganMgPSBnZXRNeVZhcihcXFwicHNfanNcXFwiLCBcXFwiXFxcIikgfHwgdm9pZCAwO1xcbiAgICAgICAgaWYgKHJ1blR5cGUgPT09IFxcXCJKU09OXFxcIiAmJiAhanNvblBhdGgpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlNPTuaooeW8j+S4i+W/hemhu+Whq2pzb25QYXRoXFxcIjtcXG4gICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PT0gXFxcIkpTXFxcIiAmJiAhanMpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlPmqKHlvI/kuIvlv4Xpobvloatqc1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG9iajEgPSB7XFxuICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgIGpzXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcbiAgICAgICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBvYmoxKTtcXG4gICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBvYmoxKTtcXG4gICAgICAgIH1cXG4gICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgIC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1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG5ld0kgPSAwO1xcbiAgICAgICAgZm9yIChsZXQgcnVsZSBvZiBydWxlcykge1xcbiAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lm5hbWUgPT09IHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID4gLTEpIHtcXG4gICAgICAgICAgICAgICAgcnVsZSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFwiICsgaW5kZXggKyBcXFwiJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIuaWsOWinu+8mlxcXCIgKyBuZXdJICsgXFxcIiDopobnm5bmm7TmlrDvvJpcXFwiICsgKHJ1bGVzLmxlbmd0aCAtIG5ld0kpKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl5aSx6LSlXFxcIik7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gaW1wb3J0UnVsZShwYXNzKSB7XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgW18sIHJ1bGUsIHBuYW1lXSA9IHBhc3Muc3BsaXQoXFxcIiRcXFwiKTtcXG4gICAgICAgIGxldCBwYXRoID0gZ2V0UHVibGljSXRlbShcXFwiRHJweUhpa2VyQGlucHV0X3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TogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcImRycHlIaWtlcl9zdWJuYW1lX2lucHV0XFxcIiwgaW5wdXQpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBpZDogXFxcImRycHlIaWtlcl9zdWJuYW1lX2lucHV0XFxcIlxcbiAgICB9XFxufSk7XFxubGV0IHBhdGggPSBqb2luVXJsKGdldFBhdGgoXFxcImhpa2VyOi8vZmlsZXMvXFxcIiksIFxcXCIuLi9cXFwiLnJlcGVhdCg1KSkuc2xpY2UoNyk7XFxubGF5b3V0LnB1c2goe1xcbiAgICB0aXRsZTogXFxcIumAieaLqVxcXCIsXFxuICAgIHVybDogSlNPTi5zdHJpbmdpZnkoZi5maWxlU2VsZWN0aW9uVXJpKHtcXG4gICAgICAgIGNhbGxiYWNrOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBsZXQgdGFyZ2V0ID0gZmluZEl0ZW0oXFxcImRycHlIaWtlcl9zdWJfaW5wdXRcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJkcnB5SGlrZXJfc3ViX2lucHV0XFxcIiwge1xcbiAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih0YXJnZXQsIHtcXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSksXFxuICAgICAgICByb290RGlyUGF0aDogcGF0aCxcXG4gICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgcGF0dGVybjogMVxcbiAgICB9KSksXFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5YKo5a2Y6Lev5b6EXFxcIixcXG4gICAgZXh0cmE6IHtcX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gICAgICAgICAgJ25hbWUnOiBgJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAndHlwZSc6IDMsXFxuICAgICAgICAgICAgICAgICAgICAnYXBpJzogJy4uL2xpYnMvZHJweTIuanMnLFxcbiAgICAgICAgICAgICAgICAgICAgJ3NlYXJjaGFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdmaWx0ZXJhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdleHQnOiBcXFwiLi9cXFwiICsgaXQubmFtZSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGNvdW50Kys7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIFxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgbmFtZXMucHVzaChpdC5uYW1lKTtcXG4gICAgfVxcbiAgICBkZWxldGVsb3NlKG5hbWVzLCBwYXRoKVxcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgc2l0ZXM6IHJ1bGVzXFxuICAgIH0pKTtcXG5cXG4gICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aIkOWKn+abtOaWsFxcXCIgKyBjb3VudCArIFxcXCLkuKpcXFwiOztcXG59XFxuXFxuZnVuY3Rpb24gZGVsZXRlbG9zZShuYW1lcywgcGF0aCkge1xcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHBhdGhGaWxlID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG4gICAgICAgIGlmICghcGF0aEZpbGUuaXNEaXJlY3RvcnkoKSkgcmV0dXJuO1xcbiAgICAgICAgZm9yIChsZXQgZmlsZSBvZiBwYXRoRmlsZS5saXN0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gICAgICAgaWYgKFN0cmluZyhpdC5leHQpLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3QoaXQuZXh0KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpdC5leHQgPSBcXFwiLi9cXFwiICsgbmFtZTtcXG4gICAgICAgICAgICAgICAgaWYgKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgbmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIG5hbWVzLnB1c2gobmFtZSk7XFxuICAgICAgICAgICAgICAgIGNvdW50Kys7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaSsrO1xcbiAgICB9XFxuICAgIGRlbGV0ZWxvc2UobmFtZXMsIHBhdGgpO1xcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIGNvdW50ICsgXFxcIuS4qlxcXCI7XFxufVxcbiQuZXhwb3J0cy5w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GgpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImdpdGh1YkRpclxcXCI7XFxuICAgICAgICAgICAgLy9zb3VyY2VMaXN0PVtdO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhmZXRjaChjb25maWcucGF0aCkgfHwgXFxcInt9XFxcIikpO1xcbiAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCAhanNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLku47nvZHnu5zojrflj5bnmoTphY3nva7mlofku7bkuLrnqbrvvIzor7fmo4Dmn6XnvZHnu5xcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc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bWUgPSBuYW1lLnNsaWNlKDAsIG5hbWUubGFzdEluZGV4T2YoXFxcIi5cXFwiKSk7XFxuICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgJ25hbWUnOiBgJHtuYW1lfWAsXFxuICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXG4gICAgICAgICAgICAncXVpY2tTZWFyY2gnOiAxLFxcbiAgICAgICAgICAgICdmaWx0ZXJhYmxlJzogMSxcXG4gICAgICAgICAgICAnZXh0JzogYCR7cGF0aH1gLFxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgdHJ5IHtcXG4gICAgICAgIGxldCBtYXBwaW5nID0gZ2V0TG9hY2xNYXBwaW5nKFN0cmluZyhkaXJGaWxlLmdldFBhdGgoKSkpO1xcblxcbiAgICAgICAgaWYgKG1hcHBpbmcubGVuZ3RoKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbWFwcGluZykge1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBydWxlcy5maW5kSW5kZXgodiA9PiB2Lm5hbWUgPT09IGl0LmtleSk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IHJ1bGVzW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKGluZGV4LCAwLCBPYmplY3QuYXNzaWduKHt9LCBpdGVtLCB7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtpdC50b2tleX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBgJHtpdC50b2tleX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IGl0ZW0uZXh0ICsgXFxcIj9cXFwiICsgaXQucG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xcXFwiZnVuY3Rpb24gbWFpblxcXCIpK1xcXCJcXFxcbjttYWluO1xcXCIsIHtcXG4gICAgICAgIHBhdGhMaWI6IHtcXG4gICAgICAgICAgICBqb2luOiBqb2luVXJsLFxcbiAgICAgICAgICAgIHJlYWRGaWxlKHBhdGgpIHtcXG4gICAgICAgICAgICAgICAgcGF0aCA9IHBhdGguc3RhcnRzV2l0aChcXFwiZmlsZTovL1xcXCIpID8gcGF0aCA6IChcXFwiZmlsZTovL1xcXCIgKyBwYXRoKTtcXG4gICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgIHJldHVybiBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHJlYWREaXIocGF0aCkge1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGZpbGUgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsXFxcIlxcXCIpKTtcXG4gICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgIGlmKCEoZmlsZS5leGlzdHMoKSYmZmlsZS5pc0RpcmVjdG9yeSgpKSkgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgICAgICBmb3IobGV0IGl0IG9mIGZpbGUubGlzdEZpbGVzKCkpe1xcbiAgICAgICAgICAgICAgICAgICAgbmFtZXMucHVzaChTdHJpbmcoaXQuZ2V0TmFtZSgpKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZGlybmFtZShwYSl7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gam9pblVybChqc1BhdGgsIHBhKTtcXG4gICAgICAgICAgICAgICAgbGV0IG5hbWVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBmaWxlID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG4gICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgIGlmKCEoZmlsZS5leGlzdHMoKSYmZmlsZS5pc0RpcmVjdG9yeSgpKSkgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgICAgICBmb3IobGV0IGl0IG9mIGRpckZpbGUubGlzdEZpbGVzKCkpe1xcbiAgICAgICAgICAgICAgICAgICAgaWYoaXQuaXNEaXJlY3Rvcnkpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBwYXRocztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHN0YXQoKXtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICAgIGxvZzogbG9nLFxcbiAgICAgICAgcGF0aDoganNQYXRoLFxcbiAgICAgICAgcGF0aF9kaXI6IGpvaW5VcmwoanNQYXRoLCBcXFwiLi9cXFwiKVxcbiAgICB9KTtcXG4gICAgbGV0IGpzb25UZXh0PW1haW4oKTtcXG4gICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGpzb25UZXh0KTtcXG4gICAgXFxuICAgIGlmKEFycmF5LmlzQXJyYXkoanNvbikpe1xcbiAgICAgICAgcmV0dXJuIGZpbHRlck90aGVyKGpzb24pO1xcbiAgICB9ZWxzZSBpZihBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpJiZqc29uLnNpdGVzLmxlbmd0aCl7XFxuICAgICAgICB3cml0ZUZpbGUoam9pblVybChqc1BhdGgsIFxcXCIuL2luZGV4Lmpzb25cXFwiKSwganNvblRleHQpO1xcbiAgICAgICAgcmV0dXJuIGZpbHRlck90aGVyKGpzb24uc2l0ZXN8fFtdKTtcXG4gICAgfV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AgIGNvbnN0IGhpa2VyUG9wID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTY2XFxcIik7XFxuICAgICAgICBsZXQgcG9wID0gaGlrZXJQb3AuaW5mb0JvdHRvbSh7XFxuICAgICAgICAgICAgY29udGVudDogXFxcIuivpue7hlxcXCIsXFxuICAgICAgICAgICAgb3B0aW9uczogW1xcbiAgICAgICAgICAgICAgICBcXFwi56ys5LiA56m6KOWQjeensCk65pa55L6/5LiL5qyh5om+5YiwXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIuesrOS6jOepuijot6/lvoQpW+Whq+acrOWcsOe0ouW8leWcsOWdgF066YCJ5oupSlNPTi9VUkzpgInpobnvvIzngrnlh7vml4HovrnnmoTpgInmi6nlj6/ku6XmtY/op4jmnKzlnLDmlofku7bpgInmi6nmnKzlnLDljIXnmoQuanNvbue0ouW8leaWh+S7tuWNs+WPr+OAglxcXFxuKOazqOaEj++8muS9v+eUqOatpOenjeaWueW8j++8jOWcqOacrOWcsOaWh+S7tuWkueWGheaWsOWinuaIluWIoOmZpC5qc+a6kOaXtumcgOimgeiHquihjOmFjee9ri5qc29u5paH5Lu2KVxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzloavov5znqIvlnLDlnYBdOuebtOaOpeWhq+WGmei/nOeoi+mTvuaOpeWNs+WPr+S4gOiIrOaYr+S7pWh0dHDlvIDlpLQuanNvbue7k+Wwvu+8jOS5n+WPr+WPr+S7pei+k+WFpWdpdGh1YuS7k+W6k+eahOaWh+S7tuWkueWcsOWdgOOAguatpOenjeaWueW8j+WPr+S7peS/neaMgeS4jui/nOeoi+mFjee9ruiAheWQjOatpeabtOaWsO+8jOS9huS4jeWmguacrOWcsOW/q+OAglxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloav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lcXFwiO1xcbiAgICAgICAgfSwgaSksXFxuICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICB9KVxcbn0pXFxuXFxuXFxubGV0IHBhdGggPSBqb2luVXJsKGdldFBhdGgoXFxcImhpa2VyOi8vZmlsZXMvXFxcIiksIFxcXCIuLi9cXFwiLnJlcGVhdCg1KSkuc2xpY2UoNyk7XFxuXFxuaWYgKHNlbGVjdF9tb2RlID09IFxcXCIwXFxcIikge1xcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIumAieaLqVxcXCIsXFxuICAgICAgICB1cmw6IEpTT04uc3RyaW5naWZ5KGYuZmlsZVNlbGVjdGlvblVyaSh7XFxuICAgICAgICAgICAgY2FsbGJhY2s6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0ID0gZmluZEl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIpLmV4dHJhO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih0YXJnZXQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFBBVEhcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICByb290RGlyUGF0aDogcGF0aCxcXG4gICAgICAgICAgICBpbml0aWFsUGF0aDogcGF0aCxcXG4gICAgICAgICAgICBwYXR0ZXJuOiAwLFxcbiAgICAgICAgICAgIGZpbGVUeXBlOiBcXFwiLmpzb258LmpzXFxcIixcXG4gICAgICAgIH0pKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIui3r+W+hChVUkwvSlNPTi9KUy9HaXRodWIpXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgaWQ6IFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cXG5pZiAoc2VsZWN0X21vZGUgPT0gXFxcIjFcXFwiKSB7XFxuICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi6YCJ5oupXFxcIixcXG4gICAgICAgIHVybDogSlNPTi5zdHJpbmdpZnkoZi5maWxlU2VsZWN0aW9uVXJpKHtcXG4gICAgICAgICAgICBjYWxsYmFjazogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCB0YXJnZXQgPSBmaW5kSXRlbShcXFwiZHJweUhpa2VyX2NvbmZpZ19mb2xkZXJcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwiZHJweUhpa2VyX2NvbmZpZ19mb2xkZXJcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih0YXJnZXQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFBBVEhcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgIC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Pr+S4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBwYXRoID0gcGF0aC5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikgPyBwYXRoIDogcGF0aC5zdGFydHNXaXRoKFxcXCIvXFxcIikgPyAoXFxcImZpbGU6Ly9cXFwiICsgcGF0aCkgOiBwYXRoO1xcbiAgICAgICAgLy9sb2cocGF0aClcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICBpZiAocGF0aC5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOWKoOi9vemFjee9ri4uLlxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgY29uZmlnYyA9IHtcXG4gICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoY29uZmlnYykpIHtcXG4gICAgICAgICAgICAgICAgY29iai5jb25maWdzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcIm5vX2xvYWRpbmdcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2F2ZUZpbGUoY29iai5wYXRoLCBKU09OLnN0cmluZ2lmeShjb2JqLmNvbmZpZ3MpKTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgRHJweU1hbmFnZS5jbGVhcigpO1xcbiAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJDaGFuZ2VTb3VyY2VQb3BcXFwiKS5zaG93KDEwMCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6YWN572u5paH5Lu25pyJ6K+vXFxcIjtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgIH0gZmluYWxseSB7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgIH1cXG4gICAgfSwgY29uZmlnc19vYmopLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbn0pO1xcblxcbmlmIChwYXRoY29uZmlncy5sZW5ndGgpIHtcXG4gICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD7ljoblj7LphY3nva7orrDlvZUg54K55oiR6L+b6KGM6YWN572u5qOA6aqMPC9zbWFsbD5cXFwiLFxcbiAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChwKSA9PiB7XFxuICAgICAgICAgICAgLy9sb2cocClcXG4gICAgICAgICAgICBmdW5jdGlvbiB1bmlxdWUoYXJyKSB7XFxuICAgICAgICAgICAgICAgIGNvbnN0IHJlcyA9IG5ldyBNYXAoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFyci5maWx0ZXIoKGEpID0+ICFyZXMuaGFzKGEpICYmIHJlcy5zZXQoYSwgMSkpXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHZhciByZXN1bHRzID0gW107XFxuICAgICAgICAgICAgaWYgKHAubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aXoOWcsOWdgFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxpc3QgPSBwLm1hcCh4ID0+IHgucGF0aCk7XFxuICAgICAgICAgICAgdmFyIHRhc2sgPSBmdW5jdGlvbihvYmopIHtcXG4gICAgICAgICAgICAgICAgbGV0IHMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBsZXQganNGaWxlcyA9IFtdO1xcbiAgICAgICAgICAgICAgICBsZXQgY291bnQgPSAwO1xcblxcbiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaWx0ZXJPdGhlcihsaXN0KSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbGlzdC5maWx0ZXIoaXQgPT4gU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLm1pbi5qc1xcXCIpIHx8IFN0cmluZyhpdC5hcGkpLmluY2x1ZGVzKFxcXCJkcnB5Mi5qc1xcXCIpKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChvYmoudXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb2RlID0gXFxcIm5vXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gb2JqLnVybC5yZXBsYWNlKFxcXCJmaWxlOi8vXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRpciA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZGlyLmlzRGlyZWN0b3J5KCkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmxpc3QgPSBkaXIubGlzdEZpbGVzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgZiBvZiBmbGlzdCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDmo4Dmn6Xmlofku7blkI3mmK/lkKbku6UuanPnu5PlsL5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogb2JqLnVybCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZTogY29kZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmRleDogb2JqLmlcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICAgICAgICAgICAgd2l0aEhlYWRlcnM6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBlIC0gcztcXG4gICAgICAgICAgICAgICAgaWYgKG9iai51cmwuaW5jbHVkZXMoXFxcImdpdGh1Yi5jb21cXFwiKSAmJiBqLnN0YXR1c0NvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhqLmJvZHkpIHx8IFxcXCJ7fVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge31cXG5cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGoudXJsLFxcbiAgICAgICAgICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICAgICAgICAgICAgaW5kZXg6IG9iai5pLFxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICAgICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgdmFyIGNvdW50ID0gc3VjY2VzcyA9IHRhc2tzLmxlbmd0aDtcXG4gICAgICAgICAgICBiZSh0YXNrcywge1xcbiAgICAgICAgICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICAgICAgICAgICAgb2JqLnJlc3VsdHMucHVzaCh0YXNrUmVzdWx0KVxcbiAgICAgICAgICAgICAgICAgICAgY291bnQgPSBjb3VudCAtIDE7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICAgICAgICAgIGhpOiAnY2NjJyxcXG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdHM6IHJlc3VsdHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHN1Y2Nlc3MpO1xcbiAgICAgICAgICAgIC8vbG9nKHJlc3VsdHMpXFxuICAgICAgICAgICAgcmVzdWx0cyA9IHJlc3VsdHMuZmlsdGVyKGYgPT4gZik7XFxuICAgICAgICAgICAgcmVzdWx0cy5mb3JFYWNoKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICAgICAgICAgIGxldCByZWdleCA9IC8o5ZCN56ewOi4qPykoXFxcXHMrKT9cXFxcbi9nO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBcXFwi5ZCN56ewOlxcXCIgKyBwW3guaW5kZXhdLm5hbWUgKyBcXFwiIFxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCB1cmwgPSBwW3guaW5kZXhdLnBhdGg7XFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IGNvdW50ID0geC5jb3VudCAhPSAwID8gXFxcIiDmupDmlbDph486XFxcIiArIHguY291bnQgOiBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKC9uby8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBpdGVtLnRpdGxlLnJlcGxhY2UocmVnZXgsIHRpdGxlICsgXFxcIumFjee9ruacieivr1xcXCIuZm9udGNvbG9yKFxcXCJyZWRcXFwiKSArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKC9eKC0xfDB8NDA0KS8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBpdGVtLnRpdGxlLnJlcGxhY2UocmVnZXgsIHRpdGxlICsgXFxcIuaXoOazleiuv+mXrlxcXCIuZm9udGNvbG9yKFxcXCJyZWRcXFwiKSArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKC9eMjAwLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YCa6K6v5q2j5bi4XFxcIi5mb250Y29sb3IoXFxcIiMzQ0IzNzFcXFwiKSArIFxcXCIgIOW7tui/nzpcXFwiICsgeC50aW1lICsgY291bnQgKyBcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdXJsID0gaXRlbS51cmw7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBpdGVtLnRpdGxlLnJlcGxhY2UocmVnZXgsIHRpdGxlICsgXFxcIumFjee9ruato+ehrlxcXCIuZm9udGNvbG9yKFxcXCIjM0NCMzcxXFxcIikgKyBjb3VudCArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy91cmwgPSBpdGVtLnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGl0ZW0uZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBtc2csXFxuICAgICAgICAgICAgICAgICAgICAvL3VybDogdXJsLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgIH0sIHBhdGhjb25maWdzKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgfSk7XFxuICAgIHBhdGhjb25maWdzLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBsb25nQyA9IFt7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLlkI3np7BcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtLCBwLCBjKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gYy5maW5kSW5kZXgoeCA9PiB4Lm5hbWUgPT0gaXRlbS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGNbaV0ubmFtZSwgXFxcIui+k+WFpeaWsOWQjeensFxcXCIpLmlucHV0KChjLCBwLCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY1tpXS5uYW1lID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZUZpbGUocCwgSlNPTi5zdHJpbmdpZnkoYykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9LCBjLCBwLCBpKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSwgY3BhdGgsIHBhdGhjb25maWdzKVxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi6Lev5b6EXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSwgcCwgYykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGMuZmluZEluZGV4KHggPT4geC5uYW1lID09IGl0ZW0ubmFtZSk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChjW2ldLnBhdGgsIFxcXCLovpPlhaXmlrDot6/lvoRcXFwiKS5pbnB1dCgoYywgcCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNbaV0ucGF0aCA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYywgcCwgaSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGl0ZW0sIGNwYXRoLCBwYXRoY29uZmlncylcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0sIHAsIGMpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBjLmZpbmRJbmRleCh4ID0+IHgubmFtZSA9PSBpdGVtLm5hbWUpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYy5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlRmlsZShwLCBKU09OLnN0cmluZ2lmeShjKSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSwgY3BhdGgsIHBhdGhjb25maWdzKVxcbiAgICAgICAgfV07XFxuICAgICAgICBpZiAoaXRlbS5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgIGxvbmdDLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuiuv+mXrlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwid2ViOi8vXFxcIiArIGl0ZW0ucGF0aDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaXRlbSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGN1cnJlbnQgPSBcXFwiXFxcIjtcXG4gICAgICAgIGlmIChjdXJyZW50Y29uZmlnICYmIGN1cnJlbnRjb25maWcuaGFzT3duUHJvcGVydHkoXFxcInBhdGhcXFwiKSkge1xcbiAgICAgICAgICAgIGlmIChpdGVtLnBhdGggPT0gY3VycmVudGNvbmZpZy5wYXRoKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBcXFwi4p6h77iPXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD5cXFwiICsgY3VycmVudCArIFxcXCLlkI3np7A6XFxcIiArIGl0ZW0ubmFtZSArIFxcXCJcXFxcbui3r+W+hDpcXFwiICsgaXRlbS5wYXRoICsgXFxcIjwvc21hbGw+XFxcIixcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWVcXG4gICAgICAgICAgICAgICAgfSA9IGl0ZW07XFxuICAgICAgICAgICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOWKoOi9vemFjee9ri4uLlxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIH0pKSB7XFxuXFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgRHJweU1hbmFnZS5jbGVhcigpO1xcbiAgICAgICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIkNoYW5nZVNvdXJjZVBvcFxcXCIpLnNob3coMTAwKTtcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liIfmjaLlpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiAncGF0aCcgKyBpLFxcbiAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IGxvbmdDXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0pO1xcbn1cXG5cXG5cXG5zZXRSZXN1bHQobGF5b3V0KTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuaNoua6kOW8ueeql1wiLFwicGF0aFwiOlwiQ2hhbmdlU291cmNlUG9wXCIsXCJydWxlXCI6XCIkLmV4cG9ydHMuc2hvdyA9IGZ1bmN0aW9uKHRpbWUpI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gIGxldCBmbGlzdCA9IG5hbWVzLmZpbHRlcih4ID0+IHguaW5jbHVkZXModGV4dCkpO1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogXFxcIlxcXCIsXFxuICAgICAgICAgICAgY2xpY2socywgbWFuYWdlKSB7XFxuICAgICAgICAgICAgICAgIGxldCB0YWdDbGFzc2VzID0gcnVudGltZUNvbmZpZy5nZXRUYWdDbGFzc2VzKCk7XFxuICAgICAgICAgICAgICAgIGlmICghdGFnQ2xhc3Nlcy5sZW5ndGgpIHJldHVybiBcXFwidG9hc3Q6Ly/lvZPliY3phY3nva7msqHmnIlUQUflk6bjgIJcXFwiO1xcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5zZWxlY3RDZW50ZXIoe1xcbiAgICAgICAgICAgICAgICAgICAgb3B0aW9uczogdGFnQ2xhc3NlcyxcXG4gICAgICAgICAgICAgICAgICAgIGNvbHVtbnM6IDMsXFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIlRBR1tcXFwiICsgdGFnQ2xhc3Nlcy5sZW5ndGggKyBcXFwiXVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBjbGljayhhKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRCb3guc2V0RGVmYXVsdFZhbHVlKFxcXCJbXFxcIiArIGEgKyBcXFwiXVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogdHJ1ZVxcbiAgICAgICAgfSkpLFxcbiAgICAgICAgbG9uZ0NsaWNrKHMsIGkpIHtcXG4gICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5YiG5Lqr6KeG6aKR5rqQXFxcIixcXG4gICAgICAgICAgICAgICAgb3B0aW9uczogW1xcXCJKU+aWh+S7tuWIhuS6q1xcXCJdLmNvbmNhdChnZXRQYXN0ZXMoKSksXFxuICAgICAgICAgICAgICAgIGNvbDogMixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcobmFtZSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjb25zdCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gc291cmNlcy5maW5kKHYgPT4gdi5uYW1lID09IG5hbWUpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwbmFtZSA9IHBhdGguc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGVuY29kZU1vZGUgPSBnZXRJdGVtKFxcXCJzaGFyZV9lbmNvZGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZW5jb2RlTW9kZSAmJiAvdmFyIHJ1bGV8W1xcXFx1NEUwMC1cXFxcdTlGQTVdK3xmdW5jdGlvbnxsZXQgfHZhciB8Y29uc3QgfFxcXFwofFxcXFwpfFxcXCJ8Jy8udGVzdChydWxlKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmNvZGVNb2RlID09PSBcXFwiR3ppcFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IEdaSVAgPSAkLnJlcXVpcmUoXFxcIkdaSVBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZSA9IEdaSVAuemlwKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5jb2RlTW9kZSA9PT0gXFxcIkJhc2U2NFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZSA9IGJhc2U2NEVuY29kZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGVuY29kZU1vZGUgPT09IFxcXCJBRVNcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENyeXB0b1V0aWwgPSAkLnJlcXVpcmUoXFxcImhpa2VyOi8vYXNzZXRzL2NyeXB0by1qYXZhLmpzXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZXkgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VIZXgoXFxcIjY4NkE2NDY4NkU3ODBBMEEwQTBBMEEwQTBBMEEwQTBBXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpdiA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChcXFwiNjQ3QTc5Nzk2NDczMEEwQTBBMEEwQTBBMEEwQTBBMEFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRleHREYXRhID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlVVRGOChydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVuY3J5cHRlZDAgPSBDcnlwdG9VdGlsLkFFUy5lbmNyeXB0KHRleHREYXRhLCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGU6IFxcXCJBRVMvQ0JDL1BLQ1M3UGFkZGluZ1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdjogaXZcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBlbmNyeXB0ZWQwLnRvQmFzZTY0KF9iYXNlNjQuTk9fV1JBUCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFydWxlKSByZXR1cm4gXFxcInRvYXN0Oi8v6I635Y+W5aSx6LSlXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvXFxcIiArIHBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInNoYXJlOi8vaGlrZXI6Ly9maWxlcy9fY2FjaGUvXFxcIiArIHBuYW1lO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdXJsID0gc2hhcmVQYXN0ZShiYXNlNjRFbmNvZGUocnVsZSksIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly/mtbfpmJTop4bnlYzvvIxEUlBZ6KeG6aKR5rqQ44CMXFxcIiArIG5hbWUgKyBcXFwi44CN5aSN5Yi25pW05p2h5Y+j5Luk5omT5byA6L2v5Lu25bCx5Lya6Ieq5Yqo5a+85YWlJFxcXCIgKyB1cmwgKyBcXFwiJFx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AgICAgICAgICAgY29sdW1uczogMixcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLor7fpgInmi6lcXFwiLFxcbiAgICAgICAgICAgICAgICBjbGljayhzLCBpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAocyA9PSBcXFwi5pS55Y+Y5qC35byPXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogKHNwZW4gPT0gMiA/IDMgOiAyKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5YCS5bqPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZXMucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi6Ieq54S25o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0dXJhbCA9IGdldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdHVyYWwgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0dXJhbFNvcnQobGlzdCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgXFxcIlxcXCIpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgbmF0dXJhbCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5L2/55So5o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdXNpbmdzdCA9IGdldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVzaW5nc3QgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNpbmdTb3J0LmdldChsaXN0KS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbmFtZS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCB1c2luZ3N0ID8gXFxcIlxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzID09IFxcXCLliLfmlrDphY3nva5cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZighcnVudGltZUNvbmZpZy5pbml0RGVmYXVsdCgpKXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuWIt+aWsOWksei0pVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvKlxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKENrZXkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNmZyA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjZmc7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRTb3VyY2UoQ2tleSk7Ki9cXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5paw5aKeOlxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi56e76ZmkOlxcXCIgKyBkbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShcXFwi6YCJ5oup6KeG6aKR5rqQIOW9k+WJjeWFsTpcXFwiICsgbWFuYWdlLmxpc3QubGVuZ3RoICsgXFxcIuS4quinhumikea6kFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLlt7LliLfmlrBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnvJbnoIHnsbvlnotcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIuS4jee8lueggVxcXCIsIFxcXCJHemlwXFxcIiwgXFxcIkJhc2U2NFxcXCIsIFxcXCJBRVNcXFwiXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzaGFyZV9lbmNvZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9KTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJkcnB5566h55CGXCIsXCJwYXRoXCI6XCJEcnB5TWFuYWdlXCIsXCJydWxlXCI6XCJqczpcXG5jb25zdCBKU0VuZ2luZSA9IGNvbS5leGFtcGxlLmhpa2Vydmlldy5zZXJ2aWNlLnBhcnNlci5KU0VuZ2luZTtcXG5jb25zdCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29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IChEcnB5TWFuYWdlKSA9PiB7XFxuICAgICAgICAgICAgRHJweU1hbmFnZS5wdXQoa2V5LCBkcnB5KTtcXG4gICAgICAgIH0pO1xcbiAgICB9LCBrZXksIEdNa2V5LCBNWV9USUNLRVQpICsgXFxcIjtcXFxcblxcXCIsIFxcXCJcXFwiLCBmYWxzZSk7XFxufVxcblxcbmZ1bmN0aW9uIGdldChrZXkpIHtcXG4gICAgcmV0dXJuIHN5bmMoKCkgPT4ge1xcbiAgICAgICAgLy9sb2coZHJweU1hcC5zaXplKVxcbiAgICAgICAgaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChkcnB5TWFwLnNpemUgPj0gNSkge1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlcygpLmZpbmQodiA9PiB2LmtleSA9PT0ga2V5KTtcXG4gICAgICAgIGNyZWF0ZURycHkoa2V5KTtcXG4gICAgICAgIGxldCBkcnB5ID0gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIGRycHkuaW5pdChydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KSk7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmIChkcnB5LmdldFJ1bGUoXFxcInByb3h5X3J1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgUHJveHkgPSAkLnJlcXVpcmUoXFxcIkxvY2FsUHJveHlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHByb3h5VXJsID0gUHJveHkuc3RhcnRQcm94eShNWV9SVUxFLnRpdGxlLCBHTS5nZXRTZWxmS2V5KCkpO1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiUHJveHlfVXJsXFxcIiwgcHJveHlVcmwpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcbi8vc291cmNlLmV4dOW/hemhu+S4uue7neWvuei3r+W+hFxcbmZ1bmN0aW9uIGdldEJ5U291cmNlKHNvdXJjZSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICBsZXQga2V5ID0gc291cmNlLmtleTtcXG4gICAgICAgIC8vbG9nKGRycHlNYXAuc2l6ZSlcXG4gICAgICAgIGlmIChkcnB5TWFwLmhhcyhrZXkpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGRycHlNYXAuZ2V0KGtleSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZHJweU1hcC5zaXplID49IDUpIHtcXG4gICAgICAgICAgICAvL2xvZyhcXFwi6K+35rGCOlxcXCIgKyBrZXkpXFxuICAgICAgICAgICAgZGVsKEFycmF5LmZyb20oZHJweU1hcC5rZXlzKCkpLmF0KDApKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGNyZWF0ZURycHkoa2V5KTtcXG4gICAgICAgIGxldCBkcnB5ID0gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIGRycHkuaW5pdChzb3VyY2UuZXh0KTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKGRycHkuZ2V0UnVsZShcXFwicHJveHlfcnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBQcm94eSA9ICQucmVxdWlyZShcXFwiTG9jYWxQcm94eVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcHJveHlVcmwgPSBQcm94eS5zdGFydFByb3h5KE1ZX1JVTEUudGl0bGUsIEdNLmdldFNlbGZLZXkoKSk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJQcm94eV9VcmxcXFwiLCBwcm94eVVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcnVuUHJveHkoZHJweSwgYXJncykge1xcbiAgICBpZiAodHlwZW9mIGRycHkucHJveHkgPT09IFxcXCJmdW5jdGlvblxcXCIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTEgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLmFjcXVpcmUoKTtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMiA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjHnrYnlvoXml7bpl7Q6XFxcIiArICh0aW1lMiAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xcbiAgICAgICAgICAgIGxldCByZXMgPSBkcnB5LnByb3h5LmFwcGx5KGRycHksIGFyZ3MpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMuaJp+ihjOS7o+eQhuiAl+aXtjpcXFwiICsgKHRpbWUzIC0gdGltZTIpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjPmgLvogJfml7bogJfml7Y6XFxcIiArICh0aW1lMyAtIHRpbWUxKSArIFxcXCJtc1xcXCIpO1xc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biAgICAgICAgc2VhcmNob25jb3VudCA9IGNhblNlYXJjaFNvdXJjZS5sZW5ndGg7XFxuICAgIH1cXG5cXG4gICAgbGV0IHNlYXJjaEtleSA9IFxcXCJcXFwiO1xcbiAgICBoaWtlclBvcC5zZWxlY3RCb3R0b21SZXMoe1xcbiAgICAgICAgb3B0aW9uczogZ2V0TmFtZXMoKSxcXG4gICAgICAgIGNvbHVtbnM6IHNwZW4sXFxuICAgICAgICB0aXRsZTogXFxcIuWQr+eUqOaQnOe0oua6kDpcXFwiICsgc2VhcmNob25jb3VudCArIFxcXCLkuKog5YWxOlxcXCIgKyBjYW5TZWFyY2hTb3VyY2UubGVuZ3RoICsgXFxcIuS4quaQnOe0oua6kFxcXCIsXFxuICAgICAgICBub0F1dG9EaXNtaXNzOiB0cnVlLFxcbiAgICAgICAgcG9zaXRpb246IDEsXFxuICAgICAgICBoZWlnaHQ6IC45LFxcbiAgICAgICAgZXh0cmFJbnB1dEJveDogbmV3IGhpa2VyUG9wLlJlc0V4dHJhSW5wdXRCb3goe1xcbiAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCJva1xcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2UodGV4dCwgbWFuYWdlKSB7XFxuICAgICAgICAgICAgICAgIC8vbG9nKFxcXCJvbkNoYW5nZTpcXFwiK3RleHQpXFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogXFxcIlxcXCIsXFxuICAgICAgICAgICAgY2xpY2socywgbWFuYWdlKSB7XFxuICAgICAgICAgICAgICAgIC8vdG9hc3Qocyk7XFxuICAgICAgICAgICAgICAgIC8vbG9nKG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY2xpY2socywgaSwgbWFuYWdlKSB7XFxuXFxuICAgICAgICAgICAgbGV0IGtleSA9IGR5bmFtaWNTb3VyY2VbaV0ua2V5O1xcbiAgICAgICAgICAgIGxldCBpbmRleCA9IC0xO1xcbiAgICAgICAgICAgIGlmICgoaW5kZXggPSBzZWFyY2hBbGxvdy5pbmRleE9mKGtleSkpICE9PSAtMSkge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdFtpXSA9IGR5bmFtaWNTb3VyY2VbaV0ubmFtZTtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cuc3BsaWNlKGluZGV4LCAxKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdFtpXSA9IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKGR5bmFtaWNTb3VyY2VbaV0ubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaChrZXkpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIG1lbnVDbGljayhtYW5hZ2UpIHtcXG4gICAgICAgICAgICBoaWtlclBvcC5zZWxlY3RDZW50ZXIoe1xcbiAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIuaUueWPmOagt+W8j1xcXCIsIFxcXCLnrZvpgInmupBcXFwiLCBcXFwi6Ieq54S25o6S5bqPXFxcIiwgXFxcIuWAkuW6j1xcXCIsIFxcXCLlhajpgIlcXFwiLCBcXFwi5Y+N6YCJXFxcIl0sXFxuICAgICAgICAgICAgICAgIGNvbHVtbnM6IDIsXFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K+36YCJ5oupXFxcIixcXG4gICAgICAgICAgICAgICAgY2xpY2socywgaSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzcGVuID0gc3BlbiA9PSAzID8gMSA6IChzcGVuID09IDIgPyAzIDogMik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZUNvbHVtbnMoc3Blbik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBcXFwi6L6T5YWl5YWz6ZSu5a2XIOepuuaYvuekuuWFqOmDqFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuXFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRlbWxpc3QuaW5jbHVkZXModi5rZXkpKSByZXR1cm47XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgICAgICA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gICAgICAgICAgICAgbGV0IGNhdGVfdGVtcCA9IG8uY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICBpZiAoY2F0ZV90ZW1wLmNvbnN0cnVjdG9yICE9IEFycmF5KSB7XFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5pbmRleDtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGMpXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IGkgKyBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjYXRlX29ialtvLmNhdGVdID0gY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjYXRlX3RlbXApXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfdGVtcFxcXCIsIGNhdGVfdGVtcCk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX29ialxcXCIsIGNhdGVfb2JqKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcbiAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXG4gICA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XJuIFxcXCJoaWtlcjovL3NlYXJjaD9ydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIiZzPVxcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICB9LCBuYW1lKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHNraXBFcikge1xcbiAgICAgICAgICAgICAgICB1cmwgPSAkKCkubGF6eVJ1bGUoKHNvdXJjZSwgaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB1cmw7XFxuICAgICAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBEcnB5TWFuYWdlLmdldEJ5U291cmNlKHNvdXJjZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gSlNPTi5wYXJzZShkcnB5LmRldGFpbChpZCkpLmxpc3RbMF0udm9kX3BsYXlfdXJsLnNwbGl0KFxcXCIkXFxcIilbMV07XFxuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gaWQuc3BsaXQoXFxcIkBAXFxcIilbMF07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnBhcnNlKHVybCwgaWQsIHNvdXJjZSk7XFxuICAgICAgICAgICAgICAgIH0sIHNvdXJjZSwgaWQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogbmFtZSxcXG4gICAgICAgICAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXFxuICAgICAgICAgICAgICAgIHVybDogdXJsLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogaG9tZUxpc3RDb2wsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXFxuICAgICAgICAgICAgICAgICAgICB2b2RJZDogaWQsXFxuICAgICAgICAgICAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICBza2V5OiBzb3VyY2Uua2V5LFxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6IGa5ZCI5pCc57SiXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogXFxcInB1dE15VmFyKCd0ZW1zbW9kZScsICcxJyk7J2hpa2VyOi8vc2VhcmNoP3J1bGU9JyArIE1ZX1JVTEUudGl0bGUgKyAnJnM9XFxcIiArIG5hbWUgKyBcXFwiJztcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgZGVsZXRlSXRlbShNWV9SVUxFLnRpdGxlICsgXFxcImxvYWRcXFwiKTtcXG59XFxuXFxuZnVuY3Rpb24gc2V0RHJweVBhdGgoZCkge1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLnvLrlsJHov5DooYzlupNcXFxcbuivpeWwj+eoi+W6j+S4jeiDvemAmui/h+S6keWJqui0tOadv+WIhuS6q++8jOWPquiDvemAmui/h+aJk+WMheWIhuS6q1xcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi5bCG6L+Q6KGM5bqT5pS+5YWlXFxcIiArIGdldFBhdGgoXFxcImhpa2VyOi8vZm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1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGNwYXRoOiBjb25maWcucGF0aCxcXG4gICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pu05o2i6YWN572uXFxcIixcXG4gICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvY3JlYXRlQ29uZmlnI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCIpXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuiuv+mXrue9keermVxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ3ZWI6Ly9cXFwiICsgRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkuZ2V0UnVsZShcXFwiaG9zdFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy9yZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliLfmlrDmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLmluaXQocnVudGltZUNvbmZpZy5nZXRBYnNvbHV0ZVBhdGgoc291cmNlLmV4dCkpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6YeN6L295rqQXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuafpeeci+a6kOS7o+eggVxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvZGUgPSBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5ydW5NYWluKFxcXCJsZXQgbWFpbj1cXFwiICsgJC50b1N0cmluZygoZXh0KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgpID0+IGdldE9yaWdpbmFsSnMocmVxdWVzdChleHQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ21ldGhvZCc6ICdHRVQnXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlUGF0aCgpKSk7XFxuXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS92aWV3U291cmNlQ29kZS5qc1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCwgY29kZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfV0uY29uY2F0KGNvbmZpZy50eXBlID09PSBcXFwibG9jYWxEaXJcXFwiID8gW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnvJbovpHlj4LmlbDmmKDlsITooahcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygocGF0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCArPSBcXFwiLy5tYXBwaW5nLnR4dFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZmlsZUV4aXN0KHBhdGgpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuS/neWtmOWQjuWIt+aWsOmFjee9ruaIlumHjeWQr+aJjeS8mueUn+aViFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiZWRpdEZpbGU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuS4jeWtmOWcqOaYoOWwhOaWh+S7tuaYr+WQpuWIm+W7uu+8n1xcXCIpLmNvbmZpcm0ocGF0aCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLkv53lrZjlkI7liLfmlrDphY3nva7miJbph43lkK/miY3kvJrnlJ/mlYhcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJlZGl0RmlsZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBjb25maWcucGF0aClcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pys5Zyw566h55CGXFxcIixcXG4gICAgICAgICAgICAgICAganM6IFxcXCInaGlrZXI6Ly9wYWd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R1cm4gXFxcInRvYXN0Oi8v5b2T5YmN6YWN572u5rKh5pyJVEFH5ZOm44CCXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChzdGFnKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXggPSB0YWdDbGFzc2VzLmluZGV4T2Yoc3RhZykgKyAxO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgdGFnQ2xhc3Nlcy51bnNoaWZ0KFxcXCJb5pegVEFHXVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQodGFnQ2xhc3NlcywgMywgXFxcIuaQnOe0olRBR1tcXFwiICsgdGFnQ2xhc3Nlcy5sZW5ndGggKyBcXFwiXVxcXCIsIGluZGV4KS5zZWxlY3QoKHQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWcgPSBNWV9JTkRFWCA9PT0gMCA/IFxcXCJcXFwiIDogaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoVGFnKHRhZykpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic21vZGVcXFwiLCBcXFwiMlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKHQgKyBcXFwiQHNlYXJjaF9tb2RlXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRhZyB8fCBcXFwi5pegVEFHXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7lpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0sIHQpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNtb2RlXFxcIiwgXFxcIlxcXCIgKyBNWV9JTkRFWCk7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0odCArIFxcXCJAc2VhcmNoX21vZGVcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCLpgInkuK1cXFwiLCBcXFwi6IGa5ZCIXFxcIl1bTVlfSU5ERVhdLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBNWV9SVUxFLnRpdGxlKVxcbiAgICAgICAgfSksXFxuICAgICAgICBpbWc6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS8xNDkucG5nXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiB1aV9jb25maWcuY29sLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJAc2VhcmNoX21vZGVcXFwiLFxcbiAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjIflrprmkJzntKLmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIlNlYXJjaEFsbG93UG9wXFxcIikuc2hvdygpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH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ZrumAmuS9v+eUqOS4jemcgOimgeW8gOWQr1xcXFxu5b2T5YmNOlxcXCIgKyB1c2VMb2cgKyBcXFwiXFxcXG7ngrnlh7vnoa7lrprljbPlj69cXFwiICsgKHVzZUxvZyA/IFxcXCLlhbPpl61cXFwiIDogXFxcIuW8gOWQr1xcXCIpKS5jb25maXJtKCh1c2VMb2cpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzZUxvZ1xcXCIsIHVzZUxvZyA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArICh1c2VMb2cgPyBcXFwi5bey5YWz6ZetXFxcIiA6IFxcXCLlt7LlvIDlkK9cXFwiKTtcXG4gICAgICAgICAgICAgICAgfSwgdXNlTG9nKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yib5bu66K6i6ZiF5Zyw5Z2AXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9jcmVhdGV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ShcXFwiaG9tZUxpc3RDb2xcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5pu05o2i6YWN572uXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKFxcXCLmlK/mjIHkvZzogIVcXFwiID09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL0RvbmF0ZS52I25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChcXFwiVUnnrqHnkIZcXFwiID09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL1VJTWFuYWdlP21vZGU95LiA57qnI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChcXFwi5YiG5Lqr5a+85YWl6Lev5b6EXFxcIiA9PSBpbnB1dCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9zaGFyZWRlZmF1bHRwYXRoI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dC5pbmNsdWRlcyhcXFwi5pCc57Si5qih5byPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXFxcInNtb2RlXFxcIiwgXFxcIjBcXFwiKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6YCJ5LitXFxcIiwgXFxcIuiBmuWQiFxcXCJdLCAxLCBcXFwi5pCc57Si5qih5byPXFxcIiwgc21vZGUpLnNlbGVjdCgodCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic21vZGVcXFwiLCBcXFwiXFxcIiArIE1ZX0lOREVYKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBNWV9SVUxFLnRpdGxlKVxcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT0gXFxcIuaQnOe0ouaMh+Wumua6kFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiU2VhcmNoQWxsb3dQb3BcXFwiKS5zaG93KCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PSBcXFwi5oiR55qEXFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgZmF2aWNvbnMgPSBHTS5nZXQoXFxcImZhdmljb25zXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBmYXZpY29ucy5nZXQoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0LmluY2x1ZGVzKFxcXCLmkJzntKLmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgc2VhcmNoc29ydCA9IE51bWJlcihnZXRJdGVtKFxcXCJzZWFyY2hzb3J0XFxcIiwgXFxcIjBcXFwiKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi5LiN5L2/55SoXFxcIiwgXFxcIuiHqueEtuaOkuW6j1xcXCIsIFxcXCLkvb/nlKjmjpLluo9cXFwiXSwgMSwgXFxcIuaQnOe0ouaOkuW6j1xcXCIsIHNl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ICAgICB1cmw6IFxcXCJoaWtlcjovL2hpc3Rvcnk/cnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZSxcXG4gICAgfSk7XFxuICAgIHVpb2JqLnB1c2goe1xcbiAgICAgICAgaW5kZXg6IDQsXFxuICAgICAgICBrZXk6IFxcXCLmlLbol49cXFwiLFxcbiAgICAgICAgdGl0bGU6IFxcXCLmlLbol49cXFwiLFxcbiAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICBsZXQgZmF2aWNvbnMgPSBHTS5nZXQoXFxcImZhdmljb25zXFxcIik7XFxuICAgICAgICAgICAgcmV0dXJuIGZhdmljb25zLmdldCgpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBpbWc6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS8xMzkucG5nXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiB1aV9jb25maWcuY29sLFxcbiAgICB9KTtcXG4gICAgdWlvYmoucHVzaCh7XFxuICAgICAgICBpbmRleDogNSxcXG4gICAgICAgIGtleTogXFxcIua6kOWQjVxcXCIsXFxuICAgICAgICB0aXRsZTogXFxcIuW9k+WJjea6kDpcXFwiICsgKG5hbWUgfHwgXFxcIlxcXCIpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJhdmF0YXJcXFwiLFxcbiAgICAgICAgaW1nOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9rZS8xNTAucG5nXFxcIixcXG4gICAgICAgIHVybDogXFxcInRvYXN0Oi8v54K55LiK6Z2i5o2i5rqQXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwic291cmNlbmFtZVxcXCIsXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICB1aW9iai5wdXNoKHtcXG4gICAgICAgIGluZGV4OiA2LFxcbiAgICAgICAga2V5OiBcXFwi5pCc57SiXFxcIixcXG4gICAgICAgIHRpdGxlOiAn5pCc57SiJyxcXG4gICAgICAgIC8vZGVzYzogJycsXFxuICAgICAgICBkZXNjOiAn6KaB5pCc54K55LuA5LmIJyxcXG4gICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuICdoaWtlcjovL3NlYXJjaD9ydWxlPScgKyBNWV9SVUxFLnRpdGxlICsgXFxcIiZzPVxcXCIgKyBpbnB1dDtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY29sX3R5cGU6ICdpbnB1dCcsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogZ2V0TXlWYXIoXFxcImtleXdvcmRcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwia2V5d29yZFxcXCIsIGlucHV0KVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwidWlvYmpcXFwiLCB1aW9iaik7XFxuXFxuICAgIHN1aW9iaiA9IHVpb2JqLnNsaWNlKCk7XFxuICAgIHVpb2JqID0gcmVvcmRlckFycmF5QnlPcmRlcih1aW9iaiwgdWlfaW5kZXhzKTtcXG4gICAgdWlfaW5kZXhzLm1hcChpdGVtID0+IHtcXG4gICAgICAgIGlmIChpdGVtLmtleSA9PSBcXFwi5o2i5rqQXFxcIiAmJiBpdGVtLmluZGV4ID09IC0xKSB7XFxuICAgICAgICAgICAgbGV0IG9iamkgPSBzdWlvYmouZmluZEluZGV4KHggPT4geC5rZXkgPT0gXFxcIuaNoua6kFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBjb2JqaSA9IHVpb2JqLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IFxcXCLmupDlkI1cXFwiKTtcXG4gICAgICAgICAgICBpZiAob2JqaSAhPSAxICYmIGNvYmppICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgIHVpb2JqW2NvYmppXS51cmwgPSBzdWlvYmpbb2JqaV0udXJsO1xcbiAgICAgICAgICAgICAgICBpZiAoc3Vpb2JqW29iamldLmhhc093blByb3BlcnR5KFxcXCJleHRyYVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICB1aW9ialtjb2JqaV0uZXh0cmEgPSBzdWlvYmpbb2JqaV0uZXh0cmE7XFxuICAgICAgICAgICAgICAgICAgICB1aW9ialtjb2JqaV0uZXh0cmEuaWQgPSBNWV9SVUxFLnRpdGxlICsgXFxcInNvdXJjZW5hbWVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGl0ZW0ua2V5ID09IFxcXCLmupDlkI1cXFwiICYmIGl0ZW0uaW5kZXggPT0gLTEpIHtcXG4gICAgICAgICAgICBsZXQgb2JqaSA9IHN1aW9iai5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBcXFwi5rqQ5ZCNXFxcIik7XFxuICAgICAgICAgICAgbGV0IGNvYmppID0gdWlvYmouZmluZEluZGV4KHggPT4geC5rZXkgPT0gXFxcIuaNoua6kFxcXCIpO1xcbiAgICAgICAgICAgIGlmIChvYmppICE9IDEgJiYgY29iamkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgdWlvYmpbY29iamldLnRpdGxlID0gbmFtZSB8fCBcXFwi5o2i5rqQXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXRlbS5rZXkgPT0gXFxcIuWOhuWPslxcXCIgJiYgaXRlbS5pbmRleCA9PSAtMSkge1xcbiAgICAgICAgICAgIHNlbGVjdHMudW5zaGlmdCh7XFxuICAgICAgICAgICAgICAgIFxcXCJ0aXRsZVxcXCI6IF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gICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICB9IGVsc2UgaWYgKCFydW50aW1lQ29uZmlnLmlzUHJlcGFyZWQoKSkge1xcbiAgICAgICAgbGV0IGxvYWRFcnJvciA9IHJ1bnRpbWVDb25maWcuZ2V0TG9hZEVycm9yKCk7XFxuICAgICAgICBpZiAobG9hZEVycm9yKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzphY3nva7mlofku7bliqDovb3lpLHotKXigJ3igJ1cXFwiLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBsb2FkRXJyb3IudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKCkubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIikuaW5pdERlZmF1bHQoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNoumFjee9rlxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L+Y5rKh5pyJ6YWN572u6KeG6aKR5rqQXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZUNvbmZpZyNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9IGVsc2UgaWYgKGZpbGVFeGlzdChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIikpIHtcXG5cXG4gICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgIGlmIChNWV9QQUdFID09PSAxKSB7XFxuICAgICAgICAgICAgaWYgKHNvdXJjZSA9PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICAgICAgc2V0SGllZChkLCBcXFwiXFxcIiwge30pO1xcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIuW9k+WJjeayoeaciemAieS4reS7u+S9leinhumikea6kFxcXCIpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHNldEhpZWQoZCwgc291cmNlLm5hbWUsIHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpIHx8IHt9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICAvL2xvZyhEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KSlcXG4gICAgICAgIGxldCBoYXNIYWVkID0gZmFsc2U7XFxuICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcImxpbmtzXFxcIiwgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6ICfliqDovb3kuK0uLi4nLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudGVyXzEnLFxcbiAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXFxcImxvYWRcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBzZXRQcmVSZXN1bHQoZCk7XFxuICAgICAgICAgICAgZC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgIGhhc0hhZWQgPSB0cnVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHNvdXJjZSkge1xcbiAgICAgICAgICAgIGxvYWQoZCwgRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSksIHNvdXJjZSwgaGFzSGFlZCk7XFxuICAgICAgICB9XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBzZXREcnB5UGF0aChkKTtcXG4gICAgfVxcblxcbn0gY2F0Y2ggKGUpIHtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIGUudG9TdHJpbmcoKSArIFxcXCLigJ3igJ1cXFwiLFxcbiAgICAgICAgZGVzYzogZS5saW5lTnVtYmVyLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5riF6ZmkdWnorr7nva5cXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVpX2NsZWFyLFxcbiAgICAgICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiVUlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHVpX2NsZWFyKFxcXCJ5aVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5pu05o2i6YWN572uXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZGVsZXRlSXRlbShNWV9SVUxFLnRpdGxlICsgXFxcImxvYWRcXFwiKTtcXG59XFxuXFxuc2V0UmVzdWx0KGQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi5Li76aG15aSE55CGXC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gICAgICAgIGhpa2VyUG9wLnVwZGF0ZVJlY29yZHNCb3R0b20oJC5yZXF1aXJlKFxcXCJ1cGRhdGVSZWNvcmRzXFxcIikpO1xcblxcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiB0aW1lICsgXFxcIuenkuWQjue7p+e7rVxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJ0b2FzdDovL+ivt+iupOecn+mYheivu+S7peS4iuWGheWuuVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwidGltZXJcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIHdoaWxlICh0aW1lICE9IDApIHtcXG4gICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwMCk7XFxuICAgICAgICB0aW1lIC09IDE7XFxuICAgICAgICB1cGRhdGVJdGVtKGlkICsgXFxcInRpbWVyXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiB0aW1lICsgXFxcIuenkuWQjue7p+e7rVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHVwZGF0ZUl0ZW0oaWQgKyBcXFwidGltZXJcXFwiLCB7XFxuICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOaIkeWQjOaEj+S7peS4iuimgeaxguKAneKAnVxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ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JldHVybiByZXN1bHQ7XFxuICAgICAgfSxcXG4gICAgICB1aUNvbmZpZzoge1xcbiAgICAgICAgaXRlbXM6IGl0ZW1zLFxcbiAgICAgICAgdWM6IHVpX2NvbmZpZyxcXG4gICAgICAgIGRlZjogZGVmLFxcbiAgICAgICAgZGVlcE9iamVjdFByb3BlcnR5KG9iaiwgcGF0aCwgdmFsdWUpIHtcXG4gICAgICAgICAgdmFyIHBhcnRzID0gcGF0aC5zcGxpdCgnLicpO1xcbiAgICAgICAgICB2YXIgY3VycmVudCA9IG9iajtcXG4gICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBwYXJ0cy5sZW5ndGggLSAxOyBpKyspIHtcXG4gICAgICAgICAgICB2YXIgcGFydCA9IHBhcnRzW2ldO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFtwYXJ0XSkge1xcbiAgICAgICAgICAgICAgY3VycmVudFtwYXJ0XSA9IHt9O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtwYXJ0XTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBjdXJyZW50W3BhcnRzW3BhcnRzLmxlbmd0aCAtIDFdXSA9IHZhbHVlO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldCgpIHtcXG4gICAgICAgICAgbGV0IHVjID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdGhpcy51Yyk7XFxuICAgICAgICAgIGlmIChPYmplY3Qua2V5cyh1YykubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICB1YyA9IHRoaXMuZGVmO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiB1YztcXG4gICAgICAgIH0sXFxuICAgICAgICBzZXQodmFsdWUsIGtleSkge1xcbiAgICAgICAgICBsZXQgdWMgPSB0aGlzLmdldCgpO1xcbiAgICAgICAgICBpZiAoa2V5KSB7XFxuICAgICAgICAgICAgdGhpcy5kZWVwT2Jq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ljOiBjdXJyZW50LnBpYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGRlc2M6IGN1cnJlbnQuZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBjdXJyZW50LnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgaXRlbS5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGN1cnJlbnQuZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogY3VycmVudC5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKGN1cnJlbnQuZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgcGljOiBpdGVtLnBpYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGRlc2M6IGl0ZW0uZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBpdGVtLnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgY3VycmVudC5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGl0ZW0uZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogaXRlbS5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBsZXQgbmFyciA9ICQuc3dhcEFycmF5RWxlbWVudHMoaW5kZXhzLCBjdXJyZW50LmV4dHJhLmluZGV4LCBpdGVtLmV4dHJhLmluZGV4KTtcXG5cXG4gICAgICAgICAgICAkLnVpQ29uZmlnLnNldChuYXJyLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIik7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGggPSAn4oCc4oCc4oCd4oCdJztcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBpdGVtLnRpdGxlO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLpgInmi6nnp7vliqjnmoTnm67moIdcXFwiKTtcXG4gICAgICAgICAgICBpZiAoL3RleHRfaWNvbnxhdmF0YXJ8aWNvbl9zbWFsbF8zLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICgvaWNvbl8xX3NlYXJjaC8udGVzdChpdGVtLnR5cGUpKSB7XFxuICAgICAgICAgICAgICBoID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICB0aXRsZSA9IFxcXCLinqHvuI9cXFwiICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGggKyB0aXRsZSxcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIiwgaXRlbSk7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGkpXFxuICAgICAgICBpdGVtW1xcXCJleHRyYVxcXCJdID0ge1xcbiAgICAgICAgICBrZXk6IGl0ZW0ua2V5LFxcbiAgICAgICAgICBjbHM6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIixcXG4gICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgIGluZGV4OiBpdGVtLmluZGV4LFxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLorr7nva5cXFwiKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW5kZXhcXFwiXSA9IC0xO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghL2ljb25fMV9zZWFyY2h8YXZhdGFyLy50ZXN0KGl0ZW0uY29sX3R5cGUpKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmm7TmjaLlm77moIdcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiKS5pbnB1dCgoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW1nXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCwgeyBwaWM6IGlucHV0IH0pXFxuICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgfSwgaXRlbS5rZXkpXFxuICAgICAgICAgIH0pXFxuICAgICAgICAgIGlmIChpdGVtLmtleSAhPSBcXFwi5o2i5rqQXFxcIiAmJiBpdGVtLmtleSAhPSBcXFwi5pCc57Si5qih5byPXFxcIikge1xcbiAgICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogXFxcIuS/ruaUueWQjeensFxcXCIsXFxuICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiKS5pbnB1dCgoa2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJ0aXRsZVxcXCJdID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICBsZXQgaWQgPSBmaW5kSXRlbXNCeUNscyhNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIpLmZpbHRlcih4ID0+IHguZXh0cmEua2V5ID09IGtleSlbMF0uZXh0cmEuaWQ7XFxuICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpZCwgeyB0aXRsZTogaW5wdXQgfSlcXG4gICAgICAgICAgICAgICAgfSwga2V5KVxcbiAgICAgICAgICAgICAgfSwgaXRlbS5rZXkpXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaXRlbS5leHRyYS5Mb25nQ2xpY2sgPSBsb25nY2xpY2tzO1xcbiAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgfSlcXG4gICAgfSBlbHNlIHtcXG4gICAgICB1aW9iaiA9IHVpb2JqLm1hcCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgaXRlbS5leHRyYSA9IHtcXG4gICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9XFxuICAgIGQgPSBkLmNvbmNhdCh1aW9iaik7XFxuXFxuICAgIGlmIChpbmRleHMuc29tZSh4ID0+IHguaW5kZXggPT0gLTEpICYmIHVpbW9kZSkge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuW3suenu+mZpFxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgIH1cXG4gICAgICB9KVxcbiAgICAgIGluZGV4cy5maWx0ZXIoeCA9PiB4LmluZGV4ID09IC0xKS5mb3JFYWNoKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBsZXQgbWFwID0gbmV3IE1hcChzdWlvYmoubWFwKG9iaiA9PiBbb2JqLmtleSwgb2JqXSkpO1xcbiAgICAgICAgbGV0IG9iaiA9IG1hcC5nZXQoaXRlbS5rZXkpO1xcbiAgICAgICAgb2JqLnVybCA9ICQoXFxcIlxcXCIpLmxhenlSdWxlKChrZXksIGluZGV4KSA9PiB7XFxuICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW5kZXhcXFwiXSA9IGluZGV4O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaXRlbS5rZXksIG9iai5pbmRleClcXG4gICAgICAgIG9iai50aXRsZSA9IG9iai5rZXk7XFxuICAgICAgICBpZiAob2JqLmV4dHJhID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICBvYmouZXh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AgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbiAgICB9LCB7XFxuICAgICAgdGl0bGU6IFxcXCLov5jljp9cXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZywgZGVmKSA9PiB7XFxuICAgICAgICByZXR1cm4gJChcXFwi5piv5ZCm5oGi5aSN6K6+572uXFxcIikuY29uZmlybSgodWlfY29uZmlnLCBkZWYpID0+IHtcXG4gICAgICAgICAgdWlfY29uZmlnLnlpID0gZGVmLnlpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5Y6f5a6M5oiQXFxcIjtcXG4gICAgICAgIH0sIHVpX2NvbmZpZywgZGVmKVxcbiAgICAgIH0sIHVpX2NvbmZpZywgZGVmKSxcXG4gICAgfSwge1xcbiAgICAgIHRpdGxlOiBcXFwi56Gu6K6kXFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIExvbmdDbGljazogW3tcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlpI3liLZcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgY29weShKU09OLnN0cmluZ2lmeSh1aV9jb25maWcueWkpKTtcXG4gICAgICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlr7zlhaVcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHVjID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwie3tjbGlwYm9hcmR9fVxcXCIpLmlucHV0KCh1YykgPT4ge1xcbiAgICAgICAgICAgICAgdmFyIHlpID0ge307XFxuICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB5aSA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoeWkuaGFzT3duUHJvcGVydHkoXFxcInVpXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICB1Yy55aSA9IHlpO1xcbiAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVjKTtcXG4gICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmoLzlvI/plJnor69cXFwiKVxcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHVjKVxcbiAgICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgICB9XVxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuWktOmDqOe7hOS7tuagt+W8jzpcXFwiICsgdWlfY29uZmlnLnlpLmNvbCxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCh1aV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pZCwge1xcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGlucHV0LFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9KTtcXG4gICAgICAgICAgdWlfY29uZmlnLnlpLmNvbCA9IGlucHV0O1xcbiAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICB1cGRhdGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIlxcbiAgICAgIH1cXG4gICAgfSlcXG4gIH1cXG5cXG4gIGlmICh1aV9uYXZpID09IFxcXCLkuoznuqdcXFwiKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmr4/pobXmlbDph49cXFwiLFxcbiAgICAgIGRlc2M6IFxcXCIw5YiZ6KGo56S65LiN5YiG6aG1XFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICB1cmw6ICQudG9TdHJpbmcoKHVpX2NvbmZpZykgPT4ge1xcbiAgICAgICAgaWYgKFN0cmluZyhpbnB1dCkubGVuZ3RoID4gMykge1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWlM+S9jeaVsOWtl+S7peWGhVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoU3RyaW5nKGlucHV0KS5sZW5ndGggPCAyICYmIGlucHV0ICE9ID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1xcbiAgICBmdW5jdGlvbiBwYXJzZVZpZGVvKE1ZX1BBUkFNUywgdGl0bGUpIHtcXG4gICAgICAgIGZ1bmN0aW9uIHRvUGF0aCh2YWx1ZSkge1xcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgIT09ICdzdHJpbmcnKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBbXTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhdGggPSBbXTtcXG4gICAgICAgICAgICBsZXQgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgIGxldCBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgbGV0IGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdmFsdWUubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGNoYXIgPSB2YWx1ZVtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGVzY2FwZSkge1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgICAgICAgICAgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1xcXFxcXFxcJykge1xcbiAgICAgICAgICAgICAgICAgICAgZXNjYXBlID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnLicgJiYgIWluQnJhY2tldHMpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnWycpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICddJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChjdXJyZW50KSB7XFxuICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHBhdGg7XFxuICAgICAgICB9XFxuXFxuICAgICAgICBmdW5jdGlvbiBnZXRKc29uKG9iaiwgcGF0aCkge1xcbiAgICAgICAgICAgIGlmICghb2JqIHx8ICFBcnJheS5pc0FycmF5KHBhdGgpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChwYXRoLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgY3VycmVudCA9IG9iajtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHBhdGgubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IHBhdGhbaV07XFxuICAgICAgICAgICAgICAgIGlmIChjdXJyZW50ID09PSBudWxsIHx8IGN1cnJlbnQgPT09IHVuZGVmaW5lZCB8fCB0eXBlb2YgY3VycmVudCAhPT0gJ29iamVjdCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY3VycmVudCA9IGN1cnJlbnRba2V5XTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGN1cnJlbnQ7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBydW5UeXBlID0gTVlfUEFSQU1TLnJ1blR5cGVbMF07XFxuICAgICAgICAgICAgbGV0IHVybCA9IGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnVybFswXSkpO1xcbiAgICAgICAgICAgIGlmIChydW5UeXBlID09IFxcXCJKU09OXFxcIikge1xcblxcbiAgICAgICAgICAgICAgICBsZXQgcGFyYW0gPSBKU09OLnBhcnNlKGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UocmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHBhcmFtLmhlYWRlcnMgfHwge30sXFxuICAgICAgICAgICAgICAgICAgICBtZXRob2Q6IHBhcmFtLm1ldGhvZCB8fCB2b2lkIDBcXG4gICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogT2JqZWN0LmFzc2lnbih7fSwgcGFyYW0uaGVhZGVycyB8fCB7fSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IGdldEpzb24oanNvbiwgdG9QYXRoKHBhcmFtLmpzb25QYXRoKSksXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT0gXFxcIkpTXFxcIikge1xcblxcbiAgICAgICAgICAgICAgICBsZXQgcGFyc2U7XFxuICAgICAgICAgICAgICAgIGlmIChNWV9QQVJBTVMuaW5kZXgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHRpdGxlKS5nZXRKc29uKClbTVlfUEFSQU1TLmluZGV4WzBdXTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUoZGVjb2RlVVJJQ29tcG9uZW50KE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgcmVzID0gbmV3IEZ1bmN0aW9uKFxcXCJ1cmxcXFwiLCBcXFwic2VsZlxcXCIsIHBhcnNlLmpzKSh1cmwsIHBhcnNlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXMgPT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCQudHlwZShyZXMpID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcmVzXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAg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w5pel5b+X44CCXFxcIixcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrpgInmupDplb/mjInoj5zljZXvvIzlop7liqDot7PovaznvZHpobXvvIzmn6XnnIvmupDnoIHjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjee8lui+keino+aekOeVjOmdoua1i+ivlWpz6Kej5p6Q5LiA55u05aSx6LSl44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI1naXRodWLorqLpmIXvvIzkvJrliKDpmaTlhajpg6jop4TliJnmlofku7bjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeino+aekOiwg+eUqOWksei0peOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5pu05o2i6YWN572u5pe25rKh5pyJ5Y+K5pe25riF56m6ZHJweee8k+WtmOOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlLnorqLpmIXmm7TmlrDnrZbnlaXvvIzkvJrliKDpmaTmnKzlnLDlpLHmlYjmupDjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5pu05pawZHJweTIuanPjgIJcXFwiLFxcbiAgICAgICAgXFxcIm9wdGltaXpl77ya5LyY5YyW6Kej5p6QZmxhZ+WMuemFjeOAglxcXCIsXFxuXFxuICAgIF1cXG59LCB7XFxuICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8wOSBNYXhWZXJzaW9uIDIwXFxcIixcXG4gICAgcmVjb3JkczogW1xcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muaUr+aMgXByb3h5X3J1bGXku6PnkIbjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeS6keebmOmTvuaOpeS4jeiwg+WPluS6keebmOeugOOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5ZOU5ZOp5b2x6KeG5LiN6IO95L2/55So6Kej5p6Q44CCXFxcIixcXG4gICAgXVxcbn1dO1wifV0iLCJpY29uIjoiIiwicHJveHkiOiIifQ==
Add Comment
Please, Sign In to add comment