xiaomianao666

插件名:global_JAVBUS影片预告

Jun 27th, 2024
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_JAVBUS影片预告@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICBKQVZCVVPlvbHniYfpooTlkYoKLy8gQG5hbWVzcGFjZSAgICBodHRwOi8vdGFtcGVybW9ua2V5Lm5ldC8KLy8gQHZlcnNpb24gICAgICAxLjgKLy8gQGRlc2NyaXB0aW9uICBKQVZCVVPoh6rliqjmmL7npLrpooTlkYrniYcKLy8gQGF1dGhvciAgICAgICBBOQovLyBAc3VwcG9ydFVSTCAgIGh0dHBzOi8vc2xlYXp5Zm9yay5vcmcvemgtQ04vc2NyaXB0cy80NTA3NDAvZmVlZGJhY2sKLy8gQHNvdXJjZSAgICAgICBodHRwczovL2dpdGh1Yi5jb20vYmlnd29sZjk5ODcvSmF2QnVzVHJhaWxlcgovLyBAbWF0Y2ggICAgICAgIGh0dHBzOi8vd3d3LmphdmJ1cy5jb20vCi8vIEBpbmNsdWRlICAgICAgL15odHRwcz86XC9cLyg/OltBLVphLXowLTldK1wuKSooPzpqYXZidXN8YnVzamF2fGJ1c2ZhbnxmYW5idXN8YnVzY2RufGNkbmJ1c3xkbW1zZWV8c2VlZG1tfGJ1c2RtbXxkbW1idXN8amF2c2VlfHNlZWphdil7MX0oPzpcLltBLVphLXowLTldKyk/XC9bXHdfLV17MSx9XC8/JC8KLy8gQGV4Y2x1ZGUgICAgICAvXmh0dHBzPzpcL1wvKD86W0EtWmEtejAtOV0rXC4pKig/OmphdmJ1c3xidXNqYXZ8YnVzZmFufGZhbmJ1c3xidXNjZG58Y2RuYnVzfGRtbXNlZXxzZWVkbW18YnVzZG1tfGRtbWJ1c3xqYXZzZWV8c2VlamF2KXsxfSg/OlwuW0EtWmEtejAtOV0rKT9cLyg/OmZvcnVtfGFjdHJlc3Nlc3x1bmNlbnN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aXNFdXJvcGVPckFtZXJpY2EsCiAgICAgIHRodW1ibmFpbFVSTCwKICAgICAgdGl0bGVLZXlQaHJhc2UsCiAgICB9KTsKICAgIHJldHVybiB7CiAgICAgIHRpdGxlLAogICAgICBtb3ZpZUlkLAogICAgICBjb3JwTmFtZSwKICAgICAgaXNWUiwKICAgICAgaXNVbmNlbnNvcmVkLAogICAgICBpc0V1cm9wZU9yQW1lcmljYSwKICAgICAgdGh1bWJuYWlsVVJMLAogICAgICB0aXRsZUtleVBocmFzZSwKICAgIH07CiAgfQoKICAvKioKICAgKiBBcHBlbmQgcGxheWVyIHN0eWxlCiAgICovCiAgZnVuY3Rpb24gYWRkUHJldmlld1ZpZGVvU3R5bGUoKSB7CiAgICBsZXQgY29udGFpbmVyU3R5bGUgPSBgCiAgICAgICAgI3ByZXZpZXctdmlkZW8tY29udGFpbmVyewogICAgICAgICAgICBwb3NpdGlvbjogZml4ZWQ7CiAgICAgICAgICAgIGhlaWdodDogMTAwJTsKICAgICAgICAgICAgd2lkdGg6IDEwMCU7CiAgICAgICAgICAgIGJhY2tncm91bmQtY29sb3I6IHJnYmEoMCwwLDAsMC44KTsKICAgICAgICAgICAgdG9wOiAwcHg7CiAgICAgICAgICAgIHotaW5kZXg6IDk5OTsKICAgICAgICAgICAgZGlzcGxheTogbm9uZTsKICAgICAgICAgICAgYWxpZ24taXRlbXM6IGNlbnRlcjsKICAgICAgICAgICAganVzdGlmeS1jb250ZW50OiBjZW50ZXI7CiAgICAgICAgfQogICAgICAgICNwcmV2aWV3LXZpZGVvLWNvbnRhaW5lcjpiZWZvcmUgewogICAgICAgICAgICBjb250ZW50OiAnXFwyNzE1JzsKICAgICAgICAgICAgZm9udC1zaXplOiAyOHB4OwogICAgICAgICAgICBjb2xvcjogd2hpdGU7CiAgICAgICAgICAgIG9wYWNpdHk6IDAuNzsKICAgICAgICAgICAgcmlnaHQ6IDE4cHg7CiAgICAgICAgICAgIHRvcDogOHB4OwogICAgICAgICAgICBwb3NpdGlvbjogYWJzb2x1dGU7CiAgICAgICAgICAgIGN1cnNvcjogcG9pbnRlcjsKICAgICAgICAgICAgcG9pbnRlci1ldmVudHM6bm9uZTsKICAgICAgICB9CiAgICAgICAgI3ByZXZpZXctdmlkZW8tcGxheWVyewogICAgICAgICAgICBoZWlnaHQ6IDgwJTsKICAgICAgICAgICAgbWluLXdpZHRoOiA3MCU7CiAgICAgICAgICAgIG1heC13aWR0aDogODAlOwogICAgICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiAjMDAwOwogICAgICAgICAgICBib3JkZXItcmFkaXVzOiA4cHg7CiAgICAgICAgICAgIG91dGxpbmU6IG5vbmU7CiAgICAgICAgICAgIG92ZXJmbG93OiBoaWRkZW47CiAgICAgICAgfQogICAgICAgIC5wcmV2aWV3LXZpZGVvLWltZy1jb250YWluZXJ7CiAgICAgICAgICAgIHBvc2l0aW9uOiByZWxhdGl2ZTsKICAgICAgICAgICAgY3Vyc29yOnBvaW50ZXI7CiAgICAgICAgfQogICAgICAgIC5wcmV2aWV3LXZpZGVvLWltZy1jb250YWluZXIgaW1newogICAgICAgICAgICBtYXgtd2lkdGg6IDEwMCU7CiAgICAgICAgICAgIG9iamVjdC1maXQ6IGNvdmVyOwogICAgICAgICAgICB3aWR0aDogMTIwcHg7CiAgICAgICAgfQogICAgICAgIC5wcmV2aWV3LXZpZGVvLWltZy1jb250YWluZXI6YWZ0ZXIgewogICAgICAgICAgICBiYWNrZ3JvdW5kLWltYWdlOiB1cmwoImRhdGE6aW1hZ2Uvc3ZnK3htbCwlM0NzdmcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyAgdmlld0JveD0nMCAwIDUxMiA1MTInJTNFJTNDcGF0aCBkPSdNNDQ4IDI1NWMwLTEwNi04Ni0xOTItMTkyLTE5MlM2NCAxNTAgNjQgMjU2czg2IDE5MiAxOTIgMTkyIDE5Mi04NiAxOTItMTkyeicgZmlsbD0nZ29sZCcgIGZpbGwtb3Bh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pZUluZm8udmlkZW9VUkx9IiB0eXBlPSJ2aWRlby9tcDQiIC8+CiAgICAgICAgPC92aWRlbz5gOwogICAgICBpZiAoCiAgICAgICAgdmlkZW9qcyAmJgogICAgICAgICgoc2V0dGluZ3MuZW5hYmxlX3ZyX21vZGUgPT0gdHJ1ZSAmJiBtb3ZpZUluZm8uaXNWUikgfHwKICAgICAgICAgIGlzTTNVOChtb3ZpZUluZm8udmlkZW9VUkwpKQogICAgICApIHsKICAgICAgICB2aWRlbyA9IGAKICAgICAgICAgICAgICA8dmlkZW8gaWQ9InByZXZpZXctdmlkZW8tcGxheWVyIiBjbGFzcz0idmlkZW8tanMiIHBsYXlzaW5saW5lIGNvbnRyb2xzIHByZWxvYWQ9Im5vbmUiIAogICAgICAgICAgICAgICR7bXV0ZWR9IHBvc3Rlcj0iJHsKICAgICAgICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoImEuYmlnSW1hZ2UgaW1nIik/LnNyYwogICAgICAgIH0iIGNyb3Nzb3JpZ2luPSJhbm9ueW1vdXMiPgogICAgICAgICAgICAgIDwvdmlkZW8+YDsKICAgICAgfQogICAgfQogICAgbGV0IHZDb250YWluZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgIHZDb250YWluZXIuaWQgPSAicHJldmlldy12aWRlby1jb250YWluZXIiOwogICAgdkNvbnRhaW5lci5pbm5lckhUTUwgPSB2aWRlbzsKCiAgICAvL29uY2xpY2sgZXZlbnQgLS0gaGlkZSBhbmQgcGF1c2UgcGxheWVyCiAgICB2Q29udGFpbmVyLmFkZEV2ZW50TGlzdGVuZXIoImNsaWNrIiwgKGV2ZW50KSA9PiB7CiAgICAgIGlmIChldmVudD8udGFyZ2V0ICE9IHZDb250YWluZXIpIHJldHVybjsKICAgICAgdkNvbnRhaW5lci5zdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgICBpZiAocGxheWVyKSB7CiAgICAgICAgcGxheWVyLnBhdXNlKCk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgLy9yZXNldCBpZnJhbWUgdG8gcGF1c2UgdmlkZW8KICAgICAgICBpZiAobmVlZENPUlMobW92aWVJbmZvLnZpZGVvVVJMKSkgewogICAgICAgICAgY29uc3QgaWZyYW1lID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcigiI3ByZXZpZXctdmlkZW8taWZyYW1lIik7CiAgICAgICAgICBsZXQgb3JpZ2luSWZyYW1lID0gaWZyYW1lLmNsb25lTm9kZSh0cnVlKTsKICAgICAgICAgIGlmcmFtZS5wYXJlbnRFbGVtZW50LmFwcGVuZChvcmlnaW5JZnJhbWUpOwogICAgICAgICAgaWZyYW1lLnJlbW92ZSgpOwogICAgICAgIH0KICAgICAgfQogICAgICBkb2N1bWVudC5ib2R5LnN0eWxlLm92ZXJmbG93ID0gImF1dG8iOwogICAgfSk7CiAgICBkb2N1bWVudC5ib2R5LmFwcGVuZCh2Q29udGFpbmVyKTsKICAgIGluaXRWaWRlb1BsYXllcihtb3ZpZUluZm8pOwogICAgYWRkVmlkZW9QcmV2aWV3SW1hZ2UoKTsKICB9CgogIGZ1bmN0aW9uIGluaXRWaWRlb1BsYXllcihtb3ZpZUluZm8pIHsKICAgIGlmIChuZWVkQ09SUyhtb3ZpZUluZm8udmlkZW9VUkwpKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGlmICgKICAgICAgdmlkZW9qcyAmJgogICAgICAoKHNldHRpbmdzLmVuYWJsZV92cl9tb2RlID09IHRydWUgJiYgbW92aWVJbmZvLmlzVlIpIHx8IGlzTTNVOChtb3ZpZUluZm8udmlkZW9VUkwpKQogICAgKSB7CiAgICAgIHBsYXllciA9IHZpZGVvanMoInByZXZpZXctdmlkZW8tcGxheWVyIiwgewogICAgICAgIHBsYXliYWNrUmF0ZXM6IFswLjUsIDEsIDEuNSwgMl0sCiAgICAgIH0pOwogICAgICBwbGF5ZXIubWVkaWFpbmZvID0gcGxheWVyLm1lZGlhaW5mbyB8fCB7fTsKICAgICAgaWYgKGlzTTNVOChtb3ZpZUluZm8udmlkZW9VUkwpKSB7CiAgICAgICAgcGxheWVyLnNyYyh7CiAgICAgICAgICB0eXBlOiAiYXBwbGljYXRpb24veC1tcGVnVVJMIiwKICAgICAgICAgIHNyYzogbW92aWVJbmZvLnZpZGVvVVJMLAogICAgICAgIH0pOwogICAgICB9CiAgICAgIC8vZW5hYmxlZCB2ciBwbHVnaW4KICAgICAgaWYgKG1vdmllSW5mby5pc1ZSKSB7CiAgICAgICAgcGxheWVyLnNyYyh7CiAgICAgICAgICB0eXBlOiAidmlkZW8vbXA0IiwKICAgICAgICAgIHNyYzogbW92aWVJbmZvLnZpZGVvVVJMLAogICAgICAgIH0pOwogICAgICAgIHBsYXllci5tZWRpYWluZm8ucHJvamVjdGlvbiA9ICIzNjAiOwogICAgICAgIHBsYXllci52cih7IHByb2plY3Rpb246ICJBVVRPIiB9KTsKICAgICAgICBwbGF5ZXIudnIoKS5vbigiaW5pdGlhbGl6ZWQiLCAoKSA9PiB7CiAgICAgICAgICBwbGF5ZXIudnIoKS5jYW1lcmEucG9zaXRpb24ueCA9IC0xLjM5ODE1OTEwODE3Mzg5ODI7CiAgICAgICAgICBwbGF5ZXIudnIoKS5jYW1lcmEucG9zaXRpb24ueSA9IDAuMDM1MzA0MDExMTE4OTQ0MjUzOwogICAgICAgICAgcGxheWVyLnZyKCkuY2FtZXJhLnBvc2l0aW9uLnogPSAtMC43OTA0NjU0MzIzNzYxNjg2OwogICAgICAgIH0pOwogICAgICAgIHBsYXllci50ZWNoKGZhbHNlKTsgLy90ZWNoKCkgd2lsbCBsb2cgd2FybmluZyB3aXRob3V0IGFueSBhcmd1bWVudAogICAgICB9CiAgICAgIHBsYXllci5kZWZhdWx0UGxheWJhY2tSYXRlKHNldHRpbmdzLnZpZGVvX3BsYXliYWNrX3NwZWVkKTsKICAgIH0gZWxzZSB7CiAgICAgIHBsYXllciA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0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Shtb3ZpZUluZm8pOwogICAgICB9KQogICAgICAuY2F0Y2goKGUpID0+IHsKICAgICAgICBsb2coZSk7CiAgICAgICAgcmV0dXJuIHF1ZXJ5Q0YobW92aWVJbmZvKTsKICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgbG9nKGUpOwogICAgICAgIHJldHVybiBxdWVyeURNTVZpZGVvVVJMKG1vdmllSW5mbywgdW5kZWZpbmVkLCBmYWxzZSwgIm1oYiIpOwogICAgICB9KQogICAgICAuY2F0Y2goKGUpID0+IHsKICAgICAgICBsb2coZSk7CiAgICAgICAgcmV0dXJuIHF1ZXJ5RE1NVmlkZW9VUkwobW92aWVJbmZvKTsKICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgbG9nKGUpOwogICAgICAgIHJldHVybiBxdWVyeURNTVZpZGVvVVJMKG1vdmllSW5mbywgdW5kZWZpbmVkLCB0cnVlKTsKICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgbG9nKGUpOwogICAgICAgIHJldHVybiBxdWVyeVByZXN0aWdlVmlkZW9VUkwobW92aWVJbmZvKTsKICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgbG9nKGUpOwogICAgICAgIHJldHVybiBxdWVyeU1HU3RhZ2VWaWRlb1VSTChtb3ZpZUluZm8pOwogICAgICB9KQogICAgICAuY2F0Y2goKGUpID0+IHsKICAgICAgICBsb2coZSk7CiAgICAgICAgcmV0dXJuIHF1ZXJ5TUdTdGFnZVZpZGVvVVJMKG1vdmllSW5mbywgZmFsc2UsIHRydWUpOwogICAgICB9KQogICAgICAuY2F0Y2goKGUpID0+IHsKICAgICAgICBsb2coZSk7CiAgICAgICAgLy9yZXRyeSBxdWVyeSAodXNlIG1vdmllIHRpdGxlIGFzIGtleXdvcmQpCiAgICAgICAgcmV0dXJuIHF1ZXJ5TUdTdGFnZVZpZGVvVVJMKG1vdmllSW5mbywg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244KA44GZ44KBIiB8fAogICAgICBtb3ZpZUluZm8uY29ycE5hbWUudG9VcHBlckNhc2UoKSA9PT0gIjEwTVVTVU1FIgogICAgKSB7CiAgICAgIHZpZGVvVVJMcyA9IHF1YWxpdHlBcnIubWFwKAogICAgICAgIChxdWFsaXR5KSA9PgogICAgICAgICAgYGh0dHBzOi8vc21vdmllLjEwbXVzdW1lLmNvbS9zYW1wbGUvbW92aWVzLyR7bW92aWVJbmZvLm1vdmllSWR9LyR7cXVhbGl0eX1gCiAgICAgICk7CiAgICB9IGVsc2UgaWYgKAogICAgICBtb3ZpZUluZm8uY29ycE5hbWUgPT09ICLkuIDmnKzpgZMiIHx8CiAgICAgIG1vdmllSW5mby5jb3JwTmFtZS50b1VwcGVyQ2FzZSgpID09PSAiMVBPTkRPIgogICAgKSB7CiAgICAgIHZpZGVvVVJMcyA9IHF1YWxpdHlBcnIubWFwKAogICAgICAgIChxdWFsaXR5KSA9PgogICAgICAgICAgYGh0dHBzOi8vc21vdmllLjFwb25kby50di9zYW1wbGUvbW92aWVzLyR7bW92aWVJbmZvLm1vdmllSWR9LyR7cXVhbGl0eX1gCiAgICAgICk7CiAgICAgIHZpZGVvVVJMcy5wdXNoKAogICAgICAgIGBodHRwczovL3BwdmNsaXBzMDIuYXZlbnRlcnRhaW5tZW50cy5jb20vMDFtM3U4LzFwb25fJHttb3ZpZUluZm8ubW92aWVJZH0vMXBvbl8ke21vdmllSW5mby5tb3ZpZUlkfS5tM3U4YAogICAgICApOwogICAgfSBlbHNlIGlmICgKICAgICAgbW92aWVJbmZvLmNvcnBOYW1lID09PSAi44Ov44Oz44OU44O844K5IiB8fAogICAgICBtb3ZpZUluZm8uY29ycE5hbWUgPT09ICLjgqrjg6rjgqjjg7Pjgr/jg6vjg4njg6rjg7zjg6AiIHx8CiAgICAgIG1vdmllSW5mby5jb3JwTmFtZS50b1VwcGVyQ2FzZSgpID09PSAiT05FUElFQ0VFTlRFUlRBSU5NRU5UIiB8fAogICAgICBtb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lIGh0dHBzOi8vYml0Lmx5LzNSa2dxU28KICAgIGxldCBzZXJ2ZXJVUkwgPSAiaHR0cHM6Ly9hcGkuamF2c3B5bC5ldS5vcmcvYXBpLyI7CiAgICByZXR1cm4gYXdhaXQgeEZldGNoKHNlcnZlclVSTCwgewogICAgICBoZWFkZXJzOiB7CiAgICAgICAgb3JpZ2luOiAiaHR0cHM6Ly9hcGkuamF2c3B5bC5ldS5vcmciLAogICAgICAgICJDb250ZW50LVR5cGUiOiAiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkIiwKICAgICAgfSwKICAgICAgZGF0YTogYElEPSR7bW92aWVJbmZvLm1vdmllSWR9YCwKICAgICAgbWV0aG9kOiAiUE9TVCIsCiAgICB9KQogICAgICAudGhlbigocmVzcCkgPT4gewogICAgICAgIGlmIChyZXNwPy5zdGF0dXMgIT09IDIwMCB8fCAhcmVzcC5yZXNwb25zZVRleHQpCiAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QoIkphdlNweWwgc2VydmVyIG5vdCBmb3VuZCBtb3ZpZS4iKTsKICAgICAgICByZXR1cm4gSlNPTi5wYXJzZShyZXNwLnJlc3BvbnNlVGV4dCk7CiAgICAgIH0pCiAgICAgIC50aGVuKCh2aWRlbykgPT4gewogICAgICAgIGlmICh2aWRlbz8uaW5mbz8udXJsPy5sZW5ndGggPiAwKSB7CiAgICAgICAgICBsb2coIkphdlNweWwgc2VydmVyIHJlc3VsdCB2aWRlbyB1cmw6IGh0dHBzOi8vIiArIHZpZGVvLmluZm8udXJsKTsKICAgICAgICAgIHJldHVybiAiaHR0cHM6Ly8iICsgdmlkZW8uaW5mby51cmw7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdCgiSmF2U3B5bCBzZXJ2ZXIgbm90IGZvdW5kIG1vdmllLiIpOwogICAgICAgIH0KICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgcm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iByZXN1bHRNb3ZpZXMudmFsdWVzKCkpIHsKICAgICAgICAgIGlmIChtYXRjaE1vdmllQnlLZXl3b3JkKGVsZW1lbnQuaW5uZXJIVE1MLCBtb3ZpZUluZm8pKSB7CiAgICAgICAgICAgIHRhcmdldE1vdmllRWxlID0gZWxlbWVudDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICghdGFyZ2V0TW92aWVFbGUpIHJldHVybiBub3RGb3VuZCgpOwogICAgICAgIGxldCBhdkRldGFpbFBhdGhOYW1lID0gdGFyZ2V0TW92aWVFbGUucXVlcnlTZWxlY3RvcigiYSIpPy5wYXRobmFtZTsKICAgICAgICBpZiAoIWF2RGV0YWlsUGF0aE5hbWUpIHJldHVybiBub3RGb3VuZCgpOwogICAgICAgIHJldHVybiBmZXRjaCgiaHR0cHM6Ly9qYXZkYi5jb20iICsgYXZEZXRhaWxQYXRoTmFtZSk7CiAgICAgIH0pCiAgICAgIC50aGVuKChhdkRldGFpbFJlc3ApID0+IHsKICAgICAgICByZXR1cm4gYXZEZXRhaWxSZXNwLnRleHQoKTsKICAgICAgfSkKICAgICAgLnRoZW4oKHRleHQpID0+IHsKICAgICAgICAvL0phdkRCIG1vdmllIGRldGFpbCBwYWdlIHJlc3VsdC4KICAgICAgICBsZXQgZG9jID0gY29udmVydFRleHRUb0RPTSh0ZXh0KTsKICAgICAgICBsZXQgdmlkZW9Tb3VyY2UgPSBkb2MucXVlcnlTZWxlY3RvcigiI3ByZXZpZXctdmlkZW8gc291cmNlIik7CiAgICAgICAgaWYgKHZpZGVvU291cmNlICYmIHZpZGVvU291cmNlPy5zcmMgJiYgdmlkZW9Tb3VyY2Uuc3JjICE9IGxvY2F0aW9uLmhyZWYpIHsKICAgICAgICAgIGxvZygiSmF2REIgc2VydmVyIHJlc3VsdCB2aWRlbyB1cmw6ICIgKyB2aWRlb1NvdXJjZS5zcmMpOwogICAgICAgICAgcmV0dXJuIHZpZGVvU291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TsKICAgICAgICAgIGlmIChtYXRjaE1vdmllQnlLZXl3b3JkKGVsZW1lbnQsIG1vdmllSW5mbykpIHsKICAgICAgICAgICAgdGFyZ2V0TW92aWVFbGUgPSBlbGVtZW50OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGlmICghdGFyZ2V0TW92aWVFbGUpIHJldHVybiBub3RGb3VuZCgpOwogICAgICAgIGxldCBhdkRldGFpbFVSTCA9IHRhcmdldE1vdmllRWxlLm1hdGNoKC90bWIuKj9ocmVmPSIoXFMqPykiL3MpPy5hdCgxKTsKICAgICAgICBpZiAoIWF2RGV0YWlsVVJMKSByZXR1cm4gbm90Rm91bmQoKTsKICAgICAgICAvL3JlbW92ZSB1bnVzZSBwYXJhbXMKICAgICAgICByZXR1cm4geEZldGNoKGF2RGV0YWlsVVJMLnNwbGl0KCI/IilbMF0sIHsKICAgICAgICAgIGhlYWRlcnM6IGhlYWRlcnMsCiAgICAgICAgfSk7CiAgICAgIH0pCiAgICAgIC50aGVuKChhdkRldGFpbFJlc3ApID0+IHsKICAgICAgICAvL0RpZmZlcmVudCBsaW5rIGZvcm1hdCwgZ2V0IHR3aWNlLgogICAgICAgIGxldCB2aWRlb0lmcmFtZVVSTCA9IGF2RGV0YWlsUmVzcC5yZXNwb25zZVRleHQKICAgICAgICAgID8ubWF0Y2goL2RhdGEtdmlkZW8tdXJsPSIoXFMqPykiL3MpCiAgICAgICAgICA/LmF0KDEpOwogICAgICAgIGlmICghdmlkZW9JZnJhbWVVUkwpIHsKICAgICAgICAgIC8vdHJ5IGFnYWluCiAgICAgICAgICB2aWRlb0lmcmFtZVVSTCA9IGF2RGV0YWlsUmVzcC5yZXNwb25zZVRleHQKICAgICAgICAgICAgPy5tYXRjaCgvc2FtcGxlcGxheVwoJyhcUyo/KSdcKS9zKQogICAgICAgICAgICA/LmF0KDEpOwogICAgICAgIH0KICAgICAgICBpZiAoIXZpZGVvSWZyYW1lVVJMKSByZXR1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YWdlIjogImphLUpQIiwKICAgICAgY29va2llOiAiY29jPTE7YWRjPTEiLAogICAgICAicmVmZXJyZXItcG9saWN5IjogIm5vLXJlZmVycmVyIiwKICAgIH07CiAgICByZXR1cm4gYXdhaXQgeEZldGNoKHNlcnZlclVSTCwgewogICAgICBoZWFkZXJzOiBoZWFkZXJzLAogICAgfSkKICAgICAgLnRoZW4oKHJlc3ApID0+IHsKICAgICAgICAvL01HU3RhZ2Ugc2VhcmNoIHJlc3VsdCwgbWF5IGNvbnRhaW4gbXVsdGlwbGUgbW92aWVzLgogICAgICAgIGxldCByZXN1bHRNb3ZpZXMgPSBleHRyYWN0TUdTdGFnZU1vdmllSXRlbShyZXNwLnJlc3BvbnNlVGV4dCk7CiAgICAgICAgaWYgKCFyZXN1bHRNb3ZpZXMpIHJldHVybiBub3RGb3VuZCgpOwogICAgICAgIGxldCB0YXJnZXRNb3ZpZUVsZSA9IG51bGw7CiAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIHJlc3VsdE1vdmllcykgewogICAgICAgICAgaWYgKG1hdGNoTW92aWVCeUtleXdvcmQoZWxlbWVudCwgbW92aWVJbmZvKSkgewogICAgICAgICAgICB0YXJnZXRNb3ZpZUVsZSA9IGVsZW1lbnQ7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIXRhcmdldE1vdmllRWxlKSByZXR1cm4gbm90Rm91bmQoKTsKICAgICAgICBsZXQgYXZEZXRhaWxVUkwgPSB0YXJnZXRNb3ZpZUVsZQogICAgICAgICAgLm1hdGNoKC88YSBocmVmPSIoXFMqPykiXHMqP2NsYXNzPSJidXR0b25fc2FtcGxlIj4vcykKICAgICAgICAgID8uYXQoMSk7CiAgICAgICAgaWYgKCFhdkRldGFpbFVSTCkgcmV0dXJuIG5vdEZvdW5kKCk7CiAgICAgICAgbGV0IHBpZCA9IGF2RGV0YWlsVVJMLnNwbGl0KCIvIikuYXQoLTEpOwogICAgICAgIHJldHVybiB4RmV0Y2goCiAgICAgICAgICAiaHR0cHM6Ly93d3cubWdzdGFnZS5jb20vc2FtcGxlcGxheWVyL3NhbXBsZVJlc3BvbnMucGhwP3BpZD0iICsgcGlkLAogICAgICAgICAgewogICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzLAogICAgICAgICAgfQogICAgICAgICk7CiAgICAgIH0pCiAgICAgIC50aGVuKChhdkRldGFpbFJlc3ApID0+IHsKICAgICAgICAvL01HU3RhZ2UgbW92aWUgZGV0YWlsIHBhZ2UgcmVzdWx0LgogICAgICAgIGxldCB2aWRlb1VSTCA9IEpTT04ucGFyc2UoYXZEZXRhaWxSZXNwLnJlc3BvbnNlKT8udXJsPy5zcGxpdCgiLmlzbSIpWzBdICsgIi5tcDQiOwogICAgICAgIGlmICh2aWRlb1VSTCkgewogICAgICAgICAgbG9nKCJNR1N0YWdlIHNlcnZlciByZXN1bHQgdmlkZW8gdXJsOiAiICsgdmlkZW9VUkwpOwogICAgICAgICAgcmV0dXJuIHZpZGVvVVJMOwogICAgICAgIH0KICAgICAgICByZXR1cm4gbm90Rm91bmQoKTsKICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KGUpOwogICAgICB9KTsKICB9CgogIGFzeW5jIGZ1bmN0aW9uIHF1ZXJ5UHJlc3RpZ2VWaWRlb1VSTChtb3ZpZUluZm8sIGlzVXNlVGl0bGUgPSBmYWxzZSkgewogICAgaWYgKAogICAgICBtb3ZpZUluZm8uaXNVbmNlbnNvcmVkIHx8CiAgICAgIChtb3ZpZUluZm8uY29ycE5hbWUuaW5jbHVkZXMoIuODl+ODrOOCueODhuODvOOCuCIpID09PSBmYWxzZSAmJgogICAgICAgIG1vdmllSW5mby5jb3JwTmFtZS50b1VwcGVyQ2FzZSgpLmluY2x1ZGVzKCJQUkVTVElHRSIpID09PSBmYWxzZSAmJgogICAgICAgICFtb3ZpZUluZm8udGh1bWJu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M7CiAgICAgICAgaWYgKCFyZXN1bHRNb3ZpZXMpIHJldHVybiBub3RGb3VuZCgpOwogICAgICAgIGZvciAoY29uc3QgbW92aWVEZXRhaWwgb2YgcmVzdWx0TW92aWVzKSB7CiAgICAgICAgICBsZXQgeyBkZWxpdmVyeUl0ZW1JZCwgcHJvZHVjdFRpdGxlLCBwcm9kdWN0TW92aWUgfSA9IG1vdmllRGV0YWlsWyJfc291cmNlIl07CiAgICAgICAgICBpZiAoCiAgICAgICAgICAgIG1hdGNoTW92aWVCeUtleXdvcmQoZGVsaXZlcnlJdGVtSWQgKyBwcm9kdWN0VGl0bGUsIG1vdmllSW5mbykgJiYKICAgICAgICAgICAgcHJvZHVjdE1vdmllPy5wYXRoCiAgICAgICAgICApIHsKICAgICAgICAgICAgbGV0IHZpZGVvVVJMID0gImh0dHBzOi8vd3d3LnByZXN0aWdlLWF2LmNvbS9hcGkvbWVkaWEvIiArIHByb2R1Y3RNb3ZpZS5wYXRoOwogICAgICAgICAgICBsb2coIlByZXN0aWdlIHNlcnZlciByZXN1bHQgdmlkZW8gdXJsOiAiICsgdmlkZW9VUkwpOwogICAgICAgICAgICByZXR1cm4gdmlkZW9VUkw7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBub3RGb3VuZCgpOwogICAgICB9KQogICAgICAuY2F0Y2goKGUpID0+IHsKICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QoZSk7CiAgICAgIH0pOwogIH0KCiAgYXN5bmMgZnVuY3Rpb24gcXVlcnlUb2t5b0hvdFZpZGVvVVJMKG1vdmllSW5mbykgewogICAgaWYgKAogICAgICAhbW92aWVJbmZvLmlzVW5jZW5zb3JlZCB8fAogICAgICAobW92aWVJbmZvLmNvcnBOYW1lICE9ICLmnbHkuqznhrEiICYmIG1vdmllSW5mby5jb3JwTmFtZS50b1VwcGVyQ2FzZSgpICE9ICJUT0tZT0hPVCIpCiAgICApCiAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdCgKICAgICAgICBgVG9reW9Ib3Qgc2VydmVyIG5vdCBzdXBwb3J0IG1vdmllSWQ6ICR7bW92aWVJbmZvLm1vdmllSWR9LCBDb3JwTmFtZTogJHttb3ZpZUluZm8uY29ycE5hbWV9YAogICAgICApOwogICAgbGV0IG5vdEZvdW5kID0gKCkgPT4gUHJvbWlzZS5yZWplY3QoIlRva3lvSG90IHNlcnZlciBub3QgZm91bmQgbW92aWUuIik7CiAgICAvL05lZWQgbGFkZGVyCiAgICBsZXQgc2VydmVyVVJMID0gYGh0dHBzOi8vbXkuY2RuLnRva3lvLWhvdC5jb20vcHJvZHVjdC8/cT0ke21vdmllSW5mby5tb3ZpZUlkfWA7CiAgICBsb2coIlRva3lvSG90IHNlcnZlciBxdWVyeTpcclxuIiArIHNlcnZlclVSTCk7CiAgICByZXR1cm4gYXdhaXQgeEZldGNoKHNlcnZlclVSTCkKICAgICAgLnRoZW4oKHJlc3ApID0+IHsKICAgICAgICAvL3NlYXJjaCByZXN1bHQsIG1heSBjb250YWluIG11bHRpcGxlIG1vdmllcy4KICAgICAgICBsZXQgcmVzdWx0TW92aWVzID0gZXh0cmFjdFRva3lvSG90TW92aWVJdGVtKHJlc3AucmVzcG9uc2VUZXh0KTsKICAgICAgICBpZiAoIXJlc3VsdE1vdmllcykgcmV0dXJuIG5vdEZvdW5kKCk7CiAgICAgICAgbGV0IHRhcmdldE1vdmllRWxlID0gbnVsbDsKICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgcmVzdWx0TW92aWVzKSB7CiAgICAgICAgICBpZiAobWF0Y2hNb3ZpZUJ5S2V5d29yZChlbGVtZW50LCBtb3ZpZUluZm8pKSB7CiAgICAgICAgICAgIHRhcmdldE1vdmllRWxlID0gZWxlbWVudDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICghdGFyZ2V0TW92aWVFbGUpIHJldHVybiBub3RGb3VuZCgpOwogICAgICAgIGxldC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1vdmllLiIpOwogICAgbGV0IHNlcnZlclVSTCA9IGBodHRwczovL2phdi10cmFpbGVyLmJyZWFrd2FsbDk5ODcud29ya2Vycy5kZXYvYDsKCiAgICByZXR1cm4gYXdhaXQgeEZldGNoKHNlcnZlclVSTCwgewogICAgICBkYXRhOiBKU09OLnN0cmluZ2lmeSh7CiAgICAgICAgbW92aWVJZDogbW92aWVJbmZvLm1vdmllSWQsCiAgICAgICAgdGl0bGU6IG1vdmllSW5mby50aXRsZSwKICAgICAgICBjb3JwTmFtZTogbW92aWVJbmZvLmNvcnBOYW1lLAogICAgICAgIGlzVlI6IG1vdmllSW5mby5pc1ZSLAogICAgICAgIGlzVW5jZW5zb3JlZDogbW92aWVJbmZvLmlzVW5jZW5zb3JlZCwKICAgICAgICB0aHVtYm5haWxVUkw6IG1vdmllSW5mby50aHVtYm5haWxVUkwsCiAgICAgIH0pLAogICAgICBtZXRob2Q6ICJQT1NUIiwKICAgIH0pCiAgICAgIC50aGVuKChyZXNwKSA9PiB7CiAgICAgICAgaWYgKHJlc3A/LnN0YXR1cyAhPT0gMjAwKSByZXR1cm4gbm90Rm91bmQoKTsKICAgICAgICBsZXQgdmlkZW9VUkwgPSByZXNwLnJlc3BvbnNlVGV4dDsKICAgICAgICBpZiAoIXZpZGVvVVJMKSByZXR1cm4gbm90Rm91bmQoKTsKICAgICAgICBsb2coIkNGIHNlcnZlciByZXN1bHQgdmlkZW8gdXJsOiAiICsgdmlkZW9VUkwpOwogICAgICAgIHJldHVybiB2aWRlb1VSTDsKICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KGUpOwogICAgICB9KTsKICB9CgogIGFzeW5jIGZ1bmN0aW9uIHF1ZXJ5U3VwYUJhc2UobW92aWVJbmZvKSB7CiAgICBsZXQgbm90Rm91bmQgPSAoKSA9PiBQcm9taXNlLnJlamVjdCgiU3VwYWJhc2Ugc2VydmVyIG5vdCBmb3VuZC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WYgKCFhdkRldGFpbFVSTCkgcmV0dXJuIG5vdEZvdW5kKCk7CiAgICAgICAgcmV0dXJuIHhGZXRjaChgaHR0cHM6Ly94Y2l0eS5qcCR7YXZEZXRhaWxVUkx9YCwgewogICAgICAgICAgaGVhZGVyczogaGVhZGVycywKICAgICAgICB9KTsKICAgICAgfSkKICAgICAgLnRoZW4oKGF2RGV0YWlsUmVzcCkgPT4gewogICAgICAgIC8vWENpdHkgbW92aWUgZGV0YWlsIHBhZ2UgcmVzdWx0LgogICAgICAgIGxldCB2aWRlb1VSTCA9IGF2RGV0YWlsUmVzcC5yZXNwb25zZVRleHQKICAgICAgICAgID8ubWF0Y2goL25hbWU9InNyYyIgdmFsdWU9IihcUyo/KSIvcykKICAgICAgICAgID8uYXQoMSk7CiAgICAgICAgaWYgKHZpZGVvVVJMKSB7CiAgICAgICAgICBsb2coIlhDaXR5IHNlcnZlciByZXN1bHQgdmlkZW8gdXJsOiAiICsgdmlkZW9VUkwpOwogICAgICAgICAgcmV0dXJuIHZpZGVvVVJMOwogICAgICAgIH0KICAgICAgICByZXR1cm4gbm90Rm91bmQoKTsKICAgICAgfSkKICAgICAgLmNhdGNoKChlKSA9PiB7CiAgICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KGUpOwogICAgICB9KTsKICB9CgogIC8vI3JlZ2lvbiB1dGlsaXR5IGZ1bmN0aW9ucwoKICBhc3luYyBmdW5jdGlvbiB4RmV0Y2godXJsLCBmZXRjaEluaXQgPSB7fSkgewogICAgY29uc3QgZGVmYXVsdEZldGNoSW5pdCA9IHsgbWV0aG9kOiAiZ2V0IiB9OwogICAgY29uc3QgeyBoZWFkZXJzLCBtZXRob2QsIGRhdGEsIHJlZmVycmVyUG9saWN5IH0gPSB7CiAgICAgIC4uLmRlZmF1bHRGZXRjaEluaXQsCiAgICAgIC4uLmZldGNoSW5pdCwKICAgIH07CiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogIC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56YWN5a2X56ym5pWwCiAgICBmb3IgKGxldCBpID0gMDsgaSA8IG07IGkrKykgewogICAgICBjb25zdCBzdGFydCA9IE1hdGgubWF4KDAsIGkgLSBtYXhEaXN0YW5jZSk7CiAgICAgIGNvbnN0IGVuZCA9IE1hdGgubWluKGkgKyBtYXhEaXN0YW5jZSArIDEsIG4pOwoKICAgICAgZm9yIChsZXQgaiA9IHN0YXJ0OyBqIDwgZW5kOyBqKyspIHsKICAgICAgICBpZiAoc3RyMk1hdGNoZWRbal0gPT09IGZhbHNlICYmIHN0cjFbaV0gPT09IHN0cjJbal0pIHsKICAgICAgICAgIHN0cjFNYXRjaGVkW2ldID0gdHJ1ZTsKICAgICAgICAgIHN0cjJNYXRjaGVkW2pdID0gdHJ1ZTsKICAgICAgICAgIG1hdGNoKys7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0KCiAgICBpZiAobWF0Y2ggPT09IDApIHsKICAgICAgcmV0dXJuIDA7CiAgICB9CgogICAgLy8g6K6h566X5a2X56ym5Liy55qE5Lyg6L6TCiAgICBsZXQgdCA9IDA7CiAgICBsZXQgcG9pbnQgPSAwOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBtOyBpKyspIHsKICAgICAgaWYgKHN0cjFNYXRjaGVkW2ldKSB7CiAgICAgICAgd2hpbGUgKHN0cjJNYXRjaGVkW3BvaW50XSA9PT0gZmFsc2UpIHsKICAgICAgICAgIHBvaW50Kys7CiAgICAgICAgfQogICAgICAgIGlmIChzdHIxW2ldICE9PSBzdHIyW3BvaW50XSkgewogICAgICAgICAgdCsrOwogICAgICAgIH0KICAgICAgICBwb2ludCsrOwogICAgICB9CiAgICB9CgogICAgdCAvPSAyOwoKICAgIC8vIOiuoeeul0phcm8tV2lua2xlcui3neemuwogICAgY29uc3QgamFyb0Rpc3RhbmNlID0gKG1hdGNoIC8gbSArIG1hdGNoIC8gbiArIChtYXRjaCAtIHQpIC8gbWF0Y2gpIC8gMzsKCiAgICAvLyDlpoLmnpzkuKTkuKrlrZfnrKbkuLLliY3nvIDnm7jlkIws5aKe5Yqg5YmN57yA5YiG5pWwCiAgICBsZXQgcHJlZml4TGVuZ3RoID0gMDsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgTWF0aC5taW4obSwgbik7IGkrKykgewogICAgICBpZiAoc3RyMVtpXSA9PT0gc3RyMltpXSkgewogICAgICAgIHByZWZpeExlbmd0aCsrOwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBwcmVmaXhMZW5ndGggPSBNYXRoLm1pbig0LCBwcmVmaXhMZW5ndGgpOwoKICAgIGNvbnN0IGphcm9fd2lua2xlciA9IGphcm9EaXN0YW5jZSArIDAuMSAqIHByZWZpeExlbmd0aCAqICgxIC0gamFyb0Rpc3RhbmNlKTsKCiAgICByZXR1cm4gamFyb193aW5rbGVyOwogIH0KICAvLyNlbmRyZWdpb24KfSkoKTsK
Add Comment
Please, Sign In to add comment