Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IkRycHlIaWtlciIsImF1dGhvciI6IkBMb3lEZ0lrJnpldGFscGhhIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6NDUsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoidmlkZW8iLCJjbGFzc191cmwiOiIiLCJhcmVhX25hbWUiOiIiLCJhcmVhX3VybCI6IiIsInNvcnRfbmFtZSI6IiIsInllYXJfbmFtZSI6IiIsInNvcnRfdXJsIjoiIiwieWVhcl91cmwiOiIiLCJmaW5kX3J1bGUiOiJqczokLnJlcXVpcmUoXCJNaWFuTG9hZFwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zPSoqJnBhZ2U9ZnlwYWdlIiwiZ3JvdXAiOiLlvIDlj5HkuK3lv4MiLCJzZWFyY2hGaW5kIjoianM6XG4oZnVuY3Rpb24gKCkge1xuICBsZXQgc21vZGUgPSBOdW1iZXIoZ2V0SXRlbShcInNtb2RlXCIsIFwiMFwiKSk7XG4gIGxldCB0ZW1zbW9kZSA9IGdldE15VmFyKFwidGVtc21vZGVcIiwgXCJcIik7XG4gIGlmICh0ZW1zbW9kZSkge1xuICAgIHNtb2RlID0gTnVtYmVyKHRlbXNtb2RlKTtcbiAgICBjbGVhck15VmFyKFwidGVtc21vZGVcIik7XG4gIH1cbiAgaWYgKCFmaWxlRXhpc3QoXCJoaWtlcjovL2ZpbGVzL2RhdGEvXCIgKyBNWV9SVUxFLnRpdGxlICsgXCIvbGlic19oaWtlci9kcnB5Mi5qc1wiKSkgcmV0dXJuIHNldFJlc3VsdChbe1xuICAgIHRpdGxlOiBcIuivt+W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xvd1NlYXJjaFNvdXJjZShzbW9kZT09PTIpO1xuXG4gICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG5cbiAgICAgICAgICAgIGxldCBsaXN0aSA9IGxpc3QuZmluZEluZGV4KHggPT4geC5rZXkgPT0gc291cmNlLmtleSk7XG5cbiAgICAgICAgICAgIGlmIChzb3VyY2Uuc2VhcmNoYWJsZSAmJiBsaXN0aSAhPSAtMSkge1xuICAgICAgICAgICAgICBsaXN0LnNwbGljZShsaXN0LmluZGV4T2Yoc291cmNlKSwgMSk7XG4gICAgICAgICAgICAgIGxpc3QudW5zaGlmdChzb3VyY2UpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IHNlYXJjaHNvcnQgPSBOdW1iZXIoZ2V0SXRlbShcInNlYXJjaHNvcnRcIiwgXCIwXCIpKTtcbiAgICAgICAgICAgIGxldCB7XG4gICAgICAgICAgICAgIG5hdHVyYWxTb3J0LFxuICAgICAgICAgICAgICB1c2luZ1NvcnRcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXCJtZXRob2RzXCIpO1xuXG4gICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA+IDApIHtcbiAgICAgICAgICAgICAgaWYgKHNlYXJjaHNvcnQgPT0gMSkge1xuICAgICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QsIFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChzZWFyY2hzb3J0ID09IDIpIHtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuc2V0a2V5KFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHJ1bGVzID0gW107XG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XG4gICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xuICAgICAgICAgICAgICAgIHRpdGxlOiBpdC5uYW1lLFxuICAgICAgICAgICAgICAgIHNlYXJjaF91cmw6IFwiaGlrZXI6Ly9lbXB0eT9wYWdlPWZ5cGFnZSZzZWFyY2hUZXJtcz0qKlwiLFxuICAgICAgICAgICAgICAgIHNlYXJjaEZpbmQ6IFwianM6XCIgKyAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIikuZ2V0KGl0ZW0ua2V5KTtcblxuICAgICAgICAgICAgICAgICAgbGV0IGhvbWVMaXN0ID0gSlNPTi5wYXJzZShkcnB5LnNlYXJjaChNWV9LRVlXT1JELCBmYWxzZSwgTVlfUEFHRSkpLmxpc3QgfHwgW107XG4gICAgICAgICAgICAgICAgICBsZXQgZCA9IFtdO1xuICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaG9tZUxpc3QpIHtcbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXG4gICAgICAgICAgICAgICAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vcGFnZS9kZXRhaWxlZCNpbW1lcnNpdmVUaGVtZSNcIixcbiAgICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcIm1vdmllXzNcIixcbiAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdm9kSWQ6IFN0cmluZyhpdC52b2RfaWQpLFxuICAgICAgICAgICAgICAgICAgICAgICAgaXNQb2x5bWVyaXplOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICAgICAgc25hbWU6IGl0ZW0ubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNrZXk6IGl0ZW0ua2V5LFxuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICBzZXRSZXN1bHQoZCk7XG4gICAgICAgICAgICAgICAgfSwgaXQpXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHJ1bGVzKTtcbiAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pXG4gICAgICB9XG4gICAgfV0pO1xuICB9XG59KSgpIiwiZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsImRldGFpbF9maW5kX3J1bGUiOiIiLCJzZGV0YWlsX2NvbF90eXBlIjoibW92aWVfMSIsInNkZXRhaWxfZmluZF9ydWxlIjoiIiwidWEiOiJtb2JpbGUiLCJwcmVSdWxlIjoiLyo8JD5cbkBpbmNsdWRlIHN0YXJ0XG5odHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTE2JmF1dGg9MWQzNWU4ZjAtMjJlOC01MjcwLWE5ZDEtODI2ZjUzZjE3N2FkXG5AaW5jbHVkZSBlbmRcbjwkPiovXG4iLCJwYWdlcyI6Ilt7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiZHJweVwiLFwicGF0aFwiOlwiZHJweVwiLFwicnVsZVwiOlwiY29uc3Qgc2tleSA9IG1vZHVsZS5pbXBvcnRQYXJhbTtcXG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biAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5qcy80LjEuMC9tdXN0YWNoZS5qc1xcXCIpO1xcbiAgXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2pzb25wYXRoLXBsdXMuZ2l0aHViLmlvL0pTT05QYXRoL2Rpc3QvaW5kZXgtYnJvd3Nlci11bWQuY2pzXFxcIik7XFxuICAgIGdsb2JhbFRoaXMuY2hlZXJpbyA9IHtcXG4gICAgICAgIGppbmphMih0ZW1wbGF0ZSwgb2JqKSB7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuICQubG9nKEppbkphLnJlbmRlcih0ZW1wbGF0ZSwgb2JqKSk7XFxuICAgICAgICB9LFxcbiAgICAgICAganAocGF0aCwganNvbikge1xcbiAgICAgICAgICAgIHJldHVybiBKUC5KU09OUGF0aCh7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIGpzb25cXG4gICAgICAgICAgICB9KVswXTtcXG4gICAgICAgIH1cXG4gICAgfSovXFxuICAgIGdsb2JhbFRoaXMucGRmYSA9IF9wZGZhO1xcblxcbiAgICBnbG9iYWxUaGlzLnBkID0gX3BkO1xcbiAgICBnbG9iYWxUaGlzLnBkZmggPSBfcGRmaDtcXG4gICAgU3RyaW5nLnByb3RvdHlwZS5yZXBsYWNlQWxsID0gZnVuY3Rpb24gKHNlYXJjaCwgcmVwbGFjZW1lbnQpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLnNwbGl0KHNlYXJjaCkuam9pbihyZXBsYWNlbWVudCk7XFxuICAgIH07XFxuICAgIGxldCAkdG9TdHJpbmcgPSBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmc7XFxuICAgIEZ1bmN0aW9uLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uICgpIHtcXG4gICAgICAgIHJldHVybiAkdG9TdHJpbmcuYXBwbHkodGhpcykudHJpbSgpO1xcbiAgICB9O1xcbiAgICBpZiAoaXNDbG9zZUxvZykge1xcbiAgICAgICAgLy8g6YeN5YaZY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgIGNvbnNvbGUubG9nID0gZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgIC8vIOajgOafpeS8oOWFpeWPguaVsOeahOaVsOmHj1xcbiAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzlj4LmlbDmlbDph4/lpKfkuo4x77yM6LCD55So5Y6f5aeL55qEY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgICAgICAgICAgLy9vcmlnaW5hbExvZy5hcHBseShjb25zb2xlLCBhcmd1bWVudHMpO1xcbiAgICAgICAgICAgIH0g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AgICAgICAgdmFyIHNob3cgPSBzdG9yYWdlMC5nZXRJdGVtKG0sICcwJyk7XFxuICAgICAgICAgICAgdmFyIHRpdGxlID0gZmluZEl0ZW0oJ2Rlc2MnKS50aXRsZTtcXG4gICAgICAgICAgICB2YXIgcmUgPSAvKDxcXFxcL3NtYWxsPjxicj4uKj8+KS4rL2c7XFxuICAgICAgICAgICAgdmFyIGV4cCA9ICflsZXlvIA6JztcXG4gICAgICAgICAgICB2YXIgcmV0ID0gJ+aUtui1tzonO1xcbiAgICAgICAgICAgIGlmIChzaG93ID09ICcxJykge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBzZGMgKyAnPC9zbWFsbD4nKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8oPFxcXFwvc21hbGw+PGJyPlxcXFw8Zm9udCBjb2xvcj1cXFwiKS4qPyhcXFwiPikvLCAnJDEnICsgY3MuaGlkZSArICckMicpXFxuXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0obSwgJzAnKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoZXhwLCByZXQpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBkYyArICc8L3NtYWxsPicpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXC9zbWFsbD48YnI+XFxcXDxmb250IGNvbG9yPVxcXCIpLio/KFxcXCI+KS8sICckMScgKyBjcy5zaG93ICsgJyQyJylcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMScpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gYGhpa2VyOi8vZW1wdHlgXFxuICAgICAgICB9LCBkZXNjLCBzZGVzYywgbWFyaywgY29sb3JzKVxcbiAgICAgICAgdmFyIHNjID0gc3RvcmFnZTAuZ2V0SXRlbShtYXJrLCAnMCcpID09ICcwJyA/ICflsZXlvIA6JyA6ICfmlLbotbc6JztcXG4gICAgICAgIHZhciBkYyA9IHN0b3JhZ2UwLmdldEl0ZW0obWFyaywgJzAnKSA9PSAnMCcgPyBzZGVzYyA6IGRlc2M7XFxuICAgICAgICB2YXIgY3MgPSBzdG9yYWdlMC5nZXRJdGVtKG1hcmssICcwJykgPT0gJzAnID8gY29sb3JzLmhpZGUgOiBjb2xvcnMuc2hvdztcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICcnICsgJzxiPjxmb250IGNvbG9yPVxcXCIjMDk4QUMxXFxcIj7iiLfliafmg4XnroDku4tcXHQ8L2ZvbnQ+PC9iPicgKyBcXFwiPHNtYWxsPjxhIHN0eWxlPSd0ZXh0LWRlY29yYXRpb246IG5vbmU7JyBocmVmPSdcXFwiICsgbGF6eSArIFxcXCInPlxcXCIgKyBzYyArICc8L2E+PC9zbWFsbD48YnI+PGZvbnQgY29sb3I9XFxcIicgKyBjcyArICdcXFwiPicgKyBgJHtkY31gICsgJzwvc21hbGw+JyxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3JpY2hfdGV4dCcsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6ICdkZXNjJyxcXG4gICAgICAgICAgICAgICAgbGluZVNwYWNpbmc6IDYsXFxuICAgICAgICAgICAgICAgIHRleHRTaXplOiAxNSxcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IHRydWUsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgfVxcblxcbiAgICBsZXQgc29ydG9iaiA9IFt7XFxuICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShcXFwi4oa/XFxcIiwge1xcbiAgICAgICAgICAgICAgICBoOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgYzogXFxcIiMxQUFEMTlcXFwiLFxcbiAgICAgICAgICAgICAgICB0YWdzOiBcXFwiYlxcXCJcXG4gICAgICAgICAgICB9KSArIGZvbnRzdHlsZShcXFwi4oeCXFxcIiwge1xcbiAgICAgICAgICAgICAgICBoOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgdGFnczogXFxcImJcXFwiXFxuICAgICAgICAgICAgfSkgKyBcXFwiXFxcXHRcXFwiLFxcbiAgICAgICAgICAgIGltZzogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vbWVzc3kvMTIzLnN2Z1xcXCJcXG4gICAgICAgIH0sXFxuICAgICAgICB7XFxuICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShcXFwi4oa/XFxcIiwge1xcbiAgICAgICAgICAgICAgICBoOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgdGFnczogXFxcImJcXFwiXFxuICAgICAgICAgICAgfSkgKyBmb250c3R5bGUoXFxcIuKHglxcXCIsIHtcXG4gICAgICAgICAgICAgICAgaDogZmFsc2UsXFxuICAgICAgICAgICAgICAgIGM6IFxcXCIjRkYwMDAwXFxcIixcXG4gICAgICAgICAgICAgICAgdGFnczogXFxcImJcXFwiXFxuICAgICAgICAgICAgfSkgKyBcXFwiXFxcXHRcXFwiLFxcbiAgICAgICAgICAgIGltZzogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vbWVzc3kvMTI0LnN2Z1xcXCJcXG4gICAgICAgIH1cXG4gICAg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TtcXG4gICAgICAgICAgICAgICAgdmFyIHN0YXJ0ID0gcGFydHNbMF0gLSAxOyAvLyDlh48x5piv5Zug5Li65pWw57uE57Si5byV5LuOMOW8gOWni1xcbiAgICAgICAgICAgICAgICB2YXIgZW5kID0gcGFydHNbMV0gLSAxO1xcbiAgICAgICAgICAgICAgICAvLyDkvb/nlKhBcnJheS5wcm90b3R5cGUuc2xpY2XmnaXojrflj5blrZDmlbDnu4RcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFycmF5LnNsaWNlKHN0YXJ0LCBlbmQgKyAxKTsgLy8g5YyF5ous57uT5p2f57Si5byV77yM5omA5Lul5YqgMVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICB9LFxcbiAgICB9KVxcblxcbiAgICBsZXQgc291cmNlID0ge307XFxuICAgIGlmIChNWV9QQVJBTVMuc291cmNlKSB7XFxuICAgICAgICBzb3VyY2UgPSBNWV9QQVJBTVMuc291cmNlO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgc291cmNlID0gcnVudGltZUNvbmZpZy5maW5kU291cmNlKE1ZX1BBUkFNUy5za2V5KTtcXG4gICAgICAgIE1ZX1BBUkFNUy5zb3VyY2UgPSBzb3VyY2U7XFxuICAgICAgICBzZXRQYWdlUGFyYW1zKE1ZX1BBUkFNUyk7XFxuICAgIH1cXG5cXG4gICAgY29uc3QgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcblxcbiAgICBEcnB5TWFuYWdlLmluaXRQYWdlKFxcXCJlclxcXCIpO1xcblxcbiAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcXG4gICAgbGV0IHN0eXBl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XM7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmICh0YyA+IDI0KSB7XFxuICAgICAgICAgICAgICAgIGNvbCA9IFxcXCJ0ZXh0XzFcXFwiO1xcbiAgICAgICAgICAgICAgICBpbWcgPSBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9tb3ZpZS8xNDYuc3ZnXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRjID49IDEyICYmIHRjIDwgMTUpIHtcXG4gICAgICAgICAgICAgICAgY29sID0gXFxcInRleHRfM1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICh0YyA+PSAxNSkge1xcbiAgICAgICAgICAgICAgICBjb2wgPSBcXFwidGV4dF8yXFxcIjtcXG4gICAgICAgICAgICAgICAgdGV4dGFsaWduID0gXFxcImxlZnRcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGxheW9iaiA9IHQuc3BsaXQoXFxcIiNcXFwiKS5tYXAoKGosIGlpKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBrID0gai5zcGxpdChcXFwiJFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICAgICAgICAgIGxldCB1aWQgPSAoa1sxXSB8fCBrWzBdKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIHN0aXRsZTogdCxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICAgICAgc3VybDogdWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXNOb3ZlbCA/IFxcXCJoaWtlcjovL3BhZ2Uvbm92ZWwjYXV0b1BhZ2UjI3JlYWRUaGVtZSNcXFwiIDogKHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0gKyBwbGF5TGF6eSksXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogY29sLFxcbiAgICAgICAgICAgICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgICAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcbiAgICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IGRlY29kZVVSSUNvbXBvbmVudChrWzFdKSxcXG4gICAgICAgICAgICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgICAgICAgICAgIC8vbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfSkqL1xcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmcm9tOiBmcm9tW2ldLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogc291cmNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiB1aWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tSdWxlczogWydiYi4qLnBuZycsICcuanBnJywgXFxcImhtXFxcXC5iYWlkdVxcXFwuY29tXFxcXC9obS5qc1xcXCJdLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZpZGVvRXhjbHVkZVJ1bGVzOiBbJz91cmw9J10sXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBpZiAoc3R5cGUgPT0gXFxcIua8q+eUu1xcXCIgfHwgc3R5cGUgPT0gXFxcIuWwj+ivtFxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgdmFyIGRvd25sb2FkbGF6eSA9ICQudG9TdHJpbmcoKGtleSwgc2tleSwgdGl0bGUpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkcnB5O1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCQuaGlrZXJbXFxcIl9fZHJweV9fXFxcIl0pIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkcnB5ID0gJC5oaWtlcltcXFwiX19kcnB5X19cXFwiXTtcXG5cXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgR01cXG4gICAgICAgICAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJodHRwOi8vaGlrZXIubm9raWEucHJlc3MvaGlrZXJ1bGUvcnVsZWxpc3QuanNvbj9pZD02OTE2JmF1dGg9MWQzNWU4ZjAtMjJlOC01MjcwLWE5ZDEtODI2ZjUzZjE3N2FkXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgR00uc2V0U2VsZktleShrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIiwgXFxcIkRycHlNYW5hZ2U/cnVsZT1cXFwiICsgdGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRycHkgPSBEcnB5TWFuYWdlLmdldChza2V5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAkLmhpa2VyW1xcXCJfX2RycHlfX1xcXCJdID0gZHJweTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAkLmhpa2VyW1xcXCJfX3Rlc3RfX1xcXCJdID0gW107XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnNwbGl0KFxcXCIjXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcmVzdWx0ID0gSlNPTi5wYXJzZShkcnB5LnBsYXkoaW5wdXRbMV0sIGlucHV0WzBdKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0LnVybC5zdGFydHNXaXRoKFxcXCJwaWNzOi8vXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0LnVybDtcXG4gICAgICAgICAgICAgICAgICAgIH1lbHNlIGlmIChyZXN1bHQudXJsLnN0YXJ0c1dpdGgoXFxcIm5vdmVsOi8vXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29udGVudD1KU09OLnBhcnNlKHJlc3VsdC51cmwucmVwbGFjZShcXFwibm92ZWw6Ly9cXFwiLCBcXFwiXFxcIikpLmNvbnRlbnQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNtZDU9bWQ1KGNvbnRlbnQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbmRleD0wO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKChpbmRleD0kLmhpa2VyW1xcXCJfX3Rlc3RfX1xcXCJdLmluZGV4T2YoY21kNSkpIT09LTEpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coXFxcIumHjeWkje+8mlxcXCIraW5wdXQrXFxcIj0+XFxcIitpbmRleCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICQuaGlrZXJbXFxcIl9fdGVzdF9fXFxcIl0ucHVzaChjbWQ1KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29udGVudDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5ryr55S75oiW5q2j5paH6I635Y+W5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIH0sIEdNLmdldFNlbGZLZXkoKSwgTVlfUEFSQU1TLnNrZXksIE1ZX1JVTEUudGl0bGUpO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2hhcHRlckxpc3QgPSBwbGF5b2JqLmV4Y2x1ZGVLZXlzKFtcXFwic3VybFxcXCIsIFxcXCJzdGl0bGVcXFwiXSwgZmFsc2UpLnRyYW5zZm9ybUtleXMoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInN1cmxcXFwiOiBcXFwidXJsXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJzdGl0bGVcXFwiOiBcXFwidGl0bGVcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShjaGFwdGVyTGlzdCkpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLkuIvovb1cXFwiICsgc3R5cGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvZG93bmxvYWQudmlldyNub1JlY29yZEhpc3RvcnkjI25vUmVmcmVzaCM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYnLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2hhcHRlckxpc3Q6IFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmZvOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tOYW1lOiBpbmZvLnZvZF9uYW1lLCAvL+a8q+eUu+WQjeensCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZU5hbWU6IE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tUb3BQaWM6IGluZm8udm9kX3BpYyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VDb2RlOiBkb3dubG9hZGxhenksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tJZDogTVlfUEFSQU1TLnNuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBzdHlwZSA9PT0gXFxcIua8q+eUu1xcXCIgPyBcXFwiY29taWNcXFwiIDogXFxcIm5vdmVsXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWaWV3OiBcXFwiMVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuacrOWcsOS5puaetlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvQm9va3JhY2sudmlldyNub1JlY29yZEhpc3RvcnkjP3J1bGU95pys5Zyw6LWE5rqQ566h55CGJnJ1bGVOYW1lPScgKyBNWV9SVUxFLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBwbGF5b2JqID0gJC5zcGxpdEFycmF5QnlSYW5nZXMocGxheW9iaiwgcGFnZXMpO1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5b2JqO1xcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuaaguaXoOaSreaUvua6kOaIluaSreaUvuWIl+ihqOWumuS9jemUmeivr1xcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IE1ZX1BBUkFNUy52b2RJZCxcXG4gICAgICAgIH0pO1xcbiAgICAgICAgY2FjaGVTaG93VGlwcygpO1xcbiAgICAgICAgc2V0UmVzdWx0KGQpO1xcbiAgICB9XFxuXFxuXFxuICAgIGxldCBjdXJyZW50TG9jYXRpb24gPSAwO1xcblxcbiAgICBpZiAoZnJvbS5sZW5ndGgpIHtcXG4gICAgICAgIGVyT3B0aW9ucy5zZXQoXFxcImZyb21cXFwiLCBmcm9tKTtcXG4gICAgICAgIGVyT3B0aW9ucy5zZXQoXFxcInRvdGFsXFxcIiwgcGxheVVybExpc3QubWFwKHggPT4geC5sZW5ndGgpKTtcXG4gICAgICAgIGVyT3B0aW9ucy5zZXQoXFxcInBsYXlzXFxcI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gICAgICAgICAgIGxldCB0ZW1wID0ge1xcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfMScsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBsZXQgZmMgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICBpZiAoIShwbGF5cCAmJiBwbGF5cC5sZW5ndGggPiAxKSkge1xcbiAgICAgICAgICAgICAgICBmYyA9IFxcXCJncmV5XFxcIjtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgbGV0IHBhZ2VvYmogPSBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZm9udHN0eWxlKCfkuIrkuIDpobUnLCB7XFxuICAgICAgICAgICAgICAgICAgICBjOiBmY1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkLCBwY291bnQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGVmID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZ2V0RUluZm8oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhZ2VudW0gPSBlZi5wYWdlbnVtO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBjb3VudCA9PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bS0tO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgaWQsIHBjb3VudCwgU3RyaW5nKHBhZ2VudW0pKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VAdXBcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUocGxheXBbcGFnZW51bV0sIHtcXG4gICAgICAgICAgICAgICAgICAgIGM6IGZjXFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIHBhZ2VudW0pO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGVmID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZ2V0RUluZm8oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBjb3VudCA9PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBwbGF5cCA9IGVmLnBsYXlwO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhZ2VhcnIgPSBwbGF5cC5tYXAoKHgsIGkpID0+IGkgPT0gcGFnZW51bSA/ICfigJzigJzigJ3igJ0nICsgeC5mb250Y29sb3IoXFxcIiNmZmE1MDBcXFwiKSA6IHgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKE1ZX0lOREVYKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0sIGxvY2F0aW9uKVxcbiAgICAgICAgICAgICAgICB9LCBpZCwgcGFnZW51bSksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBpZDogXFxcInBsYXlwYWdlQHBhZ2VhcnJcXFwiLFxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZm9udHN0eWxlKCfkuIvkuIDpobUnLCB7XFxuICAgICAgICAgICAgICAgICAgICBjOiBmY1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbG9jYXRpb24gPSBnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGNvdW50ID0gZWYubWF4W2xvY2F0aW9uXTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYWdlbnVtID0gZWYucGFnZW51bTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgICAgICBpZiAocGFnZW51bSA+PSBwY291bnQgLSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IDA7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0rKztcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKHBhZ2VudW0pKTtcXG4gICAgICAgICAgICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4ge30pKGxvY2F0aW9uKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGlkKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VAbmV4dFxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1dXFxuXFxuICAgICAgICAgICAgbGV0IHBsaW5lID0gZC5maW5kSW5kZXgoeCA9PiB4LmV4dHJhICYmIHguZXh0cmEuaWQgPT0gXFxcInBsYXlwYWdlbGluZVxcXCIpO1xcblxcbiAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwicGxheWxpc3RfcmVhZHlcXFwiLCBcXFwiMFxcXCIpID09IFxcXCIwXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAocGxpbmUgPiAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaW5zZXJ0QXJyYXlBdChkLCBwbGluZSArIDEsIHBhZ2VvYmopO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIC8vQXJyYXkucHJvdG90eXBlLnB1c2guYXBwbHkoZCxwYWdlb2JqKTtcXG4gICAgICAgICAgICAgICAgLy9hZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIHBhZ2VvYmopO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwibm9wYWdlXFxcIiwgXFxcIjBcXFwiKSA9PSBcXFwiMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheXBhZ2VsaW5lXFxcIiwgcGFnZW9iaik7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJub3BhZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJwbGF5cGFnZUB1cFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBwYWdlb2JqWzBdLnRpdGxlLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJwbGF5cGFnZUBwYWdlYXJyXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBhZ2VvYmpbMV0udGl0bGUsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInBsYXlwYWdlQG5leHRcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGFnZW9ialsyXS50aXRsZSxcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgLy8gYWRkSXRlbUFmdGVyKFxcXCJwbGF5cGFnZWxpbmVcXFwiLCBbe1xcbiAgICAgICAgICAgIC8vICAgdGl0bGU6ICfkuIrkuIDpobUnLFxcbiAgICAgICAgICAgIC8vICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgICAgIC8vICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxuICAgICAgICAgICAgLy8gICAg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pKGxvY2F0aW9uKTtcXG4gICAgICAgICAgICAvLyAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgIC8vICAgfSwgbG9jYXRpb24pLFxcbiAgICAgICAgICAgIC8vICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAvLyAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiXFxuICAgICAgICAgICAgLy8gICB9XFxuICAgICAgICAgICAgLy8gfSwge1xcbiAgICAgICAgICAgIC8vICAgdGl0bGU6ICfkuIvkuIDpobUnLFxcbiAgICAgICAgICAgIC8vICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgICAgIC8vICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxuICAgICAgICAgICAgLy8gICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgIC8vICAgICBpZiAocGFnZW51bSA+PSBwY291bnQgLSAxKSB7XFxuICAgICAgICAgICAgLy8gICAgICAgcGFnZW51bSA9IDA7XFxuICAgICAgICAgICAgLy8gICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgLy8gICAgICAgcGFnZW51bSsrO1xcbiAgICAgICAgICAgIC8vICAgICB9XFxuICAgICAgICAgICAgLy8gICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKHBhZ2VudW0pKTtcXG4gICAgICAgICAgICAvLyAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7IH0pKGxvY2F0aW9uKTtcXG4gICAgICAgICAgICAvLyAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAvLyAgIH0sIGxvY2F0aW9uLCBwY291bnQpLFxcbiAgICAgICAgICAgIC8vICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAvLyAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiXFxuICAgICAgICAgICAgLy8gICB9XFxuICAgICAgICAgICAgLy8gfV0pXFxuICAgICAgICAgICAgLypwbGF5cCA9IHBsYXlwLm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgIGxldCBvYmogPSBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLCB7XFxuICAgICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyAocGFnZW51bSA9PSBpID8geC5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogeCksXFxuICAgICAgICAgICAgICAgICBjb2xfdHlwZTpcXFwic2Nyb2xsX2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCAkLnRlbXBfbGlzdFtpXSk7XFxuICAgICAgICAgICAgICAgICAgIGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpLmZvckVhY2goKHgsIGlpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgbGV0IHRpdGxlID0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgaWYgKGlpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcInJlZFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgfSwgaSksXFxuICAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgdGVtcC5leHRyYSwge1xcbiAgICAgICAgICAgICAgICAgICBpZDogXFxcInBhZ2VudW1cXFwiICsgaSxcXG4gICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIHBsYXlwKSovXFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheXBhZ2VcXFwiKTtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwibm9wYWdlXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChnZXRNeVZhcihcXFwicGxheWxpc3RfcmVhZHlcXFwiLCBcXFwiMFxcXCIpID09IFxcXCIxXFxcIikge1xcbiAgICAgICAgICAgIGxldCBvbGRJZHMgPSAoZmluZEl0ZW1zQnlDbHMoJ3BsYXlsaXN0JykgfHwgW10pLm1hcChpdCA9PiBpdC5leHRyYS5pZCk7XFxuICAgICAgICAgICAgbGV0IHRvRGVsZXRlSWRzID0gW107IC8v5b6F5Yig6Zmk55qE5penaWRcXG4gICAgICAgICAgICBsZXQgdG9BZGREYXRhcyA9IFtdOyAvL+W+heaWsOWinueahOaWsOaVsOaNrlxcbiAgICAgICAgICAgIGlmIChvbGRJZHMubGVuZ3RoID4gbGlzdC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgdG9EZWxldGVJZHMgPSBvbGRJZHMuc2xpY2UobGlzdC5sZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAob2xkSWRzLmxlbmd0aCA8IGxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIHRvQWRkRGF0YXMgPSBsaXN0LnNsaWNlKG9sZElkcy5sZW5ndGgpXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBjbnQgPSBNYXRoLm1pbihvbGRJZHMubGVuZ3RoLCBsaXN0Lmxlbmd0aCk7XFxuICAgICAgICAgICAgaWYgKHRvRGVsZXRlSWRzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgLy/mnInliKDpmaTnmoTlhYjliKDpmaRcXG4gICAgICAgICAgICAgICAgZGVsZXRlSXRlbSh0b0RlbGV0ZUlkcyk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmICh0b0FkZERhdGFzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgLy/mnInmlrDlop7nmoTlhYjmlrDlop5cXG4gICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKG9sZElkc1tjbnQgLSAxXSwgdG9BZGREYXRhcyk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIC8vc2hvd0xvYWRpbmcoJ+WKoOi9veS4rScpXFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjbnQ7IGkrKykge1xcbiAgICAgICAgICAgICAgICAvL+acgOWQjumhuuW6j+abtOaWsFxcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKG9sZElkc1tpXSwgbGlzdFtpXSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG5cXG4gICAgICAgICAgICAvL2xvZyhsaXN0Lmxlbmd0aClcXG4gICAgICAgICAgICBpZiAobGlzdCkge1xcbiAgICAgICAgICAgICAgICBsZXQgcGxzID0gZC5maW5kSW5kZXgoeCA9PiB4LmV4dHJhICYmIHguZXh0cmEuaWQgPT0gXFxcInBsYXlsaXN0c1xcXCIpO1xcbiAgICAgICAgICAgICAgICBpZiAocGxzID4gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluc2VydEFycmF5QXQoZCwgcGxzICsgMSwgbGlzdCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgLy9BcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShkLGxpc3QpO1xcbiAgICAgICAgICAgICAgICAvL2FkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgbGlzdCk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwbGF5bGlzdF9yZWFkeVxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcblxcbiAgICAgICAgdXBkYXRlSXRlbShcXFwibG9jYXRpb25AXFxcIiArIGN1cnJlbnRMb2NhdGlvbiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBmcm9tW2N1cnJlbnRMb2NhdGlvbl0sXFxuICAgICAgICB9KTtcXG5cXG4gICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxvY2F0aW9uQFxcXCIgKyBsb2NhdGlvbiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUoZnJvbVtsb2NhdGlvbl0sIHtcXG4gICAgICAgICAgICAgICAgYzogXFxcIi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DogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoc28pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IHNpID0gZ2V0TXlWYXIoXFxcInNvcnRpXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGlpID0gKHNpID09IFxcXCIwXFxcIiA/IFxcXCIxXFxcIiA6IFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcIkBzb3J0XFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogc29baWldLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgaW1nOiBzb1tpaV0uaW1nLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB2YXIgcGxheXMgPSBmaW5kSXRlbXNCeUNscyhcXFwicGxheWxpc3RcXFwiKS5yZXZlcnNlKCkubWFwKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgeC5jb2xfdHlwZSA9IHgudHlwZTtcXG4gICAgICAgICAgICAgICAgICAgIHguZXh0cmEuaWQgPSB4LmV4dHJhLmlkLmVuZHNXaXRoKFxcXCLih4VcXFwiKSA/IHguZXh0cmEuaWQucmVwbGFjZSgv4oeFJC8sIFxcXCJcXFwiKSA6IHguZXh0cmEuaWQgKyBcXFwi4oeFXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB4O1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbGV0IG9sZElkcyA9IChmaW5kSXRlbXNCeUNscygncGxheWxpc3QnKSB8fCBbXSkubWFwKGl0ID0+IGl0LmV4dHJhLmlkKTtcXG5cXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBvbGRJZHMubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIC8v5pyA5ZCO6aG65bqP5pu05pawXFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKG9sZElkc1tpXSwgcGxheXNbaV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJdGVtID0gKGZpbmRJdGVtc0J5Q2xzKCdwbGF5bGlzdCcpIHx8IFtdKTtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuZXdJdGVtLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICAvL+acgOWQjumhuuW6j+abtOaWsFxcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShuZXdJdGVtW2ldLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIG5ld0l0ZW1baV0uZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IG5ld0l0ZW1baV0uZXh0cmEuaWQucmVwbGFjZSgv4oeFJC8sIFxcXCJcXFwiKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICAvLyBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgICAgIC8vIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgcGxheXMpO1xcblxcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwic29ydGlcXFwiLCBpaSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgKGlpID09IFxcXCIwXFxcIiA/IFxcXCLmraPluo9cXFwiIDogXFxcIuWAkuW6j1xcXCIpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgc29ydG9iaiksXFxuICAgICAgICAgICAgY29sX3R5cGU6ICdhdmF0YXInLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBcXFwiQHNvcnRcXFwiLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBpZiAoZnJvbS5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSBpbiBmcm9tKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjaSA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IChpID09IGNpID8gZm9udHN0eWxlKGZyb21baV0sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjOiBcXFwiI0ZGRDcwMFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGFnczogXFxcIlxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pIDogZnJvbVtpXSksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGksIGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkoaSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGksIGlkKSxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwibG9jYXRpb25AXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZDogXFxcImxvY2F0aW9uQFxcXCIgKyBpXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH1cXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYmxhbmtfYmxvY2tcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcInBsYXlwYWdlbGluZVxcXCJcXG4gICAgICAgIH1cXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwicGxheWxpc3RzXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYmxhbmtfYmxvY2tcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcInBsYXlsaXN0c0VORFxcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGNhY2hlU2hvd1RpcHMoKTtcXG4gICAgcmVub3ZhdGVMaXN0KGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpKTtcXG4gICAgc2V0UmVzdWx0KGQpO1xcbn0pKClcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIix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gICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBydWxlcztcXG4gICAgICAgICAgICBpZiAobW8gPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0yKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0zKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0Rm9yYmlkZGVuSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpLmZpbHRlcigodiwgaSkgPT4gaW5kZXhzLmluY2x1ZGVzKGkpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5tYXAoKHYpID0+IHtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmRleGNbMV0pO1xcblxcbiAgICB9LCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hbGxfNFxcXCIsXFxuICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3NoYXJlX2dyZWVuXFxcIlxcbn0pO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi6YeN572uXFxcIixcXG4gICAg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ChmKSkge1xcbiAgICAgICAgICAgICAgICBmbGFnaSA9IFtmXVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGZsYWdpID0gZmxhZ2kuZmlsdGVyKHggPT4gIS8o5YWo6YOofOW3suemgeeUqCkvLnRlc3QoeCkpO1xcbiAgICAgICAgICAgICAgICBpZiAoZmxhZ2kuaW5jbHVkZXMoZikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGZsYWdpID0gZmxhZ2kuZmlsdGVyKHggPT4geCAhPSBmKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChmbGFnaS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdpID0gW1xcXCLlhajpg6hcXFwiXVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgZmxhZ2kucHVzaChmKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJmbGFnaVxcXCIsIGZsYWdpKTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBmKVxcbiAgICB9KVxcbn0pXFxuZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xcbiAgICBsZXQgaXQgPSBhcnJbaV07XFxuXFxuICAgIGxldCBmbGFnID0gaXQuZmxhZy5zcGxpdChcXFwifFxcXCIpO1xcbiAgICBpZiAoZmxhZ2kubGVuZ3RoID4gMCAmJiAhW1xcXCLlhajpg6hcXFwiLCBcXFwi5bey56aB55SoXFxcIl0uaW5jbHVkZXMoZmxhZ2lbMF0pKSB7XFxuICAgICAgICBpZiAoIWZsYWdpLmV2ZXJ5KGYgPT4gZmxhZy5pb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AgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XF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CAwO1xcbiAgICAgICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzID0gSlNPTi5wYXJzZShoZWFkZXJzKTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoZWFkZXJz5qC85byP6ZSZ6K+vOlxcXCIgKyBlLnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wcmVwYXJlUGFyc2VzKFt7XFxuICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICAgICAganNcXG4gICAgICAgICAgICB9XSwgaW5wdXQsbnVsbCwgdHJ1ZSk7XFxuICAgICAgICB9KTtcXG4gICAgfSksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIGlzSW1wb3J0KSA9PiB7XFxuICAgICAgICBsZXQgbmFtZSA9IGdldE15VmFyKFxcXCJwc19uYW1lXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghbmFtZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lkI3lrZflvpfmnInkuIDkuKrl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FxcInBzX21ldGhvZFxcXCIsIFxcXCJHRVRcXFwiKTtcXG4gICAgICAgIGxldCBqc29uUGF0aCA9IGdldE15VmFyKFxcXCJwc19qc29uUGF0aFxcXCIsIFxcXCJcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcbiAgICAgICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcInBzX2pzXFxcIiwgXFxcIlxcXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgIGlmIChydW5UeXBlID09PSBcXFwiSlNPTlxcXCIgJiYgIWpzb25QYXRoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pTT07mqKHlvI/kuIvlv4Xpobvloatqc29uUGF0aFxcXCI7XFxuICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT09IFxcXCJKU1xcXCIgJiYgIWpzKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pT5qih5byP5LiL5b+F6aG75aGranNcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBvYmoxID0ge1xcbiAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICBqc1xcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgb2JqMSk7XFxuICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgb2JqMSk7XFxuICAgICAgICB9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XJhbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXG4gICAgICAgIGZvciAobGV0IHJ1bGUgb2YgcnVsZXMpIHtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA+IDEpIHtcXG4gICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLmlrDlop7vvJpcXFwiICsgbmV3SSArIFxcXCIg6KaG55uW5pu05paw77yaXFxcIiArIChydWxlcy5sZW5ndGggLSBuZXdJKSk7XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgdG9hc3QoXFxcIuWvvOWFpeWksei0pVxcXCIpO1xcbiAgICB9XFxufVxcblxcbmZ1bmN0aW9uIGltcG9ydFJ1bGUocGFzcykge1xcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IFtfLCBydWxlLCBwbmFtZV0gPSBwYXNzLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICBs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Agd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOiAnLi4vbGlicy9kcnB5Mi5qcycsXFxuICAgICAgICAgICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAncXVpY2tTZWFyY2gnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IFxcXCIuL1xcXCIgKyBpdC5uYW1lLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBuYW1lcy5wdXNoKGl0Lm5hbWUpO1xcbiAgICB9XFxuICAgIGRlbGV0ZWxvc2UobmFtZXMsIHBhdGgpXFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcImluZGV4Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICBzaXRlczogcnVsZXNcXG4gICAgfSkpO1xcblxcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIGNvdW50ICsgXFxcIuS4qlxcXCI7O1xcbn1cXG5cXG5mdW5jdGlvbiBkZWxldGVsb3NlKG5hbWVzLCBwYXRoKSB7XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgcGF0aEZpbG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RlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSkpIDogKGl0Lm5hbWUgKyBcXFwiLmpzXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcbiAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGl0LmV4dCkuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgbmFtZXMucHVzaChuYW1lKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgZGVsZXRlbG9zZShuYW1lcywgcGF0aCk7XFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcImluZGV4Lmpzb25cXFw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0aC5zdGFydHNXaXRoKFxcXCJodHRwczovL2dpdGh1Yi5jb21cXFwiKSkge1xcbiAgICAgICAgICAgIHNvdXJjZUxpc3QgPSBnZW5lcmF0ZUNvbmZpZ0J5R2l0aHViKGNvbmZpZy5wYXRoKTtcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJnaXRodWJEaXJcXFwiO1xcbiAgICAgICAgICAgIC8vc291cmNlTGlzdD1bXTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoZmV0Y2goY29uZmlnLnBhdGgpIHx8IFxcXCJ7fVxcXCIpKTtcXG4gICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwgIWpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5LuO572R57uc6I635Y+W55qE6YWN572u5paH5Lu25Li656m677yM6K+35qOA5p+l572R57ucXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHNvdXJjZUxpc3QgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKTtcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJpbmRleFxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBmaWxlID0gdm9pZCAwO1xcbiAgICAgICAgbGV0IGN1cnJlbnRTb3VyY2UsIHNlYXJjaEFsbG93O1xcbiAgICAgICAgaWYgKGNvbmZpZy5jS2V5KSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3QuZmluZCh2ID0+IHYua2V5ID09PSBjb25maWcuY0tleSk7XFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50U291cmNlKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgICAgICAvL2N1cnJlbnRDb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgLy9jb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IEpTT04ucGFyc2UoZmV0Y2goc2VhcmNoQWxsb3dQYXRoKSB8fCBcXFwiW11cXFwiKTtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBkZWxldGVGaWxlKHNlYXJjaEFsbG93UGF0aCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxvYWRFcnJvciA9IHZvaWQgMDtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyxcXG4gICAgICAgICAgICBzb3VyY2VMaXN0XFxuICAgICAgICB9O1xcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIGxvYWRFcnJvciA9IGU7XFxuICAgIH1cXG5cXG4gICAgcmV0dXJuIG51bGw7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlMb2NhbChkaXJGaWxlKSB7XFxuICAgIGxldCBsaXN0ID0gZGlyRmlsZS5saXN0RmlsZXMoKTtcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuXFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGxldCBuYW1lID0gU3RyaW5nKGl0LmdldE5hbWUoKSk7XFxuICAgICAgICBsZXQgcGF0aCA9IGl0LmdldFBhdGgoKTtcXG4gICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikgfHwgaXQuaXNEaXJlY3RvcnkoKSkgY29udGludWU7XFxuICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ2V4dCc6IGAke3BhdGh9YCxcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgbWFwcGluZyA9IGdldExvYWNsTWFwcGluZyhTdHJpbmcoZGlyRmlsZS5nZXRQYXRoKCkpKTtcXG5cXG4gICAgICAgIGlmIChtYXBwaW5nLmxlbmd0aCkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIG1hcHBpbmcpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gcnVsZXMuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBpdC5rZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBydWxlc1tpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShpbmRleCwgMCwgT2JqZWN0LmFzc2lnbih7fSwgaXRlbSwge1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7aXQudG9rZXl9Y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MoanNQYXRoKSB7XFxuXFxuICAgIGxldCBtYWluID0gZXZhbEpzKHJlcXVlc3QoanNQYXRoKS5yZXBsYWNlKC9hc3luY1xcXFxzKj9mdW5jdGlvblxcXFxzKj9tYWluL2csIFxcXCJmdW5jdGlvbiBtYWluXFxcIikgKyBcXFwiXFxcXG47bWFpbjtcXFwiLCB7XFxuICAgICAgICBwYXRoTGliOiB7XFxuICAgICAgICAgICAgam9pbjogam9pblVybCxcXG4gICAgICAgICAgICByZWFkRmlsZShwYXRoKSB7XFxuICAgICAgICAgICAgICAgIHBhdGggPSBwYXRoLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSA/IHBhdGggOiAoXFxcImZpbGU6Ly9cXFwiICsgcGF0aCk7XFxuXFxuICAgICAgICAgICAgICAgIHJldHVybiBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHJlYWREaXIocGF0aCkge1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGZpbGUgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKSk7XFxuXFxuICAgICAgICAgICAgICAgIGlmICghKGZpbGUuZXhpc3RzKCkgJiYgZmlsZS5pc0RpcmVjdG9yeSgpKSkgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBmaWxlLmxpc3RGaWxlcygpKSB7XFxuICAgICAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKFN0cmluZyhpdC5nZXROYW1lKCkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkaXJuYW1lKHBhKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gam9pblVybChqc1BhdGgsIHBhKTtcXG4gICAgICAgICAgICAgICAgbGV0IG5hbWVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBmaWxlID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG5cXG4gICAgICAgICAgICAgICAgaWYgKCEoZmlsZS5leGlzdHMoKSAmJiBmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGRpckZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdC5pc0RpcmVjdG9yeSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBwYXRocztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHN0YXQoKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgICBsb2c6IGxvZyxcXG4gICAgICAgIHBhdGg6IGpzUGF0aCxcXG4gICAgICAgIHBhdGhfZGlyOiBqb2luVXJsKGpzUGF0aCwgXFxcIi4vXFxcIilcXG4gICAgfSk7XFxuICAgIGxldCBqc29uVGV4dCA9IG1haW4oKTtcXG4gICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGpzb25UZXh0KTtcXG5cXG4gICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbikpIHtcXG4gICAgICAgIHJldHVybiBmaWx0ZXJPdGhlcihqc29uKTtcXG4gICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpICYmIGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICB3cml0ZUZpbGUoam9pblVybChqc1BhdGgsIFxcXCIuL2luZGV4Lmp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xldCBjb2RlID0gXFxcIm5vXFxcIjtcXG4gICAgICAgICAgbGV0IHBhdGggPSBvYmoudXJsLnJlcGxhY2UoXFxcImZpbGU6Ly9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgIGxldCBkaXIgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcbiAgICAgICAgICBpZiAoZGlyLmlzRGlyZWN0b3J5KCkpIHtcXG4gICAgICAgICAgICBsZXQgZmxpc3QgPSBkaXIubGlzdEZpbGVzKCk7XFxuICAgICAgICAgICAgZm9yICh2YXIgZiBvZiBmbGlzdCkge1xcbiAgICAgICAgICAgICAgLy8g5qOA5p+l5paH5Lu25ZCN5piv5ZCm5LulLmpz57uT5bC+XFxuICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBqc0ZpbGVzLnB1c2goZik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKG9iai51cmwpKTtcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7IH1cXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHsgfVxcblxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgdXJsOiBqLnVybCxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgIGluZGV4OiBvYmouaSxcXG4gICAgICAgIH1cXG4gICAgICB9O1xcbiAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgfVxcbiAgICAgIH0pO1xcbiAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxuICAgICAgYmUodGFza3MsIHtcXG4gICAgICAgIGZ1bmM6IGZ1bmN0aW9uIChvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICBsZXQgcmVnZXggPSAvKOWQjeensDouKj8pKFxcXFxzKyk/XFxcXG4vZztcXG4gICAgICAgIGxldCB0aXRsZSA9IFxcXCLlkI3np7A6XFxcIiArIHBbeC5pbmRleF0ubmFtZSArIFxcXCIgXFxcIjtcXG4gICAgICAgIGxldCB1cmwgPSBwW3guaW5kZXhdLnBhdGg7XFxuICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICBsZXQgY291bnQgPSB4LmNvdW50ICE9IDAgPyBcXFwiIOa6kOaVsOmHjzpcXFwiICsgeC5jb3VudCA6IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKC9uby8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5pyJ6K+vXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuX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Sk7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBjbGljayhzLCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHRhZ0NsYXNzZXMgPSBydW50aW1lQ29uZmlnLmdldFRhZ0NsYXNzZXMoKTtcXG4gICAgICAgICAgICAgICAgaWYgKCF0YWdDbGFzc2VzLmxlbmd0aCkgcmV0dXJuIFxcXCJ0b2FzdDovL+W9k+WJjemFjee9ruayoeaciVRBR+WTpuOAglxcXCI7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLnNlbGVjdENlbnRlcih7XFxuICAgICAgICAgICAgICAgICAgICBvcHRpb25zOiB0YWdDbGFzc2VzLFxcbiAgICAgICAgICAgICAgICAgICAgY29sdW1uczogMyxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwiVEFHW1xcXCIgKyB0YWdDbGFzc2VzLmxlbmd0aCArIFxcXCJdXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNsaWNrKGEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbnB1dEJveC5zZXREZWZhdWx0VmFsdWUoXFxcIltcXFwiICsgYSArIFxcXCJdXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiB0cnVlXFxuICAgICAgICB9KSksXFxuICAgICAgICBsb25nQ2xpY2socywgaSkge1xcbiAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliIbkuqvop4bpopHmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIkpT5paH5Lu25YiG5LqrXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSxcXG4gICAgICAgICAgICAgICAgY29sOiAyLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhuYW1lID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBuYW1lID0gcGF0aC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gZmV0Y2gocGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZW5jb2RlTW9kZSA9IGdldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChlbmNvZGVNb2RlICYmIC92YXIgcnVsZXxbXFxcXHU0RTAwLVxcXFx1OUZBNV0rfGZ1bmN0aW9ufGxldCB8dmFyIHxjb25zdCB8XFxcXCh8XFxcXCl8XFxcInwnLy50ZXN0KHJ1bGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kZU1vZGUgPT09IFxcXCJHemlwXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgR1pJUCA9ICQucmVxdWlyZShcXFwiR1pJUFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gR1pJUC56aXAocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbmNvZGVNb2RlID09PSBcXFwiQmFzZTY0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYmFzZTY0RW5jb2RlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5jb2RlTW9kZSA9PT0gXFxcIkFFU1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQ3J5cHRvVXRpbCA9ICQucmVxdWlyZShcXFwiaGlrZXI6Ly9hc3NldHMvY3J5cHRvLWphdmEuanNcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChcXFwiNjg2QTY0Njg2RTc4MEEwQTBBMEEwQTBBMEEwQTBBMEFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGl2ID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlSGV4KFxcXCI2NDdBNzk3OTY0NzMwQTBBMEEwQTBBMEEwQTBBMEEwQVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGV4dERhdGEgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VVVEY4KHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZW5jcnlwdGVkMCA9IENyeXB0b1V0aWwuQUVTLmVuY3J5cHQodGV4dERhdGEsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogXFxcIkFFUy9DQkMvUEtDUzdQYWRkaW5nXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBpdlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZSA9IGVuY3J5cHRlZDAudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXJ1bGUpIHJldHVybiBcXFwidG9hc3Q6Ly/ojrflj5blpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE1ZX0lOREVYID09PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9cXFwiICsgcG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9oaWtlcjovL2ZpbGVzL19jYWNoZS9cXFwiICsgcG5hbWU7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1cmwgPSBzaGFyZVBhc3RlKGJhc2U2NEVuY29kZShydWxlKSwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL+a1t+mYlOinhueVjO+8jERSUFnop4bpopHmupDjgIxcXFwiICsgbmFtZSArIFxcXCLjgI3lpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHVybCArIFxcXCIkXFxcIiArIHBuYW1lICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0LCB0cnVlKVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIHMucmVwbGFjZSgvW+KAmeKAmF0vZywgXFxcIlxcXCIpKVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGNsaWNrKHMsIGksIG1hbmFnZSkge1xcbiAgICAgICAgICAgIHBvcC5kaXNtaXNzKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibm9fbG9hZGluZ1xcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgLy8gbWFuYWdlLmxpc3QuZm9yRWFjaCgodiwgaWkpID0+IChcXG4gICAgICAgICAgICAvLyAgIG1hbmFnZS5saXN0W2lpXSA9IGkgPT09IGlpID8gXFxcIuKAmOKAmFxcXCIgKyBuYW1lc1tpaV0gKyBcXFwi4oCZ4oCZXFxcIiA6IG5hbWVzW2lpXS5yZXBsYWNlKC9b4oCZ4oCYXS9nLCBcXFwiXFxcIilcXG4gICAgICAgICAgICAvLyApKTtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IG1hbmFnZS5saXN0W2ldLnJlcGxhY2UoL1vigJnigJhdL2csIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAobmFtZSA9PSBzb3VyY2UubmFtZSkge1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICBsZXQga2V5ID0gc291cmNlcy5maW5kKHYgPT4gdi5uYW1lID09IG5hbWUpLmtleTtcXG5cXG4gICAgICAgICAgICB1c2luZ1NvcnQuc2V0KG5hbWUpO1xcblxcbiAgICAgICAgICAgIC8vbWFuYWd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IuWIt+aWsOmFjee9rlxcXCIsIFxcXCLliIbkuqvml7bnvJbnoIE6XFxcIiArIGdldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIFxcXCLkuI3nvJbnoIFcXFwiKSwgXFxcIumdkuWwkeW5tOaooeW8jzpcXFwiICsgKGxlYWNoID8gXFxcIuW8gOWQr1xcXCIgOiBcXFwi5YWz6ZetXFxcIildLFxcbiAgICAgICAgICAgICAgICBjb2x1bW5zOiAyLFxcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuivt+mAieaLqSDml7bpl7QgXFxcIiArIGRhdGV0aW1lLFxcbiAgICAgICAgICAgICAgICBjbGljayhzLCBpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAocyA9PSBcXFwi5pS55Y+Y5qC35byPXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogKHNwZW4gPT0gMiA/IDMgOiAyKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5YCS5bqPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZXMucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi6Ieq54S25o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0dXJhbCA9IGdldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdHVyYWwgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0dXJhbFNvcnQobGlzdCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgXFxcIlxcXCIpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgbmF0dXJhbCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5L2/55So5o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdXNpbmdzdCA9IGdldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVzaW5nc3QgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNpbmdTb3J0LmdldChsaXN0KS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbmFtZS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCB1c2luZ3N0ID8gXFxcIlxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzID09IFxcXCLliLfmlrDphY3nva5cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXJ1bnRpbWVDb25maWcuaW5pdERlZmF1bHQoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChcXFwi5Yi35paw5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8qXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IENrZXkgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKS5rZXk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coQ2tleSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2ZnID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50Q29uZmlnKClcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGNmZztcXG4gICAgICAgICAgICAgICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTsqL1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCLmlrDlop5cXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3Quc3BsaWNlKG1hbmFnZS5saXN0LmluZGV4T2YoeC5uYW1lKSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCIg56e76ZmkXFxcIiArIGRsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKFxcXCLpgInmi6nop4bpopHmupAg5b2T5YmN5YWxOlxcXCIgKyBtYW5hZ2UubGlzdC5sZW5ndGggKyBcXFwi5Liq6KeG6aKR5rqQXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXCIg5pu05aSa6K+m5oOF55yLbG9nXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi6Z2S5bCR5bm05qih5byPXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBzZWxlY3QoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJ0aXRsZVxcXCI6IFxcXCLpgInmi6lcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIm9wdGlvbnNcXFwiOiBbXFxcIuS4tOaXtuWFs+mXrVxcXCIsIFxcXCLlhbPpl61cXFwiLCBcXFwi6K6+572u5a+G56CBXFxcIl0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2w6IDEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLkuLTml7blhbPpl61cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJ0ZW1wTGVhY2hcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmKGlucHV0ID09IFxcXCLlhbPpl61cXFwiKXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJsZWFjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1lbHNle1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIiwgXFxcIuiuvue9ruWvhueggVxcXFxu5oyH57q55LiN6IO955So5pe25pyJ5pWIXFxcIikuaW5wdXQoKCk9PntcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGlucHV0KXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJsZWFjaFBhc3NcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImxlYWNoUGFzc1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kvb/nlKjpu5jorqTlr4bnoIFcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxlYWNoUGFzcyA9IGdldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocy5pbmNsdWRlcyhcXFwi5YWz6ZetXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoaWtlclBvcC5jYW5CaW9tZXRyaWMoKSAhPT0gMCYmIWxlYWNoUGFzcykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuiuvue9ruWvhueggVxcXCIsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGludDogXFxcIuWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WvhueggeS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJsZWFjaFBhc3NcXFwiLCB0ZXh0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInRlbXBMZWFjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuaJk+W8gOi/h+a7pFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInRlbXBMZWFjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuaJk+W8gOi/h+a7pFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhpa2VyUG9wLmNhbkJpb21ldHJpYygpICE9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlr4bnoIHov5vooYzlhbPpl61cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L6T5YWl5a+G56CBXFxcIiwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaW50OiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQgPT09IGxlYWNoUGFzc3x8KCFsZWFjaFBhc3MmJnRleHQ9PT1TdHJpbmcocHMpKSl7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHplJnor69cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlrZXJQb3AuY2hlY2tCeUJpb21ldHJpYygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlrZXJQb3AucnVuT25OZXdUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBvcC5kaXNtaXNzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIue8lueggeexu+Wei1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnM6IFtcXFwi5LiN57yW56CBXFxcIiwgXFxcIkd6aXBcXFwiLCBcXFwiQmFzZTY0XFxcIiwgXFxcIkFFU1xcXCJdLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2w6IDEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHnnrqHnkIZcIixcInBhdGhcIjpcIkRycHlNYW5hZ2VcIixcInJ1bGVcIjpcImpzOlxcbmNvbnN0IEpTRW5naW5lID0gY29tLmV4YW1wbGUuaGlrZXJ2aWV3LnNlcnZpY2UucGFyc2VyLkpTRW5naW5lO1xcbmNvbnN0IHJ1bnRpbWVDb25maWcgPSB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XCJkcnB5XFxcIiwga2V5KTtcXG4gICAgICAgIEdNLmhhcyhHTWtleSwgKERycHlNYW5hZ2UpID0+IHtcXG4gICAgICAgICAgICBEcnB5TWFuYWdlLnB1dChrZXksIGRycHkpO1xcbiAgICAgICAgfSk7XFxuICAgIH0sIGtleSwgR01rZXksIE1ZX1RJQ0tFVCkgKyBcXFwiO1xcXFxuXFxcIiwgXFxcIlxcXCIsIGZhbHNlKTtcXG59XFxuXFxuZnVuY3Rpb24gZ2V0KGtleSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICAvL2xvZyhkcnB5TWFwLnNpemUpXFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuivt+axgjpcXFwiICsga2V5KVxcbiAgICAgICAgICAgIGRlbChBcnJheS5mcm9tKGRycHlNYXAua2V5cygpKS5hdCgwKSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2VzKCkuZmluZCh2ID0+IHYua2V5ID09PSBrZXkpO1xcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpKTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKGRycHkuZ2V0UnVsZShcXFwicHJveHlfcnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBQcm94eSA9ICQucmVxdWlyZShcXFwiTG9jYWxQcm94eVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcHJveHlVcmwgPSBQcm94eS5zdGFydFByb3h5KE1ZX1JVTEUudGl0bGUsIEdNLmdldFNlbGZLZXkoKSk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJQcm94eV9VcmxcXFwiLCBwcm94eVVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuLy9zb3VyY2UuZXh05b+F6aG75Li657ud5a+56Lev5b6EXFxuZnVuY3Rpb24gZ2V0QnlTb3VyY2Uoc291cmNlKSB7XFxuICAgIHJldHVybiBzeW5jKCgpID0+IHtcXG4gICAgICAgIGxldCBrZXkgPSBzb3VyY2Uua2V5O1xcbiAgICAgICAgLy9sb2coZHJweU1hcC5zaXplKVxcbiAgICAgICAgaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChkcnB5TWFwLnNpemUgPj0gNSkge1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHNvdXJjZS5leHQpO1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBpZiAoZHJweS5nZXRSdWxlKFxcXCJwcm94eV9ydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgbGV0IFByb3h5ID0gJC5yZXF1aXJlKFxcXCJMb2NhbFByb3h5XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBwcm94eVVybCA9IFByb3h5LnN0YXJ0UHJveHkoTVlfUlVMRS50aXRsZSwgR00uZ2V0U2VsZktleSgpKTtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcIlByb3h5X1VybFxcXCIsIHByb3h5VXJsKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gZHJweTtcXG4gICAgfSwgdGhpcykuY2FsbCgpO1xcbn1cXG5cXG5mdW5jdGlvbiBwdXQoa2V5LCBkcnB5KSB7XFxuICAgIHN5bmMoKCkgPT4gZHJweU1hcC5zZXQoa2V5LCBkcnB5KSwgdGhpcykuY2FsbCgpO1xcbn1cXG5cXG5mdW5jdGlvbiBydW5Qcm94eShkcnB5LCBhcmdzKSB7XFxuICAgIGlmICh0eXBlb2YgZHJweS5wcm94eSA9PT0gXFxcImZ1bmN0aW9uXFxcIikge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMSA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgcHJveHlTZW1hcGhvcmUuYWNxdWlyZSgpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUyID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMeetieW+heaXtumXtDpcXFwiICsgKHRpbWUyIC0gdGltZTEpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgbGV0IHJlcyA9IGRycHkucHJveHkuYXBwbHkoZHJweSwgYXJncyk7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCIy5omn6KGM5Luj55CG6ICX5pe2OlxcXCIgKyAodGltZTMgLSB0aW1lMikgKyBcXFwibXNcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiM+aAu+iAl+aXtuiAl+aXtj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queUqHzpmpTlvIBcXFwiLFxcbiAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICBjYW5TZWFyY2hTb3VyY2UuZm9yRWFjaCgodiwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxuICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgIH0sXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuXFxuXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nKGEubmFtZSkubG9jYWxlQ29tcGFyZShTdHJpbmcoYi5uYW1lKSwgdW5kZWZpbmVkLCB7XFxuICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5yZXZlcnNlKCk7XFxuXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNCkge1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICghc2VhcmNoQWxsb3cuaW5jbHVkZXModikpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDUpIHtcXG4gICAgICAgICAgICBsZXQgdGVtbGlzdCA9IHNlYXJjaEFsbG93LnNsaWNlKCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybjtcXG4gICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgfSk7XFxuICAgIH1cXG4gIH0pO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuWIhuexu1wiLFwicGF0aFwiOlwiY2F0ZWdvcn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ICAgICAgICBpZiAoY2F0ZV90ZW1wW2luZGV4XSA9PSBpKSB7XFxuICAgICAgICAgICAgdCA9IFxcXCI8Yj48Zm9udCBjb2xvcj1cXFwiICsgY29sb3IgKyBcXFwiPlxcXCIgKyB0ICsgXFxcIjwvZm9udD48L2I+XFxcIjtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBpdC52O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IFxcXCItMVxcXCIpIHtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBcXFwidW5kZWZpbmVkXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZm9sZCA9PSAxKSB7XFxuICAgICAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgdCxcXG4gICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgobykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IG8uaTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImlzX2RlZlxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX29iaiA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJjYXRlX29ialxcXCIsIHt9KTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfdGVtcCA9IG8uY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICBpZiAoY2F0ZV90ZW1wLmNvbnN0cnVjdG9yICE9IEFycmF5KSB7XFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5pbmRleDtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGMpXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IGkgKyBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjYXRlX29ialtvLmNhdGVdID0gY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjYXRlX3RlbXApXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfdGVtcFxcXCIsIGNhdGVfdGVtcCk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX29ialxcXCIsIGNhdGVfb2JqKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcbiAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXG4gICAgICAgICAgICAgICAgaTogaSxcXG4gICAgICAgICAgICAgICAgY2F0ZTogY2F0ZVxcbiAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgfSlcXG4gICAgfVxcbiAgfVxcbn1cXG5cXG5mdW5jdGlvbiBnZXRGbCgpIHtcXG4gIGZsID0gT2JqZWN0LmtleXMoZmwpLmZpbHRl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YW5hZ2VcXFwiKTtcXG4gICAgICAgICAgRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkuaW5pdChydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KSk7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9KVxcbiAgICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiBcXFwi6YeN6L295rqQXFxcIixcXG4gICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIH0pXFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLmn6XnnIvmupDku6PnoIFcXFwiLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIGxldCBjb2RlID0gRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkucnVuTWFpbihcXFw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xcbiAgICAgICAgICBpZiAoT2JqZWN0LmtleXMoY3VycmVudCkubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGN1cnJlbnQudGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGN1cnJlbnQucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogY3VycmVudC5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGN1cnJlbnQudHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBpdGVtLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogY3VycmVudC5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBjdXJyZW50LmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oY3VycmVudC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGl0ZW0ucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogaXRlbS5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGl0ZW0udHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBjdXJyZW50LmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogaXRlbS5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpdGVtLmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxldCBuYXJyID0gJC5zd2FwQXJyYXlFbGVtZW50cyhpbmRleHMsIGN1cnJlbnQuZXh0cmEuaW5kZXgsIGl0ZW0uZXh0cmEuaW5kZXgpO1xcblxcbiAgICAgICAgICAgICQudWlDb25maWcuc2V0KG5hcnIsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgaCA9ICfigJzigJzigJ3igJ0nO1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0ZW0udGl0bGU7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIumAieaLqeenu+WKqOeahOebruagh1xcXCIpO1xcbiAgICAgICAgICAgIGlmICgvdGV4dF9pY29ufGF2YXRhcnxpY29uX3NtYWxsXzMvLnRlc3QoaXRlbS50eXBlKSkge1xcbiAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKC9pY29uXzFfc2VhcmNoLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gXFxcIuKeoe+4j1xcXCIgKyB0aXRsZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaCArIHRpdGxlLFxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiLCBpdGVtKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaSlcXG4gICAgICAgIGl0ZW1bXFxcImV4dHJhXFxcIl0gPSB7XFxuICAgICAgICAgIGtleTogaXRlbS5rZXksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiLFxcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgaW5kZXg6IGl0ZW0uaW5kZXgsXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuiuvue9rlxcXCIpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gLTE7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0sIGl0ZW0ua2V5KVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCEvaWNvbl8xX3NlYXJjaHxhdmF0YXIvLnRlc3QoaXRlbS5jb2xfdHlwZSkpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNouWbvuagh1xcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbWdcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA9PSBrZXkpWzBdLmV4dHJhLmlkO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHBpYzogaW5wdXQgfSlcXG4gICAgICAgICAgICAgIH0sIGtleSlcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLmjaLmupBcXFwiICYmIGl0ZW0ua2V5ICE9IFxcXCLmkJzntKLmqKHlvI9cXFwiKSB7XFxuICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi5L+u5pS55ZCN56ewXFxcIixcXG4gICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcInRpdGxlXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHRpdGxlOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpdGVtLmV4dHJhLkxvbmdDbGljayA9IGxvbmdjbGlja3M7XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIHVpb2JqID0gdWlvYmoubWFwKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBpdGVtLmV4dHJhID0ge1xcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCJcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgIH0pXFxuICAgIH1cXG4gICAgZCA9IGQuY29uY2F0KHVpb2JqKTtcXG5cXG4gICAgaWYgKGluZGV4cy5zb21lKHggPT4geC5pbmRleCA9PSAtMSkgJiYgdWltb2RlKSB7XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5bey56e76ZmkXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICAgIH0pXFxuICAgICAgaW5kZXhzLmZpbHRlcih4ID0+IHguaW5kZXggPT0gLTEpLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBtYXAgPSBuZXcgTWFwKHN1aW9iai5tYXAob2JqID0+IFtvYmoua2V5LCBvYmpdKSk7XFxuICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuICAgICAgICBvYmoudXJsID0gJChcXFwiXFxcIikubGF6eVJ1bGUoKGtleSwgaW5kZXgpID0+IHtcXG4gICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gaW5kZXg7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIHJldHVyb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1xcbiAgICAgICAgTG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWkjeWItlxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICBjb3B5KEpTT04uc3RyaW5naWZ5KHVpX2NvbmZpZy55aSkpO1xcbiAgICAgICAgICB9LCB1aV9jb25maWcpLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWvvOWFpVxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIikuaW5wdXQoKHVjKSA9PiB7XFxuICAgICAgICAgICAgICB2YXIgeWkgPSB7fTtcXG4gICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHlpID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgICAgIGlmICh5aS5oYXNPd25Qcm9wZXJ0eShcXFwidWlcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgIHVjLnlpID0geWk7XFxuICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWMpO1xcbiAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgdWMpXFxuICAgICAgICAgIH0sIHVpX2NvbmZpZylcXG4gICAgICAgIH1dXFxuICA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BTVMsIHRpdGxlKSB7XFxuICAgICAgICBmdW5jdGlvbiB0b1BhdGgodmFsdWUpIHtcXG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnc3RyaW5nJykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gW107XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwYXRoID0gW107XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZhbHVlLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxuICAgICAgICAgICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBwYXRoO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgICAgICAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBwYXRoW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W2tleV07XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBjdXJyZW50O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IE1ZX1BBUkFNUy5ydW5UeXBlWzBdO1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pKTtcXG4gICAgICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFwiSlNPTlxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBwYXJhbS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IE9iamVjdC5hc3NpZ24oe30sIHBhcmFtLmhlYWRlcnMgfHwge30sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiBnZXRKc29uKGpzb24sIHRvUGF0aChwYXJhbS5qc29uUGF0aCkpLFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09IFxcXCJKU1xcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcnNlO1xcbiAgICAgICAgICAgICAgICBpZiAoTVlfUEFSQU1TLmluZGV4KSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyB0aXRsZSkuZ2V0SnNvbigpW01ZX1BBUkFNUy5pbmRleFswXV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKGRlY29kZVVSSUNvbXBvbmVudChNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IHJlcyA9IG5ldyBGdW5jdGlvbihcXFwidXJsXFxcIiwgXFxcInNlbGZcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzID09PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiByZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgkLnR5cGUocmVzKSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgIC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QuZW50cmllcyhpdGVtKTtcXG4gICAgICAgICAgICBjb25zdCBwcm9jZXNzZWRFbnRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgLy8g5aaC5p6c5pyJ6YeN5ZG95ZCN5Zue6LCD5Ye95pWw77yM5YiZ6LCD55So5a6DXFxuICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbmFtZUNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIHJldHVybiBba2V5LCB2YWx1ZV07XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgY29uc3QgZmlsdGVyZWRFbnRyaWVzID0gc2hvdWxkRXhjbHVkZSA/XFxuICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+ICFrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSkgOlxcbiAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx0ZXIoKFtrZXldKSA9PiBrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSk7XFxuICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5mcm9tRW50cmllcyhmaWx0ZXJlZEVudHJpZXMpO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICB9LFxcbiAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgfSxcXG4gICAgdHJhbnNm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xcIixcXG4gICAgICAgIFxcXCJvcHRpbWl6Ze+8muWcqOmAiea6kOeVjOmdouWIt+aWsOmFjee9ruWQjuS8muWQjOatpeabtOaWsOaVsOmHj+aYvuekuuOAglxcXCIsXFxuICAgIF1cXG59LCB7XFxuICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8xMCAgTWF4VmVyc2lvbiAyNVxcXCIsXFxuICAgIHJlY29yZHM6IFtcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrlop7liqDmm7TmlrDml6Xlv5fjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8mumAiea6kOmVv+aMieiPnOWNle+8jOWinuWKoOi3s+i9rOe9kemhte+8jOafpeeci+a6kOeggeOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN57yW6L6R6Kej5p6Q55WM6Z2i5rWL6K+VanPop6PmnpDkuIDnm7TlpLHotKXjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjWdpdGh1YuiuoumYhe+8jOS8muWIoOmZpOWFqOmDqOinhOWImeaWh+S7tuOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN6Kej5p6Q6LCD55So5aSx6LSl44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3mm7TmjaLphY3nva7ml7bmsqHmnInlj4rml7bmuIXnqbpkcnB557yT5a2Y44CCXFxcIixcXG4gICAgICAgIFxcXCJvcHRpbWl6Ze+8muabtOaUueiuoumYheabtOaWsOetlueVpe+8jOS8muWIoOmZpOacrOWcsOWkseaViOa6kOOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlrBkcnB5Mi5qc+OAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrkvJjljJbop6PmnpBmbGFn5Yy56YWN44CCXFxcIixcXG5cXG4gICAgXVxcbn0sIHtcXG4gICAgdGl0bGU6IFxcXCIyMDI0LzA2LzA5IE1heFZlcnNpb24gMjBcXFwiLFxcbiAgICByZWNvcmRzOiBbXFxuICAgICAgICBcXFwi4oCY4oCYbmV34oCZ4oCZ77ya5pSv5oyBcHJveHlfcnVsZeS7o+eQhuOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5LqR55uY6ZO+5o6l5LiN6LCD5Y+W5LqR55uY566A44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3lk5Tlk6nlvbHop4bkuI3og73kvb/nlKjop6PmnpDjgIJcXFwiLFxcbiAgICBdXFxufV07XCJ9XSIsImljb24iOiIiLCJwcm94eSI6IiJ9
Add Comment
Please, Sign In to add comment