xiaomianao666

插件名:global_网盘直链下载助手

Jan 4th, 2024
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_网盘直链下载助手@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICAgICAgIOe9keebmOebtOmTvuS4i+i9veWKqeaJiwovLyBAbmFtZXNwYWNlICAgICAgICAgaHR0cHM6Ly9naXRodWIuY29tL3N5aHl6MTk5MC9iYWlkdXl1bgovLyBAdmVyc2lvbiAgICAgICAgICAgNi4xLjQKLy8gQGF1dGhvciAgICAgICAgICAgIEdyZWFzeUZvcmsKLy8gQGRlc2NyaXB0aW9uICAgICAgIPCfkYbwn5GG8J+RhvCfkYbwn5GG8J+RhvCfkYYgLSDmlK/mjIHmibnph4/ojrflj5Yg4pyF55m+5bqm572R55uYIOKchemYv+mHjOS6keebmCDinIXlpKnnv7zkupHnm5gg4pyF6L+F6Zu35LqR55uYIOKcheWkuOWFi+e9keebmCDinIXnp7vliqjkupHnm5gg5YWt5aSn572R55uY55qE55u06ZO+5LiL6L295Zyw5Z2A77yM6YWN5ZCIIElETe+8jFhkb3du77yMQXJpYTLvvIxDdXJs77yM5q+U54m55b2X5pif562J5bel5YW36auY5pWI8J+agPCfmoDwn5qA5LiL6L2977yM5a6M576O6YCC6YWNIENocm9tZe+8jEVkZ2XvvIxGaXJlRm9477yMMzYw77yMUVHvvIzmkJzni5fvvIznmb7liIbvvIzpgajmuLjvvIzmmJ/mhL/vvIxPcGVyYe+8jOeMjuixue+8jFZpdmFsZGnvvIxZYW5kZXjvvIxLaXdpIOetiSAxOCDnp43mtY/op4jlmajjgILlj6/lnKjml6Dms5Xlronoo4XlrqLmiLfnq6/nmoTnjq/looPkuIvkvb/nlKjvvIzliqnmiYvlhY3otLnlvIDmupDjgILwn5iOCi8vIEBsaWNlbnNlICAgICAgICAgICBBR1BMLTMuMC1vci1sYXRlcgovLyBAaG9tZXBhZ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B1cCcsCiAgICAgICAgaGVhZGVyOiAncGwtaGVhZGVyJywKICAgICAgICB0aXRsZTogJ3BsLXRpdGxlJywKICAgICAgICBjbG9zZUJ1dHRvbjogJ3BsLWNsb3NlJywKICAgICAgICBjb250ZW50OiAncGwtY29udGVudCcsCiAgICAgICAgaW5wdXQ6ICdwbC1pbnB1dCcsCiAgICAgICAgZm9vdGVyOiAncGwtZm9vdGVyJwogICAgfTsKCiAgICBjb25zdCB0ZXJtaW5hbFR5cGUgPSB7CiAgICAgICAgd2M6ICJXaW5kb3dzIENNRCIsCiAgICAgICAgd3A6ICJXaW5kb3dzIFBvd2VyU2hlbGwiLAogICAgICAgIGx0OiAiTGludXgg57uI56uvIiwKICAgICAgICBsczogIkxpbnV4IFNoZWxsIiwKICAgICAgICBtdDogIk1hY09TIOe7iOerryIsCiAgICB9OwoKICAgIGxldCB0b2FzdCA9IFN3YWwubWl4aW4oewogICAgICAgIHRvYXN0OiB0cnVlLAogICAgICAgIHBvc2l0aW9uOiAndG9wJywKICAgICAgICBzaG93Q29uZmlybUJ1dHRvbjogZmFsc2UsCiAgICAgICAgdGltZXI6IDM1MDAsCiAgICAgICAgdGltZXJQcm9ncmVzc0JhcjogZmFsc2UsCiAgICAgICAgZGlkT3BlbjogKHRvYXN0KSA9PiB7CiAgICAgICAgICAgIHRvYXN0LmFkZEV2ZW50TGlzdGVuZXIoJ21vdXNlZW50ZXInLCBTd2FsLnN0b3BUaW1lcik7CiAgICAgICAgICAgIHRvYXN0LmFkZEV2ZW50TGlzdGVuZXIoJ21vdXNlbGVhdmUnLCBTd2FsLnJlc3VtZVRpbWVyKTsKICAgICAgICB9CiAgICB9KTsKCiAgICBjb25zdCBtZXNzYWdlID0gewogICAgICAgIHN1Y2Nlc3M6ICh0ZXh0KSA9PiB7CiAgICAgICAgICAgIHRvYXN0LmZpcmUoe3RpdGxlOiB0ZXh0LCBpY29uOiAnc3VjY2Vzcyd9KTsKICAgICAgICB9LAogICAgICAgIGVycm9yOiAodGV4dCkgPT4gewogICAgICAgICAgICB0b2FzdC5maXJlKHt0aXRsZTogdGV4dCwgaWNvbjogJ2Vycm9yJ30pOwogICAgICAgIH0sCiAgICAgICAgd2FybmluZzogKHRleHQpID0+IHsKICAgICAgICAgICAgdG9hc3QuZmlyZSh7dGl0bGU6IHRleHQsIGljb246ICd3YXJuaW5nJ30pOwogICAgICAgIH0sCiAgICAgICAgaW5mbzogKHRleHQpID0+IHsKICAgICAgICAgICAgdG9hc3QuZmlyZSh7dGl0bGU6IHRleHQsIGljb246ICdpbmZvJ30pOwogICAgICAgIH0sCiAgICAgICAgcXVlc3Rpb246ICh0ZXh0KSA9PiB7CiAgICAgICAgICAgIHRvYXN0LmZpcmUoe3RpdGxlOiB0ZXh0LCBpY29uOiAncXVlc3Rpb24nfSk7CiAgICAgICAgfQogICAgfTsKCiAgICBsZXQgYmFzZSA9IHsKCiAgICAgICAgZ2V0Q29va2llKG5hbWUpIHsKICAgICAgICAgICAgbGV0IGNvb2tpZXMgPSBkb2N1bWVudC5jb29raWUuc3BsaXQoJzsnKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb29raWVzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBsZXQgY29va2llUGFpciA9IGNvb2tpZXNbaV0udHJpbSgpLnNwbGl0KCc9Jyk7CiAgICAgICAgICAgICAgICBpZiAoY29va2llUGFpci5sZW5ndGggPT09IDIpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgY29va2llTmFtZSA9IGNvb2tpZVBhaXJbMF07CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvb2tpZU5hbWUgPT09IG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvb2tpZVBhaXJbMV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiAnJzsKICAgICAgICB9LAoKICAgICAgICBpc1R5cGUob2JqKSB7CiAgICAgICAgICAgIHJldHVybiBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwob2JqKS5yZXBsYWNlKC9eXFtvYmplY3QgKC4rKVxdJC8sICckMScpLnRvTG93ZXJDYXNlKCk7CiAgICAgICAgfSwKCiAgICAgICAgZ2V0VmFsdWUobmFtZSkgewogICAgICAgICAgICByZXR1cm4gR01fZ2V0VmFsdWUobmFtZSk7CiAgICAgICAgfSwKCiAgICAgICAgc2V0VmFsdWUobmFtZSwgdmFsdWUpIHsKICAgICAgICAgICAgR01fc2V0VmFsdWUobmFtZSwgdmFsdWUpOwogICAgICAgIH0sCgogICAgICAgIGdldFN0b3JhZ2Uoa2V5KSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5wYXJzZShsb2NhbFN0b3JhZ2UuZ2V0SXRlbShrZXkpKTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuIGxvY2FsU3RvcmFnZS5nZXRJdGVtKGtleSk7CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBzZXRTdG9yYWdlKGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgaWYgKHRoaXMuaXNUeXBlKHZhbHVlKSA9PT0gJ29iamVjdCcgfHwgdGhpcy5pc1R5cGUodmFsdWUpID09PSAnYXJyYXknKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbG9jYWxTdG9yYWdlLnNldEl0ZW0oa2V5LCBKU09OLnN0cmluZ2lmeSh2YWx1ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBsb2NhbFN0b3JhZ2Uuc2V0SXRlbShrZXksIHZhbHVlKTsKICAgICAgICB9LAoKICAgICAgICBzZXRDbGlwYm9hcmQodGV4dCkgewogICAgICAgICAgICBHTV9zZXRDbGlwYm9hcmQodGV4dCwgJ3RleHQnKTsKICAgICAgICB9LAoKICAgICAgICBlKHN0cikgewogICAgICAgICAgICByZXR1cm4gYnRvYSh1bmVzY2FwZShlbmNvZGVVUklDb21wb25lbnQoc3RyKSkpOwogICAgICAgIH0sCgogICAgICAgIGQoc3RyKSB7CiAgICAgICAgICAgIHJldHVybiBkZWNvZGVVUklDb21wb25lbnQoZXNjYXBlKGF0b2Ioc3RyKSkpOwogICAgICAgIH0sCgogICAgICAgIGdldEV4dGVuc2lvbihuYW1lKSB7CiAgICAgICAgICAgIGNvbnN0IHJlZyA9IC8oPyFcLilcdyskLzsKICAgICAgICAgICAgaWYgKHJlZy50ZXN0KG5hbWUpKSB7CiAgICAgICAgICAgICAgICBsZXQgbWF0Y2ggPSBuYW1lLm1hdGNoKHJlZyk7CiAgICAgICAgICAgICAgICByZXR1cm4gbWF0Y2hbMF0udG9VcHBlckNhc2UoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gJyc7CiAgICAgICAgfSwKCiAgICAgICAgc2l6ZUZvcm1hdCh2YWx1ZSkgewogICAgICAgICAgICBpZiAodmFsdWUgPT09ICt2YWx1ZSkgewogICAgICAgICAgICAgICAgbGV0IHVuaXQgPSBbIkIiLCAiS0IiLCAiTUIiLCAiR0IiLCAiVEIiLCAiUEIiLCAiRUIiLCAiWkIiLCAiWUIiXTsKICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IE1hdGguZmxvb3IoTWF0aC5sb2codmFsdWUpIC8gTWF0aC5sb2coMTAyNCkpOwogICAgICAgICAgICAgICAgbGV0IHNpemUgPSB2YWx1ZSAvIE1hdGgucG93KDEwMjQsIGluZGV4KTsKICAgICAgICAgICAgICAgIHNpemUgPSBzaXplLnRvRml4ZWQoMSk7CiAgICAgICAgICAgICAgICByZXR1cm4gc2l6ZSArIHVuaXRbaW5kZXhdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiAnJzsKICAgICAgICB9LAoKICAgICAgICBzb3J0QnlOYW1lKGFycikgewogICAgICAgICAgICBjb25zdCBoYW5kbGUgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICByZXR1cm4gKGEsIGIpID0+IHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwMSA9IGEuZmlsZW5hbWUgPyBhLmZpbGVuYW1lIDogYS5zZXJ2ZXJfZmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIgPSBiLmZpbGVuYW1lID8gYi5maWxlbmFtZSA6IGIuc2VydmVyX2ZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBwMS5sb2NhbGVDb21wYXJlKHAyLCAiemgtQ04iKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgIH07CiAgICAgICAgICAgIGFyci5zb3J0KGhhbmRsZSgpKTsKICAgICAgICB9LAoKICAgICAgICBmaXhGaWxlbmFtZShuYW1lKSB7CiAgICAgICAgICAgIHJldHVybiBuYW1lLnJlcGxhY2UoL1shPyZ8YCInKlwvOjw+XFxdL2csICdfJyk7CiAgICAgICAgfSwKCiAgICAgICAgYmxvYkRvd25sb2FkKGJsb2IsIGZpbGVuYW1lKSB7CiAgICAgICAgICAgIGlmIChibG9iIGluc3RhbmNlb2YgQmxvYikgewogICAgICAgICAgICAgICAgY29uc3QgdXJsID0gVVJMLmNyZWF0ZU9iamVjdFVSTChibG9iKTsKICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdhJyk7CiAgICAgICAgICAgICAgICBhLmhyZWYgPSB1cmw7CiAgICAgICAgICAgICAgICBhLmRvd25sb2FkID0gZmlsZW5hbWU7CiAgICAgICAgICAgICAgICBhLmNsaWNrKCk7CiAgICAgICAgICAgICAgICBVUkwucmV2b2tlT2JqZWN0VVJMKHVybCk7CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBwb3N0KHVybCwgZGF0YSwgaGVhZGVycywgdHlwZSkgewogICAgICAgICAgICBpZiAodGhpcy5pc1R5cGUoZGF0YSkgPT09ICdvYmplY3QnKSB7CiAgICAgICAgICAgICAgICBkYXRhID0gSlNPTi5zdHJpbmdpZnkoZGF0YSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHsKICAgICAgICAgICAgICAgIEdNX3htbGh0dHBSZXF1ZXN0KHsKICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICJQT1NUIiwgdXJsLCBoZWFkZXJzLCBkYXRhLAogICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlVHlwZTogdHlwZSB8fCAnanNvbicsCiAgICAgICAgICAgICAgICAgICAgb25sb2FkOiAocmVzKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPT09ICdibG9iJyA/IHJlc29sdmUocmVzKSA6IHJlc29sdmUocmVzLnJlc3BvbnNlIHx8IHJlcy5yZXNwb25zZVRleHQpOwogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgb25lcnJvcjogKGVycikgPT4gewogICAgICAgICAgICAgICAgICAgICAgICByZWplY3QoZXJyKTsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIGdldCh1cmwsIGhlYWRlcnMsIHR5cGUsIGV4dHJhKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgcmVxdWVzdE9iaiA9IEdNX3htbGh0dHBSZXF1ZXN0KHsKICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICJHRVQiLCB1cmwsIGhlYWRlcnMsCiAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VUeXBlOiB0eXBlIHx8ICdqc29uJywKICAgICAgICAgICAgICAgICAgICBvbmxvYWQ6IChyZXMpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcy5zdGF0dXMgPT09IDIwNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdE9iai5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRtW2V4dHJhLmluZGV4XSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGUgPT09ICdibG9iJykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzLnN0YXR1cyA9PT0gMjAwICYmIGJhc2UuYmxvYkRvd25sb2FkKHJlcy5yZXNwb25zZSwgZXh0cmEuZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShyZXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShyZXMucmVzcG9uc2UgfHwgcmVzLnJlc3BvbnNlVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIG9ucHJvZ3Jlc3M6IChyZXMpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV4dHJhICYmIGV4dHJhLmZpbGVuYW1lICYmIGV4dHJhLmluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXMudG90YWwgPiAwID8gcHJvZ3Jlc3NbZXh0cmEuaW5kZXhdID0gKHJlcy5sb2FkZWQgKiAxMDAgLyByZXMudG90YWwpLnRvRml4ZWQoMikgOiBwcm9ncmVzc1tleHRyYS5pbmRleF0gPSAwLjAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICBvbmxvYWRzdGFydCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmEgJiYgZXh0cmEuZmlsZW5hbWUgJiYgZXh0cmEuaW5kZXggJiYgKHJlcXVlc3RbZXh0cmEuaW5kZXhdID0gcmVxdWVzdE9iaik7CiAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICBvbmVycm9yOiAoZXJyKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChlcnIpOwogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwKCiAgICAgICAgZ2V0RmluYWxVcmwodXJsLCBoZWFkZXJzKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgcmVxdWVzdE9iaiA9IEdNX3htbGh0dHBSZXF1ZXN0KHsKICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICJHRVQiLCB1cmwsIGhlYWRlcnMsCiAgICAgICAgICAgICAgICAgICAgb25sb2FkOiAocmVzKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUocmVzLmZpbmFsVXJsKTsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIG9uZXJyb3I6IChlcnIpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KGVycik7CiAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9KTsKICAgICAgICB9LAoKICAgICAgICBzdHJpbmdpZnkob2JqKSB7CiAgICAgICAgICAgIGxldCBzdHIgPSAnJzsKICAgICAgICAgICAgZm9yICh2YXIga2V5IGluIG9iaikgewogICAgICAgICAgICAgICAgaWYgKG9iai5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gb2JqW2tleV07CiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgdmFsdWUubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ciArPSBlbmNvZGVVUklDb21wb25lbnQoa2V5KSArICc9JyArIGVuY29kZVVSSUNvbXBvbmVudCh2YWx1ZVtpXSkgKyAnJic7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBzdHIgKz0gZW5jb2RlVVJJQ29tcG9uZW50KGtleSkgKyAnPScgKyBlbmNvZGVVUklDb21wb25lbnQodmFsdWUpICsgJyYnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gc3RyLnNsaWNlKDAsIC0xKTsgLy8g5Y675o6J5pyr5bC+55qEICImIgogICAgICAgIH0sCgogICAgICAgIGFkZFN0eWxlKGlkLCB0YWcsIGNzcykgewogICAgICAgICAgICB0YWcgPSB0YWcgfHwgJ3N0eWxlJzsKICAgICAgICAgICAgbGV0IGRvYyA9IGRvY3VtZW50LCBzdHlsZURvbSA9IGRvYy5nZXRFbGVtZW50QnlJZChpZCk7CiAgICAgICAgICAgIGlmIChzdHlsZURvbSkgcmV0dXJuOwogICAgICAgICAgICBsZXQgc3R5bGUgPSBkb2MuY3JlYXRlRWxlbWVudCh0YWcpOwogICAgICAgICAgICBzdHlsZS5yZWwgPSAnc3R5bGVzaGVldCc7CiAgICAgICAgICAgIHN0eWxlLmlkID0gaWQ7CiAgICAgICAgICAgIHRhZyA9PT0gJ3N0eWxlJyA/IHN0eWxlLmlubmVySFRNTCA9IGNzcyA6IHN0eWxlLmhyZWYgPSBjc3M7CiAgICAgICAgICAgIGRvYy5nZXRFbGVtZW50c0J5VGFnTmFtZSgnaGVhZCcpWzBdLmFwcGVuZENoaWxkKHN0eWxlKTsKICAgICAgICB9LAoKICAgICAgICBzbGVlcCh0aW1lKSB7CiAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHNldFRpbWVvdXQocmVzb2x2ZSwgdGltZSkpOwogICAgICAgIH0sCgogICAgICAgIGZpbmRSZWFjdChkb20sIHRyYXZlcnNlVXAgPSAwKSB7CiAgICAgICAgICAgIGNvbnN0IGtleSA9IE9iamVjdC5rZXlzKGRvbSkuZmluZChrZXkgPT4gewogICAgICAgICAgICAgICAgcmV0dXJuIGtleS5zdGFydHNXaXRoKCJfX3JlYWN0RmliZXIkIikKICAgICAgICAgICAgICAgICAgICB8fCBrZXkuc3RhcnRzV2l0aCgiX19yZWFjdEludGVybmFsSW5zdGFuY2UkIik7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBjb25zdCBkb21GaWJlciA9IGRvbVtrZXldOwogICAgICAgICAgICBpZiAoZG9tRmliZXIgPT0gbnVsbCkgcmV0dXJuIG51bGw7CgogICAgICAgICAgICBpZiAoZG9tRmliZXIuX2N1cnJlbnRFbGVtZW50KSB7CiAgICAgICAgICAgICAgICBsZXQgY29tcEZpYmVyID0gZG9tRmliZXIuX2N1cnJlbnRFbGVtZW50Ll9vd25lcjsKICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdHJhdmVyc2VVcDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgY29tcEZpYmVyID0gY29tcEZpYmVyLl9jdXJyZW50RWxlbWVudC5fb3duZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gY29tcEZpYmVyLl9pbnN0YW5jZTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgY29uc3QgR2V0Q29tcEZpYmVyID0gZmliZXIgPT4gewogICAgICAgICAgICAgICAgbGV0IHBhcmVudEZpYmVyID0gZmliZXIucmV0dXJuOwogICAgICAgICAgICAgICAgd2hpbGUgKHR5cGVvZiBwYXJlbnRGaWJlci50eXBlID09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgcGFyZW50RmliZXIgPSBwYXJlbnRGaWJlci5yZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gcGFyZW50RmliZXI7CiAgICAgICAgICAgIH07CiAgICAgICAgICAgIGxldCBjb21wRmliZXIgPSBHZXRDb21wRmliZXIoZG9tRmliZXIpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRyYXZlcnNlVXA7IGkrKykgewogICAgICAgICAgICAgICAgY29tcEZpYmVyID0gR2V0Q29tcEZpYmVyKGNvbXBGaWJlcik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGNvbXBGaWJlci5zdGF0ZU5vZGUgfHwgY29tcEZpYmVyOwogICAgICAgIH0sCgogICAgICAgIGluaXREZWZhdWx0Q29uZmlnKCkgewogICAgICAgICAgICBsZXQgdmFsdWUgPSBbewogICAgICAgICAgICAgICAgbmFtZTogJ3NldHRpbmdfcnBjX2RvbWFpbicsCiAgICAgICAgICAgICAgICB2YWx1ZTogJ2h0dHA6Ly9sb2NhbGhvc3QnCiAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIG5hbWU6ICdzZXR0aW5nX3JwY19wb3J0JywKICAgICAgICAgICAgICAgIHZhbHVlOiAnMTY4MDAnCiAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIG5hbWU6ICdzZXR0aW5nX3JwY19wYXRoJywKICAgICAgICAgICAgICAgIHZhbHVlOiAnL2pzb25ycGMnCiAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIG5hbWU6ICdzZXR0aW5nX3JwY190b2tlbicsCiAgICAgICAgICAgICAgICB2YWx1ZTogJycKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgbmFtZTogJ3NldHRpbmdfcnBjX2RpcicsCiAgICAgICAgICAgICAgICB2YWx1ZTogJ0Q6JwogICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICBuYW1lOiAnc2V0dGluZ190ZXJtaW5hbF90eXBlJywKICAgICAgICAgICAgICAgIHZhbHVlOiAnd2MnCiAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgIG5hbWU6ICdzZXR0aW5nX3RoZW1lX2NvbG9yJywKICAgICAgICAgICAgICAgIHZhbHVlOiAnIzA5QUFGRicKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgbmFtZTogJ3NldHRpbmdfaW5pdF9jb2RlJywKICAgICAgICAgICAgICAgIHZhbHVlOiAnJwogICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICBuYW1lOiAnbGljZW5zZScsCiAgICAgICAgICAgICAgICB2YWx1ZTogJycKICAgICAgICAgICAgfV07CgogICAgICAgICAgICB2YWx1ZS5mb3JFYWNoKCh2KSA9PiB7CiAgICAgICAgICAgICAgICBiYXNlLmdldFZhbHVlKHYubmFtZSkgPT09IHVuZGVmaW5lZCAmJiBiYXNlLnNldFZhbHVlKHYubmFtZSwgdi52YWx1ZSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIHNob3dTZXR0aW5nKCkgewogICAgICAgICAgICBsZXQgZG9tID0gJycsIGJ0biA9ICcnLAogICAgICAgICAgICAgICAgY29sb3JMaXN0ID0gWycjMDlBQUZGJywgJyNjYzMyMzUnLCAnIzUyNmVmYScsICcjNTE4YzE3JywgJyNlZDk0NGInLCAnI2Y5NjlhNScsICcjYmNhMjgwJ107CiAgICAgICAgICAgIGRvbSArPSBgPGxhYmVsIGNsYXNzPSJwbC1zZXR0aW5nLWxhYmVsIj48ZGl2IGNsYXNzPSJwbC1sYWJlbCI+UlBD5Li75py6PC9kaXY+PGlucHV0IHR5cGU9InRleHQiICBwbGFjZWhvbGRlcj0i5Li75py65Zyw5Z2A77yM6ZyA5bim5LiKaHR0cChzKTovLyIgY2xhc3M9InBsLWlucHV0IGxpc3RlbmVyLWRvbWFpbiIgdmFsdWU9IiR7YmFzZS5nZXRWYWx1ZSgnc2V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vc2VsZWN0PjwvbGFiZWw+YDsKICAgICAgICAgICAgZG9tICs9IGA8bGFiZWwgY2xhc3M9InBsLXNldHRpbmctbGFiZWwiPjxkaXYgY2xhc3M9InBsLWxhYmVsIj7kuLvpopjpopzoibI8L2Rpdj4gPGRpdiBjbGFzcz0icGwtY29sb3IiPiR7YnRufTxkaXY+PC9sYWJlbD5gOwogICAgICAgICAgICBkb20gPSAnPGRpdj4nICsgZG9tICsgJzwvZGl2Pic7CgogICAgICAgICAgICBTd2FsLmZpcmUoewogICAgICAgICAgICAgICAgdGl0bGU6ICfliqnmiYvphY3nva4nLAogICAgICAgICAgICAgICAgaHRtbDogZG9tLAogICAgICAgICAgICAgICAgaWNvbjogJ2luZm8nLAogICAgICAgICAgICAgICAgc2hvd0Nsb3NlQnV0dG9uOiB0cnVlLAogICAgICAgICAgICAgICAgc2hvd0NvbmZpcm1CdXR0b246IGZhbHNlLAogICAgICAgICAgICAgICAgZm9vdGVyOiBwYW4uZm9vdGVyLAogICAgICAgICAgICB9KS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgIG1lc3NhZ2Uuc3VjY2Vzcygn6K6+572u5oiQ5Yqf77yBJyk7CiAgICAgICAgICAgICAgICBoaXN0b3J5LmdvKDApOwogICAgICAgICAgICB9KTsKCiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWNvbG9yJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0VmFsdWUoJ3NldHRpbmdfdGhlbWVfY29sb3InLCBlLnRhcmdldC5kYXRhc2V0LmNvbG9yKTsKICAgICAgICAgICAgICAgIG1lc3NhZ2Uuc3VjY2Vzcygn6K6+572u5oiQ5Yqf77yBJyk7CiAgICAgICAgICAgICAgICBoaXN0b3J5LmdvKDApOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdpbnB1dCcsICcubGlzdGVuZXItZG9tYWluJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0VmFsdWUoJ3NldHRpbmdfcnBjX2RvbWFpbicsIGUudGFyZ2V0LnZhbHVlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignaW5wdXQnLCAnLmxpc3RlbmVyLXBvcnQnLCBhc3luYyAoZSkgPT4gewogICAgICAgICAgICAgICAgYmFzZS5zZXRWYWx1ZSgnc2V0dGluZ19ycGNfcG9ydCcsIGUudGFyZ2V0LnZhbHVlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignaW5wdXQnLCAnLmxpc3RlbmVyLXBhdGgnLCBhc3luYyAoZSkgPT4gewogICAgICAgICAgICAgICAgYmFzZS5zZXRWYWx1ZSgnc2V0dGluZ19ycGNfcGF0aCcsIGUudGFyZ2V0LnZhbHVlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignaW5wdXQnLCAnLmxpc3RlbmVyLXRva2VuJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0VmFsdWUoJ3NldHRpbmdfcnBjX3Rva2VuJywgZS50YXJnZXQudmFsdWUpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdpbnB1dCcsICcubGlzdGVuZXItZGlyJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0VmFsdWUoJ3NldHRpbmdfcnBjX2RpcicsIGUudGFyZ2V0LnZhbHVlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2hhbmdlJywgJy5saXN0ZW5lci10ZXJtaW5hbCcsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBiYXNlLnNldFZhbHVlKCdzZXR0aW5nX3Rlcm1pbmFsX3R5cGUnLCBlLnRhcmdldC52YWx1ZSk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIHJlZ2lzdGVyTWVudUNvbW1hbmQoKSB7CiAgICAgICAgICAgIEdNX3JlZ2lzdGVyTWVudUNvbW1hbmQoJ+Kame+4jyDorr7nva4nLCAoKSA9PiB7CiAgICAgICAgICAgICAgICB0aGlzLnNob3dTZXR0aW5nKCk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIGNyZWF0ZVRpcCgpIHsKICAgICAgICAgICAgJCgnYm9keScpLmFwcGVuZCgnPGRpdiBjbGFzcz0icGwtdG9vbHRpcCI+PC9kaXY+Jyk7CgogICAgICAgICAgICBkb2Mub24oJ21vdXNlZW50ZXIgbW91c2VsZWF2ZScsICcubGlzdGVuZXItdGlwJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIGlmIChlLnR5cGUgPT09ICdtb3VzZWVudGVyJykgewogICAgICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9IGUuY3VycmVudFRhcmdldC5pbm5lclRleHQ7CiAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBlLmN1cnJlbnRUYXJnZXQuZGF0YXNldC5zaXplOwogICAgICAgICAgICAgICAgICAgIGxldCB0aXAgPSBgJHtmaWxlbmFtZX08c3BhbiBzdHlsZT0ibWFyZ2luLWxlZnQ6IDEwcHg7Y29sb3I6ICNmNTZjNmM7Ij4ke3NpemV9PC9zcGFuPmA7CiAgICAgICAgICAgICAgICAgICAgJChlLmN1cnJlbnRUYXJnZXQpLmNzcyh7b3BhY2l0eTogJzAuNSd9KTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtdG9vbHRpcCcpLmh0bWwodGlwKS5jc3MoewogICAgICAgICAgICAgICAgICAgICAgICAnbGVmdCc6IGUucGFnZVggKyAxMCArICdweCcsCiAgICAgICAgICAgICAgICAgICAgICAgICd0b3AnOiBlLnBhZ2VZIC0gZS5jdXJyZW50VGFyZ2V0Lm9mZnNldFRvcCA+IDE0ID8gZS5wYWdlWSArICdweCcgOiBlLnBhZ2VZICsgMjAgKyAncHgnCiAgICAgICAgICAgICAgICAgICAgfSkuc2hvdygpOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAkKGUuY3VycmVudFRhcmdldCkuY3NzKHtvcGFjaXR5OiAnMSd9KTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtdG9vbHRpcCcpLmhpZGUoMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIGNyZWF0ZUxvYWRpbmcoKSB7CiAgICAgICAgICAgIHJldHVybiAkKCc8ZGl2IGNsYXNzPSJwbC1sb2FkaW5nIj48ZGl2IGNsYXNzPSJwbC1sb2FkaW5nLWJveCI+PGRpdj48ZGl2PjwvZGl2PjxkaXY+PC9kaXY+PC9kaXY+PC9kaXY+PC9kaXY+Jyk7CiAgICAgICAgfSwKCiAgICAgICAgY3JlYXRlRG93bmxvYWRJZnJhbWUoKSB7CiAgICAgICAgICAgIGxldCAkZGl2ID0gJCgnPGRpdiBzdHlsZT0icGFkZGluZzowO21hcmdpbjowO2Rpc3BsYXk6YmxvY2siPjwvZGl2PicpOwogICAgICAgICAgICBsZXQgJGlmcmFtZSA9ICQoJzxpZnJhbWUgc3JjPSJqYXZhc2NyaXB0OjsiIGlkPSJkb3dubG9hZElmcmFtZSIgc3R5bGU9ImRpc3BsYXk6bm9uZSI+PC9pZnJhbWU+Jyk7CiAgICAgICAgICAgICRkaXYuYXBwZW5kKCRpZnJhbWUpOwogICAgICAgICAgICAkKCdib2R5JykuYXBwZW5kKCRkaXYpOwogICAgICAgIH0sCgogICAgICAgIGdldE1pcnJvckxpc3QobGluaywgbWlycm9yLCB0aHJlYWQgPSAyKSB7CiAgICAgICAgICAgIGxldCBob3N0ID0gbmV3IFVSTChsaW5rKS5ob3N0OwogICAgICAgICAgICBsZXQgbWlycm9ycyA9IFtdOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG1pcnJvci5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB0aHJlYWQ7IGorKykgewogICAgICAgICAgICAgICAgICAgIGxldCBpdGVtID0gbGluay5yZXBsYWNlKGhvc3QsIG1pcnJvcltpXSkgKyAnJicucmVwZWF0KGopOwogICAgICAgICAgICAgICAgICAgIG1pcnJvcnMucHVzaChpdGVtKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gbWlycm9ycy5qb2luKCdcbicpOwogICAgICAgIH0sCgogICAgICAgIGxpc3RlbkVsZW1lbnQoZWxlbWVudCwgY2FsbGJhY2spIHsKICAgICAgICAgICAgY29uc3QgY2hlY2tJbnRlcnZhbCA9IDUwMDsgLy8g5qOA5p+l5YWD57Sg55qE6Ze06ZqU5pe26Ze077yI5q+r56eS77yJCiAgICAgICAgICAgIGxldCB3YXNFbGVtZW50Rm91bmQgPSBmYWxzZTsgLy8g55So5LqO6Lef6Liq5YWD57Sg5piv5ZCm5LmL5YmN5bey57uP5om+5YiwCgogICAgICAgICAgICBmdW5jdGlvbiBjaGVja0VsZW1lbnQoKSB7CiAgICAgICAgICAgICAgICBpZiAoZG9jdW1lbnQucXVlcnlTZWxlY3RvcihlbGVtZW50KSkgewogICAgICAgICAgICAgICAgICAgIHdhc0VsZW1lbnRGb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAod2FzRWxlbWVudEZvdW5kKSB7CiAgICAgICAgICAgICAgICAgICAgd2FzRWxlbWVudEZvdW5kID0gZmFsc2U7IC8vIOWFg+e0oOa2iOWkseWQjumHjee9ruagh+W/lwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoY2hlY2tFbGVtZW50LCBjaGVja0ludGVydmFsKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgY2hlY2tFbGVtZW50KCk7CiAgICAgICAgfSwKCiAgICAg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gpID0+IHsKICAgICAgICAgICAgICAgICAgICBoaXN0b3J5LmdvKDApOwogICAgICAgICAgICAgICAgfSwgMTUwMCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBhd2FpdCBTd2FsLmZpcmUoewogICAgICAgICAgICAgICAgICAgIHRpdGxlOiBwYW4uaW5pdFszXSwKICAgICAgICAgICAgICAgICAgICB0ZXh0OiBwYW4uaW5pdFs0XSwKICAgICAgICAgICAgICAgICAgICBjb25maXJtQnV0dG9uVGV4dDogJ+mHjeaWsOi+k+WFpScsCiAgICAgICAgICAgICAgICAgICAgaW1hZ2VVcmw6IHBhbi5pbWcsCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGF3YWl0IHRoaXMuaW5pdERpYWxvZygpOwogICAgICAgICAgICB9CiAgICAgICAgfSwKICAgIH07CgogICAgbGV0IGJhaWR1ID0gewoKICAgICAgICBfZ2V0RXh0cmEoKSB7CiAgICAgICAgICAgIGxldCBzZUtleSA9IGRlY29kZVVSSUNvbXBvbmVudChiYXNlLmdldENvb2tpZSgnQkRDTE5EJykpOwogICAgICAgICAgICByZXR1cm4gJ3snICsgJyJzZWtleSI6IicgKyBzZUtleSArICciJyArICJ9IjsKICAgICAgICB9LAoKICAgICAgICBfZ2V0U3VybCgpIHsKICAgICAgICAgICAgbGV0IHJlZyA9IC8oPzw9c1wvfHN1cmw9KShbYS16QS1aMC05Xy1dKykvZzsKICAgICAgICAgICAgaWYgKHJlZy50ZXN0KGxvY2F0aW9uLmhyZWYpKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbG9jYXRpb24uaHJlZi5tYXRjaChyZWcpWzBdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiAnJzsKICAgICAgICB9LAoKICAgICAgICBfZ2V0RmlkTGlzdCgpIHsKICAgICAgICAgICAgbGV0IGZpZGxpc3QgPSBbXTsKICAgICAgICAgICAgc2VsZWN0TGlzdC5mb3JFYWNoKHYgPT4gewogICAgICAgICAgICAgICAgaWYgKCt2LmlzZGlyID09PSAxKSByZXR1cm47CiAgICAgICAgICAgICAgICBmaWRsaXN0LnB1c2godi5mc19pZCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gJ1snICsgZmlkbGlzdCArICddJzsKICAgICAgICB9LAoKICAgICAgICBfcmVzZXREYXRhKCkgewogICAgICAgICAgICBwcm9ncmVzcyA9IHt9OwogICAgICAgICAgICAkLmVhY2gocmVxdWVzdCwgKGtleSkgPT4gewogICAgICAgICAgICAgICAgKHJlcXVlc3Rba2V5XSkuYWJvcnQoKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICQuZWFjaChpbnMsIChrZXkpID0+IHsKICAgICAgICAgICAgICAgIGNsZWFySW50ZXJ2YWwoaW5zW2tleV0pOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgaWRtID0ge307CiAgICAgICAgICAgIGlucyA9IHt9OwogICAgICAgICAgICByZXF1ZXN0ID0ge307CiAgICAgICAgfSwKCiAgICAgICAgc2V0QkRVU1MoKSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBHTV9jb29raWUgJiYgR01fY29va2llKCdsaXN0Jywge25hbWU6ICdCRFVTUyd9LCAoY29va2llcywgZXJyb3IpID0+IHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJhc2Uuc2V0U3RvcmFnZSgiYmFpZHV5dW5QbHVnaW5fQkRVU1MiLCB7QkRVU1M6IGNvb2tpZXNbMF0udmFsdWV9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICB9CiAgICAgICAgfSwKCiAgICAgICAgZ2V0QkRVU1MoKSB7CiAgICAgICAgICAgIGxldCBiYWlkdXl1blBsdWdpbl9CRFVTUyA9IGJhc2UuZ2V0U3RvcmFnZSgnYmFpZHV5dW5QbHVnaW5fQkRVU1MnKSA/IGJhc2UuZ2V0U3RvcmFnZSgnYmFpZHV5dW5QbHVnaW5fQkRVU1MnKSA6ICd7ImJhaWR1eXVuUGx1Z2luX0JEVVNTIjoiIn0nOwogICAgICAgICAgICByZXR1cm4gYmFpZHV5dW5QbHVnaW5fQkRVU1MuQkRVU1MgfHwgJyc7CiAgICAgICAgfSwKCiAgICAgICAgY29udmVydExpbmtUb0FyaWEobGluaywgZmlsZW5hbWUsIHVhKSB7CiAgICAgICAgICAgIGxldCBCRFVTUyA9IHRoaXMuZ2V0QkRVU1MoKTsKICAgICAgICAgICAgaWYgKCEhQkRVU1MpIHsKICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gYmFzZS5maXhGaWxlbmFtZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICByZXR1cm4gZW5jb2RlVVJJQ29tcG9uZW50KGBhcmlhMmMgIiR7bGlua30iIC0tb3V0ICIke2ZpbGVuYW1lfSIgLS1oZWFkZXIgIlVzZXItQWdlbnQ6ICR7dWF9IiAtLWhlYWRlciAiQ29va2llOiBCRFVTUz0ke0JEVVNTfSJgKTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgbGluazogcGFuLmFzc2lzdGFudCwKICAgICAgICAgICAgICAgIHRleHQ6IHBhbi5pbml0WzVdCiAgICAgICAgICAgIH07CiAgICAgICAgfSwKCiAgICAgICAgY29udmVydExpbmtUb0JDKGxpbmssIGZpbGVuYW1lLCB1YSkgewogICAgICAgICAgICBsZXQgQkRVU1MgPSB0aGlzLmdldEJEVVNTKCk7CiAgICAgICAgICAgIGlmICghIUJEVVNTKSB7CiAgICAgICAgICAgICAgICBsZXQgY29va2llID0gYEJEVVNTPSR7QkRVU1N9YDsKICAgICAgICAgICAgICAgIGxldCBiYyA9IGBBQS8ke2VuY29kZVVSSUNvbXBvbmVudChmaWxlbmFtZSl9Lz91cmw9JHtlbmNvZGVVUklDb21wb25lbnQobGluayl9JmNvb2tpZT0ke2VuY29kZVVSSUNvbXBvbmVudChjb29raWUpfSZ1c2VyX2FnZW50PSR7ZW5jb2RlVVJJQ29tcG9uZW50KHVhKX1aWmA7CiAgICAgICAgICAgICAgICByZXR1cm4gZW5jb2RlVVJJQ29tcG9uZW50KGBiYzovL2h0dHAvJHtiYXNlLmUoYmMpfWApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICBsaW5rOiBwYW4uYXNzaXN0YW50LAogICAgICAgICAgICAgICAgdGV4dDogcGFuLmluaXRbNV0KICAgICAgICAgICAgfTsKICAgICAgICB9LAoKICAgICAgICBjb252ZXJ0TGlua1RvQ3VybChsaW5rLCBmaWxlbmFtZSwgdWEpIHsKICAgICAgICAgICAgbGV0IEJEVVNTID0gdGhpcy5nZXRCRFVTUygpOwogICAgICAgICAgICBpZiAoISFCRFVTUykgewogICAgICAgICAgICAgICAgbGV0IHRlcm1pbmFsID0gYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ190ZXJtaW5hbF90eXBlJyk7CiAgICAgICAgICAgICAgICBmaWxlbmFtZSA9IGJhc2UuZml4RmlsZW5hbWUoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgcmV0dXJuIGVuY29kZVVSSUNvbXBvbmVudChgJHt0ZXJtaW5hbCAhPT0gJ3dwJyA/ICdjdXJsJyA6ICdjdXJsLmV4ZSd9IC1MIC1DIC0gIiR7bGlua30iIC1vICIke2ZpbGVuYW1lfSIgLUEgIiR7dWF9IiAtYiAiQkRVU1M9JHtCRFVTU30iYCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIGxpbms6IHBhbi5hc3Npc3RhbnQsCiAgICAgICAgICAgICAgICB0ZXh0OiBwYW4uaW5pdFs1XQogICAgICAgICAgICB9OwogICAgICAgIH0sCgogICAgICAgIGFkZFBhZ2VMaXN0ZW5lcigpIHsKICAgICAgICAgICAgZnVuY3Rpb24gX2ZhY3RvcnkoZSkgewogICAgICAgICAgICAgICAgbGV0IHRhcmdldCA9ICQoZS50YXJnZXQpOwogICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSB0YXJnZXQucGFyZW50cygnLnBsLWl0ZW0nKTsKICAgICAgICAgICAgICAgIGxldCBsaW5rID0gaXRlbS5maW5kKCcucGwtaXRlbS1saW5rJyk7CiAgICAgICAgICAgICAgICBsZXQgcHJvZ3Jlc3MgPSBpdGVtLmZpbmQoJy5wbC1pdGVtLXByb2dyZXNzJyk7CiAgICAgICAgICAgICAgICBsZXQgdGlwID0gaXRlbS5maW5kKCcucGwtaXRlbS10aXAnKTsKICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgaXRlbSwgbGluaywgcHJvZ3Jlc3MsIHRpcCwgdGFyZ2V0LAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgZnVuY3Rpb24gX3Jlc2V0KGkpIHsKICAgICAgICAgICAgICAgIGluc1tpXSAmJiBjbGVhckludGVydmFsKGluc1tpXSk7CiAgICAgICAgICAgICAgICByZXF1ZXN0W2ldICYmIHJlcXVlc3RbaV0uYWJvcnQoKTsKICAgICAgICAgICAgICAgIHByb2dyZXNzW2ldID0gMDsKICAgICAgICAgICAgICAgIGlkbVtpXSA9IGZhbHNlOwogICAgICAgICAgICB9CgogICAgICAgICAgICBkb2Mub24oJ21vdXNlZW50ZXIgbW91c2VsZWF2ZSBjbGljaycsICcucGwtYnV0dG9uLmctZHJvcGRvd24tYnV0dG9uJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIGlmIChlLnR5cGUgPT09ICdtb3VzZWxlYXZlJykgewogICAgICAgICAgICAgICAgICAgICQoZS5jdXJyZW50VGFyZ2V0KS5yZW1vdmVDbGFzcygnYnV0dG9uLW9wZW4nKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgJChlLmN1cnJlbnRUYXJnZXQpLmFkZENsYXNzKCdidXR0b24tb3BlbicpOwogICAgICAgICAgICAgICAgICAgICQoZS5jdXJyZW50VGFyZ2V0KS5maW5kKCcucGwtZHJvcGRvd24tbWVudScpLnNob3coKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignbW91c2VsZWF2ZScsICcucGwtYnV0dG9uLmctZHJvcGRvd24tYnV0dG9uIC5wbC1kcm9wZG93bi1tZW51JywgKGUpID0+IHsKICAgICAgICAgICAgICAgICQoZS5jdXJyZW50VGFyZ2V0KS5oaWRlKCk7CiAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcucGwtYnV0dG9uLW1vZGUnLCAoZSkgPT4gewogICAgICAgICAgICAgICAgbW9kZSA9IGUudGFyZ2V0LmRhdGFzZXQubW9kZTsKICAgICAgICAgICAgICAgIFN3YWwuc2hvd0xvYWRpbmcoKTsKICAgICAgICAgICAgICAgIHRoaXMuZ2V0UENTTGluaygpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItbGluay1hcGknLCBhc3luYyAoZSkgPT4gewogICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgbGV0IG8gPSBfZmFjdG9yeShlKTsKICAgICAgICAgICAgICAgIGxldCAkd2lkdGggPSBvLml0ZW0uZmluZCgnLnBsLXByb2dyZXNzLWlubmVyJyk7CiAgICAgICAgICAgICAgICBsZXQgJHRleHQgPSBvLml0ZW0uZmluZCgnLnBsLXByb2dyZXNzLWlubmVyLXRleHQnKTsKICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9IG8ubGlua1swXS5kYXRhc2V0LmZpbGVuYW1lOwogICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5saW5rWzBdLmRhdGFzZXQuaW5kZXg7CiAgICAgICAgICAgICAgICBfcmVzZXQoaW5kZXgpOwogICAgICAgICAgICAgICAgYmFzZS5nZXQoby5saW5rWzBdLmRhdGFzZXQubGluaywgeyJVc2VyLUFnZW50IjogcGFuLnVhfSwgJ2Jsb2InLCB7ZmlsZW5hbWUsIGluZGV4fSk7CiAgICAgICAgICAgICAgICBpbnNbaW5kZXhdID0gc2V0SW50ZXJ2YWwoKCkgPT4gewogICAgICAgICAgICAgICAgICAgIGxldCBwcm9nID0gK3Byb2dyZXNzW2luZGV4XSB8fCAwOwogICAgICAgICAgICAgICAgICAgIGxldCBpc0lETSA9IGlkbVtpbmRleF0gfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzSURNKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG8udGlwLmhpZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgby5wcm9ncmVzcy5oaWRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIG8ubGluay50ZXh0KCflt7LmiJDlip/llKTotbdJRE3vvIzor7fmn6XnnItJRE3kuIvovb3moYbvvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iikuc2hvdygpOwogICAgICAgICAgICAgICAgICAgICAgICBjbGVhckludGVydmFsKGluc1tpbmRleF0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZG1baW5kZXhdID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgby5saW5rLmhpZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgby50aXAuaGlkZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBvLnByb2dyZXNzLnNob3coKTsKICAgICAgICAgICAgICAgICAgICAgICAgJHdpZHRoLmNzcygnd2lkdGgnLCBwcm9nICsgJyUnKTsKICAgICAgICAgICAgICAgICAgICAgICAgJHRleHQudGV4dChwcm9nICsgJyUnKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByb2cgPT09IDEwMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJJbnRlcnZhbChpbnNbaW5kZXhdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzW2luZGV4XSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvLml0ZW0uZmluZCgnLnBsLXByb2dyZXNzLXN0b3AnKS5oaWRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvLml0ZW0uZmluZCgnLnBsLXByb2dyZXNzLXRpcCcpLmh0bWwoJ+S4i+i9veWujOaIkO+8jOato+WcqOW8ueWHuua1j+iniOWZqOS4i+i9veahhu+8gScpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSwgNTAwKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLXJldHJ5JywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGxldCBvID0gX2ZhY3RvcnkoZSk7CiAgICAgICAgICAgICAgICBvLnRpcC5oaWRlKCk7CiAgICAgICAgICAgICAgICBvLmxpbmsuc2hvdygpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItaG93JywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGxldCBvID0gX2ZhY3RvcnkoZSk7CiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmxpbmtbMF0uZGF0YXNldC5pbmRleDsKICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0W2luZGV4XSkgewogICAgICAgICAgICAgICAgICAgIHJlcXVlc3RbaW5kZXhdLmFib3J0KCk7CiAgICAgICAgICAgICAgICAgICAgY2xlYXJJbnRlcnZhbChpbnNbaW5kZXhdKTsKICAgICAgICAgICAgICAgICAgICBvLnByb2dyZXNzLmhpZGUoKTsKICAgICAgICAgICAgICAgICAgICBvLnRpcC5zaG93KCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItc3RvcCcsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgbyA9IF9mYWN0b3J5KGUpOwogICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5saW5rWzBdLmRhdGFzZXQuaW5kZXg7CiAgICAgICAgICAgICAgICBpZiAocmVxdWVzdFtpbmRleF0pIHsKICAgICAgICAgICAgICAgICAgICByZXF1ZXN0W2luZGV4XS5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIGNsZWFySW50ZXJ2YWwoaW5zW2luZGV4XSk7CiAgICAgICAgICAgICAgICAgICAgby50aXAuaGlkZSgpOwogICAgICAgICAgICAgICAgICAgIG8ucHJvZ3Jlc3MuaGlkZSgpOwogICAgICAgICAgICAgICAgICAgIG8ubGluay5zaG93KDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItYmFjaycsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgbyA9IF9mYWN0b3J5KGUpOwogICAgICAgICAgICAgICAgby50aXAuaGlkZSgpOwogICAgICAgICAgICAgICAgby5saW5rLnNob3coKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstYXJpYSwgLmxpc3RlbmVyLWNvcHktYWxsJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgIGlmICghZS50YXJnZXQuZGF0YXNldC5saW5rKSB7CiAgICAgICAgICAgICAgICAgICAgJChlLnRhcmdldCkucmVtb3ZlQ2xhc3MoJ2xpc3RlbmVyLWNvcHktYWxsJykuYWRkQ2xhc3MoJ3BsLWJ0bi1kYW5nZXInKS5odG1sKGAke3Bhbi5pbml0WzVdffCfkYk8YSBocmVmPSIke3Bhbi5hc3Npc3RhbnR9IiB0YXJnZXQ9Il9ibGFuayIgY2xhc3M9InBsLWEiPueCueWHu+atpOWkhOWuieijhTwvYT7wn5GIYCk7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIGJhc2Uuc2V0Q2xpcGJvYXJkKGRlY29kZVVSSUNvbXBvbmVudChlLnRhcmdldC5kYXRhc2V0LmxpbmspKTsKICAgICAgICAgICAgICAgICAgICAkKGUudGFyZ2V0KS50ZXh0KCflpI3liLbmiJDlip/vvIzlv6vljrvnspjotLTlkKfvvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1saW5rLXJwYycsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0ID0gJChlLmN1cnJlbnRUYXJnZXQpOwogICAgICAgICAgICAgICAgdGFyZ2V0LmZpbmQoJy5pY29uJykucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB0YXJnZXQuZmluZCgnLnBsLWxvYWRpbmcnKS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgIHRhcmdldC5wcmVwZW5kKGJhc2UuY3JlYXRlTG9hZGluZygpKTsKICAgICAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCB0aGlzLnNlbmRMaW5rVG9SUEMoZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQuZmlsZW5hbWUsIGUuY3VycmVudFRhcmdldC5kYXRhc2V0LmxpbmspOwogICAgICAgICAgICAgICAgaWYgKHJlcyA9PT0gJ3N1Y2Nlc3MnKSB7CiAgICAgICAgICAgICAgICAgICAgJCgnLmxpc3RlbmVyLXJwYy10YXNrJykuc2hvdygpOwogICAgICAgICAgICAgICAgICAgIHRhcmdldC5yZW1vdmVDbGFzcygncGwtYnRuLWRhbmdlcicpLmh0bWwoJ+WPkemAgeaIkOWKn++8jOW/q+WOu+eci+eci+WQp++8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmVzID09PSAnYXNzaXN0YW50JykgewogICAgICAgICAgICAgICAgICAgIHRhcmdldC5hZGRDbGFzcygncGwtYnRuLWRhbmdlcicpLmh0bWwoYCR7cGFuLmluaXRbNV198J+RiTxhIGhyZWY9IiR7cGFuLmFzc2lzdGFudH0iIHRhcmdldD0iX2JsYW5rIiBjbGFzcz0icGwtYSI+54K55Ye75q2k5aSE5a6J6KOFPC9hPvCfkYhgKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LmFkZENsYXNzKCdwbC1idG4tZGFuZ2VyJykudGV4dCgn5Y+R6YCB5aSx6LSl77yM6K+35qOA5p+l5oKo55qEUlBD6YWN572u5L+h5oGv77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItc2VuZC1ycGMnLCAoZSkgPT4gewogICAgICAgICAgICAgICAgJCgnLmxpc3RlbmVyLWxpbmstcnBjJykuY2xpY2soKTsKICAgICAgICAgICAgICAgICQoZS50YXJnZXQpLnRleHQoJ+WPkemAgeWujOaIkO+8jOWPkemAgee7k+aenOingeS4iuaWueaMiemSru+8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLW9wZW4tc2V0dGluZycsICgpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2hvd1NldHRpbmcoKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLXJwYy10YXNrJywgKCkgPT4gewogICAgICAgICAgICAgICAgbGV0IHJwYyA9IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgICBkb21haW46IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX2RvbWFpbicpLAogICAgICAgICAgICAgICAgICAgIHBvcnQ6IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3BvcnQnKSwKICAgICAgICAgICAgICAgIH0pLCB1cmwgPSBgJHtwYW4uZH0vP3JwYz0ke2Jhc2UuZShycGMpfSMke2Jhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3Rva2VuJyl9YDsKICAgICAgICAgICAgICAgIEdNX29wZW5JblRhYih1cmwsIHthY3RpdmU6IHRydWV9KTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCdtb3VzZXVwJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIGlmIChlLnRhcmdldC5ub2RlTmFtZSA9PT0gJ0EnICYmIH5lLnRhcmdldC5jbGFzc05hbWUuaW5kZXhPZigncGwtYScpKSB7CiAgICAgICAgICAgICAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSwgdHJ1ZSk7CiAgICAgICAgfSwKCiAgICAgICAgYWRkQnV0dG9uKCkgewogICAgICAgICAgICBpZiAoIXB0KSByZXR1cm47CiAgICAgICAgICAgIGxldCAkdG9vbFdyYXA7CiAgICAgICAgICAgIGxldCAkYnV0dG9uID0gJChgPGRpdiBjbGFzcz0iZy1kcm9wZG93bi1idXR0b24gcG9pbnRlciBwbC1idXR0b24iPjxkaXYgc3R5bGU9ImNvbG9yOiNmZm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7kuIvovb3liqnmiYs8L3NwYW4+PC9zcGFuPjwvZGl2PjwvZGl2PmApOwogICAgICAgICAgICBpZiAocHQgPT09ICdob21lJykgJHRvb2xXcmFwID0gJChwYW4uYnRuLmhvbWUpOwogICAgICAgICAgICBpZiAocHQgPT09ICdtYWluJykgewogICAgICAgICAgICAgICAgJHRvb2xXcmFwID0gJChwYW4uYnRuLm1haW4pOwogICAgICAgICAgICAgICAgJGJ1dHRvbiA9ICQoYDxkaXYgY2xhc3M9InBsLWJ1dHRvbi1pbml0IiBzdHlsZT0ib3BhY2l0eTouNTsgZGlzcGxheTogaW5saW5lLWJsb2NrOyBtYXJnaW4tcmlnaHQ6IDhweDsiPjxidXR0b24gY2xhc3M9InUtYnV0dG9uIHUtYnV0dG9uLS1wcmltYXJ5IHUtYnV0dG9uLS1zbWFsbCBpcy1yb3VuZCBpcy1oYXMtaWNvbiIgc3R5bGU9ImJhY2tncm91bmQ6ICR7Y29sb3J9O2JvcmRlci1jb2xvcjogJHtjb2xvcn07Zm9udC1zaXplOiAxNHB4OyBwYWRkaW5nOiA4cHggMTZweDsgYm9yZGVyOiBub25lOyI+PGkgY2xhc3M9InUtaWNvbiB1LWljb24tZG93bmxvYWQiPjwvaT48c3Bhbj7kuIvovb3liqnmiYs8L3NwYW4+PC9idXR0b24+PC9kaXY+YCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHB0ID09PSAnc2hhcmUnKSAkdG9vbFdyYXAgPSAkKHBhbi5idG4uc2hhcmUpOwogICAgICAgICAgICAkdG9vbFdyYXAucHJlcGVuZCgkYnV0dG9uKTsKICAgICAgICAgICAgJGJ1dHRvbi5jbGljaygoKSA9PiBiYXNlLmluaXREaWFsb2coKSk7CiAgICAgICAgfSwKCiAgICAgICAgYXN5bmMgZ2V0VG9rZW4oKSB7CiAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCBiYXNlLmdldEZpbmFsVXJsKHBhbi5wY3NbM10pOwogICAgICAgICAgICBpZiAocmVzLmluZGV4T2YoJ2FjY2Vzc190b2tlbicpID09PSAtMSkgewogICAgICAgICAgICAgICAgbGV0IGh0bWwgPSBhd2FpdCBiYXNlLmdldChwYW4ucGNzWzNdLCB7fSwgJ3RleHQnKTsKICAgICAgICAgICAgICAgIGxldCBiZHN0b2tlbiA9IGh0bWwubWF0Y2goL25hbWU9ImJkc3Rva2VuIlxzK3ZhbHVlPSIoW14iXSspIi8pPy5bMV07CiAgICAgICAgICAgICAgICBsZXQgY2xpZW50X2lkID0gaHRtbC5tYXRjaCgvbmFtZT0iY2xpZW50X2lkIlxzK3ZhbHVlPSIoW14iXSspIi8pPy5bMV07CiAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IHsKICAgICAgICAgICAgICAgICAgICBncmFudF9wZXJtaXNzaW9uc19hcnI6ICduZXRkaXNrJywKICAgICAgICAgICAgICAgICAgICBiZHN0b2tlbjogYmRzdG9rZW4sCiAgICAgICAgICAgICAgICAgICAgY2xpZW50X2lkOiBjbGllbnRfaWQsCiAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2VfdHlwZTogInRva2VuIiwKICAgICAgICAgICAgICAgICAgICBkaXNwbGF5OiAicGFnZSIsCiAgICAgICAgICAgICAgICAgICAgZ3JhbnRfcGVybWlzc2lvbnM6ICJiYXNpYyxuZXRkaXNrIgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYXdhaXQgYmFzZS5wb3N0KHBhbi5wY3NbM10sIGJhc2Uuc3RyaW5naWZ5KGRhdGEpLCB7CiAgICAgICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi94LXd3dy1mb3JtLXVybGVuY29kZWQnLAogICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgICAgIGxldCByZXMyID0gYXdhaXQgYmFzZS5nZXRGaW5hbFVybChwYW4ucGNzWzNdKTsKICAgICAgICAgICAgICAgIGxldCBhY2Nlc3NUb2tlbiA9IHJlczIubWF0Y2goL2FjY2Vzc190b2tlbj0oW14mXSspLyk/LlsxXTsKICAgICAgICAgICAgICAgIGFjY2Vzc1Rva2VuICYmIGJhc2Uuc2V0U3RvcmFnZSgnYWNjZXNzVG9rZW4nLCBhY2Nlc3NUb2tlbik7CiAgICAgICAgICAgICAgICByZXR1cm4gYWNjZXNzVG9rZW47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IGFjY2Vzc1Rva2VuID0gcmVzLm1hdGNoKC9hY2Nlc3NfdG9rZW49KFteJl0rKS8pPy5bMV07CiAgICAgICAgICAgIGFjY2Vzc1Rva2VuICYmIGJhc2Uuc2V0U3RvcmFnZSgnYWNjZXNzVG9rZW4nLCBhY2Nlc3NUb2tlbik7CiAgICAgICAgICAgIHJldHVybiBhY2Nlc3NUb2tlbjsKICAgICAgICB9LAoKICAgICAgICBhc3luYyBnZXRQQ1NMaW5rKG1heFJlcXVlc3RUaW1lID0gMikgewogICAgICAgICAgICBzZWxlY3RMaXN0ID0gdGhpcy5nZXRTZWxlY3RlZExpc3QoKTsKICAgICAgICAgICAgbGV0IGZpZExpc3QgPSB0aGlzLl9nZXRGaWRMaXN0KCksIHVybCwgcmVzOwoKICAgICAgICAgICAgaWYgKHB0ID09PSAnaG9tZScgfHwgcHQgPT09ICdtYWluJykgewogICAgICAgICAgICAgICAgaWYgKHNlbGVjdExpc3QubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muivt+WFiOWLvumAieimgeS4i+i9veeahOaWh+S7tu+8gScpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKGZpZExpc3QubGVuZ3RoID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muivt+aJk+W8gOaWh+S7tuWkueWQjuWLvumAieaWh+S7tu+8gScpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZmlkTGlzdCA9IGVuY29kZVVSSUNvbXBvbmVudChmaWRMaXN0KTsKICAgICAgICAgICAgICAgIGxldCBhY2Nlc3NUb2tlbiA9IGJhc2UuZ2V0U3RvcmFnZSgnYWNjZXNzVG9rZW4nKSB8fCBhd2FpdCB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICB1cmwgPSBgJHtwYW4ucGNzWzBdfSZmc2lkcz0ke2ZpZExpc3R9JmFjY2Vzc190b2tlbj0ke2FjY2Vzc1Rva2VufWA7CiAgICAgICAgICAgICAgICByZXMgPSBhd2FpdCBiYXNlLmdldCh1cmwsIHsiVXNlci1BZ2VudCI6IHBhbi51YX0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChwdCA9PT0gJ3NoYXJlJykgewogICAgICAgICAgICAgICAgdGhpcy5nZXRTaGFyZURhdGEoKTsKICAgICAgICAgICAgICAgIGlmIChzZWxlY3RMaXN0Lmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7flhYjli77pgInopoHkuIvovb3nmoTmlofku7bvvIEnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChmaWRMaXN0Lmxlbmd0aCA9PT0gMikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7fmiZPlvIDmlofku7blpLnlkI7li77pgInmlofku7bvvIEnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcGFyYW1zLnNpZ24pIHsKICAgICAgICAgICAgICAgICAgICBsZXQgdXJsID0gYCR7cGFuLnBjc1syXX0mc3VybD0ke3BhcmFtcy5zdXJsfSZsb2dpZD0ke3BhcmFtcy5sb2dpZH1gOwogICAgICAgICAgICAgICAgICAgIGxldCByID0gYXdhaXQgYmFzZS5nZXQodXJsKTsKICAgICAgICAgICAgICAgICAgICBpZiAoci5lcnJubyA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMuc2lnbiA9IHIuZGF0YS5zaWduOwogICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMudGltZXN0YW1wID0gci5kYXRhLnRpbWVzdGFtcDsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGlhbG9nID0gYXdhaXQgU3dhbC5maXJlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0OiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWNvbjogJ2luZm8nLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGDmj5DnpLrvvJror7flsIbmlofku7Y8c3BhbiBjbGFzcz0idGFnLWRhbmdlciI+W+S/neWtmOWIsOe9keebmF08L3NwYW4+8J+RieWJjeW+gDxzcGFuIGNsYXNzPSJ0YWctZGFuZ2VyIj5b5oiR55qE572R55uYXTwvc3Bhbj7kuK3kuIvovb3vvIFgLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0NvbmZpcm1CdXR0b246IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maXJtQnV0dG9uVGV4dDogJ+eCueWHu+S/neWtmCcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3NpdGlvbjogJ3RvcCcsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlhbG9nLmlzQ29uZmlybWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcudG9vbHMtc2hhcmUtc2F2ZS1oYicpWzBdLmNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICghcGFyYW1zLmJkc3Rva2VuKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muivt+WFiOeZu+W9lee9keebmO+8gScpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IGZvcm1EYXRhID0gbmV3IEZvcm1EYXRhKCk7CiAgICAgICAgICAgICAgICBmb3JtRGF0YS5hcHBlbmQoJ2VuY3J5cHQnLCBwYXJhbXMuZW5jcnlwdCk7CiAgICAgICAgICAgICAgICBmb3JtRGF0YS5hcHBlbmQoJ3Byb2R1Y3QnLCBwYXJhbXMucHJvZHVjdCk7CiAgICAgICAgICAgICAgICBmb3JtRGF0YS5hcHBlbmQoJ3VrJywgcGFyYW1zLnVrKTsKICAgICAgICAgICAgICAgIGZvcm1EYXRhLmFwcGVuZCgncHJpbWFyeWlkJywgcGFyYW1zLnByaW1hcnlpZCk7CiAgICAgICAgICAgICAgICBmb3JtRGF0YS5hcHBlbmQoJ2ZpZF9saXN0JywgZmlkTGlzdCk7CiAgICAgICAgICAgICAgICBmb3JtRGF0YS5hcHBlbmQoJ2xvZ2lkJywgcGFyYW1zLmxvZ2lkKTsKICAgICAgICAgICAgICAgIHBhcmFtcy5zaGFyZVR5cGUgPT09ICdzZWNyZXQnID8gZm9ybURhdGEuYXBwZW5kKCdleHRyYScsIHBhcmFtcy5leHRyYSkgOiAnJzsKICAgICAgICAgICAgICAgIHVybCA9IGAke3Bhbi5wY3NbMV19JnNpZ249JHtwYXJhbXMuc2lnbn0mdGltZXN0YW1wPSR7cGFyYW1zLnRpbWVzdGFtcH1gOwogICAgICAgICAgICAgICAgcmVzID0gYXdhaXQgYmFzZS5wb3N0KHVybCwgZm9ybURhdGEsIHsiVXNlci1BZ2VudCI6IHBhbi51YX0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChyZXMuZXJybm8gPT09IDApIHsKICAgICAgICAgICAgICAgIGxldCBodG1sID0gdGhpcy5nZW5lcmF0ZURvbShyZXMubGlzdCk7CiAgICAgICAgICAgICAgICB0aGlzLnNob3dNYWluRGlhbG9nKHBhblttb2RlXVswXSwgaHRtbCwgcGFuW21vZGVdWzFdKTsKICAgICAgICAgICAgfSBlbHNlIGlmIChyZXMuZXJybm8gPT09IDExMikgewogICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8mumhtemdoui/h+acn++8jOivt+WIt+aWsOmHjeivle+8gScpOwogICAgICAgICAgICB9IGVsc2UgaWYgKHJlcy5lcnJubyA9PT0gOTAxOSkgewogICAgICAgICAgICAgICAgbWF4UmVxdWVzdFRpbWUtLTsKICAgICAgICAgICAgICAgIGF3YWl0IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgICAgIGlmIChtYXhSZXF1ZXN0VGltZSA+IDApIHsKICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLmdldFBDU0xpbmsobWF4UmVxdWVzdFRpbWUpOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJrojrflj5bkuIvovb3pk77mjqXlpLHotKXvvIHor7fliLfmlrDnvZHpobXlkI7ph43or5XvvIEnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muiOt+WPluS4i+i9vemTvuaOpeWksei0pe+8geivt+WIt+aWsOe9kemhteWQjumHjeivle+8gScpOwogICAgICAgICAgICB9CiAgICAgICAgfSwKCiAgICAgICAgZ2VuZXJhdGVEb20obGlzdCkgewogICAgICAgICAgICBsZXQgY29udGVudCA9ICc8ZGl2IGNsYXNzPSJwbC1tYWluIj4nOwogICAgICAgICAgICBsZXQgYWxpbmtBbGxUZXh0ID0gJyc7CiAgICAgICAgICAgIGJhc2Uuc29ydEJ5TmFtZShsaXN0KTsKICAgICAgICAgICAgbGlzdC5mb3JFYWNoKCh2LCBpKSA9PiB7CiAgICAgICAgICAgICAgICBpZiAodi5pc2RpciA9PT0gMSkgcmV0dXJuOwogICAgICAgICAgICAgICAgbGV0IGZpbGVuYW1lID0gdi5zZXJ2ZXJfZmlsZW5hbWUgfHwgdi5maWxlbmFtZTsKICAgICAgICAgICAgICAgIGxldCBleHQgPSBiYXNlLmdldEV4dGVuc2lvbihmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICBsZXQgc2l6ZSA9IGJhc2Uuc2l6ZUZvcm1hdCh2LnNpemUpOwogICAgICAgICAgICAgICAgbGV0IGRsaW5rID0gdi5kbGluazsKICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXBpJykgewogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIHBsLWEgbGlzdGVuZXItbGluay1hcGkiIGhyZWY9IiR7ZGxpbmt9IiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSIgZGF0YS1saW5rPSIke2RsaW5rfSIgZGF0YS1pbmRleD0iJHtpfSI+JHtkbGlua308L2E+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS10aXAiIHN0eWxlPSJkaXNwbGF5OiBub25lIj48c3Bhbj7oi6XmsqHmnInlvLnlh7pJRE3kuIvovb3moYbvvIzmib7liLBJRE0gPGI+6YCJ6aG5PC9iPiAtPiA8Yj7mlofku7bnsbvlnos8L2I+IC0+IDxiPuesrOS4gOS4quahhjwvYj4g5Lit5re75Yqg5ZCO57yAIDxzcGFuIGNsYXNzPSJwbC1leHQiPiR7ZXh0fTwvc3Bhbj7vvIw8YSBocmVmPSIke3Bhbi5pZG19IiB0YXJnZXQ9Il9ibGFuayIgY2xhc3M9InBsLWEiPuivpuingeatpOWkhDwvYT48L3NwYW4+IDxzcGFuIGNsYXNzPSJwbC1iYWNrIGxpc3RlbmVyLWJhY2siPui/lOWbnjwvc3Bhbj48L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLXByb2dyZXNzIiBzdHlsZT0iZGlzcGxheTogbm9uZSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLXByb2dyZXNzIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLXByb2dyZXNzLW91dGVyIj48L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLXByb2dyZXNzLWlubmVyIiBzdHlsZT0id2lkdGg6NSUiPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1wcm9ncmVzcy1pbm5lci10ZXh0Ij4wJTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8c3BhbiBjbGFzcz0icGwtcHJvZ3Jlc3Mtc3RvcCBsaXN0ZW5lci1zdG9wIj7lj5bmtojkuIvovb08L3NwYW4+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxzcGFuIGNsYXNzPSJwbC1wcm9ncmVzcy10aXAiPuacquWPkeeOsElETe+8jOS9v+eUqOiHquW4pua1j+iniOWZqOS4i+i9vTwvc3Bhbj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPHNwYW4gY2xhc3M9InBsLXByb2dyZXNzLWhvdyBsaXN0ZW5lci1ob3ciPuWmguS9leWUpOi1t0lETe+8nzwvc3Bhbj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8L2Rpdj48L2Rpdj5gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdhcmlhJykgewogICAgICAgICAgICAgICAgICAgIGxldCBhbGluayA9IHRoaXMuY29udmVydExpbmtUb0FyaWEoZGxpbmssIGZpbGVuYW1lLCBwYW4udWEpOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgKGFsaW5rKSA9PT0gJ29iamVjdCcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxhIGNsYXNzPSJwbC1pdGVtLWxpbmsgcGwtYSIgdGFyZ2V0PSJfYmxhbmsiIGhyZWY9IiR7YWxpbmsubGlua30iIGRhdGEtZmlsZW5hbWU9IiR7ZmlsZW5hbWV9IiBkYXRhLWxpbms9IiR7YWxpbmsubGlua30iPiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rLnRleHQpfTwvYT4gPC9kaXY+YDsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBhbGlua0FsbFRleHQgKz0gYWxpbmsgKyAnXHJcbic7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIHBsLWEgbGlzdGVuZXItbGluay1hcmlhIiBocmVmPSIke2FsaW5rfSIgdGl0bGU9IueCueWHu+WkjeWItmFyaWEyY+mTvuaOpSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGlua30iPiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rKX08L2E+IDwvZGl2PmA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdycGMnKSB7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxidXR0b24gY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLXJwYyBwbC1idG4tcHJpbWFyeSBwbC1idG4taW5mbyIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHtkbGlua30iPjxlbSBjbGFzcz0iaWNvbiBpY29uLWRldmljZSI+PC9lbT48c3BhbiBzdHlsZT0ibWFyZ2luLWxlZnQ6IDVweDsiPuaOqOmAgeWIsCBSUEMg5LiL6L295ZmoPC9zcGFuPjwvYnV0dG9uPjwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2N1cmwnKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaW5rID0gdGhpcy5jb252ZXJ0TGlua1RvQ3VybChkbGluaywgZmlsZW5hbWUsIHBhbi51YSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiAoYWxpbmspID09PSAnb2JqZWN0JykgewogICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBwbC1hIiB0YXJnZXQ9Il9ibGFuayIgaHJlZj0iJHthbGluay5saW5rfSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGluay5saW5rfSI+JHtkZWNvZGVVUklDb21wb25lbnQoYWxpbmsudGV4dCl9PC9hPiA8L2Rpdj5gOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFsaW5rQWxsVGV4dCArPSBhbGluayArICdcclxuJzsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxhIGNsYXNzPSJwbC1pdGVtLWxpbmsgcGwtYSBsaXN0ZW5lci1saW5rLWFyaWEiIGhyZWY9IiR7YWxpbmt9IiB0aXRsZT0i54K55Ye75aSN5Yi2Y3VybOmTvuaOpSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGlua30iPiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rKX08L2E+IDwvZGl2PmA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdiYycpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYWxpbmsgPSB0aGlzLmNvbnZlcnRMaW5rVG9CQyhkbGluaywgZmlsZW5hbWUsIHBhbi51YSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiAoYWxpbmspID09PSAnb2JqZWN0JykgewogICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBwbC1hIiB0YXJnZXQ9Il9ibGFuayIgaHJlZj0iJHthbGluay5saW5rfSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGluay5saW5rfSI+JHtkZWNvZGVVUklDb21wb25lbnQoYWxpbmsudGV4dCl9PC9hPiA8L2Rpdj5gOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW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xlbmFtZSwgbGluaykgewogICAgICAgICAgICBsZXQgcnBjID0gewogICAgICAgICAgICAgICAgZG9tYWluOiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19kb21haW4nKSwKICAgICAgICAgICAgICAgIHBvcnQ6IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3BvcnQnKSwKICAgICAgICAgICAgICAgIHBhdGg6IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3BhdGgnKSwKICAgICAgICAgICAgICAgIHRva2VuOiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY190b2tlbicpLAogICAgICAgICAgICAgICAgZGlyOiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19kaXInKSwKICAgICAgICAgICAgfTsKICAgICAgICAgICAgbGV0IEJEVVNTID0gdGhpcy5nZXRCRFVTUygpOwogICAgICAgICAgICBpZiAoIUJEVVNTKSByZXR1cm4gJ2Fzc2lzdGFudCc7CgogICAgICAgICAgICBsZXQgdXJsID0gYCR7cnBjLmRvbWFpbn06JHtycGMucG9ydH0ke3JwYy5wYXRofWA7CiAgICAgICAgICAgIGxldCBycGNEYXRhID0gewogICAgICAgICAgICAgICAgaWQ6IG5ldyBEYXRlKCkuZ2V0VGltZSgpLAogICAgICAgICAgICAgICAganNvbnJwYzogJzIuMCcsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICdhcmlhMi5hZGRVcmknLAogICAgICAgICAgICAgICAgcGFyYW1zOiBbYHRva2VuOiR7cnBjLnRva2VufWAsIFtsaW5rXSwgewogICAgICAgICAgICAgICAgICAgIGRpcjogcnBjLmRpciwKICAgICAgICAgICAgICAgICAgICBvdXQ6IGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgIGhlYWRlcjogW2BVc2VyLUFnZW50OiAke3Bhbi51YX1gLCBgQ29va2llOiBCRFVTUz0ke0JEVVNTfWBdCiAgICAgICAgICAgICAgICB9XQogICAgICAgICAgICB9OwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IGJhc2UucG9zdCh1cmwsIHJwY0RhdGEsIHsiVXNlci1BZ2VudCI6IHBhbi51YX0sICcnKTsKICAgICAgICAgICAgICAgIGlmIChyZXMucmVzdWx0KSByZXR1cm4gJ3N1Y2Nlc3MnOwogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIGdldFNlbGVjdGVkTGlzdCgpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJldHVybiByZXF1aXJlKCdzeXN0ZW0tY29yZTpjb250ZXh0L2NvbnRleHQuanMnKS5pbnN0YW5jZUZvclN5c3RlbS5saXN0LmdldFNlbGVjdGVkKCk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCcud3Atcy1jb3JlLXBhbicpLl9fdnVlX18uc2VsZWN0ZWRMaXN0OwogICAgICAgICAgICB9CiAgICAgICAgfSwKCiAgICAgICAgZ2V0TG9naWQoKSB7CiAgICAgICAgICAgIGxldCB1dCA9IHJlcXVpcmUoInN5c3RlbS1jb3JlOmNvbnRleHQvY29udGV4dC5qcyIpLmluc3RhbmNlRm9yU3lzdGVtLnRvb2xzLmJhc2VTZXJ2aWNlOwogICAgICAgICAgICByZXR1cm4gdXQuYmFzZTY0RW5jb2RlKGJhc2UuZ2V0Q29va2llKCJCQUlEVUlEIikpOwogICAgICAgIH0sCgogICAgICAgIGdldFNoYXJlRGF0YSgpIHsKICAgICAgICAgICAgbGV0IHJlcyA9IGxvY2Fscy5kdW1wKCk7CiAgICAgICAgICAgIHBhcmFtcy5zaGFyZVR5cGUgPSAnc2VjcmV0JzsKICAgICAgICAgICAgcGFyYW1zLnNpZ24gPSAnJzsKICAgICAgICAgICAgcGFyYW1zLnRpbWVzdGFtcCA9ICcnOwogICAgICAgICAgICBwYXJhbXMuYmRzdG9rZW4gPSByZXMuYmRzdG9rZW4udmFsdWU7CiAgICAgICAgICAgIHBhcmFtcy5jaGFubmVsID0gJ2NodW5sZWknOwogICAgICAgICAgICBwYXJhbXMuY2xpZW50dHlwZSA9IDA7CiAgICAgICAgICAgIHBhcmFtcy53ZWIgPSAxOwogICAgICAgICAgICBwYXJhbXMuYXBwX2lkID0gMjUwNTI4OwogICAgICAgICAgICBwYXJhbXMuZW5jcnlwdCA9IDA7CiAgICAgICAgICAgIHBhcmFtcy5wcm9kdWN0ID0gJ3NoYXJlJzsKICAgICAgICAgICAgcGFyYW1zLmxvZ2lkID0gdGhpcy5nZXRMb2dpZCgpOwogICAgICAgICAgICBwYXJhbXMucHJpbWFyeWlkID0gcmVzLnNoYXJlaWQudmFsdWU7CiAgICAgICAgICAgIHBhcmFtcy51ayA9IHJlcy5zaGFyZV91ay52YWx1ZTsKICAgICAgICAgICAgcGFyYW1zLnNoYXJlVHlwZSA9PT0gJ3NlY3JldCcgJiYgKHBhcmFtcy5leHRyYSA9IHRoaXMuX2dldEV4dHJhKCkpOwogICAgICAgICAgICBwYXJhbXMuc3VybCA9IHRoaXMuX2dldFN1cmwoKTsKICAgICAgICB9LAoKICAgICAgICBkZXRlY3RQYWdlKCkgewogICAgICAgICAgICBsZXQgcGF0aCA9IGxvY2F0aW9uLnBhdGhuYW1lOwogICAgICAgICAgICBpZiAoL15cL2Rpc2tcL2hvbWUvLnRlc3QocGF0aCkpIHJldHVybiAnaG9tZSc7CiAgICAgICAgICAgIGlmICgvXlwvZGlza1wvbWFpbi8udGVzdChwYXRoKSkgcmV0dXJuICdtYWluJzsKICAgICAgICAgICAgaWYgKC9eXC8oc3xzaGFyZSlcLy8udGVzdChwYXRoKSkgcmV0dXJuICdzaGFyZSc7CiAgICAgICAgICAgIHJldHVybiAnJzsKICAgICAgICAgICAgcmV0dXJuICcnOwogICAgICAgIH0sCgogICAgICAgIHNob3dNYWluRGlhbG9nKHRpdGxlLCBodG1sLCBmb290ZXIpIHsKICAgICAgICAgICAgU3dhbC5maXJlKHsKICAgICAgICAgICAgICAgIHRpdGxlLAogICAgICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgICAgIGZvb3RlciwKICAgICAgICAgICAgICAgIGFsbG93T3V0c2lkZUNsaWNrOiBmYWxzZSwKICAgICAgICAgICAgICAgIHNob3dDbG9zZUJ1dHRvbjogdHJ1ZSwKICAgICAgICAgICAgICAgIHNob3dDb25maXJtQnV0dG9uOiBmYWxzZSwKICAgICAgICAgICAgICAgIHBvc2l0aW9uOiAndG9wJywKICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgcGFkZGluZzogJzE1cHggMjBweCA1cHgnLAogICAgICAgICAgICAgICAgY3VzdG9tQ2xhc3MsCiAgICAgICAgICAgIH0pLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgdGhpcy5fcmVzZXREYXRhKCk7CiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIGFzeW5jIGluaXRQYW5MaW5rZXIoKSB7CiAgICAgICAgICAgIGJhc2UuaW5pdERlZmF1bHRDb25maWcoKTsKICAgICAgICAgICAgYmFzZS5hZGRQYW5MaW5rZXJTdHlsZSgpOwogICAgICAgICAgICBwdCA9IHRoaXMuZGV0ZWN0UGFnZSgpOwogICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0CiAgICAgICAgICAgIChgaHR0cHM6Ly9hcGkueW91eGlhb2hvdS5jb20vY29uZmlnL3YyP3Zlcj0ke3ZlcnNpb259JmE9JHthdXRob3J9YCwge30sIHt9LCAndGV4dCcpOwogICAgICAgICAgICBwYW4gPSBKU09OLnBhcnNlKGJhc2UuZChyZXMpKTsKICAgICAgICAgICAgT2JqZWN0LmZyZWV6ZSAmJiBPYmplY3QuZnJ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KSB7CiAgICAgICAgICAgIGxldCB0ZXJtaW5hbCA9IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfdGVybWluYWxfdHlwZScpOwogICAgICAgICAgICBmaWxlbmFtZSA9IGJhc2UuZml4RmlsZW5hbWUoZmlsZW5hbWUpOwogICAgICAgICAgICByZXR1cm4gZW5jb2RlVVJJQ29tcG9uZW50KGAke3Rlcm1pbmFsICE9PSAnd3AnID8gJ2N1cmwnIDogJ2N1cmwuZXhlJ30gLUwgLUMgLSAiJHtsaW5rfSIgLW8gIiR7ZmlsZW5hbWV9IiAtZSAiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLyJgKTsKICAgICAgICB9LAoKICAgICAgICBhZGRQYWdlTGlzdGVuZXIoKSB7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLnBsLWJ1dHRvbi1tb2RlJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIG1vZGUgPSBlLnRhcmdldC5kYXRhc2V0Lm1vZGU7CiAgICAgICAgICAgICAgICBTd2FsLnNob3dMb2FkaW5nKCk7CiAgICAgICAgICAgICAgICB0aGlzLmdldFBDU0xpbmsoKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstYXBpJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgIGxldCBkYXRhc2V0ID0gZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQ7CiAgICAgICAgICAgICAgICBsZXQgaHJlZiA9IGRhdGFzZXQubGluazsKICAgICAgICAgICAgICAgIGxldCB1cmwgPSBhd2FpdCB0aGlzLmdldFJlYWxMaW5rKGRhdGFzZXQuZGlkLCBkYXRhc2V0LmZpZCk7CiAgICAgICAgICAgICAgICBpZiAodXJsKSBocmVmID0gdXJsOwogICAgICAgICAgICAgICAgbGV0IGQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJhIik7CiAgICAgICAgICAgICAgICBkLmRvd25sb2FkID0gZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQuZmlsZW5hbWU7CiAgICAgICAgICAgICAgICBkLnJlbCA9ICJub29wZW5lciI7CiAgICAgICAgICAgICAgICBkLmhyZWYgPSBocmVmOwogICAgICAgICAgICAgICAgZC5kaXNwYXRjaEV2ZW50KG5ldyBNb3VzZUV2ZW50KCJjbGljayIpKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstYXBpLWJ0bicsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBiYXNlLnNldENsaXBib2FyZChlLnRhcmdldC5kYXRhc2V0LmZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICQoZS50YXJnZXQpLnRleHQoJ+WkjeWItuaIkOWKnycpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstYXJpYSwgLmxpc3RlbmVyLWNvcHktYWxsJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0Q2xpcGJvYXJkKGRlY29kZVVSSUNvbXBvbmVudChlLnRhcmdldC5kYXRhc2V0LmxpbmspKTsKICAgICAgICAgICAgICAgICQoZS50YXJnZXQpLnRleHQoJ+WkjeWItuaIkOWKn++8jOW/q+WOu+eymOi0tOWQp++8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstcnBjJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGxldCB0YXJnZXQgPSAkKGUuY3VycmVudFRhcmdldCk7CiAgICAgICAgICAgICAgICB0YXJnZXQuZmluZCgnLmljb24nKS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgIHRhcmdldC5maW5kKCcucGwtbG9hZGluZycpLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgdGFyZ2V0LnByZXBlbmQoYmFzZS5jcmVhdGVMb2FkaW5nKCkpOwogICAgICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IHRoaXMuc2VuZExpbmtUb1JQQyhlLmN1cnJlbnRUYXJnZXQuZGF0YXNldC5maWxlbmFtZSwgZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQubGluayk7CiAgICAgICAgICAgICAgICBpZiAocmVzID09PSAnc3VjY2VzcycpIHsKICAgICAgICAgICAgICAgICAgICAkKCcubGlzdGVuZXItcnBjLXRhc2snKS5zaG93KCk7CiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnJlbW92ZUNsYXNzKCdwbC1idG4tZGFuZ2VyJykuaHRtbCgn5Y+R6YCB5oiQ5Yqf77yM5b+r5Y6755yL55yL5ZCn77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB0YXJnZXQuYWRkQ2xhc3MoJ3BsLWJ0bi1kYW5nZXInKS50ZXh0KCflj5HpgIHlpLHotKXvvIzor7fmo4Dmn6XmgqjnmoRSUEPphY3nva7kv6Hmga/vvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1zZW5kLXJwYycsIChlKSA9PiB7CiAgICAgICAgICAgICAgICAkKCcubGlzdGVuZXItbGluay1ycGMnKS5jbGljaygpOwogICAgICAgICAgICAgICAgJChlLnRhcmdldCkudGV4dCgn5Y+R6YCB5a6M5oiQ77yM5Y+R6YCB57uT5p6c6KeB5LiK5pa55oyJ6ZKu77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItb3Blbi1zZXR0aW5nJywgKCkgPT4gewogICAgICAgICAgICAgICAgYmFzZS5zaG93U2V0dGluZygpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItcnBjLXRhc2snLCAoKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgcnBjID0gSlNPTi5zdHJpbmdpZnkoewogICAgICAgICAgICAgICAgICAgIGRvbWFpbjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfZG9tYWluJyksCiAgICAgICAgICAgICAgICAgICAgcG9ydDogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfcG9ydCcpLAogICAgICAgICAgICAgICAgfSksIHVybCA9IGAke3Bhbi5kfS8/cnBjPSR7YmFzZS5lKHJwYyl9IyR7YmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfdG9rZW4nKX1gOwogICAgICAgICAgICAgICAgR01fb3BlbkluVGFiKHVybCwge2FjdGl2ZTogdHJ1ZX0pOwogICAgICAgICAgICB9KTsKICAgICAgICB9LAoKICAgICAgICBhc3luYyBnZXRSZWFsTGluayhkLCBmKSB7CiAgICAgICAgICAgIGxldCBhdXRob3JpemF0aW9uID0gYCR7YmFzZS5nZXRTdG9yYWdlKCd0b2tlbicpLnRva2VuX3R5cGV9ICR7YmFzZS5nZXRTdG9yYWdlKCd0b2tlbicpLmFjY2Vzc190b2tlbn1gOwogICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0KHBhbi5wY3NbMV0sIHsKICAgICAgICAgICAgICAgIGRyaXZlX2lkOiBkLAogICAgICAgICAgICAg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IDIwMCAmJiB2ZXJzaW9uIDwgcGFuLnZlcnNpb24gPyBwYW4ubmV3IDogJyd9PC91bD48L2Rpdj5gKTsKICAgICAgICAgICAgaWYgKHB0ID09PSAnaG9tZScpIHsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLmhvbWUsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAkdG9vbFdyYXAgPSAkKHBhbi5idG4uaG9tZSk7CiAgICAgICAgICAgICAgICAgICAgJCgnLnBsLWJ1dHRvbicpLmxlbmd0aCA9PT0gMCAmJiAkdG9vbFdyYXAuYXBwZW5kKCRidXR0b24pOwogICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocHQgPT09ICdzaGFyZScpIHsKICAgICAgICAgICAgICAgICRidXR0b24uY3NzKHsnbWFyZ2luLXJpZ2h0JzogJzEwcHgnfSk7CiAgICAgICAgICAgICAgICBiYXNlLmxpc3RlbkVsZW1lbnQocGFuLmJ0bi5zaGFyZSwgKCkgPT4gewogICAgICAgICAgICAgICAgICAgICR0b29sV3JhcCA9ICQocGFuLmJ0bi5zaGFyZSk7CiAgICAgICAgICAgICAgICAgICAgJCgnLnBsLWJ1dHRvbicpLmxlbmd0aCA9PT0gMCAmJiAkdG9vbFdyYXAucHJlcGVuZCgkYnV0dG9uKTsKICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgIH0KICAgICAgICAgICAgYmFzZS5jcmVhdGVEb3dubG9hZElmcmFtZSgpOwogICAgICAgICAgICB0aGlzLmFkZFBhZ2VMaXN0ZW5lcigpOwogICAgICAgIH0sCgogICAgICAgIGFkZEluaXRCdXR0b24oKSB7CiAgICAgICAgICAgIGlmICghcHQpIHJldHVybjsKICAgICAgICAgICAgbGV0ICR0b29sV3JhcDsKICAgICAgICAgICAgbGV0ICRidXR0b24gPSAkKGA8ZGl2IGNsYXNzPSJhbGktYnV0dG9uIHBsLWJ1dHRvbi1pbml0Ij48c3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eaJizwvc3Bhbj48L2Rpdj5gKTsKICAgICAgICAgICAgaWYgKHB0ID09PSAnaG9tZScpIHsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLmhvbWUsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAkdG9vbFdyYXAgPSAkKHBhbi5idG4uaG9tZSk7CiAgICAgICAgICAgICAgICAgICAgJCgnLnBsLWJ1dHRvbi1pbml0JykubGVuZ3RoID09PSAwICYmICR0b29sV3JhcC5hcHBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChwdCA9PT0gJ3NoYXJlJykgewogICAgICAgICAgICAgICAgJGJ1dHRvbi5jc3MoeydtYXJnaW4tcmlnaHQnOiAnMTBweCd9KTsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLnNoYXJlLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgJHRvb2xXcmFwID0gJChwYW4uYnRuLnNoYXJlKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG8taW5pdCcpLmxlbmd0aCA9PT0gMCAmJiAkdG9vbFdyYXAucHJlcGVuZCgkYnV0dG9uKTsKICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgIH0KICAgICAgICAgICAgJGJ1dHRvbi5jbGljaygoKSA9PiBiYXNlLmluaXREaWFsb2coKSk7CiAgICAgICAgfSwKCiAgICAgICAgYXN5bmMgZ2V0UENTTGluaygpIHsKICAgICAgICAgICAgbGV0IHJlYWN0RG9tR3JpZCA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IocGFuLmRvbS5ncmlkKTsKICAgICAgICAgICAgaWYgKHJlYWN0RG9tR3JpZCkgewogICAgICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IFN3YWwuZmlyZSh7CiAgICAgICAgICAgICAgICAgICAgdGl0bGU6ICfmj5DnpLonL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jZXNzKCfliIfmjaLmiJDlip/vvIzor7fph43mlrDojrflj5bkuIvovb3pk77mjqXvvIEnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzZWxlY3RMaXN0ID0gdGhpcy5nZXRTZWxlY3RlZExpc3QoKTsKICAgICAgICAgICAgaWYgKHNlbGVjdExpc3QubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbWVzc2FnZS5lcnJvcign5o+Q56S677ya6K+35YWI5Yu+6YCJ6KaB5LiL6L2955qE5paH5Lu277yBJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHRoaXMuaXNPbmx5Rm9sZGVyKCkpIHsKICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7fmiZPlvIDmlofku7blpLnlkI7li77pgInmlofku7bvvIEnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocHQgPT09ICdzaGFyZScpIHsKICAgICAgICAgICAgICAgIGlmIChzZWxlY3RMaXN0Lmxlbmd0aCA+IDIwKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muWNleasoeacgOWkmuWPr+WLvumAiSAyMCDkuKrmlofku7bvvIEnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGF1dGhvcml6YXRpb24gPSBgJHtiYXNlLmdldFN0b3JhZ2UoJ3Rva2VuJykudG9rZW5fdHlwZX0gJHtiYXNlLmdldFN0b3JhZ2UoJ3Rva2VuJykuYWNjZXNzX3Rva2VufWA7CiAgICAgICAgICAgICAgICAgICAgbGV0IHhTaGFyZVRva2VuID0gYmFzZS5nZXRTdG9yYWdlKCdzaGFyZVRva2VuJykuc2hhcmVfdG9rZW47CgogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2VsZWN0TGlzdC5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0KHBhbi5wY3NbMF0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cGlyZV9zZWM6IDYwMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVfaWQ6IHNlbGVjdExpc3RbaV0uZmlsZUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVfaWQ6IHNlbGVjdExpc3RbaV0uc2hhcmVJZAogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdXRob3JpemF0aW9uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgImNvbnRlbnQtdHlwZSI6ICJhcHBsaWNhdGlvbi9qc29uO2NoYXJzZXQ9dXRmLTgiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIngtc2hhcmUtdG9rZW4iOiB4U2hhcmVUb2tlbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcy5kb3dubG9hZF91cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdExpc3RbaV0uZG93bmxvYWRVcmwgPSByZXMuZG93bmxvYWRfdXJsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7flhYjnmbvlvZXnvZHnm5jvvIEnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaHRtbCA9IHRoaXMuZ2VuZXJhdGVEb20oc2VsZWN0TGlzdCk7CiAgICAgICAgICAgIHRoaXMuc2hvd01haW5EaWFsb2cocGFuW21vZGVdWzBdLCBodG1sLCBwYW5bbW9kZV1bMV0pOwogICAgICAgIH0sCgogICAgICAgIGdlbmVyYXRlRG9tKGxpc3QpIHsKICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSAnPGRpdiBjbGFzcz0icGwtbWFpbiI+JzsKICAgICAgICAgICAgbGV0IGFsaW5rQWxsVGV4dCA9ICcnOwogICAgICAgICAgICBsaXN0LmZvckVhY2goKHYsIGkpID0+IHsKICAgICAgICAgICAgICAgIGlmICh2LnR5cGUgPT09ICdmb2xkZXInKSByZXR1cm47CiAgICAgICAgICAgICAgICBsZXQgZmlsZW5hbWUgPSB2Lm5hbWU7CiAgICAgICAgICAgICAgICBsZXQgZmlkID0gdi5maWxlSWQ7CiAgICAgICAgICAgICAgICBsZXQgZGlkID0gdi5kcml2ZUlkOwogICAgICAgICAgICAgICAgbGV0IHNpemUgPSBiYXNlLnNpemVGb3JtYXQodi5zaXplKTsKICAgICAgICAgICAgICAgIGxldCBkbGluayA9IHYuZG93bmxvYWRVcmwgfHwgdi51cmw7CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2FwaScpIHsKICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLWFwaSIgZGF0YS1kaWQ9IiR7ZGlkfSIgZGF0YS1maWQ9IiR7ZmlkfSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHtkbGlua30iIGRhdGEtaW5kZXg9IiR7aX0iPiR7ZGxpbmt9PC9hPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tYnRuIGxpc3RlbmVyLWxpbmstYXBpLWJ0biIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iPuWkjeWItuaWh+S7tuWQjTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2FyaWEnKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaW5rID0gdGhpcy5jb252ZXJ0TGlua1RvQXJpYShkbGluaywgZmlsZW5hbWUsIG5hdmlnYXRvci51c2VyQWdlbnQpOwogICAgICAgICAgICAgICAgICAgIGFsaW5rQWxsVGV4dCArPSBhbGluayArICdcclxuJzsKICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLWFyaWEiIGhyZWY9IiR7YWxpbmt9IiB0aXRsZT0i54K55Ye75aSN5Yi2YXJpYTJj6ZO+5o6lIiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSIgZGF0YS1saW5rPSIke2FsaW5rfSI+JHtkZWNvZGVVUklDb21wb25lbnQoYWxpbmspfTwvYT4gPC9kaXY+YDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAncnBjJykgewogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YnV0dG9uIGNsYXNzPSJwbC1pdGVtLWxpbmsgbGlzdGVuZXItbGluay1ycGMgcGwtYnRuLXByaW1hcnkgcGwtYnRuLWluZm8iIGRhdGEtZmlsZW5hbWU9IiR7ZmlsZW5hbWV9IiBkYXRhLWxpbms9IiR7ZGxpbmt9Ij48ZW0gY2xhc3M9Imljb24gaWNvbi1kZXZpY2UiPjwvZW0+PHNwYW4gc3R5bGU9Im1hcmdpbi1sZWZ0OiA1cHg7Ij7mjqjpgIHliLAgUlBDIOS4i+i9veWZqDwvc3Bhbj48L2J1dHRvbj48L2Rpdj5gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdjdXJsJykgewogICAgICAgICAgICAgICAgICAgIGxldCBhbGluayA9IHRoaXMuY29udmVydExpbmtUb0N1cmwoZGxpbmssIGZpbGVuYW1lLCBuYXZpZ2F0b3IudXNlckFnZW50KTsKICAgICAgICAgICAgICAgICAgICBhbGlua0FsbFRleHQgKz0gYWxpbmsgKyAnXHJcbic7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxhIGNsYXNzPSJwbC1pdGVtLWxpbmsgbGlzdGVuZXItbGluay1hcmlhIiBocmVmPSIke2FsaW5rfSIgdGl0bGU9IueCueWHu+WkjeWItmN1cmzpk77mjqUiIGRhdGEtZmlsZW5hbWU9IiR7ZmlsZW5hbWV9IiBkYXRhLWxpbms9IiR7YWxpbmt9Ij4ke2RlY29kZVVSSUNvbXBvbmVudChhbGluayl9PC9hPiA8L2Rpdj5gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdiYycpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYWxpbmsgPSB0aGlzLmNvbnZlcnRMaW5rVG9CQyhkbGluaywgZmlsZW5hbWUsIG5hdmlnYXRvci51c2VyQWdlbnQpOwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIiBocmVmPSIke2RlY29kZVVSSUNvbXBvbmVudChhbGluayl9IiB0aXRsZT0i54K55Ye755So5q+U54m55b2X5pif5LiL6L29IiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSIgZGF0YS1saW5rPSIke2FsaW5rfSI+JHtkZWNvZGVVUklDb21wb25lbnQoYWxpbmspfTwvYT4gPC9kaXY+YDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGNvbnRlbnQgKz0gJzwvZGl2Pic7CiAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXJpYScpCiAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1leHRyYSI+PGJ1dHRvbiBjbGFzcz0icGwtYnRuLXByaW1hcnkgbGlzdGVuZXItY29weS1hb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HthbGlua0FsbFRleHR9Ij7lpI3liLblhajpg6jpk77mjqU8L2J1dHRvbj48YnV0dG9uIGNsYXNzPSJwbC1idG4tcHJpbWFyeSBwbC1idG4td2FybmluZyBsaXN0ZW5lci1vcGVuLXNldHRpbmciIHN0eWxlPSJtYXJnaW4tbGVmdDogMTBweDsiPuiuvue9rue7iOerr+exu+Wei++8iOW9k+WJjeS4uu+8miR7dGVybWluYWxUeXBlW2Jhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfdGVybWluYWxfdHlwZScpXX3vvIk8L2J1dHRvbj48L2Rpdj5gOwogICAgICAgICAgICByZXR1cm4gY29udGVudDsKICAgICAgICB9LAoKICAgICAgICBhc3luYyBzZW5kTGlua1RvUlBDKGZpbGVuYW1lLCBsaW5rKSB7CiAgICAgICAgICAgIGxldCBycGMgPSB7CiAgICAgICAgICAgICAgICBkb21haW46IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX2RvbWFpbicpLAogICAgICAgICAgICAgICAgcG9ydDogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfcG9ydCcpLAogICAgICAgICAgICAgICAgcGF0aDogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfcGF0aCcpLAogICAgICAgICAgICAgICAgdG9rZW46IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3Rva2VuJyksCiAgICAgICAgICAgICAgICBkaXI6IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX2RpcicpLAogICAgICAgICAgICB9OwoKICAgICAgICAgICAgbGV0IHVybCA9IGAke3JwYy5kb21haW59OiR7cnBjLnBvcnR9JHtycGMucGF0aH1gOwogICAgICAgICAgICBsZXQgcnBjRGF0YSA9IHsKICAgICAgICAgICAgICAgIGlkOiBuZXcgRGF0ZSgpLmdldFRpbWUoKSwKICAgICAgICAgICAgICAgIGpzb25ycGM6ICcyLjAnLAogICAgICAgICAgICAgICAgbWV0aG9kOiAnYXJpYTIuYWRkVXJpJywKICAgICAgICAgICAgICAgIHBhcmFtczogW2B0b2tlbjoke3JwYy50b2tlbn1gLCBbbGlua10sIHsKICAgICAgICAgICAgICAgICAgICBkaXI6IHJwYy5kaXIsCiAgICAgICAgICAgICAgICAgICAgb3V0OiBmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICBoZWFkZXI6IFtgUmVmZXJlcjogaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL2BdCiAgICAgICAgICAgICAgICB9XQogICAgICAgICAgICB9OwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IGJhc2UucG9zdCh1cmwsIHJwY0RhdGEsIHsiUmVmZXJlciI6ICJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vIn0sICcnKTsKICAgICAgICAgICAgICAgIGlmIChyZXMucmVzdWx0KSByZXR1cm4gJ3N1Y2Nlc3MnOwogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIGdldFNlbGVjdGVkTGlzdCgpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGxldCBzZWxlY3RlZExpc3QgPSBbXTsKICAgICAgICAgICAgICAgIGxldCByZWFjdERvbSA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IocGFuLmRvbS5saXN0KTsKICAgICAgICAgICAgICAgIGxldCByZWFjdE9iaiA9IGJhc2UuZmluZFJlYWN0KHJlYWN0RG9tLCAxKTsKICAgICAgICAgICAgICAgIGxldCBwcm9wcyA9IHJlYWN0T2JqLnBlbmRpbmdQcm9wczsKICAgICAgICAgICAgICAgIGlmIChwcm9wcykgewogICAgICAgICAgICAgICAgICAgIGxldCBmaWxlTGlzdCA9IHByb3BzLmRhdGFTb3VyY2UgfHwgW107CiAgICAgICAgICAgICAgICAgICAgbGV0IHNlbGVjdGVkS2V5cyA9IHByb3BzLnNlbGVjdGVkS2V5cy5zcGxpdCgnLCcpOwogICAgICAgICAgICAgICAgICAgIGZpbGVMaXN0LmZvckVhY2goKHZhbCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0ZWRLZXlzLmluY2x1ZGVzKHZhbC5maWxlSWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RlZExpc3QucHVzaCh2YWwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gc2VsZWN0ZWRMaXN0OwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gW107CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBkZXRlY3RQYWdlKCkgewogICAgICAgICAgICBsZXQgcGF0aCA9IGxvY2F0aW9uLnBhdGhuYW1lOwogICAgICAgICAgICBpZiAoL15cLyhkcml2ZSkvLnRlc3QocGF0aCkpIHJldHVybiAnaG9tZSc7CiAgICAgICAgICAgIGlmICgvXlwvKHN8c2hhcmUpXC8vLnRlc3QocGF0aCkpIHJldHVybiAnc2hhcmUnOwogICAgICAgICAgICByZXR1cm4gJyc7CiAgICAgICAgfSwKCiAgICAgICAgaXNPbmx5Rm9sZGVyKCkgewogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNlbGVjdExpc3QubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChzZWxlY3RMaXN0W2ldLnR5cGUgPT09ICdmaWxlJykgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0sCgogICAgICAgIHNob3dNYWluRGlhbG9nKHRpdGxlLCBodG1sLCBmb290ZXIpIHsKICAgICAgICAgICAgU3dhbC5maXJlKHsKICAgICAgICAgICAgICAgIHRpdGxlLAogICAgICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgICAgIGZvb3RlciwKICAgICAgICAgICAgICAgIGFsbG93T3V0c2lkZUNsaWNrOiBmYWxzZSwKICAgICAgICAgICAgICAgIHNob3dDbG9zZUJ1dHRvbjogdHJ1ZSwKICAgICAgICAgICAgICAgIHNob3dDb25maXJtQnV0dG9uOiBmYWxzZSwKICAgICAgICAgICAgICAgIHBvc2l0aW9uOiAndG9wJywKICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgcGFkZGluZzogJzE1cHggMjBweCA1cHgnLAogICAgICAgICAgICAgICAgY3VzdG9tQ2xhc3MsCiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIGFzeW5jIGluaXRQYW5MaW5rZXIoKSB7CiAgICAgICAgICAgIGJhc2UuaW5pdERlZmF1bHRDb25maWcoKTsKICAgICAgICAgICAgYmFzZS5hZGRQYW5MaW5rZXJTdHlsZSgpOwogICAgICAgICAgICBwdCA9IHRoaXMuZGV0ZWN0UGFnZSgpOwogICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0CiAgICAgICAgICAgIChgaHR0cHM6Ly9hcGkueW91eGlhb2hvdS5jb20vY29uZmlnL3YyL2FsaT92ZXI9JHt2ZXJzaW9ufSZhPSR7YXV0aG9yfWAsIHt9LCB7fSwgJ3RleHQnKTsKICAgICAgICAgICAgcGFuID0gSlNPTi5wYXJzZShiYXNlLmQocmVzKSk7CiAgICAgICAgICAgIE9iamVjdC5mcmVlemUgJiYgT2JqZWN0LmZyZWV6ZShwYW4pOwogICAgICAgICAgICBwYW4ubnVtID09PSBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX2luaXRfY29kZScpIHx8CiAgICAgICAgICAgIHBhbi5saWNlbnNlID09PSBiYXNlLmdldFZhbHVlKCdsaWNlbnNlJykgPyB0aGlzLmFkZEJ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gIH0sCgogICAgICAgIGFkZFBhZ2VMaXN0ZW5lcigpIHsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcucGwtYnV0dG9uLW1vZGUnLCAoZSkgPT4gewogICAgICAgICAgICAgICAgbW9kZSA9IGUudGFyZ2V0LmRhdGFzZXQubW9kZTsKICAgICAgICAgICAgICAgIFN3YWwuc2hvd0xvYWRpbmcoKTsKICAgICAgICAgICAgICAgIHRoaXMuZ2V0UENTTGluaygpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItbGluay1hcGknLCBhc3luYyAoZSkgPT4gewogICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgJCgnI2Rvd25sb2FkSWZyYW1lJykuYXR0cignc3JjJywgZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQubGluayk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1saW5rLWFyaWEsIC5saXN0ZW5lci1jb3B5LWFsbCcsIChlKSA9PiB7CiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICBiYXNlLnNldENsaXBib2FyZChkZWNvZGVVUklDb21wb25lbnQoZS50YXJnZXQuZGF0YXNldC5saW5rKSk7CiAgICAgICAgICAgICAgICAkKGUudGFyZ2V0KS50ZXh0KCflpI3liLbmiJDlip/vvIzlv6vljrvnspjotLTlkKfvvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1saW5rLXJwYycsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0ID0gJChlLmN1cnJlbnRUYXJnZXQpOwogICAgICAgICAgICAgICAgdGFyZ2V0LmZpbmQoJy5pY29uJykucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB0YXJnZXQuZmluZCgnLnBsLWxvYWRpbmcnKS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgIHRhcmdldC5wcmVwZW5kKGJhc2UuY3JlYXRlTG9hZGluZygpKTsKICAgICAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCB0aGlzLnNlbmRMaW5rVG9SUEMoZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQuZmlsZW5hbWUsIGUuY3VycmVudFRhcmdldC5kYXRhc2V0LmxpbmspOwogICAgICAgICAgICAgICAgaWYgKHJlcyA9PT0gJ3N1Y2Nlc3MnKSB7CiAgICAgICAgICAgICAgICAgICAgJCgnLmxpc3RlbmVyLXJwYy10YXNrJykuc2hvdygpOwogICAgICAgICAgICAgICAgICAgIHRhcmdldC5yZW1vdmVDbGFzcygncGwtYnRuLWRhbmdlcicpLmh0bWwoJ+WPkemAgeaIkOWKn++8jOW/q+WOu+eci+eci+WQp++8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LmFkZENsYXNzKCdwbC1idG4tZGFuZ2VyJykudGV4dCgn5Y+R6YCB5aSx6LSl77yM6K+35qOA5p+l5oKo55qEUlBD6YWN572u5L+h5oGv77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItc2VuZC1ycGMnLCAoZSkgPT4gewogICAgICAgICAgICAgICAgJCgnLmxpc3RlbmVyLWxpbmstcnBjJykuY2xpY2soKTsKICAgICAgICAgICAgICAgICQoZS50YXJnZXQpLnRleHQoJ+WPkemAgeWujOaIkO+8jOWPkemAgee7k+aenOingeS4iuaWueaMiemSru+8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLW9wZW4tc2V0dGluZycsICgpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2hvd1NldHRpbmcoKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLXJwYy10YXNrJywgKCkgPT4gewogICAgICAgICAgICAgICAgbGV0IHJwYyA9IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgICBkb21haW46IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX2RvbWFpbicpLAogICAgICAgICAgICAgICAgICAgIHBvcnQ6IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3BvcnQnKSwKICAgICAgICAgICAgICAgIH0pLCB1cmwgPSBgJHtwYW4uZH0vP3JwYz0ke2Jhc2UuZShycGMpfSMke2Jhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3Rva2VuJyl9YDsKICAgICAgICAgICAgICAgIEdNX29wZW5JblRhYih1cmwsIHthY3RpdmU6IHRydWV9KTsKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwKCiAgICAgICAgYWRkQnV0dG9uKCkgewogICAgICAgICAgICBpZiAoIXB0KSByZXR1cm47CiAgICAgICAgICAgIGxldCAkdG9vbFdyYXA7CiAgICAgICAgICAgIGxldCAkYnV0dG9uID0gJChgPGRpdiBjbGFzcz0idGlhbnlpLWJ1dHRvbiBwbC1idXR0b24iPuS4i+i9veWKqeaJizx1bCBjbGFzcz0icGwtZHJvcGRvd24tbWVudSIgc3R5bGU9InRvcDogMjZweDsiPjxsaSBjbGFzcz0icGwtZHJvcGRvd24tbWVudS1pdGVtIHBsLWJ1dHRvbi1tb2RlIiBkYXRhLW1vZGU9ImFwaSI+QVBJ5LiL6L29PC9saT48bGkgY2xhc3M9InBsLWRyb3Bkb3duLW1lbnUtaXRlbSBwbC1idXR0b24tbW9kZSIgZGF0YS1tb2RlPSJhcmlhIiA+QXJpYeS4i+i9vTwvbGk+PGxpIGNsYXNzPSJwbC1kcm9wZG93bi1tZW51LWl0ZW0gcGwtYnV0dG9uLW1vZGUiIGRhdGEtbW9kZT0icnBjIj5SUEPkuIvovb08L2xpPjxsaSBjbGFzcz0icGwtZHJvcGRvd24tbWVudS1pdGVtIHBsLWJ1dHRvbi1tb2RlIiBkYXRhLW1vZGU9ImN1cmwiPmNVUkzkuIvovb08L2xpPjxsaSBjbGFzcz0icGwtZHJvcGRvd24tbWVudS1pdGVtIHBsLWJ1dHRvbi1tb2RlIiBkYXRhLW1vZGU9ImJjIiA+QkPkuIvovb08L2xpPiR7cGFuLmNvZGUgPT0gMjAwICYmIHZlcnNpb24gPCBwYW4udmVyc2lvbiA/IHBhbi5uZXcgOiAnJ308L3VsPjwvZGl2PmApOwogICAgICAgICAgICBpZiAocHQgPT09ICdob21lJykgewogICAgICAgICAgICAgICAgYmFzZS5saXN0ZW5FbGVtZW50KHBhbi5idG4uaG9tZSwgKCkgPT4gewogICAgICAgICAgICAgICAgICAgICR0b29sV3JhcCA9ICQocGFuLmJ0bi5ob21lKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG9uJykubGVuZ3RoID09PSAwICYmICR0b29sV3JhcC5wcmVwZW5kKCRidXR0b24pOwogICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocHQgPT09ICdzaGFyZScpIHsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLnNoYXJlLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgJHRvb2xXcmFwID0gJChwYW4uYnRuLnNoYXJlKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG9uJykubGVuZ3RoID09PSAwICYmICR0b29sV3JhcC5wcmVwZW5kKCRidXR0b24pOwogICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgfQogICAgICAgICAgICBiYXNlLmNyZWF0ZURvd25sb2FkSWZyYW1lKCk7CiAgICAgICAgICAgIHRoaXMuYWRkUGFnZUxpc3RlbmVyKCk7CiAgICAgICAgfSwKCiAgICAgICAgYWRkSW5pdEJ1dHRvbigpIHsKICAgICAgICAgICAgaWYgKCFwdCkgcmV0dXJuOwogICAgICAgICAgICBsZXQgJHRvb2xXcmFwOwogICAgICAgICAgICBsZXQgJGJ1dHRvbiA9ICQoYDxkaXYgY2xhc3M9InRpYW55aS1idXR0b24gcGwtYnV0dG9uLWluaXQiPuS4i+i9veWKqeaJizwvZGl2PmApOwogICAgICAgICAgICBpZiAocHQgPT09ICdob21lJykgewogICAgICAgICAgICAgICAgYmFzZS5saXN0ZW5FbGVtZW50KHBhbi5idG4uaG9tZSwgKCkgPT4gewogICAgICAgICAgICAgICAgICAgICR0b29sV3JhcCA9ICQocGFuLmJ0bi5ob21lKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG9uLWluaXQnKS5sZW5ndGggPT09IDAgJiYgJHRvb2xXcmFwLnByZXBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChwdCA9PT0gJ3NoYXJlJykgewogICAgICAgICAgICAgICAgJGJ1dHRvbi5jc3MoeydtYXJnaW4tcmlnaHQnOiAnMTBweCd9KTsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLnNoYXJlLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgJHRvb2xXcmFwID0gJChwYW4uYnRuLnNoYXJlKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG9uLWluaXQnKS5sZW5ndGggPT09IDAgJiYgJHRvb2xXcmFwLnByZXBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgICAgICRidXR0b24uY2xpY2soKCkgPT4gYmFzZS5pbml0RGlhbG9nKCkpOwogICAgICAgIH0sCgogICAgICAgIGFzeW5jIGdldFRva2VuKCkgewogICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5nZXRGaW5hbFVybChwYW4ucGNzWzFdLCB7fSk7CiAgICAgICAgICAgIGxldCBhY2Nlc3NUb2tlbiA9IHJlcy5tYXRjaCgvYWNjZXNzVG9rZW49KFx3KykvKT8uWzFdOwogICAgICAgICAgICBhY2Nlc3NUb2tlbiAmJiBiYXNlLnNldFN0b3JhZ2UoJ2FjY2Vzc1Rva2VuJywgYWNjZXNzVG9rZW4pOwogICAgICAgICAgICByZXR1cm4gYWNjZXNzVG9rZW47CiAgICAgICAgfSwKCiAgICAgICAgYXN5bmMgZ2V0RmlsZVVybEJ5T25jZShpdGVtLCBpbmRleCwgdG9rZW4pIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGlmIChpdGVtLmRvd25sb2FkVXJsKSByZXR1cm4gewogICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgIGRvd25sb2FkVXJsOiBpdGVtLmRvd25sb2FkVXJsCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbGV0IHRpbWUgPSBEYXRlLm5vdygpLAogICAgICAgICAgICAgICAgICAgIGZpbGVJZCA9IGl0ZW0uZmlsZUlkLAogICAgICAgICAgICAgICAgICAgIG8gPSAiQWNjZXNzVG9rZW49IiArIHRva2VuICsgIiZUaW1lc3RhbXA9IiArIHRpbWUgKyAiJmZpbGVJZD0iICsgZmlsZUlkLAogICAgICAgICAgICAgICAgICAgIHVybCA9IHBhbi5wY3NbMl0gKyAnP2ZpbGVJZD0nICsgZmlsZUlkOwogICAgICAgICAgICAgICAgaWYgKGl0ZW0uc2hhcmVJZCkgewogICAgICAgICAgICAgICAgICAgIG8gPSAiQWNjZXNzVG9rZW49IiArIHRva2VuICsgIiZUaW1lc3RhbXA9IiArIHRpbWUgKyAiJmR0PTEmZmlsZUlkPSIgKyBmaWxlSWQgKyAiJnNoYXJlSWQ9IiArIGl0ZW0uc2hhcmVJZDsKICAgICAgICAgICAgICAgICAgICB1cmwgKz0gJyZkdD0xJnNoYXJlSWQ9JyArIGl0ZW0uc2hhcmVJZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGxldCBzaWduID0gbWQ1KG8pLnRvU3RyaW5nKCk7CiAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5nZXQodXJsLCB7CiAgICAgICAgICAgICAgICAgICAgImFjY2VwdCI6ICJhcHBsaWNhdGlvbi9qc29uO2NoYXJzZXQ9VVRGLTgiLAogICAgICAgICAgICAgICAgICAgICJzaWduLXR5cGUiOiAxLAogICAgICAgICAgICAgICAgICAgICJhY2Nlc3N0b2tlbiI6IHRva2VuLAogICAgICAgICAgICAgICAgICAgICJ0aW1lc3RhbXAiOiB0aW1lLAogICAgICAgICAgICAgICAgICAgICJzaWduYXR1cmUiOiBzaWduCiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGlmIChyZXMucmVzX2NvZGUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgZG93bmxvYWRVcmw6IHJlcy5maWxlRG93bmxvYWRVcmwKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChyZXMuZXJyb3JDb2RlID09PSAnSW52YWxpZFNlc3Npb25LZXknKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvd25sb2FkVXJsOiAn5o+Q56S677ya6K+35YWI55m75b2V572R55uY77yBJwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHJlcy5yZXNfY29kZSA9PT0gJ1NoYXJlTm90Rm91bmRGbGF0RGlyJykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZFVybDogJ+aPkOekuu+8muivt+WFiFvovazlrZhd5paH5Lu277yM8J+RieWJjeW+gFvmiJHnmoTnvZHnm5hd5Lit5LiL6L2977yBJwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZFVybDogJ+iOt+WPluS4i+i9veWcsOWdgOWksei0pe+8jOivt+WIt+aWsOmHjeivle+8gScKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgIGRvd25sb2FkVXJsOiAn6I635Y+W5LiL6L295Zyw5Z2A5aSx6LSl77yM6K+35Yi35paw6YeN6K+V77yBJwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIGFzeW5jIGdldFBDU0xpbmsoKSB7CiAgICAgICAgICAgIHNlbGVjdExpc3QgPSB0aGlzLmdldFNlbGVjdGVkTGlzdCgpOwogICAgICAgICAgICBpZiAoc2VsZWN0TGlzdC5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7flhYjli77pgInopoHkuIvovb3nmoTmlofku7bvvIEnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodGhpcy5pc09ubHlGb2xkZXIoKSkgewogICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muivt+aJk+W8gOaWh+S7tuWkueWQjuWLvumAieaWh+S7tu+8gScpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCB0b2tlbiA9IGJhc2UuZ2V0U3RvcmFnZSgnYWNjZXNzVG9rZW4nKSB8fCBhd2FpdCB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIGlmICghdG9rZW4pIHsKICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7flhYjnmbvlvZXnvZHnm5jvvIEnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgcXVldWUgPSBbXTsKICAgICAgICAgICAgc2VsZWN0TGlzdC5mb3JFYWNoKChpdGVtLCBpbmRleCkgPT4gewogICAgICAgICAgICAgICAgcXVldWUucHVzaCh0aGlzLmdldEZpbGVVcmxCeU9uY2UoaXRlbSwgaW5kZXgsIHRva2VuKSk7CiAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgY29uc3QgcmVzID0gYXdhaXQgUHJvbWlzZS5hbGwocXVldWUpOwogICAgICAgICAgICByZXMuZm9yRWFjaCh2YWwgPT4gewogICAgICAgICAgICAgICAgc2VsZWN0TGlzdFt2YWwuaW5kZXhdLmRvd25sb2FkVXJsID0gdmFsLmRvd25sb2FkVXJsOwogICAgICAgICAgICB9KTsKCiAgICAgICAgICAgIGxldCBodG1sID0gdGhpcy5nZW5lcmF0ZURvbShzZWxlY3RMaXN0KTsKICAgICAgICAgICAgdGhpcy5zaG93TWFpbkRpYWxvZyhwYW5bbW9kZV1bMF0sIGh0bWwsIHBhblttb2RlXVsxXSk7CiAgICAgICAgfSwKCiAgICAgICAgZ2VuZXJhdGVEb20obGlzdCkgewogICAgICAgICAgICBsZXQgY29udGVudCA9ICc8ZGl2IGNsYXNzPSJwbC1tYWluIj4nOwogICAgICAgICAgICBsZXQgYWxpbmtBbGxUZXh0ID0gJyc7CiAgICAgICAgICAgIGxpc3QuZm9yRWFjaCgodiwgaSkgPT4gewogICAgICAgICAgICAgICAgaWYgKHYuaXNGb2xkZXIpIHJldHVybjsKICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9IHYuZmlsZU5hbWU7CiAgICAgICAgICAgICAgICBsZXQgc2l6ZSA9IGJhc2Uuc2l6ZUZvcm1hdCh2LnNpemUpOwogICAgICAgICAgICAgICAgbGV0IGRsaW5rID0gdi5kb3dubG9hZFVybDsKICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXBpJykgewogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIGxpc3RlbmVyLWxpbmstYXBpIiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSIgZGF0YS1saW5rPSIke2RsaW5rfSIgZGF0YS1pbmRleD0iJHtpfSI+JHtkbGlua308L2E+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+YDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXJpYScpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYWxpbmsgPSB0aGlzLmNvbnZlcnRMaW5rVG9BcmlhKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgYWxpbmtBbGxUZXh0ICs9IGFsaW5rICsgJ1xyXG4nOwogICAgICAgICAgICAgICAgIC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l2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2N1cmwnKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaW5rID0gdGhpcy5jb252ZXJ0TGlua1RvQ3VybChkbGluaywgZmlsZW5hbWUsIG5hdmlnYXRvci51c2VyQWdlbnQpOwogICAgICAgICAgICAgICAgICAgIGFsaW5rQWxsVGV4dCArPSBhbGluayArICdcclxuJzsKICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLWFyaWEiIGhyZWY9IiR7YWxpbmt9IiB0aXRsZT0i54K55Ye75aSN5Yi2Y3VybOmTvuaOpSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGlua30iPiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rKX08L2E+IDwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2JjJykgewogICAgICAgICAgICAgICAgICAgIGxldCBhbGluayA9IHRoaXMuY29udmVydExpbmtUb0JDKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0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ZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfZG9tYWluJyksCiAgICAgICAgICAgICAgICBwb3J0OiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19wb3J0JyksCiAgICAgICAgICAgICAgICBwYXRoOiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19wYXRoJyksCiAgICAgICAgICAgICAgICB0b2tlbjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfdG9rZW4nKSwKICAgICAgICAgICAgICAgIGRpcjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfZGlyJyksCiAgICAgICAgICAgIH07CgogICAgICAgICAgICBsZXQgdXJsID0gYCR7cnBjLmRvbWFpbn06JHtycGMucG9ydH0ke3JwYy5wYXRofWA7CiAgICAgICAgICAgIGxldCBycGNEYXRhID0gewogICAgICAgICAgICAgICAgaWQ6IG5ldyBEYXRlKCkuZ2V0VGltZSgpLAogICAgICAgICAgICAgICAganNvbnJwYzogJzIuMCcsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICdhcmlhMi5hZGRVcmknLAogICAgICAgICAgICAgICAgcGFyYW1zOiBbYHRva2VuOiR7cnBjLnRva2VufWAsIFtsaW5rXSwgewogICAgICAgICAgICAgICAgICAgIGRpcjogcnBjLmRpciwKICAgICAgICAgICAgICAgICAgICBvdXQ6IGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgIGhlYWRlcjogW10KICAgICAgICAgICAgICAgIH1dCiAgICAgICAgICAgIH07CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0KHVybCwgcnBjRGF0YSwge30sICcnKTsKICAgICAgICAgICAgICAgIGlmIChyZXMucmVzdWx0KSByZXR1cm4gJ3N1Y2Nlc3MnOwogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIGdldFNlbGVjdGVkTGlzdCgpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIuYy1maWxlLWxpc3QiKS5fX3Z1ZV9fLnNlbGVjdGVkTGlzdDsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuIFtkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIuaW5mby1kZXRhaWwiKS5fX3Z1ZV9fLmZpbGVEZXRhaWxdOwogICAgICAgICAgICB9CiAgICAgICAgfSwKCiAgICAgICAgZGV0ZWN0UGFnZSgpIHsKICAgICAgICAgICAgbGV0IHBhdGggPSBsb2NhdGlvbi5wYXRobmFtZTsKICAgICAgICAgICAgaWYgKC9eXC93ZWJcL21haW4vLnRlc3QocGF0aCkpIHJldHVybiAnaG9tZSc7CiAgICAgICAgICAgIGlmICgvXlwvd2ViXC9zaGFyZS8udGVzdChwYXRoKSkgcmV0dXJuICdzaGFyZSc7CiAgICAgICAgICAgIHJldHVybiAnJzsKICAgICAgICB9LAoKICAgICAgICBpc09ubHlGb2xkZXIoKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2VsZWN0TGlzdC5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgaWYgKCFzZWxlY3RMaXN0W2ldLmlzRm9sZGVyKSByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfSwKCiAgICAgICAgc2hvd01haW5EaWFsb2codGl0bGUsIGh0bWwsIGZvb3RlcikgewogICAgICAgICAgICBTd2FsLmZpcmUoewogICAgICAgICAgICAgICAgdGl0bGUsCiAgICAgICAgICAgICAgICBodG1sLAogICAgICAgICAgICAgICAgZm9vdGVyLAogICAgICAgICAgICAgICAgYWxsb3dPdXRzaWRlQ2xpY2s6IGZhbHNlLAogICAgICAgICAgICAgICAgc2hvd0Nsb3NlQnV0dG9uOiB0cnVlLAogICAgICAgICAgICAgICAgc2hvd0NvbmZpcm1CdXR0b246IGZhbHNlLAogICAgICAgICAgICAgICAgcG9zaXRpb246ICd0b3AnLAogICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICBwYWRkaW5nOiAnMTVweCAyMHB4IDVweCcsCiAgICAgICAgICAgICAgICBjdXN0b21DbGFzcywKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwKCiAgICAgICAgYXN5bmMgaW5pdFBhbkxpbmtlcigpIHsKICAgICAgICAgICAgYmFzZS5pbml0RGVmYXVsdENvbmZpZygpOwogICAgICAgICAgICBiYXNlLmFkZFBhbkxpbmtlclN0eWxlKCk7CiAgICAgICAgICAgIHB0ID0gdGhpcy5kZXRlY3RQYWdlKCk7CiAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCBiYXNlLnBvc3QKICAgICAgICAgICAgKGBodHRwczovL2FwaS55b3V4aWFvaG91LmNvbS9jb25maWcvdjIvdGlhbnlpP3Zlcj0ke3ZlcnNpb259JmE9JHthdXRob3J9YCwge30sIHt9LCAndGV4dCcpOwogICAgICAgICAgICBwYW4gPSBKU09OLnBhcnNlKGJhc2UuZChyZXMpKTsKICAgICAgICAgICAgT2JqZWN0LmZyZWV6ZSAmJiBPYmplY3QuZnJlZXplKHBhbik7CiAgICAgICAgICAgIHBhbi5udW0gPT09IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfaW5pdF9jb2RlJykgfHwKICAgICAgICAgICAgcGFuLmxpY2Vuc2UgPT09IGJhc2UuZ2V0VmFsdWUoJ2xpY2Vuc2UnKSA/IHRoaXMuYWRkQnV0dG9uKCkgOiB0aGlzLmFkZEluaXRCdXR0b24oKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBiYXNlLmNyZWF0ZVRpcCgp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nBsLWJ1dHRvbi1tb2RlJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIG1vZGUgPSBlLnRhcmdldC5kYXRhc2V0Lm1vZGU7CiAgICAgICAgICAgICAgICBTd2FsLnNob3dMb2FkaW5nKCk7CiAgICAgICAgICAgICAgICB0aGlzLmdldFBDU0xpbmsoKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstYXBpJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICQoJyNkb3dubG9hZElmcmFtZScpLmF0dHIoJ3NyYycsIGUuY3VycmVudFRhcmdldC5kYXRhc2V0LmxpbmspOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItbGluay1hcGktYnRuJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0Q2xpcGJvYXJkKGUudGFyZ2V0LmRhdGFzZXQuZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgJChlLnRhcmdldCkudGV4dCgn5aSN5Yi25oiQ5YqfJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItbGluay1iYy1idG4nLCBhc3luYyAoZSkgPT4gewogICAgICAgICAgICAgICAgbGV0IG1pcnJvciA9IGJhc2UuZ2V0TWlycm9yTGlzdChlLnRhcmdldC5kYXRhc2V0LmRsaW5rLCBwYW4ubWlycm9yKTsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0Q2xpcGJvYXJkKG1pcnJvcik7CiAgICAgICAgICAgICAgICAkKGUudGFyZ2V0KS50ZXh0KCflpI3liLbmiJDlip8nKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1saW5rLWFyaWEsIC5saXN0ZW5lci1jb3B5LWFsbCcsIChlKSA9PiB7CiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICBiYXNlLnNldENsaXBib2FyZChkZWNvZGVVUklDb21wb25lbnQoZS50YXJnZXQuZGF0YXNldC5saW5rKSk7CiAgICAgICAgICAgICAgICAkKGUudGFyZ2V0KS50ZXh0KCflpI3liLbmiJDlip/vvIzlv6vljrvnspjotLTlkKfvvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1saW5rLXJwYycsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0ID0gJChlLmN1cnJlbnRUYXJnZXQpOwogICAgICAgICAgICAgICAgdGFyZ2V0LmZpbmQoJy5pY29uJykucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB0YXJnZXQuZmluZCgnLnBsLWxvYWRpbmcnKS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgIHRhcmdldC5wcmVwZW5kKGJhc2UuY3JlYXRlTG9hZGluZygpKTsKICAgICAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCB0aGlzLnNlbmRMaW5rVG9SUEMoZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQuZmlsZW5hbWUsIGUuY3VycmVudFRhcmdldC5kYXRhc2V0LmxpbmspOwogICAgICAgICAgICAgICAgaWYgKHJlcyA9PT0gJ3N1Y2Nlc3MnKSB7CiAgICAgICAgICAgICAgICAgICAgJCgnLmxpc3RlbmVyLXJwYy10YXNrJykuc2hvdygpOwogICAgICAgICAgICAgICAgICAgIHRhcmdldC5yZW1vdmVDbGFzcygncGwtYnRuLWRhbmdlcicpLmh0bWwoJ+WPkemAgeaIkOWKn++8jOW/q+WOu+eci+eci+WQp++8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LmFkZENsYXNzKCdwbC1idG4tZGFuZ2VyJykudGV4dCgn5Y+R6YCB5aSx6LSl77yM6K+35qOA5p+l5oKo55qEUlBD6YWN572u5L+h5oGv77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItc2VuZC1ycGMnLCAoZSkgPT4gewogICAgICAgICAgICAgICAgJCgnLmxpc3RlbmVyLWxpbmstcnBjJykuY2xpY2soKTsKICAgICAgICAgICAgICAgICQoZS50YXJnZXQpLnRleHQoJ+WPkemAgeWujOaIkO+8jOWPkemAgee7k+aenOingeS4iuaWueaMiemSru+8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLW9wZW4tc2V0dGluZycsICgpID0+IHsKICAgICAgICAgICAgICAgIGJhc2Uuc2hvd1NldHRpbmcoKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLXJwYy10YXNrJywgKCkgPT4gewogICAgICAgICAgICAgICAgbGV0IHJwYyA9IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgICBkb21haW46IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX2RvbWFpbicpLAogICAgICAgICAgICAgICAgICAgIHBvcnQ6IGJhc2UuZ2V0VmFsdWUoJ3NldHRpbmdfcnBjX3BvcnQnKSw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XRlbSBwbC1idXR0b24tbW9kZSIgZGF0YS1tb2RlPSJiYyIgPkJD5LiL6L29PC9saT4ke3Bhbi5jb2RlID09IDIwMCAmJiB2ZXJzaW9uIDwgcGFuLnZlcnNpb24gPyBwYW4ubmV3IDogJyd9PC91bD48L2Rpdj5gKTsKICAgICAgICAgICAgaWYgKHB0ID09PSAnaG9tZScpIHsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLmhvbWUsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAkdG9vbFdyYXAgPSAkKHBhbi5idG4uaG9tZSk7CiAgICAgICAgICAgICAgICAgICAgJCgnLnBsLWJ1dHRvbicpLmxlbmd0aCA9PT0gMCAmJiAkdG9vbFdyYXAucHJlcGVuZCgkYnV0dG9uKTsKICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHB0ID09PSAnc2hhcmUnKSB7CiAgICAgICAgICAgICAgICAkYnV0dG9uLmNzcyh7J21hcmdpbi1yaWdodCc6ICcxMHB4J30pOwogICAgICAgICAgICAgICAgYmFzZS5saXN0ZW5FbGVtZW50KHBhbi5idG4uc2hhcmUsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAkdG9vbFdyYXAgPSAkKHBhbi5idG4uc2hhcmUpOwogICAgICAgICAgICAgICAgICAgICQoJy5wbC1idXR0b24nKS5sZW5ndGggPT09IDAgJiYgJHRvb2xXcmFwLnByZXBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgICAgIGJhc2UuY3JlYXRlRG93bmxvYWRJZnJhbWUoKTsKICAgICAgICAgICAgdGhpcy5hZGRQYWdlTGlzdGVuZXIoKTsKICAgICAgICB9LAoKICAgICAgICBhZGRJbml0QnV0dG9uKCkgewogICAgICAgICAgICBpZiAoIXB0KSByZXR1cm47CiAgICAgICAgICAgIGxldCAkdG9vbFdyYXA7CiAgICAgICAgICAgIGxldCAkYnV0dG9uID0gJChgPGRpdiBjbGFzcz0ieHVubGVpLWJ1dHRvbiBwbC1idXR0b24taW5pdCI+PGkgY2xhc3M9InhscGZvbnQgeGxwLWRvd25sb2FkIj48L2k+PHNwYW4gc3R5bGU9ImZvbnQtc2l6ZTogMTNweDttYXJnaW4tbGVmdDogNnB4OyI+5LiL6L295Yqp5omLPC9zcGFuPjwvZGl2PmApOwogICAgICAgICAgICBpZiAocHQgPT09ICdob21lJykgewogICAgICAgICAgICAgICAgYmFzZS5saXN0ZW5FbGVtZW50KHBhbi5idG4uaG9tZSwgKCkgPT4gewogICAgICAgICAgICAgICAgICAgICR0b29sV3JhcCA9ICQocGFuLmJ0bi5ob21lKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG9uLWluaXQnKS5sZW5ndGggPT09IDAgJiYgJHRvb2xXcmFwLnByZXBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChwdCA9PT0gJ3NoYXJlJykgewogICAgICAgICAgICAgICAgJGJ1dHRvbi5jc3MoeydtYXJnaW4tcmlnaHQnOiAnMTBweCd9KTsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLnNoYXJlLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgJHRvb2xXcmFwID0gJChwYW4uYnRuLnNoYXJlKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG9uLWluaXQnKS5sZW5ndGggPT09IDAgJiYgJHRvb2xXcmFwLnByZXBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgICAgICRidXR0b24uY2xpY2soKCkgPT4gYmFzZS5pbml0RGlhbG9nKCkpOwogICAgICAgIH0sCgogICAgICAgIGdldFRva2VuKCkgewogICAgICAgICAgICBsZXQgY3JlZGVudGlhbHMgPSB7fSwgY2FwdGNoYSA9IHt9OwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxvY2FsU3RvcmFnZS5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgaWYgKC9eY3JlZGVudGlhbHNfLy50ZXN0KGxvY2FsU3RvcmFnZS5rZXkoaSkpKSB7CiAgICAgICAgICAgICAgICAgICAgY3JlZGVudGlhbHMgPSBiYXNlLmdldFN0b3JhZ2UobG9jYWxTdG9yYWdlLmtleShpKSk7CiAgICAgICAgICAgICAgICAgICAgYmFzZS5zZXRTdG9yYWdlKCcnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICgvXmNhcHRjaGFfW1x3XXsxNn0vLnRlc3QobG9jYWxTdG9yYWdlLmtleShpKSkpIHsKICAgICAgICAgICAgICAgICAgICBjYXB0Y2hhID0gYmFzZS5nZXRTdG9yYWdlKGxvY2FsU3RvcmFnZS5rZXkoaSkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCBkZXZpY2VpZCA9IC8oXHd7MzJ9KS8uZXhlYyhiYXNlLmdldFN0b3JhZ2UoJ2RldmljZWlkJykuc3BsaXQoJywnKSlbMF07CiAgICAgICAgICAgIGxldCB0b2tlbiA9IHsKICAgICAgICAgICAgICAgIGNyZWRlbnRpYWxzLAogICAgICAgICAgICAgICAgY2FwdGNoYSwKICAgICAgICAgICAgICAgIGRldmljZWlkCiAgICAgICAgICAgIH07CiAgICAgICAgICAgIHJldHVybiB0b2tlbjsKICAgICAgICB9LAoKICAgICAgICBhc3luYyBnZXRGaWxlVXJsQnlPbmNlKGl0ZW0sIGluZGV4LCB0b2tlbikgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgaWYgKGl0ZW0uZG93bmxvYWRVcmwpIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgaW5kZXgsCiAgICAgICAgICAgICAgICAgICAgZG93bmxvYWRVcmw6IGl0ZW0uZG93bmxvYWRVcmwKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5nZXQocGFuLnBjc1swXSArIGl0ZW0uaWQsIHsKICAgICAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IGAke3Rva2VuLmNyZWRlbnRpYWxzLnRva2VuX3R5cGV9ICR7dG9rZW4uY3JlZGVudGlhbHMuYWNjZXNzX3Rva2VufWAsCiAgICAgICAgICAgICAgICAgICAgJ2NvbnRlbnQtdHlwZSc6ICJhcHBsaWNhdGlvbi9qc29uIiwKICAgICAgICAgICAgICAgICAgICAneC1jYXB0Y2hhLXRva2VuJzogdG9rZW4uY2FwdGNoYS50b2tlbiwKICAgICAgICAgICAgICAgICAgICAneC1kZXZpY2UtaWQnOiB0b2tlbi5kZXZpY2VpZCwKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgaWYgKHJlcy53ZWJfY29udGVudF9saW5rKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvd25sb2FkVXJsOiByZXMud2ViX2NvbnRlbnRfbGluawogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZFVybDogJ+iOt+WPluS4i+i9veWcsOWdgOWksei0pe+8jOivt+WIt+aWsOmHjeivle+8gScKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbWVzc2FnZS5lcnJvcign5o+Q56S677ya6K+35YWI55m75b2V572R55uY5ZCO5Yi35paw6aG16Z2i77yBJyk7CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBhc3luYyBnZXRQQ1NMaW5rKCkgewogICAgICAgICAgICBzZWxlY3RMaXN0ID0gdGhpcy5nZXRTZWxlY3RlZExpc3QoKTsKICAgICAgICAgICAgaWYgKHNlbGVjdExpc3QubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbWVzc2FnZS5lcnJvcign5o+Q56S677ya6K+35YWI5Yu+6YCJ6KaB5LiL6L2955qE5paH5Lu277yBJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHRoaXMuaXNPbmx5Rm9sZGVyKCkpIHsKICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7fmiZPlvIDmlofku7blpLnlkI7li77pgInmlofku7bvvIEnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocHQgPT09ICdob21lJykgewogICAgICAgICAgICAgICAgbGV0IHF1ZXVlID0gW107CiAgICAgICAgICAgICAgICBsZXQgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICBzZWxlY3RMaXN0LmZvckVhY2goKGl0ZW0sIGluZGV4KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgcXVldWUucHVzaCh0aGlzLmdldEZpbGVVcmxCeU9uY2UoaXRlbSwgaW5kZXgsIHRva2VuKSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGNvbnN0IHJlcyA9IGF3YWl0IFByb21pc2UuYWxsKHF1ZXVlKTsKICAgICAgICAgICAgICAgIHJlcy5mb3JFYWNoKHZhbCA9PiB7CiAgICAgICAgICAgICAgICAgICAgc2VsZWN0TGlzdFt2YWwuaW5kZXhdLmRvd25sb2FkVXJsID0gdmFsLmRvd25sb2FkVXJsOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbWVzc2FnZS5lcnJvcign5o+Q56S677ya6K+35L+d5a2Y5Yiw6Ieq5bex572R55uY5ZCO5Y67572R55uY5Li76aG15LiL6L2977yBJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IGh0bWwgPSB0aGlzLmdlbmVyYXRlRG9tKHNlbGVjdExpc3QpOwogICAgICAgICAgICB0aGlzLnNob3dNYWluRGlhbG9nKHBhblttb2RlXVswXSwgaHRtbCwgcGFuW21vZGVdWzFdKTsKCiAgICAgICAgfSwKCiAgICAgICAgZ2VuZXJhdGVEb20obGlzdCkgewogICAgICAgICAgICBsZXQgY29udGVudCA9ICc8ZGl2IGNsYXNzPSJwbC1tYWluIj4nOwogICAgICAgICAgICBsZXQgYWxpbmtBbGxUZXh0ID0gJyc7CiAgICAgICAgICAgIGxpc3QuZm9yRWFjaCgodiwgaSkgPT4gewogICAgICAgICAgICAgICAgaWYgKHYua2luZCA9PT0gJ2RyaXZlI2ZvbGRlcicpIHJldHVybjsKICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9IHYubmFtZTsKICAgICAgICAgICAgICAgIGxldCBzaXplID0gYmFzZS5zaXplRm9ybWF0KCt2LnNpemUpOwogICAgICAgICAgICAgICAgbGV0IGRsaW5rID0gdi5kb3dubG9hZFVybDsKICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXBpJykgewogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIGxpc3RlbmVyLWxpbmstYXBpIiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSIgZGF0YS1saW5rPSIke2RsaW5rfSIgZGF0YS1pbmRleD0iJHtpfSI+JHtkbGlua308L2E+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1idG4gbGlzdGVuZXItbGluay1hcGktYnRuIiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSI+5aSN5Yi25paH5Lu25ZCNPC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+YDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXJpYScpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYWxpbmsgPSB0aGlzLmNvbnZlcnRMaW5rVG9BcmlhKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgYWxpbmtBbGxUZXh0ICs9IGFsaW5rICsgJ1xyXG4nOwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIGxpc3RlbmVyLWxpbmstYXJpYSIgaHJlZj0iJHthbGlua30iIHRpdGxlPSLngrnlh7vlpI3liLZhcmlhMmPpk77mjqUiIGRhdGEtZmlsZW5hbWU9IiR7ZmlsZW5hbWV9IiBkYXRhLWxpbms9IiR7YWxpbmt9Ij4ke2RlY29kZVVSSUNvbXBvbmVudChhbGluayl9PC9hPiA8L2Rpdj5gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdycGMnKSB7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxidXR0b24gY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLXJwYyBwbC1idG4tcHJpbWFyeSBwbC1idG4taW5mbyIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHtkbGlua30iPjxlbSBjbGFzcz0iaWNvbiBpY29uLWRldmljZSI+PC9lbT48c3BhbiBzdHlsZT0ibWFyZ2luLWxlZnQ6IDVweDsiPuaOqOmAgeWIsCBSUEMg5LiL6L295ZmoPC9zcGFuPjwvYnV0dG9uPjwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2N1cmwnKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaW5rID0gdGhpcy5jb252ZXJ0TGlua1RvQ3VybChkbGluaywgZmlsZW5hbWUsIG5hdmlnYXRvci51c2VyQWdlbnQpOwogICAgICAgICAgICAgICAgICAgIGFsaW5rQWxsVGV4dCArPSBhbGluayArICdcclxuJzsKICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLWFyaWEiIGhyZWY9IiR7YWxpbmt9IiB0aXRsZT0i54K55Ye75aSN5Yi2Y3VybOmTvuaOpSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGlua30iPiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rKX08L2E+IDwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2JjJykgewogICAgICAgICAgICAgICAgICAgIGxldCBhbGluayA9IHRoaXMuY29udmVydExpbmtUb0JDKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxhIGNsYXNzPSJwbC1pdGVtLWxpbmsiIGhyZWY9IiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rKX0iIHRpdGxlPSLngrnlh7vnlKjmr5TnibnlvZfmmJ/kuIvovb0iIGRhdGEtZmlsZW5hbWU9IiR7ZmlsZW5hbWV9IiBkYXRhLWxpbms9IiR7YWxpbmt9Ij4ke2RlY29kZVVSSUNvbXBvbmVudChhbGluayl9PC9hPiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLWJ0biBsaXN0ZW5lci1saW5rLWJjLWJ0biIgZGF0YS1kbGluaz0iJHtkbGlua30iPuWkjeWItumVnOWDj+WcsOWdgDwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICA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sKCiAgICAgICAgICAgIGxldCB1cmwgPSBgJHtycGMuZG9tYWlufToke3JwYy5wb3J0fSR7cnBjLnBhdGh9YDsKICAgICAgICAgICAgbGV0IHJwY0RhdGEgPSB7CiAgICAgICAgICAgICAgICBpZDogbmV3IERhdGUoKS5nZXRUaW1lKCksCiAgICAgICAgICAgICAgICBqc29ucnBjOiAnMi4wJywKICAgICAgICAgICAgICAgIG1ldGhvZDogJ2FyaWEyLmFkZFVyaScsCiAgICAgICAgICAgICAgICBwYXJhbXM6IFtgdG9rZW46JHtycGMudG9rZW59YCwgW2xpbmtdLCB7CiAgICAgICAgICAgICAgICAgICAgZGlyOiBycGMuZGlyLAogICAgICAgICAgICAgICAgICAgIG91dDogZmlsZW5hbWUsCiAgICAgICAgICAgICAgICAgICAgaGVhZGVyOiBbXQogICAgICAgICAgICAgICAgfV0KICAgICAgICAgICAgfTsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCBiYXNlLnBvc3QodXJsLCBycGNEYXRhLCB7fSwgJycpOwogICAgICAgICAgICAgICAgaWYgKHJlcy5yZXN1bHQpIHJldHVybiAnc3VjY2Vzcyc7CiAgICAgICAgICAgICAgICByZXR1cm4gJ2ZhaWwnOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gJ2ZhaWwnOwogICAgICAgICAgICB9CiAgICAgICAgfSwKCiAgICAgICAgZ2V0U2VsZWN0ZWRMaXN0KCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbGV0IGRvbXMgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCcucGFuLWxpc3QgbGknKTsKICAgICAgICAgICAgICAgIGxldCBzZWxlY3RlZExpc3QgPSBbXTsKICAgICAgICAgICAgICAgIGZvciAobGV0IGRvbSBvZiBkb21zKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGRvbVZ1ZSA9IGRvbS5fX3Z1ZV9fOwogICAgICAgICAgICAgICAgICAgIGlmIChkb21WdWUuc2VsZWN0ZWQuaW5jbHVkZXMoZG9tVnVlLmluZm8uaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkTGlzdC5wdXNoKGRvbVZ1ZS5pbmZvKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gc2VsZWN0ZWRMaXN0OwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gW107CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBkZXRlY3RQYWdlKCkgewogICAgICAgICAgICBsZXQgcGF0aCA9IGxvY2F0aW9uLnBhdGhuYW1lOwogICAgICAgICAgICBpZiAoL15cLyQvLnRlc3QocGF0aCkpIHJldHVybiAnaG9tZSc7CiAgICAgICAgICAgIGlmICgvXlwvKHN8c2hhcmUpXC8vLnRlc3QocGF0aCkpIHJldHVybiAnc2hhcmUnOwogICAgICAgICAgICByZXR1cm4gJyc7CiAgICAgICAgfSwKCiAgICAgICAgaXNPbmx5Rm9sZGVyKCkgewogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNlbGVjdExpc3QubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChzZWxlY3RMaXN0W2ldLmtpbmQgPT09ICdkcml2ZSNmaWxlJykgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0sCgogICAgICAgIHNob3dNYWluRGlhbG9nKHRpdGxlLCBodG1sLCBmb290ZXIpIHsKICAgICAgICAgICAgU3dhbC5maXJlKHsKICAgICAgICAgICAgICAgIHRpdGxlLAogICAgICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgICAgIGZvb3RlciwKICAgICAgICAgICAgICAgIGFsbG93T3V0c2lkZUNsaWNrOiBmYWxzZSwKICAgICAgICAgICAgICAgIHNob3dDbG9zZUJ1dHRvbjogdHJ1ZSwKICAgICAgICAgICAgICAgIHNob3dDb25maXJtQnV0dG9uOiBmYWxzZSwKICAgICAgICAgICAgICAgIHBvc2l0aW9uOiAndG9wJywKICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgcGFkZGluZzogJzE1cHggMjBweCA1cHgnLAogICAgICAgICAgICAgICAgY3VzdG9tQ2xhc3MsCiAgICAgICAgICAgIH0pOwogICAgICAgIH0sCgogICAgICAgIGFzeW5jIGluaXRQYW5MaW5rZXIoKSB7CiAgICAgICAgICAgIGJhc2UuaW5pdERlZmF1bHRDb25maWcoKTsKICAgICAgICAgICAgYmFzZS5hZGRQYW5MaW5rZXJTdHlsZSgpOwogICAgICAgICAgICBwdCA9IHRoaXMuZGV0ZWN0UGFnZSgpOwogICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0CiAgICAgICAgICAgIChgaHR0cHM6Ly9hcGkueW91eGlhb2hvdS5jb20vY29uZmlnL3YyL3h1bmxlaT92ZXI9JHt2ZXJzaW9ufSZhPSR7YXV0aG9yfWAsIHt9LCB7fSwgJ3RleHQnKTsKICAgICAgICAgICAgcGFuID0gSlNPTi5wYXJzZShiYXNlLmQocmVzKSk7CiAgICAgICAgICAgIE9iamVjdC5mcmVlemUgJiYgT2JqZWN0LmZyZWV6ZShwYW4pOwogICAgICAgICAgICBwYW4ubnVtID09PSBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX2luaXRfY29kZScpIHx8CiAgICAgICAgICAgIHBhbi5saWNlbnNlID09PSBiYXNlLmdldFZhbHVlKCdsaWNlbnNlJykgPyB0aGlzLmFkZEJ1dHRvbigpIDogdGhpcy5hZGRJbml0QnV0dG9uKCk7CiAgICAgICAgICAgIGJhc2UuY3JlYXRlVGlwKCk7CiAgICAgICAgICAgIGJhc2UucmVnaXN0ZXJNZW51Q29tbWFuZCgpOwogICAgICAgIH0KICAgIH07CgogICAgbGV0IHF1YXJrID0gewoKICAgICAgICBjb252ZXJ0TGlua1RvQXJpYShsaW5rLCBmaWxlbmFtZSwgdWEpIHsKICAgICAgICAgICAgZmlsZW5hbWUgPSBiYXNlLmZpeEZpbGVuYW1lKGZpbGVuYW1lKTsKICAgICAgICAgICAgcmV0dXJuIGVuY29kZVVSSUNvbXBvbmVudChgYXJpYTJjICIke2xpbmt9IiAtLW91dCAiJHtmaWxlbmFtZX0iIC0taGVhZGVyICJDb29raWU6ICR7ZG9jdW1lbnQuY29va2llfSJgKTsKICAgICAgICB9LAoKICAgICAgICBjb252ZXJ0TGlua1RvQkMobGluaywgZmlsZW5hbWUsIHVhKSB7CiAgICAgICAgICAgIGxldCBiYyA9IGBBQS8ke2VuY29kZVVSSUNvbXBvbmVudChmaWxlbmFtZSl9Lz91cmw9JHtlbmNvZGVVUklDb21wb25lbnQobGluayl9JmNvb2tpZT0ke2VuY29kZVVSSUNvbXBvbmVudChkb2N1bWVudC5jb29raWUpfVpaYDsKICAgICAgICAgICAgcmV0dXJuIGVuY29kZVVSSUNvbXBvbmVudChgYmM6Ly9odHRwLyR7YmFzZS5lKGJjKX1gKTsKICAgICAgICB9LAoKICAgICAgICBjb252ZXJ0TGlua1RvQ3VybChsaW5rLCBmaWxlbmFtZSwgdWEpIHsKICAgICAgICAgICAgbGV0IHRlcm1pbmFsID0gYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ190ZXJtaW5hbF90eXBlJyk7CiAgICAgICAgICAgIGZpbGVuYW1lID0gYmFzZS5maXhGaWxlbmFtZShmaWxlbmFtZSk7CiAgICAgICAgICAgIHJldHVybiBlbmNvZGVVUklDb21wb25lbnQoYCR7dGVybWluYWwgIT09ICd3cCcgPyAnY3VybCcgOiAnY3VybC5leGUnfSAtTCAtQyAtICIke2xpbmt9IiAtbyAiJHtmaWxlbmFtZX0iIC1iICIke2RvY3VtZW50LmNvb2tpZX0iYCk7CiAgICAgICAgfSwKCiAgICAgICAgYWRkUGFnZUxpc3RlbmVyKCkgewogICAgICAgICAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcignaGFzaGNoYW5nZScsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgaG9tZSA9ICdodHRwczovL3Bhbi5xdWFyay5jbi9saXN0Iy8nLCBhbGwgPSAnaHR0cHM6Ly9wYW4ucXVhcmsuY24vbGlzdCMvbGlzdC9hbGwnOwogICAgICAgICAgICAgICAgaWYgKGUub2xkVVJMID09PSBob21lICYmIGUubmV3VVJMID09PSBhbGwpIHJldHVybjsKICAgICAgICAgICAgICAgIGF3YWl0IGJhc2Uuc2xlZXAoMTUwKTsKICAgICAgICAgICAgICAgIGlmICgkKCcucXVhcmstYnV0dG9uJykubGVuZ3RoID4gMCkgcmV0dXJuOwogICAgICAgICAgICAgICAgcGFuLm51bSA9PT0gYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19pbml0X2NvZGUnKSB8fAogICAgICAgICAgICAgICAgcGFuLmxpY2Vuc2UgPT09IGJhc2UuZ2V0VmFsdWUoJ2xpY2Vuc2UnKSA/IHRoaXMuYWRkQnV0dG9uKCkgOiB0aGlzLmFkZEluaXRCdXR0b24oKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLnBsLWJ1dHRvbi1tb2RlJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIG1vZGUgPSBlLnRhcmdldC5kYXRhc2V0Lm1vZGU7CiAgICAgICAgICAgICAgICBTd2FsLnNob3dMb2FkaW5nKCk7CiAgICAgICAgICAgICAgICB0aGlzLmdldFBDU0xpbmsoKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstYXBpJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICQoJyNkb3dubG9hZElmcmFtZScpLmF0dHIoJ3NyYycsIGUuY3VycmVudFRhcmdldC5kYXRhc2V0LmxpbmspOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItbGluay1hcmlhLCAubGlzdGVuZXItY29weS1hbGwnLCAoZSkgPT4gewogICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgYmFzZS5zZXRDbGlwYm9hcmQoZGVjb2RlVVJJQ29tcG9uZW50KGUudGFyZ2V0LmRhdGFzZXQubGluaykpOwogICAgICAgICAgICAgICAgJChlLnRhcmdldCkudGV4dCgn5aSN5Yi25oiQ5Yqf77yM5b+r5Y6757KY6LS05ZCn77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItbGluay1ycGMnLCBhc3luYyAoZSkgPT4gewogICAgICAgICAgICAgICAgbGV0IHRhcmdldCA9ICQoZS5jdXJyZW50VGFyZ2V0KTsKICAgICAgICAgICAgICAgIHRhcmdldC5maW5kKCcuaWNvbicpLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgdGFyZ2V0LmZpbmQoJy5wbC1sb2FkaW5nJykucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB0YXJnZXQucHJlcGVuZChiYXNlLmNyZWF0ZUxvYWRpbmcoKSk7CiAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgdGhpcy5zZW5kTGlua1RvUlBDKGUuY3VycmVudFRhcmdldC5kYXRhc2V0LmZpbGVuYW1lLCBlLmN1cnJlbnRUYXJnZXQuZGF0YXNldC5saW5rKTsKICAgICAgICAgICAgICAgIGlmIChyZXMgPT09ICdzdWNjZXNzJykgewogICAgICAgICAgICAgICAgICAgICQoJy5saXN0ZW5lci1ycGMtdGFzaycpLnNob3coKTsKICAgICAgICAgICAgICAgICAgICB0YXJnZXQucmVtb3ZlQ2xhc3MoJ3BsLWJ0bi1kYW5nZXInKS5odG1sKCflj5HpgIHmiJDlip/vvIzlv6vljrvnnIvnnIvlkKfvvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgIHRhcmdldC5hZGRDbGFzcygncGwtYnRuLWRhbmdlcicpLnRleHQoJ+WPkemAgeWksei0pe+8jOivt+ajgOafpeaCqOeahFJQQ+mFjee9ruS/oeaBr++8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLXNlbmQtcnBjJywgKGUpID0+IHsKICAgICAgICAgICAgICAgICQoJy5saXN0ZW5lci1saW5rLXJwYycpLmNsaWNrKCk7CiAgICAgICAgICAgICAgICAkKGUudGFyZ2V0KS50ZXh0KCflj5HpgIHlrozmiJDvvIzlj5HpgIHnu5Pmnpzop4HkuIrmlrnmjInpkq7vvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1vcGVuLXNldHRpbmcnLCAoKSA9PiB7CiAgICAgICAgICAgICAgICBiYXNlLnNob3dTZXR0aW5nKCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1ycGMtdGFzaycsICgpID0+IHsKICAgICAgICAgICAgICAgIGxldCBycGMgPSBKU09OLnN0cmluZ2lmeSh7CiAgICAgICAgICAgICAgICAgICAgZG9tYWluOiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19kb21haW4nKSwKICAgICAgICAgICAgICAgICAgICBwb3J0OiBi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CA9ICQocGFuLmJ0bi5ob21lKTsKICAgICAgICAgICAgICAgICAgICAkKCcucGwtYnV0dG9uJykubGVuZ3RoID09PSAwICYmICR0b29sV3JhcC5wcmVwZW5kKCRidXR0b24pOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHB0ID09PSAnc2hhcmUnKSB7CiAgICAgICAgICAgICAgICAkYnV0dG9uLmNzcyh7J21hcmdpbi1yaWdodCc6ICcxMHB4J30pOwogICAgICAgICAgICAgICAgYmFzZS5saXN0ZW5FbGVtZW50KHBhbi5idG4uc2hhcmUsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAkdG9vbFdyYXAgPSAkKHBhbi5idG4uc2hhcmUpOwogICAgICAgICAgICAgICAgICAgICQoJy5wbC1idXR0b24nKS5sZW5ndGggPT09IDAgJiYgJHRvb2xXcmFwLnByZXBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIGFkZEluaXRCdXR0b24oKSB7CiAgICAgICAgICAgIGlmICghcHQpIHJldHVybjsKICAgICAgICAgICAgbGV0ICR0b29sV3JhcDsKICAgICAgICAgICAgbGV0ICRidXR0b24gPSAkKGA8ZGl2IGNsYXNzPSJxdWFyay1idXR0b24gcGwtYnV0dG9uLWluaXQiPjxzdmcgd2lkdGg9IjIyIiBoZWlnaHQ9IjIyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSIjNTU1IiBzdHJva2Utd2lkdGg9IjIiPjxwYXRoIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZD0iTTkgMTJsMiAyIDItMnoiLz48cGF0aCBkPSJNMTQgOGgxLjU1M2MuODUgMCAxLjE2LjA5MyAxLjQ3LjI2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gICAgICAgICR0b29sV3JhcCA9ICQocGFuLmJ0bi5zaGFyZSk7CiAgICAgICAgICAgICAgICAgICAgJCgnLnBsLWJ1dHRvbi1pbml0JykubGVuZ3RoID09PSAwICYmICR0b29sV3JhcC5wcmVwZW5kKCRidXR0b24pOwogICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgfQogICAgICAgICAgICAkYnV0dG9uLmNsaWNrKCgpID0+IGJhc2UuaW5pdERpYWxvZygpKTsKICAgICAgICB9LAoKICAgICAgICBhc3luYyBnZXRQQ1NMaW5rKCkgewogICAgICAgICAgICBzZWxlY3RMaXN0ID0gdGhpcy5nZXRTZWxlY3RlZExpc3QoKTsKICAgICAgICAgICAgaWYgKHNlbGVjdExpc3QubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbWVzc2FnZS5lcnJvcign5o+Q56S677ya6K+35YWI5Yu+6YCJ6KaB5LiL6L2955qE5paH5Lu277yBJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHRoaXMuaXNPbmx5Rm9sZGVyKCkpIHsKICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7fmiZPlvIDmlofku7blpLnlkI7li77pgInmlofku7bvvIEnKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgZmlkcyA9IFtdOwogICAgICAgICAgICBzZWxlY3RMaXN0LmZvckVhY2godmFsID0+IHsKICAgICAgICAgICAgICAgIGZpZHMucHVzaCh2YWwuZmlkKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChwdCA9PT0gJ2hvbWUnKSB7CiAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0KHBhbi5wY3NbMF0sIHsKICAgICAgICAgICAgICAgICAgICAiZmlkcyI6IGZpZHMKICAgICAgICAgICAgICAgIH0sIHsiY29udGVudC10eXBlIjogImFwcGxpY2F0aW9uL2pzb247Y2hhcnNldD11dGYtOCIsICJ1c2VyLWFnZW50IjogcGFuLnVhfSk7CiAgICAgICAgICAgICAgICBpZiAocmVzLmNvZGUgPT09IDMxMDAxKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muivt+WFiOeZu+W9lee9keebmO+8gScpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHJlcy5jb2RlICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1lc3NhZ2UuZXJyb3IoJ+aPkOekuu+8muiOt+WPlumTvuaOpeWksei0pe+8gScpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IGh0bWwgPSB0aGlzLmdlbmVyYXRlRG9tKHJlcy5kYXRhKTsKICAgICAgICAgICAgICAgIHRoaXMuc2hvd01haW5EaWFsb2cocGFuW21vZGVdWzBdLCBodG1sLCBwYW5bbW9kZV1bMV0pOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbWVzc2FnZS5lcnJvcign5o+Q56S677ya6K+35L+d5a2Y5Yiw6Ieq5bex572R55uY5ZCO5Y67572R55uY5Li76aG15LiL6L2977yBJyk7CiAgICAgICAgICAgICAgICBhd2FpdCBiYXNlLnNsZWVwKDEwMDApOwogICAgICAgICAgICAgICAgZG9jdW1lbnQucXVlcnlTZWxlY3RvcignLmZpbGUtaW5mb19yJykuY2xpY2soKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIGdlbmVyYXRlRG9tKGxpc3QpIHsKICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSAnPGRpdiBjbGFzcz0icGwtbWFpbiI+JzsKICAgICAgICAgICAgbGV0IGFsaW5rQWxsVGV4dCA9ICcnOwogICAgICAgICAgICBsaXN0LmZvckVhY2goKHYsIGkpID0+IHsKICAgICAgICAgICAgICAgIGlmICh2LmZpbGUgPT09IGZhbHNlKSByZXR1cm47CiAgICAgICAgICAgICAgICBsZXQgZmlsZW5hbWUgPSB2LmZpbGVfbmFtZTsKICAgICAgICAgICAgICAgIGxldCBmaWQgPSB2LmZpZDsKICAgICAgICAgICAgICAgIGxldCBzaXplID0gYmFzZS5zaXplRm9ybWF0KHYuc2l6ZSk7CiAgICAgICAgICAgICAgICBsZXQgZGxpbmsgPSB2LmRvd25sb2FkX3VybDsKICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXBpJykgewogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIGxpc3RlbmVyLWxpbmstYXBpIiBkYXRhLWZpZD0iJHtmaWR9IiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSIgZGF0YS1saW5rPSIke2RsaW5rfSIgZGF0YS1pbmRleD0iJHtpfSI+JHtkbGlua308L2E+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+YDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXJpYScpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYWxpbmsgPSB0aGlzLmNvbnZlcnRMaW5rVG9BcmlhKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgYWxpbmtBbGxUZXh0ICs9IGFsaW5rICsgJ1xyXG4nOwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIGxpc3RlbmVyLWxpbmstYXJpYSIgaHJlZj0iJHthbGlua30iIHRpdGxlPSLngrnlh7vlpI3liLZhcmlhMmPpk77mjqUiIGRhdGEtZmlsZW5hbWU9IiR7ZmlsZW5hbWV9IiBkYXRhLWxpbms9IiR7YWxpbmt9Ij4ke2RlY29kZVVSSUNvbXBvbmVudChhbGluayl9PC9hPiA8L2Rpdj5gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdycGMnKSB7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxidXR0b24gY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLXJwYyBwbC1idG4tcHJpbWFyeSBwbC1idG4taW5mbyIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHtkbGlua30iPjxlbSBjbGFzcz0iaWNvbiBpY29uLWRldmljZSI+PC9lbT48c3BhbiBzdHlsZT0ibWFyZ2luLWxlZnQ6IDVweDsiPuaOqOmAgeWIsCBSUEMg5LiL6L295ZmoPC9zcGFuPjwvYnV0dG9uPjwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2N1cmwnKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaW5rID0gdGhpcy5jb252ZXJ0TGlua1RvQ3VybChkbGluaywgZmlsZW5hbWUsIG5hdmlnYXRvci51c2VyQWdlbnQpOwogICAgICAgICAgICAgICAgICAgIGFsaW5rQWxsVGV4dCArPSBhbGluayArICdcclxuJzsKICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLWFyaWEiIGhyZWY9IiR7YWxpbmt9IiB0aXRsZT0i54K55Ye75aSN5Yi2Y3VybOmTvuaOpSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGlua30iPiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rKX08L2E+IDwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2JjJykgewogICAgICAgICAgICAgICAgICAgIGxldCBhbGluayA9IHRoaXMuY29udmVydExpbmtUb0JDKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAg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ICAgICAgICAgICBwb3J0OiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19wb3J0JyksCiAgICAgICAgICAgICAgICBwYXRoOiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19wYXRoJyksCiAgICAgICAgICAgICAgICB0b2tlbjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfdG9rZW4nKSwKICAgICAgICAgICAgICAgIGRpcjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfZGlyJyksCiAgICAgICAgICAgIH07CgogICAgICAgICAgICBsZXQgdXJsID0gYCR7cnBjLmRvbWFpbn06JHtycGMucG9ydH0ke3JwYy5wYXRofWA7CiAgICAgICAgICAgIGxldCBycGNEYXRhID0gewogICAgICAgICAgICAgICAgaWQ6IG5ldyBEYXRlKCkuZ2V0VGltZSgpLAogICAgICAgICAgICAgICAganNvbnJwYzogJzIuMCcsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICdhcmlhMi5hZGRVcmknLAogICAgICAgICAgICAgICAgcGFyYW1zOiBbYHRva2VuOiR7cnBjLnRva2VufWAsIFtsaW5rXSwgewogICAgICAgICAgICAgICAgICAgIGRpcjogcnBjLmRpciwKICAgICAgICAgICAgICAgICAgICBvdXQ6IGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgIGhlYWRlcjogW2BDb29raWU6ICR7ZG9jdW1lbnQuY29va2llfWBdCiAgICAgICAgICAgICAgICB9XQogICAgICAgICAgICB9OwogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IGJhc2UucG9zdCh1cmwsIHJwY0RhdGEsIHsiQ29va2llIjogZG9jdW1lbnQuY29va2llfSwgJycpOwogICAgICAgICAgICAgICAgaWYgKHJlcy5yZXN1bHQpIHJldHVybiAnc3VjY2Vzcyc7CiAgICAgICAgICAgICAgICByZXR1cm4gJ2ZhaWwnOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gJ2ZhaWwnOwogICAgICAgICAgICB9CiAgICAgICAgfSwKCiAgICAgICAgZ2V0U2VsZWN0ZWRMaXN0KCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbGV0IHNlbGVjdGVkTGlzdCA9IFtdOwogICAgICAgICAgICAgICAgbGV0IHJlYWN0RG9tID0gZG9jdW1lbnQuZ2V0RWxlbWVudHNCeUNsYXNzTmFtZSgnZmlsZS1saXN0JylbMF07CiAgICAgICAgICAgICAgICBsZXQgcmVhY3RPYmogPSBiYXNlLmZpbmRSZWFjdChyZWFjdERvbSk7CiAgICAgICAgICAgICAgICBsZXQgcHJvcHMgPSByZWFjdE9iai5wcm9wczsKICAgICAgICAgICAgICAgIGlmIChwcm9wcykgewogICAgICAgICAgICAgICAgICAgIGxldCBmaWxlTGlzdCA9IHByb3BzLmxpc3QgfHwgW107CiAgICAgICAgICAgICAgICAgICAgbGV0IHNlbGVjdGVkS2V5cyA9IHByb3BzLnNlbGVjdGVkUm93S2V5cyB8fCBbXTsKICAgICAgICAgICAgICAgICAgICBmaWxlTGlzdC5mb3JFYWNoKCh2YWwpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGVjdGVkS2V5cy5pbmNsdWRlcyh2YWwuZmlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0ZWRMaXN0LnB1c2godmFsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIHNlbGVjdGVkTGlzdDsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuIFtdOwogICAgICAgICAgICB9CiAgICAgICAgfSwKCiAgICAgICAgZGV0ZWN0UGFnZSgpIHsKICAgICAgICAgICAgbGV0IHBhdGggPSBsb2NhdGlvbi5wYXRobmFtZTsKICAgICAgICAgICAgaWYgKC9eXC8obGlzdCkvLnRlc3QocGF0aCkpIHJldHVybiAnaG9tZSc7CiAgICAgICAgICAgIGlmICgvXlwvKHN8c2hhcmUpXC8vLnRlc3QocGF0aCkpIHJldHVybiAnc2hhcmUnOwogICAgICAgICAgICByZXR1cm4gJyc7CiAgICAgICAgfSwKCiAgICAgICAgaXNPbmx5Rm9sZGVyKCkgewogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNlbGVjdExpc3QubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChzZWxlY3RMaXN0W2ldLmZpbGUpIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICB9LAoKICAgICAgICBzaG93TWFpbkRpYWxvZyh0aXRsZSwgaHRtbCwgZm9vdGVyKSB7CiAgICAgICAgICAgIFN3YWwuZmlyZSh7CiAgICAgICAgICAgICAgICB0aXRsZSwKICAgICAgICAgICAgICAgIGh0bWwsCiAgICAgICAgICAgICAgICBmb290ZXIsCiAgICAgICAgICAgICAgICBhbGxvd091dHNpZGVDbGljazogZmFsc2UsCiAgICAgICAgICAgICAgICBzaG93Q2xvc2VCdXR0b246IHRydWUsCiAgICAgICAgICAgICAgICBzaG93Q29uZmlybUJ1dHRvbjogZmFsc2UsCiAgICAgICAgICAgICAgICBwb3NpdGlvbjogJ3RvcCcsCiAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgIHBhZGRpbmc6ICcxNXB4IDIwcHggNXB4JywKICAgICAgICAgICAgICAgIGN1c3RvbUNsYXNzLAogICAgICAgICAgICB9KTsKICAgICAgICB9LAoKICAgICAgICBhc3luYyBpbml0UGFuTGlua2VyKCkgewogICAgICAgICAgICBiYXNlLmluaXREZWZhdWx0Q29uZmlnKCk7CiAgICAgICAgICAgIGJhc2UuYWRkUGFuTGlua2VyU3R5bGUoKTsKICAgICAgICAgICAgcHQgPSB0aGlzLmRldGVj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gQUEvJHtlbmNvZGVVUklDb21wb25lbnQoZmlsZW5hbWUpfS8/dXJsPSR7ZW5jb2RlVVJJQ29tcG9uZW50KGxpbmspfVpaYDsKICAgICAgICAgICAgcmV0dXJuIGVuY29kZVVSSUNvbXBvbmVudChgYmM6Ly9odHRwLyR7YmFzZS5lKGJjKX1gKTsKICAgICAgICB9LAoKICAgICAgICBjb252ZXJ0TGlua1RvQ3VybChsaW5rLCBmaWxlbmFtZSwgdWEpIHsKICAgICAgICAgICAgbGV0IHRlcm1pbmFsID0gYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ190ZXJtaW5hbF90eXBlJyk7CiAgICAgICAgICAgIGZpbGVuYW1lID0gYmFzZS5maXhGaWxlbmFtZShmaWxlbmFtZSk7CiAgICAgICAgICAgIHJldHVybiBlbmNvZGVVUklDb21wb25lbnQoYCR7dGVybWluYWwgIT09ICd3cCcgPyAnY3VybCcgOiAnY3VybC5leGUnfSAtTCAtQyAtICIke2xpbmt9IiAtbyAiJHtmaWxlbmFtZX0iYCk7CiAgICAgICAgfSwKCiAgICAgICAgYWRkUGFnZUxpc3RlbmVyKCkgewogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5wbC1idXR0b24tbW9kZScsIChlKSA9PiB7CiAgICAgICAgICAgICAgICBtb2RlID0gZS50YXJnZXQuZGF0YXNldC5tb2RlOwogICAgICAgICAgICAgICAgU3dhbC5zaG93TG9hZGluZygpOwogICAgICAgICAgICAgICAgdGhpcy5nZXRQQ1NMaW5rKCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1saW5rLWFwaScsIGFzeW5jIChlKSA9PiB7CiAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAkKCcjZG93bmxvYWRJZnJhbWUnKS5hdHRyKCdzcmMnLCBlLmN1cnJlbnRUYXJnZXQuZGF0YXNldC5saW5rKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstYXJpYSwgLmxpc3RlbmVyLWNvcHktYWxsJywgKGUpID0+IHsKICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgIGJhc2Uuc2V0Q2xpcGJvYXJkKGRlY29kZVVSSUNvbXBvbmVudChlLnRhcmdldC5kYXRhc2V0LmxpbmspKTsKICAgICAgICAgICAgICAgICQoZS50YXJnZXQpLnRleHQoJ+WkjeWItuaIkOWKn++8jOW/q+WOu+eymOi0tOWQp++8gScpLmFuaW1hdGUoe29wYWNpdHk6ICcwLjUnfSwgInNsb3ciKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGRvYy5vbignY2xpY2snLCAnLmxpc3RlbmVyLWxpbmstcnBjJywgYXN5bmMgKGUpID0+IHsKICAgICAgICAgICAgICAgIGxldCB0YXJnZXQgPSAkKGUuY3VycmVudFRhcmdldCk7CiAgICAgICAgICAgICAgICB0YXJnZXQuZmluZCgnLmljb24nKS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgIHRhcmdldC5maW5kKCcucGwtbG9hZGluZycpLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgdGFyZ2V0LnByZXBlbmQoYmFzZS5jcmVhdGVMb2FkaW5nKCkpOwogICAgICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IHRoaXMuc2VuZExpbmtUb1JQQyhlLmN1cnJlbnRUYXJnZXQuZGF0YXNldC5maWxlbmFtZSwgZS5jdXJyZW50VGFyZ2V0LmRhdGFzZXQubGluayk7CiAgICAgICAgICAgICAgICBpZiAocmVzID09PSAnc3VjY2VzcycpIHsKICAgICAgICAgICAgICAgICAgICAkKCcubGlzdGVuZXItcnBjLXRhc2snKS5zaG93KCk7CiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnJlbW92ZUNsYXNzKCdwbC1idG4tZGFuZ2VyJykuaHRtbCgn5Y+R6YCB5oiQ5Yqf77yM5b+r5Y6755yL55yL5ZCn77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB0YXJnZXQuYWRkQ2xhc3MoJ3BsLWJ0bi1kYW5nZXInKS50ZXh0KCflj5HpgIHlpLHotKXvvIzor7fmo4Dmn6XmgqjnmoRSUEPphY3nva7kv6Hmga/vvIEnKS5hbmltYXRlKHtvcGFjaXR5OiAnMC41J30sICJzbG93Iik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBkb2Mub24oJ2NsaWNrJywgJy5saXN0ZW5lci1zZW5kLXJwYycsIChlKSA9PiB7CiAgICAgICAgICAgICAgICAkKCcubGlzdGVuZXItbGluay1ycGMnKS5jbGljaygpOwogICAgICAgICAgICAgICAgJChlLnRhcmdldCkudGV4dCgn5Y+R6YCB5a6M5oiQ77yM5Y+R6YCB57uT5p6c6KeB5LiK5pa55oyJ6ZKu77yBJykuYW5pbWF0ZSh7b3BhY2l0eTogJzAuNSd9LCAic2xvdyIpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItb3Blbi1zZXR0aW5nJywgKCkgPT4gewogICAgICAgICAgICAgICAgYmFzZS5zaG93U2V0dGluZygpOwogICAgICAgICAgICB9KTsKICAgICAgICAgICAgZG9jLm9uKCdjbGljaycsICcubGlzdGVuZXItcnBjLXRhc2snLCAoKSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgcnBjID0gSlNPTi5zdHJpbmdpZnkoewogICAgICAgICAgICAgICAgICAgIGRvbWFpbjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfZG9tYWluJyksCiAgICAgICAgICAgICAgICAgICAgcG9ydDogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfcG9ydCcpLAogICAgICA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uID8gcGFuLm5ldyA6ICcnfTwvdWw+PC9kaXY+YCk7CiAgICAgICAgICAgIGlmIChwdCA9PT0gJ2hvbWUnKSB7CiAgICAgICAgICAgICAgICBiYXNlLmxpc3RlbkVsZW1lbnQocGFuLmJ0bi5ob21lLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgJHRvb2xXcmFwID0gJChwYW4uYnRuLmhvbWUpOwogICAgICAgICAgICAgICAgICAgICQoJy5wbC1idXR0b24nKS5sZW5ndGggPT09IDAgJiYgJHRvb2xXcmFwLnByZXBlbmQoJGJ1dHRvbik7CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChwdCA9PT0gJ3NoYXJlJykgewogICAgICAgICAgICAgICAgJGJ1dHRvbi5yZW1vdmVDbGFzcygneWlkb25nLWJ1dHRvbicpLmFkZENsYXNzKCd5aWRvbmctc2hhcmUtYnV0dG9uJyk7CiAgICAgICAgICAgICAgICBiYXNlLmxpc3RlbkVsZW1lbnQocGFuLmJ0bi5zaGFyZSwgKCkgPT4gewogICAgICAgICAgICAgICAgICAgICR0b29sV3JhcCA9ICQocGFuLmJ0bi5zaGFyZSk7CiAgICAgICAgICAgICAgICAgICAgJCgnLnBsLWJ1dHRvbicpLmxlbmd0aCA9PT0gMCAmJiAkdG9vbFdyYXAucHJlcGVuZCgkYnV0dG9uKTsKICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgIH0KICAgICAgICAgICAgYmFzZS5jcmVhdGVEb3dubG9hZElmcmFtZSgpOwogICAgICAgICAgICB0aGlzLmFkZFBhZ2VMaXN0ZW5lcigpOwogICAgICAgIH0sCgogICAgICAgIGFkZEluaXRCdXR0b24oKSB7CiAgICAgICAgICAgIGlmICghcHQpIHJldHVybjsKICAgICAgICAgICAgbGV0ICR0b29sV3JhcDsKICAgICAgICAgICAgbGV0ICRidXR0b24gPSAkKGA8ZGl2IGNsYXNzPSJ5aWRvbmctYnV0dG9uIHBsLWJ1dHRvbi1pbml0Ij7kuIvovb3liqnmiYs8L2Rpdj5gKTsKICAgICAgICAgICAgaWYgKHB0ID09PSAnaG9tZScpIHsKICAgICAgICAgICAgICAgIGJhc2UubGlzdGVuRWxlbWVudChwYW4uYnRuLmhvbWUsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAkdG9vbFdyYXAgPSAkKHBhbi5idG4uaG9tZSk7CiAgICAgICAgICAgICAgICAgICAgJCgnLnBsLWJ1dHRvbi1pbml0JykubGVuZ3RoID09PSAwICYmICR0b29sV3JhcC5wcmVwZW5kKCRidXR0b24pOwogICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocHQgPT09ICdzaGFyZScpIHsKICAgICAgICAgICAgICAgICRidXR0b24ucmVtb3ZlQ2xhc3MoJ3lpZG9uZy1idXR0b24nKS5hZGRDbGFzcygneWlkb25nLXNoYXJlLWJ1dHRvbicpOwogICAgICAgICAgICAgICAgYmFzZS5saXN0ZW5FbGVtZW50KHBhbi5idG4uc2hhcmUsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAkdG9vbFdyYXAgPSAkKHBhbi5idG4uc2hhcmUpOwogICAgICAgICAgICAgICAgICAgICQoJy5wbC1idXR0b24taW5pdCcpLmxlbmd0aCA9PT0gMCAmJiAkdG9vbFdyYXAucHJlcGVuZCgkYnV0dG9uKTsKICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgIH0KICAgICAgICAgICAgJGJ1dHRvbi5jbGljaygoKSA9PiBiYXNlLmluaXREaWFsb2coKSk7CiAgICAgICAgfSwKCiAgICAgICAgZ2V0UmFuZG9tU3RyaW5nKGxlbikgewogICAgICAgICAgICBsZW4gPSBsZW4gfHwgMTY7CiAgICAgICAgICAgIGxldCAkY2hhcnMgPSAnQUJDREVGR0hKS01OUFFSU1RXWFlaYWJjZGVmaGlqa21ucHJzdHd4eXoyMzQ1Njc4JzsKICAgICAgICAgICAgbGV0IG1heFBvcyA9ICRjaGFycy5sZW5ndGg7CiAgICAgICAgICAgIGxldCBwd2QgPSAnJzsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgcHdkICs9ICRjaGFycy5jaGFyQXQoTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogbWF4UG9zKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHB3ZDsKICAgICAgICB9LAoKICAgICAgICB1dG9iKHN0cikgewogICAgICAgICAgICBjb25zdCB1ID0gU3RyaW5nLmZyb21DaGFyQ29kZTsKICAgICAgICAgICAgcmV0dXJuIHN0ci5yZXBsYWNlKC9bXHVEODAwLVx1REJGRl1bXHVEQzAwLVx1REZGRkZdfFteXHgwMC1ceDdGXS9nLCAodCkgPT4gewogICAgICAgICAgICAgICAgaWYgKHQubGVuZ3RoIDwgMikgewogICAgICAgICAgICAgICAgICAgIGxldCBlID0gdC5jaGFyQ29kZUF0KDApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBlIDwgMTI4ID8gdCA6IGUgPCAyMDQ4ID8gdSgxOTIgfCBlID4+PiA2KSArIHUoMTI4IHwgNjMgJiBlKSA6IHUoMjI0IHwgZSA+Pj4gMTIgJiAxNSkgKyB1KDEyOCB8IGUgPj4+IDYgJiA2MykgKyB1KDEyOCB8IDYzICYgZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlID0gNjU1MzYgKyAxMDI0ICogKHQuY2hhckNvZGVBdCgwKSAtIDU1Mjk2KSArICh0LmNoYXJDb2RlQXQoMSkgLSA1NjMyMCk7CiAgICAgICAgICAgICAgICByZXR1cm4gdSgyNDAgfCBlID4+PiAxOCAmIDcpICsgdSgxMjggfCBlID4+PiAxMiAmIDYzKSArIHUoMTI4IHwgZSA+Pj4gNiAmIDYzKSArIHUoMTI4IHwgNjMgJiBlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwKCiAgICAgICAgZ2V0U2lnbihlLCB0LCBhLCBuKSB7CiAgICAgICAgICAgIGxldCByID0gIiIsCiAgICAgICAgICAgICAgICBpID0gIiI7CiAgICAgICAgICAgIGlmICh0KSB7CiAgICAgICAgICAgICAgICBsZXQgcyA9IE9iamVjdC5hc3NpZ24oe30sIHQpOwogICAgICAgICAgICAgICAgaSA9IEpTT04uc3RyaW5naWZ5KHMpLAogICAgICAgICAgICAgICAgICAgIGkgPSBpLnJlcGxhY2UoL1xzKi9nLCAiIiksCiAgICAgICAgICAgICAgICAgICAgaSA9IGVuY29kZVVSSUNvbXBvbmVudChpKTsKICAgICAgICAgICAgICAgIGxldCBjID0gaS5zcGxpdCgiIiksCiAgICAgICAgICAgICAgICAgICAgdSA9IGMuc29ydCgpOwogICAgICAgICAgICAgICAgaSA9IHUuam9pbigiIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGV0IEEgPSBtZDUoYmFzZS5lKHRoaXMudXRvYihpKSkpOwogICAgICAgICAgICBsZXQgbCA9IG1kNShhICsgIjoiICsgbik7CiAgICAgICAgICAgIHJldHVybiBtZDUoQSArIGwpLnRvVXBwZXJDYXNlKCk7CiAgICAgICAgfSwKCiAgICAgICAgYXN5bmMgZ2V0RmlsZVVybEJ5T25jZShpdGVtLCBpbmRleCkgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgaWYgKGl0ZW0uZG93bmxvYWRVcmwpIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgaW5kZXgsCiAgICAgICAgICAgICAgICAgICAgZG93bmxvYWRVcmw6IGl0ZW0uZG93bmxvYWRVcmwKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXRlY3RQYWdlKCkgPT09ICdob21lJykgewogICAgICAgICAgICAgICAgICAgIGxldCBib2R5ID0gewogICAgICAgICAgICAgICAgICAgICAgICAiY29udGVudElEIjogaXRlbS5jb250ZW50SUQsCiAgICAgICAgICAgICAgICAgICAgICAgICJjb21tb25BY2NvdW50SW5mbyI6IHsiYWNjb3VudCI6IGl0ZW0ub3duZXIsICJhY2NvdW50VHlwZSI6IDF9LAogICAgICAgICAgICAgICAgICAgICAgICAib3BlcmF0aW9uIjogIjAiLAogICAgICAgICAgICAgICAgICAgICAgICAiaW5saW5lIjogIjAiLAogICAgICAgICAgICAgICAgICAgICAgICAiZXh0SW5mbyI6IHsiaXNSZXR1cm5DZG5Eb3dubG9hZFVybCI6ICIxIn0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGxldCB0aW1lID0gbmV3IERhdGUoK25ldyBEYXRlKCkgKyA4ICogMzYwMCAqIDEwMDApLnRvSlNPTigpLnN1YnN0cigwLCAxOSkucmVwbGFjZSgnVCcsICcgJyk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGtleSA9IHRoaXMuZ2V0UmFuZG9tU3RyaW5nKDE2KTsKICAgICAgICAgICAgICAgICAgICBsZXQgc2lnbiA9IHRoaXMuZ2V0U2lnbih1bmRlZmluZWQsIGJvZHksIHRpbWUsIGtleSk7CgogICAgICAgICAgICAgICAgICAgIGxldCByZXMgPSBhd2FpdCBiYXNlLnBvc3QocGFuLnBjc1swXSwgYm9keSwgewogICAgICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IGJhc2UuZ2V0Q29va2llKCdhdXRob3JpemF0aW9uJyksCiAgICAgICAgICAgICAgICAgICAgICAgICd4LWh1YXdlaS1jaGFubmVsU3JjJzogJzEwMDAwMDM0JywKICAgICAgICAgICAgICAgICAgICAgICAgJ3gtaW5uZXItbnR3ayc6ICcyJywKICAgICAgICAgICAgICAgICAgICAgICAgJ21jbG91ZC1jaGFubmVsJzogJzEwMDAxMDEnLAogICAgICAgICAgICAgICAgICAgICAgICAnbWNsb3VkLWNsaWVudCc6ICcxMDcwMScsCiAgICAgICAgICAgICAgICAgICAgICAgICdtY2xvdWQtc2lnbic6IHRpbWUgKyAiLCIgKyBrZXkgKyAiLCIgKyBzaWduLAogICAgICAgICAgICAgICAgICAgICAgICAnY29udGVudC10eXBlJzogImFwcGxpY2F0aW9uL2pzb247Y2hhcnNldD1VVEYtOCIsCiAgICAgICAgICAgICAgICAgICAgICAgICdjYWxsZXInOiAnd2ViJywKICAgICAgICAgICAgICAgICAgICAgICAgJ0NNUy1ERVZJQ0UnOiAnZGVmYXVsdCcsCiAgICAgICAgICAgICAgICAgICAgICAgICd4LURldmljZUluZm8nOiAnfHw5fDcuMTIuMHxjaHJvbWV8MTE4LjAuMC4wfHx3aW5kb3dzIDEwfHx6aC1DTnx8fCcsCiAgICAgICAgICAgICAgICAgICAgICAgICd4LVN2Y1R5cGUnOiAnMScsCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHJlcy5zdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvd25sb2FkVXJsOiByZXMuZGF0YS5kb3dubG9hZFVSTAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvd25sb2FkVXJsOiAn6I635Y+W5LiL6L295Zyw5Z2A5aSx6LSl77yM6K+35Yi35paw6YeN6K+V77yBJwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICh0aGlzLmRldGVjdFBhZ2UoKSA9PT0gJ3NoYXJlJykgewogICAgICAgICAgICAgICAgICAgIGxldCB2dWVEb20gPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIuaG9tZS1wYWdlIikuX192dWVfXzsKCiAgICAgICAgICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IGJhc2UucG9zdChwYW4ucGNzWzFdLCBgbGlua0lkPSR7dnVlRG9tLmxpbmtJRH0mY29udGVudElkcz0ke2VuY29kZVVSSUNvbXBvbmVudCh2dWVEb20uY3VycmVudFBhdGguaWQgKyAnLycgKyBpdGVtLmNvSUQpfSZjYXRhbG9nSWRzPWAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi94LXd3dy1mb3JtLXVybGVuY29kZWQnLAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGlmIChyZXMuY29kZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZFVybDogcmVzLmRhdGEucmVkclVybAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvd25sb2FkVXJsOiAn6I635Y+W5LiL6L295Zyw5Z2A5aSx6LSl77yM6K+35Yi35paw6YeN6K+V77yBJwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICBkb3dubG9hZFVybDogJ+iOt+WPluS4i+i9veWcsOWdgOWksei0pe+8jOivt+WIt+aWsOmHjeivle+8gScKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBhc3luYyBnZXRQQ1NMaW5rKCkgewogICAgICAgICAgICBzZWxlY3RMaXN0ID0gdGhpcy5nZXRTZWxlY3RlZExpc3QoKTsKICAgICAgICAgICAgaWYgKHNlbGVjdExpc3QubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gbWVzc2FnZS5lcnJvcign5o+Q56S677ya6K+35YWI5Yu+6YCJ6KaB5LiL6L2955qE5paH5Lu277yBJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHRoaXMuaXNPbmx5Rm9sZGVyKCkpIHsKICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlLmVycm9yKCfmj5DnpLrvvJror7fmiZPlvIDmlofku7blpLnlkI7li77pgInmlofku7bvvIEnKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgbGV0IHF1ZXVlID0gW107CiAgICAgICAgICAgIHNlbGVjdExpc3QuZm9yRWFjaCgoaXRlbSwgaW5kZXgpID0+IHsKICAgICAgICAgICAgICAgIHF1ZXVlLnB1c2godGhpcy5nZXRGaWxlVXJsQnlPbmNlKGl0ZW0sIGluZGV4KSk7CiAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgY29uc3QgcmVzID0gYXdhaXQgUHJvbWlzZS5hbGwocXVldWUpOwogICAgICAgICAgICByZXMuZm9yRWFjaCh2YWwgPT4gewogICAgICAgICAgICAgICAgc2VsZWN0TGlzdFt2YWwuaW5kZXhdLmRvd25sb2FkVXJsID0gdmFsLmRvd25sb2FkVXJsOwogICAgICAgICAgICB9KTsKCiAgICAgICAgICAgIGxldCBodG1sID0gdGhpcy5nZW5lcmF0ZURvbShzZWxlY3RMaXN0KTsKICAgICAgICAgICAgdGhpcy5zaG93TWFpbkRpYWxvZyhwYW5bbW9kZV1bMF0sIGh0bWwsIHBhblttb2RlXVsxXSk7CiAgICAgICAgfSwKCiAgICAgICAgZ2VuZXJhdGVEb20obGlzdCkgewogICAgICAgICAgICBsZXQgY29udGVudCA9ICc8ZGl2IGNsYXNzPSJwbC1tYWluIj4nOwogICAgICAgICAgICBsZXQgYWxpbmtBbGxUZXh0ID0gJyc7CiAgICAgICAgICAgIGxpc3QuZm9yRWFjaCgodiwgaSkgPT4gewogICAgICAgICAgICAgICAgaWYgKHYuZGlyRXRhZyB8fCB2LmNhTmFtZSkgcmV0dXJuOwogICAgICAgICAgICAgICAgbGV0IGZpbGVuYW1lID0gdi5jb250ZW50TmFtZSB8fCB2LmNvTmFtZTsKICAgICAgICAgICAgICAgIGxldCBzaXplID0gYmFzZS5zaXplRm9ybWF0KHYuY29udGVudFNpemUgfHwgdi5jb1NpemUpOwogICAgICAgICAgICAgICAgbGV0IGRsaW5rID0gdi5kb3dubG9hZFVybDsKICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXBpJykgewogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIGxpc3RlbmVyLWxpbmstYXBpIiBkYXRhLWZpbGVuYW1lPSIke2ZpbGVuYW1lfSIgZGF0YS1saW5rPSIke2RsaW5rfSIgZGF0YS1pbmRleD0iJHtpfSI+JHtkbGlua308L2E+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+YDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChtb2RlID09PSAnYXJpYScpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYWxpbmsgPSB0aGlzLmNvbnZlcnRMaW5rVG9BcmlhKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgYWxpbmtBbGxUZXh0ICs9IGFsaW5rICsgJ1xyXG4nOwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnQgKz0gYDxkaXYgY2xhc3M9InBsLWl0ZW0iPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9InBsLWl0ZW0tbmFtZSBsaXN0ZW5lci10aXAiIGRhdGEtc2l6ZT0iJHtzaXplfSI+JHtmaWxlbmFtZX08L2Rpdj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8YSBjbGFzcz0icGwtaXRlbS1saW5rIGxpc3RlbmVyLWxpbmstYXJpYSIgaHJlZj0iJHthbGlua30iIHRpdGxlPSLngrnlh7vlpI3liLZhcmlhMmPpk77mjqUiIGRhdGEtZmlsZW5hbWU9IiR7ZmlsZW5hbWV9IiBkYXRhLWxpbms9IiR7YWxpbmt9Ij4ke2RlY29kZVVSSUNvbXBvbmVudChhbGluayl9PC9hPiA8L2Rpdj5gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG1vZGUgPT09ICdycGMnKSB7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz0icGwtaXRlbS1uYW1lIGxpc3RlbmVyLXRpcCIgZGF0YS1zaXplPSIke3NpemV9Ij4ke2ZpbGVuYW1lfTwvZGl2PgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxidXR0b24gY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLXJwYyBwbC1idG4tcHJpbWFyeSBwbC1idG4taW5mbyIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHtkbGlua30iPjxlbSBjbGFzcz0iaWNvbiBpY29uLWRldmljZSI+PC9lbT48c3BhbiBzdHlsZT0ibWFyZ2luLWxlZnQ6IDVweDsiPuaOqOmAgeWIsCBSUEMg5LiL6L295ZmoPC9zcGFuPjwvYnV0dG9uPjwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2N1cmwnKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaW5rID0gdGhpcy5jb252ZXJ0TGlua1RvQ3VybChkbGluaywgZmlsZW5hbWUsIG5hdmlnYXRvci51c2VyQWdlbnQpOwogICAgICAgICAgICAgICAgICAgIGFsaW5rQWxsVGV4dCArPSBhbGluayArICdcclxuJzsKICAgICAgICAgICAgICAgICAgICBjb250ZW50ICs9IGA8ZGl2IGNsYXNzPSJwbC1pdGVtIj4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJwbC1pdGVtLW5hbWUgbGlzdGVuZXItdGlwIiBkYXRhLXNpemU9IiR7c2l6ZX0iPiR7ZmlsZW5hbWV9PC9kaXY+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGEgY2xhc3M9InBsLWl0ZW0tbGluayBsaXN0ZW5lci1saW5rLWFyaWEiIGhyZWY9IiR7YWxpbmt9IiB0aXRsZT0i54K55Ye75aSN5Yi2Y3VybOmTvuaOpSIgZGF0YS1maWxlbmFtZT0iJHtmaWxlbmFtZX0iIGRhdGEtbGluaz0iJHthbGlua30iPiR7ZGVjb2RlVVJJQ29tcG9uZW50KGFsaW5rKX08L2E+IDwvZGl2PmA7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gJ2JjJykgewogICAgICAgICAgICAgICAgICAgIGxldCBhbGluayA9IHRoaXMuY29udmVydExpbmtUb0JDKGRsaW5rLCBmaWxlbmFtZSwgbmF2aWdhdG9yLnVzZXJBZ2VudCk7CiAgICAgICAgICAgICAgICAgICAgY29udGVudCArPSBgPGRpdiBjbGFzcz0icGwtaXRlbSI+CiA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SUEMoZmlsZW5hbWUsIGxpbmspIHsKICAgICAgICAgICAgbGV0IHJwYyA9IHsKICAgICAgICAgICAgICAgIGRvbWFpbjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfZG9tYWluJyksCiAgICAgICAgICAgICAgICBwb3J0OiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19wb3J0JyksCiAgICAgICAgICAgICAgICBwYXRoOiBiYXNlLmdldFZhbHVlKCdzZXR0aW5nX3JwY19wYXRoJyksCiAgICAgICAgICAgICAgICB0b2tlbjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfdG9rZW4nKSwKICAgICAgICAgICAgICAgIGRpcjogYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19ycGNfZGlyJyksCiAgICAgICAgICAgIH07CgogICAgICAgICAgICBsZXQgdXJsID0gYCR7cnBjLmRvbWFpbn06JHtycGMucG9ydH0ke3JwYy5wYXRofWA7CiAgICAgICAgICAgIGxldCBycGNEYXRhID0gewogICAgICAgICAgICAgICAgaWQ6IG5ldyBEYXRlKCkuZ2V0VGltZSgpLAogICAgICAgICAgICAgICAganNvbnJwYzogJzIuMCcsCiAgICAgICAgICAgICAgICBtZXRob2Q6ICdhcmlhMi5hZGRVcmknLAogICAgICAgICAgICAgICAgcGFyYW1zOiBbYHRva2VuOiR7cnBjLnRva2VufWAsIFtsaW5rXSwgewogICAgICAgICAgICAgICAgICAgIGRpcjogcnBjLmRpciwKICAgICAgICAgICAgICAgICAgICBvdXQ6IGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgIGhlYWRlcjogW10KICAgICAgICAgICAgICAgIH1dCiAgICAgICAgICAgIH07CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBsZXQgcmVzID0gYXdhaXQgYmFzZS5wb3N0KHVybCwgcnBjRGF0YSwge30sICcnKTsKICAgICAgICAgICAgICAgIGlmIChyZXMucmVzdWx0KSByZXR1cm4gJ3N1Y2Nlc3MnOwogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgcmV0dXJuICdmYWlsJzsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIGdldFNlbGVjdGVkTGlzdCgpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIubWFpbl9maWxlX2xpc3QiKS5fX3Z1ZV9fLnNlbGVjdExpc3QubWFwKHZhbCA9PiB2YWwuaXRlbSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgIGxldCB2dWVEb20gPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIuaG9tZS1wYWdlIikuX192dWVfXzsKICAgICAgICAgICAgICAgIGxldCBmaWxlTGlzdCA9IHZ1ZURvbS5fY29tcHV0ZWRXYXRjaGVycy5maWxlTGlzdC52YWx1ZTsKICAgICAgICAgICAgICAgIGxldCBkaXJMaXN0ID0gdnVlRG9tLl9jb21wdXRlZFdhdGNoZXJzLmRpckxpc3QudmFsdWU7CiAgICAgICAgICAgICAgICBsZXQgc2VsZWN0ZWRGaWxlSW5kZXggPSB2dWVEb20uc2VsZWN0ZWRGaWxlOwogICAgICAgICAgICAgICAgbGV0IHNlbGVjdGVkRGlySW5kZXggPSB2dWVEb20uc2VsZWN0ZWREaXI7CiAgICAgICAgICAgICAgICBsZXQgc2VsZWN0RmlsZUxpc3QgPSBmaWxlTGlzdC5maWx0ZXIoKHYsIGkpID0+IHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2VsZWN0ZWRGaWxlSW5kZXguaW5jbHVkZXMoaSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGxldCBzZWxlY3REaXJMaXN0ID0gZGlyTGlzdC5maWx0ZXIoKHYsIGkpID0+IHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2VsZWN0ZWREaXJJbmRleC5pbmNsdWRlcyhpKTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgcmV0dXJuIFsuLi5zZWxlY3RGaWxlTGlzdCwgLi4uc2VsZWN0RGlyTGlzdF07CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBkZXRlY3RQYWdlKCkgewogICAgICAgICAgICBsZXQgaG9zdG5hbWUgPSBsb2NhdGlvbi5ob3N0bmFtZTsKICAgICAgICAgICAgaWYgKC9eeXVuLy50ZXN0KGhvc3RuYW1lKSkgcmV0dXJuICdob21lJzsKICAgICAgICAgICAgaWYgKC9eY2FpeXVuLy50ZXN0KGhvc3RuYW1lKSkgcmV0dXJuICdzaGFyZSc7CiAgICAgICAgICAgIHJldHVybiAnJzsKICAgICAgICB9LAoKICAgICAgICBpc09ubHlGb2xkZXIoKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2VsZWN0TGlzdC5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgaWYgKHNlbGVjdExpc3RbaV0uZmlsZUV0YWcgfHwgc2VsZWN0TGlzdFtpXS5jb05hbWUpIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICB9LAoKICAgICAgICBzaG93TWFpbkRpYWxvZyh0aXRsZSwgaHRtbCwgZm9vdGVyKSB7CiAgICAgICAgICAgIFN3YWwuZmlyZSh7CiAgICAgICAgICAgICAgICB0aXRsZSwKICAgICAgICAgICAgICAgIGh0bWwsCiAgICAgICAgICAgICAgICBmb290ZXIsCiAgICAgICAgICAgICAgICBhbGxvd091dHNpZGVDbGljazogZmFsc2UsCiAgICAgICAgICAgICAgICBzaG93Q2xvc2VCdXR0b246IHRydWUsCiAgICAgICAgICAgICAgICBzaG93Q29uZmlybUJ1dHRvbjogZmFsc2UsCiAgICAgICAgICAgICAgICBwb3NpdGlvbjogJ3RvcCcsCiAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgIHBhZGRpbmc6ICcxNXB4IDIwcHggNXB4JywKICAgICAgICAgICAgICAgIGN1c3RvbUNsYXNzLAogICAgICAgICAgICB9KTsKICAgICAgICB9LAoKICAgICAgICBhc3luYyBpbml0UGFuTGlua2VyKCkgewogICAgICAgICAgICBiYXNlLmluaXREZWZhdWx0Q29uZmlnKCk7CiAgICAgICAgICAgIGJhc2UuYWRkUGFuTGlua2VyU3R5bGUoKTsKICAgICAgICAgICAgcHQgPSB0aGlzLmRldGVjdFBhZ2UoKTsKICAgICAgICAgICAgbGV0IHJlcyA9IGF3YWl0IGJhc2UucG9zdAogICAgICAgICAgICAoYGh0dHBzOi8vYXBpLnlvdXhpYW9ob3UuY29tL2NvbmZpZy92Mi95aWRvbmc/dmVyPSR7dmVyc2lvbn0mYT0ke2F1dGhvcn1gLCB7fSwge30sICd0ZXh0Jyk7CiAgICAgICAgICAgIHBhbiA9IEpTT04ucGFyc2UoYmFzZS5kKHJlcykpOwogICAgICAgICAgICBPYmplY3QuZnJlZXplICYmIE9iamVjdC5mcmVlemUocGFuKTsKICAgICAgICAgICAgcGFuLm51bSA9PT0gYmFzZS5nZXRWYWx1ZSgnc2V0dGluZ19pbml0X2NvZGUnKSB8fAogICAgICAgICAgICBwYW4ubGljZW5zZSA9PT0gYmFzZS5nZXRWYWx1ZSgnbGljZW5zZScpID8gdGhpcy5hZGRCdXR0b24oKSA6IHRoaXMuYWRkSW5pdEJ1dHRvbigpOwogICAgICAgICAgICBiYXNlLmNyZWF0ZVRpcCgpOwogICAgICAgICAgICBiYXNlLnJlZ2lzdGVyTWVudUNvbW1hbmQoKTsKICAgICAgICB9CiAgICB9OwoKICAgIGxldCBtYWluID0gewogICAgICAgIGluaXQoKSB7CiAgICAgICAgICAgIGlmICgvKHBhbnx5dW4pLmJhaWR1LmNvbS8udGVzdChsb2NhdGlvbi5ob3N0KSkgewogICAgICAgICAgICAgICAgYmFpZHUuaW5pdFBhbkxpbmtlcigpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICgvd3d3LihhbGl5dW5kcml2ZXxhbGlwYW4pLmNvbS8udGVzdChsb2NhdGlvbi5ob3N0KSkgewogICAgICAgICAgICAgICAgYWxpLmluaXRQYW5MaW5rZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoL2Nsb3VkLjE4OS5jbi8udGVzdChsb2NhdGlvbi5ob3N0KSkgewogICAgICAgICAgICAgICAgdGlhbnlpLmluaXRQYW5MaW5rZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoL3Bhbi54dW5sZWkuY29tLy50ZXN0KGxvY2F0aW9uLmhvc3QpKSB7CiAgICAgICAgICAgICAgICB4dW5sZWkuaW5pdFBhbkxpbmtlcigpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICgvcGFuLnF1YXJrLmNuLy50ZXN0KGxvY2F0aW9uLmhvc3QpKSB7CiAgICAgICAgICAgICAgICBxdWFyay5pbml0UGFuTGlua2VyKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKC8oeXVufGNhaXl1bikuMTM5LmNvbS8udGVzdChsb2NhdGlvbi5ob3N0KSkgewogICAgICAgICAgICAgICAgeWlkb25nLmluaXRQYW5MaW5rZXIoKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH07CgogICAgbWFpbi5pbml0KCk7Cn0pKCk7Cg==
Add Comment
Please, Sign In to add comment