Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IkRycHlIaWtlciIsImF1dGhvciI6IkBMb3lEZ0lrJnpldGFscGhhIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6MjcsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoidmlkZW8iLCJjbGFzc191cmwiOiIiLCJhcmVhX25hbWUiOiIiLCJhcmVhX3VybCI6IiIsInNvcnRfbmFtZSI6IiIsInllYXJfbmFtZSI6IiIsInNvcnRfdXJsIjoiIiwieWVhcl91cmwiOiIiLCJmaW5kX3J1bGUiOiJqczokLnJlcXVpcmUoXCJNaWFuTG9hZFwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zPSoqJnBhZ2U9ZnlwYWdlIiwiZ3JvdXAiOiIjIyMj5Lmd55+zIiwic2VhcmNoRmluZCI6ImpzOlxuKGZ1bmN0aW9uKCkge1xuICAgIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgICBsZXQgdGVtc21vZGUgPSBnZXRNeVZhcihcInRlbXNtb2RlXCIsIFwiXCIpO1xuICAgIGlmICh0ZW1zbW9kZSkge1xuICAgICAgICBzbW9kZSA9IE51bWJlcih0ZW1zbW9kZSk7XG4gICAgICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgICB9XG4gICAgaWYgKCFmaWxlRXhpc3QoXCJoaWtlcjovL2ZpbGVzL2RhdGEvXCIgKyBNWV9SVUxFLnRpdGxlICsgXCIvbGlic19oaWtlci9kcnB5Mi5qc1wiKSkgcmV0dXJuIHNldFJlc3VsdChbe1xuIC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dGNoIHt9XG4gICAgICAgIGxldCBkID0gW107XG4gICAgICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyArIFwiwrdcIiArIHNvdXJjZS5uYW1lLFxuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICAgICAgICAgIHVybDogXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWQjaW1tZXJzaXZlVGhlbWUjXCIsXG4gICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgdm9kSWQ6IGl0LnZvZF9pZCxcbiAgICAgICAgICAgICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXG4gICAgICAgICAgICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXlcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBzZXRSZXN1bHQoZCk7XG4gICAgfSBlbHNlIHtcbiAgICAgICAgc2V0UmVzdWx0KFt7XG4gICAgICAgICAgICB0aXRsZTogXCLngrnmiJHlvIDlp4vogZrlkIjmkJzntKJcIiArIE1ZX0tFWVdPUkQsXG4gICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9zZWFyY2g/cz1cIiArIE1ZX0tFWVdPUkQsXG4gICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgIGRlbGVnYXRlT25seVNlYXJjaDogdHJ1ZSxcbiAgICAgICAgICAgICAgICBydWxlczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIiwgXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbG93U2VhcmNoU291cmNlKCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdC5zcGxpY2UobGlzdC5pbmRleE9mKHNvdXJjZSksIDEpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3QudW5zaGlmdChzb3VyY2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaF91cmw6IFwiaGlrZXI6Ly9lbXB0eT9wYWdlPWZ5cGFnZSZzZWFyY2hUZXJtcz0qKlwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRycHkgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpLmdldChpdGVtLmtleSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBob21lTGlzdCA9IEpTT04ucGFyc2UoZHJweS5zZWFyY2goTVlfS0VZV09SRCwgZmFsc2UsIE1ZX1BBR0UpKS5saXN0IHx8IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnZvZF9uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWQjaW1tZXJzaXZlVGhlbWUjXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcIm1vdmllXzNcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvZElkOiBpdC52b2RfaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbmFtZTogaXRlbS5uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2tleTogaXRlbS5rZXksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFJlc3VsdChkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkocnVsZXMpO1xuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH1dKTtcbiAgICB9XG59KSgpIiwiZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsImRldGFpbF9maW5kX3J1bGUiOiIiLCJzZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsInNkZXRhaWxfZmluZF9ydWxlIjoiIiwidWEiOiJtb2Jpb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gICAgICAgc3RvcmFnZTAuY2xlYXJJdGVtKGxvY2FsS2V5ICsgXFxcIkBcXFwiICsgcnVsZWtleSArIFxcXCJAXFxcIiArIGspO1xcbiAgICAgICAgfVxcbiAgICB9O1xcbiAgICBnbG9iYWxUaGlzLmdldFByb3h5ID0gZnVuY3Rpb24oKSB7XFxuICAgICAgICByZXR1cm4gZ2V0TXlWYXIoXFxcIlByb3h5X1VybFxcXCIsIFxcXCJodHRwOi8vMTI3LjAuMC4xOjUyMDIwL3Byb3h5XFxcIikgKyBcXFwiP2hpa2VyU2tleT1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHNrZXkpICsgXFxcIiZkbz1qc1xcXCI7XFxuICAgIH1cXG4gICAgZXZhbChnZXRDcnlwdG9KUygpKTtcXG4gICAgZ2xvYmFsVGhpcy5DcnlwdG9KUyA9IENyeXB0b0pTO1xcblxcbiAgICBsZXQgJHJlcXVlc3QgPSByZXF1ZXN0O1xcbiAgICBsZXQgJHBvc3QgPSBwb3N0O1xcbiAgICBnbG9iYWxUaGlzLnJlcSA9IGZ1bmN0aW9uKHVybCwgY29iaikge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcmVzID0ge307XFxuICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIGNvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmouZGF0YSkge1xcbiAgICAgICAgICAgICAgICBvYmouYm9keSA9IG9iai5kYXRhO1xcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqLmRhdGE7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoXFxcInJlZGlyZWN0XFxcIikpIG9iai5yZWRpcmVjdCA9ICEhb2JqLnJlZGlyZWN0O1xcbiAgICAgICAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICAgICAgICAgIG9iai50b0hleCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iai5oZWFkZXJzID0gT2JqZWN0LmFzc2lnbih7XFxuICAgICAgICAgICAgICAgIENvb2tpZTogXFxcIiNub0Nvb2tpZSNcXFwiXFxuICAgICAgICAgICAgfSwgb2JqLmhlYWRlcnMpO1xcbiAgICAgICAgICAgIGlmICh1cmwgPT09IFxcXCJodHRwczovL2FwaS5ubi5jaS9vY3IvYjY0L3RleHRcXFwiICYmIG9iai5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW1xcXCJDb250ZW50LVR5cGVcXFwiXSA9IFxcXCJ0ZXh0L3BsYWluXFxcIjtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKHVybC5zdGFydHNXaXRoKFxcXCJmaWxlOi8vXFxcIikgJiYgKHVybC5pbmNsdWRlcyhcXFwiP3R5cGU9XFxcIikgfHwgdXJsLmluY2x1ZGVzKFxcXCI/cGFyYW1zPVxcXCIpKSkge1xcbiAgICAgICAgICAgICAgICB1cmwgPSB1cmwuc2xpY2UoMCwgdXJsLmxhc3RJbmRleE9mKFxcXCI/XFxcIikpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBmb3IgKGxldCBrZXkgaW4gb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBvYmouaGVhZGVyc1trZXldICE9PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNba2V5XSA9IFN0cmluZyhvYmouaGVhZGVyc1trZXldKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgciA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIC8qIGlmIChTdHJpbmcob2JqLm1ldGhvZCkudG9Mb3dlckNhc2UoKSA9PT0gXFxcInBvc3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICBpZiAob2JqLndpdGhIZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHIuYm9keTtcXG4gICAgICAgICAgICAgICAgcmVzLmhlYWRlcnMgPSB7fTtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzW2tdID0gdlswXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VIZXgocmVzLmNvbnRlbnQpLnRvQmFzZTY0KF9iYXNlNjQuTk9fV1JBUCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKFxcXCJFcnJvclxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIC8qXFxuICAgIGNvbnN0IEppbkphID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2Nkbi5ib290Y2RuLm5ldC9hamF4L2xpYnMvbXVzdGFjaGUuanMvNC4xLjAvbX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lQXQoaSk7XFxuICAgICAgICAgICAgaWYgKGNvZGUgPj0gMHgwMTAwKSB7IC8vIOWPjOWtl+iKguWtl+espueahCBVbmljb2RlIOe8lueggeWkp+S6jiAyNTVcXG4gICAgICAgICAgICAgICAgY291bnQgKz0gMjsgLy8g5Y+M5a2X6IqC5a2X56ym6K6h5pWw5Li6MlxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ICs9IDE7IC8vIOWNleWtl+iKguWtl+espuiuoeaVsOS4ujFcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gY291bnQ7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gY2FjaGVTaG93VGlwcygpIHtcXG4gICAgICAgIC8qaWYgKHN0b3JhZ2UwLmdldE15VmFyKGlkICsgXFxcImVyaW5mb1xcXCIpKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShcXFwi5b2T5YmN5Li657yT5a2YLOeCueaIkeWIt+aWsFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGM6IFxcXCJncmV5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaWQgKyBcXFwiZXJpbmZvXFxcIilcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGlkKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSlcXG4gICAgICAgIH0qL1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIHN1YnN0cihzdHIsIG1heExlbmd0aCkge1xcbiAgICAgICAgbGV0IGxlbiA9IDA7XFxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgIGlmIChzdHIuY2hhckNvZGVBdChpKSA+IDI1NSkge1xcbiAgICAgICAgICAgICAgICBsZW4gKz0gMjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZW4rKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGxlbiA+IG1heExlbmd0aCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gc3RyLnNsaWNlKDAsIGkpICsgJy4uLic7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHN0cjtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBzZXREZXNjKGRlc2MsIG51bSkge1xcbiAgICAgICAgaWYgKGRlc2MgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgfVxcbiAgICAgICAgZGVzYyA9IGRlc2MuY29uc3RydWN0b3IgPT0gQXJyYXkgPyBkZXNjLmpvaW4oJzxicj4nKSA6IGRlc2M7XFxuICAgICAgICBpZiAoZGVzYy5yZXBsYWNlKC8oPGJyPnxcXFxccyspL2csICcnKS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmlnX2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgICAgIH0pXF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9ICflsZXlvIA6JztcXG4gICAgICAgICAgICB2YXIgcmV0ID0gJ+aUtui1tzonO1xcbiAgICAgICAgICAgIGlmIChzaG93ID09ICcxJykge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBzZGMgKyAnPC9zbWFsbD4nKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8oPFxcXFwvc21hbGw+PGJyPlxcXFw8Zm9udCBjb2xvcj1cXFwiKS4qPyhcXFwiPikvLCAnJDEnICsgY3MuaGlkZSArICckMicpXFxuXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0obSwgJzAnKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoZXhwLCByZXQpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBkYyArICc8L3NtYWxsPicpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXC9zbWFsbD48YnI+XFxcXDxmb250IGNvbG9yPVxcXCIpLio/KFxcXCI+KS8sICckMScgKyBjcy5zaG93ICsgJyQyJylcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMScpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gYGhpa2VyOi8vZW1wdHlgXFxuICAgICAgICB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uKHMsIGUpIHtcXG4gICAgICAgICAgICBpZiAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zcGxpdChzKS5maWx0ZXIoaXRlbSA9PiBpdGVtICE9PSAnJyk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3BsaXQocyk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICAgIGVudW1lcmFibGU6IGZhbHNlLFxcbiAgICB9KTtcXG5cXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoQXJyYXkucHJvdG90eXBlLCB7XFxuICAgICAgICBleGNsdWRlS2V5czoge1xcbiAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbihrZXlzLCBleGNsdWRlLCByZW5hbWVDYWxsYmFjaykge1xcbiAgICAgICAgICAgICAgICAvLyDnoa7lrprmmK/mjpLpmaTov5jmmK/lj6rkv53nlZnplK5cXG4gICAgICAgICAgICAgICAgY29uc3Qgc2hvdWxkRXhjbHVkZSA9IHR5cGVvZiBleGNsdWRlID09PSAnYm9vbGVhbicgPyBleGNsdWRlIDogdHJ1ZTtcXG4gICAgICAgICAgICAgICAgY29uc3Qga2V5c1RvSGFuZGxlID0gQXJyYXkuaXNBcnJheShrZXlzKSA/IGtleXMgOiBbXTtcXG5cXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLm1hcOmBjeWOhuaVsOe7hOS4reeahOavj+S4quWFg+e0oFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrmlbDnu4TvvIzpgJLlvZLosIPnlKhleGNsdWRlS2V5c1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaXRlbSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS5leGNsdWRlS2V5cyhleGNsdWRlLCBrZXlzLCByZW5hbWVDYWxsYmFjayk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICE9PSBudWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5pyJ6YeN5ZG95ZCN5Zue6LCD5Ye95pWw77yM5YiZ6LCD55So5a6DXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVuYW1lQ2FsbGJhY2sgPT09ICdmdW5jdGlvbicpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2tleSwgdmFsdWVdO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlcmVkRW50cmllcyA9IHNob3VsZEV4Y2x1ZGUgP1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+ICFrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSkgOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+IGtleXNUb0hhbmRsZS5pbmNsdWRlcyhrZXkpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKGZpbHRlcmVkRW50cmllcyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgICAgIH0sXFxuICAgICAgICB0cmFuc2Zvcm1LZXlzOiB7XFxuICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uKGtleU1hcHBpbmcpIHtcXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLm1hcOmBjeWOhuaVsOe7hOS4reeahOavj+S4quWFg+e0oFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrmlbDnu4TvvIzpgJLlvZLosIPnlKh0cmFuc2Zvcm1LZXlzXFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLnRyYW5zZm9ybUtleXMoa2V5TWFwcGluZyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICE9PSBudWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNmb3JtZWRFbnRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdLZXkgPSBrZXlNYXBwaW5nW2tleV0gfHwga2V5OyAvLyDlpoLmnpzplK7lnKjmmKDlsITkuK3vvIzkvb/nlKjmlrDplK7vvJvlkKbliJnkvb/nlKjljp/lp4vplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtuZXdLZXksIHZhbHVlXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKHRyYW5zZm9ybWVkRW50cmllcyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIGxldCBzb3J0b2JqID0gW1xcbiAgICAgICAgZm9udHN0eWxlKFxcXCLmraPluo9cXFwiLCB7XFxuICAgICAgICAgICAgYzogXFxcIiMxQUFEMTlcXFwiLFxcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJiXFxcIlxcbiAgICAgICAgfSksXFxuICAgICAgICBmb250c3R5bGUoXFxcIumAhuW6j1xcXCIsIHtcXG4gICAgICAgICAgICBjOiBcXFwiI0ZGMDAwMFxcXCIsXFxuICAgICAgICAgICAgdGFnczogXFxcImJcXFwiXFxuICAgICAgICB9KVxcbiAgICBdXFxuICAgIC8v5pa55rOVXFxuXFxuICAgIHZhciBzb3J0aSA9IGdldE15VmFyKFxcXCJzb3J0aVxcXCIsIFxcXCIwXFxcIik7XFxuXFxuICAgIC8vbG9nKHNvcnRvYmopXFxuICAgICQuZXh0ZW5kKHtcXG4gICAgICAgIHNwbGl0UGFnZSh0b3RhbEl0ZW1zLCBwYWdlU2l6ZSkge1xcbiAgICAgICAgICAgIHBhZ2VTaXplID0gcGFnZVNpemUgfHwgNTA7XFxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDw9IHRvdGFsSXRlbXM7IGkgKz0gcGFnZVNpemUpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGVuZCA9IGkgKyBwYWdlU2l6ZSAtIDE7XFxuICAgICAgICAgICAgICAgIGlmIChlbmQgPiB0b3RhbEl0ZW1zKSB7XFxuICAgICAgICAgICAgICAgICAgICBlbmQgPSB0b3RhbEl0ZW1zO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJlc3VsdC5wdXNoKGAke2l9LSR7ZW5kfWApO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xcbiAgICAgICAgfSxcXG4gICAgICAgIHNwbGl0QXJyYXlCeVJhbmdlcyhhcnJheSwgcmFuZ2VzKSB7XFxuICAgICAgICAgICAgLy8g5qC55o2u6IyD5Zu05ouG5YiG5pWw57uEXFxuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHJhbmdlcy5tYXAoZnVuY3Rpb24ocmFuZ2UpIHtcXG4gICAgICAgICAgICAgICAgdmFyIHBhcnRzID0gcmFuZ2Uuc3BsaXQoJy0nKS5tYXAoTnVtYmVyKTtcXG4gICAgICAgICAgICAgICAgdmFyIHN0YXJ0ID0gcGFydHNbMF0gLSAxOyAvLyDlh48x5piv5Zug5Li65pWw57uE57Si5byV5LuOMOW8gOWni1xcbiAgICAgICAgICAgICAgICB2YXIgZW5kID0gcGFydHNbMV0gLSAxO1xcbiAgICAgICAgICAgICAgICAvLyDkvb/nlKhBcnJheS5wcm90b3R5cGUuc2xpY2XmnaXojrflj5blrZDmlbDnu4RcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFycmF5LnNsaWNlKHN0YXJ0LCBlbmQgKyAxKTsgLy8g5YyF5ous57uT5p2f57Si5byV77yM5omA5Lul5YqgMVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICB9LFxcbiAgICB9KVxcblxcbiAgICBsZXQgc291cmNlID0ge307XFxuICAgIGlmIChNWV9QQVJBTVMuc291cmNlKSB7XFxuICAgICAgICBzb3VyY2UgPSBNWV9QQVJBTVMuc291cmNlO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgc291cmNlID0gcnVudGltZUNvbmZpZy5maW5kU291cmNlKE1ZX1BBUkFNUy5za2V5KTtcXG4gICAgICAgIE1ZX1BBUkFNUy5zb3VyY2UgPSBzb3VyY2U7XFxuICAgICAgICBzZXRQ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cXCIjXFxcIikubWFwKChqKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBrID0gai5zcGxpdChcXFwiJFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICAgICAgICAgIGxldCB1aWQgPSAoa1sxXSB8fCBrWzBdKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIHN0aXRsZTogdCxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICAgICAgc3VybDogdWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXNOb3ZlbD9cXFwiaGlrZXI6Ly9wYWdlL25vdmVsI2F1dG9QYWdlIyNyZWFkVGhlbWUjXFxcIjoodWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5LnJlcGxhY2UoJ1xcXCJpZFxcXCInLCAnXFxcIicgKyB1aWQgKyAnXFxcIicpKSxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgICAgICAgICAgICBpZDoga1sxXSxcXG4gICAgICAgICAgICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9KSovXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGlmIChzdHlwZSA9PSBcXFwi5ryr55S7XFxcIiB8fCBzdHlwZSA9PSBcXFwi5bCP6K+0XFxcIikge1xcblxcbiAgICAgICAgICAgICAgICB2YXIgZG93bmxvYWRsYXp5ID0gJC50b1N0cmluZygoa2V5LCBza2V5LCB0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBHTVxcbiAgICAgICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzV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gZmFsc2UpLnRyYW5zZm9ybUtleXMoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInN1cmxcXFwiOiBcXFwidXJsXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJzdGl0bGVcXFwiOiBcXFwidGl0bGVcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShjaGFwdGVyTGlzdCkpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLkuIvovb1cXFwiICsgc3R5cGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvZG93bmxvYWQudmlldyNub1JlY29yZEhpc3RvcnkjI25vUmVmcmVzaCM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYnLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2hhcHRlckxpc3Q6IFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmZvOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tOYW1lOiBpbmZvLnZvZF9uYW1lLCAvL+a8q+eUu+WQjeensCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZU5hbWU6IE1ZX1JVTEUudGl0bGUgLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29rVG9wUGljOiBpbmZvLnZvZF9waWMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlQ29kZTogZG93bmxvYWRsYXp5LFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29rSWQ6IE1ZX1BBUkFNUy5zbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmlldzogXFxcIjFcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKzlnLDkuabmnrZcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiAnaGlrZXI6Ly9wYWdlL0Jvb2tyYWNrLnZpZXcjbm9SZWNvcmRIaXN0b3J5Iz9ydWxlPeacrOWcsOi1hOa6kOeuoeeQhiZydWxlTmFtZT0nICsgTVlfUlVMRS50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHN0eXBlID09PSBcXFwi5ryr55S7XFxcIiA/IFxcXCJjb21pY1xcXCIgOiBcXFwibm92ZWxcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcGxheW9iaiA9ICQuc3BsaXRBcnJheUJ5UmFuZ2VzKHBsYXlvYmosIHBhZ2VzKTtcXG4gICAgICAgICAgICByZXR1cm4gcGxheW9iajtcXG4gICAgICAgIH0pO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmmoLml6Dmkq3mlL7mupDmiJbmkq3mlL7liJfooajlrprkvY3plJnor69cXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBNWV9QQVJBTVMudm9kSWQsXFxuICAgICAgICB9KTtcXG4gICAgICAgIGNhY2hlU2hvd1RpcHMoKTtcXG4gICAgICAgIHNldFJlc3VsdChkKTtcXG4gICAgfVxcblxcblxcbiAgICBsZXQgY3VycmVudExvY2F0aW9uID0gMDtcXG5cXG4gICAgZnVuY3Rpb24gcmVub3ZhdGVMaXN0KGxvY2F0aW9uKSB7XFxuICAgICAgICAvL2RlbGV0ZUl0ZW1CeUNscyhcXFwicGxheXBhZ2VcXFwiKTtcXG4gICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgIGlmIChwbGF5VXJsTGlzdC5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgbGV0IHBjb3VudCA9IHBsYXlVcmxMaXN0W2xvY2F0aW9uXS5sZW5ndGg7XFxuICAgICAgICBsZXQgbGlzdCA9IHBsYXlVcmxMaXN0W2xvY2F0aW9uXVtwYWdlbnVtXTtcXG4gICAgICAgIGlmICghbGlzdCkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBwYWdlbnVtOyBpID49IDA7IGktLSkge1xcbiAgICAgICAgICAgICAgICBsaXN0ID0gcGxheVVybExpc3RbbG9jYXRpb25dW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAobGlzdCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IGk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChnZXRNeVZhcihcXFwic29ydGlcXFwiLCBcXFwiMFxcXCIpID09IDEpIHtcXG4gICAgICAgICAgICBsaXN0LnJldmVyc2UoKTtcXG4gICAgICAgIH1cXG4gICAgICAgICQuZXh0ZW5kKHtcXG4gICAgICAgICAgICB0ZW1wX2xpc3Q6IHBsYXlVcmxMaXN0W2xvY2F0aW9uXSxcXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgcGxheXAgPSBwbGF5cGFnZXNbbG9jYXRpb25dO1xcblxcbiAgICAgICAgaWYgKHBsYXlwICYmIHBsYXlwLmxlbmd0aCA+IDEpIHtcXG4gICAgICAgICAgICBsZXQgdGVtcCA9IHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0XzEnLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhZ2VhcnIgPSBwbGF5cC5tYXAoKHgsIGkpID0+IGkgPT0gcGFnZW51bSA/ICfigJzigJzigJ3igJ0nICsgeC5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogeCk7XFxuICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpXFxuICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5cGFnZWxpbmVcXFwiLCBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+S4iuS4gOmhtScsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bS0tO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHBsYXlwW3BhZ2VudW1dLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChwYWdlYXJyLCAzKS5zZWxlY3QoKGxvY2F0aW9uKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICB9LCBsb2NhdGlvbiksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6ICfkuIvkuIDpobUnLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgobG9jYXRpb24sIHBjb3VudCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAocGFnZW51bSA+PSBwY291bnQgLSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IDA7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0rKztcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKHBhZ2VudW0pKTtcXG4gICAgICAgICAgICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4ge30pKGxvY2F0aW9uKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGxvY2F0aW9uLCBwY291bnQpLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XSlcXG4gICAgICAgICAgICAvKnBsYXlwID0gcGxheXAubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIHRlbXAsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIChwYWdlbnVtID09IGkgPyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KSxcXG4gICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiKSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5bGlzdFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlsaXN0c1xcXCIsICQudGVtcF9saXN0W2ldKTtcXG4gICAgICAgICAgICAgICAgICAgZmluZEl0ZW1zQnlDbHMoXFxcInBsYXlwYWdlXFxcIikuZm9yRWFjaCgoeCwgaWkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSB4LnRpdGxlLnJlcGxhY2UoL+KAmHzigJl84oCcfOKAnXw8W14+XSs+L2csIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICBpZiAoaWkgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSAn4oCc4oCc4oCd4oCdJyArIHRpdGxlLmZvbnRjb2xvcihcXFwicmVkXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oeC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICB9LCBpKSxcXG4gICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgIGlkOiBcXFwicGFnZW51bVxcXCIgKyBpLFxcbiAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheXBhZ2VsaW5lXFxcIiwgcGxheXApKi9cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChsaXN0KSB7XFxuICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCBsaXN0KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxvY2F0aW9uQFxcXCIgKyBjdXJyZW50TG9jYXRpb24sIHtcXG4gICAgICAgICAgICB0aXRsZTogZnJvbVtjdXJyZW50TG9jYXRpb25dLFxcbiAgICAgICAgfSk7XFxuICAgICAgICB1cGRhdGVJdGVtKFxcXCJsb2NhdGlvbkBcXFwiICsgbG9jYXRpb24sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyBmcm9tW2xvY2F0aW9uXSArIFxcXCLigJ3igJ1cXFwiLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBjdXJyZW50TG9jYXRpb24gPSBsb2NhdGlvbjtcXG4gICAgfVxcblxcbiAgICBHTS5wdXQoXFxcInJlbm92YXRlTGlzdFxcXCIsIHJlbm92YXRlTGlzdCk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImJpZ19ibGFua19ibG9ja1xcXCJcXG4gICAgfSk7XFxuICAgIGlmIChmcm9tLmxlbmd0aCkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImJpZ19ibGFua19ibG9ja1xcXCIsXFxuICAgICAgICB9KVxcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc29ydG9ialtzb3J0aV0sXFxuICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChzbykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgc2kgPSBnZXRNeVZhcihcXFwic29ydGlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgaWkgPSAoc2kgPT0gXFxcIjBcXFwiID8gXFxcIjFcXFwiIDogXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwiQHNvcnRcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogc29baWldXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHZhciBwbGF5cyA9IGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5bGlzdFxcXCIpLnJldmVyc2UoKS5tYXAoeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICB4LmNvbF90eXBlID0geC50eXBlO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHg7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgcGxheXMpO1xcblxcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwic29ydGlcXFwiLCBpaSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgc29ydG9iaiksXFxuICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBpZDogXFxcIkBzb3J0XFxcIixcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgICAgZm9yIChsZXQgaSBpbiBmcm9tKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGZyb21baV0sXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaSwgaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkoaSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBpLCBpZCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpZDogXFxcImxvY2F0aW9uQFxcXCIgKyBpXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICAvL2NvbnNvbGUubG9nKHBsYXlVcmxMaXN0KTtcXG4gICAgLyppZiAocGxheVVybExpc3QubGVuZ3RoKSB7XFxuICAgICAgdmFyIGVqb2JqID0ge1xcbiAgICAgICAgXFxcImxpc3RcXFwiOiBwbGF5VXJsTGlzdCxcXG4gICAgICAgIFxcXCJ0YWJcXFwiOiBmcm9tLm1hcCgoeCwgaSkgPT4gZnJvbVtpXSlcXG4gICAgICB9O1xcbiAgICAgIOWIneWni+WMlihkLCBlam9iailcXG4gICAgfSBlbHNlIHtcXG4gICAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmmoLml6Dmkq3mlL7mupBcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbiAgICAgICAgdXJsOiBNWV9QQVJBTVMudm9kSWQsXFxuICAgICAgfSk7XFxuICAgIH0qL1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VsaW5lXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KVxcblxcblxcbiAgICB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HBhZ2VUaXRsZTogXFxcIuaWsOWinuino+aekFxcXCJcXG4gICAgfVxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YiG5LqrXFxcIixcXG4gICAgdXJsOiAkKFxcXCItMVxcXCIsIFxcXCLovpPlhaXkvaDopoHliIbkuqvop6PmnpDnmoTluo/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiAkKFtcXFwiSElLRVJcXFwiLCBcXFwiVFhUXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSwgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgobW8sIGluZGV4cywgZXh0KSA9PiB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gdXAocnVsZXM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3J5IyNub1JlZnJlc2gjXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5YiG5LqrXFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgb3BzID0gZ2V0UGFzdGVzKCk7XFxuICAgICAgICAgICAgICAgIG9wcy51bnNoaWZ0KFxcXCLlrozmlbTlj6Pku6RcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQob3BzLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKClbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS51c2VyID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlKSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChuYW1lLCBydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG55WM77yM44CMXFxcIiArIG5hbWUgKyBcXFwi44CNRFJQWeino+aekO+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNl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dGxlOiBcXFwi5Yig6ZmkXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgdXJsSW5kZXgpID0+IHtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mraTpobnml6Dms5XliKDpmaRcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHVybEluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ato+WcqOabtOaWsOino+aekO+8jOWIoOmZpOivt+S7juino+aekOeuoeeQhui/m+WFpVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liKDpmaTmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIGluZGV4KVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgIH0sIGluZGV4LCB1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yA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICAgICAgaWYgKGhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgICAgICBqc1xcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXG4gICAgICAgIH0pO1xcbiAgICB9KSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5L+d5a2YXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgaXNJbXBvcnQpID0+IHtcXG4gICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcInBzX25hbWVcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCFuYW1lKSB7X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cXCIsIFxcXCJXRUJcXFwiKTtcXG4gICAgICAgIGxldCBtZXRob2QgPSBnZXRNeVZhcihcXFwicHNfbWV0aG9kXFxcIiwgXFxcIkdFVFxcXCIpO1xcbiAgICAgICAgbGV0IGpzb25QYXRoID0gZ2V0TXlWYXIoXFxcInBzX2pzb25QYXRoXFxcIiwgXFxcIlxcXCIpLnRyaW0oKSB8fCB2b2lkIDA7XFxuICAgICAgICBsZXQganMgPSBnZXRNeVZhcihcXFwicHNfanNcXFwiLCBcXFwiXFxcIikgfHwgdm9pZCAwO1xcbiAgICAgICAgaWYgKHJ1blR5cGUgPT09IFxcXCJKU09OXFxcIiAmJiAhanNvblBhdGgpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlNPTuaooeW8j+S4i+W/hemhu+Whq2pzb25QYXRoXFxcIjtcXG4gICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PT0gXFxcIkpTXFxcIiAmJiAhanMpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlPmqKHlvI/kuIvlv4Xpobvloatqc1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG9iajEgPSB7XFxuICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgIGpzXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcbiAgICAgICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbih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gICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIuaWsOWinu+8mlxcXCIgKyBuZXdJICsgXFxcIiDopobnm5bmm7TmlrDvvJpcXFwiICsgKHJ1bGVzLmxlbmd0aCAtIG5ld0kpKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl5aSx6LSlXFxcIik7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gaW1wb3J0UnVsZShwYXNzK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biAgICBpZiAocGFyc2UuaGFzT3duUHJvcGVydHkoXFxcImhlYWRlclxcXCIpKSB7XFxuICAgICAgICBleHRyYVtcXFwidWFcXFwiXSA9IHBhcnNlW1xcXCJoZWFkZXJcXFwiXVtcXFwiVXNlci1BZ2VudFxcXCJdO1xcbiAgICAgICAgLy9leHRyYVtcXFwicmVkaXJlY3RcXFwiXT1mYWxzZTtcXG4gICAgICAgIC8qZXh0cmFbXFxcImpzXFxcIl0gPSAkLnRvU3RyaW5nKChqcykgPT4ge1xcbiAgICAgICAgICBldmFsKGpzKVxcbiAgICAgICAgICBmYmEubG9nKG5hdmlnYXRvci51c2VyQWdlbnQpXFxuICAgICAgICAgIGZiYS5sb2cobG9jYXRpb24uaHJlZilcXG4gICAgICAgIH0sICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkobmF2aWdhdG9yLCAndXNlckFnZW50Jywge1xcbiAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgICAgcmV0dXJuICdNeS1DdXN0b20tVUEtU3RyaW5nJztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH0pO1xcbiAgICAgICAgfSkpKi9cXG4gICAgfVxcbiAgICBpZiAocGFyc2Vfb2JqLmhhc093blByb3BlcnR5KFxcXCJjdXN0b21fcmVnZXhcXFwiKSkge1xcbiAgICAgICAgbGV0IGN1cnJlbnQgPSBwYXJzZV9vYmpbXFxcImRlZlJ1bGVzXFxcIl07XFxuICAgICAgICBleHRyYVtcXFwidmlkZW9SdWxlc1xcXCJdID0gY3VycmVudC5jb25jYXQocGFyc2Vfb2JqLmN1c3RvbV9yZWdleC5zcGxpdCgvXFxcXHwvZykuZmlsdGVyKGUgPT4gZSkpXFxuICAgIH1cXG4gICAgaWYgKHBhcnNlLmhhc093blByb3BlcnR5KFxcXCJqc1xcXCIpICYmIHBhcnNlLmpzICE9IFxcXCJcXFwiKSB7XFxuICAg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JyaWNoX3RleHRcXFwiLFxcbiAgICAgICAgICAgICAgICB0aXRsZTogKFxcXCI8c3Ryb25nPlxcXCIgKyBkYXRhLnRpdGxlICsgXFxcIjwvc3Ryb25nPlxcXCIpLmJpZygpLFxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGNvbnRlbnQsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAncmljaF90ZXh0JyxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIHRleHRTaXplOiAxOCxcXG4gICAgICAgICAgICAgICAgICAgIGNsaWNrOiB0cnVlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBzZXRSZXN1bHQobGF5b3V0KTtcXG4gICAgICAgIH0sIHBsYXkudXJsLnJlcGxhY2UoXFxcIm5vdmVsOi8vXFxcIiwgXFxcIlxcXCIpKTtcXG4gICAgfVxcbiAgICAvL2xvZyhwbGF5KTtcXG4gICAgaWYgKHBsYXkucGFyc2UgPT09IDEgfHwgcGxheS5qeCA9PT0gMSkge1xcbiAgICAgICAgaWYgKHBsYXkudXJsLnN0YXJ0c1dpdGgoXFxcIm1hZ25ldDpcXFwiKSkge1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5LnVybDtcXG4gICAgICAgIH1cXG4gICAgICAgIGNhcnJ5SnMocGxheSwgaWQpO1xcbiAgICAgICAgaWYgKHBsYXkuanggPT09IDEgfHwgKGlzb2ZmaWNpYWwocGxheS51cmwpICYmIChwbGF5LmZsYWcgfHwgaW5wdXRbMV0pKSkge1xcbiAgICAgICAgICAgIHJldHVybiB1c2VQYXJzZXMocGxheS51cmwsIHBsYXkuZmxhZyB8fCBpbnB1dFsxXSk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcInZpZGVvOi8vXFxcIiArIHBsYXkudX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XCIpKSBjb250aW51ZTtcXG4gICAgICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBydWxlID0gZmV0Y2goYGh0dHBzOi8vcmF3LmdpdG1pcnJvci5jb20vJHtyb3BlfS9tYXN0ZXIvJHtzcGF0aH1gKTtcXG4gICAgICAgICAgICBpZiAoISgoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkgJiYgIWZpbGVFeGlzdChwYXRoICsgaXQubmFtZSkpKSB7XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgaXQubmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBgJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAndHlwZSc6IDMsXFxuICAgICAgICAgICAgICAgICAgICAnYXBpJzogJy4uL2xpYnMvZHJweTIuanMnLFxcbiAgICAgICAgICAgICAgICAgICAgJ3NlYXJjaGFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdmaWx0ZXJhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdleHQnOiBcXFwiLi9cXFwiICsgaXQubmFtZSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGNvdW50Kys7XFxuICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goaXQubmFtZSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XF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V0IGNvdW50ID0gMDtcXG4gICAgbGV0IGkgPSAwO1xcbiAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgZm9yIChsZXQgaXQgb2YgYXJyKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmICgoU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLm1pbi5qc1xcXCIpIHx8IFN0cmluZyhpdC5hcGkpLmluY2x1ZGVzKFxcXCJkcnB5Mi5qc1xcXCIpKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0LmV4dC5lbmRzV2l0aChcXFwiLmpzXFxcIikgPyBkZWNvZGVVUklDb21wb25lbnQoaXQuZXh0LnNwbGl0KFxcXCIvXFxcIikuYXQoLTEpKSA6IChpdC5uYW1lICsgXFxcIi5qc1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZTtcXG4gICAgICAgICAgICAgICAgaWYgKFN0cmluZyhpdC5leHQpLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3QoaXQuZXh0KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpdC5leHQgPSBcXFwiLi9cXFwiICsgbmFtZTtcXG4gICAgICAgICAgICAgICAgaWYgKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH07XFxuIC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lTGlzdCA9IGdlbmVyYXRlQ29uZmlnQnlHaXRodWIoY29uZmlnLnBhdGgpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImdpdGh1YkRpclxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGZldGNoKGNvbmZpZy5wYXRoKSB8fCBcXFwie31cXFwiKSk7XFxuICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8ICFqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAvL2NvbmZpZy5jS2V5ID0gc291cmNlTGlzd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0LnB1c2goe1xcbiAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgIHRpdGxlOiBcXFwi5o+Q56S6XFxcIixcXG4gICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vc3lzdGVtLzI3LnBuZ1xcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBjb25zdCBoaWtlclBvcCA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9Njk2NlxcXCIpO1xcbiAgICAgICAgbGV0IHBvcCA9IGhpa2VyUG9wLmluZm9Cb3R0b20oe1xcbiAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLor6bnu4ZcXFwiLFxcbiAgICAgICAgICAgIG9wdGlvbnM6IFtcXG4gICAgICAgICAgICAgICAgXFxcIuesrOS4gOepuijlkI3np7ApOuaWueS+v+S4i+asoeaJvuWIsFxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzlnLDntKLlvJXlnLDlnYBdOumAieaLqUpTT04vVVJM6YCJ6aG577yM54K55Ye75peB6L6555qE6YCJ5oup5Y+v5Lul5rWP6KeI5pys5Zyw5paH5Lu26YCJ5oup5pys5Zyw5YyF55qELmpzb27ntKLlvJXmlofku7bljbPlj6/jgIJcXFxcbijms6jmhI/vvJrkvb/nlKjmraTnp43mlrnlvI/vvIzlnKjmnKzlnLDmlofku7blpLnlhoXmlrDlop7miJbliKDpmaQuanPmupDml7bpnIDopoHoh6rooYzliJrliJouanNvbumFjee9ruaWh+S7tilcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5aGr6L+c56iL5Zyw5Z2AXTrnm7TmjqXloavlhpnov5znqIvpk77mjqXljbP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CIjMTVCNzZDXFxcIikgOiB4KSxcXG4gICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSkgPT4ge1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcInNlbGVjdF9jb25maWdfbW9kZVxcXCIsIGkgKyBcXFwiXFxcIik7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaSksXFxuICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICB9KVxcbn0pXFxuXFxuXFxubGV0IHBhdGggPSBqb2luVXJsKGdldFBhdGgoXFxcImhpa2VyOi8vZmlsZXMvXFxcIiksIFxcXCIuLi9cXFwiLnJlcGVhdCg1KSkuc2xpY2UoNyk7XFxuXFxuaWYgKHNlbGVjdF9tb2RlID09IFxcXCIwXFxcIikge1xcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIumAieaLqVxcXCIsXFxuICAgICAgICB1cmw6IEpTT04uc3RyaW5naWZ5KGYuZmlsZVNlbGVjdGlvblVyaSh7XFxuICAgICAgICAgICAgY2FsbGJhY2s6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0ID0gZmluZEl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIpLmV4dHJhO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih0YXJnZXQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFBBVEhcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgIC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bGRlclxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHRhcmdldCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHJvb3REaXJQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIHBhdHRlcm46IDEsXFxuICAgICAgICAgICAgLy9maWxlVHlwZTogXFxcIi5qc29uXFxcIixcXG4gICAgICAgIH0pKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIui3r+W+hCjmlofku7blpLkpXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgaWQ6IFxcXCJkcnB5SGlrZXJfY29uZmlnX2ZvbGRlclxcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxufVxcbmxheW91dC5wdXNoKHtcXG4gICAgY29sX3R5cGU6IFxcXCJsaW5lX2JsYW5rXFxcIlxcbn0pO1xcbmxheW91dC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLnoa7orqRcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGNvYmopID0+IHtcXG4gICAgICAgIGxldCBwYXRoID0gZ2V0TXlWYXIoXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcImRycHlIaWtlcl9jb25maWdfbmFtZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgIGlmICghKHBhdGggJiYgbmFtZSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5Y+v5Li656m6XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIHBhdGggPSBwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSA/IHBhdGggOiBwYXRoLnN0YXJ0c1dpdGgoXFxcIi9cXFwiKSA/IChcXFwiZmlsZTovL1xcXCIgKyBwYXRoKSA6IHBhdGg7XFxuICAgICAgICAvL2xvZyhwYXRoKVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIH0pKSB7XFxuICAgICAgICAgICAgICAgIGNvYmouY29uZmlncy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBjbGV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Xp5UnVsZSgocCkgPT4ge1xcbiAgICAgICAgICAgIC8vbG9nKHApXFxuICAgICAgICAgICAgZnVuY3Rpb24gdW5pcXVlKGFycikge1xcbiAgICAgICAgICAgICAgICBjb25zdCByZXMgPSBuZXcgTWFwKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBhcnIuZmlsdGVyKChhKSA9PiAhcmVzLmhhcyhhKSAmJiByZXMuc2V0KGEsIDEpKVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB2YXIgcmVzdWx0cyA9IFtdO1xcbiAgICAgICAgICAgIGlmIChwLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/ml6DlnLDlnYBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsaXN0ID0gcC5tYXAoeCA9PiB4LnBhdGgpO1xcbiAgICAgICAgICAgIHZhciB0YXNrID0gZnVuY3Rpb24ob2JqKSB7XFxuICAgICAgICAgICAgICAgIGxldCBzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzRmlsZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGNvdW50ID0gMDtcXG5cXG4gICAgICAgICAgICAgICAgZnVuY3Rpb24gZmlsdGVyT3RoZXIobGlzdCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpc3QuZmlsdGVyKGl0ID0+IFN0cmluZyhpdC5hcGkpLmluY2x1ZGVzKFxcXCJkcnB5Mi5taW4uanNcXFwiKSB8fCBTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIuanNcXFwiKSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAob2JqLnVybC5zdGFydHNXaXRoKFxcXCJmaWxlOlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29kZSA9IFxcXCJub1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IG9iai51cmwucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkaXIgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpci5pc0RpcmVjdG9yeSgpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gZGlyLmxpc3RGaWxlcygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGYgb2YgZmxpc3QpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8g5qOA5p+l5paH5Lu25ZCN5piv5ZCm5LulLmpz57uT5bC+XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmLmlzRmlsZSgpICYmIGYuZ2V0TmFtZSgpLnRvTG93ZXJDYXNlKCkuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc0ZpbGVzLnB1c2goZik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge31cXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IG9iai51cmwsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXg6IG9iai5pXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdmFyIGogPSBKU09OLnBhcnNlKGZldGNoKG9iai51cmwsIHtcXG4gICAgICAgICAgICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICBsZXQgZSA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICAgICAgICAgIGlmIChvYmoudXJsLmluY2x1ZGVzKFxcXCJnaXRodWIuY29tXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2gge31cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuXFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICB0aW1lOiBjLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXG4gICAgICAgICAgICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgbGV0IHRhc2tzID0gbGlzdC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgICAgICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiB4LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGk6IGkgLSAxLFxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxuICAgICAgICAgICAgYmUodGFza3MsIHtcXG4gICAgICAgICAgICAgICAgZnVuYzogZnVuY3Rpb24ob2JqLCBpZCwgZXJyb3IsIHRhc2tSZXN1bHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9iai5yZXN1bHRzLnB1c2godGFza1Jlc3VsdClcXG4gICAgICAgICAgICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNvdW50ID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmo4DmtYvkuK0uLi7liankvZnlnLDlnYDvvJpcXFwiICsgY291bnQpXFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgICAgICAgICAgICBoaTogJ2NjYycsXFxuICAgICAgICAgICAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBzdWNjZXNzKTtcXG4gICAgICAgICAgICAvL2xvZyhyZXN1bHRzKVxcbiAgICAgICAgICAgIHJlc3VsdHMgPSByZXN1bHRzLmZpbHRlcihmID0+IGYpO1xcbiAgICAgICAgICAgIHJlc3VsdHMuZm9yRWFjaCgoeCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGZpbmRJdGVtKFxcXCJwYXRoXFxcIiArIHguaW5kZXgpO1xcbiAgICAgICAgICAgICAgICBsZXQgcmVnZXggPSAvKOWQjeensDouKj8pKFxcXFxzKyk/XFxcXG4vZztcXG4gICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gXFxcIuWQjeensDpcXFwiICsgcFt4LmluZGV4XS5uYW1lICsgXFxcIiBcXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgdXJsID0gcFt4LmluZGV4XS5wYXRoO1xcbiAgICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCBjb3VudCA9IHguY291bnQgIT0gMCA/IFxcXCIg5rqQ5pWw6YePOlxcXCIgKyB4LmNvdW50IDogXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIGlmICgvbm8vLnRlc3QoeC5jb2RlKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gaXRlbS50aXRsZS5yZXBsYWNlKHJlZ2V4LCB0aXRsZSArIFxcXCLphY3nva7mnInor69cXFwiLmZvbnRjb2xvcihcXFwicmVkXFxcIikgKyBcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgvXigtMXwwfDQwNCkvLnRlc3QoeC5jb2RlKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gaXRlbS50aXRsZS5yZXBsYWNlKHJlZ2V4LCB0aXRsZSArIFxcXCLml6Dms5Xorr/pl65cXFwiLmZvbnRjb2xvcihcXFwicmVkXFxcIikgKyBcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgvXjIwMC8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBpdGVtLnRpdGxlLnJlcGxhY2UocmVnZXgsIHRpdGxlICsgXFxcIumAmuiur+ato+W4uFxcXCIuZm9udGNvbG9yKFxcXCIjM0NCMzcxXFxcIikgKyBcXFwiICDlu7bov586XFxcIiArIHgudGltZSArIGNvdW50ICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL3VybCA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gaXRlbS50aXRsZS5yZXBsYWNlKHJlZ2V4LCB0aXRsZSArIFxcXCLphY3nva7mraPnoa5cXFwiLmZvbnRjb2xvcihcXFwiIzNDQjM3MVxcXCIpICsgY291bnQgKyBcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdXJsID0gaXRlbS51cmw7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogbXNnLFxcbiAgICAgICAgICAgICAgICAgICAgLy91cmw6IHVybCxcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICB9LCBwYXRoY29uZmlncyksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgIH0pXFxuICAgIHBhdGhjb25maWdzLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBsb25nQyA9IFt7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLlkI3np7BcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtLCBwLCBjKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gYy5maW5kSW5kZXgoeCA9PiB4Lm5hbWUgPT0gaXRlbS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGNbaV0ubmFtZSwgXFxcIui+k+WFpeaWsOWQjeensFxcXCIpLmlucHV0KChjLCBwLCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY1tpXS5uYW1lID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZUZpbGUocCwgSlNPTi5zdHJpbmdpZnkoYykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9LCBjLCBwLCBpKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSwgY3BhdGgsIHBhdGhjb25maWdzKVxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi6Lev5b6EXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSwgcCwgYykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGMuZmluZEluZGV4KHggPT4geC5uYW1lID09IGl0ZW0ubmFtZSk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChjW2ldLnBhdGgsIFxcXCLovpPlhaXmlrDot6/lvoRcXFwiKS5pbnB1dCgoYywgcCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNbaV0ucGF0aCA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYywgcCwgaSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGl0ZW0sIGNwYXRoLCBwYXRoY29uZmlncylcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0sIHAsIGMpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBjLmZpbmRJbmRleCh4ID0+IHgubmFtZSA9PSBpdGVtLm5hbWUpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYy5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlRmlsZShwLCBKU09OLnN0cmluZ2lmeShjKSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSwgY3BhdGgsIHBhdGhjb25maWdzKVxcbiAgICAgICAgfV1cXG4gICAgICAgIGlmIChpdGVtLnBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgbG9uZ0MucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6/6ZeuXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLnBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ3ZWI6Ly9cXFwiICsgaXRlbS5wYXRoO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpdGVtKVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgICAgICBsZXQgY3VycmVudCA9IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKGN1cnJlbnRjb25maWcgJiYgY3VycmVudGNvbmZpZy5oYXNPd25Qcm9wZXJ0eShcXFwicGF0aFxcXCIpKSB7XFxuICAgICAgICAgICAgaWYgKGl0ZW0ucGF0aCA9PSBjdXJyZW50Y29uZmlnLnBhdGgpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudCA9IFxcXCLinqHvuI9cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyBcXFwiPHNtYWxsPlxcXCIgKyBjdXJyZW50ICsgXFxcIuWQjeensDpcXFwiICsgaXRlbS5uYW1lICsgXFxcIlxcXFxu6Lev5b6EOlxcXCIgKyBpdGVtLnBhdGggKyBcXFwiPC9zbWFsbD5cXFwiLFxcbiAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZShpdGVtID0+IHtcXG4gICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJub19sb2FkaW5nXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgICAgICB9ID0gaXRlbTtcXG4gICAgICAgICAgICAgICAgaWYgKHBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgfSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuY2xlYXIoKTtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJDaGFuZ2VTb3VyY2VQb3BcXFwiKS5zaG93KDEwMCk7XFxuICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5aSx6LSlXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGl0ZW0pLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBpZDogJ3BhdGgnICsgaSxcXG4gICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBsb25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gICAgIGV4dHJhSW5wdXRCb3g6IG5ldyBoaWtlclBvcC5SZXNFeHRyYUlucHV0Qm94KHtcXG4gICAgICAgICAgICBoaW50OiBcXFwi5rqQ5YWz6ZSu5a2XXFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIm9rXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZSh0ZXh0LCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgLy9sb2coXFxcIm9uQ2hhbmdlOlxcXCIrdGV4dClcXG4gICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbmFtZXMuZmlsdGVyKHggPT4geC5pbmNsdWRlcyh0ZXh0KSk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBjbGljayhzLCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgLy90b2FzdChzKTtcXG4gICAgICAgICAgICAgICAgLy9sb2cobWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfSksXFxuICAgICAgICBsb25nQ2xpY2socywgaSkge1xcbiAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliIbkuqvop4bpopHmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIkpT5paH5Lu25YiG5LqrXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSxcXG4gICAgICAgICAgICAgICAgY29sOiAyLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhuYW1lID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBuYW1lID0gcGF0aC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gZmV0Y2gocGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZW5jb2RlTW9kZSA9IGdldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChlbmNvZGVNb2RlICYmIC92YXIgcnVsZXxbXFxcXHU0RTAwLVxcXFx1OUZBNV0rfGZ1bmN0aW9ufGxldCB8dmFyIHxjb25zdCB8XFxcXCh8XFxcXCl8XFxcInwnLy50ZXN0KHJ1bGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kZU1vZGUgPT09IFxcXCJHemlwXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgR1pJUCA9ICQucmVxdWlyZShcXFwiR1pJUFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gR1pJUC56aXAocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbmNvZGVNb2RlID09PSBcXFwiQmFzZTY0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYmFzZTY0RW5jb2RlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlmICghcnVsZSkgcmV0dXJuIFxcXCJ0b2FzdDovL+iOt+WPluWksei0pVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL1xcXCIgKyBwbmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJzaGFyZTovL2hpa2VyOi8vZmlsZXMvX2NhY2hlL1xcXCIgKyBwbmFtZTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IHNoYXJlUGFzdGUoYmFzZTY0RW5jb2RlKHJ1bGUpLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8v5rW36ZiU6KeG55WM77yMRFJQWeinhumikea6kOOAjFxcXCIgKyBuYW1lICsgXFxcIuOAjeWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgdXJsICsgXFxcIiRcXFwiICsgcG5hbWUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQsIHRydWUpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgcy5yZXBsYWNlKC9b4oCZ4oCYXS9nLCBcXFwiXFxcIikpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9LFxcbiAgICAgICAgY2xpY2socywgaSwgbWFuYWdlKSB7XFxuICAgICAgICAgICAgcG9wLmRpc21pc3MoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJub19sb2FkaW5nXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAvLyBtYW5hZ2UubGlzdC5mb3JFYWNoKCh2LCBpaSkgPT4gKFxcbiAgICAgICAgICAgIC8vICAgbWFuYWdlLmxpc3RbaWldID0gaSA9PT0gaWkgPyBcXFwi4oCY4oCYXFxcIiArIG5hbWVzW2lpXSArIFxcXCLigJnigJlcXFwiIDogbmFtZXNbaWldLnJlcGxhY2UoL1vigJnigJhdL2csIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIC8vICkpO1xcbiAgICAgICAgICAgIGxldCBuYW1lID0gbWFuYWdlLmxpc3RbaV0ucmVwbGFjZSgvW+KAmeKAmF0vZywgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmIChuYW1lID09IHNvdXJjZS5uYW1lKSB7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgIGxldCBrZXkgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSkua2V5O1xcblxcbiAgICAgICAgICAgIC8vbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIGxldCBzb3VyY2VOYW1lTGlzdCA9IHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShrZXkpO1xcbiAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImNhdGVpXFxcIik7XFxuICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwiY2F0ZV9vYmpcXFwiKTtcXG4gICAgICAgICAgICBjbGVhck15VmFyKFxcXCJpc2hvbWVcXFwiKTtcXG4gICAgICAgICAgICBjbGVhck15VmFyKFxcXCJsaW5rc1xcXCIpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuXFxuICAgICAgICB9LFxcbiAgICAgICAgbWVudUNsaWNrKG1hbmFnZSkge1xcbiAgICAgICAgICAgIGhpa2VyUG9wLnNlbGVjdENlbnRlcih7XFxuICAgICAgICAgICAgICAgIG9wdGlvbnM6IFtcXFwi5pS55Y+Y5qC35byPXFxcIiwgXFxcIuetm+mAiea6kFxcXCIsIFxcXCLoh6rnhLbmjpLluo86XFxcIiArIChnZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpID09IFxcXCJcXFwiID8gXFxcIuWFs+mXrVxcXCIgOiBcXFwi5ZCv55SoXFxcIiksIFxcXCLlgJLluo9cXFwiLCBcXFwi5Yi35paw6YWN572uXFxcIiwgXFxcIuWIhuS6q+aXtue8lueggTpcXFwiICsgZ2V0SXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIiwgXFxcIuS4jee8lueggVxcXCIpXSxcXG4gICAgICAgICAgICAgICAgY29sdW1uczogMixcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLor7fpgInmi6lcXFwiLFxcbiAgICAgICAgICAgICAgICBjbGljayhzLCBpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogMztcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaW50OiBcXFwi5rqQ5YWz6ZSu5a2XXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKS5tYXAoeCA9PiB4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbGlzdC5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5hdHVyYWwgPSBnZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXR1cmFsID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3Quc29ydChuYXR1cmFsU29ydCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lcy5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBhcnJheURpZmZlcmVuY2UoYXJyMSwgYXJyMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKGFycjIubWFwKGl0ZW0gPT4gW2l0ZW0ua2V5LCBpdGVtXSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5maWx0ZXIoaXRlbSA9PiAhbWFwLmhhcyhpdGVtLmtleSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKENrZXkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNmZyA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudENvbmZpZygpXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjZmc7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRTb3VyY2UoQ2tleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5zb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDAgfHwgZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuaWsOWinjpcXFwiICsgYWxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIuaWsOWinlxcXCIgKyBhbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuenu+mZpDpcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIiDnp7vpmaRcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2Uuc2V0VGl0bGUoXFxcIumAieaLqeinhumikea6kCDlvZPliY3lhbE6XFxcIiArIG1hbmFnZS5saXN0Lmxlbmd0aCArIFxcXCLkuKrop4bpopHmupBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QobXNnICsgXFxcIiDmm7TlpJror6bmg4XnnItsb2dcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChcXFwi5bey5Yi35pawXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi57yW56CB57G75Z6LXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uczogW1xcXCLkuI3nvJbnoIFcXFwiLCBcXFwiR3ppcFxcXCIsIFxcXCJCYXNlNjRcXFwiXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzaGFyZV9lbmNvZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9KTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJkcnB5566h55CGXCIsXCJwYXRoXCI6XCJEcnB5TWFuYWdlXCIsXCJydWxlXCI6XCJqczpcXG5jb25zdCBKU0VuZ2luZSA9IGNvbS5leGFtcGxlLmhpa2Vydmlldy5zZXJ2aWNlLnBhcnNlci5KU0VuZ2luZTtcXG5jb25zdCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuY29uc3QgZHJweU1hcCA9IG5ldyBNYXAoKTtcXG5jb25zdCBHTWtleSA9IG1vZHVsZS5pbXBvcnRQYXJhbTtcXG4vL2xvZyhcXFwi5Yid5aeL5YyWRHJweU1hbmFnZVxcXCIpO1xcbmNvbnN0IHByb3h5U2VtYXBob3JlID0gbmV3IGphdmEudXRpbC5jb25jdXJyZW50LlNlbWFwaG9yZSgzKTtcXG5cXG5mdW5jdGlvbiBidWlsZEpzRW52KHRpY2tldCkge1xcbiAgICBsZXQgY29kZSA9IFN0cmluZy5yYXcgYFxcbiA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U1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuivt+axgjpcXFwiICsga2V5KVxcbiAgICAgICAgICAgIGRlbChBcnJheS5mcm9tKGRycHlNYXAua2V5cygpKS5hdCgwKSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2VzKCkuZmluZCh2ID0+IHYua2V5ID09PSBrZXkpO1xcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpKTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKGRycHkuZ2V0UnVsZShcXFwicHJveHlfcnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBQcm94eSA9ICQucmVxdWlyZShcXFwiTG9jYWxQcm94eVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcHJveHlVcmwgPSBQcm94eS5zdGFydFByb3h5KE1ZX1JVTEUudGl0bGUsIEdNLmdldFNlbGZLZXkoKSk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJQcm94eV9VcmxcXFwiLCBwcm94eVVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuLy9zb3VyY2UuZXh05b+F6aG75Li657ud5a+56Lev5b6EXFxuZnVuY3Rpb24gZ2V0QnlTb3VyY2Uoc291cmNlKSB7XFxuICAgIHJldHVybiBzeW5jKCgpID0+IHtcXG4gICAgICAgIGxldCBrZXkgPSBzb3VyY2Uua2V5O1xcbiAgICAgICAgLy9sb2coZHJweU1hcC5zaXplKVxcbiAgICAgICAgaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChkcnB5TWFwLnNpemUgPj0gNSkge1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHNvdXJjZS5leHQpO1xcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gcnVuUHJveHkoZHJweSwgYXJncykge1xcbiAgICBpZiAodHlwZW9mIGRycHkucHJveHkgPT09IFxcXCJmdW5jdGlvblxcXCIpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTEgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIHByb3h5U2VtYXBob3JlLmFjcXVpcmUoKTtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMiA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgLy9sb2coXFxcIjHnrYnlvoXml7bpl7Q6XFxcIiArICh0aW1lMiAtIHRpbWUxKSArI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iAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDEpIHtcXG4gICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgY29udGVudDogXFxcIui+k+WFpeWFs+mUruWtlyDnqbrmmL7npLrlhajpg6hcXFwiLFxcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFwi4oCc4oCc4oCd4oCdXFxcIiArICh2Lm5hbWUgKyBcXFwiXFxcIikuZm9udGNvbG9yKFxcXCIjMDA5OTY2XFxcIikgOiB2Lm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcblxcblxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2Uuc29ydCgoYSwgYikgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcblxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxuICAgICAgICAgICAgbGV0IHRlbWxpc3QgPSBzZWFyY2hBbGxvdy5zbGljZSgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKHRlbWxpc3QuaW5jbHVkZXModi5rZXkpKSByZXR1cm47XFxuICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZX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HQsXFxuICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBvLmk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJpc19kZWZcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV9vYmogPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcbiAgICAgICAgICAgICAgICAvL3N0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX3RlbXBcXFwiLCBjYXRlX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xuICAgICAgICAgICAgLy9sb2coaXQpXFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC52b2RfbmFtZTtcXG4gICAgICAgICAgICB1cmwgPSBcXFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1xcXCI7XFxuICAgICAgICAgICAgaWYgKHR5cGVvZiBpZCA9PT0gXFxcInN0cmluZ1xcXCIgJiYgaWQuaW5jbHVkZXMoXFxcIm1zZWFyY2g6XFxcIikgfHwgaWQgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9ICQoXFxcIlxcXCIpLmxhenlSdWxlKChuYW1lKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwidGVtc21vZGVcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3NlYXJjaD9ydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIiZzPVxcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICB9LCBuYW1lKVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogbmFtZSxcXG4gICAgICAgICAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXFxuICAgICAgICAgICAgICAgIHVybDogdXJsLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogaG9tZUxpc3RDb2wsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXFxuICAgICAgICAgICAgICAgICAgICB2b2RJZDogaWQsXFxuICAgICAgICAgICAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICBza2V5OiBzb3VyY2Uua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LnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NTA5OVxcXCIpO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IG5hbWUgfHwgXFxcIuaNoua6kFxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogJ2ljb25fcm91bmRfc21hbGxfNCcsXFxuICAgICAgICBpbWc6ICdodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS8xMzAucG5nJyxcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJDaGFuZ2VTb3VyY2VQb3BcXFwiKS5zaG93KCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBjcGF0aDogY29uZmlnLnBhdGgsXFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNoumFjee9rlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZUNvbmZpZyNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiKVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr/pl67nvZHnq5lcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwid2ViOi8vXFxcIiArIERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLmdldFJ1bGUoXFxcImhvc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yi35paw5rqQXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5pbml0KHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6YeN6L295rqQXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuafpeeci+a6kOS7o+eggVxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvZGUgPSBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5ydW5NYWluKFxcXCJsZXQgbWFpbj1cXFwiICsgJC50b1N0cmluZygoZXh0KT0+e1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKSA9PiBnZXRPcmlnaW5hbEpzKHJlcXVlc3QoZXh0LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdtZXRob2QnOiAnR0VUJ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iLCBcXFwi6IGa5ZCIXFxcIl0sIDEsIFxcXCLmkJzntKLmqKHlvI9cXFwiLCBzbW9kZSkuc2VsZWN0KCh0KSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNtb2RlXFxcIiwgXFxcIlxcXCIgKyBNWV9JTkRFWCk7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0odCArIFxcXCJAc2VhcmNoX21vZGVcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCLku4XpgInkuK1cXFwiLCBcXFwi6IGa5ZCIXFxcIl1bTVlfSU5ERVhdLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAvL3JlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgfSwgTVlfUlVMRS50aXRsZSlcXG4gICAgICAgIH0pLFxcbiAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vc3lzdGVtLzQxLnBuZ1xcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcImljb25fcm91bmRfc21hbGxfNFxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXFxcIkBzZWFyY2hfbW9kZVxcXCIsXFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaMh+WumuaQnOe0oua6kFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiU2VhcmNoQWxsb3dQb3BcXFwiKS5zaG93KCk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfV1cXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuaIkeeahFxcXCIsXFxuICAgICAgICB1cmw6ICQoW3tcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWOhuWPslxcXCIsXFxuICAgICAgICAgICAgaWNvbjogJ2h0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vc3lzdGVtLzEzNi5wbmcnXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmlLbol49cXFwiLFxcbiAgICAgICAgICAgIGljb246ICdodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL3N5c3RlbS8xMzkucG5nJ1xcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5Lmm5p62LeWwj+ivtFxcXCIsXFxuICAgICAgICAgICAgaWNvbjogJ2h0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vcS8xMy5wbmcnXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLkuabmnrYt5ryr55S7XFxcIixcXG4gICAgICAgICAgICBpY29uOiAnaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9xLzM0LnBuZydcXG4gICAgICAgIH1dLCAyLCBcXFwi5oiR55qEXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2hpc3Rvcnk/cnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKE1ZX0lOREVYID09PSAxKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9jb2xsZWN0aW9uP3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChNWV9JTkRFWCA9PT0gMikge1xcbiAg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oXFxcInVzZUxvZ1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuW8gOWQr+aXpeW/l+i+heWKqeiwg+ivle+8jOaZrumAmuS9v+eUqOS4jemcgOimgeW8gOWQr1xcXFxu5b2T5YmNOlxcXCIgKyB1c2VMb2cgKyBcXFwiXFxcXG7ngrnlh7vnoa7lrprljbPlj69cXFwiICsgKHVzZUxvZyA/IFxcXCLlhbPpl61cXFwiIDogXFxcIuW8gOWQr1xcXCIpKS5jb25maXJtKCh1c2VMb2cpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzZUxvZ1xcXCIsIHVzZUxvZyA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArICh1c2VMb2cgPyBcXFwi5bey5YWz6ZetXFxcIiA6IFxcXCLlt7LlvIDlkK9cXFwiKTtcXG4gICAgICAgICAgICAgICAgfSwgdXNlTG9nKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yib5bu66K6i6ZiF5Zyw5Z2AXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVTdWJzY3JpcHRpb24jbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5YiH5o2i5YiX6KGo5qC35byPXFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgY29sbGlzdCA9IFtcXFwi6buY6K6kXFxcIiwgXFxcIm1vdmllXzNfbWFycXVlZVxcXCIsIFxcXCJtb3ZpZV8zXFxcIiwgXFxcIm1vdmllXzJcXFwiLCBcXFwibW92aWVfMVxcXCIsIFxcXCJ0ZXh0XzFcXFwiXTtcXG4gICAgICAgICAgICAgICAgbGV0IGhvbWVMaXN0Q29sID0gZ2V0SXRlbShcXFwiaG9tZUxpc3RDb2xcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGhvbWVMaXN0Q29sID8gY29sbGlzdC5pbmRleE9mKGhvbWVMaXN0Q29sKSA6IDA7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGNvbGxpc3QsIDEsIFxcXCLpgInmi6nmoLflvI9cXFwiLCBpbmRleCkuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImhvbWVMaXN0Q29sXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJob21lTGlzdENvbFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICA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2VtcHR5XFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIGlmICghcnVudGltZUNvbmZpZy5pc1ByZXBhcmVkKCkpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLov5jmsqHmnInphY3nva7op4bpopHmupBcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSBpZiAoZmlsZUV4aXN0KFxcXCJoaWtlcjovL2ZpbGVzL2RhdGEvXFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiL2xpYnNfaGlrZXIvZHJweTIuanNcXFwiKSkge1xcbiAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgaWYgKE1ZX1BBR0UgPT09IDEpIHtcXG4gICAgICAgICAgICBpZiAoc291cmNlID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICAgICAgICBzZXRIaWVkKGQpXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2V0SGllZChkLCBzb3VyY2UubmFtZSwgcnVudGltZUNvbmZpZy5nZXRDdXJyZW50Q29uZmlnKCkgfHwge30pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIC8vbG9nKERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpKVxcbiAgICAgICAgbGV0IGhhc0hhZWQgPSBmYWxzZTtcXG4gICAgICAgIGlmIChnZXRNeVZhcihcXFwibGlua3NcXFwiLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+WKoOi9veS4rS4uLicsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMScsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwibG9hZFxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHNldFByZVJlc3VsdChkKTtcXG4gICAgICAgICAgICBkLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgaGFzSGFlZCA9IHRydWU7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoc291cmNlKSB7XFxuICAgICAgICAgICAgbG9hZChkLCBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KSwgc291cmNlLCBoYXNIYWVkKTtcXG4gICAgICAgIH1cXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIHNldERycHlQYXRoKGQpO1xcbiAgICB9XFxuXFxufSBjYXRjaCAoZSkge1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgZS50b1N0cmluZygpICsgXFxcIuKAneKAnVxcXCIsXFxuICAgICAgICBkZXNjOiBlLmxpbmVOdW1iZXIsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuabtOaNoumFjee9rlxcXCIsXF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IikmJmdldEl0ZW0oXFxcImZpcnN0b3BlblxcXCIsXFxcIlxcXCIpIDwgTVlfUlVMRS52ZXJzaW9uP1xcXCLwn4aVXFxcIjpcXFwiXFxcIn1gLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICBjb25zdCBoaWtlclBvcCA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9Njk2NlxcXCIpO1xcbiAgICAgICAgICAgIGhpa2VyUG9wLnVwZGF0ZVJlY29yZHNCb3R0b20oW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCIyMDI0LzA2LzEyICBNYXhWZXJzaW9uIDI2XFxcIixcXG4gICAgICAgICAgICAgICAgcmVjb3JkczogW1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8muWcqOaNoua6kOeVjOmdoueahOiPnOWNleWPr+S7peW8gOWQr+WIhuS6q+aXtuaYr+WQpuS9v+eUqOe8lueggeOAglxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwib3B0aW1pemXvvJrlnKjpgInmupDnlYzpnaLliLfmlrDphY3nva7lkI7kvJrlkIzmraXmm7TmlrDmlbDph4/mmL7npLrjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICBdXFxuICAgICAgICAgICAgfSx7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8xMCAgTWF4VmVyc2lvbiAyNVxcXCIsXFxuICAgICAgICAgICAgICAgIHJlY29yZHM6IFtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrlop7liqDmm7TmlrDml6Xlv5fjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8mumAiea6kOmVv+aMieiPnOWNle+8jOWinuWKoOi3s+i9rOe9kemhte+8jOafpeeci+a6kOeggeOAglxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN57yW6L6R6Kej5p6Q55WM6Z2i5rWL6K+VanPop6PmnpDkuIDnm7TlpLHotKXjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjWdpdGh1YuiuoumYhe+8jOS8muWIoOmZpOWFqOmDqOinhOWImeaWh+S7tuOAglxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN6Kej5p6Q6LCD55So5aSx6LSl44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3mm7TmjaLphY3nva7ml7bmsqHmnInlj4rml7bmuIXnqbpkcnB557yT5a2Y44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJvcHRpbWl6Ze+8muabtOaUueiuoumYheabtOaWsOetlueVpe+8jOS8muWIoOmZpOacrOWcsOWkseaViOa6kOOAglxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlrBkcnB5Mi5qc+OAglxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwib3B0aW1pemXvvJrkvJjljJbop6PmnpBmbGFn5Yy56YWN44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgICBdXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIjIwMjQvMDYvMDkgTWF4VmVyc2lvbiAyMFxcXCIsXFxuICAgICAgICAgICAgICAgIHJlY29yZHM6IFtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrmlK/mjIFwcm94eV9ydWxl5Luj55CG44CCXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3kupHnm5jpk77mjqXkuI3osIPlj5bkupHnm5jnroDjgIJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjeWTlOWTqeW9seinhuS4jeiDveS9v+eUqOino+aekOOAglxcXCIsXFxuICAgICAgICAgICAgICAgIF1cXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8wOCBNYXhWZXJzaW9uIDE4XFxcIixcXG4gICAgICAgICAgICAgICAgcmVjb3JkczogW1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIm9wdGltaXpl77ya5LyY5YyW6K6+572u6I+c5Y2V5o6S54mI77yM6YOo5YiG55WM6Z2i5aKe5Yqg5o+Q56S644CCXFxcIixcXG4gICAgICAgICAgICAgICAgXVxcbiAgICAgICAgICAgIH1dKTtcXG4gICAgICAgICAgICBcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIlxcbiAgICB9LCB7XFxuICAgICAgICB0aXRsZTogdGltZSArIFxcXCLnp5LlkI7nu6fnu61cXFwiLFxcbiAgICAgICAgdXJsOiBcXFwidG9hc3Q6Ly/or7forqTnnJ/pmIXor7vku6XkuIrlhoXlrrlcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAga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XCIpLFxcbiAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgZXh0cmE6IHtcXG4gICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICB9XFxufSk7XFxuc2V0UmVzdWx0KGQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiTG9jYWxQcm94eVwiLFwicGF0aFwiOlwiTG9jYWxQcm94eVwiLFwicnVsZVwiOlwiZnVuY3Rpb24gcHJveHkoKSB7XFxuICAgIGZ1bmN0aW9uIHBhcnNlVmlkZW8oTVlfUEFSQU1TLCB0aXRsZSkge1xcbiAgICAgICAgZnVuY3Rpb24gdG9QYXRoKHZhbHVlKSB7XFxuICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gJ3N0cmluZycpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFtdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGF0aCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgbGV0IGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICBsZXQgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2YWx1ZS5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoZXNjYXBlKSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXFxcXFxcXFwnKSB7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGN1cnJlbnQpIHtcXG4gICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcGF0aDtcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxuICAgICAgICAgICAgaWYgKCFvYmogfHwgIUFycmF5LmlzQXJyYXkocGF0aCkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHBhdGgubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gb2JqO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IG51bGwgfHwgY3VycmVudCA9PT0gdW5kZWZpbmVkIHx8IHR5cGVvZiBjdXJyZW50ICE9PSAnb2JqZWN0Jykge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtrZXldO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gY3VycmVudDtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJ1blR5cGUgPSBNWV9QQVJBTVMucnVuVHlwZVswXTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKSk7XFxuICAgICAgICAgICAgaWYgKHJ1blR5cGUgPT0gXFxcIkpTT05cXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJhbSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcGFyYW0uaGVhZGVycyB8fCB7fSxcXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZDogcGFyYW0ubWV0aG9kIHx8IHZvaWQgMFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBPYmplY3QuYXNzaWduKHt9LCBwYXJhbS5oZWFkZXJzIHx8IHt9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogZ2V0SnNvbihqc29uLCB0b1BhdGgocGFyYW0uanNvblBhdGgpKSxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PSBcXFwiSlNcXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJzZTtcXG4gICAgICAgICAgICAgICAgaWYgKE1ZX1BBUkFNUy5pbmRleCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgdGl0bGUpLmdldEpzb24oKVtNWV9QQVJBTVMuaW5kZXhbMF1dO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShkZWNvZGVVUklDb21wb25lbnQoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCByZXMgPSBuZXcgRnVuY3Rpb24oXFxcInVybFxcXCIsIFxcXCJzZWxmXFxcIiwgcGFyc2UuanMpKHVybCwgcGFyc2UpO1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcyA9PT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogcmVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoJC50eXBlKHJlcykgPT09IFxcXCJvYmplY3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiByZXNcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGRvSnMoTVlfUEFSQU1TLCB0aXRsZSwgZ2tleSkge1xcbiAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICBHTVxcbiAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzVlOGYwLTIyZTgtNTI3MC1hOWQxLTgyNmY1M2YxNzdhZFxcXCIpO1xcbiAgICAgICAgR00uc2V0U2VsZktleShna2V5KTtcXG4gICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIiwgXFxcIkRycHlNYW5hZ2U/cnVsZT1cXFwiICsgdGl0bGUpO1xcbiAgICAgICAgbGV0IGRycHkgPSBEcnB5TWFuYWdlLmdldChkZWNvZGVVUklDb21wb25lbnQoTVlfUEFSQU1TLmhpa2VyU2tleVswXSkpO1xcbiAgICAgICAgbGV0IHBhcmFtcyA9IHt9O1xcbiAgICAgICAgZm9yIChsZXQga2V5IGluIE1ZX1BBUkFNUykge1xcbiAgICAgICAgICAgIHBhcmFtc1trZXldID0g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