data:text/javascript;base64,Ci8qIDwhW0NEQVRBWyAqLwp2YXIgZ3JpZGxvdmVfanNfc2V0dGluZ3MgPSB7InJ0bF9tb2RlIjoiIiwiaGVhZGVyX3N0aWNreSI6IjEiLCJoZWFkZXJfc3RpY2t5X29mZnNldCI6IjEwMCIsImhlYWRlcl9zdGlja3lfdXAiOiIiLCJsb2dvIjoiaHR0cHM6XC9cL3Nib3R2ZXQuY29tXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDE3XC8xMFwvd3NpLWltYWdlb3B0aW0tbG9nby5wbmciLCJsb2dvX3JldGluYSI6Imh0dHBzOlwvXC9zYm90dmV0LmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvMjAxN1wvMTBcL3dzaS1pbWFnZW9wdGltLWxvZ28tMngucG5nIiwibG9nb19taW5pIjoiaHR0cHM6XC9cL3Nib3R2ZXQuY29tXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDE3XC8xMFwvd3NpLWltYWdlb3B0aW0tbG9nby1taW5pLnBuZyIsImxvZ29fbWluaV9yZXRpbmEiOiJodHRwczpcL1wvc2JvdHZldC5jb21cL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMTdcLzEwXC93c2ktaW1hZ2VvcHRpbS1sb2dvLW1pbmktMngucG5nIiwiZ3JpZGxvdmVfZ2FsbGVyeSI6IjEiLCJyZXNwb25zaXZlX3NlY29uZGFyeV9uYXYiOiIiLCJyZXNwb25zaXZlX21vcmVfbGluayI6IiIsInJlc3BvbnNpdmVfc29jaWFsX25hdiI6IiJ9OwovKiBdXT4gKi8K |
data:text/javascript;base64,Ci8qIDwhW0NEQVRBWyAqLwp2YXIgd3BjZjcgPSB7ImFwaSI6eyJyb290IjoiaHR0cHM6XC9cL3Nib3R2ZXQuY29tXC93cC1qc29uXC8iLCJuYW1lc3BhY2UiOiJjb250YWN0LWZvcm0tN1wvdjEifSwiY2FjaGVkIjoiMSJ9OwovKiBdXT4gKi8K |
data:text/javascript;base64,CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBvbkVycm9yUGxhY2luZygpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGNhY2hlUGxhY2luZyAhPT0gJ3VuZGVmaW5lZCcgJiYgdHlwZW9mIGNhY2hlUGxhY2luZyA9PT0gJ2Z1bmN0aW9uJyAmJiB0eXBlb2Ygd2luZG93LmpzSW5wdXRlckxhdW5jaCAhPT0gJ3VuZGVmaW5lZCcgJiYgWzE1LCAxMF0uaW5jbHVkZXMod2luZG93LmpzSW5wdXRlckxhdW5jaCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVycm9ySW5mbyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBjYWNoZVBsYWNpbmcoJ2xvdycsZXJyb3JJbmZvKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3JQbGFjaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIDEwMCkKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgeGhyID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICB4aHIub3BlbignR0VUJywiLy9uZXdyb3RhdG9ybWFyY2gyMy5iaWQvamJuYS5qc29uIix0cnVlKTsKICAgICAgICAgICAgICAgIHhoci5zZXRSZXF1ZXN0SGVhZGVyKCJDb250ZW50LXR5cGUiLCAiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkIik7CiAgICAgICAgICAgICAgICB4aHIub25yZWFkeXN0YXRlY2hhbmdlID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5zdGF0dXMgIT0gMjAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh4aHIuc3RhdHVzVGV4dCAhPSAnYWJvcnQnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbkVycm9yUGxhY2luZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHhoci5zZW5kKCk7CiAgICAgICAgICAgIA== |
data:text/javascript;base64,CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBvbkVycm9yUGxhY2luZygpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGNhY2hlUGxhY2luZyAhPT0gJ3VuZGVmaW5lZCcgJiYgdHlwZW9mIGNhY2hlUGxhY2luZyA9PT0gJ2Z1bmN0aW9uJyAmJiB0eXBlb2Ygd2luZG93LmpzSW5wdXRlckxhdW5jaCAhPT0gJ3VuZGVmaW5lZCcgJiYgWzE1LCAxMF0uaW5jbHVkZXMod2luZG93LmpzSW5wdXRlckxhdW5jaCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVycm9ySW5mbyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBjYWNoZVBsYWNpbmcoJ2xvdycsZXJyb3JJbmZvKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3JQbGFjaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIDEwMCkKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgeGhyID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICB4aHIub3BlbignR0VUJywiLy9uZXdyb3RhdG9ybWFyY2gyMy5iaWQvamJuYS5taW4uanMiLHRydWUpOwogICAgICAgICAgICAgICAgeGhyLnNldFJlcXVlc3RIZWFkZXIoIkNvbnRlbnQtdHlwZSIsICJhcHBsaWNhdGlvbi94LXd3dy1mb3JtLXVybGVuY29kZWQiKTsKICAgICAgICAgICAgICAgIHhoci5vbnJlYWR5c3RhdGVjaGFuZ2UgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoeGhyLnN0YXR1cyAhPSAyMDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5zdGF0dXNUZXh0ICE9ICdhYm9ydCcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3JQbGFjaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgeGhyLnNlbmQoKTsKICAgICAgICAgICAg |
data:text/javascript;base64,CiAgICAgICAgICAgIGZ1bmN0aW9uIEFJX3Jlc3BvbnNpdmVfd2lkZ2V0KCkgewogICAgICAgICAgICAgICAgalF1ZXJ5KCdvYmplY3QuU3RlZmFub0FJLXlvdXR1YmUtcmVzcG9uc2l2ZScpLmVhY2goZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGpRdWVyeSh0aGlzKS5wYXJlbnQoJy5mbHVpZC13aWR0aC12aWRlby13cmFwcGVyJykucmVtb3ZlQ2xhc3MoJ2ZsdWlkLXdpZHRoLXZpZGVvLXdyYXBwZXInKS5yZW1vdmVBdHRyKCdzdHlsZScpLmNzcygnd2lkdGgnLCAnMTAwJScpLmNzcygnZGlzcGxheScsICdibG9jaycpOwogICAgICAgICAgICAgICAgICAgIGpRdWVyeSh0aGlzKS5jaGlsZHJlbignLmZsdWlkLXdpZHRoLXZpZGVvLXdyYXBwZXInKS5yZW1vdmVDbGFzcygnZmx1aWQtd2lkdGgtdmlkZW8td3JhcHBlcicpLnJlbW92ZUF0dHIoJ3N0eWxlJykuY3NzKCd3aWR0aCcsICcxMDAlJykuY3NzKCdkaXNwbGF5JywgJ2Jsb2NrJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHdpZHRoID0galF1ZXJ5KHRoaXMpLnBhcmVudCgpLmlubmVyV2lkdGgoKTsKICAgICAgICAgICAgICAgICAgICB2YXIgbWF4d2lkdGggPSBqUXVlcnkodGhpcykuY3NzKCdtYXgtd2lkdGgnKS5yZXBsYWNlKC9weC8sICcnKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcGwgPSBwYXJzZUludChqUXVlcnkodGhpcykucGFyZW50KCkuY3NzKCdwYWRkaW5nLWxlZnQnKS5yZXBsYWNlKC9weC8sICcnKSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHByID0gcGFyc2VJbnQoalF1ZXJ5KHRoaXMpLnBhcmVudCgpLmNzcygncGFkZGluZy1yaWdodCcpLnJlcGxhY2UoL3B4LywgJycpKTsKICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IHdpZHRoIC0gcGwgLSBwcjsKICAgICAgICAgICAgICAgICAgICBpZiAobWF4d2lkdGggPCB3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IG1heHdpZHRoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgcmF0aW8gPSBqUXVlcnkodGhpcykuYXR0cignZGF0YS1yYXRpbycpOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmF0aW8gPT0gJ3VuZGVmaW5lZCcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmF0aW8gPSAxNiAvIDk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGpRdWVyeSh0aGlzKS5jc3MoJ3dpZHRoJywgd2lkdGggKyAicHgiKTsKICAgICAgICAgICAgICAgICAgICBqUXVlcnkodGhpcykuY3NzKCdoZWlnaHQnLCB3aWR0aCAvIHJhdGlvICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgalF1ZXJ5KHRoaXMpLmZpbmQoJ2lmcmFtZScpLmNzcygnd2lkdGgnLCB3aWR0aCArICJweCIpOwogICAgICAgICAgICAgICAgICAgIGpRdWVyeSh0aGlzKS5maW5kKCdpZnJhbWUnKS5jc3MoJ2hlaWdodCcsIHdpZHRoIC8gcmF0aW8gKyAicHgiKTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgalF1ZXJ5ICE9PSAndW5kZWZpbmVkJykgewogICAgICAgICAgICAgICAgalF1ZXJ5KGRvY3VtZW50KS5yZWFkeShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGpRdWVyeSgiZGl2W2RhdGEtaWZyYW1lPSdTdGVmYW5vQUkteW91dHViZS13aWRnZXQtcmVzcG9uc2l2ZSddIikuZWFjaChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgaWZyYW1lID0galF1ZXJ5KCI8aWZyYW1lPjwvaWZyYW1lPiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgalF1ZXJ5LmVhY2godGhpcy5hdHRyaWJ1dGVzLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMubmFtZSA9PSAnZGF0YS1pZnJhbWUnIHx8IHRoaXMubmFtZSA9PSAnZGF0YS0nKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWZyYW1lLmF0dHIodGhpcy5uYW1lLnJlcGxhY2UoL15kYXRhLS8sICcnKSwgdGhpcy52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpRdWVyeShpZnJhbWUpLmluc2VydEFmdGVyKGpRdWVyeSh0aGlzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqUXVlcnkodGhpcykucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQUlfcmVzcG9uc2l2ZV93aWRnZXQoKTsKICAgICAgICAgICAgICAgICAgICB9LCA1MCk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIGpRdWVyeSh3aW5kb3cpLnJlc2l6ZShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgQUlfcmVzcG9uc2l2ZV93aWRnZXQoKTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgICAgICA= |
data:text/javascript;base64,CmlmICh0eXBlb2YgcmJfYWpheHVybD09PSd1bmRlZmluZWQnKSB7dmFyIHJiX2FqYXh1cmwgPSAnaHR0cHM6Ly9zYm90dmV0LmNvbS93cC1hZG1pbi9hZG1pbi1hamF4LnBocCc7fQppZiAodHlwZW9mIGdhdGhlcl9jb250ZW50PT09J3VuZGVmaW5lZCcpIHt2YXIgZ2F0aGVyX2NvbnRlbnQgPSB0cnVlO30KaWYgKHR5cGVvZiBlbmRlZFNjPT09J3VuZGVmaW5lZCcpIHt2YXIgZW5kZWRTYyA9IGZhbHNlO30NCmlmICh0eXBlb2YgZW5kZWRDYz09PSd1bmRlZmluZWQnKSB7dmFyIGVuZGVkQ2MgPSBmYWxzZTt9DQppZiAodHlwZW9mIHVzZWRBZEJsb2Nrc0FycmF5PT09J3VuZGVmaW5lZCcpIHt2YXIgdXNlZEFkQmxvY2tzQXJyYXkgPSBbXTt9DQppZiAodHlwZW9mIHVzZWRCbG9ja1NldHRpbmdBcnJheUlkcz09PSd1bmRlZmluZWQnKSB7dmFyIHVzZWRCbG9ja1NldHRpbmdBcnJheUlkcyA9IFtdO30NCmlmICh0eXBlb2Ygc2FtZUVsZW1lbnRBZnRlcldpZHRoPT09J3VuZ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5cGVvZiBzY0FycmF5ICE9PSAndW5kZWZpbmVkJykgew0KICAgICAgICBpZiAoc2NBcnJheSYmc2NBcnJheS5sZW5ndGggPiAwJiZnYXRoZXJlZEJsb2NrcyYmZ2F0aGVyZWRCbG9ja3MubGVuZ3RoID4gMCYmdHlwZW9mIHdpbmRvdy5ydWx2VzVnbnRiICE9PSAndW5kZWZpbmVkJykgew0KICAgICAgICAgICAgZGF0YUNpZElkZW50aWZpZXIgPSB3aW5kb3cucnVsdlc1Z250YjsNCiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZ2F0aGVyZWRCbG9ja3MubGVuZ3RoOyBpKyspIHsNCiAgICAgICAgICAgICAgICBnYXRoZXJlZEJsb2NrQ2hpbGQgPSBnYXRoZXJlZEJsb2Nrc1tpXS5jaGlsZHJlblswXTsNCiAgICAgICAgICAgICAgICBpZiAoIWdhdGhlcmVkQmxvY2tDaGlsZCkgew0KICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgc2NBZElkID0gLTM7DQogICAgICAgICAgICAgICAgYmxvY2tTdGF0dXMgPSBudWxsOw0KICAgICAgICAgICAgICAgIHNjQ29udGFpbmVyID0gbnVsbDsNCiAgICAgICAgICAgICAgICBkYXRhRnVsbCA9IC0xOw0KICAgICAgICAgICAgICAgIHNreXNjcmFwZXJTdGF0dXMgPSBmYWxzZTsNCiAgICAgICAgICAgICAgICBzcGxpdGVkU2t5c2NyYXBlciA9IFtdOw0KICAgICAgICAgICAgICAgIGdhdGhlcmVkQmxvY2tDaGlsZFNreVBhcnRzID0gW107DQogICAgICAgICAgICAgICAgc3RpY2t5U3RhdHVzID0gZmFsc2U7DQogICAgICAgICAgICAgICAgc3RpY2t5Q2hlY2sgPSBbXTsNCiAgICAgICAgICAgICAgICBzdGlja3lGaXhlZFN0YXR1cyA9IGZhbHNlOw0KICAgICAgICAgICAgICAgIHN0aWNreUZpeGVkQ2hlY2sgPSBbXTsNCiAgICAgICAgICAgICAgICByZXBlYXRhYmxlSWRlbnRpZmllciA9ICIiOw0KICAgICAgICAgICAgICAgIGRpdkNpZEVsZW1lbnQgPSBudWxsOw0KDQogICAgICAgICAgICAgICAgc2NBZElkID0gZ2F0aGVyZWRCbG9ja0NoaWxkLmdldEF0dHJpYnV0ZSgnZGF0YS1haWQnKTsNCiAgICAgICAgICAgICAgICBzY0Jsb2NrSWQgPSBnYXRoZXJlZEJsb2NrQ2hpbGQuZ2V0QXR0cmlidXRlKCdkYXRhLWlkJyk7DQogICAgICAgICAgICAgICAgYmxvY2tTdGF0dXMgPSBnYXRoZXJlZEJsb2NrQ2hpbGQuZ2V0QXR0cmlidXRlKCdkYXRhLXN0YXRlJyk7DQogICAgICAgICAgICAgICAgZGF0YUZ1bGwgPSBnYXRoZXJlZEJsb2NrQ2hpbGQuZ2V0QXR0cmlidXRlKCdkYXRhLWZ1bGwnKTsNCg0KICAgICAgICAgICAgICAgIGlmIChzY0Jsb2NrSWQmJnNjQWRJZCA+IDApIHsNCiAgICAgICAgICAgICAgICAgICAgc2NpID0gLTE7DQogICAgICAgICAgICAgICAgICAgIGZvciAoaTEgPSAwOyBpMSA8IHNjQXJyYXkubGVuZ3RoOyBpMSsrKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2NCbG9ja0lkID09IHNjQXJyYXlbaTFdWydibG9ja0lkJ10mJnNjQWRJZCA9PSBzY0FycmF5W2kxXVsnYWRJZCddKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NpID0gaTE7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICBpZiAoc2NpID4gLTEpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChibG9ja1N0YXR1cyYmb2tTdGF0ZXMuaW5jbHVkZXMoYmxvY2tTdGF0dXMpKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsb2NrU3RhdHVzPT0nbm8tYmxvY2snKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhdGhlcmVkQmxvY2tDaGlsZC5pbm5lckhUTUwgPSAnJzsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKChibG9ja1N0YXR1cz09J2ZldGNoZWQnJiZkYXRhRnVsbD09MSl8fCFbJ25vLWJsb2NrJywnZmV0Y2hlZCddLmluY2x1ZGVzKGJsb2NrU3RhdHVzKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBjbDEgPSAwOyBjbDEgPCBnYXRoZXJlZEJsb2Nrc1tpXS5jbGFzc0xpc3QubGVuZ3RoOyBjbDErKykgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdhdGhlcmVkQmxvY2tzW2ldLmNsYXNzTGlzdFtjbDFdLmluY2x1ZGVzKCJyZXBlYXRhYmxlLW1hcmsiKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcGVhdGFibGVJZGVudGlmaWVyID0gZ2F0aGVyZWRCbG9ja3NbaV0uY2xhc3NMaXN0W2NsMV07DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVwZWF0YWJsZUlkZW50aWZpZXIpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdkNpZEVsZW1lbnQgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCIucGVyY2VudFBvaW50ZXJDbGFzcy5zY01hcmsuIityZXBlYXRhYmxlSWRlbnRpZmllcisnIGRpdltkYXRhLWNpZD0iJytkYXRhQ2lkSWRlbnRpZmllcisnIl0nKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdkNpZEVsZW1lbnQgPSBnYXRoZXJlZEJsb2NrQ2hpbGQucXVlcnlTZWxlY3RvckFsbCgnZGl2W2RhdGEtY2lkPSInK2RhdGFDaWRJZGVudGlmaWVyKyciXScpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSBzY0FycmF5W3NjaV1bJ3RleHQnXTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRpdkNpZEVsZW1lbnQmJmRpdkNpZEVsZW1lbnQubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaTIgPSAwOyBpMiA8IGRpdkNpZEVsZW1lbnQubGVuZ3RoOyBpMisrKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgalF1ZXJ5KGRpdkNpZEVsZW1lbnRbaTJdKS5odG1sKHRleHQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgalF1ZXJ5KGdhdGhlcmVkQmxvY2tDaGlsZCkuaHRtbCh0ZXh0KTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXVuY2hVcGRhdGVSYkRpc3BsYXlzKCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChibG9ja1N0YXR1cyE9J2ZldGNoZWQnfHwoYmxvY2tTdGF0dXM9PSdmZXRjaGVkJyYmZGF0YUZ1bGw9PTEpKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaTEgPSAwOyBpMSA8IHNjQXJyYXkubGVuZ3RoOyBpMSsrKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2NCbG9ja0lkID09IHNjQXJyYXlbaTFdWydibG9ja0lkJ10pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY0FycmF5LnNwbGljZShpMSwgMSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaTEtLTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnYXRoZXJlZEJsb2Nrc1tpXS5jbGFzc0xpc3QucmVtb3ZlKCdzY01hcmsnKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNjQmxvY2tJZCYmc2NBZElkIDwgMSYmWyduby1ibG9jaycsJ2ZldGNoZWQnXS5pbmNsdWRlcyhibG9ja1N0YXR1cykpIHsNCiAgICAgICAgICAgICAgICAgICAgZm9yIChpMSA9IDA7IGkxIDwgc2NBcnJheS5sZW5ndGg7IGkxKyspIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzY0Jsb2NrSWQgPT0gc2NBcnJheVtpMV1bJ2Jsb2NrSWQnXSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjQXJyYXkuc3BsaWNlKGkxLCAxKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpMS0tOw0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIGdhdGhlcmVkQmxvY2tzW2ldLmN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Sduby1ibG9jaycpfHwoWydkb25lJywnZmV0Y2hlZCcsJ3JlZnJlc2gtd2FpdCddLmluY2x1ZGVzKGdhdGhlcmVkQmxvY2tzW2ldWydkYXRhc2V0J11bInN0YXRlIl0pKSkgew0KICAgICAgICAgICAgICAgICAgICBnYXRoZXJlZEJsb2Nrc1tpXVsnaW5uZXJIVE1MJ10gPSAnJzsNCiAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICBjY1JlcGVhdCA9IHRydWU7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfSBlbHNlIGlmICghZ2F0aGVyZWRCbG9ja3NbaV1bJ2RhdGFzZXQnXVsnYWlkJ10pIHsNCiAgICAgICAgICAgICAgICBjY1JlcGVhdCA9IHRydWU7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICAgICAgaWYgKGN1Y19jb3UgPCA1MCkgew0KICAgICAgICAgICAgaWYgKGNjUmVwZWF0KSB7DQogICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7DQogICAgICAgICAgICAgICAgICAgIGNsZWFyVW5zdWl0YWJsZUNhY2hlKGN1Y19jb3UrMSk7DQogICAgICAgICAgICAgICAgfSwgMTAwKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgIGVuZGVkQ2MgPSB0cnVlOw0KICAgICAgICB9DQogICAgfSBlbHNlIHsNCiAgICAgICAgZW5kZWRDYyA9IHRydWU7DQogICAgfQ0KfQ0KDQpmdW5jdGlvbiBibG9ja3NSZXBvc2l0aW9uVXNlKGNvbnRhaW5lclN0cmluZywgYmxUeXBlLCBzZWFyY2hUeXBlLCBjb250ZW50RWxlbWVudCkgew0KICAgIGxldCBibG9ja3NJbkNvbnRhaW5lcjsNCiAgICBsZXQgYmxMb2NhbCA9IGJsVHlwZTsNCiAgICBsZXQgY3VycmVudEJsb2NrOw0KICAgIGxldCBjdXJyZW50QmxvY2tJZDsNCiAgICBsZXQgY3VycmVudEJsb2NrUG9zaXRpb247DQogICAgbGV0IGN1cnJlbnRDb250YWluZXI7DQogICAgbGV0IGkgPSAwOw0KICAgIGxldCBqID0gMDsNCiAgICBsZXQgYmxvY2tTdHJKcyA9ICcgLnBlcmNlbnRQb2ludGVyQ2xhc3MubWFya2VkJzsNCiAgICBsZXQgYmxvY2tTdHJQaHAgPSAnIC5wZXJjZW50UG9pbnRlckNsYXNzOm5vdCgubWFya2VkKSc7DQogICAgbGV0IGJsb2NrU3RyID0gJyAucGVyY2VudFBvaW50ZXJDbGFzcyc7DQogICAgbGV0IGNoZWNrUG9pbnRlciA9IG51bGw7DQogICAgbGV0IGJsb2NrUmVwZWF0RW5kID0gZmFsc2U7DQoNCiAgICBpZiAoc2VhcmNoVHlwZSkgew0KICAgICAgICBpZiAoc2VhcmNoVHlwZSA9PSAnbWFya2VkJykgew0KICAgICAgICAgICAgd2hpbGUgKCFibG9ja1JlcGVhdEVuZCkgew0KICAgICAgICAgICAgICAgIGJsTG9jYWwgPSBibExvY2FsLnBhcmVudEVsZW1lbnQ7DQogICAgICAgICAgICAgICAgaWYgKGJsTG9jYWwpIHsNCiAgICAgICAgICAgICAgICAgICAgY2hlY2tQb2ludGVyID0gYmxMb2NhbC5xdWVyeVNlbGVjdG9yKCIjY29udGVudF9wb2ludGVyX2lkIik7DQogICAgICAgICAgICAgICAgICAgIGlmICghY2hlY2tQb2ludGVyKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBibG9ja3NJbkNvbnRhaW5lciA9IGpRdWVyeShibExvY2FsKS5wYXJlbnQoY29udGFpbmVyU3RyaW5nKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChibG9ja3NJbkNvbnRhaW5lciAmJiBibG9ja3NJbkNvbnRhaW5lci5sZW5ndGggPiAwKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogY2hlY2tQb2ludGVyID0gYmxvY2tzSW5Db250YWluZXIucXVlcnlTZWxlY3RvcigiI2NvbnRlbnRfcG9pbnRlcl9pZCIpOyAqLw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrUG9pbnRlciA9IGpRdWVyeShibG9ja3NJbkNvbnRhaW5lcikuZmluZCgiI2NvbnRlbnRfcG9pbnRlcl9pZCIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGVja1BvaW50ZXIgJiYgY2hlY2tQb2ludGVyLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tzSW5Db250YWluZXIgPSBudWxsOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja1JlcGVhdEVuZCA9IHRydWU7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICBibG9ja1JlcGVhdEVuZCA9IHRydWUNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgIGJsb2NrUmVwZWF0RW5kID0gdHJ1ZQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIC8qIGJsb2Nrc0luQ29udGFpbmVyID0galF1ZXJ5KGJsVHlwZSkucGFyZW50KGNvbnRhaW5lclN0cmluZyk7ICovDQogICAgICAgICAgICBpZiAoYmxvY2tzSW5Db250YWluZXImJmJsb2Nrc0luQ29udGFpbmVyLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICAvKiBibG9ja3NJbkNvbnRhaW5lci5wYXJlbnROb2RlLmluc2VydEJlZm9yZShyYl90ZW1wRWxlbWVudCwgYmxvY2tzSW5Db250YWluZXIpOyAqLw0KICAgICAgICAgICAgICAgIGJsb2Nrc0luQ29udGFpbmVyWzBdLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHJiX3RlbXBFbGVtZW50LCBibG9ja3NJbkNvbnRhaW5lclswXSk7DQoNCiAgICAgICAgICAgICAgICBzYW1lRWxlbWVudEFmdGVyRXhjQ2xhc3NJZCA9IGZhbHNlOw0KICAgICAgICAgICAgICAgIHJldHVybiBibG9ja3NJbkNvbnRhaW5lclswXTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIHJldHVybiBibFR5cGU7DQogICAgICAgIH0gZWxzZSBpZiAoc2VhcmNoVHlwZSA9PSAnbm9uLW1hcmtlZCcpIHsNCiAgICAgICAgICAgIGJsb2Nrc0luQ29udGFpbmVyID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbChibFR5cGUgKyBjb250YWluZXJTdHJpbmcgKyBibG9ja1N0clBocCk7DQogICAgICAgICAgICBpZiAoYmxvY2tzSW5Db250YWluZXIgJiYgYmxvY2tzSW5Db250YWluZXIubGVuZ3RoID4gMCAmJiB1c2VkQmxvY2tTZXR0aW5nQXJyYXkgJiYgdXNlZEJsb2NrU2V0dGluZ0FycmF5Lmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgYmxvY2tzSW5Db250YWluZXIubGVuZ3RoOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgY3VycmVudEJsb2NrID0gYmxvY2tzSW5Db250YWluZXJbaV07DQogICAgICAgICAgICAgICAgICAgIGN1cnJlbnRCbG9ja0lkID0gY3VycmVudEJsb2NrLnF1ZXJ5U2VsZWN0b3IoJy4nICsgYmxvY2tfY2xhc3Nlcy5qb2luKCcsIC4nKSkuZ2V0QXR0cmlidXRlKCdkYXRhLWlkJyk7DQogICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDb250YWluZXIgPSBudWxsOw0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgdXNlZEJsb2NrU2V0dGluZ0FycmF5Lmxlbmd0aDsgaSsrKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodXNlZEJsb2NrU2V0dGluZ0FycmF5W2ldWydpZCddID09IGN1cnJlbnRCbG9ja0lkKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEJsb2NrUG9zaXRpb24gPSB1c2VkQmxvY2tTZXR0aW5nQXJyYXlbaV1bJ2VsZW1lbnRQb3NpdGlvbiddOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDb250YWluZXIgPSBjdXJyZW50QmxvY2suY2xvc2VzdChibFR5cGUgKyBjb250YWluZXJTdHJpbmcpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50QmxvY2tQb3NpdGlvbiA9PSAwKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDb250YWluZXIucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUoY3VycmVudEJsb2NrLCBjdXJyZW50Q29udGFpbmVyKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q29udGFpbmVyLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKGN1cnJlbnRCbG9jaywgY3VycmVudENvbnRhaW5lci5uZXh0U2libGluZyk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgfQ0KICAgIHJldHVybiBmYWxzZTsNCn0NCg0KZnVuY3Rpb24gY3JlYXRlU3R5bGVFbGVtZW50KGJsb2NrTnVtYmVyLCBsb2NhbEVsZW1lbnRDc3MpIHsNCiAgICBsZXQgaHRtbFRvQWRkID0gJyc7DQogICAgbGV0IG1hcmdpblN0cmluZ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FnZUNvbXBXaWR0aCA9IGdldENvbXB1dGVkU3R5bGUoZmlndXJlQ2hpbGRzW2ZjQ291XSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlc3RJbWFnZUNvbXBXaWR0aCA9IHBhcnNlSW50KHRlc3RJbWFnZUNvbXBXaWR0aC53aWR0aCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdpbWdfZl93OicrZmlndXJlQ29tV2lkdGgrJzsgaW1nX3c6Jyt0ZXN0SW1hZ2VDb21wV2lkdGgrJzsnKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmNDb3UrKzsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAodGVzdEltZyBpbnN0YW5jZW9mIEhUTUxJbWFnZUVsZW1lbnQpIHsNCiAgICAgICAgICAgICAgICAgICAgdGVzdEltZ0RldGVjdGVkID0gdHJ1ZTsNCiAgICAgICAgICAgICAgICAgICAgdGVzdEltYWdlQ29tcFdpZHRoID0gZ2V0Q29tcHV0ZWRTdHlsZSh0ZXN0SW1nKTsNCiAgICAgICAgICAgICAgICAgICAgdGVzdEltYWdlQ29tcFdpZHRoID0gcGFyc2VJbnQodGVzdEltYWdlQ29tcFdpZHRoLndpZHRoKTsNCiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ2ltZ193OicrdGVzdEltYWdlQ29tcFdpZHRoKyc7Jyk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGlmICghdGVzdEltZy5wcmV2aW91c1NpYmxpbmcpIHsNCiAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIHRlc3RJbWcgPSB0ZXN0SW1nLnByZXZpb3VzU2lib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JXaWR0aCA9IGNoZWNrQWRzV2lkdGgoY29udGVudF9wb2ludGVyLCAwLCBjdXJyZW50RWxlbWVudCk7DQogICAgICAgIH0gY2F0Y2ggKGV4KSB7DQogICAgICAgICAgICBjb25zb2xlLmxvZyhleC5tZXNzYWdlKTsNCiAgICAgICAgfQ0KICAgICAgICByZXZlcnQ/IGN1clN1bS0tOiBjdXJTdW0rKzsNCiAgICAgICAgdGVzdENvdSsrOw0KICAgIH0NCiAgICByZXR1cm4gY3VycmVudEVsZW1lbnQ/Y3VycmVudEVsZW1lbnQ6b3JpZ0N1cnJlbnRFbGVtZW50Ow0KfQ0KDQpmdW5jdGlvbiBleGNJZENsVW5wYWNrZXIoKSB7DQogICAgbGV0IGV4Y0FyciA9IFtdLA0KICAgICAgICBjb3UgPSAwLA0KICAgICAgICBjdXJyRXhjU3RyID0gJycsDQogICAgICAgIGN1ckV4Y0ZpcnN0ID0gJyc7DQogICAgZXhjQXJyWydpZCddID0gW107DQogICAgZXhjQXJyWydjbGFzcyddID0gW107DQogICAgZXhjQXJyWyd0YWcnXSA9IFtdOw0KICAgIGlmIChleGNJZENsYXNzJiZleGNJZENsYXNzLmxlbmd0aCA+IDApIHsNCiAgICAgICAgd2hpbGUgKGV4Y0lkQ2xhc3NbY291XSkgew0KICAgICAgICAgICAgY3VyckV4Y1N0ciA9IGV4Y0lkQ2xhc3NbY291XTsNCiAgICAgICAgICAgIGlmIChjdXJyRXhjU3RyLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICBjdXJFeGNGaXJzdCA9IGN1cnJFeGNTdHIuc3Vic3RyaW5nKDAsMSk7DQogICAgICAgICAgICAgICAgc3dpdGNoIChjdXJFeGNGaXJzdCkgew0KICAgICAgICAgICAgICAgICAgICBjYXNlICcjJzoNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyRXhjU3RyLmxlbmd0aCA+IDEpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyRXhjU3RyID0gY3VyckV4Y1N0ci5zdWJzdHJpbmcoMSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhjQXJyWydpZCddLnB1c2goY3VyckV4Y1N0cik7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICAgICAgY2FzZSAnLic6DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VyckV4Y1N0ci5sZW5ndGggPiAxKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VyckV4Y1N0ciA9IGN1cnJFeGNTdHIuc3Vic3RyaW5nKDEpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4Y0FyclsnY2xhc3MnXS5wdXNoKGN1cnJFeGNTdHIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6DQogICAgICAgICAgICAgICAgICAgICAgICBleGNBcnJbJ3RhZyddLnB1c2goY3VyckV4Y1N0cik7DQogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgY291Kys7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICB9DQogICAgcmV0dXJuIGV4Y0FycjsNCn0NCg0KZnVuY3Rpb24gYXN5bmNCbG9ja3NJbnNlcnRpbmdGdW5jdGlvbihibG9ja1NldHRpbmdBcnJheSkgew0KICAgIHRyeSB7DQogICAgICAgIHZhciBjb250ZW50X3BvaW50ZXIgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIjY29udGVudF9wb2ludGVyX2lkIik7IC8qIG9yaWcgKi8NCiAgICAgICAgdmFyIHBhcmVudF93aXRoX2NvbnRlbnQgPSBjb250ZW50X3BvaW50ZXIucGFyZW50RWxlbWVudDsNCiAgICAgICAgdmFyIGxvcmRPZkVsZW1lbnRzID0gcGFyZW50X3dpdGhfY29udGVudDsNCiAgICAgICAgcGFyZW50X3dpdGhfY29udGVudCA9IHBhcmVudF93aXRoX2NvbnRlbnQucGFyZW50RWxlbWVudDsNCiAgICAgICAgdmFyIG5ld0VsZW1lbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsNCiAgICAgICAgdmFyIGVsZW1lbnRUb0FkZDsNCiAgICAgICAgdmFyIGVsZW1lbnRUb0FkZFN0eWxlOw0KICAgICAgICB2YXIgcG9vbGJhY2tJID0gMDsNCiAgICAgICAgdmFyIGNvdW50ZXIgPSAwOw0KICAgICAgICB2YXIgY3VycmVudEVsZW1lbnQ7DQogICAgICAgIHZhciByZXBlYXRhYmxlQ3VycmVudEVsZW1lbnQ7DQogICAgICAgIHZhciByZXBlYXRhYmxlU3VjY2VzczsNCiAgICAgICAgdmFyIHJlQ291Ow0KICAgICAgICB2YXIgY3VyRmlyc3RQbGFjZTsNCiAgICAgICAgdmFyIGN1ckVsZW1lbnRDb3VudDsNCiAgICAgICAgdmFyIGN1ckVsZW1lbnRTdGVwOw0KICAgICAgICB2YXIgYmFja0VsZW1lbnQgPSAwOw0KICAgICAgICB2YXIgc3VtUmVzdWx0ID0gMDsNCiAgICAgICAgdmFyIGN1clN1bVJlc3VsdCA9IDA7DQogICAgICAgIHZhciByZXBlYXQgPSBmYWxzZTsNCiAgICAgICAgdmFyIGN1cnJlbnRFbGVtZW50Q2hlY2tlciA9IGZhbHNlOw0KICAgICAgICBsZXQgY29udGFpbmVyRm9yNnRoID0gW107DQogICAgICAgIGxldCBjb250YWluZXJGb3I3dGggPSBbXTsNCiAgICAgICAgdmFyIHBvc0N1cnJlbnRFbGVtZW50Ow0KICAgICAgICB2YXIgYmxvY2tfbnVtYmVyOw0KICAgICAgICBsZXQgY29udGVudExlbmd0aCA9IGNvbnRlbnRfcG9pbnRlci5nZXRBdHRyaWJ1dGUoJ2RhdGEtY29udGVudC1sZW5ndGgnKTsNCiAgICAgIC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JyZW50RWxlbWVudC5wYXJlbnROb2RlLmluc2VydEJlZm9yZShyYl90ZW1wRWxlbWVudCwgY3VycmVudEVsZW1lbnQpOw0KICAgICAgICAgICAgICAgIHJiX3RlbXBFbGVtZW50X2NoZWNrID0gdHJ1ZTsNCiAgICAgICAgICAgICAgICBzYW1lRWxlbWVudEFmdGVyRnJvbUNvbnN0cnVjdGlvbj1mYWxzZTsNCiAgICAgICAgICAgIH0gZWxzZSBpZiAoWyJ0ciIsInRkIiwidGgiLCJ0aGVhZCIsInRib2R5IiwidGFibGUiXS5pbmNsdWRlcyhjdXJyZW50RWxlbWVudC5wYXJlbnRFbGVtZW50LnRhZ05hbWUudG9Mb3dlckNhc2UoKSkpIHsNCiAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudCA9IGN1cnJlbnRFbGVtZW50LnBhcmVudEVsZW1lbnQ7DQogICAgICAgICAgICAgICAgd2hpbGUgKFsidHIiLCJ0ZCIsInRoIiwidGhlYWQiLCJ0Ym9keSIsInRhYmxlIl0uaW5jbHVkZXMoY3VycmVudEVsZW1lbnQucGFyZW50RWxlbWVudC50YWdOYW1lLnRvTG93ZXJDYXNlKCkpKSB7DQogICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50ID0gY3VycmVudEVsZW1lbnQucGFyZW50RWxlbWVudDsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgY3VycmVudEVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocmJfdGVtcEVsZW1lbnQsIGN1cnJlbnRFbGVtZW50KTsNCiAgICAgICAgICAgICAgICByYl90ZW1wRWxlbWVudF9jaGVjayA9IHRydWU7DQogICAgICAgICAgICAgICAgc2FtZUVsZW1lbnRBZnRlckZyb21Db25zdHJ1Y3Rpb249ZmFsc2U7DQogICAgICAgICAgICB9DQogICAgICAgICAgICByZXR1cm4gY3VycmVudEVsZW1lbnQ7DQogICAgICAgIH0NCg0KICAgICAgICBmdW5jdGlvbiBkaXJlY3RDbGFzc0VsZW1lbnREZXRlY3RpbmcoYmxvY2tTZXR0aW5nQXJyYXksIGRpcmVjdEVsZW1lbnQpIHsNCiAgICAgICAgICAgIGxldCBmaW5kUXVlcnkgPSAwOw0KICAgICAgICAgICAgbGV0IGRpcmVjdENsYXNzRWxlbWVudFJlc3VsdCA9IFtdOw0KDQogICAgICAgICAgICBjdXJyZW50RWxlbWVudCA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoZGlyZWN0RWxlbWVudCk7DQogICAgICAgICAgICBpZiAoY3VycmVudEVsZW1lbnQubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgIGlmIChibG9ja1NldHRpbmdBcnJheVtpXVsnZWxlbWVudFBsYWNlJ10gPiAxKSB7DQogICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50RWxlbWVudC5sZW5ndGggPj0gYmxvY2tTZXR0aW5nQXJyYXlbaV1bJ2VsZW1lbnRQbGFjZSddKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudCA9IGN1cnJlbnRFbGVtZW50W2Jsb2NrU2V0dGluZ0FycmF5W2ldWydlbGVtZW50UGxhY2UnXS0xXTsNCiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjdXJyZW50RWxlbWVudC5sZW5ndGggPCBibG9ja1NldHRpbmdBcnJheVtpXVsnZWxlbWVudFBsYWNlJ10pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50ID0gY3VycmVudEVsZW1lbnRbY3VycmVudEVsZW1lbnQubGVuZ3RoIC0gMV07DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICBmaW5kUXVlcnkgPSAxOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfSBlbHNlIGlmIChibG9ja1NldHRpbmdBcnJheVtpXVsnZWxlbWVudFBsYWNlJ10gPCAwKSB7DQogICAgICAgICAgICAgICAgICAgIGlmICgoY3VycmVudEVsZW1lbnQubGVuZ3RoICsgYmxvY2tTZXR0aW5nQXJyYXlbaV1bJ2VsZW1lbnRQbGFjZSddICsgMSkgPiAwKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudCA9IGN1cnJlbnRFbGVtZW50W2N1cnJlbnRFbGVtZW50Lmxlbmd0aCArIGJsb2NrU2V0dGluZ0FycmF5W2ldWydlbGVtZW50UGxhY2UnXV07DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICBmaW5kUXVlcnkgPSAxOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgZmluZFF1ZXJ5ID0gMTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgIGZpbmRRdWVyeSA9IDE7DQogICAgICAgICAgICB9DQoNCiAgICAgICAgICAgIGRpcmVjdENsYXNzRWxlbWVudFJlc3VsdFsnZmluZFF1ZXJ5J10gPSBmaW5kUXVlcnk7DQogICAgICAgICAgICBkaXJlY3RDbGFzc0VsZW1lbnRSZXN1bHRbJ2N1cnJlbnRFbGVtZW50J10gPSBjdXJyZW50RWxlbWVudDsNCg0KICAgICAgICAgICAgcmV0dXJuIGRpcmVjdENsYXNzRWxlbWVudFJlc3VsdDsNCiAgICAgICAgfQ0KDQogICAgICAgIGZ1bmN0aW9uIHBsYWNpbmdUb0gxKHVzZWRFbGVtZW50LCBlbGVtZW50VGFnVG9GaW5kKSB7DQogICAgICAgICAgICBsZXQgdXNlbGVzc0xldDsNCiAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50ID0gdXNlZEVsZW1lbnQucXVlcnlTZWxlY3RvckFsbChlbGVtZW50VGFnVG9GaW5kKTsNCg0KICAgICAgICAgICAgaWYgKGN1cnJlbnRFbGVtZW50Lmxlbmd0aCA8IDEpIHsNCiAgICAgICAgICAgICAgICBpZiAodXNlZEVsZW1lbnQucGFyZW50RWxlbWVudCkgew0KICAgICAgICAgICAgICAgICAgICB1c2VsZXNzTGV0ID0gcGxhY2luZ1RvSDEodXNlZEVsZW1lbnQucGFyZW50RWxlbWVudCwgZWxlbWVudFRhZ1RvRmluZCk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgcmV0dXJuIGN1cnJlbnRFbGVtZW50Ow0KICAgICAgICB9DQoNCiAgICAgICAgZnVuY3Rpb24gZWxlbWVudHNDbGVhbmluZyhleGNBcnIsIGVsTGlzdCwgcHdjTG9jYWwsIGdhdGhlclN0cmluZykgew0KICAgICAgICAgICAgbGV0IG1hcmtlZENsYXNzID0gJ3JiX21faW5jJzsNCiAgICAgICAgICAgIGxldCBtYXJrZWRDbGFzc0JhZCA9ICdyYl9tX2V4Yyc7DQogICAgICAgICAgICBsZXQgY291ID0gMDsNCiAgICAgICAgICAgIGxldCBjb3UxID0gMDsNCiAgICAgICAgICAgIGxldCBmaW5hbEFyciA9IFtdOw0KICAgICAgICAgICAgbGV0IGZpbmFsQXJyQ2xlYXIgPSBbXTsNCiAgICAgICAgICAgIGxldCBjaGVja05lYXJlc3Q7DQogICAgICAgICAgICBsZXQgb3V0T2ZSYW5nZUNoZWNrOw0KICAgICAgICAgICAgbGV0IGdhdGhlclJlamVjdGVkOw0KICAgICAgICAgICAgbGV0IGFsbG93ZXI7DQoNCiAgICAgICAgICAgIHRyeSB7DQogICAgICAgICAgICAgICAgd2hpbGUgKGVsTGlzdFtjb3VdKSB7DQogICAgICAgICAgICAgICAgICAgIGFsbG93ZXIgPSB0cnVlOw0KICAgICAgICAgICAgICAgICAgICBpZiAoIWVsTGlzdFtjb3VdLmNsYXNzTGlzdC5jb250YWlucyhtYXJrZWRDbGFzc0JhZCkpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChleGNBcnImJmV4Y0Fyci5sZW5ndGggPiAwKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY291MSA9IDA7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGV4Y0Fycltjb3UxXSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja05lYXJlc3QgPSBlbExpc3RbY291XS5wYXJlbnRFbGVtZW50LmNsb3Nlc3QoZXhjQXJyW2NvdTFdKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoZWNrTmVhcmVzdCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tOZWFyZXN0LmNsYXNzTGlzdC5hZGQoJ2N1cnJDbG9zZXN0Jyk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRPZlJhbmdlQ2hlY2sgPSBwd2NMb2NhbC5xdWVyeVNlbGVjdG9yKCcuY3VyckNsb3Nlc3QnKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvdXRPZlJhbmdlQ2hlY2spIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxvd2VyID0gZmFsc2U7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tOZWFyZXN0LmNsYXNzTGlzdC5hZGQobWFya2VkQ2xhc3MpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhdGhlclJlamVjdGVkID0gY2hlY2tOZWFyZXN0LnF1ZXJ5U2VsZWN0b3JBbGwoZ2F0aGVyU3RyaW5nKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2F0aGVyUmVqZWN0ZWQubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpMSA9IDA7IGkxIDwgZ2F0aGVyUmVqZWN0ZWQubGVuZ3RoOyBpMSsrKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnYXRoZXJSZWplY3RlZFtpMV0uY2xhc3NMaXN0LmFkZChtYXJrZWRDbGFzc0JhZCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja05lYXJlc3QuY2xhc3NMaXN0LnJlbW92ZSgnY3VyckNsb3Nlc3QnKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb3UxKys7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFsbG93ZXI9PT10cnVlKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxMaXN0W2NvdV0uY2xhc3NMaXN0LmFkZChtYXJrZWRDbGFzcyk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogZmluYWxBcnIucHVzaChlbExpc3RbY291XSk7ICovDQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgY291Kys7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGZpbmFsQXJyID0gcHdjTG9jYWwucXVlcnlTZWxlY3RvckFsbCgnLicrbWFya2VkQ2xhc3MrJzpub3QoJyttYXJrZWRDbGFzc0JhZCsnKScpOw0KICAgICAgICAgICAgICAgIGZpbmFsQXJyQ2xlYXIgPSBwd2NMb2NhbC5xdWVyeVNlbGVjdG9yQWxsKCcuJyttYXJrZWRDbGFzcysnLC4nK21hcmtlZENsYXNzQmFkKTsNCiAgICAgICAgICAgICAgICBpZiAoZmluYWxBcnJDbGVhciYmZmluYWxBcnJDbGVhci5sZW5ndGggPiAwKSB7DQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkxID0gMDsgaTEgPCBmaW5hbEFyckNsZWFyLmxlbmd0aDsgaTErKykgew0KICAgICAgICAgICAgICAgICAgICAgICAgZmluYWxBcnJDbGVhcltpMV0uY2xhc3NMaXN0LnJlbW92ZShtYXJrZWRDbGFzcyxtYXJrZWRDbGFzc0JhZCk7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9IGNhdGNoIChlcikgew0KICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGVyLm1lc3NhZ2UpOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgcmV0dXJuIGZpbmFsQXJyOw0KICAgICAgICB9DQoNCiAgICAgICAgZnVuY3Rpb24gY3VyZWVudEVsZW1lbnRzR2F0aGVyKHVzZWRFbGVtZW50LCBsb29wTGltaXQgPSAyLCBsb2NhbFB3YyA9IHBhcmVudF93aXRoX2NvbnRlbnQpIHsNCiAgICAgICAgICAgIGxldCBjdXJFbGVtZW50U2VhcmNoUmVwZWF0ZXIgPSB0cnVlOw0KICAgICAgICAgICAgbGV0IGN1ckVsZW1lbnRTZWFyY2hDb3VudGVyID0gMDsNCiAgICAgICAgICAgIGxldCBjdXJyZW50RWxlbWVudExvYyA9IG51bGw7DQogICAgICAgICAgICBsZXQgRXhjbHVkZWRTdHJpbmdCZWdpbiA9ICcnOw0KICAgICAgICAgICAgbGV0IEV4Y2x1ZGVkU3RyaW5nID0gJyc7DQogICAgICAgICAgICBsZXQgRXhjbHVkZWRTdHJpbmdFbmQgPSAnJzsNCiAgICAgICAgICAgIGxldCB0YWdMaXN0U3RyaW5nID0gJyc7DQogICAgICAgICAgICBsZXQgdGFnTGlzdFN0cmluZ0V4YyA9ICcnOw0KICAgICAgICAgICAgbGV0IGNvdSA9IDA7DQogICAgICAgICAgICAvKiBsZXQgZXhjQXJyID0gZXhjSWRDbFVucGFja2VyKCk7ICovDQogICAgICAgICAgICBsZXQgdGFnTGlzdENvdSA9IDA7DQoNCiAgICAgICAgICAgIGlmICh1c2VkRWxlbWVudD09J2gxJykgew0KICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50TG9jID0gcGxhY2luZ1RvSDEobG9jYWxQd2MsIHVzZWRFbGVtZW50KTsNCiAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgaWYgKHVzZWRFbGVtZW50PT0naDItNCcpIHt0YWdMaXN0ID0gWydoMicsJ2gzJywnaDMnXTt9DQogICAgICAgICAgICAgICAgZWxzZSAgICAgICAgICAgICAgICAgICAgIHt0YWdMaXN0ID0gW3VzZWRFbGVtZW50XTsgICB9DQogICAgICAgICAgICAgICAgd2hpbGUgKHRhZ0xpc3RbdGFnTGlzdENvdV0pIHsNCiAgICAgICAgICAgICAgICAgICAgdGFnTGlzdFN0cmluZyArPSAoKGNvdSsrPjApPycsJzonJykrdGFnTGlzdFt0YWdMaXN0Q291XTsNCiAgICAgICAgICAgICAgICAgICAgdGFnTGlzdFN0cmluZ0V4YyArPSAnOm5vdCgnK3RhZ0xpc3RbdGFnTGlzdENvdV0rJyknOw0KICAgICAgICAgICAgICAgICAgICB0YWdMaXN0Q291Kys7DQogICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgRXhjbHVkZWRTdHJpbmcgPSAnJzsNCiAgICAgICAgICAgICAgICBpZiAoZXhjSWRDbGFzcyYmZXhjSWRDbGFzcy5sZW5ndGggPiAwKSB7DQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkyID0gMDsgaTIgPCBleGNJZENsYXNzLmxlbmd0aDsgaTIrKykgew0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV4Y0lkQ2xhc3NbaTJdLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBFeGNsdWRlZFN0cmluZyArPSAoaTI+MD8nLCc6JycpK2V4Y0lkQ2xhc3NbaTJdK3RhZ0xpc3RTdHJpbmdFeGM7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgZGV0YWlsZWRRdWVyeVN0cmluZyArPSB0YWdMaXN0U3RyaW5nKycsJytFeGNsdWRlZFN0cmluZzsNCg0KICAgICAgICAgICAgICAgIC8qIGNvbnNvbGUubG9nKGRldGFpbGVkUXVlcnlTdHJpbmcpOyAqLw0KICAgICAgICAgICAgICAgIHdoaWxlIChjdXJFbGVtZW50U2VhcmNoUmVwZWF0ZXImJmN1ckVsZW1lbnRTZWFyY2hDb3VudGVyIDwgbG9vcExpbWl0KSB7DQogICAgICAgICAgICAgICAgICAgIHRyeSB7DQogICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudExvYyA9IGxvY2FsUHdjLnF1ZXJ5U2VsZWN0b3JBbGwodGFnTGlzdFN0cmluZyk7DQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUxKSB7Y29uc29sZS5sb2coZTEubWVzc2FnZSk7fQ0KICAgICAgICAgICAgICAgICAgICBpZiAoIWN1cnJlbnRFbGVtZW50TG9jKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAobG9jYWxQd2MucGFyZW50RWxlbWVudCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvY2FsUHdjID0gbG9jYWxQd2MucGFyZW50RWxlbWVudDsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICBjdX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AgICAgICAgICBzYW1lRWxlbWVudEFmdGVyV2lkdGggPSBjaGVja0Fkc1dpZHRoKGNvbnRlbnRfcG9pbnRlciwgYmxvY2tTZXR0aW5nQXJyYXlbaV1bImVsZW1lbnRQb3NpdGlvbiJdLCBsb2NhbEN1ckVsKTsNCiAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgew0KICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhleC5tZXNzYWdlKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgcmV2ZXJ0PyBjdXJTdW1SZXN1bHQtLTogY3VyU3VtUmVzdWx0Kys7DQogICAgICAgICAgICAgICAgdGVzdENvdSsrOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgaWYgKGxvY2FsQ3VyRWwpIHsNCiAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudENoZWNrZXIgPSB0cnVlOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgcmV0dXJuIGxvY2FsQ3VyRWw/bG9jYWxDdXJFbDpvcmlnQ3VyRWw7DQogICAgICAgIH0NCiAgICAgICAgDQogICAgICAgIGZ1bmN0aW9uIGVuZGluZ0FjdGlvbnMoYmxvY2tfbnVtYmVyKSB7DQogICAgICAgICAgICB1c2VkQmxvY2tTZXR0aW5nQXJyYXlJZHMucHVzaChibG9ja19udW1iZXIpOw0KICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXkuc3BsaWNlKGktLSwgMSk7DQogICAgICAgICAgICBwb29sYmFja0kgPSAxOw0KICAgICAgICB9DQoNCiAgICAgICAgZm9yIChpID0gMDsgaSA8IGJsb2NrU2V0dGluZ0FycmF5Lmxlbmd0aDsgaSsrKSB7DQogICAgICAgICAgICBjdXJyZW50RWxlbWVudCA9IG51bGw7DQogICAgICAgICAgICBjdXJyZW50RWxlbWVudENoZWNrZXIgPSBmYWxzZTsNCiAgICAgICAgICAgIHNhbWVFbGVtZW50QWZ0ZXJXaWR0aCA9IGZh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ZXIuY2xhc3NMaXN0LmNvbnRhaW5zKCJoYXJkLWNvbnRlbnQiKSYmYmxvY2tTZXR0aW5nQXJyYXlbaV1bInNldHRpbmdfdHlwZSJdIT0zKQ0KICAgICAgICAgICAgICAgICkgew0KICAgICAgICAgICAgICAgICAgICBibG9ja1NldHRpbmdBcnJheS5zcGxpY2UoaS0tLCAxKTsNCiAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgY29udGludWU7DQogICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgYmxvY2tfbnVtYmVyID0gMDsNCg0KICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOw0KICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5jbGFzc0xpc3QuYWRkKCJwZXJjZW50UG9pbnRlckNsYXNzIik7DQogICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLmNsYXNzTGlzdC5hZGQoIm1hcmtlZCIpOw0KICAgICAgICAgICAgICAgIGlmIChibG9ja1NldHRpbmdBcnJheVtpXVsic2MiXT09MSkgew0KICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuY2xhc3NMaXN0LmFkZCgic2NNYXJrIik7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5pbm5lckhUTUwgPSBibG9ja1NldHRpbmdBcnJheVtpXVsidGV4dCJdOw0KICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5kYXRhc2V0LnJiaW5kZXIgPSBiaW5kZXJOYW1lOw0KICAgICAgICAgICAgICAgIGJsb2NrX251bWJlciA9IGVsZW1lbnRUb0FkZC5jaGlsZHJlblswXS5hdHRyaWJ1dGVzWydkYXRhLWlkJ10udmFsdWU7DQoNCiAgICAgICAgICAgICAgICBpZiAoYmxvY2tEdXBsaWNhdGUgPT0gJ25vJykgew0KICAgICAgICAgICAgICAgICAgICBpZiAodXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkxID0gMDsgaTEgPCB1c2VkQmxvY2tTZXR0aW5nQXJyYXlJZHMubGVuZ3RoOyBpMSsrKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsb2NrX251bWJlcj09dXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzW2kxXSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja1NldHRpbmdBcnJheS5zcGxpY2UoaS0tLCAxKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBvb2xiYWNrSSA9PSAxKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGRTdHlsZSA9IGNyZWF0ZVN0eWxlRWxlbWVudChibG9ja19udW1iZXIsIGJsb2NrU2V0dGluZ0FycmF5W2ldWyJlbGVtZW50Q3NzIl0pOw0KDQogICAgICAgICAgICAgICAgaWYgKGVsZW1lbnRUb0FkZFN0eWxlJiZlbGVtZW50VG9BZGRTdHlsZSE9J2RlZmF1bHQnKSB7DQogICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5zdHlsZS50ZXh0QWxpZ24gPSBlbGVtZW50VG9BZGRTdHlsZTsNCiAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICBpZiAoKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJtaW5IZWFkZXJzIl0gPiAwKSYmKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJtaW5IZWFkZXJzIl0gPiB0ZXJtb3Jhcml0eV9wYXJlbnRfd2l0aF9jb250ZW50X2xlbmd0aCkpIHtjb250aW51ZTt9DQogICAgICAgICAgICAgICAgaWYgKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJtaW5TeW1ib2xzIl0gPiBjb250ZW50TGVuZ3RoKSB7Y29udGludWU7fQ0KDQogICAgICAgICAgICAgICAgaWYgKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJzZXR0aW5nX3R5cGUiXSA9PSAxKSB7DQogICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50ID0gY3VyZWVudEVsZW1lbnRzR2F0aGVyKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJlbGVtZW50Il0udG9Mb3dlckNhc2UoKSk7DQogICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50RWxlbWVudCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJlbGVtZW50UGxhY2UiXSA8IDApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdW1SZXN1bHQgPSBjdXJyZW50RWxlbWVudC5sZW5ndGggKyBibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudFBsYWNlIl07DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN1bVJlc3VsdCA+PSAwICYmIHN1bVJlc3VsdCA8IGN1cnJlbnRFbGVtZW50Lmxlbmd0aCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudCA9IGN1cnJlbnRFbGVtZW50UmVjZWl2ZXIodHJ1ZSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdW1SZXN1bHQgPSBibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudFBsYWNlIl0gLSAxOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdW1SZXN1bHQgPCBjdXJyZW50RWxlbWVudC5sZW5ndGgpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEVsZW1lbnQgPSBjdXJyZW50RWxlbWVudFJlY2VpdmVyKGZhbHNlKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRFbGVtZW50ICE9IHVuZGVmaW5lZCAmJiBjdXJyZW50RWxlbWVudCAhPSBudWxsICYmIGN1cnJlbnRFbGVtZW50Q2hlY2tlcikgew0KICAgICAgICAgICAgICAgICAgICAgICAgcG9zQ3VycmVudEVsZW1lbnQgPSBpbml0VGFyZ2V0VG9JbnNlcnQoYmxvY2tTZXR0aW5nQXJyYXlbaV1bImVsZW1lbnRQb3NpdGlvbiJdLCAnZWxlbWVudCcsIGN1cnJlbnRFbGVtZW50KTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50LnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKGVsZW1lbnRUb0FkZCwgcG9zQ3VycmVudEVsZW1lbnQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEVsZW1lbnQuY2xhc3NMaXN0LmFkZCgncmJpbmRlci0nK2JpbmRlck5hbWUpOw0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLmNsYXNzTGlzdC5yZW1vdmUoJ2NvdmVyZWRBZCcpOw0KICAgICAgICAgICAgICAgICAgICAgICAgdXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzLnB1c2goYmxvY2tfbnVtYmVyKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrU2V0dGluZ0FycmF5LnNwbGljZShpLS0sIDEpOw0KICAgICAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJiX3RlbXBFbGVtZW50X2NoZWNrID0gZmFsc2U7DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXBlYXQgPSB0cnVlOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGVsc2UgaWYgKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJzZXR0aW5nX3R5cGUiXSA9PSAyKSB7DQogICAgICAgICAgICAgICAgICAgIGlmIChibG9ja0R1cGxpY2F0ZSA9PSAnbm8nKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudENvdW50Il0gPSAxOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIHJlcGVhdGFibGVDdXJyZW50RWxlbWVudCA9IFtdOw0KICAgICAgICAgICAgICAgICAgICByZUNvdSA9IDA7DQogICAgICAgICAgICAgICAgICAgIGN1ckZpcnN0UGxhY2UgPSBibG9ja1NldHRpbmdBcnJheVtpXVsiZmlyc3RQbGFjZSJdOw0KICAgICAgICAgICAgICAgICAgICBjdXJFbGVtZW50Q291bnQgPSBibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudENvdW50Il07DQogICAgICAgICAgICAgICAgICAgIGN1ckVsZW1lbnRTdGVwID0gYmxvY2tTZXR0aW5nQXJyYXlbaV1bImVsZW1lbnRTdGVwIl07DQogICAgICAgICAgICAgICAgICAgIHJlcGVhdGFibGVTdWNjZXNzID0gZmFsc2U7DQoNCiAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkU3R5bGUgPSBjcmVhdGVTdHlsZUVsZW1lbnQoYmxvY2tfbnVtYmVyLCBibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudENzcyJdKTsNCg0KICAgICAgICAgICAgICAgICAgICByZXBlYXRhYmxlQ3VycmVudEVsZW1lbnQgPSBjdXJlZW50RWxlbWVudHNHYXRoZXIoYmxvY2tTZXR0aW5nQXJyYXlbaV1bImVsZW1lbnQiXS50b0xvd2VyQ2FzZSgpKTsNCiAgICAgICAgICAgICAgICAgICAgaWYgKHJlcGVhdGFibGVDdXJyZW50RWxlbWVudCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaTEgPSAwOyBpMSA8IGJsb2NrU2V0dGluZ0FycmF5W2ldWyJlbGVtZW50Q291bnQiXTsgaTErKykgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50Q2hlY2tlciA9IGZhbHNlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXBFbGVtZW50VG9BZGQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXBFbGVtZW50VG9BZGQuY2xhc3NMaXN0LmFkZCgicGVyY2VudFBvaW50ZXJDbGFzcyIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcEVsZW1lbnRUb0FkZC5jbGFzc0xpc3QuYWRkKCJtYXJrZWQiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmxvY2tTZXR0aW5nQXJyYXlbaV1bInNjIl09PTEpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVwRWxlbWVudFRvQWRkLmNsYXNzTGlzdC5hZGQoInNjTWFyayIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXBFbGVtZW50VG9BZGQuY2xhc3NMaXN0LmFkZCgicmVwZWF0YWJsZS1tYXJrLSIrcmVwZWF0YWJsZUJsb2NrSWRlbnRpZmllcik7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVwRWxlbWVudFRvQWRkLmlubmVySFRNTCA9IGJsb2NrU2V0dGluZ0FycmF5W2ldWyJ0ZXh0Il07DQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudFRvQWRkU3R5bGUmJmVsZW1lbnRUb0FkZFN0eWxlIT0nZGVmYXVsdCcpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVwRWxlbWVudFRvQWRkLnN0eWxlLnRleHRBbGlnbiA9IGVsZW1lbnRUb0FkZFN0eWxlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1bVJlc3VsdCA9IE1hdGgucm91bmQocGFyc2VJbnQoYmxvY2tTZXR0aW5nQXJyYXlbaV1bImZpcnN0UGxhY2UiXSkgKyAoaTEqcGFyc2VJbnQoYmxvY2tTZXR0aW5nQXJyYXlbaV1bImVsZW1lbnRTdGVwIl0pKSAtIDEpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdW1SZXN1bHQgPCByZXBlYXRhYmxlQ3VycmVudEVsZW1lbnQubGVuZ3RoKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50ID0gY3VycmVudEVsZW1lbnRSZWNlaXZlcihmYWxzZSwgcmVwZWF0YWJsZUN1cnJlbnRFbGVtZW50KTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEVsZW1lbnQgIT0gdW5kZWZpbmVkICYmIGN1cnJlbnRFbGVtZW50ICE9IG51bGwgJiYgY3VycmVudEVsZW1lbnRDaGVja2VyKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc0N1cnJlbnRFbGVtZW50ID0gaW5pdFRhcmdldFRvSW5zZXJ0KGJsb2NrU2V0dGluZ0FycmF5W2ldWyJlbGVtZW50UG9zaXRpb24iXSwgJ2VsZW1lbnQnLCBjdXJyZW50RWxlbWVudCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50LnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHJlcEVsZW1lbnRUb0FkZCwgcG9zQ3VycmVudEVsZW1lbnQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudC5jbGFzc0xpc3QuYWRkKCdyYmluZGVyLScrYmluZGVyTmFtZSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcEVsZW1lbnRUb0FkZC5jbGFzc0xpc3QucmVtb3ZlKCdjb3ZlcmVkQWQnKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VyRmlyc3RQbGFjZSA9IHN1bVJlc3VsdCArIHBhcnNlSW50KGJsb2NrU2V0dGluZ0FycmF5W2ldWyJlbGVtZW50U3RlcCJdKSArIDE7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1ckVsZW1lbnRDb3VudC0tOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXBlYXRhYmxlU3VjY2VzcyA9IHRydWU7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVwZWF0YWJsZVN1Y2Nlc3MgPSBmYWxzZTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIGlmIChyZXBlYXRhYmxlU3VjY2Vzcz09dHJ1ZSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgdXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzLnB1c2goYmxvY2tfbnVtYmVyKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrU2V0dGluZ0FycmF5LnNwbGljZShpLS0sIDEpOw0KICAgICAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgICAgIHJlcGVhdGFibGVCbG9ja0lkZW50aWZpZXIrKzsNCiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYmxvY2tTZXR0aW5nQXJyYXlbaV1bInVuc3VjY2VzcyJdKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXlbaV1bInVuc3VjY2VzcyJdID0gMTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXlbaV1bInVuc3VjY2VzcyJdID0gTWF0aC5yb3VuZChibG9ja1NldHRpbmdBcnJheVtpXVsidW5zdWNjZXNzIl0gKyAxKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChibG9ja1NldHRpbmdBcnJheVtpXVsidW5zdWNjZXNzIl0gPiAxMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVzZWRCbG9ja1NldHRpbmdBcnJheUlkcy5wdXNoKGJsb2NrX251bWJlcik7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXkuc3BsaWNlKGktLSwgMSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXlbaV1bImZpcnN0UGxhY2UiXSA9IGN1ckZpcnN0UGxhY2U7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXlbaV1bImVsZW1lbnRDb3VudCJdID0gY3VyRWxlbWVudENvdW50Ow0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrU2V0dGluZ0FycmF5W2ldWyJlbGVtZW50U3RlcCJdID0gY3VyRWxlbWVudFN0ZXA7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVwZWF0ID0gdHJ1ZTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBlbHNlIGlmIChibG9ja1NldHRpbmdBcnJheVtpXVsic2V0dGluZ190eXBlIl0gPT0gMykgew0KICAgICAgICAgICAgICAgICAgICBsZXQgZWxlbWVudFR5cGVTeW1ib2wgPSAnJzsNCiAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRTcGFjZVN5bWJvbCA9ICcnOw0KICAgICAgICAgICAgICAgICAgICBsZXQgZWxlbWVudE5hbWUgPSAnJzsNCiAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRUeXBlID0gJyc7DQogICAgICAgICAgICAgICAgICAgIGxldCBlbGVtZW50VGFnICA9ICcnOw0KICAgICAgICAgICAgICAgICAgICBsZXQgZmluZFF1ZXJ5ID0gMDsNCiAgICAgICAgICAgICAgICAgICAgbGV0IGRpcmVjdENsYXNzUmVzdWx0ID0gW107DQogICAgICAgICAgICAgICAgICAgIGxldCBkaXJlY3RFbGVtZW50ID0gYmxvY2tTZXR0aW5nQXJyYXlbaV1bImRpcmVjdEVsZW1lbnQiXS50cmltKCk7DQoNCiAgICAgICAgICAgICAgICAgICAgaWYgKGRpcmVjdEVsZW1lbnQuc2VhcmNoKCcjJykgPiAtMSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgZmluZFF1ZXJ5ID0gMTsNCiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICgoZGlyZWN0RWxlbWVudC5zZWFyY2goJyMnKSA8IDApJiYoZGlyZWN0RWxlbWVudC5zZWFyY2goJy4nKSA+IC0xKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgZGlyZWN0Q2xhc3NSZXN1bHQgPSBkaXJlY3RDbGFzc0VsZW1lbnREZXRlY3RpbmcoYmxvY2tTZXR0aW5nQXJyYXksIGRpcmVjdEVsZW1lbnQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgZmluZFF1ZXJ5ID0gZGlyZWN0Q2xhc3NSZXN1bHRbJ2ZpbmRRdWVyeSddOw0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEVsZW1lbnQgPSBkaXJlY3RDbGFzc1Jlc3VsdFsnY3VycmVudEVsZW1lbnQnXTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBpZiAoZmluZFF1ZXJ5ID09IDEpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihkaXJlY3RFbGVtZW50KTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEVsZW1lbnQpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50Q2hlY2tlciA9IHRydWU7DQogICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEVsZW1lbnQgIT0gdW5kZWZpbmVkICYmIGN1cnJlbnRFbGVtZW50ICE9IG51bGwgJiYgY3VycmVudEVsZW1lbnRDaGVja2VyKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBwb3NDdXJyZW50RWxlbWVudCA9IGluaXRUYXJnZXRUb0luc2VydChibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudFBvc2l0aW9uIl0sICdlbGVtZW50JywgY3VycmVudEVsZW1lbnQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEVsZW1lbnQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUoZWxlbWVudFRvQWRkLCBwb3NDdXJyZW50RWxlbWVudCk7DQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuY2xhc3NMaXN0LnJlbW92ZSgnY292ZXJlZEFkJyk7DQogICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudC5jbGFzc0xpc3QuYWRkKCdyYmluZGVyLScrYmluZGVyTmFtZSk7DQogICAgICAgICAgICAgICAgICAgICAgICB1c2VkQmxvY2tTZXR0aW5nQXJyYXlJZHMucHVzaChibG9ja19udW1iZXIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXkuc3BsaWNlKGktLSwgMSk7DQogICAgICAgICAgICAgICAgICAgICAgICBwb29sYmFja0kgPSAxOw0KICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgcmVwZWF0ID0gdHJ1ZTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBlbHNlIGlmIChibG9ja1NldHRpbmdBcnJheVtpXVsic2V0dGluZ190eXBlIl0gPT0gNCkgew0KICAgICAgICAgICAgICAgICAgICBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCIjY29udGVudF9wb2ludGVyX2lkIikucGFyZW50RWxlbWVudC5hcHBlbmQoZWxlbWVudFRvQWRkKTsNCiAgICAgICAgICAgICAgICAgICAgdXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzLnB1c2goYmxvY2tfbnVtYmVyKTsNCiAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXkuc3BsaWNlKGktLSwgMSk7DQogICAgICAgICAgICAgICAgICAgIHBvb2xiYWNrSSA9IDE7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGVsc2UgaWYgKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJzZXR0aW5nX3R5cGUiXSA9PSA1KSB7DQogICAgICAgICAgICAgICAgICAgIGxldCBjdXJyZW50RWxlbWVudExpc3QgPSBjdXJlZW50RWxlbWVudHNHYXRoZXIoJ3AnLCAxLCBjb250ZW50X3BvaW50ZXIucGFyZW50RWxlbWVudCk7DQogICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50RWxlbWVudExpc3QmJmN1cnJlbnRFbGVtZW50TGlzdC5sZW5ndGggPiAwKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcENvdW50ID0gY3VycmVudEVsZW1lbnRMaXN0Lmxlbmd0aDsNCiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbGVtZW50TnVtYmVyID0gTWF0aC5yb3VuZChwQ291bnQvMik7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocENvdW50ID4gMSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50ID0gY3VycmVudEVsZW1lbnRMaXN0W2VsZW1lbnROdW1iZXIrMV07DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEVsZW1lbnQgIT0gdW5kZWZpbmVkICYmIGN1cnJlbnRFbGVtZW50ICE9IG51bGwpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocENvdW50ID4gMSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudC5wYXJlbnROb2RlLmluc2VydEJlZm9yZShlbGVtZW50VG9BZGQsIGN1cnJlbnRFbGVtZW50KTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudC5wYXJlbnROb2RlLmluc2VydEJlZm9yZShlbGVtZW50VG9BZGQsIGN1cnJlbnRFbGVtZW50Lm5leHRTaWJsaW5nKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLmNsYXNzTGlzdC5yZW1vdmUoJ2NvdmVyZWRBZCcpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50LmNsYXNzTGlzdC5hZGQoJ3JiaW5kZXItJytiaW5kZXJOYW1lKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VkQmxvY2tTZXR0aW5nQXJyYXlJZHMucHVzaChibG9ja19udW1iZXIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrU2V0dGluZ0FycmF5LnNwbGljZShpLS0sIDEpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvb2xiYWNrSSA9IDE7DQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcGVhdCA9IHRydWU7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXBlYXQgPSB0cnVlOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGVsc2UgaWYgKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJzZXR0aW5nX3R5cGUiXSA9PSA2KSB7DQogICAgICAgICAgICAgICAgICAgIGlmIChjb250YWluZXJGb3I2dGgubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBjb250YWluZXJGb3I2dGgubGVuZ3RoOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29udGFpbmVyRm9yNnRoW2pdWyJlbGVtZW50UGxhY2UiXT5ibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudFBsYWNlIl0pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogY29udGludWU7ICovDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChqID09IGNvbnRhaW5lckZvcjZ0aC5sZW5ndGgtMSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyRm9yNnRoLnB1c2goYmxvY2tTZXR0aW5nQXJyYXlbaV0pOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogdXNlZEFkQmxvY2tzQXJyYXkucHVzaChjaGVja0lmQmxvY2tVc2VkKTsgKi8NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVzZWRCbG9ja1NldHRpbmdBcnJheUlkcy5wdXNoKGJsb2NrX251bWJlcik7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja1NldHRpbmdBcnJheS5zcGxpY2UoaS0tLCAxKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvb2xiYWNrSSA9IDE7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGsgPSBjb250YWluZXJGb3I2dGgubGVuZ3RoLTE7IGsgPiBqLTE7IGstLSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyRm9yNnRoW2sgKyAxXSA9IGNvbnRhaW5lckZvcjZ0aFtrXTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXJGb3I2dGhbal0gPSBibG9ja1NldHRpbmdBcnJheVtpXTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogdXNlZEFkQmxvY2tzQXJyYXkucHVzaChjaGVja0lmQmxvY2tVc2VkKTsgKi8NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzLnB1c2goYmxvY2tfbnVtYmVyKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tTZXR0aW5nQXJyYXkuc3BsaWNlKGktLSwgMSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvb2xiYWNrSSA9IDE7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lckZvcjZ0aC5wdXNoKGJsb2NrU2V0dGluZ0FycmF5W2ldKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIHVzZWRCbG9ja1NldHRpbmdBcnJheUlkcy5wdXNoKGJsb2NrX251bWJlcik7DQogICAgICAgICAgICAgICAgICAgICAgICBibG9ja1NldHRpbmdBcnJheS5zcGxpY2UoaS0tLCAxKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIHBvb2xiYWNrSSA9IDE7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAvKiB2aWRwcmF2dXR1IHYgdmlkc3RpaW51ayBkbHlhIDZobyB0aXBhICovDQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGVsc2UgaWYgKGJsb2NrU2V0dGluZ0FycmF5W2ldWyJzZXR0aW5nX3R5cGUiXSA9PSA3KSB7DQogICAgICAgICAgICAgICAgICAgIGlmIChjb250YWluZXJGb3I3dGgubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBjb250YWluZXJGb3I3dGgubGVuZ3RoOyBqKyspIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29udGFpbmVyRm9yN3RoW2pdWyJlbGVtZW50UGxhY2UiXT5ibG9ja1NldHRpbmdBcnJheVtpXVsiZWxlbWVudFBsYWNlIl0pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogY29udGludWU7ICovDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChqID09IGNvbnRhaW5lckZvcjd0aC5sZW5ndGgtMSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyRm9yN3RoLnB1c2goYmxvY2tTZXR0aW5nQXJyYXlbaV0pOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzLnB1c2goYmxvY2tfbnVtYmVyKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrU2V0dGluZ0FycmF5LnNwbGljZShpLS0sIDEpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgayA9IGNvbnRhaW5lckZvcjd0aC5sZW5ndGgtMTsgayA+IGotMTsgay0tKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXJGb3I3dGhbayArIDFdID0gY29udGFpbmVyRm9yN3RoW2tdOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lckZvcjd0aFtqXSA9IGJsb2NrU2V0dGluZ0FycmF5W2ldOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VkQmxvY2tTZXR0aW5nQXJyYXlJZHMucHVzaChibG9ja19udW1iZXIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja1NldHRpbmdBcnJheS5zcGxpY2UoaS0tLCAxKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyRm9yN3RoLnB1c2goYmxvY2tTZXR0aW5nQXJyYXlbaV0pOw0KICAgICAgICAgICAgICAgICAgICAgICAgdXNlZEJsb2NrU2V0dGluZ0FycmF5SWRzLnB1c2goYmxvY2tfbnVtYmVyKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGJsb2NrU2V0dGluZ0FycmF5LnNwbGljZShpLS0sIDEpOw0KICAgICAgICAgICAgICAgICAgICAgICAgcG9vbGJhY2tJID0gMTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIC8qIHZpZHByYXZ1dHUgdiB2aWRzdGlpbnVrIGRseWEgN2hvIHRpcGEgKi8NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9IGNhdGNoIChlKSB7DQogICAgICAgICAgICAgICAgY29uc29sZS5sb2coZS5tZXNzYWdlKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KDQogICAgICAgIHZhciBhcnJheSA9IHRleHRMZW5ndGhHYXRoZXJlcihsb3JkT2ZFbGVtZW50cyksDQogICAgICAgICAgICB0bEFycmF5ID0gYXJyYXkuYXJyYXksDQogICAgICAgICAgICBsZW5ndGggPSBhcnJheS5sZW5ndGg7DQoNCiAgICAgICAgaWYgKGNvbnRhaW5lckZvcjZ0aC5sZW5ndGggPiAwKSB7DQogICAgICAgICAgICBwZXJjZW50SW5zZXJ0ZXIobG9yZE9mRWxlbWVudHMsIGNvbnRhaW5lckZvcjZ0aCwgdGxBcnJheSwgbGVuZ3RoKTsNCiAgICAgICAgfQ0KICAgICAgICBpZiAoY29udGFpbmVyRm9yN3RoLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgIHN5bWJvbEluc2VydGVyKGxvcmRPZkVsZW1lbnRzLCBjb250YWluZXJGb3I3dGgsIHRsQXJyYXkpOw0KICAgICAgICB9DQogICAgICAgIHNob3J0Y29kZXNJbnNlcnQoKTsNCiAgICAgICAgbGV0IHN0b3BwZXIgPSAwOw0KDQogICAgICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCdsb2FkJywgZnVuY3Rpb24gKCkgew0KICAgICAgICAgICAgaWYgKHJlcGVhdCA9IHRydWUpIHsNCiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsNCiAgICAgICAgICAgICAgICAgICAgLyogYXN5bmNCbG9ja3NJbnNlcnRpbmdGdW5jdGlvbihibG9ja1NldHRpbmdBcnJheSwgY29udGVudExlbmd0aCkgKi8NCiAgICAgICAgICAgICAgICAgICAgYXN5bmNCbG9ja3NJbnNlcnRpbmdGdW5jdGlvbihibG9ja1NldHRpbmdBcnJheSk7DQogICAgICAgICAgICAgICAgfSwgMTAwKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfSBjYXRjaCAoZSkgew0KICAgICAgICBjb25zb2xlLmxvZyhlLm1lc3NhZ2UpOw0KICAgIH0NCn0NCg0KZnVuY3Rpb24gcG9zc2libGVUYWdzSW5DaGVja0NvbmZpcm1lcihwb3NzaWJsZVRh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LA0KICAgICAgICB0ZXh0TGVuZ3RoID0gMCwNCiAgICAgICAgdGxBcnJheSA9IFtdOw0KDQogICAgZnVuY3Rpb24gdGV4dExlbmd0aEdhdGhlcmVyUmVjKGxvcmRPZkVsZW1lbnRzTG9jKSB7DQogICAgICAgIGxldCBhbGxvd2VkOw0KICAgICAgICBsZXQgY291MTsNCiAgICAgICAgbGV0IGNsYXNzZXNBcnJheTsNCiAgICAgICAgbGV0IGNvdW50U3VjY2VzcyA9IDA7DQogICAgICAgIHRyeSB7DQogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxvcmRPZkVsZW1lbnRzTG9jLmNoaWxkcmVuLmxlbmd0aDsgaSsrKSB7DQogICAgICAgICAgICAgICAgaWYgKHBvc3NpYmxlVGFnc0FycmF5LmluY2x1ZGVzKGxvcmRPZkVsZW1lbnRzTG9jLmNoaWxkcmVuW2ldLnRhZ05hbWUpDQogICAgICAgICAgICAgICAgICAgICYmIWxvcmRPZkVsZW1lbnRzTG9jLmNoaWxkcmVuW2ldLmNsYXNzTGlzdC5jb250YWlucygicGVyY2VudFBvaW50ZXJDbGFzcyIpDQogICAgICAgICAgICAgICAgICAgICYmbG9yZE9mRWxlbWVudHNMb2MuY2hpbGRyZW5baV0uaWQhPSJ0b2NfY29udGFpbmVyIg0KICAgICAgICAgICAgICAgICkgew0KICAgICAgICAgICAgICAgICAgICBpZiAocG9zc2libGVUYWdzSW5DaGVjay5pbmNsdWRlcyhsb3JkT2ZFbGVtZW50c0xvYy5jaGlsZHJlbltpXS50YWdOYW1lKQ0KICAgICAgICAgICAgICAgICAgICAgICAgJiYobG9yZE9mRWxlbWVudHNMb2MuY2hpbGRyZW5baV0uY2hpbGRyZW4ubGVuZ3RoID4gMCkNCiAgICAgICAgICAgICAgICAgICAgKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBhbGxvd2VkID0gdHJ1ZTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsb3JkT2ZFbGVtZW50c0xvYy5jaGlsZHJlbltpXS5pZCYmZXhjQXJyWydpZCddLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb3UxID0gMDsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZXhjQXJyWydpZCddW2NvdTFdKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsb3JkT2ZFbGVtZW50c0xvYy5jaGlsZHJlbltpXS5pZC50b0xvd2VyQ2FzZSgpPT1leGNBcnJbJ2lkJ11bY291MV0udG9Mb3dlckNhc2UoKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dlZCA9IGZhbHNlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY291MSsrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxvcmRPZkVsZW1lbnRzTG9jLmNoaWxkcmVuW2ldLmNsYXNzTGlzdC5sZW5ndGggPiAwJiZleGNBcnJbJ2NsYXNzJ10ubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvdTEgPSAwOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChleGNBcnJbJ2NsYXNzJ11bY291MV0pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhc3Nlc0FycmF5ID0gZXhjQXJyWydjbGFzcyddW2NvdTFdLnNwbGl0KCcuJyk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjbGFzc2VzQXJyYXkuZXZlcnkoY2xhc3NOYW1lID0+IGxvcmRPZkVsZW1lbnRzTG9jLmNoaWxkcmVuW2ldLmNsYXNzTGlzdC5jb250YWlucyhjbGFzc05hbWUpKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dlZCA9IGZhbHNlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY291MSsrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV4Y0FyclsndGFnJ10ubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvdTEgPSAwOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChleGNBcnJbJ3RhZyddW2NvdTFdKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsb3JkT2ZFbGVtZW50c0xvYy5jaGlsZHJlbltpXS50YWdOYW1lLnRvTG93ZXJDYXNlKCk9PWV4Y0FyclsndGFnJ11bY291MV0udG9Mb3dlckNhc2UoKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dlZCA9IGZhbHNlOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY291MSsrOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFsbG93ZWQpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGV4dExlbmd0aEdhdGhlcmVyUmVjKGxvcmRPZkVsZW1lbnRzTG9jLmNoaWxkcmVuW2ldLCBleGNBcnIsIHBvc3NpYmxlVGFnc0FycmF5LCBwb3NzaWJsZVRhZ3NJbkNoZWNrKSkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb3VudFN1Y2Nlc3MrKzsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIHRleHRMZW5ndGggPSB0ZXh0TGVuZ3RoICsgbG9yZE9mRWxlbWVudHNMb2MuY2hpbGRyZW5baV0uaW5uZXJUZXh0Lmxlbmd0aDsNCiAgICAgICAgICAgICAgICAgICAgdGxBcnJheS5wdXNoKHsNCiAgICAgICAgICAgICAgICAgICAgICAgIHRhZzogbG9yZE9mRWxlbWVudHNMb2MuY2hpbGRyZW5baV0udGFnTmFtZSwNCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbmd0aDogbG9yZE9mRWxlbWVudHNMb2MuY2hpbGRyZW5baV0uaW5uZXJUZXh0Lmxlbmd0aCwNCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbmd0aFN1bTogdGV4dExlbmd0aCwNCiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQ6IGxvcmRPZkVsZW1lbnRzTG9jLmNoaWxkcmVuW2ldDQogICAgICAgICAgICAgICAgICAgIH0pOw0KICAgICAgICAgICAgICAgICAgICBjb3VudFN1Y2Nlc3MrKzsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9DQogICAgICAgIH0gY2F0Y2ggKGVyKSB7DQogICAgICAgICAgICBjb25zb2xlLmxvZyhlci5tZXNzYWdlKTsNCiAgICAgICAgfQ0KICAgICAgICByZXR1cm4gY291bnRTdWNjZXNzID4gMDsNCiAgICB9DQoNCiAgICB0ZXh0TGVuZ3RoR2F0aGVyZXJSZWMobG9yZE9mRWxlbWVudHNMb2MpOw0KDQog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NoID0gMDsNCiAgICBpZiAoaW5zZXJ0aW5nc0FycmF5JiZpbnNlcnRpbmdzQXJyYXkubGVuZ3RoID4gMCkgew0KICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGluc2VydGluZ3NBcnJheS5sZW5ndGg7IGkrKykgew0KICAgICAgICAgICAgaWYgKCFpbnNlcnRpbmdzQXJyYXlbaV1bJ3VzZWQnXXx8KGluc2VydGluZ3NBcnJheVtpXVsndXNlZCddJiZpbnNlcnRpbmdzQXJyYXlbaV1bJ3VzZWQnXT09MCkpIHsNCiAgICAgICAgICAgICAgICBwb3NpdGlvbkVsZW1lbnQgPSBpbnNlcnRpbmdzQXJyYXlbaV1bJ3Bvc2l0aW9uX2VsZW1lbnQnXTsNCiAgICAgICAgICAgICAgICBwb3NpdGlvbiA9IGluc2VydGluZ3NBcnJheVtpXVsncG9zaXRpb24nXTsNCiAgICAgICAgICAgICAgICBpbnNlcnRUb0FkZCA9IGluc2VydGluZ3NBcnJheVtpXVsnY29udGVudCddOw0KICAgICAgICAgICAgICAgIHBvc3RJZCA9IGluc2VydGluZ3NBcnJheVtpXVsncG9zdElkJ107DQoNCiAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudEZvckluc2VydGluZyA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IocG9zaXRpb25FbGVtZW50KTsNCg0KICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50VG9Nb3ZlID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcignLmNvdmVyZWRJbnNlcnRpbmdzW2RhdGEtaWQ9IicrcG9zdElkKyciXScpOw0KICAgICAgICAgICAgICAgIGlmIChjdXJyZW50RWxlbWVudEZvckluc2VydGluZykgew0KICAgICAgICAgICAgICAgICAgICBpZiAocG9zaXRpb249PTApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50Rm9ySW5zZXJ0aW5nLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKGN1cnJlbnRFbGVtZW50VG9Nb3ZlLCBjdXJyZW50RWxlbWVudEZvckluc2VydGluZyk7DQogICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50RWxlbWVudFRvTW92ZS5jbGFzc0xpc3QucmVtb3ZlKCdjb3ZlcmVkSW5zZXJ0aW5ncycpOw0KICAgICAgICAgICAgICAgICAgICAgICAgaW5zZXJ0aW5nc0FycmF5W2ldWyd1c2VkJ10gPSAxOw0KICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEVsZW1lbnRGb3JJbnNlcnRpbmcucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUoY3VycmVudEVsZW1lbnRUb01vdmUsIGN1cnJlbnRFbGVtZW50Rm9ySW5zZXJ0aW5nLm5leHRTaWJsaW5nKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRFbGVtZW50VG9Nb3ZlLmNsYXNzTGlzdC5yZW1vdmUoJ2NvdmVyZWRJbnNlcnRpbmdzJyk7DQogICAgICAgICAgICAgICAgICAgICAgICBpbnNlcnRpbmdzQXJyYXlbaV1bJ3VzZWQnXSA9IDE7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICByZXBlYXRTZWFyY2ggPSAxOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KICAgIH0NCiAgICBpZiAocmVwZWF0U2VhcmNoID09IDEpIHsNCiAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7DQogICAgICAgICAgICBhc3luY0luc2VydGluZ3NJbnNlcnRpbmdGdW5jdGlvbihpbnNlcnRpbmdzQXJyYXkpOw0KICAgICAgICB9LCAxMDApDQogICAgfQ0KfQ0KDQpmdW5jdGlvbiBpbnNlcnRpbmdzRnVuY3Rpb25MYXVuY2goKSB7DQogICAgaWYgKHdpbmR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pb24gc3ltYm9sSW5zZXJ0ZXIobG9yZE9mRWxlbWVudHMsIGNvbnRhaW5lckZvcjd0aCwgdGxBcnJheSkgew0KICAgIHRyeSB7DQogICAgICAgIHZhciBjdXJyZW50Q2hpbGRyZW5MZW5ndGggPSAwOw0KICAgICAgICBsZXQgcHJldmlvdXNCcmVhayA9IDA7DQogICAgICAgIGxldCBuZWVkbGVMZW5ndGg7DQogICAgICAgIGxldCBjdXJyZW50U3VtTGVuZ3RoOw0KICAgICAgICBsZXQgZWxlbWVudFRvQWRkOw0KICAgICAgICBsZXQgZWxlbWVudFRvQmluZDsNCiAgICAgICAgbGV0IGVsZW1lbnRUb0FkZFN0eWxlOw0KICAgICAgICBsZXQgYmxvY2tfbnVtYmVyOw0KICAgICAgICBsZXQgYmluZGVyTmFtZTsNCg0KICAgICAgICBpZiAoIWRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJtYXJrZWRTcGFuMSIpKSB7DQogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvbnRhaW5lckZvcjd0aC5sZW5ndGg7IGkrKykgew0KICAgICAgICAgICAgICAgIHByZXZpb3VzQnJlYWsgPSAwOw0KICAgICAgICAgICAgICAgIGN1cnJlbnRDaGlsZHJlbkxlbmd0aCA9IDA7DQogICAgICAgICAgICAgICAgY3VycmVudFN1bUxlbmd0aCA9IDA7DQogICAgICAgICAgICAgICAgbmVlZGxlTGVuZ3RoID0gTWF0aC5hYnMoY29udGFpbmVyRm9yN3RoW2ldWydlbGVtZW50UGxhY2UnXSk7DQogICAgICAgICAgICAgICAgYmluZGVyTmFtZSA9IGVsZW1lbnRCaW5kZXJOYW1lR2VuZXJhdG9yKCk7DQoNCiAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsNCiAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuY2xhc3NMaXN0LmFkZCgicGVyY2VudFBvaW50ZXJDbGFzcyIpOw0KICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5jbGFzc0xpc3QuYWRkKCJtYXJrZWQiKTsNCiAgICAgICAgICAgICAgICBpZiAoY29udGFpbmVyRm9yN3RoW2ldWyJzYyJdPT0xKSB7DQogICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5jbGFzc0xpc3QuYWRkKCJzY01hcmsiKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLmRhdGFzZXQucmJpbmRlciA9IGJpbmRlck5hbWU7DQogICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLmlubmVySFRNTCA9IGNvbnRhaW5lckZvcjd0aFtpXVsidGV4dCJdOw0KICAgICAgICAgICAgICAgIGJsb2NrX251bWJlciA9IGVsZW1lbnRUb0FkZC5jaGlsZHJlblswXS5hdHRyaWJ1dGVzWydkYXRhLWlkJ10udmFsdWU7DQogICAgICAgICAgICAgICAgaWYgKCFlbGVtZW50VG9BZGQpIHsNCiAgICAgICAgICAgICAgICAgICAgY29udGludWU7DQogICAgICAgICAgICAgICAgfQ0KDQogICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkU3R5bGUgPSBjcmVhdGVTdHlsZUVsZW1lbnQoYmxvY2tfbnVtYmVyLCBjb250YWluZXJGb3I3dGhbaV1bImVsZW1lbnRDc3MiXSk7DQoNCiAgICAgICAgICAgICAgICBpZiAoZWxlbWVudFRvQWRkU3R5bGUmJmVsZW1lbnRUb0FkZFN0eWxlIT0nZGVmYXVsdCcpIHsNCiAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLnN0eWxlLnRleHRBbGlnbiA9IGVsZW1lbnRUb0FkZFN0eWxlOw0KICAgICAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAgIGlmIChjb250YWluZXJGb3I3dGhbaV1bJ2VsZW1lbnRQbGFjZSddIDwgMCkgew0KICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gdGxBcnJheS5sZW5ndGgtMTsgaiA+IC0xOyBqLS0pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRTdW1MZW5ndGggPSBjdXJyZW50U3VtTGVuZ3RoICsgdGxBcnJheVtqXVsnbGVuZ3RoJ107DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAobmVlZGxlTGVuZ3RoIDwgY3VycmVudFN1bUxlbmd0aCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0JpbmQgPSB0bEFycmF5W2pdWydlbGVtZW50J107DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQmluZCA9IGN1cnJlbnRFbGVtZW50UmVjZWl2ZXJTcGVjKHRydWUsIGosIHRsQXJyYXksIGVsZW1lbnRUb0JpbmQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0JpbmQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUoZWxlbWVudFRvQWRkLCBlbGVtZW50VG9CaW5kKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9CaW5kLmNsYXNzTGlzdC5hZGQoJ3JiaW5kZXItJytiaW5kZXJOYW1lKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuY2xhc3NMaXN0LnJlbW92ZSgnY292ZXJlZEFkJyk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNvbnRhaW5lckZvcjd0aFtpXVsnZWxlbWVudFBsYWNlJ10gPT0gMCkgew0KICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9CaW5kID0gdGxBcnJheVswXVsnZWxlbWVudCddOw0KICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9CaW5kLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKGVsZW1lbnRUb0FkZCwgZWxlbWVudFRvQmluZCk7DQogICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0JpbmQuY2xhc3NMaXN0LmFkZCgncmJpbmRlci0nK2JpbmRlck5hbWUpOw0KICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuY2xhc3NMaXN0LnJlbW92ZSgnY292ZXJlZEFkJyk7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB0bEFycmF5Lmxlbmd0aDsgaisrKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50U3VtTGVuZ3RoID0gY3VycmVudFN1bUxlbmd0aCArIHRsQXJyYXlbal1bJ2xlbmd0aCddOw0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5lZWRsZUxlbmd0aCA8IGN1cnJlbnRTdW1MZW5ndGgpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9CaW5kID0gdGxBcnJheVtqXVsnZWxlbWVudCddOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0JpbmQgPSBjdXJyZW50RWxlbWVudFJlY2VpdmVyU3BlYyhmYWxzZSwgaiwgdGxBcnJheSwgZWxlbWVudFRvQmluZCk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQmluZC5wYXJlbnROb2RlLmluc2VydEJlZm9yZShlbGVtZW50VG9BZGQsIGVsZW1lbnRUb0JpbmQubmV4dFNpYmxpbmcpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0JpbmQuY2xhc3NMaXN0LmFkZCgncmJpbmRlci0nK2JpbmRlck5hbWUpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5jbGFzc0xpc3QucmVtb3ZlKCdjb3ZlcmVkQWQnKTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCg0KICAgICAgICAgICAgdmFyIHNwYW5NYXJrZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7DQogICAgICAgICAgICBzcGFuTWFya2VyLnNldEF0dHJpYnV0ZSgiaWQiLCAibWFya2VkU3BhbjEiKTsNCiAgICAgICAgICAgIGxvcmRPZkVsZW1lbnRzLnByZXBlbmQoc3Bhbk1hcmtlcik7DQogICAgICAgIH0NCiAgICB9IGNhdGNoIChlKSB7DQogICAgICAgIGNvbnNvbGUubG9nKGUpOw0KICAgIH0NCn0NCg0KZnVuY3Rpb24gcGVyY2VudEluc2VydGVyKGxvcmRPZkVsZW1lbnRzLCBjb250YWluZXJGb3I2dGgsIHRsQXJyYXksIHRleHRMZW5ndGgpIHsNCiAgICB0cnkgew0KICAgICAgICB2YXIgdGV4dE5lZWR5TGVuZ3RoID0gMDsNCiAgICAgICAgbGV0IGVsZW1lbnRUb0FkZDsNCiAgICAgICAgdmFyIGVsZW1lbnRUb0JpbmQ7DQogICAgICAgIGxldCBlbGVtZW50VG9BZGRTdHlsZTsNCiAgICAgICAgbGV0IGJsb2NrX251bWJlcjsNCiAgICAgICAgdmFyIGJpbmRlck5hbWU7DQogICAgICAgIC8qIHZhciBjaGVja0lmQmxvY2tVc2VkID0gMDsgKi8NCg0KICAgICAgICBmdW5jdGlvbiBpbnNlcnRCeVBlcmNlbnRzKHRleHRMZW5ndGgpIHsNCiAgICAgICAgICAgIGxldCBsb2NhbE1pZGRsZVZhbHVlID0gMDsNCg0KICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBjb250YWluZXJGb3I2dGgubGVuZ3RoOyBqKyspIHsNCiAgICAgICAgICAgICAgICB0ZXh0TmVlZHlMZW5ndGggPSBNYXRoLnJvdW5kKHRleHRMZW5ndGggKiAoY29udGFpbmVyRm9yNnRoW2pdWyJlbGVtZW50UGxhY2UiXS8xMDApKTsNCiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRsQXJyYXkubGVuZ3RoOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgaWYgKHRsQXJyYXlbaV1bJ2xlbmd0aFN1bSddID49IHRleHROZWVkeUxlbmd0aCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgYmluZGVyTmFtZSA9IGVsZW1lbnRCaW5kZXJOYW1lR2VuZXJhdG9yKCk7DQoNCiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOw0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLmNsYXNzTGlzdC5hZGQoInBlcmNlbnRQb2ludGVyQ2xhc3MiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5jbGFzc0xpc3QuYWRkKCJtYXJrZWQiKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb250YWluZXJGb3I2dGhbal1bInNjIl09PTEpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuY2xhc3NMaXN0LmFkZCgic2NNYXJrIik7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuZGF0YXNldC5yYmluZGVyID0gYmluZGVyTmFtZTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0FkZC5pbm5lckhUTUwgPSBjb250YWluZXJGb3I2dGhbal1bInRleHQiXTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWxlbWVudFRvQWRkKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICBibG9ja19udW1iZXIgPSBlbGVtZW50VG9BZGQuY2hpbGRyZW5bMF0uYXR0cmlidXRlc1snZGF0YS1pZCddLnZhbHVlOw0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkU3R5bGUgPSBjcmVhdGVTdHlsZUVsZW1lbnQoYmxvY2tfbnVtYmVyLCBjb250YWluZXJGb3I2dGhbal1bImVsZW1lbnRDc3MiXSk7DQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudFRvQWRkU3R5bGUmJmVsZW1lbnRUb0FkZFN0eWxlIT0nZGVmYXVsdCcpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9BZGQuc3R5bGUudGV4dEFsaWduID0gZWxlbWVudFRvQWRkU3R5bGU7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQoNCiAgICAgICAgICAgICAgICAgICAgICAgIGxvY2FsTWlkZGxlVmFsdWUgPSB0bEFycmF5W2ldWydsZW5ndGhTdW0nXSAtIE1hdGgucm91bmQodGxBcnJheVtpXVsnbGVuZ3RoJ10vMik7DQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9CaW5kID0gdGxBcnJheVtpXVsnZWxlbWVudCddOw0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEVsZW1lbnRSZWNlaXZlclNwZWMoZmFsc2UsIGksIHRsQXJyYXksIGVsZW1lbnRUb0JpbmQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRleHROZWVkeUxlbmd0aCA8IGxvY2FsTWlkZGxlVmFsdWUpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50VG9CaW5kLnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKGVsZW1lbnRUb0FkZCwgZWxlbWVudFRvQmluZCk7DQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0JpbmQucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUoZWxlbWVudFRvQWRkLCBlbGVtZW50VG9CaW5kLm5leHRTaWJsaW5nKTsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRUb0JpbmQuY2xhc3NMaXN0LmFkZCgncmJpbmRlci0nK2JpbmRlck5hbWUpOw0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFRvQWRkLmNsYXNzTGlzdC5yZW1vdmUoJ2NvdmVyZWRBZCcpOw0KICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9DQogICAgICAgICAgICByZXR1cm4gZmFsc2U7DQogICAgICAgIH0NCg0KICAgICAgICBmdW5jdGlvbiBjbGVhclRsTWFya3MoKSB7DQogICAgICAgICAgICBsZXQgbWFya3NGb3JEZWxldGluZyA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoJy50ZXh0TGVuZ3RoTWFya2VyJyk7DQoNCiAgICAgICAgICAgIGlmIChtYXJrc0ZvckRlbGV0aW5nLmxlbmd0aCA+IDApIHsNCiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG1hcmtzRm9yRGVsZXRpbmcubGVuZ3RoOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgbWFya3NGb3JEZWxldGluZ1tpXS5yZW1vdmUoKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9DQogICAgICAgIH0NCg0KICAgICAgICBpZiAoIWRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJtYXJrZWRTcGFuIikpIHsNCiAgICAgICAgICAgIGluc2VydEJ5UGVyY2VudHModGV4dExlbmd0aCk7DQogICAgICAgICAgICBjbGVhclRsTWFya3MoKTsNCiAgICAgICAgICAgIHZhciBzcGFuTWFya2VyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOw0KICAgICAgICAgICAgc3Bhbk1hcmtlci5zZXRBdHRyaWJ1dGUoImlkIiwgIm1hcmtlZFNwYW4iKTsNCiAgICAgICAgICAgIGxvcmRPZkVsZW1lbnRzLnByZXBlbmQoc3Bhbk1hcmtlcik7DQogICAgICAgIH0NCiAgICB9IGNhdGNoIChlKSB7DQogICAgICAgIGNvbnNvbGUubG9nKGUubWVzc2FnZSk7DQogICAgfQ0KfQ0KDQpmdW5jdGlvbiBzYXZlQ29udGVudEJsb2NrKGNvbnRlbnRDb250YWluZXIpIHsNCiAgICB0cnkgew0KICAgICAgICBpZiAoIWdhdGhlcl9jb250ZW50KSB7DQogICAgICAgICAgICBjb25zb2xlLmxvZygnY29udGVudCBnYXRoZXIgc2F2ZSBmdW5jdGlvbiBlbnRlcmVkJyk7DQogICAgICAgICAgICBsZXQgeGh0dHAgPSBuZXcgWE1MSHR0cFJlcXVlc3QoKTsNCiAgICAgICAgICAgIGxldCBzZW5kRGF0YSA9ICdhY3Rpb249UkZXUF9zYXZlQ29udGVudENvbnRhaW5lciZ0eXBlPWdhdGhlckNvbnRlbnRCbG9jayZkYXRhPScrY29udGVudENvbnRhaW5lcjsNCiAgICAgICAgICAgIHhodHRwLm9ucmVhZHlzdGF0ZWNoYW5nZSA9IGZ1bmN0aW9uKHJlZGF0YSkgew0KICAgICAgICAgICAgICAgIGlmICh0aGlzLnJlYWR5U3RhdGUgPT0gNCAmJiB0aGlzLnN0YXR1cyA9PSAyMDApIHsNCiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ2NvbnRlbnQgZ2F0aGVyIHN1Y2NlZWQnKTsNCiAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnY29udGVudCBnYXRoZXIgZ29uZSB3cm9uZycpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH07DQogICAgICAgICAgICB4aHR0cC5vcGVuKCJQT1NUIiwgcmJfYWpheHVybCwgdHJ1ZSk7DQogICAgICAgICAgICB4aHR0cC5zZXRSZXF1ZXN0SGVhZGVyKCJDb250ZW50LXR5cGUiLCAiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkIik7DQogICAgICAgICAgICB4aHR0cC5zZW5kKHNlbmREYXRhKTsNCiAgICAgICAgfQ0KICAgIH0gY2F0Y2ggKGVyKSB7DQogICAgICAgIGNvbnNvbGUubG9nKCdjb250ZW50IGdhdGhlciBlcnJvcjogJytlcisnOycpOw0KICAgIH0NCn0NCg0Kd2luZG93LmdhdGhlckNvbnRlbnRCbG9jayA9IGZ1bmN0aW9uKCkgew0KICAgIGxldCBjUG9pbnRlciA9IG51bGwsDQogICAgICAgIGNQb2ludGVyUGFyZW50ID0gbnVsbCwNCiAgICAgICAgY1BvaW50ZXJQYXJlbnRTdHJpbmcgPSBudWxsLA0KICAgICAgICBjbGFzc1dvcmRzID0gWydjb250ZW50JywnZW50cnknLCdwb3N0Jywnd3JhcCcsJ2Rlc2NyaXB0aW9uJywndGF4b25vbXknXSwNCiAgICAgICAgY2xhc3NDaG9vc2VkID0gZmFsc2U7DQoNCiAgICBjUG9pbnRlciA9ICBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCcjY29udGVudF9wb2ludGVyX2lkJyk7DQogICAgaWYgKGNQb2ludGVyKSB7DQogICAgICAgIGlmICh3aW5kb3cuanNJbnB1dGVyTGF1bmNoIT09MTUpIHsNCiAgICAgICAgICAgIHJldHVybiBmYWxzZTsNCiAgICAgICAgfQ0KICAgICAgICBjUG9pbnRlclBhcmVudCA9IGNQb2ludGVyLnBhcmVudEVsZW1lbnQ7DQogICAgICAgIGlmIChjUG9pbnRlclBhcmVudCkgew0KICAgICAgICAgICAgaWYgKGNQb2ludGVyUGFyZW50LmlkKSB7DQogICAgICAgICAgICAgICAgY1BvaW50ZXJQYXJlbnRTdHJpbmcgPSAnIycrY1BvaW50ZXJQYXJlbnQuaWQ7DQogICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgIGlmIChjUG9pbnRlclBhcmVudC5jbGFzc0xpc3QubGVuZ3RoID4gMCkgew0KICAgICAgICAgICAgICAgICAgICBjUG9pbnRlclBhcmVudFN0cmluZyA9ICcuJytjUG9pbnRlclBhcmVudC5jbGFzc0xpc3RbMF07DQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY2xhc3NXb3Jkcy5sZW5ndGg7IGorKykgew0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjUG9pbnRlclBhcmVudC5jbGFzc0xpc3QubGVuZ3RoOyBpKyspIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY1BvaW50ZXJQYXJlbnQuY2xhc3NMaXN0W2ldLmluY2x1ZGVzKGNsYXNzV29yZHNbal0pKSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNQb2ludGVyUGFyZW50U3RyaW5nID0gJy4nK2NQb2ludGVyUGFyZW50LmNsYXNzTGlzdFtpXTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xhc3NDaG9vc2VkID0gdHJ1ZTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNsYXNzQ2hvb3NlZD09PXRydWUpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGlmIChjUG9pbnRlclBhcmVudFN0cmluZykgew0KICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdjb250ZW50IGdhdGhlciBjb250ZW50IGJsb2NrIGRldGVjdGVkJyk7DQogICAgICAgICAgICAgICAgLyogY1BvaW50ZXJQYXJlbnRTdHJpbmcgPSBKU09OLnN0cmluZ2lmeShjUG9pbnRlclBhcmVudFN0cmluZyk7ICovDQogICAgICAgICAgICAgICAgc2F2ZUNvbnRlbnRCbG9jayhjUG9pbnRlclBhcmVudFN0cmluZyk7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICB9IGVsc2Ugew0KICAgICAgICBjb25zb2xlLmxvZygnY29udGVudCBnYXRoZXIgZGVsYXllZCcpOw0KICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsNCiAgICAgICAgICAgIGdhdGhlckNvbnRlbnRCbG9jaygpOw0KICAgICAgICB9LCA1MDApOw0KICAgIH0NCn07DQoNCndpbmRvdy5yZW1vdmVNYXJnaW5DbGFzcyA9IGZ1bmN0aW9uKGJsb2NrT2JqZWN0KSB7DQogICAgaWYgKGJsb2NrT2JqZWN0ICYmIHR5cGVvZiB3aW5kb3cuanNJbnB1dGVyTGF1bmNoICE9PSAndW5kZWZpbmVkJyAmJiBbMTUsIDEwXS5pbmNsdWRlcyh3aW5kb3cuanNJbnB1dGVyTGF1bmNoKSkgew0KICAgICAgICBsZXQgYmluZGVyTmFtZSwNCiAgICAgICAgICAgIG5lZWRlZEVsZW1lbnQsDQogICAgICAgICAgICBjdXJyZW50RGlyZWN0aW9uLA0KICAgICAgICAgICAgc2Vla2VySXRlcmF0aW9uQ291bnQsDQogICAgICAgICAgICBjdXJyZW50U3VibGluZzsNCg0KICAgICAgICBiaW5kZXJOYW1lID0gYmxvY2tPYmplY3QuZGF0YXNldC5yYmluZGVyOw0KICAgICAgICBpZiAoYmluZGVyTmFtZSkgew0KICAgICAgICAgICAgc2Vla2VySXRlcmF0aW9uQ291bnQgPSAwOw0KICAgICAgICAgICAgY3VycmVudERpcmVjdGlvbiA9ICdiZWZvcmUnOw0KICAgICAgICAgICAgZG8gew0KICAgICAgICAgICAgICAgIHNlZWtlckl0ZXJhdGlvbkNvdW50Kys7DQogICAgICAgICAgICAgICAgY3VycmVudFN1YmxpbmcgPSBibG9ja09iamVjdC5uZXh0RWxlbWVudFNpYmxpbmc7DQogICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRTdWJsaW5nJiZjdXJyZW50U3VibGluZy5jbGFzc0xpc3QuY29udGFpbnMoJ3JiaW5kZXItJytiaW5kZXJOYW1lKSkgew0KICAgICAgICAgICAgICAgICAgICBuZWVkZWRFbGVtZW50ID0gY3VycmVudFN1Ymxpbmc7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfSB3aGlsZSAoY3VycmVudFN1YmxpbmcmJiFuZWVkZWRFbGVtZW50JiZzZWVrZXJJdGVyYXRpb25Db3VudCA8IDUpOw0KDQogICAgICAgICAgICBpZiAoIW5lZWRlZEVsZW1lbnQpIHsNCiAgICAgICAgICAgICAgICBzZWVrZXJJdGVyYXRpb25Db3VudCA9IDA7DQogICAgICAgICAgICAgICAgY3VycmVudERpcmVjdGlvbiA9ICdhZnRlcic7DQogICAgICAgICAgICAgICAgZG8gew0KICAgICAgICAgICAgICAgICAgICBzZWVrZXJJdGVyYXRpb25Db3VudCsrOw0KICAgICAgICAgICAgICAgICAgICBjdXJyZW50U3VibGluZyA9IGJsb2NrT2JqZWN0LnByZXZpb3VzRWxlbWVudFNpYmxpbmc7DQogICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50U3VibGluZyYmY3VycmVudFN1YmxpbmcuY2xhc3NMaXN0LmNvbnRhaW5zKCdyYmluZGVyLScrYmluZGVyTmFtZSkpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRlZEVsZW1lbnQgPSBjdXJyZW50U3VibGluZzsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0gd2hpbGUgKGN1cnJlbnRTdWJsaW5nJiYhbmVlZGVkRWxlbWVudCYmc2Vla2VySXRlcmF0aW9uQ291bnQgPCA1KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGlmIChuZWVkZWRFbGVtZW50KSB7DQogICAgICAgICAgICAgICAgaWYgKGN1cnJlbnREaXJlY3Rpb24gPT09ICdiZWZvcmUnKSB7DQogICAgICAgICAgICAgICAgICAgIG5lZWRlZEVsZW1lbnQuY2xhc3NMaXN0LnJlbW92ZSgncmZ3cF9yZW1vdmVkTWFyZ2luVG9wJyk7DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgbmVlZGVkRWxlbWVudC5jbGFzc0xpc3QucmVtb3ZlKCdyZndwX3JlbW92ZWRNYXJnaW5Cb3R0b20nKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICB9DQoNCiAgICByZXR1cm4gZmFsc2U7DQp9Ow0KDQpmdW5jdGlvbiBlbGVtZW50QmluZGVyTmFtZUdlbmVyYXRvcigpIHsNCiAgICBsZXQgYmluZGVyTmFtZSA9ICcnLA0KICAgICAgICBjaGVja2VkRWxlbWVudHMsDQogICAgICAgIHBhc3NlZCA9IGZhbHNlOw0KDQogICAgd2hpbGUgKHBhc3NlZD09PWZhbHNlKSB7DQogICAgICAgIGJpbmRlck5hbWUgPSBNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkqMTAwMDAwKTsNCiAgICAgICAgY2hlY2tlZEVsZW1lbnRzID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvckFsbCgnW2RhdGEtcmJpbmRlcj0iJytiaW5kZXJOYW1lKyciXScpOw0KICAgICAgICBpZiAoY2hlY2tlZEVsZW1lbnRzLmxlbmd0aCA8IDEpIHsNCiAgICAgICAgICAgIHBhc3NlZCA9IHRydWU7DQogICAgICAgIH0NCiAgICB9DQoNCiAgICByZXR1cm4gYmluZGVyTmFtZTsNCn0K |
data:text/javascript;base64,DQogICAgICAgICAgIChmdW5jdGlvbiAoZCwgdywgYykgew0KICAgICAgICAgICAgKHdbY10gPSB3W2NdIHx8IFtdKS5wdXNoKGZ1bmN0aW9uKCkgew0KICAgICAgICAgICAgIHRyeSB7DQogICAgICAgICAgICAgIG5ldyBDcmVkaXRodWJXaWRnZXRGb3JtLmluaXQoew0KICAgICAgICAgICAgICAgY29sb3I6ICdibHVlJywNCiAgICAgICAgICAgICAgIGlkOiAiNjI4OWUzMDAtN2RjMi0xMWViLWE0Y2MtNzUyOTEwYWM1NmNjIiwNCiAgICAgICAgICAgICAgIGNwYUxpbms6ICJodHRwczovL2FwaS5sZWFkY3JhZnQucnUvY2xpY2tzLzYyODllMzAwLTdkYzItMTFlYi1hNGNjLTc1MjkxMGFjNTZjYyIsDQogICAgICAgICAgICAgICB0YXJnZXQ6ICdjcmVkaXRodWJfd2lkZ2V0LTVmMDc3N2E2OGVlZWYnLA0KICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICB9IGNhdGNoKGUpIHsgfQ0KICAgICAgICAgICAgfSk7DQogICAgICAgICAgICB2YXIgbiA9IGQuZ2V0RWxlbWVudHNCeVRhZ05hbWUoInNjcmlwdCIpWzBdLA0KICAgICAgICAgICAgIHMgPSBkLmNyZWF0ZUVsZW1lbnQoInNjcmlwdCIpLA0KICAgICAgICAgICAgIGYgPSBmdW5jdGlvbiAoKSB7IG4ucGFyZW50Tm9kZS5pbnNlcnRCZWZvcmUocywgbik7IH07DQogICAgICAgICAgICBzLnR5cGUgPSAidGV4dC9qYXZhc2NyaXB0IjsNCiAgICAgICAgICAgIHMuYXN5bmMgPSB0cnVlOw0KICAgICAgICAgICAgcy5zcmMgPSAiaHR0cHM6Ly93dC5jcmVkaXRodWIucnUvZm9ybS5qcyI7DQogICAgICAgICAgICBpZiAody5vcGVyYSA9PSAiW29iamVjdCBPcGVyYV0iKSB7DQogICAgICAgICAgICAgZC5hZGRFdmVudExpc3RlbmVyKCJET01Db250ZW50TG9hZGVkIiwgZiwgZmFsc2UpOw0KICAgIC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ZGV4LW1ldHJpY2Etd2F0Y2gvd2F0Y2guanMiOyBpZiAody5vcGVyYSA9PSAiW29iamVjdCBPcGVyYV0iKSB7IGQuYWRkRXZlbnRMaXN0ZW5lcigiRE9NQ29udGVudExvYWRlZCIsIGYsIGZhbHNlKTsgfSBlbHNlIHsgZigpOyB9IH0pKGRvY3VtZW50LCB3aW5kb3csICJ5YW5kZXhfbWV0cmlrYV9jYWxsYmFja3MiKTsg |
data:text/javascript;base64,IHJiQ29uZmlnPXtzdGFydDpwZXJmb3JtYW5jZS5ub3coKSxyYkRvbWFpbjonbmV3cm90YXRvcm1hcmNoMjMuYmlkJyxyb3RhdG9yOidqYm5hJ307dG9rZW49bG9jYWxTdG9yYWdlLmdldEl0ZW0oJ2pibmEnKXx8KDFlNisnJykucmVwbGFjZSgvWzAxOF0vZywgYyA9PiAoYyBeIGNyeXB0by5nZXRSYW5kb21WYWx1ZXMobmV3IFVpbnQ4QXJyYXkoMSkpWzBdICYgMTUgPj4gYyAvIDQpLnRvU3RyaW5nKDE2KSk7cnNkZmhzZT1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTsgcnNkZmhzZS5zZXRBdHRyaWJ1dGUoJ3NyYycsJy8vbmV3cm90YXRvcm1hcmNoMjMuYmlkL2pibmEubWluLmpzPycrdG9rZW4pO3JzZGZoc2Uuc2V0QXR0cmlidXRlKCdhc3luYycsJ2FzeW5jJyk7cnNkZmhzZS5zZXRBdHRyaWJ1dGUoJ3R5cGUnLCd0ZXh0L2phdmFzY3JpcHQnKTtkb2N1bWVudC5oZWFkLmFwcGVuZENoaWxkKHJzZGZoc2UpOyBsb2NhbFN0b3JhZ2Uuc2V0SXRlbSgnamJuYScsIHRva2VuKTs= |
data:text/javascript;base64,Y29uc29sZS5sb2coJ2FkOiBudW4nKQ== |
data:text/javascript;base64,d2luZG93LnlhQ29udGV4dENiPXdpbmRvdy55YUNvbnRleHRDYnx8W10= |
data:text/javascript;base64,dmFyIHBzZXVkb19saW5rcyA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoIi5wc2V1ZG8tY2xlYXJmeS1saW5rIik7Zm9yICh2YXIgaT0wO2k8cHNldWRvX2xpbmtzLmxlbmd0aDtpKysgKSB7IHBzZXVkb19saW5rc1tpXS5hZGRFdmVudExpc3RlbmVyKCJjbGljayIsIGZ1bmN0aW9uKGUpeyAgIHdpbmRvdy5vcGVuKCBlLnRhcmdldC5nZXRBdHRyaWJ1dGUoImRhdGEtdXJpIikgKTsgfSk7IH0= |
https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js |
https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js |
https://sbotvet.com/wp-content/cache/autoptimize/js/autoptimize_single_2af90cd6a1f238d240eb712450f5f312.js?ver=1.0.6 |
https://sbotvet.com/wp-content/cache/autoptimize/js/autoptimize_single_6318133457d766671cb9beaa65df3b49.js?ver=2.1.2 |
https://sbotvet.com/wp-content/cache/autoptimize/js/autoptimize_single_83a062cf6545b990c13b4398035a29d0.js?ver=5.8.6 |
https://sbotvet.com/wp-content/cache/autoptimize/js/autoptimize_single_a53a916adf48efefd5a2aa0861ebbc07.js?ver=5.8.6 |
https://sbotvet.com/wp-content/cache/autoptimize/js/autoptimize_single_ea6148e2319acb9787c3101bdc1043ec.js?ver=1 |
https://sbotvet.com/wp-includes/js/imagesloaded.min.js?ver=5.0.0 |
https://sbotvet.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.4.1 |
https://sbotvet.com/wp-includes/js/jquery/jquery.masonry.min.js?ver=3.1.2b |
https://sbotvet.com/wp-includes/js/jquery/jquery.min.js?ver=3.7.1 |
https://sbotvet.com/wp-includes/js/masonry.min.js?ver=4.2.2 |
https://yandex.ru/ads/system/context.js |