Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:二级页面详情¥page_detail¥蒋依依 体验不一样的性爱@@eyJkYXRhIjoie1wiYXNzb2NpYXRlZE1vZGVsc01hcEZvckpvaW5UYWJsZVwiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhGS1wiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhvdXRGS1wiOnt9LFwiZmllbGRzVG9TZXRUb0RlZmF1bHRcIjpbXSxcImdtdE1vZGlmaWVkXCI6MCxcImlkXCI6MCxcImxhc3RfY2hhcHRlcl9ydWxlXCI6XCJcIixcImxpc3RUb0NsZWFyQXNzb2NpYXRlZEZLXCI6W10sXCJsaXN0VG9DbGVhclNlbGZGS1wiOltdLFwicGFnZUxpc3RcIjpbe1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHlcIixcInBhdGhcIjpcImRycHlcIixcInJ1bGVcIjpcImZ1bmN0aW9uIGluaXRIaWtlcigpIHtcXG4gICAgY29uc3QgaXNDbG9zZUxvZyA9ICFnZXRJdGVtKFxcXCJ1c2VMb2dcXFwiLCBcXFwiXFxcIik7XFxuICAgIGNvbnN0IGxvY2FsS2V5ID0gXFxcImRycHlcXFwiO1xcbiAgICBjb25zdCBDcnlwdG9VdGlsID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2Fzc2V0cy9jcnlwdG8tamF2YS5qc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmxvY2FsID0ge1xcbiAgICAgICAgc2V0KHJ1bGVrZXksIGssIHYpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKGxvY2FsS2V5ICsgXFxcIkBcXFwiICsgcnVsZWtleSArIFxcXCJAXFxcIiArIGssIHYpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldChydWxla2V5LCBrLCB2KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHN0b3JhZ2U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AgICAgQ29va2llOiBcXFwiI25vQ29va2llI1xcXCJcXG4gICAgICAgICAgICB9LCBvYmouaGVhZGVycyk7XFxuICAgICAgICAgICAgaWYgKHVybCA9PT0gXFxcImh0dHBzOi8vYXBpLm5uLmNpL29jci9iNjQvdGV4dFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNbXFxcIkNvbnRlbnQtVHlwZVxcXCJdID0gXFxcInRleHQvcGxhaW5cXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5qcy80LjEuMC9tdXN0YWNoZS5qc1xcXCIpO1xcbiAgXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2pzb25wYXRoLXBsdXMuZ2l0aHViLmlvL0pTT05QYXRoL2Rpc3QvaW5kZXgtYnJvd3Nlci11bWQuY2pzXFxcIik7XFxuICAgIGdsb2JhbFRoaXMuY2hlZXJpbyA9IHtcXG4gICAgICAgIGppbmphMih0ZW1wbGF0ZSwgb2JqKSB7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuICQubG9nKEppbkphLnJlbmRlcih0ZW1wbGF0ZSwgb2JqKSk7XFxuICAgICAgICB9LFxcbiAgICAgICAganAocGF0aCwganNvbikge1xcbiAgICAgICAgICAgIHJldHVybiBKUC5KU09OUGF0aCh7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIGpzb25cXG4gICAgICAgICAgICB9KVswXTtcXG4gICAgICAgIH1cXG4gICAgfSovXFxuICAgIGdsb2JhbFRoaXMucGRmYSA9IF9wZGZhO1xcbiAgICBnbG9iYWxUaGlzLnBkID0gX3BkO1xcbiAgICBnbG9iYWxUaGlzLnBkZmggPSBfcGRmaDtcXG4gICAgU3RyaW5nLnByb3RvdHlwZS5yZXBsYWNlQWxsID0gZnVuY3Rpb24gKHNlYXJjaCwgcmVwbGFjZW1lbnQpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLnNwbGl0KHNlYXJjaCkuam9pbihyZXBsYWNlbWVudCk7XFxuICAgIH07XFxuICAgIGxldCAkdG9TdHJpbmcgPSBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmc7XFxuICAgIEZ1bmN0aW9uLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uICgpIHtcXG4gICAgICAgIHJldHVybiAkdG9TdHJpbmcuYXBwbHkodGhpcykudHJpbSgpO1xcbiAgICB9O1xcbiAgICBpZiAoaXNDbG9zZUxvZykge1xcbiAgICAgICAgLy8g6YeN5YaZY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgIGNvbnNvbGUubG9nID0gZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgIC8vIOajgOafpeS8oOWFpeWPguaVsOeahOaVsOmHj1xcbiAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzlj4LmlbDmlbDph4/lpKfkuo4x77yM6LCD55So5Y6f5aeL55qEY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgICAgICAgICAgLy9vcmlnaW5hbExvZy5hcHBseShjb25zb2xlLCBhcmd1bWVudHMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgLy8g5aaC5p6c5Y+C5pWw5Y+q5pyJ5LiA5Liq77yM5YiZ5LiN5YGa5Lu75L2V5pON5L2cXFxuICAgICAgICB9O1xcbiAgICB9XFxufVxcbmluaXRIaWtlcigpO1xcbmNvbnN0IGRycHlQYXRoID0gZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIik7XFxuXFxuaWYgKCFmaWxlRXhpc3QoZHJweVBhdGgpKSB7XFxuICAgIHRocm93IG5ldyBFcnJvcihcXFwi57y65bCRZHJweS5qc+i/kOihjOW6k1xcXCIpO1xcbn1cXG5sZXQgZHJweSA9ICQucmVxdWlyZShkcnB5UGF0aCk7XFxuLypcXG5sZXQgY3VycmVudFBhdGggPSBcXFwiXFxcIjtcXG5sZXQgJGluaXQgPSBkcnB5LmluaXQ7XFxuZHJweS5pbml0ID0gZnVuY3Rpb24oZXh0KSB7XFxuICAgIGlmIChleHQgPT09IGN1cnJlbnRQYXRoKSByZXR1cm47XFxuICAgICRpbml0LmNhbGwodGhpcywgZXh0KTtcXG4gICAgY3VycmVudFBhdGggPSBleHQ7XFxufSovXFxuJC5leHBvcnRzID0gZHJweTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzFfd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9XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gY291bnQ7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gY2FjaGVTaG93VGlwcygpIHtcXG4gICAgICAgIC8qaWYgKHN0b3JhZ2UwLmdldE15VmFyKGlkICsgXFxcImVyaW5mb1xcXCIpKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShcXFwi5b2T5YmN5Li657yT5a2YLOeCueaIkeWIt+aWsFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGM6IFxcXCJncmV5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaWQgKyBcXFwiZXJpbmZvXFxcIilcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGlkKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSlcXG4gICAgICAgIH0qL1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIHN1YnN0cihzdHIsIG1heExlbmd0aCkge1xcbiAgICAgICAgbGV0IGxlbiA9IDA7XFxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgIGlmIChzdHIuY2hhckNvZGVBdChpKSA+IDI1NSkge1xcbiAgICAgICAgICAgICAgICBsZW4gKz0gMjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZW4rKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGxlbiA+IG1heExlbmd0aCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gc3RyLnNsaWNlKDAsIGkpICsgJy4uLic7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHN0cjtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBzZXREZXNjKGRlc2MsIG51bSkge1xcbiAgICAgICAgaWYgKGRlc2MgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgfVxcbiAgICAgICAgZGVzYyA9IGRlc2MuY29uc3RydWN0b3IgPT0gQXJyYXkgPyBkZXNjLmpvaW4oJzxicj4nKSA6IGRlc2M7XFxuICAgICAgICBpZiAoZGVzYy5yZXBsYWNlKC8oPGJyPnxcXFxccyspL2csICcnKS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmlnX2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICdiaWdfYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICByZXR1cm47XFxuICAgICAgICB9XFxuXFxuICAgICAgICBjb25zdCBtYXJrID0gJ2Rlc2MnO1xcbiAgICAgICAgbnVtID0gdHlwZW9mKG51bSkgPT0gJ3VuZGVmaW5lZCcgPyAxMDAgOiBudW1cXG4gICAgICAgIGRlc2MgPSBkZXNjLnN0YXJ0c1dpdGgoJ+OAgOOAgCcpID8gZGVzYyA6ICfjgIDjgIAnICsgZGVzYztcXG4gICAgICAgIGRlc2MgPSBkZXNjLnJlcGxhY2UoLycvZywgXFxcIiYjMzk7XFxcIik7XFxuICAgICAgICBkZXNjID0gZGVzYy5yZXBsYWNlKC9cXFxcclxcXFxuL2csIFxcXCI8YnI+XFxcIik7XFxuICAgICAgICBkZXNjID0gZGVzYy5yZXBsYWNlKC9cXFxcbi9nLCBcXFwiPGJyPlxcXCIpO1xcbiAgICAgICAgbGV0IHNkZXNjID0gc3Vic3RyKGRlc2MsIG51bSk7XFxuXFxuICAgICAgICB2YXIgY29sb3JzID0ge1xcbiAgICAgICAgICAgIHNob3c6IFxcXCJibGFja1xcXCIsXFxuICAgICAgICAgICAgaGlkZTogXFxcImdyZXlcXFwiXFxuICAgICAgICB9XFxuXFxuICAgICAgICB2YXIgbGF6eSA9ICQoYCNub0xvYWRpbmcjYCkubGF6eVJ1bGUoKGRjLCBzZGMsIG0sIGNzKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHNob3cgPSBzdG9yYWdlMC5nZXRJdGVtKG0sICcwJyk7XFxuICAgICAgICAgICAgdmFyIHRpdGxlID0gZmluZEl0ZW0oJ2Rlc2MnKS50aXRsZTtcXG4gICAgICAgICAgICB2YXIgcmUgPSAvKDxcXFxcL3NtYWxsPjxicj4uKj8+KS4rL2c7XFxuICAgICAgICAgICAgdmFyIGV4cCA9ICflsZXlvIA6JztcXG4gICAgICAgICAgICB2YXIgcmV0ID0gJ+aUtui1tzonO1xcbiAgICAgICAgICAgIGlmIChzaG93ID09ICcxJykge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBzZGMgKyAnPC9zbWFsbD4nKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8oPFxcXFwvc21hbGw+PGJyPlxcXFw8Zm9udCBjb2xvcj1cXFwiKS4qPyhcXFwiPikvLCAnJDEnICsgY3MuaGlkZSArICckMicpXFxuXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0obSwgJzAnKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoZXhwLCByZXQpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBkYyArICc8L3NtYWxsPicpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXC9zbWFsbD48YnI+XFxcXDxmb250IGNvbG9yPVxcXCIpLio/KFxcXCI+KS8sICckMScgKyBjcy5zaG93ICsgJyQyJylcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMScpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gYGhpa2VyOi8vZW1wdHlgXFxuICAgICAgICB9LCBkZXNjLCBzZGVzYywgbWFyaywgY29sb3JzKVxcbiAgICAgICAgdmFyIHNjID0gc3RvcmFnZTAuZ2V0SXRlbShtYXJrLCAnMCcpID09ICcwJyA/ICflsZXlvIA6JyA6ICfmlLbotbc6JztcXG4gICAgICAgIHZhciBkYyA9IHN0b3JhZ2UwLmdldEl0ZW0obWFyaywgJzAnKSA9PSAnMCcgPyBzZGVzYyA6IGRlc2M7XFxuICAgICAgICB2YXIgY3MgPSBzdG9yYWdlMC5nZXRJdGVtKG1hcmssICcwJykgPT0gJzAnID8gY29sb3JzLmhpZGUgOiBjb2xvcnMuc2hvdztcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICcnICsgJzxiPjxmb250IGNvbG9yPVxcXCIjMDk4QUMxXFxcIj7iiLfliafmg4XnroDku4tcXHQ8L2ZvbnQ+PC9iPicgKyBcXFwiPHNtYWxsPjxhIHN0eWxlPSd0ZXh0LWRlY29yYXRpb246IG5vbmU7JyBocmVmPSdcXFwiICsgbGF6eSArIFxcXCInPlxcXCIgKyBzYyArICc8L2E+PC9zbWFsbD48YnI+PGZvbnQgY29sb3I9XFxcIicgKyBjcyArICdcXFwiPicgKyBgJHtkY31gICsgJzwvc21hbGw+JyxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3JpY2hfdGV4dCcsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6ICdkZXNjJyxcXG4gICAgICAgICAgICAgICAgbGluZVNwYWNpbmc6IDYsXFxuICAgICAgICAgICAgICAgIHRleHRTaXplOiAxNSxcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IHRydWUsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgfVxcblxcbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoU3RyaW5nLnByb3RvdHlwZSwgJ1NwbGl0Jywge1xcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uKHMsIGUpIHtcXG4gICAgICAgICAgICBpZiAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zcGxpdChzKS5maWx0ZXIoaXRlbSA9PiBpdGVtICE9PSAnJyk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3BsaXQocyk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICAgIGVudW1lcmFibGU6IGZhbHNlLFxcbiAgICB9KTtcXG5cXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoQXJyYXkucHJvdG90eXBlLCB7XFxuICAgICAgICBleGNsdWRlS2V5czoge1xcbiAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbihrZXlzLCBleGNsdWRlLCByZW5hbWVDYWxsYmFjaykge1xcbiAgICAgICAgICAgICAgICAvLyDnoa7lrprmmK/mjpLpmaTov5jmmK/lj6rkv53nlZnplK5cXG4gICAgICAgICAgICAgICAgY29uc3Qgc2hvdWxkRXhjbHVkZSA9IHR5cGVvZiBleGNsdWRlID09PSAnYm9vbGVhbicgPyBleGNsdWRlIDogdHJ1ZTtcXG4gICAgICAgICAgICAgICAgY29uc3Qga2V5c1RvSGFuZGxlID0gQXJyYXkuaXNBcnJheShrZXlzKSA/IGtleXMgOiBbXTtcXG5cXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLm1hcOmBjeWOhuaVsOe7hOS4reeahOavj+S4quWFg+e0oFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrmlbDnu4TvvIzpgJLlvZLosIPnlKhleGNsdWRlS2V5c1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaXRlbSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS5leGNsdWRlS2V5cyhleGNsdWRlLCBrZXlzLCByZW5hbWVDYWxsYmFjayk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICE9PSBudWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5pyJ6YeN5ZG95ZCN5Zue6LCD5Ye95pWw77yM5YiZ6LCD55So5a6DXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVuYW1lQ2FsbGJhY2sgPT09ICdmdW5jdGlvbicpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2tleSwgdmFsdWVdO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlcmVkRW50cmllcyA9IHNob3VsZEV4Y2x1ZGUgP1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+ICFrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSkgOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+IGtleXNUb0hhbmRsZS5pbmNsdWRlcyhrZXkpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKGZpbHRlcmVkRW50cmllcyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgICAgIH0sXFxuICAgICAgICB0cmFuc2Zvcm1LZXlzOiB7XFxuICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uKGtleU1hcHBpbmcpIHtcXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLm1hcOmBjeWOhuaVsOe7hOS4reeahOavj+S4quWFg+e0oFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrmlbDnu4TvvIzpgJLlvZLosIPnlKh0cmFuc2Zvcm1LZXlzXFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLnRyYW5zZm9ybUtleXMoa2V5TWFwcGluZyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICE9PSBudWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNmb3JtZWRFbnRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdLZXkgPSBrZXlNYXBwaW5nW2tleV0gfHwga2V5OyAvLyDlpoLmnpzplK7lnKjmmKDlsITkuK3vvIzkvb/nlKjmlrDplK7vvJvlkKbliJnkvb/nlKjljp/lp4vplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtuZXdLZXksIHZhbHVlXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKHRyYW5zZm9ybWVkRW50cmllcyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIGxldCBzb3J0b2JqID0gW1xcbiAgICAgICAgZm9udHN0eWxlKFxcXCLmraPluo9cXFwiLCB7XFxuICAgICAgICAgICAgYzogXFxcIiMxQUFEMTlcXFwiLFxcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJiXFxcIlxcbiAgICAgICAgfSksXFxuICAgICAgICBmb250c3R5bGUoXFxcIumAhuW6j1xcXCIsIHtcXG4gICAgICAgICAgICBjOiBcXFwiI0ZG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ID0gcGFydHNbMF0gLSAxOyAvLyDlh48x5piv5Zug5Li65pWw57uE57Si5byV5LuOMOW8gOWni1xcbiAgICAgICAgICAgICAgICB2YXIgZW5kID0gcGFydHNbMV0gLSAxO1xcbiAgICAgICAgICAgICAgICAvLyDkvb/nlKhBcnJheS5wcm90b3R5cGUuc2xpY2XmnaXojrflj5blrZDmlbDnu4RcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFycmF5LnNsaWNlKHN0YXJ0LCBlbmQgKyAxKTsgLy8g5YyF5ous57uT5p2f57Si5byV77yM5omA5Lul5YqgMVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICB9LFxcbiAgICB9KVxcblxcbiAgICBsZXQgc291cmNlID0ge307XFxuICAgIGlmIChNWV9QQVJBTVMuc291cmNlKSB7XFxuICAgICAgICBzb3VyY2UgPSBNWV9QQVJBTVMuc291cmNlO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgc291cmNlID0gcnVudGltZUNvbmZpZy5maW5kU291cmNlKE1ZX1BBUkFNUy5za2V5KTtcXG4gICAgICAgIE1ZX1BBUkFNUy5zb3VyY2UgPSBzb3VyY2U7XFxuICAgICAgICBzZXRQYWdlUGFyYW1zKE1ZX1BBUkFNUyk7XFxuICAgIH1cXG5cXG4gICAgY29uc3QgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcblxcbiAgICBEcnB5TWFuYWdlLmluaXRQYWdlKFxcXCJlclxcXCIpO1xcblxcbiAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcXG4gICAgbGV0IHN0eXBlID0gZHJweS5nZXRSdWxlKFxcXCLnsbvlnotcXF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xpdFBhZ2UodHMubGVuZ3RoKVxcbiAgICAgICAgICAgIGxldCB0YyA9IGNvdW50VG90YWxCeXRlcyhmaW5kTG9uZ2VzdEVsZW1lbnQodHMpKTtcXG4gICAgICAgICAgICBpZiAodHMuZmlsdGVyKGUgPT4gZSAhPSBcXFwiXFxcIikubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIHBsYXlwYWdlc1tpXSA9IHBhZ2VzO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodGMgPiAyNCkge1xcbiAgICAgICAgICAgICAgICBjb2wgPSBcXFwidGV4dF8xXFxcIjtcXG4gICAgICAgICAgICAgICAgaW1nID0gXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vbW92aWUvMTQ2LnN2Z1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICh0YyA+PSAxMiAmJiB0YyA8IDE1KSB7XFxuICAgICAgICAgICAgICAgIGNvbCA9IFxcXCJ0ZXh0XzNcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGMgPj0gMTUpIHtcXG4gICAgICAgICAgICAgICAgY29sID0gXFxcInRleHRfMlxcXCI7XFxuICAgICAgICAgICAgICAgIHRleHRhbGlnbiA9IFxcXCJsZWZ0XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBsYXlvYmogPSB0LnNwbGl0KFxcXCIjXFxcIikubWFwKChqKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBrID0gai5zcGxpdChcXFwiJFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICAgICAgICAgIGxldCB1aWQgPSAoa1sxXSB8fCBrWzBdKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIHN0aXRsZTogdCxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICAgICAgc3VybDogdWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXNOb3ZlbD9cXFwiaGlrZXI6Ly9wYWdlL25vdmVsI2F1dG9QYWdlIyNyZWFkVGhlbWUjXFxcIjoodWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5LnJlcGxhY2UoJ1xcXCJpZFxcXCInLCAnXFxcIicgKyB1aWQgKyAnXFxcIicpKSxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgICAgICAgICAgICBpZDoga1sxXSxcXG4gICAgICAgICAgICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9KSovXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGlmIChzdHlwZSA9PSBcXFwi5ryr55S7XFxcIiB8fCBzdHlwZSA9PSBcXFwi5bCP6K+0XFxcIikge1xcblxcbiAgICAgICAgICAgICAgICB2YXIgZG93bmxvYWRsYXp5ID0gJC50b1N0cmluZygoa2V5LCBza2V5LCB0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBHTVxcbiAgICAgICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzVlOGYwLTIyZTgtNTI3MC1hOWQxLTgyNmY1M2YxNzdhZFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uc2V0U2VsZktleShrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiLFxcXCJEcnB5TWFuYWdlP3J1bGU9XFxcIit0aXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0KHNrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC5zcGxpdChcXFwiI1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IEpTT04ucGFyc2UoZHJweS5wbGF5KGlucHV0WzFdLCBpbnB1dFswXSkpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdC51cmwuc3RhcnRzV2l0aChcXFwicGljczovL1xcXCIpKSByZXR1cm4gcmVzdWx0LnVybDtcXG4gICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKHJlc3VsdC51cmwuc3RhcnRzV2l0aChcXFwibm92ZWw6Ly9cXFwiKSkgcmV0dXJuIEpTT04ucGFyc2UocmVzdWx0LnVybC5yZXBsYWNlKFxcXCJub3ZlbDovL1xcXCIsIFxcXCJcXFwiKSkuY29udGVudDtcXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5ryr55S75oiW5q2j5paH6I635Y+W5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIH0sIEdNLmdldFNlbGZLZXkoKSwgTVlfUEFSQU1TLnNrZXksIE1ZX1JVTEUudGl0bGUpO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2hhcHRlckxpc3QgPSBwbGF5b2JqLmV4Y2x1ZGVLZXlzKFtcXFwic3VybFxcXCIsIFxcXCJzdGl0bGVcXFwiXSwgZmFsc2UpLnRyYW5zZm9ybUtleXMoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInN1cmxcXFwiOiBcXFwidXJsXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJzdGl0bGVcXFwiOiBcXFwidGl0bGVcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShjaGFwdGVyTGlzdCkpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLkuIvovb1cXFwiICsgc3R5cGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvZG93bmxvYWQudmlldyNub1JlY29yZEhpc3RvcnkjI25vUmVmcmVzaCM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYnLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2hhcHRlckxpc3Q6IFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmZvOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tOYW1lOiBpbmZvLnZvZF9uYW1lLCAvL+a8q+eUu+WQjeensCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZU5hbWU6IFxcXCJEUlBZXFxcIiArIE1ZX1BBUkFNUy5zbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9va1RvcFBpYzogaW5mby52b2RfcGljLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJzZUNvZGU6IGRvd25sb2FkbGF6eSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmlldzogXFxcIjFcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKzlnLDkuabmnrZcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiAnaGlrZXI6Ly9wYWdlL0Jvb2tyYWNrLnZpZXcjbm9SZWNvcmRIaXN0b3J5Iz9ydWxlPeacrOWcsOi1hOa6kOeuoeeQhiZydWxlTmFtZT0nICsgXFxcIkRSUFlcXFwiICsgTVlfUEFSQU1TLnNuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBwbGF5b2JqID0gJC5zcGxpdEFycmF5QnlSYW5nZXMocGxheW9iaiwgcGFnZXMpO1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5b2JqO1xcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuaaguaXoOaSreaUvua6kOaIluaSreaUvuWIl+ihqOWumuS9jemUmeivr1xcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IE1ZX1BBUkFNUy52b2RJZC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xcbiAgICAgICAgfVxcbiAgICAgICAgJC5leHRlbmQoe1xcbiAgICAgICAgICAgIHRlbXBfbGlzdDogcGxheVVybExpc3RbbG9jYXRpb25dLFxcbiAgICAgICAgfSlcXG4gICAgICAgIGxldCBwbGF5cCA9IHBsYXlwYWdlc1tsb2NhdGlvbl07XFxuXFxuICAgICAgICBpZiAocGxheXAgJiYgcGxheXAubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1wID0ge1xcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfMScsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGFnZWFyciA9IHBsYXlwLm1hcCgoeCwgaSkgPT4gaSA9PSBwYWdlbnVtID8gJ+KAnOKAnOKAneKAnScgKyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KTtcXG4gICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlwYWdlXFxcIilcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn5LiK5LiA6aG1JyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0gPSBwY291bnQgLSAxO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBsb2NhdGlvbiwgcGNvdW50KSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKHBhZ2VhcnIsIDMpLnNlbGVjdCgobG9jYXRpb24pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKE1ZX0lOREVYKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgIH0sIGxvY2F0aW9uKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSsrO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1dKVxcbiAgICAgICAgICAgIC8qcGxheXAgPSBwbGF5cC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgICBsZXQgb2JqID0gT2JqZWN0LmFzc2lnbih7fSwgdGVtcCwge1xcbiAgICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgKHBhZ2VudW0gPT0gaSA/IHguZm9udGNvbG9yKFxcXCJyZWRcXFwiKSA6IHgpLFxcbiAgICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwicGFnZW51bVxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgJC50ZW1wX2xpc3RbaV0pO1xcbiAgICAgICAgICAgICAgICAgICBmaW5kSXRlbXNCeUNscyhcXFwicGxheXBhZ2VcXFwiKS5mb3JFYWNoKCh4LCBpaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IHgudGl0bGUucmVwbGFjZSgv4oCYfOKAmXzigJx84oCdfDxbXj5dKz4vZywgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgIGlmIChpaSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSA9ICfigJzigJzigJ3igJ0nICsgdGl0bGUuZm9udGNvbG9yKFxcXCJyZWRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh4LmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgIH0sIGkpLFxcbiAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIHRlbXAuZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIiArIGksXFxuICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5cGFnZWxpbmVcXFwiLCBwbGF5cCkqL1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGxpc3QpIHtcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlsaXN0c1xcXCIsIGxpc3QpO1xcbiAgICAgICAgfVxcbiAgICAgICAgdXBkYXRlSXRlbShcXFwibG9jYXRpb25AXFxcIiArIGN1cnJlbnRMb2NhdGlvbiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBmcm9tW2N1cnJlbnRMb2NhdGlvbl0sXFxuICAgICAgICB9KTtcXG4gICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxvY2F0aW9uQFxcXCIgKyBsb2NhdGlvbiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIGZyb21bbG9jYXRpb25dICsgXFxcIuKAneKAnVxcXCIsXFxuICAgICAgICB9KTtcXG4gICAgICAgIGN1cnJlbnRMb2NhdGlvbiA9IGxvY2F0aW9uO1xcbiAgICB9XFxuXFxuICAgIEdNLnB1dChcXFwicmVub3ZhdGVMaXN0XFxcIiwgcmVub3ZhdGVMaXN0KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYmlnX2JsYW5rX2Jsb2NrXFxcIlxcbiAgICB9KTtcXG4gICAgaWYgKGZyb20ubGVuZ3RoKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiYmlnX2JsYW5rX2Jsb2NrXFxcIixcXG4gICAgICAgIH0pXFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBzb3J0b2JqW3NvcnRpXSxcXG4gICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHNvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBzaSA9IGdldE15VmFyKFxcXCJzb3J0aVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBpaSA9IChzaSA9PSBcXFwiMFxcXCIgPyBcXFwiMVxcXCIgOiBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJAc29ydFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBzb1tpaV1cXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgdmFyIHBsYXlzID0gZmluZEl0ZW1zQnlDbHMoXFxcInBsYXlsaXN0XFxcIikucmV2ZXJzZSgpLm1hcCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHguY29sX3R5cGUgPSB4LnR5cGU7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4geDtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCBwbGF5cyk7XFxuXFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJzb3J0aVxcXCIsIGlpKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBzb3J0b2JqKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBcXFwiQHNvcnRcXFwiLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBmb3IgKGxldCBpIGluIGZyb20pIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGksIGlkKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBcXFwibG9jYXRpb25AXFxcIiArIGlcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgIC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ge1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcbiAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChsZW5ndGgsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzvvIxEUlBZ6Kej5p6Q77yM5YWx44CMXFxcIiArIGxlbmd0aCArIFxcXCLjgI3mnaHvvIzlpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHJ1bGUgKyBcXFwiJFxcXCIgKyB0eXBlICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgIGlmIChnZXRQYXN0ZXMoKS5pbmNsdWRlcyhpbnB1dCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlcy5sZW5ndGgsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IFxcXCJoaWtlcjovL2ZpbGVzL3J1bGVzL0xveURnSWsvc2hhcmUvZHJweeino+aekOOAjFxcXCIgKyBydWxlcy5sZW5ndGggKyBcXFwi44CN5p2hLlxcXCIgKyAoaW5wdXQgPT09IFxcXCJISUtFUlxcXCIgPyBcXFwiaGlrZXJcXFwiIDogXFxcInR4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGdldFBhc3MocnVsZXMubGVuZ3RoLCBydWxlYjY0LCBcXFwiYVxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdXAocnVsZXMpO1xcbiAgICAgICAgfSwgbW8sIGluZGV4cywgaW5kZXhjWzFdKTtcXG5cXG4gICAgfSwgbGVuZ3RoKSxcXG4gICAgY29sX3R5cGU6IFxcXCJpY29uX3NtYWxsXzRcXFwiLFxcbiAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9zaGFyZV9ncmVlblxcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIumHjee9rlxcXCIsXFxuICAgIHVybDogJChcXFwi5L2g56Gu5a6a6YeN572u77yfXFxcXG7or6Xmk43kvZzkvJrliKDpmaTnjrDmnInop6PmnpDvvIzmgaLlpI3oh6rluKbop6PmnpDjgIJcXFwiKS5jb25maXJtKChwYXRoKSA9PiB7XFxuICAgICAgICBkZWxld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ICAgICAgICAgICBsZXQgcnVsZSA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKVtpbmRleF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlLnVzZXIgPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlYjY0ID0gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBnZXRQYXNzID0gKG5hbWUsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzvvIzjgIxcXFwiICsgbmFtZSArIFxcXCLjgI1EUlBZ6Kej5p6Q77yM5aSN5Yi25pW05p2h5Y+j5Luk5omT5byA6L2v5Lu25bCx5Lya6Ieq5Yqo5a+85YWlJFxcXCIgKyBydWxlICsgXFxcIiRcXFwiICsgdHlwZSArIFxcXCJAaW1wb3J0PWpzOiQucmVxdWlyZSgnaW1wb3J0P3J1bGU9JytcXFwiICsgSlNPTi5zdHJpbmdpZnkoTVlfUlVMRS50aXRsZSkgKyBcXFwiKShpbnB1dClcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLlrozmlbTlj6Pku6RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCBydWxlYjY0LCBcXFwiYVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGFycltpbmR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l0bGU6IFxcXCLigJjigJhcXFwiICsgdGlwICsgXFxcIuKAmeKAmVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgb2JqID0ge307XFxuICAgICAgICBiYWNrKCk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl6ZSZ6K+vXFxcIik7XFxuICAgIH1cXG59IGVsc2UgaWYgKGluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgIG9iaiA9IGFycltpbmRleF07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi57yW6L6R6Kej5p6QOlxcXCIgKyBvYmoubmFtZSk7XFxufSBlbHNlIHtcXG4gICAgb2JqID0ge1xcbiAgICAgICAgcnVuVHlwZTogXFxcIldFQlxcXCIsXFxuICAgICAgICBtZXRob2Q6IFxcXCJHRVRcXFwiXFxuICAgIH07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi5paw5bu66Kej5p6QXFxcIik7XFxufVxcblxcbmQucHVzaCh7XFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5ZCN5a2XKOW/heWhqylcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19uYW1lXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5uYW1lLFxcbiAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxc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gICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4LCBpc0ltcG9ydCkgPT4ge1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIW5hbWUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFwicHNfdXJsXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghdXJsKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmxhZyA9IGdldE15VmFyKFxcXCJwc19mbGFnXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmbGFnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOagh+ivhuS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IGdldE15VmFyKFxcXCJwc19oZWFkZXJzXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIGlmKHR5cGVvZiBoZWFkZXJzIT09XFxcIm9iamVjdFxcXCIpIHRocm93IG5ldyBFcnJvcihcXFwi6ZSZ6K+v57G75Z6L77yM5b+F6aG75Li6T2JqZWN0XFxcIik7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcbiAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIG9iajEpO1xcbiAgICAgICAgfVxcbiAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+d5a2Y5oiQ5YqfXFxcIjtcXG4gICAgfSwgaW5kZXgsIGlzSW1wb3J0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BydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUm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YgIWluQnJhY2tldHMpIHtcXG4gICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnWycpIHtcXG4gICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IHRydWU7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBwYXRoO1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxuICAgICAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHBhdGgubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXG4gICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W2tleV07XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gY3VycmVudDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHJ1blR5cGUgPSBNWV9QQVJBTVMucnVuVHlwZVswXTtcXG4gICAgICAgIGxldCB1cmwgPSBkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pKTtcXG4gICAgICAgIGlmIChydW5UeXBlID09IFxcXCJKU09OXFxcIikge1xcblxcbiAgICAgICAgICAgIGxldCBwYXJhbSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHBhcmFtLmhlYWRlcnMgfHwge30sXFxuICAgICAgICAgICAgICAgIG1ldGhvZDogcGFyYW0ubWV0aG9kIHx8IHZvaWQgMFxcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IE9iamVjdC5hc3NpZ24oe30sIHBhcmFtLmhlYWRlcnMgfHwge30sIHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IGdldEpzb24oanNvbiwgdG9QYXRoKHBhcmFtLmpzb25QYXRoKSksXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT0gXFxcIkpTXFxcIikge1xcblxcbiAgICAgICAgICAgIGxldCBwYXJzZTtcXG4gICAgICAgICAgICBpZiAoTVlfUEFSQU1TLmluZGV4KSB7XFxuICAgICAgICAgICAgICAgIHBhcnNlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHRpdGxlKS5nZXRKc29uKClbTVlfUEFSQU1TLmluZGV4WzBdXTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByZXMgPSBuZXcgRnVuY3Rpb24oXFxcInVybFxcXCIsIFxcXCJzZWxmXFxcIiwgcGFyc2UuanMpKHVybCwgcGFyc2UpO1xcbiAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzID09PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKCQudHlwZShyZXMpID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcmVzXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gcHJlcGFyZVBhcnNlcyhwYXJzZXMsIHVybCwgcGxheWxpc3QsIGlzVGVzdCkge1xcbiAgICBwbGF5bGlzdCA9IHBsYXlsaXN0IHx8IHtcXG4gICAgICAgIHVybHM6IFtdLFxcbiAgICAgICAgbmFtZXM6IFtdLFxcbiAgICAgICAgaGVhZGVyczogW10sXFxuICAgICAgICBpczogXFxcIiNpc1ZpZGVvPXRydWUjXFxcIixcXG4gICAgfTtcXG4gICAgbGV0IHByb3h5VXJsID0gc3RhcnRQcm94eVNlcnZlcigkLnRvU3RyaW5nKHByb3h5LCBNWV9SVUxFLnRpdGxlKSk7XFxuICAgIHBhcnNlcy5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICBpZiAodi5mb3JiaWRkZW4pIHJldHVybjtcXG4gICAgICAgIHBsYXlsaXN0Lm5hbWVzLnB1c2godi5uYW1lKTtcXG4gICAgICAgIGlmICh2LmhlYWRlcnMpIHtcXG4gICAgICAgICAgICBwbGF5bGlzdC5oZWFkZXJzLnB1c2godi5oZWFkZXJzKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICh2LnJ1blR5cGUgPT09IFxcXCJKU09OXFxcIikge1xcbiAgICAgICAgICAgIGxldCBwYXJhbSA9IHtcXG4gICAgICAgICAgICAgICAgLy91cmw6IHYudXJsLFxcbiAgICAgICAgICAgICAgICBtZXRob2Q6IHYubWV0aG9kLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB2LmhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoOiB2Lmpzb25QYXRoXFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICBwbGF5bGlzdC51cmxzLnB1c2gocHJveHlVcmwgKyBcXFwiP3J1blR5cGU9SlNPTiZ1cmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChiYXNlNjRFbmNvZGUodi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IsXFxuICAgICAgICAgICAgICAgIHRpdGxlOiAoXFxcIjxzdHJvbmc+XFxcIiArIGRhdGEudGl0bGUgKyBcXFwiPC9zdHJvbmc+XFxcIikuYmlnKCksXFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogY29udGVudCxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICdyaWNoX3RleHQnLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgdGV4dFNpemU6IDE4LFxcbiAgICAgICAgICAgICAgICAgICAgY2xpY2s6IHRydWVcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHNldFJlc3VsdChsYXlvdXQpO1xcbiAgICAgICAgfSwgcGxheS51cmwucmVwbGFjZShcXFwibm92ZWw6Ly9cXFwiLFxcXCJcXFwiKSk7XFxuICAgIH1cXG4gICAgaWYgKHBsYXkucGFyc2UgPT09IDEpIHtcXG4gICAgICAgIGlmIChwbGF5LnVybC5zdGFydHNXaXRoKFxcXCJtYWduZXQ6XFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGxheS51cmw7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXNvZmZpY2lhbChwbGF5LnVybCkgJiYgKHBsYXkuZmxhZyB8fCBpbnB1dFsxXSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gdXNlUGFyc2VzKHBsYXkudXJsKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBcXFwidmlkZW86Ly9cXFwiICsgcGxheS51cmw7XFxuICAgIH0gZWxzZSBpZiAocGxheS5wYXJzZSA9PT0gMCkge1xcbiAgICAgICAgaWYgKHBsYXkudXJsLnN0YXJ0c1dpdGgoXFxcIm1hZ25ldDpcXFwiKSkge1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5LnVybDtcXG4gICAg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gICBpZiAoISgoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkgJiYgIWZpbGVFeGlzdChwYXRoICsgaXQubmFtZSkpKSB7XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgaXQubmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBgJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAndHlwZSc6IDMsXFxuICAgICAgICAgICAgICAgICAgICAnYXBpJzonLi4vbGlicy9kcnB5Mi5qcycsXFxuICAgICAgICAgICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAncXVpY2tTZWFyY2gnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IFxcXCIuL1xcXCIgKyBpdC5uYW1lLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KHtzaXRlczpydWxlc30pKTtcXG4gICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aIkOWKn+abtOaWsFxcXCIgKyBjb3VudCArIFxcXCLkuKpcXFwiOztcXG59XFxuXFxuZnVuY3Rpb24gZ2VuZXJhdGVDb25maWdCeUluZGV4KHVybCwgcGF0aCkge1xcbiAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhyZXF1ZXN0KHVybCkpKTtcXG4gICAgbGV0IGFyciA9IGpzb24uc2l0ZXM7XFxuICAgIGxldCBjb3VudCA9IDA7XFxuICAgIGxldCBpID0gMDtcXG4gICAgZm9yIChsZXQgaXQgb2YgYXJyKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmICgoU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLm1pbi5qc1xcXCIpIHx8IFN0cmluZyhpdC5hcGkpLmluY2x1ZGVzKFxcXCJkcnB5Mi5qc1xcXCIpKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0LmV4dC5lbmRzV2l0aChcXFwiLmpzXFxcIikgPyBkZWNvZGVVUklDb21wb25lbnQoaXQuZXh0LnNwbGl0KFxcXCIvXFxcIikuYXQoLTEpKSA6IChpdC5uYW1lICsgXFxcIi5qc1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZTtcXG4gICAgICAgICAgICAgICAgaWYgKFN0cmluZyhpdC5leHQpLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3QoaXQuZXh0KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpdC5leHQgPSBcXFwiLi9cXFwiICsgbmFtZTtcXG4gICAgICAgICAgICAgICAgaWYgKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgbmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGNvdW50Kys7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaSsrO1xcbiAgICB9XFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcImluZGV4Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShqc29uKSk7XFxuICAgIHJldHVybiBcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFwiICsgY291bnQgKyBcXFwi5LiqXFxcIjtcXG59XFxuJC5leHBvcnRzLnBhcnNlVXJsID0gZnVuY3Rpb24odXJsLCBwYXRoKSB7XFxuICAgIHBhdGggPSBiYXNlNjREZWNvZGUocGF0aCk7XFxuICAgIHBhdGggPSBwYXRoLmVuZHNXaXRoKFxcXCIvXFxcIikgPyBwYXRoIDogcGF0aCArIFxcXCIvXFxcIjtcXG4gICAgdHJ5IHtcXG4gICAgICAgIGlmICh1cmwuc3RhcnRzV2l0aChcXFwiaHR0cHM6Ly9naXRodWIuY29tL2hqZGhueC9cXFwiKSkge1xcbiAgICAgICAgICAgIHJldHVybiBnZW5lcmF0ZUNvbmZpZ0J5R2l0aHViKHVybCwgcGF0aCk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHJldHVybiBnZW5lcmF0ZUNvbmZpZ0J5SW5kZXgodXJsLCBwYXRoKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICByZXR1cm4gXFxcImVycm9yOlxcXCIgKyBlLnRvU3RyaW5nKCk7XFxuICAgIH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ID0gZ2VuZXJhdGVDb25maWdCeUdpdGh1Yihjb25maWcucGF0aCk7XFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFwiZ2l0aHViRGlyXFxcIjtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoZmV0Y2goY29uZmlnLnBhdGgpIHx8IFxcXCJ7fVxcXCIpKTtcXG4gICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwgIWpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBzb3VyY2VMaXN0ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcyk7XFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFwiaW5kZXhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXG4gICAgICAgIGxldCBjdXJyZW50U291cmNlLCBzZWFyY2hBbGxvdztcXG4gICAgICAgIGlmIChjb25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJjaEFsbG93UGF0aCkgfHwgXFxcIltdXFxcIik7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZGVsZXRlRmlsZShzZWFyY2hBbGxvd1BhdGgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UsXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxuICAgICAgICAgICAgc291cmNlTGlzdFxcbiAgICAgICAgfTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIG51bGw7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlMb2NhbChkaXJGaWxlKSB7XFxuICAgIGxldCBsaXN0ID0gZGlyRmlsZS5saXN0RmlsZXMoKTtcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGxldCBuYW1lID0gU3RyaW5nKGl0LmdldE5hbWUoKSk7XFxuICAgICAgICBsZXQgcGF0aCA9IGl0LmdldFBhdGgoKTtcXG4gICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikgfHwgaXQuaXNEaXJlY3RvcnkoKSkgY29udGludWU7XFxuICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICA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gb2JqLnVybC5yZXBsYWNlKFxcXCJmaWxlOi8vXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICBsZXQgZGlyID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG4gICAgICAgICAgaWYgKGRpci5pc0RpcmVjdG9yeSgpKSB7XFxuICAgICAgICAgICAgbGV0IGZsaXN0ID0gZGlyLmxpc3RGaWxlcygpO1xcbiAgICAgICAgICAgIGZvciAodmFyIGYgb2YgZmxpc3QpIHtcXG4gICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIHtcXG4gICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG5cXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICB9XFxuICAgICAgfTtcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICBsZXQgcmVnZXggPSAvKOWQjeensDouKj8pKFxcXFxzKyk/XFxcXG4vZztcXG4gICAgICAgIGxldCB0aXRsZSA9IFxcXCLlkI3np7A6XFxcIiArIHBbeC5pbmRleF0ubmFtZSArIFxcXCIgXFxcIjtcXG4gICAgICAgIGxldCB1cmwgPSBwW3guaW5kZXhdLnBhdGg7XFxuICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICBsZXQgY291bnQgPSB4LmNvdW50ICE9IDAgPyBcXFwiIOa6kOaVsOmHjzpcXFwiICsgeC5jb3VudCA6IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKC9uby8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5pyJ6K+vXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICB9IGVsc2UgaWYgKC9eKC0xfDB8NDA0KS8udGVzdCh4LmNvZGUpKSB7XFxuICAgICA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biAgICAgICAgICAgICAgICBjb2w6IDIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKG5hbWUgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHNvdXJjZXMuZmluZCh2ID0+IHYubmFtZSA9PSBuYW1lKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gcnVudGltZUNvbmZpZy5nZXRBYnNvbHV0ZVBhdGgoc291cmNlLmV4dCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcG5hbWUgPSBwYXRoLnNwbGl0KFxcXCIvXFxcIikuYXQoLTEpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghcnVsZSkgcmV0dXJuIFxcXCJ0b2FzdDovL+iOt+WPluWksei0pVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL1xcXCIgKyBwbmFtZSwgZmV0Y2gocGF0aCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9oaWtlcjovL2ZpbGVzL19jYWNoZS9cXFwiICsgcG5hbWU7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1cmwgPSBzaGFyZVBhc3RlKGJhc2U2NEVuY29kZShydWxlKSwgaW5wdXQp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tbnMoc3Blbik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMSkge1xcbiAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICBjb250ZW50OiBcXFwi6L6T5YWl5YWz6ZSu5a2XIOepuuaYvuekuuWFqOmDqFxcXCIsXFxuICAgICAgICAgICAgICB0aXRsZTogXFxcIuetm+mAiea6kFxcXCIsXFxuICAgICAgICAgICAgICBoaW50OiBcXFwi5rqQ5YWz6ZSu5a2XXFxcIixcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKS5tYXAoeCA9PiB4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICBsZXQgZmxpc3QgPSBsaXN0LmZpbHRlcih4ID0+IHguaW5jbHVkZXModGV4dCkpO1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbGV0IG5hdHVyYWwgPSBnZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmIChuYXR1cmFsID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgbGlzdC5zb3J0KG5hdHVyYWxTb3J0KS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICBzbmFtZS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBuYXR1cmFsID8gXFxcIlxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICBuYW1lcy5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIGFycmF5RGlmZmVyZW5jZShhcnIxLCBhcnIyKSB7XFxuICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKGFycjIubWFwKGl0ZW0gPT4gW2l0ZW0ua2V5LCBpdGVtXSkpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICBsZXQgQ2tleSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpLmtleTtcXG4gICAgICAgICAgICAvL2xvZyhDa2V5KVxcbiAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcbiAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgIH0gPSBjZmc7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTtcXG4gICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxuICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXG5cXG4gICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIuaWsOWinlxcXCIgKyBhbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3Quc3BsaWNlKG1hbmFnZS5saXN0LmluZGV4T2YoeC5uYW1lKSwgMSk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGxvZyhcXFwi56e76ZmkOlxcXCIgKyBkbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4g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ZWN0Q2VudGVyKHtcXG4gICAgICAgIG9wdGlvbnM6IFtcXFwi5pS55Y+Y5qC35byPXFxcIiwgXFxcIuetm+mAiea6kFxcXCIsIFxcXCLoh6rnhLbmjpLluo9cXFwiLCBcXFwi5YCS5bqPXFxcIiwgXFxcIuWFqOmAiVxcXCIsIFxcXCLlj43pgIlcXFwiXSxcXG4gICAgICAgIGNvbHVtbnM6IDIsXFxuICAgICAgICB0aXRsZTogXFxcIuivt+mAieaLqVxcXCIsXFxuICAgICAgICBjbGljayhzLCBpKSB7XFxuICAgICAgICAgIGlmIChpID09PSAwKSB7XFxuICAgICAgICAgICAgc3BlbiA9IHNwZW4gPT0gMyA/IDEgOiAzO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2VDb2x1bW5zKHNwZW4pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDEpIHtcXG4gICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgY29udGVudDogXFxcIui+k+WFpeWFs+mUruWtlyDnqbrmmL7npLrlhajpg6hcXFwiLFxcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFwi4oCc4oCc4oCd4oCdXFxcIiArICh2Lm5hbWUgKyBcXFwiXFxcIikuZm9udGNvbG9yKFxcXCIjMDA5OTY2XFxcIikgOiB2Lm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcblxcblxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2Uuc29ydCgoYSwgYikgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcblxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gIC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aSkge1xcbiAgICAgICAgICAgIHQgPSBcXFwiPGI+PGZvbnQgY29sb3I9XFxcIiArIGNvbG9yICsgXFxcIj5cXFwiICsgdCArIFxcXCI8L2ZvbnQ+PC9iPlxcXCI7XFxuICAgICAgICAgICAgZmxbeC5rZXldID0gaXQudjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoY2F0ZV90ZW1wW2luZGV4XSA9PSBcXFwiLTFcXFwiKSB7XFxuICAgICAgICAgICAgZmxbeC5rZXldID0gXFxcInVuZGVmaW5lZFxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGZvbGQgPT0gMSkge1xcbiAgICAgICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIHQsXFxuICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBvLmk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJpc19kZWZcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV9vYmogPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcbiAgICAgICAgICAgICAgICAvL3N0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX3RlbXBcXFwiLCBjYXRlX3RlbXApO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCBjYXRlX29iaik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCxcXG4gICAgICAgICAgICAgICAgY2F0ZV90ZW1wOiBjYXRlX3RlbXAsXFxuICAgICAgICAgICAgICAgIGk6IGksXFxuICAgICAgICAgICAgICAgIGNhdGU6IGNhdGVcXG4gICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgIH0pXFxuICAgIH1cXG4gIH1cXG59XFxuXFxuZnVuY3Rpb24gZ2V0RmwoKSB7XFxuICBmbCA9IE9iamVjdC5rZXlzKGZsKS5maWx0ZXIoa2V5ID0+IGZsW2tleV0gIT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uICAgICAgICByZXR1cm4gY291bnQ7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gY2FjaGVTaG93VGlwcygpIHtcXG4gICAgICAgIC8qaWYgKHN0b3JhZ2UwLmdldE15VmFyKGlkICsgXFxcImVyaW5mb1xcXCIpKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShcXFwi5b2T5YmN5Li657yT5a2YLOeCueaIkeWIt+aWsFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGM6IFxcXCJncmV5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaWQgKyBcXFwiZXJpbmZvXFxcIilcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGlkKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSlcXG4gICAgICAgIH0qL1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIHN1YnN0cihzdHIsIG1heExlbmd0aCkge1xcbiAgICAgICAgbGV0IGxlbiA9IDA7XFxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgIGlmIChzdHIuY2hhckNvZGVBdChpKSA+IDI1NSkge1xcbiAgICAgICAgICAgICAgICBsZW4gKz0gMjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZW4rKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGxlbiA+IG1heExlbmd0aCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gc3RyLnNsaWNlKDAsIGkpICsgJy4uLic7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHN0cjtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBzZXREZXNjKGRlc2MsIG51bSkge1xcbiAgICAgICAgaWYgKGRlc2MgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgfVxcbiAgICAgICAgZGVzYyA9IGRlc2MuY29uc3RydWN0b3IgPT0gQXJyYXkgPyBkZXNjLmpvaW4oJzxicj4nKSA6IGRlc2M7XFxuICAgICAgICBpZiAoZGVzYy5yZXBsYWNlKC8oPGJyPnxcXFxccyspL2csICcnKS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmlnX2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICdiaWdfYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICByZXR1cm47XFxuICAgICAgICB9XFxuXFxuICAgICAgICBjb25zdCBtYXJrID0gJ2Rlc2MnO1xcbiAgICAgICAgbnVtID0gdHlwZW9mKG51bSkgPT0gJ3VuZGVmaW5lZCcgPyAxMDAgOiBudW1cXG4gICAgICAgIGRlc2MgPSBkZXNjLnN0YXJ0c1dpdGgoJ+OAgOOAgCcpID8gZGVzYyA6ICfjgIDjgIAnICsgZGVzYztcXG4gICAgICAgIGRlc2MgPSBkZXNjLnJlcGxhY2UoLycvZywgXFxcIiYjMzk7XFxcIik7XFxuICAgICAgICBkZXNjID0gZGVzYy5yZXBsYWNlKC9cXFxcclxcXFxuL2csIFxcXCI8YnI+XFxcIik7XFxuICAgICAgICBkZXNjID0gZGVzYy5yZXBsYWNlKC9cXFxcbi9nLCBcXFwiPGJyPlxcXCIpO1xcbiAgICAgICAgbGV0IHNkZXNjID0gc3Vic3RyKGRlc2MsIG51bSk7XFxuXFxuICAgICAgICB2YXIgY29sb3JzID0ge1xcbiAgICAgICAgICAgIHNob3c6IFxcXCJibGFja1xcXCIsXFxuICAgICAgICAgICAgaGlkZTogXFxcImdyZXlcXFwiXFxuICAgICAgICB9XFxuXFxuICAgICAgICB2YXIgbGF6eSA9ICQoYCNub0xvYWRpbmcjYCkubGF6eVJ1bGUoKGRjLCBzZGMsIG0sIGNzKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHNob3cgPSBzdG9yYWdlMC5nZXRJdGVtKG0sICcwJyk7XFxuICAgICAgICAgICAgdmFyIHRpdGxlID0gZmluZEl0ZW0oJ2Rlc2MnKS50aXRsZTtcXG4gICAgICAgICAgICB2YXIgcmUgPSAvKDxcXFxcL3NtYWxsPjxicj4uKj8+KS4rL2c7XFxuICAgICAgICAgICAgdmFyIGV4cCA9ICflsZXlvIA6JztcXG4gICAgICAgICAgICB2YXIgcmV0ID0gJ+aUtui1tzonO1xcbiAgICAgICAgICAgIGlmIChzaG93ID09ICcxJykge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBzZGMgKyAnPC9zbWFsbD4nKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8oPFxcXFwvc21hbGw+PGJyPlxcXFw8Zm9udCBjb2xvcj1cXFwiKS4qPyhcXFwiPikvLCAnJDEnICsgY3MuaGlkZSArICckMicpXFxuXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0obSwgJzAnKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoZXhwLCByZXQpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBkYyArICc8L3NtYWxsPicpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXC9zbWFsbD48YnI+XFxcXDxmb250IGNvbG9yPVxcXCIpLio/KFxcXCI+KS8sICckMScgKyBjcy5zaG93ICsgJyQyJylcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMScpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gYGhpa2VyOi8vZW1wdHlgXFxuICAgICAgICB9LCBkZXNjLCBzZGVzYywgbWFyaywgY29sb3JzKVxcbiAgICAgICAgdmFyIHNjID0gc3RvcmFnZTAuZ2V0SXRlbShtYXJrLCAnMCcpID09ICcwJyA/ICflsZXlvIA6JyA6ICfmlLbotbc6JztcXG4gICAgICAgIHZhciBkYyA9IHN0b3JhZ2UwLmdldEl0ZW0obWFyaywgJzAnKSA9PSAnMCcgPyBzZGVzYyA6IGRlc2M7XFxuICAgICAgICB2YXIgY3MgPSBzdG9yYWdlMC5nZXRJdGVtKG1hcmssICcwJykgPT0gJzAnID8gY29sb3JzLmhpZGUgOiBjb2xvcnMuc2hvdztcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICcnICsgJzxiPjxmb250IGNvbG9yPVxcXCIjMDk4QUMxXFxcIj7iiLfliafmg4XnroDku4tcXHQ8L2ZvbnQ+PC9iPicgKyBcXFwiPHNtYWxsPjxhIHN0eWxlPSd0ZXh0LWRlY29yYXRpb246IG5vbmU7JyBocmVmPSdcXFwiICsgbGF6eSArIFxcXCInPlxcXCIgKyBzYyArICc8L2E+PC9zbWFsbD48YnI+PGZvbnQgY29sb3I9XFxcIicgKyBjcyArICdcXFwiPicgKyBgJHtkY31gICsgJzwvc21hbGw+JyxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3JpY2hfdGV4dCcsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6ICdkZXNjJyxcXG4gICAgICAgICAgICAgICAgbGluZVNwYWNpbmc6IDYsXFxuICAgICAgICAgICAgICAgIHRleHRTaXplOiAxNSxcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IHRydWUsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgfVxcblxcbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoU3RyaW5nLnByb3RvdHlwZSwgJ1NwbGl0Jywge1xcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uKHMsIGUpIHtcXG4gICAgICAgICAgICBpZiAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zcGxpdChzKS5maWx0ZXIoaXRlbSA9PiBpdGVtICE9PSAnJyk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3BsaXQocyk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICAgIGVudW1lcmFibGU6IGZhbHNlLFxcbiAgICB9KTtcXG5cXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoQXJyYXkucHJvdG90eXBlLCB7XFxuICAgICAgICBleGNsdWRlS2V5czoge1xcbiAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbihrZXlzLCBleGNsdWRlLCByZW5hbWVDYWxsYmFjaykge1xcbiAgICAgICAgICAgICAgICAvLyDnoa7lrprmmK/mjpLpmaTov5jmmK/lj6rkv53nlZnplK5cXG4gICAgICAgICAgICAgICAgY29uc3Qgc2hvdWxkRXhjbHVkZSA9IHR5cGVvZiBleGNsdWRlID09PSAnYm9vbGVhbicgPyBleGNsdWRlIDogdHJ1ZTtcXG4gICAgICAgICAgICAgICAgY29uc3Qga2V5c1RvSGFuZGxlID0gQXJyYXkuaXNBcnJheShrZXlzKSA/IGtleXMgOiBbXTtcXG5cXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLm1hcOmBjeWOhuaVsOe7hOS4reeahOavj+S4quWFg+e0oFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrmlbDnu4TvvIzpgJLlvZLosIPnlKhleGNsdWRlS2V5c1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaXRlbSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS5leGNsdWRlS2V5cyhleGNsdWRlLCBrZXlzLCByZW5hbWVDYWxsYmFjayk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICE9PSBudWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5pyJ6YeN5ZG95ZCN5Zue6LCD5Ye95pWw77yM5YiZ6LCD55So5a6DXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVuYW1lQ2FsbGJhY2sgPT09ICdmdW5jdGlvbicpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2tleSwgdmFsdWVdO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlcmVkRW50cmllcyA9IHNob3VsZEV4Y2x1ZGUgP1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+ICFrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSkgOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+IGtleXNUb0hhbmRsZS5pbmNsdWRlcyhrZXkpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKGZpbHRlcmVkRW50cmllcyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgICAgIH0sXFxuICAgICAgICB0cmFuc2Zvcm1LZXlzOiB7XFxuICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uKGtleU1hcHBpbmcpIHtcXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLm1hcOmBjeWOhuaVsOe7hOS4reeahOavj+S4quWFg+e0oFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrmlbDnu4TvvIzpgJLlvZLosIPnlKh0cmFuc2Zvcm1LZXlzXFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLnRyYW5zZm9ybUtleXMoa2V5TWFwcGluZyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICE9PSBudWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNmb3JtZWRFbnRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdLZXkgPSBrZXlNYXBwaW5nW2tleV0gfHwga2V5OyAvLyDlpoLmnpzplK7lnKjmmKDlsITkuK3vvIzkvb/nlKjmlrDplK7vvJvlkKbliJnkvb/nlKjljp/lp4vplK5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtuZXdLZXksIHZhbHVlXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKHRyYW5zZm9ybWVkRW50cmllcyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIGxldCBzb3J0b2JqID0gW1xcbiAgICAgICAgZm9udHN0eWxlKFxcXCLmraPluo9cXFwiLCB7XFxuICAgICAgICAgICAgYzogXFxcIiMxQUFEMTlcXFwiLFxcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJiXFxcIlxcbiAgICAgICAgfSksXFxuICAgICAgICBmb250c3R5bGUoXFxcIumAhuW6j1xcXCIsIHtcXG4gICAgICAgICAgICBjOiBcXFwiI0ZGMDAwMFxcXCIsXFxuIC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AxOyAvLyDlh48x5piv5Zug5Li65pWw57uE57Si5byV5LuOMOW8gOWni1xcbiAgICAgICAgICAgICAgICB2YXIgZW5kID0gcGFydHNbMV0gLSAxO1xcbiAgICAgICAgICAgICAgICAvLyDkvb/nlKhBcnJheS5wcm90b3R5cGUuc2xpY2XmnaXojrflj5blrZDmlbDnu4RcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFycmF5LnNsaWNlKHN0YXJ0LCBlbmQgKyAxKTsgLy8g5YyF5ous57uT5p2f57Si5byV77yM5omA5Lul5YqgMVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICB9LFxcbiAgICB9KVxcblxcbiAgICBsZXQgc291cmNlID0ge307XFxuICAgIGlmIChNWV9QQVJBTVMuc291cmNlKSB7XFxuICAgICAgICBzb3VyY2UgPSBNWV9QQVJBTVMuc291cmNlO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgc291cmNlID0gcnVudGltZUNvbmZpZy5maW5kU291cmNlKE1ZX1BBUkFNUy5za2V5KTtcXG4gICAgICAgIE1ZX1BBUkFNUy5zb3VyY2UgPSBzb3VyY2U7XFxuICAgICAgICBzZXRQYWdlUGFyYW1zKE1ZX1BBUkFNUyk7XFxuICAgIH1cXG5cXG4gICAgY29uc3QgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcblxcbiAgICBEcnB5TWFuYWdlLmluaXRQYWdlKFxcXCJlclxcXCIpO1xcblxcbiAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcXG4gICAgbGV0IHN0eXBlID0gZHJweS5nZXRSdWxlKFxcXCLnsbvlnotcXFwiKTtcXG4vKlxcbiA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Z3RoKVxcbiAgICAgICAgICAgIGxldCB0YyA9IGNvdW50VG90YWxCeXRlcyhmaW5kTG9uZ2VzdEVsZW1lbnQodHMpKTtcXG4gICAgICAgICAgICBpZiAodHMuZmlsdGVyKGUgPT4gZSAhPSBcXFwiXFxcIikubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIHBsYXlwYWdlc1tpXSA9IHBhZ2VzO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodGMgPiAyNCkge1xcbiAgICAgICAgICAgICAgICBjb2wgPSBcXFwidGV4dF8xXFxcIjtcXG4gICAgICAgICAgICAgICAgaW1nID0gXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vbW92aWUvMTQ2LnN2Z1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICh0YyA+PSAxMiAmJiB0YyA8IDE1KSB7XFxuICAgICAgICAgICAgICAgIGNvbCA9IFxcXCJ0ZXh0XzNcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGMgPj0gMTUpIHtcXG4gICAgICAgICAgICAgICAgY29sID0gXFxcInRleHRfMlxcXCI7XFxuICAgICAgICAgICAgICAgIHRleHRhbGlnbiA9IFxcXCJsZWZ0XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBsYXlvYmogPSB0LnNwbGl0KFxcXCIjXFxcIikubWFwKChqKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBrID0gai5zcGxpdChcXFwiJFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICAgICAgICAgIGxldCB1aWQgPSAoa1sxXSB8fCBrWzBdKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIHN0aXRsZTogdCxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICAgICAgc3VybDogdWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXNOb3ZlbD9cXFwiaGlrZXI6Ly9wYWdlL25vdmVsI2F1dG9QYWdlIyNyZWFkVGhlbWUjXFxcIjoodWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5LnJlcGxhY2UoJ1xcXCJpZFxcXCInLCAnXFxcIicgKyB1aWQgKyAnXFxcIicpKSxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgICAgICAgICAgICBpZDoga1sxXSxcXG4gICAgICAgICAgICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9KSovXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGlmIChzdHlwZSA9PSBcXFwi5ryr55S7XFxcIiB8fCBzdHlwZSA9PSBcXFwi5bCP6K+0XFxcIikge1xcblxcbiAgICAgICAgICAgICAgICB2YXIgZG93bmxvYWRsYXp5ID0gJC50b1N0cmluZygoa2V5LCBza2V5LCB0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBHTVxcbiAgICAgICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzVlOGYwLTIyZTgtNTI3MC1hOWQxLTgyNmY1M2YxNzdhZFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uc2V0U2VsZktleShrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiLFxcXCJEcnB5TWFuYWdlP3J1bGU9XFxcIit0aXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0KHNrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC5zcGxpdChcXFwiI1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IEpTT04ucGFyc2UoZHJweS5wbGF5KGlucHV0WzFdLCBpbnB1dFswXSkpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdC51cmwuc3RhcnRzV2l0aChcXFwicGljczovL1xcXCIpKSByZXR1cm4gcmVzdWx0LnVybDtcXG4gICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKHJlc3VsdC51cmwuc3RhcnRzV2l0aChcXFwibm92ZWw6Ly9cXFwiKSkgcmV0dXJuIEpTT04ucGFyc2UocmVzdWx0LnVybC5yZXBsYWNlKFxcXCJub3ZlbDovL1xcXCIsIFxcXCJcXFwiKSkuY29udGVudDtcXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5ryr55S75oiW5q2j5paH6I635Y+W5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIH0sIEdNLmdldFNlbGZLZXkoKSwgTVlfUEFSQU1TLnNrZXksIE1ZX1JVTEUudGl0bGUpO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2hhcHRlckxpc3QgPSBwbGF5b2JqLmV4Y2x1ZGVLZXlzKFtcXFwic3VybFxcXCIsIFxcXCJzdGl0bGVcXFwiXSwgZmFsc2UpLnRyYW5zZm9ybUtleXMoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInN1cmxcXFwiOiBcXFwidXJsXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJzdGl0bGVcXFwiOiBcXFwidGl0bGVcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUoXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShjaGFwdGVyTGlzdCkpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLkuIvovb1cXFwiICsgc3R5cGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvZG93bmxvYWQudmlldyNub1JlY29yZEhpc3RvcnkjI25vUmVmcmVzaCM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYnLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2hhcHRlckxpc3Q6IFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmZvOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tOYW1lOiBpbmZvLnZvZF9uYW1lLCAvL+a8q+eUu+WQjeensCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZU5hbWU6IFxcXCJEUlBZXFxcIiArIE1ZX1BBUkFNUy5zbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9va1RvcFBpYzogaW5mby52b2RfcGljLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJzZUNvZGU6IGRvd25sb2FkbGF6eSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmlldzogXFxcIjFcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKzlnLDkuabmnrZcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiAnaGlrZXI6Ly9wYWdlL0Jvb2tyYWNrLnZpZXcjbm9SZWNvcmRIaXN0b3J5Iz9ydWxlPeacrOWcsOi1hOa6kOeuoeeQhiZydWxlTmFtZT0nICsgXFxcIkRSUFlcXFwiICsgTVlfUEFSQU1TLnNuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBwbGF5b2JqID0gJC5zcGxpdEFycmF5QnlSYW5nZXMocGxheW9iaiwgcGFnZXMpO1xcbiAgICAgICAgICAgIHJldHVybiBwbGF5b2JqO1xcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuaaguaXoOaSreaUvua6kOaIluaSreaUvuWIl+ihqOWumuS9jemUmeivr1xcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IE1ZX1BBUkFNUy52b2RJZCxcXG4gICAgICAgIH0pO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iAgICAgICAgJC5leHRlbmQoe1xcbiAgICAgICAgICAgIHRlbXBfbGlzdDogcGxheVVybExpc3RbbG9jYXRpb25dLFxcbiAgICAgICAgfSlcXG4gICAgICAgIGxldCBwbGF5cCA9IHBsYXlwYWdlc1tsb2NhdGlvbl07XFxuXFxuICAgICAgICBpZiAocGxheXAgJiYgcGxheXAubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1wID0ge1xcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfMScsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGFnZWFyciA9IHBsYXlwLm1hcCgoeCwgaSkgPT4gaSA9PSBwYWdlbnVtID8gJ+KAnOKAnOKAneKAnScgKyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KTtcXG4gICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlwYWdlXFxcIilcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn5LiK5LiA6aG1JyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzRcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0gPSBwY291bnQgLSAxO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBsb2NhdGlvbiwgcGNvdW50KSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKHBhZ2VhcnIsIDMpLnNlbGVjdCgobG9jYXRpb24pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKE1ZX0lOREVYKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgIH0sIGxvY2F0aW9uKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSsrO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1dKVxcbiAgICAgICAgICAgIC8qcGxheXAgPSBwbGF5cC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgICBsZXQgb2JqID0gT2JqZWN0LmFzc2lnbih7fSwgdGVtcCwge1xcbiAgICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgKHBhZ2VudW0gPT0gaSA/IHguZm9udGNvbG9yKFxcXCJyZWRcXFwiKSA6IHgpLFxcbiAgICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwicGFnZW51bVxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheWxpc3RzXFxcIiwgJC50ZW1wX2xpc3RbaV0pO1xcbiAgICAgICAgICAgICAgICAgICBmaW5kSXRlbXNCeUNscyhcXFwicGxheXBhZ2VcXFwiKS5mb3JFYWNoKCh4LCBpaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IHgudGl0bGUucmVwbGFjZSgv4oCYfOKAmXzigJx84oCdfDxbXj5dKz4vZywgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgIGlmIChpaSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSA9ICfigJzigJzigJ3igJ0nICsgdGl0bGUuZm9udGNvbG9yKFxcXCJyZWRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh4LmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgIH0sIGkpLFxcbiAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIHRlbXAuZXh0cmEsIHtcXG4gICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIiArIGksXFxuICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5cGFnZWxpbmVcXFwiLCBwbGF5cCkqL1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGxpc3QpIHtcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlsaXN0c1xcXCIsIGxpc3QpO1xcbiAgICAgICAgfVxcbiAgICAgICAgdXBkYXRlSXRlbShcXFwibG9jYXRpb25AXFxcIiArIGN1cnJlbnRMb2NhdGlvbiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBmcm9tW2N1cnJlbnRMb2NhdGlvbl0sXFxuICAgICAgICB9KTtcXG4gICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxvY2F0aW9uQFxcXCIgKyBsb2NhdGlvbiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIGZyb21bbG9jYXRpb25dICsgXFxcIuKAneKAnVxcXCIsXFxuICAgICAgICB9KTtcXG4gICAgICAgIGN1cnJlbnRMb2NhdGlvbiA9IGxvY2F0aW9uO1xcbiAgICB9XFxuXFxuICAgIEdNLnB1dChcXFwicmVub3ZhdGVMaXN0XFxcIiwgcmVub3ZhdGVMaXN0KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYmlnX2JsYW5rX2Jsb2NrXFxcIlxcbiAgICB9KTtcXG4gICAgaWYgKGZyb20ubGVuZ3RoKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiYmlnX2JsYW5rX2Jsb2NrXFxcIixcXG4gICAgICAgIH0pXFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBzb3J0b2JqW3NvcnRpXSxcXG4gICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHNvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBzaSA9IGdldE15VmFyKFxcXCJzb3J0aVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBpaSA9IChzaSA9PSBcXFwiMFxcXCIgPyBcXFwiMVxcXCIgOiBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJAc29ydFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBzb1tpaV1cXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgdmFyIHBsYXlzID0gZmluZEl0ZW1zQnlDbHMoXFxcInBsYXlsaXN0XFxcIikucmV2ZXJzZSgpLm1hcCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHguY29sX3R5cGUgPSB4LnR5cGU7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4geDtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCBwbGF5cyk7XFxuXFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJzb3J0aVxcXCIsIGlpKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBzb3J0b2JqKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBcXFwiQHNvcnRcXFwiLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBmb3IgKGxldCBpIGluIGZyb20pIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZnJvbVtpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIGksIGlkKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBcXFwibG9jYXRpb25AXFxcIiArIGlcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIlxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIC8vY29uc29sZS5sb2cocGxheVVybExpc3QpO1xcbiAgICAvKmlmIChwbGF5VXJsTGlzdC5sZW5ndGgpIHtcXG4gICAgICB2YXIgZWpvYmogPSB7XFxuICAgICAgICBcXFwibGlzdFxcXCI6IHBsYXlVcmxMaXN0LFxcbiAgICAgICAgXFxcInRhYlxcXCI6IGZyb20ubWFwKCh4LCBpKSA9PiBmcm9tW2ldKVxcbiAgICAgIH07XFxuICAgICAg5Yid5aeL5YyWKGQsIGVqb2JqKVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuaaguaXoOaSreaUvua6kFxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgICAgICB1cmw6IE1ZX1BBUkFNUy52b2RJZCxcXG4gICAgICB9KTtcXG4gICAgfSovXFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImJsYW5rX2Jsb2NrXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZWxpbmVcXFwiXFxuICAgICAgICB9XFxuICAgIH0pXFxuXFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcInBsYXlsaXN0c1xcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImJsYW5rX2Jsb2NrXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IFxcXCJwbGF5bGlzdHNFTkRcXFwiXFxuICAgICAgICB9XFxuICAg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V0gIT09IFxcXFxcXFwic3RyaW5nXFxcXFxcXCIpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNba2V5XSA9IFN0cmluZyhvYmouaGVhZGVyc1trZXldKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBsZXQgciA9IFxcXFxcXFwiXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAvKiBpZiAoU3RyaW5nKG9iai5tZXRob2QpLnRvTG93ZXJDYXNlKCkgPT09IFxcXFxcXFwicG9zdFxcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxcXG4gICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXFxcbiAgICAgICAgICAgICB9Ki9cXFxcbiAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxcXG4gICAgICAgICAgICBpZiAob2JqLndpdGhIZWFkZXJzKSB7XFxcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByLmJvZHk7XFxcXG4gICAgICAgICAgICAgICAgcmVzLmhlYWRlcnMgPSB7fTtcXFxcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcXFxuICAgICAgICAgICAgICAgICAgICByZXMuaGVhZGVyc1trXSA9IHZbMF07XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHI7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcXFxu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AgIHJldHVybiBjb3VudDtcXFxcbiAgICB9XFxcXG5cXFxcbiAgICBmdW5jdGlvbiBjYWNoZVNob3dUaXBzKCkge1xcXFxuICAgICAgICAvKmlmIChzdG9yYWdlMC5nZXRNeVZhcihpZCArIFxcXFxcXFwiZXJpbmZvXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICBkLnB1c2goe1xcXFxuICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUoXFxcXFxcXCLlvZPliY3kuLrnvJPlrZgs54K55oiR5Yi35pawXFxcXFxcXCIsIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYzogXFxcXFxcXCJncmV5XFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgICAgICAgIHRhZ3M6IFxcXFxcXFwic21hbGxcXFxcXFxcIlxcXFxuICAgICAgICAgICAgICAgIH0pLFxcXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFxcXFxcInRleHRfY2VudGVyXzFcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGlkKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaWQgKyBcXFxcXFxcImVyaW5mb1xcXFxcXFwiKVxcXFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9LCBpZCksXFxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgfSovXFxcXG4gICAgfVxcXFxuXFxcXG4gICAgZnVuY3Rpb24gc3Vic3RyKHN0ciwgbWF4TGVuZ3RoKSB7XFxcXG4gICAgICAgIGxldCBsZW4gPSAwO1xcXFxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkrKykge1xcXFxuICAgICAgICAgICAgaWYgKHN0ci5jaGFyQ29kZUF0KGkpID4gMjU1KSB7XFxcXG4gICAgICAgICAgICAgICAgbGVuICs9IDI7XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIGxlbisrO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgaWYgKGxlbiA+IG1heExlbmd0aCkge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBzdHIuc2xpY2UoMCwgaSkgKyAnLi4uJztcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICByZXR1cm4gc3RyO1xcXFxuICAgIH1cXFxcblxcXFxuICAgIGZ1bmN0aW9uIHNldERlc2MoZGVzYywgbnVtKSB7XFxcXG4gICAgICAgIGlmIChkZXNjID09IHVuZGVmaW5lZCkge1xcXFxuICAgICAgICAgICAgcmV0dXJuO1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgIGRlc2MgPSBkZXNjLmNvbnN0cnVjdG9yID09IEFycmF5ID8gZGVzYy5qb2luKCc8YnI+JykgOiBkZXNjO1xcXFxuICAgICAgICBpZiAoZGVzYy5yZXBsYWNlKC8oPGJyPnxcXFxcXFxcXHMrKS9nLCAnJykubGVuZ3RoID09IDApIHtcXFxcbiAgICAgICAgICAgIGQucHVzaCh7XFxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICdiaWdfYmxhbmtfYmxvY2snXFxcXG4gICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgZC5wdXNoKHtcXFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ2JpZ19ibGFua19ibG9jaydcXFxcbiAgICAgICAgICAgIH0pXFxcXG4gICAgICAgICAgICByZXR1cm47X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IGV4cCA9ICflsZXlvIA6JztcXFxcbiAgICAgICAgICAgIHZhciByZXQgPSAn5pS26LW3Oic7XFxcXG4gICAgICAgICAgICBpZiAoc2hvdyA9PSAnMScpIHtcXFxcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcXFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGVcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKHJldCwgZXhwKVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBzZGMgKyAnPC9zbWFsbD4nKVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXFxcXFwvc21hbGw+PGJyPlxcXFxcXFxcPGZvbnQgY29sb3I9XFxcXFxcXCIpLio/KFxcXFxcXFwiPikvLCAnJDEnICsgY3MuaGlkZSArICckMicpXFxcXG5cXFxcbiAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0obSwgJzAnKTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSgnZGVzYycsIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShleHAsIHJldClcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKHJlLCAnJDEnICsgZGMgKyAnPC9zbWFsbD4nKVxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXFxcXFwvc21hbGw+PGJyPlxcXFxcXFxcPGZvbnQgY29sb3I9XFxcXFxcXCIpLio/KFxcXFxcXFwiPikvLCAnJDEnICsgY3Muc2hvdyArICckMicpXFxcXG4gICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICBzdG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6G5pWw57uE5Lit55qE5q+P5Liq5YWD57SgXFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWFwKGl0ZW0gPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrmlbDnu4TvvIzpgJLlvZLosIPnlKhleGNsdWRlS2V5c1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0uZXhjbHVkZUtleXMoZXhjbHVkZSwga2V5cywgcmVuYW1lQ2FsbGJhY2spO1xcXFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICE9PSBudWxsKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrlr7nosaHvvIzkvb/nlKhPYmplY3QuZnJvbUVudHJpZXPlkoxPYmplY3QuZW50cmllc+adpeWkhOeQhumUrlxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW50cmllcyA9IE9iamVjdC5lbnRyaWVzKGl0ZW0pO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzmnInph43lkb3lkI3lm57osIPlh73mlbDvvIzliJnosIPnlKjlroNcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbmFtZUNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtrZXksIHZhbHVlXTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsdGVyZWRFbnRyaWVzID0gc2hvdWxkRXhjbHVkZSA/XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx0ZXIoKFtrZXldKSA9PiAha2V5c1RvSGFuZGxlLmluY2x1ZGVzKGtleSkpIDpcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+IGtleXNUb0hhbmRsZS5pbmNsdWRlcyhrZXkpKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZnJvbUVudHJpZXMoZmlsdGVyZWRFbnRyaWVzKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW07XFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIH0sXFxcXG4gICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSwgLy8g6K6+572u5Li65LiN5Y+v5p6a5Li+XFxcXG4gICAgICAgIH0sXFxcXG4gICAgICAgIHRyYW5zZm9ybUtleXM6IHtcXFxcbiAgICAgICAgICAgIHZhbHVlOiBmdW5jdGlvbihrZXlNYXBwaW5nKSB7XFxcXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLm1hcOmBjeWOhuaVsOe7hOS4reeahOavj+S4quWFg+e0oFxcXFxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1hcChpdGVtID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5pWw57uE77yM6YCS5b2S6LCD55SodHJhbnNmb3JtS2V5c1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0udHJhbnNmb3JtS2V5cyhrZXlNYXBwaW5nKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gJ29iamVjdCcgJiYgaXRlbSAhPT0gbnVsbCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5piv5LiA5Liq5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyhpdGVtKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybWVkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdLZXkgPSBrZXlNYXBwaW5nW2tleV0gfHwga2V5OyAvLyDlpoLmnpzplK7lnKjmmKDlsITkuK3vvIzkvb/nlKjmlrDplK7vvJvlkKbliJnkvb/nlKjljp/lp4vplK5cXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW25ld0tleSwgdmFsdWVdO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKHRyYW5zZm9ybWVkRW50cmllcyk7XFxcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDkuI3mmK/lr7nosaHmiJbmlbDnu4TvvIznm7TmjqXov5Tlm55cXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICB9LFxcXFxuICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsIC8vIOiuvue9ruS4uuS4jeWPr+aemuS4vlxcXFxuICAgICAgICB9XFxcXG4gICAgfSk7XFxcXG5cXFxcbiAgICBsZXQgc29ydG9iaiA9IFtcXFxcbiAgICAgICAgZm9udHN0eWxlKFxcXFxcXFwi5q2j5bqPXFxcXFxcXCIsIHtcXFxcbiAgICAgICAgICAgIGM6IFxcXFxcXFwiIzFBQUQxOVxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgdGFnczogXFxcXFxcXCJiXFxcXFxcXCJcXFxcbiAgICAgICAgfSksXFxcXG4gICAgICAgIGZvbnRzdHlsZShcXFxcXFxcIumAhuW6j1xcXFxcXFwiLCB7XFxcXG4gICAgICAgICAgICBjOiBcXFxcXFxcIiNGRjAwMDBcXFxcXFxcIixcXFxcbiAgICAgICAgICAgIHRhZ3M6IFxcXFxcXFwiYlxcXFxcXFwiXFxcXG4gICAgICAgIH0pXFxcXG4gICAgXVxcXFxuICAgIC8v5pa55rOVXFxcXG5cXFxcbiAgICB2YXIgc29ydGkgPSBnZXRNeVZhcihcXFxcXFxcInNvcnRpXFxcXFxcXCIsIFxcXFxcXFwiMFxcXFxcXFwiKTtcXFxcblxcXFxuICAgIC8vbG9nKHNvcnRvYmopXFxcXG4gICAgJC5leHRlbmQoe1xcXFxuICAgICAgICBzcGxpdFBhZ2UodG90YWxJdGVtcywgcGFnZVNpemUpIHtcXFxcbiAgICAgICAgICAgIHBhZ2VTaXplID0gcGFnZVNpemUgfHwgNTA7XFxcXG4gICAgICAgICAgICBsZXQgcmVzdWx0ID0gW107XFxcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8PSB0b3RhbEl0ZW1zOyBpICs9IHBhZ2VTaXplKSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGVuZCA9IGkgKyBwYWdlU2l6ZSAtIDE7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGVuZCA+IHRvdGFsSXRlbXMpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgZW5kID0gdG90YWxJdGVtcztcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goYCR7aX0tJHtlbmR9YCk7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xcXFxuICAgICAgICB9LFxcXFxuICAgICAgICBzcGxpdEFycmF5QnlSYW5nZXMoYXJyYXksIHJhbmdlcykge1xcXFxuICAgICAgICAgICAgLy8g5qC55o2u6IyD5Zu05ouG5YiG5pWw57uEXFxcXG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gcmFuZ2VzLm1hcChmdW5jdGlvbihyYW5nZSkge1xcXFxuICAgICAgICAgICAgICAgIHZhciBwYXJ0cyA9IHJhbmdlLnNwbGl0KCctJykubWFwKE51bWJlcik7XFxcXG4gICAgICAgICAgICAgICAgdmFyIHN0YXJ0ID0gcGFydHNbMF0gLSAxOyAvLyDlh48x5piv5Zug5Li65pWw57uE57Si5byV5LuOMOW8gOWni1xcXFxuICAgICAgICAgICAgICAgIHZhciBlbmQgPSBwYXJ0c1sxXSAtIDE7XFxcXG4gICAgICAgICAgICAgICAgLy8g5L2/55SoQXJyYXkucHJvdG90eXBlLnNsaWNl5p2l6I635Y+W5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PSBcXFxcXFxcImxlZnRcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIGxldCBwbGF5b2JqID0gdC5zcGxpdChcXFxcXFxcIiNcXFxcXFxcIikubWFwKChqKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXFxcXFwiJFxcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICBsZXQgdCA9IGtbMF07XFxcXG4gICAgICAgICAgICAgICAgbGV0IHVpZCA9IChrWzFdIHx8IGtbMF0pO1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHN0aXRsZTogdCxcXFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICB0YWdzOiBcXFxcXFxcInNtYWxsXFxcXFxcXCJcXFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxcXG4gICAgICAgICAgICAgICAgICAgIHN1cmw6IHVpZCArIFxcXFxcXFwiI1xcXFxcXFwiICsgZnJvbVtpXSxcXFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpc05vdmVsP1xcXFxcXFwiaGlrZXI6Ly9wYWdlL25vdmVsI2F1dG9QYWdlIyNyZWFkVGhlbWUjXFxcXFxcXCI6KHVpZCArIFxcXFxcXFwiI1xcXFxcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5LnJlcGxhY2UoJ1xcXFxcXFwiaWRcXFxcXFxcIicsICdcXFxcXFxcIicgKyB1aWQgKyAnXFxcXFxcXCInKSksXFxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxcXG4gICAgICAgICAgICAgICAgICAgIGltZzogaW1nLFxcXFxuICAgICAgICAgICAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcXFxuICAgICAgICAgICAgICAgICAgICAgIFxcXFxcXFwiUmVmZXJlclxcXFxcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxcXG4gICAgICAgICAgICAgICAgICAgICAgaWQ6IGtbMV0sXFxcXG4gICAgICAgICAgICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxcXG4gICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFxcXFxcInBsYXlsaXN0XFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgICAgICAgIH0pKi9cXFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHNvdXJjZSxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiB1aWQsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFxcXFxcImhtXFxcXFxcXFwuYmFpZHVcXFxcXFxcXC5jb21cXFxcXFxcXC9obS5qc1xcXFxcXFwiXSxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZpZGVvRXhjbHVkZVJ1bGVzOiBbJz91cmw9J10sXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsczogXFxcXFxcXCJwbGF5bGlzdFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgfTtcXFxcbiAgICAgICAgICAgIH0pO1xcXFxuXFxcXG4gICAgICAgICAgICBpZiAoc3R5cGUgPT0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gICAgdXJsOiAnaGlrZXI6Ly9wYWdlL2Rvd25sb2FkLnZpZXcjbm9SZWNvcmRIaXN0b3J5IyNub1JlZnJlc2gjP3J1bGU95pys5Zyw6LWE5rqQ566h55CGJyxcXFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoYXB0ZXJMaXN0OiBcXFxcXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZm86IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29rTmFtZTogaW5mby52b2RfbmFtZSwgLy/mvKvnlLvlkI3np7AsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZU5hbWU6IFxcXFxcXFwiRFJQWVxcXFxcXFwiICsgTVlfUEFSQU1TLnNuYW1lLFxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2tUb3BQaWM6IGluZm8udm9kX3BpYyxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJzZUNvZGU6IGRvd25sb2FkbGF6eSxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBzdHlwZSA9PT0gXFxcXFxcXCLmvKvnlLtcXFxcXFxcIiA/IFxcXFxcXFwiY29taWNcXFxcXFxcIiA6IFxcXFxcXFwibm92ZWxcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmlldzogXFxcXFxcXCIxXFxcXFxcXCJcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFxcXFxcIuacrOWcsOS5puaetlxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvQm9va3JhY2sudmlldyNub1JlY29yZEhpc3RvcnkjP3J1bGU95pys5Zyw6LWE5rqQ566h55CGJnJ1bGVOYW1lPScgKyBcXFxcXFxcIkRSUFlcXFxcXFxcIiArIE1ZX1BBUkFNUy5zbmFtZSxcXFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdzY3JvbGxfYnV0dG9uJyxcXFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHN0eXBlID09PSBcXFxcXFxcIua8q+eUu1xcXFxcXFwiID8gXFxcXFxcXCJjb21pY1xcXFxcXFwiIDogXFxcXFxcXCJub3ZlbFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgfSwge1xcXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ2JsYW5rX2Jsb2NrJ1xcXFxuICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgfVxcXFxuXFxcXG4gICAgICAgICAgICBwbGF5b2JqID0gJC5zcGxpdEFycmF5QnlSYW5nZXMocGxheW9iaiwgcGFnZXMpO1xcXFxuICAgICAgICAgICAgcmV0dXJuIHBsYXlvYmo7XFxcXG4gICAgICAgIH0pO1xcXFxuICAgIH0gZWxzZSB7XFxcXG4gICAgICAgIGQucHVzaCh7XFxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcXFxcXCJsaW5lXFxcXFxcXCJcXFxcbiAgICAgICAgfSwge1xcXFxuICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwi5pqC5peg5pKt5pS+5rqQ5oiW5pKt5pS+5YiX6KGo5a6a5L2N6ZSZ6K+v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xcbiAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IGk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcXFxcXCJzb3J0aVxcXFxcXFwiLCBcXFxcXFxcIjBcXFxcXFxcIikgPT0gMSkge1xcXFxuICAgICAgICAgICAgbGlzdC5yZXZlcnNlKCk7XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgJC5leHRlbmQoe1xcXFxuICAgICAgICAgICAgdGVtcF9saXN0OiBwbGF5VXJsTGlzdFtsb2NhdGlvbl0sXFxcXG4gICAgICAgIH0pXFxcXG4gICAgICAgIGxldCBwbGF5cCA9IHBsYXlwYWdlc1tsb2NhdGlvbl07XFxcXG5cXFxcbiAgICAgICAgaWYgKHBsYXlwICYmIHBsYXlwLmxlbmd0aCA+IDEpIHtcXFxcbiAgICAgICAgICAgIGxldCB0ZW1wID0ge1xcXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF8xJyxcXFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcXFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXFxcXFwicGxheXBhZ2VcXFxcXFxcIlxcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIGxldCBwYWdlYXJyID0gcGxheXAubWFwKCh4LCBpKSA9PiBpID09IHBhZ2VudW0gPyAn4oCc4oCc4oCd4oCdJyArIHguZm9udGNvbG9yKFxcXFxcXFwicmVkXFxcXFxcXCIpIDogeCk7XFxcXG4gICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcXFxcXCJwbGF5cGFnZVxcXFxcXFwiKVxcXFxuICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXFxcXFwicGxheXBhZ2VsaW5lXFxcXFxcXCIsIFt7XFxcXG4gICAgICAgICAgICAgICAgdGl0bGU6ICfkuIrkuIDpobUnLFxcXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFxcXFxcInRleHRfNFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFxcXFxcIiNub0xvYWRpbmcjXFxcXFxcXCIpLmxhenlSdWxlKChsb2NhdGlvbiwgcGNvdW50KSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcXFxcXCJwYWdlbnVtXFxcXFxcXCIsIFxcXFxcXFwiMFxcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IHBjb3VudCAtIDE7XFxcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtLS07XFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcXFxcXCJwYWdlbnVtXFxcXFxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIEdNLmdldChcXFxcXFxcInJlbm92YXRlTGlzdFxcXFxcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJoaWtlcjovL2VtcHR5XFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFxcXFxcInBsYXlwYWdlXFxcXFxcXCJcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9LCB7XFxcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHBsYXlwW3BhZ2VudW1dLFxcXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFxcXFxcInRleHRfMlxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICAgIHVybDogJChwYWdlYXJyLCAzKS5zZWxlY3QoKGxvY2F0aW9uKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXFxcXFwicGFnZW51bVxcXFxcXFwiLCBTdHJpbmcoTVlfSU5ERVgpKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXFxcXFwicmVub3ZhdGVMaXN0XFxcXFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIlxcXFxuICAgICAgICAgICAgICAgIH0sIGxvY2F0aW9uKSxcXFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcXFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXFxcXFwicGxheXBhZ2VcXFxcXFxcIlxcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0sIHtcXFxcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+S4i+S4gOmhtScsXFxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXFxcXFwidGV4dF80XFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXFxcXFwiI25vTG9hZGluZyNcXFxcXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFxcXFxcInBhZ2VudW1cXFxcXFxcIiwgXFxcXFxcXCIwXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAocGFnZW51bSA+PSBwY291bnQgLSAxKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gMDtcXFxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0rKztcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFxcXFxcInBhZ2VudW1cXFxcXFxcIiwgU3RyaW5nKHBhZ2VudW0pKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXFxcXFwicmVub3ZhdGVMaXN0XFxcXFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9LCBsb2NhdGlvbiwgcGNvdW50KSxcXFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcXFxuICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXFxcXFwicGxheXBhZ2VcXFxcXFxcIlxcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1dKVxcXFxuICAgICAgICAgICAgLypwbGF5cCA9IHBsYXlwLm1hcCgoeCwgaSkgPT4ge1xcXFxuICAgICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIHRlbXAsIHtcXFxcbiAgICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgKHBhZ2VudW0gPT0gaSA/IHguZm9udGNvbG9yKFxcXFxcXFwicmVkXFxcXFxcXCIpIDogeCksXFxcXG4gICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSkgPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFxcXFxcInBhZ2VudW1cXFxcXFxcIikgPT0gaSkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGlrZXI6Ly9lbXB0eVxcXFxcXFwiXFxcXG4gICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXFxcXFwicGFnZW51bVxcXFxcXFwiLCBTdHJpbmcoaSkpO1xcXFxuICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFxcXFxcInBsYXlsaXN0XFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFxcXFxcInBsYXlsaXN0c1xcXFxcXFwiLCAkLnRlbXBfbGlzdFtpXSk7XFxcXG4gICAgICAgICAgICAgICAgICAgZmluZEl0ZW1zQnlDbHMoXFxcXFxcXCJwbGF5cGFnZVxcXFxcXFwiKS5mb3JFYWNoKCh4LCBpaSkgPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICAgbGV0IHRpdGxlID0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFxcXFxcIlxcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgIGlmIChpaSA9PSBpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcXFxcXCJyZWRcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcXFxuICAgICAgICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIjtcXFxcbiAgICAgIC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xcbiAgICBkLnB1c2goe1xcXFxuICAgICAgICBjb2xfdHlwZTogXFxcXFxcXCJiaWdfYmxhbmtfYmxvY2tcXFxcXFxcIlxcXFxuICAgIH0pO1xcXFxuICAgIGlmIChmcm9tLmxlbmd0aCkge1xcXFxuICAgICAgICBkLnB1c2goe1xcXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXFxcXFwiYmlnX2JsYW5rX2Jsb2NrXFxcXFxcXCIsXFxcXG4gICAgICAgIH0pXFxcXG4gICAgICAgIGQucHVzaCh7XFxcXG4gICAgICAgICAgICB0aXRsZTogc29ydG9ialtzb3J0aV0sXFxcXG4gICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHNvKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHNpID0gZ2V0TXlWYXIoXFxcXFxcXCJzb3J0aVxcXFxcXFwiLCBcXFxcXFxcIjBcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGlpID0gKHNpID09IFxcXFxcXFwiMFxcXFxcXFwiID8gXFxcXFxcXCIxXFxcXFxcXCIgOiBcXFxcXFxcIjBcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFxcXFxcIkBzb3J0XFxcXFxcXCIsIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHNvW2lpXVxcXFxuICAgICAgICAgICAgICAgIH0pXFxcXG4gICAgICAgICAgICAgICAgdmFyIHBsYXlzID0gZmluZEl0ZW1zQnlDbHMoXFxcXFxcXCJwbGF5bGlzdFxcXFxcXFwiKS5yZXZlcnNlKCkubWFwKHggPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICB4LmNvbF90eXBlID0geC50eXBlO1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4geDtcXFxcbiAgICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHMoXFxcXFxcXCJwbGF5bGlzdFxcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcXFxcXCJwbGF5bGlzdHNcXFxcXFxcIiwgcGxheXMpO1xcXFxuXFxcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcXFxcXCJzb3J0aVxcXFxcXFwiLCBpaSk7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGlrZXI6Ly9lbXB0eVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgfSwgc29ydG9iaiksXFxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcXFxuICAgICAgICAgICAgZXh0cmE6IHtcXFxcbiAgICAgICAgICAgICAgICBpZDogXFxcXFxcXCJAc29ydFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9KVxcXFxuICAgICAgICBmb3IgKGxldCBpIGluIGZyb20pIHtcXFxcbiAgICAgICAgICAgIGQucHVzaCh7XFxcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGZyb21baV0sXFxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXFxcXFwiI25vTG9hZGluZyNcXFxcXFxcIikubGF6eVJ1bGUoKGksIGlkKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcihpZCArIFxcXFxcXFwic291cmNlaVxcXFxcXFwiLCBcXFxcXFxcIjBcXFxcXFxcIikgPT0gaSkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGlrZXI6Ly9lbXB0eVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKGlkICsgXFxcXFxcXCJzb3VyY2VpXFxcXFxcXCIsIFN0cmluZyhpKSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIEdNLm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XFxcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXFxcbiAgICAgICAgaWYgKCEoaW5kZXhjLmxlbmd0aCAhPT0gMCAmJiBtbyA8IDAgJiYgbW8gPiAtNSkpIHtcXFxcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcXFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxcXG4gICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihudW0pIHx8IG51bSA+PSBsZW5ndGggfHwgbnVtIDwgMCkge1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+aVsOWtl+S4jeWQiOazlVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9XFxcXG4gICAgICAgIHJldHVybiAkKFtcXFxcXFxcIkhJS0VSXFxcXFxcXCIsIFxcXFxcXFwiVFhUXFxcXFxcXCJdLmNvbmNhdChnZXRQYXN0ZXMoKSksIDIsIFxcXFxcXFwi5YiG5Lqr5pa55byPXFxcXFxcXCIpLnNlbGVjdCgobW8sIGluZGV4cywgZXh0KSA9PiB7XFxcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcXFxuICAgICAgICAgICAgICAgIGxldCBydWxlYjY0ID0gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHJ1bGVzKSk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobGVuZ3RoLCBydWxlLCB0eXBlKSA9PiBcXFxcXFxcIua1t+mYlOinhueVjO+8jERSUFnop6PmnpDvvIzlhbHjgIxcXFxcXFxcIiArIGxlbmd0aCArIFxcXFxcXFwi44CN5p2h77yM5aSN5Yi25pW05p2h5Y+j5Luk5omT5byA6L2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FxcIikge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcXFxcXCJcXFxcXFxcIiwgXFxcXFxcXCLovpPlhaXkvY3nva5cXFxcXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpO1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcXFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFxcXFxcIue9rumhtlxcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXFxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLmdldEpzb24oKTtcXFxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXFxcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXFxcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFxcXFxcIuWIoOmZpFxcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcXFxcXCLnoa7orqTliKDpmaTvvJ9cXFxcXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5nZXRKc29uKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXFxcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/lt7LliKDpmaRcXFxcXFxcIiArIHJ1bGUubmFtZTtcXFxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcXFxcXCJjb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gICAgIH0pLFxcXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5qcyxcXFxcbiAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXFxcbiAgICB9XFxcXG59KTtcXFxcbmQucHVzaCh7XFxcXG4gICAgY29sX3R5cGU6IFxcXFxcXFwibGluZV9ibGFua1xcXFxcXFwiXFxcXG59KTtcXFxcbmQucHVzaCh7XFxcXG4gICAgdGl0bGU6IFxcXFxcXFwi5Yig6ZmkXFxcXFxcXCIsXFxcXG4gICAgdXJsOiAkKFxcXFxcXFwiI25vTG9hZGluZyNcXFxcXFxcIikubGF6eVJ1bGUoKGluZGV4LCB1cmxJbmRleCkgPT4ge1xcXFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXFxcbiAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v5q2k6aG55peg5rOV5Yig6ZmkXFxcXFxcXCI7XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgaWYgKHVybEluZGV4ICE9PSB2b2lkKDApKSB7XFxcXG4gICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+ato+WcqOabtOaWsOino+aekO+8jOWIoOmZpOivt+S7juino+aekOeuoeeQhui/m+WFpVxcXFxcXFwiO1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgIGNvbmZpcm0oe1xcXFxuICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwi5rip6aao5o+Q56S6XFxcXFxcXCIsXFxcXG4gICAgICAgICAgICBjb250ZW50OiBcXFxcXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwi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cXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFxcXFxcInZpZGVvVXJsXFxcXFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXFxcbiAgICAgICAgICAgICAgICBuYW1lLFxcXFxuICAgICAgICAgICAgICAgIHVybCxcXFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxcXG4gICAgICAgICAgICAgICAganNcXFxcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXFxcbiAgICAgICAgfSk7XFxcXG4gICAgfSksXFxcXG4gICAgY29sX3R5cGU6IFxcXFxcXFwidGV4dF8zXFxcXFxcXCIsXFxcXG59KTtcXFxcblxcXFxuZC5wdXNoKHtcXFxcbiAgICB0aXRsZTogXFxcXFxcXCLkv53lrZhcXFxcXFxcIixcXFxcbiAgICB1cmw6ICQoXFxcXFxcXCIjbm9Mb2FkaW5nI1xcXFxcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIGlzSW1wb3J0KSA9PiB7XFxcXG4gICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcXFxcXCJwc19uYW1lXFxcXFxcXCIsIFxcXFxcXFwiXFxcXFxcXCIpLnRyaW0oKTtcXFxcbiAgICAgICAgaWYgKCFuYW1lKSB7XFxcXG4gICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+WQjeWtl+W+l+acieS4gOS4quWQp1xcXFxcXFwiO1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFxcXFxcInBzX3VybFxcXFxcXFwiLCBcXFxcXFxcIlxcXFxcXFwiKS50c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FxcbiAgICAgICAgICAgIGpzXFxcXG4gICAgICAgIH07XFxcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcXFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcXFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXFxcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcXFxuIC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zLmxlbmd0aCA9PT0gMSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFxcXFxcIiArIGluZGV4ICsgXFxcXFxcXCImcnVsZT1cXFxcXFxcIiArIHJ1bGVUaXRsZTtcXFxcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFxcXFxcIuW3suabtOaWsOinhOWIme+8mlxcXFxcXFwiICsgcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIG5ld0krKztcXFxcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcXFxcXCIgKyBydWxlVGl0bGU7XFxcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcXFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFx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Chlc2NhcGUpIHtcXFxcbiAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxcXG4gICAgICAgICAgICAgICAgZXNjYXBlID0gZmFsc2U7XFxcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXFxcXFxcXFxcJykge1xcXFxuICAgICAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcXFxuICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXFxcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcXFxuICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXFxcbiAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICBpZiAoY3VycmVudCkge1xcXFxuICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgIHJldHVybiBwYXRoO1xcXFxuICAgIH1cXFxcblxcXFxuICAgIGZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxcXG4gICAgICAgIGlmICghb2JqIHx8ICFBcnJheS5pc0FycmF5KHBhdGgpKSB7XFxcXG4gICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgIGlmIChwYXRoLmxlbmd0aCA9PT0gMCkge1xcXFxuICAgICAgICAgICAgcmV0dXJuIG9iajtcXFxcbiAgICAgICAgfVxcXFxuICAgICAgICBsZXQgY3VycmVudCA9IG9iajtcXFxcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxcXG4gICAgICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXFxcbiAgICAgICAgICAgIGlmIChjdXJyZW50ID09PSBudWxsIHx8IGN1cnJlbnQgPT09IHVuZGVmaW5lZCB8fCB0eXBlb2YgY3VycmVudCAhPT0gJ29iamVjdCcpIHtcXFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgY3VycmVudCA9IGN1cnJlbnRba2V5XTtcXFxcbiAgICAgICAgfVxcXFxuICAgICAgICByZXR1cm4gY3VycmVudDtcXFxcbiAgICB9XFxcXG4gICAgdHJ5IHtcXFxcbiAgICAgICAgbGV0IHJ1blR5cGUgPSBNWV9QQVJBTVMucnVuVHlwZVswXTtcXFxcbiAgICAgICAgbGV0IHVybCA9IGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnVybFswXSkpO1xcXFxuICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFxcXFxcIkpTT05cXFxcXFxcIikge1xcXFxuXFxcXG4gICAgICAgICAgICBsZXQgcGFyYW0gPSBKU09OLnBhcnNlKGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcXFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogcGFyYW0uaGVhZGVycyB8fCB7fSxcXFxcbiAgICAgICAgICAgICAgICBtZXRob2Q6IHBhcmFtLm1ldGhvZCB8fCB2b2lkIDBcXFxcbiAgICAgICAgICAg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mV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXFxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFxcXFxcIkxvY2F0aW9uXFxcXFxcXCI6IHJlc1xcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKCQudHlwZShyZXMpID09PSBcXFxcXFxcIm9iamVjdFxcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXFxcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiByZXNcXFxcbiAgICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgIH0gY2F0Y2ggKGUpIHtcXFxcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxcXG4gICAgfVxcXFxufVxcXFxuXFxcXG5mdW5jdGlvbiBwcmVwYXJlUGFyc2VzKHBhcnNlcywgdXJsLCBwbGF5bGlzdCwgaXNUZXN0KSB7XFxcXG4gICAgcGxheWxpc3QgPSBwbGF5bGlzdCB8fCB7XFxcXG4gICAgICAgIHVybHM6IFtdLFxcXFxuICAgICAgICBuYW1lczogW10sXFxcXG4gICAgICAgIGhlYWRlcnM6IFtdLFxcXFxuICAgICAgICBpczogXFxcXFxcXCIjaXNWaWRlbz10cnVlI1xcXFxcXFwiLFxcXFxuICAgIH07XFxcXG4gICAgbGV0IHByb3h5VXJsID0gc3RhcnRQcm94eVNlcnZlcigkLnRvU3RyaW5nKHByb3h5LCBNWV9SVUxFLnRpdGxlKSk7XFxcXG4gICAgcGFyc2VzLmZvckVhY2goKHYs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cXFxcXCIpIHx8IFN0cmluZyhpdC5hcGkpLmluY2x1ZGVzKFxcXFxcXFwiZHJweTIuanNcXFxcXFxcIikpKSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC5leHQuZW5kc1dpdGgoXFxcXFxcXCIuanNcXFxcXFxcIikgPyBkZWNvZGVVUklDb21wb25lbnQoaXQuZXh0LnNwbGl0KFxcXFxcXFwiL1xcXFxcXFwiKS5hdCgtMSkpIDogKGl0Lm5hbWUgKyBcXFxcXFxcIi5qc1xcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGl0LmV4dCkuc3RhcnRzV2l0aChcXFxcXFxcImh0dHBcXFxcXFxcIikpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3QoaXQuZXh0KTtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChqb2luVXJsKHVybCwgaXQuZXh0KSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXFxcXFwiLi9cXFxcXFxcIiArIG5hbWU7XFxcXG4gICAgICAgICAgICAgICAgaWYgKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXFxcXFwicnVsZVxcXFxcXFwiKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGksIDEpO1xcXFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXFxcbiAgICAgICAgICAgICAgICB9O1xcXFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgbmFtZSwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgY291bnQr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cbiAgICAgICAgfSBlbHNlIGlmIChjb25maWcucGF0aC5zdGFydHNXaXRoKFxcXFxcXFwiaHR0cHM6Ly9naXRodWIuY29tXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICBzb3VyY2VMaXN0ID0gZ2VuZXJhdGVDb25maWdCeUdpdGh1Yihjb25maWcucGF0aCk7XFxcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXFxcXFwiZ2l0aHViRGlyXFxcXFxcXCI7XFxcXG4gICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhmZXRjaChjb25maWcucGF0aCkgfHwgXFxcXFxcXCJ7fVxcXFxcXFwiKSk7XFxcXG4gICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwgIWpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBzb3VyY2VMaXN0ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcyk7XFxcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXFxcXFwiaW5kZXhcXFxcXFxcIjtcXFxcbiAgICAgICAgfVxcXFxuICAgICAgICBmaWxlID0gdm9pZCAwO1xcXFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxcXG4gICAgICAgIGlmIChjb25maWcuY0tleSkge1xcXFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3QuZmluZCh2ID0+IHYua2V5ID09PSBjb25maWcuY0tleSk7XFxcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXFxcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXFxcbiAgICAgICAgICA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ZHJweTIuanNcXFxcXFxcIikpXFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgaWYgKG9iai51cmwuc3RhcnRzV2l0aChcXFxcXFxcImZpbGU6XFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgbGV0IGNvZGUgPSBcXFxcXFxcIm5vXFxcXFxcXCI7XFxcXG4gICAgICAgICAgbGV0IHBhdGggPSBvYmoudXJsLnJlcGxhY2UoXFxcXFxcXCJmaWxlOi8vXFxcXFxcXCIsIFxcXFxcXFwiXFxcXFxcXCIpO1xcXFxuICAgICAgICAgIGxldCBkaXIgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcXFxuICAgICAgICAgIGlmIChkaXIuaXNEaXJlY3RvcnkoKSkge1xcXFxuICAgICAgICAgICAgbGV0IGZsaXN0ID0gZGlyLmxpc3RGaWxlcygpO1xcXFxuICAgICAgICAgICAgZm9yICh2YXIgZiBvZiBmbGlzdCkge1xcXFxuICAgICAgICAgICAgICAvLyDmo4Dmn6Xmlofku7blkI3mmK/lkKbku6UuanPnu5PlsL5cXFxcbiAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFxcXFxcIi5qc1xcXFxcXFwiKSkge1xcXFxuICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXFxcbiAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcXFxuICAgICAgICAgICAgdHJ5IHtcXFxcbiAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcXFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcXFxuICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcXFxuICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcXFxuICAgICAgICAgICAgY29kZSA9IFxcXFxcXFwib2tcXFxcXFxcIjtcXFxcbiAgICAgICAgICB9XFxcXG4gICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXFxcbiAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxcXG4gICAgICAgICAgICBjb2RlID0gXFxcXFxcXCJva1xcXFxcXFwiO1xcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgICByZXR1cm4ge1xcXFxuICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXFxcbiAgICAgICAgICAgIHVybDogb2JqLnVybCxcXFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXFxcbiAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxcXG4gICAgICAgICAgICBpbmRleDogb2JqLmlcXFxcbiAgICAgICAgICB9XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgdmFyIGogPSBKU09OLnBhcnNlKGZldGNoKG9iai51cmwsIHtcXFxcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXFxcbiAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcXFxuICAgICAgICB9KSk7XFxcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXFxcbiAgICAgICAgbGV0IGMgPSBlIC0gcztcXFxcbiAgICAgICAgaWYgKG9iai51cmwuaW5jbHVkZXMoXFxcXFxcXCJnaXRodWIuY29tXFxcXFxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXFxcbiAgICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgdmFyIGh0bWwgPSBqLmJvZHk7XFxcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFxcXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXFxcXFwiKSk7XFxcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcXFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFxcXFxcIi5qc1xcXFxcXFwiKSkubGVuZ3RoO1xcXFxuICAgICAgICAgIH0gY2F0Y2gge31cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICB0cnkge1xcXFxuICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcXFxcXCJ7fVxcXFxcXFwiKTtcXFxcbiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcXFxuICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICB9IGNhdGNoIChlKSB7fVxcXFxuXFxcXG4gICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgdGltZTogYyxcXFxcbiAgICAgICAgICB1cmw6IGoudXJsLFxcXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXFxcbiAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxcXG4gICAgICAgICAgaW5kZXg6IG9iai5pLFxcXFxuICAgICAgICB9XFxcXG4gICAgICB9O1xcXFxuICAgICAgbGV0IHRhc2tzID0gbGlzdC5tYXAoKHgsIGkpID0+IHtcXFxcbiAgICAgICAgaSA9IGkgKyAxO1xcXFxuICAgICAgICByZXR1cm4ge1xcXFxuICAgICAgICAgIGZ1bmM6IHRhc2ssXFxcXG4gICAgICAgICAgcGFyYW06IHtcXFxcbiAgICAgICAgICAgIHVybDogeCxcXFxcbiAgICAgICAgICAgIGk6IGkgLSAxLFxcXFxuICAgICAgICAgIH0sXFxcXG4gICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcXFxuICAgICAgICB9XFxcXG4gICAgICB9KTtcXFxcbiAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxcXG4gICAgICBiZSh0YXNrcywge1xcXFxuICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcXFxuICAgICAgICAgIG9iai5yZXN1bHRzLnB1c2godGFza1Jlc3VsdClcXFxcbiAgICAgICAgICBjb3VudCA9IGNvdW50IC0gMTtcXFxcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxcXG4gICAgICAgICAgICBzaG93TG9hZGluZyhcXFxcXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXFxcXFwiICsgY291bnQpXFxcXG4gICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICB9LFxcXFxuICAgICAgICBwYXJhbToge1xcXFxuICAgICAgICAgIGhpOiAnY2NjJyxcXFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxcXG4gICAgICAgIH1cXFxcbiAgICAgIH0sIHN1Y2Nlc3MpO1xcXFxuICAgICAgLy9sb2cocmVzdWx0cylcXFxcbiAgICAgIHJlc3VsdHMgPSByZXN1bHRzLmZpbHRlcihmID0+IGYpO1xcXFxuICAgICAgcmVzdWx0cy5mb3JFYWNoKCh4LCBpKSA9PiB7XFxcXG4gICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcXFxcXCJwYXRoXFxcXFxcXCIgKyB4LmluZGV4KTtcXFxcbiAgICAgICAgbGV0IHJl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Y2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHNvdXJjZXMuZmluZCh2ID0+IHYubmFtZSA9PSBuYW1lKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBuYW1lID0gcGF0aC5zcGxpdChcXFxcXFxcIi9cXFxcXFxcIikuYXQoLTEpO1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKHBhdGgpO1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXJ1bGUpIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v6I635Y+W5aSx6LSlXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKFxcXFxcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvXFxcXFxcXCIgKyBwbmFtZSwgZmV0Y2gocGF0aCkpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwic2hhcmU6Ly9oaWtlcjovL2ZpbGVzL19jYWNoZS9cXFxcXFxcIiArIHBuYW1lO1xcXFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IHNoYXJlUGFzdGUoYmFzZTY0RW5jb2RlKHJ1bGUpLCBpbnB1dCk7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJjb3B5Oi8v5rW36ZiU6KeG55WM77yMRFJQWeinhumikea6kOOAjFxcXFxcXFwiICsgbmFtZSArIFxcXFxcXFwi44CN5aSN5Yi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XFxcIl0sXFxcXG4gICAgICAgIGNvbHVtbnM6IDIsXFxcXG4gICAgICAgIHRpdGxlOiBcXFxcXFxcIuivt+mAieaLqVxcXFxcXFwiLFxcXFxuICAgICAgICBjbGljayhzLCBpKSB7XFxcXG4gICAgICAgICAgaWYgKGkgPT09IDApIHtcXFxcbiAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogMztcXFxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2VDb2x1bW5zKHNwZW4pO1xcXFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMSkge1xcXFxuICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXFxcbiAgICAgICAgICAgICAgY29udGVudDogXFxcXFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFxcXFxcIuetm+mAiea6kFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICBoaW50OiBcXFxcXFxcIua6kOWFs+mUruWtl1xcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcXFxcXCJydW50aW1lQ29uZmlnXFxcXFxcXCIsIFxcXFxcXFwicnVudGltZUNvbmZpZ1xcXFxcXFwiKTtcXFxcbiAgICAgICAgIC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FxcIik7XFxcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxcXG4gICAgICAgICAgICBsZXQgQ2tleSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpLmtleTtcXFxcbiAgICAgICAgICAgIC8vbG9nKENrZXkpXFxcXG4gICAgICAgICAgICBsZXQgY2ZnID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50Q29uZmlnKClcXFxcbiAgICAgICAgICAgIGxldCB7XFxcXG4gICAgICAgICAgICAgIHBhdGgsXFxcXG4gICAgICAgICAgICAgIG5hbWVcXFxcbiAgICAgICAgICAgIH0gPSBjZmc7XFxcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcXFxuICAgICAgICAgICAgICBwYXRoLFxcXFxuICAgICAgICAgICAgICBuYW1lLFxcXFxuICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRTb3VyY2UoQ2tleSk7XFxcXG4gICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcXFxuXFxcXG4gICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcXFxuICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXFxcblxcXFxuICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDAgfHwgZGxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcXFxcXCJcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXFxcbiAgICAgICAgICAgICAgICBhbGlzdC5mb3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FxcIiwgXFxcXFxcXCLlj43pgIlcXFxcXFxcIl0sXFxcXG4gICAgICAgIGNvbHVtbnM6IDIsXFxcXG4gICAgICAgIHRpdGxlOiBcXFxcXFxcIuivt+mAieaLqVxcXFxcXFwiLFxcXFxuICAgICAgICBjbGljayhzLCBpKSB7XFxcXG4gICAgICAgICAgaWYgKGkgPT09IDApIHtcXFxcbiAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogMztcXFxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2VDb2x1bW5zKHNwZW4pO1xcXFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMSkge1xcXFxuICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXFxcbiAgICAgICAgICAgICAgY29udGVudDogXFxcXFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFxcXFxcIuetm+mAiea6kFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICBoaW50OiBcXFxcXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxcXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXFxcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcXFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxcXG4gICAgICAgICAgICAgICAgICBjYW5TZWFyY2hTb3VyY2UuZm9yRWFjaCgodiwgaSkgPT4ge1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXFxcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFxcXFxcIuKAnOKAnOKAneKAnVxcXFxcXFwiICsgKHYubmFtZSArIFxcXFxcXFwiXFxcXFxcXCIpLmZvbnRjb2xvcihcXFxcXFxcIiMwMDk5NjZcXFxcXFxcIikgOiB2Lm5hbWUpXFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxcXG4gICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXFxcblxcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXFxcXFwiICsgdGV4dDtcXFxcbiAgICAgICAgICAgICAgfSxcXFxcblxcXFxuICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXFxcbiAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxcXG5cXFxcblxcXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxcXG4gICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXFxcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcXFxuICAgICAgICAgICAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXFxcbiAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcXFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnJldmVyc2UoKTtcXFxcblxcXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcXFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxcXG4gICAgICAgICAgICAgIGlmICghc2VhcmNoQWxsb3cuaW5jbHVkZXModikpIHtcXFxcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXFxcbiAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbm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gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5pbmRleDtcXFxcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcXFxcXCItMVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgIC8vbG9nKGMpXFxcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcXFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcXFxcXCItMVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcXFxcXCJcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXFxcbiAgICAgICAgICAgICAgICAvL2xvZyhjYXRlX3RlbXApXFxcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcihcXFxcXFxcImNhdGVfdGVtcFxcXFxcXFwiLCBjYXRlX3RlbXApO1xcXFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXFxcXFwiY2F0ZV9vYmpcXFxcXFxcIiwgY2F0ZV9vYmopO1xcXFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGlrZXI6Ly9lbXB0eVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICB9LCB7XFxcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcXFxuICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcXFxuICAgICAgICAgICAgICAgIGk6IGksXFxcXG4gICAgICAgICAgICAgICAgY2F0ZTogY2F0ZVxcXFxuICAgICAgICAgICAgICB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