xiaomianao666

邀您一起看:创建配置

Jun 1st, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:二级页面详情¥page_detail¥创建配置@@eyJkYXRhIjoie1wiYXNzb2NpYXRlZE1vZGVsc01hcEZvckpvaW5UYWJsZVwiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhGS1wiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhvdXRGS1wiOnt9LFwiZmllbGRzVG9TZXRUb0RlZmF1bHRcIjpbXSxcImdtdE1vZGlmaWVkXCI6MCxcImlkXCI6MCxcImxhc3RfY2hhcHRlcl9ydWxlXCI6XCJcIixcImxpc3RUb0NsZWFyQXNzb2NpYXRlZEZLXCI6W10sXCJsaXN0VG9DbGVhclNlbGZGS1wiOltdLFwicGFnZUxpc3RcIjpbe1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHlcIixcInBhdGhcIjpcImRycHlcIixcInJ1bGVcIjpcImZ1bmN0aW9uIGluaXRIaWtlcigpIHtcXG4gICAgY29uc3QgaXNDbG9zZUxvZyA9ICFnZXRJdGVtKFxcXCJ1c2VMb2dcXFwiLCBcXFwiXFxcIik7XFxuICAgIGNvbnN0IGxvY2FsS2V5ID0gXFxcImRycHlcXFwiO1xcbiAgICBjb25zdCBDcnlwdG9VdGlsID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2Fzc2V0cy9jcnlwdG8tamF2YS5qc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmxvY2FsID0ge1xcbiAgICAgICAgc2V0KHJ1bGVrZXksIGssIHYpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKGxvY2FsS2V5ICsgXFxcIkBcXFwiICsgcnVsZWtleSArIFxcXCJAXFxcIiArIGssIHYpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldChydWxla2V5LCBrLCB2KSB7XFxuICAgICA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QuYXNzaWduKHtcXG4gICAgICAgICAgICAgICAgQ29va2llOiBcXFwiI25vQ29va2llI1xcXCJcXG4gICAgICAgICAgICB9LCBvYmouaGVhZGVycyk7XFxuICAgICAgICAgICAgaWYgKHVybCA9PT0gXFxcImh0dHBzOi8vYXBpLm5uLmNpL29jci9iNjQvdGV4dFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNbXFxcIkNvbnRlbnQtVHlwZVxcXCJdID0gXFxcInRleHQvcGxhaW5cXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5qcy80LjEuMC9tdXN0YWNoZS5qc1xcXCIpO1xcbiAgXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2pzb25wYXRoLXBsdXMuZ2l0aHViLmlvL0pTT05QYXRoL2Rpc3QvaW5kZXgtYnJvd3Nlci11bWQuY2pzXFxcIik7XFxuICAgIGdsb2JhbFRoaXMuY2hlZXJpbyA9IHtcXG4gICAgICAgIGppbmphMih0ZW1wbGF0ZSwgb2JqKSB7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuICQubG9nKEppbkphLnJlbmRlcih0ZW1wbGF0ZSwgb2JqKSk7XFxuICAgICAgICB9LFxcbiAgICAgICAganAocGF0aCwganNvbikge1xcbiAgICAgICAgICAgIHJldHVybiBKUC5KU09OUGF0aCh7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIGpzb25cXG4gICAgICAgICAgICB9KVswXTtcXG4gICAgICAgIH1cXG4gICAgfSovXFxuICAgIGdsb2JhbFRoaXMucGRmYSA9IF9wZGZhO1xcbiAgICBnbG9iYWxUaGlzLnBkID0gX3BkO1xcbiAgICBnbG9iYWxUaGlzLnBkZmggPSBfcGRmaDtcXG4gICAgU3RyaW5nLnByb3RvdHlwZS5yZXBsYWNlQWxsID0gZnVuY3Rpb24gKHNlYXJjaCwgcmVwbGFjZW1lbnQpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLnNwbGl0KHNlYXJjaCkuam9pbihyZXBsYWNlbWVudCk7XFxuICAgIH07XFxuICAgIGxldCAkdG9TdHJpbmcgPSBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmc7XFxuICAgIEZ1bmN0aW9uLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uICgpIHtcXG4gICAgICAgIHJldHVybiAkdG9TdHJpbmcuYXBwbHkodGhpcykudHJpbSgpO1xcbiAgICB9O1xcbiAgICBpZiAoaXNDbG9zZUxvZykge1xcbiAgICAgICAgLy8g6YeN5YaZY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgIGNvbnNvbGUubG9nID0gZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgIC8vIOajgOafpeS8oOWFpeWPguaVsOeahOaVsOmHj1xcbiAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzlj4LmlbDmlbDph4/lpKfkuo4x77yM6LCD55So5Y6f5aeL55qEY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgICAgICAgICAgLy9vcmlnaW5hbExvZy5hcHBseShjb25zb2xlLCBhcmd1bWVudHMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgLy8g5aaC5p6c5Y+C5pWw5Y+q5pyJ5LiA5Liq77yM5YiZ5LiN5YGa5Lu75L2V5pON5L2cXFxuICAgICAgICB9O1xcbiAgICB9XFxufVxcbmluaXRIaWtlcigpO1xcbmNvbnN0IGRycHlQYXRoID0gZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIik7XFxuXFxuaWYgKCFmaWxlRXhpc3QoZHJweVBhdGgpKSB7XFxuICAgIHRocm93IG5ldyBFcnJvcihcXFwi57y65bCRZHJweS5qc+i/kOihjOW6k1xcXCIpO1xcbn1cXG5sZXQgZHJweSA9ICQucmVxdWlyZShkcnB5UGF0aCk7XFxuLypcXG5sZXQgY3VycmVudFBhdGggPSBcXFwiXFxcIjtcXG5sZXQgJGluaXQgPSBkcnB5LmluaXQ7XFxuZHJweS5pbml0ID0gZnVuY3Rpb24oZXh0KSB7XFxuICAgIGlmIChleHQgPT09IGN1cnJlbnRQYXRoKSByZXR1cm47XFxuICAgICRpbml0LmNhbGwodGhpcywgZXh0KTtcXG4gICAgY3VycmVudFBhdGggPSBleHQ7XFxufSovXFxuJC5leHBvcnRzID0gZHJweTtcIn0se1wi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fM1xcXCI7XFxuICAgICAgfSBlbHNlIGlmICh0YyA+PSAxNSkge1xcbiAgICAgICAgY29sID0gXFxcInRleHRfMlxcXCI7XFxuICAgICAgICB0ZXh0YWxpZ24gPSBcXFwibGVmdFxcXCI7XFxuICAgICAgfVxcbiAgICAgIGxldCBwbGF5b2JqID0gdC5zcGxpdChcXFwiI1xcXCIpLm1hcCgoaikgPT4ge1xcbiAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICBsZXQgdWlkID0gKGtbMV18fGtbMF0pO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxuICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICB9KSxcXG4gICAgICAgICAgdXJsOiAgdWlkKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkucmVwbGFjZSgnXFxcImlkXFxcIicsICdcXFwiJyArdWlkICsgJ1xcXCInKSxcXG4gICAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxuICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9KSovXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJ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hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgIGxldCBvYmogPSBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLCB7XFxuICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyAocGFnZW51bSA9PSBpID8geC5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogeCksXFxuICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGkpID0+IHtcXG4gICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCAkLnRlbXBfbGlzdFtpXSk7XFxuICAgICAgICAgICAgIGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpLmZvckVhY2goKHgsIGlpKSA9PiB7XFxuICAgICAgICAgICAgICAgbGV0IHRpdGxlID0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgaWYgKGlpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcInJlZFxcXCIpO1xcbiAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICB9KVx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cXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9kb21haW5fY29uZmlnXFxcIixcXG4gICAgZXh0cmE6IHtcXG4gICAgICAgIHBhZ2VUaXRsZTogXFxcIuaWsOWinuino+aekFxcXCJcXG4gICAgfVxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YiG5LqrXFxcIixcXG4gICAgdXJsOiAkKFxcXCItMVxcXCIsIFxcXCLovpPlhaXkvaDopoHliIbkuqvop6PmnpDnmoTluo/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiAkKFtcXFwiSElLRVJcXFwiLCBcXFwiVFhUXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSwgMiwgXFxcIuWIhuS6q+aWueW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XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY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aGVhZGVycykge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4LCBpc0ltcG9ydCkgPT4ge1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIW5hbWUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFwicHNfdXJsXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghdXJsKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmxhZyA9IGdldE15VmFyKFxcXCJwc19mbGFnXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmbGFnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOagh+ivhuS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IGdldE15VmFyKFxcXCJwc19oZWFkZXJzXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcbiAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIG9iajEpO1xcbiAgICAgICAgfVxcbiAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+d5a2Y5oiQ5YqfXFxcIjtcXG4gICAgfSwgaW5kZX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ICBmb3IgKGxldCBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc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gPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuICAgIGxldCBjb3VudCA9IDA7XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC5uYW1lO1xcbiAgICAgICAgICAgIGxldCBzcGF0aCA9IGl0LnBhdGg7XFxuICAgICAgICAgICAgaWYgKCFuYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkgY29udGludWU7XFxuICAgICAgICAgICAgbmFtZSA9IG5hbWUuc2xpY2UoMCwgbmFtZS5sYXN0SW5kZXhPZihcXFwiLlxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKGBodHRwczovL3Jhdy5naXRtaXJyb3IuY29tLyR7cm9wZX0vbWFzdGVyLyR7c3BhdGh9YCk7XFxuICAgICAgICAgICAgaWYgKCEoKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpICYmICFmaWxlRXhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICAgICAgICAgJ2FwaSc6Jy4uL2xpYnMvZHJweTIuanMnLFxcbiAgICAgICAgICAgICAgICAgICAgJ3NlYXJjaGFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdmaWx0ZXJhYmxlJzogMSxcXG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ChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGl0LmV4dCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChqb2luVXJsKHVybCwgaXQuZXh0KSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcIi4vXFxcIiArIG5hbWU7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIGNvdW50ICsgXFxcIuS4qlxcXCI7XFxufVxcbiQuZXhwb3J0cy5wYXJzZVVybCA9IGZ1bmN0aW9uKHVybCwgcGF0aCkge1xcbiAgICBwYXRoID0gYmFzZTY0RGVjb2RlKHBhdGgpO1xcbiAgICBwYXR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b25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJjaEFsbG93UGF0aCkgfHwgXFxcIltdXFxcIik7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZGVsZXRlRmlsZShzZWFyY2hBbGxvd1BhdGgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UsXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxuICAgICAgICAgICAgc291cmNlTGlzdFxcbiAgICAgICAgfTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIG51bGw7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlMb2NhbChkaXJGaWxlKSB7XFxuICAgIGxldCBsaXN0ID0gZGlyRmlsZS5saXN0RmlsZXMoKTtcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGxldCBuYW1lID0gU3RyaW5nKGl0LmdldE5hbWUoKSk7XFxuICAgICAgICBsZXQgcGF0aCA9IGl0LmdldFBhdGgoKTtcXG4gICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikgfHwgaXQuaXNEaXJlY3RvcnkoKSkgY29udGludWU7XFxuICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ2V4dCc6IGAke3BhdGh9YCxcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHJldHVybiBydWxlcztcXG59XFxuXFxuZnVuY3Rpb24gZ2VuZXJhdGVDb25maWdCeUdpdGh1Yih1cmwpIHtcXG4gICAgLy91cmw9dXJsLnJlcGxhY2UoLygjR0lUSFVCIykkLyxcXFwiXFxcIik7XFxuICAgIGxldCByb3BlID0gdXJsLnNwbGl0KFxcXCIvXFxcIikuc2xpY2UoMywgNSkuam9pbihcXFwiL1xcXCIpO1xcbiAgICBsZXQgaHRtbCA9IGZldGNoKHVybCk7XFxuICAgIGxldCBqc29uVGV4dCA9IHBkZmgoaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpO1xcbiAgICBsZXQganN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B7XFxuICAgICAgICAgIHJldHVybiBsaXN0LmZpbHRlcihpdCA9PiBTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIubWluLmpzXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLmpzXFxcIikpXFxuICAgICAgICB9XFxuICAgICAgICBpZiAob2JqLnVybC5zdGFydHNXaXRoKFxcXCJmaWxlOlxcXCIpKSB7XFxuICAgICAgICAgIGxldCBjb2RlID0gXFxcIm5vXFxcIjtcXG4gICAgICAgICAgbGV0IHBhdGggPSBvYmoudXJsLnJlcGxhY2UoXFxcImZpbGU6Ly9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgIGxldCBkaXIgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcbiAgICAgICAgICBpZiAoZGlyLmlzRGlyZWN0b3J5KCkpIHtcXG4gICAgICAgICAgICBsZXQgZmxpc3QgPSBkaXIubGlzdEZpbGVzKCk7XFxuICAgICAgICAgICAgZm9yICh2YXIgZiBvZiBmbGlzdCkge1xcbiAgICAgICAgICAgICAgLy8g5qOA5p+l5paH5Lu25ZCN5piv5ZCm5LulLmpz57uT5bC+XFxuICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBqc0ZpbGVzLnB1c2goZik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXG4gICAgICAgICAgICB1cmw6IG9iai51cmwsXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxuICAgICAgICAgICAgaW5kZXg6IG9iai5pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcbiAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcbiAgICAgICAgfSkpO1xcbiAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgbGV0IGMgPSBlIC0gcztcXG4gICAgICAgIGlmIChvYmoudXJsLmluY2x1ZGVzKFxcXCJnaXRodWIuY29tXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcbiAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcbiAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkubGVuZ3RoO1xcbiAgICAgICAgICB9IGNhdGNoIHt9XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhqLmJvZHkpIHx8IFxcXCJ7fVxcXCIpO1xcbiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7fVxcblxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgIH1cXG4gICAgICB9O1xcbiAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgfVxcbiAgICAgIH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iAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKS5tYXAoeCA9PiB4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICBsZXQgZmxpc3QgPSBsaXN0LmZpbHRlcih4ID0+IHguaW5jbHVkZXModGV4dCkpO1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbGV0IG5hd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C5oYXMoaXRlbS5rZXkpKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICBsZXQgQ2tleSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpLmtleTtcXG4gICAgICAgICAgICAvL2xvZyhDa2V5KVxcbiAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcbiAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgIH0gPSBjZmc7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTtcXG4gICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxuICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXG5cXG4gICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIuaWsOWinlxcXCIgKyBhbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3Quc3BsaWNlKG1hbmFnZS5saXN0LmluZGV4T2YoeC5uYW1lKSwgMSk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGxvZyhcXFwi56e76ZmkOlxcXCIgKyBkbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgbXNnICs9IFxcXCIg56e76ZmkXFxcIiArIGRsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgdG9hc3QobXNnICsgXFxcIiDmm7TlpJror6bmg4XnnItsb2dcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgIC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ZS5leHTlv4XpobvkuLrnu53lr7not6/lvoRcXG5mdW5jdGlvbiBnZXRCeVNvdXJjZShzb3VyY2Upe1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICBsZXQga2V5PXNvdXJjZS5rZXk7XFxuICAgICAgICAvL2xvZyhkcnB5TWFwLnNpemUpXFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHNvdXJjZS5leHQpO1xcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuZnVuY3Rpb24gcHV0KGtleSwgZHJweSkge1xcbiAgICBzeW5jKCgpID0+IGRycHlNYXAuc2V0KGtleSwgZHJweSksIHRoaXMpLmNhbGwoKTtcXG59XFxuXFxuZnVuY3Rpb24gZGVsKGtleSkge1xcbiAgICBzeW5jKCgpID0+IHtcXG4gICAgICAgIGxvZyhcXFwi5Yig6ZmkXFxcIiArIGtleSk7XFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIGRycHlNYXAuZGVsZXRlKGtleSk7XFxuICAgICAgICB9XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxubGV0IGlzSW5pdEhvbWUgPSBmYWxzZTtcXG4vL2xldCBpc0luaXRTZWFyY2ggPSB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HNwZW4gPT0gMyA/IDEgOiAzO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2VDb2x1bW5zKHNwZW4pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDEpIHtcXG4gICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgY29udGVudDogXFxcIui+k+WFpeWFs+mUruWtlyDnqbrmmL7npLrlhajpg6hcXFwiLFxcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFwi4oCc4oCc4oCd4oCdXFxcIiArICh2Lm5hbWUgKyBcXFwiXFxcIikuZm9udGNvbG9yKFxcXCIjMDA5OTY2XFxcIikgOiB2Lm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcblxcblxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2Uuc29ydCgoYSwgYikgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcblxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxuICAgICAgICAgICAgbGV0IHRlbWxpc3QgPSBzZWFyY2hBbGxvdy5zbGljZSgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKHRlbWxpc3QuaW5jbHVkZXModi5rZXkpKSByZXR1cm47XFxuICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNo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ZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcbiAgICAgICAgICAgICAgICAvL3N0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX3RlbXBcXFwiLCBjYXRlX3RlbXApO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCBjYXRlX29iaik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCxcXG4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YpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG5cXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICB9XFxuICAgICAgfTtcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICBsZXQgcm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XksIGspIHtcXFxcbiAgICAgICAgICAgIHN0b3JhZ2UwLmNsZWFySXRlbShsb2NhbEtleSArIFxcXFxcXFwiQFxcXFxcXFwiICsgcnVsZWtleSArIFxcXFxcXFwiQFxcXFxcXFwiICsgayk7XFxcXG4gICAgICAgIH1cXFxcbiAgICB9O1xcXFxuICAgIGV2YWwoZ2V0Q3J5cHRvSlMoKSk7XFxcXG4gICAgZ2xvYmFsVGhpcy5DcnlwdG9KUyA9IENyeXB0b0pTO1xcXFxuXFxcXG4gICAgbGV0ICRyZXF1ZXN0ID0gcmVxdWVzdDtcXFxcbiAgICBsZXQgJHBvc3QgPSBwb3N0O1xcXFxuICAgIGdsb2JhbFRoaXMucmVxID0gZnVuY3Rpb24gKHVybCwgY29iaikge1xcXFxuICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgbGV0IHJlcyA9IHt9O1xcXFxuICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIGNvYmopO1xcXFxuICAgICAgICAgICAgaWYgKG9iai5kYXRhKSB7XFxcXG4gICAgICAgICAgICAgICAgb2JqLmJvZHkgPSBvYmouZGF0YTtcXFxcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqLmRhdGE7XFxcXG4gICAgICAgICAgICB9XFxcXG5cXFxcbiAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoXFxcXFxcXCJyZWRpcmVjdFxcXFxcXFwiKSkgb2JqLnJlZGlyZWN0ID0gISFvYmoucmVkaXJlY3Q7XFxcXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcXFxuICAgICAgICAgICAgICAgIG9iai50b0hleCA9IHRydWU7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBvYmouaGVhZGVycyA9IE9iamVjdC5hc3NpZ24oe1xcXFxuICAgICAgICAgICAgICAgIENvb2tpZTogXFxcXFxcXCIjbm9Db29raWUjXFxcXFxcXCJcXFxcbiAg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uICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxcXG4gICAgICAgICAgICAgfSovXFxcXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcXFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcXFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcXFxuICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXFxcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXFxcbiAgICAgICAgICAgIGxvZyhcXFxcXFxcIkVycm9yXFxcXFxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcXFxuICAgICAgICB9XFxcXG4gICAgfVxcXFxuICAgIC8qXFxcXG4gICAgY29uc3QgSmluSm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iBcXFxcXFxcImdyZXlcXFxcXFxcIlxcXFxuICAgIH1cXFxcblxcXFxuICAgIHZhciBsYXp5ID0gJChgI25vTG9hZGluZyNgKS5sYXp5UnVsZSgoZGMsIHNkYywgbSwgY3MpID0+IHtcXFxcbiAgICAgIHZhciBzaG93ID0gc3RvcmFnZTAuZ2V0SXRlbShtLCAnMCcpO1xcXFxuICAgICAgdmFyIHRpdGxlID0gZmluZEl0ZW0oJ2Rlc2MnKS50aXRsZTtcXFxcbiAgICAgIHZhciByZSA9IC8oPFxcXFxcXFxcL3NtYWxsPjxicj4uKj8+KS4rL2c7XFxcXG4gICAgICB2YXIgZXhwID0gJ+WxleW8gDonO1xcXFxuICAgICAgdmFyIHJldCA9ICfmlLbotbc6JztcXFxcbiAgICAgIGlmIChzaG93ID09ICcxJykge1xcXFxuICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcXFxuICAgICAgICAgIHRpdGxlOiB0aXRsZVxcXFxuICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxcXG4gICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIHNkYyArICc8L3NtYWxsPicpXFxcXG4gICAgICAgICAgICAucmVwbGFjZSgvKDxcXFxcXFxcXC9zbWFsbD48YnI+XFxcXFxcXFw8Zm9udCBjb2xvcj1cXFxcXFxcIikuKj8oXFxcXFxcXCI+KS8sICckMScgKyBjcy5oaWRlICsgJyQyJylcXFxcblxcXFxuICAgICAgICB9KVxcXFxuICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKG0sICcwJyk7XFxcXG4gICAgICB9IGVsc2Uge1xcXFxuICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcXFxuICAgICAgICAgIHRpdGxlOiB0aXRsZVxcXFxuICAgICAgICAgICAgLnJlcGxhY2UoZXhwLCByZXQpXFxcXG4gICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIGRjICsgJzwvc21hbGw+JylcXFxcbiAgICAgICAgICAgIC5y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3suWQr+eUqOeahO+8jC0z5bey56aB55So55qEXFxcXFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXFxcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcXFxuICAgICAgICBsZXQgaW5kZXhzID0gW107XFxcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxcXG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBpbmRleGMpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcXFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgaW5kZXhzLnB1c2gobnVtKTtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICByZXR1cm4gJChbXFxcXFxcXCJISUtFUlxcXFxcXFwiLCBcXFxcXFxcIlRYVFxcXFxcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFxcXFxcIuWIhuS6q+aWueW8j1xcXFxcXFwiKS5zZWxlY3QoKG1vLCBpbmRleHMsIGV4dCkgPT4ge1xcXFxuICAgICAgICAgICAgZnVuY3Rpb24gdXAocnVsZXMpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcXFxuICAgICAgICAgICAgICAgIGxldCBnZXRQY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ocGF0aCwgZ2V0UGFzcyhydWxlcy5sZW5ndGgsIHJ1bGViNjQsIFxcXFxcXFwiYVxcXFxcXFwiKSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInNoYXJlOi8vXFxcXFxcXCIgKyBwYXRoO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIGxldCBydWxlcztcXFxcbiAgICAgICAgICAgIGlmIChtbyA9PT0gLTEpIHtcXFxcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTIpIHtcXFxcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTMpIHtcXFxcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0Rm9yYmlkZGVuSnNvbigpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpLmZpbHRlcigodiwgaSkgPT4gaW5kZXhzLmluY2x1ZGVzKGkpKTtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHY7XFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgIC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XFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXFxcXFwiYlxcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXFxcXFwi56e75YqoXFxcXFxcXCIpIHtcXFxcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXFxcXFwiXFxcXFxcXCIsIFxcXFxcXFwi6L6T5YWl5L2N572uXFxcXFxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLmdldEpzb24oKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcXFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcXFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcXFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcXFxcXCLnva7pobZcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5nZXRKc29uKCk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcXFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcXFxcXCLliKDpmaRcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXFxcXFwi56Gu6K6k5Yig6Zmk77yfXFxcXFxcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpO1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcXFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxcXG4gICAgICAgICAg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dHJpbmcoKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXFxcXFwidmlkZW9VcmxcXFxcXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcXFxuICAgICAgICAgICAgICAgIG5hbWUsXFxcXG4gICAgICAgICAgICAgICAgdXJsLFxcXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXFxcbiAgICAgICAgICAgICAgICBqc1xcXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcXFxuICAgICAgICB9KTtcXFxcbiAgICB9KSxcXFxcbiAgICBjb2xfdHlwZTogXFxcXFxcXCJ0ZXh0XzNcXFxcXFxcIixcXFxcbn0pO1xcXFxuXFxcXG5kLnB1c2goe1xcXFxuICAgIHRpdGxlOiBcXFxcXFxcIuS/neWtmFxcXFxcXFwiLFxcXFxuICAgIHVybDogJChcXFxcXFxcIiNub0xvYWRpbmcjXFxcXFxcXCIpLmxhenlSdWxlKChpbmRleCwgaXNJbXBvcnQpID0+IHtcXFxcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFxcXFxcInBzX25hbWVcXFxcXFxcIiwgXFxcXFxcXCJcXFxcXFxcIikudHJpbSgpO1xcXFxuICAgICAgICBpZiAoIW5hbWUpIHtcXFxcbiAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcXFxcXCI7XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgbGV0IHVybCA9IGdldE15VmFyKFxcXFxcXFwicHNfdXJsXFxcXFxcXCIsIFxcXFxcXFwi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B7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXFxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcXFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcXFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOiv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cXFwiKSB7XFxcXG4gICAgICAgICAgICBydWxlID0gcGFyc2VQYXN0ZShydWxlKTtcXFxcbiAgICAgICAgfVxcXFxuICAgICAgICBsZXQgcnVsZXMgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShydWxlKSk7XFxcXG4gICAgICAgIGlmICghQXJyYXkuaXNBcnJheShydWxlcykpIHtcXFxcbiAgICAgICAgICAgIHJ1bGVzID0gW3J1bGVzXTtcXFxcbiAgICAgICAgfVxcXFxuICAgICAgICAvL3J1bGVzLnJldmVyc2UoKTtcXFxcbiAgICAgICAgTVlfVVJMID0gbW9kdWxlLmlkO1xcXFxuICAgICAgICBsZXQgcnVsZVRpdGxlID0gZ2V0UGFyYW0oXFxcXFxcXCJydWxlXFxcXFxcXCIpO1xcXFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlncz9ydWxlPVxcXFxcXFwiICsgcnVsZVRpdGxlKS5nZXRKc29uKCk7XFxcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXFxcbiAgICAgICAgZm9yIChsZXQgcnVsZSBvZiBydWxlcykge1xcXFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxcXG4gICAgICAgICAgICAgICAgcnVsZSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFxcXFxcIiArIGluZGV4ICsgXFxcXFxcXCImcnVsZT1cXFxcXFxcIiArIHJ1bGVUaXRsZTtcXFxcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFxcXFxcIuW3suabtOaWsOinhOWIme+8mlxcXFxcXFwiICsgcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIG5ld0krKztcXFxcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcXFxcXCIgKyBydWxlVGl0bGU7XFxcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcXFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXFxcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcXFxcXCIgKyBydWxlLm5hbWUpXFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9XFxcXG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XFxcXFwiKSkpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0LmV4dC5lbmRzV2l0aChcXFxcXFxcIi5qc1xcXFxcXFwiKSA/IGRlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcXFxcXCIvXFxcXFxcXCIpLmF0KC0xKSkgOiAoaXQubmFtZSArIFxcXFxcXFwiLmpzXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcXFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXFxcXFwiaHR0cFxcXFxcXFwiKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcXFxcXCIuL1xcXFxcXFwiICsgbmFtZTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcXFxcXCJydWxlXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcXFxuICAgICAgICAgICAgICAgIH07XFxcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxcXG4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ai51cmwucmVwbGFjZShcXFxcXFxcImZpbGU6Ly9cXFxcXFxcIiwgXFxcXFxcXCJcXFxcXFxcIik7XFxcXG4gICAgICAgICAgbGV0IGRpciA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxcXG4gICAgICAgICAgaWYgKGRpci5pc0RpcmVjdG9yeSgpKSB7XFxcXG4gICAgICAgICAgICBsZXQgZmxpc3QgPSBkaXIubGlzdEZpbGVzKCk7XFxcXG4gICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxcXG4gICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcXFxuICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXFxcXFwiLmpzXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcXFxuICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxcXG4gICAgICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxcXG4gICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxcXG4gICAgICAgICAgICBjb2RlID0gXFxcXFxcXCJva1xcXFxcXFwiO1xcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcXFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXFxcbiAgICAgICAgICAgIGNvZGUgPSBcXFxcXFxcIm9rXFxcXFxcXCI7XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcXFxuICAgICAgICAgICAgY29kZTogY29kZSxcXFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcXFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcXFxuICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxcXG4gICAgICAgIH0pKTtcXFxcbiAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcXFxuICAgICAgICBsZXQgYyA9IGUgLSBzO1xcXFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFxcXFxcImdpdGh1Yi5jb21cXFxcXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcXFxuICAgICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXFxcbiAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXFxcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcXFxcXCIpKTtcXFxcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxcXG4gICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXFxcXFwiLmpzXFxcXFxcXCIpKS5sZW5ndGg7XFxcXG4gICAgICAgICAgfSBjYXRjaCB7fVxcXFxuICAgICAgICB9XFxcXG4gICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFxcXFxcInt9XFxcXFxcXCIpO1xcXFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXFxcbiAgICAgICAgICB9XFxcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxcXG5cXFxcbiAgICAgICAgcmV0dXJuIHtcXFxcbiAgICAgICAgICB0aW1lOiBjLFxcXFxuICAgICAgICAgIHVybDogai51cmwsXFxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcXFxuICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxcXG4gICAgICAgIH1cXFxcbiAgICAgIH07XFxcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcXFxuICAgICAgICBpID0gaSArIDE7XFxcXG4gICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgZnVuYzogdGFzayxcXFxcbiAgICAgICAgICBwYXJhbToge1xcXFxuICAgICAgICAgICAgdXJsOiB4LFxcXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxcXG4gICAgICAgICAgfSxcXFxcbiAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxcXG4gICAgICAgIH1cXFxcbiAgICAgIH0pO1xcXFxuICAgIC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tcXFxcbiAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcXFxuICAgICAgICAgICAgLy9sb2coQ2tleSlcXFxcbiAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcXFxuICAgICAgICAgICAgbGV0IHtcXFxcbiAgICAgICAgICAgICAgcGF0aCxcXFxcbiAgICAgICAgICAgICAgbmFtZVxcXFxuICAgICAgICAgICAgfSA9IGNmZztcXFxcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxcXG4gICAgICAgICAgICAgIHBhdGgsXFxcXG4gICAgICAgICAgICAgIG5hbWUsXFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTtcXFxcbiAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxcXG5cXFxcbiAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxcXG4gICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcXFxuXFxcXG4gICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxcXG4gICAgICAgICAgICAgIGxldCBtc2cgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLmlrDlop46XFxcXFxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcXFxcXCIsXFxcXFxcXCIpKVxcXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFxcXFxcIuaWsOWinlxcXFxcXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcXFxcXCLkuKrmupBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXFxcbiAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgICAgIGxvZyhcXFxcXFxcIuenu+mZpDpcXFxcXFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFxcXFxcIixcXFxcXFxcIikpXFxcXG4gICAgICAgICAgICAgICAgbXNnICs9IFxcXFxcXFwiIOenu+mZpFxcXFxcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcXFxcXCLkuKrmupBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXFxcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgIHRvYXN0KFxcXFxcXFwi5bey5Yi35pawXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgfSxcXFxcbiAgICAgIH0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Fwi6K+36YCJ5oupXFxcXFxcXCIsXFxcXG4gICAgICAgIGNsaWNrKHMsIGkpIHtcXFxcbiAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcXFxuICAgICAgICAgICAgc3BlbiA9IHNwZW4gPT0gMyA/IDEgOiAzO1xcXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZUNvbHVtbnMoc3Blbik7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAxKSB7XFxcXG4gICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcXFxuICAgICAgICAgICAgICBjb250ZW50OiBcXFxcXFxcIui+k+WFpeWFs+mUruWtlyDnqbrmmL7npLrlhajpg6hcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwi562b6YCJ5rqQXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXFxcXFwi5rqQ5YWz6ZSu5a2XIOWkmuS4queUqHzpmpTlvIBcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXFxcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcXFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXFxcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXFxcbiAgICAgICAgIC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FuYWdlLmxpc3QpO1xcXFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXFxcblxcXFxuXFxcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXFxcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcXFxuICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxcXG4gICAgICAgICAgICAgICAgc2Vuc2l0aXZpdHk6ICdiYXNlJ1xcXFxuICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXFxcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXFxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcXFxuXFxcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXFxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXFxcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2KSkge1xcXFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcXFxuICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcXFxuICAgICAgICAgICAgcnVudGltZUNvb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NoKHtcXFxcbiAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgdCxcXFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXFxcXFwiI25vTG9hZGluZyNcXFxcXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgaSA9IG8uaTtcXFxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFxcXFxcImlzX2RlZlxcXFxcXFwiLCBcXFxcXFxcIjFcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcXFxcXCJjYXRlX29ialxcXFxcXFwiLCB7fSk7XFxcXG5cXFxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcXFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXFxcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXFxcXFwiXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcXFxcXCJjYXRlX3RlbXBcXFxcXFxcIiwgY2F0ZV90ZW1wKTtcXFxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFxcXFxcImNhdGVfb2JqXFxcXFxcXCIsIGNhdGVfb2JqKTtcXFxcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgfSwge1xcXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCxcXFxcbiAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXFxcbiAgICAgICAgICAgICAgICBpOiBpLFxcXFxuICAgICAgICAgICAgICAgIGNhdGU6IGNhdGVcXFxcbiAgICAgICAgICAgICAgfSksXFxcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxcXG4gICAgICAgICAgICB9KVxcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgfSlcXFxcbiAgICAgIH0pXFxcXG4gICAgfVxcXFxuICB9XFxcXG59XFxcXG5cXFxcbmZ1bmN0aW9uIGdldEZsKCkge1xcXFxuICBmbCA9IE9iamVjdC5rZXlzKGZsKS5maWx0ZXIoa2V5ID0+IGZsW2tleV0gIT09IFxcXFxcXFwidW5kZWZpbmVkXFxcXFxcXCIpLnJlZHVjZSgocmVzLCBrZXkpID0+IHtcXFxcbiAgICByZXNba2V5XSA9IGZsW2tleV07XFxcXG4gICAgcmV0dXJuIHJlcztcXFxcbiAgfSwge30pO1xcXFxuICByZXR1cm4gZmxcX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