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hbFRoaXMuZ2V0UmFuZG9tSXRlbSA9IGZ1bmN0aW9uIChpdGVtcykgey8v5LuO5YiX6KGo6ZqP5py65Y+W5Ye65LiA5Liq5YWD57SgCiAgICByZXR1cm4gaXRlbXNbTWF0aC5yYW5kb20oKSAqIGl0ZW1zLmxlbmd0aCB8IDBdOwp9CnZhciBydWxlID0gewogICAgdGl0bGU6ICfph4fpm4bkuYvnjotb5ZCIXScsCiAgICBhdXRob3I6ICfpgZPplb8nLAogICAgdmVyc2lvbjogJzIwMjQwNzA1IGJldGExNicsCiAgICB1cGRhdGVfaW5mbzogYAoyMDI0MDcwNToKMS7mlK/mjIHkvKDlj4Jqc29u5ZCO6Z2i5aKe5YqgJDEg6L+Z5qC355qE6aKd5aSW5qCH6K+G77yM55So5LqO5pCc57Si57uT5p6c57K+5YeG5Yy56YWNCjIu5pSv5oyB5Lyg5Y+CanNvbuWQjumdouWinuWKoCQxJDEg6L+Z5qC355qE6aKd5aSW5qCH6K+G77yM55So5LqO5by65Yi26I635Y+W5pCc57Si5Zu+54mH44CCJDEk5LiN5pi+56S65Zu+54mH44CC6buY6K6k5piv5pCc57Si5by65Yi25pyJ5Zu+54mH55qEW+W3suWunueOsOivpuaDhemhteivt+axguS9v+eUqOaJuemHj10KMy7kv67lpI3kuoznuqfmlbDmja7ml6Dluo/ljLnphY3mkJzntKLliJfooajlm77niYfnmoTpl67popgKNC7kv67mlLnmkJzntKLnsr7lh4blkozlm77niYfmmL7npLrpop3lpJblj4LmlbDpl7TpmpTnrKbku44j5Y+Y5Li6JAoyMDI0MDcwMzoKMS7ph4fpm4Zqc29u5pSv5oyBInNlYXJjaGFibGUiOiAwLOeUqOS6juaQnOe0ouaXtuaOkumZpOi/meS4qua6kAoyMDI0MDYwNDoKMS7pppbpobXmjqjojZDlj5bmtojnoazmjqfnrYnlvoXjgILlop7liqDpmo/mnLrmjqjojZDlip/og73jgIIKMi7pppbpobXmjqjojZDmlrDlop7mm7TmlrDml6Xlv5fmn6XnnIvlip/og70K44CQ54m55Yir6K+05piO44CR55uu5YmN5Y+q5pSv5oyB5qCH5YeGanNvbuagvOW8j+eahOmHh+mbhuermSjotYTmupDnq5nkuIDoiKzpg73mj5Dkvpt4bWzlkoxqc29u5Lik56eN5o6l5Y+j77yM55uu5YmN5rKh5pyJ5pSv5oyBeG1s55qE5oOz5rOV77yM5rKh5LuA5LmI5b+F6KaBKQrmnInkupvotYTmupDnq5nnmoRqc29u5o6l5Y+j5LiN5piv5qCH5YeG55qEL2FwaS5waHAvcHJvdmlkZS92b2QvLOmcgOimgeiHquW3seWcqOmHh+mbhumdmeaAgS5qc29u5Lit57yW6L6R5a+55bqU55qEYXBp5bGe5oCn5aGr5YaZ5q+U5aaCOi9hcGkucGhwL3Byb3ZpZGUvdm9kL2F0L2pzb24vCuacieS6m+i1hOa6kOermeeahOmHh+mbhuaVsOaNruaYr+WKoOWvhuWQjueahOWIh+eJh+eJh+aute+8jOWPr+iDvemcgOimgemHh+mbhuermeeJueWumueahOino+aekOaOpeWPo++8jOmcgOimgeiHquW3see8lui+kWpzb27ph4znmoRwYXJzZV91cmzlsZ7mgKcK6LWE5rqQ56uZ6YOo5YiG5aSn5YiG57G75LiL5peg5pWw5o2u5b6I5q2j5bi477yM5Y+v5Lul6Ieq6KGM57yW6L6RanNvbumHjGNhdGVfZXhjbHVkZeWxnuaAp+aOkumZpOaOieiHquW3sea1i+ivlei/h+aXoOaVsOaNrueahOWIhuexuyjlsI/nqIvluo/ml6Dms5Xoh6rliqjor4bliKvvvIzlj6rog73kurrlt6XmtYvlpb3lk6rkupvliIbnsbvml6DmlbDmja4pCmAudHJpbSgpLAogICAgaG9zdDogJycsCiAgICBob21lVGlkOiAnJywgLy8g6aaW6aG15o6o6I2Q44CC5LiA6Iis5aGr5YaZ56ys5LiA5Liq6LWE5rqQ56uZ55qE5oOz6KaB55qE5o6o6I2Q5YiG57G755qEaWQu5Y+v5Lul56m6CiAgICBob21lVXJsOiAnL2FwaS5waHAvcHJvdml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HtlfWApCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjbGFzc2VzCiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IG5hbWVzID0gaXRlbS5jbGFzc19uYW1lLnNwbGl0KCcmJyk7CiAgICAgICAgICAgICAgICBsZXQgdXJscyA9IGl0ZW0uY2xhc3NfdXJsLnNwbGl0KCcmJyk7CiAgICAgICAgICAgICAgICBsZXQgY250ID0gTWF0aC5taW4obmFtZXMubGVuZ3RoLCB1cmxzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgY2xhc3Nlcy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgJ3R5cGVfaWQnOiB1cmxzW2ldLAogICAgICAgICAgICAgICAgICAgICAgICAndHlwZV9uYW1lJzogbmFtZXNbaV0KICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xhc3NlcwogICAgICAgIH0KCiAgICAgICAgaWYgKHR5cGVvZiAoYmF0Y2hGZXRjaCkgPT09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgLy8g5pSv5oyB5om56YeP6K+35rGC55u05o6l5pS+6aOe6Ieq5oiR44CC5pCc57Si6ZmQ5Yi25pyA5aSn57q/56iL5pWw6YePMTYKICAgICAgICAgICAgcnVsZS5zZWFyY2hfbGltaXQgPSAxNjsKICAgICAgICAgICAgbG9nKCflvZPliY3nqIvluo/mlK/mjIHmibnph4/or7fmsYJbYmF0Y2hGZXRjaF0s5pCc57Si6ZmQ5Yi25bey6K6+572u5Li6MTYnKTsKICAgICAgICB9CiAgICAgICAgbGV0IF91cmwgPSBydWxlLnBhcmFtczsKICAgICAgICBsb2coYOS8oOWFpeWPguaVsDoke191cmx9YCk7CiAgICAgICAgaWYgKF91cmwgJiYgdHlwZW9mIChfdXJsKSA9PT0gJ3N0cmluZycgJiYgL14oaHR0cHxmaWxlKS8udGVzdChfdXJsKSkgewogICAgICAgICAgICBpZiAoX3VybC5pbmNsdWRlcygnJCcpKSB7CiAgICAgICAgICAgICAgICBsZXQgX3VybF9wYXJhbXMgPSBfdXJsLnNwbGl0KCckJyk7CiAgICAgICAgICAgICAgICBfdXJsID0gX3VybF9wYXJhbXNbMF07CiAgICAgICAgICAgICAgICBydWxlLnNlYXJjaF9tYXRjaCA9ICEhKF91cmxfcGFyYW1zWzFdKTsKICAgICAgICAgICAgICAgIGlmIChfdXJsX3BhcmFtcy5sZW5ndGggPiAyKSB7IC8vIOW8uuWItuWbvueJhwogICAgICAgICAgICAgICAgICAgIHJ1bGUuc2VhcmNoX3BpYyA9ICEhKF91cmxfcGFyYW1zWzJdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoX3VybCk7CiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShodG1sKTsKICAgICAgICAgICAgbGV0IF9jbGFzc2VzID0gW107CiAgICAgICAgICAgIHJ1bGUuZmlsdGVyID0ge307CiAgICAgICAgICAgIHJ1bGUuZmlsdGVyX2RlZiA9IHt9OwogICAgICAgICAgICBqc29uLmZvckVhY2goaXQgPT4gewogICAgICAgICAgICAgICAgbGV0IF9vYmogPSB7CiAgICAgICAgICAgICAgICAgICAgdHlwZV9uYW1lOiBpdC5uYW1lLAogICAgICAgICAgICAgICAgICAgIHR5cGVfaWQ6IGl0LnVybCwKICAgICAgICAgICAgICAgICAgICBwYXJzZV91cmw6IGl0LnBhcnNlX3VybCB8fCAnJywKICAgICAgICAgICAgICAgICAgICBzZWFyY2hhYmxlOiBpdC5zZWFyY2hhYmxlICE9PSAwLAogICAgICAgICAgICAgICAgICAgIGFwaTogaXQuYXBpIHx8ICcnLAogICAgICAgICAgICAgICAgICAgIGNhdGVfZXhjbHVkZTogaXQuY2F0ZV9leGNsdWRlIHx8ICcnLAogICAgICAgICAgICAgICAgICAgIC8vIGNsYXNzX25hbWU6IGl0LmNsYXNzX25hbWUgfHwgJycsCiAgICAgICAgICAgICAgICAgICAgLy8gY2xhc3NfdXJsOiBpdC5jbGFzc191cmwgfHwgJycsCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgX2NsYXNzZXMucHVzaChfb2JqKTsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGpzb24xID0gW107CiAgICAgICAgICAgICAgICAgICAgaWYgKGl0LmNsYXNzX25hbWUgJiYgaXQuY2xhc3NfdXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGpzb24xID0gZ2V0Q2xhc3NlcyhpdCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAganNvbjEgPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsam9pbihfb2JqLnR5cGVfaWQsIF9vYmouYXBpIHx8IHJ1bGUuY2xhc3NVcmwpKSkuY2xhc3M7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChfb2JqLmNhdGVfZXhjbHVkZSkgewogICAgICAgICAgICAgICAgICAgICAgICBqc29uMSA9IGpzb24xLmZpbHRlcihjbCA9PiAhbmV3IFJlZ0V4cChfb2JqLmNhdGVfZXhjbHVkZSwgJ2knKS50ZXN0KGNsLnR5cGVfbmFtZSkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBydWxlLmZpbHRlcltfb2JqLnR5cGVfaWRdID0gW3sKICAgICAgICAgICAgICAgICAgICAgICAgImtleSI6ICLnsbvlnosiLCAibmFtZSI6ICLnsbvlnosiLCAidmFsdWUiOiBqc29uMS5tYXAoaSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyJuIjogaS50eXBlX25hbWUsICd2JzogaS50eXBlX2lkfQogICAgICAgICAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICAgICAgICAgIH1dOwogICAgICAgICAgICAgICAgICAgIGlmIChqc29uMS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUuZmlsdGVyX2RlZltpdC51cmxdID0geyLnsbvlnosiOiBqc29uMVswXS50eXBlX2lkfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgcnVsZS5maWx0ZXJbaXQudXJsXSA9IFt7ImtleSI6ICLnsbvlnosiLCAibmFtZSI6ICLnsbvlnosiLCAidmFsdWUiOiBbeyJuIjogIuWFqOmDqCIsICJ2IjogIiJ9XX1dOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgcnVsZS5jbGFzc2VzID0gX2NsYXNzZXM7CiAgICAgICAgfQogICAgfSksCiAgICAvLyBjbGFzc19wYXJzZTogJGpzLnRvU3RyaW5nKCgpID0+IHsKICAgIC8vICAgICBsZXQgX3VybCA9IHJ1bGUucGFyYW1zOwogICAgLy8gICAgIGlmIChfdXJsICYmIHR5cGVvZiAoX3VybCkgPT09ICdzdHJpbmcnICYmIF91cmwuc3RhcnRzV2l0aCgnaHR0cCcpKSB7CiAgICAvLyAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChfdXJsKTsKICAgIC8vICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGh0bWwpOwogICAgLy8gICAgICAgICBsZXQgX2NsYXNzZXMgPSBbXTsKICAgIC8vICAgICAgICAgaG9tZU9iai5maWx0ZXIgPSB7fTsKICAgIC8vICAgICAgICAgcnVsZS5maWx0ZXJfZGVmID0ge307CiAgICAvLyAgICAgICAgIGpzb24uZm9yRWFjaChpdCA9PiB7CiAgICAvLyAgICAgICAgICAgICBsZXQgX29iaiA9IHsKICAgIC8vICAgICAgICAgICAgICAgICB0eXBlX25hbWU6IGl0Lm5hbWUsCiAgICAvLyAgICAgICAgICAgICAgICAgdHlwZV9pZDogaXQudXJsLAogICAgLy8gICAgICAgICAgICAgICAgIHBhcnNlX3VybDogaXQucGFyc2VfdXJsIHx8ICcnLAogICAgLy8gICAgICAgICAgICAgICAgIGNhdGVfZXhjbHVkZTogaXQuY2F0ZV9leGNsdWRlIHx8ICcnLAogICAgLy8gICAgICAgICAgICAgfTsKICAgIC8vICAgICAgICAgICAgIF9jbGFzc2VzLnB1c2goX29iaik7CiAgICAvLyAgICAgICAgICAgICB0cnkgewogICAgLy8gICAgICAgICAgICAgICAgIGxldCBqc29uMSA9IEpTT04ucGFyc2UocmVxdWVzdCh1cmxqb2luKF9vYmoudHlwZV9pZCwgcnVsZS5jbGFzc1VybCkpKS5jbGFzczsKICAgIC8vICAgICAgICAgICAgICAgICBpZiAoX29iai5jYXRlX2V4Y2x1ZGUpIHsKICAgIC8vICAgICAgICAgICAgICAgICAgICAganNvbjEgPSBqc29uMS5maWx0ZXIoY2wgPT4gIW5ldyBSZWdFeHAoX29iai5jYXRlX2V4Y2x1ZGUsICdpJykudGVzdChjbC50eXBlX25hbWUpKTsKICAgIC8vICAgICAgICAgICAgICAgICB9CiAgICAvLyAgICAgICAgICAgICAgICAgaG9tZU9iai5maWx0ZXJbX29iai50eXBlX2lkXSA9IFt7CiAgICAvLyAgICAgICAgICAgICAgICAgICAgICJrZXkiOiAi57G75Z6LIiwgIm5hbWUiOiAi57G75Z6LIiwgInZhbHVlIjoganNvbjEubWFwKGkgPT4gewogICAgLy8gICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsibiI6IGkudHlwZV9uYW1lLCAndic6IGkudHlwZV9pZH0KICAgIC8vICAgICAgICAgICAgICAgICAgICAgfSkKICAgIC8vICAgICAgICAgICAgICAgICB9XTsKICAgIC8vICAgICAgICAgICAgICAgICBpZiAoanNvbjEubGVuZ3RoID4gMCkgewogICAgLy8gICAgICAgICAgICAgICAgICAgICBydWxlLmZpbHRlcl9kZWZbaXQudXJsXSA9IHsi57G75Z6LIjoganNvbjFbMF0udHlwZV9pZH07CiAgICAvLyAgICAgICAgICAgICAgICAgfQogICAgLy8gICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgLy8gICAgICAgICAgICAgICAgIGhvbWVPYmouZmlsdGVyW2l0LnVybF0gPSBbeyJrZXkiOiAi57G75Z6LIiwgIm5hbWUiOiAi57G75Z6LIiwgInZhbHVlIjogW3sibiI6ICLlhajpg6giLCAidiI6ICIifV19XTsKICAgIC8vICAgICAgICAgICAgIH0KICAgIC8vICAgICAgICAgfSk7CiAgICAvLyAgICAgICAgIHJ1bGUuY2xhc3NlcyA9IF9jbGFzc2VzOwogICAgLy8gICAgICAgICBpbnB1dCA9IF9jbGFzc2VzOwogICAgLy8gICAgIH0KICAgIC8vIH0pLAogICAgY2xhc3NfcGFyc2U6ICRqcy50b1N0cmluZygoKSA9PiB7CiAgICAgICAgaW5wdXQgPSBydWxlLmNsYXNzZXM7CiAgICB9KSwKICAgIOaOqOiNkDogJGpzLnRvU3RyaW5nKCgpID0+IHsKICAgICAgICBsZXQgdXBkYXRlX2luZm8gPSBbewogICAgICAgICAgICB2b2RfbmFtZTogJ+abtOaWsOaXpeW/lycsCiAgICAgICAgICAgIHZvZF9pZDogJ3VwZGF0ZV9pbmZvJywKICAgICAgICAgICAgdm9kX3JlbWFya3M6IGDniYjmnKw6JHtydWxlLnZlcnNpb259YCwKICAgICAgICAgICAgdm9kX3BpYzogJ2h0dHBzOi8vZ2hwcm94eS5uZXQvaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2hqZGhueC9oaXB5LXNlcnZlci9tYXN0ZXIvYXBwL3N0YXRpYy9pbWcvbG9nby5wbmcnCiAgICAgICAgfV07CiAgICAgICAgVk9EUyA9IFtdOwogICAgICAgIGlmIChydWxlLmNsYXNzZXMpIHsKICAgICAgICAgICAgbGV0IHJhbmRvbUNsYXNzID0gZ2V0UmFuZG9tSXRlbShydWxlLmNsYXNzZXMpOwogICAgICAgICAgICBsZXQgX3VybCA9IHVybGpvaW4ocmFuZG9tQ2xhc3MudHlwZV9pZCwgaW5wdXQpOwogICAgICAgICAgICBpZiAocmFuZG9tQ2xhc3MuYXBpKSB7CiAgICAgICAgICAgICAgICBfdXJsID0gX3VybC5yZXBsYWNlKCcvYXBpLnBocC9wcm92aWRlL3ZvZC8nLCByYW5kb21DbGFzcy5hcGkpCiAgICAgICAgICAgIH0KICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChfdXJsLCB7dGltZW91dDogcnVsZS50aW1lb3V0fSk7CiAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoaHRtbCk7CiAgICAgICAgICAgICAgICBWT0RTID0ganNvbi5saXN0OwogICAgICAgICAgICAgICAgVk9EUy5mb3JFYWNoKGl0ID0+IHsKICAgICAgICAgICAgICAgICAgICBpdC52b2RfaWQgPSByYW5kb21DbGFzcy50eXBlX2lkICsgJyQnICsgaXQudm9kX2lkOwogICAgICAgICAgICAgICAgICAgIGl0LnZvZF9yZW1hcmtzID0gaXQudm9kX3JlbWFya3MgKyAnfCcgKyByYW5kb21DbGFzcy50eXBlX25hbWU7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIFZPRFMgPSB1cGRhdGVfaW5mby5jb25jYXQoVk9EUyk7CiAgICB9KSwKICAgIOS4gOe6pzogJGpzLnRvU3RyaW5nKCgpID0+IHsKICAgICAgICBWT0RTID0gW107CiAgICAgICAgaWYgKHJ1bGUuY2xhc3NlcykgewogICAgICAgICAgICAvLyBsb2coaW5wdXQpOwogICAgICAgICAgICBsZXQgX3VybCA9IHVybGpvaW4oTVlfQ0FURSwgaW5wdXQpOwogICAgICAgICAgICBsZXQgY3VycmVudF92b2QgPSBydWxlLmNsYXNzZXMuZmluZChpdGVtID0+IGl0ZW0udHlwZV9pZCA9PT0gTVlfQ0FURSk7CiAgICAgICAgICAgIGlmIChjdXJyZW50X3ZvZCAmJiBjdXJyZW50X3ZvZC5hcGkpIHsKICAgICAgICAgICAgICAgIF91cmwgPSBfdXJsLnJlcGxhY2UoJy9hcGkucGhwL3Byb3ZpZGUvdm9kLycsIGN1cnJlbnRfdm9kLmFwaSkKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoX3VybCk7CiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShodG1sKTsKICAgICAgICAgICAgVk9EUyA9IGpzb24ubGlzdDsKICAgICAgICAgICAgVk9EUy5mb3JFYWNoKGl0ID0+IHsKICAgICAgICAgICAgICAgIGl0LnZvZF9pZCA9IE1ZX0NBVEUgKyAnJCcgKyBpdC52b2RfaWQKICAgICAgICAgICAgfSk7CiAgICAgICAgfQogICAgfSksCiAgICAvLyDkuIDnuqc6ICdqc29uOmxpc3Q7dm9kX25hbWU7dm9kX3BpYzt2b2RfcmVtYXJrczt2b2RfaWQ7dm9kX3BsYXlfZnJvbScsCiAgICDkuoznuqc6ICRqcy50b1N0cmluZygoKSA9PiB7CiAgICAgICAgVk9EID0ge307CiAgICAgICAgaWYgKG9ySWQgPT09ICd1cGRhdGVfaW5mbycpIHsKICAgICAgICAgICAgVk9EID0gewogICAgICAgICAgICAgICAgdm9kX2NvbnRlbnQ6IHJ1bGUudXBkYXRlX2luZm8udHJpbSgpLAogICAgICAgICAgICAgICAgdm9kX25hbWU6ICfmm7TmlrDml6Xlv5cnLAogICAgICAgICAgICAgICAgdHlwZV9uYW1lOiAn5pu05paw5pel5b+XJywKICAgICAgICAgICAgICAgIHZvZF9waWM6ICdodHRwczovL3Jlc291cmNlLWNkbi50dXhpYW9iZWkuY29tL3ZpZGVvL0Z0V2hzMm1ld1hfN25FdUU1MV9rNnp2ZzZhd2wucG5nJywKICAgICAgICAgICAgICAgIHZvZF9yZW1hcmtzOiBg54mI5pysOiR7cnVsZS52ZXJzaW9ufWAsCiAgICAgICAgICAgICAgICB2b2RfcGxheV9mcm9tOiAn6YGT6ZW/5Zyo57q/JywKICAgICAgICAgICAgICAgIC8vIHZvZF9wbGF5X3VybDogJ+WXheaOouaSreaUviRodHRwczovL3Jlc291cmNlLWNkbi50dXhpYW9iZWkuY29tL3ZpZGVvLzEwLzhmLzEwOGZjOWQxYWMzZjY5ZDI5YTczOGNkYzA5N2M5MDE4Lm1wNCcsCiAgICAgICAgICAgICAgICB2b2RfcGxheV91cmw6ICfpmo/mnLrlsI/op4bpopEkaHR0cDovL2FwaS55dWpuLmNuL2FwaS96enhqai5waHAnLAogICAgICAgICAgICB9OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGlmIChydWxlLmNsYXNzZXMpIHsKICAgICAgICAgICAgICAgIGxldCBfdXJsID0gdXJsam9pbihmeWNsYXNzLCBpbnB1dCk7CiAgICAgICAgICAgICAgICBsZXQgY3VycmVudF92b2QgPSBydWxlLmNsYXNzZXMuZmluZChpdGVtID0+IGl0ZW0udHlwZV9pZCA9PT0gZnljbGFzcyk7CiAgICAgICAgICAgICAgICBpZiAoY3VycmVudF92b2QgJiYgY3VycmVudF92b2QuYXBpKSB7CiAgICAgICAgICAgICAgICAgICAgX3VybCA9IF91cmwucmVwbGFjZSgnL2FwaS5waHAvcHJvdmlkZS92b2QvJywgY3VycmVudF92b2QuYXBpKQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KF91cmwpOwogICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGh0bWwpOwogICAgICAgICAgICAgICAgbGV0IGRhdGEgPSBqc29uLmxpc3Q7CiAgICAgICAgICAgICAgICBWT0QgPSBkYXRhWzBdOwogICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRfdm9kICYmIGN1cnJlbnRfdm9kLnR5cGVfbmFtZSkgewogICAgICAgICAgICAgICAgICAgIFZPRC52b2RfcGxheV9mcm9tID0gVk9ELnZvZF9wbGF5X2Zyb20uc3BsaXQoJyQkJCcpLm1hcChpdCA9PiBjdXJyZW50X3ZvZC50eXBlX25hbWUgKyAnfCcgKyBpdCkuam9pbignJCQkJykKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0pLAogICAg5pCc57SiOiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgICAgIFZPRFMgPSBbXTsKICAgICAgICBpZiAocnVsZS5jbGFzc2VzKSB7CiAgICAgICAgICAgIGxldCBjYW5TZWFyY2ggPSBydWxlLmNsYXNzZXMuZmlsdGVyKGl0ID0+IGl0LnNlYXJjaGFibGUpOwogICAgICAgICAgICBsZXQgcGFnZSA9IE51bWJlcihNWV9QQUdFKTsKICAgICAgICAgICAgcGFnZSA9IChNWV9QQUdFIC0gMSkgJSBNYXRoLmNlaWwoY2FuU2VhcmNoLmxlbmd0aCAvIHJ1bGUuc2VhcmNoX2xpbWl0KSArIDE7CiAgICAgICAgICAgIGxldCB0cnVlUGFnZSA9IE1hdGguY2VpbChNWV9QQUdFIC8gTWF0aC5jZWlsKGNhblNlYXJjaC5sZW5ndGggLyBydWxlLnNlYXJjaF9saW1pdCkpOwogICAgICAgICAgICBpZiAocnVsZS5zZWFyY2hfbGltaXQpIHsKICAgICAgICAgICAgICAgIGxldCBzdGFydCA9IChwYWdlIC0gMSkgKiBydWxlLnNlYXJjaF9saW1pdDsKICAgICAgICAgICAgICAgIGxldCBlbmQgPSBwYWdlICogcnVsZS5zZWFyY2hfbGltaXQ7CiAgICAgICAgICAgICAgICBsZXQgdDEgPSBuZXcgRGF0ZSgpLmdldFRpbWUoKTsKICAgICAgICAgICAgICAgIGxldCBzZWFyY2hNb2RlID0gdHlwZW9mIChiYXRjaEZldGNoKSA9PT0gJ2Z1bmN0aW9uJyA/ICfmibnph48nIDogJ+WNleS4qic7CiAgICAgICAgICAgICAgICBsb2coJ3N0YXJ0OicgKyBzdGFydCk7CiAgICAgICAgICAgICAgICBsb2coJ2VuZDonICsgZW5kKTsKICAgICAgICAgICAgICAgIGxvZygn5pCc57Si5qih5byPOicgKyBzZWFyY2hNb2RlKTsKICAgICAgICAgICAgICAgIGxvZygn57K+5YeG5pCc57SiOicgKyBydWxlLnNlYXJjaF9tYXRjaCk7CiAgICAgICAgICAgICAgICAvLyBsb2coJ3QxOicgKyB0MSk7CiAgICAgICAgICAgICAgICBpZiAoc3RhcnQgPCBjYW5TZWFyY2gubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHNlYXJjaF9jbGFzc2VzID0gY2FuU2VhcmNoLnNsaWNlKHN0YXJ0LCBlbmQpOwogICAgICAgICAgICAgICAgICAgIGxldCB1cmxzID0gW107CiAgICAgICAgICAgICAgICAgICAgc2VhcmNoX2NsYXNzZXMuZm9yRWFjaChpdCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBfdXJsID0gdXJsam9pbihpdC50eXBlX2lkLCBpbnB1dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdC5hcGkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF91cmwgPSBfdXJsLnJlcGxhY2UoJy9hcGkucGhwL3Byb3ZpZGUvdm9kLycsIGl0LmFwaSkKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfdXJsID0gX3VybC5yZXBsYWNlKCIjVHJ1ZVBhZ2UjIiwgIiIgKyB0cnVlUGFnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHVybHMucHVzaChfdXJsKTsKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICBsZXQgcmVzdWx0c19saXN0ID0gW107CiAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIChiYXRjaEZldGNoKSA9PT0gJ2Z1bmN0aW9uJykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVxVXJscyA9IHVybHMubWFwKGl0ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBpdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zOiB7dGltZW91dDogcnVsZS50aW1lb3V0fQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJldHMgPSBiYXRjaEZldGNoKHJlcVVybHMpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGV0YWlsVXJscyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGV0YWlsVXJsQ291bnQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICByZXRzLmZvckVhY2goKHJldCwgaWR4KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaXQgPSBzZWFyY2hfY2xhc3Nlc1tpZHhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IGpzb24ubGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5mb3JFYWNoKGkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaS5zaXRlX25hbWUgPSBpdC50eXBlX25hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpLnZvZF9pZCA9IGl0LnR5cGVfaWQgKyAnJCcgKyBpLnZvZF9pZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGkudm9kX3JlbWFya3MgPSBpLnZvZF9yZW1hcmtzICsgJ3wnICsgaXQudHlwZV9uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJ1bGUuc2VhcmNoX21hdGNoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID0gZGF0YS5maWx0ZXIoaXRlbSA9PiBpdGVtLnZvZF9uYW1lICYmIChuZXcgUmVnRXhwKEtFWSwgJ2knKSkudGVzdChpdGVtLnZvZF9uYW1lKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocnVsZS5zZWFyY2hfcGljICYmICFkYXRhWzBdLnZvZF9waWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coYOW9k+WJjeaQnOe0ouermeeCueOAkCR7aXQudHlwZV9uYW1lfeOAkeayoeWbvueJhyzlsJ3or5Xorr/pl67kuoznuqfljrvojrflj5blm77niYdgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGV0YWlsVXJsID0gdXJsc1tpZHhdLnNwbGl0KCd3ZD0nKVswXSArICdhYz1kZXRhaWwmaWRzPScgKyBkYXRhLm1hcChrID0+IGsudm9kX2lkLnNwbGl0KCckJylbMV0pLmpvaW4oJywnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWxVcmxzLnB1c2goZGV0YWlsVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzX2xpc3QucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc19waWM6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWxVcmxDb3VudDogZGV0YWlsVXJsQ291bnQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWxVcmxDb3VudCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgIGxldCBkZXRhaWxKc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KGRldGFpbFVybCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICBkYXRhLmZvckVhY2goKGQsIF9zZXEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgICAgIGxvZygn5LqM57qn5pWw5o2u5YiX6KGo5YWD57Sg5pWwOicgKyBkZXRhaWxKc29uLmxpc3QubGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgICAgIGxldCBkZXRhaWxWb2RQaWMgPSBkZXRhaWxKc29uLmxpc3RbX3NlcV0udm9kX3BpYzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgICAgIGlmIChkZXRhaWxWb2RQaWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgICAgICAgICBPYmplY3QuYXNzaWduKGQsIHt2b2RfcGljOiBkZXRhaWxWb2RQaWN9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICBsb2coYOW8uuWItuiOt+WPlue9keermSR7aXQudHlwZV9pZH3nmoTmkJzntKLlm77niYflpLHotKU6JHtlLm1lc3NhZ2V9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzX2xpc3QucHVzaCh7ZGF0YTogZGF0YSwgaGFzX3BpYzogdHJ1ZX0pOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHJlc3VsdHMgPSByZXN1bHRzLmNvbmNhdChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKGDor7fmsYI6JHtpdC50eXBlX2lkfeWPkeeUn+mUmeivrzoke2UubWVzc2FnZX1gKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIOaehOmAoOivt+axguS6jOe6p+eahGJhdGNoRmV0Y2jliJfooagKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJlcVVybHMyID0gZGV0YWlsVXJscy5tYXAoaXQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IGl0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnM6IHt0aW1lb3V0OiBydWxlLnRpbWVvdXR9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmV0czIgPSBiYXRjaEZldGNoKHJlcVVybHMyKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCByZXN1bHRzX2xpc3QubGVuZ3RoOyBrKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXN1bHRfZGF0YSA9IHJlc3VsdHNfbGlzdFtrXS5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZXN1bHRzX2xpc3Rba10uaGFzX3BpYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkZXRhaWxKc29uID0gSlNPTi5wYXJzZShyZXRzMltyZXN1bHRzX2xpc3Rba10uZGV0YWlsVXJsQ291bnRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCfkuoznuqfmlbDmja7liJfooajlhYPntKDmlbA6JyArIGRldGFpbEpzb24ubGlzdC5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRfZGF0YS5mb3JFYWNoKChkLCBfc2VxKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBsZXQgZGV0YWlsVm9kUGljID0gZGV0YWlsSnNvbi5saXN0W19zZXFdLnZvZF9waWM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBsb2coZGV0YWlsSnNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGV0YWlsVm9kUGljID0gZGV0YWlsSnNvbi5saXN0LmZpbmQodm9kID0+IHZvZC52b2RfaWQudG9TdHJpbmcoKSA9PT0gZC52b2RfaWQuc3BsaXQoJyQnKVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGV0YWlsVm9kUGljKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihkLCB7dm9kX3BpYzogZGV0YWlsVm9kUGljLnZvZF9waWN9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coYOW8uuWItuiOt+WPlue9keermSR7cmVzdWx0X2RhdGFbMF0uc2l0ZV9uYW1lfeeahOaQnOe0ouWbvueJh+Wksei0pToke2UubWVzc2FnZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzID0gcmVzdWx0cy5jb25jYXQocmVzdWx0X2RhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHVybHMuZm9yRWFjaCgoX3VybCwgaWR4KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaXQgPSBzZWFyY2hfY2xhc3Nlc1tpZHhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoX3VybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGh0bWwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0ganNvbi5saXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuZm9yRWFjaChpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaS52b2RfaWQgPSBpdC50eXBlX2lkICsgJyQnICsgaS52b2RfaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGkudm9kX3JlbWFya3MgPSBpLnZvZF9yZW1hcmtzICsgJ3wnICsgaXQudHlwZV9uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChydWxlLnNlYXJjaF9tYXRjaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID0gZGF0YS5maWx0ZXIoaXRlbSA9PiBpdGVtLnZvZF9uYW1lICYmIChuZXcgUmVnRXhwKEtFWSwgJ2knKSkudGVzdChpdGVtLnZvZF9uYW1lKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocnVsZS5zZWFyY2hfcGljICYmICFkYXRhWzBdLnZvZF9waWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhg5b2T5YmN5pCc57Si56uZ54K544CQJHtpdC50eXBlX25hbWV944CR5rKh5Zu+54mHLOWwneivleiuv+mXruS6jOe6p+WOu+iOt+WPluWbvueJh2ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRldGFpbFVybCA9IHVybHNbaWR4XS5zcGxpdCgnd2Q9JylbMF0gKyAnYWM9ZGV0YWlsJmlkcz0nICsgZGF0YS5tYXAoayA9PiBrLnZvZF9pZC5zcGxpdCgnJCcpWzFdKS5qb2luKCcsJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkZXRhaWxKc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KGRldGFpbFVybCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZygn5LqM57qn5pWw5o2u5YiX6KGo5YWD57Sg5pWwOicgKyBkZXRhaWxKc29uLmxpc3QubGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLmZvckVhY2goKGQsIF9zZXEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gbGV0IGRldGFpbFZvZFBpYyA9IGRldGFpbEpzb24ubGlzdFtfc2VxXS52b2RfcGljOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGV0YWlsVm9kUGljID0gZGV0YWlsSnNvbi5saXN0LmZpbmQodm9kID0+IHZvZC52b2RfaWQudG9TdHJpbmcoKSA9PT0gZC52b2RfaWQuc3BsaXQoJyQnKVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXRhaWxWb2RQaWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24oZCwge3ZvZF9waWM6IGRldGFpbFZvZFBpYy52b2RfcGljfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coYOW8uuWItuiOt+WPlue9keermSR7aXQudHlwZV9pZH3nmoTmkJzntKLlm77niYflpLHotKU6JHtlLm1lc3NhZ2V9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0cyA9IHJlc3VsdHMuY29uY2F0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzID0gcmVzdWx0cy5jb25jYXQoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKGDor7fmsYI6JHtpdC50eXBlX2lkfeWPkeeUn+mUmeivrzoke2UubWVzc2FnZX1gKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIFZPRFMgPSByZXN1bHRzOwogICAgICAgICAgICAgICAgICAgIGxldCB0MiA9IG5ldyBEYXRlKCkuZ2V0VGltZSgpOwogICAgICAgICAgICAgICAgICAgIC8vIGxvZygndDI6Jyt0Mik7CiAgICAgICAgICAgICAgICAgICAgbG9nKGAke3NlYXJjaE1vZGV95pCc57SiOiR7dXJscy5sZW5ndGh95Liq56uZ6ICX5pe2OiR7KE51bWJlcih0MikgLSBOdW1iZXIodDEpKX1tc2ApCgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSksCiAgICBsYXp5OiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgICAgIC8vIGxhennmg7Plip7ms5XnlKjlr7nlupTnmoRwYXJzZV91cmzvvIzkvYbmmK/mnInpmr7luqbvvIzmmoLmnKrlrp7njrAKICAgICAgICBsZXQgcGFyc2VfdXJsID0gJyc7CiAgICAgICAgaWYgKGZsYWcgJiYgZmxhZy5pbmNsdWRlcygnfCcpKSB7CiAgICAgICAgICAgIGxldCB0eXBlX25hbWUgPSBmbGFnLnNwbGl0KCd8JylbMF07CiAgICAgICAgICAgIGxldCBjdXJyZW50X3ZvZCA9IHJ1bGUuY2xhc3Nlcy5maW5kKGl0ZW0gPT4gaXRlbS50eXBlX25hbWUgPT09IHR5cGVfbmFtZSk7CiAgICAgICAgICAgIGlmIChjdXJyZW50X3ZvZCAmJiBjdXJyZW50X3ZvZC5wYXJzZV91cmwpIHsKICAgICAgICAgICAgICAgIHBhcnNlX3VybCA9IGN1cnJlbnRfdm9kLnBhcnNlX3VybAogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICgvXC4obTN1OHxtcDQpLy50ZXN0KGlucHV0KSkgewogICAgICAgICAgICBpbnB1dCA9IHtwYXJzZTogMCwgdXJsOiBpbnB1dH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZiAocGFyc2VfdXJsLnN0YXJ0c1dpdGgoJ2pzb246JykpIHsKICAgICAgICAgICAgICAgIGxldCBwdXJsID0gcGFyc2VfdXJsLnJlcGxhY2UoJ2pzb246JywgJycpICsgaW5wdXQ7CiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QocHVybCk7CiAgICAgICAgICAgICAgICBpbnB1dCA9IHtwYXJzZTogMCwgdXJsOiBKU09OLnBhcnNlKGh0bWwpLnVybH0KICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGlucHV0ID0gcGFyc2VfdXJsICsgaW5wdXQ7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9KSwKfQ== |