Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@吉吉短剧@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6ImpzOlxudmFyIGNocCA9IFtdO1xudHJ5IHtcbiAgICB2YXIgaHRtbCA9IGdldFJlc0NvZGUoKTtcbiAgICB2YXIgY29udHMgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsICdib2R5JiYuc29ydC1saXN0Jyk7XG4gICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjb250cy5sZW5ndGg7IGkrKykge1xuICAgICAgICB2YXIgbGlzdCA9IHBkZmEoY29udHNbaV0sICdib2R5JiZsaScpO1xuICAgICAgICBjaHAucHVzaChsaXN0Lmxlbmd0aCk7XG4gICAgfSAgICAgXG59IGNhdGNoIChlKSB7fVxuc2V0UmVzdWx0KCfmm7TmlrDoh7M6JyArIChNYXRoLm1heC5hcHBseShudWxsLCBjaHApKSk7IiwidGl0bGUiOiLlkInlkInnn63liaciLCJhdXRob3IiOiJSIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjaHR0cHM6Ly93d3cuampkdWFuanUuY29tL3NvcnQvMS9wYWdlL2Z5cGFnZS5odG1sIiwidmVyc2lvbiI6MSwiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOlxudmFyIGQgPSBbXTtcbmFkZExpc3RlbmVyKFwib25DbG9zZVwiLCAkLnRvU3RyaW5nKCgpID0+IHtcbiAgICBsZXQga2V5cyA9IGxpc3RNeVZhcktleXMoKTtcbiAgICBmb3IgKGxldCBpdCBvZiBrZXlzKSB7XG4gICAgICA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rHzpm4Z86K+dfOacny9nLCAnJykucmVwbGFjZSgv6aKE5ZGKL2csICfwn5OiJyk7XG4gICAgICAgICAgICB2YXIgdXJsID0gcGQobGlzdFtqXSwgJ2EmJmhyZWYnKTtcbiAgICAgICAgICAgIGlmIChsaXN0Lmxlbmd0aCA8PSAyKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNvbCA9ICd0ZXh0XzInXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHZhciBjb2wgPSBqbS5sZW5ndGggPiA0ID8gJ3RleHRfMicgOiAndGV4dF80J1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aXRsZTogam0sXG4gICAgICAgICAgICAgICAgdXJsOiB1cmwgKyBsYXp5LFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBjb2wsXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgaWQ6IHVybCxcbiAgICAgICAgICAgICAgICAgICAgYmxvY2tSdWxlczogW1xuICAgICAgICAgICAgICAgICAgICAgICAgXCIuanBnXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICBcIi5qcGVnXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICBcIi5wbmdcIixcbiAgICAgICAgICAgICAgICAgICAgICAgIFwiLm1wNFwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgXCIubTN1OFwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgXCIuZ2lmXCJcbiAgICAgICAgICAgICAgICAgICAgXVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxufVxucmVzLmRhdGEgPSBkO1xuc2V0SG9tZVJlc3VsdChyZXMpOyIsInNkZXRhaWxfY29sX3R5cGUiOiJtb3ZpZV8xIiwic2RldGFpbF9maW5kX3J1bGUiOiIqIiwidWEiOiJtb2JpbGUiLCJwcmVSdWxlIjoi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ICAgICAgICBvYmouYWxsLmZvckVhY2goKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgIGNsZWFyTXlWYXIoaXRlbSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgb2JqLmNsLmZvckVhY2goKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgIGNsZWFyTXlWYXIoaXRlbSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgfSwgb2JqKSxcXG4gICAgICAgIH0sXFxuICAgICAgXTtcXG4gICAgfSxcXG4gICAgY2hlY2tQYXJhbSgpIHtcXG4gICAgICB2YXIgb2JqID0ge307XFxuICAgICAgaWYgKHRoaXMucGFnZSA9PSAwICYmIHR5cGVvZiBwYWdlID09IFxcXCJ1bmRlZmluZWRcXFwiKSB7XFxuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIuivt+S8oOWFpemhteeggVxcXCIpO1xcbiAgICAgIH0gZWxzZSB7XFxuICAgICAgICBpZiAodHlwZW9mIHBhZ2UgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgb2JqW1xcXCLpobXnoIFcXFwiXSA9IHRoaXMucGFnZTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIG9ialtcXFwi6aG156CBXFxcIl0gPSBwYWdlO1xcbiAgICAgICAgfVxcbiAgICAgIH1cXG4gICAgICBpZiAodGhpcy5odG1sID09IFxcXCJlbXB0eVxcXCIgJiYgdHlwZW9mIGh0bWwgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi6K+35Lyg5YWl5rqQ56CBXFxcIik7XFxuICAgICAgfSBlbHNlIHtcXG4gICAgICAgIGlmICh0eXBlb2YgaHRtbCA9PSBcXFwidW5kZWZpbmVkXFxcIikge1xcbiAgICAgICAgICBvYmpbXFxcIua6kOeggVxcXCJdID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KFxcXCJrZXl3b3JkXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICB9LFxcbiAgICAgICAgfSk7XFxuICAgICAgfVxcbiAgICAgIGNvbnN0IGNhdGVnb3JpZXMgPSBbXTtcXG4gICAgICBydWxlT2JqLmZvckVhY2goKHgpID0+IHtcXG4gICAgICAgIHZhciBsaXN0ID0gW107XFxuICAgICAgICBpZih4LuS4gOe6p+WumuS9jSl7XFxuICAgICAgICAgIGlmICh4LuS4gOe6p+WumuS9jS5zdGFydHNXaXRoKFxcXCJAanM6XFxcIikpIHtcXG4gICAgICAgICAgbGlzdCA9IHRoaXMuZXZhbEpTUnVsZShodG1sLCB4LuS4gOe6p+WumuS9jSk7XFxuICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgbGlzdCA9IHBkZmEoaHRtbCwgeC7kuIDnuqflrprkvY0pO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZih4LuWkp+exu+WumuS9jSl7XFxuICAgICAgICAgIGlmICh4LuWkp+exu+WumuS9jS5zdGFydHNXaXRoKFxcXCJAanM6XFxcIikpIHtcXG4gICAgICAgICAgbGlzdCA9IHRoaXMuZXZhbEpTUnVsZShodG1sLCB4LuWkp+exu+WumuS9jSk7XFxuICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgbGlzdCA9IFtwZGZhKGh0bWwsIHgu5aSn57G75a6a5L2NKS5qb2luKCdcXFxcbicpXTtcXG4gICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIg5LiA57qnID0gbGlzdC5tYXAoKHMpID0+IHtcXG4gICAgICAgICAgdmFyIHNsaXN0ID0gW107XFxuICAgICAgICAgIGlmICghKFxcXCLlsI/nsbtcXFwiIGluIHgpKSB7XFxuICAgICAgICAgICAgeC7lsI/nsbsgPSBcXFwiYm9keSYmYTpub3QoOm1hdGNoZXMo6aaW6aG1KSk6bm90KGE6bm90KFtocmVmXSkpXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoeC7lsI/nsbsuc3RhcnRzV2l0aChcXFwiQGpzOlxcXCIpKSB7XFxuICAgICAgICAgICAgc2xpc3QgPSB0aGlzLmV2YWxKU1J1bGUocywgeC7lsI/nsbspO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHNsaXN0ID0gcGRmYShzLCB4LuWwj+exuyk7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgdmFyIOWumuS9jSA9IHNsaXN0Lm1hcCgoaXRlbSkgPT4ge1xcbiAgICAgICAgICAgIHZhciB0aXRsZSA9IHRoaXMuZ2V0VGl0bGUoaXRlbSwgeC7moIfpopgpO1xcbiAgICAgICAgICAgIHZhciB1cmwgPSB0aGlzLmdldFVybChpdGVtLCB4KTtcXG4gICAgICAgICAgICB2YXIgb2JqID0geyB0aXRsZTogdGl0bGUsIHVybDogdXJsIH07XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KG9iaik7XFxuICAgICAgICAgIH0pO1xcbiAgICAgICAgICByZXR1cm4g5a6a5L2NO1xcbiAgICAgICAgfSk7XFxuICAgICAgICAvL2xvZyjkuIDnuqcpXFxuICAgICAgICAvL2xvZyjkuIDnuqcubGVuZ3RoKVxcbiAgICAgICAgaWYgKOS4gOe6py5sZW5ndGggPT0gMSkge1xcbiAgICAgICAgICBjYXRlZ29yaWVzLnB1c2go5LiA57qnLmpvaW4oXFxcIlxcXFxuXFxcIikpO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAg5LiA57qnLmZvckVhY2goKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICBjYXRlZ29yaWVzLnB1c2goaXRlbS5qb2luKFxcXCIsXFxcIikpO1xcbiAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIC8vbG9nKGNhdGVnb3JpZXMpXFxuICAgICAgfSk7XFxuICAgICAgaWYgKOaKmOWPoOeKtuaAgSkge1xcbiAgICAgICAgaWYgKHBhZ2UgPT0gMSkge1xcbiAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBmb2xkID09PSBcXFwiMVxcXCIgPyDmipjlj6AgOiDlsZXlvIAsXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKFxcbiAgICAgICAgICAgICAgKGZvbGQsIHUsIGFsbCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihNWV9SVUxFLmdyb3VwLCBmb2xkID09PSBcXFwiMVxcXCIgPyBcXFwiMFxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAvKmFsbC5mb3JFYWNoKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcXG4gICAgICAgICAgICAgICAgfSk7Ki9cXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgIGZvbGQsXFxuICAgICAgICAgICAgICDnirbmgIEsXFxuICAgICAgICAgICAgICDlhajmuIVcXG4gICAgICAgICAgICApLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgIGxvbmdDbGljazogdGhpcy5hY3Rpb24oe1xcbiAgICAgICAgICAgICAgICBzdGF0ZTog54q25oCBLFxcbiAgICAgICAgICAgICAgICBhbGw6IOWFqOa4hSxcXG4gICAgICAgICAgICAgICAgY2w6IOa4hemZpCxcXG4gICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgIH1c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wiXFxcIikge1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5yZXBsYWNlKG5ld1JlZ0V4cCjmjpLpmaQsIFxcXCJnXFxcIiksIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGpzb249JydcXG4gICAgICAgICAgICBqc29uID0gaXRlbS51cmw7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgbGV0IHBhcmFtcyA9IHtcXG4gICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAga2V5OiBrZXksXFxuICAgICAgICAgICAgICBwYWdlOiBwYWdlLFxcbiAgICAgICAgICAgICAgY2xlYXJzOiDmuIXpmaQsXFxuICAgICAgICAgICAgICBqc29uOiBqc29uLFxcbiAgICAgICAgICAgICAgc3RhdGU6IOeKtuaAgSxcXG4gICAgICAgICAgICAgIGFsbGNsZWFyczog5YWo5riFLFxcbiAgICAgICAgICAgIH07XFxuXFxuICAgICAgICAgICAgLy9sZXQgdXJsID0gcGQoaXRlbSwgX+Wkp+exu+mTvuaOpSk7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgIC8qaWYgKOWkp+exu+WkhOeQhikge1xcbiAgICAgICAgICAgICAgdXJsID0g5LiA57qn5YiG57G75aSE55CGKHVybCk7XFxuICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgLy9sb2codXJsKVxcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogdGhpcy5zZXRUaXRsZShrZXkudG9TdHJpbmcoKSwgY2F0ZV90ZW1wW2luZGV4XSwgdGl0bGUpLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgICAgICAgICAgIHVybDogJChcXFwiaGlrZXI6Ly9lbXB0eSNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHBhcmFtcykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3X2NhdGUgPSBbXTtcXG4gICAgICAgICAgICAgICAgcGFyYW1zLmNsZWFycy5mb3JFYWNoKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHBhcmFtcy5hbGxjbGVhcnMuZm9yRWFjaCgoaXRlbSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaXRlbSk7XFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgICAgICBwYXJhbXMuY2F0ZV90ZW1wLmZvckVhY2goKGNhdGUsIGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgbmV3X2NhdGUucHVzaChpbmRleCA9PT0gMCA/IHBhcmFtcy5rZXkudG9TdHJpbmcoKSA6IFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiaGVhZC5jYXRlXFxcIiwgSlNPTi5zdHJpbmdpZnkobmV3X2NhdGUpKTtcXG4gICAgICAgICAgICAgICAgaWYgKHBhcmFtcy5qc29uLmNvbnN0cnVjdG9yID09PSBPYmplY3QpIHtcXG4gICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiZHRfXFxcIiArIHBhcmFtcy5qc29uLnR5cGUsIHBhcmFtcy5qc29uLnZhbHVlKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBwdXRNeVZhcihwYXJhbXMuc3RhdGUsIHBhcmFtcy5qc29uKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSh0cnVlKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICA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1ZVxcXCIpLFxcbiAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgLy92YXIgdGl0bGUgPSBwZGZoKGl0ZW0sIOWIhuexu+agh+mimCk7XFxuICAgICAgICAgICAgICB2YXIgdGl0bGUgPSBpdGVtLnRpdGxlO1xcbiAgICAgICAgICAgICAgaWYgKHR5cGVvZiDmjpLpmaQgIT0gXFxcInVuZGVmaW5lZFxcXCIgJiYg5o6S6ZmkICE9IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUucmVwbGFjZShuZXcgUmVnRXhwKOaOkumZpCwgXFxcImdcXFwiKSwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgdmFyIGpzb24gPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIC8qc3dpdGNoICh0cnVlKSB7XFxuICAgICAgICAgICAgICAgIGNhc2Ug5YiG57G76ZO+5o6lLmluY2x1ZGVzKFxcXCJAQEBcXFwiKTpcXG4gICAgICAgICAgICAgICAgICBqc29uID0ge1xcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogcGRmaChpdGVtLCDliIbnsbvpk77mjqUuc3BsaXQoXFxcIkBAQFxcXCIpWzBdKSxcXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwZGZoKGl0ZW0sIOWIhuexu+mTvuaOpS5zcGxpdChcXFwiQEBAXFxcIilbMV0pLFxcbiAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2Ug5YiG57G76ZO+5o6lLmluY2x1ZGVzKFxcXCJAQFxcXCIpOlxcbiAgICAgICAgICAgICAgICAgIGpzb24gPSB7XFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiDliIbnsbvpk77mjqUuc3BsaXQoXFxcIkBAXFxcIilbMF0sXFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogcGRmaChpdGVtLCDliIbnsbvpk77mjqUuc3BsaXQoXFxcIkBAXFxcIilbMV0pLFxcbiAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XFxuICAgICAgICAgICAgICAgICAganNvbiA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgICAgICAgIC8vIGpzb24gPSBwZChpdGVtLCDliIbnsbvpk77mjqUpO1xcbiAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgICBqc29uID0gaXRlbS51cmw7XFxuICAgICAgICAgICAgICAvKnZhciBqc29uPeWIhuexu+mTvuaOpS5pbmNsdWRlcygnQEBAJyk/e1xcbiAgICAgICAgICAgICAgICAgICAgdHlwZTpwZGZoKGl0ZW0s5YiG57G76ZO+5o6lLnNwbGl0KCdAQEAnKVswXSksXFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTpwZGZoKGl0ZW0s5YiG57G76ZO+5o6lLnNwbGl0KCdAQEAnKVsxXSksXFxuICAgICAgICAgICAgICAgIH06cGQoaXRlbSzliIbnsbvpk77mjqUpO1xcbiAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAganNvbj3liIbnsbvpk77mjqUuaW5jbHVkZXMoJ0BAJyk/e1xcbiAgICAgICAgICAgICAgICAgICAgdHlwZTrliIbnsbvpk77mjqUuc3BsaXQoJ0BAJylbMF0sXFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTpwZGZoKGl0ZW0s5YiG57G76ZO+5o6lLnNwbGl0KCdAQCcpWzFdKSxcXG4gICAgICAgICAgICAgICAgfTpwZChpdGVtLOWIhuexu+mTvuaOpSk7Ki9cXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgbGV0IHBhcmFtcyA9IHtcXG4gICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcbiAgICAgICAgICAgICAga2V5OiBrZXksXFxuICAgICAgICAgICAgICBwYWdlOiBwYWdlLFxcbiAgICAgICAgICAgICAganNvbjoganNvbixcXG4gICAgICAgICAgICAgIHN0YXRlOiDnirbmgIEsXFxuICAgICAgICAgICAgICBhbGxjbGVhcnM6IOWFqOa4hSxcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogdGhpcy5zZXRUaXRsZShrZXkudG9TdHJpbmcoKSwgY2F0ZV90ZW1wW2luZGV4XSwgdGl0bGUpLFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCJoaWtlcjovL2VtcHR5XFxcIiArIFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChwYXJhbXMpID0+IHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zLmFsbGNsZWFycy5mb3JFYWNoKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHBhcmFtcy5jYXRlX3RlbXBbcGFyYW1zLmluZGV4XSA9IHBhcmFtcy5rZXkudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImhlYWQuY2F0ZVxcXCIsIEpTT04uc3RyaW5naWZ5KHBhcmFtcy5jYXRlX3RlbXApKTtcXG4gICAgICAgICAgICAgICAgaWYgKHBhcmFtcy5qc29uLmNvbnN0cnVjdG9yID09PSBPYmplY3QpIHtcXG4gICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiZHRfXFxcIiArIHBhcmFtcy5qc29uLnR5cGUsIHBhcmFtcy5qc29uLnZhbHVlKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBwdXRNeVZhc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CBpKSA9PiB7XFxuICAgICAgICBkZWxldGVJdGVtKFxcXCJwYWdlbnVtXFxcIik7XFxuICAgICAgICBkZWxldGVJdGVtKFxcXCJwYWdlbGluZVxcXCIpO1xcbiAgICAgICAgdmFyIGlkID0gXFxcIlxcXCI7XFxuICAgICAgICB2YXIgY2xzID0gXFxcIlxcXCI7XFxuICAgICAgICB2YXIgdGl0bGUgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS50aXRsZSk7XFxuICAgICAgICB2YXIgZGVzYyA9IHRoaXMuc2V0Q29udGVudChpdGVtLCBydWxlLmRlc2MpO1xcbiAgICAgICAgdmFyIGltZyA9IHRoaXMuaW1nSGFuZGxlKGl0ZW0sIHJ1bGUpO1xcbiAgICAgICAgdmFyIHVybCA9IHRoaXMudXJsSGFuZGxlKGl0ZW0sIHJ1bGUpO1xcbiAgICAgICAgdmFyIGNvbnRlbnQgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS5jb250ZW50KTtcXG4gICAgICAgIGlmIChpID09IGxpc3QubGVuZ3RoIC0gMSkge1xcbiAgICAgICAgICBpZCA9IFxcXCJsYXN0aWRfXFxcIiArIHBhZ2U7XFxuICAgICAgICAgIGNscyA9IFxcXCJsYXN0bWFya1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgIGRlc2M6IGRlc2MsXFxuICAgICAgICAgIHBpY191cmw6IGltZyxcXG4gICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eSMjXFxcIiArIHVybCxcXG4gICAgICAgICAgY29udGVudDogY29udGVudCxcXG4gICAgICAgICAgY29sX3R5cGU6IHJ1bGUuY29sX3R5cGUsXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAgIGlkOiBpZCxcXG4gICAgICAgICAgICBjbHM6IGNscyxcXG4gICAgICAgICAgfSxcXG4gICAgICAgIH0pO1xcbiAgICAgICAgaWYgKGkgPT0gbGlzdC5sZW5ndGggLSAxICYmIHNob3cpIHtcXG4gICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICBpZDogXFxcInBhZ2VsaW5lXFxcIixcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnTxzbWFsbD7liqDovb3kuK0uLi48L3NtYWxsPlxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIixcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgfSBlbHNlIHtcXG4gICAgICB1cGRhdGVJdGVtKFxcXCJwYWdlbnVtXFxcIiwge1xcbiAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ08Zm9udCBjb2xvcj1cXFwiZ3JleVxcXCI+PHNtYWxsPuWIsOW6leS6hjwvc21hbGw+PC9mb250PicsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBpZDogXFxcImxhc3RcXFwiLFxcbiAgICAgICAgfSxcXG4gICAgICB9KTtcXG4gICAgfVxc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56uZ5pCc57Si5pe26Ze06Ze06ZqUJyxcXG4gICAgZGVzYzogXFxcIuS4i+aLiemHjeivlVxcXCJcXG59KVxcblxcbn1cIn1dIiwiaWNvbiI6Imh0dHBzOi8vd3d3LmpqZHVhbmp1LmNvbS9mYXZpY29uLmljbyIsInByb3h5IjoiIn0=
Add Comment
Please, Sign In to add comment