diff --git a/PR-224/COMMITHASH b/PR-224/COMMITHASH
index 0d01ffc8..686599b2 100644
--- a/PR-224/COMMITHASH
+++ b/PR-224/COMMITHASH
@@ -1 +1 @@
-ddeb4511f7bb91e202d963fc6768d9b94c3d7ecc
\ No newline at end of file
+71666cd08140075aadcedc80214f4f6de81992da
\ No newline at end of file
diff --git a/PR-224/VERSION b/PR-224/VERSION
index 562f3346..c0e83b57 100644
--- a/PR-224/VERSION
+++ b/PR-224/VERSION
@@ -1 +1 @@
-ddeb451
\ No newline at end of file
+71666cd
\ No newline at end of file
diff --git a/PR-224/index.html b/PR-224/index.html
index d98a1073..5a83ac08 100644
--- a/PR-224/index.html
+++ b/PR-224/index.html
@@ -8,7 +8,7 @@
1.4.1 - Firebolt Certification App - version 1.4.1
-
+
FOUIsNEJBQTRCLHdEQUFXOztBQUV0RDtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBOztBQUVBO0FBQ0E7O0FBRUE7O0FBRUE7QUFDQTtBQUNBO0FBQ0EsMkJBQTJCLFlBQVk7QUFDdkM7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTt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dWUgPSBkZXJlZmVyZW5jZWQudmFsdWU7XG4gICAgICB9XG4gICAgICBlbHNlIHtcbiAgICAgICAgZm9yIChjb25zdCBrZXkgb2YgT2JqZWN0LmtleXMob2JqKSkge1xuICAgICAgICAgIGxldCBrZXlQYXRoID0gUG9pbnRlci5qb2luKHBhdGgsIGtleSk7XG4gICAgICAgICAgbGV0IGtleVBhdGhGcm9tUm9vdCA9IFBvaW50ZXIuam9pbihwYXRoRnJvbVJvb3QsIGtleSk7XG5cbiAgICAgICAgICBpZiAoaXNFeGNsdWRlZFBhdGgoa2V5UGF0aEZyb21Sb290KSkge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgbGV0IHZhbHVlID0gb2JqW2tleV07XG4gICAgICAgICAgbGV0IGNpcmN1bGFyID0gZmFsc2U7XG5cbiAgICAgICAgICBpZiAoJFJlZi5pc0FsbG93ZWQkUmVmKHZhbHVlLCBvcHRpb25zKSkge1xuICAgICAgICAgICAgZGVyZWZlcmVuY2VkID0gZGVyZWZlcmVuY2UkUmVmKHZhbHVlLCBrZXlQYXRoLCBrZXlQYXRoRnJvbVJvb3QsIHBhcmVudHMsIHByb2Nlc3NlZE9iamVjdHMsIGRlcmVmZXJlbmNlZENhY2hlLCAkcmVmcywgb3B0aW9ucyk7XG4gICAgICAgICAgICBjaXJjdWxhciA9IGRlcmVmZXJlbmNlZC5jaXJjdWxhcjtcbiAgICAgICAgICAgIC8vIEF2b2lkIHBvaW50bGVzcyBtdXRhdGlvbnM7IGJyZWFrcyBmcm96ZW4gb2JqZWN0cyB0byBubyBwcm9maXRcbiAgICAgICAgICAgIGlmIChvYmpba2V5XSAhPT0gZGVyZWZlcmVuY2VkLnZhbHVlKSB7XG4gICAgICAgICAgICAgIG9ialtrZXldID0gZGVyZWZlcmVuY2VkLnZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGlmIC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lamVjdChsYXN0RXJyb3IpO1xuICAgICAgfVxuXG4gICAgICB0cnkge1xuICAgICAgICAvLyBjb25zb2xlLmxvZygnICAlcycsIHBsdWdpbi5uYW1lKTtcbiAgICAgICAgbGV0IHJlc3VsdCA9IGdldFJlc3VsdChwbHVnaW4sIG1ldGhvZCwgZmlsZSwgY2FsbGJhY2ssICRyZWZzKTtcbiAgICAgICAgaWYgKHJlc3VsdCAmJiB0eXBlb2YgcmVzdWx0LnRoZW4gPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgIC8vIEEgcHJvbWlzZSB3YXMgcmV0dXJuZWRcbiAgICAgICAgICByZXN1bHQudGhlbihvblN1Y2Nlc3MsIG9uRXJyb3IpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKHJlc3VsdCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgLy8gQSBzeW5jaHJvbm91cyByZXN1bHQgd2FzIHJldHVybmVkXG4gICAgICAgICAgb25TdWNjZXNzKHJlc3VsdCk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoaW5kZXggPT09IHBsdWdpbnMubGVuZ3RoKSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiTm8gcHJvbWlzZSBoYXMgYmVlbiByZXR1cm5lZCBvciBjYWxsYmFjayBoYXMgYmVlbiBjYWxsZWQuXCIpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBjYXRjaCAoZSkge1xuICAgICAgICBvbkVycm9yKGUpO1xuICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNhbGxiYWNrIChlcnIsIHJlc3VsdCkge1xuICAgICAgaWYgKGVycikge1xuICAgICAgICBvbkVycm9yKGVycik7XG4gICAgICB9XG4gICAgICBlbHNlIHtcbiAgICAgICAgb25TdWNjZXNzKHJlc3VsdCk7XG4gICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gb25TdWNjZXNzIChyZXN1bHQpIHtcbi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o6IFsnXFx1MDFiNScsICdcXHUwMjQwJ10sXG4gIH07XG4gIHRleHQuZm9yRWFjaChmdW5jdGlvbihjKSB7XG4gICAgYyA9IGMudG9Mb3dlckNhc2UoKTtcbiAgICB2YXIgY2hhcnMgPSB0cmFwW2NdIHx8IFsnICddO1xuICAgIHZhciByYW5kID0gTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogY2hhcnMubGVuZ3RoKTtcbiAgICBpZiAodHlwZW9mIHRyYXBbY10gIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICByZXN1bHQgKz0gdHJhcFtjXVtyYW5kXTtcbiAgICB9IGVsc2Uge1xuICAgICAgcmVzdWx0ICs9IGM7XG4gICAgfVxuICB9KTtcbiAgcmV0dXJuIHJlc3VsdDtcbn07XG4iLCIvLyBwbGVhc2Ugbm9cbm1vZHVsZVsnZXhwb3J0cyddID0gZnVuY3Rpb24gemFsZ28odGV4dCwgb3B0aW9ucykge1xuICB0ZXh0ID0gdGV4dCB8fCAnICAgaGUgaXMgaGVyZSAgICc7XG4gIHZhciBzb3VsID0ge1xuICAgICd1cCc6IFtcbiAgICAgICfMjScsICfMjicsICfMhCcsICfMhScsXG4gICAgICAnzL8nLCAnzJEnLCAnzIYnLCAnzJAnLFxuICAgICAgJ82SJywgJ82XJywgJ82RJywgJ8yHJyxcbiAgICAgICfMiCcsICfMiicsICfNgicsICfMkycsXG4gICAgICAnzIgnLCAnzYonLCAnzYsnLCAnzYwnLFxuICAgICAgJ8yDJywgJ8yCJywgJ8yMJywgJ82QJyxcbiAgICAgICfMgCcsICfMgScsICfMiycsICfMjycsXG4gICAgICAnzJInLCAnzJMnLCAnzJQnLCAnzL0nLFxuICAgICAgJ8yJJywgJ82jJywgJ82kJywgJ82lJyxcbiAgICAgICfNpicsICfNpycsICfNqCcsICfNqScsXG4gICAgICAnzaonLCAnzasnLCAnzawnLCAnza0nLFxuICAgICAgJ82uJywgJ82vJywgJ8y+JywgJ82bJyxcbiAgICAgICfNhicsICfMmicsXG4gICAgXSxcbiAgICAnZG93bic6IFtcbiAgICAgICfMlicsICfMlycsICfMmCcsICfMmScsXG4gICAgICAnzJwnLCAnzJ0nLCAnzJ4nLCAnzJ8nLFxuICAgICAgJ8ygJywgJ8ykJywgJ8ylJywgJ8ymJyxcbiAgICAgICfMqScsICfMqicsICfMqycsICfMrCcsXG4gICAgICAnzK0nLCAnzK4nLCAnzK8nLCAnzLAnLFxuICAgICAgJ8yxJywgJ8yyJywgJ8yzJywgJ8y5JyxcbiAgICAgICfMuicsICfMuycsICfMvCcsICfNhScsXG4gICAgICAnzYcnLCAnzYgnLCAnzYknLCAnzY0nLFxuICAgICAgJ82OJywgJ82TJywgJ82UJywgJ82VJyxcbiAgICAgICfNlicsICfNmScsICfNmicsICfMoycsXG4gICAgXSxcbiAgICAnbWlkJzogW1xuICAgICAgJ8yVJywgJ8ybJywgJ8yAJywgJ8yBJyxcbiAgICAgICfNmCcsICfMoScsICfMoicsICfMpycsXG4gICAgICAnzKgnLCAnzLQnLCAnzLUnLCAnzLYnLFxuICAgICAgJ82cJywgJ82dJywgJ82eJyxcbiAgICAgICfNnycsICfNoCcsICfNoicsICfMuCcsXG4gICAgICAnzLcnLCAnzaEnLCAnINKJJyxcbiAgICBdLFxuICB9O1xuICB2YXIgYWxsID0gW10uY29uY2F0KHNvdWwudXAsIHNvdWwuZG93biwgc291bC5taWQpO1xuXG4gIGZ1bmN0aW9uIHJhbmRvbU51bWJlcihyYW5nZSkge1xuICAgIHZhciByID0gTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogcmFuZ2UpO1xuICAgIHJldHVybiByO1xuICB9XG5cbiAgZnVuY3Rpb24gaXNDaGFyKGNoYXJhY3Rlcikge1xuICAgIHZhciBib29sID0gZmFsc2U7XG4gICAgYWxsLmZpbHRlcihmdW5jdGlvbihpKSB7XG4gICAgICBib29sID0gKGkgPT09IGNoYXJhY3Rlcik7XG4gICAgfSk7XG4gICAgcmV0dXJuIGJvb2w7XG4g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PSByYW5kb21OdW1iZXIoOCk7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgJ21heGknOlxuICAgICAgICAgIGNvdW50cy51cCA9IHJhbmRvbU51bWJlcigxNikgKyAzO1xuICAgICAgICAgIGNvdW50cy5taWQgPSByYW5kb21OdW1iZXIoNCkgKyAxO1xuICAgICAgICAgIGNvdW50cy5kb3duID0gcmFuZG9tTnVtYmVyKDY0KSArIDM7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgY291bnRzLnVwID0gcmFuZG9tTnVtYmVyKDgpICsgMTtcbiAgICAgICAgICBjb3VudHMubWlkID0gcmFuZG9tTnVtYmVyKDYpIC8gMjtcbiAgICAgICAgICBjb3VudHMuZG93biA9IHJhbmRvbU51bWJlcig4KSArIDE7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICB9XG5cbiAgICAgIHZhciBhcnIgPSBbJ3VwJywgJ21pZCcsICdkb3duJ107XG4gICAgICBmb3IgKHZhciBkIGluIGFycikge1xuICAgICAgICB2YXIgaW5kZXggPSBhcnJbZF07XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDw9IGNvdW50c1tpbmRleF07IGkrKykge1xuICAgICAgICAgIGlmIChvcHRpb25zW2luZGV4XSkge1xuICAgICAgICAgICAgcmVzdWx0ID0gcmVzdWx0ICsgc291bFtpbmRleF1bcmFuZG9tTnVtYmVyKHNvdWxbaW5kZXhdLmxlbmd0aCldO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gcmVzdWx0O1xuICB9XG4gIC8vIGRvbid0IHN1bW1vbiBoaW1cbiAgcmV0dXJuIGhlQ29tZXModGV4dCwgb3B0aW9ucyk7XG59O1xuXG4iLCJtb2R1bGVbJ2V4cG9ydHMnXSA9IGZ1bmN0aW9uKGNvbG9ycykge1xuICByZXR1cm4gZnVuY3Rpb24obGV0dGVyLCBpLCBleH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ICAgfSlcblxuICAgIGlmIChwcm9taXNlcy5sZW5ndGgpIHtcbiAgICAgIFByb21pc2UuYWxsKHByb21pc2VzKVxuICAgICAgICAudGhlbigocmVzcG9uc2VzKSA9PiB7XG4gICAgICAgICAgcmVzb2x2ZShsaXN0ZW5lcklkKVxuICAgICAgICB9KVxuICAgICAgICAuY2F0Y2goKGVycm9yKSA9PiB7XG4gICAgICAgICAgLy8gUHJvbWlzZS5hbGwgcmVqZWN0cyBpZiBhdCBsZWFzdCBvbmUgcHJvbWlzZSByZWplY3RzLi4uIHdlIGRvbid0IHdhbnQgdGhhdCBiZWhhdmlvciBoZXJlXG4gICAgICAgICAgLy8gVE9ETzogRG8gc29tZXRoaW5nIGJldHRlciB0aGFuIGZhaWwgc2lsZW50bHlcbiAgICAgICAgICBpZiAoZXZlbnQgPT09ICcqJykge1xuICAgICAgICAgICAgcmVzb2x2ZShsaXN0ZW5lcklkKVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZWplY3QoZXJyb3IpXG4gICAgICAgICAgfVxuICAgICAgICB9KVxuICAgIH0gZWxzZSB7XG4gICAgICByZXNvbHZlKGxpc3RlbmVySWQpXG4gICAgfVxuICAgIHJldHVybiBwXG4gIH1cbn1cblxuY29uc3QgZ2V0TGlzdGVuQXJncyA9IGZ1bmN0aW9uICguLi5hcmdzKSB7XG4gIGNvbnN0IGNhbGxiYWNrID0gYXJncy5wb3AoKVxuICBjb25zdCBbbW9kdWxlLCBldmVudCwgY29udGV4dF0gPSBnZXRDbGVhckFyZ3MoLi4uYXJncylcblxuICByZXR1cm4gW21vZHVsZSwgZXZlbnQsIGNhbGxiYWNrLCBjb250ZXh0XVxufVxuXG5jb25zdCBnZXRDbGVhckFyZ3MgPSBmdW5jdGlvbiAoLi4uYXJncykge1xuICBjb25zdCBtb2R1bGUgPSAoYXJncy5zaGlmdCgpIHx8ICcqJykudG9Mb3dlckNhc2UoKVxuICBjb25zdCBldmVudCA9IGFyZ3Muc2hpZn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mNoSWQgPSBtb2R1bGVPcklkLnRvU3RyaW5nKClcbiAgICBjb25zdCBrZXkgPSBsaXN0ZW5lcnMuZmluZChzZWFyY2hJZClcblxuICAgIGlmIChrZXkpIHtcbiAgICAgIGxpc3RlbmVycy5yZW1vdmUoc2VhcmNoSWQpXG4gICAgICBpZiAobGlzdGVuZXJzLmNvdW50KGtleSkgPT09IDApIHtcbiAgICAgICAgdW5zdWJzY3JpYmUoa2V5KVxuICAgICAgfVxuICAgICAgcmV0dXJuIHRydWVcbiAgICB9XG4gICAgcmV0dXJuIGZhbHNlXG4gIH0gZWxzZSB7XG4gICAgaWYgKCFtb2R1bGVPcklkICYmICFldmVudCkge1xuICAgICAgbGlzdGVuZXJzLmtleXMoKS5mb3JFYWNoKChrZXkpID0+IHtcbiAgICAgICAgbGlzdGVuZXJzLnJlbW92ZUtleShrZXkpXG4gICAgICAgIHVuc3Vic2NyaWJlKGtleSlcbiAgICAgIH0pXG4gICAgfSBlbHNlIGlmICghZXZlbnQpIHtcbiAgICAgIGxpc3RlbmVycy5rZXlzKCkuZm9yRWFjaCgoa2V5KSA9PiB7XG4gICAgICAgIGlmIChrZXkuaW5kZXhPZihtb2R1bGVPcklkLnRvTG93ZXJDYXNlKCkpID09PSAwKSB7XG4gICAgICAgICAgbGlzdGVuZXJzLnJlbW92ZUtleShrZXkpXG4gICAgICAgICAgdW5zdWJzY3JpYmUoa2V5KVxuICAgICAgICB9XG4gICAgICB9KVxuICAgIH0gZWxzZSB7XG4gICAgICBjb25zdCBoYXNDb250ZXh0ID0gT2JqZWN0LnZhbHVlcyhjb250ZXh0KS5sZW5ndGggPiAwXG4gICAgICBjb25zdCBjb250ZXh0S2V5ID0gT2JqZWN0LmtleXMoY29udGV4dClcbiAgICAgICAgLnNvcnQoKVxuICAgICAgICAubWFwKChrZXkpID0+IGtleSArICc9JyArIEpTT04uc3RyaW5naWZ5KGNvbnRleHRba2V5XSkpXG4gICAgICAgIC5qb2luKCcmJylcbiAgICAgIGNv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1bGUgPT09ICcqJykge1xuICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KCdObyB2YWxpZCBtb2R1bGUgbmFtZSBwcm92aWRlZCcpXG4gICAgfVxuXG4gICAgY29uc3Qgd2lsZGNhcmQgPSBldmVudCA9PT0gJyonXG4gICAgY29uc3QgZXZlbnRzID0gd2lsZGNhcmQgPyB2YWxpZEV2ZW50c1ttb2R1bGVdIDogW2V2ZW50XSAvLyBleHBsb2RlcyB3aWxkY2FyZHMgaW50byBhbiBhcnJheVxuICAgIGNvbnN0IHByb21pc2VzID0gW11cbiAgICBjb25zdCBoYXNDb250ZXh0ID0gT2JqZWN0LnZhbHVlcyhjb250ZXh0KS5sZW5ndGggPiAwXG4gICAgY29uc3QgY29udGV4dEtleSA9IE9iamVjdC5rZXlzKGNvbnRleHQpXG4gICAgICAuc29ydCgpXG4gICAgICAubWFwKChrZXkpID0+IGtleSArICc9JyArIEpTT04uc3RyaW5naWZ5KGNvbnRleHRba2V5XSkpXG4gICAgICAuam9pbignJicpXG5cbiAgICBsaXN0ZW5lcklkKytcblxuICAgIGlmIChvbmNlKSB7XG4gICAgICBvbmNlcnMucHVzaChsaXN0ZW5lcklkKVxuICAgIH1cblxuICAgIGV2ZW50cy5mb3JFYWNoKChldmVudCkgPT4ge1xuICAgICAgY29uc3Qga2V5ID0gbW9kdWxlICsgJy4nICsgZXZlbnQgKyAoaGFzQ29udGV4dCA/IGAuJHtjb250ZXh0S2V5fWAgOiAnJylcblxuICAgICAgaWYgKE9iamVjdC52YWx1ZXMobGlzdGVuZXJzLmdldChrZXkpKS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgY29uc3QgYXJncyA9IE9iamVjdC5hc3NpZ24oeyBsaXN0ZW46IHRydWUgfSwgY29udGV4dClcbiAgICAgICAgY29uc3QgeyBpZCwgcHJvbWlzZSB9ID0gVHJhbnNwb3J0Lmxpc3RlbihcbiAgICAgICAgICBtb2R1bGUsXG4gICAgICAgICAgJ29uJyArIGV2ZW50WzBdLnRvVXBwZXJDYXNlKCkgKyBldmVudC5zdWJzdHJpbmcoMSksXG4gICAgICAgICAgYXJncyxcbiAgICAgICAgKVxuICAgICAgICBrZXlzW2lkXSA9IGtleVxuICAgICAgICBwcm9taXNlcy5wdXNoKHByb21pc2UpXG4gICAgICB9XG5cbiAgICAgIGNvbnN0IHNldHRlciA9IGludGVybmFsID8gbGlzdGVuZXJzLnNldEludGVybmFsIDogbGlzdGVuZXJzLnNldFxuXG4gICAgICBpZiAod2lsZGNhcmQpIHtcbiAgICAgICAgc2V0dGVyKGtleSwgJycgKyBsaXN0ZW5lcklkLCAodmFsdWUpID0+IGNhbGxiYWNrKGV2ZW50LCB2YWx1ZSkpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzZXR0ZXIoa2V5LCAnJyArIGxpc3RlbmVySWQsIGNhbGxiYWNrKVxuICAgICAgfVxuICAgIH0pXG5cbiAgICBsZXQgcmVzb2x2ZSwgcmVqZWN0XG4gICAgbGV0IHAgPSBuZXcgUHJvbWlzZSgocmVzLCByZWopID0+IHtcbiAgICAgIHJlc29sdmUgPSByZXNcbiAgICAgIHJlamVjdCA9IHJlalxuICAgIH0pXG5cbiAgICBpZiAocHJvbWlzZXMubGVuZ3RoKSB7XG4gICAgICBQcm9taXNlLmFsbChwcm9taXNlcylcbiAgICAgICAgLnRoZW4oKHJlc3BvbnNlcykgPT4ge1xuICAgICAgICAgIHJlc29sdmUobGlzdGVuZXJJZClcbiAgICAgICAgfSlcbiAgICAgICAgLmNhdGNoKChlcnJvcikgPT4ge1xuICAgICAgICAgIC8vIFByb21pc2UuYWxsIHJlamVjdHMgaWYgYXQgbGVhc3Qgb25lIHByb21pc2UgcmVqZWN0cy4uLiB3ZSBkb24ndCB3YW50IHRoYXQgYmVoYXZpb3IgaGVyZVxuICAgICAgICAgIC8vIFRPRE86IERvIHNvbWV0aGluZyBiZXR0ZXIgdGhhbiBmYWlsIHNpbGVudGx5XG4gICAgICAgICAgaWYgKGV2ZW50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y5yZW1vdmVLZXkoa2V5KVxuICAgICAgICB1bnN1YnNjcmliZShrZXkpXG4gICAgICB9KVxuICAgIH0gZWxzZSBpZiAoIWV2ZW50KSB7XG4gICAgICBsaXN0ZW5lcnMua2V5cygpLmZvckVhY2goKGtleSkgPT4ge1xuICAgICAgICBpZiAoa2V5LmluZGV4T2YobW9kdWxlT3JJZC50b0xvd2VyQ2FzZSgpKSA9PT0gMCkge1xuICAgICAgICAgIGxpc3RlbmVycy5yZW1vdmVLZXkoa2V5KVxuICAgICAgICAgIHVuc3Vic2NyaWJlKGtleSlcbiAgICAgICAgfVxuICAgICAgfSlcbiAgICB9IGVsc2Uge1xuICAgICAgY29uc3QgaGFzQ29udGV4dCA9IE9iamVjdC52YWx1ZXMoY29udGV4dCkubGVuZ3RoID4gMFxuICAgICAgY29uc3QgY29udGV4dEtleSA9IE9iamVjdC5rZXlzKGNvbnRleHQpXG4gICAgICAgIC5zb3J0KClcbiAgICAgICAgLm1hcCgoa2V5KSA9PiBrZXkgKyAnPScgKyBKU09OLnN0cmluZ2lmeShjb250ZXh0W2tleV0pKVxuICAgICAgICAuam9pbignJicpXG4gICAgICBjb25zdCBrZXkgPVxuICAgICAgICBtb2R1bGVPcklkICsgJy4nICsgZXZlbnQgKyAoaGFzQ29udGV4dCA/IGAuJHtjb250ZXh0S2V5fWAgOiAnJylcblxuICAgICAgbGlzdGVuZXJzLnJlbW92ZUtleShrZXkpXG4gICAgICB1bnN1YnNjcmliZShrZXksIGNvbnRleHQpXG4gICAgfVxuICB9XG59XG5cbmNvbnN0IGluaXQgPSAoKSA9PiB7XG4gIGlmICghdHJhbnNwb3J0SW5pdGlhbGl6ZWQpIHtcbiAgICBUcmFuc3BvcnQuYWRkRXZlbnRFbWl0dGVyKGVtaXQpXG4gICAgc2V0TW9ja0xpc3RlbmVyKGxpc3RlbilcbiAgICB0cmFuc3BvcnRJbml0aWFsaXplZCA9IHRydWVcbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCB7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pY2Vuc2UtSWRlbnRpZmllcjogQXBhY2hlLTIuMFxuICovXG5pbXBvcnQgTW9ja1Byb3BzIGZyb20gJy4uL1Byb3AvTW9ja1Byb3BzLm1qcydcblxuZXhwb3J0IGRlZmF1bHQge1xuICBhbGxvd1Jlc3VtZVBvaW50czogZnVuY3Rpb24gKHBhcmFtcykge1xuICAgIHJldHVybiBNb2NrUHJvcHMubW9jayhcbiAgICAgICdQcml2YWN5JyxcbiAgICAgICdhbGxvd1Jlc3VtZVBvaW50cycsXG4gICAgICBwYXJhbXMsXG4gICAgICB1bmRlZmluZWQsXG4gICAgICAwLFxuICAgICAgdHJ1ZSxcbiAgICApXG4gIH0sXG4gIGFsbG93VW5lbnRpdGxlZFJlc3VtZVBvaW50czogZnVuY3Rpb24gKHBhcmFtcykge1xuICAgIHJldHVybiBNb2NrUHJvcHMubW9jayhcbiAgICAgICdQcml2YWN5JyxcbiAgICAgICdhbGxvd1VuZW50aXRsZWRSZXN1bWVQb2ludHMnLFxuICAgICAgcGFyYW1zLFxuICAgICAgdW5kZWZpbmVkLFxuICAgICAgMCxcbiAgICAgIHRydWUsXG4gICAgKVxuICB9LFxuICBhbGxvd1dhdGNoSGlzdG9yeTogZnVuY3Rpb24gKHBhcmFtcykge1xuICAgIHJldHVybiBNb2NrUHJvcHMubW9jayhcbiAgICAgICdQcml2YWN5JyxcbiAgICAgICdhbGxvd1dhdGNoSGlzdG9yeScsXG4gICAgICBwYXJhbXMsXG4gICAgICB1bmRlZmluZWQsXG4gICAgICAwLFxuICAgICAgdHJ1ZSxcbiAgICApXG4gIH0sXG4gIGFsbG93UHJvZHVjdEFuYWx5dGljczogZnVuY3Rpb24gKHBhcmFtcykge1xuICAgIHJldHVybiBNb2NrUHJvcHMubW9jayhcbiAgICAgICdQcml2YWN5JyxcbiAgICAgICdhbGxvd1Byb2R1Y3RBbmFseXRpY3MnLFxuICAgICAgcGFyYW1zLFxuICAgICAgdW5kZWZpbmVkLFxuICAgICAgMCxcbiAgIC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VzdC5jb3JyZWxhdGlvbklkXG4gICAgICAgICAgfSxcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIG9ubHkgcGFzcyBpbiB0aGUgZm9jdXMgaGFuZHNoYWtlIGlmIG5lZWRlZFxuICAgICAgICBpZiAoaW1ldGhvZC5mb2N1cykge1xuICAgICAgICAgIHNlc3Npb24uZm9jdXMgPSAoKSA9PiB7XG4gICAgICAgICAgICBUcmFuc3BvcnQuc2VuZChtb2R1bGUsIGAke21ldGhvZH1Gb2N1c2AsIHtcbiAgICAgICAgICAgICAgY29ycmVsYXRpb25JZDogcmVxdWVzdC5jb3JyZWxhdGlvbklkLFxuICAgICAgICAgICAgfSlcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBwcm92aWRlckNhbGxBcmdzLnB1c2goc2Vzc2lvbilcblxuICAgICAgICBjb25zdCByZXNwb25zZSA9IHtcbiAgICAgICAgICBjb3JyZWxhdGlvbklkOiByZXF1ZXN0LmNvcnJlbGF0aW9uSWQsXG4gICAgICAgIH1cbiAgICAgICAgbGV0IGhhbmRsZUVycm9yID0gKGVycm9yKSA9PiB7XG4gICAgICAgICAgcmVzcG9uc2UuZXJyb3IgPSB7XG4gICAgICAgICAgICBjb2RlOiBlcnJvci5jb2RlIHx8IDEwMDAsIC8vIHRvZG86IHNob3VsZCBiZSBzb21lIHJlc2VydmVkIGNvZGUgZm9yIFwiVW5rbm93blwiXG4gICAgICAgICAgICBtZXNzYWdlOlxuICAgICAgICAgICAgICBlcnJvci5tZXNzYWdlIHx8XG4gICAgICAgICAgICAgIGBBbiBlcnJvciBvY2N1cmVkIHdoaWxlIGNhbGxpbmcgcHJvdmlkZWQgJHttZXRob2R9IG1ldGhvZC5gLFxuICAgICAgICAgIH1cblxuICAgICAgICAgIGlmIChlcnJvci5kYXRhKSB7XG4gICAgICAgICAgICByZXNwb25zZS5lcnJvci5kYXRhID0gSlNPTi5wYXJzZShKU09OLnN0cmluZ2lmeShlcnJvci5kYXRhKSlcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBUcmFuc3BvcnQuc2VuZChtb2R1bGUsIGAke21ldGhvZH1FcnJvcmAsIHJlc3BvbnNlKVxuICAgICAgICB9XG5cbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBjb25zdCByZXN1bHQgPSBwcm92aWRlclttZXRob2RdLmFwcGx5KHByb3ZpZGVyLCBwcm92aWRlckNhbGxBcmdzKVxuXG4gICAgICAgICAgaWYgKCEocmVzdWx0IGluc3RhbmNlb2YgUHJvbWlzZSkpIHtcbiAgICAgICAgICAgIHRocm93IGBQcm92aWRlciBtZXRob2QgJHttZXRob2R9IGRpZCBub3QgcmV0dXJuIGEgUHJvbWlzZS5gXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgcmVzdWx0XG4gICAgICAgICAgICAudGhlbigocmVzdWx0KSA9PiB7XG4gICAgICAgICAgICAgIGlmIChpbWV0aG9kLnJlc3BvbnNlKSB7XG4gICAgICAgICAgICAgICAgLy8gdm9pZCByZXN1bHRzIHNob3VsZCBiZSBudWxsIGluIHRoZSBKU09OUlBDIG1lc3NhZ2VcbiAgICAgICAgICAgICAgICByZXNwb25zZS5yZXN1bHQgPSByZXN1bHQgPT0gbnVsbCA/IG51bGwgOiByZXN1bHRcbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIFRyYW5zcG9ydC5zZW5kKG1vZHVsZSwgYCR7bWV0aG9kfVJlc3BvbnNlYCwgcmVzcG9uc2UpXG4gICAgICAgICAgICB9KVxuICAgICAgICAgICAgLmNhdGNoKChlcnIpID0+IGhhbmRsZUVycm9yKGVycikpXG4gICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgICAgaGFuZGxlRXJyb3IoZXJyb3IpXG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgKVxuICB9KVxufVxuXG5leHBvcnQgZGVmYXVsdCB7XG4gIHByb3ZpZGUsXG59XG4iLCJpbXBvcnQgVHJhbnNwb3J0IGZyb20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Skge1xuICAgIGlmIChqc29uLnBhcmFtcy5saXN0ZW4pIHtcbiAgICAgIGV2ZW50TWFwW2pzb24uaWRdID1cbiAgICAgICAgbW9kdWxlLnRvTG93ZXJDYXNlKCkgKyAnLicgKyBtZXRob2RbMl0udG9Mb3dlckNhc2UoKSArIG1ldGhvZC5zdWJzdHIoMylcbiAgICB9IGVsc2Uge1xuICAgICAgT2JqZWN0LmtleXMoZXZlbnRNYXApLmZvckVhY2goKGtleSkgPT4ge1xuICAgICAgICBpZiAoXG4gICAgICAgICAgZXZlbnRNYXBba2V5XSA9PT1cbiAgICAgICAgICBtb2R1bGUudG9Mb3dlckNhc2UoKSArXG4gICAgICAgICAgICAnLicgK1xuICAgICAgICAgICAgbWV0aG9kWzJdLnRvTG93ZXJDYXNlKCkgK1xuICAgICAgICAgICAgbWV0aG9kLnN1YnN0cigzKVxuICAgICAgICApIHtcbiAgICAgICAgICBkZWxldGUgZXZlbnRNYXBba2V5XVxuICAgICAgICB9XG4gICAgICB9KVxuICAgIH1cbiAgfVxuXG4gIGlmIChtb2NrKSBoYW5kbGUoanNvbilcbiAgZWxzZSBwZW5kaW5nLnB1c2goanNvbilcbn1cblxuZnVuY3Rpb24gaGFuZGxlKGpzb24pIHtcbiAgbGV0IHJlc3VsdFxuICB0cnkge1xuICAgIHJlc3VsdCA9IGdldFJlc3VsdChqc29uLm1ldGhvZCwganNvbi5wYXJhbXMpXG4gIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgc2V0VGltZW91dCgoKSA9PlxuICAgICAgY2FsbGJhY2soXG4gICAgICAgIEpTT04uc3RyaW5naWZ5KHtcbiAgICAgICAgICBqc29ucnBjOiAnMi4wJyxcbiAgICAgICAgICBlcnJvcjoge1xuICAgICAgICAgICAgY29kZTogLTMyNjAyLFxuICAgICAgICAgICAgbWVzc2FnZTpcbiAgICAgICAgICAgICAgJ0ludmFsaWQgcGFyYW1zICh0aGlzIGlzIGEgbW9jayBlcnJvciBmcm9tIHRoZSBtb2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MDAsXG4gICAgICB0ZXh0QWxpZ246ICdjZW50ZXInLFxuICAgICAgdGV4dEFsaWduVmVydGljYWw6ICdtaWRkbGUnLFxuICAgICAgd2luZG93Q29sb3I6ICd3aGl0ZScsXG4gICAgICB3aW5kb3dPcGFjaXR5OiA1MCxcbiAgICB9LFxuICAgIHByZWZlcnJlZExhbmd1YWdlczogWydlbmcnLCAnc3BhJ10sXG4gIH0sXG4gIGNsb3NlZENhcHRpb25zU2V0dGluZ3M6IGZ1bmN0aW9uIChwYXJhbXMpIHtcbiAgICByZXR1cm4gTW9ja1Byb3BzLm1vY2soXG4gICAgICAnQWNjZXNzaWJpbGl0eScsXG4gICAgICAnY2xvc2VkQ2FwdGlvbnNTZXR0aW5ncycsXG4gICAgICBwYXJhbXMsXG4gICAgICB1bmRlZmluZWQsXG4gICAgICAwLFxuICAgICAge1xuICAgICAgICBlbmFibGVkOiB0cnVlLFxuICAgICAgICBzdHlsZXM6IHtcbiAgICAgICAgICBmb250RmFtaWx5OiAnbW9ub3NwYWNlZF9zYW5zZXJpZicsXG4gICAgICAgICAgZm9udFNpemU6IDEsXG4gICAgICAgICAgZm9udENvbG9yOiAnI2ZmZmZmZicsXG4gICAgICAgICAgZm9udEVkZ2U6ICdub25lJyxcbiAgICAgICAgICBmb250RWRnZUNvbG9yOiAnIzdGN0Y3RicsXG4gICAgICAgICAgZm9udE9wYWNpdHk6IDEwMCxcbiAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6ICcjMDAwMDAwJyxcbiAgICAgICAgICBiYWNrZ3JvdW5kT3BhY2l0eTogMTAwLFxuICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgICAgdGV4dEFsaWduVmVydGljYWw6ICdtaWRkbGUnLFxuICAgICAgICAgIHdpbmRvd0NvbG9yOiAnd2hpdGUnLFxuICAgICAgICAgIHdpbmRvd09wYWNpdHk6IDUwLFxuICAgICAgICB9LFxuICAgICAgICBwcmVmZXJyZWRMYW5ndWF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ubWVzc2FnZSB8fCAnVW5rbm93biBFcnJvcidcbiAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcbiAgICAgICAgICAgICAgICBgRmFpbGVkIHRvIHNlbmQgZW50aXR5SW5mbyBwdWxsIHJlc3BvbnNlIHRocm91Z2ggVHJhbnNwb3J0IExheWVyOiAke21zZ31gLFxuICAgICAgICAgICAgICApXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH0pXG4gICAgICAgICAgLmNhdGNoKChlcnJvcikgPT4ge1xuICAgICAgICAgICAgY29uc3QgbXNnID1cbiAgICAgICAgICAgICAgdHlwZW9mIGVycm9yID09PSAnc3RyaW5nJ1xuICAgICAgICAgICAgICAgID8gZXJyb3JcbiAgICAgICAgICAgICAgICA6IGVycm9yLm1lc3NhZ2UgfHwgJ1Vua25vd24gRXJyb3InXG4gICAgICAgICAgICBjb25zb2xlLmVycm9yKGBBcHAgJ2VudGl0eUluZm8nIGNhbGxiYWNrIGZhaWxlZDogJHttc2d9YClcbiAgICAgICAgICB9KVxuICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgY29uc3QgbXNnID1cbiAgICAgICAgICB0eXBlb2YgZXJyb3IgPT09ICdzdHJpbmcnID8gZXJyb3IgOiBlcnJvci5tZXNzYWdlIHx8ICdVbmtub3duIEVycm9yJ1xuICAgICAgICBjb25zb2xlLmVycm9yKGBBcHAgJ2VudGl0eUluZm8nIGNhbGxiYWNrIGZhaWxlZDogJHttc2d9YClcbiAgICAgIH1cbiAgICB9KVxuICB9IGVsc2Uge1xuICAgIHJldHVybiBUcmFuc3BvcnQuc2VuZCgnRGlzY292ZXJ5JywgJ2VudGl0eUluZm8nLCB7XG4gICAgICBjb3JyZWxhdGlvbklkOiBudWxsLFxuICAgICAgcmVzdWx0OiBkYXRhLFxuICAgIH0pXG4gIH1cbn1cblxuZnVuY3Rpb24gbGF1bmNoKGFwcElkLCBpbnRlbnQpIHtcbiAgY29uc3QgdHJhbnNmb3JtcyA9IG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gKGFyZ3VtZW50cy5sZW5ndGggPT09IDEgJiYgdHlwZW9mIGFyZ3VtZW50c1swXSA9PT0gJ2Z1bmN0aW9uJykge1xuICAgIGlmIChwdXJjaGFzZWRDb250ZW50SGFzQ2FsbGJhY2spIHtcbiAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChcbiAgICAgICAgJ0Nhbm5vdCByZWdpc3RlciBtb3JlIHRoYW4gb25lIHB1cmNoYXNlZENvbnRlbnQgaGFuZGxlci4nLFxuICAgICAgKVxuICAgIH1cblxuICAgIGNvbnN0IGNhbGxiYWNrID0gYXJndW1lbnRzWzBdXG4gICAgcHVyY2hhc2VkQ29udGVudEhhc0NhbGxiYWNrID0gdHJ1ZVxuICAgIHJldHVybiBFdmVudHMubGlzdGVuKCdEaXNjb3ZlcnknLCAncHVsbFB1cmNoYXNlZENvbnRlbnQnLCAocmVxdWVzdCkgPT4ge1xuICAgICAgaWYgKHR5cGVvZiByZXF1ZXN0ID09PSAnYm9vbGVhbicpIHJldHVyblxuXG4gICAgICB0cnkge1xuICAgICAgICBjb25zdCByZXN1bHQgPSBjYWxsYmFjayhyZXF1ZXN0LnBhcmFtZXRlcnMpXG4gICAgICAgICAgLnRoZW4oKHJlc3VsdCkgPT4ge1xuICAgICAgICAgICAgY29uc3QgcGFyYW1zID0ge1xuICAgICAgICAgICAgICBjb3JyZWxhdGlvbklkOiByZXF1ZXN0LmNvcnJlbGF0aW9uSWQsXG4gICAgICAgICAgICAgIHJlc3VsdDogcmVzdWx0LFxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgVHJhbnNwb3J0LnNlbmQoJ0Rpc2NvdmVyeScsICdwdXJjaGFzZWRDb250ZW50JywgcGFyYW1zKS5jYXRjaChcbiAgICAgICAgICAgICAgKGVycm9yKSA9PiB7XG4gICAgICAgICAgICAgICAgY29uc3QgbXNnID1cbiAgICAgICAgICAgICAgICAgIHR5cGVvZiBlcnJvciA9PT0gJ3N0cmluZydcbiAgICAgICAgICAgICAgICAgICAgPyBlcnJvclxuICAgICAgICAgICAgICAgICAgICA6IGVycm9yLm1lc3NhZ2UgfHwgJ1Vua25vd24gRXJyb3InXG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcbiAgICAgICAgICAgICAgICAgIGBGYWlsZWQgdG8gc2VuZCBwdXJjaGFzZWRDb250ZW50IHB1bGwgcmVzcG9uc2UgdGhyb3VnaCBUcmFuc3BvcnQgTGF5ZXI6ICR7bXNnfWAsXG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgKVxuICAgICAgICAgIH0pXG4gICAgICAgICAgLmNhdGNoKChlcnJvcikgPT4ge1xuICAgICAgICAgICAgY29uc3QgbXNnID1cbiAgICAgICAgICAgICAgdHlwZW9mIGVycm9yID09PSAnc3RyaW5nJ1xuICAgICAgICAgICAgICAgID8gZXJyb3JcbiAgICAgICAgICAgICAgICA6IGVycm9yLm1lc3NhZ2UgfHwgJ1Vua25vd24gRXJyb3InXG4gICAgICAgICAgICBjb25zb2xlLmVycm9yKGBBcHAgJ3B1cmNoYXNlZENvbnRlbnQnIGNhbGxiYWNrIGZhaWxlZDogJHttc2d9YClcbiAgICAgICAgICB9KVxuICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgY29uc3QgbXNnID1cbiAgICAgICAgICB0eXBlb2YgZXJyb3IgPT09ICdzdHJpbmcnID8gZXJyb3IgOiBlcnJvci5tZXNzYWdlIHx8ICdVbmtub3duIEVycm9yJ1xuICAgICAgICBjb25zb2xlLmVycm9yKGBBcHAgJ3B1cmNoYXNlZENvbnRlbnQnIGNhbGxiYWNrIGZhaWxlZDogJHttc2d9YClcbiAgICAgIH1cbiAgICB9KVxuICB9IGVsc2Uge1xuICAgIHJldHVybiBUcmFuc3BvcnQuc2VuZCgnRGlzY292ZXJ5JywgJ3B1cmNoYXNlZENvbnRlbnQnLCB7XG4gICAgICBjb3JyZWxhdGlvbklkOiBudWxsLFxuICAgICAgcmV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0gbWV0aG9kLmAsXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKGVycm9yLmRhdGEpIHtcbiAgICAgICAgICAgIHJlc3BvbnNlLmVycm9yLmRhdGEgPSBKU09OLnBhcnNlKEpTT04uc3RyaW5naWZ5KGVycm9yLmRhdGEpKVxuICAgICAgICAgIH1cblxuICAgICAgICAgIFRyYW5zcG9ydC5zZW5kKG1vZHVsZSwgYCR7bWV0aG9kfUVycm9yYCwgcmVzcG9uc2UpXG4gICAgICAgIH1cblxuICAgICAgICB0cnkge1xuICAgICAgICAgIGNvbnN0IHJlc3VsdCA9IHByb3ZpZGVyW21ldGhvZF0uYXBwbHkocHJvdmlkZXIsIHByb3ZpZGVyQ2FsbEFyZ3MpXG5cbiAgICAgICAgICBpZiAoIShyZXN1bHQgaW5zdGFuY2VvZiBQcm9taXNlKSkge1xuICAgICAgICAgICAgdGhyb3cgYFByb3ZpZGVyIG1ldGhvZCAke21ldGhvZH0gZGlkIG5vdCByZXR1cm4gYSBQcm9taXNlLmBcbiAgICAgICAgICB9XG5cbiAgICAgICAgICByZXN1bHRcbiAgICAgICAgICAgIC50aGVuKChyZXN1bHQpID0+IHtcbiAgICAgICAgICAgICAgaWYgKGltZXRob2QucmVzcG9uc2UpIHtcbiAgICAgICAgICAgICAgICAvLyB2b2lkIHJlc3VsdHMgc2hvdWxkIGJlIG51bGwgaW4gdGhlIEpTT05SUEMgbWVzc2FnZVxuICAgICAgICAgICAgICAgIHJlc3BvbnNlLnJlc3VsdCA9IHJlc3VsdCA9PSBudWxsID8gbnVsbCA6IHJlc3VsdFxuICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgVHJhbnNwb3J0LnNlbmQobW9kdWxlLCBgJHttZXRob2R9UmVzcG9uc2VgLCByZXNwb25zZSlcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuY2F0Y2goKGVycikgPT4gaGFuZGxlRXJyb3IoZXJyKSlcbiAgICAgICAgfSBjYXRjaCAoZXJ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ckVhY2goKGopID0+IHNlbmQoSlNPTi5zdHJpbmdpZnkoaikpKVxuICAgIHJldHVyblxuICB9XG5cbiAgbGV0IFttb2R1bGUsIG1ldGhvZF0gPSBqc29uLm1ldGhvZC5zcGxpdCgnLicpXG5cbiAgaWYgKHRlc3RIYXJuZXNzICYmIHRlc3RIYXJuZXNzLm9uU2VuZCkge1xuICAgIHRlc3RIYXJuZXNzLm9uU2VuZChtb2R1bGUsIG1ldGhvZCwganNvbi5wYXJhbXMsIGpzb24uaWQpXG4gIH1cblxuICAvLyBzdG9yZSB0aGUgSUQgb2YgdGhlIGZpcnN0IGxpc3RlbiBmb3IgZWFjaCBldmVudFxuICBpZiAobWV0aG9kLm1hdGNoKC9eb25bQS1aXS8pKSB7XG4gICAgaWYgKGpzb24ucGFyYW1zLmxpc3Rlbikge1xuICAgICAgZXZlbnRNYXBbanNvbi5pZF0gPVxuICAgICAgICBtb2R1bGUudG9Mb3dlckNhc2UoKSArICcuJyArIG1ldGhvZFsyXS50b0xvd2VyQ2FzZSgpICsgbWV0aG9kLnN1YnN0cigzKVxuICAgIH0gZWxzZSB7XG4gICAgICBPYmplY3Qua2V5cyhldmVudE1hcCkuZm9yRWFjaCgoa2V5KSA9PiB7XG4gICAgICAgIGlmIChcbiAgICAgICAgICBldmVudE1hcFtrZXldID09PVxuICAgICAgICAgIG1vZHVsZS50b0xvd2VyQ2FzZSgpICtcbiAgICAgICAgICAgICcuJyArXG4gICAgICAgICAgICBtZXRob2RbMl0udG9Mb3dlckNhc2UoKSArXG4gICAgICAgICAgICBtZXRob2Quc3Vic3RyKDMpXG4gICAgICAgICkge1xuICAgICAgICAgIGRlbGV0ZSBldmVudE1hcFtrZXldXG4gICAgICAgIH1cbiAgICAgIH0pXG4gICAgfVxuICB9XG5cbiAgaWYgKG1vY2spIGhhbmRsZShqc29uKVxuICBlbHNlIHBlbmRpbmcucHVzaChqc29uKVxufVxuXG5mdW5jdGlvbiBoYW5kbGUoanNvbikge1xuICBsZXQgc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gKiAodCAqICgzICogeGEpICsgMiAqIHhiKSArIHhjO1xuICAgICAgICBpZiAoY2J4ZCA+IDFlLTEwICYmIGNieGQgPCAxZS0xMCkge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHQgKz0gZHggLyBjYnhkO1xuICAgICAgfVxuICAgICAgbGV0IG1pblQgPSAwO1xuICAgICAgbGV0IG1heFQgPSAxO1xuICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgIHQgPSAwLjUgKiAobWluVCArIG1heFQpO1xuICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuICAgICAgICBkeCA9IHRpbWUgLSBjYng7XG4gICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChkeCA8IDApIHtcbiAgICAgICAgICBtYXhUID0gdDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBtaW5UID0gdDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH07XG4gIH1cbiAgc3RhdGljIGdldFRpbWluZ0Z1bmN0aW9uKHN0cikge1xuICAgIHN3aXRjaCAoc3RyKSB7XG4gICAgICBjYXNlIFwibGluZWFyXCI6XG4gICAgICAgIHJldHVybiBmdW5jdGlvbih0aW1lKSB7XG4gICAgICAgICAgcmV0dXJuIHRpbWU7XG4gICAgICAgIH07XG4gICAgICBjYXNlIFwiZWFzZVwiOlxuICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC4yNSwgMC4xLCAwLjI1LCAxKTtcbiAgICAgIGNhc2UgXCJlYXNlLWluXCI6XG4gICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjQyLCAwLCAxLCAxK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xuICAgICAgICBsZXQgYW1vdW50UGVyU2hyaW5rID0gdGhpcy5fYW1vdW50UmVtYWluaW5nIC8gdG90YWxTaHJpbmtBbW91bnQ7XG4gICAgICAgIGZvciAobGV0IGkgPSB0aGlzLl9saW5lLnN0YXJ0SW5kZXg7IGkgPD0gdGhpcy5fbGluZS5lbmRJbmRleDsgaSsrKSB7XG4gICAgICAgICAgY29uc3QgaXRlbSA9IGl0ZW1zW2ldO1xuICAgICAgICAgIGNvbnN0IGZsZXhJdGVtID0gaXRlbS5mbGV4SXRlbTtcbiAgICAgICAgICBjb25zdCBzaHJpbmtBbW91bnQgPSBmbGV4SXRlbS5zaHJpbms7XG4gICAgICAgICAgY29uc3QgaXNTaHJpbmthYmxlSXRlbSA9IHNocmlua0Ftb3VudCA+IDA7XG4gICAgICAgICAgaWYgKGlzU2hyaW5rYWJsZUl0ZW0pIHtcbiAgICAgICAgICAgIGxldCBzaHJpbmsgPSBzaHJpbmtBbW91bnQgKiBhbW91bnRQZXJTaHJpbms7XG4gICAgICAgICAgICBjb25zdCBtaW5TaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWluU2l6ZSgpO1xuICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICAgIGlmIChzaXplID4gbWluU2l6ZSkge1xuICAgICAgICAgICAgICBjb25zdCBtYXhTaHJpbmsgPSBzaXplIC0gbWluU2l6ZTtcbiAgICAgICAgICAgICAgY29uc3QgaXNGdWxseVNocnVuayA9IHNocmluayA+PSBtYXhTaHJpbms7XG4gICAgICAgICAgICAgIGlmIChpc0Z1bGx5U2hydW5rKSB7XG4gICAgICAgICAgICAgICAgc2hyaW5rID0gbWF4U2hyaW5rO1xuICAgICAgICAgICAgICAgIHRvdGFsU2hyaW5rQW1vdW50IC09IHNocmlua0Ftb3VudDtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBjb25zdCBma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ftb3VudCAqIGFtb3VudFBlckdyb3c7XG4gICAgICAgICAgICBjb25zdCBtYXhTaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWF4U2l6ZVNldHRpbmcoKTtcbiAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCk7XG4gICAgICAgICAgICBpZiAobWF4U2l6ZSA+IDApIHtcbiAgICAgICAgICAgICAgaWYgKHNpemUgPj0gbWF4U2l6ZSkge1xuICAgICAgICAgICAgICAgIGdyb3cgPSAwO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnN0IG1heEdyb3cgPSBtYXhTaXplIC0gc2l6ZTtcbiAgICAgICAgICAgICAgICBjb25zdCBpc0Z1bGx5R3Jvd24gPSBncm93ID49IG1heEdyb3c7XG4gICAgICAgICAgICAgICAgaWYgKGlzRnVsbHlHcm93bikge1xuICAgICAgICAgICAgICAgICAgZ3JvdyA9IG1heEdyb3c7XG4gICAgICAgICAgICAgICAgICB0b3RhbEdyb3dBbW91bnQgLT0gZ3Jvd0Ftb3VudDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChncm93ID4gMCkge1xuICAgICAgICAgICAgICBjb25zdCBmaW5hbFNpemUgPSBzaXplICsgZ3JvdztcbiAgICAgICAgICAgICAgZmxleEl0ZW0uX3Jlc2l6ZU1haW5BeGlzKGZpbmFsU2l6ZSk7XG4gICAgICAgICAgICAgIHRoaXMuX2dyb3duU2l6ZSArPSBncm93O1xuICAgICAgICAgICAgICB0aGlzLl9hbW91bnRSZW1haW5pbmcgLT0gZ3JvdztcbiAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPCAxZS01KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICB9XG4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hbGlnbkl0ZW1zLCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuQUxJR05fSVRFTVMuam9pbihcIixcIikpO1xuICAgIH1cbiAgICB0aGlzLl9hbGlnbkl0ZW1zID0gdjtcbiAgICB0aGlzLl9jaGFuZ2VkQ29udGVudHMoKTtcbiAgfVxuICBnZXQgYWxpZ25Db250ZW50KCkge1xuICAgIHJldHVybiB0aGlzLl9hbGlnbkNvbnRlbnQ7XG4gIH1cbiAgc2V0IGFsaWduQ29udGVudCh2KSB7XG4gICAgaWYgKHRoaXMuX2FsaWduQ29udGVudCA9PT0gdilcbiAgICAgIHJldHVybjtcbiAgICBpZiAoRmxleENvbnRhaW5lci5BTElHTl9DT05URU5ULmluZGV4T2YodikgPT09IC0xKSB7XG4gICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIGFsaWduQ29udGVudCwgb3B0aW9uczogXCIgKyBGbGV4Q29udGFpbmVyLkFMSUdOX0NPTlRFTlQuam9pbihcIixcIikpO1xuICAgIH1cbiAgICB0aGlzLl9hbGlnbkNvbnRlbnQgPSB2O1xuICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICB9XG4gIGdldCBqdXN0aWZ5Q29udGVudCgpIHtcbiAgICByZXR1cm4gdGhpcy5fanVzdGlmeUNvbnRlbnQ7XG4gIH1cbiAgc2V0IGp1c3RpZnlDb250ZW50KHYpIHtcbiAgICBpZiAodGhpcy5fanVzdGlmeUNvbnRlbnQgPT09IHYpXG4gICAgICByZXR1cm47XG4gICAgaWYgKEZsZXhDb250YWluZXIuSlVTVElGWV9DT05URU5ULmluZGV4T2YodikgPT09IC0xKSB7XG4gICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIGp1c3RpZnlDb250ZW50LCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuSlVTVElGWV9DT05URU5ULmpvaW4oXCIsXCIpKTtcbiAgICB9XG4gICAgdGhpcy5fanVzdGlmeUNvbnRlbnQ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RoaXMuX3BhcmVudCkge1xuICAgICAgICB0aGlzLl9wYXJlbnQuX3NldEhhc1VwZGF0ZXMoKTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgdGhpcy5zZXRaUGFyZW50KHBhcmVudCk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLnNldFpQYXJlbnQocGFyZW50ID8gcGFyZW50LmZpbmRaQ29udGV4dCgpIDogbnVsbCk7XG4gICAgICB9XG4gICAgICBpZiAocHJldklzWkNvbnRleHQgIT09IHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgIGlmICghdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICB0aGlzLmRpc2FibGVaQ29udGV4dCgpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuZW5hYmxlWkNvbnRleHQocHJldlBhcmVudC5maW5kWkNvbnRleHQoKSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICB9XG4gICAgICBpZiAoIXRoaXMuX3NoYWRlcikge1xuICAgICAgICBsZXQgbmV3U2hhZGVyT3duZXIgPSBwYXJlbnQgJiYgIXBhcmVudC5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCA/IHBhcmVudC5fc2hhZGVyT3duZXIgOiBudWxsO1xuICAgICAgICBpZiAobmV3U2hhZGVyT3duZXIgIT09IHRoaXMuX3NoYWRlck93bmVyKSB7XG4gICAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKDEpO1xuICAgICAgICAgIHRoaXMuX3NldFNoYWRlck93bmVyUmVjdXJzaXZlKG5ld1NoYWRlck93bmVyKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH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YgKHRoaXMuX3BhcmVudCA9PT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICB0aGlzLl96UGFyZW50LmRlY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbmV3WlBhcmVudCA9IHRoaXMuX3BhcmVudDtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIGlmICh6SW5kZXggIT09IDAgJiYgdGhpcy5fekluZGV4ID09PSAwKSB7XG4gICAgICAgIG5ld1pQYXJlbnQgPSB0aGlzLl9wYXJlbnQgPyB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkgOiBudWxsO1xuICAgICAgICBpZiAobmV3WlBhcmVudCA9PT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICB0aGlzLl96UGFyZW50LmluY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSBpZiAoekluZGV4ICE9PSB0aGlzLl96SW5kZXgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQgJiYgdGhpcy5felBhcmVudC5fekNvbnRleHRVc2FnZSkge1xuICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgdGhpcy5zZXRaUGFyZW50KG51bGwpO1xuICAgICAgfVxuICAgICAgdGhpcy5fekluZGV4ID0gekluZGV4O1xuICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgdGhpc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XNpYmxlKSB7XG4gICAgICAgICAgdGhpcy5faGFzUmVuZGVyVXBkYXRlcyA9IDM7XG4gICAgICAgIH1cbiAgICAgICAgdy5hbHBoYSA9IHB3LmFscGhhICogdGhpcy5fbG9jYWxBbHBoYTtcbiAgICAgICAgaWYgKHcuYWxwaGEgPCAxZS0xNCkge1xuICAgICAgICAgIHcuYWxwaGEgPSAwO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAocmVjYWxjICYgNikge1xuICAgICAgICB3LnB4ID0gcHcucHggKyB0aGlzLl9sb2NhbFB4ICogcHcudGE7XG4gICAgICAgIHcucHkgPSBwdy5weSArIHRoaXMuX2xvY2FsUHkgKiBwdy50ZDtcbiAgICAgICAgaWYgKHB3LnRiICE9PSAwKVxuICAgICAgICAgIHcucHggKz0gdGhpcy5fbG9jYWxQeSAqIHB3LnRiO1xuICAgICAgICBpZiAocHcudGMgIT09IDApXG4gICAgICAgICAgdy5weSArPSB0aGlzLl9sb2NhbFB4ICogcHcudGM7XG4gICAgICB9XG4gICAgICBpZiAocmVjYWxjICYgNCkge1xuICAgICAgICB3LnRhID0gdGhpcy5fbG9jYWxUYSAqIHB3LnRhO1xuICAgICAgICB3LnRiID0gdGhpcy5fbG9jYWxUZCAqIHB3LnRiO1xuICAgICAgICB3LnRjID0gdGhpcy5fbG9jYWxUYSAqIHB3LnRjO1xuICAgICAgICB3LnRkID0gdGhpcy5fbG9jYWxUZCAqIHB3LnRkO1xuICAgICAgICBpZiAodGhpcy5faXNDb21wbGV4KSB7XG4gICAgICAgICAgdy50YSArPSB0aGlzLl9sb2NhbFRjICogcHcudGI7XG4gICAgICAgICAgdy50YiArPSB0aGlzLl9sb2NhbFRiICogcHcudGE7XG4gICAgICAgICAgdy50YyArPSB0aGlzLl9sb2NhbFRjICogcHcudGQ7XG4gICAgICAgICAgdy50ZCArPSB0aGlzLl9sb2NhbFRiICogcHcudGM7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGNvbnN0IHByID0gdGhpcy5fcGFyZW50Ll9yZW5kZXJDb250ZXh0O1xuICAgICAgaWYgKHRoaXMuX3BhcmVudC5faGFzUmVuZGVyQ29udGV4dCgpKSB7XG4gICAgICAgIGNvbnN0IGluaXQgPSB0aGlzLl9yZW5kZXJDb250ZXh0ID09PSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICAgIGlmIChpbml0KSB7XG4gICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IG5ldyBFbGVtZW50Q29yZUNvbnRleHQoKTtcbiAgICAgICAgfVxuICAgICAgICBjb25zdCByMiA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICAgIGlmIChpbml0IHx8IHJlY2FsYyAmIDEpIHtcbiAgICAgICAgICByMi5hbHBoYSA9IHByLmFscGhhICogdGhpcy5fbG9jYWxBbHBoYTtcbiAgICAgICAgICBpZiAocjIuYWxwaGEgPCAxZS0xNCkge1xuICAgICAgICAgICAgcjIuYWxwaGEgPSAwO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoaW5pdCB8fCByZWNhbGMgJiA2KSB7XG4gICAgICAgICAgcjIucHggPSBwci5weCArIHRoaXMuX2xvY2FsUHggKiBwci50YTtcbiAgICAgICAgICByMi5weSA9IHByLnB5ICsgdGhpcy5fbG9jYWxQeSAqIHByLnRkO1xuICAgICAgICAgIGlmIChwci50YiAhPT0gMClcbiAgICAgICAgICAgIHIyLnB4ICs9IHRoaXMuX2xvY2FsUHkgKiBwci50YjtcbiAgICAgICAgICBpZiAocHIudGMgIT09IDApXG4gICAgICAgICAgICByMi5weSArPSB0aGlzLl9sb2NhbFB4ICogcHIudGM7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGluaXQpIHtcbiAgICAgICAgICByZWNhbGMgfD0gMjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaW5pdCB8fCByZWNhbGMgJiA0KSB7XG4gICAgICAgICAgcjIudGEgPSB0aGlzLl9sb2NhbF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w9IDIgKyA0O1xuICAgICAgICByZWNhbGMgfD0gMjtcbiAgICAgICAgaWYgKCF0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnJlbGVhc2UoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgdGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlID0gdXNlUmVuZGVyVG9UZXh0dXJlO1xuICAgICAgY29uc3QgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICBjb25zdCBiYm94VyA9IHRoaXMuX2RpbXNVbmtub3duID8gMjA0OCA6IHRoaXMuX3c7XG4gICAgICBjb25zdCBiYm94SCA9IHRoaXMuX2RpbXNVbmtub3duID8gMjA0OCA6IHRoaXMuX2g7XG4gICAgICBsZXQgc3gsIHN5LCBleCwgZXk7XG4gICAgICBjb25zdCByQ29tcGxleCA9IHIudGIgIT09IDAgfHwgci50YyAhPT0gMCB8fCByLnRhIDwgMCB8fCByLnRkIDwgMDtcbiAgICAgIGlmIChyQ29tcGxleCkge1xuICAgICAgICBzeCA9IE1hdGgubWluKDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgZXggPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgIHN5ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICBleSA9IE1hdGgubWF4KDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHN4ID0gci5weDtcbiAgICAgICAgZXggPSByLnB4ICsgci50YSAqIGJib3hXO1xuICAgICAgICBzeSA9IHIucHk7XG4gICAgICAgIGV5ID0gci5weSArIHIudGQgKiBiYm94SDtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9kaW1zVW5rbm93biAmJiAockNvbXBsZXggfHwgdGhpcy5fbG9jYWxUYSA8IDEgfHwgdGhpcy5fbG9jYWxUYiA8IDEpKSB7XG4gICAgICAgIGNvbnN0IG54ID0gdGhpcy5feCAqIHByLnRhICsgdGhpcy5feSAqIHByLnRiICsgcHIucHg7XG4gICAgICAgIGNvbnN0IG55ID0gdGhpcy5feCAqIHByLnRjICsgdGhpcy5feSAqIHByLnRkICsgcHIucHk7XG4gICAgICAgIGlmIChueCA8IHN4KVxuICAgICAgICAgIHN4ID0gbng7XG4gICAgICAgIGlmIChueSA8IHN5KVxuICAgICAgICAgIHN5ID0gbnk7XG4gICAgICAgIGlmIChueCA+IGV4KVxuICAgICAgICAgIGV4ID0gbng7XG4gICAgICAgIGlmIChueSA+IGV5KVxuICAgICAgICAgIGV5ID0gbnk7XG4gICAgICB9XG4gICAgICBpZiAocmVjYWxjICYgNiB8fCAhdGhpcy5fc2Npc3Nvcikge1xuICAgICAgICBpZiAodGhpcy5fY2xpcHBpbmcgJiYgci5pc1NxdWFyZSgpKSB7XG4gICAgICAgICAgY29uc3QgYXJlYSA9IHRoaXMuX3BhcmVudC5fdXNlUmVuZGVyVG9UZXh0dXJlID8gdGhpcy5fcGFyZW50Ll92aWV3cG9ydCA6IHRoaXMuX3BhcmVudC5fc2Npc3NvcjtcbiAgICAgICAgICBpZiAoYXJlYSkge1xuICAgICAgICAgICAgY29uc3QgbHggPSBNYXRoLm1heChhcmVhWzBdLCBzeCk7XG4gICAgICAgICAgICBjb25zdCBseSA9IE1hdGgubWF4KGFyZWFbMV0sIHN5KTtcbiAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBbXG4gICAgICAgICAgICAgIGx4LFxuICAgICAgICAgICAgICBseSxcbiAgICAgICAgICAgICAgTWF0aC5taW4oYXJlYVsyXSArIGFyZWFbMF0sIGV4KSAtIGx4LFxuICAgICAgICAgICAgICBNYXRoLm1pbihhcmVhWzNdICsgYXJlYVsxXSwgZXkpIC0gbHlcbiAgICAgICAgICAgIF07XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBbc3gsIHN5LCBleCAtIHN4LCBleSAtIHN5XTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fc2Npc3NvciA9IHRoaXMuX3BhcmVudC5fdXNlUmVuZGVyVG9UZXh0dXJlID8gdGhpcy5fcGFyZW50Ll92aWV3cG9ydCA6IHRoaXMuX3BhcmVudC5fc2Npc3NvcjtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX2JvdW5kc01hcmdpbikge1xuICAgICAgICB0aGlzLl9yZWNCb3VuZHNNYXJnaW4gPSB0aGlzLl9ib3VuZHNNYXJnaW47XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLl9yZWNCb3VuZHNNYXJnaW4gPSB0aGlzLl9wYXJlbnQuX3JlY0JvdW5kc01hcmdpbjtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9vbkFmdGVyQ2FsY3MpIHtcbiAgICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJDYWxjcyh0aGlzLmVsZW1lbnQpKSB7XG4gICAgICAgICAgaWYgKHJDb21wbGV4KSB7XG4gICAgICAgICAgICBzeCA9IE1hdGgubWluKDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgIGV4ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgc3kgPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgICBleSA9IE1hdGgubWF4KDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3ggPSByLnB4O1xuICAgICAgICAgICAgZXggPSByLnB4ICsgci50YSAqIGJib3hXO1xuICAgICAgICAgICAgc3kgPSByLnB5O1xuICAgICAgICAgICAgZXkgPSByLnB5ICsgci50ZCAqIGJib3hIO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodGhpcy5fZGltc1Vua25vd24gJiYgKHJDb21wbGV4IHx8IHRoaXMuX2xvY2FsVGEgPCAxIHx8IHRoaXMuX2xvY2FsVGIgPCAxKSkge1xuICAgICAgICAgICAgY29uc3QgbnggPSB0aGlzLl94ICogcHIudGEgKyB0aGlzLl95ICogcHIudGIgKyBwci5weDtcbiAgICAgICAgICAgIGNvbnN0IG55ID0gdGhpcy5feCAqIHByLnRjICsgdGhpcy5feSAqIHByLnRkICsgcHIucHk7XG4gICAgICAgICAgICBpZiAobnggPCBzeClcbiAgICAgICAgICAgICAgc3ggPSBueDtcbiAgICAgICAgICAgIGlmIChueSA8IHN5KVxuICAgICAgICAgICAgICBzeSA9IG55O1xuICAgICAgICAgICAgaWYgKG54ID4gZXgpXG4gICAgICAgICAgICAgIGV4ID0gbng7XG4gICAgICAgICAgICBpZiAobnkgPiBleSlcbiAgICAgICAgICAgICAgZXkgPSBueTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9wYXJlbnQuX291dE9mQm91bmRzID09PSAyKSB7XG4gICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcbiAgICAgICAgaWYgKHRoaXMuX3dpdGhpbkJv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uZHMgPSAxO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gIT09IHdpdGhpbk1hcmdpbikge1xuICAgICAgICAgICAgdGhpcy5fd2l0aGluQm91bmRzTWFyZ2luID0gd2l0aGluTWFyZ2luO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICB0aGlzLl9oYXNVcGRhdGVzID0gdHJ1ZTtcbiAgICAgICAgICAgICAgY29uc3QgcmVjYWxjMiA9IHRoaXMuX3JlY2FsYztcbiAgICAgICAgICAgICAgdGhpcy5fcmVjYWxjID0gMDtcbiAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9lbmFibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcbiAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlY2FsYykge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnVwZGF0ZSgpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHRoaXMuX3JlY2FsYyA9IHJlY2FsYzI7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2Rpc2FibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgaWYgKHRoaXMuX3ZpZXdwb3J0KSB7XG4gICAgICAgICAgdGhpcy5fdmlld3BvcnRbMl0gPSBiYm94VztcbiAgICAgICAgICB0aGlzLl92aWV3cG9ydFszXSA9IGJib3hIO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0ID0gWzAsIDAsIGJib3hXLCBiYm94SF07XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHRoaXMuX3BSZWNhbGMgPSB0aGlzLl9yZWNhbGMgJiAxMzU7XG4gICAgICB0aGlzLl9yZWNhbGMgPSAwO1xuICAgICAgdGhpcy5faGFzVXBkYXRlcyA9IGZhbHNlO1xuICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzIDwgMikge1xuICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3dvcmxkQ29udGV4dC5pc0lkZW50aXR5KCkpIHtcbiAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBFbGVtZW50Q29yZUNvbnRleHQuSURFTlRJVFk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGUoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSByO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuW2ldLl9oYXNVcGRhdGVzKSB7XG4gICAgICAgICAgICAg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JiByZW5kZXJUZXh0dXJlSW5mby5jYWNoZSkge1xuICAgICAgICByZW5kZXJTdGF0ZS5pc0NhY2hpbmdUZXh0dXJpemVyID0gZmFsc2U7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIGdldCB6U29ydCgpIHtcbiAgICByZXR1cm4gdGhpcy5felNvcnQ7XG4gIH1cbiAgc29ydFpJbmRleGVkQ2hpbGRyZW4oKSB7XG4gICAgY29uc3QgbiA9IHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4ubGVuZ3RoO1xuICAgIGxldCBwdHIgPSAwO1xuICAgIGNvbnN0IGEgPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuO1xuICAgIGNvbnN0IGIgPSBbXTtcbiAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgaWYgKGFbaV0uX3pQYXJlbnQgPT09IHRoaXMpIHtcbiAgICAgICAgaWYgKGFbaV0uX3pJbmRleFJlc29ydCkge1xuICAgICAgICAgIGIucHVzaChhW2ldKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAocHRyICE9PSBpKSB7XG4gICAgICAgICAgICBhW3B0cl0gPSBhW2ldO1xuICAgICAgICAgIH1cbiAgICAgICAgICBwdHIrKztcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBjb25zdCBtID0gYi5sZW5ndGg7XG4gICAgaWYgKG0pIHtcbiAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbTsgaisrKSB7XG4gICAgICAgIGJbal0uX3pJbmRleFJlc29ydCA9IGZhbHNlO1xuICAgICAgfVxuICAgICAgYi5zb3J0KEVsZW1lbnRDb3JlLnNvcnRaSW5kZXhlZENoaWxkcmVuKTtcbiAgICAgIGNvbnN0IG4yID0gcHRyO1xuICAgICAgaWYgKCFuMikge1xuICAgICAgICBwdHIgPSAwO1xuICAgICAgICBsZXQgaiA9IDA7XG4gICAgICAgIGRvIHtcbiAgICAgICAgICBhW3B0cisrXSA9IGJbaisrXTtcbiAgICAgICAgfSB3aGlsZSAoaiA8IG0pO1xuICAgICAgICBpZiAoYS5sZW5ndGggPiBwdHIpIHtcbiAgICAgICAgICBhLnNwbGljZShwdHIpO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBwdHIgPSAwO1xuICAgICAgICBsZXQgaSA9IDA7XG4gICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgY29uc3QgbWVyZ2VSZXN1bHQgPSBbXTtcbiAgICAgICAgZG8ge1xuICAgICAgICAgIGNvbnN0IHYgPSBhW2ldLl96SW5kZXggPT09IGJbal0uX3pJbmRleCA/IGFbaV0uX3VwZGF0ZVRyZWVPcmRlciAtIGJbal0uX3VwZGF0ZVRyZWVPcmRlciA6IGFbaV0uX3pJbmRleCAtIGJbal0uX3pJbmRleDtcbiAgICAgICAgICBjb25zdCBhZGQgPSB2ID4gMCA/IGJbaisrXSA6IGFbaSsrXTtcbiAgICAgICAgICBpZiAocHRyID09PSAwIHx8IG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQpIHtcbiAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGkgPj0gbjIpIHtcbiAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgY29uc3QgYWRkMiA9IGJbaisrXTtcbiAgICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCBtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkMikge1xuICAgICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDI7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUgKGogPCBtKTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH0gZWxzZSBpZiAoaiA+PSBtKSB7XG4gICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgIGNvbnN0IGFkZDIgPSBh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iB0aGlzLl90ZXh0dXJpemVyO1xuICB9XG4gIGdldENvcm5lclBvaW50cygpIHtcbiAgICBsZXQgdyA9IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICByZXR1cm4gW1xuICAgICAgdy5weCxcbiAgICAgIHcucHksXG4gICAgICB3LnB4ICsgdGhpcy5fdyAqIHcudGEsXG4gICAgICB3LnB5ICsgdGhpcy5fdyAqIHcudGMsXG4gICAgICB3LnB4ICsgdGhpcy5fdyAqIHcudGEgKyB0aGlzLl9oICogdy50YixcbiAgICAgIHcucHkgKyB0aGlzLl93ICogdy50YyArIHRoaXMuX2ggKiB3LnRkLFxuICAgICAgdy5weCArIHRoaXMuX2ggKiB3LnRiLFxuICAgICAgdy5weSArIHRoaXMuX2ggKiB3LnRkXG4gICAgXTtcbiAgfVxuICBnZXRSZW5kZXJUZXh0dXJlQ29vcmRzKHJlbFgsIHJlbFkpIHtcbiAgICBsZXQgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgcmV0dXJuIFtcbiAgICAgIHIucHggKyByLnRhICogcmVsWCArIHIudGIgKiByZWxZLFxuICAgICAgci5weSArIHIudGMgKiByZWxYICsgci50ZCAqIHJlbFlcbiAgICBdO1xuICB9XG4gIGdldEFic29sdXRlQ29vcmRzKHJlbFgsIHJlbFkpIHtcbiAgICBsZXQgdyA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgcmV0dXJuIFtcbiAgICAgIHcucHggKyB3LnRhICogcmVsWCArIHcudGIgKiByZWxZLFxuICAgICAgdy5weSArIHcudGMgKiByZWxYICsgdy50ZCAqIHJlbFlcbiAgICBdO1xuICB9XG4gIGNvbGxlY3RBdENvb3JkKHgsIHksIGNoaWxkcmVuKSB7XG4gICAgaWYgKHRoaXMuX3JlbmRlckNvbnRleHQuYWxwaGEgPT09IDApIHtcbiAgICAgIHJldHVybjtcbiAgICB9XG4gICAgaWYgKHRoaXMuaW5Cb3VuZCh4LCB5KSkge1xuICAgICAgaWYg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Jlc2l6ZU1vZGUpIHtcbiAgICAgICAgICAgIHRoaXMuX2FwcGx5UmVzaXplTW9kZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goKGVsZW1lbnQpID0+IHtcbiAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICBlbGVtZW50Ll9zZXREaXNwbGF5ZWRUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnN0IGxvYWRFcnJvciA9IG5ld1NvdXJjZS5sb2FkRXJyb3I7XG4gICAgICAgICAgaWYgKGxvYWRFcnJvcikge1xuICAgICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKChlbGVtZW50KSA9PiB7XG4gICAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgIGVsZW1lbnQub25UZXh0dXJlU291cmNlTG9hZEVycm9yKGxvYWRFcnJvcik7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKChlbGVtZW50KSA9PiB7XG4gICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICBlbGVtZW50Ll9zZXREaXNwbGF5ZWRUZXh0dXJlKG51bGwpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIGxvYWQoKSB7XG4gICAgaWYgKHRoaXMuc291cmNlKSB7XG4gICAgICBpZiAoIXRoaXMuaXNMb2FkZWQoKSkge1xuICAgICAgICB0aGlzLnNvdXJjZS5sb2FkKHRydWUpO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICBpc0xvYWRl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XMuZ2V0UHJlY2lzaW9uKCksXG4gICAgICAgIHRoaXMuX3N0YWdlLmdldE9wdGlvbihcImRlZmF1bHRGb250RmFjZVwiKVxuICAgICAgKTtcbiAgICAgIHRyeSB7XG4gICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmZvbnRzLmxvYWQoZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpLmNhdGNoKChlcnIpID0+IHtcbiAgICAgICAgICAgIGNvbnNvbGUud2FybihcIkZvbnQgbG9hZCBlcnJvclwiLCBlcnIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICB9KS50aGVuKCgpID0+IHtcbiAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIkZvbnQgbm90IGZvdW5kXCIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICBjb25zb2xlLndhcm4oXCJDYW4ndCBjaGVjayBmb250IGxvYWRpbmcgZm9yIFwiICsgZm9udFNldHRpbmcpO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICBkcmF3KCkge1xuICAgIGNvbnN0IGxvYWRQcm9taXNlID0gdGhpcy5fbG9hZCgpO1xuICAgIGlmICghbG9hZFByb21pc2UpIHtcbiAgICAgIHJldHVybiBVdGlscyQxLmlzU3BhcmsgPyB0aGlzLl9zdGFnZS5wbGF0Zm9ybS5kcmF3VGV4dCh0aGlzKSA6IHRoaXMuX2RyYXcoKTtcbiAgICB9IGVsc2Uge1xuICAgICAgcmV0dXJuIGxvYWRQcm9taXNlLnRoZW4o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c2V0dGluZ3MudGV4dE92ZXJmbG93O1xuICAgICAgfVxuICAgICAgdGV4dCA9IHRoaXMud3JhcFdvcmQodGV4dCwgd29yZFdyYXBXaWR0aCB8fCByZW5kZXJJbmZvLncsIHN1ZmZpeCk7XG4gICAgfVxuICAgIHRleHQgPSB0aGlzLnRva2VuaXplKHRleHQpO1xuICAgIHRleHQgPSB0aGlzLnBhcnNlKHRleHQpO1xuICAgIHRleHQgPSB0aGlzLm1lYXN1cmUodGV4dCwgbGV0dGVyU3BhY2luZywgcmVuZGVySW5mby5iYXNlRm9udCk7XG4gICAgaWYgKHJlbmRlckluZm8udGV4dEluZGVudCkge1xuICAgICAgdGV4dCA9IHRoaXMuaW5kZW50KHRleHQsIHJlbmRlckluZm8udGV4dEluZGVudCk7XG4gICAgfVxuICAgIGlmIChyZW5kZXJJbmZvLndvcmRCcmVhaykge1xuICAgICAgdGV4dCA9IHRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYy5jb25jYXQodGhpcy53b3JkQnJlYWsodCwgd3JhcFdpZHRoLCByZW5kZXJJbmZvLmJhc2VGb250KSksIFtdKTtcbiAgICAgIHRoaXMucmVzZXRGb250U3R5bGUoKTtcbiAgICB9XG4gICAgbGV0IHggPSBwYWRkaW5nTGVmdDtcbiAgICBsZXQgbGluZU5vID0gMDtcbiAgICBmb3IgKGNvbnN0IHQgb2YgdGV4dCkge1xuICAgICAgaWYgKHJlbmRlckluZm8ud29yZFdyYXAgJiYgeCArIHQud2lkdGggPiB3cmFwV2lkdGggfHwgdC50ZXh0ID09IFwiXFxuXCIpIHtcbiAgICAgICAgeCA9IHBhZGRpbmdMZWZ0O1xuICAgICAgICBsaW5lTm8gKz0gMTtcbiAgICAgIH1cbiAgICAgIHQubGluZU5vID0gbGluZU5vO1xuICAgICAgaWYgKHQudGV4dCA9PSBcIlxcblwiKSB7XG4gICAgICAgIGNvbnRpbnVlO1xuICAgICAgfVxuICAgICAgdC54ID0geDtcbiAgICAgIHggKz0gdC53aWR0aDtcbiAgICB9XG4gICAgcmVuZGVySW5mby5saW5lTnVtID0gbGluZU5vICsgMTtcbiAgICBpZiAodGhpcy5fc2V0dGluZ3MuaCkge1xuICAgICAgcmVuZGVySW5mby5oID0gdGhpcy5fc2V0dGluZ3MuaDtcbiAgICB9IGVsc2UgaWYgKHJlbmRlckluZm8ubWF4TGluZXMgJiYgcmVuZGVySW5mby5tYXhMaW5lcyA8IHJlbmRlckluZm8ubGluZU51bSkge1xuICAgICAgcmVuZGVySW5mby5oID0gcmVuZGVySW5mby5tYXhMaW5lcyAqIHJlbmRlckluZm8ubGluZUhlaWdodCArIGZvbnRTaXplIC8gMjtcbiAgICB9IGVsc2Uge1xuICAgICAgcmVuZGVySW5mby5oID0gcmVuZGVySW5mby5saW5lTnVtICogcmVuZGVySW5mby5saW5lSGVpZ2h0ICsgZm9udFNpemUgLyAyO1xuICAgIH1cbiAgICBjb25zdCBiYXNlbGluZU9mZnNldEluUHggPSByZW5kZXJJbmZvLmZvbnRCYXNlbGluZVJhdGlvICogcmVuZGVySW5mby5mb250U2l6ZTtcbiAgICBsZXQgdmFPZmZzZXQgPSAwO1xuICAgIGlmIChyZW5kZXJJbmZvLnZlcnRpY2FsQWxpZ24gPT0gXCJ0b3BcIiAmJiB0aGlzLl9jb250ZXh0LnRleHRCYXNlbGluZSA9PSBcImFscGhhYmV0aWNcIikge1xuICAgICAgdmFPZmZzZXQgPSAtYmFzZWxpbmVPZmZzZXRJblB4O1xuICAgIH0gZWxzZSBpZiAocmVuZGVySW5mby52ZXJ0aWNhbEFsaWduID09IFwibWlkZGxlXCIpIHtcbiAgICAgIHZhT2Zmc2V0ID0gKHJlbmRlckluZm8ubGluZUhlaWdodCAtIHJlbmRlckluZm8uZm9udFNpemUgLSBiYXNlbGluZU9mZnNldEluUHgpIC8gMjtcbiAgICB9IGVsc2UgaWYgKHRoaXMuX3NldHRpbmdzLnZlcnRpY2FsQWxpZ24gPT0gXCJib3R0b21cIikge1xuICAgICAgdmFPZmZzZXQgPSByZW5kZXJJbmZvLmxpbmVIZWlnaHQgLSByZW5kZXJJbmZvLmZvbnRTaXplO1xuICAgIH1cbiAgICByZW5kZXJJbmZvLmxpbmVzID0gW107XG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCByZW5kZXJJbmZvLmxpbmVOdW07IGkrKykge1xuICAgICAgcmVuZGVySW5mby5saW5lc1tpXSA9IHtcbiAgICAgICAgd2lkdGg6IDAsXG4gICAgICAgIHg6IDAsXG4gICAgICAgIHk6IHJlbmRlckluZm8ubGluZUhlaWdodCAqIGkgKyB2YU9mZnNldCxcbiAgICAgICAgdGV4dDogW11cbiAgICAgIH07XG4gICAgfVxuICAgIGZvciAobGV0IHQgb2YgdGV4dCkge1xuICAgICAgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10udGV4dC5wdXNoKHQpO1xuICAgIH1cbiAgICBmb3IgKGNvbnN0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgaWYgKGwudGV4dC5sZW5ndGggPT0gMCkge1xuICAgICAgICBjb250aW51ZTtcbiAgICAgIH1cbiAgICAgIGNvbnN0IGZpcnN0V29yZCA9IGwudGV4dFswXS50ZXh0O1xuICAgICAgY29uc3QgbGFzdFdvcmQgPSBsLnRleHRbbC50ZXh0Lmxlbmd0aCAtIDFdLnRleHQ7XG4gICAgICBpZiAoZmlyc3RXb3JkID09IFwiXFxuXCIpIHtcbiAgICAgICAgbC50ZXh0LnNoaWZ0KCk7XG4gICAgICB9XG4gICAgICBpZiAoaXNTcGFjZShsYXN0V29yZCkgfHwgbGFzdFdvcmQgPT0gXCJcXG5cIikge1xuICAgICAgICBsLnRleHQucG9wKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgbC53aWR0aCA9IGwudGV4dC5yZWR1Y2UoKGFjYywgdCkgPT4gYWNjICsgdC53aWR0aCwgMCk7XG4gICAgfVxuICAgIHJlbmRl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JlbmRlckluZm8ud2lkdGggfHwgaXNTcGFjZShsYXN0TGluZVRleHRbbGFzdExpbmVUZXh0Lmxlbmd0aCAtIHNwbF0udGV4dCkpIHtcbiAgICAgICAgbGFzdExpbmVUZXh0LnNwbGljZShsYXN0TGluZVRleHQubGVuZ3RoIC0gc3BsLCAxKTtcbiAgICAgICAgX3cgPSBsYXN0TGluZVRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYyArIHQud2lkdGgsIDApO1xuICAgICAgICBpZiAobGFzdExpbmVUZXh0Lmxlbmd0aCA8IHNwbCkge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB0aGlzLmFsaWduTGluZShsYXN0TGluZVRleHQsIGxhc3RMaW5lVGV4dFswXS54KTtcbiAgICAgIHJlbmRlckluZm8ubGluZXNbaW5kZXhdLnRleHQgPSBsYXN0TGluZVRleHQ7XG4gICAgICByZW5kZXJJbmZvLmxpbmVzW2luZGV4XS53aWR0aCA9IF93O1xuICAgIH1cbiAgICBpZiAocmVuZGVySW5mby50ZXh0QWxpZ24gPT0gXCJjZW50ZXJcIikge1xuICAgICAgZm9yIChsZXQgbCBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgIGwueCA9IChyZW5kZXJJbmZvLndpZHRoIC0gbC53aWR0aCAtIHBhZGRpbmdMZWZ0KSAvIDI7XG4gICAgICB9XG4gICAgfSBlbHNlIGlmIChyZW5kZXJJbmZvLnRleHRBbGlnbiA9PSBcInJpZ2h0XCIpIHtcbiAgICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICBsLnggPSByZW5kZXJJbmZvLndpZHRoIC0gbC53aWR0aCAtIHBhZGRpbmdMZWZ0O1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gcmVuZGVySW5mbztcbiAgfVxuICBfZHJhdygpIHtcbiAgICBjb25zdCByZW5kZXJJbmZvID0gdGhpcy5fY2FsY3VsYXRl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CbHVyID0gdGhpcy5fc2V0dGluZ3Muc2hhZG93Qmx1ciAqIHByZWNpc2lvbjtcbiAgICB9XG4gICAgY29uc3QgZGVmYXVsdENvbG9yID0gU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHRoaXMuX3NldHRpbmdzLnRleHRDb2xvcik7XG4gICAgbGV0IGN1cnJlbnRDb2xvciA9IGRlZmF1bHRDb2xvcjtcbiAgICB0aGlzLl9jb250ZXh0LmZpbGxTdHlsZSA9IGRlZmF1bHRDb2xvcjtcbiAgICBmb3IgKGNvbnN0IGxpbmUgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgZm9yIChjb25zdCB0IG9mIGxpbmUudGV4dCkge1xuICAgICAgICBsZXQgbHggPSAwO1xuICAgICAgICBpZiAodC50ZXh0ID09IFwiXFxuXCIpIHtcbiAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocmVuZGVySW5mby5tYXhMaW5lcyAmJiB0LmxpbmVObyA+PSByZW5kZXJJbmZvLm1heExpbmVzKSB7XG4gICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHQuY29sb3IgIT0gY3VycmVudENvbG9yKSB7XG4gICAgICAgICAgY3VycmVudENvbG9yID0gdC5jb2xvcjtcbiAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxTdHlsZSA9IGN1cnJlbnRDb2xvcjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSB0LmZvbnRTdHlsZTtcbiAgICAgICAgaWYgKHQubGV0dGVycykge1xuICAgICAgICAgIGZvciAobGV0IGwgb2YgdC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICBjb25zdCBfeCA9IHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnggKyB0LnggKyBseDtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFRleHQobC50ZXh0LCBfeCwgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueSArIHJlbmRlckluZm8uZm9udFNpemUpO1xuICAgICAgICAgICAgbHggKz0gbC53aWR0aDtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgY29uc3QgX3ggPSByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS54ICsgdC54O1xuICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFRleHQodC50ZXh0LCBfeCwgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueSArIHJlbmRlckluZm8uZm9udFNpemUpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGlmIChwcmV2U2hhZG93U2V0dGluZ3MpIHtcbiAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Q29sb3IgPSBwcmV2U2hhZG93U2V0dGluZ3NbMF07XG4gICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFggPSBwcmV2U2hhZG93U2V0dGluZ3NbMV07XG4gICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFkgPSBwcmV2U2hhZG93U2V0dGluZ3NbMl07XG4gICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0JsdXIgPSBwcmV2U2hhZG93U2V0dGluZ3NbM107XG4gICAgfVxuICAgIGlmIChyZW5kZXJJbmZvLmN1dFN4IHx8IHJlbmRlckluZm8uY3V0U3kpIHtcbiAgICAgIHRoaXMuX2NvbnRleHQudHJhbnNsYXRlKHJlbmRlckluZm8uY3V0U3gsIHJlbmRlckluZm8uY3V0U3kpO1xuICAgIH1cbiAgICByZW5kZXJJbmZvLmxpbmVzID0gcmVuZGVySW5mby5saW5lcy5tYXAoKGwpID0+IGwudGV4dC5yZWR1Y2UoKGFjYywgdikgPT4gYWNjICsgdi50ZXh0LCBcIlwiKSk7XG4gICAgaWYgKHJlbmRlckluZm8ubWF4TGluZXMpIHtcbiAgICAgIHJlbmRlckluZm8ubGluZXMgPSByZW5kZXJJbmZvL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leCA9PT0gdGV4dC5sZW5ndGgpIHtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICB0ZXh0ID0gdGV4dC5zbGljZShicmVha0luZGV4KTtcbiAgICAgIH1cbiAgICB9IGVsc2Uge1xuICAgICAgbGV0IHRvdGFsV2lkdGggPSAwO1xuICAgICAgbGV0IGxldHRlcnMgPSBbXTtcbiAgICAgIGxldCBicmVha0luZGV4ID0gMDtcbiAgICAgIGZvciAoY29uc3QgbCBvZiB3b3JkLmxldHRlcnMpIHtcbiAgICAgICAgaWYgKHRvdGFsV2lkdGggKyBsLndpZHRoID49IHdpZHRoKSB7XG4gICAgICAgICAgcGFydHMucHVzaCh7IC4uLndvcmQgfSk7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0udGV4dCA9IHRleHQuc2xpY2UoMCwgYnJlYWtJbmRleCk7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ud2lkdGggPSB0b3RhbFdpZHRoO1xuICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLmxldHRlcnMgPSBsZXR0ZXJzO1xuICAgICAgICAgIHRleHQgPSB0ZXh0LnNsaWNlKGJyZWFrSW5kZXgpO1xuICAgICAgICAgIHRvdGFsV2lkdGggPSAwO1xuICAgICAgICAgIGxldHRlcnMgPSBbXTtcbiAgICAgICAgICBicmVha0luZGV4ID0gMDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBicmVha0luZGV4ICs9IDE7XG4gICAgICAgICAgbGV0dGVycy5wdXNoKGwpO1xuICAgICAgICAgIHRvdGFsV2lkdGggKz0gbC53aWR0aDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHRvdGFsV2lkdGggPiAwKSB7XG4gICAgICAgIHBhcnRzLnB1c2goeyAuLi53b3JkIH0pO1xuICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5z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HYuaXNUZXh0dXJlKSB7XG4gICAgICAgIHRleHR1cmUgPSB2O1xuICAgICAgfSBlbHNlIGlmICh2LmlzVGV4dHVyZVNvdXJjZSkge1xuICAgICAgICB0ZXh0dXJlID0gbmV3IFNvdXJjZVRleHR1cmUodGhpcy5zdGFnZSk7XG4gICAgICAgIHRleHR1cmUudGV4dHVyZVNvdXJjZSA9IHY7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBjb25zb2xlLmVycm9yKFwiW0xpZ2h0bmluZ10gUGxlYXNlIHNwZWNpZnkgYSB0ZXh0dXJlIHR5cGUuXCIpO1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG4gICAgfVxuICAgIGNvbnN0IHByZXZUZXh0dXJlID0gdGhpcy5fX3RleHR1cmU7XG4gICAgaWYgKHRleHR1cmUgIT09IHByZXZUZXh0dXJlKSB7XG4gICAgICB0aGlzLl9fdGV4dHVyZSA9IHRleHR1cmU7XG4gICAgICBpZiAodGhpcy5fX3RleHR1cmUpIHtcbiAgICAgICAgaWYgKHRoaXMuX19lbmFibGVkKSB7XG4gICAgICAgICAgdGhpcy5fX3RleHR1cmUuYWRkRWxlbWVudCh0aGlzKTtcbiAgICAgICAgICBpZiAodGhpcy53aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZS5pc0xvYWRlZCgpKSB7XG4gICAgICAgICAgICAgIHRoaXMuX3NldERpc3BsYXllZFRleHR1cmUodGhpcy5fX3RleHR1cmUpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgdGhpcy5fZW5hYmxlVGV4dHVyZUVycm9yKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLl9zZXREaXNwbGF5ZWRUZXh0dXJlKG51bGwpO1xuICAgICAgfVxuICAgICAgaWYgKHByZXZUZXh0dXJlICYmIHByZXZUZ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XkodGhpcy5fX3RyZWVUYWdzLmtleXMoKSk7XG4gICAgICAgIG4gPSB0YWdzLmxlbmd0aDtcbiAgICAgICAgaWYgKG4gPiAwKSB7XG4gICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGxldCB0YWdTZXQgPSB0aGlzLl9fdHJlZVRhZ3MuZ2V0KHRhZ3NbaV0pO1xuICAgICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgICAgd2hpbGUgKHAgPSBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgICAgIGxldCBwYXJlbnRUcmVlVGFncyA9IHAuX190cmVlVGFncy5nZXQodGFnc1tpXSk7XG4gICAgICAgICAgICAgIHRhZ1NldC5mb3JFYWNoKGZ1bmN0aW9uKGNvbXApIHtcbiAgICAgICAgICAgICAgICBwYXJlbnRUcmVlVGFncy5kZWxldGUoY29tcCk7XG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgfVxuICBfc2V0VGFnc1BhcmVudCgpIHtcbiAgICBpZiAodGhpcy5fX3RhZ3MpIHtcbiAgICAgIHRoaXMuX190YWdzLmZvckVhY2goKHRhZykgPT4ge1xuICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgIHdoaWxlIChwID0gcC5fX3BhcmVudCkge1xuICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSAvKiBAX19QVVJFX18gKi8gbmV3IE1hcCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgIHMgPSAvKiBAX19QVVJFX18gKi8gbmV3IFNldCgpO1xuICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzLmFkZCh0aGlzKTtcbiAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MgJiYgdGhpcy5fX3RyZWVUYWdzLnNpemUpIHtcbiAgICAgIGlmICghdGhpcy5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgdGhpcy5fX3RyZWVUYWdzLmZvckVhY2goKHRhZ1NldCwgdGFnKSA9PiB7XG4gICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgIHdoaWxlICghcC5fX3RhZ1Jvb3QgJiYgKHAgPSBwLl9fcGFyZW50KSkge1xuICAgICAgICAgICAgaWYgKHAuX190YWdSb290KVxuICAgICAgICAgICAgICA7XG4gICAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSAvKiBAX19QVVJFX18gKi8gbmV3IE1hcCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgICAgcyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgU2V0KCk7XG4gICAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRhZ1NldC5mb3JFYWNoKGZ1bmN0aW9uKGNvbXApIHtcbiAgICAgICAgICAgICAgcy5hZGQoY29tcCk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICA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T0gLTEpIHtcbiAgICAgIHRoaXMuX190YWdzLnB1c2godGFnKTtcbiAgICAgIGxldCBwID0gdGhpcy5fX3BhcmVudDtcbiAgICAgIGlmIChwKSB7XG4gICAgICAgIGRvIHtcbiAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICBzID0gLyogQF9fUFVSRV9fICovIG5ldyBTZXQoKTtcbiAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcy5hZGQodGhpcyk7XG4gICAgICAgIH0gd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKTtcbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgcmVtb3ZlVGFnKHRhZykge1xuICAgIGxldCBpID0gdGhpcy5fX3RhZ3MuaW5kZXhPZih0YWcpO1xuICAgIGlmIChpICE9PSAtMSkge1xuICAgICAgdGhpcy5fX3RhZ3Muc3BsaWNlKGksIDEpO1xuICAgICAgbGV0IHAgPSB0aGlzLl9fcGFyZW50O1xuICAgICAgaWYgKHApIHtcbiAgICAgICAgZG8ge1xuICAgICAgICAgIGxldCBsaXN0ID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgIGlmIChsaXN0KSB7XG4gICAgICAgICAgICBsaXN0LmRlbGV0ZSh0aGlzKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKTtcbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgaGFzVGFnKHRhZykge1xuICAgIHJldHVybiB0aGlzLl9fdGFncyAmJiB0aGlzLl9fdGFncy5pbmRleE9mKHRhZykgIT09IC0xO1xuICB9XG4gIF90YWcodGFnKSB7XG4gICAgaWYgKHRhZy5pbmRleE9mKFwiLlwiKSAhPT0gLTEpIHtcbiAgICAgIHJldHVybiB0aGlzLm10YWcodGFnKVswXTtcbiAgICB9IGVsc2Uge1xuICAgICAgaWYgKHRoaXMuX190cmVlVGFncykge1xuICAgICAgICBsZXQgdCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgaWYgKHQpIHtcbiAgICAgICAgICBjb25zdCBpdGVtID0gdC52YWx1ZXMoKS5uZXh0KCk7XG4gICAgICAgICAgcmV0dXJuIGl0ZW0gPyBpdGVtLnZhbHVlIDogdm9pZCAwO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICB9XG4gIGdldCB0YWcoKSB7XG4gICAgcmV0dXJuIHRoaXMuX3RhZztcbiAgfVxuICBzZXQgdGFnKHQpIHtcbiAgICB0aGlzLnRhZ3MgPSB0O1xuICB9XG4gIG10YWcodGFnKSB7XG4gICAgbGV0IGlkeCA9IHRhZy5pbmRleE9mKFwiLlwiKTtcbiAgICBpZiAoaWR4ID49IDApIHtcbiAgICAgIGxldCBwYXJ0cyA9IHRhZy5zcGxpdChcIi5cIik7XG4gICAgICBsZXQgcmVzID0gdGhpcy5fZ2V0QnlUYWcocGFydHNbMF0pO1xuICAgICAgbGV0IGxldmVsID0gMTtcbiAgICAgIGxldCBjID0gcGFydHMubGVuZ3RoO1xuICAgICAgd2hpbGUgKHJlcy5sZW5ndGggJiYgbGV2ZWwgPCBjKSB7XG4gICAgICAgIGxldCByZXNuID0gW107XG4gICAgICAgIGZvciAobGV0IGogPSAwLCBuID0gcmVzLmxlbmd0aDsgaiA8IG47IGorKykge1xuICAgICAgICAgIHJlc24gPSByZXNuLmNvbmNhdChyZXNbal0uX2dldEJ5VGFnKHBhcnRzW2xldmVsXSkpO1xuICAgICAgICB9XG4gICAgICAg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uc3QgY2hpbGQgPSB0aGlzLmdldEJ5UmVmKHBhdGgpO1xuICAgICAgICBpZiAoIWNoaWxkKSB7XG4gICAgICAgICAgaWYgKHYgIT09IHZvaWQgMCkge1xuICAgICAgICAgICAgbGV0IGM7XG4gICAgICAgICAgICBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgICAgYyA9IHRoaXMuY2hpbGRMaXN0LmNyZWF0ZUl0ZW0odik7XG4gICAgICAgICAgICAgIGMucGF0Y2godik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzJDEuaXNPYmplY3QodikpIHtcbiAgICAgICAgICAgICAgYyA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoYy5pc0VsZW1lbnQpIHtcbiAgICAgICAgICAgICAgYy5yZWYgPSBwYXRoO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYShjKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKHYgPT09IHZvaWQgMCkge1xuICAgICAgICAgICAgaWYgKGNoaWxkLnBhcmVudCkge1xuICAgICAgICAgICAgICBjaGlsZC5wYXJlbnQuY2hpbGRMaXN0LnJlbW92ZShjaGlsZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmIChVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgY2hpbGQucGF0Y2godik7XG4gICAgICAgICAgfSBlbHNlIGlmICh2LmlzRWxlbWVudCkge1xuICAgICAgICAgICAgdi5yZWYgPSBwYXRoO1xuICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QucmVwbGFjZSh2LCBjaGlsZCk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJVbmV4cGVjdGVkIHZhbHVlIGZvciBwYXRoOiBcIiArIHB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xuICAgIGNvbnN0IHByb3BzID0ge307XG4gICAgY29uc3QgbGlzdCA9IFtcbiAgICAgIFwiYWxwaGFcIixcbiAgICAgIFwiYWN0aXZlXCIsXG4gICAgICBcImF0dGFjaGVkXCIsXG4gICAgICBcImJvdW5kc01hcmdpblwiLFxuICAgICAgXCJjb2xvclwiLFxuICAgICAgXCJjbGlwcGluZ1wiLFxuICAgICAgXCJlbmFibGVkXCIsXG4gICAgICBcImhcIixcbiAgICAgIFwiaWRcIixcbiAgICAgIFwiaXNDb21wb25lbnRcIixcbiAgICAgIFwibW91bnRcIixcbiAgICAgIFwibW91bnRZXCIsXG4gICAgICBcIm1vdW50WFwiLFxuICAgICAgXCJwaXZvdFwiLFxuICAgICAgXCJwaXZvdFhcIixcbiAgICAgIFwicGl2b3RZXCIsXG4gICAgICBcInJlZlwiLFxuICAgICAgXCJyZW5kZXJPZmZzY3JlZW5cIixcbiAgICAgIFwicmVuZGVyVG9UZXh0dXJlXCIsXG4gICAgICBcInNjYWxlXCIsXG4gICAgICBcInNjYWxlWFwiLFxuICAgICAgXCJzY2FsZVlcIixcbiAgICAgIFwic3RhdGVcIixcbiAgICAgIFwidGFnXCIsXG4gICAgICBcInZpc2libGVcIixcbiAgICAgIFwid1wiLFxuICAgICAgXCJ4XCIsXG4gICAgICBcInlcIixcbiAgICAgIFwiekluZGV4XCIsXG4gICAgICBcIiEhZmxleFwiLFxuICAgICAgXCIhIWZsZXhJdGVtXCIsXG4gICAgICBcImhhc0ZvY3VzKClcIixcbiAgICAgIFwiaGFzRmluYWxGb2N1cygpXCJcbiAgICBdO1xuICAgIGxldCBuID0gbGlzdC5sZW5ndGg7XG4gICAgd2hpbGUgKG4tLSkge1xuICAgICAgbGV0IGtleSA9IGxpc3Rbbl07XG4gICAgICBjb25zdCBnZXRCb29sZWFuID0gL14hezJ9LztcbiAgICAgIGNvbnN0IGlzRnVuY3Rpb24gPSAvXFwoXFwpJC87XG4gICAgICBpZiAoZ2V0Qm9vbGVhbi50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NTaWduYWxzKHYpIHtcbiAgICB0aGlzLl9fcGFzc1NpZ25hbHMgPSBPYmplY3QuYXNzaWduKHRoaXMuX19wYXNzU2lnbmFscyB8fCB7fSwgdik7XG4gIH1cbiAgc2V0IGFsdGVyUGFzc1NpZ25hbHModikge1xuICAgIGlmICghVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJTaWduYWxzOiBzcGVjaWZ5IGFuIG9iamVjdCB3aXRoIHNpZ25hbC10by1maXJlIG1hcHBpbmdzXCIpO1xuICAgIH1cbiAgICBpZiAoIXRoaXMuX19wYXNzU2lnbmFscykge1xuICAgICAgdGhpcy5fX3Bhc3NTaWduYWxzID0ge307XG4gICAgfVxuICAgIGZvciAobGV0IGtleSBpbiB2KSB7XG4gICAgICBjb25zdCBkID0gdltrZXldO1xuICAgICAgaWYgKGQgPT09IHZvaWQgMCkge1xuICAgICAgICBkZWxldGUgdGhpcy5fX3Bhc3NTaWduYWxzW2tleV07XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLl9fcGFzc1NpZ25hbHNba2V5XSA9IHY7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIHNpZ25hbChldmVudCwgLi4uYXJncykge1xuICAgIHJldHVybiB0aGlzLl9zaWduYWwoZXZlbnQsIGFyZ3MpO1xuICB9XG4gIF9zaWduYWwoZXZlbnQsIGFyZ3MpIHtcbiAgICBjb25zdCBzaWduYWxQYXJlbnQgPSB0aGlzLl9nZXRQYXJlbnRTaWduYWxIYW5kbGVyKCk7XG4gICAgaWYgKHNpZ25hbFBhcmVudCkge1xuICAgICAgaWYgKHRoaXMuX19zaWduYWxzKSB7XG4gICAgICAgIGxldCBmaXJlRXZlbnQgPSB0aGlzLl9fc2lnbmFsc1tldmVudF07XG4gICAgICAgIGlmIChmaXJlRXZlbnQgPT09IGZhbHNlKSB7XG4gICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAg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TSE9SVF80XzRfNF80OlxuICAgICAgICAgIHJldHVybiAyO1xuICAgICAgICBjYXNlIGdsLlVOU0lHTkVEX1NIT1JUXzVfNV81XzE6XG4gICAgICAgICAgcmV0dXJuIDI7XG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiSW52YWxpZCB0eXBlIHNwZWNpZmllZCBmb3IgR0xfUkdCQSBmb3JtYXRcIik7XG4gICAgICB9XG4gICAgfSBlbHNlIGlmIChmbXQgPT09IGdsLlJHQikge1xuICAgICAgc3dpdGNoICh0eXBlKSB7XG4gICAgICAgIGNhc2UgZ2wuVU5TSUdORURfQllURTpcbiAgICAgICAgICByZXR1cm4gMztcbiAgICAgICAgY2FzZSBnbC5VTlNJR05FRF9CWVRFXzVfNl81OlxuICAgICAgICAgIHJldHVybiAyO1xuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkludmFsaWQgdHlwZSBzcGVjaWZpZWQgZm9yIEdMX1JHQiBmb3JtYXRcIik7XG4gICAgICB9XG4gICAgfSBlbHNlIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcihcIkludmFsaWQgZm9ybWF0IHNwZWNpZmllZCBpbiBjYWxsIHRvIF9nZXRCeXRlc1BlclBpeGVsKClcIik7XG4gICAgfVxuICB9XG4gIHVwbG9hZFRleHR1cmVTb3VyY2UodGV4dHVyZVNvdXJjZSwgb3B0aW9ucykge1xuICAgIGNvbnN0IGdsID0gdGhpcy5zdGFnZS5nbDtcbiAgICBjb25zdCBzb3VyY2UgPSBvcHRpb25zLnNvdXJjZTtcbiAgICBsZXQgY29tcHJlc3NlZCA9IGZhbHNlO1xuICAgIGlmIChvcHRpb25zLnJlbmRlckluZm8pIHtcbiAgICAgIGNvbXByZXNzZWQgPSBvcHRpb25zLnJlbmRlckluZm8uY29tcHJlc3NlZCB8fCBmYWxzZTtcbiAgICB9XG4gICAgY29uc3QgZm9ybWF0ID0ge1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50Q29yZS5faCAqIHIudGI7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl93ICogci50YyArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ4O1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icnk7XG4gICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yQnIsIHIuYWxwaGEpO1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHggKyBlbGVtZW50Q29yZS5faCAqIHIudGI7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icnk7XG4gICAgICB1aW50c1tvZmZzZXRdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvckJsLCByLmFscGhhKTtcbiAgICB9IGVsc2Uge1xuICAgICAgbGV0IGN4ID0gci5weCArIGVsZW1lbnRDb3JlLl93ICogci50YTtcbiAgICAgIGxldCBjeSA9IHIucHkgKyBlbGVtZW50Q29yZS5faCAqIHIudGQ7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weDtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5O1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHg7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVbCwgci5hbHBoYSk7XG4gICAgICBmbG9hdHNbb2Zmc2V0Kytd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PT09IGl0ZW1zW2ldLnApIHtcbiAgICAgICAgaXRlbXNbaV0uaWRwID0gMDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGl0ZW1zW2ldLmlkcCA9IDEgLyAoaXRlbXNbaV0ucGUgLSBpdGVtc1tpXS5wKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eShcInNtXCIpKSB7XG4gICAgICAgIGl0ZW1zW2ldLnNtID0gZGVmYXVsdFNtb290aG5lc3M7XG4gICAgICB9XG4gICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KFwic1wiKSkge1xuICAgICAgICBpZiAoaSA9PT0gMCB8fCBpID09PSBuIC0gMSB8fCBpdGVtc1tpXS5wID09PSAxKSB7XG4gICAgICAgICAgaXRlbXNbaV0ucyA9IHJnYmEgPyBbMCwgMCwgMCwgMF0gOiAwO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnN0IHBpID0gaXRlbXNbaSAtIDFdO1xuICAgICAgICAgIGNvbnN0IG5pID0gaXRlbXNbaSArIDFdO1xuICAgICAgICAgIGlmIChwaS5wID09PSBuaS5wKSB7XG4gICAgICAgICAgICBpdGVtc1tpXS5zID0gcmdiYSA/IFswLCAwLCAwLCAwXSA6IDA7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChyZ2JhKSB7XG4gICAgICAgICAgICAgIGNvbnN0IG5jID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHMobmkubHYpO1xuICAgICAgICAgICAgICBjb25zdCBwYyA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKHBpLmx2KTtcbiAgICAgICAgICAgICAgY29uc3QgZCA9IDEgLyAobmkucCAtIHBpLnApO1xuICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gW1xuICAgICAgICAgICAgICAgIGQgKiAobmNbMF0gLSBwY1swXSksXG4gICAgICAgICAgICAgICAgZCAqIChuY1sxXSAtIHBjWzFdKSxcbiAgICAgICAgICAgICAgICBkICogKG5jWzJdIC0gcGNbMl0pLFxuICAgICAgICAgICAgICAgIGQgKiAobmNbM10gLSBwY1szXSlcbiAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGl0ZW1zW2ldLnMgPSAobmkubHYgLSBwaS5sdikgLyAobmkucCAtIHBpLnApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBmb3IgKGkgPSAwOyBpIDwgbiAtIDE7IGkrKykge1xuICAgICAgaWYgKCFpdGVtc1tpXS5mKSB7XG4gICAgICAgIGxldCBsYXN0ID0gaSA9PT0gbiAtIDE7XG4gICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoXCJ2ZVwiKSkge1xuICAgICAgICAgIGl0ZW1zW2ldLnZlID0gbGFzdCA/IGl0ZW1zW2ldLmx2IDogaXRlbXNbaSArIDFdLmx2O1xuICAgICAgICB9XG4gICAgICAgIGlmIChVdGlscyQxLmlzTnVtYmVyKGl0ZW1zW2ldLnYpICYmIFV0aWxzJDEuaXNOdW1iZXIoaXRlbXNbaV0ubHYpKSB7XG4gICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eShcInNtZVwiKSkge1xuICAgICAgICAgICAgaXRlbXNbaV0uc21lID0gbGFzdCA/IGRlZmF1bHRTbW9vdGhuZXNzIDogaXRlbXNbaSArIDFdLnNtO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KFwic2VcIikpIHtcbiAgICAgICAgICAgIGl0ZW1zW2ldLnNlID0gbGFzdCA/IHJnYmEgPyBbMCwgMCwgMCwgMF0gOiAwIDogaXRlbXNbaS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AgICAgY29uc3QgY3R4ID0gY2hpbGQuY29yZS5fd29ybGRDb250ZXh0O1xuICAgICAgY29uc3QgY3ggPSBjdHgucHggKiBwcmVjaXNpb247XG4gICAgICBjb25zdCBjeSA9IGN0eC5weSAqIHByZWNpc2lvbjtcbiAgICAgIGNvbnN0IGN3ID0gY2hpbGQuZmluYWxXICogY3R4LnRhICogcHJlY2lzaW9uO1xuICAgICAgY29uc3QgY2ggPSBjaGlsZC5maW5hbEggKiBjdHgudGQgKiBwcmVjaXNpb247XG4gICAgICBpZiAoY3ggPiB0aGlzLnN0YWdlLncgfHwgY3kgPiB0aGlzLnN0YWdlLmgpIHtcbiAgICAgICAgY29udGludWU7XG4gICAgICB9XG4gICAgICBpZiAoY2hpbGQucGFyZW50LmNvcmUuX3NjaXNzb3IpIHtcbiAgICAgICAgY29uc3Qgc2Npc3NvciA9IGNoaWxkLnBhcmVudC5jb3JlLl9zY2lzc29yLm1hcCgodikgPT4gdiAqIHByZWNpc2lvbik7XG4gICAgICAgIGlmICghdGhpcy5fdGVzdENvbGxpc2lvbihjdXJzb3JYLCBjdXJzb3JZLCAuLi5zY2lzc29yKSlcbiAgICAgICAgICBjb250aW51ZTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl90ZXN0Q29sbGlzaW9uKGN1cnNvclgsIGN1cnNvclksIGN4LCBjeSwgY3csIGNoKSkge1xuICAgICAgICBjYW5kaWRhdGVzLnB1c2goY2hpbGQpO1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gY2FuZGlkYXRlcztcbiAgfVxuICBfdGVzdENvbGxpc2lvbihweCwgcHksIGN4LCBjeSwgY3csIGNoKSB7XG4gICAgaWYgKHB4ID49IGN4ICYmIHB4IDw9IGN4ICsgY3cgJiYgcHkgPj0gY3kgJiYgcHkgPD0gY3kgKyBjaCkge1xuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuICBkZXN0cm95KCkge1xuICA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BhaVtrZXldID0gaTtcbiAgICAgIGlmIChiaVtrZXldID09PSB2b2lkIDApIHtcbiAgICAgICAgYmlba2V5XSA9IC0xO1xuICAgICAgfVxuICAgIH1cbiAgICBjb25zdCBha3NsID0gYWtzLmxlbmd0aDtcbiAgICBjb25zdCByZXN1bHQgPSB7fTtcbiAgICBmb3IgKGxldCBpID0gMCwgbiA9IGJrcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgIGNvbnN0IGtleSA9IGJrc1tpXTtcbiAgICAgIGNvbnN0IGFJbmRleCA9IGFpW2tleV07XG4gICAgICBsZXQgY3VySW5kZXgyID0gYUluZGV4O1xuICAgICAgd2hpbGUgKC0tY3VySW5kZXgyID49IDApIHtcbiAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleDJdO1xuICAgICAgICBpZiAoYmlbYWtleV0gIT09IC0xKSB7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHdoaWxlICgrK2N1ckluZGV4MiA8IGFJbmRleCkge1xuICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4Ml07XG4gICAgICAgIHJlc3VsdFtha2V5XSA9IGFbYWtleV07XG4gICAgICB9XG4gICAgICBjb25zdCBidiA9IGJba2V5XTtcbiAgICAgIGNvbnN0IGF2ID0gYVtrZXldO1xuICAgICAgbGV0IHI7XG4gICAgICBpZiAodGhpcy5pc01mKGJ2KSkge1xuICAgICAgICByID0gYnYoYXYpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKCFVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbChhdikgfHwgIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKGJ2KSkge1xuICAgICAgICAgIHIgPSBidjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByID0gT2JqTWVyZ2VyLm1lcmdlKGF2LCBidik7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChy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pb24oZWxlbWVudCwgZWxlbWVudENvcmUpIHtcbiAgICAgIGlmIChlbGVtZW50Q29yZS5fcmVjYWxjICYgMiArIDEyOCkge1xuICAgICAgICBjb25zdCB3ID0gZWxlbWVudENvcmUudztcbiAgICAgICAgY29uc3QgaCA9IGVsZW1lbnRDb3JlLmg7XG4gICAgICAgIGxldCBjdXIgPSBlbGVtZW50Q29yZTtcbiAgICAgICAgZG8ge1xuICAgICAgICAgIGN1ciA9IGN1ci5fY2hpbGRyZW5bMF07XG4gICAgICAgICAgY3VyLl9lbGVtZW50LncgPSB3O1xuICAgICAgICAgIGN1ci5fZWxlbWVudC5oID0gaDtcbiAgICAgICAgfSB3aGlsZSAoY3VyLl9jaGlsZHJlbik7XG4gICAgICB9XG4gICAgfTtcbiAgICByZXR1cm4ge1xuICAgICAgVGV4dHdyYXA6IHsgcnR0OiB0cnVlLCBmb3JjZVpJbmRleENvbnRleHQ6IHRydWUsIHJlbmRlck9mZnNjcmVlbjogdHJ1ZSwgQ29udGVudDoge30gfSxcbiAgICAgIExheWVyczoge1xuICAgICAgICBMMDogeyBydHQ6IHRydWUsIG9uVXBkYXRlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHZpc2libGU6IGZhbHNlLCBDb250ZW50OiB7IHNoYWRlcjogeyB0eXBlOiBCb3hCbHVyU2hhZGVyIH0gfSB9LFxuICAgICAgICBMMTogeyBydHQ6IHRydWUsIG9uVXBkYXRlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHZpc2libGU6IGZhbHNlLCBDb250ZW50OiB7IHNoYWRlcjogeyB0eXBlOiBCb3hCbHVyU2hhZGVyIH0gfSB9LFxuICAgICAgICBMMjogeyBydHQ6IHRydWUsIG9uVXBkYXRlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHZpc2libGU6IGZhbHNlLCBDb250ZW50OiB7IHNoYWRlcjogeyB0eXBlOiBCb3hCbHVyU2hhZGVyIH0gfSB9LFxuICAgICAgICBMMzogeyBydHQ6I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AgICAgICAgICAgIGQgPSBwb3MyIC0gcG9zMTtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMSwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzFdID4gMC4wKSB7XG4gICAgICAgICAgICB2ZWMyIHBvczEgPSB2ZWMyKHBvaW50LnggLSByZXNvbHV0aW9uLnggLSBmYWRlWzFdLCB2VGV4dHVyZUNvb3JkLnkpO1xuICAgICAgICAgICAgdmVjMiBwb3MyID0gdmVjMihwb2ludC54IC0gcmVzb2x1dGlvbi54LCB2VGV4dHVyZUNvb3JkLnkpO1xuICAgICAgICAgICAgZCA9IHBvczEgLSBwb3MyO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MyLCBkKSAvIGRvdChkLCBkKTtcbiAgICAgICAgICAgIHQgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcChjLCAwLjAsIDEuMCkpO1xuICAgICAgICAgICAgY29sb3IgPSBtaXgodmVjNCgwLjApLCBjb2xvciwgdCk7XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGlmKGZhZGVbMl0gPiAwLjApIHtcbiAgICAgICAgICAgIHZlYzIgcG9zMSA9IHZlYzIodlRleHR1cmVDb29yZC54LCBwb2ludC55IC0gcmVzb2x1dGlvbi55IC0gZmFkZVsyXSk7XG4gICAgICAgICAgICB2ZWMyIHBvczIgPSB2ZWMyKHZUZXh0dXJlQ29vcmQueCwgcG9pbnQueSAtIHJlc29sdXRpb24ueSk7XG4gICAgICAgICAgICBkID0gcG9zMSAtIHBvczI7XG4gICAgICAgICAgICBjID0gZG90KHBvczIsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAg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LnopLCBzaW4ocm90LnopLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgIC1zaW4ocm90LnopLCBjb3Mocm90LnopKTtcbiAgICAgICAgcG9zLnh5ID0gaVJvdFh5ICogcG9zLnh5O1xuICAgICAgICBcbiAgICAgICAgLy8gUGVyZm9ybSAzZCByb3RhdGlvbnNcbiAgICAgICAgZ2xfUG9zaXRpb24ueCA9IGNvcyhyb3QueCkgKiBwb3MueCAtIHNpbihyb3QueCkgKiBwb3MuejtcbiAgICAgICAgZ2xfUG9zaXRpb24ueSA9IHBvcy55O1xuICAgICAgICBnbF9Qb3NpdGlvbi56ID0gc2luKHJvdC54KSAqIHBvcy54ICsgY29zKHJvdC54KSAqIHBvcy56O1xuICAgICAgICBcbiAgICAgICAgcG9zLnggPSBnbF9Qb3NpdGlvbi54O1xuICAgICAgICBwb3MueSA9IGNvcyhyb3QueSkgKiBnbF9Qb3NpdGlvbi55IC0gc2luKHJvdC55KSAqIGdsX1Bvc2l0aW9uLno7XG4gICAgICAgIHBvcy56ID0gc2luKHJvdC55KSAqIGdsX1Bvc2l0aW9uLnkgKyBjb3Mocm90LnkpICogZ2xfUG9zaXRpb24uejtcbiAgICAgICAgXG4gICAgICAgIC8vIFJlZG8gWFkgcm90YXRpb25cbiAgICAgICAgaVJvdFh5WzBdWzFdID0gLWlSb3RYeVswXVsxXTtcbiAgICAgICAgaVJvdFh5WzFdWzBdID0gLWlSb3RYeVsxXVswXTtcbiAgICAgICAgcG9zLnh5ID0gaVJvdFh5ICogcG9zLnh5OyBcblxuICAgICAgICAvLyBVbmRvIHRyYW5zbGF0ZSB0byBwaXZvdCBwb3NpdGlvblxuICAgICAgICBwb3MueHl6ICs9IHBpdm90O1xuXG4gICAgICAgIHBvcyA9IHZlYzMocG9zLnggKiBwcm9qZWN0aW9uLnggLSAxLjAsIHBvcy55ICogLWFicyhwcm9qZWN0aW9uLnkpICsgMS4wLCBwb3MueiAqIHByb2plY3Rpb24ueCk7XG4gICAgICAgI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uICAgICAgbGV0IHliID0gMyAqIChkIC0gYikgLSB5YztcbiAgICAgIGxldCB5YSA9IDEgLSB5YyAtIHliO1xuICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgaWYgKHRpbWUgPj0gMSkge1xuICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aW1lIDw9IDApIHtcbiAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfVxuICAgICAgICBsZXQgdCA9IDAuNSwgY2J4LCBjYnhkLCBkeDtcbiAgICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcbiAgICAgICAgICBkeCA9IHRpbWUgLSBjYng7XG4gICAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgY2J4ZCA9IHQgKiAodCAqICgzICogeGEpICsgMiAqIHhiKSArIHhjO1xuICAgICAgICAgIGlmIChjYnhkID4gMWUtMTAgJiYgY2J4ZCA8IDFlLTEwKSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgdCArPSBkeCAvIGNieGQ7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IG1pblQgPSAwO1xuICAgICAgICBsZXQgbWF4VCA9IDE7XG4gICAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICAgIHQgPSAwLjUgKiAobWluVCArIG1heFQpO1xuICAgICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG4gICAgICAgICAgZHggPSB0aW1lIC0gY2J4O1xuICAgICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5Yyk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChkeCA8IDApIHtcbiAgICAgICAgICAgIG1heFQgPSB0O1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBtaW5UID0gdDtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXRUaW1pbmdGdW5jdGlvbihzdHIpIHtcbiAgICAgIHN3aXRjaCAoc3RyKSB7XG4gICAgICAgIGNhc2UgXCJsaW5lYXJcIjpcbiAgICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRpbWU7XG4gICAgICAgICAgfTtcbiAgICAgICAgY2FzZSBcImVhc2VcIjpcbiAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC4yNSwgMC4xLCAwLjI1LCAxKTtcbiAgICAgICAgY2FzZSBcImVhc2UtaW5cIjpcbiAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC40MiwgMCwgMSwgMSk7XG4gICAgICAgIGNhc2UgXCJlYXNlLW91dFwiOlxuICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLCAwLCAwLjU4LCAxKTtcbiAgICAgICAgY2FzZSBcImVhc2UtaW4tb3V0XCI6XG4gICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAuNDIsIDAsIDAuNTgsIDEpO1xuICAgICAgICBjYXNlIFwic3RlcC1zdGFydFwiOlxuICAgICAgICAgIHJldHVybiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICAgIH07XG4gICAgICAgIGNhc2UgXCJzdGVwLWVuZFwiOlxuICAgICAgICAgIHJldHVybiBmdW5jdGlvbih0aW1lKSB7XG4gICAgICAgICAgICByZXR1cm4gdGltZSA9PT0gMSA/IDEgOiAwO1xuICAgICAgICAgIH07XG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgbGV0IHMgPSBcImN1YmljLWJlemllcihcIjtcbiAgICAgICAgICBpZiAoc3RyICYmIHN0ci5pbmRleE9mKHMpID09PSAwKSB7XG4gICAgICAgICAgICBsZXQgcGFydHMgPSBzdHIuc3Vic3RyKHMubGVuZ3RoLCBzdHIubGVuZ3RoIC0gcy5sZW5ndGggLSAxKS5zcGxpdChcIixcIik7XG4gICAgICAgICAgICBpZiAocGFydHMubGVuZ3RoICE9PSA0KSB7XG4gICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG4gICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbih0aW1lKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRpbWU7XG4gICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgYSA9IHBhcnNlRmxvYXQocGFydHNbMF0pO1xuICAgICAgICAgICAgbGV0IGIgPSBwYXJzZUZsb2F0KHBhcnRzWzFdKTtcbiAgICAgICAgICAgIGxldCBjID0gcGFyc2VGbG9hdChwYXJ0c1syXSk7XG4gICAgICAgICAgICBsZXQgZCA9IHBhcnNlRmxvYXQocGFydHNbM10pO1xuICAgICAgICAgICAgaWYgKGlzTmFOKGEpIHx8IGlzTmFOKGIpIHx8IGlzTmFOKGMpIHx8IGlzTmFOKGQpKSB7XG4gICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG4gICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbih0aW1lKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRpbWU7XG4gICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoYSwgYiwgYywgZCk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgICAgICByZXR1cm4gdGltZTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgfVxuICBsZXQgVXRpbHMkMSA9IGNsYXNzIFV0aWxzIHtcbiAgICBzdGF0aWMgaXNGdW5jdGlvbih2YWx1ZSkge1xuICAgICAgcmV0dXJuIHR5cGVvZiB2YWx1ZSA9PT0gXCJmdW5jdGlvblwiO1xuICAgIH1cbiAgICBzdGF0aWMgaXNOdW1iZXIodmFsdWUpIHtcbiAgICAgIHJldHVybiB0eXBlb2YgdmFsdWUgPT09IFwibnVtYmVyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBpc0ludGVnZXIodmFsdWUpIHtcbiAgICAgIHJldHVybiB0eXBlb2YgdmFsdWUgPT09IFwibnVtYmVyXCIgJiYgdmFsdWUgJSAxID09PSAwO1xuICAgIH1cbiAgICBzdGF0aWMgaXNCb29sZWFuKHZhbHVlKSB7XG4gICAgICByZXR1cm4gdmFsdWUgPT09IHRydWUgfHwgdmFsdWUgPT09IGZhbHNlO1xuICAgIH1cbiAgICBzdGF0aWMgaXNTdHJpbmcodmFsdWUpIHtcbiAgICAgIHJldHVybiB0eXBlb2YgdmFsdWUgPT09IFwic3RyaW5nXCI7XG4gICAgfVxuICAgIHN0YXRpYyBjbG9uZSh2KSB7XG4gICAgICBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikgfHwgQXJy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iB2YWx1ZSA9PT0gXCJvYmplY3RcIiAmJiB2YWx1ZSAmJiB2YWx1ZS5jb25zdHJ1Y3RvciA9PT0gT2JqZWN0O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0QXJyYXlJbmRleChpbmRleCwgYXJyKSB7XG4gICAgICByZXR1cm4gVXRpbHMkMS5nZXRNb2R1bG9JbmRleChpbmRleCwgYXJyLmxlbmd0aCk7XG4gICAgfVxuICAgIHN0YXRpYyBnZXRNb2R1bG9JbmRleChpbmRleCwgbGVuKSB7XG4gICAgICBpZiAobGVuID09PSAwKVxuICAgICAgICByZXR1cm4gaW5kZXg7XG4gICAgICB3aGlsZSAoaW5kZXggPCAwKSB7XG4gICAgICAgIGluZGV4ICs9IE1hdGguY2VpbCgtaW5kZXggLyBsZW4pICogbGVuO1xuICAgICAgfVxuICAgICAgaW5kZXggPSBpbmRleCAlIGxlbjtcbiAgICAgIHJldHVybiBpbmRleDtcbiAgICB9XG4gICAgc3RhdGljIGdldERlZXBDbG9uZShvYmopIHtcbiAgICAgIGxldCBpLCBjO1xuICAgICAgaWYgKFV0aWxzJDEuaXNGdW5jdGlvbihvYmopKSB7XG4gICAgICAgIHJldHVybiBvYmo7XG4gICAgICB9XG4gICAgICBpZiAoQXJyYXkuaXNBcnJheShvYmopKSB7XG4gICAgICAgIGMgPSBbXTtcbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICBmb3IgKGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgIGNba2V5c1tpXV0gPSBVdGlscyQxLmdldERlZXBDbG9uZShvYmpba2V5c1tpXV0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjO1xuICAgICAgfSBlbHNlIGlmIChVdGlscyQxLmlzT2JqZWN0KG9iaikpIHtcbiAgICAgICAgYyA9IHt9O1xuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgIGZ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BrZXlzMVtpXTtcbiAgICAgICAgY29uc3QgazIgPSBrZXlzMltpXTtcbiAgICAgICAgaWYgKGsxICE9PSBrMikge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBjb25zdCB2MSA9IG9iajFbazFdO1xuICAgICAgICBjb25zdCB2MiA9IG9iajJbazJdO1xuICAgICAgICBpZiAoIVV0aWxzJDEuZXF1YWxWYWx1ZXModjEsIHYyKSkge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICAgIHN0YXRpYyBlcXVhbEFycmF5cyh2MSwgdjIpIHtcbiAgICAgIGlmICh2MS5sZW5ndGggIT09IHYyLmxlbmd0aCkge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHYxLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBpZiAoIXRoaXMuZXF1YWxWYWx1ZXModjFbaV0sIHYyW2ldKSkge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICAgIHN0YXRpYyBzZXRUb0FycmF5KHMpIHtcbiAgICAgIGxldCByZXN1bHQgPSBbXTtcbiAgICAgIHMuZm9yRWFjaChmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICByZXN1bHQucHVzaCh2YWx1ZSk7XG4gICAgICB9KTtcbiAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuICAgIHN0YXRpYyBpdGVyYXRvclRvQXJyYXkoaXRlcmF0b3IpIHtcbiAgICAgIGxldCByZXN1bHQgPSBbXTtcbiAgICAgIGxldCBpdGVyYXRvclJlc3VsdCA9IGl0ZXJhdG9yLm5leHQoKTtcbiAgICAgIHdoaWxlICghaXRlcmF0b3JSZXN1bHQuZG9u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Jpbms7XG4gICAgICAgICAgICBjb25zdCBpc1Nocmlua2FibGVJdGVtID0gc2hyaW5rQW1vdW50ID4gMDtcbiAgICAgICAgICAgIGlmIChpc1Nocmlua2FibGVJdGVtKSB7XG4gICAgICAgICAgICAgIGxldCBzaHJpbmsgPSBzaHJpbmtBbW91bnQgKiBhbW91bnRQZXJTaHJpbms7XG4gICAgICAgICAgICAgIGNvbnN0IG1pblNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNNaW5TaXplKCk7XG4gICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCk7XG4gICAgICAgICAgICAgIGlmIChzaXplID4gbWluU2l6ZSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IG1heFNocmluayA9IHNpemUgLSBtaW5TaXplO1xuICAgICAgICAgICAgICAgIGNvbnN0IGlzRnVsbHlTaHJ1bmsgPSBzaHJpbmsgPj0gbWF4U2hyaW5rO1xuICAgICAgICAgICAgICAgIGlmIChpc0Z1bGx5U2hydW5rKSB7XG4gICAgICAgICAgICAgICAgICBzaHJpbmsgPSBtYXhTaHJpbms7XG4gICAgICAgICAgICAgICAgICB0b3RhbFNocmlua0Ftb3VudCAtPSBzaHJpbmtBbW91bnQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnN0IGZpbmFsU2l6ZSA9IHNpemUgLSBzaHJpbms7XG4gICAgICAgICAgICAgICAgZmxleEl0ZW0uX3Jlc2l6ZU1haW5BeGlzKGZpbmFsU2l6ZSk7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2hydW5rU2l6ZSArPSBzaHJpbms7XG4gICAgICAgICAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nIC09IHNocmluaztcbiAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnModGhpcy5fYW1vdW50UmVtYWluaW5nKSA8IDFlLTUpIHtcbiAgICAgICAgICAgICAgICA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U2l6ZSgpO1xuICAgICAgICAgICAgICBpZiAobWF4U2l6ZSA+IDApIHtcbiAgICAgICAgICAgICAgICBpZiAoc2l6ZSA+PSBtYXhTaXplKSB7XG4gICAgICAgICAgICAgICAgICBncm93ID0gMDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgY29uc3QgbWF4R3JvdyA9IG1heFNpemUgLSBzaXplO1xuICAgICAgICAgICAgICAgICAgY29uc3QgaXNGdWxseUdyb3duID0gZ3JvdyA+PSBtYXhHcm93O1xuICAgICAgICAgICAgICAgICAgaWYgKGlzRnVsbHlHcm93bikge1xuICAgICAgICAgICAgICAgICAgICBncm93ID0gbWF4R3JvdztcbiAgICAgICAgICAgICAgICAgICAgdG90YWxHcm93QW1vdW50IC09IGdyb3dBbW91bnQ7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmIChncm93ID4gMCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGZpbmFsU2l6ZSA9IHNpemUgKyBncm93O1xuICAgICAgICAgICAgICAgIGZsZXhJdGVtLl9yZXNpemVNYWluQXhpcyhmaW5hbFNpemUpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2dyb3duU2l6ZSArPSBncm93O1xuICAgICAgICAgICAgICAgIHRoaXMuX2Ftb3VudFJlbWFpbmluZyAtPSBncm93O1xuICAgICAgICAgICAgICAgIGlmIChNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpIDwgMWUtNSkge1xuICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSB3aGlsZSAodG90YWxHcm93QW1vdW50ICYmIE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPiAxZS01KTtcbiAgICAgIH1cbi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1cbiAgICBnZXQgYWxpZ25JdGVtcygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9hbGlnbkl0ZW1zO1xuICAgIH1cbiAgICBzZXQgYWxpZ25JdGVtcyh2KSB7XG4gICAgICBpZiAodGhpcy5fYWxpZ25JdGVtcyA9PT0gdilcbiAgICAgICAgcmV0dXJuO1xuICAgICAgaWYgKEZsZXhDb250YWluZXIuQUxJR05fSVRFTVMuaW5kZXhPZih2KSA9PT0gLTEpIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5rbm93biBhbGlnbkl0ZW1zLCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuQUxJR05fSVRFTVMuam9pbihcIixcIikpO1xuICAgICAgfVxuICAgICAgdGhpcy5fYWxpZ25JdGVtcyA9IHY7XG4gICAgICB0aGlzLl9jaGFuZ2VkQ29udGVudHMoKTtcbiAgICB9XG4gICAgZ2V0IGFsaWduQ29udGVudCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9hbGlnbkNvbnRlbnQ7XG4gICAgfVxuICAgIHNldCBhbGlnbkNvbnRlbnQodikge1xuICAgICAgaWYgKHRoaXMuX2FsaWduQ29udGVudCA9PT0gdilcbiAgICAgICAgcmV0dXJuO1xuICAgICAgaWYgKEZsZXhDb250YWluZXIuQUxJR05fQ09OVEVOVC5pbmRleE9mKHYpID09PSAtMSkge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIGFsaWduQ29udGVudCwgb3B0aW9uczogXCIgKyBGbGV4Q29udGFpbmVyLkFMSUdOX0NPTlRFTlQuam9pbihcIixcIikpO1xuICAgICAgfVxuICAgICAgdGhpcy5fYWxpZ25Db250ZW50ID0gdjtcbiAgICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICAgIH1cbiAgICBnZXQganVzdGlmeUNvbnRlbnQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fanVzdGlmeUNvbnRlbnQ7XG4gICAgfVxuICAgIH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YgKHRoaXMuX2Z1bmNYKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mdW5jWDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLmhhc0ZsZXhMYXlvdXQoKSkge1xuICAgICAgICAgIHJldHVybiB0aGlzLl9sYXlvdXQub3JpZ2luYWxYO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHJldHVybiB0aGlzLl94O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHNldCBvZmZzZXRYKHYpIHtcbiAgICAgIGlmIChVdGlscyQxLmlzRnVuY3Rpb24odikpIHtcbiAgICAgICAgdGhpcy5mdW5jWCA9IHY7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLl9kaXNhYmxlRnVuY1goKTtcbiAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgdGhpcy54ICs9IHYgLSB0aGlzLl9sYXlvdXQub3JpZ2luYWxYO1xuICAgICAgICAgIHRoaXMuX2xheW91dC5zZXRPcmlnaW5hbFhXaXRob3V0VXBkYXRpbmdMYXlvdXQodik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy54ID0gdjtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBnZXQgeCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl94O1xuICAgIH1cbiAgICBzZXQgeCh2KSB7XG4gICAgICBpZiAodiAhPT0gdGhpcy5feCkge1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZURlbHRhKHYgLSB0aGlzLl94LCAwKTtcbiAgICAgICAgdGhpcy5feCA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBmdW5jWCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9vcHRGbGFncyAmIDEgPyB0aGlzLl9mdW5jWCA6IG51bGw7XG4gICAgfVxuICAgIHNldCBmdW5jWCh2KSB7XG4g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AgaWYgKHRoaXMuX3Bpdm90WSAhPT0gdikge1xuICAgICAgICB0aGlzLl9waXZvdFkgPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgcGl2b3QoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fcGl2b3RYO1xuICAgIH1cbiAgICBzZXQgcGl2b3Qodikge1xuICAgICAgaWYgKHRoaXMuX3Bpdm90WCAhPT0gdiB8fCB0aGlzLl9waXZvdFkgIT09IHYpIHtcbiAgICAgICAgdGhpcy5fcGl2b3RYID0gdjtcbiAgICAgICAgdGhpcy5fcGl2b3RZID0gdjtcbiAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IG1vdW50WCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9tb3VudFg7XG4gICAgfVxuICAgIHNldCBtb3VudFgodikge1xuICAgICAgaWYgKHRoaXMuX21vdW50WCAhPT0gdikge1xuICAgICAgICB0aGlzLl9tb3VudFggPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgbW91bnRZKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX21vdW50WTtcbiAgICB9XG4gICAgc2V0IG1vdW50WSh2KSB7XG4gICAgICBpZiAodGhpcy5fbW91bnRZICE9PSB2KSB7XG4gICAgICAgIHRoaXMuX21vdW50WSA9IHY7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBtb3VudCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9tb3VudFg7XG4gICAgfVxuICAgIHNldCBtb3VudCh2KSB7XG4gICAgICBpZiAodGhpcy5fbW91bnRYICE9PSB2IHx8IHRoaXMuX21vdW50WSAhPT0gdikge1xuICAgICAgICB0aGlzLl9tb3VudFggPSB2O1xuICAgICAgICB0aGlzLl9tb3VudFkgPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgcm90YXRpb24oKSB7XG4gICAgICByZXR1cm4gdGhpcy5fcm90YXRpb247XG4gICAgfVxuICAgIHNldCByb3RhdGlvbih2KSB7XG4gICAgICBpZiAodGhpcy5fcm90YXRpb24gIT09IHYpIHtcbiAgICAgICAgdGhpcy5fcm90YXRpb24gPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zZm9ybSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgYWxwaGEoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fYWxwaGE7XG4gICAgfVxuICAgIHNldCBhbHBoYSh2KSB7XG4gICAgICB2ID0gdiA+IDEgPyAxIDogdiA8IDFlLTE0ID8gMCA6IHY7XG4gICAgICBpZiAodGhpcy5fYWxwaGEgIT09IHYpIHtcbiAgICAgICAgbGV0IHByZXYgPSB0aGlzLl9hbHBoYTtcbiAgICAgICAgdGhpcy5fYWxwaGEgPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbEFscGhhKCk7XG4gICAgICAgIGlmIChwcmV2ID09PSAwICE9PSAodiA9PT0gMCkpIHtcbiAgICAgICAgICB0aGlzLl9lbGVtZW50Ll91cGRhdGVFbmFibGVkRmxhZygpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGdldCB2aXNpYmxlKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3Zpc2libGU7XG4gICAgfVxuICAgIHNldCB2aXNpYmxlKHYpIHtcbiAgICAgIGlmICh0aGlzLl92aXNpYmxlICE9PSB2KSB7XG4gICAgICAgIHRoaXMuX3Zpc2libGUgPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbEFscGhhK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ZGF0ZXMoMyk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fc2V0UmVjYWxjKDEgKyAyICsgNCk7XG4gICAgICAgIGlmICh0aGlzLl9wYXJlbnQpIHtcbiAgICAgICAgICB0aGlzLl9wYXJlbnQuX3NldEhhc1VwZGF0ZXMoKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fekluZGV4ID09PSAwKSB7XG4gICAgICAgICAgdGhpcy5zZXRaUGFyZW50KHBhcmVudCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5zZXRaUGFyZW50KHBhcmVudCA/IHBhcmVudC5maW5kWkNvbnRleHQoKSA6IG51bGwpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChwcmV2SXNaQ29udGV4dCAhPT0gdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICBpZiAoIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICB0aGlzLmRpc2FibGVaQ29udGV4dCgpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmVuYWJsZVpDb250ZXh0KHByZXZQYXJlbnQuZmluZFpDb250ZXh0KCkpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl96SW5kZXhSZXNvcnQgPSB0cnVlO1xuICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX3NoYWRlcikge1xuICAgICAgICAgIGxldCBuZXdTaGFkZXJPd25lciA9IHBhcmVudCAmJiAhcGFyZW50Ll9yZW5kZXJUb1RleHR1cmVFbmFibGVkID8gcGFyZW50Ll9zaGFkZXJPd25lciA6IG51bGw7XG4gICAgICAgICAgaWYgKG5ld1NoYWRlck93bmVyICE9PSB0aGlzLl9zaGFkZXJPd25lcikge1xuICAgICAgICAg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9IGM7XG4gICAgICB3aGlsZSAocCA9IHAuX3BhcmVudCkge1xuICAgICAgICBpZiAodGhpcyA9PT0gcCkge1xuICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIGlzWkNvbnRleHQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fZm9yY2VaSW5kZXhDb250ZXh0IHx8IHRoaXMuX3JlbmRlclRvVGV4dHVyZUVuYWJsZWQgfHwgdGhpcy5fekluZGV4ICE9PSAwIHx8IHRoaXMuX2lzUm9vdCB8fCAhdGhpcy5fcGFyZW50O1xuICAgIH1cbiAgICBmaW5kWkNvbnRleHQoKSB7XG4gICAgICBpZiAodGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpO1xuICAgICAgfVxuICAgIH1cbiAgICBzZXRaUGFyZW50KG5ld1pQYXJlbnQpIHtcbiAgICAgIGlmICh0aGlzLl96UGFyZW50ICE9PSBuZXdaUGFyZW50KSB7XG4gICAgICAgIGlmICh0aGlzLl96UGFyZW50ICE9PSBudWxsKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgdGhpcy5felBhcmVudC5kZWNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAobmV3WlBhcmVudCAhPT0gbnVsbCkge1xuICAgICAgICAgIGxldCBoYWRaQ29udGV4dFVzYWdlID0gbmV3WlBhcmVudC5fekNvbnRleHRVc2FnZSA+IDA7XG4gICAgICAgICAgaWYgKHRoaXMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgbmV3WlBhcmVudC5pbmNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChuZXdaUGFyZW50Ll96Q29udGV4dFVzYWdlID4gMCkge1xuICAgICAgICAgICAgaWYgKCFoYWRaQ29udGV4dFVzYWdlICYmIHRoaXMuX3BhcmVudCA9PT0gbmV3WlBhcmVudClcbiAgICAgICAgICAgICAgO1xuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgIG5ld1pQYXJlbnQuX3pJbmRleGVkQ2hpbGRyZW4ucHVzaCh0aGlzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIG5ld1pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5felBhcmVudCA9IG5ld1pQYXJlbnQ7XG4gICAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICB9XG4gICAgfVxuICAgIGluY1pDb250ZXh0VXNhZ2UoKSB7XG4gICAgICB0aGlzLl96Q29udGV4dFVzYWdlKys7XG4gICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSA9PT0gMSkge1xuICAgICAgICBpZiAoIXRoaXMuX3pJbmRleGVkQ2hpbGRyZW4pIHtcbiAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuID0gW107XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4ucHVzaCh0aGlzLl9jaGlsZHJlbltpXSk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHRoaXMuX3pTb3J0ID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZGVjWkNvbnRleHRVc2FnZSgpIHtcbiAgICAgIHRoaXMuX3pDb250ZXh0VXNhZ2UtLTtcbiAgICAgIGlmICh0aGlzLl96Q29udGV4dFVzYWdlID09PSAwKSB7XG4gICAgICAgIHRoaXMuX3pTb3J0ID0gZmFsc2U7XG4gICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4uc3BsaWNlKDApO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgekluZGV4KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3pJbmRleDtcbiAgICB9XG4gICAgc2V0IHpJbmRleCh6SW5kZXgpIHtcbiAgICAgIGlmICh0aGlzLl96SW5kZXggIT09IHpJbmRleCkge1xuICAgICAgICB0aGlzLnNldEhhc1JlbmRlclVwZGF0ZXMoMSk7XG4gICAgICAgIGxldCBuZXdaUGFyZW50ID0gdGhpcy5felBhcmVudDtcbiAgICAgICAgbGV0IHByZXZJc1pDb250ZXh0ID0gdGhpcy5pc1pDb250ZXh0KCk7XG4gICAgICAgIGlmICh6SW5kZXggPT09IDAgJiYgdGhpcy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3BhcmVudCA9PT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5kZWNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5ld1pQYXJlbnQgPSB0aGlzLl9wYXJlbnQ7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHpJbmRleCAhPT0gMCAmJiB0aGlzLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgICBuZXdaUGFyZW50ID0gdGhpcy5fcGFyZW50ID8gdGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpIDogbnVsbDtcbiAgICAgICAgICBpZiAobmV3WlBhcmVudCA9PT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5pbmNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAoekluZGV4ICE9PSB0aGlzLl96SW5kZXgpIHtcbiAgICAgICAgICBpZiAodGhpcy5felBhcmVudCAmJiB0aGlzLl96UGFyZW50Ll96Q29udGV4dFVzYWdlKSB7XG4gICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChuZXdaUGFyZW50ICE9PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgdGhpcy5zZXRaUGFyZW50KG51bGwpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3pJbmRleCA9IHpJbmRleDtcbiAgICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICB0aGlzLnNldFpQYXJlbnQobmV3WlBhcmVudCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHByZXZJc1pDb250ZXh0ICE9PSB0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgIGlmICghdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgIHRoaXMuZGlzYWJsZVpDb250ZXh0KCk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuZW5hYmxlWkNvbnRleHQodGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fekluZGV4UmVzb3J0ID0gdHJ1ZTtcbiAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IGZvcmNlWkluZGV4Q29udGV4dCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9mb3JjZVpJbmRleENvbnRleHQ7XG4gICAgfVxuICAgIHNldCBmb3JjZVpJbmRleENvbnRleHQodikge1xuICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKDEpO1xuICAgICAgbGV0IHByZXZJc1pDb250ZXh0ID0gdGhpcy5pc1pDb250ZXh0KCk7XG4gICAgICB0aGlzLl9mb3JjZVpJbmRleENvbnRleHQgPSB2O1xuICAgICAgaWYgKHByZXZJc1pDb250ZXh0ICE9PSB0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICBpZiAoIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgdGhpcy5kaXNhYmxlWkNvbnRleHQoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLmVuYWJsZVpDb250ZXh0KHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZW5hYmxlWkNvbnRleHQocHJldlpDb250ZXh0KSB7XG4gICAgICBpZiAocHJldlpDb250ZXh0ICYmIHByZXZaQ29udGV4dC5fekNvbnRleHRVc2FnZSA+IDApIHtcbiAgICAgICAgY29uc3QgcmVzdWx0cyA9IHRoaXMuX2dldFpJbmRleGVkRGVzY3MoKTtcbiAgICAgICAgcmVzdWx0cy5mb3JFYWNoKChjKSA9PiB7XG4gICAgICAgICAgaWYgKHRoaXMuaXNBbmNlc3Rvck9mKGMpICYmIGMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgYy5zZXRaUGFyZW50KHRoaXMpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSk7X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sQWxwaGE7XG4gICAgICBpZiAodGhpcy5faGFzVXBkYXRlcyB8fCB0aGlzLl9yZWNhbGMgJiYgdmlzaWJsZSB8fCB3LmFscGhhICYmICF2aXNpYmxlKSB7XG4gICAgICAgIGxldCByZWNhbGMgPSB0aGlzLl9yZWNhbGM7XG4gICAgICAgIGlmIChyZWNhbGMgJiAxKSB7XG4gICAgICAgICAgaWYgKCF3LmFscGhhICYmIHZpc2libGUpIHtcbiAgICAgICAgICAgIHRoaXMuX2hhc1JlbmRlclVwZGF0ZXMgPSAzO1xuICAgICAgICAgIH1cbiAgICAgICAgICB3LmFscGhhID0gcHcuYWxwaGEgKiB0aGlzLl9sb2NhbEFscGhhO1xuICAgICAgICAgIGlmICh3LmFscGhhIDwgMWUtMTQpIHtcbiAgICAgICAgICAgIHcuYWxwaGEgPSAwO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAocmVjYWxjICYgNikge1xuICAgICAgICAgIHcucHggPSBwdy5weCArIHRoaXMuX2xvY2FsUHggKiBwdy50YTtcbiAgICAgICAgICB3LnB5ID0gcHcucHkgKyB0aGlzLl9sb2NhbFB5ICogcHcudGQ7XG4gICAgICAgICAgaWYgKHB3LnRiICE9PSAwKVxuICAgICAgICAgICAgdy5weCArPSB0aGlzLl9sb2NhbFB5ICogcHcudGI7XG4gICAgICAgICAgaWYgKHB3LnRjICE9PSAwKVxuICAgICAgICAgICAgdy5weSArPSB0aGlzLl9sb2NhbFB4ICogcHcudGM7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHJlY2FsYyAmIDQpIHtcbiAgICAgICAgICB3LnRhID0gdGhpcy5fbG9jYWxUYSAqIHB3LnRhO1xuICAgICAgICAgIHcudGIgPSB0aGlzLl9sb2NhbFRkICogcHcudGI7XG4gICAgICAgICAgdy50YyA9IHRoaXMuX2xvY2FsVGEgKiBwdy50YztcbiAgICAgICAgICB3LnRkID0gdGhpcy5fbG9jYWxUZCAqIHB3LnRkO1xuICAgICAgICAgIGlmICh0aGlzLl9pc0NvbXBsZXgpIHtcbiAgICAgICAgICAgIHcudGEgKz0gdGhpcy5fbG9jYWxUYyAqIHB3LnRiO1xuICAgICAgICAgICAgdy50YiArPSB0aGlzLl9sb2NhbFRiICogcHcudGE7XG4gICAgICAgICAgICB3LnRjICs9IHRoaXMuX2xvY2FsVGMgKiBwdy50ZDtcbiAgICAgICAgICAgIHcudGQgKz0gdGhpcy5fbG9jYWxUYiAqIHB3LnRjO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBjb25zdCBwciA9IHRoaXMuX3BhcmVudC5fcmVuZGVyQ29udGV4dDtcbiAgICAgICAgaWYgKHRoaXMuX3BhcmVudC5faGFzUmVuZGVyQ29udGV4dCgpKSB7XG4gICAgICAgICAgY29uc3QgaW5pdCA9IHRoaXMuX3JlbmRlckNvbnRleHQgPT09IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgICBpZiAoaW5pdCkge1xuICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IG5ldyBFbGVtZW50Q29yZUNvbnRleHQoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgY29uc3QgcjIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgICAgIGlmIChpbml0IHx8IHJlY2FsYyAmIDEpIHtcbiAgICAgICAgICAgIHIyLmFscGhhID0gcHIuYWxwaGEgKiB0aGlzLl9sb2NhbEFscGhhO1xuICAgICAgICAgICAgaWYgKHIyLmFscGhhIDwgMWUtMTQpIHtcbiAgICAgICAgICAgICAgcjIuYWxwaGEgPSAwO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaW5pdCB8fCByZWNhbGMgJiA2KSB7XG4gICAgICAgICAgICByMi5weCA9IHByLnB4ICsgdGhpcy5fbG9jYWxQeCAqIHByLnRhO1xuICAgICAgICAgICAgcjIucHkgPSBwci5weSArIHRoaXMuX2xvY2FsUHkgKiBwci50ZDtcbiAgICAgICAgICAgIGlmIChwci50YiAhPT0gMClcbiAgICAgICAgICAgICAgcjIucHggKz0gdGhpcy5fbG9jYWxQeSAqIHByLnRiO1xuICAgICAgICAgICAgaWYgKHByLnRjICE9PSAwKVxuICAgICAgICAgICAgICByMi5weSArPSB0aGlzLl9sb2NhbFB4ICogcHIudGM7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChpbml0KSB7XG4gICAgICAgICAgICByZWNhbGMgfD0gMjtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGluaXQgfHwgcmVjYWxjICYgNCkge1xuICAgICAgICAgICAgcjIudGEgPSB0aGlzLl9sb2NhbFRhICogcHIudGE7XG4gICAgICAgICAgICByMi50YiA9IHRoaXMuX2xvY2FsVGQgKiBwci50YjtcbiAgICAgICAgICAgIHIyLnRjID0gdGhpcy5fbG9jYWxUYSAqIHByLnRjO1xuICAgICAgICAgICAgcjIudGQgPSB0aGlzLl9sb2NhbFRkICogcHIudGQ7XG4gICAgICAgICAgICBpZiAodGhpcy5faXNDb21wbGV4KSB7XG4gICAgICAgICAgICAgIHIyLnRhICs9IHRoaXMuX2xvY2FsVGMgKiBwci50YjtcbiAgICAgICAgICAgICAgcjIudGIgKz0gdGhpcy5fbG9jYWxUYiAqIHByLnRhO1xuICAgICAgICAgICAgICByMi50YyArPSB0aGlzLl9sb2NhbFRjICogcHIudGQ7XG4gICAgICAgICAgICAgIHIyLnRkICs9IHRoaXMuX2xvY2FsVGIgKiBwci50YztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID09PSAtMSkge1xuICAgICAgICAgIHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlciA9IHRoaXMuX3VwZGF0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HIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgIGV4ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgIHN5ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgIGV5ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHN4ID0gci5weDtcbiAgICAgICAgICBleCA9IHIucHggKyByLnRhICogYmJveFc7XG4gICAgICAgICAgc3kgPSByLnB5O1xuICAgICAgICAgIGV5ID0gci5weSArIHIudGQgKiBiYm94SDtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fZGltc1Vua25vd24gJiYgKHJDb21wbGV4IHx8IHRoaXMuX2xvY2FsVGEgPCAxIHx8IHRoaXMuX2xvY2FsVGIgPCAxKSkge1xuICAgICAgICAgIGNvbnN0IG54ID0gdGhpcy5feCAqIHByLnRhICsgdGhpcy5feSAqIHByLnRiICsgcHIucHg7XG4gICAgICAgICAgY29uc3QgbnkgPSB0aGlzLl94ICogcHIudGMgKyB0aGlzLl95ICogcHIudGQgKyBwci5weTtcbiAgICAgICAgICBpZiAobnggPCBzeClcbiAgICAgICAgICAgIHN4ID0gbng7XG4gICAgICAgICAgaWYgKG55IDwgc3kpXG4gICAgICAgICAgICBzeSA9IG55O1xuICAgICAgICAgIGlmIChueCA+IGV4KVxuICAgICAgICAgICAgZXggPSBueDtcbiAgICAgICAgICBpZiAobnkgPiBleSlcbiAgICAgICAgICAgIGV5ID0gbnk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHJlY2FsYyAmIDYgfHwgIXRoaXMuX3NjaXNzb3IpIHtcbiAgICAgICAgICBpZiAodGhpcy5fY2xpcHBpbmcgJiYgci5pc1NxdWFyZSgpKSB7XG4gICAgICAgICAgICBjb25zdCBhcmVhID0gdGhpcy5fcGFyZW50Ll91c2VSZW5kZXJUb1RleHR1cmUgPyB0aGlzLl9wYXJlbnQuX3ZpZXdwb3J0IDogdGhpcy5fcGFyZW50Ll9zY2lzc29yO1xuICAgICAgICAgICAgaWYgKGFyZWEpIHtcbiAgICAgICAgICAgICAgY29uc3QgbHggPSBNYXRoLm1heChhcmVhWzBdLCBzeCk7XG4gICAgICAgICAgICAgIGNvbnN0IGx5ID0gTWF0aC5tYXgoYXJlYVsxXSwgc3kpO1xuICAgICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gW1xuICAgICAgICAgICAgICAgIGx4LFxuICAgICAgICAgICAgICAgIGx5LFxuICAgICAgICAgICAgICAgIE1hdGgubWluKGFyZWFbMl0gKyBhcmVhWzBdLCBleCkgLSBseCxcbiAgICAgICAgICAgICAgICBNYXRoLm1pbihhcmVhWzNdICsgYXJlYVsxXSwgZXkpIC0gbHlcbiAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBbc3gsIHN5LCBleCAtIHN4LCBleSAtIHN5XTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IHRoaXMuX3BhcmVudC5fdXNlUmVuZGVyVG9UZXh0dXJlID8gdGhpcy5fcGFyZW50Ll92aWV3cG9ydCA6IHRoaXMuX3BhcmVudC5fc2Npc3NvcjtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX2JvdW5kc01hcmdpbikge1xuICAgICAgICAgIHRoaXMuX3JlY0JvdW5kc01hcmdpbiA9IHRoaXMuX2JvdW5kc01hcmdpbjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl9yZWNCb3VuZHNNYXJnaW4gPSB0aGlzLl9wYXJlbnQuX3JlY0JvdW5kc01hcmdpbjtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fb25BZnRlckNhbGNzKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJDYWxjcyh0aGlzLmVsZW1lbnQpKSB7XG4gICAgICAgICAgICBpZiAockNvbXBsZXgpIHtcbiAgICAgICAgICAgICAgc3ggPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICAgIGV4ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgICBzeSA9IE1hdGgubWluKDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICAgICAgZXkgPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzeCA9IHIucHg7XG4gICAgICAgICAgICAgIGV4ID0gci5weCArIHIudGEgKiBiYm94VztcbiAgICAgICAgICAgICAgc3kgPSByLnB5O1xuICAgICAgICAgICAgICBleSA9IHIucHkgKyByLnRkICogYmJveEg7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fZGltc1Vua25vd24gJiYgKHJDb21wbGV4IHx8IHRoaXMuX2xvY2FsVGEgPCAxIHx8IHRoaXMuX2xvY2FsVGIgPCAxKSkge1xuICAgICAgICAgICAgICBjb25zdCBueCA9IHRoaXMuX3ggKiBwci50YSArIHRoaXMuX3kgKiBwci50YiArIHByLnB4O1xuICAgICAgICAgICAgICBjb25zdCBueSA9IHRoaXMuX3ggKiBwci50YyArIHRoaXMuX3kgKiBwci50ZCArIHByLnB5O1xuICAgICAgICAgICAgICBpZiAobnggPCBzeClcbiAgICAgICAgICAgICAgICBzeCA9IG54O1xuICAgICAgICAgICAgICBpZiAobnkgPCBzeSlcbiAgICAgICAgICAgICAgICBzeSA9IG55O1xuICAgICAgICAgICAgICBpZiAobnggPiBleClcbiAgICAgICAgICAgICAgICBleCA9IG54O1xuICAgICAgICAgICAgICBpZiAobnkgPiBleSlcbiAgICAgICAgICAgICAgICBleSA9IG55O1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fcGFyZW50Ll9vdXRPZkJvdW5kcyA9PT0gMikge1xuICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcbiAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICB0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gPSBmYWxzZTtcbiAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZGlzYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAocmVjYWxjICYgNikge1xuICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAwO1xuICAgICAgICAgICAgbGV0IHdpdGhpbk1hcmdpbiA9IHRydWU7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX3JlbmRlclRvVGV4dHVyZUVuYWJsZWQgfHwgIXRoaXMuX3RleHR1cml6ZXIgfHwgIXRoaXMuX3RleHR1cml6ZXIucmVuZGVyT2Zmc2NyZWVuKSB7XG4gICAgICAgICAgICAgIGlmICh0aGlzLl9zY2lzc29yICYmICh0aGlzLl9zY2lzc29yWzJdIDw9IDAgfHwgdGhpcy5fc2Npc3NvclszXSA8PSAwKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fc2Npc3NvclswXSA+IGV4IHx8IHRoaXMuX3NjaXNzb3JbMV0gPiBleSB8fCBzeCA+IHRoaXMuX3NjaXNzb3JbMF0gKyB0aGlzLl9zY2lzc29yWzJdIHx8IHN5ID4gdGhpcy5fc2Npc3NvclsxXSArIHRoaXMuX3NjaXNzb3JbM10pIHtcbiAgICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzKSB7XG4gICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2xpcHBpbmcgfHwgdGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlIHx8IHRoaXMuX2NsaXBib3ggJiYgKGJib3hXICYmIGJib3hIKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDI7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHdpdGhpbk1hcmdpbiA9IHRoaXMuX291dE9mQm91bmRzID09PSAwO1xuICAgICAgICAgICAgICBpZiAoIXdpdGhpbk1hcmdpbikge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWNCb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgICAgIHdpdGhpbk1hcmdpbiA9ICEoZXggPCB0aGlzLl9zY2lzc29yWzBdIC0gdGhpcy5fcmVjQm91bmRzTWFyZ2luWzJdIHx8IGV5IDwgdGhpcy5fc2Npc3NvclsxXSAtIHRoaXMuX3JlY0JvdW5k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jID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2VuYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWNhbGMpIHtcbiAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnVwZGF0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLl9yZWNhbGMgPSByZWNhbGMyO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZGlzYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICBpZiAodGhpcy5fdmlld3BvcnQpIHtcbiAgICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0WzJdID0gYmJveFc7XG4gICAgICAgICAgICB0aGlzLl92aWV3cG9ydFszXSA9IGJib3hIO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl92aWV3cG9ydCA9IFswLCAwLCBiYm94VywgYmJveEhdO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9wUmVjYWxjID0gdGhpcy5fcmVjYWxjICYgMTM1O1xuICAgICAgICB0aGlzLl9yZWNhbGMgPSAwO1xuICAgICAgICB0aGlzLl9oYXNVcGRhdGVzID0gZmFsc2U7XG4gICAgICAgIGlmICh0aGlzLl9vdXRPZkJvdW5kcyA8IDIpIHtcbiAgICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fd29ybGRDb250ZXh0LmlzSWRlbnRpdHkoKSkge1xuICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IEVsZW1lbnRDb3JlQ29udGV4dC5JREVOVElUWTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHI7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuW2ldLl9oYXNVcGRhdGVzKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlKCk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0uX3JlY2FsYyB8PSB0aGlzLl9wUmVjYWxjO1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZU91dE9mQm91bmRzKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJVcG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gICAgICAgbGV0IG11c3RSZW5kZXJDaGlsZHJlbiA9IHRydWU7XG4gICAgICAgIGxldCByZW5kZXJUZXh0dXJlSW5mbztcbiAgICAgICAgbGV0IHByZXZSZW5kZXJUZXh0dXJlSW5mbztcbiAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgIGlmICh0aGlzLl93ID09PSAwIHx8IHRoaXMuX2ggPT09IDApIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9IGVsc2UgaWYgKCF0aGlzLl90ZXh0dXJpemVyLmhhc1JlbmRlclRleHR1cmUoKSB8fCBoYXNSZW5kZXJVcGRhdGVzID49IDMpIHtcbiAgICAgICAgICAgIHRoaXMuY3R4LnJlbmRlclRvVGV4dHVyZUNvdW50Kys7XG4gICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTaGFkZXIocmVuZGVyU3RhdGUuZGVmYXVsdFNoYWRlciwgdGhpcyk7XG4gICAgICAgICAgICBwcmV2UmVuZGVyVGV4dHVyZUluZm8gPSByZW5kZXJTdGF0ZS5yZW5kZXJUZXh0dXJlSW5mbztcbiAgICAgICAgICAgIHJlbmRlclRleHR1cmVJbmZvID0ge1xuICAgICAgICAgICAgICBuYXRpdmVUZXh0dXJlOiBudWxsLFxuICAgICAgICAgICAgICBvZmZzZXQ6IDAsXG4gICAgICAgICAgICAgIHc6IHRoaXMuX3csXG4gICAgICAgICAgICAgIGg6IHRoaXMuX2gsXG4gICAgICAgICAgICAgIGVtcHR5OiB0cnVlLFxuICAgICAgICAgICAgICBjbGVhcmVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgaWdub3JlOiBmYWxzZSxcbiAgICAgICAgICAgICAgY2FjaGU6IGZhbHNlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHRoaXMuX3RleHR1cml6ZXIuaGFzUmVzdWx0VGV4dHVyZSgpIHx8ICFyZW5kZXJTdGF0ZS5pc0NhY2hpbmdUZXh0dXJpemVyICYmIGhhc1JlbmRlclVwZGF0ZXMgPCAzKSB7XG4gICAgICAgICAgICAgIHJlbmRlclRleHR1cmVJbmZvLmNhY2hlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuaXNDYWNoaW5nVGV4dHVyaXplciA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIuaGFzUmVzdWx0VGV4dHVyZSgpKSB7XG4gICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZVJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFJlbmRlclRleHR1cmVJbmZvKHJlbmRlclRleHR1cmVJbmZvKTtcbiAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNjaXNzb3IobnVsbCk7XG4gICAgICAgICAgICBpZiAodGhpcy5fZGlzcGxheWVkVGV4dHVyZVNvdXJjZSkge1xuICAgICAgICAgICAgICBsZXQgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBFbGVtZW50Q29yZUNvbnRleHQuSURFTlRJVFk7XG4gICAgICAgICAgICAgIHRoaXMucmVuZGVyU3RhdGUuYWRkUXVhZCh0aGlzKTtcbiAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG11c3RSZW5kZXJDaGlsZHJlbiA9IGZhbHNlO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAodGhpcy5fb3V0T2ZCb3VuZHMgPT09IDAgJiYgdGhpcy5fZGlzcGxheWVkVGV4dHVyZVNvdXJjZSkge1xuICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U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dGFzaFRleENvb3JkcygpO1xuICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRUZXh0dXJpemVyKG51bGwpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAocmVuZGVyVGV4dHVyZUluZm8gJiYgcmVuZGVyVGV4dHVyZUluZm8uY2FjaGUpIHtcbiAgICAgICAgICByZW5kZXJTdGF0ZS5pc0NhY2hpbmdUZXh0dXJpemVyID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IHpTb3J0KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3pTb3J0O1xuICAgIH1cbiAgICBzb3J0WkluZGV4ZWRDaGlsZHJlbigpIHtcbiAgICAgIGNvbnN0IG4gPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuLmxlbmd0aDtcbiAgICAgIGxldCBwdHIgPSAwO1xuICAgICAgY29uc3QgYSA9IHRoaXMuX3pJbmRleGVkQ2hpbGRyZW47XG4gICAgICBjb25zdCBiID0gW107XG4gICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICBpZiAoYVtpXS5felBhcmVudCA9PT0gdGhpcykge1xuICAgICAgICAgIGlmIChhW2ldLl96SW5kZXhSZXNvcnQpIHtcbiAgICAgICAgICAgIGIucHVzaChhW2ldKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHB0ciAhPT0gaSkge1xuICAgICAgICAgICAgICBhW3B0cl0gPSBhW2ldO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcHRyKys7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBjb25zdCBtID0gYi5sZW5ndGg7XG4gICAgICBpZiAobSkge1xuICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IG07IGorKykge1xuICAgICAgICAgIGJbal0uX3pJbmRleFJlc29ydCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGIuc29ydChFbGVtZW50Q29yZS5zb3J0WkluZGV4ZWRDaGlsZHJlbik7XG4gICAgICAgIGNvbnN0IG4yID0gcHRyO1xuICAgICAgICBpZiAoIW4yKSB7XG4gICAgICAgICAgcHRyID0gMDtcbiAgICAgICAgICBsZXQgaiA9IDA7XG4gICAgICAgICAgZG8ge1xuICAgICAgICAgICAgYVtwdHIrK10gPSBiW2orK107XG4gICAgICAgICAgfSB3aGlsZSAoaiA8IG0pO1xuICAgICAgICAgIGlmIChhLmxlbmd0aCA+IHB0cikge1xuICAgICAgICAgICAgYS5zcGxpY2UocHRyKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcHRyID0gMDtcbiAgICAgICAgICBsZXQgaSA9IDA7XG4gICAgICAgICAgbGV0IGogPSAwO1xuICAgICAgICAgIGNvbnN0IG1lcmdlUmVzdWx0ID0gW107XG4gICAgICAgICAgZG8ge1xuICAgICAgICAgICAgY29uc3QgdiA9IGFbaV0uX3pJbmRleCA9PT0gYltqXS5fekluZGV4ID8gYVtpXS5fdXBkYXRlVHJlZU9yZGVyIC0gYltqXS5fdXBkYXRlVHJlZU9yZGVyIDogYVtpXS5fekluZGV4IC0gYltqXS5fekluZGV4O1xuICAgICAgICAgICAgY29uc3QgYWRkID0gdiA+IDAgPyBiW2orK10gOiBhW2krK107XG4gICAgICAgICAgICBpZiAocHRyID09PSAwIHx8IG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQpIHtcbiAgICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGkgPj0gbjIpIHtcbiAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIGNvbnN0IGFkZDIgPSBiW2orK107XG4gICAgICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCBtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkMikge1xuICAgICAgICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkMjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0gd2hpbGUgKGogPCBtKTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGogPj0gbSkge1xuICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgY29uc3QgYWRkMiA9IGFbaSsrXTtcbiAgICAgICAgICAgICAgICBpZiAocHRyID09PSAwIHx8IG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQyKSB7XG4gICAgICAgICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQyO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSB3aGlsZSAoaSA8IG4yKTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSB3aGlsZSAodHJ1ZSk7XG4gICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbiA9IG1lcmdlUmVzdWx0O1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAoYS5sZW5ndGggPiBwdHIpIHtcbiAgICAgICAgICBhLnNwbGljZShwdHIpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuICAgIH1cbiAgICBnZXQgbG9jYWxUYSgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRhO1xuICAgIH1cbiAgICBnZXQgbG9jYWxUYigpIHtcbiAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRiO1xuICAgIH1cbiAgICBnZXQgbG9jYWxUYygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRjO1xuICAgIH1cbiAgICBnZXQgbG9jYWxUZCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRkO1xuICAgIH1cbiAgICBnZXQgZWxlbWVudCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9lbGVtZW50O1xuICAgIH1cbiAgICBnZXQgcmVuZGVyVXBkYXRlcygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9oYXNSZW5kZXJVcGRhdGVzO1xuICAgIH1cbiAgICBnZXQgdGV4dHVyaXplcigpIHtcbiAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplcikge1xuICAgICAgICB0aGlzLl90ZXh0dXJpemVyID0gbmV3IEVsZW1lbnRUZXh0dXJpemVyKHRoaXMpO1xuICAgICAgfVxuICAgICAgcmV0dXJuIHRoaXMuX3RleHR1cml6ZXI7XG4gICAgfVxuICAgIGdldENvcm5lclBvaW50cygpIHtcbiAgICAgIGxldCB3ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgcmV0dXJuIFtcbiAgICAgICAgdy5weCxcbiAgICAgICAgdy5weSxcbiAgICAgICAgdy5weCArIHRoaXMuX3cgKiB3LnRhLFxuICAgICAgICB3LnB5ICsgdGhpcy5fdyAqIHcudGMsXG4gICAgICAgIHcucHggKyB0aGlzLl93ICogdy50YSArIHRoaXMuX2ggKiB3LnRiLFxuICAgICAgICB3LnB5ICsgdGhpcy5fdyAqIHcudGMgKyB0aGlzLl9oICogdy50ZCxcbiAgICAgICAgdy5weCArIHRoaXMuX2ggKiB3LnRiLFxuICAgICAgICB3LnB5ICsgdGhpcy5faCAqIHcudGRcbiAgICAgIF07XG4gICAgfVxuICAgIGdldFJlbmRlclRleHR1cmVDb29yZHMocmVsWCwgcmVsWSkge1xuICAgICAgbGV0IHIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgcmV0dXJuIFtcbiAgICAgICAgci5weCArIHIudGEgKiByZWxYICsgci50YiAqIHJlbFksXG4gICAgICAgIHIucHkgKyByLnRjICogcmVsWCArIHIudGQgKiByZWxZXG4gICAgICBdO1xuICAgIH1cbiAgICBnZXRBYnNvbHV0ZUNvb3JkcyhyZWxYLCByZWxZKSB7XG4gICAgICBsZXQgdyA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICByZXR1cm4gW1xuICAgICAgICB3LnB4ICsgdy50YSAqIHJlbFggKyB3LnRiICogcmVsWSxcbiAgICAgICAgdy5weSArIHcudGMgKiByZWxYICsgdy50ZCAqIHJlbFlcbiAgICAgIF07XG4gICAgfVxuICAgIGNvbGxlY3RBdENvb3JkKHgsIHksIGNoaWxkcmVuKSB7XG4gICAgICBpZiAodGhpcy5fcmVuZGVyQ29udGV4dC5hbHBoYSA9PT0gMCkge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5pbkJvdW5kKHgsIHkpKSB7XG4gICAgICAgIGlmICh0aGlzLl9zY2lzc29yKSB7XG4gICAgICAgICAgaWYgKHRoaXMuaW5TY2lzc29yKCkpIHtcbiAgICAgICAgICAgIGNoaWxkcmVuLnB1c2godGhpcyk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNoaWxkcmVuLnB1c2godGhpcyk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICBjb25zdCBqID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGo7IGkrKykge1xuICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLmNvbGxlY3RBdENvb3JkKHgsIHksIGNoaWxkcmVuKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIGNoaWxkcmVuLnNvcnQoRWxlbWVudENvcmUuc29ydFpJbmRleGVkQ2hpbGRyZW4pO1xuICAgIH1cbiAgICBpbkJvdW5kKHR4LCB0eSkge1xuICAgICAgY29uc3QgYyA9IHRoaXMuZ2V0Q29ybmVyUG9pbnRzKCk7XG4gICAgICByZXR1cm4gdHggPiBjWzBdICY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XIgfHwgbC5fX29yaWdpbmFsRnVuYyA9PSBsaXN0ZW5lcikge1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdID09PSBsaXN0ZW5lciB8fCB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdLl9fb3JpZ2luYWxGdW5jID09PSBsaXN0ZW5lcikge1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIG9mZihuYW1lLCBsaXN0ZW5lcikge1xuICAgICAgaWYgKHRoaXMuX2hhc0V2ZW50TGlzdGVuZXJzKSB7XG4gICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdO1xuICAgICAgICBpZiAoY3VycmVudCkge1xuICAgICAgICAgIGlmIChjdXJyZW50ID09PSBFdmVudEVtaXR0ZXIuY29tYmluZXIpIHtcbiAgICAgICAgICAgIGNvbnN0IGxpc3RlbmVycyA9IHRoaXMuX2V2ZW50TGlzdGVuZXJzW25hbWVdO1xuICAgICAgICAgICAgbGV0IGluZGV4ID0gbGlzdGVuZXJzLmluZGV4T2YobGlzdGVuZXIpO1xuICAgICAgICAgICAgaWYgKGluZGV4ID49IDApIHtcbiAgICAgICAgICAgICAgbGlzdGVuZXJzLnNwbGljZShpbmRleCwgMSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpbmRleCA9IGxpc3RlbmVycy5tYXAoKGwpID0+IGwuX19vcmlnaW5hbEZ1bmMpLmluZGV4T2YobGlzdGVuZXIpO1xuICAgICAgICAgICAgaWYgKGluZGV4ID49IDApIHtcbiAgICAgICAgICAgICAgbGlzdGVuZXJzLnNwbGljZShpbmRleCwgMSk7XG4gICA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RleHR1cmVTb3VyY2UodGhpcy5fZ2V0U291cmNlTG9hZGVyKCksIGxvb2t1cElkKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHNvdXJjZTtcbiAgICB9XG4gICAgX2dldFJldXNhYmxlVGV4dHVyZVNvdXJjZShsb29rdXBJZCA9IHRoaXMuX2dldExvb2t1cElkKCkpIHtcbiAgICAgIGlmICh0aGlzLl9nZXRJc1ZhbGlkKCkpIHtcbiAgICAgICAgaWYgKGxvb2t1cElkKSB7XG4gICAgICAgICAgcmV0dXJuIHRoaXMubWFuYWdlci5nZXRSZXVzYWJsZVRleHR1cmVTb3VyY2UobG9va3VwSWQpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gbnVsbDtcbiAgICB9XG4gICAgX3JlcGxhY2VUZXh0dXJlU291cmNlKG5ld1NvdXJjZSA9IG51bGwpIHtcbiAgICAgIGxldCBvbGRTb3VyY2UgPSB0aGlzLl9zb3VyY2U7XG4gICAgICB0aGlzLl9zb3VyY2UgPSBuZXdTb3VyY2U7XG4gICAgICBpZiAodGhpcy5lbGVtZW50cy5zaXplKSB7XG4gICAgICAgIGlmIChvbGRTb3VyY2UpIHtcbiAgICAgICAgICBpZiAodGhpcy5fYWN0aXZlQ291bnQpIHtcbiAgICAgICAgICAgIG9sZFNvdXJjZS5kZWNBY3RpdmVUZXh0dXJlQ291bnQoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgb2xkU291cmNlLnJlbW92ZVRleHR1cmUodGhpcyk7XG4gICAgICAgICAgaWYgKHRoaXNbXCJ0ZXh0XCJdICYmICFvbGRTb3VyY2UuaXNVc2VkKCkpIHtcbiAgICAgICAgICAgIHRoaXMubWFuYWdlci5mcmVlVGV4dHVyZVNvdXJjZShvbGRTb3VyY2UpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAobmV3U291cmNlKSB7XG4gICAgICAgICAgbmV3U291cmNlLmFkZFRleHR1cmUodGhpcyk7XG4gICAgICAgICAgaWYgKHRoaXMuX2FjdGl2ZUNvdW50KSB7XG4gICAgICAgICAgICBuZXdTb3VyY2UuaW5jQWN0aXZlVGV4dHVyZUNvdW50KCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5pc1VzZWQoKSkge1xuICAgICAgICBpZiAobmV3U291cmNlKSB7XG4gICAgICAgICAgaWYgKG5ld1NvdXJjZS5pc0xvYWRlZCgpKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fcmVzaXplTW9kZSkge1xuICAgICAgICAgICAgICB0aGlzLl9hcHBseVJlc2l6ZU1vZGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaCgoZWxlbWVudCkgPT4ge1xuICAgICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICBlbGVtZW50Ll9zZXREaXNwbGF5ZWRUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3QgbG9hZEVycm9yID0gbmV3U291cmNlLmxvYWRFcnJvcjtcbiAgICAgICAgICAgIGlmIChsb2FkRXJyb3IpIHtcbiAgICAgICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKChlbGVtZW50KSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICBlbGVtZW50Lm9uVGV4dHVyZVNvdXJjZUxvYWRFcnJvcihsb2FkRXJyb3IpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaCgoZWxlbWVud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m9udFNldHRpbmcoXG4gICAgICAgICAgdGhpcy5fc2V0dGluZ3MuZm9udEZhY2UsXG4gICAgICAgICAgdGhpcy5fc2V0dGluZ3MuZm9udFN0eWxlLFxuICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTaXplLFxuICAgICAgICAgIHRoaXMuZ2V0UHJlY2lzaW9uKCksXG4gICAgICAgICAgdGhpcy5fc3RhZ2UuZ2V0T3B0aW9uKFwiZGVmYXVsdEZvbnRGYWNlXCIpXG4gICAgICAgICk7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgIHJldHVybiBkb2N1bWVudC5mb250cy5sb2FkKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KS5jYXRjaCgoZXJyKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIEZvbnQgbG9hZCBlcnJvclwiLCBlcnIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgIH0pLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICBpZiAoIWRvY3VtZW50LmZvbnRzLmNoZWNrKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KSkge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIEZvbnQgbm90IGZvdW5kXCIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gQ2FuJ3QgY2hlY2sgZm9udCBsb2FkaW5nIGZvciBcIiArIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cb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dGhpcy5fc2V0dGluZ3MubWF4TGluZXM7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICBvdGhlckxpbmVzW2pdICs9IChvdGhlckxpbmVzW2pdID8gXCIgXCIgOiBcIlwiKSArIGxpbmVzW2ldO1xuICAgICAgICAgIGlmIChpICsgMSA8IG0gJiYgbGluZXNJbmZvLm5baSArIDFdKSB7XG4gICAgICAgICAgICBqKys7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJlbmRlckluZm8ucmVtYWluaW5nVGV4dCA9IG90aGVyTGluZXMuam9pbihcIlxcblwiKTtcbiAgICAgICAgcmVuZGVySW5mby5tb3JlVGV4dExpbmVzID0gdHJ1ZTtcbiAgICAgICAgbGluZXMgPSB1c2VkTGluZXM7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZW5kZXJJbmZvLm1vcmVUZXh0TGluZXMgPSBmYWxzZTtcbiAgICAgICAgcmVuZGVySW5mby5yZW1haW5pbmdUZXh0ID0gXCJcIjtcbiAgICAgIH1cbiAgICAgIGxldCBtYXhMaW5lV2lkdGggPSAwO1xuICAgICAgbGV0IGxpbmVXaWR0aHMgPSBbXTtcbiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGluZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgbGV0IGxpbmVXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQobGluZXNbaV0sIGxldHRlclNwYWNpbmcpICsgKGkgPT09IDAgPyB0ZXh0SW5kZW50IDogMCk7XG4gICAgICAgIGxpbmVXaWR0aHMucHVzaChsaW5lV2lkdGgpO1xuICAgICAgICBtYXhMaW5lV2lkdGggPSBNYXRoLm1heChtYXhMaW5lV2lkdGgsIGxpbmVXaWR0aCk7XG4gICAgICB9XG4gICAgICByZW5kZXJJbmZvLmxpbmVXaWR0aHMgPSBsaW5lV2lkdGhzO1xuICAgICAgaWYgKCF3KSB7XG4gICAgICAgIHdpZHRoID0gbWF4TGluZVdpZHRoICsgcGFkZ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Rm9udFByb3BlcnRpZXMoKSB7XG4gICAgICBjb25zdCBmb250ID0gZ2V0Rm9udFNldHRpbmcoXG4gICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRGYWNlLFxuICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U3R5bGUsXG4gICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTaXplLFxuICAgICAgICB0aGlzLmdldFByZWNpc2lvbigpLFxuICAgICAgICB0aGlzLl9zdGFnZS5nZXRPcHRpb24oXCJkZWZhdWx0Rm9udEZhY2VcIilcbiAgICAgICk7XG4gICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSBmb250O1xuICAgICAgdGhpcy5fY29udGV4dC50ZXh0QmFzZWxpbmUgPSB0aGlzLl9zZXR0aW5ncy50ZXh0QmFzZWxpbmU7XG4gICAgICByZXR1cm4gZm9udDtcbiAgICB9XG4gICAgX2xvYWQoKSB7XG4gICAgICBpZiAoVXRpbHMkMS5pc1dlYiAmJiBkb2N1bWVudC5mb250cykge1xuICAgICAgICBjb25zdCBmb250U2V0dGluZyA9IGdldEZvbnRTZXR0aW5nKFxuICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRGYWNlLFxuICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTdHlsZSxcbiAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U2l6ZSxcbiAgICAgICAgICB0aGlzLmdldFByZWNpc2lvbigpLFxuICAgICAgICAgIHRoaXMuX3N0YWdlLmdldE9wdGlvbihcImRlZmF1bHRGb250RmFjZVwiKVxuICAgICAgICApO1xuICAgICAgICB0cnkge1xuICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuZm9udHMubG9hZChmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkuY2F0Y2goKGVycikgPT4ge1xuICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJGb250IGxvYWQgZXJyb3JcIiwgZXJyLCBmb250U2V0dGluZyk7XG4gICAgICAgICAgICB9KS50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJGb250IG5vdCBmb3VuZFwiLCBmb250U2V0dGluZyk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgIGNvbnNvbGUud2FybihcIkNhbid0IGNoZWNrIGZvbnQgbG9hZGluZyBmb3IgXCIgKyBmb250U2V0dGluZyk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZHJhdygpIHtcbiAgICAgIGNvbnN0IGxvYWRQcm9taXNlID0gdGhpcy5fbG9hZCgpO1xuICAgICAgaWYgKCFsb2FkUHJvbWlzZSkge1xuICAgICAgICByZXR1cm4gVXRpbHMkMS5pc1NwYXJrID8gdGhpcy5fc3RhZ2UucGxhdGZvcm0uZHJhd1RleHQodGhpcykgOiB0aGlzLl9kcmF3KCk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gbG9hZFByb21pc2UudGhlbigoKSA9PiB7XG4gICAgICAgICAgcmV0dXJuIFV0aWxzJDEuaXNTcGFyayA/IHRoaXMuX3N0YWdlLnBsYXRmb3JtLmRyYXdUZXh0KHRoaXMpIDogdGhpcy5fZHJhdygpO1xuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICB9XG4gICAgX2NhbGN1bGF0ZVJlbmRlckluZm8oKSB7XG4gICAgICBsZXQgcmVuZGVySW5mbyA9IHt9O1xuICAgICAgY29uc3QgcHJlY2lzaW9uID0gdGhpcy5nZXRQcm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biAgICAgIH1cbiAgICAgIHRleHQgPSB0aGlzLnRva2VuaXplKHRleHQpO1xuICAgICAgdGV4dCA9IHRoaXMucGFyc2UodGV4dCk7XG4gICAgICB0ZXh0ID0gdGhpcy5tZWFzdXJlKHRleHQsIGxldHRlclNwYWNpbmcsIHJlbmRlckluZm8uYmFzZUZvbnQpO1xuICAgICAgaWYgKHJlbmRlckluZm8udGV4dEluZGVudCkge1xuICAgICAgICB0ZXh0ID0gdGhpcy5pbmRlbnQodGV4dCwgcmVuZGVySW5mby50ZXh0SW5kZW50KTtcbiAgICAgIH1cbiAgICAgIGlmIChyZW5kZXJJbmZvLndvcmRCcmVhaykge1xuICAgICAgICB0ZXh0ID0gdGV4dC5yZWR1Y2UoKGFjYywgdCkgPT4gYWNjLmNvbmNhdCh0aGlzLndvcmRCcmVhayh0LCB3cmFwV2lkdGgsIHJlbmRlckluZm8uYmFzZUZvbnQpKSwgW10pO1xuICAgICAgICB0aGlzLnJlc2V0Rm9udFN0eWxlKCk7XG4gICAgICB9XG4gICAgICBsZXQgeCA9IHBhZGRpbmdMZWZ0O1xuICAgICAgbGV0IGxpbmVObyA9IDA7XG4gICAgICBmb3IgKGNvbnN0IHQgb2YgdGV4dCkge1xuICAgICAgICBpZiAocmVuZGVySW5mby53b3JkV3JhcCAmJiB4ICsgdC53aWR0aCA+IHdyYXBXaWR0aCB8fCB0LnRleHQgPT0gXCJcXG5cIikge1xuICAgICAgICAgIHggPSBwYWRkaW5nTGVmdDtcbiAgICAgICAgICBsaW5lTm8gKz0gMTtcbiAgICAgICAgfVxuICAgICAgICB0LmxpbmVObyA9IGxpbmVObztcbiAgICAgICAgaWYgKHQudGV4dCA9PSBcIlxcblwiKSB7XG4gICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgdC54ID0geDtcbiAgICAgICAgeCArPSB0LndpZHRoO1xuICAgICAgfVxuICAgICAgcmVuZGVySW5mby5saW5lTnVtID0gbGluZU5vICsgMTtcbiAgICAgI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mVIZWlnaHQgLSByZW5kZXJJbmZvLmZvbnRTaXplO1xuICAgICAgfVxuICAgICAgcmVuZGVySW5mby5saW5lcyA9IFtdO1xuICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCByZW5kZXJJbmZvLmxpbmVOdW07IGkrKykge1xuICAgICAgICByZW5kZXJJbmZvLmxpbmVzW2ldID0ge1xuICAgICAgICAgIHdpZHRoOiAwLFxuICAgICAgICAgIHg6IDAsXG4gICAgICAgICAgeTogcmVuZGVySW5mby5saW5lSGVpZ2h0ICogaSArIHZhT2Zmc2V0LFxuICAgICAgICAgIHRleHQ6IFtdXG4gICAgICAgIH07XG4gICAgICB9XG4gICAgICBmb3IgKGxldCB0IG9mIHRleHQpIHtcbiAgICAgICAgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10udGV4dC5wdXNoKHQpO1xuICAgICAgfVxuICAgICAgZm9yIChjb25zdCBsIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgaWYgKGwudGV4dC5sZW5ndGggPT0gMCkge1xuICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGZpcnN0V29yZCA9IGwudGV4dFswXS50ZXh0O1xuICAgICAgICBjb25zdCBsYXN0V29yZCA9IGwudGV4dFtsLnRleHQubGVuZ3RoIC0gMV0udGV4dDtcbiAgICAgICAgaWYgKGZpcnN0V29yZCA9PSBcIlxcblwiKSB7XG4gICAgICAgICAgbC50ZXh0LnNoaWZ0KCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGlzU3BhY2UobGFzdFdvcmQpIHx8IGxhc3RXb3JkID09IFwiXFxuXCIpIHtcbiAgICAgICAgICBsLnRleHQucG9wKCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICBsLndpZHRoID0gbC50ZXh0LnJlZHVjZSgoYWNjLCB0KSA9PiBhY2MgKyB0L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JlZHVjZSgoYWNjLCB0KSA9PiBhY2MgKyB0LndpZHRoLCAwKTtcbiAgICAgICAgd2hpbGUgKF93ID4gcmVuZGVySW5mby53aWR0aCB8fCBpc1NwYWNlKGxhc3RMaW5lVGV4dFtsYXN0TGluZVRleHQubGVuZ3RoIC0gc3BsXS50ZXh0KSkge1xuICAgICAgICAgIGxhc3RMaW5lVGV4dC5zcGxpY2UobGFzdExpbmVUZXh0Lmxlbmd0aCAtIHNwbCwgMSk7XG4gICAgICAgICAgX3cgPSBsYXN0TGluZVRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYyArIHQud2lkdGgsIDApO1xuICAgICAgICAgIGlmIChsYXN0TGluZVRleHQubGVuZ3RoIDwgc3BsKSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5hbGlnbkxpbmUobGFzdExpbmVUZXh0LCBsYXN0TGluZVRleHRbMF0ueCk7XG4gICAgICAgIHJlbmRlckluZm8ubGluZXNbaW5kZXhdLnRleHQgPSBsYXN0TGluZVRleHQ7XG4gICAgICAgIHJlbmRlckluZm8ubGluZXNbaW5kZXhdLndpZHRoID0gX3c7XG4gICAgICB9XG4gICAgICBpZiAocmVuZGVySW5mby50ZXh0QWxpZ24gPT0gXCJjZW50ZXJcIikge1xuICAgICAgICBmb3IgKGxldCBsIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgICBsLnggPSAocmVuZGVySW5mby53aWR0aCAtIGwud2lkdGggLSBwYWRkaW5nTGVmdCkgLyAyO1xuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKHJlbmRlckluZm8udGV4dEFsaWduID09IFwicmlnaHRcIikge1xuICAgICAgICBmb3IgKGxldCBsIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgICBsLnggPSByZW5kZXJJbmZvLndpZHRoIC0gbC53aWR0aCAtIHBhZGRpbmdMZWZ0O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gcmVuZGVySW5mbztcbiAgICB9XG4gICAgX2RyYXcoKSB7XG4gICAgICBjb25zdCByZW5kZXJJbmZvID0gdGhpcy5fY2FsY3VsYXRlUmVuZGVySW5mbygpO1xuICAgICAgY29uc3QgcHJlY2lzaW9uID0gdGhpcy5nZXRQcmVjaXNpb24oKTtcbiAgICAgIGNvbnN0IHBhZGRpbmdMZWZ0ID0gcmVuZGVySW5mby5wYWRkaW5nTGVmdCAqIHByZWNpc2lvbjtcbiAgICAgIGxldCBjYW52YXNXaWR0aCA9IHJlbmRlckluZm8udyB8fCByZW5kZXJJbmZvLndpZHRoO1xuICAgICAgaWYgKHJlbmRlckluZm8uY3V0U3ggfHwgcmVuZGVySW5mby5jdXRFeCkge1xuICAgICAgICBjYW52YXNXaWR0aCA9IE1hdGgubWluKHJlbmRlckluZm8udywgcmVuZGVySW5mby5jdXRFeCAtIHJlbmRlckluZm8uY3V0U3gpO1xuICAgICAgfVxuICAgICAgbGV0IGNhbnZhc0hlaWdodCA9IHJlbmRlckluZm8uaDtcbiAgICAgIGlmIChyZW5kZXJJbmZvLmN1dFN5IHx8IHJlbmRlckluZm8uY3V0RXkpIHtcbiAgICAgICAgY2FudmFzSGVpZ2h0ID0gTWF0aC5taW4ocmVuZGVySW5mby5oLCByZW5kZXJJbmZvLmN1dEV5IC0gcmVuZGVySW5mby5jdXRTeSk7XG4gICAgICB9XG4gICAgICB0aGlzLl9jYW52YXMud2lkdGggPSBNYXRoLmNlaWwoY2FudmFzV2lkdGggKyB0aGlzLl9zdGFnZS5nZXRPcHRpb24oXCJ0ZXh0UmVuZGVySXNzdWVNYXJnaW5cIikpO1xuICAgICAgdGhpcy5fY2FudmFzLmhlaWdodCA9IE1hdGguY2VpbChjYW52YXNIZWlnaHQpO1xuICAgICAgdGhpcy5zZXRGb250UHJvcGVydGllcygpO1xuICAgICAgaWYgKHJlbmRlckluZm8uZm9udFNpemUgPj0gMTI4KSB7XG4gICAgICAg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RoaXMuX3NldHRpbmdzLnNoYWRvd09mZnNldFggKiBwcmVjaXNpb247XG4gICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93T2Zmc2V0WSA9IHRoaXMuX3NldHRpbmdzLnNoYWRvd09mZnNldFkgKiBwcmVjaXNpb247XG4gICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Qmx1ciA9IHRoaXMuX3NldHRpbmdzLnNoYWRvd0JsdXIgKiBwcmVjaXNpb247XG4gICAgICB9XG4gICAgICBjb25zdCBkZWZhdWx0Q29sb3IgPSBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodGhpcy5fc2V0dGluZ3MudGV4dENvbG9yKTtcbiAgICAgIGxldCBjdXJyZW50Q29sb3IgPSBkZWZhdWx0Q29sb3I7XG4gICAgICB0aGlzLl9jb250ZXh0LmZpbGxTdHlsZSA9IGRlZmF1bHRDb2xvcjtcbiAgICAgIGZvciAoY29uc3QgbGluZSBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgIGZvciAoY29uc3QgdCBvZiBsaW5lLnRleHQpIHtcbiAgICAgICAgICBsZXQgbHggPSAwO1xuICAgICAgICAgIGlmICh0LnRleHQgPT0gXCJcXG5cIikge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChyZW5kZXJJbmZvLm1heExpbmVzICYmIHQubGluZU5vID49IHJlbmRlckluZm8ubWF4TGluZXMpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodC5jb2xvciAhPSBjdXJyZW50Q29sb3IpIHtcbiAgICAgICAgICAgIGN1cnJlbnRDb2xvciA9IHQuY29sb3I7XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxTdHlsZSA9IGN1cnJlbnRDb2xvcjtcbiAgICAgICAgICB9XG4gICAgICAgICAgdGhpcy5fY29udGV4dC5mb250ID0gdC5mb250U3R5bGU7XG4gICAgICAgICAgaWYgKHQubGV0dGVycykge1xuICAgICAgICAgICAgZm9yIChsZXQgbCBvZiB0LmxldHRlcnMpIHtcbiAgICAgICAgICAgICAgY29uc3QgX3ggPSByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS54ICsgdC54ICsgbHg7XG4gICAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFRleHQobC50ZXh0LCBfeCwgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueSArIHJlbmRlckluZm8uZm9udFNpemUpO1xuICAgICAgICAgICAgICBseCArPSBsLndpZHRoO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBfeCA9IHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnggKyB0Lng7XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KHQudGV4dCwgX3gsIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnkgKyByZW5kZXJJbmZvLmZvbnRTaXplKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChwcmV2U2hhZG93U2V0dGluZ3MpIHtcbiAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dDb2xvciA9IHByZXZTaGFkb3dTZXR0aW5nc1swXTtcbiAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dPZmZzZXRYID0gcHJldlNoYWRvd1NldHRpbmdzWzFdO1xuICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFkgPSBwcmV2U2hhZG93U2V0dGluZ3NbMl07XG4gICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Qmx1ciA9IHByZXZTaGFkb3dTZXR0aW5nc1szXTtcbiAgICAgIH1cbiAgICAgIGlmIChyZW5kZXJJbmZvLmN1dFN4IHx8IHJlbmRlckluZm8uY3V0U3kpIHtcbiAgICAgICAgdGhpcy5fY29udGV4dC50cmFuc2x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lwiKSB7XG4gICAgICAgICAgaXRhbGljICs9IDE7XG4gICAgICAgICAgdCA9IFwiXCI7XG4gICAgICAgIH0gZWxzZSBpZiAodCA9PSBcIjwvaT5cIiAmJiBpdGFsaWMgPiAwKSB7XG4gICAgICAgICAgaXRhbGljIC09IDE7XG4gICAgICAgICAgdCA9IFwiXCI7XG4gICAgICAgIH0gZWxzZSBpZiAodCA9PSBcIjxiPlwiKSB7XG4gICAgICAgICAgYm9sZCArPSAxO1xuICAgICAgICAgIHQgPSBcIlwiO1xuICAgICAgICB9IGVsc2UgaWYgKHQgPT0gXCI8L2I+XCIgJiYgYm9sZCA+IDApIHtcbiAgICAgICAgICBib2xkIC09IDE7XG4gICAgICAgICAgdCA9IFwiXCI7XG4gICAgICAgIH0gZWxzZSBpZiAodCA9PSBcIjwvY29sb3I+XCIpIHtcbiAgICAgICAgICBpZiAoY29sb3JTdGFjay5sZW5ndGggPiAxKSB7XG4gICAgICAgICAgICBjb2xvciAtPSAxO1xuICAgICAgICAgICAgY29sb3JTdGFjay5wb3AoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgdCA9IFwiXCI7XG4gICAgICAgIH0gZWxzZSBpZiAoY29sb3JSZWdleHAudGVzdCh0KSkge1xuICAgICAgICAgIGNvbnN0IG1hdGNoZWQgPSBjb2xvclJlZ2V4cC5leGVjKHQpO1xuICAgICAgICAgIGNvbG9yU3RhY2sucHVzaChcbiAgICAgICAgICAgIFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyhwYXJzZUludChtYXRjaGVkWzFdKSlcbiAgICAgICAgICApO1xuICAgICAgICAgIGNvbG9yICs9IDE7XG4gICAgICAgICAgdCA9IFwiXCI7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICB0ZXh0OiB0LFxuICAgICAgICAgIGl0YWxpYyxcbiAgICAgICAgICBib2xkLFxuICAgICAgICAgIGNvbG9yOiBjb2xvclN0YWNrW2NvbG9yXVxuICAgICAgICB9O1xuICAgICAgfSkuZmlsdGVyKChvKSA9PiBvLnRleHQgIT0gXCJcIik7XG4gICAgfVxuICAgIGFwcGx5Rm9udFN0eWxlKHdvcmQsIGJhc2VGb250KSB7XG4gICAgICBsZXQgZm9udCA9IGJhc2VGb250O1xuICAgICAgaWYgKHdvcmQuYm9sZCkge1xuICAgICAgICBmb250ID0gXCJib2xkIFwiICsgZm9udDtcbiAgICAgIH1cbiAgICAgIGlmICh3b3JkLml0YWxpYykge1xuICAgICAgICBmb250ID0gXCJpdGFsaWMgXCIgKyBmb250O1xuICAgICAgfVxuICAgICAgdGhpcy5fY29udGV4dC5mb250ID0gZm9udDtcbiAgICAgIHdvcmQuZm9udFN0eWxlID0gZm9udDtcbiAgICB9XG4gICAgcmVzZXRGb250U3R5bGUoYmFzZUZvbnQpIHtcbiAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IGJhc2VGb250O1xuICAgIH1cbiAgICBtZWFzdXJlKHBhcnNlZCwgbGV0dGVyU3BhY2luZyA9IDAsIGJhc2VGb250KSB7XG4gICAgICBmb3IgKGNvbnN0IHAgb2YgcGFyc2VkKSB7XG4gICAgICAgIHRoaXMuYXBwbHlGb250U3R5bGUocCwgYmFzZUZvbnQpO1xuICAgICAgICBwLndpZHRoID0gdGhpcy5tZWFzdXJlVGV4dChwLnRleHQsIGxldHRlclNwYWNpbmcpO1xuICAgICAgICBpZiAobGV0dGVyU3BhY2luZyA+IDApIHtcbiAgICAgICAgICBwLmxldHRlcnMgPSBwLnRleHQuc3BsaXQoXCJcIikubWFwKChsKSA9PiB7XG4gICAgICAgICAgICByZXR1cm4geyB0ZXh0OiBsIH07XG4gICAgICAgICAgfSk7XG4gICAgICAgICAgZm9yIChsZXQgbCBvZiBwLmxldHRlcnMpIHtcbiAgICAgICAgICAgIGwud2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KGwudGV4dCwgbGV0dGVyU3BhY2luZyk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9X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tcbiAgICAgIGxldCB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgYnJlYWtJbmRleCkpO1xuICAgICAgaWYgKHRydW5jV29yZFdpZHRoID4gd2lkdGgpIHtcbiAgICAgICAgd2hpbGUgKGJyZWFrSW5kZXggPiAwKSB7XG4gICAgICAgICAgdHJ1bmNXb3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQuc3Vic3RyaW5nKDAsIGJyZWFrSW5kZXgpKTtcbiAgICAgICAgICBpZiAodHJ1bmNXb3JkV2lkdGggPiB3aWR0aCkge1xuICAgICAgICAgICAgYnJlYWtJbmRleCAtPSAxO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHdoaWxlIChicmVha0luZGV4IDwgd29yZExlbikge1xuICAgICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSk7XG4gICAgICAgICAgaWYgKHRydW5jV29yZFdpZHRoIDwgd2lkdGgpIHtcbiAgICAgICAgICAgIGJyZWFrSW5kZXggKz0gMTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgYnJlYWtJbmRleCAtPSAxO1xuICAgICAgICAgICAgdHJ1bmNXb3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQuc3Vic3RyaW5nKDAsIGJyZWFrSW5kZXgpKTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHsgYnJlYWtJbmRleCwgdHJ1bmNXb3JkV2lkdGggfTtcbiAgICB9XG4gICAgd29yZEJyZWFrKHdvcmQsIHdpZHRoLCBiYXNlRm9udCkge1xuICAgICAgaWYgKCF3b3JkLnRleHQpIHtcbiAgICAgICAgcmV0dXJuIHdvcmQ7XG4gICAgICB9XG4gICAgICB0aGlzLmFwcGx5Rm9udFN0eWxlKHdvcmQsIGJhc2VGb250KTtcbiAgICAgIGNvbnN0IHBhcnRzID0gW107XG4gICAgICBsZXQgdGV4dCA9IHdvcmQudGV4dDtcbiAgICAgIGlmICghd29yZC5sZXR0ZXJzKSB7XG4gICAgICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgICAgY29uc3QgeyBicmVha0luZGV4LCB0cnVuY1dvcmRXaWR0aCB9ID0gdGhpcy5fZ2V0QnJlYWtJbmRleCh0ZXh0LCB3aWR0aCk7XG4gICAgICAgICAgcGFydHMucHVzaCh7IC4uLndvcmQgfSk7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0udGV4dCA9IHRleHQuc2xpY2UoMCwgYnJlYWtJbmRleCk7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ud2lkdGggPSB0cnVuY1dvcmRXaWR0aDtcbiAgICAgICAgICBpZiAoYnJlYWtJbmRleCA9PT0gdGV4dC5sZW5ndGgpIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0ZXh0ID0gdGV4dC5zbGljZShicmVha0luZGV4KTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgbGV0IHRvdGFsV2lkdGggPSAwO1xuICAgICAgICBsZXQgbGV0dGVycyA9IFtdO1xuICAgICAgICBsZXQgYnJlYWtJbmRleCA9IDA7XG4gICAgICAgIGZvciAoY29uc3QgbCBvZiB3b3JkLmxldHRlcnMpIHtcbiAgICAgICAgICBpZiAodG90YWxXaWR0aCArIGwud2lkdGggPj0gd2lkdGgpIHtcbiAgICAgICAgICAgIHBhcnRzLnB1c2goeyAuLi53b3JkIH0pO1xuICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0udGV4dCA9IHRleHQuc2xpY2UoMCwgYnJlYWtJbmRleCk7XG4gICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS53aWR0aCA9IHRvdGFsV2lkdGg7XG4gICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS5sZXR0ZXJzID0gbGV0dGVycztcbiAgICAgICAgICAgIHRleHQgPSB0ZXh0LnNsaWNlKGJyZWFrSW5kZXgpO1xuICAgICAgICAgICAgdG90YWxXaWR0aCA9IDA7XG4gICAgICAgICAgICBsZXR0ZXJzID0gW107XG4gICAgICAgICAgICBicmVha0luZGV4ID0gMDtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgYnJlYWtJbmRleCArPSAxO1xuICAgICAgICAgICAgbGV0dGVycy5wdXNoKGwpO1xuICAgICAgICAgICAgdG90YWxXaWR0aCArPSBsLndpZHRoO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodG90YWxXaWR0aCA+IDApIHtcbiAgICAgICAgICBwYXJ0cy5wdXNoKHsgLi4ud29yZCB9KTtcbiAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5zbGljZSgwLCBicmVha0luZGV4KTtcbiAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS53aWR0aCA9IHRvdGFsV2lkdGg7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ubGV0dGVycyA9IGxldHRlcnM7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBwYXJ0cztcbiAgICB9XG4gICAgYWxpZ25MaW5lKHBhcnNlZCwgaW5pdGlhbFggPSAwKSB7XG4gICAgICBsZXQgcHJldldpZHRoID0gMDtcbiAgICAgIGxldCBwcmV2WCA9IGluaXRpYWxYO1xuICAgICAgZm9yIChjb25zdCB3b3JkIG9mIHBhcnNlZCkge1xuICAgICAgICBpZiAod29yZ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mdCA+IDApIHtcbiAgICAgICAgICB0aGlzLl9kZWxheUxlZnQgLT0gZHQ7XG4gICAgICAgICAgaWYgKHRoaXMuZGVsYXlMZWZ0IDwgMCkge1xuICAgICAgICAgICAgZHQgPSAtdGhpcy5kZWxheUxlZnQ7XG4gICAgICAgICAgICB0aGlzLl9kZWxheUxlZnQgPSAwO1xuICAgICAgICAgICAgdGhpcy5lbWl0KFwiZGVsYXlFbmRcIik7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLmR1cmF0aW9uID09IDApIHtcbiAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gdGhpcy5fc2V0dGluZ3MuZHVyYXRpb247XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3AgPj0gMSkge1xuICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB0aGlzLl91cGRhdGVEcmF3VmFsdWUoKTtcbiAgICAgIHRoaXMuaW52b2tlTGlzdGVuZXJzKCk7XG4gICAgfVxuICAgIGludm9rZUxpc3RlbmVycygpIHtcbiAgICAgIHRoaXMuZW1pdChcInByb2dyZXNzXCIsIHRoaXMucCk7XG4gICAgICBpZiAodGhpcy5wID09PSAxKSB7XG4gICAgICAgIHRoaXMuZW1pdChcImZpbmlzaFwiKTtcbiAgICAgIH1cbiAgICB9XG4gICAgdXBkYXRlVGFyZ2V0VmFsdWUodGFyZ2V0VmFsdWUpIHtcbiAgICAgIGxldCB0ID0gdGhpcy5fc2V0dGluZ3MudGltaW5nRnVuY3Rpb25JbXBsKHRoaXMucCk7XG4gICAgICBpZiAodCA9PT0gMSkge1xuICAgICAgICB0aGlzLl90YXJnZXRWYWx1ZSA9IHRhcmdldFZhbHVlO1xu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GluZ3MpIHtcbiAgICAgIGxldCByZWZzID0gdGhpcy5fZ2V0UmVmcygpO1xuICAgICAgbGV0IGNyZWZzID0gT2JqZWN0LmtleXMoc2V0dGluZ3MpO1xuICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBjcmVmcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgbGV0IGNyZWYgPSBjcmVmc1tpXTtcbiAgICAgICAgbGV0IHMgPSBzZXR0aW5nc1tjcmVmXTtcbiAgICAgICAgbGV0IGMgPSByZWZzW2NyZWZdO1xuICAgICAgICBpZiAoIWMpIHtcbiAgICAgICAgICBpZiAodGhpcy5pc0l0ZW0ocykpIHtcbiAgICAgICAgICAgIHMucmVmID0gY3JlZjtcbiAgICAgICAgICAgIHRoaXMuYWRkKHMpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjID0gdGhpcy5jcmVhdGVJdGVtKHMpO1xuICAgICAgICAgICAgYy5yZWYgPSBjcmVmO1xuICAgICAgICAgICAgYy5wYXRjaChzKTtcbiAgICAgICAgICAgIHRoaXMuYWRkKGMpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAodGhpcy5pc0l0ZW0ocykpIHtcbiAgICAgICAgICAgIGlmIChjICE9PSBzKSB7XG4gICAgICAgICAgICAgIGxldCBpZHggPSB0aGlzLmdldEluZGV4KGMpO1xuICAgICAgICAgICAgICBzLnJlZiA9IGNyZWY7XG4gICAgICAgICAgICAgIHRoaXMuc2V0QXQocywgaWR4KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgYy5wYXRjaChzKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgX2VxdWFsc0FycmF5KGFycmF5KSB7XG4gICAgICBsZXQgc2FtZSA9IHRydWU7XG4gICAgICBpZiAoYXJyYXkubGVuZ3RoID09PSB0aGlz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ICAgICBpZiAodGhpcy5fX3JlZiAhPT0gbnVsbCkge1xuICAgICAgICAgIHRoaXMucmVtb3ZlVGFnKHRoaXMuX19yZWYpO1xuICAgICAgICAgIGlmICh0aGlzLl9fcGFyZW50KSB7XG4gICAgICAgICAgICB0aGlzLl9fcGFyZW50Ll9fY2hpbGRMaXN0LmNsZWFyUmVmKHRoaXMuX19yZWYpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9fcmVmID0gcmVmO1xuICAgICAgICBpZiAodGhpcy5fX3JlZikge1xuICAgICAgICAgIHRoaXMuX2FkZFRhZyh0aGlzLl9fcmVmKTtcbiAgICAgICAgICBpZiAodGhpcy5fX3BhcmVudCkge1xuICAgICAgICAgICAgdGhpcy5fX3BhcmVudC5fX2NoaWxkTGlzdC5zZXRSZWYodGhpcy5fX3JlZiwgdGhpcyk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGdldCByZWYoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX3JlZjtcbiAgICB9XG4gICAgZ2V0IGNvcmUoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmU7XG4gICAgfVxuICAgIHNldEFzUm9vdCgpIHtcbiAgICAgIHRoaXMuX19jb3JlLnNldEFzUm9vdCgpO1xuICAgICAgdGhpcy5fdXBkYXRlQXR0YWNoZWRGbGFnKCk7XG4gICAgICB0aGlzLl91cGRhdGVFbmFibGVkRmxhZygpO1xuICAgIH1cbiAgICBnZXQgaXNSb290KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmlzUm9vdDtcbiAgICB9XG4gICAgX3NldFBhcmVudChwYXJlbnQpIHtcbiAgICAgIGlmICh0aGlzLl9fcGFyZW50ID09PSBwYXJlbnQpXG4gICAgICAgIHJldHVybjtcbiAgICAgIGlmICh0aGlzLl9fcGFyZW50KSB7XG4gICAgICAgIHRoaXMuX3Vuc2V0VGFnc1BhcmVudCgpO1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dG9yQXREZXB0aChkZXB0aCkge1xuICAgICAgbGV0IGxldmVscyA9IHRoaXMuZ2V0RGVwdGgoKSAtIGRlcHRoO1xuICAgICAgaWYgKGxldmVscyA8IDApIHtcbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICB9XG4gICAgICByZXR1cm4gdGhpcy5nZXRBbmNlc3RvcihsZXZlbHMpO1xuICAgIH1cbiAgICBpc0FuY2VzdG9yT2YoYykge1xuICAgICAgbGV0IHAgPSBjO1xuICAgICAgd2hpbGUgKHAgPSBwLnBhcmVudCkge1xuICAgICAgICBpZiAodGhpcyA9PT0gcCkge1xuICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIGdldFNoYXJlZEFuY2VzdG9yKGMpIHtcbiAgICAgIGxldCBvMSA9IHRoaXM7XG4gICAgICBsZXQgbzIgPSBjO1xuICAgICAgbGV0IGwxID0gbzEuZ2V0RGVwdGgoKTtcbiAgICAgIGxldCBsMiA9IG8yLmdldERlcHRoKCk7XG4gICAgICBpZiAobDEgPiBsMikge1xuICAgICAgICBvMSA9IG8xLmdldEFuY2VzdG9yKGwxIC0gbDIpO1xuICAgICAgfSBlbHNlIGlmIChsMiA+IGwxKSB7XG4gICAgICAgIG8yID0gbzIuZ2V0QW5jZXN0b3IobDIgLSBsMSk7XG4gICAgICB9XG4gICAgICBkbyB7XG4gICAgICAgIGlmIChvMSA9PT0gbzIpIHtcbiAgICAgICAgICByZXR1cm4gbzE7XG4gICAgICAgIH1cbiAgICAgICAgbzEgPSBvMS5fX3BhcmVudDtcbiAgICAgICAgbzIgPSBvMi5fX3BhcmVudDtcbiAgICAgIH0gd2hpbGUgKG8xICYmIG8yKTtcbiAgICAgIHJldHVybiBudWxsO1xuICAgIH1cbiAgICBnZXQgYXR0YWNoZWQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2F0dGFjaGVkO1xuICAgIH1cbiA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biAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbTsgaSsrKSB7XG4gICAgICAgICAgICAgIGNoaWxkcmVuW2ldLl91cGRhdGVBdHRhY2hlZEZsYWcoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG5ld0F0dGFjaGVkKSB7XG4gICAgICAgICAgdGhpcy5fb25BdHRhY2goKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl9vbkRldGFjaCgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVFbmFibGVkRmxhZygpIHtcbiAgICAgIGxldCBuZXdFbmFibGVkID0gdGhpcy5faXNFbmFibGVkKCk7XG4gICAgICBpZiAodGhpcy5fX2VuYWJsZWQgIT09IG5ld0VuYWJsZWQpIHtcbiAgICAgICAgaWYgKG5ld0VuYWJsZWQpIHtcbiAgICAgICAgICB0aGlzLl9vbkVuYWJsZWQoKTtcbiAgICAgICAgICB0aGlzLl9zZXRFbmFibGVkRmxhZygpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuX29uRGlzYWJsZWQoKTtcbiAgICAgICAgICB0aGlzLl91bnNldEVuYWJsZWRGbGFnKCk7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGNoaWxkcmVuID0gdGhpcy5fY2hpbGRyZW4uZ2V0KCk7XG4gICAgICAgIGlmIChjaGlsZHJlbikge1xuICAgICAgICAgIGxldCBtID0gY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICAgIGlmIChtID4gMCkge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBtOyBpKyspIHtcbiAgICAgICAgICAgICAgY2hpbGRyZW5baV0uX3VwZGF0ZUVuYWJsZWRGbGFnKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF9zZXRF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KSkge1xuICAgICAgICB0aGlzLl9zZXREaXNwbGF5ZWRUZXh0dXJlKHRoaXMuX190ZXh0dXJlKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMuX3NldERpc3BsYXllZFRleHR1cmUobnVsbCk7XG4gICAgICAgIHRoaXMuX2VuYWJsZVRleHR1cmVFcnJvcigpO1xuICAgICAgfVxuICAgIH1cbiAgICBfZGlzYWJsZVRleHR1cmUoKSB7XG4gICAgICB0aGlzLl9zZXREaXNwbGF5ZWRUZXh0dXJlKG51bGwpO1xuICAgIH1cbiAgICBnZXQgdGV4dHVyZSgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fdGV4dHVyZTtcbiAgICB9XG4gICAgc2V0IHRleHR1cmUodikge1xuICAgICAgbGV0IHRleHR1cmU7XG4gICAgICBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgaWYgKHYudHlwZSkge1xuICAgICAgICAgIHRleHR1cmUgPSBuZXcgdi50eXBlKHRoaXMuc3RhZ2UpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRleHR1cmUgPSB0aGlzLnRleHR1cmU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRleHR1cmUpIHtcbiAgICAgICAgICBCYXNlLnBhdGNoT2JqZWN0KHRleHR1cmUsIHYpO1xuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKCF2KSB7XG4gICAgICAgIHRleHR1cmUgPSBudWxsO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHYuaXNUZXh0dXJlKSB7XG4gICAgICAgICAgdGV4dHVyZSA9IHY7XG4gICAgICAgIH0gZWxzZSBpZiAodi5pc1RleHR1cmVTb3VyY2UpIHtcbiAgICAgICAgICB0ZXh0dXJlID0gbmV3IFNvdXJjZVRleHR1cmUodGhpcy5zdGFnZSk7XG4gICAgICAgICAgdGV4dHVyZS50ZXh0dXJlU291cmNlID0gdjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjb25zb2xlLmVycm9yKFwiW0xpZ2h0bmluZ10gUGxlYXNlIHNwZWNpZnkgYSB0ZXh0dXJlIHR5cGUuXCIpO1xuICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgY29uc3QgcHJldlRleHR1cmUgPSB0aGlzLl9fdGV4dHVyZTtcbiAgICAgIGlmICh0ZXh0dXJlICE9PSBwcmV2VGV4dHVyZSkge1xuICAgICAgICB0aGlzLl9fdGV4dHVyZSA9IHRleHR1cmU7XG4gICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZSkge1xuICAgICAgICAgIGlmICh0aGlzLl9fZW5hYmxlZCkge1xuICAgICAgICAgICAgdGhpcy5fX3RleHR1cmUuYWRkRWxlbWVudCh0aGlzKTtcbiAgICAgICAgICAgIGlmICh0aGlzLndpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICBpZiAodGhpcy5fX3RleHR1cmUuaXNMb2FkZWQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3NldERpc3BsYXllZFRleHR1cmUodGhpcy5fX3RleHR1cmUpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX2VuYWJsZVRleHR1cmVFcnJvcigpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuX3NldERpc3BsYXllZFRleHR1cmUobnVsbCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHByZXZUZXh0dXJlICYmIHByZXZUZXh0dXJlICE9PSB0aGlzLl9fZGlzcGxheWVkVGV4dHVyZSkge1xuICAgICAgICAgIHByZXZUZXh0dXJlLnJlbW92ZUVsZW1lbnQodGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fdXBkYXRlRGltZW5zaW9ucygpO1xuICAgICAgfVxuICAgIH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IHRoaXMuZGlzcGxheWVkVGV4dHVyZS5fc291cmNlO1xuICAgICAgICBsZXQgdHgxID0gMCwgdHkxID0gMCwgdHgyID0gMSwgdHkyID0gMTtcbiAgICAgICAgaWYgKGRpc3BsYXllZFRleHR1cmUuY2xpcHBpbmcpIHtcbiAgICAgICAgICBsZXQgdyA9IGRpc3BsYXllZFRleHR1cmVTb3VyY2UuZ2V0UmVuZGVyV2lkdGgoKTtcbiAgICAgICAgICBsZXQgaCA9IGRpc3BsYXllZFRleHR1cmVTb3VyY2UuZ2V0UmVuZGVySGVpZ2h0KCk7XG4gICAgICAgICAgbGV0IGl3LCBpaCwgcncsIHJoO1xuICAgICAgICAgIGl3ID0gMSAvIHc7XG4gICAgICAgICAgaWggPSAxIC8gaDtcbiAgICAgICAgICBpZiAoZGlzcGxheWVkVGV4dHVyZS5wdykge1xuICAgICAgICAgICAgcncgPSBkaXNwbGF5ZWRUZXh0dXJlLnB3ICogaXc7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJ3ID0gKHcgLSBkaXNwbGF5ZWRUZXh0dXJlLnB4KSAqIGl3O1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoZGlzcGxheWVkVGV4dHVyZS5waCkge1xuICAgICAgICAgICAgcmggPSBkaXNwbGF5ZWRUZXh0dXJlLnBoICogaWg7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJoID0gKGggLSBkaXNwbGF5ZWRUZXh0dXJlLnB5KSAqIGloO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpdyAqPSBkaXNwbGF5ZWRUZXh0dXJlLnB4O1xuICAgICAgICAgIGloICo9IGRpc3BsYXllZFRleHR1cmUucHk7XG4gICAgICAgICAgdHgxID0gaXc7XG4gICAgICAgICAgdHkxID0gaWg7XG4gICAgICAgICAgdHgyID0gdHgyICogcncgKyBpdztcbiAgICAgICAgICB0eTIgPSB0eTIgKiByaCArIGloO1xuICAgICAgICAgIHR4MSA9IE1hdGgubWF4KDAsIHR4MSk7XG4gICAgICAgICAgdHkxID0gTWF0aC5tYXgoMCwgdHkxKTtcbiAgICAgICAgICB0eDIgPSBNYXRoLm1pbigxLCB0eDIpO1xuICAgICAgICAgIHR5MiA9IE1hdGgubWluKDEsIHR5Mik7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGRpc3BsYXllZFRleHR1cmVTb3VyY2UuX2ZsaXBUZXh0dXJlWSkge1xuICAgICAgICAgIGxldCB0ZW1wdHkgPSB0eTI7XG4gICAgICAgICAgdHkyID0gdHkxO1xuICAgICAgICAgIHR5MSA9IHRlbXB0eTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9fY29yZS5zZXRUZXh0dXJlQ29vcmRzKHR4MSwgdHkxLCB0eDIsIHR5Mik7XG4gICAgICB9XG4gICAgfVxuICAgIGdldENvcm5lclBvaW50cygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5nZXRDb3JuZXJQb2ludHMoKTtcbiAgICB9XG4gICAgX3Vuc2V0VGFnc1BhcmVudCgpIHtcbiAgICAgIGlmICh0aGlzLl9fdGFncykge1xuICAgICAgICB0aGlzLl9fdGFncy5mb3JFYWNoKCh0YWcpID0+IHtcbiAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgd2hpbGUgKHAgPSBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgICBsZXQgcGFyZW50VHJlZVRhZ3MgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICBwYXJlbnRUcmVlVGFncy5kZWxldGUodGhpcyk7XG4gICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICAgIGxldCB0YWdzID0gbnVsbDtcbiAgICAgIGxldCBuID0gMDtcbiAgICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9fdGFnUm9vdCkge1xuICAgICAgICAgIHRhZ3MgPSBVdGlscyQxLml0ZXJhdG9yVG9BcnJheSh0aGlzLl9fdHJlZVRhZ3Mua2V5cygpKTtcbiAgICAgICAgICBuID0gdGFncy5sZW5ndGg7XG4gICAgICAgICAgaWYgKG4gPiAwKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICBsZXQgdGFnU2V0ID0gdGhpcy5fX3RyZWVUYWdzLmdldCh0YWdzW2ldKTtcbiAgICAgICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgICAgICB3aGlsZSAocCA9IHAuX19wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICBsZXQgcGFyZW50VHJlZVRhZ3MgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZ3NbaV0pO1xuICAgICAgICAgICAgICAgIHRhZ1NldC5mb3JFYWNoKGZ1bmN0aW9uKGNvbXApIHtcbiAgICAgICAgICAgICAgICAgIHBhcmVudFRyZWVUYWdzLmRlbGV0ZShjb21wKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfc2V0VGFnc1BhcmVudCgpIHtcbiAgICAgIGlmICh0aGlzLl9fdGFncykge1xuICAgICAgICB0aGlzLl9fdGFncy5mb3JFYWNoKCh0YWcpID0+IHtcbiAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgd2hpbGUgKHAgPSBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSAvKiBAX19QVVJFX18gKi8gbmV3IE1hcCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgICAgcyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgU2V0KCk7XG4gICAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHMuYWRkKHRoaXMpO1xuICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fX3RyZWVUYWdzICYmIHRoaXMuX190cmVlVGFncy5zaXplKSB7XG4gICAgICAgIGlmICghdGhpcy5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICB0aGlzLl9fdHJlZVRhZ3MuZm9yRWFjaCgodGFnU2V0LCB0YWcpID0+IHtcbiAgICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICAgIHdoaWxlICghcC5fX3RhZ1Jvb3QgJiYgKHAgPSBwLl9fcGFyZW50KSkge1xuICAgICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpXG4gICAgICAgICAgICAgICAgO1xuICAgICAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgICAgIHAuX190cmVlVGFncyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgICAgIHMgPSAvKiBAX19QVVJFX18gKi8gbmV3IFNldCgpO1xuICAgICAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB0YWdTZXQuZm9yRWFjaChmdW5jdGlvbihjb21wKSB7XG4gICAgICAgICAgICAgICAgcy5hZGQoY29tcCk7XG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF9nZXRCeVRhZyh0YWcpIHtcbiAgICAgIGlmICghdGhpcy5fX3RyZWVUYWdzKSB7XG4gICAgICAgIHJldHVybiBbXTtcbiAgICAgIH1cbiAgICAgIGxldCB0ID0gdGhpcy5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgcmV0dXJuIHQgPyBVdGlscyQxLnNldFRvQXJyYXkodCkgOiBbXTtcbiAgICB9XG4gICAgZ2V0VGFncygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fdGFncyA/IHRoaXMuX190YWdzIDogW107XG4gICAgfVxuICAgIHNldFRhZ3ModGFncykge1xuICAgICAgdGFncyA9IHRhZ3MucmVkdWNlKChhY2MsIHRhZykgPT4ge1xuICAgICAgICByZXR1cm4gYWNjLmNvbmNhdCh0YWcuc3BsaXQoXCIgXCIpKTtcbiAgICAgIH0sIFtdKTtcbiAgICAgIGlmICh0aGlzLl9fcmVmKSB7XG4gICAgICAgIHRhZ3MucHVzaCh0aGlzLl9fcmVmKTtcbiAgICAgIH1cbiAgICAgIGxldCBpLCBuID0gdGFncy5sZW5ndGg7XG4gICAgICBsZXQgcmVtb3ZlcyA9IFtdO1xuICAgICAgbGV0IGFkZHMgPSBbXTtcbiAgICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgaWYgKCF0aGlzLmhhc1RhZyh0YWdzW2ldKSkge1xuICAgICAgICAgIGFkZHMucHVzaCh0YWdzW2ldKTtcbiAgICAgICAgfVxuICAgICAgfVxu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cbiAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJUYWcgbWF5IG5vdCBzdGFydCB3aXRoIGFuIHVwcGVyIGNhc2UgY2hhcmFjdGVyLlwiKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgdGhpcy5fYWRkVGFnKHRhZzIpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF9hZGRUYWcodGFnKSB7XG4gICAgICBpZiAoIXRoaXMuX190YWdzKSB7XG4gICAgICAgIHRoaXMuX190YWdzID0gW107XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fX3RhZ3MuaW5kZXhPZih0YWcpID09PSAtMSkge1xuICAgICAgICB0aGlzLl9fdGFncy5wdXNoKHRhZyk7XG4gICAgICAgIGxldCBwID0gdGhpcy5fX3BhcmVudDtcbiAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICBkbyB7XG4gICAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSAvKiBAX19QVVJFX18gKi8gbmV3IE1hcCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgICAgcyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgU2V0KCk7XG4gICAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHMuYWRkKHRoaXMpO1xuICAgICAgICAgIH0gd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICByZW1vdmVUYWcodGFnKSB7XG4gICAgICBsZXQgaSA9IHRoaXMuX190YWdzLmluZGV4T2YodGFnKTtcbiAgICAgIGlmIChpICE9PSAtMSkge1xuICAgICAgICB0aGlzLl9fdGFncy5zcGxpY2UoaSwgMSk7XG4gICAgICAgIGxldCBwID0gdGhpcy5fX3BhcmVudDtcbiAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICBkbyB7XG4gICAgICAgICAgICBsZXQgbGlzdCA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgIGlmIChsaXN0KSB7XG4gICAgICAgICAgICAgIGxpc3QuZGVsZXRlKHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBoYXNUYWcodGFnKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX3RhZ3MgJiYgdGhpcy5fX3RhZ3MuaW5kZXhPZih0YWcpICE9PSAtMTtcbiAgICB9XG4gICAgX3RhZyh0YWcpIHtcbiAgICAgIGlmICh0YWcuaW5kZXhPZihcIi5cIikgIT09IC0xKSB7XG4gICAgICAgIHJldHVybiB0aGlzLm10YWcodGFnKVswXTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICBsZXQgdCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICBpZiAodCkge1xuICAgICAgICAgICAgY29uc3QgaXRlbSA9IHQudmFsdWVzKCkubmV4dCgpO1xuICAgICAgICAgICAgcmV0dXJuIGl0ZW0gPyBpdGVtLnZhbHVlIDogdm9pZCAwO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBnZXQgdGFnKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3RhZztcbiAgICB9XG4gICAgc2V0IHRhZyh0KSB7XG4gICAgICB0aGlzLnRhZ3MgPSB0O1xuICAgIH1cbiAgICBtdGFnKHRhZykge1xuICAgICAgbGV0IGlkeC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gYXJyb3dJZHggPT09IC0xKSB7XG4gICAgICAgIHJldHVybiB0aGlzLm10YWcocGF0aCk7XG4gICAgICB9XG4gICAgICBsZXQgaXNSZWY7XG4gICAgICBpZiAoYXJyb3dJZHggPT09IDApIHtcbiAgICAgICAgaXNSZWYgPSB0cnVlO1xuICAgICAgICBwYXRoID0gcGF0aC5zdWJzdHIoMSk7XG4gICAgICB9IGVsc2UgaWYgKHBvaW50SWR4ID09PSAwKSB7XG4gICAgICAgIGlzUmVmID0gZmFsc2U7XG4gICAgICAgIHBhdGggPSBwYXRoLnN1YnN0cigxKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlzUmVmID0gZmFsc2U7XG4gICAgICB9XG4gICAgICByZXR1cm4gdGhpcy5fc2VsZWN0Q2hpbGRzKHBhdGgsIGlzUmVmKTtcbiAgICB9XG4gICAgX3NlbGVjdENoaWxkcyhwYXRoLCBpc1JlZikge1xuICAgICAgY29uc3QgcG9pbnRJZHggPSBwYXRoLmluZGV4T2YoXCIuXCIpO1xuICAgICAgY29uc3QgYXJyb3dJZHggPSBwYXRoLmluZGV4T2YoXCI+XCIpO1xuICAgICAgaWYgKHBvaW50SWR4ID09PSAtMSAmJiBhcnJvd0lkeCA9PT0gLTEpIHtcbiAgICAgICAgaWYgKGlzUmVmKSB7XG4gICAgICAgICAgY29uc3QgcmVmID0gdGhpcy5nZXRCeVJlZihwYXRoKTtcbiAgICAgICAgICByZXR1cm4gcmVmID8gW3JlZl0gOiBbXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZXR1cm4gdGhpcy5tdGFnKHBhdGgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAoYXJyb3dJZHggPT09IC0xIHx8IHBvaW50SWR4ICE9PSAtMSAmJiBwb2ludElkeCA8IGFycm93SWR4KSB7XG4gICAgICAgIGxldCBuZXh0O1xuICAgICAgICBjb25zdCBzdHIgPSBwYXRoLnN1YnN0cigwLCBwb2ludElkeCk7XG4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7XG4gICAgICAgICAgY29uc3QgY2hpbGRBcnJheSA9IFtdO1xuICAgICAgICAgIGxldCBtaXNzaW5nID0gZmFsc2U7XG4gICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGNoaWxkQXJyYXkucHVzaChjaGlsZHJlbltpXS5nZXRTZXR0aW5ncygpKTtcbiAgICAgICAgICAgIG1pc3NpbmcgPSBtaXNzaW5nIHx8ICFjaGlsZHJlbltpXS5yZWY7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICghbWlzc2luZykge1xuICAgICAgICAgICAgc2V0dGluZ3MuY2hpbGRyZW4gPSB7fTtcbiAgICAgICAgICAgIGNoaWxkQXJyYXkuZm9yRWFjaCgoY2hpbGQpID0+IHtcbiAgICAgICAgICAgICAgc2V0dGluZ3MuY2hpbGRyZW5bY2hpbGQucmVmXSA9IGNoaWxkO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHNldHRpbmdzLmNoaWxkcmVuID0gY2hpbGRBcnJheTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHNldHRpbmdzLmlkID0gdGhpcy5pZDtcbiAgICAgIHJldHVybiBzZXR0aW5ncztcbiAgICB9XG4gICAgZ2V0Tm9uRGVmYXVsdHMoKSB7XG4gICAgICBsZXQgc2V0dGluZ3MgPSB7fTtcbiAgICAgIGlmICh0aGlzLmNvbnN0cnVjdG9yICE9PSBFbGVtZW50KSB7XG4gICAgICAgIHNldHRpbmdzLnR5cGUgPSB0aGlzLmNvbnN0cnVjdG9yLm5hbWU7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fX3JlZikge1xuICAgICAgICBzZXR0aW5ncy5yZWYgPSB0aGlzLl9fcmVmO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX190YWdzICYmIHRoaXMuX190YWdzLmxlbmd0aCkge1xuICAgICAgICBzZXR0aW5ncy50YWdzID0gdGhpcy5fX3RhZ3M7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy54ICE9PSAwKVxuICAgICAgICBzZXR0aW5ncy54ID0gdGhpcy54O1xuICAgICAgaWYgKHRoaXMueSAhPT0gMClcbiAgICAgICAgc2V0dGluZ3MueSA9IHRoaXMueTtcbiAgICAgIGlmICh0aGlzLncgIT09IDApXG4gICAgICAgIHNldHRpbmdzLncgPSB0aGlzLnc7XG4gICAgICBpZiAodGhpcy5oICE9PSAwKVxuICAgICAgICBzZXR0aW5ncy5oID0gdGhpcy5oO1xuICAgICAgaWYgKHRoaXMuc2NhbGVYID09PSB0aGlzLnNjYWxlWSkge1xuICAgICAgICBpZiAodGhpcy5zY2FsZVggIT09IDEpXG4gICAgICAgICAgc2V0dGluZ3Muc2NhbGUgPSB0aGlzLnNjYWxlWDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLnNjYWxlWCAhPT0gMSlcbiAgICAgICAgICBzZXR0aW5ncy5zY2FsZVggPSB0aGlzLnNjYWxlWDtcbiAgICAgICAgaWYgKHRoaXMuc2NhbGVZICE9PSAxKVxuICAgICAgICAgIHNldHRpbmdzLnNjYWxlWSA9IHRoaXMuc2NhbGVZO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMucGl2b3RYID09PSB0aGlzLnBpdm90WSkge1xuICAgICAgICBpZiAodGhpcy5waXZvdFggIT09IDAuNSlcbiAgICAgICAgICBzZXR0aW5ncy5waXZvdCA9IHRoaXMucGl2b3RYO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMucGl2b3RYICE9PSAwLjUpXG4gICAgICAgICAgc2V0dGluZ3MucGl2b3RYID0gdGhpcy5waXZvdFg7XG4gICAgICAgIGlmICh0aGlzLnBpdm90WSAhPT0gMC41KVxuICAgICAgICAgIHNldHRpbmdzLnBpdm90WSA9IHRoaXMucGl2b3RZO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMubW91bnRYID09PSB0aGlzLm1vdW50WSkge1xuICAgICAgICBpZiAodGhpcy5tb3VudFggIT09IDApXG4gICAgICAgICAgc2V0dGluZ3MubW91bnQgPSB0aGlzLm1vdW50WDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLm1vdW50WCAhPT0gMClcbiAgICAgICAgICBzZXR0aW5ncy5tb3VudFggPSB0aGlzLm1vdW50WDtcbiAgICAgICAgaWYgKHRoaXMubW91bnRZICE9PSAwKVxuICAgICAgICAgIHNldHRpbmdzLm1vdW50WSA9IHRoaXMubW91bnRZO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuYWxwaGEgIT09IDEpXG4gICAgICAgIHNldHRpbmdzLmFscGhhID0gdGhpcy5hbHBoYTtcbiAgICAgIGlmICghdGhpcy52aXNpYmxlKVxuICAgICAgICBzZXR0aW5ncy52aXNpYmxlID0gZmFsc2U7XG4gICAgICBpZiAodGhpcy5yb3RhdGlvbiAhPT0gMClcbiAgICAgICAgc2V0dGluZ3Mucm90YXRpb24gPSB0aGlzLnJvdGF0aW9uO1xuICAgICAgaWYgKHRoaXMuY29sb3JVbCA9PT0gdGhpcy5jb2xvclVyICYmIHRoaXMuY29sb3JCbCA9PT0gdGhpcy5jb2xvckJyICYmIHRoaXMuY29sb3JVbCA9PT0gdGhpcy5jb2xvckJsKSB7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yVWwgIT09IDQyOTQ5NjcyOTUpXG4gICAgICAgICAgc2V0dGluZ3MuY29sb3IgPSB0aGlzLmNvbG9yVWwudG9TdHJpbmcoMTYpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMuY29sb3JVbCAhPT0gNDI5NDk2NzI5NSlcbiAgICAgICAgICBzZXR0aW5ncy5jb2xvclVsID0gdGhpcy5jb2xvclVsLnRvU3RyaW5nKDE2KTtcbiAgICAgICAgaWYgKHRoaXMuY29sb3JVciAhPT0gNDI5NDk2NzI5NSlcbiAgICAgICA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AgcmV0dXJuIHRoaXMuX19jb3JlLnJvdGF0aW9uO1xuICAgIH1cbiAgICBzZXQgcm90YXRpb24odikge1xuICAgICAgdGhpcy5fX2NvcmUucm90YXRpb24gPSB2O1xuICAgIH1cbiAgICBnZXQgYWxwaGEoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUuYWxwaGE7XG4gICAgfVxuICAgIHNldCBhbHBoYSh2KSB7XG4gICAgICB0aGlzLl9fY29yZS5hbHBoYSA9IHY7XG4gICAgfVxuICAgIGdldCB2aXNpYmxlKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnZpc2libGU7XG4gICAgfVxuICAgIHNldCB2aXNpYmxlKHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLnZpc2libGUgPSB2O1xuICAgIH1cbiAgICBnZXQgY29sb3JVbCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jb2xvclVsO1xuICAgIH1cbiAgICBzZXQgY29sb3JVbCh2KSB7XG4gICAgICB0aGlzLl9fY29yZS5jb2xvclVsID0gdjtcbiAgICB9XG4gICAgZ2V0IGNvbG9yVXIoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY29sb3JVcjtcbiAgICB9XG4gICAgc2V0IGNvbG9yVXIodikge1xuICAgICAgdGhpcy5fX2NvcmUuY29sb3JVciA9IHY7XG4gICAgfVxuICAgIGdldCBjb2xvckJsKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNvbG9yQmw7XG4gICAgfVxuICAgIHNldCBjb2xvckJsKHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLmNvbG9yQmwgPSB2O1xuICAgIH1cbiAgICBnZXQgY29sb3JCcigpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jb2xvckJyO1xuICAgIH1cbiAgICBzZXQgY29sb3JCcih2KSB7XG4gICAgICB0aGlzLl9fY29yZS5jb2xvckJyID0gdjtcbiAgICB9XG4gICAgZ2V0IGNvbG9yKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNvbG9yVWw7XG4gICAgfVxuICAgIHNldCBjb2xvcih2KSB7XG4gICAgICBpZiAodGhpcy5jb2xvclVsICE9PSB2IHx8IHRoaXMuY29sb3JVciAhPT0gdiB8fCB0aGlzLmNvbG9yQmwgIT09IHYgfHwgdGhpcy5jb2xvckJyICE9PSB2KSB7XG4gICAgICAgIHRoaXMuY29sb3JVbCA9IHY7XG4gICAgICAgIHRoaXMuY29sb3JVciA9IHY7XG4gICAgICAgIHRoaXMuY29sb3JCbCA9IHY7XG4gICAgICAgIHRoaXMuY29sb3JCciA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBjb2xvclRvcCgpIHtcbiAgICAgIHJldHVybiB0aGlzLmNvbG9yVWw7XG4gICAgfVxuICAgIHNldCBjb2xvclRvcCh2KSB7XG4gICAgICBpZiAodGhpcy5jb2xvclVsICE9PSB2IHx8IHRoaXMuY29sb3JVciAhPT0gdikge1xuICAgICAgICB0aGlzLmNvbG9yVWwgPSB2O1xuICAgICAgICB0aGlzLmNvbG9yVXIgPSB2O1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgY29sb3JCb3R0b20oKSB7XG4gICAgICByZXR1cm4gdGhpcy5jb2xvckJsO1xuICAgIH1cbiAgICBzZXQgY29sb3JCb3R0b20odikge1xuICAgICAgaWYgKHRoaXMuY29sb3JCbCAhPT0gdiB8fCB0aGlzLmNvbG9yQnIgIT09IHYpIHtcbiAgICAgICAgdGhpcy5jb2xvckJsID0gdjtcbiAgICAgICAgdGhpcy5jb2xvckJyID0gdjtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IGNvbG9yTGVmdCgpIHtcbiAgICAgIHJldHVybiB0aGlzLmNvbG9yVWw7XG4gICAgfVxuICAgIHNldCBjb2xvckxlZnQodikge1xuICAgICAgaWYgKHRoaXMuY29sb3JVbCAhPT0gdiB8fCB0aGlzLmNvbG9yQmwgIT09IHYpIHtcbiAgICAgICAgdGhpcy5jb2xvclVsID0gdjtcbiAgICAgICAgdGhpcy5jb2xvckJsID0gdjtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IGNvbG9yUmlnaHQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5jb2xvclVyO1xuICAgIH1cbiAgICBzZXQgY29sb3JSaWdodCh2KSB7XG4gICAgICBpZiAodGhpcy5jb2xvclVyICE9PSB2IHx8IHRoaXMuY29sb3JCciAhPT0gdikge1xuICAgICAgICB0aGlzLmNvbG9yVXIgPSB2O1xuICAgICAgICB0aGlzLmNvbG9yQnIgPSB2O1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgekluZGV4KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnpJbmRleDtcbiAgICB9XG4gICAgc2V0IHpJbmRleCh2KSB7XG4gICAgICB0aGlzLl9fY29yZS56SW5kZXggPSB2O1xuICAgIH1cbiAgICBnZXQgZm9yY2VaSW5kZXhDb250ZXh0KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmZvcmNlWkluZGV4Q29udGV4dDtcbiAgICB9XG4gICAgc2V0IGZvcmNlWkluZGV4Q29udGV4dCh2KSB7XG4gICAgICB0aGlzLl9fY29yZS5mb3JjZVpJbmRleENvbnRleHQgPSB2O1xuICAgIH1cbiAgICBnZXQgY2xpcHBpbmcoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY2xpcHBpbmc7XG4gICAgfVxuICAgIHNldCBjbGlwcGluZyh2KSB7XG4gICAgICB0aGlzLl9fY29yZS5jbGlwcGluZyA9IHY7XG4gICAgfVxuICAgIGdldCBjbGlwYm94KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNsaXBib3g7XG4gICAgfVxuICAgIHNldCBjbGlwYm94KHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLmNsaXBib3ggPSB2O1xuICAgIH1cbiAgICBnZXQgdGFncygpIHtcbiAgICAgIHJ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Ckge1xuICAgICAgICAgICAgICBsZXQgYztcbiAgICAgICAgICAgICAgaWYgKFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICAgICAgYyA9IHRoaXMuY2hpbGRMaXN0LmNyZWF0ZUl0ZW0odik7XG4gICAgICAgICAgICAgICAgYy5wYXRjaCh2KTtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscyQxLmlzT2JqZWN0KHYpKSB7XG4gICAgICAgICAgICAgICAgYyA9IHY7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKGMuaXNFbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgYy5yZWYgPSBwYXRoO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoYyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh2ID09PSB2b2lkIDApIHtcbiAgICAgICAgICAgICAgaWYgKGNoaWxkLnBhcmVudCkge1xuICAgICAgICAgICAgICAgIGNoaWxkLnBhcmVudC5jaGlsZExpc3QucmVtb3ZlKGNoaWxkKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgICBjaGlsZC5wYXRjaCh2KTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodi5pc0VsZW1lbnQpIHtcbiAgICAgICAgICAgICAgdi5yZWYgPSBwYXRoO1xuICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5yZXBsYWNlKHYsIGNoaWxkKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJVbmV4cGVjdGVkIHZhbHVlIGZvciBwYXRoOiBcIiArIHBhdGgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBCYXNlLnBhdGNoT2JqZWN0UHJvcGVydHkodGhpcywgcGF0aCwgdik7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgX3Rocm93RXJyb3IobWVzc2FnZSkge1xuICAgICAgdGhyb3cgbmV3IEVycm9yKHRoaXMuY29uc3RydWN0b3IubmFtZSArIFwiIChcIiArIHRoaXMuZ2V0TG9jYXRpb25TdHJpbmcoKSArIFwiKTogXCIgKyBtZXNzYWdlKTtcbiAgICB9XG4gICAgYW5pbWF0aW9uKHNldHRpbmdzKSB7XG4gICAgICByZXR1cm4gdGhpcy5zdGFnZS5hbmltYXRpb25zLmNyZWF0ZUFuaW1hdGlvbih0aGlzLCBzZXR0aW5ncyk7XG4gICAgfVxuICAgIHRyYW5zaXRpb24ocHJvcGVydHksIHNldHRpbmdzID0gbnVsbCkge1xuICAgICAgaWYgKHNldHRpbmdzID09PSBudWxsKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9nZXRUcmFuc2l0aW9uKHByb3BlcnR5KTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMuX3NldFRyYW5zaXRpb24ocHJvcGVydHksIHNldHRpbmdzKTtcbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICB9XG4gICAgfVxuICAgIHNldCB0cmFuc2l0aW9ucyhvYmplY3QpIHtcbiAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob2JqZWN0KTtcbiAgICAgIGtleXMuZm9yRWFjaCgocHJvcGVydHkpID0+IHtcbiAgICAgICAgdGhpcy50cmFuc2l0aW9uKHByb3BlcnR5LCBvYmplY3RbcHJvcGVydHldKTtcbiAgICAgIH0pO1xuICAgIH1cbiAgICBzZXQgc21vb3RoKG9iamVjdCkge1xuICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmplY3QpO1xuICAgICAga2V5cy5mb3JFYWNoKChwcm9wZXJ0eSkgPT4ge1x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0ge307XG4gICAgICAgICAgdGhpcy5jb2xsZWN0Q2hpbGRyZW4oXG4gICAgICAgICAgICB0cmVlW3JlZl0uY2hpbGRyZW4sXG4gICAgICAgICAgICBlbGVtZW50Ll9fY2hpbGRMaXN0XG4gICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBzdGF0aWMgZ2V0UHJvcGVydGllcyhlbGVtZW50KSB7XG4gICAgICBjb25zdCBwcm9wcyA9IHt9O1xuICAgICAgY29uc3QgbGlzdCA9IFtcbiAgICAgICAgXCJhbHBoYVwiLFxuICAgICAgICBcImFjdGl2ZVwiLFxuICAgICAgICBcImF0dGFjaGVkXCIsXG4gICAgICAgIFwiYm91bmRzTWFyZ2luXCIsXG4gICAgICAgIFwiY29sb3JcIixcbiAgICAgICAgXCJjbGlwcGluZ1wiLFxuICAgICAgICBcImVuYWJsZWRcIixcbiAgICAgICAgXCJoXCIsXG4gICAgICAgIFwiaWRcIixcbiAgICAgICAgXCJpc0NvbXBvbmVudFwiLFxuICAgICAgICBcIm1vdW50XCIsXG4gICAgICAgIFwibW91bnRZXCIsXG4gICAgICAgIFwibW91bnRYXCIsXG4gICAgICAgIFwicGl2b3RcIixcbiAgICAgICAgXCJwaXZvdFhcIixcbiAgICAgICAgXCJwaXZvdFlcIixcbiAgICAgICAgXCJyZWZcIixcbiAgICAgICAgXCJyZW5kZXJPZmZzY3JlZW5cIixcbiAgICAgICAgXCJyZW5kZXJUb1RleHR1cmVcIixcbiAgICAgICAgXCJzY2FsZVwiLFxuICAgICAgICBcInNjYWxlWFwiLFxuICAgICAgICBcInNjYWxlWVwiLFxuICAgICAgICBcInN0YXRlXCIsXG4gICAgICAgIFwidGFnXCIsXG4gICAgICAgIFwidmlzaWJsZVwiLFxuICAgICAgICBcIndcIixcbiAgICAgICAgXCJ4XCIsXG4gICAgICAgIFwieVwiLFxuICAgICAgICBcInpJbmRleFwiLFxuICAgICAgICBcIiEhZmxleFwiLFxuICAgICAgICBcIiEhZmxleEl0ZW1cIixcbiAgICAgICAgXCJoYXNGb2N1cygpXCIsXG4gICAgICAgIFwiaGFzRmluYWxGb2N1cygpXCJcbiAgICAgIF07XG4gICAgICBsZXQgbiA9IGxpc3QubGVuZ3RoO1xuICAgICAgd2hpbGUgKG4tLSkge1xuICAgICAgICBsZXQga2V5ID0gbGlzdFtuXTtcbiAgICAgICAgY29uc3QgZ2V0Qm9vbGVhbiA9IC9eIXsyfS87XG4gICAgICAgIGNvbnN0IGlzRnVuY3Rpb24gPSAvXFwoXFwpJC87XG4gICAgICAgIGlmIChnZXRCb29sZWFuLnRlc3Qoa2V5KSkge1xuICAgICAgICAgIGtleSA9IGtleS5zdWJzdHJpbmcoMiwga2V5Lmxlbmd0aCk7XG4gICAgICAgICAgcHJvcHNba2V5XSA9ICEhZWxlbWVudFtrZXldO1xuICAgICAgICB9IGVsc2UgaWYgKGlzRnVuY3Rpb24udGVzdChrZXkpKSB7XG4gICAgICAgICAga2V5ID0ga2V5LnN1YnN0cmluZygwLCBrZXkubGVuZ3RoIC0gMik7XG4gICAgICAgICAgaWYgKHR5cGVvZiBlbGVtZW50W2tleV0gPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgcHJvcHNba2V5XSA9IGVsZW1lbnRba2V5XSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwcm9wc1trZXldID0gZWxlbWVudFtrZXldO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4geyAuLi5wcm9wcywgLi4uZWxlbWVudC5nZXROb25EZWZhdWx0cygpIH07XG4gICAgfVxuICB9XG4gIEV2ZW50RW1pdHRlci5hZGRBc01peGluKEVsZW1lbnQpO1xuICBFbGVtZW50LnByb3RvdHlwZS5pc0VsZW1lbnQgPSAxO1xuICBFbGVtZW50LmlkID0gMTtcbiAgRWxlbWVudC5QUk9QX0dFVFRFUlMgPSAvKiBAX19QVVJFX18gKi8gbmV3IE1hcCg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YgKHN0YXRlQ2hhbmdlT3ZlcnJpZGRlbikge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9fc2V0U3RhdGUobmV3U3RhdGUpO1xuICAgICAgICBpZiAodGhpcy5fY2hhbmdlZFN0YXRlKSB7XG4gICAgICAgICAgY29uc3QgY29udGV4dCA9IHtcbiAgICAgICAgICAgIG5ld1N0YXRlOiBuZXdTdGF0ZS5fX3BhdGgsXG4gICAgICAgICAgICBwcmV2U3RhdGU6IHByZXZTdGF0ZS5fX3BhdGhcbiAgICAgICAgICB9O1xuICAgICAgICAgIGlmIChhcmdzKSB7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkU3RhdGUoY29udGV4dCwgLi4uYXJncyk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWRTdGF0ZShjb250ZXh0KTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX29uU3RhdGVDaGFuZ2UpIHtcbiAgICAgICAgICBjb25zdCBjb250ZXh0ID0ge1xuICAgICAgICAgICAgbmV3U3RhdGU6IG5ld1N0YXRlLl9fcGF0aCxcbiAgICAgICAgICAgIHByZXZTdGF0ZTogcHJldlN0YXRlLl9fcGF0aFxuICAgICAgICAgIH07XG4gICAgICAgICAgdGhpcy5fb25TdGF0ZUNoYW5nZShjb250ZXh0KTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfY2FsbEVudGVyKHN0YXRlLCBhcmdzID0gW10sIGNvbnRleHQpIHtcbiAgICAgIGNvbnN0IGhhc1BhcmVudCA9ICEhc3RhdGUuX19wYXJlbnQ7XG4gICAgICBpZiAoc3RhdGUucHJvdG90eXBlLiRlbnRlcikge1xuICAgICAgICBpZiAoIWhhc1BhcmVudCB8fCBzdGF0ZS5fX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m4gdGhpc1tcIiR7Y3VyfVwiXSguLi5hcmd1bWVudHMpOyBlbHNlYCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl0uYXBwbHkodGhpcywgYXJndW1lbnRzKTsgZWxzZWApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgcmV0dXJuIDsgZWxzZWApO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBjdXIgPSBhbGlhcztcbiAgICAgIH1cbiAgICAgIGlmIChjdXIpIHtcbiAgICAgICAgaWYgKHN1cHBvcnRzU3ByZWFkKSB7XG4gICAgICAgICAgY29kZS5wdXNoKGByZXR1cm4gdGhpc1tcIiR7Y3VyfVwiXSguLi5hcmd1bWVudHMpO2ApO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvZGUucHVzaChgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl0uYXBwbHkodGhpcywgYXJndW1lbnRzKTtgKTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgY29kZS5wdXNoKGA7YCk7XG4gICAgICB9XG4gICAgICBjb25zdCBmdW5jdGlvbkJvZHkgPSBjb2RlLmpvaW4oXCJcXG5cIik7XG4gICAgICBjb25zdCByb3V0ZXIgPSBuZXcgRnVuY3Rpb24oW10sIGZ1bmN0aW9uQm9keSk7XG4gICAgICBjb25zdCBkZXNjcmlwdG9yID0geyB2YWx1ZTogcm91dGVyIH07XG4gICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcy5fcm91dGVyLnByb3RvdHlwZSwgbWVtYmVyLCBkZXNjcmlwdG9yKTtcbiAgICB9XG4gICAgX2FkZEdldHRlclNldHRlclJvdXRlcnMobWVtYmVyKSB7XG4gICAgICBj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vcGVydHkodGhpcy5fcm91dGVyLnByb3RvdHlwZSwgYWxpYXMsIGRlc2NyaXB0b3IpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBhbGlhc2VzW2luZGV4XSA9IG51bGw7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgICAgY29uc3QgY29kZSA9IFtcbiAgICAgICAgXCIvL0Agc291cmNlVVJMPVN0YXRlTWFjaGluZVJvdXRlci5qc1wiLFxuICAgICAgICBcInZhciBpID0gdGhpcy5fc3RhdGVJbmRleDtcIlxuICAgICAgXTtcbiAgICAgIGxldCBjdXIgPSBhbGlhc2VzWzBdO1xuICAgICAgZm9yIChsZXQgaSA9IDEsIG4gPSBhbGlhc2VzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBjb25zdCBhbGlhcyA9IGFsaWFzZXNbaV07XG4gICAgICAgIGlmIChhbGlhcyAhPT0gY3VyKSB7XG4gICAgICAgICAgaWYgKGN1cikge1xuICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIHJldHVybiB0aGlzW1wiJHtjdXJ9XCJdOyBlbHNlYCk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSByZXR1cm4gOyBlbHNlYCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGN1ciA9IGFsaWFzO1xuICAgICAgfVxuICAgICAgaWYgKGN1cikge1xuICAgICAgICBjb2RlLnB1c2goYHJldHVybiB0aGlzW1wiJHtjdXJ9XCJdO2ApO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgY29kZS5wdXNoKGA7YCk7XG4gICAgICB9XG4gICAgICBjb25zdCBmdW5jdGlvbkJvZHkgPSBjb2RlLmpvaW4oXCJcXG5cIik7XG4gICAgICBjb25zdCByb3V0ZXIgPSBuZXcgRnVuY3Rpb24oW10sIGZ1bmN0aW9uQm9keS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GNvbnRleHQucmlkfWA7XG4gICAgICAgICAgICBsZXQgdHlwZSA9IHZhbHVlLnR5cGUgPyB2YWx1ZS50eXBlIDogRWxlbWVudDtcbiAgICAgICAgICAgIGlmICh0eXBlID09PSBFbGVtZW50KSB7XG4gICAgICAgICAgICAgIGxvYy5wdXNoKGB2YXIgJHtjaGlsZEN1cnNvcn0gPSBlbGVtZW50LnN0YWdlLmNyZWF0ZUVsZW1lbnQoKWApO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgc3RvcmUucHVzaCh0eXBlKTtcbiAgICAgICAgICAgICAgbG9jLnB1c2goYHZhciAke2NoaWxkQ3Vyc29yfSA9IG5ldyBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSgke2N1cnNvcn0uc3RhZ2UpYCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsb2MucHVzaChgJHtjaGlsZEN1cnNvcn0ucmVmID0gXCIke2tleX1cImApO1xuICAgICAgICAgICAgY29udGV4dC5yaWQrKztcbiAgICAgICAgICAgIHRoaXMucGFyc2VUZW1wbGF0ZVJlYyh2YWx1ZSwgY29udGV4dCwgY2hpbGRDdXJzb3IpO1xuICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfS5jaGlsZExpc3QuYWRkKCR7Y2hpbGRDdXJzb3J9KWApO1xuICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdCh2YWx1ZSkpIHtcbiAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfS5jaGlsZExpc3QuYWRkKHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dKWApO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAoa2V5ID09PSBcInRleHRcIikge1xuICAgICAgICAgICAgY29uc3QgcHJvcEtleSA9IGN1cnNvciArIFwiX190ZXh0XC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ZXZlbnRdO1xuICAgICAgICAgIGlmIChmaXJlRXZlbnQgPT09IGZhbHNlKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChmaXJlRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChmaXJlRXZlbnQgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgZmlyZUV2ZW50ID0gZXZlbnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoVXRpbHMkMS5pc0Z1bmN0aW9uKGZpcmVFdmVudCkpIHtcbiAgICAgICAgICAgICAgcmV0dXJuIGZpcmVFdmVudCguLi5hcmdzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzaWduYWxQYXJlbnQuX2hhc01ldGhvZChmaXJlRXZlbnQpKSB7XG4gICAgICAgICAgICAgIHJldHVybiBzaWduYWxQYXJlbnRbZmlyZUV2ZW50XSguLi5hcmdzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgbGV0IHBhc3NTaWduYWwgPSB0aGlzLl9fcGFzc1NpZ25hbHMgJiYgdGhpcy5fX3Bhc3NTaWduYWxzW2V2ZW50XTtcbiAgICAgICAgaWYgKHBhc3NTaWduYWwpIHtcbiAgICAgICAgICBpZiAocGFzc1NpZ25hbCAmJiBwYXNzU2lnbmFsICE9PSB0cnVlKSB7XG4gICAgICAgICAgICBldmVudCA9IHBhc3NTaWduYWw7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJldHVybiBzaWduYWxQYXJlbnQuX3NpZ25hbChldmVudCwgYXJncyk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgX2dldFBhcmVudFNpZ25hbEhhbmRsZXIoKSB7XG4gICAgICByZXR1cm4gdGhpcy5jcGFyZW50ID8gdGhpcy5jcGFyZW50Ll9nZXRTaWduYWxIYW5kbGVyKCkgOiBudWxsO1xuICAgIH1cbiAgICBfZ2V0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gICAgIH1cbiAgICB9XG4gICAgZ2V0IHJlbmRlclRleHR1cmVJbmZvKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3JlbmRlclRleHR1cmVJbmZvO1xuICAgIH1cbiAgICBzZXRTY2lzc29yKGFyZWEpIHtcbiAgICAgIGlmICh0aGlzLl9zY2lzc29yICE9PSBhcmVhKSB7XG4gICAgICAgIGlmIChhcmVhKSB7XG4gICAgICAgICAgdGhpcy5fc2Npc3NvciA9IGFyZWE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fc2Npc3NvciA9IG51bGw7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fY2hlY2sgPSB0cnVlO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXRTY2lzc29yKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3NjaXNzb3I7XG4gICAgfVxuICAgIHNldFJlbmRlclRleHR1cmVJbmZvKHJlbmRlclRleHR1cmVJbmZvKSB7XG4gICAgICBpZiAodGhpcy5fcmVuZGVyVGV4dHVyZUluZm8gIT09IHJlbmRlclRleHR1cmVJbmZvKSB7XG4gICAgICAgIHRoaXMuX3JlbmRlclRleHR1cmVJbmZvID0gcmVuZGVyVGV4dHVyZUluZm87XG4gICAgICAgIHRoaXMuX3NjaXNzb3IgPSBudWxsO1xuICAgICAgICB0aGlzLl9jaGVjayA9IHRydWU7XG4gICAgICB9XG4gICAgfVxuICAgIHNldFRleHR1cml6ZXIodGV4dHVyaXplciwgY2FjaGUgPSBmYWxzZSkge1xuICAgICAgdGhpcy5fdGV4dHVyaXplciA9IHRleHR1cml6ZXI7XG4gICAgICB0aGlzLl9jYWNoZVRleHR1cml6ZXIgPSBjYWNoZTtcbiAgICB9XG4gICAgc2V0IGlzQ2FjaGluZ1RleHR1cml6ZXIodikge1xuICAgICAgdGhpcy5faXNDYWNoaW5nVGV4dHVyaXplciA9IHY7XG4gICAgfVxuICAgIGdldCBpc0NhY2hpbmdUZXh0dXJpemVyKC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3VseTtcbiAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVyLCByLmFscGhhKTtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHggKyBlbGVtZW50Q29yZS5fdyAqIHIudGEgKyBlbGVtZW50Q29yZS5faCAqIHIudGI7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX3cgKiByLnRjICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icnk7XG4gICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JCciwgci5hbHBoYSk7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4ICsgZWxlbWVudENvcmUuX2ggKiByLnRiO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHg7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ5O1xuICAgICAgICB1aW50c1tvZmZzZXRdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvckJsLCByLmFscGhhKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGxldCBjeCA9IHIucHggKyBlbGVtZW50Q29yZS5fdyAqIHIudGE7XG4gICAgICAgIGxldCBjeSA9IHIucHkgKyBlbGVtZW50Q29yZS5faCAqIHIudGQ7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weTtcbiAgICAgICAgZmxvYXR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JJbWFnZSBsb2FkIGVycm9yXCIpO1xuICAgICAgICB9O1xuICAgICAgICBpbWFnZS5vbkxvYWQgPSBmdW5jdGlvbih7IGltYWdlQml0bWFwLCBoYXNBbHBoYUNoYW5uZWwgfSkge1xuICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgIHNvdXJjZTogaW1hZ2VCaXRtYXAsXG4gICAgICAgICAgICByZW5kZXJJbmZvOiB7IHNyYywgY29tcHJlc3NlZDogZmFsc2UgfSxcbiAgICAgICAgICAgIGhhc0FscGhhOiBoYXNBbHBoYUNoYW5uZWwsXG4gICAgICAgICAgICBwcmVtdWx0aXBseUFscGhhOiB0cnVlXG4gICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgICAgIGNhbmNlbENiID0gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgaW1hZ2UuY2FuY2VsKCk7XG4gICAgICAgIH07XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBsZXQgaW1hZ2UgPSBuZXcgSW1hZ2UoKTtcbiAgICAgICAgaWYgKCEoc3JjLnN1YnN0cigwLCA1KSA9PSBcImRhdGE6XCIpICYmICFVdGlscyQxLmlzUFM0KSB7XG4gICAgICAgICAgaW1hZ2UuY3Jvc3NPcmlnaW4gPSBcIkFub255bW91c1wiO1xuICAgICAgICB9XG4gICAgICAgIGltYWdlLm9uZXJyb3IgPSBmdW5jdGlvbihlcnIpIHtcbiAgICAgICAgICBpZiAoaW1hZ2Uuc3JjKSB7XG4gICAgICAgICAgICByZXR1cm4gY2IoXCJJbWFnZSBsb2FkIGVycm9yXCIpO1xuICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgaW1hZ2Uub25sb2FkID0gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgc291cmNlOiBpbWFnZSxcbiAgICAgICAgICAgIHJlbmRlckluZm86IHsgc3JjLCBjb21wcmVzc2VkOiBmYWxzZSB9LFxuICAgICAgICA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gIHN3aXRjaCAodGFyZ2V0KSB7XG4gICAgICAgIGNhc2UgMzU1MzpcbiAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgY2FzZSAzNDA2NzpcbiAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIHRleHR1cmUgdGFyZ2V0OiBcIiArIHRhcmdldCk7XG4gICAgICB9XG4gICAgfVxuICAgIHN0YXRpYyBfZ2V0VGV4dHVyZVRhcmdldEJ5SW5kZXgoaW5kZXgpIHtcbiAgICAgIGlmICghdGhpcy5fdGV4dHVyZVRhcmdldEluZGljZXMpIHtcbiAgICAgICAgdGhpcy5fdGV4dHVyZVRhcmdldEluZGljZXMgPSBbMzU1MywgMzQwNjddO1xuICAgICAgfVxuICAgICAgcmV0dXJuIHRoaXMuX3RleHR1cmVUYXJnZXRJbmRpY2VzW2luZGV4XTtcbiAgICB9XG4gICAgc3RhdGljIF9nZXRUZXh0dXJlSW5kZXgoaW5kZXgpIHtcbiAgICAgIHJldHVybiBpbmRleCAtIDMzOTg0O1xuICAgIH1cbiAgICBzdGF0aWMgX2dldFRleHR1cmVCeUluZGV4KGluZGV4KSB7XG4gICAgICByZXR1cm4gaW5kZXggKyAzMzk4NDtcbiAgICB9XG4gICAgc3RhdGljIF9nZXRQaXhlbFN0b3JlaUluZGV4KHBuYW1lKSB7XG4gICAgICBzd2l0Y2ggKHBuYW1lKSB7XG4gICAgICAgIGNhc2UgMzMzMzpcbiAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgY2FzZSAzMzE3OlxuICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICBjYXNlIDM3NDQwOlxuICAgICAgICAgIHJldHVybiAyO1xuICAgICAgICBjYXNlIDM3NDQxOlxuICAgICAgICAgIHJldHVybiAzO1xuICAgICAgICBjYXNlIDM3NDQzOlxuICAgICAgICAgIHJldHVybiA0O1xuICAgICAgICBjYXNl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iAgICByZW1vdmVBY3RpdmUodHJhbnNpdGlvbikge1xuICAgICAgdGhpcy5hY3RpdmUuZGVsZXRlKHRyYW5zaXRpb24pO1xuICAgIH1cbiAgfVxuICBjbGFzcyBNdWx0aVNwbGluZSB7XG4gICAgY29uc3RydWN0b3IoKSB7XG4gICAgICB0aGlzLl9jbGVhcigpO1xuICAgIH1cbiAgICBfY2xlYXIoKSB7XG4gICAgICB0aGlzLl9wID0gW107XG4gICAgICB0aGlzLl9wZSA9IFtdO1xuICAgICAgdGhpcy5faWRwID0gW107XG4gICAgICB0aGlzLl9mID0gW107XG4gICAgICB0aGlzLl92ID0gW107XG4gICAgICB0aGlzLl9sdiA9IFtdO1xuICAgICAgdGhpcy5fc20gPSBbXTtcbiAgICAgIHRoaXMuX3MgPSBbXTtcbiAgICAgIHRoaXMuX3ZlID0gW107XG4gICAgICB0aGlzLl9zbWUgPSBbXTtcbiAgICAgIHRoaXMuX3NlID0gW107XG4gICAgICB0aGlzLl9sZW5ndGggPSAwO1xuICAgIH1cbiAgICBwYXJzZShyZ2JhLCBkZWYpIHtcbiAgICAgIGxldCBpLCBuO1xuICAgICAgaWYgKCFVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbChkZWYpKSB7XG4gICAgICAgIGRlZiA9IHsgMDogZGVmIH07XG4gICAgICB9XG4gICAgICBsZXQgZGVmYXVsdFNtb290aG5lc3MgPSAwLjU7XG4gICAgICBsZXQgaXRlbXMgPSBbXTtcbiAgICAgIGZvciAobGV0IGtleSBpbiBkZWYpIHtcbiAgICAgICAgaWYgKGRlZi5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgbGV0IG9iaiA9IGRlZltrZXldO1xuICAgICAgICAgIGlmICghVXRpbHMkMS5pc09iamVjdExpdGVyYWwob2JqKSkge1xuICAgICAgICAgICAgb2JqID0geyB2OiBvYmogfTtcbiAgICAgICAgICB9XG4gICAgICAgICAgbGV0IHAgPSBwYXJzZUZsb2F0KGtleSk7XG4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XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaXRlbXNbaV0uaWRwID0gMSAvIChpdGVtc1tpXS5wZSAtIGl0ZW1zW2ldLnApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoXCJzbVwiKSkge1xuICAgICAgICAgIGl0ZW1zW2ldLnNtID0gZGVmYXVsdFNtb290aG5lc3M7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eShcInNcIikpIHtcbiAgICAgICAgICBpZiAoaSA9PT0gMCB8fCBpID09PSBuIC0gMSB8fCBpdGVtc1tpXS5wID09PSAxKSB7XG4gICAgICAgICAgICBpdGVtc1tpXS5zID0gcmdiYSA/IFswLCAwLCAwLCAwXSA6IDA7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnN0IHBpID0gaXRlbXNbaSAtIDFdO1xuICAgICAgICAgICAgY29uc3QgbmkgPSBpdGVtc1tpICsgMV07XG4gICAgICAgICAgICBpZiAocGkucCA9PT0gbmkucCkge1xuICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gcmdiYSA/IFswLCAwLCAwLCAwXSA6IDA7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBpZiAocmdiYSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IG5jID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHMobmkubHYpO1xuICAgICAgICAgICAgICAgIGNvbnN0IHBjID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHMocGkubHYpO1xuICAgICAgICAgICAgICAgIGNvbnN0IGQgPSAxIC8gKG5pLnAgLSBwaS5wKTtcbiAgICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gW1xuICAgICAgICAgICAgICAgICAgZCAqIChuY1swXSAtIHBjWzBdKSxcbiAgICAgICAgICAgICAgICAgIGQgKiAobmNbMV0gLSBwY1sxXSksXG4gICAgICAgICAgICAgICAgICBkICogKG5jWzJdIC0gcGNbMl0pLFxuICAgICAgICAgICAgICAgICAgZCAqIChuY1szXSAtIHBjWzNdKVxuICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IChuaS5sdiAtIHBpLmx2KSAvIChuaS5wIC0gcGkucCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGZvciAoaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7XG4gICAgICAgIGlmICghaXRlbXNbaV0uZikge1xuICAgICAgICAgIGxldCBsYXN0ID0gaSA9PT0gbiAtIDE7XG4gICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eShcInZlXCIpKSB7XG4gICAgICAgICAgICBpdGVtc1tpXS52ZSA9IGxhc3QgPyBpdGVtc1tpXS5sdiA6IGl0ZW1zW2kgKyAxXS5sdjtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKFV0aWxzJDEuaXNOdW1iZXIoaXRlbXNbaV0udikgJiYgVXRpbHMkMS5pc051bWJlcihpdGVtc1tpXS5sdikpIHtcbiAgICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoXCJzbWVcIikpIHtcbiAgICAgICAgICAgICAgaXRlbXNbaV0uc21lID0gbGFzdCA/IGRlZmF1bHRTbW9vdGhuZXNzIDogaXRlbXNbaSArIDFdLnNtO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eShcInNlXCIpKSB7XG4gICAgICAgICAgICAgIGl0ZW1zW2ldLnNlID0gbGFzdCA/IHJnYm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DAsIChwIC0gdGhpcy5fcFtpXSkgKiB0aGlzLl9pZHBbaV0pKTtcbiAgICAgICAgICByZXR1cm4gdGhpcy5fdltpXShvKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZXR1cm4gdGhpcy5fdltpXTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBnZXQgbGVuZ3RoKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2xlbmd0aDtcbiAgICB9XG4gICAgc3RhdGljIGdldFJnYmFDb21wb25lbnRzKGFyZ2IpIHtcbiAgICAgIGxldCByID0gKGFyZ2IgLyA2NTUzNiB8IDApICUgMjU2O1xuICAgICAgbGV0IGcgPSAoYXJnYiAvIDI1NiB8IDApICUgMjU2O1xuICAgICAgbGV0IGIgPSBhcmdiICUgMjU2O1xuICAgICAgbGV0IGEgPSBhcmdiIC8gMTY3NzcyMTYgfCAwO1xuICAgICAgcmV0dXJuIFtyLCBnLCBiLCBhXTtcbiAgICB9XG4gICAgc3RhdGljIGdldFNwbGluZVZhbHVlRnVuY3Rpb24odjEsIHYyLCBwMSwgcDIsIG8xLCBpMiwgczEsIHMyKSB7XG4gICAgICBsZXQgZHAgPSBwMiAtIHAxO1xuICAgICAgczEgKj0gZHA7XG4gICAgICBzMiAqPSBkcDtcbiAgICAgIGxldCBoZWxwZXJzID0gTXVsdGlTcGxpbmUuZ2V0U3BsaW5lSGVscGVycyh2MSwgdjIsIG8xLCBpMiwgczEsIHMyKTtcbiAgICAgIGlmICghaGVscGVycykge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24ocCkge1xuICAgICAgICAgIGlmIChwID09PSAwKVxuICAgICAgICAgICAgcmV0dXJuIHYxO1xuICAgICAgICAgIGlmIChwID09PSAxKVxuICAgICAgICAgICAgcmV0dXJuIHYyO1xuICAgICAgICAgIHJldHVybiB2MiAqIHAgKyB2MSAqICgxIC0gcCk7XG4gICAgICAgIH07XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZX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UuZ2V0U3BsaW5lSGVscGVycyhjdjFbM10sIGN2MlszXSwgbzEsIGkyLCBzMVszXSwgczJbM10pXG4gICAgICBdO1xuICAgICAgaWYgKCFoZWxwZXJzWzBdKSB7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbihwKSB7XG4gICAgICAgICAgaWYgKHAgPT09IDApXG4gICAgICAgICAgICByZXR1cm4gdjE7XG4gICAgICAgICAgaWYgKHAgPT09IDEpXG4gICAgICAgICAgICByZXR1cm4gdjI7XG4gICAgICAgICAgcmV0dXJuIE11bHRpU3BsaW5lLm1lcmdlQ29sb3JzKHYyLCB2MSwgcCk7XG4gICAgICAgIH07XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24ocCkge1xuICAgICAgICAgIGlmIChwID09PSAwKVxuICAgICAgICAgICAgcmV0dXJuIHYxO1xuICAgICAgICAgIGlmIChwID09PSAxKVxuICAgICAgICAgICAgcmV0dXJuIHYyO1xuICAgICAgICAgIHJldHVybiBNdWx0aVNwbGluZS5nZXRBcmdiTnVtYmVyKFtcbiAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbMF0sIHApKSxcbiAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbMV0sIHApKSxcbiAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbMl0sIHApKSxcbiAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbM10sIHApKVxuICAgICAgICAgIF0pO1xuICAgICAgICB9O1xuICAgICAgfVxuICAgIH1cbiAgICBzdGF0aWMgZ2V0U3BsaW5lSGVscGVycyh2MSwgdjIsIG8xLCBpMiwgczEsIHMyKSB7XG4gICAgICBpZiAoIW8xICYmICFpMikge1xuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgIH1cbiAgICAgIGxldCBjc3ggPSBvMTtcbiAgICAgIGxldCBjc3kgPSB2MSArIHMxICogbzE7XG4gICAgICBsZXQgY2V4ID0gMSAtIGkyO1xuICAgICAgbGV0IGNleSA9IHYyIC0gczIgKiBpMjtcbiAgICAgIGxldCB4YSA9IDMgKiBjc3ggLSAzICogY2V4ICsgMTtcbiAgICAgIGxldCB4YiA9IC02ICogY3N4ICsgMyAqIGNleDtcbiAgICAgIGxldCB4YyA9IDMgKiBjc3g7XG4gICAgICBsZXQgeWEgPSAzICogY3N5IC0gMyAqIGNleSArIHYyIC0gdjE7XG4gICAgICBsZXQgeWIgPSAzICogKGNleSArIHYxKSAtIDYgKiBjc3k7XG4gICAgICBsZXQgeWMgPSAzICogKGNzeSAtIHYxKTtcbiAgICAgIGxldCB5ZCA9IHYxO1xuICAgICAgcmV0dXJuIFt4YSwgeGIsIHhjLCB5YSwgeWIsIHljLCB5ZF07XG4gICAgfVxuICAgIHN0YXRpYyBjYWxjdWxhdGVTcGxpbmUoaGVscGVycywgcCkge1xuICAgICAgbGV0IHhhID0gaGVscGVyc1swXTtcbiAgICAgIGxldCB4YiA9IGhlbHBlcnNbMV07XG4gICAgICBsZXQgeGMgPSBoZWxwZXJzWzJdO1xuICAgICAgbGV0IHlhID0gaGVscGVyc1szXTtcbiAgICAgIGxldCB5YiA9IGhlbHBlcnNbNF07XG4gICAgICBsZXQgeWMgPSBoZWxwZXJzWzVdO1xuICAgICAgbGV0IHlkID0gaGVscGVyc1s2XTtcbiAgICAgIGlmICh4YSA9PT0gLTIgJiYgeWEgPT09IC0yICYmIHhjID09PSAwICYmIHljID09PSAwKSB7XG4gICAgICAgIHJldHVybiBwO1xuICAgICAgfVxuICAgICAgbGV0IHQgPSAwLjUsIGNieCwgZHg7XG4gICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcbiAgICAgICAgZHggPSBwIC0gY2J4O1xuICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKSArIHlkO1xuICAgICAgICB9XG4gICAgICAgIGxldCBjYnhkID0gdCAqICh0ICogKDMgKiB4YSkgKyAyICogeGIpICsgeGM7XG4gICAgICAgIGlmIChjYnhkID4gMWUtMTAgJiYgY2J4ZCA8IDFlLTEwKSB7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgdCArPSBkeCAvIGNieGQ7XG4gICAgICB9XG4gICAgICBsZXQgbWluVCA9IDA7XG4gICAgICBsZXQgbWF4VCA9IDE7XG4gICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgdCA9IDAuNSAqIChtaW5UICsgbWF4VCk7XG4gICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG4gICAgICAgIGR4ID0gcCAtIGNieDtcbiAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5YykgKyB5ZDtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZHggPCAwKSB7XG4gICAgICAgICAgbWF4VCA9IHQ7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbWluVCA9IHQ7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiB0O1xuICAgIH1cbiAgICBzdGF0aWMgbWVyZ2VDb2xvcnMoYzEsIGMyLCBwKSB7XG4gICAgICBsZXQgcjEgPSAoYzEgLyA2NTUzNiB8IDApICUgMjU2O1xuICAgICAgbGV0IGcxID0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IGR1cmF0aW9uO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodGhpcy5fcCA+PSAyKSB7XG4gICAgICAgICAgICB0aGlzLl9wID0gMjtcbiAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgdGhpcy5lbWl0KFwic3RvcEZpbmlzaFwiKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5lbWl0KFwicHJvZ3Jlc3NcIiwgdGhpcy5fcCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuRk9SV0FSRCkge1xuICAgICAgICBpZiAodGhpcy5fcCA8IDEpIHtcbiAgICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5kdXJhdGlvbiA9PSAwKSB7XG4gICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fcCArPSBkdCAvIHRoaXMuc2V0dGluZ3MuZHVyYXRpb247XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0aGlzLl9wID49IDEpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLkZPUldBUkQpIHtcbiAgICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgICB0aGlzLmVtaXQoXCJzdG9wRmluaXNoXCIpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlcGVhdHNMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlcGVhdHNMZWZ0LS07XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IDA7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KFwicmVwZWF0XCIsIHRoaXMuX3JlcGVhdHNMZWZ0KTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoXCJzdG9wRmluaXNoXCIpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuZW1pdChcInByb2dyZXNzXCIsIHRoaXMuX3ApO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfcHJvZ3Jlc3NTdG9wVHJhbnNpdGlvbihkdCkge1xuICAgICAgaWYgKHRoaXMuX3N0b3BQIDwgMSkge1xuICAgICAgICBpZiAodGhpcy5fc3RvcERlbGF5TGVmdCA+IDApIHtcbiAgICAgICAgICB0aGlzLl9zdG9wRGVsYXlMZWZ0IC09IGR0O1xuICAgICAgICAgIGlmICh0aGlzLl9zdG9wRGVsYXlMZWZ0IDwgMCkge1xuICAgICAgICAgICAgZHQgPSAtdGhpcy5fc3RvcERlbGF5TGVmdDtcbiAgICAgICAgICAgIHRoaXMuX3N0b3BEZWxheUxlZnQgPSAwO1xuICAgICAgICAgICAgdGhpcy5lbWl0KFwiZGVsYXlFbmRcIik7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgZHVyYXRpb24gPSB0aGlzLl9nZXRTdG9wRHVyYXRpb24o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AgICAgIHJldHVybiBVdGlscyQxLmlzRnVuY3Rpb24oZikgJiYgZi5fX21mO1xuICAgIH1cbiAgICBzdGF0aWMgbWYoZikge1xuICAgICAgZi5fX21mID0gdHJ1ZTtcbiAgICAgIHJldHVybiBmO1xuICAgIH1cbiAgICBzdGF0aWMgbWVyZ2UoYSwgYikge1xuICAgICAgY29uc3QgYWtzID0gT2JqZWN0LmtleXMoYSk7XG4gICAgICBjb25zdCBia3MgPSBPYmplY3Qua2V5cyhiKTtcbiAgICAgIGlmICghYmtzLmxlbmd0aCkge1xuICAgICAgICByZXR1cm4gYTtcbiAgICAgIH1cbiAgICAgIGNvbnN0IGFpID0ge307XG4gICAgICBjb25zdCBiaSA9IHt9O1xuICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBia3MubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIGNvbnN0IGtleSA9IGJrc1tpXTtcbiAgICAgICAgYWlba2V5XSA9IC0xO1xuICAgICAgICBiaVtrZXldID0gaTtcbiAgICAgIH1cbiAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYWtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBjb25zdCBrZXkgPSBha3NbaV07XG4gICAgICAgIGFpW2tleV0gPSBpO1xuICAgICAgICBpZiAoYmlba2V5XSA9PT0gdm9pZCAwKSB7XG4gICAgICAgICAgYmlba2V5XSA9IC0xO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBjb25zdCBha3NsID0gYWtzLmxlbmd0aDtcbiAgICAgIGNvbnN0IHJlc3VsdCA9IHt9O1xuICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBia3MubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIGNvbnN0IGtleSA9IGJrc1tpXTtcbiAgICAgICAgY29uc3QgYUluZGV4ID0gYWlba2V5XTtcbiAgICAgICAgbGV0IGN1ckluZGV4MiA9IGFJbmRleDtcbiAgICAgICAgd2hpbGUgKC0tY3VySW5kZXgyID49IDApIHtcbiAgICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4Ml07XG4gICAgICAgICAgaWYgKGJpW2FrZXldICE9PSAtMSkge1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHdoaWxlICgrK2N1ckluZGV4MiA8IGFJbmRleCkge1xuICAgICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXgyXTtcbiAgICAgICAgICByZXN1bHRbYWtleV0gPSBhW2FrZXldO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGJ2ID0gYltrZXldO1xuICAgICAgICBjb25zdCBhdiA9IGFba2V5XTtcbiAgICAgICAgbGV0IHI7XG4gICAgICAgIGlmICh0aGlzLmlzTWYoYnYpKSB7XG4gICAgICAgICAgciA9IGJ2KGF2KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAoIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKGF2KSB8fCAhVXRpbHMkMS5pc09iamVjdExpdGVyYWwoYnYpKSB7XG4gICAgICAgICAgICByID0gYnY7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHIgPSBPYmpNZXJnZXIubWVyZ2UoYXYsIGJ2KTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHIgIT09IHZvaWQgMCkge1xuICAgICAgICAgIHJlc3VsdFtrZXldID0gcjtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgbGV0IGN1ckluZGV4ID0gYWtzbDtcbiAgICAgIHdoaWxlICgtLWN1ckluZGV4ID49IDApIHtcbiAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleF07XG4gICAgICAgIGlmIChiaVtha2V5XSAhPT0gLTEpIHtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgd2hpbGUgKCsrY3VySW5kZXggPC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0aGlzLl9pdGVtU2l6ZSk7XG4gICAgICAgIHBlID0gZSAtICh2IC0gdmlld3BvcnRTaXplKSAvIHRoaXMuX2l0ZW1TaXplO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX3JvbGwgfHwgdmlld3BvcnRTaXplID4gdGhpcy5faXRlbVNpemUgKiBuRWxlbWVudHMpIHtcbiAgICAgICAgaWYgKGUgPj0gbkVsZW1lbnRzKSB7XG4gICAgICAgICAgZSA9IG5FbGVtZW50cyAtIDE7XG4gICAgICAgICAgcGUgPSAxO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzID49IG5FbGVtZW50cykge1xuICAgICAgICAgIHMgPSBuRWxlbWVudHMgLSAxO1xuICAgICAgICAgIHBzID0gMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZSA8PSAtMSkge1xuICAgICAgICAgIGUgPSAwO1xuICAgICAgICAgIHBlID0gMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocyA8PSAtMSkge1xuICAgICAgICAgIHMgPSAwO1xuICAgICAgICAgIHBzID0gMTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgbGV0IG9mZnNldCA9IC1kaXJlY3Rpb24gKiBzICogdGhpcy5faXRlbVNpemU7XG4gICAgICBsZXQgaXRlbTtcbiAgICAgIGZvciAobGV0IGluZGV4ID0gczsgZGlyZWN0aW9uID09IC0xID8gaW5kZXggPD0gZSA6IGluZGV4ID49IGU7IGRpcmVjdGlvbiA9PSAtMSA/IGluZGV4KysgOiBpbmRleC0tKSB7XG4gICAgICAgIGxldCByZWFsSW5kZXggPSBVdGlscyQxLmdldE1vZHVsb0luZGV4KGluZGV4LCBuRWxlbWVudHMpO1xuICAgICAgICBsZXQgZWxlbWVudCA9IHRoaXMuZ2V0RWxlbWVudChyZWFsSW5kZXgpO1xuICAgICAgICBpdGVtID0gZWxlbWVudC5wYXJlbnQ7XG4gICAgICAgIHRoaXMuX3Zpc2libGVJdGVtcy5kZWxldGUoaXRlbSk7XG4gICAgICAgIGlmICh0aGlzLl9ob3Jpem9udGFsKSB7XG4gICAgICAgICAgaXRlbS54ID0gb2Zmc2V0ICsgc2Nyb2xsRGVsdGE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaXRlbS55ID0gb2Zmc2V0ICsgc2Nyb2xsRGVsdGE7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IHdhc1Zpc2libGUgPSBpdGVtLnZpc2libGU7XG4gICAgICAgIGl0ZW0udmlzaWJsZSA9IHRydWU7XG4gICAgICAgIGlmICghd2FzVmlzaWJsZSB8fCB0aGlzLl9yZWxvYWRWaXNpYmxlRWxlbWVudHMpIHtcbiAgICAgICAgICB0aGlzLmVtaXQoXCJ2aXNpYmxlXCIsIGluZGV4LCByZWFsSW5kZXgpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9wcm9ncmVzc0FuaW1hdGlvbikge1xuICAgICAgICAgIGxldCBwID0gMTtcbiAgICAgICAgICBpZiAoaW5kZXggPT0gcykge1xuICAgICAgICAgICAgcCA9IHBzO1xuICAgICAgICAgIH0gZWxzZSBpZiAoaW5kZXggPT0gZSkge1xuICAgICAgICAgICAgcCA9IHBlO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0aGlzLl9wcm9ncmVzc0FuaW1hdGlvbi5hcHBseShlbGVtZW50LCBwKTtcbiAgICAgICAgfVxuICAgICAgICBvZmZzZXQgKz0gdGhpcy5faXRlbVNpemU7XG4gICAgICB9XG4gICAgICBsZXQgc2VsZjIgPSB0aGlzO1xuICAgICAgdGhpcy5fdmlzaWJsZUl0ZW1zLmZvckVhY2goZnVuY3Rpb24oaW52aXNpYmxlSXRlbSkge1xuICAgICAgICBpbnZpc2libGVJdGVtLnZpc2libGUgPSBmYWxzZTtcbiAgICAgICAgc2VsZjIuX3Zpc2libGVJdGVtcy5kZWxldGUoaW52aXNpYmxlSXRlbSk7XG4gICAgICB9KTtcbiAgICAgIGZvciAobGV0IGluZGV4ID0gczsgZGly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Bjb250ZW50LnJlbmRlcldpZHRoO1xuICAgICAgbGV0IGggPSBjb250ZW50LnJlbmRlckhlaWdodDtcbiAgICAgIGlmICh3ICE9PSBjb250ZW50V3JhcC53IHx8IGggIT09IGNvbnRlbnRXcmFwLmggfHwgZm9yY2UpIHtcbiAgICAgICAgY29udGVudFdyYXAudyA9IHc7XG4gICAgICAgIGNvbnRlbnRXcmFwLmggPSBoO1xuICAgICAgICBjb25zdCBzY2FsZXJzID0gY29udGVudFdyYXAucGFyZW50LnRhZyhcIlNjYWxlXCIpLmNoaWxkcmVuO1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHNjYWxlcnMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgdyA9IHcgKiAwLjU7XG4gICAgICAgICAgaCA9IGggKiAwLjU7XG4gICAgICAgICAgc2NhbGVyc1tpXS53ID0gdztcbiAgICAgICAgICBzY2FsZXJzW2ldLmggPSBoO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBfc2lnbmFsUHJveHkoKSB7XG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG4gIH1cbiAgY2xhc3MgQm9yZGVyQ29tcG9uZW50IGV4dGVuZHMgQ29tcG9uZW50IHtcbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgQ29udGVudDoge30sXG4gICAgICAgIEJvcmRlcnM6IHtcbiAgICAgICAgICBUb3A6IHsgcmVjdDogdHJ1ZSwgdmlzaWJsZTogZmFsc2UsIG1vdW50WTogMSB9LFxuICAgICAgICAgIFJpZ2h0OiB7IHJlY3Q6IHRydWUsIHZpc2libGU6IGZhbHNlIH0sXG4gICAgICAgICAgQm90dG9tOiB7IHJlY3Q6IHRydWUsIHZpc2libGU6IGZhbHNlIH0sXG4gICAgICAgICAgTGVmdDogeyByZWN0OiB0cnVlLCB2aXNpYmxlOiBmYWxzZSwgbW91bnRYOiAxIH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zQgY29sb3IgPSB0ZXh0dXJlMkQodVNhbXBsZXIsIHZUZXh0dXJlQ29vcmQpICogdkNvbG9yO1xuICAgICAgICB2ZWMyIGhhbGZSZXMgPSAwLjUgKiByZXNvbHV0aW9uLnh5O1xuICAgICAgICB2ZWMyIHBvaW50ID0gdlRleHR1cmVDb29yZC54eSAqIHJlc29sdXRpb24ueHk7XG4gICAgICAgIFxuICAgICAgICB2ZWMyIHBvczE7XG4gICAgICAgIHZlYzIgcG9zMjtcbiAgICAgICAgdmVjMiBkO1xuICAgICAgICBmbG9hdCBjO1xuICAgICAgICBmbG9hdCB0ID0gMC4wO1xuICAgICAgICAgICAgIFxuICAgICAgICBpZihmYWRlWzBdID4gMC4wKSB7XG4gICAgICAgICAgICBwb3MxID0gdmVjMihwb2ludC54LCBwb2ludC55KTtcbiAgICAgICAgICAgIHBvczIgPSB2ZWMyKHBvaW50LngsIHBvaW50LnkgKyBmYWRlWzBdKTtcbiAgICAgICAgICAgIGQgPSBwb3MyIC0gcG9zMTtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMSwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzFdID4gMC4wKSB7XG4gICAgICAgICAgICB2ZWMyIHBvczEgPSB2ZWMyKHBvaW50LnggLSByZXNvbHV0aW9uLnggLSBmYWRlWzFdLCB2VGV4dHVyZUNvb3JkLnkpO1xuICAgICAgICAgICAgdmVjMiBwb3MyID0gdmVjMihwb2ludC54IC0gcmVzb2x1dGlvbi54LCB2VGV4dHVyZUNvb3JkLnkpO1xuICAgICAgICAgICAgZCA9IHBvczEgLSBwb3MyO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MyLCBkKSAvIGRvdChkLCBkKTtcbiAgICAgICAgICAgIHQgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcChjLCAwLjAsIDEuMCkpO1xuICAgICAgICAgICAgY29sb3IgPSBtaXgodmVjNCgwLjApLCBjb2xvciwgdCk7XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGlmKGZhZGVbMl0gPiAwLjApIHtcbiAgICAgICAgICAgIHZlYzIgcG9zMSA9IHZlYzIodlRleHR1cmVDb29yZC54LCBwb2ludC55IC0gcmVzb2x1dGlvbi55IC0gZmFkZVsyXSk7XG4gICAgICAgICAgICB2ZWMyIHBvczIgPSB2ZWMyKHZUZXh0dXJlQ29vcmQueCwgcG9pbnQueSAtIHJlc29sdXRpb24ueSk7XG4gICAgICAgICAgICBkID0gcG9zMSAtIHBvczI7XG4gICAgICAgICAgICBjID0gZG90KHBvczIsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKGMsIDAuMCwgMS4wKSk7XG4gICAgICAgICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgICAgaWYoZmFkZVszXSA+IDAuMCkge1xuICAgICAgICAgICAgcG9zMSA9IHZlYzIocG9pbnQueCwgcG9pbnQueSk7XG4gICAgICAgICAgICBwb3MyID0gdmVjMihwb2ludC54ICsgZmFkZVszXSwgcG9pbnQueSk7XG4gICAgICAgICAgICBkID0gcG9zMiAtIHBvczE7XG4gICAgICAgICAgICBjID0gZG90KHBvczEsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKGMsIDAuMCwgMS4wKSk7XG4gICAgICAgICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgIC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gICAgICAgIGZsb2F0IG91dGVyID0gbWF4KHJhZGl1cyAvIHJlc29sdXRpb24ueCwgcmFkaXVzIC8gcmVzb2x1dGlvbi55KTtcblxuICAgICAgICBmbG9hdCB4MSA9IG1vZCh0LCAxLjApO1xuICAgICAgICBmbG9hdCB4MiA9IG1vZCh0ICsgYW5nbGUsIDEuMCk7XG5cbiAgICAgICAgaWYgKHgxIDwgeDIpIHtcbiAgICAgICAgICAgIGlmIChhID4geDEgJiYgYSA8IHgyKSB7XG4gICAgICAgICAgICAgICAgZmxvYXQgdmFsID0gKDEuMCAtICh4MiAtIGEpIC8gYW5nbGUpICogc21vb3Roc3RlcCgwLjAsIDMuICogc21vb3RoLCAoeDIgLSBhKSk7XG4gICAgICAgICAgICAgICAgZnJhZ0NvbG9yID0gbWl4KGJhY2tncm91bmRDb2xvciwgY29sb3IsIHZhbCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGZyYWdDb2xvciA9IGJhY2tncm91bmRDb2xvcjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChhIDwgeDIpIHtcbiAgICAgICAgICAgICAgICBmbG9hdCB2YWwgPSAoMS4wIC0gKHgyIC0gYSkgLyBhbmdsZSkgKiBzbW9vdGhzdGVwKDAuMCwgMy4gKiBzbW9vdGgsICh4MiAtIGEpKTtcbiAgICAgICAgICAgICAgICBmcmFnQ29sb3IgPSBtaXgoYmFja2dyb3VuZENvbG9yLCBjb2xvciwgdmFsKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoYSA+IHgxKSB7XG4gICAgICAgICAgICAgICAgZmxvYXQgdmFsID0gKDEuMCAtICgxLjAgKyB4MiAtIGEpIC8gYW5nbGUpICogc21vb3Roc3RlcCgwLjAsIDMuICogc21vb3RoLCAoMS4wICsgeDIgLSBhKSk7XG4gICAgICAgICAgICAgICAgZnJhZ0NvbG9yID0gbWl4KGJhY2tncm91bmRDb2x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ZlYzMgcm90O1xuICAgIHZhcnlpbmcgdmVjMyBwb3M7XG5cbiAgICB2b2lkIG1haW4odm9pZCkge1xuICAgICAgICBwb3MgPSB2ZWMzKGFWZXJ0ZXhQb3NpdGlvbi54eSwgeik7XG4gICAgICAgIFxuICAgICAgICBwb3MgLT0gcGl2b3Q7XG4gICAgICAgIFxuICAgICAgICAvLyBVbmRvIFhZIHJvdGF0aW9uXG4gICAgICAgIG1hdDIgaVJvdFh5ID0gbWF0MiggY29zKHJvdC56KSwgc2luKHJvdC56KSwgXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAtc2luKHJvdC56KSwgY29zKHJvdC56KSk7XG4gICAgICAgIHBvcy54eSA9IGlSb3RYeSAqIHBvcy54eTtcbiAgICAgICAgXG4gICAgICAgIC8vIFBlcmZvcm0gM2Qgcm90YXRpb25zXG4gICAgICAgIGdsX1Bvc2l0aW9uLnggPSBjb3Mocm90LngpICogcG9zLnggLSBzaW4ocm90LngpICogcG9zLno7XG4gICAgICAgIGdsX1Bvc2l0aW9uLnkgPSBwb3MueTtcbiAgICAgICAgZ2xfUG9zaXRpb24ueiA9IHNpbihyb3QueCkgKiBwb3MueCArIGNvcyhyb3QueCkgKiBwb3MuejtcbiAgICAgICAgXG4gICAgICAgIHBvcy54ID0gZ2xfUG9zaXRpb24ueDtcbiAgICAgICAgcG9zLnkgPSBjb3Mocm90LnkpICogZ2xfUG9zaXRpb24ueSAtIHNpbihyb3QueSkgKiBnbF9Qb3NpdGlvbi56O1xuICAgICAgICBwb3MueiA9IHNpbihyb3QueSkgKiBnbF9Qb3NpdGlvbi55ICsgY29zKHJvdC55KSAqIGdsX1Bvc2l0aW9uLno7XG4gICAgICAgIFxuICAgICAgICAvLyBSZWRvIFhZIHJvdGF0aW9uXG4gICAgICAgIGlSb3RYeVswXVsxXSA9IC1pUm90WHlbMF1bMV07XG4gICAgICAgIGlSb3RYeVsxXVswXSA9IC1pUm90WHlbMV1bMF07XG4gICAgICAgIHBvcy54eSA9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ICAgICAgICAgICB0aGlzLl9ldmVudExpc3RlbmVyc1tuYW1lXS5wdXNoKGxpc3RlbmVyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIG9uY2UobmFtZSwgbGlzdGVuZXIpIHtcbiAgICAgICAgY29uc3Qgd3JhcHBlciA9IChhcmcxLCBhcmcyLCBhcmczKSA9PiB7XG4gICAgICAgICAgICBsaXN0ZW5lcihhcmcxLCBhcmcyLCBhcmczKTtcbiAgICAgICAgICAgIHRoaXMub2ZmKG5hbWUsIHdyYXBwZXIpO1xuICAgICAgICB9XG4gICAgICAgIHdyYXBwZXIuX19vcmlnaW5hbEZ1bmMgPSBsaXN0ZW5lcjtcbiAgICAgICAgdGhpcy5vbihuYW1lLCB3cmFwcGVyKTtcbiAgICB9XG5cbiAgICBoYXMobmFtZSwgbGlzdGVuZXIpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hhc0V2ZW50TGlzdGVuZXJzKSB7XG4gICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXTtcbiAgICAgICAgICAgIGlmIChjdXJyZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IEV2ZW50RW1pdHRlci5jb21iaW5lcikge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBsaXN0ZW5lcnMgPSB0aGlzLl9ldmVudExpc3RlbmVyc1tuYW1lXTtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsIG9mIGxpc3RlbmVycykge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGwgPT09IGxpc3RlbmVyIHx8IGwuX19vcmlnaW5hbEZ1bmMgPT0gbGlzdGVuZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXSA9PT0gbGlzdGVuZXIgfHwgdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXS5fX29yaWdpbmFsRnVuYyA9PT0gbGlzdGVuZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG5cbiAgICBvZmYobmFtZSwgbGlzdGVuZXIpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hhc0V2ZW50TGlzdGVuZXJzKSB7XG4gICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXTtcbiAgICAgICAgICAgIGlmIChjdXJyZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IEV2ZW50RW1pdHRlci5jb21iaW5lcikge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBsaXN0ZW5lcnMgPSB0aGlzLl9ldmVudExpc3RlbmVyc1tuYW1lXTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gbGlzdGVuZXJzLmluZGV4T2YobGlzdGVuZXIpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLnNwbGljZShpbmRleCwgMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBsaXN0ZW5lcnMubWFwKChsKSA9PiBsLl9fb3JpZ2luYWxGdW5jKS5pbmRleE9mKGxpc3RlbmVyKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ID49IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVycy5zcGxpY2UoaW5kZXgsIDEpO1xuICAgICAgICAg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AgICAgICAgICAgZnVuYyhhcmcxLCBhcmcyLCBhcmczKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBsaXN0ZW5lckNvdW50KG5hbWUpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hhc0V2ZW50TGlzdGVuZXJzKSB7XG4gICAgICAgICAgICBjb25zdCBmdW5jID0gdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXTtcbiAgICAgICAgICAgIGlmIChmdW5jKSB7XG4gICAgICAgICAgICAgICAgaWYgKGZ1bmMgPT09IEV2ZW50RW1pdHRlci5jb21iaW5lcikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZXZlbnRMaXN0ZW5lcnNbbmFtZV0ubGVuZ3RoO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gMDtcbiAgICB9XG5cbiAgICByZW1vdmVBbGxMaXN0ZW5lcnMobmFtZSkge1xuICAgICAgICBpZiAodGhpcy5faGFzRXZlbnRMaXN0ZW5lcnMpIHtcbiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdO1xuICAgICAgICAgICAgZGVsZXRlIHRoaXMuX2V2ZW50TGlzdGVuZXJzW25hbWVdO1xuICAgICAgICB9XG4gICAgfVxuXG59XG5cbkV2ZW50RW1pdHRlci5jb21iaW5lciA9IGZ1bmN0aW9uKG9iamVjdCwgbmFtZSwgYXJnMSwgYXJnMiwgYXJnMykge1xuICAgIGNvbnN0IGxpc3RlbmVycyA9IG9iamVjdC5fZXZlbnRMaXN0ZW5lcnNbbmFtZV07XG4gICAgaWYgKGxpc3RlbmVycykge1xuICAgICAgICAvKiBCZWNhdXNlIGxpc3RlbmVyIG1heSBk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c3MoZHQpIHtcbiAgICAgICAgaWYgKHRoaXMuX3N0YXRlID09IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBJTkcpIHtcbiAgICAgICAgICAgIHRoaXMuX3N0b3BQcm9ncmVzcyhkdCk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fc3RhdGUgIT0gQW5pbWF0aW9uLlNUQVRFUy5QTEFZSU5HKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fZGVsYXlMZWZ0ID4gMCkge1xuICAgICAgICAgICAgdGhpcy5fZGVsYXlMZWZ0IC09IGR0O1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fZGVsYXlMZWZ0IDwgMCkge1xuICAgICAgICAgICAgICAgIGR0ID0gLXRoaXMuX2RlbGF5TGVmdDtcbiAgICAgICAgICAgICAgICB0aGlzLl9kZWxheUxlZnQgPSAwO1xuXG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdkZWxheUVuZCcpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5kdXJhdGlvbiA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zZXR0aW5ncy5kdXJhdGlvbiA+IDApIHtcbiAgICAgICAgICAgIHRoaXMuX3AgKz0gZHQgLyB0aGlzLnNldHRpbmdzLmR1cmF0aW9uO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9wID49IDEpIHtcbiAgICAgICAgICAgIC8vIEZpbmlzaGVkITtcbiAgICAgICAgICAgIGlmICh0aGlzLnNldHRpbmdzLnJlcGVhdCA9PSAtMSB8fCB0aGlzLl9yZXBlYXRzTGVmdCA+IDApIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fcmVwZWF0c0xlZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcGVhdHNMZWZ0LS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSB0aGlzLnNldHRpbmdzLnJlcGVhdE9mZnNldDtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3Byb2dyZXNzJywgdGhpcy5fcCk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3MucmVwZWF0RGVsYXkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsYXlMZWZ0ID0gdGhpcy5zZXR0aW5ncy5yZXBlYXREZWxheTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3JlcGVhdCcsIHRoaXMuX3JlcGVhdHNMZWZ0KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdwcm9ncmVzcycsIHRoaXMuX3ApO1xuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5GSU5JU0hFRDtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ2ZpbmlzaCcpO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNldHRpbmdzLmF1dG9zdG9wKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc3RvcCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuZW1pdCgncHJvZ3Jlc3MnLCB0aGlzLl9wKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBcbiAgICBfc3RvcFByb2dyZXNzKGR0KSB7XG4gICAgICAgIGxldCBkdXJhdGlvbiA9IHRoaXMuX2dldFN0b3BEdXJhdGlvbigpO1xuXG4gICAgICAgIGlmICh0aGlzLl9zdG9wRGVsYXlMZWZ0ID4gMCkge1xuICAgICAgICAgICAgdGhpcy5fc3RvcERlbGF5TGVmdCAtPSBkdDtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3BEZWxheUxlZnQgPCAwKSB7XG4gICAgICAgICAgICAgICAgZHQgPSAtdGhpcy5fc3RvcERlbGF5TGVmdDtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdG9wRGVsYXlMZWZ0ID0gMDtcblxuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnc3RvcERlbGF5RW5kJyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5JTU1FRElBVEUpIHtcbiAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgdGhpcy5lbWl0KCdzdG9wRmluaXNoJyk7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5SRVZFUlNFKSB7XG4gICAgICAgICAgICBpZiAoZHVyYXRpb24gPT09IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMDtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZHVyYXRpb24gPiAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCAtPSBkdCAvIGR1cmF0aW9uO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fcCA8PSAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IDA7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdzdG9wRmluaXNoJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5GQURFKSB7XG4gICAgICAgICAgICB0aGlzLl9wcm9ncmVzc1N0b3BUcmFuc2l0aW9uKGR0KTtcbiAgICAgICAgICAgIGlmICh0aGlzLl9zdG9wUCA+PSAxKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IDA7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdzdG9wRmluaXNoJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5PTkVUT1RXTykge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3AgPCAyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGR1cmF0aW9uID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAyO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZHVyYXRpb24gPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wIDwgMSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCArPSBkdCAvIHRoaXMuc2V0dGluZ3MuZHVyYXRpb247XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gZHVyYXRpb247XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3AgPj0gMikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wID0gMjtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnc3RvcEZpbmlzaCcpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgncHJvZ3Jlc3MnLCB0aGlzLl9wKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5GT1JXQVJEKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fcCA8IDEpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5kdXJhdGlvbiA9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgKz0gZHQgLyB0aGlzLnNldHRpbmdzLmR1cmF0aW9uO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fcCA+PSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLkZPUldBUkQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3N0b3BGaW5pc2gnKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXBlYXRzTGVmdCA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXBlYXRzTGVmdC0tO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgncmVwZWF0JywgdGhpcy5fcmVwZWF0c0xlZnQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3N0b3BGaW5pc2gnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgncHJvZ3Jlc3MnLCB0aGlzLl9wKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgfVxuICAgIFxuICAgIF9wcm9ncmVzc1N0b3BUcmFuc2l0aW9uKGR0KSB7XG4gICAgICAgIGlmICh0aGlzLl9zdG9wUCA8IDEpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9zdG9wRGVsYXlMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0b3BEZWxheUxlZnQgLT0gZHQ7XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fc3RvcERlbGF5TGVmdCA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgZHQgPSAtdGhpcy5fc3RvcERlbGF5TGVmdDtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcERlbGF5TGVmdCA9IDA7XG5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdkZWxheUVuZCcpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBcbiAgICAgICAgICAgIGNvbnN0IGR1cmF0aW9uID0gdGhpcy5fZ2V0U3RvcER1cmF0aW9uKCk7XG5cbiAgICAgICAgICAgIGlmIChkdXJhdGlvbiA9PSAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RvcFAgPSAxO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdG9wUCArPSBkdCAvIGR1cmF0aW9uO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3BQID49IDEpIHtcbiAgICAgICAgICAgICAgICAvLyBGaW5pc2hlZCE7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RvcFAgPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldFN0b3BEdXJhdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc2V0dGluZ3Muc3RvcER1cmF0aW9uIHx8IHRoaXMuc2V0dGluZ3MuZHVyYXRpb247XG4gICAgfVxuXG4gICAgYXBwbHkoKSB7XG4gICAgICAgIGlmICh0aGlzLl9zdGF0ZSA9PT0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEKSB7XG4gICAgICAgICAgICB0aGlzLnJlc2V0KCk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1Jlc2V0VmFsdWUgPSBmYWxzZTtcblxuICAgICAgICB0aGlzLl9oYXNDb2xvclByb3BlcnR5ID0gdW5kZWZpbmVkO1xuICAgIH1cblxuICAgIGdldFJlc2V0VmFsdWUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNSZXNldFZhbHVlKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVzZXRWYWx1ZTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9pdGVtcy5nZXRWYWx1ZSgwKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGFwcGx5KGVsZW1lbnQsIHAsIGZhY3Rvcikge1xuICAgICAgICBjb25zdCBlbGVtZW50cyA9IHRoaXMuZ2V0QW5pbWF0ZWRFbGVtZW50cyhlbGVtZW50KTtcblxuICAgICAgICBsZXQgdiA9IHRoaXMuX2l0ZW1zLmdldFZhbHVlKHApO1xuXG4gICAgICAgIGlmICh2ID09PSB1bmRlZmluZWQgfHwgIWVsZW1lbnRzLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGZhY3RvciAhPT0gMSkge1xuICAgICAgICAgICAgLy8gU3RvcCBmYWN0b3IuO1xuICAgICAgICAgICAgbGV0IHN2ID0gdGhpcy5nZXRSZXNldFZhbHVlKCk7XG5cbiAgICAgICAgICAgIGlmIChVdGlscy5pc051bWJlcih2KSAmJiBVdGlscy5pc051bWJlcihzdikpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5oYXNDb2xvclByb3BlcnR5KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdiA9IFN0YWdlVXRpbHMubWVyZ2VDb2xvcnModiwgc3YsIGZhY3Rvcik7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdiA9IFN0YWdlVXRpbHMubWVyZ2VOdW1iZXJzKHYsIHN2LCBmYWN0b3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iAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcHJvcFNldHRlcnNbaV0oZWxlbWVudHNbal0sIHYpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIFxuICAgIHNldCBzZWxlY3Rvcih2KSB7XG4gICAgICAgIHRoaXMuX3NlbGVjdG9yID0gdjtcbiAgICB9XG5cbiAgICBzZXQgdCh2KSB7XG4gICAgICAgIHRoaXMuc2VsZWN0b3IgPSB2O1xuICAgIH1cblxuICAgIGdldCByZXNldFZhbHVlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmVzZXRWYWx1ZTtcbiAgICB9XG4gICAgXG4gICAgc2V0IHJlc2V0VmFsdWUodikge1xuICAgICAgICB0aGlzLl9yZXNldFZhbHVlID0gdjtcbiAgICAgICAgdGhpcy5faGFzUmVzZXRWYWx1ZSA9ICh2ICE9PSB1bmRlZmluZWQpO1xuICAgIH1cblxuICAgIHNldCBydih2KSB7XG4gICAgICAgIHRoaXMucmVzZXRWYWx1ZSA9IHY7XG4gICAgfVxuXG4gICAgc2V0IHZhbHVlKHYpIHtcbiAgICAgICAgdGhpcy5faXRlbXMucGFyc2UodGhpcy5oYXNDb2xvclByb3BlcnR5KCksIHYpO1xuICAgIH1cblxuICAgIHNldCB2KHYpIHtcbiAgICAgICAgdGhpcy52YWx1ZSA9IHY7XG4gICAgfVxuXG4gICAgc2V0IHByb3BlcnRpZXModikge1xuICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkodikpIHtcbiAgICAgICAgICAgIHYgPSBbdl07XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9wcm9wcyA9IFtdO1xuXG4gICAgICAgIHYuZm9yRWFjaCgocHJvcCkgPT4ge1xuICAgICAgICAgICAgdGhpcy5fcHJvcHMucHVzaChwcm9wKTtcbiAgICAgICAgICAgIHRoaXMuX3Byb3BTZXR0ZXJzLnB1c2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zQXR0YWNoZWQoKSkge1xuICAgICAgICAgICAgLy8gU2tpcCB0byBlbmQgb2YgdHJhbnNpdGlvbiBzbyB0aGF0IGl0IGlzIHJlbW92ZWQuXG4gICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLnAgPCAxKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5kZWxheUxlZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZGVsYXlMZWZ0IC09IGR0O1xuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVsYXlMZWZ0IDwgMCkge1xuICAgICAgICAgICAgICAgICAgICBkdCA9IC10aGlzLmRlbGF5TGVmdDtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsYXlMZWZ0ID0gMDtcblxuICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ2RlbGF5RW5kJyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLmR1cmF0aW9uID09IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCArPSBkdCAvIHRoaXMuX3NldHRpbmdzLmR1cmF0aW9uO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX3AgPj0gMSkge1xuICAgICAgICAgICAgICAgIC8vIEZpbmlzaGVkITtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuX3VwZGF0ZURyYXdWYWx1ZSgpO1xuXG4gICAgICAgIHRoaXMuaW52b2tlTGlzdGVuZXJzKCk7XG4gICAgfV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nRlclwiKSkge1xuICAgICAgICAgICAgdGhpcy5zdGFnZS5wbGF0Zm9ybS5yZWdpc3RlckNsaWNrSGFuZGxlcigoZSkgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlY2VpdmVDbGljayhlKTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICB0aGlzLnN0YWdlLnBsYXRmb3JtLnJlZ2lzdGVySG92ZXJIYW5kbGVyKChlKSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmVjZWl2ZUhvdmVyKGUpO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHRoaXMuc3RhZ2UucGxhdGZvcm0ucmVnaXN0ZXJTY3JvbGxXaGVlbEhhbmRsZXIoKGUpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZWNpZXZlU2Nyb2xsV2hlZWwoZSk7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgdGhpcy5jdXJzb3IgPSAnZGVmYXVsdCc7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXRPcHRpb24obmFtZSkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX29wdGlvbnNbbmFtZV07XG4gICAgfVxuXG4gICAgX3NldE9wdGlvbnMobykge1xuICAgICAgICB0aGlzLl9fb3B0aW9ucyA9IHt9O1xuXG4gICAgICAgIGxldCBvcHQgPSAobmFtZSwgZGVmKSA9PiB7XG4gICAgICAgICAgICBsZXQgdmFsdWUgPSBvW25hbWVdO1xuXG4gICAgICAgICAgICBpZiAodmFsdWUgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX19vcHRpb25zW25hbWVdID0gZGVmO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9fb3B0aW9uc1tuYW1lXSA9IHZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgb3B0KCdkZWJ1ZycsIGZhbHNlKTtcbiAgICAgICAgb3B0KCdrZXlzJywge1xuICAgICAgICAgICAgMzg6IFwiVXBcIixcbiAgICAgICAgICAgIDQwOiBcIkRvd25cIixcbiAgICAgICAgICAgIDM3OiBcIkxlZnRcIixcbiAgICAgICAgICAgIDM5OiBcIlJpZ2h0XCIsXG4gICAgICAgICAgICAxMzogXCJFbnRlclwiLFxuICAgICAgICAgICAgODogXCJCYWNrXCIsXG4gICAgICAgICAgICAyNzogXCJFeGl0XCJcbiAgICAgICAgfSk7XG4gICAgICAgIG9wdCgnZW5hYmxlUG9pbnRlcicsIGZhbHNlKTtcbiAgICB9XG5cbiAgICBfX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgdGhpcy5zdGFnZS5zZXRBcHBsaWNhdGlvbih0aGlzKTtcblxuICAgICAgICB0aGlzLl9zZXRPcHRpb25zKEFwcGxpY2F0aW9uLl90ZW1wX29wdGlvbnMpO1xuICAgICAgICBkZWxldGUgQXBwbGljYXRpb24uX3RlbXBfb3B0aW9ucztcblxuICAgICAgICBzdXBlci5fX2NvbnN0cnVjdCgpO1xuICAgIH1cblxuICAgIF9faW5pdCgpIHtcbiAgICAgICAgc3VwZXIuX19pbml0KCk7XG4gICAgICAgIHRoaXMuX191cGRhdGVGb2N1cygpO1xuICAgIH1cblxuICAgIHVwZGF0ZUZvY3VzUGF0aCgpIHtcbiAgICAgICAgdGhpcy5fX3VwZGF0ZUZvY3VzKCk7XG4gICAgfVxuXG4gICAgX191cGRhdGVGb2N1cygpIHtcbiAgICAgICAgY29uc3Qgbm90T3ZlcnJpZGRlbiA9IHRoaXMuX191cGRhdGVGb2N1c1JlYygpO1xuXG4gICAgICAgIGlmICghQXBwbGljYXRpb24uYm9vdGluZyAmJiBub3RPdmVycmlkZGVuKSB7XG4gICAgICAgICAgICB0aGlzLnVwZGF0ZUZvY3VzU2V0dGluZ3MoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9fdXBkYXRlRm9jdXNSZWMoKSB7XG4gICAg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IH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbGV0IG0gPSBNYXRoLm1pbih0aGlzLl9mb2N1c1BhdGgubGVuZ3RoLCBuZXdGb2N1c1BhdGgubGVuZ3RoKTtcbiAgICAgICAgICAgIGxldCBpbmRleDtcbiAgICAgICAgICAgIGZvciAoaW5kZXggPSAwOyBpbmRleCA8IG07IGluZGV4KyspIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fZm9jdXNQYXRoW2luZGV4XSAhPT0gbmV3Rm9jdXNQYXRoW2luZGV4XSkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9mb2N1c1BhdGgubGVuZ3RoICE9PSBuZXdGb2N1c1BhdGgubGVuZ3RoIHx8IGluZGV4ICE9PSBuZXdGb2N1c1BhdGgubGVuZ3RoKSB7XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5nZXRPcHRpb24oJ2RlYnVnJykpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ1tMaWdodG5pbmddIEZvY3VzIGNoYW5nZWQ6ICcgKyBuZXdGb2N1c2VkQ29tcG9uZW50LmdldExvY2F0aW9uU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIFVuZm9jdXMgZXZlbnRzLlxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSB0aGlzLl9mb2N1c1BhdGgubGVuZ3RoIC0gMTsgaSA+PSBpbmRleDsgaS0tKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuZm9jdXNlZEVsZW1lbnQgPSB0aGlzLl9mb2N1c1BhdGgucG9wKCk7XG4gICAgICAgICAgICAgICAgICAgIHVuZm9jdXNlZEVsZW1lbnQuX3VuZm9jdXMobmV3Rm9jdXNlZENvbXBvbmVudCwgcHJldkZvY3VzZWRDb21wb25lbnQpO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBmb2N1c092ZXJyaWRkZW4gPSAodGhpcy5fX3VwZGF0ZUZvY3VzSWQgIT09IHVwZGF0ZUZvY3VzSWQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZm9jdXNPdmVycmlkZGVuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBGb2N1cyBldmVudHMuXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IGluZGV4LCBuID0gbmV3Rm9jdXNQYXRoLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9mb2N1c1BhdGgucHVzaChuZXdGb2N1c1BhdGhbaV0pO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9mb2N1c1BhdGhbaV0uX2ZvY3VzKG5ld0ZvY3VzZWRDb21wb25lbnQsIHByZXZGb2N1c2VkQ29tcG9uZW50KTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9jdXNPdmVycmlkZGVuID0gKHRoaXMuX191cGRhdGVGb2N1c0lkICE9PSB1cGRhdGVGb2N1c0lkKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZvY3VzT3ZlcnJpZGRlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gRm9jdXMgY2hhbmdlZCBldmVudHMuXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpbmRleDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZvY3VzUGF0aFtpXS5f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bGV0IHB0ciA9IG5leHRGb2N1cy5jcGFyZW50O1xuICAgICAgICAgICAgaWYgKHB0ciA9PT0gY3VycmVudCkge1xuICAgICAgICAgICAgICAgIHBhdGgucHVzaChuZXh0Rm9jdXMpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBOb3QgYW4gaW1tZWRpYXRlIGNoaWxkOiBpbmNsdWRlIGZ1bGwgcGF0aCB0byBkZXNjZW5kYW50LlxuICAgICAgICAgICAgICAgIGNvbnN0IG5ld1BhcnRzID0gW25leHRGb2N1c107XG4gICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXB0cikge1xuICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5fdGhyb3dFcnJvcihcIlJldHVybiB2YWx1ZSBmb3IgX2dldEZvY3VzZWQgbXVzdCBiZSBhbiBhdHRhY2hlZCBkZXNjZW5kYW50IGNvbXBvbmVudCBidXQgaXRzICdcIiArIG5leHRGb2N1cy5nZXRMb2NhdGlvblN0cmluZygpICsgXCInXCIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIG5ld1BhcnRzLnB1c2gocHRyKTtcbiAgICAgICAgICAgICAgICAgICAgcHRyID0gcHRyLmNwYXJlbnQ7XG4gICAgICAgICAgICAgICAgfSB3aGlsZSAocHRyICE9PSBjdXJyZW50KTtcblxuICAgICAgICAgICAgICAgIC8vIEFkZCB0aGVtIHJldmVyc2VkLlxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gbmV3UGFydHMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIHBhdGgucHVzaChuZXdQYXJ0c1tuIC0gaSAtIDFdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGN1cnJlbnQgPSBuZXh0Rm9jdXM7XG4gICAgICAgIH0gd2hpb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vbi5cbiAgICAgKi9cbiAgICBmb2N1c0JvdHRvbVVwRXZlbnQoZXZlbnRzLCAuLi5hcmdzKSB7XG4gICAgICAgIGNvbnN0IHBhdGggPSB0aGlzLmZvY3VzUGF0aDtcbiAgICAgICAgY29uc3QgbiA9IHBhdGgubGVuZ3RoO1xuXG4gICAgICAgIC8vIE11bHRpcGxlIGV2ZW50cy5cbiAgICAgICAgZm9yIChsZXQgaSA9IG4gLSAxOyBpID49IDA7IGktLSkge1xuICAgICAgICAgICAgY29uc3QgZXZlbnQgPSBwYXRoW2ldLl9nZXRNb3N0U3BlY2lmaWNIYW5kbGVkTWVtYmVyKGV2ZW50cyk7XG4gICAgICAgICAgICBpZiAoZXZlbnQgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJldHVyblZhbHVlID0gcGF0aFtpXVtldmVudF0oLi4uYXJncyk7XG4gICAgICAgICAgICAgICAgaWYgKHJldHVyblZhbHVlICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgX3JlY2VpdmVLZXlkb3duKGUpIHtcbiAgICAgICAgY29uc3Qgb2JqID0gZTtcbiAgICAgICAgY29uc3Qga2V5ID0gdGhpcy5fX2tleW1hcFtlLmtleUNvZGVdO1xuICAgICAgICBjb25zdCBwYXRoID0gdGhpcy5mb2N1c1BhdGg7XG5cbiAgICAgICAgbGV0IGtleXM7XG4gICAgICAgIGlmIChrZXkpIHtcbiAgICAgICAgICAgIGtleXMgPSBBcnJheS5pc0FycmF5KGtleSkgPyBrZXkgOiBba2V5XTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChrZXlzKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGtleXMubGVuZ3RoOyBpIDwgbjsg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TtcblxuICAgICAgICBpZiAoY29uZmlnW2xvb2t1cF0pIHtcbiAgICAgICAgICAgIGNvbnN0IHRpbWVvdXQgPSBjb25maWdbbG9va3VwXTtcbiAgICAgICAgICAgIGlmICghVXRpbHMuaXNOdW1iZXIodGltZW91dCkpIHtcbiAgICAgICAgICAgICAgICBlbGVtZW50Ll90aHJvd0Vycm9yKFwiY29uZmlnIHZhbHVlIGZvciBsb25ncHJlc3MgbXVzdCBiZSBhIG51bWJlclwiKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX2tleXByZXNzVGltZXJzLnNldChrZXksIHNldFRpbWVvdXQoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuc3RhZ2UuYXBwbGljYXRpb24uZm9jdXNUb3BEb3duRXZlbnQoW2BfY2FwdHVyZSR7a2V5fUxvbmdgLCBcIl9jYXB0dXJlS2V5XCJdLCB7fSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuYXBwbGljYXRpb24uZm9jdXNCb3R0b21VcEV2ZW50KFtgX2hhbmRsZSR7a2V5fUxvbmdgLCBcIl9oYW5kbGVLZXlcIl0sIHt9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19rZXlwcmVzc1RpbWVycy5kZWxldGUoa2V5KTtcbiAgICAgICAgICAgICAgICB9LCB0aW1lb3V0IHx8IDUwMCAvKiBwcmV2ZW50IDBtcyAqLykpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybjtcbiAgICB9XG5cbiAgICBfcmVjaWV2ZVNjcm9sbFdoZWVsKGUpIHtcbiAgICAgICAgY29uc3Qgb2JqID0gZTtcbiAgICAgICAgY29uc3QgeyBjbGllbnRYLCBjbGllbnRZIH0gPSBvYmo7XG5cbiAgICAgICAgaWYgKGNsaWVudFggPD0gdGhpcy5zdGFnZ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gIGxldCBjaGlsZCA9IHRhcmdldDtcblxuICAgICAgICAvLyBTZWFyY2ggdHJlZSBib3R0b20gdXAgZm9yIGEgaGFuZGxlclxuICAgICAgICB3aGlsZSAoY2hpbGQgIT09IG51bGwpIHtcbiAgICAgICAgICAgIGlmIChjaGlsZCAmJiBjaGlsZFtldmVudF0pIHtcbiAgICAgICAgICAgICAgICBjaGlsZC5faGFuZGxlU2Nyb2xsKG9iaik7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjaGlsZCA9IGNoaWxkLnBhcmVudDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgX3JlY2VpdmVDbGljayhlKSB7XG4gICAgICAgIGNvbnN0IG9iaiA9IGU7XG4gICAgICAgIGNvbnN0IHsgY2xpZW50WCwgY2xpZW50WSB9ID0gb2JqO1xuXG4gICAgICAgIGlmIChjbGllbnRYIDw9IHRoaXMuc3RhZ2UudyAmJiBjbGllbnRZIDw9IHRoaXMuc3RhZ2UuaCkge1xuICAgICAgICAgICAgdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5maXJlQm90dG9tVXBDbGlja0hhbmRsZXIob2JqKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZpcmVCb3R0b21VcENsaWNrSGFuZGxlcihvYmopIHtcbiAgICAgICAgY29uc3QgeyBjbGllbnRYLCBjbGllbnRZIH0gPSBvYmo7XG4gICAgICAgIGNvbnN0IHRhcmdldCA9IHRoaXMuX2dldFRhcmdldENoaWxkKGNsaWVudFgsIGNsaWVudFkpO1xuICAgICAgICBjb25zdCBwcmVjaXNpb24gPSB0aGlzLnN0YWdlLmdldFJlbmRlclByZWNpc2lvbigpIC8gdGhpcy5zdGFnZS5nZXRPcHRpb24oJ2RldmljZVBpeGVsUmF0aW8nKTtcbiAgICAgICAgbGV0IGNoaWxkID0gdGFyZ2V0O1xuXG4gICAgICAgIC8vIFNlYXJjaCB0cmVlIGJvdHRvbSB1cCBmb3IgYSBoYW5kbGVyXG4gICAgICAgIHdoaWxlIChjaGlsZCAhPT0gbnVsbCkge1xuICAgICAgICAgICAgaWYgKGNoaWxkICYmIGNoaWxkW1wiX2hhbmRsZUNsaWNrXCJdKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgeyBweCwgcHkgfSA9IGNoaWxkLmNvcmUuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgICAgICAgICBjb25zdCBjeCA9IHB4ICogcHJlY2lzaW9uO1xuICAgICAgICAgICAgICAgIGNvbnN0IGN5ID0gcHkgKiBwcmVjaXNpb247XG5cbiAgICAgICAgICAgICAgICBjb25zdCBsb2NhbENvb3JkcyA9IHtcbiAgICAgICAgICAgICAgICAgICAgeDogY2xpZW50WCAtIGN4LFxuICAgICAgICAgICAgICAgICAgICB5OiBjbGllbnRZIC0gY3lcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBjb25zdCByZXR1cm5WYWx1ZSA9IGNoaWxkLl9oYW5kbGVDbGljayh0YXJnZXQsIGxvY2FsQ29vcmRzKTtcbiAgICAgICAgICAgICAgICBpZiAocmV0dXJuVmFsdWUgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNoaWxkID0gY2hpbGQucGFyZW50O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3JlY2VpdmVIb3ZlcihlKSB7XG4gICAgICAgIGNvbnN0IG9iaiA9IGU7XG4gICAgICAgIGNvbnN0IHsgY2xpZW50WCwgY2xpZW50WSB9ID0gb2JqO1xuXG4gICAgICAgIGlmIChjbGllbnRYIDw9IHRoaXMuc3RhZ2UudyAmJiBjbGllbnRZIDw9IHRoaXMuc3RhZ2UuaCkge1xuICAgICAgICAgICAgdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5maXJlQ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AgICAgICAgICAgICAgYy5faGFuZGxlVW5ob3ZlcihlbGVtKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbS5wYXJlbnQgJiYgZWxlbS5wYXJlbnQuY3Vyc29yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLmdldENhbnZhcygpLnN0eWxlLmN1cnNvciA9IGVsZW0ucGFyZW50LmN1cnNvcjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fX2hvdmVyZWRDaGlsZCA9IHRhcmdldDtcblxuICAgICAgICAgICAgY29uc3QgZGlmZkJyYW5jaCA9IFsuLi5uZXdIb3ZlcmVkQnJhbmNoXS5maWx0ZXIoKGUpID0+ICFob3ZlcmVkQnJhbmNoLmhhcyhlKSlcbiAgICAgICAgICAgIGZvciAoY29uc3QgZWxlbSBvZiBkaWZmQnJhbmNoKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgYyA9IENvbXBvbmVudC5nZXRDb21wb25lbnQoZWxlbSk7XG4gICAgICAgICAgICAgICAgaWYgKGNbXCJfaGFuZGxlSG92ZXJcIl0pIHtcbiAgICAgICAgICAgICAgICAgICAgYy5faGFuZGxlSG92ZXIoZWxlbSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBOZXcgZWxlbWVudCBob3ZlciBjdXJzb3JcbiAgICAgICAgICAgIGNvbnN0IGxhc3RFbGVtZW50ID0gZGlmZkJyYW5jaFswXTtcbiAgICAgICAgICAgIGlmIChsYXN0RWxlbWVudCAmJiBsYXN0RWxlbWVudC5jdXJzb3IpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLmdldENhbnZhcygpLnN0eWxlLmN1cnNvciA9IGxhc3RFbGVtZW50LmN1cnNvcjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gUmVydW4gX2hhbmRsZUhvdmVyIGZvciB0YXJnZXQgZWxlbWVudCBpbiBjYXNlIGl0J3MgYmVlbiBob3ZlcmVkXG4gICAgICAgICAgICAvLyBiYWNrIGZyb20gaXRzIGNoaWxkXG4gICAgICAgICAgICBpZiAoZGlmZkJyYW5jaC5sZW5ndGggPT09IDAgJiYgdGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgY29uc3QgYyA9IENvbXBvbmVudC5nZXRDb21wb25lbnQodGFyZ2V0KTtcbiAgICAgICAgICAgICAgICBpZiAoY1tcIl9oYW5kbGVIb3ZlclwiXSkge1xuICAgICAgICAgICAgICAgICAgICBjLl9oYW5kbGVIb3Zlcih0YXJnZXQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRUYXJnZXRDaGlsZChjbGllbnRYLCBjbGllbnRZKSB7XG4gICAgICAgIGxldCBjaGlsZHJlbiA9IHRoaXMuc3RhZ2UuYXBwbGljYXRpb24uY2hpbGRyZW47XG4gICAgICAgIGxldCBhZmZlY3RlZCA9IHRoaXMuX2ZpbmRDaGlsZHJlbihbXSwgY2hpbGRyZW4pO1xuICAgICAgICBsZXQgaG92ZXJhYmxlQ2hpbGRyZW4gPSB0aGlzLl93aXRoaW5DbGlja2FibGVSYW5nZShhZmZlY3RlZCwgY2xpZW50WCwgY2xpZW50WSk7XG5cbiAgICAgICAgaG92ZXJhYmxlQ2hpbGRyZW4uc29ydCgoYSwgYikgPT4ge1xuICAgICAgICAgICAgLy8gU29ydCBieSB6SW5kZXggYW5kIHRoZW4gaWRcbiAgICAgICAgICAgIGlmIChhLnpJbmRleCA+IGIuekluZGV4KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGEuekluZGV4IDwgYi56SW5kZXgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gLTE7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBhLmlkID4gYi5pZCA/IDEgOiAtMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgaWYgKGhvdmVyYWJsZUNoaWxkcmVuLmxlbmd0aCkge1xuICAgICAgICAgICAgLy8gQXNzdW1lIHRhcmdldCBoYXMgaGlnaGVzdCB6SW5kZXggKGlkIHdoZW4gekluZGV4IGVxdWFsKVxuICAgICAgICAgICAgcmV0dXJuIGhvdmVyYWJsZUNoaWxkcmVuLnNsaWNlKC0xKVswXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2ZpbmRDaGlsZHJlbihidWNrZXQsIGNoaWxkcmVuKSB7XG4gICAgICAgIGxldCBuID0gY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICB3aGlsZSAobi0tKSB7XG4gICAgICAgICAgICBjb25zdCBjaGlsZCA9IGNoaWxkcmVuW25dO1xuICAgICAgICAgICAgLy8gb25seSBhZGQgYWN0aXZlIGNoaWxkcmVuXG4gICAgICAgICAgICBpZiAoY2hpbGQuX19hY3RpdmUgJiYgY2hpbGQuY29sbGlzaW9uKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkLmNvbGxpc2lvbiA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICBidWNrZXQucHVzaChjaGlsZCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChjaGlsZC5oYXNDaGlsZHJlbigpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbmRDaGlsZHJlbihidWNrZXQsIGNoaWxkLmNoaWxkcmVuKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGJ1Y2tldDtcbiAgICB9XG5cbiA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qgc2Npc3NvciA9IGNoaWxkLnBhcmVudC5jb3JlLl9zY2lzc29yLm1hcCgodikgPT4gdiAqIHByZWNpc2lvbik7XG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXN0Q29sbGlzaW9uKGN1cnNvclgsIGN1cnNvclksIC4uLnNjaXNzb3IpKVxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fdGVzdENvbGxpc2lvbihjdXJzb3JYLCBjdXJzb3JZLCBjeCwgY3ksIGN3LCBjaCkpIHtcbiAgICAgICAgICAgICAgICBjYW5kaWRhdGVzLnB1c2goY2hpbGQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjYW5kaWRhdGVzO1xuICAgIH1cblxuICAgIF90ZXN0Q29sbGlzaW9uKHB4LCBweSwgY3gsIGN5LCBjdywgY2gpIHtcbiAgICAgICAgaWYgKHB4ID49IGN4ICYmXG4gICAgICAgICAgICBweCA8PSBjeCArIGN3ICYmXG4gICAgICAgICAgICBweSA+PSBjeSAmJlxuICAgICAgICAgICAgcHkgPD0gY3kgKyBjaCkge1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIGRlc3Ryb3koKSB7XG4gICAgICAgIGlmICghdGhpcy5fZGVzdHJveWVkKSB7XG4gICAgICAgICAgICB0aGlzLl9kZXN0cm95KCk7XG4gICAgICAgICAgICB0aGlzLnN0YWdlLmRlc3Ryb3koKTtcbiAgICAgICAgICAgIHRoaXMuX2Rlc3Ryb3llZCA9IHRydWU7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZGVzdHJveSgpIHtcbiAgICAgICAgLy8gVGhpcyBmb3JjZXMgdGhlIF9kZXRhY2gsIF9kaXNhYmxlZCBhbmQgX2FjdGl2ZSBldmVudHMgdG8gYmUgY2F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cE5hbWUgPSBwcm9wRGVwZW5kZW5jaWVzW2ldO1xuICAgICAgICAgICAgY29uc3QgZnVuYyA9IHByb3BPYmouX19mdW5jID8gcHJvcE9iai5fX2Z1bmMgOiAoY29udGV4dCkgPT4gY29udGV4dFtwcm9wTmFtZV07XG5cbiAgICAgICAgICAgIGlmICghdGhpcy5oYXNPd25Qcm9wZXJ0eShwcm9wTmFtZSkpIHtcbiAgICAgICAgICAgICAgICB0aGlzW2BfX3Byb3BfYmluZGluZ3NfJHtwcm9wTmFtZX1gXSA9IFt7X19vYmo6IG9iaiwgX19wcm9wOiBwcm9wLCBfX2Z1bmM6IGZ1bmN9XTtcbiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgcHJvcE5hbWUsIHtcbiAgICAgICAgICAgICAgICAgICAgc2V0OiAodmFsdWUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbYF9fcHJvcF8ke3Byb3BOYW1lfWBdID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHtfX29iaiwgX19wcm9wLCBfX2Z1bmN9IG9mIHRoaXNbYF9fcHJvcF9iaW5kaW5nc18ke3Byb3BOYW1lfWBdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgX19vYmpbX19wcm9wXSA9IF9fZnVuYyh0aGlzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgZ2V0OiAoKSA9PiB0aGlzW2BfX3Byb3BfJHtwcm9wTmFtZX1gXVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzW2BfX3Byb3BfYmluZGluZ3NfJHtwcm9wTmFtZX1gXS5wdXNoKHtfX29iajogb2JqLCBfX3Byb3A6IHByb3AsIF9fZnVuYzogZnVuY30pO1xuICAgICAg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lXCIsIGNvZGUpO1xuICAgICAgICByZXR1cm4ge2Y6IGYsIGE6IGNvbnRleHQuc3RvcmV9O1xuICAgIH1cblxuICAgIHN0YXRpYyBwYXJzZVRlbXBsYXRlUmVjKG9iaiwgY29udGV4dCwgY3Vyc29yKSB7XG4gICAgICAgIGNvbnN0IHN0b3JlID0gY29udGV4dC5zdG9yZTtcbiAgICAgICAgY29uc3QgbG9jID0gY29udGV4dC5sb2M7XG4gICAgICAgIGNvbnN0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICBrZXlzLmZvckVhY2goa2V5ID0+IHtcbiAgICAgICAgICAgIGxldCB2YWx1ZSA9IG9ialtrZXldO1xuICAgICAgICAgICAgaWYgKFV0aWxzLmlzVWNDaGFyKGtleS5jaGFyQ29kZUF0KDApKSkge1xuICAgICAgICAgICAgICAgIC8vIFZhbHVlIG11c3QgYmUgZXhwYW5kZWQgYXMgd2VsbC5cbiAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBSZWYuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkQ3Vyc29yID0gYHIke2tleS5yZXBsYWNlKC9bXmEtejAtOV0vZ2ksIFwiXCIpICsgY29udGV4dC5yaWR9YDtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHR5cGUgPSB2YWx1ZS50eXBlID8gdmFsdWUudHlwZSA6IEVsZW1lbnQ7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlID09PSBFbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgdmFyICR7Y2hpbGRDdXJzb3J9ID0gZWxlbWVudC5zdGFnZS5jcmVhdGVFbGVtZW50KClgKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godHlwZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgdmFyICR7Y2hpbGRDdXJzb3J9ID0gbmV3IHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dKCR7Y3Vyc29yfS5zdGFnZSlgKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjaGlsZEN1cnNvcn0ucmVmID0gXCIke2tleX1cImApO1xuICAgICAgICAgICAgICAgICAgICBjb250ZXh0LnJpZCsrO1xuXG4gICAgICAgICAgICAgICAgICAgIC8vIEVudGVyIHN1Yi5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJzZVRlbXBsYXRlUmVjKHZhbHVlLCBjb250ZXh0LCBjaGlsZEN1cnNvcik7XG5cbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfS5jaGlsZExpc3QuYWRkKCR7Y2hpbGRDdXJzb3J9KWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3QodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIER5bmFtaWMgYXNzaWdubWVudC5cbiAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn0uY2hpbGRMaXN0LmFkZChzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSlgKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChrZXkgPT09IFwidGV4dFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb3BLZXkgPSBjdXJzb3IgKyBcIl9fdGV4dFwiO1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgdmFyICR7cHJvcEtleX0gPSAke2N1cnNvcn0uZW5hYmxlVGV4dFRleHR1cmUoKWApO1xuICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUuX19wcm9wZXJ0eUJpbmRpbmcgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEFsbG93IGJpbmRpbmcgZW50aXJlIG9iamVjdHMgdG8gdGV4dCBwcm9wZXJ0eVxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgZWxlbWVudC5fX2JpbmRQcm9wZXJ0eShzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSwgJHtjdXJzb3J9LCBcIiR7a2V5fVwiKWApO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJzZVRlbXBsYXRlUHJvcFJlYyh2YWx1ZSwgY29udGV4dCwgcHJvcEtleSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGtleSA9PT0gXCJzaGFkZXJcIiAmJiBVdGlscy5pc09iamVjdExpdGVyYWwodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoYWRlckN1cnNvciA9IGAke2N1cnNvcn1bXCJzaGFkZXJcIl1gXG4gICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV1gKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJzZVByb3BlcnR5QmluZGluZ3ModmFsdWUsIGNvbnRleHQsIHNoYWRlckN1cnNvcik7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChrZXkgPT09IFwidGV4dHVyZVwiICYmIFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvcEtleSA9IGN1cnNvciArIFwiX190ZXh0dXJlXCI7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSB2YWx1ZS50eXBlO1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh0eXBlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGB2YXIgJHtwcm9wS2V5fSA9IG5ldyBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSgke2N1cnNvcn0uc3RhZ2UpYCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcnNlVGVtcGxhdGVQcm9wUmVjKHZhbHVlLCBjb250ZXh0LCBwcm9wS2V5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSAke3Byb3BLZXl9YCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtwcm9wS2V5fSA9ICR7Y3Vyc29yfS50ZXh0dXJlYCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcnNlVGVtcGxhdGVQcm9wUmVjKHZhbHVlLCBjb250ZXh0LCBwcm9wS2V5KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHZhbHVlKSAmJiB2YWx1ZS5fX3Byb3BlcnR5QmluZGluZyA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYGVsZW1lbnQuX19iaW5kUHJvcGVydHkoc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0sICR7Y3Vyc29yfSwgXCIke2tleX1cIilgKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBQcm9wZXJ0eTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzTnVtYmVyKHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9ICR7dmFsdWV9YCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNCb29sZWFuKHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9ICR7dmFsdWUgPyBcInRydWVcIiA6IFwiZmFsc2VcIn1gKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdCh2YWx1ZSkgfHwgQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIER5bmFtaWMgYXNzaWdubWVudC5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEJlY2F1c2UgbGl0ZXJhbCBvYmplY3RzIG1heSBjb250YWluIGR5bmFtaWNzLCB3ZSBzdG9yZSB0aGUgZnVsbCBvYmplY3QuXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XWApO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gU3RyaW5nIGV0Yy5cbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSAke0pTT04uc3RyaW5naWZ5KHZhbHVlKX1gKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgc3RhdGljIHBhcnNlVGVtcGxhdGVQcm9wUmVjKG9iaiwgY29udGV4dCwgY3Vyc29yKSB7XG4gICAgICAgIGNvbnN0IHN0b3JlID0gY29udGV4dC5zdG9yZTtcbiAgICAgICAgY29uc3QgbG9jID0gY29udGV4dC5sb2M7XG4gICAgICAgIGNvbnN0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICBrZXlzLmZvckVhY2goa2V5ID0+IHtcbiAgICAgICAgICAgIGlmIChrZXkgIT09IFwidHlwZVwiKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBvYmpba2V5XTtcbiAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNOdW1iZXIodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSAke3ZhbHVlfWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNCb29sZWFuKHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHt2YWx1ZSA/IFwidHJ1ZVwiIDogXCJmYWxzZVwifWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3QodmFsdWUpICYmIHZhbHVlLl9fcHJvcGVydHlCaW5kaW5nID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgZWxlbWVudC5fX2JpbmRQcm9wZXJ0eShzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSwgJHtjdXJzb3J9LCBcIiR7a2V5fVwiKWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3QodmFsdWUpIHx8IEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIER5bmFtaWMgYXNzaWdubWVudC5cbiAgICAgICAgICAgICAgICAgICAgLy8gQmVjYXVzZSBsaXRlcmFsIG9iamVjdHMgbWF5IGNvbnRhaW4gZHluYW1pY3MsIHdlIHN0b3JlIHRoZSBmdWxsIG9iamVjdC5cbiAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFN0cmluZyBldGMuXG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSAke0pTT04uc3RyaW5naWZ5KHZhbHVlKX1gKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHN0YXRpYyBwYXJzZVByb3BlcnR5QmluZGluZ3Mob2JqLCBjb250ZXh0LCBjdXJzb3IpIHtcbiAgICAgICAgY29uc3Qgc3RvcmUgPSBjb250ZXh0LnN0b3JlO1xuICAgICAgICBjb25zdCBsb2MgPSBjb250ZXh0LmxvYztcbiAgICAgICAgY29uc3Qga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgIGtleXMuZm9yRWFjaChrZXkgPT4ge1xuICAgICAgICAgICAgaWYgKGtleSAhPT0gXCJ0eXBlXCIpIHtcbiAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IG9ialtrZXldO1xuICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodmFsdWUpICYmIHZhbHVlLl9fcHJvcGVydHlCaW5kaW5nID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgZWxlbWVudC5fX2JpbmRQcm9wZXJ0eShzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSwgJHtjdXJzb3J9LCBcIiR7a2V5fVwiKWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgX29uU2V0dXAoKSB7XG4gICAgICAgIGlmICghdGhpcy5fX2luaXRpYWxpemVkKSB7XG4gICAgICAgICAgICB0aGlzLl9zZXR1cCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3NldHVwKCkge1xuICAgIH1cblxuICAgIF9vbkF0dGFjaCgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9faW5pdGlhbGl6ZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX19pbml0KCk7XG4gICAgICAgICAgICB0aGlzLl9faW5pdGlhbGl6ZWQgPSB0cnVlO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fYXR0YWNoKCk7XG4gICAgfVxuXG4gICAgX2F0dGFjaCgpIHtcbiAgICB9XG5cbiAgICBfb25EZXRhY2goKSB7XG4gICAgICAgIHRoaXMuX2RldGFjaCgpO1xuICAgIH1cblxuICAgIF9kZXRhY2goKSB7XG4gICAgfVxuXG4gICAgX29uRW5hYmxlZCgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9fZmlyc3RFbmFibGUpIHtcbiAgICAgICAgICAgIHRoaXMuX2ZpcnN0RW5hYmxlKCk7XG4gICAgICAgICAgICB0aGlzLl9fZmlyc3RFbmFibGUgPSB0cnVlO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fZW5hYmxlKCk7XG4gICAgfVxuXG4gICAgX2ZpcnN0RW5hYmxlKCkge1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tcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX19zaWduYWxzKSB7XG4gICAgICAgICAgICB0aGlzLl9fc2lnbmFscyA9IHt9O1xuICAgICAgICB9XG4gICAgICAgIGZvciAobGV0IGtleSBpbiB2KSB7XG4gICAgICAgICAgICBjb25zdCBkID0gdltrZXldO1xuICAgICAgICAgICAgaWYgKGQgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLl9fc2lnbmFsc1trZXldO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9fc2lnbmFsc1trZXldID0gdjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBwYXNzU2lnbmFscygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19wYXNzU2lnbmFscyB8fCB7fTtcbiAgICB9XG5cbiAgICBzZXQgcGFzc1NpZ25hbHModikge1xuICAgICAgICB0aGlzLl9fcGFzc1NpZ25hbHMgPSBPYmplY3QuYXNzaWduKHRoaXMuX19wYXNzU2lnbmFscyB8fCB7fSwgdik7XG4gICAgfVxuXG4gICAgc2V0IGFsdGVyUGFzc1NpZ25hbHModikge1xuICAgICAgICBpZiAoIVV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlNpZ25hbHM6IHNwZWNpZnkgYW4gb2JqZWN0IHdpdGggc2lnbmFsLXRvLWZpcmUgbWFwcGluZ3NcIik7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLl9fcGFzc1NpZ25hbHMpIHtcbiAgICAgICAgICAgIHRoaXMuX19wYXNzU2lnbmFscyA9IHt9O1xuICAgICAgICB9XG4gICAgICAgIGZvciAobGV0IGtleSBpbiB2KSB7XG4gICAgICAgICAgICBjb25zdCBkID0gdltrZXldO1xuICAgICAgICAgICAgaWYgKGQgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLl9fcGFzc1NpZ25hbHNba2V5XTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX3Bhc3NTaWduYWxzW2tleV0gPSB2O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogU2lnbmFscyB0aGUgcGFyZW50IG9mIHRoZSBzcGVjaWZpZWQgZXZlbnQuXG4gICAgICogQSBwYXJlbnQvYW5jZXN0b3IgdGhhdCB3aXNoZXMgdG8gaGFuZGxlIHRoZSBzaWduYWwgc2hvdWxkIHNldCB0aGUgJ3NpZ25hbHMnIHByb3BlcnR5IG9uIHRoaXMgY29tcG9uZW50LlxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSBldmVudFxuICAgICAqIEBwYXJhbSB7Li4uKn0gYXJnc1xuICAgICAqL1xuICAgIHNpZ25hbChldmVudCwgLi4uYXJncykge1xuICAgICAgICByZXR1cm4gdGhpcy5fc2lnbmFsKGV2ZW50LCBhcmdzKTtcbiAgICB9XG5cbiAgICBfc2lnbmFsKGV2ZW50LCBhcmdzKSB7XG4gICAgICAgIGNvbnN0IHNpZ25hbFBhcmVudCA9IHRoaXMuX2dldFBhcmVudFNpZ25hbEhhbmRsZXIoKTtcbiAgICAgICAgaWYgKHNpZ25hbFBhcmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX19zaWduYWxzKSB7XG4gICAgICAgICAgICAgICAgbGV0IGZpcmVFdmVudCA9IHRoaXMuX19zaWduYWxzW2V2ZW50XTtcbiAgICAgICAgICAgICAgICBpZiAoZmlyZUV2ZW50ID09PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBJZ25vcmUgZXZlbnQuXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGZpcmVFdmVudCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZmlyZUV2ZW50ID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaXJlRXZlbnQgPSBldmVudDtcbiAgICAgICAgICAgICAgICAgICAgfVxuIFxuICAgICAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNGdW5jdGlvbihmaXJlRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmlyZUV2ZW50KC4uLmFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHNpZ25hbFBhcmVudC5faGFzTWV0aG9kKGZpcmVFdmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzaWduYWxQYXJlbnRbZmlyZUV2ZW50XSguLi5hcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHBhc3NTaWduYWwgPSAodGhpcy5fX3Bhc3NTaWduYWxzICYmIHRoaXMuX19wYXNzU2lnbmFsc1tldmVudF0pO1xuICAgICAgICAgICAgaWYgKHBhc3NTaWduYWwpIHtcbiAgICAgICAgICAgICAgICAvLyBCdWJibGUgdXAuXG4gICAgICAgICAgICAgICAgaWYgKHBhc3NTaWduYWwgJiYgcGFzc1NpZ25hbCAhPT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBSZXBsYWNlIHNpZ25hbCBuYW1lLlxuICAgICAgICAgICAgICAgICAgICBldmVudCA9IHBhc3NTaWduYWw7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHNpZ25hbFBhcmVudC5fc2lnbmFsKGV2ZW50LCBhcmdzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRQYXJlbnRTaWduYWxIYW5kbGVyKCkge1xuIC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Z25hbEhhbmRsZXIoKTtcbiAgICAgICAgICAgIGlmIChzaWduYWxQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gc2lnbmFsUGFyZW50Ll9kb0ZpcmVBbmNlc3RvcnMobmFtZSwgYXJncyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgY29sbGVjdFN1YkNvbXBvbmVudHMoc3VicywgZWxlbWVudCkge1xuICAgICAgICBpZiAoZWxlbWVudC5oYXNDaGlsZHJlbigpKSB7XG4gICAgICAgICAgICBjb25zdCBjaGlsZExpc3QgPSBlbGVtZW50Ll9fY2hpbGRMaXN0O1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBjaGlsZExpc3QubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgY2hpbGQgPSBjaGlsZExpc3QuZ2V0QXQoaSk7XG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkLmlzQ29tcG9uZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnMucHVzaChjaGlsZCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgQ29tcG9uZW50LmNvbGxlY3RTdWJDb21wb25lbnRzKHN1YnMsIGNoaWxkKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0Q29tcG9uZW50KGVsZW1lbnQpIHtcbiAgICAgICAgbGV0IHBhcmVudCA9IGVsZW1lbnQ7XG4gICAgICAgIHdoaWxlIChwYXJlbnQgJiYgIXBhcmVudC5pc0NvbXBvbmVudCkge1xuICAgICAgICAgICAgcGFyZW50ID0gcGFyZW50LnBhcmVudDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcGFyZW50O1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXRQYXJlbnQoZWx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hhcmVkU3RhdGU6IHNoYXJlZFN0YXRlLl9fcGF0aFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgY29uc3Qgc2hhcmVkTGV2ZWwgPSBzaGFyZWRTdGF0ZS5fX2xldmVsO1xuXG4gICAgICAgICAgICAgICAgaWYgKGhhc0RpZmZlcmVudEV4aXRNZXRob2QpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZXhpdFN0YXRlcyA9IFN0YXRlTWFjaGluZS5fZ2V0U3RhdGVzVW50aWxMZXZlbCh0aGlzLl9zdGF0ZSwgc2hhcmVkTGV2ZWwpO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGV4aXRTdGF0ZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fc2V0U3RhdGUoZXhpdFN0YXRlc1tpXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWxsRXhpdCh0aGlzLl9zdGF0ZSwgYXJncywgY29udGV4dCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGF0ZUNoYW5nZU92ZXJyaWRkZW4gPSAodGhpcy5fc2V0U3RhdGVJZCAhPT0gc2V0U3RhdGVJZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVDaGFuZ2VPdmVycmlkZGVuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGhhc0RpZmZlcmVudEVudGVyTWV0aG9kKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGVudGVyU3RhdGVzID0gU3RhdGVNYWNoaW5lLl9nZXRTdGF0ZXNVbnRpbExldmVsKG5ld1N0YXRlLCBzaGFyZWRMZXZlbCkucmV2ZXJzZSgpO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGVudGVyU3RhdGVzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3NldFN0YXRlKGVudGVyU3RhdGVzW2ldKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbGxFbnRlcih0aGlzLl9zdGF0ZSwgYXJncywgY29udGV4dCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGF0ZUNoYW5nZU92ZXJyaWRkZW4gPSAodGhpcy5fc2V0U3RhdGVJZCAhPT0gc2V0U3RhdGVJZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdGVDaGFuZ2VPdmVycmlkZGVuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX19zZXRTdGF0ZShuZXdTdGF0ZSk7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9jaGFuZ2VkU3RhdGUpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBjb250ZXh0ID0ge1xuICAgICAgICAgICAgICAgICAgICBuZXdTdGF0ZTogbmV3U3RhdGUuX19wYXRoLFxuICAgICAgICAgICAgICAgICAgICBwcmV2U3RhdGU6IHByZXZTdGF0ZS5fX3BhdGhcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgaWYgKGFyZ3MpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hhbmdlZFN0YXRlKGNvbnRleHQsIC4uLmFyZ3MpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoYW5nZWRTdGF0ZShjb250ZXh0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9vblN0YXRlQ2hhbmdlKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgY29udGV4dCA9IHtcbiAgICAgICAgICAgICAgICAgICAgbmV3U3RhdGU6IG5ld1N0YXRlLl9fcGF0aCxcbiAgICAgICAgICAgICAgICAgICAgcHJldlN0YXRlOiBwcmV2U3RhdGUuX19wYXRoXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB0aGlzLl9vblN0YXRlQ2hhbmdlKGNvbnRleHQpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfY2FsbEVudGVyKHN0YXRlLCBhcmdzID0gW10sIGNvbnRleHQpIHtcbiAgICAgICAgY29uc3QgaGFzUGFyZW50ID0gISFzdGF0ZS5fX3BhcmVudDtcbiAgICAgICAgaWYgKHN0YXRlLnByb3RvdHlwZS4kZW50ZXIpIHtcbiAgICAgICAgICAgIGlmICghaGFzUGFyZW50IHx8IChzdGF0ZS5fX3BhcmVudC5wcm90b3R5cGUuJGVudGVyICE9PSBzdGF0ZS5wcm90b3R5cGUuJGVudGVyKSkge1xuICAgICAgICAgICAgICAgIHN0YXRlLnByb3RvdHlwZS4kZW50ZXIuYXBwbHkodGhpcywgW2NvbnRleHQsIC4uLmFyZ3NdKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9jYWxsRXhpdChzdGF0ZSwgYXJncyA9IFtdLCBjb250ZXh0KSB7XG4gICAgICAgIGNvbnN0IGhhc1BhcmVudCA9ICEhc3RhdGUuX19wYXJlbnQ7XG4gICAgICAgIGlmIChzdGF0ZS5wcm90b3R5cGUuJGV4aXQpIHtcbiAgICAgICAgICAgIGlmICghaGFzUGFyZW50IHx8IChzdGF0ZS5fX3BhcmVudC5wcm90b3R5cGUuJGV4aXQgIT09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Ugc3BlY2lmaWVkIGluIHRoZSBzYW1lIGRlZXBlc3Qgc3RhdGUsIHRoZSBmaXJzdCBvbmUgaW4gdGhlIGFycmF5IGlzIHJldHVybmVkLlxuICAgICAqIEBwYXJhbSB7c3RyaW5nW119IG1lbWJlck5hbWVzXG4gICAgICogQHJldHVybnMge3N0cmluZ3x1bmRlZmluZWR9XG4gICAgICogQHByb3RlY3RlZFxuICAgICAqL1xuICAgIF9nZXRNb3N0U3BlY2lmaWNIYW5kbGVkTWVtYmVyKG1lbWJlck5hbWVzKSB7XG4gICAgICAgIGxldCBjdXIgPSB0aGlzLl9zdGF0ZTtcbiAgICAgICAgZG8ge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBtZW1iZXJOYW1lcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjb25zdCBtZW1iZXJOYW1lID0gbWVtYmVyTmFtZXNbaV07XG4gICAgICAgICAgICAgICAgaWYgKCFjdXIuX19wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGN1ci5wcm90b3R5cGVbbWVtYmVyTmFtZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZW1iZXJOYW1lO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYWxpYXMgPSBTdGF0ZU1hY2hpbmVUeXBlLmdldFN0YXRlTWVtYmVyQWxpYXMoY3VyLl9fcGF0aCwgbWVtYmVyTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzW2FsaWFzXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1lbWJlck5hbWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdXIgPSBjdXIuX19wYXJlbnQ7XG4gICAgIC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ihzdGF0ZSwgbWVtYmVyKTtcbiAgICAgICAgICAgIGlmIChkZXNjcmlwdG9yKSB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRvcnNbaW5kZXhdID0gZGVzY3JpcHRvcjtcblxuICAgICAgICAgICAgICAgIC8vIEFkZCB0byBwcm90b3R5cGUuXG4gICAgICAgICAgICAgICAgY29uc3QgYWxpYXMgPSBTdGF0ZU1hY2hpbmVUeXBlLmdldFN0YXRlTWVtYmVyQWxpYXMoZGVzY3JpcHRvci5fc291cmNlLl9fcGF0aCwgbWVtYmVyKTtcbiAgICAgICAgICAgICAgICBhbGlhc2VzW2luZGV4XSA9IGFsaWFzO1xuXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yb3V0ZXIucHJvdG90eXBlLmhhc093blByb3BlcnR5KGFsaWFzKSkge1xuICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcy5fcm91dGVyLnByb3RvdHlwZSwgYWxpYXMsIGRlc2NyaXB0b3IpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRvcnNbaW5kZXhdID0gbnVsbDtcbiAgICAgICAgICAgICAgICBhbGlhc2VzW2luZGV4XSA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGxldCB0eXBlID0gdW5kZWZpbmVkO1xuICAgICAgICBkZXNjcmlwdG9ycy5mb3JFYWNoKGRlc2NyaXB0b3IgPT4ge1xuICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBkZXNjVHlwZSA9IHRoaXMuX2dldERlc2NyaXB0b3JUeXBlKGRlc2NyaXB0b3IpO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlICYmICh0eXBlICE9PSBkZXNjVHlwZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKGBbTGlnaHRuaW5nXSBNZW1iZXIgJHttZW1iZXJ9IGluICR7dGhpcy5fdHlwZS5uYW1lfSBoYXMgaW5jb25zaXN0ZW50IHR5cGVzLmApO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHR5cGUgPSBkZXNjVHlwZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgc3dpdGNoKHR5cGUpIHtcbiAgICAgICAgICAgIGNhc2UgXCJtZXRob2RcIjpcbiAgICAgICAgICAgICAgICB0aGlzLl9hZGRNZXRob2RSb3V0ZXIobWVtYmVyLCBkZXNjcmlwdG9ycywgYWxpYXNlcyk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwiZ2V0dGVyXCI6XG4gICAgICAgICAgICAgICAgdGhpcy5fYWRkR2V0dGVyU2V0dGVyUm91dGVycyhtZW1iZXIpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcInByb3BlcnR5XCI6XG4gICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gRml4ZWQgcHJvcGVydGllcyBhcmUgbm90IHN1cHBvcnRlZDsgcGxlYXNlIHVzZSBhIGdldHRlciBpbnN0ZWFkIVwiKVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldERlc2NyaXB0b3Ioc3RhdGUsIG1lbWJlciwgaXNWYWxpZCA9ICgpID0+IHRydWUpIHtcbiAgICAgICAgbGV0IHR5cGUgPSBzdGF0ZTtcbiAgICAgICAgbGV0IGN1clN0YXRlID0gc3RhdGU7XG5cbiAgICAgICAgZG8ge1xuICAgICAgICAgICAgY29uc3QgZGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodHlwZS5wcm90b3R5cGUsIG1lbWJlcik7XG4gICAgICAgICAgICBpZiAoZGVzY3JpcHRvcikge1xuICAgICAgICAgICAgICAgIGlmIChpc1ZhbGlkKGRlc2NyaXB0b3IpKSB7XG4gICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0b3IuX3NvdXJjZSA9IGN1clN0YXRlO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVzY3JpcHRvcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0eXBlID0gT2JqZWN0LmdldFByb3RvdHlwZU9mKHR5cGUpO1xuICAgICAgICAgICAgaWYgKHR5cGUgJiYgdHlwZS5oYXNPd25Qcm9wZXJ0eSgnX19zdGF0ZScpKSB7XG4gICAgICAgICAgICAgICAgY3VyU3RhdGUgPSB0eXBlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IHdoaWxlKHR5cGUgJiYgdHlwZS5wcm90b3R5cGUpO1xuICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgIH1cblxuICAgIF9nZXREZXNjcmlwdG9yVHlwZShkZXNjcmlwdG9yKSB7XG4gICAgICAgIGlmIChkZXNjcmlwdG9yLmdldCB8fCBkZXNjcmlwdG9yLnNldCkge1xuICAgICAgICAgICAgcmV0dXJuICdnZXR0ZXInO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBkZXNjcmlwdG9yLnZhbHVlID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ21ldGhvZCc7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiAncHJvcGVydHknO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIF9zdXBwb3J0c1NwcmVhZCgpIHtcbiAgICAgICAgaWYgKHRoaXMuX19zdXBwb3J0c1NwcmVhZCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgIC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AgICAgICBpZiAoc3VwcG9ydHNTcHJlYWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSByZXR1cm4gdGhpc1tcIiR7Y3VyfVwiXSguLi5hcmd1bWVudHMpOyBlbHNlYCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl0uYXBwbHkodGhpcywgYXJndW1lbnRzKTsgZWxzZWApO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIHJldHVybiA7IGVsc2VgKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdXIgPSBhbGlhcztcbiAgICAgICAgfVxuICAgICAgICBpZiAoY3VyKSB7XG4gICAgICAgICAgICBpZiAoc3VwcG9ydHNTcHJlYWQpIHtcbiAgICAgICAgICAgICAgICBjb2RlLnB1c2goYHJldHVybiB0aGlzW1wiJHtjdXJ9XCJdKC4uLmFyZ3VtZW50cyk7YCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvZGUucHVzaChgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl0uYXBwbHkodGhpcywgYXJndW1lbnRzKTtgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvZGUucHVzaChgO2ApO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGZ1bmN0aW9uQm9keSA9IGNvZGUuam9pbihcIlxcblwiKTtcbiAgICAgICAgY29uc3Qgcm91dGVyID0gbmV3IEZ1bmN0aW9uKFtdLCBmdW5jdGlvbkJvZHkpO1xuXG4gICAgICAgIG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gMSwgbiA9IGFsaWFzZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBhbGlhcyA9IGFsaWFzZXNbaV07XG4gICAgICAgICAgICBpZiAoYWxpYXMgIT09IGN1cikge1xuICAgICAgICAgICAgICAgIGlmIChjdXIpIHtcbiAgICAgICAgICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIHJldHVybiB0aGlzW1wiJHtjdXJ9XCJdOyBlbHNlYCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIHJldHVybiA7IGVsc2VgKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdXIgPSBhbGlhcztcbiAgICAgICAgfVxuICAgICAgICBpZiAoY3VyKSB7XG4gICAgICAgICAgICBjb2RlLnB1c2goYHJldHVybiB0aGlzW1wiJHtjdXJ9XCJdO2ApO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29kZS5wdXNoKGA7YCk7XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgZnVuY3Rpb25Cb2R5ID0gY29kZS5qb2luKFwiXFxuXCIpO1xuICAgICAgICBjb25zdCByb3V0ZXIgPSBuZXcgRnVuY3Rpb24oW10sIGZ1bmN0aW9uQm9keSk7XG4gICAgICAgIHJldHVybiByb3V0ZXI7XG4gICAgfVxuXG4gICAgX2dldFNldHRlclJvdXRlcihtZW1iZXIpIHtcbiAgICAgICAgY29uc3Qgc3RhdGVQYXRocyA9IE9iamVjdC5rZXlzKHRoaXMuX3N0YXRlTWFwKTtcbiAgICAgICAgY29uc3QgZGVzY3JpcHRvcnMgPSBbXTtcbiAgICAgICAgY29uc3QgYWxpYXNlcyA9IFtdO1xuICAgICAgICBzdGF0ZVBhdGhzLmZvckVhY2goKHN0YXRlUGF0aCwgaW5kZXgpID0+IHtcbiAgICAgICAgICAgIGNvbnN0IHN0YXRlID0gdGhpcy5fc3RhdGVNYXBbc3RhdGVQYXRoXTtcbiAgICAgICAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSB0aGlzLl9nZXREZXNjcmlwdG9yKHN0YXRlLCBtZW1iZXIsIChkZXNjcmlwdG9yID0+IGRlc2NyaXB0b3Iuc2V0KSk7XG4gICAgICAgICAgICBpZiAoZGVzY3JpcHRvcikge1xuICAgICAgICAgICAgICAgIGRlc2NyaXB0b3JzW2luZGV4XSA9IGRlc2NyaXB0b3I7XG5cbiAgICAgICAgICAgICAgICAvLyBBZGQgdG8gcHJvdG90eXBlLlxuICAgICAgICAgICAgICAgIGNvbnN0IGFsaWFzID0gU3RhdGVNYWNoaW5lVHlwZS5nZXRTdGF0ZU1lbWJlckFsaWFzKGRlc2NyaXB0b3IuX3NvdXJjZS5fX3BhdGgsIG1lbWJlcik7XG4gICAgICAgICAgICAgICAgYWxpYXNlc1tpbmRleF0gPSBhbGlhcztcblxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fcm91dGVyLnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eShhbGlhcykpIHtcbiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMuX3JvdXRlci5wcm90b3R5cGUsIGFsaWFzLCBkZXNjcmlwdG9yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGRlc2NyaXB0b3JzW2luZGV4XSA9IG51bGw7XG4gICAgICAgICAgICAgICAgYWxpYXNlc1tpbmRleF0gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBjb25zdCBjb2RlID0gW1xuICAgICAgICAgICAgLy8gVGhlIGxpbmUgZW5zdXJlcyB0aGF0LCB3aGlsZSBkZWJ1Z2dpbmcsIHlvdXIgSURFIHdvbid0IG9wZW4gbWFueSB0YWJzLlxuICAgICAgICAgICAgXCIvL0Agc291cmNlVVJMPVN0YXRlTWFjaGluZVJvdXRlci5qc1wiLFxuICAgICAgICAgICAgXCJ2YXIgaSA9IHRoaXMuX3N0YXRlSW5kZXg7XCJcbiAgICAgICAgXTtcbiAgICAgICAgbGV0IGN1ciA9IGFsaWFzZXNbMF07XG4gICAgICAgIGZvciAobGV0IGkgPSAxLCBuID0gYWxpYXNlcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGFsaWFzID0gYWxpYXNlc1tpXTtcbiAgICAgICAgICAgIGlmIChhbGlhcyAhPT0gY3VyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGN1cikge1xuICAgICAgICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgdGhpc1tcIiR7Y3VyfVwiXSA9IGFyZzsgZWxzZWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSA7IGVsc2VgKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdXIgPSBhbGlhcztcbiAgICAgICAgfVxuICAgICAgICBpZiAoY3VyKSB7XG4gICAgICAgICAgICBjb2RlLnB1c2goYHRoaXNbXCIke2N1cn1cIl0gPSBhcmc7YCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb2RlLnB1c2goYDtgKTtcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBmdW5jdGlvbkJvZHkgPSBjb2RlLmpvaW4oXCJcXG5cIik7XG4gICAgICAgIGNvbnN0IHJvdXRlciA9IG5ldyBGdW5jdGlvbihbXCJhcmdcIl0sIGZ1bmN0aW9uQm9keSk7XG4gICAgICAgIHJldHVybiByb3V0ZXI7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFN0YXRlTWVtYmVyQWxpYXMocGF0aCwgbWVtYmVyKSB7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BcIi4uL3JlbmRlcmVyL3dlYmdsL3NoYWRlcnMvQm94Qmx1clNoYWRlci5tanNcIjtcbmltcG9ydCBEZWZhdWx0U2hhZGVyIGZyb20gXCIuLi9yZW5kZXJlci93ZWJnbC9zaGFkZXJzL0RlZmF1bHRTaGFkZXIubWpzXCI7XG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIEJsb29tQ29tcG9uZW50IGV4dGVuZHMgQ29tcG9uZW50IHtcblxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIGNvbnN0IG9uVXBkYXRlID0gZnVuY3Rpb24oZWxlbWVudCwgZWxlbWVudENvcmUpIHtcbiAgICAgICAgICAgIGlmICgoZWxlbWVudENvcmUuX3JlY2FsYyAmICgyICsgMTI4KSkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCB3ID0gZWxlbWVudENvcmUudztcbiAgICAgICAgICAgICAgICBjb25zdCBoID0gZWxlbWVudENvcmUuaDtcbiAgICAgICAgICAgICAgICBsZXQgY3VyID0gZWxlbWVudENvcmU7XG4gICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBjdXIgPSBjdXIuX2NoaWxkcmVuWzBdO1xuICAgICAgICAgICAgICAgICAgICBjdXIuX2VsZW1lbnQudyA9IHc7XG4gICAgICAgICAgICAgICAgICAgIGN1ci5fZWxlbWVudC5oID0gaDtcbiAgICAgICAgICAgICAgICB9IHdoaWxlKGN1ci5fY2hpbGRyZW4pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBUZXh0d3JhcDoge3J0dDogdHJ1ZSwgZm9yY2VaSW5kZXhDb250ZXh0OiB0cnVlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsXG4gICAgICAgICAgICAgICAgQmxvb21CYXNlOiB7c2hhZGVyOiB7dHlwZTogQmxvb21CYXNlU2hhZGVyfSxcbiAgICAgICAgICAgICAgICAgICAgQ29udG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AgIC8qKlxuICAgICAqIFNldHMgdGhlIGFtb3VudCBvZiBibHVyLiBBIHZhbHVlIGJldHdlZW4gMCBhbmQgNC4gR29lcyB1cCBleHBvbmVudGlhbGx5IGZvciBibHVyLlxuICAgICAqIEJlc3QgcmVzdWx0cyBmb3Igbm9uLWZyYWN0aW9uYWwgdmFsdWVzLlxuICAgICAqIEBwYXJhbSB2O1xuICAgICAqL1xuICAgIHNldCBhbW91bnQodikge1xuICAgICAgICB0aGlzLl9hbW91bnQgPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGUoKTtcbiAgICB9XG5cbiAgICBnZXQgYW1vdW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYW1vdW50O1xuICAgIH1cblxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIGxldCB2ID0gTWF0aC5taW4oNCwgTWF0aC5tYXgoMCwgdGhpcy5fYW1vdW50KSk7XG4gICAgICAgIGlmICh2ID4gMCkge1xuICAgICAgICAgICAgdGhpcy5nZXRMYXllcigwKS52aXNpYmxlID0gKHYgPiAwKTtcbiAgICAgICAgICAgIHRoaXMuZ2V0TGF5ZXIoMSkudmlzaWJsZSA9ICh2ID4gMSk7XG4gICAgICAgICAgICB0aGlzLmdldExheWVyKDIpLnZpc2libGUgPSAodiA+IDIpO1xuICAgICAgICAgICAgdGhpcy5nZXRMYXllcigzKS52aXNpYmxlID0gKHYgPiAzKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldCBzaGFkZXIocykge1xuICAgICAgICBzdXBlci5zaGFkZXIgPSBzO1xuICAgICAgICBpZiAoIXRoaXMucmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBQbGVhc2UgZW5hYmxlIHJlbmRlclRvVGV4dHVyZSB0byB1c2Ugd2l0aCBhIHNoYWRlci5cIik7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZmlyc3RBY3RpdmUoKSB7XG4gIC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0aW9uYWwgdmFsdWVzLlxuICAgICAqIEBwYXJhbSB2O1xuICAgICAqL1xuICAgIHNldCBhbW91bnQodikge1xuICAgICAgICB0aGlzLl9hbW91bnQgPSB2O1xuICAgICAgICB0aGlzLl90ZXh0d3JhcC5zaGFkZXIua2VybmVsUmFkaXVzID0gQzJkRmFzdEJsdXJDb21wb25lbnQuX2Ftb3VudFRvS2VybmVsUmFkaXVzKHYpO1xuICAgIH1cblxuICAgIHN0YXRpYyBfYW1vdW50VG9LZXJuZWxSYWRpdXModikge1xuICAgICAgICByZXR1cm4gQzJkRmFzdEJsdXJDb21wb25lbnQuZ2V0U3BsaW5lKCkuZ2V0VmFsdWUoTWF0aC5taW4oMSwgdiAqIDAuMjUpKTtcbiAgICB9XG5cbiAgICBnZXQgX3NpZ25hbFByb3h5KCkge1xuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbn1cblxuY2xhc3MgV2ViR0xGYXN0Qmx1ckNvbXBvbmVudCBleHRlbmRzIENvbXBvbmVudCB7XG5cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICBjb25zdCBvblVwZGF0ZSA9IGZ1bmN0aW9uKGVsZW1lbnQsIGVsZW1lbnRDb3JlKSB7XG4gICAgICAgICAgICBpZiAoKGVsZW1lbnRDb3JlLl9yZWNhbGMgJiAoMiArIDEyOCkpKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgdyA9IGVsZW1lbnRDb3JlLnc7XG4gICAgICAgICAgICAgICAgY29uc3QgaCA9IGVsZW1lbnRDb3JlLmg7XG4gICAgICAgICAgICAgICAgbGV0IGN1ciA9IGVsZW1lbnRDb3JlO1xuICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgY3VyID0gY3VyLl9jaGlsZHJlblswXTtcbiAgICAgICAgICAgICAgICAgICAgY3VyLl9lbGVtZW50LncgPSB3O1xuICAgICAgICAgICAgICAgICAgICBjdXIuX2VsZW1lbnQuaCA9IGg7XG4gICAgICAgICAgICAgICAgfSB3aGlsZShjdXIuX2NoaWxkcmVuKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgVGV4dHdyYXA6IHtydHQ6IHRydWUsIGZvcmNlWkluZGV4Q29udGV4dDogdHJ1ZSwgcmVuZGVyT2Zmc2NyZWVuOiB0cnVlLCBDb250ZW50OiB7fX0sXG4gICAgICAgICAgICBMYXllcnM6IHtcbiAgICAgICAgICAgICAgICBMMDoge3J0dDogdHJ1ZSwgb25VcGRhdGU6IG9uVXBkYXRlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHZpc2libGU6IGZhbHNlLCBDb250ZW50OiB7c2hhZGVyOiB7dHlwZTogQm94Qmx1clNoYWRlcn19fSxcbiAgICAgICAgICAgICAgICBMMToge3J0dDogdHJ1ZSwgb25VcGRhdGU6IG9uVXBkYXRlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHZpc2libGU6IGZhbHNlLCBDb250ZW50OiB7c2hhZGVyOiB7dHlwZTogQm94Qmx1clNoYWRlcn19fSxcbiAgICAgICAgICAgICAgICBMMjoge3J0dDogdHJ1ZSwgb25VcGRhdGU6IG9uVXBkYXRlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHZpc2libGU6IGZhbHNlLCBDb250ZW50OiB7c2hhZGVyOiB7dHlwZTogQm94Qmx1clNoYWRlcn19fSxcbiAgICAgICAgICAgICAgICBMMzoge3J0dDogdHJ1ZSwgb25VcGRhdGU6IG9uVXBkYXRlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHZpc2libGU6IGZhbHNlLCBDb250ZW50OiB7c2hhZGVyOiB7dHlwZTogQm94Qmx1clNoYWRlcn19fVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFJlc3VsdDoge3NoYWRlcjoge3R5cGU6IEZhc3RCbHVyT3V0cHV0U2hhZGVyfSwgdmlzaWJsZTogZmFsc2V9XG4gIC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V4LCB0aGlzLnJlYWxJbmRleCk7XG5cbiAgICAgICAgaWYgKGNsb3Nlc3QpIHtcbiAgICAgICAgICAgIC8vIFNjcm9sbCB0byBzYW1lIG9mZnNldCBjbG9zZXN0IHRvIHRoZSBpbmRleC5cbiAgICAgICAgICAgIGxldCBvZmZzZXQgPSBVdGlscy5nZXRNb2R1bG9JbmRleChpbmRleCwgbkVsZW1lbnRzKTtcbiAgICAgICAgICAgIGxldCBvID0gVXRpbHMuZ2V0TW9kdWxvSW5kZXgodGhpcy5pbmRleCwgbkVsZW1lbnRzKTtcbiAgICAgICAgICAgIGxldCBkaWZmID0gb2Zmc2V0IC0gbztcbiAgICAgICAgICAgIGlmIChkaWZmID4gMC41ICogbkVsZW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgZGlmZiAtPSBuRWxlbWVudHM7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGRpZmYgPCAtMC41ICogbkVsZW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgZGlmZiArPSBuRWxlbWVudHM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9pbmRleCArPSBkaWZmO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5faW5kZXggPSBpbmRleDtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9yb2xsIHx8ICh0aGlzLnZpZXdwb3J0U2l6ZSA+IHRoaXMuX2l0ZW1TaXplICogbkVsZW1lbnRzKSkge1xuICAgICAgICAgICAgdGhpcy5faW5kZXggPSBVdGlscy5nZXRNb2R1bG9JbmRleCh0aGlzLl9pbmRleCwgbkVsZW1lbnRzKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBkaXJlY3Rpb24gPSAodGhpcy5faG9yaXpvbnRhbCBeIHRoaXMuX2ludmVydERpcmVjdGlvbiA/IC0xIDogMSk7XG4gICAgICAgIGxldCB2YWx1ZSA9IGRpcmVjdGlvbiAqIHRoaXMuX2luZGV4ICogdG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hdGguY2VpbCh2IC8gdGhpcy5faXRlbVNpemUpO1xuICAgICAgICAgICAgcHMgPSAxICsgKHYgLyB0aGlzLl9pdGVtU2l6ZSkgLSBzO1xuICAgICAgICAgICAgZSA9IE1hdGguY2VpbCgodiAtIHZpZXdwb3J0U2l6ZSkgLyB0aGlzLl9pdGVtU2l6ZSk7XG4gICAgICAgICAgICBwZSA9IGUgLSAoKHYgLSB2aWV3cG9ydFNpemUpIC8gdGhpcy5faXRlbVNpemUpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9yb2xsIHx8ICh2aWV3cG9ydFNpemUgPiB0aGlzLl9pdGVtU2l6ZSAqIG5FbGVtZW50cykpIHtcbiAgICAgICAgICAgIC8vIERvbid0IHNob3cgYWRkaXRpb25hbCBpdGVtcy5cbiAgICAgICAgICAgIGlmIChlID49IG5FbGVtZW50cykge1xuICAgICAgICAgICAgICAgIGUgPSBuRWxlbWVudHMgLSAxO1xuICAgICAgICAgICAgICAgIHBlID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzID49IG5FbGVtZW50cykge1xuICAgICAgICAgICAgICAgIHMgPSBuRWxlbWVudHMgLSAxO1xuICAgICAgICAgICAgICAgIHBzID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChlIDw9IC0xKSB7XG4gICAgICAgICAgICAgICAgZSA9IDA7XG4gICAgICAgICAgICAgICAgcGUgPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHMgPD0gLTEpIHtcbiAgICAgICAgICAgICAgICBzID0gMDtcbiAgICAgICAgICAgICAgICBwcyA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgb2Zmc2V0ID0gLWRpcmVjdGlvbiAqIHMgKiB0aGlzLl9pdGVtU2l6ZTtcblxuICAgICAgICBsZXQgaXRlbTtcbiAgICAgICAgZm9yIChsZXQgaW5kZXggPSBzOyAoZGlyZWN0aW9uID09IC0xID8gaW5kZXggPD0gZSA6IGluZGV4ID49IGUpOyAoZGlyZWN0aW9uID09IC0xID8gaW5kZXgrKyA6IGluZGV4LS0pKSB7XG4gICAgICAgICAgICBsZXQgcmVhbEluZGV4ID0gVXRpbHMuZ2V0TW9kdWxvSW5kZXgoaW5kZXgsIG5FbGVtZW50cyk7XG5cbiAgICAgICAgICAgIGxldCBlbGVtZW50ID0gdGhpcy5nZXRFbGVtZW50KHJlYWxJbmRleCk7XG4gICAgICAgICAgICBpdGVtID0gZWxlbWVudC5wYXJlbnQ7XG4gICAgICAgICAgICB0aGlzLl92aXNpYmxlSXRlbXMuZGVsZXRlKGl0ZW0pO1xuICAgICAgICAgICAgaWYgKHRoaXMuX2hvcml6b250YWwpIHtcbiAgICAgICAgICAgICAgICBpdGVtLnggPSBvZmZzZXQgKyBzY3JvbGxEZWx0YTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaXRlbS55ID0gb2Zmc2V0ICsgc2Nyb2xsRGVsdGE7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCB3YXNWaXNpYmxlID0gaXRlbS52aXNpYmxlO1xuICAgICAgICAgICAgaXRlbS52aXNpYmxlID0gdHJ1ZTtcblxuICAgICAgICAgICAgaWYgKCF3YXNWaXNpYmxlIHx8IHRoaXMuX3JlbG9hZFZpc2libGVFbGVtZW50cykge1xuICAgICAgICAgICAgICAgIC8vIFR1cm5lZCB2aXNpYmxlLlxuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgndmlzaWJsZScsIGluZGV4LCByZWFsSW5kZXgpO1xuICAgICAgICAgICAgfVxuXG5cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3Byb2dyZXNzQW5pbWF0aW9uKSB7XG4gICAgICAgICAgICAgICAgbGV0IHAgPSAxO1xuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PSBzKSB7XG4gICAgICAgICAgICAgICAgICAgIHAgPSBwcztcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGluZGV4ID09IGUpIHtcbiAgICAgICAgICAgICAgICAgICAgcCA9IHBlO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIFVzZSBhbmltYXRpb24gdG8gcHJvZ3Jlc3MuXG4gICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NBbmltYXRpb24uYXBwbHkoZWxlbWVudCwgcCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIG9mZnNldCArPSB0aGlzLl9pdGVtU2l6ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEhhbmRsZSBpdGVtIHZpc2liaWxpdHkuXG4gICAgICAgIGxldCBzZWxmID0gdGhpcztcbiAgICAgICAgdGhpcy5fdmlzaWJsZUl0ZW1zLmZvckVhY2goZnVuY3Rpb24oaW52aXNpYmxlSXRlbSkge1xuICAgICAgICAgICAgaW52aXNpYmxlSXRlbS52aXNpYmxlID0gZmFsc2U7XG4gICAgICAgICAgICBzZWxmLl92aXNpYmxlSXRlbXMuZGVsZXRlKGludmlzaWJsZUl0ZW0pO1xuICAgICAgICB9KTtcblxuICAgICAgICBmb3IgKGxldCBpbmRleCA9IHM7IChkaXJlY3Rpb24gPT0gLTEgPyBpbmRleCA8PSBlIDogaW5kZXggPj0gZSk7IChkaXJlY3Rpb24gPT0gLTEgPyBpbmRleCsrIDogaW5kZXgtLSkpIHtcbiAgICAgICAgICAgIGxldCByZWFsSW5kZXggPSBVdGlscy5nZXRNb2R1bG9JbmRleChpbmRleCwgbkVsZW1lbnRzKTtcbiAgICAgICAgICAgIHRoaXMuX3Zpc2libGVJdGVtcy5hZGQodGhpcy5nZXRXcmFwcGVyKHJlYWxJbmRleCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fcmVsb2FkVmlzaWJsZUVsZW1lbnRzID0gZmFsc2U7XG4gICAgfVxuXG4gICAgc2V0UHJldmlvdXMoKSB7XG4gICAgICAgIHR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gICAgfVxuXG4gICAgc2V0IHJvbGxNYXgodikge1xuICAgICAgICB0aGlzLl9yb2xsTWF4ID0gdjtcbiAgICAgICAgdGhpcy51cGRhdGUoKTtcbiAgICB9XG5cbiAgICBnZXQgaW52ZXJ0RGlyZWN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faW52ZXJ0RGlyZWN0aW9uO1xuICAgIH1cblxuICAgIHNldCBpbnZlcnREaXJlY3Rpb24odikge1xuICAgICAgICBpZiAoIXRoaXMuX3N0YXJ0ZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX2ludmVydERpcmVjdGlvbiA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgaG9yaXpvbnRhbCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2hvcml6b250YWw7XG4gICAgfVxuXG4gICAgc2V0IGhvcml6b250YWwodikge1xuICAgICAgICBpZiAodiAhPT0gdGhpcy5faG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9zdGFydGVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5faG9yaXpvbnRhbCA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbn1cblxuaW1wb3J0IE9iamVjdExpc3RXcmFwcGVyIGZyb20gXCIuLi90b29scy9PYmplY3RMaXN0V3JhcHBlci5tanNcIjtcbmNsYXNzIExpc3RJdGVtcyBleHRlbmRzIE9iamVjdExpc3RXcmFwcGVyIHtcbiAgICBjb25zdHJ1Y3RvcihsaXN0KSB7XG4gICAgICAgIGxldCB3cmFwID0gKGl0ZW0gPT4ge1xuICAgICAgICAgICAgbGV0IHBhcmVudCA9IGl0ZW0uc3RhZ2UuY3JlYXRlRWxlbWVudCgpO1xuICAgICAgICAgICAgcGFyZW50LmFkZChpdGVtKTtcbiAgICAgICAgICAgIHBhcmVudC52aXNpYmxlID0gZmFsc2U7XG4gICAgICAgICAgICByZXR1cm4gcGFyZW50O1xuICAgICAgICB9KVxuXG4gICAgICAgIHN1cGVyKGxpc3QuX3dyYXBwZXIuX2NoaWxkcmVuLCB3cmFwKTtcbiAgICAgICAgdGhpcy5saXN0ID0gbGlzdDtcbiAgICB9XG5cbiAgICBvbkFkZChpdGVtLCBpbmRleCkge1xuICAgICAgICBzdXBlci5vbkFkZChpdGVtLCBpbmRleCk7XG4gICAgICAgIHRoaXMuY2hlY2tTdGFydGVkKGluZGV4KTtcbiAgICB9XG5cbiAgICBjaGVja1N0YXJ0ZWQoaW5kZXgpIHtcbiAgICAgICAgdGhpcy5saXN0Ll9yZWxvYWRWaXNpYmxlRWxlbWVudHMgPSB0cnVlO1xuICAgICAgICBpZiAoIXRoaXMubGlzdC5fc3RhcnRlZCkge1xuICAgICAgICAgICAgdGhpcy5saXN0LnN0YXJ0KCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5saXN0Lmxlbmd0aCA9PT0gMSkge1xuICAgICAgICAgICAgICAgIHRoaXMubGlzdC5zZXRJbmRleCgwLCB0cnVlLCB0cnVlKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMubGlzdC5faW5kZXggPj0gdGhpcy5saXN0Lmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmxpc3Quc2V0SW5kZXgoMCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5saXN0LnVwZGF0ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgb25SZW1vdmUoaXRlbSwgaW5kZXgpIHtcbiAgICAgICAgc3VwZXIub25SZW1vdmUoaXRlbSwgaW5kZXgpO1xuICAgICAgICBsZXQgcmkgPSB0aGlzLmxpc3QucmVhbEluZGV4O1xuICAgICAgICBpZiAocmkgPT09IGluZGV4KSB7XG4gICAgICAgICAgICBpZiAocmkgPT09IHRoaXMubGlzdC5sZW5ndGgpIHt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gICAgICAgICBDb250ZW50OiB7fVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFNjYWxlOiB7dmlzaWJsZTogZmFsc2V9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjb25zdHJ1Y3RvcihzdGFnZSkge1xuICAgICAgICBzdXBlcihzdGFnZSk7XG5cbiAgICAgICAgdGhpcy5fc21vb3RoU2NhbGUgPSAxO1xuICAgICAgICB0aGlzLl9pdGVyYXRpb25zID0gMDtcbiAgICB9XG5cbiAgICBnZXQgY29udGVudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudGFnKCdDb250ZW50Jyk7XG4gICAgfVxuXG4gICAgc2V0IGNvbnRlbnQodikge1xuICAgICAgICB0aGlzLnRhZygnQ29udGVudCcpLnBhdGNoKHYsIHRydWUpO1xuICAgIH1cblxuICAgIGdldCBzbW9vdGhTY2FsZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3Ntb290aFNjYWxlO1xuICAgIH1cblxuICAgIHNldCBzbW9vdGhTY2FsZSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9zbW9vdGhTY2FsZSAhPT0gdikge1xuICAgICAgICAgICAgbGV0IGl0cyA9IDA7XG4gICAgICAgICAgICB3aGlsZSh2IDwgMC41ICYmIGl0cyA8IDEyKSB7XG4gICAgICAgICAgICAgICAgaXRzKys7XG4gICAgICAgICAgICAgICAgdiA9IHYgKiAyO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLnNjYWxlID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3NldEl0ZXJhdGlvbnMoaXRzKTtcblxuICAgICAgICAgICAgdGhpcy5fc21vb3RoU2NhbGUgPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3NldEl0ZXJhdGlvbnMoaXRzKSB7XG4gICAgICAgIGlmICh0aGlzLl9pdGVyYXRpb25zICE9PSBpdHMpIHtcbiAgICAgICAgICAgIGNvbnN0IHNjYWxlcnMgPSB0a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hPT0gaXRzIC0gMVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5faXRlcmF0aW9ucyA9IGl0cztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBfdXBkYXRlRGltZW5zaW9ucyhjb250ZW50V3JhcCwgZm9yY2UpIHtcbiAgICAgICAgY29uc3QgY29udGVudCA9IGNvbnRlbnRXcmFwLmNoaWxkcmVuWzBdO1xuICAgICAgICBsZXQgdyA9IGNvbnRlbnQucmVuZGVyV2lkdGg7XG4gICAgICAgIGxldCBoID0gY29udGVudC5yZW5kZXJIZWlnaHQ7XG4gICAgICAgIGlmICh3ICE9PSBjb250ZW50V3JhcC53IHx8IGggIT09IGNvbnRlbnRXcmFwLmggfHwgZm9yY2UpIHtcbiAgICAgICAgICAgIGNvbnRlbnRXcmFwLncgPSB3O1xuICAgICAgICAgICAgY29udGVudFdyYXAuaCA9IGg7XG5cbiAgICAgICAgICAgIGNvbnN0IHNjYWxlcnMgPSBjb250ZW50V3JhcC5wYXJlbnQudGFnKFwiU2NhbGVcIikuY2hpbGRyZW47XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHNjYWxlcnMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdyA9IHcgKiAwLjU7XG4gICAgICAgICAgICAgICAgaCA9IGggKiAwLjU7XG4gICAgICAgICAgICAgICAgc2NhbGVyc1tpXS53ID0gdztcbiAgICAgICAgICAgICAgICBzY2FsZXJzW2ldLmggPSBoO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IF9zaWduYWxQcm94eSgpIHtcbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaW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odikge1xuICAgICAgICBpZiAodGhpcy5fYWxpZ25Db250ZW50ID09PSB2KSByZXR1cm47XG4gICAgICAgIGlmIChGbGV4Q29udGFpbmVyLkFMSUdOX0NPTlRFTlQuaW5kZXhPZih2KSA9PT0gLTEpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlVua25vd24gYWxpZ25Db250ZW50LCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuQUxJR05fQ09OVEVOVC5qb2luKFwiLFwiKSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fYWxpZ25Db250ZW50ID0gdjtcblxuICAgICAgICB0aGlzLl9jaGFuZ2VkQ29udGVudHMoKTtcbiAgICB9XG5cbiAgICBnZXQganVzdGlmeUNvbnRlbnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9qdXN0aWZ5Q29udGVudDtcbiAgICB9XG5cbiAgICBzZXQganVzdGlmeUNvbnRlbnQodikge1xuICAgICAgICBpZiAodGhpcy5fanVzdGlmeUNvbnRlbnQgPT09IHYpIHJldHVybjtcblxuICAgICAgICBpZiAoRmxleENvbnRhaW5lci5KVVNUSUZZX0NPTlRFTlQuaW5kZXhPZih2KSA9PT0gLTEpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlVua25vd24ganVzdGlmeUNvbnRlbnQsIG9wdGlvbnM6IFwiICsgRmxleENvbnRhaW5lci5KVVNUSUZZX0NPTlRFTlQuam9pbihcIixcIikpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2p1c3RpZnlDb250ZW50ID0gdjtcblxuICAgICAgICB0aGlzLl9jaGFuZ2VkQ29udGVudHMoKTtcbiAgICB9XG5cbiAgICBzZXQgcGFkZGluZyh2KSB7XG4gICAgICAgIHRoaXMucGFkZGluZ0xlZnQgPSB2O1xuICAgICAgICB0aGlzLnBhZGRpbmdUb3AgPSB2O1xuICAgICAgICB0aGlzLnBhZGRpbmdSaWdodCA9IHY7XG4gICAgICAgIH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BzZXQgc2hyaW5rKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3NocmluayA9PT0gdikgcmV0dXJuO1xuXG4gICAgICAgIHRoaXMuX3NocmluayA9IHBhcnNlSW50KHYpIHx8IDA7XG5cbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgIH1cblxuICAgIGdldCBhbGlnblNlbGYoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9hbGlnblNlbGY7XG4gICAgfVxuXG4gICAgc2V0IGFsaWduU2VsZih2KSB7XG4gICAgICAgIGlmICh0aGlzLl9hbGlnblNlbGYgPT09IHYpIHJldHVybjtcblxuICAgICAgICBpZiAodiA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICB0aGlzLl9hbGlnblNlbGYgPSB1bmRlZmluZWQ7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoRmxleENvbnRhaW5lci5BTElHTl9JVEVNUy5pbmRleE9mKHYpID09PSAtMSkge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlVua25vd24gYWxpZ25TZWxmLCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuQUxJR05fSVRFTVMuam9pbihcIixcIikpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fYWxpZ25TZWxmID0gdjtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICB9XG5cbiAgICBnZXQgbWluV2lkdGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9taW5XaWR0aDtcbiAgICB9XG5cbiAgICBzZXQgbWluV2lkdGgodikge1xuICAgICAgICB0aGlzLl9taW5XaWR0aCA9IE1hdGgubWF4KDAsIHYpO1xuICAgICAgICB0aGlzLl9pdGVtLmNoYW5nZWREaW1lbnNpb25zKHRydWUsIGZhbHNlKTtcbiAgICB9XG5cbiAgICBnZXQgbWluSGVpZ2h0KCkge1xuICAgICAgICByZXR1cm4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hpcy5fdGFyZ2V0O1xuICAgIH1cblxuICAgIGdldCBmbGV4KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZmxleDtcbiAgICB9XG5cbiAgICBzZXQgZmxleCh2KSB7XG4gICAgICAgIGlmICghdikge1xuICAgICAgICAgICAgaWYgKHRoaXMuaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZGlzYWJsZUZsZXgoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5pc0ZsZXhFbmFibGVkKCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9lbmFibGVGbGV4KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9mbGV4LnBhdGNoKHYpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGZsZXhJdGVtKCkge1xuICAgICAgICBpZiAodGhpcy5fZmxleEl0ZW1EaXNhYmxlZCkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2Vuc3VyZUZsZXhJdGVtKCk7XG4gICAgICAgIHJldHVybiB0aGlzLl9mbGV4SXRlbTtcbiAgICB9XG5cbiAgICBzZXQgZmxleEl0ZW0odikge1xuICAgICAgICBpZiAodiA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fZmxleEl0ZW1EaXNhYmxlZCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHBhcmVudCA9IHRoaXMuZmxleFBhcmVudDtcbiAgICAgICAgICAgICAgICB0aGlzLl9mbGV4SXRlbURpc2FibGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGVja0VuYWJsZWQoKTtcbiAgICAgICAgICAgICAgICBpZiAocGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHBhcmVudC5fY2xlYXJGbGV4SXRlbXNDYWNoZSgpO1xuICAgICAgICAgICAgICAgICAgICBwYXJlbnQuY2hhbmdlZENvbnRlbnRzKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZW5zdXJlRmxleEl0ZW0oKTtcblxuICAgICAgICAgICAgdGhpcy5fZmxleEl0ZW0ucGF0Y2godik7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9mbGV4SXRlbURpc2FibGVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZmxleEl0ZW1EaXNhYmxlZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoZWNrRW5hYmxlZCgpO1xuICAgICAgICAgICAgICAgIGNvbnN0IHBhcmVudCA9IHRoaXMuZmxleFBhcmVudDtcbiAgICAgICAgICAgICAgICBpZiAocGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHBhcmVudC5fY2xlYXJGbGV4SXRlbXNDYWNoZSgpO1xuICAgICAgICAgICAgICAgICAgICBwYXJlbnQuY2hhbmdlZENvbnRlbnRzKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2VuYWJsZUZsZXgoKSB7XG4gICAgICAgIHRoaXMuX2ZsZXggPSBuZXcgRmxleENvbnRhaW5lcih0aGlzKTtcbiAgICAgICAgdGhpcy5fY2hlY2tFbmFibGVkKCk7XG4gICAgICAgIHRoaXMuY2hhbmdlZERpbWVuc2lvbnMoKTtcbiAgICAgICAgdGhpcy5fZW5hYmxlQ2hpbGRyZW5Bc0ZsZXhJdGVtcygpO1xuICAgIH1cblxuICAgIF9kaXNhYmxlRmxleCgpIHtcbiAgICAgICAgdGhpcy5jaGFuZ2VkRGltZW5zaW9ucygpO1xuICAgICAgICB0aGlzLl9mbGV4ID0gbnVsbDtcbiAgICAgICAgdGhpcy5fY2hlY2tFbmFibGVkKCk7XG4gICAgICAgI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gICAgICBpZiAocGFyZW50KSB7XG4gICAgICAgICAgICBwYXJlbnQuX2NoYW5nZWRDaGlsZHJlbigpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGl0ZW1zKCkge1xuICAgICAgICBpZiAoIXRoaXMuX2l0ZW1zKSB7XG4gICAgICAgICAgICB0aGlzLl9pdGVtcyA9IHRoaXMuX2dldEZsZXhJdGVtcygpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl9pdGVtcztcbiAgICB9XG5cbiAgICBfZ2V0RmxleEl0ZW1zKCkge1xuICAgICAgICBjb25zdCBpdGVtcyA9IFtdO1xuICAgICAgICBjb25zdCBjaGlsZHJlbiA9IHRoaXMuX3RhcmdldC5fY2hpbGRyZW47XG4gICAgICAgIGlmIChjaGlsZHJlbikge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBjaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gY2hpbGRyZW5baV07XG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0udmlzaWJsZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5pc0ZsZXhJdGVtKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goaXRlbS5sYXlvdXQpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBpdGVtcztcbiAgICB9XG5cbiAgICBfY2hhbmdlZENoaWxkcmVuKCkge1xuICAgICAgICB0aGlzLl9jbGVhckZsZXhJdGVtc0NhY2hlKCk7XG4gICAgICAgIHRoaXMuY2hhbmdlZENvbnRlbnRzKCk7XG4gICAgfVxuXG4gICAgX2NsZWFyRmxleEl0ZW1zQ2FjaGUoKSB7XG4gICAgICAgIHRoaXMuX2l0ZW1zID0gbnVsbDtcb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7XG4gICAgICAgICAgICBpZiAodGhpcy5mbGV4UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5mbGV4UGFyZW50Ll91cGRhdGVSZWNhbGNCb3R0b21VcChyZWNhbGMpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90YXJnZXQudHJpZ2dlckxheW91dCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fdGFyZ2V0LnRyaWdnZXJMYXlvdXQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldE5ld1JlY2FsY0ZsYWdzKGZsYWdzKSB7XG4gICAgICAgIHJldHVybiAoNyAtIHRoaXMuX3JlY2FsYykgJiBmbGFncztcbiAgICB9XG5cbiAgICBfdXBkYXRlUmVjYWxjQm90dG9tVXAoY2hpbGRSZWNhbGMpIHtcbiAgICAgICAgY29uc3QgbmV3UmVjYWxjID0gdGhpcy5fZ2V0UmVjYWxjRnJvbUNoYW5nZWRDaGlsZFJlY2FsYyhjaGlsZFJlY2FsYyk7XG4gICAgICAgIGNvbnN0IG5ld1JlY2FsY0ZsYWdzID0gdGhpcy5nZXROZXdSZWNhbGNGbGFncyhuZXdSZWNhbGMpO1xuICAgICAgICB0aGlzLl9yZWNhbGMgfD0gbmV3UmVjYWxjO1xuICAgICAgICBpZiAobmV3UmVjYWxjRmxhZ3MgPiAxKSB7XG4gICAgICAgICAgICBjb25zdCBmbGV4UGFyZW50ID0gdGhpcy5mbGV4UGFyZW50O1xuICAgICAgICAgICAgaWYgKGZsZXhQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICBmbGV4UGFyZW50Ll91cGRhdGVSZWNhbGNCb3R0b21VcChuZXdSZWNhbGMpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90YXJnZXQudHJpZ2dlckxheW91dCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB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250ZW50cykge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gU3BlY2lhbCBjYXNlOiBkdWUgdG8gd3JhcHBpbmcsIHRoZSBjcm9zcyBheGlzIHNpemUgbWF5IGJlIGNoYW5nZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICBjaGlsZFJlY2FsYyArPSBjcm9zc0F4aXNSZWNhbGNGbGFnO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGlzV2lkdGhEeW5hbWljID0gbGF5b3V0LmlzQXhpc0ZpdFRvQ29udGVudHModHJ1ZSk7XG4gICAgICAgIGxldCBpc0hlaWdodER5bmFtaWMgPSBsYXlvdXQuaXNBeGlzRml0VG9Db250ZW50cyhmYWxzZSk7XG5cbiAgICAgICAgaWYgKGxheW91dC5zaHJ1bmspIHtcbiAgICAgICAgICAgIC8vIElmIGR1cmluZyBwcmV2aW91cyBsYXlvdXQgdGhpcyBjb250YWluZXIgd2FzICdzaHJ1bmsnLCBhbnkgY2hhbmdlcyBtYXkgY2hhbmdlIHRoZSAnbWluIGF4aXMgc2l6ZScgb2YgdGhlXG4gICAgICAgICAgICAvLyBjb250ZW50cywgbGVhZGluZyB0byBhIGRpZmZlcmVudCBheGlzIHNpemUgb24gdGhpcyBjb250YWluZXIgZXZlbiB3aGVuIGl0IHdhcyBub3QgJ2ZpdCB0byBjb250ZW50cycuXG4gICAgICAgICAgICBpZiAobGF5b3V0Ll9ob3Jpem9udGFsKSB7XG4gICAgICAgICAgICAgICAgaXNXaWR0aER5bmFtaWMgPSB0cnVlO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpc0hlaWdodER5bmFtaWMgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgY29uc3QgbG9jYWxSZWNhbGMgPSAxICsgKGlzV2lkdGhEeW5hbWljID8gMiA6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IHBlbmRpbmcgbGF5b3V0IHNpemUuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZ2V0QXhpc0xheW91dFNpemUoZmxleFBhcmVudCwgaG9yaXpvbnRhbCkgKyB0aGlzLmdldFRvdGFsUGFkZGluZyhmbGV4UGFyZW50LCBob3Jpem9udGFsKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gVXNlICdhYnNvbHV0ZScgc2l6ZS5cbiAgICAgICAgICAgICAgICByZXR1cm4gaG9yaXpvbnRhbCA/IHBhcmVudC53IDogcGFyZW50Lmg7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0UmVsQXhpc1NpemUoaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgaWYgKGl0ZW0uZnVuY1cpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fYWxsb3dSZWxBeGlzU2l6ZUZ1bmN0aW9uKGl0ZW0sIHRydWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLmZ1bmNXKHRoaXMuZ2V0UGFyZW50QXhpc1NpemVXaXRoUGFkZGluZyhpdGVtLCB0cnVlKSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS5vcmlnaW5hbFdpZHRoO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKGl0ZW0uZnVuY0gpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fYWxsb3dSZWxBeGlzU2l6ZUZ1bmN0aW9uKGl0ZW0sIGZhbHNlKSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS5mdW5jSCh0aGlzLmdldFBhcmVudEF4aXNTaXplV2l0aFBhZGRpbmcoaXRlbSwgZmFsc2UpKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLm9yaWdpbmFsSGVpZ2h0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIF9hbGxvd1JlbEF4aXNTaXplRnVuY3Rpb24oaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBjb25zdCBmbGV4UGFyZW50ID0gaXRlbS5mbGV4UGFyZW50O1xuICAgICAgICBpZiAoZmxleFBhcmVudCAmJiBmbGV4UGFyZW50Ll9mbGV4Ll9sYXlvdXQuaXNBeGlzRml0VG9Db250ZW50cyhob3Jpem9udGFsKSkge1xuICAgICAgICAgICAgLy8gV2UgZG9uJ3QgYWxsb3cgcmVsYXRpdmUgd2lkdGggb24gZml0LXRvLWNvbnRlbnRzIGJlY2F1c2UgaXQgbGVhZHMgdG8gY29uZmxpY3RzLlxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cblxuICAgIHN0YXRpYyBpc1plcm9BeGlzU2l6ZShpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGlmIChob3Jpem9udGFsKSB7XG4gICAgICAgICAgICByZXR1cm4gIWl0ZW0ub3JpZ2luYWxXaWR0aCAmJiAhaXRlbS5mdW5jVztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiAhaXRlbS5vcmlnaW5hbEhlaWdodCAmJiAhaXRlbS5mdW5jSDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBnZXRBeGlzTGF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lZE1pblNpemUgPSAoZmxleEl0ZW1NaW5TaXplID4gMCk7XG4gICAgICAgIGlmIChoYXNMaW1pdGVkTWluU2l6ZSkge1xuICAgICAgICAgICAgbWluU2l6ZSA9IE1hdGgubWF4KG1pblNpemUsIGZsZXhJdGVtTWluU2l6ZSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG1pblNpemU7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFBsYWluQXhpc01pblNpemUoaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBpZiAoaXRlbS5pc0ZsZXhFbmFibGVkKCkpIHtcbiAgICAgICAgICAgIHJldHVybiBpdGVtLl9mbGV4Ll9sYXlvdXQuZ2V0QXhpc01pblNpemUoaG9yaXpvbnRhbCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBpc1Nocmlua2FibGUgPSAoaXRlbS5mbGV4SXRlbS5zaHJpbmsgIT09IDApO1xuICAgICAgICAgICAgaWYgKGlzU2hyaW5rYWJsZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRSZWxBeGlzU2l6ZShpdGVtLCBob3Jpem9udGFsKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyByZXNpemVBeGlzKGl0ZW0sIGhvcml6b250YWwsIHNpemUpIHtcbiAgICAgICAgaWYgKGl0ZW0uaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICBjb25zdCBpc01haW5BeGlzID0gKGl0ZW0uX2ZsZXguX2hvcml6b250YWwgPT09IGhvcml6b250YWwpO1xuICAgICAgICAgICAgaWYgKGlzTWFpbkF4aXMpIHtcbiAgICAgICAgICAgICAgICBpdGVtLl9mbGV4Ll9sYXlvdXQucmVzaXplTWFpbkF4aXMoc2l6ZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGl0ZW0uX2ZsZXguX2xheW91dC5yZXNpemVDcm9zc0F4aXMoc2l6ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnNldEF4aXNMYXlvdXRTaXplKGl0ZW0sIGhvcml6b250YWwsIHNpemUpO1xuICAgICAgICB9XG4gICAgfVxuXG5cbiAgICBzdGF0aWMgZ2V0UGFkZGluZ09mZnNldChpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGlmIChpdGVtLmlzRmxleEVuYWJsZWQoKSkge1xuICAgICAgICAgICAgY29uc3QgZmxleCA9IGl0ZW0uX2ZsZXg7XG4gICAgICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4LnBhZGRpbmdMZWZ0O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleC5wYWRkaW5nVG9wO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0VG90YWxQYWRkaW5nKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKGl0ZW0uaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICBjb25zdCBmbGV4ID0gaXRlbS5fZmxleDtcbiAgICAgICAgICAgIGlmIChob3Jpem9udGFsKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZsZXgucGFkZGluZ1JpZ2h0ICsgZmxleC5wYWRkaW5nTGVmdDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZsZXgucGFkZGluZ1RvcCArIGZsZXgucGFkZGluZ0JvdHRvbTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGdldE1hcmdpbk9mZnNldChpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGNvbnN0IGZsZXhJdGVtID0gaXRlbS5mbGV4SXRlbTtcbiAgICAgICAgaWYgKGZsZXhJdGVtKSB7XG4gICAgICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4SXRlbS5tYXJnaW5MZWZ0O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleEl0ZW0ubWFyZ2luVG9wO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0VG90YWxNYXJnaW4oaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBjb25zdCBmbGV4SXRlbSA9IGl0ZW0uZmxleEl0ZW07XG4gICAgICAgIGlmIChmbGV4SXRlbSkge1xuICAgICAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleEl0ZW0ubWFyZ2luUmlnaHQgKyBmbGV4SXRlbS5tYXJnaW5MZWZ0O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleEl0ZW0ubWFyZ2luVG9wICsgZmxleEl0ZW0ubWFyZ2luQm90dG9tO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH1cbiAgICB9XG5cbn1cbiIsIi8qXG4gKiBJZiBub3Qgc3RhdGVkIG90aGVyd2lzZSBpbiB0aGlzIGZpbGUgb3IgdGhpcyBjb21wb25lbnQncyBMSUNFTlNFIGZpbGUgdGhlXG4gKiBmb2xsb3d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AgIHRoaXMuX2xheW91dENyb3NzQXhpcygpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEBwcmUgbWFpbkF4aXNTaXplIHNob3VsZCBleGNsdWRlIHBhZGRpbmcuXG4gICAgICovXG4gICAgX2xheW91dE1haW5BeGlzKCkge1xuICAgICAgICB0aGlzLl9sYXlvdXRMaW5lcygpO1xuICAgICAgICB0aGlzLl9maXRNYWluQXhpc1NpemVUb0NvbnRlbnRzKCk7XG4gICAgfVxuXG4gICAgX2xheW91dExpbmVzKCkge1xuICAgICAgICB0aGlzLl9saW5lTGF5b3V0ZXIubGF5b3V0TGluZXMoKTtcbiAgICB9XG5cbiAgICBnZXQgX2xpbmVzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbGluZUxheW91dGVyLmxpbmVzO1xuICAgIH1cblxuICAgIF9maXRNYWluQXhpc1NpemVUb0NvbnRlbnRzKCkge1xuICAgICAgICBpZiAoIXRoaXMuX3Jlc2l6aW5nTWFpbkF4aXMpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzTWFpbkF4aXNGaXRUb0NvbnRlbnRzKCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLm1haW5BeGlzU2l6ZSA9IHRoaXMuX2xpbmVMYXlvdXRlci5tYWluQXhpc0NvbnRlbnRTaXplO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQHByZSBjcm9zc0F4aXNTaXplIHNob3VsZCBleGNsdWRlIHBhZGRpbmcuXG4gICAgICovXG4gICAgX2xheW91dENyb3NzQXhpcygpIHtcbiAgICAgICAgY29uc3QgYWxpZ25lciA9IG5ldyBDb250ZW50QWxpZ25lcih0aGlzKTtcbiAgICAgICAgYWxpZ25lci5pbml0KCk7XG4gICAgICAgIHRoaXMuX3RvdGFsQ3Jvc3NBeGlzU2l6ZSA9IGFsaWduZXIudG90YWxDcm9zc0F4aXNTaXplO1xuICAgICAgICB0aGlzLl9maXRDcm9z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R1cm4gIUZsZXhVdGlscy5pc1plcm9BeGlzU2l6ZSh0aGlzLml0ZW0sIHRoaXMuX2hvcml6b250YWwpO1xuICAgIH1cblxuICAgIF9oYXNGaXhlZENyb3NzQXhpc0Jhc2lzKCkge1xuICAgICAgICByZXR1cm4gIUZsZXhVdGlscy5pc1plcm9BeGlzU2l6ZSh0aGlzLml0ZW0sICF0aGlzLl9ob3Jpem9udGFsKTtcbiAgICB9XG5cbiAgICBnZXRBeGlzTWluU2l6ZShob3Jpem9udGFsKSB7XG4gICAgICAgIGlmICh0aGlzLl9ob3Jpem9udGFsID09PSBob3Jpem9udGFsKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fZ2V0TWFpbkF4aXNNaW5TaXplKCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fZ2V0Q3Jvc3NBeGlzTWluU2l6ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldE1haW5BeGlzTWluU2l6ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xpbmVMYXlvdXRlci5tYWluQXhpc01pblNpemU7XG4gICAgfVxuXG4gICAgX2dldENyb3NzQXhpc01pblNpemUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9saW5lTGF5b3V0ZXIuY3Jvc3NBeGlzTWluU2l6ZTtcbiAgICB9XG5cbiAgICByZXNpemVNYWluQXhpcyhzaXplKSB7XG4gICAgICAgIGlmICh0aGlzLm1haW5BeGlzU2l6ZSAhPT0gc2l6ZSkge1xuICAgICAgICAgICAgaWYgKHRoaXMucmVjYWxjID4gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMucGVyZm9ybVJlc2l6ZU1haW5BeGlzKHNpemUpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2hlY2tWYWxpZENhY2hlTWFpbkF4aXNSZXNpemUoKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLm1haW5BeGlzU2l6ZSA9IHNpemU7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpdENyb3NzQXhpc1NpemVUb0NvbnRlbnRzKCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQ2FjaGUgbWlzcy5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5pdGVtLmVuYWJsZUxvY2FsUmVjYWxjRmxhZygpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnBlcmZvcm1SZXNpemVNYWluQXhpcyhzaXplKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfY2hlY2tWYWxpZENhY2hlTWFpbkF4aXNSZXNpemUoc2l6ZSkge1xuICAgICAgICBjb25zdCBpc0ZpbmFsTWFpbkF4aXNTaXplID0gKHNpemUgPT09IHRoaXMudGFyZ2V0TWFpbkF4aXNTaXplKTtcbiAgICAgICAgaWYgKGlzRmluYWxNYWluQXhpc1NpemUpIHtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGNhbklnbm9yZUNhY2hlTWlzcyA9ICF0aGlzLmlzQ3Jvc3NBeGlzRml0VG9Db250ZW50cygpO1xuICAgICAgICBpZiAoY2FuSWdub3JlQ2FjaGVNaXNzKSB7XG4gICAgICAgICAgICAvLyBBbGxvdyBvdGhlciBtYWluIGF4aXMgcmVzaXplcyBhbmQgY2hlY2sgaWYgZmluYWwgcmVzaXplIG1hdGNoZXMgdGhlIHRhcmdldCBtYWluIGF4aXMgc2l6ZVxuICAgICAgICAgICAgLy8gIChJdGVtQ29vcmRpbmF0ZXNVcGRhdGVyKS5cbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG5cbiAgICBwZXJmb3JtUmVzaXplTWFpbkF4aXMoc2l6ZSkge1xuICAgICAgICBjb25zdCBpc1Nocmlua2luZyA9IChzaXplIDwgdGhpcy5tYWluQXhpc1NpemUpO1xuICAgICAgICB0aGlzLl9zaHJ1bmsgPSBpc1Nocmlua2luZztcblxuICAgICAgICB0aGlzLm1haW5BeGlzU2l6ZSA9IHNpemU7XG5cbiAgICAgICAgdGhpcy5fcmVzaXppbmdNYWluQXhpcyA9IHRydWU7XG4gICAgICAgIHRoaXMuX2xheW91dEF4ZXMoKTtcbiAgICAgICAgdGhpcy5fcmVzaXppbmdNYWluQXhpcyA9IGZhbHNlO1xuICAgIH1cblxuICAgIHJlc2l6ZUNyb3NzQXhpcyhzaXplKSB7XG4gICAgICAgIGlmICh0aGlzLmNyb3NzQXhpc1NpemUgIT09IHNpemUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnJlY2FsYyA+IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLnBlcmZvcm1SZXNpemVDcm9zc0F4aXMoc2l6ZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuY3Jvc3NBeGlzU2l6ZSA9IHNpemU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBwZXJmb3JtUmVzaXplQ3Jvc3NBeGlzKHNpemUpIHtcbiAgICAgICAgdGhpcy5jcm9zc0F4aXNTaXplID0gc2l6ZTtcblxuICAgICAgICB0aGlzLl9yZXNpemluZ0Nyb3NzQXhpcyA9IHRydWU7XG4gICAgICAgIHRoaXMuX2xheW91dENyb3NzQXhpcygpO1xuICAgICAgICB0aGlzLl9yZXNpemluZ0Nyb3NzQXhpcyA9IGZhbHNlO1xuICAgIH1cblxuICAgIGdldCB0YXJnZXRNYWluQXhpc1NpemUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9ob3Jpem9udGFsID8gdGhpcy5pdGVtLnRhcmdldC53IDogdGhpcy5pdGVtLnRhcmdldC5oO1xuICAgIH1cblxuICAgI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gLSAxKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3VyTWFpbkF4aXNQb3MgPSAwO1xuICAgICAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX2FkZFRvTWFpbkF4aXNQb3MoaXRlbU1haW5BeGlzU2l6ZSk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoc3RhcnRJbmRleCA8IGkpIHtcbiAgICAgICAgICAgIHRoaXMuX2xheW91dExpbmUoc3RhcnRJbmRleCwgaSAtIDEpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2xheW91dEZsZXhJdGVtKGl0ZW0pIHtcbiAgICAgICAgaWYgKGl0ZW0uaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICBpdGVtLmZsZXhMYXlvdXQudXBkYXRlVHJlZUxheW91dCgpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaXRlbS5mbGV4SXRlbS5fcmVzZXRMYXlvdXRTaXplKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfc2V0dXAoKSB7XG4gICAgICAgIHRoaXMuX21haW5BeGlzU2l6ZSA9IHRoaXMuX2xheW91dC5tYWluQXhpc1NpemU7XG4gICAgICAgIHRoaXMuX2N1ck1haW5BeGlzUG9zID0gMDtcbiAgICAgICAgdGhpcy5fbWF4TWFpbkF4aXNQb3MgPSAwO1xuICAgICAgICB0aGlzLl9saW5lcyA9IFtdO1xuXG4gICAgICAgIHRoaXMuX21haW5BeGlzTWluU2l6ZSA9IC0xO1xuICAgICAgICB0aGlzLl9jcm9zc0F4aXNNaW5TaXplID0gLTE7XG4gICAgICAgIHRoaXMuX21haW5BeGlzQ29udGVudFNpemUgPSAwO1xuICAgIH1cblxuICAgIF9hZGRUb01haW5BeGlzUG9zKGl0ZW1NYWluQXhpc1NpemUpIHtcbiAgICAgICAgdGhpcy5fY3VyTWFpbkF4aXNQb3MgKz0gaXRlbU1haW5BeGlzU2l6ZTtcbiAgICAgICAgaWYgKHRoaXMuX2N1ck1haW5BeGlzUG9zID4gdGhpcy5fbWF4TWFpbkF4aXNQb3MpIHtcbiAgICAgICAgICAgIHRoaXMuX21heE1haW5BeGlzUG9zID0gdGhpcy5fY3VyTWFpbkF4aXNQb3M7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfbGF5b3V0TGluZShzdGFydEluZGV4LCBlbmRJbmRleCkge1xuICAgICAgICBjb25zdCBhdmFpbGFibGVTcGFjZSA9IHRoaXMuX2dldEF2YWlsYWJsZU1haW5BeGlzTGF5b3V0U3BhY2UoKTtcbiAgICAgICAgY29uc3QgbGluZSA9IG5ldyBMaW5lTGF5b3V0KHRoaXMuX2xheW91dCwgc3RhcnRJbmRleCwgZW5kSW5kZXgsIGF2YWlsYWJsZVNwYWNlKTtcbiAgICAgICAgbGluZS5wZXJmb3JtTGF5b3V0KCk7XG4gICAgICAgIHRoaXMuX2xpbmVzLnB1c2gobGluZSk7XG5cbiAgICAgICAgaWYgKHRoaXMuX21haW5BeGlzQ29udGVudFNpemUgPT09IDAgfHwgKHRoaXMuX2N1ck1haW5BeGlzUG9zID4gdGhpcy5fbWFpbkF4aXNDb250ZW50U2l6ZSkpIHtcbiAgICAgICAgICAgIHRoaXMuX21haW5BeGlzQ29udGVudFNpemUgPSB0aGlzLl9jdXJNYWluQXhpc1BvcztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRBdmFpbGFibGVNYWluQXhpc0xheW91dFNwYWNlKCkge1xuICAgICAgICBpZiAoIXRoaXMuX2xheW91dC5yZXNpemluZ01haW5BeGlzICYmIHRoaXMuX2xheW91dC5pc01haW5BeGlzRml0VG9Db250ZW50cygpKSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWluQXhpc1NpemUgLSB0aGl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aW5nU3BhY2UpIHtcbiAgICAgICAgY29uc3QgaXRlbUdhcHMgPSAobnVtYmVyT2ZJdGVtcyAtIDEpO1xuICAgICAgICBsZXQgc3BhY2VQZXJHYXA7XG5cbiAgICAgICAgbGV0IHNwYWNpbmdCZWZvcmUsIHNwYWNpbmdCZXR3ZWVuO1xuXG4gICAgICAgIHN3aXRjaChtb2RlKSB7XG4gICAgICAgICAgICBjYXNlIFwiZmxleC1zdGFydFwiOlxuICAgICAgICAgICAgICAgIHNwYWNpbmdCZWZvcmUgPSAwO1xuICAgICAgICAgICAgICAgIHNwYWNpbmdCZXR3ZWVuID0gMDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgXCJmbGV4LWVuZFwiOlxuICAgICAgICAgICAgICAgIHNwYWNpbmdCZWZvcmUgPSByZW1haW5pbmdTcGFjZTtcbiAgICAgICAgICAgICAgICBzcGFjaW5nQmV0d2VlbiA9IDA7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwiY2VudGVyXCI6XG4gICAgICAgICAgICAgICAgc3BhY2luZ0JlZm9yZSA9IHJlbWFpbmluZ1NwYWNlIC8gMjtcbiAgICAgICAgICAgICAgICBzcGFjaW5nQmV0d2VlbiA9IDA7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwic3BhY2UtYmV0d2VlblwiOlxuICAgICAgICAgICAgICAgIHNwYWNpbmdCZWZvcmUgPSAwO1xuICAgICAgICAgICAgICAgIHNwYWNpbmdCZXR3ZWVuID0gTWF0aC5tYXgoMCwgcmVtYWluaW5nU3BhY2UpIC8gaXRlbUdhcHM7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwic3BhY2UtYXJvdW5kXCI6XG4gICAgICAgICAgICAgICAgaWYgKHJlbWFpbmluZ1NwYWNlIDwgMCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRTcGFjaW5nKFwiY2VudGVyXCIsIG51bWJlck9mSXRlbXMsIHJlbWFpbmluZ1NwYWNlKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzcGFjZVBlckdhcCA9IHJlbWFpbmluZ1NwYWNlIC8gKGl0ZW1HYXBzICsgMSk7XG4gICAgICAgICAgICAgICAgICAgIHNwYWNpbmdCZWZvcmUgPSAwLjUgKiBzcGFjZVBlckdhcDtcbiAgICAgICAgICAgICAgICAgICAgc3BhY2luZ0JldHdlZW4gPSBzcGFjZVBlckdhcDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwic3BhY2UtZXZlbmx5XCI6XG4gICAgICAgICAgICAgICAgaWYgKHJlbWFpbmluZ1NwYWNlIDwgMCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRTcGFjaW5nKFwiY2VudGVyXCIsIG51bWJlck9mSXRlbXMsIHJlbWFpbmluZ1NwYWNlKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzcGFjZVBlckdhcCA9IHJlbWFpbmluZ1NwYWNlIC8gKGl0ZW1HYXBzICsgMik7XG4gICAgICAgICAgICAgICAgICAgIHNwYWNpbmdCZWZvcmUgPSBzcGFjZVBlckdhcDtcbiAgICAgICAgICAgICAgICAgICAgc3BhY2luZ0JldHdlZW4gPSBzcGFjZVBlckdhcDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwic3RyZXRjaFwiOlxuICAgICAgICAgICAgICAgIHNwYWNpbmdCZWZvcmUgPSAwO1xuICAgICAgICAgICAgICAgIHNwYWNpbmdCZXR3ZWVuID0gMDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgIC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ICh0b3RhbEdyb3dBbW91bnQpIHtcbiAgICAgICAgICAgIGNvbnN0IGl0ZW1zID0gdGhpcy5fbGluZS5pdGVtcztcbiAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICBsZXQgYW1vdW50UGVyR3JvdyA9IHRoaXMuX2Ftb3VudFJlbWFpbmluZyAvIHRvdGFsR3Jvd0Ftb3VudDtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGZsZXhJdGVtID0gaXRlbS5mbGV4SXRlbTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3Jvd0Ftb3VudCA9IGZsZXhJdGVtLmdyb3c7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzR3Jvd2FibGVJdGVtID0gKGdyb3dBbW91bnQgPiAwKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzR3Jvd2FibGVJdGVtKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JvdyA9IGdyb3dBbW91bnQgKiBhbW91bnRQZXJHcm93O1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF4U2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc01heFNpemVTZXR0aW5nKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1heFNpemUgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPj0gbWF4U2l6ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBBbHJlYWR5IGZ1bGx5IGdyb3duLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncm93ID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXhHcm93ID0gbWF4U2l6ZSAtIHNpemU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRnVsbHlHcm93biA9IChncm93ID49IG1heEdyb3cpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNGdWxseUdyb3duKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncm93ID0gbWF4R3JvdztcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRGVzdHJpYnV0ZSByZW1haW5pbmcgYW1vdW50IG92ZXIgdGhlIG90aGVyIGZsZXggaXRlbXMuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbEdyb3dBbW91bnQgLT0gZ3Jvd0Ftb3VudDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3cgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmluYWxTaXplID0gc2l6ZSArIGdyb3c7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxleEl0ZW0uX3Jlc2l6ZU1haW5BeGlzKGZpbmFsU2l6ZSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9ncm93blNpemUgKz0gZ3JvdztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hbW91bnRSZW1haW5pbmcgLT0gZ3JvdztcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpIDwgMTBlLTYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUodG90YWxHcm93QW1vdW50ICYmIChNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpID4gMTBlLTYpKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRUb3RhbEdyb3dBbW91bnQoKSB7XG4gICAgICAgIGxldCB0b3RhbCA9IDA7XG4gICAgICAgIGNvbnN0IGl0ZW1zID0gdGhpcy5fbGluZS5pdGVtcztcbiAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuX2xpbmUuc3RhcnRJbmRleDsgaSA8PSB0aGlzLl9saW5lLmVuZEluZGV4OyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBpdGVtc1tpXTtcbiAgICAgICAgICAgIGNvbnN0IGZsZXhJdGVtID0gaXRlbS5mbGV4SXRlbTtcblxuICAgICAgICAgICAgaWYgKGZsZXhJdGVtLmdyb3cpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBtYXhTaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWF4U2l6ZVNldHRpbmcoKTtcbiAgICAgICAgICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuXG4gICAgICAgICAgICAgICAgLy8gRXhjbHVkZSB0aG9zZSBhbHJlYWR5IGZ1bGx5IGdyb3duLlxuICAgICAgICAgICAgICAgIGlmIChtYXhTaXplID09PSAwIHx8IHNpemUgPCBtYXhTaXplKSB7XG4gICAgICAgICAgICAgICAgICAgIHRvdGFsICs9IGZsZXhJdGV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3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kXG4gKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS5cbiAqL1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBTaXplU2hyaW5rZXIge1xuXG4gICAgY29uc3RydWN0b3IobGluZSkge1xuICAgICAgICB0aGlzLl9saW5lID0gbGluZTtcbiAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nID0gMDtcbiAgICAgICAgdGhpcy5fc2hydW5rU2l6ZSA9IDA7XG4gICAgfVxuXG4gICAgc2hyaW5rKGFtb3VudCkge1xuICAgICAgICB0aGlzLl9zaHJ1bmtTaXplID0gMDtcblxuICAgICAgICB0aGlzLl9hbW91bnRSZW1haW5pbmcgPSBhbW91bnQ7XG4gICAgICAgIGxldCB0b3RhbFNocmlua0Ftb3VudCA9IHRoaXMuX2dldFRvdGFsU2hyaW5rQW1vdW50KCk7XG4gICAgICAgIGlmICh0b3RhbFNocmlua0Ftb3VudCkge1xuICAgICAgICAgICAgY29uc3QgaXRlbXMgPSB0aGlzLl9saW5lLml0ZW1zO1xuICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIGxldCBhbW91bnRQZXJTaHJpbmsgPSB0aGlzLl9hbW91bnRSZW1haW5pbmcgLyB0b3RhbFNocmlua0Ftb3VudDtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGZsZXhJdGVtID0gaXRlbS5mbGV4SXRlbTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hyaW5rQW1vdW50ID0gZmxleEl0ZW0uc2hyaW5rO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1Nocmlua2FibGVJdGVtID0gKHNocmlua0Ftb3VudCA+IDApO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNTaHJpbmthYmxlSXRlbSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNocmluayA9IHNocmlua0Ftb3VudCAqIGFtb3VudFBlclNocmluaztcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1pblNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNNaW5TaXplKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPiBtaW5TaXplKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF4U2hyaW5rID0gc2l6ZSAtIG1pblNpemU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNGdWxseVNocnVuayA9IChzaHJpbmsgPj0gbWF4U2hyaW5rKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNGdWxseVNocnVuaykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaHJpbmsgPSBtYXhTaHJpbms7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRGVzdHJpYnV0ZSByZW1haW5pbmcgYW1vdW50IG92ZXIgdGhlIG90aGVyIGZsZXggaXRlbXMuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsU2hyaW5rQW1vdW50IC09IHNocmlua0Ftb3VudDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaW5hbFNpemUgPSBzaXplIC0gc2hyaW5rO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsZXhJdGVtLl9yZXNpemVNYWluQXhpcyhmaW5hbFNpemUpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2hydW5rU2l6ZSArPSBzaHJpbms7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nIC09IHNocmluaztcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpIDwgMTBlLTYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUodG90YWxTaHJpbmtBbW91bnQgJiYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPiAxMGUtNikpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldFRvdGFsU2hyaW5rQW1vdW50KCkge1xuICAgICAgICBsZXQgdG90YWwgPSAwO1xuICAgICAgICBjb25zdCBpdGVtcyA9IHRoaXMuX2xpbmUuaXRlbXM7XG4gICAgICAgIGZvciAobGV0IGkgPSB0aGlzLl9saW5lLnN0YXJ0SW5kZXg7IGkgPD0gdGhpcy5fbGluZS5lbmRJbmRleDsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07XG4gICAgICAgICAgICBjb25zdCBmbGV4SXRlbSA9IGl0ZW0uZmxleEl0ZW07XG5cbiAgICAgICAgICAgIGlmIChmbGV4SXRlbS5zaHJpbmspIHtcbiAgICAgICAgICAgICAgICBjb25zdCBtaW5TaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWluU2l6ZSgpO1xuICAgICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCk7XG5cbiAgICAgICAgIC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KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlLmRhdGEudHlwZSA9PSAnZGF0YScpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmluaXNoKGl0ZW0sIGUuZGF0YS5pbmZvKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXJyb3IoaXRlbSwgZS5kYXRhLmluZm8pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgY3JlYXRlKHNyYykge1xuICAgICAgICBjb25zdCBpZCA9ICsrdGhpcy5faWQ7XG4gICAgICAgIGNvbnN0IGl0ZW0gPSBuZXcgSW1hZ2VXb3JrZXJJbWFnZSh0aGlzLCBpZCwgc3JjKTtcbiAgICAgICAgdGhpcy5faXRlbXMuc2V0KGlkLCBpdGVtKTtcbiAgICAgICAgdGhpcy5fd29ya2VyLnBvc3RNZXNzYWdlKHt0eXBlOiBcImFkZFwiLCBpZDogaWQsIHNyYzogc3JjfSk7XG4gICAgICAgIHJldHVybiBpdGVtO1xuICAgIH1cblxuICAgIGNhbmNlbChpbWFnZSkge1xuICAgICAgICB0aGlzLl93b3JrZXIucG9zdE1lc3NhZ2Uoe3R5cGU6IFwiY2FuY2VsXCIsIGlkOiBpbWFnZS5pZH0pO1xuICAgICAgICB0aGlzLl9pdGVtcy5kZWxldGUoaW1hZ2UuaWQpO1xuICAgIH1cblxuICAgIGVycm9yKGltYWdlLCBpbmZvKSB7XG4gICAgICAgIGltYWdlLmVycm9yKGluZm8pO1xuICAgICAgICB0aGlzLl9pdGVtcy5kZWxldGUoaW1hZ2UuaWQpO1xuICAgIH1cblxuICAgIGZpbmlzaChpbWFnZSwgaW5mbykge1xuICAgICAgICBpbWFnZS5sb2FkKGluZm8pO1xuICAgICAgICB0aGlzLl9pdGVtcy5kZWxldGUoaW1hZ2U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WxsO1xuICAgICAgICBkZWxldGUgdGhpcy5zdGFnZTtcbiAgICB9XG5cbiAgICBzdGFydExvb3AoKSB7XG4gICAgICAgIHRoaXMuX2xvb3BpbmcgPSB0cnVlO1xuICAgICAgICBpZiAoIXRoaXMuX2F3YWl0aW5nTG9vcCkge1xuICAgICAgICAgICAgdGhpcy5sb29wKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdG9wTG9vcCgpIHtcbiAgICAgICAgdGhpcy5fbG9vcGluZyA9IGZhbHNlO1xuICAgIH1cblxuICAgIHN3aXRjaExvb3AoKSB7XG4gICAgICAgIGlmICh0aGlzLl9vbklkbGUgPT09IGZhbHNlKSB7XG4gICAgICAgICAgICB0aGlzLl9vbklkbGUgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5zdGFnZS5vbklkbGUoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9pZGxlTG9vcENvdW50ZXIgPCB0aGlzLl9pZGxlTG9vcERlbGF5KSB7XG4gICAgICAgICAgICB0aGlzLl9pZGxlTG9vcENvdW50ZXIrKztcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuc3RhZ2UuY3R4Lmhhc1JlbmRlclVwZGF0ZXMoKSkge1xuICAgICAgICAgICAgdGhpcy5zdG9wTG9vcCgpO1xuICAgICAgICAgICAgdGhpcy5fbG9vcEhhbmRsZXIgPSBzZXRJbnRlcnZhbCgoKSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5zdGFnZS51cGRhdGVGcmFtZSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuaWRsZUZyYW1lKCk7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhZ2UuY3R4Lmhhc1JlbmRlclVwZGF0ZXMoKSkge1xuICAgICAgICAgICAgICAgICAgICBjbGVhckludGVydmFsKHRoaXMuX2xvb3BIYW5kbGVyKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGFydExvb3AoKTtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfSwgMTAwMCAvIDYwKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX2lkbGVMb29wQ291bnRlciA9IDA7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBsb29wKCkge1xuICAgICAgICBsZXQgc2VsZiA9IHRoaXM7XG4gICAgICAgIGxldCBscCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHNlbGYuX2F3YWl0aW5nTG9vcCA9IGZhbHNlO1xuICAgICAgICAgICAgc2VsZi5fb25JZGxlID0gZmFsc2U7XG4gICAgICAgICAgICBpZiAoc2VsZi5fbG9vcGluZykge1xuICAgICAgICAgICAgICAgIHNlbGYuc3RhZ2UudXBkYXRlRnJhbWUoKTtcbiAgICAgICAgICAgICAgICBpZiAoc2VsZi5zdGFnZS5nZXRPcHRpb24oXCJwYXVzZVJhZkxvb3BPbklkbGVcIikpIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5zd2l0Y2hMb29wKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHNlbGYuc3RhZ2UucmVuZGVyRnJhbWUoKTtcbiAgICAgICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUobHApO1xuICAgICAgICAgICAgICAgIHNlbGYuX2F3YWl0aW5nTG9vcCA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmVxdWVzdEFuaW1hdGlvbkZyYW1lKGxwKTtcbiAgICB9XG5cbiAgICB1cGxvYWRDb21wcmVzc2VkR2xUZXh0dXJlKGdsLCB0ZXh0dXJlU291cmNlLCBzb3VyY2UsIG9wdGlvbnMpIHtcbiAgICAgICAgY29uc3QgdmlldyA9ICFzb3VyY2UucHZyID8gbmV3IERhdGFWaWV3KHNvdXJjZS5taXBtYXBzWzBdKSA6IHNvdXJjZ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ZGYWNlczogdmlldy5nZXRVaW50MzIoNTIsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgbnVtYmVyT2ZNaXBtYXBMZXZlbHM6IHZpZXcuZ2V0VWludDMyKDU2LCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIGJ5dGVzT2ZLZXlWYWx1ZURhdGE6IHZpZXcuZ2V0VWludDMyKDYwLCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIGt2cHM6IFtdLFxuICAgICAgICAgICAgICAgIG1pcG1hcHM6IFtdLFxuICAgICAgICAgICAgICAgIGdldCB3aWR0aCgpIHsgcmV0dXJuIHRoaXMucGl4ZWxXaWR0aCB9LFxuICAgICAgICAgICAgICAgIGdldCBoZWlnaHQoKSB7IHJldHVybiB0aGlzLnBpeGVsSGVpZ2h0IH0sXG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBjb25zdCBwcm9wcyA9IChvYmopID0+IHtcbiAgICAgICAgICAgICAgICBjb25zdCBwID0gW107XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgdiBpbiBvYmopIHtcbiAgICAgICAgICAgICAgICAgICAgcC5wdXNoKG9ialt2XSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBwO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCBmb3JtYXRzID0gT2JqZWN0LnZhbHVlcyhzZWxmLnN0YWdlLnJlbmRlcmVyLmdldENvbXByZXNzZWRUZXh0dXJlRXh0ZW5zaW9ucygpKVxuICAgICAgICAgICAgICAgIC5maWx0ZXIoKG9iaikgPT4gb2JqICE9IG51bGwpXG4gICAgICAgICAgICAgICAgLm1hcCgob2JqKSA9PiBwcm9wcyhvYmopKVxuICAgICAgICAgICAgICAgIC5yZWR1Y2UoKHByZXYsIGN1cnJlbnQpID0+IHByZXYuY29uY2F0KGN1cnJlbnQpKTtcblxuICAgICAgICAgICAgaWYgKCFmb3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AgICAgICBwaXhlbEhlaWdodDogaGVhZGVyW3B2ckhlaWdodF0sXG4gICAgICAgICAgICAgICAgbnVtYmVyT2ZNaXBtYXBMZXZlbHM6IGhlYWRlcltwdnJNaXBtYXBDb3VudF0sXG4gICAgICAgICAgICAgICAgbWlwbWFwczogW10sXG4gICAgICAgICAgICAgICAgcHZyOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldCB3aWR0aCgpIHsgcmV0dXJuIHRoaXMucGl4ZWxXaWR0aCB9LFxuICAgICAgICAgICAgICAgIGdldCBoZWlnaHQoKSB7IHJldHVybiB0aGlzLnBpeGVsSGVpZ2h0IH0sXG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBsZXQgb2Zmc2V0ID0gMFxuICAgICAgICAgICAgbGV0IHdpZHRoID0gZGF0YS5waXhlbFdpZHRoO1xuICAgICAgICAgICAgbGV0IGhlaWdodCA9IGRhdGEucGl4ZWxIZWlnaHQ7XG5cbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgZGF0YS5udW1iZXJPZk1pcG1hcExldmVsczsgaSsrKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbGV2ZWwgPSAoKHdpZHRoICsgMykgPj4gMikgKiAoKGhlaWdodCArIDMpID4+IDIpICogODtcbiAgICAgICAgICAgICAgICBjb25zdCB2aWV3ID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlCdWZmZXIsIHB2cnRjRGF0YS5ieXRlT2Zmc2V0ICsgb2Zmc2V0LCBsZXZlbCk7XG4gICAgICAgICAgICAgICAgZGF0YS5taXBtYXBzLnB1c2godmlldyk7XG4gICAgICAgICAgICAgICAgb2Zmc2V0ICs9IGxldmVsO1xuICAgICAgICAgICAgICAgIHdpZHRoID0gd2lkdGggPj4gMTtcbiAgICAgICAgICAgICAgICBoZWlnaHQgPSBoZWlnaHQgPj4gMTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgICAgIHNvdXJjZTogZGF0YSxcbiAgICAgICAgICAgICAgICByZW5kZXJJbmZvOiB7IHNyYzogc3JjLCBjb21wcmVzc2VkOiB0cnVlIH0sXG4gICAgICAgICAgICB9KVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgbG9hZFNyY1RleHR1cmUoeyBzcmMsIGhhc0FscGhhIH0sIGNiKSB7XG4gICAgICAgIGxldCBjYW5jZWxDYiA9IHVuZGVmaW5lZDtcbiAgICAgICAgbGV0IGlzUG5nID0gKHNyYy50b0xvd2VyQ2FzZSgpLmluZGV4T2YoXCIucG5nXCIpID49IDApIHx8IHNyYy5zdWJzdHIoMCwgMjEpID09ICdkYXRhOmltYWdlL3BuZztiYXNlNjQnO1xuICAgICAgICBsZXQgaXNLdHggPSBzcmMuaW5kZXhPZignLmt0eCcpID49IDA7XG4gICAgICAgIGxldCBpc1B2ciA9IHNyYy5pbmRleE9mKCcucHZyJykgPj0gMDtcbiAgICAgICAgaWYgKGlzS3R4IHx8IGlzUHZyKSB7XG4gICAgICAgICAgICBsZXQgcmVxdWVzdCA9IG5ldyBYTUxIdHRwUmVxdWVzdCgpO1xuICAgICAgICAgICAgcmVxdWVzdC5hZGRFdmVudExpc3RlbmVyKFxuICAgICAgICAgICAgICAgIFwibG9hZFwiLCBpc0t0eCA/IHRoaXMuaGFuZGxlS3R4TG9hZChjYiwgc3JjKSA6IHRoaXMuaGFuZGxlUHZyTG9hZChjYiwgc3JjKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIHJlcXVlc3Qub3BlbihcIkdFVFwiLCBzcmMpO1xuICAgICAgICAgICAgcmVxdWVzdC5yZXNwb25zZVR5cGUgPSBcImFycmF5YnVmZmVyXCI7XG4gICAgICAgICAgICByZXF1ZXN0LnNlbmQoKTtcbiAgICAgICAgICAgIGNhbmNlbENiID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHJlcXVlc3QuYWJvcnQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9pbWFnZVdvcmtlcikge1xuICAgICAgICAgICAgLy8gV1BFLXNwZWNpZmljIGltYWdlIHBhcnNlci5cbiAgICAgICAgICAgIGNvbnN0IGltYWdlID0gdGhpcy5faW1hZ2VXb3JrZXIuY3JlYXRlKHNyYyk7XG4gICAgICAgICAgICBpbWFnZS5vbkVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYihcIkltYWdlIGxvYWQgZXJyb3JcIik7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaW1hZ2Uub25Mb2FkID0gZnVuY3Rpb24gKHsgaW1hZ2VCaXRtYXAsIGhhc0FscGhhQ2hhbm5lbCB9KSB7XG4gICAgICAgICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IGltYWdlQml0bWFwLFxuICAgICAgICAgICAgICAgICAgICByZW5kZXJJbmZvOiB7IHNyYzogc3JjLCBjb21wcmVzc2VkOiBmYWxzZSB9LFxuICAgICAgICAgICAgICAgICAgICBoYXNBbHBoYTogaGFzQWxwaGFDaGFubmVsLFxuICAgICAgICAgICAgICAgICAgICBwcmVtdWx0aXBseUFscGhhOiB0cnVlXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgY2FuY2VsQ2IgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaW1hZ2UuY2FuY2VsKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsZXQgaW1hZ2UgPSBuZXcgSW1hZ2UoKTtcblxuICAgICAgICAgICAgLy8gT24gdGhlIFBTNCBwbGF0Zm9ybSBzZXR0aW5nIHRoZSBgY3Jvc3NPcmlnaW5gIGF0dHJpYnV0ZSBvblxuICAgICAgICAgICAgLy8gaW1hZ2VzIGNhbiBjYXVzZSBDT1JTIGZhaWx1cmVzLlxuICAgICAgICAgICAgaWYgKCEoc3JjLnN1YnN0cigwLCA1KSA9PSBcImRhdGE6XCIpICYmICFVdGlscy5pc1BTNCkge1xuICAgICAgICAgICAgICAgIC8vIEJhc2U2NC5cbiAgICAgICAgICAgICAgICBpbWFnZS5jcm9zc09yaWdpbiA9IFwiQW5vbnltb3VzXCI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpbWFnZS5vbmVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIC8vIElnbm9yZSBlcnJvciBtZXNzYWdlIHdoZW4gY2FuY2VsbGVkLlxuICAgICAgICAgICAgICAgIGlmIChpbWFnZS5zcmMpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNiKFwiSW1hZ2UgbG9hZCBlcnJvclwiKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaW1hZ2Uub25sb2FkID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgICAgICAgICAgc291cmNlOiBpbWFnZSxcbiAgICAgICAgICAgICAgICAgICAgcmVuZGVySW5mbzogeyBzcmM6IHNyYywgY29tcHJlc3NlZDogZmFsc2UgfSxcbiAgICAgICAgICAgICAgICAgICAgaGFzQWxwaGE6IGlzUG5nIHx8IGhhc0FscGhhXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaW1hZ2Uuc3JjID0gc3JjO1xuXG4gICAgICAgICAgICBjYW5jZWxDYiA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpbWFnZS5vbmVycm9yID0gbnVsbDtcbiAgICAgICAgICAgICAgICBpbWFnZS5vbmxvYWQgPSBudWxsO1xuICAgICAgICAgICAgICAgIGltYWdlLnJlbW92ZUF0dHJpYnV0ZSgnc3JjJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZ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NhbnZhcycpO1xuXG4gICAgICAgIGlmICh3ICYmIGgpIHtcbiAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IHc7XG4gICAgICAgICAgICBjYW52YXMuaGVpZ2h0ID0gaDtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBjMmQgPSBjYW52YXMuZ2V0Q29udGV4dCgnMmQnKTtcbiAgICAgICAgaWYgKCFjMmQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignVGhpcyBicm93c2VyIGRvZXMgbm90IHN1cHBvcnQgMmQgY2FudmFzLicpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGMyZDtcbiAgICB9XG5cbiAgICBnZXRIclRpbWUoKSB7XG4gICAgICAgIHJldHVybiB3aW5kb3cucGVyZm9ybWFuY2UgPyB3aW5kb3cucGVyZm9ybWFuY2Uubm93KCkgOiAobmV3IERhdGUoKSkuZ2V0VGltZSgpO1xuICAgIH1cblxuICAgIGdldERyYXdpbmdDYW52YXMoKSB7XG4gICAgICAgIC8vIFdlIGNhbid0IHJldXNlIHRoaXMgY2FudmFzIGJlY2F1c2UgdGV4dHVyZXMgbWF5IGxvYWQgYXN5bmMuXG4gICAgICAgIHJldHVybiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdjYW52YXMnKTtcbiAgICB9XG5cbiAgICBnZXRUZXh0dXJlT3B0aW9uc0ZvckRyYXdpbmdDYW52YXMoY2FudmFzKSB7XG4gICAgICAgIGxldCBvcHRpb25zID0ge307XG4gICAgICAgIG9wdGlvbnMuc291cmNlID0gY2FudmFzO1xuICAgICAgICByZXR1cm4gb3B0aW9ucztcbiAgICB9XG5cbiAgICBuZXh0RnJhbWUoY2hhbmdlcykge1xuICAgICAgICAvKiBXZWJHTCBibGl0cyBhdXRvbWF0aWNhbGx5ICovXG4gICAgfVxuXG4gICAgcmVnaXN0ZXJLZXlkb3duSGFuZGxlcihrZXloYW5kbGVyKSB7XG4gICAgICAgIHRoaXMuX2tleWR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RleHRzID0gW107XG4gICAgICAgIHRoaXMubW9kZXMgPSBbXTtcbiAgICB9XG5cbiAgICBzZXRSZW5kZXJDb250ZXh0KGluZGV4LCB2KSB7XG4gICAgICAgIHRoaXMucmVuZGVyQ29udGV4dHNbaW5kZXhdID0gdjtcbiAgICB9XG5cbiAgICBzZXRTaW1wbGVUYyhpbmRleCwgdikge1xuICAgICAgICBpZiAodikge1xuICAgICAgICAgICAgdGhpcy5tb2Rlc1tpbmRleF0gfD0gMTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMubW9kZXNbaW5kZXhdIC09ICh0aGlzLm1vZGVzW2luZGV4XSAmIDEpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0V2hpdGUoaW5kZXgsIHYpIHtcbiAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgIHRoaXMubW9kZXNbaW5kZXhdIHw9IDI7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLm1vZGVzW2luZGV4XSAtPSAodGhpcy5tb2Rlc1tpbmRleF0gJiAyKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldFJlbmRlckNvbnRleHQoaW5kZXgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMucmVuZGVyQ29udGV4dHNbaW5kZXhdO1xuICAgIH1cblxuICAgIGdldFNpbXBsZVRjKGluZGV4KSB7XG4gICAgICAgIHJldHVybiAodGhpcy5tb2Rlc1tpbmRleF0gJiAxKTtcbiAgICB9XG5cbiAgICBnZXRXaGl0ZShpbmRleCkge1xuICAgICAgICByZXR1cm4gKHRoaXMubW9kZXNbaW5kZXhdICYgMik7XG4gICAgfVxuXG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXM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BpdGVtID0gdGhpcy5nZXQoY29sb3IpO1xuICAgICAgICBpdGVtLmxmID0gZnJhbWU7XG4gICAgICAgIGl0ZW0udHggPSB0ZXh0dXJlO1xuICAgICAgICBpdGVtLnUgPSBmcmFtZTtcbiAgICAgICAgdGhpcy5fbWVtVGV4dHVyZXMrKztcbiAgICB9XG5cbiAgICBjbGVhbnVwKGZyYW1lKSB7XG4gICAgICAgIC8vIFdlIG9ubHkgbmVlZCB0byBjbGVhbiB1cCBvbmNlIHBlciBmcmFtZS5cbiAgICAgICAgaWYgKHRoaXMuX2xhc3RDbGVhbnVwRnJhbWUgIT09IGZyYW1lKSB7XG5cbiAgICAgICAgICAgIC8vIFdlIGxpbWl0IGJsYW5jbyB0ZXh0dXJlcyByZXVzZSB0byBvbmUgZnJhbWUgb25seSB0byBwcmV2ZW50IG1lbW9yeSB1c2FnZSBncm93dGguXG4gICAgICAgICAgICB0aGlzLl9ibGFuY29UZXh0dXJlcyA9IFtdO1xuXG4gICAgICAgICAgICB0aGlzLl9jb2xvcnMuZm9yRWFjaCgoaXRlbSwgY29sb3IpID0+IHtcbiAgICAgICAgICAgICAgICAvLyBDbGVhbiB1cCBlbnRyaWVzIHRoYXQgd2VyZSBub3QgdXNlZCBsYXN0IGZyYW1lLlxuICAgICAgICAgICAgICAgIGlmIChpdGVtLmxmIDwgZnJhbWUgLSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLnR4KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBLZWVwIGFzIHJldXNhYmxlIGJsYW5jbyB0ZXh0dXJlLlxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmxhbmNvVGV4dHVyZXMucHVzaChpdGVtLnR4KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb2xvcnMuZGVsZXRlKGNvbG9yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcblxuICAgICAg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hdGlvbi5nZXRTaW1wbGVUYyhpKTtcblxuICAgICAgICAgICAgLy9AdG9kbzogdHJ5IHRvIG9wdGltaXplIG91dCBwZXItZHJhdyB0cmFuc2Zvcm0gc2V0dGluZy4gc3BsaXQgdHJhbnNsYXRlLCB0cmFuc2Zvcm0uXG4gICAgICAgICAgICBjb25zdCBwcmVjaXNpb24gPSB0aGlzLmN0eC5zdGFnZS5nZXRSZW5kZXJQcmVjaXNpb24oKTtcbiAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0ocmMudGEgKiBwcmVjaXNpb24sIHJjLnRjICogcHJlY2lzaW9uLCByYy50YiAqIHByZWNpc2lvbiwgcmMudGQgKiBwcmVjaXNpb24sIHJjLnB4ICogcHJlY2lzaW9uLCByYy5weSAqIHByZWNpc2lvbik7XG5cbiAgICAgICAgICAgIGNvbnN0IHJlY3QgPSAodHggPT09IHRoaXMuX3JlY3RhbmdsZVRleHR1cmUpO1xuICAgICAgICAgICAgY29uc3QgaW5mbyA9IHtvcGVyYXRpb24sIHRhcmdldCwgaW5kZXg6IGksIHJlY3R9O1xuXG4gICAgICAgICAgICBpZiAocmVjdCkge1xuICAgICAgICAgICAgICAgIC8vIENoZWNrIGZvciBncmFkaWVudC5cbiAgICAgICAgICAgICAgICBpZiAod2hpdGUpIHtcbiAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9ICd3aGl0ZSc7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0Q29sb3JHcmFkaWVudChjdHgsIHZjKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQWxwaGEgPSByYy5hbHBoYTtcbiAgICAgICAgICAgICAgICB0aGlzLl9iZWZvcmVEcmF3RWwoaW5mbyk7XG4gICAgICAgICAgICAgICAgY3R4LmZpbGxSZWN0KDAsIDAsIHZjLncsIHZjLmgpO1xuICAgICAgICAgIC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Y29sb3JCcl0pO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYWxwaGEgPSAoKGNvbG9yIC8gMTY3NzcyMTYpIHwgMCkgLyAyNTUuMDtcbiAgICAgICAgICAgICAgICAgICAgY3R4Lmdsb2JhbEFscGhhICo9IGFscGhhO1xuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJnYiA9IGNvbG9yICYgMHgwMEZGRkZGRjtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGludFRleHR1cmUgPSB0aGlzLl90aW50TWFuYWdlci5nZXRUaW50VGV4dHVyZSh0eCwgcmdiKTtcblxuICAgICAgICAgICAgICAgICAgICAvLyBBY3R1YWxseSBkcmF3IHJlc3VsdC5cbiAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9ICd3aGl0ZSc7XG4gICAgICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UodGludFRleHR1cmUsIHNvdXJjZVgsIHNvdXJjZVksIHNvdXJjZVcsIHNvdXJjZUgsIDAsIDAsIHZjLncsIHZjLmgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSAnd2hpdGUnO1xuICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKHR4LCBzb3VyY2VYLCBzb3VyY2VZLCBzb3VyY2VXLCBzb3VyY2VILCAwLCAwLCB2Yy53LCB2Yy5oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fYWZ0ZXJEcmF3RWwoaW5mbyk7XG4gICAgICAgICAgICAgICAgY3R4Lmdsb2JhbEFscGhhID0gMS4wO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3NldENvbG9yR3JhZGllbnQoY3R4LCB2YywgdyA9IHZjLncsIGggPSB2Yy5oLCB0cmFuc3BhcmVuY3kgP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nKHZjLl9jb2xvclVsKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5hZGRDb2xvclN0b3AoMSwgU3RhZ2VVdGlscy5nZXRSZ2JTdHJpbmcodmMuX2NvbG9yQmwpKTtcblxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBOb3Qgc3VwcG9ydGVkIGdyYWRpZW50LlxuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHZjLl9jb2xvclVsID09PSB2Yy5fY29sb3JCbCAmJiB2Yy5fY29sb3JVciA9PT0gdmMuX2NvbG9yQnIpIHtcbiAgICAgICAgICAgICAgICAvLyBIb3Jpem9udGFsIGdyYWRpZW50LlxuICAgICAgICAgICAgICAgIGdyYWRpZW50ID0gY3R4LmNyZWF0ZUxpbmVhckdyYWRpZW50KDAsIDAsIHcsIDApO1xuICAgICAgICAgICAgICAgIGlmICh0cmFuc3BhcmVuY3kpIHtcbiAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuYWRkQ29sb3JTdG9wKDAsIFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyh2Yy5fY29sb3JVbCkpO1xuICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5hZGRDb2xvclN0b3AoMSwgU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHZjLl9jb2xvckJyKSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuYWRkQ29sb3JTdG9wKDAsIFN0YWdlVXRpbHMuZ2V0UmdiU3RyaW5nKHZjLl9jb2xvclVsKSk7XG4gICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LmFkZENvbG9yU3RvcCgxLCBTdGFnZVV0aWxzLmdldFJnYlN0cmluZyh2Yy5fY29sb3JCcikpO1xuICAgICAgICAgICA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AgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBnbC5iaW5kVGV4dHVyZShnbC5URVhUVVJFXzJELCBnbFRleHR1cmUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZ2wuZHJhd0VsZW1lbnRzKGdsLlRSSUFOR0xFUywgNiAqIChpIC0gcG9zKSwgZ2wuVU5TSUdORURfU0hPUlQsIChwb3MgKyBvcGVyYXRpb24uaW5kZXgpICogNiAqIDIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGdsVGV4dHVyZSA9IHR4O1xuICAgICAgICAgICAgICAgICAgICBwb3MgPSBpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChwb3MgPCBsZW5ndGgpIHtcbiAgICAgICAgICAgICAgICBpZiAoZ2xUZXh0dXJlLm9wdGlvbnMgJiYgZ2xUZXh0dXJlLm9wdGlvbnMuaW1hZ2VSZWYpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJlY2lzaW9uID0gdGhpcy5jdHguc3RhZ2UuZ2V0T3B0aW9uKCdwcmVjaXNpb24nKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHZjID0gb3BlcmF0aW9uLmdldEVsZW1lbnRDb3JlKHBvcyk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0YWdlLnBsYXRmb3JtLnBhaW50KGdsLCBnbFRleHR1cmUub3B0aW9ucy5pbWFnZVJlZiwgdmMuX3dvcmxkQ29udGV4dC5weCpwcmVjaXNpb24sIHZjLl93b3JsZENvbnRleHQucHkqcHJlY2lzaW9uLCB2Yy5fY29sb3JVbCwgdmMpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGdsLmJpbmRUZXh0dXJlKGdsLlRFWFRVUkVfMkQsIGdsVGV4dHVyZSk7XG4gICAgICAgICAgICAgICAgICAgIG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WZmZXIoYnl0ZVNpemUpO1xuICAgICAgICB0aGlzLmZsb2F0cyA9IG5ldyBGbG9hdDMyQXJyYXkodGhpcy5kYXRhKTtcbiAgICAgICAgdGhpcy51aW50cyA9IG5ldyBVaW50MzJBcnJheSh0aGlzLmRhdGEpO1xuICAgIH1cblxuICAgIGdldEF0dHJpYnNEYXRhQnl0ZU9mZnNldChpbmRleCkge1xuICAgICAgICAvLyBXaGVyZSB0aGlzIHF1YWQgY2FuIGJlIGZvdW5kIGluIHRoZSBhdHRyaWJzIGJ1ZmZlci5cbiAgICAgICAgcmV0dXJuIGluZGV4ICogODA7XG4gICAgfVxuXG4gICAgZ2V0UXVhZENvbnRlbnRzKCkge1xuICAgICAgICAvLyBEZWJ1ZzogbG9nIGNvbnRlbnRzIG9mIHF1YWQgYnVmZmVyLlxuICAgICAgICBsZXQgZmxvYXRzID0gdGhpcy5mbG9hdHM7XG4gICAgICAgIGxldCB1aW50cyA9IHRoaXMudWludHM7XG4gICAgICAgIGxldCBsaW5lcyA9IFtdO1xuICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8PSB0aGlzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgc3RyID0gJ2VudHJ5ICcgKyBpICsgJzogJztcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgNDsgaisrKSB7XG4gICAgICAgICAgICAgICAgbGV0IGIgPSBpICogMjAgKyBqICogNDtcbiAgICAgICAgICAgICAgICBzdHIgKz0gZmxvYXRzW2JdICsgJywnICsgZmxvYXRzW2IrMV0gKyAnOicgKyBmbG9hdHNbYisyXSArICcsJyArIGZsb2F0c1tiKzNdICsgJ1snICsgdWludHNbYis0XS50b1N0cmluZygxNikgKyAnXSAnO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGluZXMucHVzaChzdHIpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGxpbmVzO1xuICAgIH1cblxuXG59XG4iLCIvKlxuICogSWYg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GdsLkNPTE9SX0FUVEFDSE1FTlQwLCBnbC5URVhUVVJFXzJELCBnbFRleHR1cmUsIDApO1xuXG4gICAgICAgIHJldHVybiBnbFRleHR1cmU7XG4gICAgfVxuXG4gICAgZnJlZVJlbmRlclRleHR1cmUoZ2xUZXh0dXJlKSB7XG4gICAgICAgIGxldCBnbCA9IHRoaXMuc3RhZ2UuZ2w7XG4gICAgICAgIGdsLmRlbGV0ZUZyYW1lYnVmZmVyKGdsVGV4dHVyZS5mcmFtZWJ1ZmZlcik7XG4gICAgICAgIGdsLmRlbGV0ZVRleHR1cmUoZ2xUZXh0dXJlKTtcbiAgICB9XG5cbiAgICBfZ2V0Qnl0ZXNQZXJQaXhlbChmbXQsIHR5cGUpIHtcbiAgICAgICAgY29uc3QgZ2wgPSB0aGlzLnN0YWdlLmdsO1xuXG4gICAgICAgIGlmIChmbXQgPT09IGdsLlJHQkEpIHtcbiAgICAgICAgICAgIHN3aXRjaCAodHlwZSkge1xuICAgICAgICAgICAgICAgIGNhc2UgZ2wuVU5TSUdORURfQllURTpcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDQ7XG5cbiAgICAgICAgICAgICAgICBjYXNlIGdsLlVOU0lHTkVEX1NIT1JUXzRfNF80XzQ6XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAyO1xuXG4gICAgICAgICAgICAgICAgY2FzZSBnbC5VTlNJR05FRF9TSE9SVF81XzVfNV8xOlxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gMjtcblxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCB0eXBlIHNwZWNpZmllZCBmb3IgR0xfUkdCQSBmb3JtYXQnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChmbXQgPT09IGdsLlJHQikge1xuICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7XG4gICAgICAgICAgICAgICAgY2FzZSBnbC5VTlNJR05FRF9CWVRFOlxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gMztcblxuICAgICAgICAgICAgICAgIGNhc2UgZ2wuVU5TSUdORURfQllURV81XzZfNTpcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDI7XG5cbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0ludmFsaWQgdHlwZSBzcGVjaWZpZWQgZm9yIEdMX1JHQiBmb3JtYXQnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCBmb3JtYXQgc3BlY2lmaWVkIGluIGNhbGwgdG8gX2dldEJ5dGVzUGVyUGl4ZWwoKScpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgdXBsb2FkVGV4dHVyZVNvdXJjZSh0ZXh0dXJlU291cmNlLCBvcHRpb25zKSB7XG4gICAgICAgIGNvbnN0IGdsID0gdGhpcy5zdGFnZS5nbDtcblxuICAgICAgICBjb25zdCBzb3VyY2UgPSBvcHRpb25zLnNvdXJjZTtcbiAgICAgICAgbGV0IGNvbXByZXNzZWQgPSBmYWxzZTtcbiAgICAgICAgaWYgKG9wdGlvbnMucmVuZGVySW5mbykge1xuICAgICAgICAgICAgY29tcHJlc3NlZCA9IG9wdGlvbnMucmVuZGVySW5mby5jb21wcmVzc2VkIHx8IGZhbHNlXG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBmb3JtYXQgPSB7XG4gICAgICAgICAgICBwcmVtdWx0aXBseUFscGhhOiB0cnVlLFxuICAgICAgICAgICAgaGFzQWxwaGE6IHRydWVcbiAgICAgICAgfTtcblxuICAgICAgICBpZiAob3B0aW9ucyAmJiBvcHRpb25zLmhhc093blByb3BlcnR5KCdwcmVtdWx0aXBseUFscGhhJykpIHtcbiAgICAgICAgICAgIGZvcm1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7XG4gICAgICAgIHRoaXMuc3RhZ2UuZ2wuZGVsZXRlVGV4dHVyZSh0ZXh0dXJlU291cmNlLm5hdGl2ZVRleHR1cmUpO1xuICAgIH1cblxuICAgIGFkZFF1YWQocmVuZGVyU3RhdGUsIHF1YWRzLCBpbmRleCkge1xuICAgICAgICBsZXQgb2Zmc2V0ID0gKGluZGV4ICogMjApO1xuICAgICAgICBjb25zdCBlbGVtZW50Q29yZSA9IHF1YWRzLnF1YWRFbGVtZW50c1tpbmRleF07XG5cbiAgICAgICAgbGV0IHIgPSBlbGVtZW50Q29yZS5fcmVuZGVyQ29udGV4dDtcblxuICAgICAgICBsZXQgZmxvYXRzID0gcmVuZGVyU3RhdGUucXVhZHMuZmxvYXRzO1xuICAgICAgICBsZXQgdWludHMgPSByZW5kZXJTdGF0ZS5xdWFkcy51aW50cztcbiAgICAgICAgY29uc3QgbWNhID0gU3RhZ2VVdGlscy5tZXJnZUNvbG9yQWxwaGE7XG5cbiAgICAgICAgaWYgKHIudGIgIT09IDAgfHwgci50YyAhPT0gMCkge1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHg7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHk7XG4gICAgICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yVWwsIHIuYWxwaGEpO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHggKyBlbGVtZW50Q29yZS5fdyAqIHIudGE7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl93ICogci50YztcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHk7XG4gICAgICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yVXIsIHIuYWxwaGEpO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHggKyBlbGVtZW50Q29yZS5fdyAqIHIudGEgKyBlbGVtZW50Q29yZS5faCAqIHIudGI7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl93ICogci50YyArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icnk7XG4gICAgICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yQnIsIHIuYWxwaGEpO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHggKyBlbGVtZW50Q29yZS5faCAqIHIudGI7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icnk7XG4gICAgICAgICAgICB1aW50c1tvZmZzZXRdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvckJsLCByLmFscGhhKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIC8vIFNpbXBsZS5cbiAgICAgICAgICAgIGxldCBjeCA9IHIucHggKyBlbGVtZW50Q29yZS5fdyAqIHIudGE7XG4gICAgICAgICAgICBsZXQgY3kgPSByLnB5ICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuXG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHg7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVbCwgci5hbHBoYSk7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gY3g7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHk7XG4gICAgICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yVXIsIHIuYWxwaGEpO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGN4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGN5O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JCciwgci5hbHBoYSk7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBjeTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icnk7XG4gICAgICAgICAgICB1aW50c1tvZmZzZXRdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvckJsLCByLmFscGhhKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGlzUmVuZGVyVGV4dHVyZVJldXNhYmxlKHJlbmRlclN0YXRlLCByZW5kZXJUZXh0dXJlSW5mbykge1xuICAgICAgICBsZXQgb2Zmc2V0ID0gKHJlbmRlclN0YXRlLl9yZW5kZXJUZXh0dXJlSW5mby5vZmZzZXQgKiA4MCkgLyA0O1xuICAgICAgICBsZXQgZmxvYXRzID0gcmVuZGVyU3RhdGUucXVhZHMuZmxvYXRzO1xuICAgICAgICBsZXQgdWludHMgPSByZW5kZXJTdGF0ZS5xdWFkcy51aW50cztcbiAgICAgICAgcmV0dXJuICgoZmxvYXRzW29mZnNldF0gPT09IDApICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDFdID09PSAwKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAyXSA9PT0gMCkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgM10gPT09IDApICYmXG4gICAgICAgICAgICAodWludHNbb2Zmc2V0ICsgNF0gPT09IDB4RkZGRkZGRkYpICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDVdID09PSByZW5kZXJUZXh0dXJlSW5mby53KSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyA2XSA9PT0gMCkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgN10gPT09IDEpICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDhdID09PSAwKSAmJlxuICAgICAgICAgICAgKHVpbnRzW29mZnNldCArIDldID09PSAweEZGRkZGRkZGKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAxMF0gPT09IHJlbmRlclRleHR1cmVJbmZvLncpICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDExXSA9PT0gcmVuZGVyVGV4dHVyZUluZm8uaCkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgMTJdID09PSAxKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAxM10gPT09IDEpICYmXG4gICAgICAgICAgICAodWludHNbb2Zmc2V0ICsgMTRdID09PSAweEZGRkZGRkZGKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAxNV0gPT09IDApICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDE2XSA9PT0gcmVuZGVyVGV4dHVyZUluZm8uaCkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgMTddID09PSAwKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAxOF0gPT09IDEpICYmXG4gICAgICAgICAgICAodWludHNbb2Zmc2V0ICsgMTldID09PSAweEZGRkZGRkZGKSk7XG4gICAgfVxuXG4gICAgZmluaXNoUmVuZGVyU3RhdGUocmVuZGVyU3RhdGUpIHtcbiAgICAgICAgLy8gU2V0IGV4dHJhIHNoYWRlciBhdHRyaWJ1dGUgZGF0YS5cbiAgICAgICAgbGV0IG9mZnNldCA9IHJlbmRlclN0YXRlLmxlbmd0aCAqIDgwO1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHJlbmRlclN0YXRlLnF1YWRPcGVyYXRpb25zLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgcmVuZGVyU3RhdGUucXVhZE9wZXJhdGlvbnNbaV0uZXh0cmFBdHRyaWJzRGF0YUJ5dGVPZmZzZXQgPSBvZmZzZXQ7XG4gICAgICAgICAgICBsZXQgZXh0cmEgPSByZW5kZXJTdGF0ZS5x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dGlvbi5xdWFkcy5mbG9hdHM7XG5cbiAgICAgICAgbGV0IGxlbmd0aCA9IG9wZXJhdGlvbi5sZW5ndGg7XG5cbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xuXG4gICAgICAgICAgICAvLyBDYWxjdWxhdGUgbm9pc2UgdGV4dHVyZSBjb29yZGluYXRlcyBzbyB0aGF0IGl0IHNwYW5zIHRoZSBmdWxsIGVsZW1lbnQuXG4gICAgICAgICAgICBsZXQgYnJ4ID0gb3BlcmF0aW9uLmdldEVsZW1lbnRXaWR0aChpKSAvIHRoaXMuX25vaXNlVGV4dHVyZS5nZXRSZW5kZXJXaWR0aCgpO1xuICAgICAgICAgICAgbGV0IGJyeSA9IG9wZXJhdGlvbi5nZXRFbGVtZW50SGVpZ2h0KGkpIC8gdGhpcy5fbm9pc2VUZXh0dXJlLmdldFJlbmRlckhlaWdodCgpO1xuXG4gICAgICAgICAgICBsZXQgdWx4ID0gMDtcbiAgICAgICAgICAgIGxldCB1bHkgPSAwO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3JhbmRvbSkge1xuICAgICAgICAgICAgICAgIHVseCA9IE1hdGgucmFuZG9tKCk7XG4gICAgICAgICAgICAgICAgdWx5ID0gTWF0aC5yYW5kb20oKTtcblxuICAgICAgICAgICAgICAgIGJyeCArPSB1bHg7XG4gICAgICAgICAgICAgICAgYnJ5ICs9IHVseTtcblxuICAgICAgICAgICAgICAgIGlmIChNYXRoLnJhbmRvbSgpIDwgMC41KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZsaXAgZm9yIG1vcmUgcmFuZG9tbmVzcy5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IHVseDtcbiAgICAgICAgICAgICAgICAgICAgdWx4ID0gYnJ4O1xuICAgICAgICAgICAgICAgICAgICBicnggPSB0O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChNYXRoLnJhbmRvbSgpIDwgMC41KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZsaXAgZm9yIG1vcmUgcmFuZG9tbmVzcy5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IHVseTtcbiAgICAgICAgICAgICAgICAgICAgdWx5ID0gYnJ5O1xuICAgICAgICAgICAgICAgICAgICBicnkgPSB0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gU3BlY2lmeSBhbGwgY29ybmVyIHBvaW50cy5cbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXRdID0gdWx4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCArIDFdID0gdWx5O1xuXG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0ICsgMl0gPSBicng7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0ICsgM10gPSB1bHk7XG5cbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQgKyA0XSA9IGJyeDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQgKyA1XSA9IGJyeTtcblxuICAgICAgICAgICAgZmxvYXRzW29mZnNldCArIDZdID0gdWx4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCArIDddID0gYnJ5O1xuXG4gICAgICAgICAgICBvZmZzZXQgKz0gODtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGJlZm9yZURyYXcob3BlcmF0aW9uKSB7XG4gICAgICAgIGxldCBnbCA9IHRoaXMuZ2w7XG4gICAgICAgIGdsLnZlcnRleEF0dHJpYlBvaW50ZXIodGhpcy5fYXR0cmliKFwiYU5vaXNlVGV4dHVyZUNvb3JkXCIpLCAyLCBnbC5GTE9BVCwgZmFsc2UsIDgsIHRoaXMuZ2V0VmVydGV4QXR0cmliUG9pbnRlck9mZnNldChvcGVyYXRpb24pKTtcblxuICAgICAgICBsZXQgZ2xUZXh0dXJlID0gdGhpcy5fbm9pc2VUZXh0dXJlLnNvdXJjZS5uYXRpdmV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ICAgY29uc3RydWN0b3IoY29udGV4dCkge1xuICAgICAgICBzdXBlcihjb250ZXh0KTtcbiAgICAgICAgdGhpcy5fZmFkZSA9IFswLCAwLCAwLCAwXTtcbiAgICB9XG5cbiAgICBzZXQgdG9wKG51bSkge1xuICAgICAgICB0aGlzLl9mYWRlWzBdID0gbnVtO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCB0b3AoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mYWRlWzBdO1xuICAgIH1cblxuICAgIHNldCByaWdodChudW0pIHtcbiAgICAgICAgdGhpcy5fZmFkZVsxXSA9IG51bTtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBnZXQgcmlnaHQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mYWRlWzFdO1xuICAgIH1cblxuICAgIHNldCBib3R0b20obnVtKSB7XG4gICAgICAgIHRoaXMuX2ZhZGVbMl0gPSBudW07XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IGJvdHRvbSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZhZGVbMl07XG4gICAgfVxuXG4gICAgc2V0IGxlZnQobnVtKSB7XG4gICAgICAgIHRoaXMuX2ZhZGVbM10gPSBudW07XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IGxlZnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mYWRlWzNdO1xuICAgIH1cblxuICAgIHNldCBmYWRlKHYpIHtcbiAgICAgICAgaWYoQXJyYXkuaXNBcnJheSh2KSkge1xuICAgICAgICAgICAgaWYodi5sZW5ndGggPT09IDIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9mYWRlID0gW3ZbMF0sIHZbMV0sIHZbMF0sIHZbMV1dO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZih2Lmxlbmd0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ID0gdmVjMihwb2ludC54LCBwb2ludC55ICsgZmFkZVswXSk7XG4gICAgICAgICAgICBkID0gcG9zMiAtIHBvczE7XG4gICAgICAgICAgICBjID0gZG90KHBvczEsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKGMsIDAuMCwgMS4wKSk7XG4gICAgICAgICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgICAgaWYoZmFkZVsxXSA+IDAuMCkge1xuICAgICAgICAgICAgdmVjMiBwb3MxID0gdmVjMihwb2ludC54IC0gcmVzb2x1dGlvbi54IC0gZmFkZVsxXSwgdlRleHR1cmVDb29yZC55KTtcbiAgICAgICAgICAgIHZlYzIgcG9zMiA9IHZlYzIocG9pbnQueCAtIHJlc29sdXRpb24ueCwgdlRleHR1cmVDb29yZC55KTtcbiAgICAgICAgICAgIGQgPSBwb3MxIC0gcG9zMjtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMiwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzJdID4gMC4wKSB7XG4gICAgICAgICAgICB2ZWMyIHBvczEgPSB2ZWMyKHZUZXh0dXJlQ29vcmQueCwgcG9pbnQueSAtIHJlc29sdXRpb24ueSAtIGZhZGVbMl0pO1xuICAgICAgICAgICAgdmVjMiBwb3MyID0gdmVjMih2VGV4dHVyZUNvb3JkLngsIHBvaW50LnkgLSByZXNvbHV0aW9uLnkpO1xuICAgICAgICAgICAgZCA9IHBvczEgLSBwb3MyO1xuICAgICAgICAgICAgYyA9IGRvdChwb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xuICAgIHNldCBwaXZvdFgodikge1xuICAgICAgICB0aGlzLl9waXZvdFggPSB2ICsgMTtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBnZXQgcGl2b3RZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGl2b3RZO1xuICAgIH1cblxuICAgIHNldCBwaXZvdFkodikge1xuICAgICAgICB0aGlzLl9waXZvdFkgPSB2ICsgMTtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBnZXQgbGlnaHRZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbGlnaHRZO1xuICAgIH1cblxuICAgIHNldCBsaWdodFkodikge1xuICAgICAgICB0aGlzLl9saWdodFkgPSB2O1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBwaXZvdFooKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9waXZvdFo7XG4gICAgfVxuXG4gICAgc2V0IHBpdm90Wih2KSB7XG4gICAgICAgIHRoaXMuX3Bpdm90WiA9IHY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IGxpZ2h0WigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xpZ2h0WjtcbiAgICB9XG5cbiAgICBzZXQgbGlnaHRaKHYpIHtcbiAgICAgICAgdGhpcy5fbGlnaHRaID0gdjtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICB1c2VEZWZhdWx0KCkge1xuICAgICAgICByZXR1cm4gKHRoaXMuX3J4ID09PSAwICYmIHRoaXMuX3J5ID09PSAwICYmIHRoaXMuX3ogPT09IDAgJiYgdGhpcy5fc3RyZW5ndGggPT09IDAgJiYgdGhpcy5fYW1iaWVudCA9PT0gMSk7XG4gICAgfVxuXG59XG5cbkxpZ2h0M2RTaGFkZXIudmVydGV4U2hhZGVyU291cmNlID0gYFxuICAgICNpZmRl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GFyZ2I7XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5pbm5lckNvbG9yO1xuICAgIH1cblxuICAgIGdldCBvdXRlckNvbG9yKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faWM7XG4gICAgfVxuXG4gICAgc2V0IHgoZikge1xuICAgICAgICB0aGlzLl94ID0gZjtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBzZXQgeShmKSB7XG4gICAgICAgIHRoaXMuX3kgPSBmO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIHNldCBwaXZvdCh2KSB7XG4gICAgICAgIGlmKEFycmF5LmlzQXJyYXkodikgJiYgdi5sZW5ndGggPT09IDIpIHtcbiAgICAgICAgICAgIHRoaXMuX3Bpdm90ID0gdjtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmKEFycmF5LmlzQXJyYXkodikpIHtcbiAgICAgICAgICAgIHRoaXMuX3Bpdm90ID0gW3ZbMF0sIHZbMV0gfHwgdlswXV07XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9waXZvdCA9IFt2LCB2XTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBwaXZvdCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3Bpdm90WzBdO1xuICAgIH1cblxuICAgIHNldCBwaXZvdFkoZikge1xuICAgICAgICB0aGlzLl9waXZvdFsxXSA9IGY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHBpdm90WSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3Bpdm90WzFdO1xuICAgIH1cblxuICAgIHNldCBwaXZvdFgoZikge1xuICAgICAgICB0aGlzLl9waXZvdFswXSA9IGY7XG4gICAgICAgIHRoaXMucmVkcmF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9XG4gICAgICAgICAgICBlbHNlIGlmICh2Lmxlbmd0aCA9PT0gNCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JhZGl1cyA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yYWRpdXMgPSBbdlswXSwgdlswXSwgdlswXSwgdlswXV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9yYWRpdXMgPSBbdiwgdiwgdiwgdl07XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBnZXQgcmFkaXVzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmFkaXVzO1xuICAgIH1cblxuICAgIHNldCB0b3BMZWZ0KG51bSkge1xuICAgICAgICB0aGlzLl9yYWRpdXNbMF0gPSBudW07XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHRvcExlZnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yYWRpdXNbMF07XG4gICAgfVxuXG4gICAgc2V0IHRvcFJpZ2h0KG51bSkge1xuICAgICAgICB0aGlzLl9yYWRpdXNbMV0gPSBudW07XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHRvcFJpZ2h0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmFkaXVzWzFdO1xuICAgIH1cblxuICAgIHNldCBib3R0b21SaWdodChudW0pIHtcbiAgICAgICAgdGhpcy5fcmFkaXVzWzJdID0gbnVtO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBib3R0b21SaWdodCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3JhZGl1c1syXTtcbiAgICB9XG5cbiAgICBzZXQgYm90dG9tTGVmdChudW0pIHtcbiAgICAgICAg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HVyZS5nZXRQcmVsb2FkQXJlYSgpO1xuICAgICAgICAgICAgYXJlYS5hcHBlbmRDaGlsZChodG1sRWxlbWVudCk7XG5cbiAgICAgICAgICAgIGh0bWwyY2FudmFzKGh0bWxFbGVtZW50LCB7YmFja2dyb3VuZENvbG9yOiBudWxsLCBzY2FsZTogc2NhbGV9KS50aGVuKGZ1bmN0aW9uKGNhbnZhcykge1xuICAgICAgICAgICAgICAgIGFyZWEucmVtb3ZlQ2hpbGQoaHRtbEVsZW1lbnQpO1xuICAgICAgICAgICAgICAgIGlmIChjYW52YXMuaGVpZ2h0ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBjYihuZXcgRXJyb3IoXCJDYW52YXMgaGVpZ2h0IGlzIDBcIikpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYihudWxsLCB7c291cmNlOiBjYW52YXMsIHdpZHRoOiBjYW52YXMud2lkdGgsIGhlaWdodDogY2FudmFzLmhlaWdodH0pO1xuICAgICAgICAgICAgfSkuY2F0Y2goZSA9PiB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcignW0xpZ2h0bmluZ10nLCBlKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFByZWxvYWRBcmVhKCkge1xuICAgICAgICBpZiAoIXRoaXMuX3ByZWxvYWRBcmVhKSB7XG4gICAgICAgICAgICAvLyBQcmVsb2FkIGFyZWEgbXVzdCBiZSBpbmNsdWRlZCBpbiBkb2N1bWVudCBib2R5IGFuZCBtdXN0IGJlIHZpc2libGUgdG8gdHJpZ2dlciBodG1sIGVsZW1lbnQgcmVuZGVyaW5nLlxuICAgICAgICAgICAgdGhpcy5fcHJlbG9hZEFyZWEgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKTtcbiAgICAgICAgICAgIGlmICh0aGlzLl9wcmVsb2FkQXJlYS5hdHRhY2hTaGFkb3cp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yYztcbiAgICB9XG5cbiAgICBzZXQgc3JjKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3NyYyAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fc3JjID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBoYXNBbHBoYSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2hhc0FscGhhO1xuICAgIH1cblxuICAgIHNldCBoYXNBbHBoYSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNBbHBoYSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5faGFzQWxwaGEgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldElzVmFsaWQoKSB7XG4gICAgICAgIHJldHVybiAhIXRoaXMuX3NyYztcbiAgICB9XG5cbiAgICBfZ2V0TG9va3VwSWQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zcmM7XG4gICAgfVxuXG4gICAgX2dldFNvdXJjZUxvYWRlcigpIHtcbiAgICAgICAgbGV0IHNyYyA9IHRoaXMuX3NyYztcbiAgICAgICAgbGV0IGhhc0FscGhhID0gdGhpcy5faGFzQWxwaGE7XG4gICAgICAgIGlmICh0aGlzLnN0YWdlLmdldE9wdGlvbignc3JjQmFzZVBhdGgnKSkge1xuICAgICAgICAgICAgdmFyIGZjID0gc3JjLmNoYXJDb2RlQXQoMCk7XG4gICAgICAgICAgICBpZiAoKHNyYy5pbmRleE9mKFwiLy9cIikgPT09IC0xKSAmJiAoKGZjID49IDY1ICYmIGZjIDw9IDkwKSB8fCAoZmMgPj0gOTcgJiYgZmMgPD0gMTIyKSB8fCBmYyA9PSA0NikpIHtcbiAgICAgICAgICAgICAgICAvLyBBbHBoYWJldGljYWwgb3IgZG90OiBwcmVwZW5kIGJhc2UgcGF0aC5cbiAgICAgICAgICAgICAgICBzcm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zKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dFRleHR1cmVSZW5kZXJlcihzdGFnZSwgY2FudmFzLCBzZXR0aW5ncyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdGV4dCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3RleHQ7XG4gICAgfVxuXG4gICAgc2V0IHRleHQodikge1xuICAgICAgICBpZiAodGhpcy5fdGV4dCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fdGV4dCA9IFwiXCIgKyB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93O1xuICAgIH1cblxuICAgIHNldCB3KHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3cgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3cgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oO1xuICAgIH1cblxuICAgIHNldCBoKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2ggIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2ggPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGZvbnRTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZvbnRTdHlsZTtcbiAgICB9XG5cbiAgICBzZXQgZm9udFN0eWxlKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2ZvbnRTdHlsZSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fZm9udFN0eWxlID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBmb250QmFzZWxpbmVSYXRpbygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZvbnRCYXNlbGluZVJhdGlvO1xuICAgIH1cbiAgICBcbiAgICBzZXQgZm9udEJhc2VsaW5lUmF0aW8odikge1xuICAgICAgICBpZiAodGhpcy5fZm9udEJhc2VsaW5lUmF0aW8gIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2ZvbnRCYXNlbGluZVJhdGlvID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBmb250U2l6ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZvbnRTaXplO1xuICAgIH1cblxuICAgIHNldCBmb250U2l6ZSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9mb250U2l6ZSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fZm9udFNpemUgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGZvbnRGYWNlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZm9udEZhY2U7XG4gICAgfVxuXG4gICAgc2V0IGZvbnRGYWNlKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2ZvbnRGYWNlICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9mb250RmFjZSA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgd29yZFdyYXAoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93b3JkV3JhcDtcbiAgICB9XG5cbiAgICBzZXQgd29yZFdyYXAodikge1xuICAgICAgICBpZiAodGhpcy5fd29yZFdyYXAgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3dvcmRXcmFwID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB3b3JkV3JhcFdpZHRoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fd29yZFdyYXBXaWR0aDtcbiAgICB9XG5cbiAgICBzZXQgd29yZFdyYXBXaWR0aCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl93b3JkV3JhcFdpZHRoICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl93b3JkV3JhcFdpZHRoID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB3b3JkQnJlYWsoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93b3JkQnJlYWs7XG4gICAgfVxuXG4gICAgc2V0IHdvcmRCcmVhayh2KSB7XG4gICAgICAgIGlmICh0aGlzLl93b3JkQnJlYWsgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3dvcmRCcmVhayA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdGV4dE92ZXJmbG93KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdGV4dE92ZXJmbG93O1xuICAgIH1cblxuICAgIHNldCB0ZXh0T3ZlcmZsb3codikge1xuICAgICAgICBpZiAodiAhPSB0aGlzLl90ZXh0T3ZlcmZsb3cpIHtcbiAgICAgICAgICAgIHRoaXMuX3RleHRPdmVyZmxvdyA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgbGluZUhlaWdodCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xpbmVIZWlnaHQ7XG4gICAgfVxuXG4gICAgc2V0IGxpbmVIZWlnaHQodikge1xuICAgICAgICBpZiAodGhpcy5fbGluZUhlaWdodCAhPT0gdikge1xuICAgICAgICAgICAgdGh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XRZICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9vZmZzZXRZID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBtYXhMaW5lcygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21heExpbmVzO1xuICAgIH1cblxuICAgIHNldCBtYXhMaW5lcyh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9tYXhMaW5lcyAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fbWF4TGluZXMgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IG1heExpbmVzU3VmZml4KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbWF4TGluZXNTdWZmaXg7XG4gICAgfVxuXG4gICAgc2V0IG1heExpbmVzU3VmZml4KHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX21heExpbmVzU3VmZml4ICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9tYXhMaW5lc1N1ZmZpeCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdGV4dENvbG9yKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdGV4dENvbG9yO1xuICAgIH1cblxuICAgIHNldCB0ZXh0Q29sb3Iodikge1xuICAgICAgICBpZiAodGhpcy5fdGV4dENvbG9yICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl90ZXh0Q29sb3IgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHBhZGRpbmdMZWZ0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGFkZGluZ0xlZnQ7XG4gICAgfVxuXG4gICAgc2V0IHBhZGRpbmdMZWZ0KHYpIHtcbiAgICAgIC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oaXMuX3RleHRJbmRlbnQgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3RleHRJbmRlbnQgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHRleHRJbmRlbnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl90ZXh0SW5kZW50O1xuICAgIH1cblxuICAgIHNldCBydGwodikge1xuICAgICAgICBpZiAodGhpcy5fcnRsICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9ydGwgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHJ0bCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3J0bDtcbiAgICB9XG5cbiAgICBnZXQgcHJlY2lzaW9uKCkge1xuICAgICAgICByZXR1cm4gc3VwZXIucHJlY2lzaW9uO1xuICAgIH1cblxuICAgIHNldCBwcmVjaXNpb24odikge1xuICAgICAgICAvLyBXZSBhY3R1YWxseSBkcmF3IGRpZmZlcmVudGx5IHdoZW4gdGhlIHByZWNpc2lvbiBjaGFuZ2VzLlxuICAgICAgICBpZiAodGhpcy5wcmVjaXNpb24gIT09IHYpIHtcbiAgICAgICAgICAgIHN1cGVyLnByZWNpc2lvbiA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0SXNWYWxpZCgpIHtcbiAgICAgICAgcmV0dXJuICEhdGhpcy50ZXh0O1xuICAgIH1cblxuICAgIF9nZXRMb29rdXBJZCgpIHtcbiAgICAgICAgbGV0IHBhcnRzID0gW107XG5cbiAgICAgICAgaWYgKHRoaXMudyAhPT0gMCkgcGFydHMucHVzaChcIncgXCIgKyB0aGlzLncpO1xuICAgICAgICBpZiAodGhpcy5oICE9PSAwKSBwYXJ0cy5wdXNoKFwiaCBcIiArIHR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tc1tnbC5URVhUVVJFX01BR19GSUxURVJdID0gZ2wuTkVBUkVTVDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICAgICAgICBwLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAvKiBGSVhNRTogb24gc29tZSBwbGF0Zm9ybXMgKGUuZy4gUlBJKSwgdGhyb3R0bGluZyB0ZXh0IHRleHR1cmVzIGNhdXNlIGFydGlmYWN0cyAqL1xuICAgICAgICAgICAgICAgICAgICBjYihudWxsLCBPYmplY3QuYXNzaWduKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlckluZm86IHJlbmRlcmVyLnJlbmRlckluZm8sXG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdHRsZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXhQYXJhbXM6IHRleFBhcmFtcyxcbiAgICAgICAgICAgICAgICAgICAgfSwgdGhpcy5zdGFnZS5wbGF0Zm9ybS5nZXRUZXh0dXJlT3B0aW9uc0ZvckRyYXdpbmdDYW52YXMoY2FudmFzKSkpO1xuICAgICAgICAgICAgICAgIH0pLmNhdGNoKChlcnIpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY2IoZXJyKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY2IobnVsbCwgT2JqZWN0LmFzc2lnbih7XG4gICAgICAgICAgICAgICAgICAgIHJlbmRlckluZm86IHJlbmRlcmVyLnJlbmRlckluZm8sXG4gICAgICAgICAgICAgICAgICAgIHRocm90dGxlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgdGV4UGFyYW1zOiB0ZXhQYXJhbXMsXG4gICAgICAgICAgICAgICAgfSwgdGhpcy5zdGFnZS5wbGF0Zm9ybS5nZXRUZXh0dXJlT3B0aW9uc0ZvckRyYXdpbmdDYW52YXMoY2FudmFzKSkpO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G4gICAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gVXNlIGEgcHJvbWlzZSB0aGF0IHdhaXRzIGZvciBsb2FkaW5nLlxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuZm9udHMubG9hZChmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkuY2F0Y2goZXJyID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEp1c3QgbG9hZCB0aGUgZmFsbGJhY2sgZm9udC5cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybignW0xpZ2h0bmluZ10gRm9udCBsb2FkIGVycm9yJywgZXJyLCBmb250U2V0dGluZyk7XG4gICAgICAgICAgICAgICAgICAgIH0pLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ1tMaWdodG5pbmddIEZvbnQgbm90IGZvdW5kJywgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGNhdGNoKGUpIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBDYW4ndCBjaGVjayBmb250IGxvYWRpbmcgZm9yIFwiICsgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZHJhdygpIHtcbiAgICAgICAgLy8gV2UgZG8gbm90IHVzZSBhIHByb21pc2Ugc28gdGhhdCBsb2FkaW5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ZHRoIDwgMTApIHtcbiAgICAgICAgICAgIHdpZHRoICs9ICgxMCAtIGlubmVyV2lkdGgpO1xuICAgICAgICAgICAgaW5uZXJXaWR0aCA9IDEwO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCF3b3JkV3JhcFdpZHRoKSB7XG4gICAgICAgICAgICB3b3JkV3JhcFdpZHRoID0gaW5uZXJXaWR0aFxuICAgICAgICB9XG5cbiAgICAgICAgLy8gVGV4dCBvdmVyZmxvd1xuICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MudGV4dE92ZXJmbG93ICYmICF0aGlzLl9zZXR0aW5ncy53b3JkV3JhcCkge1xuICAgICAgICAgICAgbGV0IHN1ZmZpeDtcbiAgICAgICAgICAgIHN3aXRjaCAodGhpcy5fc2V0dGluZ3MudGV4dE92ZXJmbG93KSB7XG4gICAgICAgICAgICAgICAgY2FzZSAnY2xpcCc6XG4gICAgICAgICAgICAgICAgICAgIHN1ZmZpeCA9ICcnO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICdlbGxpcHNpcyc6XG4gICAgICAgICAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMuX3NldHRpbmdzLm1heExpbmVzU3VmZml4O1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICBzdWZmaXggPSB0aGlzLl9zZXR0aW5ncy50ZXh0T3ZlcmZsb3c7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy50ZXh0ID0gdGhpcy53cmFwV29yZCh0aGlzLl9zZXR0aW5ncy50ZXh0LCB3b3JkV3JhcFdpZHRoIC0gdGV4dEluZGVudCwgc3VmZml4KVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gd29yZCB3cmFwXG4gICAgICAgIC8vIHByZXNlcnZlIG9yaWdpbmFsIHRleHRcbiAgICAgICAgbGV0IGxpbmVzSW5mbztcbiAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLndvcmRXcmFwKSB7XG4gICAgICAgICAgICBsaW5lc0luZm8gPSB0aGlzLndyYXBUZXh0KHRoaXMuX3NldHRpbmdzLnRleHQsIHdvcmRXcmFwV2lkdGgsIGxldHRlclNwYWNpbmcsIHRleHRJbmRlbnQpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbGluZXNJbmZvID0ge2w6IHRoaXMuX3NldHRpbmdzLnRleHQuc3BsaXQoLyg/OlxcclxcbnxcXHJ8XFxuKS8pLCBuOiBbXX07XG4gICAgICAgICAgICBsZXQgaSwgbiA9IGxpbmVzSW5mby5sLmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbiAtIDE7IGkrKykge1xuICAgICAgICAgICAgICAgIGxpbmVzSW5mby5uLnB1c2goaSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGxpbmVzID0gbGluZXNJbmZvLmw7XG5cbiAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLm1heExpbmVzICYmIGxpbmVzLmxlbmd0aCA+IHRoaXMuX3NldHRpbmdzLm1heExpbmVzKSB7XG4gICAgICAgICAgICBsZXQgdXNlZExpbmVzID0gbGluZXMuc2xpY2UoMCwgdGhpcy5fc2V0dGluZ3MubWF4TGluZXMpO1xuXG4gICAgICAgICAgICBsZXQgb3RoZXJMaW5lcyA9IG51bGw7XG4gICAgICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MubWF4TGluZXNTdWZmaXgpIHtcbiAgICAgICAgICAgICAgICAvLyBXcmFwIGFnYWluIHdpdGggbWF4IGxpbmVzIHN1ZmZpeCBlbmFibGVkLlxuICAgICAgICAgICAgICAgIGxldCB3ID0gdGhpcy5fc2V0dGluZ3MubWF4TGluZXNTdWZmaXggPyB0aGlzLm1lYXN1cmVUZXh0KHRoaXMuX3NldHRpbmdzLm1heExpbmVzU3VmZml4KSA6IDA7XG4gICAgICAgICAgICAgICAgbGV0IGFsID0gdGhpcy53cmFwVGV4dCh1c2VkTGluZXNbdXNlZExpbmVzLmxlbmd0aCAtIDFdLCB3b3JkV3JhcFdpZHRoIC0gdywgbGV0dGVyU3BhY2luZywgdGV4dEluZGVudCk7XG4gICAgICAgICAgICAgICAgdXNlZExpbmVzW3VzZWRMaW5lcy5sZW5ndGggLSAxXSA9IGFsLmxbMF0gKyB0aGlzLl9zZXR0aW5ncy5tYXhMaW5lc1N1ZmZpeDtcbiAgICAgICAgICAgICAgICBvdGhlckxpbmVzID0gW2FsLmwubGVuZ3RoID4gMSA/IGFsLmxbMV0gOiAnJ107XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG90aGVyTGluZXMgPSBbJyddO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBSZS1hc3NlbWJsZSB0aGUgcmVtYWluaW5nIHRleHQuXG4gICAgICAgICAgICBsZXQgaSwgbiA9IGxpbmVzLmxlbmd0aDtcbiAgICAgICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgICAgIGxldCBtID0gbGluZXNJbmZvLm4ubGVuZ3RoO1xuICAgICAgICAgICAgZm9yIChpID0gdGhpcy5fc2V0dGluZ3MubWF4TGluZXM7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBvdGhlckxpbmVzW2pdICs9IChvdGhlckxpbmVzW2pdID8gXCIgXCIgOiBcIlwiKSArIGxpbmVzW2ldO1xuICAgICAgICAgICAgICAgIGlmIChpICsgMSA8IG0gJiYgbGluZXNJbmZvLm5baSArIDFdKSB7XG4gICAgICAgICAgICAgICAgICAgIGorKztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJlbmRlckluZm8ucmVtYWluaW5nVGV4dCA9IG90aGVyTGluZXMuam9pbihcIlxcblwiKTtcblxuICAgICAgICAgICAgcmVuZGVySW5mby5tb3JlVGV4dExpbmVzID0gdHJ1ZTtcblxuICAgICAgICAgICAgbGluZXMgPSB1c2VkTGluZXM7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZW5kZXJJbmZvLm1vcmVUZXh0TGluZXMgPSBmYWxzZTtcbiAgICAgICAgICAgIHJlbmRlckluZm8ucmVtYWluaW5nVGV4dCA9IFwiXCI7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBjYWxjdWxhdGUgdGV4dCB3aWR0aFxuICAgICAgICBsZXQgbWF4TGluZVdpZHRoID0gMDtcbiAgICAgICAgbGV0IGxpbmVXaWR0aHMgPSBbXTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaW5lcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgbGV0IGxpbmVXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQobGluZXNbaV0sIGxldHRlclNwYWNpbmcpICsgKGkgPT09IDAgPyB0ZXh0SW5kZW50IDogMCk7XG4gICAgICAgICAgICBsaW5lV2lkdGhzLnB1c2gobGluZVdpZHRoKTtcbiAgICAgICAgICAgIG1heExpbmVXaWR0aCA9IE1hdGgubWF4KG1heExpbmVXaWR0aCwgbGluZVdpZHRoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJlbmRlckluZm8ubGluZVdpZHRocyA9IGxpbmVXaWR0aHM7XG5cbiAgICAgICAgaWYgKCF3KSB7XG4gICAgICAgICAgICAvLyBBdXRvLXNldCB3aWR0aCB0byBtYXggdGV4dCBsZW5ndGguXG4gICAgICAgICAgICB3aWR0aCA9IG1heExpbmVXaWR0aCArIHBhZGRpbmdMZWZ0ICsgcGFkZGluZ1JpZ2h0O1xuICAgICAgICAgICAgaW5uZXJXaWR0aCA9IG1heExpbmVXaWR0aDtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIGNhbGN1bGF0ZSB0ZXh0IGhlaWdodFxuICAgICAgICBsaW5lSGVpZ2h0ID0gbGluZUhlaWdodCB8fCBmb250U2l6ZTtcblxuICAgICAgICBsZXQgaGVpZ2h0O1xuICAgICAgICBpZiAoaCkge1xuICAgICAgICAgICAgaGVpZ2h0ID0gaDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnN0IGJhc2VsaW5lT2Zmc2V0ID0gKHRoaXMuX3NldHRpbmdzLnRleHRCYXNlbGluZSAhPSAnYm90dG9tJykgPyAwLjUgKiBmb250U2l6ZSA6IDA7XG4gICAgICAgICAgICBoZWlnaHQgPSBsaW5lSGVpZ2h0ICogKGxpbmVzLmxlbmd0aCAtIDEpICsgYmFzZWxpbmVPZmZzZXQgKyBNYXRoLm1heChsaW5lSGVpZ2h0LCBmb250U2l6ZSkgKyBvZmZzZXRZO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG9mZnNldFkgPT09IG51bGwpIHtcbiAgICAgICAgICAgIG9mZnNldFkgPSBmb250U2l6ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJlbmRlckluZm8udyA9IHdpZHRoO1xuICAgICAgICByZW5kZXJJbmZvLmggPSBoZWlnaHQ7XG4gICAgICAgIHJlbmRlckluZm8ubGluZXMgPSBsaW5lcztcbiAgICAgICAgcmVuZGVySW5mby5wcmVjaXNpb24gPSBwcmVjaXNpb247XG5cbiAgICAgICAgaWYgKCF3aWR0aCkge1xuICAgICAgICAgICAgLy8gVG8gcHJldmVudCBjYW52YXMgZXJyb3JzLlxuICAgICAgICAgICAgd2lkdGggPSAxO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCFoZWlnaHQpIHtcbiAgICAgICAgICAgIC8vIFRvIHByZXZlbnQgY2FudmFzIGVycm9ycy5cbiAgICAgICAgICAgIGhlaWdodCA9IDE7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY3V0U3ggfHwgY3V0RXgpIHtcbiAgICAgICAgICAgIHdpZHRoID0gTWF0aC5taW4od2lkdGgsIGN1dEV4IC0gY3V0U3gpO1xuICAgICAgICB9XG5cbiAgICAgICA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ICBsZXQgbGluZVBvc2l0aW9uWDtcbiAgICAgICAgbGV0IGxpbmVQb3NpdGlvblk7XG5cbiAgICAgICAgbGV0IGRyYXdMaW5lcyA9IFtdO1xuXG4gICAgICAgIC8vIERyYXcgbGluZXMgbGluZSBieSBsaW5lLlxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHJlbmRlckluZm8ubGluZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsaW5lUG9zaXRpb25YID0gaSA9PT0gMCA/IHJlbmRlckluZm8udGV4dEluZGVudCA6IDA7XG5cbiAgICAgICAgICAgIC8vIEJ5IGRlZmF1bHQsIHRleHQgaXMgYWxpZ25lZCB0byB0b3BcbiAgICAgICAgICAgIGxpbmVQb3NpdGlvblkgPSAoaSAqIHJlbmRlckluZm8ubGluZUhlaWdodCkgKyByZW5kZXJJbmZvLm9mZnNldFk7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy52ZXJ0aWNhbEFsaWduID09ICdtaWRkbGUnKSB7XG4gICAgICAgICAgICAgICAgbGluZVBvc2l0aW9uWSArPSAocmVuZGVySW5mby5saW5lSGVpZ2h0IC0gcmVuZGVySW5mby5mb250U2l6ZSkgLyAyO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9zZXR0aW5ncy52ZXJ0aWNhbEFsaWduID09ICdib3R0b20nKSB7XG4gICAgICAgICAgICAgICAgbGluZVBvc2l0aW9uWSArPSByZW5kZXJJbmZvLmxpbmVIZWlnaHQgLSByZW5kZXJJbmZvLmZvbnRTaXplO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MudGV4dEFsaWduID09PSAncmlnaHQnKSB7XG4gICAgICAgICAgICAgICAgbGluZVBvc2l0aW9uWCArPSAocmVuZGVySW5mby5pbm5lcldpZHRoIC0gcmVuZGVySW5mby5saW5lV2lkdGhzW2ldKTtcbiAgICAgICAgICAgIH0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ICAgIGxldCB4ID0gZHJhd0xpbmUueDtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaiA9IHRleHRTcGxpdC5sZW5ndGg7IGkgPCBqOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsVGV4dCh0ZXh0U3BsaXRbaV0sIHgsIGRyYXdMaW5lLnkpO1xuICAgICAgICAgICAgICAgICAgICB4ICs9IHRoaXMubWVhc3VyZVRleHQodGV4dFNwbGl0W2ldLCByZW5kZXJJbmZvLmxldHRlclNwYWNpbmcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChwcmV2U2hhZG93U2V0dGluZ3MpIHtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Q29sb3IgPSBwcmV2U2hhZG93U2V0dGluZ3NbMF07XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFggPSBwcmV2U2hhZG93U2V0dGluZ3NbMV07XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFkgPSBwcmV2U2hhZG93U2V0dGluZ3NbMl07XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0JsdXIgPSBwcmV2U2hhZG93U2V0dGluZ3NbM107XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocmVuZGVySW5mby5jdXRTeCB8fCByZW5kZXJJbmZvLmN1dFN5KSB7XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnRyYW5zbGF0ZShyZW5kZXJJbmZvLmN1dFN4LCByZW5kZXJJbmZvLmN1dFN5KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMucmVuZGVySW5mbyA9IHJlbmRlckluZm87XG4gICAgfTtcblxuICAgIHdyYXBXb3JkKHdvcmQsIHdvcmRXcmFwV2lkdGgsIHN1ZmZpeCkge1xuICAgICAgICBjb25zd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XggLT0gMTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgLyogSW4gY2FzZSBndWVzcyB3YXMgdW5kZXJlc3RpbWF0ZWQsIGV4dGVuZCBpdCBsZXR0ZXIgYnkgbGV0dGVyLiAqL1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgd2hpbGUgKGN1dG9mZkluZGV4IDwgd29yZExlbikge1xuICAgICAgICAgICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBjdXRvZmZJbmRleCkpICsgc3VmZml4V2lkdGg7XG4gICAgICAgICAgICAgICAgaWYgKHRydW5jV29yZFdpZHRoIDwgd29yZFdyYXBXaWR0aCkge1xuICAgICAgICAgICAgICAgICAgICBjdXRvZmZJbmRleCArPSAxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZpbmFsbHksIHdoZW4gYm91bmQgaXMgY3Jvc3NlZCwgcmV0cmFjdCBsYXN0IGxldHRlci5cbiAgICAgICAgICAgICAgICAgICAgY3V0b2ZmSW5kZXggLT0xO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKiBJZiB3cmFwV2lkdGggaXMgdG9vIHNob3J0IHRvIGV2ZW4gY29udGFpbiBzdWZmaXggYWxvbmUsIHJldHVybiBlbXB0eSBzdHJpbmcgKi9cbiAgICAgICAgcmV0dXJuIHdvcmQuc3Vic3RyaW5nKDAsIGN1dG9mZkluZGV4KSArICh3b3JkV3JhcFdpZHRoID49IHN1ZmZpeFdpZHRoID8gc3VmZml4IDogJycpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFNlZSB7QGxpbms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LCBzZXR0aW5ncykge1xuICAgICAgICB0aGlzLl9zdGFnZSA9IHN0YWdlO1xuICAgICAgICB0aGlzLl9jYW52YXMgPSBjYW52YXM7XG4gICAgICAgIHRoaXMuX2NvbnRleHQgPSB0aGlzLl9jYW52YXMuZ2V0Q29udGV4dCgnMmQnKTtcbiAgICAgICAgdGhpcy5fc2V0dGluZ3MgPSBzZXR0aW5ncztcbiAgICB9XG5cbiAgICBnZXRQcmVjaXNpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zZXR0aW5ncy5wcmVjaXNpb247XG4gICAgfTtcblxuICAgIHNldEZvbnRQcm9wZXJ0aWVzKCkge1xuICAgICAgICBjb25zdCBmb250ID0gZ2V0Rm9udFNldHRpbmcoXG4gICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250RmFjZSxcbiAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTdHlsZSxcbiAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTaXplLFxuICAgICAgICAgICAgdGhpcy5nZXRQcmVjaXNpb24oKSxcbiAgICAgICAgICAgIHRoaXMuX3N0YWdlLmdldE9wdGlvbignZGVmYXVsdEZvbnRGYWNlJylcbiAgICAgICAgKTtcbiAgICAgICAgdGhpcy5fY29udGV4dC5mb250ID0gZm9udDtcbiAgICAgICAgdGhpcy5fY29udGV4dC50ZXh0QmFzZWxpbmUgPSB0aGlzLl9zZXR0aW5ncy50ZXh0QmFzZWxpbmU7XG4gICAgICAgIHJldHVybiBmb250O1xuICAgIH07XG5cbiAgICBfbG9hZCgpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzV2ViICYmIGRvY3VtZW50LmZvbnRzKSB7XG4gICAgICAgICAgICBjb25zdCBmb250U2V0dGluZyA9IGdldEZvbnRTZXR0aW5nKFxuICAgICAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRGYWNlLFxuICAgICAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTdHlsZSxcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U2l6ZSxcbiAgICAgICAgICAgICAgICB0aGlzLmdldFByZWNpc2lvbigpLFxuICAgICAgICAgICAgICAgIHRoaXMuX3N0YWdlLmdldE9wdGlvbignZGVmYXVsdEZvbnRGYWNlJylcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFVzZSBhIHByb21pc2UgdGhhdCB3YWl0cyBmb3IgbG9hZGluZy5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmZvbnRzLmxvYWQoZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpLmNhdGNoKGVyciA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBKdXN0IGxvYWQgdGhlIGZhbGxiYWNrIGZvbnQuXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ0ZvbnQgbG9hZCBlcnJvcicsIGVyciwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgICAgICAgICB9KS50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdGb250IG5vdCBmb3VuZCcsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBjYXRjaChlKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiQ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SB0aGlzLl9zZXR0aW5ncy5zaGFkb3dCbHVyO1xuICAgICAgICByZW5kZXJJbmZvLmN1dFN4ID0gY3V0U3g7XG4gICAgICAgIHJlbmRlckluZm8uY3V0RXggPSBjdXRFeDtcbiAgICAgICAgcmVuZGVySW5mby5jdXRTeSA9IGN1dFN5O1xuICAgICAgICByZW5kZXJJbmZvLmN1dEV5ID0gY3V0RXk7XG4gICAgICAgIHJlbmRlckluZm8udGV4dEluZGVudCA9IHRoaXMuX3NldHRpbmdzLnRleHRJbmRlbnQgKiBwcmVjaXNpb247XG4gICAgICAgIHJlbmRlckluZm8ud29yZEJyZWFrID0gdGhpcy5fc2V0dGluZ3Mud29yZEJyZWFrO1xuXG4gICAgICAgIGxldCB0ZXh0ID0gcmVuZGVySW5mby50ZXh0O1xuICAgICAgICBsZXQgd3JhcFdpZHRoID0gcmVuZGVySW5mby53b3JkV3JhcCA/IChyZW5kZXJJbmZvLndvcmRXcmFwV2lkdGggfHwgcmVuZGVySW5mby53aWR0aCkgOiByZW5kZXJJbmZvLndpZHRoO1xuXG4gICAgICAgIC8vIFRleHQgb3ZlcmZsb3dcbiAgICAgICAgaWYgKHJlbmRlckluZm8udGV4dE92ZXJmbG93ICYmICFyZW5kZXJJbmZvLndvcmRXcmFwKSB7XG4gICAgICAgICAgICBsZXQgc3VmZml4O1xuICAgICAgICAgICAgc3dpdGNoICh0aGlzLl9zZXR0aW5ncy50ZXh0T3ZlcmZsb3cpIHtcbiAgICAgICAgICAgICAgICBjYXNlICdjbGlwJzpcbiAgICAgICAgICAgICAgICAgICAgc3VmZml4ID0gJyc7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ2VsbGlwc2lzJzpcbiAgICAgICAgICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5fc2V0dGluZ3MubWF4TGluZXNTdWZmaXg7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGRlZ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ndpZHRoID4gd3JhcFdpZHRoIHx8IHQudGV4dCA9PSAnXFxuJykge1xuICAgICAgICAgICAgICAgIHggPSBwYWRkaW5nTGVmdDtcbiAgICAgICAgICAgICAgICBsaW5lTm8gKz0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHQubGluZU5vID0gbGluZU5vO1xuXG4gICAgICAgICAgICBpZiAodC50ZXh0ID09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHQueCA9IHg7XG4gICAgICAgICAgICB4ICs9IHQud2lkdGg7XG4gICAgICAgIH1cbiAgICAgICAgcmVuZGVySW5mby5saW5lTnVtID0gbGluZU5vICsgMTtcblxuICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MuaCkge1xuICAgICAgICAgICAgcmVuZGVySW5mby5oID0gdGhpcy5fc2V0dGluZ3MuaDtcbiAgICAgICAgfSBlbHNlIGlmIChyZW5kZXJJbmZvLm1heExpbmVzICYmIHJlbmRlckluZm8ubWF4TGluZXMgPCByZW5kZXJJbmZvLmxpbmVOdW0pIHtcbiAgICAgICAgICAgIHJlbmRlckluZm8uaCA9IHJlbmRlckluZm8ubWF4TGluZXMgKiByZW5kZXJJbmZvLmxpbmVIZWlnaHQgKyBmb250U2l6ZSAvIDI7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZW5kZXJJbmZvLmggPSByZW5kZXJJbmZvLmxpbmVOdW0gKiByZW5kZXJJbmZvLmxpbmVIZWlnaHQgKyBmb250U2l6ZSAvIDI7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBUaGlzIGNhbGN1bGF0ZXMgdGhlIGJhc2VsaW5lIG9mZnNldCBpbiBwaXhlbHMgZnJvbSB0aGUgZm9udCBzaXplLlxuICAgICAgICAvLyBUbyByZXRyaWV2ZSB0aGlzIHJhdGlvLCB5b3Ugd291bGQgZG8gdGhpcyBjYWxjdWxhdGlvbjpcbiAgIC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bmRlckluZm8uZm9udFNpemU7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBDYWxjdWxhdGUgbGluZXMgaW5mb3JtYXRpb25cbiAgICAgICAgcmVuZGVySW5mby5saW5lcyA9IFtdXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcmVuZGVySW5mby5saW5lTnVtOyBpKyspIHtcbiAgICAgICAgICAgIHJlbmRlckluZm8ubGluZXNbaV0gPSB7XG4gICAgICAgICAgICAgICAgd2lkdGg6IDAsXG4gICAgICAgICAgICAgICAgeDogMCxcbiAgICAgICAgICAgICAgICB5OiByZW5kZXJJbmZvLmxpbmVIZWlnaHQgKiBpICsgdmFPZmZzZXQsXG4gICAgICAgICAgICAgICAgdGV4dDogW10sXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGxldCB0IG9mIHRleHQpIHtcbiAgICAgICAgICAgIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnRleHQucHVzaCh0KTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEZpbHRlciBvdXQgd2hpdGUgc3BhY2VzIGF0IGJlZ2lubmluZyBhbmQgZW5kIG9mIGVhY2ggbGluZVxuICAgICAgICBmb3IgKGNvbnN0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICAgICAgaWYgKGwudGV4dC5sZW5ndGggPT0gMCkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCBmaXJzdFdvcmQgPSBsLnRleHRbMF0udGV4dDtcbiAgICAgICAgICAgIGNvbnN0IGxhc3RXb3JkID0gbC50ZXh0W2wudGV4dC5sZW5ndGggLSAxXS50ZXh0O1xuXG4gICAgICAgICAgICBpZiAoZmlyc3RXb3JkID09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgbC50ZXh0LnNoaWZ0KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoaXNTcGFjZShsYXN0V29yZCkgfHwgbGFzdFdvcmQgPT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICBsLnRleHQucG9wKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuXG4gICAgICAgIC8vIENhbGN1bGF0ZSBsaW5lIHdpZHRoXG4gICAgICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICAgICAgbC53aWR0aCA9IGwudGV4dC5yZWR1Y2UoKGFjYywgdCkgPT4gYWNjICsgdC53aWR0aCwgMCk7XG4gICAgICAgIH1cblxuICAgICAgICByZW5kZXJJbmZvLndpZHRoID0gdGhpcy5fc2V0dGluZ3MudyAhPSAwID8gdGhpcy5fc2V0dGluZ3MudyAqIHByZWNpc2lvbiA6IE1hdGgubWF4KC4uLnJlbmRlckluZm8ubGluZXMubWFwKChsKSA9PiBsLndpZHRoKSkgKyBwYWRkaW5nUmlnaHQ7XG4gICAgICAgIHJlbmRlckluZm8udyA9IHJlbmRlckluZm8ud2lkdGg7XG5cbiAgICAgICAgLy8gQXBwbHkgbWF4TGluZXNTdWZmaXhcbiAgICAgICAgaWYgKHJlbmRlckluZm8ubWF4TGluZXMgJiYgcmVuZGVySW5mby5saW5lTnVtID4gcmVuZGVySW5mby5tYXhMaW5lcyAmJiByZW5kZXJJbmZvLm1heExpbmVzU3VmZml4KSB7XG4gICAgICAgICAgICBjb25zdCBpbmRleCA9IHJlbmRlckluZm8ubWF4TGluZXMgLSAxO1xuICAgICAgICAgICAgbGV0IGxhc3RMaW5lVGV4dCA9IHRleHQuZmlsdGVyKCh0KSA9PiB0LmxpbmVObyA9PSBpbmRleClcbiAgICAgICAgICAgIGxldCBzdWZmaXggPSByZW5kZXJJbmZvLm1heExpbmVzU3VmZml4O1xuICAgICAgICAgICAgc3VmZml4ID0gdGhpcy50b2tlbml6ZShzdWZmaXgpO1xuICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5wYXJzZShzdWZmaXgpO1xuICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5tZWFzdXJlKHN1ZmZpeCwgcmVuZGVySW5mby5sZXR0ZXJTcGFjaW5nLCByZW5kZXJJbmZvLmJhc2VGb250KTtcbiAgICAgICAgICAgIGZvciAoY29uc3QgcyBvZiBzdWZmaXgpIHtcbiAgICAgICAgICAgICAgICBzLmxpbmVObyA9IGluZGV4O1xuICAgICAgICAgICAgICAgIHMueCA9IDA7XG4gICAgICAgICAgICAgICAgbGFzdExpbmVUZXh0LnB1c2gocylcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29uc3Qgc3BsID0gc3VmZml4Lmxlbmd0aCArIDFcbiAgICAgICAgICAgIGxldCBfdyA9IGxhc3RMaW5lVGV4dC5yZWR1Y2UoKGFjYywgdCkgPT4gYWNjICsgdC53aWR0aCwgMCk7XG4gICAgICAgICAgICB3aGlsZSAoX3cgPiByZW5kZXJJbmZvLndpZHRoIHx8IGlzU3BhY2UobGFzdExpbmVUZXh0W2xhc3RMaW5lVGV4dC5sZW5ndGggLSBzcGxdLnRleHQpKSB7XG4gICAgICAgICAgICAgICAgbGFzdExpbmVUZXh0LnNwbGljZShsYXN0TGluZVRleHQubGVuZ3RoIC0gc3BsLCAxKTtcbiAgICAgICAgICAgICAgICBfdyA9IGxhc3RMaW5lVGV4dC5yZWR1Y2UoKGFjYywgdCkgPT4gYWNjICsgdC53aWR0aCwgMCk7XG4gICAgICAgICAgICAgICAgaWYgKGxhc3RMaW5lVGV4dC5sZW5ndGggPCBzcGwpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5hbGlnbkxpbmUobGFzdExpbmVUZXh0LCBsYXN0TGluZVRleHRbMF0ueClcblxuICAgICAgICAgICAgcmVuZGVySW5mby5saW5lc1tpbmRleF0udGV4dCA9IGxhc3RMaW5lVGV4dDtcbiAgICAgICAgICAgIHJlbmRlckluZm8ubGluZXNbaW5kZXhdLndpZHRoID0gX3c7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBIb3Jpem9udGFsIGFsaWdubWVudCBvZmZzZXRcbiAgICAgICAgaWYgKHJlbmRlckluZm8udGV4dEFsaWduID09ICdjZW50ZXInKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBsIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgICAgICAgICBsLnggPSAocmVuZGVySW5mby53aWR0aCAtIGwud2lkdGggLSBwYWRkaW5nTGVmdCkgLyAyO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHJlbmRlckluZm8udGV4dEFsaWduID09ICdyaWdodCcpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICAgICAgICAgIGwueCA9IHJlbmRlckluZm8ud2lkdGggLSBsLndpZHRoIC0gcGFkZGluZ0xlZnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcmVuZGVySW5mbztcbiAgICB9XG5cbiAgICBfZHJhdygpIHtcbiAgICAgICAgY29uc3QgcmVuZGVySW5mbyA9IHRoaXMuX2NhbGN1bGF0ZVJlbmRlckluZm8oKTtcbiAgICAgICAgY29uc3QgcHJlY2lzaW9uID0gdGhpcy5nZXRQcmVjaXNpb24oKTtcbiAgICAgICAgY29uc3QgcGFkZGluZ0xlZnQgPSByZW5kZXJJbmZvLnBhZGRpbmdMZWZ0ICogcHJlY2lzaW9uO1xuXG4gICAgICAgIC8vIFNldCBjYW52YXMgZGltZW5zaW9uc1xuICAgICAgICBsZXQgY2FudmFzV2lkdGggPSByZW5kZXJJbmZvLncgfHwgcmVuZGVySW5mby53aWR0aDtcbiAgICAgICAgaWYgKHJlbmRlckluZm8uY3V0U3ggfHwgcmVuZGVySW5mby5jdXRFeCkge1xuICAgICAgICAgICAgY2FudmFzV2lkdGggPSBNYXRoLm1pbihyZW5k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ZG93T2Zmc2V0WCAqIHByZWNpc2lvbjtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93T2Zmc2V0WSA9IHRoaXMuX3NldHRpbmdzLnNoYWRvd09mZnNldFkgKiBwcmVjaXNpb247XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0JsdXIgPSB0aGlzLl9zZXR0aW5ncy5zaGFkb3dCbHVyICogcHJlY2lzaW9uO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gRHJhdyB0ZXh0XG4gICAgICAgIGNvbnN0IGRlZmF1bHRDb2xvciA9IFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyh0aGlzLl9zZXR0aW5ncy50ZXh0Q29sb3IpO1xuICAgICAgICBsZXQgY3VycmVudENvbG9yID0gZGVmYXVsdENvbG9yO1xuICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxTdHlsZSA9IGRlZmF1bHRDb2xvcjtcbiAgICAgICAgZm9yIChjb25zdCBsaW5lIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgICAgIGZvciAoY29uc3QgdCBvZiBsaW5lLnRleHQpIHtcbiAgICAgICAgICAgICAgICBsZXQgbHggPSAwO1xuXG4gICAgICAgICAgICAgICAgaWYgKHQudGV4dCA9PSAnXFxuJykge1xuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAocmVuZGVySW5mby5tYXhMaW5lcyAmJiB0LmxpbmVObyA+PSByZW5kZXJJbmZvLm1heExpbmVzKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICh0LmNvbG9yICE9IGN1cnJlbnRDb2xvcikge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q29sb3IgPSB0LmNvbG9yO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxTdHlsZSA9IGN1cnJlbnRDb2xvcjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSB0LmZvbnRTdHlsZTtcblxuICAgICAgICAgICAgICAgIC8vIERyYXcgd2l0aCBsZXR0ZXIgc3BhY2luZ1xuICAgICAgICAgICAgICAgIGlmICh0LmxldHRlcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgbCBvZiB0LmxldHRlcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IF94ID0gcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueCArIHQueCArIGx4O1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsVGV4dChsLnRleHQsIF94LCByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS55ICsgcmVuZGVySW5mby5mb250U2l6ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBseCArPSBsLndpZHRoO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgLy8gU3RhbmRhcmQgZHJhd2luZ1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IF94ID0gcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueCArIHQueDtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsVGV4dCh0LnRleHQsIF94LCByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS55ICsgcmVuZGVySW5mby5mb250U2l6ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gUmVzZXQgdGV4dCBzaGFkb3dcbiAgICAgICAgaWYgKHByZXZTaGFkb3dTZXR0aW5ncykge1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dDb2xvciA9IHByZXZT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FxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBzcGFjZVxuICAgICAqIEByZXR1cm5zIHtudW1iZXJ9XG4gICAgICovXG4gICAgbWVhc3VyZVRleHQod29yZCwgc3BhY2UgPSAwKSB7XG4gICAgICAgIHJldHVybiBtZWFzdXJlVGV4dCh0aGlzLl9jb250ZXh0LCB3b3JkLCBzcGFjZSk7XG4gICAgfVxuXG4gICAgdG9rZW5pemUodGV4dCkge1xuICAgICAgICByZXR1cm4gdG9rZW5pemVTdHJpbmcoLyB8XFx1MjAwQnxcXG58PGk+fDxcXC9pPnw8Yj58PFxcL2I+fDxjb2xvcj0wW3hYXVswLTlhLWZBLUZdezh9Pnw8XFwvY29sb3I+L2csIHRleHQpO1xuICAgIH1cblxuICAgIHBhcnNlKHRva2Vucykge1xuICAgICAgICBsZXQgaXRhbGljID0gMDtcbiAgICAgICAgbGV0IGJvbGQgPSAwO1xuICAgICAgICBsZXQgY29sb3JTdGFjayA9IFtTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodGhpcy5fc2V0dGluZ3MudGV4dENvbG9yKV07XG4gICAgICAgIGxldCBjb2xvciA9IDA7XG5cbiAgICAgICAgY29uc3QgY29sb3JSZWdleHAgPSAvPGNvbG9yPSgwW3hYXVswLTlhLWZBLUZdezh9KT4vO1xuXG4gICAgICAgIHJldHVybiB0b2tlbnMubWFwKCh0KSA9PiB7XG4gICAgICAgICAgICBpZiAodCA9PSAnPGk+Jykge1xuICAgICAgICAgICAgICAgIGl0YWxpYyArPSAxO1xuICAgICAgICAgICAgICAgIHQgPSAnJztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodCA9PSAnPC9pPicgJiYgaXRhbGljID4gMCkge1xuICAgICAgICAgICAgICAgIGl0YWxpYyAtPSAxO1xuICAgICAgICAgICAgICAgIHQgPSAnJztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodCA9PSAnPGI+Jykge1xuICAgICAgICAgICAgICAgIGJvbGQgKz0gMTtcbiAgICAgICAgICAgICAgICB0ID0gJyc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHQgPT0gJzwvYj4nICYmIGJvbGQgPiAwKSB7XG4gICAgICAgICAgICAgICAgYm9sZCAtPSAxO1xuICAgICAgICAgICAgICAgIHQgPSAnJztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodCA9PSAnPC9jb2xvcj4nKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNvbG9yU3RhY2subGVuZ3RoID4gMSkge1xuICAgICAgICAgICAgICAgICAgICBjb2xvciAtPSAxO1xuICAgICAgICAgICAgICAgICAgICBjb2xvclN0YWNrLnBvcCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0ID0gJyc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNvbG9yUmVnZXhwLnRlc3QodCkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBtYXRjaGVkID0gY29sb3JSZWdleHAuZXhlYyh0KTtcbiAgICAgICAgICAgICAgICBjb2xvclN0YWNrLnB1c2goXG4gICAgICAgICAgICAgICAgICAgIFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyhwYXJzZUludChtYXRjaGVkWzFdKSlcbiAgICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICAgIGNvbG9yICs9IDE7XG4gICAgICAgICAgICAgICAgdCA9ICcnO1xuXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdGV4dDogdCxcbiAgICAgICAgICAgICAgICBpdGFsaWM6IGl0YWxpYyxcbiAgICAgICAgICAgICAgICBib2xkOiBib2xkLFxuICAgICAgICAgICAgICAgIGNvbG9yOiBjb2xvclN0YWNrW2NvbG9yXSxcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSlcbiAgICAgICAgLmZpbHRlcigobykgPT4gby50ZXh0ICE9ICcnKTtcbiAgICB9XG5cbiAgICBhcHBseUZvbnRTdHlsZSh3b3JkLCBiYXNlRm9udCkge1xuICAgICAgICBsZXQgZm9udCA9IGJhc2VGb250O1xuICAgICAgICBpZiAod29yZC5ib2xkKSB7XG4gICAgICAgICAgICBmb250ID0gJ2JvbGQgJyArIGZvbnQ7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHdvcmQuaXRhbGljKSB7XG4gICAgICAgICAgICBmb250ID0gJ2l0YWxpYyAnICsgZm9udDtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSBmb250XG4gICAgICAgIHdvcmQuZm9udFN0eWxlID0gZm9udDtcbiAgICB9XG5cbiAgICByZXNldEZvbnRTdHlsZShiYXNlRm9udCkge1xuICAgICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSBiYXNlRm9udDtcbiAgICB9XG5cbiAgICBtZWFzdXJlKHBhcnNlZCwgbGV0dGVyU3BhY2luZyA9IDAsIGJhc2VGb250KSB7XG4gICAgICAgIGZvciAoY29uc3QgcCBvZiBwYXJzZWQpIHtcbiAgICAgICAgICAgIHRoaXMuYXBwbHlGb250U3R5bGUocCwgYmFzZUZvbnQpO1xuICAgICAgICAgICAgcC53aWR0aCA9IHRoaXMubWVhc3VyZVRleHQocC50ZXh0LCBsZXR0ZXJTcGFjaW5nKTtcblxuICAgICAgICAgICAgLy8gTGV0dGVyIGJ5IGxldHRlciBkZXRhaWwgZm9yIGxldHRlciBzcGFjaW5nXG4gICAgICAgICAgICBpZiAobGV0dGVyU3BhY2luZyA+IDApIHtcbiAgICAgICAgICAgICAgICBwLmxldHRlcnMgPSBwLnRleHQuc3BsaXQoJycpLm1hcCgobCkgPT4ge3JldHVybiB7dGV4dDogbH19KTtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBsIG9mIHAubGV0dGVycykge1xuICAgICAgICAgICAgICAgICAgICBsLndpZHRoID0gdGhpcy5tZWFzdXJlVGV4dChsLnRleHQsIGxldHRlclNwYWNpbmcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1c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AgICAgICAgICAgICB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgYnJlYWtJbmRleCkpO1xuICAgICAgICAgICAgICAgIGlmICh0cnVuY1dvcmRXaWR0aCA+IHdpZHRoKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrSW5kZXggLT0gMTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgLyogSW4gY2FzZSBndWVzcyB3YXMgdW5kZXJlc3RpbWF0ZWQsIGV4dGVuZCBpdCBsZXR0ZXIgYnkgbGV0dGVyLiAqL1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgd2hpbGUgKGJyZWFrSW5kZXggPCB3b3JkTGVuKSB7XG4gICAgICAgICAgICAgICAgdHJ1bmNXb3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQuc3Vic3RyaW5nKDAsIGJyZWFrSW5kZXgpKTtcbiAgICAgICAgICAgICAgICBpZiAodHJ1bmNXb3JkV2lkdGggPCB3aWR0aCkge1xuICAgICAgICAgICAgICAgICAgICBicmVha0luZGV4ICs9IDE7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmluYWxseSwgd2hlbiBib3VuZCBpcyBjcm9zc2VkLCByZXRyYWN0IGxhc3QgbGV0dGVyLlxuICAgICAgICAgICAgICAgICAgICBicmVha0luZGV4IC09MTtcbiAgICAgICAgICAgICAgICAgICAgdHJ1bmNXb3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQuc3Vic3RyaW5nKDAsIGJyZWFrSW5kZXgpKTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7YnJlYWtJbmRleCwgdHJ1bmNXb3JkV2lkdGh9O1xuXG4gICAgfVxuXG4gICAgd29yZEJyZWFrKHdvcmQsIHdpZHRoLCBiYXNlRm9udCkge1xuICAgICAgICBpZiAoIXdvcmQudGV4dCkge1xuICAgICAgICAgICAgcmV0dXJuIHdvcmRcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmFwcGx5Rm9udFN0eWxlKHdvcmQsIGJhc2VGb250KVxuICAgICAgICBjb25zdCBwYXJ0cyA9IFtdO1xuICAgICAgICBsZXQgdGV4dCA9IHdvcmQudGV4dDtcbiAgICAgICAgaWYgKCF3b3JkLmxldHRlcnMpIHtcbiAgICAgICAgICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgICAgICAgICAgY29uc3Qge2JyZWFrSW5kZXgsIHRydW5jV29yZFdpZHRofSA9IHRoaXMuX2dldEJyZWFrSW5kZXgodGV4dCwgd2lkdGgpO1xuICAgICAgICAgICAgICAgIHBhcnRzLnB1c2goey4uLndvcmR9KTtcbiAgICAgICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5zbGljZSgwLCBicmVha0luZGV4KTtcbiAgICAgICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS53aWR0aCA9IHRydW5jV29yZFdpZHRoO1xuXG4gICAgICAgICAgICAgICAgaWYgKGJyZWFrSW5kZXggPT09IHRleHQubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnNsaWNlKGJyZWFrSW5kZXgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbGV0IHRvdGFsV2lkdGggPSAwO1xuICAgICAgICAgICAgbGV0IGxldHRlcnMgPSBbXTtcbiAgICAgICAgICAgIGxldCBicmVha0luZGV4ID0gMDtcbiAgICAgICAgICAgIGZvciAoY29uc3QgbCBvZiB3b3JkLmxldHRlcnMpIHtcbiAgICAgICAgICAgICAgICBpZiAodG90YWxXaWR0aCArIGwud2lkdGggPj0gd2lkdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgcGFydHMucHVzaCh7Li4ud29yZH0pO1xuICAgICAgICAgICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5zbGljZSgwLCBicmVha0luZGV4KTtcbiAgICAgICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ud2lkdGggPSB0b3RhbFdpZHRoO1xuICAgICAgICAgICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS5sZXR0ZXJzID0gbGV0dGVycztcbiAgICAgICAgICAgICAgICAgICAgdGV4dCA9IHRleHQuc2xpY2UoYnJlYWtJbmRleCk7XG4gICAgICAgICAgICAgICAgICAgIHRvdGFsV2lkdGggPSAwO1xuICAgICAgICAgICAgICAgICAgICBsZXR0ZXJzID0gW107XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrSW5kZXggPSAwO1xuXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWtJbmRleCArPSAxO1xuICAgICAgICAgICAgICAgICAgICBsZXR0ZXJzLnB1c2gobCk7XG4gICAgICAgICAgICAgICAgICAgIHRvdGFsV2lkdGggKz0gbC53aWR0aDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0b3RhbFdpZHRoID4gMCkge1xuICAgICAgICAgICAgICAgIHBhcnRzLnB1c2goey4uLndvcmR9KTtcbiAgICAgICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5zbGljZSgwLCBicmVha0luZGV4KTtcbiAgICAgICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS53aWR0aCA9IHRvdGFsV2lkdGg7XG4gICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ubGV0dGVycyA9IGxldHRlcnM7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcGFydHM7XG4gICAgfVxuXG4gICAgYWxpZ25MaW5lKHBhcnNlZCwgaW5pdGlhbFggPSAwKSB7XG4gICAgICAgIGxldCBwcmV2V2lkdGggPSAwO1xuICAgICAgICBsZXQgcHJldlggPSBpbml0aWFsWDtcbiAgICAgICAgZm9yIChjb25zdCB3b3JkIG9mIHBhcnNlZCkge1xuICAgICAgICAgICAgaWYgKHdvcmQudGV4dCA9PSAnXFxuJykge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgd29yZC54ID0gcHJldlggKyBwcmV2V2lkdGg7XG4gICAgICAgICAgICBwcmV2WCA9IHdvcmQueDtcbiAgICAgICAgICAgIHByZXZXaWR0aCA9IHdvcmQud2lkdGg7XG4gICAgICAgIH1cblxuICAgIH1cbn0iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXMgYXBwbHk6XG4gKlxuICogQ29weXJpZ2h0IDIwMjAgTWV0cm9sb2dpY2FsXG4gKlxuICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlIExpY2Vuc2UpO1xuICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLlxuICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0XG4gKl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ZXIgdGhhbiB0aGUgd29yZCB3cmFwIHdpZHRoLlxuICAgICAgICAgICAgICAgIGlmIChqID4gMCkge1xuICAgICAgICAgICAgICAgICAgICByZXN1bHRMaW5lcy5wdXNoKHJlc3VsdCk7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9ICcnO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXN1bHQgKz0gd29yZDtcbiAgICAgICAgICAgICAgICBzcGFjZUxlZnQgPSB3b3JkV3JhcFdpZHRoIC0gd29yZFdpZHRoIC0gKGogPT09IDAgPyBpbmRlbnQgOiAwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHNwYWNlTGVmdCAtPSB3b3JkV2lkdGhXaXRoU3BhY2U7XG4gICAgICAgICAgICAgICAgcmVzdWx0ICs9IHNwYWNlICsgd29yZDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXN1bHRMaW5lcy5wdXNoKHJlc3VsdCk7XG4gICAgICAgIHJlc3VsdCA9ICcnO1xuICAgICAgICBhbGxMaW5lcyA9IGFsbExpbmVzLmNvbmNhdChyZXN1bHRMaW5lcyk7XG4gICAgICAgIGlmIChpIDwgbGluZXMubGVuZ3RoIC0gMSkge1xuICAgICAgICAgICAgcmVhbE5ld2xpbmVzLnB1c2goYWxsTGluZXMubGVuZ3RoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4geyBsOiBhbGxMaW5lcywgbjogcmVhbE5ld2xpbmVzIH07XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1UZXh0VGV4dHVyZVJlbmRlcmVyVXRpbHMubWpzLm1hcCIsIi8qXG4gKiBJZiBub3Qgc3RhdGVkIG90aGVyd2lzZSBpbiB0aGlzIGZpbGUgb3IgdGhpcyBjb21wb25lbnQncyBMSUNFTlNFIGZpbGUgdGhlXG4gKiBmb2xsb3dpbmcgY29weXJpZ2h0I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W107XG4gICAgICAgIHRoaXMuX3BlID0gW107XG4gICAgICAgIHRoaXMuX2lkcCA9IFtdO1xuICAgICAgICB0aGlzLl9mID0gW107XG4gICAgICAgIHRoaXMuX3YgPSBbXTtcbiAgICAgICAgdGhpcy5fbHYgPSBbXTtcbiAgICAgICAgdGhpcy5fc20gPSBbXTtcbiAgICAgICAgdGhpcy5fcyA9IFtdO1xuICAgICAgICB0aGlzLl92ZSA9IFtdO1xuICAgICAgICB0aGlzLl9zbWUgPSBbXTtcbiAgICAgICAgdGhpcy5fc2UgPSBbXTtcblxuICAgICAgICB0aGlzLl9sZW5ndGggPSAwO1xuICAgIH1cblxuICAgIHBhcnNlKHJnYmEsIGRlZikge1xuICAgICAgICBsZXQgaSwgbjtcbiAgICAgICAgaWYgKCFVdGlscy5pc09iamVjdExpdGVyYWwoZGVmKSkge1xuICAgICAgICAgICAgZGVmID0gezA6IGRlZn1cbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBkZWZhdWx0U21vb3RobmVzcyA9IDAuNTtcblxuICAgICAgICBsZXQgaXRlbXMgPSBbXTtcbiAgICAgICAgZm9yIChsZXQga2V5IGluIGRlZikge1xuICAgICAgICAgICAgaWYgKGRlZi5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICAgICAgbGV0IG9iaiA9IGRlZltrZXldO1xuICAgICAgICAgICAgICAgIGlmICghVXRpbHMuaXNPYmplY3RMaXRlcmFsKG9iaikpIHtcbiAgICAgICAgICAgICAgICAgICAgb2JqID0ge3Y6IG9ian1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBsZXQgcCA9IHBhcnNlRmxvYXQoa2V5KTtcblxuICAgICAgICAgICAgICAgIGlmIChrZXkgPT09IFwic21cIikge1xuICAgICAgICAgICAgICAgICAgICBkZWZhdWx0U21vb3RobmVzcyA9IG9iai52O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzTmFOKHApICYmIHAgPj0gMCAmJiBwIDw9IDIpIHtcbiAgICAgICAgICAgICAgICAgICAgb2JqLnAgPSBwO1xuXG4gICAgICAgICAgICAgICAgICAgIG9iai5mID0gVXRpbHMuaXNGdW5jdGlvbihvYmoudik7XG4gICAgICAgICAgICAgICAgICAgIG9iai5sdiA9IG9iai5mID8gb2JqLnYoMCwgMCkgOiBvYmoudjtcblxuICAgICAgICAgICAgICAgICAgICBpdGVtcy5wdXNoKG9iaik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gU29ydCBieSBwcm9ncmVzcyB2YWx1ZS5cbiAgICAgICAgaXRlbXMgPSBpdGVtcy5zb3J0KGZ1bmN0aW9uKGEsIGIpIHtyZXR1cm4gYS5wIC0gYi5wfSk7XG5cbiAgICAgICAgbiA9IGl0ZW1zLmxlbmd0aDtcblxuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgbGFzdCA9IChpID09PSBuIC0gMSk7XG4gICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KCdwZScpKSB7XG4gICAgICAgICAgICAgICAgLy8gUHJvZ3Jlc3MuXG4gICAgICAgICAgICAgICAgaXRlbXNbaV0ucGUgPSBsYXN0ID8gKGl0ZW1zW2ldLnAgPD0gMSA/IDEgOiAyIC8qIHN1cHBvcnQgb25ldG90d28gc3RvcCAqLykgOiBpdGVtc1tpICsgMV0ucDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gUHJldmVudCBtdWx0aXBsZSBpdGVtcyBhdCB0aGUgc2FtZSB0aW1lLlxuICAgICAgICAgICAgICAgIGNvbnN0IG1heCA9IGkgPCBuIC0gMSA/IGl0ZW1zW2kgKyAxXS5wIDogMTtcbiAgICAgICAgICAgICAgICBpZiAoaXRlbXNbaV0ucGUgPiBtYXgpIHtcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0ucGUgPSBtYXg7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGl0ZW1zW2ldLnBlID09PSBpdGVtc1tpXS5wKSB7XG4gICAgICAgICAgICAgICAgaXRlbXNbaV0uaWRwID0gMDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaXRlbXNbaV0uaWRwID0gMSAvIChpdGVtc1tpXS5wZSAtIGl0ZW1zW2ldLnApO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gQ29sb3IgbWVyZ2VyOiB3ZSBuZWVkIHRvIHNwbGl0L2NvbWJpbmUgUkdCQSBjb21wb25lbnRzLlxuXG4gICAgICAgIC8vIENhbGN1bGF0ZSBiZXppZXIgaGVscGVyIHZhbHVlcy47XG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoJ3NtJykpIHtcbiAgICAgICAgICAgICAgICAvLyBTbW9vdGhuZXNzLjtcbiAgICAgICAgICAgICAgICBpdGVtc1tpXS5zbSA9IGRlZmF1bHRTbW9vdGhuZXNzO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eSgncycpKSB7XG4gICAgICAgICAgICAgICAgLy8gU2xvcGUuO1xuICAgICAgICAgICAgICAgIGlmIChpID09PSAwIHx8IGkgPT09IG4gLSAxIHx8IChpdGVtc1tpXS5wID09PSAxIC8qIGZvciBvbmV0b3R3byAqLykpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gSG9yaXpvbnRhbCBzbG9wZSBhdCBzdGFydCBhbmQgZW5kLjtcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IHJnYmEgPyBbMCwgMCwgMCwgMF0gOiAwO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHBpID0gaXRlbXNbaSAtIDFdO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBuaSA9IGl0ZW1zW2kgKyAxXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBpLnAgPT09IG5pLnApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnMgPSByZ2JhID8gWzAsIDAsIDAsIDBdIDogMDtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZ2JhKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmMgPSBNdWx0aVNwbGluZS5nZXRSZ2JhQ29tcG9uZW50cyhuaS5sdik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGMgPSBNdWx0aVNwbGluZS5nZXRSZ2JhQ29tcG9uZW50cyhwaS5sdik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZCA9IDEgLyAobmkucCAtIHBpLnApO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnMgPSBbXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQgKiAobmNbMF0gLSBwY1swXSksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQgKiAobmNbMV0gLSBwY1sxXSksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQgKiAobmNbMl0gLSBwY1syXSksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQgKiAobmNbM10gLSBwY1szXSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gKG5pLmx2IC0gcGkubHYpIC8gKG5pLnAgLSBwaS5wKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7XG4gICAgICAgICAgICAvLyBDYWxjdWxhdGUgdmFsdWUgZnVuY3Rpb24uO1xuICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5mKSB7XG5cbiAgICAgICAgICAgICAgICBsZXQgbGFzdCA9IChpID09PSBuIC0gMSk7XG4gICAgICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eSgndmUnKSkge1xuICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS52ZSA9IGxhc3QgPyBpdGVtc1tpXS5sdiA6IGl0ZW1zW2kgKyAxXS5sdjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBXZSBjYW4gb25seSBpbnRlcnBvbGF0ZSBvbiBudW1lcmljIHZhbHVlcy4gTm9uLW51bWVyaWMgdmFsdWVzIGFyZSBzZXQgbGl0ZXJhbGx5IHdoZW4gcmVhY2hlZCB0aW1lLlxuICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc051bWJlcihpdGVtc1tpXS52KSAmJiBVdGlscy5pc051bWJlcihpdGVtc1tpXS5sdikpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eSgnc21lJykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnNtZSA9IGxhc3QgPyBkZWZhdWx0U21vb3RobmVzcyA6IGl0ZW1zW2kgKyAxXS5zbTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KCdzZScpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS5zZSA9IGxhc3QgPyAocmdiYSA/IFswLCAwLCAwLCAwXSA6IDApIDogaXRlbXNbaSArIDFdLnM7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAvLyBHZW5lcmF0ZSBzcGxpbmUuO1xuICAgICAgICAgICAgICAgICAgICBpZiAocmdiYSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0udiA9IE11bHRpU3BsaW5lLmdldFNwbGluZVJnYmFWYWx1ZUZ1bmN0aW9uKGl0ZW1zW2ldLnYsIGl0ZW1zW2ldLnZlLCBpdGVtc1tpXS5wLCBpdGVtc1tpXS5wZSwgaXRlbXNbaV0uc20sIGl0ZW1zW2ldLnNtZSwgaXRlbXNbaV0ucywgaXRlbXNbaV0uc2UpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0udiA9IE11bHRpU3BsaW5lLmdldFNwbGluZVZhbHVlRnVuY3Rpb24oaXRlbXNbaV0udiwgaXRlbXNbaV0udmUsIGl0ZW1zW2ldLnAsIGl0ZW1zW2ldLnBlLCBpdGVtc1tpXS5zbSwgaXRlbXNbaV0uc21lLCBpdGVtc1tpXS5zLCBpdGVtc1tpXS5zZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS5mID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHRoaXMuX2NsZWFyKCk7XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGkgPSAwLCBuID0gaXRlbXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICB0aGlzLl9hZGQoaXRlbXNbaV0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2FkZChpdGVtKSB7XG4g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uXG4gICAgICAgIGxldCBkcCA9IHAyIC0gcDE7XG4gICAgICAgIHMxICo9IGRwO1xuICAgICAgICBzMiAqPSBkcDtcblxuICAgICAgICBsZXQgaGVscGVycyA9IE11bHRpU3BsaW5lLmdldFNwbGluZUhlbHBlcnModjEsIHYyLCBvMSwgaTIsIHMxLCBzMik7XG4gICAgICAgIGlmICghaGVscGVycykge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIChwKSB7XG4gICAgICAgICAgICAgICAgaWYgKHAgPT09IDApIHJldHVybiB2MTtcbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gMSkgcmV0dXJuIHYyO1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHYyICogcCArIHYxICogKDEgLSBwKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHApIHtcbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gMCkgcmV0dXJuIHYxO1xuICAgICAgICAgICAgICAgIGlmIChwID09PSAxKSByZXR1cm4gdjI7XG4gICAgICAgICAgICAgICAgcmV0dXJuIE11bHRpU3BsaW5lLmNhbGN1bGF0ZVNwbGluZShoZWxwZXJzLCBwKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc3RhdGljIGdldFNwbGluZVJnYmFWYWx1ZUZ1bmN0aW9uKHYxLCB2MiwgcDEsIHAyLCBvMSwgaTIsIHMxLCBzMikge1xuICAgICAgICAvLyBOb3JtYWxpemUgc2xvcGVzIGJlY2F1c2Ugd2UgdXNlIGEgc3BsaW5lIHRoYXQgZ29lcyBmcm9tIDAgdG8gMS5cbiAgICAgICAgbGV0IGRwID0gcDIgLSBwMTtcbiAgICAgICAgczFbMF0gKj0gZHA7XG4gICAgICAgIHMxWzFdICo9IGRwO1xuICAgICAgICBzMVsyXSAqPSBkcDtcbiAgICAgICAgczFbM10gKj0gZHA7XG4gICAgICA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ZnVuY3Rpb24gKHApIHtcbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gMCkgcmV0dXJuIHYxO1xuICAgICAgICAgICAgICAgIGlmIChwID09PSAxKSByZXR1cm4gdjI7XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gTXVsdGlTcGxpbmUuZ2V0QXJnYk51bWJlcihbXG4gICAgICAgICAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbMF0sIHApKSxcbiAgICAgICAgICAgICAgICAgICAgTWF0aC5taW4oMjU1LCBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVyc1sxXSwgcCkpLFxuICAgICAgICAgICAgICAgICAgICBNYXRoLm1pbigyNTUsIE11bHRpU3BsaW5lLmNhbGN1bGF0ZVNwbGluZShoZWxwZXJzWzJdLCBwKSksXG4gICAgICAgICAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbM10sIHApKVxuICAgICAgICAgICAgICAgIF0pO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuXG4gICAgfTtcblxuICAgIC8qKlxuICAgICAqIENyZWF0ZXMgaGVscGVycyB0byBiZSB1c2VkIGluIHRoZSBzcGxpbmUgZnVuY3Rpb24uXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHYxXG4gICAgICogICBGcm9tIHZhbHVlLlxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB2MlxuICAgICAqICAgVG8gdmFsdWUuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IG8xXG4gICAgICogICBGcm9tIHNtb290aG5lc3MgKDAgPSBsaW5lYXIsIDEgPSBzbW9vdGgpLlxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBzMVxuICAgICAqICAgRnJvbSBzbG9wZSAoMCA9IGhvcml6b250YWwsIGluZmluaXRlID0gdmVydGljYWwpLlxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBpMlxuICAgICAqICAgVG8gc21vb3RobmVzcy5cbiAgICAgKiBAcGFyYW0ge251bWJlcn0gczJcbiAgICAgKiAgIFRvIHNsb3BlLlxuICAgICAqIEByZXR1cm5zIHtOdW1iZXJbXX1cbiAgICAgKiAgIFRoZSBoZWxwZXIgdmFsdWVzIHRvIGJlIHN1cHBsaWVkIHRvIHRoZSBzcGxpbmUgZnVuY3Rpb24uXG4gICAgICogICBJZiB0aGUgY29uZmlndXJhdGlvbiBpcyBhY3R1YWxseSBsaW5lYXIsIG51bGwgaXMgcmV0dXJuZWQuXG4gICAgICovXG4gICAgc3RhdGljIGdldFNwbGluZUhlbHBlcnModjEsIHYyLCBvMSwgaTIsIHMxLCBzMikge1xuICAgICAgICBpZiAoIW8xICYmICFpMikge1xuICAgICAgICAgICAgLy8gTGluZWFyLlxuICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBDdWJpYyBiZXppZXIgcG9pbnRzLlxuICAgICAgICAvLyBodHRwOi8vY3ViaWMtYmV6aWVyLmNvbS9cbiAgICAgICAgbGV0IGNzeCA9IG8xO1xuICAgICAgICBsZXQgY3N5ID0gdjEgKyBzMSAqIG8xO1xuICAgICAgICBsZXQgY2V4ID0gMSAtIGkyO1xuICAgICAgICBsZXQgY2V5ID0gdjIgLSBzMiAqIGkyO1xuXG4gICAgICAgIGxldCB4YSA9IDMgKiBjc3ggLSAzICogY2V4ICsgMTtcbiAgICAgICAgbGV0IHhiID0gLTYgKiBjc3ggKyAzICogY2V4O1xuICAgICAgICBsZXQgeGMgPSAzICogY3N4O1xuXG4gICAgICAgIGxldCB5YSA9IDMgKiBjc3kgLSAzICogY2V5ICsgdjIgLSB2MTtcbiAgICAgICAgbGV0IHliID0gMyAqIChjZXkgKyB2MSkgLSA2ICogY3N5O1xuICAgICAgICBsZXQgeWMgPSAzICogKGNzeSAtIHYxKTtcbiAgICAgICAgbGV0IHlkID0gdjE7XG5cbiAgICAgICAgcmV0dXJuIFt4YSwgeGIsIHhjLCB5YSwgeWIsIHljLCB5ZF07XG4gICAgfTtcblxuICAgIC8qKlxuICAgICAqIENhbGN1bGF0ZXMgdGhlIGludGVybWVkaWF0ZSBzcGxpbmUgdmFsdWUgYmFzZWQgb24gdGhlIHNwZWNpZmllZCBoZWxwZXJzLlxuICAgICAqIEBwYXJhbSB7bnVtYmVyW119IGhlbHBlcnNcbiAgICAgKiAgIE9idGFpbmVkIGZyb20gZ2V0U3BsaW5lSGVscGVycy5cbiAgICAgKiBAcGFyYW0ge251bWJlcn0gcFxuICAgICAqIEByZXR1cm4ge251bWJlcn1cbiAgICAgKi9cbiAgICBzdGF0aWMgY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnMsIHApIHtcbiAgICAgICAgbGV0IHhhID0gaGVscGVyc1swXTtcbiAgICAgICAgbGV0IHhiID0gaGVscGVyc1sxXTtcbiAgICAgICAgbGV0IHhjID0gaGVscGVyc1syXTtcbiAgICAgICAgbGV0IHlhID0gaGVscGVyc1szXTtcbiAgICAgICAgbGV0IHliID0gaGVscGVyc1s0XTtcbiAgICAgICAgbGV0IHljID0gaGVscGVyc1s1XTtcbiAgICAgICAgbGV0IHlkID0gaGVscGVyc1s2XTtcblxuICAgICAgICBpZiAoeGEgPT09IC0yICYmIHlhID09PSAtMiAmJiB4YyA9PT0gMCAmJiB5YyA9PT0gMCkge1xuICAgICAgICAgICAgLy8gTGluZWFyLlxuICAgICAgICAgICAgcmV0dXJuIHA7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBGaW5kIHQgZm9yIHAuXG4gICAgICAgIGxldCB0ID0gMC41LCBjYngsIGR4O1xuXG4gICAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICAgICAgLy8gQ3ViaWMgYmV6aWVyIGZ1bmN0aW9uOiBmKHQpPXQqKHQqKHQqYStiKStjKS5cbiAgICAgICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG5cbiAgICAgICAgICAgIGR4ID0gcCAtIGNieDtcbiAgICAgICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgICAgICAgIC8vIFNvbHV0aW9uIGZvdW5kIVxuICAgICAgICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpICsgeWQ7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEN1YmljIGJlemllciBkZXJpdmF0aXZlIGZ1bmN0aW9uOiBmJyh0KT10Kih0KigzKmEpKzIqYikrY1xuICAgICAgICAgICAgbGV0IGNieGQgPSB0ICogKHQgKiAoMyAqIHhhKSArIDIgKiB4YikgKyB4YztcblxuICAgICAgICAgICAgaWYgKGNieGQgPiAxZS0xMCAmJiBjYnhkIDwgMWUtMTApIHtcbiAgICAgICAgICAgICAgICAvLyBQcm9ibGVtYXRpYy4gRmFsbCBiYWNrIHRvIGJpbmFyeSBzZWFyY2ggbWV0aG9kLlxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0ICs9IGR4IC8gY2J4ZDtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEZhbGxiYWNrOiBiaW5hcnkgc2VhcmNoIG1ldGhvZC4gVGhpcyBpcyBtb3JlIHJlbGlhYmxlIHdoZW4gdGhlcmUgYXJlIG5lYXItMCBzbG9wZXMuXG4gICAgICAgIGxldCBtaW5UID0gMDtcbiAgICAgICAgbGV0IG1heFQgPSAxO1xuICAgICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgICAgIHQgPSAwLjUgKiAobWluVCArIG1heFQpO1xuXG4gICAgICAgICAgICAvLyBDdWJpYyBiZXppZXIgZnVuY3Rpb246IGYodCk9dCoodCoodCphK2IpK2MpK2QuXG4gICAgICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuXG4gICAgICAgICAgICBkeCA9IHAgLSBjYng7XG4gICAgICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICAgICAgICAvLyBTb2x1dGlvbiBmb3VuZCFcbiAgICAgICAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKSArIHlkO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoZHggPCAwKSB7XG4gICAgICAgICAgICAgICAgbWF4VCA9IHQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG1pblQgPSB0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHQ7XG4gICAgfTtcblxuICAgIHN0YXRpYyBtZXJnZUNvbG9ycyhjMSwgYzIsIHApIHtcbiAgICAgICAgbGV0IHIxID0gKChjMSAvIDY1NTM2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgZzEgPSAoKGMxIC8gMjU2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgYjEgPSBjMSAlIDI1NjtcbiAgICAgICAgbGV0IGExID0gKChjMSAvIDE2Nzc3MjE2KSB8IDApO1xuXG4gICAgICAgIGxldCByMiA9ICgoYzIgLyA2NTUzNikgfCAwKSAlIDI1NjtcbiAgICAgICAgbGV0IGcyID0gKChjMiAvIDI1NikgfCAwKSAlIDI1NjtcbiAgICAgICAgbGV0IGIyID0gYzIgJSAyNTY7XG4gICAgICAgIGxldCBhMiA9ICgoYzIgLyAxNjc3NzIxNikgfCAwKTtcblxuICAgICAgICBsZXQgciA9IHIxICogcCArIHIyICogKDEgLSBwKTtcbiAgICAgICAgbGV0IGcgPSBnMSAqIHAgKyBnMiAqICgxIC0gcCk7XG4gICAgICAgIGxldCBiID0gYjEgKiBwICsgYjIgKiAoMSAtIHApO1x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gIGNvbnN0IGFrcyA9IE9iamVjdC5rZXlzKGEpO1xuICAgICAgICBjb25zdCBia3MgPSBPYmplY3Qua2V5cyhiKTtcblxuICAgICAgICBpZiAoIWJrcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gQ3JlYXRlIGluZGV4IGFycmF5IGZvciBhbGwgZWxlbWVudHMuXG4gICAgICAgIGNvbnN0IGFpID0ge307XG4gICAgICAgIGNvbnN0IGJpID0ge307XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYmtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3Qga2V5ID0gYmtzW2ldO1xuICAgICAgICAgICAgYWlba2V5XSA9IC0xO1xuICAgICAgICAgICAgYmlba2V5XSA9IGk7XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBha3MubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBrZXkgPSBha3NbaV07XG4gICAgICAgICAgICBhaVtrZXldID0gaTtcbiAgICAgICAgICAgIGlmIChiaVtrZXldID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBiaVtrZXldID0gLTE7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBha3NsID0gYWtzLmxlbmd0aDtcblxuICAgICAgICBjb25zdCByZXN1bHQgPSB7fTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBia3MubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBrZXkgPSBia3NbaV07XG5cbiAgICAgICAgICAgIC8vIFByZXBlbmQgYWxsIGl0ZW1zIGluIGEgdGhhdCBhcmUgbm90IGluIGIgLSBiZWZvcmUgdGhlIG5vdyBhZGRlZCBiIGF0dHJpYnV0ZS5cbiAgICAgICAgICAgIGNvbnN0IGFJbmRleCA9IGFpW2tleV07XG4gICAgICAgICAgICBsZXQgY3VySW5kZXggPSBhSW5kZXg7XG4gICAgICAgICAgICB3aGlsZSgtLWN1ckluZGV4ID49IDApIHtcbiAgICAgICAgICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4XTtcbiAgICAgICAgICAgICAgICBpZiAoYmlbYWtleV0gIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEFscmVhZHkgZm91bmQ/IFN0b3AgcHJvY2Vzc2luZy5cbiAgICAgICAgICAgICAgICAgICAgLy8gTm90IHlldCBmb3VuZCBidXQgZXhpc3RzIGluIGI/IEFsc28gc3RvcCBwcm9jZXNzaW5nOiB3YWl0IHVudGlsIHdlIGZpbmQgaXQgaW4gYi5cbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgd2hpbGUoKytjdXJJbmRleCA8IGFJbmRleCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXhdO1xuICAgICAgICAgICAgICAgIHJlc3VsdFtha2V5XSA9IGFbYWtleV07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNvbnN0IGJ2ID0gYltrZXldO1xuICAgICAgICAgICAgY29uc3QgYXYgPSBhW2tleV07XG4gICAgICAgICAgICBsZXQgcjtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzTWYoYnYpKSB7XG4gICAgICAgICAgICAgICAgciA9IGJ2KGF2KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKCFVdGlscy5pc09iamVjdExpdGVyYWwoYXYpIHx8ICFVdGlscy5pc09iamVjdExpdGVyYWwoYnYpKSB7XG4gICAgICAgICAgICAgICAgICAgIHIgPSBidjtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByID0gT2JqTWVyZ2VyLm1lcmdlKGF2LCBidik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBXaGVuIG1hcmtlZCBhcyB1bmRlZmluZWQsIHByb3BlcnR5IGlzIGRlbGV0ZWQuXG4gICAgICAgICAgICBpZiAociAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0W2tleV0gPSByO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gQXBwZW5kIHJlbWFpbmluZyBmaW5hbCBpdGVtcyBpbiBhLlxuICAgICAgICBsZXQgY3VySW5kZXggPSBha3NsO1xuICAgICAgICB3aGlsZSgtLWN1ckluZGV4ID49IDApIHtcbiAgICAgICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXhdO1xuICAgICAgICAgICAgaWYgKGJpW2FrZXldICE9PSAtMSkge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHdoaWxlKCsrY3VySW5kZXggPCBha3NsKSB7XG4gICAgICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4XTtcbiAgICAgICAgICAgIHJlc3VsdFtha2V5XSA9IGFbYWtleV07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxufVxuIiwiLypcbiAqIElmIG5vdCBzdGF0ZWQgb3RoZXJ3aXNlIGluIHRoaXMgZmlsZSBvciB0aGlzIGNvbXBvbmVudCdzIExJQ0VOU0UgZmlsZSB0aGVcbiAqIGZvbGxvd2luZyBjb3B5cmlnaHQgYW5kIGxpY2Vuc2VzIGFwcGx5OlxuICpcbiAqIENvcHlyaWdodCAyMDIwIE1ldHJvbG9naWNhbFxuICpcbiAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFjaGUgTGljZW5zZSwgVmVyc2lvbiAyLjAgKHRoZSBMaWNlbnNlKTtcbiAq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FkaXVzWzJdLCB5ICsgaCwgcmFkaXVzWzJdKTtcbiAgICAgICAgY3R4LmxpbmVUbyh4ICsgcmFkaXVzWzNdLCB5ICsgaCk7XG4gICAgICAgIGN0eC5hcmNUbyh4LCB5ICsgaCwgeCwgeSArIGggLSByYWRpdXNbM10sIHJhZGl1c1szXSk7XG4gICAgICAgIGN0eC5saW5lVG8oeCwgeSArIHJhZGl1c1swXSk7XG4gICAgICAgIGN0eC5hcmNUbyh4LCB5LCB4ICsgcmFkaXVzWzBdLCB5LCByYWRpdXNbMF0pO1xuICAgICAgICBjdHguY2xvc2VQYXRoKCk7XG5cbiAgICAgICAgaWYgKGZpbGwpIHtcbiAgICAgICAgICAgIGlmIChVdGlscy5pc051bWJlcihmaWxsQ29sb3IpKSB7XG4gICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyhmaWxsQ29sb3IpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gXCJ3aGl0ZVwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY3R4LmZpbGwoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChzdHJva2VXaWR0aCkge1xuICAgICAgICAgICAgaWYgKFV0aWxzLmlzTnVtYmVyKHN0cm9rZUNvbG9yKSkge1xuICAgICAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyhzdHJva2VDb2xvcik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IFwid2hpdGVcIjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBzdHJva2VXaWR0aDtcbiAgICAgICAgICAgIGN0eC5zdHJva2UoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBjY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T09ICh0eXBlb2YgdjIpKSByZXR1cm4gZmFsc2VcbiAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2MSkpIHtcbiAgICAgICAgICAgIHJldHVybiBVdGlscy5pc09iamVjdExpdGVyYWwodjIpICYmIFV0aWxzLmVxdWFsT2JqZWN0TGl0ZXJhbHModjEsIHYyKVxuICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkodjEpKSB7XG4gICAgICAgICAgICByZXR1cm4gQXJyYXkuaXNBcnJheSh2MikgJiYgVXRpbHMuZXF1YWxBcnJheXModjEsIHYyKVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHYxID09PSB2MlxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGVxdWFsT2JqZWN0TGl0ZXJhbHMob2JqMSwgb2JqMikge1xuICAgICAgICBsZXQga2V5czEgPSBPYmplY3Qua2V5cyhvYmoxKTtcbiAgICAgICAgbGV0IGtleXMyID0gT2JqZWN0LmtleXMob2JqMik7XG4gICAgICAgIGlmIChrZXlzMS5sZW5ndGggIT09IGtleXMyLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlXG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGtleXMxLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3QgazEgPSBrZXlzMVtpXTtcbiAgICAgICAgICAgIGNvbnN0IGsyID0ga2V5czJbaV07XG4gICAgICAgICAgICBpZiAoazEgIT09IGsyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNvbnN0IHYxID0gb2JqMVtrMV07XG4gICAgICAgICAgICBjb25zdCB2MiA9IG9iajJbazJdO1xuXG4gICAgICAgICAgICBpZiAoIVV0aWxzLmVxdWFsVmFsdWVzKHYxLCB2MikpIHtcbiAg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liWzRdKTtcbiAgICAgICAgICAgICAgICBpZiAoYXR0cmliWzVdKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9lbmFibGVWZXJ0ZXhBdHRyaWJBcnJheShpbmRleCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2wuX2Rpc2FibGVWZXJ0ZXhBdHRyaWJBcnJheShpbmRleCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBXaGVuIGJ1ZmZlcnMgYXJlIGNoYW5nZWQsIHByZXZpb3VzIGF0dHJpYnV0ZXMgd2VyZSByZXNldCBhdXRvbWF0aWNhbGx5LlxuICAgICAgICAgICAgcy5fdmVydGV4QXR0cmlicy5mb3JFYWNoKChhdHRyaWIsIGluZGV4KSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGF0dHJpYlswXSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBEbyBub3Qgc2V0IHZlcnRleCBhdHRyaWIgcG9pbnRlciB3aGVuIGl0IHdhcyBqdXN0IHRoZSBkZWZhdWx0IHZhbHVlLlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbC5fdmVydGV4QXR0cmliUG9pbnRlcihpbmRleCwgYXR0cmliWzBdLCBhdHRyaWJbMV0sIGF0dHJpYlsyXSwgYXR0cmliWzNdLCBhdHRyaWJbNF0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoYXR0cmliWzVdKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9lbmFibGVWZXJ0ZXhBdHRyaWJBcnJheShpbmRleCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfbWlncmF0ZVNldHRpbmdzKHQsIHMpIHtcbiAgICAgICAgY29uc3Qg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bkRlZmF1bHRGbGFncy5mb3JFYWNoKHNldHRpbmcgPT4ge1xuICAgICAgICAgICAgaWYgKCFzLl9ub25EZWZhdWx0RmxhZ3MuaGFzKHNldHRpbmcpKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2dldERlZmF1bHRGbGFnKHNldHRpbmcpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9lbmFibGUoc2V0dGluZyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2wuX2Rpc2FibGUoc2V0dGluZyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgcy5fbm9uRGVmYXVsdEZsYWdzLmZvckVhY2goc2V0dGluZyA9PiB7XG4gICAgICAgICAgICBpZiAoIXQuX25vbkRlZmF1bHRGbGFncy5oYXMoc2V0dGluZykpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fZ2V0RGVmYXVsdEZsYWcoc2V0dGluZykpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2wuX2Rpc2FibGUoc2V0dGluZyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2wuX2VuYWJsZShzZXR0aW5nKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXREZWZhdWx0U2V0dGluZ3MoKSB7XG4gICAgICAgIGlmICghdGhpcy5fZGVmYXVsdFNldHRpbmdzKSB7XG4gICAgICAgICAgICB0aGlzLl9kZWZhdWx0U2V0dGluZ3MgPSBuZXcgTWFwKCk7XG4gICAgICAgICAgICBjb25zdCBkID0gdGhpcy5fZGVmYXVsdFNldHRpbmdzO1xuICAgICAgICAgICAgY29uc3QgZyA9IFdlYkdMUmVuZGVyaW5nQ29udGV4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AgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAvLyBTaG91bGRuJ3QgaGFwcGVuLlxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignVW5rbm93biB0ZXh0dXJlIHRhcmdldDogJyArIHRhcmdldCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgX2dldFRleHR1cmVUYXJnZXRCeUluZGV4KGluZGV4KSB7XG4gICAgICAgIGlmICghdGhpcy5fdGV4dHVyZVRhcmdldEluZGljZXMpIHtcbiAgICAgICAgICAgIHRoaXMuX3RleHR1cmVUYXJnZXRJbmRpY2VzID0gWzB4MERFMSwgMHg4NTEzXTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5fdGV4dHVyZVRhcmdldEluZGljZXNbaW5kZXhdXG4gICAgfVxuXG4gICAgc3RhdGljIF9nZXRUZXh0dXJlSW5kZXgoaW5kZXgpIHtcbiAgICAgICAgcmV0dXJuIGluZGV4IC0gMHg4NEMwIC8qIEdMX1RFWFRVUkUwICovO1xuICAgIH1cblxuICAgIHN0YXRpYyBfZ2V0VGV4dHVyZUJ5SW5kZXgoaW5kZXgpIHtcbiAgICAgICAgcmV0dXJuIGluZGV4ICsgMHg4NEMwO1xuICAgIH1cblxuICAgIHN0YXRpYyBfZ2V0UGl4ZWxTdG9yZWlJbmRleChwbmFtZSkge1xuICAgICAgICBzd2l0Y2gocG5hbWUpIHtcbiAgICAgICAgICAgIGNhc2UgMHgwRDA1OlxuICAgICAgICAgICAgICAgIC8qIFBBQ0tfQUxJR05NRU5UICovXG4gICAgICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgICAgICBjYXNlIDB4MENGNTpcbiAgICAgICAgICAgICAgICAvKiBVTlBBQ0tfQUxJR05NRU5UICovXG4gICAgICAgICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgICAgICBjYXNlIDB4OTI0MDpcbiAgICAgICAgICAgICAgICAvKiBVTlBBQ0tfR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tZSAhPT0gXCJjb25zdHJ1Y3RvclwiKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbWV0aG9kID0gV2ViR0xTdGF0ZU1hbmFnZXIucHJvdG90eXBlW25hbWVdO1xuICAgICAgICAgICAgICAgIGlmIChuYW1lLmNoYXJBdCgwKSA9PT0gXCIkXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgbmFtZSA9IG5hbWUuc3Vic3RyKDEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoZ2xbbmFtZV0gIT09IG1ldGhvZCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZ2xbbmFtZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZ2xbbmFtZV0ubmFtZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFdlIGRvIHRoaXMgZm9yIGNvbXBhdGliaWxpdHkgd2l0aCB0aGUgQ2hyb21lIFdlYkdMIEluc3BlY3RvciBwbHVnaW4uXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2xbbmFtZV0ueG5hbWUgPSBuYW1lO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgZ2xbJ18nICsgbmFtZV0gPSBnbFtuYW1lXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBnbFtuYW1lXSA9IG1ldGhvZDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIFdlYkdMU3RhdGVNYW5hZ2VyLnByb3RvdHlwZS5faW5pdFN0YXRlTWFuYWdlci5jYWxsKGdsLCBpZCk7XG5cbiAgICAgICAgcmV0dXJuIGdsO1xuICAgIH1cblxufVxuXG5leHBvcnQgZGVmYXVsdCBXZWJHTFN0YXRlTWFuYWdlcjtcbiIsIi8qXG4gKiBJZiBub3Qgc3RhdGVkIG90aGVyd2lzZSBpbiB0a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XMgZW5hYmxlZCBhbmQgaXQgaXMgd2l0aGluIGJvdW5kcy5cbiAgICAgICAgICogQHR5cGUge2Jvb2xlYW59XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9fYWN0aXZlID0gZmFsc2U7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEB0eXBlIHtFbGVtZW50fVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fX3BhcmVudCA9IG51bGw7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSB0ZXh0dXJlIHRoYXQgaXMgY3VycmVudGx5IHNldC5cbiAgICAgICAgICogQHR5cGUge1RleHR1cmV9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9fdGV4dHVyZSA9IG51bGw7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSBjdXJyZW50bHkgZGlzcGxheWVkIHRleHR1cmUuIFdoaWxlIHRoaXMudGV4dHVyZSBpcyBsb2FkaW5nLCB0aGlzIG9uZSBtYXkgYmUgZGlmZmVyZW50LlxuICAgICAgICAgKiBAdHlwZSB7VGV4dHVyZX1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX19kaXNwbGF5ZWRUZXh0dXJlID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGFncyB0aGF0IGNhbiBiZSB1c2VkIHRvIGlkZW50aWZ5L3NlYXJjaCBmb3IgYSBzcGVjaWZpYyBlbGVtZW50LlxuICAgICAgICAgKiBAdHlwZSB7U3RyaW5nW119XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9fdGFncyA9IG51bGw7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSB0cmVlJ3MgdGFncyBtYXBwaW5nLlxuICAgICAgICAgKiBUaGlzIGNvbnRhaW5zIGFsbCBlbGVtZW50cyBmb3IgYWxsIGtub3duIHRhZ3MsIGF0IGFsbCB0aW1lcy5cbiAgICAgICAgICogQHR5cGUge01hcH1cbiAgICAg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ICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVUYWcodGhpcy5fX3JlZik7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX19wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3BhcmVudC5fX2NoaWxkTGlzdC5jbGVhclJlZih0aGlzLl9fcmVmKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX19yZWYgPSByZWY7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9fcmVmKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fYWRkVGFnKHRoaXMuX19yZWYpO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9fcGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19wYXJlbnQuX19jaGlsZExpc3Quc2V0UmVmKHRoaXMuX19yZWYsIHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCByZWYoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fcmVmO1xuICAgIH1cblxuICAgIGdldCBjb3JlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmU7XG4gICAgfVxuXG4gICAgc2V0QXNSb290KCkge1xuICAgICAgICB0aGlzLl9fY29yZS5zZXRBc1Jvb3QoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQXR0YWNoZWRGbGFnKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUVuYWJsZWRGbGFnKCk7XG4gICAgfVxuXG4gICAgZ2V0IGlzUm9vdCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmlzUm9vdDtcbiAgICB9XG5cbiAgICBfc2V0UGFyZW50KHBhcmVudCkge1xuICAgICAgICBpZiAodGhpcy5fX3BhcmVudCA9PT0gcGFyZW50KSByZXR1cm47XG5cbiAgICAgICAgaWYgKHRoaXMuX19wYXJlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX3Vuc2V0VGFnc1BhcmVudCgpO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fX3BhcmVudCA9IHBhcmVudDtcblxuICAgICAgICBpZiAocGFyZW50KSB7XG4gICAgICAgICAgICB0aGlzLl9zZXRUYWdzUGFyZW50KCk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl91cGRhdGVBdHRhY2hlZEZsYWcoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlRW5hYmxlZEZsYWcoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29sbGlzaW9uKCk7XG5cbiAgICAgICAgaWYgKHRoaXMuaXNSb290ICYmIHBhcmVudCkge1xuICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlJvb3Qgc2hvdWxkIG5vdCBiZSBhZGRlZCBhcyBhIGNoaWxkISBSZXN1bHRzIGFyZSB1bnNwZWNpZmllZCFcIik7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZ2V0RGVwdGgoKSB7XG4gICAgICAgIGxldCBkZXB0aCA9IDA7XG5cbiAgICAgICAgbGV0IHAgPSB0aGlzLl9fcGFyZW50O1xuICAgICAgICB3aGlsZShwKSB7XG4gICAgICAgICAgICBkZXB0aCsrO1xuICAgICAgICAgICAgcCA9IHAuX19wYXJlbnQ7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZGVwdGg7XG4gICAgfTtcblxuICAgIGdldEFuY2VzdG9yKGwpIHtcbiAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICB3aGlsZSAobCA+IDAgJiYgcC5fX3BhcmVudCkge1xuICAgICAgICAgICAgcCA9IHAuX19wYXJlbnQ7XG4gICAgICAgICAgICBsLS07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHA7XG4gICAgfTtcblxuICAgIGdldEFuY2VzdG9ycygpIHtcbiAgICAgICAgY29uc3QgYSA9IFtdO1xuICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgIHdoaWxlIChwKSB7XG4gICAgICAgICAgICBhLnB1c2gocCk7XG4gICAgICAgICAgICBwID0gcC5fX3BhcmVudDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYTtcbiAgICB9XG5cbiAgICBnZXRBbmNlc3RvckF0RGVwdGgoZGVwdGgpIHtcbiAgICAgICAgbGV0IGxldmVscyA9IHRoaXMuZ2V0RGVwdGgoKSAtIGRlcHRoO1xuICAgICAgICBpZiAobGV2ZWxzIDwgMCkge1xuICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0QW5jZXN0b3IobGV2ZWxzKTtcbiAgICB9O1xuXG4gICAgaXNBbmNlc3Rvck9mKGMpIHtcbiAgICAgICAgbGV0IHAgPSBjO1xuICAgICAgICB3aGlsZShwID0gcC5wYXJlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzID09PSBwKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH07XG5cbiAgICBnZXRTaGFyZWRBbmNlc3RvcihjKSB7XG4gICAgICAgIGxldCBvMSA9IHRoaXM7XG4gICAgICAgIGxldCBvMiA9IGM7XG4gICAgICAgIGxldCBsMSA9IG8xLmdldERlcHRoKCk7XG4gICAgICAgIGxldCBsMiA9IG8yLmdldERlcHRoKCk7XG4gICAgICAgIGlmIChsMSA+IGwyKSB7XG4gICAgICAgICAgICBvMSA9IG8xLmdldEFuY2VzdG9yKGwxIC0gbDIpO1xuICAgICAgICB9IGVsc2UgaWYgKGwyID4gbDEpIHtcbiAgICAgICAgICAgIG8yID0gbzIuZ2V0QW5jZXN0b3IobDIgLSBsMSk7XG4gICAgICAgIH1cblxuICAgICAgICBkbyB7XG4gICAgICAg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XBkYXRlQXR0YWNoZWRGbGFnKCkge1xuICAgICAgICBsZXQgbmV3QXR0YWNoZWQgPSB0aGlzLl9pc0F0dGFjaGVkKCk7XG4gICAgICAgIGlmICh0aGlzLl9fYXR0YWNoZWQgIT09IG5ld0F0dGFjaGVkKSB7XG4gICAgICAgICAgICB0aGlzLl9fYXR0YWNoZWQgPSBuZXdBdHRhY2hlZDtcblxuICAgICAgICAgICAgaWYgKG5ld0F0dGFjaGVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb25TZXR1cCgpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgY2hpbGRyZW4gPSB0aGlzLl9jaGlsZHJlbi5nZXQoKTtcbiAgICAgICAgICAgIGlmIChjaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIGxldCBtID0gY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGlmIChtID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG07IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRyZW5baV0uX3VwZGF0ZUF0dGFjaGVkRmxhZygpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAobmV3QXR0YWNoZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vbkF0dGFjaCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vbkRldGFjaCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIC8qKlxuICAgICAqIFVwZGF0ZXMgdGhlICdlbmFibGVkJyBmbGFnIGZvciB0aGlzIGJyYW5jaC5cbiAgICAgKi9cbiAgICBfdXBkYXRlRW5hYmxlZEZsYWcoKSB7XG4gICAgICAgIGxldCBuZXdFbmFibGVkID0gdGhpcy5faXNFbmFibGVkKCk7XG4gICAgICAgIGlmICh0aGlzLl9fZW5hYmxlZCAhPT0gbmV3RW5hYmxlZCkge1xuICAgICAgICAgICAgaWYgKG5ld0VuYWJsZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vbkVuYWJsZWQoKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXRFbmFibGVkRmxhZygpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vbkRpc2FibGVkKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fdW5zZXRFbmFibGVkRmxhZygpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgY2hpbGRyZW4gPSB0aGlzLl9jaGlsZHJlbi5nZXQoKTtcbiAgICAgICAgICAgIGlmIChjaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIGxldCBtID0gY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGlmIChtID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG07IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRyZW5baV0uX3VwZGF0ZUVuYWJsZWRGbGFnKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgX3NldEVuYWJsZWRGbGFnKCkge1xuICAgICAgICB0aGlzLl9fZW5hYmxlZCA9IHRydWU7XG5cbiAgICAgICAgLy8gRm9yY2UgcmUtY2hlY2sgb2YgdGV4dHVyZSBiZWNhdXNlIGRpbWVuc2lvbnMgbWlnaHQgaGF2ZSBjaGFuZ2VkIChjdXR0aW5nKS5cbiAgICAgICAgdGhpcy5fdXBkYXRlRGltZW5zaW9ucygpO1xuICAgICAgICB0aGlzLl91cGRhdGVUZXh0dXJlQ29vcmRzKCk7XG5cbiAgICAgICAgaWYgKHRoaXMuX190ZXh0dXJlKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGV4dHVyZS5hZGRFbGVtZW50KHRoaXMpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMud2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICB0aGlzLl9zZXRBY3RpdmVGbGFnKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fX2NvcmUuc2hhZGVyKSB7XG4gICAgICAgICAgICB0aGlzLl9fY29yZS5zaGFkZXIuYWRkRWxlbWVudCh0aGlzLl9fY29yZSk7XG4gICAgICAgIH1cblxuICAgIH1cblxuICAgIF91bnNldEVuYWJsZWRGbGFnKCkge1xuICAgICAgICBpZiAodGhpcy5fX2FjdGl2ZSkge1xuICAgICAgICAgICAgdGhpcy5fdW5zZXRBY3RpdmVGbGFnKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fX3RleHR1cmUpIHtcbiAgICAgICAgICAgIHRoaXMuX190ZXh0dXJlLnJlbW92ZUVsZW1lbnQodGhpcyk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fX2NvcmUuc2hhZGVyKSB7XG4gICAgICAgICAgICB0aGlzLl9fY29yZS5zaGFkZXIucmVtb3ZlRWxlbWVudCh0aGlzLl9fY29yZSk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fdGV4dHVyaXplcikge1xuICAgICAgICAgICAgdGhpcy50ZXh0dXJpemVyLmZpbHRlcnMuZm9yRWFjaChmaWx0ZXIgPT4gZmlsdGVyLnJlbW92ZUVsZW1lbnQodGhpcy5fX2NvcmUpKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuX19lbmFibGVkID0gZmFsc2U7XG4gICAgfVxuXG4gICAgX3NldEFjdGl2ZUZsYWcoKSB7XG4gICAgICAgIHRoaXMuX19hY3RpdmUgPSB0cnVlO1xuXG4gICAgICAgIC8vIFRoaXMgbXVzdCBoYXBwZW4gYmV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hpcy5fX3RleHR1cmUuZ2V0UmVuZGVySGVpZ2h0KCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBnZXQgcmVuZGVyV2lkdGgoKSB7XG4gICAgICAgIGlmICh0aGlzLl9fZW5hYmxlZCkge1xuICAgICAgICAgICAgLy8gUmVuZGVyIHdpZHRoIGlzIG9ubHkgbWFpbnRhaW5lZCBpZiB0aGlzIGVsZW1lbnQgaXMgZW5hYmxlZC5cbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5nZXRSZW5kZXJXaWR0aCgpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2dldFJlbmRlcldpZHRoKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgcmVuZGVySGVpZ2h0KCkge1xuICAgICAgICBpZiAodGhpcy5fX2VuYWJsZWQpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5nZXRSZW5kZXJIZWlnaHQoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9nZXRSZW5kZXJIZWlnaHQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBmaW5hbFgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS54O1xuICAgIH1cblxuICAgIGdldCBmaW5hbFkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS55O1xuICAgIH1cblxuICAgIGdldCBmaW5hbFcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS53O1xuICAgIH1cblxuICAgIGdldCBmaW5hbEgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5oO1xuICAgIH1cblxuICAgIHRleHR1cmVJc0xvYWRlZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX190ZXh0dXJlICYm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leHR1cmUpIHtcbiAgICAgICAgICAgICAgICBCYXNlLnBhdGNoT2JqZWN0KHRleHR1cmUsIHYpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKCF2KSB7XG4gICAgICAgICAgICB0ZXh0dXJlID0gbnVsbDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh2LmlzVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIHRleHR1cmUgPSB2O1xuICAgICAgICAgICAgfSBlbHNlIGlmICh2LmlzVGV4dHVyZVNvdXJjZSkge1xuICAgICAgICAgICAgICAgIHRleHR1cmUgPSBuZXcgU291cmNlVGV4dHVyZSh0aGlzLnN0YWdlKTtcbiAgICAgICAgICAgICAgICB0ZXh0dXJlLnRleHR1cmVTb3VyY2UgPSB2O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiW0xpZ2h0bmluZ10gUGxlYXNlIHNwZWNpZnkgYSB0ZXh0dXJlIHR5cGUuXCIpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHByZXZUZXh0dXJlID0gdGhpcy5fX3RleHR1cmU7XG4gICAgICAgIGlmICh0ZXh0dXJlICE9PSBwcmV2VGV4dHVyZSkge1xuICAgICAgICAgICAgdGhpcy5fX3RleHR1cmUgPSB0ZXh0dXJlO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fX3RleHR1cmUpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fX2VuYWJsZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3RleHR1cmUuYWRkRWxlbWVudCh0aGlzKTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZS5pc0xvYWRlZCgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGlzcGxheWVkVGV4dHVyZSh0aGlzLl9fdGV4dHVyZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2VuYWJsZVRleHR1cmVFcnJvcigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBNYWtlIHN1cmUgdGhhdCBjdXJyZW50IHRleHR1cmUgaXMgY2xlYXJlZCB3aGVuIHRoZSB0ZXh0dXJlIGlzIGV4cGxpY2l0bHkgc2V0IHRvIG51bGwuXG4gICAgICAgICAgICAgICAgdGhpcy5fc2V0RGlzcGxheWVkVGV4dHVyZShudWxsKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHByZXZUZXh0dXJlICYmIHByZXZUZXh0dXJlICE9PSB0aGlzLl9fZGlzcGxheWVkVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIHByZXZUZXh0dXJlLnJlbW92ZUVsZW1lbnQodGhpcyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZURpbWVuc2lvbnMoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBkaXNwbGF5ZWRUZXh0dXJlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2Rpc3BsYXllZFRleHR1cmU7XG4gICAgfVxuXG4gICAgX3NldERpc3BsYXllZFRleHR1cmUodikge1xuICAgICAgICBsZXQgcHJldlRleHR1cmUgPSB0aGlzLl9fZGlzcGxheWVkVGV4dHVyZTtcblxuICAgICAgICBpZiAocHJldlRleHR1cmUgJiYgKHYgIT09IHByZXZUZXh0dXJlKSkge1xuICAgICAgICAg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WJsZSB0byBkZXRlcm1pbmUgd2l0aGluQm91bmRzLlxuICAgICAgICAgICAgICAgIHcgPSB3IHx8IHRoaXMuX190ZXh0dXJlLm13O1xuICAgICAgICAgICAgICAgIGggPSBoIHx8IHRoaXMuX190ZXh0dXJlLm1oO1xuXG4gICAgICAgICAgICAgICAgaWYgKCghdyB8fCAhaCkgJiYgdGhpcy5fX3RleHR1cmUuaXNBdXRvc2l6ZVRleHR1cmUoKSkge1xuICAgICAgICAgICAgICAgICAgICB1bmtub3duU2l6ZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX19jb3JlLnNldERpbWVuc2lvbnModywgaCwgdW5rbm93blNpemUpKSB7XG4gICAgICAgICAgICB0aGlzLl9vblJlc2l6ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3VwZGF0ZVRleHR1cmVDb29yZHMoKSB7XG4gICAgICAgIGlmICh0aGlzLmRpc3BsYXllZFRleHR1cmUgJiYgdGhpcy5kaXNwbGF5ZWRUZXh0dXJlLl9zb3VyY2UpIHtcbiAgICAgICAgICAgIGxldCBkaXNwbGF5ZWRUZXh0dXJlID0gdGhpcy5kaXNwbGF5ZWRUZXh0dXJlO1xuICAgICAgICAgICAgbGV0IGRpc3BsYXllZFRleHR1cmVTb3VyY2UgPSB0aGlzLmRpc3BsYXllZFRleHR1cmUuX3NvdXJjZTtcblxuICAgICAgICAgICAgbGV0IHR4MSA9IDAsIHR5MSA9IDAsIHR4MiA9IDEuMCwgdHkyID0gMS4wO1xuICAgICAgICAgICAgaWYgKGRpc3BsYXllZFRleHR1cmUuY2xpcHBpbmcpIHtcbiAgICAgICAgICAgICAgICAvLyBBcHBseSB0ZXh0dXJlIGNsaXBwaW5nLlxuICAgICAgICAgICAgICAgIGxldCB3ID0gZGlzcGxheWVkVGV4dHVyZVNvdXJjZS5nZXRSZW5kZXJXaWR0aCgpO1xuICAgICAgICAgICAgICAgIGxldCBoID0gZGlzcGxheWVkVGV4dHVyZVNvdXJjZS5nZXRSZW5kZXJIZWlnaHQoKTtcbiAgICAgICAgICAgICAgICBsZXQgaXcsIGloLCBydywgcmg7XG4gICAgICAgICAgICAgICAgaXcgPSAxIC8gdztcbiAgICAgICAgICAgICAgICBpaCA9IDEgLyBoO1xuXG4gICAgICAgICAgICAgICAgaWYgKGRpc3BsYXllZFRleHR1cmUucHcpIHtcbiAgICAgICAgICAgICAgICAgICAgcncgPSAoZGlzcGxheWVkVGV4dHVyZS5wdykgKiBpdztcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBydyA9ICh3IC0gZGlzcGxheWVkVGV4dHVyZS5weCkgKiBpdztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoZGlzcGxheWVkVGV4dHVyZS5waCkge1xuICAgICAgICAgICAgICAgICAgICByaCA9IGRpc3BsYXllZFRleHR1cmUucGggKiBpaDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByaCA9IChoIC0gZGlzcGxheWVkVGV4dHVyZS5weSkgKiBpaDtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpdyAqPSAoZGlzcGxheWVkVGV4dHVyZS5weCk7XG4gICAgICAgICAgICAgICAgaWggKj0gKGRpc3BsYXllZFRleHR1cmUucHkpO1xuXG4gICAgICAgICAgICAgICAgdHgxID0gaXc7XG4gICAgICAgICAgICAgICAgdHkxID0gaWg7XG4gICAgICAgICAgICAgICAgdHgyID0gdHgyICogcncgKyBpdztcbiAgICAgICAgICAgICAgICB0eTIgPSB0eTIgKiByaCArIGloO1xuXG4gICAgICAgICAgICAgICAgdHgxID0gTWF0aC5tYXgoMCwgdHgxKTtcbiAgICAgICAgICAgICAgICB0eTEgPSBNYXRoLm1heCgwLCB0eTEpO1xuICAgICAgICAgICAgICAgIHR4MiA9IE1hdGgubWluKDEsIHR4Mik7XG4gICAgICAgICAgICAgICAgdHkyID0gTWF0aC5taW4oMSwgdHkyKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGRpc3BsYXllZFRleHR1cmVTb3VyY2UuX2ZsaXBUZXh0dXJlWSkge1xuICAgICAgICAgICAgICAgIGxldCB0ZW1wdHkgPSB0eTI7XG4gICAgICAgICAgICAgICAgdHkyID0gdHkxO1xuICAgICAgICAgICAgICAgIHR5MSA9IHRlbXB0eTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX19jb3JlLnNldFRleHR1cmVDb29yZHModHgxLCB0eTEsIHR4MiwgdHkyKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldENvcm5lclBvaW50cygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmdldENvcm5lclBvaW50cygpO1xuICAgIH1cblxuICAgIF91bnNldFRhZ3NQYXJlbnQoKSB7XG4gICAgICAgIGlmICh0aGlzLl9fdGFncykge1xuICAgICAgICAgICAgdGhpcy5fX3RhZ3MuZm9yRWFjaCgodGFnKSA9PiB7XG4gICAgICAgICAgICAgICAgLy8gUmVtb3ZlIGZyb20gdHJlZVRhZ3MuXG4gICAgICAgICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgICAgICAgIHdoaWxlIChwID0gcC5fX3BhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICBsZXQgcGFyZW50VHJlZVRhZ3MgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICAgICAgICAgIHBhcmVudFRyZWVUYWdzLmRlbGV0ZSh0aGlzKTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgdGFncyA9IG51bGw7XG4gICAgICAgIGxldCBuID0gMDtcbiAgICAgICAgaWYgKHRoaXMuX190cmVlVGFncykge1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgIHRhZ3MgPSBVdGlscy5pdGVyYXRvclRvQXJyYXkodGhpcy5fX3RyZWVUYWdzLmtleXMoKSk7XG4gICAgICAgICAgICAgICAgbiA9IHRhZ3MubGVuZ3RoO1xuXG4gICAgICAgICAgICAgICAgaWYgKG4gPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGFnU2V0ID0gdGhpcy5fX3RyZWVUYWdzLmdldCh0YWdzW2ldKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVtb3ZlIGZyb20gdHJlZVRhZ3MuXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKHAgPSBwLl9fcGFyZW50KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXJlbnRUcmVlVGFncyA9IHAuX190cmVlVGFncy5nZXQodGFnc1tpXSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWdTZXQuZm9yRWFjaChmdW5jdGlvbiAoY29tcCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnRUcmVlVGFncy5kZWxldGUoY29tcCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIF9zZXRUYWdzUGFyZW50KCkge1xuICAgICAgICAvLyBKdXN0IGNvcHkgb3ZlciB0aGUgJ2xvY2FsJyB0YWdzLlxuICAgICAgICBpZiAodGhpcy5fX3RhZ3MpIHtcbiAgICAgICAgICAgIHRoaXMuX190YWdzLmZvckVhY2goKHRhZykgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICAgICAgICB3aGlsZSAocCA9IHAuX19wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAuX190cmVlVGFncyA9IG5ldyBNYXAoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMgPSBuZXcgU2V0KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBzLmFkZCh0aGlzKTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fX3RyZWVUYWdzICYmIHRoaXMuX190cmVlVGFncy5zaXplKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX3RyZWVUYWdzLmZvckVhY2goKHRhZ1NldCwgdGFnKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBEbyBub3QgY29weSBhbGwgc3Vicy5cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gbmV3IE1hcCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMgPSBuZXcgU2V0KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICB0YWdTZXQuZm9yRWFjaChmdW5jdGlvbiAoY29tcCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMuYWRkKGNvbXApO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cblxuICAgIF9nZXRCeVRhZyh0YWcpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgIHJldHVybiBbXTtcbiAgICAgICAgfVxuICAgICAgICBsZXQgdCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgcmV0dXJuIHQgPyBVdGlscy5zZXRUb0FycmF5KHQpIDogW107XG4gICAgfTtcblxuICAgIGdldFRhZ3MoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fdGFncyA/IHRoaXMuX190YWdzIDogW107XG4gICAgfTtcblxuICAgIHNldFRhZ3ModGFncykge1xuICAgICAgICB0YWdzID0gdGFncy5yZWR1Y2UoKGFjYywgdGFnKSA9PiB7XG4gICAgICAgICAgICByZXR1cm4gYWNjLmNvbmNhdCh0YWcuc3BsaXQoJyAnKSk7XG4gICAgICAgIH0sIFtdKTtcblxuICAgICAgICBpZiAodGhpcy5fX3JlZikge1xuICAgICAgICAgICAgdGFncy5wdXNoKHRoaXMuX19yZWYpO1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGksIG4gPSB0YWdzLmxlbmd0aDtcbiAgICAgICAgbGV0IHJlbW92ZXMgPSBbXTtcbiAgICAgICAgbGV0IGFkZHMgPSBbXTtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmhhc1RhZyh0YWdzW2ldKSkge1xuICAgICAgICAgICAgICAgIGFkZHMucHVzaCh0YWdzW2ldKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBjdXJyZW50VGFncyA9IHRoaXMudGFncyB8fCBbXTtcbiAgICAgICAgbiA9IGN1cnJlbnRUYWdzLmxlbmd0aDtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKHRhZ3MuaW5kZXhPZihjdXJyZW50VGFnc1tpXSkgPT0gLTEpIHtcbiAgICAgICAgICAgICAgICByZW1vdmVzLnB1c2goY3VycmVudFRhZ3NbaV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJlbW92ZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHRoaXMucmVtb3ZlVGFnKHJlbW92ZXNbaV0pO1xuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGFkZHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHRoaXMuYWRkVGFnKGFkZHNbaV0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgYWRkVGFnKHRhZykge1xuICAgICAgICBpZiAodGFnLmluZGV4T2YoJyAnKSA9PT0gLTEpIHtcbiAgICAgICAgICAgIGlmIChVdGlscy5pc1VjQ2hhcih0YWcuY2hhckNvZGVBdCgwKSkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90aHJvd0Vycm9yKFwiVGFnIG1heSBub3Qgc3RhcnQgd2l0aCBhbiB1cHBlciBjYXNlIGNoYXJhY3Rlci5cIik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX2FkZFRhZyh0YWcpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3QgdGFncyA9IHRhZy5zcGxpdCgnICcpO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG0gPSB0YWdzLmxlbmd0aDsgaSA8IG07IGkrKykge1xuICAgICAgICAgICAgICAgIGNvbnN0IHRhZyA9IHRhZ3NbaV07XG5cbiAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNVY0NoYXIodGFnLmNoYXJDb2RlQXQoMCkpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJUYWcgbWF5IG5vdCBzdGFydCB3aXRoIGFuIHVwcGVyIGNhc2UgY2hhcmFjdGVyLlwiKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0aGlzLl9hZGRUYWcodGFnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9hZGRUYWcodGFnKSB7XG4gICAgICAgIGlmICghdGhpcy5fX3RhZ3MpIHtcbiAgICAgICAgICAgIHRoaXMuX190YWdzID0gW107XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX190YWdzLmluZGV4T2YodGFnKSA9PT0gLTEpIHtcbiAgICAgICAgICAgIHRoaXMuX190YWdzLnB1c2godGFnKTtcblxuICAgICAgICAgICAgLy8gQWRkIHRvIHRyZWVUYWdzIGhpZXJhcmNoeS5cbiAgICAgICAgICAgIGxldCBwID0gdGhpcy5fX3BhcmVudDtcbiAgICAgICAgICAgIGlmIChwKSB7XG4gICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gbmV3IE1hcCgpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgcyA9IG5ldyBTZXQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIHMuYWRkKHRoaXMpO1xuXG4gICAgICAgICAgICAgICAgfSB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmVtb3ZlVGFnKHRhZykge1xuICAgICAgICBsZXQgaSA9IHRoaXMuX190YWdzLmluZGV4T2YodGFnKTtcbiAgICAgICAgaWYgKGkgIT09IC0xKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGFncy5zcGxpY2UoaSwgMSk7XG5cbiAgICAgICAgICAgIC8vIFJlbW92ZSBmcm9tIHRyZWVUYWdzIGhpZXJhcmNoeS5cbiAgICAgICAgICAgIGxldCBwID0gdGhpcy5fX3BhcmVudDtcbiAgICAgICAgICAgIGlmIChwKSB7XG4gICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGxpc3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3QuZGVsZXRlKHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgaGFzVGFnKHRhZykge1xuICAgICAgICByZXR1cm4gKHRoaXMuX190YWdzICYmICh0aGlzLl9fdGFncy5pbmRleE9mKHRhZykgIT09IC0xKSk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmV0dXJucyBvbmUgb2YgdGhlIGVsZW1lbnRzIGZyb20gdGhlIHN1YnRyZWUgdGhhdCBoYXZlIHRoaXMgdGFnLlxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSB0YWdcbiAgICAgKiBAcmV0dXJucyB7RWxlbWVudH1cbiAgICAgKi9cbiAgICBfdGFnKHRhZykge1xuICAgICAgICBpZiAodGFnLmluZGV4T2YoXCIuXCIpICE9PSAtMSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMubXRhZyh0YWcpWzBdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuX190cmVlVGFncykge1xuICAgICAgICAgICAgICAgIGxldCB0ID0gdGhpcy5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgICAgIGlmICh0KSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSB0LnZhbHVlcygpLm5leHQoKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0gPyBpdGVtLnZhbHVlIDogdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBnZXQgdGFnKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdGFnO1xuICAgIH1cblxuICAgIHNldCB0YWcodCkge1xuICAgICAgICB0aGlzLnRhZ3MgPSB0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFJldHVybnMgYWxsIGVsZW1lbnRzIGZyb20gdGhlIHN1YnRyZWUgdGhhdCBoYXZlIHRoaXMgdGFnLlxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSB0YWdcbiAgICAgKiBAcmV0dXJucyB7RWxlbWVudFtdfVxuICAgICAqL1xuICAgIG10YWcodGFnKSB7XG4gICAgICAgIGxldCBpZHggPSB0YWcuaW5kZXhPZihcIi5cIik7XG4gICAgICAgIGlmIChpZHggPj0gMCkge1xuICAgICAgICAgICAgbGV0IHBhcnRzID0gdGFnLnNwbGl0KCcuJyk7XG4gICAgICAgICAgICBsZXQgcmVzID0gdGhpcy5fZ2V0QnlUYWcocGFydHNbMF0pO1xuICAgICAgICAgICAgbGV0IGxldmVsID0gMTtcbiAgICAgICAgICAgIGxldCBjID0gcGFydHMubGVuZ3RoO1xuICAgICAgICAgICAgd2hpbGUgKHJlcy5sZW5ndGggJiYgbGV2ZWwgPCBjKSB7XG4gICAgICAgICAgICAgICAgbGV0IHJlc24gPSBbXTtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMCwgbiA9IHJlcy5sZW5ndGg7IGogPCBuOyBqKyspIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzbiA9IHJlc24uY29uY2F0KHJlc1tqXS5fZ2V0QnlUYWcocGFydHNbbGV2ZWxdKSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgcmVzID0gcmVzbjtcbiAgICAgICAgICAgICAgICBsZXZlbCsrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHJlcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9nZXRCeVRhZyh0YWcpO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHN0YWcodGFnLCBzZXR0aW5ncykge1xuICAgICAgICBsZXQgdCA9IHRoaXMubXRhZyh0YWcpO1xuICAgICAgICBsZXQgbiA9IHQubGVuZ3RoO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgQmFzZS5wYXRjaE9iamVjdCh0W2ldLCBzZXR0aW5ncyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdGFnUm9vdCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX190YWdSb290O1xuICAgIH1cblxuICAgIHNldCB0YWdSb290KHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX190YWdSb290ICE9PSB2KSB7XG4gICAgICAgICAgICBpZiAoIXYpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXRUYWdzUGFyZW50KCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3Vuc2V0VGFnc1BhcmVudCgpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9fdGFnUm9vdCA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzZWwocGF0aCkge1xuICAgICAgICBjb25zdCByZXN1bHRzID0gdGhpcy5zZWxlY3QocGF0aCk7XG4gICAgICAgIGlmIChyZXN1bHRzLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdHNbMF07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2VsZWN0KHBhdGgpIHtcbiAgICAgICAgaWYgKHBhdGguaW5kZXhPZihcIixcIikgIT09IC0xKSB7XG4gICAgICAgICAgICBsZXQgc2VsZWN0b3JzID0gcGF0aC5zcGxpdCgnLCcpO1xuICAgICAgICAgICAgbGV0IHJlcyA9IFtdO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzZWxlY3RvcnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICByZXMgPSByZXMuY29uY2F0KHRoaXMuX3NlbGVjdChzZWxlY3RvcnNbaV0pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiByZXM7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc2VsZWN0KHBhdGgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3NlbGVjdChwYXRoKSB7XG4gICAgICAgIGlmIChwYXRoID09PSBcIlwiKSByZXR1cm4gW3RoaXNdO1xuXG5cbiAgICAgICAgbGV0IHBvaW50SWR4ID0gcGF0aC5pbmRleE9mKFwiLlwiKTtcbiAgICAgICAgbGV0IGFycm93SWR4ID0gcGF0aC5pbmRleE9mKFwiPlwiKTtcbiAgICAgICAgaWYgKHBvaW50SWR4ID09PSAtMSAmJiBhcnJvd0lkeCA9PT0gLTEpIHtcbiAgICAgICAgICAgIC8vIFF1aWNrIGNhc2UuXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5tdGFnKHBhdGgpO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gRGV0ZWN0IGJ5IGZpcnN0IGNoYXIuXG4gICAgICAgIGxldCBpc1JlZjtcbiAgICAgICAgaWYgKGFycm93SWR4ID09PSAwKSB7XG4gICAgICAgICAgICBpc1JlZiA9IHRydWU7XG4gICAgICAgICAgICBwYXRoID0gcGF0aC5zdWJzdHIoMSk7XG4gICAgICAgIH0gZWxzZSBpZiAocG9pbnRJZHggPT09IDApIHtcbiAgICAgICAgICAgIGlzUmVmID0gZmFsc2U7XG4gICAgICAgICAgICBwYXRoID0gcGF0aC5zdWJzdHIoMSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpc1JlZiA9IGZhbHNlO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHRoaXMuX3NlbGVjdENoaWxkcyhwYXRoLCBpc1JlZik7XG4gICAgfVxuXG4gICAgX3NlbGVjdENoaWxkcyhwYXRoLCBpc1JlZikge1xuICAgICAgICBjb25zdCBwb2ludElkeCA9IHBhdGguaW5kZXhPZihcIi5cIik7XG4gICAgICAgIGNvbnN0IGFycm93SWR4ID0gcGF0aC5pbmRleE9mKFwiPlwiKTtcblxuICAgICAgICBpZiAocG9pbnRJZHggPT09IC0xICYmIGFycm93SWR4ID09PSAtMSkge1xuICAgICAgICAgICAgaWYgKGlzUmVmKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVmID0gdGhpcy5nZXRCeVJlZihwYXRoKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gcmVmID8gW3JlZl0gOiBbXTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubXRhZyhwYXRoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICgoYXJyb3dJZHggPT09IC0xKSB8fCAocG9pbnRJZHggIT09IC0xICYmIHBvaW50SWR4IDwgYXJyb3dJZHgpKSB7XG4gICAgICAgICAgICBsZXQgbmV4dDtcbiAgICAgICAgICAgIGNvbnN0IHN0ciA9IHBhdGguc3Vic3RyKDAsIHBvaW50SWR4KTtcbiAgICAgICAgICAgIGlmIChpc1JlZikge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJlZiA9IHRoaXMuZ2V0QnlSZWYoc3RyKTtcbiAgICAgICAgICAgICAgICBuZXh0ID0gcmVmID8gW3JlZl0gOiBbXTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbmV4dCA9IHRoaXMubXRhZyhzdHIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IHRvdGFsID0gW107XG4gICAgICAgICAgICBjb25zdCBzdWJQYXRoID0gcGF0aC5zdWJzdHIocG9pbnRJZHggKyAxKTtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gbmV4dC5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB0b3RhbCA9IHRvdGFsLmNvbmNhdChuZXh0W2ldLl9zZWxlY3RDaGlsZHMoc3ViUGF0aCwgZmFsc2UpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0b3RhbDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxldCBuZXh0O1xuICAgICAgICAgICAgY29uc3Qgc3RyID0gcGF0aC5zdWJzdHIoMCwgYXJyb3dJZHgpO1xuICAgICAgICAgICAgaWYgKGlzUmVmKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVmID0gdGhpcy5nZXRCeVJlZihzdHIpO1xuICAgICAgICAgICAgICAgIG5leHQgPSByZWYgPyBbcmVmXSA6IFtdO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBuZXh0ID0gdGhpcy5tdGFnKHN0cik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgdG90YWwgPSBbXTtcbiAgICAgICAgICAgIGNvbnN0IHN1YlBhdGggPSBwYXRoLnN1YnN0cihhcnJvd0lkeCArIDEpO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBuZXh0Lmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHRvdGFsID0gdG90YWwuY29uY2F0KG5leHRbaV0uX3NlbGVjdENoaWxkcyhzdWJQYXRoLCB0cnVlKSk7XG4gICAgICAgICAgIC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VuID0gb2JqLmNoaWxkcmVuO1xuICAgICAgICBkZWxldGUgb2JqLmNoaWxkcmVuO1xuXG5cbiAgICAgICAgLy8gQ29udmVydCBzaW5ndWxhciBqc29uIHNldHRpbmdzIG9iamVjdC5cbiAgICAgICAgbGV0IGNvbG9yS2V5cyA9IFtcImNvbG9yXCIsIFwiY29sb3JVbFwiLCBcImNvbG9yVXJcIiwgXCJjb2xvckJsXCIsIFwiY29sb3JCclwiXTtcbiAgICAgICAgbGV0IHN0ciA9IEpTT04uc3RyaW5naWZ5KG9iaiwgZnVuY3Rpb24gKGssIHYpIHtcbiAgICAgICAgICAgIGlmIChjb2xvcktleXMuaW5kZXhPZihrKSAhPT0gLTEpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gXCJDT0xPUltcIiArIHYudG9TdHJpbmcoMTYpICsgXCJdXCI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdjtcbiAgICAgICAgfSk7XG4gICAgICAgIHN0ciA9IHN0ci5yZXBsYWNlKC9cIkNPTE9SXFxbKFthLWYwLTldezEsOH0pXFxdXCIvZywgXCIweCQxXCIpO1xuXG4gICAgICAgIGlmIChjaGlsZHJlbikge1xuICAgICAgICAgICAgbGV0IGNoaWxkU3RyID0gXCJcIjtcbiAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwoY2hpbGRyZW4pKSB7XG4gICAgICAgICAgICAgICAgbGV0IHJlZnMgPSBPYmplY3Qua2V5cyhjaGlsZHJlbik7XG4gICAgICAgICAgICAgICAgY2hpbGRTdHIgPSBcIlwiO1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gcmVmcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgY2hpbGRTdHIgKz0gYFxcbiR7aW5kZW50fSAgXCIke3JlZnNbaV19XCI6YFxuICAgICAgICAgICAgICAgICAgICBkZWxldGUgY2hpbGRyZW5bcmVmc1tpXV0ucmVmO1xuICAgICAgICAgICAgICAgICAgICBjaGlsZFN0ciArPSBFbGVtZW50LmdldFByZXR0eVN0cmluZyhjaGlsZHJlbltyZWZzW2ldXSwgaW5kZW50ICsgXCIgIFwiKSArIChpIDwgbiAtIDEgPyBcIixcIiA6IFwiXCIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBsZXQgaXNFbXB0eSA9IChzdHIgPT09IFwie31cIik7XG4gICAgICAgICAgICAgICAgc3RyID0gc3RyLnN1YnN0cigwLCBzdHIubGVuZ3RoIC0gMSkgKyAoaXNFbXB0eSA/IFwiXCIgOiBcIixcIikgKyBjaGlsZFN0ciArIFwiXFxuXCIgKyBpbmRlbnQgKyBcIn1cIjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbGV0IG4gPSBjaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgICAgICAgICAgY2hpbGRTdHIgPSBcIltcIjtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZFN0ciArPSBFbGVtZW50LmdldFByZXR0eVN0cmluZyhjaGlsZHJlbltpXSwgaW5kZW50ICsgXCIgIFwiKSArIChpIDwgbiAtIDEgPyBcIixcIiA6IFwiXCIpICsgXCJcXG5cIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2hpbGRTdHIgKz0gaW5kZW50ICsgXCJdfVwiO1xuICAgICAgICAgICAgICAgIGxldCBpc0VtcHR5ID0gKHN0ciA9PT0gXCJ7fVwiKTtcbiAgICAgICAgICAgICAgICBzdHIgPSBzdHIuc3Vic3RyKDAsIHN0ci5sZW5ndGggLSAxKSArIChpc0VtcHR5ID8gXCJcIiA6IFwiLFwiKSArIFwiXFxcImNoaWxkcmVuXFxcIjpcXG5cIiArIGluZGVudCArIGNoaWxkU3RyICsgXCJ9XCI7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBzdHI7XG4gICAgfVxuXG4gICAgZ2V0U2V0dGluZ3MoKSB7XG4gICAgICAgIGxldCBzZXR0aW5ncyA9IHRoaXMuZ2V0Tm9uRGVmYXVsdHMoKTtcblxuICAgICAgICBsZXQgY2hpbGRyZW4gPSB0aGlzLl9jaGlsZHJlbi5nZXQoKTtcbiAgICAgICAgaWYgKGNoaWxkcmVuKSB7XG4gICAgICAgICAgICBsZXQgbiA9IGNoaWxkcmVuLmxlbmd0aDtcbiAgICAgICAgICAgIGlmIChuKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgY2hpbGRBcnJheSA9IFtdO1xuICAgICAgICAgICAgICAgIGxldCBtaXNzaW5nID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgY2hpbGRBcnJheS5wdXNoKGNoaWxkcmVuW2ldLmdldFNldHRpbmdzKCkpO1xuICAgICAgICAgICAgICAgICAgICBtaXNzaW5nID0gbWlzc2luZyB8fCAhY2hpbGRyZW5baV0ucmVmO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICghbWlzc2luZykge1xuICAgICAgICAgICAgICAgICAgICBzZXR0aW5ncy5jaGlsZHJlbiA9IHt9XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkQXJyYXkuZm9yRWFjaChjaGlsZCA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZXR0aW5ncy5jaGlsZHJlbltjaGlsZC5yZWZdID0gY2hpbGQ7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHNldHRpbmdzLmNoaWxkcmVuID0gY2hpbGRBcnJheTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBzZXR0aW5ncy5pZCA9IHRoaXMuaWQ7XG5cbiAgICAgICAgcmV0dXJuIHNldHRpbmdzO1xuICAgIH1cblxuICAgIGdldE5vbkRlZmF1bHRzKCkge1xuICAgICAgICBsZXQgc2V0dGluZ3MgPSB7fTtcblxuICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciAhPT0gRWxlbWVudCkge1xuICAgICAgICAgICAgc2V0dGluZ3MudHlwZSA9IHRoaXMuY29uc3RydWN0b3IubmFtZTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9fcmVmKSB7XG4gICAgICAgICAgICBzZXR0aW5ncy5yZWYgPSB0aGlzLl9fcmVmO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX190YWdzICYmIHRoaXMuX190YWdzLmxlbmd0aCkge1xuICAgICAgICAgICAgc2V0dGluZ3MudGFncyA9IHRoaXMuX190YWdzO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMueCAhPT0gMCkgc2V0dGluZ3MueCA9IHRoaXMueDtcbiAgICAgICAgaWYgKHRoaXMueSAhPT0gMCkgc2V0dGluZ3MueSA9IHRoaXMueTtcbiAgICAgICAgaWYgKHRoaXMudyAhPT0gMCkgc2V0dGluZ3MudyA9IHRoaXMudztcbiAgICAgICAgaWYgKHRoaXMuaCAhPT0gMCkgc2V0dGluZ3MuaCA9IHRoaXMuaDtcblxuICAgICAgICBpZiAodGhpcy5zY2FsZVggPT09IHRoaXMuc2NhbGVZKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5zY2FsZVggIT09IDEpIHNldHRpbmdzLnNjYWxlID0gdGhpcy5zY2FsZVg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5zY2FsZVggIT09IDEpIHNldHRpbmdzLnNjYWxlWCA9IHRoaXMuc2NhbGVYO1xuICAgICAgICAgICAgaWYgKHRoaXMuc2NhbGVZICE9PSAxKSBzZXR0aW5ncy5zY2FsZVkgPSB0aGlzLnNjYWxlWTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLnBpdm90WCA9PT0gdGhpcy5waXZvdFkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnBpdm90WCAhPT0gMC41KSBzZXR0aW5ncy5waXZvdCA9IHRoaXMucGl2b3RYO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMucGl2b3RYICE9PSAwLjUpIHNldHRpbmdzLnBpdm90WCA9IHRoaXMucGl2b3RYO1xuICAgICAgICAgICAgaWYgKHRoaXMucGl2b3RZICE9PSAwLjUpIHNldHRpbmdzLnBpdm90WSA9IHRoaXMucGl2b3RZO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMubW91bnRYID09PSB0aGlzLm1vdW50WSkge1xuICAgICAgICAgICAgaWYgKHRoaXMubW91bnRYICE9PSAwKSBzZXR0aW5ncy5tb3VudCA9IHRoaXMubW91bnRYO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMubW91bnRYICE9PSAwKSBzZXR0aW5ncy5tb3VudFggPSB0aGlzLm1vdW50WDtcbiAgICAgICAgICAgIGlmICh0aGlzLm1vdW50WSAhPT0gMCkgc2V0dGluZ3MubW91bnRZID0gdGhpcy5tb3VudFk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5hbHBoYSAhPT0gMSkgc2V0dGluZ3MuYWxwaGEgPSB0aGlzLmFscGhhO1xuXG4gICAgICAgIGlmICghdGhpcy52aXNpYmxlKSBzZXR0aW5ncy52aXNpYmxlID0gZmFsc2U7XG5cbiAgICAgICAgaWYgKHRoaXMucm90YXRpb24gIT09IDApIHNldHRpbmdzLnJvdGF0aW9uID0gdGhpcy5yb3RhdGlvbjtcblxuICAgICAgICBpZiAodGhpcy5jb2xvclVsID09PSB0aGlzLmNvbG9yVXIgJiYgdGhpcy5jb2xvckJsID09PSB0aGlzLmNvbG9yQnIgJiYgdGh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l9fdGV4dHVyZS5nZXROb25EZWZhdWx0cygpO1xuICAgICAgICAgICAgaWYgKE9iamVjdC5rZXlzKHRuZCkubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgc2V0dGluZ3MudGV4dHVyZSA9IHRuZDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLnNoYWRlciAmJiBVdGlscy5pc0Z1bmN0aW9uKHRoaXMuc2hhZGVyLmdldE5vbkRlZmF1bHRzKSkge1xuICAgICAgICAgICAgbGV0IHRuZCA9IHRoaXMuc2hhZGVyLmdldE5vbkRlZmF1bHRzKCk7XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXModG5kKS5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICBzZXR0aW5ncy5zaGFkZXIgPSB0bmQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5faGFzVGV4dHVyaXplcigpKSB7XG4gICAgICAgICAgICBpZiAodGhpcy50ZXh0dXJpemVyLmVuYWJsZWQpIHtcbiAgICAgICAgICAgICAgICBzZXR0aW5ncy5yZW5kZXJUb1RleHR1cmUgPSB0aGlzLnRleHR1cml6ZXIuZW5hYmxlZDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLnRleHR1cml6ZXIubGF6eSkge1xuICAgICAgICAgICAgICAgIHNldHRpbmdzLnJlbmRlclRvVGV4dHVyZUxhenkgPSB0aGlzLnRleHR1cml6ZXIubGF6eTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLnRleHR1cml6ZXIuY29sb3JpemUpIHtcbiAgICAgICAgICAgICAgICBzZXR0aW5ncy5jb2xvcml6ZVJlc3VsdFRleHR1cmUgPSB0aGlzLnRleHR1cml6ZXIuY29sb3JpemU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy50ZXh0dXJpemVyLnJlbmRlck9mZnNjcmVlbikge1xuICAgICAgICAgICAgICAgIHNldHRpbmdzLnJlbmRlck9mZnNjcmVlbiA9IHRoaXMudGV4dHVyaXplci5yZW5kZXJPZmZzY3JlZW47XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gc2V0dGluZ3M7XG4gICAgfTtcblxuICAgIHN0YXRpYyBnZXRHZXR0ZXIocHJvcGVydHlQYXRoKSB7XG4gICAgICAgIGxldCBnZXR0ZXIgPSBFbGVtZW50LlBST1BfR0VUVEVSUy5nZXQocHJvcGVydHlQYXRoKTtcbiAgICAgICAgaWYgKCFnZXR0ZXIpIHtcbiAgICAgICAgICAgIGdldHRlciA9IG5ldyBGdW5jdGlvbignb2JqJywgJ3JldHVybiBvYmouJyArIHByb3BlcnR5UGF0aCk7XG4gICAgICAgICAgICBFbGVtZW50LlBST1BfR0VUVEVSUy5zZXQocHJvcGVydHlQYXRoLCBnZXR0ZXIpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBnZXR0ZXI7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFNldHRlcihwcm9wZXJ0eVBhdGgpIHtcbiAgICAgICAgbGV0IHNldHRlciA9IEVsZW1lbnQuUFJPUF9TRVRURVJTLmdldChwcm9wZXJ0eVBhdGgpO1xuICAgICAgICBpZiAoIXNldHRlcikge1xuICAgICAgICAgICAgc2V0dGVyID0gbmV3IEZ1bmN0aW9uKCdvYmonLCAndicsICdvYmouJyArIHByb3BlcnR5UGF0aCArICcgPSB2Jyk7XG4gICAgICAgICAgICBFbGVtZW50LlBST1BfU0VUVEVSUy5zZXQocHJvcGVydHlQYXRoLCBzZXR0ZXIpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzZXR0ZXI7XG4gICAgfVxuXG4gICAgZ2V0IHdpdGhpbkJvdW5kc01hcmdpbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLl93aXRoaW5Cb3VuZHNNYXJnaW47XG4gICAgfVxuXG4gIC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HVybiB0aGlzLl9fY29yZS5vZmZzZXRZO1xuICAgIH1cblxuICAgIHNldCB5KHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUub2Zmc2V0WSA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93O1xuICAgIH1cblxuICAgIHNldCB3KHYpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzRnVuY3Rpb24odikpIHtcbiAgICAgICAgICAgIHRoaXMuX3cgPSAwO1xuICAgICAgICAgICAgdGhpcy5fX2NvcmUuZnVuY1cgPSB2O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdiA9IE1hdGgubWF4KHYsIDApO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3cgIT09IHYpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9fY29yZS5kaXNhYmxlRnVuY1coKTtcbiAgICAgICAgICAgICAgICB0aGlzLl93ID0gdjtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgaCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2g7XG4gICAgfVxuXG4gICAgc2V0IGgodikge1xuICAgICAgICBpZiAoVXRpbHMuaXNGdW5jdGlvbih2KSkge1xuICAgICAgICAgICAgdGhpcy5faCA9IDA7XG4gICAgICAgICAgICB0aGlzLl9fY29yZS5mdW5jSCA9IHY7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2ID0gTWF0aC5tYXgodiwgMCk7XG4gICAgICAgICAgICBpZiAodGhpcy5faCAhPT0gdikge1xuICAgICAgICAgICAgICAgIHRoaXMuX19jb3JlLmRpc2FibGVGdW5jSCgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2ggPSB2O1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZURpbWVuc2lvbnMoKTtcbi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0aGlzLl9fY29yZS5zY2FsZTtcbiAgICB9XG5cbiAgICBzZXQgc2NhbGUodikge1xuICAgICAgICB0aGlzLl9fY29yZS5zY2FsZSA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHBpdm90WCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnBpdm90WDtcbiAgICB9XG5cbiAgICBzZXQgcGl2b3RYKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUucGl2b3RYID0gdjtcbiAgICB9XG5cbiAgICBnZXQgcGl2b3RZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUucGl2b3RZO1xuICAgIH1cblxuICAgIHNldCBwaXZvdFkodikge1xuICAgICAgICB0aGlzLl9fY29yZS5waXZvdFkgPSB2O1xuICAgIH1cblxuICAgIGdldCBwaXZvdCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnBpdm90O1xuICAgIH1cblxuICAgIHNldCBwaXZvdCh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLnBpdm90ID0gdjtcbiAgICB9XG5cbiAgICBnZXQgbW91bnRYKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUubW91bnRYO1xuICAgIH1cblxuICAgIHNldCBtb3VudFgodikge1xuICAgICAgICB0aGlzLl9fY29yZS5tb3VudFggPSB2O1xuICAgIH1cblxuICAgIGdldCBtb3VudFkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5tb3VudFk7XG4gICAgfVxuXG4gICAgc2V0IG1vdW50WSh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLm1vdW50WSA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IG1vdW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUubW91bnQ7XG4gICAgfVxuXG4gICAgc2V0IG1vdW50KHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUubW91bnQgPSB2O1xuICAgIH1cblxuICAgIGdldCByb3RhdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnJvdGF0aW9uO1xuICAgIH1cblxuICAgIHNldCByb3RhdGlvbih2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLnJvdGF0aW9uID0gdjtcbiAgICB9XG5cbiAgICBnZXQgYWxwaGEoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5hbHBoYTtcbiAgICB9XG5cbiAgICBzZXQgYWxwaGEodikge1xuICAgICAgICB0aGlzLl9fY29yZS5hbHBoYSA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHZpc2libGUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS52aXNpYmxlO1xuICAgIH1cblxuICAgIHNldCB2aXNpYmxlKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUudmlzaWJsZSA9IHY7XG4gICAgfVxuICAgIFxuICAgIGdldCBjb2xvclVsKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY29sb3JVbDtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JVbCh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLmNvbG9yVWwgPSB2O1xuICAgIH1cblxuICAgIGdldCBjb2xvclVyKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY29sb3JVcjtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JVcih2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLmNvbG9yVXIgPSB2O1xuICAgIH1cblxuICAgIGdldCBjb2xvckJsKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY29sb3JCbDtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JCbCh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLmNvbG9yQmwgPSB2O1xuICAgIH1cblxuICAgIGdldCBjb2xvckJyKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY29sb3JCcjtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JCcih2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLmNvbG9yQnIgPSB2O1xuICAgIH1cblxuICAgIGdldCBjb2xvcigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNvbG9yVWw7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuY29sb3JVbCAhPT0gdiB8fCB0aGlzLmNvbG9yVXIgIT09IHYgfHwgdGhpcy5jb2xvckJsICE9PSB2IHx8IHRoaXMuY29sb3JCciAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5jb2xvclVsID0gdjtcbiAgICAgICAgICAgIHRoaXMuY29sb3JVciA9IHY7XG4gICAgICAgICAgICB0aGlzLmNvbG9yQmwgPSB2O1xuICAgICAgICAgICAgdGhpcy5jb2xvckJyID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBjb2xvclRvcCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuY29sb3JVbDtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JUb3Aodikge1xuICAgICAgICBpZiAodGhpcy5jb2xvclVsICE9PSB2IHx8IHRoaXMuY29sb3JVciAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5jb2xvclVsID0gdjtcbiAgICAgICAgICAgIHRoaXMuY29sb3JVciA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgY29sb3JCb3R0b20oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNvbG9yQmw7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yQm90dG9tKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuY29sb3JCbCAhPT0gdiB8fCB0aGlzLmNvbG9yQnIgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuY29sb3JCbCA9IHY7XG4gICAgICAgICAgICB0aGlzLmNvbG9yQnIgPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ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ZWRpYXRlbHkuXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgYztcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDYXRjaCB0aGlzIGNhc2UgdG8gY2FwdHVyZSBjcmVhdGVNb2RlIGZsYWcuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYyA9IHRoaXMuY2hpbGRMaXN0LmNyZWF0ZUl0ZW0odik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYy5wYXRjaCh2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3QodikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gdjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjLmlzRWxlbWVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGMucmVmID0gcGF0aDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYShjKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2ID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZC5wYXJlbnQuY2hpbGRMaXN0LnJlbW92ZShjaGlsZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaGlsZC5wYXRjaCh2KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh2LmlzRWxlbWVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVwbGFjZSBlbGVtZW50IGJ5IG5ldyBlbGVtZW50LlxuICAgICAgICAgICAgICAgICAgICAgICAgdi5yZWYgPSBwYXRoO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QucmVwbGFjZSh2LCBjaGlsZCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl90aHJvd0Vycm9yKFwiVW5leHBlY3RlZCB2YWx1ZSBmb3IgcGF0aDogXCIgKyBwYXRoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gUHJvcGVydHkuXG4gICAgICAgICAgICAgICAgQmFzZS5wYXRjaE9iamVjdFByb3BlcnR5KHRoaXMsIHBhdGgsIHYpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3Rocm93RXJyb3IobWVzc2FnZSkge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IodGhpcy5jb25zdHJ1Y3Rvci5uYW1lICsgXCIgKFwiICsgdGhpcy5nZXRMb2NhdGlvblN0cmluZygpICsgXCIpOiBcIiArIG1lc3NhZ2UpO1xuICAgIH1cblxuICAgIGFuaW1hdGlvbihzZXR0aW5ncykge1xuICAgICAgICByZXR1cm4gdGhpcy5zdGFnZS5hbmltYXRpb25zLmNyZWF0ZUFuaW1hdGlvbih0aGlzLCBzZXR0aW5ncyk7XG4gICAgfVxuXG4gICAgdHJhbnNpdGlvbihwcm9wZXJ0eSwgc2V0dGluZ3MgPSBudWxsKSB7XG4gICAgICAgIGlmIChzZXR0aW5ncyA9PT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2dldFRyYW5za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gaWYgKHRoaXMuX3RyYW5zaXRpb25zKSB7XG4gICAgICAgICAgICBsZXQgdCA9IHRoaXMuX3RyYW5zaXRpb25zW3Byb3BlcnR5XTtcbiAgICAgICAgICAgIGlmICh0ICYmIHQuaXNUcmFuc2l0aW9uKSB7XG4gICAgICAgICAgICAgICAgdC5maW5pc2goKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRUcmFuc2l0aW9uKHByb3BlcnR5KSB7XG4gICAgICAgIGlmICghdGhpcy5fdHJhbnNpdGlvbnMpIHtcbiAgICAgICAgICAgIHRoaXMuX3RyYW5zaXRpb25zID0ge307XG4gICAgICAgIH1cbiAgICAgICAgbGV0IHQgPSB0aGlzLl90cmFuc2l0aW9uc1twcm9wZXJ0eV07XG4gICAgICAgIGlmICghdCkge1xuICAgICAgICAgICAgLy8gQ3JlYXRlIGRlZmF1bHQgdHJhbnNpdGlvbi5cbiAgICAgICAgICAgIHQgPSBuZXcgVHJhbnNpdGlvbih0aGlzLnN0YWdlLnRyYW5zaXRpb25zLCB0aGlzLnN0YWdlLnRyYW5zaXRpb25zLmRlZmF1bHRUcmFuc2l0aW9uU2V0dGluZ3MsIHRoaXMsIHByb3BlcnR5KTtcbiAgICAgICAgfSBlbHNlIGlmICh0LmlzVHJhbnNpdGlvblNldHRpbmdzKSB7XG4gICAgICAgICAgICAvLyBVcGdyYWRlIHRvICdyZWFsJyB0cmFuc2l0aW9uLlxuICAgICAgICAgICAgdCA9IG5ldyBUcmFuc2l0aW9uKFxuICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UudHJhbnNpdGlvbnMsXG4gICAgICAgICAgICAgICAgdCxcbiAgICAgICAgICAgICAgICB0aGlzLFxuICAgICAgICAgICAgICAgIHByb3BlcnR5XG4gICAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3RyYW5zaXRpb25zW3Byb3BlcnR5XSA9IHQ7XG4gICAgICAgIHJldHVybiB0O1xuICAgIH1cblxuICAgIF9zZXRUcmFuc2l0aW9uKHByb3BlcnR5LCBzZXR0aW5ncykge1xuICAgICAgICBpZiAoIXNldHRpbmdzKSB7XG4gICAgICAgICAgICB0aGlzLl9yZW1vdmVUcmFuc2l0aW9uKHByb3BlcnR5KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwoc2V0dGluZ3MpKSB7XG4gICAgICAgICAgICAgICAgLy8gQ29udmVydCBwbGFpbiBvYmplY3QgdG8gcHJvcGVyIHNldHRpbmdzIG9iamVjdC5cbiAgICAgICAgICAgICAgICBzZXR0aW5ncyA9IHRoaXMuc3RhZ2UudHJhbnNpdGlvbnMuY3JlYXRlU2V0dGluZ3Moc2V0dGluZ3MpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoIXRoaXMuX3RyYW5zaXRpb25zKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNpdGlvbnMgPSB7fTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSB0aGlzLl90cmFuc2l0aW9uc1twcm9wZXJ0eV07XG4gICAgICAgICAgICBpZiAoY3VycmVudCAmJiBjdXJyZW50LmlzVHJhbnNpdGlvbikge1xuICAgICAgICAgICAgICAgIC8vIFJ1bnRpbWUgc2V0dGluZ3MgY2hhbmdlLlxuICAgICAgICAgICAgICAgIGN1cnJlbnQuc2V0dGluZ3MgPSBzZXR0aW5ncztcbiAgICAgICAgICAgICAgICByZXR1cm4gY3VycmVudDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gSW5pdGlhbGx5LCBvbmx5IHNldCB0aGUgc2V0dGluZ3MgYW5kIHVwZ3JhZGUgdG8gYSAncmVhbCcgdHJhbnNpdGlvbiB3aGVuIGl0IGlzIHVzZWQuXG4gICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNpdGlvbnN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XCIsIFwic2NhbGVcIixcbiAgICAgICAgICAgIFwic2NhbGVYXCIsIFwic2NhbGVZXCIsIFwic3RhdGVcIiwgXCJ0YWdcIiwgXCJ2aXNpYmxlXCIsIFwid1wiLCBcInhcIiwgXCJ5XCIsIFwiekluZGV4XCIsXG4gICAgICAgICAgICBcIiEhZmxleFwiLCBcIiEhZmxleEl0ZW1cIiwgXCJoYXNGb2N1cygpXCIsIFwiaGFzRmluYWxGb2N1cygpXCJcbiAgICAgICAgXTtcbiAgICAgICAgbGV0IG4gPSBsaXN0Lmxlbmd0aDtcblxuICAgICAgICB3aGlsZSAobi0tKSB7XG4gICAgICAgICAgICBsZXQga2V5ID0gbGlzdFtuXTtcbiAgICAgICAgICAgIGNvbnN0IGdldEJvb2xlYW4gPSAvXiF7Mn0vO1xuICAgICAgICAgICAgY29uc3QgaXNGdW5jdGlvbiA9IC9cXChcXCkkLztcblxuICAgICAgICAgICAgaWYgKGdldEJvb2xlYW4udGVzdChrZXkpKSB7XG4gICAgICAgICAgICAgICAga2V5ID0ga2V5LnN1YnN0cmluZygyLCBrZXkubGVuZ3RoKTtcbiAgICAgICAgICAgICAgICBwcm9wc1trZXldID0gISFlbGVtZW50W2tleV07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzRnVuY3Rpb24udGVzdChrZXkpKSB7XG4gICAgICAgICAgICAgICAga2V5ID0ga2V5LnN1YnN0cmluZygwLCBrZXkubGVuZ3RoIC0gMik7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBlbGVtZW50W2tleV0gPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgICAgICBwcm9wc1trZXldID0gZWxlbWVudFtrZXldKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwcm9wc1trZXldID0gZWxlbWVudFtrZXldO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7Li4ucHJ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4gICAgZ2V0IGxhc3QoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9pdGVtcy5sZW5ndGggPyB0aGlzLl9pdGVtc1t0aGlzLl9pdGVtcy5sZW5ndGggLSAxXSA6IHVuZGVmaW5lZDtcbiAgICB9XG5cbiAgICBhZGQoaXRlbSkge1xuICAgICAgICB0aGlzLmFkZEF0KGl0ZW0sIHRoaXMuX2l0ZW1zLmxlbmd0aCk7XG4gICAgfVxuXG4gICAgYWRkQXQoaXRlbSwgaW5kZXgpIHtcbiAgICAgICAgaWYgKGluZGV4ID49IDAgJiYgaW5kZXggPD0gdGhpcy5faXRlbXMubGVuZ3RoKSB7XG4gICAgICAgICAgICBsZXQgY3VycmVudEluZGV4ID0gdGhpcy5faXRlbXMuaW5kZXhPZihpdGVtKTtcbiAgICAgICAgICAgIGlmIChjdXJyZW50SW5kZXggPT09IGluZGV4KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW07XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwoaXRlbSkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBvID0gaXRlbTtcbiAgICAgICAgICAgICAgICBpdGVtID0gdGhpcy5jcmVhdGVJdGVtKG8pO1xuICAgICAgICAgICAgICAgIGl0ZW0ucGF0Y2gobyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChjdXJyZW50SW5kZXggIT0gLTEpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldEF0KGl0ZW0sIGluZGV4KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0ucmVmKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlZnNbaXRlbS5yZWZdID0gaXRlbTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5faXRlbXMuc3BsaWNlKGluZGV4LCAwLCBpdGVtKTtcb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CcpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuc2V0QXQoaXRlbSwgaW5kZXgpO1xuICAgIH1cblxuICAgIHNldEF0KGl0ZW0sIGluZGV4KSB7XG4gICAgICAgIGlmIChpbmRleCA+PSAwICYmIGluZGV4IDw9IHRoaXMuX2l0ZW1zLmxlbmd0aCkge1xuXG4gICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbyA9IGl0ZW07XG4gICAgICAgICAgICAgICAgaXRlbSA9IHRoaXMuY3JlYXRlSXRlbShvKTtcbiAgICAgICAgICAgICAgICBpdGVtLnBhdGNoKG8pO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgY3VycmVudEluZGV4ID0gdGhpcy5faXRlbXMuaW5kZXhPZihpdGVtKTtcbiAgICAgICAgICAgIGlmIChjdXJyZW50SW5kZXggIT0gLTEpIHtcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudEluZGV4ICE9PSBpbmRleCkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBmcm9tSW5kZXggPSBjdXJyZW50SW5kZXg7XG4gICAgICAgICAgICAgICAgICAgIGlmIChmcm9tSW5kZXggIT09IGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pdGVtcy5zcGxpY2UoZnJvbUluZGV4LCAxKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2l0ZW1zLnNwbGljZShpbmRleCwgMCwgaXRlbSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uTW92ZShpdGVtLCBmcm9tSW5kZXgsIGluZGV4KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYoIGluZGV4IDwgdGhpcy5faXRlbXMubGVuZ3RoKXtcblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5faXRlbXNbaW5kZXhdLnJlZikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVmc1t0aGlzLl9pdGVtc1tpbmRleF0ucmVmXSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZJdGVtID0gdGhpcy5faXRlbXNbaW5kZXhdO1xuXG4gICAgICAgICAgICAgICAgICAgIC8vIERvZXNuJ3QgZXhpc3QgeWV0OiBvdmVyd3JpdGUgY3VycmVudC5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5faXRlbXNbaW5kZXhdID0gaXRlbTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5yZWYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlZnNbaXRlbS5yZWZdID0gaXRlbTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMub25TZXQoaXRlbSwgaW5kZXgsIHByZXZJdGVtKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ3NldEF0OiBUaGUgaW5kZXggJyArIGluZGV4ICsgJyBpcyBvdXQgb2YgYm91bmRzICcgKyB0aGlzLl9pdGVtcy5sZW5ndGgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignc2V0QXQ6IFRoZSBpbmRleCAnICsgaW5kZXggKyAnIGlzIG91dCBvZiBib3VuZHMgJyArIHRoaXMuX2l0ZW1zLmxlbmd0aCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXRBdChpbmRleCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faXRlbXNbaW5kZXhdO1xuICAgIH1cblxuICAgIGd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lSXRlbShzKTtcbiAgICAgICAgICAgICAgICAgICAgYy5yZWYgPSBjcmVmO1xuICAgICAgICAgICAgICAgICAgICBjLnBhdGNoKHMpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChjKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSXRlbShzKSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoYyAhPT0gcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVwbGFjZSBwcmV2aW91cyBpdGVtO1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlkeCA9IHRoaXMuZ2V0SW5kZXgoYyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzLnJlZiA9IGNyZWY7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0KHMsIGlkeCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjLnBhdGNoKHMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9lcXVhbHNBcnJheShhcnJheSkge1xuICAgICAgICBsZXQgc2FtZSA9IHRydWU7XG4gICAgICAgIGlmIChhcnJheS5sZW5ndGggPT09IHRoaXMuX2l0ZW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9pdGVtcy5sZW5ndGg7IChpIDwgbikgJiYgc2FtZTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgc2FtZSA9IHNhbWUgJiYgKHRoaXMuX2l0ZW1zW2ldID09PSBhcnJheVtpXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzYW1lID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHNhbWU7XG4gICAgfVxuXG4gICAgX3NldEJ5QXJyYXkoYXJyYXkpIHtcbiAgICAgICAgLy8gRm9yIHBlcmZvcm1hbmNlIHJlYXNvbnMsIGZpcnN0IGNoZWNrIGlmIHRoZSBhcnJheXMgbWF0Y2ggZXhhY3RseSBhbmQgYmFpbCBvdXQgaWYgdGhleSBkby5cbiAgICAgICAgaWYgKHRoaXMuX2VxdWFsc0FycmF5KGFycmF5KSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9pdGVtcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIHRoaXMuX2l0ZW1zW2ldLm1hcmtlciA9IHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgcmVmcztcbiAgICAgICAgbGV0IG5ld0l0ZW1zID0gW107XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYXJyYXkubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgcyA9IGFycmF5W2ldO1xuICAgICAgICAgICAgaWYgKHRoaXMuaXNJdGVtKHMpKSB7XG4gICAgICAgICAgICAgICAgcy5tYXJrZXIgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBuZXdJdGVtcy5wdXNoKHMpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBsZXQgY3JlZiA9IHMucmVmO1xuICAgICAgICAgICAgICAgIGxldCBjO1xuICAgICAgICAgICAgICAgIGlmIChjcmVmKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcmVmcykgcmVmcyA9IHRoaXMuX2dldFJlZnMoKTtcbiAgICAgICAgICAgICAgICAgICAgYyA9IHJlZnNbY3JlZl07XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCFjKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIENyZWF0ZSBuZXcgaXRlbS5cbiAgICAgICAgICAgICAgICAgICAgYyA9IHRoaXMuY3JlYXRlSXRlbShzKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjLm1hcmtlciA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwocykpIHtcbiAgICAgICAgICAgICAgICAgICAgYy5wYXRjaChzKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBuZXdJdGVtcy5wdXNoKGMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fc2V0SXRlbXMobmV3SXRlbXMpO1xuICAgIH1cblxuICAgIF9zZXRJdGVtcyhuZXdJdGVtcykge1xuICAgICAgICBsZXQgcHJldkl0ZW1zID0gdGhpcy5faXRlbXM7XG4gICAgICAgIHRoaXMuX2l0ZW1zID0gbmV3SXRlbXM7XG5cbiAgICAgICAgLy8gUmVtb3ZlIHRoZSBpdGVtcy5cbiAgICAgICAgbGV0IHJlbW92ZWQgPSBwcmV2SXRlbXMuZmlsdGVyKGl0ZW0gPT4ge2xldCBtID0gaXRlbS5tYXJrZXI7IGRlbGV0ZSBpdGVtLm1hcmtlcjsgcmV0dXJuIG19KTtcbiAgICAgICAgbGV0IGFkZGVkID0gbmV3SXRlbXMuZmlsdGVyKGl0ZW0gPT4gKHByZXZJdGVtcy5pbmRleE9mKGl0ZW0pID09PSAtMSkpO1xuXG4gICAgICAgIGlmIChyZW1vdmVkLmxlbmd0aCB8fCBhZGRlZC5sZW5ndGgpIHtcbiAgICAgICAgICAgIC8vIFJlY2FsY3VsYXRlIHJlZnMuXG4gICAgICAgICAgICB0aGlzLl9yZWZzID0ge31cbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5faXRlbXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbGV0IHJlZiA9IHRoaXMuX2l0ZW1zW2ldLnJlZjtcbiAgICAgICAgICAgICAgICBpZiAocmVmKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlZnNbcmVmXSA9IHRoaXMuX2l0ZW1zW2ldO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMub25TeW5jKHJlbW92ZWQsIGFkZGVkLCBuZXdJdGVtcyk7XG4gICAgfVxuXG4gICAgc29ydChmKSB7XG4gICAgICAgIGNvbnN0IGl0ZW1zID0gdGhpcy5faXRlbXMuc2xpY2UoKTtcbiAgICAgICAgaXRlbXMuc29ydChmKTtcbiAgICAgICAgdGhpcy5fc2V0QnlBcnJheShpdGVtcyk7XG4gICAgfVxuXG4gICAgb25BZGQoaXRlbSwgaW5kZXgpIHtcbiAgICB9XG5cbiAgICBvblJlbW92ZShpdGVtLCBpbmRleCkge1xuICAgIH1cblxuICAgIG9uU3luYyhyZW1vdmVkLCBhZGRlZCwgb3JkZXIpIHtcbiAgICB9XG5cbiAgICBvblNldChpdGVtLCBpbmRleCwgcHJldkl0ZW0pIHtcbiAgICB9XG5cbiAgICBvbk1vdmUoaXRlbSwgZnJvbUluZGV4LCB0b0luZGV4KSB7XG4gICAgfVxuXG4gICAgY3JlYXRlSXRlbShvYmplY3QpIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiT2JqZWN0TGlzdC5jcmVhdGVJdGVtIG11c3QgY3JlYXRlIGFuZCByZXR1cm4gYSBuZXcgb2JqZWN0XCIpO1xuICAgIH1cblxuICAgIGlzSXRlbShvYmplY3QpIHtcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIGZvckVhY2goZikge1xuICAgICAgICB0aGlzLmdldCgpLmZvckVhY2goZik7XG4gICAgfVxuXG59XG5cbmltcG9ydCBVdGlscyBmcm9tIFwiLi9VdGlscy5tanN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IH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodi5pc1NoYWRlcikge1xuICAgICAgICAgICAgICAgIGlmICghc3RhZ2UucmVuZGVyZXIuaXNWYWxpZFNoYWRlclR5cGUodi5jb25zdHJ1Y3RvcikpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcIltMaWdodG5pbmddIEludmFsaWQgc2hhZGVyIHR5cGVcIik7XG4gICAgICAgICAgICAgICAgICAgIHYgPSBudWxsO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzaGFkZXIgPSB2O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiW0xpZ2h0bmluZ10gUGxlYXNlIHNwZWNpZnkgYSBzaGFkZXIgdHlwZS5cIik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHNoYWRlcjtcbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0V2ViR0woKSB7XG4gICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldEMyZCgpIHtcbiAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgICB9XG5cbiAgICBhZGRFbGVtZW50KGVsZW1lbnRDb3JlKSB7XG4gICAgICAgIHRoaXMuX2VsZW1lbnRzLmFkZChlbGVtZW50Q29yZSk7XG4gICAgfVxuXG4gICAgcmVtb3ZlRWxlbWVudChlbGVtZW50Q29yZSkge1xuICAgICAgICB0aGlzLl9lbGVtZW50cy5kZWxldGUoZWxlbWVudENvcmUpO1xuICAgICAgICBpZiAoIXRoaXMuX2VsZW1lbnRzKSB7XG4gICAgICAgICAgICB0aGlzLmNsZWFudXAoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJlZHJhdygpIHtcbiAgICAgICAgdGhpcy5fZWxlbWVudHMuZm9yRW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pbmRvdy5XZWJHTFJlbmRlcmluZ0NvbnRleHQ7XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFJldHVybnMgdGhlIHJlbmRlcmluZyBtb2RlLlxuICAgICAqIEByZXR1cm5zIHtudW1iZXJ9XG4gICAgICogIDA6IFdlYkdMXG4gICAgICogIDE6IENhbnZhczJkXG4gICAgICovXG4gICAgZ2V0IG1vZGUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9tb2RlO1xuICAgIH1cblxuICAgIGlzV2ViZ2woKSB7XG4gICAgICAgIHJldHVybiB0aGlzLm1vZGUgPT09IDA7XG4gICAgfVxuXG4gICAgaXNDMmQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLm1vZGUgPT09IDE7XG4gICAgfVxuXG4gICAgZ2V0T3B0aW9uKG5hbWUpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX29wdGlvbnNbbmFtZV07XG4gICAgfVxuXG4gICAgX3NldE9wdGlvbnMobykge1xuICAgICAgICB0aGlzLl9vcHRpb25zID0ge307XG5cbiAgICAgICAgbGV0IG9wdCA9IChuYW1lLCBkZWYpID0+IHtcbiAgICAgICAgICAgIGxldCB2YWx1ZSA9IG9bbmFtZV07XG5cbiAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3B0aW9uc1tuYW1lXSA9IGRlZjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3B0aW9uc1tuYW1lXSA9IHZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgb3B0KCdjYW52YXMnLCBudWxsKTtcbiAgICAgICAgb3B0KCdjb250ZXh0JywgbnVsbCk7XG4gICAgICAgIG9wdCgndycsIDE5MjApO1xuICA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ZChnKSAqIDI1NiArIE1hdGgucm91bmQoYik7XG4gICAgfTtcblxuICAgIHN0YXRpYyBtZXJnZU11bHRpQ29sb3JzKGMsIHApIHtcbiAgICAgICAgbGV0IHIgPSAwLCBnID0gMCwgYiA9IDAsIGEgPSAwLCB0ID0gMDtcbiAgICAgICAgbGV0IG4gPSBjLmxlbmd0aDtcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGxldCByMSA9ICgoY1tpXSAvIDY1NTM2KSB8IDApICUgMjU2O1xuICAgICAgICAgICAgbGV0IGcxID0gKChjW2ldIC8gMjU2KSB8IDApICUgMjU2O1xuICAgICAgICAgICAgbGV0IGIxID0gY1tpXSAlIDI1NjtcbiAgICAgICAgICAgIGxldCBhMSA9ICgoY1tpXSAvIDE2Nzc3MjE2KSB8IDApO1xuICAgICAgICAgICAgciArPSByMSAqIHBbaV07XG4gICAgICAgICAgICBnICs9IGcxICogcFtpXTtcbiAgICAgICAgICAgIGIgKz0gYjEgKiBwW2ldO1xuICAgICAgICAgICAgYSArPSBhMSAqIHBbaV07XG4gICAgICAgICAgICB0ICs9IHBbaV07XG4gICAgICAgIH1cblxuICAgICAgICB0ID0gMSAvIHQ7XG4gICAgICAgIHJldHVybiBNYXRoLnJvdW5kKGEgKiB0KSAqIDE2Nzc3MjE2ICsgTWF0aC5yb3VuZChyICogdCkgKiA2NTUzNiArIE1hdGgucm91bmQoZyAqIHQpICogMjU2ICsgTWF0aC5yb3VuZChiICogdCk7XG4gICAgfTtcblxuICAgIHN0YXRpYyBtZXJnZU11bHRpQ29sb3JzRXF1YWwoYykge1xuICAgICAgICBsZXQgciA9IDAsIGcgPSAwLCBiID0gMCwgYSA9IDAsIHQgPSAwO1xuICAgICAgICBsZXQgbiA9IGMubGVuZ3RoO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbGV0IHIxID0gKChjW2ldIC8gNjU1MzYpIHwgMCkgJSAyNTY7XG4gICAgICAgICAgICBsZXQgZzEgPSAoKGNbaV0gLyAyNTYpIHwgMCkgJSAyNTY7XG4gICAgICAgICAgICBsZXQgYjEgPSBjW2ldICUgMjU2O1xuICAgICAgICAgICAgbGV0IGExID0gKChjW2ldIC8gMTY3NzcyMTYpIHwgMCk7XG4gICAgICAgICAgICByICs9IHIxO1xuICAgICAgICAgICAgZyArPSBnMTtcbiAgICAgICAgICAgIGIgKz0gYjE7XG4gICAgICAgICAgICBhICs9IGExO1xuICAgICAgICAgICAgdCArPSAxLjA7XG4gICAgICAgIH1cblxuICAgICAgICB0ID0gMSAvIHQ7XG4gICAgICAgIHJldHVybiBNYXRoLnJvdW5kKGEgKiB0KSAqIDE2Nzc3MjE2ICsgTWF0aC5yb3VuZChyICogdCkgKiA2NTUzNiArIE1hdGgucm91bmQoZyAqIHQpICogMjU2ICsgTWF0aC5yb3VuZChiICogdCk7XG4gICAgfTtcblxuICAgIHN0YXRpYyBtZXJnZUNvbG9yQWxwaGEoYywgYWxwaGEpIHtcbiAgICAgICAgbGV0IGEgPSAoKGMgLyAxNjc3NzIxNiB8IDApICogYWxwaGEpIHwgMDtcbiAgICAgICAgcmV0dXJuICgoKCgoYyA+PiAxNikgJiAweGZmKSAqIGEpIC8gMjU1KSAmIDB4ZmYpICtcbiAgICAgICAgICAgICgoKChjICYgMHhmZjAwKSAqIGEpIC8gMjU1KSAmIDB4ZmYwMCkgK1xuICAgICAgICAgICAgKCgoKChjICYgMHhmZikgPDwgMTYpICogYSkgLyAyNTUpICYgMHhmZjAwMDApICtcbiAgICAgICAgICAgIChhIDw8IDI0KTtcbiAgICB9O1xuXG4gICAgc3RhdGljIHJhZChkZWcpIHtcbiAgICAgICAgcmV0dXJuIGRlZyAqIChNYXRoLlBJIC8gMTgwKTtcbiAgICB9O1xuXG4gICAgc3RhdGljIGdldFRpbWluZ0JlemllcihhLCBiLCBjLCBkKSB7XG4gICAgICAgIGxldCB4YyA9IDMuMCAqIGE7XG4gICAgICAgIGxldCB4YiA9IDMuMCAqIChjIC0gYSkgLSB4YztcbiAgICAgICAgbGV0IHhhID0gMS4wIC0geGMgLSB4YjtcbiAgICAgICAgbGV0IHljID0gMy4wICogYjtcbiAgICAgICAgbGV0IHliID0gMy4wICogKGQgLSBiKSAtIHljO1xuICAgICAgICBsZXQgeWEgPSAxLjAgLSB5YyAtIHliO1xuXG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAodGltZSkge1xuICAgICAgICAgICAgaWYgKHRpbWUgPj0gMS4wKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGltZSA8PSAwKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCB0ID0gMC41LCBjYngsIGNieGQsIGR4O1xuXG4gICAgICAgICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuICAgICAgICAgICAgICAgIGR4ID0gdGltZSAtIGNieDtcbiAgICAgICAgICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5Yyk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gQ3ViaWMgYmV6aWVyIGRlcml2YXRpdmUuXG4gICAgICAgICAgICAgICAgY2J4ZCA9IHQgKiAodCAqICgzICogeGEpICsgMiAqIHhiKSArIHhjO1xuXG4gICAgICAgICAgICAgICAgaWYgKGNieGQgPiAxZS0xMCAmJiBjYnhkIDwgMWUtMTApIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gUHJvYmxlbWF0aWMuIEZhbGwgYmFjayB0byBiaW5hcnkgc2VhcmNoIG1ldGhvZC5cbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdCArPSBkeCAvIGNieGQ7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEZhbGxiYWNrOiBiaW5hcnkgc2VhcmNoIG1ldGhvZC4gVGhpcyBpcyBtb3JlIHJlbGlhYmxlIHdoZW4gdGhlcmUgYXJlIG5lYXItMCBzbG9wZXMuXG4gICAgICAgICAgICBsZXQgbWluVCA9IDA7XG4gICAgICAgICAgICBsZXQgbWF4VCA9IDE7XG4gICAgICAgICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgICAgICAgICB0ID0gMC41ICogKG1pblQgKyBtYXhUKTtcblxuICAgICAgICAgICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG5cbiAgICAgICAgICAgICAgICBkeCA9IHRpbWUgLSBjYng7XG4gICAgICAgICAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFNvbHV0aW9uIGZvdW5kIVxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoZHggPCAwKSB7XG4gICAgICAgICAgICAgICAgICAgIG1heFQgPSB0O1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG1pblQgPSB0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICB9O1xuICAgIH07XG5cbiAgICBzdGF0aWMgZ2V0VGltaW5nRnVuY3Rpb24oc3RyKSB7XG4gICAgICAgIHN3aXRjaCAoc3RyKSB7XG4gICAgICAgICAgICBjYXNlIFwibGluZWFyXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICh0aW1lKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aW1lXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGNhc2UgXCJlYXNlXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAuMjUsIDAuMSwgMC4yNSwgMS4wKTtcbiAgICAgICAgICAgIGNhc2UgXCJlYXNlLWluXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAuNDIsIDAsIDEuMCwgMS4wKTtcbiAgICAgICAgICAgIGNhc2UgXCJlYXNlLW91dFwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLCAwLCAwLjU4LCAxLjApO1xuICAgICAgICAgICAgY2FzZSBcImVhc2UtaW4tb3V0XCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAuNDIsIDAsIDAuNTgsIDEuMCk7XG4gICAgICAgICAgICBjYXNlIFwic3RlcC1zdGFydFwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAxXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGNhc2UgXCJzdGVwLWVuZFwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAodGltZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGltZSA9PT0gMSA/IDEgOiAwO1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIGxldCBzID0gXCJjdWJpYy1iZXppZXIoXCI7XG4gICAgICAgICAgICAgICAgaWYgKHN0ciAmJiBzdHIuaW5kZXhPZihzKSA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICBsZXQgcGFydHMgPSBzdHIuc3Vic3RyKHMubGVuZ3RoLCBzdHIubGVuZ3RoIC0gcy5sZW5ndGggLSAxKS5zcGxpdChcIixcIik7XG4gICAgICAgICAgICAgICAgICAgIGlmIChwYXJ0cy5sZW5ndGggIT09IDQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEZhbGxiYWNrOiB1c2UgbGluZWFyLlxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICh0aW1lKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRpbWVcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgbGV0IGEgPSBwYXJzZUZsb2F0KHBhcnRzWzBdKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGIgPSBwYXJzZUZsb2F0KHBhcnRzWzFdKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGMgPSBwYXJzZUZsb2F0KHBhcnRzWzJdKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBwYXJzZUZsb2F0KHBhcnRzWzNdKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzTmFOKGEpIHx8IGlzTmFOKGIpIHx8IGlzTmFOKGMpIHx8IGlzTmFOKGQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBVbmtub3duIHRpbWluZyBmdW5jdGlvbjogXCIgKyBzdHIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gRmFsbGJhY2s6IHVzZSBsaW5lYXIuXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHRpbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGltZVxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcihhLCBiLCBjLCBkKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBVbmtub3duIHRpbWluZyBmdW5jdGlvbjogXCIgKyBzdHIpO1xuICAgICAgICAgICAgICAgICAgICAvLyBGYWxsYmFjazogdXNlIGxpbmVhci5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICh0aW1lKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGltZVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbn1cbiIsIi8qXG4gKiBJZiBub3Qgc3RhdGVkIG90aGVyd2lzZSBpbiB0aGlzIGZpbGUgb3IgdGhpcyBjb21wb25lbnQncyBMSUNFTlNFIGZpbGUgdGhlXG4gKiBmb2xsb3dpbmcgY29weXJpZ2h0IGFuZCBsaWNlbnNlcyBhcHBseTpcbiAqXG4gKiBDb3B5cmlnaHQgMjAyMCBNZXRyb2xvZ2ljYWxcbiAqXG4gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgTGljZW5zZSk7XG4gKiB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuXG4gKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb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xlbWVudHMgPSBuZXcgU2V0KCk7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSBudW1iZXIgb2YgZW5hYmxlZCBlbGVtZW50cyB0aGF0IGFyZSBhY3RpdmUuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9hY3RpdmVDb3VudCA9IDA7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSBhc3NvY2lhdGVkIHRleHR1cmUgc291cmNlLlxuICAgICAgICAgKiBTaG91bGQgbm90IGJlIGNoYW5nZWQuXG4gICAgICAgICAqIEB0eXBlIHtUZXh0dXJlU291cmNlfVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fc291cmNlID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogQSByZXNpemUgbW9kZSBjYW4gYmUgc2V0IHRvIGNvdmVyIG9yIGNvbnRhaW4gYSBjZXJ0YWluIGFyZWEuXG4gICAgICAgICAqIEl0IHdpbGwgcmVzZXQgdGhlIHRleHR1cmUgY2xpcHBpbmcgc2V0dGluZ3MuXG4gICAgICAgICAqIFdoZW4gbWFudWFsIHRleHR1cmUgY2xpcHBpbmcgaXMgcGVyZm9ybWVkLCB0aGUgcmVzaXplTW9kZSBpcyByZXNldC5cbiAgICAgICAgICogQHR5cGUge3t0eXBlOiBzdHJpbmcsIHdpZHRoOiBudW1iZXIsIGhlaWdodDogbnVtYmVyfX1cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX3Jlc2l6ZU1vZGUgPSBudWxsO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUaGUgdGV4dHVyZSBjbGlwcGluZyB4LW9mZnNldC5cbiAgICAgICAgICogQHR5cGUge251bWJlcn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX3ggPSAwO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUaGUgdGV4dHVyZSBjbGlwcGluZyB5LW9mZnNldC5cbiAgICAgICAgICogQHR5cGUge251bWJlcn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX3kgPSAwO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUaGUgdGV4dHVyZSBjbGlwcGluZyB3aWR0aC4gSWYgMCB0aGVuIGZ1bGwgd2lkdGguXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl93ID0gMDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIHRleHR1cmUgY2xpcHBpbmcgaGVpZ2h0LiBJZiAwIHRoZW4gZnVsbCBoZWlnaHQuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9oID0gMDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogUmVuZGVyIHByZWNpc2lvbiAoMC41ID0gZnV6enksIDEgPSBub3JtYWwsIDIgPSBzaGFycCBldmVuIHdoZW4gc2NhbGVkIHR3aWNlLCBldGMuKS5cbiAgICAgICAgICogQHR5cGUge251bWJlcn1cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX3ByZWNpc2lvbiA9IDE7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSAobWF4aW11bSkgZXhwZWN0ZWQgdGV4dHVyZSBzb3VyY2Ugd2lkdGguIFVzZWQgZm9yIHdpdGhpbiBib3VuZHMgZGV0ZXJtaW5hdGlvbiB3aGlsZSB0ZXh0dXJlIGlzIG5vdCB5ZXQgbG9hZGVkLlxuICAgICAgICAgKiBJZiBub3Qgc2V0LCAyMDQ4IGlzIHVzZWQgYnkgRWxlbWVudENvcmUudXBkYXRlLlxuICAgICAgICAgKiBAdHlwZSB7bnVtYmVyfVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5tdyA9IDA7XG5cbiAgICAgICAgLyoq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dXJuIHRoaXMuX3NvdXJjZTtcbiAgICB9XG5cbiAgICBhZGRFbGVtZW50KHYpIHtcbiAgICAgICAgaWYgKCF0aGlzLmVsZW1lbnRzLmhhcyh2KSkge1xuICAgICAgICAgICAgdGhpcy5lbGVtZW50cy5hZGQodik7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLmVsZW1lbnRzLnNpemUgPT09IDEpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fc291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3NvdXJjZS5hZGRUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHYuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5pbmNBY3RpdmVDb3VudCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmVtb3ZlRWxlbWVudCh2KSB7XG4gICAgICAgIGlmICh0aGlzLmVsZW1lbnRzLmRlbGV0ZSh2KSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuZWxlbWVudHMuc2l6ZSA9PT0gMCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc291cmNlLnJlbW92ZVRleHR1cmUodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodi5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmRlY0FjdGl2ZUNvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBpbmNBY3RpdmVDb3VudCgpIHtcbiAgICAgICAgLy8gRW5zdXJlIHRoYXQgdGV4dHVyZSBzb3VyY2UncyBhY3RpdmVDb3VudCBoYXMgdHJhbnNmZXJyZWQgb3duZXJzaGlwLlxuICAgICAgICBjb25zdCBzb3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VcGRhdGUgPSBmYWxzZTtcbiAgICAgICAgICAgIGxldCBzb3VyY2UgPSB0aGlzLl9nZXRUZXh0dXJlU291cmNlKCk7XG4gICAgICAgICAgICB0aGlzLl9yZXBsYWNlVGV4dHVyZVNvdXJjZShzb3VyY2UpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldFRleHR1cmVTb3VyY2UoKSB7XG4gICAgICAgIGxldCBzb3VyY2UgPSBudWxsO1xuICAgICAgICBpZiAodGhpcy5fZ2V0SXNWYWxpZCgpKSB7XG4gICAgICAgICAgICBjb25zdCBsb29rdXBJZCA9IHRoaXMuX2dldExvb2t1cElkKCk7XG4gICAgICAgICAgICBzb3VyY2UgPSB0aGlzLl9nZXRSZXVzYWJsZVRleHR1cmVTb3VyY2UobG9va3VwSWQpO1xuICAgICAgICAgICAgaWYgKCFzb3VyY2UpIHtcbiAgICAgICAgICAgICAgICBzb3VyY2UgPSB0aGlzLm1hbmFnZXIuZ2V0VGV4dHVyZVNvdXJjZSh0aGlzLl9nZXRTb3VyY2VMb2FkZXIoKSwgbG9va3VwSWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzb3VyY2U7XG4gICAgfVxuXG4gICAgX2dldFJldXNhYmxlVGV4dHVyZVNvdXJjZShsb29rdXBJZCA9IHRoaXMuX2dldExvb2t1cElkKCkpIHtcbiAgICAgICAgaWYgKHRoaXMuX2dldElzVmFsaWQoKSkge1xuICAgICAgICAgICAgaWYgKGxvb2t1cElkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWFuYWdlci5nZXRSZXVzYWJsZVRleHR1cmVTb3VyY2UobG9va3VwSWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cblxuICAgIF9yZXBsYWNlVGV4dHVyZVNvdXJjZShuZXdTb3VyY2UgPSBudWxsKSB7XG4gICAgICAgIGxldCBvbGRTb3VyY2UgPSB0aGlzLl9zb3VyY2U7XG5cbiAgICAgICAgdGhpcy5fc291cmNlID0gbmV3U291cmNlO1xuXG4gICAgICAgIGlmICh0aGlzLmVsZW1lbnRzLnNpemUpIHtcbiAgICAgICAgICAgIGlmIChvbGRTb3VyY2UpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fYWN0aXZlQ291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgb2xkU291cmNlLmRlY0FjdGl2ZVRleHR1cmVDb3VudCgpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIG9sZFNvdXJjZS5yZW1vdmVUZXh0dXJlKHRoaXMpO1xuXG4gICAgICAgICAgICAgICAgLy8gZnJlZSB1cCB1bnVzZWQgVGV4dFRleHR1cmVzIGltbWVkaWF0ZWx5IGFzIHRoZXkgYXJlIG5vdCByZXVzZWQgYW55d2F5XG4gICAgICAgICAgICAgICAgaWYodGhpc1sndGV4dCddICYmICFvbGRTb3VyY2UuaXNVc2VkKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5tYW5hZ2VyLmZyZWVUZXh0dXJlU291cmNlKG9sZFNvdXJjZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAobmV3U291cmNlKSB7XG4gICAgICAgICAgICAgICAgLy8gTXVzdCBoYXBwZW4gYmVmb3JlIHNldERpc3BsYXllZFRleHR1cmUgdG8gZW5zdXJlIHNwcml0ZSBtYXAgdGV4Y29vcmRzIGFyZSB1c2VkLlxuICAgICAgICAgICAgICAgIG5ld1NvdXJjZS5hZGRUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9hY3RpdmVDb3VudCkge1xuICAgICAgICAgICAgICAgICAgICBuZXdTb3VyY2UuaW5jQWN0aXZlVGV4dHVyZUNvdW50KCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuaXNVc2VkKCkpIHtcbiAgICAgICAgICAgIGlmIChuZXdTb3VyY2UpIHtcbiAgICAgICAgICAgICAgICBpZiAobmV3U291cmNlLmlzTG9hZGVkKCkpIHtcblxuICAgICAgICAgICAgICAgICAgICAvLyBBcHBseSByZXNpemVNb2RlXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXNpemVNb2RlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hcHBseVJlc2l6ZU1vZGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaChlbGVtZW50ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuX3NldERpc3BsYXllZFRleHR1cmUodGhpcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvYWRFcnJvciA9IG5ld1NvdXJjZS5sb2FkRXJyb3I7XG4gICAgICAgICAgICAgICAgICAgIGlmIChsb2FkRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaChlbGVtZW50ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5vblRleHR1cmVTb3VyY2VMb2FkRXJyb3IobG9hZEVycm9yKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKGVsZW1lbnQgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuX3NldERpc3BsYXllZFRleHR1cmUobnVsbCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGxvYWQoKSB7XG4gICAgICAgIC8vIE1ha2Ugc3VyZSB0aGF0IHNvdXJjZSBpcyB1cCB0byBkYXRlLlxuICAgICAgICBpZiAodGhpcy5zb3VyY2UpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5pc0xvYWRlZCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zb3VyY2UubG9hZCh0cnVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGlzTG9hZGVkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc291cmNlICYmIHRoaXMuX3NvdXJjZS5pc0xvYWRlZCgpO1xuICAgIH1cblxuICAgIGdldCBsb2FkRXJyb3IoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zb3VyY2UgJiYgdGhpcy5fc291cmNlLmxvYWRFcnJvcjtcbiAgICB9XG5cbiAgICBmcmVlKCkge1xuICAgICAgICBpZiAodGhpcy5fc291cmNlKSB7XG4gICAgICAgICAgICB0aGlzLl9zb3VyY2UuZnJlZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0IHJlc2l6ZU1vZGUoe3R5cGUgPSBcImNvdmVyXCIsIHcgPSAwLCBoID0gMCwgY2xpcFggPSAwLjUsIGNsaXBZID0gMC41fSkge1xuICAgICAgICB0aGlzLl9yZXNpemVNb2RlID0ge3R5cGUsIHcsIGgsIGNsaXBY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xlKSB7XG4gICAgICAgICAgICBzY2FsZSA9IHNjYWxlWTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXNjYWxlKSByZXR1cm47XG4gICAgICAgIHRoaXMuX3ByZWNpc2lvbiA9IDEvc2NhbGU7XG4gICAgfVxuXG4gICAgZW5hYmxlQ2xpcHBpbmcoeCwgeSwgdywgaCkge1xuICAgICAgICB0aGlzLl9jbGVhclJlc2l6ZU1vZGUoKTtcblxuICAgICAgICB4ICo9IHRoaXMuX3ByZWNpc2lvbjtcbiAgICAgICAgeSAqPSB0aGlzLl9wcmVjaXNpb247XG4gICAgICAgIHcgKj0gdGhpcy5fcHJlY2lzaW9uO1xuICAgICAgICBoICo9IHRoaXMuX3ByZWNpc2lvbjtcbiAgICAgICAgaWYgKHRoaXMuX3ggIT09IHggfHwgdGhpcy5feSAhPT0geSB8fCB0aGlzLl93ICE9PSB3IHx8IHRoaXMuX2ggIT09IGgpIHtcbiAgICAgICAgICAgIHRoaXMuX3ggPSB4O1xuICAgICAgICAgICAgdGhpcy5feSA9IHk7XG4gICAgICAgICAgICB0aGlzLl93ID0gdztcbiAgICAgICAgICAgIHRoaXMuX2ggPSBoO1xuXG4gICAgICAgICAgICB0aGlzLl91cGRhdGVDbGlwcGluZyh0cnVlKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGRpc2FibGVDbGlwcGluZygpIHtcbiAgICAgICAgdGhpcy5fY2xlYXJSZXNpemVNb2RlKCk7XG5cbiAgICAgICAgaWYgKHRoaXMuX3ggfHwgdGhpcy5feSB8fCB0aGlzLl93IHx8IHRoaXMuX2gpIHtcbiAgICAgICAgICAgIHRoaXMuX3ggPSAwO1xuICAgICAgICAgICAgdGhpcy5feSA9IDA7XG4gICAgICAgICAgICB0aGlzLl93ID0gMDtcbiAgICAgICAgICAgIHRoaXMuX2ggPSAwO1xuXG4gICAgICAgICAgICB0aGlzLl91cGRhdGVDbGlwcGluZygpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX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10gPSB0aGlzLng7XG4gICAgICAgIGlmICh0aGlzLnkgIT09IDApIG5vbkRlZmF1bHRzWyd5J10gPSB0aGlzLnk7XG4gICAgICAgIGlmICh0aGlzLncgIT09IDApIG5vbkRlZmF1bHRzWyd3J10gPSB0aGlzLnc7XG4gICAgICAgIGlmICh0aGlzLmggIT09IDApIG5vbkRlZmF1bHRzWydoJ10gPSB0aGlzLmg7XG4gICAgICAgIGlmICh0aGlzLnByZWNpc2lvbiAhPT0gMSkgbm9uRGVmYXVsdHNbJ3ByZWNpc2lvbiddID0gdGhpcy5wcmVjaXNpb247XG4gICAgICAgIHJldHVybiBub25EZWZhdWx0cztcbiAgICB9XG5cbiAgICBnZXQgcHgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl94O1xuICAgIH1cblxuICAgIGdldCBweSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3k7XG4gICAgfVxuXG4gICAgZ2V0IHB3KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdztcbiAgICB9XG5cbiAgICBnZXQgcGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oO1xuICAgIH1cblxuICAgIGdldCB4KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5feCAvIHRoaXMuX3ByZWNpc2lvbjtcbiAgICB9XG4gICAgc2V0IHgodikge1xuICAgICAgICB0aGlzLl9jbGVhclJlc2l6ZU1vZGUoKTtcbiAgICAgICAgdiA9IHYgKiB0aGlzLl9wcmVjaXNpb247XG4gICAgICAgIGlmICh0aGlzLl94ICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl94ID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUNsaXBwaW5nKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgeSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3kgLyB0aGlzLl9wcmVjaXNpb247XG4gICAgfVxuICAgIHNldCB5KHYpIHtcbiAgICAgICAgdGhpcy5fY2xlYXJSZXNpemVNb2RlKCk7XG4gICAgICAgIHYgPSB2ICogdGhpcy5fcHJlY2lzaW9uO1xuICAgICAgICBpZiAodGhpcy5feSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5feSA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVDbGlwcGluZygpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93IC8gdGhpcy5fcHJlY2lzaW9uO1xuICAgIH1cblxuICAgIHNldCB3KHYpIHtcbiAgICAgICAgdGhpcy5fY2xlYXJSZXNpemVNb2RlKCk7XG4gICAgICAgIHYgPSB2ICogdGhpcy5fcHJlY2lzaW9uO1xuICAgICAgICBpZiAodGhpcy5fdyAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fdyA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVDbGlwcGluZygpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oIC8gdGhpcy5fcHJlY2lzaW9uO1xuICAgIH1cblxuICAgIHNldCBoKHYpIHtcbiAgICAgICAgdGhpcy5fY2xlYXJSZXNpemVNb2RlKCk7XG4gICAgICAgIHYgPSB2ICogdGhpcy5fcHJlY2lzaW9uO1xuICAgICAgICBpZiAodGhpcy5faCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5faCA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVDbGlwcGluZygpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHByZWNpc2lvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3ByZWNpc2lvbjtcbiAgICB9XG5cbiAgICBzZXQgcHJlY2lzaW9uKHYpIHtcbiAgICAgICAgdGhpcy5fY2xlYXJSZXNpemVNb2RlKCk7XG4gICAgICAgIGlmICh0aGlzLl9wcmVjaXNpb24gIT09IHYpIHtc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b25lIGFjdGl2ZSBlbGVtZW50KS5cbiAgICAgICAgICogQHR5cGUge251bWJlcn1cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX2FjdGl2ZVRleHR1cmVDb3VudCA9IDA7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSBmYWN0b3J5IGZvciB0aGUgc291cmNlIG9mIHRoaXMgdGV4dHVyZS5cbiAgICAgICAgICogQHR5cGUge0Z1bmN0aW9ufVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5sb2FkZXIgPSBsb2FkZXI7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIElkZW50aWZpZXIgZm9yIHJldXNlLlxuICAgICAgICAgKiBAdHlwZSB7U3RyaW5nfVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5sb29rdXBJZCA9IG51bGw7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIElmIHNldCwgdGhpcy5pcyBjYWxsZWQgd2hlbiB0aGUgdGV4dHVyZSBzb3VyY2UgaXMgbm8gbG9uZ2VyIGRpc3BsYXllZCAodGhpcy5jb21wb25lbnRzLnNpemUgYmVjb21lcyAwKS5cbiAgICAgICAgICogQHR5cGUge0Z1bmN0aW9ufVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fY2FuY2VsQ2IgPSBudWxsO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBMb2FkaW5nIHNpbmNlIHRpbWVzdGFtcCBpbiBtaWxsaXMuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLmxvYWRpbmdTaW5jZSA9IDA7XG5cbiAgICAgICAgdGhpcy53ID0gMDtcbiAgICAgICAgdGhpcy5oID0gMDtcblxuICAgICAgICB0aGlzLl9uYXRpdmVUZXh0dXJlID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogSWYgdHJ1ZSwgdGhlbiB0aGlzLnRleHR1cmUgc291cmNlIGlzIG5ldmVyIGZyZWVkIGZyb20gbWVtb3J5IGR1cmluZyBnYXJiYWdlIGNvbGxlY3Rpb24uXG4gICAgICAgICAqIEB0eXBlIHtib29sZWFufVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5wZXJtYW5lbnQgPSBmYWxzZTtcblxuICAgICAgICAvKipcbiAgICAgICAgICogU3ViLW9iamVjdCB3aXRoIHRleHR1cmUtc3BlY2lmaWMgcmVuZGVyaW5nIGluZm9ybWF0aW9uLlxuICAgICAgICAgKiBGb3IgaW1hZ2VzLCBjb250YWlucyB0aGUgc3JjIHByb3BlcnR5LCBmb3IgdGV4dHMsIGNvbnRhaW5zIGhhbmR5IHJlbmRlcmluZyBpbmZvcm1hdGlvbi5cbiAgICAgICAgICogQHR5cGUge09iamVjdH1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMucmVuZGVySW5mbyA9IG51bGw7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEdlbmVyYXRlZCBmb3IgJ3JlbmRlclRvVGV4dHVyZScuXG4gICAgICAgICAqIEB0eXBlIHtib29sZWFufVxuICAgICAgICAgKiBAcHJpdmF0ZVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5faXNSZXN1bHRUZXh0dXJlID0gIXRoaXMubG9hZGVyO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBDb250YWlucyB0aGUgbG9hZCBlcnJvciwgaWYgdGhlIHRleHR1cmUgc291cmNlIGNvdWxkIHByZXZpb3VzbHkgbm90IGJlIGxvYWRlZC5cbiAgICAgICAgICogQHR5cGUge29iamVjdH1cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX2xvYWRFcnJvciA9IG51bGw7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqICBIb2xkIGEgcmVmZXJlbmNlIHRvIHRoZSBqYXZhc2NyaXB0IHZhcmlhYmxlIHdoaWNoIGNvb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0gbnVsbDtcblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tYW5hZ2VyLnN0YWdlLmRlc3Ryb3llZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gSWdub3JlIGFzeW5jIGxvYWQgd2hlbiBzdGFnZSBpcyBkZXN0cm95ZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gRW1pdCB0eEVycm9yLlxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAob3B0aW9ucyAmJiBvcHRpb25zLnNvdXJjZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLnN0YWdlLmlzVXBkYXRpbmdGcmFtZSgpICYmICFmb3JjZVN5bmMgJiYgKG9wdGlvbnMudGhyb3R0bGUgIT09IGZhbHNlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHR1cmVUaHJvdHRsZXIgPSB0aGlzLnN0YWdlLnRleHR1cmVUaHJvdHRsZXI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FuY2VsQ2IgPSB0ZXh0dXJlVGhyb3R0bGVyLmdlbmVyaWNDYW5jZWxDYjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0dXJlVGhyb3R0bGVyLmFkZCh0aGlzLCBvcHRpb25zKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzTG9hZGVkU291cmNlKG9wdGlvbnMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgIC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mVZO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZmxpcFRleHR1cmVZID0gZmFsc2U7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5faXNOYXRpdmVUZXh0dXJlKHNvdXJjZSkpIHtcbiAgICAgICAgICAgIC8vIFRleHR1cmUgbWFuYWdlZCBieSBjYWxsZXIuXG4gICAgICAgICAgICB0aGlzLl9uYXRpdmVUZXh0dXJlID0gc291cmNlO1xuXG4gICAgICAgICAgICB0aGlzLncgPSB0aGlzLncgfHwgc291cmNlLnc7XG4gICAgICAgICAgICB0aGlzLmggPSB0aGlzLmggfHwgc291cmNlLmg7XG5cbiAgICAgICAgICAgIC8vIFdlYkdMVGV4dHVyZSBvYmplY3RzIGFyZSBieSBkZWZhdWx0O1xuICAgICAgICAgICAgdGhpcy5wZXJtYW5lbnQgPSBvcHRpb25zLmhhc093blByb3BlcnR5KCdwZXJtYW5lbnQnKSA/IG9wdGlvbnMucGVybWFuZW50IDogdHJ1ZTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMubWFuYWdlci51cGxvYWRUZXh0dXJlU291cmNlKHRoaXMsIG9wdGlvbnMpO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gTXVzdCBiZSBjbGVhcmVkIHdoZW4gcmVsb2FkIGlzIHN1Y2Nlc2Z1bC5cbiAgICAgICAgdGhpcy5fbG9hZEVycm9yID0gbnVsbDtcblxuICAgICAgICB0aGlzLm9uTG9hZCgpO1xuICAgIH1cblxuICAgIGlzVXNlZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2FjdGl2ZVRleHR1cmVDb3VudCA+IDA7XG4gICAgfVxuXG4gICAgb25Mb2FkKCkge1xuICAgICAgICBpZiAodGhpcy5pc1VzZWQoKSkge1xuICAgICAgICAgICAgdGhpcy50ZXh0dXJlcy5mb3JFYWNoKHRleHR1cmUgPT4ge1xuICAgICAgICAgICAgICAgIHRleHR1cmU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1ZSkge1xuICAgICAgICByZXR1cm4gKHR5cGVvZiB2YWx1ZSA9PT0gJ251bWJlcicgJiYgKHZhbHVlICUgMSkgPT09IDApO1xuICAgIH1cblxuICAgIHN0YXRpYyBpc0Jvb2xlYW4odmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIHZhbHVlID09PSB0cnVlIHx8IHZhbHVlID09PSBmYWxzZTtcbiAgICB9XG5cbiAgICBzdGF0aWMgaXNTdHJpbmcodmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIHR5cGVvZiB2YWx1ZSA9PT0gJ3N0cmluZyc7XG4gICAgfVxuXG4gICAgc3RhdGljIGNsb25lKHYpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2KSB8fCBBcnJheS5pc0FycmF5KHYpKSB7XG4gICAgICAgICAgICByZXR1cm4gVXRpbHMuZ2V0RGVlcENsb25lKHYpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gQ29weSBieSB2YWx1ZS5cbiAgICAgICAgICAgIHJldHVybiB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGNsb25lT2JqU2hhbGxvdyhvYmopIHtcbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICBsZXQgY2xvbmUgPSB7fVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGNsb25lW2tleXNbaV1dID0gb2JqW2tleXNbaV1dO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjbG9uZTtcbiAgICB9XG5cbiAgICBzdGF0aWMgbWVyZ2Uob2JqMSwgb2JqMikge1xuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iajIpO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIG9iajFba2V5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BsZXQgaSwgYztcbiAgICAgICAgaWYgKFV0aWxzLmlzRnVuY3Rpb24ob2JqKSkge1xuICAgICAgICAgICAgLy8gQ29weSBmdW5jdGlvbnMgYnkgcmVmZXJlbmNlLlxuICAgICAgICAgICAgcmV0dXJuIG9iajtcbiAgICAgICAgfVxuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvYmopKSB7XG4gICAgICAgICAgICBjID0gW107XG4gICAgICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGNba2V5c1tpXV0gPSBVdGlscy5nZXREZWVwQ2xvbmUob2JqW2tleXNbaV1dKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBjO1xuICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0KG9iaikpIHtcbiAgICAgICAgICAgIGMgPSB7fVxuICAgICAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjW2tleXNbaV1dID0gVXRpbHMuZ2V0RGVlcENsb25lKG9ialtrZXlzW2ldXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gYztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBvYmo7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZXF1YWxWYWx1ZXModjEsIHYyKSB7XG4gICAgICAgIGlmICgodHlwZW9mIHYxKSAhPT0gKHR5cGVvZiB2MikpIHJldHVybiBmYWxzZTtcbiAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2MSkpIHtcbiAgICAgICAgICAgIHJldHVybiBVdGlscy5pc09iamVjdExpdGVyYWwodjIpICYmIFV0aWxzLmVxdWFsT2JqZWN0TGl0ZXJhbHModjEsIHYyKTtcbiAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KHYxKSkge1xuICAgICAgICAgICAgcmV0dXJuIEFycmF5LmlzQXJyYXkodjIpICYmIFV0aWxzLmVxdWFsQXJyYXlzKHYxLCB2Mik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdjEgPT09IHYyO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGVxdWFsT2JqZWN0TGl0ZXJhbHMob2JqMSwgb2JqMikge1xuICAgICAgICBsZXQga2V5czEgPSBPYmplY3Qua2V5cyhvYmoxKTtcbiAgICAgICAgbGV0IGtleXMyID0gT2JqZWN0LmtleXMob2JqMik7XG4gICAgICAgIGlmIChrZXlzMS5sZW5ndGggIT09IGtleXMyLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBrZXlzMS5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGsxID0ga2V5czFbaV07XG4gICAgICAgICAgICBjb25zdCBrMiA9IGtleXMyW2ldO1xuICAgICAgICAgICAgaWYgKGsxICE9PSBrMikge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29uc3QgdjEgPSBvYmoxW2sxXTtcbiAgICAgICAgICAgIGNvbnN0IHYyID0gb2JqMltrMl07XG5cbiAgICAgICAgICAgIGlmICghVXRpbHMuZXF1YWxWYWx1ZXModjEsIHYyKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cblxuICAgIHN0YXRpYyBlcXVhbEFycmF5cyh2MSwgdjIpIHtcbiAgICAgICAgaWYgKHYxLmxlbmd0aCAhPT0gdjIubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB2MS5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5lcXVhbFZhbHVlcyh2MVtpXSwgdjJbaV0pKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgc3RhdGljIHNldFRvQXJyYXkocykge1xuICAgICAgICBsZXQgcmVzdWx0ID0gW107XG4gICAgICAgIHMuZm9yRWFjaChmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHJlc3VsdC5wdXNoKHZhbHVlKTtcbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgc3RhdGljIGl0ZXJhdG9yVG9BcnJheShpdGVyYXRvcikge1xuICAgICAgICBsZXQgcmVzdWx0ID0gW107XG4gICAgICAgIGxldCBpdGVyYXRvclJlc3VsdCA9IGl0ZXJhdG9yLm5leHQoKTtcbiAgICAgICAgd2hpbGUgKCFpdGVyYXRvclJlc3VsdC5kb25lKSB7XG4gICAgICAgICAgICByZXN1bHQucHVzaChpdGVyYXRvclJlc3VsdC52YWx1ZSk7XG4gICAgICAgICAgICBpdGVyYXRvclJlc3VsdCA9IGl0ZXJhdG9yLm5leHQoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIHN0YXRpYyBpc1VjQ2hhcihjaGFyY29kZSkge1xuICAgICAgICByZXR1cm4gY2hhcmNvZGUgPj0gNjUgJiYgY2hhcmNvZGUgPD0gOTA7XG4gICAgfVxuXG59XG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IHRoaXMucXVhZHMucXVhZFRleHR1cmVzLmxlbmd0aDtcbiAgICB9XG5cbiAgICBzZXRTaGFkZXIoc2hhZGVyLCBvd25lcikge1xuICAgICAgICBpZiAodGhpcy5fc2hhZGVyT3duZXIgIT09IG93bmVyIHx8IHRoaXMuX3JlYWxTaGFkZXIgIT09IHNoYWRlcikge1xuICAgICAgICAgICAgLy8gU2FtZSBzaGFkZXIgb3duZXI6IGFjdGl2ZSBzaGFkZXIgaXMgYWxzbyB0aGUgc2FtZS5cbiAgICAgICAgICAgIC8vIFByZXZlbnQgYW55IHNoYWRlciB1c2FnZSB0byBzYXZlIHBlcmZvcm1hbmNlLlxuXG4gICAgICAgICAgICB0aGlzLl9yZWFsU2hhZGVyID0gc2hhZGVyO1xuXG4gICAgICAgICAgICBpZiAoc2hhZGVyLnVzZURlZmF1bHQoKSkge1xuICAgICAgICAgICAgICAgIC8vIFVzZSB0aGUgZGVmYXVsdCBzaGFkZXIgd2hlbiBwb3NzaWJsZSB0byBwcmV2ZW50IHVubmVjZXNzYXJ5IHByb2dyYW0gY2hhbmdlcy5cbiAgICAgICAgICAgICAgICBzaGFkZXIgPSB0aGlzLmRlZmF1bHRTaGFkZXI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fc2hhZGVyICE9PSBzaGFkZXIgfHwgdGhpcy5fc2hhZGVyT3duZXIgIT09IG93bmVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2hhZGVyID0gc2hhZGVyO1xuICAgICAgICAgICAgICAgIHRoaXMuX3NoYWRlck93bmVyID0gb3duZXI7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hlY2sgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHJlbmRlclRleHR1cmVJbmZvKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyVGV4dHVyZUluZm87XG4gICAgfVxuXG4gICAgc2V0U2Npc3NvcihhcmVhKSB7XG4gICAgICAgIGlmICh0aGlzLl9zY2lzc29yICE9PSBhcmVhKSB7XG4gICAgICAgICAgICBpZiAoYXJlYSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBhcmVhO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX2NoZWNrID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldFNjaXNzb3IoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zY2lzc29yO1xuICAgIH1cblxuICAgIHNldFJlbmRlclRleHR1cmVJbmZvKHJlbmRlclRleHR1cmVJbmZvKSB7XG4gICAgICAgIGlmICh0aGlzLl9yZW5kZXJUZXh0dXJlSW5mbyAhPT0gcmVuZGVyVGV4dHVyZUluZm8pIHtcbiAgICAgICAgICAgIHRoaXMuX3JlbmRlclRleHR1cmVJbmZvID0gcmVuZGVyVGV4dHVyZUluZm87XG4gICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMuX2NoZWNrID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFNldHMgdGhlIHRleHR1cml6ZXIgdG8gYmUgZHJhd24gZHVyaW5nIHN1YnNlcXVlbnQgYWRkUXVhZHMuXG4gICAgICogQHBhcmFtIHtFbGVtZW50VGV4dHVyaXplcn0gdGV4dHVyaXplclxuICAgICAqL1xuICAgIHNldFRleHR1cml6ZXIodGV4dHVyaXplciwgY2FjaGUgPSBmYWxzZSkge1xuICAgICAgICB0aGlzLl90ZXh0dXJpemVyID0gdGV4dHVyaXplcjtcbiAgICAgICAgdGhpcy5fY2FjaGVUZXh0dXJpemVyID0gY2FjaGU7XG4gICAgfVxuXG4gICAgc2V0IGlzQ2FjaGluZ1RleHR1c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Z2luYWxYO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5feDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldCBvZmZzZXRYKHYpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzRnVuY3Rpb24odikpIHtcbiAgICAgICAgICAgIHRoaXMuZnVuY1ggPSB2O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZGlzYWJsZUZ1bmNYKCk7XG4gICAgICAgICAgICBpZiAodGhpcy5oYXNGbGV4TGF5b3V0KCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnggKz0gKHYgLSB0aGlzLl9sYXlvdXQub3JpZ2luYWxYKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXQuc2V0T3JpZ2luYWxYV2l0aG91dFVwZGF0aW5nTGF5b3V0KHYpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLnggPSB2O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl94O1xuICAgIH1cblxuICAgIHNldCB4KHYpIHtcbiAgICAgICAgaWYgKHYgIT09IHRoaXMuX3gpIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlRGVsdGEodiAtIHRoaXMuX3gsIDApO1xuICAgICAgICAgICAgdGhpcy5feCA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgZnVuY1goKSB7XG4gICAgICAgIHJldHVybiAodGhpcy5fb3B0RmxhZ3MgJiAxID8gdGhpcy5fZnVuY1ggOiBudWxsKTtcbiAgICB9XG5cbiAgICBzZXQgZnVuY1godikge1xuICAgICAgICBpZiAodGhpcy5fZnVuY1ggIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX29w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AgICAgICAgIHRoaXMuX2Rpc2FibGVGdW5jWSgpO1xuICAgICAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy55ICs9ICh2IC0gdGhpcy5fbGF5b3V0Lm9yaWdpbmFsWSk7XG4gICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0LnNldE9yaWdpbmFsWVdpdGhvdXRVcGRhdGluZ0xheW91dCh2KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy55ID0gdjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB5KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5feTtcbiAgICB9XG5cbiAgICBzZXQgeSh2KSB7XG4gICAgICAgIGlmICh2ICE9PSB0aGlzLl95KSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZURlbHRhKDAsIHYgLSB0aGlzLl95KTtcbiAgICAgICAgICAgIHRoaXMuX3kgPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGZ1bmNZKCkge1xuICAgICAgICByZXR1cm4gKHRoaXMuX29wdEZsYWdzICYgMiA/IHRoaXMuX2Z1bmNZIDogbnVsbCk7XG4gICAgfVxuXG4gICAgc2V0IGZ1bmNZKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2Z1bmNZICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9vcHRGbGFncyB8PSAyO1xuICAgICAgICAgICAgdGhpcy5fZnVuY1kgPSB2O1xuICAgICAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0LnNldE9yaWdpbmFsWVdpdGhvdXRVcGRhdGluZ0xheW91dCgwKTtcbiAgICAgICAgICAgICAgICB0aGlzLmxheW91dC5mb3JjZUxheW91dCgpO1xuICAgICAgIC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xsO1xuICAgIH1cblxuICAgIGdldCBmdW5jSCgpIHtcbiAgICAgICAgcmV0dXJuICh0aGlzLl9vcHRGbGFncyAmIDggPyB0aGlzLl9mdW5jSCA6IG51bGwpO1xuICAgIH1cblxuICAgIHNldCBmdW5jSCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9mdW5jSCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fb3B0RmxhZ3MgfD0gODtcbiAgICAgICAgICAgIHRoaXMuX2Z1bmNIID0gdjtcbiAgICAgICAgICAgIGlmICh0aGlzLmhhc0ZsZXhMYXlvdXQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2xheW91dC5fb3JpZ2luYWxIZWlnaHQgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMubGF5b3V0LmNoYW5nZWREaW1lbnNpb25zKGZhbHNlLCB0cnVlKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5faCA9IDA7XG4gICAgICAgICAgICAgICAgdGhpcy5fdHJpZ2dlclJlY2FsY1RyYW5zbGF0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZGlzYWJsZUZ1bmNIKCkge1xuICAgICAgICB0aGlzLl9vcHRGbGFncyA9IHRoaXMuX29wdEZsYWdzICYgKDB4RkZGRiAtIDgpO1xuICAgICAgICB0aGlzLl9mdW5jSCA9IG51bGw7XG4gICAgfVxuXG4gICAgZ2V0IHcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93O1xuICAgIH1cblxuICAgIGdldFJlbmRlcldpZHRoKCkge1xuICAgICAgICBpZiAodGhpcy5oYXNGbGV4TGF5b3V0KCkpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9sYXlvdXQub3JpZ2luYWxXaWR0aDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl93O1xuICAgICAgICB9XG4gICAgfVxuXG4gIC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ggIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX21vdW50WCA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IG1vdW50WSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21vdW50WTtcbiAgICB9XG5cbiAgICBzZXQgbW91bnRZKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX21vdW50WSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fbW91bnRZID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgbW91bnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9tb3VudFg7XG4gICAgfVxuXG4gICAgc2V0IG1vdW50KHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX21vdW50WCAhPT0gdiB8fCB0aGlzLl9tb3VudFkgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX21vdW50WCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9tb3VudFkgPSB2O1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCByb3RhdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3JvdGF0aW9uO1xuICAgIH1cblxuICAgIHNldCByb3RhdGlvbih2KSB7XG4gICAgICAgIGlmICh0aGlzLl9yb3RhdGlvbiAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fcm90YXRpb24gPSB2O1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2Zvcm0oKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBhbHBoYSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2FscGhhO1xuICAgIH1cblxuIC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zKCkge1xuICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgIHdoaWxlIChwICYmICFwLl9oYXNVcGRhdGVzKSB7XG4gICAgICAgICAgICBwLl9oYXNVcGRhdGVzID0gdHJ1ZTtcbiAgICAgICAgICAgIHAgPSBwLl9wYXJlbnQ7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXRQYXJlbnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9wYXJlbnQ7XG4gICAgfVxuXG4gICAgc2V0UGFyZW50KHBhcmVudCkge1xuICAgICAgICBpZiAocGFyZW50ICE9PSB0aGlzLl9wYXJlbnQpIHtcbiAgICAgICAgICAgIGxldCBwcmV2SXNaQ29udGV4dCA9IHRoaXMuaXNaQ29udGV4dCgpO1xuICAgICAgICAgICAgbGV0IHByZXZQYXJlbnQgPSB0aGlzLl9wYXJlbnQ7XG4gICAgICAgICAgICB0aGlzLl9wYXJlbnQgPSBwYXJlbnQ7XG5cbiAgICAgICAgICAgIC8vIE5vdGlmeSBmbGV4IGxheW91dCBlbmdpbmUuXG4gICAgICAgICAgICBpZiAodGhpcy5fbGF5b3V0IHx8IChwYXJlbnQgJiYgcGFyZW50LmlzRmxleENvbnRhaW5lcigpKSkge1xuICAgICAgICAgICAgICAgIHRoaXMubGF5b3V0LnNldFBhcmVudChwcmV2UGFyZW50LCBwYXJlbnQpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocHJldlBhcmVudCkge1xuICAgICAgICAgICAgICAgIC8vIFdoZW4gZWxlbWVudHMgYXJlIGRlbGV0ZWQsIHRoZSByZW5kZXIgdGV4dHVyZSBtdXN0IGJlIHJlLXJlbmRlcmVkLlxuICAgICAgICAgICAgICAgIHByZXZQYXJlbnQuc2V0SGFzUmVuZGVyVXBkYXRlcygzKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fc2V0UmVjYWxjKDEgKyAyICsgNCk7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAvLyBGb3JjZSBwYXJlbnQgdG8gcHJvcGFnYXRlIGhhc1VwZGF0ZXMgZmxhZy5cbiAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnQuX3NldEhhc1VwZGF0ZXMoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChwYXJlbnQpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldFpQYXJlbnQocGFyZW50ID8gcGFyZW50LmZpbmRaQ29udGV4dCgpIDogbnVsbCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChwcmV2SXNaQ29udGV4dCAhPT0gdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZVpDb250ZXh0KCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVaQ29udGV4dChwcmV2UGFyZW50LmZpbmRaQ29udGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIFRyZWUgb3JkZXIgZGlkIGNoYW5nZTogZXZlbiBpZiB6UGFyZW50IHN0YXlzIHRoZSBzYW1lLCB3ZSBtdXN0IHJlc29ydC5cbiAgICAgICAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKCF0aGlzLl9zaGFkZXIpIHtcbiAgICAgICAgICAgICAgICBsZXQgbmV3U2hhZGVyT3duZXIgPSBwYXJlbnQgJiYgIXBhcmVudC5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCA/IHBhcmVudC5fc2hhZGVyT3duZXIgOiBudWxsO1xuICAgICAgICAgICAgICAgIGlmIChuZXdTaGFkZXJPd25lciAhPT0gdGhpcy5fc2hhZGVyT3duZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKDEpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTaGFkZXJPd25lclJlY3Vyc2l2ZShuZXdTaGFkZXJPd25lcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIGVuYWJsZVpTb3J0KGZvcmNlID0gZmFsc2UpIHtcbiAgICAgICAgaWYgKCF0aGlzLl96U29ydCAmJiB0aGlzLl96Q29udGV4dFVzYWdlID4gMCkge1xuICAgICAgICAgICAgdGhpcy5felNvcnQgPSB0cnVlO1xuICAgICAgICAgICAgaWYgKGZvcmNlKSB7XG4gICAgICAgICAgICAgICAgLy8gWlNvcnQgbXVzdCBiZSBkb25lLCBldmVuIGlmIHRoaXMgZWxlbWVudCBpcyBpbnZpc2libGUuXG4gICAgICAgICAgICAgICAgLy8gVGhpcyBpcyBkb25lIHRvIHByZXZlbnQgbWVtb3J5IGxlYWtzIHdoZW4gcmVtb3ZpbmcgZWxlbWVudCBmcm9tIGluYWN0aXZlIHJlbmRlciBicmFuY2hlcy5cbiAgICAgICAgICAgICAgICB0aGlzLmN0eC5mb3JjZVpTb3J0KHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgYWRkQ2hpbGRBdChpbmRleCwgY2hpbGQpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9jaGlsZHJlbikgdGhpcy5fY2hpbGRyZW4gPSBb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zRXN0aW1hdGUgPSB0aGlzLl9kaW1zVW5rbm93bikge1xuICAgICAgICAvLyBJbiBjYXNlIG9mIGFuIGVzdGltYXRpb24sIHRoZSB1cGRhdGUgbG9vcCBzaG91bGQgcGVyZm9ybSBkaWZmZXJlbnQgYm91bmQgY2hlY2tzLlxuICAgICAgICB0aGlzLl9kaW1zVW5rbm93biA9IGlzRXN0aW1hdGU7XG5cbiAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICB0aGlzLl9sYXlvdXQub3JpZ2luYWxXaWR0aCA9IHc7XG4gICAgICAgICAgICB0aGlzLl9sYXlvdXQub3JpZ2luYWxIZWlnaHQgPSBoO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3cgIT09IHcgfHwgdGhpcy5faCAhPT0gaCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZURpbWVuc2lvbnModywgaCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH07XG5cbiAgICBfdXBkYXRlRGltZW5zaW9ucyh3LCBoKSB7XG4gICAgICAgIGlmICh0aGlzLl93ICE9PSB3IHx8IHRoaXMuX2ggIT09IGgpIHtcbiAgICAgICAgICAgIHRoaXMuX3cgPSB3O1xuICAgICAgICAgICAgdGhpcy5faCA9IGg7XG5cbiAgICAgICAgICAgIHRoaXMuX3RyaWdnZXJSZWNhbGNUcmFuc2xhdGUoKTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX3RleHR1cml6ZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnJlbGVhc2VSZW5kZXJUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci51cGRhdGVSZXN1bHRUZXh0dXJlKCk7XG4gICAgICAgICAgICB9XG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RoaXMuX2ZvcmNlWkluZGV4Q29udGV4dCB8fCB0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkIHx8IHRoaXMuX3pJbmRleCAhPT0gMCB8fCB0aGlzLl9pc1Jvb3QgfHwgIXRoaXMuX3BhcmVudCk7XG4gICAgfTtcblxuICAgIGZpbmRaQ29udGV4dCgpIHtcbiAgICAgICAgaWYgKHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc2V0WlBhcmVudChuZXdaUGFyZW50KSB7XG4gICAgICAgIGlmICh0aGlzLl96UGFyZW50ICE9PSBuZXdaUGFyZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5kZWNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gV2UgbXVzdCBmaWx0ZXIgb3V0IHRoaXMgaXRlbSB1cG9uIHRoZSBuZXh0IHJlc29ydC5cbiAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChuZXdaUGFyZW50ICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgbGV0IGhhZFpDb250ZXh0VXNhZ2UgPSAobmV3WlBhcmVudC5fekNvbnRleHRVc2FnZSA+IDApO1xuXG4gICAgICAgICAgICAgICAgLy8gQHByZTogbmV3IHBhcmVudCdzIGNoaWxkcmVuIGFycmF5IGhhcyBhbHJlYWR5IGJlZW4gbW9kaWZpZWQuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgICAgICAgICBuZXdaUGFyZW50LmluY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAobmV3WlBhcmVudC5fekNvbnRleHRVc2FnZSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYWRaQ29udGV4dFVzYWdlICYmICh0aGlzLl9wYXJlbnQgPT09IG5ld1pQYXJlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBUaGlzIGNoaWxkIHdhcyBhbHJlYWR5IGluIHRoZSBjaGlsZHJlbiBsaXN0LlxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gRG8gbm90IGFkZCBkb3VibGUuXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBBZGQgbmV3IGNoaWxkIHRvIGFycmF5LlxuICAgICAgICAgICAgICAgICAgICAgICAgbmV3WlBhcmVudC5fekluZGV4ZWRDaGlsZHJlbi5wdXNoKHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gT3JkZXIgc2hvdWxkIGJlIGNoZWNrZWQuXG4gICAgICAgICAgICAgICAgICAgIG5ld1pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQgPSBuZXdaUGFyZW50O1xuXG4gICAgICAgICAgICAvLyBOZXdseSBhZGRlZCBlbGVtZW50IG11c3QgYmUgbWFya2VkIGZvciByZXNvcnQuXG4gICAgICAgICAgICB0aGlzLl96SW5kZXhSZXNvcnQgPSB0cnVlO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGluY1pDb250ZXh0VXNhZ2UoKSB7XG4gICAgICAgIHRoaXMuX3pDb250ZXh0VXNhZ2UrKztcbiAgICAgICAgaWYgKHRoaXMuX3pDb250ZXh0VXNhZ2UgPT09IDEpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fekluZGV4ZWRDaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4gPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIC8vIENvcHkuXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5wdXNoKHRoaXMuX2NoaWxkcmVuW2ldKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgLy8gSW5pdGlhbGx5LCBjaGlsZHJlbiBhcmUgYWxyZWFkeSBzb3J0ZWQgcHJvcGVybHkgKHRyZWUgb3JkZXIpLlxuICAgICAgICAgICAgICAgIHRoaXMuX3pTb3J0ID0gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZGVjWkNvbnRleHRVc2FnZSgpIHtcbiAgICAgICAgdGhpcy5fekNvbnRleHRVc2FnZS0tO1xuICAgICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5felNvcnQgPSBmYWxzZTtcbiAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4uc3BsaWNlKDApO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldCB6SW5kZXgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl96SW5kZXg7XG4gICAgfVxuXG4gICAgc2V0IHpJbmRleCh6SW5kZXgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3pJbmRleCAhPT0gekluZGV4KSB7XG4gICAgICAgICAgICB0aGlzLnNldEhhc1JlbmRlclVwZGF0ZXMoMSk7XG5cbiAgICAgICAgICAgIGxldCBuZXdaUGFyZW50ID0gdGhpcy5felBhcmVudDtcblxuICAgICAgICAgICAgbGV0IHByZXZJc1pDb250ZXh0ID0gdGhpcy5pc1pDb250ZXh0KCk7XG4gICAgICAgICAgICBpZiAoekluZGV4ID09PSAwICYmIHRoaXMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wYXJlbnQgPT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZGVjWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbmV3WlBhcmVudCA9IHRoaXMuX3BhcmVudDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHpJbmRleCAhPT0gMCAmJiB0aGlzLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgICAgICAgICBuZXdaUGFyZW50ID0gdGhpcy5fcGFyZW50ID8gdGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpIDogbnVsbDtcbiAgICAgICAgICAgICAgICBpZiAobmV3WlBhcmVudCA9PT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5pbmNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHpJbmRleCAhPT0gdGhpcy5fekluZGV4KSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQgJiYgdGhpcy5felBhcmVudC5fekNvbnRleHRVc2FnZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAobmV3WlBhcmVudCAhPT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChudWxsKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fekluZGV4ID0gekluZGV4O1xuXG4gICAgICAgICAgICBpZiAobmV3WlBhcmVudCAhPT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChuZXdaUGFyZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHByZXZJc1pDb250ZXh0ICE9PSB0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlWkNvbnRleHQoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZVpDb250ZXh0KHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBNYWtlIHN1cmUgdGhhdCByZXNvcnQgaXMgZG9uZS5cbiAgICAgICAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBnZXQgZm9yY2VaSW5kZXhDb250ZXh0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZm9yY2VaSW5kZXhDb250ZXh0O1xuICAgIH1cblxuICAgIHNldCBmb3JjZVpJbmRleENvbnRleHQodikge1xuICAgICAgICB0aGlzLnNldEhhc1JlbmRlclVwZGF0ZXMoMSk7XG5cbiAgICAgICAgbGV0IHByZXZJc1pDb250ZXh0ID0gdGhpcy5pc1pDb250ZXh0KCk7XG4gICAgICAgIHRoaXMuX2ZvcmNlWkluZGV4Q29udGV4dCA9IHY7XG5cbiAgICAgICAgaWYgKHByZXZJc1pDb250ZXh0ICE9PSB0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZVpDb250ZXh0KCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlWkNvbnRleHQodGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBlbmFibGVaQ29udGV4dChwcmV2WkNvbnRleHQpIHtcbiAgICAgICAgaWYgKHByZXZaQ29udGV4dCAmJiBwcmV2WkNvbnRleHQuX3pDb250ZXh0VXNhZ2UgPiAwKSB7XG4gICAgICAgICAgICAvLyBUcmFuc2ZlciBmcm9tIHVwcGVyIHogY29udGV4dCB0byB0aGlzIHogY29udGV4dC5cbiAgICAgICAgICAgIGNvbnN0IHJlc3VsdHMgPSB0aGlzLl9nZXRaSW5kZXhlZERlc2NzKCk7XG4gICAgICAgICAgICByZXN1bHRzLmZvckVhY2goKGMpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0FuY2VzdG9yT2YoYykgJiYgYy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGMuc2V0WlBhcmVudCh0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRaSW5kZXhlZERlc2NzKCkge1xuICAgICAgICBjb25zdCByZXN1bHRzID0gW107XG4gICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS5fZ2V0WkluZGV4ZWREZXNjc1JlYyhyZXN1bHRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0cztcbiAgICB9XG5cbiAgICBfZ2V0WkluZGV4ZWREZXNjc1JlYyhyZXN1bHRzKSB7XG4gICAgICAgIGlmICh0aGlzLl96SW5kZXgpIHtcbiAgICAgICAgICAgIHJlc3VsdHMucHVzaCh0aGlzKTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9jaGlsZHJlbiAmJiAhdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0uX2dldFpJbmRleGVkRGVzY3NSZWMocmVzdWx0cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBkaXNhYmxlWkNvbnRleHQoKSB7XG4gICAgICAgIC8vIFRyYW5zZmVyIGZyb20gdGhpcyB6IGNvbnRleHQgdG8gdXBwZXIgeiBjb250ZXh0LlxuICAgICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSA+IDApIHtcbiAgICAgICAgICAgIGxldCBuZXdaUGFyZW50ID0gdGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpO1xuXG4gICAgICAgICAgICAvLyBNYWtlIHN1cmUgdGhhdCB6LWluZGV4ZWQgY2hpbGRyZW4gYXJlIHVwIHRvIGRhdGUgKG9sZCBvbmVzIHJlbW92ZWQpLlxuICAgICAgICAgICAgaWYgKHRoaXMuX3pTb3J0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zb3J0WkluZGV4ZWRDaGlsZHJlbigpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuLnNsaWNlKCkuZm9yRWFjaChmdW5jdGlvbiAoYykge1xuICAgICAgICAgICAgICAgIGlmIChjLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgYy5zZXRaUGFyZW50KG5ld1pQYXJlbnQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldCBjb2xvclVsKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY29sb3JVbDtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JVbChjb2xvcikge1xuICAgICAgICBpZiAodGhpcy5fY29sb3JVbCAhPT0gY29sb3IpIHtcbiAgICAgICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcyh0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlID8gMyA6IDEpO1xuICAgICAgICAgICAgdGhpcy5fY29sb3JVbCA9IGNvbG9yO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yVXIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jb2xvclVyO1xuICAgIH1cblxuICAgIHNldCBjb2xvclVyKGNvbG9yKSB7XG4gICAgICAgIGlmICh0aGlzLl9jb2xvclVyICE9PSBjb2xvcikge1xuICAgICAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UgPyAzIDogMSk7XG4gICAgICAgICAgICB0aGlzLl9jb2xvclVyID0gY29sb3I7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZ2V0IGNvbG9yQmwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jb2xvckJsO1xuICAgIH1cblxuICAgIHNldCBjb2xvckJsKGNvbG9yKSB7XG4gICAgICAgIGlmICh0aGlzLl9jb2xvckJsICE9PSBjb2xvcikge1xuICAgICAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UgPyAzIDogMSk7XG4gICAgICAgICAgICB0aGlzLl9jb2xvckJsID0gY29sb3I7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZ2V0IGNvbG9yQnIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jb2xvckJyO1xuICAgIH1cblxuICAgIHNldCBjb2xvckJyKGNvbG9yKSB7XG4gICAgICAgIGlmICh0aGlzLl9jb2xvckJyICE9PSBjb2xvcikge1xuICAgICAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UgPyAzIDogMSk7XG4gICAgICAgICAgICB0aGlzLl9jb2xvckJyID0gY29sb3I7XG4gICAgICAgIH1cbiAgICB9O1xuXG5cbiAgICBzZXQgb25VcGRhdGUoZikge1xuICAgICAgICB0aGlzLl9vblVwZGF0ZSA9IGY7XG4gICAgICAgIHRoaXMuX3NldFJlY2FsYyg3KTtcbiAgICB9XG5cbiAgICBzZXQgb25BZnRlclVwZGF0ZShmKSB7XG4gICAgICAgIHRoaXMuX29uQWZ0ZXJVcGRhdGUgPSBmO1xuICAgICAgICB0aGlzLl9zZXRSZ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AgdGhpcy5fc2hhZGVyT3duZXIgPSBlbGVtZW50Q29yZTtcblxuICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4gJiYgIXRoaXMuX3JlbmRlclRvVGV4dHVyZUVuYWJsZWQpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbGV0IGMgPSB0aGlzLl9jaGlsZHJlbltpXTtcbiAgICAgICAgICAgICAgICBpZiAoIWMuX3NoYWRlcikge1xuICAgICAgICAgICAgICAgICAgICBjLl9zZXRTaGFkZXJPd25lclJlY3Vyc2l2ZShlbGVtZW50Q29yZSk7XG4gICAgICAgICAgICAgICAgICAgIGMuX2hhc1JlbmRlclVwZGF0ZXMgPSAzO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBfc2V0U2hhZGVyT3duZXJDaGlsZHJlblJlY3Vyc2l2ZShlbGVtZW50Q29yZSkge1xuICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbGV0IGMgPSB0aGlzLl9jaGlsZHJlbltpXTtcbiAgICAgICAgICAgICAgICBpZiAoIWMuX3NoYWRlcikge1xuICAgICAgICAgICAgICAgICAgICBjLl9zZXRTaGFkZXJPd25lclJlY3Vyc2l2ZShlbGVtZW50Q29yZSk7XG4gICAgICAgICAgICAgICAgICAgIGMuX2hhc1JlbmRlclVwZGF0ZXMgPSAzO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBfaGFzUmVuZGVyQ29udGV4dCgpIHtcbiAgICAgICAgcmV0dXJu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2l2ZShudWxsKTtcblxuICAgICAgICAgICAgaWYgKCFwcmV2SXNaQ29udGV4dCkge1xuICAgICAgICAgICAgICAgIC8vIFJlbmRlciBjb250ZXh0IGZvcmNlcyB6IGNvbnRleHQuXG4gICAgICAgICAgICAgICAgdGhpcy5lbmFibGVaQ29udGV4dCh0aGlzLl9wYXJlbnQgPyB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkgOiBudWxsKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKDMpO1xuXG4gICAgICAgICAgICAvLyBNYWtlIHN1cmUgdGhhdCB0aGUgcmVuZGVyIGNvb3JkaW5hdGVzIGdldCB1cGRhdGVkLlxuICAgICAgICAgICAgdGhpcy5fc2V0UmVjYWxjKDcpO1xuXG4gICAgICAgICAgICB0aGlzLnJlbmRlciA9IHRoaXMuX3JlbmRlckFkdmFuY2VkO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2Rpc2FibGVSZW5kZXJUb1RleHR1cmUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkKSB7XG4gICAgICAgICAgICB0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkID0gZmFsc2U7XG5cbiAgICAgICAgICAgIHRoaXMuX3NldFNoYWRlck93bmVyQ2hpbGRyZW5SZWN1cnNpdmUodGhpcy5fc2hhZGVyT3duZXIpO1xuXG4gICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuXG4gICAgICAgICAgICBpZiAoIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlWkNvbnRleHQoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHRoYXQgdGhlIHJlbmRlciBjb29yZGluYXRlcyBnZXQgdXBkYXRl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xwaGEgJiYgdmlzaWJsZSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBCZWNvbWVzIHZpc2libGUuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2hhc1JlbmRlclVwZGF0ZXMgPSAzO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB3LmFscGhhID0gcHcuYWxwaGEgKiB0aGlzLl9sb2NhbEFscGhhO1xuXG4gICAgICAgICAgICAgICAgaWYgKHcuYWxwaGEgPCAxZS0xNCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBUaW55IHJvdW5kaW5nIGVycm9ycyBtYXkgY2F1c2UgZmFpbGluZyB2aXNpYmlsaXR5IHRlc3RzLlxuICAgICAgICAgICAgICAgICAgICB3LmFscGhhID0gMDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChyZWNhbGMgJiA2KSB7XG4gICAgICAgICAgICAgICAgdy5weCA9IHB3LnB4ICsgdGhpcy5fbG9jYWxQeCAqIHB3LnRhO1xuICAgICAgICAgICAgICAgIHcucHkgPSBwdy5weSArIHRoaXMuX2xvY2FsUHkgKiBwdy50ZDtcbiAgICAgICAgICAgICAgICBpZiAocHcudGIgIT09IDApIHcucHggKz0gdGhpcy5fbG9jYWxQeSAqIHB3LnRiO1xuICAgICAgICAgICAgICAgIGlmIChwdy50YyAhPT0gMCkgdy5weSArPSB0aGlzLl9sb2NhbFB4ICogcHcudGM7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChyZWNhbGMgJiA0KSB7XG4gICAgICAgICAgICAgICAgdy50YSA9IHRoaXMuX2xvY2FsVGEgKiBwdy50YTtcbiAgICAgICAgICAgICAgICB3LnRiID0gdGhpcy5fbG9jYWxUZCAqIHB3LnRiO1xuICAgICAgICAgICAgICAgIHcudGMgPSB0aGlzLl9sb2NhbFRhICogcHcudGM7XG4gICAgICAgICAgICAgICAgdy50ZCA9IHRoaXMuX2xvY2FsVGQgKiBwdy50ZDtcblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pc0NvbXBsZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgdy50YSArPSB0aGlzLl9sb2NhbFRjICogcHcudGI7XG4gICAgICAgICAgICAgICAgICAgIHcudGIgKz0gdGhpcy5fbG9jYWxUYiAqIHB3LnRhO1xuICAgICAgICAgICAgICAgICAgICB3LnRjICs9IHRoaXMuX2xvY2FsVGMgKiBwdy50ZDtcbiAgICAgICAgICAgICAgICAgICAgdy50ZCArPSB0aGlzLl9sb2NhbFRiICogcHcudGM7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBVcGRhdGUgcmVuZGVyIGNvb3Jkcy9hbHBoYS5cbiAgICAgICAgICAgIGNvbnN0IHByID0gdGhpcy5fcGFyZW50Ll9yZW5kZXJDb250ZXh0O1xuICAgICAgICAgICAgaWYgKHRoaXMuX3BhcmVudC5faGFzUmVuZGVyQ29udGV4dCgpKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgaW5pdCA9IHRoaXMuX3JlbmRlckNvbnRleHQgPT09IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgICAgICAgICBpZiAoaW5pdCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBGaXJzdCByZW5kZXIgY29udGV4dCBidWlsZDogbWFrZSBzdXJlIHRoYXQgaXQgaXMgZnVsbHkgaW5pdGlhbGl6ZWQgY29ycmVjdGx5LlxuICAgICAgICAgICAgICAgICAgICAvLyBPdGhlcndpc2UsIGlmIHdlIGdldCBpbnRvIGJvdW5kcyBsYXRlciwgdGhlIHJlbmRlciBjb250ZXh0IHdvdWxkIG5vdCBiZSBpbml0aWFsaXplZCBjb3JyZWN0bHkuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBuZXcgRWxlbWVudENvcmVDb250ZXh0KCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgY29uc3QgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG5cbiAgICAgICAgICAgICAgICAvLyBVcGRhdGUgd29ybGQgY29vcmRzL2FscGhhLlxuICAgICAgICAgICAgICAgIGlmIChpbml0IHx8IChyZWNhbGMgJiAxKSkge1xuICAgICAgICAgICAgICAgICAgICByLmFscGhhID0gcHIuYWxwaGEgKiB0aGlzLl9sb2NhbEFscGhhO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChyLmFscGhhIDwgMWUtMTQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHIuYWxwaGEgPSAwO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGluaXQgfHwgKHJlY2FsYyAmIDYpKSB7XG4gICAgICAgICAgICAgICAgICAgIHIucHggPSBwci5weCArIHRoaXMuX2xvY2FsUHggKiBwci50YTtcbiAgICAgICAgICAgICAgICAgICAgci5weSA9IHByLnB5ICsgdGhpcy5fbG9jYWxQeSAqIHByLnRkO1xuICAgICAgICAgICAgICAgICAgICBpZiAocHIudGIgIT09IDApIHIucHggKz0gdGhpcy5fbG9jYWxQeSAqIHByLnRiO1xuICAgICAgICAgICAgICAgICAgICBpZiAocHIudGMgIT09IDApIHIucHkgKz0gdGhpcy5fbG9jYWxQeCAqIHByLnRjO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChpbml0KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFdlIHNldCB0aGUgcmVjYWxjIHRvZ2dsZSwgYmVjYXVzZSB3ZSBtdXN0IG1ha2Ugc3VyZSB0aGF0IHRoZSBzY2lzc29yIGlzIHVwZGF0ZWQuXG4gICAgICAgICAgICAgICAgICAgIHJlY2FsYyB8PSAyO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChpbml0IHx8IChyZWNhbGMgJiA0KSkge1xuICAgICAgICAgICAgICAgICAgICByLnRhID0gdGhpcy5fbG9jYWxUYSAqIHByLnRhO1xuICAgICAgICAgICAgICAgICAgICByLnRiID0gdGhpcy5fbG9jYWxUZCAqIHByLnRiO1xuICAgICAgICAgICAgICAgICAgICByLnRjID0gdGhpcy5fbG9jYWxUYSAqIHByLnRjO1xuICAgICAgICAgICAgICAgICAgICByLnRkID0gdGhpcy5fbG9jYWxUZCAqIHByLnRkO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pc0NvbXBsZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHIudGEgKz0gdGhpcy5fbG9jYWxUYyAqIHByLnRiO1xuICAgICAgICAgICAgICAgICAgICAgICAgci50YiArPSB0aGlzLl9sb2NhbFRiICogcHIudGE7XG4gICAgICAgICAgICAgICAgICAgICAgICByLnRjICs9IHRoaXMuX2xvY2FsVGMgKiBwci50ZDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHIudGQgKz0gdGhpcy5fbG9jYWxUYiAqIHByLnRjO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID09PSAtMSkge1xuICAgICAgICAgICAgICAgIHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlciA9IHRoaXMuX3VwZGF0ZVRyZWVPcmRlciArIDE7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVRyZWVPcmRlciA9IHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlcisrO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBEZXRlcm1pbmUgd2hldGhlciB3ZSB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ZWxlbWVudC5cbiAgICAgICAgICAgIGxldCBzeCwgc3ksIGV4LCBleTtcbiAgICAgICAgICAgIGNvbnN0IHJDb21wbGV4ID0gKHIudGIgIT09IDApIHx8IChyLnRjICE9PSAwKSB8fCAoci50YSA8IDApIHx8IChyLnRkIDwgMCk7XG4gICAgICAgICAgICBpZiAockNvbXBsZXgpIHtcbiAgICAgICAgICAgICAgICBzeCA9IE1hdGgubWluKDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgICAgICBleCA9IE1hdGgubWF4KDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgICAgICBzeSA9IE1hdGgubWluKDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICAgICAgICBleSA9IE1hdGgubWF4KDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgc3ggPSByLnB4O1xuICAgICAgICAgICAgICAgIGV4ID0gci5weCArIHIudGEgKiBiYm94VztcbiAgICAgICAgICAgICAgICBzeSA9IHIucHk7XG4gICAgICAgICAgICAgICAgZXkgPSByLnB5ICsgci50ZCAqIGJib3hIO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fZGltc1Vua25vd24gJiYgKHJDb21wbGV4IHx8IHRoaXMuX2xvY2FsVGEgPCAxIHx8IHRoaXMuX2xvY2FsVGIgPCAxKSkge1xuICAgICAgICAgICAgICAgIC8vIElmIHdlIGFyZSBkZWFsaW5nIHdpdGggYSBub24taWRlbnRpdHkgbWF0cml4LCB3ZSBtdXN0IGV4dGVuZCB0aGUgYmJveCBzbyB0aGF0IHdpdGhpbkJvdW5kcyBhbmRcbiAgICAgICAgICAgICAgICAvLyAgc2Npc3NvcnMgd2lsbCBpbmNsdWRlIHRoZSBjb21wbGV0ZSByYW5nZSBvZiAocG9zaXRpdmUpIGRpbWVuc2lvbnMgdXAgdG8gLGxoLlxuICAgICAgICAgICAgICAgIGNvbnN0IG54ID0gdGhpcy5feCAqIHByLnRhICsgdGhpcy5feSAqIHByLnRiICsgcHIucHg7XG4gICAgICAgICAgICAgICAgY29uc3QgbnkgPSB0aGlzLl94ICogcHIudGMgKyB0aGlzLl95ICogcHIudGQgKyBwci5weTtcbiAgICAgICAgICAgICAgICBpZiAobnggPCBzeCkgc3ggPSBueDtcbiAgICAgICAgICAgICAgICBpZiAobnkgPCBzeSkgc3kgPSBueTtcbiAgICAgICAgICAgICAgICBpZiAobnggPiBleCkgZXggPSBueDtcbiAgICAgICAgICAgICAgICBpZiAobnkgPiBleSkgZXkgPSBueTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHJlY2FsYyAmIDYgfHwgIXRoaXMuX3NjaXNzb3IgLyogaW5pdGlhbCAqLykge1xuICAgICAgICAgICAgICAgIC8vIERldGVybWluZSB3aGV0aGVyIHdlIG11c3QgJ2NsaXAnLlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jbGlwcGluZyAmJiByLmlzU3F1YXJlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gSWYgdGhlIHBhcmVudCByZW5kZXJzIHRvIGEgdGV4dHVyZSwgaXQncyBzY2lzc29yIHNob3VsZCBiZSBpZ25vcmVkO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmVhID0gdGhpcy5fcGFyZW50Ll91c2VSZW5kZXJUb1RleHR1cmUgPyB0aGlzLl9wYXJlbnQuX3ZpZXdwb3J0IDogdGhpcy5fcGFyZW50Ll9zY2lzc29yO1xuICAgICAgICAgICAgICAgICAgICBpZiAoYXJlYSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gTWVyZ2Ugc2Npc3NvciBhcmVhcy5cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGx4ID0gTWF0aC5tYXgoYXJlYVswXSwgc3gpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbHkgPSBNYXRoLm1heChhcmVhWzFdLCBzeSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gW1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGx4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGx5LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWluKGFyZWFbMl0gKyBhcmVhWzBdLCBleCkgLSBseCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXRoLm1pbihhcmVhWzNdICsgYXJlYVsxXSwgZXkpIC0gbHlcbiAgICAgICAgICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gW3N4LCBzeSwgZXggLSBzeCwgZXkgLSBzeV07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBObyBjbGlwcGluZzogcmV1c2UgcGFyZW50IHNjaXNzb3IuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSB0aGlzLl9wYXJlbnQuX3VzZVJlbmRlclRvVGV4dHVyZSA/IHRoaXMuX3BhcmVudC5fdmlld3BvcnQgOiB0aGlzLl9wYXJlbnQuX3NjaXNzb3I7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBDYWxjdWxhdGUgdGhlIG91dE9mQm91bmRzIG1hcmdpbi5cbiAgICAgICAgICAgIGlmICh0aGlzLl9ib3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZWNCb3VuZHNNYXJnaW4gPSB0aGlzLl9ib3VuZHNNYXJnaW47XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlY0JvdW5kc01hcmdpbiA9IHRoaXMuX3BhcmVudC5fcmVjQm91bmRzTWFyZ2luO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fb25BZnRlckNhbGNzKSB7XG4gICAgICAgICAgICAgICAgLy8gQWZ0ZXIgY2FsY3MgbWF5IGNoYW5nZSByZW5kZXIgY29vcmRzLCBzY2lzc29yIGFuZC9vciByZWNCb3VuZHNNYXJnaW4uXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJDYWxjcyh0aGlzLmVsZW1lbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFJlY2FsY3VsYXRlIGJib3guXG4gICAgICAgICAgICAgICAgICAgIGlmIChyQ29tcGxleCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ggPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICAgICAgICAgICAgICBleCA9IE1hdGgubWF4KDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN5ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgICAgICAgICAgICAgICAgZXkgPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzeCA9IHIucHg7XG4gICAgICAgICAgICAgICAgICAgICAgICBleCA9IHIucHggKyByLnRhICogYmJveFc7XG4gICAgICAgICAgICAgICAgICAgICAgICBzeSA9IHIucHk7XG4gICAgICAgICAgICAgICAgICAgICAgICBleSA9IHIucHkgKyByLnRkICogYmJveEg7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGltc1Vua25vd24gJiYgKHJDb21wbGV4IHx8IHRoaXMuX2xvY2FsVGEgPCAxIHx8IHRoaXMuX2xvY2FsVGIgPCAxKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbnggPSB0aGlzLl94ICogcHIudGEgKyB0aGlzLl95ICogcHIudGIgKyBwci5weDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG55ID0gdGhpcy5feCAqIHByLnRjICsgdGhpcy5feSAqIHByLnRkICsgcHIucHk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobnggPCBzeCkgc3ggPSBueDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChueSA8IHN5KSBzeSA9IG55O1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG54ID4gZXgpIGV4ID0gbng7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobnkgPiBleSkgZXkgPSBueTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3BhcmVudC5fb3V0T2ZCb3VuZHMgPT09IDIpIHtcbiAgICAgICAgICAgICAgICAvLyBJbmhlcml0IHBhcmVudCBvdXQgb2YgYm91bmRzbmVzcy5cbiAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDI7XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2Rpc2FibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChyZWNhbGMgJiA2KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFJlY2hlY2sgaWYgZWxlbWVudCBpcyBvdXQtb2YtYm91bmRzIChhbGwgc2V0dGluZ3MgdGhhdCBhZmZlY3QgdGhpcyBzaG91bGQgZW5hYmxlIHJlY2FsYyBiaXQgMiBvciA0KS5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAwO1xuICAgICAgICAgICAgICAgICAgICBsZXQgd2l0aGluTWFyZ2luID0gdHJ1ZTtcblxuICAgICAgICAgICAgICAgICAgICAvLyBPZmZzY3JlZW5zIGFyZSBhbHdheXMgcmVuZGVyZWQgYXMgbG9uZyBhcyB0aGUgcGFyZW50IGlzIHdpdGhpbiBib3VuZHMuXG4gICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCB8fCAhdGhpcy5fdGV4dHVyaXplciB8fCAhdGhpcy5fdGV4dHVyaXplci5yZW5kZXJPZmZzY3JlZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zY2lzc29yICYmICh0aGlzLl9zY2lzc29yWzJdIDw9IDAgfHwgdGhpcy5fc2Npc3NvclszXSA8PSAwKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEVtcHR5IHNjaXNzb3IgYXJlYS5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDI7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFVzZSBiYm94IHRvIGNoZWNrIG91dC1vZi1ib3VuZG5lc3MuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCh0aGlzLl9zY2lzc29yWzBdID4gZXgpIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICh0aGlzLl9zY2lzc29yWzFdID4gZXkpIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzeCA+ICh0aGlzLl9zY2lzc29yWzBdICsgdGhpcy5fc2Npc3NvclsyXSkpIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzeSA+ICh0aGlzLl9zY2lzc29yWzFdICsgdGhpcy5fc2Npc3NvclszXSkpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fb3V0T2ZCb3VuZHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NsaXBwaW5nIHx8IHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSB8fCAodGhpcy5fY2xpcGJveCAmJiAoYmJveFcgJiYgYmJveEgpKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICB3aXRoaW5NYXJnaW4gPSAodGhpcy5fb3V0T2ZCb3VuZHMgPT09IDApO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF3aXRoaW5NYXJnaW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBSZS10ZXN0LCBub3cgd2l0aCBtYXJnaW5zLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWNCb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aGluTWFyZ2luID0gISgoZXggPCB0aGlzLl9zY2lzc29yWzBdIC0gdGhpcy5fcmVjQm91bmRzTWFyZ2luWzJdKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGV5IDwgdGhpcy5fc2Npc3NvclsxXSAtIHRoaXMuX3JlY0JvdW5kc01hcmdpblszXSkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzeCA+IHRoaXMuX3NjaXNzb3JbMF0gKyB0aGlzLl9zY2lzc29yWzJdICsgdGhpcy5fcmVjQm91bmRzTWFyZ2luWzBdKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN5ID4gdGhpcy5fc2Npc3NvclsxXSArIHRoaXMuX3NjaXNzb3JbM10gKyB0aGlzLl9yZWNCb3VuZHNNYXJnaW5bMV0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoaW5NYXJnaW4gPSAhKChleCA8IHRoaXMuX3NjaXNzb3JbMF0gLSAxMDApIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZXkgPCB0aGlzLl9zY2lzc29yWzFdIC0gMTAwKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN4ID4gdGhpcy5fc2Npc3NvclswXSArIHRoaXMuX3NjaXNzb3JbMl0gKyAxMDApIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3kgPiB0aGlzLl9zY2lzc29yWzFdICsgdGhpcy5fc2Npc3NvclszXSArIDEwMCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod2l0aGluTWFyZ2luICYmIHRoaXMuX291dE9mQm91bmRzID09PSAyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENoaWxkcmVuIG11c3QgYmUgdmlzaXRlZCBiZWNhdXNlIHRoZXkgbWF5IGNvbnRhaW4gZWxlbWVudHMgdGhhdCBhcmUgd2l0aGluIG1hcmdpbiwgc28gbXVzdCBiZSB2aXNpYmxlLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbiAhPT0gd2l0aGluTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gPSB3aXRoaW5NYXJnaW47XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUaGlzIG1heSB1cGRhdGUgdGhpbmdzICh0eExvYWRlZCBldmVudHMpIGluIHRoZSBlbGVtZW50IGl0c2VsZiwgYnV0IGFsc28gaW4gZGVzY2VuZGFudHMgYW5kIGFuY2VzdG9ycy5cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENoYW5nZXMgaW4gYW5jZXN0b3JzIHNob3VsZCBiZSBleGVjdXRlZCBkdXJpbmcgdGhlIG5leHQgY2FsbCBvZiB0aGUg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ICAgICAgICAgICAgICAgICB0aGlzLl9yZWNhbGMgPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZW5hYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcmVjYWxjKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgZWxlbWVudCBuZWVkcyB0byBiZSByZS11cGRhdGVkIG5vdywgYmVjYXVzZSB3ZSB3YW50IHRoZSBkaW1lbnNpb25zIChhbmQgb3RoZXIgY2hhbmdlcykgdG8gYmUgdXBkYXRlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudXBkYXRlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVjYWxjID0gcmVjYWxjO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2Rpc2FibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIC8vIFNldCB2aWV3cG9ydCBuZWNlc3NhcnkgZm9yIGNoaWxkcmVuIHNjaXNzb3IgY2FsY3VsYXRpb24uXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3ZpZXdwb3J0KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0WzJdID0gYmJveFc7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0WzNdID0gYmJveEg7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdmlld3BvcnQgPSBbMCwgMCwgYmJveFcsIGJib3hIXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEZpbHRlciBvdXQgYml0cyB0aGF0IHNob3VsZCBub3QgYmUgY29waWVkIHRvIHRoZSBjaGlsZHJlbiAoY3VycmVudGx5IGFsbCBhcmUpLlxuICAgICAgICAgICAgdGhpcy5fcFJlY2FsYyA9ICh0aGlzLl9yZWNhbGMgJiAxMzUpO1xuXG4gICAgICAgICAgICAvLyBDbGVhciBmbGFncyBzbyB0aGF0IGZ1dHVyZSB1cGRhdGVzIGFyZSBwcm9wZXJseSBkZXRlY3RlZC5cbiAgICAgICAgICAgIHRoaXMuX3JlY2FsYyA9IDA7XG4gICAgICAgICAgICB0aGlzLl9oYXNVcGRhdGVzID0gZmFsc2U7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9vdXRPZkJvdW5kcyA8IDIpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl93b3JsZENvbnRleHQuaXNJZGVudGl0eSgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBPcHRpbWl6YXRpb24uXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBUaGUgd29ybGQgY29udGV4dCBpcyBhbHJlYWR5IGlkZW50aXR5OiB1c2UgdGhlIHdvcmxkIGNvbnRleHQgYXMgcmVuZGVyIGNvbnRleHQgdG8gcHJldmVudHMgdGhlXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBhbmNlc3RvcnMgZnJvbSBoYXZpbmcgdG8gdXBkYXRlIHRoZSByZW5kZXIgY29udGV4dC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBUZW1wb3JhcmlseSByZXBsYWNlIHRoZSByZW5kZXIgY29vcmQgYXR0cmlicyBieSB0aGUgaWRlbnRpdHkgbWF0cml4LlxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGhpcyBhbGxvd3MgdGhlIGNoaWxkcmVuIHRvIGNhbGN1bGF0ZSB0aGUgcmVuZGVyIGNvbnRleHQuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gRWxlbWVudENvcmVDb250ZXh0LklERU5USVRZO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbltpXS5faGFzVXBkYXRlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBNYWtlIHN1cmUgd2UgZG9uJ3QgbG9zZSB0aGUgJ2luaGVyaXRlZCcgdXBkYXRlcy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS5fcmVjYWxjIHw9IHRoaXMuX3BSZWNhbGM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlT3V0T2ZCb3VuZHMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJVcGRhdGUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vbkFmdGVyVXBkYXRlKHRoaXMuZWxlbWVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID09PSAtMSB8fCB0aGlzLl91cGRhdGVUcmVlT3JkZXIgPj0gdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyKSB7XG4gICAgICAgICAgICAgICAgLy8gSWYgbmV3IHRyZWUgb3JkZXIgZG9lcyBub3QgaW50ZXJmZXJlIHdpdGggdGhlIGN1cnJlbnQgKGdhcHMgYWxsb3dlZCkgdGhlcmUncyBubyBuZWVkIHRvIHRyYXZlcnNlIHRoZSBicmFuY2guXG4gICAgICAgICAgICAgICAgdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID0gLTE7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlVHJlZU9yZGVyKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfYXBwbHlSZWxhdGl2ZURpbUZ1bmNzKCkge1xuICAgICAgICBpZiAodGhpcy5fb3B0RmxhZ3MgJiAxKSB7XG4gICAgICAgICAgICBjb25zdCB4ID0gdGhpcy5fZnVuY1godGhpcy5fcGFyZW50LncpO1xuICAgICAgICAgICAgaWYgKHggIT09IHRoaXMuX3gpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9sb2NhbFB4ICs9ICh4IC0gdGhpcy5feCk7XG4gICAgICAgICAgICAgICAgdGhpcy5feCA9IHg7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX29wdEZsYWdzICYgMikge1xuICAgICAgICAgICAgY29uc3QgeSA9IHRoaXMuX2Z1bmNZKHRoaXMuX3BhcmVudC5oKTtcbiAgICAgICAgICAgIGlmICh5ICE9PSB0aGlzLl95KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbG9jYWxQeSArPSAoeSAtIHRoaXMuX3kpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3kgPSB5O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGNoYW5nZWREaW1zID0gZmFsc2U7XG4gICAgICAgIGlmICh0aGlzLl9vcHRGbGFncyAmIDQpIHtcbiAgICAgICAgICAgIGNvbnN0IHcgPSB0aGlzLl9mdW5jVyh0aGlzLl9wYXJlbnQudyk7XG4gICAgICAgICAgICBpZiAodyAhPT0gdGhpcy5fdykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3cgPSB3O1xuICAgICAgICAgICAgICAgIGNoYW5nZWREaW1zID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fb3B0RmxhZ3MgJiA4KSB7XG4gICAgICAgICAgICBjb25zdCBoID0gdGhpcy5fZnVuY0godGhpcy5fcGFyZW50LmgpO1xuICAgICAgICAgICAgaWYgKGggIT09IHRoaXMuX2gpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9oID0gaDtcbiAgICAgICAgICAgICAgICBjaGFuZ2VkRGltcyA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY2hhbmdlZERpbXMpIHtcbiAgICAgICAgICAgIC8vIFJlY2FsYyBtb3VudCwgc2NhbGUgcG9zaXRpb24uXG4gICAgICAgICAgICB0aGlzLl9yZWNhbGNMb2NhbFRyYW5zbGF0ZSgpO1xuXG4gICAgICAgICAgICB0aGlzLmVsZW1lbnQub25EaW1lbnNpb25zQ2hhbmdlZCh0aGlzLl93LCB0aGlzLl9oKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHVwZGF0ZU91dE9mQm91bmRzKCkge1xuICAgICAgICAvLyBQcm9wYWdhdGUgb3V0T2ZCb3VuZHMgZmxhZyB0byBkZXNjZW5kYW50cyAobmVjZXNzYXJ5IGJlY2F1c2Ugb2Ygei1pbmRleGluZykuXG4gICAgICAgIC8vIEludmlzaWJsZSBlbGVtZW50cyBhcmUgbm90IGRyYXduIGFueXdheS4gV2hlbiBhbHBoYSBpcyB1cGRhdGVkLCBzbyB3aWxsIF9vdXRPZkJvdW5kcy5cbiAgICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzICE9PSAyICYmIHRoaXMuX3JlbmRlckNvbnRleHQuYWxwaGEgPiAwKSB7XG5cbiAgICAgICAgICAgIC8vIEluaGVyaXQgcGFyZW50IG91dCBvZiBib3VuZHNuZXNzLlxuICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fd2l0aGluQm91bmRzTWFyZ2luID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9kaXNhYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZU91dE9mQm91bmRzKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgdXBkYXRlVHJlZU9yZGVyKCkge1xuICAgICAgICBpZiAodGhpcy5fbG9jYWxBbHBoYSAmJiAodGhpcy5fb3V0T2ZCb3VuZHMgIT09IDIpKSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVUcmVlT3JkZXIgPSB0aGlzLmN0eC51cGRhdGVUcmVlT3JkZXIrKztcblxuICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlVHJlZU9yZGVyKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3JlbmRlclNpbXBsZSgpIHtcbiAgICAgICAgdGhpcy5faGFzUmVuZGVyVXBkYXRlcyA9IDA7XG5cbiAgICAgICAgaWYgKHRoaXMuX3pTb3J0KSB7XG4gICAgICAgICAgICB0aGlzLnNvcnRaSW5kZXhlZENoaWxkcmVuKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fb3V0T2ZCb3VuZHMgPCAyICYmIHRoaXMuX3JlbmRlckNvbnRleHQuYWxwaGEpIHtcbiAgICAgICAgICAgIGxldCByZW5kZXJTdGF0ZSA9IHRoaXMucmVuZGVyU3RhdGU7XG5cbiAgICAgICAgICAgIGlmICgodGhpcy5fb3V0T2ZCb3VuZHMgPT09IDApICYmIHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UpIHtcbiAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTaGFkZXIodGhpcy5hY3RpdmVTaGFkZXIsIHRoaXMuX3NoYWRlck93bmVyKTtcbiAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTY2lzc29yKHRoaXMuX3NjaXNzb3IpO1xuICAgICAgICAgICAgICAgIHRoaXMucmVuZGVyU3RhdGUuYWRkUXVhZCh0aGlzKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gQWxzbyBhZGQgY2hpbGRyZW4gdG8gdGhlIFZCTy5cbiAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl96Q29udGV4dFVzYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW5baV0ucmVuZGVyKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuW2ldLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiB6SW5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uZGVyQ29udGV4dC5hbHBoYSkge1xuICAgICAgICAgICAgbGV0IHJlbmRlclN0YXRlID0gdGhpcy5yZW5kZXJTdGF0ZTtcblxuICAgICAgICAgICAgbGV0IG11c3RSZW5kZXJDaGlsZHJlbiA9IHRydWU7XG4gICAgICAgICAgICBsZXQgcmVuZGVyVGV4dHVyZUluZm87XG4gICAgICAgICAgICBsZXQgcHJldlJlbmRlclRleHR1cmVJbmZvO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl93ID09PSAwIHx8IHRoaXMuX2ggPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gSWdub3JlIHRoaXMgYnJhbmNoIGFuZCBkb24ndCBkcmF3IGFueXRoaW5nLlxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5fdGV4dHVyaXplci5oYXNSZW5kZXJUZXh0dXJlKCkgfHwgKGhhc1JlbmRlclVwZGF0ZXMgPj0gMykpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gVGVsbCB0aGUgcmVuZGVyZXIgd2UncmUgcmVuZGVyaW5nIGEgcmVuZGVyVG9UZXh0dXJlIGVsZW1lbnQgaW4gdGhpcyBmcmFtZVxuICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZW5kZXJUb1RleHR1cmVDb3VudCsrO1xuICAgICAgICAgICAgICAgICAgICAvLyBTd2l0Y2ggdG8gZGVmYXVsdCBzaGFkZXIgZm9yIGJ1aWxkaW5nIHVwIHRoZSByZW5kZXIgdGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2hhZGVyKHJlbmRlclN0YXRlLmRlZmF1bHRTaGFkZXIsIHRoaXMpO1xuXG4gICAgICAgICAgICAgICAgICAgIHByZXZSZW5kZXJUZXh0dXJlSW5mbyA9IHJlbmRlclN0YXRlLnJlbmRlclRleHR1cmVJbmZvO1xuXG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclRleHR1cmVJbmZvID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgbmF0aXZlVGV4dHVyZTogbnVsbCxcbiAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldDogMCwgIC8vIFNldCBieSBDb3JlUmVuZGVyU3RhdGUuXG4gICAgICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLl93LFxuICAgICAgICAgICAgICAgICAgICAgICAgaDogdGhpcy5faCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGVtcHR5OiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJlZDogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmU6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FjaGU6IGZhbHNlXG4gICAgICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3RleHR1cml6ZXIuaGFzUmVzdWx0VGV4dHVyZSgpIHx8ICghcmVuZGVyU3RhdGUuaXNDYWNoaW5nVGV4dHVyaXplciAmJiAoaGFzUmVuZGVyVXBkYXRlcyA8IDMpKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLyoqXG4gICAgICAgICAgICAgICAgICAgICAgICAgKiBXZSBkb24ndCBhbHdheXMgY2FjaGUgcmVuZGVyIHRleHR1cmVzLlxuICAgICAgICAgICAgICAgICAgICAgICAgICpcbiAgICAgICAgICAgICAgICAgICAgICAgICAqIFRoZSBydWxlIGlzLCB0aGF0IGNhY2hpbmcgZm9yIGEgc3BlY2lmaWMgcmVuZGVyIHRleHR1cmUgaXMgb25seSBlbmFibGVkIGlmOlxuICAgICAgICAgICAgICAgICAgICAgICAgICogLSBUaGVyZSBpcyBhIHJlc3VsdCB0ZXh0dXJlIHRvIGJlIHVwZGF0ZWQuXG4gICAgICAgICAgICAgICAgIC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YXJlIFJUVCB0aGlzIHdpbGwgaGF2ZSBhIHZlcnlcbiAgICAgICAgICAgICAgICAgICAgICAgICAqIG5vdGljYWJsZSBlZmZlY3Qgb24gcGVyZm9ybWFuY2UgYXMgbGVzcyByZW5kZXIgdGV4dHVyZXMgbmVlZCB0byBiZSBhbGxvY2F0ZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICAgKi9cbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlclRleHR1cmVJbmZvLmNhY2hlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLmlzQ2FjaGluZ1RleHR1cml6ZXIgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLmhhc1Jlc3VsdFRleHR1cmUoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gV2UgY2FuIGFscmVhZHkgcmVsZWFzZSB0aGUgY3VycmVudCB0ZXh0dXJlIHRvIHRoZSBwb29sLCBhcyBpdCB3aWxsIGJlIHJlYnVpbGQgYW55d2F5LlxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gSW4gY2FzZSBvZiBtdWx0aXBsZSBsYXllcnMgb2YgJ2ZpbHRlcmluZycsIHRoaXMgbWF5IHNhdmUgdXMgZnJvbSBoYXZpbmcgdG8gY3JlYXRlIG9uZVxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gIHJlbmRlci10by10ZXh0dXJlIGxheWVyLlxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gTm90aWNlIHRoYXQgd2UgZG9uJ3QgZG8gdGhpcyB3aGVuIHRoZXJlIGlzIGEgcmVzdWx0IHRleHR1cmUsIGFzIGFueSBvdGhlciBlbGVtZW50IG1heSByZWx5IG9uXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyAgdGhhdCByZXN1bHQgdGV4dHVyZSBiZWluZyBmaWxsZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnJlbGVhc2VSZW5kZXJUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRSZW5kZXJUZXh0dXJlSW5mbyhyZW5kZXJUZXh0dXJlSW5mbyk7XG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNjaXNzb3IobnVsbCk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcblxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gVXNlIGFuIGlkZW50aXR5IGNvbnRleHQgZm9yIGRyYXdpbmcgdGhlIGRpc3BsYXllZCB0ZXh0dXJlIHRvIHRoZSByZW5kZXIgdGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBFbGVtZW50Q29yZUNvbnRleHQuSURFTlRJVFk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEFkZCBkaXNwbGF5ZWQgdGV4dHVyZSBzb3VyY2UgaW4gbG9jYWwgY29vcmRpbmF0ZXMuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlbmRlclN0YXRlLmFkZFF1YWQodGhpcyk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSByO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbXVzdFJlbmRlckNoaWxkcmVuID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAoKHRoaXMuX291dE9mQm91bmRzID09PSAwKSAmJiB0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNoYWRlcih0aGlzLmFjdGl2ZVNoYWRlciwgdGhpcy5fc2hhZGVyT3duZXIpO1xuICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTY2lzc29yKHRoaXMuX3NjaXNzb3IpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJlbmRlclN0YXRlLmFkZFF1YWQodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBBbHNvIGFkZCBjaGlsZHJlbiB0byB0aGUgVkJPLlxuICAgICAgICAgICAgaWYgKG11c3RSZW5kZXJDaGlsZHJlbiAmJiB0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl96Q29udGV4dFVzYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW5baV0ucmVuZGVyKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuW2ldLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiB6SW5kZXggaXMgc2V0LCB0aGlzIGl0ZW0gYWxyZWFkeSBiZWxvbmdzIHRvIGEgekluZGV4ZWRDaGlsZHJlbiBhcnJheSBpbiBvbmUgb2YgdGhlIGFuY2VzdG9ycy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS5yZW5kZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIGxldCB1cGRhdGVSZXN1bHRUZXh0dXJlID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgaWYgKG11c3RSZW5kZXJDaGlsZHJlbikge1xuICAgICAgICAgICAgICAgICAgICAvLyBGaW5pc2hlZCByZWZyZXNoaW5nIHJlbmRlclRleHR1cmUuXG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLmZpbmlzaGVkUmVuZGVyVGV4dHVyZSgpO1xuXG4gICAgICAgICAgICAgICAgICAgIC8vIElmIG5vdGhpbmcgd2FzIHJlbmRlcmVkLCB3ZSBzdG9yZSBhIGZsYWcgaW4gdGhlIHRleHR1cml6ZXIgYW5kIHByZXZlbnQgdW5uZWNlc3NhcnlcbiAgICAgICAgICAgICAgICAgICAgLy8gIHJlbmRlci10by10ZXh0dXJlIGFuZCBmaWx0ZXJpbmcuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIuZW1wdHkgPSByZW5kZXJUZXh0dXJlSW5mby5lbXB0eTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAocmVuZGVyVGV4dHVyZUluZm8uZW1wdHkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFdlIGlnbm9yZSBlbXB0eSByZW5kZXIgdGV4dHVyZXMgYW5kIGRvIG5vdCBkcmF3IHRoZSBmaW5hbCBxdWFkLlxuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBUaGUgZm9sbG93aW5nIGNsZWFucyB1cCBtZW1vcnkgYW5kIGVuZm9yY2VzIHRoYXQgdGhlIHJlc3VsdCB0ZXh0dXJlIGlzIGFsc28gY2xlYXJlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZVJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChyZW5kZXJUZXh0dXJlSW5mby5uYXRpdmVUZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiBuYXRpdmVUZXh0dXJlIGlzIHNldCwgd2UgY2FuIHJldXNlIHRoYXQgZGlyZWN0bHkgaW5zdGVhZCBvZiBjcmVhdGluZyBhIG5ldyByZW5kZXIgdGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmV1c2VUZXh0dXJlQXNSZW5kZXJUZXh0dXJlKHJlbmRlclRleHR1cmVJbmZvLm5hdGl2ZVRleHR1cmUpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJUZXh0dXJlSW5mby5pZ25vcmUgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3RleHR1cml6ZXIucmVuZGVyVGV4dHVyZVJldXNlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFF1YWQgb3BlcmF0aW9ucyBtdXN0IGJlIHdyaXR0ZW4gdG8gYSByZW5kZXIgdGV4dHVyZSBhY3R1YWxseSBvd25lZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnJlbGVhc2VSZW5kZXJUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBKdXN0IGNyZWF0ZSB0aGUgcmVuZGVyIHRleHR1cmUuXG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJUZXh0dXJlSW5mby5uYXRpdmVUZXh0dXJlID0gdGhpcy5fdGV4dHVyaXplci5nZXRSZW5kZXJUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAvLyBSZXN0b3JlIHRoZSBwYXJlbnQncyByZW5kZXIgdGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0UmVuZGVyVGV4dHVyZUluZm8ocHJldlJlbmRlclRleHR1cmVJbmZvKTtcblxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZXN1bHRUZXh0dXJlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIuZW1wdHkpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdFRleHR1cmUgPSB0aGlzLl90ZXh0dXJpemVyLmdldFJlc3VsdFRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHVwZGF0ZVJlc3VsdFRleHR1cmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRUZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gTG9nZ2luZyB0aGUgdXBkYXRlIGZyYW1lIGNhbiBiZSBoYW5keSBmb3IgdXNlcmxhbmQuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0VGV4dHVyZS51cGRhdGUgPSByZW5kZXJTdGF0ZS5zdGFnZS5mcmFtZUNvdW50ZXI7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnVwZGF0ZVJlc3VsdFRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5yZW5kZXJPZmZzY3JlZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFJlbmRlciByZXN1bHQgdGV4dHVyZSB0byB0aGUgYWN0dWFsIHJlbmRlciB0YXJnZXQuXG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTaGFkZXIodGhpcy5hY3RpdmVTaGFkZXIsIHRoaXMuX3NoYWRlck93bmVyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNjaXNzb3IodGhpcy5fc2Npc3Nvcik7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIG5vIHJlbmRlciB0ZXh0dXJlIGluZm8gaXMgc2V0LCB0aGUgY2FjaGUgY2FuIGJlIHJldXNlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhY2hlID0gIXJlbmRlclRleHR1cmVJbmZvIHx8IHJlbmRlclRleHR1cmVJbmZvLmNhY2hlO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRUZXh0dXJpemVyKHRoaXMuX3RleHR1cml6ZXIsIGNhY2hlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0YXNoVGV4Q29vcmRzKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIuY29sb3JpemUpIHRoaXMuX3N0YXNoQ29sb3JzKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlbmRlclN0YXRlLmFkZFF1YWQodGhpcywgdHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIuY29sb3JpemUpIHRoaXMuX3Vuc3Rhc2hDb2xvcnMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Vuc3Rhc2hUZXhDb29yZHMoKTtcbiAgICAgICAgICAgICAgIC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W4gbWVyZ2Utc29ydGluZyBhbHNvIGNoZWNrIGZvciBkb3VibGVzLlxuICAgICAgICAgKiAtIGlmIHRoZSBvbGQgb25lIGlzIGxhcmdlciAoaW4gc2l6ZSkgdGhhbiBpdCBzaG91bGQgYmUsIHNwbGljZSBvZmYgdGhlIGVuZCBvZiB0aGUgYXJyYXkuXG4gICAgICAgICAqL1xuXG4gICAgICAgIGNvbnN0IG4gPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuLmxlbmd0aDtcbiAgICAgICAgbGV0IHB0ciA9IDA7XG4gICAgICAgIGNvbnN0IGEgPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuO1xuXG4gICAgICAgIC8vIE5vdGljZSB0aGF0IGl0ZW1zIG1heSBvY2N1ciBtdWx0aXBsZSB0aW1lcyBkdWUgdG8gei1pbmRleCBjaGFuZ2luZy5cbiAgICAgICAgY29uc3QgYiA9IFtdO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKGFbaV0uX3pQYXJlbnQgPT09IHRoaXMpIHtcbiAgICAgICAgICAgICAgICBpZiAoYVtpXS5fekluZGV4UmVzb3J0KSB7XG4gICAgICAgICAgICAgICAgICAgIGIucHVzaChhW2ldKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpZiAocHRyICE9PSBpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBhW3B0cl0gPSBhW2ldO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHB0cisrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IG0gPSBiLmxlbmd0aDtcbiAgICAgICAgaWYgKG0pIHtcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbTsgaisrKSB7XG4gICAgICAgICAgICAgICAgYltqXS5fekluZGV4UmVzb3J0ID0gZmFsc2U7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGIuc29ydChFbGVtZW50Q29yZS5zb3J0WkluZGV4ZWRDaGlsZHJlbik7XG4gICAgICAgICAgICBjb25zdCBuID0gcHRyO1xuICAgICAgICAgICAgaWYgKCFuKSB7XG4gICAgICAgICAgICAgICAgcHRyID0gMDtcbiAgICAgICAgICAgICAgICBsZXQgaiA9IDA7XG4gICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBhW3B0cisrXSA9IGJbaisrXTtcbiAgICAgICAgICAgICAgICB9IHdoaWxlIChqIDwgbSk7XG5cbiAgICAgICAgICAgICAgICBpZiAoYS5sZW5ndGggPiBwdHIpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gU2xpY2Ugb2xkICh1bm5lY2Vzc2FyeSkgcGFydCBvZmYgYXJyYXkuXG4gICAgICAgICAgICAgICAgICAgIGEuc3BsaWNlKHB0cik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBhLnNwbGljZShuKTsgLy8gUmVtb3ZlIGl0ZW1zIHRoYXQgd2VyZSBzb3J0ZWQgaW4gYiBhcnJheSwgc28gdGhhdCB3ZSBjYW4gc29ydCBhXG4rICAgICAgICAgICAgICAgLy8gQmV3YXJlIHRoYXQgdGhlIGZ1bmN0aW9uIHBhc3NlZCBoZXJlIHRvIEFycmF5LnNvcnQgbXVzdCBiZSBzdGFibGVcbisgICAgICAgICAgICAgICBhLnNvcnQoRWxlbWVudENvcmUuc29ydFpJbmRleGVkQ2hpbGRyZW4pOyAvLyBOZWVkZWQgYmVjYXVzZSBpdGVtcyB3aXRoIHNhbWUgX3pJbmRleCBtYXkgbm90IGJlIG9yZGVyZWQgYnkgX3VwZGF0ZVRyZWVPcmRlclxuICAgICAgICAgICAgICAgIC8vIE1lcmdlLXNvcnQgYXJyYXlzO1xuICAgICAgICAgICAgICAgIHB0ciA9IDA7XG4gICAgICAgICAgICAgICAgbGV0IGkgPSAwO1xuICAgICAgICAgICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgICAgICAgICBjb25zdCBtZXJnZVJlc3VsdCA9IFtdO1xuICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdiA9IChhW2ldLl96SW5kZXggPT09IGJbal0uX3pJbmRleCA/IGFbaV0uX3VwZGF0ZVRyZWVPcmRlciAtIGJbal0uX3VwZGF0ZVRyZWVPcmRlciA6IGFbaV0uX3pJbmRleCAtIGJbal0uX3pJbmRleCk7XG5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYWRkID0gdiA+IDAgPyBiW2orK10gOiBhW2krK107XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCAobWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmIChpID49IG4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZGQgPSBiW2orK107XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCAobWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGogPCBtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGogPj0gbSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFkZCA9IGFbaSsrXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHRyID09PSAwIHx8IChtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoaSA8IG4pO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IHdoaWxlICh0cnVlKTtcblxuICAgICAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4gPSBtZXJnZVJlc3VsdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChhLmxlbmd0aCA+IHB0cikge1xuICAgICAgICAgICAgICAgIC8vIFNsaWNlIG9sZCAodW5uZWNlc3NhcnkpIHBhcnQgb2ZmIGFycmF5LlxuICAgICAgICAgICAgICAgIGEuc3BsaWNlKHB0cik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuICAgIH07XG5cbiAgICBnZXQgbG9jYWxUYSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGE7XG4gICAgfTtcblxuICAgIGdldCBsb2NhbFRiKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbG9jYWxUYjtcbiAgICB9O1xuXG4gICAgZ2V0IGxvY2FsVGMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRjO1xuICAgIH07XG5cbiAgICBnZXQgbG9jYWxUZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGQ7XG4gICAgfTtcblxuICAgIGdldCBlbGVtZW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZWxlbWVudDtcbiAgICB9XG5cbiAgICBnZXQgcmVuZGVyVXBkYXRlcygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2hhc1JlbmRlclVwZGF0ZXM7XG4gICAgfVxuXG4gICAgZ2V0IHRleHR1cml6ZXIoKSB7XG4gICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplcikge1xuICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplciA9IG5ldyBFbGVtZW50VGV4dHVyaXplcih0aGlzKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5fdGV4dHVyaXplcjtcbiAgICB9XG5cbiAgICBnZXRDb3JuZXJQb2ludHMoKSB7XG4gICAgICAgIGxldCB3ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuXG4gICAgICAgIHJldHVybiBbXG4gICAgICAgICAgICB3LnB4LFxuICAgICAgICAgICAgdy5weSxcbiAgICAgICAgICAgIHcucHggKyB0aGlzLl93ICogdy50YSxcbiAgICAgICAgICAgIHcucHkgKyB0aGlzLl93ICogdy50YyxcbiAgICAgICAgICAgIHcucHggKyB0aGlzLl93ICogdy50YSArIHRoaXMuX2ggKiB3LnRiLFxuICAgICAgICAgICAgdy5weSArIHRoaXMuX3cgKiB3LnRjICsgdGhpcy5faCAqIHcudGQsXG4gICAgICAgICAgICB3LnB4ICsgdGhpcy5faCAqIHcudGIsXG4gICAgICAgICAgICB3LnB5ICsgdGhpcy5faCAqIHcudGRcbiAgICAgICAgXTtcbiAgICB9O1xuXG4gICAgZ2V0UmVuZGVyVGV4dHVyZUNvb3JkcyhyZWxYLCByZWxZKSB7XG4gICAgICAgIGxldCByID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgIHIucHggKyByLnRhICogcmVsWCArIHIudGIgKiByZWxZLFxuICAgICAgICAgICAgci5weSArIHIudGMgKiByZWxYICsgci50ZCAqIHJlbFlcbiAgICAgICAgXTtcbiAgICB9XG5cbiAgICBnZXRBYnNvbHV0ZUNvb3JkcyhyZWxYLCByZWxZKSB7XG4gICAgICAgIGxldCB3ID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgIHcucHggKyB3LnRhICogcmVsWCArIHcudGIgKiByZWxZLFxuICAgICAgICAgICAgdy5weSArIHcudGMgKiByZWxYICsgdy50ZCAqIHJlbFlcbiAgICAgICAgXTtcbiAgICB9XG5cbiAgICBjb2xsZWN0QXRDb29yZCh4LCB5LCBjaGlsZHJlbikge1xuICAgICAgICAvLyByZXR1cm4gd2hlbiBicmFuY2ggaXMgaGlkZGVuXG4gICAgICAgIGlmICh0aGlzLl9yZW5kZXJDb250ZXh0LmFscGhhID09PSAwKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5pbkJvdW5kKHgsIHkpKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fc2Npc3Nvcikge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmluU2Npc3NvcigpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkcmVuLnB1c2godGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjaGlsZHJlbi5wdXNoKHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICBjb25zdCBqID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBqOyBpKyspIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS5jb2xsZWN0QXRDb29yZC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EVsZW1lbnRDb3JlQ29udGV4dCB7XG5cbiAgICBjb25zdHJ1Y3RvcigpIHtcbiAgICAgICAgdGhpcy5hbHBoYSA9IDE7XG5cbiAgICAgICAgdGhpcy5weCA9IDA7XG4gICAgICAgIHRoaXMucHkgPSAwO1xuXG4gICAgICAgIHRoaXMudGEgPSAxO1xuICAgICAgICB0aGlzLnRiID0gMDtcbiAgICAgICAgdGhpcy50YyA9IDA7XG4gICAgICAgIHRoaXMudGQgPSAxO1xuICAgIH1cblxuICAgIGlzSWRlbnRpdHkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmFscGhhID09PSAxICYmXG4gICAgICAgICAgICB0aGlzLnB4ID09PSAwICYmXG4gICAgICAgICAgICB0aGlzLnB5ID09PSAwICYmXG4gICAgICAgICAgICB0aGlzLnRhID09PSAxICYmXG4gICAgICAgICAgICB0aGlzLnRiID09PSAwICYmXG4gICAgICAgICAgICB0aGlzLnRjID09PSAwICYmXG4gICAgICAgICAgICB0aGlzLnRkID09PSAxO1xuICAgIH1cblxuICAgIGlzU3F1YXJlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy50YiA9PT0gMCAmJiB0aGlzLnRjID09PSAwO1xuICAgIH1cblxufVxuXG5FbGVtZW50Q29yZUNvbnRleHQuSURFTlRJVFkgPSBuZXcgRWxlbWVudENvcmVDb250ZXh0KCk7XG5FbGVtZW50Q29yZS5zb3J0WkluZGV4ZWRDaGlsZHJlbiA9IGZ1bmN0aW9uIChhLCBiKSB7XG4gICAgcmV0dXJuIChhLl96SW5kZXggPT09IGIuX3pJbmRleCA/IGEuX3VwZGF0ZVRyZWVPcmRlciAtIGIuX3VwZGF0ZVRyZWVPcmRlciA6IGEuX3pJbmRleCAtIGIuX3pJbmRleCk7XG59O1xuXG5pbXBvcnQgRWxlbWVudFRleHR1cml6ZXIgZnJvbSBcIi4vRWxlbWVudFRleHR1cml6ZXIubWpzXCI7XG5pbXBvcnQgVXRpbHMgZnJvbSBcIi4uL1V0aWxzL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U0UtJykpIHtcbiAgICAgICAgICAvLyBQYXVzZSBpdFxuICAgICAgICAgIGxldCBwYXVzZSA9IHBocmFzZS5zcGxpdCgnUEFVU0UtJylbMV0gKiAxMDAwXG4gICAgICAgICAgaWYgKGlzTmFOKHBhdXNlKSkge1xuICAgICAgICAgICAgcGF1c2UgPSAwXG4gICAgICAgICAgfVxuICAgICAgICAgIGF3YWl0IGRlbGF5KHBhdXNlKVxuICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBwaHJhc2UgPT09ICdzdHJpbmcnICYmIHBocmFzZS5sZW5ndGgpIHtcbiAgICAgICAgICAvLyBTcGVhayBpdFxuICAgICAgICAgIGNvbnN0IHRvdGFsUmV0cmllcyA9IDNcbiAgICAgICAgICBsZXQgcmV0cmllc0xlZnQgPSB0b3RhbFJldHJpZXNcbiAgICAgICAgICB3aGlsZSAoYWN0aXZlICYmIHJldHJpZXNMZWZ0ID4gMCkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgYXdhaXQgc3BlYWsocGhyYXNlLCB1dHRlcmFuY2VzLCBsYW5nKVxuICAgICAgICAgICAgICByZXRyaWVzTGVmdCA9IDBcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIG5vLXVuZGVmXG4gICAgICAgICAgICAgIGlmIChlIGluc3RhbmNlb2YgU3BlZWNoU3ludGhlc2lzRXJyb3JFdmVudCkge1xuICAgICAgICAgICAgICAgIGlmIChlLmVycm9yID09PSAnbmV0d29yaycpIHtcbiAgICAgICAgICAgICAgICAgIHJldHJpZXNMZWZ0LS1cbiAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihgU3BlZWNoIHN5bnRoZXNpcyBuZXR3b3JrIGVycm9yLiBSZXRyaWVzIGxlZnQ6ICR7cmV0cmllc0xlZnR9YClcbiAgICAgICAgICAgICAgICAgIGF3YWl0IGRlbGF5KDUwMCA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iB0aW1lRXZlbnRzLm1pZFBvaW50ICYmIHZpZGVvRWwuY3VycmVudFRpbWUgPj0gdGltZUV2ZW50cy5taWRQb2ludCkge1xuICAgICAgICAgIGZpcmVPbkNvbnN1bWVyKCdNaWRQb2ludCcsIGFkKVxuICAgICAgICAgIGRlbGV0ZSB0aW1lRXZlbnRzLm1pZFBvaW50XG4gICAgICAgICAgc2VuZEJlYWNvbihhZC5jYWxsYmFja3MsICdtaWRQb2ludCcpXG4gICAgICAgIH1cbiAgICAgICAgaWYgKFxuICAgICAgICAgIHRpbWVFdmVudHMgJiZcbiAgICAgICAgICB0aW1lRXZlbnRzLnRoaXJkUXVhcnRpbGUgJiZcbiAgICAgICAgICB2aWRlb0VsLmN1cnJlbnRUaW1lID49IHRpbWVFdmVudHMudGhpcmRRdWFydGlsZVxuICAgICAgICApIHtcbiAgICAgICAgICBmaXJlT25Db25zdW1lcignVGhpcmRRdWFydGlsZScsIGFkKVxuICAgICAgICAgIGRlbGV0ZSB0aW1lRXZlbnRzLnRoaXJkUXVhcnRpbGVcbiAgICAgICAgICBzZW5kQmVhY29uKGFkLmNhbGxiYWNrcywgJ3RoaXJkUXVhcnRpbGUnKVxuICAgICAgICB9XG4gICAgICB9LFxuICAgICAgc3RhbGxlZCgpIHtcbiAgICAgICAgZmlyZU9uQ29uc3VtZXIoJ1N0YWxsZWQnLCBhZClcbiAgICAgICAgdGltZW91dCA9IHNldFRpbWVvdXQoKCkgPT4ge1xuICAgICAgICAgIGNsZWFudXAoKVxuICAgICAgICB9LCA1MDAwKSAvLyBtYWtlIHRpbWVvdXQgY29uZmlndXJhYmxlXG4gICAgICB9LFxuICAgICAgY2FucGxheSgpIHtcbiAgICAgICAgdGltZW91dCAmJiBjbGVhclRpbWVvdXQodGltZW91dClcbiAgICAgIH0sXG4gICAgICBlcnJvcigpIHtcbiAgICAgICAgZmlyZU9uQ29uc3VtZXIoJ0Vycm9yJywgYWQpXG4gICAgICAgIGNsZWFudXAoKVxuICAgICAgf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KVxuICAgIHJldHVybiBjYWxsYmFja3NbZXZlbnRdLnJlZHVjZSgocHJvbWlzZSwgdXJsKSA9PiB7XG4gICAgICByZXR1cm4gcHJvbWlzZS50aGVuKCgpID0+XG4gICAgICAgIGZldGNoKHVybClcbiAgICAgICAgICAvLyBhbHdheXMgcmVzb2x2ZSwgYWxzbyBpbiBjYXNlIG9mIGEgZmV0Y2ggZXJyb3IgKHNvIHdlIGRvbid0IGJsb2NrIGZpcmluZyB0aGUgcmVzdCBvZiB0aGUgYmVhY29ucyBmb3IgdGhpcyBldmVudClcbiAgICAgICAgICAvLyBub3RlOiBmb3IgZmV0Y2ggZmFpbGVkIGh0dHAgcmVzcG9uc2VzIGRvbid0IHRocm93IGFuIEVycm9yIDopXG4gICAgICAgICAgLnRoZW4ocmVzcG9uc2UgPT4ge1xuICAgICAgICAgICAgaWYgKHJlc3BvbnNlLnN0YXR1cyA9PT0gMjAwKSB7XG4gICAgICAgICAgICAgIGZpcmVPbkNvbnN1bWVyKCdCZWFjb24nICsgZXZlbnQgKyAnU2VudCcpXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBmaXJlT25Db25zdW1lcignQmVhY29uJyArIGV2ZW50ICsgJ0ZhaWxlZCcgKyByZXNwb25zZS5zdGF0dXMpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBQcm9taXNlLnJlc29sdmUobnVsbClcbiAgICAgICAgICB9KVxuICAgICAgICAgIC5jYXRjaCgoKSA9PiB7XG4gICAgICAgICAgICBQcm9taXNlLnJlc29sdmUobnVsbClcbiAgICAgICAgICB9KVxuICAgICAgKVxuICAgIH0sIFByb21pc2UucmVzb2x2ZShudWxsKSlcbiAgfSBlbHNlIHtcbiAgICBMb2cuaW5mbygnQWQnLCAnTm8gY2FsbGJhY2sgZm91bmQgZm9yICcgKyBldmVudClcbiAgfVxufVxuXG5jb25zdCBmaXJlT25Db25zdW1lciA9IChldmVudCwgYXJncykgPT4ge1xuICBpZiAoY29uc3VtZXIpIHtcbiAgICBjb25zdW1lci5maXJlKCckYWQnICsgZXZlbnQsIGFyZ3MpXG4gICAgY29uc3VtZXIuZmlyZSgnJGFkRXZlbnQnLCBldmVudCwgYXJncylcbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCB7XG4gIGdldChjb25maWcsIHZpZGVvUGxheWVyQ29uc3VtZXIpIHtcbiAgICBpZiAoY29uZmlnLmVuYWJsZWQgPT09IGZhbHNlKSB7XG4gICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKHtcbiAgICAgICAgcHJlcm9sbHMoKSB7XG4gICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSgpXG4gICAgICAgIH0sXG4gICAgICB9KVxuICAgIH1cbiAgICBjb25zdW1lciA9IHZpZGVvUGxheWVyQ29uc3VtZXJcblxuICAgIHJldHVybiBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHtcbiAgICAgIExvZy5pbmZvKCdBZCcsICdTdGFydGluZyBzZXNzaW9uJylcbiAgICAgIGdldEFkcyhjb25maWcpLnRoZW4oYWRzID0+IHtcbiAgICAgICAgTG9nLmluZm8oJ0FkJywgJ0FQSSByZXN1bHQnLCBhZHMpXG4gICAgICAgIHJlc29sdmUoe1xuICAgICAgICAgIHByZXJvbGxzKCkge1xuICAgICAgICAgICAgaWYgKGFkcy5wcmVyb2xsKSB7XG4gICAgICAgICAgICAgIHN0YXRlLmFjdGl2ZSA9IHRydWVcbiAgICAgICAgICAgICAgZmlyZU9uQ29uc3VtZXIoJ1ByZXJvbGxTbG90SW1wcmVzc2lvbicsIGFkcylcbiAgICAgICAgICAgICAgc2VuZEJlYWNvbihhZHMucHJlcm9sbC5jYWxsYmFja3MsICdzbG90SW1wcmVzc2lvbicpXG4gICAgICAgICAgICAgIHJldHVybiBwbGF5U2xvdChhZHMucHJlcm9sbC5hZHMpLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgIGZpcmVPbkNvbnN1bWVyKCdQcmVyb2xs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XG4gICAgMjUwOiAnUGxheVBhdXNlJyxcbiAgICAxOTE6ICdTZWFyY2gnLCAvLyBVc2UgXCIvXCIgZm9yIGtleWJvYXJkXG4gICAgNDA5OiAnU2VhcmNoJyxcbiAgfSxcbn1cblxuY29uc3QgY3VzdG9tRm9udEZhY2VzID0gW11cblxuY29uc3QgZm9udExvYWRlciA9IChmb250cywgc3RvcmUpID0+XG4gIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICBmb250c1xuICAgICAgLm1hcCgoeyBmYW1pbHksIHVybCwgdXJscywgZGVzY3JpcHRvcnMgfSkgPT4gKCkgPT4ge1xuICAgICAgICBjb25zdCBzcmMgPSB1cmxzXG4gICAgICAgICAgPyB1cmxzLm1hcCh1cmwgPT4ge1xuICAgICAgICAgICAgICByZXR1cm4gJ3VybCgnICsgdXJsICsgJyknXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIDogJ3VybCgnICsgdXJsICsgJyknXG4gICAgICAgIGNvbnN0IGZvbnRGYWNlID0gbmV3IEZvbnRGYWNlKGZhbWlseSwgc3JjLCBkZXNjcmlwdG9ycyB8fCB7fSlcbiAgICAgICAgc3RvcmUucHVzaChmb250RmFjZSlcbiAgICAgICAgTG9nLmluZm8oJ0xvYWRpbmcgZm9udCcsIGZhbWlseSlcbiAgICAgICAgZG9jdW1lbnQuZm9udHMuYWRkKGZvbnRGYWNlKVxuICAgICAgICByZXR1cm4gZm9udEZhY2UubG9hZCgpXG4gICAgICB9KVxuICAgICAgLnJlZHVjZSgocHJvbWlzZSwgbWV0aG9kKSA9PiB7XG4gICAgICAgIHJldHVybiBwcm9taXNlLnRoZW4oKCkgPT4gbWV0aG9kKCkpXG4gICAgICB9LCBQcm9taXNlLnJlc29sdmUobnVsbCkpXG4gICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgLmNhdGNoKHJlamVjdClcbiAgfSlcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24oQXBwLCBhcHBE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ICAgICAgIHJlZjogJ0FwcCcsXG4gICAgICAgICAgICB0eXBlOiBBcHAsXG4gICAgICAgICAgICB6SW5kZXg6IDEsXG4gICAgICAgICAgICBmb3JjZVpJbmRleENvbnRleHQ6ICEhcGxhdGZvcm1TZXR0aW5ncy5zaG93VmVyc2lvbiB8fCAhIXBsYXRmb3JtU2V0dGluZ3Muc2hvd0ZwcyxcbiAgICAgICAgICB9KVxuXG4gICAgICAgICAgdGhpcy5jaGlsZExpc3QuYShBcHBJbnN0YW5jZSlcblxuICAgICAgICAgIHRoaXMuX3JlZm9jdXMoKVxuXG4gICAgICAgICAgTG9nLmluZm8oJ0FwcCB2ZXJzaW9uJywgdGhpcy5jb25maWcudmVyc2lvbilcbiAgICAgICAgICBMb2cuaW5mbygnU0RLIHZlcnNpb24nLCBwYWNrYWdlSW5mby52ZXJzaW9uKVxuXG4gICAgICAgICAgaWYgKHBsYXRmb3JtU2V0dGluZ3Muc2hvd1ZlcnNpb24pIHtcbiAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoe1xuICAgICAgICAgICAgICByZWY6ICdWZXJzaW9uTGFiZWwnLFxuICAgICAgICAgICAgICB0eXBlOiBWZXJzaW9uTGFiZWwsXG4gICAgICAgICAgICAgIHZlcnNpb246IHRoaXMuY29uZmlnLnZlcnNpb24sXG4gICAgICAgICAgICAgIHNka1ZlcnNpb246IHBhY2thZ2VJbmZvLnZlcnNpb24sXG4gICAgICAgICAgICAgIHpJbmRleDogMSxcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKHBsYXRmb3JtU2V0dGluZ3Muc2hvd0Zwcykge1xuICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYSh7XG4gICAgICAgICAgICAgIHJlZjogJ0Zwc0NvdW50ZXInLFxuICAgICAgICAgICAgICB0eXBlOiBGcHNDb3VudGVyLFxuICAgICAgICAgICAgICB6SW5kZXg6IDEsXG4gICAgICAgICAgICB9KVxuICAgICA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tIGwgKiBzXG4gIH1cblxuICBpZiAobWF4ID4gMCkge1xuICAgIGggKj0gNi4wXG4gICAgY29uc3QgbWluID0gbCArIGwgLSBtYXhcbiAgICBjb25zdCBtaW5NYXggPSAobWF4IC0gbWluKSAvIG1heFxuICAgIGNvbnN0IHNleHRhbnQgPSBNYXRoLmZsb29yKGgpXG4gICAgY29uc3QgZnJhY3QgPSBoIC0gc2V4dGFudFxuICAgIGNvbnN0IG1pbk1heEZyYWN0ID0gbWF4ICogbWluTWF4ICogZnJhY3RcbiAgICBjb25zdCBtaWQxID0gbWluICsgbWluTWF4RnJhY3RcbiAgICBjb25zdCBtaWQyID0gbWF4IC0gbWluTWF4RnJhY3RcblxuICAgIGlmIChzZXh0YW50ID09PSAwKSB7XG4gICAgICByID0gbWF4XG4gICAgICBnID0gbWlkMVxuICAgICAgYiA9IG1pblxuICAgIH1cbiAgICBpZiAoc2V4dGFudCA9PT0gMSkge1xuICAgICAgciA9IG1pZDJcbiAgICAgIGcgPSBtYXhcbiAgICAgIGIgPSBtaW5cbiAgICB9XG4gICAgaWYgKHNleHRhbnQgPT09IDIpIHtcbiAgICAgIHIgPSBtaW5cbiAgICAgIGcgPSBtYXhcbiAgICAgIGIgPSBtaWQxXG4gICAgfVxuICAgIGlmIChzZXh0YW50ID09PSAzKSB7XG4gICAgICByID0gbWluXG4gICAgICBnID0gbWlkMlxuICAgICAgYiA9IG1heFxuICAgIH1cbiAgICBpZiAoc2V4dGFudCA9PT0gNCkge1xuICAgICAgciA9IG1pZDFcbiAgICAgIGcgPSBtaW5cbiAgICAgIGIgPSBtYXhcbiAgICB9XG4gICAgaWYgKHNleHRhbnQgPT09IDUpIHtcbiAgICAgIHIgPSBtYXhcbiAgICAgIGcgPSBtaW5cbiAgICAgIGIgPSBtaWQyXG4gICAgfVxuICB9XG4gIHJldHVybiBnZXRBcmdiTnVtYmVyKFtNYXRoLmZsb29yKHIgKiAyNTUpLCBNYXRoLmZsb29yKGcgKiAyNTUpLCBNYX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9MaWdodG5pbmcnXG5pbXBvcnQgU2V0dGluZ3MgZnJvbSAnLi4vU2V0dGluZ3MnXG5pbXBvcnQgTG9nIGZyb20gJy4uL0xvZydcbmV4cG9ydCBkZWZhdWx0IGNsYXNzIEZwc0luZGljYXRvciBleHRlbmRzIExpZ2h0bmluZy5Db21wb25lbnQge1xuICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgIHJldHVybiB7XG4gICAgICByZWN0OiB0cnVlLFxuICAgICAgY29sb3I6IDB4ZmZmZmZmZmYsXG4gICAgICB0ZXh0dXJlOiBMaWdodG5pbmcuVG9vbHMuZ2V0Um91bmRSZWN0KDgwLCA4MCwgNDApLFxuICAgICAgaDogODAsXG4gICAgICB3OiA4MCxcbiAgICAgIHg6IDEwMCxcbiAgICAgIHk6IDEwMCxcbiAgICAgIG1vdW50OiAxLFxuICAgICAgQmFja2dyb3VuZDoge1xuICAgICAgICB4OiAzLFxuICAgICAgICB5OiAzLFxuICAgICAgICB0ZXh0dXJlOiBMaWdodG5pbmcuVG9vbHMuZ2V0Um91bmRSZWN0KDcyLCA3MiwgMzYpLFxuICAgICAgICBjb2xvcjogMHhmZjAwODAwMCxcbiAgICAgIH0sXG4gICAgICBDb3VudGVyOiB7XG4gICAgICAgIHc6IHcgPT4gdyxcbiAgICAgICAgaDogaCA9PiBoLFxuICAgICAgICB5OiAxMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAzMixcbiAgICAgICAgICB0ZXh0QWxpZ246ICdjZW50ZXInLFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICAgIFRleHQ6IHtcbiAgICAgICAgdzogdyA9PiB3LFxuICAgICAgICBoOiBoID0+IGgsXG4gICAgICAgIHk6IDQ4LFxuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgZm9udFNpemU6IDE1LFxuICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgICAgdGV4dDogJ0ZQUycsXG4gICAg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wgcmVqZWN0KSA9PiB7XG4gICAgZmV0Y2hKc29uKGZpbGUpXG4gICAgICAudGhlbihqc29uID0+IHtcbiAgICAgICAgc2V0VHJhbnNsYXRpb25zKGpzb24pXG4gICAgICAgIC8vIHNldCBsYW5ndWFnZSAoZGlyZWN0bHkgb3IgaW4gYSBwcm9taXNlKVxuICAgICAgICB0eXBlb2YgbGFuZ3VhZ2UgPT09ICdvYmplY3QnICYmICd0aGVuJyBpbiBsYW5ndWFnZSAmJiB0eXBlb2YgbGFuZ3VhZ2UudGhlbiA9PT0gJ2Z1bmN0aW9uJ1xuICAgICAgICAgID8gbGFuZ3VhZ2VcbiAgICAgICAgICAgICAgLnRoZW4obGFuZyA9PlxuICAgICAgICAgICAgICAgIHNldExhbmd1YWdlKGxhbmcpXG4gICAgICAgICAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgICAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAuY2F0Y2goZSA9PiB7XG4gICAgICAgICAgICAgICAgTG9nLmVycm9yKGUpXG4gICAgICAgICAgICAgICAgcmVqZWN0KGUpXG4gICAgICAgICAgICAgIH0pXG4gICAgICAgICAgOiBzZXRMYW5ndWFnZShsYW5ndWFnZSlcbiAgICAgICAgICAgICAgLnRoZW4ocmVzb2x2ZSlcbiAgICAgICAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICAgIH0pXG4gICAgICAuY2F0Y2goKCkgPT4ge1xuICAgICAgICBjb25zdCBlcnJvciA9ICdMYW5ndWFnZSBmaWxlICcgKyBmaWxlICsgJyBub3QgZm91bmQnXG4gICAgICAgIExvZy5lcnJvcihlcnJvcilcbiAgICAgICAgcmVqZWN0KGVycm9yKVxuICAgICAgfSlcbiAgfSlcbn1cblxuY29uc3Qgc2V0VHJhbnNsYXRpb25zID0gb2JqID0+IHtcbiAgaWYgKCdtZXRhJyBpbiBvYmopIHtcbiAgICBtZXRhID0geyAuLi5vYmo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GEtcHJvdmlkZXIgb24oKSB5b3UgQ0FOIG92ZXJyaWRlIGluIGNoaWxkLWNsYXNzXG4gICAgICAgKi9cbiAgICAgIExvYWRpbmc6IHtcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgdzogMTkyMCxcbiAgICAgICAgaDogMTA4MCxcbiAgICAgICAgY29sb3I6IDB4ZmYwMDAwMDAsXG4gICAgICAgIHZpc2libGU6IGZhbHNlLFxuICAgICAgICB6SW5kZXg6IDk5LFxuICAgICAgICBMYWJlbDoge1xuICAgICAgICAgIG1vdW50OiAwLjUsXG4gICAgICAgICAgeDogOTYwLFxuICAgICAgICAgIHk6IDU0MCxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiAnTG9hZGluZy4uJyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICB9XG4gIH1cblxuICBzdGF0aWMgX3N0YXRlcygpIHtcbiAgICByZXR1cm4gW1xuICAgICAgY2xhc3MgTG9hZGluZyBleHRlbmRzIHRoaXMge1xuICAgICAgICAkZW50ZXIoKSB7XG4gICAgICAgICAgdGhpcy50YWcoJ0xvYWRpbmcnKS52aXNpYmxlID0gdHJ1ZVxuICAgICAgICB9XG5cbiAgICAgICAgJGV4aXQoKSB7XG4gICAgICAgICAgdGhpcy50YWcoJ0xvYWRpbmcnKS52aXNpYmxlID0gZmFsc2VcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIGNsYXNzIFdpZGdldHMgZXh0ZW5kcyB0aGlzIHtcbiAgICAgICAgJGVudGVyKGFyZ3MsIHdpZGdldCkge1xuICAgICAgICAgIC8vIHN0b3JlIHdpZGdldCByZWZlcmVuY2VcbiAgICAgICAgICB0aGlzLl93aWRnZXQgPSB3aWRnZXRcblxuICAgICAgICAgIC8vIHNpbmNlIGl0J3MgcG9zc2libGUgdGhhdCB0aGlzIGJlaGF2aW91clxuICAgICAgICAgIC8vIGlzIG5vbi1yZW1vdGU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bWUgcG9pbnQgZm9yIG1hbnVhbCByZXN1bWVcbiAgcmVzdW1lSGFzaCA9IGlzRGlyZWN0TG9hZCA/IHJvb3RIYXNoIDogaGFzaCB8fCByb290SGFzaFxuXG4gIGNvbnN0IHJlYWR5ID0gKCkgPT4ge1xuICAgIGlmICghaGFzaCAmJiByb290SGFzaCkge1xuICAgICAgaWYgKGlzU3RyaW5nKHJvb3RIYXNoKSkge1xuICAgICAgICBuYXZpZ2F0ZShyb290SGFzaClcbiAgICAgIH0gZWxzZSBpZiAoaXNGdW5jdGlvbihyb290SGFzaCkpIHtcbiAgICAgICAgcm9vdEhhc2goKS50aGVuKHJlcyA9PiB7XG4gICAgICAgICAgaWYgKGlzT2JqZWN0KHJlcykpIHtcbiAgICAgICAgICAgIG5hdmlnYXRlKHJlcy5wYXRoLCByZXMucGFyYW1zKVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBuYXZpZ2F0ZShyZXMpXG4gICAgICAgICAgfVxuICAgICAgICB9KVxuICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICBxdWV1ZShoYXNoKVxuICAgICAgaGFuZGxlSGFzaENoYW5nZSgpXG4gICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICBhcHAuX3JlZm9jdXMoKVxuICAgICAgICB9KVxuICAgICAgICAuY2F0Y2goZSA9PiB7XG4gICAgICAgICAgY29uc29sZS5lcnJvcihlKVxuICAgICAgICB9KVxuICAgIH1cbiAgfVxuXG4gIGlmIChyb3V0ZUV4aXN0cyhib290S2V5KSkge1xuICAgIGlmIChoYXNoICYmICFpc0RpcmVjdExvYWQpIHtcbiAgICAgIGlmICghZ2V0Um91dGVCeUhhc2goaGFzaCkpIHtcbiAgICAgICAgbmF2aWdhdGUoJyonLCB7IGZhaWxlZEhhc2g6IGhhc2ggfSlcbiAgICAgICAgcmV0dXJuXG4gICAgICB9XG4gICAgfVxuICAgIG5hdmlnYXRlKFxuICAgICAgYm9vdEtleSxcbiAgIC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iBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHtcbiAgICBpLnBhdGNoKHtcbiAgICAgIGFscGhhOiAwLFxuICAgICAgdmlzaWJsZTogdHJ1ZSxcbiAgICAgIHNtb290aDoge1xuICAgICAgICBhbHBoYTogWzEsIHsgZHVyYXRpb246IDAuNSwgZGVsYXk6IDAuMSB9XSxcbiAgICAgIH0sXG4gICAgfSlcbiAgICBpZiAobykge1xuICAgICAgby5wYXRjaCh7XG4gICAgICAgIHNtb290aDoge1xuICAgICAgICAgIGFscGhhOiBbMCwgeyBkdXJhdGlvbjogMC41LCBkZWxheTogMC4zIH1dLFxuICAgICAgICB9LFxuICAgICAgfSlcbiAgICB9XG4gICAgLy8gcmVzb2x2ZSBvbiB5IGZpbmlzaFxuICAgIGkudHJhbnNpdGlvbignYWxwaGEnKS5vbignZmluaXNoJywgKCkgPT4ge1xuICAgICAgcmVzb2x2ZSgpXG4gICAgfSlcbiAgfSlcbn1cblxuY29uc3QgbW92ZU9uQXhlcyA9IChheGlzLCBkaXJlY3Rpb24sIGksIG8pID0+IHtcbiAgY29uc3QgYm91bmRzID0gYXhpcyA9PT0gJ3gnID8gMTkyMCA6IDEwODBcbiAgcmV0dXJuIG5ldyBQcm9taXNlKHJlc29sdmUgPT4ge1xuICAgIGkucGF0Y2goe1xuICAgICAgW2Ake2F4aXN9YF06IGRpcmVjdGlvbiA/IGJvdW5kcyAqIC0xIDogYm91bmRzLFxuICAgICAgdmlzaWJsZTogdHJ1ZSxcbiAgICAgIHNtb290aDoge1xuICAgICAgICBbYCR7YXhpc31gXTogWzAsIHsgZHVyYXRpb246IDAuNCwgZGVsYXk6IDAuMiB9XSxcbiAgICAgIH0sXG4gICAgfSlcbiAgICAvLyBvdXQgaXMgb3B0aW9uYWxcbiAgICBpZiAobykge1xuICAgICAgby5wYXRjaCh7XG4gICAgICAgIFtgJHtheGlzfWBdOiAwLFxuICAgICAgICBzbW9vdGg6IHtcbiAgICAgICAgICBbYCR7YXhpc31gXT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ge1xuICAgICAgICAgICAgdmFyIGEgPSBuLmFwcGx5KHQsIGUpO1xuICAgICAgICAgICAgZnVuY3Rpb24gX25leHQobikge1xuICAgICAgICAgICAgICAgIGFzeW5jR2VuZXJhdG9yU3RlcChhLCByLCBvLCBfbmV4dCwgX3Rocm93LCBcIm5leHRcIiwgbik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBmdW5jdGlvbiBfdGhyb3cobikge1xuICAgICAgICAgICAgICAgIGFzeW5jR2VuZXJhdG9yU3RlcChhLCByLCBvLCBfbmV4dCwgX3Rocm93LCBcInRocm93XCIsIG4pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX25leHQodm9pZCAwKTtcbiAgICAgICAgfSkpO1xuICAgIH07XG59XG5cbmZ1bmN0aW9uIG93bktleXMoZSwgcikge1xuICAgIHZhciB0ID0gT2JqZWN0LmtleXMoZSk7XG4gICAgaWYgKE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMpIHtcbiAgICAgICAgdmFyIG8gPSBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO1xuICAgICAgICByICYmIChvID0gby5maWx0ZXIoKGZ1bmN0aW9uKHIpIHtcbiAgICAgICAgICAgIHJldHVybiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKGUsIHIpLmVudW1lcmFibGU7XG4gICAgICAgIH0pKSksIHQucHVzaC5hcHBseSh0LCBvKTtcbiAgICB9XG4gICAgcmV0dXJuIHQ7XG59XG5cbmZ1bmN0aW9uIF9vYmplY3RTcHJlYWQoZSkge1xuICAgIGZvciAodmFyIHIgPSAxOyByIDwgYXJndW1lbnRzLmxlbmd0aDsgcisrKSB7XG4gICAgICAgIHZhciB0ID0gbnVsbCAhPSBhcmd1bWVudHNbcl0gPyBhcmd1bWVudHNbcl0gOiB7fTtcbiAgICAgICAgciAlIDIgPyBvd25LZXlzKE9iamVjdCh0KSwgITApLmZvckVhY2goKGZ1bmN0aW9u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XJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2xvZ0NhbGxiYWNrID0gdmFsdWU7XG4gICAgfVxuICAgIGxvZygpIHtcbiAgICAgICAgZm9yICh2YXIgX2xlbiA9IGFyZ3VtZW50cy5sZW5ndGgsIGFyZ3MgPSBuZXcgQXJyYXkoX2xlbiksIF9rZXkgPSAwOyBfa2V5IDwgX2xlbjsgX2tleSsrKSB7XG4gICAgICAgICAgICBhcmdzW19rZXldID0gYXJndW1lbnRzW19rZXldO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9sb2dDYWxsYmFjaykge1xuICAgICAgICAgICAgdGhpcy5fbG9nQ2FsbGJhY2soe1xuICAgICAgICAgICAgICAgIGxldmVsOiBcImxvZ1wiLFxuICAgICAgICAgICAgICAgIHBheWxvYWQ6IGFyZ3NcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmRlYnVnKSB7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyh0aGlzLl9wcmVmaXgsIC4uLmFyZ3MpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGluZm8oKSB7XG4gICAgICAgIGZvciAodmFyIF9sZW4yID0gYXJndW1lbnRzLmxlbmd0aCwgYXJncyA9IG5ldyBBcnJheShfbGVuMiksIF9rZXkyID0gMDsgX2tleTIgPCBfbGVuMjsgX2tleTIrKykge1xuICAgICAgICAgICAgYXJnc1tfa2V5Ml0gPSBhcmd1bWVudHNbX2tleTJdO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9sb2dDYWxsYmFjaykge1xuICAgICAgICAgICAgdGhpcy5fbG9nQ2FsbGJhY2soe1xuICAgICAgICAgICAgICAgIGxldmVsOiBcImluZm9cIixcbiAgICAgICAgICAgICAgICBwYXlsb2FkOiBhcmdzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5kZWJ1Zykge1xuICAgICAgICAgICAgY29uc29sZS5pbmZvKHRoaXMuX3ByZWZpeCwgLi4uYXJncyk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgd2FybigpIHtcbiAgICAgICAgZm9yICh2YXIgX2xlbjMgPSBhcmd1bWVudHMubGVuZ3RoLCBhcmdzID0gbmV3IEFycmF5KF9sZW4zKSwgX2tleTMgPSAwOyBfa2V5MyA8IF9sZW4zOyBfa2V5MysrKSB7XG4gICAgICAgICAgICBhcmdzW19rZXkzXSA9IGFyZ3VtZW50c1tfa2V5M107XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX2xvZ0NhbGxiYWNrKSB7XG4gICAgICAgICAgICB0aGlzLl9sb2dDYWxsYmFjayh7XG4gICAgICAgICAgICAgICAgbGV2ZWw6IFwid2FyblwiLFxuICAgICAgICAgICAgICAgIHBheWxvYWQ6IGFyZ3NcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmRlYnVnKSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4odGhpcy5fcHJlZml4LCAuLi5hcmdzKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBlcnJvcigpIHtcbiAgICAgICAgZm9yICh2YXIgX2xlbjQgPSBhcmd1bWVudHMubGVuZ3RoLCBhcmdzID0gbmV3IEFycmF5KF9sZW40KSwgX2tleTQgPSAwOyBfa2V5NCA8IF9sZW40OyBfa2V5NCsrKSB7XG4gICAgICAgICAgICBhcmdzW19rZXk0XSA9IGFyZ3VtZW50c1tfa2V5NF07XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX2xvZ0NhbGxiYWNrKSB7XG4gICAgICAgICAgICB0aGlzLl9sb2dDYWxsYmFjayh7XG4gICAgICAgICAgICAgICAgbGV2ZWw6IFwiZXJyb3JcIixcbiAgICAgICAgICAgICAgICBwYXlsb2FkOiBhcmdzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5kZWJ1Zykge1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcih0aGlzLl9wcmVmaXgsIC4uLmFyZ3MpO1xuICAgICAgICB9XG4gICAgfVxufVxuXG52YXIgbG9nZ2VySW5zdGFuY2UgPSBuZXcgTG9nZ2VyO1xuXG5mdW5jdGlvbiBkZWJvdW5jZShmdW5jLCB3YWl0LCBpbW1lZGlhdGUpIHtcbiAgICB2YXIgdGltZW91dCwgYXJncywgY29udGV4dCwgdGltZXN0YW1wLCByZXN1bHQ7XG4gICAgaWYgKG51bGwgPT0gd2FpdCkgd2FpdCA9IDEwMDtcbiAgICBmdW5jdGlvbiBsYXRlcigpIHtcbiAgICAgICAgdmFyIGxhc3QgPSBEYXRlLm5vdygpIC0gdGltZXN0YW1wO1xuICAgICAgICBpZiAobGFzdCA8IHdhaXQgJiYgbGFzdCA+PSAwKSB7XG4gICAgICAgICAgICB0aW1lb3V0ID0gc2V0VGltZW91dChsYXRlciwgd2FpdCAtIGxhc3QpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGltZW91dCA9IG51bGw7XG4gICAgICAgICAgICBpZiAoIWltbWVkaWF0ZSkge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9IGZ1bmMuYXBwbHkoY29udGV4dCwgYXJncyk7XG4gICAgICAgICAgICAgICAgY29udGV4dCA9IGFyZ3MgPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIHZhciBkZWJvdW5jZWQgPSBmdW5jdGlvbiBkZWJvdW5jZWQoKSB7XG4gICAgICAgIGNvbnRleHQgPSB0aGlzO1xuICAgICAgICBhcmdzID0gYXJndW1lbnRzO1xuICAgICAgICB0aW1lc3RhbXAgPSBEYXRlLm5vdygpO1xuICAgICAgICB2YXIgY2FsbE5vdyA9IGltbWVkaWF0ZSAmJiAhdGltZW91dDtcbiAgICAgICAgaWYgKCF0aW1lb3V0KSB0aW1lb3V0ID0gc2V0VGltZW91dChsYXRlciwgd2FpdCk7XG4gICAgICA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lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiB7fTtcbiAgICB2YXIge3c6IHcsIGg6IGgsIHJhdGlvWDogcmF0aW9YLCByYXRpb1k6IHJhdGlvWSwgdXBDb3VudDogdXBDb3VudH0gPSBvYmo7XG4gICAgdmFyIGZhbGxiYWNrVyA9IGZhbGxiYWNrLncgfHwgMDtcbiAgICB2YXIgZmFsbGJhY2tIID0gZmFsbGJhY2suaCB8fCAwO1xuICAgIHZhciBkaW1lbnNpb25zID0ge307XG4gICAgaWYgKHcgJiYgaCkge1xuICAgICAgICBkaW1lbnNpb25zID0ge1xuICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgIGg6IGhcbiAgICAgICAgfTtcbiAgICB9IGVsc2UgaWYgKGggJiYgcmF0aW9YICYmIHJhdGlvWSkge1xuICAgICAgICBkaW1lbnNpb25zID0ge1xuICAgICAgICAgICAgdzogTWF0aC5yb3VuZChoICogcmF0aW9YIC8gcmF0aW9ZKSxcbiAgICAgICAgICAgIGg6IGhcbiAgICAgICAgfTtcbiAgICB9IGVsc2UgaWYgKHJhdGlvWCAmJiByYXRpb1kgJiYgdXBDb3VudCkge1xuICAgICAgICBkaW1lbnNpb25zID0gZ2V0SXRlbVJhdGlvRGltZW5zaW9ucyh0aGVtZSwgcmF0aW9YLCByYXRpb1ksIHVwQ291bnQpO1xuICAgIH0gZWxzZSBpZiAoaCAmJiB1cENvdW50KSB7XG4gICAgICAgIGRpbWVuc2lvbnMgPSB7XG4gICAgICAgICAgICB3OiBNYXRoLnJvdW5kKGdldFdpZHRoQnlVcENvdW50KHRoZW1lLCB1cENvdW50KSksXG4gICAgICAgICAgICBoOiBoXG4gICAgICAgIH07XG4gICAgfSBlbHNlIGlmIChoKSB7XG4gICAgICAgIGRpbWVuc2lvbnMgPSB7XG4gICAgICAgICAgICB3OiBmYWxsYmFja1csXG4gICAgICAgICAgICBoOiBoXG4gICAgICAgIH07XG4gICAgfSBlbHNlIGlmIC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SAqIDI1NSkudG9TdHJpbmcoMTYpO1xuICAgIHZhciBzdHIgPSBcIjB4XCIuY29uY2F0KGhleEFscGhhKS5jb25jYXQoaGV4KTtcbiAgICByZXR1cm4gTnVtYmVyKHN0cik7XG59XG5cbmZ1bmN0aW9uIGdldFZhbGlkQ29sb3IoY29sb3IpIHtcbiAgICBpZiAodHlwZW9mIGNvbG9yID09PSBcInN0cmluZ1wiIHx8IHR5cGVvZiBjb2xvciA9PT0gXCJudW1iZXJcIikge1xuICAgICAgICBpZiAoL14weFswLTlhLWZBLUZdezh9L2cudGVzdChjb2xvcikpIHtcbiAgICAgICAgICAgIHJldHVybiBOdW1iZXIoY29sb3IpO1xuICAgICAgICB9IGVsc2UgaWYgKC9eI1swLTlhLWZBLUZdezZ9L2cudGVzdChjb2xvcikpIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRIZXhDb2xvcihjb2xvci5zdWJzdHIoMSwgNikpO1xuICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBjb2xvciA9PT0gXCJzdHJpbmdcIiAmJiAvXlswLTldezgsMTB9L2cudGVzdChjb2xvcikpIHtcbiAgICAgICAgICAgIHJldHVybiBwYXJzZUludChjb2xvcik7XG4gICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGNvbG9yID09PSBcIm51bWJlclwiICYmIC9eWzAtOV17OCwxMH0vZy50ZXN0KGNvbG9yLnRvU3RyaW5nKCkpKSB7XG4gICAgICAgICAgICByZXR1cm4gY29sb3I7XG4gICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGNvbG9yID09PSBcInN0cmluZ1wiICYmIGNvbG9yLmluZGV4T2YoXCJyZ2JhXCIpID4gLTEpIHtcbiAgICAgICAgICAgIHJldHVybiByZ2JhMmFyZ2IoY29sb3IpO1xuICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBjb2xvciA9PT0gXCJzdHJpbmdcIiAmJiBjb2xvci5pbmRleE9mKFwicmdiXCIpID4gLTEpIHtcbiAgICAgIC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UUklOR19QQVRURVJOKTtcbiAgICAgICAgaWYgKHNwbGl0U3RyICYmIHNwbGl0U3RyLmxlbmd0aCkge1xuICAgICAgICAgICAgc3BsaXRTdHIuZm9yRWFjaCgoaXRlbSA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIGZvcm1hdHRlZEl0ZW0gPSBpdGVtO1xuICAgICAgICAgICAgICAgIHZhciBiYWRnZSA9IGJhZGdlUmVnRXguZXhlYyhpdGVtKTtcbiAgICAgICAgICAgICAgICB2YXIgaWNvbiA9IGljb25SZWdFeC5leGVjKGl0ZW0pO1xuICAgICAgICAgICAgICAgIHZhciBuZXdsaW5lID0gbmV3bGluZVJlZ0V4LmV4ZWMoaXRlbSk7XG4gICAgICAgICAgICAgICAgdmFyIHRleHQgPSB0ZXh0UmVnRXguZXhlYyhpdGVtKTtcbiAgICAgICAgICAgICAgICBpZiAoYmFkZ2UgJiYgYmFkZ2VbMV0pIHtcbiAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkSXRlbSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJhZGdlOiBiYWRnZVsxXVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaWNvbiAmJiBpY29uWzFdKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvcm1hdHRlZEl0ZW0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaWNvblsxXSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGljb246IGljb25bMl0gfHwgaWNvblsxXVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmV3bGluZSkge1xuICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRJdGVtID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV3bGluZTogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGV4dCAm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wLFxuICAgICAgICAgICAgeGZhc3Q6IC4xLFxuICAgICAgICAgICAgZmFzdDogLjI1LFxuICAgICAgICAgICAgbm9ybWFsOiAuNSxcbiAgICAgICAgICAgIHNsb3c6IC43NSxcbiAgICAgICAgICAgIHhzbG93OiAuOVxuICAgICAgICB9LFxuICAgICAgICBkZWxheToge1xuICAgICAgICAgICAgbm9uZTogMCxcbiAgICAgICAgICAgIHhmYXN0OiAuMDEsXG4gICAgICAgICAgICBmYXN0OiAuMDI1LFxuICAgICAgICAgICAgbm9ybWFsOiAuMDUsXG4gICAgICAgICAgICBzbG93OiAuMDc1LFxuICAgICAgICAgICAgeHNsb3c6IC4wOVxuICAgICAgICB9LFxuICAgICAgICBleHByZXNzaXZlOiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9LFxuICAgICAgICBleHByZXNzaXZlRW50cmFuY2U6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIGV4cHJlc3NpdmVFeGl0OiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9LFxuICAgICAgICBzdGFuZGFyZDoge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSxcbiAgICAgICAgc3RhbmRhcmRFbnRyYW5jZToge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSxcbiAgICAgICAgc3RhbmRhcmRFeGl0OiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9LFxuICAgICAgICB1dGlsaXR5OiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9LFxuICAgICAgICB1dGlsaXR5RW50cmFuY2U6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIHV0aWxpdHlFeGl0OiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9XG4gICAgfSxcbiAgICBhc3NldDoge1xuICAgICAgICBhcnJvd0xlZnQ6IFwiZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFCZ0FBQUFZQ0FZQU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uICAgICAgICB4eGw6IDQwLFxuICAgICAgICB4eHhsOiA1MFxuICAgIH0sXG4gICAgc3Ryb2tlOiB7XG4gICAgICAgIG5vbmU6IDAsXG4gICAgICAgIHNtOiAyLFxuICAgICAgICBtZDogNCxcbiAgICAgICAgbGc6IDYsXG4gICAgICAgIHhsOiA4XG4gICAgfSxcbiAgICB0eXBvZ3JhcGh5OiB7XG4gICAgICAgIGRpc3BsYXkxOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogNzUsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA4NSxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgZGlzcGxheTI6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiA1MCxcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDYwLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBoZWFkbGluZTE6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAzNSxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDQ4LFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBoZWFkbGluZTI6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAzMCxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDQwLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBoZWFkbGluZTM6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyNSxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDM2LFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBib2R5MToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDI1LFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjMwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogNDAsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGJvZHkyOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjIsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiMzAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAzMixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgYm9keTM6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyMCxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCIzMDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDMyLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBidXR0b24xOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjUsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAzMixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgYnV0dG9uMjoge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDIwLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMzIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGNhbGxvdXQxOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjAsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAzMixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgY2FwdGlvbjE6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAxNSxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDI0LFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICB0YWcxOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjAsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAyNCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgZm9vdG5vdGUxOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjIsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiMzAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAzMCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfVxuICAgIH1cbn07XG5cbnZhciBjdXN0b21Gb250RmFjZXMgPSBbXTtcblxudmFyIGZvbnRMb2FkZXIgPSBmb250cyA9PiB7XG4gICAgdmFyIHByb21pc2VzID0gW107XG4gICAgdmFyIF9sb29wID0gZnVuY3Rpb24gX2xvb3AoKSB7XG4gICAgICAgIHZhciB7ZmFtaWx5OiBmYW1pbHksIHNyYzogc3JjLCBkZXNjcmlwdG9yczogZGVzY3JpcHRvcnN9ID0gZm9udHNbaV07XG4gICAgICAgIHZhciBmb250U3JjID0gc3JjICYmIEFycmF5LmlzQXJyYXkoc3JjKSAmJiBzcmMubGVuZ3RoID8gc3JjLm1hcCgodXJsID0+IHVybC5zdWJzdHIoMCwgNSkgPT09IFwibG9jYWxcIiA/IHVybCA6IFwidXJsKFwiLmNvbmNhdCh1cmwsIFwiKVwiKSkpLmpvaW4oXCIsXCIpIDogXCJ1cmwoXCIgKyBzcmMgKyBcIilcIjtcbiAgICAgICAgdmFyIGZvbnRGYWNlID0gbmV3IEZvbnRGYWNlKGZhbWlseSwgZm9udFNyYywgZGVzY3JpcHRvcnMgfHwge30pO1xuICAgICAgICBsb2dnZXJJbnN0YW5jZS5pbmZvKFwiTG9hZGluZyBmb250XCIsIGZhbWlseSk7XG4gICAgICAgIGRvY3VtZW50LmZvbnRzLmFkZChmb250RmFjZSk7XG4gICAgICAgIHByb21pc2VzLnB1c2gobmV3IFByb21pc2UoKHJlc29sdmUgPT4ge1xuICAgICAgICAgICAgZm9udEZhY2UubG9hZCgpLnRoZW4oKCgpID0+IHtcbiAgICAgICAgICAgICAgICBjdXN0b21Gb250RmFjZXMucHVzaChmb250RmFjZSk7XG4gICAgICAgICAgICAgICAgcmVzb2x2ZShmYW1pbHkpO1xuICAgICAgICAgICAgfSkpLmNhdGNoKChlcnIgPT4ge1xuICAgICAgICAgICAgICAgIHJlc29sdmUobmV3IEVycm9yKFwiXCIuY29uY2F0KGZhbWlseSwgXCI6IFwiKS5jb25jYXQoZXJyLm1lc3NhZ2UpKSk7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH0pKSk7XG4gICAgfTtcbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGZvbnRzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgIF9sb29wKCk7XG4gICAgfVxuICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbigoZm9udHNMb2FkZWQgPT4ge1xuICAgICAgICB2YXIgbG9hZGVkID0gZm9udHNMb2FkZWQuZmlsdGVyKChmb250ID0+ICEoZm9udCBpbnN0YW5jZW9mIEVycm9yKSkpLmpvaW4oXCIsIFwiKTtcbiAgICAgICAgaWYgKGxvYWRlZCkge1xuICAgICAgICAgICAgbG9nZ2VySW5zdGFuY2UubG9nKFwiRm9udHMgbG9hZGVkOiBcIi5jb25jYXQobG9hZGVkKSk7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGZhaWxlZCA9IGZvbnRzTG9hZGVkLmZpbHRlcigoZm9udCA9PiBmb250IGluc3RhbmNlb2YgRXJyb3IpKS5tYXAoKGl0ZW0gPT4gaXRlbS5tZXNzYWdlKSkuam9pbihcIiwgXCIpO1xuICAgICAgICBpZiAoZmFpbGVkKSB7XG4gICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS5lcnJvcihcIlVuYWJsZSB0byBsb2FkIGZvbnRzOiBcIi5jb25jYXQoZmFpbGVkKSk7XG4gICAgICAgIH1cbiAgICB9KSk7XG59O1xuXG52YXIgY2xlYW51cEZvbnRzID0gZnVuY3Rpb24oKSB7XG4gICAgdmFyIF9yZWYzID0gX2FzeW5jVG9HZW5lcmF0b3IoKGZ1bmN0aW9uKihmb250cykge1xuICAgICAgICBpZiAoZG9jdW1lbnQuZm9udHMgJiYgXCJkZWxldGVcIiBpbiBkb2N1bWVudC5mb250cykge1xuICAgICAgICAgICAgaWYgKCFjdXN0b21Gb250RmFjZXMubGVuZ3RoKSByZXR1cm47XG4gICAgICAgICAgICBjdXN0b21Gb250RmFjZXMgPSBjdXN0b21Gb250RmFjZXMuZmlsdGVyKChmb250RmFjZSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKCFmb250cy5maW5kKChmb250ID0+IGZvbnQuZmFtaWx5ID09PSBmb250RmFjZS5mYW1pbHkpKSkge1xuICAgICAgICAgICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS5pbmZvKFwiUmVtb3ZpbmcgZm9udFwiLCBmb250RmFjZS5mYW1pbHkpO1xuICAgICAgICAgICAgICAgICAgICBkb2N1bWVudC5mb250cy5kZWxldGUoZm9udEZhY2UpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZvbnRGYWNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxvZ2dlckluc3RhbmNlLmluZm8oXCJVbmFibGUgdG8gcmVtb3ZlIG1hbnVhbGx5LWFkZGVkIGZvbnRzXCIpO1xuICAgICAgICB9XG4gICAgfSkpO1xuICAgIHJldHVybiBmdW5jdGlvbiBjbGVhbnVwRm9udHMoX3gpIHtcbiAgICAgICAgcmV0dXJuIF9yZWYzLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XG4gICAgfTtcbn0oKTtcblxudmFyIFRIRU1FX0tFWV9SRVBMQUNFUiA9IHtcbiAgICBmb250RmFtaWx5OiBcImZvbnRGYWNlXCJcbn07XG5cbnZhciBtZXJnZSA9IHtcbiAgICBhbGw6IG9iakFycmF5ID0+IHtcbiAgICAgICAgdmFyIHJlc3VsdCA9IHt9O1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IG9iakFycmF5Lmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICByZXN1bHQgPSBjbG9uZShyZXN1bHQsIG9iakFycmF5W2ldKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdW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mluZWRcIikgcmV0dXJuO1xuICAgICAgICBpZiAoIXdpbmRvdy5MVUkpIHtcbiAgICAgICAgICAgIHdpbmRvdy5MVUkgPSB7fTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXdpbmRvdy5MVUkudGhlbWVNYW5hZ2VySW5zdGFuY2VzKSB7XG4gICAgICAgICAgICB3aW5kb3cuTFVJLnRoZW1lTWFuYWdlckluc3RhbmNlcyA9IFsge1xuICAgICAgICAgICAgICAgIHRoZW1lTWFuYWdlcjogdGhpcyxcbiAgICAgICAgICAgICAgICBldmVudHM6IGV2ZW50c1xuICAgICAgICAgICAgfSBdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgd2luZG93LkxVSS50aGVtZU1hbmFnZXJJbnN0YW5jZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgdGhlbWVNYW5hZ2VyOiB0aGlzLFxuICAgICAgICAgICAgICAgIGV2ZW50czogZXZlbnRzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfc2V0Q2FjaGUoa2V5LCBwYXlsb2FkKSB7XG4gICAgICAgIGlmICh0eXBlb2Ygd2luZG93ID09PSBcInVuZGVmaW5lZFwiKSByZXR1cm47XG4gICAgICAgIHdpbmRvdy5MVUkudGhlbWVNYW5hZ2VySW5zdGFuY2VzLmZvckVhY2goKF9yZWY0ID0+IHtcbiAgICAgICAgICAgIHZhciB7dGhlbWVNYW5hZ2VyOiB0aGVtZU1hbmFnZXJ9ID0gX3JlZjQ7XG4gICAgICAgICAgICBpZiAodGhlbWVNYW5hZ2VyKSB0aGVtZU1hbmFnZXIuX2NhY2hlLnNldChrZXksIHBheWxvYWQpO1xuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF9kZWxldGVDYWNoZShrZXkpIHtcbiAgICAgICAgaWYgKHR5cGVvZiB3aW5kb3cgPT09IFwidW5kZWZpbmVkXCIpIHJldHVybjtcbiAgICAgICAgd2luZG93LkxVSS50aGVtZU1h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pZykpIHtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IG1lcmdlLmFsbCh0aGVtZUNvbmZpZyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHZhbHVlID0gdGhlbWVDb25maWc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoXCJvYmplY3RcIiAhPT0gdHlwZW9mIHZhbHVlIHx8IG51bGwgPT09IHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgbG9nZ2VySW5zdGFuY2Uud2FybihcImNvbnRleHQgdGhlbWUgZXhwZWN0ZWQgYW4gb2JqZWN0LiBSZWNlaXZlZCBcIi5jb25jYXQodHlwZW9mIHZhbHVlKSk7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX3RoaXMuX2NsZWFyQ2FjaGUoKTtcbiAgICAgICAgICAgIHZhciB0aGVtZSA9IF90aGlzLl9wcm9jZXNzVGhlbWUuY2FsbChfdGhpcywgWyB2YWx1ZSBdLCB2YWx1ZS5leHRlbnNpb25zKTtcbiAgICAgICAgICAgIF90aGlzLl9zZXRDYWNoZShcInRoZW1lXCIsIHRoZW1lKTtcbiAgICAgICAgICAgIHlpZWxkIGNsZWFudXBGb250cyh0aGVtZS5mb250KTtcbiAgICAgICAgICAgIGlmICh0aGVtZS5mb250ICYmIHRoZW1lLmZvbnQubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgeWllbGQgX3RoaXMuX2xvYWRGb250cyh0aGVtZS5mb250KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIF90aGlzLl9yZWZyZXNoU3ViVGhlbWVzKCk7XG4gICAgICAgICAgICBfdGhpcy5fZW1pdChcInRoZW1lRXh0ZW5zaW9uc1VwZGF0ZVwiKTtcbiAgICAgICAgICAgIF90aGlzLl9lbWl0KFwidGhlbWVVcGRhdGVcIik7XG4gICAgICAgICAgICByZXR1cm4gdGhlbWU7XG4gICAgICAgIH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gICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhbHVlID0gcmVwbGFjZW1lbnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIge2lzSW1hZ2U6IGlzSW1hZ2UsIG1pbWVUeXBlOiBtaW1lVHlwZX0gPSBjaGVja0Jhc2U2NEVuY29kZWRJbWFnZSh2YWx1ZSk7XG4gICAgICAgICAgICBpZiAod2luZG93LlVSTCAmJiB0eXBlb2Ygd2luZG93LlVSTC5jcmVhdGVPYmplY3RVUkwgPT09IFwiZnVuY3Rpb25cIiAmJiBpc0ltYWdlKSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGJsb2JVUkwgPSBiYXNlNjRUb0Jsb2JVUkwodmFsdWUsIG1pbWVUeXBlKTtcbiAgICAgICAgICAgICAgICAgICAgYmFzZTY0Q2FjaGUucHVzaChibG9iVVJMKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJsb2JVUkw7XG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHZhbHVlKSAmJiAyID09PSB2YWx1ZS5sZW5ndGggJiYgIXZhbHVlWzBdLnRhcmdldENvbXBvbmVudCAmJiB2YWx1ZVswXS5sZW5ndGggJiYgdHlwZW9mIHZhbHVlWzBdID09PSBcInN0cmluZ1wiICYmIHZhbHVlWzBdLnN1YnN0cigwLCAxKSA9PT0gXCIjXCIgJiYgdHlwZW9mIHZhbHVlWzFdID09PSBcIm51bWJlclwiKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGdldEhleENvbG9yKHZhbHVlWzBdLCB2YWx1ZVsxXSk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKFwiZXh0ZW5zaW9uc1wiID09PSBrZXkgfHwgXCJmdW5jdGlvblwiID09PSB0eXBlb2YgdmFsdWUgfHwgXCJvYmplY3RcIiA9PT0gdHlwZW9mIHZhbHVlICYmIHZhbHVlICE9PSBudWxsICYmIFwiT2JqZWN0XCIgIT09IHZhbHVlLmNvbnN0cnVjdG9yLm5hbWUgJiYgIUFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgdGhlbWVGdW5jdGlvbnNba2V5XSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoXCJzdHJpbmdcIiA9PT0gdHlwZW9mIHZhbHVlICYmIHZhbHVlLmluY2x1ZGVzKFwidGhlbWUuXCIpKSB7XG4gICAgICAgICAgICAgICAgdmFyIHRoZW1lVmFsdWUgPSBnZXRWYWxGcm9tT2JqUGF0aCh7XG4gICAgICAgICAgICAgICAgICAgIHRoZW1lOiB0aGVtZVxuICAgICAgICAgICAgICAgIH0sIHZhbHVlKTtcbiAgICAgICAgICAgICAgICBpZiAodGhlbWVWYWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhlbWVWYWx1ZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsaWRDb2xvciA9IGdldFZhbGlkQ29sb3IodmFsdWUpO1xuICAgICAgICAgICAgICAgIGlmICh2YWxpZENvbG9yKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWxpZENvbG9yO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKTtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iam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cmVzdWx0ID0gcHJvcDtcbiAgICBpZiAodHlwZW9mIGNvbXBvbmVudENvbmZpZ1Byb3AgPT09IFwib2JqZWN0XCIgJiYgT2JqZWN0LmtleXMoY29tcG9uZW50Q29uZmlnUHJvcCkubGVuZ3RoICYmIHR5cGVvZiBwcm9wID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgIHJlc3VsdCA9IGNsb25lKGNvbXBvbmVudENvbmZpZ1Byb3AsIHByb3ApO1xuICAgIH1cbiAgICByZXR1cm4gKF9yZXN1bHQgPSByZXN1bHQpICE9PSBudWxsICYmIF9yZXN1bHQgIT09IHZvaWQgMCA/IF9yZXN1bHQgOiBjb21wb25lbnRDb25maWdQcm9wO1xufVxuXG5mdW5jdGlvbiBnZXRQcm9wZXJ0eURlc2NyaXB0b3IkMShuYW1lLCBrZXkpIHtcbiAgICByZXR1cm4ge1xuICAgICAgICBnZXQoKSB7XG4gICAgICAgICAgICB2YXIgX3RoaXMkX19jb21wb25lbnRDb25mMztcbiAgICAgICAgICAgIHZhciBjdXN0b21HZXR0ZXIgPSB0aGlzW1wiX2dldFwiLmNvbmNhdChjYXBpdGFsKG5hbWUpKV07XG4gICAgICAgICAgICBpZiAoY3VzdG9tR2V0dGVyICYmIHR5cGVvZiBjdXN0b21HZXR0ZXIgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfX2NvbXBvbmVudENvbmYsIF90aGlzJF9fY29tcG9uZW50Q29uZjI7XG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gY3VzdG9tR2V0dGVyLmNhbGwodGhpcywgdGhpc1trZXldKTtcbiAgICAgICAgICAgICAgICB0aGlzW2tleV0gPSB2YWx1ZSB8fCAoKF90aGlzJF9fY29tcG9uZW50Q29uZiA9IHRoaXMuX19jb21wb25lbnRDb25maWdQcm9wcykgPT09IG51bGwgfHwgX3RoaXMkX19jb21wb25lbnRDb25mID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfX2NvbXBvbmVudENvbmZbbmFtZV0pO1xuICAgICAgICAgICAgICAgIHJldHVybiBtZXJnZVByb3BzKChfdGhpcyRfX2NvbXBvbmVudENvbmYyID0gdGhpcy5fX2NvbXBvbmVudENvbmZpZ1Byb3BzKSA9PT0gbnVsbCB8fCBfdGhpcyRfX2NvbXBvbmVudENvbmYyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfX2NvbXBvbmVudENvbmYyW25hbWVdLCB2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gbWVyZ2VQcm9wcygoX3RoaXMkX19jb21wb25lbnRDb25mMyA9IHRoaXMuX19jb21wb25lbnRDb25maWdQcm9wcykgPT09IG51bGwgfHwgX3RoaXMkX19jb21wb25lbnRDb25mMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX19jb21wb25lbnRDb25mM1tuYW1lXSwgdGhpc1trZXldKTtcbiAgICAgICAgfSxcbiAgICAgICAgc2V0KHZhbHVlKSB7XG4gICAgICAgICAgICB2YXIgb2xkVmFsdWUgPSB0aGlzW2tleV07XG4gICAgICAgICAgICBpZiAodmFsdWUgIT09IG9sZFZhbHVlKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNoYW5nZUhhbmRsZXIgPSB0aGlzW1wiX3NldFwiLmNvbmNhdChjYXBpdGFsKG5hbWUpKV07XG4gICAgICAgICAgICAgICAgaWYgKGNoYW5nZUhhbmRsZXIgJiYgdHlwZW9mIGNoYW5nZUhhbmRsZXIgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IGNoYW5nZUhhbmRsZXIuY2FsbCh0aGlzLCB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBuZXdWYWx1ZSA9IGtleSA9PT0gXCJzdHlsZVwiID8gY2xvbmUodGhpc1trZXldLCB2YWx1ZSkgOiB2YWx1ZTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXNba2V5XSA9PT0gXCJvYmplY3RcIiAmJiB0aGlzW2tleV0gIT09IG51bGwgJiYgdGhpc1trZXldLnN0eWxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBzdHlsZSA9IGNsb25lKHRoaXNba2V5XS5zdHlsZSwgdmFsdWUuc3R5bGUgfHwge30pO1xuICAgICAgICAgICAgICAgICAgICBuZXdWYWx1ZS5zdHlsZSA9IHN0eWxlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzW2tleV0gPSBuZXdWYWx1ZTtcbiAgICAgICAgICAgICAgICB0aGlzLnF1ZXVlUmVxdWVzdFVwZGF0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgIGVudW1lcmFibGU6IHRydWVcbiAgICB9O1xufVxuXG5mdW5jdGlvbiBnZXRBbGlhc1Byb3BlcnR5RGVzY3JpcHRvcihwcmV2LCBjdXJyKSB7XG4gICAgdmFyIGRlcHJlY2F0aW9uV2FybmluZyA9ICdUaGUgcHJvcGVydHkgXCInLmNvbmNhdChwcmV2LCAnXCIgaXMgZGVwcmVjYXRlZCBhbmQgd2lsbCBiZSByZW1vdmVkIGluIGEgZnV0dXJlIHJlbGVhc2UuIFBsZWFzZSB1c2UgXCInKS5jb25jYXQoY3VyciwgJ1wiIGluc3RlYWQuJyk7XG4gICAgcmV0dXJuIHtcbiAgICAgICAgZ2V0KCkge1xuICAgICAgICAgICAgY29uc29sZS53YXJuKGRlcHJlY2F0aW9uV2FybmluZyk7XG4gICAgICAgICAgICByZXR1cm4gdGhpc1tjdXJyXTtcbiAgICAgICAgfSxcbiAgICAgICAgc2V0KHZhbHVlKSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4oZGVwcmVjYXRpb25XYXJuaW5nKTtcbiAgICAgICAgICAgIHRoaXNbY3Vycl0gPSB2YWx1ZTtcbiAgICAgICAgfVxuICAgIH07XG59XG5cbmZ1bmN0aW9uIHdpdGhVcGRhdGVzKEJhc2UpIHtcbiAgICByZXR1cm4gY2xhc3MgZXh0ZW5kcyBCYXNlIHtcbiAgICAgICAgc3RhdGljIGdldCBuYW1lKCkge1xuICAgICAgICAgICAgcmV0dXJuIEJhc2UubmFtZTtcbiAgICAgICAgfVxuICAgICAgICBfY29uc3RydWN0KCkge1xuICAgICAgICAgICAgdmFyIHByb3RvdHlwZSA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0aGlzKTtcbiAgICAgICAgICAgIGlmICghcHJvdG90eXBlLl93aXRoVXBkYXRlc0luaXRpYWxpemVkKSB7XG4gICAgICAgICAgICAgICAgdmFyIHByb3BzID0gdGhpcy5jb25zdHJ1Y3Rvci5wcm9wZXJ0aWVzIHx8IFtdO1xuICAgICAgICAgICAgICAgIHByb3BzLmZvckVhY2goKG5hbWUgPT4ge1xuICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0gXCJfXCIgKyBuYW1lO1xuICAgICAgICAgICAgICAgICAgICB2YXIgZGVzY3JpcHRvciA9IGdldFByb3BlcnR5RGVzY3JpcHRvciQxKG5hbWUsIGtleSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkZXNjcmlwdG9yICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShwcm90b3R5cGUsIG5hbWUsIGRlc2NyaXB0b3IpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIHZhciBhbGlhc1Byb3BzID0gdGhpcy5jb25zdHJ1Y3Rvci5hbGlhc1Byb3BlcnRpZXMgfHwgW107XG4gICAgICAgICAgICAgICAgYWxpYXNQcm9wcy5mb3JFYWNoKChhbGlhcyA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChhbGlhcyAmJiB0eXBlb2YgYWxpYXMucHJldiA9PT0gXCJzdHJpbmdcIiAmJiB0eXBlb2YgYWxpYXMuY3VyciA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRlc2NyaXB0b3IgPSBnZXRBbGlhc1Byb3BlcnR5RGVzY3JpcHRvcihhbGlhcy5wcmV2LCBhbGlhcy5jdXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXNjcmlwdG9yICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkocHJvdG90eXBlLCBhbGlhcy5wcmV2LCBkZXNjcmlwdG9yKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICBwcm90b3R5cGUuX3dpdGhVcGRhdGVzSW5pdGlhbGl6ZWQgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fd2hlbkVuYWJsZWQgPSBuZXcgUHJvbWlzZSgocmVzb2x2ZSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5fd2hlbkVuYWJsZWRSZXNvbHZlciA9IHJlc29sdmU7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICBzdXBlci5fY29uc3RydWN0ICYmIHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICAgICAgfVxuICAgICAgICBxdWV1ZVJlcXVlc3RVcGRhdGUoKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX2lzQXR0YWNoZWQoKSkgcmV0dXJuO1xuICAgICAgICAgICAgdXBkYXRlTWFuYWdlci5hZGRSZXF1ZXN0VXBkYXRlKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIF9maXJzdEVuYWJsZSgpIHtcbiAgICAgICAgICAgIHRoaXMuX3JlYWR5Rm9yVXBkYX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VhZHlGb3JVcGRhdGVzIHx8IGZvcmNlKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRoaXMuX3VwZGF0ZSgpO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzdWx0ID09PSBcIm9iamVjdFwiICYmIHJlc3VsdCAhPT0gbnVsbCAmJiByZXN1bHQuY2F0Y2gpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0LmNhdGNoKChlID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHRJbnN0YW5jZS5lcnJvcihcImFzeW5jcm9ub3VzIF91cGRhdGUoKSBlcnJvciBpbiAnXCIuY29uY2F0KHRoaXMuY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lLCBcIidcIiksIHRoaXMsIGUpO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGxvZ1Byb3BUYWJsZSgpIHtcbiAgICAgICAgICAgIGNvbnNvbGUudGFibGUodGhpcy5fcHJvcFRhYmxlKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgX3Byb3BUYWJsZSgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnN0cnVjdG9yLnByb3BlcnRpZXMucmVkdWNlKCgoYWNjLCBwcm9wKSA9PiB7XG4gICAgICAgICAgICAgICAgYWNjW3Byb3BdID0gdGhpc1twcm9wXTtcbiAgICAgICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICAgICAgfSksIHt9KTtcbiAgICAgICAgfVxuICAgIH07XG59XG5cbmZ1bmN0aW9uIGdldFByb3BlcnR5RGVzY3JpcHRvcihwYXRoKSB7XG4gICAgcmV0dXJuIHtcbiAgICAgICAgZ2V0KCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMudGFnKHBhdGgpO1xuICAgICAgICB9LFxuICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgIGVudW1lcmFibGU6IHRydWVcbiAgICB9O1xufVxuXG5mdW5jdGlvbiB3aXRoVGFncyhCYXNlKSB7XG4gICAgcmV0dXJuIGNsYXNzIGV4dGVuZHMgQmFzZSB7XG4gICAgICAgIHN0YXRpYyBnZXQgbmFtZSgpIHtcbiAgICAgICAgICAgIHJldHVybiBCYXNlLm5hbWU7XG4gICAgICAgIH1cbiAgICAgICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgICAgIHZhciBwcm90b3R5cGUgPSBPYmplY3QuZ2V0UHJvdG90eXBlT2YodGhpcyk7XG4gICAgICAgICAgICBpZiAoIXByb3RvdHlwZS5fd2l0aFRhZ3NJbml0aWFsaXplZCkge1xuICAgICAgICAgICAgICAgIHZhciB0YWdzID0gdGhpcy5jb25zdHJ1Y3Rvci50YWdzIHx8IFtdO1xuICAgICAgICAgICAgICAgIHRhZ3MuZm9yRWFjaCgodGFnID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0YWcgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB7bmFtZTogbmFtZSwgcGF0aDogcGF0aH0gPSB0YWc7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgbmFtZSA9IHRhZztcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwYXRoID0gdGFnO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHZhciBrZXkgPSBcIl9cIiArIG5hbWU7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkZXNjcmlwdG9yID0gZ2V0UHJvcGVydHlEZXNjcmlwdG9yKHBhdGgpO1xuICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkocHJvdG90eXBlLCBrZXksIGRlc2NyaXB0b3IpO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICBwcm90b3R5cGUuX3dpdGhUYWdzSW5pdGlhbGl6ZWQgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCAmJiBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG5mdW5jdGlvbiB3aXRoSGFuZGxlS2V5KEJhc2UpIHtcbiAgICByZXR1cm4gY2xhc3MgZXh0ZW5kcyBCYXNlIHtcbiAgICAgICAgc3RhdGljIGdldCBuYW1lKCkge1xuICAgICAgICAgICAgcmV0dXJuIEJhc2UubmFtZTtcbiAgICAgICAgfVxuICAgICAgICBfaGFuZGxlS2V5KGtleUV2ZW50KSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fcHJvY2Vzc0V2ZW50KGtleUV2ZW50KTtcbiAgICAgICAgfVxuICAgICAgICBfaGFuZGxlS2V5UmVsZWFzZShrZXlFdmVudCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3Byb2Nlc3NFdmVudChrZXlFdmVudCwgXCJSZWxlYXNlXCIpO1xuICAgICAgICB9XG4gICAgICAgIF9wcm9jZXNzRXZlbnQoa2V5RXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBzdWZmaXggPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IFwiXCI7XG4gICAgICAgICAgICB2YXIga2V5TWFwID0gdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5fX2tleW1hcCB8fCB7fTtcbiAgICAgICAgICAgIHZhciBrZXkgPSBrZXlNYXBba2V5RXZlbnQua2V5Q29kZV07XG4gICAgICAgICAgICBpZiAoIWtleSkge1xuICAgICAgICAgICAgICAgIGtleSA9IGtleUV2ZW50LmtleTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChrZXkgJiYgdHlwZW9mIHRoaXNbXCJvblwiLmNvbmNhdChrZXkpLmNvbmNhdChzdWZmaXgpXSA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5faW52b2tlS2V5UGF5bG9hZENhbGxiYWNrKGtleSArIHN1ZmZpeCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXNbXCJvblwiLmNvbmNhdChrZXkpLmNvbmNhdChzdWZmaXgpXS5jYWxsKHRoaXMsIHRoaXMsIGtleUV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBfaW52b2tlS2V5UGF5bG9hZENhbGxiYWNrKGtleSkge1xuICAgICAgICAgICAgaWYgKHRoaXMubWV0cmljc1BheWxvYWQgJiYgdHlwZW9mIGNvbnRleHRJbnN0YW5jZS5rZXlNZXRyaWNzQ2FsbGJhY2sgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgIGNvbnRleHRJbnN0YW5jZS5rZXlNZXRyaWNzQ2FsbGJhY2soa2V5LCB0aGlzLm1ldHJpY3NQYXlsb2FkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG59XG5cbmZ1bmN0aW9uIHdpdGhMYXlvdXQoQmFzZSkge1xuICAgIHJldHVybiBjbGFzcyBleHRlbmRzIEJhc2Uge1xuICAgICAgICBfY29uc3RydWN0KCkge1xuICAgICAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCAmJiBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgICAgICB0aGlzLl9wcmV2aW91c0RpbWVuc2lvbkRhdGEgPSBudWxsO1xuICAgICAgICB9XG4gICAgICAgIGdldCBpdGVtTGF5b3V0KCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2l0ZW1MYXlvdXQ7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IGl0ZW1MYXlvdXQodikge1xuICAgICAgICAgICAgdmFyIGNvbXBvbmVudE5hbWUgPSB0aGlzLmNvbnN0cnVjdG9yLl9jb21wb25lbnROYW1lIHx8IHRoaXMuY29uc3RydWN0b3IubmFtZTtcbiAgICAgICAgICAgIHZhciBpdGVtTGF5b3V0O1xuICAgICAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgICAgICBpdGVtTGF5b3V0ID0gSlNPTi5wYXJzZShKU09OLnN0cmluZ2lmeSh2LCAoKGssIHYpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGsgIT09IFwiY2lyY2xlXCIgJiYgdiA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHRJbnN0YW5jZS5lcnJvcihcIml0ZW1MYXlvdXQgZm9yIFwiLmNvbmNhdChjb21wb25lbnROYW1lLCBcIiByZWNlaXZlZCBhbiBpbnZhbGlkIHZhbHVlIG9mIFwiKS5jb25jYXQodiwgXCIgZm9yIFwiKS5jb25jYXQoaykpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGsgPT09IFwiY2lyY2xlXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBCb29sZWFuKHYpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB2O1xuICAgICAgICAgICAgICAgIH0pKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIXN0cmluZ2lmeUNvbXBhcmUodGhpcy5faXRlbUxheW91dCwgaXRlbUxheW91dCkpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXRlbUxheW91dCAmJiAhaXRlbUxheW91dC51cENvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX29yaWdpbmFsVyA9IHRoaXMudztcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3JpZ2luYWxIID0gdGhpcy5oO1xuICAgICAgICAgICAgICAgICAgICB0aGlzL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uIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgX3VwZGF0ZUl0ZW1MYXlvdXQoKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX2FsbG93VXBkYXRlKCkpIHJldHVybjtcbiAgICAgICAgICAgIHZhciB7dzogdywgaDogaH0gPSBnZXREaW1lbnNpb25zKHRoaXMudGhlbWUsIHRoaXMuX2l0ZW1MYXlvdXQpO1xuICAgICAgICAgICAgaWYgKGggfHwgdykge1xuICAgICAgICAgICAgICAgIHZhciB3aWR0aCA9IGNvbnRleHRJbnN0YW5jZS50aGVtZS5sYXlvdXQuc2NyZWVuVztcbiAgICAgICAgICAgICAgICB2YXIgaGVpZ2h0ID0gY29udGV4dEluc3RhbmNlLnRoZW1lLmxheW91dC5zY3JlZW5IO1xuICAgICAgICAgICAgICAgIHZhciBjYWxjdWxhdGVkV2lkdGggPSB3IHx8IGggKiAod2lkdGggLyBoZWlnaHQpO1xuICAgICAgICAgICAgICAgIHZhciBjYWxjdWxhdGVkSGVpZ2h0ID0gaCB8fCB3ICogKGhlaWdodCAvIHdpZHRoKTtcbiAgICAgICAgICAgICAgICB0aGlzLncgPSB0aGlzLl9pdGVtTGF5b3V0ICYmIHRoaXMuX2l0ZW1MYXlvdXQuY2lyY2xlID8gY2FsY3VsYXRlZEhlaWdodCA6IGNhbGN1bGF0ZWRXaWR0aDtcbiAgICAgICAgICAgICAgICB0aGlzLmggPSBjYWxjdWxhdGVkSGVpZ2h0O1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pdGVtTGF5b3V0ICYmIHRoaXMuX2l0ZW1MYXlvdXQuY2lyY2xlICYmIHRoaXMuc3R5bGUucmFkaXVzKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NpcmNsZVNldCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX29yaWdpbmFsUmFkaXVzID0gdGhpcy5zdHlsZS5yYWRpdXM7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGUgPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmFkaXVzOiBjYWxjdWxhdGVkSGVpZ2h0IC8gMlxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2NpcmNsZVNldCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnN0eWxlID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJhZGl1czogdGhpcy5fb3JpZ2luYWxSYWRpdXNcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX29yaWdpbmFsUmFkaXVzID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaXJjbGVTZXQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5xdWV1ZVJlcXVlc3RVcGRhdGUgJiYgdGhpcy5xdWV1ZVJlcXVlc3RVcGRhdGUoKTtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkaXRlbUNoYW5nZWRcIik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG52YXIgZ2V0Q2hhcmFjdGVyVmFsdWUgPSAoY2hhciwgaW5kZXgpID0+IGNoYXIuY2hhckNvZGVBdCgwKSAqIChpbmRleCArIDEpO1xuXG52YXIgc29ydE9iamVjdCA9IG9iaiA9PiB7XG4gICAgdmFyIHNvcnRlZE9iaiA9IHt9O1xuICAgIE9iamVjdC5rZXlzKG9iaikuc29ydCgpLmZvckVhY2goKGtleSA9PiB7XG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1bmN0aW9uIGNyZWF0ZVNoYXJlZFJlZmVyZW5jZXMoKSB7XG4gICAgdmFyIG9iaiA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307XG4gICAgdmFyIHNlZW5PYmplY3RzID0gbmV3IE1hcDtcbiAgICBmdW5jdGlvbiBoYXNoKG9iamVjdCkge1xuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkob2JqZWN0LCBPYmplY3Qua2V5cyhvYmplY3QpLnNvcnQoKSk7XG4gICAgfVxuICAgIGZ1bmN0aW9uIHByb2Nlc3MoY3VycmVudE9iaikge1xuICAgICAgICBmb3IgKHZhciBrZXkgaW4gY3VycmVudE9iaikge1xuICAgICAgICAgICAgaWYgKGN1cnJlbnRPYmouaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IGN1cnJlbnRPYmpba2V5XTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSBcIm9iamVjdFwiICYmIHZhbHVlICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB2YWx1ZUhhc2ggPSBoYXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNlZW5PYmplY3RzLmhhcyh2YWx1ZUhhc2gpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50T2JqW2tleV0gPSBzZWVuT2JqZWN0cy5nZXQodmFsdWVIYXNoKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlZW5PYmplY3RzLnNldCh2YWx1ZUhhc2gsIHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3ModmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgIC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ob2JqKSB7XG4gICAgICAgIGlmICh0eXBlb2Ygb2JqID09PSBcIm9iamVjdFwiICYmIG9iaiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgZm9yICh2YXIga2V5IGluIG9iaikge1xuICAgICAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoa2V5ID09PSBrZXlUb0ZpbmQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaE5lc3RlZEtleXMob2JqW2tleV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgc2VhcmNoRm9yS2V5KG9ialtrZXldKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgc2VhcmNoRm9yS2V5KG9iaik7XG4gICAgcmV0dXJuIG5lc3RlZEtleXM7XG59XG5cbnZhciBnZW5lcmF0ZVNvbHV0aW9uID0gZnVuY3Rpb24gZ2VuZXJhdGVTb2x1dGlvbihfcmVmNykge1xuICAgIHZhciB7YmFzZTogYmFzZSA9IHt9LCB0b25lOiB0b25lID0ge30sIG1vZGU6IG1vZGUgPSB7fSwgZGVmYXVsdFN0eWxlOiBkZWZhdWx0U3R5bGUgPSB7fX0gPSBfcmVmNztcbiAgICB2YXIgbW9kZUtleXMgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IFtdO1xuICAgIHZhciB0b25lS2V5cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogW107XG4gICAgdmFyIHNvbHV0aW9uID0ge307XG4gICAgdmFyIHVuaXF1ZU1vZGVzID0gZ2V0VW5pcX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LmtleXMoaW5wdXRPYmopIF0pIHtcbiAgICAgICAgaWYgKCFpbnB1dE9iai5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICB2YXIgZmFsbGJhY2tLZXkgPSBERUZBVUxUX0tFWVMuZmluZCgoZmFsbGJhY2sgPT4gaW5wdXRPYmouaGFzT3duUHJvcGVydHkoZmFsbGJhY2spKSk7XG4gICAgICAgICAgICBpZiAoZmFsbGJhY2tLZXkpIHtcbiAgICAgICAgICAgICAgICB2YXIgZmFsbGJhY2sgPSBpbnB1dE9ialtmYWxsYmFja0tleV07XG4gICAgICAgICAgICAgICAgcmVzdWx0W2tleV0gPSB0eXBlb2YgZmFsbGJhY2sgIT09IFwib2JqZWN0XCIgPyB7fSA6IGZhbGxiYWNrO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXN1bHRba2V5XSA9IHt9O1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBpbnB1dE9ialtrZXldICE9PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0W2tleV0gPSB7fTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0W2tleV0gPSBpbnB1dE9ialtrZXldO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIHJldHVybiByZXN1bHQ7XG59XG5cbnZhciBnZW5lcmF0ZUNvbXBvbmVudFN0eWxlU291cmNlID0gZnVuY3Rpb24gZ2VuZXJhdGVDb21wb25lbnRTdHlsZVNvdXJjZSgpIHtcbiAgICB2YXIge3RoZW1lOiB0aGVtZSA9IHt9LCBzdHlsZUNoYWluOiBzdHlsZUNoYWluID0gW10sIGlubGluZVN0eWxlOiBpbmxpbmVTdHlsZSA9IHt9LCBhbGlhczogYWxpYXMgPSBbXX0gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAm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RlID0ge30sIHRvbmU6IF90b25lID0ge319ID0gc3R5bGU7XG4gICAgICAgICAgICB2YXIgY29tcG9uZW50Q29uZmlnRGVmYXVsdFN0eWxlO1xuICAgICAgICAgICAgaWYgKHN0eWxlKSB7XG4gICAgICAgICAgICAgICAgdmFyIGRlZmF1bHRTdHlsZSA9IEpTT04ucGFyc2UoSlNPTi5zdHJpbmdpZnkoc3R5bGUpKTtcbiAgICAgICAgICAgICAgICBkZWxldGUgZGVmYXVsdFN0eWxlLmJhc2U7XG4gICAgICAgICAgICAgICAgZGVsZXRlIGRlZmF1bHRTdHlsZS50b25lO1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBkZWZhdWx0U3R5bGUubW9kZTtcbiAgICAgICAgICAgICAgICBjb21wb25lbnRDb25maWdEZWZhdWx0U3R5bGUgPSBkZWZhdWx0U3R5bGU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIGRlZmF1bHRTdHlsZTogY29tcG9uZW50Q29uZmlnRGVmYXVsdFN0eWxlIHx8IHt9LFxuICAgICAgICAgICAgICAgIGJhc2U6IF9iYXNlLFxuICAgICAgICAgICAgICAgIG1vZGU6IF9tb2RlLFxuICAgICAgICAgICAgICAgIHRvbmU6IF90b25lXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfSkpO1xuICAgIHZhciBsb2NhbERlZmF1bHRTdHlsZTtcbiAgICBpZiAoaW5saW5lU3R5bGUpIHtcbiAgICAgICAgdmFyIGRlZmF1bHRTdHlsZSA9IEpTT04ucGFyc2UoSlNPTi5zdHJpbmdpZnkoaW5saW5lU3R5bGUpKTtcbiAgICAgICAgZGVsZXRlIGRlZmF1bHRTdHlsZS5iYXNlO1xuICAgICAgICBkZWxldGUgZGVmYXVsdFN0eWxlLnRvbmU7XG4gICAgICAgIGRlbGV0ZSBkZWZhdWx0U3R5bGUubW9kZTtcbiAgICAgICAgbG9jYWxEZWZhdWx0U3R5bGUgP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FwLmhhcyhjb21wb25lbnRDb25maWdTdHlsZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGVNYXAuc2V0KGNvbXBvbmVudENvbmZpZ1N0eWxlLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZTogY29tcG9uZW50Q29uZmlnU3R5bGVcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHRoZW1lU3R5bGUgPSBwcm90by5jb25zdHJ1Y3Rvci5oYXNPd25Qcm9wZXJ0eShcIl9fdGhlbWVTdHlsZVwiKSAmJiBwcm90by5jb25zdHJ1Y3Rvci5fX3RoZW1lU3R5bGU7XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXModGhlbWVTdHlsZSB8fCB7fSkubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFzdHlsZU1hcC5oYXModGhlbWVTdHlsZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGVNYXAuc2V0KHRoZW1lU3R5bGUsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKHt9LCB0aGVtZVN0eWxlKVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB0aGVtZVN0eWxlID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXN0eWxlTWFwLmhhcyh0aGVtZVN0eWxlKSkge1xuICAgICAgICAgICAgICAgICAgICBzdHlsZU1hcC5zZXQodGhlbWVTdHlsZSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHRoZW1lU3R5bGVcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIG1peGluU3R5bG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dGluZyA9PT0gdm9pZCAwID8gdm9pZCAwIDogZXhpc3RpbmcuaWRzKSB8fCBbXSwgdGhpcy5jb21wb25lbnQuX19pZCBdKSBdLFxuICAgICAgICAgICAgcGF5bG9hZDogcGF5bG9hZFxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX2NsZWFudXBDYWNoZSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmNvbXBvbmVudCkgcmV0dXJuO1xuICAgICAgICBjYWNoZS5mb3JFYWNoKCgoX3JlZjEwLCBuYW1lKSA9PiB7XG4gICAgICAgICAgICB2YXIge2lkczogaWRzLCBwYXlsb2FkOiBwYXlsb2FkfSA9IF9yZWYxMDtcbiAgICAgICAgICAgIHZhciByZW1vdmVJbmRleCA9IGlkcyAmJiBpZHMubGVuZ3RoICYmIGlkcy5pbmRleE9mKHRoaXMuY29tcG9uZW50Ll9faWQpO1xuICAgICAgICAgICAgaWYgKHJlbW92ZUluZGV4ID4gLTEgJiYgaWRzLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgICAgICBjYWNoZS5zZXQobmFtZSwge1xuICAgICAgICAgICAgICAgICAgICBpZHM6IGlkcy5zbGljZSgwLCByZW1vdmVJbmRleCkuY29uY2F0KGlkcy5zbGljZShyZW1vdmVJbmRleCArIDEpKSxcbiAgICAgICAgICAgICAgICAgICAgcGF5bG9hZDogcGF5bG9hZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChyZW1vdmVJbmRleCA+IC0xKSB7XG4gICAgICAgICAgICAgICAgY2FjaGUuZGVsZXRlKG5hbWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF9yZW1vdmVDYWNoZShuYW1lKSB7XG4gICAgICAgIGNhY2hlLmRlbGV0ZShuYW1lKTtcbiAgICB9XG4gICAgX2dldENhY2hlKG5hbWUpIHtcbiAgICAgICAgdmFyIGtleSA9IHRoaXMuX2dlbmVyYXRlQ2FjaGVL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AgICB9XG4gICAgICAgIHN0YXRpYyBnZXQgX19taXhpblN0eWxlKCkge1xuICAgICAgICAgICAgcmV0dXJuIG1peGluU3R5bGU7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IHRoZW1lKCkge1xuICAgICAgICAgICAgdmFyIHN1YlRoZW1lID0gdGhpcy5fdGFyZ2V0U3ViVGhlbWUgJiYgY29udGV4dEluc3RhbmNlLmdldFN1YlRoZW1lKHRoaXMuX3RhcmdldFN1YlRoZW1lKTtcbiAgICAgICAgICAgIHJldHVybiBzdWJUaGVtZSB8fCBjb250ZXh0SW5zdGFuY2UudGhlbWU7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IHN0eWxlKHYpIHtcbiAgICAgICAgICAgIGlmIChPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwodikgIT09IFwiW29iamVjdCBPYmplY3RdXCIpIHtcbiAgICAgICAgICAgICAgICBjb250ZXh0SW5zdGFuY2UuZXJyb3IoXCJzdHlsZSBtdXN0IGJlIGFuIG9iamVjdFwiKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9jb21wb25lbnRMZXZlbFN0eWxlID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci5jbGVhclN0eWxlQ2FjaGUoKTtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci51cGRhdGUoKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgc3R5bGUoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc3R5bGU7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9jb21wb25lbnRTdHlsZSgpIHtcbiAgICAgICAgICAgIGNvbnRleHRJbnN0YW5jZS5pbmZvKFwiX2NvbXBvbmVudFN0eWxlIHdpbGwgc29vbiBiZSBkZXByZWNhdGVkLiBQbGVhc2UgdXNlIENvbXBvbmVudC5zdHlsZVwiKTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHlsZTtcbiAgICAgICAgfVxuICAgICAgICBzZXQgc3R5bGVDb25maWcodikge1xuICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmluZm8oXCJzdHlsZSBjb25maWcgaXMgZGVwcmVjYXRlZC4gUGxlYXNlIHVzZSBzdHlsZSA9IHsgYmFzZToge30sIHRvbmU6IHt9LCBtb2RlOiB7fSB9XCIpO1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVDb25maWcgPSB2O1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVNYW5hZ2VyLnVwZGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBzdHlsZUNvbmZpZygpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHlsZUNvbmZpZztcbiAgICAgICAgfVxuICAgICAgICBnZXQgX2NvbXBvbmVudENvbmZpZygpIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRDb21wb25lbnRDb25maWcodGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IG1vZGUoKSB7XG4gICAgICAgICAgICB2YXIgX3RoaXMkX2NvbXBvbmVudENvbmZpO1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21vZGUgfHwgKChfdGhpcyRfY29tcG9uZW50Q29uZmkgPSB0aGlzLl9jb21wb25lbnRDb25maWcpID09PSBudWxsIHx8IF90aGlzJF9jb21wb25lbnRDb25maSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2NvbXBvbmVudENvbmZpLm1vZGUpIHx8IFwidW5mb2N1c2VkXCI7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IG1vZGUodikge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB2ICE9PSBcInN0cmluZ1wiIHx8IHRoaXMuX21vZGUgPT09IHYpIHJldHVybjtcbiAgICAgICAgICAgIHRoaXMuX21vZGUgPSB2O1xuICAgICAgICAgICAgdmFyIGV2ZW50ID0gdGhpc1tcIm9uXCIuY29uY2F0KGNhcGl0YWxpemVGaXJzdExldHRlcih2KSldO1xuICAgICAgICAgICAgaWYgKGV2ZW50ICYmIHR5cGVvZiBldmVudCA9PT0gXCJmdW5jdGlvblwiKSBldmVudC5jYWxsKHRoaXMpO1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVNYW5hZ2VyLnVwZGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCB0b25lKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RvbmUgfHwgdGhpcy5fY29tcG9uZW50Q29uZmlnLnRvbmUgfHwgXCJuZXV0cmFsXCI7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IHRvbmUodikge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB2ICE9PSBcInN0cmluZ1wiIHx8IHRoaXMuX3RvbmUgPT09IHYpIHJldHVybjtcbiAgICAgICAgICAgIHRoaXMuX3RvbmUgPSB2O1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVNYW5hZ2VyLnVwZGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCB3KCkge1xuICAgICAgICAgICAgdmFyIF90aGlzJHN0eWxlO1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3dTZXRCeVVzZXIgJiYgdGhpcy5fdyB8fCAoKF90aGlzJHN0eWxlID0gdGhpcy5zdHlsZSkgPT09IG51bGwgfHwgX3RoaXMkc3R5bGUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJHN0eWxlLncpIHx8IDA7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IHcodikge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3cgPT09IHYpIHJldHVybjtcbiAgICAgICAgICAgIHN1cGVyLncgPSB2O1xuICAgICAgICAgICAgdGhpcy5fd1NldEJ5VXNlciA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVUaGVtZUNvbXBvbmVudCgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBoK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mcgdG8gd29yayBwcm9wZXJseS4gUGxlYXNlIGFkZCB0aGlzIHRvIHRoZSBcIi5jb25jYXQodGhpcy5jb25zdHJ1Y3Rvci5uYW1lLCBcIiBjbGFzcy5cIikpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHN1cGVyLl9fY29tcG9uZW50TmFtZTtcbiAgICAgICAgfVxuICAgICAgICBzdGF0aWMgZ2V0IF93aXRoRXh0ZW5zaW9uc0FwcGxpZWQoKSB7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgX3Byb3RvdHlwZUNoYWluKCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX19wcm90b3R5cGVDaGFpbikgcmV0dXJuIHRoaXMuX19wcm90b3R5cGVDaGFpbjtcbiAgICAgICAgICAgIHZhciBwcm90b3R5cGVDaGFpbiA9IG5ldyBTZXQ7XG4gICAgICAgICAgICB2YXIgcHJvdG8gPSB0aGlzO1xuICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIHByb3RvID0gT2JqZWN0LmdldFByb3RvdHlwZU9mKHByb3RvKTtcbiAgICAgICAgICAgICAgICBpZiAobnVsbCAhPT0gcHJvdG8gJiYgdHlwZW9mIHByb3RvID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJvdG8uY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lKSBwcm90b3R5cGVDaGFpbi5hZGQocHJvdG8uY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHt9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSB3aGlsZSAocHJvdG8pO1xuICAgICAgICAgICAgdGhpcy5fX3Byb3RvdHlwZUNoYWluID0gcHJvdG90eXBlQ2hhaW47XG4gICAgICAgICAgICByZXR1cm4gcHJvdG90eXBlQ2hhaW47XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9leHRlbnNpb25zKCkge1xuICAgICAgICAgICAgdmFyIGV4dGVuc2lvbnMgPSBjb250ZXh0SW5zdGFuY2UgJiYgY29udGV4dEluc3RhbmNlLnRoZW1lICYmIGNvbnRleHRJbnN0YW5jZS50aGVtZS5leHRlbnNpb25zO1xuICAgICAgICAgICAgaWYgKCFleHRlbnNpb25zIHx8ICFBcnJheS5pc0FycmF5KGV4dGVuc2lvbnMpIHx8IEFycmF5LmlzQXJyYXkoZXh0ZW5zaW9ucykgJiYgIWV4dGVuc2lvbnMubGVuZ3RoKSByZXR1cm4gW107XG4gICAgICAgICAgICByZXR1cm4gZXh0ZW5zaW9ucy5maWx0ZXIoKF9yZWYxMSA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIHt0YXJnZXRDb21wb25lbnQ6IHRhcmdldENvbXBvbmVudCwgZXh0ZW5zaW9uOiBleHRlbnNpb259ID0gX3JlZjExO1xuICAgICAgICAgICAgICAgIHJldHVybiAodHlwZW9mIHRhcmdldENvbXBvbmVudCA9PT0gXCJzdHJpbmdcIiB8fCBBcnJheS5pc0FycmF5KHRhcmdldENvbXBvbmVudCkpICYmIHR5cGVvZiBleHRlbnNpb24gPT09IFwiZnVuY3Rpb25cIjtcbiAgICAgICAgICAgIH0pKS5zbGljZSgpLnJldmVyc2UoKSB8fCBbXTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgX2NvbXBvbmVudEV4dGVuc2lvbnMoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fZXh0ZW5zaW9ucy5maWx0ZXIoKF9yZWYxMiA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIHt0YXJnZXRDb21wb25lbnQ6IHRhcmdldENvbXBvbmVudH0gPSBfcmVmMTI7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0YXJnZXRDb21wb25lbnQgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhcmdldENvbXBvbmVudCA9PT0gdGhpcy5jb25zdHJ1Y3Rvci5fX2NvbXBvbmVudE5hbWUgfHwgdGhpcy5fcHJvdG90eXBlQ2hhaW4uaGFzKHRhcmdldENvbXBvbmVudCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KHRhcmdldENvbXBvbmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhcmdldENvbXBvbmVudC5maW5kKChwYXR0ZXJuID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXR0ZXJuLnN0YXJ0c1dpdGgoXCIvXCIpICYmIHBhdHRlcm4uZW5kc1dpdGgoXCIvXCIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIENvbXBvbmVudFJlZ0V4cCA9IG5ldyBSZWdFeHAocGF0dGVybi5zbGljZSgxLCAtMSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBBcnJheS5mcm9tKHRoaXMuX3Byb3RvdHlwZUNoYWluKS5zb21lKChuYW1lID0+IENvbXBvbmVudFJlZ0V4cC50ZXN0KG5hbWUpKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wcm90b3R5cGVDaGFpbi5oYXMocGF0dGVybik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfSkpLnJlZHVjZSgoKGFjYywgX3JlZjEzKSA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIHtleHRlbnNpb246IGV4dGVuc2lvbn0gPSBfcmVmMTM7XG4gICAgICAgICAgICAgICAgYWNjLnB1c2goZX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gICAgICAgICAgICBleHRlbmRlZFtwcm9wXSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBcImFjY2Vzc29yXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiBnZXQoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzW3Byb3AgKyBTVUZGSVhdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbiBzZXQodikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW3Byb3AgKyBTVUZGSVhdID0gdjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGV4dGVuZGVkW3Byb3BdID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogXCJtZXRob2RcIlxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gdmFsdWUoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpc1twcm9wICsgU1VGRklYXSAmJiB0aGlzW3Byb3AgKyBTVUZGSVhdKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwge30pO1xuICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoYmFzZVByb3RvLCBleHRlbnNpb25PdmVycmlkZXMpO1xuICAgICAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKGJhc2VQcm90bywgdGhpcyk7XG4gICAgICAgICAgICByZXR1cm4gZXh0ZW5kZWQ7XG4gICAgICAgIH1cbiAgICAgICAgX3NldENvbXBvbmVudEFsaWFzZXMoYWxpYXNPYmopIHtcbiAgICAgICAgICAgIE9iamVjdC5rZXlzKGFsaWFzT2JqKS5mb3JFYWNoKChwcm9wID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzW3Byb3AgKyBTVUZGSVhdID0gdGhpc1twcm9wXTtcbiAgICAgICAgICAgICAgICBpZiAoYWxpYXNPYmpbcHJvcF0udHlwZSA9PT0gXCJtZXRob2RcIikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzW3Byb3BdID0gdGhpcy5fZXh0ZW5zaW9uSW5zdGFuY2VbcHJvcF07XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChhbGlhc09ialtwcm9wXS50eXBlID09PSBcImFjY2Vzc29yXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsIHByb3AsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGdldCgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZXh0ZW5zaW9uSW5zdGFuY2VbcHJvcF07XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0KHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9leHRlbnNpb25JbnN0YW5jZVtwcm9wXSA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgIC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ZSB7XG4gICAgY29uc3RydWN0b3Ioc3RhZ2UpIHtcbiAgICAgICAgc3VwZXIoc3RhZ2UpO1xuICAgICAgICB0aGlzLl9zcmMgPSB1bmRlZmluZWQ7XG4gICAgICAgIHRoaXMuX2hhc0FscGhhID0gZmFsc2U7XG4gICAgfVxuICAgIGdldCBzcmMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zcmM7XG4gICAgfVxuICAgIHNldCBzcmModikge1xuICAgICAgICBpZiAodGhpcy5fc3JjICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9zcmMgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGdldCBoYXNBbHBoYSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2hhc0FscGhhO1xuICAgIH1cbiAgICBzZXQgaGFzQWxwaGEodikge1xuICAgICAgICBpZiAodGhpcy5faGFzQWxwaGEgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2hhc0FscGhhID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBnZXQgdygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3c7XG4gICAgfVxuICAgIHNldCB3KGwpIHtcbiAgICAgICAgdGhpcy5fdyA9IGw7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICB9XG4gICAgZ2V0IGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oO1xuICAgIH1cbiAgICBzZXQgaChsKSB7XG4gICAgICAgIHRoaXMuX2ggPSBsO1xuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgfVxuICAgIF9nZXRJc1ZhbGlkKCkge1xuICAgICAgICByZXR1cm4gISF0aGlzLl9zcmM7XG4gICAgfVxuICAgIF9nZXRMb29rdXBJZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NyYztcbiAgICB9XG4gICAgX2dldFNvdXJjZUxvYWRlcigpIHtcbiAgICAgICAgdmFyIHcgPSB0aGlzLl93O1xuICAgICAgICB2YXIgaCA9IHRoaXMuX2g7XG4gICAgICAgIHZhciBzcmMgPSB0aGlzLl9zcmM7XG4gICAgICAgIHZhciBoYXNBbHBoYSA9IHRoaXMuX2hhc0FscGhhO1xuICAgICAgICBpZiAodGhpcy5zdGFnZS5nZXRPcHRpb24oXCJzcmNCYXNlUGF0aFwiKSkge1xuICAgICAgICAgICAgdmFyIGZjID0gc3JjLmNoYXJDb2RlQXQoMCk7XG4gICAgICAgICAgICBpZiAoc3JjLmluZGV4T2YoXCIvL1wiKSA9PT0gLTEgJiYgKGZjID49IDY1ICYmIGZjIDw9IDkwIHx8IGZjID49IDk3ICYmIGZjIDw9IDEyMiB8fCBmYyA9PSA0NikpIHtcbiAgICAgICAgICAgICAgICBzcmMgPSB0aGlzLnN0YWdlLmdldE9wdGlvbihcInNyY0Jhc2VQYXRoXCIpICsgc3JjO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjYiA9PiB7XG4gICAgICAgICAgICB2YXIgZmlsZVR5cGUgPSBjaGVja0ZpbGVUeXBlKHNyYyk7XG4gICAgICAgICAgICBzd2l0Y2ggKGZpbGVUeXBlKSB7XG4gICAgICAgICAgICAgIGNhc2UgXCJTVkdcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlU3ZnKGNiLCB0aGlzLnN0YWdlLCBcImRhdGE6aW1hZ2Uvc3ZnK3htbCxcIi5jb25jYXQoZW5jb2RlVVJJQ29tcG9uZW50KHNyYykpLCB3LCBoKTtcblxuICAgICAgICAgICAgICBjYXNlIFwiQmxvYlwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBpbWFnZUxvYWRlcih7XG4gICAgICAgICAgICAgICAgICAgIHNyYzogc3JjXG4gICAgICAgICAgICAgICAgfSwgY2IpO1xuXG4gICAgICAgICAgICAgIGRl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bXBvbmVudFNyYy5yZXNvbHZlKCk7XG4gICAgICAgIHRoaXMuc2lnbmFsKFwiaW1hZ2VMb2FkZWRcIik7XG4gICAgfVxuICAgIF9yZWplY3RMb2FkaW5nKGVycm9yKSB7XG4gICAgICAgIHRoaXMuX2NvbXBvbmVudFNyYy5yZWplY3QgJiYgdGhpcy5fY29tcG9uZW50U3JjLnJlamVjdChlcnJvcik7XG4gICAgICAgIHRoaXMuc2lnbmFsKFwiaW1hZ2VMb2FkRmFpbGVkXCIpO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB2YXIgX3RoaXM1ID0gdGhpcztcbiAgICAgICAgcmV0dXJuIF9hc3luY1RvR2VuZXJhdG9yKChmdW5jdGlvbiooKSB7XG4gICAgICAgICAgICBfdGhpczUuX3VwZGF0ZVJhZGl1cygpO1xuICAgICAgICAgICAgX3RoaXM1Ll91cGRhdGVHcmFkaWVudCgpO1xuICAgICAgICAgICAgeWllbGQgX3RoaXM1Ll91cGRhdGVJbWFnZSgpO1xuICAgICAgICAgICAgX3RoaXM1Ll91cGRhdGVGaWxsQ29sb3IoKTtcbiAgICAgICAgICAgIF90aGlzNS5fdXBkYXRlRm9yZWdyb3VuZEltYWdlKCk7XG4gICAgICAgICAgICBpZiAoIV90aGlzNS5zcmMpIHtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3Nob3dDb21wb25lbnQoKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHlpZWxkIF90aGlzNS5fY29tcG9uZW50U3JjLmNvbXBsZXRlO1xuICAgICAgICAgICAgICAgIHlpZWxkIF90aGlzNS5fdXBkYXRlQ2VudGVySW1hZ2UoKTtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3VwZGF0ZUJsdXIoKTtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3Nob3dDb21wb25lbnQoKTtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3VwZGF0ZVNjYWxlKCk7XG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgX3RoaXM1Ll9oYW5kbGVJbWFnZUxvYWRFcnJvcigpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKF90aGlzNS5zaG91bGRTbW9vdGggPT09IHVuZGVmaW5lZCkgX3RoaXM1LnNob3VsZFNtb290aCA9IHRydWU7XG4gICAgICAgIH0pKSgpO1xuICAgIH1cbiAgICBfdXBkYXRlU2NhbGUoKSB7XG4gICAgICAgIGlmICh0aGlzLnNob3VsZFNjYWxlKSB7XG4gICAgICAgICAgICB2YXIgaW1hZ2VTY2FsZTtcbiAgICAgICAgICAgIHN3aXRjaCAodHlwZW9mIHRoaXMuc3R5bGUuaW1hZ2VTY2FsZSkge1xuICAgICAgICAgICAgICBjYXNlIFwiZnVuY3Rpb25cIjpcbiAgICAgICAgICAgICAgICBpbWFnZVNjYWxlID0gdGhpcy5zdHlsZS5pbWFnZVNjYWxlKHRoaXMudyk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSBcIm51bWJlclwiOlxuICAgICAgICAgICAgICAgIGltYWdlU2NhbGUgPSB0aGlzLnN0eWxlLmltYWdlU2NhbGU7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICBpbWFnZVNjYWxlID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX0ltYWdlLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICBwaXZvdFg6IHRoaXMuc3R5bGUuaW1hZ2VTY2FsZVBpdm90WCxcbiAgICAgICAgICAgICAgICBwaXZvdFk6IHRoaXMuc3R5bGUuaW1hZ2VTY2FsZVBpdm90WSxcbiAgICAgICAgICAgICAgICBzY2FsZTogWyBpbWFnZVNjYWxlLCB0aGlzLl9JbWFn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bmN0aW9uKigpIHtcbiAgICAgICAgICAgIGlmICghX3RoaXM2Ll9mb3JlZ3JvdW5kU3JjKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzNi5fRm9yZWdyb3VuZEltYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzNi5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBGb3JlZ3JvdW5kSW1hZ2U6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGZvcmVncm91bmRJbWFnZVBhdGNoID0ge1xuICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICB4OiBfdGhpczYudyAvIDIsXG4gICAgICAgICAgICAgICAgeTogX3RoaXM2LmggLyAyLFxuICAgICAgICAgICAgICAgIHpJbmRleDogX3RoaXM2LmNvcmUuZmluZFpDb250ZXh0KCkuekluZGV4ICsgX3RoaXM2LnN0eWxlLnpJbmRleFNldC5mb3JlZ3JvdW5kLFxuICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQ3VzdG9tSW1hZ2VUZXh0dXJlLFxuICAgICAgICAgICAgICAgICAgICBzcmM6IF90aGlzNi5fZm9yZWdyb3VuZFNyYyxcbiAgICAgICAgICAgICAgICAgICAgaGFzQWxwaGE6IHRydWVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKF90aGlzNi5mb3JlZ3JvdW5kV2lkdGggJiYgX3RoaXM2LmZvcmVncm91bmRIZWlnaHQpIHtcbiAgICAgICAgICAgICAgICBmb3JlZ3JvdW5kSW1hZ2VQYXRjaC5oID0gX3RoaXM2LmZvcmVncm91bmRIZWlnaHQ7XG4gICAgICAgICAgICAgICAgZm9yZWdyb3VuZEltYWdlUGF0Y2gudyA9IF90aGlzNi5mb3JlZ3JvdW5kV2lkdGg7XG4gICAgICAgICAgICAgICAgX3RoaXM2LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgRm9yZWdyb3VuZEltYWdlOiBmb3JlZ3JvdW5kSW1hZ2VQYXRjaFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChfdGhpczYuZm9yZWdyb3VuZFdpZHRoIHx8IF90aGlzNi5mb3JlZ3JvdW5kSGVpZ2h0KSB7XG4gICAgICAgICAgICAgICAgX3RoaXM2LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgRm9yZWdyb3VuZEltYWdlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGZvcmVncm91bmRJbWFnZVBhdGNoKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFscGhhOiAuMDAxXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgX3RoaXM2Ll9Gb3JlZ3JvdW5kSW1hZ2Uub25jZShcInR4TG9hZGVkXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbWFnZVcgPSBfdGhpczYuX0ZvcmVncm91bmRJbWFnZS50ZXh0dXJlLmdldFJlbmRlcldpZHRoKCk7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbWFnZUggPSBfdGhpczYuX0ZvcmVncm91bmRJbWFnZS50ZXh0dXJlLmdldFJlbmRlckhlaWdodCgpO1xuICAgICAgICAgICAgICAgICAgICBfdGhpczYuX0ZvcmVncm91bmRJbWFnZS5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogMSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHc6IF90aGlzNi5mb3JlZ3JvdW5kSGVpZ2h0ID8gX3RoaXM2LmZvcmVncm91bmRIZWlnaHQgKiAoaW1hZ2VXIC8gaW1hZ2VIKSA6IF90aGlzNi5mb3JlZ3JvdW5kV2lkdGgsXG4gICAgICAgICAgICAgICAgICAgICAgICBoOiBfdGhpczYuZm9yZWdyb3VuZFdpZHRoID8gX3RoaXM2LmZvcmVncm91bmRXaWR0aCAqIChpbWFnZUggLyBpbWFnZVcpIDogX3RoaXM2LmZvcmVncm91bmRIZWlnaHRcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX3RoaXM2LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBGb3JlZ3JvdW5kSW1hZ2U6IGZvcmVncm91bmRJbWFnZVBhdGNoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSkpKCk7XG4gICAgfVxuICAgIF91cGRhdGVCbHVyKCkge1xuICAgICAgICBpZiAoKCF0aGlzLl9zaG91bGRCbHVyIHx8IHRoaXMuX0ltYWdlICYmIHRoaXMuX0ltYWdlLnRleHR1cmUgJiYgdGhpcy5fSW1hZ2UudGV4dHVyZS5zcmMgPT09IHRoaXMuZmFsbGJhY2tTcmMpICYmIHRoaXMuX0JsdXIpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnNob3VsZFNtb290aCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX0JsdXIuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgQmx1cjogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9CbHVyLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IFsgMCwgdGhpcy5zdHlsZS5hbmltYXRpb25CbHVyRXhpdCBdXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIEJsdXI6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fc3JjRmFpbGVkICYmIHRoaXMuX3Nob3VsZEJsdXIpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIEJsdXI6IHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6ICF0aGlzLl9CbHVyICYmIHRoaXMuc2hvdWxkU21vb3RoID8gLjAwMSA6IDEsXG4gICAgICAgICAgICAgICAgICAgIGFtb3VudDogdGhpcy5zdHlsZS5ibHVyLFxuICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IHRoaXMuY29yZS5maW5kWkNvbnRleHQoKS56SW5kZXggKyB0aGlzLnN0eWxlLnpJbmRleFNldC5ibHVyLFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBJbWFnZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0dXJlOiB0aGlzLl9JbWFnZS5nZXRUZXh0dXJlKCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdzogdGhpcy53XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICAgICAgcnR0OiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBsbmcuY29tcG9uZW50cy5GYXN0Qmx1ckNvbXBvbmVudCxcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy53XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAodGhpcy5fQmx1ci5hbHBoYSA8IDEpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9CbHVyLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IFsgMSwgdGhpcy5zdHlsZS5hbmltYXRpb25CbHVyRW50cmFuY2UgXVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUNlbnRlckltYWdlKCkge1xuICAgICAgICBpZiAodGhpcy5mb3JtYXQgPT09IFwiY29udGFpblwiKSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVGb3JtYXRDb250YWluKCk7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5mb3JtYXQgPT09IFwiY2lyY2xlXCIgfHwgdGhpcy5mb3JtYXQgPT09IFwic3F1YXJlXCIpIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUZvcm1hdFNxdWFyZUNpcmNsZSgpO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX0NlbnRlckltYWdlKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBDZW50ZXJJbWFnZTogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlRm9ybWF0Q29udGFpbigpIHtcbiAgICAgICAgdmFyIF90aGlzNyA9IHRoaXM7XG4gICAgICAgIHJldHVybiBfYXN5bmNUb0dlbmVyYXRvcigoZnVuY3Rpb24qKCkge1xuICAgICAgICAgICAgaWYgKF90aGlzNy5fQ2VudGVySW1hZ2UgJiYgX3RoaXM3Ll9DZW50ZXJJbWFnZS5tb2RlICE9PSBfdGhpczcuZm9ybWF0IHx8IF90aGlzNy5zcmMgPT09IF90aGlzNy5mYWxsYmFja1NyYyB8fCBfdGhpczcuX2FzcGVjdFJhdGlvRXF1YWwpIHtcbiAgICAgICAgICAgICAgICBfdGhpczcucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBDZW50ZXJJbWFnZTogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzNy5zcmMgPT09IF90aGlzNy5mYWxsYmFja1NyYyB8fCBfdGhpczcuX2FzcGVjdFJhdGlvRXF1YWwpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXM3Ll9JbWFnZS5hbHBoYSA9IDE7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgaW1hZ2VXO1xuICAgICAgICAgICAgdmFyIGltYWdlSDtcbiAgICAgICAgICAgIHZhciByYXRpb1cgPSBNYXRoLmFicyhfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLncgLyBfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLmgpO1xuICAgICAgICAgICAgdmFyIHJhdGlvSCA9IE1hdGguYWJzKF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UuaCAvIF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2Uudyk7XG4gICAgICAgICAgICBpZiAoX3RoaXM3Ll9JbWFnZS50ZXh0dXJlLnNvdXJjZS53IDwgX3RoaXM3Ll9JbWFnZS50ZXh0dXJlLnNvdXJjZS5oKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzNy5oICogcmF0aW9XIDwgX3RoaXM3LncpIHtcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2VXID0gX3RoaXM3LmggKiByYXRpb1c7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlSCA9IF90aGlzNy5oO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlVyA9IF90aGlzNy53O1xuICAgICAgICAgICAgICAgICAgICBpbWFnZUggPSBfdGhpczcudyAqIHJhdGlvSDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UudyA+IF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UuaCkge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpczcudyAqIHJhdGlvSCA8IF90aGlzNy5oKSB7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlVyA9IF90aGlzNy53O1xuICAgICAgICAgICAgICAgICAgICBpbWFnZUggPSBfdGhpczcudyAqIHJhdGlvSDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpbWFnZVcgPSBfdGhpczcuaCAqIHJhdGlvVztcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2VIID0gX3RoaXM3Lmg7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpbWFnZVcgPSBNYXRoLm1pbihfdGhpczcudywgX3RoaXM3LmgpO1xuICAgICAgICAgICAgICAgIGltYWdlSCA9IGltYWdlVztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBzcmMgPSB5aWVsZCBfdGhpczcuX3Byb2Nlc3NlZEltYWdlU3JjO1xuICAgICAgICAgICAgX3RoaXM3LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBDZW50ZXJJbWFnZToge1xuICAgICAgICAgICAgICAgICAgICBmb3JtYXQ6IF90aGlzNy5mb3JtYXQsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICAgICAgdzogaW1hZ2VXLFxuICAgICAgICAgICAgICAgICAgICBoOiBpbWFnZUgsXG4gICAgICAgICAgICAgICAgICAgIHg6IF90aGlzNy53IC8gMixcbiAgICAgICAgICAgICAgICAgICAgeTogX3RoaXM3LmggLyAyLFxuICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IF90aGlzNy5jb3JlLmZpbmRaQ29udGV4dCgpLnpJbmRleCArIF90aGlzNy5zdHlsZS56SW5kZXhTZXQuY2VudGVySW1hZ2UsXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNyYzogc3JjLFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzaXplTW9kZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IGltYWdlSCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBcImNvdmVyXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdzogaW1hZ2VXXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogQ3VzdG9tSW1hZ2VUZXh0dXJlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSkpKCk7XG4gICAgfVxuICAgIF91cGRhdGVGb3JtYXRTcXVhcmVDaXJjbGUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9DZW50ZXJJbWFnZSAmJiB0aGlzLl9DZW50ZXJJbWFnZS5tb2RlICE9PSB0aGlzLmZvcm1hdCB8fCB0aGlzLnNyYyA9PT0gdGhpcy5mYWxsYmFja1NyYykge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgQ2VudGVySW1hZ2U6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAodGhpcy5zcmMgPT09IHRoaXMuZmFsbGJhY2tTcmMpIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaW1hZ2VTaXplID0gTWF0aC5taW4odGhpcy53LCB0aGlzLmgpIC0gdGhpcy5zdHlsZS5wYWRkaW5nICogMjtcbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBDZW50ZXJJbWFnZToge1xuICAgICAgICAgICAgICAgIGZvcm1hdDogdGhpcy5mb3JtYXQsXG4gICAgICAgICAgICAgICAgaDogaW1hZ2VTaXplLFxuICAgICAgICAgICAgICAgIHNoYWRlcjoge1xuICAgICAgICAgICAgICAgICAgICByYWRpdXM6IFwiY2lyY2xlXCIgPT09IHRoaXMuZm9ybWF0ID8gaW1hZ2VTaXplIC8gMiA6IHRoaXMuc3R5bGUuY2VudGVySW1hZ2VSYWRpdXMsXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IGxuZy5zaGFkZXJzLlJvdW5kZWRSZWN0YW5nbGVcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHc6IGltYWdlU2l6ZSxcbiAgICAgICAgICAgICAgICB6SW5kZXg6IHRoaXMuY29yZS5maW5kWkNvbnRleHQoKS56SW5kZXggKyB0aGlzLnN0eWxlLnpJbmRleFNldC5jZW50ZXJJbWFnZSxcbiAgICAgICAgICAgICAgICBJbWFnZToge1xuICAgICAgICAgICAgICAgICAgICBoOiBpbWFnZVNpemUsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICAgICAgcnR0OiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3OiBpbWFnZVNpemUsXG4gICAgICAgICAgICAgICAgICAgIHg6IHRoaXMudyAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHk6IHRoaXMuaCAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNyYzogdGhpcy5fSW1hZ2UudGV4dHVyZS5zcmMsXG4gICAgICAgICAgICAgICAgICAgICAgICByZXNpemVNb2RlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaDogaW1hZ2VTaXplLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFwiY292ZXJcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3OiBpbWFnZVNpemVcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDdXN0b21JbWFnZVRleHR1cmVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVHcmFkaWVudCgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmdyYWRpZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fR3JhZGllbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zaG91bGRTbW9vdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fR3JhZGllbnQuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHJhbnNpdGlvbiA9IHRoaXMuX0dyYWRpZW50ICYmIHRoaXMuX0dyYWRpZW50Ll9nZXRUcmFuc2l0aW9uKFwiYWxwaGFcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhZGllbnQgJiYgdHJhbnNpdGlvbiAmJiB0cmFuc2l0aW9uLnAgPT09IDEpIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdyYWRpZW50OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX0dyYWRpZW50LnBhdGNoKHRoaXMuX2dyYWRpZW50UGF0Y2gpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9HcmFkaWVudC5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogWyAwLCB0aGlzLnN0eWxlLmFuaW1hdGlvbkdyYWRpZW50RXhpdCBdXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBHcmFkaWVudDogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9jcmVhdGVHcmFkaWVudCgpO1xuICAgIH1cbiAgICBfY3JlYXRlR3JhZGllbnQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgR3JhZGllbnQ6IHRoaXMuX2dyYWRpZW50UGF0Y2hcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh0aGlzLnNob3VsZFNtb290aCkge1xuICAgICAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9HcmFkaWVudCwge1xuICAgICAgICAgICAgICAgIGFscGhhOiBbIDEsIHRoaXMuc3R5bGUuYW5pbWF0aW9uR3JhZGllbnRFbnRyYW5jZSBdXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlSW1hZ2UoKSB7XG4gICAgICAgIHZhciBfdGhpczggPSB0aGlzO1xuICAgICAgICByZXR1cm4gX2FzeW5jVG9HZW5lcmF0b3IoKGZ1bmN0aW9uKigpIHtcbiAgICAgICAgICAgIF90aGlzOC5fYXNwZWN0UmF0aW9FcXVhbCA9IGZhbHNlO1xuICAgICAgICAgICAgaWYgKCFfdGhpczguX3Byb2Nlc3NlZEltYWdlU3JjKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzOC5fSW1hZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXM4Ll9JbWFnZS50ZXh0dXJlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgc3JjID0geWllbGQgX3RoaXM4Ll9wcm9jZXNzZWRJbWFnZVNyYztcbiAgICAgICAgICAgIF90aGlzOC5fSW1hZ2UucGF0Y2goe1xuICAgICAgICAgICAgICAgIGFscGhhOiBfdGhpczguc3JjICE9PSBfdGhpczguZmFsbGJhY2tTcmMgJiYgKF90aGlzOC5fYmx1ciB8fCBfdGhpczguX2hhc0NlbnRlckltYWdlKSA/IC4wMDEgOiAxLFxuICAgICAgICAgICAgICAgIGg6IF90aGlzOC5oLFxuICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQ3VzdG9tSW1hZ2VUZXh0dXJlLFxuICAgICAgICAgICAgICAgICAgICBzcmM6IHNyYyxcbiAgICAgICAgICAgICAgICAgICAgcmVzaXplTW9kZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogXCJjb3ZlclwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgdzogX3RoaXM4LncsXG4gICAgICAgICAgICAgICAgICAgICAgICBoOiBfdGhpczguaFxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB3OiBfdGhpczgudyxcbiAgICAgICAgICAgICAgICB6SW5kZXg6IF90aGlzOC5jb3JlLmZpbmRaQ29udGV4dCgpLnpJbmRleCArIF90aGlzOC5zdHlsZS56SW5kZXhTZXQuaW1hZ2VcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KSkoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUZpbGxDb2xvcigpIHtcbiAgICAgICAgaWYgKCF0aGlzLmZpbGwpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIEZpbGxDb2xvcjogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIEZpbGxDb2xvcjoge1xuICAgICAgICAgICAgICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLncsXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuZmlsbENvbG9yLFxuICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IDVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlUmFkaXVzKCkge1xuICAgICAgICB0aGlzLnBhdGNoKHRoaXMuc3R5bGUucmFkaXVzID8ge1xuICAgICAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgICAgICAgdHlwZTogbG5nLnNoYWRlcnMuUm91bmRlZFJlY3RhbmdsZSxcbiAgICAgICAgICAgICAgICByYWRpdXM6IGdldE1heFJvdW5kUmFkaXVzKHRoaXMuc3R5bGUucmFkaXVzLCB0aGlzLncsIHRoaXMuaClcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSA6IHtcbiAgICAgICAgICAgIHNoYWRlcjogdW5kZWZpbmVkXG4gICAgICAgIH0pO1xuICAgIH1cbn1cblxudmFyIHRvbmUkbyA9IHRoZW1lID0+ICh7XG4gICAgbmV1dHJhbDoge1xuICAgICAgICBjb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWxcbiAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgY29sb3I6IHRoZW1lLmNvbG9yLmZpbGxJbnZlcnNlXG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBjb2xvcjogdGhlbWUuY29sb3IuZmlsbEJyYW5kXG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkUSA9IE9iamVjdC5mcmVlemUoe1xuICAgIF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gICAgICAgICAgICAgIHR5cGU6IEN1c3RvbUltYWdlVGV4dHVyZSxcbiAgICAgICAgICAgICAgICB3OiB0aGlzLncsXG4gICAgICAgICAgICAgICAgaDogdGhpcy5oLFxuICAgICAgICAgICAgICAgIHNyYzogdGhpcy5pY29uXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgICAgIHZhciBjb2xvciA9IGdldFZhbGlkQ29sb3IodGhpcy5fY29sb3IgfHwgdGhpcy5zdHlsZS5jb2xvcik7XG4gICAgICAgIHZhciBzaGFkZXIgPSB0aGlzLnJhZGl1cyB8fCB0aGlzLnN0eWxlLnJhZGl1cyA/IHtcbiAgICAgICAgICAgIHJhZGl1czogdGhpcy5yYWRpdXMgfHwgdGhpcy5zdHlsZS5yYWRpdXMsXG4gICAgICAgICAgICB0eXBlOiBsbmcuc2hhZGVycy5Sb3VuZGVkUmVjdGFuZ2xlXG4gICAgICAgIH0gOiB1bmRlZmluZWQ7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgIHRleHR1cmU6IHRleHR1cmUsXG4gICAgICAgICAgICBzaGFkZXI6IHNoYWRlclxuICAgICAgICB9LCBjb2xvciA/IHtcbiAgICAgICAgICAgIGNvbG9yVWw6IGNvbG9yLFxuICAgICAgICAgICAgY29sb3JVcjogY29sb3IsXG4gICAgICAgICAgICBjb2xvckJsOiBjb2xvcixcbiAgICAgICAgICAgIGNvbG9yQnI6IGNvbG9yXG4gICAgICAgIH0gOiB7fSk7XG4gICAgfVxufVxuXG52YXIgYmFzZSRQID0gdGhlbWUgPT4gKHtcbiAgICBjb250ZW50U3BhY2luZzogdGhlbWUuc3BhY2VyLnhzLFxuICAgIG9mZnNldFk6IDEsXG4gICAgcGFkZGluZ1g6IHRoZW1lLnNwYWNlci5tZCxcbiAgICBwYWRkaW5nWTogdGhlbWUuc3BhY2VyLnhzLFxuICAgIHJhZGl1czogdGhlbWUucmFkaXVzLnNtLFxuICAgIHN0cm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biAgICAgICAgdGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIHN0cm9rZUNvbG9yOiB0aGVtZS5jb2xvci5zdHJva2VJbnZlcnNlU2Vjb25kYXJ5XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkUCA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJFAsXG4gICAgdG9uZTogdG9uZSRuXG59KTtcblxuY2xhc3MgQmFkZ2UgZXh0ZW5kcyBCYXNlJDEge1xuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgbW91bnRZOiAuNVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIEljb246IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBpdGVtQ2hhbmdlZDogXCJfdXBkYXRlTGF5b3V0XCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJCYWRnZVwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRQO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwidGl0bGVcIiwgXCJpY29uXCIsIFwiaWNvbkFsaWduXCIsIFwiaWNvbldpZHRoXCIsIFwiaWNvbkhlaWdodFwi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b3VuZFJlY3QodGhpcy53LCBoZWlnaHQsIGdldE1heFJvdW5kUmFkaXVzKHRoaXMuc3R5bGUucmFkaXVzLCB0aGlzLncsIGhlaWdodCksIHRoaXMuc3R5bGUuc3Ryb2tlV2lkdGgsIHRoaXMuc3R5bGUuc3Ryb2tlQ29sb3IsIHRydWUsIHRoaXMuc3R5bGUuYmFja2dyb3VuZENvbG9yKVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZVRleHQoKSB7XG4gICAgICAgIGlmICh0aGlzLl9UZXh0KSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LnBhdGNoKHtcbiAgICAgICAgICAgICAgICB0ZXh0OiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dDogdGhpcy50aXRsZSB8fCBcIlwiXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVJY29uKCkge1xuICAgICAgICB0aGlzLl9JY29uLnBhdGNoKHtcbiAgICAgICAgICAgIGljb246IHRoaXMuaWNvbixcbiAgICAgICAgICAgIHc6IHRoaXMuaWNvbldpZHRoLFxuICAgICAgICAgICAgaDogdGhpcy5pY29uSGVpZ2h0LFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb2xvcjogZ2V0SGV4Q29sb3IodGhpcy5zdHlsZS5pY29uQ29sb3IpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlV2lkdGgoKSB7XG4gICAgICAgIHZhciB3aWR0aCA9IDA7XG4gICAgICAgIGlmICh0aGlzLnRpdGxlICYmIHRoaXMuaWNvbikge1xuICAgICAgICAgICAgd2lkdGggPSB0aGlzLl9UZXh0LnJlbmRlcldpZHRoICsgdGhpcy5fSWNvbi5maW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GV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoZW1lLnR5cG9ncmFwaHkuYnV0dG9uMSksIHt9LCB7XG4gICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgfSksXG4gICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxufSk7XG5cbnZhciBtb2RlJGcgPSB0aGVtZSA9PiAoe1xuICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgdGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlXG4gICAgICAgIH0sXG4gICAgICAgIGNvbnRlbnRDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2UsXG4gICAgICAgIHRvbmU6IHtcbiAgICAgICAgICAgIGludmVyc2U6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJyYW5kOiB7XG4gICAgICAgICAgICAgICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBkaXNhYmxlZDoge1xuICAgICAgICB0ZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICB9LFxuICAgICAgICBjb250ZW50Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsR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gICAgICAgICAgIGZvciAodmFyIGkgPSB0aGlzLkl0ZW1zLmNoaWxkcmVuLmxlbmd0aCAtIDE7IGkgPj0gMDsgaS0tKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNoaWxkUG9zaXRpb24gPSB0aGlzLl9jYWxjQXhpc1Bvc2l0aW9uKHRoaXMuSXRlbXMuY2hpbGRyZW5baV0pO1xuICAgICAgICAgICAgICAgIHZhciBjYW5TY3JvbGxUb0NoaWxkID0gY2hpbGRQb3NpdGlvbiArIHRoaXNbbGVuZ3RoRGltZW5zaW9uXSAtIHNjcm9sbE9mZnNldCA+IGVuZE9mTGFzdENoaWxkO1xuICAgICAgICAgICAgICAgIGlmIChjYW5TY3JvbGxUb0NoaWxkKSB7XG4gICAgICAgICAgICAgICAgICAgIGxhc3RTY3JvbGxJbmRleCA9IGk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fbGFzdFNjcm9sbEluZGV4ID0gbGFzdFNjcm9sbEluZGV4O1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9sYXN0U2Nyb2xsSW5kZXggPiB0aGlzLml0ZW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgdGhpcy5fbGFzdFNjcm9sbEluZGV4ID0gdGhpcy5pdGVtcy5sZW5ndGggLSAxO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9jYWxjQ3Jvc3NEaW1lbnNpb25TaXplKGNvbXApIHtcbiAgICAgICAgaWYgKHRoaXMuX2lzUm93KSB7XG4gICAgICAgICAgICByZXR1cm4gZ2V0SChjb21wKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5faXNDb2x1bW4pIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRXKGNvbXApO1xuICAgICAgICB9XG4gICAgfVx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Y3RlZC53ICsgdGhpcy5zdHlsZS5pdGVtU3BhY2luZyArICh0aGlzLnNlbGVjdGVkLmV4dHJhSXRlbVNwYWNpbmcgfHwgMCkgKyB0aGlzLml0ZW1Qb3NYO1xuICAgICAgICB9IGVsc2UgaWYgKHByZXYpIHtcbiAgICAgICAgICAgIHZhciBpdGVtc0NvbnRhaW5lclg7XG4gICAgICAgICAgICB2YXIgX3ByZXZJbmRleCA9IHRoaXMuSXRlbXMuY2hpbGRMaXN0LmdldEluZGV4KHByZXYpO1xuICAgICAgICAgICAgdmFyIHNlbGVjdGVkWCA9IHRoaXMuc2VsZWN0ZWQueDtcbiAgICAgICAgICAgIGlmIChfcHJldkluZGV4ID09PSAtMSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChfcHJldkluZGV4ID4gdGhpcy5zZWxlY3RlZEluZGV4KSB7XG4gICAgICAgICAgICAgICAgaXRlbXNDb250YWluZXJYID0gLXNlbGVjdGVkWCArIHRoaXMuaXRlbVBvc1g7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9wcmV2SW5kZXggPCB0aGlzLnNlbGVjdGVkSW5kZXgpIHtcbiAgICAgICAgICAgICAgICBpdGVtc0NvbnRhaW5lclggPSB0aGlzLncgLSBzZWxlY3RlZFggLSB0aGlzLnNlbGVjdGVkLnc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gaXRlbXNDb250YWluZXJYO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl9nZXRTY3JvbGxYKCk7XG4gICAgfVxuICAgIF9nZXRTY3JvbGxYKCkge1xuICAgICAgICBpZiAodGhpcy5fc2VsZWN0ZWRQYXN0QWRkZWQpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9nZXRQcmVwZW5kZWRPZmZzZXQoKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaXRlbXNDb250YWluZXJYO1xuICAgICAgIC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gICAgaWYgKHRoaXMuX3Nob3VsZFRydW5jYXRlKSB7XG4gICAgICAgICAgICB0aGlzLmFscGhhID0gLjAwMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fcGFyc2VkQ29udGVudCAmJiB0aGlzLl9wYXJzZWRDb250ZW50Lmxlbmd0aCkge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgZmxleDoge1xuICAgICAgICAgICAgICAgICAgICBkaXJlY3Rpb246IFwicm93XCIsXG4gICAgICAgICAgICAgICAgICAgIHdyYXA6ICEhdGhpcy5jb250ZW50V3JhcCxcbiAgICAgICAgICAgICAgICAgICAganVzdGlmeUNvbnRlbnQ6IHRoaXMuanVzdGlmeSAhPSB1bmRlZmluZWQgPyB0aGlzLmp1c3RpZnkgOiB0aGlzLnN0eWxlLmp1c3RpZnlcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMuX3BhcnNlZENvbnRlbnQuZm9yRWFjaCgoKGl0ZW0sIGluZGV4KSA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIGlzTGFzdCA9IGluZGV4ID09PSB0aGlzLl9wYXJzZWRDb250ZW50Lmxlbmd0aCAtIDE7XG4gICAgICAgICAgICAgICAgdmFyIGJhc2UgPSB7XG4gICAgICAgICAgICAgICAgICAgIGZsZXhJdGVtOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuY29udGVudFByb3BlcnRpZXMpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFyZ2luQm90dG9tOiBpc0xhc3QgPyAwIDogdGhpcy5fbWFyZ2luQm90dG9tLFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFyZ2luUmlnaHQ6IGlzTGFzdCA/IDAgOiB0aGlzLmNvbnRlbnRQcm9wZXJ0aWVzLm1hcmdpblJpZ2h0IHx8IHRoaXMuc3R5bGUuY29udGVudFNwYWNpbmdcbiAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGlmIChpc1RleHQoaXRlbSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIG5leHRJdGVtID0gdGhpcy5fcGFyc2VkQ29udGVudFtpbmRleCArIDFdO1xuICAgICAgICAgICAgICAgICAgICBpZiAobmV4dEl0ZW0gJiYgaXNUZXh0KG5leHRJdGVtKSB8fCB0aGlzLmNvbnRlbnRXcmFwICYmIG5leHRJdGVtICYmIG5leHRJdGVtLm5ld2xpbmUgJiYgdGhpcy5fcGFyc2VkQ29udGVudFtpbmRleCArIDJdICYmIGlzVGV4dCh0aGlzLl9wYXJzZWRDb250ZW50W2luZGV4ICsgMl0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBiYXNlLmZsZXhJdGVtLm1hcmdpblJpZ2h0ID0gMDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKHRoaXMuX2NyZWF0ZVRleHQoYmFzZSwgaXRlbSkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNJY29uKGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEodGhpcy5fY3JlYXRlSWNvbihiYXNlLCBpdGVtKSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpc0JhZGdlKGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEodGhpcy5fY3JlYXRlQmFkZ2UoYmFzZSwgaXRlbS5iYWRnZSkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS5uZXdsaW5lICYmIHRoaXMuY29udGVudFdyYXApIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYSh7XG4gICAgICAgICAgICAgICAgICAgICAgICBoOiAwLFxuICAgICAgICAgICAgICAgICAgICAgICAgdzogdGhpcy53XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfd2FpdEZvckNvbXBvbmVudExvYWQoKSB7XG4gICAgICAgIGlmICh0aGlzLmNoaWxkcmVuLmxlbmd0aCkge1xuICAgICAgICAgICAgUHJvbWlzZS5hbGwodGhpcy5jaGlsZHJlbi5tYXAoKGNoaWxkID0+IG5ldyBQcm9taXNlKChyZXNvbHZlID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoY2hpbGQuaCA9PT0gMCAmJiBjaGlsZC53ID09PSB0aGlzLncpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZSgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkLm9uKFwidHhMb2FkZWRcIiwgcmVzb2x2ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpKSkpLmZpbmFsbHkoKCgpID0+IHRoaXMuX2NvbnRlbnRMb2FkZWQoKSkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5oID0gMDtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMb2FkZWQoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfbm90aWZ5QW5jZXN0b3JzKCkge1xuICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkbG9hZGVkSW5saW5lQ29udGVudFwiLCB0aGlzKTtcbiAgICAgICAgdGhpcy5zaWduYWwoXCJsb2FkZWRJbmxpbmVDb250ZW50XCIsIHRoaXMuZmluYWxXLCB0aGlzLm11bHRpTGluZUhlaWdodCk7XG4gICAgfVxuICAgIF9jb250ZW50TG9hZGVkKCkge1xuICAgICAgICBpZiAodGhpcy5jaGlsZHJlbi5sZW5ndGgpIHtcbiAgICAgICAgICAgIHNldFRpbWVvdXQoKCgpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLm11bHRpTGluZUhlaWdodCA9IHRoaXMuZmluYWxIO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmZsZXggJiYgdGhpcy5mbGV4Ll9sYXlvdXQgJiYgdGhpcy5mbGV4Ll9sYXlvdXQuX2xpbmVMYXlvdXRlciAmJiB0aGlzLmZsZXguX2xheW91dC5fbGluZUxheW91dGVyLl9saW5lcykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdG90YWxIZWlnaHQgPSAwO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZsZXguX2xheW91dC5fbGluZUxheW91dGVyLl9saW5lcy5mb3JFYWNoKChsaW5lID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsSGVpZ2h0ICs9IE9iamVjdC5lbnRyaWVzKGxpbmUuaXRlbXMpLnNsaWNlKGxpbmUuc3RhcnRJbmRleCwgbGluZS5lbmRJbmRleCArIDEpLnNvcnQoKChhLCBiKSA9PiBiWzFdLmggLSBhWzFdLmgpKVswXVsxXS5oO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMubXVsdGlMaW5lSGVpZ2h0ID0gdG90YWxIZWlnaHQ7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zaG91bGRUcnVuY2F0ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyTWF4TGluZXMoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9ub3RpZnlBbmNlc3RvcnMoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TG9hZGVkKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSksIDEwKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHR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zU3BhY2VGb3JTdWZmaXggJiYgIW5leHRDaGlsZC5oYXNTcGFjZUZvclN1ZmZpeDtcbiAgICAgICAgICAgIHZhciBpc0xhc3QgPSAhbmV4dENoaWxkIHx8IGNhblJlbmRlckxhc3RXaXRoU3VmZml4IHx8IGlzTGFzdFdpdGhTcGFjZUZvclN1ZmZpeDtcbiAgICAgICAgICAgIGlmIChjaGlsZC5saW5lIDw9IHRoaXMubWF4TGluZXMpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXNMYXN0ICYmIGluZGV4ICE9PSBjaGlsZHJlbkRpbWVuc2lvbnMubGVuZ3RoIC0gMSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hZGQodGhpcy5fYWRkU3VmZml4KGNoaWxkKSk7XG4gICAgICAgICAgICAgICAgICAgIHJlbmRlcmVkTGFzdEVsZW1lbnQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmFkZChjaGlsZC5jb21wb25lbnQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSkpO1xuICAgICAgICB0aGlzLmFscGhhID0gMTtcbiAgICB9XG4gICAgX2NhbGNDaGlsZHJlbkRpbWVuc2lvbnMoKSB7XG4gICAgICAgIHZhciBzdWZmaXhXID0gbWVhc3VyZVRleHRXaWR0aChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgIHRleHQ6IHRoaXMubWF4TGluZXNTdWZmaXhcbiAgICAgICAgfSkpO1xuICAgICAgICB2YXIgY29udGVudEVuZFggPSAwO1xuICAgICAgICB2YXIgbGluZSA9IDE7XG4gICAgICAgIHJldHVybiB0aGlzLmNoaWxkcmVuLnJlZHVjZSgoKGFjYywgY2hpbGQpID0+IHtcbiAgICAgICAgICAgIHZhciBjb21wb25lbnQgPSBjaGlsZDtcbiAgICAgICAgICAgIHZhciB0eXBlLCBjb250ZW50LCB3O1xuICAgICAgICAgICAgdmFyIGlzTmV3TGluZUVsZW1lbnQgPSBjaGlsZC53ID09IHRoaXMudyAmJiBjaGlsZC5oID09PSAwO1xuICAgICAgICAgICAgaWYgKGlzTmV3TGluZUVsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICBsaW5lKys7XG4gICAgICAgICAgICAgICAgY29udGVudEVuZFggPSAwO1xuICAgICAgICAgICAgICAgIHZhciBfZGF0YSA9IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogXCJsaW5lYnJlYWtcIixcbiAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50OiBjb21wb25lbnQsXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGNvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgIGxpbmU6IGxpbmUsXG4gICAgICAgICAgICAgICAgICAgIGhhc1NwYWNlRm9yU3VmZml4OiB0cnVlXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBhY2MucHVzaChfZGF0YSk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpc1RleHQoY2hpbGQpKSB7XG4gICAgICAgICAgICAgICAgdHlwZSA9IFwidGV4dFwiO1xuICAgICAgICAgICAgICAgIGNvbnRlbnQgPSBjaGlsZC50ZXh0LnRleHQ7XG4gICAgICAgICAgICAgICAgdyA9IGNoaWxkLnRleHR1cmUuZ2V0UmVuZGVyV2lkdGgoKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNJY29uKGNoaWxkKSkge1xuICAgICAgICAgICAgICAgIHR5cGUgPSBcImljb25cIjtcbiAgICAgICAgICAgICAgICB3ID0gY2hpbGQudztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hpbGQuY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lID09PSBcIkJhZGdlXCIpIHtcbiAgICAgICAgICAgICAgICB0eXBlID0gXCJiYWRnZVwiO1xuICAgICAgICAgICAgICAgIHcgPSBjaGlsZC53O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29udGVudEVuZFggKz0gdztcbiAgICAgICAgICAgIGNvbnRlbnRFbmRYICs9IGNoaWxkLmZsZXhJdGVtLm1hcmdpblJpZ2h0O1xuICAgICAgICAgICAgaWYgKE1hdGguY2VpbChjb250ZW50RW5kWCkgPj0gdGhpcy53KSB7XG4gICAgICAgICAgICAgICAgbGluZSsrO1xuICAgICAgICAgICAgICAgIGNvbnRlbnRFbmRYID0gdztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBoYXNTcGFjZUZvclN1ZmZpeCA9IE1hdGguY2VpbChjb250ZW50RW5kWCkgKyBzdWZmaXhXIDw9IHRoaXMudztcbiAgICAgICAgICAgIHZhciBkYXRhID0ge1xuICAgICAgICAgICAgICAgIHR5cGU6IHR5cGUsXG4gICAgICAgICAgICAgICAgY29tcG9uZW50OiBjb21wb25lbnQsXG4gICAgICAgICAgICAgICAgY29udGVudDogY29udGVudCxcbiAgICAgICAgICAgICAgICBsaW5lOiBsaW5lLFxuICAgICAgICAgICAgICAgIGhhc1NwYWNlRm9yU3VmZml4OiBoYXNTcGFjZUZvclN1ZmZpeFxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGFjYy5wdXNoKGRhdGEpO1xuICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgfSksIFtdKTtcbiAgICB9XG4gICAgX2FkZFN1ZmZpeChfcmVmMTYpIHtcbiAgICAgICAgdmFyIHt0eXBlOiB0eXBlLCBjb21wb25lbnQ6IGNvbXBvbmVudCwgY29udGVudDogY29udGVudH0gPSBfcmVmMTY7XG4gICAgICAgIHZhciBuZWdhdGVkUmlnaHRNYXJnaW4gPSBjb21wb25lbnQuZmxleEl0ZW0ubWFyZ2luUmlnaHQgKiAtMTtcbiAgICAgICAgdmFyIHN1ZmZpeDtcbiAgICAgICAgaWYgKHR5cGUgPT09IFwidGV4dFwiKSB7XG4gICAgICAgICAgICB2YXIge2ZvbnRGYWNlOiBmb250RmFjZSwgZm9udFNpemU6IGZvbnRTaXplLCBmb250U3R5bGU6IGZvbnRTdHlsZSwgbGluZUhlaWdodDogbGluZUhlaWdodCwgdmVydGljYWxBbGlnbjogdmVydGljYWxBbGlnbn0gPSBjb21wb25lbnQudGV4dDtcbiAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMuX2NyZWF0ZVRleHQoe1xuICAgICAgICAgICAgICAgIGZsZXhJdGVtOiB0aGlzLmNvbnRlbnRQcm9wZXJ0aWVzXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGV4dDogXCJcIi5jb25jYXQoY29udGVudC50cmltKCkpLmNvbmNhdCh0aGlzLm1heExpbmVzU3VmZml4KSxcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICBmb250RmFjZTogZm9udEZhY2UsXG4gICAgICAgICAgICAgICAgICAgIGZvbnRTaXplOiBmb250U2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgZm9udFN0eWxlOiBmb250U3R5bGUsXG4gICAgICAgICAgICAgICAgICAgIGxpbmVIZWlnaHQ6IGxpbmVIZWlnaHQsXG4gICAgICAgICAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IHZlcnRpY2FsQWxpZ25cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmFkZChjb21wb25lbnQpO1xuICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5fY3JlYXRlVGV4dCh7XG4gICAgICAgICAgICAgICAgZmxleEl0ZW06IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5jb250ZW50UHJvcGVydGllcyksIHt9L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ICAgICAgdGV4dDogdGV4dC50ZXh0IHx8IHRleHRcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIHZhciBzdHJpa2V0aHJvdWdoTGluZSA9IHtcbiAgICAgICAgICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICAgICAgICAgIHc6IHRleHRXaWR0aCxcbiAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5zdHJpa2V0aHJvdWdoQ29sb3IgfHwgKHRleHRPdmVycmlkZVN0eWxlcyA9PT0gbnVsbCB8fCB0ZXh0T3ZlcnJpZGVTdHlsZXMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHRleHRPdmVycmlkZVN0eWxlcy50ZXh0Q29sb3IpIHx8IHRoaXMuc3R5bGUudGV4dFN0eWxlLnRleHRDb2xvcixcbiAgICAgICAgICAgICAgICBoOiB0ZXh0Q29tcG9uZW50LmggKiB0aGlzLnN0eWxlLnN0cmlrZXRocm91Z2hSYXRpbyxcbiAgICAgICAgICAgICAgICB5OiB0ZXh0Q29tcG9uZW50LmggLyAyLFxuICAgICAgICAgICAgICAgIG1vdW50WTogMVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogbG5nLkNvbXBvbmVudCxcbiAgICAgICAgICAgICAgICB3OiB0ZXh0V2lkdGggKyB0ZXh0Q29tcG9uZW50LmZsZXhJdGVtLm1hcmdpblJpZ2h0LFxuICAgICAgICAgICAgICAgIGg6IHRleHRDb21wb25lbnQuaCxcbiAgICAgICAgICAgICAgICBjaGlsZHJlbjogWyBfb2JqZWN0U3ByZWFkKHt9LCB0ZXh0Q29tcG9uZW50KSwgX29iamVjdFNwcmVhZCh7fSwgc3RyaWtldGhyb3VnaExpbmUpIF1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRleHRDb21wb25lbnQ7XG4gICAgfVxuICAgIF9jcmVhdGVCYWRnZShiYXNlLCBiYWRnZSkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGJhc2UpLCB7fSwge1xuICAgICAgICAgICAgeTogdGhpcy5iYWRnZVkgfHwgMFxuICAgICAgICB9LCB0aGlzLmJhZGdlUHJvcGVydGllcyksIHt9LCB7XG4gICAgICAgICAgICB0eXBlOiBCYWRnZSxcbiAgICAgICAgICAgIHRpdGxlOiBiYWRnZSxcbiAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICBsb2FkZWRCYWRnZTogXCJfbG9hZGVkQmFkZ2VcIlxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZUljb25Qb3NpdGlvbihpY29uKSB7XG4gICAgICAgIGljb24ueSA9IHRoaXMuc3R5bGUudGV4dFN0eWxlLmxpbmVIZWlnaHQgLSBpY29uLmg7XG4gICAgfVxuICAgIF9sb2FkZWRCYWRnZShiYWRnZSkge1xuICAgICAgICBpZiAodGhpcy5iYWRnZVkgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgYmFkZ2UueSA9IHRoaXMuc3R5bGUudGV4dFN0eWxlLmxpbmVIZWlnaHQgLSBiYWRnZS5oO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9mb3JtYXRTcGFjZXMocGFyc2VkQ29udGVudCkge1xuICAgICAgICB2YXIgd2hpdGVzcGFjZSA9IC8oLis/XFxzKykvO1xuICAgICAgICByZXR1cm4gZmxhdHRlbigocGFyc2VkQ29udGVudCB8fCBbXSkucmVkdWNlKCgoYWNjLCBpdGVtKSA9PiB7XG4gICAgICAgICAgICB2YXIgcGFyc2VkID0gaXRlbTtcbiAgICAgICAgICAgIGlmIChpc1RleHQoaXRlbSkpIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGl0ZW0gPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGZvcm1hdHRlZFdvcmRzID0gaXRlbS50ZXh0LnNwbGl0KHdoaXRlc3BhY2UpLm1hcCgod29yZCA9PiB3b3JkICYmIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgaXRlbSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0OiB3b3JkXG4gICAgICAgICAgICAgICAgICAgIH0pKSk7XG4gICAgICAgICAgICAgICAgICAgIGFjYy5wdXNoKC4uLmZvcm1hdHRlZFdvcmRzKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcGFyc2VkID0gaXRlbS5zcGxpdCh3aGl0ZXNwYWNlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGFjYy5wdXNoKHBhcnNlZCk7XG4gICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICB9KSwgW10pKS5tYXAoKChpdGVtLCBpbmRleCwgYXJyKSA9PiB7XG4gICAgICAgICAgICBpZiAoaXRlbSA9PT0gXCIgXCIpIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIGlmIChhcnJbaW5kZXggKyAxXSA9PT0gXCIgXCIpIHJldHVybiBpdGVtICsgXCIgXCI7XG4gICAgICAgICAgICByZXR1cm4gaXRlbTtcbiAgICAgICAgfSkpLmZpbHRlcihCb29sZWFuKTtcbiAgICB9XG4gICAgX3NldENvbnRlbnQoY29udGVudCkge1xuICAgICAgICBpZiAoY29udGVudCAhPT0gdGhpcy5fY29udGVudCkge1xuICAgICAgICAgICAgdGhpcy5fY29udGVudCA9IGNvbnRlbnQ7XG4gICAgICAgICAgICB2YXIgcGFyc2VkQ29udGVudCA9IHRoaXMuX2NvbnRlbnQ7XG4gICAgICAgICAgICBpZiAoY29udGVudCAmJiAhQXJyYXkuaXNBcnJheShjb250ZW50KSkge1xuICAgICAgICAgICAgICAgIHBhcnNlZENvbnRlbnQgPS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ZENvbnRlbnQgJiYgdGhpcy5fcGFyc2VkQ29udGVudC5yZWR1Y2UoKChhbm5vdW5jZSwgaXRlbSkgPT4ge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBpdGVtID09PSBcInN0cmluZ1wiKSB7XG4gICAgICAgICAgICAgICAgYW5ub3VuY2UgKz0gaXRlbTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS5hbm5vdW5jZSkge1xuICAgICAgICAgICAgICAgIGFubm91bmNlICs9IGl0ZW0uYW5ub3VuY2U7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0udGV4dCkge1xuICAgICAgICAgICAgICAgIHZhciBfaXRlbSRzdHlsZTtcbiAgICAgICAgICAgICAgICBhbm5vdW5jZSArPSBpdGVtLnRleHQ7XG4gICAgICAgICAgICAgICAgaWYgKCgoX2l0ZW0kc3R5bGUgPSBpdGVtLnN0eWxlKSA9PT0gbnVsbCB8fCBfaXRlbSRzdHlsZSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2l0ZW0kc3R5bGUudGV4dERlY29yYXRpb24pID09PSBcImxpbmUtdGhyb3VnaFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGFubm91bmNlICs9IFwic3RyaWtldGhyb3VnaFwiO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS50aXRsZSkge1xuICAgICAgICAgICAgICAgIGFubm91bmNlICs9IGl0ZW0udGl0bGU7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0uYmFkZ2UpIHtcbiAgICAgICAgICAgICAgICBhbm5vdW5jZSArPSBpdGVtLmJhZGdlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGFubm91bmNlICsgXCIgXCI7XG4gICAgICAgIH0pLCBcIlwiKTtcbiAgICAgICAgcmV0dXJuIGFubm91bmNlID8gYW5ub3VuY2UucmVwbGFjZSgvXFxzKyg/PVxccyl8XFxzJC9n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mFnQ29sb3IgPSBjb2xvcjtcXG4gIH1cXG5cIjtcblxuY2xhc3MgTWFycXVlZSBleHRlbmRzIEJhc2UkMSB7XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIENvbnRlbnRDbGlwcGVyOiB7XG4gICAgICAgICAgICAgICAgYm91bmRzTWFyZ2luOiBbXSxcbiAgICAgICAgICAgICAgICBDb250ZW50Qm94OiB7XG4gICAgICAgICAgICAgICAgICAgIENvbnRlbnQ6IHt9LFxuICAgICAgICAgICAgICAgICAgICBDb250ZW50TG9vcFRleHR1cmU6IHt9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTWFycXVlZVwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRJO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQ29udGVudENsaXBwZXJcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJDb250ZW50Qm94XCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnRDbGlwcGVyLkNvbnRlbnRCb3hcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIkNvbnRlbnRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudENsaXBwZXIuQ29udGVudEJveC5Db250ZW50XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJDb250ZW50TG9vcFRleHR1cmVcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudENsaXBwZXIuQ29udGVudEJveC5Db250ZW50TG9vcFRleHR1cmVcIlxuICAgICAgICB9IF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cy5jb2xvcilcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9XG4gICAgZ2V0IF9jdXJyZW50VGV4dHVyZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX0NvbnRlbnQudGV4dCB8fCB0aGlzLl9Db250ZW50LnRleHR1cmUgfHwge307XG4gICAgfVxuICAgIF91cGRhdGVUZXh0dXJlKCkge1xuICAgICAgICB2YXIgY29udGVudCA9IHtcbiAgICAgICAgICAgIHJ0dDogdHJ1ZVxuICAgICAgICB9O1xuICAgICAgICBpZiAodGhpcy5jb250ZW50VGV4dHVyZSkge1xuICAgICAgICAgICAgY29udGVudC50ZXh0dXJlID0gdGhpcy5jb250ZW50VGV4dHVyZTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnRpdGxlKSB7XG4gICAgICAgICAgICBjb250ZW50LnRleHQgPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50ZXh0U3R5bGUpLCB0aGlzLnRpdGxlKSwge30sIHtcbiAgICAgICAgICAgICAgICB0ZXh0OiB0aGlzLnRleHRDb250ZW50XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIENvbnRlbnRDbGlwcGVyOiB7XG4gICAgICAgICAgICAgICAgdzogdGhpcy53ICsgMTQsXG4gICAgICAgICAgICAgICAgQ29udGVudEJveDoge1xuICAgICAgICAgICAgICAgICAgICBDb250ZW50OiBjb250ZW50LFxuICAgICAgICAgICAgICAgICAgICBDb250ZW50TG9vcFRleHR1cmU6IHt9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5zaWduYWwoXCJtYXJxdWVlQ29udGVudExvYWRlZFwiKTtcbiAgICB9XG4gICAgX3VwZGF0ZVNoYWRlcigpIHtcbiAgICAgICAgdGhpcy5fQ29udGVudENsaXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgdzogdGhpcy53ID4gMCA/IHRoaXMudyArIHRoaXMuc3R5bGUuZmFkZVdpZHRoIC8gMiA6IDAsXG4gICAgICAgICAgICBzaGFkZXI6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBGYWRlU2hhZGVyLFxuICAgICAgICAgICAgICAgIHBvc2l0aW9uTGVmdDogMCxcbiAgICAgICAgICAgICAgICBwb3NpdGlvblJpZ2h0OiB0aGlzLnN0eWxlLmZhZGVXaWR0aFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHJ0dDogdHJ1ZVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZUFuaW1hdGlvbigpIHtcbiAgICAgICAgdGhpcy5fc2Nyb2xsQW5pbWF0aW9uICYmIHRoaXMuX3Njcm9sbEFuaW1hdGlvbi5zdG9wTm93KCk7XG4gICAgICAgIHRoaXMuX3Njcm9sbEFuaW1hdGlvbiA9IHRoaXMuYW5pbWF0aW9uKHtcbiAgICAgICAgICAgIGR1cmF0aW9uOiB0aGlzLl9sb29wV2lkdGggLyA1MCxcbiAgICAgICAgICAgIGRlbGF5OiBpc05hTih0aGlzLmRlbGF5KSA/IDEuNSA6IHRoaXMuZGVsYXksXG4gICAgICAgICAgICByZXBlYXQ6IGlzTmFOKHRoaXMucmVwZWF0KSA/IC0xIDogdGhpcy5yZXBlYXQsXG4gICAgICAgICAgICBhY3Rpb25zOiBbIHtcbiAgICAgICAgICAgICAgICB0OiBcIkNvbnRlbnRCb3hcIixcbiAgICAgICAgICAgICAgICBwOiBcInhcIixcbiAgICAgICAgICAgICAgICB2OiB7XG4gICAgICAgICAgICAgICAgICAgIHNtOiAwLFxuICAgICAgICAgICAgICAgICAgICAwOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2OiAwXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIC41OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2OiAtKHRoaXMuX2xvb3BXaWR0aCArIHRoaXMuc3R5bGUub2Zmc2V0KVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHQ6IFwiQ29udGVudENsaXBwZXJcIixcbiAgICAgICAgICAgICAgICBwOiBcInNoYWRlci5wb3NpdGlvbkxlZnRcIixcbiAgICAgICAgICAgICAgICB2OiB7XG4gICAgICAgICAgICAgICAgICAgIHNtOiAwLFxuICAgICAgICAgICAgICAgICAgICAwOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2OiAwXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIC4xOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2OiB0aGlzLnN0eWxlLmZhZGVXaWR0aFxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAuNDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogdGhpcy5zdHlsZS5mYWRlV2lkdGhcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgLjU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHY6IDBcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gXVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3Bvc2l0aW9uVGV4dHVyZSgpIHtcbiAgICAgICAgdmFyIHggPSB0aGlzLl9zaG91bGRDZW50ZXIoKSA/ICh0aGlzLncgLSB0aGlzLl90ZXh0UmVuZGVyZWRXKSAvIDIgOiAwO1xuICAgICAgICBpZiAodGhpcy5zdHlsZS5zaG91bGRTbW9vdGgpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnRCb3guc21vb3RoID0ge1xuICAgICAgICAgICAgICAgIHg6IHhcbiAgICAgICAgICAgIH07XG4gICAgICA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laWdodCA9IHRoaXMuX1RleHQudGV4dHVyZS5nZXRSZW5kZXJIZWlnaHQoKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgc2l6ZUNoYW5nZWQgPSB0aGlzLncgIT09IHdpZHRoIHx8IHRoaXMuaCAhPT0gaGVpZ2h0O1xuICAgICAgICBpZiAod2lkdGggJiYgaGVpZ2h0ICYmIHNpemVDaGFuZ2VkKSB7XG4gICAgICAgICAgICB0aGlzLmggPSBoZWlnaHQ7XG4gICAgICAgICAgICBpZiAoIXRoaXMuZml4ZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLncgPSB3aWR0aDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghdGhpcy5oaWRlT25Mb2FkICYmIHRoaXMuYWxwaGEgPCAxKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5hbHBoYSA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9ub3RpZnlBbmNlc3RvcnMoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfc2V0Q29udGVudChjb250ZW50KSB7XG4gICAgICAgIHRoaXMuX2lzSW5saW5lQ29udGVudCA9IGZhbHNlO1xuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb250ZW50KSB8fCB1dGlscyQxLmlzTWFya3VwU3RyaW5nKGNvbnRlbnQpKSB7XG4gICAgICAgICAgICB0aGlzLl9pc0lubGluZUNvbnRlbnQgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChcInN0cmluZ1wiICE9PSB0eXBlb2YgY29udGVudCAmJiAhdGhpcy5faXNJbmxpbmVDb250ZW50KSB7XG4gICAgICAgICAgICByZXR1cm4gXCJcIjtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gY29udGVudDtcbiAgICB9XG4gICAgZ2V0IHRpdGxlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY29udGVudDtcbiAgICB9XG4gICAgX25vdGlmeUFuY2VzdG9ycygpIHtcbiAgICAgICAgdmFyIHcgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRoaXMudztcbiAgICAgICAgdmFyIGggPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHRoaXMuaDtcbiAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKFwiJGl0ZW1DaGFuZ2VkXCIpO1xuICAgICAgICB0aGlzLnNpZ25hbChcInRleHRCb3hDaGFuZ2VkXCIsIHtcbiAgICAgICAgICAgIHc6IHcsXG4gICAgICAgICAgICBoOiBoXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfY29uc3RydWN0KCkge1xuICAgICAgICBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgIHRoaXMuX21hcnF1ZWVDb250ZW50TGlzdGVuZXJBdHRhY2hlZCA9IGZhbHNlO1xuICAgICAgICB0aGlzLl9tYXJxdWVlT3ZlcnJpZGVMb29wWCA9IHVuZGVmaW5lZDtcbiAgICAgICAgdGhpcy5fcmVzZXRNYXJxdWVlUHJvbWlzZSgpO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICBpZiAoIXRoaXMuY29udGVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX1RleHQgfHwgdGhpcy5fSW5saW5lQ29udGVudCkge1xuICAgICAgICAgICAgICAgIHRoaXMudyA9IHRoaXMuaCA9IDA7XG4gICAgICAgICAgICAgICAgdGhpcy5fbm90aWZ5QW5jZXN0b3JzKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlTWFycXVlZSgpO1xuICAgICAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBUZXh0OiB1bmRlZmluZWQsXG4gICAgICAgICAgICAgICAgICAgIElubGluZUNvbnRlbnQ6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2lzSW5saW5lQ29udGVudCA/IHRoaXMuX3VwZGF0ZUlubGluZUNvbnRlbnQoKSA6IHRoaXMuX3VwZGF0ZVRleHQoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlTWFycXVlZSgpO1xuICAgIH1cbiAgICBfdXBkYXRlSW5saW5lQ29udGVudCgpIHtcbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBUZXh0OiB1bmRlZmluZWRcbiAgICAgICAgfSk7XG4gICAgICAgIHZhciBpbmxpbmVDb250ZW50UGF0Y2ggPSBJbmxpbmVDb250ZW50LnByb3BlcnRpZXMucmVkdWNlKCgoYWNjLCBwcm9wKSA9PiB7XG4gICAgICAgICAgICBpZiAodGhpc1twcm9wXSAhPSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSB0aGlzW3Byb3BdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgfSksIHtcbiAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5fdGV4dFN0eWxlU2V0XG4gICAgICAgICAgICB9KVxuICAgICAgICB9KTtcbiAgICAgICAgaWYgKHRoaXMuX3RleHRTdHlsZVNldC53b3JkV3JhcFdpZHRoKSB7XG4gICAgICAgICAgICBpbmxpbmVDb250ZW50UGF0Y2gudyA9IHRoaXMuX3RleHRTdHlsZVNldC53b3JkV3JhcFdpZHRoO1xuICAgICAgICAgICAgaW5saW5lQ29udGVudFBhdGNoLnJ0dCA9IHRydWU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3RleHRTdHlsZVNldC5tYXhMaW5lcykge1xuICAgICAgICAgICAgaW5saW5lQ29udGVudFBhdGNoLm1heExpbmVzID0gdGhpcy5fdGV4dFN0eWxlU2V0Lm1heExpbmVzO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl90ZXh0U3R5bGVTZXQubWF4TGluZXNTdWZmaXgpIHtcbiAgICAgICAgICAgIGlubGluZUNvbnRlbnRQYXRjaC5tYXhMaW5lc1N1ZmZpeCA9IHRoaXMuX3RleHRTdHlsZVNldC5tYXhMaW5lc1N1ZmZpeDtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIGFscGhhOiAxLFxuICAgICAgICAgICAgSW5saW5lQ29udGVudDogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICB0eXBlOiBJbmxpbmVDb250ZW50LFxuICAgICAgICAgICAgICAgIHc6IHRoaXMud1xuICAgICAgICAgICAgfSwgaW5saW5lQ29udGVudFBhdGNoKSwge30sIHtcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIGxvYWRlZElubGluZUNvbnRlbnQ6IFwiX3NldERpbWVuc2lvbnNcIlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlVGV4dCgpIHtcbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBJbmxpbmVDb250ZW50OiB1bmRlZmluZWRcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICghdGhpcy5fVGV4dCkge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgVGV4dDoge31cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5vbihcInR4TG9hZGVkXCIsIHRoaXMuX3NldERpbWVuc2lvbn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0TWFycXVlZU92ZXJyaWRlWCA9IHJlamVjdDtcbiAgICAgICAgfSkpO1xuICAgIH1cbiAgICBfbG9hZGVkTWFycXVlZUNvbnRlbnQoKSB7XG4gICAgICAgIHRoaXMuc2lnbmFsKFwid2lsbE1hcnF1ZWVcIiwgdGhpcy5fTWFycXVlZSk7XG4gICAgfVxuICAgIF91cGRhdGVNYXJxdWVlKCkge1xuICAgICAgICBpZiAodGhpcy5fTWFycXVlZSAmJiAhdGhpcy5tYXJxdWVlKSB7XG4gICAgICAgICAgICB0aGlzLl90b2dnbGVNYXJxdWVlKHRoaXMuX2NvbnRlbnRUYWcpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLm1hcnF1ZWUpIHtcbiAgICAgICAgICAgIHRoaXMuX3Jlc2V0TWFycXVlZVByb21pc2UoKTtcbiAgICAgICAgICAgIHZhciBtYXJxdWVlUGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMubWFycXVlZVByb3BzKSwge30sIHtcbiAgICAgICAgICAgICAgICB3OiB0aGlzLl90ZXh0U3R5bGVTZXQud29yZFdyYXBXaWR0aCB8fCB0aGlzLncsXG4gICAgICAgICAgICAgICAgaDogdGhpcy5oLFxuICAgICAgICAgICAgICAgIHk6IHRoaXMuc3R5bGUub2Zmc2V0WSxcbiAgICAgICAgICAgICAgICB4OiB0aGlzLnN0eWxlLm9mZnNldFgsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBtYXJxdWVlQ29udGVudExvYWRlZDogXCJfbG9hZGVkTWFycXVlZUNvbnRlbnRcIlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9NYXJxdWVlKSB7XG4gICAgICAgICAgICAgICAgbWFycXVlZVBhdGNoLnR5cGUgPSBNYXJxdWVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX2lzSW5saW5lQ29udGVudCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX0lubGluZUNvbnRlbnQudyA9IDA7XG4gICAgICAgICAgICAgICAgbWFycXVlZVBhdGNoLnRpdGxlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC5jb250ZW50VGV4dHVyZSA9IHRoaXMuX2NvbnRlbnRUYWcuZ2V0VGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC53ID0gdGhpcy5fdGV4dFN0eWxlU2V0LndvcmRXcmFwV2lkdGggfHwgdGhpcy53O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBtYXJxdWVlUGF0Y2guY29udGVudFRleHR1cmUgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgbWFycXVlZVBhdGNoLnRpdGxlID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dDogdGhpcy5fY29udGVudFRhZy50ZXh0LnRleHRcbiAgICAgICAgICAgICAgICB9LCB0aGlzLl90ZXh0U3R5bGVTZXQpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiAwLFxuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgTWFycXVlZTogbWFycXVlZVBhdGNoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fbWFycXVlZUNvbnRlbnRMaXN0ZW5lckF0dGFjaGVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbWFycXVlZUNvbnRlbnRMaXN0ZW5lckF0dGFjaGVkID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChc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J0aWVzLmZvckVhY2goKHByb3AgPT4ge1xuICAgICAgICAgICAgaWYgKFwiZm9udFN0eWxlXCIgIT09IHByb3AgJiYgXCJ1bmRlZmluZWRcIiAhPT0gdHlwZW9mIHRoaXNbXCJfXCIuY29uY2F0KHByb3ApXSkge1xuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBcImNvbnRlbnRcIiA9PT0gcHJvcCA/IFwidGV4dFwiIDogcHJvcDtcbiAgICAgICAgICAgICAgICBmb250U3R5bGVba2V5XSA9IHRoaXNbXCJfXCIuY29uY2F0KHByb3ApXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSkpO1xuICAgICAgICBpZiAodGhpcy53ICYmICF0aGlzLl9pc0lubGluZUNvbnRlbnQgJiYgIXRoaXMuc3R5bGUudGV4dFN0eWxlLndvcmRXcmFwV2lkdGggJiYgdGhpcy5maXhlZCkge1xuICAgICAgICAgICAgZm9udFN0eWxlLndvcmRXcmFwV2lkdGggPSB0aGlzLnc7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZvbnRTdHlsZTtcbiAgICB9XG4gICAgZ2V0IF9jb250ZW50VGFnKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faXNJbmxpbmVDb250ZW50ID8gdGhpcy5fSW5saW5lQ29udGVudCA6IHRoaXMuX1RleHQ7XG4gICAgfVxuICAgIF90b2dnbGVNYXJxdWVlKGNvbnRlbnRUYWcpIHtcbiAgICAgICAgaWYgKHRoaXMubWFycXVlZSkge1xuICAgICAgICAgICAgaWYgKGNvbnRlbnRUYWcpIHtcbiAgICAgICAgICAgICAgICBjb250ZW50VGFnLmFscGhhID0gLjAwMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLl9NYXJxdWVlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fTWFycXVlZS5hbHBoYSA9IDE7XG4gICAgICAgICAgICAgICAgdGhpcy5fTWFycXVlZS5zdGFydFNjcm9sbGluZygpO1xuICAg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ZVBvc2l0aW9ucygpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hhc1ByZWZpeCAmJiB0aGlzLl9QcmVmaXggIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgdGhpcy5fUHJlZml4LnggPSB0aGlzLl9wcmVmaXhYO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9oYXNUaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIueCA9IHRoaXMuX3RpdGxlWDtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5faGFzU3VmZml4ICYmIHRoaXMuX1N1ZmZpeCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICB0aGlzLl9TdWZmaXgueCA9IHRoaXMuX3N1ZmZpeFg7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVByZWZpeCgpIHtcbiAgICAgICAgdmFyIHByZWZpeFN0cmluZyA9IEpTT04uc3RyaW5naWZ5KHRoaXMucHJlZml4KTtcbiAgICAgICAgaWYgKHRoaXMucHJlZml4KSB7XG4gICAgICAgICAgICB2YXIgcHJlZml4UGF0Y2ggPSB7XG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUuaXRlbVNwYWNpbmdcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9QcmVmaXgpIHtcbiAgICAgICAgICAgICAgICBwcmVmaXhQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5fcm93UHJvcHMpLCBwcmVmaXhQYXRjaCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBQcmVmaXg6IHByZWZpeFBhdGNoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeFN1ZmZpeFN0eWxlcyhcInByZWZpeFwiKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIFByZWZpeDogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9wcmV2UHJlZml4ID0gcHJlZml4U3RyaW5nO1xuICAgIH1cbiAgICBfdXBkYXRlUHJlZml4U3VmZml4U3R5bGVzKCkge1xuICAgICAgICB2YXIgdHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogXCJwcmVmaXhcIjtcbiAgICAgICAgdmFyIG1hcCA9IHtcbiAgICAgICAgICAgIHByZWZpeDoge1xuICAgICAgICAgICAgICAgIHRhZzogdGhpcy5fUHJlZml4LFxuICAgICAgICAgICAgICAgIHByb3A6IHRoaXMucHJlZml4LFxuICAgICAgICAgICAgICAgIHByZXZQcm9wOiB0aGlzLl9wcmV2UHJlZml4XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgc3VmZml4OiB7XG4gICAgICAgICAgICAgICAgdGFnOiB0aGlzLl9TdWZmaXgsXG4gICAgICAgICAgICAgICAgcHJvcDogdGhpcy5zdWZmaXgsXG4gICAgICAgICAgICAgICAgcHJldlByb3A6IHRoaXMuX3ByZXZTdWZmaXhcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgdmFyIHt0YWc6IHRhZywgcHJvcDogcHJvcH0gPSBtYXBbdHlwZV07XG4gICAgICAgIHZhciB7cHJldlByb3A6IHByZXZQcm9wfSA9IG1hcFt0eXBlXTtcbiAgICAgICAgdmFyIHByb3BTdHJpbmcgPSBKU09OLnN0cmluZ2lmeShwcm9wKTtcbiAgICAgICAgaWYgKHByb3BTdHJpbmcgIT09IHByZXZQcm9wKSB7XG4gICAgICAgICAgICBwcmV2UHJvcCA9IHByb3BTdHJpbmc7XG4gICAgICAgICAgICB0YWcuaXRlbXMgPSB0aGlzLl9hZGRCdXR0b25Qcm9wcyhwcm9wKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRhZy5JdGVtcy5jaGlsZHJlbi5mb3JFYWNoKCgoaXRlbSwgaWR4KSA9PiB7XG4gICAgICAgICAgICAgICAgaXRlbS5jb2xvciA9IEFycmF5LmlzQXJyYXkocHJvcCkgPyBwcm9wW2lkeF0uY29sb3IgOiBwcm9wLmNvbG9yO1xuICAgICAgICAgICAgICAgIGl0ZW0uc3R5bGUgPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGl0ZW0uc3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5jb250ZW50Q29sb3JcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlVGl0bGUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNUaXRsZSkge1xuICAgICAgICAgICAgdmFyIHRpdGxlUGF0Y2ggPSB7XG4gICAgICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUudGV4dFN0eWxlXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgICAgICB0aXRsZVBhdGNoID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIHk6IGggPT4gaCAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9vblRpdGxlVGV4dEJveENoYW5nZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSwgdGl0bGVQYXRjaCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBUZXh0V3JhcHBlcjoge1xuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICBUaXRsZTogdGl0bGVQYXRjaFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgVGV4dFdyYXBwZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgVGl0bGU6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVTdWZmaXgoKSB7XG4gICAgICAgIGlmICh0aGlzLnN1ZmZpeCkge1xuICAgICAgICAgICAgdmFyIHN1ZmZpeFBhdGNoID0ge1xuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIGl0ZW1TcGFjaW5nOiB0aGlzLnN0eWxlLml0ZW1TcGFjaW5nXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fU3VmZml4KSB7XG4gICAgICAgICAgICAgICAgc3VmZml4UGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuX3Jvd1Byb3BzKSwgc3VmZml4UGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgU3VmZml4OiBzdWZmaXhQYXRjaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhTdWZmaXhTdHlsZXMoXCJzdWZmaXhcIik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBTdWZmaXg6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVRydW5jYXRpb24oKSB7XG4gICAgICAgIGlmICh0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fVGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdGhpcy5maXhlZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuZml4ZWQgPyB0aGlzLl9maXhlZFdvcmRXcmFwV2lkdGggOiAwXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnREaW1lbnNpb25zKCkge1xuICAgICAgICB2YXIgY29udGVudERpbWVuc2lvbnNQYXRjaCA9IHt9O1xuICAgICAgICB2YXIgeSA9IHRoaXMuaCAvIDI7XG4gICAgICAgIGlmICh0aGlzLl9Db250ZW50LnRyYW5zaXRpb24oXCJ3XCIpLnRhcmdldFZhbHVlICE9PSB0aGlzLl9jb250ZW50Vykge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC53ID0gdGhpcy5fY29udGVudFc7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX0NvbnRlbnQueSAhPT0geSkge1xuICAgICAgICAgICAgY29udGVudERpbWVuc2lvbnNQYXRjaC55ID0geTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoT2JqZWN0LmtleXMoY29udGVudERpbWVuc2lvbnNQYXRjaCkubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaChjb250ZW50RGltZW5zaW9uc1BhdGNoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlQ29udGVudFBvc2l0aW9uKCkge1xuICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHRoaXMuX2NvbnRlbnRQcm9wcyk7XG4gICAgfVxuICAgIF91cGRhdGVTdXJmYWNlRGltZW5zaW9ucygpIHtcbiAgICAgICAgdmFyIG5ld1dpZHRoID0gdGhpcy53O1xuICAgICAgICBpZiAodGhpcy5maXhlZCkge1xuICAgICAgICAgICAgbmV3V2lkdGggPSB0aGlzLl93O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbmV3V2lkdGggPSB0aGlzLl9jYWxjRHluYW1pY1dpZHRoKCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG5ld1dpZHRoICE9PSB0aGlzLncpIHtcbiAgICAgICAgICAgIHRoaXMudyA9IG5ld1dpZHRoO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5faFNldEJ5VXNlciAmJiAhdGhpcy5zdHlsZS5oKSB7XG4gICAgICAgICAgICB0aGlzLl9oID0gdGhpcy5zdHlsZS50ZXh0U3R5bGUubGluZUhlaWdodCArIHRoaXMuc3R5bGUucGFkZGluZ1kgKiAyO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycyhcIiRpdGVtQ2hhbmdlZFwiKTtcbiAgICB9XG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lZnRcIjpcbiAgICAgICAgICAgIG1vdW50WCA9IDA7XG4gICAgICAgICAgICB4ID0gdGhpcy5fcGFkZGluZ0xlZnQ7XG4gICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgIGNhc2UgXCJyaWdodFwiOlxuICAgICAgICAgICAgbW91bnRYID0gMTtcbiAgICAgICAgICAgIHggPSB0aGlzLncgLSB0aGlzLl9wYWRkaW5nUmlnaHQ7XG4gICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgIGNhc2UgXCJjZW50ZXJcIjpcbiAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgbW91bnRYID0gLjU7XG4gICAgICAgICAgICB4ID0gdGhpcy53IC8gMjtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBtb3VudFg6IG1vdW50WCxcbiAgICAgICAgICAgIHg6IHhcbiAgICAgICAgfTtcbiAgICB9XG4gICAgZ2V0IF9idXR0b25Qcm9wcygpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNlbnRlckluUGFyZW50OiB0cnVlLFxuICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlXG4gICAgICAgIH07XG4gICAgfVxuICAgIGdldCBfaGFzUHJlZml4KCkge1xuICAgICAgICByZXR1cm4gISEodGhpcy5wcmVmaXggJiYgT2JqZWN0LmtleXModGhpcy5wcmVmaXgpLmxlbmd0aCk7XG4gICAgfVxuICAgIGdldCBfcHJlZml4VygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2hhc1ByZWZpeCAmJiB0aGlzLl9QcmVmaXggIT09IHVuZGVmaW5lZCA/IHRoaXMuX1ByZWZpeC53IDogMDtcbiAgICB9XG4gICAgZ2V0IF9wcmVmaXhYKCkge1xuICAgICAgICByZXR1cm4gMDtcbiAgICB9XG4gICAgZ2V0IF9oYXNUaXRsZSgpIHtcbiAgICAgICAgcmV0dXJuICEhdGhpcy50aXRs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ge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N1ZmZpeFggKyB0aGlzLl9zdWZmaXhXO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2hhc1RpdGxlICYmIHRoaXMuX1RpdGxlICYmIHRoaXMuX1RpdGxlLnZpc2libGUpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl90aXRsZVggKyB0aGlzLl90aXRsZVc7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5faGFzUHJlZml4KSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fcHJlZml4WCArIHRoaXMuX3ByZWZpeFc7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIDA7XG4gICAgfVxuICAgIGdldCBfcm93UHJvcHMoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgYXV0b1Jlc2l6ZUhlaWdodDogdHJ1ZSxcbiAgICAgICAgICAgIGF1dG9SZXNpemVXaWR0aDogdHJ1ZVxuICAgICAgICB9O1xuICAgIH1cbiAgICBnZXQgX3RvdGFsVGl0bGVQYWRkaW5nWCgpIHtcbiAgICAgICAgdmFyIHRvdGFsVGl0bGVQYWRkaW5nID0gMDtcbiAgICAgICAgaWYgKHRoaXMuX2hhc1ByZWZpeCkge1xuICAgICAgICAgICAgdG90YWxUaXRsZVBhZGRpbmcgKz0gdGhpcy5zdHlsZS5jb250ZW50U3BhY2luZztcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5faGFzU3VmZml4KSB7XG4gICAgICAgICAgICB0b3RhbFRpdGxlUGFkZGluZyArPSB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0b3RhbFRpdGxlUGFkZGluZztcbiAgICB9XG4gICAgZ2V0IF9maXhlZFdvcmRXcmFwV2lkdGgoKSB7XG4gICAgICAgIH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SksIHt9LCB7XG4gICAgICAgICAgICBUaXRsZToge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfdXBkYXRlUG9zaXRpb25zXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICBzdXBlci5fdXBkYXRlKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRpdGxlKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVBvc2l0aW9ucygpO1xuICAgIH1cbiAgICBfdXBkYXRlUG9zaXRpb25zKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVUaXRsZVBvc2l0aW9uKCk7XG4gICAgfVxuICAgIF91cGRhdGVUaXRsZSgpIHtcbiAgICAgICAgdGhpcy5fVGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9jYWxjdWxhdGVUZXh0V2lkdGgoKVxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfY2FsY3VsYXRlVGV4dFdpZHRoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy53IC0gdGhpcy5zdHlsZS5wYWRkaW5nSG9yaXpvbnRhbCAqIDI7XG4gICAgfVxuICAgIF91cGRhdGVUaXRsZVBvc2l0aW9uKCkge1xuICAgICAgICB0aGlzLl9UaXRsZS54ID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RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkpLCB7fSwge1xuICAgICAgICAgICAgRGVzY3JpcHRpb246IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3VwZGF0ZVBvc2l0aW9uc1wiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIERldGFpbHM6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIG1vdW50WTogMVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVEZXNjcmlwdGlvbigpO1xuICAgICAgICB0aGlzLl91cGRhdGVEZXRhaWxzKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVBvc2l0aW9ucygpO1xuICAgIH1cbiAgICBfdXBkYXRlUG9zaXRpb25zKCkge1xuICAgICAgICBzdXBlci5fdXBkYXRlUG9zaXRpb25zKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZURlc2NyaXB0aW9uUG9zaXRpb24oKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlRGV0YWlsc1Bvc2l0aW9uKCk7XG4gICAgfVxuICAgIF91cGRhdGVEZXNjcmlwdGlvbigpIHtcbiAgICAgICAgdGhpcy5fRGVzY3JpcHRpb24ucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5kZXNjcmlwdGlvbixcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUu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RpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJEQ7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHZhciBjZW50ZXIgPSB7XG4gICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICB4OiB3ID0+IHcgLyAyLFxuICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICB9O1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgQm9keTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICBydHQ6IHRydWVcbiAgICAgICAgICAgIH0sIGNlbnRlciksIHt9LCB7XG4gICAgICAgICAgICAgICAgS25vYjogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBjZW50ZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBhbHBoYTogMFxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9KSxcbiAgICAgICAgICAgIFN0cm9rZTogY2VudGVyXG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJLbm9iXCIsIFwiQm9keVwiLCBcIlN0cm9rZVwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJjaGVja2VkXCIgXTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlQm9keSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVTdHJva2UoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlS25vYigpO1xuICAgICAgICBpZiAodGhpcy5fY2hlY2tlZENoYW5nZWQpIHtcbiAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycyhcIiRhbm5vdW5jZVwiLCB0aGlzLmFubm91bm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lvXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJEU7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIucHJvcGVydGllcywgXCJyYWRpb1wiLCBcInN1YnRpdGxlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCBcIlJhZGlvXCIsIFwiU3VidGl0bGVcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fdGVtcGxhdGUoKSksIHt9LCB7XG4gICAgICAgICAgICBTdWJ0aXRsZToge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfdXBkYXRlUG9zaXRpb25zXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICBzdXBlci5fdXBkYXRlKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVJhZGlvKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVN1YnRpdGxlKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVBvc2l0aW9ucygpO1xuICAgIH1cbiAgICBfdXBkYXRlUG9zaXRpb25zKCkge1xuICAgICAgICBzdXBlci5fdXBkYXRlUG9zaXRpb25zKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVN1YnRpdGxlUG9zaXRpb24oKTtcbiAgICB9XG4gICAgX3VwZGF0ZVN1YnRpdG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RBLFxuICAgIG1vZGU6IG1vZGUkYSxcbiAgICB0b25lOiB0b25lJGpcbn0pO1xuXG5jbGFzcyBDaGVja2JveCBleHRlbmRzIEJhc2UkMSB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkNoZWNrYm94XCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJEE7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHZhciBjZW50ZXIgPSB7XG4gICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICB4OiB3ID0+IHcgLyAyLFxuICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICB9O1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgQm9keTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICBydHQ6IHRydWVcbiAgICAgICAgICAgIH0sIGNlbnRlciksIHt9LCB7XG4gICAgICAgICAgICAgICAgQ2hlY2s6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEljb25cbiAgICAgICAgICAgICAgICB9LCBjZW50ZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBhbHBoYTogMFxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9KSxcbiAgICAgICAgICAgIFN0cm9rZTogY2VudGVyXG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJDaGVja1wiLCBcIkJvZHlcIiwgXCJTdHJva2VcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiY2hlY2tlZFwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgYWxpYXNTdHlsZXMoKSB7XG4gICAgICAgIHJldHVybiBbIHtcbiAgICAgICAgICAgIHByZXY6IFwiY2hlY2tTcmNcIixcbiAgICAgICAgICAgIGN1cnI6IFwiaWNvblwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIHByZXY6IFwiY2hlY2tIXCIsXG4gICAgICAgICAgICBjdXJyOiBcImljb25IZWlnaHRcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBwcmV2OiBcImNoZWNrV1wiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uV2lkdGhcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBwcmV2OiBcImNoZWNrSGVpZ2h0XCIsXG4gICAgICAgICAgICBjdXJyOiBcImljb25IZWlnaHRcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBwcmV2OiBcImNoZWNrV2lkdGhcIixcbiAgICAgICAgICAgIGN1cnI6IFwiaWNvbldpZHRoXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVCb2R5KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVN0cm9rZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVDaGVjaygpO1xuICAgICAgICBpZiAodGhpcy5fY2hlY2tlZENoYW5nZWQpIHtcbiAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycyhcIiRhbm5vdW5jZVwiLCB0aGlzLmFubm91bmNlKTtcbiAgICAgICAgICAgIHRoaXMuX2NoZWNrZWRDaGFuZ2VkID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fdXBkYXRlT3BhY2l0eSgpO1xuICAgIH1cbiAgICBfdXBkYXRlQ2hlY2soKSB7XG4gICAgICAgIHRoaXMuX0NoZWNrLnBhdGNoKHtcbiAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUuaWNvbldpZ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cbiAgICAgICAgfSxcbiAgICAgICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5maWxsQnJhbmRcbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyR6ID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkeixcbiAgICB0b25lOiB0b25lJGlcbn0pO1xuXG5jbGFzcyBMYWJlbCBleHRlbmRzIEJhc2UkMSB7XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIEJhY2tncm91bmQ6IHt9LFxuICAgICAgICAgICAgVGV4dDoge1xuICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgbW91bnRYOiAuNSxcbiAgICAgICAgICAgICAgICB0ZXh0OiB7fVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTGFiZWxcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkejtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcInRpdGxlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkJhY2tncm91bmRcIiwgXCJUZXh0XCIgXTtcbiAgICB9XG4gICAgX2luaXQoKSB7XG4gICAgICAgIHRoaXMuX1RleHQub24oXCJ0eExvYWRlZFwiLCB0aGlzLl91cGRhdGVCYWNrZ3JvdW5kLmJpbmQodGhpcykpO1xuICAgICAgICBzdXBlci5faW5pdCgpO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl91cGRhd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9XG4gICAgc2V0IGFubm91bmNlKGFubm91bmNlKSB7XG4gICAgICAgIHN1cGVyLmFubm91bmNlID0gYW5ub3VuY2U7XG4gICAgfVxuICAgIGdldCBhbm5vdW5jZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2Fubm91bmNlIHx8IHRoaXMuX1RleHQgJiYgdGhpcy5fVGV4dC50ZXh0LnRleHQ7XG4gICAgfVxufVxuXG5mdW5jdGlvbiB3aXRoTWFycXVlZVN5bmMoQmFzZSkge1xuICAgIHJldHVybiBjbGFzcyBleHRlbmRzIEJhc2Uge1xuICAgICAgICBzdGF0aWMgZ2V0IG5hbWUoKSB7XG4gICAgICAgICAgICByZXR1cm4gQmFzZS5uYW1lO1xuICAgICAgICB9XG4gICAgICAgIF9pbml0KCkge1xuICAgICAgICAgICAgc3VwZXIuX2luaXQoKTtcbiAgICAgICAgICAgIGlmICh0aGlzLl9zaG91bGRTeW5jKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlU2lnbmFscygpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIF91cGRhdGUoKSB7XG4gICAgICAgICAgICBzdXBlci5fdXBkYXRlKCk7XG4gICAgICAgICAgICBpZiAodGhpcy5fc2hvdWxkU3luYykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVNpZ25hbHMoKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2xlYW51cFN5bmNWYWx1ZXMoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBfY2xlYW51cFN5bmNWYWx1ZXMoKSB7XG4gICAgICAgICAgICB0aGlzLnN5bmNBcnJheS5tYXAoKGNvbXBvbmVudCA9PiB7XG4gICAgICAgICAgICAgICAgY29tcG9uZW50Lm1hcnF1ZWVPdmVycmlkZUxvb3BYID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIGNvbXBvbmVudC5zaWduYWxzICYmIGNvbXBvbmVudC5zaWduYWxzLndpbGxNYXJxdWVlICYmIGRlbGV0ZSBjb21wb25lbnQuc2lnbmFscy53aWxsTWFycXVlZTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfVxuICAgICAgICBfdXBkYXRlU2lnbmFscygpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnN5bmNBcnJheSkge1xuICAgICAgICAgICAgICAgIHRoaXMuc3luY0FycmF5Lm1hcCgoY29tcG9uZW50ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50LnNpZ25hbHMgPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGNvbXBvbmVudC5zaWduYWxzKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHdpbGxNYXJxdWVlOiBcIl93aWxsTWFycXVlZVwiXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBfd2lsbE1hcnF1ZWUoY29tcFJlZikge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3Nob3VsZFN5bmMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9sb25nZXN0TWFycXVlZVdpZHRoID0gTWF0aC5tYXgoY29tcFJlZi5fdGV4dFJlbmRlcmVkVyB8fCAwLCB0aGlzLl9sb25nZXN0TWFycXVlZVdpZHRoIHx8IDApO1xuICAgICAgICAgICAgICAgIHRoaXMuc3luY0FycmF5Lm1hcCgoY29tcG9uZW50ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50Lm1hcnF1ZWVPdmVycmlkZUxvb3BYID0gdGhpcy5fbG9uZ2VzdE1hcnF1ZWVXaWR0aDtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9zaG91bGRTeW5jKCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuc3R5bGUubWFycXVlZVN5bmMgPT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCF0aGlzLnN5bmNBcnJheSkge1xuICAgICAgICAgICAgICAgIGxvZ2dlckluc3RhbmNlLndhcm4oXCJ3YXJuaW5nOiBjb21wb25lbnRzIHVzaW5nIE1hcnF1ZWVTeW5jIG11c3QgaGF2ZSBhIHN5bmNBcnJheSBnZXR0ZXIgZGVmaW5lZC5cIik7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfSBlbHNlIGlmICghQXJyYXkuaXNBcnJheSh0aGlzLnN5bmNBcnJheSkpIHtcbiAgICAgICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS53YXJuKFwid2FybmluZzogc3luY0FycmF5IG11c3QgYmUgdHlwZW9mIGFycmF5LlwiKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuc3luY0FycmF5Lmxlbmd0aCA8IDIpIHtcbiAgICAgICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS53YXJuKFwid2FybmluZzogc3luY0FycmF5IG11c3QgY29udGFpbiBhdCBsZWFzdCB0d28gY29tcG9uZW50IHJlZmVyZW5jZXMuXCIpO1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG52YXIgYmFzZSR5ID0gdGhlbWUgPT4gKHtcbiAgICBkZXNjcmlwdGlvblRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGVtZS50eXBvZ3JhcGh5LmJvZHkyKSwge30sIHtcbiAgICAgICAgbWF4T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0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFNlY29uZGFyeVxuICAgICAgICB9LFxuICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGRpc2FibGVkOiB7XG4gICAgICAgICAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlXG4gICAgICAgIH0sXG4gICAgICAgIHN1YnRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VcbiAgICAgICAgfSxcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICB0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHN1YnRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgfSxcbiAgICAgICAgc3VidGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFNlY29uZGFyeVxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJHkgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSR5LFxuICAgIG1vZGU6IG1vZGUkOSxcbiAgICB0b25lOiB0b25lJGhcbn0pO1xuXG5jbG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uU3VidGl0bGVcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIkRldGFpbHNXcmFwcGVyXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHQuRGV0YWlsc1dyYXBwZXJcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIkRldGFpbHNcIixcbiAgICAgICAgICAgIHBhdGg6IFwiVGV4dC5EZXRhaWxzV3JhcHBlci5EZXRhaWxzXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXNjcmlwdGlvblwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LkRlc2NyaXB0aW9uXCJcbiAgICAgICAgfSwgXCJMb2dvXCIgXTtcbiAgICB9XG4gICAgX3RpdGxlTG9hZGVkKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVMYXlvdXQoKTtcbiAgICB9XG4gICAgX3N1YnRpdGxlTG9hZGVkKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVMYXlvdXQoKTtcbiAgICB9XG4gICAgX2RldGFpbHNMb2FkZWQoX3JlZjE5KSB7XG4gICAgICAgIHZhciB7dzogdywgaDogaH0gPSBfcmVmMTk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZURldGFpbHNMYXlvdXQoe1xuICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgIGg6IGhcbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUxheW91dCgpO1xuICAgIH1cbiAgICBfZGVzY3JpcHRpb25Mb2FkZWQoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUxheW91dCgpO1xuICAgIH1cbiAgICBfdXBkYXRlRGV0YWlsc0xheW91dChfcmVmMjApIHtcbiAgICAgICAgdmFyIHt3OiB3LCBoOiBofSA9IF9yZWYyMDtcbiAgICAgICAgaWYgKCF0aGlzLmRldGFpbHMgJiYgIXRoaXMuX0RldGFpbHMpIHtcbiAgICAgICAgICAgIHJldHVybjtc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MuaCAtIHRoaXMuX1RleHQuaCkgLyAyO1xuICAgIH1cbiAgICBfdXBkYXRlTWV0YWRhdGFIZWlnaHQoKSB7XG4gICAgICAgIHZhciBuZXdIID0gTWF0aC5tYXgodGhpcy5sb2dvSGVpZ2h0LCB0aGlzLl9UZXh0LmgpO1xuICAgICAgICBpZiAodGhpcy5oICE9PSBuZXdIKSB7XG4gICAgICAgICAgICB0aGlzLmggPSBuZXdIO1xuICAgICAgICAgICAgdGhpcy5zaWduYWwoXCJ1cGRhdGVDb21wb25lbnREaW1lbnNpb25zXCIpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVUaXRsZSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLnRpdGxlICYmICF0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHQuY2hpbGRMaXN0LmFkZEF0KHtcbiAgICAgICAgICAgICAgICByZWY6IFwiVGl0bGVcIixcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3RpdGxlTG9hZGVkXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LCAwKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9UaXRsZS5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLnRpdGxlLFxuICAgICAgICAgICAgbWFycXVlZTogdGhpcy5tYXJxdWVlLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50aXRsZVRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogdGhpcy5fVGV4dC53XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVTdWJ0aXRsZSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLnN1YnRpdGxlICYmICF0aGlzLl9TdWJ0aXRsZSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fU3VidGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHQuY2hpbGRMaXN0LmFkZEF0KHtcbiAgICAgICAgICAgICAgICByZWY6IFwiU3VidGl0bGVcIixcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3N1YnRpdGxlTG9hZGVkXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LCAxKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9TdWJ0aXRsZS5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLnN1YnRpdGxlLFxuICAgICAgICAgICAgbWFycXVlZTogdGhpcy5tYXJxdWVlLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5zdWJ0aXRsZVRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogdGhpcy5fVGV4dC53XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHJlc2V0TWFycXVlZSgpIHtcbiAgICAgICAgaWYgKHRoaXMubWFycXVlZSkge1xuICAgICAgICAgICAgaWYgKHRoaXMudGl0bGUpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVRpdGxlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX1RpdGxlLnRvZ2dsZU1hcnF1ZWUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLmRlc2NyaXB0aW9uKSB7XG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9EZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVEZXNjcmlwdGlvbigpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLl9EZXNjcmlwdGlvbi50b2dnbGVNYXJxdWVlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZURldGFpbHMoKSB7XG4gICAgICAgIGlmICghdGhpcy5kZXRhaWxzICYmICF0aGlzLl9EZXRhaWxzKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLl9EZXRhaWxzKSB7XG4gICAgICAgICAgICB0aGlzLl9EZXRhaWxzV3JhcHBlci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgRGV0YWlsczoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfZGV0YWlsc0xvYWRlZFwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9EZXRhaWxzLnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGV0YWlscyxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLmRldGFpbHNUZXh0U3R5bGVcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh0aGlzLl9EZXRhaWxzLmZpbmFsVyA+IHRoaXMuX3RleHRXKCkpIHtcbiAgICAgICAgICAgIHRoaXMuX0RldGFpbHMucGF0Y2goe1xuICAgICAgICAgICAgICAgIHc6IHRoaXMuX3RleHRXKCkgKyB0aGlzLnN0eWxlLmZhZGVXaWR0aCAvIDIsXG4gICAgICAgICAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEZhZGVTaGFkZXIsXG4gICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uTGVmdDogMCxcbiAgICAgICAgICAgICAgICAgICAgcG9zaXRpb25SaWdodDogdGhpcy5zdHlsZS5mYWRlV2lkdGhcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHJ0dDogdHJ1ZVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9EZXRhaWxzV3JhcHBlci5zaGFkZXIgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fRGV0YWlsc1dyYXBwZXIudmlzaWJsZSA9IHRoaXMuZGV0YWlscyA/IHRydWUgOiBmYWxzZTtcbiAgICAgICAgdGhpcy5fRGV0YWlsc1dyYXBwZXIuYWxwaGEgPSB0aGlzLnN0eWxlLmFscGhhO1xuICAgIH1cbiAgICBfdXBkYXRlRGVzY3JpcHRpb24oKSB7XG4gICAgICAgIGlmICghdGhpcy5kZXNjcmlwdGlvbiAmJiAhdGhpcy5fRGVzY3JpcHRpb24pIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX0Rlc2NyaXB0aW9uKSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LmNoaWxkTGlzdC5hZGQoe1xuICAgICAgICAgICAgICAgIHJlZjogXCJEZXNjcmlwdGlvblwiLFxuICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfZGVzY3JpcHRpb25Mb2FkZWRcIlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX0Rlc2NyaXB0aW9uLnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGVzY3JpcHRpb24sXG4gICAgICAgICAgICBtYXJxdWVlOiB0aGlzLm1hcnF1ZWUsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uVGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgbWF4TGluZXM6IDEsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9UZXh0LndcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZUxvZ28oKSB7XG4gICAgICAgIGlmICghdGhpcy5sb2dvICYmICF0aGlzLl9Mb2dvKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLl9Mb2dvKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBMb2dvOiB7XG4gICAgICAgICAgICAgICAgICAgIGZsZXhJdGVtOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvblxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMubG9nb1Bvc2l0aW9uID0gdGhpcy5sb2dvUG9zaXRpb24gfHwgXCJyaWdodFwiO1xuICAgICAgICB2YXIgc3VidGl0bGVIID0gdGhpcy5zdWJ0aXRsZSAmJiB0aGlzLl9TdWJ0aXRsZSAmJiB0aGlzLl9TdWJ0aXRsZS5oIHx8IDA7XG4gICAgICAgIHRoaXMuX0xvZ28ucGF0Y2goe1xuICAgICAgICAgICAgdzogdGhpcy5sb2dvV2lkdGgsXG4gICAgICAgICAgICBoOiB0aGlzLmxvZ29IZWlnaHQsXG4gICAgICAgICAgICBpY29uOiB0aGlzLmxvZ28sXG4gICAgICAgICAgICBhbHBoYTogdGhpcy5zdHlsZS5hbHBoYVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5fTG9nby54ID0gdGhpcy5sb2dvUG9zaXRpb24gPT09IFwibGVmdFwiID8gMCA6IHRoaXMudyAtIHRoaXMuX0xvZ28udztcbiAgICAgICAgdGhpcy5fTG9nby55ID0gKHRoaXMuaCAtIHRoaXMubG9nb0hlaWdodCArIHN1YnRpdGxlSCkgLyAyO1xuICAgIH1cbiAgICBfdGV4dFcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLncgLSAodGhpcy5sb2dvID8gdGhpcy5sb2dvV2lkdGggKyB0aGlzLnN0eWxlLmxvZ29QYWRkaW5nIDogMCk7XG4gICAgfVxuICAgIF90ZXh0SCgpIHtcbiAgICAgICAgdmFyIHRpdGxlSCA9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AgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFNlY29uZGFyeVxuICAgICAgICB9LFxuICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVNlY29uZGFyeVxuICAgICAgICB9LFxuICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkeCA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJHgsXG4gICAgdG9uZTogdG9uZSRnXG59KTtcblxuY2xhc3MgTWV0YWRhdGFUaWxlIGV4dGVuZHMgTWV0YWRhdGFCYXNlJDEge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJNZXRhZGF0YVRpbGVcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkeDtcbiAgICB9XG4gICAgX3VwZGF0ZURldGFpbHMoKSB7XG4gICAgICAgIGlmICghdGhpcy5kZXRhaWxzICYmICF0aGlzLl9EZXRhaWxzKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuZGVzY3JpcHRpb24gJiYgdGhpcy5fRGV0YWlscykge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlscy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgY29udGVudDogXCJcIlxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB0aGlzLl9EZXRhaWxzLmFscGhhID0gMDtcbiAgICAgICAgICAgIHRoaXMuX0RldGFpbHMudmlzaWJsZSA9IGZhbHNlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3VwZXIuX3VwZGF0ZURldGFpbHMoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlRGV0YWlsc0xheW91dChfcmVmMjEpIHtcbiAgICAgICAgdmFyIHtoOiBofSA9IF9yZWYyMTtcbiAgICAgICAgaWYgKCF0aGlzLmRldGFpbHMgJiYgIXRoaXMuX0RldGFpbHMpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fRGV0YWlscyAmJiAhdGhpcy5kZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlsc1dyYXBwZXIuaCA9IGg7XG4gICAgICAgICAgICB0aGlzLl9EZXRhaWxzV3JhcHBlci5hbHBoYSA9IHRoaXMuc3R5bGUuYWxwaGE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9EZXRhaWxzV3JhcHBlci5oID0gMDtcbiAgICAgICAgfVxuICAgIH1cbiAgICBzZXQgYW5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tcbiAgICAgICAgICAgICAgICBBcnR3b3JrOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEFydHdvcmssXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlTG9hZGVkOiBcIl9pbWFnZUxvYWRlZFwiXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAuNVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgQ29udGVudDoge1xuICAgICAgICAgICAgICAgICAgICBtb3VudDogLjVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiYXJ0d29ya1wiLCBcImJhZGdlXCIsIFwiY2hlY2tib3hcIiwgXCJjaXJjbGVcIiwgXCJsYWJlbFwiLCBcImxvZ29cIiwgXCJtZXRhZGF0YVwiLCBcIm1ldGFkYXRhTG9jYXRpb25cIiwgXCJwZXJzaXN0ZW50TWV0YWRhdGFcIiwgXCJwcm9ncmVzc0JhclwiLCBcInNyY1wiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgYWxpYXNTdHlsZXMoKSB7XG4gICAgICAgIHJldHVybiBbIHtcbiAgICAgICAgICAgIHByZXY6IFwiaWNvbkhlaWdodFwiLFxuICAgICAgICAgICAgY3VycjogXCJsb2dvSGVpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJpY29uV2lkdGhcIixcbiAgICAgICAgICAgIGN1cnI6IFwibG9nb1dpZHRoXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzUHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsge1xuICAgICAgICAgICAgcHJldjogXCJpY29uU3JjXCIsXG4gICAgICAgICAgICBjdXJyOiBcImxvZ29cIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIudGFncywgXCJBcnR3b3JrXCIsIFwiQ29udGVudFwiLCBcIlRpbGVcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJCYWRnZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LkJhZGdlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJDaGVja2JveFwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LkNoZWNrYm94XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJMb2dvXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnQuTG9nb1wiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiTWV0YWRhdGFcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5NZXRhZGF0YVwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiUHJvZ3Jlc3NCYXJcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5Qcm9ncmVzc0JhclwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiTGFiZWxcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5MYWJlbFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc2V0IGFubm91bmNlKGFubm91bmNlKSB7XG4gICAgICAgIHN1cGVyLmFubm91bmNlID0gYW5ub3VuY2U7XG4gICAgfVxuICAgIGdldCBhbm5vdW5jZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2Fubm91bmNlIHx8IFsgdGhpcy5fTWV0YWRhdGEgJiYgdGhpcy5fTWV0YWRhdGEuYW5ub3VuY2UsIHRoaXMuX0JhZGdlICYmIHRoaXMuX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gLyAyLFxuICAgICAgICAgICAgeTogdGhpcy5faCAvIDJcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9Db250ZW50LCBpdGVtQ29udGFpbmVyUGF0Y2gsIE9iamVjdC5rZXlzKGl0ZW1Db250YWluZXJQYXRjaCkucmVkdWNlKCgoYWNjLCBwcm9wKSA9PiB7XG4gICAgICAgICAgICBhY2NbcHJvcF0gPSBbIGl0ZW1Db250YWluZXJQYXRjaFtwcm9wXSwgdGhpcy5faXNGb2N1c2VkTW9kZSA/IHRoaXMuc3R5bGUuYW5pbWF0aW9uRW50cmFuY2UgOiB0aGlzLnN0eWxlLmFuaW1hdGlvbkV4aXQgXTtcbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCB7fSkpO1xuICAgIH1cbiAgICBfdXBkYXRlTG9nbygpIHtcbiAgICAgICAgaWYgKCF0aGlzLmxvZ28pIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIExvZ286IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGxvZ29PYmplY3QgPSB7XG4gICAgICAgICAgICB3OiB0aGlzLnN0eWxlLmxvZ29XaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUubG9nb0hlaWdodCxcbiAgICAgICAgICAgIGljb246IHRoaXMubG9nbyxcbiAgICAgICAgICAgIGFscGhhOiB0aGlzLl9zaG91bGRTaG93TG9nbyA/IHRoaXMuc3R5bGUuYWxwaGEgOiAuMDAxLFxuICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5wYWRkaW5nWCxcbiAgICAgICAgICAgIHk6IHRoaXMuX2NhbGN1bGF0ZUxvZ29ZUG9zaXRpb24oKVxuICAgICAgICB9O1xuICAgICAgICBpZiAoIXRoaXMuX0xvZ28pIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIExvZ286IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IDFcbiAgICAgICAgICAgICAgICB9LCBsb2dvT2JqZWN0KVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmFwcGx5U21vb3RoKHRoaXMuX0xvZ28sIGxvZ29PYmplY3QpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9jYWxjdWxhdGVMb2dvWVBvc2l0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5faXNJbnNldE1ldGFkYXRhICYmIHRoaXMuX01ldGFkYXRhKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbWV0YWRhdGFZIC0gdGhpcy5fTWV0YWRhdGEuaDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5fcHJvZ3Jlc3NCYXJZID8gdGhpcy5fcHJvZ3Jlc3NCYXJZIC0gdGhpcy5zdHlsZS5wYWRkaW5nWUJldHdlZW5Db250ZW50IDogdGhpcy5faCAtIHRoaXMuc3R5bGUucGFkZGluZ1k7XG4gICAgfVxuICAgIGdldCBfc2hvdWxkU2hvd0xvZ28oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmxvZ28gJiYgKHRoaXMucGVyc2lzdGVudE1ldGFkYXRhIHx8IHRoaXMuX2lzRm9jdXNlZE1vZGUpO1xuICAgIH1cbiAgICBfdXBkYXRlQXJ0d29yaygpIHtcbiAgICAgICAgdmFyIF90aGlzJHN0eWxlMywgX3RoaXMkYXJ0d29yaztcbiAgICAgICAgdGhpcy5fQXJ0d29yay5wYXRjaChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgaDogdGhpcy5faCxcbiAgICAgICA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zQ2lyY2xlTGF5b3V0KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fQmFkZ2UpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgQmFkZ2U6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBiYWRnZVBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLmJhZGdlKSwge30sIHtcbiAgICAgICAgICAgIG1vZGU6IHRoaXMubW9kZSxcbiAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUucGFkZGluZ1gsXG4gICAgICAgICAgICB5OiB0aGlzLnN0eWxlLnBhZGRpbmdZLFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuX3Nob3VsZFNob3dCYWRnZUxhYmVsID8gMSA6IC4wMDFcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICghdGhpcy5fQmFkZ2UpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIEJhZGdlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBCYWRnZVxuICAgICAgICAgICAgICAgIH0sIGJhZGdlUGF0Y2gpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWRCYWRnZTogXCJfdXBkYXRlQmFkZ2VcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fQmFkZ2UucGF0Y2goYmFkZ2VQYXRja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0gbnVsbCB8fCBfdGhpcyRwcm9ncmVzc0JhcjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJHByb2dyZXNzQmFyMi5wcm9ncmVzcykgPT09IFwibnVtYmVyXCIgJiYgdGhpcy5wcm9ncmVzc0Jhci5wcm9ncmVzcykgfHwgdGhpcy5faXNDaXJjbGVMYXlvdXQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9Qcm9ncmVzc0Jhcikge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNob3VsZFNtb290aCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9Qcm9ncmVzc0Jhci5fZ2V0VHJhbnNpdGlvbihcImFscGhhXCIpLm9uY2UoXCJmaW5pc2hcIiwgKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbW92ZVByb2dyZXNzQmFyKCk7XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fUHJvZ3Jlc3NCYXIuc21vb3RoID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgYWxwaGE6IDBcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW1vdmVQcm9ncmVzc0JhcigpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5wcm9ncmVzc0Jhci5wcm9ncmVzcyA+IDApIHtcbiAgICAgICAgICAgIHZhciBwcm9ncmVzc1BhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnByb2dyZXNzQmFyKSwge30sIHtcbiAgICAgICAgICAgICAgICBtb2RlOiB0aGlzLm1vZGUsXG4gICAgICAgICAgICAgICAgdzogdGhpcy5fdyAtIHRoaXMuc3R5bGUucGFkZGluZ1ggKiAyLFxuICAgICAgICAgICAgICAgIHg6IHRoaXMuX3cgLyAyLFxuICAgICAgICAgICAgICAgIHk6IHRoaXMuX2ggLSB0aGlzLnN0eWxlLnBhZGRpbmdZUHJvZ3Jlc3NcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9Qcm9ncmVzc0Jhcikge1xuICAgICAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBQcm9ncmVzc0JhcjogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBwcm9ncmVzc1BhdGNoKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFByb2dyZXNzQmFyLFxuICAgICAgICAgICAgICAgICAgICAgICAgbW91bnRYOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WTogMSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFscGhhOiB0aGlzLl9oYXNNZXRhZGF0YSAmJiB0aGlzLnNob3VsZFNtb290aCA/IC4wMDEgOiAxXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2hvdWxkU21vb3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX1Byb2dyZXNzQmFyLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFscGhhOiBbIDEsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxheTogdGhpcy5zdHlsZS5hbmltYXRpb25FbnRyYW5jZS5kdXJhdGlvblxuICAgICAgICAgICAgICAgICAgICAgICAgfSBdXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuYXBwbHlTbW9vdGgodGh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AgICAgICAgICAgTWV0YWRhdGE6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLl9NZXRhZGF0YSAmJiB0aGlzLl9oYXNNZXRhZGF0YSkge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgTWV0YWRhdGE6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IE1ldGFkYXRhVGlsZSxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlQ29tcG9uZW50RGltZW5zaW9uczogXCJfbWV0YWRhdGFMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSwgdGhpcy5fbm9uU21vb3RoaW5nTWV0YWRhdGFQYXRjaCksIHRoaXMuX21ldGFkYXRhUGF0Y2gpXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9NZXRhZGF0YS5wYXRjaCh0aGlzLl9ub25TbW9vdGhpbmdNZXRhZGF0YVBhdGNoKTtcbiAgICAgICAgdGhpcy5fYW5pbWF0ZU1ldGFkYXRhKCk7XG4gICAgfVxuICAgIF9hbmltYXRlTWV0YWRhdGEoKSB7XG4gICAgICAgIGlmICghdGhpcy5fTWV0YWRhdGEpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmFwcGx5U21vb3RoKHRoaXMuX01ldGFkYXRhLCB0aGlzLl9tZXRhZGF0YVBhdGNoLCB0aGlzLl9tZXRhZGF0YVRyYW5zaXRpb25zKTtcbiAgICAgICAgaWYgKCF0aGlzLl9pc0ZvY3VzZWRNb2RlKSB7XG4gICAgICAgICAgICB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ICAgcmV0dXJuIHtcbiAgICAgICAgICAgIFJvdzoge1xuICAgICAgICAgICAgICAgIHR5cGU6IFJvdyxcbiAgICAgICAgICAgICAgICBhdXRvUmVzaXplV2lkdGg6IHRydWVcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImRpc2FibGVSYWRpdXNcIiwgXCJjb3VudGVyVGV4dFwiLCBcInByb3ZpZGVyc1wiLCBcInZpc2libGVDb3VudFwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJSb3dcIiBdO1xuICAgIH1cbiAgICBnZXQgcHJvdmlkZXJzSGlkZGVuKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5wcm92aWRlcnMubGVuZ3RoIC0gdGhpcy5fdmlzaWJsZUNvdW50O1xuICAgIH1cbiAgICBfY29uc3RydWN0KCkge1xuICAgICAgICB0aGlzLl9wcm92aWRlcnMgPSBbXTtcbiAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVQcm92aWRlcnMoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ291bnRlcigpO1xuICAgIH1cbiAgICBfdXBkYXRlUHJvdmlkZXJzKCkge1xuICAgICAgICB2YXIgcHJvdmlkZXJMaXN0ID0gW107XG4gICAgICAgIHRoaXMucHJvdmlkZXJzLnNsaWNlKDAsIHRoaXMudmlzaWJsZUNvdW50KS5mb3JFYWNoKChwcm92aWRlciA9PiB7XG4gICAgICAgICAgICB2YXIgcGF0Y2ggPSB7XG4gICAgICAgICAgICAgICAgY2VudGVySW5QYXJlbnQ6IHRydWUsXG4gICAgICAgICAgICAgICAgcmFkaXVzOiB0aGlzLmRpc2FibGVSYWRpdXMgPyAwIDogZ2V0TWF4Um91bmRSYWRpdXModGhpcy5zdHlsZS5yYWRpdXMsIHRoaXMuc3R5bGUuaXRlbVNpemUsIHRoaXMuc3R5bGUuaXRlbVNpemUpLFxuICAgICAgICAgICAgICAgIGFscGhhOiB0aGlzLnN0eWxlLmFscGhhLFxuICAgICAgICAgICAgICAgIHN0eWxlOiBwcm92aWRlci5zdHlsZSB8fCB7fVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmIChwcm92aWRlci50eXBlID09PSBJY29uICYmIHByb3ZpZGVyLmljb24gJiYgcHJvdmlkZXIudyAmJiBwcm92aWRlci5oKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJhdGlvID0gcHJvdmlkZXIudyAvIHByb3ZpZGVyLmg7XG4gICAgICAgICAgICAgICAgcGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICBpY29uOiBwcm92aWRlci5pY29uXG4gICAgICAgICAgICAgICAgfSwgcHJvdmlkZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLnN0eWxlLml0ZW1TaXplICogcmF0aW8sXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaXRlbVNpemVcbiAgICAgICAgICAgICAgICB9LCBwYXRjaCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHBhdGNoID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEljb24sXG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUuaXRlbVNpemUsXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaXRlbVNpemVcbiAgICAgICAgICAgICAgICB9LCBwYXRjaCk7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBwcm92aWRlciA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgICAgICBwYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgcGF0Y2gpLCBwcm92aWRlcik7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcGF0Y2guaWNvbiA9IHByb3ZpZGVyO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHByb3ZpZGVyTGlzdC5wdXNoKHBhdGNoKTtcbiAgICAgICAgfSkpO1xuICAgICAgICB0aGlzLl9Sb3cucGF0Y2goe1xuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICBpdGVtU3BhY2luZzogdGhpcy5zdHlsZS5pdGVtU3BhY2luZ1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGl0ZW1zOiBwcm92aWRlckxpc3QsXG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLml0ZW1TaXplXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlQ291bnRlcigpIHtcbiAgICAgICAgaWYgKHRoaXMucHJvdmlkZXJzLmxlbmd0aCA+IHRoaXMudmlzaWJsZUNvdW50KSB7XG4gICAgICAgICAgICB2YXIgcmVtYWluaW5nID0gdGhpcy5wcm92aWRlcnNIaWRkZW47XG4gICAgICAgICAgICB2YXIgY291bnRlciA9IHtcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCIrXCIuY29uY2F0KHJlbWFpbmluZyksXG4gICAgICAgICAgICAgICAgYWxwaGE6IHRoaXMuc3R5bGUuYWxwaGEsXG4gICAgICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pdGVtU2l6ZSxcbiAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLml0ZW1TaXplLFxuICAgICAgICAgICAgICAgIGNlbnRlckluUGFyZW50OiB0cnVlLFxuICAgICAgICAgICAgICAgIEJhY2tncm91bmQ6IHtcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pdGVtU2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5pdGVtU2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgdGV4dHVyZTogbG5nLlRvb2xzLmdldFJvdW5kUmVjdCh0aGlzLnN0eWxlLml0ZW1TaXplLCB0aGlzLnN0eWxlLml0ZW1TaXplLCBnZXRNYXhSb3VuZFJhZGl1cyh0aGlzLnN0eWxlLnJhZGl1cywgdGhpcy5zdHlsZS5pdGVtU2l6ZSwgdGhpcy5zdHlsZS5pdGVtU2l6ZSksIDAsIG51bGwsIHRydWUsIHRoaXMuc3R5bGUuY291bnRlckJhY2tncm91bmRDb2xvcilcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFRleHQ6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgbW91bnRYOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5pdGVtU2l6ZSAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHk6IHRoaXMuc3R5bGUuaXRlbVNpemUgLyAyLFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB0aGlzLmNvdW50ZXJUZXh0IHx8IFwiK1wiLmNvbmNhdChyZW1haW5pbmcpLFxuICAgICAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLmNvdW50ZXJUZXh0U3R5bGVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICB0aGlzLl9Sb3cuYXBwZW5kSXRlbXMoWyBjb3VudGVyIF0pO1xuICAgICAgICB9XG4gICAgfVxuICAgICRpdGVtQ2hhbmdlZCgpIHtcbiAgICAgICAgdGhpcy5zaWduYWwoXCJwcm92aWRlckNoYW5nZWRcIik7XG4gICAgfVxuICAgIF9nZXRWaXNpYmxlQ291bnQoKSB7XG4gICAgICAgIHZhciBtaW4gPSAxO1xuICAgICAgICB2YXIgbWF4ID0gdGhpcy5wcm92aWRlcnMubGVuZ3RoO1xuICAgICAgICB2YXIgdmlzaWJsZUNvdW50ID0gTWF0aC5taW4oTWF0aC5tYXgobWluLCB0aGlzLl92aXNpYmxlQ291bnQpLCBtYXgpO1xuICAgICAgICBpZiAodGhpcy5fdmlzaWJsZUNvdW50IDwgbWluKSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4oXCJXYXJuaW5nOiBUaGUgc3BlY2lmaWVkIHZpc2libGUgY291bnQgKFwiLmNvbmNhdCh0aGlzLl92aXNpYmxlQ291bnQsIFwiKSBpcyBsZXNzIHRoYW4gdGhlIG1pbmltdW0gdmFsdWUgKFwiKS5jb25jYXQobWluLCBcIikuIFNldHRpbmcgaXQgdG8gXCIpLmNvbmNhdChtaW4sIFwiLlwiKSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3Zpc2libGVDb3VudCA+IG1heCkge1xuICAgICAgICAgICAgY29uc29sZS53YXJuKFwiV2FybmluZzogVGhlIHNwZWNpZmllZCB2aXNpYmxlIGNvdW50IChcIi5jb25jYXQodGhpcy5fdmlzaWJsZUNvdW50LCBcIikgaXMgZ3JlYXRlciB0aGFuIHRoZSBtYXhpbXVtIHZhbHVlIChcIikuY29uY2F0KG1heCwgXCIpLiBTZXR0aW5nIGl0IHRvIFwiKS5jb25jYXQobWF4LCBcIi5cIikpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB2aXNpYmxlQ291bnQ7XG4gICAgfVxuICAgIGdldCB3KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fUm93Lnc7XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5v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biAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGRpc2FibGVkOiB7XG4gICAgICAgICAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyR0ID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkdCxcbiAgICB0b25lOiB0b25lJGNcbn0pO1xuXG5jbGFzcyBNZXRhZGF0YUNhcmRDb250ZW50IGV4dGVuZHMgTWV0YWRhdGFCYXNlJDEge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJNZXRhZGF0YUNhcmRDb250ZW50XCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHQ7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgZmxleDoge1xuICAgICAgICAgICAgICAgICAgICBkaXJlY3Rpb246IFwiY29sdW1uXCIsXG4gICAgICAgICAgICAgICAgICAgIGp1c3RpZnlDb250ZW50OiBcImZsZXgtc3RhcnRcIlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgVGl0bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgU3VidGl0bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgRGVzY3JpcHRpb246IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgRGVzY3JpcHRpb25EZXRhaWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgRGV0YWlsc1dyYXBwZXI6IHtcbiAgICAgICAgICAgICAgICBEZXRhaWxzRmFkZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgRGV0YWlsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3Jlc29sdmVEZXRhaWxzXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgUHJvdmlkZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnQ6IDEsXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFByb3ZpZGVyLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwcm92aWRlckNoYW5nZWQ6IFwiX3Jlc29sdmVQcm92aWRlclwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJkZXNjcmlwdGlvblwiLCBcImRlc2NyaXB0aW9uRGV0YWlsc1wiLCBcImRldGFpbHNcIiwgXCJwcm92aWRlclwiLCBcInN1YnRpdGxlXCIsIFwidGl0bGVcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiVGV4dFwiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRpdGxlXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHQuVGl0bGVcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlN1YnRpdGxlXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHQuU3VidGl0bGVcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIkRlc2NyaXB0aW9uXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHQuRGVzY3JpcHRpb25cIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIkRlc2NyaXB0aW9uRGV0YWlsc1wiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LkRlc2NyaXB0aW9uRGV0YWlsc1wiXG4gICAgICAgIH0sIFwiRGV0YWlsc1dyYXBwZXJcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXRhaWxzRmFkZXJcIixcbiAgICAgICAgICAgIHBhdGg6IFwiRGV0YWlsc1dyYXBwZXIuRGV0YWlsc0ZhZGVyXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXRhaWxzXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkRldGFpbHNXcmFwcGVyLkRldGFpbHNGYWRlci5EZXRhaWxzXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJQcm92aWRlclwiLFxuICAgICAgICAgICAgcGF0aDogXCJEZXRhaWxzV3JhcHBlci5Qcm92aWRlclwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX3NldERldGFpbHMoZGV0YWlscykge1xuICAgICAgICBpZiAoZGV0YWlscykge1xuICAgICAgICAgICAgdGhpcy5fZGV0YWlsc1Byb21pc2UgPSBuZXcgUHJvbWlzZSgocmVzb2x2ZSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZGV0YWlsc1Byb21pc2VSZXNvbHZlciA9IHJlc29sdmU7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9kZXRhaWxzUHJvbWlzZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZGV0YWlscztcbiAgICB9XG4gICAgX3NldFByb3ZpZGVyKHByb3ZpZGVyKSB7XG4gICAgICAgIGlmIChwcm92aWRlcikge1xuICAgICAgICAgICAgdGhpcy5fcHJvdmlkZXJQcm9taXNlID0gbmV3IFByb21pc2UoKHJlc29sdmUgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuX3Byb3ZpZGVyUHJvbWlzZVJlc29sdmVyID0gcmVzb2x2ZTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfSBlbHNlIHtcbiAg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XG4gICAgICAgICAgICAgICAgcmVmOiBcIlN1YnRpdGxlXCIsXG4gICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fU3VidGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5zdWJ0aXRsZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuc3VidGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlRGVzY3JpcHRpb24oKSB7XG4gICAgICAgIHRoaXMuX0Rlc2NyaXB0aW9uLnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGVzY3JpcHRpb24sXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uVGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlRGVzY3JpcHRpb25EZXRhaWxzKCkge1xuICAgICAgICB0aGlzLl9EZXNjcmlwdGlvbkRldGFpbHMucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5kZXNjcmlwdGlvbkRldGFpbHMsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uRGV0YWlsc1RleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogdGhpcy5fVGV4dC53XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB5OiB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uRGV0YWlsc1N0eWxlLnBhZGRpbmdZXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlRGV0YWlscygpIHtcbiAgICAgICAgdmFyIG1heFdpZHRoID0gdGhpcy5fZGV0YWlsc01heFc7XG4gICAgICAgIHRoaXMuX0RldGFpbHMucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5kZXRhaWxzLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXRhaWxzVGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiBtYXhXaWR0aCArIHRoaXMuc3R5bGUuZmFkZVdpZHRoIC8gMlxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBpZiAodGhpcy5fRGV0YWlscy5maW5hbFcgPiBtYXhXaWR0aCkge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlsc0ZhZGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICB3OiBtYXhXaWR0aCArIHRoaXMuc3R5bGUuZmFkZVdpZHRoIC8gMixcbiAgICAgICAgICAgICAgICBzaGFkZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogRmFkZVNoYWRlcixcbiAgICAgICAgICAgICAgICAgICAgcG9zaXRpb25MZWZ0OiAwLFxuICAgICAgICAgICAgICAgICAgICBwb3NpdGlvblJpZ2h0OiB0aGlzLnN0eWxlLmZhZGVXaWR0aFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlsc0ZhZGVyLnNoYWRlciA9IHVuZGVmaW5lZDtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfcmVzb2x2ZURldGFpbHMoKSB7XG4gICAgICAgIHRoaXMuX2RldGFpbHNQcm9taXNlUmVzb2x2ZXIgJiYgdGhpcy5fZGV0YWlsc1Byb21pc2VSZXNvbHZlcigpO1xuICAgICAgICB0aGlzLl91cGRhdGVQb3NpdGlvbnMoKTtcbiAgICB9XG4gICAgX3VwZGF0ZVByb3ZpZGVyKCkge1xuICAgICAgICBpZiAodGhpcy5wcm92aWRlcikge1xuICAgICAgICAgICAgdGhpcy5fUHJvdmlkZXIucGF0Y2goX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICBtb2RlOiB0aGlzLm1vZGVcbiAgICAgICAgICAgIH0sIHRoaXMucHJvdmlkZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgIHN0eWxlOiB0aGlzLnN0eWxlLnByb3ZpZGVyXG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbi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DksXG4gICAgICAgIHVwQ291bnQ6IDRcbiAgICB9KS5oLFxuICAgIGltYWdlU2l6ZToge1xuICAgICAgICB3aWR0aDogdXRpbHMkMS5nZXREaW1lbnNpb25zKHRoZW1lLCB7XG4gICAgICAgICAgICByYXRpb1g6IDE2LFxuICAgICAgICAgICAgcmF0aW9ZOiA5LFxuICAgICAgICAgICAgdXBDb3VudDogNFxuICAgICAgICB9KS53LFxuICAgICAgICBoZWlnaHQ6IHV0aWxzJDEuZ2V0RGltZW5zaW9ucyh0aGVtZSwge1xuICAgICAgICAgICAgcmF0aW9YOiAxNixcbiAgICAgICAgICAgIHJhdGlvWTogOSxcbiAgICAgICAgICAgIHVwQ291bnQ6IDRcbiAgICAgICAgfSkuaFxuICAgIH0sXG4gICAgbWV0YWRhdGE6IHtcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIG1heExpbmVzOiAyXG4gICAgICAgIH1cbiAgICB9LFxuICAgIHBhZGRpbmdWZXJ0aWNhbDogdGhlbWUuc3BhY2VyLm1kICogMS41XG59KTtcblxudmFyIHN0eWxlcyRzID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2Ukc1xufSk7XG5cbmNsYXNzIENhcmRDb250ZW50IGV4dGVuZHMgQ2FyZCB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkNhcmRDb250ZW50XCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHM7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHN1cGVyLl90ZW1wbGF0ZSgpKSwge30sIHtcbiAgICAgICAgICAgIFRpbGU6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUaWxlXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIC4uLnN1cGVyLnByb3BlcnRpZXMsIFwidGlsZVwiLCBcIm1ldGFkYXRhXCIsIFwib3JpZW50YXRpb25cIiwgXCJjb2xsYXBzZVRvTWV0YWRhdGFcIiwgXCJzaG91bGRDb2xsYXBzZVwiLCBcInNyY1wiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIudGFncywgXCJNZXRhZGF0YVwiLCBcIlRpbGVcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcImV4cGFuZGVkV1wiLFxuICAgICAgICAgICAgY3VycjogXCJleHBhbmRlZFdpZHRoXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJleHBhbmRlZEhcIixcbiAgICAgICAgICAgIGN1cnI6IFwiZXhwYW5kZWRIZWlnaHRcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVNpemUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGlsZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVNZXRhZGF0YSgpO1xuICAgICAgICBzdXBlci5fdXBkYXRlKCk7XG4gICAgfVxuICAgIF91cGRhdGVUaXRsZSgpIHt9XG4gICAgX3VwZGF0ZVRpdGxlUG9zaXRpb24oKSB7fVxuICAgIF91cGRhdGVUaWxlKCkge1xuICAgICAgICB2YXIgX3RpbGU7XG4gICAgICAgIHZhciB3ID0gdGhpcy5zdHlsZS5pbWFnZVNpemUudztcbiAgICAgICA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aHQgLSBwYWRkaW5nVmVydGljYWw7XG4gICAgICAgIGlmICh0aGlzLm9yaWVudGF0aW9uICE9PSBcImhvcml6b250YWxcIikge1xuICAgICAgICAgICAgdyA9IHRoaXMuc3R5bGUuZXhwYW5kZWRXaWR0aCAtIHBhZGRpbmdIb3Jpem9udGFsO1xuICAgICAgICAgICAgaCA9IHRoaXMuc3R5bGUuZXhwYW5kZWRIZWlnaHQgLSB0aGlzLnN0eWxlLmltYWdlU2l6ZS5oIC0gcGFkZGluZ1ZlcnRpY2FsO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgaDogaFxuICAgICAgICB9O1xuICAgIH1cbiAgICBnZXQgX21ldGFkYXRhUG9zaXRpb24oKSB7XG4gICAgICAgIHZhciBwYWRkaW5nSG9yaXpvbnRhbCA9IHRoaXMuc3R5bGUucGFkZGluZ0hvcml6b250YWw7XG4gICAgICAgIHZhciBwYWRkaW5nVmVydGljYWwgPSB0aGlzLnN0eWxlLnBhZGRpbmdWZXJ0aWNhbDtcbiAgICAgICAgdmFyIHggPSBwYWRkaW5nSG9yaXpvbnRhbCArICh0aGlzLl9jb2xsYXBzZSA/IDAgOiB0aGlzLnN0eWxlLmltYWdlU2l6ZS53KTtcbiAgICAgICAgdmFyIHkgPSBwYWRkaW5nVmVydGljYWw7XG4gICAgICAgIGlmICh0aGlzLm9yaWVudGF0aW9uICE9PSBcImhvcml6b250YWxcIikge1xuICAgICAgICAgICAgeCA9IHBhZGRpbmdIb3Jpem9udGFsO1xuICAgICAgICAgICAgeSA9IHBhZGRpbmdWZXJ0aWNhbCArICh0aGlzLl9jb2xsYXBzZSA/IDAgOiB0aGlzLnN0eWxlLmltYWdlU2l6ZS5oKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgIHk6IHlcbiAgICAgICAgfTtcbiAgICB9XG4gICAgZ2V0IF9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ufVxuXG5jbGFzcyBDYXJkQ29udGVudEhvcml6b250YWwgZXh0ZW5kcyBDYXJkQ29udGVudCB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkNhcmRDb250ZW50SG9yaXpvbnRhbFwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRzO1xuICAgIH1cbiAgICBfaW5pdCgpIHtcbiAgICAgICAgdGhpcy5fb3JpZW50YXRpb24gPSBcImhvcml6b250YWxcIjtcbiAgICAgICAgc3VwZXIuX2luaXQoKTtcbiAgICB9XG59XG5cbnZhciBiYXNlJHIgPSB0aGVtZSA9PiB7XG4gICAgdmFyIHt3OiB3LCBoOiBofSA9IHV0aWxzJDEuZ2V0RGltZW5zaW9ucyh0aGVtZSwge1xuICAgICAgICByYXRpb1g6IDE2LFxuICAgICAgICByYXRpb1k6IDksXG4gICAgICAgIHVwQ291bnQ6IDNcbiAgICB9KTtcbiAgICByZXR1cm4ge1xuICAgICAgICBleHBhbmRlZFdpZHRoOiB1dGlscyQxLmdldFdpZHRoQnlDb2x1bW5TcGFuKHRoZW1lLCA4KSxcbiAgICAgICAgZXhwYW5kZWRIZWlnaHQ6IGgsXG4gICAgICAgIGltYWdlU2l6ZToge1xuICAgICAgICAgICAgd2lkdGg6IHcsXG4gICAgICAgICAgICBoZWlnaHQ6IGhcbiAgICAgICAgfSxcbiAgICAgICAgbWV0YWRhdGE6IHtcbiAgICAgICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgbWF4TGluZXM6IDNcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG59O1xuXG52YXIgc3R5bGVzJHIgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSRyXG59KTtcbl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FxuICAgICAgICBpY29uU3R5bGU6IHtcbiAgICAgICAgICAgIHJhZGl1czogcmFkaXVzLFxuICAgICAgICAgICAgd2lkdGg6IHRoZW1lLnNwYWNlci54eHhsLFxuICAgICAgICAgICAgaGVpZ2h0OiB0aGVtZS5zcGFjZXIueHh4bFxuICAgICAgICB9LFxuICAgICAgICBsb2dvU3R5bGU6IHtcbiAgICAgICAgICAgIHJhZGl1czogbG9nb1JhZGl1cyxcbiAgICAgICAgICAgIHdpZHRoOiB0aGVtZS5zcGFjZXIubWQgKiA3LFxuICAgICAgICAgICAgaGVpZ2h0OiB0aGVtZS5zcGFjZXIubWQgKiA2XG4gICAgICAgIH0sXG4gICAgICAgIG1pbldpZHRoOiB0aGVtZS5zcGFjZXIubWQgKiA5LFxuICAgICAgICBwYWRkaW5nWDogcGFkZGluZ1gsXG4gICAgICAgIHBhZGRpbmdYTm9UaXRsZTogdGhlbWUuc3BhY2VyLm1kLFxuICAgICAgICBwcmVmaXhQYWRkaW5nOiB0aGVtZS5zcGFjZXIubWQsXG4gICAgICAgIHJhZGl1czogcmFkaXVzLFxuICAgICAgICBjb250ZW50U3BhY2luZzogdGhlbWUuc3BhY2VyLm1kXG4gICAgfTtcbn07XG5cbnZhciBzdHlsZXMkbSA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJG1cbn0pO1xuXG5jbGFzcyBDb250cm9sIGV4dGVuZHMgQnV0dG9uU21hbGwge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJDb250cm9sXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJG07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIucHJvcGVydGllcywgXCJpY29uXCIsIFwibG9nb1wiLCBcInNob3VsZENvbGxhcHNlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBhbGlhc1N0eWxlcygpIHtcbiAgICAgICAgcmV0dXJuIFsge1xuICAgICAgICAgICAgcHJldjogXCJ0aXRsZVBhZGRpbmdcIixcbiAgICAgICAgICAgIGN1cnI6IFwiY29udGVudFNwYWNpbmdcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeFN0eWxlKCk7XG4gICAgICAgIHN1cGVyLl91cGRhdGVUaXRsZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVDb2xsYXBzZVN0YXR1cygpO1xuICAgICAgICBzdXBlci5fdXBkYXRlKCk7XG4gICAgfVxuICAgIF91cGRhdGVDb2xsYXBzZVN0YXR1cygpIHtcbiAgICAgICAgaWYgKHRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UaXRsZS52aXNpYmxlID0gIXRoaXMuX2NvbGxhcHNlO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXhTdHlsZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3ByZWZpeCkge1xuICAgICAgICAgICAgaWYgKHRoaXMubG9nbykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaih0aGlzLmxvZ28sIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICAgICAgY29sb3I6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLnN0eWxlLmxvZ29TdHlsZSlcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5pY29uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJlZml4T2JqKHRoaXMuaWNvbiwge1xuICAgICAgICAgICAgICAgICAgICBzdHlsZTogdGhpcy5zdHlsZS5pY29uU3R5bGVcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICBfcGF0Y2hUaXRsZSh4LCBtb3VudFgpIHtcbiAgICAgICAgdGhpcy5fVGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgIG1vdW50WDogbW91bnRYXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlQ29udGVudFBvc2l0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fcHJlZml4ICYmIHRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBtb3VudFg6IDAsXG4gICAgICAgICAgICAgICAgeDogdGhpcy5fcGFkZGluZ0xlZnRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgc3dpdGNoICh0aGlzLl9qdXN0aWZ5KSB7XG4gICAgICAgICAgICAgIGNhc2UgXCJsZWZ0XCI6XG4gICAgICAgICAgICAgICAgdGhpcy5fcGF0Y2hUaXRsZSgwLCAwKTtcbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgICBjYXNlIFwicmlnaHRcIjpcbiAgICAgICAgICAgICAgICBpZiAodGhpcy53IDwgdGhpcy5fUHJlZml4LncgKyB0aGlzLl9UaXRsZS53KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhdGNoVGl0bGUoMCwgMCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGxlZnRPdmVyU3BhY2UgPSB0aGlzLncgLSAodGhpcy5fcGFkZGluZ0xlZnQgKyB0aGlzLl9wYWRkaW5nUmlnaHQgKyB0aGlzLl9QcmVmaXgudyArIHRoaXMuc3R5bGUuY29udGVudFNwYWNpbmcpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXRjaFRpdGxlKGxlZnRPdmVyU3BhY2UsIDEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgICBjYXNlIFwiY2VudGVyXCI6XG4gICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuZml4ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudyA8IHRoaXMuX1ByZWZpeC53ICsgdGhpcy5fVGl0bGUudykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGF0Y2hUaXRsZSgwLCAwKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBtaWRkbGUgPSAodGhpcy53IC0gKHRoaXMuX3BhZGRpbmdMZWZ0ICsgdGhpcy5fUHJlZml4LncgKyB0aGlzLl9wYWRkaW5nUmlnaHQpKSAvIDI7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXRjaFRpdGxlKG1pZGRsZSwgLjUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9QcmVmaXggIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgX21pZGRsZSA9ICh0aGlzLncgLSAodGhpcy5fcGFkZGluZ0xlZnQgKyB0aGlzLl9QcmVmaXgudyArIHRoaXMuc3R5bGUuY29udGVudFNwYWNpbmcgKyB0aGlzLl9wYWRkaW5nUmlnaHQpKSAvIDI7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhdGNoVGl0bGUoX21pZGRsZSwgLjUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN1cGVyLl91cGRhdGVDb250ZW50UG9zaXRpb24oKTtcbiAgICAgICAgICAgIHRoaXMuX1RpdGxlICYmIHRoaXMuX3BhdGNoVGl0bGUoMCwgMCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3NldFByZWZpeCgpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBfc2V0U3VmZml4KCkge1xuICAgICAgICByZXR1cm47XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXhPYmooaWNvbikge1xuICAgICAgICB2YXIgcHJvcHMgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHt9O1xuICAgICAgICB0aGlzLl9wcmVmaXggPSBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgIHR5cGU6IEljb24sXG4gICAgICAgICAgICBpY29uOiBpY29uXG4gICAgICAgIH0sIHByb3BzKTtcbiAgICB9XG4gICAgX3NldEljb24oaWNvbikge1xuICAgICAgICBpZiAoIXRoaXMubG9nbykge1xuICAgICAgICAgICAgaWYgKGljb24pIHtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhPYmooaWNvbiwge1xuICAgICAgICAgICAgICAgICAgICBzdHlsZTogdGhpcy5zdHlsZS5pY29uU3R5bGVcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcHJlZml4ID0gaWNvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gaWNvbjtcbiAgICB9XG4gICAgX3NldExvZ28obG9nbykge1xuICAgICAgICBpZiAobG9nbykge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJlZml4T2JqKGxvZ28sIHtcbiAgICAgICAgICAgICAgICBzdHlsZTogX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgI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F0aGlzLnRpdGxlKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgVGl0bGU6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciB0aXRsZVBhdGNoID0ge1xuICAgICAgICAgICAgeDogdGhpcy5zdHlsZS50aXRsZU1hcmdpbkxlZnQsXG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLnRpdGxlLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUudGl0bGVUZXh0U3R5bGVcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgaWYgKCF0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGl0bGVQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5fdGl0bGVGaXJzdExvYWRQcm9wcyksIHRpdGxlUGF0Y2gpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgVGl0bGU6IHRpdGxlUGF0Y2hcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIGdldCBfdGl0bGVGaXJzdExvYWRQcm9wcygpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3RpdGxlTG9hZGVkXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgX3VwZGF0ZVJvdygpIHtcbiAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLkl0ZW1zLCB7XG4gICAg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XQoaXRlbXNUb0FkZCwgYWRkSW5kZXgsIHRoaXMuX2xhc3RMZWZ0Q29udHJvbEluZGV4KTtcbiAgICAgICAgaWYgKHRoaXMuX2xlZnRDb250cm9scykge1xuICAgICAgICAgICAgdGhpcy5fbGVmdENvbnRyb2xzID0gWyAuLi50aGlzLl9sZWZ0Q29udHJvbHMsIC4uLmNvbnRyb2xzIF07XG4gICAgICAgICAgICB0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleCA9IHRoaXMuX2xlZnRDb250cm9scy5sZW5ndGggLSAxO1xuICAgICAgICAgICAgdGhpcy5fbGFzdEl0ZW1JbmRleCArPSBjb250cm9scy5sZW5ndGg7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBzdGFydExhenlTY3JvbGxJbmRleDogdGhpcy5sZWZ0Q29udHJvbHMubGVuZ3RoLFxuICAgICAgICAgICAgc3RvcExhenlTY3JvbGxJbmRleDogdGhpcy5sZWZ0Q29udHJvbHMubGVuZ3RoICsgdGhpcy5pdGVtcy5sZW5ndGggLSAxXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBhZGRMZWZ0Q29udHJvbHNBdChjb250cm9scywgaW5kZXgpIHtcbiAgICAgICAgdmFyIGl0ZW1zVG9BZGQgPSB0aGlzLl9jcmVhdGVDb250cm9scyhjb250cm9scyk7XG4gICAgICAgIGlmIChpbmRleCA9PT0gdGhpcy5fbGFzdExlZnRDb250cm9sSW5kZXggKyAxKSB7XG4gICAgICAgICAgICB0aGlzLmFkZExlZnRDb250cm9scyhjb250cm9scyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9hcHBlbmRJdGVtc0F0KGl0ZW1zVG9BZGQsIGluZGV4KTtcbiAgICAgICAgICAgIGlmICh0aGlzLmxlZnRDb250cm9scykge1xuICAgICAgICAgICAgICAgIHRoaXMuX2xlZnRDb250cm9scy5zcGxpY2UoaW5kZXgsIDAsIC4uLmNvbnRyb2xzKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleCA9IHRoaXMuX2xlZnRDb250cm9scy5sZW5ndGggLSAxO1xuICAgICAgICAgICAgICAgIHRoaXMuX2xhc3RJdGVtSW5kZXggKz0gY29udHJvbHMubGVuZ3RoO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgc3RhcnRMYXp5U2Nyb2xsSW5kZXg6IHRoaXMubGVmdENvbnRyb2xzLmxlbmd0aCxcbiAgICAgICAgICAgICAgICBzdG9wTGF6eVNjcm9sbEluZGV4OiB0aGlzLmxlZnRDb250cm9scy5sZW5ndGggKyB0aGlzLml0ZW1zLmxlbmd0aCAtIDFcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJlbW92ZUxlZnRDb250cm9sQXQoaW5kZXgpIHtcbiAgICAgICAgdGhpcy5yZW1vdmVJdGVtQXQoaW5kZXgpO1xuICAgICAgICB0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleC0tO1xuICAgICAgICB0aGlzLl9sYXN0SXRlbUluZGV4LS07XG4gICAgICAgIGlmICh0aGlzLmxlZnRDb250cm9scykge1xuICAgICAgICAgICAgdGhpcy5fbGVmdENvbnRyb2xzLnNwbGljZShpbmRleCwgMSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBzdGFydExhenlTY3JvbGxJbmRleDogdGhpcy5sZWZ0Q29udHJvbHMubGVuZ3RoLFxuICAgICAgICAgICAgc3RvcExhenlTY3JvbGxJbmRleDogdGhpcy5sZWZ0Q29udHJvbHMubGVuZ3RoICsgdGhpcy5pdGVtcy5sZW5ndGggLSAxXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBhZGRSaWdodENvbnRyb2xzKGNvbnRyb2xzKSB7XG4gICAgICAgIHRoaXMuX3JpZ2h0Q29udHJvbHMucHVzaCguLi5jb250cm9scyk7XG4gICAgICAgIHRoaXMuX2FwcGVuZEl0ZW1zQXQodGhpcy5fY3JlYXRlQ29udHJvbHMoY29udHJvbHMpLCB0aGlzLml0ZW1zLmxlbmd0aCk7XG4gICAgfVxuICAgIGFkZFJpZ2h0Q29udHJvbHNBdChjb250cm9scywgaW5kZXgpIHtcbiAgICAgICAgdmFyIGFwcGVuZEluZGV4ID0gdGhpcy5fbGVmdENvbnRyb2xzLmxlbmd0aCArIHRoaXMuX2NvbnRlbnRJdGVtcy5sZW5ndGggKyBpbmRleDtcbiAgICAgICAgdGhpcy5fcmlnaHRDb250cm9scy5zcGxpY2UoaW5kZXgsIDAsIC4uLmNvbnRyb2xzKTtcbiAgICAgICAgdGhpcy5fYXBwZW5kSXRlbXNBdCh0aGlzLl9jcmVhdGVDb250cm9scyhjb250cm9scyksIGFwcGVuZEluZGV4KTtcbiAgICB9XG4gICAgcmVtb3ZlUmlnaHRDb250cm9sQXQoaW5kZXgpIHtcbiAgICAgICAgdmFyIHJlbW92ZUluZGV4ID0gdGhpcy5sZWZ0Q29udHJvbHMubGVuZ3RoICsgdGhpcy5jb250ZW50SXRlbXMubGVuZ3RoICsgaW5kZXg7XG4gICAgICAgIHRoaXMucmVtb3ZlSXRlbUF0KHJlbW92ZUluZGV4KTtcbiAgICAgICAgaWYgKHRoaXMucmlnaHRDb250cm9scykge1xuICAgICAgICAgICAgdGhpcy5fcmlnaHRDb250cm9scy5zcGxpY2UoaW5kZXgsIDEpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9jcmVhdGVDb250cm9scyhjb250cm9scykge1xuICAgICAgICByZXR1cm4gY29udHJvbHMubWFwKChjb250cm9sUHJvcHMgPT4gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICBiYWNrZ3JvdW5kVHlwZTogXCJmaWxsXCIsXG4gICAgICAgICAgICBjZW50ZXJJblBhcmVudDogdHJ1ZVxuICAgICAgICB9LCBjb250cm9sUHJvcHMpKS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V4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgIH0pLFxuICAgIHZhbHVlVGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoZW1lLnR5cG9ncmFwaHkuYm9keTEpLCB7fSwge1xuICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgfSlcbn0pO1xuXG52YXIgc3R5bGVzJGkgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSRpXG59KTtcblxuY2xhc3MgU3BhY2VyIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiU3BhY2VyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBMaW5lOiB7XG4gICAgICAgICAgICAgICAgaDogU3BhY2VyLl9saW5lVGhpY2tuZXNzLFxuICAgICAgICAgICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICBUaWNrTGVmdDogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBTcGFjZXIuX3RpY2spLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICB4OiBTcGFjZXIuX2xpbmVUaGlja25lc3MgKiAtMVxuICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgIFRpY2tSaWdodDogU3BhY2VyLl90aWNrXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJsaW5lQ29sb3JcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2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ICAgcmV0dXJuIFwiR3JpZE92ZXJsYXlcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkaTtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgdmFyIHRleHRSb3cgPSB7XG4gICAgICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgICAgICBhdXRvUmVzaXplSGVpZ2h0OiB0cnVlLFxuICAgICAgICAgICAgSXRlbXM6IHtcbiAgICAgICAgICAgICAgICBQcm9wZXJ0eToge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfdXBkYXRlXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgVmFsdWU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3VwZGF0ZVwiXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIGNlbnRlckluUGFyZW50OiB0cnVlXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgQ29sdW1uczoge1xuICAgICAgICAgICAgICAgIGFscGhhOiAuMDAxLFxuICAgICAgICAgICAgICAgIHR5cGU6IFJvd1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIE1hcmdpbnM6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICBIb3Jpem9udGFsOiB7XG4gICAgICAgICAgICAgICAgICAgIExlZnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjZXJMb2FkZWQ6IFwiX3VwZGF0ZVwiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIFJpZ2h0OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BhY2VyTG9hZGVkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBWZXJ0aWNhbDoge1xuICAgICAgICAgICAgICAgICAgICBUb3A6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHZlcnRpY2FsOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgU2FmZToge1xuICAgICAgICAgICAgICAgIGFscGhhOiAuMDAxLFxuICAgICAgICAgICAgICAgIEhvcml6b250YWw6IHtcbiAgICAgICAgICAgICAgICAgICAgTGVmdDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3BhY2VyLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYWNlckxvYWRlZDogXCJfdXBkYXRlXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgUmlnaHQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjZXJMb2FkZWQ6IFwiX3VwZGF0ZVwiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFZlcnRpY2FsOiB7XG4gICAgICAgICAgICAgICAgICAgIFRvcDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3BhY2VyLFxuICAgICAgICAgICAgICAgICAgICAgICAgdmVydGljYWw6IHRydWVcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgQm90dG9tOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICB2ZXJ0aWNhbDogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIEd1dHRlcnM6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICBIb3Jpem9udGFsOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3BhY2VyTG9hZGVkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFRleHRQYW5lbDoge1xuICAgICAgICAgICAgICAgIGFscGhhOiAuMDAxLFxuICAgICAgICAgICAgICAgIHR5cGU6IENvbHVtbixcbiAgICAgICAgICAgICAgICBhdXRvUmVzaXplSGVpZ2h0OiB0cnVlLFxuICAgICAgICAgICAgICAgIEl0ZW1zOiB7XG4gICAgICAgICAgICAgICAgICAgIFNjcmVlblc6IHRleHRSb3csXG4gICAgICAgICAgICAgICAgICAgIFNjcmVlbkg6IHRleHRSb3csXG4gICAgICAgICAgICAgICAgICAgIENvbHVtbkNvdW50OiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBNYXJnaW5YOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBNYXJnaW5ZOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBHdXR0ZXJYOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBHdXR0ZXJZOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBTYWZlOiB0ZXh0Um93XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwic2hvd0NvbHVtbnNcIiwgXCJzaG93TWFyZ2luc1wiLCBcInNob3dTYWZlXCIsIFwic2hvd0d1dHRlcnNcIiwgXCJzaG93VGV4dFwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJDb2x1bW5zXCIsIFwiTWFyZ2luc1wiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIk1hcmdpbkhvcml6b250YWxcIixcbiAgICAgICAgICAgIHBhdGg6IFwiTWFyZ2lucy5Ib3Jpem9udGFsXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5MZWZ0XCIsXG4gICAgICAgICAgICBwYXRoOiBcIk1hcmdpbnMuSG9yaXpvbnRhbC5MZWZ0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5SaWdodFwiLFxuICAgICAgICAgICAgcGF0aDogXCJNYXJnaW5zLkhvcml6b250YWwuUmlnaHRcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIk1hcmdpblZlcnRpY2FsXCIsXG4gICAgICAgICAgICBwYXRoOiBcIk1hcmdpbnMuVmVydGljYWxcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIk1hcmdpblRvcFwiLFxuICAgICAgICAgICAgcGF0aDogXCJNYXJnaW5zLlZlcnRpY2FsLlRvcFwiXG4gICAgICAgIH0sIFwiU2FmZVwiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNhZmVIb3Jpem9udGFsXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlNhZmUuSG9yaXpvbnRhbFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiU2FmZUxlZnRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiU2FmZS5Ib3Jpem9udGFsLkxlZnRcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNhZmVSaWdodFwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLkhvcml6b250YWwuUmlnaHRcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNhZmVWZXJ0aWNhbFwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLlZlcnRpY2FsXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlVG9wXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlNhZmUuVmVydGljYWwuVG9wXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlQm90dG9tXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlNhZmUuVmVydGljYWwuQm90dG9tXCJcbiAgICAgICAgfSwgXCJHdXR0ZXJzXCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiR3V0dGVySG9yaXpvbnRhbFwiLFxuICAgICAgICAgICAgcGF0aDogXCJHdXR0ZXJzLkhvcml6b250YWxcIlxuICAgICAgICB9LCBcIlRleHRQYW5lbFwiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRleHRTY3JlZW5XXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHRQYW5lbC5JdGVtcy5TY3JlZW5XXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJUZXh0U2NyZWVuSFwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0UGFuZWwuSXRlbXMuU2NyZWVuSFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVGV4dENvbHVtbkNvdW50XCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHRQYW5lbC5JdGVtcy5Db2x1bW5Db3VudFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVGV4dE1hcmdpblhcIixcbiAgICAgICAgICAgIHBhdGg6IFwiVGV4dFBhbmVsLkl0ZW1zLk1hcmdpblhcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRleHRNYXJnaW5ZXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHRQYW5lbC5JdGVtcy5NYXJnaW5ZXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJUZXh0R3V0dGVyWFwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0UGFuZWwuSXRlbXMuR3V0dGVyWFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVGV4dEd1dHRlcllcIixcbiAgICAgICAgICAgIHBhdGg6IFwiVGV4dFBhbmVsLkl0ZW1zLkd1dHRlcllcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRleHRTYWZlXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHRQYW5lbC5JdGVtcy5TYWZlXCJcbiAgICAgICAgfSBdO1x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dHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBoZWxwVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHRvbmUkYSA9IHRoZW1lID0+ICh7XG4gICAgaW52ZXJzZToge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgZXllYnJvd1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBoZWxwVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRoID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkaCxcbiAgICBtb2RlOiBtb2RlJDYsXG4gICAgdG9uZTogdG9uZSRhXG59KTtcblxuY2xhc3MgSW5wdXQgZXh0ZW5kcyBCdXR0b24ge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJJbnB1dFwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRoO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVh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GF0ZUN1cnNvclBvc2l0aW9uKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRpdGxlU2Nyb2xsUG9zaXRpb24oKTtcbiAgICB9XG4gICAgX3VwZGF0ZVBhc3N3b3JkKCkge1xuICAgICAgICB0aGlzLnRpdGxlID0gdGhpcy5wYXNzd29yZCA/IHRoaXMubWFzay5yZXBlYXQodGhpcy5hY3R1YWxUaXRsZS5sZW5ndGgpIDogdGhpcy5hY3R1YWxUaXRsZTtcbiAgICB9XG4gICAgX3VwZGF0ZVRydW5jYXRpb24oKSB7XG4gICAgICAgIGlmICh0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fVGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogZmFsc2VcbiAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlRXllYnJvdygpIHtcbiAgICAgICAgdGhpcy5fRXllYnJvdy5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLmV5ZWJyb3csXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS5leWVicm93VGV4dFN0eWxlXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgbW91bnRZOiAxLFxuICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5wYWRkaW5nWCxcbiAgICAgICAgICAgIHk6IHRoaXMueSAtIHRoaXMuc3R5bGUucGFkZGluZ1lcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVIZWxwVGV4dCgpIHtcbiAgICAgICAgdGhpcy5fSGVscFRleHQucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5oZWxwVGV4dCxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLmhlbHBUZXh0U3R5bGVcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB4OiB0aGlzLnN0eWxlLnBhZGRpbmdYLFxuICAgICAgICAgICAgeTogdGhpcy55ICsgdGhpcy5pbm5lckggKyB0aGlzLnN0eWxlLnBhZGRpbmdZXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlVGV4dFdyYXBwZXIoKSB7XG4gICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLmNsaXBwaW5nID0gdHJ1ZTtcbiAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIudyA9IHRoaXMuX3Zpc2libGVDb250ZW50V2lkdGg7XG4gICAgICAgIGlmICh0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIuaCA9IHRoaXMuX1RpdGxlLmg7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUhpZGRlbkNvbnRlbnQoKSB7XG4gICAgICAgIGlmICghdGhpcy5fSGlkZGVuQ29udGVudCkge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgSGlkZGVuQ29udGVudDoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICB5OiBoID0+IGggLyAyLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfb25IaWRkZW5UZXh0Qm94Q2hhbmdlZFwiXG4gICAgICAg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AuNVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgdGhpcy5jdXJzb3JCbGluayA9IHRoaXMuX0N1cnNvci5hbmltYXRpb24oe1xuICAgICAgICAgICAgICAgICAgICBkdXJhdGlvbjogMS41LFxuICAgICAgICAgICAgICAgICAgICByZXBlYXQ6IC0xLFxuICAgICAgICAgICAgICAgICAgICBhY3Rpb25zOiBbIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHA6IFwiYWxwaGFcIixcbiAgICAgICAgICAgICAgICAgICAgICAgIHY6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAwOiAwLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC41OiAxLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDE6IDBcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSBdXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9DdXJzb3IucGF0Y2godGhpcy5zdHlsZS5jdXJzb3JTdHlsZSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUN1cnNvckxpc3RlbmluZygpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3Vyc29yQmxpbmsgJiYgIXRoaXMuY3Vyc29yQmxpbmsuaXNQbGF5aW5nKCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmN1cnNvckJsaW5rLnN0YXJ0KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5jdXJzb3JCbGluaykgdGhpcy5pc0N1cnNvckFjdGl2ZSA/IHRoaXMuY3Vyc29yQmxpbmsuc3RhcnQoKSA6IHRoaXMuY3Vyc29yQmxpbmsuc3RvcCgpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX0N1cnNvci5zbW9vdGggPSB7XG4gICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5jdXJzb3JTdHlsZS50ZXh0Q29sb3JcbiAgICAgICAgfTtcbiAgICB9XG4gICAgX3VwZGF0ZUN1cnNvckJsaW5rKCkge1xuICAgICAgICBpZiAodGhpcy5jdXJzb3JCbGluaykge1xuICAgICAgICAgICAgaWYgKHRoaXMuaXNDdXJzb3JBY3RpdmUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmN1cnNvckJsaW5rLnN0YXJ0KCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuY3Vyc29yQmxpbmsuc3RvcCgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX0N1cnNvci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiAuMDAxXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUN1cnNvclBvc2l0aW9uKCkge1xuICAgICAgICB0aGlzLl9DdXJzb3IueCA9IHRoaXMuX3RpdGxlWCArICh0aGlzLl9pc092ZXJmbG93ID8gdGhpcy5fVGV4dFdyYXBwZXIudyA6IHRoaXMuX0hpZGRlbkNvbnRlbnQudyk7XG4gICAgfVxuICAgIF91cGRhdGVUaXRsZVNjcm9sbFBvc2l0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RpdGxlLnggPSB0aGlzLl9pc092ZXJmbG93ID8gdGhpcy5fdmlzaWJsZUNvbnRlbnRXaWR0aCAtIHRoaXMuX0hpZGRlbkNvbnRlbnQudyA6IDA7XG4gICAgICAgICAgICBpZiAodGhpcy5fSGlkZGVuQ29udGVudCAmJiB0aGlzLl9UZXh0V3JhcHBlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuX0hpZGRlbkNvb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Z0KCk7XG4gICAgICAgIGlmICh0eXBlb2YgdGhpcy5vbkxlZnQgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMub25MZWZ0KHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICBfaGFuZGxlUmlnaHQoKSB7XG4gICAgICAgIGlmICh0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMubW92ZVJpZ2h0KCk7XG4gICAgICAgIGlmICh0eXBlb2YgdGhpcy5vblJpZ2h0ID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLm9uUmlnaHQodGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICAgIG1vdmVMZWZ0KCkge1xuICAgICAgICB2YXIge3Bvc2l0aW9uOiBwb3NpdGlvbn0gPSB0aGlzO1xuICAgICAgICBpZiAocG9zaXRpb24gPj0gMCkge1xuICAgICAgICAgICAgdGhpcy5wb3NpdGlvbi0tO1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgICBtb3ZlUmlnaHQoKSB7XG4gICAgICAgIHZhciB7cG9zaXRpb246IHBvc2l0aW9uLCB0aXRsZTogdGl0bGV9ID0gdGhpcztcbiAgICAgICAgaWYgKHBvc2l0aW9uIDwgdGl0bGUubGVuZ3RoKSB7XG4gICAgICAgICAgICB0aGlzLnBvc2l0aW9uKys7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5vdW5jZSA9IGFubm91bmNlO1xuICAgIH1cbiAgICBnZXQgYW5ub3VuY2UoKSB7XG4gICAgICAgIGlmICh0aGlzLl9hbm5vdW5jZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Fubm91bmNlO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLnBhc3N3b3JkKSB7XG4gICAgICAgICAgICByZXR1cm4gWyB0aGlzLmV5ZWJyb3csIHRoaXMuaGVscFRleHQgXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBbIHRoaXMuZXllYnJvdywgXCJJbnB1dDogXCIgKyB0aGlzLnRpdGxlLCB0aGlzLmhlbHBUZXh0IF07XG4gICAgICAgIH1cbiAgICB9XG59XG5cbnZhciBiYXNlJGcgPSB0aGVtZSA9PiB7XG4gICAgdmFyIHRleHRTdHlsZSA9IHRoZW1lLnR5cG9ncmFwaHkuaGVhZGxpbmUyO1xuICAgIHJldHVybiB7XG4gICAgICAgIGhlaWdodDogdGhlbWUuc3BhY2VyLm1kICogOSxcbiAgICAgICAgbWluV2lkdGg6IHRoZW1lLnNwYWNlci5tZCAqIDcsXG4gICAgICAgIHBhZGRpbmdYOiB0aGVtZS5zcGFjZXIubWQsXG4gICAgICAgIHRleHRTdHlsZTogdGV4dFN0eWxlLFxuICAgICAgICBzaXplczoge1xuICAgICAgICAgICAgc206IDEsXG4gICAgICAgICAgICBtZDogMixcbiAgICAgICAgICAgIGxnOiAzLFxuICAgICAgICAgICAgeGw6IDQsXG4gICAgICAgICAgICB4eGw6IDVcbiAgICAgICAgfSxcbiAgICAgICAgYmFzZVdpZHRoOiB0aGVtZS5zcGFjZXIubWQgKiA3LFxuICAgICAgICBpY29uV2lkdGg6IHRleHRTdHlsZS5saW5lSGVpZ2h0LFxuICAgICAgICBpY29uSGVpZ2h0OiB0ZXh0U3R5bGUubGluZUhlaWdodFxuICAgIH07XG59O1xuXG52YXIgc3R5bGVzJGcgPSBPYmplY3QuZnJlZXpl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ID0gdGhpcy5zdHlsZS5iYXNlV2lkdGggKiBzaXplTXVsdGlwbGllcjtcbiAgICAgICAgdmFyIHBhZGRpbmcgPSB0aGlzLmtleVNwYWNpbmcgKiAoc2l6ZU11bHRpcGxpZXIgLSAxKTtcbiAgICAgICAgcmV0dXJuIGJhc2VTaXplICsgcGFkZGluZztcbiAgICB9XG4gICAgX3VwZGF0ZVByZWZpeFN0eWxlKCkge1xuICAgICAgICBpZiAodGhpcy5fcHJlZml4ICYmIHRoaXMuaWNvbikge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJlZml4T2JqKHRoaXMuaWNvbiwge1xuICAgICAgICAgICAgICAgIHN0eWxlOiB0aGlzLnN0eWxlLmljb25TdHlsZVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVByZWZpeE9iaihpY29uKSB7XG4gICAgICAgIHZhciBwcm9wcyA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307XG4gICAgICAgIHRoaXMuX3ByZWZpeCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgIGljb246IGljb24sXG4gICAgICAgICAgICB3OiB0aGlzLnN0eWxlLmljb25XaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaWNvbkhlaWdodFxuICAgICAgICB9LCBwcm9wcyk7XG4gICAgfVxuICAgIF9zZXRJY29uKGljb24pIHtcbiAgICAgICAgaWYgKGljb24pIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaihpY29uLCB7XG4gICAgICAgICAgICAgICAgc3R5bGU6IHRoaXMuc3R5bGUuaWNvblN0eWxlXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3ByZWZpeCA9IGljb247XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGljb247XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5vdW5jZSA9IGFubm91bmNlO1xuICAgIH1cbiAgICBnZXQgYW5ub3VuY2UoKSB7XG4gICAgICAgIGlmICh0aGlzLl9hbm5vdW5jZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Fubm91bmNlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpc1VwcGVyQ2FzZSh0aGlzLnRpdGxlKSkge1xuICAgICAgICAgICAgcmV0dXJuIFwiQ2FwaXRhbCBcIi5jb25jYXQoZ2V0TmF0byh0aGlzLnRpdGxlKSwgXCIsIGJ1dHRvblwiKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZ2V0TmF0byh0aGlzLnRpdGxlKSArIFwiLCBidXR0b25cIjtcbiAgICB9XG4gICAgX2hhbmRsZUVudGVyKCkge1xuICAgICAgICBpZiAodHlwZW9mIHRoaXMub25FbnRlciA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5vbkVudGVyKHRoaXMpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMudG9nZ2xlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKFwiJHRvZ2dsZUtleWJvYXJkXCIsIHRoaXMudG9nZ2xlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycyhcIiRvblNvZnRLZXlcIiwge1xuICAgICAgICAgICAgICAgIGtleTogdGhpcy5rZXlJZCB8fCB0aGlzLnRpdGxlLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogdGhpcy50b2dnbGVcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG59XG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gICAgICBba2V5XTogcm93c1swXVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBba2V5XToge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBDb2x1bW4sXG4gICAgICAgICAgICAgICAgICAgIHBsaW5rbzogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgaXRlbXM6IHJvd3MsXG4gICAgICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpdGVtU3BhY2luZzogdGhpcy5zdHlsZS5rZXlTcGFjaW5nXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIGF1dG9SZXNpemVXaWR0aDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgYXV0b1Jlc2l6ZUhlaWdodDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgbmV2ZXJTY3JvbGw6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiBrZXkgPT09IGNhcGl0YWxpemUodGhpcy5fY3VycmVudEZvcm1hdCkgPyAxIDogLjAwMVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9jcmVhdGVSb3dzKCkge1xuICAgICAgICB2YXIgcm93cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogW107XG4gICAgICAgIHZhciBrZXlib2FyZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxID8gYXJndW1lbnRzWzFdIDogdW5kZWZpbmVkO1xuICAgICAgICByZXR1cm4gcm93cy5tYXAoKGtleXMgPT4ge1xuICAgICAgICAgICAgdmFyIF90aGlzJF9jdXJyZW50S2V5Ym9hcjtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgdHlwZTogUm93LFxuICAgICAgICAgICAgICAgIGF1dG9SZXNpemVIZWlnaHQ6IHRydWUsXG4gICAgICAgICAgICAgICAgYXV0b1Jlc2l6ZVdpZHRoOiB0cnVlLFxuICAgICAgICAgICAgICAgIGNlbnRlckluUGFyZW50OiB0aGlzLmNlbnRlcktleXMsXG4gICAgICAgICAgICAgICAgbmV2ZXJTY3JvbGw6IHRydWUsXG4gICAgICAgICAgICAgICAgd3JhcFNlbGVjdGVkOiB0aGlzLnJvd1dyYXAgIT09IHVuZGVmaW5lZCA/IHRoaXMucm93V3JhcCA6IHRydWUsXG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZ1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgaXRlbXM6IHRoaXMuX2NyZWF0ZUtleXMoa2V5cywga2V5Ym9hcmQpLFxuICAgICAgICAgICAgICAgIHNlbGVjdGVkSW5kZXg6ICgoX3RoaXMkX2N1cnJlbnRLZXlib2FyID0gdGhpcy5fY3VycmVudEtleWJvYXJkKSA9PT0gbnVsbCB8fCBfdGhpcyRfY3VycmVudEtleWJvYXIgPT09IHZvaWQgMCB8fCAoX3RoaXMkX2N1cnJlbnRLZXlib2FyID0gX3RoaXMkX2N1cnJlbnRLZXlib2FyLnNlbGVjdGVkKSA9PT0gbnVsbCB8fCBfdGhpcyRfY3VycmVudEtleWJvYXIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9jdXJyZW50S2V5Ym9hci5zZWxlY3RlZEluZGV4KSB8fCAwXG4gICAgICAgICAgICB9O1xuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF9jcmVhdGVLZXlzKCkge1xuICAgICAgICB2YXIga2V5cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogW107XG4gICAgICAgIHZhciBrZXlib2FyZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxID8gYXJndW1lbnRzWzFdIDogdW5kZWZpbmVkO1xuICAgICAgICByZXR1cm4ga2V5cy5tYXAoKGtleVByb3BzID0+IHtcbiAgICAgICAgICAgIGlmICgha2V5UHJvcHMpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLmtleUNvbXBvbmVudCB8fCBLZXksXG4gICAgICAgICAgICAgICAgICAgIGtleVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZyxcbiAgICAgICAgICAgICAgICAgICAgc2tpcEZvY3VzOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBhbHBoYTogLjAxXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBrZXkgPSB7XG4gICAgICAgICAgICAgICAgdHlwZTogdGhpcy5rZXlDb21wb25lbnQgfHwgS2V5LFxuICAgICAgICAgICAgICAgIGtleVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZ1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICh0eXBlb2Yga2V5UHJvcHMgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICB2YXIgX3RoaXMkc3R5bGUka2V5UHJvcHMsIF90aGlzJHN0eWxlJGtleVByb3BzMjtcbiAgICAgICAgICAgICAgICB2YXIga2V5TmFtZSA9IGtleVByb3BzLmtleUlkIHx8IGtleVByb3BzLnRpdGxlO1xuICAgICAgICAgICAgICAgIHZhciBrZXlPdmVycmlkZXMgPSAoKF90aGlzJHN0eWxlJGtleVByb3BzID0gdGhpcy5zdHlsZS5rZXlQcm9wcykgPT09IG51bGwgfHwgX3RoaXMkc3R5bGUka2V5UHJvcHMgPT09IHZvaWQgMCB8fCAoX3RoaXMkc3R5bGUka2V5UHJvcHMgPSBfdGhpcyRzdHlsZSRrZXlQcm9wc1trZXlib2FyZF0pID09PSBudWxsIHx8IF90aGlzJHN0eWxlJGtleVByb3BzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRzdHlsZSRrZXlQcm9wc1trZXlOYW1lXSkgfHwgKChfdGhpcyRzdHlsZSRrZXlQcm9wczIgPSB0aGlzLnN0eWxlLmtleVByb3BzKSA9PT0gbnVsbCB8fCBfdGhpcyRzdHlsZSRrZXlQcm9wczIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJHN0eWxlJGtleVByb3BzMltrZXlOYW1lXSkgfHwge307XG4gICAgICAgICAgICAgICAgdmFyIGtleVBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGtleSksIGtleVByb3BzKSwga2V5T3ZlcnJpZGVzKTtcbiAgICAgICAgICAgICAgICBpZiAoa2V5T3ZlcnJpZGVzICE9PSBudWxsICYmIGtleU92ZXJyaWRlcyAhPT0gdm9pZCAwICYmIGtleU92ZXJyaWRlcy5pY29uKSB7XG4gICAgICAgICAgICAgICAgICAgIGtleVBhdGNoLnN0eWxlID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBrZXlPdmVycmlkZXMuc3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWNvblN0eWxlOiBfb2JqZWN0U3ByZWFkKHt9LCBrZXlPdmVycmlkZXMuaWNvblN0eWxlKVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGtleVBhdGNoO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwga2V5KSwge30sIHtcbiAgICAgICAgICAgICAgICB0aXRsZToga2V5UHJvcHNcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF9mb3JtYXRLZXlib2FyZERhdGEoKSB7XG4gICAgICAgIHZhciBkYXRhID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBbXTtcbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoZGF0YSkgJiYgZGF0YS5sZW5ndGgpIHtcbiAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShkYXRhWzBdKSAmJiAhdGhpcy5pbmxpbmUpIHtcbiAgICAgICAgICAgICAgICB2YXIga2V5Um93cyA9IFtdO1xuICAgICAgICAgICAgICAgIHZhciBpZHgsIGNvdW50ZXI7XG4gICAgICAgICAgICAgICAgZm9yIChpZHggPSAwLCBjb3VudGVyID0gLTE7IGlkeCA8IGRhdGEubGVuZ3RoOyBpZHgrKykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaWR4ICUgdGhpcy5jb2x1bW5Db3VudCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY291bnRlcisrO1xuICAgICAgICAgICAgICAgICAgICAgICAga2V5Um93c1tjb3VudGVyXSA9IFtdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGtleVJvd3NbY291bnRlcl0ucHVzaChkYXRhW2lkeF0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4ga2V5Um93cztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5pbmxpbmUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gWyBkYXRhIF07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZGF0YTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfZm9ybWF0S2V5cygpIHtcbiAgICAgICAgT2JqZWN0LmtleXModGhpcy5mb3JtYXRzKS5mb3JFYWNoKChmb3JtYXQgPT4ge1xuICAgICAgICAgICAgdmFyIGVsZW1lbnQgPSB0aGlzLnRhZyhjYXBpdGFsaXplKGZvcm1hdCkpO1xuICAgICAgICAgICAgaWYgKGVsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICBlbGVtZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IGZvcm1hdCA9PT0gdGhpcy5fY3VycmVudEZvcm1hdCA/IDEgOiAuMDAxLFxuICAgICAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZ1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5pdGVtcy5mb3JFYWNoKChyb3cgPT4ge1xuICAgICAgICAgICAgICAgICAgICByb3cucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtU3BhY2luZzogdGhpcy5zdHlsZS5rZXlTcGFjaW5nXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgY2VudGVySW5QYXJlbnQ6IHRoaXMuY2VudGVyS2V5cyxcbiAgICAgICAgICAgICAgICAgICAgICAgIHdyYXBTZWxlY3RlZDogdGhpcy5yb3dXcmFwICE9PSB1bmRlZmluZWQgPyB0aGlzLnJvd1dyYXAgOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICBlbGVtZW50LnF1ZXVlUmVxdWVzdFVwZGF0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgfVxuICAgICR0b2dnbGVLZXlib2FyZChuZXh0KSB7XG4gICAgICAgIHZhciBuZXh0S2V5Ym9hcmQgPSBjYXBpdGFsaXplKG5leHQpO1xuICAgICAgICBpZiAobmV4dCAhPT0gdGhpcy5fY3VycmVudEZvcm1hdCkge1xuICAgICAgICAgICAgdmFyIG5leHRLZXlib2FyZFRhZyA9IHRoaXMudGFnKG5leHRLZXlib2FyZCk7XG4gICAgICAgICAgICB0aGlzLnNlbGVjdEtleU9uKG5leHRLZXlib2FyZFRhZyk7XG4gICAgICAgICAgICB0aGlzLl9jdXJyZW50S2V5Ym9hcmQuYWxwaGEgPSAuMDAxO1xuICAgICAgICAgICAgbmV4dEtleWJvYXJkVGFnLmFscGhhID0gMTtcbiAgICAgICAgICAgIHRoaXMuX2N1cnJlbnRGb3JtYXQgPSBuZXh0O1xuICAgICAgICB9XG4gICAgfVxuICAgIHNlbGVjdEtleU9uKGtleWJvYXJkKSB7XG4gICAgICAgIHZhciB7cm93OiByb3csIGNvbHVtbjogY29sdW1ufSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdGhpcy5nZXRTZWxlY3RlZEtleSgpO1xuICAgICAgICBpZiAoa2V5Ym9hcmQgJiYga2V5Ym9hcmQuY29uc3RydWN0b3IpIHtcbiAgICAgICAgICAgIHZhciB0eXBlID0ga2V5Ym9hcmQuY29uc3RydWN0b3IubmFtZTtcbiAgICAgICAgICAgIGlmICh0eXBlID09PSBcIlJvd1wiKSB7XG4gICAgICAgICAgICAgICAga2V5Ym9hcmQuc2VsZWN0ZWRJbmRleCA9IGNvbHVtbjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAga2V5Ym9hcmQuc2VsZWN0ZWRJbmRleCA9IHJvdztcbiAgICAgICAgICAgICAgICBrZXlib2FyZC5zZWxlY3RlZC5zZWxlY3RlZEluZGV4ID0gY29sdW1uO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIGdldFNlbGVjdGVkS2V5KCkge1xuICAgICAgICB2Y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uICAgIH1cbiAgICBnZXQgZW1haWxGb3JtYXQoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB1cHBlcmNhc2U6IFsgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCJRXCIsIFwiV1wiLCBcIkVcIiwgXCJSXCIsIFwiVFwiLCBcIllcIiwgXCJVXCIsIFwiSVwiLCBcIk9cIiwgXCJQXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9IF0sIFsgXCJBXCIsIFwiU1wiLCBcIkRcIiwgXCJGXCIsIFwiR1wiLCBcIkhcIiwgXCJKXCIsIFwiS1wiLCBcIkxcIiwgXCJAXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLDocO2w7tcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImFjY2VudHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhY2NlbnRzLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJhY2NlbnRzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIlpcIiwgXCJYXCIsIFwiQ1wiLCBcIlZcIiwgXCJCXCIsIFwiTlwiLCBcIk1cIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwZXJpb2QsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwic2hpZnRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNoaWZ0IG9mZiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29tXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb21cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIubmV0XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBuZXRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuZWR1XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBlZHVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIub3JnXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBvcmdcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLnVrXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCB1a1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgbG93ZXJjYXNlOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwicVwiLCBcIndcIiwgXCJlXCIsIFwiclwiLCBcInRcIiwgXCJ5XCIsIFwidVwiLCBcImlcIiwgXCJvXCIsIFwicFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiI0AhXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJzeW1ib2xzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3ltYm9sIG1vZGUsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInN5bWJvbHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiYVwiLCBcInNcIiwgXCJkXCIsIFwiZlwiLCBcImdcIiwgXCJoXCIsIFwialwiLCBcImtcIiwgXCJsXCIsIFwiQFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiw6HDtsO7XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWNjZW50cywgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiYWNjZW50c1wiXG4gICAgICAgICAgICB9IF0sIFsgXCJ6XCIsIFwieFwiLCBcImNcIiwgXCJ2XCIsIFwiYlwiLCBcIm5cIiwgXCJtXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJ1cHBlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvbiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29tXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb21cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIubmV0XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBuZXRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuZWR1XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBlZHVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIub3JnXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBvcmdcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLnVrXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCB1a1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0d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iLCBcIsO0XCIsIFwiw7tcIiwgXCLDo1wiLCBcIsOxXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzVXBwZXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvZmYsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvbVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29tXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm5ldFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgbmV0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmVkdVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgZWR1XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm9yZ1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgb3JnXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi51a1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgdWtcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiA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XCLDg1wiLCBcIsORXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb2ZmLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzaGlmdFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb21cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvbVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5uZXRcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG5ldFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5lZHVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGVkdVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5vcmdcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG9yZ1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIudWtcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIHVrXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF0sXG4gICAgICAgICAgICBzeW1ib2xzOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIhXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZXhjbGFtYXRpb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCBcIkBcIiwgXCIjXCIsIFwiJFwiLCBcIiVcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjYXJldCBjaXJjdW1mbGV4LCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCImXCIsIFwiKlwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiKFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIm9wZW4gcGFyZW50aGVzaXMsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiKVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIHBhcmVudGhlc2lzLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcImFiY1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwibG93ZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWxwaGEgbW9kZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwie1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIm9wZW4gYnJhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwifVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIGJyYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIltcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIGJyYWNrZXQsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiXVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIGJyYWNrZXQsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiO1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNlbWljb2xvbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogJ1wiJyxcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3VibGVxdW90ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIsXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY29tbWEsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwifFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInZlcnRpY2FsIGJhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJcXFxcXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYmFja3NsYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJmb3J3YXJkc2xhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiw6HDtsO7XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWNjZW50cywgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiYWNjZW50c1wiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjxcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJsZXNzIHRoYW4sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiPlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImdyZWF0ZXIgdGhhbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI/XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicXVlc3Rpb24gbWFyaywgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI9XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZXF1YWwgc2lnbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJgXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZ3JhdmUgYWNjZW50LCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIn5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ0aWxkZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI6XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY29sb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiK1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBsdXMgc2lnbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvbVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29tXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm5ldFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgbmV0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmVkdVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgZWR1XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm9yZ1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgb3JnXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi51a1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgdWtcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXVxuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgS2V5Ym9hcmRGdWxsU2NyZWVuIGV4dGVuZHMgS2V5Ym9hcmQge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJLZXlib2FyZEZ1bGxTY3JlZW5cIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkZjtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB0aGlzLmZvcm1hdHMgPSB0aGlzLmZ1bGxzY3JlZW5Gb3JtYXQ7XG4gICAgfVxuICAgIGdldCBmdWxsc2NyZWVuRm9ybWF0KCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgbGV0dGVyczogWyBbIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiBdLCBbIFwiQVwiLCBcIkJcIiwgXCJDXCIsIFwiRFwiLCBcIkVcIiwgXCJGXCIsIFwiR1wiLCBcIkhcIiwgXCJJXCIsIFwiSlwiLCBcIktcIiwgXCJMXCIsIFwiTVwiLCBcIk5cIiwgXCJPXCIsIFwiUFwiLCBcIlFcIiwgXCJSXCIsIFwiU1wiLCBcIlRcIiwgXCJVXCIsIFwiVlwiLCBcIldcIiwgXCJYXCIsIFwiWVwiLCBcIlpcIiBdIF0sXG4gICAgICAgICAgICBzeW1ib2xzOiBbIFsgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkFCQ1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwibGV0dGVyc1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNhcHMgb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiwgXCJcIiBdLCBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiIVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImV4Y2xhbWF0aW9uLCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCJAXCIsIFwiI1wiLCBcIiRcIiwgXCIlXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJeXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2FyZXQgY2lyY3VtZmxleCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIFwiJlwiLCBcIipcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIihcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIHBhcmVudGhlc2lzLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIilcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbG9zZSBwYXJlbnRoZXNpcywgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJgXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZ3JhdmUgYWNjZW50LCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCJ+XCIsIFwiX1wiLCBcIi5cIiwgXCItXCIsIFwiK1wiIF0gXVxuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgS2V5Ym9hcmROdW1iZXJzIGV4dGVuZHMgS2V5Ym9hcmQge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJ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IkZcIiwgXCJHXCIsIFwiSFwiLCBcIkpcIiwgXCJLXCIsIFwiTFwiLCBcIkBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIsOhw7bDu1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFjY2VudHMsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImFjY2VudHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiWlwiLCBcIlhcIiwgXCJDXCIsIFwiVlwiLCBcIkJcIiwgXCJOXCIsIFwiTVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBlcmlvZCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJzaGlmdFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwibG93ZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb2ZmLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzaGlmdFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF0sXG4gICAgICAgICAgICBsb3dlcmNhc2U6IFsgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCJxXCIsIFwid1wiLCBcImVcIiwgXCJyXCIsIFwidFwiLCBcInlcIiwgXCJ1XCIsIFwiaVwiLCBcIm9cIiwgXCJwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9IF0sIFsgXCJhXCIsIFwic1wiLCBcImRcIiwgXCJmXCIsIFwiZ1wiLCBcImhcIiwgXCJqXCIsIFwia1wiLCBcImxcIiwgXCJAXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLDocO2w7tcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImFjY2VudHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhY2NlbnRzLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJhY2NlbnRzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcInpcIiwgXCJ4XCIsIFwiY1wiLCBcInZcIiwgXCJiXCIsIFwiblwiLCBcIm1cIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwZXJpb2QsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwic2hpZnRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInVwcGVyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNoaWZ0IG9uLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzaGlmdFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF0sXG4gICAgICAgICAgICBhY2NlbnRzOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwiw6RcIiwgXCLDq1wiLCBcIsOvXCIsIFwiw7ZcIiwgXCLDvFwiLCBcIsO/XCIsIFwiw6BcIiwgXCLDqFwiLCBcIsOsXCIsIFwiw7JcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIiNAIVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwic3ltYm9sc1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInN5bWJvbCBtb2RlLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzeW1ib2xzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsO5XCIsIFwiw6FcIiwgXCLDqVwiLCBcIsOtXCIsIFwiw7NcIiwgXCLDulwiLCBcIsO9XCIsIFwiw6JcIiwgXCLDqlwiLCBcIkBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcImFiY1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwibG93ZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWxwaGEgbW9kZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsOuXCIsIFwiw7RcIiwgXCLDu1wiLCBcIsOjXCIsIFwiw7FcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwZXJpb2QsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwic2hpZnRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImFjY2VudHNVcHBlclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNoaWZ0IG9mZiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgYWNjZW50c1VwcGVyOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwiw4RcIiwgXCLDi1wiLCBcIsOPXCIsIFwiw5ZcIiwgXCLDnFwiLCBcIsW4XCIsIFwiw4BcIiwgXCLDiFwiLCBcIsOMXCIsIFwiw5JcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIiNAIVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwic3ltYm9sc1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInN5bWJvbCBtb2RlLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzeW1ib2xzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsOZXCIsIFwiw4FcIiwgXCLDiVwiLCBcIsONXCIsIFwiw5NcIiwgXCLDmlwiLCBcIsOdXCIsIFwiw4JcIiwgXCLDilwiLCBcIkBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcImFiY1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwibG93ZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWxwaGEgbW9kZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsOOXCIsIFwiw5RcIiwgXCLDm1wiLCBcIsODXCIsIFwiw5FcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwZXJpb2QsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwic2hpZnRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImFjY2VudHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvZmYsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiAgICAgICAgICAgIHN5bWJvbHM6IFsgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIiFcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJleGNsYW1hdGlvbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIFwiQFwiLCBcIiNcIiwgXCIkXCIsIFwiJVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiXlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNhcmV0IGNpcmN1bWZsZXgsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCBcIiZcIiwgXCIqXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIoXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwib3BlbiBwYXJlbnRoZXNpcywgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIpXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xvc2UgcGFyZW50aGVzaXMsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiYWJjXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJsb3dlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhbHBoYSBtb2RlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJ7XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwib3BlbiBicmFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJ9XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xvc2UgYnJhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiW1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIm9wZW4gYnJhY2tldCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJdXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xvc2UgYnJhY2tldCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI7XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2VtaWNvbG9uLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiAnXCInLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdWJsZXF1b3RlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIixcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjb21tYSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJ8XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidmVydGljYWwgYmFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlxcXFxcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJiYWNrc2xhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiL1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImZvcndhcmRzbGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLDocO2w7tcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImFjY2VudHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhY2NlbnRzLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJhY2NlbnRzXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiPFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImxlc3MgdGhhbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI+XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZ3JlYXRlciB0aGFuLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIj9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJxdWVzdGlvbiBtYXJrLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIj1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJlcXVhbCBzaWduLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcImBcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJncmF2ZSBhY2NlbnQsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiflwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInRpbGRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjpcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjb2xvbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIrXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGx1cyBzaWduLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdXG4gICAgICAgIH07XG4gICAgfVxufVxuXG5jbGFzcyBLZXlib2FyZElucHV0IGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiS2V5Ym9hcmRJbnB1dFwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiY2VudGVyS2V5Ym9hcmRcIiwgXCJkZWZhdWx0Rm9ybWF0XCIsIFwiaW5wdXRcIiwgXCJrZXlib2FyZFR5cGVcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRmO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgV3JhcHBlcjoge1xuICAgICAgICAgICAgICAgIHR5cGU6IENvbHVtbixcbiAgICAgICAgICAgICAgICBuZXZlclNjcm9sbDogdHJ1ZSxcbiAgICAgICAgICAgICAgICB3OiB0aGlzLncsXG4gICAgICAgICAgICAgICAgaXRlbXM6IFsge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJbnB1dCxcbiAgICAgICAgICAgICAgICAgICAgcmVmOiBcIklucHV0XCJcbiAgICAgICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEtleWJvYXJkLFxuICAgICAgICAgICAgICAgICAgICByZWY6IFwiS2V5Ym9hcmRcIixcbiAgICAgICAgICAgICAgICAgICAgcGFzc1NpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGtleWJvYXJkV2lkdGhDaGFuZ2VkOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IF0sXG4gICAgICAgICAgICAgICAgc2VsZWN0ZWRJbmRleDogMSxcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICA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wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcIm51bWJlclwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiM1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcIm51bWJlclwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiNFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcIm51bWJlclwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjVcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjZcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjhcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjlcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjBcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXVxuICAgICAgICB9O1xuICAgIH1cbn1cblxudmFyIGJhc2UkZSA9IHRoZW1lID0+IHtcbiAgICB2YXIgc2l6ZSA9IHRoZW1lLnNwYWNlci5sZztcbiAgICByZXR1cm4ge1xuICAgICAgICB3aWR0aDogc2l6ZSxcbiAgICAgICAgaGVpZ2h0OiBzaXplLFxuICAgICAgICByYWRpdXM6IHNpemUgLyAyXG4gICAgfTtcbn07XG5cbnZhciB0b25lJDkgPSB0aGVtZSA9PiAoe1xuICAgIG5ldXRyYWw6IHtcbiAgICAgICAgY2lyY2xlQ29sb3I6IHRoZW1lLmNvbG9yLmludGVyYWN0aXZlTmV1dHJhbEZvY3VzLFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgY2lyY2xlQ29sb3I6IHRoZW1lLmNvbG9yLmludGVyYWN0aXZlSW52ZXJzZUZvY3VzLFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5maWxsSW52ZXJzZURpc2FibGVkXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZUJyYW5kRm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aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgIH1cbiAgICB9LFxuICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VcbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgdG9uZSQ4ID0gdGhlbWUgPT4gKHtcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkZCA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJGQsXG4gICAgbW9kZTogbW9kZSQ1LFxuICAgIHRvbmU6IHRvbmUkOFxufSk7XG5cbmNsYXNzIExpc3RJdGVtIGV4dGVuZHMgQnV0dG9uIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTGlzdEl0ZW1cIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkZDtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkpLCB7fSwge1xuICAgICAgICAgICAganVzdGlmeTogXCJsZWZ0XCIsXG4gICAgICAgICAgICBmaXhlZDogdHJ1ZSxcbiAgICAgICAgICAgIENvbnRlbnQ6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkuQ29udGVudCksIHt9LCB7XG4gICAgICAgICAgICAgICAgVGV4dFdyYXBwZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgZmxleDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgZGlyZWN0aW9uOiBcImNvbHVtblwiXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIFRpdGxlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9vblRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIC4uLnN1cGVyLnByb3BlcnRpZXMsIFwiZGVzY3JpcHRpb25cIiwgXCJwcmVmaXhMb2dvXCIsIFwic3VmZml4TG9nb1wiLCBcInNob3VsZENvbGxhcHNlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBhbGlhc1N0eWxlcygpIHtcbiAgICAgICAgcmV0dXJuIFsge1xuICAgICAgICAgICAgcHJldjogXCJ0aXRsZVBhZGRpbmdcIixcbiAgICAgICAgICAgIGN1cnI6IFwiY29udGVudFNwYWNpbmdcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIudGFncywge1xuICAgICAgICAgICAgbmFtZTogXCJEZXNjcmlwdGlvblwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlRleHRXcmFwcGVyLkRlc2NyaXB0aW9uXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBfb25UZXh0Qm94Q2hhbmdlZCgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGl0bGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlRGVzY3JpcHRpb24oKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVHJ1bmNhdGlvbigpO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhMb2dvKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVN1ZmZpeExvZ28oKTtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVEZXNjcmlwdGlvbigpO1xuICAgIH1cbiAgICBfdXBkYXRlVGl0bGUoKSB7XG4gICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgIFRpdGxlOiB7XG4gICAgICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUudGl0bGVUZXh0U3R5bGVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlRGVzY3JpcHRpb24oKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNEZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgdmFyIGRlc2NyaXB0aW9uUGF0Y2ggPSB7XG4gICAgICAgICAgICAgICAgY29udGVudDogdGhpcy5kZXNjcmlwdGlvbixcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXNjcmlwdGlvblRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX2ZpeGVkV29yZFdyYXBXaWR0aFxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgdmlzaWJsZTogIXRoaXMuX2NvbGxhcHNlXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9EZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uUGF0Y2ggPSBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX29uVGV4dEJveENoYW5nZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSwgZGVzY3JpcHRpb25QYXRjaCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9UZXh0V3JhcHBlci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgRGVzY3JpcHRpb246IGRlc2NyaXB0aW9uUGF0Y2hcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgICAgIERlc2NyaXB0aW9uOiB1bmRlZmluZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVUcnVuY2F0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RpdGxlLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50aXRsZVRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdGhpcy5maXhlZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuZml4ZWQgPyB0aGlzLl9maXhlZFdvcmRXcmFwV2lkdGggOiAwXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVByZWZpeExvZ28oKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNQcmVmaXhMb2dvKSB7XG4gICAgICAgICAgICB0aGlzLl9wcmVmaXggPSB0aGlzLl9hZGRMb2dvUHJvcHModGhpcy5fcHJlZml4TG9nbyk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVN1ZmZpeExvZ28oKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNTdWZmaXhMb2dvKSB7XG4gICAgICAgICAgICB0aGlzLl9zdWZmaXggPSB0aGlzLl9hZGRMb2dvUHJvcHModGhpcy5fc3VmZml4TG9nbyk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2FkZExvZ29Qcm9wcyhpY29uKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgaWNvbjogaWNvbixcbiAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICBjb2xvcjogdW5kZWZpbmVkXG4gICAgICAgICAgICB9LCB0aGlzLnN0eWxlLmxvZ29TdHlsZSlcbiAgICAgICAgfTtcbiAgICB9XG4gICAgZ2V0IF9oYXNQcmVmaXhMb2dvKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5wcmVmaXhMb2dvO1xuICAgIH1cbiAgICBnZXQgX2hhc1N1ZmZpeExvZ28oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnN1ZmZpeExvZ287XG4gICAgfVxuICAgIGdldCBfcm93UHJvcHMoKSB7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHN1cGVyLl9yb3dQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICBhdXRvUmVzaXplSGVpZ2h0OiB0cnVlXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBnZXQgX2J1dHRvblByb3BzKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fYnV0dG9uUHJvcHMpLCB7fSwge1xuICAgICAgICAgICAgYWxwaGE6IHRoaXMuc3R5bGUuYWxwaGFcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIGdldCBfaGFzRGVzY3JpcHRpb24oKSB7XG4gICAgICAgIHJldHVybiAhIXRoaXMuZGVzY3JpcHRpb247XG4gICAgfVxuICAgIGdldCBfc3VmZml4WCgpIHtcbiAgICAgICAgc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B0aGVtZS5jb2xvci5maWxsSW52ZXJzZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgaW52ZXJzZToge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgYXJyb3dDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWwsXG4gICAgICAgICAgICAgICAgcHJvZ3Jlc3NCYXI6IHtcbiAgICAgICAgICAgICAgICAgICAgYmFyQ29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsVGVydGlhcnksXG4gICAgICAgICAgICAgICAgICAgIHByb2dyZXNzQ29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgYXJyb3dDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2UsXG4gICAgICAgICAgICAgICAgcHJvZ3Jlc3NCYXI6IHtcbiAgICAgICAgICAgICAgICAgICAgYmFyQ29sb3I6IHRoZW1lLmNvbG9yLmZpbGxCcmFuZFRlcnRpYXJ5LFxuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc0NvbG9yOiB0aGVtZS5jb2xvci5maWxsQnJhbmRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRjID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkYyxcbiAgICBtb2RlOiBtb2RlJDQsXG4gICAgdG9uZTogdG9uZSQ3XG59KTtcblxudmFyIGJhc2UkYiA9IHRoZW1lID0+IHtcbi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IC41LFxuICAgICAgICAgICAgICAgICAgICBTbGlkZXJCYXI6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFByb2dyZXNzQmFyLFxuICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3M6IC41LFxuICAgICAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIlwiXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIENpcmNsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogS25vYixcbiAgICAgICAgICAgICAgICAgICAgICAgIHpJbmRleDogNVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBMZWZ0QXJyb3c6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgUmlnaHRBcnJvdzoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICB5OiBoID0+IGggLyAyXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwibWF4XCIsIFwibWluXCIsIFwic3RlcFwiLCBcInZhbHVlXCIsIFwidmVydGljYWxcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQ29udGFpbmVyXCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiQmFyXCIsXG4gIC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ljYWwgPyBkZWdyZWVzVG9SYWRpYW5zKDkwKSA6IDAsXG4gICAgICAgICAgICBtb3VudFk6IHRoaXMudmVydGljYWwgPyAuNSA6IDBcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVTbGlkZXJMYXlvdXQoKSB7XG4gICAgICAgIHZhciB3ID0gdGhpcy53IHx8IHRoaXMuc3R5bGUubWluV2lkdGg7XG4gICAgICAgIHRoaXMuX0NvbnRhaW5lci5wYXRjaCh7XG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmNvbnRhaW5lckhlaWdodCxcbiAgICAgICAgICAgIHc6IHcsXG4gICAgICAgICAgICBCYXI6IHtcbiAgICAgICAgICAgICAgICB4OiB0aGlzLl9jYWxjdWxhdGVkU2xpZGVyWCxcbiAgICAgICAgICAgICAgICBTbGlkZXJCYXI6IHtcbiAgICAgICAgICAgICAgICAgICAgeTogdGhpcy5zdHlsZS5jb250YWluZXJIZWlnaHQgLyAyLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLl9jYWxjdWxhdGVkU2xpZGVyV2lkdGgsXG4gICAgICAgICAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGR1cmF0aW9uOiAwXG4gICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuc3R5bGUucHJvZ3Jlc3NCYXIpXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5oID0gTWF0aC5tYXgodGhpcy5zdHlsZS5jb250YWluZXJIZWlnaHQsIHRoaXMuc3R5bGUuYXJyb3dIZWlnaHQpO1xuICAgIH1cbiAgICBfY2hlY2tBbmRTaWduYWxTaXplQ2hhbmdlKCkge1xuICAgICAgICBpZiAodGhpcy5oICE9PSB0aGlzLnByZXZIIHx8IHRoaXMuX0NvbnRhaW5lci53ICE9PSB0aGlzLnByZXZXIHx8IHRoaXMucm90Y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VmFsdWVMaW1pdCA6IG9mZkFscGhhO1xuICAgICAgICBsZWZ0QWxwaGEgPSByaWdodEFscGhhID0gYWxwaGE7XG4gICAgICAgIGlmICghdGhpcy5faXNEaXNhYmxlZE1vZGUgJiYgdGhpcy52YWx1ZSA8PSB0aGlzLm1pbikge1xuICAgICAgICAgICAgbGVmdEFscGhhID0gYWxwaGFMaW1pdDtcbiAgICAgICAgICAgIHJpZ2h0QWxwaGEgPSBhbHBoYTtcbiAgICAgICAgfSBlbHNlIGlmICghdGhpcy5faXNEaXNhYmxlZE1vZGUgJiYgdGhpcy52YWx1ZSA+PSB0aGlzLm1heCkge1xuICAgICAgICAgICAgbGVmdEFscGhhID0gYWxwaGE7XG4gICAgICAgICAgICByaWdodEFscGhhID0gYWxwaGFMaW1pdDtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9MZWZ0QXJyb3cuc21vb3RoID0ge1xuICAgICAgICAgICAgYWxwaGE6IGxlZnRBbHBoYVxuICAgICAgICB9O1xuICAgICAgICB0aGlzLl9SaWdodEFycm93LnNtb290aCA9IHtcbiAgICAgICAgICAgIGFscGhhOiByaWdodEFscGhhXG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVBcnJvd3MoKSB7XG4gICAgICAgIHZhciBhcnJvd1Byb3BzID0ge1xuICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5hcnJvd1dpZHRoLFxuICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5hcnJvd0hlaWdodCxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuYXJyb3dDb2xvclxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICB0aGlzLl9MZWZ0QXJyb3cucGF0Y2goX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBhcnJvd1Byb3BzKSwge30sIHtcbiAgICAgICAgICAgIGljb246IHRoaXMuc3R5bGUuaWNvbkxlZnR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AgIF9zZXRNYXgobWF4KSB7XG4gICAgICAgIHZhciB2YWx1ZSA9IHRoaXMudmFsdWU7XG4gICAgICAgIHRoaXMudmFsdWUgPSBtYXggPCB2YWx1ZSA/IG1heCA6IHZhbHVlO1xuICAgICAgICB0aGlzLl92YWx1ZUNoYW5nZWQgPSB2YWx1ZSAhPT0gdGhpcy52YWx1ZTtcbiAgICAgICAgcmV0dXJuIG1heDtcbiAgICB9XG4gICAgc2V0IGFubm91bmNlKGFubm91bmNlKSB7XG4gICAgICAgIHN1cGVyLmFubm91bmNlID0gYW5ub3VuY2U7XG4gICAgfVxuICAgIGdldCBhbm5vdW5jZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX2Fubm91bmNlICE9PSB1bmRlZmluZWQgJiYgdGhpcy5fYW5ub3VuY2UgIT09IG51bGwpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy52YWx1ZS50b1N0cmluZygpO1xuICAgIH1cbiAgICBzdGF0aWMgX3N0YXRlcygpIHtcbiAgICAgICAgcmV0dXJuIFsgY2xhc3MgVmVydGljYWxTbGlkZXIgZXh0ZW5kcyh0aGlzKXtcbiAgICAgICAgICAgIF9oYW5kbGVMZWZ0KCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIF9oYW5kbGVSaWdodCgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBfaGFuZGxlVXAoKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzRGlzYWJsZWRNb2RlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fZGVjcmVtZW50VmFsdWUoKTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25VcCA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm9uVXAodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX2hhbmRsZURvd24oKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzRGlzYWJsZWRNb2RlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5faW5jcmVtZW50VmFsdWUoKTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25Eb3duID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMub25Eb3duKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBdO1xuICAgIH1cbn1cblxuY2xhc3MgTmVzdGVkU2xpZGVyIGV4dGVuZHMgU2xpZGVyIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTmVzdGVkU2xpZGVyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJGM7XG4gICAgfVxufVxuXG52YXIgYmFzZSRhID0gdGhlbWUgPT4gKHtcbiAgICBwYWRkaW5nWTogdGhlbWUuc3BhY2VyLm1kICsgdGhlbWUuc3BhY2VyLnhzLFxuICAgIHZhbHVlVGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoZW1lLnR5cG9ncmFwaHkuaGVhZGxpbmUzKSwge30sIHtcbiAgICAgICAgbWF4TGluZXM6IDEsXG4gICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxTZWNvbmRhcnlcbiAgICB9KVxufSk7XG5cbnZhciBtb2RlJDIgPSB0aGVtZSA9PiAoe1xuICAgIGRpc2FibGVkOiB7XG4gICAgICAgIHZhbHVlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgfVxuICAgIH0sXG4gICAgZm9jdXNlZDoge1xuICAgICAgICB2YWx1ZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVNlY29uZGFyeVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciB0b25lJDUgPSB0aGVtZSA9PiAoe1xuICAgIG5ldXRyYWw6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIHZhbHVlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VTZWNvbmRhcnlcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIHZhbHVlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxTZWNvbmRhcnlcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ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NvbnRlbnQuVGV4dFdyYXBwZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IDAsXG4gICAgICAgICAgICAgICAgICAgIGZsZXg6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgIFNsaWRlcjoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBOZXN0ZWRTbGlkZXIsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG9uQ2hhbmdlOiBcIl9vblNsaWRlckNoYW5nZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSlcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIucHJvcGVydGllcywgXCJzbGlkZXJcIiwgXCJ2YWx1ZVwiLCBcIm1heFwiLCBcIm1pblwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgYWxpYXNTdHlsZXMoKSB7XG4gICAgICAgIHJldHVybiBbIHtcbiAgICAgICAgICAgIHByZXY6IFwidGl0bGVQYWRkaW5nXCIsXG4gICAgICAgICAgICBjdXJyOiBcImNvbnRlbnRTcGFjaW5nXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIC4uLnN1cGVyLnRhZ3MsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiU2xpZGVyXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnQuU2xpZGVyXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJWYWx1ZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlRleHRXcmFwcGVyLlZhbHVlXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBfY29uc3RydWN0KCkge1xuICAgICAgICBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgIHRoaXMudmFsdWUgPSA1MDtcbiAgICAgICAgdGhpcy5tYXggPSAxMDA7XG4gICAgICAgIHRoaXMubWluID0gMDtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVTbGlkZXJQb3NpdGlvbigpO1xuICAgICAgICB0aGlzLl91cGRhdGVWYWx1ZSgpO1xuICAgIH1cbiAgICBfb25UZXh0Qm94Q2hhbmdlZCgpIHtcbiAgICAgICAgc3VwZXIuX29uVGV4dEJveENoYW5nZWQoKTtcbiAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIuaCA9IE1hdGgubWF4KHRoaXMuX1RpdGxlID8gdGhpcy5fVGl0bGUuaCA6IDAsIHRoaXMuX1ZhbHVlID8gdGhpcy5fVmFsdWUuaCA6IDApO1xuICAgIH1cbiAgICBfdXBkYXRlVmFsdWUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNWYWx1ZSkge1xuICAgICAgICAgICAgdmFyIHZhbHVlUGF0Y2ggPSB7XG4gICAgICAgICAgICAgICAgY29udGVudDogdGhpcy52YWx1ZS50b1N0cmluZygpLFxuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS52YWx1ZVRleHRTdHlsZSlcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIG1vdW50WDogMSxcbiAgICAgICAgICAgICAgICB4OiB0aGlzLncgLSB0aGlzLl9wYWRkaW5nWFxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fVmFsdWUpIHtcbiAgICAgICAgICAgICAgICB2YWx1ZVBhdGNoID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9vblRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIHZhbHVlUGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgICAgIFZhbHVlOiB2YWx1ZVBhdGNoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBWYWx1ZTogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlU2xpZGVyUG9zaXRpb24oKSB7XG4gICAgICAgIHZhciB3ID0gdGhpcy53IC0gdGhpcy5fcGFkZGluZ0xlZnQgLSB0aGlzLl9wYWRkaW5nUmlnaHQ7XG4gICAgICAgIHZhciBzbGlkZXJQcm9wcyA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICBtb2RlOiB0aGlzLm1vZGUsXG4gICAgICAgICAgICB0b25lOiB0aGlzLnRvbmUsXG4gICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgeDogdyAvIDIsXG4gICAgICAgICAgICB2aXNpYmxlOiAhdGhpcy5fY29sbGFwc2UsXG4gICAgICAgICAgICBhbHBoYTogdGhpcy5zdHlsZS5hbHBoYVxuICAgICAgICB9LCB0aGlzLnNsaWRlciksIHt9LCB7XG4gICAgICAgICAgICB2YWx1ZTogdGhpcy52YWx1ZSxcbiAgICAgICAgICAgIG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kOiB7XG4gICAgICAgICAgICAgICAgYXJyb3dDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2VcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgaW52ZXJzZToge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgYXJyb3dDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWxcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGFycm93Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxJbnZlcnNlXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyQ5ID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkOSxcbiAgICB0b25lOiB0b25lJDRcbn0pO1xuXG5jbGFzcyBMaXN0SXRlbVBpY2tlciBleHRlbmRzIExpc3RJdGVtIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTGlzdEl0ZW1QaWNrZXJcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkOTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci5wcm9wZXJ0aWVzLCBcIm9wdGlvbnNcIiwgXCJzZWxlY3RlZEluZGV4XCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCBcIkxlZnRBcnJv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AgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIGp1c3RpZnk6IFwibGVmdFwiXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlQXJyb3dzKCkge1xuICAgICAgICBpZiAoIXRoaXMuX2lzRm9jdXNlZE1vZGUpIHtcbiAgICAgICAgICAgIHZhciBvZmZBbHBoYSA9IC4wMDE7XG4gICAgICAgICAgICBpZiAodGhpcy5fTGVmdEFycm93KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fTGVmdEFycm93LmFscGhhID0gb2ZmQWxwaGE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fUmlnaHRBcnJvdykge1xuICAgICAgICAgICAgICAgIHRoaXMuX1JpZ2h0QXJyb3cuYWxwaGEgPSBvZmZBbHBoYTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgYXJyb3dQcm9wcyA9IHtcbiAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUuYXJyb3dXaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuYXJyb3dIZWlnaHQsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIGNvbG9yOiB0aGlzLnN0eWxlLmFycm93Q29sb3JcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBhbHBoYTogdGhpcy5zdHlsZS5hcnJvd0FscGhhVmFsdWVcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKCF0aGlzLl9MZWZ0QXJyb3cpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIExlZnRBcnJvdzoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICB5OiBoID0+IGggLyAyXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fTGVmdEFycm93LnBhdGNoKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgYXJyb3dQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICBpY29uOiB0aGlzLnN0eWxlLmljb25MZWZ0U3JjXG4gICAgICAgIH0pKTtcbiAgICAgICAgdGhpcy5fTGVmdEFycm93LnNtb290aCA9IHtcbiAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUucGFkZGluZ1hcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKCF0aGlzLl9SaWdodEFycm93KSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBSaWdodEFycm93OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEljb24sXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WDogMSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX1JpZ2h0QXJyb3cucGF0Y2goX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBhcnJvd1Byb3BzKSwge30sIHtcbiAgICAgICAgICAgIGljb246IHRoaXMuc3R5bGUuaWNvblJpZ2h0U3JjXG4gICAgICAgIH0pKTtcbiAgICAgICAgdGhpcy5fUmlnaHRBcnJvdy5zbW9vdGggPSB7XG4gICAgICAgICAgICB4OiB0aGlzLncgLSB0aGlzLnN0eWxlLnBhZGRpbmdYXG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVQaWNrZXIoKSB7XG4gICAgICAgIHZhciB3ID0gdGhpcy53IC0gdGhpcy5fcGFkZGluZ1ggLSB0aGlzLnN0eWxlLmFycm93V2lkdGggKiAyO1xuICAgICAgICBpZiAoIXRoaXMuX1BpY2tlcikge1xuICAgICAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgICAgIFBpY2tlcjoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgICAgICAgICAgICAgIGNsaXBwaW5nOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBhbHdheXNTY3JvbGw6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkQ2hhbmdlOiBcIl91cGRhdGVBcnJvd3NBbHBoYVwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9QaWNrZXIucGF0Y2goe1xuICAgICAgICAgICAgdmlzaWJsZTogIXRoaXMuX2NvbGxhcHNlLFxuICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5kZXNjcmlwdGlvblRleHRTdHlsZS5saW5lSGVpZ2h0LFxuICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgIGl0ZW1zOiB0aGlzLm9wdGlvbnMubWFwKChvcHRpb24gPT4gKHtcbiAgICAgICAgICAgICAgICB0eXBlOiBNYXJxdWVlLFxuICAgICAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuZGVzY3JpcHRpb25UZXh0U3R5bGUubGluZUhlaWdodCxcbiAgICAgICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgICAgIGNlbnRlckFsaWduOiB0aGlzLl9pc0ZvY3VzZWRNb2RlLFxuICAgICAgICAgICAgICAgIHRpdGxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuZGVzY3JpcHRpb25UZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0OiBvcHRpb25cbiA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dXJuO1xuICAgICAgICBpZiAodHlwZW9mIHRoaXMuY29udGVudCA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBmbGV4OiB7XG4gICAgICAgICAgICAgICAgICAgIGRpcmVjdGlvbjogXCJjb2x1bW5cIlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgU2Nyb2xsYWJsZVRleHQ6IHtcbiAgICAgICAgICAgICAgICAgICAgaDogMCxcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fY29udGVudFdpZHRoLFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB0aGlzLmNvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50ZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX2NvbnRlbnRXaWR0aFxuICAgICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3Njcm9sbENvbnRhaW5lckxvYWRlZFwiXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIG9uQWZ0ZXJVcGRhdGU6IHRoaXMuX2FmdGVyVGV4dEJveFVwZGF0ZS5iaW5kKHRoaXMpXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheSh0aGlzLmNvbnRlbnQpKSB7XG4gICAgICAgICAgICB2YXIgY29udGVudCA9IHt9O1xuICAgICAgICAgICAgdGhpcy5jb250ZW50LmZvckVhY2goKChpdGVtLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgICAgIHZhciBpZCA9IFwiU2Nyb2xsVGV4dFwiLmNvbmNhdChpbmRleCk7XG4gICAgICAgICAgICAgICAgY29udGVudFtpZF0gPSBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fY29udGVudFdpZHRoXG4gICAgICAgICAgICAgICAgfSwgaXRlbSk7XG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0udGV4dCkge1xuICAgICAgICAgICAgICAgICAgICBjb250ZW50W2lkXSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBpdGVtLnRleHQsXG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwgaXRlbS5zdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9jb250ZW50V2lkdGhcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG9uQWZ0ZXJVcGRhdGU6IHRoaXMuX2FmdGVyVGV4dEJveFVwZGF0ZS5iaW5kKHRoaXM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cbiAgICAgICAgICAgICAgICBzbW9vdGg6IHtcbiAgICAgICAgICAgICAgICAgICAgeTogWyBjYW5TY3JvbGxCeVN0ZXBMZW5ndGggPyB0YXJnZXRZIDogMCwgdGhpcy5fc2Nyb2xsQW5pbWF0aW9uIF1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHZhciBpc1Njcm9sbGFibGUgPSB0aGlzLl9zY3JvbGxDb250YWluZXJZICsgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLmZpbmFsSCA+IHRoaXMucmVuZGVySGVpZ2h0O1xuICAgICAgICAgICAgaWYgKGlzU2Nyb2xsYWJsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2F1dG9TY3JvbGxDb21wbGV0ZSA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX3Njcm9sbENvbnRhaW5lclkgPj0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycyhcIiRzY3JvbGxDaGFuZ2VkXCIsIFwiZW5kVXBcIiwgdGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5faXNFbmRDb250ZW50VmlzaWJsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2lzRW5kQ29udGVudFZpc2libGUgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVGYWRlQ29udGFpbmVyKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnNpZ25hbChcIm9uVXBBdFRvcFwiKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICByZXNldFNjcm9sbCgpIHtcbiAgICAgICAgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLnkgPSAwO1xuICAgICAgICB0aGlzLl9TbGlkZXIudmFsdWUgPSAwO1xuICAgICAgICB0aGlzLl9TY3JvbGxDb250YWluZXIud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YUJvdW5kc1kgPSB0aGlzLnN0eWxlLm1heE9mZnNldFk7XG4gICAgICAgIHZhciBleHRyYUJvdW5kc1ggPSB0aGlzLnN0eWxlLm1heE9mZnNldFg7XG4gICAgICAgIHZhciByYWRpdXMgPSBnZXRNYXhSb3VuZFJhZGl1cyh0aGlzLnN0eWxlLnJhZGl1cywgdGhpcy53LCB0aGlzLmgpO1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIEZyYW1lOiB7XG4gICAgICAgICAgICAgICAgdzogdGhpcy53ICsgc2hhZG93U2l6ZSAqIDIgKyBleHRyYUJvdW5kc1gsXG4gICAgICAgICAgICAgICAgaDogdGhpcy5oICsgc2hhZG93U2l6ZSAqIDIgKyBleHRyYUJvdW5kc1ksXG4gICAgICAgICAgICAgICAgeDogKHRoaXMudyArIGV4dHJhQm91bmRzWCkgLyAyLFxuICAgICAgICAgICAgICAgIHk6ICh0aGlzLmggKyBleHRyYUJvdW5kc1kpIC8gMixcbiAgICAgICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICAgICAgcnR0OiB0aGlzLm1hc2tTaGFkb3csXG4gICAgICAgICAgICAgICAgc2hhZGVyOiB0aGlzLm1hc2tTaGFkb3cgPyB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IGxuZy5zaGFkZXJzLkhvbGUsXG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMudyAtIGhvbGVwdW5jaEVycm9yLFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLmggLSBob2xlcHVuY2hFcnJvcixcbiAgICAgICAgICAgICAgICAgICAgeDogc2hhZG93U2l6ZSArIGhvbGVwdW5jaEVycm9yIC8gMixcbiAgICAgICAgICAgICAgICAgICAgeTogc2hhZG93U2l6ZSArIGhvbGVwdW5jaEVycm9yIC8gMixcbiAgICAgICAgICAgICAgICAgICAgcmFkaXVzOiByYWRpdXNcbiAgICAgICAgICAgICAgICB9IDogdW5kZWZpbmVkLFxuICAgIC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jaGVyIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiQ29udGVudFN3aXRjaGVyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJzZWxlY3RlZEluZGV4XCIgXTtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB0aGlzLl9zZWxlY3RlZEluZGV4ID0gMDtcbiAgICAgICAgdGhpcy5fY29udGVudEl0ZW1zID0gW107XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHN1cGVyLl91cGRhdGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlU2VsZWN0ZWQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZVNlbGVjdGVkKCkge1xuICAgICAgICBpZiAodGhpcy5fcHJldmVTZWxlY3RlZEluZGV4ICE9PSB0aGlzLnNlbGVjdGVkSW5kZXgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9wcmV2ZVNlbGVjdGVkSW5kZXggIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIHZhciBwcmV2Q29udGVudCA9IHRoaXMudGFnKFwiQ29udGVudFwiLmNvbmNhdCh0aGlzLl9wcmV2ZVNlbGVjdGVkSW5kZXgpKTtcbiAgICAgICAgICAgICAgICBwcmV2Q29udGVudC5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiAwXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5faGFzQ29udGVudCkge1xuICAgICAgICAgICAgICAgICAgICBwcmV2Q29udGVudC5fZ2V0VHJhbnNpdGlvbihcImFscGhhXCIpLm9uY2UoXCJmaW5pc2hcIiwgKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZhZGVJbkNvbnRlbnQoKTtcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5zZWxlY3RlZEluZGV4ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmFkZUluQ29udGVudCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5faGFzQ29udGVudCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2ZhZGVJbkNvbnRlbnQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX3ByZXZlU2VsZWN0ZWRJbmRleCA9IHRoaXMuc2VsZWN0ZWRJbmRleDtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfZmFkZUluQ29udGVudCgpIHtcbiAgICAgICAgdGhpcy5fc2VsZWN0ZWRDb250ZW50LnNtb290aCA9IHtcbiAgICAgICAgICAgIGFscGhhOiAxXG4gICAgICAgIH07XG4gICAgICAgIHRoaXMuX3NlbGVjdGVkQ29udGVudC5fZ2V0VHJhbnNpdGlvbihcImFscGhhXCIpLm9uY2UoXCJmaW5pc2hcIiwgKCgpID0+IHtcbiAgICAgICAgICAgIHRoaXMuaCA9IHRoaXMuX3NlbGVjdGVkQ29udGVudC5oO1xuICAgICAgICAgICAgdGhpcy5zaWduYWwoXCJjb250ZW50SGVpZ2h0Q2hhbmdlXCIsIHRoaXMuaCk7XG4gICAgICAgIH0pKTtcbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnQoKSB7XG4gICAgICAgIHZhciBhbGxDb250ZW50ID0gdGhpcy5jb250ZW50SXRlbXMucmVkdWNlKCgoYWNjLCBpdGVtLCBpZHgpID0+IHtcbiAgICAgICAgICAgIHZhciBjb21wb25lbnQ7XG4gICAgICAgICAgICB2YXIgdGFnTmFtZSA9IFwiQ29udGVudFwiLmNvbmNhdChpZHgpO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBpdGVtID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICB2YXIgY29tcG9uZW50TG9hZGVyID0gaXRlbSgpO1xuICAgICAgICAgICAgICAgIGlmIChjb21wb25lbnRMb2FkZXIudGhlbikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkQXN5bmNDb21wb25lbnQoY29tcG9uZW50TG9hZGVyLCBpZHgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudCA9IGNvbXBvbmVudExvYWRlcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbXBvbmVudCA9IGl0ZW07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY29tcG9uZW50KSB7XG4gICAgICAgICAgICAgICAgYWNjW3RhZ05hbWVdID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBjb21wb25lbnQpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBhbHBoYTogMFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgfSksIHt9KTtcbiAgICAgICAgdGhpcy5wYXRjaChhbGxDb250ZW50KTtcbiAgICB9XG4gICAgX2xvYWRBc3luY0NvbXBvbmVudChjb21wb25lbnRMb2FkZXIsIGlkeCkge1xuICAgICAgICBjb21wb25lbnRMb2FkZXIudGhlbigoY29tcG9uZW50ID0+IHtcbiAgICAgICAgICAgIHZhciB0YWdOYW1lID0gXCJDb250ZW50XCIuY29uY2F0KGlkeCk7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBbdGFnTmFtZV06IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgY29tcG9uZW50KSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IDBcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pKTtcbiAgICB9XG4gICAgc2V0IGNvbnRlbnRJdGVtcyhjb250ZW50SXRlbXMpIHtcbiAgICAgICAgaWYgKCFzdHJpbmdpZnlDb21wYXJlKGNvbnRlbnRJdGVtcywgdGhpcy5fY29udGVudEl0ZW1zKSkge1xuICAgICAgICAgICAgdGhpcy5fY29udGVudEl0ZW1zID0gY29udGVudEl0ZW1zO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlQ29udGVudCgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGdldCBjb250ZW50SXRlbXMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50SXRlbXM7XG4gICAgfVxuICAgIGdldCBfaGFzQ29udGVudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NlbGVjdGVkQ29udGVudCAmJiB0aGlzLl9zZWxlY3RlZENvbnRlbnQuY2hpbGRyZW4ubGVuZ3RoID4gMDtcbiAgICB9XG4gICAgZ2V0IF9zZWxlY3RlZENvbnRlbnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnRhZyhcIkNvbnRlbnRcIi5jb25jYXQodGhpcy5zZWxlY3RlZEluZGV4KSk7XG4gICAgfVxuICAgIF9nZXRGb2N1c2VkKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzQ29udGVudCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3NlbGVjdGVkQ29udGVudDtcbiAgICAgICAgfVxuICAgIH1cbn1cblxudmFyIGJhc2UkNCA9IHRoZW1lID0+ICh7XG4gICAgdGFiU3BhY2luZzogdGhlbWUuc3BhY2VyLmxnLFxuICAgIHRhYnNNYXJnaW5Cb3R0b206IHRoZW1lLnNwYWNlci54eGxcbn0pO1xuXG52YXIgc3R5bGVzJDQgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSQ0XG59KTtcblxuY2xhc3MgVGFiQmFyIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgVGFiczoge1xuICAgICAgICAgICAgICAgIHR5cGU6IFJvdyxcbiAgICAgICAgICAgICAgICBhdXRvUmVzaXplSGVpZ2h0OiB0cnVlLFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZWN0ZWRDaGFuZ2U6IFwiX3NlbGVjdGVkVGFiQ2hhbmdlXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgVGFiQ29udGVudDoge1xuICAgICAgICAgICAgICAgIHR5cGU6IENvbnRlbnRTd2l0Y2hlcixcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnRIZWlnaHRDaGFuZ2U6IFwiX3VwZGF0ZVRhYkJhckhlaWdodFwiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyQ0O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiVGFiQmFyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJhbHBoYVNlbGVjdGVkVGFiXCIsIFwiY29sbGFwc2VcIiwgXCJyZXNldFwiLCBcInRhYnNcIiwgXCJyZXRhaW5TZWxlY3Rpb25cIiwgLi4uUm93LnByb3BlcnRpZXMgXTtcbiAgICB9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ICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0YWIubW9kZSA9IGlzU2VsZWN0ZWRUYWIgPyBcInNlbGVjdGVkXCIgOiBcInVuZm9jdXNlZFwiO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSkpO1xuICAgICAgICBpZiAodGhpcy5hbHBoYVNlbGVjdGVkVGFiKSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVUYWJBbHBoYXMoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlVGFiQWxwaGFzKCkge1xuICAgICAgICBpZiAodGhpcy5faXNUYWJzRm9jdXNlZCkge1xuICAgICAgICAgICAgdGhpcy5fVGFicy5pdGVtcy5mb3JFYWNoKCh0YWIgPT4ge1xuICAgICAgICAgICAgICAgIHRhYi5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiAxXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9UYWJzLml0ZW1zLmZvckVhY2goKHRhYiA9PiB7XG4gICAgICAgICAgICAgICAgdGFiLnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IHRhYiA9PT0gdGhpcy5fVGFicy5zZWxlY3RlZCA/IDEgOiAuM1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVUYWJDb250ZW50KCkge1xuICAgICAgICB2YXIgbWFyZ2luID0gdGhpcy5zdHlsZS50YWJzTWFyZ2luQm90dG9tO1xuICAgICAgICB0aGlzLl9UYWJDb250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgIHk6IHRoaXMuX1RhYnMuaCArIG1hcmdpbixcbiAgICAgICAgICAgIGNvbnRlbnRJdGVtczogdGhpcy5fdGFiQ29udGVudCxcbiA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ic0ZvY3VzZWQgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGFicygpO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGFiQmFySGVpZ2h0KCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmVzZXRUYWJzKCkge1xuICAgICAgICB0aGlzLl9UYWJzLnNlbGVjdGVkSW5kZXggPSAwO1xuICAgIH1cbiAgICBfaGFuZGxlRG93bigpIHtcbiAgICAgICAgaWYgKHRoaXMuX2lzVGFic0ZvY3VzZWQgJiYgdGhpcy5fVGFiQ29udGVudC5faGFzQ29udGVudCkge1xuICAgICAgICAgICAgdGhpcy5faXNUYWJzRm9jdXNlZCA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGFicygpO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGFiQmFySGVpZ2h0KCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgICBfaGFuZGxlVXAoKSB7XG4gICAgICAgIHRoaXMuc2VsZWN0VGFicygpO1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIF9zZXRUYWJzKHRhYnMpIHtcbiAgICAgICAgdGhpcy5fdGFiQ29udGVudCA9IFtdO1xuICAgICAgICB0aGlzLl90YWJDb250ZW50ID0gdGFicy5tYXAoKHRhYiA9PiB0YWIudGFiQ29udGVudCB8fCB7fSkpO1xuICAgICAgICB0aGlzLl9UYWJzLml0ZW1zID0gdGFicztcbiAgICAgICAgcmV0dXJuIHRhYnM7XG4gICAgfVxuICAgIF9nZXRUYWJzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fVGFicy5pdGVtcztcbiAgICB9XG4gICAgZ2V0IHNlbGVjdGVkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fVGFicy5zZWxlY3RlZDtcbiAgICB9XG4gICAgZ2V0IHNlbGVjdGVkSW5kZXgoKSB7XG4gICAgICAgIH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YWQoX29iamVjdFNwcmVhZCh7fSwgdGhlbWUudHlwb2dyYXBoeS5oZWFkbGluZTMpLCB7fSwge1xuICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgfSksXG4gICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5maWxsVHJhbnNwYXJlbnQsXG4gICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxufSk7XG5cbnZhciBtb2RlID0gdGhlbWUgPT4gKHtcbiAgICBmb2N1c2VkOiB7XG4gICAgICAgIGJhY2tncm91bmRDb2xvcjogdGhlbWUuY29sb3IuaW50ZXJhY3RpdmVOZXV0cmFsRm9jdXMsXG4gICAgICAgIGNvbnRlbnRDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2UsXG4gICAgICAgIHRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVxuICAgICAgICB9XG4gICAgfSxcbiAgICBzZWxlY3RlZDoge1xuICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IHRoZW1lLmNvbG9yLmludGVyYWN0aXZlTmV1dHJhbEZvY3VzU29mdCxcbiAgICAgICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbCxcbiAgICAgICAgdGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH1cbiAgICB9LFxuICAgIGRpc2FibGVkOiB7XG4gICAgICAgIGJhY2tncm91bmRDb2xvcjogdGhlbWUuY29sb3IuZmlsbFRyYW5zcGFyZW50LFxuICAgICAgICBjb250ZW50Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsRGlzYWJsZWQsXG4gICAgICAgIHRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHRvbmUkMiA9IHRoZW1lID0+ICh7XG4gICAgbmV1dHJhbDoge30sXG4gICAgaW52ZXJzZToge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbCxcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGNvbnRlbnRDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWwsXG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyQzID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkMyxcbiAgICBtb2RlOiBtb2RlLFxuICAgIHRvbmU6IHRvbmUkMlxufSk7XG5cbmNsYXNzIFRhYiBleHRlbmRzIFN1cmZhY2Uge1xuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHN1cGVyLl90ZW1wbGF0ZSgpKSwge30sIHtcbiAgICAgICAgICAgIENvbnRlbnQ6IHtcbiAgICAgICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICAgICAgeDogdyA9PiB3IC8gMixcbiAgICAgICAgICAgICAgICB5OiBoID0+IGggLyAyLFxuICAgICAgICAgICAgICAgIFRleHQ6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX29uVGV4dEJveENoYW5nZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkMztcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIlRhYlwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiaWNvblwiLCBcInRpdGxlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCBcIkNvbnRlbnRcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJJY29uXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnQuSWNvblwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVGV4dFwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlRleHRcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgYWxpYXNTdHlsZXMoKSB7XG4gICAgICAgIHJldHVybiBbIHtcbiAgICAgICAgICAgIHByZXY6IFwibm9UaXRsZVBhZGRpbmdYXCIsXG4gICAgICAgICAgICBjdXJyOiBcInBhZGRpbmdYTm9UaXRsZVwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX29uVGV4dEJveENoYW5nZWQoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUNvbnRlbnQoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGFiU2l6ZSgpO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICBzdXBlci5fdXBkYXRlKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUljb24oKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGV4dCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVDb250ZW50KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRhYlNpemUoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUljb24oKSB7XG4gICAgICAgIGlmICghdGhpcy5pY29uKSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBJY29uOiB1bmRlZmluZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBpY29uUGF0Y2ggPSB7XG4gICAgICAgICAgICBpY29uOiB0aGlzLmljb24sXG4gICAgICAgICAgICB3OiB0aGlzLnN0eWxlLmljb25TaXplLFxuICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5pY29uU2l6ZSxcbiAgICAgICAgICAgIHk6IHRoaXMuX0NvbnRlbnQuaCAvIDIsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIGNvbG9yOiB0aGlzLnN0eWxlLmNvbnRlbnRDb2xvclxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICBpZiAodGhpcy50aXRsZSkge1xuICAgICAgICAgICAgaWNvblBhdGNoLnggPSAwO1xuICAgICAgICAgICAgaWNvblBhdGNoLm1vdW50WCA9IDA7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpY29uUGF0Y2gueCA9IHRoaXMuX0NvbnRlbnQudyAvIDI7XG4gICAgICAgICAgICBpY29uUGF0Y2gubW91bnRYID0gLjU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX0ljb24pIHtcbiAgICAgICAgICAgIHRoaXMuX0ljb24ucGF0Y2goaWNvblBhdGNoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIEljb246IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41XG4gICAgICAgICAgICAgICAgfSwgaWNvblBhdGNoKVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVRleHQoKSB7XG4gICAgICAgIHZhciB0ZXh0UGF0Y2ggPSB7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLnRpdGxlLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUudGV4dFN0eWxlXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgeTogdGhpcy5fQ29udGVudC5oIC8gMlxuICAgICAgICB9O1xuICAgICAgICBpZiAodGhpcy5pY29uKSB7XG4gICAgICAgICAgICB0ZXh0UGF0Y2gueCA9IHRoaXMuX2ljb25XICsgdGhpcy5zdHlsZS5pY29uTWFyZ2luUmlnaHQ7XG4gICAgICAgICAgICB0ZXh0UGF0Y2gubW91bnRYID0gMDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRleHRQYXRjaC54ID0gdGhpcy5fQ29udGVudC53IC8gMjtcbiAgICAgICAgICAgIHRleHRQYXRjaC5tb3VudFggPSAuNTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9UZXh0LnBhdGNoKHRleHRQYXRjaCk7XG4gICAgfVxuICAgIF91cGRhdGVDb250ZW50KCkge1xuICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgIHc6IHRoaXMuX2ljb25XICsgKHRoaXMudGl0bGUgPyB0aGlzLnN0eWxlLmljb25NYXJnaW5SaWdodCA6IDApICsgdGhpcy5fdGV4dFcsXG4gICAgICAgICAgICBoOiBNYXRoLm1heCh0aGlzLl9pY29uSCwgdGhpcy5fVGV4dC5oKVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZVRhYlNpemUoKSB7XG4gICAgICAgIGlmICh0aGlzLnRpdGxlIHx8IHRoaXMuaWNvbikge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgdzogdGhpcy5fcGFkZGluZ1ggKiAyICsgdGhpcy5fQ29udGVudC53LFxuICAgICAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUucGFkZGluZ1kgKiAyICsgdGhpcy5fQ29udGVudC5oXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIHc6IDAsXG4gICAgICAgICAgICAgICAgaDogMFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgZ2V0IF90ZXh0VygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudGl0bGUgPyB0aGlzLl9UZXh0LncgOiAwO1xuICAgIH1cbiAgICBnZXQgX2ljb25XKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5pY29uICYmIHRoaXMuX0ljb24gIT09IHVuZGVmaW5lZCA/IHRoaXMuX0ljb24udyA6IDA7XG4gICAgfVxuICAgIGdldCBfaWNvbkgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmljb24gJiYgdGhpcy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Db2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWxEaXNhYmxlZCxcbiAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IHRoZW1lLmNvbG9yLmZpbGxJbnZlcnNlRGlzYWJsZWQsXG4gICAgICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yQ2hlY2tlZDogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWxEaXNhYmxlZCxcbiAgICAgICAgICAgICAgICBrbm9iQ29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsRGlzYWJsZWQsXG4gICAgICAgICAgICAgICAga25vYkNvbG9yQ2hlY2tlZDogdGhlbWUuY29sb3IuZmlsbEludmVyc2VEaXNhYmxlZFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkMiA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJDIsXG4gICAgdG9uZTogdG9uZSQxXG59KTtcblxuY2xhc3MgVG9nZ2xlIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiVG9nZ2xlXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJDI7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBDb250YWluZXI6IHtcbiAgICAgICAgICAgICAgICBTdHJva2U6IHt9LFxuICAgICAgICAgICAgICAgIEtub2I6IHt9XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJDb250YWluZXJcIiwge1xuICAgICAgICAgICAg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Y2tlZCAhPT0gdGhpcy5fY2hlY2tlZDtcbiAgICAgICAgcmV0dXJuIGNoZWNrZWQ7XG4gICAgfVxuICAgIHRvZ2dsZSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgdGhpcy5jaGVja2VkID0gIXRoaXMuY2hlY2tlZDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcztcbiAgICB9XG4gICAgX2hhbmRsZUVudGVyKCkge1xuICAgICAgICBpZiAodHlwZW9mIHRoaXMub25FbnRlciA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5vbkVudGVyKHRoaXMpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy50b2dnbGUoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5vdW5jZSA9IGFubm91bmNlO1xuICAgIH1cbiAgICBnZXQgYW5ub3VuY2UoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZSB8fCAodGhpcy5jaGVja2VkID8gXCJDaGVja2VkXCIgOiBcIlVuY2hlY2tlZFwiKTtcbiAgICB9XG59XG5cbnZhciBiYXNlJDEgPSB0aGVtZSA9PiB7XG4gICAgdmFyIGtub2JTaXplID0gdGhlbWUuc3BhY2VyLmxnO1xuICAgIHZhciBrbm9iUGFkZGluZyA9IHRoZW1lLnNwYWNlci54eHM7XG4gICAgdmFyIHN0cm9rZVdpZHRoID0gdGhlbWUuc3Ryb2tlLnNtO1xuICAgIHJldHVybiB7XG4gICAgICAgIGhlaWdodDoga25vYlNpemUgKyAoa25vYlBhZGRpbmcgKyBzdHJva2VXaWR0aCkgKiAyLFxuICAgICAgICBrbm9iV2lkdGg6IGtub2JTaXplLFxuICAgICAgICBrbm9iSGV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XG4gICAgICAgIHJldHVybiBzdHlsZXM7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBhbHBoYTogMCxcbiAgICAgICAgICAgIHNjYWxlOiAuNSxcbiAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICB4OiB3ID0+IHcgLyAyLFxuICAgICAgICAgICAgQmFja2dyb3VuZDoge1xuICAgICAgICAgICAgICAgIFRleHQ6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3RleHRMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwidGl0bGVcIiwgXCJkZWxheVZpc2libGVcIiwgXCJ0aW1lVmlzaWJsZVwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJCYWNrZ3JvdW5kXCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVGV4dFwiLFxuICAgICAgICAgICAgcGF0aDogXCJCYWNrZ3JvdW5kLlRleHRcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgYWxpYXNTdHlsZXMoKSB7XG4gICAgICAgIHJldHVybiBbIHtcbiAgICAgICAgICAgIHByZXY6IFwicG9pbnRlckhcIixcbiAgICAgICAgICAgIGN1cnI6IFwicG9pbnRlckhlaWdodFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIHByZXY6IFwicG9pbnRlcldcIixcbiAgICAgICAgICAgIGN1cnI6IFwicG9pbnRlcldpZHRoXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVUZXh0KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUJhY2tncm91bmQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZVRleHQoKSB7XG4gICAgICAgIGlmICh0aGlzLl9UZXh0KSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBjb250ZW50OiB0aGlzLnRpdGxlLFxuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS50ZXh0U3R5bGVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdGV4dExvYWRlZCgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlQmFja2dyb3VuZEhlaWdodCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVUZXh0UG9zaXRpb24oKTtcbiAgICB9XG4gICAgX3VwZGF0ZUJhY2tncm91bmQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgQmFja2dyb3VuZDoge1xuICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQnViYmxlLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLl9CYWNrZ3JvdW5kLncsXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuX0JhY2tncm91bmQuaCxcbiAgICAgICAgICAgICAgICAgICAgcmFkaXVzOiBnZXRNYXhSb3VuZFJhZGl1cyh0aGlzLnN0eWxlLnJhZGl1cywgdGhpcy5fQmFja2dyb3VuZC53IC0gdGhpcy5zdHlsZS5wb2ludGVySGVpZ2h0LCB0aGlzLl9CYWNrZ3JvdW5kLmggLSB0aGlzLnN0eWxlLnBvaW50ZXJIZWlnaHQpLFxuICAgICAgICAgICAgICAgICAgICBwb2ludGVyV2lkdGg6IHRoaXMuc3R5bGUucG9pbnRlcldpZHRoLFxuICAgICAgICAgICAgICAgICAgICBwb2ludGVySGVpZ2h0OiB0aGlzLnN0eWxlLnBvaW50ZXJIZWlnaHQsXG4gICAgICAgICAgICAgICAgICAgIGNvbG9yOiB0aGlzLnN0eWxlLmJhY2tncm91bmRDb2xvclxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVCYWNrZ3JvdW5kSGVpZ2h0KCkge1xuICAgICAgICB2YXIgYmFja2dyb3VuZEggPSB0aGlzLl9UZXh0LmZpbmFsSCArIHRoaXMuc3R5bGUucGFkZGluZ1kgKiAyICsgdGhpcy5zdHlsZS5wb2ludGVySGVpZ2h0O1xuICAgICAgICB2YXIgYmFja2dyb3VuZFcgPSB0aGlzLl9UZXh0LmZpbmFsVyArIHRoaXMuc3R5bGUucGFkZGluZ1ggKiAyO1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIHc6IGJhY2tncm91bmRXLFxuICAgICAgICAgICAgaDogYmFja2dyb3VuZEgsXG4gICAgICAgICAgICBtb3VudFk6IDEsXG4gICAgICAgICAgICB5OiAtdGhpcy5zdHlsZS5tYXJnaW5Cb3R0b20sXG4gICAgICAgICAgICBCYWNrZ3JvdW5kOiB7XG4gICAgICAgICAgICAgICAgdzogYmFja2dyb3VuZFcsXG4gICAgICAgICAgICAgICAgaDogYmFja2dyb3VuZEgsXG4gICAgICAgICAgICAgICAgdGV4dHVyZToge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBCdWJibGUsXG4gICAgICAgICAgICAgICAgICAgIHc6IGJhY2tncm91bmRXLFxuICAgICAgICAgICAgICAgICAgICBoOiBiYWNrZ3JvdW5kSFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVUZXh0UG9zaXRpb24oKSB7XG4gICAgICAgIGlmICh0aGlzLl9UZXh0KSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICAgICAgeDogdGhpcy5fQmFja2dyb3VuZC53IC8gMixcbiAgICAgICAgICAgICAgICB5OiAodGhpcy5fQmFja2dyb3VuZC5oIC0gdGhpcy5zdHlsZS5wb2ludGVySGVpZ2h0KSAvIDJcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9jbGVhclRpbWVycygpIHtcbiAgICAgICAgY2xlYXJUaW1lb3V0KHRoaXMuX2hpZGVUaW1lcik7XG4gICAgICAgIGNsZWFyVGltZW91dCh0aGlzLl9zaG93VGltZXIpO1xuICAgIH1cbiAgICBfdHJhbnNpdGlvbkluKCkge1xuICAgICAgICB2YXIgc21vb3RoID0ge1xuICAgICAgICAgICAgc21vb3RoOiB7XG4gICAgICAgICAgICAgICAgYWxwaGE6IFsgMSwgdGhpcy5zdHlsZS50cmFuc2l0aW9uIF0sXG4gICAgICAgICAgICAgICAgc2NhbGU6IFsgMSwgdGhpcy5zdHlsZS50cmFuc2l0aW9uIF1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgaWYgKHRoaXMuZGVsYXlWaXNpYmxlKSB7XG4gICAgICAgICAgICB0aGlzLl9zaG93VGltZXIgPSBzZXRUaW1lb3V0KCgoKSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIHNtb290aDogc21vb3RoXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KSwgdGhpcy5kZWxheVZpc2libGUpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fc2hvd1RpbWVyID0gdW5kZWZpbmVkO1xuICAgICAgICA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3Rpb24gZ2V0KGtleSkge1xuICAgIGlmIChwb29scy5oYXMoa2V5KSkge1xuICAgICAgICB2YXIgcG9vbCA9IHBvb2xzLmdldChrZXkpO1xuICAgICAgICB2YXIgX2luZGV4ID0gcG9vbC5pbmRleDtcbiAgICAgICAgaWYgKF9pbmRleCA+PSBwb29sLmNvbXBvbmVudHMubGVuZ3RoKSB7XG4gICAgICAgICAgICBfaW5kZXggPSAwO1xuICAgICAgICB9XG4gICAgICAgIHBvb2wuaW5kZXggPSBfaW5kZXggKyAxO1xuICAgICAgICByZXR1cm4gcG9vbC5jb21wb25lbnRzW19pbmRleF07XG4gICAgfVxuICAgIHJldHVybiBmYWxzZTtcbn1cblxuZnVuY3Rpb24gY2xlYXIoKSB7XG4gICAgcG9vbHMuY2xlYXIoKTtcbn1cblxuZnVuY3Rpb24gY3JlYXRlKF9yZWYyNSkge1xuICAgIHZhciB7bmFtZTogbmFtZSwgY29tcG9uZW50OiBjb21wb25lbnQsIHN0YWdlOiBzdGFnZSwgc2l6ZTogc2l6ZSA9IDJ9ID0gX3JlZjI1O1xuICAgIGlmIChwb29scy5oYXMobmFtZSkpIHtcbiAgICAgICAgcmV0dXJuIGdldChuYW1lKTtcbiAgICB9XG4gICAgY29tcG9uZW50ID0gY29tcG9uZW50IHx8IHtcbiAgICAgICAgdHlwZTogbmFtZVxuICAgIH07XG4gICAgdmFyIGNvbXBvbmVudHMgPSBbXTtcbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNpemU7IGkrKykge1xuICAgICAgICBjb21wb25lbnRzLnB1c2goc3RhZ2UuYyhjb21wb25lbnQpKTtcbiAgICB9XG4gICAgcG9vbHMuc2V0KG5hbWUsIHtcbiAgICAgICAgaW5kZXg6IDAsXG4gICAgICAgIGNvbXBvbmVudHM6IGNvbXBvbmVudHNcbiAgICB9KTtcbiAgICByZXR1cm4gZ2V0KG5hbWUpO1xufVxuXG52YXIgaW5kZXgkMiA9IHtcbiAgICBnZXQ6IGdldCxcbiAg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AgICAgICAgICAgdmFyIHBocmFzZSA9IHlpZWxkIFByb21pc2UucmVzb2x2ZShyZW1haW5pbmdQaHJhc2VzLnNoaWZ0KCkpO1xuICAgICAgICAgICAgICAgIGlmICghYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHBocmFzZSA9PT0gXCJzdHJpbmdcIiAmJiBwaHJhc2UuaW5jbHVkZXMoXCJQQVVTRS1cIikpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHBhdXNlID0gcGhyYXNlLnNwbGl0KFwiUEFVU0UtXCIpWzFdICogMWUzO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNOYU4ocGF1c2UpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwYXVzZSA9IDA7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgeWllbGQgZGVsYXkocGF1c2UpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHBocmFzZSA9PT0gXCJzdHJpbmdcIiAmJiBwaHJhc2UubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0b3RhbFJldHJpZXMgPSAzO1xuICAgICAgICAgICAgICAgICAgICB2YXIgcmV0cmllc0xlZnQgPSB0b3RhbFJldHJpZXM7XG4gICAgICAgICAgICAgICAgICAgIHdoaWxlIChhY3RpdmUgJiYgcmV0cmllc0xlZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlpZWxkIHNwZWFrKHBocmFzZSwgdXR0ZXJhbmNlcywgbGFuZyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0cmllc0xlZnQgPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlIGluc3RhbmNlb2YgU3BlZWNoU3ludGhlc2lzRXJyb3JFdmVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZS5lcnJvciA9PT0gXCJuZXR3b3JrXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHJpZXNMZWZ0LS07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJTcGVlY2ggc3ludGhlc2lzIG5ldHdvcmsgZXJyb3IuIFJldHJpZXMgbGVmdDogXCIuY29uY2F0KHJldHJpZXNMZWZ0KSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5aWVsZCBkZWxheSg1MDAgKiAodG90YWxSZXRyaWVzIC0gcmV0cmllc0xlZnQpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlLmVycm9yID09PSBcImNhbmNlbGVkXCIgfHwgZS5lcnJvciA9PT0gXCJpbnRlcnJ1cHRlZFwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXRyaWVzTGVmdCA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJTcGVlY2hTeW50aGVzaXNFcnJvckV2ZW50OiBcIi5jb25jYXQoZS5lcnJvcikpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBwaHJhc2UgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgICAgICB2YXIgc2VyaWVzUmVzdWx0ID0gc3BlYWtTZXJpZXMocGhyYXNlKCksIGxhbmcsIGZhbHNlKTtcbiAgICAgICAgICAgICAgICAgICAgbmVzdGVkU2VyaWVzUmVzdWx0cy5wdXNoKHNlcmllc1Jlc3VsdCk7XG4gICAgICAgICAgICAgICAgICAgIHlpZWxkIHNlcmllc1Jlc3VsdC5zZXJpZXM7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KHBocmFzZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIF9zZXJpZXNSZXN1bHQgPSBzcGVha1NlcmllcyhwaHJhc2UsIGxhbmcsIGZhbHNlKTtcbiAgICAgICAgICAgICAgICAgICAgbmVzdGVkU2VyaWVzUmVzdWx0cy5wdXNoKF9zZXJpZXNSZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICB5aWVsZCBfc2VyaWVzUmVzdWx0LnNlcmllcztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICBhY3RpdmUgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgIH0pKSgpO1xuICAgIHJldHVybiB7XG4gICAgICAgIHNlcmllczogc2VyaWVzQ2hhaW4sXG4gICAgICAgIGdldCBhY3RpdmUoKSB7XG4gICAgICAgICAgICByZXR1cm4gYWN0aXZlO1xuICAgICAgICB9LFxuICAgICAgICBhcHBlbmQ6IHRvU3BlYWsgPT4ge1xuICAgICAgICAgICAgcmVtYWluaW5nUGhyYXNlcy5wdXNoKHRvU3BlYWspO1xuICAgICAgICB9LFxuICAgICAgICBjYW5jZWw6ICgpID0+IHtcbiAgICAgICAgICAgIGlmICghYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAga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VuY2VyT3B0aW9ucy5hYmJyZXZpYXRpb25zQ29uZmlnKSkpIDogdHJhbnNsYXRlQWJicmV2KHRvQW5ub3VuY2UsIGFubm91bmNlck9wdGlvbnMuYWJicmV2aWF0aW9uc0NvbmZpZyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgc3BlZWNoID0gc3BlYWsodG9TcGVhaywgb3B0aW9ucy5sYW5ndWFnZSk7XG4gICAgICAgICAgICBpZiAoc3BlZWNoICYmIHNwZWVjaC5zZXJpZXMpIHtcbiAgICAgICAgICAgICAgICBzcGVlY2guc2VyaWVzLnRoZW4oKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGFnZS5lbWl0KFwiYW5ub3VuY2VFbmRlZFwiKTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgdG9Bbm5vdW5jZVN0ciA9IEFycmF5LmlzQXJyYXkodG9TcGVhaykgPyB0b1NwZWFrLmNvbmNhdCgpLmpvaW4oXCIgXCIpIDogdG9TcGVhaztcbiAgICAgICAgICAgIHZhciB0b0Fubm91bmNlV29yZHMgPSB0b0Fubm91bmNlU3RyLnNwbGl0KFwiIFwiKTtcbiAgICAgICAgICAgIHZhciB0aW1lb3V0RGVsYXkgPSB0b0Fubm91bmNlV29yZHMubGVuZ3RoICogYW5ub3VuY2VyT3B0aW9ucy52b2ljZU91dERlbGF5O1xuICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRoaXMuX2Fubm91bmNlRW5kZWRUaW1lb3V0KTtcbiAgICAgICAgICAgIHRoaXMuX2Fubm91bmNlRW5kZWRUaW1lb3V0ID0gc2V0VGltZW91dCgoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuZW1pdChcImFubm91bmNlVGltZW91dEVuZGVkXCIpO1xuICAgICAgICAgICAgfSksIHRpbWVvdXREZWxheSk7XG4gICAgICAgICAgICByZXR1cm4gc3BlZW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ICB0aGlzLl9kZWJvdW5jZUFubm91bmNlRm9jdXNDaGFuZ2VzKCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fbGFzdEZvY3VzUGF0aCA9IGZvY3VzUGF0aC5zbGljZSgwKTtcbiAgICAgICAgICAgIHRoaXMuZm9jdXNEaWZmSG9vayA9IGZvY3VzRGlmZjtcbiAgICAgICAgICAgIGlmICghdGhpcy5hbm5vdW5jZXJFbmFibGVkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHRvQW5ub3VuY2UgPSBmb2N1c0RpZmYucmVkdWNlKCgoYWNjLCBlbG0pID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoZWxtLmFubm91bmNlKSB7XG4gICAgICAgICAgICAgICAgICAgIGFjYy5wdXNoKFsgZWxtTmFtZShlbG0pLCBcIkFubm91bmNlXCIsIGVsbS5hbm5vdW5jZSBdKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGVsbS50aXRsZSkge1xuICAgICAgICAgICAgICAgICAgICBhY2MucHVzaChbIGVsbU5hbWUoZWxtKSwgXCJUaXRsZVwiLCBlbG0udGl0bGUgfHwgXCJcIiBdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgICAgIH0pLCBbXSk7XG4gICAgICAgICAgICBmb2N1c0RpZmYucmV2ZXJzZSgpLnJlZHVjZSgoKGFjYywgZWxtKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVsbS5hbm5vdW5jZUNvbnRleHQpIHtcbiAgICAgICAgICAgICAgICAgICAgYWNjLnB1c2goWyBlbG1OYW1lKGVsbSksIFwiQ29udGV4dFwiLCBlbG0uYW5ub3VuY2VDb250ZXh0IF0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGFjYy5wdXNoKFsgZWxtTmFtZShlbG0pLCBcIk5vIENvbnRleHRcIiwgXCJcIiBdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgICAgIH0pLCB0b0Fubm91bmNlKTtcbiAgICAgICAgICAgIGlmICh0aGlzLmRlYnVnKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS50YWJsZSh0b0Fubm91bmNlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRvQW5ub3VuY2UgPSB0b0Fubm91bmNlLnJlZHVjZSgoKGFjYywgYSkgPT4ge1xuICAgICAgICAgICAgICAgIHZhciB0eHQgPSBhWzJdO1xuICAgICAgICAgICAgICAgIHR4dCAmJiBhY2MucHVzaCh0eHQpO1xuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwgW10pO1xuICAgICAgICAgICAgaWYgKHRvQW5ub3VuY2UubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgdGhpcy4kYW5ub3VuY2VyQ2FuY2VsKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fY3VycmVudGx5U3BlYWtpbmcgPSB0aGlzLl92b2ljZU91dCh0b0Fubm91bmNlLnJlZHVjZSgoKGFjYywgdmFsKSA9PiBhY2MuY29uY2F0KHZhbCkpLCBbXSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgICRhbm5vdW5jZSh0b0Fubm91bmNlKSB7XG4gICAgICAgICAgICB2YXIge2FwcGVuZDogYXBwZW5kID0gZmFsc2UsIG5vdGlmaWNhdGlvbjogbm90aWZpY2F0aW9uID0gZmFsc2V9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB7fTtcbiAgICAgICAgICAgIGlmICghdG9Bbm5vdW5jZSB8fCAhdG9Bbm5vdW5jZS50cmltKCkubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3VuY2VyRW5hYmxlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2RlYm91bmNlQW5ub3VuY2VGb2N1c0NoYW5nZXMuZmx1c2goKTtcbiAgICAgICAgICAgICAgICBpZiAoYXBwZW5kICYmIHRoaXMuX2N1cnJlbnRseVNwZWFraW5nICYmIHRoaXMuX2N1cnJlbnRseVNwZWFraW5nLmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jdXJyZW50bHlTcGVha2luZy5hcHBlbmQodG9Bbm5vdW5jZSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy4kYW5ub3VuY2VyQ2FuY2VsKCk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2N1cnJlbnRseVNwZWFraW5nID0gdGhpcy5fdm9pY2VPdXQodG9Bbm5vdW5jZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChub3RpZmljYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdm9pY2VPdXREaXNhYmxlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2N1cnJlbnRseVNwZWFraW5nLnNlcmllcy5maW5hbGx5KCgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl92b2ljZU91dERpc2FibGVkID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiRhbm5vdW5jZXJSZWZyZXNoKCk7XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgJGFubm91bmNlckNhbmNlbCgpIHtcbiAgICAgICAgICAgIHRoaXMuX2N1c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ByZXZpb3VzXV0gPSBbIGFycmF5W3ByZXZpb3VzXSwgYXJyYXlbY3VycmVudF0gXTtcbiAgICAgICAgICAgIHN1cGVyLnNlbGVjdGVkSW5kZXggPSBjdXJyZW50O1xuICAgICAgICB9XG4gICAgICAgIF91bmZvY3VzKCkge1xuICAgICAgICAgICAgdGhpcy5pc0VkaXRpbmcgPSBmYWxzZTtcbiAgICAgICAgICAgIHN1cGVyLl91bmZvY3VzKCk7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IHNlbGVjdGVkSW5kZXgoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc2VsZWN0ZWRJbmRleDtcbiAgICAgICAgfVxuICAgICAgICBzZXQgc2VsZWN0ZWRJbmRleChpbmRleCkge1xuICAgICAgICAgICAgdmFyIF90aGlzMTAgPSB0aGlzO1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRWRpdGluZykge1xuICAgICAgICAgICAgICAgIHN1cGVyLnNlbGVjdGVkSW5kZXggPSBpbmRleDtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5zZWxlY3RlZEluZGV4ID49IHRoaXMuaXRlbXMubGVuZ3RoIC0gMSAmJiBpbmRleCA+IHRoaXMuc2VsZWN0ZWRJbmRleCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBjdXJyZW50SXRlbSA9IHRoaXMuc2VsZWN0ZWQ7XG4gICAgICAgICAgICB0aGlzLnByZXZTZWxlY3RlZCA9IGN1cnJlbnRJdGVtO1xuICAgICAgICAgICAgdmFyIG5leHRJdGVtID0gdGhpcy5pdGVtc1tpbmRleF07XG4gICAgICAgICAgICB2YXIgcHJldmlvdXNJbmRleCA9IHRoaXMuc2VsZWN0ZWRJbmRleDtcbiAgICAgICAgICAgIHZhciBvbGRQb3NYID0gY3VycmVudEl0ZW0udHJhbnNpdGlvbihcIn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TEgPSAwO1xuICAgICAgICB4MSA9IHdpZHRoIC0geDA7XG4gICAgfVxuICAgIHJldHVybiB7XG4gICAgICAgIHgwOiB4MCxcbiAgICAgICAgeTA6IHkwLFxuICAgICAgICB4MTogeDEsXG4gICAgICAgIHkxOiB5MVxuICAgIH07XG59O1xuXG5jbGFzcyBMaW5lYXJHcmFkaWVudCBleHRlbmRzIGxuZy5UZXh0dXJlIHtcbiAgICBjb25zdHJ1Y3RvcihzdGFnZSkge1xuICAgICAgICBzdXBlcihzdGFnZSk7XG4gICAgICAgIHRoaXMuX3cgPSAwO1xuICAgICAgICB0aGlzLl9oID0gMDtcbiAgICAgICAgdGhpcy5fc3RlcHMgPSBbXTtcbiAgICAgICAgdGhpcy5fZGVncmVlcyA9IDA7XG4gICAgfVxuICAgIGdldCB3KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdztcbiAgICB9XG4gICAgc2V0IHcodykge1xuICAgICAgICB0aGlzLl93ID0gdztcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgIH1cbiAgICBnZXQgaCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2g7XG4gICAgfVxuICAgIHNldCBoKGgpIHtcbiAgICAgICAgdGhpcy5faCA9IGg7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICB9XG4gICAgZ2V0IHN0ZXBzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc3RlcHM7XG4gICAgfVxuICAgIHNldCBzdGVwcyhzdGVwcykge1xuICAgICAgICB0aGlzLl9zdGVwcyA9IHN0ZXBzO1xuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgfVxuICAgIGdldCBkZWdyZWVzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZGVncmVlcztcbiAgICB9XG4gICAgc2V0IGRlZ3JlZXMoZGVncmVlcykge1xuICAgICAgICB0aGlzLl9kZWdyZWVzID0gZGVncmVlcztcbiAgICAgICAgdGhpcy5fY2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4LCB5ICsgaCAtIHN0cm9rZVJhZGl1c1szXSwgc3Ryb2tlUmFkaXVzWzNdKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVRvKHgsIHkgKyBzdHJva2VSYWRpdXNbMF0pO1xuICAgICAgICAgICAgICAgIGN0eC5hcmNUbyh4LCB5LCB4ICsgc3Ryb2tlUmFkaXVzWzBdLCB5LCBzdHJva2VSYWRpdXNbMF0pO1xuICAgICAgICAgICAgICAgIGN0eC5jbG9zZVBhdGgoKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVdpZHRoID0gc3Ryb2tlV2lkdGg7XG4gICAgICAgICAgICAgICAgY3R4LnN0cm9rZVN0eWxlID0gZ3JhZGllbnQ7XG4gICAgICAgICAgICAgICAgY3R4LnN0cm9rZSgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gZ3JhZGllbnQ7XG4gICAgICAgICAgICAgICAgY3R4LmZpbGxSZWN0KDAsIDAsIHcsIGgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgICAgIHNvdXJjZTogY2FudmFzLFxuICAgICAgICAgICAgICAgIHc6IHcsXG4gICAgICAgICAgICAgICAgaDogaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgfVxufVxuXG5jbGFzcyBDaXJjbGUgZXh0ZW5kcyBsbmcuVGV4dHVyZSB7XG4gICAgY29uc3RydWN0b3Ioc3RhZ2UpIHtcbiAgICAgICAgc3VwZXIoc3RhZ2UpO1xuICAgICAgICB0aGlzLl9jb2xvciA9IFwicmdiKDAsMCwwKVwiO1xuICAgICAgICB0aGlzLl9maWxsID0gdHJ1ZTtcbiAgICAgICAgdGhpcy5fcmFkaXVzID0gMTAwO1xuICAgICAgICB0aGlzLl9zdHJva2UgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5fc3Ryb2tlQ29sb3IgPSBcInJnYigwLDAsM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pO1xuICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHN0cm9rZVdpZHRoO1xuICAgICAgICAgICAgY3R4LnN0cm9rZVN0eWxlID0gc3Ryb2tlQ29sb3I7XG4gICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gY29sb3I7XG4gICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7XG4gICAgICAgICAgICBjdHguYXJjKGRpbWVuc2lvbiwgZGltZW5zaW9uLCByYWRpdXMsIDAsIDIgKiBNYXRoLlBJKTtcbiAgICAgICAgICAgIGlmIChmaWxsKSB7XG4gICAgICAgICAgICAgICAgY3R4LmZpbGwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdHJva2UpIHtcbiAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYihudWxsLCB7XG4gICAgICAgICAgICAgICAgc291cmNlOiBjYW52YXMsXG4gICAgICAgICAgICAgICAgcmFkaXVzOiByYWRpdXNcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgQXJyb3cgZXh0ZW5kcyBsbmcuVGV4dHVyZSB7XG4gICAgY29uc3RydWN0b3Ioc3RhZ2UpIHtcbiAgICAgICAgc3VwZXIoc3RhZ2UpO1xuICAgICAgICB0aGlzLl9jb2xvciA9IFwicmdiKDEzLCAxMywgMTUpXCI7XG4gICAgICAgIHRoaXMuX3cgPSAwO1xuICAgICAgICB0aGlzLl9oID0gMDtcbiAgICAgICAgdGhpcy5fZGlyZWN0aW9uID0gXCJyaWdodFwiO1xuICAgIH1cbiAgICBnZXQgdygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3c7XG4gICAgfVxuICAgIHNldCB3KGwpIHtcbiAgICAgICAgdGhpcy5fdyA9IGw7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICB9XG4gICAgZ2V0IGgoKSB7XG4gICAgICAg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gICAgICAgICBjYW52YXMud2lkdGggPSB3O1xuICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IGg7XG4gICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gY29sb3I7XG4gICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBjdHguZmlsbFN0eWxlO1xuICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IDI7XG4gICAgICAgICAgICBjdHgubGluZUNhcCA9IFwicm91bmRcIjtcbiAgICAgICAgICAgIGN0eC5saW5lSm9pbiA9IFwicm91bmRcIjtcbiAgICAgICAgICAgIHZhciBwID0gY3R4LmxpbmVXaWR0aCAvIDI7XG4gICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7XG4gICAgICAgICAgICBpZiAoZGlyZWN0aW9uID09PSBcInJpZ2h0XCIpIHtcbiAgICAgICAgICAgICAgICBjdHgubW92ZVRvKHAsIHApO1xuICAgICAgICAgICAgICAgIGN0eC5saW5lVG8ocCwgaCAtIHApO1xuICAgICAgICAgICAgICAgIGN0eC5saW5lVG8odyAtIHAsIGggLyAyKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZGlyZWN0aW9uID09PSBcImRvd25cIikge1xuICAgICAgICAgICAgICAgIGN0eC5tb3ZlVG8ocCwgcCk7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh3IC0gcCwgcCk7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh3IC8gMiwgaCAtIHApO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjdHgubW92ZVRvKHAsIGggLyAyKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVRvKHcgLSBwLCBwKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVRvKHcgLSBwLCBoIC0gcCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7XG4gICAgICAgICAgICBjdHguc3Ryb2tlKCk7XG4gICAgICAgICAgICBjdHguZmlsbCgpO1xuICAgICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgICAgIHNvdXJjZTogY2FudmFzLFxuICAgICAgICAgICAgICAgIHc6IHcsXG4gICAgICAgICAgICAgICAgaDogaCxcbiAgICAgICAgICAgICAgICBkaXJlY3Rpb246IGRpcmVjdGlvblxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgfVxufVxuXG5jbGFzcyBMaW5lIGV4dGVuZHMgbG5nLlRleHR1cmUge1xuICAgIGNvbnN0cnVjdG9yKHN0YWdlKSB7XG4gICAgICAgIHN1cGVyKHN0YWdlKTtcbiAgICAgICAgdGhpcy5fdyA9IDA7XG4gICAgICAgIHRoaXMuX2ggPSAwO1xuICAgICAgICB0aGlzLl9yb3VuZGVkID0gZmFsc2U7XG4gICAgfVxuICAgIGdldCB3KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdztcbiAgICB9XG4gICAgc2V0IHcobCkge1xuICAgICAgICB0aGlzLl93ID0gbDtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgIH1cbiAgICBnZXQgaCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2g7XG4gICAgfVxuICAgIHNldCBoKGwpIHtcbiAgICAgICAgdGhpcy5faCA9IGw7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICB9XG4gICAgZ2V0IHJvdW5kZWQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yb3VuZGVkO1xuICAgIH1cbiAgICBzZXQgcm91bmRlZChyb3VuZGVkKSB7XG4gICAgICAgIHRoaXMuX3JvdW5kZWQgPSByb3VuZGVkO1xuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgfVxuICAgIF9nZXRMb29rdXBJZCgpIHtcbiAgICAgICAgcmV0dXJuIFwiX19saW5lX1wiLmNvbmNhdCh0aGlzLl93LCBcInhcIikuY29uY2F0KHRoaXMuX2gpLmNvbmNhdCh0aGlzLl9yb3VuZGVkID8gXCJfcm91bmRlZFwiIDogXCJcIik7XG4gICAgfVxuICAgIF9nZXRTb3VyY2VMb2FkZXIoKSB7XG4gICAgICAgIHZhciB3ID0gdGhpcy5fdztcbiAgICAgICAgdmFyIGggPSB0aGlzLl9oO1xuICAgICAgICB2YXIgcm91bmRlZCA9IHRoaXMuX3JvdW5kZWQ7XG4gICAgICAgIHZhciBjYW52YXMgPSB0aGlzLnN0YWdlLnBsYXRmb3JtLmdldERyYXdpbmdDYW52YXMoKTtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGNiKSB7XG4gICAgICAgICAgICB2YXIgY3R4ID0gY2FudmFzLmdldENvbnRleHQoXCIyZFwiKTtcbiAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IHc7XG4gICAgICAgICAgICBjYW52YXMuaGVpZ2h0ID0gaDtcbiAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBoO1xuICAgICAgICAgICAgaWYgKHJvdW5kZWQpIHtcbiAgICAgICAgICAgICAgICBjdHgubGluZUNhcCA9IFwicm91bmRcIjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IFwid2hpdGVcIjtcbiAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTtcbiAgICAgICAgICAgIGN0eC5tb3ZlVG8ocm91bmRlZCA/IDIgOiAwLCBoIC8gMik7XG4gICAgICAgICAgICBjdHgubGluZVRvKHJvdW5kZWQgPyB3IC0gMiA6IHcsIGggLyAyKTtcbiAgICAgICAgICAgIGN0eC5zdHJva2UoKTtcbiAgICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgICAgICBzb3VyY2U6IGNhbnZhcyxcbiAgICAgICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgICAgIGg6IGgsXG4gICAgICAgICAgICAgICAgcm91bmRlZDogcm91bmRlZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgfVxufVxuXG5j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ICAgIGg6IDE1MCxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgY29sb3I6IDB4ZmY5NDkzOTMsXG4gICAgICAgIGFscGhhOiAwLjUsXG4gICAgICAgIHNoYWRlcjogeyB0eXBlOiBMaWdodG5pbmcuc2hhZGVycy5Sb3VuZGVkUmVjdGFuZ2xlLCByYWRpdXM6IDEwIH0sXG4gICAgICAgIE5yOiB7XG4gICAgICAgICAgdzogdyA9PiB3LFxuICAgICAgICAgIHk6IDI0LFxuICAgICAgICAgIHRleHQ6IHtcbiAgICAgICAgICAgIHRleHQ6ICcnLFxuICAgICAgICAgICAgdGV4dENvbG9yOiAweGZmMzMzMzMzLFxuICAgICAgICAgICAgZm9udFNpemU6IDgwLFxuICAgICAgICAgICAgdGV4dEFsaWduOiAnY2VudGVyJyxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246ICdtaWRkbGUnLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICB9XG4gICAgfVxuXG4gICAgc2V0IGluZGV4KHYpIHtcbiAgICAgIHRoaXMueCA9IHYgKiAoMTIwICsgMjQpXG4gICAgfVxuXG4gICAgc2V0IG5yKHYpIHtcbiAgICAgIHRoaXMuX3RpbWVvdXQgJiYgY2xlYXJUaW1lb3V0KHRoaXMuX3RpbWVvdXQpXG5cbiAgICAgIGlmICh2KSB7XG4gICAgICAgIHRoaXMuc2V0U21vb3RoKCdhbHBoYScsIDEpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLnNldFNtb290aCgnYWxwaGEnLCAwLjUpXG4gICAgICB9XG5cbiAgICAgIHRoaXMudGFnKCdOcicpLnBhdGNoKHtcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIHRleHQ6ICh2ICYmIHYudG9TdHJpbmcoKSkgfHwgJycsXG4gICAgICAgICAgZm9udFNpemU6IHYgPT09ICcqJyA/IDEyMCA6IDgwLFxuICAgICAgICB9LFxuICAgICAgfSlcblxuICAgICAgaWYgKHYgJiYgdiAhPT0gJyonKSB7XG4gICAgICAgIHRoaXMuX3RpbWVvdXQgPSBzZXRUaW1lb3V0KCgpID0+IHtcbiAgICAgICAgICB0aGlzLl90aW1lb3V0ID0gbnVsbFxuICAgICAgICAgIHRoaXMubnIgPSAnKidcbiAgICAgICAgfSwgNzUwKVxuICAgICAgfVxuICAgIH1cbiAgfVxuXG59XG5cbmV4cG9ydCBkZWZhdWx0ICgpID0+IHtcbiAgcmV0dXJuIGNsYXNzIFBpbkRpYWxvZyBleHRlbmRzIExpZ2h0bmluZy5Db21wb25lbnQge1xuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICByZXR1cm4ge1xuICAgICAgICB6SW5kZXg6IDEsXG4gICAgICAgIHc6IHcgPT4gdyxcbiAgICAgICAgaDogaCA9PiBoLFxuICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICBjb2xvcjogMHhkZDAwMDAwMCxcbiAgICAgICAgYWxwaGE6IDAuMDAwMDAxLFxuICAgICAgICBEaWFsb2c6IHtcbiAgICAgICAgICB3OiA2NDgsXG4gICAgICAgICAgaDogMzIwLFxuICAgICAgICAgIHk6IGggPT4gKGggLSAzMjApIC8gMixcbiAgICAgICAgICB4OiB3ID0+ICh3IC0gNjQ4KSAvIDIsXG4gICAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgICBjb2xvcjogMHhkZDMzMzMzMyxcbiAgICAgICAgICBzaGFkZXI6IHsgdHlwZTogTGlnaHRuaW5nLnNoYWRlcnMuUm91bmRlZFJlY3RhbmdsZSwgcmFkaXVzOiAxMCB9LFxuICAgICAgICAgIEluZm86IHtcbiAgICAgICAgICAgIHk6IDI0LFxuICAgICAgICAgICAgeDogNDgsXG4gICAgICAgICAgICB0ZXh0OiB7IHRleHQ6ICdQbGVhc2UgZW50ZXIgeW91ciBQSU4nLCBmb250U2l6ZTogMzIgfSxcbiAgICAgICAgICB9LFxuICAgICAgICAgIE1zZzoge1xuICAgICAgICAgICAgeTogMjYwLFxuICAgICAgICAgICAgeDogNDgsXG4gICAgICAgICAgICB0ZXh0OiB7IHRleHQ6ICcnLCBmb250U2l6ZTogMjgsIHRleHRDb2xvcjogMHhmZmZmZmZmZiB9LFxuICAgICAgICAgIH0sXG4gICAgICAgICAgQ29kZToge1xuICAgICAgICAgICAgeDogNDgsXG4gICAgICAgICAgICB5OiA5NixcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfVxuICAgIH1cblxuICAgIF9pbml0KCkge1xuICAgICAgY29uc3QgY2hpbGRyZW4gPSBbXVxuICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCA0OyBpKyspIHtcbiAgICAgICAgY2hpbGRyZW4ucHVzaCh7XG4gICAgICAgICAgdHlwZTogUGluSW5wdXQoKSxcbiAgICAgICAgICBpbmRleDogaSxcbiAgICAgICAgfSlcbiAgICAgIH1cblxuICAgICAgdGhpcy50YWcoJ0NvZGUnKS5jaGlsZHJlbiA9IGNoaWxkcmVuXG4gICAgfVxuXG4gICAgZ2V0IHBpbigpIHtcbiAgICAgIGlmICghdGhpcy5fcGluKSB0aGlzLl9waW4gPSAnJ1xuICAgICAgcmV0dXJuIHRoaXMuX3BpblxuICAgIH1cblxuICAgIHNldCBwaW4odikge1xuICAgICAgaWYgKHYubGVuZ3RoIDw9IDQpIHtcbiAgICAgICAgY29uc3QgbWFza2VkUGluID0gbmV3IEFycmF5KE1hdGgubWF4KHYubGVuZ3RoIC0gMSwgMCkpLmZpbGwoJyonLCAwLCB2Lmxlbmd0aCAtIDEpXG4gICAgICAgIHYubGVuZ3RoICYmIG1hc2tlZFBpbi5wdXNoKHYubGVuZ3RoID4gdGhpcy5fcGluLmxlbmd0aCA/IHYuc2xpY2UoLTEpIDogJyonKVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDQ7IGkrKykge1xuICAgICAgICAgIHRoaXMudGFnKCdDb2RlJykuY2hpbGRyZW5baV0ubnIgPSBtYXNrZWRQaW5baV0gfHwgJydcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9waW4gPSB2XG4gICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IG1zZygpIHtcbiAgICAgIGlmICghdGhpcy5fbXNnKSB0aGlzLl9tc2cgPSAnJ1xuICAgICAgcmV0dXJuIHRoaXMuX21zZ1xuICAgIH1cblxuICAgIHNldCBtc2codikge1xuICAgICAgdGhpcy5fdGltZW91dCAmJiBjbGVhclRpbWVvdXQodGhpcy5fdGltZW91dClcblxuICAgICAgdGhpcy5fbXNnID0gdlxuICAgICAgaWYgKHRoaXMuX21zZykge1xuICAgICAgICB0aGlzLnRhZygnTXNnJykudGV4dCA9IHRoaXMuX21zZ1xuICAgICAgICB0aGlzLnRhZygnSW5mbycpLnNldFNtb290aCgnYWxwaGEnLCAwLjUpXG4gICAgICAgIHRoaXMudGFnKCdDb2RlJykuc2V0U21vb3RoKCdhbHBoYScsIDAuNSlcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMudGFnKCdNc2cnKS50ZXh0ID0gJydcbiAgICAgICAgdGhpcy50YWcoJ0luZm8nKS5zZXRTbW9vdGgoJ2FscGhhJywgMSlcbiAgICAgICAgdGhpcy50YWcoJ0NvZGUnKS5zZXRTbW9vdGgoJ2FscGhhJywgMSlcbiAgICAgIH1cbiAgICAgIHRoaXMuX3RpbWVvdXQgPSBzZXRUaW1lb3V0KCgpID0+IHtcbiAgICAgICAgdGhpcy5tc2cgPSAnJ1xuICAgICAgfSwgMjAwMClcbiAgICB9XG5cbiAgICBfZmlyc3RBY3RpdmUoKSB7XG4gICAgICB0aGlzLnNldFNtb290aCgnYWxwaGEnLCAxKVxuICAgIH1cblxuICAgIF9oYW5kbGVLZXkoZXZlbnQpIHtcbiAgICAgIGlmICh0aGlzLm1zZykge1xuICAgICAgICB0aGlzLm1zZyA9IGZhbHNlXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBjb25zdCB2YWwgPSBwYXJzZUludChldmVudC5rZXkpXG4gICAgICAgIGlmICh2YWwgPiAtMSkge1xuICAgICAgICAgIHRoaXMucGluICs9IHZhbFxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgX2hhbmRsZUJhY2soKSB7XG4gICAgICBpZiAodGhpcy5tc2cpIHtcbiAgICAgICAgdGhpcy5tc2cgPSBmYWxzZVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMucGluLmxlbmd0aCkge1xuICAgICAgICAgIHRoaXMucGluID0gdGhpcy5waW4uc2xpY2UoMCwgdGhpcy5waW4ubGVuZ3RoIC0gMSlcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBQaW4uaGlkZSgpXG4gICAgICAgICAgdGhpcy5yZXNvbHZlKGZhbHNlKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgX2hhbmRsZUVudGVyKCkge1xuICAgICAgaWYgKHRoaXMubXNnKSB7XG4gICAgICAgIHRoaXMubXNnID0gZmFsc2VcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIFBpbi5zdWJtaXQodGhpcy5waW4pXG4gICAgICAgICAgLnRoZW4odmFsID0+IHtcbiAgICAgICAgICAgIHRoaXMubXNnID0gJ1VubG9ja2luZyAuLi4nXG4gICAgICAgICAgICBzZXRUaW1lb3V0KCgpID0+IHtcbiAgICAgICAgICAgICAgUGluLmhpZGUoKVxuICAgICAgICAgICAgfSwgMTAwMClcbiAgICAgICAgICAgIHRoaXMucmVzb2x2ZSh2YWwpXG4gICAgICAgICAgfSlcbiAgICAgICAgICAuY2F0Y2goZSA9PiB7XG4gICAgICAgICAgICB0aGlzLm1zZyA9IGVcbiAgICAgICAgICAgIHRoaXMucmVqZWN0KGUpXG4gICAgICAgICAgfSlcbiAgICAgIH1cbiAgICB9XG4gIH1cbn1cbiIsIi8qXG4gKiBJZiBub3Qgc3RhdGVkIG90aGVyd2lzZSBpbiB0aGlzIGZpbGUgb3IgdGhpcyBjb21wb25lbnQncyBMSUNFT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soY29udGV4dClcbiAgICAgICAgaWYgKGNvbnRleHQpIHtcbiAgICAgICAgICBzdWJtaXQocGluLCBjb250ZXh0KVxuICAgICAgICAgICAgLnRoZW4ocmVzb2x2ZSlcbiAgICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcmVqZWN0KCdJbmNvcnJlY3QgQ29udGV4dCBwcm92aWRlZCcpXG4gICAgICAgIH1cbiAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgcmVqZWN0KGUpXG4gICAgICB9XG4gICAgfSlcbiAgfSxcbiAgdW5sb2NrZWQoY29udGV4dCkge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgICB0cnkge1xuICAgICAgICBjb250ZXh0ID0gY29udGV4dENoZWNrKGNvbnRleHQpXG4gICAgICAgIGlmIChjb250ZXh0KSB7XG4gICAgICAgICAgY2hlY2soY29udGV4dClcbiAgICAgICAgICAgIC50aGVuKHJlc29sdmUpXG4gICAgICAgICAgICAuY2F0Y2gocmVqZWN0KVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHJlamVjdCgnSW5jb3JyZWN0IENvbnRleHQgcHJvdmlkZWQnKVxuICAgICAgICB9XG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIHJlamVjdChlKVxuICAgICAgfVxuICAgIH0pXG4gIH0sXG4gIGxvY2tlZChjb250ZXh0KSB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIHRyeSB7XG4gICAgICAgIGNvbnRleHQgPSBjb250ZXh0Q2hlY2soY29udGV4dClcbiAgICAgICAgaWYgKGNvbnRleHQpIHtcbiAgICAgICAgICBjaGVjayhjb250ZXh0KVxuICAgICAgICAgICAgLnRoZW4odW5sb2NrZWQgPT4gcmVzb2x2ZSghISF1bmxvY2tlZCkpXG4gICA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luZ2lmeShkYXRhKSA6IG51bGwsXG4gICAgfSlcbiAgICAgIC50aGVuKHJlc3BvbnNlID0+IChyZXNwb25zZS5vayA/IHJlc29sdmUocmVzcG9uc2UuanNvbigpKSA6IHJlamVjdChyZXNwb25zZS5zdGF0dXNUZXh0KSkpXG4gICAgICAuY2F0Y2gocmVqZWN0KVxuICB9KVxufVxuXG5jb25zdCBjc3BSZXF1ZXN0ID0gKHR5cGUsIGRhdGEgPSBudWxsLCBwYXJhbXMgPSB7fSkgPT4ge1xuICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgIGNvbnN0IGVuZHBvaW50ID0gY3NwRW5kcG9pbnRzW3R5cGVdXG5cbiAgICBpZiAoIWVuZHBvaW50KSB7XG4gICAgICByZWplY3QoJ05vIGVuZHBvaW50IGZvdW5kIGZvciBcIicgKyB0eXBlICsgJ1wiIGNhbGwnKVxuICAgIH0gZWxzZSB7XG4gICAgICBpZiAoZW5kcG9pbnQuY2FsbGJhY2sgJiYgdHlwZW9mIGVuZHBvaW50LmNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIGVuZHBvaW50XG4gICAgICAgICAgLmNhbGxiYWNrKGRhdGEsIHBhcmFtcylcbiAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXF1ZXN0KFxuICAgICAgICAgIGNyZWF0ZVVybChlbmRwb2ludC51cmksIGNzcFVybCwgcGFyYW1zKSxcbiAgICAgICAgICBlbmRwb2ludC5tZXRob2QsXG4gICAgICAgICAge1xuICAgICAgICAgICAgLi4uKGVuZHBvaW50LmRhdGEgfHwge30pLFxuICAgICAgICAgICAgLi4uZGF0YSxcbiAgICAgICAgICB9LFxuICAgICAgICAgIGVuZHBvaW50LmhlYWRlcnMgfHwge31cbiAgICAgICAgKVxuICAgICAgICAgIC50aGVuKHJlc29s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XBlID0gJ2luLWFwcCcpIHtcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgUHJvbWlzZS5hbGwoW1xuICAgICAgICBQcm9maWxlLmhvdXNlaG9sZCgpLFxuICAgICAgICBQcm9maWxlLmNvdW50cnlDb2RlKCksXG4gICAgICAgIFByb2ZpbGUub3BlcmF0b3IoKSxcbiAgICAgICAgUHJvZmlsZS5tYWMoKSxcbiAgICAgICAgUHJvZmlsZS51aWQoKSxcbiAgICAgIF0pXG4gICAgICAgIC50aGVuKChbaG91c2Vob2xkLCBjb3VudHJ5LCBvcGVyYXRvciwgbWFjLCB1aWRdKSA9PiB7XG4gICAgICAgICAgYmlsbGluZ1JlcXVlc3QoJy8nLCB7XG4gICAgICAgICAgICBwdXJjaGFzZTogc2lnbmF0dXJlLFxuICAgICAgICAgICAgaWRlbnRpZmllcjogU2V0dGluZ3MuZ2V0KCdhcHAnLCAnaWQnKSxcbiAgICAgICAgICAgIG5hbWU6IFNldHRpbmdzLmdldCgnYXBwJywgJ2lkJyksXG4gICAgICAgICAgICBob3VzZWhvbGQsXG4gICAgICAgICAgICBjb3VudHJ5LFxuICAgICAgICAgICAgb3BlcmF0b3IsXG4gICAgICAgICAgICBtYWMsXG4gICAgICAgICAgICB1aWQsXG4gICAgICAgICAgICB0eXBlLFxuICAgICAgICAgIH0pXG4gICAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICAgICAgfSlcbiAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICB9KVxuICB9LFxuICBjb25maXJtKHRyYW5zYWN0aW9uSWQpIHtcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgYmlsbGluZ1JlcXVlc3QoJy9jb25maXJtJywge1xuICAgICAgICB0cmFuc2FjdGlvbklkLFxuICAgICAgfSlcbiAgICAgICAgL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ICAgICB9IGVsc2Uge1xuICAgICAgICByZWplY3QoJ05vIGNoYW5uZWwgZm91bmQnKVxuICAgICAgfVxuICAgIH0pXG4gIH0sXG4gIGdldFByb2dyYW0oKSB7XG4gICAgaWYgKCFjdXJyZW50Q2hhbm5lbCkgY3VycmVudENoYW5uZWwgPSByYW5kb21DaGFubmVsKClcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgY3VycmVudENoYW5uZWwucHJvZ3JhbSA/IHJlc29sdmUoY3VycmVudENoYW5uZWwucHJvZ3JhbSkgOiByZWplY3QoJ05vIHByb2dyYW0gZm91bmQnKVxuICAgIH0pXG4gIH0sXG4gIHNldENoYW5uZWwobnVtYmVyKSB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIGlmIChudW1iZXIpIHtcbiAgICAgICAgY29uc3QgbmV3Q2hhbm5lbCA9IGNoYW5uZWxzKCkuZmluZChjID0+IGMubnVtYmVyID09PSBudW1iZXIpXG4gICAgICAgIGlmIChuZXdDaGFubmVsKSB7XG4gICAgICAgICAgY3VycmVudENoYW5uZWwgPSBuZXdDaGFubmVsXG4gICAgICAgICAgY29uc3QgY2hhbm5lbCA9IHsgLi4uY3VycmVudENoYW5uZWwgfVxuICAgICAgICAgIGRlbGV0ZSBjaGFubmVsLnByb2dyYW1cbiAgICAgICAgICBlbWl0KCdjaGFubmVsQ2hhbmdlJywgY2hhbm5lbClcbiAgICAgICAgICByZXNvbHZlKGNoYW5uZWwpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcmVqZWN0KCdDaGFubmVsIG5vdCBmb3VuZCcpXG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJlamVjdCgnTm8gY2hhbm5lbCBudW1iZXIgc3VwcGxpZWQnKVxuICAgICAgfVxuICAgIH0pXG4gIH0sXG59XG5cbmV4cG9ydC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1xuICAgICAgICByZXR1cm4gcGQodGhpcykuZXZlbnRUYXJnZXRcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogVGhlIHRhcmdldCBvZiB0aGlzIGV2ZW50LlxuICAgICAqIEB0eXBlIHtFdmVudFRhcmdldH1cbiAgICAgKi9cbiAgICBnZXQgY3VycmVudFRhcmdldCgpIHtcbiAgICAgICAgcmV0dXJuIHBkKHRoaXMpLmN1cnJlbnRUYXJnZXRcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQHJldHVybnMge0V2ZW50VGFyZ2V0W119IFRoZSBjb21wb3NlZCBwYXRoIG9mIHRoaXMgZXZlbnQuXG4gICAgICovXG4gICAgY29tcG9zZWRQYXRoKCkge1xuICAgICAgICBjb25zdCBjdXJyZW50VGFyZ2V0ID0gcGQodGhpcykuY3VycmVudFRhcmdldDtcbiAgICAgICAgaWYgKGN1cnJlbnRUYXJnZXQgPT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuIFtdXG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIFtjdXJyZW50VGFyZ2V0XVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBDb25zdGFudCBvZiBOT05FLlxuICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICovXG4gICAgZ2V0IE5PTkUoKSB7XG4gICAgICAgIHJldHVybiAwXG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIENvbnN0YW50IG9mIENBUFRVUklOR19QSEFTRS5cbiAgICAgKiBAdHlwZSB7bnVtYmVyfVxuICAgICAqL1xuICAgIGdldCBDQVBUVVJJTkdfUEhBU0UoKSB7XG4gICAgICAgIHJldHVybiAxXG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIENvbnN0YW50IG9mIEFUX1RBUkdFVC5cbiAgICAgKiBAdHlwZSB7bnVtYmVyfVxuICAgICAqL1xuICAgIGdldCBBVF9UQVJHRVQoKSB7XG4gICAgICAgIHJldHVybiAyXG4gICAgfSxcblxuIC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RlbmVyID0gbnVsbDsgLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1wYXJhbS1yZWFzc2lnblxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uc3QgbGlzdGVuZXJzID0gZ2V0TGlzdGVuZXJzKHRoaXMpO1xuXG4gICAgICAgICAgICAvLyBUcmF2ZXJzZSB0byB0aGUgdGFpbCB3aGlsZSByZW1vdmluZyBvbGQgdmFsdWUuXG4gICAgICAgICAgICBsZXQgcHJldiA9IG51bGw7XG4gICAgICAgICAgICBsZXQgbm9kZSA9IGxpc3RlbmVycy5nZXQoZXZlbnROYW1lKTtcbiAgICAgICAgICAgIHdoaWxlIChub2RlICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICBpZiAobm9kZS5saXN0ZW5lclR5cGUgPT09IEFUVFJJQlVURSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBSZW1vdmUgb2xkIHZhbHVlLlxuICAgICAgICAgICAgICAgICAgICBpZiAocHJldiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5uZXh0ID0gbm9kZS5uZXh0O1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGUubmV4dCAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLnNldChldmVudE5hbWUsIG5vZGUubmV4dCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcnMuZGVsZXRlKGV2ZW50TmFtZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBwcmV2ID0gbm9kZTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBub2RlID0gbm9kZS5uZXh0O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBBZGQgbmV3IHZhbHVlLlxuICAgICAgICAgICAgaWYgKGxpc3RlbmVyICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbmV3Tm9kZSA9IHtcbiAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXIsXG4gICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyVHlwZTogQVRUUklCVVRFLFxuICAgICAgICAgICAgICAgICAgICBwYXNzaXZlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgb25jZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIG5leHQ6IG51bGwsXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAocHJldiA9PT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcnMuc2V0KGV2ZW50TmFtZSwgbmV3Tm9kZSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcHJldi5uZXh0ID0gbmV3Tm9kZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSxcbiAgICB9XG59XG5cbi8qKlxuICogRGVmaW5lIGFuIGV2ZW50IGF0dHJpYnV0ZSAoZS5nLiBgZXZlbnRUYXJnZXQub25jbGlja2ApLlxuICogQHBhcmFtIHtPYmplY3R9IGV2ZW50VGFyZ2V0UHJvdG90eXBlIFRoZSBldmVudCB0YXJnZXQgcHJvdG90eXBlIHRvIGRlZmluZSBhbiBldmVudCBhdHRyYml0ZS5cbiAqIEBwYXJhbSB7c3RyaW5nfSBldmVudE5hbWUgVGhlIGV2ZW50IG5hbWUgdG8gZGVmaW5lLlxuICogQHJldHVybnMge3ZvaWR9XG4gKi9cbmZ1bmN0aW9uIGRlZmluZUV2ZW50QXR0cmlidXRlKGV2ZW50VGFyZ2V0UHJvdG90eXBlLCBldmVudE5hbWUp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10gVGhlIG9wdGlvbnMgZm9yIHRoaXMgbGlzdGVuZXIuXG4gICAgICogQHJldHVybnMge3ZvaWR9XG4gICAgICovXG4gICAgcmVtb3ZlRXZlbnRMaXN0ZW5lcihldmVudE5hbWUsIGxpc3RlbmVyLCBvcHRpb25zKSB7XG4gICAgICAgIGlmIChsaXN0ZW5lciA9PSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm5cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IGxpc3RlbmVycyA9IGdldExpc3RlbmVycyh0aGlzKTtcbiAgICAgICAgY29uc3QgY2FwdHVyZSA9IGlzT2JqZWN0KG9wdGlvbnMpXG4gICAgICAgICAgICA/IEJvb2xlYW4ob3B0aW9ucy5jYXB0dXJlKVxuICAgICAgICAgICAgOiBCb29sZWFuKG9wdGlvbnMpO1xuICAgICAgICBjb25zdCBsaXN0ZW5lclR5cGUgPSBjYXB0dXJlID8gQ0FQVFVSRSA6IEJVQkJMRTtcblxuICAgICAgICBsZXQgcHJldiA9IG51bGw7XG4gICAgICAgIGxldCBub2RlID0gbGlzdGVuZXJzLmdldChldmVudE5hbWUpO1xuICAgICAgICB3aGlsZSAobm9kZSAhPSBudWxsKSB7XG4gICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgbm9kZS5saXN0ZW5lciA9PT0gbGlzdGVuZXIgJiZcbiAgICAgICAgICAgICAgICBub2RlLmxpc3RlbmVyVHlwZSA9PT0gbGlzdGVuZXJUeXBlXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICBpZiAocHJldiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBwcmV2Lm5leHQgPSBub2RlLm5leHQ7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlLm5leHQgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLnNldChldmVudE5hbWUsIG5vZGUubmV4dCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLmRlbGV0ZShldmVudE5hbWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcHJldiA9IG5vZGU7XG4gICAgICAgICAgICBub2RlID0gbm9kZS5uZXh0O1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIERpc3BhdGNoIGEgZ2l2ZW4gZXZlbnQuXG4gICAgICogQHBhcmFtIHtFdmVudHx7dHlwZTpzdHJpbmd9fSBldmVudCBUaGUgZXZlbnQgdG8gZGlzcGF0Y2guXG4gICAgICogQHJldHVybnMge2Jvb2xlYW59IGBmYWxzZWAgaWYgY2FuY2VsZWQuXG4gICAgICovXG4gICAgZGlzcGF0Y2hFdmVudChldmVudCkge1xuICAgICAgICBpZiAoZXZlbnQgPT0gbnVsbCB8fCB0eXBlb2YgZXZlbnQudHlwZSAhPT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignXCJldmVudC50eXBlXCIgc2hvdWxkIGJlIGEgc3RyaW5nLicpXG4gICAgICAgIH1cblxuICAgICAgICAvLyBJZiBsaXN0ZW5lcnMgYXJlbid0IHJlZ2lzdGVyZWQsIHRlcm1pbmF0ZS5cbiAgICAgICAgY29uc3QgbGlzdGVuZXJzID0gZ2V0TGlzdGVuZXJzKHRoaXMpO1xuICAgICAgICBjb25zdCBldmVudE5hbWUgPSBldmVudC50eXBlO1xuICAgICAgICBsZXQgbm9kZSA9IGxpc3RlbmVycy5nZXQoZXZlbnROYW1lKTtcbiAgICAgICAgaWYgKG5vZGUgPT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuIHRydWVcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFNpbmNlIHdlIGNhbm5vdCByZXdyaXRlIHNldmVyYWwgcHJvcGVydGllcywgc28gd3JhcCBvYmplY3QuXG4gICAgICAgIGNvbnN0IHdyYXBwZWRFdmVudCA9IHdyYXBFdmVudCh0aGlzLCBldmVudCk7XG5cbiAgICAgICAgLy8gVGhpcyBkb2Vzbid0IHByb2Nlc3MgY2FwdHVyaW5nIHBoYXNlIGFuZCBidWJibGluZyBwaGFzZS5cbiAgICAgICAgLy8gVGhpcyBpc24ndCBwYXJ0aWNpcGF0aW5nIGluIGEgdHJlZS5cbiAgICAgICAgbGV0IHByZXYgPSBudWxsO1xuICAgICAgICB3aGlsZSAobm9kZSAhPSBudWxsKSB7XG4gICAgICAgICAgICAvLyBSZW1vdmUgdGhpcyBsaXN0ZW5lciBpZiBpdCdzIG9uY2VcbiAgICAgICAgICAgIGlmIChub2RlLm9uY2UpIHtcbiAgICAgICAgICAgICAgICBpZiAocHJldiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBwcmV2Lm5leHQgPSBub2RlLm5leHQ7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlLm5leHQgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLnNldChldmVudE5hbWUsIG5vZGUubmV4dCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLmRlbGV0ZShldmVudE5hbWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcHJldiA9IG5vZGU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIENhbGwgdGhpcyBsaXN0ZW5lclxuICAgICAgICAgICAgc2V0UGFzc2l2ZUxpc3RlbmVyKFxuICAgICAgICAgICAgICAgIHdyYXBwZWRFdmVudCxcbiAgICAgICAgICAgICAgICBub2RlLnBhc3NpdmUgPyBub2RlLmxpc3RlbmVyIDogbnVsbFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGlmICh0eXBlb2Ygbm9kZS5saXN0ZW5lciA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgbm9kZS5saXN0ZW5lci5jYWxsKHRoaXMsIHdyYXBwZWRFdmVudCk7XG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVvZiBjb25zb2xlICE9PSBcInVuZGVmaW5lZFwiICYmXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlb2YgY29uc29sZS5lcnJvciA9PT0gXCJmdW5jdGlvblwiXG4gICAgICAgICAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChcbiAgICAgICAgICAgICAgICBub2RlLmxpc3RlbmVyVHlwZSAhPT0gQVRUUklCVVRFICYmXG4gICAgICAgICAgICAgICAgdHlwZW9mIG5vZGUubGlzdGVuZXIuaGFuZGxlRXZlbnQgPT09IFwiZnVuY3Rpb25cIlxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgbm9kZS5saXN0ZW5lci5oYW5kbGVFdmVudCh3cmFwcGVkRXZlbnQpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBCcmVhayBpZiBgZXZlbnQuc3RvcEltbWVkaWF0ZVByb3BhZ2F0aW9uYCB3YXMgY2FsbGVkLlxuICAgICAgICAgICAgaWYgKGlzU3RvcHBlZCh3cmFwcGVkRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbm9kZSA9IG5vZGUubmV4dDtcbiAgICAgICAgfVxuICAgICAgICBzZXRQYXNzaXZlTGlzdGVuZXIod3JhcHBlZE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W50cyA9PT0gdW5kZWZpbmVkKVxuICAgICAgICByZXR1cm4gdGhpcztcblxuICAgICAgbGlzdCA9IGV2ZW50c1t0eXBlXTtcbiAgICAgIGlmIChsaXN0ID09PSB1bmRlZmluZWQpXG4gICAgICAgIHJldHVybiB0aGlzO1xuXG4gICAgICBpZiAobGlzdCA9PT0gbGlzdGVuZXIgfHwgbGlzdC5saXN0ZW5lciA9PT0gbGlzdGVuZXIpIHtcbiAgICAgICAgaWYgKC0tdGhpcy5fZXZlbnRzQ291bnQgPT09IDApXG4gICAgICAgICAgdGhpcy5fZXZlbnRzID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgZGVsZXRlIGV2ZW50c1t0eXBlXTtcbiAgICAgICAgICBpZiAoZXZlbnRzLnJlbW92ZUxpc3RlbmVyKVxuICAgICAgICAgICAgdGhpcy5lbWl0KCdyZW1vdmVMaXN0ZW5lcicsIHR5cGUsIGxpc3QubGlzdGVuZXIgfHwgbGlzdGVuZXIpO1xuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKHR5cGVvZiBsaXN0ICE9PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIHBvc2l0aW9uID0gLTE7XG5cbiAgICAgICAgZm9yIChpID0gbGlzdC5sZW5ndGggLSAxOyBpID49IDA7IGktLSkge1xuICAgICAgICAgIGlmIChsaXN0W2ldID09PSBsaXN0ZW5lciB8fCBsaXN0W2ldLmxpc3RlbmVyID09PSBsaXN0ZW5lcikge1xuICAgICAgICAgICAgb3JpZ2luYWxMaXN0ZW5lciA9IGxpc3RbaV0ubGlzdGVuZXI7XG4gICAgICAgICAgICBwb3NpdGlvbiA9IGk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocG9zaXRpb24gPCAwKVxuICAgICAgICAgIHJldHVybiB0aGlzO1xuXG4gICAgICAgIGlmIChwb3NpdGlvbiA9PT0g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pb24nIHx8IHRvU3RyLmFwcGx5KHRhcmdldCkgIT09IGZ1bmNUeXBlKSB7XG4gICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoRVJST1JfTUVTU0FHRSArIHRhcmdldCk7XG4gICAgfVxuICAgIHZhciBhcmdzID0gc2xpY3koYXJndW1lbnRzLCAxKTtcblxuICAgIHZhciBib3VuZDtcbiAgICB2YXIgYmluZGVyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAodGhpcyBpbnN0YW5jZW9mIGJvdW5kKSB7XG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gdGFyZ2V0LmFwcGx5KFxuICAgICAgICAgICAgICAgIHRoaXMsXG4gICAgICAgICAgICAgICAgY29uY2F0dHkoYXJncywgYXJndW1lbnRzKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGlmIChPYmplY3QocmVzdWx0KSA9PT0gcmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0YXJnZXQuYXBwbHkoXG4gICAgICAgICAgICB0aGF0LFxuICAgICAgICAgICAgY29uY2F0dHkoYXJncywgYXJndW1lbnRzKVxuICAgICAgICApO1xuXG4gICAgfTtcblxuICAgIHZhciBib3VuZExlbmd0aCA9IG1heCgwLCB0YXJnZXQubGVuZ3RoIC0gYXJncy5sZW5ndGgpO1xuICAgIHZhciBib3VuZEFyZ3MgPSBbXTtcbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGJvdW5kTGVuZ3RoOyBpKyspIHtcbiAgICAgICAgYm91bmRBcmdzW2ldID0gJyQnICsgaTtcbiAgICB9XG5cbiAgICBib3VuZCA9IEZ1bmN0aW9uKCdiaW5kZXInLCAncmV0dXJuIGZ1bmN0aW9uICgnICsgam9pbnkoYm91bmRBcmdzLCAnLCcpICsgJyl7IHJldHVybiBia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Y2ggPT09ICctJyB8fCBjaCA9PT0gJysnKSB7XG4gICAgY2ggPSBkYXRhWysraW5kZXhdO1xuICB9XG5cbiAgaWYgKGNoID09PSAnMCcpIHtcbiAgICAvLyAwXG4gICAgaWYgKGluZGV4ICsgMSA9PT0gbWF4KSByZXR1cm4gdHJ1ZTtcbiAgICBjaCA9IGRhdGFbKytpbmRleF07XG5cbiAgICAvLyBiYXNlIDIsIGJhc2UgOCwgYmFzZSAxNlxuXG4gICAgaWYgKGNoID09PSAnYicpIHtcbiAgICAgIC8vIGJhc2UgMlxuICAgICAgaW5kZXgrKztcblxuICAgICAgZm9yICg7IGluZGV4IDwgbWF4OyBpbmRleCsrKSB7XG4gICAgICAgIGNoID0gZGF0YVtpbmRleF07XG4gICAgICAgIGlmIChjaCA9PT0gJ18nKSBjb250aW51ZTtcbiAgICAgICAgaWYgKGNoICE9PSAnMCcgJiYgY2ggIT09ICcxJykgcmV0dXJuIGZhbHNlO1xuICAgICAgICBoYXNEaWdpdHMgPSB0cnVlO1xuICAgICAgfVxuICAgICAgcmV0dXJuIGhhc0RpZ2l0cyAmJiBjaCAhPT0gJ18nO1xuICAgIH1cblxuXG4gICAgaWYgKGNoID09PSAneCcpIHtcbiAgICAgIC8vIGJhc2UgMTZcbiAgICAgIGluZGV4Kys7XG5cbiAgICAgIGZvciAoOyBpbmRleCA8IG1heDsgaW5kZXgrKykge1xuICAgICAgICBjaCA9IGRhdGFbaW5kZXhdO1xuICAgICAgICBpZiAoY2ggPT09ICdfJykgY29udGludWU7XG4gICAgICAgIGlmICghaXNIZXhDb2RlKGRhdGEuY2hhckNvZGVBdChpbmRleCkpKSByZXR1cm4gZmFsc2U7XG4gICAgICAgIGhhc0RpZ2l0cyA9IHRydWU7XG4gICAgICB9XG4gICAgICByZXR1cm4gaGFzRGlnaXRzICYmIGNoICE9PSAnXyc7XG4gICAgfVxuXG5cbiAgICBpZiAoY2ggPT09ICdvJykge1xuICAgICAgLy8gYmFzZSA4XG4gICAgICBp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bjtcblxudmFyIFlBTUxfREFURV9SRUdFWFAgPSBuZXcgUmVnRXhwKFxuICAnXihbMC05XVswLTldWzAtOV1bMC05XSknICAgICAgICAgICsgLy8gWzFdIHllYXJcbiAgJy0oWzAtOV1bMC05XSknICAgICAgICAgICAgICAgICAgICArIC8vIFsyXSBtb250aFxuICAnLShbMC05XVswLTldKSQnKTsgICAgICAgICAgICAgICAgICAgLy8gWzNdIGRheVxuXG52YXIgWUFNTF9USU1FU1RBTVBfUkVHRVhQID0gbmV3IFJlZ0V4cChcbiAgJ14oWzAtOV1bMC05XVswLTldWzAtOV0pJyAgICAgICAgICArIC8vIFsxXSB5ZWFyXG4gICctKFswLTldWzAtOV0/KScgICAgICAgICAgICAgICAgICAgKyAvLyBbMl0gbW9udGhcbiAgJy0oWzAtOV1bMC05XT8pJyAgICAgICAgICAgICAgICAgICArIC8vIFszXSBkYXlcbiAgJyg/OltUdF18WyBcXFxcdF0rKScgICAgICAgICAgICAgICAgICsgLy8gLi4uXG4gICcoWzAtOV1bMC05XT8pJyAgICAgICAgICAgICAgICAgICAgKyAvLyBbNF0gaG91clxuICAnOihbMC05XVswLTldKScgICAgICAgICAgICAgICAgICAgICsgLy8gWzVdIG1pbnV0ZVxuICAnOihbMC05XVswLTldKScgICAgICAgICAgICAgICAgICAgICsgLy8gWzZdIHNlY29uZFxuICAnKD86XFxcXC4oWzAtOV0qKSk/JyAgICAgICAgICAgICAgICAgKyAvLyBbN10gZnJhY3Rpb25cbiAgJyg/OlsgXFxcXHRdKihafChbLStdKShbMC05XVswLTldPyknICsgLy8gWzhdIHR6IFs5XSB0el9zaWduIFsxMF0gdHpfaG91clxuICAnKD86OihbMC05XVswLTldKSk/KSk/JCcpOyAgICAgICAgICAgLy8gWzExXSB0el9taW51dGVcblxuZnVuY3Rpb24gcmVzb2x2ZVlhbWxUaW1lc3RhbXAoZGF0YSkge1xuICBpZiAoZGF0YSA9PT0gbnVsbCkgcmV0dXJuIGZhbHNlO1xuICBpZiAoW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xuICAgICAgICAoYyA9PT0gMHg2Mi8qIGIgKi8pID8gJ1xceDA4JyA6XG4gICAgICAgIChjID09PSAweDc0LyogdCAqLykgPyAnXFx4MDknIDpcbiAgICAgICAgKGMgPT09IDB4MDkvKiBUYWIgKi8pID8gJ1xceDA5JyA6XG4gICAgICAgIChjID09PSAweDZFLyogbiAqLykgPyAnXFx4MEEnIDpcbiAgICAgICAgKGMgPT09IDB4NzYvKiB2ICovKSA/ICdcXHgwQicgOlxuICAgICAgICAoYyA9PT0gMHg2Ni8qIGYgKi8pID8gJ1xceDBDJyA6XG4gICAgICAgIChjID09PSAweDcyLyogciAqLykgPyAnXFx4MEQnIDpcbiAgICAgICAgKGMgPT09IDB4NjUvKiBlICovKSA/ICdcXHgxQicgOlxuICAgICAgICAoYyA9PT0gMHgyMC8qIFNwYWNlICovKSA/ICcgJyA6XG4gICAgICAgIChjID09PSAweDIyLyogXCIgKi8pID8gJ1xceDIyJyA6XG4gICAgICAgIChjID09PSAweDJGLyogLyAqLykgPyAnLycgOlxuICAgICAgICAoYyA9PT0gMHg1Qy8qIFxcICovKSA/ICdcXHg1QycgOlxuICAgICAgICAoYyA9PT0gMHg0RS8qIE4gKi8pID8gJ1xceDg1JyA6XG4gICAgICAgIChjID09PSAweDVGLyogXyAqLykgPyAnXFx4QTAnIDpcbiAgICAgICAgKGMgPT09IDB4NEMvKiBMICovKSA/ICdcXHUyMDI4JyA6XG4gICAgICAgIChjID09PSAweDUwLyogUCAqLykgPyAnXFx1MjAyOScgOiAnJztcbn1cblxuZnVuY3Rpb24gY2hhckZyb21Db2RlcG9pbnQoYykge1xuICBpZiAoYyA8PSAweEZGRkYpIHtcbiAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZShjKTtcbiAgfVxuICAvLyBFbmNvZGUgVVRGLTE2IHN1cnJvZ2F0ZSBwYWlyXG4gIC8vIGh0dHBzOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL1VURi0xNiNDb2RlX3BvaW50c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G5cbnZhciBsb2FkZXIgPSB7XG5cdGxvYWRBbGw6IGxvYWRBbGxfMSxcblx0bG9hZDogbG9hZF8xXG59O1xuXG4vKmVzbGludC1kaXNhYmxlIG5vLXVzZS1iZWZvcmUtZGVmaW5lKi9cblxuXG5cblxuXG52YXIgX3RvU3RyaW5nICAgICAgID0gT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZztcbnZhciBfaGFzT3duUHJvcGVydHkgPSBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5O1xuXG52YXIgQ0hBUl9CT00gICAgICAgICAgICAgICAgICA9IDB4RkVGRjtcbnZhciBDSEFSX1RBQiAgICAgICAgICAgICAgICAgID0gMHgwOTsgLyogVGFiICovXG52YXIgQ0hBUl9MSU5FX0ZFRUQgICAgICAgICAgICA9IDB4MEE7IC8qIExGICovXG52YXIgQ0hBUl9DQVJSSUFHRV9SRVRVUk4gICAgICA9IDB4MEQ7IC8qIENSICovXG52YXIgQ0hBUl9TUEFDRSAgICAgICAgICAgICAgICA9IDB4MjA7IC8qIFNwYWNlICovXG52YXIgQ0hBUl9FWENMQU1BVElPTiAgICAgICAgICA9IDB4MjE7IC8qICEgKi9cbnZhciBDSEFSX0RPVUJMRV9RVU9URSAgICAgICAgID0gMHgyMjsgLyogXCIgKi9cbnZhciBDSEFSX1NIQVJQICAgICAgICAgICAgICAgID0gMHgyMzsgLyogIyAqL1xudmFyIENIQVJfUEVSQ0VOVCAgICAgICAgICAgICAgPSAweDI1OyAvKiAlICovXG52YXIgQ0hBUl9BTVBFUlNBTkQgICAgICAgICAgICA9IDB4MjY7IC8qICYgKi9cbnZhciBDSEFSX1NJTkdMRV9RVU9URSAgICAgICAgID0gMHgyNzsgLyogJyAqL1xudmFyIENIQVJfQVNURVJJU0sgICAgICAgICAgICAgPSAweDJBOyAvKiAqICovXG52YXIgQ0hBUl9DT01NQSAgICAgICAgICAgICAgICA9IDB4MkM7IC8qICwgKi9cbnZhciBDSEFSX01JTlVTICAgICAgIC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Agbm9DdXN0b21pemVyID0gIWN1c3RvbWl6ZXI7XG5cbiAgICAgIGlmIChvYmplY3QgPT0gbnVsbCkge1xuICAgICAgICByZXR1cm4gIWxlbmd0aDtcbiAgICAgIH1cbiAgICAgIG9iamVjdCA9IE9iamVjdChvYmplY3QpO1xuICAgICAgd2hpbGUgKGluZGV4LS0pIHtcbiAgICAgICAgdmFyIGRhdGEgPSBtYXRjaERhdGFbaW5kZXhdO1xuICAgICAgICBpZiAoKG5vQ3VzdG9taXplciAmJiBkYXRhWzJdKVxuICAgICAgICAgICAgICA/IGRhdGFbMV0gIT09IG9iamVjdFtkYXRhWzBdXVxuICAgICAgICAgICAgICA6ICEoZGF0YVswXSBpbiBvYmplY3QpXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgIGRhdGEgPSBtYXRjaERhdGFbaW5kZXhdO1xuICAgICAgICB2YXIga2V5ID0gZGF0YVswXSxcbiAgICAgICAgICAgIG9ialZhbHVlID0gb2JqZWN0W2tleV0sXG4gICAgICAgICAgICBzcmNWYWx1ZSA9IGRhdGFbMV07XG5cbiAgICAgICAgaWYgKG5vQ3VzdG9taXplciAmJiBkYXRhWzJdKSB7XG4gICAgICAgICAgaWYgKG9ialZhbHVlID09PSB1bmRlZmluZWQgJiYgIShrZXkgaW4gb2JqZWN0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB2YXIgc3RhY2sgPSBuZXcgU3RhY2s7XG4gICAgICAgICAgaWYgKGN1c3RvbWl6ZXIpIHtcbiAgICAgICAgICAgIHZhciByZXN1bHQgPSBjdXN0b21pemVyKG9ialZhbHVlLCBzcmNWYWx1ZSwga2V5LCBvYmplY3QsIHNvdXJjZSwgc3RhY2spO1xu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xleGl2ZSA9IHZhbHVlID09PSB2YWx1ZSxcbiAgICAgICAgICAgIHZhbElzU3ltYm9sID0gaXNTeW1ib2wodmFsdWUpO1xuXG4gICAgICAgIHZhciBvdGhJc0RlZmluZWQgPSBvdGhlciAhPT0gdW5kZWZpbmVkLFxuICAgICAgICAgICAgb3RoSXNOdWxsID0gb3RoZXIgPT09IG51bGwsXG4gICAgICAgICAgICBvdGhJc1JlZmxleGl2ZSA9IG90aGVyID09PSBvdGhlcixcbiAgICAgICAgICAgIG90aElzU3ltYm9sID0gaXNTeW1ib2wob3RoZXIpO1xuXG4gICAgICAgIGlmICgoIW90aElzTnVsbCAmJiAhb3RoSXNTeW1ib2wgJiYgIXZhbElzU3ltYm9sICYmIHZhbHVlID4gb3RoZXIpIHx8XG4gICAgICAgICAgICAodmFsSXNTeW1ib2wgJiYgb3RoSXNEZWZpbmVkICYmIG90aElzUmVmbGV4aXZlICYmICFvdGhJc051bGwgJiYgIW90aElzU3ltYm9sKSB8fFxuICAgICAgICAgICAgKHZhbElzTnVsbCAmJiBvdGhJc0RlZmluZWQgJiYgb3RoSXNSZWZsZXhpdmUpIHx8XG4gICAgICAgICAgICAoIXZhbElzRGVmaW5lZCAmJiBvdGhJc1JlZmxleGl2ZSkgfHxcbiAgICAgICAgICAgICF2YWxJc1JlZmxleGl2ZSkge1xuICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICB9XG4gICAgICAgIGlmICgoIXZhbElzTnVsbCAmJiAhdmFsSXNTeW1ib2wgJiYgIW90aElzU3ltYm9sICYmIHZhbHVlIDwgb3RoZXIpIHx8XG4gICAgICAgICAgICAob3RoSXNTeW1ib2wgJiYgdmFsSXNEZWZpbmVkICYmIHZhbElzUmVmbGV4aXZlICYmICF2YWxJc051bGwgJiYgIXZhbElzU3ltYm9sKSB8fFxuICAgICAgICAgICAgKG90aElzTnVsbCAmJiB2YWxJc0RlZmluZWQgJiYgdmFsSXNSZWZsZXhpdmUpIHx8XG4gICAgICAgICAgICAo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F07XG5cbiAgICAgICAgdmFyIG5ld1ZhbHVlID0gY3VzdG9taXplclxuICAgICAgICAgID8gY3VzdG9taXplcihvYmplY3Rba2V5XSwgc291cmNlW2tleV0sIGtleSwgb2JqZWN0LCBzb3VyY2UpXG4gICAgICAgICAgOiB1bmRlZmluZWQ7XG5cbiAgICAgICAgaWYgKG5ld1ZhbHVlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICBuZXdWYWx1ZSA9IHNvdXJjZVtrZXldO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpc05ldykge1xuICAgICAgICAgIGJhc2VBc3NpZ25WYWx1ZShvYmplY3QsIGtleSwgbmV3VmFsdWUpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGFzc2lnblZhbHVlKG9iamVjdCwga2V5LCBuZXdWYWx1ZSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBvYmplY3Q7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ29waWVzIG93biBzeW1ib2xzIG9mIGBzb3VyY2VgIHRvIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIGZyb20uXG4gICAgICogQHBhcmFtIHtPYmplY3R9IFtvYmplY3Q9e31dIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIHRvLlxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgYG9iamVjdGAuXG4gICAgICovXG4gICAgZnVuY3Rpb24gY29weVN5bWJvbHMoc291cmNlLCBvYmplY3QpIHtcbiAgICAgIHJldHVybiBjb3B5T2JqZWN0KHNvdXJjZSwgZ2V0U3ltYm9scyhzb3VyY2UpLCBvYmplY3QpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENvcGllcyBvd24gYW5kIGluaGVyaXRlZCBzeW1ib2xzIG9mIGBzb3VyY2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AgICAgIH1cbiAgICAgICAgICBpZiAocHJlcmVxICYmICF3cmFwcGVyICYmIGdldEZ1bmNOYW1lKGZ1bmMpID09ICd3cmFwcGVyJykge1xuICAgICAgICAgICAgdmFyIHdyYXBwZXIgPSBuZXcgTG9kYXNoV3JhcHBlcihbXSwgdHJ1ZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGluZGV4ID0gd3JhcHBlciA/IGluZGV4IDogbGVuZ3RoO1xuICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgIGZ1bmMgPSBmdW5jc1tpbmRleF07XG5cbiAgICAgICAgICB2YXIgZnVuY05hbWUgPSBnZXRGdW5jTmFtZShmdW5jKSxcbiAgICAgICAgICAgICAgZGF0YSA9IGZ1bmNOYW1lID09ICd3cmFwcGVyJyA/IGdldERhdGEoZnVuYykgOiB1bmRlZmluZWQ7XG5cbiAgICAgICAgICBpZiAoZGF0YSAmJiBpc0xhemlhYmxlKGRhdGFbMF0pICYmXG4gICAgICAgICAgICAgICAgZGF0YVsxXSA9PSAoV1JBUF9BUllfRkxBRyB8IFdSQVBfQ1VSUllfRkxBRyB8IFdSQVBfUEFSVElBTF9GTEFHIHwgV1JBUF9SRUFSR19GTEFHKSAmJlxuICAgICAgICAgICAgICAgICFkYXRhWzRdLmxlbmd0aCAmJiBkYXRhWzldID09IDFcbiAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICB3cmFwcGVyID0gd3JhcHBlcltnZXRGdW5jTmFtZShkYXRhWzBdKV0uYXBwbHkod3JhcHBlciwgZGF0YVszXSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHdyYXBwZXIgPSAoZnVuYy5sZW5ndGggPT0gMSAmJiBpc0xhemlhYmxlKGZ1bmMpKVxuICAgICAgICAgICAgICA/IHdyYXBwZXJbZnVuY05hbWVdKClcbiAgICAgICAgICAgICAgOiB3cmFwcGVyLnRocnUoZnVuYyk7XG4gIC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IHN0YWNrLmdldChhcnJheSk7XG4gICAgICB2YXIgb3RoU3RhY2tlZCA9IHN0YWNrLmdldChvdGhlcik7XG4gICAgICBpZiAoYXJyU3RhY2tlZCAmJiBvdGhTdGFja2VkKSB7XG4gICAgICAgIHJldHVybiBhcnJTdGFja2VkID09IG90aGVyICYmIG90aFN0YWNrZWQgPT0gYXJyYXk7XG4gICAgICB9XG4gICAgICB2YXIgaW5kZXggPSAtMSxcbiAgICAgICAgICByZXN1bHQgPSB0cnVlLFxuICAgICAgICAgIHNlZW4gPSAoYml0bWFzayAmIENPTVBBUkVfVU5PUkRFUkVEX0ZMQUcpID8gbmV3IFNldENhY2hlIDogdW5kZWZpbmVkO1xuXG4gICAgICBzdGFjay5zZXQoYXJyYXksIG90aGVyKTtcbiAgICAgIHN0YWNrLnNldChvdGhlciwgYXJyYXkpO1xuXG4gICAgICAvLyBJZ25vcmUgbm9uLWluZGV4IHByb3BlcnRpZXMuXG4gICAgICB3aGlsZSAoKytpbmRleCA8IGFyckxlbmd0aCkge1xuICAgICAgICB2YXIgYXJyVmFsdWUgPSBhcnJheVtpbmRleF0sXG4gICAgICAgICAgICBvdGhWYWx1ZSA9IG90aGVyW2luZGV4XTtcblxuICAgICAgICBpZiAoY3VzdG9taXplcikge1xuICAgICAgICAgIHZhciBjb21wYXJlZCA9IGlzUGFydGlhbFxuICAgICAgICAgICAgPyBjdXN0b21pemVyKG90aFZhbHVlLCBhcnJWYWx1ZSwgaW5kZXgsIG90aGVyLCBhcnJheSwgc3RhY2spXG4gICAgICAgICAgICA6IGN1c3RvbWl6ZXIoYXJyVmFsdWUsIG90aFZhbHVlLCBpbmRleCwgYXJyYXksIG90aGVyLCBzdGFjayk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGNvbXBhcmVkICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICBpZiAoY29tcGFyZWQpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvLyBSZWN1cnNpdmVseSBjb21wYXJlIGFycmF5cyAoc3VzY2VwdGlibGUgdG8gY2FsbCBzdGFjayBsaW1pdHMpLlxuICAgICAgICBpZiAoc2Vlbikge1xuICAgICAgICAgIGlmICghYXJyYXlTb21lKG90aGVyLCBmdW5jdGlvbihvdGhWYWx1ZSwgb3RoSW5kZXgpIHtcbiAgICAgICAgICAgICAgICBpZiAoIWNhY2hlSGFzKHNlZW4sIG90aEluZGV4KSAmJlxuICAgICAgICAgICAgICAgICAgICAoYXJyVmFsdWUgPT09IG90aFZhbHVlIHx8IGVxdWFsRnVuYyhhcnJWYWx1ZSwgb3RoVmFsdWUsIGJpdG1hc2ssIGN1c3RvbWl6ZXIsIHN0YWNrKSkpIHtcbiAgICAgICAgICAgICAgICAgIHJldHVybiBzZWVuLnB1c2gob3RoSW5kZXgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSkpIHtcbiAgICAgICAgICAgIHJlc3VsdCA9IGZhbHNlO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKCEoXG4gICAgICAgICAgICAgIGFyclZhbHVlID09PSBvdGhWYWx1ZSB8fFxuICAgICAgICAgICAgICAgIGVxdWFsRnVuYyhhcnJWYWx1ZSwgb3RoVmFsdWUsIGJpdG1hc2ssIGN1c3RvbWl6ZXIsIHN0YWNrKVxuICAgICAgICAgICAgKSkge1xuICAgICAgICAgIHJlc3VsdCA9IGZhbHNlO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBzdGFja1snZGVsZXRlJ10oYXJyYXkpO1xuICAgICAgc3RhY2tbJ2RlbGV0ZSddKG90aGVyKTtcbiAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQSBzcGVj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pYWwpIHtcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgfVxuICAgICAgdmFyIGluZGV4ID0gb2JqTGVuZ3RoO1xuICAgICAgd2hpbGUgKGluZGV4LS0pIHtcbiAgICAgICAgdmFyIGtleSA9IG9ialByb3BzW2luZGV4XTtcbiAgICAgICAgaWYgKCEoaXNQYXJ0aWFsID8ga2V5IGluIG90aGVyIDogaGFzT3duUHJvcGVydHkuY2FsbChvdGhlciwga2V5KSkpIHtcbiAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIC8vIENoZWNrIHRoYXQgY3ljbGljIHZhbHVlcyBhcmUgZXF1YWwuXG4gICAgICB2YXIgb2JqU3RhY2tlZCA9IHN0YWNrLmdldChvYmplY3QpO1xuICAgICAgdmFyIG90aFN0YWNrZWQgPSBzdGFjay5nZXQob3RoZXIpO1xuICAgICAgaWYgKG9ialN0YWNrZWQgJiYgb3RoU3RhY2tlZCkge1xuICAgICAgICByZXR1cm4gb2JqU3RhY2tlZCA9PSBvdGhlciAmJiBvdGhTdGFja2VkID09IG9iamVjdDtcbiAgICAgIH1cbiAgICAgIHZhciByZXN1bHQgPSB0cnVlO1xuICAgICAgc3RhY2suc2V0KG9iamVjdCwgb3RoZXIpO1xuICAgICAgc3RhY2suc2V0KG90aGVyLCBvYmplY3QpO1xuXG4gICAgICB2YXIgc2tpcEN0b3IgPSBpc1BhcnRpYWw7XG4gICAgICB3aGlsZSAoKytpbmRleCA8IG9iakxlbmd0aCkge1xuICAgICAgICBrZXkgPSBvYmpQcm9wc1tpbmRleF07XG4gICAgICAgIHZhciBvYmpWYWx1ZSA9IG9iamVjdFtrZXldLFxuICAgICAgICAgICAgb3RoVmFsdWUgPSBvdGhlcltrZXldO1xuXG4gICAgICAgIGlmIChjdXN0b21pemVyKSB7XG4gICAgICAgICAgdmFyIGNvbXBhcmVkID0gaXNQYXJ0aWFsXG4gICAgICAgICAgICA/IGN1c3Rvb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0gZnVuYyBUaGUgZnVuY3Rpb24gdG8gY29udmVydC5cbiAgICAgKiBAcmV0dXJucyB7c3RyaW5nfSBSZXR1cm5zIHRoZSBzb3VyY2UgY29kZS5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiB0b1NvdXJjZShmdW5jKSB7XG4gICAgICBpZiAoZnVuYyAhPSBudWxsKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgcmV0dXJuIGZ1bmNUb1N0cmluZy5jYWxsKGZ1bmMpO1xuICAgICAgICB9IGNhdGNoIChlKSB7fVxuICAgICAgICB0cnkge1xuICAgICAgICAgIHJldHVybiAoZnVuYyArICcnKTtcbiAgICAgICAgfSBjYXRjaCAoZSkge31cbiAgICAgIH1cbiAgICAgIHJldHVybiAnJztcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBVcGRhdGVzIHdyYXBwZXIgYGRldGFpbHNgIGJhc2VkIG9uIGBiaXRtYXNrYCBmbGFncy5cbiAgICAgKlxuICAgICAqIEBwcml2YXRlXG4gICAgICogQHJldHVybnMge0FycmF5fSBkZXRhaWxzIFRoZSBkZXRhaWxzIHRvIG1vZGlmeS5cbiAgICAgKiBAcGFyYW0ge251bWJlcn0gYml0bWFzayBUaGUgYml0bWFzayBmbGFncy4gU2VlIGBjcmVhdGVXcmFwYCBmb3IgbW9yZSBkZXRhaWxzLlxuICAgICAqIEByZXR1cm5zIHtBcnJheX0gUmV0dXJucyBgZGV0YWlsc2AuXG4gICAgICovXG4gICAgZnVuY3Rpb24gdXBkYXRlV3JhcERldGFpbHMoZGV0YWlscywgYml0bWFzaykge1xuICAgICAgYXJyYXlFYWNoKHdyYXBGbGFncywgZnVuY3Rpb24ocGFpcikge1xuICAgICAgICB2YXIgdmFsdWUgPSAnXy4nICsgcGFpclswXTtcbiAgICAgICAgaWYgKChiaXRtYXNrICYgcGFpclsxXSkgJiYgIWFycmF5SW5jbHVkZXMoZGV0YWlscywgdmFsdWUpKSB7XG4gICAgICAgICAgZGV0YW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ZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICB2YXIgdmFsdWUgPSBhcnJheVtpbmRleF07XG4gICAgICAgIGlmIChwcmVkaWNhdGUodmFsdWUsIGluZGV4LCBhcnJheSkpIHtcbiAgICAgICAgICByZXN1bHQucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgaW5kZXhlcy5wdXNoKGluZGV4KTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgYmFzZVB1bGxBdChhcnJheSwgaW5kZXhlcyk7XG4gICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFJldmVyc2VzIGBhcnJheWAgc28gdGhhdCB0aGUgZmlyc3QgZWxlbWVudCBiZWNvbWVzIHRoZSBsYXN0LCB0aGUgc2Vjb25kXG4gICAgICogZWxlbWVudCBiZWNvbWVzIHRoZSBzZWNvbmQgdG8gbGFzdCwgYW5kIHNvIG9uLlxuICAgICAqXG4gICAgICogKipOb3RlOioqIFRoaXMgbWV0aG9kIG11dGF0ZXMgYGFycmF5YCBhbmQgaXMgYmFzZWQgb25cbiAgICAgKiBbYEFycmF5I3JldmVyc2VgXShodHRwczovL21kbi5pby9BcnJheS9yZXZlcnNlKS5cbiAgICAgKlxuICAgICAqIEBzdGF0aWNcbiAgICAgKiBAbWVtYmVyT2YgX1xuICAgICAqIEBzaW5jZSA0LjAuMFxuICAgICAqIEBjYXRlZ29yeSBBcnJheVxuICAgICAqIEBwYXJhbSB7QXJyYXl9IGFycmF5IFRoZSBhcnJheSB0byBtb2RpZnkuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5zIGBhcnJheWAuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIHZhciBhcnJheSA9IFsxLCAyLCAzXTtcbiAgICAgKlxuICAgICAqIF8ucmV2ZXJzZShhcnJheSk7XG4gICAgICogLy8gPT4gWzMsIDIsIDFdXG4gICAgICpcbiAgICAgKiBjb25zb2xlLmxvZyh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gKlxuICAgICAqIC8vIENhbmNlbCB0aGUgdHJhaWxpbmcgZGVib3VuY2VkIGludm9jYXRpb24uXG4gICAgICogalF1ZXJ5KHdpbmRvdykub24oJ3BvcHN0YXRlJywgZGVib3VuY2VkLmNhbmNlbCk7XG4gICAgICovXG4gICAgZnVuY3Rpb24gZGVib3VuY2UoZnVuYywgd2FpdCwgb3B0aW9ucykge1xuICAgICAgdmFyIGxhc3RBcmdzLFxuICAgICAgICAgIGxhc3RUaGlzLFxuICAgICAgICAgIG1heFdhaXQsXG4gICAgICAgICAgcmVzdWx0LFxuICAgICAgICAgIHRpbWVySWQsXG4gICAgICAgICAgbGFzdENhbGxUaW1lLFxuICAgICAgICAgIGxhc3RJbnZva2VUaW1lID0gMCxcbiAgICAgICAgICBsZWFkaW5nID0gZmFsc2UsXG4gICAgICAgICAgbWF4aW5nID0gZmFsc2UsXG4gICAgICAgICAgdHJhaWxpbmcgPSB0cnVlO1xuXG4gICAgICBpZiAodHlwZW9mIGZ1bmMgIT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKEZVTkNfRVJST1JfVEVYVCk7XG4gICAgICB9XG4gICAgICB3YWl0ID0gdG9OdW1iZXIod2FpdCkgfHwgMDtcbiAgICAgIGlmIChpc09iamVjdChvcHRpb25zKSkge1xuICAgICAgICBsZWFkaW5nID0gISFvcHRpb25zLmxlYWRpbmc7XG4gICAgICAgIG1heGluZyA9ICdtYXhXYWl0JyBpbiBvcHRpb25zO1xuICAgICAgICBtYXhXYWl0ID0gbWF4aW5nID8gbmF0aXZlTWF4KHRvTnVtYmVyKG9wdGlvbnMubWF4V2FpdCkgfHwgMCwgd2FpdCkgOiBtYXhXYWl0O1xuICAgICAgICB0cmFpbGluZyA9ICd0cmFpbGluZycgaW4gb3B0aW9ucyA/ICEhb3B0aW9ucy50cmFpbGluZyA6IHRyYWlsaW5nO1xuICAgICAgfVxuXG4gICAgICBmdW5jdGlvbiBpbnZva2VG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cbiAgICAgICAgbGFzdENhbGxUaW1lID0gdGltZTtcblxuICAgICAgICBpZiAoaXNJbnZva2luZykge1xuICAgICAgICAgIGlmICh0aW1lcklkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIHJldHVybiBsZWFkaW5nRWRnZShsYXN0Q2FsbFRpbWUpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobWF4aW5nKSB7XG4gICAgICAgICAgICAvLyBIYW5kbGUgaW52b2NhdGlvbnMgaW4gYSB0aWdodCBsb29wLlxuICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVySWQpO1xuICAgICAgICAgICAgdGltZXJJZCA9IHNldFRpbWVvdXQodGltZXJFeHBpcmVkLCB3YWl0KTtcbiAgICAgICAgICAgIHJldHVybiBpbnZva2VGdW5jKGxhc3RDYWxsVGltZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aW1lcklkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICB0aW1lcklkID0gc2V0VGltZW91dCh0aW1lckV4cGlyZWQsIHdhaXQpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICB9XG4gICAgICBkZWJvdW5jZWQuY2FuY2VsID0gY2FuY2VsO1xuICAgICAgZGVib3VuY2VkLmZsdXNoID0gZmx1c2g7XG4gICAgICByZXR1cm4gZGVib3VuY2VkO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIERlZmVycyBpbnZva2luZyB0aGUgYGZ1bmNgIHVudGlsIHRoZSBjdXJyZW50IGNhbGwgc3RhY2sgaGFzIGNsZWFyZWQuIEFueVxuICAgICAqIGFkZGl0aW9uYWwgYXJndW1lbnRzIGFyZSBwcm92aWRlZCB0byBgZnVuY2Agd2hlbiBpdCdzIGludm9rZWQuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgMC4xLjBcbiAgICAgK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ICAgKlxuICAgICAqIF8uZGVmYXVsdHMoeyAnYSc6IDEgfSwgeyAnYic6IDIgfSwgeyAnYSc6IDMgfSk7XG4gICAgICogLy8gPT4geyAnYSc6IDEsICdiJzogMiB9XG4gICAgICovXG4gICAgdmFyIGRlZmF1bHRzID0gYmFzZVJlc3QoZnVuY3Rpb24ob2JqZWN0LCBzb3VyY2VzKSB7XG4gICAgICBvYmplY3QgPSBPYmplY3Qob2JqZWN0KTtcblxuICAgICAgdmFyIGluZGV4ID0gLTE7XG4gICAgICB2YXIgbGVuZ3RoID0gc291cmNlcy5sZW5ndGg7XG4gICAgICB2YXIgZ3VhcmQgPSBsZW5ndGggPiAyID8gc291cmNlc1syXSA6IHVuZGVmaW5lZDtcblxuICAgICAgaWYgKGd1YXJkICYmIGlzSXRlcmF0ZWVDYWxsKHNvdXJjZXNbMF0sIHNvdXJjZXNbMV0sIGd1YXJkKSkge1xuICAgICAgICBsZW5ndGggPSAxO1xuICAgICAgfVxuXG4gICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICB2YXIgc291cmNlID0gc291cmNlc1tpbmRleF07XG4gICAgICAgIHZhciBwcm9wcyA9IGtleXNJbihzb3VyY2UpO1xuICAgICAgICB2YXIgcHJvcHNJbmRleCA9IC0xO1xuICAgICAgICB2YXIgcHJvcHNMZW5ndGggPSBwcm9wcy5sZW5ndGg7XG5cbiAgICAgICAgd2hpbGUgKCsrcHJvcHNJbmRleCA8IHByb3BzTGVuZ3RoKSB7XG4gICAgICAgICAgdmFyIGtleSA9IHByb3BzW3Byb3BzSW5kZXhdO1xuICAgICAgICAgIHZhciB2YWx1ZSA9IG9iamVjdFtrZXldO1xuXG4gICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQgfHxcbiAgICAgICAgICAgICAgKGVxKHZhbHVlLCBvYmplY3RQcm90b1trZXldKSAmJiAhaGFzT3duUHJvcGVydHkuY2FsbChvYmplY3QsIGtleSkpKSB7XG4gICAg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b24gYm9keS5cbiAgICAgIHNvdXJjZSA9ICdmdW5jdGlvbignICsgKHZhcmlhYmxlIHx8ICdvYmonKSArICcpIHtcXG4nICtcbiAgICAgICAgKHZhcmlhYmxlXG4gICAgICAgICAgPyAnJ1xuICAgICAgICAgIDogJ29iaiB8fCAob2JqID0ge30pO1xcbidcbiAgICAgICAgKSArXG4gICAgICAgIFwidmFyIF9fdCwgX19wID0gJydcIiArXG4gICAgICAgIChpc0VzY2FwaW5nXG4gICAgICAgICAgID8gJywgX19lID0gXy5lc2NhcGUnXG4gICAgICAgICAgIDogJydcbiAgICAgICAgKSArXG4gICAgICAgIChpc0V2YWx1YXRpbmdcbiAgICAgICAgICA/ICcsIF9faiA9IEFycmF5LnByb3RvdHlwZS5qb2luO1xcbicgK1xuICAgICAgICAgICAgXCJmdW5jdGlvbiBwcmludCgpIHsgX19wICs9IF9fai5jYWxsKGFyZ3VtZW50cywgJycpIH1cXG5cIlxuICAgICAgICAgIDogJztcXG4nXG4gICAgICAgICkgK1xuICAgICAgICBzb3VyY2UgK1xuICAgICAgICAncmV0dXJuIF9fcFxcbn0nO1xuXG4gICAgICB2YXIgcmVzdWx0ID0gYXR0ZW1wdChmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIEZ1bmN0aW9uKGltcG9ydHNLZXlzLCBzb3VyY2VVUkwgKyAncmV0dXJuICcgKyBzb3VyY2UpXG4gICAgICAgICAgLmFwcGx5KHVuZGVmaW5lZCwgaW1wb3J0c1ZhbHVlcyk7XG4gICAgICB9KTtcblxuICAgICAgLy8gUHJvdmlkZSB0aGUgY29tcGlsZWQgZnVuY3Rpb24ncyBzb3VyY2UgYnkgaXRzIGB0b1N0cmluZ2AgbWV0aG9kIG9yXG4gICAgICAvLyB0aGUgYHNvdXJjZWAgcHJvcGVydHkgYXMgYSBjb252ZW5pZW5jZSBmb3IgaW5saW5pbmcgY29tcGlsZWQgdGVtcGxhdGVzLlxuICAgICAgcmVzdWx0LnNvdXJjZSA9IH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xuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYSBuZXcgZW1wdHkgYXJyYXkuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgNC4xMy4wXG4gICAgICogQGNhdGVnb3J5IFV0aWxcbiAgICAgKiBAcmV0dXJucyB7QXJyYXl9IFJldHVybnMgdGhlIG5ldyBlbXB0eSBhcnJheS5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogdmFyIGFycmF5cyA9IF8udGltZXMoMiwgXy5zdHViQXJyYXkpO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXlzKTtcbiAgICAgKiAvLyA9PiBbW10sIFtdXVxuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXlzWzBdID09PSBhcnJheXNbMV0pO1xuICAgICAqIC8vID0+IGZhbHNlXG4gICAgICovXG4gICAgZnVuY3Rpb24gc3R1YkFycmF5KCkge1xuICAgICAgcmV0dXJuIFtdO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYGZhbHNlYC5cbiAgICAgKlxuICAgICAqIEBzdGF0aWNcbiAgICAgKiBAbWVtYmVyT2YgX1xuICAgICAqIEBzaW5jZSA0LjEzLjBcbiAgICAgKiBAY2F0ZWdvcnkgVXRpbFxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSBSZXR1cm5zIGBmYWxzZWAuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8udGltZXMoMiwgXy5zdHViRmFsc2UpO1xuICAgICAqIC8vID0+IFtmYWxzZSwgZmFsc2VdXG4gICAgICovXG4gICAgZnVuY3Rpb24gc3R1YkZhbHNlKCkge1xuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYSBuZXcgZW1wdHkgb2JqZWN0LlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTMuMFxuICAgICAqIEBjYXRlZ29yeSBVdGlsXG4gICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyB0aGUgbmV3IGVtcHR5IG9iamVjdC5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogdmFyIG9iamVjdHMgPSBfLnRpbWVzKDIsIF8uc3R1Yk9iamVjdCk7XG4gICAgICpcbiAgICAgKiBjb25zb2xlLmxvZyhvYmplY3RzKTtcbiAgICAgKiAvLyA9PiBbe30sIHt9XVxuICAgICAqXG4gICAgICogY29uc29sZS5sb2cob2JqZWN0c1swXSA9PT0gb2JqZWN0c1sxXSk7XG4gICAgICogLy8gPT4gZmFsc2VcbiAgICAgKi9cbiAgICBmdW5jdGlvbiBzdHViT2JqZWN0KCkge1xuICAgICAgcmV0dXJuIHt9O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYW4gZW1wdHkgc3RyaW5nLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTMuMFxuICAgICAqIEBjYXRlZ29yeSBVdGlsXG4gICAgICogQHJldHVybnMge3N0cmluZ30gUmV0dXJucyB0aGUgZW1wdHkgc3RyaW5nLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiBfLnRpbWVzKDIsIF8uc3R1YlN0cmluZyk7XG4gICAgICogLy8gPT4gWycnLCAnJ11cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBzdHViU3RyaW5nKCkge1xuICAgICAgcmV0dXJuICcnO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYHRydWVgLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZX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SZWZsZWN0ID09PSAnZnVuY3Rpb24nID8gUmVmbGVjdC5nZXRQcm90b3R5cGVPZiA6IE9iamVjdC5nZXRQcm90b3R5cGVPZikgfHwgKFxuICAgIFtdLl9fcHJvdG9fXyA9PT0gQXJyYXkucHJvdG90eXBlIC8vIGVzbGludC1kaXNhYmxlLWxpbmUgbm8tcHJvdG9cbiAgICAgICAgPyBmdW5jdGlvbiAoTykge1xuICAgICAgICAgICAgcmV0dXJuIE8uX19wcm90b19fOyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLXByb3RvXG4gICAgICAgIH1cbiAgICAgICAgOiBudWxsXG4pO1xuXG5mdW5jdGlvbiBhZGROdW1lcmljU2VwYXJhdG9yKG51bSwgc3RyKSB7XG4gICAgaWYgKFxuICAgICAgICBudW0gPT09IEluZmluaXR5XG4gICAgICAgIHx8IG51bSA9PT0gLUluZmluaXR5XG4gICAgICAgIHx8IG51bSAhPT0gbnVtXG4gICAgICAgIHx8IChudW0gJiYgbnVtID4gLTEwMDAgJiYgbnVtIDwgMTAwMClcbiAgICAgICAgfHwgJHRlc3QuY2FsbCgvZS8sIHN0cilcbiAgICApIHtcbiAgICAgICAgcmV0dXJuIHN0cjtcbiAgICB9XG4gICAgdmFyIHNlcFJlZ2V4ID0gL1swLTldKD89KD86WzAtOV17M30pKyg/IVswLTldKSkvZztcbiAgICBpZiAodHlwZW9mIG51bSA9PT0gJ251bWJlcicpIHtcbiAgICAgICAgdmFyIGludCA9IG51bSA8IDAgPyAtJGZsb29yKC1udW0pIDogJGZsb29yKG51bSk7IC8vIHRydW5jKG51bSlcbiAgICAgICAgaWYgKGludCAhPT0gbnVtKSB7XG4gICAgICAgICAgICB2YXIgaW50U3RyID0gU3RyaW5nKGludCk7XG4gICAgICAgICAgICB2YXIgZGVjID0gJHNsaWNlLmNhbGwoc3RyLCBpbnRTdHIubGVuZ3RoICsgMSk7XG4gICAgICAgICAgICByZXR1cm4gJHJlcGxhY2UuY2FsbChpbnRTdHI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ai5ub2RlTmFtZSkpO1xuICAgICAgICB2YXIgYXR0cnMgPSBvYmouYXR0cmlidXRlcyB8fCBbXTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBhdHRycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgcyArPSAnICcgKyBhdHRyc1tpXS5uYW1lICsgJz0nICsgd3JhcFF1b3RlcyhxdW90ZShhdHRyc1tpXS52YWx1ZSksICdkb3VibGUnLCBvcHRzKTtcbiAgICAgICAgfVxuICAgICAgICBzICs9ICc+JztcbiAgICAgICAgaWYgKG9iai5jaGlsZE5vZGVzICYmIG9iai5jaGlsZE5vZGVzLmxlbmd0aCkgeyBzICs9ICcuLi4nOyB9XG4gICAgICAgIHMgKz0gJzwvJyArICR0b0xvd2VyQ2FzZS5jYWxsKFN0cmluZyhvYmoubm9kZU5hbWUpKSArICc+JztcbiAgICAgICAgcmV0dXJuIHM7XG4gICAgfVxuICAgIGlmIChpc0FycmF5KG9iaikpIHtcbiAgICAgICAgaWYgKG9iai5sZW5ndGggPT09IDApIHsgcmV0dXJuICdbXSc7IH1cbiAgICAgICAgdmFyIHhzID0gYXJyT2JqS2V5cyhvYmosIGluc3BlY3QpO1xuICAgICAgICBpZiAoaW5kZW50ICYmICFzaW5nbGVMaW5lVmFsdWVzKHhzKSkge1xuICAgICAgICAgICAgcmV0dXJuICdbJyArIGluZGVudGVkSm9pbih4cywgaW5kZW50KSArICddJztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gJ1sgJyArICRqb2luLmNhbGwoeHMsICcsICcpICsgJyBdJztcbiAgICB9XG4gICAgaWYgKGlzRXJyb3Iob2JqKSkge1xuICAgICAgICB2YXIgcGFydHMgPSBhcnJPYmpLZXlzKG9iaiwgaW5zcGVjdCk7XG4gICAgICAgIGlmICghKCdjYXVzZScgaW4gRXJyb3IucHJvdG90eXBlKSAmJiAnY2F1c2UnIGluIG9iaiAmJiAhaXNFbnVtZXJhYmxlLmNhbGwob2JqLCAnY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WQgYXMgc3RyaW5ncywgZnJvbSBiZWluZyBpbmNsdWRlZCBpbiB0aGUgc3RyaW5nIGtleSBzZWN0aW9uXG4gICAgICAgICAgICBjb250aW51ZTsgLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1yZXN0cmljdGVkLXN5bnRheCwgbm8tY29udGludWVcbiAgICAgICAgfSBlbHNlIGlmICgkdGVzdC5jYWxsKC9bXlxcdyRdLywga2V5KSkge1xuICAgICAgICAgICAgeHMucHVzaChpbnNwZWN0KGtleSwgb2JqKSArICc6ICcgKyBpbnNwZWN0KG9ialtrZXldLCBvYmopKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHhzLnB1c2goa2V5ICsgJzogJyArIGluc3BlY3Qob2JqW2tleV0sIG9iaikpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGlmICh0eXBlb2YgZ09QUyA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICBmb3IgKHZhciBqID0gMDsgaiA8IHN5bXMubGVuZ3RoOyBqKyspIHtcbiAgICAgICAgICAgIGlmIChpc0VudW1lcmFibGUuY2FsbChvYmosIHN5bXNbal0pKSB7XG4gICAgICAgICAgICAgICAgeHMucHVzaCgnWycgKyBpbnNwZWN0KHN5bXNbal0pICsgJ106ICcgKyBpbnNwZWN0KG9ialtzeW1zW2pdXSwgb2JqKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHhzO1xufVxuIiwiJ3VzZSBzdHJpY3QnO1xuXG52YXIga2V5c1NoaW07XG5pZiAoIU9iamVjdC5rZXlzKSB7XG5cdC8vIG1vZGlmaWVkIGZyb20gaHR0cHM6Ly9naXRodWIuY29tL2VzLXNoaW1zL2VzNS1zaGltXG5cdHZhciBoYXMgPSBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5O1xuXHR2YXIgdG9TdHIgPSBPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nO1xuXHR2YXIgaXNB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dWlyZSgnLi9hZGxlcjMyJyk7XG52YXIgY3JjMzIgICA9IHJlcXVpcmUoJy4vY3JjMzInKTtcbnZhciBtc2cgICAgID0gcmVxdWlyZSgnLi9tZXNzYWdlcycpO1xuXG4vKiBQdWJsaWMgY29uc3RhbnRzID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki9cblxuXG4vKiBBbGxvd2VkIGZsdXNoIHZhbHVlczsgc2VlIGRlZmxhdGUoKSBhbmQgaW5mbGF0ZSgpIGJlbG93IGZvciBkZXRhaWxzICovXG52YXIgWl9OT19GTFVTSCAgICAgID0gMDtcbnZhciBaX1BBUlRJQUxfRkxVU0ggPSAxO1xuLy92YXIgWl9TWU5DX0ZMVVNIICAgID0gMjtcbnZhciBaX0ZVTExfRkxVU0ggICAgPSAzO1xudmFyIFpfRklOSVNIICAgICAgICA9IDQ7XG52YXIgWl9CTE9DSyAgICAgICAgID0gNTtcbi8vdmFyIFpfVFJFRVMgICAgICAgICA9IDY7XG5cblxuLyogUmV0dXJuIGNvZGVzIGZvciB0aGUgY29tcHJlc3Npb24vZGVjb21wcmVzc2lvbiBmdW5jdGlvbnMuIE5lZ2F0aXZlIHZhbHVlc1xuICogYXJlIGVycm9ycywgcG9zaXRpdmUgdmFsdWVzIGFyZSB1c2VkIGZvciBzcGVjaWFsIGJ1dCBub3JtYWwgZXZlbnRzLlxuICovXG52YXIgWl9PSyAgICAgICAgICAgID0gMDtcbnZhciBaX1NUUkVBTV9FTkQgICAgPSAxO1xuLy92YXIgWl9ORUVEX0RJQ1QgICAgID0gMjtcbi8vdmFyIFpfRVJSTk8gICAgICAgICA9IC0xO1xudmFyIFpfU1RSRUFNX0VSUk9SICA9IC0yO1xudmFyIFpfREFUQV9FUlJPUiAgICA9IC0zO1xuLy92YXIgWl9NRU1fRVJST1IgICAgID0gLTQ7XG52YXIgWl9CVUZfRVJST1IgICAgID0gLTU7XG4vL3ZhciBaX1ZFUlNJT05fRVJST1IgPSAtNjtcblxuXG4vKiBjb21wcmVzc2lvbiBsZXZlbHMgKi9cbi8vdmFyIFpfTk9fQ09NUFJFU1NJT04gICAgICA9IDA7XG4vL3ZhciBaX0JFU1RfU1BFRUQgICAgICAgICAgPSAxO1xuLy92YXIgWl9CRVNUX0NPTVBSRVNTSU9OICAgID0gOTtcbnZhciBaX0RFRkFVTFRfQ09NUFJFU1NJT04gPSAtMTtcblxuXG52YXIgWl9GSUxURVJFRCAgICAgICAgICAgID0gMTtcbnZhciBaX0hVRkZNQU5fT05MWSAgICAgICAgPSAyO1xudmFyIFpfUkxFICAgICAgICAgICAgICAgICA9IDM7XG52YXIgWl9GSVhFRCAgICAgICAgICAgICAgID0gNDtcbnZhciBaX0RFRkFVTFRfU1RSQVRFR1kgICAgPSAwO1xuXG4vKiBQb3NzaWJsZSB2YWx1ZXMgb2YgdGhlIGRhdGFfdHlwZSBmaWVsZCAodGhvdWdoIHNlZSBpbmZsYXRlKCkpICovXG4vL3ZhciBaX0JJTkFSWSAgICAgICAgICAgICAgPSAwO1xuLy92YXIgWl9URVhUICAgICAgICAgICAgICAgID0gMTtcbi8vdmFyIFpfQVNDSUkgICAgICAgICAgICAgICA9IDE7IC8vID0gWl9URVhUXG52YXIgWl9VTktOT1dOICAgICAgICAgICAgID0gMjtcblxuXG4vKiBUaGUgZGVmbGF0ZSBjb21wcmVzc2lvbiBtZXRob2QgKi9cbnZhciBaX0RFRkxBVEVEICA9IDg7XG5cbi8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG5cblxudmFyIE1BWF9NRU1fTEVWRUwgPSA5O1xuLyogTWF4aW11bSB2YWx1ZSBmb3IgbWVtTGV2ZWwgaW4gZGVmbGF0ZUluaX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3RhdHVzID09PSBJTklUX1NUQVRFKSB7XG5cbiAgICBpZiAocy53cmFwID09PSAyKSB7IC8vIEdaSVAgaGVhZGVyXG4gICAgICBzdHJtLmFkbGVyID0gMDsgIC8vY3JjMzIoMEwsIFpfTlVMTCwgMCk7XG4gICAgICBwdXRfYnl0ZShzLCAzMSk7XG4gICAgICBwdXRfYnl0ZShzLCAxMzkpO1xuICAgICAgcHV0X2J5dGUocywgOCk7XG4gICAgICBpZiAoIXMuZ3poZWFkKSB7IC8vIHMtPmd6aGVhZCA9PSBaX05VTExcbiAgICAgICAgcHV0X2J5dGUocywgMCk7XG4gICAgICAgIHB1dF9ieXRlKHMsIDApO1xuICAgICAgICBwdXRfYnl0ZShzLCAwKTtcbiAgICAgICAgcHV0X2J5dGUocywgMCk7XG4gICAgICAgIHB1dF9ieXRlKHMsIDApO1xuICAgICAgICBwdXRfYnl0ZShzLCBzLmxldmVsID09PSA5ID8gMiA6XG4gICAgICAgICAgICAgICAgICAgIChzLnN0cmF0ZWd5ID49IFpfSFVGRk1BTl9PTkxZIHx8IHMubGV2ZWwgPCAyID9cbiAgICAgICAgICAgICAgICAgICAgIDQgOiAwKSk7XG4gICAgICAgIHB1dF9ieXRlKHMsIE9TX0NPREUpO1xuICAgICAgICBzLnN0YXR1cyA9IEJVU1lfU1RBVEU7XG4gICAgICB9XG4gICAgICBlbHNlIHtcbiAgICAgICAgcHV0X2J5dGUocywgKHMuZ3poZWFkLnRleHQgPyAxIDogMCkgK1xuICAgICAgICAgICAgICAgICAgICAocy5nemhlYWQuaGNyYyA/IDIgOiAwKSArXG4gICAgICAgICAgICAgICAgICAgICghcy5nemhlYWQuZXh0cmEgPyAwIDogNCkgK1xuICAgICAgICAgICAgICAgICAgICAoIXMuZ3poZWFkLm5hbWUgPyAwIDogOCkgK1xuICAgICAgICAgICAgICAgICAgICAoIXMuZ3poZWFkLmNvbW1lbnQgPyAwIDogMTYpXG4gICAgICAgICk7XG4gICAgICAgIHB1dF9ieXRlKH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HMuc3RhdHVzID0gTkFNRV9TVEFURTtcbiAgICB9XG4gIH1cbiAgaWYgKHMuc3RhdHVzID09PSBOQU1FX1NUQVRFKSB7XG4gICAgaWYgKHMuZ3poZWFkLm5hbWUvKiAhPSBaX05VTEwqLykge1xuICAgICAgYmVnID0gcy5wZW5kaW5nOyAgLyogc3RhcnQgb2YgYnl0ZXMgdG8gdXBkYXRlIGNyYyAqL1xuICAgICAgLy9pbnQgdmFsO1xuXG4gICAgICBkbyB7XG4gICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkge1xuICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykge1xuICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTtcbiAgICAgICAgICBiZWcgPSBzLnBlbmRpbmc7XG4gICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7XG4gICAgICAgICAgICB2YWwgPSAxO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIC8vIEpTIHNwZWNpZmljOiBsaXR0bGUgbWFnaWMgdG8gYWRkIHplcm8gdGVybWluYXRvciB0byBlbmQgb2Ygc3RyaW5nXG4gICAgICAgIGlmIChzLmd6aW5kZXggPCBzLmd6aGVhZC5uYW1lLmxlbmd0aCkge1xuICAgICAgICAgIHZhbCA9IHMuZ3poZWFkLm5hbWUuY2hhckNvZGVBdChzLmd6aW5kZXgrKykgJiAweGZmO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHZhbCA9IDA7XG4gICAgICAgIH1cbiAgICAgICAgcHV0X2J5dGUocywgdmFsKTtcbiAgICAgIH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pbnB1dCAqL1xuICB2YXIgbGFzdDsgICAgICAgICAgICAgICAgICAgLyogaGF2ZSBlbm91Z2ggaW5wdXQgd2hpbGUgaW4gPCBsYXN0ICovXG4gIHZhciBfb3V0OyAgICAgICAgICAgICAgICAgICAvKiBsb2NhbCBzdHJtLm91dHB1dCAqL1xuICB2YXIgYmVnOyAgICAgICAgICAgICAgICAgICAgLyogaW5mbGF0ZSgpJ3MgaW5pdGlhbCBzdHJtLm91dHB1dCAqL1xuICB2YXIgZW5kOyAgICAgICAgICAgICAgICAgICAgLyogd2hpbGUgb3V0IDwgZW5kLCBlbm91Z2ggc3BhY2UgYXZhaWxhYmxlICovXG4vLyNpZmRlZiBJTkZMQVRFX1NUUklDVFxuICB2YXIgZG1heDsgICAgICAgICAgICAgICAgICAgLyogbWF4aW11bSBkaXN0YW5jZSBmcm9tIHpsaWIgaGVhZGVyICovXG4vLyNlbmRpZlxuICB2YXIgd3NpemU7ICAgICAgICAgICAgICAgICAgLyogd2luZG93IHNpemUgb3IgemVybyBpZiBub3QgdXNpbmcgd2luZG93ICovXG4gIHZhciB3aGF2ZTsgICAgICAgICAgICAgICAgICAvKiB2YWxpZCBieXRlcyBpbiB0aGUgd2luZG93ICovXG4gIHZhciB3bmV4dDsgICAgICAgICAgICAgICAgICAvKiB3aW5kb3cgd3JpdGUgaW5kZXggKi9cbiAgLy8gVXNlIGBzX3dpbmRvd2AgaW5zdGVhZCBgd2luZG93YCwgYXZvaWQgY29uZmxpY3Qgd2l0aCBpbnN0cnVtZW50YXRpb24gdG9vbHNcbiAgdmFyIHNfd2luZG93OyAgICAgICAgICAgICAgIC8qIGFsbG9jYXRlZCBzbGlkaW5nIHdpbmRvdywgaWYgd3NpemUgIT0gMCAqL1xuICB2YXIgaG9sZDsgICAgICAgICAgICAgICAgICAgLyogbG9jYWwgc3RybS5ob2xkICovXG4gIHZhciBiaXRzOyAgICAgICAgICAgICAgICAgICAvKiBsb2NhbCBzdHJtLmJpdHMgKi9cbiAgdm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ID0gbGNvZGVbaG9sZCAmIGxtYXNrXTtcblxuICAgIGRvbGVuOlxuICAgIGZvciAoOzspIHsgLy8gR290byBlbXVsYXRpb25cbiAgICAgIG9wID0gaGVyZSA+Pj4gMjQvKmhlcmUuYml0cyovO1xuICAgICAgaG9sZCA+Pj49IG9wO1xuICAgICAgYml0cyAtPSBvcDtcbiAgICAgIG9wID0gKGhlcmUgPj4+IDE2KSAmIDB4ZmYvKmhlcmUub3AqLztcbiAgICAgIGlmIChvcCA9PT0gMCkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgLyogbGl0ZXJhbCAqL1xuICAgICAgICAvL1RyYWNldnYoKHN0ZGVyciwgaGVyZS52YWwgPj0gMHgyMCAmJiBoZXJlLnZhbCA8IDB4N2YgP1xuICAgICAgICAvLyAgICAgICAgXCJpbmZsYXRlOiAgICAgICAgIGxpdGVyYWwgJyVjJ1xcblwiIDpcbiAgICAgICAgLy8gICAgICAgIFwiaW5mbGF0ZTogICAgICAgICBsaXRlcmFsIDB4JTAyeFxcblwiLCBoZXJlLnZhbCkpO1xuICAgICAgICBvdXRwdXRbX291dCsrXSA9IGhlcmUgJiAweGZmZmYvKmhlcmUudmFsKi87XG4gICAgICB9XG4gICAgICBlbHNlIGlmIChvcCAmIDE2KSB7ICAgICAgICAgICAgICAgICAgICAgLyogbGVuZ3RoIGJhc2UgKi9cbiAgICAgICAgbGVuID0gaGVyZSAmIDB4ZmZmZi8qaGVyZS52YWwqLztcbiAgICAgICAgb3AgJj0gMTU7ICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogbnVtYmVyIG9mIGV4dHJhIGJpdHMgKi9cbiAgICAgICAgaWYgKG9wKSB7XG4gICAgICAgICAgaWYgKGJpdHMgPCBvcCkge1xuICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgbGVuICs9IGhvbGQgJiAoKDEgPDwgb3ApIC0gMSk7XG4gICAgICAgICAgaG9sZCA+Pj49IG9wO1xuICAgICAgICAgIGJpdHMgLT0gb3A7XG4gICAgICAgIH1cbiAgICAgICAgLy9UcmFjZXZ2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgICAgICBsZW5ndGggJXVcXG5cIiwgbGVuKSk7XG4gICAgICAgIGlmIChiaXRzIDwgMTUpIHtcbiAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzO1xuICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzO1xuICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgfVxuICAgICAgICBoZXJlID0gZGNvZGVbaG9sZCAmIGRtYXNrXTtcblxuICAgICAgICBkb2Rpc3Q6XG4gICAgICAgIGZvciAoOzspIHsgLy8gZ290byBlbXVsYXRpb25cbiAgICAgICAgICBvcCA9IGhlcmUgPj4+IDI0LypoZXJlLmJpdHMqLztcbiAgICAgICAgICBob2xkID4+Pj0gb3A7XG4gICAgICAgICAgYml0cyAtPSBvcDtcbiAgICAgICAgICBvcCA9IChoZXJlID4+PiAxNikgJiAweGZmLypoZXJlLm9wKi87XG5cbiAgICAgICAgICBpZiAob3AgJiAxNikgeyAgICAgICAgICAgICAgICAgICAgICAvKiBkaXN0YW5jZSBiYXNlICovXG4gICAgICAgICAgICBkaXN0ID0gaGVyZSAmIDB4ZmZmZi8qaGVyZS52YWwqLztcbiAgICAgICAgICAgIG9wICY9IDE1OyAgICAgICAgICAgICAgICAgICAgICAgLyogbnVtYmVyIG9mIGV4dHJhIGJpdHMgKi9cbiAgICAgICAgICAgIGlmIChiaXRzIDwgb3ApIHtcbiAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgICAgICBpZiAoYml0cyA8IG9wKSB7XG4gICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3QgKz0gaG9sZCAmICgoMSA8PCBvcCkgLSAxKTtcbi8vI2lmZGVmIElORkxBVEVfU1RSSUNUXG4gICAgICAgICAgICBpZiAoZGlzdCA+IGRtYXgpIHtcbiAgICAgICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2snO1xuICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgICBicmVhayB0b3A7XG4gICAgICAgICAgICB9XG4vLyNlbmRpZlxuICAgICAgICAgICAgaG9sZCA+Pj49IG9wO1xuICAgICAgICAgICAgYml0cyAtPSBvcDtcbiAgICAgICAgICAgIC8vVHJhY2V2digoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgICAgZGlzdGFuY2UgJXVcXG5cIiwgZGlzdCkpO1xuICAgICAgICAgICAgb3AgPSBfb3V0IC0gYmVnOyAgICAgICAgICAgICAgICAvKiBtYXggZGlzdGFuY2UgaW4gb3V0cHV0ICovXG4gICAgICAgICAgICBpZiAoZGlzdCA+IG9wKSB7ICAgICAgICAgICAgICAgIC8qIHNlZSBpZiBjb3B5IGZyb20gd2luZG93ICovXG4gICAgICAgICAgICAgIG9wID0gZGlzdCAtIG9wOyAgICAgICAgICAgICAgIC8qIGRpc3RhbmNlIGJhY2sgaW4gd2luZG93ICovXG4gICAgICAgICAgICAgIGlmIChvcCA+IHdoYXZlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHN0YXRlLnNhbmUpIHtcbiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgZGlzdGFuY2UgdG9vIGZhciBiYWNrJztcbiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICAgICAgICBicmVhayB0b3A7XG4gICAgICAgICAgICAgICAgfVxuXG4vLyAoISkgVGhpcyBibG9jayBpcyBkaXNhYmxlZCBpbiB6bGliIGRlZmF1bHRzLFxuLy8gZG9uJ3QgZW5hYmxlIGl0IGZvciBiaW5hcnkgY29tcGF0aWJpbGl0eVxuLy8jaWZkZWYgSU5GTEFURV9BTExPV19JTlZBTElEX0RJU1RBTkNFX1RPT0ZBUl9BUlJSXG4vLyAgICAgICAgICAgICAgICBpZiAobGVuIDw9IG9wIC0gd2hhdmUpIHtcbi8vICAgICAgICAgICAgICAgICAgZG8ge1xuLy8gICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gMDtcbi8vICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1sZW4pO1xuLy8gICAgICAgICAgICAgICAgICBjb250aW51ZSB0b3A7XG4vLyAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgICBsZW4gLT0gb3AgLSB3aGF2ZTtcbi8vICAgICAgICAgICAgICAgIGRvIHtcbi8vICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSAwO1xuLy8gICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCA+IHdoYXZlKTtcbi8vICAgICAgICAgICAgICAgIGlmIChvcCA9PT0gMCkge1xuLy8gICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7XG4vLyAgICAgICAgICAgICAgICAgIGRvIHtcbi8vICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuLy8gICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLWxlbik7XG4vLyAgICAgICAgICAgICAgICAgIGNvbnRpbnVlIHRvcDtcbi8vICAgICAgICAgICAgICAgIH1cbi8vI2VuZGlmXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgZnJvbSA9IDA7IC8vIHdpbmRvdyBpbmRleFxuICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IHNfd2luZG93O1xuICAgICAgICAgICAgICBpZiAod25leHQgPT09IDApIHsgICAgICAgICAgIC8qIHZlcnkgY29tbW9uIGNhc2UgKi9cbiAgICAgICAgICAgICAgICBmcm9tICs9IHdzaXplIC0gb3A7XG4gICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7ICAgICAgICAgLyogc29tZSBmcm9tIHdpbmRvdyAqL1xuICAgICAgICAgICAgICAgICAgbGVuIC09IG9wO1xuICAgICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107XG4gICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTtcbiAgICAgICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsgIC8qIHJlc3QgZnJvbSBvdXRwdXQgKi9cbiAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gb3V0cHV0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBlbHNlIGlmICh3bmV4dCA8IG9wKSB7ICAgICAgLyogd3JhcCBhcm91bmQgd2luZG93ICovXG4gICAgICAgICAgICAgICAgZnJvbSArPSB3c2l6ZSArIHduZXh0IC0gb3A7XG4gICAgICAgICAgICAgICAgb3AgLT0gd25leHQ7XG4gICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7ICAgICAgICAgLyogc29tZSBmcm9tIGVuZCBvZiB3aW5kb3cgKi9cbiAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDtcbiAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdO1xuICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7XG4gICAgICAgICAgICAgICAgICBmcm9tID0gMDtcbiAgICAgICAgICAgICAgICAgIGlmICh3bmV4dCA8IGxlbikgeyAgLyogc29tZSBmcm9tIHN0YXJ0IG9mIHdpbmRvdyAqL1xuICAgICAgICAgICAgICAgICAgICBvcCA9IHduZXh0O1xuICAgICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7XG4gICAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107XG4gICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApO1xuICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7ICAgICAgLyogcmVzdCBmcm9tIG91dHB1dCAqL1xuICAgICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgZWxzZSB7ICAgICAgICAgICAgICAgICAgICAgIC8qIGNvbnRpZ3VvdXMgaW4gd2luZG93ICovXG4gICAgICAgICAgICAgICAgZnJvbSArPSB3bmV4dCAtIG9wO1xuICAgICAgICAgICAgICAgIGlmIChvcCA8IGxlbikgeyAgICAgICAgIC8qIHNvbWUgZnJvbSB3aW5kb3cgKi9cbiAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDtcbiAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdO1xuICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7XG4gICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7ICAvKiByZXN0IGZyb20gb3V0cHV0ICovXG4gICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgd2hpbGUgKGxlbiA+IDIpIHtcbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdO1xuICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBsZW4gLT0gMztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAobGVuKSB7XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdO1xuICAgICAgICAgICAgICAgIGlmIChsZW4gPiAxKSB7XG4gICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OyAgICAgICAgICAvKiBjb3B5IGRpcmVjdCBmcm9tIG91dHB1dCAqL1xuICAgICAgICAgICAgICBkbyB7ICAgICAgICAgICAgICAgICAgICAgICAgLyogbWluaW11bSBsZW5ndGggaXMgdGhyZWUgKi9cbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBsZW4gLT0gMztcbiAgICAgICAgICAgICAgfSB3aGlsZSAobGVuID4gMik7XG4gICAgICAgICAgICAgIGlmIChsZW4pIHtcbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuICAgICAgICAgICAgICAgIGlmIChsZW4gPiAxKSB7XG4gICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIGlmICgob3AgJiA2NCkgPT09IDApIHsgICAgICAgICAgLyogMm5kIGxldmVsIGRpc3RhbmNlIGNvZGUgKi9cbiAgICAgICAgICAgIGhlcmUgPSBkY29kZVsoaGVyZSAmIDB4ZmZmZikvKmhlcmUudmFsKi8gKyAoaG9sZCAmICgoMSA8PCBvcCkgLSAxKSldO1xuICAgICAgICAgICAgY29udGludWUgZG9kaXN0O1xuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgZGlzdGFuY2UgY29kZSc7XG4gICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgYnJlYWsgdG9wO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGJyZWFrOyAvLyBuZWVkIHRvIGVtdWxhdGUgZ290byB2aWEgXCJjb250aW51ZVwiXG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGVsc2UgaWYgKChvcCAmIDY0KSA9PT0gMCkgeyAgICAgICAgICAgICAgLyogMm5kIGxldmVsIGxlbmd0aCBjb2RlICovXG4gICAgICAgIGhlcmUgPSBsY29kZVsoaGVyZSAmIDB4ZmZmZikvKmhlcmUudmFsKi8gKyAoaG9sZCAmICgoMSA8PCBvcCkgLSAxKSldO1xuICAgICAgICBjb250aW51ZSBkb2xlbjtcbiAgICAgIH1cbiAgICAgIGVsc2UgaWYgKG9wICYgMzIpIHsgICAgICAgICAgICAgICAgICAgICAvKiBlbmQtb2YtYmxvY2sgKi9cbiAgICAgICAgLy9UcmFjZXZ2KChzdGRlcnIsIFwiaW5mbGF0ZT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A2O1xuXG5cbi8qIFJldHVybiBjb2RlcyBmb3IgdGhlIGNvbXByZXNzaW9uL2RlY29tcHJlc3Npb24gZnVuY3Rpb25zLiBOZWdhdGl2ZSB2YWx1ZXNcbiAqIGFyZSBlcnJvcnMsIHBvc2l0aXZlIHZhbHVlcyBhcmUgdXNlZCBmb3Igc3BlY2lhbCBidXQgbm9ybWFsIGV2ZW50cy5cbiAqL1xudmFyIFpfT0sgICAgICAgICAgICA9IDA7XG52YXIgWl9TVFJFQU1fRU5EICAgID0gMTtcbnZhciBaX05FRURfRElDVCAgICAgPSAyO1xuLy92YXIgWl9FUlJOTyAgICAgICAgID0gLTE7XG52YXIgWl9TVFJFQU1fRVJST1IgID0gLTI7XG52YXIgWl9EQVRBX0VSUk9SICAgID0gLTM7XG52YXIgWl9NRU1fRVJST1IgICAgID0gLTQ7XG52YXIgWl9CVUZfRVJST1IgICAgID0gLTU7XG4vL3ZhciBaX1ZFUlNJT05fRVJST1IgPSAtNjtcblxuLyogVGhlIGRlZmxhdGUgY29tcHJlc3Npb24gbWV0aG9kICovXG52YXIgWl9ERUZMQVRFRCAgPSA4O1xuXG5cbi8qIFNUQVRFUyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG4vKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuXG5cbnZhciAgICBIRUFEID0gMTsgICAgICAgLyogaTogd2FpdGluZyBmb3IgbWFnaWMgaGVhZGVyICovXG52YXIgICAgRkxBR1MgPSAyOyAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIG1ldGhvZCBhbmQgZmxhZ3MgKGd6aXApICovXG52YXIgICAgVElNRSA9IDM7ICAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIG1vZGlmaWNhdGlvbiB0aW1lIChnemlwKSAqL1xudmFyICAgIE9TID0gNDs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Pj4+IDgpICYgMHhmZjtcbiAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCAyLCAwKTtcbiAgICAgICAgICAvLz09PS8vXG5cbiAgICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICAgIGhvbGQgPSAwO1xuICAgICAgICAgIGJpdHMgPSAwO1xuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgICBzdGF0ZS5tb2RlID0gRkxBR1M7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUuZmxhZ3MgPSAwOyAgICAgICAgICAgLyogZXhwZWN0IHpsaWIgaGVhZGVyICovXG4gICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7XG4gICAgICAgICAgc3RhdGUuaGVhZC5kb25lID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCEoc3RhdGUud3JhcCAmIDEpIHx8ICAgLyogY2hlY2sgaWYgemxpYiBoZWFkZXIgYWxsb3dlZCAqL1xuICAgICAgICAgICgoKGhvbGQgJiAweGZmKS8qQklUUyg4KSovIDw8IDgpICsgKGhvbGQgPj4gOCkpICUgMzEpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICdpbmNvcnJlY3QgaGVhZGVyIGNoZWNrJztcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGlmICgoaG9sZCAmIDB4MGYpLypCSVRTKDQpKi8gIT09IFpfREVGTEFURUQpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICd1bmtub3duIGNvbXByZXNzaW9uIG1ldGhvZCc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvLy0tLSBEUk9QQklUUyg0KSAtLS0vL1xuICAgICAgICBob2xkID4+Pj0gNDtcbiAgICAgICAgYml0cyAtPSA0O1xuICAgICAgICAvLy0tLS8vXG4gICAgICAgIGxlbiA9IChob2xkICYgMHgwZikvKkJJVFMoNCkqLyArIDg7XG4gICAgICAgIGlmIChzdGF0ZS53Yml0cyA9PT0gMCkge1xuICAgICAgICAgIHN0YXRlLndiaXRzID0gbGVuO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGxlbiA+IHN0YXRlLndiaXRzKSB7XG4gICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCB3aW5kb3cgc2l6ZSc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5kbWF4ID0gMSA8PCBsZW47XG4gICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICB6bGliIGhlYWRlciBva1xcblwiKSk7XG4gICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDEvKmFkbGVyMzIoMEwsIFpfTlVMTCwgMCkqLztcbiAgICAgICAgc3RhdGUubW9kZSA9IGhvbGQgJiAweDIwMCA/IERJQ1RJRCA6IFRZUEU7XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgRkxBR1M6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDE2KTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5mbGFncyA9IGhvbGQ7XG4gICAgICAgIGlmICgoc3RhdGUuZmxhZ3MgJiAweGZmKSAhPT0gWl9ERUZMQVRFRCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ3Vua25vd24gY29tcHJlc3Npb24gbWV0aG9kJztcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4ZTAwMCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ3Vua25vd24gaGVhZGVyIGZsYWdzIHNldCc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQudGV4dCA9ICgoaG9sZCA+PiA4KSAmIDEpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgIC8vPT09IENSQzIoc3RhdGUuY2hlY2ssIGhvbGQpO1xuICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMHhmZjtcbiAgICAgICAgICBoYnVmWzFdID0gKGhvbGQgPj4+IDgpICYgMHhmZjtcbiAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCAyLCAwKTtcbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgIH1cbiAgICAgICAgLy89PT0gSU5JVEJJVFMoKTtcbiAgICAgICAgaG9sZCA9IDA7XG4gICAgICAgIGJpdHMgPSAwO1xuICAgICAgICAvLz09PS8vXG4gICAgICAgIHN0YXRlLm1vZGUgPSBUSU1FO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIFRJTUU6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDMyKTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQudGltZSA9IGhvbGQ7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgLy89PT0gQ1JDNChzdGF0ZS5jaGVjaywgaG9sZClcbiAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDB4ZmY7XG4gICAgICAgICAgaGJ1ZlsxXSA9IChob2xkID4+PiA4KSAmIDB4ZmY7XG4gICAgICAgICAgaGJ1ZlsyXSA9IChob2xkID4+PiAxNikgJiAweGZmO1xuICAgICAgICAgIGhidWZbM10gPSAoaG9sZCA+Pj4gMjQpICYgMHhmZjtcbiAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCA0LCAwKTtcbiAgICAgICAgICAvLz09PVxuICAgICAgICB9XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5tb2RlID0gT1M7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgT1M6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDE2KTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQueGZsYWdzID0gKGhvbGQgJiAweGZmKTtcbiAgICAgICAgICBzdGF0ZS5oZWFkLm9zID0gKGhvbGQgPj4gOCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgLy89PT0gQ1JDMihzdGF0ZS5jaGVjaywgaG9sZCk7XG4gICAgICAgICAgaGJ1ZlswXSA9IGhvbGQgJiAweGZmO1xuICAgICAgICAgIGhidWZbMV0gPSAoaG9sZCA+Pj4gOCkgJiAweGZmO1xuICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApO1xuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgfVxuICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICBob2xkID0gMDtcbiAgICAgICAgYml0cyA9IDA7XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUubW9kZSA9IEVYTEVOO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIEVYTEVOOlxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDA0MDApIHtcbiAgICAgICAgICAvLz09PSBORUVEQklUUygxNik7ICovXG4gICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIHN0YXRlLmxlbmd0aCA9IGhvbGQ7XG4gICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmFfbGVuID0gaG9sZDtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgICAvLz09PSBDUkMyKHN0YXRlLmNoZWNrLCBob2xkKTtcbiAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMHhmZjtcbiAgICAgICAgICAgIGhidWZbMV0gPSAoaG9sZCA+Pj4gOCkgJiAweGZmO1xuICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7XG4gICAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgfVxuICAgICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgICAgaG9sZCA9IDA7XG4gICAgICAgICAgYml0cyA9IDA7XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLmV4dHJhID0gbnVsbC8qWl9OVUxMKi87XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUubW9kZSA9IEVYVFJBO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIEVYVFJBOlxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDA0MDApIHtcbiAgICAgICAgICBjb3B5ID0gc3RhdGUubGVuZ3RoO1xuICAgICAgICAgIGlmIChjb3B5ID4gaGF2ZSkgeyBjb3B5ID0gaGF2ZTsgfVxuICAgICAgICAgIGlmIChjb3B5KSB7XG4gICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgICAgICBsZW4gPSBzdGF0ZS5oZWFkLmV4dHJhX2xlbiAtIHN0YXRlLmxlbmd0aDtcbiAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5oZWFkLmV4dHJhKSB7XG4gICAgICAgICAgICAgICAgLy8gVXNlIHVudHlwZWQgYXJyYXkgZm9yIG1vcmUgY29udmVuaWVudCBwcm9jZXNzaW5nIGxhdGVyXG4gICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5leHRyYSA9IG5ldyBBcnJheShzdGF0ZS5oZWFkLmV4dHJhX2xlbik7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgdXRpbHMuYXJyYXlTZXQoXG4gICAgICAgICAgICAgICAgc3RhdGUuaGVhZC5leHRyYSxcbiAgICAgICAgICAgICAgICBpbnB1dCxcbiAgICAgICAgICAgICAgICBuZXh0LFxuICAgICAgICAgICAgICAgIC8vIGV4dHJhIGZpZWxkIGlzIGxpbWl0ZWQgdG8gNjU1MzYgYnl0ZXNcbiAgICAgICAgICAgICAgICAvLyAtIG5vIG5lZWQgZm9yIGFkZGl0aW9uYWwgc2l6ZSBjaGVja1xuICAgICAgICAgICAgICAgIGNvcHksXG4gICAgICAgICAgICAgICAgLypsZW4gKyBjb3B5ID4gc3RhdGUuaGVhZC5leHRyYV9tYXggLSBsZW4gPyBzdGF0ZS5oZWFkLmV4dHJhX21heCA6IGNvcHksKi9cbiAgICAgICAgICAgICAgICBsZW5cbiAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgICAgLy96bWVtY3B5KHN0YXRlLmhlYWQuZXh0cmEgKyBsZW4sIG5leHQsXG4gICAgICAgICAgICAgIC8vICAgICAgICBsZW4gKyBjb3B5ID4gc3RhdGUuaGVhZC5leHRyYV9tYXggP1xuICAgICAgICAgICAgICAvLyAgICAgICAgc3RhdGUuaGVhZC5leHRyYV9tYXggLSBsZW4gOiBjb3B5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBpbnB1dCwgY29weSwgbmV4dCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBoYXZlIC09IGNvcHk7XG4gICAgICAgICAgICBuZXh0ICs9IGNvcHk7XG4gICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHN0YXRlLmxlbmd0aCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5sZW5ndGggPSAwO1xuICAgICAgICBzdGF0ZS5tb2RlID0gTkFNRTtcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBOQU1FOlxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDA4MDApIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBjb3B5ID0gMDtcbiAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAvLyBUT0RPOiAyIG9yIDEgYnl0ZXM/XG4gICAgICAgICAgICBsZW4gPSBpbnB1dFtuZXh0ICsgY29weSsrXTtcbiAgICAgICAgICAgIC8qIHVzZSBjb25zdGFudCBsaW1pdCBiZWNhdXNlIGluIGpzIHdlIHNob3VsZCBub3QgcHJlYWxsb2NhdGUgbWVtb3J5ICovXG4gICAgICAgICAgICBpZiAoc3RhdGUuaGVhZCAmJiBsZW4gJiZcbiAgICAgICAgICAgICAgICAoc3RhdGUubGVuZ3RoIDwgNjU1MzYgLypzdGF0ZS5oZWFkLm5hbWVfbWF4Ki8pKSB7XG4gICAgICAgICAgICAgIHN0YXRlLmhlYWQubmFtZSArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGxlbik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSB3aGlsZSAobGVuICYmIGNvcHkgPCBoYXZlKTtcblxuICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaW5wdXQsIGNvcHksIG5leHQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBoYXZlIC09IGNvcHk7XG4gICAgICAgICAgbmV4dCArPSBjb3B5O1xuICAgICAgICAgIGlmIChsZW4pIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQubmFtZSA9IG51bGw7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUubGVuZ3RoID0gMDtcbiAgICAgICAgc3RhdGUubW9kZSA9IENPTU1FTlQ7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgQ09NTUVOVDpcbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgxMDAwKSB7XG4gICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgY29weSA9IDA7XG4gICAgICAgICAgZG8ge1xuICAgICAgICAgICAgbGVuID0gaW5wdXRbbmV4dCArIGNvcHkrK107XG4gICAgICAgICAgICAvKiB1c2UgY29uc3RhbnQgbGltaXQgYmVjYXVzZSBpbiBqcyB3ZSBzaG91bGQgbm90IHByZWFsbG9jYXRlIG1lbW9yeSAqL1xuICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQgJiYgbGVuICYmXG4gICAgICAgICAgICAgICAgKHN0YXRlLmxlbmd0aCA8IDY1NTM2IC8qc3RhdGUuaGVhZC5jb21tX21heCovKSkge1xuICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmNvbW1lbnQgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShsZW4pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7XG4gICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBpbnB1dCwgY29weSwgbmV4dCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGhhdmUgLT0gY29weTtcbiAgICAgICAgICBuZXh0ICs9IGNvcHk7XG4gICAgICAgICAgaWYgKGxlbikgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7XG4gICAgICAgICAgc3RhdGUuaGVhZC5jb21tZW50ID0gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5tb2RlID0gSENSQztcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBIQ1JDOlxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDAyMDApIHtcbiAgICAgICAgICAvLz09PSBORUVEQklUUygxNik7ICovXG4gICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIGlmIChob2xkICE9PSAoc3RhdGUuY2hlY2sgJiAweGZmZmYpKSB7XG4gICAgICAgICAgICBzdHJtLm1zZyA9ICdoZWFkZXIgY3JjIG1pc21hdGNoJztcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0gSU5JVEJJVFMoKTtcbiAgICAgICAgICBob2xkID0gMDtcbiAgICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLmhjcmMgPSAoKHN0YXRlLmZsYWdzID4+IDkpICYgMSk7XG4gICAgICAgICAgc3RhdGUuaGVhZC5kb25lID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAwO1xuICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIERJQ1RJRDpcbiAgICAgICAgLy89PT0gTkVFREJJVFMoMzIpOyAqL1xuICAgICAgICB3aGlsZSAoYml0cyA8IDMyKSB7XG4gICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgfVxuICAgICAgICAvLz09PS8vXG4gICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IHpzd2FwMzIoaG9sZCk7XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5tb2RlID0gRElDVDtcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBESUNUOlxuICAgICAgICBpZiAoc3RhdGUuaGF2ZWRpY3QgPT09IDApIHtcbiAgICAgICAgICAvLy0tLSBSRVNUT1JFKCkgLS0tXG4gICAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDtcbiAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGxlZnQ7XG4gICAgICAgICAgc3RybS5uZXh0X2luID0gbmV4dDtcbiAgICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTtcbiAgICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDtcbiAgICAgICAgICBzdGF0ZS5iaXRzID0gYml0cztcbiAgICAgICAgICAvLy0tLVxuICAgICAgICAgIHJldHVybiBaX05FRURfRElDVDtcbiAgICAgICAgfVxuICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAxLyphZGxlcjMyKDBMLCBaX05VTEwsIDApKi87XG4gICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIFRZUEU6XG4gICAgICAgIGlmIChmbHVzaCA9PT0gWl9CTE9DSyB8fCBmbHVzaCA9PT0gWl9UUkVFUykgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBUWVBFRE86XG4gICAgICAgIGlmIChzdGF0ZS5sYXN0KSB7XG4gICAgICAgICAgLy8tLS0gQllURUJJVFMoKSAtLS0vL1xuICAgICAgICAgIGhvbGQgPj4+PSBiaXRzICYgNztcbiAgICAgICAgICBiaXRzIC09IGJpdHMgJiA3O1xuICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQ0hFQ0s7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0gTkVFREJJVFMoMyk7ICovXG4gICAgICAgIHdoaWxlIChiaXRzIDwgMykge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5sYXN0ID0gKGhvbGQgJiAweDAxKS8qQklUUygxKSovO1xuICAgICAgICAvLy0tLSBEUk9QQklUUygxKSAtLS0vL1xuICAgICAgICBob2xkID4+Pj0gMTtcbiAgICAgICAgYml0cyAtPSAxO1xuICAgICAgICAvLy0tLS8vXG5cbiAgICAgICAgc3dpdGNoICgoaG9sZCAmIDB4MDMpLypCSVRTKDIpKi8pIHtcbiAgICAgICAgICBjYXNlIDA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBzdG9yZWQgYmxvY2sgKi9cbiAgICAgICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgIHN0b3JlZCBibG9jayVzXFxuXCIsXG4gICAgICAgICAgICAvLyAgICAgICAgc3RhdGUubGFzdCA/IFwiIChsYXN0KVwiIDogXCJcIikpO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IFNUT1JFRDtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIGNhc2UgMTogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIGZpeGVkIGJsb2NrICovXG4gICAgICAgICAgICBmaXhlZHRhYmxlcyhzdGF0ZSk7XG4gICAgICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgICBmaXhlZCBjb2RlcyBibG9jayVzXFxuXCIsXG4gICAgICAgICAgICAvLyAgICAgICAgc3RhdGUubGFzdCA/IFwiIChsYXN0KVwiIDogXCJcIikpO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTl87ICAgICAgICAgICAgIC8qIGRlY29kZSBjb2RlcyAqL1xuICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX1RSRUVTKSB7XG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKDIpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSAyO1xuICAgICAgICAgICAgICBiaXRzIC09IDI7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgY2FzZSAyOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogZHluYW1pYyBibG9jayAqL1xuICAgICAgICAgICAgLy9UcmFjZXYoKHN0ZGVyciwgXCJpbmZsYXRlOiAgICAgZHluYW1pYyBjb2RlcyBibG9jayVzXFxuXCIsXG4gICAgICAgICAgICAvLyAgICAgICAgc3RhdGUubGFzdCA/IFwiIChsYXN0KVwiIDogXCJcIikpO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRBQkxFO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgY2FzZSAzOlxuICAgICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBibG9jayB0eXBlJztcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgIH1cbiAgICAgICAgLy8tLS0gRFJPUEJJVFMoMikgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IDI7XG4gICAgICAgIGJpdHMgLT0gMjtcbiAgICAgICAgLy8tLS0vL1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgU1RPUkVEOlxuICAgICAgICAvLy0tLSBCWVRFQklUUygpIC0tLS8vIC8qIGdvIHRvIGJ5dGUgYm91bmRhcnkgKi9cbiAgICAgICAgaG9sZCA+Pj49IGJpdHMgJiA3O1xuICAgICAgICBiaXRzIC09IGJpdHMgJiA3O1xuICAgICAgICAvLy0tLS8vXG4gICAgICAgIC8vPT09IE5FRURCSVRTKDMyKTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBpZiAoKGhvbGQgJiAweGZmZmYpICE9PSAoKGhvbGQgPj4+IDE2KSBeIDB4ZmZmZikpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIHN0b3JlZCBibG9jayBsZW5ndGhzJztcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRlLmxlbmd0aCA9IGhvbGQgJiAweGZmZmY7XG4gICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgICAgc3RvcmVkIGxlbmd0aCAldVxcblwiLFxuICAgICAgICAvLyAgICAgICAgc3RhdGUubGVuZ3RoKSk7XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5tb2RlID0gQ09QWV87XG4gICAgICAgIGlmIChmbHVzaCA9PT0gWl9UUkVFUykgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBDT1BZXzpcbiAgICAgICAgc3RhdGUubW9kZSA9IENPUFk7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgQ09QWTpcbiAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDtcbiAgICAgICAgaWYgKGNvcHkpIHtcbiAgICAgICAgICBpZiAoY29weSA+IGhhdmUpIHsgY29weSA9IGhhdmU7IH1cbiAgICAgICAgICBpZiAoY29weSA+IGxlZnQpIHsgY29weSA9IGxlZnQ7IH1cbiAgICAgICAgICBpZiAoY29weSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAvLy0tLSB6bWVtY3B5KHB1dCwgbmV4dCwgY29weSk7IC0tLVxuICAgICAgICAgIHV0aWxzLmFycmF5U2V0KG91dHB1dCwgaW5wdXQsIG5leHQsIGNvcHksIHB1dCk7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIGhhdmUgLT0gY29weTtcbiAgICAgICAgICBuZXh0ICs9IGNvcHk7XG4gICAgICAgICAgbGVmdCAtPSBjb3B5O1xuICAgICAgICAgIHB1dCArPSBjb3B5O1xuICAgICAgICAgIHN0YXRlLmxlbmd0aCAtPSBjb3B5O1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgICAgc3RvcmVkIGVuZFxcblwiKSk7XG4gICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgVEFCTEU6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDE0KTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAxNCkge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5ubGVuID0gKGhvbGQgJiAweDFmKS8qQklUUyg1KSovICsgMjU3O1xuICAgICAgICAvLy0tLSBEUk9QQklUUyg1KSAtLS0vL1xuICAgICAgICBob2xkID4+Pj0gNTtcbiAgICAgICAgYml0cyAtPSA1O1xuICAgICAgICAvLy0tLS8vXG4gICAgICAgIHN0YXRlLm5kaXN0ID0gKGhvbGQgJiAweDFmKS8qQklUUyg1KSovICs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sZW5ndGhzIHNldCc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgIGNvZGUgbGVuZ3RocyBva1xcblwiKSk7XG4gICAgICAgIHN0YXRlLmhhdmUgPSAwO1xuICAgICAgICBzdGF0ZS5tb2RlID0gQ09ERUxFTlM7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgQ09ERUxFTlM6XG4gICAgICAgIHdoaWxlIChzdGF0ZS5oYXZlIDwgc3RhdGUubmxlbiArIHN0YXRlLm5kaXN0KSB7XG4gICAgICAgICAgZm9yICg7Oykge1xuICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmxlbmNvZGVbaG9sZCAmICgoMSA8PCBzdGF0ZS5sZW5iaXRzKSAtIDEpXTsvKkJJVFMoc3RhdGUubGVuYml0cykqL1xuICAgICAgICAgICAgaGVyZV9iaXRzID0gaGVyZSA+Pj4gMjQ7XG4gICAgICAgICAgICBoZXJlX29wID0gKGhlcmUgPj4+IDE2KSAmIDB4ZmY7XG4gICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiAweGZmZmY7XG5cbiAgICAgICAgICAgIGlmICgoaGVyZV9iaXRzKSA8PSBiaXRzKSB7IGJyZWFrOyB9XG4gICAgICAgICAgICAvLy0tLSBQVUxMQllURSgpIC0tLS8vXG4gICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaGVyZV92YWwgPCAxNikge1xuICAgICAgICAgICAgLy8tLS0gRFJPUEJJVFMoaGVyZS5iaXRzKSAtLS0vL1xuICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzO1xuICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgICAgc3RhdGUubGVuc1tzdGF0ZS5oYXZlKytdID0gaGVyZV92YWw7XG4gICAgICAgICAgfVxuICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgaWYgKGhlcmVfdmFsID09PSAxNikge1xuICAgICAgICAgICAgICAvLz09PSBORUVEQklUUyhoZXJlLmJpdHMgKyAyKTtcbiAgICAgICAgICAgICAgbiA9IGhlcmVfYml0cyArIDI7XG4gICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikge1xuICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgLy89PT0vL1xuICAgICAgICAgICAgICAvLy0tLSBEUk9QQklUUyhoZXJlLmJpdHMpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzO1xuICAgICAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlID09PSAwKSB7XG4gICAgICAgICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBiaXQgbGVuZ3RoIHJlcGVhdCc7XG4gICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBsZW4gPSBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUgLSAxXTtcbiAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDB4MDMpOy8vQklUUygyKTtcbiAgICAgICAgICAgICAgLy8tLS0gRFJPUEJJVFMoMikgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IDI7XG4gICAgICAgICAgICAgIGJpdHMgLT0gMjtcbiAgICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAoaGVyZV92YWwgPT09IDE3KSB7XG4gICAgICAgICAgICAgIC8vPT09IE5FRURCSVRTKGhlcmUuYml0cyArIDMpO1xuICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgMztcbiAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7XG4gICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgICAgbGVuID0gMDtcbiAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDB4MDcpOy8vQklUUygzKTtcbiAgICAgICAgICAgICAgLy8tLS0gRFJPUEJJVFMoMykgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IDM7XG4gICAgICAgICAgICAgIGJpdHMgLT0gMztcbiAgICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgIC8vPT09IE5FRURCSVRTKGhlcmUuYml0cyArIDcpO1xuICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgNztcbiAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7XG4gICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgICAgbGVuID0gMDtcbiAgICAgICAgICAgICAgY29weSA9IDExICsgKGhvbGQgJiAweDdmKTsvL0JJVFMoNyk7XG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKDcpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSA3O1xuICAgICAgICAgICAgICBiaXRzIC09IDc7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlICsgY29weSA+IHN0YXRlLm5sZW4gKyBzdGF0ZS5uZGlzdCkge1xuICAgICAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIGJpdCBsZW5ndGggcmVwZWF0JztcbiAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICAg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ICAvLy0tLS8vXG4gICAgICAgIH1cbiAgICAgICAgaWYgKGhlcmVfb3AgJiYgKGhlcmVfb3AgJiAweGYwKSA9PT0gMCkge1xuICAgICAgICAgIGxhc3RfYml0cyA9IGhlcmVfYml0cztcbiAgICAgICAgICBsYXN0X29wID0gaGVyZV9vcDtcbiAgICAgICAgICBsYXN0X3ZhbCA9IGhlcmVfdmFsO1xuICAgICAgICAgIGZvciAoOzspIHtcbiAgICAgICAgICAgIGhlcmUgPSBzdGF0ZS5sZW5jb2RlW2xhc3RfdmFsICtcbiAgICAgICAgICAgICAgICAgICAgKChob2xkICYgKCgxIDw8IChsYXN0X2JpdHMgKyBsYXN0X29wKSkgLSAxKSkvKkJJVFMobGFzdC5iaXRzICsgbGFzdC5vcCkqLyA+PiBsYXN0X2JpdHMpXTtcbiAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0O1xuICAgICAgICAgICAgaGVyZV9vcCA9IChoZXJlID4+PiAxNikgJiAweGZmO1xuICAgICAgICAgICAgaGVyZV92YWwgPSBoZXJlICYgMHhmZmZmO1xuXG4gICAgICAgICAgICBpZiAoKGxhc3RfYml0cyArIGhlcmVfYml0cykgPD0gYml0cykgeyBicmVhazsgfVxuICAgICAgICAgICAgLy8tLS0gUFVMTEJZVEUoKSAtLS0vL1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICB9XG4gICAgICAgICAgLy8tLS0gRFJPUEJJVFMobGFzdC5iaXRzKSAtLS0vL1xuICAgICAgICAgIGhvbGQgPj4+PSBsYXN0X2JpdHM7XG4gICAgICAgICAgYml0cyAtPSBsYXN0X2JpdHM7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIHN0YXRlLmJhY2sgKz0gbGFzdF9iaXRzO1xuICAgICAgICB9XG4gICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7XG4gICAgICAgIC8vLS0tLy9cbiAgICAgICAgc3RhdGUuYmFjayArPSBoZXJlX2JpdHM7XG4gICAgICAgIHN0YXRlLmxlbmd0aCA9IGhlcmVfdmFsO1xuICAgICAgICBpZiAoaGVyZV9vcCA9PT0gMCkge1xuICAgICAgICAgIC8vVHJhY2V2digoc3RkZXJyLCBoZXJlLnZhbCA+PSAweDIwICYmIGhlcmUudmFsIDwgMHg3ZiA/XG4gICAgICAgICAgLy8gICAgICAgIFwiaW5mbGF0ZTogICAgICAgICBsaXRlcmFsICclYydcXG5cIiA6XG4gICAgICAgICAgLy8gICAgICAgIFwiaW5mbGF0ZTogICAgICAgICBsaXRlcmFsIDB4JTAyeFxcblwiLCBoZXJlLnZhbCkpO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBMSVQ7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGhlcmVfb3AgJiAzMikge1xuICAgICAgICAgIC8vVHJhY2V2digoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgICAgZW5kIG9mIGJsb2NrXFxuXCIpKTtcbiAgICAgICAgICBzdGF0ZS5iYWNrID0gLTE7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGhlcmVfb3AgJiA2NCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgbGl0ZXJhbC9sZW5ndGggY29kZSc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVx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zID0gaGVyZSA+Pj4gMjQ7XG4gICAgICAgICAgICBoZXJlX29wID0gKGhlcmUgPj4+IDE2KSAmIDB4ZmY7XG4gICAgICAgICAgICBoZXJlX3ZhbCA9IGhlcmUgJiAweGZmZmY7XG5cbiAgICAgICAgICAgIGlmICgobGFzdF9iaXRzICsgaGVyZV9iaXRzKSA8PSBiaXRzKSB7IGJyZWFrOyB9XG4gICAgICAgICAgICAvLy0tLSBQVUxMQllURSgpIC0tLS8vXG4gICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIH1cbiAgICAgICAgICAvLy0tLSBEUk9QQklUUyhsYXN0LmJpdHMpIC0tLS8vXG4gICAgICAgICAgaG9sZCA+Pj49IGxhc3RfYml0cztcbiAgICAgICAgICBiaXRzIC09IGxhc3RfYml0cztcbiAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgc3RhdGUuYmFjayArPSBsYXN0X2JpdHM7XG4gICAgICAgIH1cbiAgICAgICAgLy8tLS0gRFJPUEJJVFMoaGVyZS5iaXRzKSAtLS0vL1xuICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzO1xuICAgICAgICBiaXRzIC09IGhlcmVfYml0cztcbiAgICAgICAgLy8tLS0vL1xuICAgICAgICBzdGF0ZS5iYWNrICs9IGhlcmVfYml0cztcbiAgICAgICAgaWYgKGhlcmVfb3AgJiA2NCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgZGlzdGFuY2UgY29kZSc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5vZmZzZXQg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HkgPiBzdGF0ZS5sZW5ndGgpIHsgY29weSA9IHN0YXRlLmxlbmd0aDsgfVxuLy8gICAgICAgICAgaWYgKGNvcHkgPiBsZWZ0KSB7IGNvcHkgPSBsZWZ0OyB9XG4vLyAgICAgICAgICBsZWZ0IC09IGNvcHk7XG4vLyAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTtcbi8vICAgICAgICAgIGRvIHtcbi8vICAgICAgICAgICAgb3V0cHV0W3B1dCsrXSA9IDA7XG4vLyAgICAgICAgICB9IHdoaWxlICgtLWNvcHkpO1xuLy8gICAgICAgICAgaWYgKHN0YXRlLmxlbmd0aCA9PT0gMCkgeyBzdGF0ZS5tb2RlID0gTEVOOyB9XG4vLyAgICAgICAgICBicmVhaztcbi8vI2VuZGlmXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChjb3B5ID4gc3RhdGUud25leHQpIHtcbiAgICAgICAgICAgIGNvcHkgLT0gc3RhdGUud25leHQ7XG4gICAgICAgICAgICBmcm9tID0gc3RhdGUud3NpemUgLSBjb3B5O1xuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGZyb20gPSBzdGF0ZS53bmV4dCAtIGNvcHk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChjb3B5ID4gc3RhdGUubGVuZ3RoKSB7IGNvcHkgPSBzdGF0ZS5sZW5ndGg7IH1cbiAgICAgICAgICBmcm9tX3NvdXJjZSA9IHN0YXRlLndpbmRvdztcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBjb3B5IGZyb20gb3V0cHV0ICovXG4gICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7XG4gICAgICAgICAgZnJvbSA9IHB1dCAtIHN0YXRlLm9mZnNldDtcbiAgICAgICAgICBjb3B5ID0gc3RhdGUubGVuZ3RoO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjb3B5ID4gbGVmdCkgeyBjb3B5ID0gbGVmdDsgfVxuICAgICAgICBsZWZ0IC09IGNvcHk7XG4gICAgICAgIHN0YXRlLmxlbmd0aCAtPSBjb3B5O1xuICAgICAgICBkbyB7XG4gICAgICAgICAgb3V0cHV0W3B1dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107XG4gICAgICAgIH0gd2hpbGUgKC0tY29weSk7XG4gICAgICAgIGlmIChzdGF0ZS5sZW5ndGggPT09IDApIHsgc3RhdGUubW9kZSA9IExFTjsgfVxuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgTElUOlxuICAgICAgICBpZiAobGVmdCA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgb3V0cHV0W3B1dCsrXSA9IHN0YXRlLmxlbmd0aDtcbiAgICAgICAgbGVmdC0tO1xuICAgICAgICBzdGF0ZS5tb2RlID0gTEVOO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgQ0hFQ0s6XG4gICAgICAgIGlmIChzdGF0ZS53cmFwKSB7XG4gICAgICAgICAgLy89PT0gTkVFREJJVFMoMzIpO1xuICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHtcbiAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgLy8gVXNlICd8JyBpbnN0ZWFkIG9mICcrJyB0byBtYWtlIHN1cmUgdGhhdCByZXN1bHQgaXMgc2lnbmVkXG4gICAgICAgICAgICBob2xkIHw9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIF9vdXQgLT0gbGVmdDtcbiAgICAgICAgICBzdHJtLnRvdGFsX291dCArPSBfb3V0O1xuICAgICAgICAgIHN0YXRlLnRvdGFsICs9IF9vdXQ7XG4gICAgICAgICAga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gIC8vPT09IE5FRURCSVRTKDMyKTtcbiAgICAgICAgICB3aGlsZSAoYml0cyA8IDMyKSB7XG4gICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgIH1cbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgaWYgKGhvbGQgIT09IChzdGF0ZS50b3RhbCAmIDB4ZmZmZmZmZmYpKSB7XG4gICAgICAgICAgICBzdHJtLm1zZyA9ICdpbmNvcnJlY3QgbGVuZ3RoIGNoZWNrJztcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0gSU5JVEJJVFMoKTtcbiAgICAgICAgICBob2xkID0gMDtcbiAgICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgLy9UcmFjZXYoKHN0ZGVyciwgXCJpbmZsYXRlOiAgIGxlbmd0aCBtYXRjaGVzIHRyYWlsZXJcXG5cIikpO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRlLm1vZGUgPSBET05FO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIERPTkU6XG4gICAgICAgIHJldCA9IFpfU1RSRUFNX0VORDtcbiAgICAgICAgYnJlYWsgaW5mX2xlYXZlO1xuICAgICAgY2FzZSBCQUQ6XG4gICAgICAgIHJldCA9IFpfREFUQV9FUlJPUjtcbiAgICAgICAgYnJlYWsgaW5mX2xlYXZlO1xuICAgICAgY2FzZSBNRU06XG4gICAgICAgIHJldHVybiBaX01FTV9FUlJPUjtcbiAgICAgIGNhc2UgU1lOQzpcbiAgICAgICAgLyogZmFsbHMgdG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gaWYgKHR5cGUgPT09IENPREVTKSB7XG4gICAgYmFzZSA9IGV4dHJhID0gd29yazsgICAgLyogZHVtbXkgdmFsdWUtLW5vdCB1c2VkICovXG4gICAgZW5kID0gMTk7XG5cbiAgfSBlbHNlIGlmICh0eXBlID09PSBMRU5TKSB7XG4gICAgYmFzZSA9IGxiYXNlO1xuICAgIGJhc2VfaW5kZXggLT0gMjU3O1xuICAgIGV4dHJhID0gbGV4dDtcbiAgICBleHRyYV9pbmRleCAtPSAyNTc7XG4gICAgZW5kID0gMjU2O1xuXG4gIH0gZWxzZSB7ICAgICAgICAgICAgICAgICAgICAvKiBESVNUUyAqL1xuICAgIGJhc2UgPSBkYmFzZTtcbiAgICBleHRyYSA9IGRleHQ7XG4gICAgZW5kID0gLTE7XG4gIH1cblxuICAvKiBpbml0aWFsaXplIG9wdHMgZm9yIGxvb3AgKi9cbiAgaHVmZiA9IDA7ICAgICAgICAgICAgICAgICAgIC8qIHN0YXJ0aW5nIGNvZGUgKi9cbiAgc3ltID0gMDsgICAgICAgICAgICAgICAgICAgIC8qIHN0YXJ0aW5nIGNvZGUgc3ltYm9sICovXG4gIGxlbiA9IG1pbjsgICAgICAgICAgICAgICAgICAvKiBzdGFydGluZyBjb2RlIGxlbmd0aCAqL1xuICBuZXh0ID0gdGFibGVfaW5kZXg7ICAgICAgICAgICAgICAvKiBjdXJyZW50IHRhYmxlIHRvIGZpbGwgaW4gKi9cbiAgY3VyciA9IHJvb3Q7ICAgICAgICAgICAgICAgIC8qIGN1cnJlbnQgdGFibGUgaW5kZXggYml0cyAqL1xuICBkcm9wID0gMDsgICAgICAgICAgICAgICAgICAgLyogY3VycmVudCBiaXRzIHRvIGRyb3AgZnJvbSBjb2RlIGZvciBpbmRleCAqL1xuICBsb3cgPSAtMTsgICAgICAgICAgICAgICAgICAgLyogdHJpZ2dlciBuZXcgc3ViLXRhYmxlIHdoZW4gbGVuID4gcm9vdCAqL1xuICB1c2VkID0gMSA8PCByb290OyAgICAgICAg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T09PT09PT09PT09Ki9cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG5cblxuLy92YXIgWl9GSUxURVJFRCAgICAgICAgICA9IDE7XG4vL3ZhciBaX0hVRkZNQU5fT05MWSAgICAgID0gMjtcbi8vdmFyIFpfUkxFICAgICAgICAgICAgICAgPSAzO1xudmFyIFpfRklYRUQgICAgICAgICAgICAgICA9IDQ7XG4vL3ZhciBaX0RFRkFVTFRfU1RSQVRFR1kgID0gMDtcblxuLyogUG9zc2libGUgdmFsdWVzIG9mIHRoZSBkYXRhX3R5cGUgZmllbGQgKHRob3VnaCBzZWUgaW5mbGF0ZSgpKSAqL1xudmFyIFpfQklOQVJZICAgICAgICAgICAgICA9IDA7XG52YXIgWl9URVhUICAgICAgICAgICAgICAgID0gMTtcbi8vdmFyIFpfQVNDSUkgICAgICAgICAgICAgPSAxOyAvLyA9IFpfVEVYVFxudmFyIFpfVU5LTk9XTiAgICAgICAgICAgICA9IDI7XG5cbi8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG5cblxuZnVuY3Rpb24gemVybyhidWYpIHsgdmFyIGxlbiA9IGJ1Zi5sZW5ndGg7IHdoaWxlICgtLWxlbiA+PSAwKSB7IGJ1ZltsZW5dID0gMDsgfSB9XG5cbi8vIEZyb20genV0aWwuaFxuXG52YXIgU1RPUkVEX0JMT0NLID0gMDtcbnZhciBTVEFUSUNfVFJFRVMgPSAxO1xudmFyIERZTl9UUkVFUyAgICA9IDI7XG4vKiBUaGUgdGhyZWUga2luZHMgb2YgYmxvY2sgdHlwZSAqL1xuXG52YXIgTUlOX01BVENIICAgID0gMztcbnZhciBNQVhfTUFUQ0ggICAgPSAyNTg7XG4vKiBUaGUgbWluaW11bSBhbmQgbWF4aW11bSBtYXRjaCBsZW5ndGhzICovXG5cbi8vIEZyb20gZGVmbGF0ZS5oXG4vKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbiAqIEludGVybmFsIGNvbXByZXNzaW9uIHN0YXRlLlxuICovXG5cbnZhciBMRU5HVEhfQ09ERVMgID0gMjk7XG4vKiBudW1iZXIgb2YgbGVuZ3RoIGNvZGVzLCBub3QgY291bnRpbmcgdGhlIHNwZWNpYWwgRU5EX0JMT0NLIGNvZGUgKi9cblxudmFyIExJVEVSQUxTICAgICAgPSAyNTY7XG4vKiBudW1iZXIgb2YgbGl0ZXJhbCBieXRlcyAwLi4yNTUgKi9cblxudmFyIExfQ09ERVMgICAgICAgPSBMSVRFUkFMUyArIDEgKyBMRU5HVEhfQ09ERVM7XG4vKiBudW1iZXIgb2YgTGl0ZXJhbCBvciBMZW5ndGggY29kZXMsIGluY2x1ZGluZyB0aGUgRU5EX0JMT0NLIGNvZGUgKi9cblxudmFyIERfQ09ERVMgICAgICAgPSAzMDtcbi8qIG51bWJlciBvZiBkaXN0YW5jZSBjb2RlcyAqL1xuXG52YXIgQkxfQ09ERVMgICAgICA9IDE5O1xuLyogbnVtYmVyIG9mIGNvZGVzIHVzZWQgdG8gdHJhbnNmZXIgdGhlIGJpdCBsZW5ndGhzICovXG5cbnZhciBIRUFQX1NJWkUgICAgID0gMiAqIExfQ09ERVMgKyAxO1xuLyogbWF4aW11bSBoZWFwIHNpemUgKi9cblxudmFyIE1BWF9CSVRTICAgICAgPSAxNTtcbi8qIEFsbCBjb2RlcyBtdXN0IG5vdCBleGNlZWQgTUFYX0JJVFMgYml0cyAqL1xuXG52YXIgQnVmX3NpemUgICAgICA9IDE2O1xuLyogc2l6ZSBvZiBiaXQgYnVmZmVyIGluIGJpX2J1ZiAqL1xuXG5cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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9IGxlbiA8PSAxNVxuICovXG5mdW5jdGlvbiBiaV9yZXZlcnNlKGNvZGUsIGxlbikge1xuICB2YXIgcmVzID0gMDtcbiAgZG8ge1xuICAgIHJlcyB8PSBjb2RlICYgMTtcbiAgICBjb2RlID4+Pj0gMTtcbiAgICByZXMgPDw9IDE7XG4gIH0gd2hpbGUgKC0tbGVuID4gMCk7XG4gIHJldHVybiByZXMgPj4+IDE7XG59XG5cblxuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4gKiBGbHVzaCB0aGUgYml0IGJ1ZmZlciwga2VlcGluZyBhdCBtb3N0IDcgYml0cyBpbiBpdC5cbiAqL1xuZnVuY3Rpb24gYmlfZmx1c2gocykge1xuICBpZiAocy5iaV92YWxpZCA9PT0gMTYpIHtcbiAgICBwdXRfc2hvcnQocywgcy5iaV9idWYpO1xuICAgIHMuYmlfYnVmID0gMDtcbiAgICBzLmJpX3ZhbGlkID0gMDtcblxuICB9IGVsc2UgaWYgKHMuYmlfdmFsaWQgPj0gOCkge1xuICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gcy5iaV9idWYgJiAweGZmO1xuICAgIHMuYmlfYnVmID4+PSA4O1xuICAgIHMuYmlfdmFsaWQgLT0gODtcbiAgfVxufVxuXG5cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuICogQ29tcHV0ZSB0aGUgb3B0aW1hbCBiaXQgbGVuZ3RocyBmb3IgYSB0cmVlIGFuZCB1cGRhdGUgdGhlIHRvdGFsIGJpdCBsZW5ndGhcbiAqIGZvciB0aGUgY3VycmVudCBibG9jay5cbiAqIElOIGFzc2VydGlvbjogdGhlIGZpZWxkcyBmcmVxIGFuZCBkYWQgYXJlIHNldCwgaGVhcFtoZWFwX21heF0gYW5kXG4gKiAgICBhYm92Z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AyICsgMV0pO1xuICAgICAgbGMgPSBzLnBlbmRpbmdfYnVmW3MubF9idWYgKyBseF07XG4gICAgICBseCsrO1xuXG4gICAgICBpZiAoZGlzdCA9PT0gMCkge1xuICAgICAgICBzZW5kX2NvZGUocywgbGMsIGx0cmVlKTsgLyogc2VuZCBhIGxpdGVyYWwgYnl0ZSAqL1xuICAgICAgICAvL1RyYWNlY3YoaXNncmFwaChsYyksIChzdGRlcnIsXCIgJyVjJyBcIiwgbGMpKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIC8qIEhlcmUsIGxjIGlzIHRoZSBtYXRjaCBsZW5ndGggLSBNSU5fTUFUQ0ggKi9cbiAgICAgICAgY29kZSA9IF9sZW5ndGhfY29kZVtsY107XG4gICAgICAgIHNlbmRfY29kZShzLCBjb2RlICsgTElURVJBTFMgKyAxLCBsdHJlZSk7IC8qIHNlbmQgdGhlIGxlbmd0aCBjb2RlICovXG4gICAgICAgIGV4dHJhID0gZXh0cmFfbGJpdHNbY29kZV07XG4gICAgICAgIGlmIChleHRyYSAhPT0gMCkge1xuICAgICAgICAgIGxjIC09IGJhc2VfbGVuZ3RoW2NvZGVdO1xuICAgICAgICAgIHNlbmRfYml0cyhzLCBsYywgZXh0cmEpOyAgICAgICAvKiBzZW5kIHRoZSBleHRyYSBsZW5ndGggYml0cyAqL1xuICAgICAgICB9XG4gICAgICAgIGRpc3QtLTsgLyogZGlzdCBpcyBub3cgdGhlIG1hdGNoIGRpc3RhbmNlIC0gMSAqL1xuICAgICAgICBjb2RlID0gZF9jb2RlKGRpc3QpO1xuICAgICAgICAvL0Fzc2VydCAoY29kZSA8IERfQ09ERVMsIFwiYmFkIGRfY29kZVwiKTtcblxuICAgICAgICBzZW5kX2NvZGUocywgY29kZSwgZHRyZWUpOyAgICAgICAvKiBzZW5kIHRoZSBkaXN0YW5jZSBjb2RlICovXG4gICAgICAgIGV4dHJhID0gZXh0cmFfZGJpdHNbY29kZV07XG4gICAgICAgIGlmIChleHRyY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bWF4X2NvZGU7IG4rKykge1xuICAgIGN1cmxlbiA9IG5leHRsZW47XG4gICAgbmV4dGxlbiA9IHRyZWVbKG4gKyAxKSAqIDIgKyAxXS8qLkxlbiovO1xuXG4gICAgaWYgKCsrY291bnQgPCBtYXhfY291bnQgJiYgY3VybGVuID09PSBuZXh0bGVuKSB7XG4gICAgICBjb250aW51ZTtcblxuICAgIH0gZWxzZSBpZiAoY291bnQgPCBtaW5fY291bnQpIHtcbiAgICAgIHMuYmxfdHJlZVtjdXJsZW4gKiAyXS8qLkZyZXEqLyArPSBjb3VudDtcblxuICAgIH0gZWxzZSBpZiAoY3VybGVuICE9PSAwKSB7XG5cbiAgICAgIGlmIChjdXJsZW4gIT09IHByZXZsZW4pIHsgcy5ibF90cmVlW2N1cmxlbiAqIDJdLyouRnJlcSovKys7IH1cbiAgICAgIHMuYmxfdHJlZVtSRVBfM182ICogMl0vKi5GcmVxKi8rKztcblxuICAgIH0gZWxzZSBpZiAoY291bnQgPD0gMTApIHtcbiAgICAgIHMuYmxfdHJlZVtSRVBaXzNfMTAgKiAyXS8qLkZyZXEqLysrO1xuXG4gICAgfSBlbHNlIHtcbiAgICAgIHMuYmxfdHJlZVtSRVBaXzExXzEzOCAqIDJdLyouRnJlcSovKys7XG4gICAgfVxuXG4gICAgY291bnQgPSAwO1xuICAgIHByZXZsZW4gPSBjdXJsZW47XG5cbiAgICBpZiAobmV4dGxlbiA9PT0gMCkge1xuICAgICAgbWF4X2NvdW50ID0gMTM4O1xuICAgICAgbWluX2NvdW50ID0gMztcblxuICAgIH0gZWxzZSBpZiAoY3VybGVuID09PSBuZXh0bGVuKSB7XG4gICAgICBtYXhfY291bnQgPSA2O1xuICAgICAgbWluX2NvdW50ID0gMztcblxuICAgIH0gZWxzZSB7XG4gICAgICBtYXhfY291bnQgPSA3O1xuICAgICAgbWluX2NvdW50ID0gNDtcbiAgICB9XG4gIH1cbn1cblxuXG4vKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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udGluZWwpIHtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBhcnRzLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBpZiAocGFydHNbaV0uaW5kZXhPZigndXRmOD0nKSA9PT0gMCkge1xuICAgICAgICAgICAgICAgIGlmIChwYXJ0c1tpXSA9PT0gY2hhcnNldFNlbnRpbmVsKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoYXJzZXQgPSAndXRmLTgnO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocGFydHNbaV0gPT09IGlzb1NlbnRpbmVsKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoYXJzZXQgPSAnaXNvLTg4NTktMSc7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHNraXBJbmRleCA9IGk7XG4gICAgICAgICAgICAgICAgaSA9IHBhcnRzLmxlbmd0aDsgLy8gVGhlIGVzbGludCBzZXR0aW5ncyBkbyBub3QgYWxsb3cgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmb3IgKGkgPSAwOyBpIDwgcGFydHMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgaWYgKGkgPT09IHNraXBJbmRleCkge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHBhcnQgPSBwYXJ0c1tpXTtcblxuICAgICAgICB2YXIgYnJhY2tldEVxdWFsc1BvcyA9IHBhcnQuaW5kZXhPZignXT0nKTtcbiAgICAgICAgdmFyIHBvcyA9IGJyYWNrZXRFcXVhbHNQb3MgPT09IC0xID8gcGFydC5pbmRleE9mKCc9JykgOiBicmFja2V0RXF1YWxzUG9zICsgMTtcblxuICAgICAgICB2YXIga2V5LCB2YWw7XG4gICAgICAgIGlmIChwb3MgPT09IC0xKSB7XG4gICAgICAgICAgICBrZXkgPSBvcHRpb25zLmRlY29kZXIocGFydCwgZGVmYXVsdHMuZGVjb2RlciwgY2hhcnNldCwgJ2tleScpO1xuICAgICAgICAgICAgdmFsID0gb3B0aW9ucy5zdHJpY3ROdWxsSGFuZGxpbmcgPyBudWxsIDogJyc7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBrZXkgPSBvcHRpb25zLmRlY29kZXIocGFydC5zbGljZSgwLCBwb3MpLCBkZWZhdWx0cy5kZWNvZGVyLCBjaGFyc2V0LCAna2V5Jyk7XG4gICAgICAgICAgICB2YWwgPSB1dGlscy5tYXliZU1hcChcbiAgICAgICAgICAgICAgICBwYXJzZUFycmF5VmFsdWUocGFydC5zbGljZShwb3MgKyAxKSwgb3B0aW9ucyksXG4gICAgICAgICAgICAgICAgZnVuY3Rpb24gKGVuY29kZWRWYWwpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9wdGlvbnMuZGVjb2RlcihlbmNvZGVkVmFsLCBkZWZhdWx0cy5kZWNvZGVyLCBjaGFyc2V0LCAndmFsdWUnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICApO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHZhbCAmJiBvcHRpb25zLmludGVycHJldE51bWVyaWNFbnRpdGllcyAmJiBjaGFyc2V0ID09PSAnaXNvLTg4NTktMScpIHtcbiAgICAgICAgICAgIHZhbCA9IGludGVycHJldE51bWVyaWNFbnRpdGllcyh2YWwpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHBhcnQuaW5kZXhPZignW109JykgPiAtMSkge1xuICAgICAgICAgICAgdmFsID0gaXNBcnJheSh2YWwpID8gW3ZhbF0gOiB2YWw7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgZXhpc3RpbmcgPSBoYXMuY2FsbChvYmosIGtleSk7XG4gICAgICAgIGlmIChleGlzdGluZyAmJiBvcHRpb25zLmR1cGxpY2F0ZXMgPT09ICdjb21iaW5lJykge1xuICAgICAgICAgICAgb2JqW2tleV0gPSB1dGlscy5jb21iaW5lKG9ialtrZXldLCB2YWwpO1x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Vjb2RlRG90SW5LZXlzID8gY2xlYW5Sb290LnJlcGxhY2UoLyUyRS9nLCAnLicpIDogY2xlYW5Sb290O1xuICAgICAgICAgICAgdmFyIGluZGV4ID0gcGFyc2VJbnQoZGVjb2RlZFJvb3QsIDEwKTtcbiAgICAgICAgICAgIGlmICghb3B0aW9ucy5wYXJzZUFycmF5cyAmJiBkZWNvZGVkUm9vdCA9PT0gJycpIHtcbiAgICAgICAgICAgICAgICBvYmogPSB7IDA6IGxlYWYgfTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoXG4gICAgICAgICAgICAgICAgIWlzTmFOKGluZGV4KVxuICAgICAgICAgICAgICAgICYmIHJvb3QgIT09IGRlY29kZWRSb290XG4gICAgICAgICAgICAgICAgJiYgU3RyaW5nKGluZGV4KSA9PT0gZGVjb2RlZFJvb3RcbiAgICAgICAgICAgICAgICAmJiBpbmRleCA+PSAwXG4gICAgICAgICAgICAgICAgJiYgKG9wdGlvbnMucGFyc2VBcnJheXMgJiYgaW5kZXggPD0gb3B0aW9ucy5hcnJheUxpbWl0KVxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgb2JqID0gW107XG4gICAgICAgICAgICAgICAgb2JqW2luZGV4XSA9IGxlYWY7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGRlY29kZWRSb290ICE9PSAnX19wcm90b19fJykge1xuICAgICAgICAgICAgICAgIG9ialtkZWNvZGVkUm9vdF0gPSBsZWFmO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgbGVhZiA9IG9iajtcbiAgICB9XG5cbiAgICByZXR1cm4gbGVhZjtcbn07XG5cbnZhciBwYXJzZUtleXMgPSBmdW5jdGlvbiBwYXJzZVF1ZXJ5U3RyaW5nS2V5cyhnaXZlbktleSwgdmFsLCBvcHRpb25zLCB2YWx1ZXNQYXJzZWQpIHtcbiAgICBpZiAoIWdpdmVuS2V5KSB7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG5cbiAg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iAgICAgICAgICAgIG9ialtrZXldLFxuICAgICAgICAgICAga2V5LFxuICAgICAgICAgICAgZ2VuZXJhdGVBcnJheVByZWZpeCxcbiAgICAgICAgICAgIGNvbW1hUm91bmRUcmlwLFxuICAgICAgICAgICAgb3B0aW9ucy5hbGxvd0VtcHR5QXJyYXlzLFxuICAgICAgICAgICAgb3B0aW9ucy5zdHJpY3ROdWxsSGFuZGxpbmcsXG4gICAgICAgICAgICBvcHRpb25zLnNraXBOdWxscyxcbiAgICAgICAgICAgIG9wdGlvbnMuZW5jb2RlRG90SW5LZXlzLFxuICAgICAgICAgICAgb3B0aW9ucy5lbmNvZGUgPyBvcHRpb25zLmVuY29kZXIgOiBudWxsLFxuICAgICAgICAgICAgb3B0aW9ucy5maWx0ZXIsXG4gICAgICAgICAgICBvcHRpb25zLnNvcnQsXG4gICAgICAgICAgICBvcHRpb25zLmFsbG93RG90cyxcbiAgICAgICAgICAgIG9wdGlvbnMuc2VyaWFsaXplRGF0ZSxcbiAgICAgICAgICAgIG9wdGlvbnMuZm9ybWF0LFxuICAgICAgICAgICAgb3B0aW9ucy5mb3JtYXR0ZXIsXG4gICAgICAgICAgICBvcHRpb25zLmVuY29kZVZhbHVlc09ubHksXG4gICAgICAgICAgICBvcHRpb25zLmNoYXJzZXQsXG4gICAgICAgICAgICBzaWRlQ2hhbm5lbFxuICAgICAgICApKTtcbiAgICB9XG5cbiAgICB2YXIgam9pbmVkID0ga2V5cy5qb2luKG9wdGlvbnMuZGVsaW1pdGVyKTtcbiAgICB2YXIgcHJlZml4ID0gb3B0aW9ucy5hZGRRdWVyeVByZWZpeCA9PT0gdHJ1ZSA/ICc/JyA6ICcnO1xuXG4gICAgaWYgKG9wdGlvbnMuY2hhcnNldFNlbnRpbmVsKSB7XG4gICAgICAgIGlmIChvcHRpb25zLmNoYXJzZXQgPT09ICdpc28tODg1OS0xJykge1xuICAgICAgICAgICAgLy8gZW5jb2RlVVJJQ29tcG9uZW50KCcmIzEwMDAzOycpLCB0aGUgXCJudW1lcmljIGVudGl0eVwiIHJlcHJlc2VudGF0aW9uIG9mIGEgY2hlY2ttYXJrXG4gICAgICAgICAgICBwcmVmaXggKz0gJ3V0Zjg9JTI2JTIzMTAwMDMlM0ImJztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIC8vIGVuY29kZVVSSUNvbXBvbmVudCgn4pyTJylcbiAgICAgICAgICAgIHByZWZpeCArPSAndXRmOD0lRTIlOUMlOTMmJztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiBqb2luZWQubGVuZ3RoID4gMCA/IHByZWZpeCArIGpvaW5lZCA6ICcnO1xufTtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIGZvcm1hdHMgPSByZXF1aXJlKCcuL2Zvcm1hdHMnKTtcblxudmFyIGhhcyA9IE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHk7XG52YXIgaXNBcnJheSA9IEFycmF5LmlzQXJyYXk7XG5cbnZhciBoZXhUYWJsZSA9IChmdW5jdGlvbiAoKSB7XG4gICAgdmFyIGFycmF5ID0gW107XG4gICAgZm9yICh2YXIgaSA9IDA7IGkgPCAyNTY7ICsraSkge1xuICAgICAgICBhcnJheS5wdXNoKCclJyArICgoaSA8IDE2ID8gJzAnIDogJycpICsgaS50b1N0cmluZygxNikpLnRvVXBwZXJDYXNlKCkpO1xuICAgIH1cblxuICAgIHJldHVybiBhcnJheTtcbn0oKSk7XG5cbnZhciBjb21wYWN0UXVldWUgPSBmdW5jdGlvbiBjb21wYWN0UXVldWUocXVldWUpIHtcbiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMSkge1xuICAgICAgICB2YXIgaXRlbSA9IHF1ZXVlLnBvcCgpO1xuICAgICAgICB2YXIgb2JqID0gaXRlbS5vYmpbaXRlbS5wcm9wXTtcblxuICAgICAgICBpZiAoaXNBcnJheShvYmopKSB7XG4gICAgICAgICAgICB2YXIgY29tcGFjdGVkID0gW107XG5cbiAgICAgICAgICAgIGZvciAodmFyIGogPSAwOyBqIDwgb2JqLmxlbmd0aDsgKytqKSB7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBvYmpbal0gIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbXBhY3RlZC5wdXNoKG9ialtqXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpdGVtLm9ialtpdGVtLnByb3BdID0gY29tcGFjdGVkO1xuICAgICAgICB9XG4gICAgfVxufTtcblxudmFyIGFycmF5VG9PYmplY3QgPSBmdW5jdGlvbiBhcnJheVRvT2JqZWN0KHNvdXJjZSwgb3B0aW9ucykge1xuICAgIHZhciBvYmogPSBvcHRpb25zICYmIG9wdGlvbnMucGxhaW5PYmplY3RzID8gT2JqZWN0LmNyZWF0ZShudWxsKSA6IHt9O1xuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgc291cmNlLmxlbmd0aDsgKytpKSB7XG4gICAgICAgIGlmICh0eXBlb2Ygc291cmNlW2ldICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgb2JqW2ldID0gc291cmNlW2ldO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIG9iajtcbn07XG5cbnZhciBtZXJnZSA9IGZ1bmN0aW9uIG1lcmdlKHRhcmdldCwgc291cmNlLCBvcHRpb25zKSB7XG4gICAgLyogZXNsaW50IG5vLXBhcmFtLXJlYXNzaWduOiAwICovXG4gICAgaWYgKCFzb3VyY2UpIHtcbiAgICAgICAgcmV0dXJuIHRhcmdldDtcbiAgICB9XG5cbiAgICBpZiAodHlwZW9mIHNvdXJjZSAhPT0gJ29iamVjdCcpIHtcbiAgICAgICAgaWYgKGlzQXJyYXkodGFyZ2V0KSkge1xuICAgICAgICAgICAgdGFyZ2V0LnB1c2goc291cmNlKTtcbiAgICAgICAgfSBlbHNlIGlmICh0YXJnZXQgJiYgdHlwZW9mIHRhcmdldCA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AgICAgICAgdGFyZ2V0W2ldID0gbWVyZ2UodGFyZ2V0SXRlbSwgaXRlbSwgb3B0aW9ucyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnB1c2goaXRlbSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0YXJnZXRbaV0gPSBpdGVtO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIHRhcmdldDtcbiAgICB9XG5cbiAgICByZXR1cm4gT2JqZWN0LmtleXMoc291cmNlKS5yZWR1Y2UoZnVuY3Rpb24gKGFjYywga2V5KSB7XG4gICAgICAgIHZhciB2YWx1ZSA9IHNvdXJjZVtrZXldO1xuXG4gICAgICAgIGlmIChoYXMuY2FsbChhY2MsIGtleSkpIHtcbiAgICAgICAgICAgIGFjY1trZXldID0gbWVyZ2UoYWNjW2tleV0sIHZhbHVlLCBvcHRpb25zKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGFjY1trZXldID0gdmFsdWU7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGFjYztcbiAgICB9LCBtZXJnZVRhcmdldCk7XG59O1xuXG52YXIgYXNzaWduID0gZnVuY3Rpb24gYXNzaWduU2luZ2xlU291cmNlKHRhcmdldCwgc291cmNlKSB7XG4gICAgcmV0dXJuIE9iamVjdC5rZXlzKHNvdXJjZSkucmVkdWNlKGZ1bmN0aW9uIChhY2MsIGtleSkge1xuICAgICAgICBhY2Nba2V5XSA9IHNvdXJjZVtrZXldO1xuICAgICAgICByZXR1cm4gYWNjO1xuICAgIH0sIHRhcmdldCk7XG59O1xuXG52YXIgZGVjb2RlID0gZnVuY3Rpb24gKHN0ciwgZGVjb2RlciwgY2hhcnNldCkge1xuICAgIHZhciBzdHJXaXRob3V0UGx1cyA9IHN0ci5yZXBsYWNlKC9cXCsvZywgJy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WxzZSBpZiAodHlwZW9mIHN0ciAhPT0gJ3N0cmluZycpIHtcbiAgICAgICAgc3RyaW5nID0gU3RyaW5nKHN0cik7XG4gICAgfVxuXG4gICAgaWYgKGNoYXJzZXQgPT09ICdpc28tODg1OS0xJykge1xuICAgICAgICByZXR1cm4gZXNjYXBlKHN0cmluZykucmVwbGFjZSgvJXVbMC05YS1mXXs0fS9naSwgZnVuY3Rpb24gKCQwKSB7XG4gICAgICAgICAgICByZXR1cm4gJyUyNiUyMycgKyBwYXJzZUludCgkMC5zbGljZSgyKSwgMTYpICsgJyUzQic7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHZhciBvdXQgPSAnJztcbiAgICBmb3IgKHZhciBqID0gMDsgaiA8IHN0cmluZy5sZW5ndGg7IGogKz0gbGltaXQpIHtcbiAgICAgICAgdmFyIHNlZ21lbnQgPSBzdHJpbmcubGVuZ3RoID49IGxpbWl0ID8gc3RyaW5nLnNsaWNlKGosIGogKyBsaW1pdCkgOiBzdHJpbmc7XG4gICAgICAgIHZhciBhcnIgPSBbXTtcblxuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNlZ21lbnQubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgIHZhciBjID0gc2VnbWVudC5jaGFyQ29kZUF0KGkpO1xuICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICAgIGMgPT09IDB4MkQgLy8gLVxuICAgICAgICAgICAgICAgIHx8IGMgPT09IDB4MkUgLy8gLlxuICAgICAgICAgICAgICAgIHx8IGMgPT09IDB4NUYgLy8gX1xuICAgICAgICAgICAgICAgIHx8IGMgPT09IDB4N0UgLy8gflxuICAgICAgICAgICAgICAgIHx8IChjID49IDB4MzAgJiYgYyA8PSAweDM5KSAvLyAwLTlcbiAgICAgICAgICAgICAgICB8fCAoYyA+PSAweDQxICYmIGMgPD0gMHg1QSkgLy8gYS16XG4gICAgICAgICAgICAgICAgfHwgKGMgPj0gMHg2MSAmJiBjIDw9IDB4N0EpIC8vIEEtWlxuICAgICAgICAgICAgICAgIHx8IChmb3JtYXQgPT09IGZvcm1hdHMuUkZDMTczOCAmJiAoYyA9PT0gMHgyOCB8fCBjID09PSAweDI5KSkgLy8gKCApXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICBhcnJbYXJyLmxlbmd0aF0gPSBzZWdtZW50LmNoYXJBdChpKTtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGMgPCAweDgwKSB7XG4gICAgICAgICAgICAgICAgYXJyW2Fyci5sZW5ndGhdID0gaGV4VGFibGVbY107XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChjIDwgMHg4MDApIHtcbiAgICAgICAgICAgICAgICBhcnJbYXJyLmxlbmd0aF0gPSBoZXhUYWJsZVsweEMwIHwgKGMgPj4gNildXG4gICAgICAgICAgICAgICAgICAgICsgaGV4VGFibGVbMHg4MCB8IChjICYgMHgzRildO1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoYyA8IDB4RDgwMCB8fCBjID49IDB4RTAwMCkge1xuICAgICAgICAgICAgICAgIGFyclthcnIubGVuZ3RoXSA9IGhleFRhYmxlWzB4RTAgfCAoYyA+PiAxMildXG4gICAgICAgICAgICAgICAgICAgICsgaGV4VGFibGVbMHg4MCB8ICgoYyA+PiA2KSAmIDB4M0YpXVxuICAgICAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoYyAmIDB4M0YpXTtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaSArPSAxO1xuICAgICAgICAgICAgYyA9IDB4MTAwMDAgKyAoKChjICYgMHgzRkYpIDw8IDEwKSB8IChzZWdtZW50LmNoYXJDb2RlQXQoaSkgJiAweDNGRikpO1xuXG4gICAgICAgICAgICBhcnJbYXJyLmxlbmd0aF0gPSBoZXhUYWJsZVsweEYwIHwgKGMgPj4gMTgpXVxuICAgICAgICAgICAgICAgICsgaGV4VGFibGVbMHg4MCB8ICgoYyA+PiAxMikgJiAweDNGKV1cbiAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoKGMgPj4gNikgJiAweDNGKV1cbiAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoYyAmIDB4M0YpXTtcbiAgICAgICAgfVxuXG4gICAgICAgIG91dCArPSBhcnIuam9pbignJyk7XG4gICAgfVxuXG4gICAgcmV0dXJuIG91dDtcbn07XG5cbnZhciBjb21wYWN0ID0gZnVuY3Rpb24gY29tcGFjdCh2YWx1ZSkge1xuICAgIHZhciBxdWV1ZSA9IFt7IG9iajogeyBvOiB2YWx1ZSB9LCBwcm9wOiAnbycgfV07XG4gICAgdmFyIHJlZnMgPSBbXTtcblxuICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcXVldWUubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgdmFyIGl0ZW0gPSBxdWV1ZVtpXTtcbiAgICAgICAgdmFyIG9iaiA9IGl0ZW0ub2JqW2l0ZW0ucHJvcF07XG5cbiAgICAgICAgdmFyIGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICBmb3IgKHZhciBqID0gMDsgaiA8IGtleXMubGVuZ3RoOyArK2opIHtcbiAgICAgICAgICAgIHZhciBrZXkgPSBrZXlzW2pdO1xuICAgICAgICAgICAgdmFyIHZhbCA9IG9ialtrZXldO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWwgPT09ICdvYmplY3QnICYmIHZhbCAhPT0gbnVsbCAmJiByZWZzLmluZGV4T2YodmFsKSA9PT0gLTEpIHtcbiAgICAgICAgICAgICAgICBxdWV1ZS5wdXNoKHsgb2JqOiBvYmosIHByb3A6IGtleSB9KTtcbiAgICAgICAgICAgICAgICByZWZzLnB1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6XG4gICAgICAgICAgICAgICAgICAgICAgICBraW5kID09PSAnQydcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA/XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEVNUFRZXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwO1xuICAgICAgICBpZiAoIXJlc3VsdCkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihcIlVuZXhwZWN0ZWQgbm90aWZpY2F0aW9uIGtpbmQgXCIgKyBraW5kKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH07XG4gICAgTm90aWZpY2F0aW9uLmNyZWF0ZU5leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIG5ldyBOb3RpZmljYXRpb24oJ04nLCB2YWx1ZSk7XG4gICAgfTtcbiAgICBOb3RpZmljYXRpb24uY3JlYXRlRXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgIHJldHVybiBuZXcgTm90aWZpY2F0aW9uKCdFJywgdW5kZWZpbmVkLCBlcnIpO1xuICAgIH07XG4gICAgTm90aWZpY2F0aW9uLmNyZWF0ZUNvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gTm90aWZpY2F0aW9uLmNvbXBsZXRlTm90aWZpY2F0aW9uO1xuICAgIH07XG4gICAgTm90aWZpY2F0aW9uLmNvbXBsZXRlTm90aWZpY2F0aW9uID0gbmV3IE5vdGlmaWNhdGlvbignQycpO1xuICAgIHJldHVybiBOb3RpZmljYXRpb247XG59KCkpO1xuZXhwb3J0IHsgTm90aWZpY2F0aW9uIH07XG5leHBvcnQgZnVuY3Rpb24gb2JzZXJ2ZU5vdGlmaWNhdGlvbihub3RpZmljYXRpb24sIG9ic2VydmVyKSB7XG4gICAgdmFyIF9hLCBfYiwgX2M7XG4gICAgdmF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hYmxlID0gbmV3IE9ic2VydmFibGUoKTtcbiAgICAgICAgb2JzZXJ2YWJsZS5zb3VyY2UgPSB0aGlzO1xuICAgICAgICBvYnNlcnZhYmxlLm9wZXJhdG9yID0gb3BlcmF0b3I7XG4gICAgICAgIHJldHVybiBvYnNlcnZhYmxlO1xuICAgIH07XG4gICAgT2JzZXJ2YWJsZS5wcm90b3R5cGUuc3Vic2NyaWJlID0gZnVuY3Rpb24gKG9ic2VydmVyT3JOZXh0LCBlcnJvciwgY29tcGxldGUpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHN1YnNjcmliZXIgPSBpc1N1YnNjcmliZXIob2JzZXJ2ZXJPck5leHQpID8gb2JzZXJ2ZXJPck5leHQgOiBuZXcgU2FmZVN1YnNjcmliZXIob2JzZXJ2ZXJPck5leHQsIGVycm9yLCBjb21wbGV0ZSk7XG4gICAgICAgIGVycm9yQ29udGV4dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgX2EgPSBfdGhpcywgb3BlcmF0b3IgPSBfYS5vcGVyYXRvciwgc291cmNlID0gX2Euc291cmNlO1xuICAgICAgICAgICAgc3Vic2NyaWJlci5hZGQob3BlcmF0b3JcbiAgICAgICAgICAgICAgICA/XG4gICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yLmNhbGwoc3Vic2NyaWJlciwgc291cmNlKVxuICAgICAgICAgICAgICAgIDogc291cmNlXG4gICAgICAgICAgICAgICAgICAgID9cbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLl9zdWJzY3JpYmUoc3Vic2NyaWJlcilcbiAgICAgICAgICAgICAgICAgICAgOlxuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuX3RyeVN1YnNjcmliZShzdWJzY3JpYmVyKSk7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gc3Vic2NyaWJlcjtcbiAgICB9O1xuICAgIE9ic2VydmFibGUucHJvdG90eXBlLl90cnlTdWJzY3JpYmUgPSBmdW5jdGlvbiAoc2luaykge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N1YnNjcmliZShzaW5rKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBzaW5rLmVycm9yKGVycik7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIE9ic2VydmFibGUucHJvdG90eXBlLmZvckVhY2ggPSBmdW5jdGlvbiAobmV4dCwgcHJvbWlzZUN0b3IpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgcHJvbWlzZUN0b3IgPSBnZXRQcm9taXNlQ3Rvcihwcm9taXNlQ3Rvcik7XG4gICAgICAgIHJldHVybiBuZXcgcHJvbWlzZUN0b3IoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICAgICAgdmFyIHN1YnNjcmlwdGlvbjtcbiAgICAgICAgICAgIHN1YnNjcmlwdGlvbiA9IF90aGlzLnN1YnNjcmliZShmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBuZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICByZWplY3QoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uID09PSBudWxsIHx8IHN1YnNjcmlwdGlvbiA9PT0gdm9pZCAwID8gdm9pZCAwIDogc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgcmVqZWN0LCByZXNvbHZlKTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZS5fc3Vic2NyaWJlID0gZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAg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W5jdGlvbiAob3BlcmF0b3IpIHtcbiAgICAgICAgdmFyIHN1YmplY3QgPSBuZXcgQW5vbnltb3VzU3ViamVjdCh0aGlzLCB0aGlzKTtcbiAgICAgICAgc3ViamVjdC5vcGVyYXRvciA9IG9wZXJhdG9yO1xuICAgICAgICByZXR1cm4gc3ViamVjdDtcbiAgICB9O1xuICAgIFN1YmplY3QucHJvdG90eXBlLl90aHJvd0lmQ2xvc2VkID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAodGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBPYmplY3RVbnN1YnNjcmliZWRFcnJvcigpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS5uZXh0ID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIGVycm9yQ29udGV4dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgZV8xLCBfYTtcbiAgICAgICAgICAgIF90aGlzLl90aHJvd0lmQ2xvc2VkKCk7XG4gICAgICAgICAgICBpZiAoIV90aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgICAgIHZhciBjb3B5ID0gX3RoaXMub2JzZXJ2ZXJzLnNsaWNlKCk7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgY29weV8xID0gX192YWx1ZXMoY29weSksIGNvcHlfMV8xID0gY29weV8xLm5leHQoKTsgIWNvcHlfMV8xLmRvbmU7IGNvcHlfMV8xID0gY29weV8xLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG9ic2VydmVyID0gY29weV8xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvcHlfMV8xICYmICFjb3B5XzFfMS5kb25lICYmIChfYSA9IGNvcHlfMS5yZXR1cm4pKSBfYS5jYWxsKGNvcHlfMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzEpIHRocm93IGVfMS5lcnJvcjsgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS5lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgZXJyb3JDb250ZXh0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIF90aGlzLl90aHJvd0lmQ2xvc2VkKCk7XG4gICAgICAgICAgICBpZiAoIV90aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgICAgIF90aGlzLmhhc0Vycm9yID0gX3RoaXMuaXNTdG9wcGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBfdGhpcy50aHJvd25FcnJvciA9IGVycjtcbiAgICAgICAgICAgICAgICB2YXIgb2JzZXJ2ZXJzID0gX3RoaXMub2JzZXJ2ZXJzO1xuICAgICAgICAgICAgICAgIHdoaWxlIChvYnNlcnZlcnMubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVycy5zaGlmdCgpLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9O1xuICAgIFN1YmplY3QucHJvdG90eXBlLmNvbXBsZXRlID0gZnVuY3Rpb24gK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b3IsIHRocm93bkVycm9yID0gX2EudGhyb3duRXJyb3IsIGlzU3RvcHBlZCA9IF9hLmlzU3RvcHBlZDtcbiAgICAgICAgaWYgKGhhc0Vycm9yKSB7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKHRocm93bkVycm9yKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChpc1N0b3BwZWQpIHtcbiAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgU3ViamVjdC5wcm90b3R5cGUuYXNPYnNlcnZhYmxlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgb2JzZXJ2YWJsZSA9IG5ldyBPYnNlcnZhYmxlKCk7XG4gICAgICAgIG9ic2VydmFibGUuc291cmNlID0gdGhpcztcbiAgICAgICAgcmV0dXJuIG9ic2VydmFibGU7XG4gICAgfTtcbiAgICBTdWJqZWN0LmNyZWF0ZSA9IGZ1bmN0aW9uIChkZXN0aW5hdGlvbiwgc291cmNlKSB7XG4gICAgICAgIHJldHVybiBuZXcgQW5vbnltb3VzU3ViamVjdChkZXN0aW5hdGlvbiwgc291cmNlKTtcbiAgICB9O1xuICAgIHJldHVybiBTdWJqZWN0O1xufShPYnNlcnZhYmxlKSk7XG5leHBvcnQgeyBTdWJqZWN0IH07XG52YXIgQW5vbnltb3VzU3ViamVjdCA9IChmdW5jdGlvbiAoX3N1cGVyKSB7XG4gICAgX19leHRlbmRzKEFub255bW91c1N1YmplY3QsIF9zdXBlcik7XG4gICAgZnVuY3Rpb24gQW5vbnltb3VzU3ViamVjdChkZXN0aW5hdGlvbiwgc291cmNlKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IF9zdXBlci5jYWxsKHRoaXMpIHx8IHRoaXM7XG4gICAgICAgIF90aGlzLmRlc3RpbmF0aW9uID0gZGVzdGluYXRpb247XG4gICAgICAgIF90aGlzLnNvdXJjZSA9IHNvdXJjZTtcbiAgICAgICAgcm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3IgPSBvYnNlcnZlck9yTmV4dC5lcnJvciwgY29tcGxldGUgPSBvYnNlcnZlck9yTmV4dC5jb21wbGV0ZSk7XG4gICAgICAgICAgICB2YXIgY29udGV4dF8xO1xuICAgICAgICAgICAgaWYgKF90aGlzICYmIGNvbmZpZy51c2VEZXByZWNhdGVkTmV4dENvbnRleHQpIHtcbiAgICAgICAgICAgICAgICBjb250ZXh0XzEgPSBPYmplY3QuY3JlYXRlKG9ic2VydmVyT3JOZXh0KTtcbiAgICAgICAgICAgICAgICBjb250ZXh0XzEudW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7IHJldHVybiBfdGhpcy51bnN1YnNjcmliZSgpOyB9O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgY29udGV4dF8xID0gb2JzZXJ2ZXJPck5leHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBuZXh0ID0gbmV4dCA9PT0gbnVsbCB8fCBuZXh0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBuZXh0LmJpbmQoY29udGV4dF8xKTtcbiAgICAgICAgICAgIGVycm9yID0gZXJyb3IgPT09IG51bGwgfHwgZXJyb3IgPT09IHZvaWQgMCA/IHZvaWQgMCA6IGVycm9yLmJpbmQoY29udGV4dF8xKTtcbiAgICAgICAgICAgIGNvbXBsZXRlID0gY29tcGxldGUgPT09IG51bGwgfHwgY29tcGxldGUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IGNvbXBsZXRlLmJpbmQoY29udGV4dF8xKTtcbiAgICAgICAgfVxuICAgICAgICBfdGhpcy5kZXN0aW5hdGlvbiA9IHtcbiAgICAgICAgICAgIG5leHQ6IG5leHQgPyB3cmFwRm9yRXJyb3JIYW5kbGluZyhuZXh0LCBfdGhpcykgOiBub29wLFxuICAgICAgICAgICAgZXJyb3I6IHdyYXBGb3JFcnJvckhhbmRsaW5nKGVycm9yICE9PSBudWxsICYmIGVycm9yICE9PSB2b2l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gdGhpcy5fcGFyZW50YWdlID0gbnVsbDtcbiAgICAgICAgdGhpcy5fdGVhcmRvd25zID0gbnVsbDtcbiAgICB9XG4gICAgU3Vic2NyaXB0aW9uLnByb3RvdHlwZS51bnN1YnNjcmliZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIGVfMSwgX2EsIGVfMiwgX2I7XG4gICAgICAgIHZhciBlcnJvcnM7XG4gICAgICAgIGlmICghdGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgIHRoaXMuY2xvc2VkID0gdHJ1ZTtcbiAgICAgICAgICAgIHZhciBfcGFyZW50YWdlID0gdGhpcy5fcGFyZW50YWdlO1xuICAgICAgICAgICAgaWYgKF9wYXJlbnRhZ2UpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnRhZ2UgPSBudWxsO1xuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KF9wYXJlbnRhZ2UpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBfcGFyZW50YWdlXzEgPSBfX3ZhbHVlcyhfcGFyZW50YWdlKSwgX3BhcmVudGFnZV8xXzEgPSBfcGFyZW50YWdlXzEubmV4dCgpOyAhX3BhcmVudGFnZV8xXzEuZG9uZTsgX3BhcmVudGFnZV8xXzEgPSBfcGFyZW50YWdlXzEubmV4dCgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBhcmVudF8xID0gX3BhcmVudGFnZV8xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50XzEucmVtb3ZlKHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNhdGNoIChlXzFfMSkgeyBlXzEgPSB7IGVycm9yOiBlXzFfMSB9OyB9XG4gICAgICAgICAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX3BhcmVudGFnZV8xXzEgJiYgIV9wYXJlbnRhZ2VfMV8xLmRvbmUgJiYgKF9hID0gX3BhcmVudGFnZV8xLnJldHVybikpIF9hLmNhbGwoX3BhcmVudGFnZV8xKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbmFsbHkgeyBpZiAoZV8xKSB0aHJvdyBlXzEuZXJyb3I7IH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgX3BhcmVudGFnZS5yZW1vdmUodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGluaXRpYWxUZWFyZG93biA9IHRoaXMuaW5pdGlhbFRlYXJkb3duO1xuICAgICAgICAgICAgaWYgKGlzRnVuY3Rpb24oaW5pdGlhbFRlYXJkb3duKSkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGluaXRpYWxUZWFyZG93bigpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlIGluc3RhbmNlb2YgVW5zdWJzY3JpcHRpb25FcnJvciA/IGUuZXJyb3JzIDogW2VdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBfdGVhcmRvd25zID0gdGhpcy5fdGVhcmRvd25zO1xuICAgICAgICAgICAgaWYgKF90ZWFyZG93bnMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90ZWFyZG93bnMgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIF90ZWFyZG93bnNfMSA9IF9fdmFsdWVzKF90ZWFyZG93bnMpLCBfdGVhcmRvd25zXzFfMSA9IF90ZWFyZG93bnNfMS5uZXh0KCk7ICFfdGVhcmRvd25zXzFfMS5kb25lOyBfdGVhcmRvd25zXzFfMSA9IF90ZWFyZG93bnNfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZWFyZG93bl8xID0gX3RlYXJkb3duc18xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4ZWNUZWFyZG93bih0ZWFyZG93bl8xKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMgIT09IG51bGwgJiYgZXJyb3JzICE9PSB2b2lkIDAgPyBlcnJvcnMgOiBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyIGluc3RhbmNlb2YgVW5zdWJzY3JpcHRpb25FcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBfX3NwcmVhZEFycmF5KF9fc3ByZWFkQXJyYXkoW10sIF9fcmVhZChlcnJvcnMpKSwgX19yZWFkKGVyci5lcnJvcnMpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlXzJfMSkgeyBlXzIgPSB7IGVycm9yOiBlXzJfMSB9OyB9XG4gICAgICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoX3RlYXJkb3duc18xXzEgJiYgIV90ZWFyZG93bnNfMV8xLmRvbmUgJiYgKF9iID0gX3RlYXJkb3duc18xLnJldHVybikpIF9iLmNhbGwoX3RlYXJkb3duc18xKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMikgdGhyb3cgZV8yLmVycm9yOyB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGVycm9ycykge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBVbnN1YnNjcmlwdGlvbkVycm9yKGVycm9ycyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFN1YnNjcmlwdGlvbi5wcm90b3R5cGUuYWRkID0gZnVuY3Rpb24gKHRlYXJkb3duKSB7XG4gICAgICAgIHZhciBfYTtcbiAgICAgICAgaWYgKHRlYXJkb3duICYmIHRlYXJkb3duICE9PSB0aGlzKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICBleGVjVGVhcmRvd24odGVhcmRvd24pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHRlYXJkb3duIGluc3RhbmNlb2YgU3Vic2NyaXB0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZWFyZG93bi5jbG9zZWQgfHwgdGVhcmRvd24uX2hhc1BhcmVudCh0aGlzKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHRlYXJkb3duLl9hZ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lKHZhbHVlKTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZXJyb3I6IHJlamVjdCxcbiAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaWYgKGhhc0NvbmZpZykge1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGNvbmZpZy5kZWZhdWx0VmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFbXB0eUVycm9yKCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0pO1xuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Zmlyc3RWYWx1ZUZyb20uanMubWFwIiwiaW1wb3J0IHsgRW1wdHlFcnJvciB9IGZyb20gJy4vdXRpbC9FbXB0eUVycm9yJztcbmV4cG9ydCBmdW5jdGlvbiBsYXN0VmFsdWVGcm9tKHNvdXJjZSwgY29uZmlnKSB7XG4gICAgdmFyIGhhc0NvbmZpZyA9IHR5cGVvZiBjb25maWcgPT09ICdvYmplY3QnO1xuICAgIHJldHVybiBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7XG4gICAgICAgIHZhciBfaGFzVmFsdWUgPSBmYWxzZTtcbiAgICAgICAgdmFyIF92YWx1ZTtcbiAgICAgICAgc291cmNlLnN1YnNjcmliZSh7XG4gICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICBfdmFsdWUgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICBfaGFzVmFsdWUgPSB0cnVlO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGVycm9yOiByZWplY3QsXG4gICAgICAgICAgICBjb21wbGV0ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGlmIChfaGFzVmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShfdmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIGlmIChoYXNDb25maWcpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShjb25maWcuZGVmYXVsdFZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRW1wdHlFcnJvcigpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICB9KTtcbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWxhc3RWYWx1ZUZyb20uanMubWFwIiwiaW1wb3J0IHsgX19leHRlbmRzIH0gZnJvbSBcInRzbGliXCI7XG5pbXBvcnQgeyBPYnNlcnZhYmxlIH0gZnJvbSAnLi4vT2JzZXJ2YWJsZSc7XG5pbXBvcnQgeyBTdWJzY3JpcHRpb24gfSBmcm9tICcuLi9TdWJzY3JpcHRpb24nO1xuaW1wb3J0IHsgcmVmQ291bnQgYXMgaGlnaGVyT3JkZXJSZWZDb3VudCB9IGZyb20gJy4uL29wZXJhdG9ycy9yZWZDb3VudCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1YnNjcmliZXIgfSBmcm9tICcuLi9vcGVyYXRvcnMvT3BlcmF0b3JTdWJzY3JpYmVyJztcbmltcG9ydCB7IGhhc0xpZnQgfSBmcm9tICcuLi91dGlsL2xpZnQnO1xudmFyIENvbm5lY3RhYmxlT2JzZXJ2YWJsZSA9IChmdW5jdGlvbiAoX3N1cGVyKSB7XG4gICAgX19leHRlbmRzKENvbm5lY3RhYmxlT2JzZ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4gICAgICAgICAgICAgICAgICAgIC5hcHBseSh0aGlzLCBhcmdzKVxuICAgICAgICAgICAgICAgICAgICAucGlwZShtYXBPbmVPck1hbnlBcmdzKHJlc3VsdFNlbGVjdG9yKSk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfVxuICAgIGlmIChzY2hlZHVsZXIpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBhcmdzID0gW107XG4gICAgICAgICAgICBmb3IgKHZhciBfaSA9IDA7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xuICAgICAgICAgICAgICAgIGFyZ3NbX2ldID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBiaW5kQ2FsbGJhY2tJbnRlcm5hbHMoaXNOb2RlU3R5bGUsIGNhbGxiYWNrRnVuYylcbiAgICAgICAgICAgICAgICAuYXBwbHkodGhpcywgYXJncylcbiAgICAgICAgICAgICAgICAucGlwZShzdWJzY3JpYmVPbihzY2hlZHVsZXIpLCBvYnNlcnZlT24oc2NoZWR1bGVyKSk7XG4gICAgICAgIH07XG4gICAgfVxuICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHZhciBhcmdzID0gW107XG4gICAgICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgICAgICBhcmdzW19pXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHN1YmplY3QgPSBuZXcgQXN5bmNTdWJqZWN0KCk7XG4gICAgICAgIHZhciB1bmluaXRpYWxpemVkID0gdHJ1ZTtcbiAgICAgICAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICB2YXIgc3VicyA9IHN1YmplY3Quc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgICAgICAgICAgaWYgKHVuaW5pdGlhbGl6ZWQpIHtcbiAgICAgICAgICAgICAgICB1bmluaXRpYWxpemVkID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgdmFyIGlzQXN5bmNfMSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHZhciBpc0NvbXBsZXRlXzEgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBjYWxsYmFja0Z1bmMuYXBwbHkoX3RoaXMsIF9fc3ByZWFkQXJyYXkoX19zcHJlYWRBcnJheShbXSwgX19yZWFkKGFyZ3MpKSwgW1xuICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0cyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzW19pXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNOb2RlU3R5bGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZXJyID0gcmVzdWx0cy5zaGlmdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJqZWN0LmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJqZWN0Lm5leHQoMSA8IHJlc3VsdHMubGVuZ3RoID8gcm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pcnN0VmFsdWUgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzW2ldID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc0ZpcnN0VmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNGaXJzdFZhbHVlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1haW5pbmdGaXJzdFZhbHVlcy0tO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZW1haW5pbmdGaXJzdFZhbHVlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh2YWx1ZVRyYW5zZm9ybSh2YWx1ZXMuc2xpY2UoKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIS0tYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfSwgc3Vic2NyaWJlcik7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIF9sb29wXzEoaSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIHN1YnNjcmliZXIpO1xuICAgIH07XG59XG5mdW5jdGlvbiBtYXliZVNjaGVkdWxlKHNjaGVkdWx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nB1dCk7XG59XG5leHBvcnQgZnVuY3Rpb24gaW5uZXJGcm9tKGlucHV0KSB7XG4gICAgaWYgKGlucHV0IGluc3RhbmNlb2YgT2JzZXJ2YWJsZSkge1xuICAgICAgICByZXR1cm4gaW5wdXQ7XG4gICAgfVxuICAgIGlmIChpbnB1dCAhPSBudWxsKSB7XG4gICAgICAgIGlmIChpc0ludGVyb3BPYnNlcnZhYmxlKGlucHV0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZyb21JbnRlcm9wT2JzZXJ2YWJsZShpbnB1dCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGlzQXJyYXlMaWtlKGlucHV0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZyb21BcnJheUxpa2UoaW5wdXQpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpc1Byb21pc2UoaW5wdXQpKSB7XG4gICAgICAgICAgICByZXR1cm4gZnJvbVByb21pc2UoaW5wdXQpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpc0FzeW5jSXRlcmFibGUoaW5wdXQpKSB7XG4gICAgICAgICAgICByZXR1cm4gZnJvbUFzeW5jSXRlcmFibGUoaW5wdXQpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpc0l0ZXJhYmxlKGlucHV0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZyb21JdGVyYWJsZShpbnB1dCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGlzUmVhZGFibGVTdHJlYW1MaWtlKGlucHV0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZyb21SZWFkYWJsZVN0cmVhbUxpa2UoaW5wdXQpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHRocm93IGNyZWF0ZUludmFsaWRPYnNlcnZhYmxlVHlwZUVycm9yKGlucHV0KTtcbn1cbmZ1bmN0aW9uIGZyb21JbnRlcm9wT2JzZXJ2YWJsZShvYmopIHtcbiAgICByZXR1cm4gbmV3IE9ic2VydmFibGUoZnVuY3Rpb24gKHN1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WJzY3JpYmVyLmVycm9yKGVycik7IH0pXG4gICAgICAgICAgICAudGhlbihudWxsLCByZXBvcnRVbmhhbmRsZWRFcnJvcik7XG4gICAgfSk7XG59XG5mdW5jdGlvbiBmcm9tSXRlcmFibGUoaXRlcmFibGUpIHtcbiAgICByZXR1cm4gbmV3IE9ic2VydmFibGUoZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIGVfMSwgX2E7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBmb3IgKHZhciBpdGVyYWJsZV8xID0gX192YWx1ZXMoaXRlcmFibGUpLCBpdGVyYWJsZV8xXzEgPSBpdGVyYWJsZV8xLm5leHQoKTsgIWl0ZXJhYmxlXzFfMS5kb25lOyBpdGVyYWJsZV8xXzEgPSBpdGVyYWJsZV8xLm5leHQoKSkge1xuICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IGl0ZXJhYmxlXzFfMS52YWx1ZTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGNhdGNoIChlXzFfMSkgeyBlXzEgPSB7IGVycm9yOiBlXzFfMSB9OyB9XG4gICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBpZiAoaXRlcmFibGVfMV8xICYmICFpdGVyYWJsZV8xXzEuZG9uZSAmJiAoX2EgPSBpdGVyYWJsZV8xLnJldHVybikpIF9hLmNhbGwoaXRlcmFibGVfMSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMSkgdGhyb3cgZV8xLmVycm9yOyB9XG4gICAgICAgIH1cbiAgICAgICAgc3Vic2NyaWJlci5j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CA9IDE7XG4gICAgICAgICAgICAgICAgY2FzZSAxOiByZXR1cm4gWzQsIGFzeW5jSXRlcmFibGVfMS5uZXh0KCldO1xuICAgICAgICAgICAgICAgIGNhc2UgMjpcbiAgICAgICAgICAgICAgICAgICAgaWYgKCEoYXN5bmNJdGVyYWJsZV8xXzEgPSBfYi5zZW50KCksICFhc3luY0l0ZXJhYmxlXzFfMS5kb25lKSkgcmV0dXJuIFszLCA0XTtcbiAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBhc3luY0l0ZXJhYmxlXzFfMS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzJdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIF9iLmxhYmVsID0gMztcbiAgICAgICAgICAgICAgICBjYXNlIDM6IHJldHVybiBbMywgMV07XG4gICAgICAgICAgICAgICAgY2FzZSA0OiByZXR1cm4gWzMsIDExXTtcbiAgICAgICAgICAgICAgICBjYXNlIDU6XG4gICAgICAgICAgICAgICAgICAgIGVfMl8xID0gX2Iuc2VudCgpO1xuICAgICAgICAgICAgICAgICAgICBlXzIgPSB7IGVycm9yOiBlXzJfMSB9O1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzMsIDExXTtcbiAgICAgICAgICAgICAgICBjYXNlIDY6XG4gICAgICAgICAgICAgICAgICAgIF9iLnRyeXMucHVzaChbNiwgLCA5LCAxMF0pO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIShhc3luY0l0ZXJhYmxlXzFfMSAmJiAhYXN5bmNJdGVyYWJsZV8xXzEuZG9uZSAmJiAoX2EgPSBhc3luY0l0ZXJhYmxlXzEucmV0dXJuKSkpIHJldHVybiBbMywgOF07XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgX2EuY2FsbChhc3luY0l0ZXJhYmxlXzEpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDc6XG4gICAgICAgICAgICAgICAgICAgIF9iLnNlbnQoKTtcbiAgICAgICAgICAgICAgICAgICAgX2IubGFiZWwgPSA4O1xuICAgICAgICAgICAgICAgIGNhc2UgODogcmV0dXJuIFszLCAxMF07XG4gICAgICAgICAgICAgICAgY2FzZSA5OlxuICAgICAgICAgICAgICAgICAgICBpZiAoZV8yKSB0aHJvdyBlXzIuZXJyb3I7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbN107XG4gICAgICAgICAgICAgICAgY2FzZSAxMDogcmV0dXJuIFs3XTtcbiAgICAgICAgICAgICAgICBjYXNlIDExOlxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbMl07XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZnJvbS5qcy5tYXAiLCJpbXBvcnQgeyBzY2hlZHVsZUFycmF5IH0gZnJvbSAnLi4vc2NoZWR1bGVkL3NjaGVkdWxlQXJyYXknO1xuaW1wb3J0IHsgZnJvbUFycmF5TGlrZSB9IGZyb20gJy4vZnJvbSc7XG5leHBvcnQgZnVuY3Rpb24gaW50ZXJuYWxGcm9tQXJyYXkoaW5wdXQsIHNjaGVkdWxlcikge1xuICAgIHJldHVybiBzY2hlZHVsZXIgPyBzY2hlZHVsZUFycmF5KGlucHV0LCBzY2hlZHVsZXIpIDogZnJvbUFycmF5TGlrZShpbnB1dCk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1mcm9tQXJyYXkuanMubWFwIiwiaW1wb3J0IHsgX19yZWFkIH0gZnJvbSBcInRzbGliXCI7XG5pbXBvcnQgeyBPYnNlcnZhYmxlIH0gZnJvbSAnLi4vT2JzZXJ2YWJsZSc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ICAgICAgICAgICAgICAgIF9hLmxhYmVsID0gMTtcbiAgICAgICAgICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICAgICAgICAgIGlmICghKCFjb25kaXRpb24gfHwgY29uZGl0aW9uKHN0YXRlKSkpIHJldHVybiBbMywgNF07XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgcmVzdWx0U2VsZWN0b3Ioc3RhdGUpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDI6XG4gICAgICAgICAgICAgICAgICAgIF9hLnNlbnQoKTtcbiAgICAgICAgICAgICAgICAgICAgX2EubGFiZWwgPSAzO1xuICAgICAgICAgICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgICAgICAgICAgc3RhdGUgPSBpdGVyYXRlKHN0YXRlKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFszLCAxXTtcbiAgICAgICAgICAgICAgICBjYXNlIDQ6IHJldHVybiBbMl07XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICByZXR1cm4gZGVmZXIoKHNjaGVkdWxlclxuICAgICAgICA/XG4gICAgICAgICAgICBmdW5jdGlvbiAoKSB7IHJldHVybiBzY2hlZHVsZUl0ZXJhYmxlKGdlbigpLCBzY2hlZHVsZXIpOyB9XG4gICAgICAgIDpcbiAgICAgICAgICAgIGdlbikpO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Z2VuZXJhdGUuanMubWFwIiwiaW1wb3J0IHsgZGVmZXIgfSBmcm9tICcuL2RlZmVyJztcbmV4cG9ydCBmdW5jdGlvbiBpaWYoY29uZGl0aW9uLCB0cnVlUmVzdWx0LCBmYWxzZVJlc3VsdCkge1xuICAgIHJldHVybiBkZWZlcihmdW5jdGlvbiAoKSB7IHJldHVybiAoY29uZGl0aW9uKCkgPyB0cnVlUmVzdWx0IDogZmFsc2VSZXN1bHQpOyB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWlpZi5qcy5tYXA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JztcbmV4cG9ydCBmdW5jdGlvbiByYW5nZShzdGFydCwgY291bnQsIHNjaGVkdWxlcikge1xuICAgIGlmIChjb3VudCA9PSBudWxsKSB7XG4gICAgICAgIGNvdW50ID0gc3RhcnQ7XG4gICAgICAgIHN0YXJ0ID0gMDtcbiAgICB9XG4gICAgaWYgKGNvdW50IDw9IDApIHtcbiAgICAgICAgcmV0dXJuIEVNUFRZO1xuICAgIH1cbiAgICB2YXIgZW5kID0gY291bnQgKyBzdGFydDtcbiAgICByZXR1cm4gbmV3IE9ic2VydmFibGUoc2NoZWR1bGVyXG4gICAgICAgID9cbiAgICAgICAgICAgIGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgdmFyIG4gPSBzdGFydDtcbiAgICAgICAgICAgICAgICByZXR1cm4gc2NoZWR1bGVyLnNjaGVkdWxlKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG4gPCBlbmQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChuKyspO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2hlZHVsZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIDpcbiAgICAgICAgICAgIGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgdmFyIG4gPSBzdGFydDtcbiAgICAgICAgICAgICAgICB3aGlsZSAobiA8IGVuZCAmJiAhc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KG4rKyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAg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ICAgIHN1YnNjcmliZXIuYWRkKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBidWZmZXJzID0gY29tcGxldGVkID0gbnVsbDtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdmFyIF9sb29wXzEgPSBmdW5jdGlvbiAoc291cmNlSW5kZXgpIHtcbiAgICAgICAgICAgICAgICBpbm5lckZyb20oc291cmNlc1tzb3VyY2VJbmRleF0pLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBidWZmZXJzW3NvdXJjZUluZGV4XS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJ1ZmZlcnMuZXZlcnkoZnVuY3Rpb24gKGJ1ZmZlcikgeyByZXR1cm4gYnVmZmVyLmxlbmd0aDsgfSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBidWZmZXJzLm1hcChmdW5jdGlvbiAoYnVmZmVyKSB7IHJldHVybiBidWZmZXIuc2hpZnQoKTsgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQocmVzdWx0U2VsZWN0b3IgPyByZXN1bHRTZWxlY3Rvci5hcHBseSh2b2lkIDAsIF9fc3ByZWFkQXJyYXkoW10sIF9fcmVhZChyZXN1bHQpKSkgOiByZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJ1ZmZlcnMuc29tZShmdW5jdGlvbiAoYnVmZmVyLCBpKSB7IHJldHVybiAhYnVmZmVyLmxlbmd0aCAmJiBjb21wbGV0ZWRbaV07IH0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAg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gICAgX3RoaXMub25GaW5hbGl6ZSA9IG9uRmluYWxpemU7XG4gICAgICAgIF90aGlzLl9uZXh0ID0gb25OZXh0XG4gICAgICAgICAgICA/IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG9uTmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICA6IF9zdXBlci5wcm90b3R5cGUuX25leHQ7XG4gICAgICAgIF90aGlzLl9lcnJvciA9IG9uRXJyb3JcbiAgICAgICAgICAgID8gZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG9uRXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICBkZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIDogX3N1cGVyLnByb3RvdHlwZS5fZXJyb3I7XG4gICAgICAgIF90aGlzLl9jb21wbGV0ZSA9IG9uQ29tcGxldGVcbiAgICAgICAgICAgID8gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG9uQ29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICA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gICAgfVxuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBidWZmZXJzXzEgPSBfX3ZhbHVlcyhidWZmZXJzKSwgYnVmZmVyc18xXzEgPSBidWZmZXJzXzEubmV4dCgpOyAhYnVmZmVyc18xXzEuZG9uZTsgYnVmZmVyc18xXzEgPSBidWZmZXJzXzEubmV4dCgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSBidWZmZXJzXzFfMS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoYnVmZmVyU2l6ZSA8PSBidWZmZXIubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0b0VtaXQgPSB0b0VtaXQgIT09IG51bGwgJiYgdG9FbWl0ICE9PSB2b2lkIDAgPyB0b0VtaXQgOiBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRvRW1pdC5wdXNoKGJ1ZmZlcik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJ1ZmZlcnNfMV8xICYmICFidWZmZXJzXzFfMS5kb25lICYmIChfYSA9IGJ1ZmZlcnNfMS5yZXR1cm4pKSBfYS5jYWxsKGJ1ZmZlcnNfMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkgeyBpZiAoZV8xKSB0aHJvdyBlXzEuZXJyb3I7IH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0b0VtaXQpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciB0b0VtaXRfMSA9IF9fdmFsdWVzKHRvRW1pdCksIHRvRW1pdF8xXzEgPSB0b0VtaXRfMS5uZXh0KCk7ICF0b0VtaXRfMV8xLmRvbmU7IHRvRW1pdF8xXzEgPSB0b0VtaXRfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSB0b0VtaXRfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgYXJyUmVtb3ZlKGJ1ZmZlcnMsIGJ1ZmZlcik7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQoYnVmZmVyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZV8yXzEpIHsgZV8yID0geyBlcnJvcjogZV8yXzEgfTsgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRvRW1pdF8xXzEgJiYgIXRvRW1pdF8xXzEuZG9uZSAmJiAoX2IgPSB0b0VtaXRfMS5yZXR1cm4pKSBfYi5jYWxsKHRvRW1pdF8xKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMikgdGhyb3cgZV8yLmVycm9yOyB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgZV8zLCBfYTtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgYnVmZmVyc18yID0gX192YWx1ZXMoYnVmZmVycyksIGJ1ZmZlcnNfMl8xID0gYnVmZmVyc18yLm5leHQoKTsgIWJ1ZmZlcnNfMl8xLmRvbmU7IGJ1ZmZlcnNfMl8xID0gYnVmZmVyc18yLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgYnVmZmVyID0gYnVmZmVyc18yXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChidWZmZXIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlXzNfMSkgeyBlXzMgPSB7IGVycm9yOiBlXzNfMSB9OyB9XG4gICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoYnVmZmVyc18yXzEgJiYgIWJ1ZmZlcnNfMl8xLmRvbmUgJiYgKF9hID0gYnVmZmVyc18yLnJldHVybikpIF9hLmNhbGwoYnVmZmVyc18yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzMpIHRocm93IGVfMy5lcnJvcjsgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICB9LCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGJ1ZmZlcnMgPSBudWxsO1xuICAgICAgICB9KSk7XG4gICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1idWZmZXJDb3VudC5qcy5tYXAiLCJpbXBvcnQgeyBfX3ZhbHVlcyB9IGZyb20gXCJ0c2xpYlwiO1xuaW1wb3J0IHsgU3Vic2NyaXB0aW9uIH0gZnJvbSAnLi4vU3Vic2NyaXB0aW9uJztcbmltcG9ydCB7IG9wZXJhdGUgfSBmcm9tICcuLi91dGlsL2xpZnQnO1xuaW1wb3J0IHsgT3BlcmF0b3JTdWJzY3JpYmVyIH0gZnJvbSAnLi9PcGVyYXRvclN1YnNjcmliZXInO1xuaW1wb3J0IHsgYXJyUmVtb3ZlIH0gZnJvbSAnLi4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AgICAgYXJyUmVtb3ZlKGJ1ZmZlclJlY29yZHMsIHJlY29yZCk7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQoYnVmZmVyKTtcbiAgICAgICAgICAgIHJlc3RhcnRPbkVtaXQgJiYgc3RhcnRCdWZmZXIoKTtcbiAgICAgICAgfTtcbiAgICAgICAgdmFyIHN0YXJ0QnVmZmVyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKGJ1ZmZlclJlY29yZHMpIHtcbiAgICAgICAgICAgICAgICB2YXIgc3VicyA9IG5ldyBTdWJzY3JpcHRpb24oKTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChzdWJzKTtcbiAgICAgICAgICAgICAgICB2YXIgYnVmZmVyID0gW107XG4gICAgICAgICAgICAgICAgdmFyIHJlY29yZF8xID0ge1xuICAgICAgICAgICAgICAgICAgICBidWZmZXI6IGJ1ZmZlcixcbiAgICAgICAgICAgICAgICAgICAgc3Viczogc3VicyxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGJ1ZmZlclJlY29yZHMucHVzaChyZWNvcmRfMSk7XG4gICAgICAgICAgICAgICAgc3Vicy5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGZ1bmN0aW9uICgpIHsgcmV0dXJuIGVtaXQocmVjb3JkXzEpOyB9LCBidWZmZXJUaW1lU3BhbikpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICBidWZmZXJDcmVhdGlvbkludGVydmFsICE9PSBudWxsICYmIGJ1ZmZlckNyZWF0aW9uSW50ZXJ2YWwgPj0gMFxuICAgICAgICAgICAgP1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuYWRkKHNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0QnVmZmVyKCk7XG4gICAgICAgICAgICAgICAgICAgICF0aGlzLmNsb3NlZCAmJiBzdWJ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4gICAgICAgIH07XG4gICAgICAgIGZ1bmN0aW9uIGVtaXRXaGVuSWRsZSgpIHtcbiAgICAgICAgICAgIHZhciB0YXJnZXRUaW1lID0gbGFzdFRpbWUgKyBkdWVUaW1lO1xuICAgICAgICAgICAgdmFyIG5vdyA9IHNjaGVkdWxlci5ub3coKTtcbiAgICAgICAgICAgIGlmIChub3cgPCB0YXJnZXRUaW1lKSB7XG4gICAgICAgICAgICAgICAgYWN0aXZlVGFzayA9IHRoaXMuc2NoZWR1bGUodW5kZWZpbmVkLCB0YXJnZXRUaW1lIC0gbm93KTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChhY3RpdmVUYXNrKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbWl0KCk7XG4gICAgICAgIH1cbiAgICAgICAgc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgbGFzdFZhbHVlID0gdmFsdWU7XG4gICAgICAgICAgICBsYXN0VGltZSA9IHNjaGVkdWxlci5ub3coKTtcbiAgICAgICAgICAgIGlmICghYWN0aXZlVGFzaykge1xuICAgICAgICAgICAgICAgIGFjdGl2ZVRhc2sgPSBzY2hlZHVsZXIuc2NoZWR1bGUoZW1pdFdoZW5JZGxlLCBkdWVUaW1lKTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChhY3RpdmVUYXNrKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgZW1pdCgpO1xuICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICB9LCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGxhc3RWYWx1ZSA9IGFjdGl2ZVRhc2sgPSBudWxsO1xuICA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gICAgICAgICAgICAgICB2YXIgZ3JvdXBfMSA9IGdyb3Vwcy5nZXQoa2V5XzEpO1xuICAgICAgICAgICAgICAgIGlmICghZ3JvdXBfMSkge1xuICAgICAgICAgICAgICAgICAgICBncm91cHMuc2V0KGtleV8xLCAoZ3JvdXBfMSA9IGNvbm5lY3RvciA/IGNvbm5lY3RvcigpIDogbmV3IFN1YmplY3QoKSkpO1xuICAgICAgICAgICAgICAgICAgICB2YXIgZ3JvdXBlZCA9IGNyZWF0ZUdyb3VwZWRPYnNlcnZhYmxlKGtleV8xLCBncm91cF8xKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KGdyb3VwZWQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZHVyYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkdXJhdGlvblN1YnNjcmliZXJfMSA9IG5ldyBPcGVyYXRvclN1YnNjcmliZXIoZ3JvdXBfMSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwXzEuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkdXJhdGlvblN1YnNjcmliZXJfMSA9PT0gbnVsbCB8fCBkdXJhdGlvblN1YnNjcmliZXJfMSA9PT0gdm9pZCAwID8gdm9pZCAwIDogZHVyYXRpb25TdWJzY3JpYmVyXzEudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHVuZGVmaW5lZCwgdW5kZWZpbmVkLCBmdW5jdGlvbiAoKSB7IHJldHVybiBncm91cHMuZGVsZXRlKGtleV8xKTsgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBncm91cEJ5U291cmNlU3Vic2NyaWJlci5hZGQoaW5uZXJGcm9tKGR1cmF0aW9uKGdyb3VwZWQpKS5zdWJzY3JpYmUoZHVyYXRpb25TdWJzY3JpYmVyXzEpKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBncm91cF8xLm5leHQoZWxlbWVudCA/IGVsZW1lbnQodmFsdWUpIDogdmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgIGhhbmRsZUVycm9yKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIGZ1bmN0aW9uICgpIHsgcmV0dXJuIG5vdGlmeShmdW5jdGlvbiAoY29uc3VtZXIpIHsgcmV0dXJuIGNvbnN1bWVyLmNvbXBsZXRlKCk7IH0pOyB9LCBoYW5kbGVFcnJvciwgZnVuY3Rpb24gKCkgeyByZXR1cm4gZ3JvdXBzLmNsZWFyKCk7IH0pO1xuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKGdyb3VwQnlTb3VyY2VTdWJzY3JpYmVyKTtcbiAgICAgICAgZnVuY3Rpb24gY3JlYXRlR3JvdXBlZE9ic2VydmFibGUoa2V5LCBncm91cFN1YmplY3QpIHtcbiAgICAgICAgICAgIHZhciByZXN1bHQgPSBuZXcgT2JzZXJ2YWJsZShmdW5jdGlvbiAoZ3JvdXBTdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgZ3JvdXBCeVNvdXJjZVN1YnNjcmliZXIuYWN0aXZlR3JvdXBzKys7XG4gICAgICAgICAgICAgICAgdmFyIGlubmVyU3ViID0gZ3JvdXBTdWJqZWN0LnN1YnNjcmliZShncm91cFN1YnNjcmliZXIpO1xuICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlubmVyU3ViLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgICAgIC0tZ3JvdXBCeVNvdXJjZVN1YnNjcmliZXIuYWN0aXZlR3JvdXBzID09PSAwICYmXG4gICAgICAgICAgICAgICAgICAgICAgICBncm91cEJ5U291cmNlU3Vic2NyaWJlci50ZWFy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nVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaW5uZXJDb21wbGV0ZSA9IHRydWU7XG4gICAgICAgIH0sIHVuZGVmaW5lZCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKGlubmVyQ29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBhY3RpdmUtLTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIF9sb29wXzEgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgYnVmZmVyZWRWYWx1ZSA9IGJ1ZmZlci5zaGlmdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWJTY2hlZHVsZXIgPyBzdWJzY3JpYmVyLmFkZChpbm5lclN1YlNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7IHJldHVybiBkb0lubmVyU3ViKGJ1ZmZlcmVkVmFsdWUpOyB9KSkgOiBkb0lubmVyU3ViKGJ1ZmZlcmVkVmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB3aGlsZSAoYnVmZmVyLmxlbmd0aCAmJiBhY3RpdmUgPCBjb25jdXJyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBfbG9vcF8xKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgY2hlY2tDb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKTtcbiAgICB9O1xuICAgIHNvdXJjZS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBvdXRlck5leHQsIGZ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nNjcmliZU5leHQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoIXN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgaWYgKHJlbWFpbmluZy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBuZXh0U291cmNlID0gdm9pZCAwO1xuICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbmV4dFNvdXJjZSA9IGlubmVyRnJvbShyZW1haW5pbmcuc2hpZnQoKSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlTmV4dCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclN1YiA9IG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgdW5kZWZpbmVkLCBub29wLCBub29wKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5hZGQobmV4dFNvdXJjZS5zdWJzY3JpYmUoaW5uZXJTdWIpKTtcbiAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWIuYWRkKHN1YnNjcmliZU5leHQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgc3Vic2NyaWJlTmV4dCgpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9b25FcnJvclJlc3VtZU5leHQuanMubWFwIiwiaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlm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b3VudCsrO1xuICAgICAgICB2YXIgcmVmQ291bnRlciA9IG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgdW5kZWZpbmVkLCB1bmRlZmluZWQsIHVuZGVmaW5lZCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKCFzb3VyY2UgfHwgc291cmNlLl9yZWZDb3VudCA8PSAwIHx8IDAgPCAtLXNvdXJjZS5fcmVmQ291bnQpIHtcbiAgICAgICAgICAgICAgICBjb25uZWN0aW9uID0gbnVsbDtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgc2hhcmVkQ29ubmVjdGlvbiA9IHNvdXJjZS5fY29ubmVjdGlvbjtcbiAgICAgICAgICAgIHZhciBjb25uID0gY29ubmVjdGlvbjtcbiAgICAgICAgICAgIGNvbm5lY3Rpb24gPSBudWxsO1xuICAgICAgICAgICAgaWYgKHNoYXJlZENvbm5lY3Rpb24gJiYgKCFjb25uIHx8IHNoYXJlZENvbm5lY3Rpb24gPT09IGNvbm4pKSB7XG4gICAgICAgICAgICAgICAgc2hhcmVkQ29ubmVjdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaWJlci51bnN1YnNjcmliZSgpO1xuICAgICAgICB9KTtcbiAgICAgICAgc291cmNlLnN1YnNjcmliZShyZWZDb3VudGVyKTtcbiAgICAgICAgaWYgKCFyZWZDb3VudGVyLmNsb3NlZCkge1xuICAgICAgICAgICAgY29ubmVjdGlvbiA9IHNvdXJjZS5jb25uZWN0KCk7XG4gICAgICAgIH1cbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXJlZkNvdW50LmpzLm1hcCIsImltcG9ydCB7IEVNUFRZIH0gZnJvbSAnLi4vb2JzZXJ2YWJsZS9lbXB0eSc7XG5pbXBvcnQgeyBvcGVyYXRlIH0gZnJvbSAnLi4vdXRpbC9saWZ0JztcbmltcG9ydCB7IE9wZXJhdG9yU3Vic2NyaWJlciB9IGZyb20gJy4vT3BlcmF0b3JTdWJzY3JpYmVyJztcbmV4cG9ydCBmdW5jdGlvbiByZXBlYXQoY291bnQpIHtcbiAgICBpZiAoY291bnQgPT09IHZvaWQgMCkgeyBjb3VudCA9IEluZmluaXR5OyB9XG4gICAgcmV0dXJuIGNvdW50IDw9IDBcbiAgICAgICAgPyBmdW5jdGlvbiAoKSB7IHJldHVybiBFTVBUWTsgfVxuICAgICAgICA6IG9wZXJhdGUoZnVuY3Rpb24gKHNvdXJjZSwgc3Vic2NyaWJlcikge1xuICAgICAgICAgICAgdmFyIHNvRmFyID0gMDtcbiAgICAgICAgICAgIHZhciBpbm5lclN1YjtcbiAgICAgICAgICAgIHZhciBzdWJzY3JpYmVGb3JSZXBlYXQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN5bmNVbnN1YiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGlubmVyU3ViID0gc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIHVuZGVmaW5lZCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoKytzb0ZhciA8IGNvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJTdWIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyU3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVGb3JSZXBlYXQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN5bmNVbnN1YiA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgaWYgKHN5bmNVbnN1Yikge1xuICAgICAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICBpbm5lclN1YiA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZUZvclJlcGVhdCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBzdWJzY3JpYmVGb3JSZXBlYXQoKTtcbiAgICAgICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1yZXBlYXQuanMubWFwIiwiaW1wb3J0IHsgU3ViamVjdCB9IGZyb20gJy4uL1N1YmplY3QnO1xuaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlmdCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1YnNjcmliZXIgfSBmcm9tICcuL09wZXJhdG9yU3Vic2NyaWJlcic7XG5leHBvcnQgZnVuY3Rpb24gcmVwZWF0V2hlbihub3RpZmllcikge1xuICAgIHJldHVybiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIGlubmVyU3ViO1xuICAgICAgICB2YXIgc3luY1Jlc3ViID0gZmFsc2U7XG4gICAgICAgIHZhciBjb21wbGV0aW9ucyQ7XG4gICAgICAgIHZhciBpc05vdGlmaWVyQ29tcGxldGUgPSBmYWxzZTtcbiAgICAgICAgdmFyIGlzTWFpbkNvbXBsZXRlID0gZmFsc2U7XG4gICAgICAgIHZhciBjaGVja0NvbXBsZXRlID0gZnVuY3Rpb24gKCkgeyByZXR1cm4gaXNNYWluQ29tcGxldGUgJiYgaXNOb3RpZmllckNvbXBsZXRlICYmIChzdWJzY3JpYmVyLmNvbXBsZXRlKCksIHRydWUpOyB9O1xuICAgICAgICB2YXIgZ2V0Q29tcGxldGlvblN1YmplY3QgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoIWNvbXBsZXRpb25zJCkge1xuICAgICAgICAgICAgICAgIGNvbXBsZXRpb25zJCA9IG5ldyBTdWJqZWN0KCk7XG4gICAgICAgICAgICAgICAgbm90aWZpZXIoY29tcGxldGlvbnMkKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbm5lclN1Yikge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmVwZWF0V2hlbigpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3luY1Jlc3ViID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgaXNOb3RpZmllckNvbXBsZXRlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgY2hlY2tDb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBjb21wbGV0aW9ucyQ7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBzdWJzY3JpYmVGb3JSZXBlYXRXaGVuID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaXNNYWluQ29tcGxldGUgPSBmYWxzZTtcbiAgICAgICAgICAgIGlubmVyU3ViID0gc291cmNlLnN1YnNjcmliZShuZXcg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b3VudDtcbiAgICB9XG4gICAgZWxzZSB7XG4gICAgICAgIGNvbmZpZyA9IHtcbiAgICAgICAgICAgIGNvdW50OiBjb25maWdPckNvdW50LFxuICAgICAgICB9O1xuICAgIH1cbiAgICB2YXIgY291bnQgPSBjb25maWcuY291bnQsIF9hID0gY29uZmlnLnJlc2V0T25TdWNjZXNzLCByZXNldE9uU3VjY2VzcyA9IF9hID09PSB2b2lkIDAgPyBmYWxzZSA6IF9hO1xuICAgIHJldHVybiBjb3VudCA8PSAwXG4gICAgICAgID8gaWRlbnRpdHlcbiAgICAgICAgOiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgICAgIHZhciBzb0ZhciA9IDA7XG4gICAgICAgICAgICB2YXIgaW5uZXJTdWI7XG4gICAgICAgICAgICB2YXIgc3Vic2NyaWJlRm9yUmV0cnkgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN5bmNVbnN1YiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGlubmVyU3ViID0gc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAocmVzZXRPblN1Y2Nlc3MpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvRmFyID0gMDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIH0sIHVuZGVmaW5lZCwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICBpZiAoc29GYXIrKyA8IGNvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJTdWIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyU3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVGb3JSZXRyeSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3luY1Vuc3ViID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICBpZiAoc3luY1Vuc3ViKSB7XG4gICAgICAgICAgICAgICAgICAgIGlubmVyU3ViLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgICAgIGlubmVyU3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmV0cnkoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmV0cnkoKTtcbiAgICAgICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1yZXRyeS5qcy5tYXAiLCJpbXBvcnQgeyBTdWJqZWN0IH0gZnJvbSAnLi4vU3ViamVjdCc7XG5pbXBvcnQgeyBvcGVyYXRlIH0gZnJvbSAnLi4vdXRpbC9saWZ0JztcbmltcG9ydCB7IE9wZXJhdG9yU3Vic2NyaWJlciB9IGZyb20gJy4vT3BlcmF0b3JTdWJzY3JpYmVyJztcbmV4cG9ydCBmdW5jdGlvbiByZXRyeVdoZW4obm90aWZpZXIpIHtcbiAgICByZXR1cm4gb3BlcmF0ZShmdW5jdGlvbiAoc291cmNlLCBzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBpbm5lclN1YjtcbiAgICAgICAgdmFyIHN5bmNSZXN1YiA9IGZhbHNlO1xuICAgICAgICB2YXIgZXJyb3JzJDtcbiAgICAgICAgdmFyIHN1YnNjcmliZUZvclJldHJ5V2hlbiA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlubmVyU3ViID0gc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIHVuZGVmaW5lZCwgdW5kZWZpbmVkLCBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFlcnJvcnMkKSB7XG4gICAgICAgICAgICAgICAgICAgIGVycm9ycyQgPSBuZXcgU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgICAgICBub3RpZmllcihlcnJvcnMkKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW5uZXJTdWIgPyBzdWJzY3JpYmVGb3JSZXRyeVdoZW4oKSA6IChzeW5jUmVzdWIgPSB0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoZXJyb3JzJCkge1xuICAgICAgICAgICAgICAgICAgICBlcnJvcnMkLm5leHQoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICBpZiAoc3luY1Jlc3ViKSB7XG4gICAgICAgICAgICAgICAgaW5uZXJTdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICBpbm5lclN1YiA9IG51bGw7XG4gICAgICAgICAgICAgICAgc3luY1Jlc3ViID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmV0cnlXaGVu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GZhbHNlO1xuICAgICAgICB2YXIgaGFzRXJyb3JlZCA9IGZhbHNlO1xuICAgICAgICB2YXIgY2FuY2VsUmVzZXQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICByZXNldENvbm5lY3Rpb24gPT09IG51bGwgfHwgcmVzZXRDb25uZWN0aW9uID09PSB2b2lkIDAgPyB2b2lkIDAgOiByZXNldENvbm5lY3Rpb24udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIHJlc2V0Q29ubmVjdGlvbiA9IG51bGw7XG4gICAgICAgIH07XG4gICAgICAgIHZhciByZXNldCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGNhbmNlbFJlc2V0KCk7XG4gICAgICAgICAgICBjb25uZWN0aW9uID0gc3ViamVjdCA9IG51bGw7XG4gICAgICAgICAgICBoYXNDb21wbGV0ZWQgPSBoYXNFcnJvcmVkID0gZmFsc2U7XG4gICAgICAgIH07XG4gICAgICAgIHZhciByZXNldEFuZFVuc3Vic2NyaWJlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgdmFyIGNvbm4gPSBjb25uZWN0aW9uO1xuICAgICAgICAgICAgcmVzZXQoKTtcbiAgICAgICAgICAgIGNvbm4gPT09IG51bGwgfHwgY29ubiA9PT0gdm9pZCAwID8gdm9pZCAwIDogY29ubi51bnN1YnNjcmliZSgpO1xuICAgICAgICB9O1xuICAgICAgICByZXR1cm4gb3BlcmF0ZShmdW5jdGlvbiAoc291cmNlLCBzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICByZWZDb3VudCsrO1xuICAgICAgICAgICAgaWYgKCFoYXNFcnJvcmVkICYmICFoYXNDb21wbGV0ZWQpIHtcbiAgICAgICAgICAgICAgICBjYW5jZWxSZXNldCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGRlc3QgPSAoc3ViamVjdCA9IHN1YmplY3QgIT09IG51bGwgJiYgc3ViamVjdCAhPT0gdm9pZCAwID8gc3ViamVjdCA6IGNvbm5lY3RvcigpKTtcbiAgICAgICAgICAgIHN1YnNjcmliZXIuYWRkKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICByZWZDb3VudC0tO1xuICAgICAgICAgICAgICAgIGlmIChyZWZDb3VudCA9PT0gMCAmJiAhaGFzRXJyb3JlZCAmJiAhaGFzQ29tcGxldGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc2V0Q29ubmVjdGlvbiA9IGhhbmRsZVJlc2V0KHJlc2V0QW5kVW5zdWJzY3JpYmUsIHJlc2V0T25SZWZDb3VudFplcm8pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgZGVzdC5zdWJzY3JpYmUoc3Vic2NyaWJlcik7XG4gICAgICAgICAgICBpZiAoIWNvbm5lY3Rpb24pIHtcbiAgICAgICAgICAgICAgICBjb25uZWN0aW9uID0gbmV3IFNhZmVTdWJzY3JpYmVyKHtcbiAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHZhbHVlKSB7IHJldHVybiBkZXN0Lm5leHQodmFsdWUpOyB9LFxuICAgICAgICAgICAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaGFzRXJyb3JlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWxSZXNldCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDb25uZWN0aW9uID0gaGFuZGxlUmVzZXQocmVzZXQsIHJlc2V0T25FcnJvciwgZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0NvbXBsZXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWxSZXNldCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDb25uZWN0aW9uID0gaGFuZGxlUmVzZXQocmVzZXQsIHJlc2V0T25Db21wbGV0ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZXN0LmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgZnJvbShzb3VyY2UpLnN1YnNjcmliZShjb25uZWN0aW9uKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSkod3JhcHBlclNvdXJjZSk7XG4gICAgfTtcbn1cbmZ1bmN0aW9uIGhhbmRsZVJlc2V0KHJlc2V0LCBvbikge1xuICAgIHZhciBhcmdzID0gW107XG4gICAgZm9yICh2YXIgX2kgPSAyOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgYXJnc1tfaSAtIDJdID0gYXJndW1lbnRzW19pXTtcbiAgICB9XG4gICAgaWYgKG9uID09PSB0cnVlKSB7XG4gICAgICAgIHJlc2V0KCk7XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cbiAgICBpZiAob24gPT09IGZhbHNlKSB7XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cbiAgICByZXR1cm4gb24uYXBwbHkodm9pZCAwLCBfX3NwcmVhZEFycmF5KFtdLCBfX3JlYWQoYXJncykpKS5waXBlKHRha2UoMSkpXG4gICAgICAgIC5zdWJzY3JpYmUoZnVuY3Rpb24gKCkgeyByZXR1cm4gcmVzZXQoKTsgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1zaGFyZS5qcy5tYXAiLCJpbXBvcnQgeyBSZXBsYXlTdWJqZWN0IH0gZnJvbSAnLi4vUmVwbGF5U3ViamVjdCc7XG5pbXBvcnQgeyBzaGFyZSB9IGZyb20gJy4vc2hhcmUnO1xuZXhwb3J0IGZ1bmN0aW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cENvdW50IDw9IDBcbiAgICAgICAgP1xuICAgICAgICAgICAgaWRlbnRpdHlcbiAgICAgICAgOiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgICAgIHZhciByaW5nID0gbmV3IEFycmF5KHNraXBDb3VudCk7XG4gICAgICAgICAgICB2YXIgc2VlbiA9IDA7XG4gICAgICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlSW5kZXggPSBzZWVuKys7XG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlSW5kZXggPCBza2lwQ291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmluZ1t2YWx1ZUluZGV4XSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gdmFsdWVJbmRleCAlIHNraXBDb3VudDtcbiAgICAgICAgICAgICAgICAgICAgdmFyIG9sZFZhbHVlID0gcmluZ1tpbmRleF07XG4gICAgICAgICAgICAgICAgICAgIHJpbmdbaW5kZXhdID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChvbGRWYWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICByaW5nID0gbnVsbDtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9c2tpcExhc3QuanMubWFwIiwiaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlmdCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1Yn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AgICAgICAgICAgICAgICBpZiAoY291bnQgPD0gc2Vlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXRha2UuanMubWFwIiwiaW1wb3J0IHsgX192YWx1ZXMgfSBmcm9tIFwidHNsaWJcIjtcbmltcG9ydCB7IEVNUFRZIH0gZnJvbSAnLi4vb2JzZXJ2YWJsZS9lbXB0eSc7XG5pbXBvcnQgeyBvcGVyYXRlIH0gZnJvbSAnLi4vdXRpbC9saWZ0JztcbmltcG9ydCB7IE9wZXJhdG9yU3Vic2NyaWJlciB9IGZyb20gJy4vT3BlcmF0b3JTdWJzY3JpYmVyJztcbmV4cG9ydCBmdW5jdGlvbiB0YWtlTGFzdChjb3VudCkge1xuICAgIHJldHVybiBjb3VudCA8PSAwXG4gICAgICAgID8gZnVuY3Rpb24gKCkgeyByZXR1cm4gRU1QVFk7IH1cbiAgICAgICAgOiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgICAgIHZhciBidWZmZXIgPSBbXTtcbiAgICAgICAgICAgIHNvdXJjZS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICBidWZmZXIucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgY291bnQgPCBidWZmZXIubGVuZ3RoICYmIGJ1ZmZlci5zaGlmdCgpO1xuICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHZhciBlXzEsIF9hO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGJ1ZmZlcl8xID0gX192YWx1ZXMoYnVmZmVyKSwgYnVmZmVyXzFfMSA9IGJ1ZmZlcl8xLm5leHQoKTsgIWJ1ZmZlcl8xXzEuZG9uZTsgYnVmZmVyXzFfMSA9IGJ1ZmZlcl8xLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gYnVmZmVyXzFfMS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVfMV8xKSB7IGVfMSA9IHsgZXJyb3I6IGVfMV8xIH07IH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChidWZmZXJfMV8xICYmICFidWZmZXJfMV8xLmRvbmUgJiYgKF9hID0gYnVmZmVyXzEucmV0dXJuKSkgX2EuY2FsbChidWZmZXJfMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzEpIHRocm93IGVfMS5lcnJvcjsgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9LCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBidWZmZXIgPSBudWxsO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXRha2VMYXN0LmpzLm1hcCIsImltcG9ydCB7IG9wZXJhdGUgfSBmcm9tICcuLi91dGlsL2xpZnQnO1xuaW1wb3J0IHsgT3BlcmF0b3JTdWJzY3JpYmVyIH0gZnJvbSAnLi9PcGVyYX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ICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGVfMV8xKSB7IGVfMSA9IHsgZXJyb3I6IGVfMV8xIH07IH1cbiAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh3aW5kb3dzXzFfMSAmJiAhd2luZG93c18xXzEuZG9uZSAmJiAoX2EgPSB3aW5kb3dzXzEucmV0dXJuKSkgX2EuY2FsbCh3aW5kb3dzXzEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMSkgdGhyb3cgZV8xLmVycm9yOyB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgYyA9IGNvdW50IC0gd2luZG93U2l6ZSArIDE7XG4gICAgICAgICAgICBpZiAoYyA+PSAwICYmIGMgJSBzdGFydEV2ZXJ5ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgd2luZG93cy5zaGlmdCgpLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoKytjb3VudCAlIHN0YXJ0RXZlcnkgPT09IDApIHtcbiAgICAgICAgICAgICAgICB2YXIgd2luZG93XzIgPSBuZXcgU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgIHdpbmRvd3MucHVzaCh3aW5kb3dfMik7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHdpbmRvd18yLmFzT2JzZXJ2YWJsZSgpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgd2hpbGUgKHdpbmRvd3MubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgIHdpbmRvd3Muc2hpZnQoKS5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICB9LCBmdW5jdGlvbiAoZX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ZXcgU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgIHZhciByZWNvcmRfMSA9IHtcbiAgICAgICAgICAgICAgICAgICAgd2luZG93OiB3aW5kb3dfMSxcbiAgICAgICAgICAgICAgICAgICAgc3Viczogc3VicyxcbiAgICAgICAgICAgICAgICAgICAgc2VlbjogMCxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIHdpbmRvd1JlY29yZHMucHVzaChyZWNvcmRfMSk7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHdpbmRvd18xLmFzT2JzZXJ2YWJsZSgpKTtcbiAgICAgICAgICAgICAgICBzdWJzLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZnVuY3Rpb24gKCkgeyByZXR1cm4gY2xvc2VXaW5kb3cocmVjb3JkXzEpOyB9LCB3aW5kb3dUaW1lU3BhbikpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICB3aW5kb3dDcmVhdGlvbkludGVydmFsICE9PSBudWxsICYmIHdpbmRvd0NyZWF0aW9uSW50ZXJ2YWwgPj0gMFxuICAgICAgICAgICAgP1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuYWRkKHNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0V2luZG93KCk7XG4gICAgICAgICAgICAgICAgICAgICF0aGlzLmNsb3NlZCAmJiBzdWJzY3JpYmVyLmFkZCh0aGlzLnNjaGVkdWxlKG51bGwsIHdpbmRvd0NyZWF0aW9uSW50ZXJ2YWwpKTtcbiAgICAgICAgICAgICAgICB9LCB3aW5kb3dDcmVhdGlvbkludGVydmFsKSlcbiAgICAgICAgICAgIDogKHJlc3RhcnRPbkNsb3NlID0gdHJ1ZSk7XG4gICAgICAgIHN0YXJ0V2luZG93KCk7XG4gICAgICAgIHZhciBsb29wID0gZnVuY3Rpb24gKGNiKSB7IHJldHVybiB3aW5kb3dSZW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ZXcgU3ViamVjdCgpO1xuICAgICAgICAgICAgd2luZG93cy5wdXNoKHdpbmRvdyk7XG4gICAgICAgICAgICB2YXIgY2xvc2luZ1N1YnNjcmlwdGlvbiA9IG5ldyBTdWJzY3JpcHRpb24oKTtcbiAgICAgICAgICAgIHZhciBjbG9zZVdpbmRvdyA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBhcnJSZW1vdmUod2luZG93cywgd2luZG93KTtcbiAgICAgICAgICAgICAgICB3aW5kb3cuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICBjbG9zaW5nU3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgdmFyIGNsb3NpbmdOb3RpZmllcjtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgY2xvc2luZ05vdGlmaWVyID0gaW5uZXJGcm9tKGNsb3NpbmdTZWxlY3RvcihvcGVuVmFsdWUpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBoYW5kbGVFcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh3aW5kb3cuYXNPYnNlcnZhYmxlKCkpO1xuICAgICAgICAgICAgY2xvc2luZ1N1YnNjcmlwdGlvbi5hZGQoY2xvc2luZ05vdGlmaWVyLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGNsb3NlV2luZG93LCBub29wLCBoYW5kbGVFcnJvcikpKTtcbiAgICAgICAgfSwgbm9vcCkpO1xuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICB2YXIgZV8xLCBfYTtcbiAgICAgICAgICAgIHZhciB3aW5kb3dzQ29weSA9IHdpbmRvd3Muc2xpY2UoKTtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgd2luZG93c0NvcHlfMSA9IF9fdmFsdWVzKHdpbmRvd3NDb3B5KSwgd2luZG93c0NvcHlfMV8xID0gd2luZG93c0NvcHlfMS5uZXh0KCk7ICF3aW5kb3dzQ29weV8xXzEuZG9uZTsgd2luZG93c0NvcHlfMV8xID0gd2luZG93c0NvcHlfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHdpbmRvd18xID0gd2luZG93c0NvcHlfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICB3aW5kb3dfMS5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHdpbmRvd3NDb3B5XzFfMSAmJiAhd2luZG93c0NvcHlfMV8xLmRvbmUgJiYgKF9hID0gd2luZG93c0NvcHlfMS5yZXR1cm4pKSBfYS5jYWxsKHdpbmRvd3NDb3B5XzEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMSkgdGhyb3cgZV8xLmVycm9yOyB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHdoaWxlICgwIDwgd2luZG93cy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB3aW5kb3dzLnNoaWZ0KCkuY29tcGxldGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbi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ICAgIHZhciBvdGhlclZhbHVlcyA9IG5ldyBBcnJheShsZW4pO1xuICAgICAgICB2YXIgaGFzVmFsdWUgPSBpbnB1dHMubWFwKGZ1bmN0aW9uICgpIHsgcmV0dXJuIGZhbHNlOyB9KTtcbiAgICAgICAgdmFyIHJlYWR5ID0gZmFsc2U7XG4gICAgICAgIHZhciBfbG9vcF8xID0gZnVuY3Rpb24gKGkpIHtcbiAgICAgICAgICAgIGlubmVyRnJvbShpbnB1dHNbaV0pLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgIG90aGVyVmFsdWVzW2ldID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgaWYgKCFyZWFkeSAmJiAhaGFzVmFsdWVbaV0pIHtcbiAgICAgICAgICAgICAgICAgICAgaGFzVmFsdWVbaV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAocmVhZHkgPSBoYXNWYWx1ZS5ldmVyeShpZGVudGl0eSkpICYmIChoYXNWYWx1ZSA9IG51bGwpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIG5vb3ApKTtcbiAgICAgICAgfTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgX2xvb3BfMShpKTtcbiAgICAgICAgfVxuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICBpZiAocmVhZHkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWVzID0gX19zcHJlYWRBcnJheShbdmFsdWVdLCBfX3JlYWQob3RoZXJWYWx1ZXMpKTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQocHJvamVjdCA/IHByb2plY3QuYXBwbHkod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xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1zY2hlZHVsZUFycmF5LmpzLm1hcCIsImltcG9ydCB7IE9ic2VydmFibGUgfSBmcm9tICcuLi9PYnNlcnZhYmxlJztcbmltcG9ydCB7IFN1YnNjcmlwdGlvbiB9IGZyb20gJy4uL1N1YnNjcmlwdGlvbic7XG5leHBvcnQgZnVuY3Rpb24gc2NoZWR1bGVBc3luY0l0ZXJhYmxlKGlucHV0LCBzY2hlZHVsZXIpIHtcbiAgICBpZiAoIWlucHV0KSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcignSXRlcmFibGUgY2Fubm90IGJlIG51bGwnKTtcbiAgICB9XG4gICAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBzdWIgPSBuZXcgU3Vic2NyaXB0aW9uKCk7XG4gICAgICAgIHN1Yi5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBpdGVyYXRvciA9IGlucHV0W1N5bWJvbC5hc3luY0l0ZXJhdG9yXSgpO1xuICAgICAgICAgICAgc3ViLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgICAgICAgICAgaXRlcmF0b3IubmV4dCgpLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0LmRvbmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1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gIHN3aXRjaCAoX2IubGFiZWwpIHtcbiAgICAgICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgICAgIHJlYWRlciA9IHJlYWRhYmxlU3RyZWFtLmdldFJlYWRlcigpO1xuICAgICAgICAgICAgICAgICAgICBfYi5sYWJlbCA9IDE7XG4gICAgICAgICAgICAgICAgY2FzZSAxOlxuICAgICAgICAgICAgICAgICAgICBfYi50cnlzLnB1c2goWzEsICwgOSwgMTBdKTtcbiAgICAgICAgICAgICAgICAgICAgX2IubGFiZWwgPSAyO1xuICAgICAgICAgICAgICAgIGNhc2UgMjpcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0cnVlKSByZXR1cm4gWzMsIDhdO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzQsIF9fYXdhaXQocmVhZGVyLnJlYWQoKSldO1xuICAgICAgICAgICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgICAgICAgICAgX2EgPSBfYi5zZW50KCksIHZhbHVlID0gX2EudmFsdWUsIGRvbmUgPSBfYS5kb25lO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIWRvbmUpIHJldHVybiBbMywgNV07XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgX19hd2FpdCh2b2lkIDApXTtcbiAgICAgICAgICAgICAgICBjYXNlIDQ6IHJldHVybiBbMiwgX2Iuc2VudCgpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDU6IHJldHVybiBbNCwgX19hd2FpdCh2YWx1ZSldO1xuICAgICAgICAgICAgICAgIGNhc2UgNjogcmV0dXJuIFs0LCBfYi5zZW50KCldO1xuICAgICAgICAgICAgICAgIGNhc2UgNzpcbiAgICAgICAgICAgICAgICAgICAgX2Iuc2VudCgpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzMsIDJdO1xuICAgICAgICAgICAgICAgIGNhc2UgODogcmV0dXJuIFszLCAxMF07XG4gICAgICAgICAgICAgICAgY2FzZSA5OlxuICAgICAgICAg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lb2YgdmFsdWUgPT09ICdvYmplY3QnICYmIHZhbHVlICE9PSBudWxsICYmIHR5cGVvZiB2YWx1ZS50b0pTT04gPT09ICdmdW5jdGlvbicpIHtcbiAgICAgIHZhbHVlID0gdmFsdWUudG9KU09OKGtleSlcbiAgICB9XG4gICAgdmFsdWUgPSByZXBsYWNlci5jYWxsKHBhcmVudCwga2V5LCB2YWx1ZSlcblxuICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7XG4gICAgICBjYXNlICdzdHJpbmcnOlxuICAgICAgICByZXR1cm4gc3RyRXNjYXBlKHZhbHVlKVxuICAgICAgY2FzZSAnb2JqZWN0Jzoge1xuICAgICAgICBpZiAodmFsdWUgPT09IG51bGwpIHtcbiAgICAgICAgICByZXR1cm4gJ251bGwnXG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YWNrLmluZGV4T2YodmFsdWUpICE9PSAtMSkge1xuICAgICAgICAgIHJldHVybiBjaXJjdWxhclZhbHVlXG4gICAgICAgIH1cblxuICAgICAgICBsZXQgcmVzID0gJydcbiAgICAgICAgbGV0IGpvaW4gPSAnLCdcbiAgICAgICAgY29uc3Qgb3JpZ2luYWxJbmRlbnRhdGlvbiA9IGluZGVudGF0aW9uXG5cbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuICdbXSdcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG1heGltdW1EZXB0aCA8IHN0YWNrLmxlbmd0aCArIDEpIHtcbiAgICAgICAgICAgIHJldHVybiAnXCJbQXJyYXldXCInXG4gICAgICAgICAgfVxuICAgICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgICAgaWYgKHNwYWNlciAhPT0gJycpIHtcbiAgICAgICAgICAgIGluZGVudGF0aW9uICs9IHNwYWNlclxuICAgICAgICAgICAgcmVzICs9IGBcXG4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gYFxcbiR7b3JpZ2luYWxJbmRlbnRhdGlvbn1gXG4gICAgICAgICAgfVxuICAgICAgICAgIHN0YWNrLnBvcCgpXG4gICAgICAgICAgcmV0dXJuIGBbJHtyZXN9XWBcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXModmFsdWUpXG4gICAgICAgIGNvbnN0IGtleUxlbmd0aCA9IGtleXMubGVuZ3RoXG4gICAgICAgIGlmIChrZXlMZW5ndGggPT09IDApIHtcbiAgICAgICAgICByZXR1cm4gJ3t9J1xuICAgICAgICB9XG4gICAgICAgIGlmIChtYXhpbXVtRGVwdGggPCBzdGFjay5sZW5ndGggKyAxKSB7XG4gICAgICAgICAgcmV0dXJuICdcIltPYmplY3RdXCInXG4gICAgICAgIH1cbiAgICAgICAgbGV0IHdoaXRlc3BhY2UgPSAnJ1xuICAgICAgICBsZXQgc2VwYXJhdG9yID0gJydcbiAgICAgICAgaWYgKHNwYWNlciAhPT0gJycpIHtcbiAgICAgICAgICBpbmRlbnRhdGlvbiArPSBzcGFjZXJcbiAgICAgICAgICBqb2luID0gYCxcXG4ke2luZGVudGF0aW9ufWBcbiAgICAgICAgICB3aGl0ZXNwYWNlID0gJyAnXG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeSA9IE1hdGgubWluKGtleUxlbmd0aCwgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgIGlmIChkZXRlcm1pbmlzdGljICYmICFpc1R5cGVkQXJyYXlXaXRoRW50cmllcyh2YWx1ZSkpIHtcbiAgICAgICAgICBrZXlzID0gc29ydChrZXlzLCBjb21wYXJhdG9yKVxuICAgICAgICB9XG4gICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeTsgaSsrKSB7XG4gICAgICAgICAgY29uc3Qga2V5ID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BsZXQgam9pbiA9ICcsJ1xuXG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KHZhbHVlKSkge1xuICAgICAgICAgIGlmICh2YWx1ZS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgIHJldHVybiAnW10nXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChtYXhpbXVtRGVwdGggPCBzdGFjay5sZW5ndGggKyAxKSB7XG4gICAgICAgICAgICByZXR1cm4gJ1wiW0FycmF5XVwiJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBzdGFjay5wdXNoKHZhbHVlKVxuICAgICAgICAgIGlmIChzcGFjZXIgIT09ICcnKSB7XG4gICAgICAgICAgICBpbmRlbnRhdGlvbiArPSBzcGFjZXJcbiAgICAgICAgICAgIHJlcyArPSBgXFxuJHtpbmRlbnRhdGlvbn1gXG4gICAgICAgICAgICBqb2luID0gYCxcXG4ke2luZGVudGF0aW9ufWBcbiAgICAgICAgICB9XG4gICAgICAgICAgY29uc3QgbWF4aW11bVZhbHVlc1RvU3RyaW5naWZ5ID0gTWF0aC5taW4odmFsdWUubGVuZ3RoLCBtYXhpbXVtQnJlYWR0aClcbiAgICAgICAgICBsZXQgaSA9IDBcbiAgICAgICAgICBmb3IgKDsgaSA8IG1heGltdW1WYWx1ZXNUb1N0cmluZ2lmeSAtIDE7IGkrKykge1xuICAgICAgICAgICAgY29uc3QgdG1wID0gc3RyaW5naWZ5QXJyYXlSZXBsYWNlcihTdHJpbmcoaSksIHZhbHVlW2ldLCBzdGFjaywgcmVwbGFjZXIsIHNwYWNlciwgaW5kZW50YXRpb24pXG4gICAgICAgICAgICByZXMgKz0gdG1wICE9PSB1bmRlZmluZWQgPyB0bXAgOiAnbnVsbCdcbiAgICAgICAgICAgIHJlcyArPSBqb2luXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeUFycmF5UmVwbGFjZXIoU3RyaW5nKGkpLCB2YWx1ZVtpXSwgc3RhY2ssIHJlcGxhY2VyLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIHJlcyArPSB0bXAgIT09IHVuZGVmaW5lZCA/IHRtcCA6ICdudWxsJ1xuICAgICAgICAgIGlmICh2YWx1ZS5sZW5ndGggLSAxID4gbWF4aW11bUJyZWFkdGgpIHtcbiAgICAgICAgICAgIGNvbnN0IHJlbW92ZWRLZXlzID0gdmFsdWUubGVuZ3RoIC0gbWF4aW11bUJyZWFkdGggLSAxXG4gICAgICAgICAgICByZXMgKz0gYCR7am9pbn1cIi4uLiAke2dldEl0ZW1Db3VudChyZW1vdmVkS2V5cyl9IG5vdCBzdHJpbmdpZmllZFwiYFxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoc3BhY2VyICE9PSAnJykge1xuICAgICAgICAgICAgcmVzICs9IGBcXG4ke29yaWdpbmFsSW5kZW50YXRpb259YFxuICAgICAgICAgIH1cbiAgICAgICAgICBzdGFjay5wb3AoKVxuICAgICAgICAgIHJldHVybiBgWyR7cmVzfV1gXG4gICAgICAgIH1cbiAgICAgICAgc3RhY2sucHVzaCh2YWx1ZSlcbiAgICAgICAgbGV0IHdoaXRlc3BhY2UgPSAnJ1xuICAgICAgICBpZiAoc3BhY2VyICE9PSAnJykge1xuICAgICAgICAgIGluZGVudGF0aW9uICs9IHNwYWNlclxuICAgICAgICAgIGpvaW4gPSBgLFxcbiR7aW5kZW50YXRpb259YFxuICAgICAgICAgIHdoaXRlc3BhY2UgPSAnICdcbiAgICAgICAgfVxuICAgICAgICBsZXQgc2VwYXJhdG9yID0gJydcbiAgICAgICAgZm9yIChjb25zdCBrZXkgb2YgcmVwbGFjZXIpIHtcbiAgICAgICAgICBjb25zdCB0bXAgPSBzdHJpbmdpZnlBcnJheVJlcGxhY2VyKGtleSwgdmFsdWVba2V5XSwgc3RhY2ssIHJlcGxhY2VyLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIGlmICh0bXAgIT09IHVuZGVmaW5lZCkge1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UgJ3N0cmluZyc6XG4gICAgICAgIHJldHVybiBzdHJFc2NhcGUodmFsdWUpXG4gICAgICBjYXNlICdvYmplY3QnOiB7XG4gICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCkge1xuICAgICAgICAgIHJldHVybiAnbnVsbCdcbiAgICAgICAgfVxuICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnRvSlNPTiA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgIHZhbHVlID0gdmFsdWUudG9KU09OKGtleSlcbiAgICAgICAgICAvLyBQcmV2ZW50IGNhbGxpbmcgYHRvSlNPTmAgYWdhaW4uXG4gICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgIHJldHVybiBzdHJpbmdpZnlJbmRlbnQoa2V5LCB2YWx1ZSwgc3RhY2ssIHNwYWNlciwgaW5kZW50YXRpb24pXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuICdudWxsJ1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhY2suaW5kZXhPZih2YWx1ZSkgIT09IC0xKSB7XG4gICAgICAgICAgcmV0dXJuIGNpcmN1bGFyVmFsdWVcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBvcmlnaW5hbEluZGVudGF0aW9uID0gaW5kZW50YXRpb25cblxuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICBpZiAodmFsdWUubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICByZXR1cm4gJ1tdJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobWF4aW11bURlcHRoIDwgc3RhY2subGVuZ3RoICsgMSkge1xuICAgICAgICAgICAgcmV0dXJuICdcIltBcnJheV1cIidcbiAgICAgICAgICB9XG4gICAgICAgICAgc3RhY2sucHVzaCh2Y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FxcbiR7b3JpZ2luYWxJbmRlbnRhdGlvbn1gXG4gICAgICAgICAgc3RhY2sucG9wKClcbiAgICAgICAgICByZXR1cm4gYFske3Jlc31dYFxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyh2YWx1ZSlcbiAgICAgICAgY29uc3Qga2V5TGVuZ3RoID0ga2V5cy5sZW5ndGhcbiAgICAgICAgaWYgKGtleUxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgIHJldHVybiAne30nXG4gICAgICAgIH1cbiAgICAgICAgaWYgKG1heGltdW1EZXB0aCA8IHN0YWNrLmxlbmd0aCArIDEpIHtcbiAgICAgICAgICByZXR1cm4gJ1wiW09iamVjdF1cIidcbiAgICAgICAgfVxuICAgICAgICBpbmRlbnRhdGlvbiArPSBzcGFjZXJcbiAgICAgICAgY29uc3Qgam9pbiA9IGAsXFxuJHtpbmRlbnRhdGlvbn1gXG4gICAgICAgIGxldCByZXMgPSAnJ1xuICAgICAgICBsZXQgc2VwYXJhdG9yID0gJydcbiAgICAgICAgbGV0IG1heGltdW1Qcm9wZXJ0aWVzVG9TdHJpbmdpZnkgPSBNYXRoLm1pbihrZXlMZW5ndGgsIG1heGltdW1CcmVhZHRoKVxuICAgICAgICBpZiAoaXNUeXBlZEFycmF5V2l0aEVudHJpZXModmFsdWUpKSB7XG4gICAgICAgICAgcmVzICs9IHN0cmluZ2lmeVR5cGVkQXJyYXkodmFsdWUsIGpvaW4sIG1heGltdW1CcmVhZHRoKVxuICAgICAgICAgIGtleXMgPSBrZXlzLnNsaWNlKHZhbHVlLmxlbmd0aClcbiAgICAgICAgICBtYXhpbXVtUHJvcGVydGllc1RvU3RyaW5naWZ5IC09IHZhbHVlLmxlbmd0aFxuICAgICAgICAgIHNlcGFyYXRvciA9IGpvaW5cbiAgICAgICAgfVxuICAgICAgICBpZiAoZGV0ZXJtaW5pc3RpYykge1xuICAgICAgICAgIGtleXMgPSBzb3J0KGtleXMsIGNvbXBhcmF0b3IpXG4gICAgICAgIH1cbiAgICAgICAgc3RhY2sucHVzaCh2YWx1ZSlcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBtYXhpbXVtUHJvcGVydGllc1RvU3RyaW5naWZ5OyBpKyspIHtcbiAgICAgICAgICBjb25zdCBrZXkgPSBrZXlzW2ldXG4gICAgICAgICAgY29uc3QgdG1wID0gc3RyaW5naWZ5SW5kZW50KGtleSwgdmFsdWVba2V5XSwgc3RhY2ssIHNwYWNlciwgaW5kZW50YXRpb24pXG4gICAgICAgICAgaWYgKHRtcCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICByZXMgKz0gYCR7c2VwYXJhdG9yfSR7c3RyRXNjYXBlKGtleSl9OiAke3RtcH1gXG4gICAgICAgICAgICBzZXBhcmF0b3IgPSBqb2luXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChrZXlMZW5ndGggPiBtYXhpbXVtQnJlYWR0aCkge1xuICAgICAgICAgIGNvbnN0IHJlbW92ZWRLZXlzID0ga2V5TGVuZ3RoIC0gbWF4aW11bUJyZWFkdGhcbiAgICAgICAgICByZXMgKz0gYCR7c2VwYXJhdG9yfVwiLi4uXCI6IFwiJHtnZXRJdGVtQ291bnQocmVtb3ZlZEtleXMpfSBub3Qgc3RyaW5naWZpZWRcImBcbiAgICAgICAgICBzZXBhcmF0b3IgPSBqb2luXG4gICAgICAgIH1cbiAgICAgICAgaWYgKHNlcGFyYXRvciAhPT0gJycpIHtcbiAgICAgICAgICByZXMgPSBgXFxuJHtpbmRlbnRhdGlvbn0ke3Jlc31cXG4ke29yaWdpbmFsSW5kZW50YXRpb259YFxuICAgICAgICB9XG4gICAgICAgIHN0YWNrLnBvcCgpXG4gICAgICAgIHJldHVybiBgeyR7cmVzfX1gXG4gICAgICB9XG4gICAgICBjYXNlICdudW1iZXInOlxuICAgICAgICByZXR1cm4gaXNGaW5pdGUodmFsdWUpID8gU3RyaW5nKHZhbHVlKS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A9PT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuICdudWxsJ1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhY2suaW5kZXhPZih2YWx1ZSkgIT09IC0xKSB7XG4gICAgICAgICAgcmV0dXJuIGNpcmN1bGFyVmFsdWVcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCByZXMgPSAnJ1xuXG4gICAgICAgIGNvbnN0IGhhc0xlbmd0aCA9IHZhbHVlLmxlbmd0aCAhPT0gdW5kZWZpbmVkXG4gICAgICAgIGlmIChoYXNMZW5ndGggJiYgQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICBpZiAodmFsdWUubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICByZXR1cm4gJ1tdJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobWF4aW11bURlcHRoIDwgc3RhY2subGVuZ3RoICsgMSkge1xuICAgICAgICAgICAgcmV0dXJuICdcIltBcnJheV1cIidcbiAgICAgICAgICB9XG4gICAgICAgICAgc3RhY2sucHVzaCh2YWx1ZSlcbiAgICAgICAgICBjb25zdCBtYXhpbXVtVmFsdWVzVG9TdHJpbmdpZnkgPSBNYXRoLm1pbih2YWx1ZS5sZW5ndGgsIG1heGltdW1CcmVhZHRoKVxuICAgICAgICAgIGxldCBpID0gMFxuICAgICAgICAgIGZvciAoOyBpIDwgbWF4aW11bVZhbHVlc1RvU3RyaW5naWZ5IC0gMTsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCB0bXAgPSBzdHJpbmdpZnlTaW1wbGUoU3RyaW5nKGkpLCB2YWx1ZVtpXSwgc3RhY2spXG4gICAgICAgICAgICByZXMgKz0gdG1wICE9PSB1bmRlZmluZWQgPyB0bXAgOiAnbnVsbCdcbiAgICAgICAgICAgIHJlcyArPSAnLCdcbiAgICAgICAgICB9XG4gICAgICAgICAgY29uc3QgdG1wID0gc3RyaW5naWZ5U2ltcGxlKFN0cmluZyhpKSwgdmFsdWVbaV0sIHN0YWNrKVxuICAgICAgICAgIHJlcyArPSB0bXAgIT09IHVuZGVmaW5lZCA/IHRtcCA6ICdudWxsJ1xuICAgICAgICAgIGlmICh2YWx1ZS5sZW5ndGggLSAxID4gbWF4aW11bUJyZWFkdGgpIHtcbiAgICAgICAgICAgIGNvbnN0IHJlbW92ZWRLZXlzID0gdmFsdWUubGVuZ3RoIC0gbWF4aW11bUJyZWFkdGggLSAxXG4gICAgICAgICAgICByZXMgKz0gYCxcIi4uLiAke2dldEl0ZW1Db3VudChyZW1vdmVkS2V5cyl9IG5vdCBzdHJpbmdpZmllZFwiYFxuICAgICAgICAgIH1cbiAgICAgICAgICBzdGFjay5wb3AoKVxuICAgICAgICAgIHJldHVybiBgWyR7cmVzfV1gXG4gICAgICAgIH1cblxuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKHZhbHVlKVxuICAgICAgICBjb25zdCBrZXlMZW5ndGggPSBrZXlzLmxlbmd0aFxuICAgICAgICBpZiAoa2V5TGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgcmV0dXJuICd7fSdcbiAgICAgICAgfVxuICAgICAgICBpZiAobWF4aW11bURlcHRoIDwgc3RhY2subGVuZ3RoICsgMSkge1xuICAgICAgICAgIHJldHVybiAnXCJbT2JqZWN0XVwiJ1xuICAgICAgICB9XG4gICAgICAgIGxldCBzZXBhcmF0b3IgPSAnJ1xuICAgICAgICBsZXQgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeSA9IE1hdGgubWluKGtleUxlbmd0aCwgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgIGlmIChoYXNMZW5ndGggJiYgaXNUeXBlZEFycmF5V2l0aEVudHJpZXModmFsdWUpKSB7XG4gICAgICAgICAgcmVzICs9IHN0cmluZ2lmeVR5cGVkQXJyYXkodmFsdWUsICcsJywgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgICAga2V5cyA9IGtleXMuc2xpY2UodmFsdW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sXG4gICAgJ2FsZWZzeW0nOiA4NTAxLFxuICAgICdsYXJyJzogODU5MixcbiAgICAndWFycic6IDg1OTMsXG4gICAgJ3JhcnInOiA4NTk0LFxuICAgICdkYXJyJzogODU5NSxcbiAgICAnaGFycic6IDg1OTYsXG4gICAgJ2NyYXJyJzogODYyOSxcbiAgICAnbEFycic6IDg2NTYsXG4gICAgJ3VBcnInOiA4NjU3LFxuICAgICdyQXJyJzogODY1OCxcbiAgICAnZEFycic6IDg2NTksXG4gICAgJ2hBcnInOiA4NjYwLFxuICAgICdmb3JhbGwnOiA4NzA0LFxuICAgICdwYXJ0JzogODcwNixcbiAgICAnZXhpc3QnOiA4NzA3LFxuICAgICdlbXB0eSc6IDg3MDksXG4gICAgJ25hYmxhJzogODcxMSxcbiAgICAnaXNpbic6IDg3MTIsXG4gICAgJ25vdGluJzogODcxMyxcbiAgICAnbmknOiA4NzE1LFxuICAgICdwcm9kJzogODcxOSxcbiAgICAnc3VtJzogODcyMSxcbiAgICAnbWludXMnOiA4NzIyLFxuICAgICdsb3dhc3QnOiA4NzI3LFxuICAgICdyYWRpYyc6IDg3MzAsXG4gICAgJ3Byb3AnOiA4NzMzLFxuICAgICdpbmZpbic6IDg3MzQsXG4gICAgJ2FuZyc6IDg3MzYsXG4gICAgJ2FuZCc6IDg3NDMsXG4gICAgJ29yJzogODc0NCxcbiAgICAnY2FwJzogODc0NSxcbiAgICAnY3VwJzogODc0NixcbiAgICAnaW50JzogODc0NyxcbiAgICAndGhlcmU0JzogODc1NixcbiAgICAnc2ltJzogODc2NCxcbiAgICAnY29uZyc6IDg3NzMsXG4gICAgJ2FzeW1wJzogODc3NixcbiAgICAnbmUnOiA4ODAwLFxuICAgICdlcXVpdic6IDg4MDEsXG4gICAgJ2xlJzogODgwNCxcbiAgICAnZ2UnOiA4ODA1LFxuICAgICdzdWInOiA4ODM0LFxuICAgICdzdXAnOiA4ODM1LFxuICAgICduc3ViJzogODgzNixcbiAgICAnc3ViZSc6IDg4Mz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HVlID0gJydcbiAgfVxuXG4gIGZ1bmN0aW9uIG9wZW5UYWcgKHBhcnNlciwgc2VsZkNsb3NpbmcpIHtcbiAgICBpZiAocGFyc2VyLm9wdC54bWxucykge1xuICAgICAgLy8gZW1pdCBuYW1lc3BhY2UgYmluZGluZyBldmVudHNcbiAgICAgIHZhciB0YWcgPSBwYXJzZXIudGFnXG5cbiAgICAgIC8vIGFkZCBuYW1lc3BhY2UgaW5mbyB0byB0YWdcbiAgICAgIHZhciBxbiA9IHFuYW1lKHBhcnNlci50YWdOYW1lKVxuICAgICAgdGFnLnByZWZpeCA9IHFuLnByZWZpeFxuICAgICAgdGFnLmxvY2FsID0gcW4ubG9jYWxcbiAgICAgIHRhZy51cmkgPSB0YWcubnNbcW4ucHJlZml4XSB8fCAnJ1xuXG4gICAgICBpZiAodGFnLnByZWZpeCAmJiAhdGFnLnVyaSkge1xuICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ1VuYm91bmQgbmFtZXNwYWNlIHByZWZpeDogJyArXG4gICAgICAgICAgSlNPTi5zdHJpbmdpZnkocGFyc2VyLnRhZ05hbWUpKVxuICAgICAgICB0YWcudXJpID0gcW4ucHJlZml4XG4gICAgICB9XG5cbiAgICAgIHZhciBwYXJlbnQgPSBwYXJzZXIudGFnc1twYXJzZXIudGFncy5sZW5ndGggLSAxXSB8fCBwYXJzZXJcbiAgICAgIGlmICh0YWcubnMgJiYgcGFyZW50Lm5zICE9PSB0YWcubnMpIHtcbiAgICAgICAgT2JqZWN0LmtleXModGFnLm5zKS5mb3JFYWNoKGZ1bmN0aW9uIChwKSB7XG4gICAgICAgICAgZW1pdE5vZGUocGFyc2VyLCAnb25vcGVubmFtZXNwYWNlJywge1xuICAgICAgICAgICAgcHJlZml4OiBwLFxuICAgICAgICAgICAgdXJpOiB0YWcubnNbcF1cbiAgICAgICAgICB9KVxuICAgICAgICB9KVxuICAgICAgfVxuXG4gICAgICAvLyBoYW5kbGUgZGVmZXJyZWQgb25hdHRy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ICBwYXJzZXIubGluZSsrXG4gICAgICAgICAgcGFyc2VyLmNvbHVtbiA9IDBcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwYXJzZXIuY29sdW1uKytcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICBzd2l0Y2ggKHBhcnNlci5zdGF0ZSkge1xuICAgICAgICBjYXNlIFMuQkVHSU46XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5CRUdJTl9XSElURVNQQUNFXG4gICAgICAgICAgaWYgKGMgPT09ICdcXHVGRUZGJykge1xuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9XG4gICAgICAgICAgYmVnaW5XaGl0ZVNwYWNlKHBhcnNlciwgYylcbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5CRUdJTl9XSElURVNQQUNFOlxuICAgICAgICAgIGJlZ2luV2hpdGVTcGFjZShwYXJzZXIsIGMpXG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuVEVYVDpcbiAgICAgICAgICBpZiAocGFyc2VyLnNhd1Jvb3QgJiYgIXBhcnNlci5jbG9zZWRSb290KSB7XG4gICAgICAgICAgICB2YXIgc3RhcnRpID0gaSAtIDFcbiAgICAgICAgICAgIHdoaWxlIChjICYmIGMgIT09ICc8JyAmJiBjICE9PSAnJicpIHtcbiAgICAgICAgICAgICAgYyA9IGNoYXJBdChjaHVuaywgaSsrKVxuICAgICAgICAgICAgICBpZiAoYyAmJiBwYXJzZXIudHJhY2tQb3NpdGlvbikge1xuICAgICAgICAgICAgICAgIHBhcnNlci5wb3NpdGlvbisrXG4gICAgICAgICAgICAgICAgaWYgKGMgPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICBwYXJzZXIubGluZSsrXG4gICAgICAgICAgICAgICAgICBwYXJzZXIuY29sdW1uID0gMFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBwYXJzZXIuY29sdW1uKytcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSArPSBjaHVuay5zdWJzdHJpbmcoc3RhcnRpLCBpIC0gMSlcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGMgPT09ICc8JyAmJiAhKHBhcnNlci5zYXdSb290ICYmIHBhcnNlci5jbG9zZWRSb290ICYmICFwYXJzZXIuc3RyaWN0KSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1dBS0FcbiAgICAgICAgICAgIHBhcnNlci5zdGFydFRhZ1Bvc2l0aW9uID0gcGFyc2VyLnBvc2l0aW9uXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICghaXNXaGl0ZXNwYWNlKGMpICYmICghcGFyc2VyLnNhd1Jvb3QgfHwgcGFyc2VyLmNsb3NlZFJvb3QpKSB7XG4gICAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnVGV4dCBkYXRhIG91dHNpZGUgb2Ygcm9vdCBub2RlLicpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoYyA9PT0gJyYnKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVF9FTlRJVFlcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSArPSBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlNDUklQVDpcbiAgICAgICAgICAvLyBvbmx5IG5vbi1zdHJpY3RcbiAgICAgICAgICBpZiAoYyA9PT0gJzwnKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlNDUklQVF9FTkRJTkdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnNjcmlwdCArPSBjXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlNDUklQVF9FTkRJTkc6XG4gICAgICAgICAgaWYgKGMgPT09ICcvJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DTE9TRV9UQUdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnNjcmlwdCArPSAnPCcgKyBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlNDUklQVFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5PUEVOX1dBS0E6XG4gICAgICAgICAgLy8gZWl0aGVyIGEgLywgPywgISwgb3IgdGV4dCBpcyBjb21pbmcgbmV4dC5cbiAgICAgICAgICBpZiAoYyA9PT0gJyEnKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlNHTUxfREVDTFxuICAgICAgICAgICAgcGFyc2VyLnNnbWxEZWNsID0gJydcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgLy8gd2FpdCBmb3IgaXQuLi5cbiAgICAgICAgICB9IGVsc2UgaWYgKGlzTWF0Y2gobmFtZVN0YXJ0LCBjKSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR1xuICAgICAgICAgICAgcGFyc2VyLnRhZ05hbWUgPSBjXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnLycpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0xPU0VfVEFHXG4gICAgICAgICAgICBwYXJzZXIudGFnTmFtZSA9ICcnXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPycpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUXG4gICAgICAgICAgICBwYXJzZXIucHJvY0luc3ROYW1lID0gcGFyc2VyLnByb2NJbnN0Qm9keSA9ICcnXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnVW5lbmNvZGVkIDwnKVxuICAgICAgICAgICAgLy8gaWYgdGhlcmUgd2FzIHNvbWUgd2hpdGVzcGFjZSwgdGhlbiBhZGQgdGhhdCBpbi5cbiAgICAgICAgICAgIGlmIChwYXJzZXIuc3RhcnRUYWdQb3NpdGlvbiArIDEgPCBwYXJzZXIucG9zaXRpb24pIHtcbiAgICAgICAgICAgICAgdmFyIHBhZCA9IHBhcnNlci5wb3NpdGlvbiAtIHBhcnNlci5zdGFydFRhZ1Bvc2l0aW9uXG4gICAgICAgICAgICAgIGMgPSBuZXcgQXJyYXkocGFkKS5qb2luKCcgJykgKyBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXJzZXIudGV4dE5vZGUgKz0gJzwnICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5URVhUXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlNHTUxfREVDTDpcbiAgICAgICAgICBpZiAocGFyc2VyLnNnbWxEZWNsICsgYyA9PT0gJy0tJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UXG4gICAgICAgICAgICBwYXJzZXIuY29tbWVudCA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgPSAnJ1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKHBhcnNlci5kb2N0eXBlICYmIHBhcnNlci5kb2N0eXBlICE9PSB0cnVlICYmIHBhcnNlci5zZ21sRGVjbCkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX0RURFxuICAgICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gJzwhJyArIHBhcnNlci5zZ21sRGVjbCArIGNcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgfSBlbHNlIGlmICgocGFyc2VyLnNnbWxEZWNsICsgYykudG9VcHBlckNhc2UoKSA9PT0gQ0RBVEEpIHtcbiAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29ub3BlbmNkYXRhJylcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0RBVEFcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgPSAnJ1xuICAgICAgICAgIH0gZWxzZSBpZiAoKHBhcnNlci5zZ21sRGVjbCArIGMpLnRvVXBwZXJDYXNlKCkgPT09IERPQ1RZUEUpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRVxuICAgICAgICAgICAgaWYgKHBhcnNlci5kb2N0eXBlIHx8IHBhcnNlci5zYXdSb290KSB7XG4gICAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLFxuICAgICAgICAgICAgICAgICdJbmFwcHJvcHJpYXRlbHkgbG9jYXRlZCBkb2N0eXBlIGRlY2xhcmF0aW9uJylcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uc2dtbGRlY2xhcmF0aW9uJywgcGFyc2VyLnNnbWxEZWNsKVxuICAgICAgICAgICAgcGFyc2VyLnNnbWxEZWNsID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNRdW90ZShjKSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TR01MX0RFQ0xfUVVPVEVEXG4gICAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgKz0gY1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5TR01MX0RFQ0xfUVVPVEVEOlxuICAgICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TR01MX0RFQ0xcbiAgICAgICAgICAgIHBhcnNlci5xID0gJydcbiAgICAgICAgICB9XG4gICAgICAgICAgcGFyc2VyLnNnbWxEZWNsICs9IGNcbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5ET0NUWVBFOlxuICAgICAgICAgIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgICAgZW1pdE5vZGUocGFyc2VyLCAnb25kb2N0eXBlJywgcGFyc2VyLmRvY3R5cGUpXG4gICAgICAgICAgICBwYXJzZXIuZG9jdHlwZSA9IHRydWUgLy8ganVzdCByZW1lbWJlciB0aGF0IHdlIHNhdyBpdC5cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgICAgaWYgKGMgPT09ICdbJykge1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVfRFREXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzUXVvdGUoYykpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX1FVT1RFRFxuICAgICAgICAgICAgICBwYXJzZXIucSA9IGNcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuRE9DVFlQRV9RVU9URUQ6XG4gICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgICAgcGFyc2VyLnEgPSAnJ1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkRPQ1RZUEVfRFREOlxuICAgICAgICAgIGlmIChjID09PSAnXScpIHtcbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRVxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJzwnKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLk9QRU5fV0FLQVxuICAgICAgICAgICAgcGFyc2VyLnN0YXJ0VGFnUG9zaXRpb24gPSBwYXJzZXIucG9zaXRpb25cbiAgICAgICAgICB9IGVsc2UgaWYgKGlzUXVvdGUoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9EVERfUVVPVEVEXG4gICAgICAgICAgICBwYXJzZXIucSA9IGNcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5ET0NUWVBFX0RURF9RVU9URUQ6XG4gICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX0RURFxuICAgICAgICAgICAgcGFyc2VyLnEgPSAnJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DT01NRU5UOlxuICAgICAgICAgIGlmIChjID09PSAnLScpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ09NTUVOVF9FTkRJTkdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmNvbW1lbnQgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DT01NRU5UX0VORElORzpcbiAgICAgICAgICBpZiAoYyA9PT0gJy0nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRfRU5ERURcbiAgICAgICAgICAgIHBhcnNlci5jb21tZW50ID0gdGV4dG9wdHMocGFyc2VyLm9wdCwgcGFyc2VyLmNvbW1lbnQpXG4gICAgICAgICAgICBpZiAocGFyc2VyLmNvbW1lbnQpIHtcbiAgICAgICAgICAgICAgZW1pdE5vZGUocGFyc2VyLCAnb25jb21tZW50JywgcGFyc2VyLmNvbW1lbnQpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXJzZXIuY29tbWVudCA9ICcnXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5jb21tZW50ICs9ICctJyArIGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ09NTUVOVFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DT01NRU5UX0VOREVEOlxuICAgICAgICAgIGlmIChjICE9PSAnPicpIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnTWFsZm9ybWVkIGNvbW1lbnQnKVxuICAgICAgICAgICAgLy8gYWxsb3cgPCEtLSBibGFoIC0tIGJsb28gLS0+IGluIG5vbi1zdHJpY3QgbW9kZSxcbiAgICAgICAgICAgIC8vIHdoaWNoIGlzIGEgY29tbWVudCBvZiBcIiBibGFoIC0tIGJsb28gXCJcbiAgICAgICAgICAgIHBhcnNlci5jb21tZW50ICs9ICctLScgKyBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRcbiAgICAgICAgICB9IGVsc2UgaWYgKHBhcnNlci5kb2N0eXBlICYmIHBhcnNlci5kb2N0eXBlICE9PSB0cnVlKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVfRFREXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DREFUQTpcbiAgICAgICAgICBpZiAoYyA9PT0gJ10nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNEQVRBX0VORElOR1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DREFUQV9FTkRJTkc6XG4gICAgICAgICAgaWYgKGMgPT09ICddJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQV9FTkRJTkdfMlxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gJ10nICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DREFUQV9FTkRJTkdfMjpcbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBpZiAocGFyc2VyLmNkYXRhKSB7XG4gICAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uY2RhdGEnLCBwYXJzZXIuY2RhdGEpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsICdvbmNsb3NlY2RhdGEnKVxuICAgICAgICAgICAgcGFyc2VyLmNkYXRhID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJ10nKSB7XG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gJ10nXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5jZGF0YSArPSAnXV0nICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5QUk9DX0lOU1Q6XG4gICAgICAgICAgaWYgKGMgPT09ICc/Jykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5QUk9DX0lOU1RfRU5ESU5HXG4gICAgICAgICAgfSBlbHNlIGlmIChpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0JPRFlcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnByb2NJbnN0TmFtZSArPSBjXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlBST0NfSU5TVF9CT0RZOlxuICAgICAgICAgIGlmICghcGFyc2VyLnByb2NJbnN0Qm9keSAmJiBpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPycpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0VORElOR1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIucHJvY0luc3RCb2R5ICs9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuUFJPQ19JTlNUX0VORElORzpcbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsICdvbnByb2Nlc3NpbmdpbnN0cnVjdGlvbicsIHtcbiAgICAgICAgICAgICAgbmFtZTogcGFyc2VyLnByb2NJbnN0TmFtZSxcbiAgICAgICAgICAgICAgYm9keTogcGFyc2VyLnByb2NJbnN0Qm9keVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIHBhcnNlci5wcm9jSW5zdE5hbWUgPSBwYXJzZXIucHJvY0luc3RCb2R5ID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIucHJvY0luc3RCb2R5ICs9ICc/JyArIGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0JPRFlcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuT1BFTl9UQUc6XG4gICAgICAgICAgaWYgKGlzTWF0Y2gobmFtZUJvZHksIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIudGFnTmFtZSArPSBjXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5ld1RhZyhwYXJzZXIpXG4gICAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICAgIG9wZW5UYWcocGFyc2VyKVxuICAgICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnLycpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR19TTEFTSFxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgaWYgKCFpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgY2hhcmFjdGVyIGluIHRhZyBuYW1lJylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5PUEVOX1RBR19TTEFTSDpcbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBvcGVuVGFnKHBhcnNlciwgdHJ1ZSlcbiAgICAgICAgICAgIGNsb3NlVGFnKHBhcnNlcilcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdGb3J3YXJkLXNsYXNoIGluIG9wZW5pbmcgdGFnIG5vdCBmb2xsb3dlZCBieSA+JylcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkFUVFJJQjpcbiAgICAgICAgICAvLyBoYXZlbid0IHJlYWQgdGhlIGF0dHJpYnV0ZSBuYW1lIHlldC5cbiAgICAgICAgICBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICB9IGVsc2UgaWYgKGMgPT09ICcvJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR19TTEFTSFxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNNYXRjaChuYW1lU3RhcnQsIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuYXR0cmliTmFtZSA9IGNcbiAgICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9OQU1FXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnSW52YWxpZCBhdHRyaWJ1dGUgbmFtZScpXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkFUVFJJQl9OQU1FOlxuICAgICAgICAgIGlmIChjID09PSAnPScpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX1ZBTFVFXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnQXR0cmlidXRlIHdpdGhvdXQgdmFsdWUnKVxuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYlZhbHVlID0gcGFyc2VyLmF0dHJpYk5hbWVcbiAgICAgICAgICAgIGF0dHJpYihwYXJzZXIpXG4gICAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfTkFNRV9TQVdfV0hJVEVcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzTWF0Y2gobmFtZUJvZHksIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuYXR0cmliTmFtZSArPSBjXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnSW52YWxpZCBhdHRyaWJ1dGUgbmFtZScpXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkFUVFJJQl9OQU1FX1NBV19XSElURTpcbiAgICAgICAgICBpZiAoYyA9PT0gJz0nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9WQUxVRVxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0F0dHJpYnV0ZSB3aXRob3V0IHZhbHVlJylcbiAgICAgICAgICAgIHBhcnNlci50YWcuYXR0cmlidXRlc1twYXJzZXIuYXR0cmliTmFtZV0gPSAnJ1xuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYlZhbHVlID0gJydcbiAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uYXR0cmlidXRlJywge1xuICAgICAgICAgICAgICBuYW1lOiBwYXJzZXIuYXR0cmliTmFtZSxcbiAgICAgICAgICAgICAgdmFsdWU6ICcnXG4gICAgICAgICAgICB9KVxuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYk5hbWUgPSAnJ1xuICAgICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNNYXRjaChuYW1lU3RhcnQsIGMpKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5hdHRyaWJOYW1lID0gY1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9OQU1FXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgYXR0cmlidXRlIG5hbWUnKVxuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUU6XG4gICAgICAgICAgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzUXVvdGUoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5xID0gY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfUVVPVEVEXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICghcGFyc2VyLm9wdC51bnF1b3RlZEF0dHJpYnV0ZVZhbHVlcykge1xuICAgICAgICAgICAgICBlcnJvcihwYXJzZXIsICdVbnF1b3RlZCBhdHRyaWJ1dGUgdmFsdWUnKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfVU5RVU9URURcbiAgICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSA9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX1FVT1RFRDpcbiAgICAgICAgICBpZiAoYyAhPT0gcGFyc2VyLnEpIHtcbiAgICAgICAgICAgIGlmIChjID09PSAnJicpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfRU5USVRZX1FcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSArPSBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH1cbiAgICAgICAgICBhdHRyaWIocGFyc2VyKVxuICAgICAgICAgIHBhcnNlci5xID0gJydcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9WQUxVRV9DTE9TRURcbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfQ0xPU0VEOlxuICAgICAgICAgIGlmIChpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIG9wZW5UYWcocGFyc2VyKVxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJy8nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLk9QRU5fVEFHX1NMQVNIXG4gICAgICAgICAgfSBlbHNlIGlmIChpc01hdGNoKG5hbWVTdGFydCwgYykpIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnTm8gd2hpdGVzcGFjZSBiZXR3ZWVuIGF0dHJpYnV0ZXMnKVxuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYk5hbWUgPSBjXG4gICAgICAgICAgICBwYXJzZXIuYXR0cmliVmFsdWUgPSAnJ1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfTkFNRVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgYXR0cmlidXRlIG5hbWUnKVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfVU5RVU9URUQ6XG4gICAgICAgICAgaWYgKCFpc0F0dHJpYkVuZChjKSkge1xuICAgICAgICAgICAgaWYgKGMgPT09ICcmJykge1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9WQUxVRV9FTlRJVFlfVVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcGFyc2VyLmF0dHJpYlZhbHVlICs9IGNcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgfVxuICAgICAgICAgIGF0dHJpYihwYXJzZXIpXG4gICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgb3BlblRhZyhwYXJzZXIpXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkNMT1NFX1RBRzpcbiAgICAgICAgICBpZiAoIXBhcnNlci50YWdOYW1lKSB7XG4gICAgICAgICAgICBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG5vdE1hdGNoKG5hbWVTdGFydCwgYykpIHtcbiAgICAgICAgICAgICAgaWYgKHBhcnNlci5zY3JpcHQpIHtcbiAgICAgICAgICAgICAgICBwYXJzZXIuc2NyaXB0ICs9ICc8LycgKyBjXG4gICAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgdGFnbmFtZSBpbiBjbG9zaW5nIHRhZy4nKVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwYXJzZXIudGFnTmFtZSA9IGNcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2UgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgY2xvc2VUYWcocGFyc2VyKVxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNNYXRjaChuYW1lQm9keSwgYykpIHtcbiAgICAgICAgICAgIHBhcnNlci50YWdOYW1lICs9IGNcbiAgICAgICAgICB9IGVsc2UgaWYgKHBhcnNlci5zY3JpcHQpIHtcbiAgICAgICAgICAgIHBhcnNlci5zY3JpcHQgKz0gJzwvJyArIHBhcnNlci50YWdOYW1lXG4gICAgICAgICAgICBwYXJzZXIudGFnTmFtZSA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlNDUklQVFxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoIWlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgdGFnbmFtZSBpbiBjbG9zaW5nIHRhZycpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNMT1NFX1RBR19TQVdfV0hJVEVcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ0xPU0VfVEFHX1NBV19XSElURTpcbiAgICAgICAgICBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBjbG9zZVRhZyhwYXJzZXIpXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnSW52YWxpZCBjaGFyYWN0ZXJzIGluIGNsb3NpbmcgdGFnJylcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuVEVYVF9FTlRJVFk6XG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfRU5USVRZX1E6XG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfRU5USVRZX1U6XG4gICAgICAgICAgdmFyIHJldHVyblN0YXRlXG4gICAgICAgICAgdmFyIGJ1ZmZlclxuICAgICAgICAgIHN3aXRjaCAocGFyc2VyLnN0YXRlKSB7XG4gICAgICAgICAgICBjYXNlIFMuVEVYVF9FTlRJVFk6XG4gICAgICAgICAgICAgIHJldHVyblN0YXRlID0gUy5URVhUXG4gICAgICAgICAgICAgIGJ1ZmZlciA9ICd0ZXh0Tm9kZSdcbiAgICAgICAgICAgICAgYnJlYWtcblxuICAgICAgICAgICAgY2FzZSBT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pIHtcbiAgICAgICAgdmFyIE1BWF9TSVpFID0gMHg0MDAwXG4gICAgICAgIHZhciBjb2RlVW5pdHMgPSBbXVxuICAgICAgICB2YXIgaGlnaFN1cnJvZ2F0ZVxuICAgICAgICB2YXIgbG93U3Vycm9nYXRlXG4gICAgICAgIHZhciBpbmRleCA9IC0xXG4gICAgICAgIHZhciBsZW5ndGggPSBhcmd1bWVudHMubGVuZ3RoXG4gICAgICAgIGlmICghbGVuZ3RoKSB7XG4gICAgICAgICAgcmV0dXJuICcnXG4gICAgICAgIH1cbiAgICAgICAgdmFyIHJlc3VsdCA9ICcnXG4gICAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgdmFyIGNvZGVQb2ludCA9IE51bWJlcihhcmd1bWVudHNbaW5kZXhdKVxuICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICFpc0Zpbml0ZShjb2RlUG9pbnQpIHx8IC8vIGBOYU5gLCBgK0luZmluaXR5YCwgb3IgYC1JbmZpbml0eWBcbiAgICAgICAgICAgIGNvZGVQb2ludCA8IDAgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICBjb2RlUG9pbnQgPiAweDEwRkZGRiB8fCAvLyBub3QgYSB2YWxpZCBVbmljb2RlIGNvZGUgcG9pbnRcbiAgICAgICAgICAgIGZsb29yKGNvZGVQb2ludCkgIT09IGNvZGVQb2ludCAvLyBub3QgYW4gaW50ZWdlclxuICAgICAgICAgICkge1xuICAgICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcignSW52YWxpZCBjb2RlIHBvaW50OiAnICsgY29kZVBvaW50KVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoY29kZVBvaW50IDw9IDB4RkZGRikgeyAvLyBCTVAgY29kZSBwb2ludFxuICAgICAgICAgICAgY29kZVVuaXRzLnB1c2goY29kZVBvaW50KVxuICAgICAgICAgIH0gZWxzZSB7IC8vIEFzdHJ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YWluJywgZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAob25kcmFpbikge1xuICAgICAgICAgIGNvbnN0IGNiID0gb25kcmFpblxuICAgICAgICAgIG9uZHJhaW4gPSBudWxsXG4gICAgICAgICAgY2IoKVxuICAgICAgICB9XG4gICAgICB9KVxuICAgIH0gZWxzZSBpZiAoaXNXZWJTdHJlYW0oaGVhZCkpIHtcbiAgICAgIGNvbnN0IHdyaXRhYmxlID0gaXNUcmFuc2Zvcm1TdHJlYW0oaGVhZCkgPyBoZWFkLndyaXRhYmxlIDogaGVhZFxuICAgICAgY29uc3Qgd3JpdGVyID0gd3JpdGFibGUuZ2V0V3JpdGVyKClcbiAgICAgIGQuX3dyaXRlID0gYXN5bmMgZnVuY3Rpb24gKGNodW5rLCBlbmNvZGluZywgY2FsbGJhY2spIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBhd2FpdCB3cml0ZXIucmVhZHlcbiAgICAgICAgICB3cml0ZXIud3JpdGUoY2h1bmspLmNhdGNoKCgpID0+IHt9KVxuICAgICAgICAgIGNhbGxiYWNrKClcbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgY2FsbGJhY2soZXJyKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBkLl9maW5hbCA9IGFzeW5jIGZ1bmN0aW9uIChjYWxsYmFjaykge1xuICAgICAgICB0cnkge1xuICAgICAgICAgIGF3YWl0IHdyaXRlci5yZWFkeVxuICAgICAgICAgIHdyaXRlci5jbG9zZSgpLmNhdGNoKCgpID0+IHt9KVxuICAgICAgICAgIG9uZmluaXNoID0gY2FsbGJhY2tcbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgY2FsbGJhY2soZXJyKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGNvbnN0IHRvUmVhZCA9IGlzVHJhbnNmb3JtU3RyZWFtKHRhaWwpID8gdGFpbC5yZWFkYWJsZSA6IHRhaWxcbiAgICBlb3ModG9SZWFkLCAoKSA9PiB7XG4gICAgICBpZiAob25maW5pc2gpIHtcbiAgICAgICAgY29uc3QgY2IgPSBvbmZpbmlzaFxuICAgICAgICBvbmZpbmlzaCA9IG51bGxcbiAgICAgICAgY2IoKVxuICAgICAgfVxuICAgIH0pXG4gIH1cbiAgaWYgKHJlYWRhYmxlKSB7XG4gICAgaWYgKGlzTm9kZVN0cmVhbSh0YWlsKSkge1xuICAgICAgdGFpbC5vbigncmVhZGFibGUnLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGlmIChvbnJlYWRhYmxlKSB7XG4gICAgICAgICAgY29uc3QgY2IgPSBvbnJlYWRhYmxlXG4gICAgICAgICAgb25yZWFkYWJsZSA9IG51bGxcbiAgICAgICAgICBjYigpXG4gICAgICAgIH1cbiAgICAgIH0pXG4gICAgICB0YWlsLm9uKCdlbmQnLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGQucHVzaChudWxsKVxuICAgICAgfSlcbiAgICAgIGQuX3JlYWQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgICAgY29uc3QgYnVmID0gdGFpbC5yZWFkKClcbiAgICAgICAgICBpZiAoYnVmID09PSBudWxsKSB7XG4gICAgICAgICAgICBvbnJlYWRhYmxlID0gZC5fcmVhZFxuICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICghZC5wdXNoKGJ1ZikpIHtcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0gZWxzZSBpZiAoaXNXZWJTdHJlYW0odGFpbCkpIHtcbiAgICAgIGNvbnN0IHJlYWRhYmxlID0gaXNUcmFuc2Zvcm1TdHJlYW0odGFpbCkgPyB0YWlsLnJlYWRhYmxlIDogdGFpbFxuICAgICAgY29uc3QgcmVhZGVyID0gcmVhZGFibGUuZ2V0UmVhZGVyKClcbiAgICAgIGQuX3JlYWQgPSBhc3luYyBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIGNvbnN0IHsgdmFsdWUsIGRvbmUgfSA9IGF3YWl0IHJlYWRlci5yZWFkKClcbiAgICAgICAgICAgIGlmICghZC5wdXNoKHZhbHVlKSkge1xuICAgICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChkb25lKSB7XG4gICAgICAgICAgICAgIGQucHVzaChudWxsKVxuICAgICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGNhdGNoIHtcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgfVxuICBkLl9kZXN0cm95ID0gZnVuY3Rpb24gKGVyciwgY2FsbGJhY2spIHtcbiAgICBpZiAoIWVyciAmJiBvbmNsb3NlICE9PSBudWxsKSB7XG4gICAgICBlcnIgPSBuZXcgQWJvcnRFcnJvcigpXG4gICAgfVxuICAgIG9ucmVhZGFibGUgPSBudWxsXG4gICAgb25kcmFpbiA9IG51bGxcbiAgICBvbmZpbmlzaCA9IG51bGxcbiAgICBpZiAob25jbG9zZSA9PT0gbnVsbCkge1xuICAgICAgY2FsbGJhY2soZXJyKVxuICAgIH0gZWxzZSB7XG4gICAgICBvbmNsb3NlID0gY2FsbGJhY2tcbiAgICAgIGlmIChpc05vZGVTdHJlYW0odGFpbCkpIHtcbiAgICAgICAgZGVzdHJveWVyKHRhaWwsIGVycilcbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgcmV0dXJuIGRcbn1cbiIsIid1c2Ugc3RyaWN0J1xuXG4vKiByZXBsYWNlbWVudCBzdGFydCAqL1xuXG5jb25zdCBwcm9jZXNzID0gcmVxdWlyZSgncHJvY2Vzcy8nKVxuXG4vKiByZXBsYWNlbWVudCBlbmQgKi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bmV3IEVSUl9JTlZBTElEX1JFVFVSTl9WQUxVRSgnbnVsbHknLCAnYm9keScsIHZhbClcbiAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIChlcnIpID0+IHtcbiAgICAgICAgICBkZXN0cm95ZXIoZCwgZXJyKVxuICAgICAgICB9XG4gICAgICApXG4gICAgICByZXR1cm4gKGQgPSBuZXcgRHVwbGV4aWZ5KHtcbiAgICAgICAgLy8gVE9ETyAocm9uYWcpOiBoaWdoV2F0ZXJNYXJrP1xuICAgICAgICBvYmplY3RNb2RlOiB0cnVlLFxuICAgICAgICByZWFkYWJsZTogZmFsc2UsXG4gICAgICAgIHdyaXRlLFxuICAgICAgICBmaW5hbChjYikge1xuICAgICAgICAgIGZpbmFsKGFzeW5jICgpID0+IHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgIGF3YWl0IHByb21pc2VcbiAgICAgICAgICAgICAgcHJvY2Vzcy5uZXh0VGljayhjYiwgbnVsbClcbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICBwcm9jZXNzLm5leHRUaWNrKGNiLCBlcnIpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSlcbiAgICAgICAgfSxcbiAgICAgICAgZGVzdHJveVxuICAgICAgfSkpXG4gICAgfVxuICAgIHRocm93IG5ldyBFUlJfSU5WQUxJRF9SRVRVUk5fVkFMVUUoJ0l0ZXJhYmxlLCBBc3luY0l0ZXJhYmxlIG9yIEFzeW5jRnVuY3Rpb24nLCBuYW1lLCB2YWx1ZSlcbiAgfVxuICBpZiAoaXNCbG9iKGJvZHkpKSB7XG4gICAgcmV0dXJuIGR1cGxleGlmeShib2R5LmFycmF5QnVmZmVyKCkpXG4gIH1cbiAgaWYgKGlzSXRlcmFibGUoYm9keSkpIHtcbiAgICByZXR1cm4gZnJvbShEdXBsZXhpZnksIGJvZHksIHtcbiAgICAgIC8vIFRPRE8gKHJvbmFnKTogaGlnaFdhdGVyT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mVkXG4gICAgY29uc3Qgd3JpdGFibGUgPVxuICAgICAgYm9keSAhPT0gbnVsbCAmJiBib2R5ICE9PSB1bmRlZmluZWQgJiYgYm9keS53cml0YWJsZVxuICAgICAgICA/IGlzV3JpdGFibGVOb2RlU3RyZWFtKGJvZHkgPT09IG51bGwgfHwgYm9keSA9PT0gdW5kZWZpbmVkID8gdW5kZWZpbmVkIDogYm9keS53cml0YWJsZSlcbiAgICAgICAgICA/IGJvZHkgPT09IG51bGwgfHwgYm9keSA9PT0gdW5kZWZpbmVkXG4gICAgICAgICAgICA/IHVuZGVmaW5lZFxuICAgICAgICAgICAgOiBib2R5LndyaXRhYmxlXG4gICAgICAgICAgOiBkdXBsZXhpZnkoYm9keS53cml0YWJsZSlcbiAgICAgICAgOiB1bmRlZmluZWRcbiAgICByZXR1cm4gX2R1cGxleGlmeSh7XG4gICAgICByZWFkYWJsZSxcbiAgICAgIHdyaXRhYmxlXG4gICAgfSlcbiAgfVxuICBjb25zdCB0aGVuID0gYm9keSA9PT0gbnVsbCB8fCBib2R5ID09PSB1bmRlZmluZWQgPyB1bmRlZmluZWQgOiBib2R5LnRoZW5cbiAgaWYgKHR5cGVvZiB0aGVuID09PSAnZnVuY3Rpb24nKSB7XG4gICAgbGV0IGRcbiAgICBGdW5jdGlvblByb3RvdHlwZUNhbGwoXG4gICAgICB0aGVuLFxuICAgICAgYm9keSxcbiAgICAgICh2YWwpID0+IHtcbiAgICAgICAgaWYgKHZhbCAhPSBudWxsKSB7XG4gICAgICAgICAgZC5wdXNoKHZhbClcbiAgICAgICAgfVxuICAgICAgICBkLnB1c2gobnVsbClcbiAgICAgIH0sXG4gICAgICAoZXJyKSA9PiB7XG4gICAgICAgIGRlc3Ryb3llcihkLCBlcnIpXG4gICAgICB9XG4gICAgKVxuICAgIHJldHVybiAoZCA9IG5ldyBEdXBsZXhpZnkoe1xuICAgICAgb2JqZWN0TW9kZTogdHJ1ZSxcbiAgICAgIHdyaXRhYmxlOiBmYWxzZSx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YWxsYmFjaygpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBvbmRyYWluID0gY2FsbGJhY2tcbiAgICAgIH1cbiAgICB9XG4gICAgZC5fZmluYWwgPSBmdW5jdGlvbiAoY2FsbGJhY2spIHtcbiAgICAgIHcuZW5kKClcbiAgICAgIG9uZmluaXNoID0gY2FsbGJhY2tcbiAgICB9XG4gICAgdy5vbignZHJhaW4nLCBmdW5jdGlvbiAoKSB7XG4gICAgICBpZiAob25kcmFpbikge1xuICAgICAgICBjb25zdCBjYiA9IG9uZHJhaW5cbiAgICAgICAgb25kcmFpbiA9IG51bGxcbiAgICAgICAgY2IoKVxuICAgICAgfVxuICAgIH0pXG4gICAgdy5vbignZmluaXNoJywgZnVuY3Rpb24gKCkge1xuICAgICAgaWYgKG9uZmluaXNoKSB7XG4gICAgICAgIGNvbnN0IGNiID0gb25maW5pc2hcbiAgICAgICAgb25maW5pc2ggPSBudWxsXG4gICAgICAgIGNiKClcbiAgICAgIH1cbiAgICB9KVxuICB9XG4gIGlmIChyZWFkYWJsZSkge1xuICAgIGVvcyhyLCAoZXJyKSA9PiB7XG4gICAgICByZWFkYWJsZSA9IGZhbHNlXG4gICAgICBpZiAoZXJyKSB7XG4gICAgICAgIGRlc3Ryb3llcihyLCBlcnIpXG4gICAgICB9XG4gICAgICBvbmZpbmlzaGVkKGVycilcbiAgICB9KVxuICAgIHIub24oJ3JlYWRhYmxlJywgZnVuY3Rpb24gKCkge1xuICAgICAgaWYgKG9ucmVhZGFibGUpIHtcbiAgICAgICAgY29uc3QgY2IgPSBvbnJlYWRhYmxlXG4gICAgICAgIG9ucmVhZGFibGUgPSBudWxsXG4gICAgICAgIGNiKClcbiAgICAgIH1cbiAgICB9KVxuICAgIHIub24oJ2VuZCcsIGZ1bmN0aW9uICgpIHtcbiAgICAgIGQucHVzaChudWxsKVxuICAgIH0pXG4gICAgZC5fcmVhZCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgIHdoaWxlICh0cnVlKSB7X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gICAgIGlmIChkb25lKSB7XG4gICAgICAgIHJldHVyblxuICAgICAgfVxuICAgIH1cbiAgICBpZiAodHlwZW9mIGl0ZXJhdG9yLnJldHVybiA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgY29uc3QgeyB2YWx1ZSB9ID0gYXdhaXQgaXRlcmF0b3IucmV0dXJuKClcbiAgICAgIGF3YWl0IHZhbHVlXG4gICAgfVxuICB9XG4gIGFzeW5jIGZ1bmN0aW9uIG5leHQoKSB7XG4gICAgZm9yICg7Oykge1xuICAgICAgdHJ5IHtcbiAgICAgICAgY29uc3QgeyB2YWx1ZSwgZG9uZSB9ID0gaXNBc3luYyA/IGF3YWl0IGl0ZXJhdG9yLm5leHQoKSA6IGl0ZXJhdG9yLm5leHQoKVxuICAgICAgICBpZiAoZG9uZSkge1xuICAgICAgICAgIHJlYWRhYmxlLnB1c2gobnVsbClcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjb25zdCByZXMgPSB2YWx1ZSAmJiB0eXBlb2YgdmFsdWUudGhlbiA9PT0gJ2Z1bmN0aW9uJyA/IGF3YWl0IHZhbHVlIDogdmFsdWVcbiAgICAgICAgICBpZiAocmVzID09PSBudWxsKSB7XG4gICAgICAgICAgICByZWFkaW5nID0gZmFsc2VcbiAgICAgICAgICAgIHRocm93IG5ldyBFUlJfU1RSRUFNX05VTExfVkFMVUVTKClcbiAgICAgICAgICB9IGVsc2UgaWYgKHJlYWRhYmxlLnB1c2gocmVzKSkge1xuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmVhZGluZyA9IGZhbHNlXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgcmVhZGFibGUuZGVzdHJveShlcnIpXG4gICAgICB9XG4gICAgICBicmVha1xuICAgIH1cbiAgfVxuICByZXR1cm4gcmVhZGFibGVcbn1cbm1vZHVsZS5leHBvcnRzID0gZ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tcbiAgICAgICAgICAgIHRocm93IG5ldyBBYm9ydEVycm9yKClcbiAgICAgICAgICB9XG4gICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHZhbCA9IGZuKHZhbCwgc2lnbmFsT3B0KVxuICAgICAgICAgICAgaWYgKHZhbCA9PT0ga0VtcHR5KSB7XG4gICAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YWwgPSBQcm9taXNlUmVzb2x2ZSh2YWwpXG4gICAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB2YWwgPSBQcm9taXNlUmVqZWN0KGVycilcbiAgICAgICAgICB9XG4gICAgICAgICAgY250ICs9IDFcbiAgICAgICAgICBQcm9taXNlUHJvdG90eXBlVGhlbih2YWwsIGFmdGVySXRlbVByb2Nlc3NlZCwgb25DYXRjaClcbiAgICAgICAgICBxdWV1ZS5wdXNoKHZhbClcbiAgICAgICAgICBpZiAobmV4dCkge1xuICAgICAgICAgICAgbmV4dCgpXG4gICAgICAgICAgICBuZXh0ID0gbnVsbFxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoIWRvbmUgJiYgKHF1ZXVlLmxlbmd0aCA+PSBoaWdoV2F0ZXJNYXJrIHx8IGNudCA+PSBjb25jdXJyZW5jeSkpIHtcbiAgICAgICAgICAgIGF3YWl0IG5ldyBQcm9taXNlKChyZXNvbHZlKSA9PiB7XG4gICAgICAgICAgICAgIHJlc3VtZSA9IHJlc29sdmVcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHF1ZXVlLnB1c2goa0VvZilcbiAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICBjb25zdCB2YWwgPSBQcm9taXNlUmVqZWN0KGVycilcbiAgICAgICAgUHJvbWlzZVByb3RvdHlwZVRoZW4odmFsLCBhZnRlckl0ZW1Qcm9jZXNzZWQsIG9uQ2F0Y2gpXG4gICAgICAgIHF1ZXVlLnB1c2godmFsKVxuICAgICAgfSBmaW5hbGx5IHtcbiAgICAgICAgZG9uZSA9IHRydWVcbiAgICAgICAgaWYgKG5leHQpIHtcbiAgICAgICAgICBuZXh0KClcbiAgICAgICAgICBuZXh0ID0gbnVsbFxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHB1bXAoKVxuICAgIHRyeSB7XG4gICAgICB3aGlsZSAodHJ1ZSkge1xuICAgICAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkge1xuICAgICAgICAgIGNvbnN0IHZhbCA9IGF3YWl0IHF1ZXVlWzBdXG4gICAgICAgICAgaWYgKHZhbCA9PT0ga0VvZikge1xuICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzaWduYWwuYWJvcnRlZCkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEFib3J0RXJyb3IoKVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodmFsICE9PSBrRW1wdHkpIHtcbiAgICAgICAgICAgIHlpZWxkIHZhbFxuICAgICAgICAgIH1cbiAgICAgICAgICBxdWV1ZS5zaGlmdCgpXG4gICAgICAgICAgbWF5YmVSZXN1bWUoKVxuICAgICAgICB9XG4gICAgICAgIGF3YWl0IG5ldyBQcm9taXNlKChyZXNvbHZlKSA9PiB7XG4gICAgICAgICAgbmV4dCA9IHJlc29sdmVcbiAgICAgICAgfSlcbiAgICAgIH1cbiAgICB9IGZpbmFsbHkge1xuICAgICAgZG9uZSA9IHRydWVcbiAgICAgIGlmIChyZXN1bWUpIHtcbiAgICAgICAgcmVzdW1lKClcbiAgICAgICAgcmVzdW1lID0gbnVsbFxuICAgICAgfVxuICAgIH1cbiAgfS5jYWxsKHRoaXMpXG59XG5mdW5jdGlvbiBhc0luZGV4ZWRQYWlycyhvcHRpb25zID0gdW5kZWZpbmVkKSB7XG4gIGlmIChvcHRpb25zICE9IG51bGwpIHtcbiAgICB2YWxpZGF0ZU9iamVjdChvcH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Ckge1xuICBpZiAoIVJlYWRhYmxlKSB7XG4gICAgUmVhZGFibGUgPSByZXF1aXJlKCcuL3JlYWRhYmxlJylcbiAgfVxuICB5aWVsZCogUmVhZGFibGUucHJvdG90eXBlW1N5bWJvbEFzeW5jSXRlcmF0b3JdLmNhbGwodmFsKVxufVxuYXN5bmMgZnVuY3Rpb24gcHVtcFRvTm9kZShpdGVyYWJsZSwgd3JpdGFibGUsIGZpbmlzaCwgeyBlbmQgfSkge1xuICBsZXQgZXJyb3JcbiAgbGV0IG9ucmVzb2x2ZSA9IG51bGxcbiAgY29uc3QgcmVzdW1lID0gKGVycikgPT4ge1xuICAgIGlmIChlcnIpIHtcbiAgICAgIGVycm9yID0gZXJyXG4gICAgfVxuICAgIGlmIChvbnJlc29sdmUpIHtcbiAgICAgIGNvbnN0IGNhbGxiYWNrID0gb25yZXNvbHZlXG4gICAgICBvbnJlc29sdmUgPSBudWxsXG4gICAgICBjYWxsYmFjaygpXG4gICAgfVxuICB9XG4gIGNvbnN0IHdhaXQgPSAoKSA9PlxuICAgIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIGlmIChlcnJvcikge1xuICAgICAgICByZWplY3QoZXJyb3IpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBvbnJlc29sdmUgPSAoKSA9PiB7XG4gICAgICAgICAgaWYgKGVycm9yKSB7XG4gICAgICAgICAgICByZWplY3QoZXJyb3IpXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJlc29sdmUoKVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0pXG4gIHdyaXRhYmxlLm9uKCdkcmFpbicsIHJlc3VtZSlcbiAgY29uc3QgY2xlYW51cCA9IGVvcyhcbiAgICB3cml0YWJsZSxcbiAgICB7XG4gICAgICByZWFkYWJsZTogZmFsc2VcbiAgICB9LFxuICAgIHJlc3VtZVxuICApXG4gIHRyeSB7XG4gICAgaWYgKHdy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YW0pYC5cblxuICAgICAgICBjb25zdCBwdCA9IG5ldyBQYXNzVGhyb3VnaCh7XG4gICAgICAgICAgb2JqZWN0TW9kZTogdHJ1ZVxuICAgICAgICB9KVxuXG4gICAgICAgIC8vIEhhbmRsZSBQcm9taXNlcy9BKyBzcGVjLCBgdGhlbmAgY291bGQgYmUgYSBnZXR0ZXIgdGhhdCB0aHJvd3Mgb25cbiAgICAgICAgLy8gc2Vjb25kIHVzZS5cbiAgICAgICAgY29uc3QgdGhlbiA9IChfcmV0MiA9IHJldCkgPT09IG51bGwgfHwgX3JldDIgPT09IHVuZGVmaW5lZCA/IHVuZGVmaW5lZCA6IF9yZXQyLnRoZW5cbiAgICAgICAgaWYgKHR5cGVvZiB0aGVuID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgZmluaXNoQ291bnQrK1xuICAgICAgICAgIHRoZW4uY2FsbChcbiAgICAgICAgICAgIHJldCxcbiAgICAgICAgICAgICh2YWwpID0+IHtcbiAgICAgICAgICAgICAgdmFsdWUgPSB2YWxcbiAgICAgICAgICAgICAgaWYgKHZhbCAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgcHQud3JpdGUodmFsKVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmIChlbmQpIHtcbiAgICAgICAgICAgICAgICBwdC5lbmQoKVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHByb2Nlc3MubmV4dFRpY2soZmluaXNoKVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIChlcnIpID0+IHtcbiAgICAgICAgICAgICAgcHQuZGVzdHJveShlcnIpXG4gICAgICAgICAgICAgIHByb2Nlc3MubmV4dFRpY2soZmluaXNoLCBlcnIpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgKVxuICAgICAgICB9IGVsc2UgaWYgKGlzSXRlcmFibGUocmV0LCB0cnVlKSkge1xuICAgICAgICAgIGZpbmlzaENvdW50KytcbiAgICAgICAgICBwdW1wVG9Ob2RlK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ICAgICAgIGxhc3RTdHJlYW1DbGVhbnVwLnB1c2goY2xlYW51cClcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIGlmIChpc1RyYW5zZm9ybVN0cmVhbShyZXQpIHx8IGlzUmVhZGFibGVTdHJlYW0ocmV0KSkge1xuICAgICAgICBjb25zdCB0b1JlYWQgPSByZXQucmVhZGFibGUgfHwgcmV0XG4gICAgICAgIGZpbmlzaENvdW50KytcbiAgICAgICAgcHVtcFRvTm9kZSh0b1JlYWQsIHN0cmVhbSwgZmluaXNoLCB7XG4gICAgICAgICAgZW5kXG4gICAgICAgIH0pXG4gICAgICB9IGVsc2UgaWYgKGlzSXRlcmFibGUocmV0KSkge1xuICAgICAgICBmaW5pc2hDb3VudCsrXG4gICAgICAgIHB1bXBUb05vZGUocmV0LCBzdHJlYW0sIGZpbmlzaCwge1xuICAgICAgICAgIGVuZFxuICAgICAgICB9KVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhyb3cgbmV3IEVSUl9JTlZBTElEX0FSR19UWVBFKFxuICAgICAgICAgICd2YWwnLFxuICAgICAgICAgIFsnUmVhZGFibGUnLCAnSXRlcmFibGUnLCAnQXN5bmNJdGVyYWJsZScsICdSZWFkYWJsZVN0cmVhbScsICdUcmFuc2Zvcm1TdHJlYW0nXSxcbiAgICAgICAgICByZXRcbiAgICAgICAgKVxuICAgICAgfVxuICAgICAgcmV0ID0gc3RyZWFtXG4gICAgfSBlbHNlIGlmIChpc1dlYlN0cmVhbShzdHJlYW0pKSB7XG4gICAgICBpZiAoaXNSZWFkYWJsZU5vZGVTdHJlYW0ocmV0KSkge1xuICAgICAgICBmaW5pc2hDb3VudCsrXG4gICAgICAgIHB1bXBUb1dlYihtYWtlQXN5bmNJdGVyYWJsZShyZXQpLCBzdHJlYW0sIGZpbmlzaCwge1xuICAgICAgICAgIGVuZFxuICAgICAgICB9KVxuICAgICAgfSBlbHNlIGlmIChpc1JlYWRhYmxlU3RyZWFtKHJldCkgfHwgaXNJdG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AgICB9XG4gICAgICBpZiAoaW5zdGFuY2VzLmxlbmd0aCA+IDAgfHwgb3RoZXIubGVuZ3RoID4gMCkge1xuICAgICAgICBtc2cgKz0gJyBvciAnXG4gICAgICB9XG4gICAgfVxuICAgIGlmIChpbnN0YW5jZXMubGVuZ3RoID4gMCkge1xuICAgICAgc3dpdGNoIChpbnN0YW5jZXMubGVuZ3RoKSB7XG4gICAgICAgIGNhc2UgMTpcbiAgICAgICAgICBtc2cgKz0gYGFuIGluc3RhbmNlIG9mICR7aW5zdGFuY2VzWzBdfWBcbiAgICAgICAgICBicmVha1xuICAgICAgICBjYXNlIDI6XG4gICAgICAgICAgbXNnICs9IGBhbiBpbnN0YW5jZSBvZiAke2luc3RhbmNlc1swXX0gb3IgJHtpbnN0YW5jZXNbMV19YFxuICAgICAgICAgIGJyZWFrXG4gICAgICAgIGRlZmF1bHQ6IHtcbiAgICAgICAgICBjb25zdCBsYXN0ID0gaW5zdGFuY2VzLnBvcCgpXG4gICAgICAgICAgbXNnICs9IGBhbiBpbnN0YW5jZSBvZiAke2luc3RhbmNlcy5qb2luKCcsICcpfSwgb3IgJHtsYXN0fWBcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKG90aGVyLmxlbmd0aCA+IDApIHtcbiAgICAgICAgbXNnICs9ICcgb3IgJ1xuICAgICAgfVxuICAgIH1cbiAgICBzd2l0Y2ggKG90aGVyLmxlbmd0aCkge1xuICAgICAgY2FzZSAwOlxuICAgICAgICBicmVha1xuICAgICAgY2FzZSAxOlxuICAgICAgICBpZiAob3RoZXJbMF0udG9Mb3dlckNhc2UoKSAhPT0gb3RoZXJbMF0pIHtcbiAgICAgICAgICBtc2cgKz0gJ2FuICdcbiAgICAgICAgfVxuICAgICAgICBtc2cgKz0gYCR7b3RoZXJbMF19YFxuICAgICAgICBicmVha1xuICAgICAgY2FzZSAyOlxuICAgICAgICBtc2cgKz0gYG9uZSBvZiAke290aGVyWzBdfSBvciAke290aGVyWzFdfWBcbiA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wZW4ob3B0aW9ucy5maWxlLCAnYSsnLCAnMDY0NCcsIChlcnIsIGZkKSA9PiB7XG4gICAgaWYgKGVycikge1xuICAgICAgaWYgKCFpdGVyKSB7XG4gICAgICAgIHN0cmVhbS5lbWl0KCdlcnJvcicsIGVycik7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpdGVyKGVycik7XG4gICAgICB9XG4gICAgICBzdHJlYW0uZGVzdHJveSgpO1xuICAgICAgcmV0dXJuO1xuICAgIH1cblxuICAgIChmdW5jdGlvbiByZWFkKCkge1xuICAgICAgaWYgKHN0cmVhbS5kZXN0cm95ZWQpIHtcbiAgICAgICAgZnMuY2xvc2UoZmQsIG5vb3ApO1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBmcy5yZWFkKGZkLCBidWZmZXIsIDAsIGJ1ZmZlci5sZW5ndGgsIHBvcywgKGVycm9yLCBieXRlcykgPT4ge1xuICAgICAgICBpZiAoZXJyb3IpIHtcbiAgICAgICAgICBpZiAoIWl0ZXIpIHtcbiAgICAgICAgICAgIHN0cmVhbS5lbWl0KCdlcnJvcicsIGVycm9yKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaXRlcihlcnJvcik7XG4gICAgICAgICAgfVxuICAgICAgICAgIHN0cmVhbS5kZXN0cm95KCk7XG4gICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCFieXRlcykge1xuICAgICAgICAgIGlmIChidWZmKSB7XG4gICAgICAgICAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXFlcWVxXG4gICAgICAgICAgICBpZiAob3B0aW9ucy5zdGFydCA9PSBudWxsIHx8IHJvdyA+IG9wdGlvbnMuc3RhcnQpIHtcbiAgICAgICAgICAgICAgaWYgKCFpdGVyKSB7XG4gICAgICAgICAgICAgICAgc3RyZWFtLmVtaXQoJ2xpbmUnLCBidWZmKTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpdGVyKG51bGwsIGJ1ZmYpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByb3crKztcbiAgICAgICAgICAgIGJ1ZmYgPSAnJztcbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHNldFRpbWVvdXQocmVhZCwgMTAwMCk7XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgZGF0YSA9IGRlY29kZS53cml0ZShidWZmZXIuc2xpY2UoMCwgYnl0ZXMpKTtcbiAgICAgICAgaWYgKCFpdGVyKSB7XG4gICAgICAgICAgc3RyZWFtLmVtaXQoJ2RhdGEnLCBkYXRhKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGRhdGEgPSAoYnVmZiArIGRhdGEpLnNwbGl0KC9cXG4rLyk7XG5cbiAgICAgICAgY29uc3QgbCA9IGRhdGEubGVuZ3RoIC0gMTtcbiAgICAgICAgbGV0IGkgPSAwO1xuXG4gICAgICAgIGZvciAoOyBpIDwgbDsgaSsrKSB7XG4gICAgICAgICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGVxZXFlcVxuICAgICAgICAgIGlmIChvcHRpb25zLnN0YXJ0ID09IG51bGwgfHwgcm93ID4gb3B0aW9ucy5zdGFydCkge1xuICAgICAgICAgICAgaWYgKCFpdGVyKSB7XG4gICAgICAgICAgICAgIHN0cmVhbS5lbWl0KCdsaW5lJywgZGF0YVtpXSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBpdGVyKG51bGwsIGRhdGFbaV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICByb3crKztcbiAgICAgICAgfVxuXG4gICAgICAgIGJ1ZmYgPSBkYXRhW2xdO1xuICAgICAgICBwb3MgKz0gYnl0ZXM7XG4gICAgICAgIHJldHVybiByZWFkKCk7XG4gICAgICB9KTtcbiAgICB9KCkpO1xuICB9KTtcblxuIC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ybjtcbiAgICAgIH1cblxuICAgICAgaWYgKG9wdGlvbnMuZmllbGRzKSB7XG4gICAgICAgIGxvZyA9IG9wdGlvbnMuZmllbGRzLnJlZHVjZSgob2JqLCBrZXkpID0+IHtcbiAgICAgICAgICBvYmpba2V5XSA9IGxvZ1trZXldO1xuICAgICAgICAgIHJldHVybiBvYmo7XG4gICAgICAgIH0sIHt9KTtcbiAgICAgIH1cblxuICAgICAgaWYgKG9wdGlvbnMub3JkZXIgPT09ICdkZXNjJykge1xuICAgICAgICBpZiAocmVzdWx0cy5sZW5ndGggPj0gb3B0aW9ucy5yb3dzKSB7XG4gICAgICAgICAgcmVzdWx0cy5zaGlmdCgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXN1bHRzLnB1c2gobG9nKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjaGVjayhsb2cpIHtcbiAgICAgIGlmICghbG9nKSB7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgaWYgKHR5cGVvZiBsb2cgIT09ICdvYmplY3QnKSB7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgY29uc3QgdGltZSA9IG5ldyBEYXRlKGxvZy50aW1lc3RhbXApO1xuICAgICAgaWYgKFxuICAgICAgICAob3B0aW9ucy5mcm9tICYmIHRpbWUgPCBvcHRpb25zLmZyb20pIHx8XG4gICAgICAgIChvcHRpb25zLnVudGlsICYmIHRpbWUgPiBvcHRpb25zLnVudGlsKSB8fFxuICAgICAgICAob3B0aW9ucy5sZXZlbCAmJiBvcHRpb25zLmxldmVsICE9PSBsb2cubGV2ZWwpXG4gICAgICApIHtcbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBub3JtYWxpemVRdWVyeShvcHRpb25zKSB7XG4gICAgICBvcHRpb25zID0gb3B0aW9ucyB8fCB7fTtcblxuICAgICAgLy8gbGlta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2RvbmUgbmV4dENiJylcbiAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJ1bm5pbmcrKztcbiAgICAgICAgICAgIGl0ZXJhdGVlKHZhbHVlLCBpZHgsIGl0ZXJhdGVlQ2FsbGJhY2spO1xuICAgICAgICAgICAgaWR4Kys7XG4gICAgICAgICAgICByZXBsZW5pc2goKTtcbiAgICAgICAgfSkuY2F0Y2goaGFuZGxlRXJyb3IpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGl0ZXJhdGVlQ2FsbGJhY2soZXJyLCByZXN1bHQpIHtcbiAgICAgICAgLy9jb25zb2xlLmxvZygnaXRlcmF0ZWVDYWxsYmFjaycpXG4gICAgICAgIHJ1bm5pbmcgLT0gMTtcbiAgICAgICAgaWYgKGNhbmNlbGVkKSByZXR1cm47XG4gICAgICAgIGlmIChlcnIpIHJldHVybiBoYW5kbGVFcnJvcihlcnIpO1xuXG4gICAgICAgIGlmIChlcnIgPT09IGZhbHNlKSB7XG4gICAgICAgICAgICBkb25lID0gdHJ1ZTtcbiAgICAgICAgICAgIGNhbmNlbGVkID0gdHJ1ZTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChyZXN1bHQgPT09IF9icmVha0xvb3AyLmRlZmF1bHQgfHwgZG9uZSAmJiBydW5uaW5nIDw9IDApIHtcbiAgICAgICAgICAgIGRvbmUgPSB0cnVlO1xuICAgICAgICAgICAgLy9jb25zb2xlLmxvZygnZG9uZSBpdGVyQ2InKVxuICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKG51bGwpO1xuICAgICAgICB9XG4gICAgICAgIHJlcGxlbmlzaCgpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGhhbmRsZUVycm9yKGVycikge1xuICAgICAgICBpZiAoY2FuY2V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ICAgICAgICAgICB9IGVsc2UgaWYgKCFsb29waW5nKSB7XG4gICAgICAgICAgICAgICAgcmVwbGVuaXNoKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiByZXBsZW5pc2goKSB7XG4gICAgICAgICAgICBsb29waW5nID0gdHJ1ZTtcbiAgICAgICAgICAgIHdoaWxlIChydW5uaW5nIDwgbGltaXQgJiYgIWRvbmUpIHtcbiAgICAgICAgICAgICAgICB2YXIgZWxlbSA9IG5leHRFbGVtKCk7XG4gICAgICAgICAgICAgICAgaWYgKGVsZW0gPT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgZG9uZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIGlmIChydW5uaW5nIDw9IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcnVubmluZyArPSAxO1xuICAgICAgICAgICAgICAgIGl0ZXJhdGVlKGVsZW0udmFsdWUsIGVsZW0ua2V5LCAoMCwgX29ubHlPbmNlMi5kZWZhdWx0KShpdGVyYXRlZUNhbGxiYWNrKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsb29waW5nID0gZmFsc2U7XG4gICAgICAgIH1cblxuICAgICAgICByZXBsZW5pc2goKTtcbiAgICB9O1xufTtcblxubW9kdWxlLmV4cG9ydHMgPSBleHBvcnRzLmRlZmF1bHQ7IiwiXCJ1c2Ugc3RyaWN0XCI7XG5cbk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCBcIl9fZXNNb2R1bGVcIiwge1xuICAgIHZhbHVlOiB0cnVlXG59KTtcblxuZXhwb3J0cy5kZWZhdWx0ID0gZnVuY3Rpb24gKGNvbGwpIHtcbiAgICByZXR1cm4gY29sbFtTeW1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e1xuICogICAgIG9uZTogZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAqICAgICAgICAgICAgIC8vIGRvIHNvbWUgYXN5bmMgdGFza1xuICogICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgMSk7XG4gKiAgICAgICAgIH0sIDIwMCk7XG4gKiAgICAgfSxcbiAqICAgICB0d286IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICAvLyB0aGVuIGRvIGFub3RoZXIgYXN5bmMgdGFza1xuICogICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgMik7XG4gKiAgICAgICAgIH0sIDEwMCk7XG4gKiAgICAgfVxuICogfSwgZnVuY3Rpb24oZXJyLCByZXN1bHRzKSB7XG4gKiAgICAgY29uc29sZS5sb2cocmVzdWx0cyk7XG4gKiAgICAgLy8gcmVzdWx0cyBpcyBlcXVhbCB0bzogeyBvbmU6IDEsIHR3bzogMiB9XG4gKiB9KTtcbiAqXG4gKiAvL1VzaW5nIFByb21pc2VzXG4gKiBhc3luYy5zZXJpZXMoW1xuICogICAgIGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCAnb25lJyk7XG4gKiAgICAgICAgIH0sIDIwMCk7XG4gKiAgICAgfSxcbiAqICAgICBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgJ3R3bycpO1xuICogICAgICAgICB9LCAxMDApO1xuICogICAgIH1cbiAqIF0pLnRoZW4ocmVzdWx0cyA9PiB7XG4gKiAgICAgY29uc29sZS5sb2cocmVzdWx0cyk7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ICogICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICAgICAgICAgIC8vIGRvIHNvbWUgYXN5bmMgdGFza1xuICogICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCAnb25lJyk7XG4gKiAgICAgICAgICAgICAgICAgfSwgMjAwKTtcbiAqICAgICAgICAgICAgIH0sXG4gKiAgICAgICAgICAgICBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICAgICAgICAgIC8vIHRoZW4gZG8gYW5vdGhlciBhc3luYyB0YXNrXG4gKiAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsICd0d28nKTtcbiAqICAgICAgICAgICAgICAgICB9LCAxMDApO1xuICogICAgICAgICAgICAgfVxuICogICAgICAgICBdKTtcbiAqICAgICAgICAgY29uc29sZS5sb2cocmVzdWx0cyk7XG4gKiAgICAgICAgIC8vIHJlc3VsdHMgaXMgZXF1YWwgdG8gWydvbmUnLCd0d28nXVxuICogICAgIH1cbiAqICAgICBjYXRjaCAoZXJyKSB7XG4gKiAgICAgICAgIGNvbnNvbGUubG9nKGVycik7XG4gKiAgICAgfVxuICogfVxuICpcbiAqIC8vIGFuIGV4YW1wbGUgdXNpbmcgYW4gb2JqZWN0IGluc3RlYWQgb2YgYW4gYXJyYXlcbiAqIGFzeW5jICgpID0+IHtcbiAqICAgICB0cnkge1xuICogICAgICAgICBsZXQgcmVzdWx0cyA9IGF3YWl0IGFzeW5jLnBhcmFsbGVsKHtcbiAqICAgICAgICAgICAgIG9uZTogZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgICAgICAgICAvLyBkbyBzb21lIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgMSk7XG4gKiAgICAgICAgICAgICAgICAgfSwgMjAwKTtcbiAqICAgICAgICAgICAgIH0sXG4gKiAgICAgICAgICAgIHR3bzogZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgICAgICAgICAvLyB0aGVuIGRvIGFub3RoZXIgYXN5bmMgdGFza1xuICogICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCAyKTtcbiAqICAgICAgICAgICAgICAgICB9LCAxMDApO1xuICogICAgICAgICAgICB9XG4gKiAgICAgICAgIH0pO1xuICogICAgICAgICBjb25zb2xlLmxvZyhyZXN1bHRzKTtcbiAqICAgICAgICAgLy8gcmVzdWx0cyBpcyBlcXVhbCB0bzogeyBvbmU6IDEsIHR3bzogMiB9XG4gKiAgICAgfVxuICogICAgIGNhdGNoIChlcnIpIHtcbiAqICAgICAgICAgY29uc29sZS5sb2coZXJyKTtcbiAqICAgICB9XG4gKiB9XG4gKlxuICovXG5mdW5jdGlvbiBzZXJpZXModGFza3MsIGNhbGxiYWNrKSB7XG4gICAgcmV0dXJuICgwLCBfcGFyYWxsZWwzLmRlZmF1bHQpKF9lYWNoT2ZTZXJpZXMyLmRlZmF1bHQsIHRhc2tzLCBjYWxsYmFjayk7XG59XG5tb2R1bGUuZXhwb3J0cyA9IGV4cG9ydHMuZGVmYXVsdDsiLCIndXNlIHN0cmljdCc7XG5cbmZ1bmN0aW9uIF9pbmhlcml0c0xvb3NlKHN1YkNsYXNzLCBzdXBlckNsYXNzKSB7IHN1YkNsYXNzLnByb3RvdHlwZSA9IE9iamVjdC5jcmVhdGUoc3VwZXJDbGFzcy5wcm90b3R5cGUpOyBzdWJDbGFzcy5wcm90b3R5cGUuY29uc3RydWN0b3IgPSBzdWJDbGFzczsgc3ViQ2xhc3MuX19wcm90b19fID0gc3VwZXJDbGFzczsgfV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cm9vdEVsZW1lbnQsIHJvb3ROYW1lO1xuICAgICAgYXR0cmtleSA9IHRoaXMub3B0aW9ucy5hdHRya2V5O1xuICAgICAgY2hhcmtleSA9IHRoaXMub3B0aW9ucy5jaGFya2V5O1xuICAgICAgaWYgKChPYmplY3Qua2V5cyhyb290T2JqKS5sZW5ndGggPT09IDEpICYmICh0aGlzLm9wdGlvbnMucm9vdE5hbWUgPT09IGRlZmF1bHRzWycwLjInXS5yb290TmFtZSkpIHtcbiAgICAgICAgcm9vdE5hbWUgPSBPYmplY3Qua2V5cyhyb290T2JqKVswXTtcbiAgICAgICAgcm9vdE9iaiA9IHJvb3RPYmpbcm9vdE5hbWVdO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcm9vdE5hbWUgPSB0aGlzLm9wdGlvbnMucm9vdE5hbWU7XG4gICAgICB9XG4gICAgICByZW5kZXIgPSAoZnVuY3Rpb24oX3RoaXMpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGVsZW1lbnQsIG9iaikge1xuICAgICAgICAgIHZhciBhdHRyLCBjaGlsZCwgZW50cnksIGluZGV4LCBrZXksIHZhbHVlO1xuICAgICAgICAgIGlmICh0eXBlb2Ygb2JqICE9PSAnb2JqZWN0Jykge1xuICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMuY2RhdGEgJiYgcmVxdWlyZXNDREFUQShvYmopKSB7XG4gICAgICAgICAgICAgIGVsZW1lbnQucmF3KHdyYXBDREFUQShvYmopKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGVsZW1lbnQudHh0KG9iaik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KG9iaikpIHtcbiAgICAgICAgICAgIGZvciAoaW5kZXggaW4gb2JqKSB7XG4gICAgICAgICAgICAgIGlmICghaGFzUHJvcC5jYWxsKG9iaiwgaW5kZXgpKSBjb250aW51ZTtcbiAgICAgICAgICAgICAgY2hpbGQgPSBvYmpbaW5kZXhdO1xuICAgICAgICAgICAgICBmb3IgKGtleSBpbiBjaGlsZCkge1xuICAgICAgICAgICAgICAgIGVudHJ5ID0gY2hpbGRba2V5XTtcbiAgICAgICAgICAgICAgICBlbGVtZW50ID0gcmVuZGVyKGVsZW1lbnQuZWxlKGtleSksIGVudHJ5KS51cCgpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGZvciAoa2V5IGluIG9iaikge1xuICAgICAgICAgICAgICBpZiAoIWhhc1Byb3AuY2FsbChvYmosIGtleSkpIGNvbnRpbnVlO1xuICAgICAgICAgICAgICBjaGlsZCA9IG9ialtrZXldO1xuICAgICAgICAgICAgICBpZiAoa2V5ID09PSBhdHRya2V5KSB7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBjaGlsZCA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgICAgZm9yIChhdHRyIGluIGNoaWxkKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhbHVlID0gY2hpbGRbYXR0cl07XG4gICAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LmF0dChhdHRyLCB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKGtleSA9PT0gY2hhcmtleSkge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLmNkYXRhICYmIHJlcXVpcmVzQ0RBVEEoY2hpbGQpKSB7XG4gICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZWxlbWVudC5yYXcod3JhcENEQVRBKGNoaWxkKSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LnR4dChjaGlsZCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoY2hpbGQpKSB7XG4gICAgICAgICAgICAgICAgZm9yIChpbmRleCBpbiBjaGlsZCkge1xuICAgICAgICAgICAgICAgICAgaWYgKCFoYXNQcm9wLmNhbGwoY2hpbGQsIGluZGV4KSkgY29udGludWU7XG4gICAgICAgICAgICAgICAgICBlbnRyeSA9IGNoaWxkW2luZGV4XTtcbiAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZW50cnkgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLmNkYXRhICYmIHJlcXVpcmVzQ0RBVEEoZW50cnkpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQuZWxlKGtleSkucmF3KHdyYXBDREFUQShlbnRyeSkpLnVwKCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQuZWxlKGtleSwgZW50cnkpLnVwKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSByZW5kZXIoZWxlbWVudC5lbGUoa2V5KSwgZW50cnkpLnVwKCk7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBjaGlsZCA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgIGVsZW1lbnQgPSByZW5kZXIoZWxlbWVudC5lbGUoa2V5KSwgY2hpbGQpLnVwKCk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBjaGlsZCA9PT0gJ3N0cmluZycgJiYgX3RoaXMub3B0aW9ucy5jZGF0YSAmJiByZXF1aXJlc0NEQVRBKGNoaWxkKSkge1xuICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQuZWxlKGtleSkucmF3KHdyYXBDREFUQShjaGlsZCkpLnVwKCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIGlmIChjaGlsZCA9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkID0gJyc7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZWxlbWVudC5lbGUoa2V5LCBjaGlsZC50b1N0cmluZygpKS51cCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICByZXR1cm4gZWxlbWVudDtcbiAgICAgICAgfTtcbiAgICAgIH0pKHRoaXMpO1xuICAgICAgcm9vdEVsZW1lbnQgPSBidWlsZGVyLmNyZWF0ZShyb290TmFtZSwgdGhpcy5vcHRpb25zLnhtbGRlYywgdGhpcy5vcHRpb25zLmRvY3R5cGUsIHtcbiAgICAgICAgaGVhZGxlc3M6IHRoaXMub3B0aW9ucy5oZWFkbGVzcyxcbiAgICAgICAgYWxsb3dTdXJyb2dhdGVDaGFyczogdGhpcy5vcHRpb25zLmFsbG93U3Vycm9nYXRlQ2hhcnNcbiAgICAgIH0pO1xuICAgICAgcmV0dXJuIHJlbmRlcihyb290RWxlbWVudCwgcm9vdE9iaikuZW5kKHRoaXMub3B0aW9ucy5yZW5kZXJPcHRzKTtcbiAgICB9O1xuXG4gICAgcmV0dXJuIEJ1aWxkZXI7XG5cbiAgfSkoKTtcblxufSkuY2FsbCh0aGlzKTtcbiIsIi8vIEdlbmVyYXRlZCBieSBDb2ZmZWVTY3JpcHQgMS4xMi43XG4oZnVuY3Rpb24oKSB7XG4gIGV4cG9ydHMuZGVmYXVsdHMgPSB7XG4gICAgXCIwLjFcIjoge1xuICAgICAgZXhwbGljaXRDaG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V0dXJuIG5ldyBleHBvcnRzLlBhcnNlcihvcHRzKTtcbiAgICAgIH1cbiAgICAgIHRoaXMub3B0aW9ucyA9IHt9O1xuICAgICAgcmVmID0gZGVmYXVsdHNbXCIwLjJcIl07XG4gICAgICBmb3IgKGtleSBpbiByZWYpIHtcbiAgICAgICAgaWYgKCFoYXNQcm9wLmNhbGwocmVmLCBrZXkpKSBjb250aW51ZTtcbiAgICAgICAgdmFsdWUgPSByZWZba2V5XTtcbiAgICAgICAgdGhpcy5vcHRpb25zW2tleV0gPSB2YWx1ZTtcbiAgICAgIH1cbiAgICAgIGZvciAoa2V5IGluIG9wdHMpIHtcbiAgICAgICAgaWYgKCFoYXNQcm9wLmNhbGwob3B0cywga2V5KSkgY29udGludWU7XG4gICAgICAgIHZhbHVlID0gb3B0c1trZXldO1xuICAgICAgICB0aGlzLm9wdGlvbnNba2V5XSA9IHZhbHVlO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMub3B0aW9ucy54bWxucykge1xuICAgICAgICB0aGlzLm9wdGlvbnMueG1sbnNrZXkgPSB0aGlzLm9wdGlvbnMuYXR0cmtleSArIFwibnNcIjtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLm9wdGlvbnMubm9ybWFsaXplVGFncykge1xuICAgICAgICBpZiAoIXRoaXMub3B0aW9ucy50YWdOYW1lUHJvY2Vzc29ycykge1xuICAgICAgICAgIHRoaXMub3B0aW9ucy50YWdOYW1lUHJvY2Vzc29ycyA9IFtdO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMub3B0aW9ucy50YWdOYW1lUHJvY2Vzc29ycy51bnNoaWZ0KHByb2Nlc3NvcnMubm9ybWFsaXplKTtcbiAgICAgIH1cbiAgICAgIHRoaXMucmVzZXQoKTtcbiAgICB9XG5cbiAgICBQYXJzZXIucHJvdG90eXBlLnByb2Nlc3NBc3luYyA9IGZ1bmN0aW9uKCkge1xuICAgICAgdmFyIGNodW5rLCBlcnI7XG4gICAgICB0cnkge1xuICAgIC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aGlzLm9wdGlvbnMuZXhwbGljaXRBcnJheSkge1xuICAgICAgICAgIHJldHVybiBvYmpba2V5XSA9IG5ld1ZhbHVlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHJldHVybiBvYmpba2V5XSA9IFtuZXdWYWx1ZV07XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICghKG9ialtrZXldIGluc3RhbmNlb2YgQXJyYXkpKSB7XG4gICAgICAgICAgb2JqW2tleV0gPSBbb2JqW2tleV1dO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBvYmpba2V5XS5wdXNoKG5ld1ZhbHVlKTtcbiAgICAgIH1cbiAgICB9O1xuXG4gICAgUGFyc2VyLnByb3RvdHlwZS5yZXNldCA9IGZ1bmN0aW9uKCkge1xuICAgICAgdmFyIGF0dHJrZXksIGNoYXJrZXksIG9udGV4dCwgc3RhY2s7XG4gICAgICB0aGlzLnJlbW92ZUFsbExpc3RlbmVycygpO1xuICAgICAgdGhpcy5zYXhQYXJzZXIgPSBzYXgucGFyc2VyKHRoaXMub3B0aW9ucy5zdHJpY3QsIHtcbiAgICAgICAgdHJpbTogZmFsc2UsXG4gICAgICAgIG5vcm1hbGl6ZTogZmFsc2UsXG4gICAgICAgIHhtbG5zOiB0aGlzLm9wdGlvbnMueG1sbnNcbiAgICAgIH0pO1xuICAgICAgdGhpcy5zYXhQYXJzZXIuZXJyVGhyb3duID0gZmFsc2U7XG4gICAgICB0aGlzLnNheFBhcnNlci5vbmVycm9yID0gKGZ1bmN0aW9uKF90aGlzKSB7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbihlcnJvcikge1xuICAgICAgICAgIF90aGlzLnNheFBhcnNlci5yZXN1bWUoKTtcbiAgICAgICAgICBpZiAoIV90aGlzLnNheFBhcnNlci5lcnJUaHJvd24pIHtcbiAgICAgICAgICAgIF90aGlzLnNheFBhcnNlci5lcnJUaHJvd24gPSB0cnVlO1xuICAgICAgICAgICAgcmV0dXJuIF90aGlzLmVtaXQoXCJlcnJvclwiLCBlcnJvcik7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgfSkodGhpcyk7XG4gICAgICB0aGlzLnNheFBhcnNlci5vbmVuZCA9IChmdW5jdGlvbihfdGhpcykge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgaWYgKCFfdGhpcy5zYXhQYXJzZXIuZW5kZWQpIHtcbiAgICAgICAgICAgIF90aGlzLnNheFBhcnNlci5lbmRlZCA9IHRydWU7XG4gICAgICAgICAgICByZXR1cm4gX3RoaXMuZW1pdChcImVuZFwiLCBfdGhpcy5yZXN1bHRPYmplY3QpO1xuICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgIH0pKHRoaXMpO1xuICAgICAgdGhpcy5zYXhQYXJzZXIuZW5kZWQgPSBmYWxzZTtcbiAgICAgIHRoaXMuRVhQTElDSVRfQ0hBUktFWSA9IHRoaXMub3B0aW9ucy5leHBsaWNpdENoYXJrZXk7XG4gICAgICB0aGlzLnJlc3VsdE9iamVjdCA9IG51bGw7XG4gICAgICBzdGFjayA9IFtdO1xuICAgICAgYXR0cmtleSA9IHRoaXMub3B0aW9ucy5hdHRya2V5O1xuICAgICAgY2hhcmtleSA9IHRoaXMub3B0aW9ucy5jaGFya2V5O1xuICAgICAgdGhpcy5zYXhQYXJzZXIub25vcGVudGFnID0gKGZ1bmN0aW9uKF90aGlzKSB7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbihub2RlKSB7XG4gICAgICAgICAgdmFyIGtleSwgbmV3VmFsdWUsIG9iaiwgcHJvY2Vzc2VkS2V5LCByZWY7XG4gICAgICAgICAgb2JqID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgICAgICBvYmpbY2hhcmtleV0gPSBcIlwiO1xuICAgICAgICAgIGlmICghX3RoaXMub3B0aW9ucy5pZ25vcmVBdHRycykge1xuICAgICAgICAgICAgcmVmID0gbm9kZS5hdHR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WdOYW1lUHJvY2Vzc29ycywgbm9kZS5uYW1lKSA6IG5vZGUubmFtZTtcbiAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy54bWxucykge1xuICAgICAgICAgICAgb2JqW190aGlzLm9wdGlvbnMueG1sbnNrZXldID0ge1xuICAgICAgICAgICAgICB1cmk6IG5vZGUudXJpLFxuICAgICAgICAgICAgICBsb2NhbDogbm9kZS5sb2NhbFxuICAgICAgICAgICAgfTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHN0YWNrLnB1c2gob2JqKTtcbiAgICAgICAgfTtcbiAgICAgIH0pKHRoaXMpO1xuICAgICAgdGhpcy5zYXhQYXJzZXIub25jbG9zZXRhZyA9IChmdW5jdGlvbihfdGhpcykge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgdmFyIGNkYXRhLCBlbXB0eVN0ciwga2V5LCBub2RlLCBub2RlTmFtZSwgb2JqLCBvYmpDbG9uZSwgb2xkLCBzLCB4cGF0aDtcbiAgICAgICAgICBvYmogPSBzdGFjay5wb3AoKTtcbiAgICAgICAgICBub2RlTmFtZSA9IG9ialtcIiNuYW1lXCJdO1xuICAgICAgICAgIGlmICghX3RoaXMub3B0aW9ucy5leHBsaWNpdENoaWxkcmVuIHx8ICFfdGhpcy5vcHRpb25zLnByZXNlcnZlQ2hpbGRyZW5PcmRlcikge1xuICAgICAgICAgICAgZGVsZXRlIG9ialtcIiNuYW1lXCJdO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAob2JqLmNkYXRhID09PSB0cnVlKSB7XG4gICAgICAgICAgICBjZGF0YSA9IG9iai5jZGF0YTtcbiAgICAgICAgICAgIGRlbGV0ZSBvYmouY2RhdGE7XG4gICAgICAgICAgfVxuICAgICAgICAgIHMgPSBzdGFja1tzdGFjay5sZW5ndGggLSAxXTtcbiAgICAgICAgICBpZiAob2JqW2NoYXJrZXldLm1hdGNoKC9eXFxzKiQvKSAmJiAhY2RhdGEpIHtcbiAgICAgICAgICAgIGVtcHR5U3RyID0gb2JqW2NoYXJrZXldO1xuICAgICAgICAgICAgZGVsZXRlIG9ialtjaGFya2V5XTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMudHJpbSkge1xuICAgICAgICAgICAgICBvYmpbY2hhcmtleV0gPSBvYmpbY2hhcmtleV0udHJpbSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMubm9ybWFsaXplKSB7XG4gICAgICAgICAgICAgIG9ialtjaGFya2V5XSA9IG9ialtjaGFya2V5XS5yZXBsYWNlKC9cXHN7Mix9L2csIFwiIFwiKS50cmltKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBvYmpbY2hhcmtleV0gPSBfdGhpcy5vcHRpb25zLnZhbHVlUHJvY2Vzc29ycyA/IHByb2Nlc3NJdGVtKF90aGlzLm9wdGlvbnMudmFsdWVQcm9jZXNzb3JzLCBvYmpbY2hhcmtleV0sIG5vZGVOYW1lKSA6IG9ialtjaGFya2V5XTtcbiAgICAgICAgICAgIGlmIChPYmplY3Qua2V5cyhvYmopLmxlbmd0aCA9PT0gMSAmJiBjaGFya2V5IGluIG9iaiAmJiAhX3RoaXMuRVhQTElDSVRfQ0hBUktFWSkge1xuICAgICAgICAgICAgICBvYmogPSBvYmpbY2hhcmtleV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChpc0VtcHR5KG9iaikpIHtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgX3RoaXMub3B0aW9ucy5lbXB0eVRhZyA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgICAgICBvYmogPSBfdGhpcy5vcHRpb25zLmVtcHR5VGFnKCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBvYmogPSBfdGhpcy5vcHRpb25zLmVtcHR5VGFnICE9PSAnJyA/IF90aGlzLm9wdGlvbnMuZW1wdHlUYWcgOiBlbXB0eVN0cjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMudmFsaWRhdG9yICE9IG51bGwpIHtcbiAgICAgICAgICAgIHhwYXRoID0gXCIvXCIgKyAoKGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICB2YXIgaSwgbGVuLCByZXN1bHRzO1xuICAgICAgICAgICAgICByZXN1bHRzID0gW107XG4gICAgICAgICAgICAgIGZvciAoaSA9IDAsIGxlbiA9IHN0YWNrLmxlbmd0aDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbm9kZSA9IHN0YWNrW2ldO1xuICAgICAgICAgICAgICAgIHJlc3VsdHMucHVzaChub2RlW1wiI25hbWVcIl0pO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHJldHVybiByZXN1bHRzO1xuICAgICAgICAgICAgfSkoKSkuY29uY2F0KG5vZGVOYW1lKS5qb2luKFwiL1wiKTtcbiAgICAgICAgICAgIChmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgdmFyIGVycjtcbiAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICByZXR1cm4gb2JqID0gX3RoaXMub3B0aW9ucy52YWxpZGF0b3IoeHBhdGgsIHMgJiYgc1tub2RlTmFtZV0sIG9iaik7XG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yMSkge1xuICAgICAgICAgICAgICAgIGVyciA9IGVycm9yMTtcbiAgICAgICAgICAgICAgICByZXR1cm4gX3RoaXMuZW1pdChcImVycm9yXCIsIGVycik7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLmV4cGxpY2l0Q2hpbGRyZW4gJiYgIV90aGlzLm9wdGlvbnMubWVyZ2VBdHRycyAmJiB0eXBlb2Ygb2JqID09PSAnb2JqZWN0Jykge1xuICAgICAgICAgICAgaWYgKCFfdGhpcy5vcHRpb25zLnByZXNlcnZlQ2hpbGRyZW5PcmRlcikge1xuICAgICAgICAgICAgICBub2RlID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMuYXR0cmtleSBpbiBvYmopIHtcbiAgICAgICAgICAgICAgICBub2RlW190aGlzLm9wdGlvbnMuYXR0cmtleV0gPSBvYmpbX3RoaXMub3B0aW9ucy5hdHRya2V5XTtcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqW190aGlzLm9wdGlvbnMuYXR0cmtleV07XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKCFfdGhpcy5vcHRpb25zLmNoYXJzQXNDaGlsZHJlbiAmJiBfdGhpcy5vcHRpb25zLmNoYXJrZXkgaW4gb2JqKSB7XG4gICAgICAgICAgICAgICAgbm9kZVtfdGhpcy5vcHRpb25zLmNoYXJrZXldID0gb2JqW190aGlzLm9wdGlvbnMuY2hhcmtleV07XG4gICAgICAgICAgICAgICAgZGVsZXRlIG9ialtfdGhpcy5vcHRpb25zLmNoYXJrZXldO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmIChPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyhvYmopLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgICAgICBub2RlW190aGlzLm9wdGlvbnMuY2hpbGRrZXldID0gb2JqO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIG9iaiA9IG5vZGU7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHMpIHtcbiAgICAgICAgICAgICAgc1tfdGhpcy5vcHRpb25zLmNoaWxka2V5XSA9IHNbX3RoaXMub3B0aW9ucy5jaGlsZGtleV0gfHwgW107XG4gICAgICAgICAgICAgIG9iakNsb25lID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgICAgICAgICAgZm9yIChrZXkgaW4gb2JqKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFoYXNQcm9wLmNhbGwob2JqLCBrZXkpKSBjb250aW51ZTtcbiAgICAgICAgICAgICAgICBvYmpDbG9uZVtrZXldID0gb2JqW2tleV07XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgc1tfdGhpcy5vcHRpb25zLmNoaWxka2V5XS5wdXNoKG9iakNsb25lKTtcbiAgICAgICAgICAgICAgZGVsZXRlIG9ialtcIiNuYW1lXCJdO1xuICAgICAgICAgICAgICBpZiAoT2JqZWN0LmtleXMob2JqKS5sZW5ndGggPT09IDEgJiYgY2hhcmtleSBpbiBvYmogJiYgIV90aGlzLkVYUExJQ0lUX0NIQVJLRVkpIHtcbiAgICAgICAgICAgICAgICBvYmogPSBvYmpbY2hhcmtleV07XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIHJldHVybiBfdGhpcy5hc3NpZ25PclB1c2gocywgbm9kZU5hbWUsIG9iaik7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLmV4cGxpY2l0Um9vdCkge1xuICAgICAgICAgICAgICBvbGQgPSBvYmo7XG4gICAgICAgICAgICAgIG9iaiA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgICAgICAgICAgIG9ialtub2RlTmFtZV0gPSBvbGQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBfdGhpcy5yZXN1bHRPYmplY3QgPSBvYmo7XG4gICAgICAgICAgICBfdGhpcy5zYXhQYXJzZXIuZW5kZWQgPSB0cnVlO1xuICAgICAgICAgICAgcmV0dXJuIF90aGlzLmVtaXQoXCJlbmRcIiwgX3RoaXMucmVzdWx0T2JqZWN0KTtcbiAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICB9KSh0aGlzKTtcbiAgICAgIG9udGV4dCA9IChmdW5jdGlvbihfdGhpcykge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24odGV4dCkge1xuICAgICAgICAgIHZhciBjaGFyQ2hpbGQsIHM7XG4gICAgICAgICAgcyA9IHN0YWNrW3N0YWNrLmxlbmd0aCAtIDFdO1xuICAgICAgICAgIGlmIChzKSB7XG4gICAgICAgICAgICBzW2NoYXJrZXldICs9IHRleHQ7XG4gICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5leHBsaWNpdENoaWxkcmVuICYmIF90aGlzLm9wdGlvbnMucHJlc2VydmVDaGlsZHJlbk9yZGVyICYmIF90aGlzLm9wdGlvbnMuY2hhcnNBc0NoaWxkcmVuICYmIChfdGhpcy5vcHRpb25zLmluY2x1ZGVXaGl0ZUNoYXJzIHx8IHRleHQucmVwbGFjZSgvXFxcXG4vZywgJycpLnRyaW0oKSAhPT0gJycpKSB7XG4gICAgICAgICAgICAgIHNbX3RoaXMub3B0aW9ucy5jaGlsZGtleV0gPSBzW190aGlzLm9wdGlvbnMuY2hpbGRrZXldIHx8IFtdO1xuICAgICAgICAgICAgICBjaGFyQ2hpbGQgPSB7XG4gICAgICAgICAgICAgICAgJyNuYW1lJzogJ19fdGV4dF9fJ1xuICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICBjaGFyQ2hpbGRbY2hhcmtleV0gPSB0ZXh0O1xuICAgICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5ub3JtYWxpemUpIHtcbiAgICAgICAgICAgICAgICBjaGFyQ2hpbGRbY2hhcmtleV0gPSBjaGFyQ2hpbGRbY2hhcmtleV0ucmVwbGFjZSgvXFxzezIsfS9nLCBcIiBcIikudHJpbSgpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHNbX3RoaXMub3B0aW9ucy5jaGlsZGtleV0ucHVzaChjaGFyQ2hpbGQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHM7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgfSkodGhpcyk7XG4gICAgICB0aGlzLnNheFBhcnNlci5vbnRleHQgPSBvbnRleHQ7XG4gICAgICByZXR1cm4gdGhpcy5zYXhQYXJzZXIub25jZGF0YSA9IChmdW5jdGlvbihfdGhpcykge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24odGV4dCkge1xuICAgICAgICAgIHZhciBzO1xuICAgICAgICAgIHMgPSBvbnRleHQodGV4dCk7XG4gICAgICAgICAgaWYgKHMpIHtcbiAgICAgICAgICAgIHJldHVybiBzLmNkYXRhID0gdHJ1ZTtcbiAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICB9KSh0aGlzKTtcbiAgICB9O1xuXG4gICAgUGFyc2VyLnByb3RvdHlwZS5wYXJzZVN0cmluZyA9IGZ1bmN0aW9uKHN0ciwgY2IpIHtcbiAgICAgIHZhciBlcnI7XG4gICAgICBpZiAoKGNiICE9IG51bGwpICYmIHR5cGVvZiBjYiA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgIHRoaXMub24oXCJlbmRcIiwgZnVuY3Rpb24ocmVzdWx0KSB7XG4gICAgICAgICAgdGhpcy5yZXNldCgpO1xuICAgICAgICAgIHJldHVybiBjYihudWxsLCByZXN1bHQpO1xuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5vbihcImVycm9yXCIsIGZ1bmN0aW9uKGVycikge1xuICAgICAgICAgIHRoaXMucmVzZXQoKTtcbiAgICAgICAgICByZXR1cm4gY2IoZXJyKTtcbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgICB0cnkge1xuICAgICAgICBzdHIgPSBzdHIudG9TdHJpbmcoKTtcbiAgICAgICAgaWYgKHN0ci50cmltKCkgPT09ICcnKSB7XG4gICAgICAgICAgdGhpcy5lbWl0KFwiZW5kXCIsIG51bGwpO1xuICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHN0ciA9IGJvbS5zdHJpcEJPTShzdHIpO1xuICAgICAgICBpZiAodGhpcy5vcHRpb25zLmFzeW5jKSB7XG4gICAgICAgICAgdGhpcy5yZW1haW5pbmcgPSBzdHI7XG4gICAgICAgICAgc2V0SW1tZWRpYXRlKHRoaXMucHJvY2Vzc0FzeW5jKTtcbiAgICAgICAgICByZXR1cm4gdGhpcy5zYXhQYXJzZXI7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMuc2F4UGFyc2VyLndyaXRlKHN0cikuY2xvc2UoKTtcbiAgICAgIH0gY2F0Y2ggKGVycm9yMSkge1xuICAgICAgICBlcnIgPSBlcnJvcjE7XG4gICAgICAgIGlmICghKHRoaXMuc2F4UGFyc2VyLmVyclRocm93biB8fCB0aGlzLnNheFBhcnNlci5lbmRlZCkpIHtcbiAgICAgICAgICB0aGlzLmVtaXQoJ2Vycm9yJywgZXJyKTtcbiAgICAgICAgICByZXR1cm4gdGhpcy5zYXhQYXJzZXIuZXJyVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnNheFBhcnNlci5lbmRlZCkge1xuICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH07XG5cbiAgICBQYXJzZXIucHJvdG90eXBlLnBhcnNlU3RyaW5nUHJvbWlzZSA9IGZ1bmN0aW9uKHN0cikge1xuICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKChmdW5jdGlvbihfdGhpcykge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24ocmVzb2x2ZSwgcmVqZWN0KSB7XG4gICAgICAgICAgcmV0dXJuIF90aGlzLnBhcnNlU3RyaW5nKHN0ciwgZnVuY3Rpb24oZXJyLCB2YWx1ZSkge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICByZXR1cm4gcmVqZWN0KGVycik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICByZXR1c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FbnRpdHkucHJvdG90eXBlLCAnc3lzdGVtSWQnLCB7XG4gICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5zeXNJRDtcbiAgICAgIH1cbiAgICB9KTtcblxuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShYTUxEVERFbnRpdHkucHJvdG90eXBlLCAnbm90YXRpb25OYW1lJywge1xuICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMubkRhdGEgfHwgbnVsbDtcbiAgICAgIH1cbiAgICB9KTtcblxuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShYTUxEVERFbnRpdHkucHJvdG90eXBlLCAnaW5wdXRFbmNvZGluZycsIHtcbiAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFhNTERUREVudGl0eS5wcm90b3R5cGUsICd4bWxFbmNvZGluZycsIHtcbiAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFhNTERUREVudGl0eS5wcm90b3R5cGUsICd4bWxWZXJzaW9uJywge1xuICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICBYTUxEVERFbnRpdHkucHJvdG90eXBlLnRvU3RyaW5nID0gZnVuY3Rpb24ob3B0aW9ucykge1xuICAgICAgcmV0dXJuIHRoaXMub3B0aW9ucy53cml0ZXIuZHRkRW50aXR5KHRoaXMsIHRoaXMub3B0aW9ucy53cml0ZXIuZmlsdGVyT3B0aW9ucyhvcHRpb25zKSk7XG4gICAgfTtcblxuICAgIHJldHVybiBYTUxEVERFbnRp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9wLmNhbGwocmVmMSwgbmFtZSkpIGNvbnRpbnVlO1xuICAgICAgICAgICAgYXR0ID0gcmVmMVtuYW1lXTtcbiAgICAgICAgICAgIGNodW5rICs9IHRoaXMud3JpdGVyLmF0dHJpYnV0ZShhdHQsIHRoaXMud3JpdGVyT3B0aW9ucywgdGhpcy5jdXJyZW50TGV2ZWwpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBjaHVuayArPSAobm9kZS5jaGlsZHJlbiA/ICc+JyA6ICcvPicpICsgdGhpcy53cml0ZXIuZW5kbGluZShub2RlLCB0aGlzLndyaXRlck9wdGlvbnMsIHRoaXMuY3VycmVudExldmVsKTtcbiAgICAgICAgICB0aGlzLndyaXRlck9wdGlvbnMuc3RhdGUgPSBXcml0ZXJTdGF0ZS5JbnNpZGVUYWc7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy53cml0ZXJPcHRpb25zLnN0YXRlID0gV3JpdGVyU3RhdGUuT3BlblRhZztcbiAgICAgICAgICBjaHVuayA9IHRoaXMud3JpdGVyLmluZGVudChub2RlLCB0aGlzLndyaXRlck9wdGlvbnMsIHRoaXMuY3VycmVudExldmVsKSArICc8IURPQ1RZUEUgJyArIG5vZGUucm9vdE5vZGVOYW1lO1xuICAgICAgICAgIGlmIChub2RlLnB1YklEICYmIG5vZGUuc3lzSUQpIHtcbiAgICAgICAgICAgIGNodW5rICs9ICcgUFVCTElDIFwiJyArIG5vZGUucHViSUQgKyAnXCIgXCInICsgbm9kZS5zeXNJRCArICdcIic7XG4gICAgICAgICAgfSBlbHNlIGlmIChub2RlLnN5c0lEKSB7XG4gICAgICAgICAgICBjaHVuayArPSAnIFNZU1RFTSBcIicgKyBub2RlLnN5c0lEICsgJ1wiJztcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG5vZGUuY2hpbGRyZW4pIHtcbiAgICAgICAgICAgIGNodW5rICs9ICcgWyc7XG4gICAgICAgICAgICB0aGlzLndyaXRlck9wdGlvbnMuc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mplY3QgPSBwYXJlbnQ7XG4gICAgICAgIHBhcmVudC5yb290T2JqZWN0ID0gdGhpcztcbiAgICAgICAgaWYgKHBhcmVudC5jaGlsZHJlbikge1xuICAgICAgICAgIHJlZjEgPSBwYXJlbnQuY2hpbGRyZW47XG4gICAgICAgICAgZm9yIChqID0gMCwgbGVuID0gcmVmMS5sZW5ndGg7IGogPCBsZW47IGorKykge1xuICAgICAgICAgICAgY2hpbGQgPSByZWYxW2pdO1xuICAgICAgICAgICAgaWYgKGNoaWxkLnR5cGUgPT09IE5vZGVUeXBlLkRvY1R5cGUpIHtcbiAgICAgICAgICAgICAgY2hpbGQubmFtZSA9IHRoaXMubmFtZTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFhNTEVsZW1lbnQucHJvdG90eXBlLCAndGFnTmFtZScsIHtcbiAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLm5hbWU7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoWE1MRWxlbWVudC5wcm90b3R5cGUsICduYW1lc3BhY2VVUkknLCB7XG4gICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gJyc7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoWE1MRWxlbWVudC5wcm90b3R5cGUsICdwcmVmaXgnLCB7XG4gICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gJyc7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoWE1MRWxlbWVudC5wcm90b3R5cGUsICdsb2NhbE5hbWUnLCB7XG4gICAgICBnZXQ6IGZ1bmN0aW9uK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GVtID0gdmFsW2tdO1xuICAgICAgICAgICAgICBjaGlsZE5vZGUgPSB7fTtcbiAgICAgICAgICAgICAgY2hpbGROb2RlW2tleV0gPSBpdGVtO1xuICAgICAgICAgICAgICBsYXN0Q2hpbGQgPSB0aGlzLmVsZW1lbnQoY2hpbGROb2RlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2UgaWYgKGlzT2JqZWN0KHZhbCkpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5vcHRpb25zLmlnbm9yZURlY29yYXRvcnMgJiYgdGhpcy5zdHJpbmdpZnkuY29udmVydFRleHRLZXkgJiYga2V5LmluZGV4T2YodGhpcy5zdHJpbmdpZnkuY29udmVydFRleHRLZXkpID09PSAwKSB7XG4gICAgICAgICAgICAgIGxhc3RDaGlsZCA9IHRoaXMuZWxlbWVudCh2YWwpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgbGFzdENoaWxkID0gdGhpcy5lbGVtZW50KGtleSk7XG4gICAgICAgICAgICAgIGxhc3RDaGlsZC5lbGVtZW50KHZhbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxhc3RDaGlsZCA9IHRoaXMuZWxlbWVudChrZXksIHZhbCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKCF0aGlzLm9wdGlvbnMua2VlcE51bGxOb2RlcyAmJiB0ZXh0ID09PSBudWxsKSB7XG4gICAgICAgIGxhc3RDaGlsZCA9IHRoaXMuZHVtbXkoKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICghdGhpcy5vcHRpb25zLmlnbm9yZURlY29yYXRvcnMgJiYgdGhpcy5zdHJpbmdpZnkuY29udmVydFRleHRLZXkgJiYgbmFtZS5pbmRleE9mKHRoaXMuc3RyaW5naWZ5LmNvbnZlcnRUZXh0S2V5KSA9PT0gMCkge1xuICAgICAgICAgIGxhc3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gICAgdGhyb3cgbmV3IEVycm9yKFwiVGhpcyBET00gbWV0aG9kIGlzIG5vdCBpbXBsZW1lbnRlZC5cIiArIHRoaXMuZGVidWdJbmZvKCkpO1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KFhNTFRleHQucHJvdG90eXBlLCAnd2hvbGVUZXh0Jywge1xuICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIG5leHQsIHByZXYsIHN0cjtcbiAgICAgICAgc3RyID0gJyc7XG4gICAgICAgIHByZXYgPSB0aGlzLnByZXZpb3VzU2libGluZztcbiAgICAgICAgd2hpbGUgKHByZXYpIHtcbiAgICAgICAgICBzdHIgPSBwcmV2LmRhdGEgKyBzdHI7XG4gICAgICAgICAgcHJldiA9IHByZXYucHJldmlvdXNTaWJsaW5nO1xuICAgICAgICB9XG4gICAgICAgIHN0ciArPSB0aGlzLmRhdGE7XG4gICAgICAgIG5leHQgPSB0aGlzLm5leHRTaWJsaW5nO1xuICAgICAgICB3aGlsZSAobmV4dCkge1xuICAgICAgICAgIHN0ciA9IHN0ciArIG5leHQuZGF0YTtcbiAgICAgICAgICBuZXh0ID0gbmV4dC5uZXh0U2libGluZztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gc3RyO1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgWE1MVGV4dC5wcm90b3R5cGUuY2xvbmUgPSBmdW5jdGlvbigpIHtcbiAgICAgIHJldHVybiBPYmplY3QuY3JlYXRlKHRoaXMpO1xuICAgIH07XG5cbiAgICBYTUxUZXh0LnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uKG9wdGlvbnMpIHtcbiAgICAgIHJldHVybiB0aGlzLm9wdGlvbnMud3JpdGVyLnRleHQodGhpcywgdGhpcy5vcHRpb25zLndyaXRlci5maWx0ZXJPcHRpb25zKG9wdGlvbnMpKTtcbiAgICB9O1xuXG4gICAgWE1MVGV4dC5wcm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XG4gICAgICAgICAgICAgIHByZXR0eVN1cHByZXNzZWQgPSB0cnVlO1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgciArPSAnPicgKyB0aGlzLmVuZGxpbmUobm9kZSwgb3B0aW9ucywgbGV2ZWwpO1xuICAgICAgICBvcHRpb25zLnN0YXRlID0gV3JpdGVyU3RhdGUuSW5zaWRlVGFnO1xuICAgICAgICByZWYyID0gbm9kZS5jaGlsZHJlbjtcbiAgICAgICAgZm9yIChqID0gMCwgbGVuMSA9IHJlZjIubGVuZ3RoOyBqIDwgbGVuMTsgaisrKSB7XG4gICAgICAgICAgY2hpbGQgPSByZWYyW2pdO1xuICAgICAgICAgIHIgKz0gdGhpcy53cml0ZUNoaWxkTm9kZShjaGlsZCwgb3B0aW9ucywgbGV2ZWwgKyAxKTtcbiAgICAgICAgfVxuICAgICAgICBvcHRpb25zLnN0YXRlID0gV3JpdGVyU3RhdGUuQ2xvc2VUYWc7XG4gICAgICAgIHIgKz0gdGhpcy5pbmRlbnQobm9kZSwgb3B0aW9ucywgbGV2ZWwpICsgJzwvJyArIG5vZGUubmFtZSArICc+JztcbiAgICAgICAgaWYgKHByZXR0eVN1cHByZXNzZWQpIHtcbiAgICAgICAgICBvcHRpb25zLnN1cHByZXNzUHJldHR5Q291bnQtLTtcbiAgICAgICAgfVxuICAgICAgICByICs9IHRoaXMuZW5kbGluZShub2RlLCBvcHRpb25zLCBsZXZlbCk7XG4gICAgICAgIG9wdGlvbnMuc3RhdGUgPSBXcml0ZXJTdGF0ZS5Ob25lO1xuICAgICAgfVxuICAgICAgdGhpcy5jbG9zZU5vZGUobm9kZSwgb3B0aW9ucywgbGV2ZWwpO1xuICAgICAgcmV0dXJuIHI7XG4gICAgfTtcblxuICAgIFhNTFdyaXRlckJhc2UucHJvdG90eXBlLndyaXRlQ2hpbGROb2RlID0gZnVuY3Rpb24obm9kZSwgb3B0aW9uc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ICAgIERpc2NvdmVyeS5wcm92aWRlKCd4cm46ZmlyZWJvbHQ6Y2FwYWJpbGl0eTpkaXNjb3Zlcnk6aW50ZXJlc3QnLCBuZXcgVXNlckludGVyZXN0RGVsZWdhdGVyKHRoaXMpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICBsb2dnZXIuZXJyb3IoJ0NvdWxkIG5vdCBzZXQgdXAgcHJvdmlkZXJzJyArIGVyciwgJ0xvYWRlZFN0YXRlJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcm9jZXNzLmVudi5BUFBPQkpFQ1QgPSB0aGlzO1xuICAgICAgICAgICAgY29uc3QgbWVudXNCdWlsZGVyID0gbmV3IE1lbnVCdWlsZGVyKCk7XG4gICAgICAgICAgICBMaWZlY3ljbGVIaXN0b3J5LmdldCgpLmluaXQodGhpcyk7XG4gICAgICAgICAgICBjb25zdCBtZW51ID0gbmV3IFVSTFNlYXJjaFBhcmFtcyh3aW5kb3cubG9jYXRpb24uc2VhcmNoKS5nZXQoJ21lbnUnKTtcbiAgICAgICAgICAgIHRoaXMudGFnKCdNYWluJykucGF0Y2goe1xuICAgICAgICAgICAgICBNYWluTWVudToge1xuICAgICAgICAgICAgICAgIHR5cGU6IE1lbnUsXG4gICAgICAgICAgICAgICAgbWVudXM6IG1lbnVzQnVpbGRlci5idWlsZCgpLFxuICAgICAgICAgICAgICAgIGluaXRpYWxNZW51OiBtZW51LFxuICAgICAgICAgICAgICAgIHg6IDUwLFxuICAgICAgICAgICAgICAgIHk6IDUwLFxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIGlmICghdGhpcy5wdWJTdWJVdWlkUHJlc2VudCAmJiBzeXN0ZW11aSA9PT0gJ3RydWUnKSB7XG4gICAgICAgICAgICAgIHRoaXMuc2V0QXBwSWQoQ09OU1RBTlRTLk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xldmVsKCdERUJVRycpO1xuICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgTW9kYWw6IHtcbiAgICAgICAgICAgICAgdHlwZTogTW9kYWwsXG4gICAgICAgICAgICB9LFxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIC8vIHNoaWZ0IGZvY3VzIHRvIG1vZGFsXG4gICAgICAgIF9nZXRGb2N1c2VkKCkge1xuICAgICAgICAgIHJldHVybiB0aGlzLnRhZygnTW9kYWwnKTtcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIGNsYXNzIFRvYXN0U3RhdGUgZXh0ZW5kcyB0aGlzIHtcbiAgICAgICAgJGVudGVyKCkge1xuICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgVG9hc3Q6IHtcbiAgICAgICAgICAgICAgdHlwZTogVG9hc3QsXG4gICAgICAgICAgICB9LFxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIC8vIHNoaWZ0IGZvY3VzIHRvIFRvYXN0XG4gICAgICAgIF9nZXRGb2N1c2VkKCkge1xuICAgICAgICAgIHJldHVybiB0aGlzLnRhZygnVG9hc3QnKTtcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIGNsYXNzIFRvYXN0U3RhdGVDb21wbCBleHRlbmRzIHRoaXMge1xuICAgICAgICAkZW50ZXIoKSB7XG4gICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBUb2FzdDoge1xuICAgICAgICAgICAgICB0eXBlOiBUb2FzdCxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgLy8gc2hpZnQgZm9jdXMgdG8gVG9hc3RcbiAgICAgICAgX2dldEZvY3VzZWQoKSB7XG4gICAgICAgICAgcmV0dXJuIHRoaXMudGFnKCdUb2FzdENvbXBsJyk7XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgXTtcbiAgfVxuXG4gIF9j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UmVzdWx0SGFuZGxlcic7XG5pbXBvcnQgeyBDT05TVEFOVFMgfSBmcm9tICcuL2NvbnN0YW50JztcbmltcG9ydCB7IGNlbnNvckRhdGEgfSBmcm9tICcuL3V0aWxzL1V0aWxzJztcbmltcG9ydCBNZXRob2RGaWx0ZXJzIGZyb20gJy4vTWV0aG9kRmlsdGVycyc7XG5pbXBvcnQgZXh0ZXJuYWxJbnZva2VycyBmcm9tICdleHRlcm5hbEludm9rZXJzJztcblxuY29uc3QgbG9nZ2VyID0gcmVxdWlyZSgnLi91dGlscy9Mb2dnZXInKSgnQ2FyZHMuanMnKTtcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgQ2FyZCBleHRlbmRzIGxuZy5Db21wb25lbnQge1xuICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgIHJldHVybiB7XG4gICAgICB4OiAwLFxuICAgICAgeTogMCxcbiAgICAgIHc6ICh3KSA9PiB3LFxuICAgICAgaDogKGgpID0+IGgsXG4gICAgICBCYWNrZ3JvdW5kOiB7XG4gICAgICAgIHc6ICh3KSA9PiB3LFxuICAgICAgICBoOiAoaCkgPT4gaCxcbiAgICAgIH0sXG4gICAgICBUaXRsZToge1xuICAgICAgICB4OiAxMDAsXG4gICAgICAgIHk6IDUwLFxuICAgICAgICB3OiAodykgPT4gdyAtIDEwMCxcbiAgICAgICAgaDogMTAwLFxuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgZm9udFNpemU6IDQ1LFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICAgIFN1bW1hcnk6IHtcbiAgICAgICAgeDogMTUwLFxuICAgICAgICB5OiAyMDAsXG4gICAgICAgIHc6IDc1MCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAzNSxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBFeGFtcGxlVGV4dDoge1xuICAgICAgICB4OiAxMDAsXG4gICAgICAgIHk6IDMwMCxcbiAgICAgICAgdzogNz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ICAgICAgeTogMCxcbiAgICAgIHc6ICh3KSA9PiB3LFxuICAgICAgaDogKGgpID0+IGgsXG4gICAgICBQbGF5ZXI6IHtcbiAgICAgICAgeDogNTAsXG4gICAgICAgIHk6IDUwLFxuICAgICAgICB3OiA5NjAsXG4gICAgICAgIGg6IDU0MCxcbiAgICAgICAgdHlwZTogTWVkaWFQbGF5ZXIsXG4gICAgICB9LFxuICAgICAgUm93OiB7XG4gICAgICAgIHR5cGU6IFJvdyxcbiAgICAgICAgbmV2ZXJTY3JvbGw6IHRydWUsXG4gICAgICAgIHg6IDUwLFxuICAgICAgICB5OiAxMDgwIC0gMjAwLFxuICAgICAgICB3OiAodykgPT4gdyxcbiAgICAgICAgaDogKGgpID0+IGgsXG4gICAgICAgIGl0ZW1TcGFjaW5nOiA1MCxcbiAgICAgICAgaXRlbXM6IFtcbiAgICAgICAgICB7XG4gICAgICAgICAgICByZWY6ICdQbGF5JyxcbiAgICAgICAgICAgIHR5cGU6IEJ1dHRvbixcbiAgICAgICAgICAgIHRpdGxlOiAnUGxheScsXG4gICAgICAgICAgICB3OiAyMDAsXG4gICAgICAgICAgICBmaXhlZDogdHJ1ZSxcbiAgICAgICAgICAgIGJhY2tncm91bmRUeXBlOiAnc3Ryb2tlJyxcbiAgICAgICAgICAgIG9uRW50ZXI6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKCckcGxheScpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9LFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIHJlZjogJ1RvZ2dsZUluYWN0aXZlJyxcbiAgICAgICAgICAgIHR5cGU6IFRvZ2dsZVdpdGhUZXh0LFxuICAgICAgICAgICAgdGl0bGU6ICdQYXVzZSBvbiBpbmFjdGl2YXRlLiBBbGwgYXBwcyBzaG91bGQuIFR1cm4gdGhpcyBvZmYgdG8gdGVzdCBtaXNiZWhhdmluZyBhcHAnLFxuICAgICAgICAgIH0sX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wgT1BFTl9SUEMpIHtcbiAgICBjb25zdCBleGFtcGxlcyA9IG1ldGhvZE9iai5leGFtcGxlcztcbiAgICBpZiAoKGhhc1RhZyhtZXRob2RPYmosICdwcm9wZXJ0eScpIHx8IGhhc1RhZyhtZXRob2RPYmosICdwcm9wZXJ0eTpyZWFkb25seScpKSAmJiAhaGFzVGFnKG1ldGhvZE9iaiwgJ3Byb3BlcnR5OmltbXV0YWJsZScpKSB7XG4gICAgICBleGFtcGxlcy5wdXNoKHtcbiAgICAgICAgbmFtZTogQ09OU1RBTlRTLlNVQlNDUklCRSArICcgJyArIG1ldGhvZE9iai5uYW1lLFxuICAgICAgICBzY2hlbWE6IHtcbiAgICAgICAgICB0eXBlOiAnbnVtYmVyJyxcbiAgICAgICAgfSxcbiAgICAgICAgcGFyYW1zOiBbXG4gICAgICAgICAge1xuICAgICAgICAgICAgbmFtZTogJ2NhbGxiYWNrJyxcbiAgICAgICAgICAgIHZhbHVlOiAoKSA9PiB7fSxcbiAgICAgICAgICB9LFxuICAgICAgICBdLFxuICAgICAgICByZXN1bHQ6IHtcbiAgICAgICAgICBuYW1lOiAnbGlzdGVuZXJJZCcsXG4gICAgICAgICAgdmFsdWU6ICcxMjMnLFxuICAgICAgICB9LFxuICAgICAgfSk7XG4gICAgfVxuICB9XG5cbiAgYnVpbGRNZW51c0Zyb21PcGVuUnBjKCkge1xuICAgIGNvbnN0IGJ1aWxkTWVudXMgPSBbXTtcbiAgICBjb25zdCBtZXJnZWRTREtzID0gQ09OU1RBTlRTLmRlZmF1bHRTREtzLmNvbmNhdChDT05TVEFOVFMuYWRkaXRpb25hbFNES3MpO1xuICAgIG1lcmdlZFNES3MuZm9yRWFjaChcbiAgICAgIGZ1bmN0aW9uIChzZGtPYmplY3QpIHtcbiAgICAgICAgY29uc3Qgc2RrT2JqZWN0Q29weSA9IHsgLi4uc2RrT2JqZWN0IH07XG4gICAgICAgIHNka09iamVjdENvcHkubmFtZSA9IHNka09iamVjdENvcHkubmFtZ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MubWV0aG9kc1tpXS5uYW1lLnNwbGl0KCcuJylbMF07XG4gICAgICAgICAgICBjb25zdCBtZXRob2QgPSBPUEVOX1JQQy5tZXRob2RzW2ldLm5hbWUuc3BsaXQoJy4nKVsxXTtcbiAgICAgICAgICAgIGNvbnN0IG1ldGhvZE9iaiA9IE9QRU5fUlBDLm1ldGhvZHNbaV07XG5cbiAgICAgICAgICAgIGlmIChtZXRob2RPYmopIHtcbiAgICAgICAgICAgICAgb3ZlcnJpZGVQYXJhbXNGcm9tVGVzdERhdGEobWV0aG9kT2JqKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChJR05PUkVfTU9EVUxFUy5pbmRleE9mKG1vZHVsZSkgPT09IC0xKSB7XG4gICAgICAgICAgICAgIGNvbnN0IG1vZHVsZUNhcCA9IG1vZHVsZS5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIG1vZHVsZS5zbGljZSgxKTtcbiAgICAgICAgICAgICAgY29uc3QgZmluZCA9IG1lbnVzLmZpbHRlcigobSkgPT4gbS50aXRsZSA9PT0gbW9kdWxlQ2FwKTtcbiAgICAgICAgICAgICAgbGV0IG1vZHVsZU1lbnVJdGVtID0gZmluZC5sZW5ndGggPT09IDAgPyBudWxsIDogZmluZFswXTtcbiAgICAgICAgICAgICAgaWYgKG1vZHVsZU1lbnVJdGVtID09IG51bGwpIHtcbiAgICAgICAgICAgICAgICBtb2R1bGVNZW51SXRlbSA9IHtcbiAgICAgICAgICAgICAgICAgIHRpdGxlOiBtb2R1bGVDYXAsXG4gICAgICAgICAgICAgICAgICBtZW51czogW10sXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBtZW51cy5wdXNoKG1vZHVsZU1lbnVJdGVtKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoT1BFTl9SUEMubWV0aG9kc1tpXS5leGFtcGxlcyAmJiBPUEVOX1JQQy5tZXRob2RzW2ldLmV4YW1wbGVzLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHRoaXMuYWRkUHJvcGVydHlFeGFtcGxlcyhtZXRob2RPYmosIE9QRU5fUlBDKTtcbiAgICAgICAgICAgICAgICB0aGlzLmFkZFBvbHltb3JwaGljUHVsbEV4YW1wbGVzKG1ldGhvZE9iaik7XG4gICAgICAgICAgICAgICAgaWYgKE9QRU5fUlBDLm1ldGhvZHNbaV0uZXhhbXBsZXMubGVuZ3RoID4gMSkge1xuICAgICAgICAgICAgICAgICAgY29uc3QgbWV0aG9kTWVudUl0ZW0gPSB7XG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBtZXRob2QsXG4gICAgICAgICAgICAgICAgICAgIG1lbnVzOiBbXSxcbiAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICBtb2R1bGVNZW51SXRlbS5tZW51cy5wdXNoKG1ldGhvZE1lbnVJdGVtKTtcbiAgICAgICAgICAgICAgICAgIGZvciAobGV0IGV4SWR4ID0gMDsgZXhJZHggPCBPUEVOX1JQQy5tZXRob2RzW2ldLmV4YW1wbGVzLmxlbmd0aDsgZXhJZHgrKykge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBuYW1lID0gJyAtICcgKyBPUEVOX1JQQy5tZXRob2RzW2ldLmV4YW1wbGVzW2V4SWR4XS5uYW1lO1xuICAgICAgICAgICAgICAgICAgICBtZXRob2RNZW51SXRlbS5tZW51cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogbWV0aG9kICsgbmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICB2aWV3OiBDYXJkLFxuICAgICAgICAgICAgICAgICAgICAgIHBhcmFtczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2RrOiBzZGssXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6IE9QRU5fUlBDLm1ldGhvZHNbaV0sXG4gICAgICAgICAgICAgICAgICAgICAgICBleGFtcGxlSW5kZXg6IGV4SWR4LFxuICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBtb2R1bGVNZW51SXRlbS5tZW51cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IG1ldGhvZCxcbiAgICAgICAgICAgICAgICAgICAgdmlldzogQ2FyZCxcbiAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgc2RrOiBzZGssXG4gICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBPUEVOX1JQQy5tZXRob2RzW2ldLFxuICAgICAgICAgICAgICAgICAgICAgIGV4YW1wbGVJbmRleDogMCxcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBtb2R1bGVNZW51SXRlbS5tZW51cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgIHRpdGxlOiBtZXRob2QsXG4gICAgICAgICAgICAgICAgICB2aWV3OiBDYXJkLFxuICAgICAgICAgICAgICAgICAgcGFyYW1zOiB7XG4gICAgICAgICAgICAgICAgICAgIHNkazogc2RrLFxuICAgICAgICAgICAgICAgICAgICBtZXRob2Q6IE9QRU5fUlBDLm1ldGhvZHNbaV0sXG4gICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGJ1aWxkTWVudXMucHVzaCh7IHRpdGxlOiBzZGtPYmplY3RDb3B5Lm5hbWUsIG1lbnVzOiBtZW51cyB9KTtcbiAgICAgIH0uYmluZCh0aGlzKVxuICAgICk7XG4gICAgcmV0dXJuIGJ1aWxkTWVudXM7XG4g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Mb3dlckNhc2UoKSAmJiBtZXRob2QubmFtZS5zcGxpdCgnLicpWzFdLnN0YXJ0c1dpdGgoJ3NldCcpKSB7XG4gICAgICByZXR1cm4gaXNScGM7XG4gICAgfSBlbHNlIHtcbiAgICAgIGlmIChtZXRob2QudGFncykge1xuICAgICAgICBtZXRob2QudGFncy5mb3JFYWNoKCh0YWcpID0+IHtcbiAgICAgICAgICBpZiAodGFnLm5hbWUgJiYgdGFnLm5hbWUgPT09ICdycGMtb25seScpIHtcbiAgICAgICAgICAgIGlzUnBjID0gdHJ1ZTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gaXNScGM7XG4gIH1cblxuICBpc1BvbHltb3JwaGljUHVsbE1ldGhvZChtZXRob2QpIHtcbiAgICBsZXQgaXNQb2x5UHVsbCA9IGZhbHNlO1xuICAgIGlmIChtZXRob2QudGFncykge1xuICAgICAgbWV0aG9kLnRhZ3MuZm9yRWFjaCgodGFnKSA9PiB7XG4gICAgICAgIGlmICh0YWcubmFtZSAmJiB0YWcubmFtZSA9PT0gJ3BvbHltb3JwaGljLXB1bGwnKSB7XG4gICAgICAgICAgaXNQb2x5UHVsbCA9IHRydWU7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cbiAgICByZXR1cm4gaXNQb2x5UHVsbDtcbiAgfVxuXG4gIGlzU3Vic2NyaWJlTWV0aG9kKG1ldGhvZCkge1xuICAgIGxldCBpc1N1YnNjcmliZSA9IGZhbHNlO1xuICAgIGlmIChtZXRob2QubmFtZSAmJiBtZXRob2QubmFtZS5zcGxpdCgnICcpWzBdID09PSBDT05TVEFOVFMuU1VCU0NSSUJFKSB7XG4gICAgICBpc1N1YnNjcmliZSA9IHRydWU7XG4gICAgfVxuICAgIHJldHVybiBpc1N1YnNjcmliZTtcbiAgfVxuXG4gIGlzU2V0TWV0aG9kKG1ldGhvZCkge1xuICAgIGxldCBpc1NldCA9IGZhbHNlO1xuIC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gICBoOiAzMDAsXG4gICAgICAgIGNvbG9yOiAweGZmMWYyZjJmLFxuXG4gICAgICAgIFRpdGxlOiB7XG4gICAgICAgICAgeDogMTQwLFxuICAgICAgICAgIHk6IDEwMCxcbiAgICAgICAgICBtb3VudFk6IDAuNSxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiBDT05TVEFOVFMuRVhJVF9NT0RBTF9USVRMRSwgLy8gdGV4dCBkaXNwbGF5ZWQgaW4gbW9kYWxcbiAgICAgICAgICAgIGZvbnRTaXplOiAzMCxcbiAgICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgICAgdGV4dHVyZTogbG5nLlRvb2xzLmdldFNoYWRvd1JlY3QoMTUwLCA0MCwgNCwgMSwgNCksXG4gICAgICAgIEJ1dHRvbnM6IHtcbiAgICAgICAgICB4OiAxMDAsXG4gICAgICAgICAgeTogMTUwLFxuICAgICAgICAgIExlZnRCdXR0b246IHtcbiAgICAgICAgICAgIHR5cGU6IEJ1dHRvblNtYWxsLFxuICAgICAgICAgICAgdGl0bGU6IENPTlNUQU5UUy5ZRVMsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kVHlwZTogJ3N0cm9rZScsXG4gICAgICAgICAgICBidXR0b25UZXh0OiAnTGVmdCcsXG4gICAgICAgICAgICBvbkVudGVyOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycygnJGludm9rZU1ldGhvZCcsIHRydWUpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9LFxuICAgICAgICAgIFJpZ2h0QnV0dG9uOiB7XG4gICAgICAgICAgICB4OiAyNTAsXG4gICAgICAgICAgICB0eXBlOiBCdXR0b25TbWFsbCxcbiAgICAgICAgICAgIHRpdGxlOiBDT05TVEFOVFMuTk8sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kVHlwZTogJ3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gICAgICAgICAgICBpbnRlbnRSZWFkZXIucHJvY2Vzc0ludGVudChtZXNzYWdlKS50aGVuKChyZXNwb25zZVN0cmluZykgPT4ge1xuICAgICAgICAgICAgICBpZiAocmVzcG9uc2VTdHJpbmcpIHtcbiAgICAgICAgICAgICAgICBjbGllbnQucHVibGlzaChyZXNwb25zZVRvcGljLCByZXNwb25zZVN0cmluZywgaGVhZGVycyk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCByZXNwb25zZVRvcGljID0gdGhpcy5nZXRSZXNwb25zZVRvcGljKG1lc3NhZ2UpO1xuICAgICAgICAgICAgY29uc3QgcmVzcG9uc2VTdHJpbmcgPSB7IGNvZGU6ICdGQ0FFcnJvcicsIG1lc3NhZ2U6ICdObyB0YXNrIGluIHJlcXVlc3QnIH07XG4gICAgICAgICAgICBjbGllbnQucHVibGlzaChyZXNwb25zZVRvcGljLCBKU09OLnN0cmluZ2lmeShyZXNwb25zZVN0cmluZyksIGhlYWRlcnMpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgbG9nZ2VyLmVycm9yKCdUYXNrIGV4ZWN1dGlvbiBmYWlsZWQ6ICcgKyBlcnIsICdzdGFydFdlYlNvY2tldCcpO1xuICAgICAgICB9XG4gICAgICB9KTtcbiAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgIGxvZ2dlci5lcnJvcignVW5hYmxlIHRvIGVzdGFibGlzaCBwdWJzdWIgY29ubmVjdGlvbjogJyArIGVyciwgJ3N0YXJ0V2ViU29ja2V0Jyk7XG4gICAgfVxuICB9XG59XG4iLCIvKipcbiAqIENvcHlyaWdodCAyMDIzIENvbWNhc3QgQ2FibGUgQ29tbXVuaWNhdGlvbnMgTWFuYWdlbWVudCwgTExDXG4gKlxuICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlb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AgICAgICBicmVhaztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAodGhpcy5tZXRob2RGaWx0ZXJzLmlzU2V0TWV0aG9kKG1ldGhvZC5leGFtcGxlc1tleGFtcGxlSW5kZXhdKSkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgaWYgKHRoaXMubWV0aG9kRmlsdGVycy5zaG91bGRFeGNsdWRlRXhhbXBsZShtZXRob2QuZXhhbXBsZXNbZXhhbXBsZUluZGV4XSkpIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgbWV0aG9kV2l0aEV4YW1wbGVOYW1lID0gbWV0aG9kT2JqLm5hbWUgKyAnLicgKyBtZXRob2RPYmouZXhhbXBsZXNbZXhhbXBsZUluZGV4XS5uYW1lO1xuICAgICAgICAgICAgICAgIG1ldGhvZFV1aWQgPSB0aGlzLmNyZWF0ZVVVSUQoKTtcbiAgICAgICAgICAgICAgICBleGFtcGxlID0gbWV0aG9kLmV4YW1wbGVzW2V4YW1wbGVJbmRleF07XG4gICAgICAgICAgICAgICAgcGFyYW1WYWx1ZXMgPSBleGFtcGxlLnBhcmFtcy5tYXAoKHApID0+IHAudmFsdWUpO1xuXG4gICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IG51bGw7XG5cbiAgICAgICAgICAgICAgICAvLyBPdmVycmlkaW5nIHRoZSBzY2hlbWEgd2l0aCB0aGUgYmVsb3cgZm9ybWF0XG4gICAgICAgICAgICAgICAgY29uc3Qgc2NoZW1hRm9ybWF0ID0ge1xuICAgICAgICAgICAgICAgICAgdHlwZTogJ29iamVjdCcsXG4gICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzOiB7fSxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGlmIChtZXRob2QuZXh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m9yU2NoZW1hVmFsdWUgOiBzY2hlbWFNYXAuc2NoZW1hO1xuICAgICAgICAgICAgICAgICAgc2NoZW1hRm9ybWF0LnJlcXVpcmVkID0gW3Byb3BlcnR5S2V5XTtcbiAgICAgICAgICAgICAgICAgIHNjaGVtYU1hcC5zY2hlbWEgPSBzY2hlbWFGb3JtYXQ7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGNvbW11bmljYXRpb25Nb2RlID09IENPTlNUQU5UUy5UUkFOU1BPUlQpIHtcbiAgICAgICAgICAgICAgICAgIGNvbnN0IHBhcmFtTmFtZXMgPSBtZXRob2QucGFyYW1zID8gbWV0aG9kLnBhcmFtcy5tYXAoKHApID0+IHAubmFtZSkgOiBbXTtcbiAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGF3YWl0IHRoaXMuYXBpSW52b2tlcihtZXRob2QubmFtZSwgcGFyYW1WYWx1ZXMsIGV4ZWN1dGlvbk1vZGUsIGludm9rZWRTZGssIHBhcmFtTmFtZXMpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICByZXN1bHQgPSBhd2FpdCB0aGlzLmFwaUludm9rZXIobWV0aG9kLm5hbWUsIHBhcmFtVmFsdWVzLCBleGVjdXRpb25Nb2RlLCBpbnZva2VkU2RrKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBjb25zdCByZXNwb25zZSA9IHsgcmVzdWx0OiByZXN1bHQgfTtcbiAgICAgICAgICAgICAgICBsZXQgc2NoZW1hVmFsaWRhdGlvblJlc3VsdEZvckVhY2hFeGFtcGxlID0gdmFsaWRhdG9yLnZhbGlkYXRlKHJlc3BvbnNlLCBzY2hlbWFNYXAuc2NoZW1hKTtcblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLm1ldGhvZEZpbHRlcnMuaXNFdmVudE1ldGhvZChtZXRob2RPYmopKSB7XG4gICAgICAgICAgICAgICAgICBsb2dn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2NoZW1hKTtcbiAgICAgICAgICAgICAgICAgIG9iaiA9IHtcbiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yUmVzcG9uc2UsXG4gICAgICAgICAgICAgICAgICAgIHBhcmFtOiBleGFtcGxlLnBhcmFtcyxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kV2l0aEV4YW1wbGVOYW1lOiBtZXRob2RXaXRoRXhhbXBsZU5hbWUsXG4gICAgICAgICAgICAgICAgICAgIHZhbGlkYXRpb25SZXN1bHQ6IHNjaGVtYVZhbGlkYXRpb25SZXN1bHQsXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZFV1aWQ6IG1ldGhvZFV1aWQsXG4gICAgICAgICAgICAgICAgICAgIHNjaGVtYURhdGE6IHNjaGVtYU1hcC5zY2hlbWEsXG4gICAgICAgICAgICAgICAgICAgIGFwaUV4ZWN1dGlvblN0YXJ0VGltZTogYXBpRXhlY3V0aW9uU3RhcnRUaW1lLFxuICAgICAgICAgICAgICAgICAgICBhcGlFeGVjdXRpb25FbmRUaW1lOiBhcGlFeGVjdXRpb25FbmRUaW1lLFxuICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgb2JqID0ge1xuICAgICAgICAgICAgICAgICAgICBlcnJvcjogZXJyb3JSZXNwb25zZSxcbiAgICAgICAgICAgICAgICAgICAgcGFyYW06IGV4YW1wbGUucGFyYW1zLFxuICAgICAgICAgICAgICAgICAgICBtZXRob2RXaXRoRXhhbXBsZU5hbWU6IG1ldGhvZFdpdGhFeGFtcGxlTmFtZSxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kVXVpZDogbWV0aG9kVXVpZCxcbiAgICAgICAgICAgICAgICAgICAgYXBpRXhlY3V0aW9uU3RhcnRUaW1lOiBhcGlFeGVjdXRpb25TdGFydFRpbWUsXG4gICAgICAgICAgICAgICAgICAgIGFwaUV4ZWN1dGlvbkVuZFRpbWU6I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ICAgeTogMCxcbiAgICAgICAgaDogOTkwLFxuICAgICAgICB3OiAxOTIwIC0gNjAwLFxuICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICB6OiAxMDAwLFxuICAgICAgfSxcbiAgICAgIE5vdGlmaWNhdGlvbjoge1xuICAgICAgICB2aXNpYmxlOiBmYWxzZSxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgY29sb3I6IDB4ZmYwMDAwMDAsIC8vIEJsYWNrIGNvbG9yXG4gICAgICAgIG9wYWNpdHk6IDAuOCwgLy8gT3BhY2l0eSB2YWx1ZSAoMC4wIHRvIDEuMClcbiAgICAgICAgdzogNTAwLFxuICAgICAgICBoOiAyMDAsXG4gICAgICAgIHg6IDEzMzAsXG4gICAgICAgIHk6IDc3NSxcbiAgICAgICAgRXJyb3I6IHtcbiAgICAgICAgICB4OiAyMCxcbiAgICAgICAgICB5OiAxNSxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiBDT05TVEFOVFMuUExBVEZPUk1fRVJST1JfTUVTU0FHRSxcbiAgICAgICAgICAgIGZvbnRTaXplOiAyNixcbiAgICAgICAgICAgIHRleHRDb2xvcjogMHhmZmZmMDAwMCwgLy8gUmVkIGNvbG9yXG4gICAgICAgICAgICB3b3JkV3JhcDogZmFsc2UsXG4gICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiAyODAsXG4gICAgICAgICAgICB0ZXh0QWxpZ246ICdsZWZ0JyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgICBQbGF0Zm9ybToge1xuICAgICAgICAgIHg6IDIwLFxuICAgICAgICAgIHk6IDYwLFxuICAgICAgICAgIHRleHQ6IHtcbiAgICAgICAgICAgIHRleHQ6IHByb2Nlc3MuZW52LlBMQVRGT1JNLFxuICAgICAgICAgICAgZm9udFNpemU6IDE4LFxuICAgICAgICAgICAgdGV4dENvbG9yOiAweGZmZmZmZmZmLCAvLyB3aGl0ZSBjb2xvclxuICAgICAgICAgICAgd29yZFdyYXA6IGZhbHNlLFxuICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogMjgwLFxuICAgICAgICAgICAgdGV4dEFsaWduOiAnbGVmdCcsXG4gICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgICAgVGFyZ2V0OiB7XG4gICAgICAgICAgeDogMTUsXG4gICAgICAgICAgeTogMTEwLFxuICAgICAgICAgIHRleHQ6IHtcbiAgICAgICAgICAgIHRleHQ6IENPTlNUQU5UUy5QTEFURk9STV9UQVJHRVQsXG4gICAgICAgICAgICBmb250U2l6ZTogMTgsXG4gICAgICAgICAgICB0ZXh0Q29sb3I6IDB4ZmZmZmZmZmYsIC8vIHdoaXRlIGNvbG9yXG4gICAgICAgICAgICB3b3JkV3JhcDogZmFsc2UsXG4gICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiAyODAsXG4gICAgICAgICAgICB0ZXh0QWxpZ246ICdsZWZ0JyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICAgIFVwZGF0ZVRleHQ6IHtcbiAgICAgICAgeDogODI1LFxuICAgICAgICB5OiAyNSxcbiAgICAgICAgdzogMTkyMCAtIDcwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAzMCxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmZmZjAwMGYsXG4gICAgICB9LFxuICAgICAgQXBpdGl0bGVUZXh0OiB7XG4gICAgICAgIHg6IDUzMCxcbiAgICAgICAgeTogMTAwLFxuICAgICAgICB3OiAxOTIwIC0gNzAwLFxuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgZm9udFNpemU6IDI3LFxuICAgICAgICB9LFxuICAgICAgICBjb2xvcjogMHhmZjEyMzQ1NixcbiAgICAgIH0sXG4gICAgICBTY2hlbWFWYWxpZGF0aW9uU3RhdGVUZXh0OiB7XG4gICAgICAgIHg6IDUzMCxcbiAgICAgICAgeTogMTUwLFxuICAgICAgICB3OiAxOTIwIC0gNzAwLFxuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgZm9udFNpemU6IDI3LFxuICAgICAgICB9LFxuICAgICAgICBjb2xvcjogMHhmZjEyMzQ1NixcbiAgICAgIH0sXG4gICAgICBNZXNzYWdlOiB7XG4gICAgICAgIHg6IDUzMCxcbiAgICAgICAgeTogMjAwLFxuICAgICAgICB3OiAxOTIwIC0gNzAwLFxuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgZm9udFNpemU6IDI3LFxuICAgICAgICB9LFxuICAgICAgICBjb2xvcjogMHhmZjEyMzQ1NixcbiAgICAgIH0sXG4gICAgICBWYWxpZGF0aW9uRGF0YToge1xuICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICB4OiA1MzAsXG4gICAgICAgIHk6IDI1MCxcbiAgICAgICAgdzogMTkyMCAtIDkwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAyNyxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMjM0NTYsXG4gICAgICB9LFxuICAgICAgRXhlY3V0ZUJ1dHRvbjoge1xuICAgICAgICB0eXBlOiBCdXR0b24sXG4gICAgICAgIHRpdGxlOiAnSW52b2tlJyxcbiAgICAgICAgYmFja2dyb3VuZFR5cGU6ICdzdHJva2UnLFxuICAgICAgICBvbkVudGVyOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKCckUnVuTWV0aG9kJyk7XG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgIH07XG4gIH1cbiAgX2luaXQoKSB7XG4gICAgdGhpcy5fc2V0U3RhdGUoJ0V4ZWN1dGVCdXR0b24nKTtcbiAgICB0aGlzLnRhZygnVXBkYXRlVGV4dCcpLnRleHQgPSBDT05TVEFOVFMuSU5WT0tFX1RFU1RfTUVTU0FHRTtcbiAgfVxuICBzZXQgcGFyYW1zKHBhcmFtcykge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SA9PiB3LFxuICAgICAgICBoOiAoaCkgPT4gaCxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgdHlwZTogbG5nLnNoYWRlcnMuUm91bmRlZFJlY3RhbmdsZSxcbiAgICAgICAgICByYWRpdXM6IDQwLFxuICAgICAgICB9LFxuICAgICAgICBjb2xvcjogMHhmZjExMTExMSxcbiAgICAgIH0sXG4gICAgICBUaXRsZToge1xuICAgICAgICB4OiA1MCxcbiAgICAgICAgeTogNTAsXG4gICAgICAgIHc6ICh3KSA9PiB3IC0gMTAwLFxuICAgICAgICBoOiAxMDAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogNDUsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgQWN0aW9uQnV0dG9uczoge1xuICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgIHg6ICh3KSA9PiAodyAtIDI0MCkgLyAyLFxuICAgICAgICB5OiAoaCkgPT4gaCAtIDEwMCxcbiAgICAgICAgaXRlbVNwYWNpbmc6IDQwLFxuICAgICAgICBpdGVtczogW1xuICAgICAgICAgIHtcbiAgICAgICAgICAgIHJlZjogJ0dyYW50QnV0dG9uJyxcbiAgICAgICAgICAgIG1pbldpZHRoOiAxMDAsXG4gICAgICAgICAgICB0eXBlOiBCdXR0b24sXG4gICAgICAgICAgICB0aXRsZTogJ1llcycsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kVHlwZTogJ3N0cm9rZScsXG4gICAgICAgICAgICBvbkVudGVyUmVsZWFzZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoJyRncmFudCcpO1xuICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoJyRkaXNtaXNzT3ZlcmxheScpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9LFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIHJlZjogJ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ICAgICBPdmVybGF5OiB7XG4gICAgICAgICAgdHlwZTogUGluUHJvbXB0LFxuICAgICAgICAgIHBhcmFtczoge1xuICAgICAgICAgICAgaGVhZGVyOiBjaGFsbGVuZ2UucmVxdWVzdG9yLm5hbWUgKyAnIGlzIHJlcXVlc3RpbmcgdGhhdCB5b3UgZW50ZXIgeW91ciAnICsgY2hhbGxlbmdlLnBpblNwYWNlICsgJyBwaW4uJyxcbiAgICAgICAgICAgIGRldGFpbDogJyAnLFxuICAgICAgICAgICAgbGlzdGVuZXI6IG5ldyAoY2xhc3MgZXh0ZW5kcyBQaW5Qcm9tcHQuUGluUHJvbXB0TGlzdGVuZXIge1xuICAgICAgICAgICAgICBvblBpbkVudGVyZWQocGluKSB7XG4gICAgICAgICAgICAgICAgaWYgKHBpbiA9PT0gQ09OU1RBTlRTLlBJTlNbY2hhbGxlbmdlLnBpblNwYWNlXSkge1xuICAgICAgICAgICAgICAgICAgcmVzcG9uZGVyKHtcbiAgICAgICAgICAgICAgICAgICAgZ3JhbnRlZDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgcmVhc29uOiBQaW5DaGFsbGVuZ2UuUmVzdWx0UmVhc29uLkNPUlJFQ1RfUElOLFxuICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgICAgICAgIHByb21wdC5maXJlQW5jZXN0b3JzKCckZGlzbWlzc092ZXJsYXknKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgc2VsZi5udW1GYWlsdXJlcysrO1xuICAgICAgICAgICAgICAgICAgaWYgKHNlbGYubnVtRmFpbHVyZXMgPj0gQ09OU1RBTlRTLk1BWF9GQUlMVVJFUykge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmxvY2tlZFRpbWUgPSBEYXRlLm5vdygpO1xuICAgICAgICAgICAgICAgICAgICByZXNwb25kZXIoe1xuICAgICAgICAgICAgICAgICAgICAgIGdyYW50ZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogUGluQ2hhbGxlbmdlLlJlc3VsdFJlYXNvbi5FWENFRURFRF9QSU5fRkFJTFVSRVMsXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICBwcm9tcHQuZmlyZUFuY2VzdG9ycygnJGRpc21pc3NPdmVybGF5Jyk7XG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBzaG93IGFnYWluXG4gICAgICAgICAgICAgICAgICAgIHByb21wdC5wYXJhbXMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiAnVGhhdCB3YXMgd3JvbmcsIHRyeSBhZ2Fpbi4nLFxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBvbkRpc21pc3NSZXF1ZXN0ZWQoKSB7XG4gICAgICAgICAgICAgICAgcmVzcG9uZGVyKHtcbiAgICAgICAgICAgICAgICAgIGdyYW50ZWQ6IG51bGwsXG4gICAgICAgICAgICAgICAgICByZWFzb246IFBpbkNoYWxsZW5nZS5SZXN1bHRSZWFzb24uQ0FOQ0VMTEVELFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lcik7XG4gICAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtc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cy5fYXBwLiRkaXNtaXNzT3ZlcmxheSgpO1xuICAgICAgICAgICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZSh7XG4gICAgICAgICAgICAgIGdyYW50ZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICByZWFzb246IFBpbkNoYWxsZW5nZS5SZXN1bHRSZWFzb24uRVhDRUVERURfUElOX0ZBSUxVUkVTLFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICB9XG5cbiAgc2hvd0NoYWxsZW5nZVVpVGVzdChjaGFsbGVuZ2UsIHJlc3BvbmRlcikge1xuICAgIHRoaXMuX2FwcC5vdmVybGF5ZWQgPSB0cnVlO1xuICAgIHRoaXMuX2FwcC50YWcoJ092ZXJsYXlzJykuYWxwaGEgPSAxO1xuICAgIHRoaXMuX2FwcC50YWcoJ092ZXJsYXlzJykucGF0Y2goe1xuICAgICAgT3ZlcmxheToge1xuICAgICAgICB0eXBlOiBQaW5Qcm9tcHQsXG4gICAgICAgIHBhcmFtczoge1xuICAgICAgICAgIGhlYWRlcjogY2hhbGxlbmdlLnJlcXVlc3Rvci5uYW1lICsgJyBpcyByZXF1ZXN0aW5nIHRoYXQgeW91IGVudGVyIHlvdXIgJyArIGNoYWxsZW5nZS5waW5TcGFjZSArICcgcGluLicsXG4gICAgICAgICAgZGV0YWlsOiAnICcsXG4gICAgICAgICAgbGlzdGVuZXI6IG5ldyAoY2xhc3MgZXh0ZW5kcyBQaW5Qcm9tcHQuUGluUHJvbXB0TGlzdGVuZXIge1xuICAgICAgICAgICAgb25QaW5FbnRlcmVkKHBpbikge1xuICAgICAgICAgICAgICBhZnRlclBpbkVudGVyZWQocGluLCByZXNwb25kZXIsIGNoYWxsZW5nZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBvbkRpc21pc3NSZXF1ZXN0ZWQoKSB7XG4gICAgICAgICAgICAgIGRpc21pc3NQaW5PdmVybGF5KHJlc3BvbmRlcik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBvbkxvYWRlZCh2aWV3KSB7XG4gICAgICAgICAgICAgIHByb21wdCA9IHZpZXc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSkoKSxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgfSk7XG4gICAgdGhpcy5fYXBwLl9yZWZvY3VzKCk7XG4gIH1cblxuICBhZnRlclBpbkVudGVyZWQocGluLCByZXNwb25kZXIsIGNoYWxsZW5nZSkge1xuICAgIG5ldyBQcm9taXNlKGFzeW5jIChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIGNvbnN0IHRpbWVyID0gc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgZ3JhbnRlZDogbnVsbCxcbiAgICAgICAgICByZWFzb246IFBpbkNoYWxsZW5nZS5SZXN1bHRSZWFzb24uQ0FOQ0VMTEVELFxuICAgICAgICB9KTtcbiAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgIH0sIDUwMDApO1xuICAgICAgaWYgKHBpbikge1xuICAgICAgICBpZiAocGluID09PSBDT05TVEFOVFMuUElOUy5wdXJjaGFzZSkge1xuICAgICAgICAgIC8vIENoZWNrIHdoZXRoZXIgY2hhbGxlbmdlLnBpbnNwYWNlIGlzIGZldGVjaGluZyB0aGUgcGluICcxMTExJ1xuICAgICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgICBncmFudGVkOiB0cnVlLFxuICAgICAgICAgICAgcmVhc29uOiBQaW5DaGFsbGVuZ2UuUmVzdWx0UmVhc29uLkNPUlJFQ1RfUElOLFxuICAgICAgICAgIH0pO1xuICAgICAgICAgIC8vIHByb21wdC5maXJlQW5jZXN0b3JzKCckZGlzbWlzc092ZXJsYXknKVxuICAgICAgICAgIHRoaXMuX2FwcC4kZGlzbWlzc092ZXJsYXkoKTtcbiAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIp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AgICAgfSxcbiAgICAgIEtleWJvYXJkOiB7XG4gICAgICAgIHR5cGU6IEtleWJvYXJkTnVtYmVycyxcbiAgICAgICAgcmVmOiAnS2V5Ym9hcmQnLFxuICAgICAgICBpbmxpbmU6IHRydWUsXG4gICAgICAgIGRlZmF1bHRGb3JtYXQ6ICdudW1iZXJzJyxcbiAgICAgICAgY2VudGVyS2V5Ym9hcmQ6IHRydWUsXG4gICAgICAgIHg6IChTQ1JFRU4udyAtIDEwICogS0VZQk9BUkRfS0VZX1dJRFRIIC0gOSAqIEtFWUJPQVJEX0tFWV9TUEFDSU5HKSAvIDIsXG4gICAgICAgIHk6IEtFWUJPQVJEX1ksXG4gICAgICB9LFxuICAgICAgSGVhZGVyOiB7XG4gICAgICAgIHg6IDAsXG4gICAgICAgIHk6IFBST01QVF9UT1BfUEFERElORyxcbiAgICAgICAgdzogU0NSRUVOLncsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICAuLi57XG4gICAgICAgICAgICBmb250RmFjZTogJ1hmaW5pdHlCcm93bkJvbGQnLFxuICAgICAgICAgICAgZm9udFNpemU6IDQ4LFxuICAgICAgICAgICAgZm9udFdlaWdodDogNzAwLFxuICAgICAgICAgICAgbGV0dGVyU3BhY2luZzogLTAuNCxcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDY0LFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogJ21pZGRsZScsXG4gICAgICAgICAgfSxcbiAgICAgICAgICB0ZXh0Q29sb3I6ICcjNDA3Njg2MzQ4NycsXG4gICAgICAgICAgdGV4dEFsaWduOiAnY2VudGVyJyxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBEZXRhaWw6IHtcbiAgICAgICAgeDogMCxcbiAgICAgICAgeTogQk9EWV9ZLFxuICAgICAgICB3OiBTQ1JFRU4udyxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIC4uLntcbiAgICAgICAgICAgIGZvbnRGYWNlOiAnWGZpbml0eVN0YW5kYXJkTWVkaXVtJyxcbiAgICAgICAgICAgIGZvbnRTaXplOiAzMixcbiAgICAgICAgICAgIGZvbnRXZWlnaHQ6IDUwMCxcbiAgICAgICAgICAgIGxldHRlclNwYWNpbmc6IDAsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA0MCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246ICdtaWRkbGUnLFxuICAgICAgICAgIH0sXG4gICAgICAgICAgdGV4dENvbG9yOiAnIzM0MzkzMjkyNzknLFxuICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgUGluRGlzcGxheToge1xuICAgICAgICB4OiAwLFxuICAgICAgICB5OiBQSU5fRElTUExBWV9ZLFxuICAgICAgICB3OiBTQ1JFRU4udyxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIC4uLntcbiAgICAgICAgICAgIGZvbnRGYWNlOiAnWGZpbml0eUJyb3duQm9sZCcsXG4gICAgICAgICAgICBmb250U2l6ZTogNTYsXG4gICAgICAgICAgICBmb250V2VpZ2h0OiA3MDAsXG4gICAgICAgICAgICBsZXR0ZXJTcGFjaW5nOiAtMC40LFxuICAgICAgICAgICAgbGluZUhlaWdodDogNzIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiAnbWlkZGxlJyxcbiAgICAgICAgICB9LFxuICAgICAgICAgIGZvbnRTaXplOiA3MixcbiAgICAgICAgICB0ZXh0Q29sb3I6ICcjNDA3Njg2MzQ4NycsXG4gICAgICAgICAgdGV4dEFsaWduOiAnY2VudGVyJyxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgfTtcbiAgfVxuXG4gIF9jb25zdHJ1Y3QoKSB7XG4gICAgdGhpcy5waW4gPSBbXTtcbiAgICB0aGlzLnNvZnRLZXlQZW5kaW5nID0gbnVsbDtcbiAgfVxuXG4gIF9nZXRGb2N1c2VkKCkge1xuICAgIHJldHVybiB0aGlzLnRh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VFMuQ09SRS50b0xvd2VyQ2FzZSgpLCAnQXV0aGVudGljYXRpb24ucm9vdCcsIFtdKSk7XG4gICAgICAgIGlmIChyZXN1bHQgJiYgcmVzdWx0LnZhbHVlICYmICFlcnIpIHtcbiAgICAgICAgICBjb25zdCBidWZmZXJPYmogPSBCdWZmZXIuZnJvbShyZXN1bHQudmFsdWUsICdiYXNlNjQnKTtcbiAgICAgICAgICBjb25zdCB4bWxEYXRhID0gYnVmZmVyT2JqLnRvU3RyaW5nKCd1dGY4Jyk7XG4gICAgICAgICAgYXdhaXQgbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgICAgICAgcGFyc2VyLnBhcnNlU3RyaW5nKHhtbERhdGEsIGZ1bmN0aW9uIChlcnIsIHJlc3VsdCkge1xuICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcGFyc2luZ1N1Y2Nlc3NmdWwgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICByZXNvbHZlKCk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVzID0gcmVzdWx0WyduczI6eGNhbC1hdXRoLW1lc3NhZ2UnXVsnYXR0cmlidXRlJ107XG4gICAgICAgICAgICAgICAgcGFyc2luZ1N1Y2Nlc3NmdWwgPSB0cnVlO1xuICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVzSXRlbSBvZiByZXMpIHtcbiAgICAgICAgICAgICAgICAgIGlmIChyZXNJdGVtLiQua2V5ID09PSAnZGV2aWNlOmNjcFBraTplc3RiTWFjJykge1xuICAgICAgICAgICAgICAgICAgICBsb2dnZXIuaW5mbyhyZXNJdGVtLl8sICdwdXNoUmVwb3J0VG9TMycpO1xuICAgICAgICAgICAgICAgICAgICBtYWNBZGRyZXNzID0gcmVzSXRlbS5fO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgIC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yYW1zJyk7XG4gIH1cbn1cblxuZXhwb3J0IHtcbiAgaGFuZGxlQXN5bmNGdW5jdGlvbixcbiAgY2hlY2tNb2NrT1NSZXN0SW50ZXJmYWNlLFxuICBUUlVFX1ZBTFVFUyxcbiAgZGVyZWZlcmVuY2VPcGVuUlBDLFxuICBnZXRzY2hlbWFWYWxpZGF0aW9uRG9uZSxcbiAgcHVzaFJlcG9ydFRvUzMsXG4gIHRlc3REYXRhSGFuZGxlcixcbiAgY2Vuc29yRGF0YSxcbiAgZmlsdGVyRXhhbXBsZXMsXG4gIGVycm9yU2NoZW1hQ2hlY2ssXG4gIHJlbW92ZVNldEluTWV0aG9kTmFtZSxcbiAgZ2V0Q3VycmVudEFwcElELFxuICBnZXRNZXRob2RFeGNsdWRlZExpc3RCYXNlZE9uTW9kZSxcbiAgZmluZFR5cGVJbk9uZU9GLFxuICBvdmVycmlkZVBhcmFtc0Zyb21UZXN0RGF0YSxcbiAgcGFyc2VYQUNULFxufTtcbiIsIi8qIChpZ25vcmVkKSAqLyIsIi8qIChpZ25vcmVkKSAqLyIsIi8qIChpZ25vcmVkKSAqLyIsIi8qIChpZ25vcmVkKSAqLyIsIi8qIChpZ25vcmVkKSAqLyIsIi8qIChpZ25vcmVkKSAqLyJdLCJzb3VyY2VSb290IjoiIn0=
\ No newline at end of file
diff --git a/PR-224/startupScripts.bundle.e860f596546eed09b889.js b/PR-224/startupScripts.bundle.c86cd34c38e579a4f94e.js
similarity index 99%
rename from PR-224/startupScripts.bundle.e860f596546eed09b889.js
rename to PR-224/startupScripts.bundle.c86cd34c38e579a4f94e.js
index b13e9c46..be595e93 100644
--- a/PR-224/startupScripts.bundle.e860f596546eed09b889.js
+++ b/PR-224/startupScripts.bundle.c86cd34c38e579a4f94e.js
@@ -170,4 +170,4 @@ module.exports = __webpack_require__(/*! ./plugins/startupScripts/index.js */"./
/***/ })
/******/ });
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3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