Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_计时器掌控者|视频广告跳过|视频广告加速器@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICAgICDorqHml7blmajmjozmjqfogIV86KeG6aKR5bm/5ZGK6Lez6L+HfOinhumikeW5v+WRiuWKoOmAn+WZqAovLyBAbmFtZTplbiAgICAgICAgIFRpbWVySG9va2VyCi8vIEBuYW1lc3BhY2UgICAgICAgaHR0cHM6Ly9naXRlZS5jb20vSEdKaW5nL2V2ZXJ0aGluZy1ob29rLwovLyBAdmVyc2lvbiAgICAgICAgIDEuMC42MgovLyBAZGVzY3JpcHRpb24gICAgIOaOp+WItue9kemhteiuoeaXtuWZqOmAn+W6pnzliqDpgJ/ot7Pov4fpobXpnaLorqHml7blub/lkYp86KeG6aKR5b+r6L+b77yI5oWi5pS+77yJfOi3s+i/h+W5v+WRinzmlK/mjIHlh6DkuY7miYDmnInnvZHpobUuCi8vIEBkZXNjcmlwdGlvbjplbiAgaXQgY2FuIGhvb2sgdGhlIHRpbWVyIHNwZWVkIHRvIGNoYW5nZS4KLy8gQGluY2x1ZGUgICAgICAgICAqCi8vIEByZXF1aXJlICAgICAgICAgaHR0cHM6Ly9ncmVhc3lmb3JrLm9yZy9zY3JpcHRzLzM3MjY3Mi1ldmVyeXRoaW5nLWhvb2svY29kZS9FdmVyeXRoaW5nLUhvb2suanM/dmVyc2lvbj04ODEyNTEKLy8gQGF1dGhvciAgICAgICAgICBDYW5nc2hpCi8vIEBtYXRjaCAgICAgICAgICAgaHR0cDovLyovKgovLyBAcnVuLWF0ICAgICAgICAgIGRvY3VtZW50LXN0YXJ0Ci8vIEBncmFudCAgICAgICAgICAgbm9uZQovLyBAbGljZW5zZSAgICAgICAgIEdQTC0zLjAtb3ItbGF0ZXIKLy8gQGRvd25sb2FkVVJMIGh0dHBzOi8vdXBkYXRlLmdyZWFzeWZvcmsub3Jn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aXRlbSBfaXRlbS14MiI+Jmd0OzwvZGl2PlxuJyArCiAgICAgICAgICAgICAgICAgICAgJyAgICA8ZGl2IGNsYXNzPSJfdGgtaXRlbSBfaXRlbS14LTIiPiZsdDs8L2Rpdj5cbicgKwogICAgICAgICAgICAgICAgICAgICcgICAgPGRpdiBjbGFzcz0iX3RoLWl0ZW0gX2l0ZW0teHgyIj4mZ3Q7Jmd0OzwvZGl2PlxuJyArCiAgICAgICAgICAgICAgICAgICAgJyAgICA8ZGl2IGNsYXNzPSJfdGgtaXRlbSBfaXRlbS14eC0yIj4mbHQ7Jmx0OzwvZGl2PlxuJyArCiAgICAgICAgICAgICAgICAgICAgJyAgICA8ZGl2IGNsYXNzPSJfdGgtaXRlbSBfaXRlbS1yZXNldCI+TzwvZGl2PlxuJyArCiAgICAgICAgICAgICAgICAgICAgJzwvZGl2PlxuJyArCiAgICAgICAgICAgICAgICAgICAgJzxkaXYgY2xhc3M9Il90aF9jb3Zlci1hbGwtc2hvdy10aW1lcyBfdGhfaGlkZGVuIj5cbicgKwogICAgICAgICAgICAgICAgICAgICcgICAgPGRpdiBjbGFzcz0iX3RoX3RpbWVzIj54JyArIGRpc3BsYXlOdW0gKyAnPC9kaXY+XG4nICsKICAgICAgICAgICAgICAgICAgICAnPC9kaXY+JyArCiAgICAgICAgICAgICAgICAgICAgJyc7CiAgICAgICAgICAgICAgICB2YXIgc3R5bGVub2RlID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnc3R5bGUnKTsKICAgICAgICAgICAgICAgIHN0eWxlbm9kZS5zZXRBdHRyaWJ1dGUoInR5cGUiLCAidGV4dC9jc3MiKTsKICAgICAgICAgICAgICAgIGlmIChzdHlsZW5vZGUuc3R5bGVTaGVldCkgey8vIElFCiAgICAgICAgICAgICAgICAgICAgc3R5bGVub2RlLnN0eWxlU2hlZXQuY3NzVGV4dCA9IHN0eWxlOwogICAgICAgICAgICAgICAgfSBlbHNlIHsvLyB3M2MKICAgICAgICAgICAgICAgICAgICB2YXIgY3NzVGV4dCA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKHN0eWxlKTsKICAgICAgICAgICAgICAgICAgICBzdHlsZW5vZGUuYXBwZW5kQ2hpbGQoY3NzVGV4dCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgbm9kZSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpOwogICAgICAgICAgICAgICAgbm9kZS5pbm5lckhUTUwgPSBodG1sOwoKICAgICAgICAgICAgICAgIHZhciBjbGlja01hcHBlciA9IHsKICAgICAgICAgICAgICAgICAgICAnX2l0ZW0taW5wdXQnOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5nZVRpbWUoKTsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICdfaXRlbS14Mic6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlVGltZSgyLCAwLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICdfaXRlbS14LTInOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5nZVRpbWUoLTIsIDAsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgJ19pdGVtLXh4Mic6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlVGltZSgwLCAyKTsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICdfaXRlbS14eC0yJzogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2VUaW1lKDAsIC0yKTsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICdfaXRlbS1yZXNldCc6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlVGltZSgwLCAwLCBmYWxzZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICBPYmplY3Qua2V5cyhjbGlja01hcHBlcikuZm9yRWFjaChmdW5jdGlvbiAoY2xhc3NOYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGV4ZWMgPSBjbGlja01hcHBlcltjbGFzc05hbWVdOwogICAgICAgICAgICAgICAgICAgIHZhciB0YXJnZXRFbGUgPSBub2RlLmdldEVsZW1lbnRzQnlDbGFzc05hbWUoY2xhc3NOYW1lKVswXTsKICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0RWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldEVsZS5vbmNsaWNrID0gZXhlYzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICBpZiAoIWdsb2JhbC5pc0RPTUxvYWRlZCkgewogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoJ3JlYWR5c3RhdGVjaGFuZ2UnLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoZG9jdW1lbnQucmVhZHlTdGF0ZSA9PT0gImludGVyYWN0aXZlIiB8fCBkb2N1bWVudC5yZWFkeVN0YXRlID09PSAiY29tcGxldGUiKSAmJiAhZ2xvYmFsLmlzRE9NUmVuZGVyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmhlYWQuYXBwZW5kQ2hpbGQoc3R5bGVub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmJvZHkuYXBwZW5kQ2hpbGQobm9kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnbG9iYWwuaXNET01SZW5kZXJlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnVGltZSBIb29rZXIgV29ya3MhJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQuaGVhZC5hcHBlbmRDaGlsZChzdHlsZW5vZGUpOwogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmJvZHkuYXBwZW5kQ2hpbGQobm9kZSk7CiAgICAgICAgICAgICAgICAgICAgZ2xvYmFsLmlzRE9NUmVuZGVyZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdUaW1lIEhvb2tlciBXb3JrcyEnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSwKICAgICAgICAgICAgYXBwbHlHbG9iYWxBY3Rpb246IGZ1bmN0aW9uICh0aW1lcikgewogICAgICAgICAgICAgICAgLy8g55WM6Z2i5Y2K5ZyG5oyJ6ZKu54K55Ye755qE5pa55rOVCiAgICAgICAgICAgICAgICB0aW1lci5jaGFuZ2VUaW1lID0gZnVuY3Rpb24gKGFudW0sIGNudW0sIGlzYSwgaXNyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzcikgewogICAgICAgICAgICAgICAgICAgICAgICBnbG9iYWwudGltZXIuY2hhbmdlKDEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghZ2xvYmFsLnRpbWVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIWFudW0gJiYgIWNudW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHQgPSBwcm9tcHQoIui+k+WFpeassuaUueWPmOiuoeaXtuWZqOWPmOWMluWAjeeOh++8iOW9k+WJje+8miIgKyAxIC8gdGltZXJDb250ZXh0Ll9wZXJjZW50YWdlICsgIu+8iSIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodCA9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTmFOKHBhcnNlRmxvYXQodCkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGVydCgi6K+36L6T5YWl5q2j56Gu55qE5pWw5a2XIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aW1lci5jaGFuZ2VUaW1lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcnNlRmxvYXQodCkgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxlcnQoIuWAjeeOh+S4jeiDveWwj+S6juetieS6jjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVyLmNoYW5nZVRpbWUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSAxIC8gcGFyc2VGbG9hdCh0KTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNhICYmIGFudW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgxIC8gdGltZXJDb250ZXh0Ll9wZXJjZW50YWdlIDw9IDEgJiYgYW51bSA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSAxIC8gKDEgLyB0aW1lckNvbnRleHQuX3BlcmNlbnRhZ2UgKyBhbnVtKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjbnVtIDw9IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbnVtID0gMSAvIC1jbnVtCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSAxIC8gKCgxIC8gdGltZXJDb250ZXh0Ll9wZXJjZW50YWdlKSAqIGNudW0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRpbWVyLmNoYW5nZShyZXN1bHQpOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGdsb2JhbC5jaGFuZ2VUaW1lID0gdGltZXIuY2hhbmdlVGltZTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgYXBwbHlIb29raW5nOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB2YXIgX3RoaXMgPSB0aGlzOwogICAgICAgICAgICAgICAgLy8g5Yqr5oyB5b6q546v6K6h5pe25ZmoCiAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va1JlcGxhY2Uod2luZG93LCAnc2V0SW50ZXJ2YWwnLCBmdW5jdGlvbiAoc2V0SW50ZXJ2YWwpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3RoaXMuZ2V0SG9va2VkVGltZXJGdW5jdGlvbignaW50ZXJ2YWwnLCBzZXRJbnRlcnZhbCk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIC8vIOWKq+aMgeWNleasoeiuoeaXtgogICAgICAgICAgICAgICAgZUhvb2tDb250ZXh0Lmhvb2tSZXBsYWNlKHdpbmRvdywgJ3NldFRpbWVvdXQnLCBmdW5jdGlvbiAoc2V0VGltZW91dCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdGhpcy5nZXRIb29rZWRUaW1lckZ1bmN0aW9uKCd0aW1lb3V0Jywgc2V0VGltZW91dCkKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgLy8g5Yqr5oyB5b6q546v6K6h5pe25Zmo55qE5riF6Zmk5pa55rOVCiAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va0JlZm9yZSh3aW5kb3csICdjbGVhckludGVydmFsJywgZnVuY3Rpb24gKG1ldGhvZCwgYXJncykgewogICAgICAgICAgICAgICAgICAgIF90aGlzLnJlZGlyZWN0TmV3ZXN0SWQoYXJncyk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIC8vIOWKq+aMgeW+queOr+iuoeaXtuWZqOeahOa4hemZpOaWueazlQogICAgICAgICAgICAgICAgZUhvb2tDb250ZXh0Lmhvb2tCZWZvcmUod2luZG93LCAnY2xlYXJUaW1lb3V0JywgZnVuY3Rpb24gKG1ldGhvZCwgYXJncykgewogICAgICAgICAgICAgICAgICAgIF90aGlzLnJlZGlyZWN0TmV3ZXN0SWQoYXJncyk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIHZhciBuZXdGdW5jID0gdGhpcy5nZXRIb29rZWREYXRlQ29uc3RydWN0b3IoKTsKICAgICAgICAgICAgICAgIGVIb29rQ29udGV4dC5ob29rQ2xhc3Mod2luZG93LCAnRGF0ZScsIG5ld0Z1bmMsICdfaW5uZXJEYXRlJywgWydub3cnXSk7CiAgICAgICAgICAgICAgICBEYXRlLm5vdyA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IERhdGUoKS5nZXRUaW1lKCk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZUhvb2tDb250ZXh0Lmhvb2tlZFRvU3RyaW5nKHRpbWVyQ29udGV4dC5fRGF0ZS5ub3csIERhdGUubm93KTsKICAgICAgICAgICAgICAgIHZhciBvYmpUb1N0cmluZyA9IE9iamVjdC5wcm90b3R5cGUudG9TdHJpbmc7CgogICAgICAgICAgICAgICAgT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgICd1c2Ugc3RyaWN0JzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcyBpbnN0YW5jZW9mIHRpbWVyQ29udGV4dC5fbURhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdbb2JqZWN0IERhdGVdJzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqVG9TdHJpbmcuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIGVIb29rQ29udGV4dC5ob29rZWRUb1N0cmluZyhvYmpUb1N0cmluZywgT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZyk7CiAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va2VkVG9TdHJpbmcodGltZXJDb250ZXh0Ll9zZXRJbnRlcnZhbCwgc2V0SW50ZXJ2YWwpOwogICAgICAgICAgICAgICAgZUhvb2tDb250ZXh0Lmhvb2tlZFRvU3RyaW5nKHRpbWVyQ29udGV4dC5fc2V0VGltZW91dCwgc2V0VGltZW91dCk7CiAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va2VkVG9TdHJpbmcodGltZXJDb250ZXh0Ll9jbGVhckludGVydmFsLCBjbGVhckludGVydmFsKTsKICAgICAgICAgICAgICAgIHRpbWVyQ29udGV4dC5fbURhdGUgPSB3aW5kb3cuRGF0ZTsKICAgICAgICAgICAgICAgIHRoaXMuaG9va1NoYWRvd1Jvb3QoKTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgZ2V0SG9va2VkRGF0ZUNvbnN0cnVjdG9yOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID09PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAnX2lubmVyRGF0ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgdGltZXJDb250ZXh0Ll9EYXRlKGFyZ3VtZW50c1swXSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGFyZ3VtZW50cy5sZW5ndGggPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkZWZpbmVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJndW1lbnRzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZWRWYWx1ZSA9IG5ldyB0aW1lckNvbnRleHQuX0RhdGUoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzFdCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVkVmFsdWUgPSBuZXcgdGltZXJDb250ZXh0Ll9EYXRlKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbMF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1sxXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzJdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lZFZhbHVlID0gbmV3IHRpbWVyQ29udGV4dC5fRGF0ZSgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzBdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbMV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1syXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzNdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lZFZhbHVlID0gbmV3IHRpbWVyQ29udGV4dC5fRGF0ZSgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzBdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbMV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1syXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzNdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbNF0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA2OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZWRWYWx1ZSA9IG5ldyB0aW1lckNvbnRleHQuX0RhdGUoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzFdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbMl0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1szXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzRdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbNV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgNzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVkVmFsdWUgPSBuZXcgdGltZXJDb250ZXh0Ll9EYXRlKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbMF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1sxXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzJdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbM10sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c1s0XSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzVdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNbNl0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgJ19pbm5lckRhdGUnLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZGVmaW5lZFZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHZhciBub3cgPSB0aW1lckNvbnRleHQuX0RhdGUubm93KCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHBhc3NUaW1lID0gbm93IC0gdGltZXJDb250ZXh0Ll9fbGFzdERhdGV0aW1lOwogICAgICAgICAgICAgICAgICAgIHZhciBob29rUGFzc1RpbWUgPSBwYXNzVGltZSAqICgxIC8gdGltZXJDb250ZXh0Ll9wZXJjZW50YWdlKTsKICAgICAgICAgICAgICAgICAgICAvLyBjb25zb2xlLmxvZyhfX3RoaXMuX19sYXN0RGF0ZXRpbWUgKyBob29rUGFzc1RpbWUsIG5vdyxfX3RoaXMuX19sYXN0RGF0ZXRpbWUgKyBob29rUGFzc1RpbWUgLSBub3cpOwogICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCAnX2lubmVyRGF0ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgdGltZXJDb250ZXh0Ll9EYXRlKHRpbWVyQ29udGV4dC5fX2xhc3RNRGF0ZXRpbWUgKyBob29rUGFzc1RpbWUpLAogICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIGdldEhvb2tlZFRpbWVyRnVuY3Rpb246IGZ1bmN0aW9uICh0eXBlLCB0aW1lcikgewogICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5ID0gJ18nICsgdHlwZSArICdJZHMnOwogICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdW5pcXVlSWQgPSB0aW1lckNvbnRleHQuZ2VuVW5pcXVlSWQoKTsKICAgICAgICAgICAgICAgICAgICB2YXIgY2FsbGJhY2sgPSBhcmd1bWVudHNbMF07CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBjYWxsYmFjayA9PT0gJ3N0cmluZycpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sgKz0gJzt0aW1lci5ub3RpZnlFeGVjKCcgKyB1bmlxdWVJZCArICcpJzsKICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzBdID0gY2FsbGJhY2s7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgY2FsbGJhY2sgPT09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzBdID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJldHVyblZhbHVlID0gY2FsbGJhY2suYXBwbHkodGhpcywgYXJndW1lbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVyQ29udGV4dC5ub3RpZnlFeGVjKHVuaXF1ZUlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyDlgqjlrZjljp/lp4vml7bpl7Tpl7TpmpQKICAgICAgICAgICAgICAgICAgICB2YXIgb3JpZ2luTVMgPSBhcmd1bWVudHNbMV07CiAgICAgICAgICAgICAgICAgICAgLy8g6I635Y+W5Y+Y6YCf5pe26Ze06Ze06ZqUCiAgICAgICAgICAgICAgICAgICAgYXJndW1lbnRzWzFdICo9IHRpbWVyQ29udGV4dC5fcGVyY2VudGFnZTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0SWQgPSB0aW1lci5hcHBseSh3aW5kb3csIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgLy8g5L+d5a2Y5q+P5qyh5L2/55So6K6h5pe25Zmo5b6X5Yiw55qEaWTku6Xlj4rlj4LmlbDnrYkKICAgICAgICAgICAgICAgICAgICB0aW1lckNvbnRleHRbcHJvcGVydHldW3Jlc3VsdElkXSA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgYXJnczogYXJndW1lbnRzLAogICAgICAgICAgICAgICAgICAgICAgICBvcmlnaW5NUzogb3JpZ2luTVMsCiAgICAgICAgICAgICAgICAgICAgICAgIG9yaWdpbklkOiByZXN1bHRJZCwKICAgICAgICAgICAgICAgICAgICAgICAgbm93SWQ6IHJlc3VsdElkLAogICAgICAgICAgICAgICAgICAgICAgICB1bmlxdWVJZDogdW5pcXVlSWQsCiAgICAgICAgICAgICAgICAgICAgICAgIG9sZFBlcmNlbnRhZ2U6IHRpbWVyQ29udGV4dC5fcGVyY2VudGFnZSwKICAgICAgICAgICAgICAgICAgICAgICAgZXhjZXB0TmV4dEZpcmVUaW1lOiB0aW1lckNvbnRleHQuX0RhdGUubm93KCkgKyBvcmlnaW5NUwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdElkOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgcmVkaXJlY3ROZXdlc3RJZDogZnVuY3Rpb24gKGFyZ3MpIHsKICAgICAgICAgICAgICAgIHZhciBpZCA9IGFyZ3NbMF07CiAgICAgICAgICAgICAgICBpZiAodGltZXJDb250ZXh0Ll9pbnRlcnZhbElkc1tpZF0pIHsKICAgICAgICAgICAgICAgICAgICBhcmdzWzBdID0gdGltZXJDb250ZXh0Ll9pbnRlcnZhbElkc1tpZF0ubm93SWQ7CiAgICAgICAgICAgICAgICAgICAgLy8g5riF6Zmk6K+l6K6w5b2VaWQKICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGltZXJDb250ZXh0Ll9pbnRlcnZhbElkc1tpZF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAodGltZXJDb250ZXh0Ll90aW1lb3V0SWRzW2lkXSkgewogICAgICAgICAgICAgICAgICAgIGFyZ3NbMF0gPSB0aW1lckNvbnRleHQuX3RpbWVvdXRJZHNbaWRdLm5vd0lkOwogICAgICAgICAgICAgICAgICAgIC8vIOa4hemZpOivpeiusOW9lWlkCiAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRpbWVyQ29udGV4dC5fdGltZW91dElkc1tpZF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHJlZ2lzdGVyU2hvcnRjdXRLZXlzOiBmdW5jdGlvbiAodGltZXIpIHsKICAgICAgICAgICAgICAgIC8vIOW/q+aNt+mUruazqOWGjAogICAgICAgICAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcigna2V5ZG93bicsIGZ1bmN0aW9uIChlKSB7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChlLmtleUNvZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA1NzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlLmN0cmxLZXkgfHwgZS5hbHRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjdXN0b20KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aW1lci5jaGFuZ2VUaW1lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gWz1dCiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTkwOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDE4NzogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGUuY3RybEtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnNvbGUubG9nKCcrMicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVyLmNoYW5nZVRpbWUoMiwgMCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGUuYWx0S2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ3h4MicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVyLmNoYW5nZVRpbWUoMCwgMik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAvLyBbLV0KICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODg6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTg5OiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZS5jdHJsS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJy0yJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGltZXIuY2hhbmdlVGltZSgtMiwgMCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGUuYWx0S2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ3h4LTInKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aW1lci5jaGFuZ2VUaW1lKDAsIC0yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFswXQogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDQ4OiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZS5jdHJsS2V5IHx8IGUuYWx0S2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2coJ3Jlc2V0Jyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGltZXIuY2hhbmdlVGltZSgwLCAwLCBmYWxzZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAvLyBjb25zb2xlLmxvZyhlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgfSwKICAgICAgICAgICAgLyoqCiAgICAgICAgICAgICAqIOW9k+iuoeaXtuWZqOmAn+eOh+iiq+aUueWPmOaXtuiwg+eUqOeahOWbnuiwg+aWueazlQogICAgICAgICAgICAgKiBAcGFyYW0gcGVyY2VudGFnZQogICAgICAgICAgICAgKiBAcHJpdmF0ZQogICAgICAgICAgICAgKi8KICAgICAgICAgICAgcGVyY2VudGFnZUNoYW5nZUhhbmRsZXI6IGZ1bmN0aW9uIChwZXJjZW50YWdlKSB7CiAgICAgICAgICAgICAgICAvLyDmlLnlj5jmiYDmnInnmoTlvqrnjq/orqHml7YKICAgICAgICAgICAgICAgIHV0aWwuZXJnb2RpY09iamVjdCh0aW1lckNvbnRleHQsIHRpbWVyQ29udGV4dC5faW50ZXJ2YWxJZHMsIGZ1bmN0aW9uIChpZE9iaiwgaWQpIHsKICAgICAgICAgICAgICAgICAgICBpZE9iai5hcmdzWzFdID0gTWF0aC5mbG9vcigoaWRPYmoub3JpZ2luTVMgfHwgMSkgKiBwZXJjZW50YWdlKTsKICAgICAgICAgICAgICAgICAgICAvLyDnu5PmnZ/ljp/mnaXnmoTorqHml7blmagKICAgICAgICAgICAgICAgICAgICB0aGlzLl9jbGVhckludGVydmFsLmNhbGwod2luZG93LCBpZE9iai5ub3dJZCk7CiAgICAgICAgICAgICAgICAgICAgLy8g5paw5byA5LiA5Liq6K6h5pe25ZmoCiAgICAgICAgICAgICAgICAgICAgaWRPYmoubm93SWQgPSB0aGlzLl9zZXRJbnRlcnZhbC5hcHBseSh3aW5kb3csIGlkT2JqLmFyZ3MpOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAvLyDmlLnlj5jmiYDmnInnmoTlu7bml7borqHml7YKICAgICAgICAgICAgICAgIHV0aWwuZXJnb2RpY09iamVjdCh0aW1lckNvbnRleHQsIHRpbWVyQ29udGV4dC5fdGltZW91dElkcywgZnVuY3Rpb24gKGlkT2JqLCBpZCkgewogICAgICAgICAgICAgICAgICAgIHZhciBub3cgPSB0aGlzLl9EYXRlLm5vdygpOwogICAgICAgICAgICAgICAgICAgIHZhciBleGNlcHRUaW1lID0gaWRPYmouZXhjZXB0TmV4dEZpcmVUaW1lOwogICAgICAgICAgICAgICAgICAgIHZhciBvbGRQZXJjZW50YWdlID0gaWRPYmoub2xkUGVyY2VudGFnZTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGltZSA9IGV4Y2VwdFRpbWUgLSBub3c7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRpbWUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRpbWUgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgY2hhbmdlZFRpbWUgPSBNYXRoLmZsb29yKHBlcmNlbnRhZ2UgLyBvbGRQZXJjZW50YWdlICogdGltZSk7CiAgICAgICAgICAgICAgICAgICAgaWRPYmouYXJnc1sxXSA9IGNoYW5nZWRUaW1lOwogICAgICAgICAgICAgICAgICAgIC8vIOmHjeWumuS4i+asoeaJp+ihjOaXtumXtAogICAgICAgICAgICAgICAgICAgIGlkT2JqLmV4Y2VwdE5leHRGaXJlVGltZSA9IG5vdyArIGNoYW5nZWRUaW1lOwogICAgICAgICAgICAgICAgICAgIGlkT2JqLm9sZFBlcmNlbnRhZ2UgPSBwZXJjZW50YWdlOwogICAgICAgICAgICAgICAgICAgIC8vIOe7k+adn+WOn+adpeeahOiuoeaXtuWZqAogICAgICAgICAgICAgICAgICAgIHRoaXMuX2NsZWFyVGltZW91dC5jYWxsKHdpbmRvdywgaWRPYmoubm93SWQpOwogICAgICAgICAgICAgICAgICAgIC8vIOaWsOW8gOS4gOS4quiuoeaXtuWZqAogICAgICAgICAgICAgICAgICAgIGlkT2JqLm5vd0lkID0gdGhpcy5fc2V0VGltZW91dC5hcHBseSh3aW5kb3csIGlkT2JqLmFyZ3MpOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIGhvb2tTaGFkb3dSb290OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB2YXIgb3JpZ2luID0gRWxlbWVudC5wcm90b3R5cGUuYXR0YWNoU2hhZG93OwogICAgICAgICAgICAgICAgZUhvb2tDb250ZXh0Lmhvb2tBZnRlcihFbGVtZW50LnByb3RvdHlwZSwgJ2F0dGFjaFNoYWRvdycsCiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gKG0sIGFyZ3MsIHJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICBleHRyYUVsZW1lbnRzLnB1c2gocmVzdWx0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9LCBmYWxzZSk7CiAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va2VkVG9TdHJpbmcob3JpZ2luLCBFbGVtZW50LnByb3RvdHlwZS5hdHRhY2hTaGFkb3cpOwogICAgICAgICAgICB9LAogICAgICAgICAgICBob29rRGVmaW5lOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBjb25zdCBfdGhpcyA9IHRoaXM7CiAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va0JlZm9yZShPYmplY3QsICdkZWZpbmVQcm9wZXJ0eScsIGZ1bmN0aW9uIChtLCBhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIG9wdGlvbiA9IGFyZ3NbMl07CiAgICAgICAgICAgICAgICAgICAgdmFyIGVsZSA9IGFyZ3NbMF07CiAgICAgICAgICAgICAgICAgICAgdmFyIGtleSA9IGFyZ3NbMV07CiAgICAgICAgICAgICAgICAgICAgdmFyIGFmdGVyQXJncyA9IF90aGlzLmhvb2tEZWZpbmVEZXRhaWxzKGVsZSwga2V5LCBvcHRpb24pOwogICAgICAgICAgICAgICAgICAgIGFmdGVyQXJncy5mb3JFYWNoKChhcmcsIGkpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgYXJnc1tpXSA9IGFyZzsKICAgICAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va0JlZm9yZShPYmplY3QsICdkZWZpbmVQcm9wZXJ0aWVzJywgZnVuY3Rpb24gKG0sIGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9uID0gYXJnc1sxXTsKICAgICAgICAgICAgICAgICAgICB2YXIgZWxlID0gYXJnc1swXTsKICAgICAgICAgICAgICAgICAgICBpZiAoZWxlICYmIGVsZSBpbnN0YW5jZW9mIEVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmtleXMob3B0aW9uKS5mb3JFYWNoKGtleSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbyA9IG9wdGlvbltrZXldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGFmdGVyQXJncyA9IF90aGlzLmhvb2tEZWZpbmVEZXRhaWxzKGVsZSwga2V5LCBvKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3NbMF0gPSBhZnRlckFyZ3NbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgb3B0aW9uW2tleV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25bYWZ0ZXJBcmdzWzFdXSA9IGFmdGVyQXJnc1syXQogICAgICAgICAgICAgICAgICAgICAgICB9KQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIGhvb2tEZWZpbmVEZXRhaWxzOiBmdW5jdGlvbiAodGFyZ2V0LCBrZXksIG9wdGlvbikgewogICAgICAgICAgICAgICAgaWYgKG9wdGlvbiAmJiB0YXJnZXQgJiYgdGFyZ2V0IGluc3RhbmNlb2YgRWxlbWVudCAmJiB0eXBlb2Yga2V5ID09PSAnc3RyaW5nJyAmJiBrZXkuaW5kZXhPZignb24nKSA+PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgb3B0aW9uLmNvbmZpZ3VyYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0IGluc3RhbmNlb2YgSFRNTFZpZGVvRWxlbWVudCAmJiBrZXkgPT09ICdwbGF5YmFja1JhdGUnKSB7CiAgICAgICAgICAgICAgICAgICAgb3B0aW9uLmNvbmZpZ3VyYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdbVGltZXIgSG9va10nLCAn5bey6Zi75q2i6buY6K6k5pON5L2c6KeG6aKR5YCN546HJyk7CiAgICAgICAgICAgICAgICAgICAga2V5ID0gJ3BsYXliYWNrUmF0ZV9ob29rZWQnCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gW3RhcmdldCwga2V5LCBvcHRpb25dOwogICAgICAgICAgICB9LAogICAgICAgICAgICBzdXBwcmVzc0V2ZW50OiBmdW5jdGlvbiAoZWxlLCBldmVudE5hbWUpIHsKICAgICAgICAgICAgICAgIGlmIChlbGUpIHsKICAgICAgICAgICAgICAgICAgICBkZWxldGUgZWxlWydvbicgKyBldmVudE5hbWVdOwogICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBlbGVbJ29uJyArIGV2ZW50TmFtZV07CiAgICAgICAgICAgICAgICAgICAgZGVsZXRlIGVsZVsnb24nICsgZXZlbnROYW1lXTsKICAgICAgICAgICAgICAgICAgICBlbGVbJ29uJyArIGV2ZW50TmFtZV0gPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXN1cHByZXNzRXZlbnRzW2V2ZW50TmFtZV0pIHsKICAgICAgICAgICAgICAgICAgICBlSG9va0NvbnRleHQuaG9va0JlZm9yZShFdmVudFRhcmdldC5wcm90b3R5cGUsICdhZGRFdmVudExpc3RlbmVyJywKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gKG0sIGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlTmFtZSA9IGFyZ3NbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnROYW1lID09PSBlTmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihldmVudE5hbWUsICdldmVudCBzdXBwcmVzc2VkLicpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJnc1swXSArPSAnc3VwcHJlc3NlZCc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICBzdXBwcmVzc0V2ZW50c1tldmVudE5hbWVdID0gdHJ1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSwKICAgICAgICAgICAgY2hhbmdlUGxheWJhY2tSYXRlOiBmdW5jdGlvbiAoZWxlLCByYXRlKSB7CiAgICAgICAgICAgICAgICBkZWxldGUgZWxlLnBsYXliYWNrUmF0ZTsKICAgICAgICAgICAgICAgIGRlbGV0ZSBlbGUucGxheWJhY2tSYXRlOwogICAgICAgICAgICAgICAgZGVsZXRlIGVsZS5wbGF5YmFja1JhdGU7CiAgICAgICAgICAgICAgICBlbGUucGxheWJhY2tSYXRlID0gcmF0ZQogICAgICAgICAgICAgICAgaWYgKHJhdGUgIT09IDEpIHsKICAgICAgICAgICAgICAgICAgICB0aW1lckNvbnRleHQuZGVmaW5lUHJvcGVydHkuY2FsbChPYmplY3QsIGVsZSwgJ3BsYXliYWNrUmF0ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfTsKCiAgICB2YXIgbm9ybWFsVXRpbCA9IHsKICAgICAgICBpc0luSWZyYW1lOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgIGxldCBpcyA9IGdsb2JhbC5wYXJlbnQgIT09IGdsb2JhbDsKICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIGlzID0gaXMgJiYgZ2xvYmFsLnBhcmVudC5kb2N1bWVudC5ib2R5LnRhZ05hbWUgIT09ICdGUkFNRVNFVCcKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgLy8gaWdub3JlCiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGlzOwogICAgICAgIH0sCiAgICAgICAgbGlzdGVuUGFyZW50RXZlbnQ6IGZ1bmN0aW9uIChoYW5kbGVyKSB7CiAgICAgICAgICAgIGdsb2JhbC5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgZnVuY3Rpb24gKGUpIHsKICAgICAgICAgICAgICAgIHZhciBkYXRhID0gZS5kYXRhOwogICAgICAgICAgICAgICAgdmFyIHR5cGUgPSBkYXRhLnR5cGUgfHwgJyc7CiAgICAgICAgICAgICAgICBpZiAodHlwZSA9PT0gJ2NoYW5nZVBlcmNlbnRhZ2UnKSB7CiAgICAgICAgICAgICAgICAgICAgaGFuZGxlcihkYXRhLnBlcmNlbnRhZ2UgfHwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pCiAgICAgICAgfSwKICAgICAgICBzZW50Q2hhbmdlc1RvSWZyYW1lOiBmdW5jdGlvbiAocGVyY2VudGFnZSkgewogICAgICAgICAgICB2YXIgaWZyYW1lcyA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoJ2lmcmFtZScpIHx8IFtdOwogICAgICAgICAgICB2YXIgZnJhbWVzID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbCgnZnJhbWUnKTsKICAgICAgICAgICAgaWYgKGlmcmFtZXMubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGlmcmFtZXMubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVzW2ldLmNvbnRlbnRXaW5kb3cucG9zdE1lc3NhZ2UoCiAgICAgICAgICAgICAgICAgICAgICAgIHt0eXBlOiAnY2hhbmdlUGVyY2VudGFnZScsIHBlcmNlbnRhZ2U6IHBlcmNlbnRhZ2V9LCAnKicpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmcmFtZXMubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICBmb3IgKHZhciBqID0gMDsgaiA8IGZyYW1lcy5sZW5ndGg7IGorKykgewogICAgICAgICAgICAgICAgICAgIGZyYW1lc1tqXS5jb250ZW50V2luZG93LnBvc3RNZXNzYWdlKAogICAgICAgICAgICAgICAgICAgICAgICB7dHlwZTogJ2NoYW5nZVBlcmNlbnRhZ2UnLCBwZXJjZW50YWdlOiBwZXJjZW50YWdlfSwgJyonKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH07CgogICAgdmFyIHF1ZXJ5U2VsZWN0b3JBbGwgPSBmdW5jdGlvbiAoZWxlLCBzZWxlY3RvciwgaW5jbHVkZUV4dHJhKSB7CiAgICAgICAgdmFyIGVsZW1lbnRzID0gZWxlLnF1ZXJ5U2VsZWN0b3JBbGwoc2VsZWN0b3IpOwogICAgICAgIGVsZW1lbnRzID0gQXJyYXkucHJvdG90eXBlLnNsaWNlLmNhbGwoZWxlbWVudHMgfHwgW10pOwogICAgICAgIGlmIChpbmNsdWRlRXh0cmEpIHsKICAgICAgICAgICAgZXh0cmFFbGVtZW50cy5mb3JFYWNoKGZ1bmN0aW9uIChlbGVtZW50KSB7CiAgICAgICAgICAgICAgICBlbGVtZW50cyA9IGVsZW1lbnRzLmNvbmNhdChxdWVyeVNlbGVjdG9yQWxsKGVsZW1lbnQsIHNlbGVjdG9yLCBmYWxzZSkpOwogICAgICAgICAgICB9KQogICAgICAgIH0KICAgICAgICByZXR1cm4gZWxlbWVudHM7CiAgICB9OwoKICAgIHZhciBnZW5lcmF0ZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHV0aWwpIHsKICAgICAgICAgICAgLy8gZGlzYWJsZSB3b3JrZXIKICAgICAgICAgICAgd29ya2VyVVJMcy5mb3JFYWNoKGZ1bmN0aW9uICh1cmwpIHsKICAgICAgICAgICAgICAgIGlmICh1dGlsLnVybE1hdGNoaW5nKGxvY2F0aW9uLmhyZWYsICdodHRwLio6Ly8uKicgKyB1cmwgKyAnLionKSkgewogICAgICAgICAgICAgICAgICAgIHdpbmRvd1snV29ya2VyJ10gPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ1dvcmtlciBkaXNhYmxlZCcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdmFyIGVIb29rQ29udGV4dCA9IHRoaXM7CiAgICAgICAgICAgIHZhciB0aW1lckhvb2tlciA9IHsKICAgICAgICAgICAgICAgIC8vIOeUqOS6juWCqOWtmOiuoeaXtuWZqOeahGlk5ZKM5Y+C5pWwCiAgICAgICAgICAgICAgICBfaW50ZXJ2YWxJZHM6IHt9LAogICAgICAgICAgICAgICAgX3RpbWVvdXRJZHM6IHt9LAogICAgICAgICAgICAgICAgX2F1b1VuaXF1ZUlkOiAxLAogICAgICAgICAgICAgICAgLy8g6K6h5pe25Zmo6YCf546HCiAgICAgICAgICAgICAgICBfX3BlcmNlbnRhZ2U6IDEuMCwKICAgICAgICAgICAgICAgIC8vIOWKq+aMgeWJjeeahOWOn+Wni+eahOaWueazlQogICAgICAgICAgICAgICAgX3NldEludGVydmFsOiB3aW5kb3dbJ3NldEludGVydmFsJ10sCiAgICAgICAgICAgICAgICBfY2xlYXJJbnRlcnZhbDogd2luZG93WydjbGVhckludGVydmFsJ10sCiAgICAgICAgICAgICAgICBfY2xlYXJUaW1lb3V0OiB3aW5kb3dbJ2NsZWFyVGltZW91dCddLAogICAgICAgICAgICAgICAgX3NldFRpbWVvdXQ6IHdpbmRvd1snc2V0VGltZW91dCddLAogICAgICAgICAgICAgICAgX0RhdGU6IHdpbmRvd1snRGF0ZSddLAogICAgICAgICAgICAgICAgX19sYXN0RGF0ZXRpbWU6IG5ldyBEYXRlKCkuZ2V0VGltZSgpLAogICAgICAgICAgICAgICAgX19sYXN0TURhdGV0aW1lOiBuZXcgRGF0ZSgpLmdldFRpbWUoKSwKICAgICAgICAgICAgICAgIHZpZGVvU3BlZWRJbnRlcnZhbDogMTAwMCwKICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5OiBPYmplY3QuZGVmaW5lUHJvcGVydHksCiAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0aWVzOiBPYmplY3QuZGVmaW5lUHJvcGVydGllcywKICAgICAgICAgICAgICAgIGdlblVuaXF1ZUlkOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2F1b1VuaXF1ZUlkKys7CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgbm90aWZ5RXhlYzogZnVuY3Rpb24gKHVuaXF1ZUlkKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICAgICAgICAgICAgICBpZiAodW5pcXVlSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgLy8g5riF6ZmkIHRpbWVvdXQg5omA5YKo5a2Y55qE6K6w5b2VCiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aW1lb3V0SW5mb3MgPSBPYmplY3QudmFsdWVzKHRoaXMuX3RpbWVvdXRJZHMpLmZpbHRlcigKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIChpbmZvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGluZm8udW5pcXVlSWQgPT09IHVuaXF1ZUlkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgICAgICAgICB0aW1lb3V0SW5mb3MuZm9yRWFjaChmdW5jdGlvbiAoaW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuX2NsZWFyVGltZW91dC5jYWxsKHdpbmRvdywgaW5mby5ub3dJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgX3RoaXMuX3RpbWVvdXRJZHNbaW5mby5vcmlnaW5JZF0KICAgICAgICAgICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2codW5pcXVlSWQsICdjYWxsZWQnKQogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIC8qKgogICAgICAgICAgICAgICAgICog5Yid5aeL5YyW5pa55rOVCiAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgIGluaXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGltZXJDb250ZXh0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICB2YXIgaCA9IGhlbHBlcihlSG9va0NvbnRleHQsIHRpbWVyQ29udGV4dCwgdXRpbCk7CgogICAgICAgICAgICAgICAgICAgIGguaG9va0RlZmluZSgpOwogICAgICAgICAgICAgICAgICAgIGguYXBwbHlIb29raW5nKCk7CgogICAgICAgICAgICAgICAgICAgIC8vIOiuvuWumueZvuWIhuavlOWxnuaAp+iiq+S/ruaUueeahOWbnuiwgwogICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aW1lckNvbnRleHQsICdfcGVyY2VudGFnZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGltZXJDb250ZXh0Ll9fcGVyY2VudGFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbiAocGVyY2VudGFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlcmNlbnRhZ2UgPT09IHRpbWVyQ29udGV4dC5fX3BlcmNlbnRhZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGVyY2VudGFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgucGVyY2VudGFnZUNoYW5nZUhhbmRsZXIocGVyY2VudGFnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aW1lckNvbnRleHQuX19wZXJjZW50YWdlID0gcGVyY2VudGFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwZXJjZW50YWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgICAgIGlmICghbm9ybWFsVXRpbC5pc0luSWZyYW1lKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ1tUaW1lSG9va2VyXScsICdsb2FkaW5nIG91dGVyIHdpbmRvdy4uLicpOwogICAgICAgICAgICAgICAgICAgICAgICBoLmFwcGx5VUkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaC5hcHBseUdsb2JhbEFjdGlvbih0aW1lckNvbnRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBoLnJlZ2lzdGVyU2hvcnRjdXRLZXlzKHRpbWVyQ29udGV4dCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ1tUaW1lSG9va2VyXScsICdsb2FkaW5nIGlubmVyIHdpbmRvdy4uLicpOwogICAgICAgICAgICAgICAgICAgICAgICBub3JtYWxVdGlsLmxpc3RlblBhcmVudEV2ZW50KChmdW5jdGlvbiAocGVyY2VudGFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ1tUaW1lSG9va2VyXScsICdJbm5lciBDaGFuZ2VkJywgcGVyY2VudGFnZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hhbmdlKHBlcmNlbnRhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9KS5iaW5kKHRoaXMpKQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAvKioKICAgICAgICAgICAgICAgICAqIOiwg+eUqOivpeaWueazleaUueWPmOiuoeaXtuWZqOmAn+eOhwogICAgICAgICAgICAgICAgICogQHBhcmFtIHBlcmNlbnRhZ2UKICAgICAgICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgY2hhbmdlOiBmdW5jdGlvbiAocGVyY2VudGFnZSkgewogICAgICAgICAgICAgICAgICAgIHRoaXMuX19sYXN0TURhdGV0aW1lID0gdGhpcy5fbURhdGUubm93KCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX2xhc3REYXRldGltZSA9IHRoaXMuX0RhdGUubm93KCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGVyY2VudGFnZSA9IHBlcmNlbnRhZ2U7CiAgICAgICAgICAgICAgICAgICAgdmFyIG9sZE5vZGUgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5Q2xhc3NOYW1lKCdfdGgtY2xpY2staG92ZXInKTsKICAgICAgICAgICAgICAgICAgICB2YXIgb2xkTm9kZTEgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5Q2xhc3NOYW1lKCdfdGhfdGltZXMnKTsKICAgICAgICAgICAgICAgICAgICB2YXIgZGlzcGxheU51bSA9ICgxIC8gdGhpcy5fcGVyY2VudGFnZSkudG9GaXhlZCgyKTsKICAgICAgICAgICAgICAgICAgICAob2xkTm9kZVswXSB8fCB7fSkuaW5uZXJIVE1MID0gJ3gnICsgZGlzcGxheU51bTsKICAgICAgICAgICAgICAgICAgICAob2xkTm9kZTFbMF0gfHwge30pLmlubmVySFRNTCA9ICd4JyArIGRpc3BsYXlOdW07CiAgICAgICAgICAgICAgICAgICAgdmFyIGEgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5Q2xhc3NOYW1lKCdfdGhfY292ZXItYWxsLXNob3ctdGltZXMnKVswXSB8fCB7fTsKICAgICAgICAgICAgICAgICAgICBhLmNsYXNzTmFtZSA9ICdfdGhfY292ZXItYWxsLXNob3ctdGltZXMnOwogICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFRpbWVvdXQuYmluZCh3aW5kb3cpKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYS5jbGFzc05hbWUgPSAnX3RoX2NvdmVyLWFsbC1zaG93LXRpbWVzIF90aF9oaWRkZW4nOwogICAgICAgICAgICAgICAgICAgIH0sIDEwMCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGFuZ2VWaWRlb1NwZWVkKCk7CiAgICAgICAgICAgICAgICAgICAgbm9ybWFsVXRpbC5zZW50Q2hhbmdlc1RvSWZyYW1lKHBlcmNlbnRhZ2UpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGNoYW5nZVZpZGVvU3BlZWQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGltZXJDb250ZXh0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICB2YXIgaCA9IGhlbHBlcihlSG9va0NvbnRleHQsIHRpbWVyQ29udGV4dCwgdXRpbCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJhdGUgPSAxIC8gdGhpcy5fcGVyY2VudGFnZTsKICAgICAgICAgICAgICAgICAgICByYXRlID4gMTYgJiYgKHJhdGUgPSAxNik7CiAgICAgICAgICAgICAgICAgICAgcmF0ZSA8IDAuMDY1ICYmIChyYXRlID0gMC4wNjUpOwogICAgICAgICAgICAgICAgICAgIHZhciB2aWRlb3MgPSBxdWVyeVNlbGVjdG9yQWxsKGRvY3VtZW50LCAndmlkZW8nLCB0cnVlKSB8fCBbXTsKICAgICAgICAgICAgICAgICAgICBpZiAodmlkZW9zLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHZpZGVvcy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaC5jaGFuZ2VQbGF5YmFja1JhdGUodmlkZW9zW2ldLCByYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfTsKICAgICAgICAgICAgLy8g6buY6K6k5Yid5aeL5YyWCiAgICAgICAgICAgIHRpbWVySG9va2VyLmluaXQoKTsKICAgICAgICAgICAgcmV0dXJuIHRpbWVySG9va2VyOwogICAgICAgIH0KICAgIH07CgogICAgaWYgKGdsb2JhbC5lSG9vaykgewogICAgICAgIGdsb2JhbC5lSG9vay5wbHVnaW5zKHsKICAgICAgICAgICAgbmFtZTogJ3RpbWVyJywKICAgICAgICAgICAgLyoqCiAgICAgICAgICAgICAqIOaPkuS7tuijhei9vQogICAgICAgICAgICAgKiBAcGFyYW0gdXRpbAogICAgICAgICAgICAgKi8KICAgICAgICAgICAgbW91bnQ6IGdlbmVyYXRlKCkKICAgICAgICB9KTsKICAgIH0KfSh3aW5kb3cpOw==
Add Comment
Please, Sign In to add comment