diff --git a/PR-235/COMMITHASH b/PR-235/COMMITHASH
index 56ca725d..25248d11 100644
--- a/PR-235/COMMITHASH
+++ b/PR-235/COMMITHASH
@@ -1 +1 @@
-a75095477f578b3d071d58cc8dc9c56f76054bf2
\ No newline at end of file
+9702a4135dbbe4f9feadbadadd5844caf98b4aed
\ No newline at end of file
diff --git a/PR-235/VERSION b/PR-235/VERSION
index 4186eaf9..05de1077 100644
--- a/PR-235/VERSION
+++ b/PR-235/VERSION
@@ -1 +1 @@
-a750954
\ No newline at end of file
+9702a41
\ No newline at end of file
diff --git a/PR-235/index.html b/PR-235/index.html
index a64aa14a..700dff8b 100644
--- a/PR-235/index.html
+++ b/PR-235/index.html
@@ -8,7 +8,7 @@
1.4.1 - Firebolt Certification App - version 1.4.1
-
+
0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsU0FBUztBQUNUO0FBQ0E7QUFDQSxTQUFTO0FBQ1Q7QUFDQTtBQUNBLFNBQVM7QUFDVDtBQUNBO0FBQ0EsU0FBUztBQUNUO0FBQ0E7QUFDQSxTQUFTO0FBQ1Q7QUFDQTtBQUNBLFNBQVM7QUFDVDtBQUNBO0FBQ0EsU0FBUztBQUNUO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxhQUFhO0FBQ2IsU0FBUztBQUNUO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxhQUFhO0FBQ2IsU0FBUztBQUNUO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSxTQUFTO0FBQ1Q7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBL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Aob2JqW2tleV0gIT09IGRlcmVmZXJlbmNlZC52YWx1ZSkge1xuICAgICAgICAgICAgICBvYmpba2V5XSA9IGRlcmVmZXJlbmNlZC52YWx1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBpZiAoIXBhcmVudHMuaGFzKHZhbHVlKSkge1xuICAgICAgICAgICAgICBkZXJlZmVyZW5jZWQgPSBjcmF3bCh2YWx1ZSwga2V5UGF0aCwga2V5UGF0aEZyb21Sb290LCBwYXJlbnRzLCBwcm9jZXNzZWRPYmplY3RzLCBkZXJlZmVyZW5jZWRDYWNoZSwgJHJlZnMsIG9wdGlvbnMpO1xuICAgICAgICAgICAgICBjaXJjdWxhciA9IGRlcmVmZXJlbmNlZC5jaXJjdWxhcjtcbiAgICAgICAgICAgICAgLy8gQXZvaWQgcG9pbnRsZXNzIG11dGF0aW9uczsgYnJlYWtzIGZyb3plbiBvYmplY3RzIHRvIG5vIHByb2ZpdFxuICAgICAgICAgICAgICBpZiAob2JqW2tleV0gIT09IGRlcmVmZXJlbmNlZC52YWx1ZSkge1xuICAgICAgICAgICAgICAgIG9ialtrZXldID0gZGVyZWZlcmVuY2VkLnZhbHVlO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgY2lyY3VsYXIgPSBmb3VuZENpcmN1bGFyUmVmZXJlbmNlKGtleVBhdGgsICRyZWZzLCBvcHRpb25zKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG5cbiAgICAgICAgICAvLyBTZXQgdGhlIFwiaXNDaXJjdWxhclwiIGZsYWcgaWYgdGhpcyBvciBhbnkgb3RoZXIgcHJvcGVydHkgaXMgY2lyY3VsYXJcbiAgICAgICAgICByZXN1bHQuY2lyY3VsYXIgPSByZXN1bHQuY2lyY3VsYXIgfHwgY2lyY3VsYXI7XG4gICAgICAgIH1cbiAgICAg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IAnLCAnzIEnLCAnzIsnLCAnzI8nLFxuICAgICAgJ8ySJywgJ8yTJywgJ8yUJywgJ8y9JyxcbiAgICAgICfMiScsICfNoycsICfNpCcsICfNpScsXG4gICAgICAnzaYnLCAnzacnLCAnzagnLCAnzaknLFxuICAgICAgJ82qJywgJ82rJywgJ82sJywgJ82tJyxcbiAgICAgICfNricsICfNrycsICfMvicsICfNmycsXG4gICAgICAnzYYnLCAnzJonLFxuICAgIF0sXG4gICAgJ2Rvd24nOiBbXG4gICAgICAnzJYnLCAnzJcnLCAnzJgnLCAnzJknLFxuICAgICAgJ8ycJywgJ8ydJywgJ8yeJywgJ8yfJyxcbiAgICAgICfMoCcsICfMpCcsICfMpScsICfMpicsXG4gICAgICAnzKknLCAnzKonLCAnzKsnLCAnzKwnLFxuICAgICAgJ8ytJywgJ8yuJywgJ8yvJywgJ8ywJyxcbiAgICAgICfMsScsICfMsicsICfMsycsICfMuScsXG4gICAgICAnzLonLCAnzLsnLCAnzLwnLCAnzYUnLFxuICAgICAgJ82HJywgJ82IJywgJ82JJywgJ82NJyxcbiAgICAgICfNjicsICfNkycsICfNlCcsICfNlScsXG4gICAgICAnzZYnLCAnzZknLCAnzZonLCAnzKMnLFxuICAgIF0sXG4gICAgJ21pZCc6IFtcbiAgICAgICfMlScsICfMmycsICfMgCcsICfMgScsXG4gICAgICAnzZgnLCAnzKEnLCAnzKInLCAnzKcnLFxuICAgICAgJ8yoJywgJ8y0JywgJ8y1JywgJ8y2JyxcbiAgICAgICfNnCcsICfNnScsICfNnicsXG4gICAgICAnzZ8nLCAnzaAnLCAnzaInLCAnzLgnLFxuICAgICAgJ8y3JywgJ82hJywgJyDSiScsXG4gICAgXSxcbiAgfTtcbiAgdmFyIGFsbCA9IFtdLmNvbmNhdChzb3VsLnVwLCBzb3VsLmRvd24sIHNvdWwubWlkKTtcblxuICBmdW5jdGlvbiByYW5kb21OdW1iZXIocmFuZ2UpIHtcbiAgICB2YXIgciA9IE1hdGguZmxvb3Io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cbiAgICAgIGNvdW50cyA9IHsndXAnOiAwLCAnZG93bic6IDAsICdtaWQnOiAwfTtcbiAgICAgIHN3aXRjaCAob3B0aW9ucy5zaXplKSB7XG4gICAgICAgIGNhc2UgJ21pbmknOlxuICAgICAgICAgIGNvdW50cy51cCA9IHJhbmRvbU51bWJlcig4KTtcbiAgICAgICAgICBjb3VudHMubWlkID0gcmFuZG9tTnVtYmVyKDIpO1xuICAgICAgICAgIGNvdW50cy5kb3duID0gcmFuZG9tTnVtYmVyKDgpO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlICdtYXhpJzpcbiAgICAgICAgICBjb3VudHMudXAgPSByYW5kb21OdW1iZXIoMTYpICsgMztcbiAgICAgICAgICBjb3VudHMubWlkID0gcmFuZG9tTnVtYmVyKDQpICsgMTtcbiAgICAgICAgICBjb3VudHMuZG93biA9IHJhbmRvbU51bWJlcig2NCkgKyAzO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIGNvdW50cy51cCA9IHJhbmRvbU51bWJlcig4KSArIDE7XG4gICAgICAgICAgY291bnRzLm1pZCA9IHJhbmRvbU51bWJlcig2KSAvIDI7XG4gICAgICAgICAgY291bnRzLmRvd24gPSByYW5kb21OdW1iZXIoOCkgKyAxO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgfVxuXG4gICAgICB2YXIgYXJyID0gWyd1cCcsICdtaWQnLCAnZG93biddO1xuICAgICAgZm9yICh2YXIgZCBpbiBhcnIpIHtcbiAgICAgICAgdmFyIGluZGV4ID0gYXJyW2RdO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8PSBjb3VudHNbaW5kZXhdOyBpKyspIHtcbiAgICAgICAgICBpZiAob3B0aW9uc1tpbmRleF0pIHtcbiAgICAgICAgICAgIHJlc3VsdCA9IHJlc3VsdCArIHNvdWxbaW5kZXhdW3JhbmRvbU51bWJlcihzb3VsW2luZGV4XS5sZW5ndGgpXTtcbiA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RlbmVySWQpKSA+PSAwKSB7XG4gICAgICAgIG9uY2Vycy5zcGxpY2Uob25jZXJzLmluZGV4T2YocGFyc2VJbnQobGlzdGVuZXJJZCkpLCAxKVxuICAgICAgICBkZWxldGUgY2JzW2xpc3RlbmVySWRdXG4gICAgICB9XG4gICAgICBjYWxsYmFjay5hcHBseShudWxsLCBhcmdzKVxuICAgIH0pXG59XG5cbmNvbnN0IGRvTGlzdGVuID0gZnVuY3Rpb24gKFxuICBtb2R1bGUsXG4gIGV2ZW50LFxuICBjYWxsYmFjayxcbiAgY29udGV4dCxcbiAgb25jZSxcbiAgaW50ZXJuYWwgPSBmYWxzZSxcbikge1xuICBpbml0KClcblxuICBpZiAodHlwZW9mIGNhbGxiYWNrICE9PSAnZnVuY3Rpb24nKSB7XG4gICAgcmV0dXJuIFByb21pc2UucmVqZWN0KCdObyB2YWxpZCBjYWxsYmFjayBmdW5jdGlvbiBwcm92aWRlZC4nKVxuICB9IGVsc2Uge1xuICAgIGlmIChtb2R1bGUgPT09ICcqJykge1xuICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KCdObyB2YWxpZCBtb2R1bGUgbmFtZSBwcm92aWRlZCcpXG4gICAgfVxuXG4gICAgY29uc3Qgd2lsZGNhcmQgPSBldmVudCA9PT0gJyonXG4gICAgY29uc3QgZXZlbnRzID0gd2lsZGNhcmQgPyB2YWxpZEV2ZW50c1ttb2R1bGVdIDogW2V2ZW50XSAvLyBleHBsb2RlcyB3aWxkY2FyZHMgaW50byBhbiBhcnJheVxuICAgIGNvbnN0IHByb21pc2VzID0gW11cbiAgICBjb25zdCBoYXNDb250ZXh0ID0gT2JqZWN0LnZhbHVlcyhjb250ZXh0KS5sZW5ndGggPiAwXG4gICAgY29uc3QgY29udGV4dEtleSA9IE9iamVjdC5rZXlzKGNvbnRleHQpXG4gICAgICAuc29ydCgpXG4gICAgICAubWFwKChrZXkpID0+IGtleSArICc9JyArIEpTT04uc3RyaW5naWZ5KGNvbnRleHRba2V5XSkpXG4gICAgICAuam9pbignJicpXG5cbiAgICBsaXN0ZW5lcklkKytcblxuICAgIGlmIChvbmNlKSB7XG4gICAgICBvbmNlcnMucHVzaChsaXN0ZW5lcklkKVxuICAgIH1cblxuICAgIGV2ZW50cy5mb3JFYWNoKChldmVudCkgPT4ge1xuICAgICAgY29uc3Qga2V5ID0gbW9kdWxlICsgJy4nICsgZXZlbnQgKyAoaGFzQ29udGV4dCA/IGAuJHtjb250ZXh0S2V5fWAgOiAnJylcblxuICAgICAgaWYgKE9iamVjdC52YWx1ZXMobGlzdGVuZXJzLmdldChrZXkpKS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgY29uc3QgYXJncyA9IE9iamVjdC5hc3NpZ24oeyBsaXN0ZW46IHRydWUgfSwgY29udGV4dClcbiAgICAgICAgY29uc3QgeyBpZCwgcHJvbWlzZSB9ID0gVHJhbnNwb3J0Lmxpc3RlbihcbiAgICAgICAgICBtb2R1bGUsXG4gICAgICAgICAgJ29uJyArIGV2ZW50WzBdLnRvVXBwZXJDYXNlKCkgKyBldmVudC5zdWJzdHJpbmcoMSksXG4gICAgICAgICAgYXJncyxcbiAgICAgICAgKVxuICAgICAgICBrZXlzW2lkXSA9IGtleVxuICAgICAgICBwcm9taXNlcy5wdXNoKHByb21pc2UpXG4gICAgICB9XG5cbiAgICAgIGNvbnN0IHNldHRlciA9IGludGVybmFsID8gbGlzdGVuZXJzLnNldEludGVybmFsIDogbGlzdGVuZXJzLnNldFxuXG4gICAgICBpZiAod2lsZGNhcmQpIHtcbiAgICAgICAgc2V0dGVyKGtleSwgJycgKyBsaXN0ZW5lcklkLCAodmFsdWUpID0+IGNhbGxiYWNrKGV2ZW50LCB2YWx1ZSkpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzZXR0ZXIoa2V5LCAnJyArIGxpc3RlbmVySWQsIGNhbGxiYWNrKVxuICAgICAgfVxuICAgIH0pXG5cbiAgICBsZXQgcmVzb2x2ZSwgcmVqZWN0XG4gICAgbGV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G9Mb3dlckNhc2UoKSArXG4gICAgICAgICAgICBtZXRob2Quc3Vic3RyKDMpXG4gICAgICAgICkge1xuICAgICAgICAgIGRlbGV0ZSBldmVudE1hcFtrZXldXG4gICAgICAgIH1cbiAgICAgIH0pXG4gICAgfVxuICB9XG5cbiAgaWYgKG1vY2spIGhhbmRsZShqc29uKVxuICBlbHNlIHBlbmRpbmcucHVzaChqc29uKVxufVxuXG5mdW5jdGlvbiBoYW5kbGUoanNvbikge1xuICBsZXQgcmVzdWx0XG4gIHRyeSB7XG4gICAgcmVzdWx0ID0gZ2V0UmVzdWx0KGpzb24ubWV0aG9kLCBqc29uLnBhcmFtcylcbiAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICBzZXRUaW1lb3V0KCgpID0+XG4gICAgICBjYWxsYmFjayhcbiAgICAgICAgSlNPTi5zdHJpbmdpZnkoe1xuICAgICAgICAgIGpzb25ycGM6ICcyLjAnLFxuICAgICAgICAgIGVycm9yOiB7XG4gICAgICAgICAgICBjb2RlOiAtMzI2MDIsXG4gICAgICAgICAgICBtZXNzYWdlOlxuICAgICAgICAgICAgICAnSW52YWxpZCBwYXJhbXMgKHRoaXMgaXMgYSBtb2NrIGVycm9yIGZyb20gdGhlIG1vY2sgdHJhbnNwb3J0IGxheWVyKScsXG4gICAgICAgICAgfSxcbiAgICAgICAgICBpZDoganNvbi5pZCxcbiAgICAgICAgfSksXG4gICAgICApLFxuICAgIClcbiAgfVxuXG4gIHNldFRpbWVvdXQoKCkgPT5cbiAgICBjYWxsYmFjayhcbiAgICAgIEpTT04uc3RyaW5naWZ5KHtcbiAgICAgICAganNvbnJwYzogJzIuMCcsXG4gICAgICAgIHJlc3VsdDogcmVzdWx0LFxuICAgICAgICBpZDoganNvbi5pZCxcbiAgICAgIH0pLFxuICAgICksXG4gIClcbn1cblxuZnVuY3Rpb24gcmVjZWl2ZShfY2FsbGJhY2spIHtcbiAgY2FsbGJhY2sgPSBfY2FsbGJhY2tcblxuICBpZiAodGVzd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ICAgICAgIGNvbnN0IGFyZ3MgPSBPYmplY3QuYXNzaWduKHsgbGlzdGVuOiB0cnVlIH0sIGNvbnRleHQpXG4gICAgICAgIGNvbnN0IHsgaWQsIHByb21pc2UgfSA9IFRyYW5zcG9ydC5saXN0ZW4oXG4gICAgICAgICAgbW9kdWxlLFxuICAgICAgICAgICdvbicgKyBldmVudFswXS50b1VwcGVyQ2FzZSgpICsgZXZlbnQuc3Vic3RyaW5nKDEpLFxuICAgICAgICAgIGFyZ3MsXG4gICAgICAgIClcbiAgICAgICAga2V5c1tpZF0gPSBrZXlcbiAgICAgICAgcHJvbWlzZXMucHVzaChwcm9taXNlKVxuICAgICAgfVxuXG4gICAgICBjb25zdCBzZXR0ZXIgPSBpbnRlcm5hbCA/IGxpc3RlbmVycy5zZXRJbnRlcm5hbCA6IGxpc3RlbmVycy5zZXRcblxuICAgICAgaWYgKHdpbGRjYXJkKSB7XG4gICAgICAgIHNldHRlcihrZXksICcnICsgbGlzdGVuZXJJZCwgKHZhbHVlKSA9PiBjYWxsYmFjayhldmVudCwgdmFsdWUpKVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgc2V0dGVyKGtleSwgJycgKyBsaXN0ZW5lcklkLCBjYWxsYmFjaylcbiAgICAgIH1cbiAgICB9KVxuXG4gICAgbGV0IHJlc29sdmUsIHJlamVjdFxuICAgIGxldCBwID0gbmV3IFByb21pc2UoKHJlcywgcmVqKSA9PiB7XG4gICAgICByZXNvbHZlID0gcmVzXG4gICAgICByZWplY3QgPSByZWpcbiAgICB9KVxuXG4gICAgaWYgKHByb21pc2VzLmxlbmd0aCkge1xuICAgICAgUHJvbWlzZS5hbGwocHJvbWlzZXMpXG4gICAgICAgIC50aGVuKChyZXNwb25zZXMpID0+IHtcbiAgICAgICAgICByZXNvbHZlKGxpc3RlbmVySWQpXG4gICAgICAgIH0pXG4gICAgICAgIC5jYXRjaCgoZXJyb3IpID0+IHtcbiAgICAgICAgICAvLyBQcm9taXNlLmFsbCByZWplY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gICAgcHJvdmlkZXJDYWxsQXJncy5wdXNoKHJlcXVlc3QucGFyYW1ldGVycylcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwcm92aWRlckNhbGxBcmdzLnB1c2gobnVsbClcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHNlc3Npb24gPSB7XG4gICAgICAgICAgY29ycmVsYXRpb25JZDogKCkgPT4ge1xuICAgICAgICAgICAgcmV0dXJuIHJlcXVlc3QuY29ycmVsYXRpb25JZFxuICAgICAgICAgIH0sXG4gICAgICAgIH1cblxuICAgICAgICAvLyBvbmx5IHBhc3MgaW4gdGhlIGZvY3VzIGhhbmRzaGFrZSBpZiBuZWVkZWRcbiAgICAgICAgaWYgKGltZXRob2QuZm9jdXMpIHtcbiAgICAgICAgICBzZXNzaW9uLmZvY3VzID0gKCkgPT4ge1xuICAgICAgICAgICAgVHJhbnNwb3J0LnNlbmQobW9kdWxlLCBgJHttZXRob2R9Rm9jdXNgLCB7XG4gICAgICAgICAgICAgIGNvcnJlbGF0aW9uSWQ6IHJlcXVlc3QuY29ycmVsYXRpb25JZCxcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcHJvdmlkZXJDYWxsQXJncy5wdXNoKHNlc3Npb24pXG5cbiAgICAgICAgY29uc3QgcmVzcG9uc2UgPSB7XG4gICAgICAgICAgY29ycmVsYXRpb25JZDogcmVxdWVzdC5jb3JyZWxhdGlvbklkLFxuICAgICAgICB9XG4gICAgICAgIGxldCBoYW5kbGVFcnJvciA9IChlcnJvcikgPT4ge1xuICAgICAgICAgIHJlc3BvbnNlLmVycm9yID0ge1xuICAgICAgICAgICAgY29kZTogZXJyb3IuY29kZSB8fCAxMDAwLCAvLyB0b2RvOiBzaG91bGQgYmUgc29tZSByZXNlcnZlZCBjb2RlIGZvciBcIlVua25vd25cIlxuICAgICAgICAgICAgbWVzc2FnZTpcbiAgICAgICAgICAgICAgZXJyb3IubWVzc2FnZSB8fFxuICAgICAgICAgICAgICBgQW4gZXJyb3Igb2NjdXJlZCB3aGlsZSBjYWxsaW5nIHByb3ZpZGVkICR7bWV0aG9kfSBtZXRob2QuYCxcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAoZXJyb3IuZGF0YSkge1xuICAgICAgICAgICAgcmVzcG9uc2UuZXJyb3IuZGF0YSA9IEpTT04ucGFyc2UoSlNPTi5zdHJpbmdpZnkoZXJyb3IuZGF0YSkpXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgVHJhbnNwb3J0LnNlbmQobW9kdWxlLCBgJHttZXRob2R9RXJyb3JgLCByZXNwb25zZSlcbiAgICAgICAgfVxuXG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgY29uc3QgcmVzdWx0ID0gcHJvdmlkZXJbbWV0aG9kXS5hcHBseShwcm92aWRlciwgcHJvdmlkZXJDYWxsQXJncylcblxuICAgICAgICAgIGlmICghKHJlc3VsdCBpbnN0YW5jZW9mIFByb21pc2UpKSB7XG4gICAgICAgICAgICB0aHJvdyBgUHJvdmlkZXIgbWV0aG9kICR7bWV0aG9kfSBkaWQgbm90IHJldHVybiBhIFByb21pc2UuYFxuICAgICAgICAgIH1cblxuICAgICAgICAgIHJlc3VsdFxuICAgICAgICAgICAgLnRoZW4oKHJlc3VsdCkgPT4ge1xuICAgICAgICAgICAgICBpZiAoaW1ldGhvZC5yZXNwb25zZSkge1xuICAgICAgICAgICAgICAgIC8vIHZvaWQgcmVzdWx0cyBzaG91bGQgYmUgbnVsbCBpbiB0aGUgSlNPTlJQQyBtZXNzYWdlXG4gICAgICAgICAgICAgICAgcmVzcG9uc2UucmVzdWx0ID0gcmVzdWx0ID09IG51bGwgPyBudWxsIDogcmVzdWx0XG4gICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICBUcmFuc3BvcnQuc2VuZChtb2R1bGUsIGAke21ldGhvZH1SZXNwb25zZWAsIHJlc3BvbnNlKVxuICAgICAgICAgICAgfSlcbiAg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HJhbnNwb3J0LnNlbmQoJ0Rpc2NvdmVyeScsICdlbnRpdHlJbmZvJywgcGFyYW1zKS5jYXRjaCgoZXJyb3IpID0+IHtcbiAgICAgICAgICAgICAgY29uc3QgbXNnID1cbiAgICAgICAgICAgICAgICB0eXBlb2YgZXJyb3IgPT09ICdzdHJpbmcnXG4gICAgICAgICAgICAgICAgICA/IGVycm9yXG4gICAgICAgICAgICAgICAgICA6IGVycm9yLm1lc3NhZ2UgfHwgJ1Vua25vd24gRXJyb3InXG4gICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXG4gICAgICAgICAgICAgICAgYEZhaWxlZCB0byBzZW5kIGVudGl0eUluZm8gcHVsbCByZXNwb25zZSB0aHJvdWdoIFRyYW5zcG9ydCBMYXllcjogJHttc2d9YCxcbiAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICB9KVxuICAgICAgICAgIC5jYXRjaCgoZXJyb3IpID0+IHtcbiAgICAgICAgICAgIGNvbnN0IG1zZyA9XG4gICAgICAgICAgICAgIHR5cGVvZiBlcnJvciA9PT0gJ3N0cmluZydcbiAgICAgICAgICAgICAgICA/IGVycm9yXG4gICAgICAgICAgICAgICAgOiBlcnJvci5tZXNzYWdlIHx8ICdVbmtub3duIEVycm9yJ1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcihgQXBwICdlbnRpdHlJbmZvJyBjYWxsYmFjayBmYWlsZWQ6ICR7bXNnfWApXG4gICAgICAgICAgfSlcbiAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgIGNvbnN0IG1zZyA9XG4gICAgICAgICAgdHlwZW9mIGVycm9yID09PSAnc3RyaW5nJyA/IGVycm9yIDogZXJyb3IubWVzc2FnZSB8fCAnVW5rbm93biBFcnJvcidcbiAgICAgICAgY29uc29sZS5lcnJvcihgQXBwICdlbnRpdHlJbmZvJyBjYWxsYmFjayBmYWlsZWQ6ICR7bXNnfWApXG4gICAgICB9XG4gICAgfSlcbi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5zcG9ydC5zZW5kKCdEaXNjb3ZlcnknLCAncHVyY2hhc2VkQ29udGVudCcsIHBhcmFtcykuY2F0Y2goXG4gICAgICAgICAgICAgIChlcnJvcikgPT4ge1xuICAgICAgICAgICAgICAgIGNvbnN0IG1zZyA9XG4gICAgICAgICAgICAgICAgICB0eXBlb2YgZXJyb3IgPT09ICdzdHJpbmcnXG4gICAgICAgICAgICAgICAgICAgID8gZXJyb3JcbiAgICAgICAgICAgICAgICAgICAgOiBlcnJvci5tZXNzYWdlIHx8ICdVbmtub3duIEVycm9yJ1xuICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXG4gICAgICAgICAgICAgICAgICBgRmFpbGVkIHRvIHNlbmQgcHVyY2hhc2VkQ29udGVudCBwdWxsIHJlc3BvbnNlIHRocm91Z2ggVHJhbnNwb3J0IExheWVyOiAke21zZ31gLFxuICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIClcbiAgICAgICAgICB9KVxuICAgICAgICAgIC5jYXRjaCgoZXJyb3IpID0+IHtcbiAgICAgICAgICAgIGNvbnN0IG1zZyA9XG4gICAgICAgICAgICAgIHR5cGVvZiBlcnJvciA9PT0gJ3N0cmluZydcbiAgICAgICAgICAgICAgICA/IGVycm9yXG4gICAgICAgICAgICAgICAgOiBlcnJvci5tZXNzYWdlIHx8ICdVbmtub3duIEVycm9yJ1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcihgQXBwICdwdXJjaGFzZWRDb250ZW50JyBjYWxsYmFjayBmYWlsZWQ6ICR7bXNnfWApXG4gICAgICAgICAgfSlcbiAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgIGNvbnN0IG1zZyA9XG4gICAgICAgICAgdHlwZW9mIGVycm9yID09PSAnc3RyaW5nJyA/IGVycm9yIDogZXJyb3IubWVzc2FnZSB8fCAnVW5rbm93biBFcnJvcidcbiAgICAgICAgY29uc29sZS5lcnJvcihgQXBwICdwdXJja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AodHlwZW9mIGNhbGxiYWNrICE9PSAnZnVuY3Rpb24nKSB7XG4gICAgcmV0dXJuIFByb21pc2UucmVqZWN0KCdObyB2YWxpZCBjYWxsYmFjayBmdW5jdGlvbiBwcm92aWRlZC4nKVxuICB9IGVsc2Uge1xuICAgIGlmIChtb2R1bGUgPT09ICcqJykge1xuICAgICAgcmV0dXJuIFByb21pc2UucmVqZWN0KCdObyB2YWxpZCBtb2R1bGUgbmFtZSBwcm92aWRlZCcpXG4gICAgfVxuXG4gICAgY29uc3Qgd2lsZGNhcmQgPSBldmVudCA9PT0gJyonXG4gICAgY29uc3QgZXZlbnRzID0gd2lsZGNhcmQgPyB2YWxpZEV2ZW50c1ttb2R1bGVdIDogW2V2ZW50XSAvLyBleHBsb2RlcyB3aWxkY2FyZHMgaW50byBhbiBhcnJheVxuICAgIGNvbnN0IHByb21pc2VzID0gW11cbiAgICBjb25zdCBoYXNDb250ZXh0ID0gT2JqZWN0LnZhbHVlcyhjb250ZXh0KS5sZW5ndGggPiAwXG4gICAgY29uc3QgY29udGV4dEtleSA9IE9iamVjdC5rZXlzKGNvbnRleHQpXG4gICAgICAuc29ydCgpXG4gICAgICAubWFwKChrZXkpID0+IGtleSArICc9JyArIEpTT04uc3RyaW5naWZ5KGNvbnRleHRba2V5XSkpXG4gICAgICAuam9pbignJicpXG5cbiAgICBsaXN0ZW5lcklkKytcblxuICAgIGlmIChvbmNlKSB7XG4gICAgICBvbmNlcnMucHVzaChsaXN0ZW5lcklkKVxuICAgIH1cblxuICAgIGV2ZW50cy5mb3JFYWNoKChldmVudCkgPT4ge1xuICAgICAgY29uc3Qga2V5ID0gbW9kdWxlICsgJy4nICsgZXZlbnQgKyAoaGFzQ29udGV4dCA/IGAuJHtjb250ZXh0S2V5fWAgOiAnJylcblxuICAgICAgaWYgKE9iamVjdC52YWx1ZXMobGlzdGVuZXJzLmdldChrZXkpKS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgY29uc3QgYXJncyA9IE9iamVjdC5hc3NpZ24oeyBsaXN0ZW46IHRydWUgfSwgY29udGV4dClcbiAgICAgICAgY29uc3QgeyBpZCwgcHJvbWlzZSB9ID0gVHJhbnNwb3J0Lmxpc3RlbihcbiAgICAgICAgICBtb2R1bGUsXG4gICAgICAgICAgJ29uJyArIGV2ZW50WzBdLnRvVXBwZXJDYXNlKCkgKyBldmVudC5zdWJzdHJpbmcoMSksXG4gICAgICAgICAgYXJncyxcbiAgICAgICAgKVxuICAgICAgICBrZXlzW2lkXSA9IGtleVxuICAgICAgICBwcm9taXNlcy5wdXNoKHByb21pc2UpXG4gICAgICB9XG5cbiAgICAgIGNvbnN0IHNldHRlciA9IGludGVybmFsID8gbGlzdGVuZXJzLnNldEludGVybmFsIDogbGlzdGVuZXJzLnNldFxuXG4gICAgICBpZiAod2lsZGNhcmQpIHtcbiAgICAgICAgc2V0dGVyKGtleSwgJycgKyBsaXN0ZW5lcklkLCAodmFsdWUpID0+IGNhbGxiYWNrKGV2ZW50LCB2YWx1ZSkpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzZXR0ZXIoa2V5LCAnJyArIGxpc3RlbmVySWQsIGNhbGxiYWNrKVxuICAgICAgfVxuICAgIH0pXG5cbiAgICBsZXQgcmVzb2x2ZSwgcmVqZWN0XG4gICAgbGV0IHAgPSBuZXcgUHJvbWlzZSgocmVzLCByZWopID0+IHtcbiAgICAgIHJlc29sdmUgPSByZXNcbiAgICAgIHJlamVjdCA9IHJlalxuICAgIH0pXG5cbiAgICBpZiAocHJvbWlzZXMubGVuZ3RoKSB7XG4gICAgICBQcm9taXNlLmFsbChwcm9taXNlcylcbiAgICAgICAgLnRoZW4oKHJlc3BvbnNlcykgPT4ge1xuICAgICAgICAgIHJlc29sdmUobGlzdGVuZXJJZClcbiAgICAgICAgfSlcbiAgICAgICAgLmNhdGNoKChlcnJvcikgPT4ge1xuICAgICAgICAgIC8vIFByb21pc2UuYWxsIHJlamVjdHMgaWYgYXQgbGVhc3Qgb25lIHByb21pc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fVxuICAgIHJldHVybiBmYWxzZVxuICB9IGVsc2Uge1xuICAgIGlmICghbW9kdWxlT3JJZCAmJiAhZXZlbnQpIHtcbiAgICAgIGxpc3RlbmVycy5rZXlzKCkuZm9yRWFjaCgoa2V5KSA9PiB7XG4gICAgICAgIGxpc3RlbmVycy5yZW1vdmVLZXkoa2V5KVxuICAgICAgICB1bnN1YnNjcmliZShrZXkpXG4gICAgICB9KVxuICAgIH0gZWxzZSBpZiAoIWV2ZW50KSB7XG4gICAgICBsaXN0ZW5lcnMua2V5cygpLmZvckVhY2goKGtleSkgPT4ge1xuICAgICAgICBpZiAoa2V5LmluZGV4T2YobW9kdWxlT3JJZC50b0xvd2VyQ2FzZSgpKSA9PT0gMCkge1xuICAgICAgICAgIGxpc3RlbmVycy5yZW1vdmVLZXkoa2V5KVxuICAgICAgICAgIHVuc3Vic2NyaWJlKGtleSlcbiAgICAgICAgfVxuICAgICAgfSlcbiAgICB9IGVsc2Uge1xuICAgICAgY29uc3QgaGFzQ29udGV4dCA9IE9iamVjdC52YWx1ZXMoY29udGV4dCkubGVuZ3RoID4gMFxuICAgICAgY29uc3QgY29udGV4dEtleSA9IE9iamVjdC5rZXlzKGNvbnRleHQpXG4gICAgICAgIC5zb3J0KClcbiAgICAgICAgLm1hcCgoa2V5KSA9PiBrZXkgKyAnPScgKyBKU09OLnN0cmluZ2lmeShjb250ZXh0W2tleV0pKVxuICAgICAgICAuam9pbignJicpXG4gICAgICBjb25zdCBrZXkgPVxuICAgICAgICBtb2R1bGVPcklkICsgJy4nICsgZXZlbnQgKyAoaGFzQ29udGV4dCA/IGAuJHtjb250ZXh0S2V5fWAgOiAnJylcblxuICAgICAgbGlzdGVuZXJzLnJlbW92ZUtleShrZXkpXG4gICAgICB1bnN1YnNjcmliZShrZXksIGNvbnRleHQpXG4gICAgfVxuICB9XG59XG5cbmNvbnN0IGluaXQgPSAoKSA9PiB7XG4gIGlmICghdHJhbnNwb3J0SW5pdGlhbGl6ZWQpIHtcbi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AgICBwcm92aWRlckNhbGxBcmdzLnB1c2gocmVxdWVzdC5wYXJhbWV0ZXJzKVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHByb3ZpZGVyQ2FsbEFyZ3MucHVzaChudWxsKVxuICAgICAgICB9XG5cbiAgICAgICAgY29uc3Qgc2Vzc2lvbiA9IHtcbiAgICAgICAgICBjb3JyZWxhdGlvbklkOiAoKSA9PiB7XG4gICAgICAgICAgICByZXR1cm4gcmVxdWVzdC5jb3JyZWxhdGlvbklkXG4gICAgICAgICAgfSxcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIG9ubHkgcGFzcyBpbiB0aGUgZm9jdXMgaGFuZHNoYWtlIGlmIG5lZWRlZFxuICAgICAgICBpZiAoaW1ldGhvZC5mb2N1cykge1xuICAgICAgICAgIHNlc3Npb24uZm9jdXMgPSAoKSA9PiB7XG4gICAgICAgICAgICBUcmFuc3BvcnQuc2VuZChtb2R1bGUsIGAke21ldGhvZH1Gb2N1c2AsIHtcbiAgICAgICAgICAgICAgY29ycmVsYXRpb25JZDogcmVxdWVzdC5jb3JyZWxhdGlvbklkLFxuICAgICAgICAgICAgfSlcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBwcm92aWRlckNhbGxBcmdzLnB1c2goc2Vzc2lvbilcblxuICAgICAgICBjb25zdCByZXNwb25zZSA9IHtcbiAgICAgICAgICBjb3JyZWxhdGlvbklkOiByZXF1ZXN0LmNvcnJlbGF0aW9uSWQsXG4gICAgICAgIH1cbiAgICAgICAgbGV0IGhhbmRsZUVycm9yID0gKGVycm9yKSA9PiB7XG4gICAgICAgICAgcmVzcG9uc2UuZXJyb3IgPSB7XG4gICAgICAgICAgICBjb2RlOiBlcnJvci5jb2RlIHx8IDEwMDAsIC8vIHRvZG86IHNob3VsZCBiZSBzb21lIHJlc2VydmVkIGNvZGUgZm9yIFwiVW5rbm93blwiXG4gICAgICAgICAgICBtZXNzYWdlOlxuICAgICAgICAgICAgICBlcnJvci5tZXNzYWdlIHx8XG4gICAgICAgICAgICAgIGBBbiBlcnJvciBvY2N1cmVkIHdoaWxlIGNhbGxpbmcgcHJvdmlkZWQgJHttZXRob2R9IG1ldGhvZC5gLFxuICAgICAgICAgIH1cblxuICAgICAgICAgIGlmIChlcnJvci5kYXRhKSB7XG4gICAgICAgICAgICByZXNwb25zZS5lcnJvci5kYXRhID0gSlNPTi5wYXJzZShKU09OLnN0cmluZ2lmeShlcnJvci5kYXRhKSlcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBUcmFuc3BvcnQuc2VuZChtb2R1bGUsIGAke21ldGhvZH1FcnJvcmAsIHJlc3BvbnNlKVxuICAgICAgICB9XG5cbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBjb25zdCByZXN1bHQgPSBwcm92aWRlclttZXRob2RdLmFwcGx5KHByb3ZpZGVyLCBwcm92aWRlckNhbGxBcmdzKVxuXG4gICAgICAgICAgaWYgKCEocmVzdWx0IGluc3RhbmNlb2YgUHJvbWlzZSkpIHtcbiAgICAgICAgICAgIHRocm93IGBQcm92aWRlciBtZXRob2QgJHttZXRob2R9IGRpZCBub3QgcmV0dXJuIGEgUHJvbWlzZS5gXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgcmVzdWx0XG4gICAgICAgICAgICAudGhlbigocmVzdWx0KSA9PiB7XG4gICAgICAgICAgICAgIGlmIChpbWV0aG9kLnJlc3BvbnNlKSB7XG4gICAgICAgICAgICAgICAgLy8gdm9pZCByZXN1bHRzIHNob3VsZCBiZSBudWxsIGluIHRoZSBKU09OUlBDIG1lc3NhZ2VcbiAgICAgICAgICAgICAgICByZXNwb25zZS5yZXN1bHQgPSByZXN1bHQgPT0gbnVsbCA/IG51bGwgOiByZXN1bHRcbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIFRyYW5zcG9ydC5zZW5kKG1vZHVsZSwgYCR7bWV0aG9kfVJlc3BvbnNlYCwgcmVzcG9uc2UpXG4gICAgICAgICAgICB9KVx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3NzcyMTYgfCAwKSAqIGFscGhhIHwgMDtcbiAgICByZXR1cm4gKChjID4+IDE2ICYgMjU1KSAqIGEgLyAyNTUgJiAyNTUpICsgKChjICYgNjUyODApICogYSAvIDI1NSAmIDY1MjgwKSArICgoKGMgJiAyNTUpIDw8IDE2KSAqIGEgLyAyNTUgJiAxNjcxMTY4MCkgKyAoYSA8PCAyNCk7XG4gIH1cbiAgc3RhdGljIHJhZChkZWcpIHtcbiAgICByZXR1cm4gZGVnICogKE1hdGguUEkgLyAxODApO1xuICB9XG4gIHN0YXRpYyBnZXRUaW1pbmdCZXppZXIoYSwgYiwgYywgZCkge1xuICAgIGxldCB4YyA9IDMgKiBhO1xuICAgIGxldCB4YiA9IDMgKiAoYyAtIGEpIC0geGM7XG4gICAgbGV0IHhhID0gMSAtIHhjIC0geGI7XG4gICAgbGV0IHljID0gMyAqIGI7XG4gICAgbGV0IHliID0gMyAqIChkIC0gYikgLSB5YztcbiAgICBsZXQgeWEgPSAxIC0geWMgLSB5YjtcbiAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgaWYgKHRpbWUgPj0gMSkge1xuICAgICAgICByZXR1cm4gMTtcbiAgICAgIH1cbiAgICAgIGlmICh0aW1lIDw9IDApIHtcbiAgICAgICAgcmV0dXJuIDA7XG4gICAgICB9XG4gICAgICBsZXQgdCA9IDAuNSwgY2J4LCBjYnhkLCBkeDtcbiAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuICAgICAgICBkeCA9IHRpbWUgLSBjYng7XG4gICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpO1xuICAgICAgICB9XG4gICAgICAgIGNieGQgPSB0ICogKHQgKiAoMyAqIHhhKSArIDIgKiB4YikgKyB4YztcbiAgICAgICAgaWYgKGNieGQgPiAxZS0xMCAmJiBjYnhkIDwgMWUtMTApIHtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICB0ICs9IGR4IC8gY2J4ZDtcbiAgICAgIH1cbiAgICAgIGxldCBtaW5UID0gMDtcbiAgICAgIGxldCBtYXhUID0gMTtcbiAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICB0ID0gMC41ICogKG1pblQgKyBtYXhUKTtcbiAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcbiAgICAgICAgZHggPSB0aW1lIC0gY2J4O1xuICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZHggPCAwKSB7XG4gICAgICAgICAgbWF4VCA9IHQ7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbWluVCA9IHQ7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9O1xuICB9XG4gIHN0YXRpYyBnZXRUaW1pbmdGdW5jdGlvbihzdHIpIHtcbiAgICBzd2l0Y2ggKHN0cikge1xuICAgICAgY2FzZSBcImxpbmVhclwiOlxuICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgIHJldHVybiB0aW1lO1xuICAgICAgICB9O1xuICAgICAgY2FzZSBcImVhc2VcIjpcbiAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAuMjUsIDAuMSwgMC4yNSwgMSk7XG4gICAgICBjYXNlIFwiZWFzZS1pblwiOlxuICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC40MiwgMCwgMSwgMSk7XG4gICAgICBjYXNlIFwiZWFzZS1vdXRcIjpcbiAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAsIDAsIDAuNTgsIDEpO1xuICAgICAgY2FzZSBcImVhc2UtaW4tb3V0XCI6XG4gICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjQyLCAwLCAwLjU4LCAxKTtcbiAgICAgIGNhc2UgXCJzdGVwLXN0YXJ0XCI6XG4gICAgICAgIHJldHVybiBmdW5jdGlvbigpIHtcbiAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgfTtcbiAgICAgIGNhc2UgXCJzdGVwLWVuZFwiOlxuICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgIHJldHVybiB0aW1lID09PSAxID8gMSA6IDA7XG4gICAgICAgIH07XG4gICAgICBkZWZhdWx0OlxuICAgICAgICBsZXQgcyA9IFwiY3ViaWMtYmV6aWVyKFwiO1xuICAgICAgICBpZiAoc3RyICYmIHN0ci5pbmRleE9mKHMpID09PSAwKSB7XG4gICAgICAgICAgbGV0IHBhcnRzID0gc3RyLnN1YnN0cihzLmxlbmd0aCwgc3RyLmxlbmd0aCAtIHMubGVuZ3RoIC0gMSkuc3BsaXQoXCIsXCIpO1xuICAgICAgICAgIGlmIChwYXJ0cy5sZW5ndGggIT09IDQpIHtcbiAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgICAgICByZXR1cm4gdGltZTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgfVxuICAgICAgICAgIGxldCBhID0gcGFyc2VGbG9hdChwYXJ0c1swXSk7XG4gICAgICAgICAgbGV0IGIgPSBwYXJzZUZsb2F0KHBhcnRzWzFdKTtcbiAgICAgICAgICBsZXQgYyA9IHBhcnN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5fbGluZS5pdGVtcztcbiAgICAgIGRvIHtcbiAgICAgICAgbGV0IGFtb3VudFBlclNocmluayA9IHRoaXMuX2Ftb3VudFJlbWFpbmluZyAvIHRvdGFsU2hyaW5rQW1vdW50O1xuICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICAgIGNvbnN0IGl0ZW0gPSBpdGVtc1tpXTtcbiAgICAgICAgICBjb25zdCBmbGV4SXRlbSA9IGl0ZW0uZmxleEl0ZW07XG4gICAgICAgICAgY29uc3Qgc2hyaW5rQW1vdW50ID0gZmxleEl0ZW0uc2hyaW5rO1xuICAgICAgICAgIGNvbnN0IGlzU2hyaW5rYWJsZUl0ZW0gPSBzaHJpbmtBbW91bnQgPiAwO1xuICAgICAgICAgIGlmIChpc1Nocmlua2FibGVJdGVtKSB7XG4gICAgICAgICAgICBsZXQgc2hyaW5rID0gc2hyaW5rQW1vdW50ICogYW1vdW50UGVyU2hyaW5rO1xuICAgICAgICAgICAgY29uc3QgbWluU2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc01pblNpemUoKTtcbiAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCk7XG4gICAgICAgICAgICBpZiAoc2l6ZSA+IG1pblNpemUpIHtcbiAgICAgICAgICAgICAgY29uc3QgbWF4U2hyaW5rID0gc2l6ZSAtIG1pblNpemU7XG4gICAgICAgICAgICAgIGNvbnN0IGlzRnVsbHlTaHJ1bmsgPSBzaHJpbmsgPj0gbWF4U2hyaW5rO1xuICAgICAgICAgICAgICBpZiAoaXNGdWxseVNocnVuaykge1xuICAgICAgICAgICAgICAgIHNocmluayA9IG1heFNocmluaztcbiAgICAgICAgICAgICAgICB0b3RhbFNocmlua0Ftb3VudCAtPSBzaHJpbmtBbW91bnQ7XG4gICAgICAgIC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vd2FibGVJdGVtKSB7XG4gICAgICAgICAgICBsZXQgZ3JvdyA9IGdyb3dBbW91bnQgKiBhbW91bnRQZXJHcm93O1xuICAgICAgICAgICAgY29uc3QgbWF4U2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc01heFNpemVTZXR0aW5nKCk7XG4gICAgICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuICAgICAgICAgICAgaWYgKG1heFNpemUgPiAwKSB7XG4gICAgICAgICAgICAgIGlmIChzaXplID49IG1heFNpemUpIHtcbiAgICAgICAgICAgICAgICBncm93ID0gMDtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zdCBtYXhHcm93ID0gbWF4U2l6ZSAtIHNpemU7XG4gICAgICAgICAgICAgICAgY29uc3QgaXNGdWxseUdyb3duID0gZ3JvdyA+PSBtYXhHcm93O1xuICAgICAgICAgICAgICAgIGlmIChpc0Z1bGx5R3Jvd24pIHtcbiAgICAgICAgICAgICAgICAgIGdyb3cgPSBtYXhHcm93O1xuICAgICAgICAgICAgICAgICAgdG90YWxHcm93QW1vdW50IC09IGdyb3dBbW91bnQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoZ3JvdyA+IDApIHtcbiAgICAgICAgICAgICAgY29uc3QgZmluYWxTaXplID0gc2l6ZSArIGdyb3c7XG4gICAgICAgICAgICAgIGZsZXhJdGVtLl9yZXNpemVNYWluQXhpcyhmaW5hbFNpemUpO1xuICAgICAgICAgICAgICB0aGlzLl9ncm93blNpemUgKz0gZ3JvdztcbiAgICAgICAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nIC09IGdyb3c7XG4gICAgICAgICAgICAgIGlmIChNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpIDwgMWUtNSkge1xuICAgICAgICAgICA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AgfSBlbHNlIHtcbiAgICAgIHJldHVybiB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCk7XG4gICAgfVxuICB9XG4gIHNldFpQYXJlbnQobmV3WlBhcmVudCkge1xuICAgIGlmICh0aGlzLl96UGFyZW50ICE9PSBuZXdaUGFyZW50KSB7XG4gICAgICBpZiAodGhpcy5felBhcmVudCAhPT0gbnVsbCkge1xuICAgICAgICBpZiAodGhpcy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgdGhpcy5felBhcmVudC5kZWNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgfVxuICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IG51bGwpIHtcbiAgICAgICAgbGV0IGhhZFpDb250ZXh0VXNhZ2UgPSBuZXdaUGFyZW50Ll96Q29udGV4dFVzYWdlID4gMDtcbiAgICAgICAgaWYgKHRoaXMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgIG5ld1pQYXJlbnQuaW5jWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChuZXdaUGFyZW50Ll96Q29udGV4dFVzYWdlID4gMCkge1xuICAgICAgICAgIGlmICghaGFkWkNvbnRleHRVc2FnZSAmJiB0aGlzLl9wYXJlbnQgPT09IG5ld1pQYXJlbnQpXG4gICAgICAgICAgICA7XG4gICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBuZXdaUGFyZW50Ll96SW5kZXhlZENoaWxkcmVuLnB1c2godGhpcyk7XG4gICAgICAgICAgfVxuICAgICAgICAgIG5ld1pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgdGhpcy5felBhcmVudCA9IG5ld1pQYXJlbnQ7XG4gICAgICB0aGlzLl96SW5kZXhSZXNvcnQgPSB0cnVlO1xuICAgIH1cbiAgfVxuICBpbmNaQ29udG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G4gICAgICAgIGlmICh0aGlzLl9wYXJlbnQgPT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgdGhpcy5felBhcmVudC5kZWNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG5ld1pQYXJlbnQgPSB0aGlzLl9wYXJlbnQ7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSBpZiAoekluZGV4ICE9PSAwICYmIHRoaXMuX3pJbmRleCA9PT0gMCkge1xuICAgICAgICBuZXdaUGFyZW50ID0gdGhpcy5fcGFyZW50ID8gdGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpIDogbnVsbDtcbiAgICAgICAgaWYgKG5ld1pQYXJlbnQgPT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgdGhpcy5felBhcmVudC5pbmNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKHpJbmRleCAhPT0gdGhpcy5fekluZGV4KSB7XG4gICAgICAgIGlmICh0aGlzLl96UGFyZW50ICYmIHRoaXMuX3pQYXJlbnQuX3pDb250ZXh0VXNhZ2UpIHtcbiAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChuZXdaUGFyZW50ICE9PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgIHRoaXMuc2V0WlBhcmVudChudWxsKTtcbiAgICAgIH1cbiAgICAgIHRoaXMuX3pJbmRleCA9IHpJbmRleDtcbiAgICAgIGlmIChuZXdaUGFyZW50ICE9PSB0aGlzLl96UGFyZW50KSB7XG4gIC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gdGhpcy5fbG9jYWxUYiAqIHB3LnRjO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBjb25zdCBwciA9IHRoaXMuX3BhcmVudC5fcmVuZGVyQ29udGV4dDtcbiAgICAgIGlmICh0aGlzLl9wYXJlbnQuX2hhc1JlbmRlckNvbnRleHQoKSkge1xuICAgICAgICBjb25zdCBpbml0ID0gdGhpcy5fcmVuZGVyQ29udGV4dCA9PT0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICBpZiAoaW5pdCkge1xuICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBuZXcgRWxlbWVudENvcmVDb250ZXh0KCk7XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgcjIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgICBpZiAoaW5pdCB8fCByZWNhbGMgJiAxKSB7XG4gICAgICAgICAgcjIuYWxwaGEgPSBwci5hbHBoYSAqIHRoaXMuX2xvY2FsQWxwaGE7XG4gICAgICAgICAgaWYgKHIyLmFscGhhIDwgMWUtMTQpIHtcbiAgICAgICAgICAgIHIyLmFscGhhID0gMDtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGluaXQgfHwgcmVjYWxjICYgNikge1xuICAgICAgICAgIHIyLnB4ID0gcHIucHggKyB0aGlzLl9sb2NhbFB4ICogcHIudGE7XG4gICAgICAgICAgcjIucHkgPSBwci5weSArIHRoaXMuX2xvY2FsUHkgKiBwci50ZDtcbiAgICAgICAgICBpZiAocHIudGIgIT09IDApXG4gICAgICAgICAgICByMi5weCArPSB0aGlzLl9sb2NhbFB5ICogcHIudGI7XG4gICAgICAgICAgaWYgKHByLnRjICE9PSAwKVxuICAgICAgICAgICAgcjIucHkgKz0gdGhpcy5fbG9jYWxQeCAqIHByLnRjO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpbml0KSB7XG4gICAgICAgICAgcmVjYWxjIHw9IDI7XG4gICAgICAgIH1cbiAgICAg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dHVyZSAhPT0gdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgIHRoaXMuX3JlY2FsYyB8PSAyICsgNDtcbiAgICAgICAgcmVjYWxjIHw9IDI7XG4gICAgICAgIGlmICghdGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgdGhpcy5fdGV4dHVyaXplci5yZWxlYXNlKCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSA9IHVzZVJlbmRlclRvVGV4dHVyZTtcbiAgICAgIGNvbnN0IHIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgY29uc3QgYmJveFcgPSB0aGlzLl9kaW1zVW5rbm93biA/IDIwNDggOiB0aGlzLl93O1xuICAgICAgY29uc3QgYmJveEggPSB0aGlzLl9kaW1zVW5rbm93biA/IDIwNDggOiB0aGlzLl9oO1xuICAgICAgbGV0IHN4LCBzeSwgZXgsIGV5O1xuICAgICAgY29uc3QgckNvbXBsZXggPSByLnRiICE9PSAwIHx8IHIudGMgIT09IDAgfHwgci50YSA8IDAgfHwgci50ZCA8IDA7XG4gICAgICBpZiAockNvbXBsZXgpIHtcbiAgICAgICAgc3ggPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgIGV4ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICBzeSA9IE1hdGgubWluKDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgZXkgPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzeCA9IHIucHg7XG4gICAgICAgIGV4ID0gci5weCArIHIudGEgKiBiYm94VztcbiAgICAgICAgc3kgPSByLnB5O1xuICAgICAgICBleSA9IHIucHkgKyByLnRkICogYmJveEg7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fZGltc1Vua25vd24gJiYgKHJDb21wbGV4IHx8IHRoaXMuX2xvY2FsVGEgPCAxIHx8IHRoaXMuX2xvY2FsVGIgPCAxKSkge1xuICAgICAgICBjb25zdCBueCA9IHRoaXMuX3ggKiBwci50YSArIHRoaXMuX3kgKiBwci50YiArIHByLnB4O1xuICAgICAgICBjb25zdCBueSA9IHRoaXMuX3ggKiBwci50YyArIHRoaXMuX3kgKiBwci50ZCArIHByLnB5O1xuICAgICAgICBpZiAobnggPCBzeClcbiAgICAgICAgICBzeCA9IG54O1xuICAgICAgICBpZiAobnkgPCBzeSlcbiAgICAgICAgICBzeSA9IG55O1xuICAgICAgICBpZiAobnggPiBleClcbiAgICAgICAgICBleCA9IG54O1xuICAgICAgICBpZiAobnkgPiBleSlcbiAgICAgICAgICBleSA9IG55O1xuICAgICAgfVxuICAgICAgaWYgKHJlY2FsYyAmIDYgfHwgIXRoaXMuX3NjaXNzb3IpIHtcbiAgICAgICAgaWYgKHRoaXMuX2NsaXBwaW5nICYmIHIuaXNTcXVhcmUoKSkge1xuICAgICAgICAgIGNvbnN0IGFyZWEgPSB0aGlzLl9wYXJlbnQuX3VzZVJlbmRlclRvVGV4dHVyZSA/IHRoaXMuX3BhcmVudC5fdmlld3BvcnQgOiB0aGlzLl9wYXJlbnQuX3NjaXNzb3I7XG4gICAgICAgICAgaWYgKGFyZWEpIHtcbiAgICAgICAgICAgIGNvbnN0IGx4ID0gTWF0aC5tYXgoYXJlYVswXSwgc3gpO1xuICAgICAgICAgICAgY29uc3QgbHkgPSBNYXRoLm1heChhcmVhWzFdLCBzeSk7XG4gICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gW1xuICAgICAgICAgICAgICBseCxcbiAgICAgICAgICAgICAgbHksXG4gICAgICAgICAgICAgIE1hdGgubWluKGFyZWFbMl0gKyBhcmVhWzBdLCBleCkgLSBseCxcbiAgICAgICAgICAgICAgTWF0aC5taW4oYXJlYVszXSArIGFyZWFbMV0sIGV5KSAtIGx5XG4gICAgICAgICAgICBdO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gW3N4LCBzeSwgZXggLSBzeCwgZXkgLSBzeV07XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSB0aGlzLl9wYXJlbnQuX3VzZVJlbmRlclRvVGV4dHVyZSA/IHRoaXMuX3BhcmVudC5fdmlld3BvcnQgOiB0aGlzLl9wYXJlbnQuX3NjaXNzb3I7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9ib3VuZHNNYXJnaW4pIHtcbiAgICAgICAgdGhpcy5fcmVjQm91bmRzTWFyZ2luID0gdGhpcy5fYm91bmRzTWFyZ2luO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhpcy5fcmVjQm91bmRzTWFyZ2luID0gdGhpcy5fcGFyZW50Ll9yZWNCb3VuZHNNYXJnaW47XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fb25BZnRlckNhbGNzKSB7XG4gICAgICAgIGlmICh0aGlzLl9vbkFmdGVyQ2FsY3ModGhpcy5lbGVtZW50KSkge1xuICAgICAgICAgIGlmIChyQ29tcGxleCkge1xuICAgICAgICAgICAgc3ggPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICBleCA9IE1hdGgubWF4KDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgIHN5ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgICAgZXkgPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN4ID0gci5weDtcbiAgICAgICAgICAgIGV4ID0gci5weCArIHIudGEgKiBiYm94VztcbiAgICAgICAgICAgIHN5ID0gci5weTtcbiAgICAgICAgICAgIGV5ID0gci5weSArIHIudGQgKiBiYm94SDtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHRoaXMuX2RpbXNVbmtub3duICYmIChyQ29tcGxleCB8fCB0aGlzLl9sb2NhbFRhIDwgMSB8fCB0aGlzLl9sb2NhbFRiIDwgMSkpIHtcbiAgICAgICAgICAgIGNvbnN0IG54ID0gdGhpcy5feCAqIHByLnRhICsgdGhpcy5feSAqIHByLnRiICsgcHIucHg7XG4gICAgICAgICAgICBjb25zdCBueSA9IHRoaXMuX3ggKiBwci50YyArIHRoaXMuX3kgKiBwci50ZCArIHByLnB5O1xuICAgICAgICAgICAgaWYgKG54IDwgc3gpXG4gICAgICAgICAgICAgIHN4ID0gbng7XG4gICAgICAgICAgICBpZiAobnkgPCBzeSlcbiAgICAgICAgICAgICAgc3kgPSBueTtcbiAgICAgICAgICAgIGlmIChueCA+IGV4KVxuICAgICAgICAgICAgICBleCA9IG54O1xuICAgICAgICAgICAgaWYgKG55ID4gZXkpXG4gICAgICAgICAgICAgIGV5ID0gbnk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fcGFyZW50Ll9vdXRPZkJvdW5kcyA9PT0gMikge1xuICAgICAgICB0aGlzLl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dXRPZkJvdW5kcyA9PT0gMikge1xuICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luICE9PSB3aXRoaW5NYXJnaW4pIHtcbiAgICAgICAgICAgIHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbiA9IHdpdGhpbk1hcmdpbjtcbiAgICAgICAgICAgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgdGhpcy5faGFzVXBkYXRlcyA9IHRydWU7XG4gICAgICAgICAgICAgIGNvbnN0IHJlY2FsYzIgPSB0aGlzLl9yZWNhbGM7XG4gICAgICAgICAgICAgIHRoaXMuX3JlY2FsYyA9IDA7XG4gICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZW5hYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgICAgIGlmICh0aGlzLl9yZWNhbGMpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy51cGRhdGUoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB0aGlzLl9yZWNhbGMgPSByZWNhbGMyO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9kaXNhYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgIGlmICh0aGlzLl92aWV3cG9ydCkge1xuICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0WzJdID0gYmJveFc7XG4gICAgICAgICAgdGhpcy5fdmlld3BvcnRbM10gPSBiYm94SDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl92aWV3cG9ydCA9IFswLCAwLCBiYm94VywgYmJveEhdO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB0aGlzLl9wUmVjYWxjID0gdGhpcy5fcmVjYWxjICYgMTM1O1xuICAgICAgdGhpcy5fcmVjYWxjID0gMDtcbiAgICAgIHRoaXMuX2hhc1VwZGF0ZXMgPSBmYWxzZTtcbiAgICAgIGlmICh0aGlzLl9vdXRPZkJvdW5kcyA8IDIpIHtcbiAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgIGlmICh0aGlzLl93b3JsZENvbnRleHQuaXNJZGVudGl0eSgpKSB7XG4gICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gRWxlbWVudENvcmVDb250ZXh0LklERU5USVRZO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gcjtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGlmICh0aG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IobnVsbCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAocmVuZGVyVGV4dHVyZUluZm8gJiYgcmVuZGVyVGV4dHVyZUluZm8uY2FjaGUpIHtcbiAgICAgICAgcmVuZGVyU3RhdGUuaXNDYWNoaW5nVGV4dHVyaXplciA9IGZhbHNlO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICBnZXQgelNvcnQoKSB7XG4gICAgcmV0dXJuIHRoaXMuX3pTb3J0O1xuICB9XG4gIHNvcnRaSW5kZXhlZENoaWxkcmVuKCkge1xuICAgIGNvbnN0IG4gPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuLmxlbmd0aDtcbiAgICBsZXQgcHRyID0gMDtcbiAgICBjb25zdCBhID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbjtcbiAgICBjb25zdCBiID0gW107XG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgIGlmIChhW2ldLl96UGFyZW50ID09PSB0aGlzKSB7XG4gICAgICAgIGlmIChhW2ldLl96SW5kZXhSZXNvcnQpIHtcbiAgICAgICAgICBiLnB1c2goYVtpXSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKHB0ciAhPT0gaSkge1xuICAgICAgICAgICAgYVtwdHJdID0gYVtpXTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcHRyKys7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgY29uc3QgbSA9IGIubGVuZ3RoO1xuICAgIGlmIChtKSB7XG4gICAgICBmb3IgKGxldCBqID0gMDsgaiA8IG07IGorKykge1xuICAgICAgICBiW2pdLl96SW5kZXhSZXNvcnQgPSBmYWxzZTtcbiAgICAgIH1cbiAgICAgIGIuc29ydChFbGVtZW50Q29yZS5zb3J0WkluZGV4ZWRDaGlsZHJlbik7XG4gICAgICBjb25zdCBuMiA9IHB0cjtcbiAgICAgIGlmICghbjIpIHtcbiAgICAgICAgcHRyID0gMDtcbiAgICAgICAgbGV0IGogPSAwO1xuICAgICAgICBkbyB7XG4gICAgICAgICAgYVtwdHIrK10gPSBiW2orK107XG4gICAgICAgIH0gd2hpbGUgKGogPCBtKTtcbiAgICAgICAgaWYgKGEubGVuZ3RoID4gcHRyKSB7XG4gICAgICAgICAgYS5zcGxpY2UocHRyKTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcHRyID0gMDtcbiAgICAgICAgbGV0IGkgPSAwO1xuICAgICAgICBsZXQgaiA9IDA7XG4gICAgICAgIGNvbnN0IG1lcmdlUmVzdWx0ID0gW107XG4gICAgICAgIGRvIHtcbiAgICAgICAgICBjb25zdCB2ID0gYVtpXS5fekluZGV4ID09PSBiW2pdLl96SW5kZXggPyBhW2ldLl91cGRhdGVUcmVlT3JkZXIgLSBiW2pdLl91cGRhdGVUcmVlT3JkZXIgOiBhW2ldLl96SW5kZXggLSBiW2pdLl96SW5kZXg7XG4gICAgICAgICAgY29uc3QgYWRkID0gdiA+IDAgPyBiW2orK10gOiBhW2krK107XG4gICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCBtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkKSB7XG4gICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQ7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChpID49IG4yKSB7XG4gICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgIGNvbnN0IGFkZDIgPSBiW2orK107XG4gICAgICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgbWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZDIpIHtcbiAgICAgICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQyO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IHdoaWxlIChqIDwgbSk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9IGVsc2UgaWYgKGog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7XG4gICAgICBpZiAobmV3U291cmNlKSB7XG4gICAgICAgIGlmIChuZXdTb3VyY2UuaXNMb2FkZWQoKSkge1xuICAgICAgICAgIGlmICh0aGlzLl9yZXNpemVNb2RlKSB7XG4gICAgICAgICAgICB0aGlzLl9hcHBseVJlc2l6ZU1vZGUoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKChlbGVtZW50KSA9PiB7XG4gICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgZWxlbWVudC5fc2V0RGlzcGxheWVkVGV4dHVyZSh0aGlzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjb25zdCBsb2FkRXJyb3IgPSBuZXdTb3VyY2UubG9hZEVycm9yO1xuICAgICAgICAgIGlmIChsb2FkRXJyb3IpIHtcbiAgICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaCgoZWxlbWVudCkgPT4ge1xuICAgICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICBlbGVtZW50Lm9uVGV4dHVyZVNvdXJjZUxvYWRFcnJvcihsb2FkRXJyb3IpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaCgoZWxlbWVudCkgPT4ge1xuICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgZWxlbWVudC5fc2V0RGlzcGxheWVkVGV4dHVyZShudWxsKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICBsb2FkKCkge1xuICAgIGlmICh0aGlzLnNvdXJjZSkge1xuICAgICAgaWYgKCF0aGl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W50LmZvbnRzKSB7XG4gICAgICBjb25zdCBmb250U2V0dGluZyA9IGdldEZvbnRTZXR0aW5nKFxuICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250RmFjZSxcbiAgICAgICAgdGhpcy5fc2V0dGluZ3MuZm9udFN0eWxlLFxuICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U2l6ZSxcbiAgICAgICAgdGhpcy5nZXRQcmVjaXNpb24oKSxcbiAgICAgICAgdGhpcy5fc3RhZ2UuZ2V0T3B0aW9uKFwiZGVmYXVsdEZvbnRGYWNlXCIpXG4gICAgICApO1xuICAgICAgdHJ5IHtcbiAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuZm9udHMubG9hZChmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkuY2F0Y2goKGVycikgPT4ge1xuICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gRm9udCBsb2FkIGVycm9yXCIsIGVyciwgZm9udFNldHRpbmcpO1xuICAgICAgICAgIH0pLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gRm9udCBub3QgZm91bmRcIiwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIENhbid0IGNoZWNrIGZvbnQgbG9hZGluZyBmb3IgXCIgKyBmb250U2V0dGluZyk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIGRyYXcoKSB7XG4g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7XG4gICAgICAgIGlmICh0LmxldHRlcnMpIHtcbiAgICAgICAgICBmb3IgKGxldCBsIG9mIHQubGV0dGVycykge1xuICAgICAgICAgICAgY29uc3QgX3ggPSByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS54ICsgdC54ICsgbHg7XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KGwudGV4dCwgX3gsIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnkgKyByZW5kZXJJbmZvLmZvbnRTaXplKTtcbiAgICAgICAgICAgIGx4ICs9IGwud2lkdGg7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnN0IF94ID0gcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueCArIHQueDtcbiAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KHQudGV4dCwgX3gsIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnkgKyByZW5kZXJJbmZvLmZvbnRTaXplKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBpZiAocHJldlNoYWRvd1NldHRpbmdzKSB7XG4gICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0NvbG9yID0gcHJldlNoYWRvd1NldHRpbmdzWzBdO1xuICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dPZmZzZXRYID0gcHJldlNoYWRvd1NldHRpbmdzWzFdO1xuICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dPZmZzZXRZID0gcHJldlNoYWRvd1NldHRpbmdzWzJdO1xuICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dCbHVyID0gcHJldlNoYWRvd1NldHRpbmdzWzNdO1xuICAgIH1cbiAgICBpZiAocmVuZGVySW5mby5jdXRTeCB8fCByZW5kZXJJbmZvLmN1dFN5KSB7XG4gICAgICB0aGlzLl9jb250ZXh0LnRyYW5zbGF0ZShyZW5kZXJJbmZvLmN1dFN4LCByZW5kZX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C9pPlwiICYmIGl0YWxpYyA+IDApIHtcbiAgICAgICAgaXRhbGljIC09IDE7XG4gICAgICAgIHQgPSBcIlwiO1xuICAgICAgfSBlbHNlIGlmICh0ID09IFwiPGI+XCIpIHtcbiAgICAgICAgYm9sZCArPSAxO1xuICAgICAgICB0ID0gXCJcIjtcbiAgICAgIH0gZWxzZSBpZiAodCA9PSBcIjwvYj5cIiAmJiBib2xkID4gMCkge1xuICAgICAgICBib2xkIC09IDE7XG4gICAgICAgIHQgPSBcIlwiO1xuICAgICAgfSBlbHNlIGlmICh0ID09IFwiPC9jb2xvcj5cIikge1xuICAgICAgICBpZiAoY29sb3JTdGFjay5sZW5ndGggPiAxKSB7XG4gICAgICAgICAgY29sb3IgLT0gMTtcbiAgICAgICAgICBjb2xvclN0YWNrLnBvcCgpO1xuICAgICAgICB9XG4gICAgICAgIHQgPSBcIlwiO1xuICAgICAgfSBlbHNlIGlmIChjb2xvclJlZ2V4cC50ZXN0KHQpKSB7XG4gICAgICAgIGNvbnN0IG1hdGNoZWQgPSBjb2xvclJlZ2V4cC5leGVjKHQpO1xuICAgICAgICBjb2xvclN0YWNrLnB1c2goXG4gICAgICAgICAgU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHBhcnNlSW50KG1hdGNoZWRbMV0pKVxuICAgICAgICApO1xuICAgICAgICBjb2xvciArPSAxO1xuICAgICAgICB0ID0gXCJcIjtcbiAgICAgIH1cbiAgICAgIHJldHVybiB7XG4gICAgICAgIHRleHQ6IHQsXG4gICAgICAgIGl0YWxpYyxcbiAgICAgICAgYm9sZCxcbiAgICAgICAgY29sb3I6IGNvbG9yU3RhY2tbY29sb3JdXG4gICAgICB9O1xuICAgIH0pLmZpbHRlcigobykgPT4gby50ZXh0ICE9IFwiXCIpO1xuICB9XG4gIGFwcGx5Rm9udFN0eWxlKHdvcmQsIGJhc2VGb250KSB7XG4gICAgbGV0IGZvbnQgPSBiYXNlRm9udDtcbiAgICBpZiAod29yZC5ib2xkKSB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gaWYgKHRydW5jV29yZFdpZHRoID4gd2lkdGgpIHtcbiAgICAgICAgICBicmVha0luZGV4IC09IDE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9IGVsc2Uge1xuICAgICAgd2hpbGUgKGJyZWFrSW5kZXggPCB3b3JkTGVuKSB7XG4gICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSk7XG4gICAgICAgIGlmICh0cnVuY1dvcmRXaWR0aCA8IHdpZHRoKSB7XG4gICAgICAgICAgYnJlYWtJbmRleCArPSAxO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGJyZWFrSW5kZXggLT0gMTtcbiAgICAgICAgICB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgYnJlYWtJbmRleCkpO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiB7IGJyZWFrSW5kZXgsIHRydW5jV29yZFdpZHRoIH07XG4gIH1cbiAgd29yZEJyZWFrKHdvcmQsIHdpZHRoLCBiYXNlRm9udCkge1xuICAgIGlmICghd29yZC50ZXh0KSB7XG4gICAgICByZXR1cm4gd29yZDtcbiAgICB9XG4gICAgdGhpcy5hcHBseUZvbnRTdHlsZSh3b3JkLCBiYXNlRm9udCk7XG4gICAgY29uc3QgcGFydHMgPSBbXTtcbiAgICBsZXQgdGV4dCA9IHdvcmQudGV4dDtcbiAgICBpZiAoIXdvcmQubGV0dGVycykge1xuICAgICAgd2hpbGUgKHRydWUpIHtcbiAgICAgICAgY29uc3QgeyBicmVha0luZGV4LCB0cnVuY1dvcmRXaWR0aCB9ID0gdGhpcy5fZ2V0QnJlYWtJbmRleCh0ZXh0LCB3aWR0aCk7XG4gICAgICAgIHBh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FRleHR1cmUucHk7XG4gICAgICAgIHR4MSA9IGl3O1xuICAgICAgICB0eTEgPSBpaDtcbiAgICAgICAgdHgyID0gdHgyICogcncgKyBpdztcbiAgICAgICAgdHkyID0gdHkyICogcmggKyBpaDtcbiAgICAgICAgdHgxID0gTWF0aC5tYXgoMCwgdHgxKTtcbiAgICAgICAgdHkxID0gTWF0aC5tYXgoMCwgdHkxKTtcbiAgICAgICAgdHgyID0gTWF0aC5taW4oMSwgdHgyKTtcbiAgICAgICAgdHkyID0gTWF0aC5taW4oMSwgdHkyKTtcbiAgICAgIH1cbiAgICAgIGlmIChkaXNwbGF5ZWRUZXh0dXJlU291cmNlLl9mbGlwVGV4dHVyZVkpIHtcbiAgICAgICAgbGV0IHRlbXB0eSA9IHR5MjtcbiAgICAgICAgdHkyID0gdHkxO1xuICAgICAgICB0eTEgPSB0ZW1wdHk7XG4gICAgICB9XG4gICAgICB0aGlzLl9fY29yZS5zZXRUZXh0dXJlQ29vcmRzKHR4MSwgdHkxLCB0eDIsIHR5Mik7XG4gICAgfVxuICB9XG4gIGdldENvcm5lclBvaW50cygpIHtcbiAgICByZXR1cm4gdGhpcy5fX2NvcmUuZ2V0Q29ybmVyUG9pbnRzKCk7XG4gIH1cbiAgX3Vuc2V0VGFnc1BhcmVudCgpIHtcbiAgICBpZiAodGhpcy5fX3RhZ3MpIHtcbiAgICAgIHRoaXMuX190YWdzLmZvckVhY2goKHRhZykgPT4ge1xuICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgIHdoaWxlIChwID0gcC5fX3BhcmVudCkge1xuICAgICAgICAgIGxldCBwYXJlbnRUcmVlVGFncyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICBwYXJlbnRUcmVlVGFncy5kZWxldGUodGhpcyk7XG4gICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cbiAgICBsZXQgdGFncyA9IG51bGw7XG4gICAgbGV0IG4gPSAwO1xuICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MpIHtcbiAgICAgIGlmICghdGhpcy5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgdGFncyA9IFV0aWxzJDEuaXRlcmF0b3JUb0FycmF5KHRoaXMuX190cmVlVGFncy5rZXlzKCkpO1xuICAgICAgICBuID0gdGFncy5sZW5ndGg7XG4gICAgICAgIGlmIChuID4gMCkge1xuICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgdGFnU2V0ID0gdGhpcy5fX3RyZWVUYWdzLmdldCh0YWdzW2ldKTtcbiAgICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICAgIHdoaWxlIChwID0gcC5fX3BhcmVudCkge1xuICAgICAgICAgICAgICBsZXQgcGFyZW50VHJlZVRhZ3MgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZ3NbaV0pO1xuICAgICAgICAgICAgICB0YWdTZXQuZm9yRWFjaChmdW5jdGlvbihjb21wKSB7XG4gICAgICAgICAgICAgICAgcGFyZW50VHJlZVRhZ3MuZGVsZXRlKGNvbXApO1xuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgX3NldFRhZ3NQYXJlbnQoKSB7XG4gICAgaWYgKHRoaXMuX190YWdzKSB7XG4gICAgICB0aGlzLl9fdGFncy5mb3JFYWNoKCh0YWcpID0+IHtcbiAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICB3aGlsZSAocCA9IHAuX19wYXJlbnQpIHtcbiAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICBzID0gLyogQF9fUFVSRV9fICovIG5ldyBTZXQoKTtcbiAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcy5hZGQodGhpcyk7XG4gICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cbiAgICBpZiAodGhpcy5fX3RyZWVUYWdzICYmIHRoaXMuX190cmVlVGFncy5zaXplKSB7XG4gICAgICBpZiAoIXRoaXMuX190YWdSb290KSB7XG4gICAgICAgIHRoaXMuX190cmVlVGFncy5mb3JFYWNoKCh0YWdTZXQsIHRhZykgPT4ge1xuICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpIHtcbiAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdClcbiAgICAgICAgICAgICAgO1xuICAgICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICAgIHMgPSAvKiBAX19QVVJFX18gKi8gbmV3IFNldCgpO1xuICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgIC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kVGFnKHRhZykge1xuICAgIGlmICghdGhpcy5fX3RhZ3MpIHtcbiAgICAgIHRoaXMuX190YWdzID0gW107XG4gICAgfVxuICAgIGlmICh0aGlzLl9fdGFncy5pbmRleE9mKHRhZykgPT09IC0xKSB7XG4gICAgICB0aGlzLl9fdGFncy5wdXNoKHRhZyk7XG4gICAgICBsZXQgcCA9IHRoaXMuX19wYXJlbnQ7XG4gICAgICBpZiAocCkge1xuICAgICAgICBkbyB7XG4gICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgIHAuX190cmVlVGFncyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgcyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgU2V0KCk7XG4gICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHMuYWRkKHRoaXMpO1xuICAgICAgICB9IHdoaWxlICghcC5fX3RhZ1Jvb3QgJiYgKHAgPSBwLl9fcGFyZW50KSk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIHJlbW92ZVRhZyh0YWcpIHtcbiAgICBsZXQgaSA9IHRoaXMuX190YWdzLmluZGV4T2YodGFnKTtcbiAgICBpZiAoaSAhPT0gLTEpIHtcbiAgICAgIHRoaXMuX190YWdzLnNwbGljZShpLCAxKTtcbiAgICAgIGxldCBwID0gdGhpcy5fX3BhcmVudDtcbiAgICAgIGlmIChwKSB7XG4gICAgICAgIGRvIHtcbiAgICAgICAgICBsZXQgbGlzdCA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICBpZiAobGlzdCkge1xuICAgICAgICAgICAgbGlzdC5kZWxldGUodGhpcyk7XG4gICAgICAgICAgfVxuICAgICAgICB9I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AgICAgIGlmIChVdGlscyQxLmlzVWNDaGFyKGZpcnN0Q2hhckNvZGUpKSB7XG4gICAgICAgIGNvbnN0IGNoaWxkID0gdGhpcy5nZXRCeVJlZihwYXRoKTtcbiAgICAgICAgaWYgKCFjaGlsZCkge1xuICAgICAgICAgIGlmICh2ICE9PSB2b2lkIDApIHtcbiAgICAgICAgICAgIGxldCBjO1xuICAgICAgICAgICAgaWYgKFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICAgIGMgPSB0aGlzLmNoaWxkTGlzdC5jcmVhdGVJdGVtKHYpO1xuICAgICAgICAgICAgICBjLnBhdGNoKHYpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscyQxLmlzT2JqZWN0KHYpKSB7XG4gICAgICAgICAgICAgIGMgPSB2O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGMuaXNFbGVtZW50KSB7XG4gICAgICAgICAgICAgIGMucmVmID0gcGF0aDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoYyk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmICh2ID09PSB2b2lkIDApIHtcbiAgICAgICAgICAgIGlmIChjaGlsZC5wYXJlbnQpIHtcbiAgICAgICAgICAgICAgY2hpbGQucGFyZW50LmNoaWxkTGlzdC5yZW1vdmUoY2hpbGQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgIGNoaWxkLnBhdGNoKHYpO1xuICAgICAgICAgIH0gZWxzZSBpZiAodi5pc0VsZW1lbnQpIHtcbiAgICAgICAgICAgIHYucmVmID0gcGF0aDtcbiAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LnJlcGxhY2UodiwgY2hpbGQpO1xuICAgICAgICAgIH0gZWxzZSB7XG4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scykge1xuICAgICAgICBsZXQgZmlyZUV2ZW50ID0gdGhpcy5fX3NpZ25hbHNbZXZlbnRdO1xuICAgICAgICBpZiAoZmlyZUV2ZW50ID09PSBmYWxzZSkge1xuICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZmlyZUV2ZW50KSB7XG4gICAgICAgICAgaWYgKGZpcmVFdmVudCA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgZmlyZUV2ZW50ID0gZXZlbnQ7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChVdGlscyQxLmlzRnVuY3Rpb24oZmlyZUV2ZW50KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZpcmVFdmVudCguLi5hcmdzKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHNpZ25hbFBhcmVudC5faGFzTWV0aG9kKGZpcmVFdmVudCkpIHtcbiAgICAgICAgICAgIHJldHVybiBzaWduYWxQYXJlbnRbZmlyZUV2ZW50XSguLi5hcmdzKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGxldCBwYXNzU2lnbmFsID0gdGhpcy5fX3Bhc3NTaWduYWxzICYmIHRoaXMuX19wYXNzU2lnbmFsc1tldmVudF07XG4gICAgICBpZiAocGFzc1NpZ25hbCkge1xuICAgICAgICBpZiAocGFzc1NpZ25hbCAmJiBwYXNzU2lnbmFsICE9PSB0cnVlKSB7XG4gICAgICAgICAgZXZlbnQgPSBwYXNzU2lnbmFsO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzaWduYWxQYXJlbnQuX3NpZ25hbChldmVudCwgYXJncyk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIF9nZXRQYXJlbnRTaWduYWxIYW5kbGVyKCkge1xuICAgIHJldHVybiB0aGlzLmNwYXJlbnQgPyB0aGlzLmNwYXJlbnQuX2dldFNpZ25hbEhhbmRsZXIoKSA6IG51bGw7XG4gIH1cbiAgX2dldFNpZ25hbEh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MDtcbiAgfVxuICBwYXJzZShyZ2JhLCBkZWYpIHtcbiAgICBsZXQgaSwgbjtcbiAgICBpZiAoIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKGRlZikpIHtcbiAgICAgIGRlZiA9IHsgMDogZGVmIH07XG4gICAgfVxuICAgIGxldCBkZWZhdWx0U21vb3RobmVzcyA9IDAuNTtcbiAgICBsZXQgaXRlbXMgPSBbXTtcbiAgICBmb3IgKGxldCBrZXkgaW4gZGVmKSB7XG4gICAgICBpZiAoZGVmLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgbGV0IG9iaiA9IGRlZltrZXldO1xuICAgICAgICBpZiAoIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKG9iaikpIHtcbiAgICAgICAgICBvYmogPSB7IHY6IG9iaiB9O1xuICAgICAgICB9XG4gICAgICAgIGxldCBwID0gcGFyc2VGbG9hdChrZXkpO1xuICAgICAgICBpZiAoa2V5ID09PSBcInNtXCIpIHtcbiAgICAgICAgICBkZWZhdWx0U21vb3RobmVzcyA9IG9iai52O1xuICAgICAgICB9IGVsc2UgaWYgKCFpc05hTihwKSAmJiBwID49IDAgJiYgcCA8PSAyKSB7XG4gICAgICAgICAgb2JqLnAgPSBwO1xuICAgICAgICAgIG9iai5mID0gVXRpbHMkMS5pc0Z1bmN0aW9uKG9iai52KTtcbiAgICAgICAgICBvYmoubHYgPSBvYmouZiA/IG9iai52KDAsIDApIDogb2JqLnY7XG4gICAgICAgICAgaXRlbXMucHVzaChvYmopO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGl0ZW1zID0gaXRlbXMuc29ydChmdW5jdGlvbihhLCBiKSB7XG4gICAgICByZXR1cm4gYS5wIC0gYi5wO1xuICAgIH0pO1xuICAgIG4gPSBpdGVtcy5sZW5ndGg7XG4gICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgbGV0IGxhc3QgPSBpID09PSBuIC0gMTtcbiAgICAgIGlmIC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ICAgICAgICAgaXRlbXNbaV0ucyA9IHJnYmEgPyBbMCwgMCwgMCwgMF0gOiAwO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAocmdiYSkge1xuICAgICAgICAgICAgICBjb25zdCBuYyA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKG5pLmx2KTtcbiAgICAgICAgICAgICAgY29uc3QgcGMgPSBNdWx0aVNwbGluZS5nZXRSZ2JhQ29tcG9uZW50cyhwaS5sdik7XG4gICAgICAgICAgICAgIGNvbnN0IGQgPSAxIC8gKG5pLnAgLSBwaS5wKTtcbiAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IFtcbiAgICAgICAgICAgICAgICBkICogKG5jWzBdIC0gcGNbMF0pLFxuICAgICAgICAgICAgICAgIGQgKiAobmNbMV0gLSBwY1sxXSksXG4gICAgICAgICAgICAgICAgZCAqIChuY1syXSAtIHBjWzJdKSxcbiAgICAgICAgICAgICAgICBkICogKG5jWzNdIC0gcGNbM10pXG4gICAgICAgICAgICAgIF07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gKG5pLmx2IC0gcGkubHYpIC8gKG5pLnAgLSBwaS5wKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZm9yIChpID0gMDsgaSA8IG4gLSAxOyBpKyspIHtcbiAgICAgIGlmICghaXRlbXNbaV0uZikge1xuICAgICAgICBsZXQgbGFzdCA9IGkgPT09IG4gLSAxO1xuICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KFwidmVcIikpIHtcbiAgICAgICAgICBpdGVtc1tpXS52ZSA9IGxhc3QgPyBpdGVtc1tpXS5sdiA6IGl0ZW1zW2kgKyAxXS5sdjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoVXRpbHMkMS5pc051bWJlcihpdGVtc1tpXS52KSAm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XMoYik7XG4gICAgaWYgKCFia3MubGVuZ3RoKSB7XG4gICAgICByZXR1cm4gYTtcbiAgICB9XG4gICAgY29uc3QgYWkgPSB7fTtcbiAgICBjb25zdCBiaSA9IHt9O1xuICAgIGZvciAobGV0IGkgPSAwLCBuID0gYmtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgY29uc3Qga2V5ID0gYmtzW2ldO1xuICAgICAgYWlba2V5XSA9IC0xO1xuICAgICAgYmlba2V5XSA9IGk7XG4gICAgfVxuICAgIGZvciAobGV0IGkgPSAwLCBuID0gYWtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgY29uc3Qga2V5ID0gYWtzW2ldO1xuICAgICAgYWlba2V5XSA9IGk7XG4gICAgICBpZiAoYmlba2V5XSA9PT0gdm9pZCAwKSB7XG4gICAgICAgIGJpW2tleV0gPSAtMTtcbiAgICAgIH1cbiAgICB9XG4gICAgY29uc3QgYWtzbCA9IGFrcy5sZW5ndGg7XG4gICAgY29uc3QgcmVzdWx0ID0ge307XG4gICAgZm9yIChsZXQgaSA9IDAsIG4gPSBia3MubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICBjb25zdCBrZXkgPSBia3NbaV07XG4gICAgICBjb25zdCBhSW5kZXggPSBhaVtrZXldO1xuICAgICAgbGV0IGN1ckluZGV4MiA9IGFJbmRleDtcbiAgICAgIHdoaWxlICgtLWN1ckluZGV4MiA+PSAwKSB7XG4gICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXgyXTtcbiAgICAgICAgaWYgKGJpW2FrZXldICE9PSAtMSkge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB3aGlsZSAoKytjdXJJbmRleDIgPCBhSW5kZXgpIHtcbiAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleDJdO1xuICAgICAgICByZXN1bHRbYWtleV0gPSBhW2FrZXldO1xuICAgICAgfVxuICAgICAgY29uc3QgYnYgPSBiW2tleV07XG4gICAgICBjb25zdCBhdiA9IGFba2V5XTtcbiAgICAgIGxldCByO1xuICAgICAgaWYgKHRoaXMuaXNNZihidikpIHtcbiAgICAgICAgciA9IGJ2KGF2KTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICghVXRpbHMkMS5pc09iamVjdExpdGVyYWwoYXYpIHx8ICFVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbChidikpIHtcbiAgICAgICAgICByID0gYnY7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgciA9IE9iak1lcmdlci5tZXJnZShhdiwgYnYpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAociAhPT0gdm9pZCAwKSB7XG4gICAgICAgIHJlc3VsdFtrZXldID0gcjtcbiAgICAgIH1cbiAgICB9XG4gICAgbGV0IGN1ckluZGV4ID0gYWtzbDtcbiAgICB3aGlsZSAoLS1jdXJJbmRleCA+PSAwKSB7XG4gICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4XTtcbiAgICAgIGlmIChiaVtha2V5XSAhPT0gLTEpIHtcbiAgICAgICAgYnJlYWs7XG4gICAgICB9XG4gICAgfVxuICAgIHdoaWxlICgrK2N1ckluZGV4IDwgYWtzbCkge1xuICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleF07XG4gICAgICByZXN1bHRbYWtleV0gPSBhW2FrZXldO1xuICAgIH1cbiAgICByZXR1cm4gcmVzdWx0O1xuICB9XG59XG5jbGFzcyBPYmplY3RMaXN0UHJveHkgZXh0ZW5kcyBPYmplY3RMaXN0IHtcbiAgY29uc3RydWN0b3IodGFyZ2V0KSB7XG4gICAgc3VwZXIoKTtcbiAgICB0aGlzLl90YXJnZXQgPSB0YXJnZXQ7XG4gIH1cbiAgb25BZGQoaXRlbSwgaW5kZXgpIHtcbiAgICB0aGlzLl90YXJnZXQuYWRkQXQoaXRlbSwgaW5kZXgpO1xuICB9XG4gIG9uUmVt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XJlQ29vcmQueHkgKiByZXNvbHV0aW9uLnh5O1xuICAgICAgICBcbiAgICAgICAgdmVjMiBwb3MxO1xuICAgICAgICB2ZWMyIHBvczI7XG4gICAgICAgIHZlYzIgZDtcbiAgICAgICAgZmxvYXQgYztcbiAgICAgICAgZmxvYXQgdCA9IDAuMDtcbiAgICAgICAgICAgICBcbiAgICAgICAgaWYoZmFkZVswXSA+IDAuMCkge1xuICAgICAgICAgICAgcG9zMSA9IHZlYzIocG9pbnQueCwgcG9pbnQueSk7XG4gICAgICAgICAgICBwb3MyID0gdmVjMihwb2ludC54LCBwb2ludC55ICsgZmFkZVswXSk7XG4gICAgICAgICAgICBkID0gcG9zMiAtIHBvczE7XG4gICAgICAgICAgICBjID0gZG90KHBvczEsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKGMsIDAuMCwgMS4wKSk7XG4gICAgICAgICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgICAgaWYoZmFkZVsxXSA+IDAuMCkge1xuICAgICAgICAgICAgdmVjMiBwb3MxID0gdmVjMihwb2ludC54IC0gcmVzb2x1dGlvbi54IC0gZmFkZVsxXSwgdlRleHR1cmVDb29yZC55KTtcbiAgICAgICAgICAgIHZlYzIgcG9zMiA9IHZlYzIocG9pbnQueCAtIHJlc29sdXRpb24ueCwgdlRleHR1cmVDb29yZC55KTtcbiAgICAgICAgICAgIGQgPSBwb3MxIC0gcG9zMjtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMiwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzJdID4gMC4wKSB7XG4gICAgICAgICAgICB2ZWMyIHBvczEgPSB2ZWMyKHZUZXh0dXJlQ29vcmQueCwgcG9pbnQueSAtIHJlc29sdXRpb24ueSAtIGZhZGVbMl0pO1xuICAgICAgICAgICAgdmVjMiBwb3MyID0gdmVjMih2VGV4dHVyZUNvb3JkLngsIHBvaW50LnkgLSByZXNvbHV0aW9uLnkpO1xuICAgICAgICAgICAgZCA9IHBvczEgLSBwb3MyO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MyLCBkKSAvIGRvdChkLCBkKTtcbiAgICAgICAgICAgIHQgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcChjLCAwLjAsIDEuMCkpO1xuICAgICAgICAgICAgY29sb3IgPSBtaXgodmVjNCgwLjApLCBjb2xvciwgdCk7XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGlmKGZhZGVbM10gPiAwLjApIHtcbiAgICAgICAgICAgIHBvczEgPSB2ZWMyKHBvaW50LngsIHBvaW50LnkpO1xuICAgICAgICAgICAgcG9zMiA9IHZlYzIocG9pbnQueCArIGZhZGVbM10sIHBvaW50LnkpO1xuICAgICAgICAgICAgZCA9IHBvczIgLSBwb3MxO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MxLCBkKSAvIGRvdChkLCBkKTtcbiAgICAgICAgICAgIHQgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcChjLCAwLjAsIDEuMCkpO1xuICAgICAgICAgICAgY29sb3IgPSBtaXgodmVjNCgwLjApLCBjb2xvciwgdCk7XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGdsX0ZyYWdDb2xvciA9IGNvbG9yO1xuICAgIH1cbmA7XG5jbGFzcyBWaWduZXR0ZVNoYWRlciBleHRlbmRzIERlZmF1bHRTaGFkZXIkMSB7XG4gIGNvbnN0cnVjdG9yKGNvbnRleHQpIHtcbiAgICBzdXBlcihjb250ZXh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MzIHJvdDtcbiAgICB2YXJ5aW5nIHZlYzMgcG9zO1xuXG4gICAgdm9pZCBtYWluKHZvaWQpIHtcbiAgICAgICAgcG9zID0gdmVjMyhhVmVydGV4UG9zaXRpb24ueHksIHopO1xuICAgICAgICBcbiAgICAgICAgcG9zIC09IHBpdm90O1xuICAgICAgICBcbiAgICAgICAgLy8gVW5kbyBYWSByb3RhdGlvblxuICAgICAgICBtYXQyIGlSb3RYeSA9IG1hdDIoIGNvcyhyb3QueiksIHNpbihyb3QueiksIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgLXNpbihyb3QueiksIGNvcyhyb3QueikpO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3MueHk7XG4gICAgICAgIFxuICAgICAgICAvLyBQZXJmb3JtIDNkIHJvdGF0aW9uc1xuICAgICAgICBnbF9Qb3NpdGlvbi54ID0gY29zKHJvdC54KSAqIHBvcy54IC0gc2luKHJvdC54KSAqIHBvcy56O1xuICAgICAgICBnbF9Qb3NpdGlvbi55ID0gcG9zLnk7XG4gICAgICAgIGdsX1Bvc2l0aW9uLnogPSBzaW4ocm90LngpICogcG9zLnggKyBjb3Mocm90LngpICogcG9zLno7XG4gICAgICAgIFxuICAgICAgICBwb3MueCA9IGdsX1Bvc2l0aW9uLng7XG4gICAgICAgIHBvcy55ID0gY29zKHJvdC55KSAqIGdsX1Bvc2l0aW9uLnkgLSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24uejtcbiAgICAgICAgcG9zLnogPSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24ueSArIGNvcyhyb3QueSkgKiBnbF9Qb3NpdGlvbi56O1xuICAgICAgICBcbiAgICAgICAgLy8gUmVkbyBYWSByb3RhdGlvblxuICAgICAgICBpUm90WHlbMF1bMV0gPSAtaVJvdFh5WzBdWzFdO1xuICAgICAgICBpUm90WHlbMV1bMF0gPSAtaVJvdFh5WzFdWzBdO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3Mue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DI1NSkgPDwgMTYpICogYSAvIDI1NSAmIDE2NzExNjgwKSArIChhIDw8IDI0KTtcbiAgICB9XG4gICAgc3RhdGljIHJhZChkZWcpIHtcbiAgICAgIHJldHVybiBkZWcgKiAoTWF0aC5QSSAvIDE4MCk7XG4gICAgfVxuICAgIHN0YXRpYyBnZXRUaW1pbmdCZXppZXIoYSwgYiwgYywgZCkge1xuICAgICAgbGV0IHhjID0gMyAqIGE7XG4gICAgICBsZXQgeGIgPSAzICogKGMgLSBhKSAtIHhjO1xuICAgICAgbGV0IHhhID0gMSAtIHhjIC0geGI7XG4gICAgICBsZXQgeWMgPSAzICogYjtcbiAgICAgIGxldCB5YiA9IDMgKiAoZCAtIGIpIC0geWM7XG4gICAgICBsZXQgeWEgPSAxIC0geWMgLSB5YjtcbiAgICAgIHJldHVybiBmdW5jdGlvbih0aW1lKSB7XG4gICAgICAgIGlmICh0aW1lID49IDEpIHtcbiAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGltZSA8PSAwKSB7XG4gICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IHQgPSAwLjUsIGNieCwgY2J4ZCwgZHg7XG4gICAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG4gICAgICAgICAgZHggPSB0aW1lIC0gY2J4O1xuICAgICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5Yyk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGNieGQgPSB0ICogKHQgKiAoMyAqIHhhKSArIDIgKiB4YikgKyB4YztcbiAgICAgICAgICBpZiAoY2J4ZCA+IDFlLTEwICYmIGNieGQgPCAxZS0xMCkge1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICAgIHQgKz0gZHggLyBjYnhkO1xuICAgICAgICB9XG4gICAgICAgIGxldCBtaW5UID0gMDtcbiAgICAgICAgbGV0IG1heFQgPSAxO1xuICAgICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgICB0ID0gMC41ICogKG1pblQgKyBtYXhUKTtcbiAgICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuICAgICAgICAgIGR4ID0gdGltZSAtIGNieDtcbiAgICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoZHggPCAwKSB7XG4gICAgICAgICAgICBtYXhUID0gdDtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbWluVCA9IHQ7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0VGltaW5nRnVuY3Rpb24oc3RyKSB7XG4gICAgICBzd2l0Y2ggKHN0cikge1xuICAgICAgICBjYXNlIFwibGluZWFyXCI6XG4gICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgICAgIHJldHVybiB0aW1lO1xuICAgICAgICAgIH07XG4gICAgICAgIGNhc2UgXCJlYXNlXCI6XG4gICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAuMjUsIDAuMSwgMC4yNSwgMSk7XG4gICAgICAgIGNhc2UgXCJlYXNlLWluXCI6XG4gICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAuNDIsIDAsIDEsIDEpO1xuICAgICAgICBjYXNlIFwiZWFzZS1vdXRcIjpcbiAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMCwgMCwgMC41OCwgMSk7XG4gICAgICAgIGNhc2UgXCJlYXNlLWluLW91dFwiOlxuICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjQyLCAwLCAwLjU4LCAxKTtcbiAgICAgICAgY2FzZSBcInN0ZXAtc3RhcnRcIjpcbiAgICAgICAgICByZXR1cm4gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgICB9O1xuICAgICAgICBjYXNlIFwic3RlcC1lbmRcIjpcbiAgICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRpbWUgPT09IDEgPyAxIDogMDtcbiAgICAgICAgICB9O1xuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIGxldCBzID0gXCJjdWJpYy1iZXppZXIoXCI7XG4gICAgICAgICAgaWYgKHN0ciAmJiBzdHIuaW5kZXhPZihzKSA9PT0gMCkge1xuICAgICAgICAgICAgbGV0IHBhcnRzID0gc3RyLnN1YnN0cihzLmxlbmd0aCwgc3RyLmxlbmd0aCAtIHMubGVuZ3RoIC0gMSkuc3BsaXQoXCIsXCIpO1xuICAgICAgICAgICAgaWYgKHBhcnRzLmxlbmd0aCAhPT0gNCkge1xuICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBVbmtub3duIHRpbWluZyBmdW5jdGlvbjogXCIgKyBzdHIpO1xuICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aW1lO1xuICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IGEgPSBwYXJzZUZsb2F0KHBhcnRzWzBdKTtcbiAgICAgICAgICAgIGxldCBiID0gcGFyc2VGbG9hdChwYXJ0c1sxXSk7XG4gICAgICAgICAgICBsZXQgYyA9IHBhcnNlRmxvYXQocGFydHNbMl0pO1xuICAgICAgICAgICAgbGV0IGQgPSBwYXJzZUZsb2F0KHBhcnRzWzNdKTtcbiAgICAgICAgICAgIGlmIChpc05hTihhKSB8fCBpc05hTihiKSB8fCBpc05hTihjKSB8fCBpc05hTihkKSkge1xuICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBVbmtub3duIHRpbWluZyBmdW5jdGlvbjogXCIgKyBzdHIpO1xuICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24odGltZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aW1lO1xuICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKGEsIGIsIGMsIGQpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBVbmtub3duIHRpbWluZyBmdW5jdGlvbjogXCIgKyBzdHIpO1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgICAgICAgcmV0dXJuIHRpbWU7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgbGV0IFV0aWxzJDEgPSBjbGFzcyBVdGlscyB7XG4gICAgc3RhdGljIGlzRnVuY3Rpb24odmFsdWUpIHtcbiAgICAgIHJldHVybiB0eXBlb2YgdmFsdWUgPT09IFwiZnVuY3Rpb25cIjtcbiAgICB9XG4gICAgc3RhdGljIGlzTnVtYmVyKHZhbHVlKSB7XG4gICAgICByZXR1cm4gdHlwZW9mIHZhbHVlID09PSBcIm51bWJlclwiO1xuICAgIH1cbiAgICBzdGF0aWMgaXNJbnRlZ2VyKHZhbHVlKSB7XG4gICAgICByZXR1cm4gd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ICAgICBjID0gW107XG4gICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICBjW2tleXNbaV1dID0gVXRpbHMkMS5nZXREZWVwQ2xvbmUob2JqW2tleXNbaV1dKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYztcbiAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdChvYmopKSB7XG4gICAgICAgIGMgPSB7fTtcbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICBmb3IgKGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgIGNba2V5c1tpXV0gPSBVdGlscyQxLmdldERlZXBDbG9uZShvYmpba2V5c1tpXV0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIG9iajtcbiAgICAgIH1cbiAgICB9XG4gICAgc3RhdGljIGVxdWFsVmFsdWVzKHYxLCB2Mikge1xuICAgICAgaWYgKHR5cGVvZiB2MSAhPT0gdHlwZW9mIHYyKVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwodjEpKSB7XG4gICAgICAgIHJldHVybiBVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbCh2MikgJiYgVXRpbHMkMS5lcXVhbE9iamVjdExpdGVyYWxzKHYxLCB2Mik7XG4gICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkodjEpKSB7XG4gICAgICAgIHJldHVybiBBcnJheS5pc0FycmF5KHYyKSAmJiBVdGlscyQxLmVxdWFsQXJyYXlzKHYxLCB2Mik7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gdjEgPT09IHYyO1xuICAgICAgfVxuICAgIH1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aGlzLl9hbW91bnRSZW1haW5pbmcgLyB0b3RhbFNocmlua0Ftb3VudDtcbiAgICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICAgICAgY29uc3QgaXRlbSA9IGl0ZW1zW2ldO1xuICAgICAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuICAgICAgICAgICAgY29uc3Qgc2hyaW5rQW1vdW50ID0gZmxleEl0ZW0uc2hyaW5rO1xuICAgICAgICAgICAgY29uc3QgaXNTaHJpbmthYmxlSXRlbSA9IHNocmlua0Ftb3VudCA+IDA7XG4gICAgICAgICAgICBpZiAoaXNTaHJpbmthYmxlSXRlbSkge1xuICAgICAgICAgICAgICBsZXQgc2hyaW5rID0gc2hyaW5rQW1vdW50ICogYW1vdW50UGVyU2hyaW5rO1xuICAgICAgICAgICAgICBjb25zdCBtaW5TaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWluU2l6ZSgpO1xuICAgICAgICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuICAgICAgICAgICAgICBpZiAoc2l6ZSA+IG1pblNpemUpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBtYXhTaHJpbmsgPSBzaXplIC0gbWluU2l6ZTtcbiAgICAgICAgICAgICAgICBjb25zdCBpc0Z1bGx5U2hydW5rID0gc2hyaW5rID49IG1heFNocmluaztcbiAgICAgICAgICAgICAgICBpZiAoaXNGdWxseVNocnVuaykge1xuICAgICAgICAgICAgICAgICAgc2hyaW5rID0gbWF4U2hyaW5rO1xuICAgICAgICAgICAgICAgICAgdG90YWxTaHJpbmtBbW91bnQgLT0gc2hyaW5rQW1vdW50O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zdCBmaW5hbFNpemUgPSBzaXplIC0gc2hyaW5rO1xuICAgICAgICAgICAgICAgIGZsZXhJdGVtLl9yZXNpemVNYWluQXhpcyhmaW5hbFNpemUpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3NocnVua1NpemUgKz0gc2hyaW5rO1xuICAgICAgICAgICAgICAgIHRoaXMuX2Ftb3VudFJlbWFpbmluZyAtPSBzaHJpbms7XG4gICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPCAxZS01KSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IHdoaWxlICh0b3RhbFNocmlua0Ftb3VudCAmJiBNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpID4gMWUtNSk7XG4gICAgICB9XG4gICAgfVxuICAgIF9nZXRUb3RhbFNocmlua0Ftb3VudCgpIHtcbiAgICAgIGxldCB0b3RhbCA9IDA7XG4gICAgICBjb25zdCBpdGVtcyA9IHRoaXMuX2xpbmUuaXRlbXM7XG4gICAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07XG4gICAgICAgIGNvbnN0IGZsZXhJdGVtID0gaXRlbS5mbGV4SXRlbTtcbiAgICAgICAgaWYgKGZsZXhJdGVtLnNocmluaykge1xuICAgICAgICAgIGNvbnN0IG1pblNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNNaW5TaXplKCk7XG4gICAgICAgICAgY29uc3Qgc2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICBpZiAoc2l6ZSA+IG1pblNpemUpIHtcbiAgICAgICAgICAgIHRvdGFsICs9IGZ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W1vdW50ID4gMDtcbiAgICAgICAgICAgIGlmIChpc0dyb3dhYmxlSXRlbSkge1xuICAgICAgICAgICAgICBsZXQgZ3JvdyA9IGdyb3dBbW91bnQgKiBhbW91bnRQZXJHcm93O1xuICAgICAgICAgICAgICBjb25zdCBtYXhTaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWF4U2l6ZVNldHRpbmcoKTtcbiAgICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICAgICAgaWYgKG1heFNpemUgPiAwKSB7XG4gICAgICAgICAgICAgICAgaWYgKHNpemUgPj0gbWF4U2l6ZSkge1xuICAgICAgICAgICAgICAgICAgZ3JvdyA9IDA7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIGNvbnN0IG1heEdyb3cgPSBtYXhTaXplIC0gc2l6ZTtcbiAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRnVsbHlHcm93biA9IGdyb3cgPj0gbWF4R3JvdztcbiAgICAgICAgICAgICAgICAgIGlmIChpc0Z1bGx5R3Jvd24pIHtcbiAgICAgICAgICAgICAgICAgICAgZ3JvdyA9IG1heEdyb3c7XG4gICAgICAgICAgICAgICAgICAgIHRvdGFsR3Jvd0Ftb3VudCAtPSBncm93QW1vdW50O1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoZ3JvdyA+IDApIHtcbiAgICAgICAgICAgICAgICBjb25zdCBmaW5hbFNpemUgPSBzaXplICsgZ3JvdztcbiAgICAgICAgICAgICAgICBmbGV4SXRlbS5fcmVzaXplTWFpbkF4aXMoZmluYWxTaXplKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9ncm93blNpemUgKz0gZ3JvdztcbiAgICAgICAgICAgICAgICB0aGlzLl9hbW91bnRSZW1haW5pbmcgLT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AgICAgdGhpcy5pdGVtLmZsZXhJdGVtLl9yZXNldExheW91dFNpemUoKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMubWFpbkF4aXNTaXplID0gdGhpcy5fZ2V0TWFpbkF4aXNCYXNpcygpO1xuICAgICAgICB0aGlzLmNyb3NzQXhpc1NpemUgPSB0aGlzLl9nZXRDcm9zc0F4aXNCYXNpcygpO1xuICAgICAgfVxuICAgICAgdGhpcy5fcmVzaXppbmdNYWluQXhpcyA9IGZhbHNlO1xuICAgICAgdGhpcy5fcmVzaXppbmdDcm9zc0F4aXMgPSBmYWxzZTtcbiAgICAgIHRoaXMuX3NocnVuayA9IGZhbHNlO1xuICAgIH1cbiAgICBfbGF5b3V0QXhlcygpIHtcbiAgICAgIHRoaXMuX2xheW91dE1haW5BeGlzKCk7XG4gICAgICB0aGlzLl9sYXlvdXRDcm9zc0F4aXMoKTtcbiAgICB9XG4gICAgX2xheW91dE1haW5BeGlzKCkge1xuICAgICAgdGhpcy5fbGF5b3V0TGluZXMoKTtcbiAgICAgIHRoaXMuX2ZpdE1haW5BeGlzU2l6ZVRvQ29udGVudHMoKTtcbiAgICB9XG4gICAgX2xheW91dExpbmVzKCkge1xuICAgICAgdGhpcy5fbGluZUxheW91dGVyLmxheW91dExpbmVzKCk7XG4gICAgfVxuICAgIGdldCBfbGluZXMoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fbGluZUxheW91dGVyLmxpbmVzO1xuICAgIH1cbiAgICBfZml0TWFpbkF4aXNTaXplVG9Db250ZW50cygpIHtcbiAgICAgIGlmICghdGhpcy5fcmVzaXppbmdNYWluQXhpcykge1xuICAgICAgICBpZiAodGhpcy5pc01haW5BeGlzRml0VG9Db250ZW50cygpKSB7XG4gICAgICAgICAgdGhpcy5tYWluQXhpc1NpemUgPSB0aGlzLl9saW5lTGF5b3V0ZXIubWFpbkF4aXNDb250ZW50U2l6ZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBf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JldHVybjtcbiAgICAgIHRoaXMuX2dyb3cgPSBwYXJzZUludCh2KSB8fCAwO1xuICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgIH1cbiAgICBnZXQgc2hyaW5rKCkge1xuICAgICAgaWYgKHRoaXMuX3NocmluayA9PT0gRmxleEl0ZW0uU0hSSU5LX0FVVE8pIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2dldERlZmF1bHRTaHJpbmsoKTtcbiAgICAgIH1cbiAgICAgIHJldHVybiB0aGlzLl9zaHJpbms7XG4gICAgfVxuICAgIF9nZXREZWZhdWx0U2hyaW5rKCkge1xuICAgICAgaWYgKHRoaXMuaXRlbS5pc0ZsZXhFbmFibGVkKCkpIHtcbiAgICAgICAgcmV0dXJuIDE7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gMDtcbiAgICAgIH1cbiAgICB9XG4gICAgc2V0IHNocmluayh2KSB7XG4gICAgICBpZiAodGhpcy5fc2hyaW5rID09PSB2KVxuICAgICAgICByZXR1cm47XG4gICAgICB0aGlzLl9zaHJpbmsgPSBwYXJzZUludCh2KSB8fCAwO1xuICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgIH1cbiAgICBnZXQgYWxpZ25TZWxmKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2FsaWduU2VsZjtcbiAgICB9XG4gICAgc2V0IGFsaWduU2VsZih2KSB7XG4gICAgICBpZiAodGhpcy5fYWxpZ25TZWxmID09PSB2KVxuICAgICAgICByZXR1cm47XG4gICAgICBpZiAodiA9PT0gdm9pZCAwKSB7XG4gICAgICAgIHRoaXMuX2FsaWduU2VsZiA9IHZvaWQgMDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmIChGbGV4Q29udGFpbmVyLkFMSUdOX0lURU1TLmluZGV4T2YodikgPT09IC0xKSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5rbm93biBhbGlnblNlbGYsIG9wdGlvbnM6IFwiIC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h0ID0gdGhpcy5pc1pDb250ZXh0KCk7XG4gICAgICAgIGxldCBwcmV2UGFyZW50ID0gdGhpcy5fcGFyZW50O1xuICAgICAgICB0aGlzLl9wYXJlbnQgPSBwYXJlbnQ7XG4gICAgICAgIGlmICh0aGlzLl9sYXlvdXQgfHwgcGFyZW50ICYmIHBhcmVudC5pc0ZsZXhDb250YWluZXIoKSkge1xuICAgICAgICAgIHRoaXMubGF5b3V0LnNldFBhcmVudChwcmV2UGFyZW50LCBwYXJlbnQpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChwcmV2UGFyZW50KSB7XG4gICAgICAgICAgcHJldlBhcmVudC5zZXRIYXNSZW5kZXJVcGRhdGVzKDMpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3NldFJlY2FsYygxICsgMiArIDQpO1xuICAgICAgICBpZiAodGhpcy5fcGFyZW50KSB7XG4gICAgICAgICAgdGhpcy5fcGFyZW50Ll9zZXRIYXNVcGRhdGVzKCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChwYXJlbnQpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChwYXJlbnQgPyBwYXJlbnQuZmluZFpDb250ZXh0KCkgOiBudWxsKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocHJldklzWkNvbnRleHQgIT09IHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgaWYgKCF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgdGhpcy5kaXNhYmxlWkNvbnRleHQoKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5lbmFibGVaQ29udGV4dChwcmV2UGFyZW50LmZpbmRaQ29udGV4dCgpKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fekluZGV4UmVzb3J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0gbnVsbCkge1xuICAgICAgICAgIGlmICh0aGlzLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZGVjWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IG51bGwpIHtcbiAgICAgICAgICBsZXQgaGFkWkNvbnRleHRVc2FnZSA9IG5ld1pQYXJlbnQuX3pDb250ZXh0VXNhZ2UgPiAwO1xuICAgICAgICAgIGlmICh0aGlzLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICAgIG5ld1pQYXJlbnQuaW5jWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobmV3WlBhcmVudC5fekNvbnRleHRVc2FnZSA+IDApIHtcbiAgICAgICAgICAgIGlmICghaGFkWkNvbnRleHRVc2FnZSAmJiB0aGlzLl9wYXJlbnQgPT09IG5ld1pQYXJlbnQpXG4gICAgICAgICAgICAgIDtcbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICBuZXdaUGFyZW50Ll96SW5kZXhlZENoaWxkcmVuLnB1c2godGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBuZXdaUGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3pQYXJlbnQgPSBuZXdaUGFyZW50O1xuICAgICAgICB0aGlzLl96SW5kZXhSZXNvcnQgPSB0cnVlO1xuICAgICAgfVxuICAgIH1cbiAgICBpbmNaQ29udGV4dFVzYWdlKCkge1xuICAgICAgdGhpcy5fekNvbnRleHRVc2FnZSsrO1xuICAgICAgaWYgKHRoaXMuX3pDb250ZXh0VXNhZ2UgPT09IDEpIHtcbiAgICAgICAgaWYgKCF0aGlzLl96SW5kZXhlZENoaWxkcmVuKSB7XG4gICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbiA9IFtdO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuLnB1c2godGhpcy5fY2hpbGRyZW5baV0pO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGRlY1pDb250ZXh0VXNhZ2UoKSB7XG4gICAgICB0aGlzLl96Q29udGV4dFVzYWdlLS07XG4gICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSA9PT0gMCkge1xuICAgICAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuLnNwbGljZSgwKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IHpJbmRleCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl96SW5kZXg7XG4gICAgfVxuICAgIHNldCB6SW5kZXgoekluZGV4KSB7XG4gICAgICBpZiAodGhpcy5fekluZGV4ICE9PSB6SW5kZXgpIHtcbiAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKDEpO1xuICAgICAgICBsZXQgbmV3WlBhcmVudCA9IHRoaXMuX3pQYXJlbnQ7XG4gICAgICAgIGxldCBwcmV2SXNaQ29udGV4dCA9IHRoaXMuaXNaQ29udGV4dCgpO1xuICAgICAgICBpZiAoekluZGV4ID09PSAwICYmIHRoaXMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgIGlmICh0aGlzLl9wYXJlbnQgPT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZGVjWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBuZXdaUGFyZW50ID0gdGhpcy5fcGFyZW50O1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICh6SW5kZXggIT09IDAgJiYgdGhpcy5fekluZGV4ID09PSAwKSB7XG4gICAgICAgICAgbmV3WlBhcmVudCA9IHRoaXMuX3BhcmVudCA/IHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKSA6IG51bGw7XG4gICAgICAgICAgaWYgKG5ld1pQYXJlbnQgPT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuaW5jWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHpJbmRleCAhPT0gdGhpcy5fekluZGV4KSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQgJiYgdGhpcy5felBhcmVudC5fekNvbnRleHRVc2FnZSkge1xuICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAobmV3WlBhcmVudCAhPT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChudWxsKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl96SW5kZXggPSB6SW5kZXg7XG4gICAgICAgIGlmIChuZXdaUGFyZW50ICE9PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgdGhpcy5zZXRaUGFyZW50KG5ld1pQYXJlbnQpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChwcmV2SXNaQ29udGV4dCAhPT0gdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICBpZiAoIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICB0aGlzLmRpc2FibGVaQ29udGV4dCgpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmVuYWJsZVpDb250ZXh0KHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBmb3JjZVpJbmRleENvbnRleHQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fZm9yY2VaSW5kZXhDb250ZXh0O1xuICAgIH1cbiAgICBzZXQgZm9yY2VaSW5kZXhDb250ZXh0KHYpIHtcbiAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcygxKTtcbiAgICAgIGxldCBwcmV2SXNaQ29udGV4dCA9IHRoaXMuaXNaQ29udGV4dCgpO1xuICAgICAgdGhpcy5fZm9yY2VaSW5kZXhDb250ZXh0ID0gdjtcbiAgICAgIGlmIChwcmV2SXNaQ29udGV4dCAhPT0gdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgaWYgKCF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgIHRoaXMuZGlzYWJsZVpDb250ZXh0KCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5lbmFibGVaQ29udGV4dCh0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGVuYWJsZVpD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ICAgIGlmIChwdy50YyAhPT0gMClcbiAgICAgICAgICAgIHcucHkgKz0gdGhpcy5fbG9jYWxQeCAqIHB3LnRjO1xuICAgICAgICB9XG4gICAgICAgIGlmIChyZWNhbGMgJiA0KSB7XG4gICAgICAgICAgdy50YSA9IHRoaXMuX2xvY2FsVGEgKiBwdy50YTtcbiAgICAgICAgICB3LnRiID0gdGhpcy5fbG9jYWxUZCAqIHB3LnRiO1xuICAgICAgICAgIHcudGMgPSB0aGlzLl9sb2NhbFRhICogcHcudGM7XG4gICAgICAgICAgdy50ZCA9IHRoaXMuX2xvY2FsVGQgKiBwdy50ZDtcbiAgICAgICAgICBpZiAodGhpcy5faXNDb21wbGV4KSB7XG4gICAgICAgICAgICB3LnRhICs9IHRoaXMuX2xvY2FsVGMgKiBwdy50YjtcbiAgICAgICAgICAgIHcudGIgKz0gdGhpcy5fbG9jYWxUYiAqIHB3LnRhO1xuICAgICAgICAgICAgdy50YyArPSB0aGlzLl9sb2NhbFRjICogcHcudGQ7XG4gICAgICAgICAgICB3LnRkICs9IHRoaXMuX2xvY2FsVGIgKiBwdy50YztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgcHIgPSB0aGlzLl9wYXJlbnQuX3JlbmRlckNvbnRleHQ7XG4gICAgICAgIGlmICh0aGlzLl9wYXJlbnQuX2hhc1JlbmRlckNvbnRleHQoKSkge1xuICAgICAgICAgIGNvbnN0IGluaXQgPSB0aGlzLl9yZW5kZXJDb250ZXh0ID09PSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICAgICAgaWYgKGluaXQpIHtcbiAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBuZXcgRWxlbWVudENvcmVDb250ZXh0KCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnN0IHIyID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICAgICAgICBpZiAoaW5pdCB8fCByZWNhbGMgJiAxKSB7XG4gICAgICAgICAgICByMi5hbHBoYSA9IHByLmFscGhhICogdGhpcy5fbG9jYWxBbHBoYTtcbiAgICAgICAgICAgIGlmIChyMi5hbHBoYSA8IDFlLTE0KSB7XG4gICAgICAgICAgICAgIHIyLmFscGhhID0gMDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGluaXQgfHwgcmVjYWxjICYgNikge1xuICAgICAgICAgICAgcjIucHggPSBwci5weCArIHRoaXMuX2xvY2FsUHggKiBwci50YTtcbiAgICAgICAgICAgIHIyLnB5ID0gcHIucHkgKyB0aGlzLl9sb2NhbFB5ICogcHIudGQ7XG4gICAgICAgICAgICBpZiAocHIudGIgIT09IDApXG4gICAgICAgICAgICAgIHIyLnB4ICs9IHRoaXMuX2xvY2FsUHkgKiBwci50YjtcbiAgICAgICAgICAgIGlmIChwci50YyAhPT0gMClcbiAgICAgICAgICAgICAgcjIucHkgKz0gdGhpcy5fbG9jYWxQeCAqIHByLnRjO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaW5pdCkge1xuICAgICAgICAgICAgcmVjYWxjIHw9IDI7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChpbml0IHx8IHJlY2FsYyAmIDQpIHtcbiAgICAgICAgICAgIHIyLnRhID0gdGhpcy5fbG9jYWxUYSAqIHByLnRhO1xuICAgICAgICAgICAgcjIudGIgPSB0aGlzLl9sb2NhbFRkICogcHIudGI7XG4gICAgICAgICAgICByMi50YyA9IHRoaXMuX2xvY2FsVGEgKiBwci50YztcbiAgICAgICAgICAgIHIyLnRkID0gdGhpcy5fbG9jYWxUZCAqIHByLnRkO1xuICAgICAgICAgICAgaWYgKHRoaXMuX2lzQ29tcGxleCkge1xuICAgICAgICAgICAgICByMi50YSArPSB0aGlzLl9sb2NhbFRjICogcHIudGI7XG4gICAgICAgICAgICAgIHIyLnRiICs9IHRoaXMuX2xvY2FsVGIgKiBwci50YTtcbiAgICAgICAgICAgICAgcjIudGMgKz0gdGhpcy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cy5fZGltc1Vua25vd24gPyAyMDQ4IDogdGhpcy5fdztcbiAgICAgICAgY29uc3QgYmJveEggPSB0aGlzLl9kaW1zVW5rbm93biA/IDIwNDggOiB0aGlzLl9oO1xuICAgICAgICBsZXQgc3gsIHN5LCBleCwgZXk7XG4gICAgICAgIGNvbnN0IHJDb21wbGV4ID0gci50YiAhPT0gMCB8fCByLnRjICE9PSAwIHx8IHIudGEgPCAwIHx8IHIudGQgPCAwO1xuICAgICAgICBpZiAockNvbXBsZXgpIHtcbiAgICAgICAgICBzeCA9IE1hdGgubWluKDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICBleCA9IE1hdGgubWF4KDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICBzeSA9IE1hdGgubWluKDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICBleSA9IE1hdGgubWF4KDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBzeCA9IHIucHg7XG4gICAgICAgICAgZXggPSByLnB4ICsgci50YSAqIGJib3hXO1xuICAgICAgICAgIHN5ID0gci5weTtcbiAgICAgICAgICBleSA9IHIucHkgKyByLnRkICogYmJveEg7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX2RpbXNVbmtub3duICYmIChyQ29tcGxleCB8fCB0aGlzLl9sb2NhbFRhIDwgMSB8fCB0aGlzLl9sb2NhbFRiIDwgMSkpIHtcbiAgICAgICAgICBjb25zdCBueCA9IHRoaXMuX3ggKiBwci50YSArIHRoaXMuX3kgKiBwci50YiArIHByLnB4O1xuICAgICAgICAgIGNvbnN0IG55ID0gdGhpcy5feCAqIHByLnRjICsgdGhpcy5feSAqIHByLnRkICsgcHIucHk7XG4gICAgICAgICAgaWYgKG54IDwgc3gpXG4gICAgICAgICAgICBzeCA9IG54O1xuICAgICAgICAgIGlmIChueSA8IHN5KVxuICAgICAgICAgICAgc3kgPSBueTtcbiAgICAgICAgICBpZiAobnggPiBleClcbiAgICAgICAgICAgIGV4ID0gbng7XG4gICAgICAgICAgaWYgKG55ID4gZXkpXG4gICAgICAgICAgICBleSA9IG55O1xuICAgICAgICB9XG4gICAgICAgIGlmIChyZWNhbGMgJiA2IHx8ICF0aGlzLl9zY2lzc29yKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX2NsaXBwaW5nICYmIHIuaXNTcXVhcmUoKSkge1xuICAgICAgICAgICAgY29uc3QgYXJlYSA9IHRoaXMuX3BhcmVudC5fdXNlUmVuZGVyVG9UZXh0dXJlID8gdGhpcy5fcGFyZW50Ll92aWV3cG9ydCA6IHRoaXMuX3BhcmVudC5fc2Npc3NvcjtcbiAgICAgICAgICAgIGlmIChhcmVhKSB7XG4gICAgICAgICAgICAgIGNvbnN0IGx4ID0gTWF0aC5tYXgoYXJlYVswXSwgc3gpO1xuICAgICAgICAgICAgICBjb25zdCBseSA9IE1hdGgubWF4KGFyZWFbMV0sIHN5KTtcbiAgICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IFtcbiAgICAgICAgICAgICAgICBseCxcbiAgICAgICAgICAgICAgICBseSxcbiAgICAgICAgICAgICAgICBNYXRoLm1pbihhcmVhWzJdICsgYXJlYVswXSwgZXgpIC0gbHgsXG4gICAgICAgICAgICAgICAgTWF0aC5taW4oYXJlYVszXSArIGFyZWFbMV0sIGV5KSAtIGx5XG4gICAgICAgICAgICAgIF07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gW3N4LCBzeSwgZXggLSBzeCwgZXkgLSBzeV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSB0aGlzLl9wYXJlbnQuX3VzZVJlbmRlclRvVGV4dHVyZSA/IHRoaXMuX3BhcmVudC5fdmlld3BvcnQgOiB0aGlzLl9wYXJlbnQuX3NjaXNzb3I7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9ib3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICB0aGlzLl9yZWNCb3VuZHNNYXJnaW4gPSB0aGlzLl9ib3VuZHNNYXJnaW47XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fcmVjQm91bmRzTWFyZ2luID0gdGhpcy5fcGFyZW50Ll9yZWNCb3VuZHNNYXJnaW47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJDYWxjcykge1xuICAgICAgICAgIGlmICh0aGlzLl9vbkFmdGVyQ2FsY3ModGhpcy5lbGVtZW50KSkge1xuICAgICAgICAgICAgaWYgKHJDb21wbGV4KSB7XG4gICAgICAgICAgICAgIHN4ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgICBleCA9IE1hdGgubWF4KDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgICAgc3kgPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgICAgIGV5ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgc3ggPSByLnB4O1xuICAgICAgICAgICAgICBleCA9IHIucHggKyByLnRhICogYmJveFc7XG4gICAgICAgICAgICAgIHN5ID0gci5weTtcbiAgICAgICAgICAgICAgZXkgPSByLnB5ICsgci50ZCAqIGJib3hIO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX2RpbXNVbmtub3duICYmIChyQ29tcGxleCB8fCB0aGlzLl9sb2NhbFRhIDwgMSB8fCB0aGlzLl9sb2NhbFRiIDwgMSkpIHtcbiAgICAgICAgICAgICAgY29uc3QgbnggPSB0aGlzLl94ICogcHIudGEgKyB0aGlzLl95ICogcHIudGIgKyBwci5weDtcbiAgICAgICAgICAgICAgY29uc3QgbnkgPSB0aGlzLl94ICogcHIudGMgKyB0aGlzLl95ICogcHIudGQgKyBwci5weTtcbiAgICAgICAgICAgICAgaWYgKG54IDwgc3gpXG4gICAgICAgICAgICAgICAgc3ggPSBueDtcbiAgICAgICAgICAgICAgaWYgKG55IDwgc3kpXG4gICAgICAgICAgICAgICAgc3kgPSBueTtcbiAgICAgICAgICAgICAgaWYgKG54ID4gZXgpXG4gICAgICAgICAgICAgICAgZXggPSBueDtcbiAgICAgICAgICAgICAgaWYgKG55ID4gZXkpXG4gICAgICAgICAgICAgICAgZXkgPSBueTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3BhcmVudC5fb3V0T2ZCb3VuZHMgPT09IDIpIHtcbiAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDI7XG4gICAgICAgICAgaWYgKHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgdGhpcy5fd2l0aGluQm91bmRzTWFyZ2luID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2Rpc2FibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKHJlY2FsYyAmIDYpIHtcbiAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMDtcbiAgICAgICAgICAgIGxldCB3aXRoaW5NYXJnaW4gPSB0cnVlO1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkIHx8ICF0aGlzLl90ZXh0dXJpemVyIHx8ICF0aGlzLl90ZXh0dXJpemVyLnJlbmRlck9mZnNjcmVlbikge1xuICAgICAgICAgICAgICBpZiAodGhpcy5fc2Npc3NvciAmJiAodGhpcy5fc2Npc3NvclsyXSA8PSAwIHx8IHRoaXMuX3NjaXNzb3JbM10gPD0gMCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDI7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3NjaXNzb3JbMF0gPiBleCB8fCB0aGlzLl9zY2lzc29yWzFdID4gZXkgfHwgc3ggPiB0aGlzLl9zY2lzc29yWzBdICsgdGhpcy5fc2Npc3NvclsyXSB8fCBzeSA+IHRoaXMuX3NjaXNzb3JbMV0gKyB0aGlzLl9zY2lzc29yWzNdKSB7XG4gICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDE7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9vdXRPZkJvdW5kcykge1xuICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NsaXBwaW5nIHx8IHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSB8fCB0aGlzLl9jbGlwYm94ICYmIChiYm94VyAmJiBiYm94SCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cb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AgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gIT09IHdpdGhpbk1hcmdpbikge1xuICAgICAgICAgICAgICB0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gPSB3aXRoaW5NYXJnaW47XG4gICAgICAgICAgICAgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9oYXNVcGRhdGVzID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBjb25zdCByZWNhbGMyID0gdGhpcy5fcmVjYWxjO1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlY2FsYyA9IDA7XG4gICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9lbmFibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fcmVjYWxjKSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy51cGRhdGUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fcmVjYWxjID0gcmVjYWxjMjtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2Rpc2FibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3ZpZXdwb3J0KSB7XG4gICAgICAgICAgICB0aGlzLl92aWV3cG9ydFsyXSA9IGJib3hXO1xuICAgICAgICAgICAgdGhpcy5fdmlld3BvcnRbM10gPSBiYm94SDtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fdmlld3BvcnQgPSBbMCwgMCwgYmJveFcsIGJib3hIXTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fcFJlY2FsYyA9IHRoaXMuX3JlY2FsYyAmIDEzNTtcbiAgICAgICAgdGhpcy5fcmVjYWxjID0gMDtcbiAgICAgICAgdGhpcy5faGFzVXBkYXRlcyA9IGZhbHNlO1xuICAgICAgICBpZiAodGhpcy5fb3V0T2ZCb3VuZHMgPCAyKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3dvcmxkQ29udGV4dC5pc0lkZW50aXR5KCkpIHtcbiAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBFbGVtZW50Q29yZUNvbnRleHQuSURFTlRJVFk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSByO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbltpXS5faGFzVXBkYXRlcykge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZSgpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLl9yZWNhbGMgfD0gdGhpcy5fcFJlY2FsYztcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGVPdXRPZkJvdW5kcygpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9vbkFmdGVyVXBkYXRlKSB7XG4gICAgICAgICAgdGhpcy5fb25BZnRlclVwZGF0ZSh0aGlzLmVsZW1lbnQpO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAodGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID09PSAtMSB8fCB0aGlzLl91cGRhdGVUcmVlT3JkZXIgPj0gdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyKSB7XG4gICAgICAgICAgdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID0gLTE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy51cGRhdGVUcmVlT3JkZXIoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfYXBwbHlSZWxhdGl2ZURpbUZ1bmNzKCkge1xuICAgICAgaWYgKHRoaXMuX29wdEZsYWdzICYgMSkge1xuICAgICAgICBjb25zdCB4ID0gdGhpcy5fZnVuY1godGhpcy5fcGFyZW50LncpO1xuICAgICAgICBpZiAoeCAhPT0gdGhpcy5feCkge1xuICAgICAgICAgIHRoaXMuX2xvY2FsUHggKz0geCAtIHRoaXMuX3g7XG4gICAgICAgICAgdGhpcy5feCA9IHg7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9vcHRGbGFncyAmIDIpIHt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3VuZHMgPCAyICYmIHRoaXMuX3JlbmRlckNvbnRleHQuYWxwaGEpIHtcbiAgICAgICAgbGV0IHJlbmRlclN0YXRlID0gdGhpcy5yZW5kZXJTdGF0ZTtcbiAgICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzID09PSAwICYmIHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UpIHtcbiAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTaGFkZXIodGhpcy5hY3RpdmVTaGFkZXIsIHRoaXMuX3NoYWRlck93bmVyKTtcbiAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTY2lzc29yKHRoaXMuX3NjaXNzb3IpO1xuICAgICAgICAgIHRoaXMucmVuZGVyU3RhdGUuYWRkUXVhZCh0aGlzKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSkge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW5baV0uX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF9yZW5kZXJBZHZhbmNlZCgpIHtcbiAgICAgIGNvbnN0IGhhc1Jl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wLFxuICAgICAgICAgICAgICB3OiB0aGlzLl93LFxuICAgICAgICAgICAgICBoOiB0aGlzLl9oLFxuICAgICAgICAgICAgICBlbXB0eTogdHJ1ZSxcbiAgICAgICAgICAgICAgY2xlYXJlZDogZmFsc2UsXG4gICAgICAgICAgICAgIGlnbm9yZTogZmFsc2UsXG4gICAgICAgICAgICAgIGNhY2hlOiBmYWxzZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICh0aGlzLl90ZXh0dXJpemVyLmhhc1Jlc3VsdFRleHR1cmUoKSB8fCAhcmVuZGVyU3RhdGUuaXNDYWNoaW5nVGV4dHVyaXplciAmJiBoYXNSZW5kZXJVcGRhdGVzIDwgMykge1xuICAgICAgICAgICAgICByZW5kZXJUZXh0dXJlSW5mby5jYWNoZSA9IHRydWU7XG4gICAgICAgICAgICAgIHJlbmRlclN0YXRlLmlzQ2FjaGluZ1RleHR1cml6ZXIgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLmhhc1Jlc3VsdFRleHR1cmUoKSkge1xuICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnJlbGVhc2VSZW5kZXJUZXh0dXJlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRSZW5kZXJUZXh0dXJlSW5mbyhyZW5kZXJUZXh0dXJlSW5mbyk7XG4gICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTY2lzc29yKG51bGwpO1xuICAgICAgICAgICAgaWYgKHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UpIHtcbiAgICAgICAgICAgICAgbGV0IHIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gRWxlbWVudENvcmVDb250ZXh0LklERU5USVRZO1xuICAgICAgICAgICAgICB0aGlzLnJlbmRlclN0YXRlLmFk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VuZGVyKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgIGxldCB1cGRhdGVSZXN1bHRUZXh0dXJlID0gZmFsc2U7XG4gICAgICAgICAgaWYgKG11c3RSZW5kZXJDaGlsZHJlbikge1xuICAgICAgICAgICAgcmVuZGVyU3RhdGUuZmluaXNoZWRSZW5kZXJUZXh0dXJlKCk7XG4gICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLmVtcHR5ID0gcmVuZGVyVGV4dHVyZUluZm8uZW1wdHk7XG4gICAgICAgICAgICBpZiAocmVuZGVyVGV4dHVyZUluZm8uZW1wdHkpIHtcbiAgICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci5yZWxlYXNlUmVuZGVyVGV4dHVyZSgpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChyZW5kZXJUZXh0dXJlSW5mby5uYXRpdmVUZXh0dXJlKSB7XG4gICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmV1c2VUZXh0dXJlQXNSZW5kZXJUZXh0dXJlKHJlbmRlclRleHR1cmVJbmZvLm5hdGl2ZVRleHR1cmUpO1xuICAgICAgICAgICAgICByZW5kZXJUZXh0dXJlSW5mby5pZ25vcmUgPSB0cnVlO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgaWYgKHRoaXMuX3RleHR1cml6ZXIucmVuZGVyVGV4dHVyZVJldXNlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZVJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICByZW5kZXJUZXh0dXJlSW5mby5uYXRpdmVUZXh0dXJlID0gdGhpcy5fdGV4dHVyaXplci5nZXRSZW5kZXJUZXh0dXJlKCk7XG4gICAgIC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Ck7XG4gICAgICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5jb2xvcml6ZSlcbiAgICAgICAgICAgICAgICB0aGlzLl9zdGFzaENvbG9ycygpO1xuICAgICAgICAgICAgICB0aGlzLnJlbmRlclN0YXRlLmFkZFF1YWQodGhpcywgdHJ1ZSk7XG4gICAgICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5jb2xvcml6ZSlcbiAgICAgICAgICAgICAgICB0aGlzLl91bnN0YXNoQ29sb3JzKCk7XG4gICAgICAgICAgICAgIHRoaXMuX3Vuc3Rhc2hUZXhDb29yZHMoKTtcbiAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0VGV4dHVyaXplcihudWxsKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHJlbmRlclRleHR1cmVJbmZvICYmIHJlbmRlclRleHR1cmVJbmZvLmNhY2hlKSB7XG4gICAgICAgICAgcmVuZGVyU3RhdGUuaXNDYWNoaW5nVGV4dHVyaXplciA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGdldCB6U29ydCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl96U29ydDtcbiAgICB9XG4gICAgc29ydFpJbmRleGVkQ2hpbGRyZW4oKSB7XG4gICAgICBjb25zdCBuID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5sZW5ndGg7XG4gICAgICBsZXQgcHRyID0gMDtcbiAgICAgIGNvbnN0IGEgPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuO1xuICAgICAgY29uc3QgYiA9IFtdO1xuICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgaWYgKGFbaV0uX3pQYXJlbnQgPT09IHRoaXMpIHtcbiAgICAgICAgICBpZiAoYVtpXS5fekluZGV4UmVzb3J0KSB7XG4gICAgICAgICAgICBiLnB1c2goYVtpXSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChwdHIgIT09IGkpIHtcbiAgICAgICAgICAgICAgYVtwdHJdID0gYVtpXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHB0cisrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgY29uc3QgbSA9IGIubGVuZ3RoO1xuICAgICAgaWYgKG0pIHtcbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBtOyBqKyspIHtcbiAgICAgICAgICBiW2pdLl96SW5kZXhSZXNvcnQgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBiLnNvcnQoRWxlbWVudENvcmUuc29ydFpJbmRleGVkQ2hpbGRyZW4pO1xuICAgICAgICBjb25zdCBuMiA9IHB0cjtcbiAgICAgICAgaWYgKCFuMikge1xuICAgICAgICAgIHB0ciA9IDA7XG4gICAgICAgICAgbGV0IGogPSAwO1xuICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgIGFbcHRyKytdID0gYltqKytdO1xuICAgICAgICAgIH0gd2hpbGUgKGogPCBtKTtcbiAgICAgICAgICBpZiAoYS5sZW5ndGggPiBwdHIpIHtcbiAgICAgICAgICAgIGEuc3BsaWNlKHB0cik7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHB0ciA9IDA7XG4gICAgICAgICAgbGV0IGkgPSAwO1xuICAgICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgICBjb25zdCBtZXJnZVJlc3VsdCA9IFtdO1xuICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgIGNvbnN0IHYgPSBhW2ldLl96SW5kZXggPT09IGJbal0uX3pJbmRleCA/IGFbaV0uX3VwZGF0ZVRyZWVPcmRlciAtIGJbal0uX3VwZGF0ZVRyZWVPcmRlciA6IGFbaV0uX3pJbmRleCAtIGJbal0uX3pJbmRleDtcbiAgICAgICAgICAgIGNvbnN0IGFkZCA9IHYgPiAwID8gYltqKytdIDogYVtpKytdO1xuICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCBtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkKSB7XG4gICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpID49IG4yKSB7XG4gICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICBjb25zdCBhZGQyID0gYltqKytdO1xuICAgICAgICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgbWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZDIpIHtcbiAgICAgICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IHdoaWxlIChqIDwgbSk7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChqID49IG0pIHtcbiAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIGNvbnN0IGFkZDIgPSBhW2krK107XG4gICAgICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCBtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkMikge1xuICAgICAgICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkMjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0gd2hpbGUgKGkgPCBuMik7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gd2hpbGUgKHRydWUpO1xuICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4gPSBtZXJnZVJlc3VsdDtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKGEubGVuZ3RoID4gcHRyKSB7XG4gICAgICAgICAgYS5zcGxpY2UocHRyKTtcbiAgICAgIC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ICAgIHcucHggKyB0aGlzLl9oICogdy50YixcbiAgICAgICAgdy5weSArIHRoaXMuX2ggKiB3LnRkXG4gICAgICBdO1xuICAgIH1cbiAgICBnZXRSZW5kZXJUZXh0dXJlQ29vcmRzKHJlbFgsIHJlbFkpIHtcbiAgICAgIGxldCByID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICAgIHJldHVybiBbXG4gICAgICAgIHIucHggKyByLnRhICogcmVsWCArIHIudGIgKiByZWxZLFxuICAgICAgICByLnB5ICsgci50YyAqIHJlbFggKyByLnRkICogcmVsWVxuICAgICAgXTtcbiAgICB9XG4gICAgZ2V0QWJzb2x1dGVDb29yZHMocmVsWCwgcmVsWSkge1xuICAgICAgbGV0IHcgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgcmV0dXJuIFtcbiAgICAgICAgdy5weCArIHcudGEgKiByZWxYICsgdy50YiAqIHJlbFksXG4gICAgICAgIHcucHkgKyB3LnRjICogcmVsWCArIHcudGQgKiByZWxZXG4gICAgICBdO1xuICAgIH1cbiAgICBjb2xsZWN0QXRDb29yZCh4LCB5LCBjaGlsZHJlbikge1xuICAgICAgaWYgKHRoaXMuX3JlbmRlckNvbnRleHQuYWxwaGEgPT09IDApIHtcbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuaW5Cb3VuZCh4LCB5KSkge1xuICAgICAgICBpZiAodGhpcy5fc2Npc3Nvcikge1xuICAgICAgICAgIGlmICh0aGlzLmluU2Npc3NvcigpKSB7XG4gICAgICAgICAgICBjaGlsZHJlbi5wdXNoKHRoaXMpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjaGlsZHJlbi5wdXNoKHRoaXMpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgY29uc3QgaiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDtcbiAg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xuICAgICAgICB0aGlzLmJlY29tZXNVbnVzZWQoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgYmVjb21lc1VzZWQoKSB7XG4gICAgICBpZiAodGhpcy5zb3VyY2UpIHtcbiAgICAgICAgdGhpcy5zb3VyY2UuaW5jQWN0aXZlVGV4dHVyZUNvdW50KCk7XG4gICAgICB9XG4gICAgfVxuICAgIG9uTG9hZCgpIHtcbiAgICAgIGlmICh0aGlzLl9yZXNpemVNb2RlKSB7XG4gICAgICAgIHRoaXMuX2FwcGx5UmVzaXplTW9kZSgpO1xuICAgICAgfVxuICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKChlbGVtZW50KSA9PiB7XG4gICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgIGVsZW1lbnQub25UZXh0dXJlU291cmNlTG9hZGVkKCk7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cbiAgICBfY2hlY2tGb3JOZXdlclJldXNhYmxlVGV4dHVyZVNvdXJjZSgpIHtcbiAgICAgIGNvbnN0IHNvdXJjZSA9IHRoaXMuc291cmNlO1xuICAgICAgaWYgKCFzb3VyY2UuaXNMb2FkZWQoKSkge1xuICAgICAgICBjb25zdCByZXVzYWJsZSA9IHRoaXMuX2dldFJldXNhYmxlVGV4dHVyZVNvdXJjZSgpO1xuICAgICAgICBpZiAocmV1c2FibGUgJiYgcmV1c2FibGUuaXNMb2FkZWQoKSAmJiByZXVzYWJsZSAhPT0gc291cmNlKSB7XG4gICAgICAgICAgdGhpcy5fcmVwbGFjZVRleHR1cmVTb3VyY2UocmV1c2FibGUpO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAodGhpcy5fcmVzaXplTW9kZSkge1xuICAgICAgICAgIHRoaXMuX2FwcGx5UmVzaXplTW9kZSgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGJlY29tZXNVbnVzZWQoKSB7XG4gICAgICBpZiAod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NlKTtcbiAgICAgIH1cbiAgICB9XG4gICAgX2dldFRleHR1cmVTb3VyY2UoKSB7XG4gICAgICBsZXQgc291cmNlID0gbnVsbDtcbiAgICAgIGlmICh0aGlzLl9nZXRJc1ZhbGlkKCkpIHtcbiAgICAgICAgY29uc3QgbG9va3VwSWQgPSB0aGlzLl9nZXRMb29rdXBJZCgpO1xuICAgICAgICBzb3VyY2UgPSB0aGlzLl9nZXRSZXVzYWJsZVRleHR1cmVTb3VyY2UobG9va3VwSWQpO1xuICAgICAgICBpZiAoIXNvdXJjZSkge1xuICAgICAgICAgIHNvdXJjZSA9IHRoaXMubWFuYWdlci5nZXRUZXh0dXJlU291cmNlKHRoaXMuX2dldFNvdXJjZUxvYWRlcigpLCBsb29rdXBJZCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBzb3VyY2U7XG4gICAgfVxuICAgIF9nZXRSZXVzYWJsZVRleHR1cmVTb3VyY2UobG9va3VwSWQgPSB0aGlzLl9nZXRMb29rdXBJZCgpKSB7XG4gICAgICBpZiAodGhpcy5fZ2V0SXNWYWxpZCgpKSB7XG4gICAgICAgIGlmIChsb29rdXBJZCkge1xuICAgICAgICAgIHJldHVybiB0aGlzLm1hbmFnZXIuZ2V0UmV1c2FibGVUZXh0dXJlU291cmNlKGxvb2t1cElkKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIG51bGw7XG4gICAgfVxuICAgIF9yZXBsYWNlVGV4dHVyZVNvdXJjZShuZXdTb3VyY2UgPSBudWxsKSB7XG4gICAgICBsZXQgb2xkU291cmNlID0gdGhpcy5fc291cmNlO1xuICAgICAgdGhpcy5fc291cmNlID0gbmV3U291cmNlO1xuICAgICAgaWYgKHRoaXMuZWxlbWVudHMuc2l6ZSkge1xuICAgICAgICBpZiAob2xkU291cmNlKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX2FjdGl2ZUNvdW50KSB7XG4gICAgICAgICAgICBvbGRTb3VyY2UuZGVjQWN0aXZlVGV4dHVyZUNvdW50KCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIG9sZFNvdXJjZS5yZW1vdmVUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgIGlmICh0aGlzW1widGV4dFwiXSAmJiAhb2xkU291cmNlLmlzVXNlZCgpKSB7XG4gICAgICAgICAgICB0aGlzLm1hbmFnZXIuZnJlZVRleHR1cmVTb3VyY2Uob2xkU291cmNlKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG5ld1NvdXJjZSkge1xuICAgICAgICAgIG5ld1NvdXJjZS5hZGRUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgIGlmICh0aGlzLl9hY3RpdmVDb3VudCkge1xuICAgICAgICAgICAgbmV3U291cmNlLmluY0FjdGl2ZVRleHR1cmVDb3VudCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHRoaXMuaXNVc2VkKCkpIHtcbiAgICAgICAgaWYgKG5ld1NvdXJjZSkge1xuICAgICAgICAgIGlmIChuZXdTb3VyY2UuaXNMb2FkZWQoKSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3Jlc2l6ZU1vZGUpIHtcbiAgICAgICAgICAgICAgdGhpcy5fYXBwbHlSZXNpemVNb2RlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goKGVsZW1lbnQpID0+IHtcbiAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5fc2V0RGlzcGxheWVkVGV4dHVyZSh0aGlzKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnN0IGxvYWRFcnJvciA9IG5ld1NvdXJjZS5sb2FkRXJyb3I7XG4gICAgICAgICAgICBpZiAobG9hZEVycm9yKSB7XG4gICAgICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaCgoZWxlbWVudCkgPT4ge1xuICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgZWxlbWVudC5vblRleHR1cmVTb3VyY2VMb2FkRXJyb3IobG9hZEVycm9yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goKGVsZW1lbnQpID0+IHtcbiAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICBlbGVtZW50Ll9zZXREaXNwbGF5ZWRUZXh0dXJlKG51bGwpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGxvYWQoKSB7XG4gICAgICBpZiAodGhpcy5zb3VyY2UpIHtcbiAgICAgICAgaWYgKCF0aGlzLmlzTG9hZGVkKCkpIHtcbiAgICAgICAgICB0aGlzLnNvdXJjZS5sb2FkKHRydWUpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGlzTG9hZGVkKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3NvdXJjZSAmJiB0aGlzLl9zb3VyY2UuaXNMb2FkZWQoKTtcbiAgICB9XG4gICAgZ2V0IGxvYWRFcnJvcigpIHtcbiAgICAgIHJldHVybiB0aGlzLl9zb3VyY2UgJiYgdGhpcy5fc291cmNlLmxvYWRFcnJvcjtcbiAgICB9XG4gICAgZnJlZSgpIHtcbiAgICAgIGlmICh0aGlzLl9zb3VyY2UpIHtcbiAgICAgICAgdGhpcy5fc291cmNlLmZyZWUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgc2V0IHJlc2l6ZU1vZGUoeyB0eXBlID0gXC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PSAhISh0aGlzLl94IHx8IHRoaXMuX3kgfHwgdGhpcy5fdyB8fCB0aGlzLl9oKTtcbiAgICAgIGxldCBzZWxmMiA9IHRoaXM7XG4gICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goZnVuY3Rpb24oZWxlbWVudCkge1xuICAgICAgICBpZiAoZWxlbWVudC5kaXNwbGF5ZWRUZXh0dXJlID09PSBzZWxmMikge1xuICAgICAgICAgIGVsZW1lbnQub25EaXNwbGF5ZWRUZXh0dXJlQ2xpcHBpbmdDaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlUHJlY2lzaW9uKCkge1xuICAgICAgbGV0IHNlbGYyID0gdGhpcztcbiAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaChmdW5jdGlvbihlbGVtZW50KSB7XG4gICAgICAgIGlmIChlbGVtZW50LmRpc3BsYXllZFRleHR1cmUgPT09IHNlbGYyKSB7XG4gICAgICAgICAgZWxlbWVudC5vblByZWNpc2lvbkNoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuICAgIGdldE5vbkRlZmF1bHRzKCkge1xuICAgICAgbGV0IG5vbkRlZmF1bHRzID0ge307XG4gICAgICBub25EZWZhdWx0c1tcInR5cGVcIl0gPSB0aGlzLmNvbnN0cnVjdG9yLm5hbWU7XG4gICAgICBpZiAodGhpcy54ICE9PSAwKVxuICAgICAgICBub25EZWZhdWx0c1tcInhcIl0gPSB0aGlzLng7XG4gICAgICBpZiAodGhpcy55ICE9PSAwKVxuICAgICAgICBub25EZWZhdWx0c1tcInlcIl0gPSB0aGlzLnk7XG4gICAgICBpZiAodGhpcy53ICE9PSAwKVxuICAgICAgICBub25EZWZhdWx0c1tcIndcIl0gPSB0aGlzLnc7XG4gICAgICBpZiAodGhpcy5oICE9PSAwKVxuICAgICAgICBub25EZWZhdWx0c1tcImhcIl0gPSB0aGlzLmg7XG4gICAgICBpZiAod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gICAgICB0aGlzLl9zdGFnZS5nZXRPcHRpb24oXCJkZWZhdWx0Rm9udEZhY2VcIilcbiAgICAgICk7XG4gICAgICB0aGlzLl9jb250ZXh0LnRleHRCYXNlbGluZSA9IHRoaXMuX3NldHRpbmdzLnRleHRCYXNlbGluZTtcbiAgICB9XG4gICAgX2xvYWQoKSB7XG4gICAgICBpZiAoVXRpbHMkMS5pc1dlYiAmJiBkb2N1bWVudC5mb250cykge1xuICAgICAgICBjb25zdCBmb250U2V0dGluZyA9IGdldEZvbnRTZXR0aW5nKFxuICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRGYWNlLFxuICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTdHlsZSxcbiAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U2l6ZSxcbiAgICAgICAgICB0aGlzLmdldFByZWNpc2lvbigpLFxuICAgICAgICAgIHRoaXMuX3N0YWdlLmdldE9wdGlvbihcImRlZmF1bHRGb250RmFjZVwiKVxuICAgICAgICApO1xuICAgICAgICB0cnkge1xuICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuZm9udHMubG9hZChmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkuY2F0Y2goKGVycikgPT4ge1xuICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBGb250IGxvYWQgZXJyb3JcIiwgZXJyLCBmb250U2V0dGluZyk7XG4gICAgICAgICAgICB9KS50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBGb250IG5vdCBmb3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GggPiAxID8gYWwubFsxXSA6IFwiXCJdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG90aGVyTGluZXMgPSBbXCJcIl07XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGksIG4gPSBsaW5lcy5sZW5ndGg7XG4gICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgbGV0IG0gPSBsaW5lc0luZm8ubi5sZW5ndGg7XG4gICAgICAgIGZvciAoaSA9IHRoaXMuX3NldHRpbmdzLm1heExpbmVzOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgb3RoZXJMaW5lc1tqXSArPSAob3RoZXJMaW5lc1tqXSA/IFwiIFwiIDogXCJcIikgKyBsaW5lc1tpXTtcbiAgICAgICAgICBpZiAoaSArIDEgPCBtICYmIGxpbmVzSW5mby5uW2kgKyAxXSkge1xuICAgICAgICAgICAgaisrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZW5kZXJJbmZvLnJlbWFpbmluZ1RleHQgPSBvdGhlckxpbmVzLmpvaW4oXCJcXG5cIik7XG4gICAgICAgIHJlbmRlckluZm8ubW9yZVRleHRMaW5lcyA9IHRydWU7XG4gICAgICAgIGxpbmVzID0gdXNlZExpbmVzO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmVuZGVySW5mby5tb3JlVGV4dExpbmVzID0gZmFsc2U7XG4gICAgICAgIHJlbmRlckluZm8ucmVtYWluaW5nVGV4dCA9IFwiXCI7XG4gICAgICB9XG4gICAgICBsZXQgbWF4TGluZVdpZHRoID0gMDtcbiAgICAgIGxldCBsaW5lV2lkdGhzID0gW107XG4gICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpbmVzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgIGxldCBsaW5lV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KGxpbmVzW2ldLCBsZXR0ZXJTcGFjaW5nKSArIChpID09PSAwID8gdGV4dEluZGVudCA6IDApO1xuICAgICAgICBsaW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V4dEluZGVudCA6IDA7XG4gICAgICAgIGxpbmVQb3NpdGlvblkgPSBpICogcmVuZGVySW5mby5saW5lSGVpZ2h0ICsgcmVuZGVySW5mby5vZmZzZXRZO1xuICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MudmVydGljYWxBbGlnbiA9PSBcIm1pZGRsZVwiKSB7XG4gICAgICAgICAgbGluZVBvc2l0aW9uWSArPSAocmVuZGVySW5mby5saW5lSGVpZ2h0IC0gcmVuZGVySW5mby5mb250U2l6ZSkgLyAyO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX3NldHRpbmdzLnZlcnRpY2FsQWxpZ24gPT0gXCJib3R0b21cIikge1xuICAgICAgICAgIGxpbmVQb3NpdGlvblkgKz0gcmVuZGVySW5mby5saW5lSGVpZ2h0IC0gcmVuZGVySW5mby5mb250U2l6ZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MudGV4dEFsaWduID09PSBcInJpZ2h0XCIpIHtcbiAgICAgICAgICBsaW5lUG9zaXRpb25YICs9IHJlbmRlckluZm8uaW5uZXJXaWR0aCAtIHJlbmRlckluZm8ubGluZVdpZHRoc1tpXTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9zZXR0aW5ncy50ZXh0QWxpZ24gPT09IFwiY2VudGVyXCIpIHtcbiAgICAgICAgICBsaW5lUG9zaXRpb25YICs9IChyZW5kZXJJbmZvLmlubmVyV2lkdGggLSByZW5kZXJJbmZvLmxpbmVXaWR0aHNbaV0pIC8gMjtcbiAgICAgICAgfVxuICAgICAgICBsaW5lUG9zaXRpb25YICs9IHJlbmRlckluZm8ucGFkZGluZ0xlZnQ7XG4gICAgICAgIGRyYXdMaW5lcy5wdXNoKHsgdGV4dDogcmVuZGVySW5mby5saW5lc1tpXSwgeDogbGluZVBvc2l0aW9uWCwgeTogbGluZVBvc2l0aW9uWSwgdzogcmVuZGVySW5mby5saW5lV2lkdGhzW2ldIH0pO1xuICAgICAgfV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5nZXRPcHRpb24oXCJkZWZhdWx0Rm9udEZhY2VcIilcbiAgICAgICAgKTtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBpZiAoIWRvY3VtZW50LmZvbnRzLmNoZWNrKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmZvbnRzLmxvYWQoZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpLmNhdGNoKChlcnIpID0+IHtcbiAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiRm9udCBsb2FkIGVycm9yXCIsIGVyciwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgfSkudGhlbigoKSA9PiB7XG4gICAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiRm9udCBub3QgZm91bmRcIiwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICBjb25zb2xlLndhcm4oXCJDYW4ndCBjaGVjayBmb250IGxvYWRpbmcgZm9yIFwiICsgZm9udFNldHRpbmcpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGRyYXcoKSB7XG4gICAgICBjb25zdCBsb2FkUHJvbWlzZSA9IHRoaXMuX2xvYWQoKTtcbiAgICAgIGlmICghbG9hZFByb21pc2UpIHtcbiAgICAgICAgcmV0dXJuIFV0aWxzJDEuaXNTcGFyayA/IHRoaXMuX3N0YWdlLnBsYXRmb3JtLmRyYXdUZXh0KHRoaXMpIDogdGhpcy5fZHJhdygpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIGxvYWRQcm9taXNlLnRoZW4oKCk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ZGluZ0xlZnQ7XG4gICAgICAgICAgbGluZU5vICs9IDE7XG4gICAgICAgIH1cbiAgICAgICAgdC5saW5lTm8gPSBsaW5lTm87XG4gICAgICAgIGlmICh0LnRleHQgPT0gXCJcXG5cIikge1xuICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICB9XG4gICAgICAgIHQueCA9IHg7XG4gICAgICAgIHggKz0gdC53aWR0aDtcbiAgICAgIH1cbiAgICAgIHJlbmRlckluZm8ubGluZU51bSA9IGxpbmVObyArIDE7XG4gICAgICBpZiAodGhpcy5fc2V0dGluZ3MuaCkge1xuICAgICAgICByZW5kZXJJbmZvLmggPSB0aGlzLl9zZXR0aW5ncy5oO1xuICAgICAgfSBlbHNlIGlmIChyZW5kZXJJbmZvLm1heExpbmVzICYmIHJlbmRlckluZm8ubWF4TGluZXMgPCByZW5kZXJJbmZvLmxpbmVOdW0pIHtcbiAgICAgICAgcmVuZGVySW5mby5oID0gcmVuZGVySW5mby5tYXhMaW5lcyAqIHJlbmRlckluZm8ubGluZUhlaWdodCArIGZvbnRTaXplIC8gMjtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJlbmRlckluZm8uaCA9IHJlbmRlckluZm8ubGluZU51bSAqIHJlbmRlckluZm8ubGluZUhlaWdodCArIGZvbnRTaXplIC8gMjtcbiAgICAgIH1cbiAgICAgIGNvbnN0IGJhc2VsaW5lT2Zmc2V0SW5QeCA9IHJlbmRlckluZm8uZm9udEJhc2VsaW5lUmF0aW8gKiByZW5kZXJJbmZvLmZvbnRTaXplO1xuICAgICAgbGV0IHZhT2Zmc2V0ID0gMDtcbiAgICAgIGlmIChyZW5kZXJJbmZvLnZlcnRpY2FsQWxpZ24gPT0gXCJ0b3BcIiAmJiB0aGlzLl9jb250ZXh0LnRleHRCYXNlbGluZSA9PSBcImFscGhhYmV0aWNcIikge1xuICAgICAgICB2YU9mZnNldCA9IC1iYXNlbGluZU9mZnNldEluUHg7XG4gICAgICB9IGVsc2UgaWYgKHJlbmRlckluZm8udmVydGljYWxBbGlnbiA9PSBcIm1pZGRsZVwiKSB7XG4gICAgICAgIHZhT2Zmc2V0ID0gKHJlbmRlckluZm8ubGluZUhlaWdodCAtIHJlbmRlckluZm8uZm9udFNpemUgLSBiYXNlbGluZU9mZnNldEluUHgpIC8gMjtcbiAgICAgIH0gZWxzZSBpZiAodGhpcy5fc2V0dGluZ3MudmVydGljYWxBbGlnbiA9PSBcImJvdHRvbVwiKSB7XG4gICAgICAgIHZhT2Zmc2V0ID0gcmVuZGVySW5mby5saW5lSGVpZ2h0IC0gcmVuZGVySW5mby5mb250U2l6ZTtcbiAgICAgIH1cbiAgICAgIHJlbmRlckluZm8ubGluZXMgPSBbXTtcbiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcmVuZGVySW5mby5saW5lTnVtOyBpKyspIHtcbiAgICAgICAgcmVuZGVySW5mby5saW5lc1tpXSA9IHtcbiAgICAgICAgICB3aWR0aDogMCxcbiAgICAgICAgICB4OiAwLFxuICAgICAgICAgIHk6IHJlbmRlckluZm8ubGluZUhlaWdodCAqIGkgKyB2YU9mZnNldCxcbiAgICAgICAgICB0ZXh0OiBbXVxuICAgICAgICB9O1xuICAgICAgfVxuICAgICAgZm9yIChsZXQgdCBvZiB0ZXh0KSB7XG4gICAgICAgIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnRleHQucHVzaCh0KTtcbiAgICAgIH1cbiAgICAgIGZvciAoY29uc3QgbCBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgIGlmIChsLnRleHQubGVuZ3RoID09IDApIHtcbiAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBmaXJzdFdvcmQgPSBsLnRleHRbMF0udGV4dDtcbiAgICAgICAgY29uc3QgbGFzdFdvcmQgPSBsLnRleHRbbC50ZXh0Lmxlbmd0aCAtIDFdLnRleHQ7XG4gICAgICAgIGlmIChmaXJzdFdvcmQgPT0gXCJcXG5cI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ubGV0dGVyU3BhY2luZywgcmVuZGVySW5mby5iYXNlRm9udCk7XG4gICAgICAgIGZvciAoY29uc3QgcyBvZiBzdWZmaXgpIHtcbiAgICAgICAgICBzLmxpbmVObyA9IGluZGV4O1xuICAgICAgICAgIHMueCA9IDA7XG4gICAgICAgICAgbGFzdExpbmVUZXh0LnB1c2gocyk7XG4gICAgICAgIH1cbiAgICAgICAgY29uc3Qgc3BsID0gc3VmZml4Lmxlbmd0aCArIDE7XG4gICAgICAgIGxldCBfdyA9IGxhc3RMaW5lVGV4dC5yZWR1Y2UoKGFjYywgdCkgPT4gYWNjICsgdC53aWR0aCwgMCk7XG4gICAgICAgIHdoaWxlIChfdyA+IHJlbmRlckluZm8ud2lkdGggfHwgaXNTcGFjZShsYXN0TGluZVRleHRbbGFzdExpbmVUZXh0Lmxlbmd0aCAtIHNwbF0udGV4dCkpIHtcbiAgICAgICAgICBsYXN0TGluZVRleHQuc3BsaWNlKGxhc3RMaW5lVGV4dC5sZW5ndGggLSBzcGwsIDEpO1xuICAgICAgICAgIF93ID0gbGFzdExpbmVUZXh0LnJlZHVjZSgoYWNjLCB0KSA9PiBhY2MgKyB0LndpZHRoLCAwKTtcbiAgICAgICAgICBpZiAobGFzdExpbmVUZXh0Lmxlbmd0aCA8IHNwbCkge1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMuYWxpZ25MaW5lKGxhc3RMaW5lVGV4dCwgbGFzdExpbmVUZXh0WzBdLngpO1xuICAgICAgICByZW5kZXJJbmZvLmxpbmVzW2luZGV4XS50ZXh0ID0gbGFzdExpbmVUZXh0O1xuICAgICAgICByZW5kZXJJbmZvLmxpbmVzW2luZGV4XS53aWR0aCA9IF93O1xuICAgICAgfVxuICAgICAgaWYgKHJlbmRlckluZm8udGV4dEFsaWduID09IFwiY2VudGVyXCIpIHtcbiAgICAgICAgZm9yIChsZXQgbCBvZiByZW5kZXJJbmZvLmxpbmVzKS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W5lcyAmJiB0LmxpbmVObyA+PSByZW5kZXJJbmZvLm1heExpbmVzKSB7XG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHQuY29sb3IgIT0gY3VycmVudENvbG9yKSB7XG4gICAgICAgICAgICBjdXJyZW50Q29sb3IgPSB0LmNvbG9yO1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsU3R5bGUgPSBjdXJyZW50Q29sb3I7XG4gICAgICAgICAgfVxuICAgICAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IHQuZm9udFN0eWxlO1xuICAgICAgICAgIGlmICh0LmxldHRlcnMpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGwgb2YgdC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICAgIGNvbnN0IF94ID0gcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueCArIHQueCArIGx4O1xuICAgICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KGwudGV4dCwgX3gsIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnkgKyByZW5kZXJJbmZvLmZvbnRTaXplKTtcbiAgICAgICAgICAgICAgbHggKz0gbC53aWR0aDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3QgX3ggPSByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS54ICsgdC54O1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsVGV4dCh0LnRleHQsIF94LCByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS55ICsgcmVuZGVySW5mby5mb250U2l6ZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAocHJldlNoYWRvd1NldHRpbmdzKSB7XG4gICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Q29sb3IgPSBwcmV2U2hhZG93U2V0dGluZ3NbMF07XG4gICAgICAgIHRo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ICAgbGV0IGl0YWxpYyA9IDA7XG4gICAgICBsZXQgYm9sZCA9IDA7XG4gICAgICBsZXQgY29sb3JTdGFjayA9IFtTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodGhpcy5fc2V0dGluZ3MudGV4dENvbG9yKV07XG4gICAgICBsZXQgY29sb3IgPSAwO1xuICAgICAgY29uc3QgY29sb3JSZWdleHAgPSAvPGNvbG9yPSgwW3hYXVswLTlhLWZBLUZdezh9KT4vO1xuICAgICAgcmV0dXJuIHRva2Vucy5tYXAoKHQpID0+IHtcbiAgICAgICAgaWYgKHQgPT0gXCI8aT5cIikge1xuICAgICAgICAgIGl0YWxpYyArPSAxO1xuICAgICAgICAgIHQgPSBcIlwiO1xuICAgICAgICB9IGVsc2UgaWYgKHQgPT0gXCI8L2k+XCIgJiYgaXRhbGljID4gMCkge1xuICAgICAgICAgIGl0YWxpYyAtPSAxO1xuICAgICAgICAgIHQgPSBcIlwiO1xuICAgICAgICB9IGVsc2UgaWYgKHQgPT0gXCI8Yj5cIikge1xuICAgICAgICAgIGJvbGQgKz0gMTtcbiAgICAgICAgICB0ID0gXCJcIjtcbiAgICAgICAgfSBlbHNlIGlmICh0ID09IFwiPC9iPlwiICYmIGJvbGQgPiAwKSB7XG4gICAgICAgICAgYm9sZCAtPSAxO1xuICAgICAgICAgIHQgPSBcIlwiO1xuICAgICAgICB9IGVsc2UgaWYgKHQgPT0gXCI8L2NvbG9yPlwiKSB7XG4gICAgICAgICAgaWYgKGNvbG9yU3RhY2subGVuZ3RoID4gMSkge1xuICAgICAgICAgICAgY29sb3IgLT0gMTtcbiAgICAgICAgICAgIGNvbG9yU3RhY2sucG9wKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHQgPSBcIlwiO1xuICAgICAgICB9IGVsc2UgaWYgKGNvbG9yUmVnZXhwLnRlc3QodCkpIHtcbiAgICAgICAgICBjb25zdCBtYXRjaGVkID0gY29sb3JSZWdleHAuZXhlYyh0KTtcbiAgICAgICAgICBjb2xvclN0YWNrLnB1c2goXG4gICAgICAgICAgICBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcocGFyc2VJbnQobWF0Y2hlZFsxXSkpXG4gICAgICAgICAgKTtcbiAgICAgICAgICBjb2xvciArPSAxO1xuICAgICAgICAgIHQgPSBcIlwiO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgdGV4dDogdCxcbiAgICAgICAgICBpdGFsaWMsXG4gICAgICAgICAgYm9sZCxcbiAgICAgICAgICBjb2xvcjogY29sb3JTdGFja1tjb2xvcl1cbiAgICAgICAgfTtcbiAgICAgIH0pLmZpbHRlcigobykgPT4gby50ZXh0ICE9IFwiXCIpO1xuICAgIH1cbiAgICBhcHBseUZvbnRTdHlsZSh3b3JkLCBiYXNlRm9udCkge1xuICAgICAgbGV0IGZvbnQgPSBiYXNlRm9udDtcbiAgICAgIGlmICh3b3JkLmJvbGQpIHtcbiAgICAgICAgZm9udCA9IFwiYm9sZCBcIiArIGZvbnQ7XG4gICAgICB9XG4gICAgICBpZiAod29yZC5pdGFsaWMpIHtcbiAgICAgICAgZm9udCA9IFwiaXRhbGljIFwiICsgZm9udDtcbiAgICAgIH1cbiAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IGZvbnQ7XG4gICAgICB3b3JkLmZvbnRTdHlsZSA9IGZvbnQ7XG4gICAgfVxuICAgIHJlc2V0Rm9udFN0eWxlKGJhc2VGb250KSB7XG4gICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSBiYXNlRm9udDtcbiAgICB9XG4gICAgbWVhc3VyZShwYXJzZWQsIGxldHRlclNwYWNpbmcgPSAwLCBiYXNlRm9udCkge1xuICAgICAgZm9yIChjb25zdCBwIG9mIHBhcnNlZCkge1xuICAgICAgICB0aGlzLmFwcGx5Rm9udFN0eWxlKHAsIGJhc2VGb250KTtcbiAgICAgICAgcC53aWR0aCA9IHRoaXMubWVhc3VyZVRleHQocC50ZXh0LCBsZXR0ZXJTcGFj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IHtcbiAgICAgICAgICAgIGJyZWFrSW5kZXggLT0gMTtcbiAgICAgICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiB7IGJyZWFrSW5kZXgsIHRydW5jV29yZFdpZHRoIH07XG4gICAgfVxuICAgIHdvcmRCcmVhayh3b3JkLCB3aWR0aCwgYmFzZUZvbnQpIHtcbiAgICAgIGlmICghd29yZC50ZXh0KSB7XG4gICAgICAgIHJldHVybiB3b3JkO1xuICAgICAgfVxuICAgICAgdGhpcy5hcHBseUZvbnRTdHlsZSh3b3JkLCBiYXNlRm9udCk7XG4gICAgICBjb25zdCBwYXJ0cyA9IFtdO1xuICAgICAgbGV0IHRleHQgPSB3b3JkLnRleHQ7XG4gICAgICBpZiAoIXdvcmQubGV0dGVycykge1xuICAgICAgICB3aGlsZSAodHJ1ZSkge1xuICAgICAgICAgIGNvbnN0IHsgYnJlYWtJbmRleCwgdHJ1bmNXb3JkV2lkdGggfSA9IHRoaXMuX2dldEJyZWFrSW5kZXgodGV4dCwgd2lkdGgpO1xuICAgICAgICAgIHBhcnRzLnB1c2goeyAuLi53b3JkIH0pO1xuICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLnRleHQgPSB0ZXh0LnNsaWNlKDAsIGJyZWFrSW5kZXgpO1xuICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLndpZHRoID0gdHJ1bmNXb3JkV2lkdGg7XG4gICAgICAgICAgaWYgKGJyZWFrSW5kZXggPT09IHRleHQubGVuZ3RoKSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgdGV4dCA9IHRleHQuc2xpY2UoYnJlYWtJbmRleCk7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGxldCB0b3RhbFdpZHRoID0gMDtcbiAgICAgICAgbGV0IGxldHRlcnMgPSBbXTtcbiAgICAgICAgbGV0IGJyZWFrSW5kZXggPSAwO1xuICAgICAgICBmb3IgKGNvbnN0IGwgb2Ygd29yZC5sZXR0ZXJzKSB7XG4gICAgICAgICAgaWYgKHRvdGFsV2lkdGggKyBsLndpZHRoID49IHdpZHRoKSB7XG4gICAgICAgICAgICBwYXJ0cy5wdXNoKHsgLi4ud29yZCB9KTtcbiAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLnRleHQgPSB0ZXh0LnNsaWNlKDAsIGJyZWFrSW5kZXgpO1xuICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ud2lkdGggPSB0b3RhbFdpZHRoO1xuICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ubGV0dGVycyA9IGxldHRlcnM7XG4gICAgICAgICAgICB0ZXh0ID0gdGV4dC5zbGljZShicmVha0luZGV4KTtcbiAgICAgICAgICAgIHRvdGFsV2lkdGggPSAwO1xuICAgICAgICAgICAgbGV0dGVycyA9IFtdO1xuICAgICAgICAgICAgYnJlYWtJbmRleCA9IDA7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGJyZWFrSW5kZXggKz0gMTtcbiAgICAgICAgICAgIGxldHRlcnMucHVzaChsKTtcbiAgICAgICAgICAgIHRvdGFsV2lkdGggKz0gbC53aWR0aDtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRvdGFsV2lkdGggPiAwKSB7XG4gICAgICAgICAgcGFydHMucHVzaCh7IC4uLndvcmQgfSk7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0udGV4dCA9IHRleHQuc2xpY2UoMCwgYnJlYWtJbmRleCk7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ud2lkdGggPSB0b3RhbFdpZHRoO1xuICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLmxldHRlcnMgPSBsZXR0ZXJzO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gcGFydHM7XG4gICAgfVxuICAgIGFsaWduTGluZShwYXJzZWQsIGluaXRpYWxYID0gMCkge1xuICAgICAgbGV0IHByZXZXaWR0aCA9IDA7XG4gICAgICBsZXQgcHJldlggPSBpbml0aWFsWDtcbiAgICAgIGZvciAoY29uc3Qgd29yZCBvZiBwYXJzZWQpIHtcbiAgICAgICAgaWYgKHdvcmQudGV4dCA9PSBcIlxcblwiKSB7XG4gICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgd29yZC54ID0gcHJldlggKyBwcmV2V2lkdGg7XG4gICAgICAgIHByZXZYID0gd29yZC54O1xuICAgICAgICBwcmV2V2lkdGggPSB3b3JkLndpZHRoO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICBjbGFzcyBUZXh0VGV4dHVyZSBleHRlbmRzIFRleHR1cmUge1xuICAgIGNvbnN0cnVjdG9yKHN0YWdlKSB7XG4gICAgICBzdXBlcihzdGFnZSk7XG4gICAgICB0aGlzLl9wcmVjaXNpb24gPSB0aGlzLnN0YWdlLmdldE9wdGlvbihcInByZWNpc2lvblwiKTtcbiAgICB9XG4gICAgc3RhdGljIHJlbmRlcmVyKHN0YWdlLCBjYW52YXMsIHNldHRpbmdzKSB7XG4gICAgICBpZiAodGhpcy5hZHZhbmNlZFJlbmRlcmVyKSB7XG4gICAgICAgIHJldHVybiBuZXcgVGV4dFRleHR1cmVSZW5kZXJlckFkdmFuY2VkKHN0YWdlLCBjYW52YXMsIHNldHRpbmdzKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiBuZXcgVGV4dFRleHR1cmVSZW5kZXJlcihzdGFnZSwgY2FudmFzLCBzZXR0aW5ncyk7XG4gICAgICB9XG4gICAgfVxuIC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aXMuX2ZvbnRCYXNlbGluZVJhdGlvID0gdjtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgZm9udFNpemUoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fZm9udFNpemU7XG4gICAgfVxuICAgIHNldCBmb250U2l6ZSh2KSB7XG4gICAgICBpZiAodGhpcy5fZm9udFNpemUgIT09IHYpIHtcbiAgICAgICAgdGhpcy5fZm9udFNpemUgPSB2O1xuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBmb250RmFjZSgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9mb250RmFjZTtcbiAgICB9XG4gICAgc2V0IGZvbnRGYWNlKHYpIHtcbiAgICAgIGlmICh0aGlzLl9mb250RmFjZSAhPT0gdikge1xuICAgICAgICB0aGlzLl9mb250RmFjZSA9IHY7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IHdvcmRXcmFwKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3dvcmRXcmFwO1xuICAgIH1cbiAgICBzZXQgd29yZFdyYXAodikge1xuICAgICAgaWYgKHRoaXMuX3dvcmRXcmFwICE9PSB2KSB7XG4gICAgICAgIHRoaXMuX3dvcmRXcmFwID0gdjtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgd29yZFdyYXBXaWR0aCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl93b3JkV3JhcFdpZHRoO1xuICAgIH1cbiAgICBzZXQgd29yZFdyYXBXaWR0aCh2KSB7XG4gICAgICBpZiAodGhpcy5fd29yZFdyYXBXaWR0aCAhPT0gdikge1xuICAgICAgICB0aGlzLl93b3JkV3JhcFdpZHRoID0gdjtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgfVxuICAgIH1c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gdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgbGV0dGVyU3BhY2luZygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9sZXR0ZXJTcGFjaW5nO1xuICAgIH1cbiAgICBzZXQgdGV4dEluZGVudCh2KSB7XG4gICAgICBpZiAodGhpcy5fdGV4dEluZGVudCAhPT0gdikge1xuICAgICAgICB0aGlzLl90ZXh0SW5kZW50ID0gdjtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgdGV4dEluZGVudCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl90ZXh0SW5kZW50O1xuICAgIH1cbiAgICBnZXQgcHJlY2lzaW9uKCkge1xuICAgICAgcmV0dXJuIHN1cGVyLnByZWNpc2lvbjtcbiAgICB9XG4gICAgc2V0IHByZWNpc2lvbih2KSB7XG4gICAgICBpZiAodGhpcy5wcmVjaXNpb24gIT09IHYpIHtcbiAgICAgICAgc3VwZXIucHJlY2lzaW9uID0gdjtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgfVxuICAgIH1cbiAgICBfZ2V0SXNWYWxpZCgpIHtcbiAgICAgIHJldHVybiAhIXRoaXMudGV4dDtcbiAgICB9XG4gICAgX2dldExvb2t1cElkKCkge1xuICAgICAgbGV0IHBhcnRzID0gW107XG4gICAgICBpZiAodGhpcy53ICE9PSAwKVxuICAgICAgICBwYXJ0cy5wdXNoKFwidyBcIiArIHRoaXMudyk7XG4gICAgICBpZiAodGhpcy5oICE9PSAwKVxuICAgICAgICBwYXJ0cy5wdXNoKFwiaCBcIiArIHRoaXMuaCk7XG4gICAgICBpZiAodGhpcy5mb250U3R5bGUgIT09IFwibm9ybWFsXCIpXG4gICAgICAgIHBhcnRzLnB1c2goXCJmU1wiICsgdGhpcy5mb250U3R5bGUpO1xuICAgICAgaWYgKHRoaXMuZm9udFNpemUgIT09IDQwKVxuICAgICAgICBwYX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SA9PiB7XG4gICAgICAgICAgICBjYihudWxsLCBPYmplY3QuYXNzaWduKHtcbiAgICAgICAgICAgICAgcmVuZGVySW5mbzogcmVuZGVyZXIucmVuZGVySW5mbyxcbiAgICAgICAgICAgICAgdGhyb3R0bGU6IGZhbHNlLFxuICAgICAgICAgICAgICB0ZXhQYXJhbXNcbiAgICAgICAgICAgIH0sIHRoaXMuc3RhZ2UucGxhdGZvcm0uZ2V0VGV4dHVyZU9wdGlvbnNGb3JEcmF3aW5nQ2FudmFzKGNhbnZhcykpKTtcbiAgICAgICAgICB9KS5jYXRjaCgoZXJyKSA9PiB7XG4gICAgICAgICAgICBjYihlcnIpO1xuICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNiKG51bGwsIE9iamVjdC5hc3NpZ24oe1xuICAgICAgICAgICAgcmVuZGVySW5mbzogcmVuZGVyZXIucmVuZGVySW5mbyxcbiAgICAgICAgICAgIHRocm90dGxlOiBmYWxzZSxcbiAgICAgICAgICAgIHRleFBhcmFtc1xuICAgICAgICAgIH0sIHRoaXMuc3RhZ2UucGxhdGZvcm0uZ2V0VGV4dHVyZU9wdGlvbnNGb3JEcmF3aW5nQ2FudmFzKGNhbnZhcykpKTtcbiAgICAgICAgfVxuICAgICAgfTtcbiAgICB9XG4gICAgZ2V0Tm9uRGVmYXVsdHMoKSB7XG4gICAgICBjb25zdCBub25EZWZhdWx0cyA9IHN1cGVyLmdldE5vbkRlZmF1bHRzKCk7XG4gICAgICBpZiAodGhpcy50ZXh0ICE9PSBcIlwiKVxuICAgICAgICBub25EZWZhdWx0c1tcInRleHRcIl0gPSB0aGlzLnRleHQ7XG4gICAgICBpZiAodGhpcy53ICE9PSAwKVxuICAgICAgICBub25EZWZhdWx0c1tcIndcIl0gPSB0aGlzLnc7XG4gICAgICBpZiAodGhpcy5oICE9PSAwKVxuICAgICAgICBub25EZWZhdWx0c1tcImhcIl0gPSB0aGlzLmg7XG4gICAgICBpZiAodGhpcy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NoZWQ7XG4gICAgfVxuICAgIGlzUnVubmluZygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9wIDwgMTtcbiAgICB9XG4gICAgcHJvZ3Jlc3MoZHQpIHtcbiAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkKCkpIHtcbiAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5wIDwgMSkge1xuICAgICAgICBpZiAodGhpcy5kZWxheUxlZnQgPiAwKSB7XG4gICAgICAgICAgdGhpcy5fZGVsYXlMZWZ0IC09IGR0O1xuICAgICAgICAgIGlmICh0aGlzLmRlbGF5TGVmdCA8IDApIHtcbiAgICAgICAgICAgIGR0ID0gLXRoaXMuZGVsYXlMZWZ0O1xuICAgICAgICAgICAgdGhpcy5fZGVsYXlMZWZ0ID0gMDtcbiAgICAgICAgICAgIHRoaXMuZW1pdChcImRlbGF5RW5kXCIpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy5kdXJhdGlvbiA9PSAwKSB7XG4gICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fcCArPSBkdCAvIHRoaXMuX3NldHRpbmdzLmR1cmF0aW9uO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9wID49IDEpIHtcbiAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgdGhpcy5fdXBkYXRlRHJhd1ZhbHVlKCk7XG4gICAgICB0aGlzLmludm9rZUxpc3RlbmVycygpO1xuICAgIH1cbiAgICBpbnZva2VMaXN0ZW5lcnMoKSB7XG4gICAgICB0aGlzLmVtaXQoXCJwcm9ncmVzc1wiLCB0aGlzLnApO1xuICAgICAgaWYgKHRoaXMucCA9PT0gMSkge1xuICAgICAgIC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YgKGN1cnJlbnRJbmRleCAhPSAtMSkge1xuICAgICAgICAgIGlmIChjdXJyZW50SW5kZXggIT09IGluZGV4KSB7XG4gICAgICAgICAgICBjb25zdCBmcm9tSW5kZXggPSBjdXJyZW50SW5kZXg7XG4gICAgICAgICAgICBpZiAoZnJvbUluZGV4ICE9PSBpbmRleCkge1xuICAgICAgICAgICAgICB0aGlzLl9pdGVtcy5zcGxpY2UoZnJvbUluZGV4LCAxKTtcbiAgICAgICAgICAgICAgdGhpcy5faXRlbXMuc3BsaWNlKGluZGV4LCAwLCBpdGVtKTtcbiAgICAgICAgICAgICAgdGhpcy5vbk1vdmUoaXRlbSwgZnJvbUluZGV4LCBpbmRleCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmIChpbmRleCA8IHRoaXMuX2l0ZW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX2l0ZW1zW2luZGV4XS5yZWYpIHtcbiAgICAgICAgICAgICAgdGhpcy5fcmVmc1t0aGlzLl9pdGVtc1tpbmRleF0ucmVmXSA9IHZvaWQgMDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgY29uc3QgcHJldkl0ZW0gPSB0aGlzLl9pdGVtc1tpbmRleF07XG4gICAgICAgICAgdGhpcy5faXRlbXNbaW5kZXhdID0gaXRlbTtcbiAgICAgICAgICBpZiAoaXRlbS5yZWYpIHtcbiAgICAgICAgICAgIHRoaXMuX3JlZnNbaXRlbS5yZWZdID0gaXRlbTtcbiAgICAgICAgICB9XG4gICAgICAgICAgdGhpcy5vblNldChpdGVtLCBpbmRleCwgcHJldkl0ZW0pO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJzZXRBdDogVGhlIGluZGV4IFwiICsgaW5kZXggKyBcIiBpcyBvdXQgb2YgYm91bmRzIFwiICsgdGhpcy5fa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N0TGl0ZXJhbChzZXR0aW5ncykpIHtcbiAgICAgICAgdGhpcy5fc2V0QnlPYmplY3Qoc2V0dGluZ3MpO1xuICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KHNldHRpbmdzKSkge1xuICAgICAgICB0aGlzLl9zZXRCeUFycmF5KHNldHRpbmdzKTtcbiAgICAgIH1cbiAgICB9XG4gICAgX3NldEJ5T2JqZWN0KHNldHRpbmdzKSB7XG4gICAgICBsZXQgcmVmcyA9IHRoaXMuX2dldFJlZnMoKTtcbiAgICAgIGxldCBjcmVmcyA9IE9iamVjdC5rZXlzKHNldHRpbmdzKTtcbiAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gY3JlZnMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIGxldCBjcmVmID0gY3JlZnNbaV07XG4gICAgICAgIGxldCBzID0gc2V0dGluZ3NbY3JlZl07XG4gICAgICAgIGxldCBjID0gcmVmc1tjcmVmXTtcbiAgICAgICAgaWYgKCFjKSB7XG4gICAgICAgICAgaWYgKHRoaXMuaXNJdGVtKHMpKSB7XG4gICAgICAgICAgICBzLnJlZiA9IGNyZWY7XG4gICAgICAgICAgICB0aGlzLmFkZChzKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgYyA9IHRoaXMuY3JlYXRlSXRlbShzKTtcbiAgICAgICAgICAgIGMucmVmID0gY3JlZjtcbiAgICAgICAgICAgIGMucGF0Y2gocyk7XG4gICAgICAgICAgICB0aGlzLmFkZChjKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKHRoaXMuaXNJdGVtKHMpKSB7XG4gICAgICAgICAgICBpZiAoYyAhPT0gcykge1xuICAgICAgICAgICAgICBsZXQgaWR4ID0gdGhpcy5nZXRJbmRleChjKTtcbiAgICAgICAgICAgICAgcy5yZWYgPSBjcmVmO1xuICAgICAgICAgICAgICB0aGlzLnNldEF0KHMsIGlkeCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGMucGF0Y2gocyk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF9lcXVhbHNBcnJheShhcnJheSkge1xuICAgICAgbGV0IHNhbWUgPSB0cnVlO1xuICAgICAgaWYgKGFycmF5Lmxlbmd0aCA9PT0gdGhpcy5faXRlbXMubGVuZ3RoKSB7XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5faXRlbXMubGVuZ3RoOyBpIDwgbiAmJiBzYW1lOyBpKyspIHtcbiAgICAgICAgICBzYW1lID0gc2FtZSAmJiB0aGlzLl9pdGVtc1tpXSA9PT0gYXJyYXlbaV07XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHNhbWUgPSBmYWxzZTtcbiAgICAgIH1cbiAgICAgIHJldHVybiBzYW1lO1xuICAgIH1cbiAgICBfc2V0QnlBcnJheShhcnJheSkge1xuICAgICAgaWYgKHRoaXMuX2VxdWFsc0FycmF5KGFycmF5KSkge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2l0ZW1zLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICB0aGlzLl9pdGVtc1tpXS5tYXJrZXIgPSB0cnVlO1xuICAgICAgfVxuICAgICAgbGV0IHJlZnM7XG4gICAgICBsZXQgbmV3SXRlbXMgPSBbXTtcbiAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYXJyYXkubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIGxldCBzID0gYXJyYXlbaV07XG4gICAgICAgIGlmICh0aGlzLmlzSXRlbShzKSkge1xuICAgICAgICAgIHMubWFya2VyID0gZmFsc2U7XG4gICAgICAgICAgbmV3SXRlbXMucHVzaChzKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgIC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ZCkge1xuICAgICAgICAgIHRoaXMuX29uU2V0dXAoKTtcbiAgICAgICAgfVxuICAgICAgICBsZXQgY2hpbGRyZW4gPSB0aGlzLl9jaGlsZHJlbi5nZXQoKTtcbiAgICAgICAgaWYgKGNoaWxkcmVuKSB7XG4gICAgICAgICAgbGV0IG0gPSBjaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgICAgaWYgKG0gPiAwKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG07IGkrKykge1xuICAgICAgICAgICAgICBjaGlsZHJlbltpXS5fdXBkYXRlQXR0YWNoZWRGbGFnKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChuZXdBdHRhY2hlZCkge1xuICAgICAgICAgIHRoaXMuX29uQXR0YWNoKCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fb25EZXRhY2goKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlRW5hYmxlZEZsYWcoKSB7XG4gICAgICBsZXQgbmV3RW5hYmxlZCA9IHRoaXMuX2lzRW5hYmxlZCgpO1xuICAgICAgaWYgKHRoaXMuX19lbmFibGVkICE9PSBuZXdFbmFibGVkKSB7XG4gICAgICAgIGlmIChuZXdFbmFibGVkKSB7XG4gICAgICAgICAgdGhpcy5fb25FbmFibGVkKCk7XG4gICAgICAgICAgdGhpcy5fc2V0RW5hYmxlZEZsYWcoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl9vbkRpc2FibGVkKCk7XG4gICAgICAgICAgdGhpcy5fdW5zZXRFbmFibGVkRmxhZygpO1xuICAgICAgICB9XG4gICAgICAgIGxldCBjaGlsZHJlbiA9IHRoaXMuX2NoaWxkcmVuLmdldCgpO1xuICAgICAgICBpZiAoY2hpbGRyZW4pIHtcbiAgICAgICAgICBsZXQgbSA9IGNoaWxkcmVuLmxlbmd0aDtcbiAgICAgICAgICBpZiAobSA+IDApIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbTsgaSsrKSB7XG4gICAgICAgICAgICAgIGNoaWxkcmVuW2ldLl91cGRhdGVFbmFibGVkRmxhZygpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfc2V0RW5hYmxlZEZsYWcoKSB7XG4gICAgICB0aGlzLl9fZW5hYmxlZCA9IHRydWU7XG4gICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgICB0aGlzLl91cGRhdGVUZXh0dXJlQ29vcmRzKCk7XG4gICAgICBpZiAodGhpcy5fX3RleHR1cmUpIHtcbiAgICAgICAgdGhpcy5fX3RleHR1cmUuYWRkRWxlbWVudCh0aGlzKTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLndpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICB0aGlzLl9zZXRBY3RpdmVGbGFnKCk7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fX2NvcmUuc2hhZGVyKSB7XG4gICAgICAgIHRoaXMuX19jb3JlLnNoYWRlci5hZGRFbGVtZW50KHRoaXMuX19jb3JlKTtcbiAgICAgIH1cbiAgICB9XG4gICAgX3Vuc2V0RW5hYmxlZEZsYWcoKSB7XG4gICAgICBpZiAodGhpcy5fX2FjdGl2ZSkge1xuICAgICAgICB0aGlzLl91bnNldEFjdGl2ZUZsYWcoKTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9fdGV4dHVyZSkge1xuICAgICAgICB0aGlzLl9fdGV4dHVyZS5yZW1vdmVFbGVtZW50KHRoaXMpO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX19jb3JlLnNoYWRlcikge1xuICAgICAgICB0aGlzLl9fY29yZS5zaGFkZXIucmVtb3ZlRWxlbWVudCh0aGlzLl9fY29yZSk7XG4gICAgICB9XG4gICAgICBpZiA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gIGlmICh2LmlzVGV4dHVyZSkge1xuICAgICAgICAgIHRleHR1cmUgPSB2O1xuICAgICAgICB9IGVsc2UgaWYgKHYuaXNUZXh0dXJlU291cmNlKSB7XG4gICAgICAgICAgdGV4dHVyZSA9IG5ldyBTb3VyY2VUZXh0dXJlKHRoaXMuc3RhZ2UpO1xuICAgICAgICAgIHRleHR1cmUudGV4dHVyZVNvdXJjZSA9IHY7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgY29uc29sZS5lcnJvcihcIltMaWdodG5pbmddIFBsZWFzZSBzcGVjaWZ5IGEgdGV4dHVyZSB0eXBlLlwiKTtcbiAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGNvbnN0IHByZXZUZXh0dXJlID0gdGhpcy5fX3RleHR1cmU7XG4gICAgICBpZiAodGV4dHVyZSAhPT0gcHJldlRleHR1cmUpIHtcbiAgICAgICAgdGhpcy5fX3RleHR1cmUgPSB0ZXh0dXJlO1xuICAgICAgICBpZiAodGhpcy5fX3RleHR1cmUpIHtcbiAgICAgICAgICBpZiAodGhpcy5fX2VuYWJsZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX190ZXh0dXJlLmFkZEVsZW1lbnQodGhpcyk7XG4gICAgICAgICAgICBpZiAodGhpcy53aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgaWYgKHRoaXMuX190ZXh0dXJlLmlzTG9hZGVkKCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXREaXNwbGF5ZWRUZXh0dXJlKHRoaXMuX190ZXh0dXJlKTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9lbmFibGVUZXh0dXJlRXJyb3IoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl9zZXREaXNwbGF5ZW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XRlRGltZW5zaW9ucygpO1xuICAgICAgdGhpcy5fdXBkYXRlVGV4dHVyZUNvb3JkcygpO1xuICAgIH1cbiAgICBvblByZWNpc2lvbkNoYW5nZWQoKSB7XG4gICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgfVxuICAgIG9uRGltZW5zaW9uc0NoYW5nZWQodywgaCkge1xuICAgICAgaWYgKHRoaXMudGV4dHVyZSBpbnN0YW5jZW9mIFRleHRUZXh0dXJlKSB7XG4gICAgICAgIHRoaXMudGV4dHVyZS53ID0gdztcbiAgICAgICAgdGhpcy50ZXh0dXJlLmggPSBoO1xuICAgICAgICB0aGlzLncgPSB3O1xuICAgICAgICB0aGlzLmggPSBoO1xuICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlRGltZW5zaW9ucygpIHtcbiAgICAgIGxldCB3ID0gdGhpcy5fZ2V0UmVuZGVyV2lkdGgoKTtcbiAgICAgIGxldCBoID0gdGhpcy5fZ2V0UmVuZGVySGVpZ2h0KCk7XG4gICAgICBsZXQgdW5rbm93blNpemUgPSBmYWxzZTtcbiAgICAgIGlmICghdyB8fCAhaCkge1xuICAgICAgICBpZiAoIXRoaXMuX19kaXNwbGF5ZWRUZXh0dXJlICYmIHRoaXMuX190ZXh0dXJlKSB7XG4gICAgICAgICAgdyA9IHcgfHwgdGhpcy5fX3RleHR1cmUubXc7XG4gICAgICAgICAgaCA9IGggfHwgdGhpcy5fX3RleHR1cmUubWg7XG4gICAgICAgICAgaWYgKCghdyB8fCAhaCkgJiYgdGhpcy5fX3RleHR1cmUuaXNBdXRvc2l6ZVRleHR1cmUoKSkge1xuICAgICAgICAgICAgdW5rbm93blNpemUgPSB0cnVlO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX19jb3JlLnNldERpbWVuc2lvbnModywgaCwgdW5rbm93blNpemUpKSB7XG4gICAgICAgIHRoaXMuX29uUmVzaXplKCk7XG4gICAgICB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h0YWcpO1xuICAgICAgICAgICAgcGFyZW50VHJlZVRhZ3MuZGVsZXRlKHRoaXMpO1xuICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgICBsZXQgdGFncyA9IG51bGw7XG4gICAgICBsZXQgbiA9IDA7XG4gICAgICBpZiAodGhpcy5fX3RyZWVUYWdzKSB7XG4gICAgICAgIGlmICghdGhpcy5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICB0YWdzID0gVXRpbHMkMS5pdGVyYXRvclRvQXJyYXkodGhpcy5fX3RyZWVUYWdzLmtleXMoKSk7XG4gICAgICAgICAgbiA9IHRhZ3MubGVuZ3RoO1xuICAgICAgICAgIGlmIChuID4gMCkge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgbGV0IHRhZ1NldCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnc1tpXSk7XG4gICAgICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICAgICAgd2hpbGUgKHAgPSBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgICAgICAgbGV0IHBhcmVudFRyZWVUYWdzID0gcC5fX3RyZWVUYWdzLmdldCh0YWdzW2ldKTtcbiAgICAgICAgICAgICAgICB0YWdTZXQuZm9yRWFjaChmdW5jdGlvbihjb21wKSB7XG4gICAgICAgICAgICAgICAgICBwYXJlbnRUcmVlVGFncy5kZWxldGUoY29tcCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgX3NldFRhZ3NQYXJlbnQoKSB7XG4gICAgICBpZiAodGhpcy5fX3RhZ3MpIHtcbiAgICAgICAgdGhpcy5fX3RhZ3MuZm9yRWFjaCgodGFnKSA9PiB7XG4gICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgIHdoaWxlIChwID0gcC5fX3BhcmVudCkge1xuICAgICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICAgIHMgPSAvKiBAX19QVVJFX18gKi8gbmV3IFNldCgpO1xuICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzLmFkZCh0aGlzKTtcbiAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX190cmVlVGFncyAmJiB0aGlzLl9fdHJlZVRhZ3Muc2l6ZSkge1xuICAgICAgICBpZiAoIXRoaXMuX190YWdSb290KSB7XG4gICAgICAgICAgdGhpcy5fX3RyZWVUYWdzLmZvckVhY2goKHRhZ1NldCwgdGFnKSA9PiB7XG4gICAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgICB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpIHtcbiAgICAgICAgICAgICAgaWYgKHAuX190YWdSb290KVxuICAgICAgICAgICAgICAgIDtcbiAgICAgICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSAvKiBAX19QVVJFX18gKi8gbmV3IE1hcCgpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgICAgICBzID0gLyogQF9fUFVSRV9fICovIG5ldyBTZXQoKTtcbiAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgdGFnU2V0LmZvckVhY2goZnVuY3Rpb24oY29tcCkge1xuICAgICAgICAgICAgICAgIHMuYWRkKGNvbXApO1xuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfZ2V0QnlUYWcodGFnKSB7XG4gICAgICBpZiAoIXRoaXMuX190cmVlVGFncykge1xuICAgICAgICByZXR1cm4gW107XG4gICAgICB9XG4gICAgICBsZXQgdCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgIHJldHVybiB0ID8gVXRpbHMkMS5zZXRUb0FycmF5KHQpIDogW107XG4gICAgfVxuICAgIGdldFRhZ3MoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX3RhZ3MgPyB0aGlzLl9fdGFncyA6IFtdO1xuICAgIH1cbiAgICBzZXRUYWdzKHRhZ3MpIHtcbiAgICAgIHRhZ3MgPSB0YWdzLnJlZHVjZSgoYWNjLCB0YWcpID0+IHtcbiAgICAgICAgcmV0dXJuIGFjYy5jb25jYXQodGFnLnNwbGl0KFwiIFwiKSk7XG4gICAgICB9LCBbXSk7XG4gICAgICBpZiAodGhpcy5fX3JlZikge1xuICAgICAgICB0YWdzLnB1c2godGhpcy5fX3JlZik7XG4gICAgICB9XG4gICAgICBsZXQgaSw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NlIHtcbiAgICAgICAgY29uc3QgdGFncyA9IHRhZy5zcGxpdChcIiBcIik7XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBtID0gdGFncy5sZW5ndGg7IGkgPCBtOyBpKyspIHtcbiAgICAgICAgICBjb25zdCB0YWcyID0gdGFnc1tpXTtcbiAgICAgICAgICBpZiAoVXRpbHMkMS5pc1VjQ2hhcih0YWcyLmNoYXJDb2RlQXQoMCkpKSB7XG4gICAgICAgICAgICB0aGlzLl90aHJvd0Vycm9yKFwiVGFnIG1heSBub3Qgc3RhcnQgd2l0aCBhbiB1cHBlciBjYXNlIGNoYXJhY3Rlci5cIik7XG4gICAgICAgICAgfVxuICAgICAgICAgIHRoaXMuX2FkZFRhZyh0YWcyKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfYWRkVGFnKHRhZykge1xuICAgICAgaWYgKCF0aGlzLl9fdGFncykge1xuICAgICAgICB0aGlzLl9fdGFncyA9IFtdO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX190YWdzLmluZGV4T2YodGFnKSA9PT0gLTEpIHtcbiAgICAgICAgdGhpcy5fX3RhZ3MucHVzaCh0YWcpO1xuICAgICAgICBsZXQgcCA9IHRoaXMuX19wYXJlbnQ7XG4gICAgICAgIGlmIChwKSB7XG4gICAgICAgICAgZG8ge1xuICAgICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICAgIHMgPSAvKiBAX19QVVJFX18gKi8gbmV3IFNldCgpO1xuICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgICB9XG4gICAgICA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IHJldHVybiBpdGVtID8gaXRlbS52YWx1ZSA6IHZvaWQgMDtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IHRhZygpIHtcbiAgICAgIHJldHVybiB0aGlzLl90YWc7XG4gICAgfVxuICAgIHNldCB0YWcodCkge1xuICAgICAgdGhpcy50YWdzID0gdDtcbiAgICB9XG4gICAgbXRhZyh0YWcpIHtcbiAgICAgIGxldCBpZHggPSB0YWcuaW5kZXhPZihcIi5cIik7XG4gICAgICBpZiAoaWR4ID49IDApIHtcbiAgICAgICAgbGV0IHBhcnRzID0gdGFnLnNwbGl0KFwiLlwiKTtcbiAgICAgICAgbGV0IHJlcyA9IHRoaXMuX2dldEJ5VGFnKHBhcnRzWzBdKTtcbiAgICAgICAgbGV0IGxldmVsID0gMTtcbiAgICAgICAgbGV0IGMgPSBwYXJ0cy5sZW5ndGg7XG4gICAgICAgIHdoaWxlIChyZXMubGVuZ3RoICYmIGxldmVsIDwgYykge1xuICAgICAgICAgIGxldCByZXNuID0gW107XG4gICAgICAgICAgZm9yIChsZXQgaiA9IDAsIG4gPSByZXMubGVuZ3RoOyBqIDwgbjsgaisrKSB7XG4gICAgICAgICAgICByZXNuID0gcmVzbi5jb25jYXQocmVzW2pdLl9nZXRCeVRhZyhwYXJ0c1tsZXZlbF0pKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmVzID0gcmVzbjtcbiAgICAgICAgICBsZXZlbCsrO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXM7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gdGhpcy5fZ2V0QnlUYWcodGFnKTtcbiAgICAgIH1cbiAgICB9XG4gICAgc3RhZyh0YWcsIHNldHRpbmdzKSB7XG4gICAgICBsZXQgdCA9IHRoaXMubXRhZyh0YWcpO1xuICAgICAgbGV0IG4gPSB0Lmxlbmd0aDtcbiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIEJhc2UucGF0Y2hPYmplY3QodFtpXSwgc2V0dGluZ3MpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgdGFnUm9vdCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fdGFnUm9vdDtcbiAgICB9XG4gICAgc2V0IHRhZ1Jvb3Qodikge1xuICAgICAgaWYgKHRoaXMuX190YWdSb290ICE9PSB2KSB7XG4gICAgICAgIGlmICghdikge1xuICAgICAgICAgIHRoaXMuX3NldFRhZ3NQYXJlbnQoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl91bnNldFRhZ3NQYXJlbnQoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9fdGFnUm9vdCA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIHNlbChwYXRoKSB7XG4gICAgICBjb25zdCByZXN1bHRzID0gdGhpcy5zZWxlY3QocGF0aCk7XG4gICAgICBpZiAocmVzdWx0cy5sZW5ndGgpIHtcbiAgICAgICAgcmV0dXJuIHJlc3VsdHNbMF07XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gdm9pZCAwO1xuICAgICAgfVxuICAgIH1cbiAgICBzZWxlY3QocGF0aCkge1xuICAgICAgaWYgKHBhdGguaW5kZXhPZihcIixcIikgIT09IC0xKSB7XG4gICAgICAgIGxldCBzZWxlY3RvcnMgPSBwYXRoLnNwbGl0KFwiLFwiKTtcbiAgICAgICAgbGV0IHJlcyA9IFtdO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNlbGVjdG9ycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgIHJlcyA9IHJlcy5jb25jYXQodGhpcy5fc2VsZWN0KHNlbGVjdG9yc1tpXSkpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXM7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gdGhpcy5fc2VsZWN0KHBhdGgpO1xuICAgICAgfVxu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4gICAgICAgICAgcmV0dXJuIHRoaXMubXRhZyhwYXRoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKGFycm93SWR4ID09PSAtMSB8fCBwb2ludElkeCAhPT0gLTEgJiYgcG9pbnRJZHggPCBhcnJvd0lkeCkge1xuICAgICAgICBsZXQgbmV4dDtcbiAgICAgICAgY29uc3Qgc3RyID0gcGF0aC5zdWJzdHIoMCwgcG9pbnRJZHgpO1xuICAgICAgICBpZiAoaXNSZWYpIHtcbiAgICAgICAgICBjb25zdCByZWYgPSB0aGlzLmdldEJ5UmVmKHN0cik7XG4gICAgICAgICAgbmV4dCA9IHJlZiA/IFtyZWZdIDogW107XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbmV4dCA9IHRoaXMubXRhZyhzdHIpO1xuICAgICAgICB9XG4gICAgICAgIGxldCB0b3RhbCA9IFtdO1xuICAgICAgICBjb25zdCBzdWJQYXRoID0gcGF0aC5zdWJzdHIocG9pbnRJZHggKyAxKTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBuZXh0Lmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgIHRvdGFsID0gdG90YWwuY29uY2F0KG5leHRbaV0uX3NlbGVjdENoaWxkcyhzdWJQYXRoLCBmYWxzZSkpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0b3RhbDtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGxldCBuZXh0O1xuICAgICAgICBjb25zdCBzdHIgPSBwYXRoLnN1YnN0cigwLCBhcnJvd0lkeCk7XG4gICAgICAgIGlmIChpc1JlZikge1xuICAgICAgICAgIGNvbnN0IHJlZiA9IHRoaXMuZ2V0QnlSZWYoc3RyKTtcbiAgICAgICAgICBuZXh0ID0gcmVmID8gW3JlZl0gOiBbXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBuZXh0ID0gdGhpcy5tdGFnKHN0cik7XG4gICAgICAgIH1cbiAgICAg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nZXRTZXR0aW5ncygpIHtcbiAgICAgIGxldCBzZXR0aW5ncyA9IHRoaXMuZ2V0Tm9uRGVmYXVsdHMoKTtcbiAgICAgIGxldCBjaGlsZHJlbiA9IHRoaXMuX2NoaWxkcmVuLmdldCgpO1xuICAgICAgaWYgKGNoaWxkcmVuKSB7XG4gICAgICAgIGxldCBuID0gY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICBpZiAobikge1xuICAgICAgICAgIGNvbnN0IGNoaWxkQXJyYXkgPSBbXTtcbiAgICAgICAgICBsZXQgbWlzc2luZyA9IGZhbHNlO1xuICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjaGlsZEFycmF5LnB1c2goY2hpbGRyZW5baV0uZ2V0U2V0dGluZ3MoKSk7XG4gICAgICAgICAgICBtaXNzaW5nID0gbWlzc2luZyB8fCAhY2hpbGRyZW5baV0ucmVmO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoIW1pc3NpbmcpIHtcbiAgICAgICAgICAgIHNldHRpbmdzLmNoaWxkcmVuID0ge307XG4gICAgICAgICAgICBjaGlsZEFycmF5LmZvckVhY2goKGNoaWxkKSA9PiB7XG4gICAgICAgICAgICAgIHNldHRpbmdzLmNoaWxkcmVuW2NoaWxkLnJlZl0gPSBjaGlsZDtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzZXR0aW5ncy5jaGlsZHJlbiA9IGNoaWxkQXJyYXk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBzZXR0aW5ncy5pZCA9IHRoaXMuaWQ7XG4gICAgICByZXR1cm4gc2V0dGluZ3M7XG4gICAgfVxuICAgIGdldE5vbkRlZmF1bHRzKCkge1xuICAgICAgbGV0IHNldHRpbmdzID0ge307XG4gICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciAhPT0gRWxlbWVudCkge1xuICAgICA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tcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLnBpdm90WCAhPT0gMC41KVxuICAgICAgICAgIHNldHRpbmdzLnBpdm90WCA9IHRoaXMucGl2b3RYO1xuICAgICAgICBpZiAodGhpcy5waXZvdFkgIT09IDAuNSlcbiAgICAgICAgICBzZXR0aW5ncy5waXZvdFkgPSB0aGlzLnBpdm90WTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLm1vdW50WCA9PT0gdGhpcy5tb3VudFkpIHtcbiAgICAgICAgaWYgKHRoaXMubW91bnRYICE9PSAwKVxuICAgICAgICAgIHNldHRpbmdzLm1vdW50ID0gdGhpcy5tb3VudFg7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAodGhpcy5tb3VudFggIT09IDApXG4gICAgICAgICAgc2V0dGluZ3MubW91bnRYID0gdGhpcy5tb3VudFg7XG4gICAgICAgIGlmICh0aGlzLm1vdW50WSAhPT0gMClcbiAgICAgICAgICBzZXR0aW5ncy5tb3VudFkgPSB0aGlzLm1vdW50WTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLmFscGhhICE9PSAxKVxuICAgICAgICBzZXR0aW5ncy5hbHBoYSA9IHRoaXMuYWxwaGE7XG4gICAgICBpZiAoIXRoaXMudmlzaWJsZSlcbiAgICAgICAgc2V0dGluZ3MudmlzaWJsZSA9IGZhbHNlO1xuICAgICAgaWYgKHRoaXMucm90YXRpb24gIT09IDApXG4gICAgICAgIHNldHRpbmdzLnJvdGF0aW9uID0gdGhpcy5yb3RhdGlvbjtcbiAgICAgIGlmICh0aGlzLmNvbG9yVWwgPT09IHRoaXMuY29sb3JVciAmJiB0aGlzLmNvbG9yQmwgPT09IHRoaXMuY29sb3JCciAmJiB0aGlzLmNvbG9yVWwgPT09IHRoaXMuY29sb3JCbCkge1xuICAgICAgICBpZiAodGhpcy5jb2xvclVsICE9PSA0Mjk0OTY3Mjk1KVxuICAgICAgICAgIHNldHRpbmdzLmNvbG9yID0gdGhpcy5jb2xvclVsLnRvU3RyaW5nKDE2KTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yVWwgIT09IDQyOTQ5NjcyOTUpXG4gICAgICAgICAgc2V0dGluZ3MuY29sb3JVbCA9IHRoaXMuY29sb3JVbC50b1N0cmluZygxNik7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yVXIgIT09IDQyOTQ5NjcyOTUpXG4gICAgICAgICAgc2V0dGluZ3MuY29sb3JVciA9IHRoaXMuY29sb3JVci50b1N0cmluZygxNik7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yQmwgIT09IDQyOTQ5NjcyOTUpXG4gICAgICAgICAgc2V0dGluZ3MuY29sb3JCbCA9IHRoaXMuY29sb3JCbC50b1N0cmluZygxNik7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yQnIgIT09IDQyOTQ5NjcyOTUpXG4gICAgICAgICAgc2V0dGluZ3MuY29sb3JCciA9IHRoaXMuY29sb3JCci50b1N0cmluZygxNik7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy56SW5kZXgpXG4gICAgICAgIHNldHRpbmdzLnpJbmRleCA9IHRoaXMuekluZGV4O1xuICAgICAgaWYgKHRoaXMuZm9yY2VaSW5kZXhDb250ZXh0KVxuICAgICAgICBzZXR0aW5ncy5mb3JjZVpJbmRleENvbnRleHQgPSB0cnVlO1xuICAgICAgaWYgKHRoaXMuY2xpcHBpbmcpXG4gICAgICAgIHNldHRpbmdzLmNsaXBwaW5nID0gdGhpcy5jbGlwcGluZztcbiAgICAgIGlmICghdGhpcy5jbGlwYm94KVxuICAgICAgICBzZXR0aW5ncy5jbGlwYm94ID0gdGhpcy5jbGlwYm94O1xuICAgICAgaWYgKHRoaXMuX190ZXh0dXJlKSB7XG4gICAgICAgIGxldCB0bmQgPSB0aGlzLl9fdGV4dHVyZS5nZXROb25EZWZhdWx0cygpO1xuICAgICAgICBpZiAoT2JqZWN0LmtleXModG5kKS5sZW5ndGgp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gICAgICB0aGlzLl9fY29yZS5kaXNhYmxlRnVuY1coKTtcbiAgICAgICAgICB0aGlzLl93ID0gdjtcbiAgICAgICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IGgoKSB7XG4gICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG4gICAgc2V0IGgodikge1xuICAgICAgaWYgKFV0aWxzJDEuaXNGdW5jdGlvbih2KSkge1xuICAgICAgICB0aGlzLl9oID0gMDtcbiAgICAgICAgdGhpcy5fX2NvcmUuZnVuY0ggPSB2O1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdiA9IE1hdGgubWF4KHYsIDApO1xuICAgICAgICBpZiAodGhpcy5faCAhPT0gdikge1xuICAgICAgICAgIHRoaXMuX19jb3JlLmRpc2FibGVGdW5jSCgpO1xuICAgICAgICAgIHRoaXMuX2ggPSB2O1xuICAgICAgICAgIHRoaXMuX3VwZGF0ZURpbWVuc2lvbnMoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBnZXQgY29sbGlzaW9uKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2NvbGxpc2lvbjtcbiAgICB9XG4gICAgc2V0IGNvbGxpc2lvbih2KSB7XG4gICAgICB0aGlzLl9jb2xsaXNpb24gPSB2O1xuICAgIH1cbiAgICBfdXBkYXRlQ29sbGlzaW9uKCkge1xuICAgICAgaWYgKHRoaXMuY29sbGlzaW9uICYmIHRoaXMuX19wYXJlbnQgJiYgdGhpcy5fX3BhcmVudC5jb2xsaXNpb24gPT09IHZvaWQgMCkge1xuICAgICAgICB0aGlzLl9fcGFyZW50LmNvbGxpc2lvbiA9IDI7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBzY2FsZVgoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUuc2NhbGVYO1xuICAgIH1cbiAgICBzZXQgc2NhbGVYKHYpIHtcbiAgIC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gICAgIHRoaXMuY29sb3JCciA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBjb2xvckxlZnQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5jb2xvclVsO1xuICAgIH1cbiAgICBzZXQgY29sb3JMZWZ0KHYpIHtcbiAgICAgIGlmICh0aGlzLmNvbG9yVWwgIT09IHYgfHwgdGhpcy5jb2xvckJsICE9PSB2KSB7XG4gICAgICAgIHRoaXMuY29sb3JVbCA9IHY7XG4gICAgICAgIHRoaXMuY29sb3JCbCA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBjb2xvclJpZ2h0KCkge1xuICAgICAgcmV0dXJuIHRoaXMuY29sb3JVcjtcbiAgICB9XG4gICAgc2V0IGNvbG9yUmlnaHQodikge1xuICAgICAgaWYgKHRoaXMuY29sb3JVciAhPT0gdiB8fCB0aGlzLmNvbG9yQnIgIT09IHYpIHtcbiAgICAgICAgdGhpcy5jb2xvclVyID0gdjtcbiAgICAgICAgdGhpcy5jb2xvckJyID0gdjtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IHpJbmRleCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS56SW5kZXg7XG4gICAgfVxuICAgIHNldCB6SW5kZXgodikge1xuICAgICAgdGhpcy5fX2NvcmUuekluZGV4ID0gdjtcbiAgICB9XG4gICAgZ2V0IGZvcmNlWkluZGV4Q29udGV4dCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5mb3JjZVpJbmRleENvbnRleHQ7XG4gICAgfVxuICAgIHNldCBmb3JjZVpJbmRleENvbnRleHQodikge1xuICAgICAgdGhpcy5fX2NvcmUuZm9yY2VaSW5kZXhDb250ZXh0ID0gdjtcbiAgICB9XG4gICAgZ2V0IGNsaXBwaW5nKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNsaXBwaW5nO1xuICAgIH1cbiAgICBzZXQgY2xpcHBpbmcodikge1xuICAgICAgdGhpcy5fX2N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AgIGNvbnN0IGZpcnN0Q2hhckNvZGUgPSBwYXRoLmNoYXJDb2RlQXQoMCk7XG4gICAgICAgIGlmIChVdGlscyQxLmlzVWNDaGFyKGZpcnN0Q2hhckNvZGUpKSB7XG4gICAgICAgICAgY29uc3QgY2hpbGQgPSB0aGlzLmdldEJ5UmVmKHBhdGgpO1xuICAgICAgICAgIGlmICghY2hpbGQpIHtcbiAgICAgICAgICAgIGlmICh2ICE9PSB2b2lkIDApIHtcbiAgICAgICAgICAgICAgbGV0IGM7XG4gICAgICAgICAgICAgIGlmIChVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgICAgIGMgPSB0aGlzLmNoaWxkTGlzdC5jcmVhdGVJdGVtKHYpO1xuICAgICAgICAgICAgICAgIGMucGF0Y2godik7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdCh2KSkge1xuICAgICAgICAgICAgICAgIGMgPSB2O1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmIChjLmlzRWxlbWVudCkge1xuICAgICAgICAgICAgICAgIGMucmVmID0gcGF0aDtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKGMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodiA9PT0gdm9pZCAwKSB7XG4gICAgICAgICAgICAgIGlmIChjaGlsZC5wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICBjaGlsZC5wYXJlbnQuY2hpbGRMaXN0LnJlbW92ZShjaGlsZCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgICAgY2hpbGQucGF0Y2godik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHYuaXNFbGVtZW50KSB7XG4gICAgICAgICAgIC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29uc3QgcmVmID0gYCR7ZWxlbWVudC5fX3JlZiB8fCBgRWxlbWVudC0ke2VsZW1lbnQuaWR9YH1gO1xuICAgICAgICBjb25zdCBwcm9wZXJ0aWVzID0gdGhpcy5nZXRQcm9wZXJ0aWVzKGVsZW1lbnQpO1xuICAgICAgICB0cmVlW3JlZl0gPSB7IC4uLnByb3BlcnRpZXMgfTtcbiAgICAgICAgaWYgKGVsZW1lbnQuaGFzQ2hpbGRyZW4oKSkge1xuICAgICAgICAgIHRyZWVbcmVmXS5jaGlsZHJlbiA9IHt9O1xuICAgICAgICAgIHRoaXMuY29sbGVjdENoaWxkcmVuKFxuICAgICAgICAgICAgdHJlZVtyZWZdLmNoaWxkcmVuLFxuICAgICAgICAgICAgZWxlbWVudC5fX2NoaWxkTGlzdFxuICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgc3RhdGljIGdldFByb3BlcnRpZXMoZWxlbWVudCkge1xuICAgICAgY29uc3QgcHJvcHMgPSB7fTtcbiAgICAgIGNvbnN0IGxpc3QgPSBbXG4gICAgICAgIFwiYWxwaGFcIixcbiAgICAgICAgXCJhY3RpdmVcIixcbiAgICAgICAgXCJhdHRhY2hlZFwiLFxuICAgICAgICBcImJvdW5kc01hcmdpblwiLFxuICAgICAgICBcImNvbG9yXCIsXG4gICAgICAgIFwiY2xpcHBpbmdcIixcbiAgICAgICAgXCJlbmFibGVkXCIsXG4gICAgICAgIFwiaFwiLFxuICAgICAgICBcImlkXCIsXG4gICAgICAgIFwiaXNDb21wb25lbnRcIixcbiAgICAgICAgXCJtb3VudFwiLFxuICAgICAgICBcIm1vdW50WVwiLFxuICAgICAgICBcIm1vdW50WFwiLFxuICAgICAgICBcInBpdm90XCIsXG4gICAgICAgIFwicGl2b3RYXCIsXG4gICAgICAgIFwicGl2b3RZXCIsXG4gICAgICAgIFwicmVmXCIsXG4gICAgICAgIFwicmVuZGVyT2Zmc2NyZWVuXCIsXG4gICAgICAgIFwic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kgPSAwLCBuID0gZW50ZXJTdGF0ZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgIHRoaXMuX19zZXRTdGF0ZShlbnRlclN0YXRlc1tpXSk7XG4gICAgICAgICAgICAgIHRoaXMuX2NhbGxFbnRlcih0aGlzLl9zdGF0ZSwgYXJncywgY29udGV4dCk7XG4gICAgICAgICAgICAgIGNvbnN0IHN0YXRlQ2hhbmdlT3ZlcnJpZGRlbiA9IHRoaXMuX3NldFN0YXRlSWQgIT09IHNldFN0YXRlSWQ7XG4gICAgICAgICAgICAgIGlmIChzdGF0ZUNoYW5nZU92ZXJyaWRkZW4pIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fX3NldFN0YXRlKG5ld1N0YXRlKTtcbiAgICAgICAgaWYgKHRoaXMuX2NoYW5nZWRTdGF0ZSkge1xuICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSB7XG4gICAgICAgICAgICBuZXdTdGF0ZTogbmV3U3RhdGUuX19wYXRoLFxuICAgICAgICAgICAgcHJldlN0YXRlOiBwcmV2U3RhdGUuX19wYXRoXG4gICAgICAgICAgfTtcbiAgICAgICAgICBpZiAoYXJncykge1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZFN0YXRlKGNvbnRleHQsIC4uLmFyZ3MpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkU3RhdGUoY29udGV4dCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9vblN0YXRlQ2hhbmdlKSB7XG4gICAgICAgICAgY29uc3QgY29udGV4dCA9IHtcbiAgICAgICAgICAgIG5ld1N0YXRlOiBuZXdTdGF0ZS5fX3BhdGgsXG4gICAgICAgICAgICBwcmV2U3RhdGU6IHByZXZTdG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3JvdXRlci5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkoYWxpYXMpKSB7XG4gICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcy5fcm91dGVyLnByb3RvdHlwZSwgYWxpYXMsIGRlc2NyaXB0b3IpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBkZXNjcmlwdG9yc1tpbmRleF0gPSBudWxsO1xuICAgICAgICAgIGFsaWFzZXNbaW5kZXhdID0gbnVsbDtcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgICBsZXQgdHlwZSA9IHZvaWQgMDtcbiAgICAgIGRlc2NyaXB0b3JzLmZvckVhY2goKGRlc2NyaXB0b3IpID0+IHtcbiAgICAgICAgaWYgKGRlc2NyaXB0b3IpIHtcbiAgICAgICAgICBjb25zdCBkZXNjVHlwZSA9IHRoaXMuX2dldERlc2NyaXB0b3JUeXBlKGRlc2NyaXB0b3IpO1xuICAgICAgICAgIGlmICh0eXBlICYmIHR5cGUgIT09IGRlc2NUeXBlKSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4oYFtMaWdodG5pbmddIE1lbWJlciAke21lbWJlcn0gaW4gJHt0aGlzLl90eXBlLm5hbWV9IGhhcyBpbmNvbnNpc3RlbnQgdHlwZXMuYCk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgfVxuICAgICAgICAgIHR5cGUgPSBkZXNjVHlwZTtcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgICBzd2l0Y2ggKHR5cGUpIHtcbiAgICAgICAgY2FzZSBcIm1ldGhvZFwiOlxuICAgICAgICAgIHRoaXMuX2FkZE1ldGhvZFJvdXRlcihtZW1iZXIsIGRlc2NyaXB0b3JzLCBhbGlhc2VzKTtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSBcImdldHRlclwiOlxuICAgICAgICAgIHRoaXMuX2FkZEdldHRlclNldHRlclJvdXRlcnMobWVtYmVyK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BzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XWApO1xuICAgICAgICAgICAgdGhpcy5wYXJzZVByb3BlcnR5QmluZGluZ3ModmFsdWUsIGNvbnRleHQsIHNoYWRlckN1cnNvcik7XG4gICAgICAgICAgfSBlbHNlIGlmIChrZXkgPT09IFwidGV4dHVyZVwiICYmIFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHZhbHVlKSkge1xuICAgICAgICAgICAgY29uc3QgcHJvcEtleSA9IGN1cnNvciArIFwiX190ZXh0dXJlXCI7XG4gICAgICAgICAgICBjb25zdCB0eXBlID0gdmFsdWUudHlwZTtcbiAgICAgICAgICAgIGlmICh0eXBlKSB7XG4gICAgICAgICAgICAgIHN0b3JlLnB1c2godHlwZSk7XG4gICAgICAgICAgICAgIGxvYy5wdXNoKGB2YXIgJHtwcm9wS2V5fSA9IG5ldyBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSgke2N1cnNvcn0uc3RhZ2UpYCk7XG4gICAgICAgICAgICAgIHRoaXMucGFyc2VUZW1wbGF0ZVByb3BSZWModmFsdWUsIGNvbnRleHQsIHByb3BLZXkpO1xuICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHtwcm9wS2V5fWApO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgbG9jLnB1c2goYCR7cHJvcEtleX0gPSAke2N1cnNvcn0udGV4dHVyZWApO1xuICAgICAgICAgICAgICB0aGlzLnBhcnNlVGVtcGxhdGVQcm9wUmVjKHZhbHVlLCBjb250ZXh0LCBwcm9wS2V5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHZhbHVlKSAmJiB2YWx1ZS5fX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aWYgKCF0aGlzLl9fc2lnbmFscykge1xuICAgICAgICB0aGlzLl9fc2lnbmFscyA9IHt9O1xuICAgICAgfVxuICAgICAgZm9yIChsZXQga2V5IGluIHYpIHtcbiAgICAgICAgY29uc3QgZCA9IHZba2V5XTtcbiAgICAgICAgaWYgKGQgPT09IHZvaWQgMCkge1xuICAgICAgICAgIGRlbGV0ZSB0aGlzLl9fc2lnbmFsc1trZXldO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuX19zaWduYWxzW2tleV0gPSB2O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBwYXNzU2lnbmFscygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fcGFzc1NpZ25hbHMgfHwge307XG4gICAgfVxuICAgIHNldCBwYXNzU2lnbmFscyh2KSB7XG4gICAgICB0aGlzLl9fcGFzc1NpZ25hbHMgPSBPYmplY3QuYXNzaWduKHRoaXMuX19wYXNzU2lnbmFscyB8fCB7fSwgdik7XG4gICAgfVxuICAgIHNldCBhbHRlclBhc3NTaWduYWxzKHYpIHtcbiAgICAgIGlmICghVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlNpZ25hbHM6IHNwZWNpZnkgYW4gb2JqZWN0IHdpdGggc2lnbmFsLXRvLWZpcmUgbWFwcGluZ3NcIik7XG4gICAgICB9XG4gICAgICBpZiAoIXRoaXMuX19wYXNzU2lnbmFscykge1xuICAgICAgICB0aGlzLl9fcGFzc1NpZ25hbHMgPSB7fTtcbiAgICAgIH1cbiAgICAgIGZvciAobGV0IGtleSBpbiB2KSB7XG4gICAgICAgIGNvbnN0IGQgPSB2W2tleV07XG4gICAgICAgIGlmIChkID09PSB2b2lkIDApIHtcbiAgICAgICAgICBkZWxldGUgdGhpcy5fX3Bhc3NTaWduYWxzW2tleV07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fX3Bhc3NTaWduYWxzW2tleV0gPSB2O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHNpZ25hbChldmVudCwgLi4uYXJncykge1xuICAgICAgcmV0dXJuIHRoaXMuX3NpZ25hbChldmVudCwgYXJncyk7XG4gICAgfVxuICAgIF9zaWduYWwoZXZlbnQsIGFyZ3MpIHtcbiAgICAgIGNvbnN0IHNpZ25hbFBhcmVudCA9IHRoaXMuX2dldFBhcmVudFNpZ25hbEhhbmRsZXIoKTtcbiAgICAgIGlmIChzaWduYWxQYXJlbnQpIHtcbiAgICAgICAgaWYgKHRoaXMuX19zaWduYWxzKSB7XG4gICAgICAgICAgbGV0IGZpcmVFdmVudCA9IHRoaXMuX19zaWduYWxzW2V2ZW50XTtcbiAgICAgICAgICBpZiAoZmlyZUV2ZW50ID09PSBmYWxzZSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoZmlyZUV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoZmlyZUV2ZW50ID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgIGZpcmVFdmVudCA9IGV2ZW50O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKFV0aWxzJDEuaXNGdW5jdGlvbihmaXJlRXZlbnQpKSB7XG4gICAgICAgICAgICAgIHJldHVybiBmaXJlRXZlbnQoLi4uYXJncyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc2lnbmFsUGFyZW50Ll9oYXNNZXRob2QoZmlyZUV2ZW50KSkge1xuICAgICAgICAgICAgICByZXR1cm4gc2lnbmFsUGFyZW50W2ZpcmVFdmVudF0oLi4uYXJncyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGxldCBwYXNzU2lnbmFsID0gdGhpcy5fX3Bhc3NTaWduYWxzICYmIHRoaXMuX19wYXNzU2lnbmFsc1tldmVudF07XG4gICAgICAgIGlmIChwYXNzU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b2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVsLCByLmFscGhhKTtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHggKyBlbGVtZW50Q29yZS5fdyAqIHIudGE7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX3cgKiByLnRjO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHk7XG4gICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVciwgci5hbHBoYSk7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4ICsgZWxlbWVudENvcmUuX3cgKiByLnRhICsgZWxlbWVudENvcmUuX2ggKiByLnRiO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl93ICogci50YyArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ5O1xuICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yQnIsIHIuYWxwaGEpO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weCArIGVsZW1lbnRDb3JlLl9oICogci50YjtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHkgKyBlbGVtZW50Q29yZS5faCAqIHIudGQ7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgICAgdWludHNbb2Zmc2V0XSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JCbCwgci5hbHBoYSk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBsZXQgY3ggPSByLnB4ICsgZWxlbWVudENvcmUuX3cgKiByLnRhO1xuICAgICAgICBsZXQgY3kgPSByLnB5ICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHk7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVsLCByLmFscGhhKTtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGN4O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weTtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx5O1xuICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yVXIsIHIuYWxwaGEpO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gY3g7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBjeTtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbG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lsaXR5Q2hhbmdlSGFuZGxlcigpO1xuICAgICAgdGhpcy5zdGFnZSA9IG51bGw7XG4gICAgICBkZWxldGUgdGhpcy5zdGFnZTtcbiAgICB9XG4gICAgc3RhcnRMb29wKCkge1xuICAgICAgdGhpcy5fbG9vcGluZyA9IHRydWU7XG4gICAgICBpZiAoIXRoaXMuX2F3YWl0aW5nTG9vcCkge1xuICAgICAgICB0aGlzLmxvb3AoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgc3RvcExvb3AoKSB7XG4gICAgICB0aGlzLl9sb29waW5nID0gZmFsc2U7XG4gICAgfVxuICAgIHN3aXRjaExvb3AoKSB7XG4gICAgICBpZiAodGhpcy5faWRsZUxvb3BDb3VudGVyIDwgdGhpcy5faWRsZUxvb3BEZWxheSkge1xuICAgICAgICB0aGlzLl9pZGxlTG9vcENvdW50ZXIrKztcbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuICAgICAgaWYgKCF0aGlzLnN0YWdlLmN0eC5oYXNSZW5kZXJVcGRhdGVzKCkpIHtcbiAgICAgICAgdGhpcy5zdG9wTG9vcCgpO1xuICAgICAgICB0aGlzLl9sb29wSGFuZGxlciA9IHNldEludGVydmFsKCgpID0+IHtcbiAgICAgICAgICB0aGlzLnN0YWdlLnVwZGF0ZUZyYW1lKCk7XG4gICAgICAgICAgdGhpcy5zdGFnZS5pZGxlRnJhbWUoKTtcbiAgICAgICAgICBpZiAodGhpcy5zdGFnZS5jdHguaGFzUmVuZGVyVXBkYXRlcygpKSB7XG4gICAgICAgICAgICBjbGVhckludGVydmFsKHRoaXMuX2xvb3BIYW5kbGVyKTtcbiAgICAgICAgICAgIHRoaXMuc3RhcnRMb29wKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9LCAxZTMgLyA2MCk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLl9pZGxlTG9vcENvdW50ZXIgPSAwO1xuICAgICAgfVxuICAgIH1cbiAgICBsb29wKCkge1xuICAgICAgbGV0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bHVlRGF0YTogdmlldy5nZXRVaW50MzIoNjAsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAga3ZwczogW10sXG4gICAgICAgICAgbWlwbWFwczogW10sXG4gICAgICAgICAgZ2V0IHdpZHRoKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMucGl4ZWxXaWR0aDtcbiAgICAgICAgICB9LFxuICAgICAgICAgIGdldCBoZWlnaHQoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5waXhlbEhlaWdodDtcbiAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIGNvbnN0IHByb3BzID0gKG9iaikgPT4ge1xuICAgICAgICAgIGNvbnN0IHAgPSBbXTtcbiAgICAgICAgICBmb3IgKGxldCB2IGluIG9iaikge1xuICAgICAgICAgICAgcC5wdXNoKG9ialt2XSk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJldHVybiBwO1xuICAgICAgICB9O1xuICAgICAgICBjb25zdCBmb3JtYXRzID0gT2JqZWN0LnZhbHVlcyhzZWxmMi5zdGFnZS5yZW5kZXJlci5nZXRDb21wcmVzc2VkVGV4dHVyZUV4dGVuc2lvbnMoKSkuZmlsdGVyKChvYmopID0+IG9iaiAhPSBudWxsKS5tYXAoKG9iaikgPT4gcHJvcHMob2JqKSkucmVkdWNlKChwcmV2LCBjdXJyZW50KSA9PiBwcmV2LmNvbmNhdChjdXJyZW50KSk7XG4gICAgICAgIGlmICghZm9ybWF0cy5pbmNsdWRlcyhkYXRhLmdsSW50ZXJuYWxGb3JtYXQpKSB7XG4gICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gVW5yZWNvZ25pemVkIHRleHR1cmUgZXh0ZW5zaW9uIGZvcm1hdDpcIiwgc3JjLCBkYXRhLmdsSW50ZXJuYWxGb3JtYXQsIHNlbGYyLnN0YWdlLnJlbmRlcmVyLmdldENvbXByZXNzZWRUZXh0dXJlRXh0ZW5zaW9ucygpKTtcbiAgICAgICAgfVxu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xuICAgICAgICBpbWFnZS5vbmVycm9yID0gZnVuY3Rpb24oZXJyKSB7XG4gICAgICAgICAgaWYgKGltYWdlLnNyYykge1xuICAgICAgICAgICAgcmV0dXJuIGNiKFwiSW1hZ2UgbG9hZCBlcnJvclwiKTtcbiAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIGltYWdlLm9ubG9hZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgIHNvdXJjZTogaW1hZ2UsXG4gICAgICAgICAgICByZW5kZXJJbmZvOiB7IHNyYywgY29tcHJlc3NlZDogZmFsc2UgfSxcbiAgICAgICAgICAgIGhhc0FscGhhOiBpc1BuZyB8fCBoYXNBbHBoYVxuICAgICAgICAgIH0pO1xuICAgICAgICB9O1xuICAgICAgICBpbWFnZS5zcmMgPSBzcmM7XG4gICAgICAgIGNhbmNlbENiID0gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgaW1hZ2Uub25lcnJvciA9IG51bGw7XG4gICAgICAgICAgaW1hZ2Uub25sb2FkID0gbnVsbDtcbiAgICAgICAgICBpbWFnZS5yZW1vdmVBdHRyaWJ1dGUoXCJzcmNcIik7XG4gICAgICAgIH07XG4gICAgICB9XG4gICAgICByZXR1cm4gY2FuY2VsQ2I7XG4gICAgfVxuICAgIGNyZWF0ZVdlYkdMQ29udGV4dCh3LCBoKSB7XG4gICAgICBsZXQgY2FudmFzID0gdGhpcy5zdGFnZS5nZXRPcHRpb24oXCJjYW52YXNcIikgfHwgZG9jdW1lbnQuY3JlYXRlRWxlbWVudChcImNhbnZhc1wiKTtcbiAgICAgIGlmICh3ICYmIGgpIHtcbiAgICAgICAgY2FudmFzLndpZHRoID0gdztcbiAgICAgICAgY2FudmFzLmhlaWdodCA9IGg7XG4gICAgICB9XG4gICAgICBsZXQgb3B0cyA9IHtcbiAgICAgICAgYWxwaGE6IHRydWUsXG4gICAgICAgIGFudGlhbGlhczogZmFsc2UsXG4gICAgICA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XG4gICAgICBsZXQga2V5czIgPSBPYmplY3Qua2V5cyhvYmoyKTtcbiAgICAgIGlmIChrZXlzMS5sZW5ndGggIT09IGtleXMyLmxlbmd0aCkge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGtleXMxLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBjb25zdCBrMSA9IGtleXMxW2ldO1xuICAgICAgICBjb25zdCBrMiA9IGtleXMyW2ldO1xuICAgICAgICBpZiAoazEgIT09IGsyKSB7XG4gICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IHYxID0gb2JqMVtrMV07XG4gICAgICAgIGNvbnN0IHYyID0gb2JqMltrMl07XG4gICAgICAgIGlmICghVXRpbHMuZXF1YWxWYWx1ZXModjEsIHYyKSkge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICAgIHN0YXRpYyBlcXVhbEFycmF5cyh2MSwgdjIpIHtcbiAgICAgIGlmICh2MS5sZW5ndGggIT09IHYyLmxlbmd0aCkge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHYxLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBpZiAoIXRoaXMuZXF1YWxWYWx1ZXModjFbaV0sIHYyW2ldKSkge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICB9XG4gIGNsYXNzIFdlYkdMU3RhdGUge1xuICAgIGNvbnN0cnVjdG9yKGlkLCBnbCkge1xuICAgICAgdGhpcy5faWQgPSBpZDtcbiAgICAgIHRoaXMuX2dsID0gZ2w7XG4gICAgICB0aGlzLl9wcm9ncm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AgICBmb3IgKGxldCBrZXkgaW4gZGVmKSB7XG4gICAgICAgIGlmIChkZWYuaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgIGxldCBvYmogPSBkZWZba2V5XTtcbiAgICAgICAgICBpZiAoIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKG9iaikpIHtcbiAgICAgICAgICAgIG9iaiA9IHsgdjogb2JqIH07XG4gICAgICAgICAgfVxuICAgICAgICAgIGxldCBwID0gcGFyc2VGbG9hdChrZXkpO1xuICAgICAgICAgIGlmIChrZXkgPT09IFwic21cIikge1xuICAgICAgICAgICAgZGVmYXVsdFNtb290aG5lc3MgPSBvYmoudjtcbiAgICAgICAgICB9IGVsc2UgaWYgKCFpc05hTihwKSAmJiBwID49IDAgJiYgcCA8PSAyKSB7XG4gICAgICAgICAgICBvYmoucCA9IHA7XG4gICAgICAgICAgICBvYmouZiA9IFV0aWxzJDEuaXNGdW5jdGlvbihvYmoudik7XG4gICAgICAgICAgICBvYmoubHYgPSBvYmouZiA/IG9iai52KDAsIDApIDogb2JqLnY7XG4gICAgICAgICAgICBpdGVtcy5wdXNoKG9iaik7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpdGVtcyA9IGl0ZW1zLnNvcnQoZnVuY3Rpb24oYSwgYikge1xuICAgICAgICByZXR1cm4gYS5wIC0gYi5wO1xuICAgICAgfSk7XG4gICAgICBuID0gaXRlbXMubGVuZ3RoO1xuICAgICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICBsZXQgbGFzdCA9IGkgPT09IG4gLSAxO1xuICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KFwicGVcIikpIHtcbiAgICAgICAgICBpdGVtc1tpXS5wZSA9IGxhc3QgPyBpdGVtc1tpXS5wIDw9IDEgPyAxIDogMiA6IGl0ZW1zW2kgKyAxXS5wO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbn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ICAgICBjb25zdCBuYyA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKG5pLmx2KTtcbiAgICAgICAgICAgICAgICBjb25zdCBwYyA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKHBpLmx2KTtcbiAgICAgICAgICAgICAgICBjb25zdCBkID0gMSAvIChuaS5wIC0gcGkucCk7XG4gICAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IFtcbiAgICAgICAgICAgICAgICAgIGQgKiAobmNbMF0gLSBwY1swXSksXG4gICAgICAgICAgICAgICAgICBkICogKG5jWzFdIC0gcGNbMV0pLFxuICAgICAgICAgICAgICAgICAgZCAqIChuY1syXSAtIHBjWzJdKSxcbiAgICAgICAgICAgICAgICAgIGQgKiAobmNbM10gLSBwY1szXSlcbiAgICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnMgPSAobmkubHYgLSBwaS5sdikgLyAobmkucCAtIHBpLnApO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBmb3IgKGkgPSAwOyBpIDwgbiAtIDE7IGkrKykge1xuICAgICAgICBpZiAoIWl0ZW1zW2ldLmYpIHtcbiAgICAgICAgICBsZXQgbGFzdCA9IGkgPT09IG4gLSAxO1xuICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoXCJ2ZVwiKSkge1xuICAgICAgICAgICAgaXRlbXNbaV0udmUgPSBsYXN0ID8gaXRlbXNbaV0ubHYgOiBpdGVtc1tpICsgMV0ubHY7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChVdGlscyQxLmlzTnVtYmVyKGl0ZW1zW2ldLnYpICYmIFV0aWxzJDEuaXNOdW1iZXIoaXRlbXNbaV0ubHYpKSB7XG4gICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc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V0dXJuIGZ1bmN0aW9uKHApIHtcbiAgICAgICAgICBpZiAocCA9PT0gMClcbiAgICAgICAgICAgIHJldHVybiB2MTtcbiAgICAgICAgICBpZiAocCA9PT0gMSlcbiAgICAgICAgICAgIHJldHVybiB2MjtcbiAgICAgICAgICByZXR1cm4gdjIgKiBwICsgdjEgKiAoMSAtIHApO1xuICAgICAgICB9O1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHApIHtcbiAgICAgICAgICBpZiAocCA9PT0gMClcbiAgICAgICAgICAgIHJldHVybiB2MTtcbiAgICAgICAgICBpZiAocCA9PT0gMSlcbiAgICAgICAgICAgIHJldHVybiB2MjtcbiAgICAgICAgICByZXR1cm4gTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnMsIHApO1xuICAgICAgICB9O1xuICAgICAgfVxuICAgIH1cbiAgICBzdGF0aWMgZ2V0U3BsaW5lUmdiYVZhbHVlRnVuY3Rpb24odjEsIHYyLCBwMSwgcDIsIG8xLCBpMiwgczEsIHMyKSB7XG4gICAgICBsZXQgZHAgPSBwMiAtIHAxO1xuICAgICAgczFbMF0gKj0gZHA7XG4gICAgICBzMVsxXSAqPSBkcDtcbiAgICAgIHMxWzJdICo9IGRwO1xuICAgICAgczFbM10gKj0gZHA7XG4gICAgICBzMlswXSAqPSBkcDtcbiAgICAgIHMyWzFdICo9IGRwO1xuICAgICAgczJbMl0gKj0gZHA7XG4gICAgICBzMlszXSAqPSBkcDtcbiAgICAgIGxldCBjdjEgPSBNdWx0aVNwbGluZS5nZXRSZ2JhQ29tcG9uZW50cyh2MSk7XG4gICAgICBsZXQgY3YyID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHModjIpO1xuICAgICAgbGV0IGhlbHBlcnMgPSBbXG4gICAgICAgIE11bHRpU3BsaW5lLmdldFNwbGluZUhlbHBlcnMoY3YxWzBdLCBjdjJbMF0sIG8xLCBpMiwgczFbMF0sIHMyWzBdKSxcbiAgICAgICAgTXVsdGlTcGxpbmUuZ2V0U3BsaW5lSGVscGVycyhjdjFbMV0sIGN2MlsxXSwgbzEsIGkyLCBzMVsxXSwgczJbMV0pLFxuICAgICAgICBNdWx0aVNwbGluZS5nZXRTcGxpbmVIZWxwZXJzKGN2MVsyXSwgY3YyWzJdLCBvMSwgaTIsIHMxWzJdLCBzMlsyXSksXG4gICAgICAgIE11bHRpU3BsaW5lLmdldFNwbGluZUhlbHBlcnMoY3YxWzNdLCBjdjJbM10sIG8xLCBpMiwgczFbM10sIHMyWzNdKVxuICAgICAgXTtcbiAgICAgIGlmICghaGVscGVyc1swXSkge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24ocCkge1xuICAgICAgICAgIGlmIChwID09PSAwKVxuICAgICAgICAgICAgcmV0dXJuIHYxO1xuICAgICAgICAgIGlmIChwID09PSAxKVxuICAgICAgICAgICAgcmV0dXJuIHYyO1xuICAgICAgICAgIHJldHVybiBNdWx0aVNwbGluZS5tZXJnZUNvbG9ycyh2MiwgdjEsIHApO1xuICAgICAgICB9O1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHApIHtcbiAgICAgICAgICBpZiAocCA9PT0gMClcbiAgICAgICAgICAgIHJldHVybiB2MTtcbiAgICAgICAgICBpZiAocCA9PT0gMSlcbiAgICAgICAgICAgIHJldHVybiB2MjtcbiAgICAgICAgICByZXR1cm4gTXVsdGlTcGxpbmUuZ2V0QXJnYk51bWJlcihbXG4gICAgICAgICAgICBNYXRoLm1pbigyNTUsIE11bHRpU3BsaW5lLmNhbGN1bGF0ZVNwbGluZShoZWxwZXJzWzBdLCBwKSksXG4gICAgICAgICAgICBNYXRoLm1pbigyNTUsIE11bHRpU3BsaW5lLmNhbGN1bGF0ZVNwbGluZShoZWxwZXJzWzFdLCBwKSksXG4gICAgICAgICAgICBNYXRoLm1pbigyNTUsIE11bHRpU3BsaW5lLmNhbGN1bGF0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ljID0gaGVscGVyc1s1XTtcbiAgICAgIGxldCB5ZCA9IGhlbHBlcnNbNl07XG4gICAgICBpZiAoeGEgPT09IC0yICYmIHlhID09PSAtMiAmJiB4YyA9PT0gMCAmJiB5YyA9PT0gMCkge1xuICAgICAgICByZXR1cm4gcDtcbiAgICAgIH1cbiAgICAgIGxldCB0ID0gMC41LCBjYngsIGR4O1xuICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG4gICAgICAgIGR4ID0gcCAtIGNieDtcbiAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5YykgKyB5ZDtcbiAgICAgICAgfVxuICAgICAgICBsZXQgY2J4ZCA9IHQgKiAodCAqICgzICogeGEpICsgMiAqIHhiKSArIHhjO1xuICAgICAgICBpZiAoY2J4ZCA+IDFlLTEwICYmIGNieGQgPCAxZS0xMCkge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHQgKz0gZHggLyBjYnhkO1xuICAgICAgfVxuICAgICAgbGV0IG1pblQgPSAwO1xuICAgICAgbGV0IG1heFQgPSAxO1xuICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgIHQgPSAwLjUgKiAobWluVCArIG1heFQpO1xuICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuICAgICAgICBkeCA9IHAgLSBjYng7XG4gICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpICsgeWQ7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGR4IDwgMCkge1xuICAgICAgIC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PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5fcCA9IDI7XG4gICAgICAgICAgfSBlbHNlIGlmIChkdXJhdGlvbiA+IDApIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9wIDwgMSkge1xuICAgICAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gdGhpcy5zZXR0aW5ncy5kdXJhdGlvbjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRoaXMuX3AgKz0gZHQgLyBkdXJhdGlvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHRoaXMuX3AgPj0gMikge1xuICAgICAgICAgICAgdGhpcy5fcCA9IDI7XG4gICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgIHRoaXMuZW1pdChcInN0b3BGaW5pc2hcIik7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuZW1pdChcInByb2dyZXNzXCIsIHRoaXMuX3ApO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSBlbHNlIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLkZPUldBUkQpIHtcbiAgICAgICAgaWYgKHRoaXMuX3AgPCAxKSB7XG4gICAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3MuZHVyYXRpb24gPT0gMCkge1xuICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3AgKz0gZHQgLyB0aGlzLnNldHRpbmdzLmR1cmF0aW9uO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodGhpcy5fcCA+PSAxKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5GT1JXQVJEKSB7XG4gICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgICAgdGhpcy5lbWl0KFwic3RvcEZpbmlzaFwiKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGlmICh0aGlzLl9yZXBlYXRzTGVmdCA+IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZXBlYXRzTGVmdC0tO1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuZW1pdChcInJlcGVhdFwiLCB0aGlzLl9yZXBlYXRzTGVmdCk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KFwic3RvcEZpbmlzaFwiKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmVtaXQoXCJwcm9ncmVzc1wiLCB0aGlzLl9wKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgX3Byb2dyZXNzU3RvcFRyYW5zaXRpb24oZHQpIHtcbiAgICAgIGlmICh0aGlzLl9zdG9wUCA8IDEpIHtcbiAgICAgICAgaWYgKHRoaXMuX3N0b3BEZWxheUxlZnQgPiAwKSB7XG4gICAgICAgICAgdGhpcy5fc3RvcERlbGF5TGVmdCAtPSBkdDtcbiAgICAgICAgICBpZiAodGhpcy5fc3RvcERlbGF5TGVmdCA8IDApIHtcbiAgICAgICAgICAgIG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5mb2N1c1BhdGg7XG4gICAgICBjb25zdCBuID0gcGF0aC5sZW5ndGg7XG4gICAgICBmb3IgKGxldCBpID0gbiAtIDE7IGkgPj0gMDsgaS0tKSB7XG4gICAgICAgIGNvbnN0IGV2ZW50ID0gcGF0aFtpXS5fZ2V0TW9zdFNwZWNpZmljSGFuZGxlZE1lbWJlcihldmVudHMpO1xuICAgICAgICBpZiAoZXZlbnQgIT09IHZvaWQgMCkge1xuICAgICAgICAgIGNvbnN0IHJldHVyblZhbHVlID0gcGF0aFtpXVtldmVudF0oLi4uYXJncyk7XG4gICAgICAgICAgaWYgKHJldHVyblZhbHVlICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIF9yZWNlaXZlS2V5ZG93bihlKSB7XG4gICAgICBjb25zdCBvYmogPSBlO1xuICAgICAgY29uc3Qga2V5ID0gdGhpcy5fX2tleW1hcFtlLmtleUNvZGVdO1xuICAgICAgY29uc3QgcGF0aCA9IHRoaXMuZm9jdXNQYXRoO1xuICAgICAgbGV0IGtleXM7XG4gICAgICBpZiAoa2V5KSB7XG4gICAgICAgIGtleXMgPSBBcnJheS5pc0FycmF5KGtleSkgPyBrZXkgOiBba2V5XTtcbiAgICAgIH1cbiAgICAgIGlmIChrZXlzKSB7XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0ga2V5cy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICBjb25zdCBoYXNUaW1lciA9IHRoaXMuX19rZXlwcmVzc1RpbWVycy5oYXMoa2V5c1tpXSk7XG4gICAgICAgICAgaWYgKHBhdGhbcGF0aC5sZW5ndGggLSAxXS5sb25ncHJlc3MgJiYgaGFzVGltZXIpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKCF0aGlzLnN0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5nZShhZmZlY3RlZCwgY2xpZW50WCwgY2xpZW50WSk7XG4gICAgICBob3ZlcmFibGVDaGlsZHJlbi5zb3J0KChhLCBiKSA9PiB7XG4gICAgICAgIGlmIChhLnpJbmRleCA+IGIuekluZGV4KSB7XG4gICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgIH0gZWxzZSBpZiAoYS56SW5kZXggPCBiLnpJbmRleCkge1xuICAgICAgICAgIHJldHVybiAtMTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZXR1cm4gYS5pZCA+IGIuaWQgPyAxIDogLTE7XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgICAgaWYgKGhvdmVyYWJsZUNoaWxkcmVuLmxlbmd0aCkge1xuICAgICAgICByZXR1cm4gaG92ZXJhYmxlQ2hpbGRyZW4uc2xpY2UoLTEpWzBdO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICB9XG4gICAgfVxuICAgIF9maW5kQ2hpbGRyZW4oYnVja2V0LCBjaGlsZHJlbikge1xuICAgICAgbGV0IG4gPSBjaGlsZHJlbi5sZW5ndGg7XG4gICAgICB3aGlsZSAobi0tKSB7XG4gICAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGRyZW5bbl07XG4gICAgICAgIGlmIChjaGlsZC5fX2FjdGl2ZSAmJiBjaGlsZC5jb2xsaXNpb24pIHtcbiAgICAgICAgICBpZiAoY2hpbGQuY29sbGlzaW9uID09PSB0cnVlKSB7XG4gICAgICAgICAgICBidWNrZXQucHVzaChjaGlsZCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChjaGlsZC5oYXNDaGlsZHJlbigpKSB7XG4gICAgICAgICAgICB0aGlzLl9maW5kQ2hpbGRyZW4oYnVja2V0LCBjaGlsZC5jaGlsZHJlbik7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gYnVja2V0O1xuICAgIH1cbiAgICBfd2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TtcbiAgICAgIGlmICghVXRpbHMkMS5pc1BTNCkge1xuICAgICAgICBpbWcuY3Jvc3NPcmlnaW4gPSBcIkFub255bW91c1wiO1xuICAgICAgfVxuICAgICAgaW1nLnNyYyA9IHVybDtcbiAgICB9XG4gIH1cbiAgY2xhc3MgT2JqTWVyZ2VyIHtcbiAgICBzdGF0aWMgaXNNZihmKSB7XG4gICAgICByZXR1cm4gVXRpbHMkMS5pc0Z1bmN0aW9uKGYpICYmIGYuX19tZjtcbiAgICB9XG4gICAgc3RhdGljIG1mKGYpIHtcbiAgICAgIGYuX19tZiA9IHRydWU7XG4gICAgICByZXR1cm4gZjtcbiAgICB9XG4gICAgc3RhdGljIG1lcmdlKGEsIGIpIHtcbiAgICAgIGNvbnN0IGFrcyA9IE9iamVjdC5rZXlzKGEpO1xuICAgICAgY29uc3QgYmtzID0gT2JqZWN0LmtleXMoYik7XG4gICAgICBpZiAoIWJrcy5sZW5ndGgpIHtcbiAgICAgICAgcmV0dXJuIGE7XG4gICAgICB9XG4gICAgICBjb25zdCBhaSA9IHt9O1xuICAgICAgY29uc3QgYmkgPSB7fTtcbiAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYmtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBjb25zdCBrZXkgPSBia3NbaV07XG4gICAgICAgIGFpW2tleV0gPSAtMTtcbiAgICAgICAgYmlba2V5XSA9IGk7XG4gICAgICB9XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGFrcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgY29uc3Qga2V5ID0gYWtzW2ldO1xuICAgICAgICBhaVtrZXldID0gaTtcbiAgICAgICAgaWYgKGJpW2tleV0gPT09IHZvaWQgMCkge1xuICAgICAgICAgIGJpW2tleV0gPSAtMTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgY29uc3QgYWtzbCA9IGFrcy5sZW5ndGg7XG4gICAgICBjb25zdCByZXN1bHQgPSB7fTtcbiAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYmtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBjb25zdCBrZXkgPSBia3NbaV07XG4gICAgICAgIGNvbnN0IGFJbmRleCA9IGFpW2tleV07XG4gICAgICAgIGxldCBjdXJJbmRleDIgPSBhSW5kZXg7XG4gICAgICAgIHdoaWxlICgtLWN1ckluZGV4MiA+PSAwKSB7XG4gICAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleDJdO1xuICAgICAgICAgIGlmIChiaVtha2V5XSAhPT0gLTEpIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB3aGlsZSAoKytjdXJJbmRleDIgPCBhSW5kZXgpIHtcbiAgICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4Ml07XG4gICAgICAgICAgcmVzdWx0W2FrZXldID0gYVtha2V5XTtcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBidiA9IGJba2V5XTtcbiAgICAgICAgY29uc3QgYXYgPSBhW2tleV07XG4gICAgICAgIGxldCByO1xuICAgICAgICBpZiAodGhpcy5pc01mKGJ2KSkge1xuICAgICAgICAgIHIgPSBidihhdik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKCFVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbChhdikgfHwgIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKGJ2KSkge1xuICAgICAgICAgICAgciA9IGJ2O1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByID0gT2JqTWVyZ2VyLm1lcmdlKGF2LCBidik7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChyICE9PSB2b2lkIDApIHtcbiAgICAgICAgICByZXN1bHRba2V5XSA9IHI7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGxldCBjdXJJbmRleCA9IGFrc2w7XG4gICA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XRpb24gPSB2O1xuICAgICAgfVxuICAgICAgdGhpcy51cGRhdGUoKTtcbiAgICB9XG4gICAgZ2V0IHJvbGwoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fcm9sbDtcbiAgICB9XG4gICAgc2V0IHJvbGwodikge1xuICAgICAgdGhpcy5fcm9sbCA9IHY7XG4gICAgICB0aGlzLnVwZGF0ZSgpO1xuICAgIH1cbiAgICBnZXQgcm9sbE1pbigpIHtcbiAgICAgIHJldHVybiB0aGlzLl9yb2xsTWluO1xuICAgIH1cbiAgICBzZXQgcm9sbE1pbih2KSB7XG4gICAgICB0aGlzLl9yb2xsTWluID0gdjtcbiAgICAgIHRoaXMudXBkYXRlKCk7XG4gICAgfVxuICAgIGdldCByb2xsTWF4KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3JvbGxNYXg7XG4gICAgfVxuICAgIHNldCByb2xsTWF4KHYpIHtcbiAgICAgIHRoaXMuX3JvbGxNYXggPSB2O1xuICAgICAgdGhpcy51cGRhdGUoKTtcbiAgICB9XG4gICAgZ2V0IGludmVydERpcmVjdGlvbigpIHtcbiAgICAgIHJldHVybiB0aGlzLl9pbnZlcnREaXJlY3Rpb247XG4gICAgfVxuICAgIHNldCBpbnZlcnREaXJlY3Rpb24odikge1xuICAgICAgaWYgKCF0aGlzLl9zdGFydGVkKSB7XG4gICAgICAgIHRoaXMuX2ludmVydERpcmVjdGlvbiA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBob3Jpem9udGFsKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2hvcml6b250YWw7XG4gICAgfVxuICAgIHNldCBob3Jpem9udGFsKHYpIHtcbiAgICAgIGlmICh2ICE9PSB0aGlzLl9ob3Jpem9udGFsKSB7XG4gICAgICAgIGlmICghdGhpcy5fc3RhcnRlZCkge1xuICAgICAgICAgIHRoaXMuX2hvcml6b250YWwgPSB2O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICB9XG4gIGNsYXNzIExpc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oge1xuICAgICAgICAgIHJlbmRlck9mZnNjcmVlbjogdHJ1ZSxcbiAgICAgICAgICBmb3JjZVpJbmRleENvbnRleHQ6IHRydWUsXG4gICAgICAgICAgb25BZnRlclVwZGF0ZTogU21vb3RoU2NhbGVDb21wb25lbnQuX3VwZGF0ZURpbWVuc2lvbnMsXG4gICAgICAgICAgQ29udGVudDoge31cbiAgICAgICAgfSxcbiAgICAgICAgU2NhbGU6IHsgdmlzaWJsZTogZmFsc2UgfVxuICAgICAgfTtcbiAgICB9XG4gICAgY29uc3RydWN0b3Ioc3RhZ2UpIHtcbiAgICAgIHN1cGVyKHN0YWdlKTtcbiAgICAgIHRoaXMuX3Ntb290aFNjYWxlID0gMTtcbiAgICAgIHRoaXMuX2l0ZXJhdGlvbnMgPSAwO1xuICAgIH1cbiAgICBnZXQgY29udGVudCgpIHtcbiAgICAgIHJldHVybiB0aGlzLnRhZyhcIkNvbnRlbnRcIik7XG4gICAgfVxuICAgIHNldCBjb250ZW50KHYpIHtcbiAgICAgIHRoaXMudGFnKFwiQ29udGVudFwiKS5wYXRjaCh2LCB0cnVlKTtcbiAgICB9XG4gICAgZ2V0IHNtb290aFNjYWxlKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3Ntb290aFNjYWxlO1xuICAgIH1cbiAgICBzZXQgc21vb3RoU2NhbGUodikge1xuICAgICAgaWYgKHRoaXMuX3Ntb290aFNjYWxlICE9PSB2KSB7XG4gICAgICAgIGxldCBpdHMgPSAwO1xuICAgICAgICB3aGlsZSAodiA8IDAuNSAmJiBpdHMgPCAxMikge1xuICAgICAgICAgIGl0cysrO1xuICAgICAgICAgIHYgPSB2ICogMjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnNjYWxlID0gdjtcbiAgICAgICAgdGhpcy5fc2V0SXRlcmF0aW9ucyhpdHMpO1xuICAgICAgICB0aGlzLl9zbW9vdGhTY2FsZSA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIF9zZXRJdGVyYXRpb25z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ICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2l0ZXJhdGlvbnMgPSBpdHM7XG4gICAgICB9XG4gICAgfVxuICAgIHN0YXRpYyBfdXBkYXRlRGltZW5zaW9ucyhjb250ZW50V3JhcCwgZm9yY2UpIHtcbiAgICAgIGNvbnN0IGNvbnRlbnQgPSBjb250ZW50V3JhcC5jaGlsZHJlblswXTtcbiAgICAgIGxldCB3ID0gY29udGVudC5yZW5kZXJXaWR0aDtcbiAgICAgIGxldCBoID0gY29udGVudC5yZW5kZXJIZWlnaHQ7XG4gICAgICBpZiAodyAhPT0gY29udGVudFdyYXAudyB8fCBoICE9PSBjb250ZW50V3JhcC5oIHx8IGZvcmNlKSB7XG4gICAgICAgIGNvbnRlbnRXcmFwLncgPSB3O1xuICAgICAgICBjb250ZW50V3JhcC5oID0gaDtcbiAgICAgICAgY29uc3Qgc2NhbGVycyA9IGNvbnRlbnRXcmFwLnBhcmVudC50YWcoXCJTY2FsZVwiKS5jaGlsZHJlbjtcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBzY2FsZXJzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgIHcgPSB3ICogMC41O1xuICAgICAgICAgIGggPSBoICogMC41O1xuICAgICAgICAgIHNjYWxlcnNbaV0udyA9IHc7XG4gICAgICAgICAgc2NhbGVyc1tpXS5oID0gaDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBnZXQgX3NpZ25hbFByb3h5KCkge1xuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuICB9XG4gIGNsYXNzIEJvcmRlckNvbXBvbmVudCBleHRlbmRzIENvbXBvbmVudCB7XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgIHJldHVybiB7XG4gICAgICAgIENvbnRlbnQ6IHt9LFxuICAgICAgICBCb3JkZXJzOiB7XG4gICAgICAgICAgVG9wOiB7IHJlY3Q6IHRydWUsIHZpc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cnlpbmcgdmVjNCB2Q29sb3I7XG4gICAgdW5pZm9ybSBzYW1wbGVyMkQgdVNhbXBsZXI7XG4gICAgdW5pZm9ybSB2ZWMyIHJlc29sdXRpb247XG4gICAgdW5pZm9ybSB2ZWM0IGZhZGU7XG4gICAgXG4gICAgdm9pZCBtYWluKCkge1xuICAgICAgICB2ZWM0IGNvbG9yID0gdGV4dHVyZTJEKHVTYW1wbGVyLCB2VGV4dHVyZUNvb3JkKSAqIHZDb2xvcjtcbiAgICAgICAgdmVjMiBoYWxmUmVzID0gMC41ICogcmVzb2x1dGlvbi54eTtcbiAgICAgICAgdmVjMiBwb2ludCA9IHZUZXh0dXJlQ29vcmQueHkgKiByZXNvbHV0aW9uLnh5O1xuICAgICAgICBcbiAgICAgICAgdmVjMiBwb3MxO1xuICAgICAgICB2ZWMyIHBvczI7XG4gICAgICAgIHZlYzIgZDtcbiAgICAgICAgZmxvYXQgYztcbiAgICAgICAgZmxvYXQgdCA9IDAuMDtcbiAgICAgICAgICAgICBcbiAgICAgICAgaWYoZmFkZVswXSA+IDAuMCkge1xuICAgICAgICAgICAgcG9zMSA9IHZlYzIocG9pbnQueCwgcG9pbnQueSk7XG4gICAgICAgICAgICBwb3MyID0gdmVjMihwb2ludC54LCBwb2ludC55ICsgZmFkZVswXSk7XG4gICAgICAgICAgICBkID0gcG9zMiAtIHBvczE7XG4gICAgICAgICAgICBjID0gZG90KHBvczEsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKGMsIDAuMCwgMS4wKSk7XG4gICAgICAgICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgICAgaWYoZmFkZVsxXSA+IDAuMCkge1xuICAgICAgICAgICAgdmVjMiBwb3MxID0gdmVjMihwb2ludC54IC0gcmVzb2x1dGlvbi54IC0gZmFkZVsxXSwgdlRleHR1cmVDb29yZC55KTtcbiAgICAgICAgICAgIHZlYzIgcG9zMiA9IHZlYzIocG9pbnQueCAtIHJlc29sdXRpb24ueCwgdlRleHR1cmVDb29yZC55KTtcbiAgICAgICAgICAgIGQgPSBwb3MxIC0gcG9zMjtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMiwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzJdID4gMC4wKSB7XG4gICAgICAgICAgICB2ZWMyIHBvczEgPSB2ZWMyKHZUZXh0dXJlQ29vcmQueCwgcG9pbnQueSAtIHJlc29sdXRpb24ueSAtIGZhZGVbMl0pO1xuICAgICAgICAgICAgdmVjMiBwb3MyID0gdmVjMih2VGV4dHVyZUNvb3JkLngsIHBvaW50LnkgLSByZXNvbHV0aW9uLnkpO1xuICAgICAgICAgICAgZCA9IHBvczEgLSBwb3MyO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MyLCBkKSAvIGRvdChkLCBkKTtcbiAgICAgICAgICAgIHQgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcChjLCAwLjAsIDEuMCkpO1xuICAgICAgICAgICAgY29sb3IgPSBtaXgodmVjNCgwLjApLCBjb2xvciwgdCk7XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGlmKGZhZGVbM10gPiAwLjApIHtcbiAgICAgICAgICAgIHBvczEgPSB2ZWMyKHBvaW50LngsIHBvaW50LnkpO1xuICAgICAgICAgICAgcG9zMiA9IHZlYzIocG9pbnQueCArIGZhZGVbM10sIHBvaW50LnkpO1xuICAgICAgICAgICAgZCA9IHBvczIgLSBwb3MxO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MxLCB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VudExpc3RlbmVyc1tuYW1lXSA9IFt0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdLCBsaXN0ZW5lcl07XG4gICAgICAgICAgICAgICAgdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXSA9IEV2ZW50RW1pdHRlci5jb21iaW5lcjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZXZlbnRMaXN0ZW5lcnNbbmFtZV0ucHVzaChsaXN0ZW5lcik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBvbmNlKG5hbWUsIGxpc3RlbmVyKSB7XG4gICAgICAgIGNvbnN0IHdyYXBwZXIgPSAoYXJnMSwgYXJnMiwgYXJnMykgPT4ge1xuICAgICAgICAgICAgbGlzdGVuZXIoYXJnMSwgYXJnMiwgYXJnMyk7XG4gICAgICAgICAgICB0aGlzLm9mZihuYW1lLCB3cmFwcGVyKTtcbiAgICAgICAgfVxuICAgICAgICB3cmFwcGVyLl9fb3JpZ2luYWxGdW5jID0gbGlzdGVuZXI7XG4gICAgICAgIHRoaXMub24obmFtZSwgd3JhcHBlcik7XG4gICAgfVxuXG4gICAgaGFzKG5hbWUsIGxpc3RlbmVyKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNFdmVudExpc3RlbmVycykge1xuICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV07XG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xuICAgICAgICAgICAgICAgIGlmIChjdXJyZW50ID09PSBFdmVudEVtaXR0ZXIuY29tYmluZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGlzdGVuZXJzID0gdGhpcy5fZXZlbnRMaXN0ZW5lcnNbbmFtZV07XG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbCBvZiBsaXN0ZW5lcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsID09PSBsaXN0ZW5lciB8fCBsLl9fb3JpZ2luYWxGdW5jID09IGxpc3RlbmVyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV0gPT09IGxpc3RlbmVyIHx8IHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV0uX19vcmlnaW5hbEZ1bmMgPT09IGxpc3RlbmVyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgb2ZmKG5hbWUsIGxpc3RlbmVyKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNFdmVudExpc3RlbmVycykge1xuICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV07XG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xuICAgICAgICAgICAgICAgIGlmIChjdXJyZW50ID09PSBFdmVudEVtaXR0ZXIuY29tYmluZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGlzdGVuZXJzID0gdGhpcy5fZXZlbnRMaXN0ZW5lcnNbbmFtZV07XG4gICAgICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGxpc3RlbmVycy5pbmRleE9mKGxpc3RlbmVyKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ID49IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVycy5zcGxpY2UoaW5kZXgsIDEpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGluZGV4ID0gbGlzdGVuZXJzLm1hcCgobCkgPT4gbC5fX29yaWdpbmFsRnVuYykuaW5kZXhPZihsaXN0ZW5lcik7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcnMuc3BsaWNlKGluZGV4LCAxKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAobGlzdGVuZXJzLmxlbmd0aCA9PT0gMSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXSA9IGxpc3RlbmVyc1swXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2V2ZW50TGlzdGVuZXJzW25hbWVdID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdID09PSBsaXN0ZW5lciB8fCB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdLl9fb3JpZ2luYWxGdW5jID09PSBsaXN0ZW5lcikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJlbW92ZUxpc3RlbmVyKG5hbWUsIGxpc3RlbmVyKSB7XG4gICAgICAgIHRoaXMub2ZmKG5hbWUsIGxpc3RlbmVyKTtcbiAgICB9XG5cbiAgICBlbWl0KG5hbWUsIGFyZzEsIGFyZzIsIGFyZzMpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hhc0V2ZW50TGlzdGVuZXJzKSB7XG4gICAgICAgICAgICBjb25zdCBmdW5jID0gdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXTtcbiAgICAgICAgICAgIGlmIChmdW5jKSB7XG4gICAgICAgICAgICAgICAgaWYgKGZ1bmMgPT09IEV2ZW50RW1pdHRlci5jb21iaW5lcikge1xuICAgICAgICAgICAgICAgICAgICBmdW5jKHRoaXMsIG5hbWUsIGFyZzEsIGFyZzIsIGFyZzMpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGZ1bmMoYXJnMSwgYXJnMiwgYXJnMyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgbGlzdGVuZXJDb3VudChuYW1lKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNFdmVudExpc3RlbmVycykge1xuICAgICAgICAgICAgY29uc3QgZnVuYyA9IHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV07XG4gICAgICAgICAgICBpZiAoZnVuYykge1xuICAgICAgICAgICAgICAgIGlmIChmdW5jID09PSBFdmVudEVtaXR0ZXIuY29tYmluZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2V2ZW50TGlzdGVuZXJzW25hbWVdLmxlbmd0aDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIDA7XG4gICAgfVxuXG4gICAgcmVtb3ZlQWxsTGlzdGVuZXJzKG5hbWUpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hhc0V2ZW50TGlzdGVuZXJzKSB7XG4gICAgICAgICAgICBkZWxldGUgdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXTtcbiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLl9ldmVudExpc3RlbmVyc1tuYW1lXTtcbiAgICAgICAgfVxuICAgIH1cblxufVxuXG5FdmVudEVtaXR0ZXIuY29tYmluZXIgPSBmdW5jdGlvbihvYmplY3QsIG5hbWU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gICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fcCA+PSAxKSB7XG4gICAgICAgICAgICAvLyBGaW5pc2hlZCE7XG4gICAgICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5yZXBlYXQgPT0gLTEgfHwgdGhpcy5fcmVwZWF0c0xlZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlcGVhdHNMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXBlYXRzTGVmdC0tO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gdGhpcy5zZXR0aW5ncy5yZXBlYXRPZmZzZXQ7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdwcm9ncmVzcycsIHRoaXMuX3ApO1xuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNldHRpbmdzLnJlcGVhdERlbGF5KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2RlbGF5TGVmdCA9IHRoaXMuc2V0dGluZ3MucmVwZWF0RGVsYXk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdyZXBlYXQnLCB0aGlzLl9yZXBlYXRzTGVmdCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgncHJvZ3Jlc3MnLCB0aGlzLl9wKTtcbiAgICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuRklOSVNIRUQ7XG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdmaW5pc2gnKTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5hdXRvc3RvcCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnN0b3AoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmVtaXQoJ3Byb2dyZXNzJywgdGhpcy5fcCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgXG4gICAgX3N0b3BQcm9ncmVzcyhkdCkge1xuICAgICAgICBsZXQgZHVyYXRpb24gPSB0aGlzLl9nZXRTdG9wRHVyYXRpb24oKTtcblxuICAgICAgICBpZiAodGhpcy5fc3RvcERlbGF5TGVmdCA+IDApIHtcbiAgICAgICAgICAgIHRoaXMuX3N0b3BEZWxheUxlZnQgLT0gZHQ7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9zdG9wRGVsYXlMZWZ0IDwgMCkge1xuICAgICAgICAgICAgICAgIGR0ID0gLXRoaXMuX3N0b3BEZWxheUxlZnQ7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RvcERlbGF5TGVmdCA9IDA7XG5cbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3N0b3BEZWxheUVuZCcpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuSU1NRURJQVRFKSB7XG4gICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgIHRoaXMuZW1pdCgnc3RvcEZpbmlzaCcpO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuUkVWRVJTRSkge1xuICAgICAgICAgICAgaWYgKGR1cmF0aW9uID09PSAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IDA7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGR1cmF0aW9uID4gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgLT0gZHQgLyBkdXJhdGlvbjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3AgPD0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnc3RvcEZpbmlzaCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuRkFERSkge1xuICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NTdG9wVHJhbnNpdGlvbihkdCk7XG4gICAgICAgICAgICBpZiAodGhpcy5fc3RvcFAgPj0gMSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnc3RvcEZpbmlzaCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuT05FVE9UV08pIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9wIDwgMikge1xuICAgICAgICAgICAgICAgIGlmIChkdXJhdGlvbiA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wID0gMjtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGR1cmF0aW9uID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcCA8IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgKz0gZHQgLyB0aGlzLnNldHRpbmdzLmR1cmF0aW9uO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCArPSBkdCAvIGR1cmF0aW9uO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wID49IDIpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCA9IDI7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3N0b3BGaW5pc2gnKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3Byb2dyZXNzJywgdGhpcy5fcCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuRk9SV0FSRCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3AgPCAxKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3MuZHVyYXRpb24gPT0gMCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gdGhpcy5zZXR0aW5ncy5kdXJhdGlvbjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3AgPj0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5GT1JXQVJEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdzdG9wRmluaXNoJyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcmVwZWF0c0xlZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVwZWF0c0xlZnQtLTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3JlcGVhdCcsIHRoaXMuX3JlcGVhdHNMZWZ0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdzdG9wRmluaXNoJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3Byb2dyZXNzJywgdGhpcy5fcCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIFxuICAgIH1cbiAgICBcbiAgICBfcHJvZ3Jlc3NTdG9wVHJhbnNpdGlvbihkdCkge1xuICAgICAgICBpZiAodGhpcy5fc3RvcFAgPCAxKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fc3RvcERlbGF5TGVmdCA+IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdG9wRGVsYXlMZWZ0IC09IGR0O1xuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3BEZWxheUxlZnQgPCAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGR0ID0gLXRoaXMuX3N0b3BEZWxheUxlZnQ7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0b3BEZWxheUxlZnQgPSAwO1xuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnZGVsYXlFbmQnKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgXG4gICAgICAgICAgICBjb25zdCBkdXJhdGlvbiA9IHRoaXMuX2dldFN0b3BEdXJhdGlvbigpO1xuXG4gICAgICAgICAgICBpZiAoZHVyYXRpb24gPT0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0b3BQID0gMTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RvcFAgKz0gZHQgLyBkdXJhdGlvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLl9zdG9wUCA+PSAxKSB7XG4gICAgICAgICAgICAgICAgLy8gRmluaXNoZWQhO1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0b3BQID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRTdG9wRHVyYXRpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnNldHRpbmdzLnN0b3BEdXJhdGlvbiB8fCB0aGlzLnN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YgPSBTdGFnZVV0aWxzLm1lcmdlQ29sb3JzKHYsIHN2LCBmYWN0b3IpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHYgPSBTdGFnZVV0aWxzLm1lcmdlTnVtYmVycyh2LCBzdiwgZmFjdG9yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvLyBBcHBseSB0cmFuc2Zvcm1hdGlvbiB0byBhbGwgY29tcG9uZW50cy47XG4gICAgICAgIGNvbnN0IG4gPSB0aGlzLl9wcm9wU2V0dGVycy5sZW5ndGg7XG5cbiAgICAgICAgY29uc3QgbSA9IGVsZW1lbnRzLmxlbmd0aDtcbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBtOyBqKyspIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcHJvcFNldHRlcnNbaV0oZWxlbWVudHNbal0sIHYpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIFxuICAgIGdldEFuaW1hdGVkRWxlbWVudHMoZWxlbWVudCkge1xuICAgICAgICByZXR1cm4gZWxlbWVudC5zZWxlY3QodGhpcy5fc2VsZWN0b3IpO1xuICAgIH1cblxuICAgIHJlc2V0KGVsZW1lbnQpIHtcbiAgICAgICAgY29uc3QgZWxlbWVudHMgPSB0aGlzLmdldEFuaW1hdGVkRWxlbWVudHMoZWxlbWVudCk7XG5cbiAgICAgICAgbGV0IHYgPSB0aGlzLmdldFJlc2V0VmFsdWUoKTtcblxuICAgICAgICBpZiAodiA9PT0gdW5kZWZpbmVkIHx8ICFlbGVtZW50cy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEFwcGx5IHRyYW5zZm9ybWF0aW9uIHRvIGFsbCBjb21wb25lbnR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k7XG4gICAgfVxuXG4gICAgaXNBdHRhY2hlZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2VsZW1lbnQuYXR0YWNoZWQ7XG4gICAgfVxuXG4gICAgaXNSdW5uaW5nKCkge1xuICAgICAgICByZXR1cm4gKHRoaXMuX3AgPCAxLjApO1xuICAgIH1cblxuICAgIHByb2dyZXNzKGR0KSB7XG4gICAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkKCkpIHtcbiAgICAgICAgICAgIC8vIFNraXAgdG8gZW5kIG9mIHRyYW5zaXRpb24gc28gdGhhdCBpdCBpcyByZW1vdmVkLlxuICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5wIDwgMSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuZGVsYXlMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2RlbGF5TGVmdCAtPSBkdDtcblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlbGF5TGVmdCA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgZHQgPSAtdGhpcy5kZWxheUxlZnQ7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2RlbGF5TGVmdCA9IDA7XG5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdkZWxheUVuZCcpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy5kdXJhdGlvbiA9PSAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgKz0gZHQgLyB0aGlzLl9zZXR0aW5ncy5kdXJhdGlvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgIC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AgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBVbmZvY3VzIGV2ZW50cy5cbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5fZm9jdXNQYXRoLmxlbmd0aCAtIDE7IGkgPj0gaW5kZXg7IGktLSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmZvY3VzZWRFbGVtZW50ID0gdGhpcy5fZm9jdXNQYXRoLnBvcCgpO1xuICAgICAgICAgICAgICAgICAgICB1bmZvY3VzZWRFbGVtZW50Ll91bmZvY3VzKG5ld0ZvY3VzZWRDb21wb25lbnQsIHByZXZGb2N1c2VkQ29tcG9uZW50KTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9jdXNPdmVycmlkZGVuID0gKHRoaXMuX191cGRhdGVGb2N1c0lkICE9PSB1cGRhdGVGb2N1c0lkKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZvY3VzT3ZlcnJpZGRlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gRm9jdXMgZXZlbnRzLlxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSBpbmRleCwgbiA9IG5ld0ZvY3VzUGF0aC5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZm9jdXNQYXRoLnB1c2gobmV3Rm9jdXNQYXRoW2ldKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZm9jdXNQYXRoW2ldLl9mb2N1cyhuZXdGb2N1c2VkQ29tcG9uZW50LCBwcmV2Rm9jdXNlZENvbXBvbmVudCk7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvY3VzT3ZlcnJpZGRlbiA9ICh0aGlzLl9fdXBkYXRlRm9jdXNJZCAhPT0gdXBkYXRlRm9jdXNJZCk7XG4gICAgIC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dCBwYXRoID0gW3RoaXNdO1xuICAgICAgICBsZXQgY3VycmVudCA9IHRoaXM7XG4gICAgICAgIGRvIHtcbiAgICAgICAgICAgIGNvbnN0IG5leHRGb2N1cyA9IGN1cnJlbnQuX2dldEZvY3VzZWQoKTtcbiAgICAgICAgICAgIGlmICghbmV4dEZvY3VzIHx8IChuZXh0Rm9jdXMgPT09IGN1cnJlbnQpKSB7XG4gICAgICAgICAgICAgICAgLy8gRm91bmQhO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIGxldCBwdHIgPSBuZXh0Rm9jdXMuY3BhcmVudDtcbiAgICAgICAgICAgIGlmIChwdHIgPT09IGN1cnJlbnQpIHtcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2gobmV4dEZvY3VzKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gTm90IGFuIGltbWVkaWF0ZSBjaGlsZDogaW5jbHVkZSBmdWxsIHBhdGggdG8gZGVzY2VuZGFudC5cbiAgICAgICAgICAgICAgICBjb25zdCBuZXdQYXJ0cyA9IFtuZXh0Rm9jdXNdO1xuICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwdHIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuX3Rocm93RXJyb3IoXCJSZXR1cm4gdmFsdWUgZm9yIF9nZXRGb2N1c2VkIG11c3QgYmUgYW4gYXR0YWNoZWQgZGVzY2VuZGFudCBjb21wb25lbnQgYnV0IGl0cyAnXCIgKyBuZXh0Rm9jdXMuZ2V0TG9jYXRpb25TdHJpbmcoKSArIFwiJ1wiKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBuZXdQYXJ0cy5wdXNoKHB0cik7XG4gICAgICAgICAgICAgICAgICAgIHB0ciA9IHB0ci5jcGFyZW50O1xuICAgICAgICAgICAgICAgIH0gd2hpbGUgKHB0ciAhPT0gY3VycmVudCk7XG5cbiAgICAgICAgICAgICAgICAvLyBBZGQgdGhlbSByZXZlcnNlZC5cbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IG5ld1BhcnRzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2gobmV3UGFydHNbbiAtIGkgLSAxXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjdXJyZW50ID0gbmV4dEZvY3VzO1xuICAgICAgICB9IHdoaWxlICh0cnVlKTtcblxuICAgICAgICByZXR1cm4gcGF0aDtcbiAgICB9XG5cbiAgICBnZXQgZm9jdXNQYXRoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZm9jdXNQYXRoO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEluamVjdHMgYW4gZXZlbnQgaW4gdGhlIHN0YXRlIG1hY2hpbmVzLCB0b3AtZG93biBmcm9tIGFwcGxpY2F0aW9uIHRvIGZvY3VzZWQgY29tcG9uZW50LlxuICAgICAqL1xuICAgIGZvY3VzVG9wRG93bkV2ZW50KGV2ZW50cywgLi4uYXJncykge1xuICAgICAgICBjb25zdCBwYXRoID0gdGhpcy5mb2N1c1BhdGg7XG4gICAgICAgIGNvbnN0IG4gPSBwYXRoLmxlbmd0aDtcblxuICAgICAgICAvLyBNdWx0aXBsZSBldmVudHMuXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBldmVudCA9IHBhdGhbaV0uX2dldE1vc3RTcGVjaWZpY0hhbmRsZWRNZW1iZXIoZXZlbnRzKTtcbiAgICAgICAgICAgIGlmIChldmVudCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmV0dXJuVmFsdWUgPSBwYXRoW2ldW2V2ZW50XSguLi5hcmdzKTtcbiAgICAgICAgICAgICAgICBpZiAocmV0dXJuVmFsdWUgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBJbmplY3RzIGFuIGV2ZW50IGluIHRoZSBzdGF0ZSBtYWNoaW5lcywgYm90dG9tLXVwIGZyb20gZm9jdXNlZCBjb21wb25lbnQgdG8gYXBwbGljYXRpb24uXG4gICAgICovXG4gICAgZm9jdXNCb3R0b21VcEV2ZW50KGV2ZW50cywgLi4uYXJncykge1xuICAgICAgICBjb25zdCBwYXRoID0gdGhpcy5mb2N1c1BhdGg7XG4gICAgICAgIGNvbnN0IG4gPSBwYXRoLmxlbmd0aDtcblxuICAgICAgICAvLyBNdWx0aXBsZSBldmVudHMuXG4gICAgICAgIGZvciAobGV0IGkgPSBuIC0gMTsgaSA+PSAwOyBpLS0pIHtcbiAgICAgICAgICAgIGNvbnN0IGV2ZW50ID0gcGF0aFtpXS5fZ2V0TW9zdFNwZWNpZmljSGFuZGxlZE1lbWJlcihldmVudHMpO1xuICAgICAgICAgICAgaWYgKGV2ZW50ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBjb25zdCByZXR1cm5WYWx1ZSA9IHBhdGhbaV1bZXZlbnRdKC4uLmFyZ3MpO1xuICAgICAgICAgICAgICAgIGlmIChyZXR1cm5WYWx1ZSAhPT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIF9yZWNlaXZlS2V5ZG93bihlKSB7XG4gICAgICAgIGNvbnN0IG9iaiA9IGU7XG4gICAgICAgIGNvbnN0IGtleSA9IHRoaXMuX19rZXltYXBbZS5rZXlDb2RlXTtcbiAgICAgICAgY29uc3QgcGF0aCA9IHRoaXMuZm9jdXNQYXRoO1xuXG4gICAgICAgIGxldCBrZXlzO1xuICAgICAgICBpZiAoa2V5KSB7XG4gICAgICAgICAgICBrZXlzID0gQXJyYXkuaXNBcnJheShrZXkpID8ga2V5IDogW2tleV07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoa2V5cykge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBrZXlzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGNvbnN0IGhhc1RpbWVyID0gdGhpcy5fX2tleXByZXNzVGltZXJzLmhhcyhrZXlzW2ldKTtcbiAgICAgICAgICAgICAgICAvLyBwcmV2ZW50IGV2ZW50IGZyb20gZ2V0dGluZyBmaXJlZCB3aGVuIHRoZSB0aW1lb3V0IGlzIHN0aWxsIGFjdGl2ZVxuICAgICAgICAgICAgICAgIGlmIChwYXRoW3BhdGgubGVuZ3RoIC0gMV0ubG9uZ3ByZXNzICYmIGhhc1RpbWVyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuc3RhZ2UuYXBwbGljYXRpb24uZm9jdXNUb3BEb3duRXZlbnQoW2BfY2FwdHVyZSR7a2V5c1tpXX1gLCBcIl9jYXB0dXJlS2V5XCJdLCBvYmopKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuYXBwbGljYXRpb24uZm9jdXNCb3R0b21VcEV2ZW50KFtgX2hhbmRsZSR7a2V5c1tpXX1gLCBcIl9oYW5kbGVLZXlcIl0sIG9iaik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKCF0aGlzLnN0YWdlLmFwcGxp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2V5KSB7XG4gICAgICAgICAgICBrZXlzID0gQXJyYXkuaXNBcnJheShrZXkpID8ga2V5IDogW2tleV07XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoa2V5cykge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBrZXlzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5mb2N1c1RvcERvd25FdmVudChbYF9jYXB0dXJlJHtrZXlzW2ldfVJlbGVhc2VgLCBcIl9jYXB0dXJlS2V5UmVsZWFzZVwiXSwgb2JqKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLmZvY3VzQm90dG9tVXBFdmVudChbYF9oYW5kbGUke2tleXNbaV19UmVsZWFzZWAsIFwiX2hhbmRsZUtleVJlbGVhc2VcIl0sIG9iaik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKCF0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLmZvY3VzVG9wRG93bkV2ZW50KFtcIl9jYXB0dXJlS2V5UmVsZWFzZVwiXSwgb2JqKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuYXBwbGljYXRpb24uZm9jdXNCb3R0b21VcEV2ZW50KFtcIl9oYW5kbGVLZXlSZWxlYXNlXCJdLCBvYmopO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy51cGRhdGVGb2N1c1BhdGgoKTtcblxuICAgICAgICBpZiAoa2V5cykge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBrZXlzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9fa2V5cHJlc3NUaW1lcnMuaGFzKGtleXNbaV0pKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGtleXVwIGhhcyBmaXJlZCBiZWZvcmUgZW5kIG9mIHRpbWVvdXQgc28gd2UgY2xlYXIgaXRcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRoaXMuX19rZXlwcmVzc1RpbWVycy5nZXQoa2V5c1tpXSkpO1xuICAgICAgICAgICAgICAgICAgICAvLyBkZWxldGUgc28gd2UgY2FuIHJlZ2lzdGVyIGl0IGFnYWluXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19rZXlwcmVzc1RpbWVycy5kZWxldGUoa2V5c1tpXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmVnaXN0ZXJzIGFuZCBzdGFydHMgYSB0aW1lciBmb3IgdGhlIHByZXNzZWQga2V5LiBUaW1lciB3aWxsIGJlIGNsZWFyZWQgd2hlbiB0aGUga2V5IGlzIHJlbGVhc2VkXG4gICAgICogYmVmb3JlIHRoZSB0aW1lciBnb2VzIG9mZi5cbiAgICAgKlxuICAgICAqIElmIGtleSBpcyBub3QgcmVsZWFzZSAoa2V5dXApIHRoZSBsb25ncHJlc3MgaGFuZGxlciB3aWxsIGJlIGZpcmVkLlxuICAgICAqIENvbmZpZ3VyYXRpb24gY2FuIGJlIHZpYSB0aGUgQ29tcG9uZW50cyB0ZW1wbGF0ZTpcbiAgICAgKlxuICAgICAqIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICogICAgIHJldHVybiB7XG4gICAgICogICAgICAgICB3OjEwMCwgaDoxMDAsXG4gICAgICogICAgICAgICBsb25ncHJlc3M6e3VwOjcwMCwgZG93bjo1MDB9XG4gICAgICogICAgIH1cbiAgICAgKiB9ICAgICAqXG4gICAgICogLy8gdGhpcyB3aWxsIGdldCBjYWxsZWQgd2hlbiB1cCBoYXMgYmVlbiBwcmVzc2VkIGZvciA3MDBtc1xuICAgICAqIF9oYW5kbGVVcExvbmcoKSB7XG4gICAgICpcbiAgICAgKiB9XG4gICAgICpcbiAgICAgKiBAcGFyYW0ga2V5XG4gICAgICogQHBhcmFtIGVsZW1lbnRcbiAgICAgKiBAcHJpdmF0ZVxuICAgICAqL1xuICAgIF9zdGFydExvbmdwcmVzc1RpbWVyKGtleSwgZWxlbWVudCkge1xuICAgICAgICBjb25zdCBjb25maWcgPSBlbGVtZW50LmxvbmdwcmVzcztcbiAgICAgICAgY29uc3QgbG9va3VwID0ga2V5LnRvTG93ZXJDYXNlKCk7XG5cbiAgICAgICAgaWYgKGNvbmZpZ1tsb29rdXBdKSB7XG4gICAgICAgICAgICBjb25zdCB0aW1lb3V0ID0gY29uZmlnW2xvb2t1cF07XG4gICAgICAgICAgICBpZiAoIVV0aWxzLmlzTnVtYmVyKHRpbWVvdXQpKSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5fdGhyb3dFcnJvcihcImNvbmZpZyB2YWx1ZSBmb3IgbG9uZ3ByZXNzIG11c3QgYmUgYSBudW1iZXJcIik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX19rZXlwcmVzc1RpbWVycy5zZXQoa2V5LCBzZXRUaW1lb3V0KCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLmZvY3VzVG9wRG93bkV2ZW50KFtgX2NhcHR1cmUke2tleX1Mb25nYCwgXCJfY2FwdHVyZUtleVwiXSwge30pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLmZvY3VzQm90dG9tVXBFdmVudChbYF9oYW5kbGUke2tleX1Mb25nYCwgXCJfaGFuZGxlS2V5XCJdLCB7fSk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fa2V5cHJlc3NUaW1lcnMuZGVsZXRlKGtleSk7XG4gICAgICAgICAgICAg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vbnN0IHsgY2xpZW50WCwgY2xpZW50WSB9ID0gb2JqO1xuICAgICAgICBjb25zdCB0YXJnZXQgPSB0aGlzLl9nZXRUYXJnZXRDaGlsZChjbGllbnRYLCBjbGllbnRZKTtcbiAgICAgICAgY29uc3QgcHJlY2lzaW9uID0gdGhpcy5zdGFnZS5nZXRSZW5kZXJQcmVjaXNpb24oKSAvIHRoaXMuc3RhZ2UuZ2V0T3B0aW9uKCdkZXZpY2VQaXhlbFJhdGlvJyk7XG4gICAgICAgIGxldCBjaGlsZCA9IHRhcmdldDtcblxuICAgICAgICAvLyBTZWFyY2ggdHJlZSBib3R0b20gdXAgZm9yIGEgaGFuZGxlclxuICAgICAgICB3aGlsZSAoY2hpbGQgIT09IG51bGwpIHtcbiAgICAgICAgICAgIGlmIChjaGlsZCAmJiBjaGlsZFtcIl9oYW5kbGVDbGlja1wiXSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHsgcHgsIHB5IH0gPSBjaGlsZC5jb3JlLl93b3JsZENvbnRleHQ7XG4gICAgICAgICAgICAgICAgY29uc3QgY3ggPSBweCAqIHByZWNpc2lvbjtcbiAgICAgICAgICAgICAgICBjb25zdCBjeSA9IHB5ICogcHJlY2lzaW9uO1xuXG4gICAgICAgICAgICAgICAgY29uc3QgbG9jYWxDb29yZHMgPSB7XG4gICAgICAgICAgICAgICAgICAgIHg6IGNsaWVudFggLSBjeCxcbiAgICAgICAgICAgICAgICAgICAgeTogY2xpZW50WSAtIGN5XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgY29uc3QgcmV0dXJuVmFsdWUgPSBjaGlsZC5faGFuZGxlQ2xpY2sodGFyZ2V0LCBsb2NhbENvb3Jkcyk7XG4gICAgICAgICAgICAgICAgaWYgKHJldHVyblZhbHVlICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjaGlsZCA9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lsZC5nZXRBbmNlc3RvcnMoKSk7XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtIG9mIFsuLi5ob3ZlcmVkQnJhbmNoXS5maWx0ZXIoKGUpID0+ICFuZXdIb3ZlcmVkQnJhbmNoLmhhcyhlKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYyA9IENvbXBvbmVudC5nZXRDb21wb25lbnQoZWxlbSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjW1wiX2hhbmRsZVVuaG92ZXJcIl0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGMuX2hhbmRsZVVuaG92ZXIoZWxlbSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW0ucGFyZW50ICYmIGVsZW0ucGFyZW50LmN1cnNvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGFnZS5nZXRDYW52YXMoKS5zdHlsZS5jdXJzb3IgPSBlbGVtLnBhcmVudC5jdXJzb3I7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX19ob3ZlcmVkQ2hpbGQgPSB0YXJnZXQ7XG5cbiAgICAgICAgICAgIGNvbnN0IGRpZmZCcmFuY2ggPSBbLi4ubmV3SG92ZXJlZEJyYW5jaF0uZmlsdGVyKChlKSA9PiAhaG92ZXJlZEJyYW5jaC5oYXMoZSkpXG4gICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW0gb2YgZGlmZkJyYW5jaCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGMgPSBDb21wb25lbnQuZ2V0Q29tcG9uZW50KGVsZW0pO1xuICAgICAgICAgICAgICAgIGlmIChjW1wiX2hhbmRsZUhvdmVyXCJdKSB7XG4gICAgICAgICAgICAgICAgICAgIGMuX2hhbmRsZUhvdmVyKGVsZW0pO1xuICAgICAgICAgICAgICAg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xlUmFuZ2UoYWZmZWN0ZWQsIGNsaWVudFgsIGNsaWVudFkpO1xuXG4gICAgICAgIGhvdmVyYWJsZUNoaWxkcmVuLnNvcnQoKGEsIGIpID0+IHtcbiAgICAgICAgICAgIC8vIFNvcnQgYnkgekluZGV4IGFuZCB0aGVuIGlkXG4gICAgICAgICAgICBpZiAoYS56SW5kZXggPiBiLnpJbmRleCkge1xuICAgICAgICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChhLnpJbmRleCA8IGIuekluZGV4KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIC0xO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYS5pZCA+IGIuaWQgPyAxIDogLTE7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGlmIChob3ZlcmFibGVDaGlsZHJlbi5sZW5ndGgpIHtcbiAgICAgICAgICAgIC8vIEFzc3VtZSB0YXJnZXQgaGFzIGhpZ2hlc3QgekluZGV4IChpZCB3aGVuIHpJbmRleCBlcXVhbClcbiAgICAgICAgICAgIHJldHVybiBob3ZlcmFibGVDaGlsZHJlbi5zbGljZSgtMSlbMF07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9maW5kQ2hpbGRyZW4oYnVja2V0LCBjaGlsZHJlbikge1xuICAgICAgICBsZXQgbiA9IGNoaWxkcmVuLmxlbmd0aDtcbiAgICAgICAgd2hpbGUgKG4tLSkge1xuICAgICAgICAgICAgY29uc3QgY2hpbGQgPSBjaGlsZHJlbltuXTtcbiAgICAgICAgICAgIC8vIG9ubHkgYWRkIGFjdGl2ZSBjaGlsZHJlblxuICAgICAgICAgICAgaWYgKGNoaWxkLl9fYWN0aXZlICYmIGNoaWxkLmNvbGxpc2lvbikge1xuICAgICAgICAgICAgICAgIGlmIChjaGlsZC5jb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lsZC5maW5hbFcgKiBjdHgudGEgKiBwcmVjaXNpb247XG4gICAgICAgICAgICBjb25zdCBjaCA9IGNoaWxkLmZpbmFsSCAqIGN0eC50ZCAqIHByZWNpc2lvbjtcblxuICAgICAgICAgICAgaWYgKGN4ID4gdGhpcy5zdGFnZS53IHx8IGN5ID4gdGhpcy5zdGFnZS5oKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChjaGlsZC5wYXJlbnQuY29yZS5fc2Npc3Nvcikge1xuICAgICAgICAgICAgICAgIGNvbnN0IHNjaXNzb3IgPSBjaGlsZC5wYXJlbnQuY29yZS5fc2Npc3Nvci5tYXAoKHYpID0+IHYgKiBwcmVjaXNpb24pO1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fdGVzdENvbGxpc2lvbihjdXJzb3JYLCBjdXJzb3JZLCAuLi5zY2lzc29yKSlcbiAgICAgICAgICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3Rlc3RDb2xsaXNpb24oY3Vyc29yWCwgY3Vyc29yWSwgY3gsIGN5LCBjdywgY2gpKSB7XG4gICAgICAgICAgICAgICAgY2FuZGlkYXRlcy5wdXNoKGNoaWxkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gY2FuZGlkYXRlcztcbiAgICB9XG5cbiAgICBfdGVzdENvbGxpc2lvbihweCwgcHksIGN4LCBjeSwgY3csIGNoKSB7XG4gICAgICAgIGlmIChweCA+PSBjeCAmJlxuICAgICAgICAgICAgcHggPD0gY3ggKyBjdyAmJlxuICAgICAgICAgICAgcHkgPj0gY3kgJiZcbiAgICAgICAgICAgIHB5IDw9IGN5ICsgY2gpIHtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG5cbiAgICBkZX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9IHRhcmdldFByb3A7XG4gICAgICAgIGNvbnN0IHByb3BEZXBlbmRlbmNpZXMgPSBBcnJheS5pc0FycmF5KHByb3BPYmouX19uYW1lKSA/IHByb3BPYmouX19uYW1lIDogW3Byb3BPYmouX19uYW1lXTtcblxuICAgICAgICAvLyAyLiBjcmVhdGUgc2V0dGVycyBmb3IgZXZlcnkgZ2l2ZW4gZGVwZW5kZW5jeVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHByb3BEZXBlbmRlbmNpZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IHByb3BOYW1lID0gcHJvcERlcGVuZGVuY2llc1tpXTtcbiAgICAgICAgICAgIGNvbnN0IGZ1bmMgPSBwcm9wT2JqLl9fZnVuYyA/IHByb3BPYmouX19mdW5jIDogKGNvbnRleHQpID0+IGNvbnRleHRbcHJvcE5hbWVdO1xuXG4gICAgICAgICAgICBpZiAoIXRoaXMuaGFzT3duUHJvcGVydHkocHJvcE5hbWUpKSB7XG4gICAgICAgICAgICAgICAgdGhpc1tgX19wcm9wX2JpbmRpbmdzXyR7cHJvcE5hbWV9YF0gPSBbe19fb2JqOiBvYmosIF9fcHJvcDogcHJvcCwgX19mdW5jOiBmdW5jfV07XG4gICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsIHByb3BOYW1lLCB7XG4gICAgICAgICAgICAgICAgICAgIHNldDogKHZhbHVlKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2BfX3Byb3BfJHtwcm9wTmFtZX1gXSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB7X19vYmosIF9fcHJvcCwgX19mdW5jfSBvZiB0aGlzW2BfX3Byb3BfYmluZGluZ3NfJHtwcm9wTmFtZX1gXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fb2JqW19fcHJvcF0gPSBfX2Z1bmModGhpcyk7XG4gIC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nRleHQgPSB7XG4gICAgICAgICAgICBsb2M6IFtdLFxuICAgICAgICAgICAgc3RvcmU6IFtdLFxuICAgICAgICAgICAgcmlkOiAwXG4gICAgICAgIH07XG5cbiAgICAgICAgdGhpcy5wYXJzZVRlbXBsYXRlUmVjKG9iaiwgY29udGV4dCwgXCJlbGVtZW50XCIpO1xuXG4gICAgICAgIGNvbnN0IGNvZGUgPSBjb250ZXh0LmxvYy5qb2luKFwiO1xcblwiKTtcbiAgICAgICAgY29uc3QgZiA9IG5ldyBGdW5jdGlvbihcImVsZW1lbnRcIiwgXCJzdG9yZVwiLCBjb2RlKTtcbiAgICAgICAgcmV0dXJuIHtmOiBmLCBhOiBjb250ZXh0LnN0b3JlfTtcbiAgICB9XG5cbiAgICBzdGF0aWMgcGFyc2VUZW1wbGF0ZVJlYyhvYmosIGNvbnRleHQsIGN1cnNvcikge1xuICAgICAgICBjb25zdCBzdG9yZSA9IGNvbnRleHQuc3RvcmU7XG4gICAgICAgIGNvbnN0IGxvYyA9IGNvbnRleHQubG9jO1xuICAgICAgICBjb25zdCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAga2V5cy5mb3JFYWNoKGtleSA9PiB7XG4gICAgICAgICAgICBsZXQgdmFsdWUgPSBvYmpba2V5XTtcbiAgICAgICAgICAgIGlmIChVdGlscy5pc1VjQ2hhcihrZXkuY2hhckNvZGVBdCgwKSkpIHtcbiAgICAgICAgICAgICAgICAvLyBWYWx1ZSBtdXN0IGJlIGV4cGFuZGVkIGFzIHdlbGwuXG4gICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gUmVmLlxuICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZEN1cnNvciA9IGByJHtrZXkucmVwbGFjZSgvW15hLXowLTldL2dpLCBcIlwiKSArIGNvbnRleHQucmlkfWA7XG4gICAgICAgICAgICAgICAgICAgIGxldCB0eXBlID0gdmFsdWUudHlwZSA/IHZhbHVlLnR5cGUgOiBFbGVtZW50O1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZSA9PT0gRWxlbWVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYHZhciAke2NoaWxkQ3Vyc29yfSA9IGVsZW1lbnQuc3RhZ2UuY3JlYXRlRWxlbWVudCgpYCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHR5cGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYHZhciAke2NoaWxkQ3Vyc29yfSA9IG5ldyBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSgke2N1cnNvcn0uc3RhZ2UpYCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y2hpbGRDdXJzb3J9LnJlZiA9IFwiJHtrZXl9XCJgKTtcbiAgICAgICAgICAgICAgICAgICAgY29udGV4dC5yaWQrKztcblxuICAgICAgICAgICAgICAgICAgICAvLyBFbnRlciBzdWIuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMucGFyc2VUZW1wbGF0ZVJlYyh2YWx1ZSwgY29udGV4dCwgY2hpbGRDdXJzb3IpO1xuXG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn0uY2hpbGRMaXN0LmFkZCgke2NoaWxkQ3Vyc29yfSlgKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0KHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBEeW5hbWljIGFzc2lnbm1lbnQuXG4gICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9LmNoaWxkTGlzdC5hZGQoc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0pYCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAoa2V5ID09PSBcInRleHRcIikge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9wS2V5ID0gY3Vyc29yICsgXCJfX3RleHRcIjtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYHZhciAke3Byb3BLZXl9ID0gJHtjdXJzb3J9LmVuYWJsZVRleHRUZXh0dXJlKClgKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLl9fcHJvcGVydHlCaW5kaW5nID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBBbGxvdyBiaW5kaW5nIGVudGlyZSBvYmplY3RzIHRvIHRleHQgcHJvcGVydHlcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYGVsZW1lbnQuX19iaW5kUHJvcGVydHkoc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0sICR7Y3Vyc29yfSwgXCIke2tleX1cIilgKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyc2VUZW1wbGF0ZVByb3BSZWModmFsdWUsIGNvbnRleHQsIHByb3BLZXkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChrZXkgPT09IFwic2hhZGVyXCIgJiYgVXRpbHMuaXNPYmplY3RMaXRlcmFsKHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBzaGFkZXJDdXJzb3IgPSBgJHtjdXJzb3J9W1wic2hhZGVyXCJdYFxuICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9IHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dYCk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucGFyc2VQcm9wZXJ0eUJpbmRpbmdzKHZhbHVlLCBjb250ZXh0LCBzaGFkZXJDdXJzb3IpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoa2V5ID09PSBcInRleHR1cmVcIiAmJiBVdGlscy5pc09iamVjdExpdGVyYWwodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb3BLZXkgPSBjdXJzb3IgKyBcIl9fdGV4dHVyZVwiO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCB0eXBlID0gdmFsdWUudHlwZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godHlwZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgdmFyICR7cHJvcEtleX0gPSBuZXcgc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0oJHtjdXJzb3J9LnN0YWdlKWApO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJzZVRlbXBsYXRlUHJvcFJlYyh2YWx1ZSwgY29udGV4dCwgcHJvcEtleSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHtwcm9wS2V5fWApO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7cHJvcEtleX0gPSAke2N1cnNvcn0udGV4dHVyZWApO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJzZVRlbXBsYXRlUHJvcFJlYyh2YWx1ZSwgY29udGV4dCwgcHJvcEtleSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2YWx1ZSkgJiYgdmFsdWUuX19wcm9wZXJ0eUJpbmRpbmcgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGBlbGVtZW50Ll9fYmluZFByb3BlcnR5KHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dLCAke2N1cnNvcn0sIFwiJHtrZXl9XCIpYCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gUHJvcGVydHk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc051bWJlcih2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSAke3ZhbHVlfWApO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzQm9vbGVhbih2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSAke3ZhbHVlID8gXCJ0cnVlXCIgOiBcImZhbHNlXCJ9YCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3QodmFsdWUpIHx8IEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBEeW5hbWljIGFzc2lnbm1lbnQuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBCZWNhdXNlIGxpdGVyYWwgb2JqZWN0cyBtYXkgY29udGFpbiBkeW5hbWljcywgd2Ugc3RvcmUgdGhlIGZ1bGwgb2JqZWN0LlxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV1gKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFN0cmluZyBldGMuXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHtKU09OLnN0cmluZ2lmeSh2YWx1ZSl9YCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHN0YXRpYyBwYXJzZVRlbXBsYXRlUHJvcFJlYyhvYmosIGNvbnRleHQsIGN1cnNvcikge1xuICAgICAgICBjb25zdCBzdG9yZSA9IGNvbnRleHQuc3RvcmU7XG4gICAgICAgIGNvbnN0IGxvYyA9IGNvbnRleHQubG9jO1xuICAgICAgICBjb25zdCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAga2V5cy5mb3JFYWNoKGtleSA9PiB7XG4gICAgICAgICAgICBpZiAoa2V5ICE9PSBcInR5cGVcIikge1xuICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gb2JqW2tleV07XG4gICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzTnVtYmVyKHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHt2YWx1ZX1gKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzQm9vbGVhbih2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9ICR7dmFsdWUgPyBcInRydWVcIiA6IFwiZmFsc2VcIn1gKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0KHZhbHVlKSAmJiB2YWx1ZS5fX3Byb3BlcnR5QmluZGluZyA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYGVsZW1lbnQuX19iaW5kUHJvcGVydHkoc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0sICR7Y3Vyc29yfSwgXCIke2tleX1cIilgKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0KHZhbHVlKSB8fCBBcnJheS5pc0FycmF5KHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBEeW5hbWljIGFzc2lnbm1lbnQuXG4gICAgICAgICAgICAgICAgICAgIC8vIEJlY2F1c2UgbGl0ZXJhbCBvYmplY3RzIG1heSBjb250YWluIGR5bmFtaWNzLCB3ZSBzdG9yZSB0aGUgZnVsbCBvYmplY3QuXG4gICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV1gKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBTdHJpbmcgZXRjLlxuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHtKU09OLnN0cmluZ2lmeSh2YWx1ZSl9YCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBzdGF0aWMgcGFyc2VQcm9wZXJ0eUJpbmRpbmdzKG9iaiwgY29udGV4dCwgY3Vyc29yKSB7XG4gICAgICAgIGNvbnN0IHN0b3JlID0gY29udGV4dC5zdG9yZTtcbiAgICAgICAgY29uc3QgbG9jID0gY29udGV4dC5sb2M7XG4gICAgICAgIGNvbnN0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICBrZXlzLmZvckVhY2goa2V5ID0+IHtcbiAgICAgICAgICAgIGlmIChrZXkgIT09IFwidHlwZVwiKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBvYmpba2V5XTtcbiAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHZhbHVlKSAmJiB2YWx1ZS5fX3Byb3BlcnR5QmluZGluZyA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYGVsZW1lbnQuX19iaW5kUHJvcGVydHkoc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0sICR7Y3Vyc29yfSwgXCIke2tleX1cIilgKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIF9vblNldHVwKCkge1xuICAgICAgICBpZiAoIXRoaXMuX19pbml0aWFsaXplZCkge1xuICAgICAgICAgICAgdGhpcy5fc2V0dXAoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9zZXR1cCgpIHtcbiAgICB9XG5cbiAgICBfb25BdHRhY2goKSB7XG4gICAgICAgIGlmICghdGhpcy5fX2luaXRpYWxpemVkKSB7XG4gICAgICAgICAgICB0aGlzLl9faW5pdCgpO1xuICAgICAgICAgICAgdGhpcy5fX2luaXRpYWxpemVkID0gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuX2F0dGFjaCgpO1xuICAgIH1cblxuICAgIF9hdHRhY2goKSB7XG4gICAgfVxuXG4gICAgX29uRGV0YWNoKCkge1xuICAgICAgIC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lnbmFsLXRvLWZpcmUgbWFwcGluZ3NcIik7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fX3NpZ25hbHMgPSB2O1xuICAgIH1cblxuICAgIHNldCBhbHRlclNpZ25hbHModikge1xuICAgICAgICBpZiAoIVV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlNpZ25hbHM6IHNwZWNpZnkgYW4gb2JqZWN0IHdpdGggc2lnbmFsLXRvLWZpcmUgbWFwcGluZ3NcIik7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLl9fc2lnbmFscykge1xuICAgICAgICAgICAgdGhpcy5fX3NpZ25hbHMgPSB7fTtcbiAgICAgICAgfVxuICAgICAgICBmb3IgKGxldCBrZXkgaW4gdikge1xuICAgICAgICAgICAgY29uc3QgZCA9IHZba2V5XTtcbiAgICAgICAgICAgIGlmIChkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5fX3NpZ25hbHNba2V5XTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX3NpZ25hbHNba2V5XSA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgcGFzc1NpZ25hbHMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fcGFzc1NpZ25hbHMgfHwge307XG4gICAgfVxuXG4gICAgc2V0IHBhc3NTaWduYWxzKHYpIHtcbiAgICAgICAgdGhpcy5fX3Bhc3NTaWduYWxzID0gT2JqZWN0LmFzc2lnbih0aGlzLl9fcGFzc1NpZ25hbHMgfHwge30sIHYpO1xuICAgIH1cblxuICAgIHNldCBhbHRlclBhc3NTaWduYWxzKHYpIHtcbiAgICAgICAgaWYgKCFVdGlscy5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJTaWduYWxzOiBzcGVjaWZ5IGFuIG9iamVjdCB3aXRoIHNpZ25hbC10by1maXJlIG1hcHBpbmdzXCIpO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fX3Bhc3NTaWduYWxzKSB7XG4gICAgICAgICAgICB0aGlzLl9fcGFzc1NpZ25hbHMgPSB7fTtcbiAgICAgICAgfVxuICAgICAgICBmb3IgKGxldCBrZXkgaW4gdikge1xuICAgICAgICAgICAgY29uc3QgZCA9IHZba2V5XTtcbiAgICAgICAgICAgIGlmIChkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5fX3Bhc3NTaWduYWxzW2tleV07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX19wYXNzU2lnbmFsc1trZXldID0gdjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFNpZ25hbHMgdGhlIHBhcmVudCBvZiB0aGUgc3BlY2lmaWVkIGV2ZW50LlxuICAgICAqIEEgcGFyZW50L2FuY2VzdG9yIHRoYXQgd2lzaGVzIHRvIGhhbmRsZSB0aGUgc2lnbmFsIHNob3VsZCBzZXQgdGhlICdzaWduYWxzJyBwcm9wZXJ0eSBvbiB0aGlzIGNvbXBvbmVudC5cbiAgICAgKiBAcGFyYW0ge3N0cmluZ30gZXZlbnRcbiAgICAgKiBAcGFyYW0gey4uLip9IGFyZ3NcbiAgICAgKi9cbiAgICBzaWduYWwoZXZlbnQsIC4uLmFyZ3MpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NpZ25hbChldmVudCwgYXJncyk7XG4gICAgfVxuXG4gICAgX3NpZ25hbChldmVudCwgYXJncykge1xuICAgICAgICBjb25zdCBzaWduYWxQYXJlbnQgPSB0aGlzLl9nZXRQYXJlbnRTaWduYWxIYW5kbGVyKCk7XG4gICAgICAgIGlmIChzaWduYWxQYXJlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9fc2lnbmFscykge1xuICAgICAgICAgICAgICAgIGxldCBmaXJlRXZlbnQgPSB0aGlzLl9fc2lnbmFsc1tldmVudF07XG4gICAgICAgICAgICAgICAgaWYgKGZpcmVFdmVudCA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gSWdub3JlIGV2ZW50LlxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChmaXJlRXZlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZpcmVFdmVudCA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZmlyZUV2ZW50ID0gZXZlbnQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiBcbiAgICAgICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzRnVuY3Rpb24oZmlyZUV2ZW50KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpcmVFdmVudCguLi5hcmdzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmIChzaWduYWxQYXJlbnQuX2hhc01ldGhvZChmaXJlRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2lnbmFsUGFyZW50W2ZpcmVFdmVudF0oLi4uYXJncyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBwYXNzU2lnbmFsID0gKHRoaXMuX19wYXNzU2lnbmFscyAmJiB0aGlzLl9fcGFzc1NpZ25hbHNbZXZlbnRdKTtcbiAgICAgICAgICAgIGlmIChwYXNzU2lnbmFsKSB7XG4gICAgICAgICAgICAgICAgLy8gQnViYmxlIHVwLlxuICAgICAgICAgICAgICAgIGlmIChwYXNzU2lnbmFsICYmIHBhc3NTaWduYWwg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5fZG9GaXJlQW5jZXN0b3JzKG5hbWUsIGFyZ3MpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2RvRmlyZUFuY2VzdG9ycyhuYW1lLCBhcmdzKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNNZXRob2QobmFtZSkpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmZpcmUobmFtZSwgLi4uYXJncyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBzaWduYWxQYXJlbnQgPSB0aGlzLl9nZXRQYXJlbnRTaWduYWxIYW5kbGVyKCk7XG4gICAgICAgICAgICBpZiAoc2lnbmFsUGFyZW50KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHNpZ25hbFBhcmVudC5fZG9GaXJlQW5jZXN0b3JzKG5hbWUsIGFyZ3MpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGNvbGxlY3RTdWJDb21wb25lbnRzKHN1YnMsIGVsZW1lbnQpIHtcbiAgICAgICAgaWYgKGVsZW1lbnQuaGFzQ2hpbGRyZW4oKSkge1xuICAgICAgICAgICAgY29uc3QgY2hpbGRMaXN0ID0gZWxlbWVudC5fX2NoaWxkTGlzdDtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gY2hpbGRMaXN0Lmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGRMaXN0LmdldEF0KGkpO1xuICAgICAgICAgICAgICAgIGlmIChjaGlsZC5pc0NvbXBvbmVudCkge1xuICAgICAgICAgICAgICAgICAgICBzdWJzLnB1c2goY2hpbGQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIENvbXBvbmVudC5jb2xsZWN0U3ViQ29tcG9uZW50cyhzdWJzLCBjaGlsZCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICA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V0aG9kIHx8IGhhc0RpZmZlcmVudEV4aXRNZXRob2QpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBzaGFyZWRTdGF0ZSA9IFN0YXRlTWFjaGluZS5fZ2V0U2hhcmVkU3RhdGUodGhpcy5fc3RhdGUsIG5ld1N0YXRlKTtcbiAgICAgICAgICAgICAgICBjb25zdCBjb250ZXh0ID0ge1xuICAgICAgICAgICAgICAgICAgICBuZXdTdGF0ZTogbmV3U3RhdGUuX19wYXRoLFxuICAgICAgICAgICAgICAgICAgICBwcmV2U3RhdGU6IHByZXZTdGF0ZS5fX3BhdGgsXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlZFN0YXRlOiBzaGFyZWRTdGF0ZS5fX3BhdGhcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGNvbnN0IHNoYXJlZExldmVsID0gc2hhcmVkU3RhdGUuX19sZXZlbDtcblxuICAgICAgICAgICAgICAgIGlmIChoYXNEaWZmZXJlbnRFeGl0TWV0aG9kKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4aXRTdGF0ZXMgPSBTdGF0ZU1hY2hpbmUuX2dldFN0YXRlc1VudGlsTGV2ZWwodGhpcy5fc3RhdGUsIHNoYXJlZExldmVsKTtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBleGl0U3RhdGVzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3NldFN0YXRlKGV4aXRTdGF0ZXNbaV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FsbEV4aXQodGhpcy5fc3RhdGUsIGFyZ3MsIGNvbnRleHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RhdGVDaGFuZ2VPdmVycmlkZGVuID0gKHRoaXMuX3NldFN0YXRlSWQgIT09IHNldFN0YXRlSWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlQ2hhbmdlT3ZlcnJpZGRlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChoYXNEaWZmZXJlbnRFbnRlck1ldGhvZCkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBlbnRlclN0YXRlcyA9IFN0YXRlTWFjaGluZS5fZ2V0U3RhdGVzVW50aWxMZXZlbChuZXdTdGF0ZSwgc2hhcmVkTGV2ZWwpLnJldmVyc2UoKTtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBlbnRlclN0YXRlcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19zZXRTdGF0ZShlbnRlclN0YXRlc1tpXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWxsRW50ZXIodGhpcy5fc3RhdGUsIGFyZ3MsIGNvbnRleHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RhdGVDaGFuZ2VPdmVycmlkZGVuID0gKHRoaXMuX3NldFN0YXRlSWQgIT09IHNldFN0YXRlSWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlQ2hhbmdlT3ZlcnJpZGRlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9fc2V0U3RhdGUobmV3U3RhdGUpO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fY2hhbmdlZFN0YXRlKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgY29udGV4dCA9IHtcbiAgICAgICAgICAgICAgICAgICAgbmV3U3RhdGU6IG5ld1N0YXRlLl9fcGF0aCxcbiAgICAgICAgICAgICAgICAgICAgcHJldlN0YXRlOiBwcmV2U3RhdGUuX19wYXRoXG4gICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgIGlmIChhcmdzKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoYW5nZWRTdGF0ZShjb250ZXh0LCAuLi5hcmdzKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGFuZ2VkU3RhdGUoY29udGV4dCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fb25TdGF0ZUNoYW5nZSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSB7XG4gICAgICAgICAgICAgICAgICAgIG5ld1N0YXRlOiBuZXdTdGF0ZS5fX3BhdGgsXG4gICAgICAgICAgICAgICAgICAgIHByZXZTdGF0ZTogcHJldlN0YXRlLl9fcGF0aFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgdGhpcy5fb25TdGF0ZUNoYW5nZShjb250ZXh0KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2NhbGxFbnRlcihzdGF0ZSwgYXJncyA9IFtdLCBjb250ZXh0KSB7XG4gICAgICAgIGNvbnN0IGhhc1BhcmVudCA9ICEhc3RhdGUuX19wYXJlbnQ7XG4gICAgICAgIGlmIChzdGF0ZS5wcm90b3R5cGUuJGVudGVyKSB7XG4gICAgICAgICAgICBpZiAoIWhhc1BhcmVudCB8fCAoc3RhdGUuX19wYXJlbnQucHJvdG90eXBlLiRlbnRlciAhPT0gc3RhdGUucHJvdG90eXBlLiRlbnRlcikpIHtcbiAgICAgICAgICAgICAgICBzdGF0ZS5wcm90b3R5cGUuJGVudGVyLm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hdGhzID0gT2JqZWN0LmtleXModGhpcy5fc3RhdGVNYXApO1xuICAgICAgICBjb25zdCBkZXNjcmlwdG9ycyA9IFtdO1xuICAgICAgICBjb25zdCBhbGlhc2VzID0gW107XG4gICAgICAgIHN0YXRlUGF0aHMuZm9yRWFjaCgoc3RhdGVQYXRoLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgY29uc3Qgc3RhdGUgPSB0aGlzLl9zdGF0ZU1hcFtzdGF0ZVBhdGhdO1xuICAgICAgICAgICAgY29uc3QgZGVzY3JpcHRvciA9IHRoaXMuX2dldERlc2NyaXB0b3Ioc3RhdGUsIG1lbWJlcik7XG4gICAgICAgICAgICBpZiAoZGVzY3JpcHRvcikge1xuICAgICAgICAgICAgICAgIGRlc2NyaXB0b3JzW2luZGV4XSA9IGRlc2NyaXB0b3I7XG5cbiAgICAgICAgICAgICAgICAvLyBBZGQgdG8gcHJvdG90eXBlLlxuICAgICAgICAgICAgICAgIGNvbnN0IGFsaWFzID0gU3RhdGVNYWNoaW5lVHlwZS5nZXRTdGF0ZU1lbWJlckFsaWFzKGRlc2NyaXB0b3IuX3NvdXJjZS5fX3BhdGgsIG1lbWJlcik7XG4gICAgICAgICAgICAgICAgYWxpYXNlc1tpbmRleF0gPSBhbGlhcztcblxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fcm91dGVyLnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eShhbGlhcykpIHtcbiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMuX3JvdXRlci5wcm90b3R5cGUsIGFsaWFzLCBkZXNjcmlwdG9yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGRlc2NyaXB0b3JzW2luZGV4XSA9IG51bGw7XG4gICAgICAgICAgICAgICAgYWxpYXNlc1tpbmRleF0gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBsZXQgdHlwZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgZGVzY3JpcHRvcnMuZm9yRWFjaChkZXNjcmlwdG9yID0+IHtcbiAgICAgICAgICAgIGlmIChkZXNjcmlwdG9yKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgZGVzY1R5cGUgPSB0aGlzLl9nZXREZXNjcmlwdG9yVHlwZShkZXNjcmlwdG9yKTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZSAmJiAodHlwZSAhPT0gZGVzY1R5cGUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihgW0xpZ2h0bmluZ10gTWVtYmVyICR7bWVtYmVyfSBpbiAke3RoaXMuX3R5cGUubmFtZX0gaGFzIGluY29uc2lzdGVudCB0eXBlcy5gKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0eXBlID0gZGVzY1R5cGU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHN3aXRjaCh0eXBlKSB7XG4gICAgICAgICAgICBjYXNlIFwibWV0aG9kXCI6XG4gICAgICAgICAgICAgICAgdGhpcy5fYWRkTWV0aG9kUm91dGVyKG1lbWJlciwgZGVzY3JpcHRvcnMsIGFsaWFzZXMpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcImdldHRlclwiOlxuICAgICAgICAgICAgICAgIHRoaXMuX2FkZEdldHRlclNldHRlclJvdXRlcnMobWVtYmVyKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgXCJwcm9wZXJ0eVwiOlxuICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIEZpeGVkIHByb3BlcnRpZXMgYXJlIG5vdCBzdXBwb3J0ZWQ7IHBsZWFzZSB1c2UgYSBnZXR0ZXIgaW5zdGVhZCFcIilcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXREZXNjcmlwdG9yKHN0YXRlLCBtZW1iZXIsIGlzVmFsaWQgPSAoKSA9PiB0cnVlKSB7XG4gICAgICAgIGxldCB0eXBlID0gc3RhdGU7XG4gICAgICAgIGxldCBjdXJTdGF0ZSA9IHN0YXRlO1xuXG4gICAgICAgIGRvIHtcbiAgICAgICAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKHR5cGUucHJvdG90eXBlLCBtZW1iZXIpO1xuICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXNWYWxpZChkZXNjcmlwdG9yKSkge1xuICAgICAgICAgICAgICAgICAgICBkZXNjcmlwdG9yLl9zb3VyY2UgPSBjdXJTdGF0ZTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlc2NyaXB0b3I7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdHlwZSA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0eXBlKTtcbiAgICAgICAgICAgIGlmICh0eXBlICYmIHR5cGUuaGFzT3duUHJvcGVydHkoJ19fc3RhdGUnKSkge1xuICAgICAgICAgICAgICAgIGN1clN0YXRlID0gdHlwZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSB3aGlsZSh0eXBlICYmIHR5cGUucHJvdG90eXBlKTtcbiAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgICB9XG5cbiAgICBfZ2V0RGVzY3JpcHRvclR5cGUoZGVzY3JpcHRvcikge1xuICAgICAgICBpZiAoZGVzY3JpcHRvci5nZXQgfHwgZGVzY3JpcHRvci5zZXQpIHtcbiAgICAgICAgICAgIHJldHVybiAnZ2V0dGVyJztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh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gY3VyID0gYWxpYXNlc1swXTtcbiAgICAgICAgY29uc3Qgc3VwcG9ydHNTcHJlYWQgPSBTdGF0ZU1hY2hpbmVUeXBlLl9zdXBwb3J0c1NwcmVhZCgpO1xuICAgICAgICBmb3IgKGxldCBpID0gMSwgbiA9IGFsaWFzZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBhbGlhcyA9IGFsaWFzZXNbaV07XG4gICAgICAgICAgICBpZiAoYWxpYXMgIT09IGN1cikge1xuICAgICAgICAgICAgICAgIGlmIChjdXIpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHN1cHBvcnRzU3ByZWFkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl0oLi4uYXJndW1lbnRzKTsgZWxzZWApO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIHJldHVybiB0aGlzW1wiJHtjdXJ9XCJdLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7IGVsc2VgKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSByZXR1cm4gOyBlbHNlYCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY3VyID0gYWxpYXM7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGN1cikge1xuICAgICAgICAgICAgaWYgKHN1cHBvcnRzU3ByZWFkKSB7XG4gICAgICAgICAgICAgICAgY29kZS5wdXNoKGByZXR1cm4gdGhpc1tcIiR7Y3VyfVwiXSguLi5hcmd1bWVudHMpO2ApO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAg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ICBjb25zdCBhbGlhc2VzID0gW107XG4gICAgICAgIHN0YXRlUGF0aHMuZm9yRWFjaCgoc3RhdGVQYXRoLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgY29uc3Qgc3RhdGUgPSB0aGlzLl9zdGF0ZU1hcFtzdGF0ZVBhdGhdO1xuICAgICAgICAgICAgY29uc3QgZGVzY3JpcHRvciA9IHRoaXMuX2dldERlc2NyaXB0b3Ioc3RhdGUsIG1lbWJlciwgKGRlc2NyaXB0b3IgPT4gZGVzY3JpcHRvci5nZXQpKTtcbiAgICAgICAgICAgIGlmIChkZXNjcmlwdG9yKSB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRvcnNbaW5kZXhdID0gZGVzY3JpcHRvcjtcblxuICAgICAgICAgICAgICAgIC8vIEFkZCB0byBwcm90b3R5cGUuXG4gICAgICAgICAgICAgICAgY29uc3QgYWxpYXMgPSBTdGF0ZU1hY2hpbmVUeXBlLmdldFN0YXRlTWVtYmVyQWxpYXMoZGVzY3JpcHRvci5fc291cmNlLl9fcGF0aCwgbWVtYmVyKTtcbiAgICAgICAgICAgICAgICBhbGlhc2VzW2luZGV4XSA9IGFsaWFzO1xuXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yb3V0ZXIucHJvdG90eXBlLmhhc093blByb3BlcnR5KGFsaWFzKSkge1xuICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcy5fcm91dGVyLnByb3RvdHlwZSwgYWxpYXMsIGRlc2NyaXB0b3IpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRvcnNbaW5kZXhdID0gbnVsbDtcbiAgICAgICAgICAgICAgICBhbGlhc2VzW2luZGV4XSA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGNvbnN0IGNvZGUgPSBbXG4gICAgICAgICAgICAvLyBUaGUgbGluZSBlbnN1cmVzIHRoYXQsIHdoaWxlIGRlYnVnZ2luZywgeW91ciBJREUgd29uJ3Qgb3BlbiBtYW55IHRhYnMuXG4gICAgICAgICAgICBcIi8vQCBzb3VyY2VVUkw9U3RhdGVNYWNoaW5lUm91dGVyLmpzXCIsXG4gICAgICAgICAgICBcInZhciBpID0gdGhpcy5fc3RhdGVJbmRleDtcIlxuICAgICAgICBdO1xuICAgICAgICBsZXQgY3VyID0gYWxpYXNlc1swXTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDEsIG4gPSBhbGlhc2VzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3QgYWxpYXMgPSBhbGlhc2VzW2ldO1xuICAgICAgICAgICAgaWYgKGFsaWFzICE9PSBjdXIpIHtcbiAgICAgICAgICAgICAgICBpZiAoY3VyKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSByZXR1cm4gdGhpc1tcIiR7Y3VyfVwiXTsgZWxzZWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSByZXR1cm4gOyBlbHNlYCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY3VyID0gYWxpYXM7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGN1cikge1xuICAgICAgICAgICAgY29kZS5wdXNoKGByZXR1cm4gdGhpc1tcIiR7Y3VyfVwiXTtgKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvZGUucHVzaChgO2ApO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGZ1bmN0aW9uQm9keSA9IGNvZGUuam9pbihcIlxcblwiKTtcbiAgICAgICAgY29uc3Qgcm91dGVyID0gbmV3IEZ1bmN0aW9uKFtdLCBmdW5jdGlvbkJvZHkpO1xuICAgICAgICByZX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ICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBkZXNjcmlwdG9yc1tpbmRleF0gPSBudWxsO1xuICAgICAgICAgICAgICAgIGFsaWFzZXNbaW5kZXhdID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgY29uc3QgY29kZSA9IFtcbiAgICAgICAgICAgIC8vIFRoZSBsaW5lIGVuc3VyZXMgdGhhdCwgd2hpbGUgZGVidWdnaW5nLCB5b3VyIElERSB3b24ndCBvcGVuIG1hbnkgdGFicy5cbiAgICAgICAgICAgIFwiLy9AIHNvdXJjZVVSTD1TdGF0ZU1hY2hpbmVSb3V0ZXIuanNcIixcbiAgICAgICAgICAgIFwidmFyIGkgPSB0aGlzLl9zdGF0ZUluZGV4O1wiXG4gICAgICAgIF07XG4gICAgICAgIGxldCBjdXIgPSBhbGlhc2VzWzBdO1xuICAgICAgICBmb3IgKGxldCBpID0gMSwgbiA9IGFsaWFzZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBhbGlhcyA9IGFsaWFzZXNbaV07XG4gICAgICAgICAgICBpZiAoYWxpYXMgIT09IGN1cikge1xuICAgICAgICAgICAgICAgIGlmIChjdXIpIHtcbiAgICAgICAgICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIHRoaXNbXCIke2N1cn1cIl0gPSBhcmc7IGVsc2VgKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgOyBlbHNlYCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY3VyID0gYWxpYXM7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGN1cikge1xuICAgICAgICAgICAgY29kZS5wdXNoKGB0aGlzW1wiJHtjdXJ9XCJdID0gYXJnO2ApO1xuICAgICAgICB9IGVsc2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ybiB0aGlzLnRhZyhcIldyYXBcIik7XG4gICAgfVxuXG4gICAgc2V0IGNvbnRlbnQodikge1xuICAgICAgICByZXR1cm4gdGhpcy53cmFwLmNvbnRlbnQgPSB2O1xuICAgIH1cblxuICAgIGdldCBjb250ZW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy53cmFwLmNvbnRlbnQ7XG4gICAgfVxuXG4gICAgc2V0IHBhZGRpbmcodikge1xuICAgICAgICB0aGlzLndyYXAuX3BhZGRpbmdYID0gdjtcbiAgICAgICAgdGhpcy53cmFwLl9wYWRkaW5nWSA9IHY7XG4gICAgICAgIHRoaXMud3JhcC5fdXBkYXRlQmx1clNpemUoKTtcbiAgICB9XG5cbiAgICBzZXQgcGFkZGluZ1godikge1xuICAgICAgICB0aGlzLndyYXAuX3BhZGRpbmdYID0gdjtcbiAgICAgICAgdGhpcy53cmFwLl91cGRhdGVCbHVyU2l6ZSgpO1xuICAgIH1cblxuICAgIHNldCBwYWRkaW5nWSh2KSB7XG4gICAgICAgIHRoaXMud3JhcC5fcGFkZGluZ1kgPSB2O1xuICAgICAgICB0aGlzLndyYXAuX3VwZGF0ZUJsdXJTaXplKCk7XG4gICAgfVxuXG4gICAgc2V0IGFtb3VudCh2KSB7XG4gICAgICAgIHJldHVybiB0aGlzLndyYXAuYW1vdW50ID0gdjtcbiAgICB9XG5cbiAgICBnZXQgYW1vdW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy53cmFwLmFtb3VudDtcbiAgICB9XG5cbiAgICBfb25SZXNpemUoKSB7XG4gICAgICAgIHRoaXMud3JhcC53ID0gdGhpcy5yZW5kZXJXaWR0aDtcbiAgICAgICAgdGhpcy53cmFwLmggPSB0aGlzLnJlbmRlckhlaWdodDtcbiAgICB9XG5cbiAgICBnZXQgX3NpZ25hbFByb3h5KCkge1xuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBfYnVpbGQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICA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50Q29yZSkge1xuICAgICAgICAgICAgaWYgKChlbGVtZW50Q29yZS5fcmVjYWxjICYgKDIgKyAxMjgpKSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHcgPSBlbGVtZW50Q29yZS53O1xuICAgICAgICAgICAgICAgIGNvbnN0IGggPSBlbGVtZW50Q29yZS5oO1xuICAgICAgICAgICAgICAgIGxldCBjdXIgPSBlbGVtZW50Q29yZTtcbiAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIGN1ciA9IGN1ci5fY2hpbGRyZW5bMF07XG4gICAgICAgICAgICAgICAgICAgIGN1ci5fZWxlbWVudC53ID0gdztcbiAgICAgICAgICAgICAgICAgICAgY3VyLl9lbGVtZW50LmggPSBoO1xuICAgICAgICAgICAgICAgIH0gd2hpbGUoY3VyLl9jaGlsZHJlbik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIFRleHR3cmFwOiB7cnR0OiB0cnVlLCBmb3JjZVpJbmRleENvbnRleHQ6IHRydWUsIHJlbmRlck9mZnNjcmVlbjogdHJ1ZSwgQ29udGVudDoge319LFxuICAgICAgICAgICAgTGF5ZXJzOiB7XG4gICAgICAgICAgICAgICAgTDA6IHtydHQ6IHRydWUsIG9uVXBkYXRlOiBvblVwZGF0ZSwgcmVuZGVyT2Zmc2NyZWVuOiB0cnVlLCB2aXNpYmxlOiBmYWxzZSwgQ29udGVudDoge3NoYWRlcjoge3R5cGU6IEJveEJsdXJTaGFkZXJ9fX0sXG4gICAgICAgICAgICAgICAgTDE6IHtydHQ6IHRydWUsIG9uVXBkYXRlOiBvblVwZGF0ZSwgcmVuZGVyT2Zmc2NyZWVuOiB0cnVlLCB2aXNpYmxlOiBmYWxzZSwgQ29udGVudDoge3NoYWRlcjoge3R5cGU6IEJveEJsdXJTaGFkZXJ9fX0sXG4gICAgICAgICAgICAgICAgTDI6IHtydHQ6IHRydWUsIG9uVXBk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BvbmVudGlhbGx5IGZvciBibHVyLlxuICAgICAqIEJlc3QgcmVzdWx0cyBmb3Igbm9uLWZyYWN0aW9uYWwgdmFsdWVzLlxuICAgICAqIEBwYXJhbSB2O1xuICAgICAqL1xuICAgIHNldCBhbW91bnQodikge1xuICAgICAgICB0aGlzLl9hbW91bnQgPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGUoKTtcbiAgICB9XG5cbiAgICBnZXQgYW1vdW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYW1vdW50O1xuICAgIH1cblxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIGxldCB2ID0gTWF0aC5taW4oNCwgTWF0aC5tYXgoMCwgdGhpcy5fYW1vdW50KSk7XG4gICAgICAgIGlmICh2ID09PSAwKSB7XG4gICAgICAgICAgICB0aGlzLl90ZXh0d3JhcC5yZW5kZXJUb1RleHR1cmUgPSBmYWxzZTtcbiAgICAgICAgICAgIHRoaXMuX291dHB1dC5zaGFkZXIub3RoZXJUZXh0dXJlU291cmNlID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMuX291dHB1dC52aXNpYmxlID0gZmFsc2U7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl90ZXh0d3JhcC5yZW5kZXJUb1RleHR1cmUgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5fb3V0cHV0LnZpc2libGUgPSB0cnVlO1xuXG4gICAgICAgICAgICB0aGlzLmdldExheWVyKDApLnZpc2libGUgPSAodiA+IDApO1xuICAgICAgICAgICAgdGhpcy5nZXRMYXllcigxKS52aXNpYmxlID0gKHYgPiAxKTtcbiAgICAgICAgICAgIHRoaXMuZ2V0TGF5ZXIoMikudmlzaWJsZSA9ICh2ID4gMik7XG4gICAgICAgICAgICB0aGlzLmdldExheWVyKDMpLnZpc2libGUgPSAodiA+IDMpO1xuXG4gICAgICAgICAgICBpZiAodiA8PSAxKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3V0cHV0L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AgIHRoaXMuX2luZGV4ID0gaW5kZXg7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fcm9sbCB8fCAodGhpcy52aWV3cG9ydFNpemUgPiB0aGlzLl9pdGVtU2l6ZSAqIG5FbGVtZW50cykpIHtcbiAgICAgICAgICAgIHRoaXMuX2luZGV4ID0gVXRpbHMuZ2V0TW9kdWxvSW5kZXgodGhpcy5faW5kZXgsIG5FbGVtZW50cyk7XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgZGlyZWN0aW9uID0gKHRoaXMuX2hvcml6b250YWwgXiB0aGlzLl9pbnZlcnREaXJlY3Rpb24gPyAtMSA6IDEpO1xuICAgICAgICBsZXQgdmFsdWUgPSBkaXJlY3Rpb24gKiB0aGlzLl9pbmRleCAqIHRoaXMuX2l0ZW1TaXplO1xuXG4gICAgICAgIGlmICh0aGlzLl9yb2xsKSB7XG4gICAgICAgICAgICBsZXQgbWluLCBtYXgsIHNjcm9sbERlbHRhO1xuICAgICAgICAgICAgaWYgKGRpcmVjdGlvbiA9PSAxKSB7XG4gICAgICAgICAgICAgICAgbWF4ID0gKG5FbGVtZW50cyAtIDEpICogdGhpcy5faXRlbVNpemU7XG4gICAgICAgICAgICAgICAgc2Nyb2xsRGVsdGEgPSB0aGlzLl92aWV3cG9ydFNjcm9sbE9mZnNldCAqIHRoaXMudmlld3BvcnRTaXplIC0gdGhpcy5faXRlbVNjcm9sbE9mZnNldCAqIHRoaXMuX2l0ZW1TaXplO1xuXG4gICAgICAgICAgICAgICAgbWF4IC09IHNjcm9sbERlbHRhO1xuXG4gICAgICAgICAgICAgICAgbWluID0gdGhpcy52aWV3cG9ydFNpemUgLSAodGhpcy5faXRlbVNpemUgKyBzY3JvbGxEZWx0YSk7XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fcm9sbE1pbikgbWluIC09IHRoaXMuX3JvbGxNaW47XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3JvbGxNYXgpIG1heCArPSB0a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xuICAgICAgICBsZXQgcywgZSwgcHMsIHBlO1xuICAgICAgICBpZiAoZGlyZWN0aW9uID09IC0xKSB7XG4gICAgICAgICAgICBzID0gTWF0aC5mbG9vcigtdiAvIHRoaXMuX2l0ZW1TaXplKTtcbiAgICAgICAgICAgIHBzID0gMSAtICgoLXYgLyB0aGlzLl9pdGVtU2l6ZSkgLSBzKTtcbiAgICAgICAgICAgIGUgPSBNYXRoLmZsb29yKCh2aWV3cG9ydFNpemUgLSB2KSAvIHRoaXMuX2l0ZW1TaXplKTtcbiAgICAgICAgICAgIHBlID0gKCgodmlld3BvcnRTaXplIC0gdikgLyB0aGlzLl9pdGVtU2l6ZSkgLSBlKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHMgPSBNYXRoLmNlaWwodiAvIHRoaXMuX2l0ZW1TaXplKTtcbiAgICAgICAgICAgIHBzID0gMSArICh2IC8gdGhpcy5faXRlbVNpemUpIC0gcztcbiAgICAgICAgICAgIGUgPSBNYXRoLmNlaWwoKHYgLSB2aWV3cG9ydFNpemUpIC8gdGhpcy5faXRlbVNpemUpO1xuICAgICAgICAgICAgcGUgPSBlIC0gKCh2IC0gdmlld3BvcnRTaXplKSAvIHRoaXMuX2l0ZW1TaXplKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fcm9sbCB8fCAodmlld3BvcnRTaXplID4gdGhpcy5faXRlbVNpemUgKiBuRWxlbWVudHMpKSB7XG4gICAgICAgICAgICAvLyBEb24ndCBzaG93IGFkZGl0aW9uYWwgaXRlbXMuXG4gICAgICAgICAgICBpZiAoZSA+PSBuRWxlbWVudHMpIHtcbiAgICAgICAgICAgICAgICBlID0gbkVsZW1lbnRzIC0gMTtcbiAgICAgICAgICAgICAgICBwZSA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocyA+PSBuRWxlbWVudHMpIHtcbiAgICAgICAgICAgICAgICBzID0gbkVsZW1lbnRzIC0gMTtcbiAgICAgICAgICAgICAgICBwcyA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoZSA8PSAtMSkge1xuICAgICAgICAgICAgICAgIGUgPSAwO1xuICAgICAgICAgICAgICAgIHBlID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzIDw9IC0xKSB7XG4gICAgICAgICAgICAgICAgcyA9IDA7XG4gICAgICAgICAgICAgICAgcHMgPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IG9mZnNldCA9IC1kaXJlY3Rpb24gKiBzICogdGhpcy5faXRlbVNpemU7XG5cbiAgICAgICAgbGV0IGl0ZW07XG4gICAgICAgIGZvciAobGV0IGluZGV4ID0gczsgKGRpcmVjdGlvbiA9PSAtMSA/IGluZGV4IDw9IGUgOiBpbmRleCA+PSBlKTsgKGRpcmVjdGlvbiA9PSAtMSA/IGluZGV4KysgOiBpbmRleC0tKSkge1xuICAgICAgICAgICAgbGV0IHJlYWxJbmRleCA9IFV0aWxzLmdldE1vZHVsb0luZGV4KGluZGV4LCBuRWxlbWVudHMpO1xuXG4gICAgICAgICAgICBsZXQgZWxlbWVudCA9IHRoaXMuZ2V0RWxlbWVudChyZWFsSW5kZXgpO1xuICAgICAgICAgICAgaXRlbSA9IGVsZW1lbnQucGFyZW50O1xuICAgICAgICAgICAgdGhpcy5fdmlzaWJsZUl0ZW1zLmRlbGV0ZShpdGVtKTtcbiAgICAgICAgICAgIGlmICh0aGlzLl9ob3Jpem9udGFsKSB7XG4gICAgICAgICAgICAgICAgaXRlbS54ID0gb2Zmc2V0ICsgc2Nyb2xsRGVsdGE7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGl0ZW0ueSA9IG9mZnNldCArIHNjcm9sbERlbHRhO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgd2FzVmlzaWJsZSA9IGl0ZW0udmlzaWJsZTtcbiAgICAgICAgICAgIGl0ZW0udmlzaWJsZSA9IHRydWU7XG5cbiAgICAgICAgICAgIGlmICghd2FzVmlzaWJsZSB8fCB0aGlzLl9yZWxvYWRWaXNpYmxlRWxlbWVudHMpIHtcbiAgICAgICAgICAgICAgICAvLyBUdXJuZWQgdmlzaWJsZS5cbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3Zpc2libGUnLCBpbmRleCwgcmVhbEluZGV4KTtcbiAgICAgICAgICAgIH1cblxuXG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9wcm9ncmVzc0FuaW1hdGlvbikge1xuICAgICAgICAgICAgICAgIGxldCBwID0gMTtcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT0gcykge1xuICAgICAgICAgICAgICAgICAgICBwID0gcHM7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpbmRleCA9PSBlKSB7XG4gICAgICAgICAgICAgICAgICAgIHAgPSBwZTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBVc2UgYW5pbWF0aW9uIHRvIHByb2dyZXNzLlxuICAgICAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzQW5pbWF0aW9uLmFwcGx5KGVsZW1lbnQsIHApO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBvZmZzZXQgKz0gdGhpcy5faXRlbVNpemU7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBIYW5kbGUgaXRlbSB2aXNpYmlsaXR5LlxuICAgICAgICBsZXQgc2VsZiA9IHRoaXM7XG4gICAgICAgIHRoaXMuX3Zpc2libGVJdGVtcy5mb3JFYWNoKGZ1bmN0aW9uKGludmlzaWJsZUl0ZW0pIHtcbiAgICAgICAgICAgIGludmlzaWJsZUl0ZW0udmlzaWJsZSA9IGZhbHNlO1xuICAgICAgICAgICAgc2VsZi5fdmlzaWJsZUl0ZW1zLmRlbGV0ZShpbnZpc2libGVJdGVtKTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgZm9yIChsZXQgaW5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HJvbGwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yb2xsO1xuICAgIH1cblxuICAgIHNldCByb2xsKHYpIHtcbiAgICAgICAgdGhpcy5fcm9sbCA9IHY7XG4gICAgICAgIHRoaXMudXBkYXRlKCk7XG4gICAgfVxuXG4gICAgZ2V0IHJvbGxNaW4oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yb2xsTWluO1xuICAgIH1cblxuICAgIHNldCByb2xsTWluKHYpIHtcbiAgICAgICAgdGhpcy5fcm9sbE1pbiA9IHY7XG4gICAgICAgIHRoaXMudXBkYXRlKCk7XG4gICAgfVxuXG4gICAgZ2V0IHJvbGxNYXgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yb2xsTWF4O1xuICAgIH1cblxuICAgIHNldCByb2xsTWF4KHYpIHtcbiAgICAgICAgdGhpcy5fcm9sbE1heCA9IHY7XG4gICAgICAgIHRoaXMudXBkYXRlKCk7XG4gICAgfVxuXG4gICAgZ2V0IGludmVydERpcmVjdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ludmVydERpcmVjdGlvbjtcbiAgICB9XG5cbiAgICBzZXQgaW52ZXJ0RGlyZWN0aW9uKHYpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9zdGFydGVkKSB7XG4gICAgICAgICAgICB0aGlzLl9pbnZlcnREaXJlY3Rpb24gPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGhvcml6b250YWwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9ob3Jpem9udGFsO1xuICAgIH1cblxuICAgIHNldCBob3Jpem9udGFsKHYpIHtcbiAgICAgICAgaWYgKHYgIT09IHRoaXMuX2hvcml6b250YWwpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fc3RhcnRlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2hvcml6b250YWwgPSB2O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG59XG5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X2luZGV4ID49IHRoaXMubGlzdC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5saXN0LnNldEluZGV4KDApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMubGlzdC51cGRhdGUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIG9uUmVtb3ZlKGl0ZW0sIGluZGV4KSB7XG4gICAgICAgIHN1cGVyLm9uUmVtb3ZlKGl0ZW0sIGluZGV4KTtcbiAgICAgICAgbGV0IHJpID0gdGhpcy5saXN0LnJlYWxJbmRleDtcbiAgICAgICAgaWYgKHJpID09PSBpbmRleCkge1xuICAgICAgICAgICAgaWYgKHJpID09PSB0aGlzLmxpc3QubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgcmktLTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChyaSA+PSAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5saXN0LnNldEluZGV4KHJpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmIChyaSA+IGluZGV4KSB7XG4gICAgICAgICAgICB0aGlzLmxpc3Quc2V0SW5kZXgocmkgLSAxKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMubGlzdC5fcmVsb2FkVmlzaWJsZUVsZW1lbnRzID0gdHJ1ZTtcbiAgICB9XG5cbiAgICBvblNldChpdGVtLCBpbmRleCkge1xuICAgICAgICBzdXBlci5vblNldChpdGVtLCBpbmRleCk7XG4gICAgICAgIHRoaXMuY2hlY2tTdGFydGVkKGluZGV4KTtcbiAgICB9XG5cbiAgICBvblN5bmMocmVtb3ZlZCwgYWRkZWQsIG9yZGVyKSB7XG4gICAgICAgIHN1cGVyLm9uU3luYyhyZW1vdmVkLCBhZGRlZCwgb3JkZXIpO1xuICAgICAgICB0aGlzLmNoZWNrU3RhcnRlZCgwKTtcbiAgICB9XG5cbiAgICBnZXQgX3NpZ25hbFBy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xldCBpdHMgPSAwO1xuICAgICAgICAgICAgd2hpbGUodiA8IDAuNSAmJiBpdHMgPCAxMikge1xuICAgICAgICAgICAgICAgIGl0cysrO1xuICAgICAgICAgICAgICAgIHYgPSB2ICogMjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5zY2FsZSA9IHY7XG4gICAgICAgICAgICB0aGlzLl9zZXRJdGVyYXRpb25zKGl0cyk7XG5cbiAgICAgICAgICAgIHRoaXMuX3Ntb290aFNjYWxlID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9zZXRJdGVyYXRpb25zKGl0cykge1xuICAgICAgICBpZiAodGhpcy5faXRlcmF0aW9ucyAhPT0gaXRzKSB7XG4gICAgICAgICAgICBjb25zdCBzY2FsZXJzID0gdGhpcy5zZWwoXCJTY2FsZVwiKS5jaGlsZExpc3Q7XG4gICAgICAgICAgICBjb25zdCBjb250ZW50ID0gdGhpcy5zZWwoXCJDb250ZW50V3JhcFwiKTtcbiAgICAgICAgICAgIHdoaWxlIChzY2FsZXJzLmxlbmd0aCA8IGl0cykge1xuICAgICAgICAgICAgICAgIGNvbnN0IGZpcnN0ID0gc2NhbGVycy5sZW5ndGggPT09IDA7XG4gICAgICAgICAgICAgICAgY29uc3QgdGV4dHVyZSA9IChmaXJzdCA/IGNvbnRlbnQuZ2V0VGV4dHVyZSgpIDogc2NhbGVycy5sYXN0LmdldFRleHR1cmUoKSk7XG4gICAgICAgICAgICAgICAgc2NhbGVycy5hKHtydHQ6IHRydWUsIHJlbmRlck9mZnNjcmVlbjogdHJ1ZSwgdGV4dHVyZTogdGV4dHVyZX0pO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBTbW9vdGhTY2FsZUNvbXBvbmVudC5fdXBkYXRlRGltZW5zaW9ucyh0aGlzLnRhZyhcIkNvbnRlbnRXcmFwXCIpLCB0cnVlKTtcblxuICAgICAgICAgICAgY29uc3QgdXNlU2NhbGVycyA9IChpdHMgPiAwKTtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIENvbnRlbnRXcmFwOiB7cmVuZGVyVG9UZXh0dXJlOiB1c2VTY2FsZXJzfSxcbiAgICAgICAgICAgICAgICBTY2FsZToge3Zpc2libGU6IHVzZVNjYWxlcnN9XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBzY2FsZXJzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHNjYWxlcnMuZ2V0QXQoaSkucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICB2aXNpYmxlOiBpIDwgaXRzLFxuICAgICAgICAgICAgICAgICAgICByZW5kZXJPZmZzY3JlZW46IGkgIT09IGl0cyAtIDFcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX2l0ZXJhdGlvbnMgPSBpdHM7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgX3VwZGF0ZURpbWVuc2lvbnMoY29udGVudFdyYXAsIGZvcmNlKSB7XG4gICAgICAgIGNvbnN0IGNvbnRlbnQgPSBjb250ZW50V3JhcC5jaGlsZHJlblswXTtcbiAgICAgICAgbGV0IHcgPSBjb250ZW50LnJlbmRlcldpZHRoO1xuICAgICAgICBsZXQgaCA9IGNvbnRlbnQucmVuZGVySGVpZ2h0O1xuICAgICAgICBpZiAodyAhPT0gY29udGVudFdyYXAudyB8fCBoICE9PSBjb250ZW50V3JhcC5oIHx8IGZvcmNlKSB7XG4gICAgICAgICAgICBjb250ZW50V3JhcC53ID0gdztcbiAgICAgICAgICAgIGNvbnRlbnRXcmFwLmggPSBoO1xuXG4gICAgICAgICAgICBjb25zdCBzY2FsZXJzID0gY29udGVudFdyYXAucGFyZW50LnRhZyhcIlNjYWxlXCIpLmNoaWxkcmVuO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBzY2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yLkFMSUdOX0lURU1TLmluZGV4T2YodikgPT09IC0xKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIGFsaWduSXRlbXMsIG9wdGlvbnM6IFwiICsgRmxleENvbnRhaW5lci5BTElHTl9JVEVNUy5qb2luKFwiLFwiKSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fYWxpZ25JdGVtcyA9IHY7XG5cbiAgICAgICAgdGhpcy5fY2hhbmdlZENvbnRlbnRzKCk7XG4gICAgfVxuXG4gICAgZ2V0IGFsaWduQ29udGVudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2FsaWduQ29udGVudDtcbiAgICB9XG5cbiAgICBzZXQgYWxpZ25Db250ZW50KHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2FsaWduQ29udGVudCA9PT0gdikgcmV0dXJuO1xuICAgICAgICBpZiAoRmxleENvbnRhaW5lci5BTElHTl9DT05URU5ULmluZGV4T2YodikgPT09IC0xKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIGFsaWduQ29udGVudCwgb3B0aW9uczogXCIgKyBGbGV4Q29udGFpbmVyLkFMSUdOX0NPTlRFTlQuam9pbihcIixcIikpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2FsaWduQ29udGVudCA9IHY7XG5cbiAgICAgICAgdGhpcy5fY2hhbmdlZENvbnRlbnRzKCk7XG4gICAgfVxuXG4gICAgZ2V0IGp1c3RpZnlDb250ZW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fanVzdGlmeUNvbnRlbnQ7XG4gICAgfVxuXG4gICAgc2V0IGp1c3RpZnlDb250ZW50KHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2p1c3RpZnlDb250ZW50ID09PSB2KSByZXR1cm47XG5cbiAgICAgICAgaWYgKEZsZXhDb250YWluZXIuSlVTVElGWV9DT05URU5ULmluZGV4T2YodikgPT09IC0xKSB7XG4gICA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mluaygpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl9zaHJpbms7XG4gICAgfVxuXG4gICAgX2dldERlZmF1bHRTaHJpbmsoKSB7XG4gICAgICAgIGlmICh0aGlzLml0ZW0uaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIC8vIEFsbCBub24tZmxleCBjb250YWluZXJzIGFyZSBhYnNvbHV0ZWx5IHBvc2l0aW9uZWQgaXRlbXMgd2l0aCBmaXhlZCBkaW1lbnNpb25zLCBhbmQgYnkgZGVmYXVsdCBub3Qgc2hyaW5rYWJsZS5cbiAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0IHNocmluayh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9zaHJpbmsgPT09IHYpIHJldHVybjtcblxuICAgICAgICB0aGlzLl9zaHJpbmsgPSBwYXJzZUludCh2KSB8fCAwO1xuXG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICB9XG5cbiAgICBnZXQgYWxpZ25TZWxmKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYWxpZ25TZWxmO1xuICAgIH1cblxuICAgIHNldCBhbGlnblNlbGYodikge1xuICAgICAgICBpZiAodGhpcy5fYWxpZ25TZWxmID09PSB2KSByZXR1cm47XG5cbiAgICAgICAgaWYgKHYgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgdGhpcy5fYWxpZ25TZWxmID0gdW5kZWZpbmVkO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKEZsZXhDb250YWluZXIuQUxJR05fSVRFTVMuaW5kZXhPZih2KSA9PT0gLTEpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIGFsaWduU2VsZiwgb3B0aW9uczogXCIgKyBGbGV4Q29udGFpbmVyLkFM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aXplU2V0dGluZyghdGhpcy5jdHIuX2hvcml6b250YWwpO1xuICAgIH1cblxuICAgIF9nZXRDcm9zc0F4aXNNYXhTaXplU2V0dGluZygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2dldE1heFNpemVTZXR0aW5nKCF0aGlzLmN0ci5faG9yaXpvbnRhbCk7XG4gICAgfVxuXG4gICAgX2dldE1haW5BeGlzTWF4U2l6ZVNldHRpbmcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9nZXRNYXhTaXplU2V0dGluZyh0aGlzLmN0ci5faG9yaXpvbnRhbCk7XG4gICAgfVxuXG4gICAgX2dldE1pblNpemVTZXR0aW5nKGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9taW5XaWR0aDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9taW5IZWlnaHQ7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0TWF4U2l6ZVNldHRpbmcoaG9yaXpvbnRhbCkge1xuICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21heFdpZHRoO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21heEhlaWdodDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRNYWluQXhpc01pblNpemUoKSB7XG4gICAgICAgIHJldHVybiBGbGV4VXRpbHMuZ2V0QXhpc01pblNpemUodGhpcy5pdGVtLCB0aGlzLmN0ci5faG9yaXpvbnRhbCk7XG4gICAgfVxuXG4gICAgX2dldENyb3NzQXhpc01pblNpemUoKSB7XG4gICAgICAgIHJldHVybiBGbGV4VXRpbHMuZ2V0QXhpc01pblNpemUodGhpcy5pdGVtLCAhdGhpcy5jdHIuX2hvcml6b250YWwpO1xuICAgIH1cblxuICAgIF9nZXRNYWluQ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gPSBmYWxzZTtcblxuICAgICAgICB0aGlzLl9pdGVtcyA9IG51bGw7XG4gICAgfVxuXG4gICAgZ2V0IGZsZXhMYXlvdXQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmZsZXggPyB0aGlzLmZsZXguX2xheW91dCA6IG51bGw7XG4gICAgfVxuXG4gICAgbGF5b3V0RmxleFRyZWUoKSB7XG4gICAgICAgIGlmICh0aGlzLmlzRmxleEVuYWJsZWQoKSAmJiB0aGlzLmlzQ2hhbmdlZCgpKSB7XG4gICAgICAgICAgICB0aGlzLmZsZXhMYXlvdXQubGF5b3V0VHJlZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHRhcmdldCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3RhcmdldDtcbiAgICB9XG5cbiAgICBnZXQgZmxleCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZsZXg7XG4gICAgfVxuXG4gICAgc2V0IGZsZXgodikge1xuICAgICAgICBpZiAoIXYpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzRmxleEVuYWJsZWQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVGbGV4KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZW5hYmxlRmxleCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fZmxleC5wYXRjaCh2KTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBmbGV4SXRlbSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX2ZsZXhJdGVtRGlzYWJsZWQpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9lbnN1cmVGbGV4SXRlbSgpO1xuICAgICAgICByZXR1cm4gdGhpcy5fZmxleEl0ZW07XG4gICAgfVxuXG4gICAgc2V0IGZsZXhJdGVtKHYpIHtcbiAgICAgICAgaWYgKHYgPT09IGZhbHNlKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX2ZsZXhJdGVtRGlzYWJsZWQpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBwYXJlbnQgPSB0aGlzLmZsZXhQYXJlbnQ7XG4gICAgICAgICAgICAgICAgdGhpcy5fZmxleEl0ZW1EaXNhYmxlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hlY2tFbmFibGVkKCk7XG4gICAgICAgICAgICAgICAgaWYgKHBhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICBwYXJlbnQuX2NsZWFyRmxleEl0ZW1zQ2FjaGUoKTtcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50LmNoYW5nZWRDb250ZW50cygpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX2Vuc3VyZUZsZXhJdGVtKCk7XG5cbiAgICAgICAgICAgIHRoaXMuX2ZsZXhJdGVtLnBhdGNoKHYpO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fZmxleEl0ZW1EaXNhYmxlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2ZsZXhJdGVtRGlzYWJsZWQgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGVja0VuYWJsZWQoKTtcbiAgICAgICAgICAgICAgICBjb25zdCBwYXJlbnQgPSB0aGlzLmZsZXhQYXJlbnQ7XG4gICAgICAgICAgICAgICAgaWYgKHBhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICBwYXJlbnQuX2NsZWFyRmxleEl0ZW1zQ2FjaGUoKTtcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50LmNoYW5nZWRDb250ZW50cygpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgI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W5BeGlzRGltZW5zaW9uc0NoYW5nZWRJbkNoaWxkID0gKGNoaWxkUmVjYWxjICYgbWFpbkF4aXNSZWNhbGNGbGFnKTtcbiAgICAgICAgICAgIGlmIChtYWluQXhpc0RpbWVuc2lvbnNDaGFuZ2VkSW5DaGlsZCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IG1haW5BeGlzSXNXcmFwcGluZyA9IGxheW91dC5pc1dyYXBwaW5nKCk7XG4gICAgICAgICAgICAgICAgaWYgKG1haW5BeGlzSXNXcmFwcGluZykge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBjcm9zc0F4aXNJc0ZpdFRvQ29udGVudHMgPSBsYXlvdXQuaXNDcm9zc0F4aXNGaXRUb0NvbnRlbnRzKCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjcm9zc0F4aXNJc0ZpdFRvQ29udGVudHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFNwZWNpYWwgY2FzZTogZHVlIHRvIHdyYXBwaW5nLCB0aGUgY3Jvc3MgYXhpcyBzaXplIG1heSBiZSBjaGFuZ2VkLlxuICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRSZWNhbGMgKz0gY3Jvc3NBeGlzUmVjYWxjRmxhZztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBpc1dpZHRoRHluYW1pYyA9IGxheW91dC5pc0F4aXNGaXRUb0NvbnRlbnRzKHRydWUpO1xuICAgICAgICBsZXQgaXNIZWlnaHREeW5hbWljID0gbGF5b3V0LmlzQXhpc0ZpdFRvQ29udGVudHMoZmFsc2UpO1xuXG4gICAgICAgIGlmIChsYXlvdXQuc2hydW5rKSB7XG4gICAgICAgICAgICAvLyBJZiBkdXJpbmcgcHJldmlvdXMgbGF5b3V0IHRoaXMgY29udGFpbmVyIHdhcyAnc2hydW5rJywgYW55IGNoYW5nZXMgbWF5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0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLlxuICovXG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIEZsZXhVdGlscyB7XG5cbiAgICBzdGF0aWMgZ2V0UGFyZW50QXhpc1NpemVXaXRoUGFkZGluZyhpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGNvbnN0IHRhcmdldCA9IGl0ZW0udGFyZ2V0O1xuICAgICAgICBjb25zdCBwYXJlbnQgPSB0YXJnZXQuZ2V0UGFyZW50KCk7XG4gICAgICAgIGlmICghcGFyZW50KSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnN0IGZsZXhQYXJlbnQgPSBpdGVtLmZsZXhQYXJlbnQ7XG4gICAgICAgICAgICBpZiAoZmxleFBhcmVudCkge1xuICAgICAgICAgICAgICAgIC8vIFVzZSBwZW5kaW5nIGxheW91dCBzaXplLlxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldEF4aXNMYXlvdXRTaXplKGZsZXhQYXJlbnQsIGhvcml6b250YWwpICsgdGhpcy5nZXRUb3RhbFBhZGRpbmcoZmxleFBhcmVudCwgaG9yaXpvbnRhbCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIFVzZSAnYWJzb2x1dGUnIHNpemUuXG4gICAgICAgICAgICAgICAgcmV0dXJuIGhvcml6b250YWwgPyBwYXJlbnQudyA6IHBhcmVudC5oO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFJlbEF4aXNTaXplKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgIGlmIChpdGVtLmZ1bmNXKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2FsbG93UmVsQXhpc1NpemVGdW5jdGlvbihpdGVtLCB0cnVlKSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS5mdW5jVyh0aGlzLmdldFBhcmVudEF4aXNTaXplV2l0aFBhZGRpbmcoaXRlbSwgdHJ1ZSkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0ub3JpZ2luYWxXaWR0aDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChpdGVtLmZ1bmNIKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2FsbG93UmVsQXhpc1NpemVGdW5jdGlvbihpdGVtLCBmYWxzZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0uZnVuY0godGhpcy5nZXRQYXJlbnRBeGlzU2l6ZVdpdGhQYWRkaW5nKGl0ZW0sIGZhbHNlKSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaXRlbS5vcmlnaW5hbEhlaWdodDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBfYWxsb3dSZWxBeGlzU2l6ZUZ1bmN0aW9uKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgY29uc3QgZmxleFBhcmVudCA9IGl0ZW0uZmxleFBhcmVudDtcbiAgICAgICAgaWYgKGZsZXhQYXJlbnQgJiYgZmxleFBhcmVudC5fZmxleC5fbGF5b3V0LmlzQXhpc0ZpdFRvQ29udGVudHMoaG9yaXpvbnRhbCkpIHtcbiAgICAgICAgICAgIC8vIFdlIGRvbid0IGFsbG93IHJlbGF0aXZlIHdpZHRoIG9uIGZpdC10by1jb250ZW50cyBiZWNhdXNlIGl0IGxlYWRzIHRvIGNvbmZsaWN0cy5cbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBzdGF0aWMgaXNaZXJvQXhpc1NpemUoaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgcmV0dXJuICFpdGVtLm9yaWdpbmFsV2lkdGggJiYgIWl0ZW0uZnVuY1c7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gIWl0ZW0ub3JpZ2luYWxIZWlnaHQgJiYgIWl0ZW0uZnVuY0g7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0QXhpc0xheW91dFBvcyhpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIHJldHVybiBob3Jpem9udGFsID8gaXRlbS54IDogaXRlbS55O1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXRBeGlzTGF5b3V0U2l6ZShpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIHJldHVybiBob3Jpem9udGFsID8gaXRlbS53IDogaXRlbS5oO1xuICAgIH1cblxuICAgIHN0YXRpYyBzZXRBeGlzTGF5b3V0UG9zKGl0ZW0sIGhvcml6b250YWwsIHBvcykge1xuICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgaXRlbS54ID0gcG9zO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaXRlbS55ID0gcG9zO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIHNldEF4aXNMYXlvdXRTaXplKGl0ZW0sIGhvcml6b250YWwsIHNpemUpIHtcbiAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgIGl0ZW0udyA9IHNpemU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpdGVtLmggPSBzaXplO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGdldEF4aXNNaW5TaXplKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgbGV0IG1pblNpemUgPSB0aGlzLmdldFBsYWluQXhpc01pblNpemUoaXRlbSwgaG9yaXpvbnRhbCk7XG5cbiAgICAgICAgbGV0IGZsZXhJdGVtTWluU2l6ZSA9IDA7XG4gICAgICAgIGlmIChpdGVtLmlzRmxleEl0ZW1FbmFibGVkKCkpIHtcbiAgICAgICAgICAgIGZsZXhJdGVtTWluU2l6ZSA9IGl0ZW0uX2ZsZXhJdGVtLl9nZXRNaW5TaXplU2V0dGluZyhob3Jpem9udGFsKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IGhhc0xpbWl0ZWRNaW5TaXplID0gKGZsZXhJdGVtTWluU2l6ZSA+IDApO1xuICAgICAgICBpZiAoaGFzTGltaXRlZE1pblNpemUpIHtcbiAgICAgICAgICAgIG1pblNpemUgPSBNYXRoLm1heChtaW5TaXplLCBmbGV4SXRlbU1pblNpemUpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBtaW5TaXplO1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXRQbGFpbkF4aXNNaW5TaXplKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKGl0ZW0uaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICByZXR1cm4gaXRlbS5fZmxleC5fbGF5b3V0LmdldEF4aXNNaW5TaXplKGhvcml6b250YWwpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3QgaXNTaHJpbmthYmxlID0gKGl0ZW0uZmxleEl0ZW0uc2hyaW5rICE9PSAwKTtcbiAgICAgICAgICAgIGlmIChpc1Nocmlua2FibGUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZ2V0UmVsQXhpc1NpemUoaXRlbSwgaG9yaXpvbnRhbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgcmVzaXplQXhpcyhpdGVtLCBob3Jpem9udGFsLCBzaXplKSB7XG4gICAgICAgIGlmIChpdGVtLmlzRmxleEVuYWJsZWQoKSkge1xuICAgICAgICAgICAgY29uc3QgaXNNYWluQXhpcyA9IChpdGVtLl9mbGV4Ll9ob3Jpem9udGFsID09PSBob3Jpem9udGFsKTtcbiAgICAgICAgICAgIGlmIChpc01haW5BeGlzKSB7XG4gICAgICAgICAgICAgICAgaXRlbS5fZmxleC5fbGF5b3V0LnJlc2l6ZU1haW5BeGlzKHNpemUpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpdGVtLl9mbGV4Ll9sYXlvdXQucmVzaXplQ3Jvc3NBeGlzKHNpemUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5zZXRBeGlzTGF5b3V0U2l6ZShpdGVtLCBob3Jpem9udGFsLCBzaXplKTtcbiAgICAgICAgfVxuICAgIH1cblxuXG4gICAgc3RhdGljIGdldFBhZGRpbmdPZmZzZXQoaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBpZiAoaXRlbS5pc0ZsZXhFbmFibGVkKCkpIHtcbiAgICAgICAgICAgIGNvbnN0IGZsZXggPSBpdGVtLl9mbGV4O1xuICAgICAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleC5wYWRkaW5nTGVmdDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZsZXgucGFkZGluZ1RvcDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFRvdGFsUGFkZGluZyhpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGlmIChpdGVtLmlzRmxleEVuYWJsZWQoKSkge1xuICAgICAgICAgICAgY29uc3QgZmxleCA9IGl0ZW0uX2ZsZXg7XG4gICAgICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4LnBhZGRpbmdSaWdodCArIGZsZXgucGFkZGluZ0xlZnQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4LnBhZGRpbmdUb3AgKyBmbGV4LnBhZGRpbmdCb3R0b207XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBnZXRNYXJnaW5PZmZzZXQoaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBjb25zdCBmbGV4SXRlbSA9IGl0ZW0uZmxleEl0ZW07XG4gICAgICAgIGlmIChmbGV4SXRlbSkge1xuICAgICAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleEl0ZW0ubWFyZ2luTGVmdDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZsZXhJdGVtLm1hcmdpblRvcDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFRvdGFsTWFyZ2luKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuICAgICAgICBpZiAoZmxleEl0ZW0p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luQXhpc01pblNpemUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9saW5lTGF5b3V0ZXIubWFpbkF4aXNNaW5TaXplO1xuICAgIH1cblxuICAgIF9nZXRDcm9zc0F4aXNNaW5TaXplKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbGluZUxheW91dGVyLmNyb3NzQXhpc01pblNpemU7XG4gICAgfVxuXG4gICAgcmVzaXplTWFpbkF4aXMoc2l6ZSkge1xuICAgICAgICBpZiAodGhpcy5tYWluQXhpc1NpemUgIT09IHNpemUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnJlY2FsYyA+IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLnBlcmZvcm1SZXNpemVNYWluQXhpcyhzaXplKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NoZWNrVmFsaWRDYWNoZU1haW5BeGlzUmVzaXplKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5tYWluQXhpc1NpemUgPSBzaXplO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9maXRDcm9zc0F4aXNTaXplVG9Db250ZW50cygpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIENhY2hlIG1pc3MuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuaXRlbS5lbmFibGVMb2NhbFJlY2FsY0ZsYWcoKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5wZXJmb3JtUmVzaXplTWFpbkF4aXMoc2l6ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2NoZWNrVmFsaWRDYWNoZU1haW5BeGlzUmVzaXplKHNpemUpIHtcbiAgICAgICAgY29uc3QgaXNGaW5hbE1haW5BeGlzU2l6ZSA9IChzaXplID09PSB0aGlzLnRhcmdldE1haW5BeGlzU2l6ZSk7XG4gICAg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0ZW1DYWNoZShpdGVtKSB7XG4gICAgICAgIGlmIChpdGVtLnJlY2FsYyA9PT0gMCkge1xuICAgICAgICAgICAgaWYgKGl0ZW0uaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbGF5b3V0ID0gaXRlbS5fZmxleC5fbGF5b3V0O1xuXG4gICAgICAgICAgICAgICAgY29uc3QgZGltZW5zaW9uc01hdGNoUHJldmlvdXNSZXN1bHQgPSAoaXRlbS53ID09PSBpdGVtLnRhcmdldC53ICYmIGl0ZW0uaCA9PT0gaXRlbS50YXJnZXQuaCk7XG4gICAgICAgICAgICAgICAgaWYgKGRpbWVuc2lvbnNNYXRjaFByZXZpb3VzUmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIENhY2hlIGlzIHZhbGlkLlxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBjcm9zc0F4aXNTaXplID0gbGF5b3V0LmNyb3NzQXhpc1NpemU7XG4gICAgICAgICAgICAgICAgICAgIGxheW91dC5wZXJmb3JtUmVzaXplTWFpbkF4aXMobGF5b3V0Lm1haW5BeGlzU2l6ZSk7XG4gICAgICAgICAgICAgICAgICAgIGxheW91dC5wZXJmb3JtUmVzaXplQ3Jvc3NBeGlzKGNyb3NzQXhpc1NpemUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgX2ZpbmFsaXplSXRlbUFuZENoaWxkcmVuKGl0ZW0pIHtcbiAgICAgICAgdGhpcy5fZmluYWxpemVJdGVtKGl0ZW0pO1xuICAgICAgICB0aGlzLl9maW5hbGl6ZUl0ZW1DaGlsZHJlbihpdGVtKTtcbiAgICB9XG5cbiAgICBfZmluYWxpemVJdGVtKGl0ZW0pIHtcbiA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baV07XG5cbiAgICAgICAgICAgIHRoaXMuX2xheW91dEZsZXhJdGVtKGl0ZW0pO1xuXG4gICAgICAgICAgICAvLyBHZXQgcHJlZGljdGVkIG1haW4gYXhpcyBzaXplLlxuICAgICAgICAgICAgY29uc3QgaXRlbU1haW5BeGlzU2l6ZSA9IGl0ZW0uZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZVdpdGhQYWRkaW5nQW5kTWFyZ2luKCk7XG5cbiAgICAgICAgICAgIGlmICh3cmFwICYmIChpID4gc3RhcnRJbmRleCkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBpc092ZXJmbG93aW5nID0gKHRoaXMuX2N1ck1haW5BeGlzUG9zICsgaXRlbU1haW5BeGlzU2l6ZSA+IHRoaXMuX21haW5BeGlzU2l6ZSk7XG4gICAgICAgICAgICAgICAgaWYgKGlzT3ZlcmZsb3dpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0TGluZShzdGFydEluZGV4LCBpIC0gMSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2N1ck1haW5BeGlzUG9zID0gMDtcbiAgICAgICAgICAgICAgICAgICAgc3RhcnRJbmRleCA9IGk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9hZGRUb01haW5BeGlzUG9zKGl0ZW1NYWluQXhpc1NpemUpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHN0YXJ0SW5kZXggPCBpKSB7XG4gICAgICAgICAgICB0aGlzLl9sYXlvdXRMaW5lKHN0YXJ0SW5kZXgsIGkgLSAxKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9sYXlvdXRGbGV4SXRlbShpdGVtKSB7XG4gICAgICAgIGlmIChpdGVtLmlzRmxleEVuYWJsZWQoKSkge1xuICAgICAgICAgICAgaXRlbS5mbGV4TGF5b3V0LnVwZGF0ZVRyZWVMYXlvdXQoKTtcbiA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dlZW4gPSAwO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcImNlbnRlclwiOlxuICAgICAgICAgICAgICAgIHNwYWNpbmdCZWZvcmUgPSByZW1haW5pbmdTcGFjZSAvIDI7XG4gICAgICAgICAgICAgICAgc3BhY2luZ0JldHdlZW4gPSAwO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcInNwYWNlLWJldHdlZW5cIjpcbiAgICAgICAgICAgICAgICBzcGFjaW5nQmVmb3JlID0gMDtcbiAgICAgICAgICAgICAgICBzcGFjaW5nQmV0d2VlbiA9IE1hdGgubWF4KDAsIHJlbWFpbmluZ1NwYWNlKSAvIGl0ZW1HYXBzO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcInNwYWNlLWFyb3VuZFwiOlxuICAgICAgICAgICAgICAgIGlmIChyZW1haW5pbmdTcGFjZSA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZ2V0U3BhY2luZyhcImNlbnRlclwiLCBudW1iZXJPZkl0ZW1zLCByZW1haW5pbmdTcGFjZSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgc3BhY2VQZXJHYXAgPSByZW1haW5pbmdTcGFjZSAvIChpdGVtR2FwcyArIDEpO1xuICAgICAgICAgICAgICAgICAgICBzcGFjaW5nQmVmb3JlID0gMC41ICogc3BhY2VQZXJHYXA7XG4gICAgICAgICAgICAgICAgICAgIHNwYWNpbmdCZXR3ZWVuID0gc3BhY2VQZXJHYXA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcInNwYWNlLWV2ZW5seVwiOlxuICAgICAgICAgICAgICAgIGlmIChyZW1haW5pbmdTcGFjZSA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZ2V0U3BhY2luZyhcImNlbnRlclwiLCBudW1iZXJPZkl0ZW1zLCByZW1haW5pbmdTcGFjZSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgc3BhY2VQZXJHYXAgPSByZW1haW5pbmdTcGFjZSAvIChpdGVtR2FwcyArIDIpO1xuICAgICAgICAgICAgICAgICAgICBzcGFjaW5nQmVmb3JlID0gc3BhY2VQZXJHYXA7XG4gICAgICAgICAgICAgICAgICAgIHNwYWNpbmdCZXR3ZWVuID0gc3BhY2VQZXJHYXA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcInN0cmV0Y2hcIjpcbiAgICAgICAgICAgICAgICBzcGFjaW5nQmVmb3JlID0gMDtcbiAgICAgICAgICAgICAgICBzcGFjaW5nQmV0d2VlbiA9IDA7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlVua25vd24gbW9kZTogXCIgKyBtb2RlKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB7c3BhY2luZ0JlZm9yZSwgc3BhY2luZ0JldHdlZW59XG4gICAgfVxuXG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXMgYXBwbHk6XG4gKlxuICogQ29weXJpZ2h0IDIwMjAgTWV0cm9sb2dpY2FsXG4gKlxuICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlIExpY2Vuc2UpO1xuICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQga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ICB9XG5cbiAgICBfc2hyaW5rSXRlbVNpemVzKGFtb3VudCkge1xuICAgICAgICBjb25zdCBzaHJpbmtlciA9IG5ldyBTaXplU2hyaW5rZXIodGhpcyk7XG4gICAgICAgIHNocmlua2VyLnNocmluayhhbW91bnQpO1xuICAgICAgICB0aGlzLl9hdmFpbGFibGVTcGFjZSArPSBzaHJpbmtlci5nZXRTaHJ1bmtTaXplKCk7XG4gICAgfVxuXG4gICAgc2V0SXRlbVBvc2l0aW9ucygpIHtcbiAgICAgICAgY29uc3QgcG9zaXRpb25lciA9IG5ldyBJdGVtUG9zaXRpb25lcih0aGlzKTtcbiAgICAgICAgcG9zaXRpb25lci5wb3NpdGlvbigpO1xuICAgIH1cblxuICAgIGNyZWF0ZUl0ZW1BbGlnbmVyKCkge1xuICAgICAgICByZXR1cm4gbmV3IEl0ZW1BbGlnbmVyKHRoaXMpO1xuICAgIH1cblxuICAgIF9jYWxjTGF5b3V0SW5mbygpIHtcbiAgICAgICAgdGhpcy5fY2FsY0Nyb3NzQXhpc01heExheW91dFNpemUoKTtcbiAgICB9XG5cbiAgICBnZXRNYWluQXhpc01pblNpemUoKSB7XG4gICAgICAgIGxldCBtYWluQXhpc01pblNpemUgPSAwO1xuICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5zdGFydEluZGV4OyBpIDw9IHRoaXMuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICAgICAgY29uc3QgaXRlbSA9IHRoaXMuaXRlbXNbaV07XG4gICAgICAgICAgICBtYWluQXhpc01pblNpemUgKz0gaXRlbS5mbGV4SXRlbS5fZ2V0TWFpbkF4aXNNaW5TaXplV2l0aFBhZGRpbmdBbmRNYXJnaW4oKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbWFpbkF4aXNNaW5TaXplO1xuICAgIH1cbiAgICBcbiAgICBnZXQgbnVtYmVyT2ZJdGVtcygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZW5kSW5kZXggLSB0aGlzLnN0YX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Rpb25zIHVuZGVyIHRoZSBMaWNlbnNlLlxuICovXG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIFNpemVHcm93ZXIge1xuXG4gICAgY29uc3RydWN0b3IobGluZSkge1xuICAgICAgICB0aGlzLl9saW5lID0gbGluZTtcbiAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nID0gMDtcbiAgICAgICAgdGhpcy5fZ3Jvd25TaXplID0gMDtcbiAgICB9XG5cbiAgICBncm93KGFtb3VudCkge1xuICAgICAgICB0aGlzLl9ncm93blNpemUgPSAwO1xuXG4gICAgICAgIHRoaXMuX2Ftb3VudFJlbWFpbmluZyA9IGFtb3VudDtcbiAgICAgICAgbGV0IHRvdGFsR3Jvd0Ftb3VudCA9IHRoaXMuX2dldFRvdGFsR3Jvd0Ftb3VudCgpO1xuICAgICAgICBpZiAodG90YWxHcm93QW1vdW50KSB7XG4gICAgICAgICAgICBjb25zdCBpdGVtcyA9IHRoaXMuX2xpbmUuaXRlbXM7XG4gICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgbGV0IGFtb3VudFBlckdyb3cgPSB0aGlzLl9hbW91bnRSZW1haW5pbmcgLyB0b3RhbEdyb3dBbW91bnQ7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuX2xpbmUuc3RhcnRJbmRleDsgaSA8PSB0aGlzLl9saW5lLmVuZEluZGV4OyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGl0ZW1zW2ldO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBmbGV4SXRlbSA9IGl0ZW0uZmxleEl0ZW07XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGdyb3dBbW91bnQgPSBmbGV4SXRlbS5ncm93O1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0dyb3dhYmxlSXRlbSA9IChncm93QW1vdW50ID4gMCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc0dyb3dhYmxlSXRlbSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGdyb3cgPSBncm93QW1vdW50ICogYW1vdW50UGVyR3JvdztcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1heFNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNNYXhTaXplU2V0dGluZygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhTaXplID4gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaXplID49IG1heFNpemUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQWxyZWFkeSBmdWxseSBncm93bi5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdyA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF4R3JvdyA9IG1heFNpemUgLSBzaXplO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0Z1bGx5R3Jvd24gPSAoZ3JvdyA+PSBtYXhHcm93KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzRnVsbHlHcm93bikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdyA9IG1heEdyb3c7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIERlc3RyaWJ1dGUgcmVtYWluaW5nIGFtb3VudCBvdmVyIHRoZSBvdGhlciBmbGV4IGl0ZW1zLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxHcm93QW1vdW50IC09IGdyb3dBbW91bnQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm93ID4gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbmFsU2l6ZSA9IHNpemUgKyBncm93O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsZXhJdGVtLl9yZXNpemVNYWluQXhpcyhmaW5hbFNpemUpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ3Jvd25TaXplICs9IGdyb3c7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nIC09IGdyb3c7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnModGhpcy5fYW1vdW50UmVtYWluaW5nKSA8IDEwZS02KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IHdoaWxlKHRvdGFsR3Jvd0Ftb3VudCAmJiAoTWF0aC5hYnModGhpcy5fYW1vdW50UmVtYWluaW5nKSA+IDEwZS02KSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0VG90YWxHcm93QW1vdW50KCkge1xuICAgICAgICBsZXQgdG90YWwgPSAwO1xuICAgICAgICBjb25zdCBpdGVtcyA9IHRoaXMuX2xpbmUuaXRlbXM7XG4gICAgICAgIGZvciAobGV0IGkgPSB0aGlzLl9saW5lLnN0YXJ0SW5kZXg7IGkgPD0gdGhpcy5fbGluZS5lbmRJbmRleDsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07XG4gICAgICAgICAgICBjb25zdCBmbGV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ICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICBsZXQgYW1vdW50UGVyU2hyaW5rID0gdGhpcy5fYW1vdW50UmVtYWluaW5nIC8gdG90YWxTaHJpbmtBbW91bnQ7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuX2xpbmUuc3RhcnRJbmRleDsgaSA8PSB0aGlzLl9saW5lLmVuZEluZGV4OyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGl0ZW1zW2ldO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBmbGV4SXRlbSA9IGl0ZW0uZmxleEl0ZW07XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHNocmlua0Ftb3VudCA9IGZsZXhJdGVtLnNocmluaztcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNTaHJpbmthYmxlSXRlbSA9IChzaHJpbmtBbW91bnQgPiAwKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzU2hyaW5rYWJsZUl0ZW0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzaHJpbmsgPSBzaHJpbmtBbW91bnQgKiBhbW91bnRQZXJTaHJpbms7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtaW5TaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWluU2l6ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaXplID4gbWluU2l6ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1heFNocmluayA9IHNpemUgLSBtaW5TaXplO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRnVsbHlTaHJ1bmsgPSAoc2hyaW5rID49IG1heFNocmluayk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzRnVsbHlTaHJ1bmspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hyaW5rID0gbWF4U2hyaW5rO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIERlc3RyaWJ1dGUgcmVtYWluaW5nIGFtb3VudCBvdmVyIHRoZSBvdGhlciBmbGV4IGl0ZW1zLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbFNocmlua0Ftb3VudCAtPSBzaHJpbmtBbW91bnQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmluYWxTaXplID0gc2l6ZSAtIHNocmluaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbGV4SXRlbS5fcmVzaXplTWFpbkF4aXMoZmluYWxTaXplKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NocnVua1NpemUgKz0gc2hyaW5rO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Ftb3VudFJlbWFpbmluZyAtPSBzaHJpbms7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnModGhpcy5fYW1vdW50UmVtYWluaW5nKSA8IDEwZS02KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IHdoaWxlKHRvdGFsU2hyaW5rQW1vdW50ICYmIChNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpID4gMTBlLTYpKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRUb3RhbFNocmlua0Ftb3VudCgpIHtcbiAgICAgICAgbGV0IHRvdGFsID0gMDtcbiAgICAgICAgY29uc3QgaXRlbXMgPSB0aGlzLl9saW5lLml0ZW1zO1xuICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICAgICAgY29uc3QgaXRlbSA9IGl0ZW1zW2ldO1xuICAgICAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuXG4gICAgICAgICAgICBpZiAoZmxleEl0ZW0uc2hyaW5rKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbWluU2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc01pblNpemUoKTtcbiAgICAgICAgICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuXG4gICAgICAgICAgICAgICAgLy8gRXhjbHVkZSB0aG9zZSBhbHJlYWR5IGZ1bGx5IHNocnVuay5cbiAgICAgICAgICAgICAgICBpZiAoc2l6ZSA+IG1pblNpemUpIHtcbiAgICAgICAgICAgICAgICAgICAgdG90YWwgKz0gZmxleEl0ZW0uc2hyaW5rO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdG90YWw7XG4gICAgfVxuXG4gICAgZ2V0U2hydW5rU2l6ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NocnVua1NpemU7XG4gICAgfVxuXG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXMgYXBwbHk6XG4gKlxuICogQ29weXJpZ2h0IDIwMjMgTWV0cm9sb2dpY2FsXG4gKlxuICogTGljZW5zZWQgdW5kZXIgd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IHRoaXMuX3dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTogJ2NvbmZpZycsIGNvbmZpZzoge3BhdGg6IHdpbmRvdy5sb2NhdGlvbi5ocmVmLCBwcm90b2NvbDogd2luZG93LmxvY2F0aW9uLnByb3RvY29sfX0pO1xuXG4gICAgICAgIHRoaXMuX3dvcmtlci5vbm1lc3NhZ2UgPSAoZSkgPT4ge1xuICAgICAgICAgICAgaWYgKGUuZGF0YSAmJiBlLmRhdGEuaWQpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGUuZGF0YS5pZDtcbiAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gdGhpcy5faXRlbXMuZ2V0KGlkKTtcbiAgICAgICAgICAgICAgICBpZiAoaXRlbSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZS5kYXRhLnR5cGUgPT0gJ2RhdGEnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbmlzaChpdGVtLCBlLmRhdGEuaW5mbyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVycm9yKGl0ZW0sIGUuZGF0YS5pbmZvKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGNyZWF0ZShzcmMpIHtcbiAgICAgICAgY29uc3QgaWQgPSArK3RoaXMuX2lkO1xuICAgICAgICBjb25zdCBpdGVtID0gbmV3IEltYWdlV29ya2VySW1hZ2UodGhpcywgaWQsIHNyYyk7XG4gICAgICAgIHRoaXMuX2l0ZW1zLnNldChpZCwgaXRlbSk7XG4gICAgICAgIHRoaXMuX3dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTogXCJhZGRcIiwgaWQ6IGlkLCBzcmM6IHNyY30pO1xuICAgICAgICByZXR1cm4gaXRlbTtcbiAgICB9XG5cbiAgICBjYW5j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4c3BlY192MS5odG1sXG4gICAgICoqL1xuICAgIGhhbmRsZUt0eExvYWQoY2IsIHNyYykge1xuICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgYXJyYXlidWZmZXIgPSB0aGlzLnJlc3BvbnNlO1xuICAgICAgICAgICAgdmFyIHZpZXcgPSBuZXcgRGF0YVZpZXcoYXJyYXlidWZmZXIpO1xuXG4gICAgICAgICAgICAvLyBpZGVudGlmaWVyLCBiaWcgZW5kaWFuXG4gICAgICAgICAgICB2YXIgdGFyZ2V0SWRlbnRpZmllciA9IDM2MzI3MDE0NjlcbiAgICAgICAgICAgIGlmICh0YXJnZXRJZGVudGlmaWVyICE9PSAodmlldy5nZXRVaW50MzIoMCkgKyB2aWV3LmdldFVpbnQzMig0KSArIHZpZXcuZ2V0VWludDMyKDgpKSkge1xuICAgICAgICAgICAgICAgIGNiKCdQYXJzaW5nIGZhaWxlZDogaWRlbnRpZmllciBrdHggbWlzbWF0Y2g6Jywgc3JjKVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgbGl0dGxlRW5kaWFuID0gKHZpZXcuZ2V0VWludDMyKDEyKSA9PT0gMTY5MDkwNjApID8gdHJ1ZSA6IGZhbHNlO1xuICAgICAgICAgICAgdmFyIGRhdGEgPSB7XG4gICAgICAgICAgICAgICAgZ2xUeXBlOiB2aWV3LmdldFVpbnQzMigxNiwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBnbFR5cGVTaXplOiB2aWV3LmdldFVpbnQzMigyMCwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBnbEZvcm1hdDogdmlldy5nZXRVaW50MzIoMjQsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgZ2xJbnRlcm5hbEZvcm1hdDogdmlldy5nZXRVaW50MzIoMjgsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgZ2xCYXNlSW50ZXJuYWxGb3JtYXQ6IHZpZXcuZ2V0VWludDMyKDMyLCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIHBpeGVsV2lkdGg6IHZpZXcuZ2V0VWludDMyKDM2LCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIHBpeGVsSGVpZ2h0OiB2aWV3LmdldFVpbnQzMig0MCwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBwaXhlbERlcHRoOiB2aWV3LmdldFVpbnQzMig0NCwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBudW1iZXJPZkFycmF5RWxlbWVudHM6IHZpZXcuZ2V0VWludDMyKDQ4LCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIG51bWJlck9mRmFjZXM6IHZpZXcuZ2V0VWludDMyKDUyLCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIG51bWJlck9mTWlwbWFwTGV2ZWxzOiB2aWV3LmdldFVpbnQzMig1NiwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBieXRlc09mS2V5VmFsdWVEYXRhOiB2aWV3LmdldFVpbnQzMig2MCwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBrdnBzOiBbXSxcbiAgICAgICAgICAgICAgICBtaXBtYXBzOiBbXSxcbiAgICAgICAgICAgICAgICBnZXQgd2lkdGgoKSB7IHJldHVybiB0aGlzLnBpeGVsV2lkdGggfSxcbiAgICAgICAgICAgICAgICBnZXQgaGVpZ2h0KCkgeyByZXR1cm4gdGhpcy5waXhlbEhlaWdodCB9LFxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgY29uc3QgcHJvcHMgPSAob2JqKSA9PiB7XG4gICAgICAgICAgICAgICAgY29uc3QgcCA9IFtdO1xuICAgICAgICAgICAgICAgIGZvciAobGV0IHYgaW4gb2JqKSB7XG4gICAgIC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odmFyIGkgPSAwOyBpIDwgZGF0YS5udW1iZXJPZk1pcG1hcExldmVsczsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdmFyIGltYWdlU2l6ZSA9IHZpZXcuZ2V0VWludDMyKG9mZnNldCk7XG4gICAgICAgICAgICAgICAgb2Zmc2V0ICs9IDQ7XG4gICAgICAgICAgICAgICAgZGF0YS5taXBtYXBzLnB1c2godmlldy5idWZmZXIuc2xpY2Uob2Zmc2V0LCBpbWFnZVNpemUpKTtcbiAgICAgICAgICAgICAgICBvZmZzZXQgKz0gaW1hZ2VTaXplXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgICAgICBzb3VyY2U6IGRhdGEsXG4gICAgICAgICAgICAgICAgcmVuZGVySW5mbzogeyBzcmM6IHNyYywgY29tcHJlc3NlZDogdHJ1ZSB9LFxuICAgICAgICAgICAgfSlcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGhhbmRsZVB2ckxvYWQoY2IsIHNyYykge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgLy8gcHZyIGhlYWRlciBsZW5ndGggaW4gMzIgYml0c1xuICAgICAgICAgICAgY29uc3QgcHZySGVhZGVyTGVuZ3RoID0gMTM7XG4gICAgICAgICAgICAvLyBmb3Igbm93IG9ubHkgd2Ugb25seSBzdXBwb3J0OiBDT01QUkVTU0VEX1JHQl9FVEMxX1dFQkdMXG4gICAgICAgICAgICBjb25zdCBwdnJGb3JtYXRFdGMxID0gMHg4RDY0O1xuICAgICAgICAgICAgY29uc3QgcHZyV2lkdGggPSA3O1xuICAgICAgICAgICAgY29uc3QgcHZySGVpZ2h0ID0gNjtcbiAgICAgICAgICAgIGNvbnN0IHB2ck1pcG1hcENvdW50ID0gMTE7XG4gICAgICAgICAgICBjb25zdCBwdnJNZXRhZGF0YSA9IDEyO1xuICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB0aG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c3QoKTtcbiAgICAgICAgICAgIHJlcXVlc3QuYWRkRXZlbnRMaXN0ZW5lcihcbiAgICAgICAgICAgICAgICBcImxvYWRcIiwgaXNLdHggPyB0aGlzLmhhbmRsZUt0eExvYWQoY2IsIHNyYykgOiB0aGlzLmhhbmRsZVB2ckxvYWQoY2IsIHNyYylcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICByZXF1ZXN0Lm9wZW4oXCJHRVRcIiwgc3JjKTtcbiAgICAgICAgICAgIHJlcXVlc3QucmVzcG9uc2VUeXBlID0gXCJhcnJheWJ1ZmZlclwiO1xuICAgICAgICAgICAgcmVxdWVzdC5zZW5kKCk7XG4gICAgICAgICAgICBjYW5jZWxDYiA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICByZXF1ZXN0LmFib3J0KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5faW1hZ2VXb3JrZXIpIHtcbiAgICAgICAgICAgIC8vIFdQRS1zcGVjaWZpYyBpbWFnZSBwYXJzZXIuXG4gICAgICAgICAgICBjb25zdCBpbWFnZSA9IHRoaXMuX2ltYWdlV29ya2VyLmNyZWF0ZShzcmMpO1xuICAgICAgICAgICAgaW1hZ2Uub25FcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY2IoXCJJbWFnZSBsb2FkIGVycm9yXCIpO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGltYWdlLm9uTG9hZCA9IGZ1bmN0aW9uICh7IGltYWdlQml0bWFwLCBoYXNBbHBoYUNoYW5uZWwgfSkge1xuICAgICAgICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgICAgICAgICAgc291cmNlOiBpbWFnZUJpdG1hcCxcbiAgICAgICAgICAgICAgICAgICAgcmVuZGVySW5mbzogeyBzcmM6IHNyYywgY29tcHJlc3NlZDogZmFsc2UgfSxcbiAgICAgICAgICAgICAgICAgICAgaGFzQWxwaGE6IGhhc0FscGhhQ2hhbm5lbCxcbiAgICAgICAgICAgICAgICAgICAgcHJlbXVsdGlwbHlBbHBoYTogdHJ1ZVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGNhbmNlbENiID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGltYWdlLmNhbmNlbCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbGV0IGltYWdlID0gbmV3IEltYWdlKCk7XG5cbiAgICAgICAgICAgIC8vIE9uIHRoZSBQUzQgcGxhdGZvcm0gc2V0dGluZyB0aGUgYGNyb3NzT3JpZ2luYCBhdHRyaWJ1dGUgb25cbiAgICAgICAgICAgIC8vIGltYWdlcyBjYW4gY2F1c2UgQ09SUyBmYWlsdXJlcy5cbiAgICAgICAgICAgIGlmICghKHNyYy5zdWJzdHIoMCwgNSkgPT0gXCJkYXRhOlwiKSAmJiAhVXRpbHMuaXNQUzQpIHtcbiAgICAgICAgICAgICAgICAvLyBCYXNlNjQuXG4gICAgICAgICAgICAgICAgaW1hZ2UuY3Jvc3NPcmlnaW4gPSBcIkFub255bW91c1wiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaW1hZ2Uub25lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICAvLyBJZ25vcmUgZXJyb3IgbWVzc2FnZSB3aGVuIGNhbmNlbGxlZC5cbiAgICAgICAgICAgICAgICBpZiAoaW1hZ2Uuc3JjKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBjYihcIkltYWdlIGxvYWQgZXJyb3JcIik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGltYWdlLm9ubG9hZCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBjYihudWxsLCB7XG4gICAgICAgICAgICAgICAgICAgIHNvdXJjZTogaW1hZ2UsXG4gICAgICAgICAgICAgICAgICAgIHJlbmRlckluZm86IHsgc3JjOiBzcmMsIGNvbXByZXNzZWQ6IGZhbHNlIH0sXG4gICAgICAgICAgICAgICAgICAgIGhhc0FscGhhOiBpc1BuZyB8fCBoYXNBbHBoYVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGltYWdlLnNyYyA9IHNyYztcblxuICAgICAgICAgICAgY2FuY2VsQ2IgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaW1hZ2Uub25lcnJvciA9IG51bGw7XG4gICAgICAgICAgICAgICAgaW1hZ2Uub25sb2FkID0gbnVsbDtcbiAgICAgICAgICAgICAgICBpbWFnZS5yZW1vdmVBdHRyaWJ1dGUoJ3NyYycpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGNhbmNlbENiO1xuICAgIH1cblxuICAgIGNyZWF0ZVdlYkdMQ29udGV4dCh3LCBoKSB7XG4gICAgICAgIGxldCBjYW52YXMgPSB0aGlzLnN0YWdlLmdldE9wdGlvbignY2FudmFzJykgfHwgZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnY2FudmFzJyk7XG5cbiAgICAgICAgaWYgKHcgJiYgaCkge1xuICAgICAgICAgICAgY2FudmFzLndpZHRoID0gdztcbiAgICAgICAgICAgIGNhbnZhcy5oZWlnaHQgPSBoO1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IG9wdHMgPSB7XG4gICAgICAgICAgICBhbHBoYTogdHJ1ZSxcbiAgICAgICAgICAgIGFudGlhbGlhczogZmFsc2UsXG4gICAgICAgICAgICBwcmVtdWx0aXBsaWVkQWxwaGE6IHRydWUsXG4gICAgICAgICAgICBzdGVuY2lsOiB0cnVlLFxuICAgICAgICAgICAgcHJlc2VydmVEcmF3aW5nQnVmZmVyOiBmYWxzZVxuICAgICAgICB9O1xuXG4gICAgICAgIGxldCB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AgaXRlbS5sZiA9IGZyYW1lO1xuXG4gICAgICAgIGlmIChpdGVtLnR4KSB7XG4gICAgICAgICAgICBpZiAobmF0aXZlVGV4dHVyZS51cGRhdGUgPiBpdGVtLnUpIHtcbiAgICAgICAgICAgICAgICAvLyBOYXRpdmUgdGV4dHVyZSB3YXMgdXBkYXRlZCBpbiB0aGUgbWVhbiB0aW1lOiByZW5ldy5cbiAgICAgICAgICAgICAgICB0aGlzLl90aW50VGV4dHVyZShpdGVtLnR4LCBuYXRpdmVUZXh0dXJlLCBjb2xvcilcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIGl0ZW0udHg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBiZWZvcmUgPSBjYWNoZS5tZW1vcnlVc2FnZTtcblxuICAgICAgICAgICAgLy8gRmluZCBibGFuY28gdGludCB0ZXh0dXJlLlxuICAgICAgICAgICAgbGV0IHRhcmdldCA9IGNhY2hlLnJldXNlVGV4dHVyZShmcmFtZSk7XG4gICAgICAgICAgICBpZiAodGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgdGFyZ2V0LmN0eC5jbGVhclJlY3QoMCwgMCwgdGFyZ2V0LndpZHRoLCB0YXJnZXQuaGVpZ2h0KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gQWxsb2NhdGUgbmV3LlxuICAgICAgICAgICAgICAgIHRhcmdldCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2NhbnZhcycpO1xuICAgICAgICAgICAgICAgIHRhcmdldC53aWR0aCA9IG5hdGl2ZVRleHR1cmUudztcbiAgICAgICAgICAgICAgICB0YXJnZXQuaGVpZ2h0ID0gbmF0aXZlVGV4dHVyZS5oO1xuICAgICAgICAgICAgICAgIHRhcmdldC5jdHggPSB0YXJnZXQuZ2V0Q29udGV4dCgnMmQnKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5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gICAgICAgICAgdGhpcy5fY29sb3JzLmZvckVhY2goKGl0ZW0sIGNvbG9yKSA9PiB7XG4gICAgICAgICAgICAgICAgLy8gQ2xlYW4gdXAgZW50cmllcyB0aGF0IHdlcmUgbm90IHVzZWQgbGFzdCBmcmFtZS5cbiAgICAgICAgICAgICAgICBpZiAoaXRlbS5sZiA8IGZyYW1lIC0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS50eCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gS2VlcCBhcyByZXVzYWJsZSBibGFuY28gdGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2JsYW5jb1RleHR1cmVzLnB1c2goaXRlbS50eCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29sb3JzLmRlbGV0ZShjb2xvcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHRoaXMuX2xhc3RDbGVhbnVwRnJhbWUgPSBmcmFtZTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJldXNlVGV4dHVyZShmcmFtZSkge1xuICAgICAgICAvLyBUcnkgdG8gcmV1c2UgdGV4dHVyZXMsIGJlY2F1c2UgY3JlYXRpbmcgdGhlbSBldmVyeSBmcmFtZSBpcyBleHBlbnNpdmUuXG4gICAgICAgIHRoaXMuY2xlYW51cChmcmFtZSk7XG4gICAgICAgIGlmICh0aGlzLl9ibGFuY29UZXh0dXJlcyAmJiB0aGlzLl9ibGFuY29UZXh0dXJlcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHRoaXMuX21lbVRleHR1cmVzLS07XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fYmxhbmNvVGV4dHVyZXMucG9wKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbn1cblxuIiwiLypcbiAqIElmIG5vdCBzdGF0ZWQgb3RoZXJ3aXNlIGluIHRoaXMg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luZGV4OiBpLCByZWN0fTtcblxuICAgICAgICAgICAgaWYgKHJlY3QpIHtcbiAgICAgICAgICAgICAgICAvLyBDaGVjayBmb3IgZ3JhZGllbnQuXG4gICAgICAgICAgICAgICAgaWYgKHdoaXRlKSB7XG4gICAgICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSAnd2hpdGUnO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldENvbG9yR3JhZGllbnQoY3R4LCB2Yyk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgY3R4Lmdsb2JhbEFscGhhID0gcmMuYWxwaGE7XG4gICAgICAgICAgICAgICAgdGhpcy5fYmVmb3JlRHJhd0VsKGluZm8pO1xuICAgICAgICAgICAgICAgIGN0eC5maWxsUmVjdCgwLCAwLCB2Yy53LCB2Yy5oKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9hZnRlckRyYXdFbChpbmZvKTtcbiAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQWxwaGEgPSAxLjA7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIEB0b2RvOiBzZXQgaW1hZ2Ugc21vb3RoaW5nIGJhc2VkIG9uIHRoZSB0ZXh0dXJlLlxuXG4gICAgICAgICAgICAgICAgLy8gQHRvZG86IG9wdGltaXplIGJ5IHJlZ2lzdGVyaW5nIHdoZXRoZXIgaWRlbnRpdHkgdGV4Y29vcmRzIGFyZSB1c2VkLlxuICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHJjLmFscGhhO1xuICAgICAgICAgICAgICAgIHRoaXMuX2JlZm9yZURyYXdFbChpbmZvKTtcblxuICAgICAgICAgICAgICAgIC8vIEB0b2RvOiB0ZXN0IGlmIHJvdW5kaW5nIHlpZWxkcyBiZXR0ZXIgcGVyZm9ybWFuY2UuXG5cbiAgICAgICAgICAgICAgICAvLyBOb3RpY2UgdGhhdCBzaW1wbGUgdGV4dHVyZSBjb29yZHMgY2FuIGJlIHR1cm5lZCBvbiBldmVuIHRob3VnaCB2Yy5fdWx4IGV0YyBhcmUgbm90IHNpbXBsZSwgYmVjYXVzZVxuICAgICAgICAgICAgICAgIC8vICB3ZSBhcmUgcmVuZGVyaW5nIGEgcmVuZGVyLXRvLXRleHR1cmUgKHRleGNvb3JkcyB3ZXJlIHN0YXNoZWQpLiBTYW1lIGlzIHRydWUgZm9yICd3aGl0ZScgY29sb3IgYnR3LlxuICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZVggPSBzdGMgPyAwIDogKHZjLl91bHggKiB0eC53KTtcbiAgICAgICAgICAgICAgICBjb25zdCBzb3VyY2VZID0gc3RjID8gMCA6ICh2Yy5fdWx5ICogdHguaCk7XG4gICAgICAgICAgICAgICAgY29uc3Qgc291cmNlVyA9IChzdGMgPyAxIDogKHZjLl9icnggLSB2Yy5fdWx4KSkgKiB0eC53O1xuICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZUggPSAoc3RjID8gMSA6ICh2Yy5fYnJ5IC0gdmMuX3VseSkpICogdHguaDtcblxuICAgICAgICAgICAgICAgIGxldCBjb2xvcml6ZSA9ICF3aGl0ZTtcbiAgICAgICAgICAgICAgICBpZiAoY29sb3JpemUpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQHRvZG86IGNhY2hlIHRoZSB0aW50IHRleHR1cmUgZm9yIGJldHRlciBwZXJmb3JtYW5jZS5cblxuICAgICAgICAgICAgICAgICAgICAvLyBEcmF3IHRvIGludGVybWVkaWF0ZSB0ZXh0dXJlIHdpdGggYmFja2dyb3VuZCBjb2xvci9ncmFkaWVudC5cbiAgICAgICAgICAgICAgICAgICAgLy8gVGhpcyBwcmV2ZW50cyB1cyBmcm9tIGhhdmluZyB0byBjcmVhdGUgYSBsb3Qgb2YgcmVuZGVyIHRleHR1cmUgY2FudmFzZXMuXG5cbiAgICAgICAgICAgICAgICAgICAgLy8gTm90aWNlIHRoYXQgd2UgZG9uJ3Qgc3VwcG9ydCAobm9uLXJlY3QpIGdyYWRpZW50cywgb25seSBjb2xvciB0aW50aW5nIGZvciBjMmQuIFdlJ2xsIGp1c3QgdGFrZSB0aGUgYXZlcmFnZSBjb2xvci5cbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvbG9yID0gdmMuX2NvbG9yVWw7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2Yy5fY29sb3JVbCAhPT0gdmMuX2NvbG9yVXIgfHwgdmMuX2NvbG9yVXIgIT09IHZjLl9jb2xvckJsIHx8IHZjLl9jb2xvckJyICE9PSB2Yy5fY29sb3JCbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IgPSBTdGFnZVV0aWxzLm1lcmdlTXVsdGlDb2xvcnNFcXVhbChbdmMuX2NvbG9yVWwsIHZjLl9jb2xvclVyLCB2Yy5fY29sb3JCbCwgdmMuX2NvbG9yQnJdKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gKChjb2xvciAvIDE2Nzc3MjE2KSB8IDApIC8gMjU1LjA7XG4gICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSAqPSBhbHBoYTtcblxuICAgICAgICAgICAgICAgICAgICBjb25zdCByZ2IgPSBjb2xvciAmIDB4MDBGRkZGRkY7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHRpbnRUZXh0dXJlID0gdGhpcy5fdGludE1hbmFnZXIuZ2V0VGludFRleHR1cmUodHgsIHJnYik7XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gQWN0dWFsbHkgZHJhdyByZXN1bHQuXG4gICAgICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSAnd2hpdGUnO1xuICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKHRpbnRUZXh0dXJlLCBzb3VyY2VYLCBzb3VyY2VZLCBzb3VyY2VXLCBzb3VyY2VILCAwLCAwLCB2Yy53LCB2Yy5oKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gJ3doaXRlJztcbiAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZSh0eCwgc291cmNlWCwgc291cmNlWSwgc291cmNlVywgc291cmNlSCwgMCwgMCwgdmMudywgdmMuaCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX2FmdGVyRHJhd0VsKGluZm8pO1xuICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IDEuMDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9zZXRDb2xvckdyYWRpZW50KGN0eCwgdmMsIHcgPSB2Yy53LCBoID0gdmMuaCwgdHJhbnNwYXJlbmN5ID0gdHJ1ZSkge1xuICAgICAgICBsZXQgY29sb3IgPSB2Yy5fY29sb3JVbDtcbiAgICAgICAgbGV0IGdyYWRpZW50O1xuICAgICAgICAvL0B0b2RvOiBxdWljayBzaW5nbGUgY29sb3IgY2hlY2suXG4gICAgICAgIC8vQHRvZG86IGNhY2hlIGdyYWRpZW50L2ZpbGwgc3R5bGUgKGlmIHBvc3NpYmxlLCBwcm9iYWJseSBjb250ZXh0LXNwZWNpZmljKS5cblxuICAgICAgICBpZiAodmMuX2NvbG9yVWwgPT09IHZjLl9jb2xvclVyKSB7XG4gICAgICAgICAgICBpZiAodmMuX2NvbG9yQmwgPT09IHZjLl9jb2xvckJyKSB7XG4gICAgICAgICAgICAgICAgaWYgKHZjLl9jb2xvclVsID09PSB2Yy5jb2xvckJsKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFNpbmdsZSBjb2xvci5cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBWZXJ0aWNhbCBncmFkaWVudC5cbiAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQgPSBjdHguY3JlYXRlTGluZWFyR3JhZGllbnQoMCwgMCwgMCwgaCk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc3BhcmVuY3kpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LmFkZENvbG9yU3RvcCgwLCBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodmMuX2NvbG9yVWwpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LmFkZENvbG9yU3RvcCgxLCBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodmMuX2NvbG9yQmwpKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LmFkZENvbG9yU3RvcCgwLCBTdGFnZVV0aWxzLmdldFJnYlN0cmluZyh2Yy5fY29sb3JVbCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuYWRkQ29sb3JTdG9wKDEsIFN0YWdlVXRpbHMuZ2V0UmdiU3RyaW5nKHZjLl9jb2xvckJsKSk7XG5cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gTm90IHN1cHBvcnRlZCBncmFkaWVudC5cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh2Yy5fY29sb3JVbCA9PT0gdmMuX2NvbG9yQmwgJiYgdmMuX2NvbG9yVXIgPT09IHZjLl9jb2xvckJyKSB7XG4gICAgICAgICAgICAgICAgLy8gSG9yaXpvbnRhbCBncmFkaWVudC5cbiAgICAgICAgICAgICAgICBncmFkaWVudCA9IGN0eC5jcmVhdGVMaW5lYXJHcmFkaWVudCgwLCAwLCB3LCAwKTtcbiAgICAgICAgICAgICAgICBpZiAodHJhbnNwYXJlbmN5KSB7XG4gIC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aSA+IDApID8gKGkgLSAxKSA6IGk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcmVjaXNpb24gPSB0aGlzLmN0eC5zdGFnZS5nZXRPcHRpb24oJ3ByZWNpc2lvbicpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHZjID0gb3BlcmF0aW9uLmdldEVsZW1lbnRDb3JlKGVsZW1lbnRQb3N0aW9uKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0YWdlLnBsYXRmb3JtLnBhaW50KGdsLCBnbFRleHR1cmUub3B0aW9ucy5pbWFnZVJlZiwgdmMuX3dvcmxkQ29udGV4dC5weCpwcmVjaXNpb24sIHZjLl93b3JsZENvbnRleHQucHkqcHJlY2lzaW9uLCB2Yy5fY29sb3JVbCwgdmMpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgZ2wuYmluZFRleHR1cmUoZ2wuVEVYVFVSRV8yRCwgZ2xUZXh0dXJlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdsLmRyYXdFbGVtZW50cyhnbC5UUklBTkdMRVMsIDYgKiAoaSAtIHBvcyksIGdsLlVOU0lHTkVEX1NIT1JULCAocG9zICsgb3BlcmF0aW9uLmluZGV4KSAqIDYgKiAyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBnbFRleHR1cmUgPSB0eDtcbiAgICAgICAgICAgICAgICAgICAgcG9zID0gaTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocG9zIDwgbGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaWYgKGdsVGV4dHVyZS5vcHRpb25zICYmIGdsVGV4dHVyZS5vcHRpb25zLmltYWdlUmVmKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZWNpc2lvbiA9IHRoaXMuY3R4LnN0YWdlLmdldE9wdGl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yXSAqIGdsQ2xlYXJDb2xvclszXSwgZ2xDbGVhckNvbG9yWzNdKTtcbiAgICAgICAgICAgICAgICBnbC5jbGVhcihnbC5DT0xPUl9CVUZGRVJfQklUKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIC8vIENsZWFyIHRleHR1cmUuXG4gICAgICAgICAgICBnbC5jbGVhckNvbG9yKDAsIDAsIDAsIDApO1xuICAgICAgICAgICAgZ2wuY2xlYXIoZ2wuQ09MT1JfQlVGRkVSX0JJVCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfc2V0U2Npc3NvcihhcmVhKSB7XG4gICAgICAgIHN1cGVyLl9zZXRTY2lzc29yKGFyZWEpO1xuXG4gICAgICAgIGlmICh0aGlzLl9zY2lzc29yID09PSBhcmVhKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fc2Npc3NvciA9IGFyZWE7XG5cbiAgICAgICAgbGV0IGdsID0gdGhpcy5nbDtcbiAgICAgICAgaWYgKCFhcmVhKSB7XG4gICAgICAgICAgICBnbC5kaXNhYmxlKGdsLlNDSVNTT1JfVEVTVCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBnbC5lbmFibGUoZ2wuU0NJU1NPUl9URVNUKTtcbiAgICAgICAgICAgIGxldCBwcmVjaXNpb24gPSB0aGlzLmN0eC5zdGFnZS5nZXRSZW5kZXJQcmVjaXNpb24oKTtcbiAgICAgICAgICAgIGxldCB5ID0gYXJlYVsxXTtcbiAgICAgICAgICAgIGlmICh0aGlzLl9yZW5kZXJUZXh0dXJlID09PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgLy8gRmxpcC5cbiAgICAgICAgICAgICAgICB5ID0gKHRoaXMuY3R4LnN0YWdlLmggLyBwcmVjaXNpb24gLSAoYXJlYVsxXSArIGFyZWFbM10pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGd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gICAgICAgICAgICAgICByZXR1cm4gMjtcblxuICAgICAgICAgICAgICAgIGNhc2UgZ2wuVU5TSUdORURfU0hPUlRfNV81XzVfMTpcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDI7XG5cbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0ludmFsaWQgdHlwZSBzcGVjaWZpZWQgZm9yIEdMX1JHQkEgZm9ybWF0Jyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoZm10ID09PSBnbC5SR0IpIHtcbiAgICAgICAgICAgIHN3aXRjaCAodHlwZSkge1xuICAgICAgICAgICAgICAgIGNhc2UgZ2wuVU5TSUdORURfQllURTpcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDM7XG5cbiAgICAgICAgICAgICAgICBjYXNlIGdsLlVOU0lHTkVEX0JZVEVfNV82XzU6XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAyO1xuXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIHR5cGUgc3BlY2lmaWVkIGZvciBHTF9SR0IgZm9ybWF0Jyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0ludmFsaWQgZm9ybWF0IHNwZWNpZmllZCBpbiBjYWxsIHRvIF9nZXRCeXRlc1BlclBpeGVsKCknKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHVwbG9hZFRleHR1cmVTb3VyY2UodGV4dHVyZVNvdXJjZSwgb3B0aW9ucykge1xuICAgICAgICBjb25zdCBnbCA9IHRoaXMuc3RhZ2UuZ2w7XG5cbiAgICAgICAgY29uc3Qgc291cmNlID0gb3B0aW9ucy5zb3VyY2U7XG4gICAgICAgIG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zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx5O1xuICAgICAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVsLCByLmFscGhhKTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4ICsgZWxlbWVudENvcmUuX3cgKiByLnRhO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHkgKyBlbGVtZW50Q29yZS5fdyAqIHIudGM7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx5O1xuICAgICAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVyLCByLmFscGhhKTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4ICsgZWxlbWVudENvcmUuX3cgKiByLnRhICsgZWxlbWVudENvcmUuX2ggKiByLnRiO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHkgKyBlbGVtZW50Q29yZS5fdyAqIHIudGMgKyBlbGVtZW50Q29yZS5faCAqIHIudGQ7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ5O1xuICAgICAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvckJyLCByLmFscGhhKTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4ICsgZWxlbWVudENvcmUuX2ggKiByLnRiO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHkgKyBlbGVtZW50Q29yZS5faCAqIHIudGQ7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ5O1xuICAgICAgICAgICAgdWludHNbb2Zmc2V0XSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JCbCwgci5hbHBoYSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBTaW1wbGUuXG4gICAgICAgICAgICBsZXQgY3ggPSByLnB4ICsgZWxlbWVudENvcmUuX3cgKiByLnRhO1xuICAgICAgICAgICAgbGV0IGN5ID0gci5weSArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcblxuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHg7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHk7XG4gICAgICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yVWwsIHIuYWxwaGEpO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGN4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHk7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx5O1xuICAgICAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVyLCByLmFscGhhKTtcbiAgICAgICAgICAgIGZsb2F0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AgICAgICAgICAoZmxvYXRzW29mZnNldCArIDNdID09PSAwKSAmJlxuICAgICAgICAgICAgKHVpbnRzW29mZnNldCArIDRdID09PSAweEZGRkZGRkZGKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyA1XSA9PT0gcmVuZGVyVGV4dHVyZUluZm8udykgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgNl0gPT09IDApICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDddID09PSAxKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyA4XSA9PT0gMCkgJiZcbiAgICAgICAgICAgICh1aW50c1tvZmZzZXQgKyA5XSA9PT0gMHhGRkZGRkZGRikgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgMTBdID09PSByZW5kZXJUZXh0dXJlSW5mby53KSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAxMV0gPT09IHJlbmRlclRleHR1cmVJbmZvLmgpICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDEyXSA9PT0gMSkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgMTNdID09PSAxKSAmJlxuICAgICAgICAgICAgKHVpbnRzW29mZnNldCArIDE0XSA9PT0gMHhGRkZGRkZGRikgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgMTVdID09PSAwKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAxNl0gPT09IHJlbmRlclRleHR1cmVJbmZvLmgpICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDE3XSA9PT0gMCkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgMThdID09PSAxKSAmJlxuICAgICAgICAgICAgKHVpbnRzW29mZnNldCArIDE5XSA9PT0gMHhGRkZGRkZGRikpO1xuICAgIH1cblxuICAgIGZpbmlzaF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FzcGVjdFJhdGlvKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYXNwZWN0UmF0aW87XG4gICAgfVxuXG4gICAgc2V0IGFzcGVjdFJhdGlvKHYpIHtcbiAgICAgICAgdGhpcy5fYXNwZWN0UmF0aW8gPSB2O1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBvZmZzZXRYKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fb2Zmc2V0WDtcbiAgICB9XG5cbiAgICBzZXQgb2Zmc2V0WCh2KSB7XG4gICAgICAgIHRoaXMuX29mZnNldFggPSB2O1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBvZmZzZXRZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fb2Zmc2V0WTtcbiAgICB9XG5cbiAgICBzZXQgb2Zmc2V0WSh2KSB7XG4gICAgICAgIHRoaXMuX29mZnNldFkgPSB2O1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIHNldCBhbW91bnQodikge1xuICAgICAgICB0aGlzLl9hbW91bnQgPSB2O1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBhbW91bnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9hbW91bnQ7XG4gICAgfVxuXG4gICAgc2V0IGlucHV0VmFsdWUodikge1xuICAgICAgICB0aGlzLl9pbnB1dFZhbHVlID0gdjtcbiAgICB9XG5cbiAgICBnZXQgaW5wdXRWYWx1ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2lucHV0VmFsdWU7XG4gICAgfVxuXG4gICAgc2V0IG1heERlcml2YXRpdmUodikge1xuICAgICAgICB0aGlzLl9tYXhEZXJpdmF0aXZlID0gdjtcbiAgICB9XG5cbiAgICBnZXQgbWF4RGVyaXZhdGl2ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21heERlcml2YXRpdmU7XG4gIC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Byb2plY3Rpb25cIiwgdGhpcy5fZ2V0UHJvamVjdGlvbihvcGVyYXRpb24pLCB0aGlzLmdsLnVuaWZvcm0yZnYsIGZhbHNlKTtcbiAgICB9XG5cbiAgICBkcmF3KG9wZXJhdGlvbikge1xuICAgICAgICBsZXQgZ2wgPSB0aGlzLmdsO1xuXG4gICAgICAgIGxldCBsZW5ndGggPSBvcGVyYXRpb24ubGVuZ3RoO1xuXG4gICAgICAgIGlmIChsZW5ndGgpIHtcbiAgICAgICAgICAgIGxldCBnbFRleHR1cmUgPSBvcGVyYXRpb24uZ2V0VGV4dHVyZSgwKTtcbiAgICAgICAgICAgIGxldCBwb3MgPSAwO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGxldCB0eCA9IG9wZXJhdGlvbi5nZXRUZXh0dXJlKGkpO1xuICAgICAgICAgICAgICAgIGlmIChnbFRleHR1cmUgIT09IHR4KSB7XG4gICAgICAgICAgICAgICAgICAgIGdsLmJpbmRUZXh0dXJlKGdsLlRFWFRVUkVfMkQsIGdsVGV4dHVyZSk7XG4gICAgICAgICAgICAgICAgICAgIGdsLmRyYXdFbGVtZW50cyhnbC5UUklBTkdMRVMsIDYgKiAoaSAtIHBvcyksIGdsLlVOU0lHTkVEX1NIT1JULCAocG9zICsgb3BlcmF0aW9uLmluZGV4KSAqIDYgKiAyKTtcbiAgICAgICAgICAgICAgICAgICAgZ2xUZXh0dXJlID0gdHg7XG4gICAgICAgICAgICAgICAgICAgIHBvcyA9IGk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgXG4gICAgICAgICAgICBnbC5iaW5kVGV4dHVyZShnbC5URVhUVVJFXzJELCBnbFRleHR1cmUpO1xuICAgICAgICAgICAgZ2wuZHJhd0VsZW1lbnRzKGdsLlRSSUFOR0xFUywgNiAqIChsZW5ndGggLSBwb3MpLCBnbC5VTlNJR05FRF9T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ICAgICAgIHVseSA9IE1hdGgucmFuZG9tKCk7XG5cbiAgICAgICAgICAgICAgICBicnggKz0gdWx4O1xuICAgICAgICAgICAgICAgIGJyeSArPSB1bHk7XG5cbiAgICAgICAgICAgICAgICBpZiAoTWF0aC5yYW5kb20oKSA8IDAuNSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBGbGlwIGZvciBtb3JlIHJhbmRvbW5lc3MuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHQgPSB1bHg7XG4gICAgICAgICAgICAgICAgICAgIHVseCA9IGJyeDtcbiAgICAgICAgICAgICAgICAgICAgYnJ4ID0gdDtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoTWF0aC5yYW5kb20oKSA8IDAuNSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBGbGlwIGZvciBtb3JlIHJhbmRvbW5lc3MuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHQgPSB1bHk7XG4gICAgICAgICAgICAgICAgICAgIHVseSA9IGJyeTtcbiAgICAgICAgICAgICAgICAgICAgYnJ5ID0gdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIFNwZWNpZnkgYWxsIGNvcm5lciBwb2ludHMuXG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0XSA9IHVseDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQgKyAxXSA9IHVseTtcblxuICAgICAgICAgICAgZmxvYXRzW29mZnNldCArIDJdID0gYnJ4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCArIDNdID0gdWx5O1xuXG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0ICsgNF0gPSBicng7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0ICsgNV0gPSBicnk7XG5cbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQgKyA2XSA9IHVseDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZX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HNldCBsZWZ0KG51bSkge1xuICAgICAgICB0aGlzLl9mYWRlWzNdID0gbnVtO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBsZWZ0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZmFkZVszXTtcbiAgICB9XG5cbiAgICBzZXQgZmFkZSh2KSB7XG4gICAgICAgIGlmKEFycmF5LmlzQXJyYXkodikpIHtcbiAgICAgICAgICAgIGlmKHYubGVuZ3RoID09PSAyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZmFkZSA9IFt2WzBdLCB2WzFdLCB2WzBdLCB2WzFdXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYodi5sZW5ndGggPT09IDMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9mYWRlID0gW3ZbMF0sIHZbMV0sIHZbMl0sIHRoaXMuX2ZhZGVbM11dO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAodi5sZW5ndGggPT09IDQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9mYWRlID0gdjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX2ZhZGUgPSBbdlswXSwgdlswXSwgdlswXSwgdlswXV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9mYWRlID0gW3YsIHYsIHYsIHZdO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IGZhZGUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mYWRlO1xuICAgIH1cblxuICAgIHNldHVwVW5pZm9ybXMob3BlcmF0aW9uKSB7XG4gICAgICAgIHN1cGVyLnNldHVwVW5pZm9ybXMob3BlcmF0aW9uKTtcbiAgICAgICAgY29uc3Qgb3duZXIgPSBvcGV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b3I7XG4gICAgICAgIHZlYzIgaGFsZlJlcyA9IDAuNSAqIHJlc29sdXRpb24ueHk7XG4gICAgICAgIHZlYzIgcG9pbnQgPSB2VGV4dHVyZUNvb3JkLnh5ICogcmVzb2x1dGlvbi54eTtcbiAgICAgICAgXG4gICAgICAgIHZlYzIgcG9zMTtcbiAgICAgICAgdmVjMiBwb3MyO1xuICAgICAgICB2ZWMyIGQ7XG4gICAgICAgIGZsb2F0IGM7XG4gICAgICAgIGZsb2F0IHQgPSAwLjA7XG4gICAgICAgICAgICAgXG4gICAgICAgIGlmKGZhZGVbMF0gPiAwLjApIHtcbiAgICAgICAgICAgIHBvczEgPSB2ZWMyKHBvaW50LngsIHBvaW50LnkpO1xuICAgICAgICAgICAgcG9zMiA9IHZlYzIocG9pbnQueCwgcG9pbnQueSArIGZhZGVbMF0pO1xuICAgICAgICAgICAgZCA9IHBvczIgLSBwb3MxO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MxLCBkKSAvIGRvdChkLCBkKTtcbiAgICAgICAgICAgIHQgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcChjLCAwLjAsIDEuMCkpO1xuICAgICAgICAgICAgY29sb3IgPSBtaXgodmVjNCgwLjApLCBjb2xvciwgdCk7XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGlmKGZhZGVbMV0gPiAwLjApIHtcbiAgICAgICAgICAgIHZlYzIgcG9zMSA9IHZlYzIocG9pbnQueCAtIHJlc29sdXRpb24ueCAtIGZhZGVbMV0sIHZUZXh0dXJlQ29vcmQueSk7XG4gICAgICAgICAgICB2ZWMyIHBvczIgPSB2ZWMyKHBvaW50LnggLSByZXNvbHV0aW9uLngsIHZUZXh0dXJlQ29vcmQueSk7XG4gICAgICAgICAgICBkID0gcG9zMSAtIHBvczI7XG4gICAgICAgICAgICBjID0gZG90KHBvczIsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKGMsIDAuMCwgMS4wKSk7XG4gICAgICAgICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgICAgaWYoZmFkZVsyXSA+IDAuMCkge1xuICAgICAgICAgICAgdmVjMiBwb3MxID0gdmVjMih2VGV4dHVyZUNvb3JkLngsIHBvaW50LnkgLSByZXNvbHV0aW9uLnkgLSBmYWRlWzJdKTtcbiAgICAgICAgICAgIHZlYzIgcG9zMiA9IHZlYzIodlRleHR1cmVDb29yZC54LCBwb2ludC55IC0gcmVzb2x1dGlvbi55KTtcbiAgICAgICAgICAgIGQgPSBwb3MxIC0gcG9zMjtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMiwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzNdID4gMC4wKSB7XG4gICAgICAgICAgICBwb3MxID0gdmVjMihwb2ludC54LCBwb2ludC55KTtcbiAgICAgICAgICAgIHBvczIgPSB2ZWMyKHBvaW50LnggKyBmYWRlWzNdLCBwb2ludC55KTtcbiAgICAgICAgICAgIGQgPSBwb3MyIC0gcG9zMTtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMSwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBnbF9GcmFnQ29sb3IgPSBjb2xvcjtcbiAgICB9XG5gO1xuIiwi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IGRlZmF1bHQgY2xhc3MgSG9sZVNoYWRlciBleHRlbmRzIERlZmF1bHRTaGFkZXIge1xuXG4gICAgY29uc3RydWN0b3IoY29udGV4dCkge1xuICAgICAgICBzdXBlcihjb250ZXh0KTtcbiAgICAgICAgdGhpcy5feCA9IDA7XG4gICAgICAgIHRoaXMuX3kgPSAwO1xuICAgICAgICB0aGlzLl93ID0gMDtcbiAgICAgICAgdGhpcy5faCA9IDA7XG4gICAgICAgIHRoaXMuX3JhZGl1cyA9IDA7XG4gICAgfVxuXG4gICAgZ2V0IHgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl94O1xuICAgIH1cblxuICAgIHNldCB4KHYpIHtcbiAgICAgICAgdGhpcy5feCA9IHY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl95O1xuICAgIH1cblxuICAgIHNldCB5KHYpIHtcbiAgICAgICAgdGhpcy5feSA9IHY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93O1xuICAgIH1cblxuICAgIHNldCB3KHYpIHtcbiAgICAgICAgdGhpcy5fdyA9IHY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oO1xuICAgIH1cblxuICAgIHNldCBoKHYpIHtcbiAgICAgICAgdGhpcy5faCA9IHY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHJhZGl1cygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3JhZGl1cztcbiAgICB9XG5cbiAgICBzZXQgcmFkaXVzKHYpIHtcbiAgICAgICAgdGhpcy5fcmFkaXVzID0gdjtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9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YXRoLm1pbihNYXRoLm1heChwLCAwKSwgMSk7XG4gICAgfVxuXG4gICAgZ2V0IGJsZW5kKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYmxlbmQ7XG4gICAgfVxuXG4gICAgc2V0IHJhZGl1cyh2KSB7XG4gICAgICAgIGlmKEFycmF5LmlzQXJyYXkodikpIHtcbiAgICAgICAgICAgIGlmKHYubGVuZ3RoID09PSAyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmFkaXVzID0gW3ZbMF0sIHZbMV0sIHZbMF0sIHZbMV1dO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZih2Lmxlbmd0aCA9PT0gMykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JhZGl1cyA9IFt2WzBdLCB2WzFdLCB2WzJdLCB0aGlzLl9yYWRpdXNbM11dO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAodi5sZW5ndGggPT09IDQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yYWRpdXMgPSB2O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmFkaXVzID0gW3ZbMF0sIHZbMF0sIHZbMF0sIHZbMF1dO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fcmFkaXVzID0gW3YsIHYsIHYsIHZdO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHJhZGl1cygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3JhZGl1cztcbiAgICB9XG5cbiAgICBzZXQgdG9wTGVmdChudW0pIHtcbiAgICAgICAgdGhpcy5fcmFkaXVzWzBdID0gbnVtO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCB0b3BMZWZ0KCkge1xuICAgICAgICByZX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gICAgfVxuXG4gICAgX2dldExvb2t1cElkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc2NhbGUgKyBcIjpcIiArIHRoaXMuX2h0bWxFbGVtZW50LmlubmVySFRNTDtcbiAgICB9XG5cbiAgICBfZ2V0U291cmNlTG9hZGVyKCkge1xuICAgICAgICBjb25zdCBodG1sRWxlbWVudCA9IHRoaXMuX2h0bWxFbGVtZW50O1xuICAgICAgICBjb25zdCBzY2FsZSA9IHRoaXMuX3NjYWxlO1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24oY2IpIHtcbiAgICAgICAgICAgIGlmICghd2luZG93Lmh0bWwyY2FudmFzKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNiKG5ldyBFcnJvcihcIlBsZWFzZSBpbmNsdWRlIGh0bWwyY2FudmFzIChodHRwczovL2h0bWwyY2FudmFzLmhlcnR6ZW4uY29tLylcIikpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCBhcmVhID0gSHRtbFRleHR1cmUuZ2V0UHJlbG9hZEFyZWEoKTtcbiAgICAgICAgICAgIGFyZWEuYXBwZW5kQ2hpbGQoaHRtbEVsZW1lbnQpO1xuXG4gICAgICAgICAgICBodG1sMmNhbnZhcyhodG1sRWxlbWVudCwge2JhY2tncm91bmRDb2xvcjogbnVsbCwgc2NhbGU6IHNjYWxlfSkudGhlbihmdW5jdGlvbihjYW52YXMpIHtcbiAgICAgICAgICAgICAgICBhcmVhLnJlbW92ZUNoaWxkKGh0bWxFbGVtZW50KTtcbiAgICAgICAgICAgICAgICBpZiAoY2FudmFzLmhlaWdodCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2IobmV3IEVycm9yKFwiQ2FudmFzIGhlaWdodCBpcyAwXCIpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2IobnVsbCwge3NvdXJjZTogY2FudmFzLCB3aWR0aDogY2FudmFzLndpZHRoLCBoZWlnaH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l9zcmM7XG4gICAgfVxuXG4gICAgX2dldExvb2t1cElkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc3JjO1xuICAgIH1cblxuICAgIF9nZXRTb3VyY2VMb2FkZXIoKSB7XG4gICAgICAgIGxldCBzcmMgPSB0aGlzLl9zcmM7XG4gICAgICAgIGxldCBoYXNBbHBoYSA9IHRoaXMuX2hhc0FscGhhO1xuICAgICAgICBpZiAodGhpcy5zdGFnZS5nZXRPcHRpb24oJ3NyY0Jhc2VQYXRoJykpIHtcbiAgICAgICAgICAgIHZhciBmYyA9IHNyYy5jaGFyQ29kZUF0KDApO1xuICAgICAgICAgICAgaWYgKChzcmMuaW5kZXhPZihcIi8vXCIpID09PSAtMSkgJiYgKChmYyA+PSA2NSAmJiBmYyA8PSA5MCkgfHwgKGZjID49IDk3ICYmIGZjIDw9IDEyMikgfHwgZmMgPT0gNDYpKSB7XG4gICAgICAgICAgICAgICAgLy8gQWxwaGFiZXRpY2FsIG9yIGRvdDogcHJlcGVuZCBiYXNlIHBhdGguXG4gICAgICAgICAgICAgICAgc3JjID0gdGhpcy5zdGFnZS5nZXRPcHRpb24oJ3NyY0Jhc2VQYXRoJykgKyBzcmM7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gKGNiKSA9PiB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5zdGFnZS5wbGF0Zm9ybS5sb2FkU3JjVGV4dHVyZSh7c3JjOiBzcmMsIGhhc0FscGhhOiBoYXNBbHBoYX0sIGNiKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldE5vbkRlZmF1bHRzKCkge1xuICAgICAgICBjb25zdCBvYmogPSBzdXBlci5nZXROb25EZWZhdWx0cygpO1xuICAgICAgICBpZiAodGhpcy5fc3JjKSB7XG4gICAgICAgICAgICBvYmouc3JjID0gdGhpcy5fc3JjO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBvYmo7XG4gICAgfVxuXG59XG5cbi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WZhdWx0IGNsYXNzIE5vaXNlVGV4dHVyZSBleHRlbmRzIFRleHR1cmUge1xuXG4gICAgX2dldExvb2t1cElkKCkge1xuICAgICAgICByZXR1cm4gJ19fbm9pc2UnO1xuICAgIH1cblxuICAgIF9nZXRTb3VyY2VMb2FkZXIoKSB7XG4gICAgICAgIGNvbnN0IGdsID0gdGhpcy5zdGFnZS5nbDtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGNiKSB7XG4gICAgICAgICAgICBjb25zdCBub2lzZSA9IG5ldyBVaW50OEFycmF5KDEyOCAqIDEyOCAqIDQpO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCAxMjggKiAxMjggKiA0OyBpKz00KSB7XG4gICAgICAgICAgICAgICAgY29uc3QgdiA9IE1hdGguZmxvb3IoTWF0aC5yYW5kb20oKSAqIDI1Nik7XG4gICAgICAgICAgICAgICAgbm9pc2VbaV0gPSB2O1xuICAgICAgICAgICAgICAgIG5vaXNlW2krMV0gPSB2O1xuICAgICAgICAgICAgICAgIG5vaXNlW2krMl0gPSB2O1xuICAgICAgICAgICAgICAgIG5vaXNlW2krM10gPSAyNTU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb25zdCB0ZXhQYXJhbXMgPSB7fVxuXG4gICAgICAgICAgICBpZiAoZ2wpIHtcbiAgICAgICAgICAgICAgICB0ZXhQYXJhbXNbZ2wuVEVYVFVSRV9XUkFQX1NdID0gZ2wuUkVQRUFUO1xuICAgICAgICAgICAgICAgIHRleFBhcmFtc1tnbC5URVhUVVJFX1dSQVBfVF0gPSBnbC5SRVBFQVQ7XG4gICAgICAgICAgICAgICAgdGV4UGFyYW1zW2dsLlRFWFRVUkVfTUlOX0ZJTFRFUl0gPSBnbC5ORUFSRVNUO1xuICAgICAgICAgICAgICAgIHRleFBhcmFtc1tnbC5URVhUVVJFX01BR19GSUxURVJdID0gZ2wuTkVBUkVTVDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgIC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ICB0aGlzLl93ID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG5cbiAgICBzZXQgaCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9oICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9oID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBmb250U3R5bGUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mb250U3R5bGU7XG4gICAgfVxuXG4gICAgc2V0IGZvbnRTdHlsZSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9mb250U3R5bGUgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2ZvbnRTdHlsZSA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgZm9udEJhc2VsaW5lUmF0aW8oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mb250QmFzZWxpbmVSYXRpbztcbiAgICB9XG4gICAgXG4gICAgc2V0IGZvbnRCYXNlbGluZVJhdGlvKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2ZvbnRCYXNlbGluZVJhdGlvICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9mb250QmFzZWxpbmVSYXRpbyA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgZm9udFNpemUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mb250U2l6ZTtcbiAgICB9XG5cbiAgICBzZXQgZm9udFNpemUodikge1xuICAgICAgICBpZiAodGhpcy5fZm9udFNpemUgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2ZvbnRTaXplID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBmb250RmFjZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZvbnRGYWNlO1xuICAgIH1cblxuICAgIHNldCBmb250RmFjZSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9mb250RmFjZSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fZm9udEZhY2UgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHdvcmRXcmFwKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fd29yZFdyYXA7XG4gICAgfVxuXG4gICAgc2V0IHdvcmRXcmFwKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3dvcmRXcmFwICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl93b3JkV3JhcCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgd29yZFdyYXBXaWR0aCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3dvcmRXcmFwV2lkdGg7XG4gICAgfVxuXG4gICAgc2V0IHdvcmRXcmFwV2lkdGgodikge1xuICAgICAgICBpZiAodGhpcy5fd29yZFdyYXBXaWR0aCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fd29yZFdyYXBXaWR0aCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgd29yZEJyZWFrKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fd29yZEJyZWFrO1xuICAgIH1cblxuICAgIHNldCB3b3JkQnJlYWsodikge1xuICAgICAgICBpZiAodGhpcy5fd29yZEJyZWFrICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl93b3JkQnJlYWsg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pZ24gIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3RleHRBbGlnbiA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdmVydGljYWxBbGlnbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3ZlcnRpY2FsQWxpZ247XG4gICAgfVxuXG4gICAgc2V0IHZlcnRpY2FsQWxpZ24odikge1xuICAgICAgICBpZiAodGhpcy5fdmVydGljYWxBbGlnbiAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fdmVydGljYWxBbGlnbiA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgb2Zmc2V0WSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX29mZnNldFk7XG4gICAgfVxuXG4gICAgc2V0IG9mZnNldFkodikge1xuICAgICAgICBpZiAodGhpcy5fb2Zmc2V0WSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fb2Zmc2V0WSA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgbWF4TGluZXMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9tYXhMaW5lcztcbiAgICB9XG5cbiAgICBzZXQgbWF4TGluZXModikge1xuICAgICAgICBpZiAodGhpcy5fbWF4TGluZXMgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX21heExpbmVzID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBtYXhMaW5lc1N1ZmZpeCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21heExpbmVzU3VmZml4O1xuICAgIH1cblxuICAgIHNldCBtYXhMaW5lc1N1ZmZpeCh2KSB7XG4gICAgICAgIGlmICh0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uXG4gICAgc2V0IGFkdmFuY2VkUmVuZGVyZXIodikge1xuICAgICAgICBpZiAodGhpcy5fYWR2YW5jZWRSZW5kZXJlciAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fYWR2YW5jZWRSZW5kZXJlciA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzZXQgbGV0dGVyU3BhY2luZyh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9sZXR0ZXJTcGFjaW5nICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9sZXR0ZXJTcGFjaW5nID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBsZXR0ZXJTcGFjaW5nKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbGV0dGVyU3BhY2luZztcbiAgICB9XG5cbiAgICBzZXQgdGV4dEluZGVudCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl90ZXh0SW5kZW50ICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl90ZXh0SW5kZW50ID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB0ZXh0SW5kZW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdGV4dEluZGVudDtcbiAgICB9XG5cbiAgICBzZXQgcnRsKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3J0bCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fcnRsID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBydGwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9ydGw7XG4gICAgfVxuXG4gICAgZ2V0IHByZWNpc2lvbigpIHtcbiAgICAgICAgcmV0dXJuIHN1cGVyLnByZWNpc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gICAgICAgICAgLy8gUHJldmVudCB0ZXh0IGJsdXIgd2hlbiB0ZXh0IHRleHR1cmUgaXMgZG93bnNjYWxlZFxuICAgICAgICAgICAgaWYgKFV0aWxzLmlzQm9vbGVhbihzaGFycENmZykpIHtcbiAgICAgICAgICAgICAgICBzaGFycGVuID0gc2hhcnBDZmc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0KHNoYXJwQ2ZnKSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHByZWNpc2lvbiA9IHRoaXMuc3RhZ2UuZ2V0UmVuZGVyUHJlY2lzaW9uKCk7XG4gICAgICAgICAgICAgICAgc2hhcnBlbiA9IHByZWNpc2lvbiA8PSBzaGFycENmZy5wcmVjaXNpb24gJiYgYXJncy5mb250U2l6ZSA8PSBzaGFycENmZy5mb250U2l6ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGdsICYmIHNoYXJwZW4pIHtcbiAgICAgICAgICAgICAgICB0ZXhQYXJhbXNbZ2wuVEVYVFVSRV9NQUdfRklMVEVSXSA9IGdsLk5FQVJFU1Q7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChwKSB7XG4gICAgICAgICAgICAgICAgcC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgLyogRklYTUU6IG9uIHNvbWUgcGxhdGZvcm1zIChlLmcuIFJQSSksIHRocm90dGxpbmcgdGV4dCB0ZXh0dXJlcyBjYXVzZSBhcnRpZmFjdHMgKi9cbiAgICAgICAgICAgICAgICAgICAgY2IobnVsbCwgT2JqZWN0LmFzc2lnbih7XG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJJbmZvOiByZW5kZXJlci5yZW5kZXJJbmZvLFxuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3R0bGU6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICAgICAgdGV4UGFyYW1zOiB0ZXhQYXJhbXMsXG4gICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuc3RhZ2UucGxhdGZvcm0uZ2V0VGV4dHVyZU9wdGlvbnNGb3JEcmF3aW5nQ2FudmFzKGNhbnZhcykpKTtcbiAgICAgICAgICAgICAgICB9KS5jYXRjaCgoZXJyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGNiKGVycik7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNiKG51bGwsIE9iamVjdC5hc3NpZ24oe1xuICAgICAgICAgICAgICAgICAgICByZW5kZXJJbmZvOiByZW5kZXJlci5yZW5kZXJJbmZvLFxuICAgICAgICAgICAgICAgICAgICB0aHJvdHRsZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIHRleFBhcmFtczogdGV4UGFyYW1zLFxuICAgICAgICAgICAgICAgIH0sIHRoaXMuc3RhZ2UucGxhdGZvcm0uZ2V0VGV4dHVyZU9wdGlvbnNGb3JEcmF3aW5nQ2FudmFzKGNhbnZhcykpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG5cblxuICAgIGdldE5vbkRlZmF1bHRzKCkge1xuICAgICAgICBjb25zdCBub25EZWZhdWx0cyA9IHN1cGVyLmdldE5vbkRlZmF1bHRzKCk7XG4gICAgICAgIGlmICh0aGlzLnRleHQgIT09IFwiXCIpIG5vbkRlZmF1bHRzWyd0ZXh0J10gPSB0aGlzLnRleHQ7XG4gICAgICAgIGlmICh0aGlzLncgIT09IDApIG5vbkRlZmF1bHRzWyd3J10gPSB0aGlzLnc7XG4gICAgICAgIGlmICh0aGlzLmggIT09IDApIG5vbkRlZmF1bHRzWydoJ10gPSB0aGlzLmg7XG4gICAgICAgIGlmICh0aGlzLmZvbnRTdHlsZSAhPT0gXCJub3JtYWxcIikgbm9uRGVmYXVsdHNbJ2ZvbnRTdHlsZSddID0gdGhpcy5mb250U3R5bGU7XG4gICAgICAgIGlmICh0aGlzLmZvb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biAgICAgICAgbGV0IG9iaiA9IHt9O1xuICAgICAgICBvYmoudGV4dCA9IHRoaXMuX3RleHQ7XG4gICAgICAgIG9iai53ID0gdGhpcy5fdztcbiAgICAgICAgb2JqLmggPSB0aGlzLl9oO1xuICAgICAgICBvYmouZm9udFN0eWxlID0gdGhpcy5fZm9udFN0eWxlO1xuICAgICAgICBvYmouZm9udFNpemUgPSB0aGlzLl9mb250U2l6ZTtcbiAgICAgICAgb2JqLmZvbnRCYXNlbGluZVJhdGlvID0gdGhpcy5fZm9udEJhc2VsaW5lUmF0aW87XG4gICAgICAgIG9iai5mb250RmFjZSA9IHRoaXMuX2ZvbnRGYWNlO1xuICAgICAgICBvYmoud29yZFdyYXAgPSB0aGlzLl93b3JkV3JhcDtcbiAgICAgICAgb2JqLndvcmRXcmFwV2lkdGggPSB0aGlzLl93b3JkV3JhcFdpZHRoO1xuICAgICAgICBvYmoud29yZEJyZWFrID0gdGhpcy5fd29yZEJyZWFrO1xuICAgICAgICBvYmoudGV4dE92ZXJmbG93ID0gdGhpcy5fdGV4dE92ZXJmbG93O1xuICAgICAgICBvYmoubGluZUhlaWdodCA9IHRoaXMuX2xpbmVIZWlnaHQ7XG4gICAgICAgIG9iai50ZXh0QmFzZWxpbmUgPSB0aGlzLl90ZXh0QmFzZWxpbmU7XG4gICAgICAgIG9iai50ZXh0QWxpZ24gPSB0aGlzLl90ZXh0QWxpZ247XG4gICAgICAgIG9iai52ZXJ0aWNhbEFsaWduID0gdGhpcy5fdmVydGljYWxBbGlnbjtcbiAgICAgICAgb2JqLm9mZnNldFkgPSB0aGlzLl9vZmZzZXRZO1xuICAgICAgICBvYmoubWF4TGluZXMgPSB0aGlzLl9tYXhMaW5lcztcbiAgICAgICAgb2JqLm1heExpbmVzU3VmZml4ID0gdGhpcy5fbWF4TGluZXNTdWZmaXg7XG4gICAgICAgIG9iai5wcmVjaXNpb24gPSB0aGlzLl9wcmVjaXNpb247XG4gICAgICAgIG9iai50ZXh0Q29sb3Ig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zLl9jb250ZXh0LmRpcmVjdGlvbiA9IHRoaXMuX3NldHRpbmdzLnJ0bCA/IFwicnRsXCIgOiBcImx0clwiO1xuICAgIH07XG5cbiAgICBfbG9hZCgpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzV2ViICYmIGRvY3VtZW50LmZvbnRzKSB7XG4gICAgICAgICAgICBjb25zdCBmb250U2V0dGluZyA9IGdldEZvbnRTZXR0aW5nKFxuICAgICAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRGYWNlLFxuICAgICAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTdHlsZSxcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U2l6ZSxcbiAgICAgICAgICAgICAgICB0aGlzLmdldFByZWNpc2lvbigpLFxuICAgICAgICAgICAgICAgIHRoaXMuX3N0YWdlLmdldE9wdGlvbignZGVmYXVsdEZvbnRGYWNlJylcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFVzZSBhIHByb21pc2UgdGhhdCB3YWl0cyBmb3IgbG9hZGluZy5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmZvbnRzLmxvYWQoZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpLmNhdGNoKGVyciA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBKdXN0IGxvYWQgdGhlIGZhbGxiYWNrIGZvbnQuXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ1tMaWdodG5pbmddIEZvbnQgbG9hZCBlcnJvcicsIGVyciwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgICAgICAgICB9KS50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdbTGlnaHRuaW5nXSBGb250IG5vdCBmb3VuZCcsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBjYXRjaChlKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gQ2FuJ3QgY2hlY2sgZm9udCBsb2FkaW5nIGZvciBcIiArIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGRyYXcoKSB7XG4gICAgICAgIC8vIFdlIGRvIG5vdCB1c2UgYSBwcm9taXNlIHNvIHRoYXQgbG9hZGluZyBpcyBwZXJmb3JtZWQgc3luY3Jvbm91cyB3aGVuIHBvc3NpYmxlLlxuICAgICAgICBjb25zdCBsb2FkUHJvbWlzZSA9IHRoaXMuX2xvYWQoKTtcbiAgICAgICAgaWYgKCFsb2FkUHJvbWlzZSkge1xuICAgICAgICAgICAgcmV0dXJuIFV0aWxzLmlzU3BhcmsgPyB0aGlzLl9zdGFnZS5wbGF0Zm9ybS5kcmF3VGV4dCh0aGlzKSA6IHRoaXMuX2RyYXcoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBsb2FkUHJvbWlzZS50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgICByZXR1cm4gVXRpbHMuaXNTcGFyayA/IHRoaXMuX3N0YWdlLnBsYXRmb3JtLmRyYXdUZXh0KHRoaXMpIDogdGhpcy5fZHJhdygpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG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ICAgICAgICAgICAgICAgICBzdWZmaXggPSAnJztcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnZWxsaXBzaXMnOlxuICAgICAgICAgICAgICAgICAgICBzdWZmaXggPSB0aGlzLl9zZXR0aW5ncy5tYXhMaW5lc1N1ZmZpeDtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5fc2V0dGluZ3MudGV4dE92ZXJmbG93O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fc2V0dGluZ3MudGV4dCA9IHRoaXMud3JhcFdvcmQodGhpcy5fc2V0dGluZ3MudGV4dCwgd29yZFdyYXBXaWR0aCAtIHRleHRJbmRlbnQsIHN1ZmZpeClcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIHdvcmQgd3JhcFxuICAgICAgICAvLyBwcmVzZXJ2ZSBvcmlnaW5hbCB0ZXh0XG4gICAgICAgIGxldCBsaW5lc0luZm87XG4gICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy53b3JkV3JhcCkge1xuICAgICAgICAgICAgbGluZXNJbmZvID0gdGhpcy53cmFwVGV4dCh0aGlzLl9zZXR0aW5ncy50ZXh0LCB3b3JkV3JhcFdpZHRoLCBsZXR0ZXJTcGFjaW5nLCB0ZXh0SW5kZW50KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxpbmVzSW5mbyA9IHtsOiB0aGlzLl9zZXR0aW5ncy50ZXh0LnNwbGl0KC8oPzpcXHJcXG58XFxyfFxcbikvKSwgbjogW119O1xuICAgICAgICAgICAgbGV0IGksIG4gPSBsaW5lc0luZm8ubC5sZW5ndGg7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG4gLSAxOyBpKyspIHtcbiAgICAgICAgICAgICAgICBsaW5lc0luZm8ubi5wdXNoKGkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGxldCBsaW5lcyA9IGxpbmVzSW5mby5sO1xuXG4gICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy5tYXhMaW5lcyAmJiBsaW5lcy5sZW5ndGggPiB0aGlzLl9zZXR0aW5ncy5tYXhMaW5lcykge1xuICAgICAgICAgICAgbGV0IHVzZWRMaW5lcyA9IGxpbmVzLnNsaWNlKDAsIHRoaXMuX3NldHRpbmdzLm1heExpbmVzKTtcblxuICAgICAgICAgICAgbGV0IG90aGVyTGluZXMgPSBudWxsO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLm1heExpbmVzU3VmZml4KSB7XG4gICAgICAgICAgICAgICAgLy8gV3JhcCBhZ2FpbiB3aXRoIG1heCBsaW5lcyBzdWZmaXggZW5hYmxlZC5cbiAgICAgICAgICAgICAgICBsZXQgdyA9IHRoaXMuX3NldHRpbmdzLm1heExpbmVzU3VmZml4ID8gdGhpcy5tZWFzdXJlVGV4dCh0aGlzLl9zZXR0aW5ncy5tYXhMaW5lc1N1ZmZpeCkgOiAwO1xuICAgICAgICAgICAgICAgIGxldCBhbCA9IHRoaXMud3JhcFRleHQodXNlZExpbmVzW3VzZWRMaW5lcy5sZW5ndGggLSAxXSwgd29yZFdyYXBXaWR0aCAtIHcsIGxldHRlclNwYWNpbmcsIHRleHRJbmRlbnQpO1xuICAgICAgICAgICAgICAgIHVzZWRMaW5lc1t1c2VkTGluZXMubGVuZ3RoIC0gMV0gPSBhbC5sWzBdICsgdGhpcy5fc2V0dGluZ3MubWF4TGluZXNTdWZmaXg7XG4gICAgICAgICAgICAgICAgb3RoZXJMaW5lcyA9IFthbC5sLmxlbmd0aCA+IDEgPyBhbC5sWzFdIDogJyddO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBvdGhlckxpbmVzID0gWycnXTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gUmUtYXNzZW1ibGUgdGhlIHJlbWFpbmluZyB0ZXh0LlxuICAgICAgICAgICAgbGV0IGksIG4gPSBsaW5lcy5sZW5ndGg7XG4gICAgICAgICAgICBsZXQgaiA9IDA7XG4gICAgICAgICAgICBsZXQgbSA9IGxpbmVzSW5mby5uLmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAoaSA9IHRoaXMuX3NldHRpbmdzLm1heExpbmVzOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgb3RoZXJMaW5lc1tqXSArPSAob3RoZXJMaW5lc1tqXSA/IFwiIFwiIDogXCJcIikgKyBsaW5lc1tpXTtcbiAgICAgICAgICAgICAgICBpZiAoaSArIDEgPCBtICYmIGxpbmVzSW5mby5uW2kgKyAxXSkge1xuICAgICAgICAgICAgICAgICAgICBqKys7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZW5kZXJJbmZvLnJlbWFpbmluZ1RleHQgPSBvdGhlckxpbmVzLmpvaW4oXCJcXG5cIik7XG5cbiAgICAgICAgICAgIHJlbmRlckluZm8ubW9yZVRleHRMaW5lcyA9IHRydWU7XG5cbiAgICAgICAgICAgIGxpbmVzID0gdXNlZExpbmVzO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmVuZGVySW5mby5tb3JlVGV4dExpbmVzID0gZmFsc2U7XG4gICAgICAgICAgICByZW5kZXJJbmZvLnJlbWFpbmluZ1RleHQgPSBcIlwiO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gY2FsY3VsYXRlIHRleHQgd2lkdGhcbiAgICAgICAgbGV0IG1heExpbmVXaWR0aCA9IDA7XG4gICAgICAgIGxldCBsaW5lV2lkdGhzID0gW107XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGluZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGxldCBsaW5lV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KGxpbmVzW2ldLCBsZXR0ZXJTcGFjaW5nKSArIChpID09PSAwID8gdGV4dEluZGVudCA6IDApO1xuICAgICAgICAgICAgbGluZVdpZHRocy5wdXNoKGxpbmVXaWR0aCk7XG4gICAgICAgICAgICBtYXhMaW5lV2lkdGggPSBNYXRoLm1heChtYXhMaW5lV2lkdGgsIGxpbmVXaWR0aCk7XG4gICAgICAgIH1cblxuICAgICAgICByZW5kZXJJbmZvLmxpbmVXaWR0aHMgPSBsaW5lV2lkdGhzO1xuXG4gICAgICAgIGlmICghdykge1xuICAgICAgICAgICAgLy8gQXV0by1zZXQgd2lkdGggdG8gbWF4IHRleHQgbGVuZ3RoLlxuICAgICAgICAgICAgd2lkdGggPSBtYXhMaW5lV2lkdGggKyBwYWRkaW5nTGVmdCArIHBhZGRpbmdSaWdodDtcbiAgICAgICAgICAgIGlubmVyV2lkdGggPSBtYXhMaW5lV2lkdGg7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBjYWxjdWxhdGUgdGV4dCBoZWlnaHRcbiAgICAgICAgbGluZUhlaWdodCA9IGxpbmVIZWlnaHQgfHwgZm9udFNpemU7XG5cbiAgICAgICAgbGV0IGhlaWdodDtcbiAgICAgICAgaWYgKGgpIHtcbiAgICAgICAgICAgIGhlaWdodCA9IGg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBiYXNlbGluZU9mZnNldCA9ICh0aGlzLl9zZXR0aW5ncy50ZXh0QmFzZWxpbmUgIT0gJ2JvdHRvbScpID8gMC41ICogZm9udFNpemUgOiAwO1xuICAgICAgICAgICAgaGVpZ2h0ID0gbGluZUhlaWdodCAqIChsaW5lcy5sZW5ndGggLSAxKSArIGJhc2VsaW5lT2Zmc2V0ICsgTWF0aC5tYXgobGluZUhlaWdodCwgZm9udFNpemUpICsgb2Zmc2V0WTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChvZmZzZXRZID09PSBudWxsKSB7XG4gICAgICAgICAgICBvZmZzZXRZID0gZm9udFNpemU7XG4gICAgICAgIH1cblxuICAgICAgICByZW5kZXJJbmZvLncgPSB3aWR0aDtcbiAgICAgICAgcmVuZGVySW5mby5oID0gaGVpZ2h0O1xuICAgICAgICByZW5kZXJJbmZvLmxpbmVzID0gbGluZXM7XG4gICAgICAgIHJlbmRlckluZm8ucHJlY2lzaW9uID0gcHJlY2lzaW9uO1xuXG4gICAgICAgIGlmICghd2lkdGgpIHtcbiAgICAgICAgICAgIC8vIFRvIHByZXZlbnQgY2FudmFzIGVycm9ycy5cbiAgICAgICAgICAgIHdpZHRoID0gMTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICghaGVpZ2h0KSB7XG4gICAgICAgICAgICAvLyBUbyBwcmV2ZW50IGNhbnZhcyBlcnJvcnMuXG4gICAgICAgICAgICBoZWlnaHQgPSAxO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGN1dFN4IHx8IGN1dEV4KSB7XG4gICAgICAgICAgICB3aWR0aCA9IE1hdGgubWluKHdpZHRoLCBjdXRFeCAtIGN1dFN4KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjdXRTeSB8fCBjdXRFeSkge1xuICAgICAgICAgICAgaGVpZ2h0ID0gTWF0aC5taW4oaGVpZ2h0LCBjdXRFeSAtIGN1dFN5KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJlbmRlckluZm8ud2lkdGggPSB3aWR0aDtcbiAgICAgICAgcmVuZGVySW5mby5pbm5lcldpZHRoID0gaW5uZXJXaWR0aDtcbiAgICAgICAgcmVuZGVySW5mby5oZWlnaHQgPSBoZWlnaHQ7XG4gICAgICAgIHJlbmRlckluZm8uZm9udFNpemUgPSBmb250U2l6ZTtcbiAgICAgICAgcmVuZGVySW5mby5jdXRTeCA9IGN1dFN4O1xuICAgICAgICByZW5kZXJJbmZvLmN1dFN5ID0gY3V0U3k7XG4gICAgICAgIHJlbmRlckluZm8uY3V0RXggPSBjdXRFeDtcbiAgICAgICAgcmVuZGVySW5mby5jdXR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sgcmVuZGVySW5mby5vZmZzZXRZO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MudmVydGljYWxBbGlnbiA9PSAnbWlkZGxlJykge1xuICAgICAgICAgICAgICAgIGxpbmVQb3NpdGlvblkgKz0gKHJlbmRlckluZm8ubGluZUhlaWdodCAtIHJlbmRlckluZm8uZm9udFNpemUpIC8gMjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fc2V0dGluZ3MudmVydGljYWxBbGlnbiA9PSAnYm90dG9tJykge1xuICAgICAgICAgICAgICAgIGxpbmVQb3NpdGlvblkgKz0gcmVuZGVySW5mby5saW5lSGVpZ2h0IC0gcmVuZGVySW5mby5mb250U2l6ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLnRleHRBbGlnbiA9PT0gJ3JpZ2h0Jykge1xuICAgICAgICAgICAgICAgIGxpbmVQb3NpdGlvblggKz0gKHJlbmRlckluZm8uaW5uZXJXaWR0aCAtIHJlbmRlckluZm8ubGluZVdpZHRoc1tpXSk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX3NldHRpbmdzLnRleHRBbGlnbiA9PT0gJ2NlbnRlcicpIHtcbiAgICAgICAgICAgICAgICBsaW5lUG9zaXRpb25YICs9ICgocmVuZGVySW5mby5pbm5lcldpZHRoIC0gcmVuZGVySW5mby5saW5lV2lkdGhzW2ldKSAvIDIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGluZVBvc2l0aW9uWCArPSByZW5kZXJJbmZvLnBhZGRpbmdMZWZ0O1xuICAgICAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLnJ0bCkge1xuICAgICAgICAgICAgICAgIGxpbmVQb3NpdGlvblggKz0gcmVuZGVySW5mby5saW5lV2lkdGhzW2ldO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBkcmF3TGluZXMucHVzaCh7dGV4dDogcmVuZGVySW5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zLl9zZXR0aW5ncy5zaGFkb3dCbHVyICogcHJlY2lzaW9uO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fY29udGV4dC5maWxsU3R5bGUgPSBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodGhpcy5fc2V0dGluZ3MudGV4dENvbG9yKTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBkcmF3TGluZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgZHJhd0xpbmUgPSBkcmF3TGluZXNbaV07XG5cbiAgICAgICAgICAgIGlmIChyZW5kZXJJbmZvLmxldHRlclNwYWNpbmcgPT09IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KGRyYXdMaW5lLnRleHQsIGRyYXdMaW5lLngsIGRyYXdMaW5lLnkpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zdCB0ZXh0U3BsaXQgPSBkcmF3TGluZS50ZXh0LnNwbGl0KCcnKTtcbiAgICAgICAgICAgICAgICBsZXQgeCA9IGRyYXdMaW5lLng7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGogPSB0ZXh0U3BsaXQubGVuZ3RoOyBpIDwgajsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFRleHQodGV4dFNwbGl0W2ldLCB4LCBkcmF3TGluZS55KTtcbiAgICAgICAgICAgICAgICAgICAgeCArPSB0aGlzLm1lYXN1cmVUZXh0KHRleHRTcGxpdFtpXSwgcmVuZGVySW5mby5sZXR0ZXJTcGFjaW5nKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocHJldlNoYWRvd1NldHRpbmdzKSB7XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0NvbG9yID0gcHJldlNoYWR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dvcmRXaWR0aCA8IHdvcmRXcmFwV2lkdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgY3V0b2ZmSW5kZXggKz0gMTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBGaW5hbGx5LCB3aGVuIGJvdW5kIGlzIGNyb3NzZWQsIHJldHJhY3QgbGFzdCBsZXR0ZXIuXG4gICAgICAgICAgICAgICAgICAgIGN1dG9mZkluZGV4IC09MTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyogSWYgd3JhcFdpZHRoIGlzIHRvbyBzaG9ydCB0byBldmVuIGNvbnRhaW4gc3VmZml4IGFsb25lLCByZXR1cm4gZW1wdHkgc3RyaW5nICovXG4gICAgICAgIHJldHVybiB3b3JkLnN1YnN0cmluZygwLCBjdXRvZmZJbmRleCkgKyAod29yZFdyYXBXaWR0aCA+PSBzdWZmaXhXaWR0aCA/IHN1ZmZpeCA6ICcnKTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBTZWUge0BsaW5rIHdyYXBUZXh0fVxuICAgICAqXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IHRleHRcbiAgICAgKiBAcGFyYW0ge251bWJlcn0gd29yZFdyYXBXaWR0aFxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBsZXR0ZXJTcGFjaW5nXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IGluZGVudFxuICAgICAqIEByZXR1cm5zXG4gICAgICovXG4gICAgd3JhcFRleHQodGV4dCwgd29yZFdyYXBXaWR0aCwgbGV0dGVyU3BhY2luZywgaW5kZW50ID0gMCkge1xuICAgICAgICByZXR1cm4gd3JhcFRleHQodGhpcy5fY29udGV4dCwgdGV4dCwgd29yZFdyYXBXaWR0aCwgbGV0dGVyU3BhY2luZywgaW5kZW50KTtcbiAgICB9O1xuXG4gICAgL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gICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U3R5bGUsXG4gICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U2l6ZSxcbiAgICAgICAgICAgIHRoaXMuZ2V0UHJlY2lzaW9uKCksXG4gICAgICAgICAgICB0aGlzLl9zdGFnZS5nZXRPcHRpb24oJ2RlZmF1bHRGb250RmFjZScpXG4gICAgICAgICk7XG4gICAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IGZvbnQ7XG4gICAgICAgIHRoaXMuX2NvbnRleHQudGV4dEJhc2VsaW5lID0gdGhpcy5fc2V0dGluZ3MudGV4dEJhc2VsaW5lO1xuICAgICAgICByZXR1cm4gZm9udDtcbiAgICB9O1xuXG4gICAgX2xvYWQoKSB7XG4gICAgICAgIGlmIChVdGlscy5pc1dlYiAmJiBkb2N1bWVudC5mb250cykge1xuICAgICAgICAgICAgY29uc3QgZm9udFNldHRpbmcgPSBnZXRGb250U2V0dGluZyhcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250RmFjZSxcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U3R5bGUsXG4gICAgICAgICAgICAgICAgdGhpcy5fc2V0dGluZ3MuZm9udFNpemUsXG4gICAgICAgICAgICAgICAgdGhpcy5nZXRQcmVjaXNpb24oKSxcbiAgICAgICAgICAgICAgICB0aGlzLl9zdGFnZS5nZXRPcHRpb24oJ2RlZmF1bHRGb250RmFjZScpXG4gICAgICAgICAgICApO1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBpZiAoIWRvY3VtZW50LmZvbnRzLmNoZWNrKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBVc2UgYSBwcm9taXNlIHRoYXQgd2FpdHMgZm9yIGxvYWRpbmcuXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudC5mb250cy5sb2FkKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KS5jYXRjaChlcnIgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gSnVzdCBsb2FkIHRoZSBmYWxsYmFjayBmb250LlxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdGb250IGxvYWQgZXJyb3InLCBlcnIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgICAgICAgICAgfSkudGhlbigoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRvY3VtZW50LmZvbnRzLmNoZWNrKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybignRm9udCBub3QgZm91bmQnLCBmb250U2V0dGluZyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gY2F0Y2goZSkge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIkNhbid0IGNoZWNrIGZvbnQgbG9hZGluZyBmb3IgXCIgKyBmb250U2V0dGluZyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBkcmF3KCkge1xuICAgICAgICAvLyBXZSBkbyBub3QgdXNlIGEgcHJvbWlzZSBzbyB0aGF0IGxvYWRpbmcgaXMgcGVyZm9ybWVkIHN5bmNyb25vdXMgd2hlbiBwb3NzaWJsZS5cbiAgICAgICAgY29uc3QgbG9hZFByb21pc2UgPSB0aGlzLl9sb2FkKCk7XG4gICAgICAgIGlmICghbG9hZFByb21pc2UpIHtcbiAgICAgICAgICAgIHJldHVybiBVdGlscy5pc1NwYXJrID8gdGhpcy5fc3RhZ2UucGxhdGZvcm0uZHJhd1RleHQodGhpcykgOiB0aGlzLl9kcmF3KCk7XG4gICAgICAgIH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gbGV0IHdyYXBXaWR0aCA9IHJlbmRlckluZm8ud29yZFdyYXAgPyAocmVuZGVySW5mby53b3JkV3JhcFdpZHRoIHx8IHJlbmRlckluZm8ud2lkdGgpIDogcmVuZGVySW5mby53aWR0aDtcblxuICAgICAgICAvLyBUZXh0IG92ZXJmbG93XG4gICAgICAgIGlmIChyZW5kZXJJbmZvLnRleHRPdmVyZmxvdyAmJiAhcmVuZGVySW5mby53b3JkV3JhcCkge1xuICAgICAgICAgICAgbGV0IHN1ZmZpeDtcbiAgICAgICAgICAgIHN3aXRjaCAodGhpcy5fc2V0dGluZ3MudGV4dE92ZXJmbG93KSB7XG4gICAgICAgICAgICAgICAgY2FzZSAnY2xpcCc6XG4gICAgICAgICAgICAgICAgICAgIHN1ZmZpeCA9ICcnO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICdlbGxpcHNpcyc6XG4gICAgICAgICAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMuX3NldHRpbmdzLm1heExpbmVzU3VmZml4O1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICBzdWZmaXggPSB0aGlzLl9zZXR0aW5ncy50ZXh0T3ZlcmZsb3c7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0ZXh0ID0gdGhpcy53cmFwV29yZCh0ZXh0LCB3b3JkV3JhcFdpZHRoIHx8IHJlbmRlckluZm8udywgc3VmZml4KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRleHQgPSB0aGlzLnRva2VuaXplKHRleHQpO1xuICAgICAgICB0ZXh0ID0gdGhpcy5wYXJzZSh0ZXh0KTtcbiAgICAgICAgdGV4dCA9IHRoaXMubWVhc3VyZSh0ZXh0LCBsZXR0ZXJTcGFjaW5nLCByZW5kZXJJbmZvLmJhc2VGb250KTtcblxuICAgICAgICBpZiAocmVuZGVySW5mby50ZXh0SW5kZW50KSB7XG4gICAgICAgICAgICB0ZXh0ID0gdGhpcy5pbmRlbnQodGV4dCwgcmVuZGVySW5mby50ZXh0SW5kZW50KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChyZW5kZXJJbmZvLndvcmRCcmVhaykge1xuICAgICAgICAgICAgdGV4dCA9IHRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYy5jb25jYXQodGhpcy53b3JkQnJlYWsodCwgd3JhcFdpZHRoLCByZW5kZXJJbmZvLmJhc2VGb250KSksIFtdKVxuICAgICAgICAgICAgdGhpcy5yZXNldEZvbnRTdHlsZSgpXG4gICAgICAgIH1cblxuICAgICAgICAvLyBDYWxjdWxhdGUgZGV0YWlsZWQgZHJhd2luZyBpbmZvcm1hdGlvblxuICAgICAgICBsZXQgeCA9IHBhZGRpbmdMZWZ0O1xuICAgICAgICBsZXQgbGluZU5vID0gMDtcblxuICAgICAgICBmb3IgKGNvbnN0IHQgb2YgdGV4dCkge1xuICAgICAgICAgICAgLy8gV3JhcCB0ZXh0XG4gICAgICAgICAgICBpZiAocmVuZGVySW5mby53b3JkV3JhcCAmJiB4ICsgdC53aWR0aCA+IHdyYXBXaWR0aCB8fCB0LnRleHQgPT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICB4ID0gcGFkZGluZ0xlZnQ7XG4gICAgICAgICAgICAgICAgbGluZU5vICs9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0LmxpbmVObyA9IGxpbmVObztcblxuICAgICAgICAgICAgaWYgKHQudGV4dCA9PSAnXFxuJykge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0LnggPSB4O1xuICAgICAgICAgICAgeCArPSB0LndpZHRoO1xuICAgICAgICB9XG4gICAgICAgIHJlbmRlckluZm8ubGluZU51bSA9IGxpbmVObyArIDE7XG5cbiAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLmgpIHtcbiAgICAgICAgICA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XG4gICAgICAgIC8vIFZlcnRpY2FsIGFsaWduXG4gICAgICAgIGxldCB2YU9mZnNldCA9IDA7XG4gICAgICAgIGlmIChyZW5kZXJJbmZvLnZlcnRpY2FsQWxpZ24gPT0gJ3RvcCcgJiYgdGhpcy5fY29udGV4dC50ZXh0QmFzZWxpbmUgPT0gJ2FscGhhYmV0aWMnKSB7XG4gICAgICAgICAgICB2YU9mZnNldCA9IC1iYXNlbGluZU9mZnNldEluUHg7XG4gICAgICAgIH0gZWxzZSBpZiAocmVuZGVySW5mby52ZXJ0aWNhbEFsaWduID09ICdtaWRkbGUnKSB7XG4gICAgICAgICAgICB2YU9mZnNldCA9IChyZW5kZXJJbmZvLmxpbmVIZWlnaHQgLSByZW5kZXJJbmZvLmZvbnRTaXplIC0gYmFzZWxpbmVPZmZzZXRJblB4KSAvIDI7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5fc2V0dGluZ3MudmVydGljYWxBbGlnbiA9PSAnYm90dG9tJykge1xuICAgICAgICAgICAgdmFPZmZzZXQgPSByZW5kZXJJbmZvLmxpbmVIZWlnaHQgLSByZW5kZXJJbmZvLmZvbnRTaXplO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gQ2FsY3VsYXRlIGxpbmVzIGluZm9ybWF0aW9uXG4gICAgICAgIHJlbmRlckluZm8ubGluZXMgPSBbXVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHJlbmRlckluZm8ubGluZU51bTsgaSsrKSB7XG4gICAgICAgICAgICByZW5kZXJJbmZvLmxpbmVzW2ldID0ge1xuICAgICAgICAgICAgICAgIHdpZHRoOiAwLFxuICAgICAgICAgICAgICAgIHg6IDAsXG4gICAgICAgICAgICAgICAgeTogcmVuZGVySW5mby5saW5lSGVpZ2h0ICogaSArIHZhT2Zmc2V0LFxuICAgICAgICAgICAgICAgIHRleHQ6IFtdLFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChsZXQgdCBvZiB0ZXh0KSB7XG4gICAgICAgICAgICByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS50ZXh0LnB1c2godCk7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBGaWx0ZXIgb3V0IHdoaXRlIHNwYWNlcyBhdCBiZWdpbm5pbmcgYW5kIGVuZCBvZiBlYWNoIGxpbmVcbiAgICAgICAgZm9yIChjb25zdCBsIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgICAgIGlmIChsLnRleHQubGVuZ3RoID09IDApIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29uc3QgZmlyc3RXb3JkID0gbC50ZXh0WzBdLnRleHQ7XG4gICAgICAgICAgICBjb25zdCBsYXN0V29yZCA9IGwudGV4dFtsLnRleHQubGVuZ3RoIC0gMV0udGV4dDtcblxuICAgICAgICAgICAgaWYgKGZpcnN0V29yZCA9PSAnXFxuJykge1xuICAgICAgICAgICAgICAgIGwudGV4dC5zaGlmdCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGlzU3BhY2UobGFzdFdvcmQpIHx8IGxhc3RXb3JkID09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgbC50ZXh0LnBvcCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cblxuICAgICAgICAvLyBDYWxjdWxhdGUgbGluZSB3aWR0aFxuICAgICAgICBmb3IgKGxldCBsIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgICAgIGwud2lkdGggPSBsLnRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYyArIHQud2lkdGgsIDApO1xuICAgICAgICB9XG5cbiAgICAgICAgcmVuZGVySW5mby53aWR0aCA9IHRoaXMuX3NldHRpbmdzLncgIT0gMCA/IHRoaXMuX3NldHRpbmdzLncgKiBwcmVjaXNpb24gOiBNYXRoLm1heCguLi5yZW5kZXJJbmZvLmxpbmVzLm1hcCgobCkgPT4gbC53aWR0aCkpICsgcGFkZGluZ1JpZ2h0O1xuICAgICAgICByZW5kZXJJbmZvLncgPSByZW5kZXJJbmZvLndpZHRoO1xuXG4gICAgICAgIC8vIEFwcGx5IG1heExpbmVzU3VmZml4XG4gICAgICAgIGlmIChyZW5kZXJJbmZvLm1heExpbmVzICYmIHJlbmRlckluZm8ubGluZU51bSA+IHJlbmRlckluZm8ubWF4TGluZXMgJiYgcmVuZGVySW5mby5tYXhMaW5lc1N1ZmZpeCkge1xuICAgICAgICAgICAgY29uc3QgaW5kZXggPSByZW5kZXJJbmZvLm1heExpbmVzIC0gMTtcbiAgICAgICAgICAgIGxldCBsYXN0TGluZVRleHQgPSB0ZXh0LmZpbHRlcigodCkgPT4gdC5saW5lTm8gPT0gaW5kZXgpXG4gICAgICAgICAgICBsZXQgc3VmZml4ID0gcmVuZGVySW5mby5tYXhMaW5lc1N1ZmZpeDtcbiAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMudG9rZW5pemUoc3VmZml4KTtcbiAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMucGFyc2Uoc3VmZml4KTtcbiAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMubWVhc3VyZShzdWZmaXgsIHJlbmRlckluZm8ubGV0dGVyU3BhY2luZywgcmVuZGVySW5mby5iYXNlRm9udCk7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IHMgb2Ygc3VmZml4KSB7XG4gICAgICAgICAgICAgICAgcy5saW5lTm8gPSBpbmRleDtcbiAgICAgICAgICAgICAgICBzLnggPSAwO1xuICAgICAgICAgICAgICAgIGxhc3RMaW5lVGV4dC5wdXNoKHMpXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNvbnN0IHNwbCA9IHN1ZmZpeC5sZW5ndGggKyAxXG4gICAgICAgICAgICBsZXQgX3cgPSBsYXN0TGluZVRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYyArIHQud2lkdGgsIDApO1xuICAgICAgICAgICAgd2hpbGUgKF93ID4gcmVuZGVySW5mby53aWR0aCB8fCBpc1NwYWNlKGxhc3RMaW5lVGV4dFtsYXN0TGluZVRleHQubGVuZ3RoIC0gc3BsXS50ZXh0KSkge1xuICAgICAgICAgICAgICAgIGxhc3RMaW5lVGV4dC5zcGxpY2UobGFzdExpbmVUZXh0Lmxlbmd0aCAtIHNwbCwgMSk7XG4gICAgICAgICAgICAgICAgX3cgPSBsYXN0TGluZVRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYyArIHQud2lkdGgsIDApO1xuICAgICAgICAgICAgICAgIGlmIChsYXN0TGluZVRleHQubGVuZ3RoIDwgc3BsKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuYWxpZ25MaW5lKGxhc3RMaW5lVGV4dCwgbGFzdExpbmVUZXh0WzBdLngpXG5cbiAgICAgICAgICAgIHJlbmRlckluZm8ubGluZXNbaW5kZXhdLnRleHQgPSBsYXN0TGluZVRleHQ7XG4gICAgICAgICAgICByZW5kZXJJbmZvLmxpbmVzW2luZGV4XS53aWR0aCA9IF93O1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gSG9yaXpvbnRhbCBhbGlnbm1lbnQgb2Zmc2V0XG4gICAgICAgIGlmIChyZW5kZXJJbmZvLnRleHRBbGlnbiA9PSAnY2VudGVyJykge1xuICAgICAgICAgICAgZm9yIChsZXQgbCBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgICAgICAgICAgbC54ID0gKHJlbmRlckluZm8ud2lkdGggLSBsLndpZHRoIC0gcGFkZGluZ0xlZnQpIC8gMjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmIChyZW5kZXJJbmZvLnRleHRBbGlnbiA9PSAncmlnaHQnKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBsIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgIC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0IGN1cnJlbnRDb2xvciA9IGRlZmF1bHRDb2xvcjtcbiAgICAgICAgdGhpcy5fY29udGV4dC5maWxsU3R5bGUgPSBkZWZhdWx0Q29sb3I7XG4gICAgICAgIGZvciAoY29uc3QgbGluZSBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IHQgb2YgbGluZS50ZXh0KSB7XG4gICAgICAgICAgICAgICAgbGV0IGx4ID0gMDtcblxuICAgICAgICAgICAgICAgIGlmICh0LnRleHQgPT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKHJlbmRlckluZm8ubWF4TGluZXMgJiYgdC5saW5lTm8gPj0gcmVuZGVySW5mby5tYXhMaW5lcykge1xuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAodC5jb2xvciAhPSBjdXJyZW50Q29sb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudENvbG9yID0gdC5jb2xvcjtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsU3R5bGUgPSBjdXJyZW50Q29sb3I7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdGhpcy5fY29udGV4dC5mb250ID0gdC5mb250U3R5bGU7XG5cbiAgICAgICAgICAgICAgICAvLyBEcmF3IHdpdGggbGV0dGVyIHNwYWNpbmdcbiAgICAgICAgICAgICAgICBpZiAodC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGwgb2YgdC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBfeCA9IHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnggKyB0LnggKyBseDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFRleHQobC50ZXh0LCBfeCwgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueSArIHJlbmRlckluZm8uZm9udFNpemUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbHggKz0gbC53aWR0aDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIC8vIFN0YW5kYXJkIGRyYXdpbmdcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBfeCA9IHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnggKyB0Lng7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFRleHQodC50ZXh0LCBfeCwgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueSArIHJlbmRlckluZm8uZm9udFNpemUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFJlc2V0IHRleHQgc2hhZG93XG4gICAgICAgIGlmIChwcmV2U2hhZG93U2V0dGluZ3MpIHtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Q29sb3IgPSBwcmV2U2hhZG93U2V0dGluZ3NbMF07XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFggPSBwcmV2U2hhZG93U2V0dGluZ3NbMV07XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFkgPSBwcmV2U2hhZG93U2V0dGluZ3NbMl07XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0JsdXIgPSBwcmV2U2hhZG93U2V0dGluZ3NbM107XG4gICAgICAgIH1cblxuICAgICAgICAvLyBSZXNldCBjdXQgdHJhbnNsYXRpb25cbiAgICAgICAgaWYgKHJlbmRlckluZm8uY3V0U3ggfHwgcmVuZGVySW5mby5jdXRTeSkge1xuICAgICAgICAgICAgdGhp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h0b2tlbnMpIHtcbiAgICAgICAgbGV0IGl0YWxpYyA9IDA7XG4gICAgICAgIGxldCBib2xkID0gMDtcbiAgICAgICAgbGV0IGNvbG9yU3RhY2sgPSBbU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHRoaXMuX3NldHRpbmdzLnRleHRDb2xvcildO1xuICAgICAgICBsZXQgY29sb3IgPSAwO1xuXG4gICAgICAgIGNvbnN0IGNvbG9yUmVnZXhwID0gLzxjb2xvcj0oMFt4WF1bMC05YS1mQS1GXXs4fSk+LztcblxuICAgICAgICByZXR1cm4gdG9rZW5zLm1hcCgodCkgPT4ge1xuICAgICAgICAgICAgaWYgKHQgPT0gJzxpPicpIHtcbiAgICAgICAgICAgICAgICBpdGFsaWMgKz0gMTtcbiAgICAgICAgICAgICAgICB0ID0gJyc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHQgPT0gJzwvaT4nICYmIGl0YWxpYyA+IDApIHtcbiAgICAgICAgICAgICAgICBpdGFsaWMgLT0gMTtcbiAgICAgICAgICAgICAgICB0ID0gJyc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHQgPT0gJzxiPicpIHtcbiAgICAgICAgICAgICAgICBib2xkICs9IDE7XG4gICAgICAgICAgICAgICAgdCA9ICcnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09ICc8L2I+JyAmJiBib2xkID4gMCkge1xuICAgICAgICAgICAgICAgIGJvbGQgLT0gMTtcbiAgICAgICAgICAgICAgICB0ID0gJyc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHQgPT0gJzwvY29sb3I+Jykge1xuICAgICAgICAgICAgICAgIGlmIChjb2xvclN0YWNrLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgY29sb3IgLT0gMTtcbiAgICAgICAgICAgICAgICAgICAgY29sb3JTdGFjay5wb3AoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdCA9ICcnO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChjb2xvclJlZ2V4cC50ZXN0KHQpKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbWF0Y2hlZCA9IGNvbG9yUmVnZXhwLmV4ZWModCk7XG4gICAgICAgICAgICAgICAgY29sb3JTdGFjay5wdXNoKFxuICAgICAgICAgICAgICAgICAgICBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcocGFyc2VJbnQobWF0Y2hlZFsxXSkpXG4gICAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgICAgICBjb2xvciArPSAxO1xuICAgICAgICAgICAgICAgIHQgPSAnJztcblxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHRleHQ6IHQsXG4gICAgICAgICAgICAgICAgaXRhbGljOiBpdGFsaWMsXG4gICAgICAgICAgICAgICAgYm9sZDogYm9sZCxcbiAgICAgICAgICAgICAgICBjb2xvcjogY29sb3JTdGFja1tjb2xvcl0sXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pXG4gICAgICAgIC5maWx0ZXIoKG8pID0+IG8udGV4dCAhPSAnJyk7XG4gICAgfVxuXG4gICAgYXBwbHlGb250U3R5bGUod29yZCwgYmFzZUZvbnQpIHtcbiAgICAgICAgbGV0IGZvbnQgPSBiYXNlRm9udDtcbiAgICAgICAgaWYgKHdvcmQuYm9sZCkge1xuICAgICAgICAgICAgZm9udCA9ICdib2xkICcgKyBmb250O1xuICAgICAgICB9XG4gICAgICAgIGlmICh3b3JkLml0YWxpYykge1xuICAgICAgICAgICAgZm9udCA9ICdpdGFsaWMgJyArIGZvbnQ7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fY29udGV4dC5mb250ID0gZm9udFxuICAgICAgICB3b3JkLmZvbnRTdHlsZSA9IGZvbnQ7XG4gICAgfVxuXG4gICAgcmVzZXRGb250U3R5bGUoYmFzZUZvbnQpIHtcbiAgICAgICAgdGhpcy5fY29udGV4dC5mb250ID0gYmFzZUZv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B7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAvKiBJbiBjYXNlIGd1ZXNzIHdhcyB1bmRlcmVzdGltYXRlZCwgZXh0ZW5kIGl0IGxldHRlciBieSBsZXR0ZXIuICovXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB3aGlsZSAoY3V0b2ZmSW5kZXggPCB3b3JkTGVuKSB7XG4gICAgICAgICAgICAgICAgdHJ1bmNXb3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQuc3Vic3RyaW5nKDAsIGN1dG9mZkluZGV4KSkgKyBzdWZmaXhXaWR0aDtcbiAgICAgICAgICAgICAgICBpZiAodHJ1bmNXb3JkV2lkdGggPCB3b3JkV3JhcFdpZHRoKSB7XG4gICAgICAgICAgICAgICAgICAgIGN1dG9mZkluZGV4ICs9IDE7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmluYWxseSwgd2hlbiBib3VuZCBpcyBjcm9zc2VkLCByZXRyYWN0IGxhc3QgbGV0dGVyLlxuICAgICAgICAgICAgICAgICAgICBjdXRvZmZJbmRleCAtPTE7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8qIElmIHdyYXBXaWR0aCBpcyB0b28gc2hvcnQgdG8gZXZlbiBjb250YWluIHN1ZmZpeCBhbG9uZSwgcmV0dXJuIGVtcHR5IHN0cmluZyAqL1xuICAgICAgICByZXR1cm4gd29yZC5zdWJzdHJpbmcoMCwgY3V0b2ZmSW5kZXgpICsgKHdvcmRXcmFwV2lkdGggPj0gc3VmZml4V2lkdGggPyBzdWZmaXggOiAnJylcbiAgICB9XG5cbiAgICBfZ2V0QnJlYWtJbmRleCh3b3JkLCB3aWR0aCkge1xuICAg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HRlci4gKi9cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHdoaWxlIChicmVha0luZGV4IDwgd29yZExlbikge1xuICAgICAgICAgICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSk7XG4gICAgICAgICAgICAgICAgaWYgKHRydW5jV29yZFdpZHRoIDwgd2lkdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWtJbmRleCArPSAxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZpbmFsbHksIHdoZW4gYm91bmQgaXMgY3Jvc3NlZCwgcmV0cmFjdCBsYXN0IGxldHRlci5cbiAgICAgICAgICAgICAgICAgICAgYnJlYWtJbmRleCAtPTE7XG4gICAgICAgICAgICAgICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSk7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4ge2JyZWFrSW5kZXgsIHRydW5jV29yZFdpZHRofTtcblxuICAgIH1cblxuICAgIHdvcmRCcmVhayh3b3JkLCB3aWR0aCwgYmFzZUZvbnQpIHtcbiAgICAgICAgaWYgKCF3b3JkLnRleHQpIHtcbiAgICAgICAgICAgIHJldHVybiB3b3JkXG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5hcHBseUZvbnRTdHlsZSh3b3JkLCBiYXNlRm9udClcbiAgICAgICAgY29uc3QgcGFydHMgPSBbXTtcbiAgICAgICAgbGV0IHRleHQgPSB3b3JkLnRleHQ7XG4gICAgICAgIGlmICghd29yZC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICB3aGlsZSAodHJ1ZSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHticmVha0luZGV4LCB0cnVuY1dvcmRXaWR0aH0gPSB0aGlzLl9nZXRCcmVha0luZGV4KHRleHQsIHdpZHRoKTtcbiAgICAgICAgICAgICAgICBwYXJ0cy5wdXNoKHsuLi53b3JkfSk7XG4gICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0udGV4dCA9IHRleHQuc2xpY2UoMCwgYnJlYWtJbmRleCk7XG4gICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ud2lkdGggPSB0cnVuY1dvcmRXaWR0aDtcblxuICAgICAgICAgICAgICAgIGlmIChicmVha0luZGV4ID09PSB0ZXh0Lmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0ZXh0ID0gdGV4dC5zbGljZShicmVha0luZGV4KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxldCB0b3RhbFdpZHRoID0gMDtcbiAgICAgICAgICAgIGxldCBsZXR0ZXJzID0gW107XG4gICAgICAgICAgICBsZXQgYnJlYWtJbmRleCA9IDA7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGwgb2Ygd29yZC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRvdGFsV2lkdGggKyBsLndpZHRoID49IHdpZHRoKSB7XG4gICAgICAgICAgICAgICAgICAgIHBhcnRzLnB1c2goey4uLndvcmR9KTtcbiAgICAgICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0udGV4dCA9IHRleHQuc2xpY2UoMCwgYnJlYWtJbmRleCk7XG4gICAgICAgICAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLndpZHRoID0gdG90YWxXaWR0aDtcbiAgICAgICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ubGV0dGVycyA9IGxldHRlcnM7XG4gICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnNsaWNlKGJyZWFrSW5kZXgpO1xuICAgICAgICAgICAgICAgICAgICB0b3RhbFdpZHRoID0gMDtcbiAgICAgICAgICAgICAgICAgICAgbGV0dGVycyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICBicmVha0luZGV4ID0gMDtcblxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrSW5kZXggKz0gMTtcbiAgICAgICAgICAgICAgICAgICAgbGV0dGVycy5wdXNoKGwpO1xuICAgICAgICAgICAgICAgICAgICB0b3RhbFdpZHRoICs9IGwud2lkdGg7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodG90YWxXaWR0aCA+IDApIHtcbiAgICAgICAgICAgICAgICBwYXJ0cy5wdXNoKHsuLi53b3JkfSk7XG4gICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0udGV4dCA9IHRleHQuc2xpY2UoMCwgYnJlYWtJbmRleCk7XG4gICAgICAgICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ud2lkdGggPSB0b3RhbFdpZHRoO1xuICAgICAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLmxldHRlcnMgPSBsZXR0ZXJzO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHBhcnRzO1xuICAgIH1cblxuICAgIGFsaWduTGluZShwYXJzZWQsIGluaXRpYWxYID0gMCkge1xuICAgICAgICBsZXQgcHJldldpZHRoID0gMDtcbiAgICAgICAgbGV0IHByZXZYID0gaW5pdGlhbFg7XG4gICAgICAgIGZvciAoY29uc3Qgd29yZCBvZiBwYXJzZWQpIHtcbiAgICAgICAgICAgIGlmICh3b3JkLnRleHQgPT0gJ1xcbicpIHtcbiAgICAgICA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ICAgICAgIGxldCBzcGFjZXMgPSBsaW5lc1tpXS5tYXRjaChzcGFjZVJlZ2V4KSB8fCBbXTtcbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB3b3Jkcy5sZW5ndGg7IGorKykge1xuICAgICAgICAgICAgY29uc3Qgc3BhY2UgPSBzcGFjZXNbaiAtIDFdIHx8ICcnO1xuICAgICAgICAgICAgY29uc3Qgd29yZCA9IHdvcmRzW2pdO1xuICAgICAgICAgICAgY29uc3Qgd29yZFdpZHRoID0gbWVhc3VyZVRleHQoY29udGV4dCwgd29yZCwgbGV0dGVyU3BhY2luZyk7XG4gICAgICAgICAgICBjb25zdCB3b3JkV2lkdGhXaXRoU3BhY2UgPSB3b3JkV2lkdGggKyBtZWFzdXJlVGV4dChjb250ZXh0LCBzcGFjZSwgbGV0dGVyU3BhY2luZyk7XG4gICAgICAgICAgICBpZiAoaiA9PT0gMCB8fCB3b3JkV2lkdGhXaXRoU3BhY2UgPiBzcGFjZUxlZnQpIHtcbiAgICAgICAgICAgICAgICAvLyBTa2lwIHByaW50aW5nIHRoZSBuZXdsaW5lIGlmIGl0J3MgdGhlIGZpcnN0IHdvcmQgb2YgdGhlIGxpbmUgdGhhdCBpcy5cbiAgICAgICAgICAgICAgICAvLyBncmVhdGVyIHRoYW4gdGhlIHdvcmQgd3JhcCB3aWR0aC5cbiAgICAgICAgICAgICAgICBpZiAoaiA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0TGluZXMucHVzaChyZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSAnJztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmVzdWx0ICs9IHdvcmQ7XG4gICAgICAgICAgICAgICAgc3BhY2VMZWZ0ID0gd29yZFdyYXBXaWR0aCAtIHdvcmRXaWR0aCAtIChqID09PSAwID8gaW5kZW50IDogMCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAg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IG47XG4gICAgICAgIGlmICghVXRpbHMuaXNPYmplY3RMaXRlcmFsKGRlZikpIHtcbiAgICAgICAgICAgIGRlZiA9IHswOiBkZWZ9XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgZGVmYXVsdFNtb290aG5lc3MgPSAwLjU7XG5cbiAgICAgICAgbGV0IGl0ZW1zID0gW107XG4gICAgICAgIGZvciAobGV0IGtleSBpbiBkZWYpIHtcbiAgICAgICAgICAgIGlmIChkZWYuaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgICAgICAgIGxldCBvYmogPSBkZWZba2V5XTtcbiAgICAgICAgICAgICAgICBpZiAoIVV0aWxzLmlzT2JqZWN0TGl0ZXJhbChvYmopKSB7XG4gICAgICAgICAgICAgICAgICAgIG9iaiA9IHt2OiBvYmp9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgbGV0IHAgPSBwYXJzZUZsb2F0KGtleSk7XG5cbiAgICAgICAgICAgICAgICBpZiAoa2V5ID09PSBcInNtXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFNtb290aG5lc3MgPSBvYmoudjtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFpc05hTihwKSAmJiBwID49IDAgJiYgcCA8PSAyKSB7XG4gICAgICAgICAgICAgICAgICAgIG9iai5wID0gcDtcblxuICAgICAgICAgICAgICAgICAgICBvYmouZiA9IFV0aWxzLmlzRnVuY3Rpb24ob2JqLnYpO1xuICAgICAgICAgICAgICAgICAgICBvYmoubHYgPSBvYmouZiA/IG9iai52KDAsIDApIDogb2JqLnY7XG5cbiAgICAgICAgICAgICAgICAgICAgaXRlbXMucHVzaChvYmopO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFNvcnQgYnkgcHJvZ3Jlc3MgdmFsdWUuXG4gICAgICAgIGl0ZW1zID0gaXRlbXMuc29ydChmdW5jdGlvbihhLCBiKSB7cmV0dXJuIGEucCAtIGIucH0pO1xuXG4gICAgICAgIG4gPSBpdGVtcy5sZW5ndGg7XG5cbiAgICAgICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbGV0IGxhc3QgPSAoaSA9PT0gbiAtIDEpO1xuICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eSgncGUnKSkge1xuICAgICAgICAgICAgICAgIC8vIFByb2dyZXNzLlxuICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnBlID0gbGFzdCA/IChpdGVtc1tpXS5wIDw9IDEgPyAxIDogMiAvKiBzdXBwb3J0IG9uZXRvdHdvIHN0b3AgKi8pIDogaXRlbXNbaSArIDFdLnA7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIFByZXZlbnQgbXVsdGlwbGUgaXRlbXMgYXQgdGhlIHNhbWUgdGltZS5cbiAgICAgICAgICAgICAgICBjb25zdCBtYXggPSBpIDwgbiAtIDEgPyBpdGVtc1tpICsgMV0ucCA6IDE7XG4gICAgICAgICAgICAgICAgaWYgKGl0ZW1zW2ldLnBlID4gbWF4KSB7XG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnBlID0gbWF4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpdGVtc1tpXS5wZSA9PT0gaXRlbXNbaV0ucCkge1xuICAgICAgICAgICAgICAgIGl0ZW1zW2ldLmlkcCA9IDA7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGl0ZW1zW2ldLmlkcCA9IDEgLyAoaXRlbXNbaV0ucGUgLSBpdGVtc1tpXS5wKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIENvbG9yIG1lcmdlcjogd2UgbmVlZCB0byBzcGxpdC9jb21iaW5lIFJHQkEgY29tcG9uZW50cy5cblxuICAgICAgICAvLyBDYWxjdWxhdGUgYmV6aWVyIGhlbHBlciB2YWx1ZXMuO1xuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KCdzbScpKSB7XG4gICAgICAgICAgICAgICAgLy8gU21vb3RobmVzcy47XG4gICAgICAgICAgICAgICAgaXRlbXNbaV0uc20gPSBkZWZhdWx0U21vb3RobmVzcztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoJ3MnKSkge1xuICAgICAgICAgICAgICAgIC8vIFNsb3BlLjtcbiAgICAgICAgICAgICAgICBpZiAoaSA9PT0gMCB8fCBpID09PSBuIC0gMSB8fCAoaXRlbXNbaV0ucCA9PT0gMSAvKiBmb3Igb25ldG90d28gKi8pKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEhvcml6b250YWwgc2xvcGUgYXQgc3RhcnQgYW5kIGVuZC47XG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnMgPSByZ2JhID8gWzAsIDAsIDAsIDBdIDogMDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBwaSA9IGl0ZW1zW2kgLSAxXTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbmkgPSBpdGVtc1tpICsgMV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChwaS5wID09PSBuaS5wKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gcmdiYSA/IFswLCAwLCAwLCAwXSA6IDA7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocmdiYSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5jID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHMobmkubHYpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBjID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHMocGkubHYpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSAxIC8gKG5pLnAgLSBwaS5wKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gW1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkICogKG5jWzBdIC0gcGNbMF0pLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkICogKG5jWzFdIC0gcGNbMV0pLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkICogKG5jWzJdIC0gcGNbMl0pLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkICogKG5jWzNdIC0gcGNbM10pXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IChuaS5sdiAtIHBpLmx2KSAvIChuaS5wIC0gcGkucCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbiAtIDE7IGkrKykge1xuICAgICAgICAgICAgLy8gQ2FsY3VsYXRlIHZhbHVlIGZ1bmN0aW9uLjtcbiAgICAgICAgICAgIGlmICghaXRlbXNbaV0uZikge1xuXG4gICAgICAgICAgICAgICAgbGV0IGxhc3QgPSAoaSA9PT0gbiAtIDEpO1xuICAgICAgICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoJ3ZlJykpIHtcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0udmUgPSBsYXN0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VzaChpdGVtLnNtIHx8IDApO1xuICAgICAgICB0aGlzLl9zLnB1c2goaXRlbS5zIHx8IDApO1xuICAgICAgICB0aGlzLl92ZS5wdXNoKGl0ZW0udmUgfHwgMCk7XG4gICAgICAgIHRoaXMuX3NtZS5wdXNoKGl0ZW0uc21lIHx8IDApO1xuICAgICAgICB0aGlzLl9zZS5wdXNoKGl0ZW0uc2UgfHwgMCk7XG4gICAgICAgIHRoaXMuX2xlbmd0aCsrO1xuICAgIH1cblxuICAgIF9nZXRJdGVtKHApIHtcbiAgICAgICAgY29uc3QgbiA9IHRoaXMuX2xlbmd0aDtcbiAgICAgICAgaWYgKCFuKSB7XG4gICAgICAgICAgICByZXR1cm4gLTE7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocCA8IHRoaXMuX3BbMF0pIHtcbiAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9wW2ldIDw9IHAgJiYgcCA8IHRoaXMuX3BlW2ldKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gbiAtIDE7XG4gICAgfVxuXG4gICAgZ2V0VmFsdWUocCkge1xuICAgICAgICBjb25zdCBpID0gdGhpcy5fZ2V0SXRlbShwKTtcbiAgICAgICAgaWYgKGkgPT09IC0xKSB7XG4gICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuX2ZbaV0pIHtcbiAgICAgICAgICAgICAgICBjb25zdCBvID0gTWF0aC5taW4oMSwgTWF0aC5tYXgoMCwgKHAgLSB0aGlzLl9wW2ldKSAqIHRoaXMuX2lkcFtpXSkpO1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl92W2ldKG8pO1xuICA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VybiB2MiAqIHAgKyB2MSAqICgxIC0gcCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIChwKSB7XG4gICAgICAgICAgICAgICAgaWYgKHAgPT09IDApIHJldHVybiB2MTtcbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gMSkgcmV0dXJuIHYyO1xuICAgICAgICAgICAgICAgIHJldHVybiBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVycywgcCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHN0YXRpYyBnZXRTcGxpbmVSZ2JhVmFsdWVGdW5jdGlvbih2MSwgdjIsIHAxLCBwMiwgbzEsIGkyLCBzMSwgczIpIHtcbiAgICAgICAgLy8gTm9ybWFsaXplIHNsb3BlcyBiZWNhdXNlIHdlIHVzZSBhIHNwbGluZSB0aGF0IGdvZXMgZnJvbSAwIHRvIDEuXG4gICAgICAgIGxldCBkcCA9IHAyIC0gcDE7XG4gICAgICAgIHMxWzBdICo9IGRwO1xuICAgICAgICBzMVsxXSAqPSBkcDtcbiAgICAgICAgczFbMl0gKj0gZHA7XG4gICAgICAgIHMxWzNdICo9IGRwO1xuICAgICAgICBzMlswXSAqPSBkcDtcbiAgICAgICAgczJbMV0gKj0gZHA7XG4gICAgICAgIHMyWzJdICo9IGRwO1xuICAgICAgICBzMlszXSAqPSBkcDtcblxuICAgICAgICBsZXQgY3YxID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHModjEpO1xuICAgICAgICBsZXQgY3YyID0gTXVsdGlTcGxpbmUuZ2V0UmdiYUNvbXBvbmVudHModjIpO1xuXG4gICAgICAgIGxldCBoZWxwZXJzID0gW1xuICAgICAgICAgICAgTXVsdGlTcGxpbmUuZ2V0U3BsaW5lSGVscGVycyhjdjFbMF0sIGN2MlswXSwgbzEsIGkyLCBzMVswXSwgczJbMF0pLFxuICAgICAgICAgICAgTXVsdGlTcGxpbmUuZ2V0U3BsaW5lSGVscGVycyhjdjFbMV0sIGN2MlsxXSwgbzEsIGkyLCBzMVsxXSwgczJbMV0pLFxuICAgICAgICAgICAgTXVsdGlTcGxpbmUuZ2V0U3BsaW5lSGVscGVycyhjdjFbMl0sIGN2MlsyXSwgbzEsIGkyLCBzMVsyXSwgczJbMl0pLFxuICAgICAgICAgICAgTXVsdGlTcGxpbmUuZ2V0U3BsaW5lSGVscGVycyhjdjFbM10sIGN2MlszXSwgbzEsIGkyLCBzMVszXSwgczJbM10pXG4gICAgICAgIF07XG5cbiAgICAgICAgaWYgKCFoZWxwZXJzWzBdKSB7XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHApIHtcbiAgICAgICAgICAgICAgICAvLyBMaW5lYXIuXG4gICAgICAgICAgICAgICAgaWYgKHAgPT09IDApIHJldHVybiB2MTtcbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gMSkgcmV0dXJuIHYyO1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIE11bHRpU3BsaW5lLm1lcmdlQ29sb3JzKHYyLCB2MSwgcCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIChwKSB7XG4gICAgICAgICAgICAgICAgaWYgKHAgPT09IDApIHJldHVybiB2MTtcbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gMSkgcmV0dXJuIHYyO1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIE11bHRpU3BsaW5lLmdldEFyZ2JOdW1iZXIoW1xuICAgICAgICAgICAgICAgICAgICBNYXRoLm1pbigyNTUsIE11bHRpU3BsaW5lLmNhbGN1bGF0ZVNwbGluZShoZWxwZXJzWzBdLCBwKSksXG4gICAgICAgICAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbMV0s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XRTcGxpbmVIZWxwZXJzKHYxLCB2MiwgbzEsIGkyLCBzMSwgczIpIHtcbiAgICAgICAgaWYgKCFvMSAmJiAhaTIpIHtcbiAgICAgICAgICAgIC8vIExpbmVhci5cbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gQ3ViaWMgYmV6aWVyIHBvaW50cy5cbiAgICAgICAgLy8gaHR0cDovL2N1YmljLWJlemllci5jb20vXG4gICAgICAgIGxldCBjc3ggPSBvMTtcbiAgICAgICAgbGV0IGNzeSA9IHYxICsgczEgKiBvMTtcbiAgICAgICAgbGV0IGNleCA9IDEgLSBpMjtcbiAgICAgICAgbGV0IGNleSA9IHYyIC0gczIgKiBpMjtcblxuICAgICAgICBsZXQgeGEgPSAzICogY3N4IC0gMyAqIGNleCArIDE7XG4gICAgICAgIGxldCB4YiA9IC02ICogY3N4ICsgMyAqIGNleDtcbiAgICAgICAgbGV0IHhjID0gMyAqIGNzeDtcblxuICAgICAgICBsZXQgeWEgPSAzICogY3N5IC0gMyAqIGNleSArIHYyIC0gdjE7XG4gICAgICAgIGxldCB5YiA9IDMgKiAoY2V5ICsgdjEpIC0gNiAqIGNzeTtcbiAgICAgICAgbGV0IHljID0gMyAqIChjc3kgLSB2MSk7XG4gICAgICAgIGxldCB5ZCA9IHYxO1xuXG4gICAgICAgIHJldHVybiBbeGEsIHhiLCB4YywgeWEsIHliLCB5YywgeWRdO1xuICAgIH07XG5cbiAgICAvKipcbiAgICAgKiBDYWxjdWxhdGVzIHRoZSBpbnRlcm1lZGlhdGUgc3BsaW5lIHZhbHVlIGJhc2VkIG9uIHRoZSBzcGVjaWZpZWQgaGVscGVycy5cbiAgICAgKiBAcGFyYW0ge251bWJlcltdfSBoZWxwZXJzXG4gICAgICogICBPYnRhaW5lZCBmcm9tIGdldFNwbGluZUhlbHBlcnMuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHBcbiAgICAgKiBAcmV0dXJuIHtudW1iZXJ9XG4gICAgICovXG4gICAgc3RhdGljIGNhbGN1bGF0ZVNwbGluZShoZWxwZXJzLCBwKSB7XG4gICAgICAgIGxldCB4YSA9IGhlbHBlcnNbMF07XG4gICAgICAgIGxldCB4YiA9IGhlbHBlcnNbMV07XG4gICAgICAgIGxldCB4YyA9IGhlbHBlcnNbMl07XG4gICAgICAgIGxldCB5YSA9IGhlbHBlcnNbM107XG4gICAgICAgIGxldCB5YiA9IGhlbHBlcnNbNF07XG4gICAgICAgIGxldCB5YyA9IGhlbHBlcnNbNV07XG4gICAgICAgIGxldCB5ZCA9IGhlbHBlcnNbNl07XG5cbiAgICAgICAgaWYgKHhhID09PSAtMiAmJiB5YSA9PT0gLTIgJiYgeGMgPT09IDAgJiYgeWMgPT09IDApIHtcbiAgICAgICAgICAgIC8vIExpbmVhci5cbiAgICAgICAgICAgIHJldHVybiBwO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gRmluZCB0IGZvciBwLlxuICAgICAgICBsZXQgdCA9IDAuNSwgY2J4LCBkeDtcblxuICAgICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgICAgIC8vIEN1YmljIGJlemllciBmdW5jdGlvbjogZih0KT10Kih0Kih0KmErYikrYykuXG4gICAgICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuXG4gICAgICAgICAgICBkeCA9IHAgLSBjYng7XG4gICAgICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICAgICAgICAvLyBTb2x1dGlvbiBmb3VuZCFcbiAgICAgICAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKSArIHlkO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBDdWJpYyBiZXppZXIgZGVyaXZhdGl2ZSBmdW5jdGlvbjogZicodCk9dCoodCooMyphKSsyKmIpK2NcbiAgICAgICAgICAgIGxldCBjYnhkID0gdCAqICh0ICogKDMgKiB4YSkgKyAyICogeGIpICsgeGM7XG5cbiAgICAgICAgICAgIGlmIChjYnhkID4gMWUtMTAgJiYgY2J4ZCA8IDFlLTEwKSB7XG4gICAgICAgICAgICAgICAgLy8gUHJvYmxlbWF0aWMuIEZhbGwgYmFjayB0byBiaW5hcnkgc2VhcmNoIG1ldGhvZC5cbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdCArPSBkeCAvIGNieGQ7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBGYWxsYmFjazogYmluYXJ5IHNlYXJjaCBtZXRob2QuIFRoaXMgaXMgbW9yZSByZWxpYWJsZSB3aGVuIHRoZXJlIGFyZSBuZWFyLTAgc2xvcGVzLlxuICAgICAgICBsZXQgbWluVCA9IDA7XG4gICAgICAgIGxldCBtYXhUID0gMTtcbiAgICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgICAgICB0ID0gMC41ICogKG1pblQgKyBtYXhUKTtcblxuICAgICAgICAgICAgLy8gQ3ViaWMgYmV6aWVyIGZ1bmN0aW9uOiBmKHQpPXQqKHQqKHQqYStiKStjKStkLlxuICAgICAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcblxuICAgICAgICAgICAgZHggPSBwIC0gY2J4O1xuICAgICAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgICAgICAgLy8gU29sdXRpb24gZm91bmQhXG4gICAgICAgICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5YykgKyB5ZDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGR4IDwgMCkge1xuICAgICAgICAgICAgICAgIG1heFQgPSB0O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAg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yBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGtleSA9IGJrc1tpXTtcbiAgICAgICAgICAgIGFpW2tleV0gPSAtMTtcbiAgICAgICAgICAgIGJpW2tleV0gPSBpO1xuICAgICAgICB9XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYWtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3Qga2V5ID0gYWtzW2ldO1xuICAgICAgICAgICAgYWlba2V5XSA9IGk7XG4gICAgICAgICAgICBpZiAoYmlba2V5XSA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgYmlba2V5XSA9IC0xO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgY29uc3QgYWtzbCA9IGFrcy5sZW5ndGg7XG5cbiAgICAgICAgY29uc3QgcmVzdWx0ID0ge307XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gYmtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3Qga2V5ID0gYmtzW2ldO1xuXG4gICAgICAgICAgICAvLyBQcmVwZW5kIGFsbCBpdGVtcyBpbiBhIHRoYXQgYXJlIG5vdCBpbiBiIC0gYmVmb3JlIHRoZSBub3cgYWRkZWQgYiBhdHRyaWJ1dGUuXG4gICAgICAgICAgICBjb25zdCBhSW5kZXggPSBhaVtrZXldO1xuICAgICAgICAgICAgbGV0IGN1ckluZGV4ID0gYUluZGV4O1xuICAgICAgICAgICAgd2hpbGUoLS1jdXJJbmRleCA+PSAwKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleF07XG4gICAgICAgICAgICAgICAgaWYgKGJpW2FrZXldICE9PSAtMSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBBbHJlYWR5IGZvdW5kPyBTdG9wIHByb2Nlc3NpbmcuXG4gICAgICAgICAgICAgICAgICAgIC8vIE5vdCB5ZXQgZm91bmQgYnV0IGV4aXN0cyBpbiBiPyBBbHNvIHN0b3AgcHJvY2Vzc2luZzogd2FpdCB1bnRpbCB3ZSBmaW5kIGl0IGluIGIuXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHdoaWxlKCsrY3VySW5kZXggPCBhSW5kZXgpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4XTtcbiAgICAgICAgICAgICAgICByZXN1bHRbYWtleV0gPSBhW2FrZXldO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCBidiA9IGJba2V5XTtcbiAgICAgICAgICAgIGNvbnN0IGF2ID0gYVtrZXldO1xuICAgICAgICAgICAgbGV0IHI7XG4gICAgICAgICAgICBpZiAodGhpcy5pc01mKGJ2KSkge1xuICAgICAgICAgICAgICAgIHIgPSBidihhdik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICghVXRpbHMuaXNPYmplY3RMaXRlcmFsKGF2KSB8fCAhVXRpbHMuaXNPYmplY3RMaXRlcmFsKGJ2KSkge1xuICAgICAgICAgICAgICAgICAgICByID0gYnY7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgciA9IE9iak1lcmdlci5tZXJnZShhdiwgYnYpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gV2hlbiBtYXJrZWQgYXMgdW5kZWZpbmVkLCBwcm9wZXJ0eSBpcyBkZWxldGVkLlxuICAgICAgICAgICAgaWYgKHIgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIHJlc3VsdFtrZXldID0gcjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEFwcGVuZCByZW1haW5pbmcgZmluYWwgaXRlbXMgaW4gYS5cbiAgICAgIC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gICAgICAgIGlmIChmaWxsKSB7XG4gICAgICAgICAgICBpZiAoVXRpbHMuaXNOdW1iZXIoZmlsbENvbG9yKSkge1xuICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcoZmlsbENvbG9yKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IFwid2hpdGVcIjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGN0eC5maWxsKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoc3Ryb2tlV2lkdGgpIHtcbiAgICAgICAgICAgIGlmIChVdGlscy5pc051bWJlcihzdHJva2VDb2xvcikpIHtcbiAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcoc3Ryb2tlQ29sb3IpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBcIndoaXRlXCI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdHgubGluZVdpZHRoID0gc3Ryb2tlV2lkdGg7XG4gICAgICAgICAgICBjdHguc3Ryb2tlKCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gY2FudmFzO1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXRTaGFkb3dSZWN0KHcsIGgsIHJhZGl1cyA9IDAsIGJsdXIgPSA1LCBtYXJnaW4gPSBibHVyICogMikge1xuICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkocmFkaXVzKSl7XG4gICAgICAgICAgICAvLyB1cHBlci1sZWZ0LCB1cHBlci1yaWdodCwgYm90dG9tLXJpZ2h0LCBib3R0b20tbGVmdC5cbiAgICAgICAgICAgIHJhZGl1cyA9IFtyYWRpdXMsIHJhZGl1cywgcmFkaXVzLCByYWRpdXNdO1xuICAgICAgICB9XG5cb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zKHYxLCB2MilcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB2MSA9PT0gdjJcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBlcXVhbE9iamVjdExpdGVyYWxzKG9iajEsIG9iajIpIHtcbiAgICAgICAgbGV0IGtleXMxID0gT2JqZWN0LmtleXMob2JqMSk7XG4gICAgICAgIGxldCBrZXlzMiA9IE9iamVjdC5rZXlzKG9iajIpO1xuICAgICAgICBpZiAoa2V5czEubGVuZ3RoICE9PSBrZXlzMi5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBrZXlzMS5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGsxID0ga2V5czFbaV07XG4gICAgICAgICAgICBjb25zdCBrMiA9IGtleXMyW2ldO1xuICAgICAgICAgICAgaWYgKGsxICE9PSBrMikge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCB2MSA9IG9iajFbazFdO1xuICAgICAgICAgICAgY29uc3QgdjIgPSBvYmoyW2syXTtcblxuICAgICAgICAgICAgaWYgKCFVdGlscy5lcXVhbFZhbHVlcyh2MSwgdjIpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBzdGF0aWMgZXF1YWxBcnJheXModjEsIHYyKSB7XG4gICAgICAgIGlmICh2MS5sZW5ndGggIT09IHYyLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlXG4gICAgICAgIH1cbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB2MS5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAg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RleEF0dHJpYnNbaW5kZXhdO1xuICAgICAgICBpZiAodmEgJiYgdmFbNV0pIHtcbiAgICAgICAgICAgIHZhWzVdID0gZmFsc2U7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgZW5hYmxlVmVydGV4QXR0cmliQXJyYXkoaW5kZXgpIHtcbiAgICAgICAgY29uc3QgdmEgPSB0aGlzLl92ZXJ0ZXhBdHRyaWJzW2luZGV4XTtcbiAgICAgICAgaWYgKHZhKSB7XG4gICAgICAgICAgICBpZiAoIXZhWzBdKSB7XG4gICAgICAgICAgICAgICAgdmFbMF0gPSB0cnVlO1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fdmVydGV4QXR0cmlic1tpbmRleF0gPSBbMCwgMCwgMCwgMCwgMCwgdHJ1ZV07XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgdmVydGV4QXR0cmliUG9pbnRlcihpbmRleCwgcHJvcHMpIHtcbiAgICAgICAgbGV0IHZhID0gdGhpcy5fdmVydGV4QXR0cmlic1tpbmRleF07XG4gICAgICAgIGxldCBlcXVhbCA9IGZhbHNlO1xuICAgICAgICBpZiAodmEpIHtcbiAgICAgICAgICAgIGVxdWFsID0gdmFbMF0gPT09IHByb3BzWzBdICYmXG4gICAgICAgICAgICAgICAgdmFbMV0gPT09IHByb3BzWzFdICYmXG4gICAgICAgICAgICAgICAgdmFbMl0gPT09IHByb3BzWzJdICYmXG4gICAgICAgICAgICAgICAgdmFbM10gPT09IHByb3BzWzNdICYmXG4gICAgICAgICAgICAgICAgdmFbNF0gPT09IHByb3BzWzRdO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGVxdW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JnZXQsIG51bGwpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBfbWlncmF0ZUF0dHJpYnV0ZXModCwgcywgYnVmZmVyc0NoYW5nZWQpIHtcblxuICAgICAgICBpZiAoIWJ1ZmZlcnNDaGFuZ2VkKSB7XG4gICAgICAgICAgICB0Ll92ZXJ0ZXhBdHRyaWJzLmZvckVhY2goKGF0dHJpYiwgaW5kZXgpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoIXMuX3ZlcnRleEF0dHJpYnNbaW5kZXhdKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFdlIGNhbid0ICdkZWxldGUnIGEgdmVydGV4IGF0dHJpYiBzbyB3ZSdsbCBkaXNhYmxlIGl0LlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbC5fZGlzYWJsZVZlcnRleEF0dHJpYkFycmF5KGluZGV4KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgcy5fdmVydGV4QXR0cmlicy5mb3JFYWNoKChhdHRyaWIsIGluZGV4KSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZ2wuX3ZlcnRleEF0dHJpYlBvaW50ZXIoaW5kZXgsIGF0dHJpYlswXSwgYXR0cmliWzFdLCBhdHRyaWJbMl0sIGF0dHJpYls0XSk7XG4gICAgICAgICAgICAgICAgaWYgKGF0dHJpYls1XSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbC5fZW5hYmxlVmVydGV4QXR0cmliQXJyYXkoaW5kZXgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9kaXNhYmxlVmVydGV4QXR0cmliQXJyYXkoaW5kZXgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gV2hlbiBidWZmZXJzIGFy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KFV0aWxzLmlzRnVuY3Rpb24oYXJncykpIHtcbiAgICAgICAgICAgICAgICAgICAgYXJncyA9IGFyZ3ModGhpcy5fZ2wpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAvLyBXZSBhcmUgYWN0dWFsbHkgc2V0dGluZyB0aGUgc2V0dGluZyBmb3Igb3B0aW1pemF0aW9uIHB1cnBvc2VzLlxuICAgICAgICAgICAgICAgIHMuX3NldHRpbmdzLnNldChmdW5jLCBhcmdzKTtcbiAgICAgICAgICAgICAgICBmdW5jLmFwcGx5KHRoaXMuX2dsLCBhcmdzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHMuX3NldHRpbmdzLmZvckVhY2goKHZhbHVlLCBmdW5jKSA9PiB7XG4gICAgICAgICAgICBjb25zdCB0VmFsdWUgPSB0Ll9zZXR0aW5ncy5nZXQoZnVuYyk7XG4gICAgICAgICAgICBpZiAoIXRWYWx1ZSB8fCAhVXRpbHMuZXF1YWxWYWx1ZXModFZhbHVlLCB2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICBmdW5jLmFwcGx5KHRoaXMuX2dsLCB2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIF9taWdyYXRlRmxhZ3ModCwgcykge1xuICAgICAgICB0Ll9ub25EZWZhdWx0RmxhZ3MuZm9yRWFjaChzZXR0aW5nID0+IHtcbiAgICAgICAgICAgIGlmICghcy5fbm9uRGVmYXVsdEZsYWdzLmhhcyhzZXR0aW5nKSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9nZXREZWZhdWx0RmxhZyhzZXR0aW5nKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbC5fZW5hYmxlKHNldHRpbmcpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9kaXNhYmxlKHNldHRpbmcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHMuX25vbkRlZmF1bHRGbGFncy5mb3JFYWNoKHNldHRpbmcgPT4ge1xuICAgICAgICAgICAgaWYgKCF0Ll9ub25EZWZhdWx0RmxhZ3MuaGFzKHNldHRpbmcpKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2dldERlZmF1bHRGbGFnKHNldHRpbmcpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9kaXNhYmxlKHNldHRpbmcpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9lbmFibGUoc2V0dGluZyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0RGVmYXVsdFNldHRpbmdzKCkge1xuICAgICAgICBpZiAoIXRoaXMuX2RlZmF1bHRTZXR0aW5ncykge1xuICAgICAgICAgICAgdGhpcy5fZGVmYXVsdFNldHRpbmdzID0gbmV3IE1hcCgpO1xuICAgICAgICAgICAgY29uc3QgZCA9IHRoaXMuX2RlZmF1bHRTZXR0aW5ncztcbiAgICAgICAgICAgIGNvbnN0IGcgPSBXZWJHTFJlbmRlcmluZ0NvbnRleHQucHJvdG90eXBlO1xuICAgICAgICAgICAgZC5zZXQoXCJ2aWV3cG9ydFwiLCBmdW5jdGlvbihnbCkge3JldHVybiBbMCwwLGdsLmNhbnZhcy53aWR0aCwgZ2wuY2FudmFzLmhlaWdodF19KTtcbiAgICAgICAgICAgIGQuc2V0KFwic2Npc3NvclwiLCBmdW5jdGlvbihnbCkge3JldHVybiBbMCwwLGdsLmNhbnZhcy53aWR0aCwgZ2wuY2FudmFzLmhlaWdodF19KTtcbiAgICAgICAgICAgIGQuc2V0KFwiYmxlbmRDb2xvclwiLCBbMCwgMCwgMCwgMF0pO1xuICAgIC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AgICAgICAgICB0aGlzLl90ZXh0dXJlVGFyZ2V0SW5kaWNlcyA9IFsweDBERTEsIDB4ODUxM107XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMuX3RleHR1cmVUYXJnZXRJbmRpY2VzW2luZGV4XVxuICAgIH1cblxuICAgIHN0YXRpYyBfZ2V0VGV4dHVyZUluZGV4KGluZGV4KSB7XG4gICAgICAgIHJldHVybiBpbmRleCAtIDB4ODRDMCAvKiBHTF9URVhUVVJFMCAqLztcbiAgICB9XG5cbiAgICBzdGF0aWMgX2dldFRleHR1cmVCeUluZGV4KGluZGV4KSB7XG4gICAgICAgIHJldHVybiBpbmRleCArIDB4ODRDMDtcbiAgICB9XG5cbiAgICBzdGF0aWMgX2dldFBpeGVsU3RvcmVpSW5kZXgocG5hbWUpIHtcbiAgICAgICAgc3dpdGNoKHBuYW1lKSB7XG4gICAgICAgICAgICBjYXNlIDB4MEQwNTpcbiAgICAgICAgICAgICAgICAvKiBQQUNLX0FMSUdOTUVOVCAqL1xuICAgICAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICAgICAgY2FzZSAweDBDRjU6XG4gICAgICAgICAgICAgICAgLyogVU5QQUNLX0FMSUdOTUVOVCAqL1xuICAgICAgICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICAgICAgY2FzZSAweDkyNDA6XG4gICAgICAgICAgICAgICAgLyogVU5QQUNLX0ZMSVBfWV9XRUJHTCAqL1xuICAgICAgICAgICAgICAgIHJldHVybiAyO1xuICAgICAgICAgICAgY2FzZSAweDkyNDE6XG4gICAgICAgICAgICAgICAgLyogVU5QQUNLX1BSRU1VTFRJUExZX0FMUEhBX1dFQkdMICovXG4gICAgICAgICAgICAgICAgcmV0dXJuIDM7XG4gICAgICAgICAgICBjYXNlIDB4OTI0MzpcbiAgICAgICAgICAgICAgICAvKiBVTlBBQ0tfQ09MT1JTUEFDRV9DT05WRVJTSU9OX1dFQkdMICovXG4gICAgICAgICAgICAgICAgcmV0d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ICBpZiAoIWdsW25hbWVdLm5hbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBXZSBkbyB0aGlzIGZvciBjb21wYXRpYmlsaXR5IHdpdGggdGhlIENocm9tZSBXZWJHTCBJbnNwZWN0b3IgcGx1Z2luLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdsW25hbWVdLnhuYW1lID0gbmFtZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGdsWydfJyArIG5hbWVdID0gZ2xbbmFtZV07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZ2xbbmFtZV0gPSBtZXRob2Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBXZWJHTFN0YXRlTWFuYWdlci5wcm90b3R5cGUuX2luaXRTdGF0ZU1hbmFnZXIuY2FsbChnbCwgaWQpO1xuXG4gICAgICAgIHJldHVybiBnbDtcbiAgICB9XG5cbn1cblxuZXhwb3J0IGRlZmF1bHQgV2ViR0xTdGF0ZU1hbmFnZXI7XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXMgYXBwbHk6XG4gKlxuICogQ29weXJpZ2h0IDIwMjAgTWV0cm9sb2dpY2FsXG4gKlxuICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlIExpY2Vuc2UpO1xuICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLlxuICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNl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ZW1lbnRzLlxuICAgICAgICAgKiBAdHlwZSB7RWxlbWVudENoaWxkTGlzdH1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX19jaGlsZExpc3QgPSBudWxsO1xuXG4gICAgICAgIHRoaXMuX3cgPSAwO1xuXG4gICAgICAgIHRoaXMuX2ggPSAwO1xuICAgIH1cblxuICAgIF9fc3RhcnQoKSB7XG4gICAgfVxuXG4gICAgZ2V0IGlkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2lkO1xuICAgIH1cblxuICAgIHNldCByZWYocmVmKSB7XG4gICAgICAgIGlmICh0aGlzLl9fcmVmICE9PSByZWYpIHtcbiAgICAgICAgICAgIGNvbnN0IGNoYXJjb2RlID0gcmVmLmNoYXJDb2RlQXQoMCk7XG4gICAgICAgICAgICBpZiAoIVV0aWxzLmlzVWNDaGFyKGNoYXJjb2RlKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJSZWYgbXVzdCBzdGFydCB3aXRoIGFuIHVwcGVyIGNhc2UgY2hhcmFjdGVyOiBcIiArIHJlZik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fX3JlZiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlVGFnKHRoaXMuX19yZWYpO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9fcGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX19wYXJlbnQuX19jaGlsZExpc3QuY2xlYXJSZWYodGhpcy5fX3JlZik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9fcmVmID0gcmVmO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fX3JlZikge1xuICAgICAgICAgICAgICAgIHRoaXMuX2FkZFRhZyh0aGlzLl9fcmVmKTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fX3BhcmVudCkge1xuICAgIC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tcbiAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJSb290IHNob3VsZCBub3QgYmUgYWRkZWQgYXMgYSBjaGlsZCEgUmVzdWx0cyBhcmUgdW5zcGVjaWZpZWQhXCIpO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldERlcHRoKCkge1xuICAgICAgICBsZXQgZGVwdGggPSAwO1xuXG4gICAgICAgIGxldCBwID0gdGhpcy5fX3BhcmVudDtcbiAgICAgICAgd2hpbGUocCkge1xuICAgICAgICAgICAgZGVwdGgrKztcbiAgICAgICAgICAgIHAgPSBwLl9fcGFyZW50O1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGRlcHRoO1xuICAgIH07XG5cbiAgICBnZXRBbmNlc3RvcihsKSB7XG4gICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgd2hpbGUgKGwgPiAwICYmIHAuX19wYXJlbnQpIHtcbiAgICAgICAgICAgIHAgPSBwLl9fcGFyZW50O1xuICAgICAgICAgICAgbC0tO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBwO1xuICAgIH07XG5cbiAgICBnZXRBbmNlc3RvcnMoKSB7XG4gICAgICAgIGNvbnN0IGEgPSBbXTtcbiAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICB3aGlsZSAocCkge1xuICAgICAgICAgICAgYS5wdXNoKHApO1xuICAgICAgICAgICAgcCA9IHAuX19wYXJlbnQ7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGE7XG4gICAgfVxuXG4gICAgZ2V0QW5jZXN0b3JBdERlcHRoKGRlcHRoKSB7XG4gICAgICAgIGxldCBsZXZlbHMgPSB0aGlzLmdldERlcHRoKCkgLSBkZXB0aDtcbiAgICAgICAgaWYgKGxldmVscyA8IDApIHtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLmdldEFuY2VzdG9yKGxldmVscyk7XG4gICAgfTtcblxuICAgIGlzQW5jZXN0b3JPZihjKSB7XG4gICAgICAgIGxldCBwID0gYztcbiAgICAgICAgd2hpbGUocCA9IHAucGFyZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcyA9PT0gcCkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9O1xuXG4gICAgZ2V0U2hhcmVkQW5jZXN0b3IoYykge1xuICAgICAgICBsZXQgbzEgPSB0aGlzO1xuICAgICAgICBsZXQgbzIgPSBjO1xuICAgICAgICBsZXQgbDEgPSBvMS5nZXREZXB0aCgpO1xuICAgICAgICBsZXQgbDIgPSBvMi5nZXREZXB0aCgpO1xuICAgICAgICBpZiAobDEgPiBsMikge1xuICAgICAgICAgICAgbzEgPSBvMS5nZXRBbmNlc3RvcihsMSAtIGwyKTtcbiAgICAgICAgfSBlbHNlIGlmIChsMiA+IGwxKSB7XG4gICAgICAgICAgICBvMiA9IG8yLmdldEFuY2VzdG9yKGwyIC0gbDEpO1xuICAgICAgICB9XG5cbiAgICAgICAgZG8ge1xuICAgICAgICAgICAgaWYgKG8xID09PSBvMikge1xuICAgICAgICAgICAgICAgIHJldHVybiBvMTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbzEgPSBvMS5fX3BhcmVudDtcbiAgICAgICAgICAgIG8yID0gbzIuX19wYXJlbnQ7XG4gICAgICAgIH0gd2hpbGUgKG8xICYmIG8yKTtcblxuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICB9O1xuXG4gICAgZ2V0IGF0dGFjaGVkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2F0dGFjaGVkO1xuICAgIH1cblxuICAgIGdldCBlbmFibGVkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2VuYWJsZWQ7XG4gICAgfVxuXG4gICAgZ2V0IGFjdGl2ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXM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VuLmxlbmd0aDtcbiAgICAgICAgICAgICAgICBpZiAobSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBtOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkcmVuW2ldLl91cGRhdGVBdHRhY2hlZEZsYWcoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKG5ld0F0dGFjaGVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb25BdHRhY2goKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb25EZXRhY2goKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICAvKipcbiAgICAgKiBVcGRhdGVzIHRoZSAnZW5hYmxlZCcgZmxhZyBmb3IgdGhpcyBicmFuY2guXG4gICAgICovXG4gICAgX3VwZGF0ZUVuYWJsZWRGbGFnKCkge1xuICAgICAgICBsZXQgbmV3RW5hYmxlZCA9IHRoaXMuX2lzRW5hYmxlZCgpO1xuICAgICAgICBpZiAodGhpcy5fX2VuYWJsZWQgIT09IG5ld0VuYWJsZWQpIHtcbiAgICAgICAgICAgIGlmIChuZXdFbmFibGVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb25FbmFibGVkKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2V0RW5hYmxlZEZsYWcoKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb25EaXNhYmxlZCgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3Vuc2V0RW5hYmxlZEZsYWcoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IGNoaWxkcmVuID0gdGhpcy5fY2hpbGRyZW4uZ2V0KCk7XG4gICAgICAgICAgICBpZiAoY2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICBsZXQgbSA9IGNoaWxkcmVuLmxlbmd0aDtcbiAgICAgICAgICAgICAgICBpZiAobSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBtOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkcmVuW2ldLl91cGRhdGVFbmFibGVkRmxhZygpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIF9zZXRFbmFibGVkRmxhZygpIHtcbiAgICAgICAgdGhpcy5fX2VuYWJsZWQgPSB0cnVlO1xuXG4gICAgICAgIC8vIEZvcmNlIHJlLWNoZWNrIG9mIHRleHR1cmUgYmVjYXVzZSBkaW1lbnNpb25zIG1pZ2h0IGhhdmUgY2hhbmdlZCAoY3V0dGluZykuXG4gICAgICAgIHRoaXMuX3VwZGF0ZURpbWVuc2lvbnMoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGV4dHVyZUNvb3JkcygpO1xuXG4gICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZSkge1xuICAgICAgICAgICAgdGhpcy5fX3RleHR1cmUuYWRkRWxlbWVudCh0aGlzKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLndpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgdGhpcy5fc2V0QWN0aXZlRmxhZygpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX19jb3JlLnNoYWRlcikge1xuICAgICAgICAgICAgdGhpcy5fX2NvcmUuc2hhZGVyLmFkZEVsZW1lbnQodGhpcy5fX2NvcmUpO1xuICAgICAgICB9XG5cbiAgICB9XG5cbiAgICBfdW5zZXRFbmFibGVkRmxhZygpIHtcbiAgICAgICAgaWYgKHRoaXMuX19hY3RpdmUpIHtcbiAgICAgICAgICAgIHRoaXMuX3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iAgICAgICAgICAgIHRoaXMuX190ZXh0dXJlLmRlY0FjdGl2ZUNvdW50KCk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9fYWN0aXZlID0gZmFsc2U7XG4gICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZSkge1xuICAgICAgICAgICAgdGhpcy5fZGlzYWJsZVRleHR1cmUoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9oYXNUZXh0dXJpemVyKCkpIHtcbiAgICAgICAgICAgIHRoaXMudGV4dHVyaXplci5kZWFjdGl2YXRlKCk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9vbkluYWN0aXZlKCk7XG4gICAgfVxuXG4gICAgX29uU2V0dXAoKSB7XG4gICAgfVxuXG4gICAgX29uQXR0YWNoKCkge1xuICAgIH1cblxuICAgIF9vbkRldGFjaCgpIHtcbiAgICB9XG5cbiAgICBfb25FbmFibGVkKCkge1xuICAgIH1cblxuICAgIF9vbkRpc2FibGVkKCkge1xuICAgIH1cblxuICAgIF9vbkFjdGl2ZSgpIHtcbiAgICB9XG5cbiAgICBfb25JbmFjdGl2ZSgpIHtcbiAgICB9XG5cbiAgICBfb25SZXNpemUoKSB7XG4gICAgfVxuXG4gICAgX2dldFJlbmRlcldpZHRoKCkge1xuICAgICAgICBpZiAodGhpcy5fdykge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3c7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5fX2Rpc3BsYXllZFRleHR1cmUpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9fZGlzcGxheWVkVGV4dHVyZS5nZXRSZW5kZXJXaWR0aCgpO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX190ZXh0dXJlKSB7XG4gICAgICAgICAgICAvLyBUZXh0dXJlIGFscmVhZHkgbG9hZGVkLCBidXQgbm90IHlldCB1cGRhdGVkIChwcm9iYWJseSBiZWNhdXNlIHRoaXMgZWxlbWVudCBpc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W4gdGhlIHRleHR1cmUgY2hhbmdlcyB3aGlsZSBpbnZpc2libGUsIHdlIHNob3VsZCB1c2UgdGhhdCB3LCBoLFxuICAgICAgICAvLyBtdywgbWggZm9yIGNoZWNraW5nIHdpdGhpbiBib3VuZHMuXG4gICAgICAgIHRoaXMuX3NldERpc3BsYXllZFRleHR1cmUobnVsbCk7XG4gICAgfVxuXG4gICAgZ2V0IHRleHR1cmUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fdGV4dHVyZTtcbiAgICB9XG5cbiAgICBzZXQgdGV4dHVyZSh2KSB7XG4gICAgICAgIGxldCB0ZXh0dXJlO1xuICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICBpZiAodi50eXBlKSB7XG4gICAgICAgICAgICAgICAgdGV4dHVyZSA9IG5ldyB2LnR5cGUodGhpcy5zdGFnZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRleHR1cmUgPSB0aGlzLnRleHR1cmU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0ZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgQmFzZS5wYXRjaE9iamVjdCh0ZXh0dXJlLCB2KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICghdikge1xuICAgICAgICAgICAgdGV4dHVyZSA9IG51bGw7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodi5pc1RleHR1cmUpIHtcbiAgICAgICAgICAgICAgICB0ZXh0dXJlID0gdjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodi5pc1RleHR1cmVTb3VyY2UpIHtcbiAgICAgICAgICAgICAgICB0ZXh0dXJlID0gbmV3IFNvdXJjZVRleHR1cmUodGhpcy5zdGFnZSk7XG4gICAgICAgICAgICAgICAgdGV4dHVyZS50ZXh0dXJlU291cmNlID0gdjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcIltMaWdodG5pbmddIFBsZWFzZSBzcGVjaWZ5IGEgdGV4dHVyZSB0eXBlLlwiKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBwcmV2VGV4dHVyZSA9IHRoaXMuX190ZXh0dXJlO1xuICAgICAgICBpZiAodGV4dHVyZSAhPT0gcHJldlRleHR1cmUpIHtcbiAgICAgICAgICAgIHRoaXMuX190ZXh0dXJlID0gdGV4dHVyZTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX190ZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX19lbmFibGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX190ZXh0dXJlLmFkZEVsZW1lbnQodGhpcyk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fX3RleHR1cmUuaXNMb2FkZWQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldERpc3BsYXllZFRleHR1cmUodGhpcy5fX3RleHR1cmUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbmFibGVUZXh0dXJlRXJyb3IoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHRoYXQgY3VycmVudCB0ZXh0dXJlIGlzIGNsZWFyZWQgd2hlbiB0aGUgdGV4dHVyZSBpcyBleHBsaWNpdGx5IHNldCB0byBudWxsLlxuICAgICAgICAgICAgICAg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B0aGlzLnRleHR1cmUudyA9IHc7XG4gICAgICAgICAgICB0aGlzLnRleHR1cmUuaCA9IGg7XG4gICAgICAgICAgICB0aGlzLncgPSB3O1xuICAgICAgICAgICAgdGhpcy5oID0gaDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF91cGRhdGVEaW1lbnNpb25zKCkge1xuICAgICAgICBsZXQgdyA9IHRoaXMuX2dldFJlbmRlcldpZHRoKCk7XG4gICAgICAgIGxldCBoID0gdGhpcy5fZ2V0UmVuZGVySGVpZ2h0KCk7XG5cbiAgICAgICAgbGV0IHVua25vd25TaXplID0gZmFsc2U7XG4gICAgICAgIGlmICghdyB8fCAhaCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9fZGlzcGxheWVkVGV4dHVyZSAmJiB0aGlzLl9fdGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIC8vIFdlIHVzZSBhICdtYXggd2lkdGgnIHJlcGxhY2VtZW50IGluc3RlYWQgaW4gdGhlIEVsZW1lbnRDb3JlIGNhbGNzLlxuICAgICAgICAgICAgICAgIC8vIFRoaXMgbWFrZXMgc3VyZSB0aGF0IGl0IGlzIGFibGUgdG8gZGV0ZXJtaW5lIHdpdGhpbkJvdW5kcy5cbiAgICAgICAgICAgICAgICB3ID0gdyB8fCB0aGlzLl9fdGV4dHVyZS5tdztcbiAgICAgICAgICAgICAgICBoID0gaCB8fCB0aGlzLl9fdGV4dHVyZS5taDtcblxuICAgICAgICAgICAgICAgIGlmICgoIXcgfHwgIWgpICYmIHRoaXMuX190ZXh0dXJlLmlzQXV0b3NpemVUZXh0dXJlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdW5rbm93blNpemUgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9fY29yZS5zZXREaW1lbnNpb25zKHcsIGgsIHVua25vd25TaXplKSkge1xuICAgICAgICAgICAgdGhpcy5fb25SZXNpemUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF91cGRhdGVUZXh0dXJlQ29vcmRzKCkge1xuICAgICAgICBpZiAodGhpcy5kaXNwbGF5ZWRUZXh0dXJlICYmIHRoaXMuZGlzcGxheWVkVGV4dHVyZS5fc291cmNlKSB7XG4gICAgICAgICAgICBsZXQgZGlzcGxheWVkVGV4dHVyZSA9IHRoaXMuZGlzcGxheWVkVGV4dHVyZTtcbiAgICAgICAgICAgIGxldCBkaXNwbGF5ZWRUZXh0dXJlU291cmNlID0gdGhpcy5kaXNwbGF5ZWRUZXh0dXJlLl9zb3VyY2U7XG5cbiAgICAgICAgICAgIGxldCB0eDEgPSAwLCB0eTEgPSAwLCB0eDIgPSAxLjAsIHR5MiA9IDEuMDtcbiAgICAgICAgICAgIGlmIChkaXNwbGF5ZWRUZXh0dXJlLmNsaXBwaW5nKSB7XG4gICAgICAgICAgICAgICAgLy8gQXBwbHkgdGV4dHVyZSBjbGlwcGluZy5cbiAgICAgICAgICAgICAgICBsZXQgdyA9IGRpc3BsYXllZFRleHR1cmVTb3VyY2UuZ2V0UmVuZGVyV2lkdGgoKTtcbiAgICAgICAgICAgICAgICBsZXQgaCA9IGRpc3BsYXllZFRleHR1cmVTb3VyY2UuZ2V0UmVuZGVySGVpZ2h0KCk7XG4gICAgICAgICAgICAgICAgbGV0IGl3LCBpaCwgcncsIHJoO1xuICAgICAgICAgICAgICAgIGl3ID0gMSAvIHc7XG4gICAgICAgICAgICAgICAgaWggPSAxIC8gaDtcblxuICAgICAgICAgICAgICAgIGlmIChkaXNwbGF5ZWRUZXh0dXJlLnB3KSB7XG4gICAgICAgICAgICAgICAgICAgIHJ3ID0gKGRpc3BsYXllZFRleHR1cmUucHcpICogaXc7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcncgPSAodyAtIGRpc3BsYXllZFRleHR1cmUucHgpICogaXc7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGRpc3BsYXllZFRleHR1cmUucGgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmggPSBkaXNwbGF5ZWRUZXh0dXJlLnBoICogaWg7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmggPSAoaCAtIGRpc3BsYXllZFRleHR1cmUucHkpICogaWg7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaXcgKj0gKGRpc3BsYXllZFRleHR1cmUucHgpO1xuICAgICAgICAgICAgICAgIGloICo9IChkaXNwbGF5ZWRUZXh0dXJlLnB5KTtcblxuICAgICAgICAgICAgICAgIHR4MSA9IGl3O1xuICAgICAgICAgICAgICAgIHR5MSA9IGloO1xuICAgICAgICAgICAgICAgIHR4MiA9IHR4MiAqIHJ3ICsgaXc7XG4gICAgICAgICAgICAgICAgdHkyID0gdHkyICogcmggKyBpaDtcblxuICAgICAgICAgICAgICAgIHR4MSA9IE1hdGgubWF4KDAsIHR4MSk7XG4gICAgICAgICAgICAgICAgdHkxID0gTWF0aC5tYXgoMCwgdHkxKTtcbiAgICAgICAgICAgICAgICB0eDIgPSBNYXRoLm1pbigxLCB0eDIpO1xuICAgICAgICAgICAgICAgIHR5MiA9IE1hdGgubWluKDEsIHR5Mik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChkaXNwbGF5ZWRUZXh0dXJlU291cmNlLl9mbGlwVGV4dHVyZVkpIHtcbiAgICAgICAgICAgICAgICBsZXQgdGVtcHR5ID0gdHkyO1xuICAgICAgICAgICAgICAgIHR5MiA9IHR5MTtcbiAgICAgICAgICAgICAgICB0eTEgPSB0ZW1wdHk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9fY29yZS5zZXRUZXh0dXJlQ29vcmRzKHR4MSwgdHkxLCB0eDIsIHR5Mik7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXRDb3JuZXJQb2ludHMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5nZXRDb3JuZXJQb2ludHMoKTtcbiAgICB9XG5cbiAgICBfdW5zZXRUYWdzUGFyZW50KCkge1xuICAgICAgICBpZiAodGhpcy5fX3RhZ3MpIHtcbiAgICAgICAgICAgIHRoaXMuX190YWdzLmZvckVhY2goKHRhZykgPT4ge1xuICAgICAgICAgICAgICAgIC8vIFJlbW92ZSBmcm9tIHRyZWVUYWdzLlxuICAgICAgICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICAgICAgICB3aGlsZSAocCA9IHAuX19wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhcmVudFRyZWVUYWdzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgICAgICAgICBwYXJlbnRUcmVlVGFncy5kZWxldGUodGhpcyk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IHRhZ3MgPSBudWxsO1xuICAgICAgICBsZXQgbiA9IDA7XG4gICAgICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICB0YWdzID0gVXRpbHMuaXRlcmF0b3JUb0FycmF5KHRoaXMuX190cmVlVGFncy5rZXlzKCkpO1xuICAgICAgICAgICAgICAgIG4gPSB0YWdzLmxlbmd0aDtcblxuICAgICAgICAgICAgICAgIGlmIChuID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRhZ1NldCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnc1tpXSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFJlbW92ZSBmcm9tIHRyZWVUYWdzLlxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKChwID0gcC5fX3BhcmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGFyZW50VHJlZVRhZ3MgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZ3NbaV0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFnU2V0LmZvckVhY2goZnVuY3Rpb24gKGNvbXApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50VHJlZVRhZ3MuZGVsZXRlKGNvbXApO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBfc2V0VGFnc1BhcmVudCgpIHtcbiAgICAgICAgLy8gSnVzdCBjb3B5IG92ZXIgdGhlICdsb2NhbCcgdGFncy5cbiAgICAgICAgaWYgKHRoaXMuX190YWdzKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGFncy5mb3JFYWNoKCh0YWcpID0+IHtcbiAgICAgICAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgICAgICAgd2hpbGUgKHAgPSBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSBuZXcgTWFwKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzID0gbmV3IFNldCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgcy5hZGQodGhpcyk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX190cmVlVGFncyAmJiB0aGlzLl9fdHJlZVRhZ3Muc2l6ZSkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX190cmVlVGFncy5mb3JFYWNoKCh0YWdTZXQsIHRhZykgPT4ge1xuICAgICAgICAgICAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgICAgICAgICAgIHdoaWxlICghcC5fX3RhZ1Jvb3QgJiYgKHAgPSBwLl9fcGFyZW50KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHAuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRG8gbm90IGNvcHkgYWxsIHN1YnMuXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAuX190cmVlVGFncyA9IG5ldyBNYXAoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzID0gbmV3IFNldCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgdGFnU2V0LmZvckVhY2goZnVuY3Rpb24gKGNvbXApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzLmFkZChjb21wKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG5cbiAgICBfZ2V0QnlUYWcodGFnKSB7XG4gICAgICAgIGlmICghdGhpcy5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICByZXR1cm4gW107XG4gICAgICAgIH1cbiAgICAgICAgbGV0IHQgPSB0aGlzLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgIHJldHVybiB0ID8gVXRpbHMuc2V0VG9BcnJheSh0KSA6IFtdO1xuICAgIH07XG5cbiAgICBnZXRUYWdzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX3RhZ3MgPyB0aGlzLl9fdGFncyA6IFtdO1xuICAgIH07XG5cbiAgICBzZXRUYWdzKHRhZ3MpIHtcbiAgICAgICAgdGFncyA9IHRhZ3MucmVkdWNlKChhY2MsIHRhZykgPT4ge1xuICAgICAgICAgICAgcmV0dXJuIGFjYy5jb25jYXQodGFnLnNwbGl0KCcgJykpO1xuICAgICAgICB9LCBbXSk7XG5cbiAgICAgICAgaWYgKHRoaXMuX19yZWYpIHtcbiAgICAgICAgICAgIHRhZ3MucHVzaCh0aGlzLl9fcmVmKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBpLCBuID0gdGFncy5sZW5ndGg7XG4gICAgICAgIGxldCByZW1vdmVzID0gW107XG4gICAgICAgIGxldCBhZGRzID0gW107XG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5oYXNUYWcodGFnc1tpXSkpIHtcbiAgICAgICAgICAgICAgICBhZGRzLnB1c2godGFnc1tpXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgY3VycmVudFRhZ3MgPSB0aGlzLnRhZ3MgfHwgW107XG4gICAgICAgIG4gPSBjdXJyZW50VGFncy5sZW5ndGg7XG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGlmICh0YWdzLmluZGV4T2YoY3VycmVudFRhZ3NbaV0pID09IC0xKSB7XG4gICAgICAgICAgICAgICAgcmVtb3Zlcy5wdXNoKGN1cnJlbnRUYWdzW2ldKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCByZW1vdmVzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB0aGlzLnJlbW92ZVRhZyhyZW1vdmVzW2ldKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBhZGRzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB0aGlzLmFkZFRhZyhhZGRzW2ldKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGFkZFRhZyh0YWcpIHtcbiAgICAgICAgaWYgKHRhZy5pbmRleE9mKCcgJykgPT09IC0xKSB7XG4gICAgICAgICAgICBpZiAoVXRpbHMuaXNVY0NoYXIodGFnLmNoYXJDb2RlQXQoMCkpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlRhZyBtYXkgbm90IHN0YXJ0IHdpdGggYW4gdXBwZXIgY2FzZSBjaGFyYWN0ZXIuXCIpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9hZGRUYWcodGFnKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnN0IHRhZ3MgPSB0YWcuc3BsaXQoJyAnKTtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBtID0gdGFncy5sZW5ndGg7IGkgPCBtOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjb25zdCB0YWcgPSB0YWdzW2ldO1xuXG4gICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzVWNDaGFyKHRhZy5jaGFyQ29kZUF0KDApKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl90aHJvd0Vycm9yKFwiVGFnIG1heSBub3Qgc3RhcnQgd2l0aCBhbiB1cHBlciBjYXNlIGNoYXJhY3Rlci5cIik7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdGhpcy5fYWRkVGFnKHRhZyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfYWRkVGFnKHRhZykge1xuICAgICAgICBpZiAoIXRoaXMuX190YWdzKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGFncyA9IFtdO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9fdGFncy5pbmRleE9mKHRhZykgPT09IC0xKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGFncy5wdXNoKHRhZyk7XG5cbiAgICAgICAgICAgIC8vIEFkZCB0byB0cmVlVGFncyBoaWVyYXJjaHkuXG4gICAgICAgICAgICBsZXQgcCA9IHRoaXMuX19wYXJlbnQ7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAuX190cmVlVGFncyA9IG5ldyBNYXAoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMgPSBuZXcgU2V0KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBzLmFkZCh0aGlzKTtcblxuICAgICAgICAgICAgICAgIH0gd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJlbW92ZVRhZyh0YWcpIHtcbiAgICAgICAgbGV0IGkgPSB0aGlzLl9fdGFncy5pbmRleE9mKHRhZyk7XG4gICAgICAgIGlmIChpICE9PSAtMSkge1xuICAgICAgICAgICAgdGhpcy5fX3RhZ3Muc3BsaWNlKGksIDEpO1xuXG4gICAgICAgICAgICAvLyBSZW1vdmUgZnJvbSB0cmVlVGFncyBoaWVyYXJjaHkuXG4gICAgICAgICAgICBsZXQgcCA9IHRoaXMuX19wYXJlbnQ7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChsaXN0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0LmRlbGV0ZSh0aGlzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGhhc1RhZyh0YWcpIHtcbiAgICAgICAgcmV0dXJuICh0aGlzLl9fdGFncyAmJiAodGhpcy5fX3RhZ3MuaW5kZXhPZih0YWcpICE9PSAtMSkpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFJldHVybnMgb25lIG9mIHRoZSBlbGVtZW50cyBmcm9tIHRoZSBzdWJ0cmVlIHRoYXQgaGF2ZSB0aGlzIHRhZy5cbiAgICAgKiBAcGFyYW0ge3N0cmluZ30gdGFnXG4gICAgICogQHJldHVybnMge0VsZW1lbnR9XG4gICAgICovXG4gICAgX3RhZyh0YWcpIHtcbiAgICAgICAgaWYgKHRhZy5pbmRleE9mKFwiLlwiKSAhPT0gLTEpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLm10YWcodGFnKVswXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgICBsZXQgdCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgICAgICBpZiAodCkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gdC52YWx1ZXMoKS5uZXh0KCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtID8gaXRlbS52YWx1ZSA6IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZ2V0IHRhZygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3RhZztcbiAgICB9XG5cbiAgICBzZXQgdGFnKHQpIHtcbiAgICAgICAgdGhpcy50YWdzID0gdDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBSZXR1cm5zIGFsbCBlbGVtZW50cyBmcm9tIHRoZSBzdWJ0cmVlIHRoYXQgaGF2ZSB0aGlzIHRhZy5cbiAgICAgKiBAcGFyYW0ge3N0cmluZ30gdGFnXG4gICAgICogQHJldHVybnMge0VsZW1lbnRbXX1cbiAgICAgKi9cbiAgICBtdGFnKHRhZykge1xuICAgICAgICBsZXQgaWR4ID0gdGFnLmluZGV4T2YoXCIuXCIpO1xuICAgICAgICBpZiAoaWR4ID49IDApIHtcbiAgICAgICAgICAgIGxldCBwYXJ0cyA9IHRhZy5zcGxpdCgnLicpO1xuICAgICAgICAgICAgbGV0IHJlcyA9IHRoaXMuX2dldEJ5VGFnKHBhcnRzWzBdKTtcbiAgICAgICAgICAgIGxldCBsZXZlbCA9IDE7XG4gICAgICAgICAgICBsZXQgYyA9IHBhcnRzLmxlbmd0aDtcbiAgICAgICAgICAgIHdoaWxlIChyZXMubGVuZ3RoICYmIGxldmVsIDwgYykge1xuICAgICAgICAgICAgICAgIGxldCByZXNuID0gW107XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDAsIG4gPSByZXMubGVuZ3RoOyBqIDwgbjsgaisrKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc24gPSByZXNuLmNvbmNhdChyZXNbal0uX2dldEJ5VGFnKHBhcnRzW2xldmVsXSkpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHJlcyA9IHJlc247XG4gICAgICAgICAgICAgICAgbGV2ZWwrKztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiByZXM7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fZ2V0QnlUYWcodGFnKTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBzdGFnKHRhZywgc2V0dGluZ3MpIHtcbiAgICAgICAgbGV0IHQgPSB0aGlzLm10YWcodGFnKTtcbiAgICAgICAgbGV0IG4gPSB0Lmxlbmd0aDtcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIEJhc2UucGF0Y2hPYmplY3QodFtpXSwgc2V0dGluZ3MpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHRhZ1Jvb3QoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fdGFnUm9vdDtcbiAgICB9XG5cbiAgICBzZXQgdGFnUm9vdCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9fdGFnUm9vdCAhPT0gdikge1xuICAgICAgICAgICAgaWYgKCF2KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2V0VGFnc1BhcmVudCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl91bnNldFRhZ3NQYXJlbnQoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fX3RhZ1Jvb3QgPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2VsKHBhdGgpIHtcbiAgICAgICAgY29uc3QgcmVzdWx0cyA9IHRoaXMuc2VsZWN0KHBhdGgpO1xuICAgICAgICBpZiAocmVzdWx0cy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybiByZXN1bHRzWzBdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNlbGVjdChwYXRoKSB7XG4gICAgICAgIGlmIChwYXRoLmluZGV4T2YoXCIsXCIpICE9PSAtMSkge1xuICAgICAgICAgICAgbGV0IHNlbGVjdG9ycyA9IHBhdGguc3BsaXQoJywnKTtcbiAgICAgICAgICAgIGxldCByZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc2VsZWN0b3JzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgcmVzID0gcmVzLmNvbmNhdCh0aGlzLl9zZWxlY3Qoc2VsZWN0b3JzW2ldKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcmVzO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3NlbGVjdChwYXRoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9zZWxlY3QocGF0aCkge1xuICAgICAgICBpZiAocGF0aCA9PT0gXCJcIikgcmV0dXJuIFt0aGlzXTtcblxuXG4gICAgICAgIGxldCBwb2ludElkeCA9IHBhdGguaW5kZXhPZihcIi5cIik7XG4gICAgICAgIGxldCBhcnJvd0lkeCA9IHBhdGguaW5kZXhPZihcIj5cIik7XG4gICAgICAgIGlmIChwb2ludElkeCA9PT0gLTEgJiYgYXJyb3dJZHggPT09IC0xKSB7XG4gICAgICAgICAgICAvLyBRdWljayBjYXNlLlxuICAgICAgICAgICAgcmV0dXJuIHRoaXMubXRhZyhwYXRoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIERldGVjdCBieSBmaXJzdCBjaGFyLlxuICAgICAgICBsZXQgaXNSZWY7XG4gICAgICAgIGlmIChhcnJvd0lkeCA9PT0gMCkge1xuICAgICAgICAgICAgaXNSZWYgPSB0cnVlO1xuICAgICAgICAgICAgcGF0aCA9IHBhdGguc3Vic3RyKDEpO1xuICAgICAgICB9IGVsc2UgaWYgKHBvaW50SWR4ID09PSAwKSB7XG4gICAgICAgICAgICBpc1JlZiA9IGZhbHNlO1xuICAgICAgICAgICAgcGF0aCA9IHBhdGguc3Vic3RyKDEpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaXNSZWYgPSBmYWxzZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB0aGlzLl9zZWxlY3RDaGlsZHMocGF0aCwgaXNSZWYpO1xuICAgIH1cblxuICAgIF9zZWxlY3RDaGlsZHMocGF0aCwgaXNSZWYpIHtcbiAgICAgICAgY29uc3QgcG9pbnRJZHggPSBwYXRoLmluZGV4T2YoXCIuXCIpO1xuICAgICAgICBjb25zdCBhcnJvd0lkeCA9IHBhdGguaW5kZXhPZihcIj5cIik7XG5cbiAgICAgICAgaWYgKHBvaW50SWR4ID09PSAtMSAmJiBhcnJvd0lkeCA9PT0gLTEpIHtcbiAgICAgICAgICAgIGlmIChpc1JlZikge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJlZiA9IHRoaXMuZ2V0QnlSZWYocGF0aCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlZiA/IFtyZWZdIDogW107XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm10YWcocGF0aCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoKGFycm93SWR4ID09PSAtMSkgfHwgKHBvaW50SWR4ICE9PSAtMSAmJiBwb2ludElkeCA8IGFycm93SWR4KSkge1xuICAgICAgICAgICAgbGV0IG5leHQ7XG4gICAgICAgICAgICBjb25zdCBzdHIgPSBwYXRoLnN1YnN0cigwLCBwb2ludElkeCk7XG4gICAgICAgICAgICBpZiAoaXNSZWYpIHtcbiAgICAgICAgICAgICAgICBjb25zdCByZWYgPSB0aGlzLmdldEJ5UmVmKHN0cik7XG4gICAgICAgICAgICAgICAgbmV4dCA9IHJlZiA/IFtyZWZdIDogW107XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG5leHQgPSB0aGlzLm10YWcoc3RyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCB0b3RhbCA9IFtdO1xuICAgICAgICAgICAgY29uc3Qgc3ViUGF0aCA9IHBhdGguc3Vic3RyKHBvaW50SWR4ICsgMSk7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IG5leHQubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdG90YWwgPSB0b3RhbC5jb25jYXQobmV4dFtpXS5fc2VsZWN0Q2hpbGRzKHN1YlBhdGgsIGZhbHNlKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdG90YWw7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsZXQgbmV4dDtcbiAgICAgICAgICAgIGNvbnN0IHN0ciA9IHBhdGguc3Vic3RyKDAsIGFycm93SWR4KTtcbiAgICAgICAgICAgIGlmIChpc1JlZikge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJlZiA9IHRoaXMuZ2V0QnlSZWYoc3RyKTtcbiAgICAgICAgICAgICAgICBuZXh0ID0gcmVmID8gW3JlZl0gOiBbXTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbmV4dCA9IHRoaXMubXRhZyhzdHIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGV0IHRvdGFsID0gW107XG4gICAgICAgICAgICBjb25zdCBzdWJQYXRoID0gcGF0aC5zdWJzdHIoYXJyb3dJZHggKyAxKTtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gbmV4dC5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB0b3RhbCA9IHRvdGFsLmNvbmNhdChuZXh0W2ldLl9zZWxlY3RDaGlsZHMoc3ViUGF0aCwgdHJ1ZSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRvdGFsO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0QnlSZWYocmVmKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNoaWxkTGlzdC5nZXRCeVJlZihyZWYpO1xuICAgIH1cblxuICAgIGdldExvY2F0aW9uU3RyaW5nKCkge1xuICAgICAgICBsZXQgaTtcbiAgICAgICAgaSA9IHRoaXMuX19wYXJlbnQgPyB0aGlzLl9fcGFyZW50Ll9jaGlsZHJlbi5nZXRJbmRleCh0aGlzKSA6IFwiUlwiO1xuICAgICAgICBsZXQgbG9jYWxUYWdzID0gdGhpcy5nZXRUYWdzKCk7XG4gICAgICAgIGxldCBzdHIgPSB0aGlzLl9fcGFyZW50ID8gdGhpcy5fX3BhcmVudC5nZXRMb2NhdGlvblN0cmluZygpOiBcIlwiO1xuICAgICAgICBpZiAodGhpcy5yZWYpIHtcbiAgICAgICAgICAgIHN0ciArPSBcIjpbXCIgKyBpICsgXCJdXCIgKyB0aGlzLnJlZjtcbiAgICAgICAgfSBlbHNlIGlmIChsb2NhbFRhZ3MubGVuZ3RoKSB7XG4gICAgICAgICAgICBzdHIgKz0gXCI6W1wiICsgaSArIFwiXVwiICsgbG9jYWxUYWdzLmpvaW4oXCIsXCIpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RyICs9IFwiOltcIiArIGkgKyBcIl0jXCIgKyB0aGlzLmlkO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzdHI7XG4gICAgfVxuXG4gICAgdG9TdHJpbmcoKSB7XG4gICAgICAgIGxldCBvYmogPSB0aGlzLmdldFNldHRpbmdzKCk7XG4gICAgICAgIHJldHVybiBFbGVtZW50LmdldFByZXR0eVN0cmluZyhvYmosIFwiXCIpO1xuICAgIH07XG5cbiAgICBzdGF0aWMgZ2V0UHJldHR5U3RyaW5nKG9iaiwgaW5kZW50KSB7XG4gICAgICAgIGxldCBjaGlsZHJlbiA9IG9iai5jaGlsZHJlbjtcbiAgICAgICAgZGVsZXRlIG9iai5jaGlsZHJlbjtcblxuXG4gICAgICAgIC8vIENvbnZlcnQgc2luZ3VsYXIganNvbiBzZXR0aW5ncyBvYmplY3QuXG4gICAgICAgIGxldCBjb2xvcktleXMgPSBbXCJjb2xvclwiLCBcImNvbG9yVWxcIiwgXCJjb2xvclVyXCIsIFwiY29sb3JCbFwiLCBcImNvbG9yQnJcIl07XG4gICAgICAgIGxldCBzdHIgPSBKU09OLnN0cmluZ2lmeShvYmosIGZ1bmN0aW9uIChrLCB2KSB7XG4gICAgICAgICAgICBpZiAoY29sb3JLZXlzLmluZGV4T2YoaykgIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFwiQ09MT1JbXCIgKyB2LnRvU3RyaW5nKDE2KSArIFwiXVwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgIH0pO1xuICAgICAgICBzdHIgPSBzdHIucmVwbGFjZSgvXCJDT0xPUlxcWyhbYS1mMC05XXsxLDh9KVxcXVwiL2csIFwiMHgkMVwiKTtcblxuICAgICAgICBpZiAoY2hpbGRyZW4pIHtcbiAgICAgICAgICAgIGxldCBjaGlsZFN0ciA9IFwiXCI7XG4gICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKGNoaWxkcmVuKSkge1xuICAgICAgICAgICAgICAgIGxldCByZWZzID0gT2JqZWN0LmtleXMoY2hpbGRyZW4pO1xuICAgICAgICAgICAgICAgIGNoaWxkU3RyID0gXCJcIjtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHJlZnMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkU3RyICs9IGBcXG4ke2luZGVudH0gIFwiJHtyZWZzW2ldfVwiOmBcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlIGNoaWxkcmVuW3JlZnNbaV1dLnJlZjtcbiAgICAgICAgICAgICAgICAgICAgY2hpbGRTdHIgKz0gRWxlbWVudC5nZXRQcmV0dHlTdHJpbmcoY2hpbGRyZW5bcmVmc1tpXV0sIGluZGVudCArIFwiICBcIikgKyAoaSA8IG4gLSAxID8gXCIsXCIgOiBcIlwiKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgbGV0IGlzRW1wdHkgPSAoc3RyID09PSBcInt9XCIpO1xuICAgICAgICAgICAgICAgIHN0ciA9IHN0ci5zdWJzdHIoMCwgc3RyLmxlbmd0aCAtIDEpICsgKGlzRW1wdHkgPyBcIlwiIDogXCIsXCIpICsgY2hpbGRTdHIgKyBcIlxcblwiICsgaW5kZW50ICsgXCJ9XCI7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGxldCBuID0gY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGNoaWxkU3RyID0gXCJbXCI7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgY2hpbGRTdHIgKz0gRWxlbWVudC5nZXRQcmV0dHlTdHJpbmcoY2hpbGRyZW5baV0sIGluZGVudCArIFwiICBcIikgKyAoaSA8IG4gLSAxID8gXCIsXCIgOiBcIlwiKSArIFwiXFxuXCI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNoaWxkU3RyICs9IGluZGVudCArIFwiXX1cIjtcbiAgICAgICAgICAgICAgICBsZXQgaXNFbXB0eSA9IChzdHIgPT09IFwie31cIik7XG4gICAgICAgICAgICAgICAgc3RyID0gc3RyLnN1YnN0cigwLCBzdHIubGVuZ3RoIC0gMSkgKyAoaXNFbXB0eSA/IFwiXCIgOiBcIixcIikgKyBcIlxcXCJjaGlsZHJlblxcXCI6XFxuXCIgKyBpbmRlbnQgKyBjaGlsZFN0ciArIFwifVwiO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gc3RyO1xuICAgIH1cblxuICAgIGdldFNldHRpbmdzKCkge1xuICAgICAgICBsZXQgc2V0dGluZ3MgPSB0aGlzLmdldE5vbkRlZmF1bHRzKCk7XG5cbiAgICAgICAgbGV0IGNoaWxkcmVuID0gdGhpcy5fY2hpbGRyZW4uZ2V0KCk7XG4gICAgICAgIGlmIChjaGlsZHJlbikge1xuICAgICAgICAgICAgbGV0IG4gPSBjaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgICAgICBpZiAobikge1xuICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkQXJyYXkgPSBbXTtcbiAgICAgICAgICAgICAgICBsZXQgbWlzc2luZyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoaWxkQXJyYXkucHVzaChjaGlsZHJlbltpXS5nZXRTZXR0aW5ncygpKTtcbiAgICAgICAgICAgICAgICAgICAgbWlzc2luZyA9IG1pc3NpbmcgfHwgIWNoaWxkcmVuW2ldLnJlZjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoIW1pc3NpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgc2V0dGluZ3MuY2hpbGRyZW4gPSB7fVxuICAgICAgICAgICAgICAgICAgICBjaGlsZEFycmF5LmZvckVhY2goY2hpbGQgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0dGluZ3MuY2hpbGRyZW5bY2hpbGQucmVmXSA9IGNoaWxkO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzZXR0aW5ncy5jaGlsZHJlbiA9IGNoaWxkQXJyYXk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgc2V0dGluZ3MuaWQgPSB0aGlzLmlkO1xuXG4gICAgICAgIHJldHVybiBzZXR0aW5ncztcbiAgICB9XG5cbiAgICBnZXROb25EZWZhdWx0cygpIHtcbiAgICAgICAgbGV0IHNldHRpbmdzID0ge307XG5cbiAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgIT09IEVsZW1lbnQpIHtcbiAgICAgICAgICAgIHNldHRpbmdzLnR5cGUgPSB0aGlzLmNvbnN0cnVjdG9yLm5hbWU7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fX3JlZikge1xuICAgICAgICAgICAgc2V0dGluZ3MucmVmID0gdGhpcy5fX3JlZjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9fdGFncyAmJiB0aGlzLl9fdGFncy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHNldHRpbmdzLnRhZ3MgPSB0aGlzLl9fdGFncztcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLnggIT09IDApIHNldHRpbmdzLnggPSB0aGlzLng7XG4gICAgICAgIGlmICh0aGlzLnkgIT09IDApIHNldHRpbmdzLnkgPSB0aGlzLnk7XG4gICAgICAgIGlmICh0aGlzLncgIT09IDApIHNldHRpbmdzLncgPSB0aGlzLnc7XG4gICAgICAgIGlmICh0aGlzLmggIT09IDApIHNldHRpbmdzLmggPSB0aGlzLmg7XG5cbiAgICAgICAgaWYgKHRoaXMuc2NhbGVYID09PSB0aGlzLnNjYWxlWSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuc2NhbGVYICE9PSAxKSBzZXR0aW5ncy5zY2FsZSA9IHRoaXMuc2NhbGVYO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuc2NhbGVYICE9PSAxKSBzZXR0aW5ncy5zY2FsZVggPSB0aGlzLnNjYWxlWDtcbiAgICAgICAgICAgIGlmICh0aGlzLnNjYWxlWSAhPT0gMSkgc2V0dGluZ3Muc2NhbGVZID0gdGhpcy5zY2FsZVk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5waXZvdFggPT09IHRoaXMucGl2b3RZKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5waXZvdFggIT09IDAuNSkgc2V0dGluZ3MucGl2b3QgPSB0aGlzLnBpdm90WDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnBpdm90WCAhPT0gMC41KSBzZXR0aW5ncy5waXZvdFggPSB0aGlzLnBpdm90WDtcbiAgICAgICAgICAgIGlmICh0aGlzLnBpdm90WSAhPT0gMC41KSBzZXR0aW5ncy5waXZvdFkgPSB0aGlzLnBpdm90WTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLm1vdW50WCA9PT0gdGhpcy5tb3VudFkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLm1vdW50WCAhPT0gMCkgc2V0dGluZ3MubW91bnQgPSB0aGlzLm1vdW50WDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh0aGlzLm1vdW50WCAhPT0gMCkgc2V0dGluZ3MubW91bnRYID0gdGhpcy5tb3VudFg7XG4gICAgICAgICAgICBpZiAodGhpcy5tb3VudFkgIT09IDApIHNldHRpbmdzLm1vdW50WSA9IHRoaXMubW91bnRZO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuYWxwaGEgIT09IDEpIHNldHRpbmdzLmFscGhhID0gdGhpcy5hbHBoYTtcblxuICAgICAgICBpZiAoIXRoaXMudmlzaWJsZSkgc2V0dGluZ3MudmlzaWJsZSA9IGZhbHNlO1xuXG4gICAgICAgIGlmICh0aGlzLnJvdGF0aW9uICE9PSAwKSBzZXR0aW5ncy5yb3RhdGlvbiA9IHRoaXMucm90YXRpb247XG5cbiAgICAgICAgaWYgKHRoaXMuY29sb3JVbCA9PT0gdGhpcy5jb2xvclVyICYmIHRoaXMuY29sb3JCbCA9PT0gdGhpcy5jb2xvckJyICYmIHRoaXMuY29sb3JVbCA9PT0gdGhpcy5jb2xvckJsKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5jb2xvclVsICE9PSAweEZGRkZGRkZGKSBzZXR0aW5ncy5jb2xvciA9IHRoaXMuY29sb3JVbC50b1N0cmluZygxNik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5jb2xvclVsICE9PSAweEZGRkZGRkZGKSBzZXR0aW5ncy5jb2xvclVsID0gdGhpcy5jb2xvclVsLnRvU3RyaW5nKDE2KTtcbiAgICAgICAgICAgIGlmICh0aGlzLmNvbG9yVXIgIT09IDB4RkZGRkZGRkYpIHNldHRpbmdz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aWYgKE9iamVjdC5rZXlzKHRuZCkubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgc2V0dGluZ3Muc2hhZGVyID0gdG5kO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX2hhc1RleHR1cml6ZXIoKSkge1xuICAgICAgICAgICAgaWYgKHRoaXMudGV4dHVyaXplci5lbmFibGVkKSB7XG4gICAgICAgICAgICAgICAgc2V0dGluZ3MucmVuZGVyVG9UZXh0dXJlID0gdGhpcy50ZXh0dXJpemVyLmVuYWJsZWQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy50ZXh0dXJpemVyLmxhenkpIHtcbiAgICAgICAgICAgICAgICBzZXR0aW5ncy5yZW5kZXJUb1RleHR1cmVMYXp5ID0gdGhpcy50ZXh0dXJpemVyLmxhenk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy50ZXh0dXJpemVyLmNvbG9yaXplKSB7XG4gICAgICAgICAgICAgICAgc2V0dGluZ3MuY29sb3JpemVSZXN1bHRUZXh0dXJlID0gdGhpcy50ZXh0dXJpemVyLmNvbG9yaXplO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMudGV4dHVyaXplci5yZW5kZXJPZmZzY3JlZW4pIHtcbiAgICAgICAgICAgICAgICBzZXR0aW5ncy5yZW5kZXJPZmZzY3JlZW4gPSB0aGlzLnRleHR1cml6ZXIucmVuZGVyT2Zmc2NyZWVuO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHNldHRpbmdzO1xuICAgIH07XG5cbiAgICBzdGF0aWMgZ2V0R2V0dGVyKHByb3BlcnR5UGF0aCkge1xuICAgICAgICBsZXQgZ2V0dGVyID0gRWxlbWVudC5QUk9QX0dFVFRFUlMuZ2V0KHByb3BlcnR5UGF0aCk7XG4gICAgICAgIGlmICghZ2V0dGVyKSB7XG4gICAgICAgIC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2ZSBmbGFnLlxuICAgICAgICBpZiAodGhpcy5fX2FjdGl2ZSkge1xuICAgICAgICAgICAgdGhpcy5fdW5zZXRBY3RpdmVGbGFnKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzZXQgYm91bmRzTWFyZ2luKHYpIHtcbiAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHYpICYmIHYgIT09IG51bGwpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcImJvdW5kc01hcmdpbiBzaG91bGQgYmUgYW4gYXJyYXkgb2YgbGVmdC10b3AtcmlnaHQtYm90dG9tIHZhbHVlcyBvciBudWxsIChpbmhlcml0IG1hcmdpbilcIik7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fX2NvcmUuYm91bmRzTWFyZ2luID0gdjtcbiAgICB9XG5cbiAgICBnZXQgYm91bmRzTWFyZ2luKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuYm91bmRzTWFyZ2luO1xuICAgIH1cblxuICAgIGdldCB4KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUub2Zmc2V0WDtcbiAgICB9XG5cbiAgICBzZXQgeCh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLm9mZnNldFggPSB2O1xuICAgIH1cblxuICAgIGdldCB5KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUub2Zmc2V0WTtcbiAgICB9XG5cbiAgICBzZXQgeSh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLm9mZnNldFkgPSB2O1xuICAgIH1cblxuICAgIGdldCB3KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdztcbiAgICB9XG5cbiAgICBzZXQgdyh2KSB7XG4gICAgICAgIGlmIChVdGlscy5pc0Z1bmN0aW9uKHYpKSB7XG4gICAgICAgICAgICB0aGlzLl93ID0gMDtcbiAgICAgICAgICAgIHRoaXMuX19jb3JlLmZ1bmNXID0gdjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHYgPSBNYXRoLm1heCh2LCAwKTtcbiAgICAgICAgICAgIGlmICh0aGlzLl93ICE9PSB2KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX2NvcmUuZGlzYWJsZUZ1bmNXKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fdyA9IHY7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlRGltZW5zaW9ucygpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oO1xuICAgIH1cblxuICAgIHNldCBoKHYpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzRnVuY3Rpb24odikpIHtcbiAgICAgICAgICAgIHRoaXMuX2ggPSAwO1xuICAgICAgICAgICAgdGhpcy5fX2NvcmUuZnVuY0ggPSB2O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdiA9IE1hdGgubWF4KHYsIDApO1xuICAgICAgICAgICAgaWYgKHRoaXMuX2ggIT09IHYpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9fY29yZS5kaXNhYmxlRnVuY0goKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9oID0gdjtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgY29sbGlzaW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY29sbGlzaW9uO1xuICAgIH1cblxuICAgIHNldCBjb2xsaXNpb24odikge1xuICAgICAgICB0aGlzLl9jb2xsaXNpb24gPSB2O1xuICAgIH1cblxuICAgIF91cGRhdGVDb2xsaXNpb24oKSB7XG4gICAgICAgIGlmICh0aGlzLmNvbGxpc2lvbiAmJiB0aGlzLl9fcGFyZW50ICYmIHRoaXMuX19wYXJlbnQuY29sbGlzaW9uID09PSB1bmRlZmluZW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B9XG5cbiAgICBzZXQgcGl2b3RZKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUucGl2b3RZID0gdjtcbiAgICB9XG5cbiAgICBnZXQgcGl2b3QoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5waXZvdDtcbiAgICB9XG5cbiAgICBzZXQgcGl2b3Qodikge1xuICAgICAgICB0aGlzLl9fY29yZS5waXZvdCA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IG1vdW50WCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLm1vdW50WDtcbiAgICB9XG5cbiAgICBzZXQgbW91bnRYKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUubW91bnRYID0gdjtcbiAgICB9XG5cbiAgICBnZXQgbW91bnRZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUubW91bnRZO1xuICAgIH1cblxuICAgIHNldCBtb3VudFkodikge1xuICAgICAgICB0aGlzLl9fY29yZS5tb3VudFkgPSB2O1xuICAgIH1cblxuICAgIGdldCBtb3VudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLm1vdW50O1xuICAgIH1cblxuICAgIHNldCBtb3VudCh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLm1vdW50ID0gdjtcbiAgICB9XG5cbiAgICBnZXQgcm90YXRpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5yb3RhdGlvbjtcbiAgICB9XG5cbiAgICBzZXQgcm90YXRpb24odikge1xuICAgICAgICB0aGlzLl9fY29yZS5yb3RhdGlvbiA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IGFscGhhKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuYWxwaGE7XG4gICAgfVxuXG4gICAgc2V0IGFscGhhKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuYWxwaGEgPSB2O1xuICAgIH1cblxuICAgIGdldCB2aXNpYmxlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUudmlzaWJsZTtcbiAgICB9XG5cbiAgICBzZXQgdmlzaWJsZSh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLnZpc2libGUgPSB2O1xuICAgIH1cbiAgICBcbiAgICBnZXQgY29sb3JVbCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNvbG9yVWw7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yVWwodikge1xuICAgICAgICB0aGlzLl9fY29yZS5jb2xvclVsID0gdjtcbiAgICB9XG5cbiAgICBnZXQgY29sb3JVcigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNvbG9yVXI7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yVXIodikge1xuICAgICAgICB0aGlzLl9fY29yZS5jb2xvclVyID0gdjtcbiAgICB9XG5cbiAgICBnZXQgY29sb3JCbCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNvbG9yQmw7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yQmwodikge1xuICAgICAgICB0aGlzLl9fY29yZS5jb2xvckJsID0gdjtcbiAgICB9XG5cbiAgICBnZXQgY29sb3JCcigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmNvbG9yQnI7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yQnIodikge1xuICAgICAgICB0aGlzLl9fY29yZS5jb2xvckJyID0gdjtcbiAgICB9XG5cbiAgICBnZXQgY29sb3IoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jb2xvclVsO1xuICAgIH1cblxuICAgIHNldCBjb2xvcih2KSB7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yVWwgIT09IHYgfHwgdGhpcy5jb2xvclVyICE9PSB2IHx8IHRoaXMuY29sb3JCbCAhPT0gdiB8fCB0aGlzLmNvbG9yQnIgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuY29sb3JVbCA9IHY7XG4gICAgICAgICAgICB0aGlzLmNvbG9yVXIgPSB2O1xuICAgICAgICAgICAgdGhpcy5jb2xvckJsID0gdjtcbiAgICAgICAgICAgIHRoaXMuY29sb3JCciA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgY29sb3JUb3AoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNvbG9yVWw7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yVG9wKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuY29sb3JVbCAhPT0gdiB8fCB0aGlzLmNvbG9yVXIgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuY29sb3JVbCA9IHY7XG4gICAgICAgICAgICB0aGlzLmNvbG9yVXIgPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yQm90dG9tKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5jb2xvckJsO1xuICAgIH1cblxuICAgIHNldCBjb2xvckJvdHRvbSh2KSB7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yQmwgIT09IHYgfHwgdGhpcy5jb2xvckJyICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLmNvbG9yQmwgPSB2O1xuICAgICAgICAgICAgdGhpcy5jb2xvckJyID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBjb2xvckxlZnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNvbG9yVWw7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yTGVmdCh2KSB7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yVWwgIT09IHYgfHwgdGhpcy5jb2xvckJsICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLmNvbG9yVWwgPSB2O1xuICAgICAgICAgICAgdGhpcy5jb2xvckJsID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBjb2xvclJpZ2h0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5jb2xvclVy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yb3dFcnJvcignUGxlYXNlIHNldCBtaCBhZnRlciBzZXR0aW5nIGEgdGV4dHVyZS4nKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCByZWN0KCkge1xuICAgICAgICByZXR1cm4gKHRoaXMudGV4dHVyZSA9PT0gdGhpcy5zdGFnZS5yZWN0YW5nbGVUZXh0dXJlKTtcbiAgICB9XG5cbiAgICBzZXQgcmVjdCh2KSB7XG4gICAgICAgIGlmICh2KSB7XG4gICAgICAgICAgICB0aGlzLnRleHR1cmUgPSB0aGlzLnN0YWdlLnJlY3RhbmdsZVRleHR1cmU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnRleHR1cmUgPSBudWxsO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZW5hYmxlVGV4dFRleHR1cmUoKSB7XG4gICAgICAgIGlmICghdGhpcy50ZXh0dXJlIHx8ICEodGhpcy50ZXh0dXJlIGluc3RhbmNlb2YgVGV4dFRleHR1cmUpKSB7XG4gICAgICAgICAgICB0aGlzLnRleHR1cmUgPSBuZXcgVGV4dFRleHR1cmUodGhpcy5zdGFnZSk7XG5cbiAgICAgICAgICAgIGlmICghdGhpcy50ZXh0dXJlLncgJiYgIXRoaXMudGV4dHVyZS5oKSB7XG4gICAgICAgICAgICAgICAgLy8gSW5oZXJpdCBkaW1lbnNpb25zIGZyb20gZWxlbWVudC5cbiAgICAgICAgICAgICAgICAvLyBUaGlzIGFsbG93cyB1c2VybGFuZCB0byBzZXQgZGltZW5zaW9ucyBvZiB0aGUgRWxlbWVudCBhbmQgdGhlbiBsYXRlciBzcGVjaWZ5IHRoZSB0ZXh0LlxuICAgICAgICAgICAgICAgIHRoaXMudGV4dHVyZS53ID0gdGhpcy53O1xuICAgICAgICAgICAgICAgIHRoaXMudGV4dHVyZS5oID0gdGhpcy5oO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLnRleHR1cmU7XG4gICAgfVx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HtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnRleHR1cml6ZXI7XG4gICAgfVxuXG4gICAgcGF0Y2goc2V0dGluZ3MpIHtcbiAgICAgICAgbGV0IHBhdGhzID0gT2JqZWN0LmtleXMoc2V0dGluZ3MpO1xuXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gcGF0aHMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgcGF0aCA9IHBhdGhzW2ldO1xuICAgICAgICAgICAgY29uc3QgdiA9IHNldHRpbmdzW3BhdGhdO1xuXG4gICAgICAgICAgICBjb25zdCBmaXJzdENoYXJDb2RlID0gcGF0aC5jaGFyQ29kZUF0KDApO1xuICAgICAgICAgICAgaWYgKFV0aWxzLmlzVWNDaGFyKGZpcnN0Q2hhckNvZGUpKSB7XG4gICAgICAgICAgICAgICAgLy8gUmVmLlxuICAgICAgICAgICAgICAgIGNvbnN0IGNoaWxkID0gdGhpcy5nZXRCeVJlZihwYXRoKTtcbiAgICAgICAgICAgICAgICBpZiAoIWNoaWxkKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEFkZCB0byBsaXN0IGltbWVkaWF0ZWx5LlxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGM7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2F0Y2ggdGhpcyBjYXNlIHRvIGNhcHR1cmUgY3JlYXRlTW9kZSBmbGFnLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGMgPSB0aGlzLmNoaWxkTGlzdC5jcmVhdGVJdGVtKHYpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGMucGF0Y2godik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0KHYpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYyA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYy5pc0VsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjLnJlZiA9IHBhdGg7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoYyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpZiAodiA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQucGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGQucGFyZW50LmNoaWxkTGlzdC5yZW1vdmUoY2hpbGQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGQucGF0Y2godik7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodi5pc0VsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFJlcGxhY2UgZWxlbWVudCBieSBuZXcgZWxlbWVudC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHYucmVmID0gcGF0aDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LnJlcGxhY2UodiwgY2hpbGQpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlVuZXhwZWN0ZWQgdmFsdWUgZm9yIHBhdGg6IFwiICsgcGF0aCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIFByb3BlcnR5LlxuICAgICAgICAgICAgICAgIEJhc2UucGF0Y2hPYmplY3RQcm9wZXJ0eSh0aGlzLCBwYXRoLCB2KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF90aHJvd0Vycm9yKG1lc3NhZ2UpIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKHRoaXMuY29uc3RydWN0b3IubmFtZSArIFwiIChcIiArIHRoaXMuZ2V0TG9jYXRpb25TdHJpbmcoKSArIFwiKTogXCIgKyBtZXNzYWdlKTtcbiAgICB9XG5cbiAgICBhbmltYXRpb24oc2V0dGluZ3MpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc3RhZ2UuYW5pbWF0aW9ucy5jcmVhdGVBbmltYXRpb24odGhpcywgc2V0dGluZ3MpO1xuICAgIH1cblxuICAgIHRyYW5zaXRpb24ocHJvcGVydHksIHNldHRpbmdzID0gbnVsbCkge1xuICAgICAgICBpZiAoc2V0dGluZ3MgPT09IG51bGwpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9nZXRUcmFuc2l0aW9uKHByb3BlcnR5KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3NldFRyYW5zaXRpb24ocHJvcGVydHksIHNldHRpbmdzKTtcbiAgICAgICAgICAgIC8vIFdlIGRvIG5vdCBjcmVhdGUvcmV0dXJuIHRoZSB0cmFuc2l0aW9uLCBiZWNhdXNlIGl0IHdvdWxkIHVuZG8gdGhlICdsYXp5IHRyYW5zaXRpb24gY3JlYXRpb24nIG9wdGltaXphdGlvbi5cbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0IHRyYW5zaXRpb25zKG9iamVjdCkge1xuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iamVjdCk7XG4gICAgICAgIGtleXMuZm9yRWFjaChwcm9wZXJ0eSA9PiB7XG4gICAgICAgICAgICB0aGlzLnRyYW5zaXRpb24ocHJvcGVydHksIG9iamVjdFtwcm9wZXJ0eV0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBzZXQgc21vb3RoKG9iamVjdCkge1xuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iamVjdCk7XG4gICAgICAgIGtleXMuZm9yRWFjaChwcm9wZXJ0eSA9PiB7XG4gICAgICAgICAgICBsZXQgdmFsdWUgPSBvYmplY3RbcHJvcGVydHldO1xuICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zZXRTbW9vdGgocHJvcGVydHksIHZhbHVlWzBdLCB2YWx1ZVsxXSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuc2V0U21vb3RoKHByb3BlcnR5LCB2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIGZhc3RGb3J3YXJkKHByb3BlcnR5KSB7XG4gICAgICAgIGlmICh0aGlzLl90cmFuc2l0aW9ucykge1xuICAgICAgICAgICAgbGV0IHQgPSB0aGlzLl90cmFuc2l0aW9uc1twcm9wZXJ0eV07XG4gICAgICAgICAgICBpZiAodCAmJiB0LmlzVHJhbnNpdGlvbikge1xuICAgICAgICAgICAgICAgIHQuZmluaXNoKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0VHJhbnNpdGlvbihwcm9wZXJ0eSkge1xuICAgICAgICBpZiAoIXRoaXMuX3RyYW5zaXRpb25zKSB7XG4gICAgICAgICAgICB0aGlzLl90cmFuc2l0aW9ucyA9IHt9O1xuICAgICAgICB9XG4gICAgICAgIGxldCB0ID0gdGhpcy5fdHJhbnNpdGlvbnNbcHJvcGVydHldO1xuICAgICAgICBpZiAoIXQpIHtcbiAgICAgICAgICAgIC8vIENyZWF0ZSBkZWZhdWx0IHRyYW5zaXRpb24uXG4gICAgICAgICAgICB0ID0gbmV3IFRyYW5zaXRpb24odGhpcy5zdGFnZS50cmFuc2l0aW9ucywgdGhpcy5zdGFnZS50cmFuc2l0aW9ucy5kZWZhdWx0VHJhbnNpdGlvblNldHRpbmdzLCB0aGlzLCBwcm9wZXJ0eSk7XG4gICAgICAgIH0gZWxzZSBpZiAodC5pc1RyYW5zaXRpb25TZXR0aW5ncykge1xuICAgICAgICAgICAgLy8gVXBncmFkZSB0byAncmVhbCcgdHJhbnNpdGlvbi5cbiAgICAgICAgICAgIHQgPSBuZXcgVHJhbnNpdGlvbihcbiAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLnRyYW5zaXRpb25zLFxuICAgICAgICAgICAgICAgIHQsXG4gICAgICAgICAgICAgICAgdGhpcyxcbiAgICAgICAgICAgICAgICBwcm9wZXJ0eVxuICAgICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl90cmFuc2l0aW9uc1twcm9wZXJ0eV0gPSB0O1xuICAgICAgICByZXR1cm4gdDtcbiAgICB9XG5cbiAgICBfc2V0VHJhbnNpdGlvbihwcm9wZXJ0eSwgc2V0dGluZ3MpIHtcbiAgICAgICAgaWYgKCFzZXR0aW5ncykge1xuICAgICAgICAgICAgdGhpcy5fcmVtb3ZlVHJhbnNpdGlvbihwcm9wZXJ0eSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHNldHRpbmdzKSkge1xuICAgICAgICAgICAgICAgIC8vIENvbnZlcnQgcGxhaW4gb2JqZWN0IHRvIHByb3BlciBzZXR0aW5ncyBvYmplY3QuXG4gICAgICAgICAgICAgICAgc2V0dGluZ3MgPSB0aGlzLnN0YWdlLnRyYW5zaXRpb25zLmNyZWF0ZVNldHRpbmdzKHNldHRpbmdzKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKCF0aGlzLl90cmFuc2l0aW9ucykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zaXRpb25zID0ge307XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gdGhpcy5fdHJhbnNpdGlvbnNbcHJvcGVydHldO1xuICAgICAgICAgICAgaWYgKGN1cnJlbnQgJiYgY3VycmVudC5pc1RyYW5zaXRpb24pIHtcbiAgICAgICAgICAgICAgICAvLyBSdW50aW1lIHNldHRpbmdzIGNoYW5nZS5cbiAgICAgICAgICAgICAgICBjdXJyZW50LnNldHRpbmdzID0gc2V0dGluZ3M7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGN1cnJlbnQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIEluaXRpYWxseSwgb25seSBzZXQgdGhlIHNldHRpbmdzIGFuZCB1cGdyYWRlIHRvIGEgJ3JlYWwnIHRyYW5zaXRpb24gd2hlbiBpdCBpcyB1c2VkLlxuICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zaXRpb25zW3Byb3BlcnR5XSA9IHNldHRpbmdzO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3JlbW92ZVRyYW5zaXRpb24ocHJvcGVydHkpIHtcbiAgICAgICAgaWYgKHRoaXMuX3RyYW5zaXRpb25zKSB7XG4gICAgICAgICAgICBkZWxldGUgdGhpcy5fdHJhbnNpdGlvbnNbcHJvcGVydHldO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0U21vb3RoKHByb3BlcnR5LCB2KSB7XG4gICAgICAgIGxldCB0ID0gdGhpcy5fZ2V0VHJhbnNpdGlvbihwcm9wZXJ0eSk7XG4gICAgICAgIGlmICh0ICYmIHQuaXNBdHRhY2hlZC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AgICAgICAgICBjb25zdCBnZXRCb29sZWFuID0gL14hezJ9LztcbiAgICAgICAgICAgIGNvbnN0IGlzRnVuY3Rpb24gPSAvXFwoXFwpJC87XG5cbiAgICAgICAgICAgIGlmIChnZXRCb29sZWFuLnRlc3Qoa2V5KSkge1xuICAgICAgICAgICAgICAgIGtleSA9IGtleS5zdWJzdHJpbmcoMiwga2V5Lmxlbmd0aCk7XG4gICAgICAgICAgICAgICAgcHJvcHNba2V5XSA9ICEhZWxlbWVudFtrZXldO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpc0Z1bmN0aW9uLnRlc3Qoa2V5KSkge1xuICAgICAgICAgICAgICAgIGtleSA9IGtleS5zdWJzdHJpbmcoMCwga2V5Lmxlbmd0aCAtIDIpO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZWxlbWVudFtrZXldID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgcHJvcHNba2V5XSA9IGVsZW1lbnRba2V5XSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcHJvcHNba2V5XSA9IGVsZW1lbnRba2V5XTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gey4uLnByb3BzLCAuLi5lbGVtZW50LmdldE5vbkRlZmF1bHRzKCl9O1xuICAgIH1cbn1cblxuLy8gVGhpcyBnaXZlcyBhIHNsaWdodCBwZXJmb3JtYW5jZSBiZW5lZml0IGNvbXBhcmVkIHRvIGV4dGVuZGluZyBFdmVudEVtaXR0ZXIuXG5FdmVudEVtaXR0ZXIuYWRkQXNNaXhpbihFbGVtZW50KTtcblxuRWxlbWVudC5wcm90b3R5cGUuaXNFbGVtZW50ID0gMTtcblxuRWxlbWVudC5pZCA9IDE7XG5cbi8vIEdldHRlcnMgcmV1c2VkIHdoZW4gcmVmZXJlbmNpbmcgZWxlbWVudCAoc3Vib2JqZWN0KS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+PSAwICYmIGluZGV4IDw9IHRoaXMuX2l0ZW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgbGV0IGN1cnJlbnRJbmRleCA9IHRoaXMuX2l0ZW1zLmluZGV4T2YoaXRlbSk7XG4gICAgICAgICAgICBpZiAoY3VycmVudEluZGV4ID09PSBpbmRleCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBpdGVtO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbyA9IGl0ZW07XG4gICAgICAgICAgICAgICAgaXRlbSA9IHRoaXMuY3JlYXRlSXRlbShvKTtcbiAgICAgICAgICAgICAgICBpdGVtLnBhdGNoKG8pO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoY3VycmVudEluZGV4ICE9IC0xKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zZXRBdChpdGVtLCBpbmRleCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChpdGVtLnJlZikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWZzW2l0ZW0ucmVmXSA9IGl0ZW07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX2l0ZW1zLnNwbGljZShpbmRleCwgMCwgaXRlbSk7XG4gICAgICAgICAgICAgICAgdGhpcy5vbkFkZChpdGVtLCBpbmRleCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ2FkZEF0OiBUaGUgaW5kZXggJyArIGluZGV4ICsgJyBpcyBvdXQgb2YgYm91bmRzICcgKyB0aGlzLl9pdGVtcy5sZW5ndGgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmVwbGFjZUJ5UmVmKGl0ZW0pIHtcbiAgICAgICAgaWYgKGl0Z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IGl0ZW0gPSB0aGlzLmNyZWF0ZUl0ZW0obyk7XG4gICAgICAgICAgICAgICAgaXRlbS5wYXRjaChvKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IGN1cnJlbnRJbmRleCA9IHRoaXMuX2l0ZW1zLmluZGV4T2YoaXRlbSk7XG4gICAgICAgICAgICBpZiAoY3VycmVudEluZGV4ICE9IC0xKSB7XG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRJbmRleCAhPT0gaW5kZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZnJvbUluZGV4ID0gY3VycmVudEluZGV4O1xuICAgICAgICAgICAgICAgICAgICBpZiAoZnJvbUluZGV4ICE9PSBpbmRleCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXRlbXMuc3BsaWNlKGZyb21JbmRleCwgMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pdGVtcy5zcGxpY2UoaW5kZXgsIDAsIGl0ZW0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbk1vdmUoaXRlbSwgZnJvbUluZGV4LCBpbmRleCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmKCBpbmRleCA8IHRoaXMuX2l0ZW1zLmxlbmd0aCl7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2l0ZW1zW2luZGV4XS5yZWYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlZnNbdGhpcy5faXRlbXNbaW5kZXhdLnJlZl0gPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBjb25zdCBwcmV2SXRlbSA9IHRoaXMuX2l0ZW1zW2luZGV4XTtcblxuICAgICAgICAgICAgICAgICAgICAvLyBEb2Vzbid0IGV4aXN0IHlldDogb3ZlcndyaXRlIGN1cnJlbnQuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2l0ZW1zW2luZGV4XSA9IGl0ZW07XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0ucmVmKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWZzW2l0ZW0ucmVmXSA9IGl0ZW07XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICB0aGlzLm9uU2V0KGl0ZW0sIGluZGV4LCBwcmV2SXRlbSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdzZXRBdDogVGhlIGluZGV4ICcgKyBpbmRleCArICcgaXMgb3V0IG9mIGJvdW5kcyAnICsgdGhpcy5faXRlbXMubGVuZ3RoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ3NldEF0OiBUaGUgaW5kZXggJyArIGluZGV4ICsgJyBpcyBvdXQgb2YgYm91bmRzICcgKyB0aGlzLl9pdGVtcy5sZW5ndGgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0QXQoaW5kZXgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2l0ZW1zW2luZGV4XTtcbiAgICB9XG5cbiAgICBnZXRJbmRleChpdGVtKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9pdGVtcy5pbmRleE9mKGl0ZW0pO1xuICAgIH1cblxuICAgIHJlbW92ZShpdGVtKSB7XG4gICAgICAgIGxldCBpbmRleCA9IHRoaXMuX2l0ZW1zLmluZGV4T2YoaXRlbSk7XG5cbiAgICAgICAgaWYgKGluZGV4ICE9PSAtMSkge1xuICAgICAgICAgICAgdGhpcy5yZW1vdmVBdChpbmRleCk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgcmVtb3ZlQXQoaW5kZXgpIHtcbiAgICAgICAgaWYgKGluZGV4ID49IDAgJiYgaW5kZXggPCB0aGlzLl9pdGVtcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSB0aGlzLl9pdGVtc1tpbmRleF07XG5cbiAgICAgICAgICAgIGlmIChpdGVtLnJlZikge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlZnNbaXRlbS5yZWZdID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9pdGVtcy5zcGxpY2UoaW5kZXgsIDEpO1xuXG4gICAgICAgICAgICB0aGlzLm9uUmVtb3ZlKGl0ZW0sIGluZGV4KTtcblxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYHJlbW92ZUF0OiBUaGUgaW5kZXggJHtpbmRleH0gaXMgb3V0IG9mIGJvdW5kcyAke3RoaXMuX2l0ZW1zLmxlbmd0aCAtIDF9YCk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgY2xlYXIoKSB7XG4gICAgICAgIGxldCBuID0gdGhpcy5faXRlbXMubGVuZ3RoO1xuICAgICAgICBpZiAobikge1xuICAgICAgICAgICAgbGV0IHByZXYgPSB0aGlzLl9pdGVtcztcbiAgICAgICAgICAgIHRoaXMuX2l0ZW1zID0gW107XG4gICAgICAgICAgICB0aGlzLl9yZWZzID0ge31cbiAgICAgICAgICAgIHRoaXMub25TeW5jKHByZXYsIFtdLCBbXSk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgYShvKSB7XG4gICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwobykpIHtcbiAgICAgICAgICAgIGxldCBjID0gdGhpcy5jcmVhdGVJdGVtKG8pO1xuICAgICAgICAgICAgYy5wYXRjaChvKTtcbiAgICAgICAgICAgIHRoaXMuYWRkKGMpO1xuICAgICAgICAgICAgcmV0dXJuIGM7XG4gICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShvKSkge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBvLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHRoaXMuYShvW2ldKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaXNJdGVtKG8pKSB7XG4gICAgICAgICAgICB0aGlzLmFkZChvKTtcbiAgICAgICAgICAgIHJldHVybiBvO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldCBsZW5ndGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9pdGVtcy5sZW5ndGg7XG4gICAgfVxuXG4gICAgX2dldFJlZnMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yZWZzO1xuICAgIH1cblxuICAgIGdldEJ5UmVmKHJlZikge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmVmc1tyZWZdO1xuICAgIH1cblxuICAgIGNsZWFyUmVmKHJlZikge1xuICAgICAgICBkZWxldGUgdGhpcy5fcmVmc1tyZWZdO1xuICAgIH1cblxuICAgIHNldFJlZihyZWYsIGNoaWxkKSB7XG4gICAgICAgIHRoaXMuX3JlZnNbcmVmXSA9IGNoaWxkO1xuICAgIH1cblxuICAgIHBhdGNoKHNldHRpbmdzKSB7XG4gICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwoc2V0dGluZ3MpKSB7XG4gICAgICAgICAgICB0aGlzLl9zZXRCeU9iamVjdChzZXR0aW5ncyk7XG4gICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShzZXR0aW5ncykpIHtcbiAgICAgICAgICAgIHRoaXMuX3NldEJ5QXJyYXkoc2V0dGluZ3MpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3NldEJ5T2JqZWN0KHNldHRpbmdzKSB7XG4gICAgICAgIC8vIE92ZXJydWxlIHNldHRpbmdzIG9mIGtub3duIHJlZmVyZW5jZWQgaXRlbXMuXG4gICAgICAgIGxldCByZWZzID0gdGhpcy5fZ2V0UmVmcygpO1xuICAgICAgICBsZXQgY3JlZnMgPSBPYmplY3Qua2V5cyhzZXR0aW5ncyk7XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gY3JlZnMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgY3JlZiA9IGNyZWZzW2ldO1xuICAgICAgICAgICAgbGV0IHMgPSBzZXR0aW5nc1tjcmVmXTtcblxuICAgICAgICAgICAgbGV0IGMgPSByZWZzW2NyZWZdO1xuICAgICAgICAgICAgaWYgKCFjKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJdGVtKHMpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFJlcGxhY2UgcHJldmlvdXMgaXRlbTtcbiAgICAgICAgICAgICAgICAgICAgcy5yZWYgPSBjcmVmO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChzKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBDcmVhdGUgbmV3IGl0ZW0uXG4gICAgICAgICAgICAgICAgICAgIGMgPSB0aGlzLmNyZWF0ZUl0ZW0ocyk7XG4gICAgICAgICAgICAgICAgICAgIGMucmVmID0gY3JlZjtcbiAgICAgICAgICAgICAgICAgICAgYy5wYXRjaChzKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGQoYyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0l0ZW0ocykpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGMgIT09IHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFJlcGxhY2UgcHJldmlvdXMgaXRlbTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpZHggPSB0aGlzLmdldEluZGV4KGMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcy5yZWYgPSBjcmVmO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdChzLCBpZHgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgYy5wYXRjaChzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZXF1YWxzQXJyYXkoYXJyYXkpIHtcbiAgICAgICAgbGV0IHNhbWUgPSB0cnVlO1xuICAgICAgICBpZiAoYXJyYXkubGVuZ3RoID09PSB0aGlzLl9pdGVtcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5faXRlbXMubGVuZ3RoOyAoaSA8IG4pICYmIHNhbWU7IGkrKykge1xuICAgICAgICAgICAgICAgIHNhbWUgPSBzYW1lICYmICh0aGlzLl9pdGVtc1tpXSA9PT0gYXJyYXlbaV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc2FtZSA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzYW1lO1xuICAgIH1cblxuICAgIF9zZXRCeUFycmF5KGFycmF5KSB7XG4gICAgICAgIC8vIEZvciBwZXJmb3JtYW5jZSByZWFzb25zLCBmaXJzdCBjaGVjayBpZiB0aGUgYXJyYXlzIG1hdGNoIGV4YWN0bHkgYW5kIGJhaWwgb3V0IGlmIHRoZXkgZG8uXG4gICAgICAgIGlmICh0aGlzLl9lcXVhbHNBcnJheShhcnJheSkpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5faXRlbXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICB0aGlzLl9pdGVtc1tpXS5tYXJrZXIgPSB0cnVlO1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IHJlZnM7XG4gICAgICAgIGxldCBuZXdJdGVtcyA9IFtdO1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGFycmF5Lmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbGV0IHMgPSBhcnJheVtpXTtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzSXRlbShzKSkge1xuICAgICAgICAgICAgICAgIHMubWFya2VyID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgbmV3SXRlbXMucHVzaChzKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbGV0IGNyZWYgPSBzLnJlZjtcbiAgICAgICAgICAgICAgICBsZXQgYztcbiAgICAgICAgICAgICAgICBpZiAoY3JlZikge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXJlZnMpIHJlZnMgPSB0aGlzLl9nZXRSZWZzKCk7XG4gICAgICAgICAgICAgICAgICAgIGMgPSByZWZzW2NyZWZdO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICghYykge1xuICAgICAgICAgICAgICAgICAgICAvLyBDcmVhdGUgbmV3IGl0ZW0uXG4gICAgICAgICAgICAgICAgICAgIGMgPSB0aGlzLmNyZWF0ZUl0ZW0ocyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgYy5tYXJrZXIgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHMpKSB7XG4gICAgICAgICAgICAgICAgICAgIGMucGF0Y2gocyk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgbmV3SXRl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ICogQHR5cGUge1NldDxFbGVtZW50Q29yZT59XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9lbGVtZW50cyA9IG5ldyBTZXQoKTtcbiAgICB9XG5cbiAgICBzdGF0aWMgY3JlYXRlKHN0YWdlLCB2KSB7XG4gICAgICAgIGxldCBzaGFkZXI7XG4gICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgIGlmICh2LnR5cGUpIHtcbiAgICAgICAgICAgICAgICBzaGFkZXIgPSBzdGFnZS5yZW5kZXJlci5jcmVhdGVTaGFkZXIoc3RhZ2UuY3R4LCB2KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgc2hhZGVyID0gdGhpcy5zaGFkZXI7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChzaGFkZXIpIHtcbiAgICAgICAgICAgICAgICBCYXNlLnBhdGNoT2JqZWN0KHNoYWRlciwgdik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodiA9PT0gbnVsbCkge1xuICAgICAgICAgICAgc2hhZGVyID0gc3RhZ2UuY3R4LnJlbmRlclN0YXRlLmRlZmF1bHRTaGFkZXI7XG4gICAgICAgIH0gZWxzZSBpZiAodiA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICBzaGFkZXIgPSBudWxsO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHYuaXNTaGFkZXIpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXN0YWdlLnJlbmRlcmVyLmlzVmFsaWRTaGFkZXJUeXBlKHYuY29uc3RydWN0b3IpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXCJbTGlnaHRuaW5nXSBJbnZhbGlkIHNoYWRlciB0eXBlXCIpO1xuICAgICAgICAgICAgICAgICAgICB2ID0gbnVsbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2hhZGVyID0gdjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcIltMaWdodG5pbmddIFBsZWFzZSBzcGVjaWZ5IGEgc2hhZGVyIHR5cGUuXCIpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBzaGFkZXI7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldFdlYkdMKCkge1xuICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXRDMmQoKSB7XG4gICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgfVxuXG4gICAgYWRkRWxlbWVudChlbGVtZW50Q29yZSkge1xuICAgICAgICB0aGlzLl9lbGVtZW50cy5hZGQoZWxlbWVudENvcmUpO1xuICAgIH1cblxuICAgIHJlbW92ZUVsZW1lbnQoZWxlbWVudENvcmUpIHtcbiAgICAgICAgdGhpcy5fZWxlbWVudHMuZGVsZXRlKGVsZW1lbnRDb3JlKTtcbiAgICAgICAgaWYgKCF0aGlzLl9lbGVtZW50cykge1xuICAgICAgICAgICAgdGhpcy5jbGVhbnVwKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZWRyYXcoKSB7XG4gICAgICAgIHRoaXMuX2VsZW1lbnRzLmZvckVhY2goZWxlbWVudENvcmUgPT4ge1xuICAgICAgICAgICAgZWxlbWVudENvcmUuc2V0SGFzUmVuZGVyVXBkYXRlcygyKTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgcGF0Y2goc2V0dGluZ3MpIHtcbiAgICAgICAgQmFzZS5wYXRjaE9iamVjdCh0aGlzLCBzZXR0aW5ncyk7XG4gICAgfVxuXG4gICAgdXNlRGVmYXVsdCgpIHtcbiAgICAgICAgLy8gU2hvdWxkIHJldHVybiB0cnVlIGlmIHRoaXMgc2hhZGVyIGlzI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ICAgIGdldCBtb2RlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbW9kZTtcbiAgICB9XG5cbiAgICBpc1dlYmdsKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5tb2RlID09PSAwO1xuICAgIH1cblxuICAgIGlzQzJkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5tb2RlID09PSAxO1xuICAgIH1cblxuICAgIGdldE9wdGlvbihuYW1lKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9vcHRpb25zW25hbWVdO1xuICAgIH1cblxuICAgIF9zZXRPcHRpb25zKG8pIHtcbiAgICAgICAgdGhpcy5fb3B0aW9ucyA9IHt9O1xuXG4gICAgICAgIGxldCBvcHQgPSAobmFtZSwgZGVmKSA9PiB7XG4gICAgICAgICAgICBsZXQgdmFsdWUgPSBvW25hbWVdO1xuXG4gICAgICAgICAgICBpZiAodmFsdWUgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX29wdGlvbnNbbmFtZV0gPSBkZWY7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX29wdGlvbnNbbmFtZV0gPSB2YWx1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIG9wdCgnY2FudmFzJywgbnVsbCk7XG4gICAgICAgIG9wdCgnY29udGV4dCcsIG51bGwpO1xuICAgICAgICBvcHQoJ3cnLCAxOTIwKTtcbiAgICAgICAgb3B0KCdoJywgMTA4MCk7XG4gICAgICAgIG9wdCgnc3JjQmFzZVBhdGgnLCBudWxsKTtcbiAgICAgICAgb3B0KCdtZW1vcnlQcmVzc3VyZScsIDI0ZTYpO1xuICAgICAgICBvcHQoJ2J1ZmZlck1lbW9yeScsIDJlNik7XG4gICAgICAgIG9wdCgndGV4dFJlbmRlcklzc3VlTWFyZ2luJywgMCk7XG4gICAgICAgIG9wdCgnZm9udFNoYXJwJywgeyBwcmVjaXNpb246IDAuNjY2NjY2N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O1xuICAgICAgICBsZXQgZyA9IE1hdGguZmxvb3IoY29sb3JbMV0gKiAyNTUpO1xuICAgICAgICBsZXQgYiA9IE1hdGguZmxvb3IoY29sb3JbMl0gKiAyNTUpO1xuICAgICAgICBsZXQgYSA9IE1hdGguZmxvb3IoY29sb3JbM10gKiAyNTUpIC8gMjU1O1xuICAgICAgICByZXR1cm4gJ3JnYmEoJyArIHIgKyAnLCcgKyBnICsgJywnICsgYiArICcsJyArIGEudG9GaXhlZCg0KSArICcpJztcbiAgICB9O1xuXG4gICAgc3RhdGljIGdldFJnYmFDb21wb25lbnRzTm9ybWFsaXplZChhcmdiKSB7XG4gICAgICAgIGxldCByID0gKChhcmdiIC8gNjU1MzYpIHwgMCkgJSAyNTY7XG4gICAgICAgIGxldCBnID0gKChhcmdiIC8gMjU2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgYiA9IGFyZ2IgJSAyNTY7XG4gICAgICAgIGxldCBhID0gKChhcmdiIC8gMTY3NzcyMTYpIHwgMCk7XG4gICAgICAgIHJldHVybiBbciAvIDI1NSwgZyAvIDI1NSwgYiAvIDI1NSwgYSAvIDI1NV07XG4gICAgfTtcblxuICAgIHN0YXRpYyBnZXRSZ2JDb21wb25lbnRzTm9ybWFsaXplZChhcmdiKSB7XG4gICAgICAgIGxldCByID0gKChhcmdiIC8gNjU1MzYpIHwgMCkgJSAyNTY7XG4gICAgICAgIGxldCBnID0gKChhcmdiIC8gMjU2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgYiA9IGFyZ2IgJSAyNTY7XG4gICAgICAgIHJldHVybiBbciAvIDI1NSwgZyAvIDI1NSwgYiAvIDI1NV07XG4gICAgfTtcblxuICAgIHN0YXRpYyBnZXRSZ2JhQ29tcG9uZW50cyhhcmdiKSB7XG4gICAgICAgIGxldCByID0gKChhcmdiIC8gNjU1MzYpIHwgMCkgJSAyNTY7XG4gICAgICAgIGxldCBnID0gKChhcmdiIC8gMjU2KSB8IDApICUgMjU2O1xuICAg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gJSAyNTY7XG4gICAgICAgIGxldCBiMiA9IGMyICUgMjU2O1xuICAgICAgICBsZXQgYTIgPSAoKGMyIC8gMTY3NzcyMTYpIHwgMCk7XG5cbiAgICAgICAgbGV0IHIgPSByMSAqIHAgKyByMiAqICgxIC0gcCk7XG4gICAgICAgIGxldCBnID0gZzEgKiBwICsgZzIgKiAoMSAtIHApO1xuICAgICAgICBsZXQgYiA9IGIxICogcCArIGIyICogKDEgLSBwKTtcbiAgICAgICAgbGV0IGEgPSBhMSAqIHAgKyBhMiAqICgxIC0gcCk7XG5cbiAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoYSkgKiAxNjc3NzIxNiArIE1hdGgucm91bmQocikgKiA2NTUzNiArIE1hdGgucm91bmQoZykgKiAyNTYgKyBNYXRoLnJvdW5kKGIpO1xuICAgIH07XG5cbiAgICBzdGF0aWMgbWVyZ2VNdWx0aUNvbG9ycyhjLCBwKSB7XG4gICAgICAgIGxldCByID0gMCwgZyA9IDAsIGIgPSAwLCBhID0gMCwgdCA9IDA7XG4gICAgICAgIGxldCBuID0gYy5sZW5ndGg7XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgcjEgPSAoKGNbaV0gLyA2NTUzNikgfCAwKSAlIDI1NjtcbiAgICAgICAgICAgIGxldCBnMSA9ICgoY1tpXSAvIDI1NikgfCAwKSAlIDI1NjtcbiAgICAgICAgICAgIGxldCBiMSA9IGNbaV0gJSAyNTY7XG4gICAgICAgICAgICBsZXQgYTEgPSAoKGNbaV0gLyAxNjc3NzIxNikgfCAwKTtcbiAgICAgICAgICAgIHIgKz0gcjEgKiBwW2ldO1xuICAgICAgICAgICAgZyArPSBnMSAqIHBbaV07XG4gICAgICAgICAgICBiICs9IGIxICogcFtpXTtcbiAgICAgICAgICAgIGEgKz0gYTEgKiBwW2ldO1xuICAgICAgICAgICAgdCArPSBwW2ldO1xuICAgICAgICB9XG5cbiAgICAgICAgdCA9IDEgLyB0O1xuICAgICAgICByZXR1cm4gTWF0aC5yb3VuZChhICogdCkgKiAxNjc3NzIxNiArIE1hdGgucm91bmQociAqIHQpICogNjU1MzYgKyBNYXRoLnJvdW5kKGcgKiB0KSAqIDI1NiArIE1hdGgucm91bmQoYiAqIHQpO1xuICAgIH07XG5cbiAgICBzdGF0aWMgbWVyZ2VNdWx0aUNvbG9yc0VxdWFsKGMpIHtcbiAgICAgICAgbGV0IHIgPSAwLCBnID0gMCwgYiA9IDAsIGEgPSAwLCB0ID0gMDtcbiAgICAgICAgbGV0IG4gPSBjLmxlbmd0aDtcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGxldCByMSA9ICgoY1tpXSAvIDY1NTM2KSB8IDApICUgMjU2O1xuICAgICAgICAgICAgbGV0IGcxID0gKChjW2ldIC8gMjU2KSB8IDApICUgMjU2O1xuICAgICAgICAgICAgbGV0IGIxID0gY1tpXSAlIDI1NjtcbiAgICAgICAgICAgIGxldCBhMSA9ICgoY1tpXSAvIDE2Nzc3MjE2KSB8IDApO1xuICAgICAgICAgICAgciArPSByMTtcbiAgICAgICAgICAgIGcgKz0gZzE7XG4gICAgICAgICAgICBiICs9IGIxO1xuICAgICAgICAgICAgYSArPSBhMTtcbiAgICAgICAgICAgIHQgKz0gMS4wO1xuICAgICAgICB9XG5cbiAgICAgICAgdCA9IDEgLyB0O1xuICAgICAgICByZXR1cm4gTWF0aC5yb3VuZChhICogdCkgKiAxNjc3NzIxNiArIE1hdGgucm91bmQociAqIHQpICogNjU1MzYgKyBNYXRoLnJvdW5kKGcgKiB0KSAqIDI1NiArIE1hdGgucm91bmQoYiAqIHQpO1xuICAgIH07XG5cbiAgICBzdGF0aWMgbWVyZ2VDb2xvckFscGhhKGMsIGFscGhhKSB7XG4gICAgICAgIGxldCBhID0gKChjIC8gMTY3NzcyMTYgfCAwKSAqIGFscGhhKSB8IDA7XG4gICAgICAgIHJldHVybiAoKCgoKGMgPj4gMTYpICYgMHhmZikgKiBhKSAvIDI1NSkgJiAweGZmKSArXG4gICAgICAgICAgICAoKCgoYyAmIDB4ZmYwMCkgKiBhKSAvIDI1NSkgJiAweGZmMDApICtcbiAgICAgICAgICAgICgoKCgoYyAmIDB4ZmYpIDw8IDE2KSAqIGEpIC8gMjU1KSAmIDB4ZmYwMDAwKSArXG4gICAgICAgICAgICAoYSA8PCAyNCk7XG4gICAgfTtcblxuICAgIHN0YXRpYyByYWQoZGVnKSB7XG4gICAgICAgIHJldHVybiBkZWcgKiAoTWF0aC5QSSAvIDE4MCk7XG4gICAgfTtcblxuICAgIHN0YXRpYyBnZXRUaW1pbmdCZXppZXIoYSwgYiwgYywgZCkge1xuICAgICAgICBsZXQgeGMgPSAzLjAgKiBhO1xuICAgICAgICBsZXQgeGIgPSAzLjAgKiAoYyAtIGEpIC0geGM7XG4gICAgICAgIGxldCB4YSA9IDEuMCAtIHhjIC0geGI7XG4gICAgICAgIGxldCB5YyA9IDMuMCAqIGI7XG4gICAgICAgIGxldCB5YiA9IDMuMCAqIChkIC0gYikgLSB5YztcbiAgICAgICAgbGV0IHlhID0gMS4wIC0geWMgLSB5YjtcblxuICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHRpbWUpIHtcbiAgICAgICAgICAgIGlmICh0aW1lID49IDEuMCkge1xuICAgICAgICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRpbWUgPD0gMCkge1xuICAgICAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgdCA9IDAuNSwgY2J4LCBjYnhkLCBkeDtcblxuICAgICAgICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgICAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcbiAgICAgICAgICAgICAgICBkeCA9IHRpbWUgLSBjYng7XG4gICAgICAgICAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIEN1YmljIGJlemllciBkZXJpdmF0aXZlLlxuICAgICAgICAgICAgICAgIGNieGQgPSB0ICogKHQgKiAoMyAqIHhhKSArIDIgKiB4YikgKyB4YztcblxuICAgICAgICAgICAgICAgIGlmIChjYnhkID4gMWUtMTAgJiYgY2J4ZCA8IDFlLTEwKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFByb2JsZW1hdGljLiBGYWxsIGJhY2sgdG8gYmluYXJ5IHNlYXJjaCBtZXRob2QuXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHQgKz0gZHggLyBjYnhkO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBGYWxsYmFjazogYmluYXJ5IHNlYXJjaCBtZXRob2QuIFRoaXMgaXMgbW9yZSByZWxpYWJsZSB3aGVuIHRoZXJlIGFyZSBuZWFyLTAgc2xvcGVzLlxuICAgICAgICAgICAgbGV0IG1pblQgPSAwO1xuICAgICAgICAgICAgbGV0IG1heFQgPSAxO1xuICAgICAgICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgICAgICAgICAgdCA9IDAuNSAqIChtaW5UICsgbWF4VCk7XG5cbiAgICAgICAgICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuXG4gICAgICAgICAgICAgICAgZHggPSB0aW1lIC0gY2J4O1xuICAgICAgICAgICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBTb2x1dGlvbiBmb3VuZCFcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5Yyk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGR4IDwgMCkge1xuICAgICAgICAgICAgICAgICAgICBtYXhUID0gdDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBtaW5UID0gdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgfTtcbiAgICB9O1xuXG4gICAgc3RhdGljIGdldFRpbWluZ0Z1bmN0aW9uKHN0cikge1xuICAgICAgICBzd2l0Y2ggKHN0cikge1xuICAgICAgICAgICAgY2FzZSBcImxpbmVhclwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAodGltZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGltZVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICBjYXNlIFwiZWFzZVwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjI1LCAwLjEsIDAuMjUsIDEuMCk7XG4gICAgICAgICAgICBjYXNlIFwiZWFzZS1pblwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjQyLCAwLCAxLjAsIDEuMCk7XG4gICAgICAgICAgICBjYXNlIFwiZWFzZS1vdXRcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMCwgMCwgMC41OCwgMS4wKTtcbiAgICAgICAgICAgIGNhc2UgXCJlYXNlLWluLW91dFwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjQyLCAwLCAwLjU4LCAxLjApO1xuICAgICAgICAgICAgY2FzZSBcInN0ZXAtc3RhcnRcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gMVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICBjYXNlIFwic3RlcC1lbmRcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHRpbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRpbWUgPT09IDEgPyAxIDogMDtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICBsZXQgcyA9IFwiY3ViaWMtYmV6aWVyKFwiO1xuICAgICAgICAgICAgICAgIGlmIChzdHIgJiYgc3RyLmluZGV4T2YocykgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhcnRzID0gc3RyLnN1YnN0cihzLmxlbmd0aCwgc3RyLmxlbmd0aCAtIHMubGVuZ3RoIC0gMSkuc3BsaXQoXCIsXCIpO1xuICAgICAgICAgICAgICAgICAgICBpZiAocGFydHMubGVuZ3RoICE9PSA0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBVbmtub3duIHRpbWluZyBmdW5jdGlvbjogXCIgKyBzdHIpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBGYWxsYmFjazogdXNlIGxpbmVhci5cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAodGltZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aW1lXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGxldCBhID0gcGFyc2VGbG9hdChwYXJ0c1swXSk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBiID0gcGFyc2VGbG9hdChwYXJ0c1sxXSk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBjID0gcGFyc2VGbG9hdChwYXJ0c1syXSk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBkID0gcGFyc2VGbG9hdChwYXJ0c1szXSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc05hTihhKSB8fCBpc05hTihiKSB8fCBpc05hTihjKSB8fCBpc05hTihkKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gVW5rbm93biB0aW1pbmcgZnVuY3Rpb246IFwiICsgc3RyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEZhbGxiYWNrOiB1c2UgbGluZWFyLlxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICh0aW1lKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRpbWVcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoYSwgYiwgYywgZCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gVW5rbm93biB0aW1pbmcgZnVuY3Rpb246IFwiICsgc3RyKTtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmFsbGJhY2s6IHVzZSBsaW5lYXIuXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAodGltZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRpbWVcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZ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mVzZXQuXG4gICAgICAgICAqIEB0eXBlIHt7dHlwZTogc3RyaW5nLCB3aWR0aDogbnVtYmVyLCBoZWlnaHQ6IG51bWJlcn19XG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9yZXNpemVNb2RlID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIHRleHR1cmUgY2xpcHBpbmcgeC1vZmZzZXQuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl94ID0gMDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIHRleHR1cmUgY2xpcHBpbmcgeS1vZmZzZXQuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl95ID0gMDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIHRleHR1cmUgY2xpcHBpbmcgd2lkdGguIElmIDAgdGhlbiBmdWxsIHdpZHRoLlxuICAgICAgICAgKiBAdHlwZSB7bnVtYmVyfVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fdyA9IDA7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFRoZSB0ZXh0dXJlIGNsaXBwaW5nIGhlaWdodC4gSWYgMCB0aGVuIGZ1bGwgaGVpZ2h0LlxuICAgICAgICAgKiBAdHlwZSB7bnVtYmVyfVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5faCA9IDA7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFJlbmRlciBwcmVjaXNpb24gKDAuNSA9IGZ1enp5LCAxID0gbm9ybWFsLCAyID0gc2hhcnAgZXZlbiB3aGVuIHNjYWxlZCB0d2ljZSwgZXRjLikuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9wcmVjaXNpb24gPSAxO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUaGUgKG1heGltdW0pIGV4cGVjdGVkIHRleHR1cmUgc291cmNlIHdpZHRoLiBVc2VkIGZvciB3aXRoaW4gYm91bmRzIGRldGVybWluYXRpb24gd2hpbGUgdGV4dHVyZSBpcyBub3QgeWV0IGxvYWRlZC5cbiAgICAgICAgICogSWYgbm90IHNldCwgMjA0OCBpcyB1c2VkIGJ5IEVsZW1lbnRDb3JlLnVwZGF0ZS5cbiAgICAgICAgICogQHR5cGUge251bWJlcn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMubXcgPSAwO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUaGUgKG1heGltdW0pIGV4cGVjdGVkIHRleHR1cmUgc291cmNlIGhlaWdodC4gVXNlZCBmb3Igd2l0aGluIGJvdW5kcyBkZXRlcm1pbmF0aW9uIHdoaWxlIHRleHR1cmUgaXMgbm90IHlldCBsb2FkZWQuXG4gICAgICAgICAqIElmIG5vdCBzZXQsIDIwNDggaXMgdXNlZCBieSBFbGVtZW50Q29yZS51cGRhdGUuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLm1oID0gMDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogSW5kaWNhdGVzIGlmIFRleHR1cmUucHJvdG90eXBlLnRleHR1cmUgdXNlcyBjbGlwcGluZy5cbiAgICAgICAgICogQHR5cGUge2Jvb2xlYW59XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLmNsaXBwaW5nID0gZmFsc2U7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEluZGljYXRlcyB3aGV0aGVyIHRoaXMgdGV4dHVyZSBtdXN0IHVwZGF0ZSAod2hlbiBpdCBiZWNvbWVzIHVzZWQgYWdhaW4pLlxuICAgICAgICAgKiBAdHlwZSB7Ym9vbGVhbn1cbiAgICAgICAgICogQHByaXZhdGVcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX211c3RVcGRhdGUgPSB0cnVlO1xuXG4gICAgfVxuXG4gICAgZ2V0IHNvdXJjZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX211c3RVcGRhdGUgfHwgdGhpcy5zdGFnZS5oYXNVcGRhdGVTb3VyY2VUZXh0dXJlKHRoaXMpKSB7XG4gICAgICAgICAgICB0aGlzLl9wZXJmb3JtVXBkYXRlU291cmNlKHRydWUpO1xuICAgICAgICAgICAgdGhpcy5zdGFnZS5yZW1vdmVVcGRhdGVTb3VyY2VUZXh0dXJlKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl9zb3VyY2U7XG4gICAgfVxuXG4gICAgYWRkRWxlbWVudCh2KSB7XG4gICAgICAgIGlmICghdGhpcy5lbGVtZW50cy5oYXModikpIHtcbiAgICAgICAgICAgIHRoaXMuZWxlbWVudHMuYWRkKHYpO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5lbGVtZW50cy5zaXplID09PSAxKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3NvdXJjZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zb3VyY2UuYWRkVGV4dHVyZSh0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh2LmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuaW5jQWN0aXZlQ291bnQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJlbW92ZUVsZW1lbnQodikge1xuICAgICAgICBpZiAodGhpcy5lbGVtZW50cy5kZWxldGUodikpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmVsZW1lbnRzLnNpemUgPT09IDApIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fc291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3NvdXJjZS5yZW1vdmVUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHYuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5kZWNBY3RpdmVDb3VudCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgaW5jQWN0aXZlQ291bnQoKSB7XG4gICAgICAgIC8vIEVuc3VyZSB0aGF0IHRleHR1cmUgc291cmNlJ3MgYWN0aXZlQ291bnQgaGFzIHRyYW5zZmVycmVkIG93bmVyc2hpcC5cbiAgICAgICAgY29uc3Qgc291cmNlID0gdGhpcy5zb3VyY2U7XG5cbiAgICAgICAgaWYgKHNvdXJjZSkge1xuICAgICAgICAgICAgdGhpcy5fY2hlY2tGb3JOZXdlclJldXNhYmxlVGV4dHVyZVNvdXJjZSgpO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fYWN0aXZlQ291bnQrKztcbiAgICAgICAgaWYgKHRoaXMuX2FjdGl2ZUNvdW50ID09PSAxKSB7XG4gICAgICAgICAgICB0aGlzLmJlY29tZXNVc2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBkZWNBY3RpdmVDb3VudCgpIHtcbiAgICAgICAgY29uc3Qgc291cmNlID0gdGhpcy5zb3VyY2U7IC8vIEZvcmNlIHVwZGF0aW5nIHRoZSBzb3VyY2UuXG4gICAgICAgIHRoaXMuX2FjdGl2ZUNvdW50LS07XG4gICAgICAgIGlmICghdGhpcy5fYWN0aXZlQ291bnQpIHtcbiAgICAgICAgICAgIHRoaXMuYmVjb21lc1VudXNlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgYmVjb21lc1VzZWQoKSB7XG4gICAgICAgIGlmICh0aGlzLnNvdXJjZSkge1xuICAgICAgICAgICAgdGhpcy5zb3VyY2UuaW5jQWN0aXZlVGV4dHVyZUNvdW50KCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBvbkxvYWQoK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GlmICh0aGlzLl9nZXRJc1ZhbGlkKCkpIHtcbiAgICAgICAgICAgIGlmIChsb29rdXBJZCkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1hbmFnZXIuZ2V0UmV1c2FibGVUZXh0dXJlU291cmNlKGxvb2t1cElkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICB9XG5cbiAgICBfcmVwbGFjZVRleHR1cmVTb3VyY2UobmV3U291cmNlID0gbnVsbCkge1xuICAgICAgICBsZXQgb2xkU291cmNlID0gdGhpcy5fc291cmNlO1xuXG4gICAgICAgIHRoaXMuX3NvdXJjZSA9IG5ld1NvdXJjZTtcblxuICAgICAgICBpZiAodGhpcy5lbGVtZW50cy5zaXplKSB7XG4gICAgICAgICAgICBpZiAob2xkU291cmNlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2FjdGl2ZUNvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgIG9sZFNvdXJjZS5kZWNBY3RpdmVUZXh0dXJlQ291bnQoKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBvbGRTb3VyY2UucmVtb3ZlVGV4dHVyZSh0aGlzKTtcblxuICAgICAgICAgICAgICAgIC8vIGZyZWUgdXAgdW51c2VkIFRleHRUZXh0dXJlcyBpbW1lZGlhdGVseSBhcyB0aGV5IGFyZSBub3QgcmV1c2VkIGFueXdheVxuICAgICAgICAgICAgICAgIGlmKHRoaXNbJ3RleHQnXSAmJiAhb2xkU291cmNlLmlzVXNlZCgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMubWFuYWdlci5mcmVlVGV4dHVyZVNvdXJjZShvbGRTb3VyY2UpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKG5ld1NvdXJjZSkge1xuICAgICAgICAgICAgICAgIC8vIE11c3QgaGFwcGVuIGJlZm9yZSBzZXREaXNwbGF5ZWRUZXh0dXJlIHRvIGVuc3VyZSBzcHJpdGUgbWFwIHRleGNvb3JkcyBhcmUgdXNlZC5cbiAgICAgICAgICAgICAgICBuZXdTb3VyY2UuYWRkVGV4dHVyZSh0aGlzKTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fYWN0aXZlQ291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgbmV3U291cmNlLmluY0FjdGl2ZVRleHR1cmVDb3VudCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLmlzVXNlZCgpKSB7XG4gICAgICAgICAgICBpZiAobmV3U291cmNlKSB7XG4gICAgICAgICAgICAgICAgaWYgKG5ld1NvdXJjZS5pc0xvYWRlZCgpKSB7XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gQXBwbHkgcmVzaXplTW9kZVxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcmVzaXplTW9kZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYXBwbHlSZXNpemVNb2RlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goZWxlbWVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Ll9zZXREaXNwbGF5ZWRUZXh0dXJlKHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBsb2FkRXJyb3IgPSBuZXdTb3VyY2UubG9hZEVycm9yO1xuICAgICAgICAgICAgICAgICAgICBpZiAobG9hZEVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goZWxlbWVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQub25UZXh0dXJlU291cmNlTG9hZEVycm9yKGxvYWRFcnJvcik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaChlbGVtZW50ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Ll9zZXREaXNwbGF5ZWRUZXh0dXJlKG51bGwpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBsb2FkKCkge1xuICAgICAgICAvLyBNYWtlIHN1cmUgdGhhdCBzb3VyY2UgaXMgdXAgdG8gZGF0ZS5cbiAgICAgICAgaWYgKHRoaXMuc291cmNlKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuaXNMb2FkZWQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuc291cmNlLmxvYWQodHJ1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBpc0xvYWRlZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NvdXJjZSAmJiB0aGlzLl9zb3VyY2UuaXNMb2FkZWQoKTtcbiAgICB9XG5cbiAgICBnZXQgbG9hZEVycm9yKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc291cmNlICYmIHRoaXMuX3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RUZXh0dXJlID09PSBzZWxmKSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5vblByZWNpc2lvbkNoYW5nZWQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgZ2V0Tm9uRGVmYXVsdHMoKSB7XG4gICAgICAgIGxldCBub25EZWZhdWx0cyA9IHt9O1xuICAgICAgICBub25EZWZhdWx0c1sndHlwZSddID0gdGhpcy5jb25zdHJ1Y3Rvci5uYW1lO1xuICAgICAgICBpZiAodGhpcy54ICE9PSAwKSBub25EZWZhdWx0c1sneCddID0gdGhpcy54O1xuICAgICAgICBpZiAodGhpcy55ICE9PSAwKSBub25EZWZhdWx0c1sneSddID0gdGhpcy55O1xuICAgICAgICBpZiAodGhpcy53ICE9PSAwKSBub25EZWZhdWx0c1sndyddID0gdGhpcy53O1xuICAgICAgICBpZiAodGhpcy5oICE9PSAwKSBub25EZWZhdWx0c1snaCddID0gdGhpcy5oO1xuICAgICAgICBpZiAodGhpcy5wcmVjaXNpb24gIT09IDEpIG5vbkRlZmF1bHRzWydwcmVjaXNpb24nXSA9IHRoaXMucHJlY2lzaW9uO1xuICAgICAgICByZXR1cm4gbm9uRGVmYXVsdHM7XG4gICAgfVxuXG4gICAgZ2V0IHB4KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5feDtcbiAgICB9XG5cbiAgICBnZXQgcHkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl95O1xuICAgIH1cblxuICAgIGdldCBwdygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3c7XG4gICAgfVxuXG4gICAgZ2V0IHBoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG5cbiAgICBnZXQgeCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3ggLyB0aGlzLl9wcmVjaXNpb247XG4gICAgfVxuICAgIHNldCB4KHYpIHtcbiAgICAgICAgdGhpcy5fY2xlYXJSZXNpemVNb2RlKCk7X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uYWJsZWQgdGV4dHVyZXMgKHRleHR1cmVzIHRoYXQgYXJlIHVzZWQgYnkgdmlzaWJsZSBlbGVtZW50cykuXG4gICAgICAgICAqIEB0eXBlIHtTZXQ8VGV4dHVyZT59XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLnRleHR1cmVzID0gbmV3IFNldCgpO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUaGUgbnVtYmVyIG9mIGFjdGl2ZSB0ZXh0dXJlcyAodGV4dHVyZXMgdGhhdCBoYXZlIGF0IGxlYXN0IG9uZSBhY3RpdmUgZWxlbWVudCkuXG4gICAgICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9hY3RpdmVUZXh0dXJlQ291bnQgPSAwO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUaGUgZmFjdG9yeSBmb3IgdGhlIHNvdXJjZSBvZiB0aGlzIHRleHR1cmUuXG4gICAgICAgICAqIEB0eXBlIHtGdW5jdGlvbn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMubG9hZGVyID0gbG9hZGVyO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBJZGVudGlmaWVyIGZvciByZXVzZS5cbiAgICAgICAgICogQHR5cGUge1N0cmluZ31cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMubG9va3VwSWQgPSBudWxsO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBJZiBzZXQsIHRoaXMuaXMgY2FsbGVkIHdoZW4gdGhlIHRleHR1cmUgc291cmNlIGlzIG5vIGxvbmdlciBkaXNwbGF5ZWQgKHRoaXMuY29tcG9uZW50cy5zaXplIGJlY29tZXMgMCkuXG4gICAgICAgICAqIEB0eXBlIHtGdW5jdGlvbn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX2NhbmNlbENiID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogT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0dXJlcy5hZGQodik7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZW1vdmVUZXh0dXJlKHYpIHtcbiAgICAgICAgdGhpcy50ZXh0dXJlcy5kZWxldGUodik7XG4gICAgfVxuXG4gICAgaW5jQWN0aXZlVGV4dHVyZUNvdW50KCkge1xuICAgICAgICB0aGlzLl9hY3RpdmVUZXh0dXJlQ291bnQrKztcbiAgICAgICAgaWYgKHRoaXMuX2FjdGl2ZVRleHR1cmVDb3VudCA9PT0gMSkge1xuICAgICAgICAgICAgdGhpcy5iZWNvbWVzVXNlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZGVjQWN0aXZlVGV4dHVyZUNvdW50KCkge1xuICAgICAgICB0aGlzLl9hY3RpdmVUZXh0dXJlQ291bnQtLTtcbiAgICAgICAgaWYgKHRoaXMuX2FjdGl2ZVRleHR1cmVDb3VudCA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5iZWNvbWVzVW51c2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgaXNSZXN1bHRUZXh0dXJlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faXNSZXN1bHRUZXh0dXJlO1xuICAgIH1cblxuICAgIHNldCBpc1Jlc3VsdFRleHR1cmUodikge1xuICAgICAgICB0aGlzLl9pc1Jlc3VsdFRleHR1cmUgPSB2O1xuICAgIH1cblxuICAgIGZvckVhY2hFbmFibGVkRWxlbWVudChjYikge1xuICAgICAgICB0aGlzLnRleHR1cmVzLmZvckVhY2godGV4dHVyZSA9PiB7XG4gICAgICAgICAgICB0ZXh0dXJlLmVsZW1lbnRzLmZvckVhY2goY2IpO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBoYXNFbmFibGVkRWxlbWVudHMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnRleHR1cmVzLnNpemUgPiAwO1xuICAgIH1cblxuICAgIGZvckVhY2hBY3RpdmVFbGVtZW50KGNiKSB7XG4gICAgICAgI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sb2FkZXIoKGVyciwgb3B0aW9ucykgPT4ge1xuICAgICAgICAgICAgICAgIC8vIElnbm9yZSBsb2FkcyB0aGF0IGNvbWUgaW4gYWZ0ZXIgYSBjYW5jZWwuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNMb2FkaW5nKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQ2xlYXIgY2FsbGJhY2sgdG8gYXZvaWQgbWVtb3J5IGxlYWtzLlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxDYiA9IG51bGw7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMubWFuYWdlci5zdGFnZS5kZXN0cm95ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIElnbm9yZSBhc3luYyBsb2FkIHdoZW4gc3RhZ2UgaXMgZGVzdHJveWVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEVtaXQgdHhFcnJvci5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25FcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG9wdGlvbnMgJiYgb3B0aW9ucy5zb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdGFnZS5pc1VwZGF0aW5nRnJhbWUoKSAmJiAhZm9yY2VTeW5jICYmIChvcHRpb25zLnRocm90dGxlICE9PSBmYWxzZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0dXJlVGhyb3R0bGVyID0gdGhpcy5zdGFnZS50ZXh0dXJlVGhyb3R0bGVyO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbmNlbENiID0gdGV4dHVyZVRocm90dGxlci5nZW5lcmljQ2FuY2VsQ2I7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dHVyZVRocm90dGxlci5hZGQodGhpcywgb3B0aW9ucyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc0xvYWRlZFNvdXJjZShvcHRpb25zKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIHRoaXMpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcHJvY2Vzc0xvYWRlZFNvdXJjZShvcHRpb25zKSB7XG4gICAgICAgIHRoaXMubG9hZGluZ1NpbmNlID0gMDtcbiAgICAgICAgdGhpcy5zZXRTb3VyY2Uob3B0aW9ucyk7XG4gICAgfVxuXG4gICAgc2V0U291cmNlKG9wdGlvbnMpIHtcbiAgICAgICAgY29uc3Qgc291cmNlID0gb3B0aW9ucy5zb3VyY2U7XG5cbiAgICAgICAgdGhpcy5faGFzQWxwaGEgPSAob3B0aW9ucyA/IChvcHRpb25zLmhhc0FscGhhIHx8IGZhbHNlKSA6IGZhbHNlKTtcbiAgICAgICAgdGhpcy53ID0gc291cmNlLndpZHRoIHx8IChvcHRpb25zICYmIG9wdGlvbnMudykgfHwgMDtcbiAgICAgICAgdGhpcy5oID0gc291cmNlLmhlaWdodCB8fCAob3B0aW9ucyAmJiBvcHRpb25zLmgpIHx8IDA7XG5cbiAgICAgICAgaWYgKG9wdGlvbnMgJiYgb3B0aW9ucy5yZW5kZXJJbmZvKSB7XG4gICAgICAgICAgICAvLyBBc3NpZ24gdG8gaWQgaW4gY2FjaGUgc28gdGhhdCBpdCBjYW4gYmUgcmV1c2VkLlxuICAgICAgICAgICAgdGhpcy5yZW5kZXJJbmZvID0gb3B0aW9ucy5yZW5kZXJJbmZvO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5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GljIGdldE1vZHVsb0luZGV4KGluZGV4LCBsZW4pIHtcbiAgICAgICAgaWYgKGxlbiA9PT0gMCkgcmV0dXJuIGluZGV4O1xuICAgICAgICB3aGlsZSAoaW5kZXggPCAwKSB7XG4gICAgICAgICAgICBpbmRleCArPSBNYXRoLmNlaWwoLWluZGV4IC8gbGVuKSAqIGxlbjtcbiAgICAgICAgfVxuICAgICAgICBpbmRleCA9IGluZGV4ICUgbGVuO1xuICAgICAgICByZXR1cm4gaW5kZXg7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldERlZXBDbG9uZShvYmopIHtcbiAgICAgICAgbGV0IGksIGM7XG4gICAgICAgIGlmIChVdGlscy5pc0Z1bmN0aW9uKG9iaikpIHtcbiAgICAgICAgICAgIC8vIENvcHkgZnVuY3Rpb25zIGJ5IHJlZmVyZW5jZS5cbiAgICAgICAgICAgIHJldHVybiBvYmo7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkob2JqKSkge1xuICAgICAgICAgICAgYyA9IFtdO1xuICAgICAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjW2tleXNbaV1dID0gVXRpbHMuZ2V0RGVlcENsb25lKG9ialtrZXlzW2ldXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gYztcbiAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdChvYmopKSB7XG4gICAgICAgICAgICBjID0ge31cbiAgICAgICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBrZXlzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgY1trZXlzW2ldXSA9IFV0aWxzLmdldERlZXBDbG9uZShvYmpba2V5c1tpXV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGM7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gb2JqO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIGVxdWFsVmFsdWVzKHYxLCB2Mikge1xuICAgICAgICBpZiAoKHR5cGVvZiB2MSkgIT09ICh0eXBlb2YgdjIpKSByZXR1cm4gZmFsc2U7XG4gICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodjEpKSB7XG4gICAgICAgICAgICByZXR1cm4gVXRpbHMuaXNPYmplY3RMaXRlcmFsKHYyKSAmJiBVdGlscy5lcXVhbE9iamVjdExpdGVyYWxzKHYxLCB2Mik7XG4gICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheSh2MSkpIHtcbiAgICAgICAgICAgIHJldHVybiBBcnJheS5pc0FycmF5KHYyKSAmJiBVdGlscy5lcXVhbEFycmF5cyh2MSwgdjIpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHYxID09PSB2MjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBlcXVhbE9iamVjdExpdGVyYWxzKG9iajEsIG9iajIpIHtcbiAgICAgICAgbGV0IGtleXMxID0gT2JqZWN0LmtleXMob2JqMSk7XG4gICAgICAgIGxldCBrZXlzMiA9IE9iamVjdC5rZXlzKG9iajIpO1xuICAgICAgICBpZiAoa2V5czEubGVuZ3RoICE9PSBrZXlzMi5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0ga2V5czEubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBrMSA9IGtleXMxW2ldO1xuICAgICAgICAgICAgY29uc3QgazIgPSBrZXlzMltpXTtcbiAgICAgICAgICAgIGlmIChrMSAhPT0gazIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNvbnN0IHYxID0gb2JqMVtrMV07XG4gICAgICAgICAgICBjb25zdCB2MiA9IG9iajJbazJdO1xuXG4gICAgICAgICAgICBpZiAoIVV0aWxzLmVxdWFsVmFsdWVzKHYxLCB2MikpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBzdGF0aWMgZXF1YWxBcnJheXModjEsIHYyKSB7XG4gICAgICAgIGlmICh2MS5sZW5ndGggIT09IHYyLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdjEubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuZXF1YWxWYWx1ZXModjFbaV0sIHYyW2ldKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cblxuICAgIHN0YXRpYyBzZXRUb0FycmF5KHMpIHtcbiAgICAgICAgbGV0IHJlc3VsdCA9IFtdO1xuICAgICAgICBzLmZvckVhY2goZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICByZXN1bHQucHVzaCh2YWx1ZSk7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIHN0YXRpYyBpdGVyYXRvclRvQXJyYXkoaXRlcmF0b3IpIHtcbiAgICAgICAgbGV0IHJlc3VsdCA9IFtdO1xuICAgICAgICBsZXQgaXRlcmF0b3JSZXN1bHQgPSBpdGVyYXRvci5uZXh0KCk7XG4gICAgICAgIHdoaW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ZW50IGluZmluaXRlIGxvb3BzKS5cbiAgICAgICAgaWYgKHRoaXMucm9vdC5faGFzVXBkYXRlcykge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlKCk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9wZXJmb3JtRm9yY2VkWlNvcnRzKCk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ2VydGFpbiBFbGVtZW50Q29yZSBpdGVtcyBtYXkgYmUgZm9yY2VkIHRvIHpTb3J0IHRvIHN0cmlwIG91dCByZWZlcmVuY2VzIHRvIHByZXZlbnQgbWVtbGVha3MuLlxuICAgICAqL1xuICAgIF9wZXJmb3JtRm9yY2VkWlNvcnRzKCkge1xuICAgICAgICBjb25zdCBuID0gdGhpcy5felNvcnRzLmxlbmd0aDtcbiAgICAgICAgaWYgKG4pIHtcbiAgICAgICAgICAgIC8vIEZvcmNlZCB6LXNvcnRzIChFbGVtZW50Q29yZSBtYXkgZm9yY2UgYSB6LXNvcnQgaW4gb3JkZXIgdG8gZnJlZSBtZW1vcnkvcHJldmVudCBtZW1vcnkgbGVha3MpLlxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl96U29ydHMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pTb3J0c1tpXS56U29ydCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl96U29ydHNbaV0uc29ydFpJbmRleGVkQ2hpbGRyZW4oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl96U29ydHMgPSBbXTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHRoaXMudXBkYXRlVHJlZU9yZGVyID0gMDtcblxuICAgICAgICB0aGlzLnJvb3QudXBkYXRlKCk7XG4gICAgfVxuXG4gICAgX3JlbmRlcigpIHtcbiAgICAgICAgY29uc3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G4gICAgfVxuXG4gICAgcmVzZXQoKSB7XG4gICAgICAgIHRoaXMucXVhZFRleHR1cmVzID0gW107XG4gICAgICAgIHRoaXMucXVhZEVsZW1lbnRzID0gW107XG4gICAgICAgIHRoaXMuZGF0YUxlbmd0aCA9IDA7XG4gICAgfVxuXG4gICAgZ2V0RWxlbWVudChpbmRleCkge1xuICAgICAgICByZXR1cm4gdGhpcy5xdWFkRWxlbWVudHNbaW5kZXhdLl9lbGVtZW50O1xuICAgIH1cblxuICAgIGdldEVsZW1lbnRDb3JlKGluZGV4KSB7XG4gICAgICAgIHJldHVybiB0aGlzLnF1YWRFbGVtZW50c1tpbmRleF07XG4gICAgfVxuXG4gICAgZ2V0VGV4dHVyZShpbmRleCkge1xuICAgICAgICByZXR1cm4gdGhpcy5xdWFkVGV4dHVyZXNbaW5kZXhdO1xuICAgIH1cblxuICAgIGdldFRleHR1cmVXaWR0aChpbmRleCkge1xuICAgICAgICBsZXQgbmF0aXZlVGV4dHVyZSA9IHRoaXMucXVhZFRleHR1cmVzW2luZGV4XTtcbiAgICAgICAgaWYgKG5hdGl2ZVRleHR1cmUudykge1xuICAgICAgICAgICAgLy8gUmVuZGVyIHRleHR1cmU7XG4gICAgICAgICAgICByZXR1cm4gbmF0aXZlVGV4dHVyZS53O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMucXVhZEVsZW1lbnRzW2luZGV4XS5fZGlzcGxheWVkVGV4dHVyZVNvdXJjZS53O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0VGV4dHVyZUhlaWdodChpbmRleCkge1xuICAgICAgICBsZXQgbmF0aXZlVGV4dHVyZSA9IHRoaXMucXVhZFRleHR1cmVzW2luZGV4XTtcbiAgICAgICAgaWYgKG5hdGl2ZVRleHR1cmUuaCkge1xuICAgICAgICAgICAgLy8gUmVuZGVyIHRleHR1cmU7XG4gICAgICAgICAgICByZXR1cm4gbmF0aXZlVGV4dHVyZS5oO1xuIC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3NoYWRlciA9IHNoYWRlcjtcbiAgICAgICAgICAgICAgICB0aGlzLl9zaGFkZXJPd25lciA9IG93bmVyO1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoZWNrID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCByZW5kZXJUZXh0dXJlSW5mbygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3JlbmRlclRleHR1cmVJbmZvO1xuICAgIH1cblxuICAgIHNldFNjaXNzb3IoYXJlYSkge1xuICAgICAgICBpZiAodGhpcy5fc2Npc3NvciAhPT0gYXJlYSkge1xuICAgICAgICAgICAgaWYgKGFyZWEpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gYXJlYTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9jaGVjayA9IHRydWU7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXRTY2lzc29yKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc2Npc3NvcjtcbiAgICB9XG5cbiAgICBzZXRSZW5kZXJUZXh0dXJlSW5mbyhyZW5kZXJUZXh0dXJlSW5mbykge1xuICAgICAgICBpZiAodGhpcy5fcmVuZGVyVGV4dHVyZUluZm8gIT09IHJlbmRlclRleHR1cmVJbmZvKSB7XG4gICAgICAgICAgICB0aGlzLl9yZW5kZXJUZXh0dXJlSW5mbyA9IHJlbmRlclRleHR1cmVJbmZvO1xuICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLl9jaGVjayA9IHRydWU7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBTZXRzIHRoZSB0ZXh0dXJpemVyIHRvIGJlIGRyYXduIGR1cmluZyBzdWJzZXF1ZW50IGFkZFF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Ll9sb2NhbFRhID0gMTtcbiAgICAgICAgdGhpcy5fbG9jYWxUYiA9IDA7XG4gICAgICAgIHRoaXMuX2xvY2FsVGMgPSAwO1xuICAgICAgICB0aGlzLl9sb2NhbFRkID0gMTtcblxuICAgICAgICB0aGlzLl9pc0NvbXBsZXggPSBmYWxzZTtcblxuICAgICAgICB0aGlzLl9kaW1zVW5rbm93biA9IGZhbHNlO1xuXG4gICAgICAgIHRoaXMuX2NsaXBwaW5nID0gZmFsc2U7XG5cbiAgICAgICAgLy8gVXNlZCBieSBib3RoIHVwZGF0ZSBhbmQgcmVuZGVyLlxuICAgICAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuXG4gICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIHRleHR1cmUgc291cmNlIHRvIGJlIGRpc3BsYXllZC5cbiAgICAgICAgICogQHR5cGUge1RleHR1cmVTb3VyY2V9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlID0gbnVsbDtcblxuICAgICAgICB0aGlzLl96Q29udGV4dFVzYWdlID0gMDtcblxuICAgICAgICB0aGlzLl9jaGlsZHJlbiA9IG51bGw7XG5cbiAgICAgICAgdGhpcy5faGFzUmVuZGVyVXBkYXRlcyA9IDA7XG5cbiAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbiA9IG51bGw7XG5cbiAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHRoaXMuX3dvcmxkQ29udGV4dDtcblxuICAgICAgICB0aGlzLnJlbmRlclN0YXRlID0gdGhpcy5jdHgucmVuZGVyU3RhdGU7XG5cbiAgICAgICAgdGhpcy5fc2Npc3NvciA9IG51bGw7XG5cbiAgICAgICAgLy8gVGhlIGFuY2VzdG9yIEVsZW1lbnRDb3JlIHRoYXQgb3ducyB0aGUgaW5oZXJpdGVkIHNoYWRlci4gTnVsbCBpZiBub25l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Ll94LCAwKTtcbiAgICAgICAgICAgIHRoaXMuX3ggPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGZ1bmNYKCkge1xuICAgICAgICByZXR1cm4gKHRoaXMuX29wdEZsYWdzICYgMSA/IHRoaXMuX2Z1bmNYIDogbnVsbCk7XG4gICAgfVxuXG4gICAgc2V0IGZ1bmNYKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2Z1bmNYICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9vcHRGbGFncyB8PSAxO1xuICAgICAgICAgICAgdGhpcy5fZnVuY1ggPSB2O1xuICAgICAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0LnNldE9yaWdpbmFsWFdpdGhvdXRVcGRhdGluZ0xheW91dCgwKTtcbiAgICAgICAgICAgICAgICB0aGlzLmxheW91dC5mb3JjZUxheW91dCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl94ID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLl90cmlnZ2VyUmVjYWxjVHJhbnNsYXRlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZGlzYWJsZUZ1bmNYKCkge1xuICAgICAgICB0aGlzLl9vcHRGbGFncyA9IHRoaXMuX29wdEZsYWdzICYgKDB4RkZGRiAtIDEpO1xuICAgICAgICB0aGlzLl9mdW5jWCA9IG51bGw7XG4gICAgfVxuXG4gICAgZ2V0IG9mZnNldFkoKSB7XG4gICAgICAgIGlmICh0aGlzLl9mdW5jWSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Z1bmNZO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xheW91dC5vcmlnaW5hbFk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl95O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0IG9mZnNldFkodikge1xuICAgICAgICBpZiAoVXRpbHMuaXNGdW5jdGlvbih2KSkge1xuICAgICAgICAgICAgdGhpcy5mdW5jWSA9IHY7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9kaXNhYmxlRnVuY1koKTtcbiAgICAgICAgICAgIGlmICh0aGlzLmhhc0ZsZXhMYXlvdXQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMueSArPSAodiAtIHRoaXMuX2xheW91dC5vcmlnaW5hbFkpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2xheW91dC5zZXRPcmlnaW5hbFlXaXRob3V0VXBkYXRpbmdMYXlvdXQodik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMueSA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgeSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3k7XG4gICAgfVxuXG4gICAgc2V0IHkodikge1xuICAgICAgICBpZiAodiAhPT0gdGhpcy5feSkge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGVEZWx0YSgwLCB2IC0gdGhpcy5feSk7XG4gICAgICAgICAgICB0aGlzLl95ID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBmdW5jWSgpIHtcbiAgICAgICAgcmV0dXJuICh0aGlzLl9vcHRGbGFncyAmIDIgPyB0aGlzLl9mdW5jWSA6IG51bGwpO1xuICAgIH1cblxuICAgIHNldCBmdW5jWSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9mdW5jWSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fb3B0RmxhZ3MgfD0gMjtc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m4gdGhpcy5fdztcbiAgICB9XG5cbiAgICBnZXRSZW5kZXJXaWR0aCgpIHtcbiAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbGF5b3V0Lm9yaWdpbmFsV2lkdGg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fdztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG5cbiAgICBnZXRSZW5kZXJIZWlnaHQoKSB7XG4gICAgICAgIGlmICh0aGlzLmhhc0ZsZXhMYXlvdXQoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xheW91dC5vcmlnaW5hbEhlaWdodDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9oO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHNjYWxlWCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NjYWxlWDtcbiAgICB9XG5cbiAgICBzZXQgc2NhbGVYKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3NjYWxlWCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fc2NhbGVYID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNmb3JtKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgc2NhbGVZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc2NhbGVZO1xuICAgIH1cblxuICAgIHNldCBzY2FsZVkodikge1xuICAgICAgICBpZiAodGhpcy5fc2NhbGVZICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9zY2FsZVkgPSB2O1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2Zvcm0oKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBzY2FsZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc2NhbGVYO1xuICAgIH1cblxuICAgIHNldCBzY2FsZSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9zY2FsZVggIT09IHYgfHwgdGhpcy5fc2NhbGVZICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9zY2FsZVggPSB2O1xuICAgICAgICAgICAgdGhpcy5fc2NhbGVZID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNmb3JtKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgcGl2b3RYKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGl2b3RYO1xuICAgIH1cblxuICAgIHNldCBwaXZvdFgodikge1xuICAgICAgICBpZiAodGhpcy5fcGl2b3RYICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9waXZvdFggPSB2O1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBwaXZvdFkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9waXZvdFk7XG4gICAgfVxuXG4gICAgc2V0IHBpdm90WSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9waXZvdFkgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3Bpdm90WSA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHBpdm90KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGl2b3RYO1xuICAgIH1cblxuICAgIHNldCBwaXZvdCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9waXZvdFggIT09IHYgfHwgdGhpcy5fcGl2b3RZICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9waXZvdFggPSB2O1xuICAgICAgICAgICAgdGhpcy5fcGl2b3RZID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgbW91bnRYKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbW91bnRYO1xuICAgIH1cblxuICAgIHNldCBtb3VudFgodikge1xuICAgICAgICBpZiAodGhpcy5fbW91bnRYICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9tb3VudFggPSB2O1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBtb3VudFkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9tb3VudFk7XG4gICAgfVxuXG4gICAgc2V0IG1vdW50WSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9tb3VudFkgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX21vdW50WSA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IG1vdW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbW91bnRYO1xuICAgIH1cblxuICAgIHNldCBtb3VudCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9tb3VudFggIT09IHYgfHwgdGhpcy5fbW91bnRZICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9tb3VudFggPSB2O1xuICAgICAgICAgICAgdGhpcy5fbW91bnRZID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgcm90YXRpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yb3RhdGlvbjtcbiAgICB9XG5cbiAgICBzZXQgcm90YXRpb24odikge1xuICAgICAgICBpZiAodGhpcy5fcm90YXRpb24gIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3JvdGF0aW9uID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNmb3JtKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgYWxwaGEoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9hbHBoYTtcbiAgICB9XG5cbiAgICBzZXQgYWxwaGEodikge1xuICAgICAgICAvLyBBY2NvdW50IGZvciByb3VuZGluZyBlcnJvcnMuXG4gICAgICAgIHYgPSAodiA+IDEgPyAxIDogKHYgPCAxZS0xNCA/IDAgOiB2KSk7XG4gICAgICAgIGlmICh0aGlzLl9hbHBoYSAhPT0gdikge1xuICAgICAgICAgICAgbGV0IHByZXYgPSB0aGlzLl9hbHBoYTtcbiAgICAgICAgICAgIHRoaXMuX2FscGhhID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsQWxwaGEoKTtcbiAgICAgICAgICAgIGlmICgocHJldiA9PT0gMCkgIT09ICh2ID09PSAwKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2VsZW1lbnQuX3VwZGF0ZUVuYWJsZWRGbGFnKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdmlzaWJsZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3Zpc2libGU7XG4gICAgfVxuXG4gICAgc2V0IHZpc2libGUodikge1xuICAgICAgICBpZiAodGhpcy5fdmlzaWJsZSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fdmlzaWJsZSA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbEFscGhhKCk7XG4gICAgICAgICAgICB0aGlzLl9lbGVtZW50Ll91cGRhdGVFbmFibGVkRmxhZygpO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5oYXNGbGV4TGF5b3V0KCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmxheW91dC5zZXRWaXNpYmxlKHYpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX3VwZGF0ZUxvY2FsVHJhbnNmb3JtKCkge1xuICAgICAgICBpZiAodGhpcy5fcm90YXRpb24gIT09IDAgJiYgdGhpcy5fcm90YXRpb24gJSAoMiAqIE1hdGguUEkpKSB7XG4gICAgICAgICAgICAvLyBjaGVjayB0byBzZWUgaWYgdGhlIHJvdGF0aW9uIGlzIHRoZSBzYW1lIGFzIHRoZSBwcmV2aW91cyByZW5kZXIuIFRoaXMgbWVhbnMgd2Ugb25seSBuZWVkIHRvIHVzZSBzaW4gYW5kIGNvcyB3aGVuIHJvdGF0aW9uIGFjdHVhbGx5IGNoYW5nZXNcbiAgICAgICAgICAgIGxldCBfc3IgPSBNYXRoLnNpbih0aGlzLl9yb3RhdGlvbik7XG4gICAgICAgICAgICBsZXQgX2NyID0gTWF0aC5jb3ModGhpcy5fcm90YXRpb24pO1xuXG4gICAgICAgICAgICB0aGlzLl9zZXRMb2NhbFRyYW5zZm9ybShcbiAgICAgICAgICAgICAgICBfY3IgKiB0aGlzLl9zY2FsZVgsXG4gICAgICAgICAgICAgICAgLV9zciAqIHRoaXMuX3NjYWxlWSxcbiAgICAgICAgICAgICAgICBfc3IgKiB0aGlzLl9zY2FsZVgsXG4gICAgICAgICAgICAgICAgX2NyICogdGhpcy5fc2NhbGVZXG4gICAgICAgICAgICApO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fc2V0TG9jYWxUcmFuc2Zvcm0oXG4gICAgICAgICAgICAgICAgdGhpcy5fc2NhbGVYLFxuICAgICAgICAgICAgICAgIDAsXG4gICAgICAgICAgICAgICAgMCxcbiAgICAgICAgICAgICAgICB0aGlzLl9zY2FsZVlcbiAgICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGUoKTtcbiAgICB9O1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SBjaGFuZ2VzIGluIGRlc2NlbmRhbnRzIHNob3VsZCB0cmlnZ2VyIHRleHR1cmUgdXBkYXRlcy5cbiAgICAgICAgaWYgKHRoaXMuX3BhcmVudCkge1xuICAgICAgICAgICAgdGhpcy5fcGFyZW50LnNldEhhc1JlbmRlclVwZGF0ZXMoMyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfc2V0SGFzVXBkYXRlcygpIHtcbiAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICB3aGlsZSAocCAmJiAhcC5faGFzVXBkYXRlcykge1xuICAgICAgICAgICAgcC5faGFzVXBkYXRlcyA9IHRydWU7XG4gICAgICAgICAgICBwID0gcC5fcGFyZW50O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0UGFyZW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGFyZW50O1xuICAgIH1cblxuICAgIHNldFBhcmVudChwYXJlbnQpIHtcbiAgICAgICAgaWYgKHBhcmVudCAhPT0gdGhpcy5fcGFyZW50KSB7XG4gICAgICAgICAgICBsZXQgcHJldklzWkNvbnRleHQgPSB0aGlzLmlzWkNvbnRleHQoKTtcbiAgICAgICAgICAgIGxldCBwcmV2UGFyZW50ID0gdGhpcy5fcGFyZW50O1xuICAgICAgICAgICAgdGhpcy5fcGFyZW50ID0gcGFyZW50O1xuXG4gICAgICAgICAgICAvLyBOb3RpZnkgZmxleCBsYXlvdXQgZW5naW5lLlxuICAgICAgICAgICAgaWYgKHRoaXMuX2xheW91dCB8fCAocGFyZW50ICYmIHBhcmVudC5pc0ZsZXhDb250YWluZXIoKSkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmxheW91dC5zZXRQYXJlbnQocHJldlBhcmVudCwgcGFyZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHByZXZQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAvLyBXaGVuIGVsZW1lbnRzIGFyZSBkZWxldGVkLCB0aGUgcmVuZGVyIHRleHR1cmUgbXVzdCBiZSByZS1yZW5kZXJlZC5cbiAgICAgICAgICAgICAgICBwcmV2UGFyZW50LnNldEhhc1JlbmRlclVwZGF0ZXMoMyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX3NldFJlY2FsYygxICsgMiArIDQpO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fcGFyZW50KSB7XG4gICAgICAgICAgICAgICAgLy8gRm9yY2UgcGFyZW50IHRvIHByb3BhZ2F0ZSBoYXNVcGRhdGVzIGZsYWcuXG4gICAgICAgICAgICAgICAgdGhpcy5fcGFyZW50Ll9zZXRIYXNVcGRhdGVzKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldFpQYXJlbnQocGFyZW50KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zZXRaUGFyZW50KHBhcmVudCA/IHBhcmVudC5maW5kWkNvbnRleHQoKSA6IG51bGwpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocHJldklzWkNvbnRleHQgIT09IHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmRpc2FibGVaQ29udGV4dCgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlWkNvbnRleHQocHJldlBhcmVudC5maW5kWkNvbnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBUcmVlIG9yZGVyIGRpZCBjaGFuZ2U6IGV2ZW4gaWYgelBhcmVudCBzdGF5cyB0aGUgc2FtZSwgd2UgbXVzdCByZXNvcnQuXG4gICAgICAgICAgICB0aGlzLl96SW5kZXhSZXNvcnQgPSB0cnVlO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICghdGhpcy5fc2hhZGVyKSB7XG4gICAgICAgICAgICAgICAgbGV0IG5ld1NoYWRlck93bmVyID0gcGFyZW50ICYmICFwYXJlbnQuX3JlbmRlclRvVGV4dHVyZUVuYWJsZWQgPyBwYXJlbnQuX3NoYWRlck93bmVyIDogbnVsbDtcbiAgICAgICAgICAgICAgICBpZiAobmV3U2hhZGVyT3duZXIgIT09IHRoaXMuX3NoYWRlck93bmVyKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcygxKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0U2hhZGVyT3duZXJSZWN1cnNpdmUobmV3U2hhZGVyT3duZXIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBlbmFibGVaU29ydChmb3JjZSA9IGZhbHNlKSB7XG4gICAgICAgIGlmICghdGhpcy5felNvcnQgJiYgdGhpcy5fekNvbnRleHRVc2FnZSA+IDApIHtcbiAgICAgICAgICAgIHRoaXMuX3pTb3J0ID0gdHJ1ZTtcbiAgICAgICAgICAgIGlmIChmb3JjZSkge1xuICAgICAgICAgICAgICAgIC8vIFpTb3J0IG11c3QgYmUgZG9uZSwgZXZlbiBpZiB0aGlzIGVsZW1lbnQgaXMgaW52aXNpYmxlLlxuICAgICAgICAgICAgICAgIC8vIFRoaXMgaXMgZG9uZSB0byBwcmV2ZW50IG1lbW9yeSBsZWFrcyB3aGVuIHJlbW92aW5nIGVsZW1lbnQgZnJvbSBpbmFjdGl2ZSByZW5kZXIgYnJhbmNoZXMuXG4gICAg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GFyZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcyA9PT0gcCkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9O1xuXG4gICAgaXNaQ29udGV4dCgpIHtcbiAgICAgICAgcmV0dXJuICh0aGlzLl9mb3JjZVpJbmRleENvbnRleHQgfHwgdGhpcy5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCB8fCB0aGlzLl96SW5kZXggIT09IDAgfHwgdGhpcy5faXNSb290IHx8ICF0aGlzLl9wYXJlbnQpO1xuICAgIH07XG5cbiAgICBmaW5kWkNvbnRleHQoKSB7XG4gICAgICAgIGlmICh0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHNldFpQYXJlbnQobmV3WlBhcmVudCkge1xuICAgICAgICBpZiAodGhpcy5felBhcmVudCAhPT0gbmV3WlBhcmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZGVjWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIFdlIG11c3QgZmlsdGVyIG91dCB0aGlzIGl0ZW0gdXBvbiB0aGUgbmV4dCByZXNvcnQuXG4gICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAobmV3WlBhcmVudCAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIGxldCBoYWRaQ29udGV4dFVzYWdlID0gKG5ld1pQYXJlbnQuX3pDb250ZXh0VXNhZ2UgPiAwKTtcblxuICAgICAgICAgICAgICAgIC8vIEBwcmU6IG5ldyBwYXJlbnQncyBjaGlsZHJlbiBhcnJheSBoYXMgYWxyZWFkeSBiZWVuIG1vZGlmaWVkLlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgbmV3WlBhcmVudC5pbmNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKG5ld1pQYXJlbnQuX3pDb250ZXh0VXNhZ2UgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghaGFkWkNvbnRleHRVc2FnZSAmJiAodGhpcy5fcGFyZW50ID09PSBuZXdaUGFyZW50KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGhpcyBjaGlsZCB3YXMgYWxyZWFkeSBpbiB0aGUgY2hpbGRyZW4gbGlzdC5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIERvIG5vdCBhZGQgZG91YmxlLlxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQWRkIG5ldyBjaGlsZCB0byBhcnJheS5cbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld1pQYXJlbnQuX3pJbmRleGVkQ2hpbGRyZW4ucHVzaCh0aGlzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIC8vIE9yZGVyIHNob3VsZCBiZSBjaGVja2VkLlxuICAgICAgICAgICAgICAgICAgICBuZXdaUGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl96UGFyZW50ID0gbmV3WlBhcmVudDtcblxuICAgICAgICAgICAgLy8gTmV3bHkgYWRkZWQgZWxlbWVudCBtdXN0IGJlIG1hcmtlZCBmb3IgcmVzb3J0LlxuICAgICAgICAgICAgdGhpcy5fekluZGV4UmVzb3J0ID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBpbmNaQ29udGV4dFVzYWdlKCkge1xuICAgICAgICB0aGlzLl96Q29udGV4dFVzYWdlKys7XG4gICAgICAgIGlmICh0aGlzLl96Q29udGV4dFVzYWdlID09PSAxKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX3pJbmRleGVkQ2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuID0gW107XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICAvLyBDb3B5LlxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4ucHVzaCh0aGlzLl9jaGlsZHJlbltpXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIC8vIEluaXRpYWxseSwgY2hpbGRyZW4gYXJlIGFscmVhZHkgc29ydGVkIHByb3Blcmx5ICh0cmVlIG9yZGVyKS5cbiAgICAgICAgICAgICAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIGRlY1pDb250ZXh0VXNhZ2UoKSB7XG4gICAgICAgIHRoaXMuX3pDb250ZXh0VXNhZ2UtLTtcbiAgICAgICAgaWYgKHRoaXMuX3pDb250ZXh0VXNhZ2UgPT09IDApIHtcbiAgICAgICAgICAgIHRoaXMuX3pTb3J0ID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuLnNwbGljZSgwKTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBnZXQgekluZGV4KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fekluZGV4O1xuICAgIH1cblxuICAgIHNldCB6SW5kZXgoekluZGV4KSB7XG4gICAgICAgIGlmICh0aGlzLl96SW5kZXggIT09IHpJbmRleCkge1xuICAgICAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKDEpO1xuXG4gICAgICAgICAgICBsZXQgbmV3WlBhcmVudCA9IHRoaXMuX3pQYXJlbnQ7XG5cbiAgICAgICAgICAgIGxldCBwcmV2SXNaQ29udGV4dCA9IHRoaXMuaXNaQ29udGV4dCgpO1xuICAgICAgICAgICAgaWYgKHpJbmRleCA9PT0gMCAmJiB0aGlzLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fcGFyZW50ID09PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmRlY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG5ld1pQYXJlbnQgPSB0aGlzLl9wYXJlbnQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmICh6SW5kZXggIT09IDAgJiYgdGhpcy5fekluZGV4ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgbmV3WlBhcmVudCA9IHRoaXMuX3BhcmVudCA/IHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKSA6IG51bGw7XG4gICAgICAgICAgICAgICAgaWYgKG5ld1pQYXJlbnQgPT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuaW5jWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmICh6SW5kZXggIT09IHRoaXMuX3pJbmRleCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50ICYmIHRoaXMuX3pQYXJlbnQuX3pDb250ZXh0VXNhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldFpQYXJlbnQobnVsbCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX3pJbmRleCA9IHpJbmRleDtcblxuICAgICAgICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldFpQYXJlbnQobmV3WlBhcmVudCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChwcmV2SXNaQ29udGV4dCAhPT0gdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZVpDb250ZXh0KCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVaQ29udGV4dCh0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHRoYXQgcmVzb3J0IGlzIGRvbmUuXG4gICAgICAgICAgICB0aGlzLl96SW5kZXhSZXNvcnQgPSB0cnVlO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmVuYWJsZVpTb3J0KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZ2V0IGZvcmNlWkluZGV4Q29udGV4dCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZvcmNlWkluZGV4Q29udGV4dDtcbiAgICB9XG5cbiAgICBzZXQgZm9yY2VaSW5kZXhDb250ZXh0KHYpIHtcbiAgICAgICAgdGhpcy5zZXRIYXNSZW5kZXJVcGRhdGVzKDEpO1xuXG4gICAgICAgIGxldCBwcmV2SXNaQ29udGV4dCA9IHRoaXMuaXNaQ29udGV4dCgpO1xuICAgICAgICB0aGlzLl9mb3JjZVpJbmRleENvbnRleHQgPSB2O1xuXG4gICAgICAgIGlmIChwcmV2SXNaQ29udGV4dCAhPT0gdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmRpc2FibGVaQ29udGV4dCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZVpDb250ZXh0KHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZW5hYmxlWkNvbnRleHQocHJldlpDb250ZXh0KSB7XG4gICAgICAgIGlmIChwcmV2WkNvbnRleHQgJiYgcHJldlpDb250ZXh0Ll96Q29udGV4dFVzYWdlID4gMCkge1xuICAgICAgICAgICAgLy8gVHJhbnNmZXIgZnJvbSB1cHBlciB6IGNvbnRleHQgdG8gdGhpcyB6IGNvbnRleHQuXG4gICAgICAgICAgICBjb25zdCByZXN1bHRzID0gdGhpcy5fZ2V0WkluZGV4ZWREZXNjcygpO1xuICAgICAgICAgICAgcmVzdWx0cy5mb3JFYWNoKChjKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNBbmNlc3Rvck9mKGMpICYmIGMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgICAgICAgICBjLnNldFpQYXJlbnQodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0WkluZGV4ZWREZXNjcygpIHtcbiAgICAgICAgY29uc3QgcmVzdWx0cyA9IFtdO1xuICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0uX2dldFpJbmRleGVkRGVzY3NSZWMocmVzdWx0cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlc3VsdHM7XG4gICAgfVxuXG4gICAgX2dldFpJbmRleGVkRGVzY3NSZWMocmVzdWx0cykge1xuICAgICAgICBpZiAodGhpcy5fekluZGV4KSB7XG4gICAgICAgICAgICByZXN1bHRzLnB1c2godGhpcyk7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5fY2hpbGRyZW4gJiYgIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLl9nZXRaSW5kZXhlZERlc2NzUmVjKHJlc3VsdHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZGlzYWJsZVpDb250ZXh0KCkge1xuICAgICAgICAvLyBUcmFuc2ZlciBmcm9tIHRoaXMgeiBjb250ZXh0IHRvIHVwcGVyIHogY29udGV4dC5cbiAgICAgICAgaWYgKHRoaXMuX3pDb250ZXh0VXNhZ2UgPiAwKSB7XG4gICAgICAgICAgICBsZXQgbmV3WlBhcmVudCA9IHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKTtcblxuICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHRoYXQgei1pbmRleGVkIGNoaWxkcmVuIGFyZSB1cCB0byBkYXRlIChvbGQgb25lcyByZW1vdmVkKS5cbiAgICAgICAgICAgIGlmICh0aGlzLl96U29ydCkge1xuICAgICAgICAgICAgICAgIHRoaXMuc29ydFpJbmRleGVkQ2hpbGRyZW4oKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5zbGljZSgpLmZvckVhY2goZnVuY3Rpb24gKGMpIHtcbiAgICAgICAgICAgICAgICBpZiAoYy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGMuc2V0WlBhcmVudChuZXdaUGFyZW50KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBnZXQgY29sb3JVbCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2NvbG9yVWw7XG4gICAgfVxuXG4gICAgc2V0IGNvbG9yVWwoY29sb3IpIHtcbiAgICAgICAgaWYgKHRoaXMuX2NvbG9yVWwgIT09IGNvbG9yKSB7XG4gICAgICAgICAgICB0aGlzLnNldEhhc1JlbmRlclVwZGF0ZXModGhpcy5fZGlzcGxheWVkVGV4dHVyZVNvdXJjZSA/IDMgOiAxKTtcbiAgICAgICAgICAgIHRoaXMuX2NvbG9yVWwgPSBjb2xvcjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBjb2xvclVyKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY29sb3JVcjtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JVcihjb2xvcikge1xuICAgICAgICBpZiAodGhpcy5fY29sb3JVciAhPT0gY29sb3IpIHtcbiAgICAgICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcyh0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlID8gMyA6IDEpO1xuICAgICAgICAgICAgdGhpcy5fY29sb3JVciA9IGNvbG9yO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldCBjb2xvckJsKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY29sb3JCbDtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JCbChjb2xvcikge1xuICAgICAgICBpZiAodGhpcy5fY29sb3JCbCAhPT0gY29sb3IpIHtcbiAgICAgICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcyh0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlID8gMyA6IDEpO1xuICAgICAgICAgICAgdGhpcy5fY29sb3JCbCA9IGNvbG9yO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldCBjb2xvckJyKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY29sb3JCcjtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JCcihjb2xvcikge1xuICAgICAgICBpZiAodGhpcy5fY29sb3JCciAhPT0gY29sb3IpIHtcbiAgICAgICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcyh0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlID8gMyA6IDEpO1xuICAgICAgICAgICAgdGhpcy5fY29sb3JCciA9IGNvbG9yO1xuICAgICAgICB9XG4gICAgfTtcblxuXG4gICAgc2V0IG9uVX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gdGhvc2UuXG4gICAgICAgIC8vIFRoZSBvcHRpbWl6YXRpb24gd2lsbCBiZSB1c2VkIGltbWVkaWF0ZWx5IGR1cmluZyB0aGUgbmV4dCBmcmFtZS5cbiAgICAgICAgdGhpcy5fY2xpcGJveCA9IHY7XG4gICAgfVxuXG4gICAgX3NldFNoYWRlck93bmVyUmVjdXJzaXZlKGVsZW1lbnRDb3JlKSB7XG4gICAgICAgIHRoaXMuX3NoYWRlck93bmVyID0gZWxlbWVudENvcmU7XG5cbiAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuICYmICF0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGxldCBjID0gdGhpcy5fY2hpbGRyZW5baV07XG4gICAgICAgICAgICAgICAgaWYgKCFjLl9zaGFkZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgYy5fc2V0U2hhZGVyT3duZXJSZWN1cnNpdmUoZWxlbWVudENvcmUpO1xuICAgICAgICAgICAgICAgICAgICBjLl9oYXNSZW5kZXJVcGRhdGVzID0gMztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgX3NldFNoYWRlck93bmVyQ2hpbGRyZW5SZWN1cnNpdmUoZWxlbWVudENvcmUpIHtcbiAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGxldCBjID0gdGhpcy5fY2hpbGRyZW5baV07XG4gICAgICAgICAgICAgICAgaWYgKCFjLl9zaGFkZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgYy5fc2V0U2hhZGVyT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tcblxuICAgICAgICAgICAgaWYgKCF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZVpDb250ZXh0KCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIE1ha2Ugc3VyZSB0aGF0IHRoZSByZW5kZXIgY29vcmRpbmF0ZXMgZ2V0IHVwZGF0ZWQuXG4gICAgICAgICAgICB0aGlzLl9zZXRSZWNhbGMoNyk7XG5cbiAgICAgICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcygzKTtcblxuICAgICAgICAgICAgdGhpcy5yZW5kZXIgPSB0aGlzLl9yZW5kZXJTaW1wbGU7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBpc1doaXRlKCkge1xuICAgICAgICByZXR1cm4gKHRoaXMuX2NvbG9yVWwgPT09IDB4RkZGRkZGRkYpICYmICh0aGlzLl9jb2xvclVyID09PSAweEZGRkZGRkZGKSAmJiAodGhpcy5fY29sb3JCbCA9PT0gMHhGRkZGRkZGRikgJiYgKHRoaXMuX2NvbG9yQnIgPT09IDB4RkZGRkZGRkYpO1xuICAgIH1cblxuICAgIGhhc1NpbXBsZVRleENvb3JkcygpIHtcbiAgICAgICAgcmV0dXJuICh0aGlzLl91bHggPT09IDApICYmICh0aGlzLl91bHkgPT09IDApICYmICh0aGlzLl9icnggPT09IDEpICYmICh0aGlzLl9icnkgPT09IDEpO1xuICAgIH1cblxuICAgIF9zdGFzaFRleENvb3JkcygpIHtcbiAgICAgICAgdGhpcy5fc3Rhc2hlZFRleENvb3JkcyA9IFt0aGlzLl91bHgsIHRoaXMuX3VseSwgdGhpcy5fYnJ4LCB0aGlzLl9icnldO1xuICAgICAgICB0aGlzLl91bHggPSAwO1xuICAgICAgICB0aGlzLl91bHkgPSAwO1xuICAgICAgICB0aGlzLl9icnggPSAxO1xuICAgICAgICB0aGlzLl9icnkgPSAxO1xuICAgIH1cblxuICAgIF91bnN0YXNoVGV4Q29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9IHRoaXMuX3JlY2FsYztcblxuICAgICAgICAgICAgLy8gVXBkYXRlIHdvcmxkIGNvb3Jkcy9hbHBoYS5cbiAgICAgICAgICAgIGlmIChyZWNhbGMgJiAxKSB7XG4gICAgICAgICAgICAgICAgaWYgKCF3LmFscGhhICYmIHZpc2libGUpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQmVjb21lcyB2aXNpYmxlLlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9oYXNSZW5kZXJVcGRhdGVzID0gMztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdy5hbHBoYSA9IHB3LmFscGhhICogdGhpcy5fbG9jYWxBbHBoYTtcblxuICAgICAgICAgICAgICAgIGlmICh3LmFscGhhIDwgMWUtMTQpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gVGlueSByb3VuZGluZyBlcnJvcnMgbWF5IGNhdXNlIGZhaWxpbmcgdmlzaWJpbGl0eSB0ZXN0cy5cbiAgICAgICAgICAgICAgICAgICAgdy5hbHBoYSA9IDA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocmVjYWxjICYgNikge1xuICAgICAgICAgICAgICAgIHcucHggPSBwdy5weCArIHRoaXMuX2xvY2FsUHggKiBwdy50YTtcbiAgICAgICAgICAgICAgICB3LnB5ID0gcHcucHkgKyB0aGlzLl9sb2NhbFB5ICogcHcudGQ7XG4gICAgICAgICAgICAgICAgaWYgKHB3LnRiICE9PSAwKSB3LnB4ICs9IHRoaXMuX2xvY2FsUHkgKiBwdy50YjtcbiAgICAgICAgICAgICAgICBpZiAocHcudGMgIT09IDApIHcucHkgKz0gdGhpcy5fbG9jYWxQeCAqIHB3LnRjO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocmVjYWxjICYgNCkge1xuICAgICAgICAgICAgICAgIHcudGEgPSB0aGlzLl9sb2NhbFRhICogcHcudGE7XG4gICAgICAgICAgICAgICAgdy50YiA9IHRoaXMuX2xvY2FsVGQgKiBwdy50YjtcbiAgICAgICAgICAgICAgICB3LnRjID0gdGhpcy5fbG9jYWxUYSAqIHB3LnRjO1xuICAgICAgICAgICAgICAgIHcudGQgPSB0aGlzLl9sb2NhbFRkICogcHcudGQ7XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5faXNDb21wbGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIHcudGEgKz0gdGhpcy5fbG9jYWxUYyAqIHB3LnRiO1xuICAgICAgICAgICAgICAgICAgICB3LnRiICs9IHRoaXMuX2xvY2FsVGIgKiBwdy50YTtcbiAgICAgICAgICAgICAgICAgICAgdy50YyArPSB0aGlzLl9sb2NhbFRjICogcHcudGQ7XG4gICAgICAgICAgICAgICAgICAgIHcudGQgKz0gdGhpcy5fbG9jYWxUYiAqIHB3LnRjO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gVXBkYXRlIHJlbmRlciBjb29yZHMvYWxwaGEuXG4gICAgICAgICAgICBjb25zdCBwciA9IHRoaXMuX3BhcmVudC5fcmVuZGVyQ29udGV4dDtcbiAgICAgICAgICAgIGlmICh0aGlzLl9wYXJlbnQuX2hhc1JlbmRlckNvbnRleHQoKSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGluaXQgPSB0aGlzLl9yZW5kZXJDb250ZXh0ID09PSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICAgICAgICAgICAgaWYgKGluaXQpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmlyc3QgcmVuZGVyIGNvbnRleHQgYnVpbGQ6IG1ha2Ugc3VyZSB0aGF0IGl0IGlzIGZ1bGx5IGluaXRpYWxpemVkIGNvcnJlY3RseS5cbiAgICAgICAgICAgICAgICAgICAgLy8gT3RoZXJ3aXNlLCBpZiB3ZSBnZXQgaW50byBib3VuZHMgbGF0ZXIsIHRoZSByZW5kZXIgY29udGV4dCB3b3VsZCBub3QgYmUgaW5pdGlhbGl6ZWQgY29ycmVjdGx5LlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gbmV3IEVsZW1lbnRDb3JlQ29udGV4dCgpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGNvbnN0IHIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuXG4gICAgICAgICAgICAgICAgLy8gVXBkYXRlIHdvcmxkIGNvb3Jkcy9hbHBoYS5cbiAgICAgICAgICAgICAgICBpZiAoaW5pdCB8fCAocmVjYWxjICYgMSkpIHtcbiAgICAgICAgICAgICAgICAgICAgci5hbHBoYSA9IHByLmFscGhhICogdGhpcy5fbG9jYWxBbHBoYTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAoci5hbHBoYSA8IDFlLTE0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByLmFscGhhID0gMDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChpbml0IHx8IChyZWNhbGMgJiA2KSkge1xuICAgICAgICAgICAgICAgICAgICByLnB4ID0gcHIucHggKyB0aGlzLl9sb2NhbFB4ICogcHIudGE7XG4gICAgICAgICAgICAgICAgICAgIHIucHkgPSBwci5weSArIHRoaXMuX2xvY2FsUHkgKiBwci50ZDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHByLnRiICE9PSAwKSByLnB4ICs9IHRoaXMuX2xvY2FsUHkgKiBwci50YjtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHByLnRjICE9PSAwKSByLnB5ICs9IHRoaXMuX2xvY2FsUHggKiBwci50YztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoaW5pdCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBXZSBzZXQgdGhlIHJlY2FsYyB0b2dnbGUsIGJlY2F1c2Ugd2UgbXVzdCBtYWtlIHN1cmUgdGhhdCB0aGUgc2Npc3NvciBpcyB1cGRhdGVkLlxuICAgICAgICAgICAgICAgICAgICByZWNhbGMgfD0gMjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoaW5pdCB8fCAocmVjYWxjICYgNCkpIHtcbiAgICAgICAgICAgICAgICAgICAgci50YSA9IHRoaXMuX2xvY2FsVGEgKiBwci50YTtcbiAgICAgICAgICAgICAgICAgICAgci50YiA9IHRoaXMuX2xvY2FsVGQgKiBwci50YjtcbiAgICAgICAgICAgICAgICAgICAgci50YyA9IHRoaXMuX2xvY2FsVGEgKiBwci50YztcbiAgICAgICAgICAgICAgICAgICAgci50ZCA9IHRoaXMuX2xvY2FsVGQgKiBwci50ZDtcblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5faXNDb21wbGV4KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByLnRhICs9IHRoaXMuX2xvY2FsVGMgKiBwci50YjtcbiAgICAgICAgICAgICAgICAgICAgICAgIHIudGIgKz0gdGhpcy5fbG9jYWxUYiAqIHByLnRhO1xuICAgICAgICAgICAgICAgICAgICAgICAgci50YyArPSB0aGlzLl9sb2NhbFRjICogcHIudGQ7XG4gICAgICAgICAgICAgICAgICAgICAgICByLnRkICs9IHRoaXMuX2xvY2FsVGIgKiBwci50YztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlciA9PT0gLTEpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmN0eC51cGRhdGVUcmVlT3JkZXIgPSB0aGlzLl91cGRhdGVUcmVlT3JkZXIgKyAxO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVUcmVlT3JkZXIgPSB0aGlzLmN0eC51cGRhdGVUcmVlT3JkZXIrKztcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gRGV0ZXJtaW5lIHdoZXRoZXIgd2UgbXVzdCB1c2UgYSAncmVuZGVyVGV4dHVyZScuXG4gICAgICAgICAgICBjb25zdCB1c2VSZW5kZXJUb1RleHR1cmUgPSB0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkICYmIHRoaXMuX3RleHR1cml6ZXIubXVzdFJlbmRlclRvVGV4dHVyZSgpO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSAhPT0gdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgLy8gQ29vcmRzIG11c3QgYmUgY2hhbmdlZC5cbiAgICAgICAgICAgICAgICB0aGlzLl9yZWNhbGMgfD0gMiArIDQ7XG5cbiAgICAgICAgICAgICAgICAvLyBTY2lzc29yIG1heSBjaGFuZ2U6IGZvcmNlIHVwZGF0ZS5cbiAgICAgICAgICAgICAgICByZWNhbGMgfD0gMjtcblxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFdlIG11c3QgcmVsZWFzZSB0aGUgdGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci5yZWxlYXNlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlID0gdXNlUmVuZGVyVG9UZXh0dXJlO1xuXG4gICAgICAgICAgICBjb25zdCByID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcblxuICAgICAgICAgICAgY29uc3QgYmJveFcgPSB0aGlzLl9kaW1zVW5rbm93biA/IDIwNDggOiB0aGlzLl93O1xuICAgICAgICAgICAgY29uc3QgYmJveEggPSB0aGlzLl9kaW1zVW5rbm93biA/IDIwNDggOiB0aGlzLl9oO1xuXG4gICAgICAgICAgICAvLyBDYWxjdWxhdGUgYSBiYm94IGZvciB0aGlzIGVsZW1lbnQuXG4gICAgICAgICAgICBsZXQgc3gsIHN5LCBleCwgZXk7XG4gICAgICAgICAgICBjb25zdCByQ29tcGxleCA9IChyLnRiICE9PSAwKSB8fCAoci50YyAhPT0gMCkgfHwgKHIudGEgPCAwKSB8fCAoci50ZCA8IDApO1xuICAgICAgICAgICAgaWYgKHJDb21wbGV4KSB7XG4gICAgICAgICAgICAgICAgc3ggPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICAgICAgZXggPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICAgICAgc3kgPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgICAgICAgZXkgPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHN4ID0gci5weDtcbiAgICAgICAgICAgICAgICBleCA9IHIucHggKyByLnRhICogYmJveFc7XG4gICAgICAgICAgICAgICAgc3kgPSByLnB5O1xuICAgICAgICAgICAgICAgIGV5ID0gci5weSArIHIudGQgKiBiYm94SDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX2RpbXNVbmtub3duICYmIChyQ29tcGxleCB8fCB0aGlzLl9sb2NhbFRhIDwgMSB8fCB0aGlzLl9sb2NhbFRiIDwgMSkpIHtcbiAgICAgICAgICAgICAgICAvLyBJZiB3ZSBhcmUgZGVhbGluZyB3aXRoIGEgbm9uLWlkZW50aXR5IG1hdHJpeCwgd2UgbXVzdCBleHRlbmQgdGhlIGJib3ggc28gdGhhdCB3aXRoaW5Cb3VuZHMgYW5kXG4gICAgICAgICAgICAgICAgLy8gIHNjaXNzb3JzIHdpbGwgaW5jbHVkZSB0aGUgY29tcGxldGUgcmFuZ2Ugb2YgKHBvc2l0aXZlKSBkaW1lbnNpb25zIHVwIHRvICxsaC5cbiAgICAgICAgICAgICAgICBjb25zdCBueCA9IHRoaXMuX3ggKiBwci50YSArIHRoaXMuX3kgKiBwci50YiArIHByLnB4O1xuICAgICAgICAgICAgICAgIGNvbnN0IG55ID0gdGhpcy5feCAqIHByLnRjICsgdGhpcy5feSAqIHByLnRkICsgcHIucHk7XG4gICAgICAgICAgICAgICAgaWYgKG54IDwgc3gpIHN4ID0gbng7XG4gICAgICAgICAgICAgICAgaWYgKG55IDwgc3kpIHN5ID0gbnk7XG4gICAgICAgICAgICAgICAgaWYgKG54ID4gZXgpIGV4ID0gbng7XG4gICAgICAgICAgICAgICAgaWYgKG55ID4gZXkpIGV5ID0gbnk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChyZWNhbGMgJiA2IHx8ICF0aGlzLl9zY2lzc29yIC8qIGluaXRpYWwgKi8pIHtcbiAgICAgICAgICAgICAgICAvLyBEZXRlcm1pbmUgd2hldGhlciB3ZSBtdXN0ICdjbGlwJy5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2xpcHBpbmcgJiYgci5pc1NxdWFyZSgpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIElmIHRoZSBwYXJlbnQgcmVuZGVycyB0byBhIHRleHR1cmUsIGl0J3Mgc2Npc3NvciBzaG91bGQgYmUgaWdub3JlZDtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJlYSA9IHRoaXMuX3BhcmVudC5fdXNlUmVuZGVyVG9UZXh0dXJlID8gdGhpcy5fcGFyZW50Ll92aWV3cG9ydCA6IHRoaXMuX3BhcmVudC5fc2Npc3NvcjtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFyZWEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIE1lcmdlIHNjaXNzb3IgYXJlYXMuXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBseCA9IE1hdGgubWF4KGFyZWFbMF0sIHN4KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGx5ID0gTWF0aC5tYXgoYXJlYVsxXSwgc3kpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IFtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBseCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBseSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXRoLm1pbihhcmVhWzJdICsgYXJlYVswXSwgZXgpIC0gbHgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgTWF0aC5taW4oYXJlYVszXSArIGFyZWFbMV0sIGV5KSAtIGx5XG4gICAgICAgICAgICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IFtzeCwgc3ksIGV4IC0gc3gsIGV5IC0gc3ldO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gTm8gY2xpcHBpbmc6IHJldXNlIHBhcmVudCBzY2lzc29yLlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gdGhpcy5fcGFyZW50Ll91c2VSZW5kZXJUb1RleHR1cmUgPyB0aGlzLl9wYXJlbnQuX3ZpZXdwb3J0IDogdGhpcy5fcGFyZW50Ll9zY2lzc29yO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gQ2FsY3VsYXRlIHRoZSBvdXRPZkJvdW5kcyBtYXJnaW4uXG4gICAgICAgICAgICBpZiAodGhpcy5fYm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmVjQm91bmRzTWFyZ2luID0gdGhpcy5fYm91bmRzTWFyZ2luO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZWNCb3VuZHNNYXJnaW4gPSB0aGlzLl9wYXJlbnQuX3JlY0JvdW5kc01hcmdpbjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJDYWxjcykge1xuICAgICAgICAgICAgICAgIC8vIEFmdGVyIGNhbGNzIG1heSBjaGFuZ2UgcmVuZGVyIGNvb3Jkcywgc2Npc3NvciBhbmQvb3IgcmVjQm91bmRzTWFyZ2luLlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9vbkFmdGVyQ2FsY3ModGhpcy5lbGVtZW50KSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBSZWNhbGN1bGF0ZSBiYm94LlxuICAgICAgICAgICAgICAgICAgICBpZiAockNvbXBsZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN4ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgICAgICAgICAgICAgZXggPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICAgICAgICAgICAgICBzeSA9IE1hdGgubWluKDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV5ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ggPSByLnB4O1xuICAgICAgICAgICAgICAgICAgICAgICAgZXggPSByLnB4ICsgci50YSAqIGJib3hXO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3kgPSByLnB5O1xuICAgICAgICAgICAgICAgICAgICAgICAgZXkgPSByLnB5ICsgci50ZCAqIGJib3hIO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RpbXNVbmtub3duICYmIChyQ29tcGxleCB8fCB0aGlzLl9sb2NhbFRhIDwgMSB8fCB0aGlzLl9sb2NhbFRiIDwgMSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG54ID0gdGhpcy5feCAqIHByLnRhICsgdGhpcy5feSAqIHByLnRiICsgcHIucHg7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBueSA9IHRoaXMuX3ggKiBwci50YyArIHRoaXMuX3kgKiBwci50ZCArIHByLnB5O1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG54IDwgc3gpIHN4ID0gbng7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobnkgPCBzeSkgc3kgPSBueTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChueCA+IGV4KSBleCA9IG54O1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG55ID4gZXkpIGV5ID0gbnk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9wYXJlbnQuX291dE9mQm91bmRzID09PSAyKSB7XG4gICAgICAgICAgICAgICAgLy8gSW5oZXJpdCBwYXJlbnQgb3V0IG9mIGJvdW5kc25lc3MuXG4gICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9kaXNhYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAocmVjYWxjICYgNikge1xuICAgICAgICAgICAgICAgICAgICAvLyBSZWNoZWNrIGlmIGVsZW1lbnQgaXMgb3V0LW9mLWJvdW5kcyAoYWxsIHNldHRpbmdzIHRoYXQgYWZmZWN0IHRoaXMgc2hvdWxkIGVuYWJsZSByZWNhbGMgYml0IDIgb3IgNCkuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMDtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHdpdGhpbk1hcmdpbiA9IHRydWU7XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gT2Zmc2NyZWVucyBhcmUgYWx3YXlzIHJlbmRlcmVkIGFzIGxvbmcgYXMgdGhlIHBhcmVudCBpcyB3aXRoaW4gYm91bmRzLlxuICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JlbmRlclRvVGV4dHVyZUVuYWJsZWQgfHwgIXRoaXMuX3RleHR1cml6ZXIgfHwgIXRoaXMuX3RleHR1cml6ZXIucmVuZGVyT2Zmc2NyZWVuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fc2Npc3NvciAmJiAodGhpcy5fc2Npc3NvclsyXSA8PSAwIHx8IHRoaXMuX3NjaXNzb3JbM10gPD0gMCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBFbXB0eSBzY2lzc29yIGFyZWEuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVc2UgYmJveCB0byBjaGVjayBvdXQtb2YtYm91bmRuZXNzLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgodGhpcy5fc2Npc3NvclswXSA+IGV4KSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodGhpcy5fc2Npc3NvclsxXSA+IGV5KSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3ggPiAodGhpcy5fc2Npc3NvclswXSArIHRoaXMuX3NjaXNzb3JbMl0pKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3kgPiAodGhpcy5fc2Npc3NvclsxXSArIHRoaXMuX3NjaXNzb3JbM10pKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jbGlwcGluZyB8fCB0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUgfHwgKHRoaXMuX2NsaXBib3ggJiYgKGJib3hXICYmIGJib3hIKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgd2l0aGluTWFyZ2luID0gKHRoaXMuX291dE9mQm91bmRzID09PSAwKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghd2l0aGluTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmUtdGVzdCwgbm93IHdpdGggbWFyZ2lucy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcmVjQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGhpbk1hcmdpbiA9ICEoKGV4IDwgdGhpcy5fc2Npc3NvclswXSAtIHRoaXMuX3JlY0JvdW5kc01hcmdpblsyXSkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChleSA8IHRoaXMuX3NjaXNzb3JbMV0gLSB0aGlzLl9yZWNCb3VuZHNNYXJnaW5bM10pIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3ggPiB0aGlzLl9zY2lzc29yWzBdICsgdGhpcy5fc2Npc3NvclsyXSArIHRoaXMuX3JlY0JvdW5kc01hcmdpblswXSkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzeSA+IHRoaXMuX3NjaXNzb3JbMV0gKyB0aGlzLl9zY2lzc29yWzNdICsgdGhpcy5fcmVjQm91bmRzTWFyZ2luWzFdKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aGluTWFyZ2luID0gISgoZXggPCB0aGlzLl9zY2lzc29yWzBdIC0gMTAwKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGV5IDwgdGhpcy5fc2Npc3NvclsxXSAtIDEwMCkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzeCA+IHRoaXMuX3NjaXNzb3JbMF0gKyB0aGlzLl9zY2lzc29yWzJdICsgMTAwKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN5ID4gdGhpcy5fc2Npc3NvclsxXSArIHRoaXMuX3NjaXNzb3JbM10gKyAxMDApKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpdGhpbk1hcmdpbiAmJiB0aGlzLl9vdXRPZkJvdW5kcyA9PT0gMikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDaGlsZHJlbiBtdXN0IGJlIHZpc2l0ZWQgYmVjYXVzZSB0aGV5IG1heSBjb250YWluIGVsZW1lbnRzIHRoYXQgYXJlIHdpdGhpbiBtYXJnaW4sIHNvIG11c3QgYmUgdmlzaWJsZS5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gIT09IHdpdGhpbk1hcmdpbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fd2l0aGluQm91bmRzTWFyZ2luID0gd2l0aGluTWFyZ2luO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGhpcyBtYXkgdXBkYXRlIHRoaW5ncyAodHhMb2FkZWQgZXZlbnRzKSBpbiB0aGUgZWxlbWVudCBpdHNlbGYsIGJ1dCBhbHNvIGluIGRlc2NlbmRhbn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hbmNlc3RvcnMuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGFzVXBkYXRlcyA9IHRydWU7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWNhbGMgPSB0aGlzLl9yZWNhbGM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVjYWxjID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2VuYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlY2FsYykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUaGlzIGVsZW1lbnQgbmVlZHMgdG8gYmUgcmUtdXBkYXRlZCBub3csIGJlY2F1c2Ugd2Ugd2FudCB0aGUgZGltZW5zaW9ucyAoYW5kIG90aGVyIGNoYW5nZXMpIHRvIGJlIHVwZGF0ZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnVwZGF0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlY2FsYyA9IHJlY2FsYztcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9kaXNhYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICAgICAgICAvLyBTZXQgdmlld3BvcnQgbmVjZXNzYXJ5IGZvciBjaGlsZHJlbiBzY2lzc29yIGNhbGN1bGF0aW9uLlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl92aWV3cG9ydCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl92aWV3cG9ydFsyXSA9IGJib3hXO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl92aWV3cG9ydFszXSA9IGJib3hIO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0ID0gWzAsIDAsIGJib3hXLCBiYm94SF07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBGaWx0ZXIgb3V0IGJpdHMgdGhhdCBzaG91bGQgbm90IGJlIGNvcGllZCB0byB0aGUgY2hpbGRyZW4gKGN1cnJlbnRseSBhbGwgYXJlKS5cbiAgICAgICAgICAgIHRoaXMuX3BSZWNhbGMgPSAodGhpcy5fcmVjYWxjICYgMTM1KTtcblxuICAgICAgICAgICAgLy8gQ2xlYXIgZmxhZ3Mgc28gdGhhdCBmdXR1cmUgdXBkYXRlcyBhcmUgcHJvcGVybHkgZGV0ZWN0ZWQuXG4gICAgICAgICAgICB0aGlzLl9yZWNhbGMgPSAwO1xuICAgICAgICAgICAgdGhpcy5faGFzVXBkYXRlcyA9IGZhbHNlO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fb3V0T2ZCb3VuZHMgPCAyKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fd29ybGRDb250ZXh0LmlzSWRlbnRpdHkoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gT3B0aW1pemF0aW9uLlxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGhlIHdvcmxkIGNvbnRleHQgaXMgYWxyZWFkeSBpZGVudGl0eTogdXNlIHRoZSB3b3JsZCBjb250ZXh0IGFzIHJlbmRlciBjb250ZXh0IHRvIHByZXZlbnRzIHRoZVxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gYW5jZXN0b3JzIGZyb20gaGF2aW5nIHRvIHVwZGF0ZSB0aGUgcmVuZGVyIGNvbnRleHQuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGVtcG9yYXJpbHkgcmVwbGFjZSB0aGUgcmVuZGVyIGNvb3JkIGF0dHJpYnMgYnkgdGhlIGlkZW50aXR5IG1hdHJpeC5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgYWxsb3dzIHRoZSBjaGlsZHJlbiB0byBjYWxjdWxhdGUgdGhlIHJlbmRlciBjb250ZXh0LlxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IEVsZW1lbnRDb3JlQ29udGV4dC5JREVOVElUWTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSByO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW5baV0uX2hhc1VwZGF0ZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gTWFrZSBzdXJlIHdlIGRvbid0IGxvc2UgdGhlICdpbmhlcml0ZWQnIHVwZGF0ZXMuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0uX3JlY2FsYyB8PSB0aGlzLl9wUmVjYWxjO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZU91dE9mQm91bmRzKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9vbkFmdGVyVXBkYXRlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb25BZnRlclVwZGF0ZSh0aGlzLmVsZW1lbnQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlciA9PT0gLTEgfHwgdGhpcy5fdXBkYXRlVHJlZU9yZGVyID49IHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlcikge1xuICAgICAgICAgICAgICAgIC8vIElmIG5ldyB0cmVlIG9yZGVyIGRvZXMgbm90IGludGVyZmVyZSB3aXRoIHRoZSBjdXJyZW50IChnYXBzIGFsbG93ZWQpIHRoZXJlJ3Mgbm8gbmVlZCB0byB0cmF2ZXJzZSB0aGUgYnJhbmNoLlxuICAgICAgICAgICAgICAgIHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlciA9IC0xO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVRyZWVPcmRlcigpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2FwcGx5UmVsYXRpdmVEaW1GdW5jcygpIHtcbiAgICAgICAgaWYgKHRoaXMuX29wdEZsYWdzICYgMSkge1xuICAgICAgICAgICAgY29uc3QgeCA9IHRoaXMuX2Z1bmNYKHRoaXMuX3BhcmVudC53KTtcbiAgICAgICAgICAgIGlmICh4ICE9PSB0aGlzLl94KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbG9jYWxQeCArPSAoeCAtIHRoaXMuX3gpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3ggPSB4O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9vcHRGbGFncyAmIDIpIHtcbiAgICAgICAgICAgIGNvbnN0IHkgPSB0aGlzLl9mdW5jWSh0aGlzLl9wYXJlbnQuaCk7XG4gICAgICAgICAgICBpZiAoeSAhPT0gdGhpcy5feSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2xvY2FsUHkgKz0gKHkgLSB0aGlzLl95KTtcbiAgICAgICAgICAgICAgICB0aGlzLl95ID0geTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBjaGFuZ2VkRGltcyA9IGZhbHNlO1xuICAgICAgICBpZiAodGhpcy5fb3B0RmxhZ3MgJiA0KSB7XG4gICAgICAgICAgICBjb25zdCB3ID0gdGhpcy5fZnVuY1codGhpcy5fcGFyZW50LncpO1xuICAgICAgICAgICAgaWYgKHcgIT09IHRoaXMuX3cpIHtcbiAgICAgICAgIC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ICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICAgIHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZGlzYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGVPdXRPZkJvdW5kcygpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHVwZGF0ZVRyZWVPcmRlcigpIHtcbiAgICAgICAgaWYgKHRoaXMuX2xvY2FsQWxwaGEgJiYgKHRoaXMuX291dE9mQm91bmRzICE9PSAyKSkge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVHJlZU9yZGVyID0gdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyKys7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZVRyZWVPcmRlcigpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9yZW5kZXJTaW1wbGUoKSB7XG4gICAgICAgIHRoaXMuX2hhc1JlbmRlclVwZGF0ZXMgPSAwO1xuXG4gICAgICAgIGlmICh0aGlzLl96U29ydCkge1xuICAgICAgICAgICAgdGhpcy5zb3J0WkluZGV4ZWRDaGlsZHJlbigpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzIDwgMiAmJiB0aGlzLl9yZW5kZXJDb250ZXh0LmFscGhhKSB7XG4gICAgICAgICAgICBsZXQgcmVuZGVyU3RhdGUgPSB0aGlzLnJlbmRlclN0YXRlO1xuXG4gICAgICAgICAgICBpZiAoKHRoaXMuX291dE9mQm91bmRzID09PSAwKSAmJiB0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlKSB7XG4gICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2hhZGVyKHRoaXMuYWN0aXZlU2hhZGVyLCB0aGlzLl9zaGFkZXJPd25lcik7XG4gICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2Npc3Nvcih0aGlzLl9zY2lzc29yKTtcbiAgICAgICAgICAgICAgICB0aGlzLnJlbmRlclN0YXRlLmFkZFF1YWQodGhpcyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEFsc28gYWRkIGNoaWxkcmVuIHRvIHRoZSBWQk8uXG4gICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGl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B0aGUgcmVuZGVyIHRleHR1cmUuXG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNoYWRlcihyZW5kZXJTdGF0ZS5kZWZhdWx0U2hhZGVyLCB0aGlzKTtcblxuICAgICAgICAgICAgICAgICAgICBwcmV2UmVuZGVyVGV4dHVyZUluZm8gPSByZW5kZXJTdGF0ZS5yZW5kZXJUZXh0dXJlSW5mbztcblxuICAgICAgICAgICAgICAgICAgICByZW5kZXJUZXh0dXJlSW5mbyA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hdGl2ZVRleHR1cmU6IG51bGwsXG4gICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQ6IDAsICAvLyBTZXQgYnkgQ29yZVJlbmRlclN0YXRlLlxuICAgICAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fdyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuX2gsXG4gICAgICAgICAgICAgICAgICAgICAgICBlbXB0eTogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlOiBmYWxzZVxuICAgICAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl90ZXh0dXJpemVyLmhhc1Jlc3VsdFRleHR1cmUoKSB8fCAoIXJlbmRlclN0YXRlLmlzQ2FjaGluZ1RleHR1cml6ZXIgJiYgKGhhc1JlbmRlclVwZGF0ZXMgPCAzKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8qKlxuICAgICAgICAgICAgICAgICAgICAgICAgICogV2UgZG9uJ3QgYWx3YXlzIGNhY2hlIHJlbmRlciB0ZXh0dXJlcy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAqXG4gICAgICAgICAgICAgICAgICAgICAgICAgKiBUaGUg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AgICAgICogb2YgR1BVIG1lbW9yeSFcbiAgICAgICAgICAgICAgICAgICAgICAgICAqXG4gICAgICAgICAgICAgICAgICAgICAgICAgKiBFc3BlY2lhbGx5IHdoZW4gdXNpbmcgbXVsdGlwbGUgc3RhY2tlZCBsYXllcnMgb2YgdGhlIHNhbWUgZGltZW5zaW9ucyB0aGF0IGFyZSBSVFQgdGhpcyB3aWxsIGhhdmUgYSB2ZXJ5XG4gICAgICAgICAgICAgICAgICAgICAgICAgKiBub3RpY2FibGUgZWZmZWN0IG9uIHBlcmZvcm1hbmNlIGFzIGxlc3MgcmVuZGVyIHRleHR1cmVzIG5lZWQgdG8gYmUgYWxsb2NhdGVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgICovXG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJUZXh0dXJlSW5mby5jYWNoZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5pc0NhY2hpbmdUZXh0dXJpemVyID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5oYXNSZXN1bHRUZXh0dXJlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFdlIGNhbiBhbHJlYWR5IHJlbGVhc2UgdGhlIGN1cnJlbnQgdGV4dHVyZSB0byB0aGUgcG9vbCwgYXMgaXQgd2lsbCBiZSByZWJ1aWxkIGFueXdheS5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEluIGNhc2Ugb2YgbXVsdGlwbGUgbGF5ZXJzIG9mICdmaWx0ZXJpbmcnLCB0aGlzIG1heSBzYXZlIHVzIGZyb20gaGF2aW5nIHRvIGNyZWF0ZSBvbmVcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vICByZW5kZXItdG8tdGV4dHVyZSBsYXllci5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5vdGljZSB0aGF0IHdlIGRvbid0IGRvIHRoaXMgd2hlbiB0aGVyZSBpcyBhIHJlc3VsdCB0ZXh0dXJlLCBhcyBhbnkgb3RoZXIgZWxlbWVudCBtYXkgcmVseSBvblxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gIHRoYXQgcmVzdWx0IHRleHR1cmUgYmVpbmcgZmlsbGVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci5yZWxlYXNlUmVuZGVyVGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0UmVuZGVyVGV4dHVyZUluZm8ocmVuZGVyVGV4dHVyZUluZm8pO1xuICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTY2lzc29yKG51bGwpO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kaXNwbGF5ZWRUZXh0dXJlU291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFVzZSBhbiBpZGVudGl0eSBjb250ZXh0IGZvciBkcmF3aW5nIHRoZSBkaXNwbGF5ZWQgdGV4dHVyZSB0byB0aGUgcmVuZGVyIHRleHR1cmUuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gRWxlbWVudENvcmVDb250ZXh0LklERU5USVRZO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBBZGQgZGlzcGxheWVkIHRleHR1cmUgc291cmNlIGluIGxvY2FsIGNvb3JkaW5hdGVzLlxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJTdGF0ZS5hZGRRdWFkKHRoaXMpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gcjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG11c3RSZW5kZXJDaGlsZHJlbiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKCh0aGlzLl9vdXRPZkJvdW5kcyA9PT0gMCkgJiYgdGhpcy5fZGlzcGxheWVkVGV4dHVyZVNvdXJjZSkge1xuICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTaGFkZXIodGhpcy5hY3RpdmVTaGFkZXIsIHRoaXMuX3NoYWRlck93bmVyKTtcbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2Npc3Nvcih0aGlzLl9zY2lzc29yKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJTdGF0ZS5hZGRRdWFkKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gQWxzbyBhZGQgY2hpbGRyZW4gdG8gdGhlIFZCTy5cbiAgICAgICAgICAgIGlmIChtdXN0UmVuZGVyQ2hpbGRyZW4gJiYgdGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbltpXS5fekluZGV4ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gSWYgekluZGV4IGlzIHNldCwgdGhpcyBpdGVtIGFscmVhZHkgYmVsb25ncyB0byBhIHpJbmRleGVkQ2hpbGRyZW4gYXJyYXkgaW4gb25lIG9mIHRoZSBhbmNlc3RvcnMuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0ucmVuZGVyKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICAgICAgICBsZXQgdXBkYXRlUmVzdWx0VGV4dHVyZSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGlmIChtdXN0UmVuZGVyQ2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmluaXNoZWQgcmVmcmVzaGluZyByZW5kZXJUZXh0dXJlLlxuICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5maW5pc2hlZFJlbmRlclRleHR1cmUoKTtcblxuICAgICAgICAgICAgICAgICAgICAvLyBJZiBub3RoaW5nIHdhcyByZW5kZXJlZCwgd2Ugc3RvcmUgYSBmbGFnIGluIHRoZSB0ZXh0dXJpemVyIGFuZCBwcmV2ZW50IHVubmVjZXNzYXJ5XG4gICAgICAgICAgICAgICAgICAgIC8vICByZW5kZXItdG8tdGV4dHVyZSBhbmQgZmlsdGVyaW5nLlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLmVtcHR5ID0gcmVuZGVyVGV4dHVyZUluZm8uZW1wdHk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHJlbmRlclRleHR1cmVJbmZvLmVtcHR5KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBXZSBpZ25vcmUgZW1wdHkgcmVuZGVyIHRleHR1cmVzIGFuZCBkbyBub3QgZHJhdyB0aGUgZmluYWwgcXVhZC5cblxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGhlIGZvbGxvd2luZyBjbGVhbnMgdXAgbWVtb3J5IGFuZCBlbmZvcmNlcyB0aGF0IHRoZSByZXN1bHQgdGV4dHVyZSBpcyBhbHNvIGNsZWFyZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnJlbGVhc2VSZW5kZXJUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmVuZGVyVGV4dHVyZUluZm8ubmF0aXZlVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gSWYgbmF0aXZlVGV4dHVyZSBpcyBzZXQsIHdlIGNhbiByZXVzZSB0aGF0IGRpcmVjdGx5IGluc3RlYWQgb2YgY3JlYXRpbmcgYSBuZXcgcmVuZGVyIHRleHR1cmUuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyLnJldXNlVGV4dHVyZUFzUmVuZGVyVGV4dHVyZShyZW5kZXJUZXh0dXJlSW5mby5uYXRpdmVUZXh0dXJlKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyVGV4dHVyZUluZm8uaWdub3JlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl90ZXh0dXJpemVyLnJlbmRlclRleHR1cmVSZXVzZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBRdWFkIG9wZXJhdGlvbnMgbXVzdCBiZSB3cml0dGVuIHRvIGEgcmVuZGVyIHRleHR1cmUgYWN0dWFsbHkgb3duZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci5yZWxlYXNlUmVuZGVyVGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gSnVzdCBjcmVhdGUgdGhlIHJlbmRlciB0ZXh0dXJlLlxuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyVGV4dHVyZUluZm8ubmF0aXZlVGV4dHVyZSA9IHRoaXMuX3RleHR1cml6ZXIuZ2V0UmVuZGVyVGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gUmVzdG9yZSB0aGUgcGFyZW50J3MgcmVuZGVyIHRleHR1cmUuXG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFJlbmRlclRleHR1cmVJbmZvKHByZXZSZW5kZXJUZXh0dXJlSW5mbyk7XG5cbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUmVzdWx0VGV4dHVyZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLmVtcHR5KSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCByZXN1bHRUZXh0dXJlID0gdGhpcy5fdGV4dHVyaXplci5nZXRSZXN1bHRUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh1cGRhdGVSZXN1bHRUZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0VGV4dHVyZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIExvZ2dpbmcgdGhlIHVwZGF0ZSBmcmFtZSBjYW4gYmUgaGFuZHkgZm9yIHVzZXJsYW5kLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdFRleHR1cmUudXBkYXRlID0gcmVuZGVyU3RhdGUuc3RhZ2UuZnJhbWVDb3VudGVyO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci51cGRhdGVSZXN1bHRUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIucmVuZGVyT2Zmc2NyZWVuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBSZW5kZXIgcmVzdWx0IHRleHR1cmUgdG8gdGhlIGFjdHVhbCByZW5kZXIgdGFyZ2V0LlxuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2hhZGVyKHRoaXMuYWN0aXZlU2hhZGVyLCB0aGlzLl9zaGFkZXJPd25lcik7XG4gICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTY2lzc29yKHRoaXMuX3NjaXNzb3IpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBJZiBubyByZW5kZXIgdGV4dHVyZSBpbmZvIGlzIHNldCwgdGhlIGNhY2hlIGNhbiBiZSByZXVzZWQuXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZSA9ICFyZW5kZXJUZXh0dXJlSW5mbyB8fCByZW5kZXJUZXh0dXJlSW5mby5jYWNoZTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0VGV4dHVyaXplcih0aGlzLl90ZXh0dXJpemVyLCBjYWNoZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGFzaFRleENvb3JkcygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLmNvbG9yaXplKSB0aGlzLl9zdGFzaENvbG9ycygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJTdGF0ZS5hZGRRdWFkKHRoaXMsI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kZXhSZXNvcnQgZmxhZ1xuICAgICAgICAgKiAtIHRoZW4sIGZpbmFsbHksIHdlIG1lcmdlLXNvcnQgYm90aCB0aGUgbmV3IGFycmF5IGFuZCB0aGUgJ29sZCcgb25lXG4gICAgICAgICAqIC0gZWxlbWVudCBtYXkgaGF2ZSBiZWVuIGFkZGVkICdkb3VibGUnLCBzbyB3aGVuIG1lcmdlLXNvcnRpbmcgYWxzbyBjaGVjayBmb3IgZG91Ymxlcy5cbiAgICAgICAgICogLSBpZiB0aGUgb2xkIG9uZSBpcyBsYXJnZXIgKGluIHNpemUpIHRoYW4gaXQgc2hvdWxkIGJlLCBzcGxpY2Ugb2ZmIHRoZSBlbmQgb2YgdGhlIGFycmF5LlxuICAgICAgICAgKi9cblxuICAgICAgICBjb25zdCBuID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgIGxldCBwdHIgPSAwO1xuICAgICAgICBjb25zdCBhID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbjtcblxuICAgICAgICAvLyBOb3RpY2UgdGhhdCBpdGVtcyBtYXkgb2NjdXIgbXVsdGlwbGUgdGltZXMgZHVlIHRvIHotaW5kZXggY2hhbmdpbmcuXG4gICAgICAgIGNvbnN0IGIgPSBbXTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGlmIChhW2ldLl96UGFyZW50ID09PSB0aGlzKSB7XG4gICAgICAgICAgICAgICAgaWYgKGFbaV0uX3pJbmRleFJlc29ydCkge1xuICAgICAgICAgICAgICAgICAgICBiLnB1c2goYVtpXSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHB0ciAhPT0gaSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgYVtwdHJdID0gYVtpXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBwdHIrKztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBtID0gYi5sZW5ndGg7XG4gICAgICAgIGlmIChtKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IG07IGorKykge1xuICAgICAgICAgICAgICAgIGJbal0uX3pJbmRleFJlc29ydCA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBiLnNvcnQoRWxlbWVudENvcmUuc29ydFpJbmRleGVkQ2hpbGRyZW4pO1xuICAgICAgICAgICAgY29uc3QgbiA9IHB0cjtcbiAgICAgICAgICAgIGlmICghbikge1xuICAgICAgICAgICAgICAgIHB0ciA9IDA7XG4gICAgICAgICAgICAgICAgbGV0IGogPSAwO1xuICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgYVtwdHIrK10gPSBiW2orK107XG4gICAgICAgICAgICAgICAgfSB3aGlsZSAoaiA8IG0pO1xuXG4gICAgICAgICAgICAgICAgaWYgKGEubGVuZ3RoID4gcHRyKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFNsaWNlIG9sZCAodW5uZWNlc3NhcnkpIHBhcnQgb2ZmIGFycmF5LlxuICAgICAgICAgICAgICAgICAgICBhLnNwbGljZShwdHIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgYS5zcGxpY2Uobik7IC8vIFJlbW92ZSBpdGVtcyB0aGF0IHdlcmUgc29ydGVkIGluIGIgYXJyYXksIHNvIHRoYXQgd2UgY2FuIHNvcnQgYVxuKyAgICAgICAgICAgICAgIC8vIEJld2FyZSB0aGF0IHRoZSBmdW5jdGlvbiBwYXNzZWQgaGVyZSB0byBBcnJheS5zb3J0IG11c3QgYmUgc3RhYmxlXG4rICAgICAgICAgICAgICAgYS5zb3J0KEVsZW1lbnRDb3JlLnNvcnRaSW5kZXhlZENoaWxkcmVuKTsgLy8gTmVlZGVkIGJlY2F1c2UgaXRlbXMgd2l0aCBzYW1lIF96SW5kZXggbWF5IG5vdCBiZSBvcmRlcmVkIGJ5IF91cGRhdGVUcmVlT3JkZXJcbiAgICAgICAgICAgICAgICAvLyBNZXJnZS1zb3J0IGFycmF5cztcbiAgICAgICAgICAgICAgICBwdHIgPSAwO1xuICAgICAgICAgICAgICAgIGxldCBpID0gMDtcbiAgICAgICAgICAgICAgICBsZXQgaiA9IDA7XG4gICAgICAgICAgICAgICAgY29uc3QgbWVyZ2VSZXN1bHQgPSBbXTtcbiAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHYgPSAoYVtpXS5fekluZGV4ID09PSBiW2pdLl96SW5kZXggPyBhW2ldLl91cGRhdGVUcmVlT3JkZXIgLSBiW2pdLl91cGRhdGVUcmVlT3JkZXIgOiBhW2ldLl96SW5kZXggLSBiW2pdLl96SW5kZXgpO1xuXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGFkZCA9IHYgPiAwID8gYltqKytdIDogYVtpKytdO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgKG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQ7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAoaSA+PSBuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWRkID0gYltqKytdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgKG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlIChqIDwgbSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChqID49IG0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZGQgPSBhW2krK107XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCAobWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKGkgPCBuKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSB3aGlsZSAodHJ1ZSk7XG5cbiAgICAgICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuID0gbWVyZ2VSZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoYS5sZW5ndGggPiBwdHIpIHtcbiAgICAgICAgICAgICAgICAvLyBTbGljZSBvbGQgKHVubmVjZXNzYXJ5KSBwYXJ0IG9mZiBhcnJheS5cbiAgICAgICAgICAgICAgICBhLnNwbGljZShwdHIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5felNvcnQgPSBmYWxzZTtcbiAgICB9O1xuXG4gICAgZ2V0IGxvY2FsVGEoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRhO1xuICAgIH07XG5cbiAgICBnZXQgbG9jYWxUYigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGI7XG4gICAgfTtcblxuICAgIGdldCBsb2NhbFRjKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbG9jYWxUYztcbiAgICB9O1xuXG4gICAgZ2V0IGxvY2FsVGQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRkO1xuICAgIH07XG5cbiAgICBnZXQgZWxlbWVudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2VsZW1lbnQ7XG4gICAgfVxuXG4gICAgZ2V0IHJlbmRlclVwZGF0ZXMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oYXNSZW5kZXJVcGRhdGVzO1xuICAgIH1cblxuICAgIGdldCB0ZXh0dXJpemVyKCkge1xuICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIgPSBuZXcgRWxlbWVudFRleHR1cml6ZXIodGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMuX3RleHR1cml6ZXI7XG4gICAgfVxuXG4gICAgZ2V0Q29ybmVyUG9pbnRzKCkge1xuICAgICAgICBsZXQgdyA9IHRoaXMuX3dvcmxkQ29udGV4dDtcblxuICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgdy5weCxcbiAgICAgICAgICAgIHcucHksXG4gICAgICAgICAgICB3LnB4ICsgdGhpcy5fdyAqIHcudGEsXG4gICAgICAgICAgICB3LnB5ICsgdGhpcy5fdyAqIHcudGMsXG4gICAgICAgICAgICB3LnB4ICsgdGhpcy5fdyAqIHcudGEgKyB0aGlzLl9oICogdy50YixcbiAgICAgICAgICAgIHcucHkgKyB0aGlzLl93ICogdy50YyArIHRoaXMuX2ggKiB3LnRkLFxuICAgICAgICAgICAgdy5weCArIHRoaXMuX2ggKiB3LnRiLFxuICAgICAgICAgICAgdy5weSArIHRoaXMuX2ggKiB3LnRkXG4gICAgICAgIF07XG4gICAgfTtcblxuICAgIGdldFJlbmRlclRleHR1cmVDb29yZHMocmVsWCwgcmVsWSkge1xuICAgICAgICBsZXQgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICAgIHJldHVybiBbXG4gICAgICAgICAgICByLnB4ICsgci50YSAqIHJlbFggKyByLnRiICogcmVsWSxcbiAgICAgICAgICAgIHIucHkgKyByLnRjICogcmVsWCArIHIudGQgKiByZWxZXG4gICAgICAgIF07XG4gICAgfVxuXG4gICAgZ2V0QWJzb2x1dGVDb29yZHMocmVsWCwgcmVsWSkge1xuICAgICAgICBsZXQgdyA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICAgIHJldHVybiBbXG4gICAgICAgICAgICB3LnB4ICsgdy50YSAqIHJlbFggKyB3LnRiICogcmVsWSxcbiAgICAgICAgICAgIHcucHkgKyB3LnRjICogcmVsWCArIHcudGQgKiByZWxZXG4gICAgICAgIF07XG4gICAgfVxuXG4gICAgY29sbGVjdEF0Q29vcmQoeCwgeSwgY2hpbGRyZW4pIHtcbiAgICAgICAgLy8gcmV0dXJuIHdoZW4gYnJhbmNoIGlzIGhpZGRlblxuICAgICAgICBpZiAodGhpcy5fcmVuZGVyQ29udGV4dC5hbHBoYSA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuaW5Cb3VuZCh4LCB5KSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3NjaXNzb3IpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5pblNjaXNzb3IoKSkge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZHJlbi5wdXNoKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY2hpbGRyZW4ucHVzaCh0aGlzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgY29uc3QgaiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgajsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0uY29sbGVjdEF0Q29vcmQoeCwgeSwgY2hpbGRyZW4pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGNoaWxkcmVuLnNvcnQoRWxlbWVudENvcmUuc29ydFpJbmRleGVkQ2hpbGRyZW4pO1xuICAgIH1cblxuICAgIGluQm91bmQodHgsIHR5KSB7XG4gICAgICAgIGNvbnN0IGMgPSB0aGlzLmdldENvcm5lclBvaW50cygpO1xuICAgICAgICByZXR1cm4gdHggPiBjWzBdICYmIHR4IDwgY1syXSAmJiB0eSA+IGNbMV0gJiYgdHkgPCBjWzddO1xuICAgIH1cblxuICAgIGluU2Npc3NvcigpIHtcbiAgICAgICAgY29uc3Qgc2MgPSB0aGlzLl9zY2lzc29yO1xuICAgICAgICBjb25zdCBjID0gdGhpcy5nZXRDb3JuZXJQb2ludHMoKTtcblxuICAgICAgICByZXR1cm4gY1syXSA+PSBzY1swXSAmJiBjWzBdIDw9IHNjWzBdICsgc2NbMl0gJiYgY1s3XSA+PSBzY1sxXSAmJiBjWzFdIDw9IHNjWzFdICsgc2NbM107XG4gICAgfVxuXG4gICAgZ2V0IGxheW91dCgpIHtcbiAgICAgICAgdGhpcy5fZW5zdXJlTGF5b3V0KCk7XG4gICAgICAgIHJldHVybiB0aGlzLl9sYXlvdXQ7XG4gICAgfVxuXG4gICAgZ2V0IGZsZXgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9sYXlvdXQgPyB0aGlzLl9sYXlvdXQuZmxleCA6IG51bGw7XG4gICAgfVxuXG4gICAgc2V0IGZsZXgodikge1xuICAgICAgICB0aGlzLmxheW91dC5mbGV4ID0gdjtc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AgICB9XG5cbiAgICB0cmlnZ2VyTGF5b3V0KCkge1xuICAgICAgICB0aGlzLl9zZXRSZWNhbGMoMjU2KTtcbiAgICB9XG5cbiAgICBfdHJpZ2dlclJlY2FsY1RyYW5zbGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fc2V0UmVjYWxjKDIpO1xuICAgIH1cblxufVxuXG5jbGFzcyBFbGVtZW50Q29yZUNvbnRleHQge1xuXG4gICAgY29uc3RydWN0b3IoKSB7XG4gICAgICAgIHRoaXMuYWxwaGEgPSAxO1xuXG4gICAgICAgIHRoaXMucHggPSAwO1xuICAgICAgICB0aGlzLnB5ID0gMDtcblxuICAgICAgICB0aGlzLnRhID0gMTtcbiAgICAgICAgdGhpcy50YiA9IDA7XG4gICAgICAgIHRoaXMudGMgPSAwO1xuICAgICAgICB0aGlzLnRkID0gMTtcbiAgICB9XG5cbiAgICBpc0lkZW50aXR5KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5hbHBoYSA9PT0gMSAmJlxuICAgICAgICAgICAgdGhpcy5weCA9PT0gMCAmJlxuICAgICAgICAgICAgdGhpcy5weSA9PT0gMCAmJlxuICAgICAgICAgICAgdGhpcy50YSA9PT0gMSAmJlxuICAgICAgICAgICAgdGhpcy50YiA9PT0gMCAmJlxuICAgICAgICAgICAgdGhpcy50YyA9PT0gMCAmJlxuICAgICAgICAgICAgdGhpcy50ZCA9PT0gMTtcbiAgICB9XG5cbiAgICBpc1NxdWFyZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudGIgPT09IDAgJiYgdGhpcy50YyA9PT0gMDtcbiAgICB9XG5cbn1cblxuRWxlbWVudENvcmVDb250ZXh0LklERU5USVRZID0gbmV3IEVsZW1lbnRDb3JlQ29udGV4dCgpO1xuRWxlbWVudENvcmUuc29ydFpJbmRleGVkQ2hpbGRyZW4gPSBmdW5jdGlvbiAoYSwgYikge1xuICAgIHJldHVybiAoYS5fekluZGV4ID09PSBiLl96SW5kZXggPyBhLl91cGRhdGV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gICAgICAgICAgICAgICAgICByZXRyaWVzTGVmdC0tXG4gICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oYFNwZWVjaCBzeW50aGVzaXMgbmV0d29yayBlcnJvci4gUmV0cmllcyBsZWZ0OiAke3JldHJpZXNMZWZ0fWApXG4gICAgICAgICAgICAgICAgICBhd2FpdCBkZWxheSg1MDAgKiAodG90YWxSZXRyaWVzIC0gcmV0cmllc0xlZnQpKVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZS5lcnJvciA9PT0gJ2NhbmNlbGVkJyB8fCBlLmVycm9yID09PSAnaW50ZXJydXB0ZWQnKSB7XG4gICAgICAgICAgICAgICAgICAvLyBDYW5jZWwgb3IgaW50ZXJydXB0IGVycm9yIChpZ25vcmUpXG4gICAgICAgICAgICAgICAgICByZXRyaWVzTGVmdCA9IDBcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBTcGVlY2hTeW50aGVzaXNFcnJvckV2ZW50OiAke2UuZXJyb3J9YClcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgZVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBwaHJhc2UgPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICBjb25zdCBzZXJpZXNSZXN1bHQgPSBzcGVha1NlcmllcyhwaHJhc2UoKSwgbGFuZywgZmFsc2UpXG4gICAgICAgICAgbmVzdGVkU2VyaWVzUmVzdWx0cy5wdXNoKHNlcmllc1Jlc3VsdClcbiAgICAgICAgICBhd2FpdCBzZXJpZXNSZXN1bHQuc2VyaWVzXG4gICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShwaHJhc2UpKSB7XG4gICAgICAgICAgLy8gU3BlYWsgaXQgKH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ICBMb2cuaW5mbygnQWQnLCAnU2VuZGluZyBiZWFjb24nLCBldmVudCwgY2FsbGJhY2tzW2V2ZW50XSlcbiAgICByZXR1cm4gY2FsbGJhY2tzW2V2ZW50XS5yZWR1Y2UoKHByb21pc2UsIHVybCkgPT4ge1xuICAgICAgcmV0dXJuIHByb21pc2UudGhlbigoKSA9PlxuICAgICAgICBmZXRjaCh1cmwpXG4gICAgICAgICAgLy8gYWx3YXlzIHJlc29sdmUsIGFsc28gaW4gY2FzZSBvZiBhIGZldGNoIGVycm9yIChzbyB3ZSBkb24ndCBibG9jayBmaXJpbmcgdGhlIHJlc3Qgb2YgdGhlIGJlYWNvbnMgZm9yIHRoaXMgZXZlbnQpXG4gICAgICAgICAgLy8gbm90ZTogZm9yIGZldGNoIGZhaWxlZCBodHRwIHJlc3BvbnNlcyBkb24ndCB0aHJvdyBhbiBFcnJvciA6KVxuICAgICAgICAgIC50aGVuKHJlc3BvbnNlID0+IHtcbiAgICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXMgPT09IDIwMCkge1xuICAgICAgICAgICAgICBmaXJlT25Db25zdW1lcignQmVhY29uJyArIGV2ZW50ICsgJ1NlbnQnKVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgZmlyZU9uQ29uc3VtZXIoJ0JlYWNvbicgKyBldmVudCArICdGYWlsZWQnICsgcmVzcG9uc2Uuc3RhdHVzKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKG51bGwpXG4gICAgICAgICAgfSlcbiAgICAgICAgICAuY2F0Y2goKCkgPT4ge1xuICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKG51bGwpXG4gICAgICAgICAgfSlcbiAgICAgIClcbiAgICB9LCBQcm9taXNlLnJlc29sdmUobnVsbCkpXG4gIH0gZWxzZSB7XG4gICAgTG9nLmluZm8oJ0FkJywgJ05vIGNhbGxiYWNrIGZvdW5kIGZvciAnICsgZXZlbnQ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hXG5cbiAgICAgICAgICBBcHBJbnN0YW5jZSA9IHRoaXMuc3RhZ2UuYyh7XG4gICAgICAgICAgICByZWY6ICdBcHAnLFxuICAgICAgICAgICAgdHlwZTogQXBwLFxuICAgICAgICAgICAgekluZGV4OiAxLFxuICAgICAgICAgICAgZm9yY2VaSW5kZXhDb250ZXh0OiAhIXBsYXRmb3JtU2V0dGluZ3Muc2hvd1ZlcnNpb24gfHwgISFwbGF0Zm9ybVNldHRpbmdzLnNob3dGcHMsXG4gICAgICAgICAgfSlcblxuICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoQXBwSW5zdGFuY2UpXG5cbiAgICAgICAgICB0aGlzLl9yZWZvY3VzKClcblxuICAgICAgICAgIExvZy5pbmZvKCdBcHAgdmVyc2lvbicsIHRoaXMuY29uZmlnLnZlcnNpb24pXG4gICAgICAgICAgTG9nLmluZm8oJ1NESyB2ZXJzaW9uJywgcGFja2FnZUluZm8udmVyc2lvbilcblxuICAgICAgICAgIGlmIChwbGF0Zm9ybVNldHRpbmdzLnNob3dWZXJzaW9uKSB7XG4gICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKHtcbiAgICAgICAgICAgICAgcmVmOiAnVmVyc2lvbkxhYmVsJyxcbiAgICAgICAgICAgICAgdHlwZTogVmVyc2lvbkxhYmVsLFxuICAgICAgICAgICAgICB2ZXJzaW9uOiB0aGlzLmNvbmZpZy52ZXJzaW9uLFxuICAgICAgICAgICAgICBzZGtWZXJzaW9uOiBwYWNrYWdlSW5mby52ZXJzaW9uLFxuICAgICAgICAgICAgICB6SW5kZXg6IDEsXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH1cblxuICAgICAgICAgIGlmIChwbGF0Zm9ybVNldHRpbmdzLnNob3dGcHMpIHtcbiAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoe1xuICAgICAgICAgICAgICByZWY6ICdGcHNDb3VudGVyJyxcbiAgICAgICAgICAgICAgdHlwZTogRnBzQ291bnRlcix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4gIHJldHVybiBnZXRBcmdiTnVtYmVyKFtyLCBnLCBiLCBjb2xvci5hICogMjU1XSlcbn1cblxuZXhwb3J0IGNvbnN0IGFyZ2JUb0hTTEEgPSBhcmdiID0+IHtcbiAgY29uc3QgY29sID0gZ2V0UmdiYUNvbXBvbmVudHMoYXJnYilcbiAgY29uc3QgciA9IGNvbC5yIC8gMjU1XG4gIGNvbnN0IGcgPSBjb2wuZyAvIDI1NVxuICBjb25zdCBiID0gY29sLmIgLyAyNTVcblxuICBjb25zdCBtYXggPSBNYXRoLm1heChyLCBnLCBiKVxuICBjb25zdCBtaW4gPSBNYXRoLm1pbihyLCBnLCBiKVxuXG4gIGxldCBoID0gMFxuICBsZXQgcyA9IDBcbiAgY29uc3QgbCA9IChtaW4gKyBtYXgpICogMC41XG4gIGlmIChsID4gMCkge1xuICAgIGNvbnN0IG1heE1pbiA9IG1heCAtIG1pblxuICAgIGlmIChtYXhNaW4gPiAwKSB7XG4gICAgICBjb25zdCByMiA9IChtYXggLSByKSAvIG1heE1pblxuICAgICAgY29uc3QgZzIgPSAobWF4IC0gZykgLyBtYXhNaW5cbiAgICAgIGNvbnN0IGIyID0gKG1heCAtIGIpIC8gbWF4TWluXG4gICAgICBpZiAobCA8IDAuNSkge1xuICAgICAgICBzID0gbWF4ICsgbWluXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzID0gMiAtIG1heCAtIG1pblxuICAgICAgfVxuXG4gICAgICBpZiAociA9PT0gbWF4ICYmIGcgPT09IG1pbikge1xuICAgICAgICBoID0gNS4wICsgYjJcbiAgICAgIH0gZWxzZSBpZiAociA9PT0gbWF4KSB7XG4gICAgICAgIGggPSAxLjAgLSBnMlxuICAgICAgfSBlbHNlIGlmIChnID09PSBtYXggJiYgYiA9PT0gbWluKSB7XG4gICAgICAgIGggPSAxLjAgKyByMlxuICAgICAgfSBlbHNlIGlmIChnID09PSBtYXgpIHtcbiAgICAgICAgaCA9IDMuMCAtIGIyXG4gICAgICB9IGVsc2U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bC52aWRlb0hlaWdodFxuICAgICAgICAgICAgICAgIGlmIChleHBlY3RlZEFzcGVjdFJhdGlvID4gcmVhbEFzcGVjdFJhdGlvKSB7XG4gICAgICAgICAgICAgICAgICB0aGlzLnZpZGVvVGV4dHVyZVZpZXcuc2NhbGVYID0gcmVhbEFzcGVjdFJhdGlvIC8gZXhwZWN0ZWRBc3BlY3RSYXRpb1xuICAgICAgICAgICAgICAgICAgdGhpcy52aWRlb1RleHR1cmVWaWV3LnNjYWxlWSA9IDFcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgdGhpcy52aWRlb1RleHR1cmVWaWV3LnNjYWxlWSA9IGV4cGVjdGVkQXNwZWN0UmF0aW8gLyByZWFsQXNwZWN0UmF0aW9cbiAgICAgICAgICAgICAgICAgIHRoaXMudmlkZW9UZXh0dXJlVmlldy5zY2FsZVggPSAxXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgTG9nLmVycm9yKCd0ZXhJbWFnZTJkIHZpZGVvJywgZSlcbiAgICAgICAgICAgICAgICB0aGlzLl9zdG9wVXBkYXRpbmdWaWRlb1RleHR1cmUoKVxuICAgICAgICAgICAgICAgIHRoaXMudmlkZW9UZXh0dXJlVmlldy52aXNpYmxlID0gZmFsc2VcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB0aGlzLnZpZGVvVGV4dHVyZS5zb3VyY2UuZm9yY2VSZW5kZXJVcGRhdGUoKVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKCF0aGlzLl91cGRhdGluZ1ZpZGVvVGV4dHVyZSkge1xuICAgICAgICBzdGFnZS5vbignZnJhbWVTdGFydCcsIHRoaXMuX3VwZGF0ZVZpZGVvVGV4dHVyZSlcbiAgICAgICAgdGhpcy5fdXBkYXRpbmdWaWRlb1RleHR1cmUgPSB0c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mdzLnN0cmVhbS5zcmMpIHtcbiAgICAgICAgLy8gVGhpcyBpcyBoZXJlIHRvIGJlIGJhY2t3YXJkcyBjb21wYXRpYmxlLCB3aWxsIGJlIHJlbW92ZWRcbiAgICAgICAgLy8gaW4gZnV0dXJlIHNkayByZWxlYXNlXG4gICAgICAgIGlmIChTZXR0aW5ncy5nZXQoJ2FwcCcsICdobHMnKSkge1xuICAgICAgICAgIGlmICghd2luZG93Lkhscykge1xuICAgICAgICAgICAgd2luZG93LkhscyA9IGNsYXNzIEhscyB7XG4gICAgICAgICAgICAgIHN0YXRpYyBpc1N1cHBvcnRlZCgpIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ2hscy1saWdodCBub3QgaW5jbHVkZWQnKVxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh3aW5kb3cuSGxzLmlzU3VwcG9ydGVkKCkpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5faGxzKSB0aGlzLl9obHMgPSBuZXcgd2luZG93Lkhscyh7IGxpdmVEdXJhdGlvbkluZmluaXR5OiB0cnVlIH0pXG4gICAgICAgICAgICB0aGlzLl9obHMubG9hZFNvdXJjZShzZXR0aW5ncy5zdHJlYW0uc3JjKVxuICAgICAgICAgICAgdGhpcy5faGxzLmF0dGFjaE1lZGlhKHRoaXMudmlkZW9FbClcbiAgICAgICAgICAgIHRoaXMudmlkZW9FbC5zdHlsZS5kaXNwbGF5ID0gJ2Jsb2NrJ1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLm9wZW4oc2V0dGluZ3Muc3RyZWFtLnNyYylcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhpcy5jbG9zZSgpXG4gICAgICB9XG4gICAgICB0aGlzLl9zdHJlYW0gPSBzZXR0aW5ncy5zdHJl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2codGhpcy5fcHJlZml4LCAuLi5hcmdzKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBpbmZvKCkge1xuICAgICAgICBmb3IgKHZhciBfbGVuMiA9IGFyZ3VtZW50cy5sZW5ndGgsIGFyZ3MgPSBuZXcgQXJyYXkoX2xlbjIpLCBfa2V5MiA9IDA7IF9rZXkyIDwgX2xlbjI7IF9rZXkyKyspIHtcbiAgICAgICAgICAgIGFyZ3NbX2tleTJdID0gYXJndW1lbnRzW19rZXkyXTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fbG9nQ2FsbGJhY2spIHtcbiAgICAgICAgICAgIHRoaXMuX2xvZ0NhbGxiYWNrKHtcbiAgICAgICAgICAgICAgICBsZXZlbDogXCJpbmZvXCIsXG4gICAgICAgICAgICAgICAgcGF5bG9hZDogYXJnc1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuZGVidWcpIHtcbiAgICAgICAgICAgIGNvbnNvbGUuaW5mbyh0aGlzLl9wcmVmaXgsIC4uLmFyZ3MpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHdhcm4oKSB7XG4gICAgICAgIGZvciAodmFyIF9sZW4zID0gYXJndW1lbnRzLmxlbmd0aCwgYXJncyA9IG5ldyBBcnJheShfbGVuMyksIF9rZXkzID0gMDsgX2tleTMgPCBfbGVuMzsgX2tleTMrKykge1xuICAgICAgICAgICAgYXJnc1tfa2V5M10gPSBhcmd1bWVudHNbX2tleTNdO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9sb2dDYWxsYmFjaykge1xuICAgICAgICAgICAgdGhpcy5fbG9nQ2FsbGJhY2soe1xuICAgICAgICAgICAgICAgIGxldmVsOiBcIndhcm5cIixcbiAgICAgICAgICAgICAgICBwYXlsb2FkOiBhcmdzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5kZWJ1Zykge1xuICAgICAgICAgICAgY29uc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gICAgICAgICAgIHRpbWVvdXQgPSBudWxsO1xuICAgICAgICAgICAgaWYgKCFpbW1lZGlhdGUpIHtcbiAgICAgICAgICAgICAgICByZXN1bHQgPSBmdW5jLmFwcGx5KGNvbnRleHQsIGFyZ3MpO1xuICAgICAgICAgICAgICAgIGNvbnRleHQgPSBhcmdzID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICB2YXIgZGVib3VuY2VkID0gZnVuY3Rpb24gZGVib3VuY2VkKCkge1xuICAgICAgICBjb250ZXh0ID0gdGhpcztcbiAgICAgICAgYXJncyA9IGFyZ3VtZW50cztcbiAgICAgICAgdGltZXN0YW1wID0gRGF0ZS5ub3coKTtcbiAgICAgICAgdmFyIGNhbGxOb3cgPSBpbW1lZGlhdGUgJiYgIXRpbWVvdXQ7XG4gICAgICAgIGlmICghdGltZW91dCkgdGltZW91dCA9IHNldFRpbWVvdXQobGF0ZXIsIHdhaXQpO1xuICAgICAgICBpZiAoY2FsbE5vdykge1xuICAgICAgICAgICAgcmVzdWx0ID0gZnVuYy5hcHBseShjb250ZXh0LCBhcmdzKTtcbiAgICAgICAgICAgIGNvbnRleHQgPSBhcmdzID0gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH07XG4gICAgZGVib3VuY2VkLmNsZWFyID0gZnVuY3Rpb24oKSB7XG4gICAgICAgIGlmICh0aW1lb3V0KSB7XG4gICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZW91dCk7XG4gICAgICAgICAgICB0aW1lb3V0ID0gbnVsbDtcbiAgICAgICAgfVxuICAgIH07XG4gICAgZGVib3VuY2VkLmZsdXNoID0gZnVuY3Rpb24oKSB7XG4gICAgICAgIGlmICh0aW1lb3V0KSB7XG4gICAgICAgICAgICByZXN1bHQgPSBmdW5jLmFwcGx5KGNvbnRleHQsIGFyZ3MpO1xuICAgICAgICAgICAgY29udGV4dCA9IGFyZ3MgPSBudWxsO1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91bmQoaCAqIHJhdGlvWCAvIHJhdGlvWSksXG4gICAgICAgICAgICBoOiBoXG4gICAgICAgIH07XG4gICAgfSBlbHNlIGlmIChyYXRpb1ggJiYgcmF0aW9ZICYmIHVwQ291bnQpIHtcbiAgICAgICAgZGltZW5zaW9ucyA9IGdldEl0ZW1SYXRpb0RpbWVuc2lvbnModGhlbWUsIHJhdGlvWCwgcmF0aW9ZLCB1cENvdW50KTtcbiAgICB9IGVsc2UgaWYgKGggJiYgdXBDb3VudCkge1xuICAgICAgICBkaW1lbnNpb25zID0ge1xuICAgICAgICAgICAgdzogTWF0aC5yb3VuZChnZXRXaWR0aEJ5VXBDb3VudCh0aGVtZSwgdXBDb3VudCkpLFxuICAgICAgICAgICAgaDogaFxuICAgICAgICB9O1xuICAgIH0gZWxzZSBpZiAoaCkge1xuICAgICAgICBkaW1lbnNpb25zID0ge1xuICAgICAgICAgICAgdzogZmFsbGJhY2tXLFxuICAgICAgICAgICAgaDogaFxuICAgICAgICB9O1xuICAgIH0gZWxzZSBpZiAodykge1xuICAgICAgICBkaW1lbnNpb25zID0ge1xuICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgIGg6IGZhbGxiYWNrSFxuICAgICAgICB9O1xuICAgIH0gZWxzZSB7XG4gICAgICAgIGRpbWVuc2lvbnMgPSB7XG4gICAgICAgICAgICB3OiBmYWxsYmFja1csXG4gICAgICAgICAgICBoOiBmYWxsYmFja0hcbiAgICAgICAgfTtcbiAgICB9XG4gICAgZGltZW5zaW9ucyA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgZGltZW5zaW9ucyksIHt9LCB7XG4gICAgICAgIHJhdGlvWDogcmF0aW9YLFxuICAgICAgICByYXRpb1k6IHJhdGlvWSxcbiAgICAgICAgdXBDb3VudDogdXBDb3VudFxuICAgIH0pO1xuICAgIHJldHVybiBkaW1lbnNpb25zO1xufVxuXG5mdW5jdGlvbiBnZXRJdGVtUmF0aW9EaW1lbnNpb25zKHR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tcbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgY29sb3IgPT09IFwic3RyaW5nXCIgJiYgL15bMC05XXs4LDEwfS9nLnRlc3QoY29sb3IpKSB7XG4gICAgICAgICAgICByZXR1cm4gcGFyc2VJbnQoY29sb3IpO1xuICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBjb2xvciA9PT0gXCJudW1iZXJcIiAmJiAvXlswLTldezgsMTB9L2cudGVzdChjb2xvci50b1N0cmluZygpKSkge1xuICAgICAgICAgICAgcmV0dXJuIGNvbG9yO1xuICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBjb2xvciA9PT0gXCJzdHJpbmdcIiAmJiBjb2xvci5pbmRleE9mKFwicmdiYVwiKSA+IC0xKSB7XG4gICAgICAgICAgICByZXR1cm4gcmdiYTJhcmdiKGNvbG9yKTtcbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgY29sb3IgPT09IFwic3RyaW5nXCIgJiYgY29sb3IuaW5kZXhPZihcInJnYlwiKSA+IC0xKSB7XG4gICAgICAgICAgICB2YXIgcmdiYSA9IFsgLi4uY29sb3IucmVwbGFjZSgvcmdiXFwofFxcKS9nLCBcIlwiKS5zcGxpdChcIixcIiksIFwiMjU1XCIgXTtcbiAgICAgICAgICAgIHJldHVybiBsbmcuU3RhZ2VVdGlscy5nZXRBcmdiTnVtYmVyKHJnYmEpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJldHVybiBudWxsO1xufVxuXG5mdW5jdGlvbiBzaW1wbGlmeUZyYWN0aW9uKF9yZWYpIHtcbiAgICB2YXIgW251bWVyYXRvciwgZGVub21pbmF0b3JdID0gX3JlZjtcbiAgICBmb3IgKHZhciBpID0gbnVtZXJhdG9yOyBpID4gMDsgaS0tKSB7XG4gICAgICAgIGlmICghKG51bWVyYXRvciAlIGkpICYmICEoZGVub21pbmF0b3IgJSBpKSkge1xuICAgICAgICAgICAgcmV0dXJuIFsgbnVtZXJhdG9yIC8gaSwgZGVub21pb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gICAgICAgICAgICAgICBiYWRnZTogYmFkZ2VbMV1cbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGljb24gJiYgaWNvblsxXSkge1xuICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRJdGVtID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGljb25bMV0sXG4gICAgICAgICAgICAgICAgICAgICAgICBpY29uOiBpY29uWzJdIHx8IGljb25bMV1cbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5ld2xpbmUpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkSXRlbSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5ld2xpbmU6IHRydWVcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRleHQgJiYgdGV4dFsxXSkge1xuICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRJdGVtID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dDogdGV4dFsxXSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlOiB0ZXh0WzJdXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnRlbnQucHVzaChmb3JtYXR0ZWRJdGVtKTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gY29udGVudDtcbn1cblxuZnVuY3Rpb24gbWF4KCkge1xuICAgIGlmICghYXJndW1lbnRzKSB7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG4gICAgdmFyIGFyZ3MgPSBBcnJheS5mcm9tKGFyZ3VtZW50cykuZmlsdGVyKChhcmcgPT4gIWlzTmFOKGFyZykgJiYgYXJnICE9IG51bGwpKTtcbiAgICBpZiAoIWFyZ3MubGVuZ3RoKS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udEVtaXR0ZXJJbnN0YW5jZTtcblxudmFyIGJhc2VUaGVtZSA9IHtcbiAgICBuYW1lOiBcIkJhc2UgTGlnaHRuaW5nIFRWXCIsXG4gICAgYWxwaGE6IHtcbiAgICAgICAgcHJpbWFyeTogMSxcbiAgICAgICAgc2Vjb25kYXJ5OiAuNyxcbiAgICAgICAgdGVydGlhcnk6IC4xLFxuICAgICAgICBpbmFjdGl2ZTogLjUsXG4gICAgICAgIGZ1bGw6IDEsXG4gICAgICAgIG5vbmU6IDAsXG4gICAgICAgIGFscGhhMTogLjEsXG4gICAgICAgIGFscGhhMjogLjMsXG4gICAgICAgIGFscGhhMzogLjUsXG4gICAgICAgIGFscGhhNDogLjcsXG4gICAgICAgIGFscGhhNTogLjlcbiAgICB9LFxuICAgIGFuaW1hdGlvbjoge1xuICAgICAgICBkdXJhdGlvbjoge1xuICAgICAgICAgICAgbm9uZTogMCxcbiAgICAgICAgICAgIHhmYXN0OiAuMSxcbiAgICAgICAgICAgIGZhc3Q6IC4yNSxcbiAgICAgICAgICAgIG5vcm1hbDogLjUsXG4gICAgICAgICAgICBzbG93OiAuNzUsXG4gICAgICAgICAgICB4c2xvdzogLjlcbiAgICAgICAgfSxcbiAgICAgICAgZGVsYXk6IHtcbiAgICAgICAgICAgIG5vbmU6IDAsXG4gICAgICAgICAgICB4ZmFzdDogLjAxLFxuICAgICAgICAgICAgZmFzdDogLjAyNSxcbiAgICAgICAgICAgIG5vcm1hbDogLjA1LFxuICAgICAgICAgICAgc2xvdzogLjA3NSxcbiAgICAgICAgICAgIHhzbG93OiAuMDlcbiAgICAgICAgfSxcbiAgICAgICAgZXhwcmVzc2l2ZToge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSxcbiAgICAgICAgZXhwcmVzc2l2ZUVudHJhbmNlOiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9LFxuICAgICAgICBleHByZXNzaXZlRXhpdDoge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSxcbiAgICAgICAgc3RhbmRhcmQ6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIHN0YW5kYXJkRW50cmFuY2U6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIHN0YW5kYXJkRXhpdDoge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSxcbiAgICAgICAgdXRpbGl0eToge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSx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xLjIsXG4gICAgICAgIGd1dHRlclg6IDIwLFxuICAgICAgICBndXR0ZXJZOiAyMCxcbiAgICAgICAgbWFyZ2luWDogMTUwLFxuICAgICAgICBtYXJnaW5ZOiAxNTAsXG4gICAgICAgIHNhZmU6IDUwLFxuICAgICAgICBzY3JlZW5XOiAxOTIwLFxuICAgICAgICBzY3JlZW5IOiAxMDgwXG4gICAgfSxcbiAgICByYWRpdXM6IHtcbiAgICAgICAgbm9uZTogMCxcbiAgICAgICAgeHM6IDIsXG4gICAgICAgIHNtOiA0LFxuICAgICAgICBtZDogOCxcbiAgICAgICAgbGc6IDE2LFxuICAgICAgICB4bDogMjRcbiAgICB9LFxuICAgIHNwYWNlcjoge1xuICAgICAgICBub25lOiAwLFxuICAgICAgICB4eHM6IDIsXG4gICAgICAgIHhzOiA0LFxuICAgICAgICBzbTogOCxcbiAgICAgICAgbWQ6IDEwLFxuICAgICAgICBsZzogMjAsXG4gICAgICAgIHhsOiAzMCxcbiAgICAgICAgeHhsOiA0MCxcbiAgICAgICAgeHh4bDogNTBcbiAgICB9LFxuICAgIHN0cm9rZToge1xuICAgICAgICBub25lOiAwLFxuICAgICAgICBzbTogMixcbiAgICAgICAgbWQ6IDQsXG4gICAgICAgIGxnOiA2LFxuICAgICAgICB4bDogOFxuICAgIH0sXG4gICAgdHlwb2dyYXBoeToge1xuICAgICAgICBkaXNwbGF5MToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDc1LFxuICAgICAgICAgICAgbGluZUhlaWdodDogODUsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGRpc3BsYXkyOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogNTAsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA2MCxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgaGVhZGxpbmUxOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMzUsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA0OCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgaGVhZGxpbmUyOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMzAsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA0MCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgaGVhZGxpbmUzOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjUsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAzNixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgYm9keTE6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyNSxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCIzMDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDQwLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBib2R5Mjoge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDIyLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjMwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMzIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGJvZHkzOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjAsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiMzAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAzMixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgYnV0dG9uMToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDI1LFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMzIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGJ1dHRvbjI6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyMCxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDMyLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBjYWxsb3V0MToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDIwLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMzIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGNhcHRpb24xOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMTUsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAyNCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgdGFnMToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDIwLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMjQsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGZvb3Rub3RlMToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDIyLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjMwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMzAsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH1cbiAgICB9XG59O1xuXG52YXIgY3VzdG9tRm9udEZhY2VzID0gW107XG5cbnZhciBmb250TG9hZGVyID0gZm9udHMgPT4ge1xuICAgIHZhciBwcm9taXNlcyA9IFtdO1xuICAgIHZhciBfbG9vcCA9IGZ1bmN0aW9uIF9sb29wKCkge1xuICAgICAgICB2YXIge2ZhbWlseTogZmFtaWx5LCBzcmM6IHNyYywgZGVzY3JpcHRvcnM6IGRlc2NyaXB0b3JzfSA9IGZvbnRzW2ldO1xuICAgICAgICB2YXIgZm9udFNyYyA9IHNyYyAmJiBBcnJheS5pc0FycmF5KHNyYykgJiYgc3JjLmxlbmd0aCA/IHNyYy5tYXAoKHVybCA9PiB1cmwuc3Vic3RyKDAsIDUpID09PSBcImxvY2FsXCIgPyB1cmwgOiBcInVybChcIi5jb25jYXQodXJsLCBcIilcIikpKS5qb2luKFwiLFwiKSA6IFwidXJsKFwiICsgc3JjICsgXCIpXCI7XG4gICAgICAgIHZhciBmb250RmFjZSA9IG5ldyBGb250RmFjZShmYW1pbHksIGZvbnRTcmMsIGRlc2N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KChpdGVtID0+IGl0ZW0ubWVzc2FnZSkpLmpvaW4oXCIsIFwiKTtcbiAgICAgICAgaWYgKGZhaWxlZCkge1xuICAgICAgICAgICAgbG9nZ2VySW5zdGFuY2UuZXJyb3IoXCJVbmFibGUgdG8gbG9hZCBmb250czogXCIuY29uY2F0KGZhaWxlZCkpO1xuICAgICAgICB9XG4gICAgfSkpO1xufTtcblxudmFyIGNsZWFudXBGb250cyA9IGZ1bmN0aW9uKCkge1xuICAgIHZhciBfcmVmMyA9IF9hc3luY1RvR2VuZXJhdG9yKChmdW5jdGlvbiooZm9udHMpIHtcbiAgICAgICAgaWYgKGRvY3VtZW50LmZvbnRzICYmIFwiZGVsZXRlXCIgaW4gZG9jdW1lbnQuZm9udHMpIHtcbiAgICAgICAgICAgIGlmICghY3VzdG9tRm9udEZhY2VzLmxlbmd0aCkgcmV0dXJuO1xuICAgICAgICAgICAgY3VzdG9tRm9udEZhY2VzID0gY3VzdG9tRm9udEZhY2VzLmZpbHRlcigoZm9udEZhY2UgPT4ge1xuICAgICAgICAgICAgICAgIGlmICghZm9udHMuZmluZCgoZm9udCA9PiBmb250LmZhbWlseSA9PT0gZm9udEZhY2UuZmFtaWx5KSkpIHtcbiAgICAgICAgICAgICAgICAgICAgbG9nZ2VySW5zdGFuY2UuaW5mbyhcIlJlbW92aW5nIGZvbnRcIiwgZm9udEZhY2UuZmFtaWx5KTtcbiAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQuZm9udHMuZGVsZXRlKGZvbnRGYWNlKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmb250RmFjZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS5pbmZvKFwiVW5hYmxlIHRvIHJlbW92ZSB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YmxvYiA9IG5ldyBCbG9iKGJ5dGVBcnJheXMsIHtcbiAgICAgICAgICAgIHR5cGU6IG1pbWVUeXBlXG4gICAgICAgIH0pO1xuICAgICAgICB2YXIgYmxvYlVSTCA9IFVSTC5jcmVhdGVPYmplY3RVUkwoYmxvYik7XG4gICAgICAgIHJldHVybiBibG9iVVJMO1xuICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgIGxvZ2dlckluc3RhbmNlLmluZm8oXCJVbmFibGUgdG8gY29udmVydCBiYXNlNjQgaW1hZ2UgdG8gVVJMXCIpO1xuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICB9XG59XG5cbmNsYXNzIFRoZW1lTWFuYWdlciB7XG4gICAgY29uc3RydWN0b3IoKSB7XG4gICAgICAgIHRoaXMuX2NhY2hlID0gbmV3IE1hcDtcbiAgICAgICAgaWYgKHR5cGVvZiB3aW5kb3cgPT09IFwidW5kZWZpbmVkXCIpIHJldHVybjtcbiAgICAgICAgaWYgKCF3aW5kb3cuTFVJKSB7XG4gICAgICAgICAgICB3aW5kb3cuTFVJID0ge307XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF3aW5kb3cuTFVJLnRoZW1lTWFuYWdlckluc3RhbmNlcykge1xuICAgICAgICAgICAgd2luZG93LkxVSS50aGVtZU1hbmFnZXJJbnN0YW5jZXMgPSBbIHtcbiAgICAgICAgICAgICAgICB0aGVtZU1hbmFnZXI6IHRoaXMsXG4gICAgICAgICAgICAgICAgZXZlbnRzOiBldmVudHNcbiAgICAgICAgICAgIH0gXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHdpbmRvdy5MVUkudGhlbWVNYW5hZ2VySW5zdGFuY2VzLnB1c2goe1xuICAgICAgICAgICAgICAgIHRoZW1lTWFuYWdlcjogdGhpcyxcbiAgICAgICAgICAgICAgICBldmVudHM6IGV2ZW50c1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3NldENhY2h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gICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHlpZWxkIGZvbnRMb2FkZXIoZm9udEFycmF5KTtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgIGxvZ2dlckluc3RhbmNlLmVycm9yKFwiVW5hYmxlIHRvIGxvYWQgZm9udDogXCIuY29uY2F0KGVycikpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSkoKTtcbiAgICB9XG4gICAgdXBkYXRlVGhlbWUodGhlbWVDb25maWcpIHtcbiAgICAgICAgdmFyIF90aGlzMyA9IHRoaXM7XG4gICAgICAgIHJldHVybiBfYXN5bmNUb0dlbmVyYXRvcigoZnVuY3Rpb24qKCkge1xuICAgICAgICAgICAgdmFyIHZhbHVlO1xuICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodGhlbWVDb25maWcpKSB7XG4gICAgICAgICAgICAgICAgdmFsdWUgPSBtZXJnZS5hbGwodGhlbWVDb25maWcpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IHRoZW1lQ29uZmlnO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGN1cnJlbnRUaGVtZSA9IHt9O1xuICAgICAgICAgICAgaWYgKF90aGlzMy5fY2FjaGUuaGFzKFwidGhlbWVcIikpIHtcbiAgICAgICAgICAgICAgICBjdXJyZW50VGhlbWUgPSBfdGhpczMuX2NhY2hlLmdldChcInRoZW1lXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX3RoaXMzLl9jbGVhckNhY2hlKCk7XG4gICAgICAgICAgICB2YXIgdGhlbWUgPSBfdGhpczMuX3Byb2Nlc3NUaGVtZS5jYWxsKF90aGlzMywgWyBjdXJyZW50VGhlbWUsIHZhbHVlIF0sIHZhbHVlLmV4dGVuc2lvbnMgfHwgY3VycmVudFRoZW1lLmV4dGVuc2lvbnMpO1xuICAgICAgICAgICAgX3RoaXMzLl9zZXRDYW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G9yaWdpbmFsVmFsdWU7XG4gICAgICAgICAgICBpZiAodmFsdWUgJiYgdHlwZW9mIHZhbHVlID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJlcGxhY2VtZW50ID0gb3JpZ2luYWxWYWx1ZTtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBrIGluIHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChPYmplY3QuaGFzT3duUHJvcGVydHkuY2FsbCh2YWx1ZSwgaykgJiYgVEhFTUVfS0VZX1JFUExBQ0VSW2tdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXBsYWNlbWVudFtrICYmIFRIRU1FX0tFWV9SRVBMQUNFUltrXV0gPSB2YWx1ZVtrXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSByZXBsYWNlbWVudFtrXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YWx1ZSA9IHJlcGxhY2VtZW50O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHtpc0ltYWdlOiBpc0ltYWdlLCBtaW1lVHlwZTogbWltZVR5cGV9ID0gY2hlY2tCYXNlNjRFbmNvZGVkSW1hZ2UodmFsdWUpO1xuICAgICAgICAgICAgaWYgKHdpbmRvdy5VUkwgJiYgdHlwZW9mIHdpbmRvdy5VUkwuY3JlYXRlT2JqZWN0VVJMID09PSBcImZ1bmN0aW9uXCIgJiYgaXNJbWFnZSkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBibG9iVVJMID0gYmFzZTY0VG9CbG9iVVJMKHZhbHVlLCBtaW1lVHlwZSk7XG4gICAgICAgICAgICAgICAgICAgIGJhc2U2NENhY2hlLnB1c2goYmxvYlVSTCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBibG9iVVJMO1xuICAgICAgICAgICAgICAgIH0gY2F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gICAgICAgaWYgKHRoZW1lVmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoZW1lVmFsdWU7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdmFyIHZhbGlkQ29sb3IgPSBnZXRWYWxpZENvbG9yKHZhbHVlKTtcbiAgICAgICAgICAgICAgICBpZiAodmFsaWRDb2xvcikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsaWRDb2xvcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgSlNPTi5wYXJzZSh0aGVtZVN0cmluZykpLCB0aGVtZUZ1bmN0aW9ucyksIHt9LCB7XG4gICAgICAgICAgICBleHRlbnNpb25zOiBleHRlbnNpb25zXG4gICAgICAgIH0pO1xuICAgIH1cbn1cblxudmFyIHRoZW1lTWFuYWdlckluc3RhbmNlID0gbmV3IFRoZW1lTWFuYWdlcjtcblxuY2xhc3MgQ29udGV4dCB7XG4gICAgZ2V0IHRoZW1lKCkge1xuICAgICAgICByZXR1cm4gdGhlbWVNYW5hZ2VySW5zdGFuY2UuZ2V0VGhlbWUoKTtcbiAgICB9XG4gICAgc2V0IHRoZW1lKHZhbHVlKSB7XG4gICAgICAgIGxvZ2dlckluc3RhbmNlLndhcm4oXCJDb250ZXh0LnRoZW1lIG11c3QgYmUgc2V0IHVzaW5nIGNvbnRleHQuc2V0VGhlbWUgb3IgY29udGV4dC51cGRhdGVUaGVtZVwiKTtcbiAgICB9XG4gICAgZ2V0IGtleU1ldHJpY3NDYWxsYm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7XG4gICAgICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmVycm9yKFwiRXJyb3IgdXBkYXRpbmcgY29tcG9uZW50XCIsIGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgICAgIHRoaXMuX3JlcXVlc3RVcGRhdGVTZXQuY2xlYXIoKTtcbiAgICB9XG4gICAgZmx1c2goKSB7XG4gICAgICAgIGlmICghdGhpcy5fdGltZW91dCkgcmV0dXJuO1xuICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5fdGltZW91dCk7XG4gICAgICAgIHRoaXMuX3J1blVwZGF0ZXNUaW1lb3V0SGFuZGxlcigpO1xuICAgIH1cbiAgICBhZGRVcGRhdGVUaGVtZShjb21wb25lbnQpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGhlbWVTZXQuYWRkKGNvbXBvbmVudCk7XG4gICAgICAgIGlmICghdGhpcy5fdGltZW91dCkge1xuICAgICAgICAgICAgdGhpcy5fdGltZW91dCA9IHNldFRpbWVvdXQodGhpcy5fcnVuVXBkYXRlc1RpbWVvdXRIYW5kbGVyLCAwKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBkZWxldGVVcGRhdGVUaGVtZShjb21wb25lbnQpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGhlbWVTZXQuZGVsZXRlKGNvbXBvbmVudCk7XG4gICAgfVxuICAgIGFkZFJlcXVlc3RVcGRhdGUoY29tcG9uZW50KSB7XG4gICAgICAgIHRoaXMuX3JlcXVlc3RVcGRhdGVTZXQuYWRkKGNvbXBvbmVudCk7XG4gICAgICAgIGlmICghdGhpcy5fdGltZW91dCkge1xuICAgICAgICAgICAgdGhpcy5fdGltZW91dCA9IHNldFRpbWVvdXQodGhpcy5fcnVuVXBkYXRlc1RpbWVvdXRIYW5kbGVyLCAwKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBkZWxldGVSZXF1ZXN0VXBkYXRlKGNvbXBvbmVudCkge1xuICAgICAgICB0aGl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tcIl9nZXRcIi5jb25jYXQoY2FwaXRhbChuYW1lKSldO1xuICAgICAgICAgICAgaWYgKGN1c3RvbUdldHRlciAmJiB0eXBlb2YgY3VzdG9tR2V0dGVyID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX19jb21wb25lbnRDb25mLCBfdGhpcyRfX2NvbXBvbmVudENvbmYyO1xuICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IGN1c3RvbUdldHRlci5jYWxsKHRoaXMsIHRoaXNba2V5XSk7XG4gICAgICAgICAgICAgICAgdGhpc1trZXldID0gdmFsdWUgfHwgKChfdGhpcyRfX2NvbXBvbmVudENvbmYgPSB0aGlzLl9fY29tcG9uZW50Q29uZmlnUHJvcHMpID09PSBudWxsIHx8IF90aGlzJF9fY29tcG9uZW50Q29uZiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX19jb21wb25lbnRDb25mW25hbWVdKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gbWVyZ2VQcm9wcygoX3RoaXMkX19jb21wb25lbnRDb25mMiA9IHRoaXMuX19jb21wb25lbnRDb25maWdQcm9wcykgPT09IG51bGwgfHwgX3RoaXMkX19jb21wb25lbnRDb25mMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX19jb21wb25lbnRDb25mMltuYW1lXSwgdmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIG1lcmdlUHJvcHMoKF90aGlzJF9fY29tcG9uZW50Q29uZjMgPSB0aGlzLl9fY29tcG9uZW50Q29uZmlnUHJvcHMpID09PSBudWxsIHx8IF90aGlzJF9fY29tcG9uZW50Q29uZjMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9fY29tcG9uZW50Q29uZjNbbmFtZV0sIHRoaXNba2V5XSk7XG4gICAgICAgIH0sXG4gICAgICAgIHNldCh2YWx1ZSkge1xuICAgICAgICAgICAgdmFyIG9sZFZhbHVlID0gdGhpc1trZXldO1xuICAgICAgICAgICAgaWYgKHZhbHVlICE9PSBvbGRWYWx1ZSkge1xuICAgICAgICAgICAgICAgIHZhciBjaGFuZ2VIYW5kbGVyID0gdGhpc1tcIl9zZXRcIi5jb25jYXQoY2FwaXRhbChuYW1lKSldO1xuICAgICAgICAgICAgICAgIGlmIChjaGFuZ2VIYW5kbGVyICYmIHR5cGVvZiBjaGFuZ2VIYW5kbGVyID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBjaGFuZ2VIYW5kbGVyLmNhbGwodGhpcywgdmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YXIgbmV3VmFsdWUgPSBrZXkgPT09IFwic3R5bGVcIiA/IGNsb25lKHRoaXNba2V5XSwgdmFsdWUpIDogdmFsdWU7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzW2tleV0gPT09IFwib2JqZWN0XCIgJiYgdGhpc1trZXldICE9PSBudWxsICYmIHRoaXNba2V5XS5zdHlsZSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgc3R5bGUgPSBjbG9uZSh0aGlzW2tleV0uc3R5bGUsIHZhbHVlLnN0eWxlIHx8IHt9KTtcbiAgICAgICAgICAgICAgICAgICAgbmV3VmFsdWUuc3R5bGUgPSBzdHlsZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpc1trZXldID0gbmV3VmFsdWU7XG4gICAgICAgICAgICAgICAgdGhpcy5xdWV1ZVJlcXVlc3RVcGRhdGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICBlbnVtZXJhYmxlOiB0cnVlXG4gICAgfTtcbn1cblxuZnVuY3Rpb24gZ2V0QWxpYXNQcm9wZXJ0eURlc2NyaXB0b3IocHJldiwgY3Vycikge1xuICAgIHZhciBkZXByZWNhdGlvbldhcm5pbmcgPSAnVGhlIHByb3BlcnR5IFwiJy5jb25jYXQocHJldiwgJ1wiIGlzIGRlcHJlY2F0ZWQgYW5kIHdpbGwgYmUgcmVtb3ZlZCBpbiBhIGZ1dHVyZSByZWxlYXNlLiBQbGVhc2UgdXNlIFwiJykuY29uY2F0KGN1cnIsICdcIiBpbnN0ZWFkLicpO1xuICAgIHJldHVybiB7XG4gICAgICAgIGdldCgpIHtcbiAgICAgICAgICAgIGNvbnNvbGUud2FybihkZXByZWNhdGlvbldhcm5pbmcpO1xuICAgICAgICAgICAgcmV0dXJuIHRoaXNbY3Vycl07XG4gICAgICAgIH0sXG4gICAgICAgIHNldCh2YWx1ZSkge1xuICAgICAgICAgICAgY29uc29sZS53YXJuKGRlcHJlY2F0aW9uV2FybmluZyk7XG4gICAgICAgICAgICB0aGlzW2N1cnJdID0gdmFsdWU7XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG5mdW5jdGlvbiB3aXRoVXBkYXRlcyhCYXNlKSB7XG4gICAgcmV0dXJuIGNsYXNzIGV4dGVuZHMgQmFzZSB7XG4gICAgICAgIHN0YXRpYyBnZXQgbmFtZSgpIHtcbiAgICAgICAgICAgIHJldHVybiBCYXNlLm5hbWU7XG4gICAgICAgIH1cbiAgICAgICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgICAgIHZhciBwcm90b3R5cGUgPSBPYmplY3QuZ2V0UHJvdG90eXBlT2YodGhpcyk7XG4gICAgICAgICAgICBpZiAoIXByb3RvdHlwZS5fd2l0aFVwZGF0ZXNJbml0aWFsaXplZCkge1xuICAgICAgICAgICAgICAgIHZhciBwcm9wcyA9IHRoaXMuY29uc3RydWN0b3IucHJvcGVydGllcyB8fCBbXTtcbiAgICAgICAgICAgICAgICBwcm9wcy5mb3JFYWNoKChuYW1lID0+IHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGtleSA9IFwiX1wiICsgbmFtZTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRlc2NyaXB0b3IgPSBnZXRQcm9wZXJ0eURlc2NyaXB0b3IkMShuYW1lLCBrZXkpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZGVzY3JpcHRvciAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkocHJvdG90eXBlLCBuYW1lLCBkZXNjcmlwdG9yKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB2YXIgYWxpYXNQcm9wcyA9IHRoaXMuY29uc3RydWN0b3IuYWxpYXNQcm9wZXJ0aWVzIHx8IFtdO1xuICAgICAgICAgICAgICAgIGFsaWFzUHJvcHMuZm9yRWFjaCgoYWxpYXMgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoYWxpYXMgJiYgdHlwZW9mIGFsaWFzLnByZXYgPT09IFwic3RyaW5nXCIgJiYgdHlwZW9mIGFsaWFzLmN1cnIgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkZXNjcmlwdG9yID0gZ2V0QWxpYXNQcm9wZXJ0eURlc2NyaXB0b3IoYWxpYXMucHJldiwgYWxpYXMuY3Vycik7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGVzY3JpcHRvciAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHByb3RvdHlwZSwgYWxpYXMucHJldiwgZGVzY3JpcHRvcik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgcHJvdG90eXBlLl93aXRoVXBkYXRlc0luaXRpYWxpemVkID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMu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AgICAgICAgICB0aGlzLnJlcXVlc3RVcGRhdGUoKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBfZGV0YWNoKCkge1xuICAgICAgICAgICAgc3VwZXIuX2RldGFjaCgpO1xuICAgICAgICAgICAgdXBkYXRlTWFuYWdlci5kZWxldGVSZXF1ZXN0VXBkYXRlKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHJlcXVlc3RVcGRhdGUoKSB7XG4gICAgICAgICAgICB2YXIgZm9yY2UgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3JlYWR5Rm9yVXBkYXRlcyB8fCBmb3JjZSkge1xuICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSB0aGlzLl91cGRhdGUoKTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc3VsdCA9PT0gXCJvYmplY3RcIiAmJiByZXN1bHQgIT09IG51bGwgJiYgcmVzdWx0LmNhdGNoKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdC5jYXRjaCgoZSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0SW5zdGFuY2UuZXJyb3IoXCJhc3luY3Jvbm91cyBfdXBkYXRlKCkgZXJyb3IgaW4gJ1wiLmNvbmNhdCh0aGlzLmNvbnN0cnVjdG9yLl9fY29tcG9uZW50TmFtZSwgXCInXCIpLCB0aGlzLCBlKTtcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBsb2dQcm9wVGFibGUoKSB7XG4gICAgICAgICAgICBjb25zb2xlLnRhYmxlKHRoaXMuX3Byb3BUYWJsZSk7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9wcm9wVGFibGUoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3Rvci5wcm9wZXJ0aWVzLnJlZHVjZSgoKGFjYywgcHJvcCkgPT4ge1xuICAgICAgICAgICAgICAgIGFjY1twcm9wXSA9IHRoaXNbcHJvcF07XG4gICAgICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgICAgIH0pLCB7fSk7XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG5mdW5jdGlvbiBnZXRQcm9wZXJ0eURlc2NyaXB0b3IocGF0aCkge1xuICAgIHJldHVybiB7XG4gICAgICAgIGdldCgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnRhZyhwYXRoKTtcbiAgICAgICAgfSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICBlbnVtZXJhYmxlOiB0cnVlXG4gICAgfTtcbn1cblxuZnVuY3Rpb24gd2l0aFRhZ3MoQmFzZSkge1xuICAgIHJldHVybiBjbGFzcyBleHRlbmRzIEJhc2Uge1xuICAgICAgICBzdGF0aWMgZ2V0IG5hbWUoKSB7XG4gICAgICAgICAgICByZXR1cm4gQmFzZS5uYW1lO1xuICAgICAgICB9XG4gICAgICAgIF9jb25zdHJ1Y3QoKSB7XG4gICAgICAgICAgICB2YXIgcHJvdG90eXBlID0gT2JqZWN0LmdldFByb3RvdHlwZU9mKHRoaXMpO1xuICAgICAgICAgICAgaWYgKCFwcm90b3R5cGUuX3dpdGhUYWdzSW5pdGlhbGl6ZWQpIHtcbiAgICAgICAgICAgICAgICB2YXIgdGFncyA9IHRoaXMuY29uc3RydWN0b3IudGFncyB8fCBbXTtcbiAgICAgICAgICAgICAgICB0YWdzLmZvckVhY2goKHRhZyA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdGFnID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIge25hbWU6IG5hbWUsIHBhdGg6IHBhdGh9ID0gdGFnO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG5hbWUgPSB0YWc7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcGF0aCA9IHRhZztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0gXCJfXCIgKyBuYW1lO1xuICAgICAgICAgICAgICAgICAgICB2YXIgZGVzY3JpcHRvciA9IGdldFByb3BlcnR5RGVzY3JpcHRvcihwYXRoKTtcbiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHByb3RvdHlwZSwga2V5LCBkZXNjcmlwdG9yKTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgcHJvdG90eXBlLl93aXRoVGFnc0luaXRpYWxpemVkID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QgJiYgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB9XG4gICAgfTtcbn1cblxuZnVuY3Rpb24gd2l0aEhhbmRsZUtleShCYXNlKSB7XG4gICAgcmV0dXJuIGNsYXNzIGV4dGVuZHMgQmFzZSB7XG4gICAgICAgIHN0YXRpYyBnZXQgbmFtZSgpIHtcbiAgICAgICAgICAgIHJldHVybiBCYXNlLm5hbWU7XG4gICAgICAgIH1cbiAgICAgICAgX2hhbmRsZUtleShrZXlFdmVudCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3Byb2Nlc3NFdmVudChrZXlFdmVudCk7XG4gICAgICAgIH1cbiAgICAgICAgX2hhbmRsZUtleVJlbGVhc2Uoa2V5RXZlbnQpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9wcm9jZXNzRXZlbnQoa2V5RXZlbnQsIFwiUmVsZWFzZVwiKTtcbiAgICAgICAgfVxuICAgICAgICBfcHJvY2Vzc0V2ZW50KGtleUV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgc3VmZml4ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBcIlwiO1xuICAgICAgICAgICAgdmFyIGtleU1hcCA9IHRoaXMuc3RhZ2UuYXBwbGljYXRpb24uX19rZXltYXAgfHwge307XG4gICAgICAgICAgICB2YXIga2V5ID0ga2V5TWFwW2tleUV2ZW50LmtleUNvZGVdO1xuICAgICAgICAgICAgaWYgKCFrZXkpIHtcbiAgICAgICAgICAgICAgICBrZXkgPSBrZXlFdmVudC5rZXk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoa2V5ICYmIHR5cGVvZiB0aGlzW1wib25cIi5jb25jYXQoa2V5KS5jb25jYXQoc3VmZml4KV0gPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgIHRoaXMuX2ludm9rZUtleVBheWxvYWRDYWxsYmFjayhrZXkgKyBzdWZmaXgpO1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzW1wib25cIi5jb25jYXQoa2V5KS5jb25jYXQoc3VmZml4KV0uY2FsbCh0aGlzLCB0aGlzLCBrZXlFdmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgX2ludm9rZUtleVBheWxvYWRDYWxsYmFjayhrZXkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLm1ldHJpY3NQYXlsb2FkICYmIHR5cGVvZiBjb250ZXh0SW5zdGFuY2Uua2V5TWV0cmljc0NhbGxiYWNrID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICBjb250ZXh0SW5zdGFuY2Uua2V5TWV0cmljc0NhbGxiYWNrKGtleSwgdGhpcy5tZXRyaWNzUGF5bG9hZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG5mdW5jdGlvbiB3aXRoTGF5b3V0KEJhc2UpIHtcbiAgICByZXR1cm4gY2xhc3MgZXh0ZW5kcyBCYXNlIHtcbiAgICAgICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QgJiYgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICAgICAgdGhpcy5fcHJldmlvdXNEaW1lbnNpb25EYXRhID0gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICBnZXQgaXRlbUxheW91dCgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9pdGVtTGF5b3V0O1xuICAgICAgICB9XG4gICAgICAgIHNldCBpdGVtTGF5b3V0KHYpIHtcbiAgICAgICAgICAgIHZhciBjb21wb25lbnROYW1lID0gdGhpcy5jb25zdHJ1Y3Rvci5fY29tcG9uZW50TmFtZSB8fCB0aGlzLmNvbnN0cnVjdG9yLm5hbWU7XG4gICAgICAgICAgICB2YXIgaXRlbUxheW91dDtcbiAgICAgICAgICAgIGlmICh2KSB7XG4gICAgICAgICAgICAgICAgaXRlbUxheW91dCA9IEpTT04ucGFyc2UoSlNPTi5zdHJpbmdpZnkodiwgKChrLCB2KSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChrICE9PSBcImNpcmNsZVwiICYmIHYgPCAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0SW5zdGFuY2UuZXJyb3IoXCJpdGVtTGF5b3V0IGZvciBcIi5jb25jYXQoY29tcG9uZW50TmFtZSwgXCIgcmVjZWl2ZWQgYW4gaW52YWxpZCB2YWx1ZSBvZiBcIikuY29uY2F0KHYsIFwiIGZvciBcIikuY29uY2F0KGspKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChrID09PSBcImNpcmNsZVwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQm9vbGVhbih2KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdjtcbiAgICAgICAgICAgICAgICB9KSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCFzdHJpbmdpZnlDb21wYXJlKHRoaXMuX2l0ZW1MYXlvdXQsIGl0ZW1MYXlvdXQpKSB7XG4gICAgICAgICAgICAgICAgaWYgKGl0ZW1MYXlvdXQgJiYgIWl0ZW1MYXlvdXQudXBDb3VudCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcmlnaW5hbFcgPSB0aGlzLnc7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX29yaWdpbmFsSCA9IHRoaXMuaDtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5faXRlbUxheW91dCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fb3JpZ2luYWxXLFxuICAgICAgICAgICAgICAgICAgICAgICAgaDogdGhpcy5fb3JpZ2luYWxIXG4gICAgICAgICAgICAgICAgICAgIH0sIGl0ZW1MYXlvdXQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2l0ZW1MYXlvdXQgPSBpdGVtTGF5b3V0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVJdGVtTGF5b3V0KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX2FsbG93VXBkYXRlKCkge1xuICAgICAgICAgICAgdmFyIHt3OiB3ID0gXCJcIiwgaDogaCA9IFwiXCIsIGNpcmNsZTogY2lyY2xlID0gXCJcIiwgcmF0aW9YOiByYXRpb1ggPSBcIlwiLCByYXRpb1k6IHJhdGlvWSA9IFwiXCIsIHVwQ291bnQ6IHVwQ291bnQgPSBcIlwifSA9IHRoaXMuX2l0ZW1MYXlvdXQgfHwge307XG4gICAgICAgICAgICB2YXIgbGF5b3V0U3RyaW5nID0gT2JqZWN0LnZhbHVlcyhjb250ZXh0SW5zdGFuY2UudGhlbWUubGF5b3V0KS5qb2luKFwiXCIpICsgXCJcIi5jb25jYXQodykuY29uY2F0KGgpLmNvbmNhdChjaXJjbGUgPyAxIDogMCkuY29uY2F0KHJhdGlvWCkuY29uY2F0KHJhdGlvWSkuY29uY2F0KHVwQ291bnQpO1xuICAgICAgICAgICAgaWYgKGxheW91dFN0cmluZyAhPT0gdGhpcy5fcHJldmlvdXNEaW1lbnNpb25EYXRhKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcHJldmlvdXNEaW1lbnNpb25EYXRhID0gbGF5b3V0U3RyaW5nO1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIF91cGRhdGVJdGVtTGF5b3V0KCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9hbGxvd1VwZGF0ZSgpKSByZXR1cm47XG4gICAgICAgICAgICB2YXIge3c6IHcsIGg6IGh9ID0gZ2V0RGltZW5zaW9ucyh0aGlzLnRoZW1lLCB0aGlzLl9pdGVtTGF5b3V0KTtcbiAgICAgICAgICAgIGlmIChoIHx8IHcpIHtcbiAgICAgICAgICAgICAgICB2YXIgd2lkdGggPSBjb250ZXh0SW5zdGFuY2UudGhlbWUubGF5b3V0LnNjcmVlblc7XG4gICAgICAgICAgICAgICAgdmFyIGhlaWdodCA9IGNvbnRleHRJbnN0YW5jZS50aGVtZS5sYXlvdXQuc2NyZWVuSDtcbiAgICAgICAgICAgICAgICB2YXIgY2FsY3VsYXRlZFdpZHRoID0gdyB8fCBoICogKHdpZHRoIC8gaGVpZ2h0KTtcbiAgICAgICAgICAgICAgICB2YXIgY2FsY3VsYXRlZEhlaWdodCA9IGggfHwgdyAqIChoZWlnaHQgLyB3aWR0aCk7XG4gICAgICAgICAgICAgICAgdGhpcy53ID0gdGhpcy5faXRlbUxheW91dCAmJiB0aGlzLl9pdGVtTGF5b3V0LmNpcmNsZSA/IGNhbGN1bGF0ZWRIZWlnaHQgOiBjYWxjdWxhdGVkV2lkdGg7XG4gICAgICAgICAgICAgICAgdGhpcy5oID0gY2FsY3VsYXRlZEhlaWdodDtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5faXRlbUxheW91dCAmJiB0aGlzLl9pdGVtTGF5b3V0LmNpcmNsZSAmJiB0aGlzLnN0eWxlLnJhZGl1cykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaXJjbGVTZXQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcmlnaW5hbFJhZGl1cyA9IHRoaXMuc3R5bGUucmFkaXVzO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnN0eWxlID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJhZGl1czogY2FsY3VsYXRlZEhlaWdodCAvIDJcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9jaXJjbGVTZXQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHlsZSA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICByYWRpdXM6IHRoaXMuX29yaWdpbmFsUmFkaXVzXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcmlnaW5hbFJhZGl1cyA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2lyY2xlU2V0ID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMucXVldWVSZXF1ZXN0VXBkYXRlICYmIHRoaXMucXVldWVSZXF1ZXN0VXBkYXRlKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKFwiJGl0ZW1DaGFuZ2VkXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbn1cblxudmFyIGdldENoYXJhY3RlclZhbHVlID0gKGNoYXIsIGluZGV4KSA9PiBjaGFyLmNoYXJDb2RlQXQoMCkgKiAoaW5kZXggKyAxKTtcblxudmFyIHNvcnRPYmplY3QgPSBvYmogPT4ge1xuICAgIHZhciBzb3J0ZWRPYmogPSB7fTtcbiAgICBPYmplY3Qua2V5cyhvYmopLnNvcnQoKS5mb3JFYWNoKChrZXkgPT4ge1xuICAgICAgICBpZiAodHlwZW9mIG9ialtrZXldID09PSBcIm9iamVjdFwiICYmIG9ialtrZXldICE9PSBudWxsICYmICFBcnJheS5pc0FycmF5KG9ialtrZXldKSkge1xuICAgICAgICAgICAgc29ydGVkT2JqW2tleV0gPSBzb3J0T2JqZWN0KG9ialtrZXldKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHNvcnRlZE9ialtrZXldID0gb2JqW2tleV07XG4gICAgICAgIH1cbiAgICB9KSk7XG4gICAgcmV0dXJuIHNvcnRlZE9iajtcbn07XG5cbnZhciBnZXRDaGFyYWN0ZXJTdW0gPSBvYmogPT4ge1xuICAgIHZhciBzb3J0ZWRPYmogPSBzb3J0T2JqZWN0KG9iaik7XG4gICAgdmFyIHN0ciA9IEpTT04uc3RyaW5naWZ5KHNvcnRlZE9iaikucmVwbGFjZSgvW3t9OlwiLFxcc10vZywgXCJcIik7XG4gICAgdmFyIHN1bSA9IDA7XG4gICAgZm9yICh2YXIgaSA9IDA7IGkgPCBzdHIubGVuZ3RoOyBpKyspIHtcbiAgIC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9pZCAwID8gdm9pZCAwIDogX29iaiR0aGVtZVtvYmouY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lXSkgfHwge307XG59O1xuXG5mdW5jdGlvbiByZW1vdmVFbXB0eU9iamVjdHMob2JqKSB7XG4gICAgZm9yICh2YXIga2V5IGluIG9iaikge1xuICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KGtleSkgJiYgaXNQbGFpbk9iamVjdChvYmpba2V5XSkpIHtcbiAgICAgICAgICAgIHJlbW92ZUVtcHR5T2JqZWN0cyhvYmpba2V5XSk7XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXMob2JqW2tleV0pLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBvYmpba2V5XTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gb2JqO1xufVxuXG5mdW5jdGlvbiBjcmVhdGVTaGFyZWRSZWZlcmVuY2VzKCkge1xuICAgIHZhciBvYmogPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9O1xuICAgIHZhciBzZWVuT2JqZWN0cyA9IG5ldyBNYXA7XG4gICAgZnVuY3Rpb24gaGFzaChvYmplY3QpIHtcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KG9iamVjdCwgT2JqZWN0LmtleXMob2JqZWN0KS5zb3J0KCkpO1xuICAgIH1cbiAgICBmdW5jdGlvbiBwcm9jZXNzKGN1cnJlbnRPYmopIHtcbiAgICAgICAgZm9yICh2YXIga2V5IGluIGN1cnJlbnRPYmopIHtcbiAgICAgICAgICAgIGlmIChjdXJyZW50T2JqLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBjdXJyZW50T2JqW2tleV07XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB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t9KTtcbiAgICByZXR1cm4gcGF5bG9hZDtcbn1cblxuZnVuY3Rpb24gZmluZE5lc3RlZEtleXMob2JqLCBrZXlUb0ZpbmQpIHtcbiAgICB2YXIgbmVzdGVkS2V5cyA9IFtdO1xuICAgIGZ1bmN0aW9uIHNlYXJjaE5lc3RlZEtleXMob2JqKSB7XG4gICAgICAgIGlmICh0eXBlb2Ygb2JqID09PSBcIm9iamVjdFwiICYmIG9iaiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgZm9yICh2YXIga2V5IGluIG9iaikge1xuICAgICAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoa2V5KSkge1xuICAgICAgICAgICAgICAgICAgICBuZXN0ZWRLZXlzLnB1c2goa2V5KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgZnVuY3Rpb24gc2VhcmNoRm9yS2V5KG9iaikge1xuICAgICAgICBpZiAodHlwZW9mIG9iaiA9PT0gXCJvYmplY3RcIiAmJiBvYmogIT09IG51bGwpIHtcbiAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBvYmopIHtcbiAgICAgICAgICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGtleSA9PT0ga2V5VG9GaW5kKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hOZXN0ZWRLZXlzKG9ialtrZXldKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHNlYXJjaEZvcktleShvYmpba2V5XSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIHNlYXJjaEZvcktleShvYmopO1xuICAgIHJldHVybiBuZXN0ZWRLZXlzO1xufVxuXG52YXIgZ2VuZXJhdGVTb2x1dGlvb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ocm93IG5ldyBFcnJvcihcIkV4cGVjdGVkIGFsaWFzIHRvIGJlIGFuIGFycmF5XCIpO1xuICAgIH1cbiAgICB2YXIgY29tcG9uZW50RGVmYXVsdCA9IHN0eWxlQ2hhaW4ubWFwKChfcmVmOCA9PiB7XG4gICAgICAgIHZhciB7c3R5bGU6IHN0eWxlfSA9IF9yZWY4O1xuICAgICAgICBpZiAodHlwZW9mIHN0eWxlID09PSBcIm9iamVjdFwiICYmICFzdHlsZS5iYXNlICYmICFzdHlsZS5tb2RlICYmICFzdHlsZS50b25lICYmICFzdHlsZS5kZWZhdWx0KSB7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIGJhc2U6IHN0eWxlXG4gICAgICAgICAgICB9O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdmFyIHtiYXNlOiBfYmFzZSA9IHt9LCBtb2RlOiBfbW9kZSA9IHt9LCB0b25lOiBfdG9uZSA9IHt9fSA9IHN0eWxlO1xuICAgICAgICAgICAgdmFyIGNvbXBvbmVudENvbmZpZ0RlZmF1bHRTdHlsZTtcbiAgICAgICAgICAgIGlmIChzdHlsZSkge1xuICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0U3R5bGUgPSBKU09OLnBhcnNlKEpTT04uc3RyaW5naWZ5KHN0eWxlKSk7XG4gICAgICAgICAgICAgICAgZGVsZXRlIGRlZmF1bHRTdHlsZS5iYXNlO1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBkZWZhdWx0U3R5bGUudG9uZTtcbiAgICAgICAgICAgICAgICBkZWxldGUgZGVmYXVsdFN0eWxlLm1vZGU7XG4gICAgICAgICAgICAgICAgY29tcG9uZW50Q29uZmlnRGVmYXVsdFN0eWxlID0gZGVmYXVsdFN0eWxlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICBkZWZhdWx0U3R5bGU6IGNvbXBvbmVudENvbmZpZ0RlZmF1bHRTd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cG9uZW50T2JqID0+IHtcbiAgICB2YXIgc3R5bGVNYXAgPSBuZXcgTWFwO1xuICAgIHZhciBwcm90bztcbiAgICBkbyB7XG4gICAgICAgIHZhciBfcHJvdG87XG4gICAgICAgIHByb3RvID0gIXByb3RvID8gY29tcG9uZW50T2JqIDogT2JqZWN0LmdldFByb3RvdHlwZU9mKHByb3RvKTtcbiAgICAgICAgaWYgKCgoX3Byb3RvID0gcHJvdG8pID09PSBudWxsIHx8IF9wcm90byA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3Byb3RvLmNvbnN0cnVjdG9yKSA9PT0gT2JqZWN0KSBicmVhaztcbiAgICAgICAgaWYgKHByb3RvICYmIHR5cGVvZiBwcm90byA9PT0gXCJvYmplY3RcIiAmJiBwcm90by5oYXNPd25Qcm9wZXJ0eShcImNvbnN0cnVjdG9yXCIpKSB7XG4gICAgICAgICAgICB2YXIge3N0eWxlOiBjb21wb25lbnRDb25maWdTdHlsZX0gPSBnZXRDb21wb25lbnRDb25maWcocHJvdG8pO1xuICAgICAgICAgICAgaWYgKE9iamVjdC5rZXlzKGNvbXBvbmVudENvbmZpZ1N0eWxlIHx8IHt9KS5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXN0eWxlTWFwLmhhcyhjb21wb25lbnRDb25maWdTdHlsZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGVNYXAuc2V0KGNvbXBvbmVudENvbmZpZ1N0eWxlLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZTogY29tcG9uZW50Q29uZmlnU3R5bGVcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHRoZW1lU3R5bGUgPSBwcm90by5jb25zdHJ1Y3Rvci5oYXNPd25Qcm9wZXJ0eShcIl9fdGhlbWVTdHlsZVwiKSAmJiBwcm90by5jb25zdHJ1Y3Rvci5fX3RoZW1lU3R5bGU7XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXModGhlbWVTdHlsZSB8fCB7fSkubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFzdHlsZU1hcC5oYXModGhlbWVTdHlsZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGVNYXAuc2V0KHRoZW1lU3R5bGUsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKHt9LCB0aGVtZVN0eWxlKVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB0aGVtZVN0eWxlID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXN0eWxlTWFwLmhhcyh0aGVtZVN0eWxlKSkge1xuICAgICAgICAgICAgICAgICAgICBzdHlsZU1hcC5zZXQodGhlbWVTdHlsZSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHRoZW1lU3R5bGVcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIG1peGluU3R5bGUgPSBwcm90by5jb25zdHJ1Y3Rvci5oYXNPd25Qcm9wZXJ0eShcIl9fbWl4aW5TdHlsZVwiKSAmJiBwcm90by5jb25zdHJ1Y3Rvci5fX21peGluU3R5bGU7XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXMobWl4aW5TdHlsZSB8fCB7fSkubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFzdHlsZU1hcC5oYXMobWl4aW5TdHlsZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGVNYXAuc2V0KG1peGluU3R5bGUsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlOiBtaXhpblN0eWxlXG4gICAgICAgICAgICAgICAgICAgIH0pO1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bmRleCA9IGlkcyAmJiBpZHMubGVuZ3RoICYmIGlkcy5pbmRleE9mKHRoaXMuY29tcG9uZW50Ll9faWQpO1xuICAgICAgICAgICAgaWYgKHJlbW92ZUluZGV4ID4gLTEgJiYgaWRzLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgICAgICBjYWNoZS5zZXQobmFtZSwge1xuICAgICAgICAgICAgICAgICAgICBpZHM6IGlkcy5zbGljZSgwLCByZW1vdmVJbmRleCkuY29uY2F0KGlkcy5zbGljZShyZW1vdmVJbmRleCArIDEpKSxcbiAgICAgICAgICAgICAgICAgICAgcGF5bG9hZDogcGF5bG9hZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChyZW1vdmVJbmRleCA+IC0xKSB7XG4gICAgICAgICAgICAgICAgY2FjaGUuZGVsZXRlKG5hbWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF9yZW1vdmVDYWNoZShuYW1lKSB7XG4gICAgICAgIGNhY2hlLmRlbGV0ZShuYW1lKTtcbiAgICB9XG4gICAgX2dldENhY2hlKG5hbWUpIHtcbiAgICAgICAgdmFyIGtleSA9IHRoaXMuX2dlbmVyYXRlQ2FjaGVLZXkobmFtZSk7XG4gICAgICAgIHJldHVybiBjYWNoZS5nZXQoa2V5KTtcbiAgICB9XG4gICAgdXBkYXRlKCkge1xuICAgICAgICBpZiAoIXRoaXMuY29tcG9uZW50KSByZXR1cm47XG4gICAgICAgIHZhciB7bW9kZTogbW9kZSwgdG9uZTogdG9uZX0gPSB0aGlzLmNvbXBvbmVudDtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHZhciBfdGhpcyRfZ2V0Q2FjaGUsIF90aGlzJF9nZXRDYWNoZTI7XG4gICAgICAgICAgICB2YXIgc3R5bGVTb3VyY2UgPSAoX3RoaXMkX2dldENhY2hlID0gdGhpcy5fZ2V0Q2FjaGUoXCJzdHlsZVNvdXJjZVw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Q2FjaGUoXCJzdHlsZV9cIi5jb25jYXQobW9kZSwgXCJfXCIpLmNvbmNhdCh0b25lKSwgc3R5bGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fc3R5bGUgPSBzdHlsZTtcbiAgICAgICAgICAgIHRoaXMuZW1pdChcInN0eWxlVXBkYXRlXCIsIHRoaXMuc3R5bGUpO1xuICAgICAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmVycm9yKFwic3R5bGVNYW5hZ2VyOiBcIiwgZXJyb3IubWVzc2FnZSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgc2V0IHN0eWxlKHYpIHtcbiAgICAgICAgY29udGV4dEluc3RhbmNlLndhcm4oXCJzdHlsZU1hbmFnZXI6IENhbm5vdCBtdXRhdGUgc3R5bGUgZGlyZWN0bHlcIik7XG4gICAgfVxuICAgIGdldCBzdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3N0eWxlO1xuICAgIH1cbiAgICBzZXQgcHJvcHModikge1xuICAgICAgICBjb250ZXh0SW5zdGFuY2Uud2FybihcInN0eWxlTWFuYWdlcjogQ2Fubm90IG11dGF0ZSBwcm9wcyBkaXJlY3RseVwiKTtcbiAgICB9XG4gICAgZ2V0IHByb3BzKCkge1xuICAgICAgICByZXR1cm4gT2JqZWN0LmtleXModGhpcy5jb21wb25lbnQuX2NvbXBvbmVudENvbmZpZykucmVkdWNlKCgoYWNjLCBrZXkpID0+IHtcbiAgICAgICAgICAgIGlmICghWyBcImJhc2VcIiwgXCJ0b25lXCIsIFwibW9kZVwiLCBcInN0eWxlXCIsIFwic3R5bGVDb25maWdcIiBdLmluY2x1ZGVzKGtleSkpIHtcbiAgICAgICAgICAgICAgICBhY2Nba2V5XSA9IHRoaXMuY29tcG9uZW50Ll9jb21wb25lbnRDb25maWdba2V5XTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBhY2M7XG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gIGlmIChPYmplY3QucHJvdG90eXBlLnRvU3RyaW5nLmNhbGwodikgIT09IFwiW29iamVjdCBPYmplY3RdXCIpIHtcbiAgICAgICAgICAgICAgICBjb250ZXh0SW5zdGFuY2UuZXJyb3IoXCJzdHlsZSBtdXN0IGJlIGFuIG9iamVjdFwiKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9jb21wb25lbnRMZXZlbFN0eWxlID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci5jbGVhclN0eWxlQ2FjaGUoKTtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci51cGRhdGUoKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgc3R5bGUoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc3R5bGU7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9jb21wb25lbnRTdHlsZSgpIHtcbiAgICAgICAgICAgIGNvbnRleHRJbnN0YW5jZS5pbmZvKFwiX2NvbXBvbmVudFN0eWxlIHdpbGwgc29vbiBiZSBkZXByZWNhdGVkLiBQbGVhc2UgdXNlIENvbXBvbmVudC5zdHlsZVwiKTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHlsZTtcbiAgICAgICAgfVxuICAgICAgICBzZXQgc3R5bGVDb25maWcodikge1xuICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmluZm8oXCJzdHlsZSBjb25maWcgaXMgZGVwcmVjYXRlZC4gUGxlYXNlIHVzZSBzdHlsZSA9IHsgYmFzZToge30sIHRvbmU6IHt9LCBtb2RlOiB7fSB9XCIpO1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVDb25maWcgPSB2O1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVNYW5hZ2VyLnVwZGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBzdHlsZUNvbmZpZygpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHlsZUNvbmZpZztcbiAgICAgICAgfVxuICAgICAgICBnZXQgX2NvbXBvbmVudENvbmZpZygpIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRDb21wb25lbnRDb25maWcodGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IG1vZGUoKSB7XG4gICAgICAgICAgICB2YXIgX3RoaXMkX2NvbXBvbmVudENvbmZpO1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21vZGUgfHwgKChfdGhpcyRfY29tcG9uZW50Q29uZmkgPSB0aGlzLl9jb21wb25lbnRDb25maWcpID09PSBudWxsIHx8IF90aGlzJF9jb21wb25lbnRDb25maSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2NvbXBvbmVudENvbmZpLm1vZGUpIHx8IFwidW5mb2N1c2VkXCI7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IG1vZGUodikge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB2ICE9PSBcInN0cmluZ1wiIHx8IHRoaXMuX21vZGUgPT09IHYpIHJldHVybjtcbiAgICAgICAgICAgIHRoaXMuX21vZGUgPSB2O1xuICAgICAgICAgICAgdmFyIGV2ZW50ID0gdGhpc1tcIm9uXCIuY29uY2F0KGNhcGl0YWxpemVGaXJzdExldHRlcih2KSldO1xuICAgICAgICAgICAgaWYgKGV2ZW50ICYmIHR5cGVvZiBldmVudCA9PT0gXCJmdW5jdGlvblwiKSBldmVudC5jYWxsKHRoaXMpO1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVNYW5hZ2VyLnVwZGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCB0b25lKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RvbmUgfHwgdGhpcy5fY29tcG9uZW50Q29uZmlnLnRvbmUgfHwgXCJuZXV0cmFsXCI7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IHRvbmUodikge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB2ICE9PSBcInN0cmluZ1wiIHx8IHRoaXMuX3RvbmUgPT09IHYpIHJldHVybjtcbiAgICAgICAgICAgIHRoaXMuX3RvbmUgPSB2O1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVNYW5hZ2VyLnVwZGF0ZSgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCB3KCkge1xuICAgICAgICAgICAgdmFyIF90aGlzJHN0eWxlO1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3dTZXRCeVVzZXIgJiYgdGhpcy5fdyB8fCAoKF90aGlzJHN0eWxlID0gdGhpcy5zdHlsZSkgPT09IG51bGwgfHwgX3RoaXMkc3R5bGUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJHN0eWxlLncpIHx8IDA7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IHcodikge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3cgPT09IHYpIHJldHVybjtcbiAgICAgICAgICAgIHN1cGVyLncgPSB2O1xuICAgICAgICAgICAgdGhpcy5fd1NldEJ5VXNlciA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVUaGVtZUNvbXBvbmVudCgpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBoKCkge1xuICAgICAgICAgICAgdmFyIF90aGlzJHN0eWxlMjtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9oU2V0QnlVc2VyICYmIHRoaXMuX2ggfHwgKChfdGhpcyRzdHlsZTIgPSB0aGlzLnN0eWxlKSA9PT0gbnVsbCB8fCBfdGhpcyRzdHlsZTIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJHN0eWxlMi5oKSB8fCB0aGlzLl9oIHx8IDA7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IGgodikge1xuICAgICAgICAgICAgaWYgKHRoaXMuX2ggPT09IHYpIHJldHVybjtcbiAgICAgICAgICAgIHN1cGVyLmggPSB2O1xuICAgICAgICAgICAgdGhpcy5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GVDaGFpbikgcmV0dXJuIHRoaXMuX19wcm90b3R5cGVDaGFpbjtcbiAgICAgICAgICAgIHZhciBwcm90b3R5cGVDaGFpbiA9IG5ldyBTZXQ7XG4gICAgICAgICAgICB2YXIgcHJvdG8gPSB0aGlzO1xuICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIHByb3RvID0gT2JqZWN0LmdldFByb3RvdHlwZU9mKHByb3RvKTtcbiAgICAgICAgICAgICAgICBpZiAobnVsbCAhPT0gcHJvdG8gJiYgdHlwZW9mIHByb3RvID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJvdG8uY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lKSBwcm90b3R5cGVDaGFpbi5hZGQocHJvdG8uY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHt9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSB3aGlsZSAocHJvdG8pO1xuICAgICAgICAgICAgdGhpcy5fX3Byb3RvdHlwZUNoYWluID0gcHJvdG90eXBlQ2hhaW47XG4gICAgICAgICAgICByZXR1cm4gcHJvdG90eXBlQ2hhaW47XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9leHRlbnNpb25zKCkge1xuICAgICAgICAgICAgdmFyIGV4dGVuc2lvbnMgPSBjb250ZXh0SW5zdGFuY2UgJiYgY29udGV4dEluc3RhbmNlLnRoZW1lICYmIGNvbnRleHRJbnN0YW5jZS50aGVtZS5leHRlbnNpb25zO1xuICAgICAgICAgICAgaWYgKCFleHRlbnNpb25zIHx8ICFBcnJheS5pc0FycmF5KGV4dGVuc2lvbnMpIHx8IEFycmF5LmlzQXJyYXkoZXh0ZW5zaW9ucykgJiYgIWV4dGVuc2lvbnMubGVuZ3RoKSByZXR1cm4gW107XG4gICAgICAgICAgICByZXR1cm4gZXh0ZW5zaW9ucy5maWx0ZXIoKF9yZWYxMSA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIHt0YXJnZXRDb21wb25lbnQ6IHRhcmdldENvbXBvbmVudCwgZXh0ZW5zaW9uOiBleHRlbnNpb259ID0gX3JlZjExO1xuICAgICAgICAgICAgICAgIHJldHVybiAodHlwZW9mIHRhcmdldENvbXBvbmVudCA9PT0gXCJzdHJpbmdcIiB8fCBBcnJheS5pc0FycmF5KHRhcmdldENvbXBvbmVudCkpICYmIHR5cGVvZiBleHRlbnNpb24gPT09IFwiZnVuY3Rpb25cIjtcbiAgICAgICAgICAgIH0pKS5zbGljZSgpLnJldmVyc2UoKSB8fCBbXTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgX2NvbXBvbmVudEV4dGVuc2lvbnMoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fZXh0ZW5zaW9ucy5maWx0ZXIoKF9yZWYxMiA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIHt0YXJnZXRDb21wb25lbnQ6IHRhcmdldENvbXBvbmVudH0gPSBfcmVmMTI7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0YXJnZXRDb21wb25lbnQgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhcmdldENvbXBvbmVudCA9PT0gdGhpcy5jb25zdHJ1Y3Rvci5fX2NvbXBvbmVudE5hbWUgfHwgdGhpcy5fcHJvdG90eXBlQ2hhaW4uaGFzKHRhcmdldENvbXBvbmVudCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KHRhcmdldENvbXBvbmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhcmdldENvbXBvbmVudC5maW5kKChwYXR0ZXJuID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXR0ZXJuLnN0YXJ0c1dpdGgoXCIvXCIpICYmIHBhdHRlcm4uZW5kc1dpdGgoXCIvXCIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIENvbXBvbmVudFJlZ0V4cCA9IG5ldyBSZWdFeHAocGF0dGVybi5zbGljZSgxLCAtMSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBBcnJheS5mcm9tKHRoaXMuX3Byb3RvdHlwZUNoYWluKS5zb21lKChuYW1lID0+IENvbXBvbmVudFJlZ0V4cC50ZXN0KG5hbWUpKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wcm90b3R5cGVDaGFpbi5oYXMocGF0dGVybik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfSkpLnJlZHVjZSgoKGFjYywgX3JlZjEzKSA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIHtleHRlbnNpb246IGV4dGVuc2lvbn0gPSBfcmVmMTM7XG4gICAgICAgICAgICAgICAgYWNjLnB1c2goZXh0ZW5zaW9uKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICAgICAgfSksIFtdKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgX2V4dGVuc2lvbkFwcGxpZWQoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fY3VycmVudENvbXBvbmVudEV4dGVuc2lvbkxlbmd0aCA9PT0gdGhpcy5fYXBwbGllZEV4dGVuc2lvbkxlbmd0aDtcbiAgICAgICAgfVxuICAgICAgICBfY29uc3RydWN0KCkge1xuICAgICAgICAgICAgdGhpcy5fYXBwbGllZEV4dGVuc2lvbkxlbmd0aCA9IDA7XG4gICAgICAgICAgICB0aGlzLl9leHRlbmRlZExpc3QgPSB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Vuc2lvbikgPT4ge1xuICAgICAgICAgICAgICAgIHZhciBleHRlbnNpb25DbGFzcyA9IG5ldyBleHRlbnNpb24oY2xhc3MgRmFrZUNsYXNzIHt9KTtcbiAgICAgICAgICAgICAgICB2YXIgaW5zdGFuY2UgPSBuZXcgZXh0ZW5zaW9uQ2xhc3M7XG4gICAgICAgICAgICAgICAgdmFyIG9yaWdpbmFsQ29tcG9uZW50RGVzY3JpcHRvcnMgPSBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyhPYmplY3QuZ2V0UHJvdG90eXBlT2YoaW5zdGFuY2UpKTtcbiAgICAgICAgICAgICAgICBPYmplY3Qua2V5cyhvcmlnaW5hbENvbXBvbmVudERlc2NyaXB0b3JzKS5mb3JFYWNoKChwcm9wID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKFsgXCJjb25zdHJ1Y3RvclwiIF0uaW5jbHVkZXMocHJvcCkpIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG9yaWdpbmFsQ29tcG9uZW50RGVzY3JpcHRvcnNbcHJvcF0uZ2V0IHx8IG9yaWdpbmFsQ29tcG9uZW50RGVzY3JpcHRvcnNbcHJvcF0uc2V0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBleHRlbmRlZFtwcm9wXSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBcImFjY2Vzc29yXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiBnZXQoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzW3Byb3AgKyBTVUZGSVhdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbiBzZXQodikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW3Byb3AgKyBTVUZGSVhdID0gdjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGV4dGVuZGVkW3Byb3BdID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogXCJtZXRob2RcIlxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZnVuY3Rpb24gdmFsdWUoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpc1twcm9wICsgU1VGRklYXSAmJiB0aGlzW3Byb3AgKyBTVUZGSVhdKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwge30pO1xuICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoYmFzZVByb3RvLCBleHRlbnNpb25PdmVycmlkZXMpO1xuICAgICAgICAgICAgT2JqZWN0LnNldFByb3RvdHlwZU9mKGJhc2VQcm90bywgdGhpcyk7XG4gICAgICAgICAgICByZXR1cm4gZXh0ZW5kZWQ7XG4gICAgICAgIH1cbiAgICAgICAgX3NldENvbXBvbmVudEFsaWFzZXMoYWxpYXNPYmopIHtcbiAgICAgICAgICAgIE9iamVjdC5rZXlzKGFsaWFzT2JqKS5mb3JFYWNoKChwcm9wID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzW3Byb3AgKyBTVUZGSVhdID0gdGhpc1twcm9wXTtcbiAgICAgICAgICAgICAgICBpZiAoYWxpYXNPYmpbcHJvcF0udHlwZSA9PT0gXCJtZXRob2RcIikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzW3Byb3BdID0gdGhpcy5fZXh0ZW5zaW9uSW5zdGFuY2VbcHJvcF07XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChhbGlhc09ialtwcm9wXS50eXBlID09PSBcImFjY2Vzc29yXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsIHByb3AsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGdldCgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZXh0ZW5zaW9uSW5zdGFuY2VbcHJvcF07XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0KHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9leHRlbnNpb25JbnN0YW5jZVtwcm9wXSA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfVxuICAgIH07XG59XG5cbmNsYXNzIEJhc2UgZXh0ZW5kcyBsbmcuQ29tcG9uZW50IHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiQmFzZVwiO1xuICAgIH1cbiAgICBfY29uc3RydWN0KCkge1xuICAgICAgICB0aGlzLmNvbnN0cnVjdG9yLl9fY29tcG9uZW50TmFtZTtcbiAgICAgICAgdGhpcy5za2lwUGxpbmtvID0gZmFsc2U7XG4gICAgICAgIHRoaXMuY2VudGVySW5QYXJlbnQgPSBmYWxzZTtcbiAgICAgICAgaWYgKCF0a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W9uKCkge1xuICAgICAgICBpZiAoaW1hZ2Uuc3JjKSB7XG4gICAgICAgICAgICByZXR1cm4gY2IoXCJJbWFnZSBsb2FkIGVycm9yXCIpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBpbWFnZS5vbmxvYWQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgc291cmNlOiBpbWFnZSxcbiAgICAgICAgICAgIHJlbmRlckluZm86IHtcbiAgICAgICAgICAgICAgICBzcmM6IHNyYyxcbiAgICAgICAgICAgICAgICBjb21wcmVzc2VkOiBmYWxzZVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGhhc0FscGhhOiB0cnVlXG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgaW1hZ2Uuc3JjID0gc3JjO1xuICAgIHJldHVybiBmdW5jdGlvbigpIHtcbiAgICAgICAgaW1hZ2Uub25lcnJvciA9IG51bGw7XG4gICAgICAgIGltYWdlLm9ubG9hZCA9IG51bGw7XG4gICAgICAgIGltYWdlLnJlbW92ZUF0dHJpYnV0ZShcInNyY1wiKTtcbiAgICB9O1xufVxuXG5jbGFzcyBDdXN0b21JbWFnZVRleHR1cmUgZXh0ZW5kcyBsbmcuVGV4dHVyZSB7XG4gICAgY29uc3RydWN0b3Ioc3RhZ2UpIHtcbiAgICAgICAgc3VwZXIoc3RhZ2UpO1xuICAgICAgICB0aGlzLl9zcmMgPSB1bmRlZmluZWQ7XG4gICAgICAgIHRoaXMuX2hhc0FscGhhID0gZmFsc2U7XG4gICAgfVxuICAgIGdldCBzcmMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zcmM7XG4gICAgfVxuICAgIHNldCBzcmModikge1xuICAgICAgICBpZiAodGhpcy5fc3JjICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9zcmMgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGdldCBoYXN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mIGZjIDw9IDkwIHx8IGZjID49IDk3ICYmIGZjIDw9IDEyMiB8fCBmYyA9PSA0NikpIHtcbiAgICAgICAgICAgICAgICBzcmMgPSB0aGlzLnN0YWdlLmdldE9wdGlvbihcInNyY0Jhc2VQYXRoXCIpICsgc3JjO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjYiA9PiB7XG4gICAgICAgICAgICB2YXIgZmlsZVR5cGUgPSBjaGVja0ZpbGVUeXBlKHNyYyk7XG4gICAgICAgICAgICBzd2l0Y2ggKGZpbGVUeXBlKSB7XG4gICAgICAgICAgICAgIGNhc2UgXCJTVkdcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlU3ZnKGNiLCB0aGlzLnN0YWdlLCBcImRhdGE6aW1hZ2Uvc3ZnK3htbCxcIi5jb25jYXQoZW5jb2RlVVJJQ29tcG9uZW50KHNyYykpLCB3LCBoKTtcblxuICAgICAgICAgICAgICBjYXNlIFwiQmxvYlwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBpbWFnZUxvYWRlcih7XG4gICAgICAgICAgICAgICAgICAgIHNyYzogc3JjXG4gICAgICAgICAgICAgICAgfSwgY2IpO1xuXG4gICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3RhZ2UucGxhdGZvcm0ubG9hZFNyY1RleHR1cmUoe1xuICAgICAgICAgICAgICAgICAgICBzcmM6IHNyYyxcbiAgICAgICAgICAgICAgICAgICAgaGFzQWxwaGE6IGhhc0FscGhhXG4gICAgICAgICAgICAgICAgfSwgY2IpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBnZXROb25EZWZhdWx0cygpIHtcbiAgICAgICAgdmFyIG9iaiA9IHN1cGVyLmdldE5vbkRlZmF1bHRzKCk7XG4gICAgICAgIGlmICh0aGlzLl9zcmMpIHtcbiAgICAgICAgICAgIG9iai5zcmMgPSB0aGl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cmVncm91bmRXaWR0aFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHJ0dDogdHJ1ZSxcbiAgICAgICAgICAgIEltYWdlOiB7fVxuICAgICAgICB9O1xuICAgIH1cbiAgICBnZXQgX3Nob3VsZEJsdXIoKSB7XG4gICAgICAgIHZhciBzaG91bGRCdXIgPSB0aGlzLl9ibHVyIHx8IHRoaXMuX2hhc0NlbnRlckltYWdlO1xuICAgICAgICB0aGlzLl9JbWFnZS5ydHQgPSBzaG91bGRCdXI7XG4gICAgICAgIHJldHVybiBzaG91bGRCdXI7XG4gICAgfVxuICAgIGdldCBfaGFzQ2VudGVySW1hZ2UoKSB7XG4gICAgICAgIHJldHVybiAtMSA8IFsgXCJjaXJjbGVcIiwgXCJzcXVhcmVcIiBdLmluZGV4T2YodGhpcy5mb3JtYXQpIHx8IFwiY29udGFpblwiID09PSB0aGlzLmZvcm1hdCAmJiAhdGhpcy5fYXNwZWN0UmF0aW9FcXVhbDtcbiAgICB9XG4gICAgc2V0IHcodikge1xuICAgICAgICBpZiAodiA9PT0gc3VwZXIudykgcmV0dXJuO1xuICAgICAgICBzdXBlci53ID0gdjtcbiAgICAgICAgdGhpcy5fY29tcG9uZW50U3JjID0gdGhpcy5fZ2VuZXJhdGVQcm9taXNlKCk7XG4gICAgfVxuICAgIGdldCB3KCkge1xuICAgICAgICByZXR1cm4gc3VwZXIudztcbiAgICB9XG4gICAgc2V0IGgodikge1xuICAgICAgICBpZiAodiA9PT0gc3VwZXIuaCkgcmV0dXJuO1xuICAgICAgICBzdXBlci5oID0gdjtcbiAgICAgICAgdGhpcy5fY29tcG9uZW50U3JjID0gdGhpcy5fZ2VuZXJhdGVQcm9taXNlKCk7XG4gICAgfVxuICAgIGdldCBoKCkge1xuICAgICAgICByZXR1cm4gc3VwZXIuaDtcbiAgICB9XG4gICAgZ2V0IF9hY3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JhY2tTcmM7XG4gICAgICAgIGlmIChzcmMgIT09IHRoaXMuZmFsbGJhY2tTcmMgJiYgdGhpcy5zcmNDYWxsYmFjayAmJiB0eXBlb2YgdGhpcy5zcmNDYWxsYmFjayA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICBzcmMgPSB0aGlzLnNyY0NhbGxiYWNrKHtcbiAgICAgICAgICAgICAgICBjbG9zZXN0QXNwZWN0UmF0aW86IHRoaXMuX2Nsb3Nlc3RTdXBwb3J0ZWRBc3BlY3RSYXRpbyxcbiAgICAgICAgICAgICAgICBhc3BlY3RSYXRpbzogdGhpcy5fYWN0dWFsQXNwZWN0UmF0aW8sXG4gICAgICAgICAgICAgICAgc3JjOiB0aGlzLnNyYyxcbiAgICAgICAgICAgICAgICB3OiB0aGlzLncsXG4gICAgICAgICAgICAgICAgaDogdGhpcy5oXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gc3JjICYmIHNyYy50aGVuID8gc3JjIDogUHJvbWlzZS5yZXNvbHZlKHNyYyk7XG4gICAgfVxuICAgIGdldCBfZ3JhZGllbnRQYXRjaCgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGFscGhhOiAhdGhpcy5fR3JhZGllbnQgJiYgdGhpcy5zaG91bGRTbW9vdGggPyAuMDAxIDogMSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgZ3JhZGllbnRDb2xvcjogZ2V0VmFsaWRDb2xvcih0aGlzLnN0eWxlLmdyYWRpZW50Q29sb3IpXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgaDogdGhpcy5oICsgNCxcbiAgICAgICAgICAgIHR5cGU6IEdyYWRpZW50LFxuICAgICAgICAgICAgdzogdGhpcy53ICsgNCxcbiAgICAgICAgICAgIHg6IC0yLFxuICAgICAgICAgICAgeTogLTIsXG4gICAgICAgICAgICB6SW5kZXg6IHRoaXMuY29yZS5maW5kWkNvbnRleHQoKS56SW5kZXggKyB0aGlzLnN0eWxlLnpJbmRleFNldC5ncmFkaWVudFxuICAgICAgICB9O1xuICAgIH1cbiAgICBfY29uc3RydWN0KCkge1xuICAgICAgICBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgIHRoaXMuX3NyY0NhbGxiYWNrQXNwZWN0UmF0aW9zID0gWyBcIjE2eDlcIiwgXCIzeDRcIiwgXCI0eDNcIiwgXCIyeDFcIiwgXCIxeDFcIiBdO1xuICAgIH1cbiAgICBfc2V0U3JjKHYpIHtcbiAgICAgICAgdGhpcy5fY29tcG9uZW50U3JjID0gdGhpcy5fZ2VuZXJhdGVQcm9taXNlKCk7XG4gICAgICAgIHJldHVybiB2O1xuICAgIH1cbiAgICBfZ2V0RmFsbGJhY2tTcmMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mYWxsYmFja1NyYyB8fCB0aGlzLnN0eWxlICYmIHRoaXMuc3R5bGUuZmFsbGJhY2tTcmM7XG4gICAgfVxuICAgIF9nZW5lcmF0ZVByb21pc2UoKSB7XG4gICAgICAgIHZhciByZXNvbHZlUHJvbWlzZSwgcmVqZWN0UHJvbWlzZTtcbiAgICAgICAgdmFyIGNvbXBsZXRlID0gbmV3IFByb21pc2UoKGZ1bmN0aW9uKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICAgICAgcmVzb2x2ZVByb21pc2UgPSByZXNvbHZlO1xuICAgICAgICAgICAgcmVqZWN0UHJvbWlzZSA9IHJlamVjdDtcbiAgICAgICAgfSkpO1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgY29tcGxldGU6IGNvbXBsZXRlLFxuICAgICAgICAgICAgcmVzb2x2ZTogcmVzb2x2ZVByb21pc2UsXG4gICAgICAgICAgICByZWplY3Q6IHJlamVjdFByb21pc2VcbiAgICAgICAgfTtcbiAgICB9XG4gICAgX3NldHVwKCkge1xuICAgICAgICB0aGlzLmFscGhhID0gLjAwMTtcbiAgICAgICAgdGhpcy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GlvbiooKSB7XG4gICAgICAgICAgICBfdGhpczUuX3VwZGF0ZVJhZGl1cygpO1xuICAgICAgICAgICAgX3RoaXM1Ll91cGRhdGVHcmFkaWVudCgpO1xuICAgICAgICAgICAgeWllbGQgX3RoaXM1Ll91cGRhdGVJbWFnZSgpO1xuICAgICAgICAgICAgX3RoaXM1Ll91cGRhdGVGaWxsQ29sb3IoKTtcbiAgICAgICAgICAgIF90aGlzNS5fdXBkYXRlRm9yZWdyb3VuZEltYWdlKCk7XG4gICAgICAgICAgICBpZiAoIV90aGlzNS5zcmMpIHtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3Nob3dDb21wb25lbnQoKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHlpZWxkIF90aGlzNS5fY29tcG9uZW50U3JjLmNvbXBsZXRlO1xuICAgICAgICAgICAgICAgIHlpZWxkIF90aGlzNS5fdXBkYXRlQ2VudGVySW1hZ2UoKTtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3VwZGF0ZUJsdXIoKTtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3Nob3dDb21wb25lbnQoKTtcbiAgICAgICAgICAgICAgICBfdGhpczUuX3VwZGF0ZVNjYWxlKCk7XG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgX3RoaXM1Ll9oYW5kbGVJbWFnZUxvYWRFcnJvcigpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKF90aGlzNS5zaG91bGRTbW9vdGggPT09IHVuZGVmaW5lZCkgX3RoaXM1LnNob3VsZFNtb290aCA9IHRydWU7XG4gICAgICAgIH0pKSgpO1xuICAgIH1cbiAgICBfdXBkYXRlU2NhbGUoKSB7XG4gICAgICAgIGlmICh0aGlzLnNob3VsZFNjYWxlKSB7XG4gICAgICAgICAgICB2YXIgaW1hZ2VTY2FsZTtcbiAgICAgICAgICA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biAgICBfaGFuZGxlSW1hZ2VMb2FkRXJyb3IoKSB7XG4gICAgICAgIGlmICh0aGlzLnNyYyA9PT0gdGhpcy5mYWxsYmFja1NyYykgcmV0dXJuO1xuICAgICAgICBjb250ZXh0SW5zdGFuY2UuZXJyb3IoXCJJbWFnZSBcIi5jb25jYXQodGhpcy5fc3JjLCBcIiBmYWlsZWQgdG8gbG9hZFwiKSk7XG4gICAgICAgIGlmICh0aGlzLmZhbGxiYWNrU3JjICYmIHRoaXMuZmFsbGJhY2tTcmMgIT09IHRoaXMuc3JjKSB7XG4gICAgICAgICAgICB0aGlzLnNyYyA9IHRoaXMuZmFsbGJhY2tTcmM7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3Nob3dDb21wb25lbnQoKSB7XG4gICAgICAgIHRoaXMuc21vb3RoID0ge1xuICAgICAgICAgICAgYWxwaGE6IFsgMSwgdGhpcy5zdHlsZS5hbmltYXRpb25Db21wb25lbnRFbnRyYW5jZSBdXG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVGb3JlZ3JvdW5kSW1hZ2UoKSB7XG4gICAgICAgIHZhciBfdGhpczYgPSB0aGlzO1xuICAgICAgICByZXR1cm4gX2FzeW5jVG9HZW5lcmF0b3IoKGZ1bmN0aW9uKigpIHtcbiAgICAgICAgICAgIGlmICghX3RoaXM2Ll9mb3JlZ3JvdW5kU3JjKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzNi5fRm9yZWdyb3VuZEltYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzNi5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBGb3JlZ3JvdW5kSW1hZ2U6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGZvcmVncm91bmRJbWFnZVBhdGNoID0ge1xuICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICB4OiBfdGhpczYudyAvIDIsXG4gICAgICAgICAgICAgICAgeTogX3RoaXM2LmggLyAyLFxuICAgICAgICAgICAgICAgIHpJbmRleDogX3RoaXM2LmNvcmUuZmluZFpDb250ZXh0KCkuekluZGV4ICsgX3RoaXM2LnN0eWxlLnpJbmRleFNldC5mb3JlZ3JvdW5kLFxuICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQ3VzdG9tSW1hZ2VUZXh0dXJlLFxuICAgICAgICAgICAgICAgICAgICBzcmM6IF90aGlzNi5fZm9yZWdyb3VuZFNyYyxcbiAgICAgICAgICAgICAgICAgICAgaGFzQWxwaGE6IHRydWVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKF90aGlzNi5mb3JlZ3JvdW5kV2lkdGggJiYgX3RoaXM2LmZvcmVncm91bmRIZWlnaHQpIHtcbiAgICAgICAgICAgICAgICBmb3JlZ3JvdW5kSW1hZ2VQYXRjaC5oID0gX3RoaXM2LmZvcmVncm91bmRIZWlnaHQ7XG4gICAgICAgICAgICAgICAgZm9yZWdyb3VuZEltYWdlUGF0Y2gudyA9IF90aGlzNi5mb3JlZ3JvdW5kV2lkdGg7XG4gICAgICAgICAgICAgICAgX3RoaXM2LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgRm9yZWdyb3VuZEltYWdlOiBmb3JlZ3JvdW5kSW1hZ2VQYXRjaFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChfdGhpczYuZm9yZWdyb3VuZFdpZHRoIHx8IF90aGlzNi5mb3JlZ3JvdW5kSGVpZ2h0KSB7XG4gICAgICAgICAgICAgICAgX3RoaXM2LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgRm9yZWdyb3VuZEltYWdlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGZvcmVncm91bmRJbWFnZVBhdGNoKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFscGhhOiAuMDAxXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgX3RoaXM2Ll9Gb3JlZ3JvdW5kSW1hZ2Uub25jZShcInR4TG9hZGVkXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbWFnZVcgPSBfdGhpczYuX0ZvcmVncm91bmRJbWFnZS50ZXh0dXJlLmdldFJlbmRlcldpZHRoKCk7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbWFnZUggPSBfdGhpczYuX0ZvcmVncm91bmRJbWFnZS50ZXh0dXJlLmdldFJlbmRlckhlaWdodCgpO1xuICAgICAgICAgICAgICAgICAgICBfdGhpczYuX0ZvcmVncm91bmRJbWFnZS5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogMSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHc6IF90aGlzNi5mb3JlZ3JvdW5kSGVpZ2h0ID8gX3RoaXM2LmZvcmVncm91bmRIZWlnaHQgKiAoaW1hZ2VXIC8gaW1hZ2VIKSA6IF90aGlzNi5mb3JlZ3JvdW5kV2lkdGgsXG4gICAgICAgICAgICAgICAgICAgICAgICBoOiBfdGhpczYuZm9yZWdyb3VuZFdpZHRoID8gX3RoaXM2LmZvcmVncm91bmRXaWR0aCAqIChpbWFnZUggLyBpbWFnZVcpIDogX3RoaXM2LmZvcmVncm91bmRIZWlnaHRcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX3RoaXM2LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBGb3JlZ3JvdW5kSW1hZ2U6IGZvcmVncm91bmRJbWFnZVBhdGNoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSkpKCk7XG4gICAgfVxuICAgIF91cGRhdGVCbHVyKCkge1xuICAgICAgICBpZiAoKCF0aGlzLl9zaG91bGRCbHVyIHx8IHRoaXMuX0ltYWdlICYmIHRoaXMuX0ltYWdlLnRleHR1cmUgJiYgdGhpcy5fSW1hZ2UudGV4dHVyZS5zcmMgPT09IHRoaXMuZmFsbGJhY2tTcmMpICYmIHRoaXMuX0JsdXIpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnNob3VsZFNtb290aCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX0JsdXIuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgQmx1cjogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9CbHVyLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IFsgMCwgdGhpcy5zdHlsZS5hbmltYXRpb25CbHVyRXhpdCBdXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIEJsdXI6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fc3JjRmFpbGVkICYmIHRoaXMuX3Nob3VsZEJsdXIpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIEJsdXI6IHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6ICF0aGlzLl9CbHVyICYmIHRoaXMuc2hvdWxkU21vb3RoID8gLjAwMSA6IDEsXG4gICAgICAgICAgICAgICAgICAgIGFtb3VudDogdGhpcy5zdHlsZS5ibHVyLFxuICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IHRoaXMuY29yZS5maW5kWkNvbnRleHQoKS56SW5kZXggKyB0aGlzLnN0eWxlLnpJbmRleFNldC5ibHVyLFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBJbWFnZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0dXJlOiB0aGlzLl9JbWFnZS5nZXRUZXh0dXJlKCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdzogdGhpcy53XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICAgICAgcnR0OiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBsbmcuY29tcG9uZW50cy5GYXN0Qmx1ckNvbXBvbmVudCxcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy53XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAodGhpcy5fQmx1ci5hbHBoYSA8IDEpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9CbHVyLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IFsgMSwgdGhpcy5zdHlsZS5hbmltYXRpb25CbHVyRW50cmFuY2UgXVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUNlbnRlckltYWdlKCkge1xuICAgICAgICBpZiAodGhpcy5mb3JtYXQgPT09IFwiY29udGFpblwiKSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVGb3JtYXRDb250YWluKCk7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5mb3JtYXQgPT09IFwiY2lyY2xlXCIgfHwgdGhpcy5mb3JtYXQgPT09IFwic3F1YXJlXCIpIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUZvcm1hdFNxdWFyZUNpcmNsZSgpO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX0NlbnRlckltYWdlKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBDZW50ZXJJbWFnZTogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlRm9ybWF0Q29udGFpbigpIHtcbiAgICAgICAgdmFyIF90aGlzNyA9IHRoaXM7XG4gICAgICAgIHJldHVybiBfYXN5bmNUb0dlbmVyYXRvcigoZnVuY3Rpb24qKCkge1xuICAgICAgICAgICAgaWYgKF90aGlzNy5fQ2VudGVySW1hZ2UgJiYgX3RoaXM3Ll9DZW50ZXJJbWFnZS5tb2RlICE9PSBfdGhpczcuZm9ybWF0IHx8IF90aGlzNy5zcmMgPT09IF90aGlzNy5mYWxsYmFja1NyYyB8fCBfdGhpczcuX2FzcGVjdFJhdGlvRXF1YWwpIHtcbiAgICAgICAgICAgICAgICBfdGhpczcucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBDZW50ZXJJbWFnZTogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzNy5zcmMgPT09IF90aGlzNy5mYWxsYmFja1NyYyB8fCBfdGhpczcuX2FzcGVjdFJhdGlvRXF1YWwpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXM3Ll9JbWFnZS5hbHBoYSA9IDE7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgaW1hZ2VXO1xuICAgICAgICAgICAgdmFyIGltYWdlSDtcbiAgICAgICAgICAgIHZhciByYXRpb1cgPSBNYXRoLmFicyhfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLncgLyBfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLmgpO1xuICAgICAgICAgICAgdmFyIHJhdGlvSCA9IE1hdGguYWJzKF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UuaCAvIF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2Uudyk7XG4gICAgICAgICAgICBpZiAoX3RoaXM3Ll9JbWFnZS50ZXh0dXJlLnNvdXJjZS53IDwgX3RoaXM3Ll9JbWFnZS50ZXh0dXJlLnNvdXJjZS5oKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzNy5oICogcmF0aW9XIDwgX3RoaXM3LncpIHtcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2VXID0gX3RoaXM3LmggKiByYXRpb1c7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlSCA9IF90aGlzNy5oO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlVyA9IF90aGlzNy53O1xuICAgICAgICAgICAgICAgICAgICBpbWFnZUggPSBfdGhpczcudyAqIHJhdGlvSDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UudyA+IF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UuaCkge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpczcudyAqIHJhdGlvSCA8IF90aGlzNy5oKSB7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlVyA9IF90aGlzNy53O1xuICAgICAgICAgICAgICAgICAgICBpbWFnZUggPSBfdGhpczcudyAqIHJhdGlvSDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpbWFnZVcgPSBfdGhpczcuaCAqIHJhdGlvVztcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2VIID0gX3RoaXM3Lmg7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpbWFnZVcgPSBNYXRoLm1pbihfdGhpczcudywgX3RoaXM3LmgpO1xuICAgICAgICAgICAgICAgIGltYWdlSCA9IGltYWdlVztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBzcmMgPSB5aWVsZCBfdGhpczcuX3Byb2Nlc3NlZEltYWdlU3JjO1xuICAgICAgICAgICAgX3RoaXM3LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBDZW50ZXJJbWFnZToge1xuICAgICAgICAgICAgICAgICAgICBmb3JtYXQ6IF90aGlzNy5mb3JtYXQsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICAgICAgdzogaW1hZ2VXLFxuICAgICAgICAgICAgICAgICAgICBoOiBpbWFnZUgsXG4gICAgICAgICAgICAgICAgICAgIHg6IF90aGlzNy53IC8gMixcbiAgICAgICAgICAgICAgICAgICAgeTogX3RoaXM3LmggLyAyLFxuICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IF90aGlzNy5jb3JlLmZpbmRaQ29udGV4dCgpLnpJbmRleCArIF90aGlzNy5zdHlsZS56SW5kZXhTZXQuY2VudGVySW1hZ2UsXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNyYzogc3JjLFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzaXplTW9kZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IGltYWdlSCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBcImNvdmVyXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdzogaW1hZ2VXXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogQ3VzdG9tSW1hZ2VUZXh0dXJlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSkpKCk7XG4gICAgfVxuICAgIF91cGRhdGVGb3JtYXRTcXVhcmVDaXJjbGUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9DZW50ZXJJbWFnZSAmJiB0aGlzLl9DZW50ZXJJbWFnZS5tb2RlICE9PSB0aGlzLmZvcm1hdCB8fCB0aGlzLnNyYyA9PT0gdGhpcy5mYWxsYmFja1NyYykge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgQ2VudGVySW1hZ2U6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAodGhpcy5zcmMgPT09IHRoaXMuZmFsbGJhY2tTcmMpIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaW1hZ2VTaXplID0gTWF0aC5taW4odGhpcy53LCB0aGlzLmgpIC0gdGhpcy5zdHlsZS5wYWRkaW5nICogMjtcbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBDZW50ZXJJbWFnZToge1xuICAgICAgICAgICAgICAgIGZvcm1hdDogdGhpcy5mb3JtYXQsXG4gICAgICAgICAgICAgICAgaDogaW1hZ2VTaXplLFxuICAgICAgICAgICAgICAgIHNoYWRlcjoge1xuICAgICAgICAgICAgICAgICAgICByYWRpdXM6IFwiY2lyY2xlXCIgPT09IHRoaXMuZm9ybWF0ID8gaW1hZ2VTaXplIC8gMiA6IHRoaXMuc3R5bGUuY2VudGVySW1hZ2VSYWRpdXMsXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IGxuZy5zaGFkZXJzLlJvdW5kZWRSZWN0YW5nbGVcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHc6IGltYWdlU2l6ZSxcbiAgICAgICAgICAgICAgICB6SW5kZXg6IHRoaXMuY29yZS5maW5kWkNvbnRleHQoKS56SW5kZXggKyB0aGlzLnN0eWxlLnpJbmRleFNldC5jZW50ZXJJbWFnZSxcbiAgICAgICAgICAgICAgICBJbWFnZToge1xuICAgICAgICAgICAgICAgICAgICBoOiBpbWFnZVNpemUsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICAgICAgcnR0OiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3OiBpbWFnZVNpemUsXG4gICAgICAgICAgICAgICAgICAgIHg6IHRoaXMudyAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHk6IHRoaXMuaCAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNyYzogdGhpcy5fSW1hZ2UudGV4dHVyZS5zcmMsXG4gICAgICAgICAgICAgICAgICAgICAgICByZXNpemVNb2RlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaDogaW1hZ2VTaXplLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFwiY292ZXJcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3OiBpbWFnZVNpemVcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDdXN0b21JbWFnZVRleHR1cmVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVHcmFkaWVudCgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmdyYWRpZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fR3JhZGllbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zaG91bGRTbW9vdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fR3JhZGllbnQuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHJhbnNpdGlvbiA9IHRoaXMuX0dyYWRpZW50ICYmIHRoaXMuX0dyYWRpZW50Ll9nZXRUcmFuc2l0aW9uKFwiYWxwaGFcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhZGllbnQgJiYgdHJhbnNpdGlvbiAmJiB0cmFuc2l0aW9uLnAgPT09IDEpIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdyYWRpZW50OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX0dyYWRpZW50LnBhdGNoKHRoaXMuX2dyYWRpZW50UGF0Y2gpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9HcmFkaWVudC5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogWyAwLCB0aGlzLnN0eWxlLmFuaW1hdGlvbkdyYWRpZW50RXhpdCBdXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBHcmFkaWVudDogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9jcmVhdGVHcmFkaWVudCgpO1xuICAgIH1cbiAgICBfY3JlYXRlR3JhZGllbnQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgR3JhZGllbnQ6IHRoaXMuX2dyYWRpZW50UGF0Y2hcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh0aGlzLnNob3VsZFNtb290aCkge1xuICAgICAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9HcmFkaWVudCwge1xuICAgICAgICAgICAgICAgIGFscGhhOiBbIDEsIHRoaXMuc3R5bGUuYW5pbWF0aW9uR3JhZGllbnRFbnRyYW5jZSBdXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlSW1hZ2UoKSB7XG4gICAgICAgIHZhciBfdGhpczggPSB0aGlzO1xuICAgICAgICByZXR1cm4gX2FzeW5jVG9HZW5lcmF0b3IoKGZ1bmN0aW9uKigpIHtcbiAgICAgICAgICAgIF90aGlzOC5fYXNwZWN0UmF0aW9FcXVhbCA9IGZhbHNlO1xuICAgICAgICAgICAgaWYgKCFfdGhpczguX3Byb2Nlc3NlZEltYWdlU3JjKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzOC5fSW1hZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXM4Ll9JbWFnZS50ZXh0dXJlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgc3JjID0geWllbGQgX3RoaXM4Ll9wcm9jZXNzZWRJbWFnZVNyYztcbiAgICAgICAgICAgIF90aGlzOC5fSW1hZ2UucGF0Y2goe1xuICAgICAgICAgICAgICAgIGFscGhhOiBfdGhpczguc3JjICE9PSBfdGhpczguZmFsbGJhY2tTcmMgJiYgKF90aGlzOC5fYmx1ciB8fCBfdGhpczguX2hhc0NlbnRlckltYWdlKSA/IC4wMDEgOiAxLFxuICAgICAgICAgICAgICAgIGg6IF90aGlzOC5oLFxuICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQ3VzdG9tSW1hZ2VUZXh0dXJlLFxuICAgICAgICAgICAgICAgICAgICBzcmM6IHNyYyxcbiAgICAgICAgICAgICAgICAgICAgcmVzaXplTW9kZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogXCJjb3ZlclwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgdzogX3RoaXM4LncsXG4gICAgICAgICAgICAgICAgICAgICAgICBoOiBfdGhpczguaFxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB3OiBfdGhpczgudyxcbiAgICAgICAgICAgICAgICB6SW5kZXg6IF90aGlzOC5jb3JlLmZpbmRaQ29udGV4dCgpLnpJbmRleCArIF90aGlzOC5zdHlsZS56SW5kZXhTZXQuaW1hZ2VcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KSkoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUZpbGxDb2xvcigpIHtcbiAgICAgICAgaWYgKCF0aGlzLmZpbGwpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIEZpbGxDb2xvcjogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIEZpbGxDb2xvcjoge1xuICAgICAgICAgICAgICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLncsXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuZmlsbENvbG9yLFxuICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IDVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlUmFkaXVzKCkge1xu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GUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgbW91bnRZOiAuNVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIEljb246IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBpdGVtQ2hhbmdlZDogXCJfdXBkYXRlTGF5b3V0XCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJCYWRnZVwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRQO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwidGl0bGVcIiwgXCJpY29uXCIsIFwiaWNvbkFsaWduXCIsIFwiaWNvbldpZHRoXCIsIFwiaWNvbkhlaWdodFwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJCYWNrZ3JvdW5kXCIsIFwiVGV4dFwiLCBcIkljb25cIiBdO1xuICAgIH1cbiAgICBfaW5pdCgpIHtcbiAgICAgICAgdGhpcy5fVGV4dC5vbihcInR4TG9hZGVkXCIsIHRoaXMuX3VwZGF0ZUxheW91dC5iaW5kKHRoaXMpKTtcbiAgICAgICAgc3VwZXIuX2luaXQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGV4dCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVJY29uKCk7XG4gICAgICAgIHRoaXMuX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plY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dDogdGhpcy50aXRsZSB8fCBcIlwiXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVJY29uKCkge1xuICAgICAgICB0aGlzLl9JY29uLnBhdGNoKHtcbiAgICAgICAgICAgIGljb246IHRoaXMuaWNvbixcbiAgICAgICAgICAgIHc6IHRoaXMuaWNvbldpZHRoLFxuICAgICAgICAgICAgaDogdGhpcy5pY29uSGVpZ2h0LFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb2xvcjogZ2V0SGV4Q29sb3IodGhpcy5zdHlsZS5pY29uQ29sb3IpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlV2lkdGgoKSB7XG4gICAgICAgIHZhciB3aWR0aCA9IDA7XG4gICAgICAgIGlmICh0aGlzLnRpdGxlICYmIHRoaXMuaWNvbikge1xuICAgICAgICAgICAgd2lkdGggPSB0aGlzLl9UZXh0LnJlbmRlcldpZHRoICsgdGhpcy5fSWNvbi5maW5hbFcgKyB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nICsgdGhpcy5zdHlsZS5wYWRkaW5nWCAqIDI7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy50aXRsZSkge1xuICAgICAgICAgICAgd2lkdGggPSB0aGlzLl9UZXh0LnJlbmRlcldpZHRoICsgdGhpcy5zdHlsZS5wYWRkaW5nWCAqIDI7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5pY29uKSB7XG4gICAgICAgICAgICB3aWR0aCA9IHRoaXMuX0ljb24uZmluYWxXICsgdGhpcy5zdHlsZS5wYWRkaW5nWCAqIDI7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy53ID0gd2lkdGg7XG4gICAgf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RJbnZlcnNlXG4gICAgICAgIH0sXG4gICAgICAgIGNvbnRlbnRDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2UsXG4gICAgICAgIHRvbmU6IHtcbiAgICAgICAgICAgIGludmVyc2U6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJyYW5kOiB7XG4gICAgICAgICAgICAgICAgY29udGVudENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBkaXNhYmxlZDoge1xuICAgICAgICB0ZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICB9LFxuICAgICAgICBjb250ZW50Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsRGlzYWJsZWRcbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRPID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkTyxcbiAgICBtb2RlOiBtb2RlJGdcbn0pO1xuXG5jbGFzcyBGb2N1c01hbmFnZXIgZXh0ZW5kcyBCYXNlJDEge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJGb2N1c01hbmFnZXJcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkl0ZW1zXCIgXTtcbiAgICB9XG4gICAgc3RhdGlj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hciBmaXJzdEl0ZW0gPSB0aGlzLml0ZW1zLnJlZHVjZSgoKGFjYywgaXRlbSwgaWR4KSA9PiB7XG4gICAgICAgICAgICBpZiAoIWl0ZW0uc2tpcEZvY3VzKSB7XG4gICAgICAgICAgICAgICAgYWNjLnB1c2goX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBpdGVtKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgb3JpZ2luYWxJZHg6IGlkeFxuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCBbXSkuc2hpZnQoKTtcbiAgICAgICAgcmV0dXJuIGZpcnN0SXRlbS5vcmlnaW5hbElkeDtcbiAgICB9XG4gICAgX2xhc3RGb2N1c2FibGVJbmRleCgpIHtcbiAgICAgICAgaWYgKCF0aGlzLml0ZW1zLmxlbmd0aCkgcmV0dXJuIDA7XG4gICAgICAgIHZhciBsYXN0SXRlbSA9IHRoaXMuaXRlbXMucmVkdWNlKCgoYWNjLCBpdGVtLCBpZHgpID0+IHtcbiAgICAgICAgICAgIGlmICghaXRlbS5za2lwRm9jdXMpIHtcbiAgICAgICAgICAgICAgICBhY2MucHVzaChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGl0ZW0pLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBvcmlnaW5hbElkeDogaWR4XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgfSksIFtdKS5wb3AoKTtcbiAgICAgICAgcmV0dXJuIGxhc3RJdGVtLm9yaWdpbmFsSWR4O1xuICAgIH1cbiAgICBzZWxlY3RQcmV2aW91cygpIHtcbiAgICAgICAgdGhpcy5zaG91bGRTbW9vdGggPSB0cnVlO1xuICAgICAgICB2YXIgaGFzRm9jdXNhYmxlID0gISEodGhpcy5pdGVtcy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xkKSB7XG4gICAgICAgICAgICAgICAgICAgIGxhc3RTY3JvbGxJbmRleCA9IGk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fbGFzdFNjcm9sbEluZGV4ID0gbGFzdFNjcm9sbEluZGV4O1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9sYXN0U2Nyb2xsSW5kZXggPiB0aGlzLml0ZW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgdGhpcy5fbGFzdFNjcm9sbEluZGV4ID0gdGhpcy5pdGVtcy5sZW5ndGggLSAxO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9jYWxjQ3Jvc3NEaW1lbnNpb25TaXplKGNvbXApIHtcbiAgICAgICAgaWYgKHRoaXMuX2lzUm93KSB7XG4gICAgICAgICAgICByZXR1cm4gZ2V0SChjb21wKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5faXNDb2x1bW4pIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRXKGNvbXApO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9jYWxjQXhpc1Bvc2l0aW9uKGNvbXApIHtcbiAgICAgICAgaWYgKHRoaXMuX2lzUm93KSB7XG4gICAgICAgICAgICByZXR1cm4gZ2V0WChjb21wKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5faXNDb2x1bW4pIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRZKGNvbXApO1xuICAgICAgICB9XG4gICAgfVxuICAgIF90cmFuc2l0aW9uTGlzdGVuZXIoKSB7XG4gICAgICAgIHRoaXMuc2hvdWxkU21vb3RoID0gZmFsc2U7XG4gICAgICAgIHRoaXMudHJhbnNpdGlvbkRvbmUoKTtcbiAgICB9XG4gICAgX3dpdGhBZnRlclVwZGF0ZShlbGV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gICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChfcHJldkluZGV4ID4gdGhpcy5zZWxlY3RlZEluZGV4KSB7XG4gICAgICAgICAgICAgICAgaXRlbXNDb250YWluZXJYID0gLXNlbGVjdGVkWCArIHRoaXMuaXRlbVBvc1g7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9wcmV2SW5kZXggPCB0aGlzLnNlbGVjdGVkSW5kZXgpIHtcbiAgICAgICAgICAgICAgICBpdGVtc0NvbnRhaW5lclggPSB0aGlzLncgLSBzZWxlY3RlZFggLSB0aGlzLnNlbGVjdGVkLnc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gaXRlbXNDb250YWluZXJYO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl9nZXRTY3JvbGxYKCk7XG4gICAgfVxuICAgIF9nZXRTY3JvbGxYKCkge1xuICAgICAgICBpZiAodGhpcy5fc2VsZWN0ZWRQYXN0QWRkZWQpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9nZXRQcmVwZW5kZWRPZmZzZXQoKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaXRlbXNDb250YWluZXJYO1xuICAgICAgICB2YXIgaXRlbUluZGV4ID0gdGhpcy5zZWxlY3RlZEluZGV4IC0gdGhpcy5zY3JvbGxJbmRleDtcbiAgICAgICAgaXRlbUluZGV4ID0gaXRlbUluZGV4IDwgMCA/IDAgOiBpdGVtSW5kZXg7XG4gICAgICAgIGlmIChpdGVtSW5kZXggPT09IHRoaXMuX2ZpcnN0Rm9jdXNhYmxlSW5kZXgoKSkge1xuICAgICAgICAgICAgaXRlbUluZGV4ID0gMDtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5JdGVtcy5jaGlsZHJlbltpdGVtSW5kZXhdKSB7XG4gICAgICAgICAgICBpdGVtc0NvbnRhaW5lclggPSB0aGlzLkl0ZW1zLmNoaWxkcmVuW2l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VudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIklubGluZUNvbnRlbnRcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkSjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBhbGlhc1N0eWxlcygpIHtcbiAgICAgICAgcmV0dXJuIFsge1xuICAgICAgICAgICAgcHJldjogXCJpY29uSFwiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uSGVpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJpY29uV1wiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uV2lkdGhcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF9jb25zdHJ1Y3QoKSB7XG4gICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICAgICAgdGhpcy5fbWF4TGluZXNTdWZmaXggPSBcIi4uXCI7XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUNvbnRlbnQoKTtcbiAgICAgICAgdGhpcy5fd2FpdEZvckNvbXBvbmVudExvYWQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnQoKSB7XG4gICAgICAgIHRoaXMuY2hpbGRMaXN0LmNsZWFyKCk7XG4gICAgICAgIGlmICh0aGlzLl9zaG91bGRUcnVuY2F0ZSkge1xuICAgICAgICAgICAgdGhpcy5hbHBoYSA9IC4wMDE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3BhcnNlZENvbnRlbnQgJiYgdGhpcy5fcGFyc2VkQ29udGVudC5sZW5ndGgpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIGZsZXg6IHtcbiAgICAgICAgICAgICAgICAgICAgZGlyZWN0aW9uOiBcInJvd1wiLFxuICAgICAgICAgICAgICAgICAgICB3cmFwOiAhIXRoaXMuY29udGVudFdyYXAsXG4gICAgICAgICAgICAgICAgICAgIGp1c3RpZnlDb250ZW50OiB0aGlzLmp1c3RpZnkgIT0gdW5kZWZpbmVkID8gdGhpcy5qdXN0aWZ5IDogdGhpcy5zdHlsZS5qdXN0aWZ5XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB0aGlzLl9wYXJzZWRDb250ZW50LmZvckVhY2goKChpdGVtLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgICAgIHZhciBpc0xhc3QgPSBpbmRleCA9PT0gdGhpcy5fcGFyc2VkQ29udGVudC5sZW5ndGggLSAxO1xuICAgICAgICAgICAgICAgIHZhciBiYXNlID0ge1xuICAgICAgICAgICAgICAgICAgICBmbGV4SXRlbTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLmNvbnRlbnRQcm9wZXJ0aWVzKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hcmdpbkJvdHRvbTogaXNMYXN0ID8gMCA6IHRoaXMuX21hcmdpbkJvdHRvbSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hcmdpblJpZ2h0OiBpc0xhc3QgPyAwIDogdGhpcy5jb250ZW50UHJvcGVydGllcy5tYXJnaW5SaWdodCB8fCB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAoaXNUZXh0KGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBuZXh0SXRlbSA9IHRoaXMuX3BhcnNlZENvbnRlbnRbaW5kZXggKyAxXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5leHRJdGVtICYmIGlzVGV4dChuZXh0SXRlbSkgfHwgdGhpcy5jb250ZW50V3JhcCAmJiBuZXh0SXRlbSAmJiBuZXh0SXRlbS5uZXdsaW5lICYmIHRoaXMuX3BhcnNlZENvbnRlbnRbaW5kZXggKyAyXSAmJiBpc1RleHQodGhpcy5fcGFyc2VkQ29udGVudFtpbmRleCArIDJdKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgYmFzZS5mbGV4SXRlbS5tYXJnaW5SaWdodCA9IDA7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYSh0aGlzLl9jcmVhdGVUZXh0KGJhc2UsIGl0ZW0pKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzSWNvbihpdGVtKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKHRoaXMuX2NyZWF0ZUljb24oYmFzZSwgaXRlbSkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNCYWRnZShpdGVtKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKHRoaXMuX2NyZWF0ZUJhZGdlKGJhc2UsIGl0ZW0uYmFkZ2UpKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0ubmV3bGluZSAmJiB0aGlzLmNvbnRlbnRXcmFwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoe1xuICAgICAgICAgICAgICAgICAgICAgICAgaDogMCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHc6IHRoaXMud1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3dhaXRGb3JDb21wb25lbnRMb2FkKCkge1xuICAgICAgICBpZiAodGhpcy5jaGlsZHJlbi5sZW5ndGgpIHtcbiAgICAgICAgICAgIFByb21pc2UuYWxsKHRoaXMuY2hpbGRyZW4ubWFwKChjaGlsZCA9PiBuZXcgUHJvbWlzZSgocmVzb2x2ZSA9PiB7XG4gICAgICAg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ICAgICAgICAgICAgICAgdGhpcy5mbGV4Ll9sYXlvdXQuX2xpbmVMYXlvdXRlci5fbGluZXMuZm9yRWFjaCgobGluZSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0b3RhbEhlaWdodCArPSBPYmplY3QuZW50cmllcyhsaW5lLml0ZW1zKS5zbGljZShsaW5lLnN0YXJ0SW5kZXgsIGxpbmUuZW5kSW5kZXggKyAxKS5zb3J0KCgoYSwgYikgPT4gYlsxXS5oIC0gYVsxXS5oKSlbMF1bMV0uaDtcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLm11bHRpTGluZUhlaWdodCA9IHRvdGFsSGVpZ2h0O1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fc2hvdWxkVHJ1bmNhdGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlck1heExpbmVzKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm90aWZ5QW5jZXN0b3JzKCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExvYWRlZCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pLCAxMCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9ub3RpZnlBbmNlc3RvcnMoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfcmVuZGVyTWF4TGluZXMoKSB7XG4gICAgICAgIHZhciBjaGlsZHJlbkRpbWVuc2lvbnMgPSB0aGlzLl9jYWxjQ2hpbGRyZW5EaW1lbnNpb25zKCk7XG4gICAgICAgIHRoaXMuY2hpbGRMaXN0LmNsZWFyKCk7XG4gICAgICAgIHZhciByZW5kZXJlZExhc3RFbGVtZW50ID0gZmFsc2U7XG4gICAgICAgIGNoaWxkcmVuRGltZW5zaW9ucy5m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ZW5EaW1lbnNpb25zLmxlbmd0aCAtIDEpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYWRkKHRoaXMuX2FkZFN1ZmZpeChjaGlsZCkpO1xuICAgICAgICAgICAgICAgICAgICByZW5kZXJlZExhc3RFbGVtZW50ID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hZGQoY2hpbGQuY29tcG9uZW50KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKTtcbiAgICAgICAgdGhpcy5hbHBoYSA9IDE7XG4gICAgfVxuICAgIF9jYWxjQ2hpbGRyZW5EaW1lbnNpb25zKCkge1xuICAgICAgICB2YXIgc3VmZml4VyA9IG1lYXN1cmVUZXh0V2lkdGgoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICB0ZXh0OiB0aGlzLm1heExpbmVzU3VmZml4XG4gICAgICAgIH0pKTtcbiAgICAgICAgdmFyIGNvbnRlbnRFbmRYID0gMDtcbiAgICAgICAgdmFyIGxpbmUgPSAxO1xuICAgICAgICByZXR1cm4gdGhpcy5jaGlsZHJlbi5yZWR1Y2UoKChhY2MsIGNoaWxkKSA9PiB7XG4gICAgICAgICAgICB2YXIgY29tcG9uZW50ID0gY2hpbGQ7XG4gICAgICAgICAgICB2YXIgdHlwZSwgY29udGVudCwgdztcbiAgICAgICAgICAgIHZhciBpc05ld0xpbmVFbGVtZW50ID0gY2hpbGQudyA9PSB0aGlzLncgJiYgY2hpbGQuaCA9PT0gMDtcbiAgICAgICAgICAgIGlmIChpc05ld0xpbmVFbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgbGluZSsrO1xuICAgICAgICAgICAgICAgIGNvbnRlbnRFbmRYID0gMDtcbiAgICAgICAgICAgICAgICB2YXIgX2RhdGEgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFwibGluZWJyZWFrXCIsXG4gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudDogY29tcG9uZW50LFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBjb250ZW50LFxuICAgICAgICAgICAgICAgICAgICBsaW5lOiBsaW5lLFxuICAgICAgICAgICAgICAgICAgICBoYXNTcGFjZUZvclN1ZmZpeDogdHJ1ZVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgYWNjLnB1c2goX2RhdGEpO1xuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoaXNUZXh0KGNoaWxkKSkge1xuICAgICAgICAgICAgICAgIHR5cGUgPSBcInRleHRcIjtcbiAgICAgICAgICAgICAgICBjb250ZW50ID0gY2hpbGQudGV4dC50ZXh0O1xuICAgICAgICAgICAgICAgIHcgPSBjaGlsZC50ZXh0dXJlLmdldFJlbmRlcldpZHRoKCk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzSWNvbihjaGlsZCkpIHtcbiAgICAgICAgICAgICAgICB0eXBlID0gXCJpY29uXCI7XG4gICAgICAgICAgICAgICAgdyA9IGNoaWxkLnc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoaWxkLmNvbnN0cnVjdG9yLl9fY29tcG9uZW50TmFtZSA9PT0gXCJCYWRnZVwiKSB7XG4gICAgICAgICAgICAgICAgdHlwZSA9IFwiYmFkZ2VcIjtcbiAgICAgICAgICAgICAgICB3ID0gY2hpbGQudztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnRlbnRFbmRYICs9IHc7XG4gICAgICAgICAgICBjb250ZW50RW5kWCArPSBjaGlsZC5mbGV4SXRlbS5tYXJnaW5SaWdodDtcbiAgICAgICAgICAgIGlmIChNYXRoLmNlaWwoY29udGVudEVuZFgpID49IHRoaXMudykge1xuICAgICAgICAgICAgICAgIGxpbmUrKztcbiAgICAgICAgICAgICAgICBjb250ZW50RW5kWCA9IHc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgaGFzU3BhY2VGb3JTdWZmaXggPSBNYXRoLmNlaWwoY29udGVudEVuZFgpICsgc3VmZml4VyA8PSB0aGlzLnc7XG4gICAgICAgICAgICB2YXIgZGF0YSA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiB0eXBlLFxuICAgICAgICAgICAgICAgIGNvbXBvbmVudDogY29tcG9uZW50LFxuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGNvbnRlbnQsXG4gICAgICAgICAgICAgICAgbGluZTogbGluZSxcbiAgICAgICAgICAgICAgICBoYXNTcGFjZUZvclN1ZmZpeDogaGFzU3BhY2VGb3JTdWZmaXhcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBhY2MucHVzaChkYXRhKTtcbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCBbXSk7XG4gICAgfVxuICAgIF9hZGRTdWZmaXgoX3JlZjE2KSB7XG4gICAgICAgIHZhciB7dHlwZTogdHlwZSwgY29tcG9uZW50OiBjb21wb25lbnQsIGNvbnRlbnQ6IGNvbnRlbnR9ID0gX3JlZjE2O1xuICAgICAgICB2YXIgbmVnYXRlZFJpZ2h0TWFyZ2luID0gY29tcG9uZW50LmZsZXhJdGVtLm1hcmdpblJpZ2h0ICogLTE7XG4gICAgICAgIHZhciBzdWZmaXg7XG4gICAgICAgIGlmICh0eXBlID09PSBcInRleHRcIikge1xuICAgICAgICAgICAgdmFyIHtmb250RmFjZTogZm9udEZhY2UsIGZvbnRTaXplOiBmb250U2l6ZSwgZm9udFN0eWxlOiBmb250U3R5bGUsIGxpbmVIZWlnaHQ6IGxpbmVIZWlnaHQsIHZlcnRpY2FsQWxpZ246IHZlcnRpY2FsQWxpZ259ID0gY29tcG9uZW50LnRleHQ7XG4gICAgICAgICAgICBzdWZmaXggPSB0aGlzLl9jcmVhdGVUZXh0KHtcbiAgICAgICAgICAgICAgICBmbGV4SXRlbTogdGhpcy5jb250ZW50UHJvcGVydGllc1xuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRleHQ6IFwiXCIuY29uY2F0KGNvbnRlbnQudHJpbSgpKS5jb25jYXQodGhpcy5tYXhMaW5lc1N1ZmZpeCksXG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgZm9udEZhY2U6IGZvbnRGYWNlLFxuICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogZm9udFNpemUsXG4gICAgICAgICAgICAgICAgICAgIGZvbnRTdHlsZTogZm9udFN0eWxlLFxuICAgICAgICAgICAgICAgICAgICBsaW5lSGVpZ2h0OiBsaW5lSGVpZ2h0LFxuICAgICAgICAgICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiB2ZXJ0aWNhbEFsaWduXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hZGQoY29tcG9uZW50KTtcbiAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMuX2NyZWF0ZVRleHQoe1xuICAgICAgICAgICAgICAgIGZsZXhJdGVtOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuY29udGVudFByb3BlcnRpZXMpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXJnaW5MZWZ0OiBuZWdhdGVkUmlnaHRNYXJnaW5cbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSwgdGhpcy5tYXhMaW5lc1N1ZmZpeCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHN1ZmZpeDtcbiAgICB9XG4gICAgX2NyZWF0ZUljb24oYmFzZSwgaWNvblByb3BzKSB7XG4gICAgICAgIHZhciB5ID0gKHRoaXMudGV4dEhlaWd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ICh0ZXh0T3ZlcnJpZGVTdHlsZXMgPT09IG51bGwgfHwgdGV4dE92ZXJyaWRlU3R5bGVzID09PSB2b2lkIDAgPyB2b2lkIDAgOiB0ZXh0T3ZlcnJpZGVTdHlsZXMudGV4dENvbG9yKSB8fCB0aGlzLnN0eWxlLnRleHRTdHlsZS50ZXh0Q29sb3IsXG4gICAgICAgICAgICAgICAgaDogdGV4dENvbXBvbmVudC5oICogdGhpcy5zdHlsZS5zdHJpa2V0aHJvdWdoUmF0aW8sXG4gICAgICAgICAgICAgICAgeTogdGV4dENvbXBvbmVudC5oIC8gMixcbiAgICAgICAgICAgICAgICBtb3VudFk6IDFcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IGxuZy5Db21wb25lbnQsXG4gICAgICAgICAgICAgICAgdzogdGV4dFdpZHRoICsgdGV4dENvbXBvbmVudC5mbGV4SXRlbS5tYXJnaW5SaWdodCxcbiAgICAgICAgICAgICAgICBoOiB0ZXh0Q29tcG9uZW50LmgsXG4gICAgICAgICAgICAgICAgY2hpbGRyZW46IFsgX29iamVjdFNwcmVhZCh7fSwgdGV4dENvbXBvbmVudCksIF9vYmplY3RTcHJlYWQoe30sIHN0cmlrZXRocm91Z2hMaW5lKSBdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0ZXh0Q29tcG9uZW50O1xuICAgIH1cbiAgICBfY3JlYXRlQmFkZ2UoYmFzZSwgYmFkZ2UpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBiYXNlKSwge30sIHtcbiAgICAgICAgICAgIHk6IHRoaXMuYmFkZ2VZIHx8IDBcbiAgICAgICAgfSwgdGhpcy5iYWRnZVByb3BlcnRpZXMpLCB7fSwge1xuICAgICAgICAgICAgdHlwZTogQmFkZ2UsXG4gICAgICAgICAgICB0aXR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gICAgICAgICAgICAgICAgICBhY2MucHVzaCguLi5mb3JtYXR0ZWRXb3Jkcyk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHBhcnNlZCA9IGl0ZW0uc3BsaXQod2hpdGVzcGFjZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBhY2MucHVzaChwYXJzZWQpO1xuICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgfSksIFtdKSkubWFwKCgoaXRlbSwgaW5kZXgsIGFycikgPT4ge1xuICAgICAgICAgICAgaWYgKGl0ZW0gPT09IFwiIFwiKSByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICBpZiAoYXJyW2luZGV4ICsgMV0gPT09IFwiIFwiKSByZXR1cm4gaXRlbSArIFwiIFwiO1xuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XG4gICAgICAgIH0pKS5maWx0ZXIoQm9vbGVhbik7XG4gICAgfVxuICAgIF9zZXRDb250ZW50KGNvbnRlbnQpIHtcbiAgICAgICAgaWYgKGNvbnRlbnQgIT09IHRoaXMuX2NvbnRlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRlbnQgPSBjb250ZW50O1xuICAgICAgICAgICAgdmFyIHBhcnNlZENvbnRlbnQgPSB0aGlzLl9jb250ZW50O1xuICAgICAgICAgICAgaWYgKGNvbnRlbnQgJiYgIUFycmF5LmlzQXJyYXkoY29udGVudCkpIHtcbiAgICAgICAgICAgICAgICBwYXJzZWRDb250ZW50ID0gcGFyc2VJbmxpbmVDb250ZW50KGNvbnRlbnQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fcGFyc2VkQ29udGVudCA9IHRoaXMuX2Zvcm1hdFNwYWNlcyhwYXJzZWRDb250ZW50KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gY29udGVudDtcbiAgICB9XG4gICAgX3NldEJhZGdlUHJvcGVydGllcyhiYWRnZVByb3BlcnRpZXMpIHtcbiAgICAgICAgaWYgKHR5cGVvZiBiYWRnZVByb3BlcnRpZXMgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgIHJldHVybiBiYWRnZVByb3BlcnRpZXM7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2dldEJhZGdlUHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2JhZGdlUHJvcGVydGllcyB8fCB7fTtcbiAgICB9XG4gICAgX3NldENvbnRlbnRQcm9wZXJ0aWVzKGNvbnRlbnRQcm9wZXJ0aWVzKSB7XG4gICAgICAgIGlmICh0eXBlb2YgY29udGVudFByb3BlcnRpZXMgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgIHJldHVybiBjb250ZW50UHJvcGVydGllcztcbiAgICAgICAgfVxuICAgIH1cbiAgICBfZ2V0Q29udGVudFByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50UHJvcGVydGllcyB8fCB7fTtcbiAgICB9XG4gICAgX3NldEN1c3RvbVN0eWxlTWFwcGluZ3MoY3VzdG9tU3R5bGVNYXBwaW5ncykge1xuICAgICAgICBpZiAodHlwZW9mIGN1c3RvbVN0eWxlTWFwcGluZ3MgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgIHJldHVybiBjdXN0b21TdHlsZU1hcHBpbmdzO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9nZXRDdXN0b21TdHlsZU1hcHBpbmdzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY3VzdG9tU3R5bGVNYXBwaW5ncyB8fCB7fTtcbiAgICB9XG4gICAgX3NldE1heExpbmVzKG1heExpbmVzKSB7XG4gICAgICAgIHJldHVybiBtYXhMaW5lcyA+PSAxID8gTWF0aC5mbG9vcihtYXhMaW5lcykgOiAwO1xuICAgIH1cbiAgICBnZXQgdGV4dEhlaWdodCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc3R5bGUudGV4dFN0eWxlLmxpbmVIZWlnaHQgfHwgdGhpcy5zdHlsZS50ZXh0U3R5bGUuZm9udFNpemU7XG4gICAgfVxuICAgIGdldCBfbWFyZ2luQm90dG9tKCkge1xuICAgICAgICBpZiAodGhpcy5jb250ZW50UHJvcGVydGllcy5tYXJnaW5Cb3R0b20gIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGVudFByb3BlcnRpZXMubWFyZ2luQm90dG9tO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLnN0eWxlLm1hcmdpbkJvdHRvbSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3R5bGUubWFyZ2luQm90dG9tO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiAwO1xuICAgIH1cbiAgICBnZXQgX3Nob3VsZFRydW5jYXRlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5jb250ZW50V3JhcCAmJiB0aGlzLm1heExpbmVzO1xuICAgIH1cbiAgICBzZXQgYW5ub3VuY2UoYW5ub3VuY2UpIHtcbiAgICAgICAgc3VwZXIuYW5ub3VuY2UgPSBhbm5vdW5jZTtcbiAgICB9XG4gICAgZ2V0IGFubm91bmNlKCkge1xuICAgICAgICBpZiAodGhpcy5fYW5ub3VuY2UpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgYW5ub3VuY2UgPSB0aGlzLl9wYXJzZWRDb250ZW50ICYmIHRoaXMuX3BhcnNlZENvbnRlbnQucmVkdWNlKCgoYW5ub3VuY2UsIGl0ZW0pID0+IHtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgIGFubm91bmNlICs9IGl0ZW07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0uYW5ub3VuY2UpIHtcbiAgICAgICAgICAgICAgICBhbm5vdW5jZSArPSBpdGVtLmFubm91bmNlO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpdGVtLnRleHQpIHtcbiAgICAgICAgICAgICAgICB2YXIgX2l0ZW0kc3R5bGU7XG4gICAgICAgICAgICAgICAgYW5ub3VuY2UgKz0gaXRlbS50ZXh0O1xuICAgICAgICAgICAgICAgIGlmICgoKF9pdGVtJHN0eWxlID0gaXRlbS5zdHlsZSkgPT09IG51bGwgfHwgX2l0ZW0kc3R5bGUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9pdGVtJHN0eWxlLnRleHREZWNvcmF0aW9uKSA9PT0gXCJsaW5lLXRocm91Z2hcIikge1xuICAgICAgICAgICAgICAgICAgICBhbm5vdW5jZSArPSBcInN0cmlrZXRocm91Z2hcIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0udGl0bGUpIHtcbiAgICAgICAgICAgICAgICBhbm5vdW5jZSArPSBpdGVtLnRpdGxlO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpdGVtLmJhZGdlKSB7XG4gICAgICAgICAgICAgICAgYW5ub3VuY2UgKz0gaXRlbS5iYWRnZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBhbm5vdW5jZSArIFwiIFwiO1xuICAgICAgICB9KSwgXCJcIik7XG4gICAgICAgIHJldHVybiBhbm5vdW5jZSA/IGFubm91bmNlLnJlcGxhY2UoL1xccysoPz1cXHMpfFxccyQvZywgXCJcIikgOiBcIlwiO1xuICAgIH1cbn1cblxudmFyIGJhc2UkSSA9IHRoZW1lID0+ICh7XG4gICAgZmFkZVdpZHRoOiAxMDAsXG4gICAgb2Zmc2V0OiB0aGVtZS5zcGFjZXIueHhsLFxuICAgIHNob3VsZFNtb290aDogZmFsc2UsXG4gICAgdGV4dFN0eWxlOiB0aGVtZS50eXBvZ3JhcGh5LmJvZHkxXG59KTtcblxudmFyIHN0eWxlc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4gICAgICAgICAgICAgICAgQ29udGVudEJveDoge1xuICAgICAgICAgICAgICAgICAgICBDb250ZW50OiB7fSxcbiAgICAgICAgICAgICAgICAgICAgQ29udGVudExvb3BUZXh0dXJlOiB7fVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIk1hcnF1ZWVcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkSTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkNvbnRlbnRDbGlwcGVyXCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiQ29udGVudEJveFwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50Q2xpcHBlci5Db250ZW50Qm94XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJDb250ZW50XCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnRDbGlwcGVyLkNvbnRlbnRCb3guQ29udGVudFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiQ29udGVudExvb3BUZXh0dXJlXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnRDbGlwcGVyLkNvbnRlbnRCb3guQ29udGVudExvb3BUZXh0dXJlXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiYXV0b1N0YXJ0XCIsIFwidGl0bGVcIiwgXCJjb250ZW50VGV4dHVyZVwiLCBcImNvbG9yXCIsIFwiY2VudGVyQWxpZ25cIiwgXCJkZWxheVwiLCBcInJlcGVhdFwiLCBcIm92ZXJyaWRlTG9vcFhcIi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AgICAgdmFyIGNvbnRlbnQgPSB7XG4gICAgICAgICAgICBydHQ6IHRydWVcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKHRoaXMuY29udGVudFRleHR1cmUpIHtcbiAgICAgICAgICAgIGNvbnRlbnQudGV4dHVyZSA9IHRoaXMuY29udGVudFRleHR1cmU7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy50aXRsZSkge1xuICAgICAgICAgICAgY29udGVudC50ZXh0ID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwgdGhpcy50aXRsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgdGV4dDogdGhpcy50ZXh0Q29udGVudFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBDb250ZW50Q2xpcHBlcjoge1xuICAgICAgICAgICAgICAgIHc6IHRoaXMudyArIDE0LFxuICAgICAgICAgICAgICAgIENvbnRlbnRCb3g6IHtcbiAgICAgICAgICAgICAgICAgICAgQ29udGVudDogY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgQ29udGVudExvb3BUZXh0dXJlOiB7fVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuc2lnbmFsKFwibWFycXVlZUNvbnRlbnRMb2FkZWRcIik7XG4gICAgfVxuICAgIF91cGRhdGVTaGFkZXIoKSB7XG4gICAgICAgIHRoaXMuX0NvbnRlbnRDbGlwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgIHc6IHRoaXMudyA+IDAgPyB0aGlzLncgKyB0aGlzLnN0eWxlLmZhZGVXaWR0aCAvIDIgOiAwLFxuICAgICAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgICAgICAgdHlwZTogRmFkZVNoYWRlcixcbiAgICAgICAgICAgICAgICBwb3NpdGlvbkxlZnQ6IDAsXG4gICAgICAgICAgICAgICAgcG9zaXRpb25SaWdodDogdGhpcy5zdHlsZS5mYWRlV2lkdGhcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBydHQ6IHRydWVcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVBbmltYXRpb24oKSB7XG4gICAgICAgIHRoaXMuX3Njcm9sbEFuaW1hdGlvbiAmJiB0aGlzLl9zY3JvbGxBbmltYXRpb24uc3RvcE5vdygpO1xuICAgICAgICB0aGlzLl9zY3JvbGxBbmltYXRpb24gPSB0aGlzLmFuaW1hdGlvbih7XG4gICAgICAgICAgICBkdXJhdGlvbjogdGhpcy5fbG9vcFdpZHRoIC8gNTAsXG4gICAgICAgICAgICBkZWxheTogaXNOYU4odGhpcy5kZWxheSkgPyAxLjUgOiB0aGlzLmRlbGF5LFxuICAgICAgICAgICAgcmVwZWF0OiBpc05hTih0aGlzLnJlcGVhdCkgPyAtMSA6IHRoaXMucmVwZWF0LFxuICAgICAgICAgICAgYWN0aW9uczogWyB7XG4gICAgICAgICAgICAgICAgdDogXCJDb250ZW50Qm94XCIsXG4gICAgICAgICAgICAgICAgcDogXCJ4XCIsXG4gICAgICAgICAgICAgICAgdjoge1xuICAgICAgICAgICAgICAgICAgICBzbTogMCxcbiAgICAgICAgICAgICAgICAgICAgMDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogMFxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAuNToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogLSh0aGlzLl9sb29wV2lkdGggKyB0aGlzLnN0eWxlLm9mZnNldClcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0OiBcIkNvbnRlbnRDbGlwcGVyXCIsXG4gICAgICAgICAgICAgICAgcDogXCJzaGFkZXIucG9zaXRpb25MZWZ0XCIsXG4gICAgICAgICAgICAgICAgdjoge1xuICAgICAgICAgICAgICAgICAgICBzbTogMCxcbiAgICAgICAgICAgICAgICAgICAgMDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogMFxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAuMToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogdGhpcy5zdHlsZS5mYWRlV2lkdGhcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgLjQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHY6IHRoaXMuc3R5bGUuZmFkZVdpZHRoXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIC41OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2OiAwXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IF1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF9wb3NpdGlvblRleHR1cmUoKSB7XG4gICAgICAgIHZhciB4ID0gdGhpcy5fc2hvdWxkQ2VudGVyKCkgPyAodGhpcy53IC0gdGhpcy5fdGV4dFJlbmRlcmVkVykgLyAyIDogMDtcbiAgICAgICAgaWYgKHRoaXMuc3R5bGUuc2hvdWxkU21vb3RoKSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50Qm94LnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICB4OiB4XG4gICAgICAgICAgICB9O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudEJveC54ID0geDtcbiAgICAgICAgfVxuICAgIH1cbiAgICBzdGFydFNjcm9sbGluZygpIHtcbiAgICAgICAgdGhpcy5fQ29udGVudC5vZmYoXCJ0eExvYWRlZFwiLCB0aGlzLnN0YXJ0U2Nyb2xsaW5nLmJpbmQodGhpcykpO1xuICAgICAgICB0aGlzLl9zaG91bGRUcnlTY3JvbGx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VtQ2hhbmdlZFwiKTtcbiAgICAgICAgdGhpcy5zaWduYWwoXCJ0ZXh0Qm94Q2hhbmdlZFwiLCB7XG4gICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgaDogaFxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB0aGlzLl9tYXJxdWVlQ29udGVudExpc3RlbmVyQXR0YWNoZWQgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5fbWFycXVlZU92ZXJyaWRlTG9vcFggPSB1bmRlZmluZWQ7XG4gICAgICAgIHRoaXMuX3Jlc2V0TWFycXVlZVByb21pc2UoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9UZXh0IHx8IHRoaXMuX0lubGluZUNvbnRlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLncgPSB0aGlzLmggPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuX25vdGlmeUFuY2VzdG9ycygpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZU1hcnF1ZWUoKTtcbiAgICAgICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgVGV4dDogdW5kZWZpbmVkLFxuICAgICAgICAgICAgICAgICAgICBJbmxpbmVDb250ZW50OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9pc0lubGluZUNvbnRlbnQgPyB0aGlzLl91cGRhdGVJbmxpbmVDb250ZW50KCkgOiB0aGlzLl91cGRhdGVUZXh0KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZU1hcnF1ZWUoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUlubGluZUNvbnRlbnQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgVGV4dDogdW5kZWZpbmVkXG4gICAgICAgIH0pO1xuICAgICAgICB2YXIgaW5saW5lQ29udGVudFBhdGNoID0gSW5saW5lQ29udGVudC5wcm9wZXJ0aWVzLnJlZHVjZSgoKGFjYywgcHJvcCkgPT4ge1xuICAgICAgICAgICAgaWYgKHRoaXNbcHJvcF0gIT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgYWNjW3Byb3BdID0gdGhpc1twcm9wXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCB7XG4gICAgICAgICAgICBzdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuX3RleHRTdHlsZVNldFxuICAgICAgICAgICAgfSlcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh0aGlzLl90ZXh0U3R5bGVTZXQud29yZFdyYXBXaWR0aCkge1xuICAgICAgICAgICAgaW5saW5lQ29udGVudFBhdGNoLncgPSB0aGlzLl90ZXh0U3R5bGVTZXQud29yZFdyYXBXaWR0aDtcbiAgICAgICAgICAgIGlubGluZUNvbnRlbnRQYXRjaC5ydHQgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl90ZXh0U3R5bGVTZXQubWF4TGluZXMpIHtcbiAgICAgICAgICAgIGlubGluZUNvbnRlbnRQYXRjaC5tYXhMaW5lcyA9IHRoaXMuX3RleHRTdHlsZVNldC5tYXhMaW5lcztcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fdGV4dFN0eWxlU2V0Lm1heExpbmVzU3VmZml4KSB7XG4gICAgICAgICAgICBpbmxpbmVDb250ZW50UGF0Y2gubWF4TGluZXNTdWZmaXggPSB0aGlzLl90ZXh0U3R5bGVTZXQubWF4TGluZXNTdWZmaXg7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBhbHBoYTogMSxcbiAgICAgICAgICAgIElubGluZUNvbnRlbnQ6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgdHlwZTogSW5saW5lQ29udGVudCxcbiAgICAgICAgICAgICAgICB3OiB0aGlzLndcbiAgICAgICAgICAgIH0sIGlubGluZUNvbnRlbnRQYXRjaCksIHt9LCB7XG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBsb2FkZWRJbmxpbmVDb250ZW50OiBcIl9zZXREaW1lbnNpb25zXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZVRleHQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgSW5saW5lQ29udGVudDogdW5kZWZpbmVkXG4gICAgICAgIH0pO1xuICAgICAgICBpZiAoIXRoaXMuX1RleHQpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIFRleHQ6IHt9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMuX1RleHQub24oXCJ0eExvYWRlZFwiLCB0aGlzLl9zZXREaW1lbnNpb25zLmJpbmQodGhpcykpO1xuICAgICAgICB9XG4gICAgICAgIHZhciBmb250U3R5bGUgPSB0aGlzLl90ZXh0U3R5bGVTZXQ7XG4gICAgICAgIGlmICh0aGlzLl9UZXh0KSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LnBhdGNoKHtcbiAgICAgICAgICAgICAgICB5OiB0aGlzLnN0eWxlLm9mZnNldFksXG4gICAgICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5vZmZzZXRYLFxuICAgICAgICAgICAgIC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AgdGhpcy5fdG9nZ2xlTWFycXVlZSh0aGlzLl9jb250ZW50VGFnKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5tYXJxdWVlKSB7XG4gICAgICAgICAgICB0aGlzLl9yZXNldE1hcnF1ZWVQcm9taXNlKCk7XG4gICAgICAgICAgICB2YXIgbWFycXVlZVBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLm1hcnF1ZWVQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICAgICAgdzogdGhpcy5fdGV4dFN0eWxlU2V0LndvcmRXcmFwV2lkdGggfHwgdGhpcy53LFxuICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICB5OiB0aGlzLnN0eWxlLm9mZnNldFksXG4gICAgICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5vZmZzZXRYLFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgbWFycXVlZUNvbnRlbnRMb2FkZWQ6IFwiX2xvYWRlZE1hcnF1ZWVDb250ZW50XCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fTWFycXVlZSkge1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC50eXBlID0gTWFycXVlZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLl9pc0lubGluZUNvbnRlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9JbmxpbmVDb250ZW50LncgPSAwO1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC50aXRsZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICBtYXJxdWVlUGF0Y2guY29udGVudFRleHR1cmUgPSB0aGlzLl9jb250ZW50VGFnLmdldFRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICBtYXJxdWVlUGF0Y2gudyA9IHRoaXMuX3RleHRTdHlsZVNldC53b3JkV3JhcFdpZHRoIHx8IHRoaXMudztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbWFycXVlZVBhdGNoLmNvbnRlbnRUZXh0dXJlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC50aXRsZSA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHRleHQ6IHRoaXMuX2NvbnRlbnRUYWcudGV4dC50ZXh0XG4gICAgICAgICAgICAgICAgfSwgdGhpcy5fdGV4dFN0eWxlU2V0KSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogMCxcbiAgICAgICAgICAgICAgICAgICAgbWF4TGluZXM6IDFcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIE1hcnF1ZWU6IG1hcnF1ZWVQYXRjaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX21hcnF1ZWVDb250ZW50TGlzdGVuZXJBdHRhY2hlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX21hcnF1ZWVDb250ZW50TGlzdGVuZXJBdHRhY2hlZCA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoXCJ1bmRlZmluZWRcIiAhPT0gdHlwZW9mIHRoaXMuX21hcnF1ZWVPdmVycmlkZUxvb3BYKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fYXdhaXRNYXJxdWVlT3ZlcnJpZGVYLnRoZW4oKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdG9nZ2xlTWFycXVlZSh0aGlzLl9jb250ZW50VGFnKTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAg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PSB0aGlzW1wiX1wiLmNvbmNhdChwcm9wKV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKTtcbiAgICAgICAgaWYgKHRoaXMudyAmJiAhdGhpcy5faXNJbmxpbmVDb250ZW50ICYmICF0aGlzLnN0eWxlLnRleHRTdHlsZS53b3JkV3JhcFdpZHRoICYmIHRoaXMuZml4ZWQpIHtcbiAgICAgICAgICAgIGZvbnRTdHlsZS53b3JkV3JhcFdpZHRoID0gdGhpcy53O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmb250U3R5bGU7XG4gICAgfVxuICAgIGdldCBfY29udGVudFRhZygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2lzSW5saW5lQ29udGVudCA/IHRoaXMuX0lubGluZUNvbnRlbnQgOiB0aGlzLl9UZXh0O1xuICAgIH1cbiAgICBfdG9nZ2xlTWFycXVlZShjb250ZW50VGFnKSB7XG4gICAgICAgIGlmICh0aGlzLm1hcnF1ZWUpIHtcbiAgICAgICAgICAgIGlmIChjb250ZW50VGFnKSB7XG4gICAgICAgICAgICAgICAgY29udGVudFRhZy5hbHBoYSA9IC4wMDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fTWFycXVlZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuYWxwaGEgPSAxO1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuc3RhcnRTY3JvbGxpbmcoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChjb250ZW50VGFnKSB7XG4gICAgICAgICAgICAgICAgY29udGVudFRhZy5hbHBoYSA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fTWFycXVlZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuYWxwaGEgPSAuMDAxO1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuc3Rvc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IiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcInRpdGxlUGFkZGluZ1wiLFxuICAgICAgICAgICAgY3VycjogXCJjb250ZW50U3BhY2luZ1wiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCBcIkNvbnRlbnRcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJUZXh0V3JhcHBlclwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlRleHRXcmFwcGVyXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJUaXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlRleHRXcmFwcGVyLlRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJQcmVmaXhcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5QcmVmaXhcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlN1ZmZpeFwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlN1ZmZpeFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkpLCB7fSwge1xuICAgICAgICAgICAgQ29udGVudDoge1xuICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICB4OiB3ID0+IHcgLyAyLFxuICAgICAgICAgICAgICAgIHk6IGggPT4gaCAvIDIsXG4gICAgICAgICAgICAgICAgekluZGV4OiAyXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cb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gICAgICAgaWYgKHRoaXMuX2hhc1N1ZmZpeCAmJiB0aGlzLl9TdWZmaXggIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgdGhpcy5fU3VmZml4LnggPSB0aGlzLl9zdWZmaXhYO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXgoKSB7XG4gICAgICAgIHZhciBwcmVmaXhTdHJpbmcgPSBKU09OLnN0cmluZ2lmeSh0aGlzLnByZWZpeCk7XG4gICAgICAgIGlmICh0aGlzLnByZWZpeCkge1xuICAgICAgICAgICAgdmFyIHByZWZpeFBhdGNoID0ge1xuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIGl0ZW1TcGFjaW5nOiB0aGlzLnN0eWxlLml0ZW1TcGFjaW5nXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fUHJlZml4KSB7XG4gICAgICAgICAgICAgICAgcHJlZml4UGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuX3Jvd1Byb3BzKSwgcHJlZml4UGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgUHJlZml4OiBwcmVmaXhQYXRjaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhTdWZmaXhTdHlsZXMoXCJwcmVmaXhcIik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBQcmVmaXg6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fcHJldlByZWZpeCA9IHByZWZpeFN0cmluZztcbiAgICB9XG4gICAgX3VwZGF0ZVByZWZpeFN1ZmZpeFN0eWxlcygpIHtcbiAgICAgICAgdmFyIHR5cGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IFwicHJlZml4XCI7XG4gICAgICAgIHZhciBtYXAgPSB7XG4gICAgICAgICAgICBwcmVmaXg6IHtcbiAgICAgICAgICAgICAgICB0YWc6IHRoaXMuX1ByZWZpeCxcbiAgICAgICAgICAgICAgICBwcm9wOiB0aGlzLnByZWZpeCxcbiAgICAgICAgICAgICAgICBwcmV2UHJvcDogdGhpcy5fcHJldlByZWZpeFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHN1ZmZpeDoge1xuICAgICAgICAgICAgICAgIHRhZzogdGhpcy5fU3VmZml4LFxuICAgICAgICAgICAgICAgIHByb3A6IHRoaXMuc3VmZml4LFxuICAgICAgICAgICAgICAgIHByZXZQcm9wOiB0aGlzLl9wcmV2U3VmZml4XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIHZhciB7dGFnOiB0YWcsIHByb3A6IHByb3B9ID0gbWFwW3R5cGVdO1xuICAgICAgICB2YXIge3ByZXZQcm9wOiBwcmV2UHJvcH0gPSBtYXBbdHlwZV07XG4gICAgICAgIHZhciBwcm9wU3RyaW5nID0gSlNPTi5zdHJpbmdpZnkocHJvcCk7XG4gICAgICAgIGlmIChwcm9wU3RyaW5nICE9PSBwcmV2UHJvcCkge1xuICAgICAgICAgICAgcHJldlByb3AgPSBwcm9wU3RyaW5nO1xuICAgICAgICAgICAgdGFnLml0ZW1zID0gdGhpcy5fYWRkQnV0dG9uUHJvcHMocHJvcCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0YWcuSXRlbXMuY2hpbGRyZW4uZm9yRWFjaCgoKGl0ZW0sIGlkeCkgPT4ge1xuICAgICAgICAgICAgICAgIGl0ZW0uY29sb3IgPSBBcnJheS5pc0FycmF5KHByb3ApID8gcHJvcFtpZHhdLmNvbG9yIDogcHJvcC5jb2xvcjtcbiAgICAgICAgICAgICAgICBpdGVtLnN0eWxlID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBpdGVtLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY29udGVudENvbG9yXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVRpdGxlKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzVGl0bGUpIHtcbiAgICAgICAgICAgIHZhciB0aXRsZVBhdGNoID0ge1xuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMudGl0bGUsXG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLnRleHRTdHlsZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoIXRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICAgICAgdGl0bGVQYXRjaCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICB5OiBoID0+IGggLyAyLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfb25UaXRsZVRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIHRpdGxlUGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgVGV4dFdyYXBwZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgVGl0bGU6IHRpdGxlUGF0Y2hcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIFRleHRXcmFwcGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIFRpdGxlOiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlU3VmZml4KCkge1xuICAgICAgICBpZiAodGhpcy5zdWZmaXgpIHtcbiAgICAgICAgICAgIHZhciBzdWZmaXhQYXRjaCA9IHtcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICBpdGVtU3BhY2luZzogdGhpcy5zdHlsZS5pdGVtU3BhY2luZ1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoIXRoaXMuX1N1ZmZpeCkge1xuICAgICAgICAgICAgICAgIHN1ZmZpeFBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLl9yb3dQcm9wcyksIHN1ZmZpeFBhdGNoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIFN1ZmZpeDogc3VmZml4UGF0Y2hcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJlZml4U3VmZml4U3R5bGVzKFwic3VmZml4XCIpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgU3VmZml4OiB1bmRlZmluZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVUcnVuY2F0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RpdGxlLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50ZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRoaXMuZml4ZWQsXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLmZpeGVkID8gdGhpcy5fZml4ZWRXb3JkV3JhcFdpZHRoIDogMFxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVDb250ZW50RGltZW5zaW9ucygpIHtcbiAgICAgICAgdmFyIGNvbnRlbnREaW1lbnNpb25zUGF0Y2ggPSB7fTtcbiAgICAgICAgdmFyIHkgPSB0aGlzLmggLyAyO1xuICAgICAgICBpZiAodGhpcy5fQ29udGVudC50cmFuc2l0aW9uKFwid1wiKS50YXJnZXRWYWx1ZSAhPT0gdGhpcy5fY29udGVudFcpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQudyA9IHRoaXMuX2NvbnRlbnRXO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9Db250ZW50LnkgIT09IHkpIHtcbiAgICAgICAgICAgIGNvbnRlbnREaW1lbnNpb25zUGF0Y2gueSA9IHk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKGNvbnRlbnREaW1lbnNpb25zUGF0Y2gpLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIHRoaXMuX0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G5cbiAgICAgICAgICBjYXNlIFwiY2VudGVyXCI6XG4gICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIG1vdW50WCA9IC41O1xuICAgICAgICAgICAgeCA9IHRoaXMudyAvIDI7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgbW91bnRYOiBtb3VudFgsXG4gICAgICAgICAgICB4OiB4XG4gICAgICAgIH07XG4gICAgfVxuICAgIGdldCBfYnV0dG9uUHJvcHMoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBjZW50ZXJJblBhcmVudDogdHJ1ZSxcbiAgICAgICAgICAgIG1vZGU6IHRoaXMubW9kZVxuICAgICAgICB9O1xuICAgIH1cbiAgICBnZXQgX2hhc1ByZWZpeCgpIHtcbiAgICAgICAgcmV0dXJuICEhKHRoaXMucHJlZml4ICYmIE9iamVjdC5rZXlzKHRoaXMucHJlZml4KS5sZW5ndGgpO1xuICAgIH1cbiAgICBnZXQgX3ByZWZpeFcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oYXNQcmVmaXggJiYgdGhpcy5fUHJlZml4ICE9PSB1bmRlZmluZWQgPyB0aGlzLl9QcmVmaXgudyA6IDA7XG4gICAgfVxuICAgIGdldCBfcHJlZml4WCgpIHtcbiAgICAgICAgcmV0dXJuIDA7XG4gICAgfVxuICAgIGdldCBfaGFzVGl0bGUoKSB7XG4gICAgICAgIHJldHVybiAhIXRoaXMudGl0bGU7XG4gICAgfVxuICAgIGdldCBfdGl0bGVXKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzVGl0bGUgJiYgdGhpcy5fVGl0bGUgJiYgdGhpcy5fVGl0bGUuX1RleHQgJiYgdGhpcy5fVGl0bGUudmlzaWJsZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX1RpdGxlLnc7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIDA7XG4gICAgfVxuICAgIG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lsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRHID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkRyxcbiAgICBtb2RlOiBtb2RlJGVcbn0pO1xuXG5jbGFzcyBDYXJkIGV4dGVuZHMgU3VyZmFjZSB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkNhcmRcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkRztcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci5wcm9wZXJ0aWVzLCBcInRpdGxlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCBcIlRpdGxlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkpLCB7fSwge1xuICAgICAgICAgICAgVGl0bGU6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3VwZGF0ZVBvc2l0aW9uc1wiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgc3VwZXIuX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9KTtcbiAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9Lbm9iLCB7XG4gICAgICAgICAgICBhbHBoYTogdGhpcy5jaGVja2VkID8gMSA6IDBcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVPcGFjaXR5KCkge1xuICAgICAgICB0aGlzLmFwcGx5U21vb3RoKHRoaXMsIHtcbiAgICAgICAgICAgIGFscGhhOiB0aGlzLnN0eWxlLmFscGhhXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfc2V0Q2hlY2tlZChjaGVja2VkKSB7XG4gICAgICAgIHRoaXMuX2NoZWNrZWRDaGFuZ2VkID0gY2hlY2tlZCAhPT0gdGhpcy5fY2hlY2tlZDtcbiAgICAgICAgcmV0dXJuIGNoZWNrZWQ7XG4gICAgfVxuICAgIHRvZ2dsZSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgdGhpcy5jaGVja2VkID0gIXRoaXMuY2hlY2tlZDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcztcbiAgICB9XG4gICAgX2hhbmRsZUVudGVyKCkge1xuICAgICAgICBpZiAodHlwZW9mIHRoaXMub25FbnRlciA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5vbkVudGVyKHRoaXMpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy50b2dnbGUoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5vdW5jZSA9IGFubm91bmNlO1xuICAgIH1cbiAgICBnZXQgYW5ub3VuY2UoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZSB8fCAodGhpcy5jaGVja2VkID8gXCJDaGVja2VkXCIgOiBcIlVuY2hlY2t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G4gICAgICAgIHJldHVybiBbIC4uLnN1cGVyLnRhZ3MsIFwiSWNvblwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIucHJvcGVydGllcywgXCJpY29uV2lkdGhcIiwgXCJpY29uSGVpZ2h0XCIsIFwiaWNvblNyY1wiIF07XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHN1cGVyLl91cGRhdGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlSWNvbigpO1xuICAgIH1cbiAgICBfdXBkYXRlSWNvbigpIHtcbiAgICAgICAgdmFyIHtpY29uV2lkdGg6IGljb25XaWR0aCwgaWNvbkhlaWdodDogaWNvbkhlaWdodH0gPSB0aGlzLnN0eWxlO1xuICAgICAgICB2YXIgaWNvbk9iamVjdCA9IHtcbiAgICAgICAgICAgIHc6IGljb25XaWR0aCxcbiAgICAgICAgICAgIGg6IGljb25IZWlnaHQsXG4gICAgICAgICAgICBpY29uOiB0aGlzLmljb25TcmMsXG4gICAgICAgICAgICB4OiB0aGlzLncgLSBpY29uV2lkdGggLSB0aGlzLnN0eWxlLnBhZGRpbmdIb3Jpem9udGFsLFxuICAgICAgICAgICAgeTogKHRoaXMuX1RpdGxlLnN0eWxlLnRleHRTdHlsZS5saW5lSGVpZ2h0IC0gaWNvbkhlaWdodCkgLyAyICsgdGhpcy5zdHlsZS5wYWRkaW5nVmVydGljYWxcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKCF0aGlzLl9JY29uKSB7XG4gICAgICAgICAgICBpY29uT2JqZWN0LnR5cGUgPSBJY29uO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgSWNvbjogaWNvbk9iamVjdFxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX2NhbGN1bGF0ZVRleHRXaWR0aCgpIHtcbiAgICAgICAgdmFyIHRleHRXaWR0aCA9IH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H1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICB2YXIgY2VudGVyID0ge1xuICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgeDogdyA9PiB3IC8gMixcbiAgICAgICAgICAgIHk6IGggPT4gaCAvIDJcbiAgICAgICAgfTtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIEJvZHk6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgcnR0OiB0cnVlXG4gICAgICAgICAgICB9LCBjZW50ZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgIENoZWNrOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uXG4gICAgICAgICAgICAgICAgfSwgY2VudGVyKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IDBcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSksXG4gICAgICAgICAgICBTdHJva2U6IGNlbnRlclxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQ2hlY2tcIiwgXCJCb2R5XCIsIFwiU3Ryb2tlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImNoZWNrZWRcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcImNoZWNrU3JjXCIsXG4gICAgICAgICAgICBjdXJyOiBcImljb25cIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBwcmV2OiBcImNoZWNrSFwiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uSGVpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJjaGVja1dcIixcbiAgICAgICAgICAgIGN1cnI6IFwiaWNvbldpZHRoXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJjaGVja0hlaWdodFwiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uSGVpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJjaGVja1dpZHRoXCIsXG4gICAgICAgICAgICBjdXJyOiBcImljb25XaWR0aFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlQm9keSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVTdHJva2UoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ2hlY2soKTtcbiAgICAgICAgaWYgKHRoaXMuX2NoZWNrZWRDaGFuZ2VkKSB7XG4gICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkYW5ub3VuY2VcIiwgdGhpcy5hbm5vdW5jZSk7XG4gICAgICAgICAgICB0aGlzLl9jaGVja2VkQ2hhbmdlZCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3VwZGF0ZU9wYWNpdHkoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUNoZWNrKCkge1xuICAgICAgICB0aGlzLl9DaGVjay5wYXRjaCh7XG4gICAgICAgICAgICB3OiB0aGlzLnN0eWxlLmljb25XaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaWNvbkhlaWdodCxcbiAgICAgICAgICAgIGljb246IHRoaXMuc3R5bGUuaWNvbixcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY2hlY2tDb2xvclxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdmFyIGFscGhhUGF0Y2ggPSB7XG4gICAgICAgICAgICBhbHBoYTogdGhp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G4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBCYWNrZ3JvdW5kOiB7fSxcbiAgICAgICAgICAgIFRleHQ6IHtcbiAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICAgICAgdGV4dDoge31cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkxhYmVsXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHo7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJ0aXRsZVwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJCYWNrZ3JvdW5kXCIsIFwiVGV4dFwiIF07XG4gICAgfVxuICAgIF9pbml0KCkge1xuICAgICAgICB0aGlzLl9UZXh0Lm9uKFwidHhMb2FkZWRcIiwgdGhpcy5fdXBkYXRlQmFja2dyb3VuZC5iaW5kKHRoaXMpKTtcbiAgICAgICAgc3VwZXIuX2luaXQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlQmFja2dyb3VuZCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVUZXh0KCk7XG4gICAgfVxuICAgIF91cGRhdGVUZXh0KCkge1xuICAgICAgICBpZiAodGhpcy5fVGV4dCkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgdGV4dDogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICA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c3MgZXh0ZW5kcyBCYXNlIHtcbiAgICAgICAgc3RhdGljIGdldCBuYW1lKCkge1xuICAgICAgICAgICAgcmV0dXJuIEJhc2UubmFtZTtcbiAgICAgICAgfVxuICAgICAgICBfaW5pdCgpIHtcbiAgICAgICAgICAgIHN1cGVyLl9pbml0KCk7XG4gICAgICAgICAgICBpZiAodGhpcy5fc2hvdWxkU3luYykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVNpZ25hbHMoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBfdXBkYXRlKCkge1xuICAgICAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3Nob3VsZFN5bmMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVTaWduYWxzKCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NsZWFudXBTeW5jVmFsdWVzKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX2NsZWFudXBTeW5jVmFsdWVzKCkge1xuICAgICAgICAgICAgdGhpcy5zeW5jQXJyYXkubWFwKChjb21wb25lbnQgPT4ge1xuICAgICAgICAgICAgICAgIGNvbXBvbmVudC5tYXJxdWVlT3ZlcnJpZGVMb29wWCA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICBjb21wb25lbnQuc2lnbmFscyAmJiBjb21wb25lbnQuc2lnbmFscy53aWxsTWFycXVlZSAmJiBkZWxldGUgY29tcG9uZW50LnNpZ25hbHMud2lsbE1hcnF1ZWU7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICAgICAgX3VwZGF0ZVNpZ25hbHMoKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5zeW5jQXJyYXkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnN5bmNBcnJheS5tYXAoKGNvbXBvbmVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudC5zaWduYWxzID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBjb21wb25lbnQuc2lnbmFscyksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB3aWxsTWFycXVlZTogXCJfd2lsbE1hcnF1ZWVcIlxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX3dpbGxNYXJxdWVlKGNvbXBSZWYpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9zaG91bGRTeW5jKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbG9uZ2VzdE1hcnF1ZWVXaWR0aCA9IE1hdGgubWF4KGNvbXBSZWYuX3RleHRSZW5kZXJlZFcgfHwgMCwgdGhpcy5fbG9uZ2VzdE1hcnF1ZWVXaWR0aCB8fCAwKTtcbiAgICAgICAgICAgICAgICB0aGlzLnN5bmNBcnJheS5tYXAoKGNvbXBvbmVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudC5tYXJxdWVlT3ZlcnJpZGVMb29wWCA9IHRoaXMuX2xvbmdlc3RNYXJxdWVlV2lkdGg7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGdldCBfc2hvdWxkU3luYygpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnN0eWxlLm1hcnF1ZWVTeW5jID09PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghdGhpcy5zeW5jQXJyYXkpIHtcbiAgICAgICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS53YXJuKFwid2FybmluZzogY29tcG9uZW50cyB1c2luZyBNYXJxdWVlU3luYyBtdXN0IGhhdmUgYSBzeW5jQXJyYXkgZ2V0dGVy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ICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgaW52ZXJzZToge1xuICAgICAgICB0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVxuICAgICAgICB9LFxuICAgICAgICBzdWJ0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVNlY29uZGFyeVxuICAgICAgICB9LFxuICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlXG4gICAgICAgIH0sXG4gICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGRpc2FibGVkOiB7XG4gICAgICAgICAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIHN1YnRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgfSxcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICB0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyR5ID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkeSxcbiAgICBtb2RlOiBtb2RlJDksXG4gICAgdG9uZTogdG9uZSRoXG59KTtcblxuY2xhc3MgTWV0YWRhdGFCYXNlIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTWV0YWRhdGFCYXNlXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHk7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgZmxleDoge1xuICAgICAgICAgICAgICAgICAgICBkaXJlY3Rpb246IFwiY29sdW1uXCIsXG4gICAgICAgICAgICAgICAgICAgIGp1c3RpZnlDb250ZW50OiBcImZsZXgtc3RhcnRcIlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgRGV0YWlsc1dyYXBwZXI6IHt9XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJkZXNjcmlwdGlvblwiLCBcImxvZ29cIiwgXCJsb2dvSGVpZ2h0XCIsIFwibG9nb1Bvc2l0aW9uXCIsIFwibG9nb1RpdGxlXCIsIFwibG9nb1dpZHRoXCIsIFwiZGV0YWlsc1wiLCBcInN1YnRpdGxlXCIsIFwidGl0bGVcIiwgXCJtYXJxdWVlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIlRleHRcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJUaXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LlRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTdWJ0aXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LlN1YnRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXRhaWxzV3JhcHBlclwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LkRldGFpbHNXcmFwcGVyXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXRhaWxzXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHQuRGV0YWlsc1dyYXBwZXIuRGV0YWlsc1wiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwi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cG9uZW50RGltZW5zaW9uc1wiKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlVGl0bGUoKSB7XG4gICAgICAgIGlmICghdGhpcy50aXRsZSAmJiAhdGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LmNoaWxkTGlzdC5hZGRBdCh7XG4gICAgICAgICAgICAgICAgcmVmOiBcIlRpdGxlXCIsXG4gICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl90aXRsZUxvYWRlZFwiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgMCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fVGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgIG1hcnF1ZWU6IHRoaXMubWFycXVlZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlU3VidGl0bGUoKSB7XG4gICAgICAgIGlmICghdGhpcy5zdWJ0aXRsZSAmJiAhdGhpcy5fU3VidGl0bGUpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX1N1YnRpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LmNoaWxkTGlzdC5hZGRBdCh7XG4gICAgICAgICAgICAgICAgcmVmOiBcIlN1YnRpdGxlXCIsXG4gICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9zdWJ0aXRsZUxvYWRlZFwiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgMSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fU3VidGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5zdWJ0aXRsZSxcbiAgICAgICAgICAgIG1hcnF1ZWU6IHRoaXMubWFycXVlZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuc3VidGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICByZXNldE1hcnF1ZWUoKSB7XG4gICAgICAgIGlmICh0aGlzLm1hcnF1ZWUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnRpdGxlKSB7XG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVUaXRsZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLl9UaXRsZS50b2dnbGVNYXJxdWVlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5kZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fRGVzY3JpcHRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlRGVzY3JpcHRpb24oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fRGVzY3JpcHRpb24udG9nZ2xlTWFycXVlZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVEZXRhaWxzKCkge1xuICAgICAgICBpZiAoIXRoaXMuZGV0YWlscyAmJiAhdGhpcy5fRGV0YWlscykge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fRGV0YWlscykge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlsc1dyYXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgICAgIERldGFpbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX2RldGFpbHNMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fRGV0YWlscy5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLmRldGFpbHMsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS5kZXRhaWxzVGV4dFN0eWxlXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBpZiAodGhpcy5fRGV0YWlscy5maW5hbFcgPiB0aGlzLl90ZXh0VygpKSB7XG4gICAgICAgICAgICB0aGlzLl9EZXRhaWxzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICB3OiB0aGlzLl90ZXh0VygpICsgdGhpcy5zdHlsZS5mYWRlV2lkdGggLyAyLFxuICAgICAgICAgICAgICAgIHNoYWRlcjoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBGYWRlU2hhZGVyLFxuICAgICAgICAgICAgICAgICAgICBwb3NpdGlvbkxlZnQ6IDAsXG4gICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uUmlnaHQ6IHRoaXMuc3R5bGUuZmFkZVdpZHRoXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBydHQ6IHRydWVcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlsc1dyYXBwZXIuc2hhZGVyID0gdW5kZWZpbmVkO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX0RldGFpbHNXcmFwcGVyLnZpc2libGUgPSB0aGlzLmRldGFpbHMgPyB0cnVlIDogZmFsc2U7XG4gICAgICAgIHRoaXMuX0RldGFpbHNXcmFwcGVyLmFscGhhID0gdGhpcy5zdHlsZS5hbHBoYTtcbiAgICB9XG4gICAgX3VwZGF0ZURlc2NyaXB0aW9uKCkge1xuICAgICAgICBpZiAoIXRoaXMuZGVzY3JpcHRpb24gJiYgIXRoaXMuX0Rlc2NyaXB0aW9uKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLl9EZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5jaGlsZExpc3QuYWRkKHtcbiAgICAgICAgICAgICAgICByZWY6IFwiRGVzY3JpcHRpb25cIixcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX2Rlc2NyaXB0aW9uTG9hZGVkXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9EZXNjcmlwdGlvbi5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLmRlc2NyaXB0aW9uLFxuICAgICAgICAgICAgbWFycXVlZTogdGhpcy5tYXJxdWVlLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXNjcmlwdGlvblRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogdGhpcy5fVGV4dC53XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVMb2dvKCkge1xuICAgICAgICBpZiAoIXRoaXMubG9nbyAmJiAhdGhpcy5fTG9nbykge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fTG9nbykge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgTG9nbzoge1xuICAgICAgICAgICAgICAgICAgICBmbGV4SXRlbTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEljb25cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmxvZ29Qb3NpdGlvbiA9IHRoaXMubG9nb1Bvc2l0aW9uIH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leHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGRpc2FibGVkOiB7XG4gICAgICAgICAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJHggPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSR4LFxuICAgIHRvbmU6IHRvbmUkZ1xufSk7XG5cbmNsYXNzIE1ldGFkYXRhVGlsZSBleHRlbmRzIE1ldGFkYXRhQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTWV0YWRhdGFUaWxlXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHg7XG4gICAgfVxuICAgIF91cGRhdGVEZXRhaWxzKCkge1xuICAgICAgICBpZiAoIXRoaXMuZGV0YWlscyAmJiAhdGhpcy5fRGV0YWlscykge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmRlc2NyaXB0aW9uICYmIHRoaXMuX0RldGFpbHMpIHtc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ICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZUJyYW5kRm9jdXNTb2Z0XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIG1vZGUkOCA9IHRoZW1lID0+ICh7XG4gICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgYWxwaGE6IHRoZW1lLmFscGhhLmluYWN0aXZlXG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkdiA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJHYsXG4gICAgbW9kZTogbW9kZSQ4LFxuICAgIHRvbmU6IHRvbmUkZVxufSk7XG5cbmNsYXNzIFRpbGUgZXh0ZW5kcyBTdXJmYWNlIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiVGlsZVwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyR2O1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fdGVtcGxhdGUoKSksIHt9LCB7XG4gICAgICAgICAgICBUaWxlOiB7XG4gICAgICAgICAgICAgICAgQXJ0d29yazoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBBcnR3b3JrLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbWFnZUxvYWRlZDogXCJfaW1hZ2VMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBtb3VudDogLjVcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIENvbnRlbnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnQ6IC41XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImFydHdvcmtcIiwgXCJiYWRnZVwiLCBcImNoZWNrYm94XCIsIFwiY2lyY2xlXCIsIFwibGFiZWxcIiwgXCJsb2dvXCIsIFwibWV0YWRhdGFcIiwgXCJtZXRhZGF0YUxvY2F0aW9uXCIsIFwicGVyc2lzdGVudE1ldGFkYXRhXCIsIFwicHJvZ3Jlc3NCYXJcIiwgXCJzcmNcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcImljb25IZWlnaHRcIixcbiAgICAgICAgICAgIGN1cnI6IFwibG9nb0hlaWdodFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIHByZXY6IFwiaWNvbldpZHRoXCIsXG4gICAgICAgICAgICBjdXJyOiBcImxvZ29XaWR0aFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBhbGlhc1Byb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIHtcbiAgICAgICAgICAgIHByZXY6IFwiaWNvblNyY1wiLFxuICAgICAgICAgICAgY3VycjogXCJsb2dvXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIC4uLnN1cGVyLnRhZ3MsIFwiQXJ0d29ya1wiLCBcIkNvbnRlbnRcIiwgXCJUaWxlXCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiQmFkZ2VcIixcbiAgICAgICAg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F0sIHRoaXMuX2lzRm9jdXNlZE1vZGUgPyB0aGlzLnN0eWxlLmFuaW1hdGlvbkVudHJhbmNlIDogdGhpcy5zdHlsZS5hbmltYXRpb25FeGl0IF07XG4gICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICB9KSwge30pKTtcbiAgICB9XG4gICAgX3VwZGF0ZUxvZ28oKSB7XG4gICAgICAgIGlmICghdGhpcy5sb2dvKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBMb2dvOiB1bmRlZmluZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBsb2dvT2JqZWN0ID0ge1xuICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5sb2dvV2lkdGgsXG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmxvZ29IZWlnaHQsXG4gICAgICAgICAgICBpY29uOiB0aGlzLmxvZ28sXG4gICAgICAgICAgICBhbHBoYTogdGhpcy5fc2hvdWxkU2hvd0xvZ28gPyB0aGlzLnN0eWxlLmFscGhhIDogLjAwMSxcbiAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUucGFkZGluZ1gsXG4gICAgICAgICAgICB5OiB0aGlzLl9jYWxjdWxhdGVMb2dvWVBvc2l0aW9uKClcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKCF0aGlzLl9Mb2dvKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBMb2dvOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAxXG4gICAgICAgICAgICAgICAgfSwgbG9nb09iamVjdClcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9Mb2dvLCBsb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XIgYmFkZ2VQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5iYWRnZSksIHt9LCB7XG4gICAgICAgICAgICBtb2RlOiB0aGlzLm1vZGUsXG4gICAgICAgICAgICB4OiB0aGlzLnN0eWxlLnBhZGRpbmdYLFxuICAgICAgICAgICAgeTogdGhpcy5zdHlsZS5wYWRkaW5nWSxcbiAgICAgICAgICAgIGFscGhhOiB0aGlzLl9zaG91bGRTaG93QmFkZ2VMYWJlbCA/IDEgOiAuMDAxXG4gICAgICAgIH0pO1xuICAgICAgICBpZiAoIXRoaXMuX0JhZGdlKSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBCYWRnZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQmFkZ2VcbiAgICAgICAgICAgICAgICB9LCBiYWRnZVBhdGNoKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkQmFkZ2U6IFwiX3VwZGF0ZUJhZGdlXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX0JhZGdlLnBhdGNoKGJhZGdlUGF0Y2gpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuYXBwbHlTbW9vdGgodGhpcy5fQmFkZ2UsIGJhZGdlUGF0Y2gsIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgYmFkZ2VQYXRjaCksIHRoaXMuX2JhZGdlTGFiZWxUcmFuc2l0aW9ucykpO1xuICAgIH1cbiAgICBfdXBkYXRlTGFiZWwoKSB7XG4gICAgICAgIHZhciBfdGhpcyRsYWJlbDtcbiAgICAgICAgaWYgKCEoKF90aGlzJGxhYmVsID0gdGhpcy5sYWJlbCkgIT09IG51bGwgJiYgX3RoaXMkbGFiZWwgIT09IHZvaWQgMCAmJiBfdGhpcyRsYWJlbC50aXRsZSkgfHwgdGhpcy5faXNDaXJjbGVMYXlvdXQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9MYWJlbCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBMYWJlbDogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGxhYmVsUGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMubGFiZWwpLCB7fSwge1xuICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgeDogdGhpcy5fdyAtIHRoaXMuc3R5bGUucGFkZGluZ1gsXG4gICAgICAgICAgICB5OiB0aGlzLnN0eWxlLnBhZGRpbmdZLFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuX3Nob3VsZFNob3dCYWRnZUxhYmVsID8gMSA6IC4wMDFcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICghdGhpcy5fTGFiZWwpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIExhYmVsOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBMYWJlbCxcbiAgICAgICAgICAgICAgICAgICAgbW91bnRYOiAxXG4gICAgICAgICAgICAgICAgfSwgbGFiZWxQYXRjaCksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZExh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3dCYWRnZUxhYmVsID8gMSA6IC4wMDEsIHRoaXMuX3Nob3VsZFNob3dCYWRnZUxhYmVsID8gdGhpcy5zdHlsZS5hbmltYXRpb25FbnRyYW5jZSA6IHRoaXMuc3R5bGUuYW5pbWF0aW9uRXhpdCBdXG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVDaGVja2JveCgpIHtcbiAgICAgICAgdmFyIF90aGlzJGNoZWNrYm94O1xuICAgICAgICBpZiAoISh0eXBlb2YgKChfdGhpcyRjaGVja2JveCA9IHRoaXMuY2hlY2tib3gpID09PSBudWxsIHx8IF90aGlzJGNoZWNrYm94ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRjaGVja2JveC5jaGVja2VkKSA9PT0gXCJib29sZWFuXCIgJiYgdGhpcy5jaGVja2JveC5jaGVja2VkKSB8fCB0aGlzLl9pc0NpcmNsZUxheW91dCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX0NoZWNrYm94KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIENoZWNrYm94OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgY2hlY2tib3hQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5jaGVja2JveCksIHt9LCB7XG4gICAgICAgICAgICBtb2RlOiB0aGlzLm1vZGUsXG4gICAgICAgICAgICB4OiB0aGlzLl93IC0gdGhpcy5zdHlsZS5wYWRkaW5nWCxcbiAgICAgICAgICAgIHk6IHRoaXMuX2ggLSB0aGlzLnN0eWxlLnBhZGRpbmdZXG4gICAgICAgIH0pO1xuICAgICAgICBpZiAoIXRoaXMuX0NoZWNrYm94KSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcb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biAgICAgICAgICAgICAgICBpZiAodGhpcy5zaG91bGRTbW9vdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fUHJvZ3Jlc3NCYXIuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW1vdmVQcm9ncmVzc0JhcigpO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX1Byb2dyZXNzQmFyLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFscGhhOiAwXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVtb3ZlUHJvZ3Jlc3NCYXIoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMucHJvZ3Jlc3NCYXIucHJvZ3Jlc3MgPiAwKSB7XG4gICAgICAgICAgICB2YXIgcHJvZ3Jlc3NQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5wcm9ncmVzc0JhciksIHt9LCB7XG4gICAgICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgICAgIHc6IHRoaXMuX3cgLSB0aGlzLnN0eWxlLnBhZGRpbmdYICogMixcbiAgICAgICAgICAgICAgICB4OiB0aGlzLl93IC8gMixcbiAgICAgICAgICAgICAgICB5OiB0aGlzLl9oIC0gdGhpcy5zdHlsZS5wYWRkaW5nWVByb2dyZXNzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fUHJvZ3Jlc3NCYXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgUHJvZ3Jlc3NCYXI6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgcHJvZ3Jlc3NQYXRjaCksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBQcm9ncmVzc0JhcixcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICAgICAgICAgICAgICBtb3VudFk6IDEsXG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogdGhpcy5faGFzTWV0YWRhdGEgJiYgdGhpcy5zaG91bGRTbW9vdGggPyAuMDAxIDogMVxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNob3VsZFNtb290aCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9Qcm9ncmVzc0Jhci5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogWyAxLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXk6IHRoaXMuc3R5bGUuYW5pbWF0aW9uRW50cmFuY2UuZHVyYXRpb25cbiAgICAgICAgICAgICAgICAgICAgICAgIH0gXVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmFwcGx5U21vb3RoKHRoaXMuX1Byb2dyZXNzQmFyLCBwcm9ncmVzc1BhdGNoLCBPYmplY3Qua2V5cyhwcm9ncmVzc1BhdGNoKS5yZWR1Y2UoKChhY2MsIHByb3ApID0+IHtcbiAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSBbIHByb2dyZXNzUGF0Y2hbcHJvcF0sIHRoaXMuX2lzRm9jdXNlZE1vZGUgPyB0aGlzLnN0eWxlLmFuaW1hdGlvbkVudHJhbm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ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBNZXRhZGF0YVRpbGUsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUNvbXBvbmVudERpbWVuc2lvbnM6IFwiX21ldGFkYXRhTG9hZGVkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIHRoaXMuX25vblNtb290aGluZ01ldGFkYXRhUGF0Y2gpLCB0aGlzLl9tZXRhZGF0YVBhdGNoKVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fTWV0YWRhdGEucGF0Y2godGhpcy5fbm9uU21vb3RoaW5nTWV0YWRhdGFQYXRjaCk7XG4gICAgICAgIHRoaXMuX2FuaW1hdGVNZXRhZGF0YSgpO1xuICAgIH1cbiAgICBfYW5pbWF0ZU1ldGFkYXRhKCkge1xuICAgICAgICBpZiAoIXRoaXMuX01ldGFkYXRhKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9NZXRhZGF0YSwgdGhpcy5fbWV0YWRhdGFQYXRjaCwgdGhpcy5fbWV0YWRhdGFUcmFuc2l0aW9ucyk7XG4gICAgICAgIGlmICghdGhpcy5faXNGb2N1c2VkTW9kZSkge1xuICAgICAgICAgICAgdGhpcy5fcmVzZXRNYXJxdWVlQW5pbWF0aW9uKCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX21ldGFkYXRhTG9hZGVkKCkge1xuICAgICAgICB0aGlzLl9hbmltYXRlTWV0YWRhdGEoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlTG9nbygpO1xuICAgICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgICAgIGlmICghdGhpcy5faXNJbnNldE1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JvdmlkZXIudHlwZSA9PT0gSWNvbiAmJiBwcm92aWRlci5pY29uICYmIHByb3ZpZGVyLncgJiYgcHJvdmlkZXIuaCkge1xuICAgICAgICAgICAgICAgIHZhciByYXRpbyA9IHByb3ZpZGVyLncgLyBwcm92aWRlci5oO1xuICAgICAgICAgICAgICAgIHBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgaWNvbjogcHJvdmlkZXIuaWNvblxuICAgICAgICAgICAgICAgIH0sIHByb3ZpZGVyKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pdGVtU2l6ZSAqIHJhdGlvLFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLml0ZW1TaXplXG4gICAgICAgICAgICAgICAgfSwgcGF0Y2gpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwYXRjaCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLnN0eWxlLml0ZW1TaXplLFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLml0ZW1TaXplXG4gICAgICAgICAgICAgICAgfSwgcGF0Y2gpO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcHJvdmlkZXIgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICAgICAgcGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHBhdGNoKSwgcHJvdmlkZXIpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHBhdGNoLmljb24gPSBwcm92aWRlcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcm92aWRlckxpc3QucHVzaChwYXRjaCk7XG4gICAgICAgIH0pKTtcbiAgICAgICAgdGhpcy5fUm93LnBhdGNoKHtcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUuaXRlbVNwYWNpbmdcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBpdGVtczogcHJvdmlkZXJMaXN0LFxuICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5pdGVtU2l6ZVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZUNvdW50ZXIoKSB7XG4gICAgICAgIGlmICh0aGlzLnByb3ZpZGVycy5sZW5ndGggPiB0aGlzLnZpc2libGVDb3VudCkge1xuICAgICAgICAgICAgdmFyIHJlbWFpbmluZyA9IHRoaXMucHJvdmlkZXJzSGlkZGVuO1xuICAgICAgICAgICAgdmFyIGNvdW50ZXIgPSB7XG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiK1wiLmNvbmNhdChyZW1haW5pbmcpLFxuICAgICAgICAgICAgICAgIGFscGhhOiB0aGlzLnN0eWxlLmFscGhhLFxuICAgICAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUuaXRlbVNpemUsXG4gICAgICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5pdGVtU2l6ZSxcbiAgICAgICAgICAgICAgICBjZW50ZXJJblBhcmVudDogdHJ1ZSxcbiAgICAgICAgICAgICAgICBCYWNrZ3JvdW5kOiB7XG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUuaXRlbVNpemUsXG4gICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaXRlbVNpemUsXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmU6IGxuZy5Ub29scy5nZXRSb3VuZFJlY3QodGhpcy5zdHlsZS5pdGVtU2l6ZSwgdGhpcy5zdHlsZS5pdGVtU2l6ZSwgZ2V0TWF4Um91bmRSYWRpdXModGhpcy5zdHlsZS5yYWRpdXMsIHRoaXMuc3R5bGUuaXRlbVNpemUsIHRoaXMuc3R5bGUuaXRlbVNpemUpLCAwLCBudWxsLCB0cnVlLCB0aGlzLnN0eWxlLmNvdW50ZXJCYWNrZ3JvdW5kQ29sb3IpXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUuaXRlbVNpemUgLyAyLFxuICAgICAgICAgICAgICAgICAgICB5OiB0aGlzLnN0eWxlLml0ZW1TaXplIC8gMixcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogdGhpcy5jb3VudGVyVGV4dCB8fCBcIitcIi5jb25jYXQocmVtYWluaW5nKSxcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS5jb3VudGVyVGV4dFN0eWxlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgdGhpcy5fUm93LmFwcGVuZEl0ZW1zKFsgY291bnRlciBdKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICAkaXRlbUNoYW5nZWQoKSB7XG4gICAgICAgIHRoaXMuc2lnbmFsKFwicHJvdmlkZXJDaGFuZ2VkXCIpO1xuICAgIH1cbiAgICBfZ2V0VmlzaWJsZUNvdW50KCkge1xuICAgICAgICB2YXIgbWluID0gMTtcbiAgICAgICAgdmFyIG1heCA9IHRoaXMucHJvdmlkZXJzLmxlbmd0aDtcbiAgICAgICAgdmFyIHZpc2libGVDb3VudCA9IE1hdGgubWluKE1hdGgubW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KSk7XG4gICAgfVxufVxuXG52YXIgYmFzZSR0ID0gdGhlbWUgPT4gKHtcbiAgICBkZXRhaWxzVGV4dFN0eWxlOiB0aGVtZS50eXBvZ3JhcGh5LmJvZHkzLFxuICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgIG1heExpbmVzOiAzXG4gICAgfSxcbiAgICBkZXNjcmlwdGlvbkRldGFpbHNTdHlsZToge1xuICAgICAgICBwYWRkaW5nWTogNVxuICAgIH0sXG4gICAgZmFkZVdpZHRoOiB0aGVtZS5zcGFjZXIubWQgKiB0aGVtZS5zcGFjZXIubWQsXG4gICAgcHJvdmlkZXI6IHtcbiAgICAgICAgaXRlbVNpemU6IHRoZW1lLnNwYWNlci54eHhsICsgdGhlbWUuc3BhY2VyLm1kXG4gICAgfVxufSk7XG5cbnZhciB0b25lJGMgPSB0aGVtZSA9PiAoe1xuICAgIG5ldXRyYWw6IHtcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkdCA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJHQsXG4gICAgdG9uZTogdG9uZSRjXG59KTtcblxuY2xhc3MgTWV0YWRhdGFDYXJkQ29udGVudCBleHRlbmRzIE1ldGFkYXRhQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTWV0YWRhdGFDYXJkQ29udGVudFwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyR0O1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgVGV4dDoge1xuICAgICAgICAgICAgICAgIGZsZXg6IHtcbiAgICAgICAgICAgICAgICAgICAgZGlyZWN0aW9uOiBcImNvbHVtblwiLFxuICAgICAgICAgICAgICAgICAgICBqdXN0aWZ5Q29udGVudDogXCJmbGV4LXN0YXJ0XCJcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFRpdGxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFN1YnRpdGxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIERlc2NyaXB0aW9uOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIERlc2NyaXB0aW9uRGV0YWlsczoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIERldGFpbHNXcmFwcGVyOiB7XG4gICAgICAgICAgICAgICAgRGV0YWlsc0ZhZGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIERldGFpbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9yZXNvbHZlRGV0YWlsc1wiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFByb3ZpZGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAxLFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBQcm92aWRlcixcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvdmlkZXJDaGFuZ2VkOiBcIl9yZXNvbHZlUHJvdmlkZXJcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiZGVzY3JpcHRpb25cIiwgXCJkZXNjcmlwdGlvbkRldGFpbHNcIiwgXCJkZXRhaWxzXCIsIFwicHJvdmlkZXJcIiwgXCJzdWJ0aXRsZVwiLCBcInRpdGxlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIlRleHRcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJUaXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LlRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTdWJ0aXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LlN1YnRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXNjcmlwdGlvblwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LkRlc2NyaXB0aW9uXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXNjcmlwdGlvbkRldGFpbHNcIixcbiAgICAgICAgICAgIHBhdGg6IFwiVGV4dC5EZXNjcmlwdGlvbkRldGFpbHNcIlxuICAgICAgICB9LCBcIkRldGFpbHNXcmFwcGVyXCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiRGV0YWlsc0ZhZGVyXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkRldGFpbHNXcmFwcGVyLkRldGFpbHNGYWRlclwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiRGV0YWlsc1wiLFxuICAgICAgICAgICAgcGF0aDogXCJEZXRhaWxzV3JhcHBlci5EZXRhaWxzRmFkZXIuRGV0YWlsc1wiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiUHJvdmlkZXJcIixcbiAgICAgICAgICAgIHBhdGg6IFwiRGV0YWlsc1dyYXBwZXIuUHJvdmlkZXJcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF9zZXREZXRhaWxzKGRldGFpbHMpIHtcbiAgICAgICAgaWYgKGRldGFpbHMpIHtcbiAgICAgICAgICAgIHRoaXMuX2RldGFpbHNQcm9taXNlID0gbmV3IFByb21pc2UoKHJlc29sdmUgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuX2RldGFpbHNQcm9taXNlUmVzb2x2ZXIgPSByZXNvbHZlO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZGV0YWlsc1Byb21pc2UgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGRldGFpbHM7XG4gICAgfVxuICAgIF9zZXRQcm92aWRlcihwcm92aWRlcikge1xuICAgICAgICBpZiAocHJvdmlkZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX3Byb3ZpZGVyUHJvbWlzZSA9IG5ldyBQcm9taXNlKChyZXNvbHZlID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wcm92aWRlclByb21pc2VSZXNvbHZlciA9IHJlc29sdmU7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9wcm92aWRlclByb21pc2UgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHByb3ZpZGVyO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB2YXIgX3RoaXM5ID0gdGhpcztcbiAgICAgICAgcmV0dXJuIF9hc3luY1RvR2VuZXJhdG9yKCh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ICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnN1YnRpdGxlVGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgbWF4TGluZXM6IDEsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9UZXh0LndcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZURlc2NyaXB0aW9uKCkge1xuICAgICAgICB0aGlzLl9EZXNjcmlwdGlvbi5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLmRlc2NyaXB0aW9uLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXNjcmlwdGlvblRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9UZXh0LndcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZURlc2NyaXB0aW9uRGV0YWlscygpIHtcbiAgICAgICAgdGhpcy5fRGVzY3JpcHRpb25EZXRhaWxzLnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGVzY3JpcHRpb25EZXRhaWxzLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXNjcmlwdGlvbkRldGFpbHNUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgeTogdGhpcy5zdHlsZS5kZXNjcmlwdGlvbkRldGFpbHNTdHlsZS5wYWRkaW5nWVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZURldGFpbHMoKSB7XG4gICAgICAgIHZhciBtYXhXaWR0aCA9IHRoaXMuX2RldGFpbHNNYXhXO1xuICAgICAgICB0aGlzLl9EZXRhaWxzLnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGV0YWlscyxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuZGV0YWlsc1RleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogbWF4V2lkdGggKyB0aGlzLnN0eWxlLmZhZGVXaWR0aCAvIDJcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgaWYgKHRoaXMuX0RldGFpbHMuZmluYWxXID4gbWF4V2lkdGgpIHtcbiAgICAgICAgICAgIHRoaXMuX0RldGFpbHNGYWRlci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgdzogbWF4V2lkdGggKyB0aGlzLnN0eWxlLmZhZGVXaWR0aCAvIDIsXG4gICAgICAgICAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEZhZGVTaGFkZXIsXG4gICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uTGVmdDogMCxcbiAgICAgICAgICAgICAgICAgICAgcG9zaXRpb25SaWdodDogdGhpcy5zdHlsZS5mYWRlV2lkdGhcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX0RldGFpbHNGYWRlci5zaGFkZXIgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3Jlc29sdmVEZXRhaWxzKCkge1xuICAgICAgICB0aGlzLl9kZXRhaWxzUHJvbWlzZVJlc29sdmVyICYmIHRoaXMuX2RldGFpbHNQcm9taXNlUmVzb2x2ZXIoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlUG9zaXRpb25zKCk7XG4gICAgfVxuICAgIF91cGRhdGVQcm92aWRlcigpIHtcbiAgICAgICAgaWYgKHRoaXMucHJvdmlkZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX1Byb3ZpZGVyLnBhdGNoKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlXG4gICAgICAgICAgICB9LCB0aGlzLnByb3ZpZGVyKSwge30sIHtcbiAgICAgICAgICAgICAgICBzdHlsZTogdGhpcy5zdHlsZS5wcm92aWRlclxuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9yZXNvbHZlUHJvdmlkZXIoKSB7XG4gICAgICAgIHRoaXMuX3Byb3ZpZGVyUHJvbWlzZVJlc29sdmVyICYmIHRoaXMuX3Byb3ZpZGVyUHJvbWlzZVJlc29sdmVyKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVBvc2l0aW9ucygpO1xuICAgICAg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gICAgICAgICAgIHVwQ291bnQ6IDRcbiAgICAgICAgfSkudyxcbiAgICAgICAgaGVpZ2h0OiB1dGlscyQxLmdldERpbWVuc2lvbnModGhlbWUsIHtcbiAgICAgICAgICAgIHJhdGlvWDogMTYsXG4gICAgICAgICAgICByYXRpb1k6IDksXG4gICAgICAgICAgICB1cENvdW50OiA0XG4gICAgICAgIH0pLmhcbiAgICB9LFxuICAgIG1ldGFkYXRhOiB7XG4gICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICBtYXhMaW5lczogMlxuICAgICAgICB9XG4gICAgfSxcbiAgICBwYWRkaW5nVmVydGljYWw6IHRoZW1lLnNwYWNlci5tZCAqIDEuNVxufSk7XG5cbnZhciBzdHlsZXMkcyA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJHNcbn0pO1xuXG5jbGFzcyBDYXJkQ29udGVudCBleHRlbmRzIENhcmQge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJDYXJkQ29udGVudFwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRzO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fdGVtcGxhdGUoKSksIHt9LCB7XG4gICAgICAgICAgICBUaWxlOiB7XG4gICAgICAgICAgICAgICAgdHlwZTogVGlsZVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci5wcm9wZXJ0aWVzLCBcInRpbGVcIiwgXCJtZXRhZGF0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250YWxcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkcztcbiAgICB9XG4gICAgX2luaXQoKSB7XG4gICAgICAgIHRoaXMuX29yaWVudGF0aW9uID0gXCJob3Jpem9udGFsXCI7XG4gICAgICAgIHN1cGVyLl9pbml0KCk7XG4gICAgfVxufVxuXG52YXIgYmFzZSRyID0gdGhlbWUgPT4ge1xuICAgIHZhciB7dzogdywgaDogaH0gPSB1dGlscyQxLmdldERpbWVuc2lvbnModGhlbWUsIHtcbiAgICAgICAgcmF0aW9YOiAxNixcbiAgICAgICAgcmF0aW9ZOiA5LFxuICAgICAgICB1cENvdW50OiAzXG4gICAgfSk7XG4gICAgcmV0dXJuIHtcbiAgICAgICAgZXhwYW5kZWRXaWR0aDogdXRpbHMkMS5nZXRXaWR0aEJ5Q29sdW1uU3Bhbih0aGVtZSwgOCksXG4gICAgICAgIGV4cGFuZGVkSGVpZ2h0OiBoLFxuICAgICAgICBpbWFnZVNpemU6IHtcbiAgICAgICAgICAgIHdpZHRoOiB3LFxuICAgICAgICAgICAgaGVpZ2h0OiBoXG4gICAgICAgIH0sXG4gICAgICAgIG1ldGFkYXRhOiB7XG4gICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgIG1heExpbmVzOiAzXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xufTtcblxudmFyIHN0eWxlcyRyID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkclxufSk7XG5cbmNsYXNzIENhcmRDb250ZW50SG9yaXpvbnRhbExhcmdlIGV4dGVuZHMgQ2FyZENvbnRlbnRIb3Jpem9udGFsIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiQ2FyZENvbnRlbn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dXBlci5faW5pdCgpO1xuICAgIH1cbn1cblxudmFyIGJhc2UkcCA9IHRoZW1lID0+ICh7XG4gICAgZXhwYW5kZWRIZWlnaHQ6IHV0aWxzJDEuZ2V0RGltZW5zaW9ucyh0aGVtZSwge1xuICAgICAgICByYXRpb1g6IDE2LFxuICAgICAgICByYXRpb1k6IDksXG4gICAgICAgIHVwQ291bnQ6IDRcbiAgICB9KS5oICsgdGhlbWUuc3BhY2VyLm1kICogMTQsXG4gICAgbWV0YWRhdGE6IHtcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIG1heExpbmVzOiAxXG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRwID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkcFxufSk7XG5cbmNsYXNzIENhcmRDb250ZW50VmVydGljYWxTbWFsbCBleHRlbmRzIENhcmRDb250ZW50VmVydGljYWwge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJDYXJkQ29udGVudFZlcnRpY2FsU21hbGxcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkcDtcbiAgICB9XG4gICAgX3NldE1ldGFkYXRhKG1ldGFkYXRhKSB7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIG1ldGFkYXRhKSwge30sIHtcbiAgICAgICAgICAgIGRldGFpbHM6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgIHByb3ZpZGVyOiB1bmRlZmluZWRcbiAgICAgICAgfSk7XG4gICAgfVxufVxuXG52YXIgYmFzZSRvID0gdGhlbWUgPT4ge1xuICAgIHZhciBzdHJva2VXaWR0aCA9IHRoZW1lLnN0cm9rZS5zbTtcb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WRkaW5nXCIsXG4gICAgICAgICAgICBjdXJyOiBcImNvbnRlbnRTcGFjaW5nXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhTdHlsZSgpO1xuICAgICAgICBzdXBlci5fdXBkYXRlVGl0bGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29sbGFwc2VTdGF0dXMoKTtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgIH1cbiAgICBfdXBkYXRlQ29sbGFwc2VTdGF0dXMoKSB7XG4gICAgICAgIGlmICh0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fVGl0bGUudmlzaWJsZSA9ICF0aGlzLl9jb2xsYXBzZTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlUHJlZml4U3R5bGUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9wcmVmaXgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmxvZ28pIHtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhPYmoodGhpcy5sb2dvLCB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yOiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICAgICAgfSwgdGhpcy5zdHlsZS5sb2dvU3R5bGUpXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaWNvbikge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaih0aGlzLmljb24sIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHRoaXMuc3R5bGUuaWNvblN0eWxlXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3BhdGNoVGl0bGUoeCwgbW91bnRYKSB7XG4gICAgICAgIHRoaXMuX1RpdGxlLnBhdGNoKHtcbiAgICAgICAgICAgIHg6IHgsXG4gICAgICAgICAgICBtb3VudFg6IG1vdW50WFxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnRQb3NpdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuX3ByZWZpeCAmJiB0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgbW91bnRYOiAwLFxuICAgICAgICAgICAgICAgIHg6IHRoaXMuX3BhZGRpbmdMZWZ0XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHN3aXRjaCAodGhpcy5fanVzdGlmeSkge1xuICAgICAgICAgICAgICBjYXNlIFwibGVmdFwiOlxuICAgICAgICAgICAgICAgIHRoaXMuX3BhdGNoVGl0bGUoMCwgMCk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSBcInJpZ2h0XCI6XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMudyA8IHRoaXMuX1ByZWZpeC53ICsgdGhpcy5fVGl0bGUudykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXRjaFRpdGxlKDAsIDApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBsZWZ0T3ZlclNwYWNlID0gdGhpcy53IC0gKHRoaXMuX3BhZGRpbmdMZWZ0ICsgdGhpcy5fcGFkZGluZ1JpZ2h0ICsgdGhpcy5fUHJlZml4LncgKyB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGF0Y2hUaXRsZShsZWZ0T3ZlclNwYWNlLCAxKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSBcImNlbnRlclwiOlxuICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmZpeGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLncgPCB0aGlzLl9QcmVmaXgudyArIHRoaXMuX1RpdGxlLncpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhdGNoVGl0bGUoMCwgMCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWlkZGxlID0gKHRoaXMudyAtICh0aGlzLl9wYWRkaW5nTGVmdCArIHRoaXMuX1ByZWZpeC53ICsgdGhpcy5fcGFkZGluZ1JpZ2h0KSkgLyAyO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGF0Y2hUaXRsZShtaWRkbGUsIC41KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fUHJlZml4ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIF9taWRkbGUgPSAodGhpcy53IC0gKHRoaXMuX3BhZGRpbmdMZWZ0ICsgdGhpcy5fUHJlZml4LncgKyB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nICsgdGhpcy5fcGFkZGluZ1JpZ2h0KSkgLyAyO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXRjaFRpdGxlKF9taWRkbGUsIC41KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdXBlci5fdXBkYXRlQ29udGVudFBvc2l0aW9uKCk7XG4gICAgICAgICAgICB0aGlzLl9UaXRsZSAmJiB0aGlzLl9wYXRjaFRpdGxlKDAsIDApO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9zZXRQcmVmaXgoKSB7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG4gICAgX3NldFN1ZmZpeCgpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBfdXBkYXRlUHJlZml4T2JqKGljb24pIHtcbiAgICAgICAgdmFyIHByb3BzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB7fTtcbiAgICAgICAgdGhpcy5fcHJlZml4ID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgaWNvbjogaWNvblxuICAgICAgICB9LCBwcm9wcyk7XG4gICAgfVxuICAgIF9zZXRJY29uKGljb24pIHtcbiAgICAgICAgaWYgKCF0aGlzLmxvZ28pIHtcbiAgICAgICAgICAgIGlmIChpY29uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJlZml4T2JqKGljb24sIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHRoaXMuc3R5bGUuaWNvblN0eWxlXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3ByZWZpeCA9IGljb247XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGljb247XG4gICAgfVxuICAgIF9zZXRMb2dvKGxvZ28pIHtcbiAgICAgICAgaWYgKGxvZ28pIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaihsb2dvLCB7XG4gICAgICAgICAgICAgICAgc3R5bGU6IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICBjb2xvcjogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfSwgdGhpcy5zdHlsZS5sb2dvU3R5bGUpXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBl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cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgdGl0bGVQYXRjaCA9IHtcbiAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUudGl0bGVNYXJnaW5MZWZ0LFxuICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLnRpdGxlVGV4dFN0eWxlXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIGlmICghdGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRpdGxlUGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuX3RpdGxlRmlyc3RMb2FkUHJvcHMpLCB0aXRsZVBhdGNoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIFRpdGxlOiB0aXRsZVBhdGNoXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBnZXQgX3RpdGxlRmlyc3RMb2FkUHJvcHMoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl90aXRsZUxvYWRlZFwiXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVSb3coKSB7XG4gICAgICAgIHRoaXMuYXBwbHlTbW9vdGgodGhpcy5JdGVtcywge1xuICAgICAgICAgICAgeTogdGhpcy50aXRsZSA/IHRoaXMuX1RpdGxlLmZpbmFsSCArIHRoaXMuc3R5bGUudGl0bGVNYXJnaW5Cb3R0b20gOiAwXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBzZXQgYW5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BcImV4dHJhSXRlbVNwYWNpbmdcIiBdO1xuICAgIH1cbiAgICBfY29uc3RydWN0KCkge1xuICAgICAgICBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgIHRoaXMuX2xlZnRDb250cm9scyA9IFtdO1xuICAgICAgICB0aGlzLl9jb250ZW50SXRlbXMgPSBbXTtcbiAgICAgICAgdGhpcy5fcmlnaHRDb250cm9scyA9IFtdO1xuICAgICAgICB0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleCA9IC0xO1xuICAgICAgICB0aGlzLl9sYXN0SXRlbUluZGV4ID0gLTE7XG4gICAgICAgIHRoaXMuX2xhenlMb2FkQnVmZmVyID0gMDtcbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnQoKSB7XG4gICAgICAgIHZhciBpdGVtc1RvQXBwZW5kID0gW107XG4gICAgICAgIGlmICh0aGlzLmxlZnRDb250cm9scy5sZW5ndGgpIHtcbiAgICAgICAgICAgIGl0ZW1zVG9BcHBlbmQucHVzaCguLi50aGlzLl93aXRoRXh0cmFTcGFjaW5nKHRoaXMubGVmdENvbnRyb2xzLCB0cnVlKSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuY29udGVudEl0ZW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgaXRlbXNUb0FwcGVuZC5wdXNoKC4uLnRoaXMuX3dpdGhFeHRyYVNwYWNpbmcodGhpcy5jb250ZW50SXRlbXMpKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5yaWdodENvbnRyb2xzLmxlbmd0aCkge1xuICAgICAgICAgICAgaXRlbXNUb0FwcGVuZC5wdXNoKC4uLnRoaXMucmlnaHRDb250cm9scyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGl0ZW1zVG9BcHBlbmQubGVuZ3RoKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBhbHBoYTogMSxcbiAgICAgICAgICAgICAgICBpdGVtczogaX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0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleCArIGl0ZW1zLmxlbmd0aDtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29udGVudCgpO1xuICAgIH1cbiAgICBfZ2V0TGVmdENvbnRyb2xJdGVtcygpIHtcbiAgICAgICAgaWYgKHRoaXMubGVmdENvbnRyb2xzLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuc2xpY2UoMCwgdGhpcy5fbGFzdExlZnRDb250cm9sSW5kZXggKyAxKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gW107XG4gICAgfVxuICAgIF9nZXRDb250ZW50SXRlbUl0ZW1zKCkge1xuICAgICAgICBpZiAodGhpcy5jb250ZW50SXRlbXMubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5pdGVtcy5zbGljZSh0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleCArIDEsIHRoaXMuX2xhc3RJdGVtSW5kZXggKyAxKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gW107XG4gICAgfVxuICAgIF9nZXRSaWdodENvbnRyb2xJdGVtcygpIHtcbiAgICAgICAgaWYgKHRoaXMucmlnaHRDb250cm9scy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHZhciBsZWZ0U2libGluZ0luZGV4ID0gdGhpcy5fbGFzdEl0ZW1JbmRleCB8fCB0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleDtcbiAgICAgICAgICAgIHJldHVybiBsZWZ0U2libGluZ0luZGV4ID8gdGhpcy5pdGVtcy5zbGljZShsZWZ0U2libGluZ0luZGV4ICsgMSkgOiB0aGlzLml0ZW1zO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBbXTtcbiAgICB9XG4gICAgc2V0IGxlZnRDb250cm9scyhsZWZ0Q29udHJvbHMpIHtcbiAgICAgICAgdGhpcy5fc2V0TGVmdENvbnRyb2xzKGxlZnRDb250cm9scyk7XG4gICAgfV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S50eXBvZ3JhcGh5LmJvZHkxKSwge30sIHtcbiAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgIH0pXG59KTtcblxudmFyIHN0eWxlcyRpID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkaVxufSk7XG5cbmNsYXNzIFNwYWNlciBleHRlbmRzIEJhc2UkMSB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIlNwYWNlclwiO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgTGluZToge1xuICAgICAgICAgICAgICAgIGg6IFNwYWNlci5fbGluZVRoaWNrbmVzcyxcbiAgICAgICAgICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgVGlja0xlZnQ6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgU3BhY2VyLl90aWNrKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgeDogU3BhY2VyLl9saW5lVGhpY2tuZXNzICogLTFcbiAgICAgICAgICAgICAgICB9KSxcbiAgICAgICAgICAgICAgICBUaWNrUmlnaHQ6IFNwYWNlci5fdGlja1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwibGluZUNvbG9yXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkxpbmVcIiwgXCJUaWNrTGVmdFwiLCBcIlRpY2tSaWdodFwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX2xpbmVUaGlja25lc3MoKSB7XG4gIC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tcGxhdGUoKSB7XG4gICAgICAgIHZhciB0ZXh0Um93ID0ge1xuICAgICAgICAgICAgdHlwZTogUm93LFxuICAgICAgICAgICAgYXV0b1Jlc2l6ZUhlaWdodDogdHJ1ZSxcbiAgICAgICAgICAgIEl0ZW1zOiB7XG4gICAgICAgICAgICAgICAgUHJvcGVydHk6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3VwZGF0ZVwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFZhbHVlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBjZW50ZXJJblBhcmVudDogdHJ1ZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIENvbHVtbnM6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICB0eXBlOiBSb3dcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBNYXJnaW5zOiB7XG4gICAgICAgICAgICAgICAgYWxwaGE6IC4wMDEsXG4gICAgICAgICAgICAgICAgSG9yaXpvbnRhbDoge1xuICAgICAgICAgICAgICAgICAgICBMZWZ0OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BhY2VyTG9hZGVkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBSaWdodDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3BhY2VyLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYWNlckxvYWRlZDogXCJfdXBkYXRlXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgVmVydGljYWw6IHtcbiAgICAgICAgICAgICAgICAgICAgVG9wOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICB2ZXJ0aWNhbDogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFNhZmU6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICBIb3Jpem9udGFsOiB7XG4gICAgICAgICAgICAgICAgICAgIExlZnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjZXJMb2FkZWQ6IFwiX3VwZGF0ZVwiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIFJpZ2h0OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BhY2VyTG9hZGVkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBWZXJ0aWNhbDoge1xuICAgICAgICAgICAgICAgICAgICBUb3A6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHZlcnRpY2FsOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIEJvdHRvbToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3BhY2VyLFxuICAgICAgICAgICAgICAgICAgICAgICAgdmVydGljYWw6IHRydWVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBHdXR0ZXJzOiB7XG4gICAgICAgICAgICAgICAgYWxwaGE6IC4wMDEsXG4gICAgICAgICAgICAgICAgSG9yaXpvbnRhbDoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwYWNlckxvYWRlZDogXCJfdXBkYXRlXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBUZXh0UGFuZWw6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICB0eXBlOiBDb2x1bW4sXG4gICAgICAgICAgICAgICAgYXV0b1Jlc2l6ZUhlaWdodDogdHJ1ZSxcbiAgICAgICAgICAgICAgICBJdGVtczoge1xuICAgICAgICAgICAgICAgICAgICBTY3JlZW5XOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBTY3JlZW5IOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBDb2x1bW5Db3VudDogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgTWFyZ2luWDogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgTWFyZ2luWTogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgR3V0dGVyWDogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgR3V0dGVyWTogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgU2FmZTogdGV4dFJvd1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcInNob3dDb2x1bW5zXCIsIFwic2hvd01hcmdpbnNcIiwgXCJzaG93U2FmZVwiLCBcInNob3dHdXR0ZXJzXCIsIFwic2hvd1RleHRcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQ29sdW1uc1wiLCBcIk1hcmdpbnNcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5Ib3Jpem9udGFsXCIsXG4gICAgICAgICAgICBwYXRoOiBcIk1hcmdpbnMuSG9yaXpvbnRhbFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiTWFyZ2luTGVmdFwiLFxuICAgICAgICAgICAgcGF0aDogXCJNYXJnaW5zLkhvcml6b250YWwuTGVmdFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiTWFyZ2luUmlnaHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiTWFyZ2lucy5Ib3Jpem9udGFsLlJpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5WZXJ0aWNhbFwiLFxuICAgICAgICAgICAgcGF0aDogXCJNYXJnaW5zLlZlcnRpY2FsXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5Ub3BcIixcbiAgICAgICAgICAgIHBhdGg6IFwiTWFyZ2lucy5WZXJ0aWNhbC5Ub3BcIlxuICAgICAgICB9LCBcIlNhZmVcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlSG9yaXpvbnRhbFwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLkhvcml6b250YWxcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNhZmVMZWZ0XCIsXG4gICAgICAgICAgICBwYXRoOiBcIlNhZmUuSG9yaXpvbnRhbC5MZWZ0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlUmlnaHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiU2FmZS5Ib3Jpem9udGFsLlJpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlVmVydGljYWxcIixcbiAgICAgICAgICAgIHBhdGg6IFwiU2FmZS5WZXJ0aWNhbFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiU2FmZVRvcFwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLlZlcnRpY2FsLlRvcFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiU2FmZUJvdHRvbVwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLlZlcnRpY2FsLkJvdHRvbVwiXG4gICAgICAgIH0sIFwiR3V0dGVyc1wiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIkd1dHRlckhvcml6b250YWxcIixcbiAgICAgICAgICAgIHBhdGg6IFwiR3V0dGVycy5Ib3Jpem9udGFsXCJcbiAgICAgICAgfSwgXCJUZXh0UGFuZWxcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJUZXh0U2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tZS5jb2xvci50ZXh0TmV1dHJhbFNlY29uZGFyeVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciB0b25lJGEgPSB0aGVtZSA9PiAoe1xuICAgIGludmVyc2U6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGV5ZWJyb3dUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgaGVscFRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkaCA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJGgsXG4gICAgbW9kZTogbW9kZSQ2LFxuICAgIHRvbmU6IHRvbmUkYVxufSk7XG5cbmNsYXNzIElucHV0IGV4dGVuZHMgQnV0dG9uIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiSW5wdXRcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkaDtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkpLCB7fSwge1xuICAgICAgICAgICAgRXllYnJvdzoge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgIH0sXG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pcy50aXRsZSA9IHRoaXMucGFzc3dvcmQgPyB0aGlzLm1hc2sucmVwZWF0KHRoaXMuYWN0dWFsVGl0bGUubGVuZ3RoKSA6IHRoaXMuYWN0dWFsVGl0bGU7XG4gICAgfVxuICAgIF91cGRhdGVUcnVuY2F0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RpdGxlLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50ZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IGZhbHNlXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUV5ZWJyb3coKSB7XG4gICAgICAgIHRoaXMuX0V5ZWJyb3cucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5leWVicm93LFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUuZXllYnJvd1RleHRTdHlsZVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIG1vdW50WTogMSxcbiAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUucGFkZGluZ1gsXG4gICAgICAgICAgICB5OiB0aGlzLnkgLSB0aGlzLnN0eWxlLnBhZGRpbmdZXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlSGVscFRleHQoKSB7XG4gICAgICAgIHRoaXMuX0hlbHBUZXh0LnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuaGVscFRleHQsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS5oZWxwVGV4dFN0eWxlXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5wYWRkaW5nWCxcbiAgICAgICAgICAgIHk6IHRoaXMueSArIHRoaXMuaW5uZXJIICsgdGhpcy5zdHlsZS5wYWRkaW5nWVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZVRleHRXcmFwcGVyKCkge1xuICAgICAgICB0aGlzLl9UZXh0V3JhcHBlci5jbGlwcGluZyA9IHRydWU7XG4gICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLncgPSB0aGlzLl92aXNpYmxlQ29udGVudFdpZHRoO1xuICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLmggPSB0aGlzLl9UaXRsZS5oO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVIaWRkZW5Db250ZW50KCkge1xuICAgICAgICBpZiAoIXRoaXMuX0hpZGRlbkNvbnRlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIEhpZGRlbkNvbnRlbnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMixcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX29uSGlkZGVuVGV4dEJveENoYW5nZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHt0aXRsZTogdmFsdWUgPSBcIlwiLCBwb3NpdGlvbjogcG9zaXRpb24sIHBhc3N3b3JkOiBwYXNzd29yZCwgbWFzazogbWFza30gPSB0aGlzO1xuICAgICAgICB2YXIgdGV4dEJlZm9yZUN1cnNvciA9IHBhc3N3b3JkID8gbWFzay5yZXBlYXQodmFsdWUubGVuZ3RoKS5zdWJzdHJpbmcoMCwgcG9zaXRpb24pIDogdmFsdWUuc3Vic3RyaW5nKDAsIHBvc2l0aW9uKTtcbiAgICAgICAgdGhpcy5fSGlkZGVuQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS50ZXh0U3R5bGVcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb250ZW50OiB0ZXh0QmVmb3JlQ3Vyc29yXG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLl9IaWRkZW5Db250ZW50Ll9UZXh0ICYmIHRoaXMuX0hpZGRlbkNvbnRlbnQuX1RleHQucGF0Y2goe1xuICAgICAgICAgICAgYWxwaGE6IC4wMDFcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVDdXJzb3IoKSB7XG4gICAgICAgIGlmICh0aGlzLnN0eWxlLmN1cnNvclN0eWxlICYmIHRoaXMuc3R5bGUuY3Vyc29yU3R5bGUuYmxpbmspIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fQ3Vyc29yKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIEN1cnNvcjoge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHRoaXMuY3Vyc29yQmxpbmsgPSB0aGlzLl9DdXJzb3IuYW5pbWF0aW9uKHtcbiAgICAgICAgICAgICAgICAgICAgZHVyYXRpb246IDEuNSxcbiAgICAgICAgICAgICAgICAgICAgcmVwZWF0OiAtMSxcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uczogWyB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwOiBcImFscGhhXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICB2OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgMDogMCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuNTogMSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAxOiAwXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0gXVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fQ3Vyc29yLnBhdGNoKHRoaXMuc3R5bGUuY3Vyc29yU3R5bGUpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVDdXJzb3JMaXN0ZW5pbmcoKSB7XG4gICAgICAgIGlmICghdGhpcy5faXNEaXNhYmxlZE1vZGUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmN1cnNvckJsaW5rICYmICF0aGlzLmN1cnNvckJsaW5rLmlzUGxheWluZygpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jdXJzb3JCbGluay5zdGFydCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3Vyc29yQmxpbmspIHRoaXMuaXNDdXJzb3JBY3RpdmUgPyB0aGlzLmN1cnNvckJsaW5rLnN0YXJ0KCkgOiB0aGlzLmN1cnNvckJsaW5rLnN0b3AoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9DdXJzb3Iuc21vb3RoID0ge1xuICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY3Vyc29yU3R5bGUudGV4dENvbG9yXG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVDdXJzb3JCbGluaygpIHtcbiAgICAgICAgaWYgKHRoaXMuY3Vyc29yQmxpbmspIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzQ3Vyc29yQWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jdXJzb3JCbGluay5zdGFydCgpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmN1cnNvckJsaW5rLnN0b3AoKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9DdXJzb3IucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBhbHBoYTogLjAwMVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVDdXJzb3JQb3NpdGlvbigpIHtcbiAgICAgICAgdGhpcy5fQ3Vyc29yLnggPSB0aGlzLl90aXRsZVggKyAodGhpcy5faXNPdmVyZmxvdyA/IHRoaXMuX1RleHRXcmFwcGVyLncgOiB0aGlzLl9IaWRkZW5Db250ZW50LncpO1xuICAgIH1cbiAgICBfdXBkYXRlVGl0bGVTY3JvbGxQb3NpdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UaXRsZS54ID0gdGhpcy5faXNPdmVyZmxvdyA/IHRoaXMuX3Zpc2libGVDb250ZW50V2lkdGggLSB0aGlzLl9IaWRkZW5Db250ZW50LncgOiAwO1xuICAgICAgICAgICAgaWYgKHRoaXMuX0hpZGRlbkNvbnRlbnQgJiYgdGhpcy5fVGV4dFdyYXBwZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9IaWRkZW5Db250ZW50LnggPSB0aGlzLl9UZXh0V3JhcHBlci54ICsgdGhpcy5fVGl0bGUueDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICBnZXQgX3N1ZmZpeFgoKSB7XG4gICAgICAgIHZhciBzdWZmaXhYID0gdGhpcy5faGFzU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dHJ1ZTtcbiAgICB9XG4gICAgX2hhbmRsZVJpZ2h0KCkge1xuICAgICAgICBpZiAodGhpcy5faXNEaXNhYmxlZE1vZGUpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm1vdmVSaWdodCgpO1xuICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SaWdodCA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5vblJpZ2h0KHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICBtb3ZlTGVmdCgpIHtcbiAgICAgICAgdmFyIHtwb3NpdGlvbjogcG9zaXRpb259ID0gdGhpcztcbiAgICAgICAgaWYgKHBvc2l0aW9uID49IDApIHtcbiAgICAgICAgICAgIHRoaXMucG9zaXRpb24tLTtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG4gICAgbW92ZVJpZ2h0KCkge1xuICAgICAgICB2YXIge3Bvc2l0aW9uOiBwb3NpdGlvbiwgdGl0bGU6IHRpdGxlfSA9IHRoaXM7XG4gICAgICAgIGlmIChwb3NpdGlvbiA8IHRpdGxlLmxlbmd0aCkge1xuICAgICAgICAgICAgdGhpcy5wb3NpdGlvbisrO1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgICBzZXQgYW5ub3VuY2UoYW5ub3VuY2UpIHtcbiAgICAgICAgc3VwZXIuYW5ub3VuY2UgPSBhbm5vdW5jZTtcbiAgICB9XG4gICAgZ2V0IGFubm91bmNlKCkge1xuICAgICAgICBpZiAodGhpcy5fYW5ub3VuY2UpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZTtcbiAgICAgICAgfVxuICAgICAgIC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4gICAgICAgIHJldHVybiBiYXNlU2l6ZSArIHBhZGRpbmc7XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXhTdHlsZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3ByZWZpeCAmJiB0aGlzLmljb24pIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaih0aGlzLmljb24sIHtcbiAgICAgICAgICAgICAgICBzdHlsZTogdGhpcy5zdHlsZS5pY29uU3R5bGVcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXhPYmooaWNvbikge1xuICAgICAgICB2YXIgcHJvcHMgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHt9O1xuICAgICAgICB0aGlzLl9wcmVmaXggPSBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgIHR5cGU6IEljb24sXG4gICAgICAgICAgICBpY29uOiBpY29uLFxuICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pY29uV2lkdGgsXG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmljb25IZWlnaHRcbiAgICAgICAgfSwgcHJvcHMpO1xuICAgIH1cbiAgICBfc2V0SWNvbihpY29uKSB7XG4gICAgICAgIGlmIChpY29uKSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhPYmooaWNvbiwge1xuICAgICAgICAgICAgICAgIHN0eWxlOiB0aGlzLnN0eWxlLmljb25TdHlsZVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9wcmVmaXggPSBpY29uO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBpY29uO1xuICAgIH1cbiAgICBzZXQgYW5ub3VuY2UoYW5ub3VuY2UpIHtcbiAgICAgICAgc3VwZXIuYW5ub3VuY2UgPSBhbm5vdW5jZTtcbiAgICB9XG4gICAgZ2V0IGFubm91bmNlKCkge1xuICAgICAgICBpZiAodGhpcy5fYW5ub3VuY2UpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNVcHBlckNhc2UodGhpcy50aXRsZSkpIHtcbiAgICAgICAgICAgIHJldHVybiBcIkNhcGl0YWwgXCIuY29uY2F0KGdldE5hdG8odGhpcy50aXRsZSksIFwiLCBidXR0b25cIik7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGdldE5hdG8odGhpcy50aXRsZSkgKyBcIiwgYnV0dG9uXCI7XG4gICAgfVxuICAgIF9oYW5kbGVFbnRlcigpIHtcbiAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uRW50ZXIgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMub25FbnRlcih0aGlzKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnRvZ2dsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycyhcIiR0b2dnbGVLZXlib2FyZFwiLCB0aGlzLnRvZ2dsZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkb25Tb2Z0S2V5XCIsIHtcbiAgICAgICAgICAgICAgICBrZXk6IHRoaXMua2V5SWQgfHwgdGhpcy50aXRsZSxcbiAgICAgICAgICAgICAgICB0b2dnbGU6IHRoaXMudG9nZ2xlXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxufVxuXG52YXIgYmFzZSRmID0gdGhlbWUgPT4gKHtcbiAgICBrZXlTcGFjaW5nOiB0aGVtZS5zcGFjZXIubWQsXG4gICAgc2NyZWVuVzogdGhlbWUubGF5b3V0LnNjcmVlblcsXG4gICA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AgW2tleV06IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQ29sdW1uLFxuICAgICAgICAgICAgICAgICAgICBwbGlua286IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zOiByb3dzLFxuICAgICAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZ1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBhdXRvUmVzaXplV2lkdGg6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIGF1dG9SZXNpemVIZWlnaHQ6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG5ldmVyU2Nyb2xsOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBhbHBoYToga2V5ID09PSBjYXBpdGFsaXplKHRoaXMuX2N1cnJlbnRGb3JtYXQpID8gMSA6IC4wMDFcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfY3JlYXRlUm93cygpIHtcbiAgICAgICAgdmFyIHJvd3MgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IFtdO1xuICAgICAgICB2YXIga2V5Ym9hcmQgPSBhcmd1bWVudHMubGVuZ3RoID4gMSA/IGFyZ3VtZW50c1sxXSA6IHVuZGVmaW5lZDtcbiAgICAgICAgcmV0dXJuIHJvd3MubWFwKChrZXlzID0+IHtcbiAgICAgICAgICAgIHZhciBfdGhpcyRfY3VycmVudEtleWJvYXI7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFJvdyxcbiAgICAgICAgICAgICAgICBhdXRvUmVzaXplSGVpZ2h0OiB0cnVlLFxuICAgICAgICAgICAgICAgIGF1dG9SZXNpemVXaWR0aD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maW5lZDtcbiAgICAgICAgcmV0dXJuIGtleXMubWFwKChrZXlQcm9wcyA9PiB7XG4gICAgICAgICAgICBpZiAoIWtleVByb3BzKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogdGhpcy5rZXlDb21wb25lbnQgfHwgS2V5LFxuICAgICAgICAgICAgICAgICAgICBrZXlTcGFjaW5nOiB0aGlzLnN0eWxlLmtleVNwYWNpbmcsXG4gICAgICAgICAgICAgICAgICAgIHNraXBGb2N1czogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IC4wMVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIga2V5ID0ge1xuICAgICAgICAgICAgICAgIHR5cGU6IHRoaXMua2V5Q29tcG9uZW50IHx8IEtleSxcbiAgICAgICAgICAgICAgICBrZXlTcGFjaW5nOiB0aGlzLnN0eWxlLmtleVNwYWNpbmdcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAodHlwZW9mIGtleVByb3BzID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgdmFyIF90aGlzJHN0eWxlJGtleVByb3BzLCBfdGhpcyRzdHlsZSRrZXlQcm9wczI7XG4gICAgICAgICAgICAgICAgdmFyIGtleU5hbWUgPSBrZXlQcm9wcy5rZXlJZCB8fCBrZXlQcm9wcy50aXRsZTtcbiAgICAgICAgICAgICAgICB2YXIga2V5T3ZlcnJpZGVzID0gKChfdGhpcyRzdHlsZSRrZXlQcm9wcyA9IHRoaXMuc3R5bGUua2V5UHJvcHMpID09PSBudWxsIHx8IF90aGlzJHN0eWxlJGtleVByb3BzID09PSB2b2lkIDAgfHwgKF90aGlzJHN0eWxlJGtleVByb3BzID0gX3RoaXMkc3R5bGUka2V5UHJvcHNba2V5Ym9hcmRdKSA9PT0gbnVsbCB8fCBfdGhpcyRzdHlsZSRrZXlQcm9wcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3R5bGUka2V5UHJvcHNba2V5TmFtZV0pIHx8ICgoX3RoaXMkc3R5bGUka2V5UHJvcHMyID0gdGhpcy5zdHlsZS5rZXlQcm9wcykgPT09IG51bGwgfHwgX3RoaXMkc3R5bGUka2V5UHJvcHMyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRzdHlsZSRrZXlQcm9wczJba2V5TmFtZV0pIHx8IHt9O1xuICAgICAgICAgICAgICAgIHZhciBrZXlQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBrZXkpLCBrZXlQcm9wcyksIGtleU92ZXJyaWRlcyk7XG4gICAgICAgICAgICAgICAgaWYgKGtleU92ZXJyaWRlcyAhPT0gbnVsbCAmJiBrZXlPdmVycmlkZXMgIT09IHZvaWQgMCAmJiBrZXlPdmVycmlkZXMuaWNvbikge1xuICAgICAgICAgICAgICAgICAgICBrZXlQYXRjaC5zdHlsZSA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwga2V5T3ZlcnJpZGVzLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGljb25TdHlsZTogX29iamVjdFNwcmVhZCh7fSwga2V5T3ZlcnJpZGVzLmljb25TdHlsZSlcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBrZXlQYXRjaDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGtleSksIHt9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGtleVByb3BzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSkpO1xuICAgIH1cbiAgICBfZm9ybWF0S2V5Ym9hcmREYXRhKCkge1xuICAgICAgICB2YXIgZGF0YSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogW107XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KGRhdGEpICYmIGRhdGEubGVuZ3RoKSB7XG4gICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZGF0YVswXSkgJiYgIXRoaXMuaW5saW5lKSB7XG4gICAgICAgICAgICAgICAgdmFyIGtleVJvd3MgPSBbXTtcbiAgICAgICAgICAgICAgICB2YXIgaWR4LCBjb3VudGVyO1xuICAgICAgICAgICAgICAgIGZvciAoaWR4ID0gMCwgY291bnRlciA9IC0xOyBpZHggPCBkYXRhLmxlbmd0aDsgaWR4KyspIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlkeCAlIHRoaXMuY29sdW1uQ291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ZXIrKztcbiAgICAgICAgICAgICAgICAgICAgICAgIGtleVJvd3NbY291bnRlcl0gPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBrZXlSb3dzW2NvdW50ZXJdLnB1c2goZGF0YVtpZHhdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGtleVJvd3M7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaW5saW5lKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFsgZGF0YSBdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGRhdGE7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2Zvcm1hdEtleXMoKSB7XG4gICAgICAgIE9iamVjdC5rZXlzKHRoaXMuZm9ybWF0cykuZm9yRWFjaCgoZm9ybWF0ID0+IHtcbiAgICAgICAgICAgIHZhciBlbGVtZW50ID0gdGhpcy50YWcoY2FwaXRhbGl6ZShmb3JtYXQpKTtcbiAgICAgICAgICAgIGlmIChlbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiBmb3JtYXQgPT09IHRoaXMuX2N1cnJlbnRGb3JtYXQgPyAxIDogLjAwMSxcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1TcGFjaW5nOiB0aGlzLnN0eWxlLmtleVNwYWNpbmdcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGVsZW1lbnQuaXRlbXMuZm9yRWFjaCgocm93ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgcm93LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZ1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlckluUGFyZW50OiB0aGlzLmNlbnRlcktleXMsXG4gICAgICAgICAgICAgICAgICAgICAgICB3cmFwU2VsZWN0ZWQ6IHRoaXMucm93V3JhcCAhPT0gdW5kZWZpbmVkID8gdGhpcy5yb3dXcmFwIDogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5xdWV1ZVJlcXVlc3RVcGRhdGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSkpO1xuICAgIH1cbiAgICAkdG9nZ2xlS2V5Ym9hcmQobmV4dCkge1xuICAgICAgICB2YXIgbmV4dEtleWJvYXJkID0gY2FwaXRhbGl6ZShuZXh0KTtcbiAgICAgICAgaWYgKG5leHQgIT09IHRoaXMuX2N1cnJlbnRGb3JtYXQpIHtcbiAgICA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CIsIFwiWFwiLCBcIkNcIiwgXCJWXCIsIFwiQlwiLCBcIk5cIiwgXCJNXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJsb3dlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvZmYsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvbVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29tXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm5ldFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgbmV0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmVkdVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgZWR1XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm9yZ1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgb3JnXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi51a1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgdWtcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiAgICAgICAgICAgIGxvd2VyY2FzZTogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcInFcIiwgXCJ3XCIsIFwiZVwiLCBcInJcIiwgXCJ0XCIsIFwieVwiLCBcInVcIiwgXCJpXCIsIFwib1wiLCBcInBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIiNAIVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwic3ltYm9sc1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInN5bWJvbCBtb2RlLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzeW1ib2xzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcImFcIiwgXCJzXCIsIFwiZFwiLCBcImZcIiwgXCJnXCIsIFwiaFwiLCBcImpcIiwgXCJrXCIsIFwibFwiLCBcIkBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIsOhw7bDu1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFjY2VudHMsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImFjY2VudHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwielwiLCBcInhcIiwgXCJjXCIsIFwidlwiLCBcImJcIiwgXCJuXCIsIFwibVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBlcmlvZCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJzaGlmdFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwidXBwZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb24sIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvbVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29tXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm5ldFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgbmV0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmVkdVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgZWR1XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm9yZ1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgb3JnXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi51a1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgdWtcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiAgICAgICAgICAgIGFjY2VudHM6I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gICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBlcmlvZCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJzaGlmdFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1VwcGVyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb2ZmLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzaGlmdFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb21cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvbVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5uZXRcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG5ldFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5lZHVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGVkdVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5vcmdcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG9yZ1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIudWtcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIHVrXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF0sXG4gICAgICAgICAgICBhY2NlbnRzVXBwZXI6IFsgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCLDhFwiLCBcIsOLXCIsIFwiw49cIiwgXCLDllwiLCBcIsOcXCIsIFwixbhcIiwgXCLDgFwiLCBcIsOIXCIsIFwiw4xcIiwgXCLDklwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiI0AhXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJzeW1ib2xzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3ltYm9sIG1vZGUsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInN5bWJvbHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiw5lcIiwgXCLDgVwiLCBcIsOJXCIsIFwiw41cIiwgXCLDk1wiLCBcIsOaXCIsIFwiw51cIiwgXCLDglwiLCBcIsOKXCIsIFwiQFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiYWJjXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJsb3dlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhbHBoYSBtb2RlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwiw45cIiwgXCLDlFwiLCBcIsObXCIsIFwiw4NcIiwgXCLDkVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBlcmlvZCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJzaGlmdFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNoaWZ0IG9mZiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29tXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb21cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIubmV0XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBuZXRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuZWR1XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBlZHVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIub3JnXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBvcmdcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLnVrXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCB1a1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgc3ltYm9sczogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiIVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImV4Y2xhbWF0aW9uLCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCJAXCIsIFwiI1wiLCBcIiRcIiwgXCIlXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJeXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2FyZXQgY2lyY3VtZmxleCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIFwiJlwiLCBcIipcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIihcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIHBhcmVudGhlc2lzLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIilcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbG9zZSBwYXJlbnRoZXNpcywgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJhYmNcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFscGhhIG1vZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIntcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIGJyYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIn1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbG9zZSBicmFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJbXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwib3BlbiBicmFja2V0LCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbG9zZSBicmFja2V0LCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjtcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzZW1pY29sb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6ICdcIicsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG91YmxlcXVvdGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNvbW1hLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInxcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ2ZXJ0aWNhbCBiYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiXFxcXFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImJhY2tzbGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZm9yd2FyZHNsYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIsOhw7bDu1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFjY2VudHMsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImFjY2VudHNcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI8XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwibGVzcyB0aGFuLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIj5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJncmVhdGVyIHRoYW4sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiP1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInF1ZXN0aW9uIG1hcmssIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiPVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImVxdWFsIHNpZ24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiYFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImdyYXZlIGFjY2VudCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJ+XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidGlsZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiOlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNvbG9uLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIitcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwbHVzIHNpZ24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb21cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvbVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5uZXRcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG5ldFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5lZHVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGVkdVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5vcmdcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG9yZ1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIudWtcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIHVrXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF1cbiAgICAgICAgfTtcbiAgICB9XG59XG5cbmNsYXNzIEtleWJvYXJkRnVsbFNjcmVlbiBleHRlbmRzIEtleWJvYXJkIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiS2V5Ym9hcmRGdWxsU2NyZWVuXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCk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gICAgICAgICAgICB0aXRsZTogXCLDocO2w7tcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImFjY2VudHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhY2NlbnRzLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJhY2NlbnRzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIlpcIiwgXCJYXCIsIFwiQ1wiLCBcIlZcIiwgXCJCXCIsIFwiTlwiLCBcIk1cIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwZXJpb2QsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwic2hpZnRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNoaWZ0IG9mZiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgbG93ZXJjYXNlOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwicVwiLCBcIndcIiwgXCJlXCIsIFwiclwiLCBcInRcIiwgXCJ5XCIsIFwidVwiLCBcImlcIiwgXCJvXCIsIFwicFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiI0AhXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJzeW1ib2xzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3ltYm9sIG1vZGUsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInN5bWJvbHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiYVwiLCBcInNcIiwgXCJkXCIsIFwiZlwiLCBcImdcIiwgXCJoXCIsIFwialwiLCBcImtcIiwgXCJsXCIsIFwiQFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiw6HDtsO7XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWNjZW50cywgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiYWNjZW50c1wiXG4gICAgICAgICAgICB9IF0sIFsgXCJ6XCIsIFwieFwiLCBcImNcIiwgXCJ2XCIsIFwiYlwiLCBcIm5cIiwgXCJtXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJ1cHBlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvbiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgYWNjZW50czogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsOkXCIsIFwiw6tcIiwgXCLDr1wiLCBcIsO2XCIsIFwiw7xcIiwgXCLDv1wiLCBcIsOgXCIsIFwiw6hcIiwgXCLDrFwiLCBcIsOyXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9IF0sIFsgXCLDuVwiLCBcIsOhXCIsIFwiw6lcIiwgXCLDrVwiLCBcIsOzXCIsIFwiw7pcIiwgXCLDvVwiLCBcIsOiXCIsIFwiw6pcIiwgXCJAXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJhYmNcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFscGhhIG1vZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCLDrlwiLCBcIsO0XCIsIFwiw7tcIiwgXCLDo1wiLCBcIsOxXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzVXBwZXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvZmYsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiAgICAgICAgICAgIGFjY2VudHNVcHBlcjogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsOEXCIsIFwiw4tcIiwgXCLDj1wiLCBcIsOWXCIsIFwiw5xcIiwgXCLFuFwiLCBcIsOAXCIsIFwiw4hcIiwgXCLDjFwiLCBcIsOSXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9IF0sIFsgXCLDmVwiLCBcIsOBXCIsIFwiw4lcIiwgXCLDjVwiLCBcIsOTXCIsIFwiw5pcIiwgXCLDnVwiLCBcIsOCXCIsIFwiw4pcIiwgXCJAXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJhYmNcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFscGhhIG1vZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCLDjlwiLCBcIsOUXCIsIFwiw5tcIiwgXCLDg1wiLCBcIsORXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb2ZmLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzaGlmdFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF0sXG4gICAgICAgICAgICBzeW1ib2xzOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIhXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZXhjbGFtYXRpb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCBcIkBcIiwgXCIjXCIsIFwiJFwiLCBcIiVcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjYXJldCBjaXJjdW1mbGV4LCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCImXCIsIFwiKlwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiKFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIm9wZW4gcGFyZW50aGVzaXMsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiKVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIHBhcmVudGhlc2lzLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcImFiY1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwibG93ZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWxwaGEgbW9kZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwie1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIm9wZW4gYnJhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwifVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIGJyYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIltcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIGJyYWNrZXQsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiXVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIGJyYWNrZXQsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiO1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNlbWljb2xvbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogJ1wiJyxcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3VibGVxdW90ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIsXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY29tbWEsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwifFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInZlcnRpY2FsIGJhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJcXFxcXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYmFja3NsYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJmb3J3YXJkc2xhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiw6HDtsO7XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWNjZW50cywgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiYWNjZW50c1wiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjxcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJsZXNzIHRoYW4sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiPlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImdyZWF0ZXIgdGhhbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI/XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicXVlc3Rpb24gbWFyaywgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI9XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZXF1YWwgc2lnbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJgXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZ3JhdmUgYWNjZW50LCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIn5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ0aWxkZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI6XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY29sb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiK1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBsdXMgc2lnbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXVxuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgS2V5Ym9hcmRJbnB1dCBleHRlbmRzIEJhc2UkMSB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIktleWJvYXJkSW5wdXRcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImNlbnRlcktleWJvYXJkXCIsIFwiZGVmYXVsdEZvcm1hdFwiLCBcImlucHV0XCIsIFwia2V5Ym9hcmRUeXBlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkZjtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIFdyYXBwZXI6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBDb2x1bW4sXG4gICAgICAgICAgICAgICAgbmV2ZXJTY3JvbGw6IHRydWUsXG4gICAgICAgICAgICAgICAgdzogdGhpcy53LFxuICAgICAgICAgICAgICAgIGl0ZW1zOiBbIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSW5wdXQsXG4gICAgICAgICAgICAgICAgICAgIHJlZjogXCJJbnB1dFwiXG4gICAgICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBLZXlib2FyZCxcbiAgICAgICAgICAgICAgICAgICAgcmVmOiBcIktleWJvYXJkXCIsXG4gICAgICAgICAgICAgICAgICAgIHBhc3NTaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBrZXlib2FyZFdpZHRoQ2hhbmdlZDogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBdLFxuICAgICAgICAgICAgICAgIHNlbGVjdGVkSW5kZXg6IDEsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBrZXlib2FyZFdpZHRoQ2hhbmdlZDogXCJfdXBkYXRlV2lkdGhcIlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIldyYXBwZXJcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJJbnB1dFwiLFxuICAgICAgICAgICAgcGF0aDogXCJXcmFwcGVyLklucHV0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJLZXlib2FyZFwiLFxuICAgICAgICAgICAgcGF0aDogXCJXcmFwcGVyLktleWJvYXJkXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl9XcmFwcGVyLnN0eWxlLml0ZW1TcGFjaW5nID0gdGhpcy5zdHlsZS5pbnB1dFNwYWNpbmc7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUtleWJvYXJkVHlwZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVJbnB1dCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVLZXlib2FyZCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVDZW50ZXJLZXlib2FyZCgpO1xuICAgIH1cbiAgICBfdXBkYXRlS2V5Ym9hcmRUeXBlKCkge1xuICAgICAgICBpZiAodGhpcy5fS2V5Ym9hcmQuY29uc3RydWN0b3IgIT09IHRoaXMua2V5Ym9hcmRUeXBlKSB7XG4gICAgICAgICAgICB0aGlzLl9XcmFwcGVyLl9yZXNldEl0ZW1zKCk7XG4gICAgICAgICAgICB0aGlzLl9XcmFwcGVyLml0ZW1zID0gWyB7XG4gICAgICAgICAgICAgICAgdHlwZTogSW5wdXQsXG4gICAgICAgICAgICAgICAgcmVmOiBcIklucHV0XCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLmtleWJvYXJkVHlwZSxcbiAgICAgICAgICAgICAgICByZWY6IFwi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SB7XG4gICAgICAgICAgICB0aGlzLnggPSAodGhpcy5zdHlsZS5zY3JlZW5XIC0gdGhpcy53KSAvIDIgLSB0aGlzLnN0eWxlLm1hcmdpblg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnggPSAwO1xuICAgICAgICB9XG4gICAgfVxuICAgICRvblNvZnRLZXkoX3JlZjIyKSB7XG4gICAgICAgIHZhciB7a2V5OiBrZXkgPSBcIlwiLCB0b2dnbGU6IHRvZ2dsZX0gPSBfcmVmMjI7XG4gICAgICAgIGlmICh0b2dnbGUpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBzd2l0Y2ggKGtleS50b0xvd2VyQ2FzZSgpKSB7XG4gICAgICAgICAgY2FzZSBcImRlbGV0ZVwiOlxuICAgICAgICAgICAgdGhpcy5fSW5wdXQuYmFja3NwYWNlKCk7XG4gICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgIGNhc2UgXCJkb25lXCI6XG4gICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgIGNhc2UgXCJzcGFjZVwiOlxuICAgICAgICAgICAgdGhpcy5fSW5wdXQuaW5zZXJ0KFwiIFwiKTtcbiAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgY2FzZSBcImNsZWFyXCI6XG4gICAgICAgICAgICB0aGlzLl9JbnB1dC5jbGVhcigpO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgdGhpcy5fSW5wdXQuaW5zZXJ0KGtleSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgJGtleWJvYXJkRm9jdXNlZChmb2N1cykge1xuICAgICAgICBpZiAoZm9jdXMpIHtcbiAgICAgICAgICAgIHRoaXMuX0lucHV0Lmxpc3RlbmluZyA9IHRydWU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9JbnB1dC5saXN0ZW5pbmcgPSB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gICAgIHRpdGxlOiBcIjNcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI1XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI2XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI3XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI4XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI5XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIwXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF1cbiAgICAgICAgfTtcbiAgICB9XG59XG5cbnZhciBiYXNlJGUgPSB0aGVtZSA9PiB7XG4gICAgdmFyIHNpemUgPSB0aGVtZS5zcGFjZXIubGc7XG4gICAgcmV0dXJuIHtcbiAgICAgICAgd2lkdGg6IHNpemUsXG4gICAgICAgIGhlaWdodDogc2l6ZSxcbiAgICAgICAgcmFkaXVzOiBzaXplIC8gMlxuICAgIH07XG59O1xuXG52YXIgdG9uZSQ5ID0gdGhlbWUgPT4gKHtcbiAgICBuZXV0cmFsOiB7XG4gICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZU5ldXRyYWxGb2N1cyxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBjaXJjbGVDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZUludmVyc2VGb2N1cyxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBjaXJjbGVDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2VEaXNhYmxlZFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBjaXJjbGVDb2xvcjogdGhlbWUuY29sb3IuaW50ZXJhY3RpdmVCcmFuZEZvY3VzLFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhY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2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICB9XG4gICAgfSxcbiAgICBmb2N1c2VkOiB7XG4gICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlXG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHRvbmUkOCA9IHRoZW1lID0+ICh7XG4gICAgaW52ZXJzZToge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJGQgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSRkLFxuICAgIG1vZGU6IG1vZGUkNSxcbiAgICB0b25lOiB0b25lJDhcbn0pO1xuXG5jbGFzcyBMaXN0SXRlbSBleHRlbmRzIEJ1dHRvbiB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkxpc3RJdGVtXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJGQ7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHN1cGVyLl90ZW1wbGF0ZSgpKSwge30sIHtcbiAgICAgICAgICAgIGp1c3RpZnk6IFwibGVmdFwiLFxuICAgICAgICAgICAgZml4ZWQ6IHRydWUsXG4gICAgICAgICAgICBDb250ZW50OiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHN1cGVyLl90ZW1wbGF0ZSgpLkNvbnRlbnQpLCB7fSwge1xuICAgICAgICAgICAgICAgIFRleHRXcmFwcGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIGZsZXg6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRpcmVjdGlvbjogXCJjb2x1bW5cIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBUaXRsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfb25UZXh0Qm94Q2hhbmdlZFwiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci5wcm9wZXJ0aWVzLCBcImRlc2NyaXB0aW9uXCIsIFwicHJlZml4TG9nb1wiLCBcInN1ZmZpeExvZ29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V4dFN0eWxlXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZURlc2NyaXB0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzRGVzY3JpcHRpb24pIHtcbiAgICAgICAgICAgIHZhciBkZXNjcmlwdGlvblBhdGNoID0ge1xuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGVzY3JpcHRpb24sXG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuZGVzY3JpcHRpb25UZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9maXhlZFdvcmRXcmFwV2lkdGhcbiAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHZpc2libGU6ICF0aGlzLl9jb2xsYXBzZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fRGVzY3JpcHRpb24pIHtcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblBhdGNoID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9vblRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIGRlc2NyaXB0aW9uUGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgICAgIERlc2NyaXB0aW9uOiBkZXNjcmlwdGlvblBhdGNoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBEZXNjcmlwdGlvbjogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlVHJ1bmNhdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UaXRsZS5wYXRjaCh7XG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRoaXMuZml4ZWQsXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLmZpeGVkID8gdGhpcy5fZml4ZWRXb3JkV3JhcFdpZHRoIDogMFxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXhMb2dvKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzUHJlZml4TG9nbykge1xuICAgICAgICAgICAgdGhpcy5fcHJlZml4ID0gdGhpcy5fYWRkTG9nb1Byb3BzKHRoaXMuX3ByZWZpeExvZ28pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVTdWZmaXhMb2dvKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzU3VmZml4TG9nbykge1xuICAgICAgICAgICAgdGhpcy5fc3VmZml4ID0gdGhpcy5fYWRkTG9nb1Byb3BzKHRoaXMuX3N1ZmZpeExvZ28pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9hZGRMb2dvUHJvcHMoaWNvbikge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgIGljb246IGljb24sXG4gICAgICAgICAgICBzdHlsZTogX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgY29sb3I6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSwgdGhpcy5zdHlsZS5sb2dvU3R5bGUpXG4gICAgICAgIH07XG4gICAgfVxuICAgIGdldCBfaGFzUHJlZml4TG9nbygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMucHJlZml4TG9nbztcbiAgICB9XG4gICAgZ2V0IF9oYXNTdWZmaXhMb2dvKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5zdWZmaXhMb2dvO1xuICAgIH1cbiAgICBnZXQgX3Jvd1Byb3BzKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fcm93UHJvcHMpLCB7fSwge1xuICAgICAgICAgICAgYXV0b1Jlc2l6ZUhlaWdodDogdHJ1ZVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgZ2V0IF9idXR0b25Qcm9wcygpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX2J1dHRvblByb3BzKSwge30sIHtcbiAgICAgICAgICAgIGFscGhhOiB0aGlzLnN0eWxlLmFscGhhXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBnZXQgX2hhc0Rlc2NyaXB0aW9uKCkge1xuICAgICAgICByZXR1cm4gISF0aGlzLmRlc2NyaXB0aW9uO1xuICAgIH1cbiAgICBnZXQgX3N1ZmZpeFgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLncgLSB0aGlzLl9wYW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Y29sb3IuZmlsbEludmVyc2VcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGFycm93Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsLFxuICAgICAgICAgICAgICAgIHByb2dyZXNzQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgIGJhckNvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFRlcnRpYXJ5LFxuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc0NvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGFycm93Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxJbnZlcnNlLFxuICAgICAgICAgICAgICAgIHByb2dyZXNzQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgIGJhckNvbG9yOiB0aGVtZS5jb2xvci5maWxsQnJhbmRUZXJ0aWFyeSxcbiAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NDb2xvcjogdGhlbWUuY29sb3IuZmlsbEJyYW5kXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkYyA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJGMsXG4gICAgbW9kZTogbW9kZSQ0LFxuICAgIHRvbmU6IHRvbmUkN1xufSk7XG5cbnZhciBiYXNlJGIgPSB0aGVtZSA9PiB7XG4gICAgdmFyIHNpem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gICAgICAgICAgICAgICAgU2xpZGVyQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBQcm9ncmVzc0JhcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBDaXJjbGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IEtub2IsXG4gICAgICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IDVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgTGVmdEFycm93OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEljb24sXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIHk6IGggPT4gaCAvIDJcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFJpZ2h0QXJyb3c6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcIm1heFwiLCBcIm1pblwiLCBcInN0ZXBcIiwgXCJ2YWx1ZVwiLCBcInZlcnRpY2FsXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkNvbnRhaW5lclwiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIkJhclwiLFxuICAgICAgIC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gZGVncmVlc1RvUmFkaWFucyg5MCkgOiAwLFxuICAgICAgICAgICAgbW91bnRZOiB0aGlzLnZlcnRpY2FsID8gLjUgOiAwXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlU2xpZGVyTGF5b3V0KCkge1xuICAgICAgICB2YXIgdyA9IHRoaXMudyB8fCB0aGlzLnN0eWxlLm1pbldpZHRoO1xuICAgICAgICB0aGlzLl9Db250YWluZXIucGF0Y2goe1xuICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5jb250YWluZXJIZWlnaHQsXG4gICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgQmFyOiB7XG4gICAgICAgICAgICAgICAgeDogdGhpcy5fY2FsY3VsYXRlZFNsaWRlclgsXG4gICAgICAgICAgICAgICAgU2xpZGVyQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgIHk6IHRoaXMuc3R5bGUuY29udGFpbmVySGVpZ2h0IC8gMixcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fY2FsY3VsYXRlZFNsaWRlcldpZHRoLFxuICAgICAgICAgICAgICAgICAgICBzdHlsZTogX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBkdXJhdGlvbjogMFxuICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLnN0eWxlLnByb2dyZXNzQmFyKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuaCA9IE1hdGgubWF4KHRoaXMuc3R5bGUuY29udGFpbmVySGVpZ2h0LCB0aGlzLnN0eWxlLmFycm93SGVpZ2h0KTtcbiAgICB9XG4gICAgX2NoZWNrQW5kU2lnbmFsU2l6ZUNoYW5nZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuaCAhPT0gdGhpcy5wcmV2SCB8fCB0aGlzLl9Db250YWluZXIudyAhPT0gdGhpcy5wcmV2VyB8fCB0aGlzLnJvdGF0aW9uICE9PSB0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udmFsdWUgPCB0aGlzLm1pbiB8fCB0aGlzLnZhbHVlICsgdGhpcy5zdGVwIDwgdGhpcy5taW4pIHtcbiAgICAgICAgICAgIHhDaXJjbGVQb3NpdGlvbiA9IHRoaXMubWluIC8gdGhpcy5tYXggKiB0aGlzLl9jYWxjdWxhdGVkU2xpZGVyV2lkdGg7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy52YWx1ZSA+IHRoaXMubWF4IHx8IHRoaXMudmFsdWUgLSB0aGlzLnN0ZXAgPiB0aGlzLm1heCkge1xuICAgICAgICAgICAgeENpcmNsZVBvc2l0aW9uID0gdGhpcy5fY2FsY3VsYXRlZFNsaWRlcldpZHRoO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMubWluIDwgMCB8fCB0aGlzLm1heCA8IDApIHtcbiAgICAgICAgICAgICAgICB4Q2lyY2xlUG9zaXRpb24gPSAodGhpcy52YWx1ZSAtIHRoaXMubWluKSAvICh0aGlzLm1heCAtIHRoaXMubWluKSAqIHRoaXMuX2NhbGN1bGF0ZWRTbGlkZXJXaWR0aDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgeENpcmNsZVBvc2l0aW9uID0gdGhpcy52YWx1ZSAvIHRoaXMubWF4ICogdGhpcy5fY2FsY3VsYXRlZFNsaWRlcldpZHRoO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9DaXJjbGUpIHtcbiAgICAgICAgICAgIHRoaXMuX0NpcmNsZS5wYXRjaCh7XG4gICAgICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHJhZGl1czogdGhpcy5zdHlsZS5yYWRpdXMsXG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUudyxcbiAgICAgICAgICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5oLFxuICAgICAgICAgICAgICAgICAgICBjaXJjbGVDb2xvcjogdGhpcy5zdHlsZS5jaXJjbGVDb2xvclxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgeTogdGhpcy5fU2xpZGVyQmFyLnkgKyAxLFxuICAgICAgICAgICAgICAgIGFscGhhOiB0aGlzLl9pc0ZvY3VzZWRNb2RlICYmIHRoaXMuc3R5bGUuc2hvd0tub2IgPyAxIDogMFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAodGhpcy5zdHlsZS5jaXJjbGVBbmltYXRpb24gJiYgT2JqZWN0LmtleXModGhpcy5zdHlsZS5jaXJjbGVBbmltYXRpb24pLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX0NpcmNsZS5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgIHg6IFsgeENpcmNsZVBvc2l0aW9uLCB0aGlzLnN0eWxlLmNpcmNsZUFuaW1hdGlvbiBdXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fQ2lyY2xlLnggPSB4Q2lyY2xlUG9zaXRpb247XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUFycm93QWxwaGEoKSB7XG4gICAgICAgIHZhciBsZWZ0QWxwaGE7XG4gICAgICAgIHZhciByaWdodEFscGhhO1xuICAgICAgICB2YXIgb2ZmQWxwaGEgPSAuMDAxO1xuICAgICAgICB2YXIgYWxwaGEgPSB0aGlzLnN0eWxlLnNob3dBcnJvd3MgPyB0aGlzLnN0eWxlLmFycm93QWxwaGFWYWx1ZSA6IG9mZkFscGhhO1xuICAgICAgICB2YXIgYWxwaGFMaW1pdCA9IHRoaXMuc3R5bGUuc2hvd0Fycm93cyA/IHRoaXMuc3R5bGUuYXJyb3dBbHBoYVZhbHVlTGltaXQgOiBvZmZBbHBoYTtcbiAgICAgICAgbGVmdEFscGhhID0gcmlnaHRBbHBoYSA9IGFscGhhO1xuICAgICAgICBpZiAoIXRoaXMuX2lzRGlzYWJsZWRNb2RlICYmIHRoaXMudmFsdWUgPD0gdGhpcy5taW4pIHtcbiAgICAgICAgICAgIGxlZnRBbHBoYSA9IGFscGhhTGltaXQ7XG4gICAgICAgICAgICByaWdodEFscGhhID0gYWxwaGE7XG4gICAgICAgIH0gZWxzZSBpZiAoIXRoaXMuX2lzRGlzYWJsZWRNb2RlICYmIHRoaXMudmFsdWUgPj0gdGhpcy5tYXgpIHtcbiAgICAgICAgICAgIGxlZnRBbHBoYSA9IGFscGhhO1xuICAgICAgICAgICAgcmlnaHRBbHBoYSA9IGFscGhhTGltaXQ7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fTGVmdEFycm93LnNtb290aCA9IHtcbiAgICAgICAgICAgIGFscGhhOiBsZWZ0QWxwaGFcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5fUmlnaHRBcnJvdy5zbW9vdGggPSB7XG4gICAgICAgICAgICBhbHBoYTogcmlnaHRBbHBoYVxuICAgICAgICB9O1xuICAgIH1cbiAgICBfdXBkYXRlQXJyb3dzKCkge1xuICAgICAgICB2YXIgYXJyb3dQcm9wcyA9IHtcbiAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUuYXJyb3dXaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuYXJyb3dIZWlnaHQsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIGNvbG9yOiB0aGlzLnN0eWxlLmFycm93Q29sb3JcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5fTGVmdEFycm93LnBhdGNoKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgYXJyb3dQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICBpY29uOiB0aGlzLnN0eWxlLmljb25MZWZ0U3JjXG4gICAgICAgIH0pKTtcbiAgICA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PSB0aGlzLnZhbHVlO1xuICAgICAgICB0aGlzLnZhbHVlID0gbWF4IDwgdmFsdWUgPyBtYXggOiB2YWx1ZTtcbiAgICAgICAgdGhpcy5fdmFsdWVDaGFuZ2VkID0gdmFsdWUgIT09IHRoaXMudmFsdWU7XG4gICAgICAgIHJldHVybiBtYXg7XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5vdW5jZSA9IGFubm91bmNlO1xuICAgIH1cbiAgICBnZXQgYW5ub3VuY2UoKSB7XG4gICAgICAgIGlmICh0aGlzLl9hbm5vdW5jZSAhPT0gdW5kZWZpbmVkICYmIHRoaXMuX2Fubm91bmNlICE9PSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fYW5ub3VuY2U7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMudmFsdWUudG9TdHJpbmcoKTtcbiAgICB9XG4gICAgc3RhdGljIF9zdGF0ZXMoKSB7XG4gICAgICAgIHJldHVybiBbIGNsYXNzIFZlcnRpY2FsU2xpZGVyIGV4dGVuZHModGhpcyl7XG4gICAgICAgICAgICBfaGFuZGxlTGVmdCgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBfaGFuZGxlUmlnaHQoKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX2hhbmRsZVVwKCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX2RlY3JlbWVudFZhbHVlKCk7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uVXAgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5vblVwKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIF9oYW5kbGVEb3duKCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX2luY3JlbWVudFZhbHVlKCk7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uRG93biA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm9uRG93bih0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gXTtcbiAgICB9XG59XG5cbmNsYXNzIE5lc3RlZFNsaWRlciBleHRlbmRzIFNsaWRlciB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIk5lc3RlZFNsaWRlclwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRjO1xuICAgIH1cbn1cblxudmFyIGJhc2UkYSA9IHRoZW1lID0+ICh7XG4gICAgcGFkZGluZ1k6IHRoZW1lLnNwYWNlci5tZCArIHRoZW1lLnNwYWNlci54cyxcbiAgICB2YWx1ZVRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGVtZS50eXBvZ3JhcGh5LmhlYWRsaW5lMyksIHt9LCB7XG4gICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgfSlcbn0pO1xuXG52YXIgbW9kZSQyID0gdGhlbWUgPT4gKHtcbiAgICBkaXNhYmxlZDoge1xuICAgICAgICB2YWx1ZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgIH1cbiAgICB9LFxuICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgdmFsdWVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VTZWNvbmRhcnlcbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgdG9uZSQ1ID0gdGhlbWUgPT4gKHtcbiAgICBuZXV0cmFsOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICB2YWx1ZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlU2Vjb25kYXJ5XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICB2YWx1ZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgdmFsdWVUZXh0U3R5b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gICAgICAgICAgICAgbW91bnRZOiAwLFxuICAgICAgICAgICAgICAgICAgICBmbGV4OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9KSxcbiAgICAgICAgICAgICAgICBTbGlkZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogTmVzdGVkU2xpZGVyLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFg6IC41LFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBvbkNoYW5nZTogXCJfb25TbGlkZXJDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIC4uLnN1cGVyLnByb3BlcnRpZXMsIFwic2xpZGVyXCIsIFwidmFsdWVcIiwgXCJtYXhcIiwgXCJtaW5cIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcInRpdGxlUGFkZGluZ1wiLFxuICAgICAgICAgICAgY3VycjogXCJjb250ZW50U3BhY2luZ1wiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNsaWRlclwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlNsaWRlclwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVmFsdWVcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5UZXh0V3JhcHBlci5WYWx1ZVwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB0aGlzLnZhbHVlID0gNTA7XG4gICAgICAgIHRoaXMubWF4ID0gMTAwO1xuICAgICAgICB0aGlzLm1pbiA9IDA7XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHN1cGVyLl91cGRhdGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlU2xpZGVyUG9zaXRpb24oKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVmFsdWUoKTtcbiAgICB9XG4gICAgX29uVGV4dEJveENoYW5nZWQoKSB7XG4gICAgICAgIHN1cGVyLl9vblRleHRCb3hDaGFuZ2VkKCk7XG4gICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLmggPSBNYXRoLm1heCh0aGlzLl9UaXRsZSA/IHRoaXMuX1RpdGxlLmggOiAwLCB0aGlzLl9WYWx1ZSA/IHRoaXMuX1ZhbHVlLmggOiAwKTtcbiAgICB9XG4gICAgX3VwZGF0ZVZhbHVlKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzVmFsdWUpIHtcbiAgICAgICAgICAgIHZhciB2YWx1ZVBhdGNoID0ge1xuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMudmFsdWUudG9TdHJpbmcoKSxcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudmFsdWVUZXh0U3R5bGUpXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBtb3VudFg6IDEsXG4gICAgICAgICAgICAgICAgeDogdGhpcy53IC0gdGhpcy5fcGFkZGluZ1hcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoIXRoaXMuX1ZhbHVlKSB7XG4gICAgICAgICAgICAgICAgdmFsdWVQYXRjaCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfb25UZXh0Qm94Q2hhbmdlZFwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LCB2YWx1ZVBhdGNoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBWYWx1ZTogdmFsdWVQYXRjaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0V3JhcHBlci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgVmFsdWU6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVNsaWRlclBvc2l0aW9uKCkge1xuICAgICAgICB2YXIgdyA9IHRoaXMudyAtIHRoaXMuX3BhZGRpbmdMZWZ0IC0gdGhpcy5fcGFkZGluZ1JpZ2h0O1xuICAgICAgICB2YXIgc2xpZGVyUHJvcHMgPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgdG9uZTogdGhpcy50b25lLFxuICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgIHg6IHcgLyAyLFxuICAgICAgICAgICAgdmlzaWJsZTogIXRoaXMuX2NvbGxhcHNlLFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuc3R5bGUuYWxwaGFcbiAgICAgICAgfSwgdGhpcy5zbGlkZXIpLCB7fSwge1xuICAgICAgICAgICAgdmFsdWU6IHRoaXMudmFsdWUsXG4gICAgICAgICAgICBtYXg6IHRoaXMubWF4LFxuICAgICAgICAgICAgbWluOiB0aGlzLm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1lLmNvbG9yLmZpbGxJbnZlcnNlXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGFycm93Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICBhcnJvd0NvbG9yOiB0aGVtZS5jb2xvci5maWxsSW52ZXJzZVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkOSA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJDksXG4gICAgdG9uZTogdG9uZSQ0XG59KTtcblxuY2xhc3MgTGlzdEl0ZW1QaWNrZXIgZXh0ZW5kcyBMaXN0SXRlbSB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkxpc3RJdGVtUGlja2VyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJDk7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIucHJvcGVydGllcywgXCJvcHRpb25zXCIsIFwic2VsZWN0ZWRJbmRleFwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIudGFncywgXCJMZWZ0QXJyb3dcIiwgXCJSaWdodEFycm93XCIsIHtcbiAgICAgICAgICAgIG5hbW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5OiBcImxlZnRcIlxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUFycm93cygpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9pc0ZvY3VzZWRNb2RlKSB7XG4gICAgICAgICAgICB2YXIgb2ZmQWxwaGEgPSAuMDAxO1xuICAgICAgICAgICAgaWYgKHRoaXMuX0xlZnRBcnJvdykge1xuICAgICAgICAgICAgICAgIHRoaXMuX0xlZnRBcnJvdy5hbHBoYSA9IG9mZkFscGhhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX1JpZ2h0QXJyb3cpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9SaWdodEFycm93LmFscGhhID0gb2ZmQWxwaGE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGFycm93UHJvcHMgPSB7XG4gICAgICAgICAgICB3OiB0aGlzLnN0eWxlLmFycm93V2lkdGgsXG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmFycm93SGVpZ2h0LFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5hcnJvd0NvbG9yXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuc3R5bGUuYXJyb3dBbHBoYVZhbHVlXG4gICAgICAgIH07XG4gICAgICAgIGlmICghdGhpcy5fTGVmdEFycm93KSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBMZWZ0QXJyb3c6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX0xlZnRBcnJvdy5wYXRjaChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGFycm93UHJvcHMpLCB7fSwge1xuICAgICAgICAgICAgaWNvbjogdGhpcy5zdHlsZS5pY29uTGVmdFNyY1xuICAgICAgICB9KSk7XG4gICAgICAgIHRoaXMuX0xlZnRBcnJvdy5zbW9vdGggPSB7XG4gICAgICAgICAgICB4OiB0aGlzLnN0eWxlLnBhZGRpbmdYXG4gICAgICAgIH07XG4gICAgICAgIGlmICghdGhpcy5fUmlnaHRBcnJvdykge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgUmlnaHRBcnJvdzoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICBtb3VudFg6IDEsXG4gICAgICAgICAgICAgICAgICAgIHk6IGggPT4gaCAvIDJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9SaWdodEFycm93LnBhdGNoKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgYXJyb3dQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICBpY29uOiB0aGlzLnN0eWxlLmljb25SaWdodFNyY1xuICAgICAgICB9KSk7XG4gICAgICAgIHRoaXMuX1JpZ2h0QXJyb3cuc21vb3RoID0ge1xuICAgICAgICAgICAgeDogdGhpcy53IC0gdGhpcy5zdHlsZS5wYWRkaW5nWFxuICAgICAgICB9O1xuICAgIH1cbiAgICBfdXBkYXRlUGlja2VyKCkge1xuICAgICAgICB2YXIgdyA9IHRoaXMudyAtIHRoaXMuX3BhZGRpbmdYIC0gdGhpcy5zdHlsZS5hcnJvd1dpZHRoICogMjtcbiAgICAgICAgaWYgKCF0aGlzLl9QaWNrZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBQaWNrZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogUm93LFxuICAgICAgICAgICAgICAgICAgICBjbGlwcGluZzogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgYWx3YXlzU2Nyb2xsOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RlZENoYW5nZTogXCJfdXBkYXRlQXJyb3dzQWxwaGFcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fUGlja2VyLnBhdGNoKHtcbiAgICAgICAgICAgIHZpc2libGU6ICF0aGlzLl9jb2xsYXBzZSxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuZGVzY3JpcHRpb25UZXh0U3R5bGUubGluZUhlaWdodCxcbiAgICAgICAgICAgIHc6IHcsXG4gICAgICAgICAgICBpdGVtczogdGhpcy5vcHRpb25zLm1hcCgob3B0aW9uID0+ICh7XG4gICAgICAgICAgICAgICAgdHlwZTogTWFycXVlZSxcbiAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uVGV4dFN0eWxlLmxpbmVIZWlnaHQsXG4gICAgICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgICAgICBjZW50ZXJBbGlnbjogdGhpcy5faXNGb2N1c2VkTW9kZSxcbiAgICAgICAgICAgICAgICB0aXRsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uVGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dDogb3B0aW9uXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pKSksXG4gICAgICAgICAgICB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IF93ID0+IF93LFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBTbGlkZXI6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTY3JvbGxTbGlkZXIsXG4gICAgICAgICAgICAgICAgdmVydGljYWw6IHRydWUsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBvblNpemVDaGFuZ2U6IFwiX3VwZGF0ZVNjcm9sbENvbnRhaW5lclNpemVcIlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiIFwiXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJTY3JvbGxXcmFwcGVyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJhdXRvU2Nyb2xsXCIsIFwiYXV0b1Njcm9sbERlbGF5XCIsIFwiYXV0b1Njcm9sbFNwZWVkXCIsIFwiY29udGVudFwiLCBcImZhZGVDb250ZW50XCIsIFwic2Nyb2xsRHVyYXRpb25cIiwgXCJzY3JvbGxTdGVwXCIsIFwic2hvd1Njcm9sbEJhclwiLCBcInNob3VsZFdyYXBcIiwgXCJmbGV4RGlyZWN0aW9uXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkZhZGVDb250YWluZXJcIiwgXCJTbGlkZXJcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJTY3JvbGxDb250YWluZXJcIixcbiAgICAgICAgICAgIHBhdGg6IFwiRmFkZUNvbnRhaW5lci5TY3JvbGxDb250YWluZXJcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBu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XCIpIHtcbiAgICAgICAgICAgIHRoaXMuX1Njcm9sbENvbnRhaW5lci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgZmxleDoge1xuICAgICAgICAgICAgICAgICAgICBkaXJlY3Rpb246IFwiY29sdW1uXCJcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFNjcm9sbGFibGVUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIGg6IDAsXG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuX2NvbnRlbnRXaWR0aCxcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogdGhpcy5jb250ZW50LFxuICAgICAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9jb250ZW50V2lkdGhcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9zY3JvbGxDb250YWluZXJMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBvbkFmdGVyVXBkYXRlOiB0aGlzLl9hZnRlclRleHRCb3hVcGRhdGUuYmluZCh0aGlzKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkodGhpcy5jb250ZW50KSkge1xuICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSB7fTtcbiAgICAgICAgICAgIHRoaXMuY29udGVudC5mb3JFYWNoKCgoaXRlbSwgaW5kZXgpID0+IHtcbiAgICAgICAgICAgICAgICB2YXIgaWQgPSBcIlNjcm9sbFRleHRcIi5jb25jYXQoaW5kZXgpO1xuICAgICAgICAgICAgICAgIGNvbnRlbnRbaWRdID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuX2NvbnRlbnRXaWR0aFxuICAgICAgICAgICAgICAgIH0sIGl0ZW0pO1xuICAgICAgICAgICAgICAgIGlmIChpdGVtLnRleHQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29udGVudFtpZF0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudDogaXRlbS50ZXh0LFxuICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIGl0ZW0uc3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogdGhpcy5fY29udGVudFdpZHRoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBvbkFmdGVyVXBkYXRlOiB0aGlzLl9hZnRlclRleHRCb3hVcGRhdGUuYmluZCh0aGlzKVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIHRoaXMuX1Njcm9sbENvbnRhaW5lci5wYXRjaChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICBmbGV4OiB7XG4gICAgICAgICAgICAgICAgICAgIGRpcmVjdGlvbjogdGhpcy5mbGV4RGlyZWN0aW9uLFxuICAgICAgICAgICAgICAgICAgICB3cmFwOiB0aGlzLnNob3VsZFdyYXBcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LCBjb250ZW50KSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3Njcm9sbERvd24oKSB7XG4gICAgICAgIHZhciBoYXNDb250ZW50VG9TY3JvbGxUbyA9IHRoaXMuX3Njcm9sbENvbnRhaW5lclkgKyB0aGlzLl9TY3JvbGxDb250YWluZXIuZmluYWxIID4gdGhpcy5yZW5kZXJIZWlnaHQ7XG4gICAgICAgIGlmIChoYXNDb250ZW50VG9TY3JvbGxUbykge1xuICAgICAgICAgICAgdmFyIHRhcmdldFkgPSB0aGlzLl9zY3JvbGxDb250YWluZXJZIC0gdGhpcy5zY3JvbGxTdGVwO1xuICAgICAgICAgICAgdmFyIGNhblNjcm9sbEJ5U3RlcExlbmd0aCA9IHRhcmdldFkgKyB0aGlzLl9TY3JvbGxDb250YWluZXIuZmluYWxIID4gdGhpcy5yZW5kZXJIZWlnaHQ7XG4gICAgICAgICAgICB2YXIgc2Nyb2xsRW5kWSA9IHRoaXMucmVuZGVySGVpZ2h0IC0gdGhpcy5fU2Nyb2xsQ29udGFpbmVyLmZpbmFsSCAtIHRoaXMuc3R5bGUuY29udGVudE1hcmdpblRvcDtcbiAgICAgICAgICAgIHRoaXMuX1Njcm9sbENvbnRhaW5lci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgc21vb3RoOiB7XG4gICAgICAgICAgICAgICAgICAgIHk6IFsgY2FuU2Nyb2xsQnlTdGVwTGVuZ3RoID8gdGFyZ2V0WSA6IHNjcm9sbEVuZFksIHRoaXMuX3Njcm9sbEFuaW1hdGlvbiBdXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB2YXIgaGFzU2Nyb2xsZWRUb0VuZCA9IHRoaXMuX3Njcm9sbENvbnRhaW5lclkgKyB0aGlzLl9TY3JvbGxDb250YWluZXIuZmluYWxIIDw9IHRoaXMuaDtcbiAgICAgICAgICAgIGlmIChoYXNTY3JvbGxlZFRvRW5kKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5faXNFbmRDb250ZW50VmlzaWJsZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgdGhpcy5fYXV0b1Njcm9sbENvbXBsZXRlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkc2Nyb2xsQ2hhbmdlZFwiLCBcImVuZERvd25cIiwgdGhpcyk7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlRmFkZUNvbnRhaW5lcigpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9zY3JvbGxVcCgpIHtcbiAgICAgICAgdmFyIGNhblNjcm9sbFVwID0gdGhpcy5fc2Nyb2xsQ29udGFpbmVyWSA8IDA7XG4gICAgICAgIGlmIChjYW5TY3JvbGxVcCkge1xuICAgICAgICAgICAgdmFyIHRhcmdldFkgPSB0aGlzLl9zY3JvbGxDb250YWluZXJZICsgdGhpcy5zY3JvbGxTdGVwO1xuICAgICAgICAgICAgdmFyIGNhblNjcm9sbEJ5U3RlcExlbmd0aCA9IHRhcmdldFkgPCAwO1xuICAgICAgICAgICAgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBzbW9vdGg6IHtcbiAgICAgICAgICAgICAgICAgICAgeTogWyBjYW5TY3JvbGxCeVN0ZXBMZW5ndGggPyB0YXJnZXRZIDogMCwgdGhpcy5fc2Nyb2xsQW5pbWF0aW9uIF1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHZhciBpc1Njcm9sbGFibGUgPSB0aGlzLl9zY3JvbGxDb250YWluZXJZICsgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLmZpbmFsSCA+IHRoaXMucmVuZGVySGVpZ2h0O1xuICAgICAgICAgICAgaWYgKGlzU2Nyb2xsYWJsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2F1dG9TY3JvbGxDb21wbGV0ZSA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX3Njcm9sbENvbnRhaW5lclkgPj0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycyhcIiRzY3JvbGxDaGFuZ2VkXCIsIFwiZW5kVXBcIiwgdGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5faXNFbmRDb250ZW50VmlzaWJsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2lzRW5kQ29udGVudFZpc2libGUgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVGYWRlQ29udGFpbmVyKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmVzZXRTY3JvbGwoKSB7XG4gICAgICAgIHRoaXMuX1Njcm9sbENvbnRhaW5lci55ID0gMDtcbiAgICAgICAgdGhpcy5fU2xpZGVyLnZhbHVlID0gMDtcbiAgICAgICAgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLnRyYW5zaXRpb24oXCJ5XCIpLmZpbmlzaCgpO1xuICAgICAgICBkZWxldGUgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLl90cmFuc2l0aW9ucztcbiAgICAgICAgdGhpcy5fYXV0b1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53IC0gdGhpcy5fc2xpZGVyV2lkdGgsXG4gICAgICAgICAgICAgICAgdzogc2xpZGVyTWF4LFxuICAgICAgICAgICAgICAgIG1pbjogMCxcbiAgICAgICAgICAgICAgICBtYXg6IHNsaWRlck1heCxcbiAgICAgICAgICAgICAgICBzdGVwOiBzbGlkZXJTdGVwLFxuICAgICAgICAgICAgICAgIG9uVXA6IHRoaXMuX3Njcm9sbFVwLmJpbmQodGhpcyksXG4gICAgICAgICAgICAgICAgb25Eb3duOiB0aGlzLl9zY3JvbGxEb3duLmJpbmQodGhpcylcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIGdldCBfY29udGVudFdpZHRoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy53IC0gdGhpcy5zdHlsZS5jb250ZW50TWFyZ2luTGVmdCAtIHRoaXMuc3R5bGUuc2xpZGVyTWFyZ2luTGVmdCAtIHRoaXMuX3NsaWRlcldpZHRoO1xuICAgIH1cbiAgICBnZXQgX3Njcm9sbENvbnRhaW5lclkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9TY3JvbGxDb250YWluZXIudHJhbnNpdGlvbihcInlcIikudGFyZ2V0VmFsdWU7XG4gICAgfVxuICAgIGdldCBfc2Nyb2xsQW5pbWF0aW9uKCkge1xuICAgICAgICB2YXIgZHVyYXRpb24gPSBpc05hTih0aGlzLnNjcm9sbER1cmF0aW9uKSA/IHRoaXMuc3R5bGUuc2Nyb2xsLmR1cmF0aW9uIDogdGhpcy5zY3JvbGxEdXJhdGlvbjtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5zY3JvbGwpLCB7fSwge1xuICAgICAgICAgICAgZHVyYXRpb246IGR1cmF0aW9uXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfZ2V0Rm9jdXNlZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX1NsaWRlcjtcbiAgIC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2V0TWF4Um91bmRSYWRpdXModGhpcy5zdHlsZS5yYWRpdXMsIHRoaXMudywgdGhpcy5oKTtcbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBGcmFtZToge1xuICAgICAgICAgICAgICAgIHc6IHRoaXMudyArIHNoYWRvd1NpemUgKiAyICsgZXh0cmFCb3VuZHNYLFxuICAgICAgICAgICAgICAgIGg6IHRoaXMuaCArIHNoYWRvd1NpemUgKiAyICsgZXh0cmFCb3VuZHNZLFxuICAgICAgICAgICAgICAgIHg6ICh0aGlzLncgKyBleHRyYUJvdW5kc1gpIC8gMixcbiAgICAgICAgICAgICAgICB5OiAodGhpcy5oICsgZXh0cmFCb3VuZHNZKSAvIDIsXG4gICAgICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgICAgIHJ0dDogdGhpcy5tYXNrU2hhZG93LFxuICAgICAgICAgICAgICAgIHNoYWRlcjogdGhpcy5tYXNrU2hhZG93ID8ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBsbmcuc2hhZGVycy5Ib2xlLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLncgLSBob2xlcHVuY2hFcnJvcixcbiAgICAgICAgICAgICAgICAgICAgaDogdGhpcy5oIC0gaG9sZXB1bmNoRXJyb3IsXG4gICAgICAgICAgICAgICAgICAgIHg6IHNoYWRvd1NpemUgKyBob2xlcHVuY2hFcnJvciAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHk6IHNoYWRvd1NpemUgKyBob2xlcHVuY2hFcnJvciAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHJhZGl1czogcmFkaXVzXG4gICAgICAgICAgICAgICAgfSA6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgICAgICBTaGFkb3c6IHtcbiAgICAgICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY29sb3IsXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmU6IGxuZy5Ub29scy5nZXRTaGFkb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ZWRJbmRleCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZhZGVJbkNvbnRlbnQoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2hhc0NvbnRlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9mYWRlSW5Db250ZW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9wcmV2ZVNlbGVjdGVkSW5kZXggPSB0aGlzLnNlbGVjdGVkSW5kZXg7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2ZhZGVJbkNvbnRlbnQoKSB7XG4gICAgICAgIHRoaXMuX3NlbGVjdGVkQ29udGVudC5zbW9vdGggPSB7XG4gICAgICAgICAgICBhbHBoYTogMVxuICAgICAgICB9O1xuICAgICAgICB0aGlzLl9zZWxlY3RlZENvbnRlbnQuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICB0aGlzLmggPSB0aGlzLl9zZWxlY3RlZENvbnRlbnQuaDtcbiAgICAgICAgICAgIHRoaXMuc2lnbmFsKFwiY29udGVudEhlaWdodENoYW5nZVwiLCB0aGlzLmgpO1xuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF91cGRhdGVDb250ZW50KCkge1xuICAgICAgICB2YXIgYWxsQ29udGVudCA9IHRoaXMuY29udGVudEl0ZW1zLnJlZHVjZSgoKGFjYywgaXRlbSwgaWR4KSA9PiB7XG4gICAgICAgICAgICB2YXIgY29tcG9uZW50O1xuICAgICAgICAgICAgdmFyIHRhZ05hbWUgPSBcIkNvbnRlbnRcIi5jb25jYXQoaWR4KTtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNvbXBvbmVudExvYWRlciA9IGl0ZW0oKTtcbiAgICAgICAgICAgICAgICBpZiAoY29tcG9uZW50TG9hZGVyLnRoZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZEFzeW5jQ29tcG9uZW50KGNvbXBvbmVudExvYWRlciwgaWR4KTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRMb2FkZXI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb21wb25lbnQgPSBpdGVtO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGNvbXBvbmVudCkge1xuICAgICAgICAgICAgICAgIGFjY1t0YWdOYW1lXSA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgY29tcG9uZW50KSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IDBcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCB7fSk7XG4gICAgICAgIHRoaXMucGF0Y2goYWxsQ29udGVudCk7XG4gICAgfVxuICAgIF9sb2FkQXN5bmNDb21wb25lbnQoY29tcG9uZW50TG9hZGVyLCBpZHgpIHtcbiAgICAgICAgY29tcG9uZW50TG9hZGVyLnRoZW4oKGNvbXBvbmVudCA9PiB7XG4gICAgICAgICAgICB2YXIgdGFnTmFtZSA9IFwiQ29udGVudFwiLmNvbmNhdChpZHgpO1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgW3RhZ05hbWVdOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGNvbXBvbmVudCksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiAwXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KSk7XG4gICA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c2UkMSB7XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIFRhYnM6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgICAgICAgICAgYXV0b1Jlc2l6ZUhlaWdodDogdHJ1ZSxcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkQ2hhbmdlOiBcIl9zZWxlY3RlZFRhYkNoYW5nZVwiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFRhYkNvbnRlbnQ6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBDb250ZW50U3dpdGNoZXIsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBjb250ZW50SGVpZ2h0Q2hhbmdlOiBcIl91cGRhdGVUYWJCYXJIZWlnaHRcIlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkNDtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIlRhYkJhclwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiYWxwaGFTZWxlY3RlZFRhYlwiLCBcImNvbGxhcHNlXCIsIFwicmVzZXRcIiwgXCJ0YWJzXCIsIFwicmV0YWluU2VsZWN0aW9uXCIsIC4uLlJvdy5wcm9wZXJ0aWVzIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJUYWJzXCIsIFwiVGFiQ29udGVudFwiIF07XG4gICAgfV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FwiIDogXCJ1bmZvY3VzZWRcIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKTtcbiAgICAgICAgaWYgKHRoaXMuYWxwaGFTZWxlY3RlZFRhYikge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGFiQWxwaGFzKCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVRhYkFscGhhcygpIHtcbiAgICAgICAgaWYgKHRoaXMuX2lzVGFic0ZvY3VzZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX1RhYnMuaXRlbXMuZm9yRWFjaCgodGFiID0+IHtcbiAgICAgICAgICAgICAgICB0YWIucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBhbHBoYTogMVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fVGFicy5pdGVtcy5mb3JFYWNoKCh0YWIgPT4ge1xuICAgICAgICAgICAgICAgIHRhYi5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiB0YWIgPT09IHRoaXMuX1RhYnMuc2VsZWN0ZWQgPyAxIDogLjNcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlVGFiQ29udGVudCgpIHtcbiAgICAgICAgdmFyIG1hcmdpbiA9IHRoaXMuc3R5bGUudGFic01hcmdpbkJvdHRvbTtcbiAgICAgICAgdGhpcy5fVGFiQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICB5OiB0aGlzLl9UYWJzLmggKyBtYXJnaW4sXG4gICAgICAgICAgICBjb250ZW50SXRlbXM6IHRoaXMuX3RhYkNvbnRlbnQsXG4gICAgICAgICAgICBzZWxlY3RlZEluZGV4OiB0aGlzLl9pc0ZvY3VzZWRNb2RlID8gdGhpcy5fVGFicy5zZWxlY3RlZEluZ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AgfVxufSk7XG5cbnZhciB0b25lJDIgPSB0aGVtZSA9PiAoe1xuICAgIG5ldXRyYWw6IHt9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGNvbnRlbnRDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWwsXG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICBjb250ZW50Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsLFxuICAgICAgICAgICAgICAgIHRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkMyA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJDMsXG4gICAgbW9kZTogbW9kZSxcbiAgICB0b25lOiB0b25lJDJcbn0pO1xuXG5jbGFzcyBUYWIgZXh0ZW5kcyBTdXJmYWNlIHtcbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fdGVtcGxhdGUoKSksIHt9LCB7XG4gICAgICAgICAgICBDb250ZW50OiB7XG4gICAgICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgICAgIHg6IHcgPT4gdyAvIDIsXG4gICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMixcbiAgICAgICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9vblRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJDM7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJUYWJcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImljb25cIiwgXCJ0aXRsZVwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIudGFncywgXCJDb250ZW50XCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiSWNvblwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50Lkljb25cIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRleHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5UZXh0XCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcIm5vVGl0bGVQYWRkaW5nWFwiLFxuICAgICAgICAgICAgY3VycjogXCJwYWRkaW5nWE5vVGl0bGVcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF9vblRleHRCb3hDaGFuZ2VkKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVDb250ZW50KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRhYlNpemUoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVJY29uKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRleHQoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29udGVudCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVUYWJTaXplKCk7XG4gICAgfVxuICAgIF91cGRhdGVJY29uKCkge1xuICAgICAgICBpZiAoIXRoaXMuaWNvbikge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgSWNvbjogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaWNvblBhdGNoID0ge1xuICAgICAgICAgICAgaWNvbjogdGhpcy5pY29uLFxuICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pY29uU2l6ZSxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaWNvblNpemUsXG4gICAgICAgICAgICB5OiB0aGlzLl9Db250ZW50LmggLyAyLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5jb250ZW50Q29sb3JcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgaWYgKHRoaXMudGl0bGUpIHtcbiAgICAgICAgICAgIGljb25QYXRjaC54ID0gMDtcbiAgICAgICAgICAgIGljb25QYXRjaC5tb3VudFggPSAwO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWNvblBhdGNoLnggPSB0aGlzLl9Db250ZW50LncgLyAyO1xuICAgICAgICAgICAgaWNvblBhdGNoLm1vdW50WCA9IC41O1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9JY29uKSB7XG4gICAgICAgICAgICB0aGlzLl9JY29uLnBhdGNoKGljb25QYXRjaCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBJY29uOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNVxuICAgICAgICAgICAgICAgIH0sIGljb25QYXRjaClcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVUZXh0KCkge1xuICAgICAgICB2YXIgdGV4dFBhdGNoID0ge1xuICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLnRleHRTdHlsZVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHk6IHRoaXMuX0NvbnRlbnQuaCAvIDJcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKHRoaXMuaWNvbikge1xuICAgICAgICAgICAgdGV4dFBhdGNoLnggPSB0aGlzLl9pY29uVyArIHRoaXMuc3R5bGUuaWNvbk1hcmdpblJpZ2h0O1xuICAgICAgICAgICAgdGV4dFBhdGNoLm1vdW50WCA9IDA7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0ZXh0UGF0Y2gueCA9IHRoaXMuX0NvbnRlbnQudyAvIDI7XG4gICAgICAgICAgICB0ZXh0UGF0Y2gubW91bnRYID0gLjU7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh0ZXh0UGF0Y2gpO1xuICAgIH1cbiAgICBfdXBkYXRlQ29udGVudCgpIHtcbiAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICB3OiB0aGlzLl9pY29uVyArICh0aGlzLnRpdGxlID8gdGhpcy5zdHlsZS5pY29uTWFyZ2luUmlnaHQgOiAwKSArIHRoaXMuX3RleHRXLFxuICAgICAgICAgICAgaDogTWF0aC5tYXgodGhpcy5faWNvbkgsIHRoaXMuX1RleHQuaClcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVUYWJTaXplKCkge1xuICAgICAgICBpZiAodGhpcy50aXRsZSB8fCB0aGlzLmljb24pIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIHc6IHRoaXMuX3BhZGRpbmdYICogMiArIHRoaXMuX0NvbnRlbnQudyxcbiAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLnBhZGRpbmdZICogMiArIHRoaXMuX0NvbnRlbnQuaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICB3OiAwLFxuICAgICAgICAgICAgICAgIGg6IDBcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIGdldCBfdGV4dFcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnRpdGxlID8gdGhpcy5fVGV4dC53IDogMDtcbiAgICB9XG4gICAgZ2V0IF9pY29uVygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuaWNvbiAmJiB0aGlzLl9JY29uICE9PSB1bmRlZmluZWQgPyB0aGlzLl9JY29uLncgOiAwO1xuICAgIH1cbiAgICBnZXQgX2ljb25IKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5pY29uICYmIHRoaXMuX0ljb24gIT09IHVuZGVmaW5lZCA/IHRoaXMuX0ljb24uaCA6IDA7XG4gICAgfV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AgICAgICAgcGF0aDogXCJDb250YWluZXIuS25vYlwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiU3Ryb2tlXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRhaW5lci5TdHJva2VcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJjaGVja2VkXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBhbGlhc1N0eWxlcygpIHtcbiAgICAgICAgcmV0dXJuIFsge1xuICAgICAgICAgICAgcHJldjogXCJzdHJva2VXZWlnaHRcIixcbiAgICAgICAgICAgIGN1cnI6IFwic3Ryb2tlV2lkdGhcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF9jb25zdHJ1Y3QoKSB7XG4gICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QgJiYgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB0aGlzLl9jaGVja2VkID0gZmFsc2U7XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUtub2JQb3NpdGlvbigpO1xuICAgICAgICB0aGlzLl91cGRhdGVDb2xvcnMoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29udGFpbmVyKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVN0cm9rZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVLbm9iKCk7XG4gICAgICAgIGlmICh0aGlzLl9jaGVja2VkQ2hhbmdlZCkge1xuICAgICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKFwiJGFubm91bmNlXCIsIHRoaXMuYW5ub3VuY2UpO1xuICAgICAgICAgICAgdGhpcy5fY2hlY2tlZENoYW5nZWQgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlS25vYlBvc2l0aW9uKCkge1xuICAgICAgICB2YXIge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ZXR1cm4gc3R5bGVzO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgYWxwaGE6IDAsXG4gICAgICAgICAgICBzY2FsZTogLjUsXG4gICAgICAgICAgICBtb3VudFg6IC41LFxuICAgICAgICAgICAgeDogdyA9PiB3IC8gMixcbiAgICAgICAgICAgIEJhY2tncm91bmQ6IHtcbiAgICAgICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl90ZXh0TG9hZGVkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcInRpdGxlXCIsIFwiZGVsYXlWaXNpYmxlXCIsIFwidGltZVZpc2libGVcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQmFja2dyb3VuZFwiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRleHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQmFja2dyb3VuZC5UZXh0XCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcInBvaW50ZXJIXCIsXG4gICAgICAgICAgICBjdXJyOiBcInBvaW50ZXJIZWlnaHRcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBwcmV2OiBcInBvaW50ZXJXXCIsXG4gICAgICAgICAgICBjdXJyOiBcInBvaW50ZXJXaWR0aFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGV4dCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVCYWNrZ3JvdW5kKCk7XG4gICAgfVxuICAgIF91cGRhdGVUZXh0KCkge1xuICAgICAgICBpZiAodGhpcy5fVGV4dCkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUudGV4dFN0eWxlXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3RleHRMb2FkZWQoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUJhY2tncm91bmRIZWlnaHQoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGV4dFBvc2l0aW9uKCk7XG4gICAgfVxuICAgIF91cGRhdGVCYWNrZ3JvdW5kKCkge1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIEJhY2tncm91bmQ6IHtcbiAgICAgICAgICAgICAgICB0ZXh0dXJlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEJ1YmJsZSxcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fQmFja2dyb3VuZC53LFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLl9CYWNrZ3JvdW5kLmgsXG4gICAgICAgICAgICAgICAgICAgIHJhZGl1czogZ2V0TWF4Um91bmRSYWRpdXModGhpcy5zdHlsZS5yYWRpdXMsIHRoaXMuX0JhY2tncm91bmQudyAtIHRoaXMuc3R5bGUucG9pbnRlckhlaWdodCwgdGhpcy5fQmFja2dyb3VuZC5oIC0gdGhpcy5zdHlsZS5wb2ludGVySGVpZ2h0KSxcbiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcldpZHRoOiB0aGlzLnN0eWxlLnBvaW50ZXJXaWR0aCxcbiAgICAgICAgICAgICAgICAgICAgcG9pbnRlckhlaWdodDogdGhpcy5zdHlsZS5wb2ludGVySGVpZ2h0LFxuICAgICAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5iYWNrZ3JvdW5kQ29sb3JcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlQmFja2dyb3VuZEhlaWdodCgpIHtcbiAgICAgICAgdmFyIGJhY2tncm91bmRIID0gdGhpcy5fVGV4dC5maW5hbEggKyB0aGlzLnN0eWxlLnBhZGRpbmdZICogMiArIHRoaXMuc3R5bGUucG9pbnRlckhlaWdodDtcbiAgICAgICAgdmFyIGJhY2tncm91bmRXID0gdGhpcy5fVGV4dC5maW5hbFcgKyB0aGlzLnN0eWxlLnBhZGRpbmdYICogMjtcbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICB3OiBiYWNrZ3JvdW5kVyxcbiAgICAgICAgICAgIGg6IGJhY2tncm91bmRILFxuICAgICAgICAgICAgbW91bnRZOiAxLFxuICAgICAgICAgICAgeTogLXRoaXMuc3R5bGUubWFyZ2luQm90dG9tLFxuICAgICAgICAgICAgQmFja2dyb3VuZDoge1xuICAgICAgICAgICAgICAgIHc6IGJhY2tncm91bmRXLFxuICAgICAgICAgICAgICAgIGg6IGJhY2tncm91bmRILFxuICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQnViYmxlLFxuICAgICAgICAgICAgICAgICAgICB3OiBiYWNrZ3JvdW5kVyxcbiAgICAgICAgICAgICAgICAgICAgaDogYmFja2dyb3VuZEhcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlVGV4dFBvc2l0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fVGV4dCkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgICAgIHg6IHRoaXMuX0JhY2tncm91bmQudyAvIDIsXG4gICAgICAgICAgICAgICAgeTogKHRoaXMuX0JhY2tncm91bmQuaCAtIHRoaXMuc3R5bGUucG9pbnRlckhlaWdodCkgLyAyXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfY2xlYXJUaW1lcnMoKSB7XG4gICAgICAgIGNsZWFyVGltZW91dCh0aGlzLl9oaWRlVGltZXIpO1xuICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5fc2hvd1RpbWVyKTtcbiAgICB9XG4gICAgX3RyYW5zaXRpb25JbigpIHtcbiAgICAgICAgdmFyIHNtb290aCA9IHtcbiAgICAgICAgICAgIHNtb290aDoge1xuICAgICAgICAgICAgICAgIGFscGhhOiBbIDEsIHRoaXMuc3R5bGUudHJhbnNpdGlvbiBdLFxuICAgICAgICAgICAgICAgIHNjYWxlOiBbIDEsIHRoaXMuc3R5bGUudHJhbnNpdGlvbiBdXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIGlmICh0aGlzLmRlbGF5VmlzaWJsZSkge1xuICAgICAgICAgICAgdGhpcy5fc2hvd1RpbWVyID0gc2V0VGltZW91dCgoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBzbW9vdGg6IHNtb290aFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSksIHRoaXMuZGVsYXlWaXNpYmxlKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3Nob3dUaW1lciA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIHNtb290aDogc21vb3RoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9oaWRlVGltZXIgPSB0aGlzLnRpbWVWaXNpYmxlID8gc2V0VGltZW91dCgoKCkgPT4ge1xuICAgICAgICAgICAgdGhpcy5fdW5mb2N1cygpO1xuICAgICAgICB9KSwgdGhpcy50aW1lVmlzaWJsZSArICh0aGlzLmRlbGF5VmlzaWJsZSB8fCAwKSkgOiB1bmRlZmluZWQ7XG4gICAgfVxuICAgIF90cmFuc2l0aW9uT3V0KCkge1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIHNtb290aDoge1xuICAgICAgICAgICAgICAgIGFscGhhOiBbIDAsIHRoaXMuc3R5bGUudHJhbnNpdGlvbiBdLFxuICAgICAgICAgICAgICAgIHNjYWxlOiBbIC41LCB0aGlzLnN0eWxlLnRyYW5zaXRpb24gXVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX2ZvY3VzKCkge1xuICAgICAgICB0aGlzLl9jbGVhclRpbWVycygpO1xuICAgICAgICB0aGlzLl90cmFuc2l0aW9uSW4oKTtcbiAgICB9XG4gICAgX3VuZm9jdXMoKSB7XG4gICAgICAgIHRoaXMuX2NsZWFyVGltZXJzKCk7XG4gICAgICAgIHRoaXMuX3RyYW5zaXRpb25PdXQoKTtcbiAgICB9XG4gICAgc2V0IGFubm91bmNlKGFubm91bmNlKSB7XG4gICAgICAgIHN1cGVyLmFubm91bmNlID0gYW5ub3VuY2U7XG4gICAgfVxuICAgIGdldCBhbm5vdW5jZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2Fubm91bmNlIHx8IHRoaXMuX1RleHQgJiYgdGhpcy5fVGV4dC5hbm5vdW5jZTtcbiAgICB9XG59XG5cbnZhciBwb29scyA9IG5ldyBNYXA7XG5cbmZ1bmN0aW9uIGdldChrZXkpIHtcbiAgICBpZiAocG9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c29sdmUocmVtYWluaW5nUGhyYXNlcy5zaGlmdCgpKTtcbiAgICAgICAgICAgICAgICBpZiAoIWFjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBwaHJhc2UgPT09IFwic3RyaW5nXCIgJiYgcGhyYXNlLmluY2x1ZGVzKFwiUEFVU0UtXCIpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBwYXVzZSA9IHBocmFzZS5zcGxpdChcIlBBVVNFLVwiKVsxXSAqIDFlMztcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzTmFOKHBhdXNlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcGF1c2UgPSAwO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHlpZWxkIGRlbGF5KHBhdXNlKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBwaHJhc2UgPT09IFwic3RyaW5nXCIgJiYgcGhyYXNlLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdG90YWxSZXRyaWVzID0gMztcbiAgICAgICAgICAgICAgICAgICAgdmFyIHJldHJpZXNMZWZ0ID0gdG90YWxSZXRyaWVzO1xuICAgICAgICAgICAgICAgICAgICB3aGlsZSAoYWN0aXZlICYmIHJldHJpZXNMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB5aWVsZCBzcGVhayhwaHJhc2UsIHV0dGVyYW5jZXMsIGxhbmcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHJpZXNMZWZ0ID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZSBpbnN0YW5jZW9mIFNwZWVjaFN5bnRoZXNpc0Vycm9yRXZlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGUuZXJyb3IgPT09IFwibmV0d29ya1wiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXRyaWVzTGVmdC0tO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiU3BlZWNoIHN5bnRoZXNpcyBuZXR3b3JrIGVycm9yLiBSZXRyaWVzIGxlZnQ6IFwiLmNvbmNhdChyZXRyaWVzTGVmdCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeWllbGQgZGVsYXkoNTAwICogKHRvdGFsUmV0cmllcyAtIHJldHJpZXNMZWZ0KSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZS5lcnJvciA9PT0gXCJjYW5jZWxlZFwiIHx8IGUuZXJyb3IgPT09IFwiaW50ZXJydXB0ZWRcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0cmllc0xlZnQgPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiU3BlZWNoU3ludGhlc2lzRXJyb3JFdmVudDogXCIuY29uY2F0KGUuZXJyb3IpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgcGhyYXNlID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNlcmllc1Jlc3VsdCA9IHNwZWFrU2VyaWVzKHBocmFzZSgpLCBsYW5nLCBmYWxzZSk7XG4gICAgICAgICAgICAgICAgICAgIG5lc3RlZFNlcmllc1Jlc3VsdHMucHVzaChzZXJpZXNSZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICB5aWVsZCBzZXJpZXNSZXN1bHQuc2VyaWVzO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShwaHJhc2UpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBfc2VyaWVzUmVzdWx0ID0gc3BlYWtTZXJpZXMocGhyYXNlLCBsYW5nLCBmYWxzZSk7XG4gICAgICAgICAgICAgICAgICAgIG5lc3RlZFNlcmllc1Jlc3VsdHMucHVzaChfc2VyaWVzUmVzdWx0KTtcbiAgICAgICAgICAgICAgICAgICAgeWllbGQgX3Nlcmllc1Jlc3VsdC5zZXJpZXM7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgYWN0aXZlID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICB9KSkoKTtcbiAgICByZXR1cm4ge1xuICAgICAgICBzZXJpZXM6IHNlcmllc0NoYWluLFxuICAgICAgICBnZXQgYWN0aXZlKCkge1xuICAgICAgICAgICAgcmV0dXJuIGFjdGl2ZTtcbiAgICAgICAgfSxcbiAgICAgICAgYXBwZW5kOiB0b1NwZWFrID0+IHtcbiAgICAgICAgICAgIHJlbWFpbmluZ1BocmFzZXMucHVzaCh0b1NwZWFrKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiAoKSA9PiB7XG4gICAgICAgICAgICBpZiAoIWFjdGl2ZSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChyb290KSB7XG4gICAgICAgICAgICAgICAgc3ludGgu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RyYW5zbGF0ZUFiYnJldih0b0Fubm91bmNlLCBhbm5vdW5jZXJPcHRpb25zLmFiYnJldmlhdGlvbnNDb25maWcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHNwZWVjaCA9IHNwZWFrKHRvU3BlYWssIG9wdGlvbnMubGFuZ3VhZ2UpO1xuICAgICAgICAgICAgaWYgKHNwZWVjaCAmJiBzcGVlY2guc2VyaWVzKSB7XG4gICAgICAgICAgICAgICAgc3BlZWNoLnNlcmllcy50aGVuKCgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuZW1pdChcImFubm91bmNlRW5kZWRcIik7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHRvQW5ub3VuY2VTdHIgPSBBcnJheS5pc0FycmF5KHRvU3BlYWspID8gdG9TcGVhay5jb25jYXQoKS5qb2luKFwiIFwiKSA6IHRvU3BlYWs7XG4gICAgICAgICAgICB2YXIgdG9Bbm5vdW5jZVdvcmRzID0gdG9Bbm5vdW5jZVN0ci5zcGxpdChcIiBcIik7XG4gICAgICAgICAgICB2YXIgdGltZW91dERlbGF5ID0gdG9Bbm5vdW5jZVdvcmRzLmxlbmd0aCAqIGFubm91bmNlck9wdGlvbnMudm9pY2VPdXREZWxheTtcbiAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aGlzLl9hbm5vdW5jZUVuZGVkVGltZW91dCk7XG4gICAgICAgICAgICB0aGlzLl9hbm5vdW5jZUVuZGVkVGltZW91dCA9IHNldFRpbWVvdXQoKCgpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLmVtaXQoXCJhbm5vdW5jZVRpbWVvdXRFbmRlZFwiKTtcbiAgICAgICAgICAgIH0pLCB0aW1lb3V0RGVsYXkpO1xuICAgICAgICAgICAgcmV0dXJuIHNwZWVjaDtcbiAgICAgICAgfVxuICAgICAgICBfYnVpbGQoKSB7XG4gICAg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gICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX2xhc3RGb2N1c1BhdGggPSBmb2N1c1BhdGguc2xpY2UoMCk7XG4gICAgICAgICAgICB0aGlzLmZvY3VzRGlmZkhvb2sgPSBmb2N1c0RpZmY7XG4gICAgICAgICAgICBpZiAoIXRoaXMuYW5ub3VuY2VyRW5hYmxlZCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciB0b0Fubm91bmNlID0gZm9jdXNEaWZmLnJlZHVjZSgoKGFjYywgZWxtKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVsbS5hbm5vdW5jZSkge1xuICAgICAgICAgICAgICAgICAgICBhY2MucHVzaChbIGVsbU5hbWUoZWxtKSwgXCJBbm5vdW5jZVwiLCBlbG0uYW5ub3VuY2UgXSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbG0udGl0bGUpIHtcbiAgICAgICAgICAgICAgICAgICAgYWNjLnB1c2goWyBlbG1OYW1lKGVsbSksIFwiVGl0bGVcIiwgZWxtLnRpdGxlIHx8IFwiXCIgXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwgW10pO1xuICAgICAgICAgICAgZm9jdXNEaWZmLnJldmVyc2UoKS5yZWR1Y2UoKChhY2MsIGVsbSkgPT4ge1xuICAgICAgICAgICAgICAgIGlmIChlbG0uYW5ub3VuY2VDb250ZXh0KSB7XG4gICAgICAgICAgICAgICAgICAgIGFjYy5wdXNoKFsgZWxtTmFtZShlbG0pLCBcIkNvbnRleHRcIiwgZWxtLmFubm91bmNlQ29udGV4dCBdKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBhY2MucHVzaChbIGVsbU5hbWUoZWxtKSwgXCJObyBDb250ZXh0XCIsIFwiXCIgXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwgdG9Bbm5vdW5jZSk7XG4gICAgICAgICAgICBpZiAodGhpcy5kZWJ1Zykge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUudGFibGUodG9Bbm5vdW5jZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0b0Fubm91bmNlID0gdG9Bbm5vdW5jZS5yZWR1Y2UoKChhY2MsIGEpID0+IHtcbiAgICAgICAgICAgICAgICB2YXIgdHh0ID0gYVsyXTtcbiAgICAgICAgICAgICAgICB0eHQgJiYgYWNjLnB1c2godHh0KTtcbiAgICAgICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICAgICAgfSksIFtdKTtcbiAgICAgICAgICAgIGlmICh0b0Fubm91bmNlLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHRoaXMuJGFubm91bmNlckNhbmNlbCgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2N1cnJlbnRseVNwZWFraW5nID0gdGhpcy5fdm9pY2VPdXQodG9Bbm5vdW5jZS5yZWR1Y2UoKChhY2MsIHZhbCkgPT4gYWNjLmNvbmNhdCh2YWwpKSwgW10pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICAkYW5ub3VuY2UodG9Bbm5vdW5jZSkge1xuICAgICAgICAgICAgdmFyIHthcHBlbmQ6IGFwcGVuZCA9IGZhbHNlLCBub3RpZmljYXRpb246IG5vdGlmaWNhdGlvbiA9IGZhbHNlfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307XG4gICAgICAgICAgICBpZiAoIXRvQW5ub3VuY2UgfHwgIXRvQW5ub3VuY2UudHJpbSgpLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLmFubm91bmNlckVuYWJsZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9kZWJvdW5jZUFubm91bmNlRm9jdXNDaGFuZ2VzLmZsdXNoKCk7XG4gICAgICAgICAgICAgICAgaWYgKGFwcGVuZCAmJiB0aGlzLl9jdXJyZW50bHlTcGVha2luZyAmJiB0aGlzLl9jdXJyZW50bHlTcGVha2luZy5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3VycmVudGx5U3BlYWtpbmcuYXBwZW5kKHRvQW5ub3VuY2UpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuJGFubm91bmNlckNhbmNlbCgpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jdXJyZW50bHlTcGVha2luZyA9IHRoaXMuX3ZvaWNlT3V0KHRvQW5ub3VuY2UpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAobm90aWZpY2F0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZvaWNlT3V0RGlzYWJsZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jdXJyZW50bHlTcGVha2luZy5zZXJpZXMuZmluYWxseSgoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdm9pY2VPdXREaXNhYmxlZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4kYW5ub3VuY2VyUmVmcmVzaCgpO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgICRhbm5vdW5jZXJDYW5jZWwoKSB7XG4gICAgICAgICAgICB0aGlzLl9jdXJyZW50bHlTcGVha2luZyAmJiB0aGlzLl9jdXJyZW50bHlTcGVha2luZy5jYW5jZWwoKTtc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ICBbYXJyYXlbY3VycmVudF0sIGFycmF5W3ByZXZpb3VzXV0gPSBbIGFycmF5W3ByZXZpb3VzXSwgYXJyYXlbY3VycmVudF0gXTtcbiAgICAgICAgICAgIHN1cGVyLnNlbGVjdGVkSW5kZXggPSBjdXJyZW50O1xuICAgICAgICB9XG4gICAgICAgIF9nZXRQb3NpdGlvblZhbHVlKGl0ZW0sIGF4aXMpIHtcbiAgICAgICAgICAgIHJldHVybiBpdGVtLnRyYW5zaXRpb24oYXhpcykgPyBpdGVtLnRyYW5zaXRpb24oYXhpcykudGFyZ2V0VmFsdWUgOiBpdGVtW2F4aXNdO1xuICAgICAgICB9XG4gICAgICAgIF93YWl0Rm9yVHJhbnNpdGlvbihpdGVtLCBheGlzKSB7XG4gICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUgPT4gaXRlbS5fZ2V0VHJhbnNpdGlvbihheGlzKS5vbihcImZpbmlzaFwiLCByZXNvbHZlKSkpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBzZWxlY3RlZEluZGV4KCkge1xuICAgICAgICAgICAgcmV0dXJuIHN1cGVyLnNlbGVjdGVkSW5kZXg7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IHNlbGVjdGVkSW5kZXgoaW5kZXgpIHtcbiAgICAgICAgICAgIHZhciBfdGhpczEwID0gdGhpcztcbiAgICAgICAgICAgIGlmICghdGhpcy5pc0VkaXRpbmcgfHwgdGhpcy5zZWxlY3RlZEluZGV4ID49IHRoaXMuaXRlbXMubGVuZ3RoIC0gMSAmJiBpbmRleCA+IHRoaXMuc2VsZWN0ZWRJbmRleCkge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VkaXRpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgc3VwZXIuc2VsZWN0ZWRJbmRleCA9IGluZGV4O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB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ICAgICAgICB4MCA9IHdpZHRoO1xuICAgICAgICB5MCA9IGhlaWdodCAvIDIgLSBhO1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSAyOlxuICAgICAgICB4MCA9IHdpZHRoO1xuICAgICAgICB5MCA9IGhlaWdodCAvIDIgKyBhO1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSAzOlxuICAgICAgICB4MCA9IHdpZHRoIC8gMiArIGE7XG4gICAgICAgIHkwID0gaGVpZ2h0O1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA0OlxuICAgICAgICB4MCA9IHdpZHRoIC8gMiAtIGE7XG4gICAgICAgIHkwID0gaGVpZ2h0O1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA1OlxuICAgICAgICB5MCA9IGhlaWdodCAvIDIgKyBhO1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA2OlxuICAgICAgICB5MCA9IGhlaWdodCAvIDIgLSBhO1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA3OlxuICAgICAgICB4MCA9IHdpZHRoIC8gMiAtIGE7XG4gICAgICAgIGJyZWFrO1xuICAgIH1cbiAgICBpZiAoeDAgPT0gMCkge1xuICAgICAgICB4MSA9IHdpZHRoO1xuICAgICAgICB5MSA9IGhlaWdodCAtIHkwO1xuICAgIH1cbiAgICBpZiAoeTAgPT0gMCkge1xuICAgICAgICB5MSA9IGhlaWdodDtcbiAgICAgICAgeDEgPSB3aWR0aCAtIHgwO1xuICAgIH1cbiAgICBpZiAoeDAgPT0gd2lkdGgpIHtcbiAgICAgICAgeDEgPSAwO1xuICAgICAgICB5MSA9IGhlaWdodCAtIHkwO1xuICAgIH1cbiAgICBpZiAoeTAgPT0gaGVpZ2h0KSB7XG4gICAgICAgIHkxID0gMDtcbiAgICAgICAgeDEgPSB3aWR0aCAtIHgwO1xuICAgIH1cbiAgICByZXR1cm4ge1xuICAgICAgICB4MDogeDAsXG4gICAgICAgIHkwOiB5MCxcbiAg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UNvbG9yO1xuICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IGNvbG9yO1xuICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgY3R4LmFyYyhkaW1lbnNpb24sIGRpbWVuc2lvbiwgcmFkaXVzLCAwLCAyICogTWF0aC5QSSk7XG4gICAgICAgICAgICBpZiAoZmlsbCkge1xuICAgICAgICAgICAgICAgIGN0eC5maWxsKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc3Ryb2tlKSB7XG4gICAgICAgICAgICAgICAgY3R4LnN0cm9rZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgICAgIHNvdXJjZTogY2FudmFzLFxuICAgICAgICAgICAgICAgIHJhZGl1czogcmFkaXVzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfTtcbiAgICB9XG59XG5cbmNsYXNzIEFycm93IGV4dGVuZHMgbG5nLlRleHR1cmUge1xuICAgIGNvbnN0cnVjdG9yKHN0YWdlKSB7XG4gICAgICAgIHN1cGVyKHN0YWdlKTtcbiAgICAgICAgdGhpcy5fY29sb3IgPSBcInJnYigxMywgMTMsIDE1KVwiO1xuICAgICAgICB0aGlzLl93ID0gMDtcbiAgICAgICAgdGhpcy5faCA9IDA7XG4gICAgICAgIHRoaXMuX2RpcmVjdGlvbiA9IFwicmlnaHRcIjtcbiAgICB9XG4gICAgZ2V0IHcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93O1xuICAgIH1cbiAgICBzZXQgdyhsKSB7XG4gICAgICAgIHRoaXMuX3cgPSBsO1xuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgfVxuICAgIGdldCBoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG4gICAgc2V0IGgobCkge1xuICAgICAgICB0aGlzLl9oID0gbDtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuIC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vbG9yO1xuICAgICAgICAgICAgY3R4LnN0cm9rZVN0eWxlID0gY3R4LmZpbGxTdHlsZTtcbiAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSAyO1xuICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSBcInJvdW5kXCI7XG4gICAgICAgICAgICBjdHgubGluZUpvaW4gPSBcInJvdW5kXCI7XG4gICAgICAgICAgICB2YXIgcCA9IGN0eC5saW5lV2lkdGggLyAyO1xuICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgaWYgKGRpcmVjdGlvbiA9PT0gXCJyaWdodFwiKSB7XG4gICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyhwLCBwKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVRvKHAsIGggLSBwKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVRvKHcgLSBwLCBoIC8gMik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGRpcmVjdGlvbiA9PT0gXCJkb3duXCIpIHtcbiAgICAgICAgICAgICAgICBjdHgubW92ZVRvKHAsIHApO1xuICAgICAgICAgICAgICAgIGN0eC5saW5lVG8odyAtIHAsIHApO1xuICAgICAgICAgICAgICAgIGN0eC5saW5lVG8odyAvIDIsIGggLSBwKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyhwLCBoIC8gMik7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh3IC0gcCwgcCk7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh3IC0gcCwgaCAtIHApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpO1xuICAgICAgICAgICAgY3R4LnN0cm9rZSgpO1xuICAgICAgICAgICAgY3R4LmZpbGwoKTtcbiAgICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgICAgICBzb3VyY2U6IGNhbnZhcyxcbiAgICAgICAgICA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ICB2YXIgdyA9IHRoaXMuX3c7XG4gICAgICAgIHZhciBoID0gdGhpcy5faDtcbiAgICAgICAgdmFyIHJvdW5kZWQgPSB0aGlzLl9yb3VuZGVkO1xuICAgICAgICB2YXIgY2FudmFzID0gdGhpcy5zdGFnZS5wbGF0Zm9ybS5nZXREcmF3aW5nQ2FudmFzKCk7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbihjYikge1xuICAgICAgICAgICAgdmFyIGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KFwiMmRcIik7XG4gICAgICAgICAgICBjYW52YXMud2lkdGggPSB3O1xuICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IGg7XG4gICAgICAgICAgICBjdHgubGluZVdpZHRoID0gaDtcbiAgICAgICAgICAgIGlmIChyb3VuZGVkKSB7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSBcInJvdW5kXCI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBcIndoaXRlXCI7XG4gICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7XG4gICAgICAgICAgICBjdHgubW92ZVRvKHJvdW5kZWQgPyAyIDogMCwgaCAvIDIpO1xuICAgICAgICAgICAgY3R4LmxpbmVUbyhyb3VuZGVkID8gdyAtIDIgOiB3LCBoIC8gMik7XG4gICAgICAgICAgICBjdHguc3Ryb2tlKCk7XG4gICAgICAgICAgICBjYihudWxsLCB7XG4gICAgICAgICAgICAgICAgc291cmNlOiBjYW52YXMsXG4gICAgICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgICAgICBoOiBoLFxuICAgICAgICAgICAgICAgIHJvdW5kZWQ6IHJvdW5kZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgU2lnbmFsQnV0dG9uIGV4dGVuZHMgQnV0dG9uIHtcbiAgICBvbkVudGVyKCkge1xuICAgICAgICB0aGlzLnNpZ25hbCh0aGlzL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bHBoYTogMC41LFxuICAgICAgICBzaGFkZXI6IHsgdHlwZTogTGlnaHRuaW5nLnNoYWRlcnMuUm91bmRlZFJlY3RhbmdsZSwgcmFkaXVzOiAxMCB9LFxuICAgICAgICBOcjoge1xuICAgICAgICAgIHc6IHcgPT4gdyxcbiAgICAgICAgICB5OiAyNCxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiAnJyxcbiAgICAgICAgICAgIHRleHRDb2xvcjogMHhmZjMzMzMzMyxcbiAgICAgICAgICAgIGZvbnRTaXplOiA4MCxcbiAgICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiAnbWlkZGxlJyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfVxuICAgIH1cblxuICAgIHNldCBpbmRleCh2KSB7XG4gICAgICB0aGlzLnggPSB2ICogKDEyMCArIDI0KVxuICAgIH1cblxuICAgIHNldCBucih2KSB7XG4gICAgICB0aGlzLl90aW1lb3V0ICYmIGNsZWFyVGltZW91dCh0aGlzLl90aW1lb3V0KVxuXG4gICAgICBpZiAodikge1xuICAgICAgICB0aGlzLnNldFNtb290aCgnYWxwaGEnLCAxKVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhpcy5zZXRTbW9vdGgoJ2FscGhhJywgMC41KVxuICAgICAgfVxuXG4gICAgICB0aGlzLnRhZygnTnInKS5wYXRjaCh7XG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICB0ZXh0OiAodiAmJiB2LnRvU3RyaW5nKCkpIHx8ICcnLFxuICAgICAgICAgIGZvbnRTaXplOiB2ID09PSAnKicgPyAxMjAgOiA4MCxcbiAgICAgICAgfSxcbiAgICAgIH0pXG5cbiAgICAgIGlmICh2ICYmIHYgIT09ICcqJykge1xuICAgICAgICB0aGlzLl90aW1lb3V0ID0gc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgICAgdGhpcy5fdGltZW91dCA9IG51bGxcbiAgICAgICAgICB0aGlzLm5yID0gJyonXG4gICAgICAgIH0sIDc1MClcbiAgICAgIH1cbiAgICB9XG4gIH1cblxufVxuXG5leHBvcnQgZGVmYXVsdCAoKSA9PiB7XG4gIHJldHVybiBjbGFzcyBQaW5EaWFsb2cgZXh0ZW5kcyBMaWdodG5pbmcuQ29tcG9uZW50IHtcbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgekluZGV4OiAxLFxuICAgICAgICB3OiB3ID0+IHcsXG4gICAgICAgIGg6IGggPT4gaCxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgY29sb3I6IDB4ZGQwMDAwMDAsXG4gICAgICAgIGFscGhhOiAwLjAwMDAwMSxcbiAgICAgICAgRGlhbG9nOiB7XG4gICAgICAgICAgdzogNjQ4LFxuICAgICAgICAgIGg6IDMyMCxcbiAgICAgICAgICB5OiBoID0+IChoIC0gMzIwKSAvIDIsXG4gICAgICAgICAgeDogdyA9PiAodyAtIDY0OCkgLyAyLFxuICAgICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgICAgY29sb3I6IDB4ZGQzMzMzMzMsXG4gICAgICAgICAgc2hhZGVyOiB7IHR5cGU6IExpZ2h0bmluZy5zaGFkZXJzLlJvdW5kZWRSZWN0YW5nbGUsIHJhZGl1czogMTAgfSxcbiAgICAgICAgICBJbmZvOiB7XG4gICAgICAgICAgICB5OiAyNCxcbiAgICAgICAgICAgIHg6IDQ4LFxuICAgICAgICAgICAgdGV4dDogeyB0ZXh0OiAnUGxlYXNlIGVudGVyIHlvdXIgUElOJywgZm9udFNpemU6IDMyIH0sXG4gICAgICAgICAgfSxcbiAgICAgICAgICBNc2c6IHtcbiAgICAgICAgICAgIHk6IDI2MCxcbiAgICAgICAgICAgIHg6IDQ4LFxuICAgICAgICAgICAgdGV4dDogeyB0ZXh0OiAnJywgZm9udFNpemU6IDI4LCB0ZXh0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uICAgICAgfVxuICAgIH1cblxuICAgIF9oYW5kbGVCYWNrKCkge1xuICAgICAgaWYgKHRoaXMubXNnKSB7XG4gICAgICAgIHRoaXMubXNnID0gZmFsc2VcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLnBpbi5sZW5ndGgpIHtcbiAgICAgICAgICB0aGlzLnBpbiA9IHRoaXMucGluLnNsaWNlKDAsIHRoaXMucGluLmxlbmd0aCAtIDEpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgUGluLmhpZGUoKVxuICAgICAgICAgIHRoaXMucmVzb2x2ZShmYWxzZSlcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cblxuICAgIF9oYW5kbGVFbnRlcigpIHtcbiAgICAgIGlmICh0aGlzLm1zZykge1xuICAgICAgICB0aGlzLm1zZyA9IGZhbHNlXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBQaW4uc3VibWl0KHRoaXMucGluKVxuICAgICAgICAgIC50aGVuKHZhbCA9PiB7XG4gICAgICAgICAgICB0aGlzLm1zZyA9ICdVbmxvY2tpbmcgLi4uJ1xuICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgICAgICAgIFBpbi5oaWRlKClcbiAgICAgICAgICAgIH0sIDEwMDApXG4gICAgICAgICAgICB0aGlzLnJlc29sdmUodmFsKVxuICAgICAgICAgIH0pXG4gICAgICAgICAgLmNhdGNoKGUgPT4ge1xuICAgICAgICAgICAgdGhpcy5tc2cgPSBlXG4gICAgICAgICAgICB0aGlzLnJlamVjdChlKVxuICAgICAgICAgIH0pXG4gICAgICB9XG4gICAgfVxuICB9XG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXMgYXBwbHk6XG4gKlxuICogQ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VuKHJlc29sdmUpXG4gICAgICAgICAgICAuY2F0Y2gocmVqZWN0KVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHJlamVjdCgnSW5jb3JyZWN0IENvbnRleHQgcHJvdmlkZWQnKVxuICAgICAgICB9XG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIHJlamVjdChlKVxuICAgICAgfVxuICAgIH0pXG4gIH0sXG4gIHVubG9ja2VkKGNvbnRleHQpIHtcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgdHJ5IHtcbiAgICAgICAgY29udGV4dCA9IGNvbnRleHRDaGVjayhjb250ZXh0KVxuICAgICAgICBpZiAoY29udGV4dCkge1xuICAgICAgICAgIGNoZWNrKGNvbnRleHQpXG4gICAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZWplY3QoJ0luY29ycmVjdCBDb250ZXh0IHByb3ZpZGVkJylcbiAgICAgICAgfVxuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICByZWplY3QoZSlcbiAgICAgIH1cbiAgICB9KVxuICB9LFxuICBsb2NrZWQoY29udGV4dCkge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgICB0cnkge1xuICAgICAgICBjb250ZXh0ID0gY29udGV4dENoZWNrKGNvbnRleHQpXG4gICAgICAgIGlmIChjb250ZXh0KSB7XG4gICAgICAgICAgY2hlY2soY29udGV4dClcbiAgICAgICAgICAgIC50aGVuKHVubG9ja2VkID0+IHJlc29sdmUoISEhdW5sb2NrZWQpKVxuICAgICAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZWplY3QoJ0luY29ycmVjdCBDb250ZXh0IHByb3ZpZGVkJylcbiAgICAg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VGV4dCkpKVxuICAgICAgLmNhdGNoKHJlamVjdClcbiAgfSlcbn1cblxuY29uc3QgY3NwUmVxdWVzdCA9ICh0eXBlLCBkYXRhID0gbnVsbCwgcGFyYW1zID0ge30pID0+IHtcbiAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICBjb25zdCBlbmRwb2ludCA9IGNzcEVuZHBvaW50c1t0eXBlXVxuXG4gICAgaWYgKCFlbmRwb2ludCkge1xuICAgICAgcmVqZWN0KCdObyBlbmRwb2ludCBmb3VuZCBmb3IgXCInICsgdHlwZSArICdcIiBjYWxsJylcbiAgICB9IGVsc2Uge1xuICAgICAgaWYgKGVuZHBvaW50LmNhbGxiYWNrICYmIHR5cGVvZiBlbmRwb2ludC5jYWxsYmFjayA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICBlbmRwb2ludFxuICAgICAgICAgIC5jYWxsYmFjayhkYXRhLCBwYXJhbXMpXG4gICAgICAgICAgLnRoZW4ocmVzb2x2ZSlcbiAgICAgICAgICAuY2F0Y2gocmVqZWN0KVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmVxdWVzdChcbiAgICAgICAgICBjcmVhdGVVcmwoZW5kcG9pbnQudXJpLCBjc3BVcmwsIHBhcmFtcyksXG4gICAgICAgICAgZW5kcG9pbnQubWV0aG9kLFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIC4uLihlbmRwb2ludC5kYXRhIHx8IHt9KSxcbiAgICAgICAgICAgIC4uLmRhdGEsXG4gICAgICAgICAgfSxcbiAgICAgICAgICBlbmRwb2ludC5oZWFkZXJzIHx8IHt9XG4gICAgICAgIClcbiAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICB9XG4gICAgfVxuICB9KVxufVxuXG5jb25zdCBiaWxsaW5nUmVxdWVzdCA9ICh1cmksIGRhdGEsIG1ldGhvZCA9ICdQT1NUJykgPT4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sZS5jb3VudHJ5Q29kZSgpLFxuICAgICAgICBQcm9maWxlLm9wZXJhdG9yKCksXG4gICAgICAgIFByb2ZpbGUubWFjKCksXG4gICAgICAgIFByb2ZpbGUudWlkKCksXG4gICAgICBdKVxuICAgICAgICAudGhlbigoW2hvdXNlaG9sZCwgY291bnRyeSwgb3BlcmF0b3IsIG1hYywgdWlkXSkgPT4ge1xuICAgICAgICAgIGJpbGxpbmdSZXF1ZXN0KCcvJywge1xuICAgICAgICAgICAgcHVyY2hhc2U6IHNpZ25hdHVyZSxcbiAgICAgICAgICAgIGlkZW50aWZpZXI6IFNldHRpbmdzLmdldCgnYXBwJywgJ2lkJyksXG4gICAgICAgICAgICBuYW1lOiBTZXR0aW5ncy5nZXQoJ2FwcCcsICdpZCcpLFxuICAgICAgICAgICAgaG91c2Vob2xkLFxuICAgICAgICAgICAgY291bnRyeSxcbiAgICAgICAgICAgIG9wZXJhdG9yLFxuICAgICAgICAgICAgbWFjLFxuICAgICAgICAgICAgdWlkLFxuICAgICAgICAgICAgdHlwZSxcbiAgICAgICAgICB9KVxuICAgICAgICAgICAgLnRoZW4ocmVzb2x2ZSlcbiAgICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICAgIH0pXG4gICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgfSlcbiAgfSxcbiAgY29uZmlybSh0cmFuc2FjdGlvbklkKSB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIGJpbGxpbmdSZXF1ZXN0KCcvY29uZmlybScsIHtcbiAgICAgICAgdHJhbnNhY3Rpb25JZCxcbiAgICAgIH0pXG4gICAgICAgIC50aGVuKHJlc29sdmUpXG4gICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgfSlcbiAgfSxcbiAgYnV5KGFzc2V0SWQsIHR5cGUpIHtcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1x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IH0sXG4gIHByb2dyYW0oKSB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIHRyeSB7XG4gICAgICAgIG1ldGhvZHNcbiAgICAgICAgICAuZ2V0UHJvZ3JhbSgpXG4gICAgICAgICAgLnRoZW4ocHJvZ3JhbSA9PiB7XG4gICAgICAgICAgICAvLyB0byBkbzogZW5zdXJlIGNvbnNpc3RlbnQgZm9ybWF0dGluZyBvZiBwcm9ncmFtIGluZm8gaGVyZT9cbiAgICAgICAgICAgIHJlc29sdmUocHJvZ3JhbSlcbiAgICAgICAgICB9KVxuICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIHJlamVjdChlKVxuICAgICAgfVxuICAgIH0pXG4gIH0sXG4gIGVudGl0bGVkKCkge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgICB0cnkge1xuICAgICAgICBtZXRob2RzXG4gICAgICAgICAgLmdldENoYW5uZWwoKVxuICAgICAgICAgIC50aGVuKGNoYW5uZWwgPT4ge1xuICAgICAgICAgICAgJ2VudGl0bGVkJyBpbiBjaGFubmVsID8gcmVzb2x2ZSghIWNoYW5uZWwuZW50aXRsZWQpIDogcmVqZWN0KClcbiAgICAgICAgICB9KVxuICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIHJlamVjdChlKVxuICAgICAgfVxuICAgIH0pXG4gIH0sXG4gIGFkZEV2ZW50TGlzdGVuZXIoZXZlbnQsIGNiKSB7XG4gICAgaWYgKHR5cGVvZiBjYiA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgY2FsbGJhY2tzW2V2ZW50XSA9IGNhbGxiYWNrc1tldmVudF0gfHwgW11cbiAgICAgIGNhbGxiYWNrc1tldmVudF0ucHVzaChjYilcbiAgICB9IGV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RGcmFtZUNvdW50XG4gICAgICAgICAgICAgICAgdGhpcy52aWRlb1ZpZXcudmlzaWJsZSA9IHRydWVcblxuICAgICAgICAgICAgICAgIHRoaXMudmlkZW9UZXh0dXJlLm9wdGlvbnMudyA9IHRoaXMudmlkZW9FbC53aWR0aFxuICAgICAgICAgICAgICAgIHRoaXMudmlkZW9UZXh0dXJlLm9wdGlvbnMuaCA9IHRoaXMudmlkZW9FbC5oZWlnaHRcbiAgICAgICAgICAgICAgICBjb25zdCBleHBlY3RlZEFzcGVjdFJhdGlvID0gdGhpcy52aWRlb1ZpZXcudyAvIHRoaXMudmlkZW9WaWV3LmhcbiAgICAgICAgICAgICAgICBjb25zdCByZWFsQXNwZWN0UmF0aW8gPSB0aGlzLnZpZGVvRWwud2lkdGggLyB0aGlzLnZpZGVvRWwuaGVpZ2h0XG5cbiAgICAgICAgICAgICAgICBpZiAoZXhwZWN0ZWRBc3BlY3RSYXRpbyA+IHJlYWxBc3BlY3RSYXRpbykge1xuICAgICAgICAgICAgICAgICAgdGhpcy52aWRlb1ZpZXcuc2NhbGVYID0gcmVhbEFzcGVjdFJhdGlvIC8gZXhwZWN0ZWRBc3BlY3RSYXRpb1xuICAgICAgICAgICAgICAgICAgdGhpcy52aWRlb1ZpZXcuc2NhbGVZID0gMVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICB0aGlzLnZpZGVvVmlldy5zY2FsZVkgPSBleHBlY3RlZEFzcGVjdFJhdGlvIC8gcmVhbEFzcGVjdFJhdGlvXG4gICAgICAgICAgICAgICAgICB0aGlzLnZpZGVvVmlldy5zY2FsZVggPSAxXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgTG9nLmVycm9yKCd0ZXhJbWFnZTJkIHZpZGVvJywgZSlcbiAgICAgICAgICAgICAgICB0aGlzLnN0b3AoKVxuICAgICAgICAgICAgICB9XG4gICAgICAgICA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7XG4gICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSAzOlxuICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdXG4gICAgICAgICAgdGhpcmRCeXRlID0gYnVmW2kgKyAyXVxuICAgICAgICAgIGlmICgoc2Vjb25kQnl0ZSAmIDB4QzApID09PSAweDgwICYmICh0aGlyZEJ5dGUgJiAweEMwKSA9PT0gMHg4MCkge1xuICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAweEYpIDw8IDB4QyB8IChzZWNvbmRCeXRlICYgMHgzRikgPDwgMHg2IHwgKHRoaXJkQnl0ZSAmIDB4M0YpXG4gICAgICAgICAgICBpZiAodGVtcENvZGVQb2ludCA+IDB4N0ZGICYmICh0ZW1wQ29kZVBvaW50IDwgMHhEODAwIHx8IHRlbXBDb2RlUG9pbnQgPiAweERGRkYpKSB7XG4gICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSA0OlxuICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdXG4gICAgICAgICAgdGhpcmRCeXRlID0gYnVmW2kgKyAyXVxuICAgICAgICAgIGZvdXJ0aEJ5dGUgPSBidWZbaSArIDNdXG4gICAgICAgICAgaWYgKChzZWNvbmRCeXRlICYgMHhDMCkgPT09IDB4ODAgJiYgKHRoaXJkQnl0ZSAmIDB4QzApID09PSAweDgwICYmIChmb3VydGhCeXRlICYgMHhDMCkgPT09IDB4ODApIHtcbiAgICAgICAgICAgIHRlbXBDb2RlUG9pbnQgPSAoZmlyc3RCeXRlICYgMHhGKSA8PCAweDEyIHwgKHNlY29uZEJ5dGUgJiAweDNGKSA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yA9IGZ1bmN0aW9uIGJpbmQodGhhdCkge1xuICAgIHZhciB0YXJnZXQgPSB0aGlzO1xuICAgIGlmICh0eXBlb2YgdGFyZ2V0ICE9PSAnZnVuY3Rpb24nIHx8IHRvU3RyLmFwcGx5KHRhcmdldCkgIT09IGZ1bmNUeXBlKSB7XG4gICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoRVJST1JfTUVTU0FHRSArIHRhcmdldCk7XG4gICAgfVxuICAgIHZhciBhcmdzID0gc2xpY3koYXJndW1lbnRzLCAxKTtcblxuICAgIHZhciBib3VuZDtcbiAgICB2YXIgYmluZGVyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAodGhpcyBpbnN0YW5jZW9mIGJvdW5kKSB7XG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gdGFyZ2V0LmFwcGx5KFxuICAgICAgICAgICAgICAgIHRoaXMsXG4gICAgICAgICAgICAgICAgY29uY2F0dHkoYXJncywgYXJndW1lbnRzKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGlmIChPYmplY3QocmVzdWx0KSA9PT0gcmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0YXJnZXQuYXBwbHkoXG4gICAgICAgICAgICB0aGF0LFxuICAgICAgICAgICAgY29uY2F0dHkoYXJncywgYXJndW1lbnRzKVxuICAgICAgICApO1xuXG4gICAgfTtcblxuICAgIHZhciBib3VuZExlbmd0aCA9IG1heCgwLCB0YXJnZXQubGVuZ3RoIC0gYXJncy5sZW5ndGgpO1xuICAgIHZhciBib3VuZEFyZ3MgPSBbXTtcbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGJvdW5kTGVuZ3RoOyBpKyspIHtcbiAgICAgICAgYm91bmRBcmdzW2ldID0gJyQnICsgaTtcbiAgICB9XG5cbiAgIC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sc2UsXG4gICAgICBjaDtcblxuICBpZiAoIW1heCkgcmV0dXJuIGZhbHNlO1xuXG4gIGNoID0gZGF0YVtpbmRleF07XG5cbiAgLy8gc2lnblxuICBpZiAoY2ggPT09ICctJyB8fCBjaCA9PT0gJysnKSB7XG4gICAgY2ggPSBkYXRhWysraW5kZXhdO1xuICB9XG5cbiAgaWYgKGNoID09PSAnMCcpIHtcbiAgICAvLyAwXG4gICAgaWYgKGluZGV4ICsgMSA9PT0gbWF4KSByZXR1cm4gdHJ1ZTtcbiAgICBjaCA9IGRhdGFbKytpbmRleF07XG5cbiAgICAvLyBiYXNlIDIsIGJhc2UgOCwgYmFzZSAxNlxuXG4gICAgaWYgKGNoID09PSAnYicpIHtcbiAgICAgIC8vIGJhc2UgMlxuICAgICAgaW5kZXgrKztcblxuICAgICAgZm9yICg7IGluZGV4IDwgbWF4OyBpbmRleCsrKSB7XG4gICAgICAgIGNoID0gZGF0YVtpbmRleF07XG4gICAgICAgIGlmIChjaCA9PT0gJ18nKSBjb250aW51ZTtcbiAgICAgICAgaWYgKGNoICE9PSAnMCcgJiYgY2ggIT09ICcxJykgcmV0dXJuIGZhbHNlO1xuICAgICAgICBoYXNEaWdpdHMgPSB0cnVlO1xuICAgICAgfVxuICAgICAgcmV0dXJuIGhhc0RpZ2l0cyAmJiBjaCAhPT0gJ18nO1xuICAgIH1cblxuXG4gICAgaWYgKGNoID09PSAneCcpIHtcbiAgICAgIC8vIGJhc2UgMTZcbiAgICAgIGluZGV4Kys7XG5cbiAgICAgIGZvciAoOyBpbmRleCA8IG1heDsgaW5kZXgrKykge1xuICAgICAgICBjaCA9IGRhdGFbaW5kZXhdO1xuICAgICAgICBpZiAoY2ggPT09ICdfJykgY29udGludWU7XG4gICAgICAgIGlmICghaXNIZXhDb2RlKGRhdGEuY2hhckNvZGVBdChpbmRleCkpKSByZXR1cm4gZmFsc2U7XG4gICAgICAgIGhhc0RpZ2l0cyA9IHRydWU7XG4gICAgICB9XG4gICAgICByZX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h7XG4gIGltcGxpY2l0OiBbXG4gICAgX251bGwsXG4gICAgYm9vbCxcbiAgICBpbnQsXG4gICAgZmxvYXRcbiAgXVxufSk7XG5cbnZhciBjb3JlID0ganNvbjtcblxudmFyIFlBTUxfREFURV9SRUdFWFAgPSBuZXcgUmVnRXhwKFxuICAnXihbMC05XVswLTldWzAtOV1bMC05XSknICAgICAgICAgICsgLy8gWzFdIHllYXJcbiAgJy0oWzAtOV1bMC05XSknICAgICAgICAgICAgICAgICAgICArIC8vIFsyXSBtb250aFxuICAnLShbMC05XVswLTldKSQnKTsgICAgICAgICAgICAgICAgICAgLy8gWzNdIGRheVxuXG52YXIgWUFNTF9USU1FU1RBTVBfUkVHRVhQID0gbmV3IFJlZ0V4cChcbiAgJ14oWzAtOV1bMC05XVswLTldWzAtOV0pJyAgICAgICAgICArIC8vIFsxXSB5ZWFyXG4gICctKFswLTldWzAtOV0/KScgICAgICAgICAgICAgICAgICAgKyAvLyBbMl0gbW9udGhcbiAgJy0oWzAtOV1bMC05XT8pJyAgICAgICAgICAgICAgICAgICArIC8vIFszXSBkYXlcbiAgJyg/OltUdF18WyBcXFxcdF0rKScgICAgICAgICAgICAgICAgICsgLy8gLi4uXG4gICcoWzAtOV1bMC05XT8pJyAgICAgICAgICAgICAgICAgICAgKyAvLyBbNF0gaG91clxuICAnOihbMC05XVswLTldKScgICAgICAgICAgICAgICAgICAgICsgLy8gWzVdIG1pbnV0ZVxuICAnOihbMC05XVswLTldKScgICAgICAgICAgICAgICAgICAgICsgLy8gWzZdIHNlY29uZFxuICAnKD86XFxcXC4oWzAtOV0qKSk/JyAgICAgICAgICAgICAgICAgKyAvLyBbN10gZnJhY3Rpb25cbiAgJyg/OlsgXFxcXHRdKihafChbLStdKShbMC05XVswLTldPyknICsgLy8gWzhdIHR6IFs5XSB0el9zaWduIFsxMF0gdHpfaG91clxuICAnKD86OihbMC05XVswLTldKSk/KSk/JCcpOyAgICAgICAgICAgLy8gWzExXSB0el9taW51dGVcblxu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lbnQgKi9cbiAgcmV0dXJuIChjID09PSAweDMwLyogMCAqLykgPyAnXFx4MDAnIDpcbiAgICAgICAgKGMgPT09IDB4NjEvKiBhICovKSA/ICdcXHgwNycgOlxuICAgICAgICAoYyA9PT0gMHg2Mi8qIGIgKi8pID8gJ1xceDA4JyA6XG4gICAgICAgIChjID09PSAweDc0LyogdCAqLykgPyAnXFx4MDknIDpcbiAgICAgICAgKGMgPT09IDB4MDkvKiBUYWIgKi8pID8gJ1xceDA5JyA6XG4gICAgICAgIChjID09PSAweDZFLyogbiAqLykgPyAnXFx4MEEnIDpcbiAgICAgICAgKGMgPT09IDB4NzYvKiB2ICovKSA/ICdcXHgwQicgOlxuICAgICAgICAoYyA9PT0gMHg2Ni8qIGYgKi8pID8gJ1xceDBDJyA6XG4gICAgICAgIChjID09PSAweDcyLyogciAqLykgPyAnXFx4MEQnIDpcbiAgICAgICAgKGMgPT09IDB4NjUvKiBlICovKSA/ICdcXHgxQicgOlxuICAgICAgICAoYyA9PT0gMHgyMC8qIFNwYWNlICovKSA/ICcgJyA6XG4gICAgICAgIChjID09PSAweDIyLyogXCIgKi8pID8gJ1xceDIyJyA6XG4gICAgICAgIChjID09PSAweDJGLyogLyAqLykgPyAnLycgOlxuICAgICAgICAoYyA9PT0gMHg1Qy8qIFxcICovKSA/ICdcXHg1QycgOlxuICAgICAgICAoYyA9PT0gMHg0RS8qIE4gKi8pID8gJ1xceDg1JyA6XG4gICAgICAgIChjID09PSAweDVGLyogXyAqLykgPyAnXFx4QTAnIDpcbiAgICAgICAgKGMgPT09IDB4NEMvKiBMICovKSA/ICdcXHUyMDI4JyA6XG4gICAgICAgIChjID09PSAweDUwLyogUCAqLykgPyAnXFx1MjAyOScgOiAnJztcbn1cblxuZnVuY3Rpb24gY2hhckZyb21Db2RlcG9pbnQoYykge1xuICBpZiAoYyA8PSAweEZGRkYpIHtcbiAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZShjKTtcbiAgfVxuICAvLyBF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JlYW0sIGJ1dCBmb3VuZCBtb3JlJyk7XG59XG5cblxudmFyIGxvYWRBbGxfMSA9IGxvYWRBbGwkMTtcbnZhciBsb2FkXzEgICAgPSBsb2FkJDE7XG5cbnZhciBsb2FkZXIgPSB7XG5cdGxvYWRBbGw6IGxvYWRBbGxfMSxcblx0bG9hZDogbG9hZF8xXG59O1xuXG4vKmVzbGludC1kaXNhYmxlIG5vLXVzZS1iZWZvcmUtZGVmaW5lKi9cblxuXG5cblxuXG52YXIgX3RvU3RyaW5nICAgICAgID0gT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZztcbnZhciBfaGFzT3duUHJvcGVydHkgPSBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5O1xuXG52YXIgQ0hBUl9CT00gICAgICAgICAgICAgICAgICA9IDB4RkVGRjtcbnZhciBDSEFSX1RBQiAgICAgICAgICAgICAgICAgID0gMHgwOTsgLyogVGFiICovXG52YXIgQ0hBUl9MSU5FX0ZFRUQgICAgICAgICAgICA9IDB4MEE7IC8qIExGICovXG52YXIgQ0hBUl9DQVJSSUFHRV9SRVRVUk4gICAgICA9IDB4MEQ7IC8qIENSICovXG52YXIgQ0hBUl9TUEFDRSAgICAgICAgICAgICAgICA9IDB4MjA7IC8qIFNwYWNlICovXG52YXIgQ0hBUl9FWENMQU1BVElPTiAgICAgICAgICA9IDB4MjE7IC8qICEgKi9cbnZhciBDSEFSX0RPVUJMRV9RVU9URSAgICAgICAgID0gMHgyMjsgLyogXCIgKi9cbnZhciBDSEFSX1NIQVJQICAgICAgICAgICAgICAgID0gMHgyMzsgLyogIyAqL1xudmFyIENIQVJfUEVSQ0VOVCAgICAgICAgICAgICAgPSAweDI1OyAvKiAlICovXG52YXIgQ0hBUl9BTVBFUlNBTkQgICAgICAgICAgICA9IDB4MjY7IC8qICYgKi9cbnZhciBDSEFSX1NJTkdMRV9RVU9URSAgICAgICAgID0gMHgyNzsgLyogJyAqL1xudmFyIENIQVJfQVNURVJJU0sgICAgIC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ZW5ndGhgIGluIHN0cmljdCBtb2RlLlxuICAgICAgICAgICAgICAga2V5ID09ICdsZW5ndGgnIHx8XG4gICAgICAgICAgICAgICAvLyBOb2RlLmpzIDAuMTAgaGFzIGVudW1lcmFibGUgbm9uLWluZGV4IHByb3BlcnRpZXMgb24gYnVmZmVycy5cbiAgICAgICAgICAgICAgIChpc0J1ZmYgJiYgKGtleSA9PSAnb2Zmc2V0JyB8fCBrZXkgPT0gJ3BhcmVudCcpKSB8fFxuICAgICAgICAgICAgICAgLy8gUGhhbnRvbUpTIDIgaGFzIGVudW1lcmFibGUgbm9uLWluZGV4IHByb3BlcnRpZXMgb24gdHlwZWQgYXJyYXlzLlxuICAgICAgICAgICAgICAgKGlzVHlwZSAmJiAoa2V5ID09ICdidWZmZXInIHx8IGtleSA9PSAnYnl0ZUxlbmd0aCcgfHwga2V5ID09ICdieXRlT2Zmc2V0JykpIHx8XG4gICAgICAgICAgICAgICAvLyBTa2lwIGluZGV4IHByb3BlcnRpZXMuXG4gICAgICAgICAgICAgICBpc0luZGV4KGtleSwgbGVuZ3RoKVxuICAgICAgICAgICAgKSkpIHtcbiAgICAgICAgICByZXN1bHQucHVzaChrZXkpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEEgc3BlY2lhbGl6ZWQgdmVyc2lvbiBvZiBgXy5zYW1wbGVgIGZvciBhcnJheXMuXG4gICAgICpcbiAgICAgKiBAcHJpdmF0ZVxuICAgICAqIEBwYXJhbSB7QXJyYXl9IGFycmF5IFRoZSBhcnJheSB0byBzYW1wbGUuXG4gICAgICogQHJldHVybnMgeyp9IFJldHVybnMgdGhlIHJhbmRvbSBlbGVtZW50LlxuICAgICAqL1xuICAgIGZ1bmN0aW9uIGFycmF5U2FtcGxlKGFycmF5KSB7XG4gICAgICB2YXIgbGVuZ3RoID0gYXJyYXkubGVuZ3RoO1xuICAgICAgcmV0dXJuIGxlb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9yKVxuICAgICAgICAgICAgKSkge1xuICAgICAgICAgIG90aEluZGV4ID0gb3RoTGVuZ3RoO1xuICAgICAgICAgIHdoaWxlICgtLW90aEluZGV4KSB7XG4gICAgICAgICAgICB2YXIgY2FjaGUgPSBjYWNoZXNbb3RoSW5kZXhdO1xuICAgICAgICAgICAgaWYgKCEoY2FjaGVcbiAgICAgICAgICAgICAgICAgID8gY2FjaGVIYXMoY2FjaGUsIGNvbXB1dGVkKVxuICAgICAgICAgICAgICAgICAgOiBpbmNsdWRlcyhhcnJheXNbb3RoSW5kZXhdLCBjb21wdXRlZCwgY29tcGFyYXRvcikpXG4gICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgIGNvbnRpbnVlIG91dGVyO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoc2Vlbikge1xuICAgICAgICAgICAgc2Vlbi5wdXNoKGNvbXB1dGVkKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmVzdWx0LnB1c2godmFsdWUpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoZSBiYXNlIGltcGxlbWVudGF0aW9uIG9mIGBfLmludmVydGAgYW5kIGBfLmludmVydEJ5YCB3aGljaCBpbnZlcnRzXG4gICAgICogYG9iamVjdGAgd2l0aCB2YWx1ZXMgdHJhbnNmb3JtZWQgYnkgYGl0ZXJhdGVlYCBhbmQgc2V0IGJ5IGBzZXR0ZXJgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gb2JqZWN0IFRoZSBvYmplY3QgdG8gaXRlcmF0ZSBvdmVyLlxuICAgICAqIEBwYXJhbSB7RnVuY3Rpb259IHNldHRlciBUaGUgZnVuY3Rpb24gdG8gc2V0IGBhY2N1bXVsYXRvcmAgdmFsdWVzLlxuICAgICAqIEBwYXJhbSB7RnVuY3Rpb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hY2spO1xuICAgICAgfVxuICAgICAgaWYgKCEoYml0bWFzayAmIENPTVBBUkVfUEFSVElBTF9GTEFHKSkge1xuICAgICAgICB2YXIgb2JqSXNXcmFwcGVkID0gb2JqSXNPYmogJiYgaGFzT3duUHJvcGVydHkuY2FsbChvYmplY3QsICdfX3dyYXBwZWRfXycpLFxuICAgICAgICAgICAgb3RoSXNXcmFwcGVkID0gb3RoSXNPYmogJiYgaGFzT3duUHJvcGVydHkuY2FsbChvdGhlciwgJ19fd3JhcHBlZF9fJyk7XG5cbiAgICAgICAgaWYgKG9iaklzV3JhcHBlZCB8fCBvdGhJc1dyYXBwZWQpIHtcbiAgICAgICAgICB2YXIgb2JqVW53cmFwcGVkID0gb2JqSXNXcmFwcGVkID8gb2JqZWN0LnZhbHVlKCkgOiBvYmplY3QsXG4gICAgICAgICAgICAgIG90aFVud3JhcHBlZCA9IG90aElzV3JhcHBlZCA/IG90aGVyLnZhbHVlKCkgOiBvdGhlcjtcblxuICAgICAgICAgIHN0YWNrIHx8IChzdGFjayA9IG5ldyBTdGFjayk7XG4gICAgICAgICAgcmV0dXJuIGVxdWFsRnVuYyhvYmpVbndyYXBwZWQsIG90aFVud3JhcHBlZCwgYml0bWFzaywgY3VzdG9taXplciwgc3RhY2spO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAoIWlzU2FtZVRhZykge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICBzdGFjayB8fCAoc3RhY2sgPSBuZXcgU3RhY2spO1xuICAgICAgcmV0dXJuIGVxdWFsT2JqZWN0cyhvYmplY3QsIG90aGVyLCBiaXRtYXNrLCBjdXN0b21pemVyLCBlcXVhbEZ1bmMsIHN0YWNrKTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBUaGUgYmFzZSBpbXBsZW1lbnRhdGlvbiBvZiBgXy5pc01hcGAgd2l0aG91dCBOb2RlLmpzIG9wdGltaXphdGlvbnMuXG4gICAgICpcbiAgICA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1c3RvbWl6ZXIpIHtcbiAgICAgIHZhciBpbmRleCA9IG1hdGNoRGF0YS5sZW5ndGgsXG4gICAgICAgICAgbGVuZ3RoID0gaW5kZXgsXG4gICAgICAgICAgbm9DdXN0b21pemVyID0gIWN1c3RvbWl6ZXI7XG5cbiAgICAgIGlmIChvYmplY3QgPT0gbnVsbCkge1xuICAgICAgICByZXR1cm4gIWxlbmd0aDtcbiAgICAgIH1cbiAgICAgIG9iamVjdCA9IE9iamVjdChvYmplY3QpO1xuICAgICAgd2hpbGUgKGluZGV4LS0pIHtcbiAgICAgICAgdmFyIGRhdGEgPSBtYXRjaERhdGFbaW5kZXhdO1xuICAgICAgICBpZiAoKG5vQ3VzdG9taXplciAmJiBkYXRhWzJdKVxuICAgICAgICAgICAgICA/IGRhdGFbMV0gIT09IG9iamVjdFtkYXRhWzBdXVxuICAgICAgICAgICAgICA6ICEoZGF0YVswXSBpbiBvYmplY3QpXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgIGRhdGEgPSBtYXRjaERhdGFbaW5kZXhdO1xuICAgICAgICB2YXIga2V5ID0gZGF0YVswXSxcbiAgICAgICAgICAgIG9ialZhbHVlID0gb2JqZWN0W2tleV0sXG4gICAgICAgICAgICBzcmNWYWx1ZSA9IGRhdGFbMV07XG5cbiAgICAgICAgaWYgKG5vQ3VzdG9taXplciAmJiBkYXRhWzJdKSB7XG4gICAgICAgICAgaWYgKG9ialZhbHVlID09PSB1bmRlZmluZWQgJiYgIShrZXkgaW4gb2JqZWN0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB2YXIgc3RhY2sgPSBuZXcgU3RhY2s7XG4gICAgICAgICAgaWYgKGN1c3RvbWl6ZXIpIHt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WQgPSB2YWx1ZSAhPT0gdW5kZWZpbmVkLFxuICAgICAgICAgICAgdmFsSXNOdWxsID0gdmFsdWUgPT09IG51bGwsXG4gICAgICAgICAgICB2YWxJc1JlZmxleGl2ZSA9IHZhbHVlID09PSB2YWx1ZSxcbiAgICAgICAgICAgIHZhbElzU3ltYm9sID0gaXNTeW1ib2wodmFsdWUpO1xuXG4gICAgICAgIHZhciBvdGhJc0RlZmluZWQgPSBvdGhlciAhPT0gdW5kZWZpbmVkLFxuICAgICAgICAgICAgb3RoSXNOdWxsID0gb3RoZXIgPT09IG51bGwsXG4gICAgICAgICAgICBvdGhJc1JlZmxleGl2ZSA9IG90aGVyID09PSBvdGhlcixcbiAgICAgICAgICAgIG90aElzU3ltYm9sID0gaXNTeW1ib2wob3RoZXIpO1xuXG4gICAgICAgIGlmICgoIW90aElzTnVsbCAmJiAhb3RoSXNTeW1ib2wgJiYgIXZhbElzU3ltYm9sICYmIHZhbHVlID4gb3RoZXIpIHx8XG4gICAgICAgICAgICAodmFsSXNTeW1ib2wgJiYgb3RoSXNEZWZpbmVkICYmIG90aElzUmVmbGV4aXZlICYmICFvdGhJc051bGwgJiYgIW90aElzU3ltYm9sKSB8fFxuICAgICAgICAgICAgKHZhbElzTnVsbCAmJiBvdGhJc0RlZmluZWQgJiYgb3RoSXNSZWZsZXhpdmUpIHx8XG4gICAgICAgICAgICAoIXZhbElzRGVmaW5lZCAmJiBvdGhJc1JlZmxleGl2ZSkgfHxcbiAgICAgICAgICAgICF2YWxJc1JlZmxleGl2ZSkge1xuICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICB9XG4gICAgICAgIGlmICgoIXZhbElzTnVsbCAmJiAhdmFsSXNTeW1ib2wgJiYgIW90aElzU3ltYm9sICYmIHZhbHVlIDwgb3RoZXIpIHx8XG4gICAgICAgICAgICAob3RoSXNTeW1ib2wgJiYgdmFsSXNEZWZpbmVkICYmIHZhbElzUmVmbGV4aXZlICYmICF2YWxJc051bGwgJiYgIXZhb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YC5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBjb3B5QXJyYXkoc291cmNlLCBhcnJheSkge1xuICAgICAgdmFyIGluZGV4ID0gLTEsXG4gICAgICAgICAgbGVuZ3RoID0gc291cmNlLmxlbmd0aDtcblxuICAgICAgYXJyYXkgfHwgKGFycmF5ID0gQXJyYXkobGVuZ3RoKSk7XG4gICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICBhcnJheVtpbmRleF0gPSBzb3VyY2VbaW5kZXhdO1xuICAgICAgfVxuICAgICAgcmV0dXJuIGFycmF5O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENvcGllcyBwcm9wZXJ0aWVzIG9mIGBzb3VyY2VgIHRvIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIFRoZSBvYmplY3QgdG8gY29weSBwcm9wZXJ0aWVzIGZyb20uXG4gICAgICogQHBhcmFtIHtBcnJheX0gcHJvcHMgVGhlIHByb3BlcnR5IGlkZW50aWZpZXJzIHRvIGNvcHkuXG4gICAgICogQHBhcmFtIHtPYmplY3R9IFtvYmplY3Q9e31dIFRoZSBvYmplY3QgdG8gY29weSBwcm9wZXJ0aWVzIHRvLlxuICAgICAqIEBwYXJhbSB7RnVuY3Rpb259IFtjdXN0b21pemVyXSBUaGUgZnVuY3Rpb24gdG8gY3VzdG9taXplIGNvcGllZCB2YWx1ZXMuXG4gICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyBgb2JqZWN0YC5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBjb3B5T2JqZWN0KHNvdXJjZSwgcHJvcHMsIG9iamVjdCwgY3VzdG9taXplcikge1xuICAgICAgdmFyIGlzTmV3ID0gIW9iamVjdDtcbiAgICAgIG9iamVjdCB8fCAob2JqZWN0ID0ge30pO1xuXG4gICAgICB2YXIgaW5kZXggPSAtMSxcbiAgICAgICAgICBsZW5ndGggPSBwcm9wcy5sZW5ndGg7XG5cbiAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgIHZhciBrZXkgPSBwcm9wc1tpbmRleF07XG5cbiAgICAgICAgdmFyIG5ld1ZhbHVlID0gY3VzdG9taXplclxuICAgICAgICAgID8gY3VzdG9taXplcihvYmplY3Rba2V5XSwgc291cmNlW2tleV0sIGtleSwgb2JqZWN0LCBzb3VyY2UpXG4gICAgICAgICAgOiB1bmRlZmluZWQ7XG5cbiAgICAgICAgaWYgKG5ld1ZhbHVlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICBuZXdWYWx1ZSA9IHNvdXJjZVtrZXldO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpc05ldykge1xuICAgICAgICAgIGJhc2VBc3NpZ25WYWx1ZShvYmplY3QsIGtleSwgbmV3VmFsdWUpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGFzc2lnblZhbHVlKG9iamVjdCwga2V5LCBuZXdWYWx1ZSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBvYmplY3Q7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ29waWVzIG93biBzeW1ib2xzIG9mIGBzb3VyY2VgIHRvIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIGZyb20uXG4gICAgICogQHBhcmFtIHtPYmplY3R9IFtvYmplY3Q9e31dIFRoZSBvYmplY3QgdG8gY29weSBzeW1ib2xzIHRvLlxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgYG9iamVjdGAuXG4gICAgICovXG4gICAgZnVuY3Rpb24gY29weVN5bWJvbHMoc291cmNlLCBvYmplY3QpIHtcbiAgICAgIHJldHVybiBjb3B5T2JqZWN0KHNvdXJjZSwgZ2V0U3ltYm9sc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mYWxzZTtcbiAgICAgIH1cbiAgICAgIC8vIENoZWNrIHRoYXQgY3ljbGljIHZhbHVlcyBhcmUgZXF1YWwuXG4gICAgICB2YXIgYXJyU3RhY2tlZCA9IHN0YWNrLmdldChhcnJheSk7XG4gICAgICB2YXIgb3RoU3RhY2tlZCA9IHN0YWNrLmdldChvdGhlcik7XG4gICAgICBpZiAoYXJyU3RhY2tlZCAmJiBvdGhTdGFja2VkKSB7XG4gICAgICAgIHJldHVybiBhcnJTdGFja2VkID09IG90aGVyICYmIG90aFN0YWNrZWQgPT0gYXJyYXk7XG4gICAgICB9XG4gICAgICB2YXIgaW5kZXggPSAtMSxcbiAgICAgICAgICByZXN1bHQgPSB0cnVlLFxuICAgICAgICAgIHNlZW4gPSAoYml0bWFzayAmIENPTVBBUkVfVU5PUkRFUkVEX0ZMQUcpID8gbmV3IFNldENhY2hlIDogdW5kZWZpbmVkO1xuXG4gICAgICBzdGFjay5zZXQoYXJyYXksIG90aGVyKTtcbiAgICAgIHN0YWNrLnNldChvdGhlciwgYXJyYXkpO1xuXG4gICAgICAvLyBJZ25vcmUgbm9uLWluZGV4IHByb3BlcnRpZXMuXG4gICAgICB3aGlsZSAoKytpbmRleCA8IGFyckxlbmd0aCkge1xuICAgICAgICB2YXIgYXJyVmFsdWUgPSBhcnJheVtpbmRleF0sXG4gICAgICAgICAgICBvdGhWYWx1ZSA9IG90aGVyW2luZGV4XTtcblxuICAgICAgICBpZiAoY3VzdG9taXplcikge1xuICAgICAgICAgIHZhciBjb21wYXJlZCA9IGlzUGFydGlhbFxuICAgICAgICAgICAgPyBjdXN0b21pemVyKG90aFZhbHVlLCBhcnJWYWx1ZSwgaW5kZXgsIG90aGVyLCBhcnJheSwgc3RhY2spXG4gICAgICAgICAgICA6IGN1c3RvbWl6ZXIoYXJyVmFsdWUsIG90aFZhbHVlLCBpbmRleCwgYXJyYXksIG90aGVyLCBzdGFjayk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGNvbXBhcmVkICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICBpZiAoY29tcGFyZWQpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvLyBSZWN1cnNpdmVseSBjb21wYXJlIGFycmF5cyAoc3VzY2VwdGlibGUgdG8gY2FsbCBzdGFjayBsaW1pdHMpLlxuICAgICAgICBpZiAoc2Vlbikge1xuICAgICAgICAgIGlmICghYXJyYXlTb21lKG90aGVyLCBmdW5jdGlvbihvdGhWYWx1ZSwgb3RoSW5kZXgpIHtcbiAgICAgICAgICAgICAgICBpZiAoIWNhY2hlSGFzKHNlZW4sIG90aEluZGV4KSAmJlxuICAgICAgICAgICAgICAgICAgICAoYXJyVmFsdWUgPT09IG90aFZhbHVlIHx8IGVxdWFsRnVuYyhhcnJWYWx1ZSwgb3RoVmFsdWUsIGJpdG1hc2ssIGN1c3RvbWl6ZXIsIHN0YWNrKSkpIHtcbiAgICAgICAgICAgICAgICAgIHJldHVybiBzZWVuLnB1c2gob3RoSW5kZXgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSkpIHtcbiAgICAgICAgICAgIHJlc3VsdCA9IGZhbHNlO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKCEoXG4gICAgICAgICAgICAgIGFyclZhbHVlID09PSBvdGhWYWx1ZSB8fFxuICAgICAgICAgICAgICAgIGVxdWFsRnVuYyhhcnJWYWx1ZSwgb3RoVmFsdWUsIGJpdG1hc2ssIGN1c3RvbWl6ZXIsIHN0YWNrKVxuICAgICAgICAgICAgKSkge1xuICAgICAgICAgIHJlc3VsdCA9IGZhbHNlO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBzdGFja1snZGVsZXRlJ10oYXJyYXk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AgICAgIC8vIENvZXJjZSBib29sZWFucyB0byBgMWAgb3IgYDBgIGFuZCBkYXRlcyB0byBtaWxsaXNlY29uZHMuXG4gICAgICAgICAgLy8gSW52YWxpZCBkYXRlcyBhcmUgY29lcmNlZCB0byBgTmFOYC5cbiAgICAgICAgICByZXR1cm4gZXEoK29iamVjdCwgK290aGVyKTtcblxuICAgICAgICBjYXNlIGVycm9yVGFnOlxuICAgICAgICAgIHJldHVybiBvYmplY3QubmFtZSA9PSBvdGhlci5uYW1lICYmIG9iamVjdC5tZXNzYWdlID09IG90aGVyLm1lc3NhZ2U7XG5cbiAgICAgICAgY2FzZSByZWdleHBUYWc6XG4gICAgICAgIGNhc2Ugc3RyaW5nVGFnOlxuICAgICAgICAgIC8vIENvZXJjZSByZWdleGVzIHRvIHN0cmluZ3MgYW5kIHRyZWF0IHN0cmluZ3MsIHByaW1pdGl2ZXMgYW5kIG9iamVjdHMsXG4gICAgICAgICAgLy8gYXMgZXF1YWwuIFNlZSBodHRwOi8vd3d3LmVjbWEtaW50ZXJuYXRpb25hbC5vcmcvZWNtYS0yNjIvNy4wLyNzZWMtcmVnZXhwLnByb3RvdHlwZS50b3N0cmluZ1xuICAgICAgICAgIC8vIGZvciBtb3JlIGRldGFpbHMuXG4gICAgICAgICAgcmV0dXJuIG9iamVjdCA9PSAob3RoZXIgKyAnJyk7XG5cbiAgICAgICAgY2FzZSBtYXBUYWc6XG4gICAgICAgICAgdmFyIGNvbnZlcnQgPSBtYXBUb0FycmF5O1xuXG4gICAgICAgIGNhc2Ugc2V0VGFnOlxuICAgICAgICAgIHZhciBpc1BhcnRpYWwgPSBiaXRtYXNrICYgQ09NUEFSRV9QQVJUSUFMX0ZMQUc7XG4gICAgICAgICAgY29udmVydCB8fCAoY29udmVydCA9IHNldFRvQXJyYXkpO1xuXG4gICAgICAgICAgaWYgKG9iamVjdC5zaXplICE9IG90aGVyLnNpemUgJiYgIWlzUGFydGlhbCkge1xuICAgICAgICAgICAgcmV0dXJuI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ICogQ29udmVydHMgYGZ1bmNgIHRvIGl0cyBzb3VyY2UgY29kZS5cbiAgICAgKlxuICAgICAqIEBwcml2YXRlXG4gICAgICogQHBhcmFtIHtGdW5jdGlvbn0gZnVuYyBUaGUgZnVuY3Rpb24gdG8gY29udmVydC5cbiAgICAgKiBAcmV0dXJucyB7c3RyaW5nfSBSZXR1cm5zIHRoZSBzb3VyY2UgY29kZS5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiB0b1NvdXJjZShmdW5jKSB7XG4gICAgICBpZiAoZnVuYyAhPSBudWxsKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgcmV0dXJuIGZ1bmNUb1N0cmluZy5jYWxsKGZ1bmMpO1xuICAgICAgICB9IGNhdGNoIChlKSB7fVxuICAgICAgICB0cnkge1xuICAgICAgICAgIHJldHVybiAoZnVuYyArICcnKTtcbiAgICAgICAgfSBjYXRjaCAoZSkge31cbiAgICAgIH1cbiAgICAgIHJldHVybiAnJztcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBVcGRhdGVzIHdyYXBwZXIgYGRldGFpbHNgIGJhc2VkIG9uIGBiaXRtYXNrYCBmbGFncy5cbiAgICAgKlxuICAgICAqIEBwcml2YXRlXG4gICAgICogQHJldHVybnMge0FycmF5fSBkZXRhaWxzIFRoZSBkZXRhaWxzIHRvIG1vZGlmeS5cbiAgICAgKiBAcGFyYW0ge251bWJlcn0gYml0bWFzayBUaGUgYml0bWFzayBmbGFncy4gU2VlIGBjcmVhdGVXcmFwYCBmb3IgbW9yZSBkZXRhaWxzLlxuICAgICAqIEByZXR1cm5zIHtBcnJheX0gUmV0dXJucyBgZGV0YWlsc2AuXG4gICAgICovXG4gICAgZnVuY3Rpb24gdXBkYXRlV3JhcERldGFpbHMoZGV0YWlscywgYml0bWFzaykge1xuICAgICAgYXJyYXlFYWNoKHdyYXBGbGFncywgZnVuY3Rpb24ocGFpcikge1xuICAgICAgICB2YXIgdmFsdWUgPSAnXy4nICsgcGFpclsw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ICAgICAqXG4gICAgICogdmFyIGFycmF5ID0gWydhJywgJ2InLCAnYycsICdkJ107XG4gICAgICogdmFyIHB1bGxlZCA9IF8ucHVsbEF0KGFycmF5LCBbMSwgM10pO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsnYScsICdjJ11cbiAgICAgKlxuICAgICAqIGNvbnNvbGUubG9nKHB1bGxlZCk7XG4gICAgICogLy8gPT4gWydiJywgJ2QnXVxuICAgICAqL1xuICAgIHZhciBwdWxsQXQgPSBmbGF0UmVzdChmdW5jdGlvbihhcnJheSwgaW5kZXhlcykge1xuICAgICAgdmFyIGxlbmd0aCA9IGFycmF5ID09IG51bGwgPyAwIDogYXJyYXkubGVuZ3RoLFxuICAgICAgICAgIHJlc3VsdCA9IGJhc2VBdChhcnJheSwgaW5kZXhlcyk7XG5cbiAgICAgIGJhc2VQdWxsQXQoYXJyYXksIGFycmF5TWFwKGluZGV4ZXMsIGZ1bmN0aW9uKGluZGV4KSB7XG4gICAgICAgIHJldHVybiBpc0luZGV4KGluZGV4LCBsZW5ndGgpID8gK2luZGV4IDogaW5kZXg7XG4gICAgICB9KS5zb3J0KGNvbXBhcmVBc2NlbmRpbmcpKTtcblxuICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9KTtcblxuICAgIC8qKlxuICAgICAqIFJlbW92ZXMgYWxsIGVsZW1lbnRzIGZyb20gYGFycmF5YCB0aGF0IGBwcmVkaWNhdGVgIHJldHVybnMgdHJ1dGh5IGZvclxuICAgICAqIGFuZCByZXR1cm5zIGFuIGFycmF5IG9mIHRoZSByZW1vdmVkIGVsZW1lbnRzLiBUaGUgcHJlZGljYXRlIGlzIGludm9rZWRcbiAgICAgKiB3aXRoIHRocmVlIGFyZ3VtZW50czogKHZhbHVlLCBpbmRleCwgYXJyYXkpLlxuICAgICAqXG4gICAgICogKipOb3RlOioqIFVubGlrZSBgXy5maWx0ZXJgLCB0aGlzIG1ldGhvZCBt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ZSA9IG5ldyBFdmVudFNvdXJjZSgnL3N0cmVhbScpO1xuICAgICAqIGpRdWVyeShzb3VyY2UpLm9uKCdtZXNzYWdlJywgZGVib3VuY2VkKTtcbiAgICAgKlxuICAgICAqIC8vIENhbmNlbCB0aGUgdHJhaWxpbmcgZGVib3VuY2VkIGludm9jYXRpb24uXG4gICAgICogalF1ZXJ5KHdpbmRvdykub24oJ3BvcHN0YXRlJywgZGVib3VuY2VkLmNhbmNlbCk7XG4gICAgICovXG4gICAgZnVuY3Rpb24gZGVib3VuY2UoZnVuYywgd2FpdCwgb3B0aW9ucykge1xuICAgICAgdmFyIGxhc3RBcmdzLFxuICAgICAgICAgIGxhc3RUaGlzLFxuICAgICAgICAgIG1heFdhaXQsXG4gICAgICAgICAgcmVzdWx0LFxuICAgICAgICAgIHRpbWVySWQsXG4gICAgICAgICAgbGFzdENhbGxUaW1lLFxuICAgICAgICAgIGxhc3RJbnZva2VUaW1lID0gMCxcbiAgICAgICAgICBsZWFkaW5nID0gZmFsc2UsXG4gICAgICAgICAgbWF4aW5nID0gZmFsc2UsXG4gICAgICAgICAgdHJhaWxpbmcgPSB0cnVlO1xuXG4gICAgICBpZiAodHlwZW9mIGZ1bmMgIT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKEZVTkNfRVJST1JfVEVYVCk7XG4gICAgICB9XG4gICAgICB3YWl0ID0gdG9OdW1iZXIod2FpdCkgfHwgMDtcbiAgICAgIGlmIChpc09iamVjdChvcHRpb25zKSkge1xuICAgICAgICBsZWFkaW5nID0gISFvcHRpb25zLmxlYWRpbmc7XG4gICAgICAgIG1heGluZyA9ICdtYXhXYWl0JyBpbiBvcHRpb25zO1xuICAgICAgICBtYXhXYWl0ID0gbWF4aW5nID8gbmF0aXZlTWF4KHRvTnVtYmVyKG9wdGlvbnMubWF4V2FpdCkgfHwgMCwgd2FpdCkgOiBtYXhXYWl0O1xuICAgICAgICB0cmFpbGluZyA9ICd0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W52b2tpbmcgPSBzaG91bGRJbnZva2UodGltZSk7XG5cbiAgICAgICAgbGFzdEFyZ3MgPSBhcmd1bWVudHM7XG4gICAgICAgIGxhc3RUaGlzID0gdGhpcztcbiAgICAgICAgbGFzdENhbGxUaW1lID0gdGltZTtcblxuICAgICAgICBpZiAoaXNJbnZva2luZykge1xuICAgICAgICAgIGlmICh0aW1lcklkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIHJldHVybiBsZWFkaW5nRWRnZShsYXN0Q2FsbFRpbWUpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobWF4aW5nKSB7XG4gICAgICAgICAgICAvLyBIYW5kbGUgaW52b2NhdGlvbnMgaW4gYSB0aWdodCBsb29wLlxuICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVySWQpO1xuICAgICAgICAgICAgdGltZXJJZCA9IHNldFRpbWVvdXQodGltZXJFeHBpcmVkLCB3YWl0KTtcbiAgICAgICAgICAgIHJldHVybiBpbnZva2VGdW5jKGxhc3RDYWxsVGltZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aW1lcklkID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICB0aW1lcklkID0gc2V0VGltZW91dCh0aW1lckV4cGlyZWQsIHdhaXQpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICB9XG4gICAgICBkZWJvdW5jZWQuY2FuY2VsID0gY2FuY2VsO1xuICAgICAgZGVib3VuY2VkLmZsdXNoID0gZmx1c2g7XG4gICAgICByZXR1cm4gZGVib3VuY2VkO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIERlZmVycyBpbnZva2luZyB0aGUgYGZ1bmNgIHVudGlsIHRoZSBjdXJyZW50IGNhbGwgc3RhY2sgaGFzIGNsZWFyZWQuIEFueVxuICAgICAqIGFkZGl0aW9uYWwgYXJndW1lbnRzIGFyZSBwcm92aWRlZCB0byBgZnVuY2Agd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0gUmV0dXJucyB0aGUgY29udmVydGVkIGludGVnZXIuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8udG9MZW5ndGgoMy4yKTtcbiAgICAgKiAvLyA9PiAzXG4gICAgICpcbiAgICAgKiBfLnRvTGVuZ3RoKE51bWJlci5NSU5fVkFMVUUpO1xuICAgICAqIC8vID0+IDBcbiAgICAgKlxuICAgICAqIF8udG9MZW5ndGgoSW5maW5pdHkpO1xuICAgICAqIC8vID0+IDQyOTQ5NjcyOTVcbiAgICAgKlxuICAgICAqIF8udG9MZW5ndGgoJzMuMicpO1xuICAgICAqIC8vID0+IDNcbiAgICAgKi9cbiAgICBmdW5jdGlvbiB0b0xlbmd0aCh2YWx1ZSkge1xuICAgICAgcmV0dXJuIHZhbHVlID8gYmFzZUNsYW1wKHRvSW50ZWdlcih2YWx1ZSksIDAsIE1BWF9BUlJBWV9MRU5HVEgpIDogMDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBDb252ZXJ0cyBgdmFsdWVgIHRvIGEgbnVtYmVyLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMC4wXG4gICAgICogQGNhdGVnb3J5IExhbmdcbiAgICAgKiBAcGFyYW0geyp9IHZhbHVlIFRoZSB2YWx1ZSB0byBwcm9jZXNzLlxuICAgICAqIEByZXR1cm5zIHtudW1iZXJ9IFJldHVybnMgdGhlIG51bWJlci5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogXy50b051bWJlcigzLjIpO1xuICAgICAqIC8vID0+IDMuMlxuICAgICAqXG4gICAgICogXy50b051bWJlcihOdW1iZXIuTUlOX1ZBTFVFKTtcbiAgICAgKiAvLyA9PiA1ZS0zMjRcbiAgICAgKlxuICAgICAqIF8udG9OdW1iZXIoSW5maW5pdHkpO1xuICAgICAqIC8vID0+IEluZmluaXR5XG4gICAgICpcbiAgICAgKiBfLnRvTn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SBpbiBzb3VyY2UpIHtcbiAgICAgICAgaWYgKGhhc093blByb3BlcnR5LmNhbGwoc291cmNlLCBrZXkpKSB7XG4gICAgICAgICAgYXNzaWduVmFsdWUob2JqZWN0LCBrZXksIHNvdXJjZVtrZXldKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0pO1xuXG4gICAgLyoqXG4gICAgICogVGhpcyBtZXRob2QgaXMgbGlrZSBgXy5hc3NpZ25gIGV4Y2VwdCB0aGF0IGl0IGl0ZXJhdGVzIG92ZXIgb3duIGFuZFxuICAgICAqIGluaGVyaXRlZCBzb3VyY2UgcHJvcGVydGllcy5cbiAgICAgKlxuICAgICAqICoqTm90ZToqKiBUaGlzIG1ldGhvZCBtdXRhdGVzIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMC4wXG4gICAgICogQGFsaWFzIGV4dGVuZFxuICAgICAqIEBjYXRlZ29yeSBPYmplY3RcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gb2JqZWN0IFRoZSBkZXN0aW5hdGlvbiBvYmplY3QuXG4gICAgICogQHBhcmFtIHsuLi5PYmplY3R9IFtzb3VyY2VzXSBUaGUgc291cmNlIG9iamVjdHMuXG4gICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyBgb2JqZWN0YC5cbiAgICAgKiBAc2VlIF8uYXNzaWduXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIGZ1bmN0aW9uIEZvbygpIHtcbiAgICAgKiAgIHRoaXMuYSA9IDE7XG4gICAgICogfVxuICAgICAqXG4gICAgICogZnVuY3Rpb24gQmFyKCkge1xuICAgICAqICAgdGhpcy5jID0gMztcbiAgICAgKiB9XG4gICAgICpcbiAgICAgKiBGb28ucHJvdG90eXBlLmIgPSAyO1xuICAgICAqIEJhci5wcm90b3R5cGUuZCA9IDQ7XG4gICAgICpcbiAgICAgKiBfLmFzc2l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ICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyBgb2JqZWN0YC5cbiAgICAgKiBAc2VlIF8uZGVmYXVsdHNEZWVwXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8uZGVmYXVsdHMoeyAnYSc6IDEgfSwgeyAnYic6IDIgfSwgeyAnYSc6IDMgfSk7XG4gICAgICogLy8gPT4geyAnYSc6IDEsICdiJzogMiB9XG4gICAgICovXG4gICAgdmFyIGRlZmF1bHRzID0gYmFzZVJlc3QoZnVuY3Rpb24ob2JqZWN0LCBzb3VyY2VzKSB7XG4gICAgICBvYmplY3QgPSBPYmplY3Qob2JqZWN0KTtcblxuICAgICAgdmFyIGluZGV4ID0gLTE7XG4gICAgICB2YXIgbGVuZ3RoID0gc291cmNlcy5sZW5ndGg7XG4gICAgICB2YXIgZ3VhcmQgPSBsZW5ndGggPiAyID8gc291cmNlc1syXSA6IHVuZGVmaW5lZDtcblxuICAgICAgaWYgKGd1YXJkICYmIGlzSXRlcmF0ZWVDYWxsKHNvdXJjZXNbMF0sIHNvdXJjZXNbMV0sIGd1YXJkKSkge1xuICAgICAgICBsZW5ndGggPSAxO1xuICAgICAgfVxuXG4gICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICB2YXIgc291cmNlID0gc291cmNlc1tpbmRleF07XG4gICAgICAgIHZhciBwcm9wcyA9IGtleXNJbihzb3VyY2UpO1xuICAgICAgICB2YXIgcHJvcHNJbmRleCA9IC0xO1xuICAgICAgICB2YXIgcHJvcHNMZW5ndGggPSBwcm9wcy5sZW5ndGg7XG5cbiAgICAgICAgd2hpbGUgKCsrcHJvcHNJbmRleCA8IHByb3BzTGVuZ3RoKSB7XG4gICAgICAgICAgdmFyIGtleSA9IHByb3BzW3Byb3BzSW5kZXhdO1xuICAgICAgICAgIHZhciB2YWx1ZSA9IG9iamVjdFtrZXldO1xuXG4gICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQgfHx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nKVxuICAgICAgICAucmVwbGFjZShyZUVtcHR5U3RyaW5nVHJhaWxpbmcsICckMTsnKTtcblxuICAgICAgLy8gRnJhbWUgY29kZSBhcyB0aGUgZnVuY3Rpb24gYm9keS5cbiAgICAgIHNvdXJjZSA9ICdmdW5jdGlvbignICsgKHZhcmlhYmxlIHx8ICdvYmonKSArICcpIHtcXG4nICtcbiAgICAgICAgKHZhcmlhYmxlXG4gICAgICAgICAgPyAnJ1xuICAgICAgICAgIDogJ29iaiB8fCAob2JqID0ge30pO1xcbidcbiAgICAgICAgKSArXG4gICAgICAgIFwidmFyIF9fdCwgX19wID0gJydcIiArXG4gICAgICAgIChpc0VzY2FwaW5nXG4gICAgICAgICAgID8gJywgX19lID0gXy5lc2NhcGUnXG4gICAgICAgICAgIDogJydcbiAgICAgICAgKSArXG4gICAgICAgIChpc0V2YWx1YXRpbmdcbiAgICAgICAgICA/ICcsIF9faiA9IEFycmF5LnByb3RvdHlwZS5qb2luO1xcbicgK1xuICAgICAgICAgICAgXCJmdW5jdGlvbiBwcmludCgpIHsgX19wICs9IF9fai5jYWxsKGFyZ3VtZW50cywgJycpIH1cXG5cIlxuICAgICAgICAgIDogJztcXG4nXG4gICAgICAgICkgK1xuICAgICAgICBzb3VyY2UgK1xuICAgICAgICAncmV0dXJuIF9fcFxcbn0nO1xuXG4gICAgICB2YXIgcmVzdWx0ID0gYXR0ZW1wdChmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIEZ1bmN0aW9uKGltcG9ydHNLZXlzLCBzb3VyY2VVUkwgKyAncmV0dXJuICcgKyBzb3VyY2UpXG4gICAgICAgICAgLmFwcGx5KHVuZGVmaW5lZCwgaW1wb3J0c1ZhbHVlcyk7XG4gICAgICB9KTtcblxuICAgICAgLy8gUHJvdmlkZSB0aGUgY29tcGlsZWQgZnVuY3Rpb24ncyBzb3VyY2UgYnkgaXRzIGB0b1N0cmluZ2AgbWV0aG9kIG9yXG4gICAgICAvLyB0aGUgYHNvdXJjZ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ogXy5yYW5nZVJpZ2h0KDApO1xuICAgICAqIC8vID0+IFtdXG4gICAgICovXG4gICAgdmFyIHJhbmdlUmlnaHQgPSBjcmVhdGVSYW5nZSh0cnVlKTtcblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYSBuZXcgZW1wdHkgYXJyYXkuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgNC4xMy4wXG4gICAgICogQGNhdGVnb3J5IFV0aWxcbiAgICAgKiBAcmV0dXJucyB7QXJyYXl9IFJldHVybnMgdGhlIG5ldyBlbXB0eSBhcnJheS5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogdmFyIGFycmF5cyA9IF8udGltZXMoMiwgXy5zdHViQXJyYXkpO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXlzKTtcbiAgICAgKiAvLyA9PiBbW10sIFtdXVxuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXlzWzBdID09PSBhcnJheXNbMV0pO1xuICAgICAqIC8vID0+IGZhbHNlXG4gICAgICovXG4gICAgZnVuY3Rpb24gc3R1YkFycmF5KCkge1xuICAgICAgcmV0dXJuIFtdO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYGZhbHNlYC5cbiAgICAgKlxuICAgICAqIEBzdGF0aWNcbiAgICAgKiBAbWVtYmVyT2YgX1xuICAgICAqIEBzaW5jZSA0LjEzLjBcbiAgICAgKiBAY2F0ZWdvcnkgVXRpbFxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSBSZXR1cm5zIGBmYWxzZWAuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8udGltZXMoMiwgXy5zdHViRmFsc2UpO1xuICAgICAqIC8vID0+IFtmYWxzZSwgZmFsc2VdXG4gICAgICovXG4gICAgZnVuY3Rpb24gc3R1YkZhbHNlKCkge1xuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYSBuZXcgZW1wdHkgb2JqZWN0LlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTMuMFxuICAgICAqIEBjYXRlZ29yeSBVdGlsXG4gICAgICogQHJldHVybnMge09iamVjdH0gUmV0dXJucyB0aGUgbmV3IGVtcHR5IG9iamVjdC5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogdmFyIG9iamVjdHMgPSBfLnRpbWVzKDIsIF8uc3R1Yk9iamVjdCk7XG4gICAgICpcbiAgICAgKiBjb25zb2xlLmxvZyhvYmplY3RzKTtcbiAgICAgKiAvLyA9PiBbe30sIHt9XVxuICAgICAqXG4gICAgICogY29uc29sZS5sb2cob2JqZWN0c1swXSA9PT0gb2JqZWN0c1sxXSk7XG4gICAgICogLy8gPT4gZmFsc2VcbiAgICAgKi9cbiAgICBmdW5jdGlvbiBzdHViT2JqZWN0KCkge1xuICAgICAgcmV0dXJuIHt9O1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoaXMgbWV0aG9kIHJldHVybnMgYW4gZW1wdHkgc3RyaW5nLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTMuMFxuICAgICAqIEBjYXRlZ29yeSBVdGlsXG4gICAgICogQHJldHVybnMge3N0cmluZ30gUmV0dXJucyB0aGUgZW1wdHkgc3RyaW5nLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiBfLnRpbWVzKDIsIF8uc3R1YlN0cmluZyk7XG4gICAgICogLy8gPT4gWycnLCAnJ11cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBzdHViU3RyaW5nKCkge1xuICAgICAgcmV0dXJuICcnO1xu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bnVsbDtcbnZhciBpc0VudW1lcmFibGUgPSBPYmplY3QucHJvdG90eXBlLnByb3BlcnR5SXNFbnVtZXJhYmxlO1xuXG52YXIgZ1BPID0gKHR5cGVvZiBSZWZsZWN0ID09PSAnZnVuY3Rpb24nID8gUmVmbGVjdC5nZXRQcm90b3R5cGVPZiA6IE9iamVjdC5nZXRQcm90b3R5cGVPZikgfHwgKFxuICAgIFtdLl9fcHJvdG9fXyA9PT0gQXJyYXkucHJvdG90eXBlIC8vIGVzbGludC1kaXNhYmxlLWxpbmUgbm8tcHJvdG9cbiAgICAgICAgPyBmdW5jdGlvbiAoTykge1xuICAgICAgICAgICAgcmV0dXJuIE8uX19wcm90b19fOyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLXByb3RvXG4gICAgICAgIH1cbiAgICAgICAgOiBudWxsXG4pO1xuXG5mdW5jdGlvbiBhZGROdW1lcmljU2VwYXJhdG9yKG51bSwgc3RyKSB7XG4gICAgaWYgKFxuICAgICAgICBudW0gPT09IEluZmluaXR5XG4gICAgICAgIHx8IG51bSA9PT0gLUluZmluaXR5XG4gICAgICAgIHx8IG51bSAhPT0gbnVtXG4gICAgICAgIHx8IChudW0gJiYgbnVtID4gLTEwMDAgJiYgbnVtIDwgMTAwMClcbiAgICAgICAgfHwgJHRlc3QuY2FsbCgvZS8sIHN0cilcbiAgICApIHtcbiAgICAgICAgcmV0dXJuIHN0cjtcbiAgICB9XG4gICAgdmFyIHNlcFJlZ2V4ID0gL1swLTldKD89KD86WzAtOV17M30pKyg/IVswLTldKSkvZztcbiAgICBpZiAodHlwZW9mIG51bSA9PT0gJ251bWJlcicpIHtcbiAgICAgICAgdmFyIGludCA9IG51bSA8IDAgPyAtJGZsb29yKC1udW0pIDogJGZsb29yKG51bSk7IC8vIHRydW5jKG51bSlcbiAgICAgICAgaWYgKGludCAhPT0gbnVtKSB7XG4gICAgICAgICAgICB2YXIgaW50U3RyID0gU3RyaW5nKGludCk7XG4gICAgICAgICAgICB2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gMTApID09PSBvcHRzLmluZGVudCAmJiBvcHRzLmluZGVudCA+IDApXG4gICAgKSB7XG4gICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJ29wdGlvbiBcImluZGVudFwiIG11c3QgYmUgXCJcXFxcdFwiLCBhbiBpbnRlZ2VyID4gMCwgb3IgYG51bGxgJyk7XG4gICAgfVxuICAgIGlmIChoYXMob3B0cywgJ251bWVyaWNTZXBhcmF0b3InKSAmJiB0eXBlb2Ygb3B0cy5udW1lcmljU2VwYXJhdG9yICE9PSAnYm9vbGVhbicpIHtcbiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignb3B0aW9uIFwibnVtZXJpY1NlcGFyYXRvclwiLCBpZiBwcm92aWRlZCwgbXVzdCBiZSBgdHJ1ZWAgb3IgYGZhbHNlYCcpO1xuICAgIH1cbiAgICB2YXIgbnVtZXJpY1NlcGFyYXRvciA9IG9wdHMubnVtZXJpY1NlcGFyYXRvcjtcblxuICAgIGlmICh0eXBlb2Ygb2JqID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICByZXR1cm4gJ3VuZGVmaW5lZCc7XG4gICAgfVxuICAgIGlmIChvYmogPT09IG51bGwpIHtcbiAgICAgICAgcmV0dXJuICdudWxsJztcbiAgICB9XG4gICAgaWYgKHR5cGVvZiBvYmogPT09ICdib29sZWFuJykge1xuICAgICAgICByZXR1cm4gb2JqID8gJ3RydWUnIDogJ2ZhbHNlJztcbiAgICB9XG5cbiAgICBpZiAodHlwZW9mIG9iaiA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgcmV0dXJuIGluc3BlY3RTdHJpbmcob2JqLCBvcHRzKTtcbiAgICB9XG4gICAgaWYgKHR5cGVvZiBvYmogPT09ICdudW1iZXInKSB7XG4gICAgICAgIGlmIChvYmogPT09IDApIHtcbiAgICAgICAgICAgIHJldHVybiBJbmZpbml0eSAvIG9iaiA+IDAgPyAnMCcgOiAnLTAnO1xuICAgICAgICB9XG4gICAgICAgIHZhciBzdH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ScpIDogc3ltVG9TdHJpbmcuY2FsbChvYmopO1xuICAgICAgICByZXR1cm4gdHlwZW9mIG9iaiA9PT0gJ29iamVjdCcgJiYgIWhhc1NoYW1tZWRTeW1ib2xzID8gbWFya0JveGVkKHN5bVN0cmluZykgOiBzeW1TdHJpbmc7XG4gICAgfVxuICAgIGlmIChpc0VsZW1lbnQob2JqKSkge1xuICAgICAgICB2YXIgcyA9ICc8JyArICR0b0xvd2VyQ2FzZS5jYWxsKFN0cmluZyhvYmoubm9kZU5hbWUpKTtcbiAgICAgICAgdmFyIGF0dHJzID0gb2JqLmF0dHJpYnV0ZXMgfHwgW107XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgYXR0cnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHMgKz0gJyAnICsgYXR0cnNbaV0ubmFtZSArICc9JyArIHdyYXBRdW90ZXMocXVvdGUoYXR0cnNbaV0udmFsdWUpLCAnZG91YmxlJywgb3B0cyk7XG4gICAgICAgIH1cbiAgICAgICAgcyArPSAnPic7XG4gICAgICAgIGlmIChvYmouY2hpbGROb2RlcyAmJiBvYmouY2hpbGROb2Rlcy5sZW5ndGgpIHsgcyArPSAnLi4uJzsgfVxuICAgICAgICBzICs9ICc8LycgKyAkdG9Mb3dlckNhc2UuY2FsbChTdHJpbmcob2JqLm5vZGVOYW1lKSkgKyAnPic7XG4gICAgICAgIHJldHVybiBzO1xuICAgIH1cbiAgICBpZiAoaXNBcnJheShvYmopKSB7XG4gICAgICAgIGlmIChvYmoubGVuZ3RoID09PSAwKSB7IHJldHVybiAnW10nOyB9XG4gICAgICAgIHZhciB4cyA9IGFyck9iaktleXMob2JqLCBpbnNwZWN0KTtcbiAgICAgICAgaWYgKGluZGVudCAmJiAhc2luZ2xlTGluZVZhbHVlcyh4cykpIHtcbiAgICAgICAgICAgIHJldHVybiAnWycgKyBpbmRlbnRlZEpvaW4oeHMsIGluZGVudCkgKyAnXSc7XG4gICAgICAgIH1cbiAgICAg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QoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBpZiAoaXNNYXAob2JqKSkge1xuICAgICAgICB2YXIgbWFwUGFydHMgPSBbXTtcbiAgICAgICAgaWYgKG1hcEZvckVhY2gpIHtcbiAgICAgICAgICAgIG1hcEZvckVhY2guY2FsbChvYmosIGZ1bmN0aW9uICh2YWx1ZSwga2V5KSB7XG4gICAgICAgICAgICAgICAgbWFwUGFydHMucHVzaChpbnNwZWN0KGtleSwgb2JqLCB0cnVlKSArICcgPT4gJyArIGluc3BlY3QodmFsdWUsIG9iaikpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGNvbGxlY3Rpb25PZignTWFwJywgbWFwU2l6ZS5jYWxsKG9iaiksIG1hcFBhcnRzLCBpbmRlbnQpO1xuICAgIH1cbiAgICBpZiAoaXNTZXQob2JqKSkge1xuICAgICAgICB2YXIgc2V0UGFydHMgPSBbXTtcbiAgICAgICAgaWYgKHNldEZvckVhY2gpIHtcbiAgICAgICAgICAgIHNldEZvckVhY2guY2FsbChvYmosIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgIHNldFBhcnRzLnB1c2goaW5zcGVjdCh2YWx1ZSwgb2JqKSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gY29sbGVjdGlvbk9mKCdTZXQnLCBzZXRTaXplLmNhbGwob2JqKSwgc2V0UGFydHMsIGluZGVudCk7XG4gICAgfVxuICAgIGlmIChpc1dlYWtNYXAob2JqKSkge1xuICAgICAgICByZXR1cm4gd2Vha0NvbGxlY3Rpb25PZignV2Vha01hcCcpO1xuICAgIH1cbiAgICBpZiAoaXNXZWFrU2V0KG9iaikpIHtcbiAgICAgICAgcmV0dXJuIHdlYWtDb2xsZWN0aW9uT2YoJ1dlYWtTZXQnKTtcbiAgICB9XG4gICAgaWYgKGlzV2Vha1JlZihvYmopKSB7XG4gICAgICAgIHJldHVybiB3Z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AgICAgIGlmIChpc0FyciAmJiBTdHJpbmcoTnVtYmVyKGtleSkpID09PSBrZXkgJiYga2V5IDwgb2JqLmxlbmd0aCkgeyBjb250aW51ZTsgfSAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLXJlc3RyaWN0ZWQtc3ludGF4LCBuby1jb250aW51ZVxuICAgICAgICBpZiAoaGFzU2hhbW1lZFN5bWJvbHMgJiYgc3ltTWFwWyckJyArIGtleV0gaW5zdGFuY2VvZiBTeW1ib2wpIHtcbiAgICAgICAgICAgIC8vIHRoaXMgaXMgdG8gcHJldmVudCBzaGFtbWVkIFN5bWJvbHMsIHdoaWNoIGFyZSBzdG9yZWQgYXMgc3RyaW5ncywgZnJvbSBiZWluZyBpbmNsdWRlZCBpbiB0aGUgc3RyaW5nIGtleSBzZWN0aW9uXG4gICAgICAgICAgICBjb250aW51ZTsgLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1yZXN0cmljdGVkLXN5bnRheCwgbm8tY29udGludWVcbiAgICAgICAgfSBlbHNlIGlmICgkdGVzdC5jYWxsKC9bXlxcdyRdLywga2V5KSkge1xuICAgICAgICAgICAgeHMucHVzaChpbnNwZWN0KGtleSwgb2JqKSArICc6ICcgKyBpbnNwZWN0KG9ialtrZXldLCBvYmopKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHhzLnB1c2goa2V5ICsgJzogJyArIGluc3BlY3Qob2JqW2tleV0sIG9iaikpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGlmICh0eXBlb2YgZ09QUyA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICBmb3IgKHZhciBqID0gMDsgaiA8IHN5bXMubGVuZ3RoOyBqKyspIHtcbiAgICAgICAgICAgIGlmIChpc0VudW1lcmFibGUuY2FsbChvYmosIHN5bXNbal0pKSB7XG4gICAgICAgICAgICAgICAgeHMucHVzaCgnWycgKyBpbnNwZWN0KHN5bXNbal0pICsgJ106ICcgKyBpbnNwZWN0KG9ial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VEU7XG4gICAgICB9XG4gICAgICBlbHNlIHtcbiAgICAgICAgcHV0X2J5dGUocywgKHMuZ3poZWFkLnRleHQgPyAxIDogMCkgK1xuICAgICAgICAgICAgICAgICAgICAocy5nemhlYWQuaGNyYyA/IDIgOiAwKSArXG4gICAgICAgICAgICAgICAgICAgICghcy5nemhlYWQuZXh0cmEgPyAwIDogNCkgK1xuICAgICAgICAgICAgICAgICAgICAoIXMuZ3poZWFkLm5hbWUgPyAwIDogOCkgK1xuICAgICAgICAgICAgICAgICAgICAoIXMuZ3poZWFkLmNvbW1lbnQgPyAwIDogMTYpXG4gICAgICAgICk7XG4gICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLnRpbWUgJiAweGZmKTtcbiAgICAgICAgcHV0X2J5dGUocywgKHMuZ3poZWFkLnRpbWUgPj4gOCkgJiAweGZmKTtcbiAgICAgICAgcHV0X2J5dGUocywgKHMuZ3poZWFkLnRpbWUgPj4gMTYpICYgMHhmZik7XG4gICAgICAgIHB1dF9ieXRlKHMsIChzLmd6aGVhZC50aW1lID4+IDI0KSAmIDB4ZmYpO1xuICAgICAgICBwdXRfYnl0ZShzLCBzLmxldmVsID09PSA5ID8gMiA6XG4gICAgICAgICAgICAgICAgICAgIChzLnN0cmF0ZWd5ID49IFpfSFVGRk1BTl9PTkxZIHx8IHMubGV2ZWwgPCAyID9cbiAgICAgICAgICAgICAgICAgICAgIDQgOiAwKSk7XG4gICAgICAgIHB1dF9ieXRlKHMsIHMuZ3poZWFkLm9zICYgMHhmZik7XG4gICAgICAgIGlmIChzLmd6aGVhZC5leHRyYSAmJiBzLmd6aGVhZC5leHRyYS5sZW5ndGgpIHtcbiAgICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC5leHRyYS5sZW5ndGggJiAweGZmKTtcbiAgICAgICAgICBwdXRfYnl0ZShzLCAocy5nemhlYWQuZXh0cmEubGVuZ3RoID4+IDgpICYgMHhmZik7XG4gICAgICAgIH1cbiAgICAgICAgaW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d3JpdGUgaW5kZXggKi9cbiAgLy8gVXNlIGBzX3dpbmRvd2AgaW5zdGVhZCBgd2luZG93YCwgYXZvaWQgY29uZmxpY3Qgd2l0aCBpbnN0cnVtZW50YXRpb24gdG9vbHNcbiAgdmFyIHNfd2luZG93OyAgICAgICAgICAgICAgIC8qIGFsbG9jYXRlZCBzbGlkaW5nIHdpbmRvdywgaWYgd3NpemUgIT0gMCAqL1xuICB2YXIgaG9sZDsgICAgICAgICAgICAgICAgICAgLyogbG9jYWwgc3RybS5ob2xkICovXG4gIHZhciBiaXRzOyAgICAgICAgICAgICAgICAgICAvKiBsb2NhbCBzdHJtLmJpdHMgKi9cbiAgdmFyIGxjb2RlOyAgICAgICAgICAgICAgICAgIC8qIGxvY2FsIHN0cm0ubGVuY29kZSAqL1xuICB2YXIgZGNvZGU7ICAgICAgICAgICAgICAgICAgLyogbG9jYWwgc3RybS5kaXN0Y29kZSAqL1xuICB2YXIgbG1hc2s7ICAgICAgICAgICAgICAgICAgLyogbWFzayBmb3IgZmlyc3QgbGV2ZWwgb2YgbGVuZ3RoIGNvZGVzICovXG4gIHZhciBkbWFzazsgICAgICAgICAgICAgICAgICAvKiBtYXNrIGZvciBmaXJzdCBsZXZlbCBvZiBkaXN0YW5jZSBjb2RlcyAqL1xuICB2YXIgaGVyZTsgICAgICAgICAgICAgICAgICAgLyogcmV0cmlldmVkIHRhYmxlIGVudHJ5ICovXG4gIHZhciBvcDsgICAgICAgICAgICAgICAgICAgICAvKiBjb2RlIGJpdHMsIG9wZXJhdGlvbiwgZXh0cmEgYml0cywgb3IgKi9cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qICB3aW5kb3cgcG9zaXRpb24sIHdpbmRvdyBieXRlcyB0byBjb3B5ICovXG4gIHZhciBsZW47ICAgICAgICAgICAgICAgICAgICAvKiBtYXRjaCBsZW5ndGgsIHVudXNlZCBieXRlcyAqL1xuICB2YXIgZGlzdDsgICAgICAgICAgICAgICAgICAgLyogbWF0Y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gLyogbGVuZ3RoIGJhc2UgKi9cbiAgICAgICAgbGVuID0gaGVyZSAmIDB4ZmZmZi8qaGVyZS52YWwqLztcbiAgICAgICAgb3AgJj0gMTU7ICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogbnVtYmVyIG9mIGV4dHJhIGJpdHMgKi9cbiAgICAgICAgaWYgKG9wKSB7XG4gICAgICAgICAgaWYgKGJpdHMgPCBvcCkge1xuICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgbGVuICs9IGhvbGQgJiAoKDEgPDwgb3ApIC0gMSk7XG4gICAgICAgICAgaG9sZCA+Pj49IG9wO1xuICAgICAgICAgIGJpdHMgLT0gb3A7XG4gICAgICAgIH1cbiAgICAgICAgLy9UcmFjZXZ2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgICAgICBsZW5ndGggJXVcXG5cIiwgbGVuKSk7XG4gICAgICAgIGlmIChiaXRzIDwgMTUpIHtcbiAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzO1xuICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICBob2xkICs9IGlucHV0W19pbisrXSA8PCBiaXRzO1xuICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgfVxuICAgICAgICBoZXJlID0gZGNvZGVbaG9sZCAmIGRtYXNrXTtcblxuICAgICAgICBkb2Rpc3Q6XG4gICAgICAgIGZvciAoOzspIHsgLy8gZ290byBlbXVsYXRpb25cbiAgICAgICAgICBvcCA9IGhlcmUgPj4+IDI0LypoZXJlLmJpdHMqLztcbiAgICAgICAgICBob2xkID4+Pj0gb3A7XG4gICAgICAgICAgYml0cyAtPSBvcDtcbiAgICAgICAgICBvcCA9IChoZXJlID4+PiAxNikgJiAweGZmLypoZXJlLm9wKi87XG5cbiAgICAgICAgICBpZiAob3AgJiAxNikgeyAgICAgICAgICAgICAgICAgICAgICAvKiBkaXN0YW5jZSBiYXNlICovXG4gICAgICAgICAgICBkaXN0ID0gaGVyZSAmIDB4ZmZmZi8qaGVyZS52YWwqLztcbiAgICAgICAgICAgIG9wICY9IDE1OyAgICAgICAgICAgICAgICAgICAgICAgLyogbnVtYmVyIG9mIGV4dHJhIGJpdHMgKi9cbiAgICAgICAgICAgIGlmIChiaXRzIDwgb3ApIHtcbiAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgICAgICBpZiAoYml0cyA8IG9wKSB7XG4gICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3QgKz0gaG9sZCAmICgoMSA8PCBvcCkgLSAxKTtcbi8vI2lmZGVmIElORkxBVEVfU1RSSUNUXG4gICAgICAgICAgICBpZiAoZGlzdCA+IGRtYXgpIHtcbiAgICAgICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBkaXN0YW5jZSB0b28gZmFyIGJhY2snO1xuICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgICBicmVhayB0b3A7XG4gICAgICAgICAgICB9XG4vLyNlbmRpZlxuICAgICAgICAgICAgaG9sZCA+Pj49IG9wO1xuICAgICAgICAgICAgYml0cyAtPSBvcDtcbiAgICAgICAgICAgIC8vVHJhY2V2digoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgICAgZGlzdGFuY2UgJXVcXG5cIiwgZGlzdCkpO1xuICAgICAgICAgICAgb3AgPSBfb3V0IC0gYmVnOyAgICAgICAgICAgICAgICAvKiBtYXggZGlzdGFuY2UgaW4gb3V0cHV0ICovXG4gICAgICAgICAgICBpZiAoZGlzdCA+IG9wKSB7ICAgICAgICAgICAgICAgIC8qIHNlZSBpZiBjb3B5IGZyb20gd2luZG93ICovXG4gICAgICAgICAgICAgIG9wID0gZGlzdCAtIG9wOyAgICAgICAgICAgICAgIC8qIGRpc3RhbmNlIGJhY2sgaW4gd2luZG93ICovXG4gICAgICAgICAgICAgIGlmIChvcCA+IHdoYXZlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHN0YXRlLnNhbmUpIHtcbiAgICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgZGlzdGFuY2UgdG9vIGZhciBiYWNrJztcbiAgICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICAgICAgICBicmVhayB0b3A7XG4gICAgICAgICAgICAgICAgfVxuXG4vLyAoISkgVGhpcyBibG9jayBpcyBkaXNhYmxlZCBpbiB6bGliIGRlZmF1bHRzLFxuLy8gZG9uJ3QgZW5hYmxlIGl0IGZvciBiaW5hcnkgY29tcGF0aWJpbGl0eVxuLy8jaWZkZWYgSU5GTEFURV9BTExPV19JTlZBTElEX0RJU1RBTkNFX1RPT0ZBUl9BUlJSXG4vLyAgICAgICAgICAgICAgICBpZiAobGVuIDw9IG9wIC0gd2hhdmUpIHtcbi8vICAgICAgICAgICAgICAgICAgZG8ge1xuLy8gICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gMDtcbi8vICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1sZW4pO1xuLy8gICAgICAgICAgICAgICAgICBjb250aW51ZSB0b3A7XG4vLyAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgICBsZW4gLT0gb3AgLSB3aGF2ZTtcbi8vICAgICAgICAgICAgICAgIGRvIHtcbi8vICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSAwO1xuLy8gICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCA+IHdoYXZlKTtcbi8vICAgICAgICAgICAgICAgIGlmIChvcCA9PT0gMCkge1xuLy8gICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7XG4vLyAgICAgICAgICAgICAgICAgIGRvIHtcbi8vICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuLy8gICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLWxlbik7XG4vLyAgICAgICAgICAgICAgICAgIGNvbnRpbnVlIHRvcDtcbi8vICAgICAgICAgICAgICAgIH1cbi8vI2VuZGlmXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgZnJvbSA9IDA7IC8vIHdpbmRvdyBpbmRleFxuICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IHNfd2luZG93O1xuICAgICAgICAgICAgICBpZiAod25leHQgPT09IDApIHsgICAgICAgICAgIC8qIHZlcnkgY29tbW9uIGNhc2UgKi9cbiAgICAgICAgICAgICAgICBmcm9tICs9IHdzaXplIC0gb3A7XG4gICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7ICAgICAgICAgLyogc29tZSBmcm9tIHdpbmRvdyAqL1xuICAgICAgICAgICAgICAgICAgbGVuIC09IG9wO1xuICAgICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107XG4gICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTtcbiAgICAgICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsgIC8qIHJlc3QgZnJvbSBvdXRwdXQgKi9cbiAgICAgICAgICAgICAgICAgIGZyb21fc291cmNlID0gb3V0cHV0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBlbHNlIGlmICh3bmV4dCA8IG9wKSB7ICAgICAgLyogd3JhcCBhcm91bmQgd2luZG93ICovXG4gICAgICAgICAgICAgICAgZnJvbSArPSB3c2l6ZSArIHduZXh0IC0gb3A7XG4gICAgICAgICAgICAgICAgb3AgLT0gd25leHQ7XG4gICAgICAgICAgICAgICAgaWYgKG9wIDwgbGVuKSB7ICAgICAgICAgLyogc29tZSBmcm9tIGVuZCBvZiB3aW5kb3cgKi9cbiAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDtcbiAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdO1xuICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7XG4gICAgICAgICAgICAgICAgICBmcm9tID0gMDtcbiAgICAgICAgICAgICAgICAgIGlmICh3bmV4dCA8IGxlbikgeyAgLyogc29tZSBmcm9tIHN0YXJ0IG9mIHdpbmRvdyAqL1xuICAgICAgICAgICAgICAgICAgICBvcCA9IHduZXh0O1xuICAgICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7XG4gICAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IHNfd2luZG93W2Zyb20rK107XG4gICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApO1xuICAgICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7ICAgICAgLyogcmVzdCBmcm9tIG91dHB1dCAqL1xuICAgICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgZWxzZSB7ICAgICAgICAgICAgICAgICAgICAgIC8qIGNvbnRpZ3VvdXMgaW4gd2luZG93ICovXG4gICAgICAgICAgICAgICAgZnJvbSArPSB3bmV4dCAtIG9wO1xuICAgICAgICAgICAgICAgIGlmIChvcCA8IGxlbikgeyAgICAgICAgIC8qIHNvbWUgZnJvbSB3aW5kb3cgKi9cbiAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDtcbiAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdO1xuICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7XG4gICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7ICAvKiByZXN0IGZyb20gb3V0cHV0ICovXG4gICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgd2hpbGUgKGxlbiA+IDIpIHtcbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdO1xuICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBsZW4gLT0gMztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAobGVuKSB7XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdO1xuICAgICAgICAgICAgICAgIGlmIChsZW4gPiAxKSB7XG4gICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OyAgICAgICAgICAvKiBjb3B5IGRpcmVjdCBmcm9tIG91dHB1dCAqL1xuICAgICAgICAgICAgICBkbyB7ICAgICAgICAgICAgICAgICAgICAgICAgLyogbWluaW11bSBsZW5ndGggaXMgdGhyZWUgKi9cbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBsZW4gLT0gMztcbiAgICAgICAgICAgICAgfSB3aGlsZSAobGVuID4gMik7XG4gICAgICAgICAgICAgIGlmIChsZW4pIHtcbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuICAgICAgICAgICAgICAgIGlmIChsZW4gPiAxKSB7XG4gICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIGlmICgob3AgJiA2NCkgPT09IDApIHsgICAgICAgICAgLyogMm5kIGxldmVsIGRpc3RhbmNlIGNvZGUgKi9cbiAgICAgICAgICAgIGhlcmUgPSBkY29kZVsoaGVyZSAmIDB4ZmZmZikvKmhlcmUudmFsKi8gKyAoaG9sZCAmICgoMSA8PCBvcCkgLSAxKSldO1xuICAgICAgICAgICAgY29udGludWUgZG9kaXN0O1xuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgZGlzdGFuY2UgY29kZSc7XG4gICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgYnJlYWsgdG9wO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGJyZWFrOyAvLyBuZWVkIHRvIGVtdWxhdGUgZ290byB2aWEgXCJjb250aW51ZVwiXG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGVs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KiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuXG5cbnZhciAgICBIRUFEID0gMTsgICAgICAgLyogaTogd2FpdGluZyBmb3IgbWFnaWMgaGVhZGVyICovXG52YXIgICAgRkxBR1MgPSAyOyAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIG1ldGhvZCBhbmQgZmxhZ3MgKGd6aXApICovXG52YXIgICAgVElNRSA9IDM7ICAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIG1vZGlmaWNhdGlvbiB0aW1lIChnemlwKSAqL1xudmFyICAgIE9TID0gNDsgICAgICAgICAvKiBpOiB3YWl0aW5nIGZvciBleHRyYSBmbGFncyBhbmQgb3BlcmF0aW5nIHN5c3RlbSAoZ3ppcCkgKi9cbnZhciAgICBFWExFTiA9IDU7ICAgICAgLyogaTogd2FpdGluZyBmb3IgZXh0cmEgbGVuZ3RoIChnemlwKSAqL1xudmFyICAgIEVYVFJBID0gNjsgICAgICAvKiBpOiB3YWl0aW5nIGZvciBleHRyYSBieXRlcyAoZ3ppcCkgKi9cbnZhciAgICBOQU1FID0gNzsgICAgICAgLyogaTogd2FpdGluZyBmb3IgZW5kIG9mIGZpbGUgbmFtZSAoZ3ppcCkgKi9cbnZhciAgICBDT01NRU5UID0gODsgICAgLyogaTogd2FpdGluZyBmb3IgZW5kIG9mIGNvbW1lbnQgKGd6aXApICovXG52YXIgICAgSENSQyA9IDk7ICAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIGhlYWRlciBjcmMgKGd6aXApICovXG52YXIgICAgRElDVElEID0gMTA7ICAgIC8qIGk6IHdhaXRpbmcgZm9yIGRpY3Rpb25hcnkgY2hlY2sgdmFsdWUgKi9cbnZhciAgICBESUNUID0gMTE7ICAgICAgLyogd2FpdGluZyBmb3IgaW5mbGF0ZVNldERpY3Rpb25hcnkoKSBjYWxsICovXG52YXIgICAgICAgIFRZUEUgPSAxM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W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBpZiAoKHN0YXRlLndyYXAgJiAyKSAmJiBob2xkID09PSAweDhiMWYpIHsgIC8qIGd6aXAgaGVhZGVyICovXG4gICAgICAgICAgc3RhdGUuY2hlY2sgPSAwLypjcmMzMigwTCwgWl9OVUxMLCAwKSovO1xuICAgICAgICAgIC8vPT09IENSQzIoc3RhdGUuY2hlY2ssIGhvbGQpO1xuICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMHhmZjtcbiAgICAgICAgICBoYnVmWzFdID0gKGhvbGQgPj4+IDgpICYgMHhmZjtcbiAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCAyLCAwKTtcbiAgICAgICAgICAvLz09PS8vXG5cbiAgICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICAgIGhvbGQgPSAwO1xuICAgICAgICAgIGJpdHMgPSAwO1xuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgICBzdGF0ZS5tb2RlID0gRkxBR1M7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUuZmxhZ3MgPSAwOyAgICAgICAgICAgLyogZXhwZWN0IHpsaWIgaGVhZGVyICovXG4gICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7XG4gICAgICAgICAgc3RhdGUuaGVhZC5kb25lID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCEoc3RhdGUud3JhcCAmIDEpIHx8ICAgLyogY2hlY2sgaWYgemxpYiBoZWFkZXIgYWxsb3dlZCAqL1xuICAgICAgICAgICgoKGhvbGQgJiAweGZmKS8qQklUUyg4KSovIDw8IDgpICsgKGhvbGQgPj4gOCkpICUgMzEpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICdpbmNvcnJlY3QgaGVhZGVyIGNoZWNrJztcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGlmICgoaG9sZCAmIDB4MGYpLypCSVRTKDQpKi8gIT09IFpfREVGTEFURUQpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICd1bmtub3duIGNvbXByZXNzaW9uIG1ldGhvZCc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvLy0tLSBEUk9QQklUUyg0KSAtLS0vL1xuICAgICAgICBob2xkID4+Pj0gNDtcbiAgICAgICAgYml0cyAtPSA0O1xuICAgICAgICAvLy0tLS8vXG4gICAgICAgIGxlbiA9IChob2xkICYgMHgwZikvKkJJVFMoNCkqLyArIDg7XG4gICAgICAgIGlmIChzdGF0ZS53Yml0cyA9PT0gMCkge1xuICAgICAgICAgIHN0YXRlLndiaXRzID0gbGVuO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGxlbiA+IHN0YXRlLndiaXRzKSB7XG4gICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCB3aW5kb3cgc2l6ZSc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5kbWF4ID0gMSA8PCBsZW47XG4gICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICB6bGliIGhlYWRlciBva1xcblwiKSk7XG4gICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IDEvKmFkbGVyMzIoMEwsIFpfTlVMTCwgMCkqLztcbiAgICAgICAgc3RhdGUubW9kZSA9IGhvbGQgJiAweDIwMCA/IERJQ1RJRCA6IFRZUEU7XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgRkxBR1M6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDE2KTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5mbGFncyA9IGhvbGQ7XG4gICAgICAgIGlmICgoc3RhdGUuZmxhZ3MgJiAweGZmKSAhPT0gWl9ERUZMQVRFRCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ3Vua25vd24gY29tcHJlc3Npb24gbWV0aG9kJztcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4ZTAwMCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ3Vua25vd24gaGVhZGVyIGZsYWdzIHNldCc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQudGV4dCA9ICgoaG9sZCA+PiA4KSAmIDEpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgIC8vPT09IENSQzIoc3RhdGUuY2hlY2ssIGhvbGQpO1xuICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMHhmZjtcbiAgICAgICAgICBoYnVmWzFdID0gKGhvbGQgPj4+IDgpICYgMHhmZjtcbiAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCAyLCAwKTtcbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgIH1cbiAgICAgICAgLy89PT0gSU5JVEJJVFMoKTtcbiAgICAgICAgaG9sZCA9IDA7XG4gICAgICAgIGJpdHMgPSAwO1xuICAgICAgICAvLz09PS8vXG4gICAgICAgIHN0YXRlLm1vZGUgPSBUSU1FO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIFRJTUU6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDMyKTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQudGltZSA9IGhvbGQ7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgLy89PT0gQ1JDNChzdGF0ZS5jaGVjaywgaG9sZClcbiAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDB4ZmY7XG4gICAgICAgICAgaGJ1ZlsxXSA9IChob2xkID4+PiA4KSAmIDB4ZmY7XG4gICAgICAgICAgaGJ1ZlsyXSA9IChob2xkID4+PiAxNikgJiAweGZmO1xuICAgICAgICAgIGhidWZbM10gPSAoaG9sZCA+Pj4gMjQpICYgMHhmZjtcbiAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBoYnVmLCA0LCAwKTtcbiAgICAgICAgICAvLz09PVxuICAgICAgICB9XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5tb2RlID0gT1M7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgT1M6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDE2KTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQueGZsYWdzID0gKGhvbGQgJiAweGZmKTtcbiAgICAgICAgICBzdGF0ZS5oZWFkLm9zID0gKGhvbGQgPj4gOCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgLy89PT0gQ1JDMihzdGF0ZS5jaGVjaywgaG9sZCk7XG4gICAgICAgICAgaGJ1ZlswXSA9IGhvbGQgJiAweGZmO1xuICAgICAgICAgIGhidWZbMV0gPSAoaG9sZCA+Pj4gOCkgJiAweGZmO1xuICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGhidWYsIDIsIDApO1xuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgfVxuICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICBob2xkID0gMDtcbiAgICAgICAgYml0cyA9IDA7XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUubW9kZSA9IEVYTEVOO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIEVYTEVOOlxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDA0MDApIHtcbiAgICAgICAgICAvLz09PSBORUVEQklUUygxNik7ICovXG4gICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIHN0YXRlLmxlbmd0aCA9IGhvbGQ7XG4gICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmFfbGVuID0gaG9sZDtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgICAvLz09PSBDUkMyKHN0YXRlLmNoZWNrLCBob2xkKTtcbiAgICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMHhmZjtcbiAgICAgICAgICAgIGhidWZbMV0gPSAoaG9sZCA+Pj4gOCkgJiAweGZmO1xuICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7XG4gICAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgfVxuICAgICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgICAgaG9sZCA9IDA7XG4gICAgICAgICAgYml0cyA9IDA7XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLmV4dHJhID0gbnV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ZS5oZWFkLmV4dHJhX21heCA6IGNvcHksKi9cbiAgICAgICAgICAgICAgICBsZW5cbiAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgICAgLy96bWVtY3B5KHN0YXRlLmhlYWQuZXh0cmEgKyBsZW4sIG5leHQsXG4gICAgICAgICAgICAgIC8vICAgICAgICBsZW4gKyBjb3B5ID4gc3RhdGUuaGVhZC5leHRyYV9tYXggP1xuICAgICAgICAgICAgICAvLyAgICAgICAgc3RhdGUuaGVhZC5leHRyYV9tYXggLSBsZW4gOiBjb3B5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBpbnB1dCwgY29weSwgbmV4dCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBoYXZlIC09IGNvcHk7XG4gICAgICAgICAgICBuZXh0ICs9IGNvcHk7XG4gICAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHN0YXRlLmxlbmd0aCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5sZW5ndGggPSAwO1xuICAgICAgICBzdGF0ZS5tb2RlID0gTkFNRTtcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBOQU1FOlxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDA4MDApIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBjb3B5ID0gMDtcbiAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAvLyBUT0RPOiAyIG9yIDEgYnl0ZXM/XG4gICAgICAgICAgICBsZW4gPSBpbnB1dFtuZXh0ICsgY29weSsrXTtcbiAgICAgICAg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0gaW5wdXRbbmV4dCArIGNvcHkrK107XG4gICAgICAgICAgICAvKiB1c2UgY29uc3RhbnQgbGltaXQgYmVjYXVzZSBpbiBqcyB3ZSBzaG91bGQgbm90IHByZWFsbG9jYXRlIG1lbW9yeSAqL1xuICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQgJiYgbGVuICYmXG4gICAgICAgICAgICAgICAgKHN0YXRlLmxlbmd0aCA8IDY1NTM2IC8qc3RhdGUuaGVhZC5jb21tX21heCovKSkge1xuICAgICAgICAgICAgICBzdGF0ZS5oZWFkLmNvbW1lbnQgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShsZW4pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7XG4gICAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgICBzdGF0ZS5jaGVjayA9IGNyYzMyKHN0YXRlLmNoZWNrLCBpbnB1dCwgY29weSwgbmV4dCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGhhdmUgLT0gY29weTtcbiAgICAgICAgICBuZXh0ICs9IGNvcHk7XG4gICAgICAgICAgaWYgKGxlbikgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7XG4gICAgICAgICAgc3RhdGUuaGVhZC5jb21tZW50ID0gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5tb2RlID0gSENSQztcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBIQ1JDOlxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDAyMDApIHtcbiAgICAgICAgICAvLz09PSBORUVEQklUUygxNik7ICovXG4gICAgICAgICAgd2hpbGUgKGJpdHMgPCAxNikge1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIGlmIChob2xkICE9PSAoc3RhdGUuY2hlY2sgJiAweGZmZmYpKSB7XG4gICAgICAgICAgICBzdHJtLm1zZyA9ICdoZWFkZXIgY3JjIG1pc21hdGNoJztcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0gSU5JVEJJVFMoKTtcbiAgICAgICAgICBob2xkID0gMDtcbiAgICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLmhjcmMgPSAoKHN0YXRlLmZsYWdzID4+IDkpICYgMSk7XG4gICAgICAgICAgc3RhdGUuaGVhZC5kb25lID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAwO1xuICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIERJQ1RJRDpcbiAgICAgICAgLy89PT0gTkVFREJJVFMoMzIpOyAqL1xuICAgICAgICB3aGlsZSAoYml0cyA8IDMyKSB7XG4gICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgfVxuICAgICAgICAvLz09PS8vXG4gICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9IHpzd2FwMzIoaG9sZCk7XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5tb2RlID0gRElDVDtcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBESUNUOlxuICAgICAgICBpZiAoc3RhdGUuaGF2ZWRpY3QgPT09IDApIHtcbiAgICAgICAgICAvLy0tLSBSRVNUT1JFKCkgLS0tXG4gICAgICAgICAgc3RybS5uZXh0X291dCA9IHB1dDtcbiAgICAgICAgICBzdHJtLmF2YWlsX291dCA9IGxlZnQ7XG4gICAgICAgICAgc3RybS5uZXh0X2luID0gbmV4dDtcbiAgICAgICAgICBzdHJtLmF2YWlsX2luID0gaGF2ZTtcbiAgICAgICAgICBzdGF0ZS5ob2xkID0gaG9sZDtcbiAgICAgICAgICBzdGF0ZS5iaXRzID0gYml0cztcbiAgICAgICAgICAvLy0tLVxuICAgICAgICAgIHJldHVybiBaX05FRURfRElDVDtcbiAgICAgICAgfVxuICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAxLyphZGxlcjMyKDBMLCBaX05VTEwsIDApKi87XG4gICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIFRZUEU6XG4gICAgICAgIGlmIChmbHVzaCA9PT0gWl9CTE9DSyB8fCBmbHVzaCA9PT0gWl9UUkVFUykgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBUWVBFRE86XG4gICAgICAgIGlmIChzdGF0ZS5sYXN0KSB7XG4gICAgICAgICAgLy8tLS0gQllURUJJVFMoKSAtLS0vL1xuICAgICAgICAgIGhvbGQgPj4+PSBiaXRzICYgNztcbiAgICAgICAgICBiaXRzIC09IGJpdHMgJiA3O1xuICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQ0hFQ0s7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0gTkVFREJJVFMoMyk7ICovXG4gICAgICAgIHdoaWxlIChiaXRzIDwgMykge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5sYXN0ID0gKGhvbGQgJiAweDAxKS8qQklUUygxKSovO1xuICAgICAgICAvLy0tLSBEUk9QQklUUygxKSAtLS0vL1xuICAgICAgICBob2xkID4+Pj0gMTtcbiAgICAgICAgYml0cyAtPSAxO1xuICAgICAgICAvLy0tLS8vXG5cbiAgICAgICAgc3dpdGNoICgoaG9sZCAmIDB4MDMpLypCSVRTKDIpKi8pIHtcbiAgICAgICAgICBjYXNlIDA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBzdG9yZWQgYmxvY2sgKi9cbiAgICAgICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgIHN0b3JlZCBibG9jayVzXFxuXCIsXG4gICAgICAgICAgICAvLyAgICAgICAgc3RhdGUubGFzdCA/IFwiIChsYXN0KVwiIDogXCJcIikpO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IFNUT1JFRDtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIGNhc2UgMTogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIGZpeGVkIGJsb2NrICovXG4gICAgICAgICAgICBmaXhlZHRhYmxlcyhzdGF0ZSk7XG4gICAgICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgICBmaXhlZCBjb2RlcyBibG9jayVzXFxuXCIsXG4gICAgICAgICAgICAvLyAgICAgICAgc3RhdGUubGFzdCA/IFwiIChsYXN0KVwiIDogXCJcIikpO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IExFTl87ICAgICAgICAgICAgIC8qIGRlY29kZSBjb2RlcyAqL1xuICAgICAgICAgICAgaWYgKGZsdXNoID09PSBaX1RSRUVTKSB7XG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKDIpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSAyO1xuICAgICAgICAgICAgICBiaXRzIC09IDI7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgICAgYnJlYWsgaW5mX2xlYXZlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgY2FzZSAyOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogZHluYW1pYyBibG9jayAqL1xuICAgICAgICAgICAgLy9UcmFjZXYoKHN0ZGVyciwgXCJpbmZsYXRlOiAgICAgZHluYW1pYyBjb2RlcyBibG9jayVzXFxuXCIsXG4gICAgICAgICAgICAvLyAgICAgICAgc3RhdGUubGFzdCA/IFwiIChsYXN0KVwiIDogXCJcIikpO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IFRBQkxFO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgY2FzZSAzOlxuICAgICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBibG9jayB0eXBlJztcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgIH1cbiAgICAgICAgLy8tLS0gRFJPUEJJVFMoMikgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IDI7XG4gICAgICAgIGJpdHMgLT0gMjtcbiAgICAgICAgLy8tLS0vL1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgU1RPUkVEOlxuICAgICAgICAvLy0tLSBCWVRFQklUUygpIC0tLS8vIC8qIGdvIHRvIGJ5dGUgYm91bmRhcnkgKi9cbiAgICAgICAgaG9sZCA+Pj49IGJpdHMgJiA3O1xuICAgICAgICBiaXRzIC09IGJpdHMgJiA3O1xuICAgICAgICAvLy0tLS8vXG4gICAgICAgIC8vPT09IE5FRURCSVRTKDMyKTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBpZiAoKGhvbGQgJiAweGZmZmYpICE9PSAoKGhvbGQgPj4+IDE2KSBeIDB4ZmZmZikpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIHN0b3JlZCBibG9jayBsZW5ndGhzJztcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRlLmxlbmd0aCA9IGhvbGQgJiAweGZmZmY7XG4gICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgICAgc3RvcmVkIGxlbmd0aCAldVxcblwiLFxuICAgICAgICAvLyAgICAgICAgc3RhdGUubGVuZ3RoKSk7XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5tb2RlID0gQ09QWV87XG4gICAgICAgIGlmIChmbHVzaCA9PT0gWl9UUkVFUykgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBDT1BZXzpcbiAgICAgICAgc3RhdGUubW9kZSA9IENPUFk7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgQ09QWTpcbiAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDtcbiAgICAgICAgaWYgKGNvcHkpIHtcbiAgICAgICAgICBpZiAoY29weSA+IGhhdmUpIHsgY29weSA9IGhhdmU7IH1cbiAgICAgICAgICBpZiAoY29weSA+IGxlZnQpIHsgY29weSA9IGxlZnQ7IH1cbiAgICAgICAgICBpZiAoY29weSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAvLy0tLSB6bWVtY3B5KHB1dCwgbmV4dCwgY29weSk7IC0tLVxuICAgICAgICAgIHV0aWxzLmFycmF5U2V0KG91dHB1dCwgaW5wdXQsIG5leHQsIGNvcHksIHB1dCk7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIGhhdmUgLT0gY29weTtcbiAgICAgICAgICBuZXh0ICs9IGNvcHk7XG4gICAgICAgICAgbGVmdCAtPSBjb3B5O1xuICAgICAgICAgIHB1dCArPSBjb3B5O1xuICAgICAgICAgIHN0YXRlLmxlbmd0aCAtPSBjb3B5O1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgICAgc3RvcmVkIGVuZFxcblwiKSk7XG4gICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgVEFCTEU6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDE0KTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAxNCkge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgI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AgIGlmICgoaGVyZV9iaXRzKSA8PSBiaXRzKSB7IGJyZWFrOyB9XG4gICAgICAgICAgICAvLy0tLSBQVUxMQllURSgpIC0tLS8vXG4gICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaGVyZV92YWwgPCAxNikge1xuICAgICAgICAgICAgLy8tLS0gRFJPUEJJVFMoaGVyZS5iaXRzKSAtLS0vL1xuICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzO1xuICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgICAgc3RhdGUubGVuc1tzdGF0ZS5oYXZlKytdID0gaGVyZV92YWw7XG4gICAgICAgICAgfVxuICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgaWYgKGhlcmVfdmFsID09PSAxNikge1xuICAgICAgICAgICAgICAvLz09PSBORUVEQklUUyhoZXJlLmJpdHMgKyAyKTtcbiAgICAgICAgICAgICAgbiA9IGhlcmVfYml0cyArIDI7XG4gICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikge1xuICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgLy89PT0vL1xuICAgICAgICAgICAgICAvLy0tLSBEUk9QQklUUyhoZXJlLmJpdHMpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzO1xuICAgICAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlID09PSAwKSB7XG4gICAgICAgICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBiaXQgbGVuZ3RoIHJlcGVhdCc7XG4gICAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBsZW4gPSBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUgLSAxXTtcbiAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDB4MDMpOy8vQklUUygyKTtcbiAgICAgICAgICAgICAgLy8tLS0gRFJPUEJJVFMoMikgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IDI7XG4gICAgICAgICAgICAgIGJpdHMgLT0gMjtcbiAgICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAoaGVyZV92YWwgPT09IDE3KSB7XG4gICAgICAgICAgICAgIC8vPT09IE5FRURCSVRTKGhlcmUuYml0cyArIDMpO1xuICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgMztcbiAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7XG4gICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgICAgbGVuID0gMDtcbiAgICAgICAgICAgICAgY29weSA9IDMgKyAoaG9sZCAmIDB4MDcpOy8vQklUUygzKTtcbiAgICAgICAgICAgICAgLy8tLS0gRFJPUEJJVFMoMykgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IDM7XG4gICAgICAgICAgICAgIGJpdHMgLT0gMztcbiAgICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgIC8vPT09IE5FRURCSVRTKGhlcmUuYml0cyArIDcpO1xuICAgICAgICAgICAgICBuID0gaGVyZV9iaXRzICsgNztcbiAgICAgICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7XG4gICAgICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgICAgbGVuID0gMDtcbiAgICAgICAgICAgICAgY29weSA9IDExICsgKGhvbGQgJiAweDdmKTsvL0JJVFMoNyk7XG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKDcpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSA3O1xuICAgICAgICAgICAgICBiaXRzIC09IDc7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdGF0ZS5oYXZlICsgY29weSA+IHN0YXRlLm5sZW4gKyBzdGF0ZS5uZGlzdCkge1xuICAgICAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIGJpdCBsZW5ndGggcmVwZWF0JztcbiAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB3aGlsZSAoY29weS0tKSB7XG4gICAgICAgICAgICAgIHN0YXRlLmxlbnNbc3RhdGUuaGF2ZSsrXSA9IGxlbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKiBoYW5kbGUgZXJyb3IgYnJlYWtzIGluIHdoaWxlICovXG4gICAgICAgIGlmIChzdGF0ZS5tb2RlID09PSBCQUQpIHsgYnJlYWs7IH1cblxuICAgICAgICAvKiBjaGVjayBmb3IgZW5kLW9mLWJsb2NrIGNvZGUgKGJldHRlciBoYXZlIG9uZSkgKi9cbiAgICAgICAgaWYgKHN0YXRlLmxlbnNbMjU2XSA9PT0gMCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgY29kZSAtLSBtaXNzaW5nIGVuZC1vZi1ibG9jayc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuXG4gICAgICAgIC8qIGJ1aWxkIGNvZGUgdGFibGVzIC0tIG5vdGU6IGRvIG5vdCBjaGFuZ2UgdGhlIGxlbmJpdHMgb3IgZGlzdGJpdHNcbiAgICAgICAgICAgdmFsdWVzIGhlcmUgK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L1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICB9XG4gICAgICAgICAgLy8tLS0gRFJPUEJJVFMobGFzdC5iaXRzKSAtLS0vL1xuICAgICAgICAgIGhvbGQgPj4+PSBsYXN0X2JpdHM7XG4gICAgICAgICAgYml0cyAtPSBsYXN0X2JpdHM7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIHN0YXRlLmJhY2sgKz0gbGFzdF9iaXRzO1xuICAgICAgICB9XG4gICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7XG4gICAgICAgIC8vLS0tLy9cbiAgICAgICAgc3RhdGUuYmFjayArPSBoZXJlX2JpdHM7XG4gICAgICAgIHN0YXRlLmxlbmd0aCA9IGhlcmVfdmFsO1xuICAgICAgICBpZiAoaGVyZV9vcCA9PT0gMCkge1xuICAgICAgICAgIC8vVHJhY2V2digoc3RkZXJyLCBoZXJlLnZhbCA+PSAweDIwICYmIGhlcmUudmFsIDwgMHg3ZiA/XG4gICAgICAgICAgLy8gICAgICAgIFwiaW5mbGF0ZTogICAgICAgICBsaXRlcmFsICclYydcXG5cIiA6XG4gICAgICAgICAgLy8gICAgICAgIFwiaW5mbGF0ZTogICAgICAgICBsaXRlcmFsIDB4JTAyeFxcblwiLCBoZXJlLnZhbCkpO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBMSVQ7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGhlcmVfb3AgJiAzMikge1xuICAgICAgICA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UubGVuZ3RoKSB7IGNvcHkgPSBzdGF0ZS5sZW5ndGg7IH1cbiAgICAgICAgICBmcm9tX3NvdXJjZSA9IHN0YXRlLndpbmRvdztcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBjb3B5IGZyb20gb3V0cHV0ICovXG4gICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7XG4gICAgICAgICAgZnJvbSA9IHB1dCAtIHN0YXRlLm9mZnNldDtcbiAgICAgICAgICBjb3B5ID0gc3RhdGUubGVuZ3RoO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjb3B5ID4gbGVmdCkgeyBjb3B5ID0gbGVmdDsgfVxuICAgICAgICBsZWZ0IC09IGNvcHk7XG4gICAgICAgIHN0YXRlLmxlbmd0aCAtPSBjb3B5O1xuICAgICAgICBkbyB7XG4gICAgICAgICAgb3V0cHV0W3B1dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107XG4gICAgICAgIH0gd2hpbGUgKC0tY29weSk7XG4gICAgICAgIGlmIChzdGF0ZS5sZW5ndGggPT09IDApIHsgc3RhdGUubW9kZSA9IExFTjsgfVxuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgTElUOlxuICAgICAgICBpZiAobGVmdCA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgb3V0cHV0W3B1dCsrXSA9IHN0YXRlLmxlbmd0aDtcbiAgICAgICAgbGVmdC0tO1xuICAgICAgICBzdGF0ZS5tb2RlID0gTEVOO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgQ0hFQ0s6XG4gICAgICAgIGlmIChzdGF0ZS53cmFwKSB7XG4gICAgICAgICAgLy89PT0gTkVFREJJVFMoMzIpO1xuICAgICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHtcbiAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgLy8gVXNlICd8JyBpbnN0ZWFkIG9mICcrJyB0byBtYWtlIHN1cmUgdGhhdCByZXN1bHQgaXMgc2lnbmVkXG4gICAgICAgICAgICBob2xkIHw9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIF9vdXQgLT0gbGVmdDtcbiAgICAgICAgICBzdHJtLnRvdGFsX291dCArPSBfb3V0O1xuICAgICAgICAgIHN0YXRlLnRvdGFsICs9IF9vdXQ7XG4gICAgICAgICAgaWYgKF9vdXQpIHtcbiAgICAgICAgICAgIHN0cm0uYWRsZXIgPSBzdGF0ZS5jaGVjayA9XG4gICAgICAgICAgICAgICAgLypVUERBVEUoc3RhdGUuY2hlY2ssIHB1dCAtIF9vdXQsIF9vdXQpOyovXG4gICAgICAgICAgICAgICAgKHN0YXRlLmZsYWdzID8gY3JjMzIoc3RhdGUuY2hlY2ssIG91dHB1dCwgX291dCwgcHV0IC0gX291dCkgOiBhZGxlcjMyKHN0YXRlLmNoZWNrLCBvdXRwdXQsIF9vdXQsIHB1dCAtIF9vdXQpKTtcblxuICAgICAgICAgIH1cbiAgICAgICAgICBfb3V0ID0gbGVmdDtcbiAgICAgICAgICAvLyBOQjogY3JjMzIgc3RvcmVkIGFzIHNpZ25lZCAzMi1iaXQgaW50LCB6c3dhcDMyIHJldHVybnMgc2lnbmVkIHRvb1xuICAgICAgICAgIGlmICgoc3RhdGUuZmxhZ3MgPyBob2xkIDogenN3YXAzMihob2xkKSkgIT09IHN0YXRlLmNoZWNrKSB7XG4gICAgICAgICAgICBzdHJtLm1zZyA9ICdpbmNvcnJlY3QgZGF0YSBjaGVjayc7XG4gICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgICAgaG9sZCA9IDA7XG4gICAgICAgICAgYml0cyA9IDA7XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICBjaGVjayBtYXRjaGVzIHRyYWlsZXJcXG5cIikpO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRlLm1vZGUgPSBMRU5HVEg7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgTEVOR1RIOlxuICAgICAgICBpZiAoc3RhdGUud3JhcCAmJiBzdGF0ZS5mbGFncykge1xuICAgICAgICAgIC8vPT09IE5FRURCSVRTKDMyKTtcbiAgICAgICAgICB3aGlsZSAoYml0cyA8IDMyKSB7XG4gICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgIH1cbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgaWYgKGhvbGQgIT09IChzdGF0ZS50b3RhbCAmIDB4ZmZmZmZmZmYpKSB7XG4gICAgICAgICAgICBzdHJtLm1zZyA9ICdpbmNvcnJlY3QgbGVuZ3RoIGNoZWNrJztcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0gSU5JVEJJVFMoKTtcbiAgICAgICAgICBob2xkID0gMDtcbiAgICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgLy9UcmFjZXYoKHN0ZGVyciwgXCJpbmZsYXRlOiAgIGxlbmd0aCBtYXRjaGVzIHRyYWlsZXJcXG5cIikpO1xuICAgICAg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AgICAgLyogYSBjb2RlJ3MgbGVuZ3RoIGluIGJpdHMgKi9cbiAgdmFyIHN5bSA9IDA7ICAgICAgICAgICAgICAgLyogaW5kZXggb2YgY29kZSBzeW1ib2xzICovXG4gIHZhciBtaW4gPSAwLCBtYXggPSAwOyAgICAgICAgICAvKiBtaW5pbXVtIGFuZCBtYXhpbXVtIGNvZGUgbGVuZ3RocyAqL1xuICB2YXIgcm9vdCA9IDA7ICAgICAgICAgICAgICAvKiBudW1iZXIgb2YgaW5kZXggYml0cyBmb3Igcm9vdCB0YWJsZSAqL1xuICB2YXIgY3VyciA9IDA7ICAgICAgICAgICAgICAvKiBudW1iZXIgb2YgaW5kZXggYml0cyBmb3IgY3VycmVudCB0YWJsZSAqL1xuICB2YXIgZHJvcCA9IDA7ICAgICAgICAgICAgICAvKiBjb2RlIGJpdHMgdG8gZHJvcCBmb3Igc3ViLXRhYmxlICovXG4gIHZhciBsZWZ0ID0gMDsgICAgICAgICAgICAgICAgICAgLyogbnVtYmVyIG9mIHByZWZpeCBjb2RlcyBhdmFpbGFibGUgKi9cbiAgdmFyIHVzZWQgPSAwOyAgICAgICAgICAgICAgLyogY29kZSBlbnRyaWVzIGluIHRhYmxlIHVzZWQgKi9cbiAgdmFyIGh1ZmYgPSAwOyAgICAgICAgICAgICAgLyogSHVmZm1hbiBjb2RlICovXG4gIHZhciBpbmNyOyAgICAgICAgICAgICAgLyogZm9yIGluY3JlbWVudGluZyBjb2RlLCBpbmRleCAqL1xuICB2YXIgZmlsbDsgICAgICAgICAgICAgIC8qIGluZGV4IGZvciByZXBsaWNhdGluZyBlbnRyaWVzICovXG4gIHZhciBsb3c7ICAgICAgICAgICAgICAgLyogbG93IGJpdHMgZm9yIGN1cnJlbnQgcm9vdCBlbnRyeSAqL1xuICB2YXIgbWFzazsgICAgICAgICAgICAgIC8qIG1hc2sgZm9yIGxvdyByb290IGJpdHMgKi9cbiAgdmFyIG5leHQ7ICAgICAgICAgICAgIC8qIG5leHQgYXZhaW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XG4vLyAgIG1pc3JlcHJlc2VudGVkIGFzIGJlaW5nIHRoZSBvcmlnaW5hbCBzb2Z0d2FyZS5cbi8vIDMuIFRoaXMgbm90aWNlIG1heSBub3QgYmUgcmVtb3ZlZCBvciBhbHRlcmVkIGZyb20gYW55IHNvdXJjZSBkaXN0cmlidXRpb24uXG5cbi8qIGVzbGludC1kaXNhYmxlIHNwYWNlLXVuYXJ5LW9wcyAqL1xuXG52YXIgdXRpbHMgPSByZXF1aXJlKCcuLi91dGlscy9jb21tb24nKTtcblxuLyogUHVibGljIGNvbnN0YW50cyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki9cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG5cblxuLy92YXIgWl9GSUxURVJFRCAgICAgICAgICA9IDE7XG4vL3ZhciBaX0hVRkZNQU5fT05MWSAgICAgID0gMjtcbi8vdmFyIFpfUkxFICAgICAgICAgICAgICAgPSAzO1xudmFyIFpfRklYRUQgICAgICAgICAgICAgICA9IDQ7XG4vL3ZhciBaX0RFRkFVTFRfU1RSQVRFR1kgID0gMDtcblxuLyogUG9zc2libGUgdmFsdWVzIG9mIHRoZSBkYXRhX3R5cGUgZmllbGQgKHRob3VnaCBzZWUgaW5mbGF0ZSgpKSAqL1xudmFyIFpfQklOQVJZICAgICAgICAgICAgICA9IDA7XG52YXIgWl9URVhUICAgICAgICAgICAgICAgID0gMTtcbi8vdmFyIFpfQVNDSUkgICAgICAgICAgICAgPSAxOyAvLyA9IFpfVEVYVFxudmFyIFpfVU5LTk9XTiAgICAgICAgICAgICA9IDI7XG5cbi8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG5cblxuZnVuY3Rpb24gemVybyhidWYpIHsgdmFyIGxlbiA9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WUpIHtcbiAgc2VuZF9iaXRzKHMsIHRyZWVbYyAqIDJdLyouQ29kZSovLCB0cmVlW2MgKiAyICsgMV0vKi5MZW4qLyk7XG59XG5cblxuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4gKiBSZXZlcnNlIHRoZSBmaXJzdCBsZW4gYml0cyBvZiBhIGNvZGUsIHVzaW5nIHN0cmFpZ2h0Zm9yd2FyZCBjb2RlIChhIGZhc3RlclxuICogbWV0aG9kIHdvdWxkIHVzZSBhIHRhYmxlKVxuICogSU4gYXNzZXJ0aW9uOiAxIDw9IGxlbiA8PSAxNVxuICovXG5mdW5jdGlvbiBiaV9yZXZlcnNlKGNvZGUsIGxlbikge1xuICB2YXIgcmVzID0gMDtcbiAgZG8ge1xuICAgIHJlcyB8PSBjb2RlICYgMTtcbiAgICBjb2RlID4+Pj0gMTtcbiAgICByZXMgPDw9IDE7XG4gIH0gd2hpbGUgKC0tbGVuID4gMCk7XG4gIHJldHVybiByZXMgPj4+IDE7XG59XG5cblxuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4gKiBGbHVzaCB0aGUgYml0IGJ1ZmZlciwga2VlcGluZyBhdCBtb3N0IDcgYml0cyBpbiBpdC5cbiAqL1xuZnVuY3Rpb24gYmlfZmx1c2gocykge1xuICBpZiAocy5iaV92YWxpZCA9PT0gMTYpIHtcbiAgICBwdXRfc2hvcnQocywgcy5iaV9idWYpO1xuICAgIHMuYmlfYnVmID0gMDtcbiAgICBzLmJpX3ZhbGlkID0gMDtcblxuICB9IGVsc2UgaWYgKHMuYmlfdmFsaWQgPj0gOCkge1xuICAgIHMucGVuZGluZ19idWZbcy5wZW5kaW5nKytdID0gcy5iaV9idWYgJiAweGZmO1xuICAgIHMuYmlfYnVmID4+PSA4O1xuICAgIHMuYmlfd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ID09IDApICovXG4gIHZhciBseCA9IDA7ICAgICAgICAgLyogcnVubmluZyBpbmRleCBpbiBsX2J1ZiAqL1xuICB2YXIgY29kZTsgICAgICAgICAgIC8qIHRoZSBjb2RlIHRvIHNlbmQgKi9cbiAgdmFyIGV4dHJhOyAgICAgICAgICAvKiBudW1iZXIgb2YgZXh0cmEgYml0cyB0byBzZW5kICovXG5cbiAgaWYgKHMubGFzdF9saXQgIT09IDApIHtcbiAgICBkbyB7XG4gICAgICBkaXN0ID0gKHMucGVuZGluZ19idWZbcy5kX2J1ZiArIGx4ICogMl0gPDwgOCkgfCAocy5wZW5kaW5nX2J1ZltzLmRfYnVmICsgbHggKiAyICsgMV0pO1xuICAgICAgbGMgPSBzLnBlbmRpbmdfYnVmW3MubF9idWYgKyBseF07XG4gICAgICBseCsrO1xuXG4gICAgICBpZiAoZGlzdCA9PT0gMCkge1xuICAgICAgICBzZW5kX2NvZGUocywgbGMsIGx0cmVlKTsgLyogc2VuZCBhIGxpdGVyYWwgYnl0ZSAqL1xuICAgICAgICAvL1RyYWNlY3YoaXNncmFwaChsYyksIChzdGRlcnIsXCIgJyVjJyBcIiwgbGMpKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIC8qIEhlcmUsIGxjIGlzIHRoZSBtYXRjaCBsZW5ndGggLSBNSU5fTUFUQ0ggKi9cbiAgICAgICAgY29kZSA9IF9sZW5ndGhfY29kZVtsY107XG4gICAgICAgIHNlbmRfY29kZShzLCBjb2RlICsgTElURVJBTFMgKyAxLCBsdHJlZSk7IC8qIHNlbmQgdGhlIGxlbmd0aCBjb2RlICovXG4gICAgICAgIGV4dHJhID0gZXh0cmFfbGJpdHNbY29kZV07XG4gICAgICAgIGlmIChleHRyYSAhPT0gMCkge1xuICAgICAgICAgIGxjIC09IGJhc2VfbGVuZ3RoW2NvZGVdO1xuICAgICAgICAgIHNlbmRfYml0cyhzLCBsYywgZXh0cmEpOyAgICAgICAvKiBzZW5kIHRoZSBleHRyYSBsZW5ndGggYml0cyAqL1xuICAgICAgICB9XG4gICAgICAgIGRpc3QtLTsgLyogZGlzdCBpcyBub3cgdGhlIG1hdGNoIGRpc3RhbmNlIC0gMSAqL1xuICAgICAgICBjb2RlID0gZF9jb2RlKGRpc3QpO1xuICAgICAgICAvL0Fzc2VydCAoY29kZSA8IERfQ09ERVMsIFwiYmFkIGRfY29kZVwiKTtcblxuICAgICAgICBzZW5kX2NvZGUocywgY29kZSwgZHRyZWUpOyAgICAgICAvKiBzZW5kIHRoZSBkaXN0YW5jZSBjb2RlICovXG4gICAgICAgIGV4dHJhID0gZXh0cmFfZGJpdHNbY29kZV07XG4gICAgICAgIGlmIChleHRyYSAhPT0gMCkge1xuICAgICAgICAgIGRpc3QgLT0gYmFzZV9kaXN0W2NvZGVdO1xuICAgICAgICAgIHNlbmRfYml0cyhzLCBkaXN0LCBleHRyYSk7ICAgLyogc2VuZCB0aGUgZXh0cmEgZGlzdGFuY2UgYml0cyAqL1xuICAgICAgICB9XG4gICAgICB9IC8qIGxpdGVyYWwgb3IgbWF0Y2ggcGFpciA/ICovXG5cbiAgICAgIC8qIENoZWNrIHRoYXQgdGhlIG92ZXJsYXkgYmV0d2VlbiBwZW5kaW5nX2J1ZiBhbmQgZF9idWYrbF9idWYgaXMgb2s6ICovXG4gICAgICAvL0Fzc2VydCgodUludCkocy0+cGVuZGluZykgPCBzLT5saXRfYnVmc2l6ZSArIDIqbHgsXG4gICAgICAvLyAgICAgICBcInBlbmRpbmdCdWYgb3ZlcmZsb3dcIik7XG5cbiAgICB9IHdoaWxlIChseCA8IHMubGFzdF9saXQpO1xuICB9XG5cbiAgc2VuZF9jb2RlKHMsIEVORF9CTE9DSywgbHRyZWUpO1xufVxuXG5cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuICogQ29uc3RydWN0IG9uZSBIdWZmbWFuIHRyZWUgYW5kIGFzc2lnbnMgdGh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Y7ICAgICAgIC8qIGlucHV0IGJsb2NrICovXG4vL3VsZyBzdG9yZWRfbGVuOyAgIC8qIGxlbmd0aCBvZiBpbnB1dCBibG9jayAqL1xuLy9pbnQgbGFzdDsgICAgICAgICAvKiBvbmUgaWYgdGhpcyBpcyB0aGUgbGFzdCBibG9jayBmb3IgYSBmaWxlICovXG57XG4gIHNlbmRfYml0cyhzLCAoU1RPUkVEX0JMT0NLIDw8IDEpICsgKGxhc3QgPyAxIDogMCksIDMpOyAgICAvKiBzZW5kIGJsb2NrIHR5cGUgKi9cbiAgY29weV9ibG9jayhzLCBidWYsIHN0b3JlZF9sZW4sIHRydWUpOyAvKiB3aXRoIGhlYWRlciAqL1xufVxuXG5cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuICogU2VuZCBvbmUgZW1wdHkgc3RhdGljIGJsb2NrIHRvIGdpdmUgZW5vdWdoIGxvb2thaGVhZCBmb3IgaW5mbGF0ZS5cbiAqIFRoaXMgdGFrZXMgMTAgYml0cywgb2Ygd2hpY2ggNyBtYXkgcmVtYWluIGluIHRoZSBiaXQgYnVmZmVyLlxuICovXG5mdW5jdGlvbiBfdHJfYWxpZ24ocykge1xuICBzZW5kX2JpdHMocywgU1RBVElDX1RSRUVTIDw8IDEsIDMpO1xuICBzZW5kX2NvZGUocywgRU5EX0JMT0NLLCBzdGF0aWNfbHRyZWUpO1xuICBiaV9mbHVzaChzKTtcbn1cblxuXG4vKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbiAqIERldGVybWluZSB0aGUgYmVzdCBlbmNvZGluZyBmb3IgdGhlIGN1cnJlbnQgYmxvY2s6IGR5bmFtaWMgdHJlZXMsIHN0YXRpY1xuICogdHJlZXMgb3Igc3RvcmUsIGFuZCBvdXRwdXQgdGhlIGVuY29kZWQgYm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XRlckxpbWl0ID09PSBJbmZpbml0eSA/IHVuZGVmaW5lZCA6IG9wdGlvbnMucGFyYW1ldGVyTGltaXQ7XG4gICAgdmFyIHBhcnRzID0gY2xlYW5TdHIuc3BsaXQob3B0aW9ucy5kZWxpbWl0ZXIsIGxpbWl0KTtcbiAgICB2YXIgc2tpcEluZGV4ID0gLTE7IC8vIEtlZXAgdHJhY2sgb2Ygd2hlcmUgdGhlIHV0Zjggc2VudGluZWwgd2FzIGZvdW5kXG4gICAgdmFyIGk7XG5cbiAgICB2YXIgY2hhcnNldCA9IG9wdGlvbnMuY2hhcnNldDtcbiAgICBpZiAob3B0aW9ucy5jaGFyc2V0U2VudGluZWwpIHtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBhcnRzLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBpZiAocGFydHNbaV0uaW5kZXhPZigndXRmOD0nKSA9PT0gMCkge1xuICAgICAgICAgICAgICAgIGlmIChwYXJ0c1tpXSA9PT0gY2hhcnNldFNlbnRpbmVsKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoYXJzZXQgPSAndXRmLTgnO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocGFydHNbaV0gPT09IGlzb1NlbnRpbmVsKSB7XG4gICAgICAgICAgICAgICAgICAgIGNoYXJzZXQgPSAnaXNvLTg4NTktMSc7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHNraXBJbmRleCA9IGk7XG4gICAgICAgICAgICAgICAgaSA9IHBhcnRzLmxlbmd0aDsgLy8gVGhlIGVzbGludCBzZXR0aW5ncyBkbyBub3QgYWxsb3cgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmb3IgKGkgPSAwOyBpIDwgcGFydHMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgaWYgKGkgPT09IHNraXBJbmRleCkge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHBhcnQgPSBwYXJ0c1tpXTtcblxuICAgICAgICB2YXIgYnJhY2tldEVxdWFsc1BvcyA9IHBhcnQuaW5kZXhPZignXT0nKTtcbiAgICAgICAgdmFyIHBvcyA9IGJyYWNrZXRFcXVhbHNQb3MgPT09IC0xID8gcGFydC5pbmRleE9mKCc9JykgOiBicmFja2V0RXF1YWxzUG9zICsgMTtcblxuICAgICAgICB2YXIga2V5O1xuICAgICAgICB2YXIgdmFsO1xuICAgICAgICBpZiAocG9zID09PSAtMSkge1xuICAgICAgICAgICAga2V5ID0gb3B0aW9ucy5kZWNvZGVyKHBhcnQsIGRlZmF1bHRzLmRlY29kZXIsIGNoYXJzZXQsICdrZXknKTtcbiAgICAgICAgICAgIHZhbCA9IG9wdGlvbnMuc3RyaWN0TnVsbEhhbmRsaW5nID8gbnVsbCA6ICcnO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAga2V5ID0gb3B0aW9ucy5kZWNvZGVyKHBhcnQuc2xpY2UoMCwgcG9zKSwgZGVmYXVsdHMuZGVjb2RlciwgY2hhcnNldCwgJ2tleScpO1xuICAgICAgICAgICAgdmFsID0gdXRpbHMubWF5YmVNYXAoXG4gICAgICAgICAgICAgICAgcGFyc2VBcnJheVZhbHVlKHBhcnQuc2xpY2UocG9zICsgMSksIG9wdGlvbnMpLFxuICAgICAgICAgICAgICAgIGZ1bmN0aW9uIChlbmNvZGVkVmFsKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBvcHRpb25zLmRlY29kZXIoZW5jb2RlZFZhbCwgZGVmYXVsdHMuZGVjb2RlciwgY2hhcnNldCwgJ3ZhbHVlJyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh2YWwgJiYgb3B0aW9ucy5pbnRlcnByZXROdW1lcmljRW50aXRpZXMgJiYgY2hhcnNldCA9PT0gJ2lzby04ODU5LTEnKSB7XG4gICAgICAgICAgICB2YWwgPSBpbnRlcnByZXROdW1lcmljRW50aXRpZXMoU3RyaW5nKHZhbCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHBhcnQuaW5kZXhPZignW109JykgPiAtMSkge1xuICAgICAgICAgICAgdmFsID0gaXNBcnJheSh2YWwpID8gW3ZhbF0gOiB2YWw7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgZXhpc3RpbmcgPSBoYXMuY2FsbChvYmosIGtleSk7XG4gICAgICAgIGlmIChleGlzdGluZyAmJiBvcHRpb25zLmR1cGxpY2F0ZXMgPT09ICdjb21iaW5lJykge1xuICAgICAgICAgICAgb2JqW2tleV0gPSB1dGlscy5jb21iaW5lKG9ialtrZXldLCB2YWwpO1xuICAgICAgICB9IGVsc2UgaWYgKCFleGlzdGluZyB8fCBvcHRpb25zLmR1cGxpY2F0ZXMgPT09ICdsYXN0Jykge1xuICAgICAgICAgICAgb2JqW2tleV0gPSB2YWw7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZXR1cm4gb2JqO1xufTtcblxudmFyIHBhcnNlT2JqZWN0ID0gZnVuY3Rpb24gKGNoYWluLCB2YWwsIG9wdGlvbnMsIHZhbHVlc1BhcnNlZCkge1xuICAgIHZhciBsZWFmID0gdmFsdWVzUGFyc2VkID8gdmFsIDogcGFyc2VBcnJheVZhbHVlKHZhbCwgb3B0aW9ucyk7XG5cbiAgICBmb3IgKHZhciBpID0gY2hhaW4ubGVuZ3RoIC0gMTsgaSA+PSAwOyAtLWkpIHtcbiAgICAgICAgdmFyIG9iajtcbiAgICAgICAgdmFyIHJvb3QgPSBjaGFpbltpXTtcblxuICAgICAgICBpZiAocm9vdCA9PT0gJ1tdJyAmJiBvcHRpb25zLnBhcnNlQXJyYXlzKSB7XG4gICAgICAgICAgICBvYmogPSBvcHRpb25zLmFsbG93RW1wdHlBcnJheXMgJiYgKGxlYWYgPT09ICcnIHx8IChvcHRpb25zLnN0cmljdE51bGxIYW5kbGluZyAmJiBsZWFmID09PSBudWxsKSlcbiAgICAgICAgICAgICAgICA/IFtdXG4gICAgICAgICAgICAgICAgOiBbXS5jb25jYXQobGVhZik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBvYmogPSBvcHRpb25zLnBsYWluT2JqZWN0cyA/IHsgX19wcm90b19fOiBudWxsIH0gOiB7fTtcbiAgICAgICAgICAgIHZhciBjbGVhblJvb3QgPSByb290LmNoYXJBdCgwKSA9PT0gJ1snICYmIHJvb3QuY2hhckF0KHJvb3QubGVuZ3RoIC0gMSkgPT09ICddJyA/IHJvb3Quc2xpY2UoMSwgLTEpIDogcm9vdDtcbiAgICAgICAgICAgIHZhciBkZWNvZGVkUm9vdCA9IG9wdGlvbnMuZGVjb2RlRG90SW5LZXlzID8gY2xlYW5Sb290LnJlcGxhY2UoLyUyRS9nLCAnLicpIDogY2xlYW5Sb290O1xuICAgICAgICAgICAgdmFyIGluZGV4ID0gcGFyc2VJbnQoZGVjb2RlZFJvb3QsIDEwKTtcbiAgICAgICAgICAgIGlmICghb3B0aW9ucy5wYXJzZUFycmF5cyAmJiBkZWNvZGVkUm9vdCA9PT0gJycpIHtcbiAgICAgICAgICAgICAgICBvYmogPSB7IDA6IGxlYWYgfTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoXG4gICAgICAgICAgICAgICAgIWlzTmFOKGluZGV4KVxuICAgICAgICAgICAgICAgICYmIHJvb3QgIT09IGRlY29kZWRSb290XG4gICAgICAgICAgICAgICAgJiYgU3RyaW5nKGluZGV4KSA9PT0gZGVjb2RlZFJvb3RcbiAgICAgICAgICAgICAgICAmJiBpbmRleCA+PSAwXG4gICAgICAgICAgICAgICAgJiYgKG9wdGlvbnMucGFyc2VBcnJheXMgJiYgaW5kZXggPD0gb3B0aW9ucy5hcnJheUxpbWl0KVxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgb2JqID0gW107XG4gICAgICAgICAgICAgICAgb2JqW2luZGV4XSA9IGxlYWY7XG4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ID0gc2VyaWFsaXplRGF0ZShvYmopO1xuICAgIH0gZWxzZSBpZiAoZ2VuZXJhdGVBcnJheVByZWZpeCA9PT0gJ2NvbW1hJyAmJiBpc0FycmF5KG9iaikpIHtcbiAgICAgICAgb2JqID0gdXRpbHMubWF5YmVNYXAob2JqLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIERhdGUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gc2VyaWFsaXplRGF0ZSh2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIGlmIChvYmogPT09IG51bGwpIHtcbiAgICAgICAgaWYgKHN0cmljdE51bGxIYW5kbGluZykge1xuICAgICAgICAgICAgcmV0dXJuIGVuY29kZXIgJiYgIWVuY29kZVZhbHVlc09ubHkgPyBlbmNvZGVyKHByZWZpeCwgZGVmYXVsdHMuZW5jb2RlciwgY2hhcnNldCwgJ2tleScsIGZvcm1hdCkgOiBwcmVmaXg7XG4gICAgICAgIH1cblxuICAgICAgICBvYmogPSAnJztcbiAgICB9XG5cbiAgICBpZiAoaXNOb25OdWxsaXNoUHJpbWl0aXZlKG9iaikgfHwgdXRpbHMuaXNCdWZmZXIob2JqKSkge1xuICAgICAgICBpZiAoZW5jb2Rlcikge1xuICAgICAgICAgICAgdmFyIGtleVZhbHVlID0gZW5jb2RlVmFsdWVzT25seSA/IHByZWZpeCA6IGVuY29kZXIocHJlZml4LCBkZWZhdWx0cy5lbmNvZGVyLCBjaGFyc2V0LCAna2V5JywgZm9ybWF0KTtcbiAgICAgICAgICAgIHJldHVybiBbZm9ybWF0dGVyKGtleVZhbHVlKSArICc9JyArIGZvcm1hdHRlcihlbmNvZGVyKG9iaiwgZGVmYXVsdHMuZW5jb2RlciwgY2hhcnNldCwgJ3ZhbHVlJywgZm9ybWF0KSldO1xuICAgICAgICB9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Wwuc2V0KG9iamVjdCwgc3RlcCk7XG4gICAgICAgIHZhciB2YWx1ZVNpZGVDaGFubmVsID0gZ2V0U2lkZUNoYW5uZWwoKTtcbiAgICAgICAgdmFsdWVTaWRlQ2hhbm5lbC5zZXQoc2VudGluZWwsIHNpZGVDaGFubmVsKTtcbiAgICAgICAgcHVzaFRvQXJyYXkodmFsdWVzLCBzdHJpbmdpZnkoXG4gICAgICAgICAgICB2YWx1ZSxcbiAgICAgICAgICAgIGtleVByZWZpeCxcbiAgICAgICAgICAgIGdlbmVyYXRlQXJyYXlQcmVmaXgsXG4gICAgICAgICAgICBjb21tYVJvdW5kVHJpcCxcbiAgICAgICAgICAgIGFsbG93RW1wdHlBcnJheXMsXG4gICAgICAgICAgICBzdHJpY3ROdWxsSGFuZGxpbmcsXG4gICAgICAgICAgICBza2lwTnVsbHMsXG4gICAgICAgICAgICBlbmNvZGVEb3RJbktleXMsXG4gICAgICAgICAgICBnZW5lcmF0ZUFycmF5UHJlZml4ID09PSAnY29tbWEnICYmIGVuY29kZVZhbHVlc09ubHkgJiYgaXNBcnJheShvYmopID8gbnVsbCA6IGVuY29kZXIsXG4gICAgICAgICAgICBmaWx0ZXIsXG4gICAgICAgICAgICBzb3J0LFxuICAgICAgICAgICAgYWxsb3dEb3RzLFxuICAgICAgICAgICAgc2VyaWFsaXplRGF0ZSxcbiAgICAgICAgICAgIGZvcm1hdCxcbiAgICAgICAgICAgIGZvcm1hdHRlcixcbiAgICAgICAgICAgIGVuY29kZVZhbHVlc09ubHksXG4gICAgICAgICAgICBjaGFyc2V0LFxuICAgICAgICAgICAgdmFsdWVTaWRlQ2hhbm5lbFxuICAgICAgICApKTtcbiAgICB9XG5cbiAgICByZXR1cm4gdmFsdWVzO1xufTtcblxudmFyIG5vcm1hbGl6ZVN0cmluZ2lmeU9wdGlvbnMgPSBmdW5jdGlvbiBub3JtYWxpemVTdHJpbmdpZnlPcHRpb25zKG9wdHMpIHtcbiAgICBpZiAoIW9wdHMpIHt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ID0gZ2VuZXJhdGVBcnJheVByZWZpeCA9PT0gJ2NvbW1hJyAmJiBvcHRpb25zLmNvbW1hUm91bmRUcmlwO1xuXG4gICAgaWYgKCFvYmpLZXlzKSB7XG4gICAgICAgIG9iaktleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgIH1cblxuICAgIGlmIChvcHRpb25zLnNvcnQpIHtcbiAgICAgICAgb2JqS2V5cy5zb3J0KG9wdGlvbnMuc29ydCk7XG4gICAgfVxuXG4gICAgdmFyIHNpZGVDaGFubmVsID0gZ2V0U2lkZUNoYW5uZWwoKTtcbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IG9iaktleXMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgdmFyIGtleSA9IG9iaktleXNbaV07XG4gICAgICAgIHZhciB2YWx1ZSA9IG9ialtrZXldO1xuXG4gICAgICAgIGlmIChvcHRpb25zLnNraXBOdWxscyAmJiB2YWx1ZSA9PT0gbnVsbCkge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgcHVzaFRvQXJyYXkoa2V5cywgc3RyaW5naWZ5KFxuICAgICAgICAgICAgdmFsdWUsXG4gICAgICAgICAgICBrZXksXG4gICAgICAgICAgICBnZW5lcmF0ZUFycmF5UHJlZml4LFxuICAgICAgICAgICAgY29tbWFSb3VuZFRyaXAsXG4gICAgICAgICAgICBvcHRpb25zLmFsbG93RW1wdHlBcnJheXMsXG4gICAgICAgICAgICBvcHRpb25zLnN0cmljdE51bGxIYW5kbGluZyxcbiAgICAgICAgICAgIG9wdGlvbnMuc2tpcE51bGxzLFxuICAgICAgICAgICAgb3B0aW9ucy5lbmNvZGVEb3RJbktleXMsXG4gICAgICAgICAgICBvcHRpb25zLmVuY29kZSA/IG9wdGlvbnMuZW5jb2RlciA6IG51bGwsXG4gICAgICAgICAgICBvcHRpb25zLmZpbHRlcixcbiAgICAgICAgICAgIG9wdGlvbnMuc29ydCxcbiAgICAgICAgICAgIG9wdGlvb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IH1cblxuICAgICAgICByZXR1cm4gdGFyZ2V0O1xuICAgIH1cblxuICAgIGlmICghdGFyZ2V0IHx8IHR5cGVvZiB0YXJnZXQgIT09ICdvYmplY3QnKSB7XG4gICAgICAgIHJldHVybiBbdGFyZ2V0XS5jb25jYXQoc291cmNlKTtcbiAgICB9XG5cbiAgICB2YXIgbWVyZ2VUYXJnZXQgPSB0YXJnZXQ7XG4gICAgaWYgKGlzQXJyYXkodGFyZ2V0KSAmJiAhaXNBcnJheShzb3VyY2UpKSB7XG4gICAgICAgIG1lcmdlVGFyZ2V0ID0gYXJyYXlUb09iamVjdCh0YXJnZXQsIG9wdGlvbnMpO1xuICAgIH1cblxuICAgIGlmIChpc0FycmF5KHRhcmdldCkgJiYgaXNBcnJheShzb3VyY2UpKSB7XG4gICAgICAgIHNvdXJjZS5mb3JFYWNoKGZ1bmN0aW9uIChpdGVtLCBpKSB7XG4gICAgICAgICAgICBpZiAoaGFzLmNhbGwodGFyZ2V0LCBpKSkge1xuICAgICAgICAgICAgICAgIHZhciB0YXJnZXRJdGVtID0gdGFyZ2V0W2ldO1xuICAgICAgICAgICAgICAgIGlmICh0YXJnZXRJdGVtICYmIHR5cGVvZiB0YXJnZXRJdGVtID09PSAnb2JqZWN0JyAmJiBpdGVtICYmIHR5cGVvZiBpdGVtID09PSAnb2JqZWN0Jykge1xuICAgICAgICAgICAgICAgICAgICB0YXJnZXRbaV0gPSBtZXJnZSh0YXJnZXRJdGVtLCBpdGVtLCBvcHRpb25zKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0YXJnZXQucHVzaChpdGVtKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRhcmdldFtpXSA9IGl0ZW07XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gdGFyZ2V0O1xuICAgIH1cblxuICAgIHJldHVybiBPYmpl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gICAgIH0pO1xuICAgIH1cblxuICAgIHZhciBvdXQgPSAnJztcbiAgICBmb3IgKHZhciBqID0gMDsgaiA8IHN0cmluZy5sZW5ndGg7IGogKz0gbGltaXQpIHtcbiAgICAgICAgdmFyIHNlZ21lbnQgPSBzdHJpbmcubGVuZ3RoID49IGxpbWl0ID8gc3RyaW5nLnNsaWNlKGosIGogKyBsaW1pdCkgOiBzdHJpbmc7XG4gICAgICAgIHZhciBhcnIgPSBbXTtcblxuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNlZ21lbnQubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgICAgIHZhciBjID0gc2VnbWVudC5jaGFyQ29kZUF0KGkpO1xuICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICAgIGMgPT09IDB4MkQgLy8gLVxuICAgICAgICAgICAgICAgIHx8IGMgPT09IDB4MkUgLy8gLlxuICAgICAgICAgICAgICAgIHx8IGMgPT09IDB4NUYgLy8gX1xuICAgICAgICAgICAgICAgIHx8IGMgPT09IDB4N0UgLy8gflxuICAgICAgICAgICAgICAgIHx8IChjID49IDB4MzAgJiYgYyA8PSAweDM5KSAvLyAwLTlcbiAgICAgICAgICAgICAgICB8fCAoYyA+PSAweDQxICYmIGMgPD0gMHg1QSkgLy8gYS16XG4gICAgICAgICAgICAgICAgfHwgKGMgPj0gMHg2MSAmJiBjIDw9IDB4N0EpIC8vIEEtWlxuICAgICAgICAgICAgICAgIHx8IChmb3JtYXQgPT09IGZvcm1hdHMuUkZDMTczOCAmJiAoYyA9PT0gMHgyOCB8fCBjID09PSAweDI5KSkgLy8gKCApXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICBhcnJbYXJyLmxlbmd0aF0gPSBzZWdtZW50LmNoYXJBdChpKTtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGMgPCAweDgwKSB7XG4gICAgICAgICAgICAgICAgYXJyW2Fyci5sZW5ndGhdID0gaGV4VGFibGVbY107XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChjIDwgMHg4MDApIHtcbiAgICAgICAgICAgICAgICBhcnJbYXJyLmxlbmd0aF0gPSBoZXhUYWJsZVsweEMwIHwgKGMgPj4gNildXG4gICAgICAgICAgICAgICAgICAgICsgaGV4VGFibGVbMHg4MCB8IChjICYgMHgzRildO1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoYyA8IDB4RDgwMCB8fCBjID49IDB4RTAwMCkge1xuICAgICAgICAgICAgICAgIGFyclthcnIubGVuZ3RoXSA9IGhleFRhYmxlWzB4RTAgfCAoYyA+PiAxMildXG4gICAgICAgICAgICAgICAgICAgICsgaGV4VGFibGVbMHg4MCB8ICgoYyA+PiA2KSAmIDB4M0YpXVxuICAgICAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoYyAmIDB4M0YpXTtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaSArPSAxO1xuICAgICAgICAgICAgYyA9IDB4MTAwMDAgKyAoKChjICYgMHgzRkYpIDw8IDEwKSB8IChzZWdtZW50LmNoYXJDb2RlQXQoaSkgJiAweDNGRikpO1xuXG4gICAgICAgICAgICBhcnJbYXJyLmxlbmd0aF0gPSBoZXhUYWJsZVsweEYwIHwgKGMgPj4gMTgpXVxuICAgICAgICAgICAgICAgICsgaGV4VGFibGVbMHg4MCB8ICgoYyA+PiAxMikgJiAweDNGKV1cbiAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoKGMgPj4gNikgJiAweDNGKV1cbiAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoYyAmIDB4M0YpXTtcbiAgICAgICAgfVxuXG4gICAgICAgIG91dCArPSBhcnIuam9pbignJyk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GxldGUpIHtcbiAgICAgICAgdmFyIF9hO1xuICAgICAgICByZXR1cm4gaXNGdW5jdGlvbigoX2EgPSBuZXh0T3JPYnNlcnZlcikgPT09IG51bGwgfHwgX2EgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9hLm5leHQpXG4gICAgICAgICAgICA/IHRoaXMub2JzZXJ2ZShuZXh0T3JPYnNlcnZlcilcbiAgICAgICAgICAgIDogdGhpcy5kbyhuZXh0T3JPYnNlcnZlciwgZXJyb3IsIGNvbXBsZXRlKTtcbiAgICB9O1xuICAgIE5vdGlmaWNhdGlvbi5wcm90b3R5cGUudG9PYnNlcnZhYmxlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX2EgPSB0aGlzLCBraW5kID0gX2Eua2luZCwgdmFsdWUgPSBfYS52YWx1ZSwgZXJyb3IgPSBfYS5lcnJvcjtcbiAgICAgICAgdmFyIHJlc3VsdCA9IGtpbmQgPT09ICdOJ1xuICAgICAgICAgICAgP1xuICAgICAgICAgICAgICAgIG9mKHZhbHVlKVxuICAgICAgICAgICAgOlxuICAgICAgICAgICAgICAgIGtpbmQgPT09ICdFJ1xuICAgICAgICAgICAgICAgICAgICA/XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvd0Vycm9yKGZ1bmN0aW9uICgpIHsgcmV0dXJuIGVycm9yOyB9KVxuICAgICAgICAgICAgICAgICAgICA6XG4gICAgICAgICAgICAgICAgICAgICAgICBraW5kID09PSAnQydcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA/XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEVNUFRZXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwO1xuICAgICAgICBpZiAoIXJlc3VsdCkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihcIlVuZXhwZWN0ZWQgbm90aWZpY2F0aW9uIGtpbmQgXCIgKyBraW5kKTtc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ICAgICAgdmFyIHN1YnNjcmliZXIgPSBpc1N1YnNjcmliZXIob2JzZXJ2ZXJPck5leHQpID8gb2JzZXJ2ZXJPck5leHQgOiBuZXcgU2FmZVN1YnNjcmliZXIob2JzZXJ2ZXJPck5leHQsIGVycm9yLCBjb21wbGV0ZSk7XG4gICAgICAgIGVycm9yQ29udGV4dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgX2EgPSBfdGhpcywgb3BlcmF0b3IgPSBfYS5vcGVyYXRvciwgc291cmNlID0gX2Euc291cmNlO1xuICAgICAgICAgICAgc3Vic2NyaWJlci5hZGQob3BlcmF0b3JcbiAgICAgICAgICAgICAgICA/XG4gICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yLmNhbGwoc3Vic2NyaWJlciwgc291cmNlKVxuICAgICAgICAgICAgICAgIDogc291cmNlXG4gICAgICAgICAgICAgICAgICAgID9cbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLl9zdWJzY3JpYmUoc3Vic2NyaWJlcilcbiAgICAgICAgICAgICAgICAgICAgOlxuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuX3RyeVN1YnNjcmliZShzdWJzY3JpYmVyKSk7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gc3Vic2NyaWJlcjtcbiAgICB9O1xuICAgIE9ic2VydmFibGUucHJvdG90eXBlLl90cnlTdWJzY3JpYmUgPSBmdW5jdGlvbiAoc2luaykge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N1YnNjcmliZShzaW5rKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBzaW5rLmVycm9yKGVycik7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIE9ic2VydmFibGUucHJvdG90eXBlLmZvckVhY2ggPSBmdW5jdGlvbiAobmV4dCwgcHJvbWlzZUN0b3IpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgcHJvbWlzZUN0b3IgPSBnZXRQcm9taXNlQ3Rvcihwcm9taXNlQ3Rvcik7XG4gICAgICAgIHJldHVybiBuZXcgcHJvbWlzZUN0b3IoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICAgICAgdmFyIHN1YnNjcmlwdGlvbjtcbiAgICAgICAgICAgIHN1YnNjcmlwdGlvbiA9IF90aGlzLnN1YnNjcmliZShmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBuZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICByZWplY3QoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uID09PSBudWxsIHx8IHN1YnNjcmlwdGlvbiA9PT0gdm9pZCAwID8gdm9pZCAwIDogc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgcmVqZWN0LCByZXNvbHZlKTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZS5fc3Vic2NyaWJlID0gZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIF9hO1xuICAgICAgICByZXR1cm4gKF9hID0gdGhpcy5zb3VyY2UpID09PSBudWxsIHx8IF9hID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfYS5zdWJzY3JpYmUoc3Vic2NyaWJlcik7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZVtTeW1ib2xfb2JzZXJ2YWJsZV0gPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiB0aGlzO1xuICAgIH07XG4gICAgT2JzZXJ2YWJsZS5wcm90b3R5cGUucGlwZSA9IGZ1bm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YmplY3RVbnN1YnNjcmliZWRFcnJvcigpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS5uZXh0ID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIGVycm9yQ29udGV4dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgZV8xLCBfYTtcbiAgICAgICAgICAgIF90aGlzLl90aHJvd0lmQ2xvc2VkKCk7XG4gICAgICAgICAgICBpZiAoIV90aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgICAgIHZhciBjb3B5ID0gX3RoaXMub2JzZXJ2ZXJzLnNsaWNlKCk7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgY29weV8xID0gX192YWx1ZXMoY29weSksIGNvcHlfMV8xID0gY29weV8xLm5leHQoKTsgIWNvcHlfMV8xLmRvbmU7IGNvcHlfMV8xID0gY29weV8xLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG9ic2VydmVyID0gY29weV8xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvcHlfMV8xICYmICFjb3B5XzFfMS5kb25lICYmIChfYSA9IGNvcHlfMS5yZXR1cm4pKSBfYS5jYWxsKGNvcHlfMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzEpIHRocm93IGVfMS5lcnJvcjsgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS5lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgZXJyb3JDb250ZXh0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIF90aGlzLl90aHJvd0lmQ2xvc2VkKCk7XG4gICAgICAgICAgICBpZiAoIV90aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgICAgIF90aGlzLmhhc0Vycm9yID0gX3RoaXMuaXNTdG9wcGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBfdGhpcy50aHJvd25FcnJvciA9IGVycjtcbiAgICAgICAgICAgICAgICB2YXIgb2JzZXJ2ZXJzID0gX3RoaXMub2JzZXJ2ZXJzO1xuICAgICAgICAgICAgICAgIHdoaWxlIChvYnNlcnZlcnMubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVycy5zaGlmdCgpLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9O1xuICAgIFN1YmplY3QucHJvdG90eXBlLmNvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBlcnJvckNvbnRleHQoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgX3RoaXMuX3Rocm93SWZDbG9zZWQoKTtcbiAgICAgICAgICAgIGlmICghX3RoaXMuaXNTdG9wcGVkKSB7XG4gICAgICAgICAgICAgICAgX3RoaXMuaXNTdG9wcGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB2YXIgb2JzZXJ2ZXJzID0gX3RoaXMub2JzZXJ2ZXJzO1xuICAgICAgICAgICAgICAgIHdoaWxlI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gICAgICBpZiAoaXNTdWJzY3JpcHRpb24oZGVzdGluYXRpb24pKSB7XG4gICAgICAgICAgICAgICAgZGVzdGluYXRpb24uYWRkKF90aGlzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIF90aGlzLmRlc3RpbmF0aW9uID0gRU1QVFlfT0JTRVJWRVI7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIF90aGlzO1xuICAgIH1cbiAgICBTdWJzY3JpYmVyLmNyZWF0ZSA9IGZ1bmN0aW9uIChuZXh0LCBlcnJvciwgY29tcGxldGUpIHtcbiAgICAgICAgcmV0dXJuIG5ldyBTYWZlU3Vic2NyaWJlcihuZXh0LCBlcnJvciwgY29tcGxldGUpO1xuICAgIH07XG4gICAgU3Vic2NyaWJlci5wcm90b3R5cGUubmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICBpZiAodGhpcy5pc1N0b3BwZWQpIHtcbiAgICAgICAgICAgIGhhbmRsZVN0b3BwZWROb3RpZmljYXRpb24obmV4dE5vdGlmaWNhdGlvbih2YWx1ZSksIHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fbmV4dCh2YWx1ZSk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFN1YnNjcmliZXIucHJvdG90eXBlLmVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICBpZiAodGhpcy5pc1N0b3BwZWQpIHtcbiAgICAgICAgICAgIGhhbmRsZVN0b3BwZWROb3RpZmljYXRpb24oZXJyb3JOb3RpZmljYXRpb24oZXJyKSwgdGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmlzU3RvcHBlZCA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLl9lcnJvcihlcnIpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBTdWJzY3JpY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ciBfcGFyZW50YWdlID0gdGhpcy5fcGFyZW50YWdlO1xuICAgICAgICAgICAgaWYgKF9wYXJlbnRhZ2UpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wYXJlbnRhZ2UgPSBudWxsO1xuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KF9wYXJlbnRhZ2UpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBfcGFyZW50YWdlXzEgPSBfX3ZhbHVlcyhfcGFyZW50YWdlKSwgX3BhcmVudGFnZV8xXzEgPSBfcGFyZW50YWdlXzEubmV4dCgpOyAhX3BhcmVudGFnZV8xXzEuZG9uZTsgX3BhcmVudGFnZV8xXzEgPSBfcGFyZW50YWdlXzEubmV4dCgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBhcmVudF8xID0gX3BhcmVudGFnZV8xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50XzEucmVtb3ZlKHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNhdGNoIChlXzFfMSkgeyBlXzEgPSB7IGVycm9yOiBlXzFfMSB9OyB9XG4gICAgICAgICAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX3BhcmVudGFnZV8xXzEgJiYgIV9wYXJlbnRhZ2VfMV8xLmRvbmUgJiYgKF9hID0gX3BhcmVudGFnZV8xLnJldHVybikpIF9hLmNhbGwoX3BhcmVudGFnZV8xKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbmFsbHkgeyBpZiAoZV8xKSB0aHJvdyBlXzEuZXJyb3I7IH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgX3BhcmVudGFnZS5yZW1vdmUodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGluaXRpYWxUZWFyZG93biA9IHRoaXMuaW5pdGlhbFRlYXJkb3duO1xuICAgICAgICAgICAgaWYgKGlzRnVuY3Rpb24oaW5pdGlhbFRlYXJkb3duKSkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGluaXRpYWxUZWFyZG93bigpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlIGluc3RhbmNlb2YgVW5zdWJzY3JpcHRpb25FcnJvciA/IGUuZXJyb3JzIDogW2VdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBfdGVhcmRvd25zID0gdGhpcy5fdGVhcmRvd25zO1xuICAgICAgICAgICAgaWYgKF90ZWFyZG93bnMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90ZWFyZG93bnMgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIF90ZWFyZG93bnNfMSA9IF9fdmFsdWVzKF90ZWFyZG93bnMpLCBfdGVhcmRvd25zXzFfMSA9IF90ZWFyZG93bnNfMS5uZXh0KCk7ICFfdGVhcmRvd25zXzFfMS5kb25lOyBfdGVhcmRvd25zXzFfMSA9IF90ZWFyZG93bnNfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZWFyZG93bl8xID0gX3RlYXJkb3duc18xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4ZWNUZWFyZG93bih0ZWFyZG93bl8xKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMgIT09IG51bGwgJiYgZXJyb3JzICE9PSB2b2lkIDAgPyBlcnJvcnMgOiBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyIGluc3RhbmNlb2YgVW5zdWJzY3JpcHRpb25FcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBfX3NwcmVhZEFycmF5KF9fc3ByZWFkQXJyYXkoW10sIF9fcmVhZChlcnJvcnMpKSwgX19yZWFkKGVyci5lcnJvcnMpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlXzJfMSkgeyBlXzIgPSB7IGVycm9yOiBlXzJfMSB9OyB9XG4gICAgICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoX3RlYXJkb3duc18xXzEgJiYgIV90ZWFyZG93bnNfMV8xLmRvbmUgJiYgKF9iID0gX3RlYXJkb3duc18xLnJldHVybikpIF9iLmNhbGwoX3RlYXJkb3duc18xKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMikgdGhyb3cgZV8yLmVycm9yOyB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGVycm9ycykge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBVbnN1YnNjcmlwdGlvbkVycm9yKGVycm9ycyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFN1YnNjcmlwdGlvbi5wcm90b3R5cGUuYWRkID0gZnVuY3Rpb24gKHRlYXJkb3duKSB7XG4gICAgICAgIHZhciBfYTtcbiAgICAgICAgaWYgKHRlYXJkb3duICYmIHRlYXJkb3duICE9PSB0aGlzKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICBleGVjVGVhcmRvd24odGVhcmRvd24pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHRlYXJkb3duIGluc3RhbmNlb2YgU3Vic2NyaXB0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZWFyZG93bi5jbG9zZWQgfHwgdGVhcmRvd24uX2hhc1BhcmVudCh0aGlzKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHRlYXJkb3duLl9hZGRQYXJlbnQodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICh0aGlzLl90ZWFyZG93bnMgPSAoX2EgPSB0aGlzLl90ZWFyZG93bnMpICE9PSBudWxsICYmIF9hICE9PSB2b2lkIDAgPyBfYSA6IFtdKS5wdXNoKHRlYXJkb3duKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgU3Vic2NyaXB0aW9uLnByb3RvdHlwZS5faGFzUGFyZW50ID0gZnVuY3Rpb24gKHBhcmVudCkge1xuICAgICAgICB2YXIgX3Bh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bmZpZyA9IHtcbiAgICBvblVuaGFuZGxlZEVycm9yOiBudWxsLFxuICAgIG9uU3RvcHBlZE5vdGlmaWNhdGlvbjogbnVsbCxcbiAgICBQcm9taXNlOiB1bmRlZmluZWQsXG4gICAgdXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZzogZmFsc2UsXG4gICAgdXNlRGVwcmVjYXRlZE5leHRDb250ZXh0OiBmYWxzZSxcbn07XG4vLyMgc291cmNlTWFwcGluZ1VSTD1jb25maWcuanMubWFwIiwiaW1wb3J0IHsgRW1wdHlFcnJvciB9IGZyb20gJy4vdXRpbC9FbXB0eUVycm9yJztcbmltcG9ydCB7IFNhZmVTdWJzY3JpYmVyIH0gZnJvbSAnLi9TdWJzY3JpYmVyJztcbmV4cG9ydCBmdW5jdGlvbiBmaXJzdFZhbHVlRnJvbShzb3VyY2UsIGNvbmZpZykge1xuICAgIHZhciBoYXNDb25maWcgPSB0eXBlb2YgY29uZmlnID09PSAnb2JqZWN0JztcbiAgICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICB2YXIgc3Vic2NyaWJlciA9IG5ldyBTYWZlU3Vic2NyaWJlcih7XG4gICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICByZXNvbHZlKHZhbHVlKTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZXJyb3I6IHJlamVjdCxcbiAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaWYgKGhhc0NvbmZpZykge1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGNvbmZpZy5kZWZhdWx0VmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFbXB0eUVycm9yKCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0pO1xuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Zmlyc3RWYWx1ZUZyb20uanMubWFwIiwiaW1wb3J0IHsgRW1wdHlFcnJvciB9IGZyb20gJy4vdXRpbC9FbXB0eUVycm9yJztcbmV4cG9ydCBmdW5jdGlvbiBsYXN0VmFsdWVGcm9tKHNvdXJjZSwgY29uZmlnKSB7XG4gICAgdmFyIGhhc0NvbmZpZyA9IHR5cGVvZiBjb25maWcgPT09ICdvYmplY3QnO1xuICAgIHJldHVybiBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7XG4gICAgICAgIHZhciBfaGFzVmFsdWUgPSBmYWxzZTtcbiAgICAgICAgdmFyIF92YWx1ZTtcbiAgICAgICAgc291cmNlLnN1YnNjcmliZSh7XG4gICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICBfdmFsdWUgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICBfaGFzVmFsdWUgPSB0cnVlO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGVycm9yOiByZWplY3QsXG4gICAgICAgICAgICBjb21wbGV0ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGlmIChfaGFzVmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShfdmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIGlmIChoYXNDb25maWcpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShjb25maWcuZGVmYXVsdFZhbHVlKTtcbiAgICAgICAgICAgICA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2NyaWJlKCk7XG4gICAgfTtcbiAgICBDb25uZWN0YWJsZU9ic2VydmFibGUucHJvdG90eXBlLmNvbm5lY3QgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHZhciBjb25uZWN0aW9uID0gdGhpcy5fY29ubmVjdGlvbjtcbiAgICAgICAgaWYgKCFjb25uZWN0aW9uKSB7XG4gICAgICAgICAgICBjb25uZWN0aW9uID0gdGhpcy5fY29ubmVjdGlvbiA9IG5ldyBTdWJzY3JpcHRpb24oKTtcbiAgICAgICAgICAgIHZhciBzdWJqZWN0XzEgPSB0aGlzLmdldFN1YmplY3QoKTtcbiAgICAgICAgICAgIGNvbm5lY3Rpb24uYWRkKHRoaXMuc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YmplY3RfMSwgdW5kZWZpbmVkLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgX3RoaXMuX3RlYXJkb3duKCk7XG4gICAgICAgICAgICAgICAgc3ViamVjdF8xLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9LCBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgX3RoaXMuX3RlYXJkb3duKCk7XG4gICAgICAgICAgICAgICAgc3ViamVjdF8xLmVycm9yKGVycik7XG4gICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7IHJldHVybiBfdGhpcy5fdGVhcmRvd24oKTsgfSkpKTtcbiAgICAgICAgICAgIGlmIChjb25uZWN0aW9uLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2Nvbm5lY3Rpb24gPSBudWxsO1xuICAgICAgICAgICAgICAgIGNvbm5lY3Rpb24gPSBTdWJzY3JpcHRpb24uRU1QVFk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGNvbm5lY3Rpb247XG4gICAgfTtcbiAgICBDb25uZWN0Y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i4vb3BlcmF0b3JzL29ic2VydmVPbic7XG5pbXBvcnQgeyBBc3luY1N1YmplY3QgfSBmcm9tICcuLi9Bc3luY1N1YmplY3QnO1xuZXhwb3J0IGZ1bmN0aW9uIGJpbmRDYWxsYmFja0ludGVybmFscyhpc05vZGVTdHlsZSwgY2FsbGJhY2tGdW5jLCByZXN1bHRTZWxlY3Rvciwgc2NoZWR1bGVyKSB7XG4gICAgaWYgKHJlc3VsdFNlbGVjdG9yKSB7XG4gICAgICAgIGlmIChpc1NjaGVkdWxlcihyZXN1bHRTZWxlY3RvcikpIHtcbiAgICAgICAgICAgIHNjaGVkdWxlciA9IHJlc3VsdFNlbGVjdG9yO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgYXJncyA9IFtdO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGFyZ3NbX2ldID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGJpbmRDYWxsYmFja0ludGVybmFscyhpc05vZGVTdHlsZSwgY2FsbGJhY2tGdW5jLCBzY2hlZHVsZXIpXG4gICAgICAgICAgICAgICAgICAgIC5hcHBseSh0aGlzLCBhcmdzKVxuICAgICAgICAgICAgICAgICAgICAucGlwZShtYXBPbmVPck1hbnlBcmdzKHJlc3VsdFNlbGVjdG9yKSk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfVxuICAgIGlmIChzY2hlZHVsZXIpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBhcmdzID0gW107XG4gICAgICAgICAgICBmb3IgKHZhciBfaSA9IDA7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xuICAgICAgICAgICAgICAgIGFyZ3NbX2ldID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBiaW5kQ2FsbGJhY2tJbnRlcm5hbHMoaXNOb2RlU3R5bGUsIGNhbGxiYWNrRnVuYylcbiAgICAgICAgICAgICAgICAuYXBwbHkodGhpcywgYXJncylcbiAgICAgICAgICAgICAgICAucGlwZShzdWJzY3JpYmVPbihzY2hlZHVsZXIpLCBvYnNlcnZlT24oc2NoZWR1bGVyKSk7XG4gICAgICAgIH07XG4gICAgfVxuICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHZhciBhcmdzID0gW107XG4gICAgICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgICAgICBhcmdzW19pXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHN1YmplY3QgPSBuZXcgQXN5bmNTdWJqZWN0KCk7XG4gICAgICAgIHZhciB1bmluaXRpYWxpemVkID0gdHJ1ZTtcbiAgICAgICAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICB2YXIgc3VicyA9IHN1YmplY3Quc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgICAgICAgICAgaWYgKHVuaW5pdGlhbGl6ZWQpIHtcbiAgICAgICAgICAgICAgICB1bmluaXRpYWxpemVkID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgdmFyIGlzQXN5bmNfMSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHZhciBpc0NvbXBsZXRlXzEgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBjYWxsYmFja0Z1bmMuYXBwbHkoX3RoaXMsIF9fc3ByZWFkQXJyYXkoX19zcHJlYWRBcnJheShbXSwgX19yZWFkKGFyZ3MpKSwgW1xuICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0cyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzW19pXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNOb2RlU3R5bGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZXJyID0gcmVzdWx0cy5zaGlmdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJqZWN0LmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJqZWN0Lm5leHQoMSA8IHJlc3VsdHMubGVuZ3RoID8gcmVzdWx0cyA6IHJlc3VsdHNbMF0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wbGV0ZV8xID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0FzeW5jXzEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJqZWN0LmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgXSkpO1xuICAgICAgICAgICAgICAgIGlmIChpc0NvbXBsZXRlXzEpIHt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gICAgICAgICAgICAgICAgICAgICAgICByZW1haW5pbmdGaXJzdFZhbHVlcy0tO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZW1haW5pbmdGaXJzdFZhbHVlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh2YWx1ZVRyYW5zZm9ybSh2YWx1ZXMuc2xpY2UoKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIS0tYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfSwgc3Vic2NyaWJlcik7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIF9sb29wXzEoaSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIHN1YnNjcmliZXIpO1xuICAgIH07XG59XG5mdW5jdGlvbiBtYXliZVNjaGVkdWxlKHNjaGVkdWxlciwgZXhlY3V0ZSwgc3Vic2NyaXB0aW9uKSB7XG4gICAgaWYgKHNjaGVkdWxlcikge1xuICAgICAgICBzdWJzY3JpcHRpb24uYWRkKHNjaGVkdWxlci5zY2hlZHVsZShleGVjdXRlKSk7XG4gICAgfVxuICAgIGVsc2Uge1xuICAgICAgICBleGVjdXRlKCk7XG4gICAgfVxufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Y29tYmluZUxhdGVzdC5qcy5tYXAiLCJpbXBvcnQgeyBjb25jYXRBbGwgfSBmcm9tICcuLi9vcGVyYXRvcnMvY29uY2F0Q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lc3VsdCA9IG5ldyBPYnNlcnZhYmxlKGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBsZW5ndGggPSBzb3VyY2VzLmxlbmd0aDtcbiAgICAgICAgaWYgKCFsZW5ndGgpIHtcbiAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgdmFsdWVzID0gbmV3IEFycmF5KGxlbmd0aCk7XG4gICAgICAgIHZhciByZW1haW5pbmdDb21wbGV0aW9ucyA9IGxlbmd0aDtcbiAgICAgICAgdmFyIHJlbWFpbmluZ0VtaXNzaW9ucyA9IGxlbmd0aDtcbiAgICAgICAgdmFyIF9sb29wXzEgPSBmdW5jdGlvbiAoc291cmNlSW5kZXgpIHtcbiAgICAgICAgICAgIHZhciBoYXNWYWx1ZSA9IGZhbHNlO1xuICAgICAgICAgICAgaW5uZXJGcm9tKHNvdXJjZXNbc291cmNlSW5kZXhdKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICBpZiAoIWhhc1ZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIGhhc1ZhbHVlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgcmVtYWluaW5nRW1pc3Npb25zLS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhbHVlc1tzb3VyY2VJbmRleF0gPSB2YWx1ZTtcbiAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpZiAoIS0tcmVtYWluaW5nQ29tcGxldGlvbnMgfHwgIWhhc1ZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcmVtYWluaW5nRW1pc3Npb25zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3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AgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzJdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIF9iLmxhYmVsID0gMztcbiAgICAgICAgICAgICAgICBjYXNlIDM6IHJldHVybiBbMywgMV07XG4gICAgICAgICAgICAgICAgY2FzZSA0OiByZXR1cm4gWzMsIDExXTtcbiAgICAgICAgICAgICAgICBjYXNlIDU6XG4gICAgICAgICAgICAgICAgICAgIGVfMl8xID0gX2Iuc2VudCgpO1xuICAgICAgICAgICAgICAgICAgICBlXzIgPSB7IGVycm9yOiBlXzJfMSB9O1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzMsIDExXTtcbiAgICAgICAgICAgICAgICBjYXNlIDY6XG4gICAgICAgICAgICAgICAgICAgIF9iLnRyeXMucHVzaChbNiwgLCA5LCAxMF0pO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIShhc3luY0l0ZXJhYmxlXzFfMSAmJiAhYXN5bmNJdGVyYWJsZV8xXzEuZG9uZSAmJiAoX2EgPSBhc3luY0l0ZXJhYmxlXzEucmV0dXJuKSkpIHJldHVybiBbMywgOF07XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgX2EuY2FsbChhc3luY0l0ZXJhYmxlXzEpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDc6XG4gICAgICAgICAgICAgICAgICAgIF9iLnNlbnQoKTtcbiAgICAgICAgICAgICAgICAgICAgX2IubGFiZWwgPSA4O1xuICAgICAgICAgICAgICAgIGNhc2UgODogcmV0dXJuIFszLCAxMF07XG4gICAgICAgICAgICAgICAgY2FzZSA5OlxuICAgICAgICAgICAgICAgICAgICBpZiAoZV8yKSB0aHJvdyBlXzIuZXJyb3I7XG4gICAgICAgICAgICAgICAgICAgIHJldHV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RpdHkgOiBfYiwgc2NoZWR1bGVyID0gX2Euc2NoZWR1bGVyKTtcbiAgICB9XG4gICAgZWxzZSB7XG4gICAgICAgIGluaXRpYWxTdGF0ZSA9IGluaXRpYWxTdGF0ZU9yT3B0aW9ucztcbiAgICAgICAgaWYgKCFyZXN1bHRTZWxlY3Rvck9yU2NoZWR1bGVyIHx8IGlzU2NoZWR1bGVyKHJlc3VsdFNlbGVjdG9yT3JTY2hlZHVsZXIpKSB7XG4gICAgICAgICAgICByZXN1bHRTZWxlY3RvciA9IGlkZW50aXR5O1xuICAgICAgICAgICAgc2NoZWR1bGVyID0gcmVzdWx0U2VsZWN0b3JPclNjaGVkdWxlcjtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHJlc3VsdFNlbGVjdG9yID0gcmVzdWx0U2VsZWN0b3JPclNjaGVkdWxlcjtcbiAgICAgICAgfVxuICAgIH1cbiAgICBmdW5jdGlvbiBnZW4oKSB7XG4gICAgICAgIHZhciBzdGF0ZTtcbiAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIGZ1bmN0aW9uIChfYSkge1xuICAgICAgICAgICAgc3dpdGNoIChfYS5sYWJlbCkge1xuICAgICAgICAgICAgICAgIGNhc2UgMDpcbiAgICAgICAgICAgICAgICAgICAgc3RhdGUgPSBpbml0aWFsU3RhdGU7XG4gICAgICAgICAgICAgICAgICAgIF9hLmxhYmVsID0gMTtcbiAgICAgICAgICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICAgICAgICAgIGlmICghKCFjb25kaXRpb24gfHwgY29uZGl0aW9uKHN0YXRlKSkpIHJldHVybiBbMywgNF07XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgcmVzdWx0U2VsZWN0b3Ioc3RhdGUpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDI6XG4gICAgICAgICAgICAgICAgICAgIF9hLnNlbnQoKTtcbiAgICAgICAgICAgICAgICAgICAgX2EubGF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GlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICBpZiAoc3Vic2NyaXB0aW9ucykge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBzID0gMDsgcyA8IHN1YnNjcmlwdGlvbnMubGVuZ3RoOyBzKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMgIT09IGkgJiYgc3Vic2NyaXB0aW9uc1tzXS51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMgPSBudWxsO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgfSkpKTtcbiAgICAgICAgfTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IHN1YnNjcmlwdGlvbnMgJiYgIXN1YnNjcmliZXIuY2xvc2VkICYmIGkgPCBzb3VyY2VzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBfbG9vcF8xKGkpO1xuICAgICAgICB9XG4gICAgfTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXJhY2UuanMubWFwIiwiaW1wb3J0IHsgT2JzZXJ2YWJsZSB9IGZyb20gJy4uL09ic2VydmFibGUnO1xuaW1wb3J0IHsgRU1QVFkgfSBmcm9tICcuL2VtcHR5JztcbmV4cG9ydCBmdW5jdGlvbiByYW5nZShzdGFydCwgY291bnQsIHNjaGVkdWxlcikge1xuICAgIGlmIChjb3VudCA9PSBudWxsKSB7XG4gICAgICAgIGNvdW50ID0gc3RhcnQ7XG4gICAgICAgIHN0YXJ0ID0gMDtcbiAgICB9XG4gICAgaWYgKGNvdW50IDw9IDApIHtcbiAgICAgICAgcmV0dXJuIEVNUFRZO1xuICAgIH1cbiAgICB2YXIgZW5kID0gY291bnQgKyBzdGFydDtcbiAgICByZXR1cm4gbmV3IE9ic2VydmFibGUoc2NoZWR1bGVyXG4gICAgICAgID9cbiAgICAgICAgICAgIGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgdmFyIG4gPSBzdGFydDtcbiAgICAgICAgICAgICAgICByZXR1cm4gc2NoZWR1bGVyLnNjaGVkdWxlKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG4gPCBlbmQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChuKyspO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2hlZHVsZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIDpcbiAgICAgICAgICAgIGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgdmFyIG4gPSBzdGFydDtcbiAgICAgICAgICAgICAgICB3aGlsZSAobiA8IGVuZCAmJiAhc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KG4rKyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9cmFuZ2UuanMubWFwIiwiaW1wb3J0IHsgT2JzZXJ2YWJsZSB9IGZyb20gJy4uL09ic2VydmFibGUnO1xuaW1wb3J0IHsgaXNGdW5jdGlvbiB9IGZyb20gJy4uL3V0aWwvaXNGdW5jdGlvbic7XG5leHBvcnQgZnVuY3Rpb24gdGhyb3dFcnJvcihlcnJvck9yRXJyb3JGYWN0b3J5LCBzY2hlZHVsZXIpIHt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XJ2YWxPclNjaGVkdWxlciAhPSBudWxsKSB7XG4gICAgICAgIGlmIChpc1NjaGVkdWxlcihpbnRlcnZhbE9yU2NoZWR1bGVyKSkge1xuICAgICAgICAgICAgc2NoZWR1bGVyID0gaW50ZXJ2YWxPclNjaGVkdWxlcjtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGludGVydmFsRHVyYXRpb24gPSBpbnRlcnZhbE9yU2NoZWR1bGVyO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJldHVybiBuZXcgT2JzZXJ2YWJsZShmdW5jdGlvbiAoc3Vic2NyaWJlcikge1xuICAgICAgICB2YXIgZHVlID0gaXNWYWxpZERhdGUoZHVlVGltZSkgPyArZHVlVGltZSAtIHNjaGVkdWxlci5ub3coKSA6IGR1ZVRpbWU7XG4gICAgICAgIGlmIChkdWUgPCAwKSB7XG4gICAgICAgICAgICBkdWUgPSAwO1xuICAgICAgICB9XG4gICAgICAgIHZhciBuID0gMDtcbiAgICAgICAgcmV0dXJuIHNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoIXN1YnNjcmliZXIuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KG4rKyk7XG4gICAgICAgICAgICAgICAgaWYgKDAgPD0gaW50ZXJ2YWxEdXJhdGlvbikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnNjaGVkdWxlKHVuZGVmaW5lZCwgaW50ZXJ2YWxEdXJhdGlvbik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9LCBkdWUpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9dGltZXIuanMubWFwIiwiaW1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kge1xuICAgICAgICAgICAgICAgICAgICBidWZmZXJzW3NvdXJjZUluZGV4XS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJ1ZmZlcnMuZXZlcnkoZnVuY3Rpb24gKGJ1ZmZlcikgeyByZXR1cm4gYnVmZmVyLmxlbmd0aDsgfSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBidWZmZXJzLm1hcChmdW5jdGlvbiAoYnVmZmVyKSB7IHJldHVybiBidWZmZXIuc2hpZnQoKTsgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQocmVzdWx0U2VsZWN0b3IgPyByZXN1bHRTZWxlY3Rvci5hcHBseSh2b2lkIDAsIF9fc3ByZWFkQXJyYXkoW10sIF9fcmVhZChyZXN1bHQpKSkgOiByZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJ1ZmZlcnMuc29tZShmdW5jdGlvbiAoYnVmZmVyLCBpKSB7IHJldHVybiAhYnVmZmVyLmxlbmd0aCAmJiBjb21wbGV0ZWRbaV07IH0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZWRbc291cmNlSW5kZXhdID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgIWJ1ZmZlcnNbc291cmNlSW5kZXhdLmxlbmd0aCAmJiBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGZvciAodmFyIHNvdXJjZUluZGV4ID0gMDsgIXN1YnNjcmliZXIuY2xvc2VkICYmIHNvdXJjZUluZGV4IDwgc291cmNlcy5sZW5ndGg7IHNvdXJjZUluZGV4KyspIHtcbiAgICAgICAgICAgICAgICBfbG9vcF8xKHNvdXJjZUluZGV4KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgYnVmZmVycyA9IGNvbXBsZXRlZCA9IG51bGw7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9KVxuICAgICAgICA6IEVNUFRZO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9emlwLmpzLm1hcCIsImltcG9ydCB7IF9fZXh0ZW5kcyB9IGZyb20gXCJ0c2xpYlwiO1xuaW1wb3J0IHsgU3Vic2NyaWJlciB9IGZyb20gJy4uL1N1YnNjcmliZXInO1xudmFyIE9wZXJhdG9yU3Vic2NyaWJlciA9IChmdW5jdGlvbiAoX3N1cGVyKSB7XG4gICAgX19leHRlbmRzKE9wZXJhdG9yU3Vic2NyaWJlciwgX3N1cGVyKTtcbiAgICBmdW5jdGlvbiBPcGVyYXRvclN1YnNjcmliZXIoZGVzdGluYXRpb24sIG9uTmV4dCwgb25Db21wbGV0ZSwgb25FcnJvciwgb25GaW5hbGl6ZSkge1xuICAgICAgICB2YXIgX3RoaXMgPSBfc3VwZXIuY2FsbCh0aGlzLCBkZXN0aW5hdGlvbikgfHwgdGhpcztcbiAgICAgICAgX3RoaXMub25GaW5hbGl6ZSA9IG9uRmluYWxpemU7XG4gICAgICAgIF90aGlzLl9uZXh0ID0gb25OZXh0XG4gICAgICAgICAgICA/IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG9uTmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICA6IF9zdXBlci5wcm90b3R5cGUuX25leHQ7XG4gICAgICAgIF90aGlzLl9lcnJvciA9IG9uRXJyb3JcbiAgICAgICAgICAgID8gZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG9uRXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICBkZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIDogX3N1cGVyLnByb3RvdHlwZS5fZXJyb3I7XG4gICAgICAgIF90aGlzLl9jb21wbGV0ZSA9IG9uQ29tcGxldGVcbiAgICAgICAgICAgID8gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG9uQ29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICBkZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIDogX3N1cGVyLnByb3RvdHlwZS5fY29tcGxldGU7XG4gICAgICAgIHJldHVybiBfdGhpcztcbiAgICB9XG4gICAgT3BlcmF0b3JTdWJzY3JpYmVyLnByb3RvdHlwZS51bnN1YnNj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UpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoYnVmZmVyU2l6ZSA8PSBidWZmZXIubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0b0VtaXQgPSB0b0VtaXQgIT09IG51bGwgJiYgdG9FbWl0ICE9PSB2b2lkIDAgPyB0b0VtaXQgOiBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRvRW1pdC5wdXNoKGJ1ZmZlcik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJ1ZmZlcnNfMV8xICYmICFidWZmZXJzXzFfMS5kb25lICYmIChfYSA9IGJ1ZmZlcnNfMS5yZXR1cm4pKSBfYS5jYWxsKGJ1ZmZlcnNfMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkgeyBpZiAoZV8xKSB0aHJvdyBlXzEuZXJyb3I7IH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0b0VtaXQpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciB0b0VtaXRfMSA9IF9fdmFsdWVzKHRvRW1pdCksIHRvRW1pdF8xXzEgPSB0b0VtaXRfMS5uZXh0KCk7ICF0b0VtaXRfMV8xLmRvbmU7IHRvRW1pdF8xXzEgPSB0b0VtaXRfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSB0b0VtaXRfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgYXJyUmVtb3ZlKGJ1ZmZlcnMsIGJ1ZmZlcik7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQoYnVmZmVyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZV8yXzEpIHsgZV8yID0geyBlcnJvcjogZV8yXzEgfTsgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRvRW1pdF8xXzEgJiYgIXRvRW1pdF8xXzEuZG9uZSAmJiAoX2IgPSB0b0VtaXRfMS5yZXR1cm4pKSBfYi5jYWxsKHRvRW1pdF8xKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMikgdGhyb3cgZV8yLmVycm9yOyB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgZV8zLCBfYTtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgYnVmZmVyc18yID0gX192YWx1ZXMoYnVmZmVycyksIGJ1ZmZlcnNfMl8xID0gYnVmZmVyc18yLm5leHQoKTsgIWJ1ZmZlcnNfMl8xLmRvbmU7IGJ1ZmZlcnNfMl8xID0gYnVmZmVyc18yLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgYnVmZmVyID0gYnVmZmVyc18yXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChidWZmZXIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlXzNfMSkgeyBlXzMgPSB7IGVycm9yOiBlXzNfMSB9OyB9XG4gICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAg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Rpb24oKTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChzdWJzKTtcbiAgICAgICAgICAgICAgICB2YXIgYnVmZmVyID0gW107XG4gICAgICAgICAgICAgICAgdmFyIHJlY29yZF8xID0ge1xuICAgICAgICAgICAgICAgICAgICBidWZmZXI6IGJ1ZmZlcixcbiAgICAgICAgICAgICAgICAgICAgc3Viczogc3VicyxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGJ1ZmZlclJlY29yZHMucHVzaChyZWNvcmRfMSk7XG4gICAgICAgICAgICAgICAgc3Vicy5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGZ1bmN0aW9uICgpIHsgcmV0dXJuIGVtaXQocmVjb3JkXzEpOyB9LCBidWZmZXJUaW1lU3BhbikpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICBidWZmZXJDcmVhdGlvbkludGVydmFsICE9PSBudWxsICYmIGJ1ZmZlckNyZWF0aW9uSW50ZXJ2YWwgPj0gMFxuICAgICAgICAgICAgP1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuYWRkKHNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0QnVmZmVyKCk7XG4gICAgICAgICAgICAgICAgICAgICF0aGlzLmNsb3NlZCAmJiBzdWJzY3JpYmVyLmFkZCh0aGlzLnNjaGVkdWxlKG51bGwsIGJ1ZmZlckNyZWF0aW9uSW50ZXJ2YWwpKTtcbiAgICAgICAgICAgICAgICB9LCBidWZmZXJDcmVhdGlvbkludGVydmFsKSlcbiAgICAgICAgICAgIDogKHJlc3RhcnRPbkVtaXQgPSB0cnVlKTtcbiAgICAgICAgc3RhcnRCdWZmZXIoKTtcbiAgICAgICAgdmFyIGJ1ZmZlclRpbWVTdWJzY3JpYmVyID0gbmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHZhciBlXzEsIF9hO1xuICAgICAgICAgICAgdmFyIHJlY29yZHNDb3B5ID0gYnVmZmVyUmVjb3Jkcy5zbGljZSgpO1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciByZWNvcmRzQ29weV8xID0gX192YWx1ZXMocmVjb3Jkc0NvcHkpLCByZWNvcmRzQ29weV8xXzEgPSByZWNvcmRzQ29weV8xLm5leHQoKTsgIXJlY29yZHNDb3B5XzFfMS5kb25lOyByZWNvcmRzQ29weV8xXzEgPSByZWNvcmRzQ29weV8xLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgcmVjb3JkID0gcmVjb3Jkc0NvcHlfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICB2YXIgYnVmZmVyID0gcmVjb3JkLmJ1ZmZlcjtcbiAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBtYXhCdWZmZXJTaXplIDw9IGJ1ZmZlci5sZW5ndGggJiYgZW1pdChyZWNvcmQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlXzFfMSkgeyBlXzEgPSB7IGVycm9yOiBlXzFfMSB9OyB9XG4gICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBpZiAocmVjb3Jkc0NvcHlfMV8xICYmICFyZWNvcmRzQ29weV8xXzEuZG9uZSAmJiAoX2EgPSByZWNvcmRzQ29weV8xLnJldHVybikpIF9hLmNhbGwocmVjb3Jkc0NvcHlfMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkgeyBpZiAoZV8xKSB0aHJvdyBlXzEuZXJyb3I7IH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZnV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gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KGdyb3VwZWQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZHVyYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkdXJhdGlvblN1YnNjcmliZXJfMSA9IG5ldyBPcGVyYXRvclN1YnNjcmliZXIoZ3JvdXBfMSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwXzEuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkdXJhdGlvblN1YnNjcmliZXJfMSA9PT0gbnVsbCB8fCBkdXJhdGlvblN1YnNjcmliZXJfMSA9PT0gdm9pZCAwID8gdm9pZCAwIDogZHVyYXRpb25TdWJzY3JpYmVyXzEudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHVuZGVmaW5lZCwgdW5kZWZpbmVkLCBmdW5jdGlvbiAoKSB7IHJldHVybiBncm91cHMuZGVsZXRlKGtleV8xKTsgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBncm91cEJ5U291cmNlU3Vic2NyaWJlci5hZGQoaW5uZXJGcm9tKGR1cmF0aW9uKGdyb3VwZWQpKS5zdWJzY3JpYmUoZHVyYXRpb25TdWJzY3JpYmVyXzEpKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBncm91cF8xLm5leHQoZWxlbWVudCA/IGVsZW1lbnQodmFsdWUpIDogdmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgIGhhbmRsZUVycm9yKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIGZ1bmN0aW9uICgpIHsgcmV0dXJuIG5vdGlmeShmdW5jdGlvbiAoY29uc3VtZXIpIHsgcmV0dXJuIGNvbnN1bWVyLmNvbXBsZX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RpdmUgPCBjb25jdXJyZW50ID8gZG9Jbm5lclN1Yih2YWx1ZSkgOiBidWZmZXIucHVzaCh2YWx1ZSkpOyB9O1xuICAgIHZhciBkb0lubmVyU3ViID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgIGV4cGFuZCAmJiBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICBhY3RpdmUrKztcbiAgICAgICAgdmFyIGlubmVyQ29tcGxldGUgPSBmYWxzZTtcbiAgICAgICAgaW5uZXJGcm9tKHByb2plY3QodmFsdWUsIGluZGV4KyspKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAoaW5uZXJWYWx1ZSkge1xuICAgICAgICAgICAgb25CZWZvcmVOZXh0ID09PSBudWxsIHx8IG9uQmVmb3JlTmV4dCA9PT0gdm9pZCAwID8gdm9pZCAwIDogb25CZWZvcmVOZXh0KGlubmVyVmFsdWUpO1xuICAgICAgICAgICAgaWYgKGV4cGFuZCkge1xuICAgICAgICAgICAgICAgIG91dGVyTmV4dChpbm5lclZhbHVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChpbm5lclZhbHVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaW5uZXJDb21wbGV0ZSA9IHRydWU7XG4gICAgICAgIH0sIHVuZGVmaW5lZCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKGlubmVyQ29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBhY3RpdmUtLTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIF9sb29wXzEgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgYnVmZmVyZWRWYWx1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ICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlTmV4dCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclN1YiA9IG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgdW5kZWZpbmVkLCBub29wLCBub29wKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5hZGQobmV4dFNvdXJjZS5zdWJzY3JpYmUoaW5uZXJTdWIpKTtcbiAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWIuYWRkKHN1YnNjcmliZU5leHQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgc3Vic2NyaWJlTmV4dCgpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9b25FcnJvclJlc3VtZU5leHQuanMubWFwIiwiaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlmdCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1YnNjcmliZXIgfSBmcm9tICcuL09wZXJhdG9yU3Vic2NyaWJlcic7XG5leHBvcnQgZnVuY3Rpb24gcGFpcndpc2UoKSB7XG4gICAgcmV0dXJuIG9wZXJhdGUoZnVuY3Rpb24gKHNvdXJjZSwgc3Vic2NyaWJlcikge1xuICAgICAgICB2YXIgcHJldjtcbiAgICAgICAgdmFyIGhhc1ByZXYgPSBmYWxzZTtcbiAgICAgICAgc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1Yn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ZSwgc3Vic2NyaWJlcikge1xuICAgICAgICAgICAgdmFyIHNvRmFyID0gMDtcbiAgICAgICAgICAgIHZhciBpbm5lclN1YjtcbiAgICAgICAgICAgIHZhciBzdWJzY3JpYmVGb3JSZXBlYXQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN5bmNVbnN1YiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGlubmVyU3ViID0gc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIHVuZGVmaW5lZCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoKytzb0ZhciA8IGNvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJTdWIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyU3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVGb3JSZXBlYXQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN5bmNVbnN1YiA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgaWYgKHN5bmNVbnN1Yikge1xuICAgICAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICBpbm5lclN1YiA9IG51b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tcGxldGlvbnMkKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbm5lclN1Yikge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmVwZWF0V2hlbigpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3luY1Jlc3ViID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgaXNOb3RpZmllckNvbXBsZXRlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgY2hlY2tDb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBjb21wbGV0aW9ucyQ7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBzdWJzY3JpYmVGb3JSZXBlYXRXaGVuID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaXNNYWluQ29tcGxldGUgPSBmYWxzZTtcbiAgICAgICAgICAgIGlubmVyU3ViID0gc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIHVuZGVmaW5lZCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGlzTWFpbkNvbXBsZXRlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAhY2hlY2tDb21wbGV0ZSgpICYmIGdldENvbXBsZXRpb25TdWJqZWN0KCkubmV4dCgpO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgaWYgKHN5bmNSZXN1Yikge1xuICAgICAgICAgICAgICAgIGlubmVyU3ViLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgaW5uZXJTdWIgPSBudWxsO1xuICAgICAgICAgICAgICAgIHN5bmNSZXN1YiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZUZvclJlcGVhdFdoZW4oKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgc3Vic2NyaWJlRm9yUmVwZWF0V2hlbigpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9cmVwZWF0V2hlbi5qcy5tYXAiLCJpbXBvcnQgeyBvcGVyYXRlIH0gZnJvbSAnLi4vdXRpbC9saWZ0JztcbmltcG9ydCB7IE9wZXJhdG9yU3Vic2NyaWJlciB9IGZyb20gJy4vT3BlcmF0b3JTdWJzY3JpYmVyJztcbmltcG9ydCB7IGlkZW50aXR5IH0gZnJvbSAnLi4vdXRpbC9pZGVudGl0eSc7XG5leHBvcnQgZnVuY3Rpb24gcmV0cnkoY29uZmlnT3JDb3VudCkge1xuICAgIGlmIChjb25maWdPckNvdW50ID09PSB2b2lkIDApIHsgY29uZmlnT3JDb3VudCA9IEluZmluaXR5OyB9XG4gICAgdmFyIGNvbmZpZztcbiAgICBpZiAoY29uZmlnT3JDb3VudCAmJiB0eXBlb2YgY29uZmlnT3JDb3VudCA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgY29uZmlnID0gY29uZmlnT3JDb3VudDtcbiAgICB9XG4gICAgZWxzZSB7XG4gICAgICAgIGNvbmZpZyA9IHtcbiAgICAgICAgICAgIGNvdW50OiBjb25maWdPckNvdW50LFxuICAgICAgICB9O1xuICAgIH1cbiAgICB2YXIgY291bnQgPSBjb25maWcuY291bnQsIF9hID0gY29uZmlnLnJlc2V0T25TdWNjZXNzLCByZXNldE9uU3VjY2VzcyA9IF9hID09PSB2b2lkIDAgPyBmYWxzZSA6IF9hO1xuICAgIHJldHVybiBjb3VudCA8PSAwXG4gICAgICAgID8gaWRlbnRpdHlcbiAgICAgICAgOiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgICAgIHZhciBzb0ZhciA9IDA7XG4gICAgICAgICAgICB2YXIgaW5uZXJTdWI7XG4gICAgICAgICAgICB2YXIgc3Vic2NyaWJlRm9yUmV0cnkgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN5bmNVbnN1YiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGlubmVyU3ViID0gc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAocmVzZXRPblN1Y2Nlc3MpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvRmFyID0gMDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIH0sIHVuZGVmaW5lZCwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICBpZiAoc29GYXIrKyA8IGNvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJTdWIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyU3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVGb3JSZXRyeSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3luY1Vuc3ViID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBl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vbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFlcnJvcnMkKSB7XG4gICAgICAgICAgICAgICAgICAgIGVycm9ycyQgPSBuZXcgU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgICAgICBub3RpZmllcihlcnJvcnMkKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW5uZXJTdWIgPyBzdWJzY3JpYmVGb3JSZXRyeVdoZW4oKSA6IChzeW5jUmVzdWIgPSB0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoZXJyb3JzJCkge1xuICAgICAgICAgICAgICAgICAgICBlcnJvcnMkLm5leHQoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICBpZiAoc3luY1Jlc3ViKSB7XG4gICAgICAgICAgICAgICAgaW5uZXJTdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICBpbm5lclN1YiA9IG51bGw7XG4gICAgICAgICAgICAgICAgc3luY1Jlc3ViID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmV0cnlXaGVuKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIHN1YnNjcmliZUZvclJldHJ5V2hlbigpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9cmV0cnlXaGVuLmpzLm1hcCIsImltcG9ydCB7IG9wZXJhdGUgfSBmcm9tICcuLi91dGlsL2xpZnQnO1xuaW1wb3J0IHsgbm9vcCB9IGZyb20gJy4uL3V0aWwvbm9vcCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1YnNjcmliZXIgfSBmcm9tICcuL09wZXJhdG9yU3Vic2N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NldCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGNhbmNlbFJlc2V0KCk7XG4gICAgICAgICAgICBjb25uZWN0aW9uID0gc3ViamVjdCA9IG51bGw7XG4gICAgICAgICAgICBoYXNDb21wbGV0ZWQgPSBoYXNFcnJvcmVkID0gZmFsc2U7XG4gICAgICAgIH07XG4gICAgICAgIHZhciByZXNldEFuZFVuc3Vic2NyaWJlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgdmFyIGNvbm4gPSBjb25uZWN0aW9uO1xuICAgICAgICAgICAgcmVzZXQoKTtcbiAgICAgICAgICAgIGNvbm4gPT09IG51bGwgfHwgY29ubiA9PT0gdm9pZCAwID8gdm9pZCAwIDogY29ubi51bnN1YnNjcmliZSgpO1xuICAgICAgICB9O1xuICAgICAgICByZXR1cm4gb3BlcmF0ZShmdW5jdGlvbiAoc291cmNlLCBzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICByZWZDb3VudCsrO1xuICAgICAgICAgICAgaWYgKCFoYXNFcnJvcmVkICYmICFoYXNDb21wbGV0ZWQpIHtcbiAgICAgICAgICAgICAgICBjYW5jZWxSZXNldCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGRlc3QgPSAoc3ViamVjdCA9IHN1YmplY3QgIT09IG51bGwgJiYgc3ViamVjdCAhPT0gdm9pZCAwID8gc3ViamVjdCA6IGNvbm5lY3RvcigpKTtcbiAgICAgICAgICAgIHN1YnNjcmliZXIuYWRkKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICByZWZDb3VudC0tO1xuICAgICAgICAgICAgICAgIGlmIChyZWZDb3VudCA9PT0gMCAmJiAhaGFzRXJyb3JlZCAmJiAhaGFzQ29tcGxldGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc2V0Q29ubmVjdGlvbiA9IGhhbmRsZVJlc2V0KHJlc2V0QW5kVW5zdWJzY3JpYmUsIHJlc2V0T25SZWZDb3VudFplcm8pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgZGVzdC5zdWJzY3JpYmUoc3Vic2NyaWJlcik7XG4gICAgICAgICAgICBpZiAoIWNvbm5lY3Rpb24pIHtcbiAgICAgICAgICAgICAgICBjb25uZWN0aW9uID0gbmV3IFNhZmVTdWJzY3JpYmVyKHtcbiAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHZhbHVlKSB7IHJldHVybiBkZXN0Lm5leHQodmFsdWUpOyB9LFxuICAgICAgICAgICAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaGFzRXJyb3JlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWxSZXNldCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDb25uZWN0aW9uID0gaGFuZGxlUmVzZXQocmVzZXQsIHJlc2V0T25FcnJvciwgZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0NvbXBsZXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWxSZXNldCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDb25uZWN0aW9uID0gaGFuZGxlUmVzZXQocmVzZXQsIHJlc2V0T25Db21wbGV0ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZXN0LmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgZnJvbShzb3VyY2UpLnN1YnNjcmliZShjb25uZWN0aW9uKTtcbiAgICAgICAgICAgIH1cbiAgICAgICA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4gICAgICAgICAgICAgICAgdmFyIHZhbHVlSW5kZXggPSBzZWVuKys7XG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlSW5kZXggPCBza2lwQ291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmluZ1t2YWx1ZUluZGV4XSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gdmFsdWVJbmRleCAlIHNraXBDb3VudDtcbiAgICAgICAgICAgICAgICAgICAgdmFyIG9sZFZhbHVlID0gcmluZ1tpbmRleF07XG4gICAgICAgICAgICAgICAgICAgIHJpbmdbaW5kZXhdID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChvbGRWYWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICByaW5nID0gbnVsbDtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9c2tpcExhc3QuanMubWFwIiwiaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlmdCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1YnNjcmliZXIgfSBmcm9tICcuL09wZXJhdG9yU3Vic2NyaWJlcic7XG5pbXBvcnQgeyBpbm5lckZyb20gfSBmcm9tICcuLi9vYnNlcnZhYmxlL2Zyb20nO1xuaW1wb3J0IHsgbm9vcCB9IGZyb20gJy4uL3V0aWwvbm9vcCc7XG5leHBvcnQgZnVuY3Rpb24gc2tpcFVudGlsKG5vdGlmaWVyKSB7XG4gICAgcmV0dXJuIG9wZXJhdGUoZnVuY3Rpb24gKHNvdXJjZSwgc3Vic2NyaWJlcikge1xuICAgICAgICB2YXIgdGFraW5nID0gZmFsc2U7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dGUgPSBudWxsO1xuICAgICAgICB9O1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9c3dpdGNoU2Nhbi5qcy5tYXAiLCJpbXBvcnQgeyBFTVBUWSB9IGZyb20gJy4uL29ic2VydmFibGUvZW1wdHknO1xuaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlmdCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1YnNjcmliZXIgfSBmcm9tICcuL09wZXJhdG9yU3Vic2NyaWJlcic7XG5leHBvcnQgZnVuY3Rpb24gdGFrZShjb3VudCkge1xuICAgIHJldHVybiBjb3VudCA8PSAwXG4gICAgICAgID9cbiAgICAgICAgICAgIGZ1bmN0aW9uICgpIHsgcmV0dXJuIEVNUFRZOyB9XG4gICAgICAgIDogb3BlcmF0ZShmdW5jdGlvbiAoc291cmNlLCBzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICB2YXIgc2VlbiA9IDA7XG4gICAgICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgaWYgKCsrc2VlbiA8PSBjb3VudCkge1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoY291bnQgPD0gc2Vlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXRha2UuanMubWFwIiwiaW1wb3J0IHsgX192YWx1ZXMgfSBmcm9tIFwidHNsaWJcIjtcbmltcG9ydCB7IEVNUFRZIH0gZnJvbSAnLi4vb2Jz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AgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVfMV8xKSB7IGVfMSA9IHsgZXJyb3I6IGVfMV8xIH07IH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChidWZmZXJfMV8xICYmICFidWZmZXJfMV8xLmRvbmUgJiYgKF9hID0gYnVmZmVyXzEucmV0dXJuKSkgX2EuY2FsbChidWZmZXJfMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzEpIHRocm93IGVfMS5lcnJvcjsgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9LCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBidWZmZXIgPSBudWxsO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXRha2VMYXN0LmpzLm1hcCIsImltcG9ydCB7IG9wZXJhdGUgfSBmcm9tICcuLi91dGlsL2xpZnQnO1xuaW1wb3J0IHsgT3BlcmF0b3JTdWJzY3JpYmVyIH0gZnJvbSAnLi9PcGVyYXRvclN1YnNjcmliZXInO1xuaW1wb3J0IHsgaW5uZXJGcm9tIH0gZnJvbSAnLi4vb2JzZXJ2YWJsZS9mcm9tJztcbmltcG9ydCB7IG5vb3AgfSBmcm9tICcuLi91dGlsL25vb3AnO1xuZXhwb3J0IGZ1bmN0aW9uIHRha2VVbnRpbChub3RpZmllcikge1xuICAgIHJldHVybiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgaW5uZXJGcm9tKG5vdGlmaWVyKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU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OiB3aW5kb3dTaXplO1xuICAgIHJldHVybiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIHdpbmRvd3MgPSBbbmV3IFN1YmplY3QoKV07XG4gICAgICAgIHZhciBzdGFydHMgPSBbXTtcbiAgICAgICAgdmFyIGNvdW50ID0gMDtcbiAgICAgICAgc3Vic2NyaWJlci5uZXh0KHdpbmRvd3NbMF0uYXNPYnNlcnZhYmxlKCkpO1xuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICB2YXIgZV8xLCBfYTtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgd2luZG93c18xID0gX192YWx1ZXMod2luZG93cyksIHdpbmRvd3NfMV8xID0gd2luZG93c18xLm5leHQoKTsgIXdpbmRvd3NfMV8xLmRvbmU7IHdpbmRvd3NfMV8xID0gd2luZG93c18xLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgd2luZG93XzEgPSB3aW5kb3dzXzFfMS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgd2luZG93XzEubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGVfMV8xKSB7IGVfMSA9IHsgZXJyb3I6IGVfMV8xIH07IH1cbiAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh3aW5kb3dzXzFfMSAmJiAhd2luZG93c18xXzEuZG9uZSAmJiAoX2EgPSB3aW5kb3dzXzEucmV0dXJuKSkgX2EuY2FsbCh3aW5kb3dzXzEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMSkgdGhyb3cgZV8xLmVycm9yOyB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgYyA9IGNvdW50IC0gd2luZG93U2l6ZSArIDE7XG4gICAgICAgICAgICBpZiAoYyA+PSAwICYmIGMgJSBzdGFydEV2ZXJ5ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgd2luZG93cy5zaGlmdCgpLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoKytjb3VudCAlIHN0YXJ0RXZlcnkgPT09IDApIHtcbiAgICAgICAgICAgICAgICB2YXIgd2luZG93XzIgPSBuZXcgU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgIHdpbmRvd3MucHVzaCh3aW5kb3dfMik7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHdpbmRvd18yLmFzT2JzZXJ2YWJsZSgpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgd2hpbGUgKHdpbmRvd3MubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgIHdpbmRvd3Muc2hpZnQoKS5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICB9LCBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICB3aGlsZSAod2luZG93cy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgd2luZG93cy5zaGlmdCgpLmVycm9yKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHN0YXJ0cyA9IG51bGw7XG4gICAgICAgICAgICB3aW5kb3dzID0gbnVsbDtcbiAgICAgICAgfSkpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZ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IHJldHVybiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIHdpbmRvd1JlY29yZHMgPSBbXTtcbiAgICAgICAgdmFyIHJlc3RhcnRPbkNsb3NlID0gZmFsc2U7XG4gICAgICAgIHZhciBjbG9zZVdpbmRvdyA9IGZ1bmN0aW9uIChyZWNvcmQpIHtcbiAgICAgICAgICAgIHZhciB3aW5kb3cgPSByZWNvcmQud2luZG93LCBzdWJzID0gcmVjb3JkLnN1YnM7XG4gICAgICAgICAgICB3aW5kb3cuY29tcGxldGUoKTtcbiAgICAgICAgICAgIHN1YnMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIGFyclJlbW92ZSh3aW5kb3dSZWNvcmRzLCByZWNvcmQpO1xuICAgICAgICAgICAgcmVzdGFydE9uQ2xvc2UgJiYgc3RhcnRXaW5kb3coKTtcbiAgICAgICAgfTtcbiAgICAgICAgdmFyIHN0YXJ0V2luZG93ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKHdpbmRvd1JlY29yZHMpIHtcbiAgICAgICAgICAgICAgICB2YXIgc3VicyA9IG5ldyBTdWJzY3JpcHRpb24oKTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChzdWJzKTtcbiAgICAgICAgICAgICAgICB2YXIgd2luZG93XzEgPSBuZXcgU3ViamVjdCgpO1xuICAgICAgICAgICAgICAgIHZhciByZWNvcmRfMSA9IHtcbiAgICAgICAgICAgICAgICAgICAgd2luZG93OiB3aW5kb3dfMSxcbiAgICAgICAgICAgICAgICAgICAgc3Viczogc3VicyxcbiAgICAgICAgICAgICAgICAgICAgc2VlbjogMCxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIHdpbmRvd1JlY29yZHMucHVzaChyZWNvcmRfMSk7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHdpbmRvd18xLmFzT2JzZXJ2YWJsZSgpKTtcbiAgICAgICAgICAgICAgICBzdWJzLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZnVuY3Rpb24gKCkgeyByZXR1cm4gY2xvc2VXaW5kb3cocmVjb3JkXzEpOyB9LCB3aW5kb3dUaW1lU3BhbikpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICB3aW5kb3dDcmVhdGlvbkludGVydmFsICE9PSBudWxsICYmIHdpbmRvd0NyZWF0aW9uSW50ZXJ2YWwgPj0gMFxuICAgICAgICAgICAgP1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuYWRkKHNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0V2luZG93KCk7XG4gICAgICAgICAgICAgICAgICAgICF0aGlzLmNsb3NlZCAmJiBzdWJzY3JpYmVyLmFkZCh0aGlzLnNjaGVkdWxlKG51bGwsIHdpbmRvd0NyZWF0aW9uSW50ZXJ2YWwpKTtcbiAgICAgICAgICAgICAgICB9LCB3aW5kb3dDcmVhdGlvbkludGVydmFsKSlcbiAgICAgICAgICAgIDogKHJlc3RhcnRPbkNsb3NlID0gdHJ1ZSk7XG4gICAgICAgIHN0YXJ0V2luZG93KCk7XG4gICAgICAgIHZhciBsb29wID0gZnVuY3Rpb24gKGNiKSB7IHJldHVybiB3aW5kb3dSZWNvcmRzLnNsaWNlKCkuZm9yRWFjaChjYik7IH07XG4gICAgICAgIHZhciB0ZXJtaW5hdGUgPSBmdW5jdGlvbiAoY2IpIHtcbiAgICAgICAgICAgIGxvb3AoZnVuY3Rpb24gKF9hKSB7XG4gICAgICAgICAgICAgICAgdmFyIHdpbmRvdyA9IF9hLndpbmRvdztcbiAgICAgICAgICAgICAgICByZXR1cm4gY2Iod2luZG93KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgY2Ioc3Vic2NyaWJlcik7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLnVuc3V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ICAgICAgICAgICAgdmFyIHdpbmRvd18xID0gd2luZG93c0NvcHlfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICB3aW5kb3dfMS5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHdpbmRvd3NDb3B5XzFfMSAmJiAhd2luZG93c0NvcHlfMV8xLmRvbmUgJiYgKF9hID0gd2luZG93c0NvcHlfMS5yZXR1cm4pKSBfYS5jYWxsKHdpbmRvd3NDb3B5XzEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMSkgdGhyb3cgZV8xLmVycm9yOyB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHdoaWxlICgwIDwgd2luZG93cy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB3aW5kb3dzLnNoaWZ0KCkuY29tcGxldGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgfSwgaGFuZGxlRXJyb3IsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHdoaWxlICgwIDwgd2luZG93cy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB3aW5kb3dzLnNoaWZ0KCkudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSkpO1xuICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9d2luZG93VG9nZ2xlLmpzLm1hcCIsImltcG9ydCB7IFN1YmplY3QgfSBmcm9tICcuLi9TdWJqZWN0Jztc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ZXIpIHtcbiAgICBpZiAoIWlucHV0KSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcignSXRlcmFibGUgY2Fubm90IGJlIG51bGwnKTtcbiAgICB9XG4gICAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBzdWIgPSBuZXcgU3Vic2NyaXB0aW9uKCk7XG4gICAgICAgIHN1Yi5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBpdGVyYXRvciA9IGlucHV0W1N5bWJvbC5hc3luY0l0ZXJhdG9yXSgpO1xuICAgICAgICAgICAgc3ViLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgICAgICAgICAgaXRlcmF0b3IubmV4dCgpLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0LmRvbmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChyZXN1bHQudmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuc2NoZWR1bGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9KSk7XG4gICAgICAgIHJldHVybiBzdWI7XG4gICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1zY2hlZHVsZUFzeW5jSXRlcmFibGUuanMubWFwIiwiaW1wb3J0IHsgT2JzZXJ2YWJsZSB9IGZyb20gJ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wgcmVzdWx0KTsgfSwge30pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Y3JlYXRlT2JqZWN0LmpzLm1hcCIsImltcG9ydCB7IGNvbmZpZyB9IGZyb20gJy4uL2NvbmZpZyc7XG52YXIgY29udGV4dCA9IG51bGw7XG5leHBvcnQgZnVuY3Rpb24gZXJyb3JDb250ZXh0KGNiKSB7XG4gICAgaWYgKGNvbmZpZy51c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nKSB7XG4gICAgICAgIHZhciBpc1Jvb3QgPSAhY29udGV4dDtcbiAgICAgICAgaWYgKGlzUm9vdCkge1xuICAgICAgICAgICAgY29udGV4dCA9IHsgZXJyb3JUaHJvd246IGZhbHNlLCBlcnJvcjogbnVsbCB9O1xuICAgICAgICB9XG4gICAgICAgIGNiKCk7XG4gICAgICAgIGlmIChpc1Jvb3QpIHtcbiAgICAgICAgICAgIHZhciBfYSA9IGNvbnRleHQsIGVycm9yVGhyb3duID0gX2EuZXJyb3JUaHJvd24sIGVycm9yID0gX2EuZXJyb3I7XG4gICAgICAgICAgICBjb250ZXh0ID0gbnVsbDtcbiAgICAgICAgICAgIGlmIChlcnJvclRocm93bikge1xuICAgICAgICAgICAgICAgIHRocm93IGVycm9yO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIGVsc2Uge1xuICAgICAgICBjYigpO1xuICAgIH1cbn1cbmV4cG9ydCBmdW5jdGlvbiBjYXB0dXJlRXJyb3IoZXJyKSB7XG4gICAgaWYgKGNvbmZpZy51c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nICYmIGNvbnRleHQpIHtcbiAgICAgICAgY29udGV4dC5lcnJvclRocm93biA9IHRydWU7XG4gICAgICAgIGNvbnRleHQuZXJyb3IgPSBlcnI7XG4gICAgfVxufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZXJyb3JDb250ZXh0LmpzLm1hcCIsImV4cG9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c2UgMjpcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0cnVlKSByZXR1cm4gWzMsIDhdO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzQsIF9fYXdhaXQocmVhZGVyLnJlYWQoKSldO1xuICAgICAgICAgICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgICAgICAgICAgX2EgPSBfYi5zZW50KCksIHZhbHVlID0gX2EudmFsdWUsIGRvbmUgPSBfYS5kb25lO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIWRvbmUpIHJldHVybiBbMywgNV07XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgX19hd2FpdCh2b2lkIDApXTtcbiAgICAgICAgICAgICAgICBjYXNlIDQ6IHJldHVybiBbMiwgX2Iuc2VudCgpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDU6IHJldHVybiBbNCwgX19hd2FpdCh2YWx1ZSldO1xuICAgICAgICAgICAgICAgIGNhc2UgNjogcmV0dXJuIFs0LCBfYi5zZW50KCldO1xuICAgICAgICAgICAgICAgIGNhc2UgNzpcbiAgICAgICAgICAgICAgICAgICAgX2Iuc2VudCgpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzMsIDJdO1xuICAgICAgICAgICAgICAgIGNhc2UgODogcmV0dXJuIFszLCAxMF07XG4gICAgICAgICAgICAgICAgY2FzZSA5OlxuICAgICAgICAgICAgICAgICAgICByZWFkZXIucmVsZWFzZUxvY2soKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFs3XTtcbiAgICAgICAgICAgICAgICBjYXNlIDEwOiByZXR1cm4gWzJdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9KTtcbn1cbmV4cG9ydCBmdW5jdGlvbiBpc1JlYWRhYmxlU3RyZWFtTGlrZShvYmopIHtcbiAgICByZXR1cm4gaXNGdW5jdGlvbihvYmogPT09IG51bGwgfHwgb2JqID09PSB2b2lkIDAgPyB2b2lkIDAgOiBvYmouZ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KVxuICAgICAgY2FzZSAnb2JqZWN0Jzoge1xuICAgICAgICBpZiAodmFsdWUgPT09IG51bGwpIHtcbiAgICAgICAgICByZXR1cm4gJ251bGwnXG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YWNrLmluZGV4T2YodmFsdWUpICE9PSAtMSkge1xuICAgICAgICAgIHJldHVybiBjaXJjdWxhclZhbHVlXG4gICAgICAgIH1cblxuICAgICAgICBsZXQgcmVzID0gJydcbiAgICAgICAgbGV0IGpvaW4gPSAnLCdcbiAgICAgICAgY29uc3Qgb3JpZ2luYWxJbmRlbnRhdGlvbiA9IGluZGVudGF0aW9uXG5cbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuICdbXSdcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG1heGltdW1EZXB0aCA8IHN0YWNrLmxlbmd0aCArIDEpIHtcbiAgICAgICAgICAgIHJldHVybiAnXCJbQXJyYXldXCInXG4gICAgICAgICAgfVxuICAgICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgICAgaWYgKHNwYWNlciAhPT0gJycpIHtcbiAgICAgICAgICAgIGluZGVudGF0aW9uICs9IHNwYWNlclxuICAgICAgICAgICAgcmVzICs9IGBcXG4ke2luZGVudGF0aW9ufWBcbiAgICAgICAgICAgIGpvaW4gPSBgLFxcbiR7aW5kZW50YXRpb259YFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb25zdCBtYXhpbXVtVmFsdWVzVG9TdHJpbmdpZnkgPSBNYXRoLm1pbih2YWx1ZS5sZW5ndGgsIG1heGltdW1CcmVhZHRoKVxuICAgICAgICAgIGxldCBpID0gMFxuICAgICAgICAgIGZvciAoOyBpIDwgbWF4aW11bVZhbHVlc1RvU3RyaW5naWZ5IC0gMTsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCB0bXA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gIGlmIChtYXhpbXVtRGVwdGggPCBzdGFjay5sZW5ndGggKyAxKSB7XG4gICAgICAgICAgcmV0dXJuICdcIltPYmplY3RdXCInXG4gICAgICAgIH1cbiAgICAgICAgbGV0IHdoaXRlc3BhY2UgPSAnJ1xuICAgICAgICBsZXQgc2VwYXJhdG9yID0gJydcbiAgICAgICAgaWYgKHNwYWNlciAhPT0gJycpIHtcbiAgICAgICAgICBpbmRlbnRhdGlvbiArPSBzcGFjZXJcbiAgICAgICAgICBqb2luID0gYCxcXG4ke2luZGVudGF0aW9ufWBcbiAgICAgICAgICB3aGl0ZXNwYWNlID0gJyAnXG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeSA9IE1hdGgubWluKGtleUxlbmd0aCwgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgIGlmIChkZXRlcm1pbmlzdGljICYmICFpc1R5cGVkQXJyYXlXaXRoRW50cmllcyh2YWx1ZSkpIHtcbiAgICAgICAgICBrZXlzID0gc29ydChrZXlzLCBjb21wYXJhdG9yKVxuICAgICAgICB9XG4gICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeTsgaSsrKSB7XG4gICAgICAgICAgY29uc3Qga2V5ID0ga2V5c1tpXVxuICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeUZuUmVwbGFjZXIoa2V5LCB2YWx1ZSwgc3RhY2ssIHJlcGxhY2VyLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIGlmICh0bXAgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmVzICs9IGAke3NlcGFyYXRvcn0ke3N0ckVzY2FwZShrZXkpfToke3doaXRlc3BhY2V9JHt0bXB9YFxuICAgICAgICAgICAgc2VwYXJhdG9yID0gam9pblxuICAgICAgICAgIH1c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W1vdmVkS2V5cyl9IG5vdCBzdHJpbmdpZmllZFwiYFxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoc3BhY2VyICE9PSAnJykge1xuICAgICAgICAgICAgcmVzICs9IGBcXG4ke29yaWdpbmFsSW5kZW50YXRpb259YFxuICAgICAgICAgIH1cbiAgICAgICAgICBzdGFjay5wb3AoKVxuICAgICAgICAgIHJldHVybiBgWyR7cmVzfV1gXG4gICAgICAgIH1cbiAgICAgICAgc3RhY2sucHVzaCh2YWx1ZSlcbiAgICAgICAgbGV0IHdoaXRlc3BhY2UgPSAnJ1xuICAgICAgICBpZiAoc3BhY2VyICE9PSAnJykge1xuICAgICAgICAgIGluZGVudGF0aW9uICs9IHNwYWNlclxuICAgICAgICAgIGpvaW4gPSBgLFxcbiR7aW5kZW50YXRpb259YFxuICAgICAgICAgIHdoaXRlc3BhY2UgPSAnICdcbiAgICAgICAgfVxuICAgICAgICBsZXQgc2VwYXJhdG9yID0gJydcbiAgICAgICAgZm9yIChjb25zdCBrZXkgb2YgcmVwbGFjZXIpIHtcbiAgICAgICAgICBjb25zdCB0bXAgPSBzdHJpbmdpZnlBcnJheVJlcGxhY2VyKGtleSwgdmFsdWVba2V5XSwgc3RhY2ssIHJlcGxhY2VyLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIGlmICh0bXAgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmVzICs9IGAke3NlcGFyYXRvcn0ke3N0ckVzY2FwZShrZXkpfToke3doaXRlc3BhY2V9JHt0bXB9YFxuICAgICAgICAgICAgc2VwYXJhdG9yID0gam9pblxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoc3BhY2VyICE9PSAnJyAmJiBzZXBhcmF0b3IubGVuZ3RoID4gMSkge1xuICAgICAgICAgIHJlcyA9IGBcXG4ke2luZGVudGF0aW9ufSR7cmVzfVxcbiR7b3JpZ2luYWxJbmRlbnRhdGlvbn1gXG4gICAgICAgI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vSlNPTmAgYWdhaW4uXG4gICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgIHJldHVybiBzdHJpbmdpZnlJbmRlbnQoa2V5LCB2YWx1ZSwgc3RhY2ssIHNwYWNlciwgaW5kZW50YXRpb24pXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuICdudWxsJ1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhY2suaW5kZXhPZih2YWx1ZSkgIT09IC0xKSB7XG4gICAgICAgICAgcmV0dXJuIGNpcmN1bGFyVmFsdWVcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBvcmlnaW5hbEluZGVudGF0aW9uID0gaW5kZW50YXRpb25cblxuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICBpZiAodmFsdWUubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICByZXR1cm4gJ1tdJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobWF4aW11bURlcHRoIDwgc3RhY2subGVuZ3RoICsgMSkge1xuICAgICAgICAgICAgcmV0dXJuICdcIltBcnJheV1cIidcbiAgICAgICAgICB9XG4gICAgICAgICAgc3RhY2sucHVzaCh2YWx1ZSlcbiAgICAgICAgICBpbmRlbnRhdGlvbiArPSBzcGFjZXJcbiAgICAgICAgICBsZXQgcmVzID0gYFxcbiR7aW5kZW50YXRpb259YFxuICAgICAgICAgIGNvbnN0IGpvaW4gPSBgLFxcbiR7aW5kZW50YXRpb259YFxuICAgICAgICAgIGNvbnN0IG1heGltdW1WYWx1ZXNUb1N0cmluZ2lmeSA9IE1hdGgubWluKHZhbHVlLmxlbmd0aCwgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgICAgbGV0IGkgPSAwXG4gICAgICAgICAgZm9yICg7IGkgPCBtYXhpbXVtVmFsdWVzVG9TdHJpbmdpZnkgLSAxOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeUluZGVudChTdHJpbmcoaSksIHZhbHVlW2ldLCBzdGFjaywgc3BhY2VyLCBpbmRlbnRhdGlvbilcbiAgICAgICAgICAgIHJlcyArPSB0bXAgIT09IHVuZGVmaW5lZCA/IHRtcCA6ICdudWxsJ1xuICAgICAgICAgICAgcmVzICs9IGpvaW5cbiAgICAgICAgICB9XG4gICAgICAgICAgY29uc3QgdG1wID0gc3RyaW5naWZ5SW5kZW50KFN0cmluZyhpKSwgdmFsdWVbaV0sIHN0YWNrLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIHJlcyArPSB0bXAgIT09IHVuZGVmaW5lZCA/IHRtcCA6ICdudWxsJ1xuICAgICAgICAgIGlmICh2YWx1ZS5sZW5ndGggLSAxID4gbWF4aW11bUJyZWFkdGgpIHtcbiAgICAgICAgICAgIGNvbnN0IHJlbW92ZWRLZXlzID0gdmFsdWUubGVuZ3RoIC0gbWF4aW11bUJyZWFkdGggLSAxXG4gICAgICAgICAgICByZXMgKz0gYCR7am9pbn1cIi4uLiAke2dldEl0ZW1Db3VudChyZW1vdmVkS2V5cyl9IG5vdCBzdHJpbmdpZmllZFwiYFxuICAgICAgICAgIH1cbiAgICAgICAgICByZXMgKz0gYFxcbiR7b3JpZ2luYWxJbmRlbnRhdGlvbn1gXG4gICAgICAgICAgc3RhY2sucG9wKClcbiAgICAgICAgICByZXR1cm4gYFske3Jlc31dYFxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyh2YWx1ZSlcbiAgICAgICAgY29uc3Qga2V5TGVuZ3RoID0ga2V5cy5sZW5ndGhcbiAgICAgICAgaWYgKGtleUxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgIHJldHVybiAne30nXG4gICAgICAgIH1cbiAgICAgICAgaWYgKG1heGltdW1EZX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G5vdCBzdHJpbmdpZmllZFwiYFxuICAgICAgICAgIH1cbiAgICAgICAgICBzdGFjay5wb3AoKVxuICAgICAgICAgIHJldHVybiBgWyR7cmVzfV1gXG4gICAgICAgIH1cblxuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKHZhbHVlKVxuICAgICAgICBjb25zdCBrZXlMZW5ndGggPSBrZXlzLmxlbmd0aFxuICAgICAgICBpZiAoa2V5TGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgcmV0dXJuICd7fSdcbiAgICAgICAgfVxuICAgICAgICBpZiAobWF4aW11bURlcHRoIDwgc3RhY2subGVuZ3RoICsgMSkge1xuICAgICAgICAgIHJldHVybiAnXCJbT2JqZWN0XVwiJ1xuICAgICAgICB9XG4gICAgICAgIGxldCBzZXBhcmF0b3IgPSAnJ1xuICAgICAgICBsZXQgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeSA9IE1hdGgubWluKGtleUxlbmd0aCwgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgIGlmIChoYXNMZW5ndGggJiYgaXNUeXBlZEFycmF5V2l0aEVudHJpZXModmFsdWUpKSB7XG4gICAgICAgICAgcmVzICs9IHN0cmluZ2lmeVR5cGVkQXJyYXkodmFsdWUsICcsJywgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgICAga2V5cyA9IGtleXMuc2xpY2UodmFsdWUubGVuZ3RoKVxuICAgICAgICAgIG1heGltdW1Qcm9wZXJ0aWVzVG9TdHJpbmdpZnkgLT0gdmFsdWUubGVuZ3RoXG4gICAgICAgICAgc2VwYXJhdG9yID0gJywnXG4gICAgICAgIH1cbiAgICAgICAgaWYgKGRldGVybWluaXN0aWMpIHtcbiAgICAgICAgICBrZXlzID0gc29ydChrZXlzLCBjb21wYXJhdG9yKVxuICAgICAgICB9XG4gICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbWF4aW11bVByb3BlcnRpZ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AgICdwYXJ0JzogODcwNixcbiAgICAnZXhpc3QnOiA4NzA3LFxuICAgICdlbXB0eSc6IDg3MDksXG4gICAgJ25hYmxhJzogODcxMSxcbiAgICAnaXNpbic6IDg3MTIsXG4gICAgJ25vdGluJzogODcxMyxcbiAgICAnbmknOiA4NzE1LFxuICAgICdwcm9kJzogODcxOSxcbiAgICAnc3VtJzogODcyMSxcbiAgICAnbWludXMnOiA4NzIyLFxuICAgICdsb3dhc3QnOiA4NzI3LFxuICAgICdyYWRpYyc6IDg3MzAsXG4gICAgJ3Byb3AnOiA4NzMzLFxuICAgICdpbmZpbic6IDg3MzQsXG4gICAgJ2FuZyc6IDg3MzYsXG4gICAgJ2FuZCc6IDg3NDMsXG4gICAgJ29yJzogODc0NCxcbiAgICAnY2FwJzogODc0NSxcbiAgICAnY3VwJzogODc0NixcbiAgICAnaW50JzogODc0NyxcbiAgICAndGhlcmU0JzogODc1NixcbiAgICAnc2ltJzogODc2NCxcbiAgICAnY29uZyc6IDg3NzMsXG4gICAgJ2FzeW1wJzogODc3NixcbiAgICAnbmUnOiA4ODAwLFxuICAgICdlcXVpdic6IDg4MDEsXG4gICAgJ2xlJzogODgwNCxcbiAgICAnZ2UnOiA4ODA1LFxuICAgICdzdWInOiA4ODM0LFxuICAgICdzdXAnOiA4ODM1LFxuICAgICduc3ViJzogODgzNixcbiAgICAnc3ViZSc6IDg4MzgsXG4gICAgJ3N1cGUnOiA4ODM5LFxuICAgICdvcGx1cyc6IDg4NTMsXG4gICAgJ290aW1lcyc6IDg4NTUsXG4gICAgJ3BlcnAnOiA4ODY5LFxuICAgICdzZG90JzogODkwMSxcbiAgICAnbGNlaWwnOiA4OTY4LFxuICAgICdyY2VpbCc6IDg5NjksXG4gICAgJ2xmbG9vcic6IDg5NzAsXG4gICAgJ3JmbG9vcic6IDg5NzEsXG4gICAgJ2xhbmcnOiA5MDAxLFxuICAgICdyYW5nJzogOTAwMixcbiAgICAnbG96JzogOTY3NCxcbiAgICAnc3BhZ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htbG5zJykge1xuICAgICAgICAvLyBuYW1lc3BhY2UgYmluZGluZyBhdHRyaWJ1dGUuIHB1c2ggdGhlIGJpbmRpbmcgaW50byBzY29wZVxuICAgICAgICBpZiAobG9jYWwgPT09ICd4bWwnICYmIHBhcnNlci5hdHRyaWJWYWx1ZSAhPT0gWE1MX05BTUVTUEFDRSkge1xuICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLFxuICAgICAgICAgICAgJ3htbDogcHJlZml4IG11c3QgYmUgYm91bmQgdG8gJyArIFhNTF9OQU1FU1BBQ0UgKyAnXFxuJyArXG4gICAgICAgICAgICAnQWN0dWFsOiAnICsgcGFyc2VyLmF0dHJpYlZhbHVlKVxuICAgICAgICB9IGVsc2UgaWYgKGxvY2FsID09PSAneG1sbnMnICYmIHBhcnNlci5hdHRyaWJWYWx1ZSAhPT0gWE1MTlNfTkFNRVNQQUNFKSB7XG4gICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsXG4gICAgICAgICAgICAneG1sbnM6IHByZWZpeCBtdXN0IGJlIGJvdW5kIHRvICcgKyBYTUxOU19OQU1FU1BBQ0UgKyAnXFxuJyArXG4gICAgICAgICAgICAnQWN0dWFsOiAnICsgcGFyc2VyLmF0dHJpYlZhbHVlKVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHZhciB0YWcgPSBwYXJzZXIudGFnXG4gICAgICAgICAgdmFyIHBhcmVudCA9IHBhcnNlci50YWdzW3BhcnNlci50YWdzLmxlbmd0aCAtIDFdIHx8IHBhcnNlclxuICAgICAgICAgIGlmICh0YWcubnMgPT09IHBhcmVudC5ucykge1xuICAgICAgICAgICAgdGFnLm5zID0gT2JqZWN0LmNyZWF0ZShwYXJlbnQubnMpXG4gICAgICAgICAgfVxuICAgICAgICAgIHRhZy5uc1tsb2NhbF0gPSBwYXJzZXIuYXR0cmliVmFsdWVcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICAvLyBkZWZlciBvbmF0dHJpYnV0ZSBld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1bmspIHtcbiAgICB2YXIgcGFyc2VyID0gdGhpc1xuICAgIGlmICh0aGlzLmVycm9yKSB7XG4gICAgICB0aHJvdyB0aGlzLmVycm9yXG4gICAgfVxuICAgIGlmIChwYXJzZXIuY2xvc2VkKSB7XG4gICAgICByZXR1cm4gZXJyb3IocGFyc2VyLFxuICAgICAgICAnQ2Fubm90IHdyaXRlIGFmdGVyIGNsb3NlLiBBc3NpZ24gYW4gb25yZWFkeSBoYW5kbGVyLicpXG4gICAgfVxuICAgIGlmIChjaHVuayA9PT0gbnVsbCkge1xuICAgICAgcmV0dXJuIGVuZChwYXJzZXIpXG4gICAgfVxuICAgIGlmICh0eXBlb2YgY2h1bmsgPT09ICdvYmplY3QnKSB7XG4gICAgICBjaHVuayA9IGNodW5rLnRvU3RyaW5nKClcbiAgICB9XG4gICAgdmFyIGkgPSAwXG4gICAgdmFyIGMgPSAnJ1xuICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICBjID0gY2hhckF0KGNodW5rLCBpKyspXG4gICAgICBwYXJzZXIuYyA9IGNcblxuICAgICAgaWYgKCFjKSB7XG4gICAgICAgIGJyZWFrXG4gICAgICB9XG5cbiAgICAgIGlmIChwYXJzZXIudHJhY2tQb3NpdGlvbikge1xuICAgICAgICBwYXJzZXIucG9zaXRpb24rK1xuICAgICAgICBpZiAoYyA9PT0gJ1xcbicpIHtcbiAgICAgICAgICBwYXJzZXIubGluZSsrXG4gICAgICAgICAgcGFyc2VyLmNvbHVtbiA9IDBcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwYXJzZXIuY29sdW1uKytcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICBzd2l0Y2ggKHBhcnNlci5zdGF0ZSkge1xuICAgICAgICBjYXNlIFMuQkVHSU46XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5CRUdJTl9XSElURVNQQUNFXG4gICAgICAgICAgaWYgKGMgPT09ICdcXHVGRUZGJykge1xuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9XG4gICAgICAgICAgYmVnaW5XaGl0ZVNwYWNlKHBhcnNlciwgYylcbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5CRUdJTl9XSElURVNQQUNFOlxuICAgICAgICAgIGJlZ2luV2hpdGVTcGFjZShwYXJzZXIsIGMpXG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuVEVYVDpcbiAgICAgICAgICBpZiAocGFyc2VyLnNhd1Jvb3QgJiYgIXBhcnNlci5jbG9zZWRSb290KSB7XG4gICAgICAgICAgICB2YXIgc3RhcnRpID0gaSAtIDFcbiAgICAgICAgICAgIHdoaWxlIChjICYmIGMgIT09ICc8JyAmJiBjICE9PSAnJicpIHtcbiAgICAgICAgICAgICAgYyA9IGNoYXJBdChjaHVuaywgaSsrKVxuICAgICAgICAgICAgICBpZiAoYyAmJiBwYXJzZXIudHJhY2tQb3NpdGlvbikge1xuICAgICAgICAgICAgICAgIHBhcnNlci5wb3NpdGlvbisrXG4gICAgICAgICAgICAgICAgaWYgKGMgPT09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICBwYXJzZXIubGluZSsrXG4gICAgICAgICAgICAgICAgICBwYXJzZXIuY29sdW1uID0gMFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBwYXJzZXIuY29sdW1uKytcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSArPSBjaHVuay5zdWJzdHJpbmcoc3RhcnRpLCBpIC0gMSlcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGMgPT09ICc8JyAmJiAhKHBhcnNlci5zYXdSb290ICYmIHBhcnNlci5jbG9zZWRSb290ICYmICFwYXJzZXIuc3RyaWN0KSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1dBS0FcbiAgICAgICAgICAgIHBhcnNlci5zdGFydFRhZ1Bvc2l0aW9uID0gcGFyc2VyLnBvc2l0aW9uXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICghaXNXaGl0ZXNwYWNlKGMpICYmICghcGFyc2VyLnNhd1Jvb3QgfHwgcGFyc2VyLmNsb3NlZFJvb3QpKSB7XG4gICAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnVGV4dCBkYXRhIG91dHNpZGUgb2Ygcm9vdCBub2RlLicpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoYyA9PT0gJyYnKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVF9FTlRJVFlcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSArPSBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlNDUklQVDpcbiAgICAgICAgICAvLyBvbmx5IG5vbi1zdHJpY3RcbiAgICAgICAgICBpZiAoYyA9PT0gJzwnKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlNDUklQVF9FTkRJTkdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnNjcmlwdCArPSBjXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlNDUklQVF9FTkRJTkc6XG4gICAgICAgICAgaWYgKGMgPT09ICcvJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DTE9TRV9UQUdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnNjcmlwdCArPSAnPCcgKyBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlNDUklQVFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250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hZCA9IHBhcnNlci5wb3NpdGlvbiAtIHBhcnNlci5zdGFydFRhZ1Bvc2l0aW9uXG4gICAgICAgICAgICAgIGMgPSBuZXcgQXJyYXkocGFkKS5qb2luKCcgJykgKyBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXJzZXIudGV4dE5vZGUgKz0gJzwnICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5URVhUXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlNHTUxfREVDTDpcbiAgICAgICAgICBpZiAocGFyc2VyLnNnbWxEZWNsICsgYyA9PT0gJy0tJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UXG4gICAgICAgICAgICBwYXJzZXIuY29tbWVudCA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgPSAnJ1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKHBhcnNlci5kb2N0eXBlICYmIHBhcnNlci5kb2N0eXBlICE9PSB0cnVlICYmIHBhcnNlci5zZ21sRGVjbCkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX0RURFxuICAgICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gJzwhJyArIHBhcnNlci5zZ21sRGVjbCArIGNcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgfSBlbHNlIGlmICgocGFyc2VyLnNnbWxEZWNsICsgYykudG9VcHBlckNhc2UoKSA9PT0gQ0RBVEEpIHtcbiAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29ub3BlbmNkYXRhJylcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0RBVEFcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgPSAnJ1xuICAgICAgICAgIH0gZWxzZSBpZiAoKHBhcnNlci5zZ21sRGVjbCArIGMpLnRvVXBwZXJDYXNlKCkgPT09IERPQ1RZUEUpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRVxuICAgICAgICAgICAgaWYgKHBhcnNlci5kb2N0eXBlIHx8IHBhcnNlci5zYXdSb290KSB7XG4gICAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLFxuICAgICAgICAgICAgICAgICdJbmFwcHJvcHJpYXRlbHkgbG9jYXRlZCBkb2N0eXBlIGRlY2xhcmF0aW9uJylcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uc2dtbGRlY2xhcmF0aW9uJywgcGFyc2VyLnNnbWxEZWNsKVxuICAgICAgICAgICAgcGFyc2VyLnNnbWxEZWNsID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNRdW90ZShjKSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TR01MX0RFQ0xfUVVPVEVEXG4gICAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgKz0gY1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5TR01MX0RFQ0xfUVVPVEVEOlxuICAgICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TR01MX0RFQ0xcbiAgICAgICAgICAgIHBhcnNlci5xID0gJydcbiAgICAgICAgICB9XG4gICAgICAgICAgcGFyc2VyLnNnbWxEZWNsICs9IGNcbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5ET0NUWVBFOlxuICAgICAgICAgIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgICAgZW1pdE5vZGUocGFyc2VyLCAnb25kb2N0eXBlJywgcGFyc2VyLmRvY3R5cGUpXG4gICAgICAgICAgICBwYXJzZXIuZG9jdHlwZSA9IHRydWUgLy8ganVzdCByZW1lbWJlciB0aGF0IHdlIHNhdyBpdC5cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgICAgaWYgKGMgPT09ICdbJykge1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVfRFREXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzUXVvdGUoYykpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX1FVT1RFRFxuICAgICAgICAgICAgICBwYXJzZXIucSA9IGNcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuRE9DVFlQRV9RVU9URUQ6XG4gICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgICAgcGFyc2VyLnEgPSAnJ1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkRPQ1RZUEVfRFREOlxuICAgICAgICAgIGlmIChjID09PSAnXScpIHtcbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRVxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJzwnKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLk9QRU5fV0FLQVxuICAgICAgICAgICAgcGFyc2VyLnN0YXJ0VGFnUG9zaXRpb24gPSBwYXJzZXIucG9zaXRpb25cbiAgICAgICAgICB9IGVsc2UgaWYgKGlzUXVvdGUoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9EVERfUVVPVEVEXG4gICAgICAgICAgICBwYXJzZXIucSA9IGNcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5ET0NUWVBFX0RURF9RVU9URUQ6XG4gICAgICAgICAgcGFyc2VyLmRvY3R5cGUgKz0gY1xuICAgICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX0RURFxuICAgICAgICAgICAgcGFyc2VyLnEgPSAnJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DT01NRU5UOlxuICAgICAgICAgIGlmIChjID09PSAnLScpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ09NTUVOVF9FTkRJTkdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmNvbW1lbnQgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DT01NRU5UX0VORElORzpcbiAgICAgICAgICBpZiAoYyA9PT0gJy0nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRfRU5ERURcbiAgICAgICAgICAgIHBhcnNlci5jb21tZW50ID0gdGV4dG9wdHMocGFyc2VyLm9wdCwgcGFyc2VyLmNvbW1lbnQpXG4gICAgICAgICAgICBpZiAocGFyc2VyLmNvbW1lbnQpIHtcbiAgICAgICAgICAgICAgZW1pdE5vZGUocGFyc2VyLCAnb25jb21tZW50JywgcGFyc2VyLmNvbW1lbnQpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXJzZXIuY29tbWVudCA9ICcnXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5jb21tZW50ICs9ICctJyArIGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ09NTUVOVFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DT01NRU5UX0VOREVEOlxuICAgICAgICAgIGlmIChjICE9PSAnPicpIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnTWFsZm9ybWVkIGNvbW1lbnQnKVxuICAgICAgICAgICAgLy8gYWxsb3cgPCEtLSBibGFoIC0tIGJsb28gLS0+IGluIG5vbi1zdHJpY3QgbW9kZSxcbiAgICAgICAgICAgIC8vIHdoaWNoIGlzIGEgY29tbWVudCBvZiBcIiBibGFoIC0tIGJsb28gXCJcbiAgICAgICAgICAgIHBhcnNlci5jb21tZW50ICs9ICctLScgKyBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRcbiAgICAgICAgICB9IGVsc2UgaWYgKHBhcnNlci5kb2N0eXBlICYmIHBhcnNlci5kb2N0eXBlICE9PSB0cnVlKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVfRFREXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DREFUQTpcbiAgICAgICAgICBpZiAoYyA9PT0gJ10nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNEQVRBX0VORElOR1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DREFUQV9FTkRJTkc6XG4gICAgICAgICAgaWYgKGMgPT09ICddJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQV9FTkRJTkdfMlxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gJ10nICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DREFUQV9FTkRJTkdfMjpcbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBpZiAocGFyc2VyLmNkYXRhKSB7XG4gICAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uY2RhdGEnLCBwYXJzZXIuY2RhdGEpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsICdvbmNsb3NlY2RhdGEnKVxuICAgICAgICAgICAgcGFyc2VyLmNkYXRhID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJ10nKSB7XG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gJ10nXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5jZGF0YSArPSAnXV0nICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5QUk9DX0lOU1Q6XG4gICAgICAgICAgaWYgKGMgPT09ICc/Jykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5QUk9DX0lOU1RfRU5ESU5HXG4gICAgICAgICAgfSBlbHNlIGlmIChpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0JPRFlcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnByb2NJbnN0TmFtZSArPSBjXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlBST0NfSU5TVF9CT0RZOlxuICAgICAgICAgIGlmICghcGFyc2VyLnByb2NJbnN0Qm9keSAmJiBpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPycpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0VORElOR1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIucHJvY0luc3RCb2R5ICs9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuUFJPQ19JTlNUX0VORElORzpcbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsICdvbnByb2Nlc3NpbmdpbnN0cnVjdGlvbicsIHtcbiAgICAgICAgICAgICAgbmFtZTogcGFyc2VyLnByb2NJbnN0TmFtZSxcbiAgICAgICAgICAgICAgYm9keTogcGFyc2VyLnByb2NJbnN0Qm9keVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIHBhcnNlci5wcm9jSW5zdE5hbWUgPSBwYXJzZXIucHJvY0luc3RCb2R5ID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIucHJvY0luc3RCb2R5ICs9ICc/JyArIGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0JPRFlcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuT1BFTl9UQUc6XG4gICAgICAgICAgaWYgKGlzTWF0Y2gobmFtZUJvZHksIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIudGFnTmFtZSArPSBjXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5ld1RhZyhwYXJzZXIpXG4gICAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICAgIG9wZW5UYWcocGFyc2VyKVxuICAgICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnLycpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR19TTEFTSFxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgaWYgKCFpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgY2hhcmFjdGVyIGluIHRhZyBuYW1lJylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5PUEVOX1RBR19TTEFTSDpcbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBvcGVuVGFnKHBhcnNlciwgdHJ1ZSlcbiAgICAgICAgICAgIG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gICAgICAgfSBlbHNlIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnQXR0cmlidXRlIHdpdGhvdXQgdmFsdWUnKVxuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYlZhbHVlID0gcGFyc2VyLmF0dHJpYk5hbWVcbiAgICAgICAgICAgIGF0dHJpYihwYXJzZXIpXG4gICAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfTkFNRV9TQVdfV0hJVEVcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzTWF0Y2gobmFtZUJvZHksIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuYXR0cmliTmFtZSArPSBjXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnSW52YWxpZCBhdHRyaWJ1dGUgbmFtZScpXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkFUVFJJQl9OQU1FX1NBV19XSElURTpcbiAgICAgICAgICBpZiAoYyA9PT0gJz0nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9WQUxVRVxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0F0dHJpYnV0ZSB3aXRob3V0IHZhbHVlJylcbiAgICAgICAgICAgIHBhcnNlci50YWcuYXR0cmlidXRlc1twYXJzZXIuYXR0cmliTmFtZV0gPSAnJ1xuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYlZhbHVlID0gJydcbiAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uYXR0cmlidXRlJywge1xuICAgICAgICAgICAgICBuYW1lOiBwYXJzZXIuYXR0cmliTmFtZSxcbiAgICAgICAgICAgICAgdmFsdWU6ICcnXG4gICAgICAgICAgICB9KVxuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYk5hbWUgPSAnJ1xuICAgICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNNYXRjaChuYW1lU3RhcnQsIGMpKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5hdHRyaWJOYW1lID0gY1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9OQU1FXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgYXR0cmlidXRlIG5hbWUnKVxuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUU6XG4gICAgICAgICAgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzUXVvdGUoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5xID0gY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfUVVPVEVEXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICghcGFyc2VyLm9wdC51bnF1b3RlZEF0dHJpYnV0ZVZhbHVlcykge1xuICAgICAgICAgICAgICBlcnJvcihwYXJzZXIsICdVbnF1b3RlZCBhdHRyaWJ1dGUgdmFsdWUnKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfVU5RVU9URURcbiAgICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSA9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX1FVT1RFRDpcbiAgICAgICAgICBpZiAoYyAhPT0gcGFyc2VyLnEpIHtcbiAgICAgICAgICAgIGlmIChjID09PSAnJicpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfRU5USVRZX1FcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSArPSBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH1cbiAgICAgICAgICBhdHRyaWIocGFyc2VyKVxuICAgICAgICAgIHBhcnNlci5xID0gJydcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9WQUxVRV9DTE9TRURcbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfQ0xPU0VEOlxuICAgICAgICAgIGlmIChpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCXG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIG9wZW5UYWcocGFyc2VyKVxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJy8nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLk9QRU5fVEFHX1NMQVNIXG4gICAgICAgICAgfSBlbHNlIGlmIChpc01hdGNoKG5hbWVTdGFydCwgYykpIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnTm8gd2hpdGVzcGFjZSBiZXR3ZWVuIGF0dHJpYnV0ZXMnKVxuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYk5hbWUgPSBjXG4gICAgICAgICAgICBwYXJzZXIuYXR0cmliVmFsdWUgPSAnJ1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfTkFNRVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgYXR0cmlidXRlIG5hbWUnKVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfVU5RVU9URUQ6XG4gICAgICAgICAgaWYgKCFpc0F0dHJpYkVuZChjKSkge1xuICAgICAgICAgICAgaWYgKGMgPT09ICcmJykge1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9WQUxVRV9FTlRJVFlfVVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcGFyc2VyLmF0dHJpYlZhbHVlICs9IGNcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgfVxuICAgICAgICAgIGF0dHJpYihwYXJzZXIpXG4gICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgb3BlblRhZyhwYXJzZXIpXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkNMT1NFX1RBRzpcbiAgICAgICAgICBpZiAoIXBhcnNlci50YWdOYW1lKSB7XG4gICAgICAgICAgICBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG5vdE1hdGNoKG5hbWVTdGFydCwgYykpIHtcbiAgICAgICAgICAgICAgaWYgKHBhcnNlci5zY3JpcHQpIHtcbiAgICAgICAgICAgICAgICBwYXJzZXIuc2NyaXB0ICs9ICc8LycgKyBjXG4gICAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgdGFnbmFtZSBpbiBjbG9zaW5nIHRhZy4nKVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwYXJzZXIudGFnTmFtZSA9IGNcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2UgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgY2xvc2VUYWcocGFyc2VyKVxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNNYXRjaChuYW1lQm9keSwgYykpIHtcbiAgICAgICAgICAgIHBhcnNlci50YWdOYW1lICs9IGNcbiAgICAgICAgICB9IGVsc2UgaWYgKHBhcnNlci5zY3JpcHQpIHtcbiAgICAgICAgICAgIHBhcnNlci5zY3JpcHQgKz0gJzwvJyArIHBhcnNlci50YWdOYW1lXG4gICAgICAgICAgICBwYXJzZXIudGFnTmFtZSA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlNDUklQVFxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoIWlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgdGFnbmFtZSBpbiBjbG9zaW5nIHRhZycpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNMT1NFX1RBR19TQVdfV0hJVEVcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ0xPU0VfVEFHX1NBV19XSElURTpcbiAgICAgICAgICBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBjbG9zZVRhZyhwYXJzZXIpXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnSW52YWxpZCBjaGFyYWN0ZXJzIGluIGNsb3NpbmcgdGFnJylcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuVEVYVF9FTlRJVFk6XG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfRU5USVRZX1E6XG4gICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfRU5USVRZX1U6XG4gICAgICAgICAgdmFyIHJldHVyblN0YXRlXG4gICAgICAgICAgdmFyIGJ1ZmZlclxuICAgICAgICAgIHN3aXRjaCAocGFyc2VyLnN0YXRlKSB7XG4gICAgICAgICAgICBjYXNlIFMuVEVYVF9FTlRJVFk6XG4gICAgICAgICAgICAgIHJldHVyblN0YXRlID0gUy5URVhUXG4gICAgICAgICAgICAgIGJ1ZmZlciA9ICd0ZXh0Tm9kZSdcbiAgICAgICAgICAgICAgYnJlYWtcblxuICAgICAgICAgICAgY2FzZSBTLkFUVFJJQl9WQUxVRV9FTlRJVFlfUTpcbiAgICAgICAgICAgICAgcmV0dXJuU3RhdGUgPSBTLkFUVFJJQl9WQUxVRV9RVU9URURcbiAgICAgICAgICAgICAgYnVmZmVyID0gJ2F0dHJpYlZhbHVlJ1xuICAgICAgICAgICAgICBicmVha1xuXG4gICAgICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX0VOVElUWV9VOlxuICAgICAgICAgICAgICByZXR1cm5TdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX1VOUVVPVEVEXG4gICAgICAgICAgICAgIGJ1ZmZlciA9ICdhdHRyaWJWYWx1ZSdcbiAgICAgICAgICAgICAgYnJlYWtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAoYyA9PT0gJzsnKSB7XG4gICAgICAgICAgICB2YXIgcGFyc2VkRW50aXR5ID0gcGFyc2VFbnRpdHkocGFyc2VyKVxuICAgICAgICAgICAgaWYgKHBhcnNlci5vcHQudW5wYXJzZWRFbnRpdGllcyAmJiAhT2JqZWN0LnZhbHVlcyhzYXguWE1MX0VOVElUSUVTKS5pbmNsdWRlcyhwYXJzZWRFbnRpdHkpKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5lbnRpdHkgPSAnJ1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSByZXR1cm5TdGF0ZVxuICAgICAgICAgICAgICBwYXJzZXIud3JpdGUocGFyc2VkRW50aXR5KVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcGFyc2VyW2J1ZmZlcl0gKz0gcGFyc2VkRW50aXR5XG4gICAgICAgICAgICAgIHBhcnNlci5lbnRpdHkgPSAnJ1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSByZXR1cm5TdGF0ZVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNNYXRjaChwYXJzZXIuZW50aXR5Lmxlbmd0aCA/IGVudGl0eUJvZHkgOiBlbnRpdHlTdGFydCwgYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5lbnRpdHkgKz0gY1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgY2hhcmFjdGVyIGluIGVudGl0eSBuYW1lJylcbiAgICAgICAgICAgIHBhcnNlcltidWZmZXJdICs9ICcmJyArIHBhcnNlci5lbnRpdHkgKyBjXG4gICAgICAgICAgICBwYXJzZXIuZW50aXR5ID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IHJldHVyblN0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A9ICcnXG4gICAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgICAgdmFyIGNvZGVQb2ludCA9IE51bWJlcihhcmd1bWVudHNbaW5kZXhdKVxuICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICFpc0Zpbml0ZShjb2RlUG9pbnQpIHx8IC8vIGBOYU5gLCBgK0luZmluaXR5YCwgb3IgYC1JbmZpbml0eWBcbiAgICAgICAgICAgIGNvZGVQb2ludCA8IDAgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICBjb2RlUG9pbnQgPiAweDEwRkZGRiB8fCAvLyBub3QgYSB2YWxpZCBVbmljb2RlIGNvZGUgcG9pbnRcbiAgICAgICAgICAgIGZsb29yKGNvZGVQb2ludCkgIT09IGNvZGVQb2ludCAvLyBub3QgYW4gaW50ZWdlclxuICAgICAgICAgICkge1xuICAgICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcignSW52YWxpZCBjb2RlIHBvaW50OiAnICsgY29kZVBvaW50KVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoY29kZVBvaW50IDw9IDB4RkZGRikgeyAvLyBCTVAgY29kZSBwb2ludFxuICAgICAgICAgICAgY29kZVVuaXRzLnB1c2goY29kZVBvaW50KVxuICAgICAgICAgIH0gZWxzZSB7IC8vIEFzdHJhbCBjb2RlIHBvaW50OyBzcGxpdCBpbiBzdXJyb2dhdGUgaGFsdmVzXG4gICAgICAgICAgICAvLyBodHRwOi8vbWF0aGlhc2J5bmVucy5iZS9ub3Rlcy9qYXZhc2NyaXB0LWVuY29kaW5nI3N1cnJvZ2F0ZS1mb3JtdWxhZVxuICAgICAgICAgICAgY29kZVBvaW50IC09IDB4MTAwMDBcbiAgICAgICAgICAgIGhpZ2hTdXJyb2dhdGUgPSAoY29kZVBvaW50ID4+IDEwKSArIDB4RDgwMFxuICAgICAgICAgICAgbG93U3Vycm9nYXRlID0gKGNvZG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icpLnNsaWNlKDEpO1xuXG4gIHJldHVybiBsaW5lc1xuICAgIC5tYXAoZnVuY3Rpb24obGluZSkge1xuICAgICAgaWYgKGxpbmUubWF0Y2goL15cXHMqWy1dezQsfSQvKSkge1xuICAgICAgICByZXR1cm4gc2VsZi5fY3JlYXRlUGFyc2VkQ2FsbFNpdGUoe1xuICAgICAgICAgIGZpbGVOYW1lOiBsaW5lLFxuICAgICAgICAgIGxpbmVOdW1iZXI6IG51bGwsXG4gICAgICAgICAgZnVuY3Rpb25OYW1lOiBudWxsLFxuICAgICAgICAgIHR5cGVOYW1lOiBudWxsLFxuICAgICAgICAgIG1ldGhvZE5hbWU6IG51bGwsXG4gICAgICAgICAgY29sdW1uTnVtYmVyOiBudWxsLFxuICAgICAgICAgICduYXRpdmUnOiBudWxsLFxuICAgICAgICB9KTtcbiAgICAgIH1cblxuICAgICAgdmFyIGxpbmVNYXRjaCA9IGxpbmUubWF0Y2goL2F0ICg/OiguKylcXHMrXFwoKT8oPzooLis/KTooXFxkKykoPzo6KFxcZCspKT98KFteKV0rKSlcXCk/Lyk7XG4gICAgICBpZiAoIWxpbmVNYXRjaCkge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIHZhciBvYmplY3QgPSBudWxsO1xuICAgICAgdmFyIG1ldGhvZCA9IG51bGw7XG4gICAgICB2YXIgZnVuY3Rpb25OYW1lID0gbnVsbDtcbiAgICAgIHZhciB0eXBlTmFtZSA9IG51bGw7XG4gICAgICB2YXIgbWV0aG9kTmFtZSA9IG51bGw7XG4gICAgICB2YXIgaXNOYXRpdmUgPSAobGluZU1hdGNoWzVdID09PSAnbmF0aXZlJyk7XG5cbiAgICAgIGlmIChsaW5lTWF0Y2hbMV0pIHtcbiAgICAgICAgZnVuY3Rpb25OYW1lID0gbGluZU1hdGNoWzFdO1xuICAgICAgICB2YXIgbWV0aG9kU3RhcnQgPSBmdW5jdGlvbk5hbWUubGFzdEluZGV4T2YoJy4nKTtcbiAgICAgICA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jb3B5KHJldCk7XG4gICAgICBuIC09IHAuZGF0YS5sZW5ndGg7XG4gICAgICB3aGlsZSAocCA9IHAubmV4dCkge1xuICAgICAgICB2YXIgYnVmID0gcC5kYXRhO1xuICAgICAgICB2YXIgbmIgPSBuID4gYnVmLmxlbmd0aCA/IGJ1Zi5sZW5ndGggOiBuO1xuICAgICAgICBidWYuY29weShyZXQsIHJldC5sZW5ndGggLSBuLCAwLCBuYik7XG4gICAgICAgIG4gLT0gbmI7XG4gICAgICAgIGlmIChuID09PSAwKSB7XG4gICAgICAgICAgaWYgKG5iID09PSBidWYubGVuZ3RoKSB7XG4gICAgICAgICAgICArK2M7XG4gICAgICAgICAgICBpZiAocC5uZXh0KSB0aGlzLmhlYWQgPSBwLm5leHQ7ZWxzZSB0aGlzLmhlYWQgPSB0aGlzLnRhaWwgPSBudWxsO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmhlYWQgPSBwO1xuICAgICAgICAgICAgcC5kYXRhID0gYnVmLnNsaWNlKG5iKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgKytjO1xuICAgICAgfVxuICAgICAgdGhpcy5sZW5ndGggLT0gYztcbiAgICAgIHJldHVybiByZXQ7XG4gICAgfVxuXG4gICAgLy8gTWFrZSBzdXJlIHRoZSBsaW5rZWQgbGlzdCBvbmx5IHNob3dzIHRoZSBtaW5pbWFsIG5lY2Vzc2FyeSBpbmZvcm1hdGlvbi5cbiAgfSwge1xuICAgIGtleTogY3VzdG9tLFxuICAgIHZhbHVlOiBmdW5jdGlvbiB2YWx1ZShfLCBvcHRpb25zKSB7XG4gICAgICByZXR1cm4gaW5zcGVjdCh0aGlzLCBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIG9wdGlvbnMpLCB7fSwge1xuICAgICAgICAvLyBPbmx5IGluc3BlY3Qgb25lIGxldmVsLlxuICAgICAgICBkZXB0aDogMCx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mZpbGUsICdhKycsICcwNjQ0JywgKGVyciwgZmQpID0+IHtcbiAgICBpZiAoZXJyKSB7XG4gICAgICBpZiAoIWl0ZXIpIHtcbiAgICAgICAgc3RyZWFtLmVtaXQoJ2Vycm9yJywgZXJyKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGl0ZXIoZXJyKTtcbiAgICAgIH1cbiAgICAgIHN0cmVhbS5kZXN0cm95KCk7XG4gICAgICByZXR1cm47XG4gICAgfVxuXG4gICAgKGZ1bmN0aW9uIHJlYWQoKSB7XG4gICAgICBpZiAoc3RyZWFtLmRlc3Ryb3llZCkge1xuICAgICAgICBmcy5jbG9zZShmZCwgbm9vcCk7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIGZzLnJlYWQoZmQsIGJ1ZmZlciwgMCwgYnVmZmVyLmxlbmd0aCwgcG9zLCAoZXJyb3IsIGJ5dGVzKSA9PiB7XG4gICAgICAgIGlmIChlcnJvcikge1xuICAgICAgICAgIGlmICghaXRlcikge1xuICAgICAgICAgICAgc3RyZWFtLmVtaXQoJ2Vycm9yJywgZXJyb3IpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpdGVyKGVycm9yKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgc3RyZWFtLmRlc3Ryb3koKTtcbiAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIWJ5dGVzKSB7XG4gICAgICAgICAgaWYgKGJ1ZmYpIHtcbiAgICAgICAgICAgIC8vIGVzbGludC1kaXNhYmxlLW5leHQtbGluZSBlcWVxZXFcbiAgICAgICAgICAgIGlmIChvcHRpb25zLnN0YXJ0ID09IG51bGwgfHwgcm93ID4gb3B0aW9ucy5zdGFydCkge1xuICAgICAgICAgICAgICBpZiAoIWl0ZXIpIHtcbiAgICAgICAgICAgICAgICBzdHJlYW0uZW1pdCgnbGluZScsIGJ1ZmYpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGl0ZXIobnVsbCwgYnVmZik7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJvdysrO1xuICAgICAgICAgICAgYnVmZiA9ICcnO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXR1cm4gc2V0VGltZW91dChyZWFkLCAxMDAwKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBkYXRhID0gZGVjb2RlLndyaXRlKGJ1ZmZlci5zbGljZSgwLCBieXRlcykpO1xuICAgICAgICBpZiAoIWl0ZXIpIHtcbiAgICAgICAgICBzdHJlYW0uZW1pdCgnZGF0YScsIGRhdGEpO1xuICAgICAgICB9XG5cbiAgICAgICAgZGF0YSA9IChidWZmICsgZGF0YSkuc3BsaXQoL1xcbisvKTtcblxuICAgICAgICBjb25zdCBsID0gZGF0YS5sZW5ndGggLSAxO1xuICAgICAgICBsZXQgaSA9IDA7XG5cbiAgICAgICAgZm9yICg7IGkgPCBsOyBpKyspIHtcbiAgICAgICAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgZXFlcWVxXG4gICAgICAgICAgaWYgKG9wdGlvbnMuc3RhcnQgPT0gbnVsbCB8fCByb3cgPiBvcHRpb25zLnN0YXJ0KSB7XG4gICAgICAgICAgICBpZiAoIWl0ZXIpIHtcbiAgICAgICAgICAgICAgc3RyZWFtLmVtaXQoJ2xpbmUnLCBkYXRhW2ldKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGl0ZXIobnVsbCwgZGF0YVtpXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIHJvdysrO1xuICAgICAgICB9XG5cbiAgICAgICAgYnVmZiA9IGRhdGFbbF07XG4gICAgICAgIHBvcyArPSBieXRlcztcbiAgICAgICAgcmV0dXJuIHJlYWQoKTtcbiAgICAgIH0pO1xuICAgIH0oKSk7XG4gIH0pO1xuXG4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Sk7XG5cbiAgICBmdW5jdGlvbiBhZGQoYnVmZiwgYXR0ZW1wdCkge1xuICAgICAgdHJ5IHtcbiAgICAgICAgY29uc3QgbG9nID0gSlNPTi5wYXJzZShidWZmKTtcbiAgICAgICAgaWYgKGNoZWNrKGxvZykpIHtcbiAgICAgICAgICBwdXNoKGxvZyk7XG4gICAgICAgIH1cbiAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgaWYgKCFhdHRlbXB0KSB7XG4gICAgICAgICAgc3RyZWFtLmVtaXQoJ2Vycm9yJywgZSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwdXNoKGxvZykge1xuICAgICAgaWYgKFxuICAgICAgICBvcHRpb25zLnJvd3MgJiZcbiAgICAgICAgcmVzdWx0cy5sZW5ndGggPj0gb3B0aW9ucy5yb3dzICYmXG4gICAgICAgIG9wdGlvbnMub3JkZXIgIT09ICdkZXNjJ1xuICAgICAgKSB7XG4gICAgICAgIGlmIChzdHJlYW0ucmVhZGFibGUpIHtcbiAgICAgICAgICBzdHJlYW0uZGVzdHJveSgpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgaWYgKG9wdGlvbnMuZmllbGRzKSB7XG4gICAgICAgIGxvZyA9IG9wdGlvbnMuZmllbGRzLnJlZHVjZSgob2JqLCBrZXkpID0+IHtcbiAgICAgICAgICBvYmpba2V5XSA9IGxvZ1trZXldO1xuICAgICAgICAgIHJldHVybiBvYmo7XG4gICAgICAgIH0sIHt9KTtcbiAgICAgIH1cblxuICAgICAgaWYgKG9wdGlvbnMub3JkZXIgPT09ICdkZXNjJykge1xuICAgICAgICBpZiAocmVzdWx0cy5sZW5ndGggPj0gb3B0aW9ucy5yb3dzKSB7XG4gICAgICAgICAgcmVzdWx0cy5zaGlmdCgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXN1bHRzLnB1c2gobG9nKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjaGVjayhsb2cpIHtcbiAgICAgIGlmICghbG9nKSB7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgaWYgKHR5cGVvZiBsb2cgIT09ICdvYmplY3QnKSB7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgY29uc3QgdGltZSA9IG5ldyBEYXRlKGxvZy50aW1lc3RhbXApO1xuICAgICAgaWYgKFxuICAgICAgICAob3B0aW9ucy5mcm9tICYmIHRpbWUgPCBvcHRpb25zLmZyb20pIHx8XG4gICAgICAgIChvcHRpb25zLnVudGlsICYmIHRpbWUgPiBvcHRpb25zLnVudGlsKSB8fFxuICAgICAgICAob3B0aW9ucy5sZXZlbCAmJiBvcHRpb25zLmxldmVsICE9PSBsb2cubGV2ZWwpXG4gICAgICApIHtcbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBub3JtYWxpemVRdWVyeShvcHRpb25zKSB7XG4gICAgICBvcHRpb25zID0gb3B0aW9ucyB8fCB7fTtcblxuICAgICAgLy8gbGltaXRcbiAgICAgIG9wdGlvbnMucm93cyA9IG9wdGlvbnMucm93cyB8fCBvcHRpb25zLmxpbWl0IHx8IDEwO1xuXG4gICAgICAvLyBzdGFydGluZyByb3cgb2Zmc2V0XG4gICAgICBvcHRpb25zLnN0YXJ0ID0gb3B0aW9ucy5zdGFydCB8fCAwO1xuXG4gICAgICAvLyBub3dcbiAgICAgIG9wdGlvbnMudW50aWwgPSBvcHRpb25zLnVudGlsIHx8IG5ldyBEYXRlKCk7XG4gICAgICBpZiAodHlwZW9mIG9wdGlvbnMudW50aWwgIT09ICdvYmplY3QnKSB7XG4gICAgICAgIG9wdGlvbnMudW50aWwgPSBuZXcgRGF0ZShvcHRpb25zLnVudGlsKTtcbiAgICAgIH1cblxuICAgICAgLy8gbm93IC0gMjRcbiAgICAgIG9w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R1cm47XG4gICAgICAgIC8vY29uc29sZS5sb2coJ3JlcGxlbmlzaCBhd2FpdGluZycpXG4gICAgICAgIGF3YWl0aW5nID0gdHJ1ZTtcbiAgICAgICAgZ2VuZXJhdG9yLm5leHQoKS50aGVuKCh7IHZhbHVlLCBkb25lOiBpdGVyRG9uZSB9KSA9PiB7XG4gICAgICAgICAgICAvL2NvbnNvbGUubG9nKCdnb3QgdmFsdWUnLCB2YWx1ZSlcbiAgICAgICAgICAgIGlmIChjYW5jZWxlZCB8fCBkb25lKSByZXR1cm47XG4gICAgICAgICAgICBhd2FpdGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgaWYgKGl0ZXJEb25lKSB7XG4gICAgICAgICAgICAgICAgZG9uZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgaWYgKHJ1bm5pbmcgPD0gMCkge1xuICAgICAgICAgICAgICAgICAgICAvL2NvbnNvbGUubG9nKCdkb25lIG5leHRDYicpXG4gICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBydW5uaW5nKys7XG4gICAgICAgICAgICBpdGVyYXRlZSh2YWx1ZSwgaWR4LCBpdGVyYXRlZUNhbGxiYWNrKTtcbiAgICAgICAgICAgIGlkeCsrO1xuICAgICAgICAgICAgcmVwbGVuaXNoKCk7XG4gICAgICAgIH0pLmNhdGNoKGhhbmRsZUVycm9yKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBpdGVyYXRlZUNhbGxiYWNrKGVyciwgcmVzdWx0KSB7XG4gICAgICAgIC8vY29uc29sZS5sb2coJ2l0ZXJhdGVlQ2FsbGJhY2snKVxuICAgICAgICBydW5uaW5nIC09IDE7XG4gICAgICAgIGlmIChjYW5jZWxlZCkgcmV0dXJuO1xuICAgICAgICBpZiAoZXJyKSByZXR1cm4gaGFuZGxlRXJyb3IoZXJyKTtc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gICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIGRvbmUgPSB0cnVlO1xuICAgICAgICAgICAgICAgIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGVyciA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICBkb25lID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBjYW5jZWxlZCA9IHRydWU7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSBfYnJlYWtMb29wMi5kZWZhdWx0IHx8IGRvbmUgJiYgcnVubmluZyA8PSAwKSB7XG4gICAgICAgICAgICAgICAgZG9uZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKG51bGwpO1xuICAgICAgICAgICAgfSBlbHNlIGlmICghbG9vcGluZykge1xuICAgICAgICAgICAgICAgIHJlcGxlbmlzaCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gcmVwbGVuaXNoKCkge1xuICAgICAgICAgICAgbG9vcGluZyA9IHRydWU7XG4gICAgICAgICAgICB3aGlsZSAocnVubmluZyA8IGxpbWl0ICYmICFkb25lKSB7XG4gICAgICAgICAgICAgICAgdmFyIGVsZW0gPSBuZXh0RWxlbSgpO1xuICAgICAgICAgICAgICAgIGlmIChlbGVtID09PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBpZiAocnVubmluZyA8PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJ1bm5pbmcgKz0gMTtcbiAgICAgICAgICAgICAgICBpdGVyYXRlZShlbGVtLnZhbHVlLCBlbGVtLmtleSwgKDAsIF9v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AqICAgICBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsICd0d28nKTtcbiAqICAgICAgICAgfSwgMTAwKTtcbiAqICAgICB9XG4gKiBdLCBmdW5jdGlvbihlcnIsIHJlc3VsdHMpIHtcbiAqICAgICBjb25zb2xlLmxvZyhyZXN1bHRzKTtcbiAqICAgICAvLyByZXN1bHRzIGlzIGVxdWFsIHRvIFsnb25lJywndHdvJ11cbiAqIH0pO1xuICpcbiAqIC8vIGFuIGV4YW1wbGUgdXNpbmcgb2JqZWN0cyBpbnN0ZWFkIG9mIGFycmF5c1xuICogYXN5bmMuc2VyaWVzKHtcbiAqICAgICBvbmU6IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICAvLyBkbyBzb21lIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDEpO1xuICogICAgICAgICB9LCAyMDApO1xuICogICAgIH0sXG4gKiAgICAgdHdvOiBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDIpO1xuICogICAgICAgICB9LCAxMDApO1xuICogICAgIH1cbiAqIH0sIGZ1bmN0aW9uKGVyciwgcmVzdWx0cykge1xuICogICAgIGNvbnNvbGUubG9nKHJlc3VsdHMpO1xuICogICAgIC8vIHJlc3VsdHMgaXMgZXF1YWwgdG86IHsgb25lOiAxLCB0d286IDIgfVxuICogfSk7XG4gKlxuICogLy9Vc2luZyBQcm9taXNlc1xuICogYXN5bmMuc2VyaWVzKFtcbiAqICAgICBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgJ29uZScpO1xuICogICAgICAgICB9LCAyMDApO1xuICogICAgIH0sXG4gKiAgICAgZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsICd0d28nKTtcbiAqICAgICAgICAgfSwgMTAwKTtcbiAqICAgICB9XG4gKiBdKS50aGVuKHJlc3VsdHMgPT4ge1xuICogICAgIGNvbnNvbGUubG9nKHJlc3VsdHMpO1xuICogICAgIC8vIHJlc3VsdHMgaXMgZXF1YWwgdG8gWydvbmUnLCd0d28nXVxuICogfSkuY2F0Y2goZXJyID0+IHtcbiAqICAgICBjb25zb2xlLmxvZyhlcnIpO1xuICogfSk7XG4gKlxuICogLy8gYW4gZXhhbXBsZSB1c2luZyBhbiBvYmplY3QgaW5zdGVhZCBvZiBhbiBhcnJheVxuICogYXN5bmMuc2VyaWVzKHtcbiAqICAgICBvbmU6IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICAvLyBkbyBzb21lIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDEpO1xuICogICAgICAgICB9LCAyMDApO1xuICogICAgIH0sXG4gKiAgICAgdHdvOiBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDIpO1xuICogICAgICAgICB9LCAxMDApO1xuICogICAgIH1cbiAqIH0pLnRoZW4ocmVzdWx0cyA9PiB7XG4gKiAgICAgY29uc29sZS5sb2cocmVzdWx0cyk7XG4gKiAgICAgLy8gcmVzdWx0cyBpcyBlcXVhbCB0bzogeyBvbmU6IDEsIHR3bzogMiB9XG4gKiB9KS5jYXRjaChlcnIgPT4ge1xuICogICAgIGNvbnNvbGUubG9nKGVycik7XG4gKiB9KTtcbiAqXG4gKiAvL1VzaW5nIGFzeW5jL2F3YWl0XG4gKiBhc3luYyAoKSA9PiB7XG4gKiAgICAgdHJ5IHtcbiAqICAgICAgICAgbGV0IHJlc3VsdHMgPSBhd2FpdCBhc3luYy5zZXJpZXMoW1xuICogICAgICAgICAgICAgZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgICAgICAgICAvLyBkbyBzb21lIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgJ29uZScpO1xuICogICAgICAgICAgICAgICAgIH0sIDIwMCk7XG4gKiAgICAgICAgICAgICB9LFxuICogICAgICAgICAgICAgZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgICAgICAgICAvLyB0aGVuIGRvIGFub3RoZXIgYXN5bmMgdGFza1xuICogICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCAndHdvJyk7XG4gKiAgICAgICAgICAgICAgICAgfSwgMTAwKTtcbiAqICAgICAgICAgICAgIH1cbiAqICAgICAgICAgXSk7XG4gKiAgICAgICAgIGNvbnNvbGUubG9nKHJlc3VsdHMpO1xuICogICAgICAgICAvLyByZXN1bHRzIGlzIGVxdWFsIHRvIFsnb25lJywndHdvJ11cbiAqICAgICB9XG4gKiAgICAgY2F0Y2ggKGVycikge1xuICogICAgICAgICBjb25zb2xlLmxvZyhlcnIpO1xuICogICAgIH1cbiAqIH1cbiAqXG4gKiAvLyBhbiBleGFtcGxlIHVzaW5nIGFuIG9iamVjdCBpbnN0ZWFkIG9mIGFuIGFycmF5XG4gKiBhc3luYyAoKSA9PiB7XG4gKiAgICAgdHJ5IHtcbiAqICAgICAgICAgbGV0IHJlc3VsdHMgPSBhd2FpdCBhc3luYy5wYXJhbGxlbCh7XG4gKiAgICAgICAgICAgICBvbmU6IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAqICAgICAgICAgICAgICAgICAgICAgLy8gZG8gc29tZSBhc3luYyB0YXNrXG4gKiAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDEpO1xuICogICAgICAgICAgICAgICAgIH0sIDIwMCk7XG4gKiAgICAgICAgICAgICB9LFxuICogICAgICAgICAgICB0d286IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAqICAgICAgICAgICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgMik7XG4gKiAgICAgICAgICAgICAgICAgfSwgMTAwKTtcbiAqICAgICAgICAgICAgfVxuICogICAgICAgICB9KTtcbiAqICAgICAgICAgY29uc29sZS5sb2cocmVzdWx0cyk7XG4gKiAgICAgICAgIC8vIHJlc3VsdHMgaXMgZXF1YWwgdG86IHsgb25lOiAxLCB0d286IDIgfVxuICogICAgIH1cbiAqICAgICBjYXRjaCAoZXJyKSB7XG4gKiAgICAgICAgIGNvbnNvbGUubG9nKGVycik7XG4gKiAgICAgfVxuICogfVxuICpcbiAqL1xuZnVuY3Rpb24gc2VyaW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gICBlbGVtZW50LnJhdyh3cmFwQ0RBVEEob2JqKSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBlbGVtZW50LnR4dChvYmopO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShvYmopKSB7XG4gICAgICAgICAgICBmb3IgKGluZGV4IGluIG9iaikge1xuICAgICAgICAgICAgICBpZiAoIWhhc1Byb3AuY2FsbChvYmosIGluZGV4KSkgY29udGludWU7XG4gICAgICAgICAgICAgIGNoaWxkID0gb2JqW2luZGV4XTtcbiAgICAgICAgICAgICAgZm9yIChrZXkgaW4gY2hpbGQpIHtcbiAgICAgICAgICAgICAgICBlbnRyeSA9IGNoaWxkW2tleV07XG4gICAgICAgICAgICAgICAgZWxlbWVudCA9IHJlbmRlcihlbGVtZW50LmVsZShrZXkpLCBlbnRyeSkudXAoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBmb3IgKGtleSBpbiBvYmopIHtcbiAgICAgICAgICAgICAgaWYgKCFoYXNQcm9wLmNhbGwob2JqLCBrZXkpKSBjb250aW51ZTtcbiAgICAgICAgICAgICAgY2hpbGQgPSBvYmpba2V5XTtcbiAgICAgICAgICAgICAgaWYgKGtleSA9PT0gYXR0cmtleSkge1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgY2hpbGQgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICAgIGZvciAoYXR0ciBpbiBjaGlsZCkge1xuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IGNoaWxkW2F0dHJdO1xuICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZWxlbWVudC5hdHQoYXR0ciwgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChrZXkgPT09IGNoYXJrZXkpIHtcbiAgICAgICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5jZGF0YSAmJiByZXF1aXJlc0NEQVRBKGNoaWxkKSkge1xuICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQucmF3KHdyYXBDREFUQShjaGlsZCkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZWxlbWVudC50eHQoY2hpbGQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KGNoaWxkKSkge1xuICAgICAgICAgICAgICAgIGZvciAoaW5kZXggaW4gY2hpbGQpIHtcbiAgICAgICAgICAgICAgICAgIGlmICghaGFzUHJvcC5jYWxsKGNoaWxkLCBpbmRleCkpIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgICAgZW50cnkgPSBjaGlsZFtpbmRleF07XG4gICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5jZGF0YSAmJiByZXF1aXJlc0NEQVRBKGVudHJ5KSkge1xuICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LmVsZShrZXkpLnJhdyh3cmFwQ0RBVEEoZW50cnkpKS51cCgpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LmVsZShrZXksIGVudHJ5KS51cCgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gcmVuZGVyKGVsZW1lbnQuZWxlKGtleSksIGVudHJ5KS51cCgpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgY2hpbGQgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICBlbGVtZW50ID0gcmVuZGVyKGVsZW1lbnQuZWxlKGtleSksIGNoaWxkKS51cCgpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgY2hpbGQgPT09ICdzdHJpbmcnICYmIF90aGlzLm9wdGlvbnMuY2RhdGEgJiYgcmVxdWlyZXNDREFUQShjaGlsZCkpIHtcbiAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LmVsZShrZXkpLnJhdyh3cmFwQ0RBVEEoY2hpbGQpKS51cCgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZCA9ICcnO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQuZWxlKGtleSwgY2hpbGQudG9TdHJpbmcoKSkudXAoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIGVsZW1lbnQ7XG4gICAgICAgIH07XG4gICAgICB9KSh0aGlzKTtcbiAgICAgIHJvb3RFbGVtZW50ID0gYnVpbGRlci5jcmVhdGUocm9vdE5hbWUsIHRoaXMub3B0aW9ucy54bWxkZWMsIHRoaXMub3B0aW9ucy5kb2N0eXBlLCB7XG4gICAgICAgIGhlYWRsZXNzOiB0aGlzLm9wdGlvbnMuaGVhZGxlc3MsXG4gICAgICAgIGFsbG93U3Vycm9nYXRlQ2hhcnM6IHRoaXMub3B0aW9ucy5hbGxvd1N1cnJvZ2F0ZUNoYXJzXG4gICAgICB9KTtcbiAgICAgIHJldHVybiByZW5kZX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4gICAgICAgIGlmICghdGhpcy5zYXhQYXJzZXIuZXJyVGhyb3duKSB7XG4gICAgICAgICAgdGhpcy5zYXhQYXJzZXIuZXJyVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICByZXR1cm4gdGhpcy5lbWl0KGVycik7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9O1xuXG4gICAgUGFyc2VyLnByb3RvdHlwZS5hc3NpZ25PclB1c2ggPSBmdW5jdGlvbihvYmosIGtleSwgbmV3VmFsdWUpIHtcbiAgICAgIGlmICghKGtleSBpbiBvYmopKSB7XG4gICAgICAgIGlmICghdGhpcy5vcHRpb25zLmV4cGxpY2l0QXJyYXkpIHtcbiAgICAgICAgICByZXR1cm4gb2JqW2tleV0gPSBuZXdWYWx1ZTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZXR1cm4gb2JqW2tleV0gPSBbbmV3VmFsdWVdO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAoIShvYmpba2V5XSBpbnN0YW5jZW9mIEFycmF5KSkge1xuICAgICAgICAgIG9ialtrZXldID0gW29ialtrZXldXTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gb2JqW2tleV0ucHVzaChuZXdWYWx1ZSk7XG4gICAgICB9XG4gICAgfTtcblxuICAgIFBhcnNlci5wcm90b3R5cGUucmVzZXQgPSBmdW5jdGlvbigpIHtcbiAgICAgIHZhciBhdHRya2V5LCBjaGFya2V5LCBvbnRleHQsIHN0YWNrO1xuICAgICAgdGhpcy5yZW1vdmVBbGxMaXN0ZW5lcnMoKTtcbiAgICAgIHRoaXMuc2F4UGFyc2VyID0gc2F4LnBhcnNlcih0aGlzLm9wdGlvbnMuc3RyaWN0LCB7XG4gICAgICAgIHRyaW06IGZhbHNlLFxuICAgICAgICBub3JtYWxpemU6IGZhbHNlLFxuICAgICAgICB4bWxuczogdGhpcy5vcHRpb25zLnhtbG5zXG4gICAgICB9KTtcbiAgICAgIHRoaX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8fCAhX3RoaXMub3B0aW9ucy5wcmVzZXJ2ZUNoaWxkcmVuT3JkZXIpIHtcbiAgICAgICAgICAgIGRlbGV0ZSBvYmpbXCIjbmFtZVwiXTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG9iai5jZGF0YSA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgY2RhdGEgPSBvYmouY2RhdGE7XG4gICAgICAgICAgICBkZWxldGUgb2JqLmNkYXRhO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gMV07XG4gICAgICAgICAgaWYgKG9ialtjaGFya2V5XS5tYXRjaCgvXlxccyokLykgJiYgIWNkYXRhKSB7XG4gICAgICAgICAgICBlbXB0eVN0ciA9IG9ialtjaGFya2V5XTtcbiAgICAgICAgICAgIGRlbGV0ZSBvYmpbY2hhcmtleV07XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLnRyaW0pIHtcbiAgICAgICAgICAgICAgb2JqW2NoYXJrZXldID0gb2JqW2NoYXJrZXldLnRyaW0oKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLm5vcm1hbGl6ZSkge1xuICAgICAgICAgICAgICBvYmpbY2hhcmtleV0gPSBvYmpbY2hhcmtleV0ucmVwbGFjZSgvXFxzezIsfS9nLCBcIiBcIikudHJpbSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgb2JqW2NoYXJrZXldID0gX3RoaXMub3B0aW9ucy52YWx1ZVByb2Nlc3NvcnMgPyBwcm9jZXNzSXRlbShfdGhpcy5vcHRpb25zLnZhbHVlUHJvY2Vzc29ycywgb2JqW2NoYXJrZXldLCBub2RlTmFtZSkgOiBvYmpbY2hhcmtleV07XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXMob2JqKS5sZW5ndGggPT09IDEgJiYgY2hhcmtleSBpbiBvYmogJiYgIV90aGlzLkVYUExJQ0lUX0NIQVJLRVkpIHtcbiAgICAgICAgICAgICAgb2JqID0gb2JqW2NoYXJrZXldO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaXNFbXB0eShvYmopKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIF90aGlzLm9wdGlvbnMuZW1wdHlUYWcgPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICAgICAgb2JqID0gX3RoaXMub3B0aW9ucy5lbXB0eVRhZygpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgb2JqID0gX3RoaXMub3B0aW9ucy5lbXB0eVRhZyAhPT0gJycgPyBfdGhpcy5vcHRpb25zLmVtcHR5VGFnIDogZW1wdHlTdHI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLnZhbGlkYXRvciAhPSBudWxsKSB7XG4gICAgICAgICAgICB4cGF0aCA9IFwiL1wiICsgKChmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgdmFyIGksIGxlbiwgcmVzdWx0cztcbiAgICAgICAgICAgICAgcmVzdWx0cyA9IFtdO1xuICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBzdGFjay5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgICAgIG5vZGUgPSBzdGFja1tpXTtcbiAgICAgICAgICAgICAgICByZXN1bHRzLnB1c2gobm9kZVtcIiNuYW1lXCJdKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0cztcbiAgICAgICAgICAgIH0pKCkpLmNvbmNhdChub2RlTmFtZSkuam9pbihcIi9cIik7XG4gICAgICAgICAgICAoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgIHZhciBlcnI7XG4gICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iaiA9IF90aGlzLm9wdGlvbnMudmFsaWRhdG9yKHhwYXRoLCBzICYmIHNbbm9kZU5hbWVdLCBvYmopO1xuICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcjEpIHtcbiAgICAgICAgICAgICAgICBlcnIgPSBlcnJvcjE7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLmVtaXQoXCJlcnJvclwiLCBlcnIpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5leHBsaWNpdENoaWxkcmVuICYmICFfdGhpcy5vcHRpb25zLm1lcmdlQXR0cnMgJiYgdHlwZW9mIG9iaiA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgIGlmICghX3RoaXMub3B0aW9ucy5wcmVzZXJ2ZUNoaWxkcmVuT3JkZXIpIHtcbiAgICAgICAgICAgICAgbm9kZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLmF0dHJrZXkgaW4gb2JqKSB7XG4gICAgICAgICAgICAgICAgbm9kZVtfdGhpcy5vcHRpb25zLmF0dHJrZXldID0gb2JqW190aGlzLm9wdGlvbnMuYXR0cmtleV07XG4gICAgICAgICAgICAgICAgZGVsZXRlIG9ialtfdGhpcy5vcHRpb25zLmF0dHJrZXldO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmICghX3RoaXMub3B0aW9ucy5jaGFyc0FzQ2hpbGRyZW4gJiYgX3RoaXMub3B0aW9ucy5jaGFya2V5IGluIG9iaikge1xuICAgICAgICAgICAgICAgIG5vZGVbX3RoaXMub3B0aW9ucy5jaGFya2V5XSA9IG9ialtfdGhpcy5vcHRpb25zLmNoYXJrZXldO1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBvYmpbX3RoaXMub3B0aW9ucy5jaGFya2V5XTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMob2JqKS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgbm9kZVtfdGhpcy5vcHRpb25zLmNoaWxka2V5XSA9IG9iajtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBvYmogPSBub2RlO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChzKSB7XG4gICAgICAgICAgICAgIHNbX3RoaXMub3B0aW9ucy5jaGlsZGtleV0gPSBzW190aGlzLm9wdGlvbnMuY2hpbGRrZXldIHx8IFtdO1xuICAgICAgICAgICAgICBvYmpDbG9uZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgICAgICAgICAgIGZvciAoa2V5IGluIG9iaikge1xuICAgICAgICAgICAgICAgIGlmICghaGFzUHJvcC5jYWxsKG9iaiwga2V5KSkgY29udGludWU7XG4gICAgICAgICAgICAgICAgb2JqQ2xvbmVba2V5XSA9IG9ialtrZXldO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHNbX3RoaXMub3B0aW9ucy5jaGlsZGtleV0ucHVzaChvYmpDbG9uZSk7XG4gICAgICAgICAgICAgIGRlbGV0ZSBvYmpbXCIjbmFtZVwiXTtcbiAgICAgICAgICAgICAgaWYgKE9iamVjdC5rZXlzKG9iaikubGVuZ3RoID09PSAxICYmIGNoYXJrZXkgaW4gb2JqICYmICFfdGhpcy5FWFBMSUNJVF9DSEFSS0VZKSB7XG4gICAgICAgICAgICAgICAgb2JqID0gb2JqW2NoYXJrZXldO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICByZXR1cm4gX3RoaXMuYXNzaWduT3JQdXNoKHMsIG5vZGVOYW1lLCBvYmopO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5leHBsaWNpdFJvb3QpIHtcbiAgICAgICAgICAgICAgb2xkID0gb2JqO1xuICAgICAgICAgICAgICBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICAgICAgICBvYmpbbm9kZU5hbWVdID0gb2xkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX3RoaXMucmVzdWx0T2JqZWN0ID0gb2JqO1xuICAgICAgICAgICAgX3RoaXMuc2F4UGFyc2VyLmVuZGVkID0gdHJ1ZTtcbiAgICAgICAgICAgIHJldHVybiBfdGhpcy5lbWl0KFwiZW5kXCIsIF90aGlzLnJlc3VsdE9iamVjdCk7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgfSkodGhpcyk7XG4gICAgICBvbnRleHQgPSAoZnVuY3Rpb24oX3RoaXMpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRleHQpIHtcbiAgICAgICAgICB2YXIgY2hhckNoaWxkLCBzO1xuICAgICAgICAgIHMgPSBzdGFja1tzdGFjay5sZW5ndGggLSAxXTtcbiAgICAgICAgICBpZiAocykge1xuICAgICAgICAgICAgc1tjaGFya2V5XSArPSB0ZXh0O1xuICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMuZXhwbGljaXRDaGlsZHJlbiAmJiBfdGhpcy5vcHRpb25zLnByZXNlcnZlQ2hpbGRyZW5PcmRlciAmJiBfdGhpcy5vcHRpb25zLmNoYXJzQXNDaGlsZHJlbiAmJiAoX3RoaXMub3B0aW9ucy5pbmNsdWRlV2hpdGVDaGFycyB8fCB0ZXh0LnJlcGxhY2UoL1xcXFxuL2csICcnKS50cmltKCkgIT09ICcnKSkge1xuICAgICAgICAgICAgICBzW190aGlzLm9wdGlvbnMuY2hpbGRrZXldID0gc1tfdGhpcy5vcHRpb25zLmNoaWxka2V5XSB8fCBbXTtcbiAgICAgICAgICAgICAgY2hhckNoaWxkID0ge1xuICAgICAgICAgICAgICAgICcjbmFtZSc6ICdfX3RleHRfXydcbiAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgY2hhckNoaWxkW2NoYXJrZXldID0gdGV4dDtcbiAgICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMubm9ybWFsaXplKSB7XG4gICAgICAgICAgICAgICAgY2hhckNoaWxkW2NoYXJrZXldID0gY2hhckNoaWxkW2NoYXJrZXldLnJlcGxhY2UoL1xcc3syLH0vZywgXCIgXCIpLnRyaW0oKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBzW190aGlzLm9wdGlvbnMuY2hpbGRrZXldLnB1c2goY2hhckNoaWxkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBzO1xuICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgIH0pKHRoaXMpO1xuICAgICAgdGhpcy5zYXhQYXJzZXIub250ZXh0ID0gb250ZXh0O1xuICAgICAgcmV0dXJuIHRoaXMuc2F4UGFyc2VyLm9uY2RhdGEgPSAoZnVuY3Rpb24oX3RoaXMpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRleHQpIHtcbiAgICAgICAgICB2YXIgcztcbiAgICAgICAgICBzID0gb250ZXh0KHRleHQpO1xuICAgICAgICAgIGlmIChzKSB7XG4gICAgICAgICAgICByZXR1cm4gcy5jZGF0YSA9IHRydWU7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgfSkodGhpcyk7XG4gICAgfTtcblxuICAgIFBhcnNlci5wcm90b3R5cGUucGFyc2VTdHJpbmcgPSBmdW5jdGlvbihzdHIsIGNiKSB7XG4gICAgICB2YXIgZXJyO1xuICAgICAgaWYgKChjYiAhPSBudWxsKSAmJiB0eXBlb2YgY2IgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICB0aGlzLm9uKFwiZW5kXCIsIGZ1bmN0aW9uKHJlc3VsdCkge1xuICAgICAgICAgIHRoaXMucmVzZXQoKTtcbiAgICAgICAgICByZXR1cm4gY2IobnVsbCwgcmVzdWx0KTtcbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMub24oXCJlcnJvclwiLCBmdW5jdGlvbihlcnIpIHtcbiAgICAgICAgICB0aGlzLnJlc2V0KCk7XG4gICAgICAgICAgcmV0dXJuIGNiKGVycik7XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgICAgdHJ5IHtcbiAgICAgICAgc3RyID0gc3RyLnRvU3RyaW5nKCk7XG4gICAgICAgIGlmIChzdHIudHJpbSgpID09PSAnJykge1xuICAgICAgICAgIHRoaXMuZW1pdChcImVuZFwiLCBudWxsKTtcbiAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICBzdHIgPSBib20uc3RyaXBCT00oc3RyKTtcbiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5hc3luYykge1xuICAgICAgICAgIHRoaXMucmVtYWluaW5nID0gc3RyO1xuICAgICAgICAgIHNldEltbWVkaWF0ZSh0aGlzLnByb2Nlc3NBc3luYyk7XG4gICAgICAgICAgcmV0dXJuIHRoaXMuc2F4UGFyc2VyO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLnNheFBhcnNlci53cml0ZShzdHIpLmNsb3NlKCk7XG4gICAgICB9IGNhdGNoIChlcnJvcjEpIHtcbiAgICAgICAgZXJyID0gZXJyb3IxO1xuICAgICAgICBpZiAoISh0aGlzLnNheFBhcnNlci5lcnJUaHJvd24gfHwgdGhpcy5zYXhQYXJzZXIuZW5kZWQpKSB7XG4gICAgICAgICAgdGhpcy5lbWl0KCdlcnJvcicsIGVycik7XG4gICAgICAgICAgcmV0dXJuIHRoaXMuc2F4UGFyc2VyLmVyclRocm93biA9IHRydWU7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zYXhQYXJzZXIuZW5kZWQpIHtcbiAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9O1xuXG4gICAgUGFyc2VyLnByb3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FBVQkxJQyBcIicgKyBub2RlLnB1YklEICsgJ1wiIFwiJyArIG5vZGUuc3lzSUQgKyAnXCInO1xuICAgICAgICAgIH0gZWxzZSBpZiAobm9kZS5zeXNJRCkge1xuICAgICAgICAgICAgY2h1bmsgKz0gJyBTWVNURU0gXCInICsgbm9kZS5zeXNJRCArICdcIic7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChub2RlLmNoaWxkcmVuKSB7XG4gICAgICAgICAgICBjaHVuayArPSAnIFsnO1xuICAgICAgICAgICAgdGhpcy53cml0ZXJPcHRpb25zLnN0YXRlID0gV3JpdGVyU3RhdGUuSW5zaWRlVGFnO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLndyaXRlck9wdGlvbnMuc3RhdGUgPSBXcml0ZXJTdGF0ZS5DbG9zZVRhZztcbiAgICAgICAgICAgIGNodW5rICs9ICc+JztcbiAgICAgICAgICB9XG4gICAgICAgICAgY2h1bmsgKz0gdGhpcy53cml0ZXIuZW5kbGluZShub2RlLCB0aGlzLndyaXRlck9wdGlvbnMsIHRoaXMuY3VycmVudExldmVsKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm9uRGF0YShjaHVuaywgdGhpcy5jdXJyZW50TGV2ZWwpO1xuICAgICAgICByZXR1cm4gbm9kZS5pc09wZW4gPSB0cnVlO1xuICAgICAgfVxuICAgIH07XG5cbiAgICBYTUxEb2N1bWVudENCLnByb3RvdHlwZS5jbG9zZU5vZGUgPSBmdW5jdGlvbihub2RlKSB7XG4gICAgICB2YXIgY2h1bms7XG4gICAgICBpZiAoIW5vZGUuaXNDbG9zZWQpIHtcbiAgICAgICAgY2h1bmsgPSAnJztcbiAgICAgICAgdGhpcy53cml0ZXJPcHRpb25zLnN0YXRlID0gV3JpdGVyU3RhdGUuQ2xvc2VUYWc7XG4gICAgICAgIGlmIChub2RlLnR5cGUgPT09IE5vZGVUeXBlLkVsZW1lbnQpIHtcbiAgICAgICAgICBjaHVuayA9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VHlwZSA9PT0gTm9kZVR5cGUuRWxlbWVudCB8fCB0aGlzLm5vZGVUeXBlID09PSBOb2RlVHlwZS5Eb2N1bWVudEZyYWdtZW50KSB7XG4gICAgICAgICAgc3RyID0gJyc7XG4gICAgICAgICAgcmVmMiA9IHRoaXMuY2hpbGRyZW47XG4gICAgICAgICAgZm9yIChqID0gMCwgbGVuID0gcmVmMi5sZW5ndGg7IGogPCBsZW47IGorKykge1xuICAgICAgICAgICAgY2hpbGQgPSByZWYyW2pdO1xuICAgICAgICAgICAgaWYgKGNoaWxkLnRleHRDb250ZW50KSB7XG4gICAgICAgICAgICAgIHN0ciArPSBjaGlsZC50ZXh0Q29udGVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHN0cjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVGhpcyBET00gbWV0aG9kIGlzIG5vdCBpbXBsZW1lbnRlZC5cIiArIHRoaXMuZGVidWdJbmZvKCkpO1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgWE1MTm9kZS5wcm90b3R5cGUuc2V0UGFyZW50ID0gZnVuY3Rpb24ocGFyZW50KSB7XG4gICAgICB2YXIgY2hpbGQsIGosIGxlbiwgcmVmMiwgcmVzdWx0cztcbiAgICAgIHRoaXMucGFyZW50ID0gcGFyZW50O1xuICAgICAgaWYgKHBhcmVudCkge1xuICAgICAgICB0aGlzLm9wdGlvbnMgPSBwYXJlbnQub3B0aW9ucztcbiAgICAgICAgdGhpcy5zdHJpbmdpZnkgPSBwYXJlbnQuc3RyaW5naWZ5O1xuICAgICAgfVxuICAgICAgcmVmMiA9IHRoaXMuY2hpbGRyZW47XG4gICAgICByZXN1bHRzID0gW107XG4gICAgICBmb3IgKGogPSAw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lRoZSByb290IG5vZGUgaGFzIG5vIHBhcmVudC4gVXNlIGRvYygpIGlmIHlvdSBuZWVkIHRvIGdldCB0aGUgZG9jdW1lbnQgb2JqZWN0LlwiKTtcbiAgICAgIH1cbiAgICAgIHJldHVybiB0aGlzLnBhcmVudDtcbiAgICB9O1xuXG4gICAgWE1MTm9kZS5wcm90b3R5cGUucm9vdCA9IGZ1bmN0aW9uKCkge1xuICAgICAgdmFyIG5vZGU7XG4gICAgICBub2RlID0gdGhpcztcbiAgICAgIHdoaWxlIChub2RlKSB7XG4gICAgICAgIGlmIChub2RlLnR5cGUgPT09IE5vZGVUeXBlLkRvY3VtZW50KSB7XG4gICAgICAgICAgcmV0dXJuIG5vZGUucm9vdE9iamVjdDtcbiAgICAgICAgfSBlbHNlIGlmIChub2RlLmlzUm9vdCkge1xuICAgICAgICAgIHJldHVybiBub2RlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG5vZGUgPSBub2RlLnBhcmVudDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH07XG5cbiAgICBYTUxOb2RlLnByb3RvdHlwZS5kb2N1bWVudCA9IGZ1bmN0aW9uKCkge1xuICAgICAgdmFyIG5vZGU7XG4gICAgICBub2RlID0gdGhpcztcbiAgICAgIHdoaWxlIChub2RlKSB7XG4gICAgICAgIGlmIChub2RlLnR5cGUgPT09IE5vZGVUeXBlLkRvY3VtZW50KSB7XG4gICAgICAgICAgcmV0dXJuIG5vZGU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbm9kZSA9IG5vZGUucGFyZW50O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfTtcblxuICAgIFhNTE5vZGUucHJvdG90eXBlLmVuZCA9IGZ1bmN0aW9uKG9wdGlvbnMpIHtcbiAgICAgIHJldHVybiB0aGlzLmRvY3VtZW50KCkuZW5kKG9wdGlvbnMpO1xuICAgIH07XG5cbiAgICBYTUxOb2RlLnByb3RvdHlwZS5wcmV2ID0gZnVuY3R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ICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAob3B0aW9ucy5kb250UHJldHR5VGV4dE5vZGVzKSB7XG4gICAgICAgICAgcmVmMSA9IG5vZGUuY2hpbGRyZW47XG4gICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcmVmMS5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgY2hpbGQgPSByZWYxW2ldO1xuICAgICAgICAgICAgaWYgKChjaGlsZC50eXBlID09PSBOb2RlVHlwZS5UZXh0IHx8IGNoaWxkLnR5cGUgPT09IE5vZGVUeXBlLlJhdykgJiYgKGNoaWxkLnZhbHVlICE9IG51bGwpKSB7XG4gICAgICAgICAgICAgIG9wdGlvbnMuc3VwcHJlc3NQcmV0dHlDb3VudCsrO1xuICAgICAgICAgICAgICBwcmV0dHlTdXBwcmVzc2VkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHIgKz0gJz4nICsgdGhpcy5lbmRsaW5lKG5vZGUsIG9wdGlvbnMsIGxldmVsKTtcbiAgICAgICAgb3B0aW9ucy5zdGF0ZSA9IFdyaXRlclN0YXRlLkluc2lkZVRhZztcbiAgICAgICAgcmVmMiA9IG5vZGUuY2hpbGRyZW47XG4gICAgICAgIGZvciAoaiA9IDAsIGxlbjEgPSByZWYyLmxlbmd0aDsgaiA8IGxlbjE7IGorKykge1xuICAgICAgICAgIGNoaWxkID0gcmVmMltqXTtcbiAgICAgICAgICByICs9IHRoaXMud3JpdGVDaGlsZE5vZGUoY2hpbGQsIG9wdGlvbnMsIGxldmVsICsgMSk7XG4gICAgICAgIH1cbiAgICAgICAgb3B0aW9ucy5zdGF0ZSA9IFdyaXRlclN0YXRlLkNsb3NlVGFnO1xuICAgICAgICByICs9IHRoaXMuaW5kZW50KG5vZGUsIG9wdGlvbnMsIGxldmVsKSArICc8LycgKyBub2RlLm5hbWUgKyAnPic7X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biAgICAgICAgeTogNSxcbiAgICAgICAgVGl0bGU6IHt9LFxuICAgICAgfSxcbiAgICAgIHc6IDE5MjAsXG4gICAgICBoOiAxMDgwLFxuICAgICAgTWFpbjoge1xuICAgICAgICB3OiAodykgPT4gdyAtIDEwMCxcbiAgICAgICAgaDogKGgpID0+IGggLSAxMDAsXG4gICAgICB9LFxuICAgICAgT3ZlcmxheXM6IHtcbiAgICAgICAgdzogKHcpID0+IHcsXG4gICAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICBjb2xvcjogMHhiYjAwMDAwMCxcbiAgICAgICAgekluZGV4OiA1MCxcbiAgICAgICAgYWxwaGE6IDAsXG4gICAgICB9LFxuICAgICAgVG9hc3Q6IHtcbiAgICAgICAgdHlwZTogVG9hc3QsXG4gICAgICAgIHJlZjogJ1RvYXN0JyxcbiAgICAgICAgYWxwaGE6IDAsXG4gICAgICAgIHk6IDM4MCxcbiAgICAgIH0sXG4gICAgICBUb2FzdENvbXBsOiB7XG4gICAgICAgIHR5cGU6IFRvYXN0LFxuICAgICAgICByZWY6ICdUb2FzdENvbXBsJyxcbiAgICAgICAgeTogNTQwLFxuICAgICAgICBhbHBoYTogMCxcbiAgICAgIH0sXG4gICAgfTtcbiAgfVxuXG4gIGFzeW5jIF9pbml0KCkge1xuICAgIFNldHRpbmdzLnNldExvZ0xldmVsKCdERUJVRycpO1xuICAgIGV2ZW50RW1pdHRlci5vbignc2hvd1RvYXN0JywgKG1lc3NhZ2UsIHN0YXRlLCB0YWdOYW1lLCBjb2xvcikgPT4ge1xuICAgICAgdGhpcy5zaG93VG9hc3QobWVzc2FnZSwgc3RhdGUsIHRhZ05hbWUsIGNvbG9yKTtcbiAgICB9KTtcbiAgICBldmVudEVtaXR0ZXIub24oJ2FjY2Vzc2liaWxpdHlDaGVjaycsICh2b2ljZUFubm91bmNlbWVudCkgPT4ge1xuICAgICAgdGhpcy5hY2Nlc3NpYmlsaXR5Q2hlY2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yeS5wcm92aWRlKCd4cm46ZmlyZWJvbHQ6Y2FwYWJpbGl0eTpkaXNjb3Zlcnk6aW50ZXJlc3QnLCBuZXcgVXNlckludGVyZXN0RGVsZWdhdGVyKHRoaXMpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICBsb2dnZXIuZXJyb3IoJ0NvdWxkIG5vdCBzZXQgdXAgcHJvdmlkZXJzJyArIGVyciwgJ0xvYWRlZFN0YXRlJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcm9jZXNzLmVudi5BUFBPQkpFQ1QgPSB0aGlzO1xuICAgICAgICAgICAgY29uc3QgbWVudXNCdWlsZGVyID0gbmV3IE1lbnVCdWlsZGVyKCk7XG4gICAgICAgICAgICBMaWZlY3ljbGVIaXN0b3J5LmdldCgpLmluaXQodGhpcyk7XG4gICAgICAgICAgICBjb25zdCBtZW51ID0gbmV3IFVSTFNlYXJjaFBhcmFtcyh3aW5kb3cubG9jYXRpb24uc2VhcmNoKS5nZXQoJ21lbnUnKTtcbiAgICAgICAgICAgIHRoaXMudGFnKCdNYWluJykucGF0Y2goe1xuICAgICAgICAgICAgICBNYWluTWVudToge1xuICAgICAgICAgICAgICAgIHR5cGU6IE1lbnUsXG4gICAgICAgICAgICAgICAgbWVudXM6IG1lbnVzQnVpbGRlci5idWlsZCgpLFxuICAgICAgICAgICAgICAgIGluaXRpYWxNZW51OiBtZW51LFxuICAgICAgICAgICAgICAgIHg6IDUwLFxuICAgICAgICAgICAgICAgIHk6IDUwLFxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIGlmICghdGhpcy5wdWJTdWJVdWlkUHJlc2VudCAmJiBzeXN0ZW11aSA9PT0gJ3RydWUnKSB7XG4gICAgICAgICAgICAgIHRoaXMuc2V0QXBwSWQoQ09OU1RBTlRTLkZJUkVCT0xUX0N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ycpO1xuICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgTW9kYWw6IHtcbiAgICAgICAgICAgICAgdHlwZTogTW9kYWwsXG4gICAgICAgICAgICB9LFxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIC8vIHNoaWZ0IGZvY3VzIHRvIG1vZGFsXG4gICAgICAgIF9nZXRGb2N1c2VkKCkge1xuICAgICAgICAgIHJldHVybiB0aGlzLnRhZygnTW9kYWwnKTtcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIGNsYXNzIFRvYXN0U3RhdGUgZXh0ZW5kcyB0aGlzIHtcbiAgICAgICAgJGVudGVyKCkge1xuICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgVG9hc3Q6IHtcbiAgICAgICAgICAgICAgdHlwZTogVG9hc3QsXG4gICAgICAgICAgICB9LFxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIC8vIHNoaWZ0IGZvY3VzIHRvIFRvYXN0XG4gICAgICAgIF9nZXRGb2N1c2VkKCkge1xuICAgICAgICAgIHJldHVybiB0aGlzLnRhZygnVG9hc3QnKTtcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIGNsYXNzIFRvYXN0U3RhdGVDb21wbCBleHRlbmRzIHRoaXMge1xuICAgICAgICAkZW50ZXIoKSB7XG4gICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBUb2FzdDoge1xuICAgICAgICAgICAgICB0eXBlOiBUb2FzdCxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgLy8gc2hpZnQgZm9jdXMgdG8gVG9hc3RcbiAgICAgICAgX2dldEZvY3VzZWQoKSB7XG4gICAgICAgICAgcmV0dXJuIHRoaXMudGFnKCdUb2FzdENvbXBsJyk7XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgXTtcbiAgfVxuXG4gIF9jYXB0dXJlQmFjay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VycyBmcm9tICcuL01ldGhvZEZpbHRlcnMnO1xuaW1wb3J0IGV4dGVybmFsSW52b2tlcnMgZnJvbSAnZXh0ZXJuYWxJbnZva2Vycyc7XG5cbmNvbnN0IGxvZ2dlciA9IHJlcXVpcmUoJy4vdXRpbHMvTG9nZ2VyJykoJ0NhcmRzLmpzJyk7XG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIENhcmQgZXh0ZW5kcyBsbmcuQ29tcG9uZW50IHtcbiAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICByZXR1cm4ge1xuICAgICAgeDogMCxcbiAgICAgIHk6IDAsXG4gICAgICB3OiAodykgPT4gdyxcbiAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgQmFja2dyb3VuZDoge1xuICAgICAgICB3OiAodykgPT4gdyxcbiAgICAgICAgaDogKGgpID0+IGgsXG4gICAgICB9LFxuICAgICAgVGl0bGU6IHtcbiAgICAgICAgeDogMTAwLFxuICAgICAgICB5OiA1MCxcbiAgICAgICAgdzogKHcpID0+IHcgLSAxMDAsXG4gICAgICAgIGg6IDEwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiA0NSxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBTdW1tYXJ5OiB7XG4gICAgICAgIHg6IDE1MCxcbiAgICAgICAgeTogMjAwLFxuICAgICAgICB3OiA3NTAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogMzUsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgRXhhbXBsZVRleHQ6IHtcbiAgICAgICAgeDogMTAwLFxuICAgICAgICB5OiAzMDAsXG4gICAgICAgIHc6IDc1MCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAzMCxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBSZXN1bHRUZXh0Qmc6IHtcbiAgICAgICAgeDogODAwLFxuICAgICAgICB5Oi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i91dGlscy9Mb2dnZXInKSgnTWVkaWFWaWV3LmpzJyk7XG5leHBvcnQgZGVmYXVsdCBjbGFzcyBNZWRpYVZpZXcgZXh0ZW5kcyBsbmcuQ29tcG9uZW50IHtcbiAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICByZXR1cm4ge1xuICAgICAgeDogMCxcbiAgICAgIHk6IDAsXG4gICAgICB3OiAodykgPT4gdyxcbiAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgUGxheWVyOiB7XG4gICAgICAgIHg6IDUwLFxuICAgICAgICB5OiA1MCxcbiAgICAgICAgdzogOTYwLFxuICAgICAgICBoOiA1NDAsXG4gICAgICAgIHR5cGU6IE1lZGlhUGxheWVyLFxuICAgICAgfSxcbiAgICAgIFJvdzoge1xuICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgIG5ldmVyU2Nyb2xsOiB0cnVlLFxuICAgICAgICB4OiA1MCxcbiAgICAgICAgeTogMTA4MCAtIDIwMCxcbiAgICAgICAgdzogKHcpID0+IHcsXG4gICAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgICBpdGVtU3BhY2luZzogNTAsXG4gICAgICAgIGl0ZW1zOiBbXG4gICAgICAgICAge1xuICAgICAgICAgICAgcmVmOiAnUGxheScsXG4gICAgICAgICAgICB0eXBlOiBCdXR0b24sXG4gICAgICAgICAgICB0aXRsZTogJ1BsYXknLFxuICAgICAgICAgICAgdzogMjAwLFxuICAgICAgICAgICAgZml4ZWQ6IHRydWUsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kVHlwZTogJ3N0cm9rZScsXG4gICAgICAgICAgICBvbkVudGVyOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycygnJHBsYXknKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgfSxcbiAgICAgICAgICB7XG4gICAgICAgICAgICByZWY6ICdUb2dnbGVJbmFjdGl2ZScsXG4gICAgICAgICAgICB0eXB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dGVuZXJJZCcsXG4gICAgICAgICAgdmFsdWU6ICcxMjMnLFxuICAgICAgICB9LFxuICAgICAgfSk7XG4gICAgfVxuICB9XG5cbiAgYWRkUHJvcGVydHlFeGFtcGxlcyhtZXRob2RPYmosIE9QRU5fUlBDKSB7XG4gICAgY29uc3QgZXhhbXBsZXMgPSBtZXRob2RPYmouZXhhbXBsZXM7XG4gICAgaWYgKChoYXNUYWcobWV0aG9kT2JqLCAncHJvcGVydHknKSB8fCBoYXNUYWcobWV0aG9kT2JqLCAncHJvcGVydHk6cmVhZG9ubHknKSkgJiYgIWhhc1RhZyhtZXRob2RPYmosICdwcm9wZXJ0eTppbW11dGFibGUnKSkge1xuICAgICAgZXhhbXBsZXMucHVzaCh7XG4gICAgICAgIG5hbWU6IENPTlNUQU5UUy5TVUJTQ1JJQkUgKyAnICcgKyBtZXRob2RPYmoubmFtZSxcbiAgICAgICAgc2NoZW1hOiB7XG4gICAgICAgICAgdHlwZTogJ251bWJlcicsXG4gICAgICAgIH0sXG4gICAgICAgIHBhcmFtczogW1xuICAgICAgICAgIHtcbiAgICAgICAgICAgIG5hbWU6ICdjYWxsYmFjaycsXG4gICAgICAgICAgICB2YWx1ZTogKCkgPT4ge30sXG4gICAgICAgICAgfSxcbiAgICAgICAgXSxcbiAgICAgICAgcmVzdWx0OiB7XG4gICAgICAgICAgbmFtZTogJ2xpc3RlbmVySWQnLFxuICAgICAgICAgIHZhbHVlOiAnMTIzJyxcbiAgICAgICAgfSxcbiAgICAgIH0pO1xuICAgIH1cbiAgfVxuXG4gIGJ1aWxkTWVudXNGcm9tT3BlblJwYygpIHtcbiAgICBjb25zdCBidWlsZE1lbnVzID0gW107XG4gICAgY29uc3QgbWVyZ2VkU0RLcyA9IENPTlNUQU5UUy5kZWZhdWx0U0RLcy5jb25jYXQoQ09OU1RBTlRTLmFkZGl0aW9uYWxTREtzKTtcbiAgICBtZXJnZWRTREtzLmZvckVhY2goXG4gICAgICBmdW5jdGlvbiAoc2RrT2J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gICAgICB9XG5cbiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IE9QRU5fUlBDLm1ldGhvZHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IG1vZHVsZSA9IE9QRU5fUlBDLm1ldGhvZHNbaV0ubmFtZS5zcGxpdCgnLicpWzBdO1xuICAgICAgICAgICAgY29uc3QgbWV0aG9kID0gT1BFTl9SUEMubWV0aG9kc1tpXS5uYW1lLnNwbGl0KCcuJylbMV07XG4gICAgICAgICAgICBjb25zdCBtZXRob2RPYmogPSBPUEVOX1JQQy5tZXRob2RzW2ldO1xuXG4gICAgICAgICAgICBpZiAobWV0aG9kT2JqKSB7XG4gICAgICAgICAgICAgIG92ZXJyaWRlUGFyYW1zRnJvbVRlc3REYXRhKG1ldGhvZE9iaik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoSUdOT1JFX01PRFVMRVMuaW5kZXhPZihtb2R1bGUpID09PSAtMSkge1xuICAgICAgICAgICAgICBjb25zdCBtb2R1bGVDYXAgPSBtb2R1bGUuY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgKyBtb2R1bGUuc2xpY2UoMSk7XG4gICAgICAgICAgICAgIGNvbnN0IGZpbmQgPSBtZW51cy5maWx0ZXIoKG0pID0+IG0udGl0bGUgPT09IG1vZHVsZUNhcCk7XG4gICAgICAgICAgICAgIGxldCBtb2R1bGVNZW51SXRlbSA9IGZpbmQubGVuZ3RoID09PSAwID8gbnVsbCA6IGZpbmRbMF07XG4gICAgICAgICAgICAgIGlmIChtb2R1bGVNZW51SXRlbSA9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0gPSB7XG4gICAgICAgICAgICAgICAgICB0aXRsZTogbW9kdWxlQ2FwLFxuICAgICAgICAgICAgICAgICAgbWVudXM6IFtdLFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbWVudXMucHVzaChtb2R1bGVNZW51SXRlbSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKE9QRU5fUlBDLm1ldGhvZHNbaV0uZXhhbXBsZXMgJiYgT1BFTl9SUEMubWV0aG9kc1tpXS5leGFtcGxlcy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmFkZFByb3BlcnR5RXhhbXBsZXMobWV0aG9kT2JqLCBPUEVOX1JQQyk7XG4gICAgICAgICAgICAgICAgdGhpcy5hZGRQb2x5bW9ycGhpY1B1bGxFeGFtcGxlcyhtZXRob2RPYmopO1xuICAgICAgICAgICAgICAgIGlmIChPUEVOX1JQQy5tZXRob2RzW2ldLmV4YW1wbGVzLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgICAgICAgIGNvbnN0IG1ldGhvZE1lbnVJdGVtID0ge1xuICAgICAgICAgICAgICAgICAgICB0aXRsZTogbWV0aG9kLFxuICAgICAgICAgICAgICAgICAgICBtZW51czogW10sXG4gICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0ubWVudXMucHVzaChtZXRob2RNZW51SXRlbSk7XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBleElkeCA9IDA7IGV4SWR4IDwgT1BFTl9SUEMubWV0aG9kc1tpXS5leGFtcGxlcy5sZW5ndGg7IGV4SWR4KyspIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9ICcgLSAnICsgT1BFTl9SUEMubWV0aG9kc1tpXS5leGFtcGxlc1tleElkeF0ubmFtZTtcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kTWVudUl0ZW0ubWVudXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IG1ldGhvZCArIG5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgdmlldzogQ2FyZCxcbiAgICAgICAgICAgICAgICAgICAgICBwYXJhbXM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNkazogc2RrLFxuICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBPUEVOX1JQQy5tZXRob2RzW2ldLFxuICAgICAgICAgICAgICAgICAgICAgICAgZXhhbXBsZUluZGV4OiBleElkeCxcbiAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0ubWVudXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBtZXRob2QsXG4gICAgICAgICAgICAgICAgICAgIHZpZXc6IENhcmQsXG4gICAgICAgICAgICAgICAgICAgIHBhcmFtczoge1xuICAgICAgICAgICAgICAgICAgICAgIHNkazogc2RrLFxuICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogT1BFTl9SUEMubWV0aG9kc1tpXSxcbiAgICAgICAgICAgICAgICAgICAgICBleGFtcGxlSW5kZXg6IDAsXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0ubWVudXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICB0aXRsZTogbWV0aG9kLFxuICAgICAgICAgICAgICAgICAgdmlldzogQ2FyZCxcbiAgICAgICAgICAgICAgICAgIHBhcmFtczoge1xuICAgICAgICAgICAgICAgICAgICBzZGs6IHNkayxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBPUEVOX1JQQy5tZXRob2RzW2ldLFxuICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBidWlsZE1lbnVzLnB1c2goeyB0aXRsZTogc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2ZsZXgnLCBhbGxpZ25JdGVtczogJ2NlbnRlcicsIGp1c3RpZnlDb250ZW50OiAnY2VudGVyJyB9LFxuICAgICAgSGVhZGVyOiB7XG4gICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgIHc6IDYwMCxcbiAgICAgICAgaDogMzAwLFxuICAgICAgICBjb2xvcjogMHhmZjFmMmYyZixcblxuICAgICAgICBUaXRsZToge1xuICAgICAgICAgIHg6IDE0MCxcbiAgICAgICAgICB5OiAxMDAsXG4gICAgICAgICAgbW91bnRZOiAwLjUsXG4gICAgICAgICAgdGV4dDoge1xuICAgICAgICAgICAgdGV4dDogQ09OU1RBTlRTLkVYSVRfTU9EQUxfVElUTEUsIC8vIHRleHQgZGlzcGxheWVkIGluIG1vZGFsXG4gICAgICAgICAgICBmb250U2l6ZTogMzAsXG4gICAgICAgICAgICB0ZXh0QWxpZ246ICdjZW50ZXInLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICAgIHRleHR1cmU6IGxuZy5Ub29scy5nZXRTaGFkb3dSZWN0KDE1MCwgNDAsIDQsIDEsIDQpLFxuICAgICAgICBCdXR0b25zOiB7XG4gICAgICAgICAgeDogMTAwLFxuICAgICAgICAgIHk6IDE1MCxcbiAgICAgICAgICBMZWZ0QnV0dG9uOiB7XG4gICAgICAgICAgICB0eXBlOiBCdXR0b25TbWFsbCxcbiAgICAgICAgICAgIHRpdGxlOiBDT05TVEFOVFMuWUVTLFxuICAgICAgICAgICAgYmFja2dyb3VuZFR5cGU6ICdzdHJva2UnLFxuICAgICAgICAgICAgYnV0dG9uVGV4dDogJ0xlZnQnLFxuICAgICAgICAgICAgb25FbnRlcjogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoJyRpbnZva2VNZXRob2QnLCB0cnVlKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgfSxcbiAgICAgICAgICBSaWdodEJ1dHRvbjoge1xuICAgICAgICA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Wx0ZXJzLmlzU3Vic2NyaWJlTWV0aG9kKG1ldGhvZC5leGFtcGxlc1tleGFtcGxlSW5kZXhdKSB8fCB0aGlzLm1ldGhvZEZpbHRlcnMuaXNTZXRNZXRob2QobWV0aG9kLmV4YW1wbGVzW2V4YW1wbGVJbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKHRoaXMubWV0aG9kRmlsdGVycy5pc1NldE1ldGhvZChtZXRob2QuZXhhbXBsZXNbZXhhbXBsZUluZGV4XSkpIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIGlmICh0aGlzLm1ldGhvZEZpbHRlcnMuc2hvdWxkRXhjbHVkZUV4YW1wbGUobWV0aG9kLmV4YW1wbGVzW2V4YW1wbGVJbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIG1ldGhvZFdpdGhFeGFtcGxlTmFtZSA9IG1ldGhvZE9iai5uYW1lICsgJy4nICsgbWV0aG9kT2JqLmV4YW1wbGVzW2V4YW1wbGVJbmRleF0ubmFtZTtcbiAgICAgICAgICAgICAgICBtZXRob2RVdWlkID0gdGhpcy5jcmVhdGVVVUlEKCk7XG4gICAgICAgICAgICAgICAgZXhhbXBsZSA9IG1ldGhvZC5leGFtcGxlc1tleGFtcGxlSW5kZXhdO1xuICAgICAgICAgICAgICAgIHBhcmFtVmFsdWVzID0gZXhhbXBsZS5wYXJhbXMubWFwKChwKSA9PiBwLnZhbHVlKTtcblxuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBudWxsO1xuXG4gICAgICAgICAgICAgICAgLy8gT3ZlcnJpZGluZyB0aGUgc2NoZW1hIHdpdGggdGhlIGJlbG93IGZvcm1hdFxuICAgICAgICAgICAgICAgIG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W50XG4gICAgICAgICAgICAgICAgaWYgKHNjaGVtYU1hcC5zY2hlbWEpIHtcbiAgICAgICAgICAgICAgICAgIGNvbnN0IHNjaGVtYVZhbGlkYXRpb25SZXN1bHQgPSB2YWxpZGF0b3IudmFsaWRhdGUoZXJyb3JSZXNwb25zZSwgc2NoZW1hTWFwLnNjaGVtYSk7XG4gICAgICAgICAgICAgICAgICBvYmogPSB7XG4gICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvclJlc3BvbnNlLFxuICAgICAgICAgICAgICAgICAgICBwYXJhbTogZXhhbXBsZS5wYXJhbXMsXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZFdpdGhFeGFtcGxlTmFtZTogbWV0aG9kV2l0aEV4YW1wbGVOYW1lLFxuICAgICAgICAgICAgICAgICAgICB2YWxpZGF0aW9uUmVzdWx0OiBzY2hlbWFWYWxpZGF0aW9uUmVzdWx0LFxuICAgICAgICAgICAgICAgICAgICBtZXRob2RVdWlkOiBtZXRob2RVdWlkLFxuICAgICAgICAgICAgICAgICAgICBzY2hlbWFEYXRhOiBzY2hlbWFNYXAuc2NoZW1hLFxuICAgICAgICAgICAgICAgICAgICBhcGlFeGVjdXRpb25TdGFydFRpbWU6IGFwaUV4ZWN1dGlvblN0YXJ0VGltZSxcbiAgICAgICAgICAgICAgICAgICAgYXBpRXhlY3V0aW9uRW5kVGltZTogYXBpRXhlY3V0aW9uRW5kVGltZSxcbiAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIG9iaiA9IHtcbiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGVycm9yUmVzcG9uc2UsXG4gICAgICAgICAgICAgICAgICAgIHBhcmFtOiBleGFtcGxlLnBhcmFtcyxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kV2l0aEV4YW1wbGVOYW1lOiBtZXRob2RXaXRoRXhhbXBsZU5hbWUsXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZFV1aWQ6IG1ldGhvZFV1aWQsXG4gICAgICAgICAgICAgICAgICAgIGFwaUV4ZWN1dGlvblN0YXJ0VGltZTogYXBpRXhlY3V0aW9uU3RhcnRUaW1lLFxuICAgICAgICAgICAgICAgICAgICBhcGlFeGVjdXRpb25FbmRUaW1lOiBhcGlFeGVjdXRpb25FbmRUaW1lLFxuICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2NoZW1hVmFsaWRhdGlvblJlc3VsdFNldC5wdXNoKG9iaik7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gQWRkaW5nIG9uIG1vcmUgZWxlbWVudCB0byBlcnIgT2JqZWN0IHRvIGRpc3BsYXkgbWV0aG9kIG5hbWUgb24gdGhlIHNjcmVlbiBmb3IgbXVsdGlwbGUgdGVzdGNhc2VzXG4gICAgICAgICAgICBsb2dnZXIuZGVidWcoJ1Rlc3RDb250ZXh0IERlYnVnOiBjb3VsZCBub3QgZmluZCBleGFtcGxlIGZvciBtZXRob2Q6ICcgKyBtZXRob2RXaXRoRXhhbXBsZU5hbWUsICdub3J0aEJvdW5kU2NoZW1hVmFsaWRhdGlvbkFuZFJlcG9ydEdlbmVyYXRpb24nKTtcbiAgICAgICAgICAgIGNvbnN0IG9iaiA9IHtcbiAgICAgICAgICAgICAgZXJyb3I6ICdDb3VsZCBub3QgZmluZCBhbiBleGFtcGxlIGZvciAnICsgbWV0aG9kLm5hbWUsXG4gICAgICAgICAgICAgIHBhcmFtOiBudWxsLFxuICAgICAgICAgICAgICBtZXRob2RXaXRoRXhhbXBsZU5hbWU6IG1ldGhvZE9iai5uYW1lLFxuICAgICAgICAgICAgICBtZXRob2RVdWlkOiBtZXRob2RVdWlkLFxuICAgICAgICAgICAgICBzY2hlbWFEYXRhOiBzY2hlbWFNYXAuc2NoZW1hLFxuICAgICA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4gICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgIGNvbnNvbGUubG9nKCdFcnJvcjogJywgZXJyb3IpO1xuICAgICAgZXJyID0gZXJyb3I7XG4gICAgfVxuICAgIHJldHVybiB7XG4gICAgICByZXNwb25zZTogcmVzcG9uc2UgPT09IHVuZGVmaW5lZCA/ICd1bmRlZmluZWQnIDogcmVzcG9uc2UsXG4gICAgICBlcnJvcjogZXJyID09PSB1bmRlZmluZWQgPyBudWxsIDogZXJyLFxuICAgIH07XG4gIH1cblxuICBjcmVhdGVSZXN1bHRPYmplY3QocmVzdWx0LCBlcnJvcikge1xuICAgIGxldCByZXN1bHRPYmplY3Q7XG4gICAgaWYgKHByb2Nlc3MuZW52LlNUQU5EQUxPTkUgPT0gdHJ1ZSkge1xuICAgICAgcmVzdWx0T2JqZWN0ID0ge1xuICAgICAgICByZXN1bHQ6IHJlc3VsdCxcbiAgICAgICAgZXJyb3I6IGVycm9yLFxuICAgICAgICBzY2hlbWFSZXN1bHQ6IHNjaGVtYVJlc3VsdCxcbiAgICAgICAgY29udGVudFJlc3VsdDogY29udGVudFJlc3VsdCxcbiAgICAgIH07XG4gICAgfSBlbHNlIHtcbiAgICAgIGlmIChlcnJvciA9PSBudWxsKSB7XG4gICAgICAgIHJlc3VsdE9iamVjdCA9IHtcbiAgICAgICAgICBqc29ucnBjOiAnMi4wJyxcbiAgICAgICAgICByZXN1bHQ6IHJlc3VsdCxcbiAgICAgICAgICBpZDogcHJvY2Vzcy5lbnYuSUQgKyAxLFxuICAgICAgICB9O1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmVzdWx0T2JqZWN0ID0ge1xuICAgICAgICAgIGpzb25ycGM6ICcyLjAnLFxuICAgICAgICAgIGVycm9yOiBlcnJvcixcbiAgICAgICAgICBpZDogcHJvY2Vzcy5lbnYuSUQgKyAxLFxuICAgICAgICB9O1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gcmVzdWx0T2JqZWN0O1xuICB9X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ICAgSGlzdG9yeToge1xuICAgICAgICB3OiAodykgPT4gdyxcbiAgICAgICAgaDogKGgpID0+IGgsXG4gICAgICAgIHR5cGU6IENvbHVtbixcbiAgICAgIH0sXG4gICAgICBDb25zb2xlVmlldzoge1xuICAgICAgICB4OiA1MjAsXG4gICAgICAgIHk6IDAsXG4gICAgICAgIGg6IDk5MCxcbiAgICAgICAgdzogMTkyMCAtIDYwMCxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgejogMTAwMCxcbiAgICAgIH0sXG4gICAgICBOb3RpZmljYXRpb246IHtcbiAgICAgICAgdmlzaWJsZTogZmFsc2UsXG4gICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgIGNvbG9yOiAweGZmMDAwMDAwLCAvLyBCbGFjayBjb2xvclxuICAgICAgICBvcGFjaXR5OiAwLjgsIC8vIE9wYWNpdHkgdmFsdWUgKDAuMCB0byAxLjApXG4gICAgICAgIHc6IDUwMCxcbiAgICAgICAgaDogMjAwLFxuICAgICAgICB4OiAxMzMwLFxuICAgICAgICB5OiA3NzUsXG4gICAgICAgIEVycm9yOiB7XG4gICAgICAgICAgeDogMjAsXG4gICAgICAgICAgeTogMTUsXG4gICAgICAgICAgdGV4dDoge1xuICAgICAgICAgICAgdGV4dDogQ09OU1RBTlRTLlBMQVRGT1JNX0VSUk9SX01FU1NBR0UsXG4gICAgICAgICAgICBmb250U2l6ZTogMjYsXG4gICAgICAgICAgICB0ZXh0Q29sb3I6IDB4ZmZmZjAwMDAsIC8vIFJlZCBjb2xvclxuICAgICAgICAgICAgd29yZFdyYXA6IGZhbHNlLFxuICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogMjgwLFxuICAgICAgICAgICAgdGV4dEFsaWduOiAnbGVmdCcsXG4gICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgICAgUGxhdGZvcm06IHtcbiAgICAgICAgICB4OiAyMCxcbiAgICAgICAgICB5OiA2MCxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiBwcm9jZXNzLmVudi5QTEFURk9STSxcbiAgICAgICAgICAgIGZvbnRTaXplOiAxOCxcbiAgICAgICAgICAgIHRleHRDb2xvcjogMHhmZmZmZmZmZiwgLy8gd2hpdGUgY29sb3JcbiAgICAgICAgICAgIHdvcmRXcmFwOiBmYWxzZSxcbiAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IDI4MCxcbiAgICAgICAgICAgIHRleHRBbGlnbjogJ2xlZnQnLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICAgIFRhcmdldDoge1xuICAgICAgICAgIHg6IDE1LFxuICAgICAgICAgIHk6IDExMCxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiBDT05TVEFOVFMuUExBVEZPUk1fVEFSR0VULFxuICAgICAgICAgICAgZm9udFNpemU6IDE4LFxuICAgICAgICAgICAgdGV4dENvbG9yOiAweGZmZmZmZmZmLCAvLyB3aGl0ZSBjb2xvclxuICAgICAgICAgICAgd29yZFdyYXA6IGZhbHNlLFxuICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogMjgwLFxuICAgICAgICAgICAgdGV4dEFsaWduOiAnbGVmdCcsXG4gICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBVcGRhdGVUZXh0OiB7XG4gICAgICAgIHg6IDgyNSxcbiAgICAgICAgeTogMjUsXG4gICAgICAgIHc6IDE5MjAgLSA3MDAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogMzAsXG4gICAgICAgIH0sXG4gICAgICAgIGNvbG9yOiAweGZmZmYwMDBmLFxuICAgICAgfSxcbiAgICAgIEFwaXRpdGxlVGV4dDoge1xuICAgICAgICB4OiA1MzAsXG4gICAgICAgIHk6IDEwMCxcbiAgICAgICAgdzogMTkyMCAtIDcwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAyNyxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMjM0NTYsXG4gICAgICB9LFxuICAgICAgU2NoZW1hVmFsaWRhdGlvblN0YXRlVGV4dDoge1xuICAgICAgICB4OiA1MzAsXG4gICAgICAgIHk6IDE1MCxcbiAgICAgICAgdzogMTkyMCAtIDcwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAyNyxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMjM0NTYsXG4gICAgICB9LFxuICAgICAgTWVzc2FnZToge1xuICAgICAgICB4OiA1MzAsXG4gICAgICAgIHk6IDIwMCxcbiAgICAgICAgdzogMTkyMCAtIDcwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAyNyxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMjM0NTYsXG4gICAgICB9LFxuICAgICAgVmFsaWRhdGlvbkRhdGE6IHtcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgeDogNTMwLFxuICAgICAgICB5OiAyNTAsXG4gICAgICAgIHc6IDE5MjAgLSA5MDAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogMjcsXG4gICAgICAgIH0sXG4gICAgICAgIGNvbG9yOiAweGZmMTIzNDU2LFxuICAgICAgfSxcbiAgICAgIEV4ZWN1dGVCdXR0b246IHtcbiAgICAgICAgdHlwZTogQnV0dG9uLFxuICAgICAgICB0aXRsZTogJ0ludm9rZScsXG4gICAgICAgIGJhY2tncm91bmRUeXBlOiAnc3Ryb2tlJyxcbiAgICAgICAgb25FbnRlcjogZnVuY3Rpb24gKCkge1xuICAgICAgICAgIHRoaXMuZmlyZUFuY2VzdG9ycygnJFJ1bk1ldGhvZCcpO1xuICAgICAgICB9LFxuICAgICAgfSxcbiAgICB9O1xuICB9XG4gIF9pbml0KCkge1xuICAgIHRoaXMuX3NldFN0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ByZXNwb25kZXIoe1xuICAgICAgICAgICAgICAgIGdyYW50ZWQ6IHRydWUsXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGRlbnlDYWxsYmFjazogKCkgPT4ge1xuICAgICAgICAgICAgICByZXNwb25kZXIoe1xuICAgICAgICAgICAgICAgIGdyYW50ZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVyKTtcbiAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBkZWZlcnJlZENhbGxiYWNrKCkge1xuICAgICAgICAgICAgICByZXNwb25kZXIoe1xuICAgICAgICAgICAgICAgIGdyYW50ZWQ6IG51bGwsXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfSk7XG4gICAgfSk7XG4gICAgdGhpcy5fYXBwLl9yZWZvY3VzKCk7XG4gIH1cbn1cbiIsIi8qKlxuICogQ29weXJpZ2h0IDIwMjMgQ29tY2FzdCBDYWJsZSBDb21tdW5pY2F0aW9ucyBNYW5hZ2VtZW50LCBMTENcbiAqXG4gKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgXCJMaWNlbnNlXCIpO1xuICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLlxuICogWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBM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uICAgICAgeDogMCxcbiAgICAgIHk6IDAsXG4gICAgICB3OiAodykgPT4gdyxcbiAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgQmFja2dyb3VuZDoge1xuICAgICAgICB3OiAodykgPT4gdyxcbiAgICAgICAgaDogKGgpID0+IGgsXG4gICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgIHNoYWRlcjoge1xuICAgICAgICAgIHR5cGU6IGxuZy5zaGFkZXJzLlJvdW5kZWRSZWN0YW5nbGUsXG4gICAgICAgICAgcmFkaXVzOiA0MCxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMTExMTEsXG4gICAgICB9LFxuICAgICAgVGl0bGU6IHtcbiAgICAgICAgeDogNTAsXG4gICAgICAgIHk6IDUwLFxuICAgICAgICB3OiAodykgPT4gdyAtIDEwMCxcbiAgICAgICAgaDogMTAwLFxuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgZm9udFNpemU6IDQ1LFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICAgIEFjdGlvbkJ1dHRvbnM6IHtcbiAgICAgICAgdHlwZTogUm93LFxuICAgICAgICB4OiAodykgPT4gKHcgLSAyNDApIC8gMixcbiAgICAgICAgeTogKGgpID0+IGggLSAxMDAsXG4gICAgICAgIGl0ZW1TcGFjaW5nOiA0MCxcbiAgICAgICAgaXRlbXM6IFtcbiAgICAgICAgICB7XG4gICAgICAgICAgICByZWY6ICdHcmFudEJ1dHRvbicsXG4gICAgICAgICAgICBtaW5XaWR0aDogMTAwLFxuICAgICAgICAgICAgdHlwZTogQnV0dG9uLFxuICAgICAgICAgICAgdGl0bGU6ICdZZXMnLFxuICAgICAgICAgICAgYmFja2dyb3VuZFR5cGU6ICdzdHJva2UnLFxuICAgICAgICAgICAgb25FbnRlclJlbGVhc2U6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKCckZ3JhbnQnKTtcbiAgICAgICAgICAg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X2FwcC5vdmVybGF5ZWQgPSB0cnVlO1xuICAgIHRoaXMuX2FwcC50YWcoJ092ZXJsYXlzJykuYWxwaGEgPSAxO1xuICAgIHRoaXMuX2FwcC50YWcoJ092ZXJsYXlzJykucGF0Y2goe1xuICAgICAgT3ZlcmxheToge1xuICAgICAgICB0eXBlOiBLZXlib2FyZEVudHJ5LFxuICAgICAgICB4OiAoV2luZG93LndpZHRoIC0gMTAwMCkgLyAyLFxuICAgICAgICB5OiAxMDAsXG4gICAgICAgIHc6IDEwMDAsXG4gICAgICAgIGg6IDMwMCxcbiAgICAgICAgc2Vzc2lvbjoge1xuICAgICAgICAgIG9uRG9uZTogKGtleWJvYXJkLCB0ZXh0KSA9PiB7XG4gICAgICAgICAgICB0aGlzLl9hcHAub3ZlcmxheURpc21pc3NUaW1lciA9IHNldFRpbWVvdXQoKCkgPT4gdGhpcy5fYXBwLiRkaXNtaXNzT3ZlcmxheSgpLCA1MDApOyAvLyBUcnkgYW5kIGdldCBsaWdodG5pbmctdWkgY29tcG9uZW50IHRvIHVzZSBvbmtleXVwXG4gICAgICAgICAgICByZXNwb25kZXIodGV4dCk7XG4gICAgICAgICAgfSxcbiAgICAgICAgICBvbkNhbmNlbDogKGtleWJvYXJkKSA9PiB7XG4gICAgICAgICAgICB0aGlzLl9hcHAuJGRpc21pc3NPdmVybGF5KCk7XG4gICAgICAgICAgICByZXNwb25kZXIoJycpO1xuICAgICAgICAgIH0sXG4gICAgICAgICAgbWFzazogbWFzayxcbiAgICAgICAgICB0aXRsZTogc2Vzc2lvbi5tZXNzYWdlLFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICB9KTtcbiAgICB0aGlzLl9hcHAuX3JlZm9jdXMoKTtcbiAgfVxufVxuIiwiLyoqXG4gKiBDb3B5cmlnaHQgMjAyMyBDb21jYXN0IENhYmxlIENvbW11bmljYXRpb25zIE1hbmFnZW1lbnQsIExMQ1xuICpcbiAqIExpY2Vuc2VkIHVuZGVyIHRoZSBBcGFja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oYSA9IDE7XG4gICAgICB0aGlzLl9hcHAudGFnKCdPdmVybGF5cycpLnBhdGNoKHtcbiAgICAgICAgT3ZlcmxheToge1xuICAgICAgICAgIHR5cGU6IFBpblByb21wdCxcbiAgICAgICAgICBwYXJhbXM6IHtcbiAgICAgICAgICAgIGhlYWRlcjogY2hhbGxlbmdlLnJlcXVlc3Rvci5uYW1lICsgJyBpcyByZXF1ZXN0aW5nIHRoYXQgeW91IGVudGVyIHlvdXIgJyArIGNoYWxsZW5nZS5waW5TcGFjZSArICcgcGluLicsXG4gICAgICAgICAgICBkZXRhaWw6ICcgJyxcbiAgICAgICAgICAgIGxpc3RlbmVyOiBuZXcgKGNsYXNzIGV4dGVuZHMgUGluUHJvbXB0LlBpblByb21wdExpc3RlbmVyIHtcbiAgICAgICAgICAgICAgb25QaW5FbnRlcmVkKHBpbikge1xuICAgICAgICAgICAgICAgIGlmIChwaW4gPT09IENPTlNUQU5UUy5QSU5TW2NoYWxsZW5nZS5waW5TcGFjZV0pIHtcbiAgICAgICAgICAgICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgICAgICAgICAgIGdyYW50ZWQ6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHJlYXNvbjogUGluQ2hhbGxlbmdlLlJlc3VsdFJlYXNvbi5DT1JSRUNUX1BJTixcbiAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVyKTtcbiAgICAgICAgICAgICAgICAgIHJlc29sdmUodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICBwcm9tcHQuZmlyZUFuY2VzdG9ycygnJGRpc21pc3NPdmVybGF5Jyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIHNlbGYubnVtRmFpbHVyZXMrKztcbiAgICAgICAgICAgICAgICAgIGlmIChzZWxmLm51bUZhaWx1cmVzID49IENPTlNUQU5UUy5NQVhfRkFJTFVSRVMpIHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5sb2NrZWRUaW1lID0gRGF0ZS5ub3coKTtcbiAgICAgICAgICAgICAgICAgICAgcmVzcG9uZGVyKHtcbiAgICAgICAgICAgICAgICAgICAgICBncmFudGVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgICByZWFzb246IFBpbkNoYWxsZW5nZS5SZXN1bHRSZWFzb24uRVhDRUVERURfUElOX0ZBSUxVUkVTLFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVyKTtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgcHJvbXB0LmZpcmVBbmNlc3RvcnMoJyRkaXNtaXNzT3ZlcmxheScpO1xuICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gc2hvdyBhZ2FpblxuICAgICAgICAgICAgICAgICAgICBwcm9tcHQucGFyYW1zID0ge1xuICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogJ1RoYXQgd2FzIHdyb25nLCB0cnkgYWdhaW4uJyxcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVyKTtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgb25EaXNtaXNzUmVxdWVzdGVkKCkge1xuICAgICAgICAgICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgICAgICAgICBncmFudGVkOiBudWxsLFxuICAgICAgICAgICAgICAgICAgcmVhc29uOiBQaW5DaGFsbGVuZ2UuUmVzdWx0UmVhc29uLkNBTkNFTExFRCxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgIC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2UpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgb25EaXNtaXNzUmVxdWVzdGVkKCkge1xuICAgICAgICAgICAgICBkaXNtaXNzUGluT3ZlcmxheShyZXNwb25kZXIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgb25Mb2FkZWQodmlldykge1xuICAgICAgICAgICAgICBwcm9tcHQgPSB2aWV3O1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pKCksXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgIH0pO1xuICAgIHRoaXMuX2FwcC5fcmVmb2N1cygpO1xuICB9XG5cbiAgYWZ0ZXJQaW5FbnRlcmVkKHBpbiwgcmVzcG9uZGVyLCBjaGFsbGVuZ2UpIHtcbiAgICBuZXcgUHJvbWlzZShhc3luYyAocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgICBjb25zdCB0aW1lciA9IHNldFRpbWVvdXQoKCkgPT4ge1xuICAgICAgICByZXNwb25kZXIoe1xuICAgICAgICAgIGdyYW50ZWQ6IG51bGwsXG4gICAgICAgICAgcmVhc29uOiBQaW5DaGFsbGVuZ2UuUmVzdWx0UmVhc29uLkNBTkNFTExFRCxcbiAgICAgICAgfSk7XG4gICAgICAgIHJlc29sdmUodHJ1ZSk7XG4gICAgICB9LCA1MDAwKTtcbiAgICAgIGlmIChwaW4pIHtcbiAgICAgICAgaWYgKHBpbiA9PT0gQ09OU1RBTlRTLlBJTlMucHVyY2hhc2UpIHtcbiAgICAgICAgICAvLyBDaGVjayB3aGV0aGVyIGNoYWxsZW5nZS5waW5zcGFjZSBpcyBmZXRlY2hpbmcgdGhlIHBpbiAnMTExMSdcbiAgICAgICAgICByZXNwb25kZXIoe1xuICAgICAgICAgICAgZ3JhbnRlZDogdHJ1ZSxcbiAgICAgICAgICAgIHJlYXNvbjogUGluQ2hhbGxlbmdlLlJlc3VsdFJlYXNvbi5DT1JSRUNUX1BJTixcbiAgICAgICAgICB9KTtcbiAgICAgICAgICAvLyBwcm9tcHQuZmlyZUFuY2VzdG9ycygnJGRpc21pc3NPdmVybGF5JylcbiAgICAgICAgICB0aGlzLl9hcHAuJGRpc21pc3NPdmVybGF5KCk7XG4gICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVyKTtcbiAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGZvciAobGV0IG51bU9mRmFpbHVyZXMgPSAxOyBudW1PZkZhaWx1cmVzIDw9IHByb2Nlc3MuZW52Lm1heEF0dGVtcHRzOyBudW1PZkZhaWx1cmVzKyspIHtcbiAgICAgICAgICAgIGlmIChudW1PZkZhaWx1cmVzID09IHByb2Nlc3MuZW52Lm1heEF0dGVtcHRzKSB7XG4gICAgICAgICAgICAgIHRoaXMuX2FwcC4kZGlzbWlzc092ZXJsYXkoKTtcbiAgICAgICAgICAgICAgcmVzcG9uZGVyKHtcbiAgICAgICAgICAgICAgICBncmFudGVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgICByZWFzb246IFBpbkNoYWxsZW5nZS5SZXN1bHRSZWFzb24uRVhDRUVERURfUElOX0ZBSUxVUkVTLFxuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVyKTtcbiAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9KTtcbiAgfVxuXG4gIGRpc21pc3NQaW5PdmVybGF5KHJlc3BvbmRlciwgaXNFeGl0ID0gZmFsc2UpIHtcbiAgICBjb25zdCBncmFudGVkID0gaXNFeGl0ID8gbnVsbCA6IGZhbHNlO1xuICAgIHJlc3BvbmRlcih7XG4gICAgICBncmFudGVkOiBncmFudGVkLFxuICAgICAgcmVhc29uOiBQaW5DaGFsbGVuZ2UuUmVzdWx0UmVhc29uLkNBTkNFTExFRCxcbiAgICB9KTtcbiAgICB0aGlzLl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gICAgICBoOiBTQ1JFRU4uaCxcbiAgICAgICAgY29sb3I6ICcjMEQwRDBGJyxcbiAgICAgICAgekluZGV4OiAtOTk5OSxcbiAgICAgIH0sXG4gICAgICBLZXlib2FyZDoge1xuICAgICAgICB0eXBlOiBLZXlib2FyZE51bWJlcnMsXG4gICAgICAgIHJlZjogJ0tleWJvYXJkJyxcbiAgICAgICAgaW5saW5lOiB0cnVlLFxuICAgICAgICBkZWZhdWx0Rm9ybWF0OiAnbnVtYmVycycsXG4gICAgICAgIGNlbnRlcktleWJvYXJkOiB0cnVlLFxuICAgICAgICB4OiAoU0NSRUVOLncgLSAxMCAqIEtFWUJPQVJEX0tFWV9XSURUSCAtIDkgKiBLRVlCT0FSRF9LRVlfU1BBQ0lORykgLyAyLFxuICAgICAgICB5OiBLRVlCT0FSRF9ZLFxuICAgICAgfSxcbiAgICAgIEhlYWRlcjoge1xuICAgICAgICB4OiAwLFxuICAgICAgICB5OiBQUk9NUFRfVE9QX1BBRERJTkcsXG4gICAgICAgIHc6IFNDUkVFTi53LFxuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgLi4ue1xuICAgICAgICAgICAgZm9udEZhY2U6ICdYZmluaXR5QnJvd25Cb2xkJyxcbiAgICAgICAgICAgIGZvbnRTaXplOiA0OCxcbiAgICAgICAgICAgIGZvbnRXZWlnaHQ6IDcwMCxcbiAgICAgICAgICAgIGxldHRlclNwYWNpbmc6IC0wLjQsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA2NCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246ICdtaWRkbGUnLFxuICAgICAgICAgIH0sXG4gICAgICAgICAgdGV4dENvbG9yOiAnIzQwNzY4NjM0ODcnLFxuICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgRGV0YWlsOiB7XG4gICAgICAgIHg6IDAsXG4gICAgICAgIHk6IEJPRFlfWSxcbiAgICAgICAgdzogU0NSRUVOLncsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICAuLi57XG4gICAgICAgICAgICBmb250RmFjZTogJ1hmaW5pdHlTdGFuZGFyZE1lZGl1bScsXG4gICAgICAgICAgICBmb250U2l6ZTogMzIsXG4gICAgICAgICAgICBmb250V2VpZ2h0OiA1MDAsXG4gICAgICAgICAgICBsZXR0ZXJTcGFjaW5nOiAwLFxuICAgICAgICAgICAgbGluZUhlaWdodDogNDAsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiAnbWlkZGxlJyxcbiAgICAgICAgICB9LFxuICAgICAgICAgIHRleHRDb2xvcjogJyMzNDM5MzI5Mjc5JyxcbiAgICAgICAgICB0ZXh0QWxpZ246ICdjZW50ZXInLFxuICAgICAgICB9LFxuICAgICAgfSxcbiAgICAgIFBpbkRpc3BsYXk6IHtcbiAgICAgICAgeDogMCxcbiAgICAgICAgeTogUElOX0RJU1BMQVlfWSxcbiAgICAgICAgdzogU0NSRUVOLncsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICAuLi57XG4gICAgICAgICAgICBmb250RmFjZTogJ1hmaW5pdHlCcm93bkJvbGQnLFxuICAgICAgICAgICAgZm9udFNpemU6IDU2LFxuICAgICAgICAgICAgZm9udFdlaWdodDogNzAwLFxuICAgICAgICAgICAgbGV0dGVyU3BhY2luZzogLTAuNCxcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDcyLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogJ21pZGRsZScsXG4gICAgICAgICAgfSxcbiAgICAgICAgICBmb250U2l6ZTogNzIsXG4gICAgICAgICAgdGV4dENvbG9yOiAnIzQwNzY4NjM0ODcnLFxuICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgIH07XG4gIH1cblxuICBfY29uc3RydWN0KCkge1xuICAgIHRoaXMucGluID0gW107XG4gICAgdGhpcy5zb2Z0S2V5UGVuZ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lamVjdCkgPT4ge1xuICAgICAgICAgICAgcGFyc2VyLnBhcnNlU3RyaW5nKHhtbERhdGEsIGZ1bmN0aW9uIChlcnIsIHJlc3VsdCkge1xuICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcGFyc2luZ1N1Y2Nlc3NmdWwgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICByZXNvbHZlKCk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVzID0gcmVzdWx0WyduczI6eGNhbC1hdXRoLW1lc3NhZ2UnXVsnYXR0cmlidXRlJ107XG4gICAgICAgICAgICAgICAgcGFyc2luZ1N1Y2Nlc3NmdWwgPSB0cnVlO1xuICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVzSXRlbSBvZiByZXMpIHtcbiAgICAgICAgICAgICAgICAgIGlmIChyZXNJdGVtLiQua2V5ID09PSAnZGV2aWNlOmNjcFBraTplc3RiTWFjJykge1xuICAgICAgICAgICAgICAgICAgICBsb2dnZXIuaW5mbyhyZXNJdGVtLl8sICdwdXNoUmVwb3J0VG9TMycpO1xuICAgICAgICAgICAgICAgICAgICBtYWNBZGRyZXNzID0gcmVzSXRlbS5fO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXNvbHZlKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBtYWNBZGRyZXNzID0gcHJvY2Vzcy5lbnYuTUFDQUREUkVTUztcbiAgICAgICAgcGFyc2luZ1N1Y2Nlc3NmdWwgPSB0cnVlO1xuICAgICAgfVxuXG4gICAgICBtYWNBZGRyZXNzID0gbWFjQWRkcmVzcy5zcGxpdCgnOicpLmpvaW4oJycpO1xuICAgICAgcmVwb3J0TmFtZSA9IG1hY0FkZHJlc3Mg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0TWV0aG9kRXhjbHVkZWRMaXN0QmFzZWRPbk1vZGUsXG4gIGZpbmRUeXBlSW5PbmVPRixcbiAgb3ZlcnJpZGVQYXJhbXNGcm9tVGVzdERhdGEsXG4gIHBhcnNlWEFDVCxcbn07XG4iLCIvKiAoaWdub3JlZCkgKi8iLCIvKiAoaWdub3JlZCkgKi8iLCIvKiAoaWdub3JlZCkgKi8iLCIvKiAoaWdub3JlZCkgKi8iLCIvKiAoaWdub3JlZCkgKi8iLCIvKiAoaWdub3JlZCkgKi8iLCIvKiAoaWdub3JlZCkgKi8iLCIvKiAoaWdub3JlZCkgKi8iXSwic291cmNlUm9vdCI6IiJ9
\ No newline at end of file
diff --git a/PR-235/startupScripts.bundle.a3824b93d754e7843db8.js b/PR-235/startupScripts.bundle.e3d2457d97d7e980d664.js
similarity index 99%
rename from PR-235/startupScripts.bundle.a3824b93d754e7843db8.js
rename to PR-235/startupScripts.bundle.e3d2457d97d7e980d664.js
index 12601f57..becf5b03 100644
--- a/PR-235/startupScripts.bundle.a3824b93d754e7843db8.js
+++ b/PR-235/startupScripts.bundle.e3d2457d97d7e980d664.js
@@ -170,4 +170,4 @@ module.exports = __webpack_require__(/*! ./plugins/startupScripts/index.js */"./
/***/ })
/******/ });
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vcGx1Z2lucy9zdGFydHVwU2NyaXB0cy9hY3RpdmF0ZU1vY2tGaXJlYm9sdC5qcyIsIndlYnBhY2s6Ly8vLi9wbHVnaW5zL3N0YXJ0dXBTY3JpcHRzL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O1FBQUE7UUFDQTs7UUFFQTtRQUNBOztRQUVBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBO1FBQ0E7UUFDQTtRQUNBOztR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