Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_m3u8视频侦测下载器【自动嗅探】@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICBtM3U46KeG6aKR5L6m5rWL5LiL6L295Zmo44CQ6Ieq5Yqo5ZeF5o6i44CRCi8vIEBuYW1lOnpoLUNOICAgbTN1OOinhumikeS+pua1i+S4i+i9veWZqOOAkOiHquWKqOWXheaOouOAkQovLyBAbmFtZTp6aC1UVyAgIG0zdTjoppbpoLvlgbXmuKzkuIvovInlmajjgJDoh6rli5Xll4XmjqLjgJEKLy8gQG5hbWU6ZW4gICAgICBNM1U4IFZpZGVvIERldGVjdG9yIGFuZCBEb3dubG9hZGVyCi8vIEB2ZXJzaW9uICAgICAgMS40LjEKLy8gQGRlc2NyaXB0aW9uICDoh6rliqjmo4DmtYvpobXpnaJtM3U46KeG6aKR5bm26L+b6KGM5a6M5pW05LiL6L2944CC5qOA5rWL5YiwbTN1OOmTvuaOpeWQjuS8muiHquWKqOWHuueOsOWcqOmhtemdouWPs+S4iuinkuS9jee9ru+8jOeCueWHu+S4i+i9veWNs+WPr+i3s+i9rOWIsG0zdTjkuIvovb3lmajjgIIKLy8gQGRlc2NyaXB0aW9uOnpoLUNOICDoh6rliqjmo4DmtYvpobXpnaJtM3U46KeG6aKR5bm26L+b6KGM5a6M5pW05LiL6L2944CC5qOA5rWL5YiwbTN1OOmTvuaOpeWQjuS8muiHquWKqOWHuueOsOWcqOmhtemdouWPs+S4iuinkuS9jee9ru+8jOeCueWHu+S4i+i9veWNs+WPr+i3s+i9rOWIsG0zdTjkuIvovb3lmajjgIIKLy8gQGRlc2NyaXB0aW9uOnpoLVRXICDoh6rli5XmqqLmuKzpoIHpnaJtM3U46KaW6aC75Lim6YCy6KGM5a6M5pW05LiL6LyJ44CC5qqi5ris5YiwbTN1OOmPiOaOpeW+jOacg+iHquWLleWHuuePvuWcqOmggemd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lscyk7CiAgICAgICAgfSwKICAgICAgICBkb3dubG9hZChkZXRhaWxzKSB7CgogICAgICAgICAgICByZXR1cm4gdGhpcy5vcGVuSW5UYWIoZGV0YWlscy51cmwpOwoKICAgICAgICAgICAgaWYgKHR5cGVvZiBHTV9kb3dubG9hZCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgdGhpcy5tZXNzYWdlKCLkuIvovb3kuK3vvIzor7fnlZnmhI/mtY/op4jlmajkuIvovb3lvLnnqpdcbkRvd25sb2FkaW5nLCBwYXkgYXR0ZW50aW9uIHRvIHRoZSBicm93c2VyJ3MgZG93bmxvYWQgcG9wLXVwLiIsIDMwMDApOwogICAgICAgICAgICAgICAgcmV0dXJuIEdNX2Rvd25sb2FkKGRldGFpbHMpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdGhpcy5vcGVuSW5UYWIoZGV0YWlscy51cmwpOwogICAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICBjb3B5VGV4dCh0ZXh0KSB7CiAgICAgICAgICAgIGNvcHlUZXh0VG9DbGlwYm9hcmQodGV4dCk7CiAgICAgICAgICAgIGZ1bmN0aW9uIGNvcHlUZXh0VG9DbGlwYm9hcmQodGV4dCkgewogICAgICAgICAgICAgICAgLy8g5aSN5Yi25paH5pysCiAgICAgICAgICAgICAgICB2YXIgY29weUZyb20gPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJ0ZXh0YXJlYSIpOwogICAgICAgICAgICAgICAgY29weUZyb20udGV4dENvbnRlbnQgPSB0ZXh0OwogICAgICAgICAgICAgICAgZG9jdW1lbnQuYm9keS5hcHBlbmRDaGlsZChjb3B5RnJvbSk7CiAgICAgICAgICAgICAgICBjb3B5RnJvbS5zZWxlY3QoKTsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmV4ZWNDb21tYW5kKCdjb3B5Jyk7CiAgICAgICAgICAgICAgICBjb3B5RnJvbS5ibHVyKCk7CiAgICAgICAgICAgICAgICBkb2N1bWVudC5ib2R5LnJlbW92ZUNoaWxkKGNvcHlGcm9tKTsKICAgICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgbWVzc2FnZSh0ZXh0LCBkaXNhcHBlYXJUaW1lID0gNTAwMCkgewogICAgICAgICAgICBjb25zdCBpZCA9ICJmODI0M3JkMjM4LWdtLW1lc3NhZ2UtcGFuZWwiOwogICAgICAgICAgICBsZXQgcCA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoYCMke2lkfWApOwogICAgICAgICAgICBpZiAoIXApIHsKICAgICAgICAgICAgICAgIHAgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgIHAuaWQgPSBpZDsKICAgICAgICAgICAgICAgIHAuc3R5bGUgPSBgCiAgICAgICAgICAgICAgICAgICAgcG9zaXRpb246IGZpeGVkOwogICAgICAgICAgICAgICAgICAgIGJvdHRvbTogMjBweDsKICAgICAgICAgICAgICAgICAgICByaWdodDogMjBweDsKICAgICAgICAgICAgICAgICAgICBkaXNwbGF5OiBmbGV4OwogICAgICAgICAgICAgICAgICAgIGZsZXgtZGlyZWN0aW9uOiBjb2x1bW47CiAgICAgICAgICAgICAgICAgICAgYWxpZ24taXRlbXM6IGVuZDsKICAgICAgICAgICAgICAgICAgICB6LWluZGV4OiA5OTk5OTk5OTk5OTk5OTk7CiAgICAgICAgICAgICAgICBgOwogICAgICAgICAgICAgICAgKGRvY3VtZW50LmJvZHkgfHwgZG9jdW1lbnQuZG9jdW1lbnRFbGVtZW50KS5hcHBlbmRDaGlsZChwKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgbWRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICBtZGl2LmlubmVyVGV4dCA9IHRleHQ7CiAgICAgICAgICAgIG1kaXYuc3R5bGUgPSBgCiAgICAgICAgICAgICAgICBwYWRkaW5nOiAzcHggOHB4OwogICAgICAgICAgICAgICAgYm9yZGVyLXJhZGl1czogNXB4OwogICAgICAgICAgICAgICAgYmFja2dyb3VuZDogYmxhY2s7CiAgICAgICAgICAgICAgICBib3gtc2hhZG93OiAjMDAwIDFweCAycHggNXB4OwogICAgICAgICAgICAgICAgbWFyZ2luLXRvcDogMTBweDsKICAgICAgICAgICAgICAgIGZvbnQtc2l6ZTogc21hbGw7CiAgICAgICAgICAgICAgICBjb2xvcjogI2ZmZjsKICAgICAgICAgICAgICAgIHRleHQtYWxpZ246IHJpZ2h0OwogICAgICAgICAgICBgOwogICAgICAgICAgICBwLmFwcGVuZENoaWxkKG1kaXYpOwogICAgICAgICAgICBzZXRUaW1lb3V0KCgpID0+IHsKICAgICAgICAgICAgICAgIHAucmVtb3ZlQ2hpbGQobWRpdik7CiAgICAgICAgICAgIH0sIGRpc2FwcGVhclRpbWUpOwogICAgICAgIH0KICAgIH07CgoKICAgIGlmIChsb2NhdGlvbi5ob3N0ID09PSAidG9vbHMudGhhdHdpbmQuY29tIiB8fCBsb2NhdGlvbi5ob3N0ID09PSAibG9jYWxob3N0OjMwMDAiKSB7CiAgICAgICAgbWdtYXBpLmFkZFN0eWxlKCIjdXNlcnNjcmlwdC10aXB7ZGlzcGxheTpub25lICFpbXBvcnRhbnQ7fSIpOwoKICAgICAgICAvLyDlr7nor7fmsYLlgZrku6PnkIYKICAgICAgICBjb25zdCBfZmV0Y2ggPSB1bnNhZmVXaW5kb3cuZmV0Y2g7CiAgICAgICAgdW5zYWZlV2luZG93LmZldGNoID0gYXN5bmMgZnVuY3Rpb24gKC4uLmFyZ3MpIHsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGxldCByZXNwb25zZSA9IGF3YWl0IF9mZXRjaCguLi5hcmdzKTsKICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXMgIT09IDIwMCkgdGhyb3cgbmV3IEVycm9yKHJlc3BvbnNlLnN0YXR1cyk7CiAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgIC8vIOWksei0peivt+axguS9v+eUqOS7o+eQhgogICAgICAgICAgICAgICAgaWYgKGFyZ3MubGVuZ3RoID09IDEpIHsKICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhg6K+35rGC5Luj55CG77yaJHthcmdzWzBdfWApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZWZlcmVyID0gbmV3IFVSTFNlYXJjaFBhcmFtcyhsb2NhdGlvbi5oYXNoLnNsaWNlKDEpKS5nZXQoInJlZmVyZXIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGhlYWRlcnMgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlZmVyZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZmVyZXIgPSBuZXcgVVJMKHJlZmVyZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAib3JpZ2luIjogcmVmZXJlci5vcmlnaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInJlZmVyZXIiOiByZWZlcmVyLmhyZWYKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbWdtYXBpLnhtbEh0dHBSZXF1ZXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogIkdFVCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IGFyZ3NbMF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZVR5cGU6ICdhcnJheWJ1ZmZlcicsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25sb2FkKHIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzOiByLnN0YXR1cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogbmV3IEhlYWRlcnMoci5yZXNwb25zZUhlYWRlcnMuc3BsaXQoIlxuIikuZmlsdGVyKG4gPT4gbikubWFwKHMgPT4gcy5zcGxpdCgvOlxzKi8pKS5yZWR1Y2UoKGFsbCwgW2EsIGJdKSA9PiB7IGFsbFthXSA9IGI7IHJldHVybiBhbGw7IH0sIHt9KSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzeW5jIHRleHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gci5yZXNwb25zZVRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzeW5jIGFycmF5QnVmZmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHIucmVzcG9uc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbmVycm9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRXJyb3IoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICByZXR1cm47CiAgICB9CgoKICAgIC8vIGlmcmFtZSDkv6Hmga/kuqTmtYEKICAgIC8vIOebruWJjeWPqueUqOS6juiOt+WPlumhtumDqOagh+mimAogICAgd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCBhc3luYyAoZSkgPT4gewogICAgICAgIGlmIChlLmRhdGEgPT09ICIzajR0OXVqMzQ5LWdtLWdldC10aXRsZSIpIHsKICAgICAgICAgICAgbGV0IG5hbWUgPSBgdG9wLXRpdGxlLSR7RGF0ZS5ub3coKX1gOwogICAgICAgICAgICBhd2FpdCBtZ21hcGkuc2V0VmFsdWUobmFtZSwgZG9jdW1lbnQudGl0bGUpOwogICAgICAgICAgICBlLnNvdXJjZS5wb3N0TWVzc2FnZShgM2o0dDl1ajM0OS1nbS10b3AtdGl0bGUtbmFtZToke25hbWV9YCwgIioiKTsKICAgICAgICB9CiAgICB9KTsKCiAgICBmdW5jdGlvbiBnZXRUb3BUaXRsZSgpIHsKICAgICAgICByZXR1cm4gbmV3IFByb21pc2UocmVzb2x2ZSA9PiB7CiAgICAgICAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgYXN5bmMgZnVuY3Rpb24gbChlKSB7CiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGUuZGF0YSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZS5kYXRhLnN0YXJ0c1dpdGgoIjNqNHQ5dWozNDktZ20tdG9wLXRpdGxlLW5hbWU6IikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5hbWUgPSBlLmRhdGEuc2xpY2UoIjNqNHQ5dWozNDktZ20tdG9wLXRpdGxlLW5hbWU6Ii5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCBuZXcgUHJvbWlzZShyID0+IHNldFRpbWVvdXQociwgNSkpOyAvLyDnrYk15q+r56eSIOehruWumiBzZXRWYWx1ZSDlt7Lnu4/lhpnlhaUKICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShhd2FpdCBtZ21hcGkuZ2V0VmFsdWUobmFtZSkpOwogICAgICAgICAgICAgICAgICAgICAgICBtZ21hcGkuZGVsZXRlVmFsdWUobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgd2luZG93LnRvcC5wb3N0TWVzc2FnZSgiM2o0dDl1ajM0OS1nbS1nZXQtdGl0bGUiLCAiKiIpOwogICAgICAgIH0pOwogICAgfQoKCiAgICB7CiAgICAgICAgLy8g6K+35rGC5qOA5rWLCiAgICAgICAgLy8gY29uc3QgX2ZldGNoID0gdW5zYWZlV2luZG93LmZldGNoOwogICAgICAgIC8vIHVuc2FmZVdpbmRvdy5mZXRjaCA9IGZ1bmN0aW9uICguLi5hcmdzKSB7CiAgICAgICAgLy8gICAgIGlmIChjaGVja1VybChhcmdzWzBdKSkgZG9NM1UoeyB1cmw6IGFyZ3NbMF0gfSk7CiAgICAgICAgLy8gICAgIHJldHVybiBfZmV0Y2goLi4uYXJncyk7CiAgICAgICAgLy8gfQoKICAgICAgICBjb25zdCBfcl90ZXh0ID0gdW5zYWZlV2luZG93LlJlc3BvbnNlLnByb3RvdHlwZS50ZXh0OwogICAgICAgIHVuc2FmZVdpbmRvdy5SZXNwb25zZS5wcm90b3R5cGUudGV4dCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHsKICAgICAgICAgICAgICAgIF9yX3RleHQuY2FsbCh0aGlzKS50aGVuKCh0ZXh0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZSh0ZXh0KTsKICAgICAgICAgICAgICAgICAgICBpZiAoY2hlY2tDb250ZW50KHRleHQpKSBkb00zVSh7IHVybDogdGhpcy51cmwsIGNvbnRlbnQ6IHRleHQgfSk7CiAgICAgICAgICAgICAgICB9KS5jYXRjaChyZWplY3QpOwogICAgICAgICAgICB9KTsKICAgICAgICB9CgogICAgICAgIGNvbnN0IF9vcGVuID0gdW5zYWZlV2luZG93LlhNTEh0dHBSZXF1ZXN0LnByb3RvdHlwZS5vcGVuOwogICAgICAgIHVuc2FmZVdpbmRvdy5YTUxIdHRwUmVxdWVzdC5wcm90b3R5cGUub3BlbiA9IGZ1bmN0aW9uICguLi5hcmdzKSB7CiAgICAgICAgICAgIHRoaXMuYWRkRXZlbnRMaXN0ZW5lcigibG9hZCIsICgpID0+IHsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSB0aGlzLnJlc3BvbnNlVGV4dDsKICAgICAgICAgICAgICAgICAgICBpZiAoY2hlY2tDb250ZW50KGNvbnRlbnQpKSBkb00zVSh7IHVybDogYXJnc1sxXSwgY29udGVudCB9KTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggeyB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICAvLyBjaGVja1VybChhcmdzWzFdKTsKICAgICAgICAgICAgcmV0dXJuIF9vcGVuLmFwcGx5KHRoaXMsIGFyZ3MpOwogICAgICAgIH0KCgogICAgICAgIGZ1bmN0aW9uIGNoZWNrVXJsKHVybCkgewogICAgICAgICAgICB1cmwgPSBuZXcgVVJMKHVybCwgbG9jYXRpb24uaHJlZik7CiAgICAgICAgICAgIGlmICh1cmwucGF0aG5hbWUuZW5kc1dpdGgoIi5tM3U4IikgfHwgdXJsLnBhdGhuYW1lLmVuZHNXaXRoKCIubTN1IikpIHsKICAgICAgICAgICAgICAgIC8vIOWPkeeOsAogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGZ1bmN0aW9uIGNoZWNrQ29udGVudChjb250ZW50KSB7CiAgICAgICAgICAgIGlmIChjb250ZW50LnRyaW0oKS5zdGFydHNXaXRoKCIjRVhUTTNVIikpIHsKICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgfQoKCiAgICAgICAgLy8g5qOA5p+l57qv6KeG6aKRCiAgICAgICAgc2V0SW50ZXJ2YWwoZG9WaWRlb3MsIDEwMDApOwoKICAgIH0KCiAgICBjb25zdCByb290RGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICByb290RGl2LnN0eWxlID0gYAogICAgICAgIHBvc2l0aW9uOiBmaXhlZDsKICAgICAgICB6LWluZGV4OiA5OTk5OTk5OTk5OTk5OTk5OwogICAgICAgIG9wYWNpdHk6IDAuOTsKICAgIGA7CiAgICByb290RGl2LnN0eWxlLmRpc3BsYXkgPSAibm9uZSI7CiAgICBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuYXBwZW5kQ2hpbGQocm9vdERpdik7CgogICAgY29uc3Qgc2hhZG93RE9NID0gcm9vdERpdi5hdHRhY2hTaGFkb3coeyBtb2RlOiAnb3BlbicgfSk7CiAgICBjb25zdCB3cmFwcGVyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICBzaGFkb3dET00uYXBwZW5kQ2hpbGQod3JhcHBlcik7CgoKICAgIC8vIOaMh+ekuuWZqAogICAgY29uc3QgYmFyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICBiYXIuc3R5bGUgPSBgCiAgICAgICAgdGV4dC1hbGlnbjogcmlnaHQ7CiAgICBgOwogICAgYmFyLmlubmVySFRNTCA9IGAKICAgICAgICA8c3BhbgogICAgICAgICAgICBjbGFzcz0ibnVtYmVyLWluZGljYXRvciIKICAgICAgICAgICAgZGF0YS1udW1iZXI9IjAiCiAgICAgICAgICAgIHN0eWxlPSIKICAgICAgICAgICAgICAgIGRpc3BsYXk6IGlubGluZS1mbGV4OwogICAgICAgICAgICAgICAgd2lkdGg6IDI1cHg7CiAgICAgICAgICAgICAgICBoZWlnaHQ6IDI1cHg7CiAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kOiBibGFjazsKICAgICAgICAgICAgICAgIHBhZGRpbmc6IDEwcHg7CiAgICAgICAgICAgICAgICBib3JkZXItcmFkaXVzOiAxMDBweDsKICAgICAgICAgICAgICAgIG1hcmdpbi1ib3R0b206IDVweDsKICAgICAgICAgICAgICAgIGN1cnNvcjogcG9pbnRlcjsKICAgICAgICAgICAgICAgIGJvcmRlcjogM3B4IHNvbGlkICM4MzgzODM4MjsKICAgICAgICAgICAgIgogICAgICAgID4KICAgICAgICAgICAgPHN2ZwogICAgICAgICAgICBzdHlsZT0iCiAgICAgICAgICAgICAgICBmaWx0ZXI6IGludmVydCgxKTsKICAgICAgICAgICAgIgogICAgICAgICAgICB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNTg1LjkxMyA1ODUuOTEzIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1ODUuOTEzIDU4NS45MTM7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KICAgICAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xMS4xNzMsNDYuMnY0OTIuMzExbDM0Ni4yMiw0Ny40MDJWNTM1LjMzYzAuNzc2LDAuMDU4LDEuNTQyLDAuMTA5LDIuMzI5LDAuMTA5aDE3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AgIDwvc3Bhbj4KICAgIGA7CgogICAgd3JhcHBlci5hcHBlbmRDaGlsZChiYXIpOwoKICAgIC8vIOagt+W8jwogICAgY29uc3Qgc3R5bGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzdHlsZSIpOwoKICAgIHN0eWxlLmlubmVySFRNTCA9IGAKICAgICAgICAubnVtYmVyLWluZGljYXRvcnsKICAgICAgICAgICAgcG9zaXRpb246cmVsYXRpdmU7CiAgICAgICAgfQoKICAgICAgICAubnVtYmVyLWluZGljYXRvcjo6YWZ0ZXJ7CiAgICAgICAgICAgIGNvbnRlbnQ6IGF0dHIoZGF0YS1udW1iZXIpOwogICAgICAgICAgICBwb3NpdGlvbjogYWJzb2x1dGU7CiAgICAgICAgICAgIGJvdHRvbTogMDsKICAgICAgICAgICAgcmlnaHQ6IDA7CiAgICAgICAgICAgIGNvbG9yOiAjNDBhOWZmOwogICAgICAgICAgICBmb250LXNpemU6IDE0cHg7CiAgICAgICAgICAgIGZvbnQtd2VpZ2h0OiBib2xkOwogICAgICAgICAgICBiYWNrZ3JvdW5kOiAjMDAwOwogICAgICAgICAgICBib3JkZXItcmFkaXVzOiAxMHB4OwogICAgICAgICAgICBwYWRkaW5nOiAzcHggNXB4OwogICAgICAgIH0KCiAgICAgICAgLmNvcHktbGluazphY3RpdmV7CiAgICAgICAgICAgIGNvbG9yOiAjY2NjOwogICAgICAgIH0KCiAgICAgICAgLmRvd25sb2FkLWJ0bjpob3ZlcnsKICAgICAgICAgICAgdGV4dC1kZWNvcmF0aW9uOiB1bmRlcmxpbmU7CiAgICAgICAgfQogICAgICAgIC5kb3dubG9hZC1idG46YWN0aXZlewogICAgICAgICAgICBvcGFjaXR5OiAwLjk7CiAgICAgICAgfQoKICAgICAgICAubTN1OC1pdGVtewogICAgICAgICAgICBjb2xvcjogd2hpdGU7CiAgICAgICAgICAgIG1hcmdpbi1ib3R0b206IDVweDsKICAgICAgICAgICAgZGlzcGxheTogZmxleDsKICAgICAgICAgICAgZmxleC1kaXJlY3Rpb246IHJvdzsKICAgICAgICAgICAgYmFja2dyb3VuZDogYmxhY2s7CiAgICAgICAgICAgIHBhZGRpbmc6IDNweCAxMHB4OwogICAgICAgICAgICBib3JkZXItcmFkaXVzOiAzcHg7CiAgICAgICAgICAgIGZvbnQtc2l6ZTogMTRweDsKICAgICAgICAgICAgdXNlci1zZWxlY3Q6IG5vbmU7CiAgICAgICAgfQoKICAgICAgICBbZGF0YS1zaG93bj0iZmFsc2UiXSB7CiAgICAgICAgICAgIG9wYWNpdHk6IDAuODsKICAgICAgICAgICAgem9vbTogMC44OwogICAgICAgIH0KCiAgICAgICAgW2RhdGEtc2hvd249ImZhbHNlIl06aG92ZXJ7CiAgICAgICAgICAgIG9wYWNpdHk6IDE7CiAgICAgICAgfQoKICAgICAgICBbZGF0YS1zaG93bj0iZmFsc2UiXSAubTN1OC1pdGVtewogICAgICAgICAgICBkaXNwbGF5OiBub25lOwogICAgICAgIH0KCiAgICBgOwoKICAgIHdyYXBwZXIuYXBwZW5kQ2hpbGQoc3R5bGUpOwoKCgoKICAgIGNvbnN0IGJhckJ0biA9IGJhci5xdWVyeVNlbGVjdG9yKCIubnVtYmVyLWluZGljYXRvciIpOwoKICAgIC8vIOWFs+S6juaYvumakOWSjOenu+WKqAoKICAgIChhc3luYyBmdW5jdGlvbiAoKSB7CgogICAgICAgIGxldCBzaG93biA9IGF3YWl0IEdNX2dldFZhbHVlKCJzaG93biIsIHRydWUpOwogICAgICAgIHdyYXBwZXIuc2V0QXR0cmlidXRlKCJkYXRhLXNob3duIiwgc2hvd24pOwoKCiAgICAgICAgbGV0IHggPSBhd2FpdCBHTV9nZXRWYWx1ZSgieCIsIDEwKTsKICAgICAgICBsZXQgeSA9IGF3YWl0IEdNX2dldFZhbHVlKCJ5IiwgMTApOwoKICAgICAgICB4ID0gTWF0aC5taW4oaW5uZXJXaWR0aCAtIDUwLCB4KTsKICAgICAgICB5ID0gTWF0aC5taW4oaW5uZXJIZWlnaHQgLSA1MCwgeSk7CgogICAgICAgIGlmICh4IDwgMCkgeCA9IDA7CiAgICAgICAgaWYgKHkgPCAwKSB5ID0gMDsKCiAgICAgICAgcm9vdERpdi5zdHlsZS50b3AgPSBgJHt5fXB4YDsKICAgICAgICByb290RGl2LnN0eWxlLnJpZ2h0ID0gYCR7eH1weGA7CgogICAgICAgIGJhckJ0bi5hZGRFdmVudExpc3RlbmVyKCJtb3VzZWRvd24iLCBlID0+IHsKICAgICAgICAgICAgbGV0IHN0YXJ0WCA9IGUucGFnZVg7CiAgICAgICAgICAgIGxldCBzdGFydFkgPSBlLnBhZ2VZOwoKICAgICAgICAgICAgbGV0IG1vdmVkID0gZmFsc2U7CgogICAgICAgICAgICBsZXQgbW91c2Vtb3ZlID0gZSA9PiB7CiAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0WCA9IGUucGFnZVggLSBzdGFydFg7CiAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0WSA9IGUucGFnZVkgLSBzdGFydFk7CiAgICAgICAgICAgICAgICBpZiAobW92ZWQgfHwgKE1hdGguYWJzKG9mZnNldFgpICsgTWF0aC5hYnMob2Zmc2V0WSkpID4gNSkgewogICAgICAgICAgICAgICAgICAgIG1vdmVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICByb290RGl2LnN0eWxlLnRvcCA9IGAke3kgKyBvZmZzZXRZfXB4YDsKICAgICAgICAgICAgICAgICAgICByb290RGl2LnN0eWxlLnJpZ2h0ID0gYCR7eCAtIG9mZnNldFh9cHhgOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9OwogICAgICAgICAgICBsZXQgbW91c2V1cCA9IGUgPT4gewoKICAgICAgICAgICAgICAgIGxldCBvZmZzZXRYID0gZS5wYWdlWCAtIHN0YXJ0WDsKICAgICAgICAgICAgICAgIGxldCBvZmZzZXRZID0gZS5wYWdlWSAtIHN0YXJ0WTsKCiAgICAgICAgICAgICAgICBpZiAobW92ZWQpIHsKICAgICAgICAgICAgICAgICAgICB4IC09IG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgeSArPSBvZmZzZXRZOwogICAgICAgICAgICAgICAgICAgIG1nbWFwaS5zZXRWYWx1ZSgieCIsIHgpOwogICAgICAgICAgICAgICAgICAgIG1nbWFwaS5zZXRWYWx1ZSgieSIsIHkpOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBzaG93biA9ICFzaG93bjsKICAgICAgICAgICAgICAgICAgICBtZ21hcGkuc2V0VmFsdWUoInNob3duIiwgc2hvd24pOwogICAgICAgICAgICAgICAgICAgIHdyYXBwZXIuc2V0QXR0cmlidXRlKCJkYXRhLXNob3duIiwgc2hvd24pOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIHJlbW92ZUV2ZW50TGlzdGVuZXIoIm1vdXNlbW92ZSIsIG1vdXNlbW92ZSk7CiAgICAgICAgICAgICAgICByZW1vdmVFdmVudExpc3RlbmVyKCJtb3VzZXVwIiwgbW91c2V1cCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibW91c2Vtb3ZlIiwgbW91c2Vtb3ZlKTsKICAgICAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigibW91c2V1cCIsIG1vdXNldXApOwogICAgICAgIH0pOwogICAgfSkoKTsKCgoKCgoKICAgIGxldCBjb3VudCA9IDA7CiAgICBsZXQgc2hvd25VcmxzID0gW107CgoKICAgIGZ1bmN0aW9uIGRvVmlkZW9zKCkgewogICAgICAgIGZvciAobGV0IHYgb2YgQXJyYXkuZnJvbShkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCJ2aWRlbyIpKSkgewogICAgICAgICAgICBpZiAodi5kdXJhdGlvbiAmJiB2LnNyYyAmJiB2LnNyYy5zdGFydHNXaXRoKCJodHRwIikgJiYgKCFzaG93blVybHMuaW5jbHVkZXModi5zcmMpKSkgewogICAgICAgICAgICAgICAgY29uc3Qgc3JjID0gdi5zcmM7CgogICAgICAgICAgICAgICAgc2hvd25VcmxzLnB1c2goc3JjKTsKICAgICAgICAgICAgICAgIHNob3dWaWRlbyh7CiAgICAgICAgICAgICAgICAgICAgdHlwZTogInZpZGVvIiwKICAgICAgICAgICAgICAgICAgICB1cmw6IG5ldyBVUkwoc3JjKSwKICAgICAgICAgICAgICAgICAgICBkdXJhdGlvbjogYCR7TWF0aC5jZWlsKHYuZHVyYXRpb24gKiAxMCAvIDYwKSAvIDEwfSBtaW5zYCwKICAgICAgICAgICAgICAgICAgICBkb3dubG9hZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGV0YWlscyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogc3JjLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IG5ldyBVUkwoc3JjKS5wYXRobmFtZS5zcGxpdCgiLyIpLnNsaWNlKC0xKVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIS9cLlx3KyQvLnRlc3QobmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUubWF0Y2goL15ccyokLykpIG5hbWUgPSBEYXRlLm5vdygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lID0gbmFtZSArICIubXA0IjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHJlZmVyZXI6IGxvY2F0aW9uLm9yaWdpbiwgLy8g5LiN5YWB6K646K+l5aS0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3JpZ2luOiBsb2NhdGlvbi5vcmlnaW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbmVycm9yKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZ21hcGkub3BlbkluVGFiKHNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIG1nbWFwaS5kb3dubG9hZChkZXRhaWxzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIGFzeW5jIGZ1bmN0aW9uIGRvTTNVKHsgdXJsLCBjb250ZW50IH0pIHsKCiAgICAgICAgdXJsID0gbmV3IFVSTCh1cmwpOwoKICAgICAgICBpZiAoc2hvd25VcmxzLmluY2x1ZGVzKHVybC5ocmVmKSkgcmV0dXJuOwoKICAgICAgICAvLyDop6PmnpAgbTN1CiAgICAgICAgY29udGVudCA9IGNvbnRlbnQgfHwgYXdhaXQgKGF3YWl0IGZldGNoKHVybCkpLnRleHQoKTsKCiAgICAgICAgY29uc3QgcGFyc2VyID0gbmV3IG0zdThQYXJzZXIuUGFyc2VyKCk7CiAgICAgICAgcGFyc2VyLnB1c2goY29udGVudCk7CiAgICAgICAgcGFyc2VyLmVuZCgpOwogICAgICAgIGNvbnN0IG1hbmlmZXN0ID0gcGFyc2VyLm1hbmlmZXN0OwoKICAgICAgICBpZiAobWFuaWZlc3Quc2VnbWVudHMpIHsKICAgICAgICAgICAgbGV0IGR1cmF0aW9uID0gMDsKICAgICAgICAgICAgbWFuaWZlc3Quc2VnbWVudHMuZm9yRWFjaCgoc2VnbWVudCkgPT4gewogICAgICAgICAgICAgICAgZHVyYXRpb24gKz0gc2VnbWVudC5kdXJhdGlvbjsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIG1hbmlmZXN0LmR1cmF0aW9uID0gZHVyYXRpb247CiAgICAgICAgfQoKICAgICAgICBzaG93VmlkZW8oewogICAgICAgICAgICB0eXBlOiAibTN1OCIsCiAgICAgICAgICAgIHVybCwKICAgICAgICAgICAgZHVyYXRpb246IG1hbmlmZXN0LmR1cmF0aW9uID8gYCR7TWF0aC5jZWlsKG1hbmlmZXN0LmR1cmF0aW9uICogMTAgLyA2MCkgLyAxMH0gbWluc2AgOiBtYW5pZmVzdC5wbGF5bGlzdHMgPyBg5aSaKE11bHRpKSgke21hbmlmZXN0LnBsYXlsaXN0cy5sZW5ndGh9KWAgOiAi5pyq55+lKHVua25vd24pIiwKICAgICAgICAgICAgYXN5bmMgZG93bmxvYWQoKSB7CiAgICAgICAgICAgICAgICBtZ21hcGkub3BlbkluVGFiKAogICAgICAgICAgICAgICAgICAgIGBodHRwczovL3Rvb2xzLnRoYXR3aW5kLmNvbS90b29sL20zdThkb3dubG9hZGVyIyR7bmV3IFVSTFNlYXJjaFBhcmFtcyh7CiAgICAgICAgICAgICAgICAgICAgICAgIG0zdTg6IHVybC5ocmVmLAogICAgICAgICAgICAgICAgICAgICAgICByZWZlcmVyOiBsb2NhdGlvbi5ocmVmLAogICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZTogKGF3YWl0IGdldFRvcFRpdGxlKCkpIHx8ICIiCiAgICAgICAgICAgICAgICAgICAgfSl9YAogICAgICAgICAgICAgICAgKTsKICAgICAgICAgICAgfQogICAgICAgIH0pCgogICAgfQoKCgogICAgYXN5bmMgZnVuY3Rpb24gc2hvd1ZpZGVvKHsKICAgICAgICB0eXBlLAogICAgICAgIHVybCwKICAgICAgICBkdXJhdGlvbiwKICAgICAgICBkb3dubG9hZAogICAgfSkgewogICAgICAgIGxldCBkaXYgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICBkaXYuY2xhc3NOYW1lID0gIm0zdTgtaXRlbSI7CiAgICAgICAgZGl2LmlubmVySFRNTCA9IGAKICAgICAgICAgICAgPHNwYW4+JHt0eXBlfTwvc3Bhbj4KICAgICAgICAgICAgPHNwYW4KICAgICAgICAgICAgICAgIGNsYXNzPSJjb3B5LWxpbmsiCiAgICAgICAgICAgICAgICB0aXRsZT0iJHt1cmx9IgogICAgICAgICAgICAgICAgc3R5bGU9IgogICAgICAgICAgICAgICAgICAgIG1heC13aWR0aDogMjAwcHg7CiAgICAgICAgICAgICAgICAgICAgdGV4dC1vdmVyZmxvdzogZWxsaXBzaXM7CiAgICAgICAgICAgICAgICAgICAgd2hpdGUtc3BhY2U6IG5vd3JhcDsKICAgICAgICAgICAgICAgICAgICBvdmVyZmxvdzogaGlkZGVuOwogICAgICAgICAgICAgICAgICAgIG1hcmdpbi1sZWZ0OiAxMHB4OwogICAgICAgICAgICAgICAgIgogICAgICAgICAgICA+JHt1cmwucGF0aG5hbWV9PC9zcGFuPgogICAgICAgICAgICA8c3BhbiAKICAgICAgICAgICAgICAgIHN0eWxlPSIKICAgICAgICAgICAgICAgICAgICBtYXJnaW4tbGVmdDogMTBweDsKICAgICAgICAgICAgICAgICAgICBmbGV4LWdyb3c6IDE7CiAgICAgICAgICAgICAgICAiCiAgICAgICAgICAgID4ke2R1cmF0aW9ufTwvc3Bhbj4KICAgICAgICAgICAgPHNwYW4KICAgICAgICAgICAgICAgIGNsYXNzPSJkb3dubG9hZC1idG4iCiAgICAgICAgICAgICAgICBzdHlsZT0iCiAgICAgICAgICAgICAgICAgICAgbWFyZ2luLWxlZnQ6IDEwcHg7CiAgICAgICAgICAgICAgICAgICAgY3Vyc29yOiBwb2ludGVyOwogICAgICAgICAgICAiPuS4i+i9vShEb3dubG9hZCk8L3NwYW4+CiAgICAgICAgYDsKCiAgICAgICAgZGl2LnF1ZXJ5U2VsZWN0b3IoIi5jb3B5LWxpbmsiKS5hZGRFdmVudExpc3RlbmVyKCJjbGljayIsICgpID0+IHsKICAgICAgICAgICAgLy8g5aSN5Yi26ZO+5o6lCiAgICAgICAgICAgIG1nbWFwaS5jb3B5VGV4dCh1cmwuaHJlZik7CiAgICAgICAgICAgIG1nbWFwaS5tZXNzYWdlKCLlt7LlpI3liLbpk77mjqUgKGxpbmsgY29waWVkKSIsIDIwMDApOwogICAgICAgIH0pOwoKICAgICAgICBkaXYucXVlcnlTZWxlY3RvcigiLmRvd25sb2FkLWJ0biIpLmFkZEV2ZW50TGlzdGVuZXIoImNsaWNrIiwgZG93bmxvYWQpOwoKICAgICAgICByb290RGl2LnN0eWxlLmRpc3BsYXkgPSAiYmxvY2siOwoKICAgICAgICBjb3VudCsrOwoKICAgICAgICBzaG93blVybHMucHVzaCh1cmwuaHJlZik7CgogICAgICAgIGJhci5xdWVyeVNlbGVjdG9yKCIubnVtYmVyLWluZGljYXRvciIpLnNldEF0dHJpYnV0ZSgiZGF0YS1udW1iZXIiLCBjb3VudCk7CgogICAgICAgIHdyYXBwZXIuYXBwZW5kQ2hpbGQoZGl2KTsKICAgIH0KCn0pKCk7CgooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIGNvbnN0IHJlZyA9IC9tYWduZXQ6XD94dD11cm46YnRpaDpcd3sxMCx9KFstYS16QS1aMC05KClAOiVfXCsufiM/Ji8vPV0qKS87CgogICAgbGV0IGwgPSBuYXZpZ2F0b3IubGFuZ3VhZ2UgfHwgImVuIjsKICAgIGlmIChsLnN0YXJ0c1dpdGgoImVuLSIpKSBsID0gImVuIjsKICAgIGVsc2UgaWYgKGwuc3RhcnRzV2l0aCgiemgtIikpIGwgPSAiemgtQ04iOwogICAgZWxzZSBsID0gImVuIjsKCiAgICBjb25zdCBUID0gewogICAgICAgICJlbiI6IHsKICAgICAgICAgICAgcGxheTogIlBsYXkiCiAgICAgICAgfSwKICAgICAgICAiemgtQ04iOiB7CiAgICAgICAgICAgIHBsYXk6ICfmkq3mlL4nCiAgICAgICAgfQogICAgfVtsXTsKCiAgICB3aGVuRE9NUmVhZHkoKCkgPT4gewogICAgICAgIGFkZFN0eWxlKGAKICAgICAgICAgICAgYnV0dG9uW2RhdGEtd3RtemprLW1hZy11cmxdewogICAgICAgICAgICAgICAgYWxsOiBpbml0aWFsOwogICAgICAgICAgICAgICAgYm9yZGVyOiBub25lOwogICAgICAgICAgICAgICAgb3V0bGluZTogbm9uZTsKICAgICAgICAgICAgICAgIGJhY2tncm91bmQ6IG5vbmU7CiAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kOiAjZjdkMzA4OwogICAgICAgICAgICAgICAgYmFja2dyb3VuZDogIzA4YTZmNzsKICAgICAgICAgICAgICAgIG1hcmdpbjogMnB4IDhweDsKICAgICAgICAgICAgICAgIGJvcmRlci1yYWRpdXM6IDNweDsKICAgICAgICAgICAgICAgIGNvbG9yOiB3aGl0ZTsKICAgICAgICAgICAgICAgIGN1cnNvcjogcG9pbnRlcjsKICAgICAgICAgICAgICAgIGRpc3BsYXk6IGlubGluZS1mbGV4OwogICAgICAgICAgICAgICAgaGVpZ2h0OiAxLjZlbTsKICAgICAgICAgICAgICAgIHBhZGRpbmc6IDAgLjhlbTsKICAgICAgICAgICAgICAgIGFsaWduLWl0ZW1zOiBjZW50ZXI7CiAgICAgICAgICAgICAgICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjsKICAgICAgICAgICAgICAgIHRyYW5zaXRpb246IGJhY2tncm91bmQgLjE1czsKICAgICAgICAgICAgICAgIHRleHQtZGVjb3JhdGlvbjogbm9uZTsKICAgICAgICAgICAgICAgIGJvcmRlci1yYWRpdXM6IDAuOGVtOwogICAgICAgICAgICAgICAgZm9udC1zaXplOiBzbWFsbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBidXR0b25bZGF0YS13dG16amstbWFnLXVybF0+c3ZnewogICAgICAgICAgICAgICAgaGVpZ2h0OiA2MCU7CiAgICAgICAgICAgICAgICBmaWxsOiB3aGl0ZTsKICAgICAgICAgICAgICAgIHBvaW50ZXItZXZlbnRzOiBub25lOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJ1dHRvbltkYXRhLXd0bXpqay1tYWctdXJsXTpob3ZlcnsKICAgICAgICAgICAgICAgIGJhY2tncm91bmQ6ICNmYWUxNTc7CiAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kOiAjMzliOWY5OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJ1dHRvbltkYXRhLXd0bXpqay1tYWctdXJsXTphY3RpdmV7CiAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kOiAjZGZiZTA3OwogICAgICAgICAgICAgICAgYmFja2dyb3VuZDogIzA3OTdkZjsKICAgICAgICAgICAgfQogICAgICAgICAgICBidXR0b25bZGF0YS13dG16amstbWFnLXVybF0+c3BhbnsKICAgICAgICAgICAgICAgIHBvaW50ZXItZXZlbnRzOiBub25lOwogICAgICAgICAgICAgICAgZm9udC1zaXplOiBzbWFsbDttYXJnaW4tcmlnaHQ6IC41ZW07Zm9udC13ZWlnaHQ6Ym9sZDtjb2xvcjp3aGl0ZSAhaW1wb3J0YW50OwogICAgICAgICAgICB9CiAgICAgICAgYCk7CiAgICAgICAgd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoImNsaWNrIiwgb25FdmVudHMsIHRydWUpOwogICAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCJtb3VzZWRvd24iLCBvbkV2ZW50cywgdHJ1ZSk7CiAgICAgICAgd2luZG93LmFkZEV2ZW50TGlzdGVuZXIoIm1vdXNldXAiLCBvbkV2ZW50cywgdHJ1ZSk7CgogICAgICAgIHdhdGNoQm9keUNoYW5nZSh3b3JrKTsKICAgIH0pOwoKICAgIGZ1bmN0aW9uIG9uRXZlbnRzKGUpIHsKICAgICAgICBpZiAoZS50YXJnZXQuaGFzQXR0cmlidXRlKCdkYXRhLXd0bXpqay1tYWctdXJsJykpIHsKICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICA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gICAgICAgICAgICAgIGxldCBtYXRjaCA9IHRleHQubWF0Y2gocmVnKTsKICAgICAgICAgICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgICAgICAgICAgIGxldCB1cmwgPSBtYXRjaFswXTsKICAgICAgICAgICAgICAgICAgICBsZXQgcCA9IG5vZGUucGFyZW50Tm9kZTsKICAgICAgICAgICAgICAgICAgICBwLmluc2VydEJlZm9yZShkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZSh0ZXh0LnNsaWNlKDAsIG1hdGNoLmluZGV4ICsgdXJsLmxlbmd0aCkpLCBub2RlKTsKICAgICAgICAgICAgICAgICAgICBwLmluc2VydEJlZm9yZShjcmVhdGVXYXRjaEJ1dHRvbih1cmwsIHRydWUpLCBub2RlKTsKICAgICAgICAgICAgICAgICAgICBwLmluc2VydEJlZm9yZShkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZSh0ZXh0LnNsaWNlKG1hdGNoLmluZGV4ICsgdXJsLmxlbmd0aCkpLCBub2RlKTsKICAgICAgICAgICAgICAgICAgICBwLnJlbW92ZUNoaWxkKG5vZGUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGEgb2YgQXJyYXkuZnJvbShkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKAogICAgICAgICAgICBbJ2hyZWYnLCAndmFsdWUnLCAnZGF0YS1jbGlwYm9hcmQtdGV4dCcsICdkYXRhLXZhbHVlJywgJ3RpdGxlJywgJ2FsdCcsICdkYXRhLXVybCcsICdkYXRhLW1hZ25ldCcsICdkYXRhLWNvcHknXS5tYXAobiA9PiBgWyR7bn0qPSJtYWduZXQ6P3h0PXVybjpidGloOiJdYCkuam9pbignLCcpCiAgICAgICAgKSkpIHsKICAgICAgICAgICAgaWYgKGEubmV4dFNpYmxpbmcgJiYgYS5uZXh0U2libGluZy5oYXNBdHRyaWJ1dGUgJiYgYS5uZXh0U2libGluZy5oYXNBdHRyaWJ1dGUoJ2RhdGEtd3RtemprLW1hZy11cmwnKSkgY29udGludWU7IC8vIOW3sue7j+a3u+WKoAogICAgICAgICAgICBpZiAocmVnLnRlc3QoYS50ZXh0Q29udGVudCkpIGNvbnRpbnVlOwogICAgICAgICAgICBmb3IgKGxldCBhdHRyIG9mIGEuZ2V0QXR0cmlidXRlTmFtZXMoKSkgewogICAgICAgICAgICAgICAgbGV0IHZhbCA9IGEuZ2V0QXR0cmlidXRlKGF0dHIpOwogICAgICAgICAgICAgICAgaWYgKCFyZWcudGVzdCh2YWwpKSBjb250aW51ZTsKICAgICAgICAgICAgICAgIGxldCB1cmwgPSB2YWwubWF0Y2gocmVnKVswXTsKICAgICAgICAgICAgICAgIGEucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUoY3JlYXRlV2F0Y2hCdXR0b24odXJsKSwgYS5uZXh0U2libGluZyk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgoKICAgIGZ1bmN0aW9uIHdhdGNoQm9keUNoYW5nZShvbmNoYW5nZSkgewogICAgICAgIGxldCB0aW1lb3V0OwogICAgICAgIGxldCBvYnNlcnZlciA9IG5ldyBNdXRhdGlvbk9ic2VydmVyKCgpID0+IHsKICAgICAgICAgICAgaWYgKCF0aW1lb3V0KSB7CiAgICAgICAgICAgICAgICB0aW1lb3V0ID0gc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgdGltZW91dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgb25jaGFuZ2UoKTsKICAgICAgICAgICAgICAgIH0sIDIwMCk7CiAgICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICBvYnNlcnZlci5vYnNlcnZlKGRvY3VtZW50LmRvY3VtZW50RWxlbWVudCwgewogICAgICAgICAgICBjaGlsZExpc3Q6IHRydWUsCiAgICAgICAgICAgIHN1YnRyZWU6IHRydWUsCiAgICAgICAgICAgIGF0dHJpYnV0ZXM6IHRydWUsCiAgICAgICAgICAgI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
Add Comment
Please, Sign In to add comment