diff --git a/PR-230/COMMITHASH b/PR-230/COMMITHASH
index e5e73db7..d8f60f64 100644
--- a/PR-230/COMMITHASH
+++ b/PR-230/COMMITHASH
@@ -1 +1 @@
-84d3926af02c3589b509aea38919182d08d10ba5
\ No newline at end of file
+9d77cb7a5eed8167f8375f4817b2659066833166
\ No newline at end of file
diff --git a/PR-230/VERSION b/PR-230/VERSION
index 156312fa..fdff5b25 100644
--- a/PR-230/VERSION
+++ b/PR-230/VERSION
@@ -1 +1 @@
-84d3926
\ No newline at end of file
+9d77cb7
\ No newline at end of file
diff --git a/PR-230/index.html b/PR-230/index.html
index 5a6c028d..e4038ec3 100644
--- a/PR-230/index.html
+++ b/PR-230/index.html
@@ -8,7 +8,7 @@
1.4.1 - Firebolt Certification App - version 1.4.1
-
+
QUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ2U7O0FBRWY7O0FBRUE7QUFDQTs7QUFFQTtBQUNBOztBQUVBO0FBQ0E7O0FBRUE7QUFDQTs7QUFFQTtBQUNBOztBQUVBOztBQUVBOztBQUVBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7O0FBRUE7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLHVDOztB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Y291bnRzLnVwID0gcmFuZG9tTnVtYmVyKDE2KSArIDM7XG4gICAgICAgICAgY291bnRzLm1pZCA9IHJhbmRvbU51bWJlcig0KSArIDE7XG4gICAgICAgICAgY291bnRzLmRvd24gPSByYW5kb21OdW1iZXIoNjQpICsgMztcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICBjb3VudHMudXAgPSByYW5kb21OdW1iZXIoOCkgKyAxO1xuICAgICAgICAgIGNvdW50cy5taWQgPSByYW5kb21OdW1iZXIoNikgLyAyO1xuICAgICAgICAgIGNvdW50cy5kb3duID0gcmFuZG9tTnVtYmVyKDgpICsgMTtcbiAgICAgICAgICBicmVhaztcbiAgICAgIH1cblxuICAgICAgdmFyIGFyciA9IFsndXAnLCAnbWlkJywgJ2Rvd24nXTtcbiAgICAgIGZvciAodmFyIGQgaW4gYXJyKSB7XG4gICAgICAgIHZhciBpbmRleCA9IGFycltkXTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPD0gY291bnRzW2luZGV4XTsgaSsrKSB7XG4gICAgICAgICAgaWYgKG9wdGlvbnNbaW5kZXhdKSB7XG4gICAgICAgICAgICByZXN1bHQgPSByZXN1bHQgKyBzb3VsW2luZGV4XVtyYW5kb21OdW1iZXIoc291bFtpbmRleF0ubGVuZ3RoKV07XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiByZXN1bHQ7XG4gIH1cbiAgLy8gZG9uJ3Qgc3VtbW9uIGhpbVxuICByZXR1cm4gaGVDb21lcyh0ZXh0LCBvcHRpb25zKTtcbn07XG5cbiIsIm1vZHVsZVsnZXhwb3J0cyddID0gZnVuY3Rpb24oY29sb3JzKSB7XG4gIHJldHVybiBmdW5jdGlvbihsZXR0ZXIsIGksIGV4cGxvZGVkKSB7XG4gICAgaWYgKGxldHRlciA9PT0gJyAnKSByZXR1cm4gbGV0dGVyO1xuICAgIHN3aXRjaCAoaSUz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A+PSAxMDU4Nikge1xuICAgICAgcmV0dXJuIE51bWJlcihvc1JlbGVhc2VbMl0pID49IDE0OTMxID8gMyA6IDI7XG4gICAgfVxuXG4gICAgcmV0dXJuIDE7XG4gIH1cblxuICBpZiAoJ0NJJyBpbiBlbnYpIHtcbiAgICBpZiAoWydUUkFWSVMnLCAnQ0lSQ0xFQ0knLCAnQVBQVkVZT1InLCAnR0lUTEFCX0NJJ10uc29tZShmdW5jdGlvbihzaWduKSB7XG4gICAgICByZXR1cm4gc2lnbiBpbiBlbnY7XG4gICAgfSkgfHwgZW52LkNJX05BTUUgPT09ICdjb2Rlc2hpcCcpIHtcbiAgICAgIHJldHVybiAxO1xuICAgIH1cblxuICAgIHJldHVybiBtaW47XG4gIH1cblxuICBpZiAoJ1RFQU1DSVRZX1ZFUlNJT04nIGluIGVudikge1xuICAgIHJldHVybiAoL14oOVxcLigwKlsxLTldXFxkKilcXC58XFxkezIsfVxcLikvLnRlc3QoZW52LlRFQU1DSVRZX1ZFUlNJT04pID8gMSA6IDBcbiAgICApO1xuICB9XG5cbiAgaWYgKCdURVJNX1BST0dSQU0nIGluIGVudikge1xuICAgIHZhciB2ZXJzaW9uID0gcGFyc2VJbnQoKGVudi5URVJNX1BST0dSQU1fVkVSU0lPTiB8fCAnJykuc3BsaXQoJy4nKVswXSwgMTApO1xuXG4gICAgc3dpdGNoIChlbnYuVEVSTV9QUk9HUkFNKSB7XG4gICAgICBjYXNlICdpVGVybS5hcHAnOlxuICAgICAgICByZXR1cm4gdmVyc2lvbiA+PSAzID8gMyA6IDI7XG4gICAgICBjYXNlICdIeXBlcic6XG4gICAgICAgIHJldHVybiAzO1xuICAgICAgY2FzZSAnQXBwbGVfVGVybWluYWwnOlxuICAgICAgICByZXR1cm4gMjtcbiAgICAgIC8vIE5vIGRlZmF1bHRcbiAgICB9XG4gIH1cblxuICBpZiAoLy0yNTYoY29sb3IpPyQvaS50ZXN0KGVudi5URVJNKSkge1xuICAgIHJldHVybiAyO1xuIC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KSB7XG4gICAgICAgIGNvbnN0IGFyZ3MgPSBPYmplY3QuYXNzaWduKHsgbGlzdGVuOiB0cnVlIH0sIGNvbnRleHQpXG4gICAgICAgIGNvbnN0IHsgaWQsIHByb21pc2UgfSA9IFRyYW5zcG9ydC5saXN0ZW4oXG4gICAgICAgICAgbW9kdWxlLFxuICAgICAgICAgICdvbicgKyBldmVudFswXS50b1VwcGVyQ2FzZSgpICsgZXZlbnQuc3Vic3RyaW5nKDEpLFxuICAgICAgICAgIGFyZ3MsXG4gICAgICAgIClcbiAgICAgICAga2V5c1tpZF0gPSBrZXlcbiAgICAgICAgcHJvbWlzZXMucHVzaChwcm9taXNlKVxuICAgICAgfVxuXG4gICAgICBjb25zdCBzZXR0ZXIgPSBpbnRlcm5hbCA/IGxpc3RlbmVycy5zZXRJbnRlcm5hbCA6IGxpc3RlbmVycy5zZXRcblxuICAgICAgaWYgKHdpbGRjYXJkKSB7XG4gICAgICAgIHNldHRlcihrZXksICcnICsgbGlzdGVuZXJJZCwgKHZhbHVlKSA9PiBjYWxsYmFjayhldmVudCwgdmFsdWUpKVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgc2V0dGVyKGtleSwgJycgKyBsaXN0ZW5lcklkLCBjYWxsYmFjaylcbiAgICAgIH1cbiAgICB9KVxuXG4gICAgbGV0IHJlc29sdmUsIHJlamVjdFxuICAgIGxldCBwID0gbmV3IFByb21pc2UoKHJlcywgcmVqKSA9PiB7XG4gICAgICByZXNvbHZlID0gcmVzXG4gICAgICByZWplY3QgPSByZWpcbiAgICB9KVxuXG4gICAgaWYgKHByb21pc2VzLmxlbmd0aCkge1xuICAgICAgUHJvbWlzZS5hbGwocHJvbWlzZXMpXG4gICAgICAgIC50aGVuKChyZXNwb25zZXMpID0+IHtcbiAgICAgICAgICByZXNvbHZlKGxpc3RlbmVySWQpXG4gICAgICAgIH0pXG4gICAgICAgIC5jYXRjaCgoZXJyb3IpID0+IHtcbiAgICAgICAgICAvLyBQcm9taXNlLmF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G9jY3VyZWQgd2hpbGUgY2FsbGluZyBwcm92aWRlZCAke21ldGhvZH0gbWV0aG9kLmAsXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKGVycm9yLmRhdGEpIHtcbiAgICAgICAgICAgIHJlc3BvbnNlLmVycm9yLmRhdGEgPSBKU09OLnBhcnNlKEpTT04uc3RyaW5naWZ5KGVycm9yLmRhdGEpKVxuICAgICAgICAgIH1cblxuICAgICAgICAgIFRyYW5zcG9ydC5zZW5kKG1vZHVsZSwgYCR7bWV0aG9kfUVycm9yYCwgcmVzcG9uc2UpXG4gICAgICAgIH1cblxuICAgICAgICB0cnkge1xuICAgICAgICAgIGNvbnN0IHJlc3VsdCA9IHByb3ZpZGVyW21ldGhvZF0uYXBwbHkocHJvdmlkZXIsIHByb3ZpZGVyQ2FsbEFyZ3MpXG5cbiAgICAgICAgICBpZiAoIShyZXN1bHQgaW5zdGFuY2VvZiBQcm9taXNlKSkge1xuICAgICAgICAgICAgdGhyb3cgYFByb3ZpZGVyIG1ldGhvZCAke21ldGhvZH0gZGlkIG5vdCByZXR1cm4gYSBQcm9taXNlLmBcbiAgICAgICAgICB9XG5cbiAgICAgICAgICByZXN1bHRcbiAgICAgICAgICAgIC50aGVuKChyZXN1bHQpID0+IHtcbiAgICAgICAgICAgICAgaWYgKGltZXRob2QucmVzcG9uc2UpIHtcbiAgICAgICAgICAgICAgICAvLyB2b2lkIHJlc3VsdHMgc2hvdWxkIGJlIG51bGwgaW4gdGhlIEpTT05SUEMgbWVzc2FnZVxuICAgICAgICAgICAgICAgIHJlc3BvbnNlLnJlc3VsdCA9IHJlc3VsdCA9PSBudWxsID8gbnVsbCA6IHJlc3VsdFxuICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgVHJhbnNwb3J0LnNlbmQobW9kdWxlLCBgJHttZXRob2R9UmVzcG9uc2VgLCByZXNwb25zZSlcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuY2F0Y2goKGVycikgPT4g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b3ZlcnknLCAnZW50aXR5SW5mbycsIHBhcmFtcykuY2F0Y2goKGVycm9yKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnN0IG1zZyA9XG4gICAgICAgICAgICAgICAgdHlwZW9mIGVycm9yID09PSAnc3RyaW5nJ1xuICAgICAgICAgICAgICAgICAgPyBlcnJvclxuICAgICAgICAgICAgICAgICAgOiBlcnJvci5tZXNzYWdlIHx8ICdVbmtub3duIEVycm9yJ1xuICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFxuICAgICAgICAgICAgICAgIGBGYWlsZWQgdG8gc2VuZCBlbnRpdHlJbmZvIHB1bGwgcmVzcG9uc2UgdGhyb3VnaCBUcmFuc3BvcnQgTGF5ZXI6ICR7bXNnfWAsXG4gICAgICAgICAgICAgIClcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgfSlcbiAgICAgICAgICAuY2F0Y2goKGVycm9yKSA9PiB7XG4gICAgICAgICAgICBjb25zdCBtc2cgPVxuICAgICAgICAgICAgICB0eXBlb2YgZXJyb3IgPT09ICdzdHJpbmcnXG4gICAgICAgICAgICAgICAgPyBlcnJvclxuICAgICAgICAgICAgICAgIDogZXJyb3IubWVzc2FnZSB8fCAnVW5rbm93biBFcnJvcidcbiAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoYEFwcCAnZW50aXR5SW5mbycgY2FsbGJhY2sgZmFpbGVkOiAke21zZ31gKVxuICAgICAgICAgIH0pXG4gICAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgICBjb25zdCBtc2cgPVxuICAgICAgICAgIHR5cGVvZiBlcnJvciA9PT0gJ3N0cmluZycgPyBlcnJvciA6IGVycm9yLm1lc3NhZ2UgfHwgJ1Vua25vd24gRXJyb3InXG4gICAgICAgIGNvbnNvbGUuZXJyb3IoYEFwcCAnZW50aXR5SW5mbycgY2FsbGJhY2sgZmFpbGVkOiAke21zZ31gKVxuICAgICAgfVxuICAgIH0pXG4gIH0gZWxzZSB7XG4gICAgcmV0d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2VuZCgnRGlzY292ZXJ5JywgJ3B1cmNoYXNlZENvbnRlbnQnLCBwYXJhbXMpLmNhdGNoKFxuICAgICAgICAgICAgICAoZXJyb3IpID0+IHtcbiAgICAgICAgICAgICAgICBjb25zdCBtc2cgPVxuICAgICAgICAgICAgICAgICAgdHlwZW9mIGVycm9yID09PSAnc3RyaW5nJ1xuICAgICAgICAgICAgICAgICAgICA/IGVycm9yXG4gICAgICAgICAgICAgICAgICAgIDogZXJyb3IubWVzc2FnZSB8fCAnVW5rbm93biBFcnJvcidcbiAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFxuICAgICAgICAgICAgICAgICAgYEZhaWxlZCB0byBzZW5kIHB1cmNoYXNlZENvbnRlbnQgcHVsbCByZXNwb25zZSB0aHJvdWdoIFRyYW5zcG9ydCBMYXllcjogJHttc2d9YCxcbiAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICApXG4gICAgICAgICAgfSlcbiAgICAgICAgICAuY2F0Y2goKGVycm9yKSA9PiB7XG4gICAgICAgICAgICBjb25zdCBtc2cgPVxuICAgICAgICAgICAgICB0eXBlb2YgZXJyb3IgPT09ICdzdHJpbmcnXG4gICAgICAgICAgICAgICAgPyBlcnJvclxuICAgICAgICAgICAgICAgIDogZXJyb3IubWVzc2FnZSB8fCAnVW5rbm93biBFcnJvcidcbiAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoYEFwcCAncHVyY2hhc2VkQ29udGVudCcgY2FsbGJhY2sgZmFpbGVkOiAke21zZ31gKVxuICAgICAgICAgIH0pXG4gICAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgICBjb25zdCBtc2cgPVxuICAgICAgICAgIHR5cGVvZiBlcnJvciA9PT0gJ3N0cmluZycgPyBlcnJvciA6IGVycm9yLm1lc3NhZ2UgfHwgJ1Vua25vd24gRXJyb3InXG4gICAgICAgIGNvbnNvbGUuZXJyb3IoYEFwcCAncHVyY2hhc2VkQ29udGVudCc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plY3QudmFsdWVzKGxpc3RlbmVycy5nZXQoa2V5KSkubGVuZ3RoID09PSAwKSB7XG4gICAgICAgIGNvbnN0IGFyZ3MgPSBPYmplY3QuYXNzaWduKHsgbGlzdGVuOiB0cnVlIH0sIGNvbnRleHQpXG4gICAgICAgIGNvbnN0IHsgaWQsIHByb21pc2UgfSA9IFRyYW5zcG9ydC5saXN0ZW4oXG4gICAgICAgICAgbW9kdWxlLFxuICAgICAgICAgICdvbicgKyBldmVudFswXS50b1VwcGVyQ2FzZSgpICsgZXZlbnQuc3Vic3RyaW5nKDEpLFxuICAgICAgICAgIGFyZ3MsXG4gICAgICAgIClcbiAgICAgICAga2V5c1tpZF0gPSBrZXlcbiAgICAgICAgcHJvbWlzZXMucHVzaChwcm9taXNlKVxuICAgICAgfVxuXG4gICAgICBjb25zdCBzZXR0ZXIgPSBpbnRlcm5hbCA/IGxpc3RlbmVycy5zZXRJbnRlcm5hbCA6IGxpc3RlbmVycy5zZXRcblxuICAgICAgaWYgKHdpbGRjYXJkKSB7XG4gICAgICAgIHNldHRlcihrZXksICcnICsgbGlzdGVuZXJJZCwgKHZhbHVlKSA9PiBjYWxsYmFjayhldmVudCwgdmFsdWUpKVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgc2V0dGVyKGtleSwgJycgKyBsaXN0ZW5lcklkLCBjYWxsYmFjaylcbiAgICAgIH1cbiAgICB9KVxuXG4gICAgbGV0IHJlc29sdmUsIHJlamVjdFxuICAgIGxldCBwID0gbmV3IFByb21pc2UoKHJlcywgcmVqKSA9PiB7XG4gICAgICByZXNvbHZlID0gcmVzXG4gICAgICByZWplY3QgPSByZWpcbiAgICB9KVxuXG4gICAgaWYgKHByb21pc2VzLmxlbmd0aCkge1xuICAgICAgUHJvbWlzZS5hbGwocHJvbWlzZXMpXG4gICAgICAgIC50aGVuKChyZXNwb25zZXMpID0+IHtcbiAgICAgICAgICByZXNvbHZlKGxpc3RlbmVySWQpXG4gICAgICAgIH0pXG4gICAgICAgI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IGV4aXN0c1xuICAgICAgICBpZiAoaW1ldGhvZC5wYXJhbWV0ZXJzKSB7XG4gICAgICAgICAgcHJvdmlkZXJDYWxsQXJncy5wdXNoKHJlcXVlc3QucGFyYW1ldGVycylcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwcm92aWRlckNhbGxBcmdzLnB1c2gobnVsbClcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHNlc3Npb24gPSB7XG4gICAgICAgICAgY29ycmVsYXRpb25JZDogKCkgPT4ge1xuICAgICAgICAgICAgcmV0dXJuIHJlcXVlc3QuY29ycmVsYXRpb25JZFxuICAgICAgICAgIH0sXG4gICAgICAgIH1cblxuICAgICAgICAvLyBvbmx5IHBhc3MgaW4gdGhlIGZvY3VzIGhhbmRzaGFrZSBpZiBuZWVkZWRcbiAgICAgICAgaWYgKGltZXRob2QuZm9jdXMpIHtcbiAgICAgICAgICBzZXNzaW9uLmZvY3VzID0gKCkgPT4ge1xuICAgICAgICAgICAgVHJhbnNwb3J0LnNlbmQobW9kdWxlLCBgJHttZXRob2R9Rm9jdXNgLCB7XG4gICAgICAgICAgICAgIGNvcnJlbGF0aW9uSWQ6IHJlcXVlc3QuY29ycmVsYXRpb25JZCxcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcHJvdmlkZXJDYWxsQXJncy5wdXNoKHNlc3Npb24pXG5cbiAgICAgICAgY29uc3QgcmVzcG9uc2UgPSB7XG4gICAgICAgICAgY29ycmVsYXRpb25JZDogcmVxdWVzdC5jb3JyZWxhdGlvbklkLFxuICAgICAgICB9XG4gICAgICAgIGxldCBoYW5kbGVFcnJvciA9IChlcnJvcikgPT4ge1xuICAgICAgICAgIHJlc3BvbnNlLmVycm9yID0ge1xuICAgICAgICAgICAgY29kZTogZXJyb3IuY29kZSB8fCAxMDAwLCAvLyB0b2RvOiBzaG91bGQgYmUgc29tZSByZXNlcnZlZCBjb2RlIGZvciBcIlVua25vd25cIlxuICAgICAgICAgICAgbWVzc2FnZTpcbiAgICAgICAgICAgICAgZXJyb3IubWVzc2FnZSB8fFxuICAgICAgICAgICAgICBgQW4gZXJyb3Igb2NjdXJlZCB3aGlsZSBjYWxsaW5nIHByb3ZpZGVkICR7bWV0aG9kfSBtZXRob2QuYCxcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAoZXJyb3IuZGF0YSkge1xuICAgICAgICAgICAgcmVzcG9uc2UuZXJyb3IuZGF0YSA9IEpTT04ucGFyc2UoSlNPTi5zdHJpbmdpZnkoZXJyb3IuZGF0YSkpXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgVHJhbnNwb3J0LnNlbmQobW9kdWxlLCBgJHttZXRob2R9RXJyb3JgLCByZXNwb25zZSlcbiAgICAgICAgfVxuXG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgY29uc3QgcmVzdWx0ID0gcHJvdmlkZXJbbWV0aG9kXS5hcHBseShwcm92aWRlciwgcHJvdmlkZXJDYWxsQXJncylcblxuICAgICAgICAgIGlmICghKHJlc3VsdCBpbnN0YW5jZW9mIFByb21pc2UpKSB7XG4gICAgICAgICAgICB0aHJvdyBgUHJvdmlkZXIgbWV0aG9kICR7bWV0aG9kfSBkaWQgbm90IHJldHVybiBhIFByb21pc2UuYFxuICAgICAgICAgIH1cblxuICAgICAgICAgIHJlc3VsdFxuICAgICAgICAgICAgLnRoZW4oKHJlc3VsdCkgPT4ge1xuICAgICAgICAgICAgICBpZiAoaW1ldGhvZC5yZXNwb25zZSkge1xuICAgICAgICAgICAgICAgIC8vIHZvaWQgcmVzdWx0cyBzaG91bGQgYmUgbnVsbCBpbiB0aGUgSlNPTlJQQyBtZXNzYWdlXG4gICAgICAgICAgICAgICAgcmVzcG9uc2UucmVzdWx0ID0gcmVzdWx0ID09IG51bGwgPyBudWxsIDogcmVzdWx0XG4gICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICBUcmFuc3BvcnQuc2VuZChtb2R1bG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vcikge1xuICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkobmV3RXJyb3IsIFwic3RhY2tcIiwge1xuICAgICAgICAgICAgZ2V0OiAoKSA9PiB7XG4gICAgICAgICAgICAgICAgbGV0IG5ld1N0YWNrID0gbGF6eVN0YWNrLmdldC5hcHBseShuZXdFcnJvcik7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGpvaW5TdGFja3MoeyBzdGFjazogbmV3U3RhY2sgfSwgb3JpZ2luYWxFcnJvcik7XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsXG4gICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWVcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIGVsc2Uge1xuICAgICAgICBsYXp5UG9wU3RhY2sobmV3RXJyb3IsIGxhenlTdGFjayk7XG4gICAgfVxufVxuLyoqXG4gKiBSZW1vdmVzIE9ubyBmcm9tIHRoZSBzdGFjaywgc28gdGhhdCB0aGUgc3RhY2sgc3RhcnRzIGF0IHRoZSBvcmlnaW5hbCBlcnJvciBsb2NhdGlvblxuICovXG5mdW5jdGlvbiBwb3BTdGFjayhzdGFjaykge1xuICAgIGlmIChzdGFjaykge1xuICAgICAgICBsZXQgbGluZXMgPSBzdGFjay5zcGxpdChuZXdsaW5lKTtcbiAgICAgICAgLy8gRmluZCB0aGUgT25vIGNhbGwocykgaW4gdGhlIHN0YWNrLCBhbmQgcmVtb3ZlIHRoZW1cbiAgICAgICAgbGV0IG9ub1N0YXJ0O1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpbmVzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBsZXQgbGluZSA9IGxpbmVzW2ldO1xuICAgICAgICAgICAgaWYgKG9ub0NhbGwudGVzdChsaW5lKSkge1xuICAgICAgICAgICAgICAgIGlmIChvbm9TdGFydCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFdl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ICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKTtcbiAgICAgICAgfVxuICAgICAgICBjYnhkID0gdCAqICh0ICogKDMgKiB4YSkgKyAyICogeGIpICsgeGM7XG4gICAgICAgIGlmIChjYnhkID4gMWUtMTAgJiYgY2J4ZCA8IDFlLTEwKSB7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgdCArPSBkeCAvIGNieGQ7XG4gICAgICB9XG4gICAgICBsZXQgbWluVCA9IDA7XG4gICAgICBsZXQgbWF4VCA9IDE7XG4gICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgdCA9IDAuNSAqIChtaW5UICsgbWF4VCk7XG4gICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG4gICAgICAgIGR4ID0gdGltZSAtIGNieDtcbiAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5Yyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGR4IDwgMCkge1xuICAgICAgICAgIG1heFQgPSB0O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG1pblQgPSB0O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfTtcbiAgfVxuICBzdGF0aWMgZ2V0VGltaW5nRnVuY3Rpb24oc3RyKSB7XG4gICAgc3dpdGNoIChzdHIpIHtcbiAgICAgIGNhc2UgXCJsaW5lYXJcIjpcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgICByZXR1cm4gdGltZTtcbiAgICAgICAgfTtcbiAgICAgIGNhc2UgXCJlYXNlXCI6XG4gICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjI1LCAwLjEsIDAuMjUsIDEpO1xuICA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1cbiAgICAgICAgICBsZXQgYSA9IHBhcnNlRmxvYXQocGFydHNbMF0pO1xuICAgICAgICAgIGxldCBiID0gcGFyc2VGbG9hdChwYXJ0c1sxXSk7XG4gICAgICAgICAgbGV0IGMgPSBwYXJzZUZsb2F0KHBhcnRzWzJdKTtcbiAgICAgICAgICBsZXQgZCA9IHBhcnNlRmxvYXQocGFydHNbM10pO1xuICAgICAgICAgIGlmIChpc05hTihhKSB8fCBpc05hTihiKSB8fCBpc05hTihjKSB8fCBpc05hTihkKSkge1xuICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gVW5rbm93biB0aW1pbmcgZnVuY3Rpb246IFwiICsgc3RyKTtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbih0aW1lKSB7XG4gICAgICAgICAgICAgIHJldHVybiB0aW1lO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKGEsIGIsIGMsIGQpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG4gICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgICAgIHJldHVybiB0aW1lO1xuICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9XG4gIH1cbn1cbmxldCBVdGlscyQxID0gY2xhc3MgVXRpbHMge1xuICBzdGF0aWMgaXNGdW5jdGlvbih2YWx1ZSkge1xuICAgIHJldHVybiB0eXBlb2YgdmFsdWUgPT09IFwiZnVuY3Rpb25cIjtcbiAgfVxuICBzdGF0aWMgaXNOdW1iZXIodmFsdWUpIHtcbiAgICByZXR1cm4gdHlwZW9mIHZhbHVlID09PSBcIm51bWJlclwiO1xuICB9XG4gIHN0YXRpYyBpc0ludGVnZXIodmFsdWU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dW50KCk7XG4gICAgaWYgKHRvdGFsU2hyaW5rQW1vdW50KSB7XG4gICAgICBjb25zdCBpdGVtcyA9IHRoaXMuX2xpbmUuaXRlbXM7XG4gICAgICBkbyB7XG4gICAgICAgIGxldCBhbW91bnRQZXJTaHJpbmsgPSB0aGlzLl9hbW91bnRSZW1haW5pbmcgLyB0b3RhbFNocmlua0Ftb3VudDtcbiAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuX2xpbmUuc3RhcnRJbmRleDsgaSA8PSB0aGlzLl9saW5lLmVuZEluZGV4OyBpKyspIHtcbiAgICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07XG4gICAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuICAgICAgICAgIGNvbnN0IHNocmlua0Ftb3VudCA9IGZsZXhJdGVtLnNocmluaztcbiAgICAgICAgICBjb25zdCBpc1Nocmlua2FibGVJdGVtID0gc2hyaW5rQW1vdW50ID4gMDtcbiAgICAgICAgICBpZiAoaXNTaHJpbmthYmxlSXRlbSkge1xuICAgICAgICAgICAgbGV0IHNocmluayA9IHNocmlua0Ftb3VudCAqIGFtb3VudFBlclNocmluaztcbiAgICAgICAgICAgIGNvbnN0IG1pblNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNNaW5TaXplKCk7XG4gICAgICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuICAgICAgICAgICAgaWYgKHNpemUgPiBtaW5TaXplKSB7XG4gICAgICAgICAgICAgIGNvbnN0IG1heFNocmluayA9IHNpemUgLSBtaW5TaXplO1xuICAgICAgICAgICAgICBjb25zdCBpc0Z1bGx5U2hydW5rID0gc2hyaW5rID49IG1heFNocmluaztcbiAgICAgICAgICAgICAgaWYgKGlzRnVsbHlTaHJ1bmspIHtcbiAgICAgICAgICAgICAgICBzaHJpbmsgPSBtYXhTaHJpbms7XG4gICAgICAgICAgICAgICAgdG90YWxTaHJpbmtBbW91bnQgLT0gc2hyaW5rQW1vdW50O1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGNvbnN0IGZpbmFsU2l6ZSA9IHNpemUgLSBzaHJpbms7XG4gICAgICAgICAgICAgIGZsZXhJdGVtLl9yZXNpemVNYWluQXhpcyhmaW5hbFNpemUpO1xuICAgICAgICAgICAgICB0aGlzLl9zaHJ1bmtTaXplICs9IHNocmluaztcbiAgICAgICAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nIC09IHNocmluaztcbiAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPCAxZS01KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IHdoaWxlICh0b3RhbFNocmlua0Ftb3VudCAmJiBNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpID4gMWUtNSk7XG4gICAgfVxuICB9XG4gIF9nZXRUb3RhbFNocmlua0Ftb3VudCgpIHtcbiAgICBsZXQgdG90YWwgPSAwO1xuICAgIGNvbnN0IGl0ZW1zID0gdGhpcy5fbGluZS5pdGVtcztcbiAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgY29uc3QgaXRlbSA9IGl0ZW1zW2ldO1xuICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuICAgICAgaWYgKGZsZXhJdGVtLnNocmluaykge1xuICAgICAgICBjb25zdCBtaW5TaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWluU2l6ZSgpO1xuICAgICAgICBjb25zdCBzaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTGF5b3V0U2l6ZSgpO1xuICAgIC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W91bnQgPiAwO1xuICAgICAgICAgIGlmIChpc0dyb3dhYmxlSXRlbSkge1xuICAgICAgICAgICAgbGV0IGdyb3cgPSBncm93QW1vdW50ICogYW1vdW50UGVyR3JvdztcbiAgICAgICAgICAgIGNvbnN0IG1heFNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNNYXhTaXplU2V0dGluZygpO1xuICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICAgIGlmIChtYXhTaXplID4gMCkge1xuICAgICAgICAgICAgICBpZiAoc2l6ZSA+PSBtYXhTaXplKSB7XG4gICAgICAgICAgICAgICAgZ3JvdyA9IDA7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbWF4R3JvdyA9IG1heFNpemUgLSBzaXplO1xuICAgICAgICAgICAgICAgIGNvbnN0IGlzRnVsbHlHcm93biA9IGdyb3cgPj0gbWF4R3JvdztcbiAgICAgICAgICAgICAgICBpZiAoaXNGdWxseUdyb3duKSB7XG4gICAgICAgICAgICAgICAgICBncm93ID0gbWF4R3JvdztcbiAgICAgICAgICAgICAgICAgIHRvdGFsR3Jvd0Ftb3VudCAtPSBncm93QW1vdW50O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGdyb3cgPiAwKSB7XG4gICAgICAgICAgICAgIGNvbnN0IGZpbmFsU2l6ZSA9IHNpemUgKyBncm93O1xuICAgICAgICAgICAgICBmbGV4SXRlbS5fcmVzaXplTWFpbkF4aXMoZmluYWxTaXplKTtcbiAgICAgICAgICAgICAgdGhpcy5fZ3Jvd25TaXplICs9IGdyb3c7XG4gICAgICAgICAgICAgIHRoaXMuX2Ftb3VudFJlbWFpbmluZyAtPSBncm93O1xuICAgICAgICAgICAgICBpZiAoTWF0aC5hYnModGhpcy5fYW1vd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odGhpcy5fcGFyZW50ID09PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZGVjWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBuZXdaUGFyZW50ID0gdGhpcy5fcGFyZW50O1xuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKHpJbmRleCAhPT0gMCAmJiB0aGlzLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgbmV3WlBhcmVudCA9IHRoaXMuX3BhcmVudCA/IHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKSA6IG51bGw7XG4gICAgICAgIGlmIChuZXdaUGFyZW50ID09PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuaW5jWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSBlbHNlIGlmICh6SW5kZXggIT09IHRoaXMuX3pJbmRleCkge1xuICAgICAgICBpZiAodGhpcy5felBhcmVudCAmJiB0aGlzLl96UGFyZW50Ll96Q29udGV4dFVzYWdlKSB7XG4gICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAobmV3WlBhcmVudCAhPT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICB0aGlzLnNldFpQYXJlbnQobnVsbCk7XG4gICAgICB9XG4gICAgICB0aGlzLl96SW5kZXggPSB6SW5kZXg7XG4gICAgICBpZiAobmV3WlBhcmVudCAhPT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICB0aGlzLnNldFpQYXJlbnQobmV3W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ICYmIHZpc2libGUpIHtcbiAgICAgICAgICB0aGlzLl9oYXNSZW5kZXJVcGRhdGVzID0gMztcbiAgICAgICAgfVxuICAgICAgICB3LmFscGhhID0gcHcuYWxwaGEgKiB0aGlzLl9sb2NhbEFscGhhO1xuICAgICAgICBpZiAody5hbHBoYSA8IDFlLTE0KSB7XG4gICAgICAgICAgdy5hbHBoYSA9IDA7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChyZWNhbGMgJiA2KSB7XG4gICAgICAgIHcucHggPSBwdy5weCArIHRoaXMuX2xvY2FsUHggKiBwdy50YTtcbiAgICAgICAgdy5weSA9IHB3LnB5ICsgdGhpcy5fbG9jYWxQeSAqIHB3LnRkO1xuICAgICAgICBpZiAocHcudGIgIT09IDApXG4gICAgICAgICAgdy5weCArPSB0aGlzLl9sb2NhbFB5ICogcHcudGI7XG4gICAgICAgIGlmIChwdy50YyAhPT0gMClcbiAgICAgICAgICB3LnB5ICs9IHRoaXMuX2xvY2FsUHggKiBwdy50YztcbiAgICAgIH1cbiAgICAgIGlmIChyZWNhbGMgJiA0KSB7XG4gICAgICAgIHcudGEgPSB0aGlzLl9sb2NhbFRhICogcHcudGE7XG4gICAgICAgIHcudGIgPSB0aGlzLl9sb2NhbFRkICogcHcudGI7XG4gICAgICAgIHcudGMgPSB0aGlzLl9sb2NhbFRhICogcHcudGM7XG4gICAgICAgIHcudGQgPSB0aGlzLl9sb2NhbFRkICogcHcudGQ7XG4gICAgICAgIGlmICh0aGlzLl9pc0NvbXBsZXgpIHtcbiAgICAgICAgICB3LnRhICs9IHRoaXMuX2xvY2FsVGMgKiBwdy50YjtcbiAgICAgICAgICB3LnRiICs9IHRoaXMuX2xvY2FsVGIgKiBwdy50YTtcbiAgICAgICAgICB3LnRjICs9IHRoaXMuX2xvY2FsVGMgKiBwdy50ZDtcbiAgICAgICAgICB3LnRkICs9IHRoaXMuX2xvY2FsVGIgKiBwdy50YztcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgY29uc3QgcHIgPSB0aGlzLl9wYXJlbnQuX3JlbmRlckNvbnRleHQ7XG4gICAgICBpZiAodGhpcy5fcGFyZW50Ll9oYXNSZW5kZXJDb250ZXh0KCkpIHtcbiAgICAgICAgY29uc3QgaW5pdCA9IHRoaXMuX3JlbmRlckNvbnRleHQgPT09IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgaWYgKGluaXQpIHtcbiAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gbmV3IEVsZW1lbnRDb3JlQ29udGV4dCgpO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IHIyID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICAgICAgaWYgKGluaXQgfHwgcmVjYWxjICYgMSkge1xuICAgICAgICAgIHIyLmFscGhhID0gcHIuYWxwaGEgKiB0aGlzLl9sb2NhbEFscGhhO1xuICAgICAgICAgIGlmIChyMi5hbHBoYSA8IDFlLTE0KSB7XG4gICAgICAgICAgICByMi5hbHBoYSA9IDA7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChpbml0IHx8IHJlY2FsYyAmIDYpIHtcbiAgICAgICAgICByMi5weCA9IHByLnB4ICsgdGhpcy5fbG9jYWxQeCAqIHByLnRhO1xuICAgICAgICAgIHIyLnB5ID0gcHIucHkgKyB0aGlzLl9sb2NhbFB5ICogcHIudGQ7XG4gICAgICAgICAgaWYgKHByLnRiICE9PSAwKVxuICAgICAgICAgICAgcjIucHggKz0gdGhpcy5fbG9jYWxQeSAqIHByLnRiO1xuICAgICAgICAgIGlmIChwci50YyAhPT0gMClcbiAgICAgICAgICAgIHIyLnB5ICs9IHRoaXMuX2xvY2FsUHggKiBwci50YztcbiAgICAgICAgfVxuICAgICAgICBpZiAoaW5pdCkge1xuICAgICAgICAgIHJlY2FsYyB8PSAyO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpbml0IHx8IHJlY2FsYyAmIDQpIHtcbiAgICAgICAgICByMi50YSA9IHRoaXMuX2xvY2FsVGEgKiBwci50YTtcbiAgICAgICAgICByMi50YiA9IHRoaXMuX2xvY2FsVGQgKiBwci50YjtcbiAgICAgICAgICByMi50YyA9IHRoaXMuX2xvY2FsVGEgKiBwci50YztcbiAgICAgICAgICByMi50ZCA9IHRoaXMuX2xvY2FsVGQgKiBwci50ZDtcbiAgICAgICAgICBpZiAodGhpcy5faXNDb21wbGV4KSB7XG4gICAgICAgICAgICByMi50YSArPSB0aGlzLl9sb2NhbFRjICogcHIudGI7XG4gICAgICAgICAgICByMi50YiArPSB0aGlzLl9sb2NhbFRiICogcHIudGE7XG4gICAgICAgICAgICByMi50YyArPSB0aGlzLl9sb2NhbFRjICogcHIudGQ7XG4gICAgICAgICAgICByMi50ZCArPSB0aGlzLl9sb2NhbFRiICogcHIudGM7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlciA9PT0gLTEpIHtcbiAgICAgICAgdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID0gdGhpcy5fdXBkYXRlVHJlZU9yZGVyICsgMTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRyZWVPcmRlciA9IHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlcisrO1xuICAgICAgfVxuICAgICAgY29uc3QgdXNlUmVuZGVyVG9UZXh0dXJlID0gdGhpcy5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCAmJiB0aGlzLl90ZXh0dXJpemVyLm11c3RSZW5kZXJUb1RleHR1cmUoKTtcbiAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUgIT09IHVzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICB0aGlzLl9yZWNhbGMgfD0gMiArIDQ7XG4gICAgICAgIHJlY2FsYyB8PSAyO1xuICAgICAgICBpZiAoIXRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZSgpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUgPSB1c2VSZW5kZXJUb1RleHR1cmU7XG4gICAgICBjb25zdCByID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICAgIGNvbnN0IGJib3hXID0gdGhpcy5fZGltc1Vua25vd24gPyAyMDQ4IDogdGhpcy5fdztcbiAgICAgIGNvbnN0IGJib3hIID0gdGhpcy5fZGltc1Vua25vd24gPyAyMDQ4IDogdGhpcy5faDtcbiAgICAgIGxldCBzeCwgc3ksIGV4LCBleTtcbiAgICAgIGNvbnN0IHJDb21wbGV4ID0gci50YiAhPT0gMCB8fCByLnRjICE9PSAwIHx8IHIudGEgPCAwIHx8IHIudGQgPCAwO1xuICAgICAgaWYgKHJDb21wbGV4KSB7XG4gICAgICAgIHN4ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICBleCA9IE1hdGgubWF4KDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgc3kgPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgIGV5ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgc3ggPSByLnB4O1xuICAgICAgICBleCA9IHIucHggKyByLnRhICogYmJveFc7XG4gICAgICAgIHN5ID0gci5weTtcbiAgICAgICAgZXkgPSByLnB5ICsgci50ZCAqIGJib3hIO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX2RpbXNVbmtub3duICYmIChyQ29tcGxleCB8fCB0aGlzLl9sb2NhbFRhIDwgMSB8fCB0aGlzLl9sb2NhbFRiIDwgMSkpIHtcbiAgICAgICAgY29uc3QgbnggPSB0aGlzLl94ICogcHIudGEgKyB0aGlzLl95ICogcHIudGIgKyBwci5weDtcbiAgICAgICAgY29uc3QgbnkgPSB0aGlzLl94ICogcHIudGMgKyB0aGlzLl95ICogcHIudGQgKyBwci5weTtcbiAgICAgICAgaWYgKG54IDwgc3gpXG4gICAgICAgICAgc3ggPSBueDtcbiAgICAgICAgaWYgKG55IDwgc3kpXG4gICAgICAgICAgc3kgPSBueTtcbiAgICAgICAgaWYgKG54ID4gZXgpXG4gICAgICAgICAgZXggPSBueDtcbiAgICAgICAgaWYgKG55ID4gZXkpXG4gICAgICAgICAgZXkgPSBueTtcbiAgICAgIH1cbiAgICAgIGlmIChyZWNhbGMgJiA2IHx8ICF0aGlzLl9zY2lzc29yKSB7XG4gICAgICAgIGlmICh0aGlzLl9jbGlwcGluZyAmJiByLmlzU3F1YXJlKCkpIHtcbiAgICAgICAgICBjb25zdCBhcmVhID0gdGhpcy5fcGFyZW50Ll91c2VSZW5kZXJUb1RleHR1cmUgPyB0aGlzLl9wYXJlbnQuX3ZpZXdwb3J0IDogdGhpcy5fcGFyZW50Ll9zY2lzc29yO1xuICAgICAgICAgIGlmIChhcmVhKSB7XG4gICAgICAgICAgICBjb25zdCBseCA9IE1hdGgubWF4KGFyZWFbMF0sIHN4KTtcbiAgICAgICAgICAgIGNvbnN0IGx5ID0gTWF0aC5tYXgoYXJlYVsxXSwgc3kpO1xuICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IFtcbiAgICAgICAgICAgICAgbHgsXG4gICAgICAgICAgICAgIGx5LFxuICAgICAgICAgICAgICBNYXRoLm1pbihhcmVhWzJdICsgYXJlYVswXSwgZXgpIC0gbHgsXG4gICAgICAgICAgICAgIE1hdGgubWluKGFyZWFbM10gKyBhcmVhWzFdLCBleSkgLSBseVxuICAgICAgICAgICAgXTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IFtzeCwgc3ksIGV4IC0gc3gsIGV5IC0gc3ldO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl9zY2lzc29yID0gdGhpcy5fcGFyZW50Ll91c2VSZW5kZXJUb1RleHR1cmUgPyB0aGlzLl9wYXJlbnQuX3ZpZXdwb3J0IDogdGhpcy5fcGFyZW50Ll9zY2lzc29yO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fYm91bmRzTWFyZ2luKSB7XG4gICAgICAgIHRoaXMuX3JlY0JvdW5kc01hcmdpbiA9IHRoaXMuX2JvdW5kc01hcmdpbjtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRoaXMuX3JlY0JvdW5kc01hcmdpbiA9IHRoaXMuX3BhcmVudC5fcmVjQm91bmRzTWFyZ2luO1xuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX29uQWZ0ZXJDYWxjcykge1xuICAgICAgICBpZiAodGhpcy5fb25BZnRlckNhbGNzKHRoaXMuZWxlbWVudCkpIHtcbiAgICAgICAgICBpZiAockNvbXBsZXgpIHtcbiAgICAgICAgICAgIHN4ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgZXggPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICBzeSA9IE1hdGgubWluKDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICAgIGV5ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzeCA9IHIucHg7XG4gICAgICAgICAgICBleCA9IHIucHggKyByLnRhICogYmJveFc7XG4gICAgICAgICAgICBzeSA9IHIucHk7XG4gICAgICAgICAgICBleSA9IHIucHkgKyByLnRkICogYmJveEg7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0aGlzLl9kaW1zVW5rbm93biAmJiAockNvbXBsZXggfHwgdGhpcy5fbG9jYWxUYSA8IDEgfHwgdGhpcy5fbG9jYWxUYiA8IDEpKSB7XG4gICAgICAgICAgICBjb25zdCBueCA9IHRoaXMuX3ggKiBwci50YSArIHRoaXMuX3kgKiBwci50YiArIHByLnB4O1xuICAgICAgICAgICAgY29uc3QgbnkgPSB0aGlzLl94ICogcHIudGMgKyB0aGlzLl95ICogcHIudGQgKyBwci5weTtcbiAgICAgICAgICAgIGlmIChueCA8IHN4KVxuICAgICAgICAgICAgICBzeCA9IG54O1xuICAgICAgICAgICAgaWYgKG55IDwgc3kpXG4gICAgICAgICAgICAgIHN5ID0gbnk7XG4gICAgICAgICAgICBpZiAobnggPiBleClcbiAgICAgICAgICAgICAgZXggPSBueDtcbiAgICAgICAgICAgIGlmIChueSA+IGV5KVxuICAgICAgICAgICAgICBleSA9IG55O1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX3BhcmVudC5fb3V0T2ZCb3VuZHMgPT09IDIpIHtcbiAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuICAgICAgICBpZiAodGhpcy5fd2l0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l9vdXRPZkJvdW5kcyA9IDE7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbiAhPT0gd2l0aGluTWFyZ2luKSB7XG4gICAgICAgICAgICB0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4gPSB3aXRoaW5NYXJnaW47XG4gICAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgIHRoaXMuX2hhc1VwZGF0ZXMgPSB0cnVlO1xuICAgICAgICAgICAgICBjb25zdCByZWNhbGMyID0gdGhpcy5fcmVjYWxjO1xuICAgICAgICAgICAgICB0aGlzLl9yZWNhbGMgPSAwO1xuICAgICAgICAgICAgICB0aGlzLmVsZW1lbnQuX2VuYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgICAgICBpZiAodGhpcy5fcmVjYWxjKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudXBkYXRlKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgdGhpcy5fcmVjYWxjID0gcmVjYWxjMjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZGlzYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICBpZiAodGhpcy5fdmlld3BvcnQpIHtcbiAgICAgICAgICB0aGlzLl92aWV3cG9ydFsyXSA9IGJib3hXO1xuICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0WzNdID0gYmJveEg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fdmlld3BvcnQgPSBbMCwgMCwgY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XN1bHRUZXh0dXJlKSB7XG4gICAgICAgICAgICAgIHJlc3VsdFRleHR1cmUudXBkYXRlID0gcmVuZGVyU3RhdGUuc3RhZ2UuZnJhbWVDb3VudGVyO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci51cGRhdGVSZXN1bHRUZXh0dXJlKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5yZW5kZXJPZmZzY3JlZW4pIHtcbiAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNoYWRlcih0aGlzLmFjdGl2ZVNoYWRlciwgdGhpcy5fc2hhZGVyT3duZXIpO1xuICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2Npc3Nvcih0aGlzLl9zY2lzc29yKTtcbiAgICAgICAgICAgIGNvbnN0IGNhY2hlID0gIXJlbmRlclRleHR1cmVJbmZvIHx8IHJlbmRlclRleHR1cmVJbmZvLmNhY2hlO1xuICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0VGV4dHVyaXplcih0aGlzLl90ZXh0dXJpemVyLCBjYWNoZSk7XG4gICAgICAgICAgICB0aGlzLl9zdGFzaFRleENvb3JkcygpO1xuICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLmNvbG9yaXplKVxuICAgICAgICAgICAgICB0aGlzLl9zdGFzaENvbG9ycygpO1xuICAgICAgICAgICAgdGhpcy5yZW5kZXJTdGF0ZS5hZGRRdWFkKHRoaXMsIHRydWUpO1xuICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLmNvbG9yaXplKVxuICAgICAgICAgICAgICB0aGlzLl91bnN0YXNoQ29sb3JzKCk7XG4gICAgICAgICAgICB0aGlzLl91bnN0YXNoVGV4Q29vcmRzKCk7XG4gICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRUZXh0dXJpemVyKG51bGwpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHJlbmRlclRleHR1cmVJbmZvICYmIHJlbmRlclRleHR1cmVJbmZvLmNhY2hlKSB7XG4gICAgICAgIHJlbmRlclN0YXRlLmlzQ2FjaGluZ1RleHR1cml6ZXIgPSBmYWxzZTtcbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgZ2V0IHpTb3J0KCkge1xuICAgIHJldHVybiB0aGlzLl96U29ydDtcbiAgfVxuICBzb3J0WkluZGV4ZWRDaGlsZHJlbigpIHtcbiAgICBjb25zdCBuID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5sZW5ndGg7XG4gICAgbGV0IHB0ciA9IDA7XG4gICAgY29uc3QgYSA9IHRoaXMuX3pJbmRleGVkQ2hpbGRyZW47XG4gICAgY29uc3QgYiA9IFtdO1xuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICBpZiAoYVtpXS5felBhcmVudCA9PT0gdGhpcykge1xuICAgICAgICBpZiAoYVtpXS5fekluZGV4UmVzb3J0KSB7XG4gICAgICAgICAgYi5wdXNoKGFbaV0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmIChwdHIgIT09IGkpIHtcbiAgICAgICAgICAgIGFbcHRyXSA9IGFbaV07XG4gICAgICAgICAgfVxuICAgICAgICAgIHB0cisrO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGNvbnN0IG0gPSBiLmxlbmd0aDtcbiAgICBpZiAobSkge1xuICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBtOyBqKyspIHtcbiAgICAgICAgYltqXS5fekluZGV4UmVzb3J0ID0gZmFsc2U7XG4gICAgICB9XG4gICAgICBiLnNvcnQoRWxlbWVudENvcmUuc29ydFpJbmRleGVkQ2hpbGRyZW4pO1xuICAgICAgY29uc3QgbjIgPSBwdHI7XG4gICAgICBpZiAoIW4yKSB7XG4gICAgICAgIHB0ciA9IDA7XG4gICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgZG8ge1xuICAgICAgICAgIGFbcHRyKytdID0gYltqKytdO1xuICAgICAgICB9IHdoaWxlIChqIDwgbSk7XG4gICAgICAgIGlmIChhLmxlbmd0aCA+IHB0cikge1xuICAgICAgICAgIGEuc3BsaWNlKHB0cik7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHB0ciA9IDA7XG4gICAgICAgIGxldCBpID0gMDtcbiAgICAgICAgbGV0IGogPSAwO1xuICAgICAgICBjb25zdCBtZXJnZVJlc3VsdCA9IFtdO1xuICAgICAgICBkbyB7XG4gICAgICAgICAgY29uc3QgdiA9IGFbaV0uX3pJbmRleCA9PT0gYltqXS5fekluZGV4ID8gYVtpXS5fdXBkYXRlVHJlZU9yZGVyIC0gYltqXS5fdXBkYXRlVHJlZU9yZGVyIDogYVtpXS5fekluZGV4IC0gYltqXS5fekluZGV4O1xuICAgICAgICAgIGNvbnN0IGFkZCA9IHYgPiAwID8gYltqKytdIDogYVtpKytdO1xuICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgbWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZCkge1xuICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaSA+PSBuMikge1xuICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICBjb25zdCBhZGQyID0gYltqKytdO1xuICAgICAgICAgICAgICBpZiAocHRyID09PSAwIHx8IG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQyKSB7XG4gICAgICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkMjtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSB3aGlsZSAoaiA8IG0pO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfSBlbHNlIGlmIChqID49IG0pIHtcbiAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgY29uc3QgYWRkMiA9IGFbaSsrXTtcbiAgICAgICAgICAgICAgaWYgKHB0ciA9PT0gMCB8fCBtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkMikge1xuICAgICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDI7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUgKGkgPCBuMik7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH0gd2hpbGUgKHRydWUpO1xuICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuID0gbWVyZ2VSZXN1bHQ7XG4gICAgICB9XG4gICAgfSBlbHNlIHtcbiAgICAgIGlmIChhLmxlbmd0aCA+IHB0cikge1xuICAgICAgICBhLnNwbGljZShwdHIpO1xuICAgICAgfVxuICAgIH1cbiAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuICB9XG4gIGdldCBsb2NhbFRhKCkge1xuICAgIHJldHVybiB0aGlzLl9sb2NhbFRhO1xuICB9XG4gIGdldCBsb2NhbFRiKCkge1xuICAgIHJldHVybiB0aGlzLl9sb2NhbFRiO1xuICB9XG4gIGdldCBsb2NhbFRjKCkge1xuICAgIHJldHVybiB0aGlzLl9sb2NhbFRjO1xuICB9XG4gIGdldCBsb2NhbFRkKCkge1xuICAgIHJldHVybiB0aGlzLl9sb2NhbFRkO1xuICB9XG4gIGdldCBlbGVtZW50KCkge1xuICAgIHJldHVybiB0aGlzLl9lbGVtZW50O1xuICB9XG4gIGdldCByZW5kZXJVcGRhdGVzKCkge1xuICAgIHJldHVybiB0aGlzLl9oYXNSZW5kZXJVcGRhdGVzO1xuICB9XG4gIGdldCB0ZXh0dXJpemVyKCkge1xuICAgIGlmICghdGhpcy5fdGV4dHVyaXplcikge1xuICAgICAgdGhpcy5fdGV4dHVyaXplciA9IG5ldyBFbGVtZW50VGV4dHVyaXplcih0aGlzKTtcbiAgICB9XG4gICAgcmV0dXJuIHRoaXMuX3RleHR1cml6ZXI7XG4gIH1cbiAgZ2V0Q29ybmVyUG9pbnRzKCkge1xuICAgIGxldCB3ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgIHJldHVybiBbXG4gICAgICB3LnB4LFxuICAgICAgdy5weSxcbiAgICAgIHcucHggKyB0aGlzLl93ICogdy50YSxcbiAgICAgIHcucHkgKyB0aGlzLl93ICogdy50YyxcbiAgICAgIHcucHggKyB0aGlzLl93ICogdy50YSArIHRoaXMuX2ggKiB3LnRiLFxuICAgICAgdy5weSArIHRoaXMuX3cgKiB3LnRjICsgdGhpcy5faCAqIHcudGQsXG4gICAgICB3LnB4ICsgdGhpcy5faCAqIHcudGIsXG4gICAgICB3LnB5ICsgdGhpcy5faCAqIHcudGRcbiAgICBdO1xuICB9XG4gIGdldFJlbmRlclRleHR1cmVDb29yZHMocmVsWCwgcmVsWSkge1xuICAgIGxldCByID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICByZXR1cm4gW1xuICAgICAgci5weCArIHIudGEgKiByZWxYICsgci50YiAqIHJlbFksXG4gICAgICByLnB5ICsgci50YyAqIHJlbFggKyByLnRkICogcmVsWVxuICAgIF07XG4gIH1cbiAgZ2V0QWJzb2x1dGVDb29yZHMocmVsWCwgcmVsWSkge1xuICAgIGxldCB3ID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICByZXR1cm4gW1xuICAgICAgdy5weCArIHcudGEgKiByZWxYICsgdy50YiAqIHJlbFksXG4gICAgICB3LnB5ICsgdy50YyAqIHJlbFggKyB3LnRkICogcmVsWVxuICAgIF07XG4gIH1cbiAgY29sbGVjdEF0Q29vcmQoeCwgeSwgY2hpbGRyZW4pIHtcbiAgICBpZiAodGhpcy5fcmVuZGVyQ29udGV4dC5hbHBoYSA9PT0gMCkge1xuICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBpZiAodGhpcy5pbkJvdW5kKHgsIHkpKSB7XG4gICAgICBpZiAodGhpcy5fc2Npc3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ZXNpemVNb2RlKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHRoaXMuZWxlbWVudHMuZm9yRWFjaCgoZWxlbWVudCkgPT4ge1xuICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgIGVsZW1lbnQuX3NldERpc3BsYXllZFRleHR1cmUodGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgY29uc3QgbG9hZEVycm9yID0gbmV3U291cmNlLmxvYWRFcnJvcjtcbiAgICAgICAgICBpZiAobG9hZEVycm9yKSB7XG4gICAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goKGVsZW1lbnQpID0+IHtcbiAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5vblRleHR1cmVTb3VyY2VMb2FkRXJyb3IobG9hZEVycm9yKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goKGVsZW1lbnQpID0+IHtcbiAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgIGVsZW1lbnQuX3NldERpc3BsYXllZFRleHR1cmUobnVsbCk7XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgbG9hZCgpIHtcbiAgICBpZiAodGhpcy5zb3VyY2UpIHtcbiAgICAgIGlmICghdGhpcy5pc0xvYWRlZCgpKSB7XG4gICAgICAgIHRoaXMuc291cmNlLmxvYWQodHJ1ZSk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIGlzTG9hZGVkKCkge1xuICAgIHJldHVybiB0aGlzLl9zb3VyY2UgJiYgdGhpcy5fc291cmNlL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4gICAgICAgIHRoaXMuX3N0YWdlLmdldE9wdGlvbihcImRlZmF1bHRGb250RmFjZVwiKVxuICAgICAgKTtcbiAgICAgIHRyeSB7XG4gICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmZvbnRzLmxvYWQoZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpLmNhdGNoKChlcnIpID0+IHtcbiAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIEZvbnQgbG9hZCBlcnJvclwiLCBlcnIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICB9KS50aGVuKCgpID0+IHtcbiAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIEZvbnQgbm90IGZvdW5kXCIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBDYW4ndCBjaGVjayBmb250IGxvYWRpbmcgZm9yIFwiICsgZm9udFNldHRpbmcpO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICBkcmF3KCkge1xuICAgIGNvbnN0IGxvYWRQcm9taXNlID0gdGhpcy5fbG9hZCgpO1xuICAgIGlmICghbG9hZFByb21pc2UpIHtcbiAgICAgIHJldHVybiBVdGlscyQxLmlzU3BhcmsgPyB0aGlzLl9zdGFnZS5wbGF0Zm9ybS5kcmF3VGV4dCh0aGlzKSA6IHRoaXMuX2RyYXcoKTtcbiAgICB9IGVsc2Uge1xuICAgICAgcmV0dXJuIGxvYW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0T3B0aW9uKFwiZGVmYXVsdEZvbnRGYWNlXCIpXG4gICAgICApO1xuICAgICAgdHJ5IHtcbiAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuZm9udHMubG9hZChmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkuY2F0Y2goKGVycikgPT4ge1xuICAgICAgICAgICAgY29uc29sZS53YXJuKFwiRm9udCBsb2FkIGVycm9yXCIsIGVyciwgZm9udFNldHRpbmcpO1xuICAgICAgICAgIH0pLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiRm9udCBub3QgZm91bmRcIiwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIGNvbnNvbGUud2FybihcIkNhbid0IGNoZWNrIGZvbnQgbG9hZGluZyBmb3IgXCIgKyBmb250U2V0dGluZyk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIGRyYXcoKSB7XG4gICAgY29uc3QgbG9hZFByb21pc2UgPSB0aGlzLl9sb2FkKCk7XG4gICAgaWYgKCFsb2FkUHJvbWlzZSkge1xuICAgICAgcmV0dXJuIFV0aWxzJDEuaXNTcGFyayA/IHRoaXMuX3N0YWdlLnBsYXRmb3JtLmRyYXdUZXh0KHRoaXMpIDogdGhpcy5fZHJhdygpO1xuICAgIH0gZWxzZSB7XG4gICAgICByZXR1cm4gbG9hZFByb21pc2UudGhlbigoKSA9PiB7XG4gICAgICAgIHJldHVybiBVdGlscyQxLmlzU3BhcmsgPyB0aGlzLl9zdGFnZS5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lzLl9zZXR0aW5ncy5zaGFkb3dCbHVyICogcHJlY2lzaW9uO1xuICAgIH1cbiAgICBjb25zdCBkZWZhdWx0Q29sb3IgPSBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodGhpcy5fc2V0dGluZ3MudGV4dENvbG9yKTtcbiAgICBsZXQgY3VycmVudENvbG9yID0gZGVmYXVsdENvbG9yO1xuICAgIHRoaXMuX2NvbnRleHQuZmlsbFN0eWxlID0gZGVmYXVsdENvbG9yO1xuICAgIGZvciAoY29uc3QgbGluZSBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICBmb3IgKGNvbnN0IHQgb2YgbGluZS50ZXh0KSB7XG4gICAgICAgIGxldCBseCA9IDA7XG4gICAgICAgIGlmICh0LnRleHQgPT0gXCJcXG5cIikge1xuICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChyZW5kZXJJbmZvLm1heExpbmVzICYmIHQubGluZU5vID49IHJlbmRlckluZm8ubWF4TGluZXMpIHtcbiAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodC5jb2xvciAhPSBjdXJyZW50Q29sb3IpIHtcbiAgICAgICAgICBjdXJyZW50Q29sb3IgPSB0LmNvbG9yO1xuICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFN0eWxlID0gY3VycmVudENvbG9yO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IHQuZm9udFN0eWxlO1xuICAgICAgICBpZiAodC5sZXR0ZXJzKSB7XG4gICAgICAgICAgZm9yIChsZXQgbCBvZiB0LmxldHRlcnMpIHtcbiAgICAgICAgICAgIGNvbnN0IF94ID0gcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueCArIHQueCArIGx4O1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsVGV4dChsLnRleHQsIF94LCByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS55ICsgcmVuZGVySW5mby5mb250U2l6ZSk7XG4gICAgICAgICAgICBseCArPSBsLndpZHRoO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjb25zdCBfeCA9IHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnggKyB0Lng7XG4gICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsVGV4dCh0LnRleHQsIF94LCByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS55ICsgcmVuZGVySW5mby5mb250U2l6ZSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgaWYgKHByZXZTaGFkb3dTZXR0aW5ncykge1xuICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dDb2xvciA9IHByZXZTaGFkb3dTZXR0aW5nc1swXTtcbiAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93T2Zmc2V0WCA9IHByZXZTaGFkb3dTZXR0aW5nc1sxXTtcbiAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93T2Zmc2V0WSA9IHByZXZTaGFkb3dTZXR0aW5nc1syXTtcbiAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Qmx1ciA9IHByZXZTaGFkb3dTZXR0aW5nc1szXTtcbiAgICB9XG4gICAgaWYgKHJlbmRlckluZm8uY3V0U3ggfHwgcmVuZGVySW5mby5jdXRTeSkge1xuICAgICAgdGhpcy5fY29udGV4dC50cmFuc2xhdGUocmVuZGVySW5mby5jdXRTeCwgcmVuZGVySW5mby5jdXRTeSk7XG4gICAgfVxuICAgIHJlbmRlckluZm8ubGluZXMgPSByZW5kZXJJbmZvLmxpbmVzLm1hcCgobCkgPT4gbC50ZXh0LnJlZHVjZSgoYWNjLCB2KSA9PiBhY2MgKyB2LnRleHQsIFwiXCIpKTtcbiAgICBpZiAocmVuZGVySW5mby5tYXhMaW5lcykge1xuICAgICAgcmVuZGVySW5mby5saW5lcyA9IHJlbmRlckluZm8ubGluZXMuc2xpY2Uo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CA+IDApIHtcbiAgICAgICAgYm9sZCAtPSAxO1xuICAgICAgICB0ID0gXCJcIjtcbiAgICAgIH0gZWxzZSBpZiAodCA9PSBcIjwvY29sb3I+XCIpIHtcbiAgICAgICAgaWYgKGNvbG9yU3RhY2subGVuZ3RoID4gMSkge1xuICAgICAgICAgIGNvbG9yIC09IDE7XG4gICAgICAgICAgY29sb3JTdGFjay5wb3AoKTtcbiAgICAgICAgfVxuICAgICAgICB0ID0gXCJcIjtcbiAgICAgIH0gZWxzZSBpZiAoY29sb3JSZWdleHAudGVzdCh0KSkge1xuICAgICAgICBjb25zdCBtYXRjaGVkID0gY29sb3JSZWdleHAuZXhlYyh0KTtcbiAgICAgICAgY29sb3JTdGFjay5wdXNoKFxuICAgICAgICAgIFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyhwYXJzZUludChtYXRjaGVkWzFdKSlcbiAgICAgICAgKTtcbiAgICAgICAgY29sb3IgKz0gMTtcbiAgICAgICAgdCA9IFwiXCI7XG4gICAgICB9XG4gICAgICByZXR1cm4ge1xuICAgICAgICB0ZXh0OiB0LFxuICAgICAgICBpdGFsaWMsXG4gICAgICAgIGJvbGQsXG4gICAgICAgIGNvbG9yOiBjb2xvclN0YWNrW2NvbG9yXVxuICAgICAgfTtcbiAgICB9KS5maWx0ZXIoKG8pID0+IG8udGV4dCAhPSBcIlwiKTtcbiAgfVxuICBhcHBseUZvbnRTdHlsZSh3b3JkLCBiYXNlRm9udCkge1xuICAgIGxldCBmb250ID0gYmFzZUZvbnQ7XG4gICAgaWYgKHdvcmQuYm9sZCkge1xuICAgICAgZm9udCA9IFwiYm9sZCBcIiArIGZvbnQ7XG4gICAgfVxuICAgIGlmICh3b3JkLml0YWxpYykge1xuICAgICAgZm9udCA9IFwiaXRhbGljIFwiICsgZm9udDtcbiAgICB9XG4gICAgdGhpcy5fY29udGV4dC5mb250ID0gZm9udDtcbiAgICB3b3JkLmZvbnRTdHlsZSA9IGZvbnQ7XG4gIH1cbiAgc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kge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHRleHQgPSB0ZXh0LnNsaWNlKGJyZWFrSW5kZXgpO1xuICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICBsZXQgdG90YWxXaWR0aCA9IDA7XG4gICAgICBsZXQgbGV0dGVycyA9IFtdO1xuICAgICAgbGV0IGJyZWFrSW5kZXggPSAwO1xuICAgICAgZm9yIChjb25zdCBsIG9mIHdvcmQubGV0dGVycykge1xuICAgICAgICBpZiAodG90YWxXaWR0aCArIGwud2lkdGggPj0gd2lkdGgpIHtcbiAgICAgICAgICBwYXJ0cy5wdXNoKHsgLi4ud29yZCB9KTtcbiAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5zbGljZSgwLCBicmVha0luZGV4KTtcbiAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS53aWR0aCA9IHRvdGFsV2lkdGg7XG4gICAgICAgICAgcGFydHNbcGFydHMubGVuZ3RoIC0gMV0ubGV0dGVycyA9IGxldHRlcnM7XG4gICAgICAgICAgdGV4dCA9IHRleHQuc2xpY2UoYnJlYWtJbmRleCk7XG4gICAgICAgICAgdG90YWxXaWR0aCA9IDA7XG4gICAgICAgICAgbGV0dGVycyA9IFtdO1xuICAgICAgICAgIGJyZWFrSW5kZXggPSAwO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGJyZWFrSW5kZXggKz0gMTtcbiAgICAgICAgICBsZXR0ZXJzLnB1c2gobCk7XG4gICAgICAgICAgdG90YWxXaWR0aCArPSBsLndpZHRoO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAodG90YWxXaWR0aCA+IDApIHtcbiAgICAgICAgcGFydHMucHVzaCh7IC4uLndvcmQgfSk7XG4gICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLnRleHQgPSB0ZXh0LnNsaWNlKDAsIGJyZWFrSW5kZX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Z3Mua2V5cygpKTtcbiAgICAgICAgbiA9IHRhZ3MubGVuZ3RoO1xuICAgICAgICBpZiAobiA+IDApIHtcbiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbGV0IHRhZ1NldCA9IHRoaXMuX190cmVlVGFncy5nZXQodGFnc1tpXSk7XG4gICAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgICB3aGlsZSAocCA9IHAuX19wYXJlbnQpIHtcbiAgICAgICAgICAgICAgbGV0IHBhcmVudFRyZWVUYWdzID0gcC5fX3RyZWVUYWdzLmdldCh0YWdzW2ldKTtcbiAgICAgICAgICAgICAgdGFnU2V0LmZvckVhY2goZnVuY3Rpb24oY29tcCkge1xuICAgICAgICAgICAgICAgIHBhcmVudFRyZWVUYWdzLmRlbGV0ZShjb21wKTtcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICB9XG4gIF9zZXRUYWdzUGFyZW50KCkge1xuICAgIGlmICh0aGlzLl9fdGFncykge1xuICAgICAgdGhpcy5fX3RhZ3MuZm9yRWFjaCgodGFnKSA9PiB7XG4gICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgd2hpbGUgKHAgPSBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgIHAuX190cmVlVGFncyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgcyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgU2V0KCk7XG4gICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHMuYWRkKHRoaXMpO1xuICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9KTtcbiAgICB9XG4gICAgaWYgKHRoaXMuX190cmVlVGFncyAmJiB0aGlzLl9fdHJlZVRhZ3Muc2l6ZSkge1xuICAgICAgaWYgKCF0aGlzLl9fdGFnUm9vdCkge1xuICAgICAgICB0aGlzLl9fdHJlZVRhZ3MuZm9yRWFjaCgodGFnU2V0LCB0YWcpID0+IHtcbiAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKSB7XG4gICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpXG4gICAgICAgICAgICAgIDtcbiAgICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgIHAuX190cmVlVGFncyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgICBzID0gLyogQF9fUFVSRV9fICovIG5ldyBTZXQoKTtcbiAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGFnU2V0LmZvckVhY2goZnVuY3Rpb24oY29tcCkge1xuICAgICAgICAgICAgICBzLmFkZChjb21wKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgfVxuICB9XG4gIF9nZXRCeVRhZy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gbGV0IHAgPSB0aGlzLl9fcGFyZW50O1xuICAgICAgaWYgKHApIHtcbiAgICAgICAgZG8ge1xuICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSAvKiBAX19QVVJFX18gKi8gbmV3IE1hcCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICBpZiAoIXMpIHtcbiAgICAgICAgICAgIHMgPSAvKiBAX19QVVJFX18gKi8gbmV3IFNldCgpO1xuICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzLmFkZCh0aGlzKTtcbiAgICAgICAgfSB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICByZW1vdmVUYWcodGFnKSB7XG4gICAgbGV0IGkgPSB0aGlzLl9fdGFncy5pbmRleE9mKHRhZyk7XG4gICAgaWYgKGkgIT09IC0xKSB7XG4gICAgICB0aGlzLl9fdGFncy5zcGxpY2UoaSwgMSk7XG4gICAgICBsZXQgcCA9IHRoaXMuX19wYXJlbnQ7XG4gICAgICBpZiAocCkge1xuICAgICAgICBkbyB7XG4gICAgICAgICAgbGV0IGxpc3QgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgaWYgKGxpc3QpIHtcbiAgICAgICAgICAgIGxpc3QuZGVsZXRlKHRoaXMpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICBoYXNUYWcodGFnKSB7XG4gICAgcmV0dXJuIHRoaXMuX190YWdzICYmIHRoaXMuX190YWdzLmluZGV4T2YodGFnKSAhPT0gLTE7XG4gI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uZ2V0QnlSZWYocGF0aCk7XG4gICAgICAgIGlmICghY2hpbGQpIHtcbiAgICAgICAgICBpZiAodiAhPT0gdm9pZCAwKSB7XG4gICAgICAgICAgICBsZXQgYztcbiAgICAgICAgICAgIGlmIChVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgICBjID0gdGhpcy5jaGlsZExpc3QuY3JlYXRlSXRlbSh2KTtcbiAgICAgICAgICAgICAgYy5wYXRjaCh2KTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdCh2KSkge1xuICAgICAgICAgICAgICBjID0gdjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChjLmlzRWxlbWVudCkge1xuICAgICAgICAgICAgICBjLnJlZiA9IHBhdGg7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKGMpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAodiA9PT0gdm9pZCAwKSB7XG4gICAgICAgICAgICBpZiAoY2hpbGQucGFyZW50KSB7XG4gICAgICAgICAgICAgIGNoaWxkLnBhcmVudC5jaGlsZExpc3QucmVtb3ZlKGNoaWxkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICBjaGlsZC5wYXRjaCh2KTtcbiAgICAgICAgICB9IGVsc2UgaWYgKHYuaXNFbGVtZW50KSB7XG4gICAgICAgICAgICB2LnJlZiA9IHBhdGg7XG4gICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5yZXBsYWNlKHYsIGNoaWxkKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlVuZXhwZWN0ZWQgdmFsdWUgZm9yIHBhdGg6IFwiICsgcGF0aCk7XG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ICBjb25zdCBsaXN0ID0gW1xuICAgICAgXCJhbHBoYVwiLFxuICAgICAgXCJhY3RpdmVcIixcbiAgICAgIFwiYXR0YWNoZWRcIixcbiAgICAgIFwiYm91bmRzTWFyZ2luXCIsXG4gICAgICBcImNvbG9yXCIsXG4gICAgICBcImNsaXBwaW5nXCIsXG4gICAgICBcImVuYWJsZWRcIixcbiAgICAgIFwiaFwiLFxuICAgICAgXCJpZFwiLFxuICAgICAgXCJpc0NvbXBvbmVudFwiLFxuICAgICAgXCJtb3VudFwiLFxuICAgICAgXCJtb3VudFlcIixcbiAgICAgIFwibW91bnRYXCIsXG4gICAgICBcInBpdm90XCIsXG4gICAgICBcInBpdm90WFwiLFxuICAgICAgXCJwaXZvdFlcIixcbiAgICAgIFwicmVmXCIsXG4gICAgICBcInJlbmRlck9mZnNjcmVlblwiLFxuICAgICAgXCJyZW5kZXJUb1RleHR1cmVcIixcbiAgICAgIFwic2NhbGVcIixcbiAgICAgIFwic2NhbGVYXCIsXG4gICAgICBcInNjYWxlWVwiLFxuICAgICAgXCJzdGF0ZVwiLFxuICAgICAgXCJ0YWdcIixcbiAgICAgIFwidmlzaWJsZVwiLFxuICAgICAgXCJ3XCIsXG4gICAgICBcInhcIixcbiAgICAgIFwieVwiLFxuICAgICAgXCJ6SW5kZXhcIixcbiAgICAgIFwiISFmbGV4XCIsXG4gICAgICBcIiEhZmxleEl0ZW1cIixcbiAgICAgIFwiaGFzRm9jdXMoKVwiLFxuICAgICAgXCJoYXNGaW5hbEZvY3VzKClcIlxuICAgIF07XG4gICAgbGV0IG4gPSBsaXN0Lmxlbmd0aDtcbiAgICB3aGlsZSAobi0tKSB7XG4gICAgICBsZXQga2V5ID0gbGlzdFtuXTtcbiAgICAgIGNvbnN0IGdldEJvb2xlYW4gPSAvXiF7Mn0vO1xuICAgICAgY29uc3QgaXNGdW5jdGlvbiA9IC9cXChcXCkkLztcbiAgICAgIGlmIChnZXRCb29sZWFuLnRlc3Qoa2V5KSkge1xuICA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luZGV4KSB7XG4gICAgbGV0IG9mZnNldCA9IGluZGV4ICogMjA7XG4gICAgY29uc3QgZWxlbWVudENvcmUgPSBxdWFkcy5xdWFkRWxlbWVudHNbaW5kZXhdO1xuICAgIGxldCByID0gZWxlbWVudENvcmUuX3JlbmRlckNvbnRleHQ7XG4gICAgbGV0IGZsb2F0cyA9IHJlbmRlclN0YXRlLnF1YWRzLmZsb2F0cztcbiAgICBsZXQgdWludHMgPSByZW5kZXJTdGF0ZS5xdWFkcy51aW50cztcbiAgICBjb25zdCBtY2EgPSBTdGFnZVV0aWxzLm1lcmdlQ29sb3JBbHBoYTtcbiAgICBpZiAoci50YiAhPT0gMCB8fCByLnRjICE9PSAwKSB7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weDtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5O1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHg7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVbCwgci5hbHBoYSk7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weCArIGVsZW1lbnRDb3JlLl93ICogci50YTtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX3cgKiByLnRjO1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVciwgci5hbHBoYSk7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weCArIGVsZW1lbnRDb3JlLl93ICogci50YSArIGVsZW1lbnRDb3JlLl9oICogci50YjtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX3cgKiByLnRjICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JCciwgci5hbHBoYSk7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weCArIGVsZW1lbnRDb3JlLl9oICogci50YjtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHg7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgIHVpbnRzW29mZnNldF0gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yQmwsIHIuYWxwaGEpO1xuICAgIH0gZWxzZSB7XG4gICAgICBsZXQgY3ggPSByLnB4ICsgZWxlbWVudENvcmUuX3cgKiByLnRhO1xuICAgICAgbGV0IGN5ID0gci5weSArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4O1xuICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHk7XG4gICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseDtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx5O1xuICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVsLCByLmFscGhhKTtcbiAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBjeDtcbiAgICA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W2ldLnMgPSBbXG4gICAgICAgICAgICAgICAgZCAqIChuY1swXSAtIHBjWzBdKSxcbiAgICAgICAgICAgICAgICBkICogKG5jWzFdIC0gcGNbMV0pLFxuICAgICAgICAgICAgICAgIGQgKiAobmNbMl0gLSBwY1syXSksXG4gICAgICAgICAgICAgICAgZCAqIChuY1szXSAtIHBjWzNdKVxuICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IChuaS5sdiAtIHBpLmx2KSAvIChuaS5wIC0gcGkucCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGZvciAoaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7XG4gICAgICBpZiAoIWl0ZW1zW2ldLmYpIHtcbiAgICAgICAgbGV0IGxhc3QgPSBpID09PSBuIC0gMTtcbiAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eShcInZlXCIpKSB7XG4gICAgICAgICAgaXRlbXNbaV0udmUgPSBsYXN0ID8gaXRlbXNbaV0ubHYgOiBpdGVtc1tpICsgMV0ubHY7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKFV0aWxzJDEuaXNOdW1iZXIoaXRlbXNbaV0udikgJiYgVXRpbHMkMS5pc051bWJlcihpdGVtc1tpXS5sdikpIHtcbiAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KFwic21lXCIpKSB7XG4gICAgICAgICAgICBpdGVtc1tpXS5zbWUgPSBsYXN0ID8gZGVmYXVsdFNtb290aG5lc3MgOiBpdGVtc1tpICsgMV0uc207XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoXCJzZVwiKSkge1xuICAgICAgICAgICAgaXRlbXNbaV0uc2UgPSBsYXN0ID8gcmdiYSA/IFswLCAwLCAwLCAwXSA6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pXTtcbiAgICAgIGFpW2tleV0gPSBpO1xuICAgICAgaWYgKGJpW2tleV0gPT09IHZvaWQgMCkge1xuICAgICAgICBiaVtrZXldID0gLTE7XG4gICAgICB9XG4gICAgfVxuICAgIGNvbnN0IGFrc2wgPSBha3MubGVuZ3RoO1xuICAgIGNvbnN0IHJlc3VsdCA9IHt9O1xuICAgIGZvciAobGV0IGkgPSAwLCBuID0gYmtzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgY29uc3Qga2V5ID0gYmtzW2ldO1xuICAgICAgY29uc3QgYUluZGV4ID0gYWlba2V5XTtcbiAgICAgIGxldCBjdXJJbmRleDIgPSBhSW5kZXg7XG4gICAgICB3aGlsZSAoLS1jdXJJbmRleDIgPj0gMCkge1xuICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4Ml07XG4gICAgICAgIGlmIChiaVtha2V5XSAhPT0gLTEpIHtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgd2hpbGUgKCsrY3VySW5kZXgyIDwgYUluZGV4KSB7XG4gICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXgyXTtcbiAgICAgICAgcmVzdWx0W2FrZXldID0gYVtha2V5XTtcbiAgICAgIH1cbiAgICAgIGNvbnN0IGJ2ID0gYltrZXldO1xuICAgICAgY29uc3QgYXYgPSBhW2tleV07XG4gICAgICBsZXQgcjtcbiAgICAgIGlmICh0aGlzLmlzTWYoYnYpKSB7XG4gICAgICAgIHIgPSBidihhdik7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAoIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKGF2KSB8fCAhVXRpbHMkMS5pc09iamVjdExpdGVyYWwoYnYpKSB7XG4gICAgICAgICAgciA9IGJ2O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHIgPSBPYmpNZXJnZXIubWVyZ2UoYXYsIGJ2KTtcbiAgICAgICAgfVxuICAg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Nvcyhyb3QueikpO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3MueHk7XG4gICAgICAgIFxuICAgICAgICAvLyBQZXJmb3JtIDNkIHJvdGF0aW9uc1xuICAgICAgICBnbF9Qb3NpdGlvbi54ID0gY29zKHJvdC54KSAqIHBvcy54IC0gc2luKHJvdC54KSAqIHBvcy56O1xuICAgICAgICBnbF9Qb3NpdGlvbi55ID0gcG9zLnk7XG4gICAgICAgIGdsX1Bvc2l0aW9uLnogPSBzaW4ocm90LngpICogcG9zLnggKyBjb3Mocm90LngpICogcG9zLno7XG4gICAgICAgIFxuICAgICAgICBwb3MueCA9IGdsX1Bvc2l0aW9uLng7XG4gICAgICAgIHBvcy55ID0gY29zKHJvdC55KSAqIGdsX1Bvc2l0aW9uLnkgLSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24uejtcbiAgICAgICAgcG9zLnogPSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24ueSArIGNvcyhyb3QueSkgKiBnbF9Qb3NpdGlvbi56O1xuICAgICAgICBcbiAgICAgICAgLy8gUmVkbyBYWSByb3RhdGlvblxuICAgICAgICBpUm90WHlbMF1bMV0gPSAtaVJvdFh5WzBdWzFdO1xuICAgICAgICBpUm90WHlbMV1bMF0gPSAtaVJvdFh5WzFdWzBdO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3MueHk7IFxuXG4gICAgICAgIC8vIFVuZG8gdHJhbnNsYXRlIHRvIHBpdm90IHBvc2l0aW9uXG4gICAgICAgIHBvcy54eXogKz0gcGl2b3Q7XG5cbiAgICAgICAgcG9zID0gdmVjMyhwb3MueCAqIHByb2plY3Rpb24ueCAtIDEuMCwgcG9zLnkgKiAtYWJzKHByb2plY3Rpb24ueSkgKyAxLjAsIHBvcy56ICogcHJvamVjdGlvbi54KTtcbiAgICAgICAgXG4gICAgICAgIC8vIFNldCBkZXB0aCBwZXJzcGVjdGl2ZVxuICAgICAgICBmbG9hdCBwZXJzcGVjdGl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3Rpb24odGltZSkge1xuICAgICAgICBpZiAodGltZSA+PSAxKSB7XG4gICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRpbWUgPD0gMCkge1xuICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICB9XG4gICAgICAgIGxldCB0ID0gMC41LCBjYngsIGNieGQsIGR4O1xuICAgICAgICBmb3IgKGxldCBpdCA9IDA7IGl0IDwgMjA7IGl0KyspIHtcbiAgICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuICAgICAgICAgIGR4ID0gdGltZSAtIGNieDtcbiAgICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBjYnhkID0gdCAqICh0ICogKDMgKiB4YSkgKyAyICogeGIpICsgeGM7XG4gICAgICAgICAgaWYgKGNieGQgPiAxZS0xMCAmJiBjYnhkIDwgMWUtMTApIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0ICs9IGR4IC8gY2J4ZDtcbiAgICAgICAgfVxuICAgICAgICBsZXQgbWluVCA9IDA7XG4gICAgICAgIGxldCBtYXhUID0gMTtcbiAgICAgICAgZm9yIChsZXQgaXQgPSAwOyBpdCA8IDIwOyBpdCsrKSB7XG4gICAgICAgICAgdCA9IDAuNSAqIChtaW5UICsgbWF4VCk7XG4gICAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcbiAgICAgICAgICBkeCA9IHRpbWUgLSBjYng7XG4gICAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGR4IDwgMCkge1xuICAgICAgICAgICAgbWF4VCA9IHQ7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG1pblQgPSB0O1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldFRpbWluZ0Z1bmN0aW9uKHN0cikge1xuICAgICAgc3dpdGNoIChzdHIpIHtcbiAgICAgICAgY2FzZSBcImxpbmVhclwiOlxuICAgICAgICAgIHJldHVybiBmdW5jdGlvbih0aW1lKSB7XG4gICAgICAgICAgICByZXR1cm4gdGltZTtcbiAgICAgICAgICB9O1xuICAgICAgICBjYXNlIFwiZWFzZVwiOlxuICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjI1LCAwLjEsIDAuMjUsIDEpO1xuICAgICAgICBjYXNlIFwiZWFzZS1pblwiOlxuICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLmdldFRpbWluZ0JlemllcigwLjQyLCAwLCAxLCAxKTtcbiAgICAgICAgY2FzZSBcImVhc2Utb3V0XCI6XG4gICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAsIDAsIDAuNTgsIDEpO1xuICAgICAgICBjYXNlIFwiZWFzZS1pbi1vdXRcIjpcbiAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC40MiwgMCwgMC41OCwgMSk7XG4gICAgICAgIGNhc2UgXCJzdGVwLXN0YXJ0XCI6XG4gICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgICAgfTtcbiAgICAgICAgY2FzZSBcInN0ZXAtZW5kXCI6XG4gICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgICAgIHJldHVybiB0aW1lID09PSAxID8gMSA6IDA7XG4gICAgICAgICAgfTtcbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICBsZXQgcyA9IFwiY3ViaWMtYmV6aWVyKFwiO1xuICAgICAgICAgIGlmIChzdHIgJiYgc3RyLmluZGV4T2YocykgPT09IDApIHtcbiAgICAgICAgICAgIGxldCBwYXJ0cyA9IHN0ci5zdWJzdHIocy5sZW5ndGgsIHN0ci5sZW5ndGggLSBzLmxlbmd0aCAtIDEpLnNwbGl0KFwiLFwiKTtcbiAgICAgICAgICAgIGlmIChwYXJ0cy5sZW5ndGggIT09IDQpIHtcbiAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gVW5rbm93biB0aW1pbmcgZnVuY3Rpb246IFwiICsgc3RyKTtcbiAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGltZTtcbiAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCBhID0gcGFyc2VGbG9hdChwYXJ0c1swXSk7XG4gICAgICAgICAgICBsZXQgYiA9IHBhcnNlRmxvYXQocGFydHNbMV0pO1xuICAgICAgICAgICAgbGV0IGMgPSBwYXJzZUZsb2F0KHBhcnRzWzJdKTtcbiAgICAgICAgICAgIGxldCBkID0gcGFyc2VGbG9hdChwYXJ0c1szXSk7XG4gICAgICAgICAgICBpZiAoaXNOYU4oYSkgfHwgaXNOYU4oYikgfHwgaXNOYU4oYykgfHwgaXNOYU4oZCkpIHtcbiAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gVW5rbm93biB0aW1pbmcgZnVuY3Rpb246IFwiICsgc3RyKTtcbiAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRpbWUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGltZTtcbiAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHV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9yID09PSBPYmplY3Q7XG4gICAgfVxuICAgIHN0YXRpYyBnZXRBcnJheUluZGV4KGluZGV4LCBhcnIpIHtcbiAgICAgIHJldHVybiBVdGlscyQxLmdldE1vZHVsb0luZGV4KGluZGV4LCBhcnIubGVuZ3RoKTtcbiAgICB9XG4gICAgc3RhdGljIGdldE1vZHVsb0luZGV4KGluZGV4LCBsZW4pIHtcbiAgICAgIGlmIChsZW4gPT09IDApXG4gICAgICAgIHJldHVybiBpbmRleDtcbiAgICAgIHdoaWxlIChpbmRleCA8IDApIHtcbiAgICAgICAgaW5kZXggKz0gTWF0aC5jZWlsKC1pbmRleCAvIGxlbikgKiBsZW47XG4gICAgICB9XG4gICAgICBpbmRleCA9IGluZGV4ICUgbGVuO1xuICAgICAgcmV0dXJuIGluZGV4O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0RGVlcENsb25lKG9iaikge1xuICAgICAgbGV0IGksIGM7XG4gICAgICBpZiAoVXRpbHMkMS5pc0Z1bmN0aW9uKG9iaikpIHtcbiAgICAgICAgcmV0dXJuIG9iajtcbiAgICAgIH1cbiAgICAgIGlmIChBcnJheS5pc0FycmF5KG9iaikpIHtcbiAgICAgICAgYyA9IFtdO1xuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBrZXlzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgY1trZXlzW2ldXSA9IFV0aWxzJDEuZ2V0RGVlcENsb25lKG9ialtrZXlzW2ldXSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGM7XG4gICAgICB9IGVsc2UgaWYgKFV0aWxzJDEuaXNPYmplY3Qob2JqKSkge1xuICAgICAgICBjID0ge307XG4gICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICBjW2tleXNbaV1dID0gVXRpbHMkMS5nZXREZWVwQ2xvbmUob2JqW2tleXNbaV1dKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYztcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiBvYmo7XG4gICAgICB9XG4gICAgfVxuICAgIHN0YXRpYyBlcXVhbFZhbHVlcyh2MSwgdjIpIHtcbiAgICAgIGlmICh0eXBlb2YgdjEgIT09IHR5cGVvZiB2MilcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgaWYgKFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHYxKSkge1xuICAgICAgICByZXR1cm4gVXRpbHMkMS5pc09iamVjdExpdGVyYWwodjIpICYmIFV0aWxzJDEuZXF1YWxPYmplY3RMaXRlcmFscyh2MSwgdjIpO1xuICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KHYxKSkge1xuICAgICAgICByZXR1cm4gQXJyYXkuaXNBcnJheSh2MikgJiYgVXRpbHMkMS5lcXVhbEFycmF5cyh2MSwgdjIpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIHYxID09PSB2MjtcbiAgICAgIH1cbiAgICB9XG4gICAgc3RhdGljIGVxdWFsT2JqZWN0TGl0ZXJhbHMob2JqMSwgb2JqMikge1xuICAgICAgbGV0IGtleXMxID0gT2JqZWN0LmtleXMob2JqMSk7XG4gICAgICBsZXQga2V5czIgPSBPYmplY3Qua2V5cyhvYmoyKTtcbiAgICAgIGlmIChrZXlzMS5sZW5ndGggIT09IGtleXMyLmxlbmd0aCkge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGtleXMxLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBjb25zdCBrMSA9IGtleXMxW2ldO1xuICAgICAgICBjb25zdCBrMiA9IGtleXMyW2ldO1xuICAgICAgICBpZiAoazEgIT09IGsyKSB7XG4gICAg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HM7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgXCJzcGFjZS1hcm91bmRcIjpcbiAgICAgICAgICBpZiAocmVtYWluaW5nU3BhY2UgPCAwKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRTcGFjaW5nKFwiY2VudGVyXCIsIG51bWJlck9mSXRlbXMsIHJlbWFpbmluZ1NwYWNlKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3BhY2VQZXJHYXAgPSByZW1haW5pbmdTcGFjZSAvIChpdGVtR2FwcyArIDEpO1xuICAgICAgICAgICAgc3BhY2luZ0JlZm9yZSA9IDAuNSAqIHNwYWNlUGVyR2FwO1xuICAgICAgICAgICAgc3BhY2luZ0JldHdlZW4gPSBzcGFjZVBlckdhcDtcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgXCJzcGFjZS1ldmVubHlcIjpcbiAgICAgICAgICBpZiAocmVtYWluaW5nU3BhY2UgPCAwKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRTcGFjaW5nKFwiY2VudGVyXCIsIG51bWJlck9mSXRlbXMsIHJlbWFpbmluZ1NwYWNlKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3BhY2VQZXJHYXAgPSByZW1haW5pbmdTcGFjZSAvIChpdGVtR2FwcyArIDIpO1xuICAgICAgICAgICAgc3BhY2luZ0JlZm9yZSA9IHNwYWNlUGVyR2FwO1xuICAgICAgICAgICAgc3BhY2luZ0JldHdlZW4gPSBzcGFjZVBlckdhcDtcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgXCJzdHJldGNoXCI6XG4gICAgICAgICAgc3BhY2luZ0JlZm9yZSA9IDA7XG4gICAgICAgICAgc3BhY2luZ0JldHdlZW4gPSAwO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICBkZWZhdWx0OlxuICAgICAg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vcml6b250YWwsIHNpemUpIHtcbiAgICAgIGlmIChob3Jpem9udGFsKSB7XG4gICAgICAgIGl0ZW0udyA9IHNpemU7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpdGVtLmggPSBzaXplO1xuICAgICAgfVxuICAgIH1cbiAgICBzdGF0aWMgZ2V0QXhpc01pblNpemUoaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgbGV0IG1pblNpemUgPSB0aGlzLmdldFBsYWluQXhpc01pblNpemUoaXRlbSwgaG9yaXpvbnRhbCk7XG4gICAgICBsZXQgZmxleEl0ZW1NaW5TaXplID0gMDtcbiAgICAgIGlmIChpdGVtLmlzRmxleEl0ZW1FbmFibGVkKCkpIHtcbiAgICAgICAgZmxleEl0ZW1NaW5TaXplID0gaXRlbS5fZmxleEl0ZW0uX2dldE1pblNpemVTZXR0aW5nKGhvcml6b250YWwpO1xuICAgICAgfVxuICAgICAgY29uc3QgaGFzTGltaXRlZE1pblNpemUgPSBmbGV4SXRlbU1pblNpemUgPiAwO1xuICAgICAgaWYgKGhhc0xpbWl0ZWRNaW5TaXplKSB7XG4gICAgICAgIG1pblNpemUgPSBNYXRoLm1heChtaW5TaXplLCBmbGV4SXRlbU1pblNpemUpO1xuICAgICAgfVxuICAgICAgcmV0dXJuIG1pblNpemU7XG4gICAgfVxuICAgIHN0YXRpYyBnZXRQbGFpbkF4aXNNaW5TaXplKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgIGlmIChpdGVtLmlzRmxleEVuYWJsZWQoKSkge1xuICAgICAgICByZXR1cm4gaXRlbS5fZmxleC5fbGF5b3V0LmdldEF4aXNNaW5TaXplKGhvcml6b250YWwpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgY29uc3QgaXNTaHJpbmthYmxlID0gaXRlbS5mbGV4SXRlbS5zaHJpbmsgIT09IDA7XG4gICAgICAgIGlmIChpc1Nocmlua2FibGUpIHtcbiAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfSB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IHtcbiAgICAgICAgICAgICAgbGV0IHNocmluayA9IHNocmlua0Ftb3VudCAqIGFtb3VudFBlclNocmluaztcbiAgICAgICAgICAgICAgY29uc3QgbWluU2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc01pblNpemUoKTtcbiAgICAgICAgICAgICAgY29uc3Qgc2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICAgICAgaWYgKHNpemUgPiBtaW5TaXplKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgbWF4U2hyaW5rID0gc2l6ZSAtIG1pblNpemU7XG4gICAgICAgICAgICAgICAgY29uc3QgaXNGdWxseVNocnVuayA9IHNocmluayA+PSBtYXhTaHJpbms7XG4gICAgICAgICAgICAgICAgaWYgKGlzRnVsbHlTaHJ1bmspIHtcbiAgICAgICAgICAgICAgICAgIHNocmluayA9IG1heFNocmluaztcbiAgICAgICAgICAgICAgICAgIHRvdGFsU2hyaW5rQW1vdW50IC09IHNocmlua0Ftb3VudDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc3QgZmluYWxTaXplID0gc2l6ZSAtIHNocmluaztcbiAgICAgICAgICAgICAgICBmbGV4SXRlbS5fcmVzaXplTWFpbkF4aXMoZmluYWxTaXplKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9zaHJ1bmtTaXplICs9IHNocmluaztcbiAgICAgICAgICAgICAgICB0aGlzLl9hbW91bnRSZW1haW5pbmcgLT0gc2hyaW5rO1xuICAgICAgICAgICAgICAgIGlmIChNYXRoLmFicyh0aGlzLl9hbW91bnRSZW1haW5pbmcpIDwgMWUtNSkge1xuICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSB3aGlsZSAodG90YWxTaHJpbmtBbW91bnQgJiYgTWF0aC5hYnModG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hbW91bnRSZW1haW5pbmcgPSBhbW91bnQ7XG4gICAgICBsZXQgdG90YWxHcm93QW1vdW50ID0gdGhpcy5fZ2V0VG90YWxHcm93QW1vdW50KCk7XG4gICAgICBpZiAodG90YWxHcm93QW1vdW50KSB7XG4gICAgICAgIGNvbnN0IGl0ZW1zID0gdGhpcy5fbGluZS5pdGVtcztcbiAgICAgICAgZG8ge1xuICAgICAgICAgIGxldCBhbW91bnRQZXJHcm93ID0gdGhpcy5fYW1vdW50UmVtYWluaW5nIC8gdG90YWxHcm93QW1vdW50O1xuICAgICAgICAgIGZvciAobGV0IGkgPSB0aGlzLl9saW5lLnN0YXJ0SW5kZXg7IGkgPD0gdGhpcy5fbGluZS5lbmRJbmRleDsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBpdGVtID0gaXRlbXNbaV07XG4gICAgICAgICAgICBjb25zdCBmbGV4SXRlbSA9IGl0ZW0uZmxleEl0ZW07XG4gICAgICAgICAgICBjb25zdCBncm93QW1vdW50ID0gZmxleEl0ZW0uZ3JvdztcbiAgICAgICAgICAgIGNvbnN0IGlzR3Jvd2FibGVJdGVtID0gZ3Jvd0Ftb3VudCA+IDA7XG4gICAgICAgICAgICBpZiAoaXNHcm93YWJsZUl0ZW0pIHtcbiAgICAgICAgICAgICAgbGV0IGdyb3cgPSBncm93QW1vdW50ICogYW1vdW50UGVyR3JvdztcbiAgICAgICAgICAgICAgY29uc3QgbWF4U2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc01heFNpemVTZXR0aW5nKCk7XG4gICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCk7XG4gICAgICAgICAgICAgIGlmIChtYXhTaXplID4gMCkge1xuICAgICAgICAgICAgICAgIGlmIChzaXplID49IG1heFNpemUpIHtcbiAgICAgICAgICAgICAgICAgIGdyb3cgPSAwO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBjb25zdCBtYXhHcm93ID0gbWF4U2l6ZSAtIHNpemU7XG4gICAgICAgICAgICAgICAgICBjb25zdCBpc0Z1bGx5R3Jvd24gPSBncm93ID49IG1heEdyb3c7XG4gICAgICAgICAgICAgICAgICBpZiAoaXNGdWxseUdyb3duKSB7XG4gICAgICAgICAgICAgICAgICAgIGdyb3cgPSBtYXhHcm93O1xuICAgICAgICAgICAgICAgICAgICB0b3RhbEdyb3dBbW91bnQgLT0gZ3Jvd0Ftb3VudDtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKGdyb3cgPiAwKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgZmluYWxTaXplID0gc2l6ZSArIGdyb3c7XG4gICAgICAgICAgICAgICAgZmxleEl0ZW0uX3Jlc2l6ZU1haW5BeGlzKGZpbmFsU2l6ZSk7XG4gICAgICAgICAgICAgICAgdGhpcy5fZ3Jvd25TaXplICs9IGdyb3c7XG4gICAgICAgICAgICAgICAgdGhpcy5fYW1vdW50UmVtYWluaW5nIC09IGdyb3c7XG4gICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPCAxZS01KSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IHdoaWxlICh0b3RhbEdyb3dBbW91bnQgJiYgTWF0aC5hYnModGhpcy5fYW1vdW50UmVtYWluaW5nKSA+IDFlLTUpO1xuICAgICAgfVxuICAgIH1cbiAgICBfZ2V0VG90YWxHcm93QW1vdW50KCkge1xuICAgICAgbGV0IHRvdGFsID0gMDtcbiAgICAgIGNvbnN0IGl0ZW1zID0gdGhpcy5fbGluZS5pdGVtcztcbiAgICAgIGZvciAobGV0IGkgPSB0aGlzLl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lzLl9hbGlnbkl0ZW1zID09PSB2KVxuICAgICAgICByZXR1cm47XG4gICAgICBpZiAoRmxleENvbnRhaW5lci5BTElHTl9JVEVNUy5pbmRleE9mKHYpID09PSAtMSkge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJVbmtub3duIGFsaWduSXRlbXMsIG9wdGlvbnM6IFwiICsgRmxleENvbnRhaW5lci5BTElHTl9JVEVNUy5qb2luKFwiLFwiKSk7XG4gICAgICB9XG4gICAgICB0aGlzLl9hbGlnbkl0ZW1zID0gdjtcbiAgICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICAgIH1cbiAgICBnZXQgYWxpZ25Db250ZW50KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2FsaWduQ29udGVudDtcbiAgICB9XG4gICAgc2V0IGFsaWduQ29udGVudCh2KSB7XG4gICAgICBpZiAodGhpcy5fYWxpZ25Db250ZW50ID09PSB2KVxuICAgICAgICByZXR1cm47XG4gICAgICBpZiAoRmxleENvbnRhaW5lci5BTElHTl9DT05URU5ULmluZGV4T2YodikgPT09IC0xKSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcIlVua25vd24gYWxpZ25Db250ZW50LCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuQUxJR05fQ09OVEVOVC5qb2luKFwiLFwiKSk7XG4gICAgICB9XG4gICAgICB0aGlzLl9hbGlnbkNvbnRlbnQgPSB2O1xuICAgICAgdGhpcy5fY2hhbmdlZENvbnRlbnRzKCk7XG4gICAgfVxuICAgIGdldCBqdXN0aWZ5Q29udGVudCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9qdXN0aWZ5Q29udGVudDtcbiAgICB9XG4gICAgc2V0IGp1c3RpZnlDb250ZW50KHYpIHtcbiAgICAgIGlmICh0aGlzLl9qdXN0aWZ5Q29udGVudCA9PT0gdilcbiAgICAgICAgcmV0dXJuO1xuICAgICAgaWYgKEZsZXhDb250YWluZXIuSlVTVElGWV9DT05URU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ldCBzaHJpbmsodikge1xuICAgICAgaWYgKHRoaXMuX3NocmluayA9PT0gdilcbiAgICAgICAgcmV0dXJuO1xuICAgICAgdGhpcy5fc2hyaW5rID0gcGFyc2VJbnQodikgfHwgMDtcbiAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICB9XG4gICAgZ2V0IGFsaWduU2VsZigpIHtcbiAgICAgIHJldHVybiB0aGlzLl9hbGlnblNlbGY7XG4gICAgfVxuICAgIHNldCBhbGlnblNlbGYodikge1xuICAgICAgaWYgKHRoaXMuX2FsaWduU2VsZiA9PT0gdilcbiAgICAgICAgcmV0dXJuO1xuICAgICAgaWYgKHYgPT09IHZvaWQgMCkge1xuICAgICAgICB0aGlzLl9hbGlnblNlbGYgPSB2b2lkIDA7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAoRmxleENvbnRhaW5lci5BTElHTl9JVEVNUy5pbmRleE9mKHYpID09PSAtMSkge1xuICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIlVua25vd24gYWxpZ25TZWxmLCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuQUxJR05fSVRFTVMuam9pbihcIixcIikpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2FsaWduU2VsZiA9IHY7XG4gICAgICB9XG4gICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgfVxuICAgIGdldCBtaW5XaWR0aCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9taW5XaWR0aDtcbiAgICB9XG4gICAgc2V0IG1pbldpZHRoKHYpIHtcbiAgICAgIHRoaXMuX21pbldpZHRoID0gTWF0aC5tYXgoMCwgdik7XG4gICAgICB0aGlzLl9pdGVtLmNoYW5nZWREaW1lbnNpb25zKHRydWUsIGZhbHNlKTtcbiAgICB9XG4gICAgZ2V0IG1pbkhlaWdodCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9taW5IZWlnaHQ7XG4gICAgfVxuICAgIHNldCBtaW5IZWlnaHQodikge1xuIC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UpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuICAgICAgaWYgKCF0aGlzLl9uYXRpdmVUZXh0dXJlICYmICF0aGlzLmlzTG9hZGluZygpKSB7XG4gICAgICAgIHRoaXMubG9hZGluZ1NpbmNlID0gbmV3IERhdGUoKS5nZXRUaW1lKCk7XG4gICAgICAgIHRoaXMuX2NhbmNlbENiID0gdGhpcy5sb2FkZXIoKGVyciwgb3B0aW9ucykgPT4ge1xuICAgICAgICAgIGlmICh0aGlzLmlzTG9hZGluZygpKSB7XG4gICAgICAgICAgICB0aGlzLl9jYW5jZWxDYiA9IG51bGw7XG4gICAgICAgICAgICBpZiAodGhpcy5tYW5hZ2VyLnN0YWdlLmRlc3Ryb3llZCkge1xuICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgIHRoaXMub25FcnJvcihlcnIpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChvcHRpb25zICYmIG9wdGlvbnMuc291cmNlKSB7XG4gICAgICAgICAgICAgIGlmICghdGhpcy5zdGFnZS5pc1VwZGF0aW5nRnJhbWUoKSAmJiAhZm9yY2VTeW5jICYmIG9wdGlvbnMudGhyb3R0bGUgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgdGV4dHVyZVRocm90dGxlciA9IHRoaXMuc3RhZ2UudGV4dHVyZVRocm90dGxlcjtcbiAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxDYiA9IHRleHR1cmVUaHJvdHRsZXIuZ2VuZXJpY0NhbmNlbENiO1xuICAgICAgICAgICAgICAgIHRleHR1cmVUaHJvdHRsZXIuYWRkKHRoaXMsIG9wdGlvbnMpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc0xvYWRlZFNvdXJjZShvcHRpb25zKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgIC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XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBwaXZvdCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9waXZvdFg7XG4gICAgfVxuICAgIHNldCBwaXZvdCh2KSB7XG4gICAgICBpZiAodGhpcy5fcGl2b3RYICE9PSB2IHx8IHRoaXMuX3Bpdm90WSAhPT0gdikge1xuICAgICAgICB0aGlzLl9waXZvdFggPSB2O1xuICAgICAgICB0aGlzLl9waXZvdFkgPSB2O1xuICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgbW91bnRYKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX21vdW50WDtcbiAgICB9XG4gICAgc2V0IG1vdW50WCh2KSB7XG4gICAgICBpZiAodGhpcy5fbW91bnRYICE9PSB2KSB7XG4gICAgICAgIHRoaXMuX21vdW50WCA9IHY7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBtb3VudFkoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fbW91bnRZO1xuICAgIH1cbiAgICBzZXQgbW91bnRZKHYpIHtcbiAgICAgIGlmICh0aGlzLl9tb3VudFkgIT09IHYpIHtcbiAgICAgICAgdGhpcy5fbW91bnRZID0gdjtcbiAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGUoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IG1vdW50KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX21vdW50WDtcbiAgICB9XG4gICAgc2V0IG1vdW50KHYpIHtcbiAgICAgIGlmICh0aGlzLl9tb3VudFggIT09IHYgfHwgdGhpcy5fbW91bnRZICE9PSB2KSB7XG4gICAgICAgIHRoaXMuX21vdW50WCA9IHY7XG4gICAgICAgIHRoaXMuX21vdW50WSA9IHY7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUxvY2F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aXMuX3BhcmVudCkge1xuICAgICAgICAgIHRoaXMuX3BhcmVudC5fc2V0SGFzVXBkYXRlcygpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl96SW5kZXggPT09IDApIHtcbiAgICAgICAgICB0aGlzLnNldFpQYXJlbnQocGFyZW50KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLnNldFpQYXJlbnQocGFyZW50ID8gcGFyZW50LmZpbmRaQ29udGV4dCgpIDogbnVsbCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHByZXZJc1pDb250ZXh0ICE9PSB0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgIGlmICghdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgIHRoaXMuZGlzYWJsZVpDb250ZXh0KCk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuZW5hYmxlWkNvbnRleHQocHJldlBhcmVudC5maW5kWkNvbnRleHQoKSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fc2hhZGVyKSB7XG4gICAgICAgICAgbGV0IG5ld1NoYWRlck93bmVyID0gcGFyZW50ICYmICFwYXJlbnQuX3JlbmRlclRvVGV4dHVyZUVuYWJsZWQgPyBwYXJlbnQuX3NoYWRlck93bmVyIDogbnVsbDtcbiAgICAgICAgICBpZiAobmV3U2hhZGVyT3duZXIgIT09IHRoaXMuX3NoYWRlck93bmVyKSB7XG4gICAgICAgICAgICB0aGlzLnNldEhhc1JlbmRlclVwZGF0ZXMoMSk7XG4gICAgICAgICAgICB0aGlzLl9zZXRTaGFkZXJPd25lclJlY3Vyc2l2ZShuZXdTa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0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG4gICAgaXNaQ29udGV4dCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9mb3JjZVpJbmRleENvbnRleHQgfHwgdGhpcy5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCB8fCB0aGlzLl96SW5kZXggIT09IDAgfHwgdGhpcy5faXNSb290IHx8ICF0aGlzLl9wYXJlbnQ7XG4gICAgfVxuICAgIGZpbmRaQ29udGV4dCgpIHtcbiAgICAgIGlmICh0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCk7XG4gICAgICB9XG4gICAgfVxuICAgIHNldFpQYXJlbnQobmV3WlBhcmVudCkge1xuICAgICAgaWYgKHRoaXMuX3pQYXJlbnQgIT09IG5ld1pQYXJlbnQpIHtcbiAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQgIT09IG51bGwpIHtcbiAgICAgICAgICBpZiAodGhpcy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICB0aGlzLl96UGFyZW50LmRlY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChuZXdaUGFyZW50ICE9PSBudWxsKSB7XG4gICAgICAgICAgbGV0IGhhZFpDb250ZXh0VXNhZ2UgPSBuZXdaUGFyZW50Ll96Q29udGV4dFVzYWdlID4gMDtcbiAgICAgICAgICBpZiAodGhpcy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICBuZXdaUGFyZW50LmluY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG5ld1pQYXJlbnQuX3pDb250ZXh0VXNhZ2UgPiAwKSB7XG4gICAgICAgICAgICBpZiAoIWhhZFpDb250ZXh0VXNhZ2UgJiYgdGhpcy5fcGFyZW50ID09PSBuZXdaUGFyZW50KVxuICAgICAgICAgICAgICA7XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgbmV3WlBhcmVudC5fekluZGV4ZWRDaGlsZHJlbi5wdXNoKHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbmV3WlBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl96UGFyZW50ID0gbmV3WlBhcmVudDtcbiAgICAgICAgdGhpcy5fekluZGV4UmVzb3J0ID0gdHJ1ZTtcbiAgICAgIH1cbiAgICB9XG4gICAgaW5jWkNvbnRleHRVc2FnZSgpIHtcbiAgICAgIHRoaXMuX3pDb250ZXh0VXNhZ2UrKztcbiAgICAgIGlmICh0aGlzLl96Q29udGV4dFVzYWdlID09PSAxKSB7XG4gICAgICAgIGlmICghdGhpcy5fekluZGV4ZWRDaGlsZHJlbikge1xuICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4gPSBbXTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5wdXNoKHRoaXMuX2NoaWxkcmVuW2ldKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgdGhpcy5felNvcnQgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBkZWNaQ29udGV4dFVzYWdlKCkge1xuICAgICAgdGhpcy5fekNvbnRleHRVc2FnZS0tO1xuICAgICAgaWYgKHRoaXMuX3pDb250ZXh0VXNhZ2UgPT09IDApIHtcbiAgICAgICAgdGhpcy5felNvcnQgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5zcGxpY2UoMCk7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCB6SW5kZXgoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fekluZGV4O1xuICAgIH1cbiAgICBzZXQgekluZGV4KHpJbmRleCkge1xuICAgICAgaWYgKHRoaXMuX3pJbmRleCAhPT0gekluZGV4KSB7XG4gICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcygxKTtcbiAgICAgICAgbGV0IG5ld1pQYXJlbnQgPSB0aGlzLl96UGFyZW50O1xuICAgICAgICBsZXQgcHJldklzWkNvbnRleHQgPSB0aGlzLmlzWkNvbnRleHQoKTtcbiAgICAgICAgaWYgKHpJbmRleCA9PT0gMCAmJiB0aGlzLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICBpZiAodGhpcy5fcGFyZW50ID09PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmRlY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbmV3WlBhcmVudCA9IHRoaXMuX3BhcmVudDtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAoekluZGV4ICE9PSAwICYmIHRoaXMuX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgIG5ld1pQYXJlbnQgPSB0aGlzLl9wYXJlbnQgPyB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkgOiBudWxsO1xuICAgICAgICAgIGlmIChuZXdaUGFyZW50ID09PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmluY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICh6SW5kZXggIT09IHRoaXMuX3pJbmRleCkge1xuICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50ICYmIHRoaXMuX3pQYXJlbnQuX3pDb250ZXh0VXNhZ2UpIHtcbiAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IHRoaXMuX3pQYXJlbnQpIHtcbiAgICAgICAgICB0aGlzLnNldFpQYXJlbnQobnVsbCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fekluZGV4ID0gekluZGV4O1xuICAgICAgICBpZiAobmV3WlBhcmVudCAhPT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChuZXdaUGFyZW50KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocHJldklzWkNvbnRleHQgIT09IHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgaWYgKCF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgdGhpcy5kaXNhYmxlWkNvbnRleHQoKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5lbmFibGVaQ29udGV4dCh0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl96SW5kZXhSZXNvcnQgPSB0cnVlO1xuICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBnZXQgZm9yY2VaSW5kZXhDb250ZXh0KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2ZvcmNlWkluZGV4Q29udGV4dDtcbiAgICB9XG4gICAgc2V0IGZvcmNlWkluZGV4Q29udGV4dCh2KSB7XG4gICAgICB0aGlzLnNldEhhc1JlbmRlclVwZGF0ZXMoMSk7XG4gICAgICBsZXQgcHJldklzWkNvbnRleHQgPSB0aGlzLmlzWkNvbnRleHQoKTtcbiAgICAgIHRoaXMuX2ZvcmNlWkluZGV4Q29udGV4dCA9IHY7XG4gICAgICBpZiAocHJldklzWkNvbnRleHQgIT09IHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgIGlmICghdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICB0aGlzLmRpc2FibGVaQ29udGV4dCgpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuZW5hYmxlWkNvbnRleHQodGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBlbmFibGVaQ29udGV4dChwcmV2WkNvbnRleHQpIHtcbiAgICAgIGlmIChwcmV2WkNvbnRleHQgJiYgcHJldlpDb250ZXh0Ll96Q29udGV4dFVzYWdlID4gMCkge1xuICAgICAgICBjb25zdCByZXN1bHRzID0gdGhpcy5fZ2V0WkluZGV4ZWREZXNjcygpO1xuICAgICAgICByZXN1bHRzLmZvckVhY2goKGMpID0+IHtcbiAgICAgICAgICBpZiAodGhpcy5pc0FuY2VzdG9yT2YoYykgJiYgYy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICBjLnNldFpQYXJlbnQodGhpcyk7XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICB9XG4gICAgX2dldFpJbmRleGVkRGVzY3MoKSB7XG4gICAgICBjb25zdCByZXN1bHRzID0gW107XG4gICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAg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RoaXMuX3JlY2FsYztcbiAgICAgICAgaWYgKHJlY2FsYyAmIDEpIHtcbiAgICAgICAgICBpZiAoIXcuYWxwaGEgJiYgdmlzaWJsZSkge1xuICAgICAgICAgICAgdGhpcy5faGFzUmVuZGVyVXBkYXRlcyA9IDM7XG4gICAgICAgICAgfVxuICAgICAgICAgIHcuYWxwaGEgPSBwdy5hbHBoYSAqIHRoaXMuX2xvY2FsQWxwaGE7XG4gICAgICAgICAgaWYgKHcuYWxwaGEgPCAxZS0xNCkge1xuICAgICAgICAgICAgdy5hbHBoYSA9IDA7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChyZWNhbGMgJiA2KSB7XG4gICAgICAgICAgdy5weCA9IHB3LnB4ICsgdGhpcy5fbG9jYWxQeCAqIHB3LnRhO1xuICAgICAgICAgIHcucHkgPSBwdy5weSArIHRoaXMuX2xvY2FsUHkgKiBwdy50ZDtcbiAgICAgICAgICBpZiAocHcudGIgIT09IDApXG4gICAgICAgICAgICB3LnB4ICs9IHRoaXMuX2xvY2FsUHkgKiBwdy50YjtcbiAgICAgICAgICBpZiAocHcudGMgIT09IDApXG4gICAgICAgICAgICB3LnB5ICs9IHRoaXMuX2xvY2FsUHggKiBwdy50YztcbiAgICAgICAgfVxuICAgICAgICBpZiAocmVjYWxjICYgNCkge1xuICAgICAgICAgIHcudGEgPSB0aGlzLl9sb2NhbFRhICogcHcudGE7XG4gICAgICAgICAgdy50YiA9IHRoaXMuX2xvY2FsVGQgKiBwdy50YjtcbiAgICAgICAgICB3LnRjID0gdGhpcy5fbG9jYWxUYSAqIHB3LnRjO1xuICAgICAgICAgIHcudGQgPSB0aGlzLl9sb2NhbFRkICogcHcudGQ7XG4gICAgICAgICAgaWYgKHRoaXMuX2lzQ29tcGxleCkge1xuICAgICAgICAgICAgdy50YSArPSB0aGlzLl9sb2NhbFRjICogcHcudGI7XG4gICAgICAgICAgICB3LnRiICs9IHRoaXMuX2xvY2FsVGIgKiBwdy50YTtcbiAgICAgICAgICAgIHcudGMgKz0gdGhpcy5fbG9jYWxUYyAqIHB3LnRkO1xuICAgICAgICAgICAgdy50ZCArPSB0aGlzLl9sb2NhbFRiICogcHcudGM7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGNvbnN0IHByID0gdGhpcy5fcGFyZW50Ll9yZW5kZXJDb250ZXh0O1xuICAgICAgICBpZiAodGhpcy5fcGFyZW50Ll9oYXNSZW5kZXJDb250ZXh0KCkpIHtcbiAgICAgICAgICBjb25zdCBpbml0ID0gdGhpcy5fcmVuZGVyQ29udGV4dCA9PT0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICAgIGlmIChpbml0KSB7XG4gICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gbmV3IEVsZW1lbnRDb3JlQ29udGV4dCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb25zdCByMiA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICAgICAgaWYgKGluaXQgfHwgcmVjYWxjICYgMSkge1xuICAgICAgICAgICAgcjIuYWxwaGEgPSBwci5hbHBoYSAqIHRoaXMuX2xvY2FsQWxwaGE7XG4gICAgICAgICAgICBpZiAocjIuYWxwaGEgPCAxZS0xNCkge1xuICAgICAgICAgICAgICByMi5hbHBoYSA9IDA7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChpbml0IHx8IHJlY2FsYyAmIDYpIHtcbiAgICAgICAgICAgIHIyLnB4ID0gcHIucHggKyB0aGlzLl9sb2NhbFB4ICogcHIudGE7XG4gICAgICAgICAgICByMi5weSA9IHByLnB5ICsgdGhpcy5fbG9jYWxQeSAqIHByLnRkO1xuICAgICAgICAgICAgaWYgKHByLnRiICE9PSAwKVxuICAgICAgICAgICAgICByMi5weCArPSB0aGlzLl9sb2NhbFB5ICogcHIudGI7XG4gICAgICAgICAgICBpZiAocHIudGMgIT09IDApXG4gICAgICAgICAgICAgIHIyLnB5ICs9IHRoaXMuX2xvY2FsUHggKiBwci50YztcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGluaXQpIHtcbiAgICAgICAgICAgIHJlY2FsYyB8PSAyO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaW5pdCB8fCByZWNhbGMgJiA0KSB7XG4gICAgICAgICAgICByMi50YSA9IHRoaXMuX2xvY2FsVGEgKiBwci50YTtcbiAgICAgICAgICAgIHIyLnRiID0gdGhpcy5fbG9jYWxUZCAqIHByLnRiO1xuICAgICAgICAgICAgcjIudGMgPSB0aGlzLl9sb2NhbFRhICogcHIudGM7XG4gICAgICAgICAgICByMi50ZCA9IHRoaXMuX2xvY2FsVGQgKiBwci50ZDtcbiAgICAgICAgICAgIGlmICh0aGlzLl9pc0NvbXBsZXgpIHtcbiAgICAgICAgICAgICAgcjIudGEgKz0gdGhpcy5fbG9jYWxUYyAqIHByLnRiO1xuICAgICAgICAgICAgICByMi50YiArPSB0aGlzLl9sb2NhbFRiICogcHIudGE7XG4gICAgICAgICAgICAgIHIyLnRjICs9IHRoaXMuX2xvY2FsVGMgKiBwci50ZDtcbiAgICAgICAgICAgICAgcjIudGQgKz0gdGhpcy5fbG9jYWxUYiAqIHByLnRjO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmN0eC51cGRhdGVUcmVlT3JkZXIgPT09IC0xKSB7XG4gICAgICAgICAgdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID0gdGhpcy5fdXBkYXRlVHJlZU9yZGVyICsgMTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB0aGlzLl91cGRhdGVUcmVlT3JkZXIgPSB0aGlzLmN0eC51cGRhdGVUcmVlT3JkZXIrKztcbiAgICAgICAgfVxuICAgICAgICBjb25zdCB1c2VSZW5kZXJUb1RleHR1cmUgPSB0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkICYmIHRoaXMuX3RleHR1cml6ZXIubXVzdFJlbmRlclRvVGV4dHVyZSgpO1xuICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlICE9PSB1c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICB0aGlzLl9yZWNhbGMgfD0gMiArIDQ7XG4gICAgICAgICAgcmVjYWxjIHw9IDI7XG4gICAgICAgICAgaWYgKCF0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUgPSB1c2VSZW5kZXJUb1RleHR1cmU7XG4gICAgICAgIGNvbnN0IHIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgICBjb25zdCBiYm94VyA9IHRoaXMuX2RpbXNVbmtub3duID8gMjA0OCA6IHRoaXMuX3c7XG4gICAgICAgIGNvbnN0IGJib3hIID0gdGhpcy5fZGltc1Vua25vd24gPyAyMDQ4IDogdGhpcy5faDtcbiAgICAgICAgbGV0IHN4LCBzeSwgZXgsIGV5O1xuICAgICAgICBjb25zdCByQ29tcGxleCA9IHIudGIgIT09IDAgfHwgci50YyAhPT0gMCB8fCByLnRhIDwgMCB8fCByLnRkIDwgMDtcbiAgICAgICAgaWYgKHJDb21wbGV4KSB7XG4gICAgICAgICAgc3ggPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgZXggPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgc3kgPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgZXkgPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgc3ggPSByLnB4O1xuICAgICAgICAgIGV4ID0gci5weCArIHIudGEgKiBiYm94VztcbiAgICAgICAgICBzeSA9IHIucHk7XG4gICAgICAgICAgZXkgPSByLnB5ICsgci50ZCAqIGJib3hIO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9kaW1zVW5rbm93biAmJiAockNvbXBsZXggfHwgdGhpcy5fbG9jYWxUYSA8IDEgfHwgdGhpcy5fbG9jYWxUYiA8IDEpKSB7XG4gICAgICAgICAgY29uc3QgbnggPSB0aGlzLl94ICogcHIudGEgKyB0aGlzLl95ICogcHIudGIgKyBwci5weDtcbiAgICAgICAgICBjb25zdCBueSA9IHRoaXMuX3ggKiBwci50YyArIHRoaXMuX3kgKiBwci50ZCArIHByLnB5O1xuICAgICAgICAgIGlmIChueCA8IHN4KVxuICAgICAgICAgICAgc3ggPSBueDtcbiAgICAgICAgICBpZiAobnkgPCBzeSlcbiAgICAgICAgICAgIHN5ID0gbnk7XG4gICAgICAgICAgaWYgKG54ID4gZXgpXG4gICAgICAgICAgICBleCA9IG54O1xuICAgICAgICAgIGlmIChueSA+IGV5KVxuICAgICAgICAgICAgZXkgPSBueTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocmVjYWxjICYgNiB8fCAhdGhpcy5fc2Npc3Nvcikge1xuICAgICAgICAgIGlmICh0aGlzLl9jbGlwcGluZyAmJiByLmlzU3F1YXJlKCkpIHtcbiAgICAgICAgICAgIGNvbnN0IGFyZWEgPSB0aGlzLl9wYXJlbnQuX3VzZVJlbmRlclRvVGV4dHVyZSA/IHRoaXMuX3BhcmVudC5fdmlld3BvcnQgOiB0aGlzLl9wYXJlbnQuX3NjaXNzb3I7XG4gICAgICAgICAgICBpZiAoYXJlYSkge1xuICAgICAgICAgICAgICBjb25zdCBseCA9IE1hdGgubWF4KGFyZWFbMF0sIHN4KTtcbiAgICAgICAgICAgICAgY29uc3QgbHkgPSBNYXRoLm1heChhcmVhWzFdLCBzeSk7XG4gICAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBbXG4gICAgICAgICAgICAgICAgbHgsXG4gICAgICAgICAgICAgICAgbHksXG4gICAgICAgICAgICAgICAgTWF0aC5taW4oYXJlYVsyXSArIGFyZWFbMF0sIGV4KSAtIGx4LFxuICAgICAgICAgICAgICAgIE1hdGgubWluKGFyZWFbM10gKyBhcmVhWzFdLCBleSkgLSBseVxuICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IFtzeCwgc3ksIGV4IC0gc3gsIGV5IC0gc3ldO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9zY2lzc29yID0gdGhpcy5fcGFyZW50Ll91c2VSZW5kZXJUb1RleHR1cmUgPyB0aGlzLl9wYXJlbnQuX3ZpZXdwb3J0IDogdGhpcy5fcGFyZW50Ll9zY2lzc29yO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fYm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgdGhpcy5fcmVjQm91bmRzTWFyZ2luID0gdGhpcy5fYm91bmRzTWFyZ2luO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuX3JlY0JvdW5kc01hcmdpbiA9IHRoaXMuX3BhcmVudC5fcmVjQm91bmRzTWFyZ2luO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9vbkFmdGVyQ2FsY3MpIHtcbiAgICAgICAgICBpZiAodGhpcy5fb25BZnRlckNhbGNzKHRoaXMuZWxlbWVudCkpIHtcbiAgICAgICAgICAgIGlmIChyQ29tcGxleCkge1xuICAgICAgICAgICAgICBzeCA9IE1hdGgubWluKDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgICAgZXggPSBNYXRoLm1heCgwLCBiYm94VyAqIHIudGEsIGJib3hXICogci50YSArIGJib3hIICogci50YiwgYmJveEggKiByLnRiKSArIHIucHg7XG4gICAgICAgICAgICAgIHN5ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgICAgICBleSA9IE1hdGgubWF4KDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHN4ID0gci5weDtcbiAgICAgICAgICAgICAgZXggPSByLnB4ICsgci50YSAqIGJib3hXO1xuICAgICAgICAgICAgICBzeSA9IHIucHk7XG4gICAgICAgICAgICAgIGV5ID0gci5weSArIHIudGQgKiBiYm94SDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLl9kaW1zVW5rbm93biAmJiAockNvbXBsZXggfHwgdGhpcy5fbG9jYWxUYSA8IDEgfHwgdGhpcy5fbG9jYWxUYiA8IDEpKSB7XG4gICAgICAgICAgICAgIGNvbnN0IG54ID0gdGhpcy5feCAqIHByLnRhICsgdGhpcy5feSAqIHByLnRiICsgcHIucHg7XG4gICAgICAgICAgICAgIGNvbnN0IG55ID0gdGhpcy5feCAqIHByLnRjICsgdGhpcy5feSAqIHByLnRkICsgcHIucHk7XG4gICAgICAgICAgICAgIGlmIChueCA8IHN4KVxuICAgICAgICAgICAgICAgIHN4ID0gbng7XG4gICAgICAgICAgICAgIGlmIChueSA8IHN5KVxuICAgICAgICAgICAgICAgIHN5ID0gbnk7XG4gICAgICAgICAgICAgIGlmIChueCA+IGV4KVxuICAgICAgICAgICAgICAgIGV4ID0gbng7XG4gICAgICAgICAgICAgIGlmIChueSA+IGV5KVxuICAgICAgICAgICAgICAgIGV5ID0gbnk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9wYXJlbnQuX291dE9mQm91bmRzID09PSAyKSB7XG4gICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuICAgICAgICAgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgIHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbiA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9kaXNhYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmIChyZWNhbGMgJiA2KSB7XG4gICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDA7XG4gICAgICAgICAgICBsZXQgd2l0aGluTWFyZ2luID0gdHJ1ZTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCB8fCAhdGhpcy5fdGV4dHVyaXplciB8fCAhdGhpcy5fdGV4dHVyaXplci5yZW5kZXJPZmZzY3JlZW4pIHtcbiAgICAgICAgICAgICAgaWYgKHRoaXMuX3NjaXNzb3IgJiYgKHRoaXMuX3NjaXNzb3JbMl0gPD0gMCB8fCB0aGlzLl9zY2lzc29yWzNdIDw9IDApKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAyO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zY2lzc29yWzBdID4gZXggfHwgdGhpcy5fc2Npc3NvclsxXSA+IGV5IHx8IHN4ID4gdGhpcy5fc2Npc3NvclswXSArIHRoaXMuX3NjaXNzb3JbMl0gfHwgc3kgPiB0aGlzLl9zY2lzc29yWzFdICsgdGhpcy5fc2Npc3NvclszXSkge1xuICAgICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAxO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fb3V0T2ZCb3VuZHMpIHtcbiAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jbGlwcGluZyB8fCB0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUgfHwgdGhpcy5fY2xpcGJveCAmJiAoYmJveFcgJiYgYmJveEgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgd2l0aGluTWFyZ2luID0gdGhpcy5fb3V0T2ZCb3VuZHMgPT09IDA7XG4gICAgICAgICAgICAgIGlmICghd2l0aGluTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlY0JvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICAgICAgd2l0aGluTWFyZ2luID0gIShleCA8IHRoaXMuX3NjaXNzb3JbMF0gLSB0aGlzLl9yZWNCb3VuZHNNYXJnaW5bMl0gfHwgZXkgPCB0aGlzLl9zY2lzc29yWzFdIC0gdGhpcy5fcmVjQm91bmRzTWFyZ2luWzNdIHx8IHN4ID4gdGhpcy5fc2Npc3NvclswXSArIHRoaXMuX3NjaXNzb3JbMl0gKyB0aGlzLl9yZWNCb3VuZHNNYXJnaW5bMF0gfHwgc3kgPiB0aGlzLl9zY2lzc29yWzFdICsgdGhpcy5fc2Npc3NvclszXSArIHRoaXMuX3JlY0JvdW5kc01hcmdpblsxXSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIHdpdGhpbk1hcmdpbiA9ICEoZXggPCB0aGlzLl9zY2lzc29yWzBdIC0gMTAwIHx8IGV5IDwgdGhpcy5fc2Npc3NvclsxXSAtIDEwMCB8fCBzeCA+IHRoaXMuX3NjaXNzb3JbMF0gKyB0aGlzLl9zY2lzc29yWzJdICsgMTAwIHx8IHN5ID4gdGhpcy5fc2Npc3NvclsxXSArIHRoaXMuX3NjaXNzb3JbM10gKyAxMDApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAod2l0aGluTWFyZ2luICYmIHRoaXMuX291dE9mQm91bmRzID09PSAyKSB7XG4gICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDE7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luICE9PSB3aXRoaW5NYXJnaW4pIHtcbiAgICAgICAgICAgICAgdGhpcy5fd2l0aGluQm91bmRzTWFyZ2luID0gd2l0aGluTWFyZ2luO1xuICAgICAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5faGFzVXBkYXRlcyA9IHRydWU7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVjYWxjMiA9IHRoaXMuX3JlY2FsYztcbiAgICAgICAgICAgICAgICB0aGlzLl9yZWNhbGMgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZW5hYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlY2FsYykge1xuICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudXBkYXRlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX3JlY2FsYyA9IHJlY2FsYzI7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9kaXNhYmxlV2l0aGluQm91bmRzTWFyZ2luKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgIGlmICh0aGlzLl92aWV3cG9ydCkge1xuICAgICAgICAgICAgdGhpcy5fdmlld3BvcnRbMl0gPSBiYm94VztcbiAgICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0WzNdID0gYmJveEg7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3ZpZXdwb3J0ID0gWzAsIDAsIGJib3hXLCBiYm94SF07XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3BSZWNhbGMgPSB0aGlzLl9yZWNhbGMgJiAxMzU7XG4gICAgICAgIHRoaXMuX3JlY2FsYyA9IDA7XG4gICAgICAgIHRoaXMuX2hhc1VwZGF0ZXMgPSBmYWxzZTtcbiAgICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzIDwgMikge1xuICAgICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl93b3JsZENvbnRleHQuaXNJZGVudGl0eSgpKSB7XG4gICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gRWxlbWVudENvcmVDb250ZXh0LklERU5USVRZO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gcjtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW5baV0uX2hhc1VwZGF0ZXMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGUoKTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS5fcmVjYWxjIHw9IHRoaXMuX3BSZWNhbGM7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlT3V0T2ZCb3VuZHMoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fb25BZnRlclVwZGF0ZSkge1xuICAgICAgICAgIHRoaXMuX29uQWZ0ZXJVcGRhdGUodGhpcy5lbGVtZW50KTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMuY3R4LnVwZGF0ZVRyZWVPcmRlciA9PT0gLT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XNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX3cgPT09IDAgfHwgdGhpcy5faCA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgIH0gZWxzZSBpZiAoIXRoaXMuX3RleHR1cml6ZXIuaGFzUmVuZGVyVGV4dHVyZSgpIHx8IGhhc1JlbmRlclVwZGF0ZXMgPj0gMykge1xuICAgICAgICAgICAgdGhpcy5jdHgucmVuZGVyVG9UZXh0dXJlQ291bnQrKztcbiAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNoYWRlcihyZW5kZXJTdGF0ZS5kZWZhdWx0U2hhZGVyLCB0aGlzKTtcbiAgICAgICAgICAgIHByZXZSZW5kZXJUZXh0dXJlSW5mbyA9IHJlbmRlclN0YXRlLnJlbmRlclRleHR1cmVJbmZvO1xuICAgICAgICAgICAgcmVuZGVyVGV4dHVyZUluZm8gPSB7XG4gICAgICAgICAgICAgIG5hdGl2ZVRleHR1cmU6IG51bGwsXG4gICAgICAgICAgICAgIG9mZnNldDogMCxcbiAgICAgICAgICAgICAgdzogdGhpcy5fdyxcbiAgICAgICAgICAgICAgaDogdGhpcy5faCxcbiAgICAgICAgICAgICAgZW1wdHk6IHRydWUsXG4gICAgICAgICAgICAgIGNsZWFyZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICBpZ25vcmU6IGZhbHNlLFxuICAgICAgICAgICAgICBjYWNoZTogZmFsc2VcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAodGhpcy5fdGV4dHVyaXplci5oYXNSZXN1bHRUZXh0dXJlKCkgfHwgIXJlbmRlclN0YXRlLmlzQ2FjaGluZ1RleHR1cml6ZXIgJiYgaGFzUmVuZGVyVXBkYXRlcyA8IDMpIHtcbiAgICAgICAgICAgICAgcmVuZGVyVGV4dHVyZUluZm8uY2FjaGUgPSB0cnVlO1xuICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5pc0NhY2hpbmdU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RlclN0YXRlLmFkZFF1YWQodGhpcyk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChtdXN0UmVuZGVyQ2hpbGRyZW4gJiYgdGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSkge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW5baV0uX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICBsZXQgdXBkYXRlUmVzdWx0VGV4dHVyZSA9IGZhbHNlO1xuICAgICAgICAgIGlmIChtdXN0UmVuZGVyQ2hpbGRyZW4pIHtcbiAgICAgICAgICAgIHJlbmRlclN0YXRlLmZpbmlzaGVkUmVuZGVyVGV4dHVyZSgpO1xuICAgICAgICAgICAgdGhpcy5fdGV4dHVyaXplci5lbXB0eSA9IHJlbmRlclRleHR1cmVJbmZvLmVtcHR5O1xuICAgICAgICAgICAgaWYgKHJlbmRlclRleHR1cmVJbmZvLmVtcHR5KSB7XG4gICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZVJlbmRlclRleHR1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b3VudGVyO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIudXBkYXRlUmVzdWx0VGV4dHVyZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLnJlbmRlck9mZnNjcmVlbikge1xuICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTaGFkZXIodGhpcy5hY3RpdmVTaGFkZXIsIHRoaXMuX3NoYWRlck93bmVyKTtcbiAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2Npc3Nvcih0aGlzLl9zY2lzc29yKTtcbiAgICAgICAgICAgICAgY29uc3QgY2FjaGUgPSAhcmVuZGVyVGV4dHVyZUluZm8gfHwgcmVuZGVyVGV4dHVyZUluZm8uY2FjaGU7XG4gICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFRleHR1cml6ZXIodGhpcy5fdGV4dHVyaXplciwgY2FjaGUpO1xuICAgICAgICAgICAgICB0aGlzLl9zdGFzaFRleENvb3JkcygpO1xuICAgICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIuY29sb3JpemUpXG4gICAgICAgICAgICAgICAgdGhpcy5fc3Rhc2hDb2xvcnMoKTtcbiAgICAgICAgICAgICAgdGhpcy5yZW5kZXJTdGF0ZS5hZGRRdWFkKHRoaXMsIHRydWUpO1xuICAgICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIuY29sb3JpemUpXG4gICAgICAgICAgICAgICAgdGhpcy5fdW5zdGFzaENvbG9ycygpO1xuICAgICAgICAgICAgICB0aGlzLl91bnN0YXNoVGV4Q29vcmRzKCk7XG4gICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFRleHR1cml6ZXIobnVsbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChyZW5kZXJUZXh0dXJlSW5mbyAmJiByZW5kZXJUZXh0dXJlSW5mby5jYWNoZSkge1xuICAgICAgICAgIHJlbmRlclN0YXRlLmlzQ2FjaGluZ1RleHR1cml6ZXIgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBnZXQgelNvcnQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5felNvcnQ7XG4gICAgfVxuICAgIHNvcnRaSW5kZXhlZENoaWxkcmVuKCkge1xuICAgICAgY29uc3QgbiA9IHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgbGV0IHB0ciA9IDA7XG4gICAgICBjb25zdCBhID0gdGhpcy5fekluZGV4ZWRDaGlsZHJlbjtcbiAgICAgIGNvbnN0IGIgPSBbXTtcbiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIGlmIChhW2ldLl96UGFyZW50ID09PSB0aGlzKSB7XG4gICAgICAgICAgaWYgKGFbaV0uX3pJbmRleFJlc29ydCkge1xuICAgICAgICAgICAgYi5wdXNoKGFbaV0pO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAocHRyICE9PSBpKSB7XG4gICAgICAgICAgICAgIGFbcHRyXSA9IGFbaV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwdHIrKztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGNvbnN0IG0gPSBiLmxlbmd0aDtcbiAgICAgIGlmIChtKSB7XG4gICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbTsgaisrKSB7XG4gICAgICAgICAgYltqXS5fekluZGV4UmVzb3J0ID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgYi5zb3J0KEVsZW1lbnRDb3JlLnNvcnRaSW5kZXhlZENoaWxkcmVuKTtcbiAgICAgICAgY29uc3QgbjIgPSBwdHI7XG4gICAgICAgIGlmICghbjIpIHtcbiAgICAgICAgICBwdHIgPSAwO1xuICAgICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgICBkbyB7XG4gICAgICAgICAgICBhW3B0cisrXSA9IGJbaisrXTtcbiAgICAgICAgICB9IHdoaWxlIChqIDwgbSk7XG4gICAgICAgICAgaWYgKGEubGVuZ3RoID4gcHRyKSB7XG4gICAgICAgICAgICBhLnNwbGljZShwdHIpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwdHIgPSAwO1xuICAgICAgICAgIGxldCBpID0gMDtcbiAgICAgICAgICBsZXQgaiA9IDA7XG4gICAgICAgICAgY29uc3QgbWVyZ2VSZXN1bHQgPSBbXTtcbiAgICAgICAgICBkbyB7XG4gICAgICAgICAgICBjb25zdCB2ID0gYVtpXS5fekluZGV4ID09PSBiW2pdLl96SW5kZXggPyBhW2ldLl91cGRhdGVUcmVlT3JkZXIgLSBiW2pdLl91cGRhdGVUcmVlT3JkZXIgOiBhW2ldLl96SW5kZXggLSBiW2pdLl96SW5kZXg7XG4gICAgICAgICAgICBjb25zdCBhZGQgPSB2ID4gMCA/IGJbaisrXSA6IGFbaSsrXTtcbiAgICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgbWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZCkge1xuICAgICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoaSA+PSBuMikge1xuICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgY29uc3QgYWRkMiA9IGJbaisrXTtcbiAgICAgICAgICAgICAgICBpZiAocHRyID09PSAwIHx8IG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQyKSB7XG4gICAgICAgICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQyO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSB3aGlsZSAoaiA8IG0pO1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaiA+PSBtKSB7XG4gICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICBjb25zdCBhZGQyID0gYVtpKytdO1xuICAgICAgICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgbWVyZ2VSZXN1bHRbcHRyIC0gMV0gIT09IGFkZDIpIHtcbiAgICAgICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IHdoaWxlIChpIDwgbjIpO1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IHdoaWxlICh0cnVlKTtcbiAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuID0gbWVyZ2VSZXN1bHQ7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmIChhLmxlbmd0aCA+IHB0cikge1xuICAgICAgICAgIGEuc3BsaWNlKHB0cik7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHRoaXMuX3pTb3J0ID0gZmFsc2U7XG4gICAgfVxuICAgIGdldCBsb2NhbFRhKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGE7XG4gICAgfVxuICAgIGdldCBsb2NhbFRiKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGI7XG4gICAgfVxuICAgIGdldCBsb2NhbFRjKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGM7XG4gICAgfVxuICAgIGdldCBsb2NhbFRkKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGQ7XG4gICAgfVxuICAgIGdldCBlbGVtZW50KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2VsZW1lbnQ7XG4gICAgfVxuICAgIGdldCByZW5kZXJVcGRhdGVzKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2hhc1JlbmRlclVwZGF0ZXM7XG4gICAgfVxuICAgIGdldCB0ZXh0dXJpemVyKCkge1xuICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyKSB7XG4gICAgICAgIHRoaXMuX3RleHR1cml6ZXIgPSBuZXcgRWxlbWVudFRleHR1cml6ZXIodGhpcyk7XG4gICAgICB9XG4gICAgICByZXR1cm4gdGhpcy5fdGV4dHVyaXplcjtcbiAgICB9XG4gICAgZ2V0Q29ybmVyUG9pbnRzKCkge1xuICAgICAgbGV0IHcgPSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICByZXR1cm4gW1xuICAgICAgICB3LnB4LFxuICAgICAgICB3LnB5LFxuICAgICAgICB3LnB4ICsgdGhpcy5fdyAqIHcudGEsXG4gICAgICAgIHcucHkgKyB0aGlzLl93ICogdy50YyxcbiAgICAgICAgdy5weCArIHRoaXMuX3cgKiB3LnRhICsgdGhpcy5faCAqIHcudGIsXG4gICAgICAgIHcucHkgKyB0aGlzLl93ICogdy50YyArIHRoaXMuX2ggKiB3LnRkLFxuICAgICAgICB3LnB4ICsgdGhpcy5faCAqIHcudGIsXG4gICAgICAgIHcucHkgKyB0aGlzLl9oICogdy50ZFxuICAgICAgXTtcbiAgICB9XG4gICAgZ2V0UmVuZGVyVGV4dHVyZUNvb3JkcyhyZWxYLCByZWxZKSB7XG4gICAgICBsZXQgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG4gICAgICByZXR1cm4gW1xuICAgICAgICByLnB4ICsgci50YSAqIHJlbFggKyByLnRiICogcmVsWSxcbiAgICAgICAgci5weSArIHIudGMgKiByZWxYICsgci50ZCAqIHJlbFlcbiAgICAgIF07XG4gICAgfVxuICAgIGdldEFic29sdXRlQ29vcmRzKHJlbFgsIHJlbFkpIHtcbiAgICAgIGxldCB3ID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICAgIHJldHVybiBbXG4gICAgICAgIHcucHggKyB3LnRhICogcmVsWCArIHcudGIgKiByZWxZLFxuICAg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KTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLmlzVXNlZCgpKSB7XG4gICAgICAgIGlmIChuZXdTb3VyY2UpIHtcbiAgICAgICAgICBpZiAobmV3U291cmNlLmlzTG9hZGVkKCkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9yZXNpemVNb2RlKSB7XG4gICAgICAgICAgICAgIHRoaXMuX2FwcGx5UmVzaXplTW9kZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKChlbGVtZW50KSA9PiB7XG4gICAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgIGVsZW1lbnQuX3NldERpc3BsYXllZFRleHR1cmUodGhpcyk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBsb2FkRXJyb3IgPSBuZXdTb3VyY2UubG9hZEVycm9yO1xuICAgICAgICAgICAgaWYgKGxvYWRFcnJvcikge1xuICAgICAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goKGVsZW1lbnQpID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICAgIGVsZW1lbnQub25UZXh0dXJlU291cmNlTG9hZEVycm9yKGxvYWRFcnJvcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKChlbGVtZW50KSA9PiB7XG4gICAgICAgICAgICBpZiAoZWxlbWVudC5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgZWxlbWVudC5fc2V0RGlzcGxheWVkVGV4dHVyZShudWxsKTtcbiA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AgdGhpcy5fc2V0dGluZ3MuZm9udFNpemUsXG4gICAgICAgICAgdGhpcy5nZXRQcmVjaXNpb24oKSxcbiAgICAgICAgICB0aGlzLl9zdGFnZS5nZXRPcHRpb24oXCJkZWZhdWx0Rm9udEZhY2VcIilcbiAgICAgICAgKTtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBpZiAoIWRvY3VtZW50LmZvbnRzLmNoZWNrKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KSkge1xuICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50LmZvbnRzLmxvYWQoZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpLmNhdGNoKChlcnIpID0+IHtcbiAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gRm9udCBsb2FkIGVycm9yXCIsIGVyciwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgfSkudGhlbigoKSA9PiB7XG4gICAgICAgICAgICAgIGlmICghZG9jdW1lbnQuZm9udHMuY2hlY2soZm9udFNldHRpbmcsIHRoaXMuX3NldHRpbmdzLnRleHQpKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gRm9udCBub3QgZm91bmRcIiwgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBDYW4ndCBjaGVjayBmb250IGxvYWRpbmcgZm9yIFwiICsgZm9udFNldHRpbmcpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGRyYXcoKSB7XG4gICAgICBjb25zdCBsb2FkUHJvbWlzZSA9IHRoaXMuX2xvYWQoKTtcbiAgICAgIGlmICghbG9hZFByb21pc2UpIHtcbiAgICAgICAgcmV0dXJuIFV0aWxz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iAgICAgIHJlbmRlckluZm8uY3V0U3kgPSBjdXRTeTtcbiAgICAgIHJlbmRlckluZm8uY3V0RXkgPSBjdXRFeTtcbiAgICAgIHJlbmRlckluZm8udGV4dEluZGVudCA9IHRoaXMuX3NldHRpbmdzLnRleHRJbmRlbnQgKiBwcmVjaXNpb247XG4gICAgICByZW5kZXJJbmZvLndvcmRCcmVhayA9IHRoaXMuX3NldHRpbmdzLndvcmRCcmVhaztcbiAgICAgIGxldCB0ZXh0ID0gcmVuZGVySW5mby50ZXh0O1xuICAgICAgbGV0IHdyYXBXaWR0aCA9IHJlbmRlckluZm8ud29yZFdyYXAgPyByZW5kZXJJbmZvLndvcmRXcmFwV2lkdGggfHwgcmVuZGVySW5mby53aWR0aCA6IHJlbmRlckluZm8ud2lkdGg7XG4gICAgICBpZiAocmVuZGVySW5mby50ZXh0T3ZlcmZsb3cgJiYgIXJlbmRlckluZm8ud29yZFdyYXApIHtcbiAgICAgICAgbGV0IHN1ZmZpeDtcbiAgICAgICAgc3dpdGNoICh0aGlzLl9zZXR0aW5ncy50ZXh0T3ZlcmZsb3cpIHtcbiAgICAgICAgICBjYXNlIFwiY2xpcFwiOlxuICAgICAgICAgICAgc3VmZml4ID0gXCJcIjtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIGNhc2UgXCJlbGxpcHNpc1wiOlxuICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5fc2V0dGluZ3MubWF4TGluZXNTdWZmaXg7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5fc2V0dGluZ3MudGV4dE92ZXJmbG93O1xuICAgICAgICB9XG4gICAgICAgIHRleHQgPSB0aGlzLndyYXBXb3JkKHRleHQsIHdvcmRXcmFwV2lkdGggfHwgcmVuZGVySW5mby53LCBzdWZmaXgpO1xuICAgICAgfVxuICAgICAgdGV4dCA9IHRoaXMudG9rZW5pemUodGV4dCk7XG4gICAgICB0ZXh0ID0gdGhpcy5wYXJzZSh0ZXh0KTtcbiAgICAgIHRleHQgPSB0aGlzLm1lYXN1cmUodGV4dCwgbGV0dGVyU3BhY2luZywgcmVuZGVySW5mby5iYXNlRm9udCk7XG4gICAgICBpZiAocmVuZGVySW5mby50ZXh0SW5kZW50KSB7XG4gICAgICAgIHRleHQgPSB0aGlzLmluZGVudCh0ZXh0LCByZW5kZXJJbmZvLnRleHRJbmRlbnQpO1xuICAgICAgfVxuICAgICAgaWYgKHJlbmRlckluZm8ud29yZEJyZWFrKSB7XG4gICAgICAgIHRleHQgPSB0ZXh0LnJlZHVjZSgoYWNjLCB0KSA9PiBhY2MuY29uY2F0KHRoaXMud29yZEJyZWFrKHQsIHdyYXBXaWR0aCwgcmVuZGVySW5mby5iYXNlRm9udCkpLCBbXSk7XG4gICAgICAgIHRoaXMucmVzZXRGb250U3R5bGUoKTtcbiAgICAgIH1cbiAgICAgIGxldCB4ID0gcGFkZGluZ0xlZnQ7XG4gICAgICBsZXQgbGluZU5vID0gMDtcbiAgICAgIGZvciAoY29uc3QgdCBvZiB0ZXh0KSB7XG4gICAgICAgIGlmIChyZW5kZXJJbmZvLndvcmRXcmFwICYmIHggKyB0LndpZHRoID4gd3JhcFdpZHRoIHx8IHQudGV4dCA9PSBcIlxcblwiKSB7XG4gICAgICAgICAgeCA9IHBhZGRpbmdMZWZ0O1xuICAgICAgICAgIGxpbmVObyArPSAxO1xuICAgICAgICB9XG4gICAgICAgIHQubGluZU5vID0gbGluZU5vO1xuICAgICAgICBpZiAodC50ZXh0ID09IFwiXFxuXCIpIHtcbiAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuICAgICAgICB0LnggPSB4O1xuICAgICAgICB4ICs9IHQud2lkdGg7XG4gICAgICB9XG4gICAgICByZW5kZXJJbmZvLmxpbmVOdW0gPSBsaW5lTm8gKyAxO1xuICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLmgpIHtcbiAgICAgICAgcmVuZGVyS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XG4gICAgICByZW5kZXJJbmZvLmxpbmVzID0gW107XG4gICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHJlbmRlckluZm8ubGluZU51bTsgaSsrKSB7XG4gICAgICAgIHJlbmRlckluZm8ubGluZXNbaV0gPSB7XG4gICAgICAgICAgd2lkdGg6IDAsXG4gICAgICAgICAgeDogMCxcbiAgICAgICAgICB5OiByZW5kZXJJbmZvLmxpbmVIZWlnaHQgKiBpICsgdmFPZmZzZXQsXG4gICAgICAgICAgdGV4dDogW11cbiAgICAgICAgfTtcbiAgICAgIH1cbiAgICAgIGZvciAobGV0IHQgb2YgdGV4dCkge1xuICAgICAgICByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS50ZXh0LnB1c2godCk7XG4gICAgICB9XG4gICAgICBmb3IgKGNvbnN0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICBpZiAobC50ZXh0Lmxlbmd0aCA9PSAwKSB7XG4gICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgZmlyc3RXb3JkID0gbC50ZXh0WzBdLnRleHQ7XG4gICAgICAgIGNvbnN0IGxhc3RXb3JkID0gbC50ZXh0W2wudGV4dC5sZW5ndGggLSAxXS50ZXh0O1xuICAgICAgICBpZiAoZmlyc3RXb3JkID09IFwiXFxuXCIpIHtcbiAgICAgICAgICBsLnRleHQuc2hpZnQoKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNTcGFjZShsYXN0V29yZCkgfHwgbGFzdFdvcmQgPT0gXCJcXG5cIikge1xuICAgICAgICAgIGwudGV4dC5wb3AoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgZm9yIChsZXQgbCBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgIGwud2lkdGggPSBsLnRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYyArIHQud2lkdGgsIDApO1xuICAgICAgfVxuICAgICAgcmVuZGVySW5mby53aWR0aCA9IHRoaXMuX3NldHRpbmdzLncgIT0gMCA/IHRoaXMuX3NldHRpbmdzLncgKiBwcmVjaXNpb24gOiBNYXRoLm1heCguLi5yZW5kZXJJbmZvLmxpbmVzLm1hcCgobCkgPT4gbC53aWR0aCkpICsgcGFkZGluZ1JpZ2h0O1xuICAgICAgcmVuZGVySW5mby53ID0gcmVuZGVySW5mby53aWR0aDtcbiAgICAgIGlmIChyZW5kZXJJbmZvLm1heExpbmVzICYmIHJlbmRlckluZm8ubGluZU51bSA+IHJlbmRlckluZm8ubWF4TGluZXMgJiYgcmVuZGVySW5mby5tYXhMaW5lc1N1ZmZpeCkge1xuICAgICAgICBjb25zdCBpbmRleCA9IHJlbmRlckluZm8ubWF4TGluZXMgLSAxO1xuICAgICAgICBsZXQgbGFzdExpbmVUZXh0ID0gdGV4dC5maWx0ZXIoKHQpID0+IHQubGluZU5vID09IGluZGV4KTtcbiAgICAgICAgbGV0IHN1ZmZpeCA9IHJlbmRlckluZm8ubWF4TGluZXNTdWZmaXg7XG4gICAgICAgIHN1ZmZpeCA9IHRoaXMudG9rZW5pemUoc3VmZml4KTtcbiAgICAgICAgc3VmZml4ID0gdGhpcy5wYXJzZShzdWZmaXgpO1xuICAgICAgICBzdWZmaXggPSB0aGlzLm1lYXN1cmUoc3VmZml4LCByZW5kZXJJbmZvLmxldHRlclNwYWNpbmcsIHJlbmRlckluZm8uYmFzZUZvbnQpO1xuICAgICAgICBmb3IgKGNvbnN0IHMgb2Ygc3VmZml4KSB7XG4gICAgICAgICAgcy5saW5lTm8gPSBpbmRleDtcbiAgICAgICAgICBzLnggPSAwO1xuICAgICAgICAgIGxhc3RMaW5lVGV4dC5wdXNoKHMpO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IHNwbCA9IHN1ZmZpeC5sZW5ndGggKyAxO1xuICAgICAgICBsZXQgX3cgPSBsYXN0TGluZVRleHQucmVkdWNlKChhY2MsIHQpID0+IGFjYyArIHQud2lkdGgsIDApO1xuICAgICAgICB3aGlsZSAoX3cgPiByZW5kZXJJbmZvLndpZHRoIHx8IGlzU3BhY2UobGFzdExpbmVUZXh0W2xhc3RMaW5lVGV4dC5sZW5ndGggLSBzcGxdLnRleHQpKSB7XG4gICAgICAgICAgbGFzdExpbmVUZXh0LnNwbGljZShsYXN0TGluZVRleHQubGVuZ3RoIC0gc3BsLCAxKTtcbiAgICAgICAgICBfdyA9IGxhc3RMaW5lVGV4dC5yZWR1Y2UoKGFjYywgdCkgPT4gYWNjICsgdC53aWR0aCwgMCk7XG4gICAgICAgICAgaWYgKGxhc3RMaW5lVGV4dC5sZW5ndGggPCBzcGwpIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLmFsaWduTGluZShsYXN0TGluZVRleHQsIGxhc3RMaW5lVGV4dFswXS54KTtcbiAgICAgICAgcmVuZGVySW5mby5saW5lc1tpbmRleF0udGV4dCA9IGxhc3RMaW5lVGV4dDtcbiAgICAgICAgcmVuZGVySW5mby5saW5lc1tpbmRleF0ud2lkdGggPSBfdztcbiAgICAgIH1cbiAgICAgIGlmIChyZW5kZXJJbmZvLnRleHRBbGlnbiA9PSBcImNlbnRlclwiKSB7XG4gICAgICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICAgIGwueCA9IChyZW5kZXJJbmZvLndpZHRoIC0gbC53aWR0aCAtIHBhZGRpbmdMZWZ0KSAvIDI7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSBpZiAocmVuZGVySW5mby50ZXh0QWxpZ24gPT0gXCJyaWdodFwiKSB7XG4gICAgICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICAgIGwueCA9IHJlbmRlckluZm8ud2lkdGggLSBsLndpZHRoIC0gcGFkZGluZ0xlZnQ7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiByZW5kZXJJbmZvO1xuICAgIH1cbi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T2Zmc2V0WCAqIHByZWNpc2lvbjtcbiAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dPZmZzZXRZID0gdGhpcy5fc2V0dGluZ3Muc2hhZG93T2Zmc2V0WSAqIHByZWNpc2lvbjtcbiAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dCbHVyID0gdGhpcy5fc2V0dGluZ3Muc2hhZG93Qmx1ciAqIHByZWNpc2lvbjtcbiAgICAgIH1cbiAgICAgIGNvbnN0IGRlZmF1bHRDb2xvciA9IFN0YWdlVXRpbHMuZ2V0UmdiYVN0cmluZyh0aGlzLl9zZXR0aW5ncy50ZXh0Q29sb3IpO1xuICAgICAgbGV0IGN1cnJlbnRDb2xvciA9IGRlZmF1bHRDb2xvcjtcbiAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFN0eWxlID0gZGVmYXVsdENvbG9yO1xuICAgICAgZm9yIChjb25zdCBsaW5lIG9mIHJlbmRlckluZm8ubGluZXMpIHtcbiAgICAgICAgZm9yIChjb25zdCB0IG9mIGxpbmUudGV4dCkge1xuICAgICAgICAgIGxldCBseCA9IDA7XG4gICAgICAgICAgaWYgKHQudGV4dCA9PSBcIlxcblwiKSB7XG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHJlbmRlckluZm8ubWF4TGluZXMgJiYgdC5saW5lTm8gPj0gcmVuZGVySW5mby5tYXhMaW5lcykge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0LmNvbG9yICE9IGN1cnJlbnRDb2xvcikge1xuICAgICAgICAgICAgY3VycmVudENvbG9yID0gdC5jb2xvcjtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFN0eWxlID0gY3VycmVudENvbG9yO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSB0LmZvbnRTdHlsZTtcbiAgICAgICAgICBpZiAodC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBsIG9mIHQubGV0dGVycykge1xuICAgICAgICAgICAgICBjb25zdCBfeCA9IHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnggKyB0LnggKyBseDtcbiAgICAgICAgICAgICAgdGhpcy5fY29udGV4dC5maWxsVGV4dChsLnRleHQsIF94LCByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS55ICsgcmVuZGVySW5mby5mb250U2l6ZSk7XG4gICAgICAgICAgICAgIGx4ICs9IGwud2lkdGg7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnN0IF94ID0gcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueCArIHQueDtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFRleHQodC50ZXh0LCBfeCwgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10ueSArIHJlbmRlckluZm8uZm9udFNpemUpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHByZXZTaGFkb3dTZXR0aW5ncykge1xuICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0NvbG9yID0gcHJldlNoYWRvd1NldHRpbmdzWzBdO1xuICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFggPSBwcmV2U2hhZG93U2V0dGluZ3NbMV07XG4gICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93T2Zmc2V0WSA9IHByZXZTaGFkb3dTZXR0aW5nc1syXTtcbiAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dCbHVyID0gcHJldlNoYWRvd1NldHRpbmdzWzNdO1xuICAgICAgfVxuICAgICAgaWYgKHJlbmRlckluZm8uY3V0U3ggfHwgcmVuZGVySW5mby5jdXRTeSkge1xuICAgICAgICB0aGlzLl9jb250ZXh0LnRyYW5zbGF0ZShyZW5kZXJJbmZvLmN1dFN4LC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ICAgICAgICBpdGFsaWMgKz0gMTtcbiAgICAgICAgICB0ID0gXCJcIjtcbiAgICAgICAgfSBlbHNlIGlmICh0ID09IFwiPC9pPlwiICYmIGl0YWxpYyA+IDApIHtcbiAgICAgICAgICBpdGFsaWMgLT0gMTtcbiAgICAgICAgICB0ID0gXCJcIjtcbiAgICAgICAgfSBlbHNlIGlmICh0ID09IFwiPGI+XCIpIHtcbiAgICAgICAgICBib2xkICs9IDE7XG4gICAgICAgICAgdCA9IFwiXCI7XG4gICAgICAgIH0gZWxzZSBpZiAodCA9PSBcIjwvYj5cIiAmJiBib2xkID4gMCkge1xuICAgICAgICAgIGJvbGQgLT0gMTtcbiAgICAgICAgICB0ID0gXCJcIjtcbiAgICAgICAgfSBlbHNlIGlmICh0ID09IFwiPC9jb2xvcj5cIikge1xuICAgICAgICAgIGlmIChjb2xvclN0YWNrLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIGNvbG9yIC09IDE7XG4gICAgICAgICAgICBjb2xvclN0YWNrLnBvcCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICB0ID0gXCJcIjtcbiAgICAgICAgfSBlbHNlIGlmIChjb2xvclJlZ2V4cC50ZXN0KHQpKSB7XG4gICAgICAgICAgY29uc3QgbWF0Y2hlZCA9IGNvbG9yUmVnZXhwLmV4ZWModCk7XG4gICAgICAgICAgY29sb3JTdGFjay5wdXNoKFxuICAgICAgICAgICAgU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHBhcnNlSW50KG1hdGNoZWRbMV0pKVxuICAgICAgICAgICk7XG4gICAgICAgICAgY29sb3IgKz0gMTtcbiAgICAgICAgICB0ID0gXCJcIjtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgIHRleHQ6IHQsXG4gICAgICAgICAgaXRhbGljLFxuICAgICAgICAgIGJvbGQsXG4gICAgICAgICAgY29sb3I6IGNvbG9yU3RhY2tbY29sb3JdXG4gICAgICAgIH07XG4gICAgICB9KS5maWx0ZXIoKG8pID0+IG8udGV4dCAhPSBcIlwiKTtcbiAgICB9XG4gICAgYXBwbHlGb250U3R5bGUod29yZCwgYmFzZUZvbnQpIHtcbiAgICAgIGxldCBmb250ID0gYmFzZUZvbnQ7XG4gICAgICBpZiAod29yZC5ib2xkKSB7XG4gICAgICAgIGZvbnQgPSBcImJvbGQgXCIgKyBmb250O1xuICAgICAgfVxuICAgICAgaWYgKHdvcmQuaXRhbGljKSB7XG4gICAgICAgIGZvbnQgPSBcIml0YWxpYyBcIiArIGZvbnQ7XG4gICAgICB9XG4gICAgICB0aGlzLl9jb250ZXh0LmZvbnQgPSBmb250O1xuICAgICAgd29yZC5mb250U3R5bGUgPSBmb250O1xuICAgIH1cbiAgICByZXNldEZvbnRTdHlsZShiYXNlRm9udCkge1xuICAgICAgdGhpcy5fY29udGV4dC5mb250ID0gYmFzZUZvbnQ7XG4gICAgfVxuICAgIG1lYXN1cmUocGFyc2VkLCBsZXR0ZXJTcGFjaW5nID0gMCwgYmFzZUZvbnQpIHtcbiAgICAgIGZvciAoY29uc3QgcCBvZiBwYXJzZWQpIHtcbiAgICAgICAgdGhpcy5hcHBseUZvbnRTdHlsZShwLCBiYXNlRm9udCk7XG4gICAgICAgIHAud2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHAudGV4dCwgbGV0dGVyU3BhY2luZyk7XG4gICAgICAgIGlmIChsZXR0ZXJTcGFjaW5nID4gMCkge1xuICAgICAgICAgIHAubGV0dGVycyA9IHAudGV4dC5zcGxpdChcIlwiKS5tYXAoKGwpID0+IHtcbiAgICAgICAgICAgIHJldHVybiB7IHRleHQ6IGwgfTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgICBmb3IgKGxldCBsIG9mIHAubGV0dGVycykge1xuICAgICAgICAgICAgbC53aWR0aCA9IHRoaXMubWVhc3VyZVRleHQobC50ZXh0LCBsZXR0ZXJTcGFjaW5nKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cb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GgpO1xuICAgICAgbGV0IHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSk7XG4gICAgICBpZiAodHJ1bmNXb3JkV2lkdGggPiB3aWR0aCkge1xuICAgICAgICB3aGlsZSAoYnJlYWtJbmRleCA+IDApIHtcbiAgICAgICAgICB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgYnJlYWtJbmRleCkpO1xuICAgICAgICAgIGlmICh0cnVuY1dvcmRXaWR0aCA+IHdpZHRoKSB7XG4gICAgICAgICAgICBicmVha0luZGV4IC09IDE7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgd2hpbGUgKGJyZWFrSW5kZXggPCB3b3JkTGVuKSB7XG4gICAgICAgICAgdHJ1bmNXb3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQuc3Vic3RyaW5nKDAsIGJyZWFrSW5kZXgpKTtcbiAgICAgICAgICBpZiAodHJ1bmNXb3JkV2lkdGggPCB3aWR0aCkge1xuICAgICAgICAgICAgYnJlYWtJbmRleCArPSAxO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBicmVha0luZGV4IC09IDE7XG4gICAgICAgICAgICB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgYnJlYWtJbmRleCkpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4geyBicmVha0luZGV4LCB0cnVuY1dvcmRXaWR0aCB9O1xuICAgIH1cbiAgICB3b3JkQnJlYWsod29yZCwgd2lkdGgsIGJhc2VGb250KSB7XG4gICAgICBpZiAoIXdvcmQudGV4dCkge1xuICAgICAgICByZXR1cm4gd29yZDtcbiAgICAgIH1cbiAgICAgIHRoaXMuYXBwbHlGb250U3R5bGUod29yZCwgYmFzZUZvbnQpO1xuICAgICAgY29uc3QgcGFydHMgPSBbXTtcbiAgICAgIGxldCB0ZXh0ID0gd29yZC50ZXh0O1xuICAgICAgaWYgKCF3b3JkLmxldHRlcnMpIHtcbiAgICAgICAgd2hpbGUgKHRydWUpIHtcbiAgICAgICAgICBjb25zdCB7IGJyZWFrSW5kZXgsIHRydW5jV29yZFdpZHRoIH0gPSB0aGlzLl9nZXRCcmVha0luZGV4KHRleHQsIHdpZHRoKTtcbiAgICAgICAgICBwYXJ0cy5wdXNoKHsgLi4ud29yZCB9KTtcbiAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5zbGljZSgwLCBicmVha0luZGV4KTtcbiAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS53aWR0aCA9IHRydW5jV29yZFdpZHRoO1xuICAgICAgICAgIGlmIChicmVha0luZGV4ID09PSB0ZXh0Lmxlbmd0aCkge1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICAgIHRleHQgPSB0ZXh0LnNsaWNlKGJyZWFrSW5kZXgpO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBsZXQgdG90YWxXaWR0aCA9IDA7XG4gICAgICAgIGxldCBsZXR0ZXJzID0gW107XG4gICAgICAgIGxldCBicmVha0luZGV4ID0gMDtcbiAgICAgICAgZm9yIChjb25zdCBsIG9mIHdvcmQubGV0dGVycykge1xuICAgICAgICAgIGlmICh0b3RhbFdpZHRoICsgbC53aWR0aCA+PSB3aWR0aCkge1xuICAgICAgICAgICAgcGFydHMucHVzaCh7IC4uLndvcmQgfSk7XG4gICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS50ZXh0ID0gdGV4dC5zbGljZSgwLCBicmVha0luZGV4KTtcbiAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLndpZHRoID0gdG90YWxXaWR0aDtcbiAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLmxldHRlcnMgPSBsZXR0ZXJzO1xuICAgICAgICAgICAgdGV4dCA9IHRleHQuc2xpY2UoYnJlYWtJbmRleCk7XG4gICAgICAgICAgICB0b3RhbFdpZHRoID0gMDtcbiAgICAgICAgICAgIGxldHRlcnMgPSBbXTtcbiAgICAgICAgICAgIGJyZWFrSW5kZXggPSAwO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBicmVha0luZGV4ICs9IDE7XG4gICAgICAgICAgICBsZXR0ZXJzLnB1c2gobCk7XG4gICAgICAgICAgICB0b3RhbFdpZHRoICs9IGwud2lkdGg7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0b3RhbFdpZHRoID4gMCkge1xuICAgICAgICAgIHBhcnRzLnB1c2goeyAuLi53b3JkIH0pO1xuICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLnRleHQgPSB0ZXh0LnNsaWNlKDAsIGJyZWFrSW5kZXgpO1xuICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLndpZHRoID0gdG90YWxXaWR0aDtcbiAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS5sZXR0ZXJzID0gbGV0dGVycztcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHBhcnRzO1xuICAgIH1cbiAgICBhbGlnbkxpbmUocGFyc2VkLCBpbml0aWFsWCA9IDApIHtcbiAgICAgIGxldCBwcmV2V2lkdGggPSAwO1xuICAgICAgbGV0IHByZXZYID0gaW5pdGlhbFg7XG4gICAgICBmb3IgKGNvbnN0IHdvcmQgb2YgcGFyc2VkKSB7XG4gICAgICAgIGlmICh3b3JkLnRleHQg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ICAgICAgdGhpcy5fdyA9IHY7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IGgoKSB7XG4gICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG4gICAgc2V0IGgodikge1xuICAgICAgaWYgKHRoaXMuX2ggIT09IHYpIHtcbiAgICAgICAgdGhpcy5faCA9IHY7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IGZvbnRTdHlsZSgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9mb250U3R5bGU7XG4gICAgfVxuICAgIHNldCBmb250U3R5bGUodikge1xuICAgICAgaWYgKHRoaXMuX2ZvbnRTdHlsZSAhPT0gdikge1xuICAgICAgICB0aGlzLl9mb250U3R5bGUgPSB2O1xuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBmb250QmFzZWxpbmVSYXRpbygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9mb250QmFzZWxpbmVSYXRpbztcbiAgICB9XG4gICAgc2V0IGZvbnRCYXNlbGluZVJhdGlvKHYpIHtcbiAgICAgIGlmICh0aGlzLl9mb250QmFzZWxpbmVSYXRpbyAhPT0gdikge1xuICAgICAgICB0aGlzLl9mb250QmFzZWxpbmVSYXRpbyA9IHY7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IGZvbnRTaXplKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX2ZvbnRTaXplO1xuICAgIH1cbiAgICBzZXQgZm9udFNpemUodikge1xuICAgICAgaWYgKHRoaXMuX2ZvbnRTaXplICE9PSB2KSB7XG4gICAgICAgIHRoaXMuX2ZvbnRTaXplID0gdjtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgfVxuICAgIH1cbiAgICBnZXQgZm9udEZhY2Uo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V4dEluZGVudDtcbiAgICB9XG4gICAgZ2V0IHByZWNpc2lvbigpIHtcbiAgICAgIHJldHVybiBzdXBlci5wcmVjaXNpb247XG4gICAgfVxuICAgIHNldCBwcmVjaXNpb24odikge1xuICAgICAgaWYgKHRoaXMucHJlY2lzaW9uICE9PSB2KSB7XG4gICAgICAgIHN1cGVyLnByZWNpc2lvbiA9IHY7XG4gICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgIH1cbiAgICB9XG4gICAgX2dldElzVmFsaWQoKSB7XG4gICAgICByZXR1cm4gISF0aGlzLnRleHQ7XG4gICAgfVxuICAgIF9nZXRMb29rdXBJZCgpIHtcbiAgICAgIGxldCBwYXJ0cyA9IFtdO1xuICAgICAgaWYgKHRoaXMudyAhPT0gMClcbiAgICAgICAgcGFydHMucHVzaChcIncgXCIgKyB0aGlzLncpO1xuICAgICAgaWYgKHRoaXMuaCAhPT0gMClcbiAgICAgICAgcGFydHMucHVzaChcImggXCIgKyB0aGlzLmgpO1xuICAgICAgaWYgKHRoaXMuZm9udFN0eWxlICE9PSBcIm5vcm1hbFwiKVxuICAgICAgICBwYXJ0cy5wdXNoKFwiZlNcIiArIHRoaXMuZm9udFN0eWxlKTtcbiAgICAgIGlmICh0aGlzLmZvbnRTaXplICE9PSA0MClcbiAgICAgICAgcGFydHMucHVzaChcImZzXCIgKyB0aGlzLmZvbnRTaXplKTtcbiAgICAgIGlmICh0aGlzLmZvbnRCYXNlbGluZVJhdGlvICE9PSAwKVxuICAgICAgICBwYXJ0cy5wdXNoKFwiZmJcIiArIHRoaXMuZm9udEJhc2VsaW5lUmF0aW8pO1xuICAgICAgaWYgKHRoaXMuZm9udEZhY2UgIT09IG51bGwpXG4gICAgICAgIHBhcnRzLnB1c2goXCJmZlwiICsgKEFycmF5LmlzQXJyYXkodGhpcy5mb250RmFjZSkgPyB0aGlzLmZvbnRGYWNlLmpvaW4oXCIsXCIpIDogdGhpcy5mb250RmFjZSkpO1xuICAgICAgaWYgKHRoaXMud29yZFdyYXAgIT09IHRydWUpXG4gICAgICAgIHBhcnRzLnB1c2goXCJ3clwiICsgKHRoaXMud29yZFdyYXAgPyAxIDogMCkpO1xuICAgICAgaWYgKHRoaXMud29yZFdyYXBXaWR0aCAhPT0gMClcbiAgICAgICAgcGFydHMucHVzaChcInd3XCIgKyB0aGlzLndvcmRXcmFwV2lkdGgpO1xuICAgICAgaWYgKHRoaXMud29yZEJyZWFrICE9PSBmYWxzZSlcbiAgICAgICAgcGFydHMucHVzaChcIndiXCIgKyB0aGlzLndvcmRCcmVhayA/IDEgOiAwKTtcbiAgICAgIGlmICh0aGlzLnRleHRPdmVyZmxvdyAhPSBcIlwiKVxuICAgICAgICBwYXJ0cy5wdXNoKFwidG9cIiArIHRoaXMudGV4dE92ZXJmbG93KTtcbiAgICAgIGlmICh0aGlzLmxpbmVIZWlnaHQgIT09IG51bGwpXG4gICAgICAgIHBhcnRzLnB1c2goXCJsaFwiICsgdGhpcy5saW5lSGVpZ2h0KTtcbiAgICAgIGlmICh0aGlzLnRleHRCYXNlbGluZSAhPT0gXCJhbHBoYWJldGljXCIpXG4gICAgICAgIHBhcnRzLnB1c2goXCJ0YlwiICsgdGhpcy50ZXh0QmFzZWxpbmUpO1xuICAgICAgaWYgKHRoaXMudGV4dEFsaWduICE9PSBcImxlZnRcIilcbiAgICAgICAgcGFydHMucHVzaChcInRhXCIgKyB0aGlzLnRleHRBbGlnbik7XG4gICAgICBpZiAodGhpcy52ZXJ0aWNhbEFsaWduICE9PSBcInRvcFwiKVxuICAgICAgICBwYXJ0cy5wdXNoKFwidmFcIiArIHRoaXMudmVydGljYWxBbGlnbik7XG4gICAgICBpZiAodGhpcy5vZmZzZXRZICE9PSBudWxsKVxuICAgICAgICBwYXJ0cy5wdXNoKFwib3lcIiArIHRoaXMub2Zmc2V0WSk7XG4gICAgICBpZiAodGhpcy5tYXhMaW5lcyAhPT0gMClcbiAgICAgICAgcGFydHMucHVzaChcIm1sXCIgKyB0aGlzLm1heExpbmVzKTtcbiAgICAgIGlmICh0aGlzLm1heExpbmVzU3VmZml4ICE9PSBcIi4uXCIpXG4gICAgICAgIHBhcnRzLnB1c2goXCJtc1wiICsgdGhpcy5tYXhMaW5lc1N1ZmZpeCk7XG4gICAgICBwYXJ0cy5wdXNoKFwicGNcIiArIHRoaXMucHJlY2lzaW9uKTtcbiAgICAgIGlmICh0aGlzLnRleHRDb2xvciAhPT0gNDI5NDk2NzI5NSlcbiAgICAgICAgcGFydHMucHVzaChcImNvXCIgKyB0aGlzLnRleHRDb2xvci50b1N0cmluZygxNikpO1xuICAgICAgaWYgKHRoaXMucGFkZGluZ0xlZnQgIT09IDApXG4gICAgICAgIHBhcnRzLnB1c2goXCJwbFwiICsgdGhpcy5wYWRkaW5nTGVmdCk7XG4gICAgICBpZiAodGhpcy5wYWRkaW5nUmlnaHQgIT09IDApXG4gICAgICAgIHBhcnRzLnB1c2goXCJwclwiICsgdGhpcy5wYWRkaW5nUmlnaHQpO1xuICAgICAgaWYgKHRoaXMuc2hhZG93ICE9PSBmYWxzZSlcbiAgICAgICAgcGFydHMucHVzaChcInNoXCIgKyAodGhpcy5zaGFkb3cgPyAxIDogMCkpO1xuICAgICAgaWYgKHRoaXMuc2hhZG93Q29sb3IgIT09IDQyNzgxOTAwODApXG4gICAgICAgIHBhcnRzLnB1c2goXCJzY1wiICsgdGhpcy5zaGFkb3dDb2xvci50b1N0cmluZygxNikpO1xuICAgICAgaWYgKHRoaXMuc2hhZG93T2Zmc2V0WCAhPT0gMClcbiAgICAgICAgcGFydHMucHVzaChcInN4XCIgKyB0aGlzLnNoYWRvd09mZnNldFgpO1xuICAgICAgaWYgKHRoaXMuc2hhZG93T2Zmc2V0WSAhPT0gMClcbiAgICAgICAgcGFydHMucHVzaChcInN5XCIgKyB0aGlzLnNoYWRvd09mZnNldFkpO1xuICAgICAgaWYgKHRoaXMuc2hhZG93Qmx1ciAhPT0gNSlcbiAgICAgICAgcGFydHMucHVzaChcInNiXCIgKy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gICAgICAgIGNvbnN0IHNoYXJwQ2ZnID0gdGhpcy5zdGFnZS5nZXRPcHRpb24oXCJmb250U2hhcnBcIik7XG4gICAgICAgIGxldCBzaGFycGVuID0gZmFsc2U7XG4gICAgICAgIGlmIChVdGlscyQxLmlzQm9vbGVhbihzaGFycENmZykpIHtcbiAgICAgICAgICBzaGFycGVuID0gc2hhcnBDZmc7XG4gICAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdChzaGFycENmZykpIHtcbiAgICAgICAgICBjb25zdCBwcmVjaXNpb24gPSB0aGlzLnN0YWdlLmdldFJlbmRlclByZWNpc2lvbigpO1xuICAgICAgICAgIHNoYXJwZW4gPSBwcmVjaXNpb24gPD0gc2hhcnBDZmcucHJlY2lzaW9uICYmIGFyZ3MuZm9udFNpemUgPD0gc2hhcnBDZmcuZm9udFNpemU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGdsICYmIHNoYXJwZW4pIHtcbiAgICAgICAgICB0ZXhQYXJhbXNbZ2wuVEVYVFVSRV9NQUdfRklMVEVSXSA9IGdsLk5FQVJFU1Q7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICBwLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgY2IobnVsbCwgT2JqZWN0LmFzc2lnbih7XG4gICAgICAgICAgICAgIHJlbmRlckluZm86IHJlbmRlcmVyLnJlbmRlckluZm8sXG4gICAgICAgICAgICAgIHRocm90dGxlOiBmYWxzZSxcbiAgICAgICAgICAgICAgdGV4UGFyYW1zXG4gICAgICAgICAgICB9LCB0aGlzLnN0YWdlLnBsYXRmb3JtLmdldFRleHR1cmVPcHRpb25zRm9yRHJhd2luZ0NhbnZhcyhjYW52YXMpKSk7XG4gICAgICAgICAgfSkuY2F0Y2goKGVycikgPT4ge1xuICAgICAgICAgICAgY2IoZXJyKTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjYihudWxsLCBPYmplY3QuYXNzaWduKHtcbiAgICAgICAgICAgIHJlbmRlckluZm86IHJlbmRlcmVyLnJlbmRlckluZm8sXG4gICAgICAgICAgICB0aHJvdHRsZTogZmFsc2UsXG4gICAgICAgICAgICB0ZXhQYXJhbXNcbiAgICAgICAgICB9LCB0aGlzLnN0YWdlLnBsYXRmb3JtLmdldFRleHR1cmVPcHRpb25zRm9yRHJhd2luZ0NhbnZhcyhjYW52YXMpKSk7XG4gICAgICAgIH1cbiAgICAgIH07XG4gICAgfVxuICAgIGdldE5vbkRlZmF1bHRzKCkge1xuICAgICAgY29uc3Qgbm9uRGVmYXVsdHMgPSBzdXBlci5nZXROb25EZWZhdWx0cygpO1xuICAgICAgaWYgKHRoaXMudGV4dCAhPT0gXCJcIilcbiAgICAgICAgbm9uRGVmYXVsdHNbXCJ0ZXh0XCJdID0gdGhpcy50ZXh0O1xuICAgICAgaWYgKHRoaXMudyAhPT0gMClcbiAgICAgICAgbm9uRGVmYXVsdHNbXCJ3XCJdID0gdGhpcy53O1xuICAgICAgaWYgKHRoaXMuaCAhPT0gMClcbiAgICAgICAgbm9uRGVmYXVsdHNbXCJoXCJdID0gdGhpcy5oO1xuICAgICAgaWYgKHRoaXMuZm9udFN0eWxlICE9PSBcIm5vcm1hbFwiKVxuICAgICAgICBub25EZWZhdWx0c1tcImZvbnRTdHlsZVwiXSA9IHRoaXMuZm9udFN0eWxlO1xuICAgICAgaWYgKHRoaXMuZm9udFNpemUgIT09IDQwKVxuICAgICAgICBub25EZWZhdWx0c1tcImZvbnRTaXplXCJdID0gdGhpcy5mb250U2l6ZTtcbiAgICAgIGlmICh0aGlzLmZvbnRCYXNlbGluZVJhdGlvICE9PSAwKVxuICAgICAgICBub25EZWZhdWx0c1tcImZvbnRCYXNlbGluZVJhdGlvXCJdID0gdGhpcy5mb250QmFzZWxpbmVSYXRpbztcbiAgICAgIGlmICh0aGlzLmZvbnRGYWNlICE9PSBudWxsKVxuICAgICAgICBub25EZWZhdWx0c1tc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UoaXRlbSwgcHJldkl0ZW0pIHtcbiAgICAgIGNvbnN0IGluZGV4ID0gdGhpcy5nZXRJbmRleChwcmV2SXRlbSk7XG4gICAgICBpZiAoaW5kZXggPT09IC0xKSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcInJlcGxhY2U6IFRoZSBwcmV2aW91cyBpdGVtIGRvZXMgbm90IGV4aXN0XCIpO1xuICAgICAgfVxuICAgICAgdGhpcy5zZXRBdChpdGVtLCBpbmRleCk7XG4gICAgfVxuICAgIHNldEF0KGl0ZW0sIGluZGV4KSB7XG4gICAgICBpZiAoaW5kZXggPj0gMCAmJiBpbmRleCA8IHRoaXMuX2l0ZW1zLmxlbmd0aCkge1xuICAgICAgICBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwoaXRlbSkpIHtcbiAgICAgICAgICBjb25zdCBvID0gaXRlbTtcbiAgICAgICAgICBpdGVtID0gdGhpcy5jcmVhdGVJdGVtKG8pO1xuICAgICAgICAgIGl0ZW0ucGF0Y2gobyk7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGN1cnJlbnRJbmRleCA9IHRoaXMuX2l0ZW1zLmluZGV4T2YoaXRlbSk7XG4gICAgICAgIGlmIChjdXJyZW50SW5kZXggIT0gLTEpIHtcbiAgICAgICAgICBpZiAoY3VycmVudEluZGV4ICE9PSBpbmRleCkge1xuICAgICAgICAgICAgY29uc3QgZnJvbUluZGV4ID0gY3VycmVudEluZGV4O1xuICAgICAgICAgICAgaWYgKGZyb21JbmRleCAhPT0gaW5kZXgpIHtcbiAgICAgICAgICAgICAgdGhpcy5faXRlbXMuc3BsaWNlKGZyb21JbmRleCwgMSk7XG4gICAgICAgICAgICAgIHRoaXMuX2l0ZW1zLnNwbGljZShpbmRleCwgMCwgaXRlbSk7XG4gICAgICAgICAgICAgIHRoaXMub25Nb3ZlKGl0ZW0sIGZyb21JbmRleCwgaW5kZXgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAg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ICAgICAgICBsZXQgY3JlZiA9IGNyZWZzW2ldO1xuICAgICAgICBsZXQgcyA9IHNldHRpbmdzW2NyZWZdO1xuICAgICAgICBsZXQgYyA9IHJlZnNbY3JlZl07XG4gICAgICAgIGlmICghYykge1xuICAgICAgICAgIGlmICh0aGlzLmlzSXRlbShzKSkge1xuICAgICAgICAgICAgcy5yZWYgPSBjcmVmO1xuICAgICAgICAgICAgdGhpcy5hZGQocyk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGMgPSB0aGlzLmNyZWF0ZUl0ZW0ocyk7XG4gICAgICAgICAgICBjLnJlZiA9IGNyZWY7XG4gICAgICAgICAgICBjLnBhdGNoKHMpO1xuICAgICAgICAgICAgdGhpcy5hZGQoYyk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmICh0aGlzLmlzSXRlbShzKSkge1xuICAgICAgICAgICAgaWYgKGMgIT09IHMpIHtcbiAgICAgICAgICAgICAgbGV0IGlkeCA9IHRoaXMuZ2V0SW5kZXgoYyk7XG4gICAgICAgICAgICAgIHMucmVmID0gY3JlZjtcbiAgICAgICAgICAgICAgdGhpcy5zZXRBdChzLCBpZHgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjLnBhdGNoKHMpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfZXF1YWxzQXJyYXkoYXJyYXkpIHtcbiAgICAgIGxldCBzYW1lID0gdHJ1ZTtcbiAgICAgIGlmIChhcnJheS5sZW5ndGggPT09IHRoaXMuX2l0ZW1zLmxlbmd0aCkge1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2l0ZW1zLmxlbmd0aDsgaSA8IG4gJiYgc2FtZTsgaSsrKSB7XG4gICAgICAgICAgc2FtZSA9IHNhbWUgJiYgdGhpcy5faXRlbXNbaV0gPT09IGFycmF5W2ldO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzYW1lID0gZmFsc2U7XG4gICAgICB9XG4gICAgICByZXR1cm4gc2FtZTtcbiAgICB9XG4gICAgX3NldEJ5QXJyYXkoYXJyYXkpIHtcbiAgICAgIGlmICh0aGlzLl9lcXVhbHNBcnJheShhcnJheSkpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgICAgfVxuICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9pdGVtcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgdGhpcy5faXRlbXNbaV0ubWFya2VyID0gdHJ1ZTtcbiAgICAgIH1cbiAgICAgIGxldCByZWZzO1xuICAgICAgbGV0IG5ld0l0ZW1zID0gW107XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGFycmF5Lmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICBsZXQgcyA9IGFycmF5W2ldO1xuICAgICAgICBpZiAodGhpcy5pc0l0ZW0ocykpIHtcbiAgICAgICAgICBzLm1hcmtlciA9IGZhbHNlO1xuICAgICAgICAgIG5ld0l0ZW1zLnB1c2gocyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbGV0IGNyZWYgPSBzLnJlZjtcbiAgICAgICAgICBsZXQgYztcbiAgICAgICAgICBpZiAoY3JlZikge1xuICAgICAgICAgICAgaWYgKCFyZWZzKVxuICAgICAgICAgICAgICByZWZzID0gdGhpcy5fZ2V0UmVmcygpO1xuICAgICAgICAgICAgYyA9IHJlZnNbY3JlZl07XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICghYykge1xuICAgICAgICAgICAgYyA9IHRoaXMuY3JlYXRlSXRlbShzKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgYy5tYXJrZXIgPSBmYWxzZTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHMp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N0b3JPZihjKSB7XG4gICAgICBsZXQgcCA9IGM7XG4gICAgICB3aGlsZSAocCA9IHAucGFyZW50KSB7XG4gICAgICAgIGlmICh0aGlzID09PSBwKSB7XG4gICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG4gICAgZ2V0U2hhcmVkQW5jZXN0b3IoYykge1xuICAgICAgbGV0IG8xID0gdGhpcztcbiAgICAgIGxldCBvMiA9IGM7XG4gICAgICBsZXQgbDEgPSBvMS5nZXREZXB0aCgpO1xuICAgICAgbGV0IGwyID0gbzIuZ2V0RGVwdGgoKTtcbiAgICAgIGlmIChsMSA+IGwyKSB7XG4gICAgICAgIG8xID0gbzEuZ2V0QW5jZXN0b3IobDEgLSBsMik7XG4gICAgICB9IGVsc2UgaWYgKGwyID4gbDEpIHtcbiAgICAgICAgbzIgPSBvMi5nZXRBbmNlc3RvcihsMiAtIGwxKTtcbiAgICAgIH1cbiAgICAgIGRvIHtcbiAgICAgICAgaWYgKG8xID09PSBvMikge1xuICAgICAgICAgIHJldHVybiBvMTtcbiAgICAgICAgfVxuICAgICAgICBvMSA9IG8xLl9fcGFyZW50O1xuICAgICAgICBvMiA9IG8yLl9fcGFyZW50O1xuICAgICAgfSB3aGlsZSAobzEgJiYgbzIpO1xuICAgICAgcmV0dXJuIG51bGw7XG4gICAgfVxuICAgIGdldCBhdHRhY2hlZCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fYXR0YWNoZWQ7XG4gICAgfVxuICAgIGdldCBlbmFibGVkKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19lbmFibGVkO1xuICAgIH1cbiAgICBnZXQgYWN0aXZlKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19hY3RpdmU7XG4gICAgfVxuICAgIF9pc0F0dGFjaGVkKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19wYXJlbnQgPyB0aGlzLl9fcGFyZW50Ll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IHRoaXMuX190ZXh0dXJlO1xuICAgICAgaWYgKHRleHR1cmUgIT09IHByZXZUZXh0dXJlKSB7XG4gICAgICAgIHRoaXMuX190ZXh0dXJlID0gdGV4dHVyZTtcbiAgICAgICAgaWYgKHRoaXMuX190ZXh0dXJlKSB7XG4gICAgICAgICAgaWYgKHRoaXMuX19lbmFibGVkKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGV4dHVyZS5hZGRFbGVtZW50KHRoaXMpO1xuICAgICAgICAgICAgaWYgKHRoaXMud2l0aGluQm91bmRzTWFyZ2luKSB7XG4gICAgICAgICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZS5pc0xvYWRlZCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2V0RGlzcGxheWVkVGV4dHVyZSh0aGlzLl9fdGV4dHVyZSk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZW5hYmxlVGV4dHVyZUVycm9yKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhpcy5fc2V0RGlzcGxheWVkVGV4dHVyZShudWxsKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAocHJldlRleHR1cmUgJiYgcHJldlRleHR1cmUgIT09IHRoaXMuX19kaXNwbGF5ZWRUZXh0dXJlKSB7XG4gICAgICAgICAgcHJldlRleHR1cmUucmVtb3ZlRWxlbWVudCh0aGlzKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCBkaXNwbGF5ZWRUZXh0dXJlKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19kaXNwbGF5ZWRUZXh0dXJlO1xuICAgIH1cbiAgICBfc2V0RGlzcGxheWVkVGV4dHVyZSh2KSB7XG4gICAgICBsZXQgcHJldlRleHR1cmUgPSB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ICAgICAgICAgIGxldCB3ID0gZGlzcGxheWVkVGV4dHVyZVNvdXJjZS5nZXRSZW5kZXJXaWR0aCgpO1xuICAgICAgICAgIGxldCBoID0gZGlzcGxheWVkVGV4dHVyZVNvdXJjZS5nZXRSZW5kZXJIZWlnaHQoKTtcbiAgICAgICAgICBsZXQgaXcsIGloLCBydywgcmg7XG4gICAgICAgICAgaXcgPSAxIC8gdztcbiAgICAgICAgICBpaCA9IDEgLyBoO1xuICAgICAgICAgIGlmIChkaXNwbGF5ZWRUZXh0dXJlLnB3KSB7XG4gICAgICAgICAgICBydyA9IGRpc3BsYXllZFRleHR1cmUucHcgKiBpdztcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcncgPSAodyAtIGRpc3BsYXllZFRleHR1cmUucHgpICogaXc7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChkaXNwbGF5ZWRUZXh0dXJlLnBoKSB7XG4gICAgICAgICAgICByaCA9IGRpc3BsYXllZFRleHR1cmUucGggKiBpaDtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmggPSAoaCAtIGRpc3BsYXllZFRleHR1cmUucHkpICogaWg7XG4gICAgICAgICAgfVxuICAgICAgICAgIGl3ICo9IGRpc3BsYXllZFRleHR1cmUucHg7XG4gICAgICAgICAgaWggKj0gZGlzcGxheWVkVGV4dHVyZS5weTtcbiAgICAgICAgICB0eDEgPSBpdztcbiAgICAgICAgICB0eTEgPSBpaDtcbiAgICAgICAgICB0eDIgPSB0eDIgKiBydyArIGl3O1xuICAgICAgICAgIHR5MiA9IHR5MiAqIHJoICsgaWg7XG4gICAgICAgICAgdHgxID0gTWF0aC5tYXgoMCwgdHgxKTtcbiAgICAgICAgICB0eTEgPSBNYXRoLm1heCgwLCB0eTEpO1xuICAgICAgICAgIHR4MiA9IE1hdGgubWluKDEsIHR4Mik7XG4gICAgICAgICAgdHkyID0gTWF0aC5taW4oMSwgdHkyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZGlzcGxheWVkVGV4dHVyZVNvdXJjZS5fZmxpcFRleHR1cmVZKSB7XG4gICAgICAgICAgbGV0IHRlbXB0eSA9IHR5MjtcbiAgICAgICAgICB0eTIgPSB0eTE7XG4gICAgICAgICAgdHkxID0gdGVtcHR5O1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX19jb3JlLnNldFRleHR1cmVDb29yZHModHgxLCB0eTEsIHR4MiwgdHkyKTtcbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0Q29ybmVyUG9pbnRzKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmdldENvcm5lclBvaW50cygpO1xuICAgIH1cbiAgICBfdW5zZXRUYWdzUGFyZW50KCkge1xuICAgICAgaWYgKHRoaXMuX190YWdzKSB7XG4gICAgICAgIHRoaXMuX190YWdzLmZvckVhY2goKHRhZykgPT4ge1xuICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICB3aGlsZSAocCA9IHAuX19wYXJlbnQpIHtcbiAgICAgICAgICAgIGxldCBwYXJlbnRUcmVlVGFncyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgIHBhcmVudFRyZWVUYWdzLmRlbGV0ZSh0aGlzKTtcbiAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgICAgbGV0IHRhZ3MgPSBudWxsO1xuICAgICAgbGV0IG4gPSAwO1xuICAgICAgaWYgKHRoaXMuX190cmVlVGFncykge1xuICAgICAgICBpZiAoIXRoaXMuX190YWdSb290KSB7XG4gICAgICAgICAgdGFncyA9IFV0aWxzJDEuaXRlcmF0b3JUb0FycmF5KHRoaXMuX190cmVlVGFncy5rZXlzKCkpO1xuICAgICAgICAgIG4gPSB0YWdzLmxlbmd0aDtcbiAgICAgICAgICBpZiAobiA+IDApIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgIGxldCB0YWdTZXQgPSB0aGlzLl9fdHJlZVRhZ3MuZ2V0KHRhZ3NbaV0pO1xuICAgICAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgICAgIHdoaWxlIChwID0gcC5fX3BhcmVudCkge1xuICAgICAgICAgICAgICAgIGxldCBwYXJlbnRUcmVlVGFncyA9IHAuX190cmVlVGFncy5nZXQodGFnc1tpXSk7XG4gICAgICAgICAgICAgICAgdGFnU2V0LmZvckVhY2goZnVuY3Rpb24oY29tcCkge1xuICAgICAgICAgICAgICAgICAgcGFyZW50VHJlZVRhZ3MuZGVsZXRlKGNvbXApO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF9zZXRUYWdzUGFyZW50KCkge1xuICAgICAgaWYgKHRoaXMuX190YWdzKSB7XG4gICAgICAgIHRoaXMuX190YWdzLmZvckVhY2goKHRhZykgPT4ge1xuICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICB3aGlsZSAocCA9IHAuX19wYXJlbnQpIHtcbiAgICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgIHAuX190cmVlVGFncyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgICBzID0gLyogQF9fUFVSRV9fICovIG5ldyBTZXQoKTtcbiAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcy5hZGQodGhpcyk7XG4gICAgICAgICAgICBpZiAocC5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MgJiYgdGhpcy5fX3RyZWVUYWdzLnNpemUpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9fdGFnUm9vdCkge1xuICAgICAgICAgIHRoaXMuX190cmVlVGFncy5mb3JFYWNoKCh0YWdTZXQsIHRhZykgPT4ge1xuICAgICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgICAgd2hpbGUgKCFwLl9fdGFnUm9vdCAmJiAocCA9IHAuX19wYXJlbnQpKSB7XG4gICAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdClcbiAgICAgICAgICAgICAgICA7XG4gICAgICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICAgICAgcyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgU2V0KCk7XG4gICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHRhZ1NldC5mb3JFYWNoKGZ1bmN0aW9uKGNvbXApIHtcbiAgICAgICAgICAgICAgICBzLmFkZChjb21wKTtcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgX2dldEJ5VGFnKHRhZykge1xuICAgICAgaWYgKCF0aGlzLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgcmV0dXJuIFtdO1xuICAgICAgfVxuICAgICAgbGV0IHQgPSB0aGlzLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICByZXR1cm4gdCA/IFV0aWxzJDEuc2V0VG9BcnJheSh0KSA6IFtdO1xuICAgIH1cbiAgICBnZXRUYWdzKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX190YWdzID8gdGhpcy5fX3RhZ3MgOiBbXTtcbiAgICB9XG4gICAgc2V0VGFncyh0YWdzKSB7XG4gICAgICB0YWdzID0gdGFncy5yZWR1Y2UoKGFjYywgdGFnKSA9PiB7XG4gICAgICAgIHJldHVybiBhY2MuY29uY2F0KHRhZy5zcGxpdChcIiBcIikpO1xuICAgICAgfSwgW10pO1xuICAgICAgaWYgKHRoaXMuX19yZWYpIHtcbiAgICAgICAgdGFncy5wdXNoKHRoaXMuX19yZWYpO1xuICAgICAgfVxuICAgICAgbGV0IGksIG4gPSB0YWdzLmxlbmd0aDtcbiAgICAgIGxldCByZW1vdmVzID0gW107XG4gICAgICBsZXQgYWRkcyA9IFtdO1xuICAgICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICBpZiAoIXRoaXMuaGFzVGFnKHRhZ3NbaV0pKSB7XG4gICAgICAgICAgYWRkcy5wdXNoKHRhZ3NbaV0pO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBsZXQgY3VycmVudFRhZ3MgPSB0aGlzLnRhZ3MgfHwgW107XG4gICAgICBuID0gY3VycmVudFRhZ3MubGVuZ3RoO1xuICAgICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICBpZiAodGFncy5pbmRleE9mKGN1cnJlbnRUYWdzW2ldKSA9PSAtMSkge1xuICAgICAgICAgIHJlbW92ZXMucHVzaCh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iAgICAgIGlmICghdGhpcy5fX3RhZ3MpIHtcbiAgICAgICAgdGhpcy5fX3RhZ3MgPSBbXTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9fdGFncy5pbmRleE9mKHRhZykgPT09IC0xKSB7XG4gICAgICAgIHRoaXMuX190YWdzLnB1c2godGFnKTtcbiAgICAgICAgbGV0IHAgPSB0aGlzLl9fcGFyZW50O1xuICAgICAgICBpZiAocCkge1xuICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgIHAuX190cmVlVGFncyA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgICBzID0gLyogQF9fUFVSRV9fICovIG5ldyBTZXQoKTtcbiAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcy5hZGQodGhpcyk7XG4gICAgICAgICAgfSB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJlbW92ZVRhZyh0YWcpIHtcbiAgICAgIGxldCBpID0gdGhpcy5fX3RhZ3MuaW5kZXhPZih0YWcpO1xuICAgICAgaWYgKGkgIT09IC0xKSB7XG4gICAgICAgIHRoaXMuX190YWdzLnNwbGljZShpLCAxKTtcbiAgICAgICAgbGV0IHAgPSB0aGlzLl9fcGFyZW50O1xuICAgICAgICBpZiAocCkge1xuICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgaWYgKGxpc3QpIHtcbiAgICAgICAgICAgICAgbGlzdC5kZWxldGUodGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGhhc1RhZyh0YWcpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fdGFncyAmJiB0aGlzLl9fdGFncy5pbmRleE9mKHRhZykgIT09IC0xO1xuICAgIH1cbiAgICBfdGFnKHRhZykge1xuICAgICAgaWYgKHRhZy5pbmRleE9mKFwiLlwiKSAhPT0gLTEpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMubXRhZyh0YWcpWzBdO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMuX190cmVlVGFncykge1xuICAgICAgICAgIGxldCB0ID0gdGhpcy5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgIGlmICh0KSB7XG4gICAgICAgICAgICBjb25zdCBpdGVtID0gdC52YWx1ZXMoKS5uZXh0KCk7XG4gICAgICAgICAgICByZXR1cm4gaXRlbSA/IGl0ZW0udmFsdWUgOiB2b2lkIDA7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIGdldCB0YWcoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fdGFnO1xuICAgIH1cbiAgICBzZXQgdGFnKHQpIHtcbiAgICAgIHRoaXMudGFncyA9IHQ7XG4gICAgfVxuICAgIG10YWcodGFnKSB7XG4gICAgICBsZXQgaWR4ID0gdGFnLmluZGV4T2YoXCIuXCIpO1xuICAgICAgaWYgKGlkeCA+PSAwKSB7XG4gICAgICAgIGxldCBwYXJ0cyA9IHRhZy5zcGxpdChcIi5cIik7XG4gICAgICAgIGxldCByZXMgPSB0aGlzLl9nZXRCeVRhZyhwYXJ0c1swXSk7XG4gICAgICAgIGxldCBsZXZlbCA9IDE7XG4gICAgICAgIGxldCBjID0gcGFydHMubGVuZ3RoO1xuICAgIC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JZHggPT09IDApIHtcbiAgICAgICAgaXNSZWYgPSBmYWxzZTtcbiAgICAgICAgcGF0aCA9IHBhdGguc3Vic3RyKDEpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaXNSZWYgPSBmYWxzZTtcbiAgICAgIH1cbiAgICAgIHJldHVybiB0aGlzLl9zZWxlY3RDaGlsZHMocGF0aCwgaXNSZWYpO1xuICAgIH1cbiAgICBfc2VsZWN0Q2hpbGRzKHBhdGgsIGlzUmVmKSB7XG4gICAgICBjb25zdCBwb2ludElkeCA9IHBhdGguaW5kZXhPZihcIi5cIik7XG4gICAgICBjb25zdCBhcnJvd0lkeCA9IHBhdGguaW5kZXhPZihcIj5cIik7XG4gICAgICBpZiAocG9pbnRJZHggPT09IC0xICYmIGFycm93SWR4ID09PSAtMSkge1xuICAgICAgICBpZiAoaXNSZWYpIHtcbiAgICAgICAgICBjb25zdCByZWYgPSB0aGlzLmdldEJ5UmVmKHBhdGgpO1xuICAgICAgICAgIHJldHVybiByZWYgPyBbcmVmXSA6IFtdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHJldHVybiB0aGlzLm10YWcocGF0aCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChhcnJvd0lkeCA9PT0gLTEgfHwgcG9pbnRJZHggIT09IC0xICYmIHBvaW50SWR4IDwgYXJyb3dJZHgpIHtcbiAgICAgICAgbGV0IG5leHQ7XG4gICAgICAgIGNvbnN0IHN0ciA9IHBhdGguc3Vic3RyKDAsIHBvaW50SWR4KTtcbiAgICAgICAgaWYgKGlzUmVmKSB7XG4gICAgICAgICAgY29uc3QgcmVmID0gdGhpcy5nZXRCeVJlZihzdHIpO1xuICAgICAgICAgIG5leHQgPSByZWYgPyBbcmVmXSA6IFtdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG5leHQgPSB0aGlzLm10YWcoc3RyKTtcbiAgICAgICAgfVxuICAgICAgICBsZXQgdG90YWwgPSBbXTtcbiA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2luZyA9IG1pc3NpbmcgfHwgIWNoaWxkcmVuW2ldLnJlZjtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKCFtaXNzaW5nKSB7XG4gICAgICAgICAgICBzZXR0aW5ncy5jaGlsZHJlbiA9IHt9O1xuICAgICAgICAgICAgY2hpbGRBcnJheS5mb3JFYWNoKChjaGlsZCkgPT4ge1xuICAgICAgICAgICAgICBzZXR0aW5ncy5jaGlsZHJlbltjaGlsZC5yZWZdID0gY2hpbGQ7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc2V0dGluZ3MuY2hpbGRyZW4gPSBjaGlsZEFycmF5O1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgc2V0dGluZ3MuaWQgPSB0aGlzLmlkO1xuICAgICAgcmV0dXJuIHNldHRpbmdzO1xuICAgIH1cbiAgICBnZXROb25EZWZhdWx0cygpIHtcbiAgICAgIGxldCBzZXR0aW5ncyA9IHt9O1xuICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgIT09IEVsZW1lbnQpIHtcbiAgICAgICAgc2V0dGluZ3MudHlwZSA9IHRoaXMuY29uc3RydWN0b3IubmFtZTtcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLl9fcmVmKSB7XG4gICAgICAgIHNldHRpbmdzLnJlZiA9IHRoaXMuX19yZWY7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5fX3RhZ3MgJiYgdGhpcy5fX3RhZ3MubGVuZ3RoKSB7XG4gICAgICAgIHNldHRpbmdzLnRhZ3MgPSB0aGlzLl9fdGFncztcbiAgICAgIH1cbiAgICAgIGlmICh0aGlzLnggIT09IDApXG4gICAgICAgIHNldHRpbmdzLnggPSB0aGlzLng7XG4gICAgICBpZiAodGhpcy55ICE9PSAwKVxuICAgICAgICBzZXR0aW5ncy55ID0gdGhpcy55O1xuICAgICAgaWYgKHRoaXMudyAhPT0gMClcbiAgICAgICAgc2V0dGluZ3MudyA9IHRoaXMudztcbiAgICAgIGlmICh0aGlzLmggIT09IDApXG4gICAgICAgIHNldHRpbmdzLmggPSB0aGlzLmg7XG4gICAgICBpZiAodGhpcy5zY2FsZVggPT09IHRoaXMuc2NhbGVZKSB7XG4gICAgICAgIGlmICh0aGlzLnNjYWxlWCAhPT0gMSlcbiAgICAgICAgICBzZXR0aW5ncy5zY2FsZSA9IHRoaXMuc2NhbGVYO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMuc2NhbGVYICE9PSAxKVxuICAgICAgICAgIHNldHRpbmdzLnNjYWxlWCA9IHRoaXMuc2NhbGVYO1xuICAgICAgICBpZiAodGhpcy5zY2FsZVkgIT09IDEpXG4gICAgICAgICAgc2V0dGluZ3Muc2NhbGVZID0gdGhpcy5zY2FsZVk7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5waXZvdFggPT09IHRoaXMucGl2b3RZKSB7XG4gICAgICAgIGlmICh0aGlzLnBpdm90WCAhPT0gMC41KVxuICAgICAgICAgIHNldHRpbmdzLnBpdm90ID0gdGhpcy5waXZvdFg7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAodGhpcy5waXZvdFggIT09IDAuNSlcbiAgICAgICAgICBzZXR0aW5ncy5waXZvdFggPSB0aGlzLnBpdm90WDtcbiAgICAgICAgaWYgKHRoaXMucGl2b3RZICE9PSAwLjUpXG4gICAgICAgICAgc2V0dGluZ3MucGl2b3RZID0gdGhpcy5waXZvdFk7XG4gICAgICB9XG4gICAgICBpZiAodGhpcy5tb3VudFggPT09IHRoaXMubW91bnRZKSB7XG4gICAgICAgIGlmICh0aGlzLm1vdW50WCAhPT0gMClcbiAgICAgICAgICBzZXR0aW5ncy5tb3VudCA9IHRoaXMubW91bnRYO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHRoaXMubW91bnRYICE9PSAwKVxuICAgICAgICAgIHNldHRpbmdzLm1vdW50WCA9IHRoaXMubW91bnR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19jb3JlLnBpdm90WCA9IHY7XG4gICAgfVxuICAgIGdldCBwaXZvdFkoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUucGl2b3RZO1xuICAgIH1cbiAgICBzZXQgcGl2b3RZKHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLnBpdm90WSA9IHY7XG4gICAgfVxuICAgIGdldCBwaXZvdCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5waXZvdDtcbiAgICB9XG4gICAgc2V0IHBpdm90KHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLnBpdm90ID0gdjtcbiAgICB9XG4gICAgZ2V0IG1vdW50WCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5tb3VudFg7XG4gICAgfVxuICAgIHNldCBtb3VudFgodikge1xuICAgICAgdGhpcy5fX2NvcmUubW91bnRYID0gdjtcbiAgICB9XG4gICAgZ2V0IG1vdW50WSgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5tb3VudFk7XG4gICAgfVxuICAgIHNldCBtb3VudFkodikge1xuICAgICAgdGhpcy5fX2NvcmUubW91bnRZID0gdjtcbiAgICB9XG4gICAgZ2V0IG1vdW50KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLm1vdW50O1xuICAgIH1cbiAgICBzZXQgbW91bnQodikge1xuICAgICAgdGhpcy5fX2NvcmUubW91bnQgPSB2O1xuICAgIH1cbiAgICBnZXQgcm90YXRpb24oKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUucm90YXRpb247XG4gICAgfVxuICAgIHNldCByb3RhdGlvbih2KSB7XG4gICAgICB0aGlzLl9fY29yZS5yb3RhdGlvbiA9IHY7XG4gICAgfVxuICAgIGdldCBhbHBoYSgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5hbHBoYTtcbiAgICB9XG4gICAgc2V0IGFscGhhKHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLmFscGhhID0gdjtcb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E9PSB2KSB7XG4gICAgICAgIHRoaXMuY29sb3JVciA9IHY7XG4gICAgICAgIHRoaXMuY29sb3JCciA9IHY7XG4gICAgICB9XG4gICAgfVxuICAgIGdldCB6SW5kZXgoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUuekluZGV4O1xuICAgIH1cbiAgICBzZXQgekluZGV4KHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLnpJbmRleCA9IHY7XG4gICAgfVxuICAgIGdldCBmb3JjZVpJbmRleENvbnRleHQoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUuZm9yY2VaSW5kZXhDb250ZXh0O1xuICAgIH1cbiAgICBzZXQgZm9yY2VaSW5kZXhDb250ZXh0KHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLmZvcmNlWkluZGV4Q29udGV4dCA9IHY7XG4gICAgfVxuICAgIGdldCBjbGlwcGluZygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jbGlwcGluZztcbiAgICB9XG4gICAgc2V0IGNsaXBwaW5nKHYpIHtcbiAgICAgIHRoaXMuX19jb3JlLmNsaXBwaW5nID0gdjtcbiAgICB9XG4gICAgZ2V0IGNsaXBib3goKSB7XG4gICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY2xpcGJveDtcbiAgICB9XG4gICAgc2V0IGNsaXBib3godikge1xuICAgICAgdGhpcy5fX2NvcmUuY2xpcGJveCA9IHY7XG4gICAgfVxuICAgIGdldCB0YWdzKCkge1xuICAgICAgcmV0dXJuIHRoaXMuZ2V0VGFncygpO1xuICAgIH1cbiAgICBzZXQgdGFncyh2KSB7XG4gICAgICBpZiAoIUFycmF5LmlzQXJyYXkodikpXG4gICAgICAgIHYgPSBbdl07XG4gICAgICB0aGlzLnNldFRhZ3Modik7XG4gICAgfVxuICAgIHNldCB0KHYpIHtcbiAgICAgIHRoaXMudGFncyA9IHY7XG4gICAgfVxuICAgIGdldCBfY2hpbGRyZW4oKSB7XG4gICAgICBpZi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XplcigpICYmIHRoaXMudGV4dHVyaXplci5jb2xvcml6ZTtcbiAgICB9XG4gICAgc2V0IGNvbG9yaXplUmVzdWx0VGV4dHVyZSh2KSB7XG4gICAgICB0aGlzLnRleHR1cml6ZXIuY29sb3JpemUgPSB2O1xuICAgIH1cbiAgICBnZXRUZXh0dXJlKCkge1xuICAgICAgcmV0dXJuIHRoaXMudGV4dHVyaXplci5fZ2V0VGV4dHVyZVNvdXJjZSgpO1xuICAgIH1cbiAgICBnZXQgdGV4dHVyaXplcigpIHtcbiAgICAgIHJldHVybiB0aGlzLl9fY29yZS50ZXh0dXJpemVyO1xuICAgIH1cbiAgICBwYXRjaChzZXR0aW5ncykge1xuICAgICAgbGV0IHBhdGhzID0gT2JqZWN0LmtleXMoc2V0dGluZ3MpO1xuICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBwYXRocy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgbGV0IHBhdGggPSBwYXRoc1tpXTtcbiAgICAgICAgY29uc3QgdiA9IHNldHRpbmdzW3BhdGhdO1xuICAgICAgICBjb25zdCBmaXJzdENoYXJDb2RlID0gcGF0aC5jaGFyQ29kZUF0KDApO1xuICAgICAgICBpZiAoVXRpbHMkMS5pc1VjQ2hhcihmaXJzdENoYXJDb2RlKSkge1xuICAgICAgICAgIGNvbnN0IGNoaWxkID0gdGhpcy5nZXRCeVJlZihwYXRoKTtcbiAgICAgICAgICBpZiAoIWNoaWxkKSB7XG4gICAgICAgICAgICBpZiAodiAhPT0gdm9pZCAwKSB7XG4gICAgICAgICAgICAgIGxldCBjO1xuICAgICAgICAgICAgICBpZiAoVXRpbHMkMS5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgICAgICBjID0gdGhpcy5jaGlsZExpc3QuY3JlYXRlSXRlbSh2KTtcbiAgICAgICAgICAgICAgICBjLnBhdGNoKHYpO1xuICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzJDEuaXNPYmplY3QodikpIHtcbiAgICAgICAgICAgICAgICBjID0gdjtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoYy5pc0VsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICBjLnJlZiA9IHBhdGg7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYShjKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHYgPT09IHZvaWQgMCkge1xuICAgICAgICAgICAgICBpZiAoY2hpbGQucGFyZW50KSB7XG4gICAgICAgICAgICAgICAgY2hpbGQucGFyZW50LmNoaWxkTGlzdC5yZW1vdmUoY2hpbGQpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICAgIGNoaWxkLnBhdGNoKHYpO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh2LmlzRWxlbWVudCkge1xuICAgICAgICAgICAgICB2LnJlZiA9IHBhdGg7XG4gICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LnJlcGxhY2UodiwgY2hpbGQpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlVuZXhwZWN0ZWQgdmFsdWUgZm9yIHBhdGg6IFwiICsgcGF0aCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIEJhc2UucGF0Y2hPYmplY3RQcm9wZXJ0eSh0aGlzLCBwYXRoLCB2KTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBfdGhyb3dFcnJvcihtZXNzYWdlKSB7XG4gICAgICB0aHJvdyBuZXcgRXJyb3IodGhpcy5jb25zdHJ1Y3Rvci5uYW1lICsgXCIgKFwiICsgdGhpcy5nZXRMb2Nh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XRpYyBnZXRQcm9wZXJ0aWVzKGVsZW1lbnQpIHtcbiAgICAgIGNvbnN0IHByb3BzID0ge307XG4gICAgICBjb25zdCBsaXN0ID0gW1xuICAgICAgICBcImFscGhhXCIsXG4gICAgICAgIFwiYWN0aXZlXCIsXG4gICAgICAgIFwiYXR0YWNoZWRcIixcbiAgICAgICAgXCJib3VuZHNNYXJnaW5cIixcbiAgICAgICAgXCJjb2xvclwiLFxuICAgICAgICBcImNsaXBwaW5nXCIsXG4gICAgICAgIFwiZW5hYmxlZFwiLFxuICAgICAgICBcImhcIixcbiAgICAgICAgXCJpZFwiLFxuICAgICAgICBcImlzQ29tcG9uZW50XCIsXG4gICAgICAgIFwibW91bnRcIixcbiAgICAgICAgXCJtb3VudFlcIixcbiAgICAgICAgXCJtb3VudFhcIixcbiAgICAgICAgXCJwaXZvdFwiLFxuICAgICAgICBcInBpdm90WFwiLFxuICAgICAgICBcInBpdm90WVwiLFxuICAgICAgICBcInJlZlwiLFxuICAgICAgICBcInJlbmRlck9mZnNjcmVlblwiLFxuICAgICAgICBcInJlbmRlclRvVGV4dHVyZVwiLFxuICAgICAgICBcInNjYWxlXCIsXG4gICAgICAgIFwic2NhbGVYXCIsXG4gICAgICAgIFwic2NhbGVZXCIsXG4gICAgICAgIFwic3RhdGVcIixcbiAgICAgICAgXCJ0YWdcIixcbiAgICAgICAgXCJ2aXNpYmxlXCIsXG4gICAgICAgIFwid1wiLFxuICAgICAgICBcInhcIixcbiAgICAgICAgXCJ5XCIsXG4gICAgICAgIFwiekluZGV4XCIsXG4gICAgICAgIFwiISFmbGV4XCIsXG4gICAgICAgIFwiISFmbGV4SXRlbVwiLFxuICAgICAgICBcImhhc0ZvY3VzKClcIixcbiAgICAgICAgXCJoYXNGaW5hbEZvY3VzKClcIlxuICAgICAgXTtcbiAgICAgIGxldCBuID0gbGlzdC5sZW5ndGg7XG4gICAgICB3aGlsZSAobi0tKSB7XG4gICAgICAgIGxldCBrZXkgPSBsaXN0W25dO1x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XCJmYWxzZVwifWApO1xuICAgICAgICAgIH0gZWxzZSBpZiAoVXRpbHMkMS5pc09iamVjdCh2YWx1ZSkgJiYgdmFsdWUuX19wcm9wZXJ0eUJpbmRpbmcgPT09IHRydWUpIHtcbiAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgbG9jLnB1c2goYGVsZW1lbnQuX19iaW5kUHJvcGVydHkoc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0sICR7Y3Vyc29yfSwgXCIke2tleX1cIilgKTtcbiAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzJDEuaXNPYmplY3QodmFsdWUpIHx8IEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSBzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XWApO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHtKU09OLnN0cmluZ2lmeSh2YWx1ZSl9YCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9KTtcbiAgICB9XG4gICAgc3RhdGljIHBhcnNlUHJvcGVydHlCaW5kaW5ncyhvYmosIGNvbnRleHQsIGN1cnNvcikge1xuICAgICAgY29uc3Qgc3RvcmUgPSBjb250ZXh0LnN0b3JlO1xuICAgICAgY29uc3QgbG9jID0gY29udGV4dC5sb2M7XG4gICAgICBjb25zdCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgIGtleXMuZm9yRWFjaCgoa2V5KSA9PiB7XG4gICAgICAgIGlmIChrZXkgIT09IFwidHlwZVwiKSB7XG4gICAgICAgICAgY29uc3QgdmFsdWUgPSBvYmpba2V5XTtcbiAgICAgICAgICBpZiAoVXRpbHMkMS5pc09iamVjdEx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iAgICBzZXQgYWx0ZXJQYXNzU2lnbmFscyh2KSB7XG4gICAgICBpZiAoIVV0aWxzJDEuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJTaWduYWxzOiBzcGVjaWZ5IGFuIG9iamVjdCB3aXRoIHNpZ25hbC10by1maXJlIG1hcHBpbmdzXCIpO1xuICAgICAgfVxuICAgICAgaWYgKCF0aGlzLl9fcGFzc1NpZ25hbHMpIHtcbiAgICAgICAgdGhpcy5fX3Bhc3NTaWduYWxzID0ge307XG4gICAgICB9XG4gICAgICBmb3IgKGxldCBrZXkgaW4gdikge1xuICAgICAgICBjb25zdCBkID0gdltrZXldO1xuICAgICAgICBpZiAoZCA9PT0gdm9pZCAwKSB7XG4gICAgICAgICAgZGVsZXRlIHRoaXMuX19wYXNzU2lnbmFsc1trZXldO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRoaXMuX19wYXNzU2lnbmFsc1trZXldID0gdjtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBzaWduYWwoZXZlbnQsIC4uLmFyZ3MpIHtcbiAgICAgIHJldHVybiB0aGlzLl9zaWduYWwoZXZlbnQsIGFyZ3MpO1xuICAgIH1cbiAgICBfc2lnbmFsKGV2ZW50LCBhcmdzKSB7XG4gICAgICBjb25zdCBzaWduYWxQYXJlbnQgPSB0aGlzLl9nZXRQYXJlbnRTaWduYWxIYW5kbGVyKCk7XG4gICAgICBpZiAoc2lnbmFsUGFyZW50KSB7XG4gICAgICAgIGlmICh0aGlzLl9fc2lnbmFscykge1xuICAgICAgICAgIGxldCBmaXJlRXZlbnQgPSB0aGlzLl9fc2lnbmFsc1tldmVudF07XG4gICAgICAgICAgaWYgKGZpcmVFdmVudCA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGZpcmVFdmVudCkge1xuICAgICAgICAgICAgaWY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AgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiSW52YWxpZCB0eXBlIHNwZWNpZmllZCBmb3IgR0xfUkdCQSBmb3JtYXRcIik7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSBpZiAoZm10ID09PSBnbC5SR0IpIHtcbiAgICAgICAgc3dpdGNoICh0eXBlKSB7XG4gICAgICAgICAgY2FzZSBnbC5VTlNJR05FRF9CWVRFOlxuICAgICAgICAgICAgcmV0dXJuIDM7XG4gICAgICAgICAgY2FzZSBnbC5VTlNJR05FRF9CWVRFXzVfNl81OlxuICAgICAgICAgICAgcmV0dXJuIDI7XG4gICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkludmFsaWQgdHlwZSBzcGVjaWZpZWQgZm9yIEdMX1JHQiBmb3JtYXRcIik7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcIkludmFsaWQgZm9ybWF0IHNwZWNpZmllZCBpbiBjYWxsIHRvIF9nZXRCeXRlc1BlclBpeGVsKClcIik7XG4gICAgICB9XG4gICAgfVxuICAgIHVwbG9hZFRleHR1cmVTb3VyY2UodGV4dHVyZVNvdXJjZSwgb3B0aW9ucykge1xuICAgICAgY29uc3QgZ2wgPSB0aGlzLnN0YWdlLmdsO1xuICAgICAgY29uc3Qgc291cmNlID0gb3B0aW9ucy5zb3VyY2U7XG4gICAgICBsZXQgY29tcHJlc3NlZCA9IGZhbHNlO1xuICAgICAgaWYgKG9wdGlvbnMucmVuZGVySW5mbykge1xuICAgICAgICBjb21wcmVzc2VkID0gb3B0aW9ucy5yZW5kZXJJbmZvLmNvbXByZXNzZWQgfHwgZmFsc2U7XG4gICAgICB9XG4gICAgICBjb25zdCBmb3JtYXQgPSB7XG4gICAgICAgIHByZW11bHRpcGx5QWxwaGE6IHRydWUsXG4gICAgICAgIGhhc0FscGhhOiB0cnVlXG4gICAgICB9O1xuICAgICA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HMsIGluZGV4KSB7XG4gICAgICBsZXQgb2Zmc2V0ID0gaW5kZXggKiAyMDtcbiAgICAgIGNvbnN0IGVsZW1lbnRDb3JlID0gcXVhZHMucXVhZEVsZW1lbnRzW2luZGV4XTtcbiAgICAgIGxldCByID0gZWxlbWVudENvcmUuX3JlbmRlckNvbnRleHQ7XG4gICAgICBsZXQgZmxvYXRzID0gcmVuZGVyU3RhdGUucXVhZHMuZmxvYXRzO1xuICAgICAgbGV0IHVpbnRzID0gcmVuZGVyU3RhdGUucXVhZHMudWludHM7XG4gICAgICBjb25zdCBtY2EgPSBTdGFnZVV0aWxzLm1lcmdlQ29sb3JBbHBoYTtcbiAgICAgIGlmIChyLnRiICE9PSAwIHx8IHIudGMgIT09IDApIHtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHg7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHk7XG4gICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVbCwgci5hbHBoYSk7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4ICsgZWxlbWVudENvcmUuX3cgKiByLnRhO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weSArIGVsZW1lbnRDb3JlLl93ICogci50YztcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx5O1xuICAgICAgICB1aW50c1tvZmZzZXQrK10gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yVXIsIHIuYWxwaGEpO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weCArIGVsZW1lbnRDb3JlLl93ICogci50YSArIGVsZW1lbnRDb3JlLl9oICogci50YjtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHkgKyBlbGVtZW50Q29yZS5fdyAqIHIudGMgKyBlbGVtZW50Q29yZS5faCAqIHIudGQ7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ4O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvckJyLCByLmFscGhhKTtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHggKyBlbGVtZW50Q29yZS5faCAqIHIudGI7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icnk7XG4gICAgICAgIHVpbnRzW29mZnNldF0gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yQmwsIHIuYWxwaGEpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgbGV0IGN4ID0gci5weCArIGVsZW1lbnRDb3JlLl93ICogci50YTtcbiAgICAgICAgbGV0IGN5ID0gci5weSArIGVsZW1lbnRDb3JlLl9oICogci50ZDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHg7XG4gICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5O1xuICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseDtcbiAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHk7XG4gICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1j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PSB7IG9wZXJhdGlvbiwgdGFyZ2V0LCBpbmRleDogaSwgcmVjdCB9O1xuICAgICAgICBpZiAocmVjdCkge1xuICAgICAgICAgIGlmICh3aGl0ZSkge1xuICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IFwid2hpdGVcIjtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fc2V0Q29sb3JHcmFkaWVudChjdHgsIHZjKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgY3R4Lmdsb2JhbEFscGhhID0gcmMuYWxwaGE7XG4gICAgICAgICAgdGhpcy5fYmVmb3JlRHJhd0VsKGluZm8pO1xuICAgICAgICAgIGN0eC5maWxsUmVjdCgwLCAwLCB2Yy53LCB2Yy5oKTtcbiAgICAgICAgICB0aGlzLl9hZnRlckRyYXdFbChpbmZvKTtcbiAgICAgICAgICBjdHguZ2xvYmFsQWxwaGEgPSAxO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHJjLmFscGhhO1xuICAgICAgICAgIHRoaXMuX2JlZm9yZURyYXdFbChpbmZvKTtcbiAgICAgICAgICBjb25zdCBzb3VyY2VYID0gc3RjID8gMCA6IHZjLl91bHggKiB0eC53O1xuICAgICAgICAgIGNvbnN0IHNvdXJjZVkgPSBzdGMgPyAwIDogdmMuX3VseSAqIHR4Lmg7XG4gICAgICAgICAgY29uc3Qgc291cmNlVyA9IChzdGMgPyAxIDogdmMuX2JyeCAtIHZjLl91bHgpICogdHgudztcbiAgICAgICAgICBjb25zdCBzb3VyY2VIID0gKHN0YyA/IDEgOiB2Yy5fYnJ5IC0gdmMuX3VseSkgKiB0eC5oO1xuICAgICAgICAgIGxldCBjb2xvcml6ZSA9ICF3aGl0ZTtcbiAgICAgICAgICBpZiAoY29sb3JpemUpIHtcbiAgICAgICAgICAgIGxldCBjb2xvciA9IHZjLl9jb2xvclVsO1xuICAgICAgICAgICAgaWYgKHZjLl9jb2xvcl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ICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgc291cmNlOiBpbWFnZUJpdG1hcCxcbiAgICAgICAgICAgIHJlbmRlckluZm86IHsgc3JjLCBjb21wcmVzc2VkOiBmYWxzZSB9LFxuICAgICAgICAgICAgaGFzQWxwaGE6IGhhc0FscGhhQ2hhbm5lbCxcbiAgICAgICAgICAgIHByZW11bHRpcGx5QWxwaGE6IHRydWVcbiAgICAgICAgICB9KTtcbiAgICAgICAgfTtcbiAgICAgICAgY2FuY2VsQ2IgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICBpbWFnZS5jYW5jZWwoKTtcbiAgICAgICAgfTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGxldCBpbWFnZSA9IG5ldyBJbWFnZSgpO1xuICAgICAgICBpZiAoIShzcmMuc3Vic3RyKDAsIDUpID09IFwiZGF0YTpcIikgJiYgIVV0aWxzJDEuaXNQUzQpIHtcbiAgICAgICAgICBpbWFnZS5jcm9zc09yaWdpbiA9IFwiQW5vbnltb3VzXCI7XG4gICAgICAgIH1cbiAgICAgICAgaW1hZ2Uub25lcnJvciA9IGZ1bmN0aW9uKGVycikge1xuICAgICAgICAgIGlmIChpbWFnZS5zcmMpIHtcbiAgICAgICAgICAgIHJldHVybiBjYihcIkltYWdlIGxvYWQgZXJyb3JcIik7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICBpbWFnZS5vbmxvYWQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICBjYihudWxsLCB7XG4gICAgICAgICAgICBzb3VyY2U6IGltYWdlLFxuICAgICAgICAgICAgcmVuZGVySW5mbzogeyBzcmMsIGNvbXByZXNzZWQ6IGZhbHNlIH0sXG4gICAgICAgICAgICBoYXNBbHBoYTogaXNQbmcgfHwgaGFzQWxwaGFcbiAgICAgICAgICB9KTtcbiAgICAgICAgfTtcbiAgICAgICAgaW1hZ2Uuc3JjID0gc3JjO1xuICAgICAgICBjYW5jZWxDYiA9IGZ1bmN0a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PSBbXG4gICAgICAgICAgICAgICAgICBkICogKG5jWzBdIC0gcGNbMF0pLFxuICAgICAgICAgICAgICAgICAgZCAqIChuY1sxXSAtIHBjWzFdKSxcbiAgICAgICAgICAgICAgICAgIGQgKiAobmNbMl0gLSBwY1syXSksXG4gICAgICAgICAgICAgICAgICBkICogKG5jWzNdIC0gcGNbM10pXG4gICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gKG5pLmx2IC0gcGkubHYpIC8gKG5pLnAgLSBwaS5wKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgZm9yIChpID0gMDsgaSA8IG4gLSAxOyBpKyspIHtcbiAgICAgICAgaWYgKCFpdGVtc1tpXS5mKSB7XG4gICAgICAgICAgbGV0IGxhc3QgPSBpID09PSBuIC0gMTtcbiAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KFwidmVcIikpIHtcbiAgICAgICAgICAgIGl0ZW1zW2ldLnZlID0gbGFzdCA/IGl0ZW1zW2ldLmx2IDogaXRlbXNbaSArIDFdLmx2O1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoVXRpbHMkMS5pc051bWJlcihpdGVtc1tpXS52KSAmJiBVdGlscyQxLmlzTnVtYmVyKGl0ZW1zW2ldLmx2KSkge1xuICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eShcInNtZVwiKSkge1xuICAgICAgICAgICAgICBpdGVtc1tpXS5zbWUgPSBsYXN0ID8gZGVmYXVsdFNtb290aG5lc3MgOiBpdGVtc1tpICsgMV0uc207XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KFwic2VcIikpIHtcbiAgICAgICAgICAgICAgaXRlbXNbaV0uc2U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FxuICAgICAgICBNdWx0aVNwbGluZS5nZXRTcGxpbmVIZWxwZXJzKGN2MVszXSwgY3YyWzNdLCBvMSwgaTIsIHMxWzNdLCBzMlszXSlcbiAgICAgIF07XG4gICAgICBpZiAoIWhlbHBlcnNbMF0pIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHApIHtcbiAgICAgICAgICBpZiAocCA9PT0gMClcbiAgICAgICAgICAgIHJldHVybiB2MTtcbiAgICAgICAgICBpZiAocCA9PT0gMSlcbiAgICAgICAgICAgIHJldHVybiB2MjtcbiAgICAgICAgICByZXR1cm4gTXVsdGlTcGxpbmUubWVyZ2VDb2xvcnModjIsIHYxLCBwKTtcbiAgICAgICAgfTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbihwKSB7XG4gICAgICAgICAgaWYgKHAgPT09IDApXG4gICAgICAgICAgICByZXR1cm4gdjE7XG4gICAgICAgICAgaWYgKHAgPT09IDEpXG4gICAgICAgICAgICByZXR1cm4gdjI7XG4gICAgICAgICAgcmV0dXJuIE11bHRpU3BsaW5lLmdldEFyZ2JOdW1iZXIoW1xuICAgICAgICAgICAgTWF0aC5taW4oMjU1LCBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVyc1swXSwgcCkpLFxuICAgICAgICAgICAgTWF0aC5taW4oMjU1LCBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVyc1sxXSwgcCkpLFxuICAgICAgICAgICAgTWF0aC5taW4oMjU1LCBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVyc1syXSwgcCkpLFxuICAgICAgICAgICAgTWF0aC5taW4oMjU1LCBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVyc1szXSwgcCkpXG4gICAgICAgICAgXSk7XG4gICAgICAgIH07XG4gICAgICB9XG4gICAgfVxuICAgIHN0YXRpYyBnZXRTcGxpbmVIZWxwZX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LCBkeDtcbiAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICBjYnggPSB0ICogKHQgKiAodCAqIHhhICsgeGIpICsgeGMpO1xuICAgICAgICBkeCA9IHAgLSBjYng7XG4gICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpICsgeWQ7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGNieGQgPSB0ICogKHQgKiAoMyAqIHhhKSArIDIgKiB4YikgKyB4YztcbiAgICAgICAgaWYgKGNieGQgPiAxZS0xMCAmJiBjYnhkIDwgMWUtMTApIHtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICB0ICs9IGR4IC8gY2J4ZDtcbiAgICAgIH1cbiAgICAgIGxldCBtaW5UID0gMDtcbiAgICAgIGxldCBtYXhUID0gMTtcbiAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICB0ID0gMC41ICogKG1pblQgKyBtYXhUKTtcbiAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcbiAgICAgICAgZHggPSBwIC0gY2J4O1xuICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKSArIHlkO1xuICAgICAgICB9XG4gICAgICAgIGlmIChkeCA8IDApIHtcbiAgICAgICAgICBtYXhUID0gdDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBtaW5UID0gdDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHQ7XG4gICAgfVxuICAgIHN0YXRpYyBtZXJnZUNvbG9ycyhjMSwgYzIsIHApIHtcbiAgICAgIGxldCByMSA9IChjMSAvIDY1NTM2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uICAgICAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gZHVyYXRpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0aGlzLl9wID49IDIpIHtcbiAgICAgICAgICAgIHRoaXMuX3AgPSAyO1xuICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICB0aGlzLmVtaXQoXCJzdG9wRmluaXNoXCIpO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmVtaXQoXCJwcm9ncmVzc1wiLCB0aGlzLl9wKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSBpZiAodGhpcy5zZXR0aW5ncy5zdG9wTWV0aG9kID09IEFuaW1hdGlvblNldHRpbmdzLlNUT1BfTUVUSE9EUy5GT1JXQVJEKSB7XG4gICAgICAgIGlmICh0aGlzLl9wIDwgMSkge1xuICAgICAgICAgIGlmICh0aGlzLnNldHRpbmdzLmR1cmF0aW9uID09IDApIHtcbiAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gdGhpcy5zZXR0aW5ncy5kdXJhdGlvbjtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHRoaXMuX3AgPj0gMSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuRk9SV0FSRCkge1xuICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICAgIHRoaXMuZW1pdChcInN0b3BGaW5pc2hcIik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBpZiAodGhpcy5fcmVwZWF0c0xlZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmVwZWF0c0xlZnQtLTtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoXCJyZXBlYXRcIiwgdGhpcy5fcmVwZWF0c0xlZnQpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgICAgIHRoaXMuZW1pdChcInN0b3BGaW5pc2hcIik7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5lbWl0KFwicHJvZ3Jlc3NcIiwgdGhpcy5fcCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIF9wcm9ncmVzc1N0b3BUcmFuc2l0aW9uKGR0KSB7XG4gICAgICBpZiAodGhpcy5fc3RvcFAgPCAxKSB7XG4gICAgICAgIGlmICh0aGlzLl9zdG9wRGVsYXlMZWZ0ID4gMCkge1xuICAgICAgICAgIHRoaXMuX3N0b3BEZWxheUxlZnQgLT0gZHQ7XG4gICAgICAgICAgaWYgKHRoaXMuX3N0b3BEZWxheUxlZnQgPCAwKSB7XG4gICAgICAgICAgICBkdCA9IC10aGlzLl9zdG9wRGVsYXlMZWZ0O1xuICAgICAgICAgICAgdGhpcy5fc3RvcERlbGF5TGVmdCA9IDA7XG4gICAgICAgICAgICB0aGlzLmVtaXQoXCJkZWxheUVuZFwiKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBjb25zdCBkdXJhdGlvbiA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gICB9XG4gICAgX19nZXRGb2N1c1BhdGgoKSB7XG4gICAgICBjb25zdCBwYXRoID0gW3RoaXNdO1xuICAgICAgbGV0IGN1cnJlbnQgPSB0aGlzO1xuICAgICAgZG8ge1xuICAgICAgICBjb25zdCBuZXh0Rm9jdXMgPSBjdXJyZW50Ll9nZXRGb2N1c2VkKCk7XG4gICAgICAgIGlmICghbmV4dEZvY3VzIHx8IG5leHRGb2N1cyA9PT0gY3VycmVudCkge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGxldCBwdHIgPSBuZXh0Rm9jdXMuY3BhcmVudDtcbiAgICAgICAgaWYgKHB0ciA9PT0gY3VycmVudCkge1xuICAgICAgICAgIHBhdGgucHVzaChuZXh0Rm9jdXMpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnN0IG5ld1BhcnRzID0gW25leHRGb2N1c107XG4gICAgICAgICAgZG8ge1xuICAgICAgICAgICAgaWYgKCFwdHIpIHtcbiAgICAgICAgICAgICAgY3VycmVudC5fdGhyb3dFcnJvcihcIlJldHVybiB2YWx1ZSBmb3IgX2dldEZvY3VzZWQgbXVzdCBiZSBhbiBhdHRhY2hlZCBkZXNjZW5kYW50IGNvbXBvbmVudCBidXQgaXRzICdcIiArIG5leHRGb2N1cy5nZXRMb2NhdGlvblN0cmluZygpICsgXCInXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbmV3UGFydHMucHVzaChwdHIpO1xuICAgICAgICAgICAgcHRyID0gcHRyLmNwYXJlbnQ7XG4gICAgICAgICAgfSB3aGlsZSAocHRyICE9PSBjdXJyZW50KTtcbiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IG5ld1BhcnRzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgcGF0aC5wdXNoKG5ld1BhcnRzW24gLSBpIC0gMV0pO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBjdXJyZW50ID0g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vbihmKSAmJiBmLl9fbWY7XG4gICAgfVxuICAgIHN0YXRpYyBtZihmKSB7XG4gICAgICBmLl9fbWYgPSB0cnVlO1xuICAgICAgcmV0dXJuIGY7XG4gICAgfVxuICAgIHN0YXRpYyBtZXJnZShhLCBiKSB7XG4gICAgICBjb25zdCBha3MgPSBPYmplY3Qua2V5cyhhKTtcbiAgICAgIGNvbnN0IGJrcyA9IE9iamVjdC5rZXlzKGIpO1xuICAgICAgaWYgKCFia3MubGVuZ3RoKSB7XG4gICAgICAgIHJldHVybiBhO1xuICAgICAgfVxuICAgICAgY29uc3QgYWkgPSB7fTtcbiAgICAgIGNvbnN0IGJpID0ge307XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGJrcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgY29uc3Qga2V5ID0gYmtzW2ldO1xuICAgICAgICBhaVtrZXldID0gLTE7XG4gICAgICAgIGJpW2tleV0gPSBpO1xuICAgICAgfVxuICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBha3MubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgIGNvbnN0IGtleSA9IGFrc1tpXTtcbiAgICAgICAgYWlba2V5XSA9IGk7XG4gICAgICAgIGlmIChiaVtrZXldID09PSB2b2lkIDApIHtcbiAgICAgICAgICBiaVtrZXldID0gLTE7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGNvbnN0IGFrc2wgPSBha3MubGVuZ3RoO1xuICAgICAgY29uc3QgcmVzdWx0ID0ge307XG4gICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGJrcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgY29uc3Qga2V5ID0gYmtzW2ldO1xuICAgICAgICBjb25zdCBhSW5kZXggPSBhaVtrZXldO1xuICAgICAgICBsZXQgY3VySW5kZXgyID0gYUluZGV4O1xuICAgICAgICB3aGlsZSAoLS1jdXJJbmRleDIgPj0gMCkge1xuICAgICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXgyXTtcbiAgICAgICAgICBpZiAoYmlbYWtleV0gIT09IC0xKSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgd2hpbGUgKCsrY3VySW5kZXgyIDwgYUluZGV4KSB7XG4gICAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleDJdO1xuICAgICAgICAgIHJlc3VsdFtha2V5XSA9IGFbYWtleV07XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgYnYgPSBiW2tleV07XG4gICAgICAgIGNvbnN0IGF2ID0gYVtrZXldO1xuICAgICAgICBsZXQgcjtcbiAgICAgICAgaWYgKHRoaXMuaXNNZihidikpIHtcbiAgICAgICAgICByID0gYnYoYXYpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmICghVXRpbHMkMS5pc09iamVjdExpdGVyYWwoYXYpIHx8ICFVdGlscyQxLmlzT2JqZWN0TGl0ZXJhbChidikpIHtcbiAgICAgICAgICAgIHIgPSBidjtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgciA9IE9iak1lcmdlci5tZXJnZShhdiwgYnYpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAociAhPT0gdm9pZCAwKSB7XG4gICAgICAgICAgcmVzdWx0W2tleV0gPSByO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBsZXQgY3VySW5kZXggPSBha3NsO1xuICAgICAgd2hpbGUgKC0tY3VySW5kZXggPj0gMCkge1xuICAgICAgICBjb25zdCBha2V5ID0gYWtzW2N1ckluZGV4XTtcbiAgICAgICAgaWYgKGJpW2FrZXldICE9PSAtMSkge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICB3aGlsZSAoKytjdXJJbmRleCA8IGFrc2wpIHtcbiAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdX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KCk7XG4gICAgICAgIHBhcmVudC5hZGQoaXRlbSk7XG4gICAgICAgIHBhcmVudC52aXNpYmxlID0gZmFsc2U7XG4gICAgICAgIHJldHVybiBwYXJlbnQ7XG4gICAgICB9O1xuICAgICAgc3VwZXIobGlzdC5fd3JhcHBlci5fY2hpbGRyZW4sIHdyYXApO1xuICAgICAgdGhpcy5saXN0ID0gbGlzdDtcbiAgICB9XG4gICAgb25BZGQoaXRlbSwgaW5kZXgpIHtcbiAgICAgIHN1cGVyLm9uQWRkKGl0ZW0sIGluZGV4KTtcbiAgICAgIHRoaXMuY2hlY2tTdGFydGVkKGluZGV4KTtcbiAgICB9XG4gICAgY2hlY2tTdGFydGVkKGluZGV4KSB7XG4gICAgICB0aGlzLmxpc3QuX3JlbG9hZFZpc2libGVFbGVtZW50cyA9IHRydWU7XG4gICAgICBpZiAoIXRoaXMubGlzdC5fc3RhcnRlZCkge1xuICAgICAgICB0aGlzLmxpc3Quc3RhcnQoKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGlmICh0aGlzLmxpc3QubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgdGhpcy5saXN0LnNldEluZGV4KDAsIHRydWUsIHRydWUpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmICh0aGlzLmxpc3QuX2luZGV4ID49IHRoaXMubGlzdC5sZW5ndGgpIHtcbiAgICAgICAgICAgIHRoaXMubGlzdC5zZXRJbmRleCgwKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5saXN0LnVwZGF0ZSgpO1xuICAgICAgfVxuICAgIH1cbiAgICBvblJlbW92ZShpdGVtLCBpbmRleCkge1xuICAgICAgc3VwZXIub25SZW1vdmUoaXRlbSwgaW5kZXgpO1xuICAgICAgbGV0IHJpID0gdGhpcy5saXN0LnJlYWxJbmRleDtcbiAgICAgIGlmIChyaSA9PT0gaW5kZXgpIHtcbiAgICAgICAgaWYgKHJpID09PSB0aGlzLmxp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AsIGZvcmNlKSB7XG4gICAgICBjb25zdCBjb250ZW50ID0gY29udGVudFdyYXAuY2hpbGRyZW5bMF07XG4gICAgICBsZXQgdyA9IGNvbnRlbnQucmVuZGVyV2lkdGg7XG4gICAgICBsZXQgaCA9IGNvbnRlbnQucmVuZGVySGVpZ2h0O1xuICAgICAgaWYgKHcgIT09IGNvbnRlbnRXcmFwLncgfHwgaCAhPT0gY29udGVudFdyYXAuaCB8fCBmb3JjZSkge1xuICAgICAgICBjb250ZW50V3JhcC53ID0gdztcbiAgICAgICAgY29udGVudFdyYXAuaCA9IGg7XG4gICAgICAgIGNvbnN0IHNjYWxlcnMgPSBjb250ZW50V3JhcC5wYXJlbnQudGFnKFwiU2NhbGVcIikuY2hpbGRyZW47XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gc2NhbGVycy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICB3ID0gdyAqIDAuNTtcbiAgICAgICAgICBoID0gaCAqIDAuNTtcbiAgICAgICAgICBzY2FsZXJzW2ldLncgPSB3O1xuICAgICAgICAgIHNjYWxlcnNbaV0uaCA9IGg7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgZ2V0IF9zaWduYWxQcm94eSgpIHtcbiAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgfVxuICBjbGFzcyBCb3JkZXJDb21wb25lbnQgZXh0ZW5kcyBDb21wb25lbnQge1xuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICByZXR1cm4ge1xuICAgICAgICBDb250ZW50OiB7fSxcbiAgICAgICAgQm9yZGVyczoge1xuICAgICAgICAgIFRvcDogeyByZWN0OiB0cnVlLCB2aXNpYmxlOiBmYWxzZSwgbW91bnRZOiAxIH0sXG4gICAgICAgICAgUmlnaHQ6IHsgcmVjdDogdHJ1ZSwgdmlzaWJsZTogZmFsc2UgfSxcbiAgICAgICAgICBCb3R0b206IHsgcmVjdDogdHJ1ZSwgd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9zMSAtIHBvczI7XG4gICAgICAgICAgICBjID0gZG90KHBvczIsIGQpIC8gZG90KGQsIGQpO1xuICAgICAgICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKGMsIDAuMCwgMS4wKSk7XG4gICAgICAgICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcbiAgICAgICAgfVxuICAgICAgICBcbiAgICAgICAgaWYoZmFkZVsyXSA+IDAuMCkge1xuICAgICAgICAgICAgdmVjMiBwb3MxID0gdmVjMih2VGV4dHVyZUNvb3JkLngsIHBvaW50LnkgLSByZXNvbHV0aW9uLnkgLSBmYWRlWzJdKTtcbiAgICAgICAgICAgIHZlYzIgcG9zMiA9IHZlYzIodlRleHR1cmVDb29yZC54LCBwb2ludC55IC0gcmVzb2x1dGlvbi55KTtcbiAgICAgICAgICAgIGQgPSBwb3MxIC0gcG9zMjtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMiwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzNdID4gMC4wKSB7XG4gICAgICAgICAgICBwb3MxID0gdmVjMihwb2ludC54LCBwb2ludC55KTtcbiAgICAgICAgICAgIHBvczIgPSB2ZWMyKHBvaW50LnggKyBmYWRlWzNdLCBwb2ludC55KTtcbiAgICAgICAgICAgIGQgPSBwb3MyIC0gcG9zMTtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMSwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlY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gIHVuaWZvcm0gZmxvYXQgejtcbiAgICB1bmlmb3JtIHZlYzMgcGl2b3Q7XG4gICAgdW5pZm9ybSB2ZWMzIHJvdDtcbiAgICB2YXJ5aW5nIHZlYzMgcG9zO1xuXG4gICAgdm9pZCBtYWluKHZvaWQpIHtcbiAgICAgICAgcG9zID0gdmVjMyhhVmVydGV4UG9zaXRpb24ueHksIHopO1xuICAgICAgICBcbiAgICAgICAgcG9zIC09IHBpdm90O1xuICAgICAgICBcbiAgICAgICAgLy8gVW5kbyBYWSByb3RhdGlvblxuICAgICAgICBtYXQyIGlSb3RYeSA9IG1hdDIoIGNvcyhyb3QueiksIHNpbihyb3QueiksIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgLXNpbihyb3QueiksIGNvcyhyb3QueikpO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3MueHk7XG4gICAgICAgIFxuICAgICAgICAvLyBQZXJmb3JtIDNkIHJvdGF0aW9uc1xuICAgICAgICBnbF9Qb3NpdGlvbi54ID0gY29zKHJvdC54KSAqIHBvcy54IC0gc2luKHJvdC54KSAqIHBvcy56O1xuICAgICAgICBnbF9Qb3NpdGlvbi55ID0gcG9zLnk7XG4gICAgICAgIGdsX1Bvc2l0aW9uLnogPSBzaW4ocm90LngpICogcG9zLnggKyBjb3Mocm90LngpICogcG9zLno7XG4gICAgICAgIFxuICAgICAgICBwb3MueCA9IGdsX1Bvc2l0aW9uLng7XG4gICAgICAgIHBvcy55ID0gY29zKHJvdC55KSAqIGdsX1Bvc2l0aW9uLnkgLSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24uejtcbiAgICAgICAgcG9zLnogPSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24ueSArIGNvcyhyb3QueSkgKiBnbF9Qb3NpdGlvbi56O1xuICAgICAgICBcbiAgICAgICAgLy8gUmVkbyBYWSByb3RhdGlvblxuICAgICAgICBpUm90WHlbMF1bMV0gPSAtaVJvdFh5WzBdWzFdO1xuICAgICA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cbiAgICAgIHRoaXMuX3JhZGl1cyA9IDA7XG4gICAgICB0aGlzLl9tYWduaWZpY2F0aW9uID0gMC42O1xuICAgIH1cbiAgICBnZXQgeCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl94O1xuICAgIH1cbiAgICBzZXQgeCh2KSB7XG4gICAgICB0aGlzLl94ID0gdjtcbiAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuICAgIGdldCB5KCkge1xuICAgICAgcmV0dXJuIHRoaXMuX3k7XG4gICAgfVxuICAgIHNldCB5KHYpIHtcbiAgICAgIHRoaXMuX3kgPSB2O1xuICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG4gICAgZ2V0IHcoKSB7XG4gICAgICByZXR1cm4gdGhpcy5fdztcbiAgICB9XG4gICAgc2V0IHcodikge1xuICAgICAgdGhpcy5fdyA9IHY7XG4gICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cbiAgICBnZXQgaCgpIHtcbiAgICAgIHJldHVybiB0aGlzLl9oO1xuICAgIH1cbiAgICBzZXQgaCh2KSB7XG4gICAgICB0aGlzLl9oID0gdjtcbiAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuICAgIGdldCBtYWduaWZpY2F0aW9uKCkge1xuICAgICAgcmV0dXJuIHRoaXMuX21hZ25pZmljYXRpb247XG4gICAgfVxuICAgIHNldCBtYWduaWZpY2F0aW9uKHYpIHtcbiAgICAgIHRoaXMuX21hZ25pZmljYXRpb24gPSB2O1xuICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG4gICAgZ2V0IHJhZGl1cygpIHtcbiAgICAgIHJldHVybiB0aGlzLl9yYWRpdXM7XG4gICAgfVxuICAgIHNldCByYWRpdXModikge1xuICAgICAgdGhpcy5fcmFkaXVzID0gdjtcbiAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuICAgIHNldHVwVW5pZm9ybXMob3BlcmF0aW9uKSB7XG4gICAgICBzdXBlci5zZXR1cFV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ZW50TGlzdGVuZXJzW25hbWVdLnB1c2gobGlzdGVuZXIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgb25jZShuYW1lLCBsaXN0ZW5lcikge1xuICAgICAgICBjb25zdCB3cmFwcGVyID0gKGFyZzEsIGFyZzIsIGFyZzMpID0+IHtcbiAgICAgICAgICAgIGxpc3RlbmVyKGFyZzEsIGFyZzIsIGFyZzMpO1xuICAgICAgICAgICAgdGhpcy5vZmYobmFtZSwgd3JhcHBlcik7XG4gICAgICAgIH1cbiAgICAgICAgd3JhcHBlci5fX29yaWdpbmFsRnVuYyA9IGxpc3RlbmVyO1xuICAgICAgICB0aGlzLm9uKG5hbWUsIHdyYXBwZXIpO1xuICAgIH1cblxuICAgIGhhcyhuYW1lLCBsaXN0ZW5lcikge1xuICAgICAgICBpZiAodGhpcy5faGFzRXZlbnRMaXN0ZW5lcnMpIHtcbiAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdO1xuICAgICAgICAgICAgaWYgKGN1cnJlbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gRXZlbnRFbWl0dGVyLmNvbWJpbmVyKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpc3RlbmVycyA9IHRoaXMuX2V2ZW50TGlzdGVuZXJzW25hbWVdO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGwgb2YgbGlzdGVuZXJzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobCA9PT0gbGlzdGVuZXIgfHwgbC5fX29yaWdpbmFsRnVuYyA9PSBsaXN0ZW5lcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdID09PSBsaXN0ZW5lciB8fCB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdLl9fb3JpZ2luYWxGdW5jID09PSBsaXN0ZW5lcikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIG9mZihuYW1lLCBsaXN0ZW5lcikge1xuICAgICAgICBpZiAodGhpcy5faGFzRXZlbnRMaXN0ZW5lcnMpIHtcbiAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdO1xuICAgICAgICAgICAgaWYgKGN1cnJlbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gRXZlbnRFbWl0dGVyLmNvbWJpbmVyKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpc3RlbmVycyA9IHRoaXMuX2V2ZW50TGlzdGVuZXJzW25hbWVdO1xuICAgICAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBsaXN0ZW5lcnMuaW5kZXhPZihsaXN0ZW5lcik7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcnMuc3BsaWNlKGluZGV4LCAxKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpbmRleCA9IGxpc3RlbmVycy5tYXAoKGwpID0+IGwuX19vcmlnaW5hbEZ1bmMpLmluZGV4T2YobGlzdGVuZXIpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPj0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLnNwbGljZShpbmRleCwgMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGxpc3RlbmVycy5sZW5ndGggPT09IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV0gPSBsaXN0ZW5lcnNbMF07XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9ldmVudExpc3RlbmVyc1tuYW1lXSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXSA9PT0gbGlzdGVuZXIgfHwgdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXS5fX29yaWdpbmFsRnVuYyA9PT0gbGlzdGVuZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXZlbnRGdW5jdGlvbltuYW1lXSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZW1vdmVMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikge1xuICAgICAgICB0aGlzLm9mZihuYW1lLCBsaXN0ZW5lcik7XG4gICAgfVxuXG4gICAgZW1pdChuYW1lLCBhcmcxLCBhcmcyLCBhcmczKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNFdmVudExpc3RlbmVycykge1xuICAgICAgICAgICAgY29uc3QgZnVuYyA9IHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV07XG4gICAgICAgICAgICBpZiAoZnVuYykge1xuICAgICAgICAgICAgICAgIGlmIChmdW5jID09PSBFdmVudEVtaXR0ZXIuY29tYmluZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgZnVuYyh0aGlzLCBuYW1lLCBhcmcxLCBhcmcyLCBhcmczKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBmdW5jKGFyZzEsIGFyZzIsIGFyZzMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGxpc3RlbmVyQ291bnQobmFtZSkge1xuICAgICAgICBpZiAodGhpcy5faGFzRXZlbnRMaXN0ZW5lcnMpIHtcbiAgICAgICAgICAgIGNvbnN0IGZ1bmMgPSB0aGlzLl9ldmVudEZ1bmN0aW9uW25hbWVdO1xuICAgICAgICAgICAgaWYgKGZ1bmMpIHtcbiAgICAgICAgICAgICAgICBpZiAoZnVuYyA9PT0gRXZlbnRFbWl0dGVyLmNvbWJpbmVyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9ldmVudExpc3RlbmVyc1tuYW1lXS5sZW5ndGg7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiAwO1xuICAgIH1cblxuICAgIHJlbW92ZUFsbExpc3RlbmVycyhuYW1lKSB7XG4gICAgICAgIGlmICh0aGlzLl9oYXNFdmVudExpc3RlbmVycykge1xuICAgICAgICAgICAgZGVsZXRlIHRoaXMuX2V2ZW50RnVuY3Rpb25bbmFtZV07XG4gICAgICAgICAgICBkZWxldGUgdGhpcy5fZXZlbnRMaXN0ZW5lcnNbbmFtZV07XG4gICAgICAgIH1cbiAgICB9XG5cbn1cblxuRXZlbnRFbWl0dGVyLmNvbWJpbmVyID0gZnVuY3Rpb24ob2JqZWN0LCBuYW1lLCBhcmcxLCBhcmcyLCBhcmczKSB7XG4gICAgY29uc3QgbGlzdGVuZXJzID0gb2JqZWN0Ll9ldmVudExpc3RlbmVyc1tuYW1lXTtcbiAgICBpZiAobGlzdGVuZXJzKSB7XG4gICAgICAgIC8qIEJlY2F1c2UgbGlzdGVuZXIgbWF5IGRldGFjaCBpdHNlbGYgd2hpbGUgYmVpbmcgaW52b2tl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FUy5TVE9QUElORykge1xuICAgICAgICAgICAgdGhpcy5fc3RvcFByb2dyZXNzKGR0KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9zdGF0ZSAhPSBBbmltYXRpb24uU1RBVEVTLlBMQVlJTkcpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9kZWxheUxlZnQgPiAwKSB7XG4gICAgICAgICAgICB0aGlzLl9kZWxheUxlZnQgLT0gZHQ7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9kZWxheUxlZnQgPCAwKSB7XG4gICAgICAgICAgICAgICAgZHQgPSAtdGhpcy5fZGVsYXlMZWZ0O1xuICAgICAgICAgICAgICAgIHRoaXMuX2RlbGF5TGVmdCA9IDA7XG5cbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ2RlbGF5RW5kJyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLnNldHRpbmdzLmR1cmF0aW9uID09PSAwKSB7XG4gICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnNldHRpbmdzLmR1cmF0aW9uID4gMCkge1xuICAgICAgICAgICAgdGhpcy5fcCArPSBkdCAvIHRoaXMuc2V0dGluZ3MuZHVyYXRpb247XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3AgPj0gMSkge1xuICAgICAgICAgICAgLy8gRmluaXNoZWQhO1xuICAgICAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3MucmVwZWF0ID09IC0xIHx8IHRoaXMuX3JlcGVhdHNMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXBlYXRzTGVmdCA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVwZWF0c0xlZnQtLTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fcCA9IHRoaXMuc2V0dGluZ3MucmVwZWF0T2Zmc2V0O1xuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgncHJvZ3Jlc3MnLCB0aGlzLl9wKTtcbiAgICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zZXR0aW5ncy5yZXBlYXREZWxheSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9kZWxheUxlZnQgPSB0aGlzLnNldHRpbmdzLnJlcGVhdERlbGF5O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgncmVwZWF0JywgdGhpcy5fcmVwZWF0c0xlZnQpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMTtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3Byb2dyZXNzJywgdGhpcy5fcCk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLkZJTklTSEVEO1xuICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnZmluaXNoJyk7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3MuYXV0b3N0b3ApIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdG9wKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5lbWl0KCdwcm9ncmVzcycsIHRoaXMuX3ApO1xuICAgICAgICB9XG4gICAgfVxuICAgIFxuICAgIF9zdG9wUHJvZ3Jlc3MoZHQpIHtcbiAgICAgICAgbGV0IGR1cmF0aW9uID0gdGhpcy5fZ2V0U3RvcER1cmF0aW9uKCk7XG5cbiAgICAgICAgaWYgKHRoaXMuX3N0b3BEZWxheUxlZnQgPiAwKSB7XG4gICAgICAgICAgICB0aGlzLl9zdG9wRGVsYXlMZWZ0IC09IGR0O1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fc3RvcERlbGF5TGVmdCA8IDApIHtcbiAgICAgICAgICAgICAgICBkdCA9IC10aGlzLl9zdG9wRGVsYXlMZWZ0O1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0b3BEZWxheUxlZnQgPSAwO1xuXG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdzdG9wRGVsYXlFbmQnKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLklNTUVESUFURSkge1xuICAgICAgICAgICAgdGhpcy5fc3RhdGUgPSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQ7XG4gICAgICAgICAgICB0aGlzLmVtaXQoJ3N0b3BGaW5pc2gnKTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLlJFVkVSU0UpIHtcbiAgICAgICAgICAgIGlmIChkdXJhdGlvbiA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAwO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChkdXJhdGlvbiA+IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wIC09IGR0IC8gZHVyYXRpb247XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9wIDw9IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3N0b3BGaW5pc2gnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLkZBREUpIHtcbiAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzU3RvcFRyYW5zaXRpb24oZHQpO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3BQID49IDEpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ3N0b3BGaW5pc2gnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLk9ORVRPVFdPKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fcCA8IDIpIHtcbiAgICAgICAgICAgICAgICBpZiAoZHVyYXRpb24gPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCA9IDI7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChkdXJhdGlvbiA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3AgPCAxKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gdGhpcy5zZXR0aW5ncy5kdXJhdGlvbjtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgKz0gZHQgLyBkdXJhdGlvbjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fcCA+PSAyKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAyO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdzdG9wRmluaXNoJyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdwcm9ncmVzcycsIHRoaXMuX3ApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnNldHRpbmdzLnN0b3BNZXRob2QgPT0gQW5pbWF0aW9uU2V0dGluZ3MuU1RPUF9NRVRIT0RTLkZPUldBUkQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9wIDwgMSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNldHRpbmdzLmR1cmF0aW9uID09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCArPSBkdCAvIHRoaXMuc2V0dGluZ3MuZHVyYXRpb247XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wID49IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc2V0dGluZ3Muc3RvcE1ldGhvZCA9PSBBbmltYXRpb25TZXR0aW5ncy5TVE9QX01FVEhPRFMuRk9SV0FSRCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCA9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGF0ZSA9IEFuaW1hdGlvbi5TVEFURVMuU1RPUFBFRDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnc3RvcEZpbmlzaCcpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlcGVhdHNMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcGVhdHNMZWZ0LS07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcCA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdyZXBlYXQnLCB0aGlzLl9yZXBlYXRzTGVmdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0YXRlID0gQW5pbWF0aW9uLlNUQVRFUy5TVE9QUEVEO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnc3RvcEZpbmlzaCcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWl0KCdwcm9ncmVzcycsIHRoaXMuX3ApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBcbiAgICB9XG4gICAgXG4gICAgX3Byb2dyZXNzU3RvcFRyYW5zaXRpb24oZHQpIHtcbiAgICAgICAgaWYgKHRoaXMuX3N0b3BQIDwgMSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3BEZWxheUxlZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc3RvcERlbGF5TGVmdCAtPSBkdDtcblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zdG9wRGVsYXlMZWZ0IDwgMCkge1xuICAgICAgICAgICAgICAgICAgICBkdCA9IC10aGlzLl9zdG9wRGVsYXlMZWZ0O1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9wRGVsYXlMZWZ0ID0gMDtcblxuICAgICAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ2RlbGF5RW5kJyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIFxuICAgICAgICAgICAgY29uc3QgZHVyYXRpb24gPSB0aGlzLl9nZXRTdG9wRHVyYXRpb24oKTtcblxuICAgICAgICAgICAgaWYgKGR1cmF0aW9uID09IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdG9wUCA9IDE7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0b3BQICs9IGR0IC8gZHVyYXRpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fc3RvcFAgPj0gMSkge1xuICAgICAgICAgICAgICAgIC8vIEZpbmlzaGVkITtcbiAgICAgICAgICAgICAgICB0aGlzLl9zdG9wUCA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0U3RvcER1cmF0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5zZXR0aW5ncy5zdG9wRHVyYXRpb24gfHwgdGhpcy5zZXR0aW5ncy5kdXJhdGlvbjtcbiAgICB9XG5cbiAgICBhcHBseSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3N0YXRlID09PSBBbmltYXRpb24uU1RBVEVTLlNUT1BQRUQpIHtcbiAgICAgICAgICAgIHRoaXMucmVzZXQoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxldCBmYWN0b3IgPSAxO1xuICAgICAgICAgICAgaWYgKHR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bmRlZmluZWQ7XG4gICAgfVxuXG4gICAgZ2V0UmVzZXRWYWx1ZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hhc1Jlc2V0VmFsdWUpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZXNldFZhbHVlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2l0ZW1zLmdldFZhbHVlKDApO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgYXBwbHkoZWxlbWVudCwgcCwgZmFjdG9yKSB7XG4gICAgICAgIGNvbnN0IGVsZW1lbnRzID0gdGhpcy5nZXRBbmltYXRlZEVsZW1lbnRzKGVsZW1lbnQpO1xuXG4gICAgICAgIGxldCB2ID0gdGhpcy5faXRlbXMuZ2V0VmFsdWUocCk7XG5cbiAgICAgICAgaWYgKHYgPT09IHVuZGVmaW5lZCB8fCAhZWxlbWVudHMubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoZmFjdG9yICE9PSAxKSB7XG4gICAgICAgICAgICAvLyBTdG9wIGZhY3Rvci47XG4gICAgICAgICAgICBsZXQgc3YgPSB0aGlzLmdldFJlc2V0VmFsdWUoKTtcblxuICAgICAgICAgICAgaWYgKFV0aWxzLmlzTnVtYmVyKHYpICYmIFV0aWxzLmlzTnVtYmVyKHN2KSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmhhc0NvbG9yUHJvcGVydHkoKSkge1xuICAgICAgICAgICAgICAgICAgICB2ID0gU3RhZ2VVdGlscy5tZXJnZUNvbG9ycyh2LCBzdiwgZmFjdG9yKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB2ID0gU3RhZ2VVdGlscy5tZXJnZU51bWJlcnModiwgc3YsIGZhY3Rvcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gQXBwbHkgdHJhbnNmb3JtYXRpb24gdG8gYWxsIGNvbXBvbmVudHMuO1xuICAgICAgICBjb25zdCBuID0gdGhpcy5fcHJvcFNldHRlcnMubGVuZ3RoO1xuXG4gICAgICAgIGNvbnN0IG0gPSBlbGVtZW50cy5sZW5ndGg7XG4gICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbTsgaisrKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3Byb3BTZXR0ZXJzW2ldKGVsZW1lbnRzW2pdLCB2KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICBcbiAgICBnZXRBbmltYXRlZEVsZW1lbnRzKGVsZW1lbnQpIHtcbiAgICAgICAgcmV0dXJuIGVsZW1lbnQuc2VsZWN0KHRoaXMuX3NlbGVjdG9yKTtcbiAgICB9XG5cbiAgICByZXNldChlbGVtZW50KSB7XG4gICAgICAgIGNvbnN0IGVsZW1lbnRzID0gdGhpcy5nZXRBbmltYXRlZEVsZW1lbnRzKGVsZW1lbnQpO1xuXG4gICAgICAgIGxldCB2ID0gdGhpcy5nZXRSZXNldFZhbHVlKCk7XG5cbiAgICAgICAgaWYgKHYgPT09IHVuZGVmaW5lZCB8fCAhZWxlbWVudHMubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICAvLyBBcHBseSB0cmFuc2Zvcm1hdGlvbiB0byBhbGwgY29tcG9uZW50cy5cbiAgICAgICAgY29uc3QgbiA9IHRoaXMuX3Byb3BTZXR0ZXJzLmxlbmd0aDtcblxuICAgICAgICBjb25zdCBtID0gZWxlbWVudHMubGVuZ3RoO1xuICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IG07IGorKykge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wcm9wU2V0dGVyc1tpXShlbGVtZW50c1tqXSwgdik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgXG4gICAgc2V0IHNlbGVjdG9yKHYpIHtcbiAgICAgICAgdGhpcy5fc2VsZWN0b3IgPSB2O1xuICAgIH1cblxuICAgIHNldCB0KHYpIHtcbiAgICAgICAgdGhpcy5zZWxlY3RvciA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHJlc2V0VmFsdWUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yZXNldFZhbHVlO1xuICAgIH1cbiAgICBcbiAgICBzZXQgcmVzZXRWYWx1ZSh2KSB7XG4gICAgICAgIHRoaXMuX3Jlc2V0VmFsdWUgPSB2O1xuICAgICAgICB0aGlzLl9oYXNSZXNldFZhbHVlID0gKHYgIT09IHVuZGVmaW5lZCk7XG4gICAgfVxuXG4gICAgc2V0IHJ2KHYpIHtcbiAgICAgICAgdGhpcy5yZXNldFZhbHVlID0gdjtcbiAgICB9XG5cbiAgICBzZXQgdmFsdWUodikge1xuICAgICAgICB0aGlzLl9pdGVtcy5wYXJzZSh0aGlzLmhhc0NvbG9yUHJvcGVydHkoKSwgdik7XG4gICAgfVxuXG4gICAgc2V0IHYodikge1xuICAgICAgICB0aGlzLnZhbHVlID0gdjtcbiAgICB9XG5cbiAgICBzZXQgcHJvcGVydGllcyh2KSB7XG4gICAgICAgIGlmICghQXJyYXkuaXNBcnJheSh2KSkge1xuICAgICAgICAgICAgdiA9IFt2XTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuX3Byb3BzID0gW107XG5cbiAgICAgICAgdi5mb3JFYWNoKChwcm9wKSA9PiB7XG4gICAgICAgICAgICB0aGlzLl9wcm9wcy5wdXNoKHByb3ApO1xuICAgICAgICAgICAgdGhpcy5fcHJvcFNldHRlcnMucHVzaChFbGVtZW50LmdldFNldHRlcihwcm9wKSk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIHN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IHN0YWdlO1xuXG4gICAgICAgIHRoaXMuc3RhZ2Uub24oJ2ZyYW1lU3RhcnQnLCAoKSA9PiB0aGlzLnByb2dyZXNzKCkpO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBBbGwgcnVubmluZyBhbmltYXRpb25zIG9uIGF0dGFjaGVkIHN1YmplY3RzLlxuICAgICAgICAgKiBAdHlwZSB7U2V0PEFuaW1hdGlvbj59XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLmFjdGl2ZSA9IG5ldyBTZXQoKTtcbiAgICB9XG5cbiAgICBwcm9ncmVzcygpIHtcbiAgICAgICAgaWYgKHRoaXMuYWN0aXZlLnNpemUpIHtcbiAgICAgICAgICAgIGxldCBkdCA9IHRoaXMuc3RhZ2UuZHQ7XG5cbiAgICAgICAgICAgIGxldCBmaWx0ZXIgPSBmYWxzZTtcbiAgICAgICAgICAgIHRoaXMuYWN0aXZlLmZvckVhY2goZnVuY3Rpb24oYSkge1xuICAgICAgICAgICAgICAgIGlmIChhLmlzQWN0aXZlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgYS5wcm9ncmVzcyhkdCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZmlsdGVyID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgaWYgKGZpbHRlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuYWN0aXZlID0gbmV3IFNldChbLi4udGhpcy5hY3RpdmVdLmZpbHRlcih0ID0+IHQuaXNBY3RpdmUoKSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgY3JlYXRlQW5pbWF0aW9uKGVsZW1lbnQsIHNldHRpbmdzKSB7XG4gICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwoc2V0dGluZ3MpKSB7XG4gICAgICAgICAgICAvLyBDb252ZXJ0IHBsYWluIG9iamVj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lwIHRvIGVuZCBvZiB0cmFuc2l0aW9uIHNvIHRoYXQgaXQgaXMgcmVtb3ZlZC5cbiAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMucCA8IDEpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmRlbGF5TGVmdCA+IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9kZWxheUxlZnQgLT0gZHQ7XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5kZWxheUxlZnQgPCAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGR0ID0gLXRoaXMuZGVsYXlMZWZ0O1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9kZWxheUxlZnQgPSAwO1xuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZW1pdCgnZGVsYXlFbmQnKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MuZHVyYXRpb24gPT0gMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wICs9IGR0IC8gdGhpcy5fc2V0dGluZ3MuZHVyYXRpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fcCA+PSAxKSB7XG4gICAgICAgICAgICAgICAgLy8gRmluaXNoZWQhO1xuICAgICAgICAgICAgICAgIHRoaXMuX3AgPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fdXBkYXRlRHJhd1ZhbHVlKCk7XG5cbiAgICAgICAgdGhpcy5pbnZva2VMaXN0ZW5lcnMoKTtcbiAgICB9XG5cbiAgICBpbnZva2VMaXN0ZW5lcnMoKSB7XG4gIC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0byBwcmV2ZW50IG1lbW9yeSBsZWFrcylcbiAgICAgICAgICogQHR5cGUge1NldDxUcmFuc2l0aW9uPn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuYWN0aXZlID0gbmV3IFNldCgpO1xuXG4gICAgICAgIHRoaXMuZGVmYXVsdFRyYW5zaXRpb25TZXR0aW5ncyA9IG5ldyBUcmFuc2l0aW9uU2V0dGluZ3ModGhpcy5zdGFnZSk7XG4gICAgfVxuXG4gICAgcHJvZ3Jlc3MoKSB7XG4gICAgICAgIGlmICh0aGlzLmFjdGl2ZS5zaXplKSB7XG4gICAgICAgICAgICBsZXQgZHQgPSB0aGlzLnN0YWdlLmR0O1xuXG4gICAgICAgICAgICBsZXQgZmlsdGVyID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLmFjdGl2ZS5mb3JFYWNoKGZ1bmN0aW9uKGEpIHtcbiAgICAgICAgICAgICAgICBhLnByb2dyZXNzKGR0KTtcbiAgICAgICAgICAgICAgICBpZiAoIWEuaXNSdW5uaW5nKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlsdGVyID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgaWYgKGZpbHRlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuYWN0aXZlID0gbmV3IFNldChbLi4udGhpcy5hY3RpdmVdLmZpbHRlcih0ID0+ICh0LmlzUnVubmluZygpKSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgY3JlYXRlU2V0dGluZ3Moc2V0dGluZ3MpIHtcbiAgICAgICAgY29uc3QgdHJhbnNpdGlvblNldHRpbmdzID0gbmV3IFRyYW5zaXRpb25TZXR0aW5ncygpO1xuICAgICAgICBCYXNlLnBhdGNoT2JqZWN0KHRyYW5zaXRpb25TZXR0aW5ncywgc2V0dGluZ3MpO1xuICAgICAgICByZXR1cm4gdHJhbnNpdGlvblNldHRpbmdzO1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Qb2ludGVyXCIpKSB7XG4gICAgICAgICAgICB0aGlzLnN0YWdlLnBsYXRmb3JtLnJlZ2lzdGVyQ2xpY2tIYW5kbGVyKChlKSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmVjZWl2ZUNsaWNrKGUpO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHRoaXMuc3RhZ2UucGxhdGZvcm0ucmVnaXN0ZXJIb3ZlckhhbmRsZXIoKGUpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZWNlaXZlSG92ZXIoZSk7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgdGhpcy5zdGFnZS5wbGF0Zm9ybS5yZWdpc3RlclNjcm9sbFdoZWVsSGFuZGxlcigoZSkgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlY2lldmVTY3JvbGxXaGVlbChlKTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICB0aGlzLmN1cnNvciA9ICdkZWZhdWx0JztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldE9wdGlvbihuYW1lKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fb3B0aW9uc1tuYW1lXTtcbiAgICB9XG5cbiAgICBfc2V0T3B0aW9ucyhvKSB7XG4gICAgICAgIHRoaXMuX19vcHRpb25zID0ge307XG5cbiAgICAgICAgbGV0IG9wdCA9IChuYW1lLCBkZWYpID0+IHtcbiAgICAgICAgICAgIGxldCB2YWx1ZSA9IG9bbmFtZV07XG5cbiAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX29wdGlvbnNbbmFtZV0gPSBkZWY7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX19vcHRpb25zW25hbWVdID0gdmFsdWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBvcHQoJ2RlYnVnJywgZmFsc2UpO1xuICAgICAgICBvcHQoJ2tleXMnLCB7XG4gICAgICAgICAgICAzODogXCJVcFwiLFxuICAgICAgICAgICAgNDA6IFwiRG93blwiLFxuICAgICAgICAgICAgMzc6IFwiTGVmdFwiLFxuICAgICAgICAgICAgMzk6IFwiUmlnaHRcIixcbiAgICAgICAgICAgIDEzOiBcIkVudGVyXCIsXG4gICAgICAgICAgICA4OiBcIkJhY2tcIixcbiAgICAgICAgICAgIDI3OiBcIkV4aXRcIlxuICAgICAgICB9KTtcbiAgICAgICAgb3B0KCdlbmFibGVQb2ludGVyJywgZmFsc2UpO1xuICAgIH1cblxuICAgIF9fY29uc3RydWN0KCkge1xuICAgICAgICB0aGlzLnN0YWdlLnNldEFwcGxpY2F0aW9uKHRoaXMpO1xuXG4gICAgICAgIHRoaXMuX3NldE9wdGlvbnMoQXBwbGljYXRpb24uX3RlbXBfb3B0aW9ucyk7XG4gICAgICAgIGRlbGV0ZSBBcHBsaWNhdGlvbi5fdGVtcF9vcHRpb25zO1xuXG4gICAgICAgIHN1cGVyLl9fY29uc3RydWN0KCk7XG4gICAgfVxuXG4gICAgX19pbml0KCkge1xuICAgICAgICBzdXBlci5fX2luaXQoKTtcbiAgICAgICAgdGhpcy5fX3VwZGF0ZUZvY3VzKCk7XG4gICAgfVxuXG4gICAgdXBkYXRlRm9jdXNQYXRoKCkge1xuICAgICAgICB0aGlzLl9fdXBkYXRlRm9jdXMoKTtcbiAgICB9XG5cbiAgICBfX3VwZGF0ZUZvY3VzKCkge1xuICAgICAgICBjb25zdCBub3RPdmVycmlkZGVuID0gdGhpcy5fX3VwZGF0ZUZvY3VzUmVjKCk7XG5cbiAgICAgICAgaWYgKCFBcHBsaWNhdGlvbi5ib290aW5nICYmIG5vdE92ZXJyaWRkZW4pIHtcbiAgICAgICAgICAgIHRoaXMudXBkYXRlRm9jdXNTZXR0aW5ncygpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX191cGRhdGVGb2N1c1JlYygpI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AgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsZXQgbSA9IE1hdGgubWluKHRoaXMuX2ZvY3VzUGF0aC5sZW5ndGgsIG5ld0ZvY3VzUGF0aC5sZW5ndGgpO1xuICAgICAgICAgICAgbGV0IGluZGV4O1xuICAgICAgICAgICAgZm9yIChpbmRleCA9IDA7IGluZGV4IDwgbTsgaW5kZXgrKykge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9mb2N1c1BhdGhbaW5kZXhdICE9PSBuZXdGb2N1c1BhdGhbaW5kZXhdKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX2ZvY3VzUGF0aC5sZW5ndGggIT09IG5ld0ZvY3VzUGF0aC5sZW5ndGggfHwgaW5kZXggIT09IG5ld0ZvY3VzUGF0aC5sZW5ndGgpIHtcblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmdldE9wdGlvbignZGVidWcnKSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnW0xpZ2h0bmluZ10gRm9jdXMgY2hhbmdlZDogJyArIG5ld0ZvY3VzZWRDb21wb25lbnQuZ2V0TG9jYXRpb25TdHJpbmcoKSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gVW5mb2N1cyBldmVudHMuXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuX2ZvY3VzUGF0aC5sZW5ndGggLSAxOyBpID49IGluZGV4OyBpLS0pIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5mb2N1c2VkRWxlbWVudCA9IHRoaXMuX2ZvY3VzUGF0aC5wb3AoKTtcbiAgICAgICAgICAgICAgICAgICAgdW5mb2N1c2VkRWxlbWVudC5fdW5mb2N1cyhuZXdGb2N1c2VkQ29tcG9uZW50LCBwcmV2Rm9jdXNlZENvbXBvbmVudCk7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvY3VzT3ZlcnJpZGRlbiA9ICh0aGlzLl9fdXBkYXRlRm9jdXNJZCAhPT0gdXBkYXRlRm9jdXNJZCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChmb2N1c092ZXJyaWRkZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIEZvY3VzIGV2ZW50cy5cbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gaW5kZXgsIG4gPSBuZXdGb2N1c1BhdGgubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZvY3VzUGF0aC5wdXNoKG5ld0ZvY3VzUGF0aFtpXSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZvY3VzUGF0aFtpXS5fZm9jdXMobmV3Rm9jdXNlZENvbXBvbmVudCwgcHJldkZvY3VzZWRDb21wb25lbnQpO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBmb2N1c092ZXJyaWRkZW4gPSAodGhpcy5fX3VwZGF0ZUZvY3VzSWQgIT09IHVwZGF0ZUZvY3VzSWQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZm9jdXNPdmVycmlkZGVuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBGb2N1cyBjaGFuZ2VkIGV2ZW50cy5cbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGluZGV4OyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAg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IH1cblxuXG4gICAgICAgICAgICBsZXQgcHRyID0gbmV4dEZvY3VzLmNwYXJlbnQ7XG4gICAgICAgICAgICBpZiAocHRyID09PSBjdXJyZW50KSB7XG4gICAgICAgICAgICAgICAgcGF0aC5wdXNoKG5leHRGb2N1cyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIE5vdCBhbiBpbW1lZGlhdGUgY2hpbGQ6IGluY2x1ZGUgZnVsbCBwYXRoIHRvIGRlc2NlbmRhbnQuXG4gICAgICAgICAgICAgICAgY29uc3QgbmV3UGFydHMgPSBbbmV4dEZvY3VzXTtcbiAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcHRyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Ll90aHJvd0Vycm9yKFwiUmV0dXJuIHZhbHVlIGZvciBfZ2V0Rm9jdXNlZCBtdXN0IGJlIGFuIGF0dGFjaGVkIGRlc2NlbmRhbnQgY29tcG9uZW50IGJ1dCBpdHMgJ1wiICsgbmV4dEZvY3VzLmdldExvY2F0aW9uU3RyaW5nKCkgKyBcIidcIik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgbmV3UGFydHMucHVzaChwdHIpO1xuICAgICAgICAgICAgICAgICAgICBwdHIgPSBwdHIuY3BhcmVudDtcbiAgICAgICAgICAgICAgICB9IHdoaWxlIChwdHIgIT09IGN1cnJlbnQpO1xuXG4gICAgICAgICAgICAgICAgLy8gQWRkIHRoZW0gcmV2ZXJzZWQuXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBuZXdQYXJ0cy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgcGF0aC5wdXNoKG5ld1BhcnRzW24gLSBpIC0gMV0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY3VycmVudCA9IG5leHRGb2N1cztcbiAgICAgICAgfSB3aGlsZSAodHJ1ZSk7XG5cbiAgICAgICAgcmV0dXJuIHBhdGg7XG4gICAgfVxuXG4gICAgZ2V0IGZvY3VzUGF0aCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZvY3VzUGF0aDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBJbmplY3RzIGFuIGV2ZW50IGluIHRoZSBzdGF0ZSBtYWNoaW5lcywgdG9wLWRvd24gZnJvbSBhcHBsaWNhdGlvbiB0byBmb2N1c2VkIGNvbXBvbmVudC5cbiAgICAgKi9cbiAgICBmb2N1c1RvcERvd25FdmVudChldmVudHMsIC4uLmFyZ3MpIHtcbiAgICAgICAgY29uc3QgcGF0aCA9IHRoaXMuZm9jdXNQYXRoO1xuICAgICAgICBjb25zdCBuID0gcGF0aC5sZW5ndGg7XG5cbiAgICAgICAgLy8gTXVsdGlwbGUgZXZlbnRzLlxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3QgZXZlbnQgPSBwYXRoW2ldLl9nZXRNb3N0U3BlY2lmaWNIYW5kbGVkTWVtYmVyKGV2ZW50cyk7XG4gICAgICAgICAgICBpZiAoZXZlbnQgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJldHVyblZhbHVlID0gcGF0aFtpXVtldmVudF0oLi4uYXJncyk7XG4gICAgICAgICAgICAgICAgaWYgKHJldHVyblZhbHVlICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogSW5qZWN0cyBhbiBldmVudCBpbiB0aGUgc3RhdGUgbWFjaGluZXMsIGJvdHRvbS11cCBmcm9tIGZvY3VzZWQgY29tcG9uZW50IHRvIGFwcGxpY2F0aW9uLlxuICAgICAqL1xuICAgIGZvY3VzQm90dG9tVXBFdmVudChldmVudHMsIC4uLmFyZ3MpIHtcbiAgICAgICAgY29uc3QgcGF0aCA9IHRoaXMuZm9jdXNQYXRoO1xuICAgICAgICBjb25zdCBuID0gcGF0aC5sZW5ndGg7XG5cbiAgICAgICAgLy8gTXVsdGlwbGUgZXZlbnRzLlxuICAgICAgICBmb3IgKGxldCBpID0gbiAtIDE7IGkgPj0gMDsgaS0tKSB7XG4gICAgICAgICAgICBjb25zdCBldmVudCA9IHBhdGhbaV0uX2dldE1vc3RTcGVjaWZpY0hhbmRsZWRNZW1iZXIoZXZlbnRzKTtcbiAgICAgICAgICAgIGlmIChldmVudCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmV0dXJuVmFsdWUgPSBwYXRoW2ldW2V2ZW50XSguLi5hcmdzKTtcbiAgICAgICAgICAgICAgICBpZiAocmV0dXJuVmFsdWUgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG5cbiAgICBfcmVjZWl2ZUtleWRvd24oZSkge1xuICAgICAgICBjb25zdCBvYmogPSBlO1xuICAgICAgICBjb25zdCBrZXkgPSB0aGlzLl9fa2V5bWFwW2Uua2V5Q29kZV07XG4gICAgICAgIGNvbnN0IHBhdGggPSB0aGlzLmZvY3VzUGF0aDtcblxuICAgICAgICBsZXQga2V5cztcbiAgICAgICAgaWYgKGtleSkge1xuICAgICAgICAgICAga2V5cyA9IEFycmF5LmlzQXJyYXkoa2V5KSA/IGtleSA6IFtrZXldO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGtleXMpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0ga2V5cy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjb25zdCBoYXNUaW1lciA9IHRoaXMuX19rZXlwcmVzc1RpbWVycy5oYXMoa2V5c1tpXSk7XG4gICAgICAgICAgICAgICAgLy8gcHJldmVudCBldmVudCBmcm9tIGdldHRpbmcgZmlyZWQgd2hlbiB0aGUgdGltZW91dCBpcyBzdGlsbCBhY3RpdmVcbiAgICAgICAgICAgICAgICBpZiAocGF0aFtwYXRoLmxlbmd0aCAtIDFdLmxvbmdwcmVzcyAmJiBoYXNUaW1lcikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLmZvY3VzVG9wRG93bkV2ZW50KFtgX2NhcHR1cmUke2tleXNbaV19YCwgXCJfY2FwdHVyZUtleVwiXSwgb2JqKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLmZvY3VzQm90dG9tVXBFdmVudChbYF9oYW5kbGUke2tleXNbaV19YCwgXCJfaGFuZGxlS2V5XCJdLCBvYmopO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5mb2N1c1RvcERvd25FdmVudChbXCJfY2FwdHVyZUtleVwiXSwgb2JqKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuYXBwbGljYXRpb24uZm9jdXNCb3R0b21VcEV2ZW50KFtcIl9oYW5kbGVLZXlcIl0sIG9iaik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnVwZGF0ZUZvY3VzUGF0aCgpO1xuXG4gICAgICAgIGNvbnN0IGNvbnN1bWVyID0gcGF0aFtwYXRoLmxlbmd0aCAt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ICAgICAgIGlmIChjb25maWdbbG9va3VwXSkge1xuICAgICAgICAgICAgY29uc3QgdGltZW91dCA9IGNvbmZpZ1tsb29rdXBdO1xuICAgICAgICAgICAgaWYgKCFVdGlscy5pc051bWJlcih0aW1lb3V0KSkge1xuICAgICAgICAgICAgICAgIGVsZW1lbnQuX3Rocm93RXJyb3IoXCJjb25maWcgdmFsdWUgZm9yIGxvbmdwcmVzcyBtdXN0IGJlIGEgbnVtYmVyXCIpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9fa2V5cHJlc3NUaW1lcnMuc2V0KGtleSwgc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5mb2N1c1RvcERvd25FdmVudChbYF9jYXB0dXJlJHtrZXl9TG9uZ2AsIFwiX2NhcHR1cmVLZXlcIl0sIHt9KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5mb2N1c0JvdHRvbVVwRXZlbnQoW2BfaGFuZGxlJHtrZXl9TG9uZ2AsIFwiX2hhbmRsZUtleVwiXSwge30pO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX2tleXByZXNzVGltZXJzLmRlbGV0ZShrZXkpO1xuICAgICAgICAgICAgICAgIH0sIHRpbWVvdXQgfHwgNTAwIC8qIHByZXZlbnQgMG1zICovKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuO1xuICAgIH1cblxuICAgIF9yZWNpZXZlU2Nyb2xsV2hlZWwoZSkge1xuICAgICAgICBjb25zdCBvYmogPSBlO1xuICAgICAgICBjb25zdCB7IGNsaWVudFgsIGNsaWVudFkgfSA9IG9iajtcblxuICAgICAgICBpZiAoY2xpZW50WCA8PSB0aGlzLnN0YWdlLncgJiYgY2xpZW50WSA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AgICAgLy8gU2VhcmNoIHRyZWUgYm90dG9tIHVwIGZvciBhIGhhbmRsZXJcbiAgICAgICAgd2hpbGUgKGNoaWxkICE9PSBudWxsKSB7XG4gICAgICAgICAgICBpZiAoY2hpbGQgJiYgY2hpbGRbXCJfaGFuZGxlQ2xpY2tcIl0pIHtcbiAgICAgICAgICAgICAgICBjb25zdCB7IHB4LCBweSB9ID0gY2hpbGQuY29yZS5fd29ybGRDb250ZXh0O1xuICAgICAgICAgICAgICAgIGNvbnN0IGN4ID0gcHggKiBwcmVjaXNpb247XG4gICAgICAgICAgICAgICAgY29uc3QgY3kgPSBweSAqIHByZWNpc2lvbjtcblxuICAgICAgICAgICAgICAgIGNvbnN0IGxvY2FsQ29vcmRzID0ge1xuICAgICAgICAgICAgICAgICAgICB4OiBjbGllbnRYIC0gY3gsXG4gICAgICAgICAgICAgICAgICAgIHk6IGNsaWVudFkgLSBjeVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGNvbnN0IHJldHVyblZhbHVlID0gY2hpbGQuX2hhbmRsZUNsaWNrKHRhcmdldCwgbG9jYWxDb29yZHMpO1xuICAgICAgICAgICAgICAgIGlmIChyZXR1cm5WYWx1ZSAhPT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2hpbGQgPSBjaGlsZC5wYXJlbnQ7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfcmVjZWl2ZUhvdmVyKGUpIHtcbiAgICAgICAgY29uc3Qgb2JqID0gZTtcbiAgICAgICAgY29uc3QgeyBjbGllbnRYLCBjbGllbnRZIH0gPSBvYmo7XG5cbiAgICAgICAgaWYgKGNsaWVudFggPD0gdGhpcy5zdGFnZS53ICYmIGNsaWVudFkgPD0gdGhpcy5zdGFnZS5oKSB7XG4gICAgICAgICAgICB0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLmZp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KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjLl9oYW5kbGVVbmhvdmVyKGVsZW0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGlmIChlbGVtLnBhcmVudCAmJiBlbGVtLnBhcmVudC5jdXJzb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuZ2V0Q2FudmFzKCkuc3R5bGUuY3Vyc29yID0gZWxlbS5wYXJlbnQuY3Vyc29yO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9faG92ZXJlZENoaWxkID0gdGFyZ2V0O1xuXG4gICAgICAgICAgICBjb25zdCBkaWZmQnJhbmNoID0gWy4uLm5ld0hvdmVyZWRCcmFuY2hdLmZpbHRlcigoZSkgPT4gIWhvdmVyZWRCcmFuY2guaGFzKGUpKVxuICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtIG9mIGRpZmZCcmFuY2gpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBjID0gQ29tcG9uZW50LmdldENvbXBvbmVudChlbGVtKTtcbiAgICAgICAgICAgICAgICBpZiAoY1tcIl9oYW5kbGVIb3ZlclwiXSkge1xuICAgICAgICAgICAgICAgICAgICBjLl9oYW5kbGVIb3ZlcihlbGVtKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIE5ldyBlbGVtZW50IGhvdmVyIGN1cnNvclxuICAgICAgICAgICAgY29uc3QgbGFzdEVsZW1lbnQgPSBkaWZmQnJhbmNoWzBdO1xuICAgICAgICAgICAgaWYgKGxhc3RFbGVtZW50ICYmIGxhc3RFbGVtZW50LmN1cnNvcikge1xuICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuZ2V0Q2FudmFzKCkuc3R5bGUuY3Vyc29yID0gbGFzdEVsZW1lbnQuY3Vyc29yO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBSZXJ1biBfaGFuZGxlSG92ZXIgZm9yIHRhcmdldCBlbGVtZW50IGluIGNhc2UgaXQncyBiZWVuIGhvdmVyZWRcbiAgICAgICAgICAgIC8vIGJhY2sgZnJvbSBpdHMgY2hpbGRcbiAgICAgICAgICAgIGlmIChkaWZmQnJhbmNoLmxlbmd0aCA9PT0gMCAmJiB0YXJnZXQpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBjID0gQ29tcG9uZW50LmdldENvbXBvbmVudCh0YXJnZXQpO1xuICAgICAgICAgICAgICAgIGlmIChjW1wiX2hhbmRsZUhvdmVyXCJdKSB7XG4gICAgICAgICAgICAgICAgICAgIGMuX2hhbmRsZUhvdmVyKHRhcmdldCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldFRhcmdldENoaWxkKGNsaWVudFgsIGNsaWVudFkpIHtcbiAgICAgICAgbGV0IGNoaWxkcmVuID0gdGhpcy5zdGFnZS5hcHBsaWNhdGlvbi5jaGlsZHJlbjtcbiAgICAgICAgbGV0IGFmZmVjdGVkID0gdGhpcy5fZmluZENoaWxkcmVuKFtdLCBjaGlsZHJlbik7XG4gICAgICAgIGxldCBob3ZlcmFibGVDaGlsZHJlbiA9IHRoaXMuX3dpdGhpbkNsaWNrYWJsZVJhbmdlKGFmZmVjdGVkLCBjbGllbnRYLCBjbGllbnRZKTtcblxuICAgICAgICBob3ZlcmFibGVDaGlsZHJlbi5zb3J0KChhLCBiKSA9PiB7XG4gICAgICAgICAgICAvLyBTb3J0IGJ5IHpJbmRleCBhbmQgdGhlbiBpZFxuICAgICAgICAgICAgaWYgKGEuekluZGV4ID4gYi56SW5kZXgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoYS56SW5kZXggPCBiLnpJbmRleCkge1xuICAgICAgICAgICAgICAgIHJldHVybiAtMTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGEuaWQgPiBiLmlkID8gMSA6IC0xO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBpZiAoaG92ZXJhYmxlQ2hpbGRyZW4ubGVuZ3RoKSB7XG4gICAgICAgICAgICAvLyBBc3N1bWUgdGFyZ2V0IGhhcyBoaWdoZXN0IHpJbmRleCAoaWQgd2hlbiB6SW5kZXggZXF1YWwpXG4gICAgICAgICAgICByZXR1cm4gaG92ZXJhYmxlQ2hpbGRyZW4uc2xpY2UoLTEpWzBdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZmluZENoaWxkcmVuKGJ1Y2tldCwgY2hpbGRyZW4pIHtcbiAgICAgICAgbGV0IG4gPSBjaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgIHdoaWxlIChuLS0pIHtcbiAgICAgICAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGRyZW5bbl07XG4gICAgICAgICAgICAvLyBvbmx5IGFkZCBhY3RpdmUgY2hpbGRyZW5cbiAgICAgICAgICAgIGlmIChjaGlsZC5fX2FjdGl2ZSAmJiBjaGlsZC5jb2xsaXNpb24pIHtcbiAgICAgICAgICAgICAgICBpZiAoY2hpbGQuY29sbGlzaW9uID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIGJ1Y2tldC5wdXNoKGNoaWxkKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkLmhhc0NoaWxkcmVuKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmluZENoaWxkcmVuKGJ1Y2tldCwgY2hpbGQuY2hpbGRyZW4pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYnVja2V0O1xuICAgIH1cblxuICAgIF93aXRoaW5DbGlja2FibGVSYW5nZShhZmZlY3RlZENoaWxkcmVuLCBjdXJzb3JYLCBjdXJzb3JZKSB7XG4gICAgICAgIGxldCBuID0gYWZmZWN0ZWRDaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgIGNvbnN0IGNhbmRpZGF0ZXMgPSBbXTtcblxuICAgICAgICAvLyBsb29wIHRocm91Z2ggYWZmZWN0ZWQgY2hpbGRyZW5cbiAgICAgICAgLy8gYW5kIHBlcmZvcm0gY29sbGlzaW9uIGRldGVjdGlvblxuICAgICAgICB3aGlsZSAobi0tKSB7XG4gICAgICAgICAgICBjb25zdCBjaGlsZCA9IGFmZmVjdGVkQ2hpbGRyZW5bbl07XG4gICAgICAgICAgICBjb25zdCBwcmVjaXNpb24gPSB0aGlzLnN0YWdlLmdldFJlbmRlclByZWNpc2lvbigpIC8gdGhpcy5zdGFnZS5nZXRPcHRpb24oJ2RldmljZVBpeGVsUmF0aW8nKTtcbiAgICAgICAgICAgIGNvbnN0IGN0eCA9IGNoaWxkLmNvcmUuX3dvcmxkQ29udGV4dDtcblxuICAgICAgICAgICAgY29uc3QgY3ggPSBjdHgucHggKiBwcmVjaXNpb247XG4gICAgICAgICAgICBjb25zdCBjeSA9IGN0eC5weSAqIHByZWNpc2lvbjtcbiAgICAgICAgICAgIGNvbnN0IGN3ID0gY2hpbGQuZmluYWxXICogY3R4LnRhICogcHJlY2lzaW9uO1xuICAgICAgICAgICAgY29uc3QgY2ggPSBjaGlsZC5maW5hbEggKiBjdHgudGQgKiBwcmVjaXNpb247XG5cbiAgICAgICAgICAgIGlmIChjeCA+IHRoaXMuc3RhZ2UudyB8fCBjeSA+IHRoaXMuc3RhZ2UuaCkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoY2hpbGQucGFyZW50LmNvcmUuX3NjaXNzb3IpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBzY2lzc29yID0gY2hpbGQucGFyZW50LmNvcmUuX3NjaXNzb3IubWFwKCh2KSA9PiB2ICogcHJlY2lzaW9uKTtcbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3Rlc3RDb2xsaXNpb24oY3Vyc29yWCwgY3Vyc29yWSwgLi4uc2Npc3NvcikpXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl90ZXN0Q29sbGlzaW9uKGN1cnNvclgsIGN1cnNvclksIGN4LCBjeSwgY3csIGNoKSkge1xuICAgICAgICAgICAgICAgIGNhbmRpZGF0ZXMucHVzaChjaGlsZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGNhbmRpZGF0ZXM7XG4gICAgfVxuXG4gICAgX3Rlc3RDb2xsaXNpb24ocHgsIHB5LCBjeCwgY3ksIGN3LCBjaCkge1xuICAgICAgICBpZiAocHggPj0gY3ggJiZcbiAgICAgICAgICAgIHB4IDw9IGN4ICsgY3cgJiZcbiAgICAgICAgICAgIHB5ID49IGN5ICYmXG4gICAgICAgICAgICBweSA8PSBjeSArIGNoKSB7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgZGVzdHJveSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9kZXN0cm95ZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX2Rlc3Ryb3koKTtcbiAgICAgICAgICAgIHRoaXMuc3RhZ2UuZGVzdHJveSgpO1xuICAgICAgICAgICAgdGhpcy5fZGVzdHJveWVkID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9kZXN0cm95KCkge1xuICAgICAgICAvLyBUaGlzIGZvcmNlcyB0aGUgX2RldGFjaCwgX2Rpc2FibGVkIGFuZCBfY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W5jaWVzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBwcm9wTmFtZSA9IHByb3BEZXBlbmRlbmNpZXNbaV07XG4gICAgICAgICAgICBjb25zdCBmdW5jID0gcHJvcE9iai5fX2Z1bmMgPyBwcm9wT2JqLl9fZnVuYyA6IChjb250ZXh0KSA9PiBjb250ZXh0W3Byb3BOYW1lXTtcblxuICAgICAgICAgICAgaWYgKCF0aGlzLmhhc093blByb3BlcnR5KHByb3BOYW1lKSkge1xuICAgICAgICAgICAgICAgIHRoaXNbYF9fcHJvcF9iaW5kaW5nc18ke3Byb3BOYW1lfWBdID0gW3tfX29iajogb2JqLCBfX3Byb3A6IHByb3AsIF9fZnVuYzogZnVuY31dO1xuICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCBwcm9wTmFtZSwge1xuICAgICAgICAgICAgICAgICAgICBzZXQ6ICh2YWx1ZSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpc1tgX19wcm9wXyR7cHJvcE5hbWV9YF0gPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qge19fb2JqLCBfX3Byb3AsIF9fZnVuY30gb2YgdGhpc1tgX19wcm9wX2JpbmRpbmdzXyR7cHJvcE5hbWV9YF0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX29ialtfX3Byb3BdID0gX19mdW5jKHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBnZXQ6ICgpID0+IHRoaXNbYF9fcHJvcF8ke3Byb3BOYW1lfWBdXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXNbYF9fcHJvcF9iaW5kaW5nc18ke3Byb3BOYW1lfWBdLnB1c2goe19fb2JqOiBvYmosIF9fc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XcgRnVuY3Rpb24oXCJlbGVtZW50XCIsIFwic3RvcmVcIiwgY29kZSk7XG4gICAgICAgIHJldHVybiB7ZjogZiwgYTogY29udGV4dC5zdG9yZX07XG4gICAgfVxuXG4gICAgc3RhdGljIHBhcnNlVGVtcGxhdGVSZWMob2JqLCBjb250ZXh0LCBjdXJzb3IpIHtcbiAgICAgICAgY29uc3Qgc3RvcmUgPSBjb250ZXh0LnN0b3JlO1xuICAgICAgICBjb25zdCBsb2MgPSBjb250ZXh0LmxvYztcbiAgICAgICAgY29uc3Qga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgIGtleXMuZm9yRWFjaChrZXkgPT4ge1xuICAgICAgICAgICAgbGV0IHZhbHVlID0gb2JqW2tleV07XG4gICAgICAgICAgICBpZiAoVXRpbHMuaXNVY0NoYXIoa2V5LmNoYXJDb2RlQXQoMCkpKSB7XG4gICAgICAgICAgICAgICAgLy8gVmFsdWUgbXVzdCBiZSBleHBhbmRlZCBhcyB3ZWxsLlxuICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFJlZi5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hpbGRDdXJzb3IgPSBgciR7a2V5LnJlcGxhY2UoL1teYS16MC05XS9naSwgXCJcIikgKyBjb250ZXh0LnJpZH1gO1xuICAgICAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IHZhbHVlLnR5cGUgPyB2YWx1ZS50eXBlIDogRWxlbWVudDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGUgPT09IEVsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGB2YXIgJHtjaGlsZEN1cnNvcn0gPSBlbGVtZW50LnN0YWdlLmNyZWF0ZUVsZW1lbnQoKWApO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh0eXBlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGB2YXIgJHtjaGlsZEN1cnNvcn0gPSBuZXcgc3RvcmVbJHtzdG9yZS5sZW5ndGggLSAxfV0oJHtjdXJzb3J9LnN0YWdlKWApO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2NoaWxkQ3Vyc29yfS5yZWYgPSBcIiR7a2V5fVwiYCk7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRleHQucmlkKys7XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gRW50ZXIgc3ViLlxuICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcnNlVGVtcGxhdGVSZWModmFsdWUsIGNvbnRleHQsIGNoaWxkQ3Vyc29yKTtcblxuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9LmNoaWxkTGlzdC5hZGQoJHtjaGlsZEN1cnNvcn0pYCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdCh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRHluYW1pYyBhc3NpZ25tZW50LlxuICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfS5jaGlsZExpc3QuYWRkKHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dKWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKGtleSA9PT0gXCJ0ZXh0XCIpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvcEtleSA9IGN1cnNvciArIFwiX190ZXh0XCI7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGB2YXIgJHtwcm9wS2V5fSA9ICR7Y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0dXJlXCIgJiYgVXRpbHMuaXNPYmplY3RMaXRlcmFsKHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9wS2V5ID0gY3Vyc29yICsgXCJfX3RleHR1cmVcIjtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHZhbHVlLnR5cGU7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHR5cGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYHZhciAke3Byb3BLZXl9ID0gbmV3IHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dKCR7Y3Vyc29yfS5zdGFnZSlgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyc2VUZW1wbGF0ZVByb3BSZWModmFsdWUsIGNvbnRleHQsIHByb3BLZXkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9ICR7cHJvcEtleX1gKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke3Byb3BLZXl9ID0gJHtjdXJzb3J9LnRleHR1cmVgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyc2VUZW1wbGF0ZVByb3BSZWModmFsdWUsIGNvbnRleHQsIHByb3BLZXkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodmFsdWUpICYmIHZhbHVlLl9fcHJvcGVydHlCaW5kaW5nID09PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgZWxlbWVudC5fX2JpbmRQcm9wZXJ0eShzdG9yZVske3N0b3JlLmxlbmd0aCAtIDF9XSwgJHtjdXJzb3J9LCBcIiR7a2V5fVwiKWApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFByb3BlcnR5O1xuICAgICAgICAgICAgICAgICAgICBpZiAoVXRpbHMuaXNOdW1iZXIodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHt2YWx1ZX1gKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc0Jvb2xlYW4odmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsb2MucHVzaChgJHtjdXJzb3J9W1wiJHtrZXl9XCJdID0gJHt2YWx1ZSA/IFwidHJ1ZVwiIDogXCJmYWxzZVwifWApO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKFV0aWxzLmlzT2JqZWN0KHZhbHVlKSB8fCBBcnJheS5pc0FycmF5KHZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gRHluYW1pYyBhc3NpZ25tZW50LlxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQmVjYXVzZSBsaXRlcmFsIG9iamVjdHMgbWF5IGNvbnRhaW4gZHluYW1pY3MsIHdlIHN0b3JlIHRoZSBmdWxsIG9iamVjdC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JlLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9IHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dYCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBTdHJpbmcgZXRjLlxuICAgICAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9ICR7SlNPTi5zdHJpbmdpZnkodmFsdWUpfWApO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBzdGF0aWMgcGFyc2VUZW1wbGF0ZVByb3BSZWMob2JqLCBjb250ZXh0LCBjdXJzb3IpIHtcbiAgICAgICAgY29uc3Qgc3RvcmUgPSBjb250ZXh0LnN0b3JlO1xuICAgICAgICBjb25zdCBsb2MgPSBjb250ZXh0LmxvYztcbiAgICAgICAgY29uc3Qga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgIGtleXMuZm9yRWFjaChrZXkgPT4ge1xuICAgICAgICAgICAgaWYgKGtleSAhPT0gXCJ0eXBlXCIpIHtcbiAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IG9ialtrZXldO1xuICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc051bWJlcih2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9ICR7dmFsdWV9YCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc0Jvb2xlYW4odmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGAke2N1cnNvcn1bXCIke2tleX1cIl0gPSAke3ZhbHVlID8gXCJ0cnVlXCIgOiBcImZhbHNlXCJ9YCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdCh2YWx1ZSkgJiYgdmFsdWUuX19wcm9wZXJ0eUJpbmRpbmcgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGBlbGVtZW50Ll9fYmluZFByb3BlcnR5KHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dLCAke2N1cnNvcn0sIFwiJHtrZXl9XCIpYCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdCh2YWx1ZSkgfHwgQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRHluYW1pYyBhc3NpZ25tZW50LlxuICAgICAgICAgICAgICAgICAgICAvLyBCZWNhdXNlIGxpdGVyYWwgb2JqZWN0cyBtYXkgY29udGFpbiBkeW5hbWljcywgd2Ugc3RvcmUgdGhlIGZ1bGwgb2JqZWN0LlxuICAgICAgICAgICAgICAgICAgICBzdG9yZS5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9IHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dYCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gU3RyaW5nIGV0Yy5cbiAgICAgICAgICAgICAgICAgICAgbG9jLnB1c2goYCR7Y3Vyc29yfVtcIiR7a2V5fVwiXSA9ICR7SlNPTi5zdHJpbmdpZnkodmFsdWUpfWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgc3RhdGljIHBhcnNlUHJvcGVydHlCaW5kaW5ncyhvYmosIGNvbnRleHQsIGN1cnNvcikge1xuICAgICAgICBjb25zdCBzdG9yZSA9IGNvbnRleHQuc3RvcmU7XG4gICAgICAgIGNvbnN0IGxvYyA9IGNvbnRleHQubG9jO1xuICAgICAgICBjb25zdCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAga2V5cy5mb3JFYWNoKGtleSA9PiB7XG4gICAgICAgICAgICBpZiAoa2V5ICE9PSBcInR5cGVcIikge1xuICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gb2JqW2tleV07XG4gICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2YWx1ZSkgJiYgdmFsdWUuX19wcm9wZXJ0eUJpbmRpbmcgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgc3RvcmUucHVzaCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIGxvYy5wdXNoKGBlbGVtZW50Ll9fYmluZFByb3BlcnR5KHN0b3JlWyR7c3RvcmUubGVuZ3RoIC0gMX1dLCAke2N1cnNvcn0sIFwiJHtrZXl9XCIpYCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBfb25TZXR1cCgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9faW5pdGlhbGl6ZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX3NldHVwKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfc2V0dXAoKSB7XG4gICAgfVxuXG4gICAgX29uQXR0YWNoKCkge1xuICAgICAgICBpZiAoIXRoaXMuX19pbml0aWFsaXplZCkge1xuICAgICAgICAgICAgdGhpcy5fX2luaXQoKTtcbiAgICAgICAgICAgIHRoaXMuX19pbml0aWFsaXplZCA9IHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9hdHRhY2goKTtcbiAgICB9XG5cbiAgICBfYXR0YWNoKCkge1xuICAgIH1cblxuICAgIF9vbkRldGFjaCgpIHtcbiAgICAgICAgdGhpcy5fZGV0YWNoKCk7XG4gICAgfVxuXG4gICAgX2RldGFjaCgpIHtcbiAgICB9XG5cbiAgICBfb25FbmFibGVkKCkge1xuICAgICAgICBpZiAoIXRoaXMuX19maXJzdEVuYWJsZSkge1xuICAgICAgICAgICAgdGhpcy5fZmlyc3RFbmFibGUoKTtcbiAgICAgICAgICAgIHRoaXMuX19maXJzdEVuYWJsZSA9IHRydWU7XG4gICAgICAg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0UGFyZW50KHRoaXMpO1xuICAgIH1cblxuICAgIHNlZWtBbmNlc3RvckJ5VHlwZSh0eXBlKSB7XG4gICAgICAgIGxldCBjID0gdGhpcy5jcGFyZW50O1xuICAgICAgICB3aGlsZSAoYykge1xuICAgICAgICAgICAgaWYgKGMuY29uc3RydWN0b3IgPT09IHR5cGUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGMgPSBjLmNwYXJlbnQ7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXRTaGFyZWRBbmNlc3RvckNvbXBvbmVudChlbGVtZW50KSB7XG4gICAgICAgIGxldCBhbmNlc3RvciA9IHRoaXMuZ2V0U2hhcmVkQW5jZXN0b3IoZWxlbWVudCk7XG4gICAgICAgIHdoaWxlIChhbmNlc3RvciAmJiAhYW5jZXN0b3IuaXNDb21wb25lbnQpIHtcbiAgICAgICAgICAgIGFuY2VzdG9yID0gYW5jZXN0b3IucGFyZW50O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBhbmNlc3RvcjtcbiAgICB9XG5cbiAgICBnZXQgc2lnbmFscygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19zaWduYWxzO1xuICAgIH1cblxuICAgIHNldCBzaWduYWxzKHYpIHtcbiAgICAgICAgaWYgKCFVdGlscy5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJTaWduYWxzOiBzcGVjaWZ5IGFuIG9iamVjdCB3aXRoIHNpZ25hbC10by1maXJlIG1hcHBpbmdzXCIpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX19zaWduYWxzID0gdjtcbiAgICB9XG5cbiAgICBzZXQgYWx0ZXJTaWduYWxzKHYpIHtcbiAgICAgICAgaWYgKCFVdGlscy5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJTaWduYWxzOiBzcGVjaWZ5IGFuIG9iamVjdCB3aXRoIHNpZ25hbC10by1maXJlIG1hcHBpbmdzXCIpO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fX3NpZ25hbHMpIHtcbiAgICAgICAgICAgIHRoaXMuX19zaWduYWxzID0ge307XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChsZXQga2V5IGluIHYpIHtcbiAgICAgICAgICAgIGNvbnN0IGQgPSB2W2tleV07XG4gICAgICAgICAgICBpZiAoZCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMuX19zaWduYWxzW2tleV07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX19zaWduYWxzW2tleV0gPSB2O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHBhc3NTaWduYWxzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX3Bhc3NTaWduYWxzIHx8IHt9O1xuICAgIH1cblxuICAgIHNldCBwYXNzU2lnbmFscyh2KSB7XG4gICAgICAgIHRoaXMuX19wYXNzU2lnbmFscyA9IE9iamVjdC5hc3NpZ24odGhpcy5fX3Bhc3NTaWduYWxzIHx8IHt9LCB2KTtcbiAgICB9XG5cbiAgICBzZXQgYWx0ZXJQYXNzU2lnbmFscyh2KSB7XG4gICAgICAgIGlmICghVXRpbHMuaXNPYmplY3RMaXRlcmFsKHYpKSB7XG4gICAgICAgICAgICB0aGlzLl90aHJvd0Vycm9yKFwiU2lnbmFsczogc3BlY2lmeSBhbiBvYmplY3Qgd2l0aCBzaWduYWwtdG8tZmlyZSBtYXBwaW5nc1wiKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX19wYXNzU2lnbmFscykge1xuICAgICAgICAgICAgdGhpcy5fX3Bhc3NTaWduYWxzID0ge307XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChsZXQga2V5IGluIHYpIHtcbiAgICAgICAgICAgIGNvbnN0IGQgPSB2W2tleV07XG4gICAgICAgICAgICBpZiAoZCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMuX19wYXNzU2lnbmFsc1trZXldO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9fcGFzc1NpZ25hbHNba2V5XSA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBTaWduYWxzIHRoZSBwYXJlbnQgb2YgdGhlIHNwZWNpZmllZCBldmVudC5cbiAgICAgKiBBIHBhcmVudC9hbmNlc3RvciB0aGF0IHdpc2hlcyB0byBoYW5kbGUgdGhlIHNpZ25hbCBzaG91bGQgc2V0IHRoZSAnc2lnbmFscycgcHJvcGVydHkgb24gdGhpcyBjb21wb25lbnQuXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IGV2ZW50XG4gICAgICogQHBhcmFtIHsuLi4qfSBhcmdzXG4gICAgICovXG4gICAgc2lnbmFsKGV2ZW50LCAuLi5hcmdzKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zaWduYWwoZXZlbnQsIGFyZ3MpO1xuICAgIH1cblxuICAgIF9zaWduYWwoZXZlbnQsIGFyZ3MpIHtcbiAgICAgICAgY29uc3Qgc2lnbmFsUGFyZW50ID0gdGhpcy5fZ2V0UGFyZW50U2lnbmFsSGFuZGxlcigpO1xuICAgICAgICBpZiAoc2lnbmFsUGFyZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fX3NpZ25hbHMpIHtcbiAgICAgICAgICAgICAgICBsZXQgZmlyZUV2ZW50ID0gdGhpcy5fX3NpZ25hbHNbZXZlbnRdO1xuICAgICAgICAgICAgICAgIGlmIChmaXJlRXZlbnQgPT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIElnbm9yZSBldmVudC5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoZmlyZUV2ZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChmaXJlRXZlbnQgPT09IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpcmVFdmVudCA9IGV2ZW50O1xuICAgICAgICAgICAgICAgICAgICB9XG4gXG4gICAgICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc0Z1bmN0aW9uKGZpcmVFdmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaXJlRXZlbnQoLi4uYXJncyk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAoc2lnbmFsUGFyZW50Ll9oYXNNZXRob2QoZmlyZUV2ZW50KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNpZ25hbFBhcmVudFtmaXJlRXZlbnRdKC4uLmFyZ3MpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcGFzc1NpZ25hbCA9ICh0aGlzLl9fcGFzc1NpZ25hbHMgJiYgdGhpcy5fX3Bhc3NTaWduYWxzW2V2ZW50XSk7XG4gICAgICAgICAgICBpZiAocGFzc1NpZ25hbCkge1xuICAgICAgICAgICAgICAgIC8vIEJ1YmJsZSB1cC5cbiAgICAgICAgICAgICAgICBpZiAocGFzc1NpZ25hbCAmJiBwYXNzU2lnbmFsICE9PSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFJlcGxhY2Ugc2lnbmFsIG5hbWUuXG4gICAgICAgICAgICAgICAgICAgIGV2ZW50ID0gcGFzc1NpZ25hbDtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gc2lnbmFsUGFyZW50Ll9zaWduYWwoZXZlbnQsIGFyZ3MpO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AgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3Qgc2lnbmFsUGFyZW50ID0gdGhpcy5fZ2V0UGFyZW50U2lnbmFsSGFuZGxlcigpO1xuICAgICAgICAgICAgaWYgKHNpZ25hbFBhcmVudCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBzaWduYWxQYXJlbnQuX2RvRmlyZUFuY2VzdG9ycyhuYW1lLCBhcmdzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBjb2xsZWN0U3ViQ29tcG9uZW50cyhzdWJzLCBlbGVtZW50KSB7XG4gICAgICAgIGlmIChlbGVtZW50Lmhhc0NoaWxkcmVuKCkpIHtcbiAgICAgICAgICAgIGNvbnN0IGNoaWxkTGlzdCA9IGVsZW1lbnQuX19jaGlsZExpc3Q7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGNoaWxkTGlzdC5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZCA9IGNoaWxkTGlzdC5nZXRBdChpKTtcbiAgICAgICAgICAgICAgICBpZiAoY2hpbGQuaXNDb21wb25lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vicy5wdXNoKGNoaWxkKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBDb21wb25lbnQuY29sbGVjdFN1YkNvbXBvbmVudHMoc3VicywgY2hpbGQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBnZXRDb21wb25lbnQoZWxlbWVudCkge1xuICAgICAgICBsZXQgcGFyZW50ID0gZWxlbWVudDtcbiAgICAgICAgd2hpbGUgKHBhcmVudCAmJiAhcGFyZW50LmlzQ29tcG9uZW50KSB7XG4gICAgICAgICAgICBwYXJlbnQgPSBwYXJlbnQucGFyZW50O1xuICAgICAg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AgICAgICAgICAgICAgICAgbmV3U3RhdGU6IG5ld1N0YXRlLl9fcGF0aCxcbiAgICAgICAgICAgICAgICAgICAgcHJldlN0YXRlOiBwcmV2U3RhdGUuX19wYXRoLFxuICAgICAgICAgICAgICAgICAgICBzaGFyZWRTdGF0ZTogc2hhcmVkU3RhdGUuX19wYXRoXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBjb25zdCBzaGFyZWRMZXZlbCA9IHNoYXJlZFN0YXRlLl9fbGV2ZWw7XG5cbiAgICAgICAgICAgICAgICBpZiAoaGFzRGlmZmVyZW50RXhpdE1ldGhvZCkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBleGl0U3RhdGVzID0gU3RhdGVNYWNoaW5lLl9nZXRTdGF0ZXNVbnRpbExldmVsKHRoaXMuX3N0YXRlLCBzaGFyZWRMZXZlbCk7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gZXhpdFN0YXRlcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19zZXRTdGF0ZShleGl0U3RhdGVzW2ldKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbGxFeGl0KHRoaXMuX3N0YXRlLCBhcmdzLCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXRlQ2hhbmdlT3ZlcnJpZGRlbiA9ICh0aGlzLl9zZXRTdGF0ZUlkICE9PSBzZXRTdGF0ZUlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZUNoYW5nZU92ZXJyaWRkZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoaGFzRGlmZmVyZW50RW50ZXJNZXRob2QpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZW50ZXJTdGF0ZXMgPSBTdGF0ZU1hY2hpbmUuX2dldFN0YXRlc1VudGlsTGV2ZWwobmV3U3RhdGUsIHNoYXJlZExldmVsKS5yZXZlcnNlKCk7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gZW50ZXJTdGF0ZXMubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fc2V0U3RhdGUoZW50ZXJTdGF0ZXNbaV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FsbEVudGVyKHRoaXMuX3N0YXRlLCBhcmdzLCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXRlQ2hhbmdlT3ZlcnJpZGRlbiA9ICh0aGlzLl9zZXRTdGF0ZUlkICE9PSBzZXRTdGF0ZUlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZUNoYW5nZU92ZXJyaWRkZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fX3NldFN0YXRlKG5ld1N0YXRlKTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX2NoYW5nZWRTdGF0ZSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSB7XG4gICAgICAgICAgICAgICAgICAgIG5ld1N0YXRlOiBuZXdTdGF0ZS5fX3BhdGgsXG4gICAgICAgICAgICAgICAgICAgIHByZXZTdGF0ZTogcHJldlN0YXRlLl9fcGF0aFxuICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICBpZiAoYXJncykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGFuZ2VkU3RhdGUoY29udGV4dCwgLi4uYXJncyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hhbmdlZFN0YXRlKGNvbnRleHQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuX29uU3RhdGVDaGFuZ2UpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBjb250ZXh0ID0ge1xuICAgICAgICAgICAgICAgICAgICBuZXdTdGF0ZTogbmV3U3RhdGUuX19wYXRoLFxuICAgICAgICAgICAgICAgICAgICBwcmV2U3RhdGU6IHByZXZTdGF0ZS5fX3BhdGhcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIHRoaXMuX29uU3RhdGVDaGFuZ2UoY29udGV4dCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9jYWxsRW50ZXIoc3RhdGUsIGFyZ3MgPSBbXSwgY29udGV4dCkge1xuICAgICAgICBjb25zdCBoYXNQYXJlbnQgPSAhIXN0YXRlLl9fcGFyZW50O1xuICAgICAgICBpZiAoc3RhdGUucHJvdG90eXBlLiRlbnRlcikge1xuICAgICAgICAgICAgaWYgKCFoYXNQYXJlbnQgfHwgKHN0YXRlLl9fcGFyZW50LnByb3RvdHlwZS4kZW50ZXIgIT09IHN0YXRlLnByb3RvdHlwZS4kZW50ZXIpKSB7XG4gICAgICAgICAgICAgICAgc3RhdGUucHJvdG90eXBlLiRlbnRlci5hcHBseSh0aGlzLCBbY29udGV4dCwgLi4uYXJnc10pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2NhbGxFeGl0KHN0YXRlLCBhcmdzID0gW10sIGNvbnRleHQpIHtcbiAgICAgICAgY29uc3QgaGFzUGFyZW50ID0gISFzdGF0ZS5fX3BhcmV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1xuICAgICAgICAgICAgICAgIGNvbnN0IGRlc2NUeXBlID0gdGhpcy5fZ2V0RGVzY3JpcHRvclR5cGUoZGVzY3JpcHRvcik7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGUgJiYgKHR5cGUgIT09IGRlc2NUeXBlKSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oYFtMaWdodG5pbmddIE1lbWJlciAke21lbWJlcn0gaW4gJHt0aGlzLl90eXBlLm5hbWV9IGhhcyBpbmNvbnNpc3RlbnQgdHlwZXMuYCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdHlwZSA9IGRlc2NUeXBlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBzd2l0Y2godHlwZSkge1xuICAgICAgICAgICAgY2FzZSBcIm1ldGhvZFwiOlxuICAgICAgICAgICAgICAgIHRoaXMuX2FkZE1ldGhvZFJvdXRlcihtZW1iZXIsIGRlc2NyaXB0b3JzLCBhbGlhc2VzKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgXCJnZXR0ZXJcIjpcbiAgICAgICAgICAgICAgICB0aGlzLl9hZGRHZXR0ZXJTZXR0ZXJSb3V0ZXJzKG1lbWJlcik7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwicHJvcGVydHlcIjpcbiAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBGaXhlZCBwcm9wZXJ0aWVzIGFyZSBub3Qgc3VwcG9ydGVkOyBwbGVhc2UgdXNlIGEgZ2V0dGVyIGluc3RlYWQhXCIpXG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0RGVzY3JpcHRvcihzdGF0ZSwgbWVtYmVyLCBpc1ZhbGlkID0gKCkgPT4gdHJ1ZSkge1xuICAgICAgICBsZXQgdHlwZSA9IHN0YXRlO1xuICAgICAgICBsZXQgY3VyU3RhdGUgPSBzdGF0ZTtcblxuICAgICAgICBkbyB7XG4gICAgICAgICAgICBjb25zdCBkZXNjcmlwdG9yID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcih0eXBlLnByb3RvdHlwZSwgbWVtYmVyKTtcbiAgICAgICAgICAgIGlmIChkZXNjcmlwdG9yKSB7XG4gICAgICAgICAgICAgICAgaWYgKGlzVmFsaWQoZGVzY3JpcHRvcikpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRvci5fc291cmNlID0gY3VyU3RhdGU7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBkZXNjcmlwdG9yO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHR5cGUgPSBPYmplY3QuZ2V0UHJvdG90eXBlT2YodHlwZSk7XG4gICAgICAgICAgICBpZiAodHlwZSAmJiB0eXBlLmhhc093blByb3BlcnR5KCdfX3N0YXRlJykpIHtcbiAgICAgICAgICAgICAgICBjdXJTdGF0ZSA9IHR5cGU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gd2hpbGUodHlwZSAmJiB0eXBlLnByb3RvdHlwZSk7XG4gICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgfVxuXG4gICAgX2dldERlc2NyaXB0b3JUeXBlKGRlc2NyaXB0b3IpIHtcbiAgICAgICAgaWYgKGRlc2NyaXB0b3IuZ2V0IHx8IGRlc2NyaXB0b3Iuc2V0KSB7XG4gICAgICAgICAgICByZXR1cm4gJ2dldHRlcic7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIGRlc2NyaXB0b3IudmFsdWUgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgIHJldHVybiAnbWV0aG9kJztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4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9yIChsZXQgaSA9IDEsIG4gPSBhbGlhc2VzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3QgYWxpYXMgPSBhbGlhc2VzW2ldO1xuICAgICAgICAgICAgaWYgKGFsaWFzICE9PSBjdXIpIHtcbiAgICAgICAgICAgICAgICBpZiAoY3VyKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzdXBwb3J0c1NwcmVhZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIHJldHVybiB0aGlzW1wiJHtjdXJ9XCJdKC4uLmFyZ3VtZW50cyk7IGVsc2VgKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSByZXR1cm4gdGhpc1tcIiR7Y3VyfVwiXS5hcHBseSh0aGlzLCBhcmd1bWVudHMpOyBlbHNlYCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgcmV0dXJuIDsgZWxzZWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGN1ciA9IGFsaWFzO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjdXIpIHtcbiAgICAgICAgICAgIGlmIChzdXBwb3J0c1NwcmVhZCkge1xuICAgICAgICAgICAgICAgIGNvZGUucHVzaChgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl0oLi4uYXJndW1lbnRzKTtgKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29kZS5wdXNoKGByZXR1cm4gdGhpc1tcIiR7Y3VyfVwiXS5hcHBseSh0aGlzLCBhcmd1bWVudHMpO2ApO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGV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RlID0gdGhpcy5fc3RhdGVNYXBbc3RhdGVQYXRoXTtcbiAgICAgICAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSB0aGlzLl9nZXREZXNjcmlwdG9yKHN0YXRlLCBtZW1iZXIsIChkZXNjcmlwdG9yID0+IGRlc2NyaXB0b3IuZ2V0KSk7XG4gICAgICAgICAgICBpZiAoZGVzY3JpcHRvcikge1xuICAgICAgICAgICAgICAgIGRlc2NyaXB0b3JzW2luZGV4XSA9IGRlc2NyaXB0b3I7XG5cbiAgICAgICAgICAgICAgICAvLyBBZGQgdG8gcHJvdG90eXBlLlxuICAgICAgICAgICAgICAgIGNvbnN0IGFsaWFzID0gU3RhdGVNYWNoaW5lVHlwZS5nZXRTdGF0ZU1lbWJlckFsaWFzKGRlc2NyaXB0b3IuX3NvdXJjZS5fX3BhdGgsIG1lbWJlcik7XG4gICAgICAgICAgICAgICAgYWxpYXNlc1tpbmRleF0gPSBhbGlhcztcblxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fcm91dGVyLnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eShhbGlhcykpIHtcbiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMuX3JvdXRlci5wcm90b3R5cGUsIGFsaWFzLCBkZXNjcmlwdG9yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGRlc2NyaXB0b3JzW2luZGV4XSA9IG51bGw7XG4gICAgICAgICAgICAgICAgYWxpYXNlc1tpbmRleF0gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBjb25zdCBjb2RlID0gW1xuICAgICAgICAgICAgLy8gVGhlIGxpbmUgZW5zdXJlcyB0aGF0LCB3aGlsZSBkZWJ1Z2dpbmcsIHlvdXIgSURFIHdvbid0IG9wZW4gbWFueSB0YWJzLlxuICAgICAgICAgICAgXCIvL0Agc291cmNlVVJMPVN0YXRlTWFjaGluZVJvdXRlci5qc1wiLFxuICAgICAgICAgICAgXCJ2YXIgaSA9IHRoaXMuX3N0YXRlSW5kZXg7XCJcbiAgICAgICAgXTtcbiAgICAgICAgbGV0IGN1ciA9IGFsaWFzZXNbMF07XG4gICAgICAgIGZvciAobGV0IGkgPSAxLCBuID0gYWxpYXNlcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGFsaWFzID0gYWxpYXNlc1tpXTtcbiAgICAgICAgICAgIGlmIChhbGlhcyAhPT0gY3VyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGN1cikge1xuICAgICAgICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl07IGVsc2VgKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb2RlLnB1c2goYGlmIChpIDwgJHtpfSkgcmV0dXJuIDsgZWxzZWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGN1ciA9IGFsaWFzO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjdXIpIHtcbiAgICAgICAgICAgIGNvZGUucHVzaChgcmV0dXJuIHRoaXNbXCIke2N1cn1cIl07YCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb2RlLnB1c2goYDtgKTtcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBmdW5jdGlvbkJvZHkgPSBjb2RlLmpvaW4oXCJcXG5cIik7XG4gICAgICAgIGNvbnN0IHJvdXRlciA9IG5ldyBGdW5jdGlvbihbXSwgZnVuY3Rpb25Cb2R5KTtcbiAgICAgICAgcmV0dXJuIHJvdXRlcjtcbiAgICB9XG5cbiAgICBfZ2V0U2V0dGVyUm91dGVyKG1lbWJlcikge1xuICAgICAgICBjb25zdCBzdGF0ZVBhdGhzID0gT2JqZWN0LmtleXModGhpcy5fc3RhdGVNYXApO1xuICAgICAgICBjb25zdCBkZXNjcmlwdG9ycyA9IFtdO1xuICAgICAgICBjb25zdCBhbGlhc2VzID0gW107XG4gICAgICAgIHN0YXRlUGF0aHMuZm9yRWFjaCgoc3RhdGVQYXRoLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgY29uc3Qgc3RhdGUgPSB0aGlzLl9zdGF0ZU1hcFtzdGF0ZVBhdGhdO1xuICAgICAgICAgICAgY29uc3QgZGVzY3JpcHRvciA9IHRoaXMuX2dldERlc2NyaXB0b3Ioc3RhdGUsIG1lbWJlciwgKGRlc2NyaXB0b3IgPT4gZGVzY3JpcHRvci5zZXQpKTtcbiAgICAgICAgICAgIGlmIChkZXNjcmlwdG9yKSB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRvcnNbaW5kZXhdID0gZGVzY3JpcHRvcjtcblxuICAgICAgICAgICAgICAgIC8vIEFkZCB0byBwcm90b3R5cGUuXG4gICAgICAgICAgICAgICAgY29uc3QgYWxpYXMgPSBTdGF0ZU1hY2hpbmVUeXBlLmdldFN0YXRlTWVtYmVyQWxpYXMoZGVzY3JpcHRvci5fc291cmNlLl9fcGF0aCwgbWVtYmVyKTtcbiAgICAgICAgICAgICAgICBhbGlhc2VzW2luZGV4XSA9IGFsaWFzO1xuXG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yb3V0ZXIucHJvdG90eXBlLmhhc093blByb3BlcnR5KGFsaWFzKSkge1xuICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcy5fcm91dGVyLnByb3RvdHlwZSwgYWxpYXMsIGRlc2NyaXB0b3IpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRvcnNbaW5kZXhdID0gbnVsbDtcbiAgICAgICAgICAgICAgICBhbGlhc2VzW2luZGV4XSA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGNvbnN0IGNvZGUgPSBbXG4gICAgICAgICAgICAvLyBUaGUgbGluZSBlbnN1cmVzIHRoYXQsIHdoaWxlIGRlYnVnZ2luZywgeW91ciBJREUgd29uJ3Qgb3BlbiBtYW55IHRhYnMuXG4gICAgICAgICAgICBcIi8vQCBzb3VyY2VVUkw9U3RhdGVNYWNoaW5lUm91dGVyLmpzXCIsXG4gICAgICAgICAgICBcInZhciBpID0gdGhpcy5fc3RhdGVJbmRleDtcIlxuICAgICAgICBdO1xuICAgICAgICBsZXQgY3VyID0gYWxpYXNlc1swXTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDEsIG4gPSBhbGlhc2VzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3QgYWxpYXMgPSBhbGlhc2VzW2ldO1xuICAgICAgICAgICAgaWYgKGFsaWFzICE9PSBjdXIpIHtcbiAgICAgICAgICAgICAgICBpZiAoY3VyKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvZGUucHVzaChgaWYgKGkgPCAke2l9KSB0aGlzW1wiJHtjdXJ9XCJdID0gYXJnOyBlbHNlYCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29kZS5wdXNoKGBpZiAoaSA8ICR7aX0pIDsgZWxzZWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGN1ciA9IGFsaWFzO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjdXIpIHtcbiAgICAgICAgICAgIGNvZGUucHVzaChgdGhpc1tcIiR7Y3VyfVwiXSA9IGFyZztgKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvZGUucHVzaChgO2ApO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGZ1bmN0aW9uQm9keSA9IGNvZGUuam9pbihcIlxcblwiKTtcbiAgICAgICAgY29uc3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AgICAgICAgcmV0dXJuIHRoaXMuX2JvcmRlclRvcC5oO1xuICAgIH1cblxuICAgIGdldCBib3JkZXJXaWR0aFJpZ2h0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYm9yZGVyUmlnaHQudztcbiAgICB9XG5cbiAgICBnZXQgYm9yZGVyV2lkdGhCb3R0b20oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9ib3JkZXJCb3R0b20uaDtcbiAgICB9XG5cbiAgICBnZXQgYm9yZGVyV2lkdGhMZWZ0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYm9yZGVyTGVmdC53O1xuICAgIH1cblxuICAgIHNldCBib3JkZXJXaWR0aCh2KSB7XG4gICAgICAgIHRoaXMuYm9yZGVyV2lkdGhUb3AgPSB2O1xuICAgICAgICB0aGlzLmJvcmRlcldpZHRoUmlnaHQgPSB2O1xuICAgICAgICB0aGlzLmJvcmRlcldpZHRoQm90dG9tID0gdjtcbiAgICAgICAgdGhpcy5ib3JkZXJXaWR0aExlZnQgPSB2O1xuICAgIH1cblxuICAgIHNldCBib3JkZXJXaWR0aFRvcCh2KSB7XG4gICAgICAgIHRoaXMuX2JvcmRlclRvcC5oID0gdjtcbiAgICAgICAgdGhpcy5fYm9yZGVyVG9wLnZpc2libGUgPSAodiA+IDApO1xuICAgIH1cblxuICAgIHNldCBib3JkZXJXaWR0aFJpZ2h0KHYpIHtcbiAgICAgICAgdGhpcy5fYm9yZGVyUmlnaHQudyA9IHY7XG4gICAgICAgIHRoaXMuX2JvcmRlclJpZ2h0LnZpc2libGUgPSAodiA+IDApO1xuICAgIH1cblxuICAgIHNldCBib3JkZXJXaWR0aEJvdHRvbSh2KSB7XG4gICAgICAgIHRoaXMuX2JvcmRlckJvdHRvbS5oID0gdjtcbiAgICAgICAgdGhpcy5fYm9yZGVyQm90dG9tLnZpc2libGUgPSAodiA+IDApO1xuICAgIH1cblxuICAgIHNldCBib3JkZXJXaWR0aExlZnQodikge1xuICAgICAgICB0aGl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XRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgZm9yY2VaSW5kZXhDb250ZXh0OiB0cnVlLFxuICAgICAgICAgICAgcnR0OiB0cnVlLFxuICAgICAgICAgICAgVGV4dHdyYXA6IHtzaGFkZXI6IHt0eXBlOiBDMmRCbHVyU2hhZGVyfSwgQ29udGVudDoge319XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjb25zdHJ1Y3RvcihzdGFnZSkge1xuICAgICAgICBzdXBlcihzdGFnZSk7XG4gICAgICAgIHRoaXMuX3RleHR3cmFwID0gdGhpcy5zZWwoXCJUZXh0d3JhcFwiKTtcbiAgICAgICAgdGhpcy5fd3JhcHBlciA9IHRoaXMuc2VsKFwiVGV4dHdyYXA+Q29udGVudFwiKTtcblxuICAgICAgICB0aGlzLl9hbW91bnQgPSAwO1xuICAgICAgICB0aGlzLl9wYWRkaW5nWCA9IDA7XG4gICAgICAgIHRoaXMuX3BhZGRpbmdZID0gMDtcblxuICAgIH1cblxuICAgIHN0YXRpYyBnZXRTcGxpbmUoKSB7XG4gICAgICAgIGlmICghdGhpcy5fbXVsdGlTcGxpbmUpIHtcbiAgICAgICAgICAgIHRoaXMuX211bHRpU3BsaW5lID0gbmV3IE11bHRpU3BsaW5lKCk7XG4gICAgICAgICAgICB0aGlzLl9tdWx0aVNwbGluZS5wYXJzZShmYWxzZSwgezA6IDAsIDAuMjU6IDEuNSwgMC41OiA1LjUsIDAuNzU6IDE4LCAxOiAzOX0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl9tdWx0aVNwbGluZTtcbiAgICB9XG5cbiAgICBnZXQgY29udGVudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc2VsKCdUZXh0d3JhcD5Db250ZW50Jyk7XG4gICAgfVxuXG4gICAgc2V0IGNvbnRlbnQodikge1xuICAgICAgICB0aGlzLnNlbCgnVGV4dHdyYXA+Q29udGVudCcpLnBhdGNoKHYsIHRydWUpO1xuICAg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gICB9XG5cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICBsZXQgdiA9IE1hdGgubWluKDQsIE1hdGgubWF4KDAsIHRoaXMuX2Ftb3VudCkpO1xuICAgICAgICBpZiAodiA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5fdGV4dHdyYXAucmVuZGVyVG9UZXh0dXJlID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLl9vdXRwdXQuc2hhZGVyLm90aGVyVGV4dHVyZVNvdXJjZSA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLl9vdXRwdXQudmlzaWJsZSA9IGZhbHNlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fdGV4dHdyYXAucmVuZGVyVG9UZXh0dXJlID0gdHJ1ZTtcbiAgICAgICAgICAgIHRoaXMuX291dHB1dC52aXNpYmxlID0gdHJ1ZTtcblxuICAgICAgICAgICAgdGhpcy5nZXRMYXllcigwKS52aXNpYmxlID0gKHYgPiAwKTtcbiAgICAgICAgICAgIHRoaXMuZ2V0TGF5ZXIoMSkudmlzaWJsZSA9ICh2ID4gMSk7XG4gICAgICAgICAgICB0aGlzLmdldExheWVyKDIpLnZpc2libGUgPSAodiA+IDIpO1xuICAgICAgICAgICAgdGhpcy5nZXRMYXllcigzKS52aXNpYmxlID0gKHYgPiAzKTtcblxuICAgICAgICAgICAgaWYgKHYgPD0gMSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX291dHB1dC50ZXh0dXJlID0gdGhpcy5fdGV4dHdyYXAuZ2V0VGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX291dHB1dC5zaGFkZXIub3RoZXJUZXh0dXJlU291cmNlID0gdGhpcy5nZXRMYXllcigwKS5nZXRUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3V0cHV0LnNoYWRlci5hID0gdjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodiA8PSAyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3V0cHV0LnRleHR1cmUgPSB0aGlzLmdldExheWVyKDApLmdldFRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9vdXRwdXQuc2hhZGVyLm90aGVyVGV4dHVyZVNvdXJjZSA9IHRoaXMuZ2V0TGF5ZXIoMSkuZ2V0VGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX291dHB1dC5zaGFkZXIuYSA9IHYgLSAxO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh2IDw9IDMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vdXRwdXQudGV4dHVyZSA9IHRoaXMuZ2V0TGF5ZXIoMSkuZ2V0VGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX291dHB1dC5zaGFkZXIub3RoZXJUZXh0dXJlU291cmNlID0gdGhpcy5nZXRMYXllcigyKS5nZXRUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3V0cHV0LnNoYWRlci5hID0gdiAtIDI7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHYgPD0gNCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX291dHB1dC50ZXh0dXJlID0gdGhpcy5nZXRMYXllcigyKS5nZXRUZXh0dXJlKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5fb3V0cHV0LnNoYWRlci5vdGhlclRleHR1cmVTb3VyY2UgPSB0aGlzLmdldExheWVyKDMpLmdldFRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9vdXRwdXQuc2hhZGVyLmEgPSB2IC0gMztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldCBzaGFkZXIocykge1xuICAgICAgICBzdXBlci5zaGFkZXIgPSBzO1xuICAgICAgICBpZiAoIXRoaXMucmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4oXCJbTGlnaHRuaW5nXSBQbGVhc2UgZW5hYm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gIC8qKlxuICAgICAgICAgKiBTaG91bGQgdGhlIGxpc3QganVtcCB3aGVuIHNjcm9sbGluZyBiZXR3ZWVuIGVuZCB0byBzdGFydCwgb3Igc2hvdWxkIGl0IGJlIGNvbnRpbnVvdXMsIGxpa2UgYSBjYXJyb3VzZWw/XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9yb2xsID0gZmFsc2U7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEFsbG93cyByZXN0cmljdGluZyB0aGUgc3RhcnQgc2Nyb2xsIHBvc2l0aW9uLlxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fcm9sbE1pbiA9IDA7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEFsbG93cyByZXN0cmljdGluZyB0aGUgZW5kIHNjcm9sbCBwb3NpdGlvbi5cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX3JvbGxNYXggPSAwO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBEZWZpbml0aW9uIGZvciBhIGN1c3RvbSBhbmltYXRpb24gdGhhdCBpcyBhcHBsaWVkIHdoZW4gYW4gaXRlbSBpcyAocGFydGlhbGx5KSBzZWxlY3RlZC5cbiAgICAgICAgICogQHR5cGUgQW5pbWF0aW9uU2V0dGluZ3NcbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX3Byb2dyZXNzQW5pbWF0aW9uID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogSW52ZXJ0cyB0aGUgc2Nyb2xsaW5nIGRpcmVjdGlvbi5cbiAgICAgICAgICogQHR5cGUge2Jvb2xlYW59XG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9pbnZlcnREaXJlY3Rpb24gPSBmYWxzZTtcblxuICAgICAgICAvKipcbiAgICAgICAgICogTGF5b3V0IHRoZSBpdGVtcyBob3Jpem9udGFsbHkgb3IgdmVydGljYWxseT9cbiAgICAgICAgICogQHR5cGUge2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iAgICAgICAgdGhpcy5lbWl0KCd1bmZvY3VzJywgdGhpcy5nZXRFbGVtZW50KHRoaXMucmVhbEluZGV4KSwgdGhpcy5faW5kZXgsIHRoaXMucmVhbEluZGV4KTtcblxuICAgICAgICBpZiAoY2xvc2VzdCkge1xuICAgICAgICAgICAgLy8gU2Nyb2xsIHRvIHNhbWUgb2Zmc2V0IGNsb3Nlc3QgdG8gdGhlIGluZGV4LlxuICAgICAgICAgICAgbGV0IG9mZnNldCA9IFV0aWxzLmdldE1vZHVsb0luZGV4KGluZGV4LCBuRWxlbWVudHMpO1xuICAgICAgICAgICAgbGV0IG8gPSBVdGlscy5nZXRNb2R1bG9JbmRleCh0aGlzLmluZGV4LCBuRWxlbWVudHMpO1xuICAgICAgICAgICAgbGV0IGRpZmYgPSBvZmZzZXQgLSBvO1xuICAgICAgICAgICAgaWYgKGRpZmYgPiAwLjUgKiBuRWxlbWVudHMpIHtcbiAgICAgICAgICAgICAgICBkaWZmIC09IG5FbGVtZW50cztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZGlmZiA8IC0wLjUgKiBuRWxlbWVudHMpIHtcbiAgICAgICAgICAgICAgICBkaWZmICs9IG5FbGVtZW50cztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX2luZGV4ICs9IGRpZmY7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9pbmRleCA9IGluZGV4O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuX3JvbGwgfHwgKHRoaXMudmlld3BvcnRTaXplID4gdGhpcy5faXRlbVNpemUgKiBuRWxlbWVudHMpKSB7XG4gICAgICAgICAgICB0aGlzLl9pbmRleCA9IFV0aWxzLmdldE1vZHVsb0luZGV4KHRoaXMuX2luZGV4LCBuRWxlbWVudHMpO1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGRpcmVjdGlvbiA9ICh0aGlzLl9ob3Jpem9udGFsIF4gdGhpcy5faW52ZX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ZSAtIHYpIC8gdGhpcy5faXRlbVNpemUpIC0gZSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzID0gTWF0aC5jZWlsKHYgLyB0aGlzLl9pdGVtU2l6ZSk7XG4gICAgICAgICAgICBwcyA9IDEgKyAodiAvIHRoaXMuX2l0ZW1TaXplKSAtIHM7XG4gICAgICAgICAgICBlID0gTWF0aC5jZWlsKCh2IC0gdmlld3BvcnRTaXplKSAvIHRoaXMuX2l0ZW1TaXplKTtcbiAgICAgICAgICAgIHBlID0gZSAtICgodiAtIHZpZXdwb3J0U2l6ZSkgLyB0aGlzLl9pdGVtU2l6ZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3JvbGwgfHwgKHZpZXdwb3J0U2l6ZSA+IHRoaXMuX2l0ZW1TaXplICogbkVsZW1lbnRzKSkge1xuICAgICAgICAgICAgLy8gRG9uJ3Qgc2hvdyBhZGRpdGlvbmFsIGl0ZW1zLlxuICAgICAgICAgICAgaWYgKGUgPj0gbkVsZW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgZSA9IG5FbGVtZW50cyAtIDE7XG4gICAgICAgICAgICAgICAgcGUgPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHMgPj0gbkVsZW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgcyA9IG5FbGVtZW50cyAtIDE7XG4gICAgICAgICAgICAgICAgcHMgPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGUgPD0gLTEpIHtcbiAgICAgICAgICAgICAgICBlID0gMDtcbiAgICAgICAgICAgICAgICBwZSA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocyA8PSAtMSkge1xuICAgICAgICAgICAgICAgIHMgPSAwO1xuICAgICAgICAgICAgICAgIHBzID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBvZmZzZXQgPSAtZGlyZWN0aW9uICogcyAqIHRoaXMuX2l0ZW1TaXplO1xuXG4gICAgICAgIGxldCBpdGVtO1xuICAgICAgICBmb3IgKGxldCBpbmRleCA9IHM7IChkaXJlY3Rpb24gPT0gLTEgPyBpbmRleCA8PSBlIDogaW5kZXggPj0gZSk7IChkaXJlY3Rpb24gPT0gLTEgPyBpbmRleCsrIDogaW5kZXgtLSkpIHtcbiAgICAgICAgICAgIGxldCByZWFsSW5kZXggPSBVdGlscy5nZXRNb2R1bG9JbmRleChpbmRleCwgbkVsZW1lbnRzKTtcblxuICAgICAgICAgICAgbGV0IGVsZW1lbnQgPSB0aGlzLmdldEVsZW1lbnQocmVhbEluZGV4KTtcbiAgICAgICAgICAgIGl0ZW0gPSBlbGVtZW50LnBhcmVudDtcbiAgICAgICAgICAgIHRoaXMuX3Zpc2libGVJdGVtcy5kZWxldGUoaXRlbSk7XG4gICAgICAgICAgICBpZiAodGhpcy5faG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgICAgIGl0ZW0ueCA9IG9mZnNldCArIHNjcm9sbERlbHRhO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpdGVtLnkgPSBvZmZzZXQgKyBzY3JvbGxEZWx0YTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHdhc1Zpc2libGUgPSBpdGVtLnZpc2libGU7XG4gICAgICAgICAgICBpdGVtLnZpc2libGUgPSB0cnVlO1xuXG4gICAgICAgICAgICBpZiAoIXdhc1Zpc2libGUgfHwgdGhpcy5fcmVsb2FkVmlzaWJsZUVsZW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgLy8gVHVybmVkIHZpc2libGUuXG4gICAgICAgICAgICAgICAgdGhpcy5lbWl0KCd2aXNpYmxlJywgaW5kZXgsIHJlYWxJbmRleCk7XG4gICAgICAgICAgICB9XG5cblxuXG4gICAgICAgICAgICBpZiAodGhpcy5fcHJvZ3Jlc3NBbmltYXRpb24pIHtcbiAgICAgICAgICAgICAgICBsZXQgcCA9IDE7XG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09IHMpIHtcbiAgICAgICAgICAgICAgICAgICAgcCA9IHBzO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5kZXggPT0gZSkge1xuICAgICAgICAgICAgICAgICAgICBwID0gcGU7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gVXNlIGFuaW1hdGlvbiB0byBwcm9ncmVzcy5cbiAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0FuaW1hdGlvbi5hcHBseShlbGVtZW50LCBwKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgb2Zmc2V0ICs9IHRoaXMuX2l0ZW1TaXplO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gSGFuZGxlIGl0ZW0gdmlzaWJpbGl0eS5cbiAgICAgICAgbGV0IHNlbGYgPSB0aGlzO1xuICAgICAgICB0aGlzLl92aXNpYmxlSXRlbXMuZm9yRWFjaChmdW5jdGlvbihpbnZpc2libGVJdGVtKSB7XG4gICAgICAgICAgICBpbnZpc2libGVJdGVtLnZpc2libGUgPSBmYWxzZTtcbiAgICAgICAgICAgIHNlbGYuX3Zpc2libGVJdGVtcy5kZWxldGUoaW52aXNpYmxlSXRlbSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGZvciAobGV0IGluZGV4ID0gczsgKGRpcmVjdGlvbiA9PSAtMSA/IGluZGV4IDw9IGUgOiBpbmRleCA+PSBlKTsgKGRpcmVjdGlvbiA9PSAtMSA/IGluZGV4KysgOiBpbmRleC0tKSkge1xuICAgICAgICAgICAgbGV0IHJlYWxJbmRleCA9IFV0aWxzLmdldE1vZHVsb0luZGV4KGluZGV4LCBuRWxlbWVudHMpO1xuICAgICAgICAgICAgdGhpcy5fdmlzaWJsZUl0ZW1zLmFkZCh0aGlzLmdldFdyYXBwZXIocmVhbEluZGV4KSk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9yZWxvYWRWaXNpYmxlRWxlbWVudHMgPSBmYWxzZTtcbiAgICB9XG5cbiAgICBzZXRQcmV2aW91cygpIHtcbiAgICAgICAgdGhpcy5zZXRJbmRleCh0aGlzLl9pbmRleCAtIDEpO1xuICAgIH1cblxuICAgIHNldE5leHQoKSB7XG4gICAgICAgIHRoaXMuc2V0SW5kZXgodGhpcy5faW5kZXggKyAxKTtcbiAgICB9XG5cbiAgICBnZXRXcmFwcGVyKGluZGV4KSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93cmFwcGVyLmNoaWxkcmVuW2luZGV4XTtcbiAgICB9XG5cbiAgICBnZXRFbGVtZW50KGluZGV4KSB7XG4gICAgICAgIGxldCBlID0gdGhpcy5fd3JhcHBlci5jaGlsZHJlbltpbmRleF07XG4gICAgICAgIHJldHVybiBlID8gZS5jaGlsZHJlblswXSA6IG51bGw7XG4gICAgfVxuXG4gICAgcmVsb2FkKCkge1xuICAgICAgICB0aGlzLl9yZWxvYWRWaXNpYmxlRWxlbWVudHMgPSB0cnVlO1xuICAgICAgICB0aGlzLnVwZGF0ZSgpO1xuICAgIH1cblxuICAgIGdldCBlbGVtZW50KCkge1xuICAgICAgICBsZXQgZSA9IHRoaXMuX3dyYXBwZXIuY2hpbGRyZW5bdGhpcy5yZWFsSW5kZXhdO1xuICAgICAgICByZXR1cm4gZSA/IGUuY2hpbGRyZW5bMF0gOiBudWxsO1xuICAgIH1cblxuICAgIGdldCBsZW5ndGgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93cmFwcGVyLmNoaWxkcmVuLmxlbmd0aDtcbiAgICB9XG5cbiAgICBnZXQgcHJvcGVydHkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9ob3Jpem9udGFsID8gJ3gnIDogJ3knO1xuICAgIH1cblxuICAgIGdldCB2aWV3cG9ydFNpemUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9ob3Jpem9udGFsID8gdGhpcy53IDogdGhpcy5oO1xuICAgIH1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xuICAgICAgICAgICAgcGFyZW50LnZpc2libGUgPSBmYWxzZTtcbiAgICAgICAgICAgIHJldHVybiBwYXJlbnQ7XG4gICAgICAgIH0pXG5cbiAgICAgICAgc3VwZXIobGlzdC5fd3JhcHBlci5fY2hpbGRyZW4sIHdyYXApO1xuICAgICAgICB0aGlzLmxpc3QgPSBsaXN0O1xuICAgIH1cblxuICAgIG9uQWRkKGl0ZW0sIGluZGV4KSB7XG4gICAgICAgIHN1cGVyLm9uQWRkKGl0ZW0sIGluZGV4KTtcbiAgICAgICAgdGhpcy5jaGVja1N0YXJ0ZWQoaW5kZXgpO1xuICAgIH1cblxuICAgIGNoZWNrU3RhcnRlZChpbmRleCkge1xuICAgICAgICB0aGlzLmxpc3QuX3JlbG9hZFZpc2libGVFbGVtZW50cyA9IHRydWU7XG4gICAgICAgIGlmICghdGhpcy5saXN0Ll9zdGFydGVkKSB7XG4gICAgICAgICAgICB0aGlzLmxpc3Quc3RhcnQoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmxpc3QubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5saXN0LnNldEluZGV4KDAsIHRydWUsIHRydWUpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5saXN0Ll9pbmRleCA+PSB0aGlzLmxpc3QubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMubGlzdC5zZXRJbmRleCgwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmxpc3QudXBkYXRlKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBvblJlbW92ZShpdGVtLCBpbmRleCkge1xuICAgICAgICBzdXBlci5vblJlbW92ZShpdGVtLCBpbmRleCk7XG4gICAgICAgIGxldCByaSA9IHRoaXMubGlzdC5yZWFsSW5kZXg7XG4gICAgICAgIGlmIChya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G9uQWZ0ZXJVcGRhdGU6IFNtb290aFNjYWxlQ29tcG9uZW50Ll91cGRhdGVEaW1lbnNpb25zLFxuICAgICAgICAgICAgICAgIENvbnRlbnQ6IHt9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgU2NhbGU6IHt2aXNpYmxlOiBmYWxzZX1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGNvbnN0cnVjdG9yKHN0YWdlKSB7XG4gICAgICAgIHN1cGVyKHN0YWdlKTtcblxuICAgICAgICB0aGlzLl9zbW9vdGhTY2FsZSA9IDE7XG4gICAgICAgIHRoaXMuX2l0ZXJhdGlvbnMgPSAwO1xuICAgIH1cblxuICAgIGdldCBjb250ZW50KCkge1xuICAgICAgICByZXR1cm4gdGhpcy50YWcoJ0NvbnRlbnQnKTtcbiAgICB9XG5cbiAgICBzZXQgY29udGVudCh2KSB7XG4gICAgICAgIHRoaXMudGFnKCdDb250ZW50JykucGF0Y2godiwgdHJ1ZSk7XG4gICAgfVxuXG4gICAgZ2V0IHNtb290aFNjYWxlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fc21vb3RoU2NhbGU7XG4gICAgfVxuXG4gICAgc2V0IHNtb290aFNjYWxlKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3Ntb290aFNjYWxlICE9PSB2KSB7XG4gICAgICAgICAgICBsZXQgaXRzID0gMDtcbiAgICAgICAgICAgIHdoaWxlKHYgPCAwLjUgJiYgaXRzIDwgMTIpIHtcbiAgICAgICAgICAgICAgICBpdHMrKztcbiAgICAgICAgICAgICAgICB2ID0gdiAqIDI7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuc2NhbGUgPSB2O1xuICAgICAgICAgICAgdGhpcy5fc2V0SXRlcmF0aW9ucyhpdHMpO1xuXG4gICAgICAgICAgICB0aGlzLl9zbW9vdGhTY2FsZSA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfc2V0SXRlcmF0aW9ucyhpdHMpIHtcbiAgICAgICAgaWYgKHRoaXMuX2l0ZXJhdGlvbnMgIT09IGl0cykge1xuICAgICAgICAgICAgY29uc3Qgc2NhbGVycyA9IHRoaXMuc2VsKFwiU2NhbGVcIikuY2hpbGRMaXN0O1xuICAgICAgICAgICAgY29uc3QgY29udGVudCA9IHRoaXMuc2VsKFwiQ29udGVudFdyYXBcIik7XG4gICAgICAgICAgICB3aGlsZSAoc2NhbGVycy5sZW5ndGggPCBpdHMpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBmaXJzdCA9IHNjYWxlcnMubGVuZ3RoID09PSAwO1xuICAgICAgICAgICAgICAgIGNvbnN0IHRleHR1cmUgPSAoZmlyc3QgPyBjb250ZW50LmdldFRleHR1cmUoKSA6IHNjYWxlcnMubGFzdC5nZXRUZXh0dXJlKCkpO1xuICAgICAgICAgICAgICAgIHNjYWxlcnMuYSh7cnR0OiB0cnVlLCByZW5kZXJPZmZzY3JlZW46IHRydWUsIHRleHR1cmU6IHRleHR1cmV9KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgU21vb3RoU2NhbGVDb21wb25lbnQuX3VwZGF0ZURpbWVuc2lvbnModGhpcy50YWcoXCJDb250ZW50V3JhcFwiKSwgdHJ1ZSk7XG5cbiAgICAgICAgICAgIGNvbnN0IHVzZVNjYWxlcnMgPSAoaXRzID4gMCk7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBDb250ZW50V3JhcDoge3JlbmRlclRvVGV4dHVyZTogdXNlU2NhbGVyc30sXG4gICAgICAgICAgICAgICAgU2NhbGU6IHt2aXNpYmxlOiB1c2VTY2FsZXJzfVxuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gc2NhbGVycy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBzY2FsZXJzLmdldEF0KGkpLnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgdmlzaWJsZTogaSA8IGl0cyxcbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyT2Zmc2NyZWVuOiBpICE9PSBpdHMgLSAxXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9pdGVyYXRpb25zID0gaXRzO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc3RhdGljIF91cGRhdGVEaW1lbnNpb25zKGNvbnRlbnRXcmFwLCBmb3JjZSkge1xuICAgICAgICBjb25zdCBjb250ZW50ID0gY29udGVudFdyYXAuY2hpbGRyZW5bMF07XG4gICAgICAgIGxldCB3ID0gY29udGVudC5yZW5kZXJXaWR0aDtcbiAgICAgICAgbGV0IGggPSBjb250ZW50LnJlbmRlckhlaWdodDtcbiAgICAgICAgaWYgKHcgIT09IGNvbnRlbnRXcmFwLncgfHwgaCAhPT0gY29udGVudFdyYXAuaCB8fCBmb3JjZSkge1xuICAgICAgICAgICAgY29udGVudFdyYXAudyA9IHc7XG4gICAgICAgICAgICBjb250ZW50V3JhcC5oID0gaDtcblxuICAgICAgICAgICAgY29uc3Qgc2NhbGVycyA9IGNvbnRlbnRXcmFwLnBhcmVudC50YWcoXCJTY2FsZVwiKS5jaGlsZHJlbjtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gc2NhbGVycy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB3ID0gdyAqIDAuNTtcbiAgICAgICAgICAgICAgICBoID0gaCAqIDAuNTtcbiAgICAgICAgICAgICAgICBzY2FsZXJzW2ldLncgPSB3O1xuICAgICAgICAgICAgICAgIHNjYWxlcnNbaV0uaCA9IGg7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgX3NpZ25hbFByb3h5KCkge1xuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbn1cbiIsIi8qXG4gKiBJZiBub3Qgc3RhdGVkIG90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i1yZXZlcnNlXCIgOiBcIlwiKTtcbiAgICB9XG5cbiAgICBzZXQgZGlyZWN0aW9uKGYpIHtcbiAgICAgICAgaWYgKHRoaXMuZGlyZWN0aW9uID09PSBmKSByZXR1cm47XG5cbiAgICAgICAgdGhpcy5faG9yaXpvbnRhbCA9IChmID09PSAncm93JyB8fCBmID09PSAncm93LXJldmVyc2UnKTtcbiAgICAgICAgdGhpcy5fcmV2ZXJzZSA9IChmID09PSAncm93LXJldmVyc2UnIHx8IGYgPT09ICdjb2x1bW4tcmV2ZXJzZScpO1xuXG4gICAgICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICAgIH1cblxuICAgIHNldCB3cmFwKHYpIHtcbiAgICAgICAgdGhpcy5fd3JhcCA9IHY7XG4gICAgICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICAgIH1cblxuICAgIGdldCB3cmFwKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fd3JhcDtcbiAgICB9XG5cbiAgICBnZXQgYWxpZ25JdGVtcygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2FsaWduSXRlbXM7XG4gICAgfVxuXG4gICAgc2V0IGFsaWduSXRlbXModikge1xuICAgICAgICBpZiAodGhpcy5fYWxpZ25JdGVtcyA9PT0gdikgcmV0dXJuO1xuICAgICAgICBpZiAoRmxleENvbnRhaW5lci5BTElHTl9JVEVNUy5pbmRleE9mKHYpID09PSAtMSkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5rbm93biBhbGlnbkl0ZW1zLCBvcHRpb25zOiBcIiArIEZsZXhDb250YWluZXIuQUxJR05fSVRFTVMuam9pbihcIixcIikpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2FsaWduSXRlbXMgPSB2O1xuXG4gICAgICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICAgIH1cblxuICAgIGdldCBhbGlnbkNvbnRlbnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9hbGlnbkNvbnRlbnQ7XG4gICAgfVxuXG4gICAgc2V0IGFsaWduQ29udGVudCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9hbGlnbkNvbnRlbnQgPT09IHYpIHJldHVybjtcbiAgICAgICAgaWYgKEZsZXhDb250YWluZXIuQUxJR05fQ09OVEVOVC5pbmRleE9mKHYpID09PSAtMSkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5rbm93biBhbGlnbkNvbnRlbnQsIG9wdGlvbnM6IFwiICsgRmxleENvbnRhaW5lci5BTElHTl9DT05URU5ULmpvaW4oXCIsXCIpKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9hbGlnbkNvbnRlbnQgPSB2O1xuXG4gICAgICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICAgIH1cblxuICAgIGdldCBqdXN0aWZ5Q29udGVudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2p1c3RpZnlDb250ZW50O1xuICAgIH1cblxuICAgIHNldCBqdXN0aWZ5Q29udGVudCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9qdXN0aWZ5Q29udGVudCA9PT0gdikgcmV0dXJuO1xuXG4gICAgICAgIGlmIChGbGV4Q29udGFpbmVyLkpVU1RJRllfQ09OVEVOVC5pbmRleE9mKHYpID09PSAtMSkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5rbm93biBqdXN0aWZ5Q29udGVudCwgb3B0aW9uczogXCIgKyBGbGV4Q29udGFpbmVyLkpVU1RJRllfQ09OVEVOVC5qb2luKFwiLFwiKSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fanVzdGlmeUNvbnRlbnQgPSB2O1xuXG4gICAgICAgIHRoaXMuX2NoYW5nZWRDb250ZW50cygpO1xuICAgIH1cblxuICAgIHNldCBwYWRkaW5nKHYpIHtcbiAgICAgICAgdGhpcy5wYWRkaW5nTGVmdCA9IHY7XG4gICAgIC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ucywgYW5kIGJ5IGRlZmF1bHQgbm90IHNocmlua2FibGUuXG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldCBzaHJpbmsodikge1xuICAgICAgICBpZiAodGhpcy5fc2hyaW5rID09PSB2KSByZXR1cm47XG5cbiAgICAgICAgdGhpcy5fc2hyaW5rID0gcGFyc2VJbnQodikgfHwgMDtcblxuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgfVxuXG4gICAgZ2V0IGFsaWduU2VsZigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2FsaWduU2VsZjtcbiAgICB9XG5cbiAgICBzZXQgYWxpZ25TZWxmKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2FsaWduU2VsZiA9PT0gdikgcmV0dXJuO1xuXG4gICAgICAgIGlmICh2ID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX2FsaWduU2VsZiA9IHVuZGVmaW5lZDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChGbGV4Q29udGFpbmVyLkFMSUdOX0lURU1TLmluZGV4T2YodikgPT09IC0xKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVW5rbm93biBhbGlnblNlbGYsIG9wdGlvbnM6IFwiICsgRmxleENvbnRhaW5lci5BTElHTl9JVEVNUy5qb2luKFwiLFwiKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9hbGlnblNlbGYgPSB2O1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgIH1cblxuICAgIGdldCBtaW5XaWR0aCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21pbldpZHRoO1xuICAgIH1cblxuICAgIHNldCBtaW5XaWR0aCh2KSB7XG4gICAgICAgIHRoaXMuX21pbldpZHRoID0gTWF0aC5tYXgoMCwgdik7XG4gICAgICAgIHR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0dGluZyhob3Jpem9udGFsKSB7XG4gICAgICAgIGlmIChob3Jpem9udGFsKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbWluV2lkdGg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fbWluSGVpZ2h0O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldE1heFNpemVTZXR0aW5nKGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYXhXaWR0aDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYXhIZWlnaHQ7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0TWFpbkF4aXNNaW5TaXplKCkge1xuICAgICAgICByZXR1cm4gRmxleFV0aWxzLmdldEF4aXNNaW5TaXplKHRoaXMuaXRlbSwgdGhpcy5jdHIuX2hvcml6b250YWwpO1xuICAgIH1cblxuICAgIF9nZXRDcm9zc0F4aXNNaW5TaXplKCkge1xuICAgICAgICByZXR1cm4gRmxleFV0aWxzLmdldEF4aXNNaW5TaXplKHRoaXMuaXRlbSwgIXRoaXMuY3RyLl9ob3Jpem9udGFsKTtcbiAgICB9XG5cbiAgICBfZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCkge1xuICAgICAgICByZXR1cm4gRmxleFV0aWxzLmdldEF4aXNMYXlvdXRTaXplKHRoaXMuaXRlbSwgdGhpcy5jdHIuX2hvcml6b250YWwpO1xuICAgIH1cblxuICAgIF9nZXRNYWluQXhpc0xheW91dFBvcygpIHtcbiAgICAgICAgcmV0dXJuIEZsZXhVdGlscy5nZXRBeGlzTGF5b3V0UG9zKHRoaXMuaXRlbSwgdGhpcy5jdHIuX2hvcml6b250YWwpO1xuICAgIH1cblxuICAgIF9zZXRNYWluQXhpc0xheW91dFBvcyhwb3MpIHtcbiAgICAgICAgcmV0dXJuIEZsZ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tcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB0YXJnZXQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl90YXJnZXQ7XG4gICAgfVxuXG4gICAgZ2V0IGZsZXgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mbGV4O1xuICAgIH1cblxuICAgIHNldCBmbGV4KHYpIHtcbiAgICAgICAgaWYgKCF2KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5pc0ZsZXhFbmFibGVkKCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9kaXNhYmxlRmxleCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRmxleEVuYWJsZWQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX2VuYWJsZUZsZXgoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX2ZsZXgucGF0Y2godik7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgZmxleEl0ZW0oKSB7XG4gICAgICAgIGlmICh0aGlzLl9mbGV4SXRlbURpc2FibGVkKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fZW5zdXJlRmxleEl0ZW0oKTtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZsZXhJdGVtO1xuICAgIH1cblxuICAgIHNldCBmbGV4SXRlbSh2KSB7XG4gICAgICAgIGlmICh2ID09PSBmYWxzZSkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLl9mbGV4SXRlbURpc2FibGVkKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcGFyZW50ID0gdGhpcy5mbGV4UGFyZW50O1xuICAgICAgICAgICAgICAgIHRoaXMuX2ZsZXhJdGVtRGlzYWJsZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoZWNrRW5hYmxlZCgpO1xuICAgICAgICAgICAgICAgIGlmIChwYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50Ll9jbGVhckZsZXhJdGVtc0NhY2hlKCk7XG4gICAgICAgICAgICAgICAgICAgIHBhcmVudC5jaGFuZ2VkQ29udGVudHMoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9lbnN1cmVGbGV4SXRlbSgpO1xuXG4gICAgICAgICAgICB0aGlzLl9mbGV4SXRlbS5wYXRjaCh2KTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX2ZsZXhJdGVtRGlzYWJsZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9mbGV4SXRlbURpc2FibGVkID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hlY2tFbmFibGVkKCk7XG4gICAgICAgICAgICAgICAgY29uc3QgcGFyZW50ID0gdGhpcy5mbGV4UGFyZW50O1xuICAgICAgICAgICAgICAgIGlmIChwYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50Ll9jbGVhckZsZXhJdGVtc0NhY2hlKCk7XG4gICAgICAgICAgICAgICAgICAgIHBhcmVudC5jaGFuZ2VkQ29udGVudHMoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZW5hYmxlRmxleCgpIHtcbiAgICAgICAgdGhpcy5fZmxleCA9IG5ldyBGbGV4Q29udGFpbmVyKHRoaXMpO1xuICAgICAgICB0aGlzLl9jaGVja0VuYWJsZWQoKTtcbiAgICAgICAgdGhpcy5jaGFuZ2VkRGltZW5zaW9ucygpO1xuICAgICAgICB0aGlzLl9lbmFibGVDaGlsZHJlbkFzRmxleEl0ZW1zKCk7XG4gICAgfVxuXG4gICAgX2Rpc2FibGVGbGV4KCkge1xuICAgICAgICB0aGlzLmNoYW5nZWREaW1lbnNpb25zKCk7XG4gICAg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zLl9vcmlnaW5hbEhlaWdodCk7XG4gICAgfVxuXG4gICAgX3NldHVwVGFyZ2V0Rm9yRmxleCgpIHtcbiAgICAgICAgY29uc3QgdGFyZ2V0ID0gdGhpcy5fdGFyZ2V0O1xuICAgICAgICB0aGlzLl9vcmlnaW5hbFggPSB0YXJnZXQuX3g7XG4gICAgICAgIHRoaXMuX29yaWdpbmFsWSA9IHRhcmdldC5feTtcbiAgICAgICAgdGhpcy5fb3JpZ2luYWxXaWR0aCA9IHRhcmdldC5fdztcbiAgICAgICAgdGhpcy5fb3JpZ2luYWxIZWlnaHQgPSB0YXJnZXQuX2g7XG4gICAgfVxuICAgIFxuICAgIHNldFBhcmVudChmcm9tLCB0bykge1xuICAgICAgICBpZiAoZnJvbSAmJiBmcm9tLmlzRmxleENvbnRhaW5lcigpKSB7XG4gICAgICAgICAgICBmcm9tLl9sYXlvdXQuX2NoYW5nZWRDaGlsZHJlbigpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRvICYmIHRvLmlzRmxleENvbnRhaW5lcigpKSB7XG4gICAgICAgICAgICB0aGlzLl9lbmFibGVGbGV4SXRlbSgpO1xuICAgICAgICAgICAgdG8uX2xheW91dC5fY2hhbmdlZENoaWxkcmVuKCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fY2hlY2tFbmFibGVkKCk7XG4gICAgfVxuXG4gICAgZ2V0IGZsZXhQYXJlbnQoKSB7XG4gICAgICAgIGlmICh0aGlzLl9mbGV4SXRlbURpc2FibGVkKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHBhcmVudCA9IHRoaXMuX3RhcmdldC5fcGFyZW50O1xuICAgICAgICBpZiAocGFyZW50ICYmIHBhcmVudC5pc0ZsZXhDb250YWluZXIoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHBhcmVudC5fbGF5b3V0O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cblxuICAgIHNldFZpc2libGUodikge1xuICAgICAgICBjb25zdCBwYXJlbnQgPSB0aGlzLmZsZXhQYXJlbnQ7XG4gICAgICAgIGlmIChwYXJlbnQpIHtcbiAgICAgICAgICAgIHBhcmVudC5fY2hhbmdlZENoaWxkcmVuKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgaXRlbXMoKSB7XG4gICAgICAgIGlmICghdGhpcy5faXRlbXMpIHtcbiAgICAgICAgICAgIHRoaXMuX2l0ZW1zID0gdGhpcy5fZ2V0RmxleEl0ZW1zKCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMuX2l0ZW1zO1xuICAgIH1cblxuICAgIF9nZXRGbGV4SXRlbXMoKSB7XG4gICAgICAgIGNvbnN0IGl0ZW1zID0gW107XG4gICAgICAgIGNvbnN0IGNoaWxkcmVuID0gdGhpcy5fdGFyZ2V0Ll9jaGlsZHJlbjtcbiAgICAgICAgaWYgKGNoaWxkcmVuKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGNoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBjaGlsZHJlbltpXTtcbiAgICAgICAgICAgICAgICBpZiAoaXRlbS52aXNpYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmlzRmxleEl0ZW0oKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMucHVzaChpdGVtLmxheW91dCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGl0ZW1zO1xuICAgIH1cblxuICAgIF9jaGFuZ2VkQ2hpbGRyZW4oKSB7XG4gICAgICAgIHRoaXMuX2NsZWFyRmxleEl0ZW1zQ2FjaGUoKTtcbiAgICAgICAgdGhpcy5jaGFuZ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ICAgICAgICAgICBjb25zdCBmbGV4UGFyZW50ID0gaXRlbS5mbGV4UGFyZW50O1xuICAgICAgICAgICAgaWYgKGZsZXhQYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAvLyBVc2UgcGVuZGluZyBsYXlvdXQgc2l6ZS5cbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRBeGlzTGF5b3V0U2l6ZShmbGV4UGFyZW50LCBob3Jpem9udGFsKSArIHRoaXMuZ2V0VG90YWxQYWRkaW5nKGZsZXhQYXJlbnQsIGhvcml6b250YWwpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBVc2UgJ2Fic29sdXRlJyBzaXplLlxuICAgICAgICAgICAgICAgIHJldHVybiBob3Jpem9udGFsID8gcGFyZW50LncgOiBwYXJlbnQuaDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBnZXRSZWxBeGlzU2l6ZShpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGlmIChob3Jpem9udGFsKSB7XG4gICAgICAgICAgICBpZiAoaXRlbS5mdW5jVykge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9hbGxvd1JlbEF4aXNTaXplRnVuY3Rpb24oaXRlbSwgdHJ1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0uZnVuY1codGhpcy5nZXRQYXJlbnRBeGlzU2l6ZVdpdGhQYWRkaW5nKGl0ZW0sIHRydWUpKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLm9yaWdpbmFsV2lkdGg7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoaXRlbS5mdW5jSCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9hbGxvd1JlbEF4aXNTaXplRnVuY3Rpb24oaXRlbSwgZmFsc2UpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtLmZ1bmNIKHRoaXMuZ2V0UGFyZW50QXhpc1NpemVXaXRoUGFkZGluZyhpdGVtLCBmYWxzZSkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW0ub3JpZ2luYWxIZWlnaHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgX2FsbG93UmVsQXhpc1NpemVGdW5jdGlvbihpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGNvbnN0IGZsZXhQYXJlbnQgPSBpdGVtLmZsZXhQYXJlbnQ7XG4gICAgICAgIGlmIChmbGV4UGFyZW50ICYmIGZsZXhQYXJlbnQuX2ZsZXguX2xheW91dC5pc0F4aXNGaXRUb0NvbnRlbnRzKGhvcml6b250YWwpKSB7XG4gICAgICAgICAgICAvLyBXZSBkb24ndCBhbGxvdyByZWxhdGl2ZSB3aWR0aCBvbiBmaXQtdG8tY29udGVudHMgYmVjYXVzZSBpdCBsZWFkcyB0byBjb25mbGljdHMuXG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgc3RhdGljIGlzWmVyb0F4aXNTaXplKGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgIHJldHVybiAhaXRlbS5vcmlnaW5hbFdpZHRoICYmICFpdGVtLmZ1bmNXO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgIC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nRhbCk7XG4gICAgICAgICAgICBpZiAoaXNNYWluQXhpcykge1xuICAgICAgICAgICAgICAgIGl0ZW0uX2ZsZXguX2xheW91dC5yZXNpemVNYWluQXhpcyhzaXplKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaXRlbS5fZmxleC5fbGF5b3V0LnJlc2l6ZUNyb3NzQXhpcyhzaXplKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuc2V0QXhpc0xheW91dFNpemUoaXRlbSwgaG9yaXpvbnRhbCwgc2l6ZSk7XG4gICAgICAgIH1cbiAgICB9XG5cblxuICAgIHN0YXRpYyBnZXRQYWRkaW5nT2Zmc2V0KGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKGl0ZW0uaXNGbGV4RW5hYmxlZCgpKSB7XG4gICAgICAgICAgICBjb25zdCBmbGV4ID0gaXRlbS5fZmxleDtcbiAgICAgICAgICAgIGlmIChob3Jpem9udGFsKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZsZXgucGFkZGluZ0xlZnQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4LnBhZGRpbmdUb3A7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBnZXRUb3RhbFBhZGRpbmcoaXRlbSwgaG9yaXpvbnRhbCkge1xuICAgICAgICBpZiAoaXRlbS5pc0ZsZXhFbmFibGVkKCkpIHtcbiAgICAgICAgICAgIGNvbnN0IGZsZXggPSBpdGVtLl9mbGV4O1xuICAgICAgICAgICAgaWYgKGhvcml6b250YWwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleC5wYWRkaW5nUmlnaHQgKyBmbGV4LnBhZGRpbmdMZWZ0O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmxleC5wYWRkaW5nVG9wICsgZmxleC5wYWRkaW5nQm90dG9tO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0TWFyZ2luT2Zmc2V0KGl0ZW0sIGhvcml6b250YWwpIHtcbiAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuICAgICAgICBpZiAoZmxleEl0ZW0pIHtcbiAgICAgICAgICAgIGlmIChob3Jpem9udGFsKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZsZXhJdGVtLm1hcmdpbkxlZnQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4SXRlbS5tYXJnaW5Ub3A7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBnZXRUb3RhbE1hcmdpbihpdGVtLCBob3Jpem9udGFsKSB7XG4gICAgICAgIGNvbnN0IGZsZXhJdGVtID0gaXRlbS5mbGV4SXRlbTtcbiAgICAgICAgaWYgKGZsZXhJdGVtKSB7XG4gICAgICAgICAgICBpZiAoaG9yaXpvbnRhbCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4SXRlbS5tYXJnaW5SaWdodCArIGZsZXhJdGVtLm1hcmdpbkxlZnQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiBmbGV4SXRlbS5tYXJnaW5Ub3AgKyBmbGV4SXRlbS5tYXJnaW5Cb3R0b207XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAg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vc3NBeGlzKCkge1xuICAgICAgICBjb25zdCBhbGlnbmVyID0gbmV3IENvbnRlbnRBbGlnbmVyKHRoaXMpO1xuICAgICAgICBhbGlnbmVyLmluaXQoKTtcbiAgICAgICAgdGhpcy5fdG90YWxDcm9zc0F4aXNTaXplID0gYWxpZ25lci50b3RhbENyb3NzQXhpc1NpemU7XG4gICAgICAgIHRoaXMuX2ZpdENyb3NzQXhpc1NpemVUb0NvbnRlbnRzKCk7XG4gICAgICAgIGFsaWduZXIuYWxpZ24oKTtcbiAgICB9XG5cbiAgICBfZml0Q3Jvc3NBeGlzU2l6ZVRvQ29udGVudHMoKSB7XG4gICAgICAgIGlmICghdGhpcy5fcmVzaXppbmdDcm9zc0F4aXMpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzQ3Jvc3NBeGlzRml0VG9Db250ZW50cygpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jcm9zc0F4aXNTaXplID0gdGhpcy5fdG90YWxDcm9zc0F4aXNTaXplO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgaXNXcmFwcGluZygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ZsZXhDb250YWluZXIud3JhcDtcbiAgICB9XG5cbiAgICBpc0F4aXNGaXRUb0NvbnRlbnRzKGhvcml6b250YWwpIHtcbiAgICAgICAgaWYgKHRoaXMuX2hvcml6b250YWwgPT09IGhvcml6b250YWwpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmlzTWFpbkF4aXNGaXRUb0NvbnRlbnRzKCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5pc0Nyb3NzQXhpc0ZpdFRvQ29udGVudHMoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGlzTWFpbkF4aXNGaXRUb0NvbnRlbnRzKCkge1xuICAgICAgICByZXR1cm4gIXRoaXMuaXNXcmFwcGluZygpICYmICF0aGlzLl9oYXNGaXh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ZyA9ICh0aGlzLl9jdXJNYWluQXhpc1BvcyArIGl0ZW1NYWluQXhpc1NpemUgPiB0aGlzLl9tYWluQXhpc1NpemUpO1xuICAgICAgICAgICAgICAgIGlmIChpc092ZXJmbG93aW5nKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2xheW91dExpbmUoc3RhcnRJbmRleCwgaSAtIDEpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jdXJNYWluQXhpc1BvcyA9IDA7XG4gICAgICAgICAgICAgICAgICAgIHN0YXJ0SW5kZXggPSBpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fYWRkVG9NYWluQXhpc1BvcyhpdGVtTWFpbkF4aXNTaXplKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChzdGFydEluZGV4IDwgaSkge1xuICAgICAgICAgICAgdGhpcy5fbGF5b3V0TGluZShzdGFydEluZGV4LCBpIC0gMSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfbGF5b3V0RmxleEl0ZW0oaXRlbSkge1xuICAgICAgICBpZiAoaXRlbS5pc0ZsZXhFbmFibGVkKCkpIHtcbiAgICAgICAgICAgIGl0ZW0uZmxleExheW91dC51cGRhdGVUcmVlTGF5b3V0KCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpdGVtLmZsZXhJdGVtLl9yZXNldExheW91dFNpemUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9zZXR1cCgpIHtcbiAgICAgICAgdGhpcy5fbWFpbkF4aXNTaXplID0gdGhpcy5fbGF5b3V0Lm1haW5BeGlzU2l6ZTtcbiAgICAgICAgdGhpcy5fY3VyTWFpbkF4aXNQb3MgPSAwO1xuICAgICAgICB0aGlzLl9tYXhNYWluQXhpc1BvcyA9IDA7XG4gICAgICAgIHRoaXMuX2xpbmVzID0gW107XG5cbiAgICAgICAgdGhpcy5fbWFpbkF4aXNNaW5TaXpl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5pbmdTcGFjZSkgLyBpdGVtR2FwcztcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgXCJzcGFjZS1hcm91bmRcIjpcbiAgICAgICAgICAgICAgICBpZiAocmVtYWluaW5nU3BhY2UgPCAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldFNwYWNpbmcoXCJjZW50ZXJcIiwgbnVtYmVyT2ZJdGVtcywgcmVtYWluaW5nU3BhY2UpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHNwYWNlUGVyR2FwID0gcmVtYWluaW5nU3BhY2UgLyAoaXRlbUdhcHMgKyAxKTtcbiAgICAgICAgICAgICAgICAgICAgc3BhY2luZ0JlZm9yZSA9IDAuNSAqIHNwYWNlUGVyR2FwO1xuICAgICAgICAgICAgICAgICAgICBzcGFjaW5nQmV0d2VlbiA9IHNwYWNlUGVyR2FwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgXCJzcGFjZS1ldmVubHlcIjpcbiAgICAgICAgICAgICAgICBpZiAocmVtYWluaW5nU3BhY2UgPCAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldFNwYWNpbmcoXCJjZW50ZXJcIiwgbnVtYmVyT2ZJdGVtcywgcmVtYWluaW5nU3BhY2UpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHNwYWNlUGVyR2FwID0gcmVtYWluaW5nU3BhY2UgLyAoaXRlbUdhcHMgKyAyKTtcbiAgICAgICAgICAgICAgICAgICAgc3BhY2luZ0JlZm9yZSA9IHNwYWNlUGVyR2FwO1xuICAgICAgICAgICAgICAgICAgICBzcGFjaW5nQmV0d2VlbiA9IHNwYWNlUGVyR2FwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztc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iO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGFsaWduICE9PSBcInN0cmV0Y2hcIiAmJiAhdGhpcy5faXNDcm9zc0F4aXNGaXRUb0NvbnRlbnRzKSB7XG4gICAgICAgICAgICBpZiAoZmxleEl0ZW0uX2hhc1JlbENyb3NzQXhpc1NpemUoKSkge1xuICAgICAgICAgICAgICAgIC8vIEFzIGNyb3NzIGF4aXMgc2l6ZSBtaWdodCBoYXZlIGNoYW5nZWQsIHdlIG5lZWQgdG8gcmVjYWxjIHRoZSByZWxhdGl2ZSBmbGV4IGl0ZW0ncyBzaXplLlxuICAgICAgICAgICAgICAgIGZsZXhJdGVtLl9yZXNldENyb3NzQXhpc0xheW91dFNpemUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHN3aXRjaChhbGlnbikge1xuICAgICAgICAgICAgY2FzZSBcImZsZXgtc3RhcnRcIjpcbiAgICAgICAgICAgICAgICB0aGlzLl9hbGlnbkl0ZW1GbGV4U3RhcnQoZmxleEl0ZW0pO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBcImZsZXgtZW5kXCI6XG4gICAgICAgICAgICAgICAgdGhpcy5fYWxpZ25JdGVtRmxleEVuZChmbGV4SXRlbSk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwiY2VudGVyXCI6XG4gICAgICAgICAgICAgICAgdGhpcy5fYWxpZ25JdGVtRmxleENlbnRlcihmbGV4SXRlbSk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIFwic3RyZXRjaFwiOlxuICAgICAgICAgICAgICAgIHRoaXMuX2FsaWduSXRlbVN0cmV0Y2goZmxleEl0ZW0pO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2FsaWduSXRlbUZsZXhTdGFydChmbGV4SXRlbSkge1xuICAgICAgICBm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gZ3JvdyhhbW91bnQpIHtcbiAgICAgICAgdGhpcy5fZ3Jvd25TaXplID0gMDtcblxuICAgICAgICB0aGlzLl9hbW91bnRSZW1haW5pbmcgPSBhbW91bnQ7XG4gICAgICAgIGxldCB0b3RhbEdyb3dBbW91bnQgPSB0aGlzLl9nZXRUb3RhbEdyb3dBbW91bnQoKTtcbiAgICAgICAgaWYgKHRvdGFsR3Jvd0Ftb3VudCkge1xuICAgICAgICAgICAgY29uc3QgaXRlbXMgPSB0aGlzLl9saW5lLml0ZW1zO1xuICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgIGxldCBhbW91bnRQZXJHcm93ID0gdGhpcy5fYW1vdW50UmVtYWluaW5nIC8gdG90YWxHcm93QW1vdW50O1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSB0aGlzLl9saW5lLnN0YXJ0SW5kZXg7IGkgPD0gdGhpcy5fbGluZS5lbmRJbmRleDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBpdGVtc1tpXTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBncm93QW1vdW50ID0gZmxleEl0ZW0uZ3JvdztcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNHcm93YWJsZUl0ZW0gPSAoZ3Jvd0Ftb3VudCA+IDApO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNHcm93YWJsZUl0ZW0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBncm93ID0gZ3Jvd0Ftb3VudCAqIGFtb3VudFBlckdyb3c7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXhTaXplID0gZmxleEl0ZW0uX2dldE1haW5BeGlzTWF4U2l6ZVNldHRpbmcoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF4U2l6ZSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2l6ZSA+PSBtYXhTaXplKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEFscmVhZHkgZnVsbHkgZ3Jvd24uXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3cgPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1heEdyb3cgPSBtYXhTaXplIC0gc2l6ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNGdWxseUdyb3duID0gKGdyb3cgPj0gbWF4R3Jvdyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0Z1bGx5R3Jvd24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3cgPSBtYXhHcm93O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBEZXN0cmlidXRlIHJlbWFpbmluZyBhbW91bnQgb3ZlciB0aGUgb3RoZXIgZmxleCBpdGVtcy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsR3Jvd0Ftb3VudCAtPSBncm93QW1vdW50O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ3JvdyA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaW5hbFNpemUgPSBzaXplICsgZ3JvdztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbGV4SXRlbS5fcmVzaXplTWFpbkF4aXMoZmluYWxTaXplKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2dyb3duU2l6ZSArPSBncm93O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Ftb3VudFJlbWFpbmluZyAtPSBncm93O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPCAxMGUtNikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSB3aGlsZSh0b3RhbEdyb3dBbW91bnQgJiYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPiAxMGUtNikpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldFRvdGFsR3Jvd0Ftb3VudCgpIHtcbiAgICAgICAgbGV0IHRvdGFsID0gMDtcbiAgICAgICAgY29uc3QgaXRlbXMgPSB0aGlzLl9saW5lLml0ZW1zO1xuICAgICAgICBmb3IgKGxldCBpID0gdGhpcy5fbGluZS5zdGFydEluZGV4OyBpIDw9IHRoaXMuX2xpbmUuZW5kSW5kZXg7IGkrKykge1xuICAgICAgICAgICAgY29uc3QgaXRlbSA9IGl0ZW1zW2ldO1xuICAgICAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuXG4gICAgICAgICAgICBpZiAoZmxleEl0ZW0uZ3Jvdykge1xuICAgICAgICAgICAgICAgIGNvbnN0IG1heFNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNNYXhTaXplU2V0dGluZygpO1xuICAgICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFp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JbmRleDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBpdGVtc1tpXTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmxleEl0ZW0gPSBpdGVtLmZsZXhJdGVtO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBzaHJpbmtBbW91bnQgPSBmbGV4SXRlbS5zaHJpbms7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzU2hyaW5rYWJsZUl0ZW0gPSAoc2hyaW5rQW1vdW50ID4gMCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc1Nocmlua2FibGVJdGVtKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2hyaW5rID0gc2hyaW5rQW1vdW50ICogYW1vdW50UGVyU2hyaW5rO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWluU2l6ZSA9IGZsZXhJdGVtLl9nZXRNYWluQXhpc01pblNpemUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNpemUgPSBmbGV4SXRlbS5fZ2V0TWFpbkF4aXNMYXlvdXRTaXplKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2l6ZSA+IG1pblNpemUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXhTaHJpbmsgPSBzaXplIC0gbWluU2l6ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0Z1bGx5U2hydW5rID0gKHNocmluayA+PSBtYXhTaHJpbmspO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0Z1bGx5U2hydW5rKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNocmluayA9IG1heFNocmluaztcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBEZXN0cmlidXRlIHJlbWFpbmluZyBhbW91bnQgb3ZlciB0aGUgb3RoZXIgZmxleCBpdGVtcy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxTaHJpbmtBbW91bnQgLT0gc2hyaW5rQW1vdW50O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbmFsU2l6ZSA9IHNpemUgLSBzaHJpbms7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxleEl0ZW0uX3Jlc2l6ZU1haW5BeGlzKGZpbmFsU2l6ZSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zaHJ1bmtTaXplICs9IHNocmluaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hbW91bnRSZW1haW5pbmcgLT0gc2hyaW5rO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKHRoaXMuX2Ftb3VudFJlbWFpbmluZykgPCAxMGUtNikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSB3aGlsZSh0b3RhbFNocmlua0Ftb3VudCAmJiAoTWF0aC5hYnModGhpcy5fYW1vdW50UmVtYWluaW5nKSA+IDEwZS02KSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfZ2V0VG90YWxTaHJpbmtBbW91bnQoKSB7XG4gICAgICAgIGxldCB0b3RhbCA9IDA7XG4gICAgICAgIGNvbnN0IGl0ZW1zID0gdGhpcy5fbGluZS5pdGVtcztcbiAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMuX2xpbmUuc3RhcnRJbmRleDsgaSA8PSB0aGlzLl9saW5lLmVuZEluZGV4OyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBpdGVtc1tpXTtc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19KTtcblxuICAgICAgICB0aGlzLl93b3JrZXIub25tZXNzYWdlID0gKGUpID0+IHtcbiAgICAgICAgICAgIGlmIChlLmRhdGEgJiYgZS5kYXRhLmlkKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgaWQgPSBlLmRhdGEuaWQ7XG4gICAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IHRoaXMuX2l0ZW1zLmdldChpZCk7XG4gICAgICAgICAgICAgICAgaWYgKGl0ZW0pIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGUuZGF0YS50eXBlID09ICdkYXRhJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maW5pc2goaXRlbSwgZS5kYXRhLmluZm8pO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lcnJvcihpdGVtLCBlLmRhdGEuaW5mbyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjcmVhdGUoc3JjKSB7XG4gICAgICAgIGNvbnN0IGlkID0gKyt0aGlzLl9pZDtcbiAgICAgICAgY29uc3QgaXRlbSA9IG5ldyBJbWFnZVdvcmtlckltYWdlKHRoaXMsIGlkLCBzcmMpO1xuICAgICAgICB0aGlzLl9pdGVtcy5zZXQoaWQsIGl0ZW0pO1xuICAgICAgICB0aGlzLl93b3JrZXIucG9zdE1lc3NhZ2Uoe3R5cGU6IFwiYWRkXCIsIGlkOiBpZCwgc3JjOiBzcmN9KTtcbiAgICAgICAgcmV0dXJuIGl0ZW07XG4gICAgfVxuXG4gICAgY2FuY2VsKGltYWdlKSB7XG4gICAgICAgIHRoaXMuX3dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTogXCJjYW5jZWxcIiwgaWQ6IGltYWdlLmlkfSk7XG4gICAgICAgIHRoaXMuX2l0ZW1zLmRlbGV0ZShpbWFnZS5p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ICAgICB0eXBlOiBcImRhdGFcIixcbiAgICAgICAgICAgIGlkOiBpdGVtLmlkLFxuICAgICAgICAgICAgaW5mbzoge1xuICAgICAgICAgICAgICAgIGltYWdlQml0bWFwLFxuICAgICAgICAgICAgICAgIGhhc0FscGhhQ2hhbm5lbFxuICAgICAgICAgICAgfVxuICAgICAgICB9LCBbaW1hZ2VCaXRtYXBdKTtcbiAgICAgICAgdGhpcy5pdGVtcy5kZWxldGUoaXRlbS5pZCk7XG4gICAgfTtcblxuICAgIEltYWdlV29ya2VyU2VydmVyLnByb3RvdHlwZS5lcnJvciA9IGZ1bmN0aW9uKGl0ZW0sIHt0eXBlLCBtZXNzYWdlfSkge1xuICAgICAgICBwb3N0TWVzc2FnZSh7XG4gICAgICAgICAgICB0eXBlOiBcImVycm9yXCIsXG4gICAgICAgICAgICBpZDogaXRlbS5pZCxcbiAgICAgICAgICAgIGluZm86IHtcbiAgICAgICAgICAgICAgICB0eXBlLFxuICAgICAgICAgICAgICAgIG1lc3NhZ2VcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuaXRlbXMuZGVsZXRlKGl0ZW0uaWQpO1xuICAgIH07XG5cbiAgICBJbWFnZVdvcmtlclNlcnZlci5pc1dQRUJyb3dzZXIgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIChuYXZpZ2F0b3IudXNlckFnZW50LmluZGV4T2YoXCJXUEVcIikgIT09IC0xKTtcbiAgICB9O1xuXG4gICAgZnVuY3Rpb24gSW1hZ2VXb3JrZXJTZXJ2ZXJJdGVtKGlkLCBzcmMpIHtcblxuICAgICAgICB0aGlzLl9vbkVycm9yID0gdW5kZWZpbmVkO1xuICAgICAgICB0aGlzLl9vbkZpbmlzaCA9IHVuZGVmaW5lZDtcbiAgICAgICAgdGhpcy5faWQgPSBpZDtcbiAgICAgICAgdGhpcy5fc3JjID0gc3JjO1xuICAgICAgICB0aGlzLl94aHIgPSB1bmRlZmluZWQ7XG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nN0YWdlLnVwZGF0ZUZyYW1lKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5zdGFnZS5pZGxlRnJhbWUoKTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zdGFnZS5jdHguaGFzUmVuZGVyVXBkYXRlcygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNsZWFySW50ZXJ2YWwodGhpcy5fbG9vcEhhbmRsZXIpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0TG9vcCgpO1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9LCAxMDAwIC8gNjApO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5faWRsZUxvb3BDb3VudGVyID0gMDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGxvb3AoKSB7XG4gICAgICAgIGxldCBzZWxmID0gdGhpcztcbiAgICAgICAgbGV0IGxwID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgc2VsZi5fYXdhaXRpbmdMb29wID0gZmFsc2U7XG4gICAgICAgICAgICBzZWxmLl9vbklkbGUgPSBmYWxzZTtcbiAgICAgICAgICAgIGlmIChzZWxmLl9sb29waW5nKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5zdGFnZS51cGRhdGVGcmFtZSgpO1xuICAgICAgICAgICAgICAgIGlmIChzZWxmLnN0YWdlLmdldE9wdGlvbihcInBhdXNlUmFmTG9vcE9uSWRsZVwiKSkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnN3aXRjaExvb3AoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2VsZi5zdGFnZS5yZW5kZXJGcmFtZSgpO1xuICAgICAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShscCk7XG4gICAgICAgICAgICAgICAgc2VsZi5fYXdhaXRpbmdMb29wID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXF1ZXN0QW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ZTtcbiAgICAgICAgICAgIHZhciB2aWV3ID0gbmV3IERhdGFWaWV3KGFycmF5YnVmZmVyKTtcblxuICAgICAgICAgICAgLy8gaWRlbnRpZmllciwgYmlnIGVuZGlhblxuICAgICAgICAgICAgdmFyIHRhcmdldElkZW50aWZpZXIgPSAzNjMyNzAxNDY5XG4gICAgICAgICAgICBpZiAodGFyZ2V0SWRlbnRpZmllciAhPT0gKHZpZXcuZ2V0VWludDMyKDApICsgdmlldy5nZXRVaW50MzIoNCkgKyB2aWV3LmdldFVpbnQzMig4KSkpIHtcbiAgICAgICAgICAgICAgICBjYignUGFyc2luZyBmYWlsZWQ6IGlkZW50aWZpZXIga3R4IG1pc21hdGNoOicsIHNyYylcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIGxpdHRsZUVuZGlhbiA9ICh2aWV3LmdldFVpbnQzMigxMikgPT09IDE2OTA5MDYwKSA/IHRydWUgOiBmYWxzZTtcbiAgICAgICAgICAgIHZhciBkYXRhID0ge1xuICAgICAgICAgICAgICAgIGdsVHlwZTogdmlldy5nZXRVaW50MzIoMTYsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgZ2xUeXBlU2l6ZTogdmlldy5nZXRVaW50MzIoMjAsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgZ2xGb3JtYXQ6IHZpZXcuZ2V0VWludDMyKDI0LCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIGdsSW50ZXJuYWxGb3JtYXQ6IHZpZXcuZ2V0VWludDMyKDI4LCBsaXR0bGVFbmRpYW4pLFxuICAgICAgICAgICAgICAgIGdsQmFzZUludGVybmFsRm9ybWF0OiB2aWV3LmdldFVpbnQzMigzMiwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBwaXhlbFdpZHRoOiB2aWV3LmdldFVpbnQzMigzNiwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBwaXhlbEhlaWdodDogdmlldy5nZXRVaW50MzIoNDAsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgcGl4ZWxEZXB0aDogdmlldy5nZXRVaW50MzIoNDQsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgbnVtYmVyT2ZBcnJheUVsZW1lbnRzOiB2aWV3LmdldFVpbnQzMig0OCwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBudW1iZXJPZkZhY2VzOiB2aWV3LmdldFVpbnQzMig1MiwgbGl0dGxlRW5kaWFuKSxcbiAgICAgICAgICAgICAgICBudW1iZXJPZk1pcG1hcExldmVsczogdmlldy5nZXRVaW50MzIoNTYsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAgYnl0ZXNPZktleVZhbHVlRGF0YTogdmlldy5nZXRVaW50MzIoNjAsIGxpdHRsZUVuZGlhbiksXG4gICAgICAgICAgICAgICAga3ZwczogW10sXG4gICAgICAgICAgICAgICAgbWlwbWFwczogW10sXG4gICAgICAgICAgICAgICAgZ2V0IHdpZHRoKCkgeyByZXR1cm4gdGhpcy5waXhlbFdpZHRoIH0sXG4gICAgICAgICAgICAgICAgZ2V0IGhlaWdodCgpIHsgcmV0dXJuIHRoaXMucGl4ZWxIZWlnaHQgfSxcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIGNvbnN0IHByb3BzID0gKG9iaikgPT4ge1xuICAgICAgICAgICAgICAgIGNvbnN0IHAgPSBbXTtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCB2IGluIG9iaikge1xuICAgICAgICAgICAgICAgICAgICBwLnB1c2gob2JqW3ZdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHA7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNvbnN0IGZvcm1hdHMgPSBPYmplY3QudmFsdWVzKHNlbGYuc3RhZ2UucmVuZGVyZXIuZ2V0Q29tcHJlc3NlZFRleHR1cmVFeHRlbnNpb25zKCkpXG4gICAgICAgICAgICAgICAgLmZpbHRlcigob2JqKSA9PiBvYmogIT0gbnVsbClcbiAgICAgICAgICAgICAgICAubWFwKChvYmopID0+IHByb3BzKG9iaikpXG4gICAgICAgICAgICAgICAgLnJlZHVjZSgocHJldiwgY3VycmVudCkgPT4gcHJldi5jb25jYXQoY3VycmVudCkpO1xuXG4gICAgICAgICAgICBpZiAoIWZvcm1hdHMuaW5jbHVkZXMoZGF0YS5nbEludGVybmFsRm9ybWF0KSkge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVucmVjb2duaXplZCB0ZXh0dXJlIGV4dGVuc2lvbiBmb3JtYXQ6XCIsIHNyYywgZGF0YS5nbEludGVybmFsRm9ybWF0LCBzZWxmLnN0YWdlLnJlbmRlcmVyLmdldENvbXByZXNzZWRUZXh0dXJlRXh0ZW5zaW9ucygpKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIG9mZnNldCA9IDY0XG4gICAgICAgICAgICAvLyBLZXkgVmFsdWUgUGFpcnMgb2YgZGF0YSBzdGFydCBhdCBieXRlIG9mZnNldCA2NFxuICAgICAgICAgICAgLy8gQnV0IHRoZSBvbmx5IGtub3duIGt2cCBpcyB0aGUgQVBJIHZlcnNpb24sIHNvIHNraXBwaW5nIHBhcnNpbmcuXG4gICAgICAgICAgICBvZmZzZXQgKz0gZGF0YS5ieXRlc09mS2V5VmFsdWVEYXRhO1xuXG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGRhdGEubnVtYmVyT2ZNaXBtYXBMZXZlbHM7IGkrKykge1xuICAgICAgICAgICAgICAgIHZhciBpbWFnZVNpemUgPSB2aWV3LmdldFVpbnQzMihvZmZzZXQpO1xuICAgICAgICAgICAgICAgIG9mZnNldCArPSA0O1xuICAgICAgICAgICAgICAgIGRhdGEubWlwbWFwcy5wdXNoKHZpZXcuYnVmZmVyLnNsaWNlKG9mZnN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ldyBVaW50OEFycmF5KGFycmF5QnVmZmVyLCBkYXRhT2Zmc2V0KTtcblxuICAgICAgICAgICAgdmFyIGRhdGEgPSB7XG4gICAgICAgICAgICAgICAgZ2xJbnRlcm5hbEZvcm1hdDogcHZyRm9ybWF0RXRjMSxcbiAgICAgICAgICAgICAgICBwaXhlbFdpZHRoOiBoZWFkZXJbcHZyV2lkdGhdLFxuICAgICAgICAgICAgICAgIHBpeGVsSGVpZ2h0OiBoZWFkZXJbcHZySGVpZ2h0XSxcbiAgICAgICAgICAgICAgICBudW1iZXJPZk1pcG1hcExldmVsczogaGVhZGVyW3B2ck1pcG1hcENvdW50XSxcbiAgICAgICAgICAgICAgICBtaXBtYXBzOiBbXSxcbiAgICAgICAgICAgICAgICBwdnI6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0IHdpZHRoKCkgeyByZXR1cm4gdGhpcy5waXhlbFdpZHRoIH0sXG4gICAgICAgICAgICAgICAgZ2V0IGhlaWdodCgpIHsgcmV0dXJuIHRoaXMucGl4ZWxIZWlnaHQgfSxcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIGxldCBvZmZzZXQgPSAwXG4gICAgICAgICAgICBsZXQgd2lkdGggPSBkYXRhLnBpeGVsV2lkdGg7XG4gICAgICAgICAgICBsZXQgaGVpZ2h0ID0gZGF0YS5waXhlbEhlaWdodDtcblxuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBkYXRhLm51bWJlck9mTWlwbWFwTGV2ZWxzOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjb25zdCBsZXZlbCA9ICgod2lkdGggKyAzKSA+PiAyKSAqICgoaGVpZ2h0ICsgMykgPj4gMikgKiA4O1xuICAgICAgICAgICAgICAgIGNvbnN0IHZpZXcgPSBuZXcgVWludDhBcnJheShhcnJheUJ1ZmZlciwgcHZydGNEYXRhLmJ5dGVPZmZzZXQgKyBvZmZzZXQsIGxldmVsKTtcbiAgICAgICAgICAgICAgICBkYXRhL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FwiR0VUXCIsIHNyYyk7XG4gICAgICAgICAgICByZXF1ZXN0LnJlc3BvbnNlVHlwZSA9IFwiYXJyYXlidWZmZXJcIjtcbiAgICAgICAgICAgIHJlcXVlc3Quc2VuZCgpO1xuICAgICAgICAgICAgY2FuY2VsQ2IgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgcmVxdWVzdC5hYm9ydCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2ltYWdlV29ya2VyKSB7XG4gICAgICAgICAgICAvLyBXUEUtc3BlY2lmaWMgaW1hZ2UgcGFyc2VyLlxuICAgICAgICAgICAgY29uc3QgaW1hZ2UgPSB0aGlzLl9pbWFnZVdvcmtlci5jcmVhdGUoc3JjKTtcbiAgICAgICAgICAgIGltYWdlLm9uRXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNiKFwiSW1hZ2UgbG9hZCBlcnJvclwiKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpbWFnZS5vbkxvYWQgPSBmdW5jdGlvbiAoeyBpbWFnZUJpdG1hcCwgaGFzQWxwaGFDaGFubmVsIH0pIHtcbiAgICAgICAgICAgICAgICBjYihudWxsLCB7XG4gICAgICAgICAgICAgICAgICAgIHNvdXJjZTogaW1hZ2VCaXRtYXAsXG4gICAgICAgICAgICAgICAgICAgIHJlbmRlckluZm86IHsgc3JjOiBzcmMsIGNvbXByZXNzZWQ6IGZhbHNlIH0sXG4gICAgICAgICAgICAgICAgICAgIGhhc0FscGhhOiBoYXNBbHBoYUNoYW5uZWwsXG4gICAgICAgICAgICAgICAgICAgIHByZW11bHRpcGx5QWxwaGE6IHRydWVcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBjYW5jZWxDYiA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpbWFnZS5jYW5jZWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGxldCBpbWFnZSA9IG5ldyBJbWFnZSgpO1xuXG4gICAgICAgICAgICAvLyBPbiB0aGUgUFM0IHBsYXRmb3JtIHNldHRpbmcgdGhlIGBjcm9zc09yaWdpbmAgYXR0cmlidXRlIG9uXG4gICAgICAgICAgICAvLyBpbWFnZXMgY2FuIGNhdXNlIENPUlMgZmFpbHVyZXMuXG4gICAgICAgICAgICBpZiAoIShzcmMuc3Vic3RyKDAsIDUpID09IFwiZGF0YTpcIikgJiYgIVV0aWxzLmlzUFM0KSB7XG4gICAgICAgICAgICAgICAgLy8gQmFzZTY0LlxuICAgICAgICAgICAgICAgIGltYWdlLmNyb3NzT3JpZ2luID0gXCJBbm9ueW1vdXNcIjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGltYWdlLm9uZXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgLy8gSWdub3JlIGVycm9yIG1lc3NhZ2Ugd2hlbiBjYW5jZWxsZWQuXG4gICAgICAgICAgICAgICAgaWYgKGltYWdlLnNyYykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2IoXCJJbWFnZSBsb2FkIGVycm9yXCIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpbWFnZS5vbmxvYWQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IGltYWdlLFxuICAgICAgICAgICAgICAgICAgICByZW5kZXJJbmZvOiB7IHNyYzogc3JjLCBjb21wcmVzc2VkOiBmYWxzZSB9LFxuICAgICAgICAgICAgICAgICAgICBoYXNBbHBoYTogaXNQbmcgfHwgaGFzQWxwaGFcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpbWFnZS5zcmMgPSBzcmM7XG5cbiAgICAgICAgICAgIGNhbmNlbENiID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGltYWdlLm9uZXJyb3IgPSBudWxsO1xuICAgICAgICAgICAgICAgIGltYWdlLm9ubG9hZCA9IG51bGw7XG4gICAgICAgICAgICAgICAgaW1hZ2UucmVtb3ZlQXR0cmlidXRlKCdzcmMnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBjYW5jZWxDYjtcbiAgICB9XG5cbiAgICBjcmVhdGVXZWJHTENvbnRleHQodywgaCkge1xuICAgICAgICBsZXQgY2FudmFzID0gdGhpcy5zdGFnZS5nZXRPcHRpb24oJ2NhbnZhcycpIHx8IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2NhbnZhcycpO1xuXG4gICAgICAgIGlmICh3ICYmIGgpIHtcbiAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IHc7XG4gICAgICAgICAgICBjYW52YXMuaGVpZ2h0ID0gaDtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBvcHRzID0ge1xuICAgICAgICAgICAgYWxwaGE6IHRydWUsXG4gICAgICAgICAgICBhbnRpYWxpYXM6IGZhbHNlLFxuICAgICAgICAgICAgcHJlbXVsdGlwbGllZEFscGhhOiB0cnVlLFxuICAgICAgICAgICAgc3RlbmNpbDogdHJ1ZSxcbiAgICAgICAgICAgIHByZXNlcnZlRHJhd2luZ0J1ZmZlcjogZmFsc2VcbiAgICAgICAgfTtcblxuICAgICAgICBsZXQgZ2wgPSBjYW52YXMuZ2V0Q29udGV4dCgnd2ViZ2wnLCBvcHRzKSB8fCBjYW52YXMuZ2V0Q29udGV4dCgnZXhwZXJpbWVudGFsLXdlYmdsJywgb3B0cykgfHwgY2FudmFzLmdldENvbnRleHQoJ3dlYmdsMicsIG9wdHMpO1xuXG4gICAgICAgIGlmICghZ2wpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJ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wgY29sb3IpXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiBpdGVtLnR4O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3QgYmVmb3JlID0gY2FjaGUubWVtb3J5VXNhZ2U7XG5cbiAgICAgICAgICAgIC8vIEZpbmQgYmxhbmNvIHRpbnQgdGV4dHVyZS5cbiAgICAgICAgICAgIGxldCB0YXJnZXQgPSBjYWNoZS5yZXVzZVRleHR1cmUoZnJhbWUpO1xuICAgICAgICAgICAgaWYgKHRhcmdldCkge1xuICAgICAgICAgICAgICAgIHRhcmdldC5jdHguY2xlYXJSZWN0KDAsIDAsIHRhcmdldC53aWR0aCwgdGFyZ2V0LmhlaWdodCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIEFsbG9jYXRlIG5ldy5cbiAgICAgICAgICAgICAgICB0YXJnZXQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdjYW52YXMnKTtcbiAgICAgICAgICAgICAgICB0YXJnZXQud2lkdGggPSBuYXRpdmVUZXh0dXJlLnc7XG4gICAgICAgICAgICAgICAgdGFyZ2V0LmhlaWdodCA9IG5hdGl2ZVRleHR1cmUuaDtcbiAgICAgICAgICAgICAgICB0YXJnZXQuY3R4ID0gdGFyZ2V0LmdldENvbnRleHQoJzJkJyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX3RpbnRUZXh0dXJlKHRhcmdldCwgbmF0aXZlVGV4dHVyZSwgY29sb3IpO1xuICAgICAgICAgICAgY2FjaGUuc2V0KGNvbG9yLCB0YXJnZXQsIGZyYW1lKTtcblxuICAgICAgICAgICAgY29uc3QgYWZ0ZXIgPSBjYWNoZS5tZW1vcnlVc2FnZTtcblxuICAgICAgICAgICAgaWYgKGFmdGVyICE9PSBiZWZvcmUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9hZGRNZW1vcnlVc2FnZShhZnRlciAtIGJlZm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biAgICAgICAgICAgIGNvbnN0IHZjID0gb3BlcmF0aW9uLmdldEVsZW1lbnRDb3JlKGkpO1xuICAgICAgICAgICAgY29uc3QgcmMgPSBvcGVyYXRpb24uZ2V0UmVuZGVyQ29udGV4dChpKTtcbiAgICAgICAgICAgIGNvbnN0IHdoaXRlID0gb3BlcmF0aW9uLmdldFdoaXRlKGkpO1xuICAgICAgICAgICAgY29uc3Qgc3RjID0gb3BlcmF0aW9uLmdldFNpbXBsZVRjKGkpO1xuXG4gICAgICAgICAgICAvL0B0b2RvOiB0cnkgdG8gb3B0aW1pemUgb3V0IHBlci1kcmF3IHRyYW5zZm9ybSBzZXR0aW5nLiBzcGxpdCB0cmFuc2xhdGUsIHRyYW5zZm9ybS5cbiAgICAgICAgICAgIGNvbnN0IHByZWNpc2lvbiA9IHRoaXMuY3R4LnN0YWdlLmdldFJlbmRlclByZWNpc2lvbigpO1xuICAgICAgICAgICAgY3R4LnNldFRyYW5zZm9ybShyYy50YSAqIHByZWNpc2lvbiwgcmMudGMgKiBwcmVjaXNpb24sIHJjLnRiICogcHJlY2lzaW9uLCByYy50ZCAqIHByZWNpc2lvbiwgcmMucHggKiBwcmVjaXNpb24sIHJjLnB5ICogcHJlY2lzaW9uKTtcblxuICAgICAgICAgICAgY29uc3QgcmVjdCA9ICh0eCA9PT0gdGhpcy5fcmVjdGFuZ2xlVGV4dHVyZSk7XG4gICAgICAgICAgICBjb25zdCBpbmZvID0ge29wZXJhdGlvbiwgdGFyZ2V0LCBpbmRleDogaSwgcmVjdH07XG5cbiAgICAgICAgICAgIGlmIChyZWN0KSB7XG4gICAgICAgICAgICAgICAgLy8gQ2hlY2sgZm9yIGdyYWRpZW50LlxuICAgICAgICAgICAgICAgIGlmICh3aGl0ZSkge1xuICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gJ3doaXRlJztcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRDb2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biAgICAgICAgICAgICAgICBjb25zdCBzb3VyY2VYID0gc3RjID8gMCA6ICh2Yy5fdWx4ICogdHgudyk7XG4gICAgICAgICAgICAgICAgY29uc3Qgc291cmNlWSA9IHN0YyA/IDAgOiAodmMuX3VseSAqIHR4LmgpO1xuICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZVcgPSAoc3RjID8gMSA6ICh2Yy5fYnJ4IC0gdmMuX3VseCkpICogdHgudztcbiAgICAgICAgICAgICAgICBjb25zdCBzb3VyY2VIID0gKHN0YyA/IDEgOiAodmMuX2JyeSAtIHZjLl91bHkpKSAqIHR4Lmg7XG5cbiAgICAgICAgICAgICAgICBsZXQgY29sb3JpemUgPSAhd2hpdGU7XG4gICAgICAgICAgICAgICAgaWYgKGNvbG9yaXplKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEB0b2RvOiBjYWNoZSB0aGUgdGludCB0ZXh0dXJlIGZvciBiZXR0ZXIgcGVyZm9ybWFuY2UuXG5cbiAgICAgICAgICAgICAgICAgICAgLy8gRHJhdyB0byBpbnRlcm1lZGlhdGUgdGV4dHVyZSB3aXRoIGJhY2tncm91bmQgY29sb3IvZ3JhZGllbnQuXG4gICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgcHJldmVudHMgdXMgZnJvbSBoYXZpbmcgdG8gY3JlYXRlIGEgbG90IG9mIHJlbmRlciB0ZXh0dXJlIGNhbnZhc2VzLlxuXG4gICAgICAgICAgICAgICAgICAgIC8vIE5vdGljZSB0aGF0IHdlIGRvbid0IHN1cHBvcnQgKG5vbi1yZWN0KSBncmFkaWVudHMsIG9ubHkgY29sb3IgdGludGluZyBmb3IgYzJkLiBXZSdsbCBqdXN0IHRha2UgdGhlIGF2ZXJhZ2UgY29sb3IuXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb2xvciA9IHZjLl9jb2xvclVsO1xuICAgICAgICAgICAgICAgICAgICBpZiAodmMuX2NvbG9yVWwgIT09IHZjLl9jb2xvclVyIHx8IHZjLl9jb2xvclVyICE9PSB2Yy5fY29sb3JCbCB8fCB2Yy5fY29sb3JCciAhPT0gdmMuX2NvbG9yQmwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yID0gU3RhZ2VVdGlscy5tZXJnZU11bHRpQ29sb3JzRXF1YWwoW3ZjLl9jb2xvclVsLCB2Yy5fY29sb3JVciwgdmMuX2NvbG9yQmwsIHZjLl9jb2xvckJyXSk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBjb25zdCBhbHBoYSA9ICgoY29sb3IgLyAxNjc3NzIxNikgfCAwKSAvIDI1NS4wO1xuICAgICAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQWxwaGEgKj0gYWxwaGE7XG5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gY29sb3IgJiAweDAwRkZGRkZGO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCB0aW50VGV4dHVyZSA9IHRoaXMuX3RpbnRNYW5hZ2VyLmdldFRpbnRUZXh0dXJlKHR4LCByZ2IpO1xuXG4gICAgICAgICAgICAgICAgICAgIC8vIEFjdHVhbGx5IGRyYXcgcmVzdWx0LlxuICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gJ3doaXRlJztcbiAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZSh0aW50VGV4dHVyZSwgc291cmNlWCwgc291cmNlWSwgc291cmNlVywgc291cmNlSCwgMCwgMCwgdmMudywgdmMuaCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9ICd3aGl0ZSc7XG4gICAgICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UodHgsIHNvdXJjZVgsIHNvdXJjZVksIHNvdXJjZVcsIHNvdXJjZUgsIDAsIDAsIHZjLncsIHZjLmgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLl9hZnRlckRyYXdFbChpbmZvKTtcbiAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQWxwaGEgPSAxLjA7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfc2V0Q29sb3JHcmFkaWVudChjdHgsIHZjLCB3ID0gdmMudywgaCA9IHZjLmgsIHRyYW5zcGFyZW5jeSA9IHRydWUpIHtcbiAgICAgICAgbGV0IGNvbG9yID0gdmMuX2NvbG9yVWw7XG4gICAgICAgIGxldCBncmFkaWVudDtcbiAgICAgICAgLy9AdG9kbzogcXVpY2sgc2luZ2xlIGNvbG9yIGNoZWNrLlxuICAgICAgICAvL0B0b2RvOiBjYWNoZSBncmFkaWVudC9maWxsIHN0eWxlIChpZiBwb3NzaWJsZSwgcHJvYmFibHkgY29udGV4dC1zcGVjaWZpYykuXG5cbiAgICAgICAgaWYgKHZjLl9jb2xvclVsID09PSB2Yy5fY29sb3JVcikge1xuICAgICAgICAgICAgaWYgKHZjLl9jb2xvckJsID09PSB2Yy5fY29sb3JCcikge1xuICAgICAgICAgICAgICAgIGlmICh2Yy5fY29sb3JVbCA9PT0gdmMuY29sb3JCbCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBTaW5nbGUgY29sb3IuXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gVmVydGljYWwgZ3JhZGllbnQuXG4gICAgICAgICAgICAgICAgICAgIGdyYWRpZW50ID0gY3R4LmNyZWF0ZUxpbmVhckdyYWRpZW50KDAsIDAsIDAsIGgpO1xuICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNwYXJlbmN5KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5hZGRDb2xvclN0b3AoMCwgU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHZjLl9jb2xvclVsKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5hZGRDb2xvclN0b3AoMSwgU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHZjLl9jb2xvckJsKSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5hZGRDb2xvclN0b3AoMCwgU3RhZ2VVdGlscy5nZXRSZ2JTdHJpbmcodmMuX2NvbG9yVWwpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LmFkZENvbG9yU3RvcCgxLCBTdGFnZVV0aWxzLmdldFJnYlN0cmluZyh2Yy5fY29sb3JCbCkpO1xuXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIE5vdCBzdXBwb3J0ZWQgZ3JhZGllbnQuXG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodmMuX2NvbG9yVWwgPT09IHZjLl9jb2xvckJsICYmIHZjLl9jb2xvclVyID09PSB2Yy5fY29sb3JCcikge1xuICAgICAgICAgICAgICAgIC8vIEhvcml6b250YWwgZ3JhZGllbnQuXG4gICAgICAgICAgICAgICAgZ3JhZGllbnQgPSBjdHguY3JlYXRlTGluZWFyR3JhZGllbnQoMCwgMCwgdywgMCk7XG4gICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW5jeSkge1xuICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5hZGRDb2xvclN0b3AoMCwgU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHZjLl9jb2xvclVsKSk7XG4gICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LmFkZENvbG9yU3RvcCgxLCBTdGFnZVV0aWxzLmdldFJnYmFTdHJpbmcodmMuX2NvbG9yQnIpKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5hZGRDb2xvclN0b3A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uXG4gICAgc2V0dXBVbmlmb3JtcyhvcGVyYXRpb24pIHtcbiAgICAgICAgdGhpcy5fc2V0VW5pZm9ybShcInByb2plY3Rpb25cIiwgdGhpcy5fZ2V0UHJvamVjdGlvbihvcGVyYXRpb24pLCB0aGlzLmdsLnVuaWZvcm0yZnYsIGZhbHNlKTtcbiAgICB9XG5cbiAgICBkcmF3KG9wZXJhdGlvbikge1xuICAgICAgICBsZXQgZ2wgPSB0aGlzLmdsO1xuXG4gICAgICAgIGxldCBsZW5ndGggPSBvcGVyYXRpb24ubGVuZ3RoO1xuXG4gICAgICAgIGlmIChsZW5ndGgpIHtcbiAgICAgICAgICAgIGxldCBnbFRleHR1cmUgPSBvcGVyYXRpb24uZ2V0VGV4dHVyZSgwKTtcbiAgICAgICAgICAgIGxldCBwb3MgPSAwO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGxldCB0eCA9IG9wZXJhdGlvbi5nZXRUZXh0dXJlKGkpO1xuICAgICAgICAgICAgICAgIGlmIChnbFRleHR1cmUgIT09IHR4KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChnbFRleHR1cmUub3B0aW9ucyAmJiBnbFRleHR1cmUub3B0aW9ucy5pbWFnZVJlZikge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRQb3N0aW9uID0gKGkgPiAwKSA/IChpIC0gMSkgOiBpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJlY2lzaW9uID0gdGhpcy5jdHguc3RhZ2UuZ2V0T3B0aW9uKCdwcmVjaXNpb24nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YyA9IG9wZXJhdGlvbi5nZXRFbGVtZW50Q29yZShlbGVtZW50UG9zdGlvbik7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zdGFnZS5wbGF0Zm9ybS5wYWludChnbCwgZ2xUZXh0dXJlLm9wdGlvbnMuaW1hZ2VSZWYsIHZjLl93b3JsZENvbnRleHQucHgqcHJlY2lzaW9uLCB2Yy5fd29ybGRDb250ZXh0LnB5KnByZWNpc2lvbiwgdmMuX2NvbG9yVWwsIHZjKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdsLmJpbmRUZXh0dXJlKGdsLlRFWFRVUkVfMkQsIGdsVGV4dHVyZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBnbC5kcmF3RWxlbWVudHMoZ2wuVFJJQU5HTEVTLCA2ICogKGkgLSBwb3MpLCBnbC5VTlNJR05FRF9TSE9SVCwgKHBvcyArIG9wZXJhdGlvbi5pbmRleCkgKiA2ICogMik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZ2xUZXh0dXJlID0gdHg7XG4gICAgICAgICAgICAgICAgICAgIHBvcyA9IGk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHBvcyA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGlmIChnbFRleHR1cmUub3B0aW9ucyAmJiBnbFRleHR1cmUub3B0aW9ucy5pbWFnZVJlZikge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBwcmVjaXNpb24gPSB0aGlzLmN0eC5zdGFnZS5nZXRPcHRpb24oJ3ByZWNpc2lvbicpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgdmMgPSBvcGVyYXRpb24uZ2V0RWxlbWVudENvcmUocG9zKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc3RhZ2UucGxhdGZvcm0ucGFpbnQoZ2wsIGdsVGV4dHVyZS5vcHRpb25zLmltYWdlUmVmLCB2Yy5fd29ybGRDb250ZXh0LnB4KnByZWNpc2lvbiwgdmMuX3dvcmxkQ29udGV4dC5weSpwcmVjaXNpb24sIHZjLl9jb2xvclVsLCB2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B9XG4gICAgfVxuXG4gICAgX3NldFNjaXNzb3IoYXJlYSkge1xuICAgICAgICBzdXBlci5fc2V0U2Npc3NvcihhcmVhKTtcblxuICAgICAgICBpZiAodGhpcy5fc2Npc3NvciA9PT0gYXJlYSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3NjaXNzb3IgPSBhcmVhO1xuXG4gICAgICAgIGxldCBnbCA9IHRoaXMuZ2w7XG4gICAgICAgIGlmICghYXJlYSkge1xuICAgICAgICAgICAgZ2wuZGlzYWJsZShnbC5TQ0lTU09SX1RFU1QpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgZ2wuZW5hYmxlKGdsLlNDSVNTT1JfVEVTVCk7XG4gICAgICAgICAgICBsZXQgcHJlY2lzaW9uID0gdGhpcy5jdHguc3RhZ2UuZ2V0UmVuZGVyUHJlY2lzaW9uKCk7XG4gICAgICAgICAgICBsZXQgeSA9IGFyZWFbMV07XG4gICAgICAgICAgICBpZiAodGhpcy5fcmVuZGVyVGV4dHVyZSA9PT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIC8vIEZsaXAuXG4gICAgICAgICAgICAgICAgeSA9ICh0aGlzLmN0eC5zdGFnZS5oIC8gcHJlY2lzaW9uIC0gKGFyZWFbMV0gKyBhcmVhWzNdKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBnbC5zY2lzc29yKE1hdGgucm91bmQoYXJlYVswXSAqIHByZWNpc2lvbiksIE1hdGgucm91bmQoeSAqIHByZWNpc2lvbiksIE1hdGgucm91bmQoYXJlYVsyXSAqIHByZWNpc2lvbiksIE1hdGgucm91bmQoYXJlYVszXSAqIHByZWNpc2lvbikpO1xuICAgICAgICB9XG4gICAgfVxuXG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxu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c2UgaWYgKGZtdCA9PT0gZ2wuUkdCKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHtcbiAgICAgICAgICAgICAgICBjYXNlIGdsLlVOU0lHTkVEX0JZVEU6XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAzO1xuXG4gICAgICAgICAgICAgICAgY2FzZSBnbC5VTlNJR05FRF9CWVRFXzVfNl81OlxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gMjtcblxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCB0eXBlIHNwZWNpZmllZCBmb3IgR0xfUkdCIGZvcm1hdCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIGZvcm1hdCBzcGVjaWZpZWQgaW4gY2FsbCB0byBfZ2V0Qnl0ZXNQZXJQaXhlbCgpJyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICB1cGxvYWRUZXh0dXJlU291cmNlKHRleHR1cmVTb3VyY2UsIG9wdGlvbnMpIHtcbiAgICAgICAgY29uc3QgZ2wgPSB0aGlzLnN0YWdlLmdsO1xuXG4gICAgICAgIGNvbnN0IHNvdXJjZSA9IG9wdGlvbnMuc291cmNlO1xuICAgICAgICBsZXQgY29tcHJlc3NlZCA9IGZhbHNlO1xuICAgICAgICBpZiAob3B0aW9ucy5yZW5kZXJJbmZvKSB7XG4gICAgICAgICAgICBjb21wcmVzc2VkID0gb3B0aW9ucy5yZW5kZXJJbmZvLmNvbXByZXNzZWQgfHwgZmFsc2VcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IGZvcm1hdCA9IHtcbiAgICAgICAgICAgIHByZW11bHRpcGx5QWxwaGE6IHRydWUsXG4gICAgICAgICAgICBoYXNBbHBoYTogdHJ1ZVxuICAgICAgICB9O1xuXG4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B5ICsgZWxlbWVudENvcmUuX3cgKiByLnRjO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVciwgci5hbHBoYSk7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weCArIGVsZW1lbnRDb3JlLl93ICogci50YSArIGVsZW1lbnRDb3JlLl9oICogci50YjtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX3cgKiByLnRjICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JCciwgci5hbHBoYSk7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gci5weCArIGVsZW1lbnRDb3JlLl9oICogci50YjtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5ICsgZWxlbWVudENvcmUuX2ggKiByLnRkO1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHg7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgICAgICAgIHVpbnRzW29mZnNldF0gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yQmwsIHIuYWxwaGEpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gU2ltcGxlLlxuICAgICAgICAgICAgbGV0IGN4ID0gci5weCArIGVsZW1lbnRDb3JlLl93ICogci50YTtcbiAgICAgICAgICAgIGxldCBjeSA9IHIucHkgKyBlbGVtZW50Q29yZS5faCAqIHIudGQ7XG5cbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IHIucHk7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fdWx5O1xuICAgICAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvclVsLCByLmFscGhhKTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBjeDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB5O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl9icng7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX3VseTtcbiAgICAgICAgICAgIHVpbnRzW29mZnNldCsrXSA9IG1jYShlbGVtZW50Q29yZS5fY29sb3JVciwgci5hbHBoYSk7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gY3g7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gY3k7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSBlbGVtZW50Q29yZS5fYnJ5O1xuICAgICAgICAgICAgdWludHNbb2Zmc2V0KytdID0gbWNhKGVsZW1lbnRDb3JlLl9jb2xvckJyLCByLmFscGhhKTtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQrK10gPSByLnB4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGN5O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCsrXSA9IGVsZW1lbnRDb3JlLl91bHg7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0KytdID0gZWxlbWVudENvcmUuX2JyeTtcbiAgICAgICAgICAgIHVpbnRzW29mZnNldF0gPSBtY2EoZWxlbWVudENvcmUuX2NvbG9yQmwsIHIuYWxwaGEpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgaXNSZW5kZXJUZXh0dXJlUmV1c2FibGUocmVuZGVyU3RhdGUsIHJlbmRlclRleHR1cmVJbmZvKSB7XG4gICAgICAgIGxldCBvZmZzZXQgPSAocmVuZGVyU3RhdGUuX3JlbmRlclRleHR1cmVJbmZvLm9mZnNldCAqIDgwKSAvIDQ7XG4gICAgICAgIGxldCBmbG9hdHMgPSByZW5kZXJTdGF0ZS5xdWFkcy5mbG9hdHM7XG4gICAgICAgIGxldCB1aW50cyA9IHJlbmRlclN0YXRlLnF1YWRzLnVpbnRzO1xuICAgICAgICByZXR1cm4gKChmbG9hdHNbb2Zmc2V0XSA9PT0gMCkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgMV0gPT09IDApICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDJdID09PSAwKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyAzXSA9PT0gMCkgJiZcbiAgICAgICAgICAgICh1aW50c1tvZmZzZXQgKyA0XSA9PT0gMHhGRkZGRkZGRikgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb2Zmc2V0ICsgNV0gPT09IHJlbmRlclRleHR1cmVJbmZvLncpICYmXG4gICAgICAgICAgICAoZmxvYXRzW29mZnNldCArIDZdID09PSAwKSAmJlxuICAgICAgICAgICAgKGZsb2F0c1tvZmZzZXQgKyA3XSA9PT0gMSkgJiZcbiAgICAgICAgICAgIChmbG9hdHNbb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JywgXCI9PT09PT09PT09IHNvdXJjZSA9PT09PT09PT09XFxuXCIgKyBzcmMuc3BsaXQoXCJcXG5cIikubWFwKGxpbmUgPT4gXCJcIiArICgrK2lkeCkgKyBcIjogXCIgKyBsaW5lKS5qb2luKFwiXFxuXCIpKTtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHNoYWRlcjtcbiAgICB9XG5cbiAgICBnZXRVbmlmb3JtTG9jYXRpb24obmFtZSkge1xuICAgICAgICBsZXQgbG9jYXRpb24gPSB0aGlzLl91bmlmb3JtTG9jYXRpb25zLmdldChuYW1lKTtcbiAgICAgICAgaWYgKGxvY2F0aW9uID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIGxvY2F0aW9uID0gdGhpcy5nbC5nZXRVbmlmb3JtTG9jYXRpb24odGhpcy5fcHJvZ3JhbSwgbmFtZSk7XG4gICAgICAgICAgICB0aGlzLl91bmlmb3JtTG9jYXRpb25zLnNldChuYW1lLCBsb2NhdGlvbik7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gbG9jYXRpb247XG4gICAgfVxuXG4gICAgZ2V0QXR0cmliTG9jYXRpb24obmFtZSkge1xuICAgICAgICBsZXQgbG9jYXRpb24gPSB0aGlzLl9hdHRyaWJ1dGVMb2NhdGlvbnMuZ2V0KG5hbWUpO1xuICAgICAgICBpZiAobG9jYXRpb24gPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgbG9jYXRpb24gPSB0aGlzLmdsLmdldEF0dHJpYkxvY2F0aW9uKHRoaXMuX3Byb2dyYW0sIG5hbWUpO1xuICAgICAgICAgICAgdGhpcy5fYXR0cmlidXRlTG9jYXRpb25zLnNldChuYW1lLCBsb2NhdGlvbik7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gbG9jYXRpb247XG4gICAgfVxuXG4gICAgZGVzdHJveSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3Byb2dy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9uLmdldFRleHR1cmUoMCk7XG4gICAgICAgICAgICBsZXQgcG9zID0gMDtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBsZXQgdHggPSBvcGVyYXRpb24uZ2V0VGV4dHVyZShpKTtcbiAgICAgICAgICAgICAgICBpZiAoZ2xUZXh0dXJlICE9PSB0eCkge1xuICAgICAgICAgICAgICAgICAgICBnbC5iaW5kVGV4dHVyZShnbC5URVhUVVJFXzJELCBnbFRleHR1cmUpO1xuICAgICAgICAgICAgICAgICAgICBnbC5kcmF3RWxlbWVudHMoZ2wuVFJJQU5HTEVTLCA2ICogKGkgLSBwb3MpLCBnbC5VTlNJR05FRF9TSE9SVCwgKHBvcyArIG9wZXJhdGlvbi5pbmRleCkgKiA2ICogMik7XG4gICAgICAgICAgICAgICAgICAgIGdsVGV4dHVyZSA9IHR4O1xuICAgICAgICAgICAgICAgICAgICBwb3MgPSBpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIFxuICAgICAgICAgICAgZ2wuYmluZFRleHR1cmUoZ2wuVEVYVFVSRV8yRCwgZ2xUZXh0dXJlKTtcbiAgICAgICAgICAgIGdsLmRyYXdFbGVtZW50cyhnbC5UUklBTkdMRVMsIDYgKiAobGVuZ3RoIC0gcG9zKSwgZ2wuVU5TSUdORURfU0hPUlQsIChwb3MgKyBvcGVyYXRpb24uaW5kZXgpICogNiAqIDIpO1xuICAgICAgICB9XG4gICAgfVxuXG59XG5cbkRlZmF1bHRTaGFkZXIudmVydGV4U2hhZGVyU291cmNlID0gYFxuICAgICNpZmRlZiBHTF9FU1xuICAgICMgaWZkZWYgR0xfRlJBR01FTlRfUFJFQ0lTSU9OX0hJR0hcbiAgICBwcmVjaXNpb24gaGlnaHAgZmxvYXQ7XG4gICAgIyBlbHNlXG4gICAgcHJlY2lzaW9uIGxvd3AgZmxvYXQ7XG4gICAgI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FBdHRyaWJzRGF0YUJ5dGVPZmZzZXQgLyA0O1xuICAgICAgICBsZXQgZmxvYXRzID0gb3BlcmF0aW9uLnF1YWRzLmZsb2F0cztcblxuICAgICAgICBsZXQgbGVuZ3RoID0gb3BlcmF0aW9uLmxlbmd0aDtcblxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XG5cbiAgICAgICAgICAgIC8vIENhbGN1bGF0ZSBub2lzZSB0ZXh0dXJlIGNvb3JkaW5hdGVzIHNvIHRoYXQgaXQgc3BhbnMgdGhlIGZ1bGwgZWxlbWVudC5cbiAgICAgICAgICAgIGxldCBicnggPSBvcGVyYXRpb24uZ2V0RWxlbWVudFdpZHRoKGkpIC8gdGhpcy5fbm9pc2VUZXh0dXJlLmdldFJlbmRlcldpZHRoKCk7XG4gICAgICAgICAgICBsZXQgYnJ5ID0gb3BlcmF0aW9uLmdldEVsZW1lbnRIZWlnaHQoaSkgLyB0aGlzLl9ub2lzZVRleHR1cmUuZ2V0UmVuZGVySGVpZ2h0KCk7XG5cbiAgICAgICAgICAgIGxldCB1bHggPSAwO1xuICAgICAgICAgICAgbGV0IHVseSA9IDA7XG4gICAgICAgICAgICBpZiAodGhpcy5fcmFuZG9tKSB7XG4gICAgICAgICAgICAgICAgdWx4ID0gTWF0aC5yYW5kb20oKTtcbiAgICAgICAgICAgICAgICB1bHkgPSBNYXRoLnJhbmRvbSgpO1xuXG4gICAgICAgICAgICAgICAgYnJ4ICs9IHVseDtcbiAgICAgICAgICAgICAgICBicnkgKz0gdWx5O1xuXG4gICAgICAgICAgICAgICAgaWYgKE1hdGgucmFuZG9tKCkgPCAwLjUpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmxpcCBmb3IgbW9yZSByYW5kb21uZXNzLlxuICAgICAgICAgICAgICAgICAgICBjb25zdCB0ID0gdWx4O1xuICAgICAgICAgICAgICAgICAgICB1bHggPSBicng7XG4gICAgICAgICAgICAgICAgICAgIGJyeCA9IHQ7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKE1hdGgucmFuZG9tKCkgPCAwLjUpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmxpcCBmb3IgbW9yZSByYW5kb21uZXNzLlxuICAgICAgICAgICAgICAgICAgICBjb25zdCB0ID0gdWx5O1xuICAgICAgICAgICAgICAgICAgICB1bHkgPSBicnk7XG4gICAgICAgICAgICAgICAgICAgIGJyeSA9IHQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBTcGVjaWZ5IGFsbCBjb3JuZXIgcG9pbnRzLlxuICAgICAgICAgICAgZmxvYXRzW29mZnNldF0gPSB1bHg7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0ICsgMV0gPSB1bHk7XG5cbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQgKyAyXSA9IGJyeDtcbiAgICAgICAgICAgIGZsb2F0c1tvZmZzZXQgKyAzXSA9IHVseTtcblxuICAgICAgICAgICAgZmxvYXRzW29mZnNldCArIDRdID0gYnJ4O1xuICAgICAgICAgICAgZmxvYXRzW29mZnNldCArIDVdID0gYnJ5O1xuXG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0ICsgNl0gPSB1bHg7XG4gICAgICAgICAgICBmbG9hdHNbb2Zmc2V0ICsgN10gPSBicnk7XG5cbiAgICAgICAgICAgIG9mZnNldCArPSA4O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgYmVmb3JlRHJhdyhvcGVyYXRpb24pIHtcbiAgICAgICAgbGV0IGdsID0gdGhpcy5nbDtcbiAgICAgICAgZ2wudmVydGV4QXR0cmliUG9pbnRlcih0aGlzLl9hdHRyaWIoXCJhTm9pc2VUZXh0dXJlQ29vcmRcIiksIDIsIGdsLkZMT0FULCBmYWxzZSwgOCwgdGhpcy5nZXRWZXJ0ZXhBdHRyaWJQb2ludGVyT2Zmc2V0KG9wZXJhdGlv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lsxXSwgdlswXSwgdlsxXV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIGlmKHYubGVuZ3RoID09PSAzKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZmFkZSA9IFt2WzBdLCB2WzFdLCB2WzJdLCB0aGlzLl9mYWRlWzNdXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKHYubGVuZ3RoID09PSA0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZmFkZSA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9mYWRlID0gW3ZbMF0sIHZbMF0sIHZbMF0sIHZbMF1dO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZmFkZSA9IFt2LCB2LCB2LCB2XTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBmYWRlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZmFkZTtcbiAgICB9XG5cbiAgICBzZXR1cFVuaWZvcm1zKG9wZXJhdGlvbikge1xuICAgICAgICBzdXBlci5zZXR1cFVuaWZvcm1zKG9wZXJhdGlvbik7XG4gICAgICAgIGNvbnN0IG93bmVyID0gb3BlcmF0aW9uLnNoYWRlck93bmVyO1xuXG4gICAgICAgIGNvbnN0IHJlbmRlclByZWNpc2lvbiA9IHRoaXMuY3R4LnN0YWdlLmdldFJlbmRlclByZWNpc2lvbigpO1xuICAgICAgICBjb25zdCBmYWRlID0gdGhpcy5fZmFkZS5tYXAoKGYpID0+IGYgKiByZW5kZXJQcmVjaXNpb24pO1xuICAgICAgICB0aGlzLl9zZXRVbmlmb3JtKCdmYWRlJywgIG5ldyBGbG9hdDMyQXJyYXkoZmFkZSksIHRoaXMuZ2wudW5pZm9ybTRmdik7XG4gICAgICAgIHRoaXMuX3N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ICAgICBwb3MxID0gdmVjMihwb2ludC54LCBwb2ludC55KTtcbiAgICAgICAgICAgIHBvczIgPSB2ZWMyKHBvaW50LngsIHBvaW50LnkgKyBmYWRlWzBdKTtcbiAgICAgICAgICAgIGQgPSBwb3MyIC0gcG9zMTtcbiAgICAgICAgICAgIGMgPSBkb3QocG9zMSwgZCkgLyBkb3QoZCwgZCk7XG4gICAgICAgICAgICB0ID0gc21vb3Roc3RlcCgwLjAsIDEuMCwgY2xhbXAoYywgMC4wLCAxLjApKTtcbiAgICAgICAgICAgIGNvbG9yID0gbWl4KHZlYzQoMC4wKSwgY29sb3IsIHQpO1xuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgICBpZihmYWRlWzFdID4gMC4wKSB7XG4gICAgICAgICAgICB2ZWMyIHBvczEgPSB2ZWMyKHBvaW50LnggLSByZXNvbHV0aW9uLnggLSBmYWRlWzFdLCB2VGV4dHVyZUNvb3JkLnkpO1xuICAgICAgICAgICAgdmVjMiBwb3MyID0gdmVjMihwb2ludC54IC0gcmVzb2x1dGlvbi54LCB2VGV4dHVyZUNvb3JkLnkpO1xuICAgICAgICAgICAgZCA9IHBvczEgLSBwb3MyO1xuICAgICAgICAgICAgYyA9IGRvdChwb3MyLCBkKSAvIGRvdChkLCBkKTtcbiAgICAgICAgICAgIHQgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcChjLCAwLjAsIDEuMCkpO1xuICAgICAgICAgICAgY29sb3IgPSBtaXgodmVjNCgwLjApLCBjb2xvciwgdCk7XG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICAgIGlmKGZhZGVbMl0gPiAwLjApIHtcbiAgICAgICAgICAgIHZlYzIgcG9zMSA9IHZlYzIodlRleHR1cmVDb29yZC54LCBwb2ludC55IC0gcmVzb2x1dGlvbi55IC0gZmFkZVsyXSk7XG4gICAgICAgICAgICB2ZWMyIHBvczIgPSB2ZWMyKHZUZXh0dXJlQ29vcmQueCwgcG9pbnQueSAtIHJlc29sd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LnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBwaXZvdFgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9waXZvdFg7XG4gICAgfVxuXG4gICAgc2V0IHBpdm90WCh2KSB7XG4gICAgICAgIHRoaXMuX3Bpdm90WCA9IHYgKyAxO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBwaXZvdFkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9waXZvdFk7XG4gICAgfVxuXG4gICAgc2V0IHBpdm90WSh2KSB7XG4gICAgICAgIHRoaXMuX3Bpdm90WSA9IHYgKyAxO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIGdldCBsaWdodFkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9saWdodFk7XG4gICAgfVxuXG4gICAgc2V0IGxpZ2h0WSh2KSB7XG4gICAgICAgIHRoaXMuX2xpZ2h0WSA9IHY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHBpdm90WigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3Bpdm90WjtcbiAgICB9XG5cbiAgICBzZXQgcGl2b3RaKHYpIHtcbiAgICAgICAgdGhpcy5fcGl2b3RaID0gdjtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBnZXQgbGlnaHRaKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbGlnaHRaO1xuICAgIH1cblxuICAgIHNldCBsaWdodFoodikge1xuICAgICAgICB0aGlzLl9saWdodFogPSB2O1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIHVzZURlZmF1bHQoKSB7XG4gICAgICAgIHJldHVybiAodGhpcy5fcnggPT09IDAgJiYgdGhpcy5fcnkgPT09IDAgJiYgdGhpcy5feiA9PT0gMCAmJiB0aGlzLl9zdHJlbmd0aCA9PT0gMCAmJiB0aGl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hdDIoIGNvcyhyb3QueiksIHNpbihyb3QueiksIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgLXNpbihyb3QueiksIGNvcyhyb3QueikpO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3MueHk7XG4gICAgICAgIFxuICAgICAgICAvLyBQZXJmb3JtIDNkIHJvdGF0aW9uc1xuICAgICAgICBnbF9Qb3NpdGlvbi54ID0gY29zKHJvdC54KSAqIHBvcy54IC0gc2luKHJvdC54KSAqIHBvcy56O1xuICAgICAgICBnbF9Qb3NpdGlvbi55ID0gcG9zLnk7XG4gICAgICAgIGdsX1Bvc2l0aW9uLnogPSBzaW4ocm90LngpICogcG9zLnggKyBjb3Mocm90LngpICogcG9zLno7XG4gICAgICAgIFxuICAgICAgICBwb3MueCA9IGdsX1Bvc2l0aW9uLng7XG4gICAgICAgIHBvcy55ID0gY29zKHJvdC55KSAqIGdsX1Bvc2l0aW9uLnkgLSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24uejtcbiAgICAgICAgcG9zLnogPSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24ueSArIGNvcyhyb3QueSkgKiBnbF9Qb3NpdGlvbi56O1xuICAgICAgICBcbiAgICAgICAgLy8gUmVkbyBYWSByb3RhdGlvblxuICAgICAgICBpUm90WHlbMF1bMV0gPSAtaVJvdFh5WzBdWzFdO1xuICAgICAgICBpUm90WHlbMV1bMF0gPSAtaVJvdFh5WzFdWzBdO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3MueHk7IFxuXG4gICAgICAgIC8vIFVuZG8gdHJhbnNsYXRlIHRvIHBpdm90IHBvc2l0aW9uXG4gICAgICAgIHBvcy54eXogKz0gcGl2b3Q7XG5cbiAgICAgICAgcG9zID0gdmVjMyhwb3MueCAqIHByb2plY3Rpb24ueCAtIDEuMCwgcG9zLnkgKiAtYWJzKHByb2plY3Rpb24ueSkgKyAxLjAsIHBvcy56ICogcHJvamVjdGlvbi54KTtcbiAgICA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ydCBTdGFnZVV0aWxzIGZyb20gXCIuLi8uLi8uLi90cmVlL1N0YWdlVXRpbHMubWpzXCI7XG5pbXBvcnQgRGVmYXVsdFNoYWRlciBmcm9tIFwiLi9EZWZhdWx0U2hhZGVyLm1qc1wiO1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBPdXRsaW5lU2hhZGVyIGV4dGVuZHMgRGVmYXVsdFNoYWRlciB7XG5cbiAgICBjb25zdHJ1Y3RvcihjdHgpIHtcbiAgICAgICAgc3VwZXIoY3R4KTtcbiAgICAgICAgdGhpcy5fd2lkdGggPSA1O1xuICAgICAgICB0aGlzLl9jb2wgPSAweEZGRkZGRkZGO1xuICAgICAgICB0aGlzLl9jb2xvciA9IFsxLDEsMSwxXTtcbiAgICB9XG5cbiAgICBzZXQgd2lkdGgodikge1xuICAgICAgICB0aGlzLl93aWR0aCA9IHY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY29sO1xuICAgIH1cblxuICAgIHNldCBjb2xvcih2KSB7XG4gICAgICAgIGlmICh0aGlzLl9jb2wgIT09IHYpIHtcbiAgICAgICAgICAgIGNvbnN0IGNvbCA9IFN0YWdlVXRpbHMuZ2V0UmdiYUNvbXBvbmVudHNOb3JtYWxpemVkKHYpO1xuICAgICAgICAgICAgY29sWzBdID0gY29sWzBdICogY29sWzNdO1xuICAgICAgICAgICAgY29sWzFdID0gY29sWzFdICogY29sWzNdO1xuICAgICAgICAgICAgY29sWzJdID0gY29sWzJdICogY29sWzNdO1xuXG4gICAgICAgICAgICB0aGlzLl9jb2xvciA9IGNvbDtcblxuICAgICAgICAgICAgdGhpcy5yZWRyYXcoKTtcblxuICAgICAgICAgICAgdGhpcy5fY29sID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHVzZURlZmF1bHQoKSB7XG4gICAgICAgIHJldHVybiAodGhpcy5fd2lkdGggPT09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RleHR1cmVDb29yZDtcbiAgICBhdHRyaWJ1dGUgdmVjNCBhQ29sb3I7XG4gICAgdW5pZm9ybSB2ZWMyIHByb2plY3Rpb247XG4gICAgdmFyeWluZyB2ZWMyIHZUZXh0dXJlQ29vcmQ7XG4gICAgdmFyeWluZyB2ZWM0IHZDb2xvcjtcblxuICAgIHVuaWZvcm0gZmxvYXQgejtcbiAgICB1bmlmb3JtIHZlYzMgcGl2b3Q7XG4gICAgdW5pZm9ybSB2ZWMzIHJvdDtcbiAgICB2YXJ5aW5nIHZlYzMgcG9zO1xuXG4gICAgdm9pZCBtYWluKHZvaWQpIHtcbiAgICAgICAgcG9zID0gdmVjMyhhVmVydGV4UG9zaXRpb24ueHksIHopO1xuICAgICAgICBcbiAgICAgICAgcG9zIC09IHBpdm90O1xuICAgICAgICBcbiAgICAgICAgLy8gVW5kbyBYWSByb3RhdGlvblxuICAgICAgICBtYXQyIGlSb3RYeSA9IG1hdDIoIGNvcyhyb3QueiksIHNpbihyb3QueiksIFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgLXNpbihyb3QueiksIGNvcyhyb3QueikpO1xuICAgICAgICBwb3MueHkgPSBpUm90WHkgKiBwb3MueHk7XG4gICAgICAgIFxuICAgICAgICAvLyBQZXJmb3JtIDNkIHJvdGF0aW9uc1xuICAgICAgICBnbF9Qb3NpdGlvbi54ID0gY29zKHJvdC54KSAqIHBvcy54IC0gc2luKHJvdC54KSAqIHBvcy56O1xuICAgICAgICBnbF9Qb3NpdGlvbi55ID0gcG9zLnk7XG4gICAgICAgIGdsX1Bvc2l0aW9uLnogPSBzaW4ocm90LngpICogcG9zLnggKyBjb3Mocm90LngpICogcG9zLno7XG4gICAgICAgIFxuICAgICAgICBwb3MueCA9IGdsX1Bvc2l0aW9uLng7XG4gICAgICAgIHBvcy55ID0gY29zKHJvdC55KSAqIGdsX1Bvc2l0aW9uLnkgLSBzaW4ocm90LnkpICogZ2xfUG9zaXRpb24uejtcbiAgICAgICAgcG9zLnog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gdGhpcy5pbm5lckNvbG9yID0gYXJnYjtcbiAgICB9XG5cbiAgICBnZXQgY29sb3IoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmlubmVyQ29sb3I7XG4gICAgfVxuXG4gICAgZ2V0IG91dGVyQ29sb3IoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9pYztcbiAgICB9XG5cbiAgICBzZXQgeChmKSB7XG4gICAgICAgIHRoaXMuX3ggPSBmO1xuICAgICAgICB0aGlzLnJlZHJhdygpO1xuICAgIH1cblxuICAgIHNldCB5KGYpIHtcbiAgICAgICAgdGhpcy5feSA9IGY7XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgc2V0IHBpdm90KHYpIHtcbiAgICAgICAgaWYoQXJyYXkuaXNBcnJheSh2KSAmJiB2Lmxlbmd0aCA9PT0gMikge1xuICAgICAgICAgICAgdGhpcy5fcGl2b3QgPSB2O1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYoQXJyYXkuaXNBcnJheSh2KSkge1xuICAgICAgICAgICAgdGhpcy5fcGl2b3QgPSBbdlswXSwgdlsxXSB8fCB2WzBdXTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3Bpdm90ID0gW3YsIHZdO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucmVkcmF3KCk7XG4gICAgfVxuXG4gICAgZ2V0IHBpdm90KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGl2b3RbMF07XG4gICAgfVxuXG4gICAgc2V0IHBpdm90WShmKSB7XG4gICAgICAgIHRoaXMuX3Bpdm90WzFdID0gZjtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBnZXQgcGl2b3RZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGl2b3RbMV07XG4gICAgfVxuXG4gICAgc2V0IHBpdm90WChmKSB7XG4gICAgICAgIHRoaXMuX3Bpdm90WzBdID0gZjtcbiAgICAgICAgdGhpcy5yZWRyYXcoKTtcbiAgICB9XG5cbiAgICBnZXQgcGl2b3RYKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcGl2b3RbMF07XG4gICAgfVxuXG4gICAgX2dldE5vcm1hbGl6ZWRDb2xvcihjb2xvcikge1xuICAgICAgICBjb25zdCBjb2wgPSBTdGFnZVV0aWxzLmdldFJnYmFDb21wb25lbnRzTm9ybWFsaXplZChjb2xvcik7XG4gICAgICAgIGNvbFswXSAqPSBjb2xbM107XG4gICAgICAgIGNvbFsxXSAqPSBjb2xbM107XG4gICAgICAgIGNvbFsyXSAqPSBjb2xbM107XG4gICAgICAgIHJldHVybiBuZXcgRmxvYXQzMkFycmF5KGNvbCk7XG4gICAgfVxuXG4gICAgc2V0dXBVbmlmb3JtcyhvcGVyYXRpb24pIHtcbiAgICAgICAgc3VwZXIuc2V0dXBVbmlmb3JtcyhvcGVyYXRpb24pO1xuICAgICAgICBjb25zdCBvd25lciA9IG9wZXJhdGlvbi5zaGFkZXJPd25lcjtcblxuICAgICAgICBpZih0aGlzLl94KSB7XG4gICAgICAgICAgICB0aGlzLl9waXZvdFswXSA9IHRoaXMuX3ggLyBvd25lci53O1xuICAgICAgICB9XG4gICAgICAgIGlmKHRoaXMuX3kpIHtcbiAgICAgICAgICAgIHRoaXMuX3Bpdm90WzFdID0gdGhpcy5feSAvIG93bmVyLmg7XG4gICAgICAgIH1cblxuICAgICAgICBpZih0aGlzLl9yYWRpdXMgPT09IDApIHtcbiAgICAgICAgICAgIHRoaXMuX3JhZGl1cyA9IG93bmVyLncgKiAwLjU7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9zZXRVbmlmb3JtKCdpbm5lckNvbG9yJywgdGhpcy5fbm9ybWFsaXplZElDLCB0aGlzLmdsLnVuaWZvcm00ZnYpO1xuICAgICAgICB0aGlzLl9zZXRVbmlmb3JtKCdmaWxsJywgU3RhZ2VVdGlscy5nZXRSZ2JhQ29tcG9uZ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ikge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBUZXh0VGV4dHVyZVJlbmRlcmVyQWR2YW5jZWQoc3RhZ2UsIGNhbnZhcywgc2V0dGluZ3MpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBUZXh0VGV4dHVyZVJlbmRlcmVyKHN0YWdlLCBjYW52YXMsIHNldHRpbmdzKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB0ZXh0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fdGV4dDtcbiAgICB9XG5cbiAgICBzZXQgdGV4dCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl90ZXh0ICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl90ZXh0ID0gXCJcIiArIHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3c7XG4gICAgfVxuXG4gICAgc2V0IHcodikge1xuICAgICAgICBpZiAodGhpcy5fdyAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fdyA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgaCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2g7XG4gICAgfVxuXG4gICAgc2V0IGgodikge1xuICAgICAgICBpZiAodGhpcy5faCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5faCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgZm9udFN0eWxlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZm9udFN0eWxlO1xuICAgIH1cblxuICAgIHNldCBmb250U3R5bGUodikge1xuICAgICAgICBpZiAodGhpcy5fZm9udFN0eWxlICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9mb250U3R5bGUgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGZvbnRCYXNlbGluZVJhdGlvKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZm9udEJhc2VsaW5lUmF0aW87XG4gICAgfVxuICAgIFxuICAgIHNldCBmb250QmFzZWxpbmVSYXRpbyh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9mb250QmFzZWxpbmVSYXRpbyAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fZm9udEJhc2VsaW5lUmF0aW8gPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGZvbnRTaXplKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZm9udFNpemU7XG4gICAgfVxuXG4gICAgc2V0IGZvbnRTaXplKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2ZvbnRTaXplICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9mb250U2l6ZSA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgZm9udEZhY2UoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mb250RmFjZTtcbiAgICB9XG5cbiAgICBzZXQgZm9udEZhY2Uodikge1xuICAgICAgICBpZiAodGhpcy5fZm9udEZhY2UgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2ZvbnRGYWNlID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB3b3JkV3JhcCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3dvcmRXcmFwO1xuICAgIH1cblxuICAgIHNldCB3b3JkV3JhcCh2KSB7XG4gICAgICAgIGlmICh0aGlzL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IHJldHVybiB0aGlzLl9vZmZzZXRZO1xuICAgIH1cblxuICAgIHNldCBvZmZzZXRZKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX29mZnNldFkgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX29mZnNldFkgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IG1heExpbmVzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbWF4TGluZXM7XG4gICAgfVxuXG4gICAgc2V0IG1heExpbmVzKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX21heExpbmVzICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9tYXhMaW5lcyA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgbWF4TGluZXNTdWZmaXgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9tYXhMaW5lc1N1ZmZpeDtcbiAgICB9XG5cbiAgICBzZXQgbWF4TGluZXNTdWZmaXgodikge1xuICAgICAgICBpZiAodGhpcy5fbWF4TGluZXNTdWZmaXggIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX21heExpbmVzU3VmZml4ID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB0ZXh0Q29sb3IoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl90ZXh0Q29sb3I7XG4gICAgfVxuXG4gICAgc2V0IHRleHRDb2xvcih2KSB7XG4gICAgICAgIGlmICh0aGlzLl90ZXh0Q29sb3IgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3RleHRDb2xvciA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgcGFkZGluZ0xlZnQoKSB7X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BnZXQgc2hhZG93T2Zmc2V0WCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NoYWRvd09mZnNldFg7XG4gICAgfVxuXG4gICAgc2V0IHNoYWRvd09mZnNldFgodikge1xuICAgICAgICBpZiAodGhpcy5fc2hhZG93T2Zmc2V0WCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fc2hhZG93T2Zmc2V0WCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgc2hhZG93T2Zmc2V0WSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NoYWRvd09mZnNldFk7XG4gICAgfVxuXG4gICAgc2V0IHNoYWRvd09mZnNldFkodikge1xuICAgICAgICBpZiAodGhpcy5fc2hhZG93T2Zmc2V0WSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fc2hhZG93T2Zmc2V0WSA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgc2hhZG93Qmx1cigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NoYWRvd0JsdXI7XG4gICAgfVxuXG4gICAgc2V0IHNoYWRvd0JsdXIodikge1xuICAgICAgICBpZiAodGhpcy5fc2hhZG93Qmx1ciAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fc2hhZG93Qmx1ciA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgaGlnaGxpZ2h0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faGlnaGxpZ2h0O1xuICAgIH1cblxuICAgIHNldCBoaWdobGlnaHQodikge1xuICAgICAgICBpZiAodGhpcy5faGlnaGxpZ2h0ICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9oaWdobGlnaHQgPSB2O1xuICAgICAgICAgICAg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AgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgY3V0U3koKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jdXRTeTtcbiAgICB9XG5cbiAgICBzZXQgY3V0U3kodikge1xuICAgICAgICBpZiAodGhpcy5fY3V0U3kgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2N1dFN5ID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBjdXRFeSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2N1dEV5O1xuICAgIH1cblxuICAgIHNldCBjdXRFeSh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9jdXRFeSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fY3V0RXkgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGFkdmFuY2VkUmVuZGVyZXIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9hZHZhbmNlZFJlbmRlcmVyO1xuICAgIH1cblxuICAgIHNldCBhZHZhbmNlZFJlbmRlcmVyKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX2FkdmFuY2VkUmVuZGVyZXIgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX2FkdmFuY2VkUmVuZGVyZXIgPSB2O1xuICAgICAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0IGxldHRlclNwYWNpbmcodikge1xuICAgICAgICBpZiAodGhpcy5fbGV0dGVyU3BhY2luZyAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fbGV0dGVyU3BhY2luZyA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgbGV0dGVyU3BhY2luZygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xldHRlclNwYWNpbmc7XG4gICAgfVxuXG4gICAgc2V0IHRleHRJbmRlbnQodikge1xuICAgICAgICBpZiAodGhpcy5fdGV4dEluZGVudCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fdGV4dEluZGVudCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgdGV4dEluZGVudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3RleHRJbmRlbnQ7XG4gICAgfVxuXG4gICAgc2V0IHJ0bCh2KSB7XG4gICAgICAgIGlmICh0aGlzLl9ydGwgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3J0bCA9IHY7XG4gICAgICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgcnRsKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcnRsO1xuICAgIH1cblxuICAgIGdldCBwcmVjaXNpb24oKSB7XG4gICAgICAgIHJldHVybiBzdXBlci5wcmVjaXNpb247XG4gICAgfVxuXG4gICAgc2V0IHByZWNpc2lvbih2KSB7XG4gICAgICAgIC8vIFdlIGFjdHVhbGx5IGRyYXcgZGlmZmVyZW50bHkgd2hlbiB0aGUgcHJlY2lzaW9uIGNoYW5nZXMuXG4gICAgICAgIGlmICh0aGlzLnByZWNpc2lvbiAhPT0gdikge1xuICAgICAgICAgICAgc3VwZXIucHJlY2lzaW9uID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2NoYW5nZWQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9nZXRJc1ZhbGlkKCkge1xuICAgICAgICByZXR1cm4gISF0aGlzLnRleHQ7XG4gICAgfVxuXG4gICAgX2dldExvb2t1cElkKCkge1xuICAgICAgICBsZXQgcGFydHMgPSBbXTtcblxuICAgICAgICBpZiAodGhpcy53ICE9PSAwKSBwYXJ0cy5wdXNoKF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B9XG5cbiAgICAgICAgICAgIGlmIChnbCAmJiBzaGFycGVuKSB7XG4gICAgICAgICAgICAgICAgdGV4UGFyYW1zW2dsLlRFWFRVUkVfTUFHX0ZJTFRFUl0gPSBnbC5ORUFSRVNUO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIHAudGhlbigoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIC8qIEZJWE1FOiBvbiBzb21lIHBsYXRmb3JtcyAoZS5nLiBSUEkpLCB0aHJvdHRsaW5nIHRleHQgdGV4dHVyZXMgY2F1c2UgYXJ0aWZhY3RzICovXG4gICAgICAgICAgICAgICAgICAgIGNiKG51bGwsIE9iamVjdC5hc3NpZ24oe1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVySW5mbzogcmVuZGVyZXIucmVuZGVySW5mbyxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm90dGxlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleFBhcmFtczogdGV4UGFyYW1zLFxuICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLnN0YWdlLnBsYXRmb3JtLmdldFRleHR1cmVPcHRpb25zRm9yRHJhd2luZ0NhbnZhcyhjYW52YXMpKSk7XG4gICAgICAgICAgICAgICAgfSkuY2F0Y2goKGVycikgPT4ge1xuICAgICAgICAgICAgICAgICAgICBjYihlcnIpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjYihudWxsLCBPYmplY3QuYXNzaWduKHtcbiAgICAgICAgICAgICAgICAgICAgcmVuZGVySW5mbzogcmVuZGVyZXIucmVuZGVySW5mbyxcbiAgICAgICAgICAgICAgICAgICAgdGhyb3R0bGU6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICB0ZXhQYXJhbXM6IHRleFBhcmFtcyxcbiAgICAgICAgICAgICAgICB9LCB0aGlzLnN0YWdl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NldHRpbmdzO1xuICAgIH1cblxuICAgIGdldFByZWNpc2lvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NldHRpbmdzLnByZWNpc2lvbjtcbiAgICB9O1xuXG4gICAgc2V0Rm9udFByb3BlcnRpZXMoKSB7XG4gICAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IGdldEZvbnRTZXR0aW5nKFxuICAgICAgICAgICAgdGhpcy5fc2V0dGluZ3MuZm9udEZhY2UsXG4gICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U3R5bGUsXG4gICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U2l6ZSxcbiAgICAgICAgICAgIHRoaXMuZ2V0UHJlY2lzaW9uKCksXG4gICAgICAgICAgICB0aGlzLl9zdGFnZS5nZXRPcHRpb24oJ2RlZmF1bHRGb250RmFjZScpLFxuICAgICAgICApO1xuICAgICAgICB0aGlzLl9jb250ZXh0LnRleHRCYXNlbGluZSA9IHRoaXMuX3NldHRpbmdzLnRleHRCYXNlbGluZTtcbiAgICAgICAgdGhpcy5fY29udGV4dC5kaXJlY3Rpb24gPSB0aGlzLl9zZXR0aW5ncy5ydGwgPyBcInJ0bFwiIDogXCJsdHJcIjtcbiAgICB9O1xuXG4gICAgX2xvYWQoKSB7XG4gICAgICAgIGlmIChVdGlscy5pc1dlYiAmJiBkb2N1bWVudC5mb250cykge1xuICAgICAgICAgICAgY29uc3QgZm9udFNldHRpbmcgPSBnZXRGb250U2V0dGluZyhcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250RmFjZSxcbiAgICAgICAgICAgICAgICB0aGlzLl9zZXR0aW5ncy5mb250U3R5bGUsXG4gICAgICAgICAgICAgICAgdGhpcy5fc2V0dGluZ3MuZm9udFNpemUsXG4gICAgICAgICAgICAgICAgdGhpcy5nZXRQcmVjaXNpb24oKSxcbiAgICAgICAgICAgICAgICB0aGlzLl9zdGFnZS5nZXRPcHRpb24oJ2RlZmF1bHRGb250RmFjZScpXG4gICAgICAgICAgICApO1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBpZiAoIWRvY3VtZW50LmZvbnRzLmNoZWNrKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBVc2UgYSBwcm9taXNlIHRoYXQgd2FpdHMgZm9yIGxvYWRpbmcuXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudC5mb250cy5sb2FkKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KS5jYXRjaChlcnIgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gSnVzdCBsb2FkIHRoZSBmYWxsYmFjayBmb250LlxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdbTGlnaHRuaW5nXSBGb250IGxvYWQgZXJyb3InLCBlcnIsIGZvbnRTZXR0aW5nKTtcbiAgICAgICAgICAgICAgICAgICAgfSkudGhlbigoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRvY3VtZW50LmZvbnRzLmNoZWNrKGZvbnRTZXR0aW5nLCB0aGlzLl9zZXR0aW5ncy50ZXh0KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybignW0xpZ2h0bmluZ10gRm9udCBub3QgZm91bmQnLCBmb250U2V0dGluZyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gY2F0Y2goZSkge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIENhbid0IGNoZWNrIGZvbnQgbG9hZGluZyBmb3IgXCIgKyBmb250U2V0dGluZyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBkcmF3KCkge1x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aCA9IHdpZHRoIC0gKHBhZGRpbmdMZWZ0KTtcbiAgICAgICAgaWYgKGlubmVyV2lkdGggPCAxMCkge1xuICAgICAgICAgICAgd2lkdGggKz0gKDEwIC0gaW5uZXJXaWR0aCk7XG4gICAgICAgICAgICBpbm5lcldpZHRoID0gMTA7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIXdvcmRXcmFwV2lkdGgpIHtcbiAgICAgICAgICAgIHdvcmRXcmFwV2lkdGggPSBpbm5lcldpZHRoXG4gICAgICAgIH1cblxuICAgICAgICAvLyBUZXh0IG92ZXJmbG93XG4gICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy50ZXh0T3ZlcmZsb3cgJiYgIXRoaXMuX3NldHRpbmdzLndvcmRXcmFwKSB7XG4gICAgICAgICAgICBsZXQgc3VmZml4O1xuICAgICAgICAgICAgc3dpdGNoICh0aGlzLl9zZXR0aW5ncy50ZXh0T3ZlcmZsb3cpIHtcbiAgICAgICAgICAgICAgICBjYXNlICdjbGlwJzpcbiAgICAgICAgICAgICAgICAgICAgc3VmZml4ID0gJyc7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ2VsbGlwc2lzJzpcbiAgICAgICAgICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5fc2V0dGluZ3MubWF4TGluZXNTdWZmaXg7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMuX3NldHRpbmdzLnRleHRPdmVyZmxvdztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLnRleHQgPSB0aGlzLndyYXBXb3JkKHRoaXMuX3NldHRpbmdzLnRleHQsIHdvcmRXcmFwV2lkdGggLSB0ZXh0SW5kZW50LCBzdWZmaXgpXG4gICAgICAgIH1cblxuICAgICAgICAvLyB3b3JkIHdyYXBcbiAgICAgICAgLy8gcHJlc2VydmUgb3JpZ2luYWwgdGV4dFxuICAgICAgICBsZXQgbGluZXNJbmZvO1xuICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3Mud29yZFdyYXApIHtcbiAgICAgICAgICAgIGxpbmVzSW5mbyA9IHRoaXMud3JhcFRleHQodGhpcy5fc2V0dGluZ3MudGV4dCwgd29yZFdyYXBXaWR0aCwgbGV0dGVyU3BhY2luZywgdGV4dEluZGVudCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsaW5lc0luZm8gPSB7bDogdGhpcy5fc2V0dGluZ3MudGV4dC5zcGxpdCgvKD86XFxyXFxufFxccnxcXG4pLyksIG46IFtdfTtcbiAgICAgICAgICAgIGxldCBpLCBuID0gbGluZXNJbmZvLmwubGVuZ3RoO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbGluZXNJbmZvLm4ucHVzaChpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBsZXQgbGluZXMgPSBsaW5lc0luZm8ubDtcblxuICAgICAgICBpZiAodGhpcy5fc2V0dGluZ3MubWF4TGluZXMgJiYgbGluZXMubGVuZ3RoID4gdGhpcy5fc2V0dGluZ3MubWF4TGluZXMpIHtcbiAgICAgICAgICAgIGxldCB1c2VkTGluZXMgPSBsaW5lcy5zbGljZSgwLCB0aGlzLl9zZXR0aW5ncy5tYXhMaW5lcyk7XG5cbiAgICAgICAgICAgIGxldCBvdGhlckxpbmVzID0gbnVsbDtcbiAgICAgICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy5tYXhMaW5lc1N1ZmZpeCkge1xuICAgICAgICAgICAgICAgIC8vIFdyYXAgYWdhaW4gd2l0aCBtYXggbGluZXMgc3VmZml4IGVuYWJsZWQuXG4gICAgICAgICAgICAgICAgbGV0IHcgPSB0aGlzLl9zZXR0aW5ncy5tYXhMaW5lc1N1ZmZpeCA/IHRoaXMubWVhc3VyZVRleHQodGhpcy5fc2V0dGluZ3MubWF4TGluZXNTdWZmaXgpIDogMDtcbiAgICAgICAgICAgICAgICBsZXQgYWwgPSB0aGlzLndyYXBUZXh0KHVzZWRMaW5lc1t1c2VkTGluZXMubGVuZ3RoIC0gMV0sIHdvcmRXcmFwV2lkdGggLSB3LCBsZXR0ZXJTcGFjaW5nLCB0ZXh0SW5kZW50KTtcbiAgICAgICAgICAgICAgICB1c2VkTGluZXNbdXNlZExpbmVzLmxlbmd0aCAtIDFdID0gYWwubFswXSArIHRoaXMuX3NldHRpbmdzLm1heExpbmVzU3VmZml4O1xuICAgICAgICAgICAgICAgIG90aGVyTGluZXMgPSBbYWwubC5sZW5ndGggPiAxID8gYWwubFsxXSA6ICcnXTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgb3RoZXJMaW5lcyA9IFsnJ107XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIFJlLWFzc2VtYmxlIHRoZSByZW1haW5pbmcgdGV4dC5cbiAgICAgICAgICAgIGxldCBpLCBuID0gbGluZXMubGVuZ3RoO1xuICAgICAgICAgICAgbGV0IGogPSAwO1xuICAgICAgICAgICAgbGV0IG0gPSBsaW5lc0luZm8ubi5sZW5ndGg7XG4gICAgICAgICAgICBmb3IgKGkgPSB0aGlzLl9zZXR0aW5ncy5tYXhMaW5lczsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIG90aGVyTGluZXNbal0gKz0gKG90aGVyTGluZXNbal0gPyBcIiBcIiA6IFwiXCIpICsgbGluZXNbaV07XG4gICAgICAgICAgICAgICAgaWYgKGkgKyAxIDwgbSAmJiBsaW5lc0luZm8ubltpICsgMV0pIHtcbiAgICAgICAgICAgICAgICAgICAgaisrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmVuZGVySW5mby5yZW1haW5pbmdUZXh0ID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Y3VsYXRlIHRleHQgaGVpZ2h0XG4gICAgICAgIGxpbmVIZWlnaHQgPSBsaW5lSGVpZ2h0IHx8IGZvbnRTaXplO1xuXG4gICAgICAgIGxldCBoZWlnaHQ7XG4gICAgICAgIGlmIChoKSB7XG4gICAgICAgICAgICBoZWlnaHQgPSBoO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3QgYmFzZWxpbmVPZmZzZXQgPSAodGhpcy5fc2V0dGluZ3MudGV4dEJhc2VsaW5lICE9ICdib3R0b20nKSA/IDAuNSAqIGZvbnRTaXplIDogMDtcbiAgICAgICAgICAgIGhlaWdodCA9IGxpbmVIZWlnaHQgKiAobGluZXMubGVuZ3RoIC0gMSkgKyBiYXNlbGluZU9mZnNldCArIE1hdGgubWF4KGxpbmVIZWlnaHQsIGZvbnRTaXplKSArIG9mZnNldFk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAob2Zmc2V0WSA9PT0gbnVsbCkge1xuICAgICAgICAgICAgb2Zmc2V0WSA9IGZvbnRTaXplO1xuICAgICAgICB9XG5cbiAgICAgICAgcmVuZGVySW5mby53ID0gd2lkdGg7XG4gICAgICAgIHJlbmRlckluZm8uaCA9IGhlaWdodDtcbiAgICAgICAgcmVuZGVySW5mby5saW5lcyA9IGxpbmVzO1xuICAgICAgICByZW5kZXJJbmZvLnByZWNpc2lvbiA9IHByZWNpc2lvbjtcblxuICAgICAgICBpZiAoIXdpZHRoKSB7XG4gICAgICAgICAgICAvLyBUbyBwcmV2ZW50IGNhbnZhcyBlcnJvcnMuXG4gICAgICAgICAgICB3aWR0aCA9IDE7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIWhlaWdodCkge1xuICAgICAgICAgICAgLy8gVG8gcHJldmVudCBjYW52YXMgZXJyb3JzLlxuICAgICAgICAgICAgaGVpZ2h0ID0gMTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChjdXRTeCB8fCBjdXRFeCkge1xuICAgICAgICAgICAgd2lkdGggPSBNYXRoLm1pbih3aWR0aCwgY3V0RXggLSBjdXRTeCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY3V0U3kgfHwgY3V0RXkpIHtcbiAgICAgICAgICAgIGhlaWdodCA9IE1hdGgubWluKGhlaWdodCwgY3V0RXkgLSBjdXRTeSk7XG4gICAgICAgIH1cblxuICAgICAgICByZW5kZXJJbmZvLndpZHRoID0gd2lkdGg7XG4gICAgICAgIHJlbmRlckluZm8uaW5uZXJXaWR0aCA9IGlubmVyV2lkdGg7XG4gICAgICAgIHJlbmRlckluZm8uaGVpZ2h0ID0gaGVpZ2h0O1xuICAgICAgICByZW5kZXJJbmZvLmZvbnRTaXplID0gZm9udFNpemU7XG4gICAgICAgIHJlbmRlckluZm8uY3V0U3ggPSBjdXRTeDtcbiAgICAgICAgcmVuZGVySW5mby5jdXRTeSA9IGN1dFN5O1xuICAgICAgICByZW5kZXJJbmZvLmN1dEV4ID0gY3V0RXg7XG4gICAgICAgIHJlbmRlckluZm8uY3V0RXkgPSBjdXRFeTtcbiAgICAgICAgcmVuZGVySW5mby5saW5lSGVpZ2h0ID0gbGluZUhlaWdodDtcbiAgICAgICAgcmVuZGVySW5mby5saW5lV2lkdGhzID0gbGluZVdpZHRocztcbiAgICAgICAgcmVuZGVySW5mby5vZmZzZXRZID0gb2Zmc2V0WTtcbiAgICAgICAgcmVuZGVySW5mby5wYWRkaW5nTGVmdCA9IHBhZGRpbmdMZWZ0O1xuICAgICAgICByZW5kZXJJbmZvLnBhZGRpbmdSaWdodCA9IHBhZGRpbmdSaWdodDtcbiAgICAgICAgcmVuZGVySW5mby5sZXR0ZXJTcGFjaW5nID0gbGV0dGVyU3BhY2luZztcbiAgICAgICAgcmVuZGVySW5mby50ZXh0SW5kZW50ID0gdGV4dEluZGVudDtcblxuICAgICAgICByZXR1cm4gcmVuZGVySW5mbztcbiAgICB9XG5cbiAgICBfZHJhdygpIHtcbiAgICAgICAgY29uc3QgcmVuZGVySW5mbyA9IHRoa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JbmZvLmN1dFN5KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBsaW5lUG9zaXRpb25YO1xuICAgICAgICBsZXQgbGluZVBvc2l0aW9uWTtcblxuICAgICAgICBsZXQgZHJhd0xpbmVzID0gW107XG5cbiAgICAgICAgLy8gRHJhdyBsaW5lcyBsaW5lIGJ5IGxpbmUuXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gcmVuZGVySW5mby5saW5lcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGxpbmVQb3NpdGlvblggPSBpID09PSAwID8gcmVuZGVySW5mby50ZXh0SW5kZW50IDogMDtcblxuICAgICAgICAgICAgLy8gQnkgZGVmYXVsdCwgdGV4dCBpcyBhbGlnbmVkIHRvIHRvcFxuICAgICAgICAgICAgbGluZVBvc2l0aW9uWSA9IChpICogcmVuZGVySW5mby5saW5lSGVpZ2h0KSArIHJlbmRlckluZm8ub2Zmc2V0WTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX3NldHRpbmdzLnZlcnRpY2FsQWxpZ24gPT0gJ21pZGRsZScpIHtcbiAgICAgICAgICAgICAgICBsaW5lUG9zaXRpb25ZICs9IChyZW5kZXJJbmZvLmxpbmVIZWlnaHQgLSByZW5kZXJJbmZvLmZvbnRTaXplKSAvIDI7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX3NldHRpbmdzLnZlcnRpY2FsQWxpZ24gPT0gJ2JvdHRvbScpIHtcbiAgICAgICAgICAgICAgICBsaW5lUG9zaXRpb25ZICs9IHJlbmRlckluZm8ubGluZUhlaWdodCAtIHJlbmRlckluZm8uZm9udFNpemU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy50ZXh0QWxpZ24gPT09ICdyaWdodCcpIHtcbiAgICAgICAgICAgICAgICBsaW5lUG9zaXRpb25YICs9IChyZW5kZXJJbmZvLmlubmVyV2lkdGggLSByZW5kZXJ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ID0gZHJhd0xpbmUudGV4dC5zcGxpdCgnJyk7XG4gICAgICAgICAgICAgICAgbGV0IHggPSBkcmF3TGluZS54O1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBqID0gdGV4dFNwbGl0Lmxlbmd0aDsgaSA8IGo7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KHRleHRTcGxpdFtpXSwgeCwgZHJhd0xpbmUueSk7XG4gICAgICAgICAgICAgICAgICAgIHggKz0gdGhpcy5tZWFzdXJlVGV4dCh0ZXh0U3BsaXRbaV0sIHJlbmRlckluZm8ubGV0dGVyU3BhY2luZyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHByZXZTaGFkb3dTZXR0aW5ncykge1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dDb2xvciA9IHByZXZTaGFkb3dTZXR0aW5nc1swXTtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93T2Zmc2V0WCA9IHByZXZTaGFkb3dTZXR0aW5nc1sxXTtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93T2Zmc2V0WSA9IHByZXZTaGFkb3dTZXR0aW5nc1syXTtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Qmx1ciA9IHByZXZTaGFkb3dTZXR0aW5nc1szXTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChyZW5kZXJJbmZvLmN1dFN4IHx8IHJlbmRlckluZm8uY3V0U3kpIHtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQudHJhbnNsYXRlKHJlbmRlckluZm8uY3V0U3gsIHJlbmRlckluZm8uY3V0U3kpO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5yZW5kZXJJbmZvID0gcmVuZGVySW5mbztcbiAgICB9O1xuXG4gICAgd3JhcFdvcm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FdyYXBXaWR0aCkge1xuICAgICAgICAgICAgICAgICAgICBjdXRvZmZJbmRleCAtPSAxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAvKiBJbiBjYXNlIGd1ZXNzIHdhcyB1bmRlcmVzdGltYXRlZCwgZXh0ZW5kIGl0IGxldHRlciBieSBsZXR0ZXIuICovXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB3aGlsZSAoY3V0b2ZmSW5kZXggPCB3b3JkTGVuKSB7XG4gICAgICAgICAgICAgICAgdHJ1bmNXb3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQuc3Vic3RyaW5nKDAsIGN1dG9mZkluZGV4KSkgKyBzdWZmaXhXaWR0aDtcbiAgICAgICAgICAgICAgICBpZiAodHJ1bmNXb3JkV2lkdGggPCB3b3JkV3JhcFdpZHRoKSB7XG4gICAgICAgICAgICAgICAgICAgIGN1dG9mZkluZGV4ICs9IDE7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gRmluYWxseSwgd2hlbiBib3VuZCBpcyBjcm9zc2VkLCByZXRyYWN0IGxhc3QgbGV0dGVyLlxuICAgICAgICAgICAgICAgICAgICBjdXRvZmZJbmRleCAtPTE7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8qIElmIHdyYXBXaWR0aCBpcyB0b28gc2hvcnQgdG8gZXZlbiBjb250YWluIHN1ZmZpeCBhbG9uZSwgcmV0dXJuIGVtcHR5IHN0cmluZyAqL1xuICAgICAgICByZXR1cm4gd29yZC5zdWJzdHJpbmcoMCwgY3V0b2ZmSW5kZXgpICsgKHdvcmRXcmFwV2lkdGggPj0gc3VmZ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5fc2V0dGluZ3MuZm9udEZhY2UsXG4gICAgICAgICAgICAgICAgdGhpcy5fc2V0dGluZ3MuZm9udFN0eWxlLFxuICAgICAgICAgICAgICAgIHRoaXMuX3NldHRpbmdzLmZvbnRTaXplLFxuICAgICAgICAgICAgICAgIHRoaXMuZ2V0UHJlY2lzaW9uKCksXG4gICAgICAgICAgICAgICAgdGhpcy5fc3RhZ2UuZ2V0T3B0aW9uKCdkZWZhdWx0Rm9udEZhY2UnKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gVXNlIGEgcHJvbWlzZSB0aGF0IHdhaXRzIGZvciBsb2FkaW5nLlxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuZm9udHMubG9hZChmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkuY2F0Y2goZXJyID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEp1c3QgbG9hZCB0aGUgZmFsbGJhY2sgZm9udC5cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybignRm9udCBsb2FkIGVycm9yJywgZXJyLCBmb250U2V0dGluZyk7XG4gICAgICAgICAgICAgICAgICAgIH0pLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFkb2N1bWVudC5mb250cy5jaGVjayhmb250U2V0dGluZywgdGhpcy5fc2V0dGluZ3MudGV4dCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ0ZvbnQgbm90IGZvdW5kJywgZm9udFNldHRpbmcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG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c2V0WSA9IHRoaXMuX3NldHRpbmdzLnNoYWRvd09mZnNldFk7XG4gICAgICAgIHJlbmRlckluZm8uc2hhZG93Qmx1ciA9IHRoaXMuX3NldHRpbmdzLnNoYWRvd0JsdXI7XG4gICAgICAgIHJlbmRlckluZm8uY3V0U3ggPSBjdXRTeDtcbiAgICAgICAgcmVuZGVySW5mby5jdXRFeCA9IGN1dEV4O1xuICAgICAgICByZW5kZXJJbmZvLmN1dFN5ID0gY3V0U3k7XG4gICAgICAgIHJlbmRlckluZm8uY3V0RXkgPSBjdXRFeTtcbiAgICAgICAgcmVuZGVySW5mby50ZXh0SW5kZW50ID0gdGhpcy5fc2V0dGluZ3MudGV4dEluZGVudCAqIHByZWNpc2lvbjtcbiAgICAgICAgcmVuZGVySW5mby53b3JkQnJlYWsgPSB0aGlzLl9zZXR0aW5ncy53b3JkQnJlYWs7XG5cbiAgICAgICAgbGV0IHRleHQgPSByZW5kZXJJbmZvLnRleHQ7XG4gICAgICAgIGxldCB3cmFwV2lkdGggPSByZW5kZXJJbmZvLndvcmRXcmFwID8gKHJlbmRlckluZm8ud29yZFdyYXBXaWR0aCB8fCByZW5kZXJJbmZvLndpZHRoKSA6IHJlbmRlckluZm8ud2lkdGg7XG5cbiAgICAgICAgLy8gVGV4dCBvdmVyZmxvd1xuICAgICAgICBpZiAocmVuZGVySW5mby50ZXh0T3ZlcmZsb3cgJiYgIXJlbmRlckluZm8ud29yZFdyYXApIHtcbiAgICAgICAgICAgIGxldCBzdWZmaXg7XG4gICAgICAgICAgICBzd2l0Y2ggKHRoaXMuX3NldHRpbmdzLnRleHRPdmVyZmxvdykge1xuICAgICAgICAgICAgICAgIGNhc2UgJ2NsaXAnOlxuICAgICAgICAgICAgICAgICAgICBzdWZmaXggPSAnJztcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnZWxsaXBzaXMnOlxuICAgICAgICAgICAgICAgICAgICBzdWZmaXggPSB0aGlzLl9zZXR0aW5ncy5tYXhMaW5lc1N1ZmZpeDtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgc3VmZml4ID0gdGhpcy5fc2V0dGluZ3MudGV4dE92ZXJmbG93O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGV4dCA9IHRoaXMud3JhcFdvcmQodGV4dCwgd29yZFdyYXBXaWR0aCB8fCByZW5kZXJJbmZvLncsIHN1ZmZpeCk7XG4gICAgICAgIH1cblxuICAgICAgICB0ZXh0ID0gdGhpcy50b2tlbml6ZSh0ZXh0KTtcbiAgICAgICAgdGV4dCA9IHRoaXMucGFyc2UodGV4dCk7XG4gICAgICAgIHRleHQgPSB0aGlzLm1lYXN1cmUodGV4dCwgbGV0dGVyU3BhY2luZywgcmVuZGVySW5mby5iYXNlRm9udCk7XG5cbiAgICAgICAgaWYgKHJlbmRlckluZm8udGV4dEluZGVudCkge1xuICAgICAgICAgICAgdGV4dCA9IHRoaXMuaW5kZW50KHRleHQsIHJlbmRlckluZm8udGV4dEluZGVudCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocmVuZGVySW5mby53b3JkQnJlYWspIHtcbiAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlZHVjZSgoYWNjLCB0KSA9PiBhY2MuY29uY2F0KHRoaXMud29yZEJyZWFrKHQsIHdyYXBXaWR0aCwgcmVuZGVySW5mby5iYXNlRm9udCkpLCBbXSlcbiAgICAgICAgICAgIHRoaXMucmVzZXRGb250U3R5bGUoKVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gQ2FsY3VsYXRlIGRldGFpbGVkIGRyYXdpbmcgaW5mb3JtYXRpb25cbiAgICAgICAgbGV0IHggPSBwYWRkaW5nTGVmdDtcbiAgICAgICAgbGV0IGxpbmVObyA9IDA7XG5cbiAgICAgICAgZm9yIChjb25zdCB0IG9mIHRleHQpIHtcbiAgICAgICAgICAgIC8vIFdyYXAgdGV4dFxuICAgICAgICAgICAgaWYgKHJlbmRlckluZm8ud29yZFdyYXAgJiYgeCArIHQud2lkdGggPiB3cmFwV2lkdGggfHwgdC50ZXh0ID09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgeCA9IHBhZGRpbmdMZWZ0O1xuICAgICAgICAgICAgICAgIGxpbmVObyArPSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdC5saW5lTm8gPSBsaW5lTm87XG5cbiAgICAgICAgICAgIGlmICh0LnRleHQgPT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdC54ID0geDtcbiAgICAgICAgICAgIHggKz0gdC53aWR0aDtcbiAgICAgICAgfVxuICAgICAgICByZW5kZXJJbmZvLmxpbmVOdW0gPSBsaW5lTm8gKyAxO1xuXG4gICAgICAgIGlmICh0aGlzLl9zZXR0aW5ncy5oKSB7XG4gICAgICAgICAgICByZW5kZXJJbmZvLmggPSB0aGlzLl9zZXR0aW5ncy5oO1xuICAgICAgICB9IGVsc2UgaWYgKHJlbmRlckluZm8ubWF4TGluZXMgJiYgcmVuZGVySW5mby5tYXhMaW5lcyA8IHJlbmRlckluZm8ubGluZU51bSkge1xuICAgICAgICAgICAgcmVuZGVySW5mby5oID0gcmVuZGVySW5mby5tYXhMaW5lcyAqIHJlbmRlckluZm8ubGluZUhlaWdodCArIGZvbnRTaXplIC8gMjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJlbmRlckluZm8uaCA9IHJlbmRlckluZm8ubGluZU51bSAqIHJlbmRlckluZm8ubGluZUhlaWdodCArIGZvbnRTaXplIC8gMjtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFRoaXMgY2FsY3VsYXRlcyB0aGUgYmFzZWxpbmUgb2Zmc2V0IGluIHBpeGVscyBmcm9tIHRoZSBmb250IHNpemUuXG4gICAgICAgIC8vIFRvIHJldHJp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ICAgICAgIHZhT2Zmc2V0ID0gcmVuZGVySW5mby5saW5lSGVpZ2h0IC0gcmVuZGVySW5mby5mb250U2l6ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIENhbGN1bGF0ZSBsaW5lcyBpbmZvcm1hdGlvblxuICAgICAgICByZW5kZXJJbmZvLmxpbmVzID0gW11cbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCByZW5kZXJJbmZvLmxpbmVOdW07IGkrKykge1xuICAgICAgICAgICAgcmVuZGVySW5mby5saW5lc1tpXSA9IHtcbiAgICAgICAgICAgICAgICB3aWR0aDogMCxcbiAgICAgICAgICAgICAgICB4OiAwLFxuICAgICAgICAgICAgICAgIHk6IHJlbmRlckluZm8ubGluZUhlaWdodCAqIGkgKyB2YU9mZnNldCxcbiAgICAgICAgICAgICAgICB0ZXh0OiBbXSxcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAobGV0IHQgb2YgdGV4dCkge1xuICAgICAgICAgICAgcmVuZGVySW5mby5saW5lc1t0LmxpbmVOb10udGV4dC5wdXNoKHQpO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gRmlsdGVyIG91dCB3aGl0ZSBzcGFjZXMgYXQgYmVnaW5uaW5nIGFuZCBlbmQgb2YgZWFjaCBsaW5lXG4gICAgICAgIGZvciAoY29uc3QgbCBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgICAgICBpZiAobC50ZXh0Lmxlbmd0aCA9PSAwKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGNvbnN0IGZpcnN0V29yZCA9IGwudGV4dFswXS50ZXh0O1xuICAgICAgICAgICAgY29uc3QgbGFzdFdvcmQgPSBsLnRleHRbbC50ZXh0Lmxlbmd0aCAtIDFdLnRleHQ7XG5cbiAgICAgICAgICAgIGlmIChmaXJzdFdvcmQgPT0gJ1xcbicpIHtcbiAgICAgICAgICAgICAgICBsLnRleHQuc2hpZnQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpc1NwYWNlKGxhc3RXb3JkKSB8fCBsYXN0V29yZCA9PSAnXFxuJykge1xuICAgICAgICAgICAgICAgIGwudGV4dC5wb3AoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG5cbiAgICAgICAgLy8gQ2FsY3VsYXRlIGxpbmUgd2lkdGhcbiAgICAgICAgZm9yIChsZXQgbCBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgICAgICBsLndpZHRoID0gbC50ZXh0LnJlZHVjZSgoYWNjLCB0KSA9PiBhY2MgKyB0LndpZHRoLCAwKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJlbmRlckluZm8ud2lkdGggPSB0aGlzLl9zZXR0aW5ncy53ICE9IDAgPyB0aGlzLl9zZXR0aW5ncy53ICogcHJlY2lzaW9uIDogTWF0aC5tYXgoLi4ucmVuZGVySW5mby5saW5lcy5tYXAoKGwpID0+IGwud2lkdGgpKSArIHBhZGRpbmdSaWdodDtcbiAgICAgICAgcmVuZGVySW5mby53ID0gcmVuZGVySW5mby53aWR0aDtcblxuICAgICAgICAvLyBBcHBseSBtYXhMaW5lc1N1ZmZpeFxuICAgICAgICBpZiAocmVuZGVySW5mby5tYXhMaW5lcyAmJiByZW5kZXJJbmZvLmxpbmVOdW0gPiByZW5kZXJJbmZvLm1heExpbmVzICYmIHJlbmRlckluZm8ubWF4TGluZXNTdWZmaXgpIHtcbiAgICAgICAgICAgIGNvbnN0IGluZGV4ID0gcmVuZGVySW5mby5tYXhMaW5lcyAtIDE7XG4gICAgICAgICAgICBsZXQgbGFzdExpbmVUZXh0ID0gdGV4dC5maWx0ZXIoKHQpID0+IHQubGluZU5vID09IGluZGV4KVxuICAgICAgICAgICAgbGV0IHN1ZmZpeCA9IHJlbmRlckluZm8ubWF4TGluZXNTdWZmaXg7XG4gICAgICAgICAgICBzdWZmaXggPSB0aGlzLnRva2VuaXplKHN1ZmZpeCk7XG4gICAgICAgICAgICBzdWZmaXggPSB0aGlzLnBhcnNlKHN1ZmZpeCk7XG4gICAgICAgICAgICBzdWZmaXggPSB0aGlzLm1lYXN1cmUoc3VmZml4LCByZW5kZXJJbmZvLmxldHRlclNwYWNpbmcsIHJlbmRlckluZm8uYmFzZUZvbnQpO1xuICAgICAgICAgICAgZm9yIChjb25zdCBzIG9mIHN1ZmZpeCkge1xuICAgICAgICAgICAgICAgIHMubGluZU5vID0gaW5kZXg7XG4gICAgICAgICAgICAgICAgcy54ID0gMDtcbiAgICAgICAgICAgICAgICBsYXN0TGluZVRleHQucHVzaChzKVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCBzcGwgPSBzdWZmaXgubGVuZ3RoICsgMVxuICAgICAgICAgICAgbGV0IF93ID0gbGFzdExpbmVUZXh0LnJlZHVjZSgoYWNjLCB0KSA9PiBhY2MgKyB0LndpZHRoLCAwKTtcbiAgICAgICAgICAgIHdoaWxlIChfdyA+IHJlbmRlckluZm8ud2lkdGggfHwgaXNTcGFjZShsYXN0TGluZVRleHRbbGFzdExpbmVUZXh0Lmxlbmd0aCAtIHNwbF0udGV4dCkpIHtcbiAgICAgICAgICAgICAgICBsYXN0TGluZVRleHQuc3BsaWNlKGxhc3RMaW5lVGV4dC5sZW5ndGggLSBzcGwsIDEpO1xuICAgICAgICAgICAgICAgIF93ID0gbGFzdExpbmVUZXh0LnJlZHVjZSgoYWNjLCB0KSA9PiBhY2MgKyB0LndpZHRoLCAwKTtcbiAgICAgICAgICAgICAgICBpZiAobGFzdExpbmVUZXh0Lmxlbmd0aCA8IHNwbCkge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmFsaWduTGluZShsYXN0TGluZVRleHQsIGxhc3RMaW5lVGV4dFswXS54KVxuXG4gICAgICAgICAgICByZW5kZXJJbmZvLmxpbmVzW2luZGV4XS50ZXh0ID0gbGFzdExpbmVUZXh0O1xuICAgICAgICAgICAgcmVuZGVySW5mby5saW5lc1tpbmRleF0ud2lkdGggPSBfdztcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEhvcml6b250YWwgYWxpZ25tZW50IG9mZnNldFxuICAgICAgICBpZiAocmVuZGVySW5mby50ZXh0QWxpZ24gPT0gJ2NlbnRlcicpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGwgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICAgICAgICAgIGwueCA9IChyZW5kZXJJbmZvLndpZHRoIC0gbC53aWR0aCAtIHBhZGRpbmdMZWZ0KSAvIDI7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAocmVuZGVySW5mby50ZXh0QWxpZ24gPT0gJ3JpZ2h0Jykge1xuICAgICAgICAgICAgZm9yIChsZXQgbCBvZiByZW5kZXJJbmZvLmxpbmVzKSB7XG4gICAgICAgICAgICAgICAgbC54ID0gcmVuZGVySW5mby53aWR0aCAtIGwud2lkdGggLSBwYWRkaW5nTGVmdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiByZW5kZXJJbmZvO1xuICAgIH1cblxuICAgIF9kcmF3KCkge1xuICAgICAgICBjb25zdCByZW5kZXJJbmZvID0gdGhpcy5fY2FsY3VsYXRlUmVuZGVySW5mbygpO1xuICAgICAgICBjb25zdCBwcmVjaXNpb24gPSB0aGlzLmdldFByZWNpc2lvbigpO1xuICAgICAgICBjb25zdCBwYWRkaW5nTGVmdCA9IHJlbmRlckluZm8ucGFkZGluZ0xlZnQgKiBwcmVjaXNpb247XG5cbiAgICAgICAgLy8gU2V0IGNhbnZhcyBkaW1lbnNpb25zXG4gICAgICAgIGxldCBjYW52YXNXaWR0aCA9IHJlbmRlckluZm8udyB8fCByZW5kZXJJbmZvLndpZHRoO1xuICAgICAgICBpZiAocmVuZGVySW5mby5jdXRT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5zaGFkb3dDb2xvcik7XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd09mZnNldFggPSB0aGlzLl9zZXR0aW5ncy5zaGFkb3dPZmZzZXRYICogcHJlY2lzaW9uO1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dPZmZzZXRZID0gdGhpcy5fc2V0dGluZ3Muc2hhZG93T2Zmc2V0WSAqIHByZWNpc2lvbjtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuc2hhZG93Qmx1ciA9IHRoaXMuX3NldHRpbmdzLnNoYWRvd0JsdXIgKiBwcmVjaXNpb247XG4gICAgICAgIH1cblxuICAgICAgICAvLyBEcmF3IHRleHRcbiAgICAgICAgY29uc3QgZGVmYXVsdENvbG9yID0gU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHRoaXMuX3NldHRpbmdzLnRleHRDb2xvcik7XG4gICAgICAgIGxldCBjdXJyZW50Q29sb3IgPSBkZWZhdWx0Q29sb3I7XG4gICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFN0eWxlID0gZGVmYXVsdENvbG9yO1xuICAgICAgICBmb3IgKGNvbnN0IGxpbmUgb2YgcmVuZGVySW5mby5saW5lcykge1xuICAgICAgICAgICAgZm9yIChjb25zdCB0IG9mIGxpbmUudGV4dCkge1xuICAgICAgICAgICAgICAgIGxldCBseCA9IDA7XG5cbiAgICAgICAgICAgICAgICBpZiAodC50ZXh0ID09ICdcXG4nKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChyZW5kZXJJbmZvLm1heExpbmVzICYmIHQubGluZU5vID49IHJlbmRlckluZm8ubWF4TGluZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKHQuY29sb3IgIT0gY3VycmVudENvbG9yKSB7XG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDb2xvciA9IHQuY29sb3I7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZmlsbFN0eWxlID0gY3VycmVudENvbG9yO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IHQuZm9udFN0eWxlO1xuXG4gICAgICAgICAgICAgICAgLy8gRHJhdyB3aXRoIGxldHRlciBzcGFjaW5nXG4gICAgICAgICAgICAgICAgaWYgKHQubGV0dGVycykge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBsIG9mIHQubGV0dGVycykge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgX3ggPSByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS54ICsgdC54ICsgbHg7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KGwudGV4dCwgX3gsIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnkgKyByZW5kZXJJbmZvLmZvbnRTaXplKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGx4ICs9IGwud2lkdGg7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAvLyBTdGFuZGFyZCBkcmF3aW5nXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgX3ggPSByZW5kZXJJbmZvLmxpbmVzW3QubGluZU5vXS54ICsgdC54O1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZXh0LmZpbGxUZXh0KHQudGV4dCwgX3gsIHJlbmRlckluZm8ubGluZXNbdC5saW5lTm9dLnkgKyByZW5kZXJJbmZvLmZvbnRTaXplKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvLyBSZXNldCB0ZXh0IHNoYWRvd1xuICAgICAgICBpZiAocHJldlNoYWRvd1NldHRpbmdzKSB7XG4gICAgICAgICAgICB0aGlzLl9jb250ZXh0LnNoYWRvd0NvbG9yID0gcHJldlNoYWRvd1NldHRpbmdzWzBdO1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dPZmZzZXRYID0gcHJldlNoYWRvd1NldHRpbmdzWzFdO1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dPZmZzZXRZID0gcHJldlNoYWRvd1NldHRpbmdzWzJdO1xuICAgICAgICAgICAgdGhpcy5fY29udGV4dC5zaGFkb3dCbHVyID0gcHJldlNoYWRvd1NldHRpbmdzWzNdO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gUmVzZXQgY3V0IHRyYW5zbGF0aW9uXG4gICAgICAgIGlmIChyZW5kZXJJbmZvLmN1dFN4IHx8IHJlbmRlckluZm8uY3V0U3kpIHtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRleHQudHJhbnNsYXRlKHJlbmRlckluZm8uY3V0U3gsIHJlbmRlckluZm8uY3V0U3kpO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gUG9zdHByb2Nlc3MgcmVuZGVySW5mby5saW5lcyB0byBiZSBjb21wYXRpYmxlIHdpdGggc3RhbmRhcmQgdmVyc2lvblxuICAgICAgICByZW5kZXJJbmZvLmxpbmVzID0gcmVuZGVySW5mby5saW5lcy5tYXAoKGwpID0+IGwudGV4dC5yZWR1Y2UoKGFjYywgdikgPT4gYWNjICsgdi50ZXh0LCAnJykpO1xuICAgICAgICBpZiAocmVuZGVySW5mby5tYXhMaW5lcykge1xuICAgICAgICAgICAgcmVuZGVySW5mby5saW5lcyA9IHJlbmRlckluZm8ubGluZXMuc2xpY2UoMCwgcmVuZGVySW5mby5tYXhMaW5lcyk7XG4gICAgICAgIH1cblxuXG4gICAgICAgIHRoaXMucmVuZGVySW5mbyA9IHJlbmRlckluZm87XG5cbiAgICB9O1xuXG4gICAgLyoqXG4gICAgICogU2VlIHtAbG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ICAgICAgICAgfSBlbHNlIGlmICh0ID09ICc8Yj4nKSB7XG4gICAgICAgICAgICAgICAgYm9sZCArPSAxO1xuICAgICAgICAgICAgICAgIHQgPSAnJztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodCA9PSAnPC9iPicgJiYgYm9sZCA+IDApIHtcbiAgICAgICAgICAgICAgICBib2xkIC09IDE7XG4gICAgICAgICAgICAgICAgdCA9ICcnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09ICc8L2NvbG9yPicpIHtcbiAgICAgICAgICAgICAgICBpZiAoY29sb3JTdGFjay5sZW5ndGggPiAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbG9yIC09IDE7XG4gICAgICAgICAgICAgICAgICAgIGNvbG9yU3RhY2sucG9wKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHQgPSAnJztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY29sb3JSZWdleHAudGVzdCh0KSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZWQgPSBjb2xvclJlZ2V4cC5leGVjKHQpO1xuICAgICAgICAgICAgICAgIGNvbG9yU3RhY2sucHVzaChcbiAgICAgICAgICAgICAgICAgICAgU3RhZ2VVdGlscy5nZXRSZ2JhU3RyaW5nKHBhcnNlSW50KG1hdGNoZWRbMV0pKVxuICAgICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgICAgY29sb3IgKz0gMTtcbiAgICAgICAgICAgICAgICB0ID0gJyc7XG5cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICB0ZXh0OiB0LFxuICAgICAgICAgICAgICAgIGl0YWxpYzogaXRhbGljLFxuICAgICAgICAgICAgICAgIGJvbGQ6IGJvbGQsXG4gICAgICAgICAgICAgICAgY29sb3I6IGNvbG9yU3RhY2tbY29sb3JdLFxuICAgICAgICAgICAgfVxuICAgICAgICB9KVxuICAgICAgICAuZmlsdGVyKChvKSA9PiBvLnRleHQgIT0gJycpO1xuICAgIH1cblxuICAgIGFwcGx5Rm9udFN0eWxlKHdvcmQsIGJhc2VGb250KSB7XG4gICAgICAgIGxldCBmb250ID0gYmFzZUZvbnQ7XG4gICAgICAgIGlmICh3b3JkLmJvbGQpIHtcbiAgICAgICAgICAgIGZvbnQgPSAnYm9sZCAnICsgZm9udDtcbiAgICAgICAgfVxuICAgICAgICBpZiAod29yZC5pdGFsaWMpIHtcbiAgICAgICAgICAgIGZvbnQgPSAnaXRhbGljICcgKyBmb250O1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IGZvbnRcbiAgICAgICAgd29yZC5mb250U3R5bGUgPSBmb250O1xuICAgIH1cblxuICAgIHJlc2V0Rm9udFN0eWxlKGJhc2VGb250KSB7XG4gICAgICAgIHRoaXMuX2NvbnRleHQuZm9udCA9IGJhc2VGb250O1xuICAgIH1cblxuICAgIG1lYXN1cmUocGFyc2VkLCBsZXR0ZXJTcGFjaW5nID0gMCwgYmFzZUZvbnQpIHtcbiAgICAgICAgZm9yIChjb25zdCBwIG9mIHBhcnNlZCkge1xuICAgICAgICAgICAgdGhpcy5hcHBseUZvbnRTdHlsZShwLCBiYXNlRm9udCk7XG4gICAgICAgICAgICBwLndpZHRoID0gdGhpcy5tZWFzdXJlVGV4dChwLnRleHQsIGxldHRlclNwYWNpbmcpO1xuXG4gICAgICAgICAgICAvLyBMZXR0ZXIgYnkgbGV0dGVyIGRldGFpbCBmb3IgbGV0dGVyIHNwYWNpbmdcbiAgICAgICAgICAgIGlmIChsZXR0ZXJTcGFjaW5nID4gMCkge1xuICAgICAgICAgICAgICAgIHAubGV0dGVycyA9IHAudGV4dC5zcGxpdCgnJykubWFwKChsKSA9PiB7cmV0dXJuIHt0ZXh0OiBsfX0pO1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGwgb2YgcC5sZXR0ZXJzKSB7XG4gICAgICAgICAgICAgICAgICAgIGwud2lkdG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5cbiAgICAgICAgLyogSW4gY2FzZSBndWVzcyB3YXMgb3ZlcmVzdGltYXRlZCwgc2hyaW5rIGl0IGxldHRlciBieSBsZXR0ZXIuICovXG4gICAgICAgIGlmICh0cnVuY1dvcmRXaWR0aCA+IHdvcmRXcmFwV2lkdGgpIHtcbiAgICAgICAgICAgIHdoaWxlIChjdXRvZmZJbmRleCA+IDApIHtcbiAgICAgICAgICAgICAgICB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgY3V0b2ZmSW5kZXgpKSArIHN1ZmZpeFdpZHRoO1xuICAgICAgICAgICAgICAgIGlmICh0cnVuY1dvcmRXaWR0aCA+IHdvcmRXcmFwV2lkdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgY3V0b2ZmSW5kZXggLT0gMTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgLyogSW4gY2FzZSBndWVzcyB3YXMgdW5kZXJlc3RpbWF0ZWQsIGV4dGVuZCBpdCBsZXR0ZXIgYnkgbGV0dGVyLiAqL1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgd2hpbGUgKGN1dG9mZkluZGV4IDwgd29yZExlbikge1xuICAgICAgICAgICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBjdXRvZmZJbmRleCkpICsgc3VmZml4V2lkdGg7XG4gICAgICAgICAgICAgICAgaWYgKHRydW5jV29yZFdpZHRoIDwgd29yZFdyYXBXaWR0aCkge1xuICAgICAgICAgICAgICAgICAgICBjdXRvZmZJbmRleCArPSAxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZpbmFsbHksIHdoZW4gYm91bmQgaXMgY3Jvc3NlZCwgcmV0cmFjdCBsYXN0IGxldHRlci5cbiAgICAgICAgICAgICAgICAgICAgY3V0b2ZmSW5kZXggLT0xO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKiBJZiB3cmFwV2lkdGggaXMgdG9vIHNob3J0IHRvIGV2ZW4gY29udGFpbiBzdWZmaXggYWxvbmUsIHJldHVybiBlbXB0eSBzdHJpbmcgKi9cbiAgICAgICAgcmV0dXJuIHdvcmQuc3Vic3RyaW5nKDAsIGN1dG9mZkluZGV4KSArICh3b3JkV3JhcFdpZHRoID49IHN1ZmZpeFdpZHRoID8gc3VmZml4IDogJycpXG4gICAgfVxuXG4gICAgX2dldEJyZWFrSW5kZXgod29yZCwgd2lkdGgpIHtcbiAgICAgICAgY29uc3Qgd29yZExlbiA9IHdvcmQubGVuZ3RoO1xuICAgICAgICBjb25zdCB3b3JkV2lkdGggPSB0aGlzLm1lYXN1cmVUZXh0KHdvcmQpO1xuXG4gICAgICAgIGlmICh3b3JkV2lkdGggPD0gd2lkdGgpIHtcbiAgICAgICAgICAgIHJldHVybiB7YnJlYWtJbmRleDogd29yZC5sZW5ndGgsIHRydW5jV29yZFdpZHRoOiB3b3JkV2lkdGh9O1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGJyZWFrSW5kZXggPSBNYXRoLmZsb29yKCh3aWR0aCAqIHdvcmRMZW4pIC8gd29yZFdpZHRoKTtcbiAgICAgICAgbGV0IHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSlcblxuICAgICAgICAvKiBJbiBjYXNlIGd1ZXNzIHdhcyBvdmVyZXN0aW1hdGVkLCBzaHJpbmsgaXQgbGV0dGVyIGJ5IGxldHRlci4gKi9cbiAgICAgICAgaWYgKHRydW5jV29yZFdpZHRoID4gd2lkdGgpIHtcbiAgICAgICAgICAgIHdoaWxlIChicmVha0luZGV4ID4gMCkge1xuICAgICAgICAgICAgICAgIHRydW5jV29yZFdpZHRoID0gdGhpcy5tZWFzdXJlVGV4dCh3b3JkLnN1YnN0cmluZygwLCBicmVha0luZGV4KSk7XG4gICAgICAgICAgICAgICAgaWYgKHRydW5jV29yZFdpZHRoID4gd2lkdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWtJbmRleCAtPSAxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAvKiBJbiBjYXNlIGd1ZXNzIHdhcyB1bmRlcmVzdGltYXRlZCwgZXh0ZW5kIGl0IGxldHRlciBieSBsZXR0ZXIuICovXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB3aGlsZSAoYnJlYWtJbmRleCA8IHdvcmRMZW4pIHtcbiAgICAgICAgICAgICAgICB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgYnJlYWtJbmRleCkpO1xuICAgICAgICAgICAgICAgIGlmICh0cnVuY1dvcmRXaWR0aCA8IHdpZHRoKSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrSW5kZXggKz0gMTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBGaW5hbGx5LCB3aGVuIGJvdW5kIGlzIGNyb3NzZWQsIHJldHJhY3QgbGFzdCBsZXR0ZXIuXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrSW5kZXggLT0xO1xuICAgICAgICAgICAgICAgICAgICB0cnVuY1dvcmRXaWR0aCA9IHRoaXMubWVhc3VyZVRleHQod29yZC5zdWJzdHJpbmcoMCwgYnJlYWtJbmRleCkpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHticmVha0luZGV4LCB0cnVuY1dvcmRXaWR0aH07XG5cbiAgICB9XG5cbiAgICB3b3JkQnJlYWsod29yZCwgd2lkdGgsIGJhc2VGb250KSB7XG4gICAgICAgIGlmICghd29yZC50ZXh0KSB7XG4gICAgICAgICAgICByZXR1cm4gd29yZFxuICAgICAgICB9XG4gICAgICAgIHRoaXMuYXBwbHlGb250U3R5bGUod29yZCwgYmFzZUZvbnQpXG4gICAgICAgIGNvbnN0IHBhcnRzID0gW107XG4gICAgICAgIGxldCB0ZXh0ID0gd29yZC50ZXh0O1xuICAgICAgICBpZiAoIXdvcmQubGV0dGVycykge1xuICAgICAgICAgICAgd2hpbGUgKHRydWUpIHtcbiAgICAgICAgICAgICAgICBjb25zdCB7YnJlYWtJbmRleCwgdHJ1bmNXb3JkV2lkdGh9ID0gdGhpcy5fZ2V0QnJlYWtJbmRleCh0ZXh0LCB3aWR0aCk7XG4gICAgICAgICAgICAgICAgcGFydHMucHVzaCh7Li4ud29yZH0pO1xuICAgICAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLnRleHQgPSB0ZXh0LnNsaWNlKDAsIGJyZWFrSW5kZXgpO1xuICAgICAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLndpZHRoID0gdHJ1bmNXb3JkV2lkdGg7XG5cbiAgICAgICAgICAgICAgICBpZiAoYnJlYWtJbmRleCA9PT0gdGV4dC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdGV4dCA9IHRleHQuc2xpY2UoYnJlYWtJbmRleCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsZXQgdG90YWxXaWR0aCA9IDA7XG4gICAgICAgICAgICBsZXQgbGV0dGVycyA9IFtdO1xuICAgICAgICAgICAgbGV0IGJyZWFrSW5kZXggPSAwO1xuICAgICAgICAgICAgZm9yIChjb25zdCBsIG9mIHdvcmQubGV0dGVycykge1xuICAgICAgICAgICAgICAgIGlmICh0b3RhbFdpZHRoICsgbC53aWR0aCA+PSB3aWR0aCkge1xuICAgICAgICAgICAgICAgICAgICBwYXJ0cy5wdXNoKHsuLi53b3JkfSk7XG4gICAgICAgICAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLnRleHQgPSB0ZXh0LnNsaWNlKDAsIGJyZWFrSW5kZXgpO1xuICAgICAgICAgICAgICAgICAgICBwYXJ0c1twYXJ0cy5sZW5ndGggLSAxXS53aWR0aCA9IHRvdGFsV2lkdGg7XG4gICAgICAgICAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLmxldHRlcnMgPSBsZXR0ZXJzO1xuICAgICAgICAgICAgICAgICAgICB0ZXh0ID0gdGV4dC5zbGljZShicmVha0luZGV4KTtcbiAgICAgICAgICAgICAgICAgICAgdG90YWxXaWR0aCA9IDA7XG4gICAgICAgICAgICAgICAgICAgIGxldHRlcnMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWtJbmRleCA9IDA7XG5cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBicmVha0luZGV4ICs9IDE7XG4gICAgICAgICAgICAgICAgICAgIGxldHRlcnMucHVzaChsKTtcbiAgICAgICAgICAgICAgICAgICAgdG90YWxXaWR0aCArPSBsLndpZHRoO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRvdGFsV2lkdGggPiAwKSB7XG4gICAgICAgICAgICAgICAgcGFydHMucHVzaCh7Li4ud29yZH0pO1xuICAgICAgICAgICAgICAgIHBhcnRzW3BhcnRzLmxlbmd0aCAtIDFdLnRleHQgPSB0ZXh0LnNsaWNlKDAsIGJyZ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YXQgaXMuXG4gICAgICAgICAgICAgICAgLy8gZ3JlYXRlciB0aGFuIHRoZSB3b3JkIHdyYXAgd2lkdGguXG4gICAgICAgICAgICAgICAgaWYgKGogPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdExpbmVzLnB1c2gocmVzdWx0KTtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gJyc7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJlc3VsdCArPSB3b3JkO1xuICAgICAgICAgICAgICAgIHNwYWNlTGVmdCA9IHdvcmRXcmFwV2lkdGggLSB3b3JkV2lkdGggLSAoaiA9PT0gMCA/IGluZGVudCA6IDApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgc3BhY2VMZWZ0IC09IHdvcmRXaWR0aFdpdGhTcGFjZTtcbiAgICAgICAgICAgICAgICByZXN1bHQgKz0gc3BhY2UgKyB3b3JkO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJlc3VsdExpbmVzLnB1c2gocmVzdWx0KTtcbiAgICAgICAgcmVzdWx0ID0gJyc7XG4gICAgICAgIGFsbExpbmVzID0gYWxsTGluZXMuY29uY2F0KHJlc3VsdExpbmVzKTtcbiAgICAgICAgaWYgKGkgPCBsaW5lcy5sZW5ndGggLSAxKSB7XG4gICAgICAgICAgICByZWFsTmV3bGluZXMucHVzaChhbGxMaW5lcy5sZW5ndGgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJldHVybiB7IGw6IGFsbExpbmVzLCBuOiByZWFsTmV3bGluZXMgfTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPVRleHRUZXh0dXJlUmVuZGVyZXJVdGlscy5tanMubWFwIiwiLypcbiAqIElmIG5vdCBzdGF0ZWQgb3RoZXJ3aXNlIGluIHRoaXMgZmlsZSBvciB0aGlzIGNvbXBvbmVudCdzIExJQ0VOU0UgZmlsZSB0aG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Y2xlYXIoKSB7XG4gICAgICAgIHRoaXMuX3AgPSBbXTtcbiAgICAgICAgdGhpcy5fcGUgPSBbXTtcbiAgICAgICAgdGhpcy5faWRwID0gW107XG4gICAgICAgIHRoaXMuX2YgPSBbXTtcbiAgICAgICAgdGhpcy5fdiA9IFtdO1xuICAgICAgICB0aGlzLl9sdiA9IFtdO1xuICAgICAgICB0aGlzLl9zbSA9IFtdO1xuICAgICAgICB0aGlzLl9zID0gW107XG4gICAgICAgIHRoaXMuX3ZlID0gW107XG4gICAgICAgIHRoaXMuX3NtZSA9IFtdO1xuICAgICAgICB0aGlzLl9zZSA9IFtdO1xuXG4gICAgICAgIHRoaXMuX2xlbmd0aCA9IDA7XG4gICAgfVxuXG4gICAgcGFyc2UocmdiYSwgZGVmKSB7XG4gICAgICAgIGxldCBpLCBuO1xuICAgICAgICBpZiAoIVV0aWxzLmlzT2JqZWN0TGl0ZXJhbChkZWYpKSB7XG4gICAgICAgICAgICBkZWYgPSB7MDogZGVmfVxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGRlZmF1bHRTbW9vdGhuZXNzID0gMC41O1xuXG4gICAgICAgIGxldCBpdGVtcyA9IFtdO1xuICAgICAgICBmb3IgKGxldCBrZXkgaW4gZGVmKSB7XG4gICAgICAgICAgICBpZiAoZGVmLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgICAgICBsZXQgb2JqID0gZGVmW2tleV07XG4gICAgICAgICAgICAgICAgaWYgKCFVdGlscy5pc09iamVjdExpdGVyYWwob2JqKSkge1xuICAgICAgICAgICAgICAgICAgICBvYmogPSB7djogb2JqfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGxldCBwID0gcGFyc2VGbG9hdChrZXkpO1xuXG4gICAgICAgICAgICAgICAgaWYgKGtleSA9PT0gXCJzbVwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHRTbW9vdGhuZXNzID0gb2JqLnY7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICghaXNOYU4ocCkgJiYgcCA+PSAwICYmIHAgPD0gMikge1xuICAgICAgICAgICAgICAgICAgICBvYmoucCA9IHA7XG5cbiAgICAgICAgICAgICAgICAgICAgb2JqLmYgPSBVdGlscy5pc0Z1bmN0aW9uKG9iai52KTtcbiAgICAgICAgICAgICAgICAgICAgb2JqLmx2ID0gb2JqLmYgPyBvYmoudigwLCAwKSA6IG9iai52O1xuXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2gob2JqKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvLyBTb3J0IGJ5IHByb2dyZXNzIHZhbHVlLlxuICAgICAgICBpdGVtcyA9IGl0ZW1zLnNvcnQoZnVuY3Rpb24oYSwgYikge3JldHVybiBhLnAgLSBiLnB9KTtcblxuICAgICAgICBuID0gaXRlbXMubGVuZ3RoO1xuXG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGxldCBsYXN0ID0gKGkgPT09IG4gLSAxKTtcbiAgICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoJ3BlJykpIHtcbiAgICAgICAgICAgICAgICAvLyBQcm9ncmVzcy5cbiAgICAgICAgICAgICAgICBpdGVtc1tpXS5wZSA9IGxhc3QgPyAoaXRlbXNbaV0ucCA8PSAxID8gMSA6IDIgLyogc3VwcG9ydCBvbmV0b3R3byBzdG9wICovKSA6IGl0ZW1zW2kgKyAxXS5wO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBQcmV2ZW50IG11bHRpcGxlIGl0ZW1zIGF0IHRoZSBzYW1lIHRpbWUuXG4gICAgICAgICAgICAgICAgY29uc3QgbWF4ID0gaSA8IG4gLSAxID8gaXRlbXNbaSArIDFdLnAgOiAxO1xuICAgICAgICAgICAgICAgIGlmIChpdGVtc1tpXS5wZSA+IG1heCkge1xuICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS5wZSA9IG1heDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoaXRlbXNbaV0ucGUgPT09IGl0ZW1zW2ldLnApIHtcbiAgICAgICAgICAgICAgICBpdGVtc1tpXS5pZHAgPSAwO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpdGVtc1tpXS5pZHAgPSAxIC8gKGl0ZW1zW2ldLnBlIC0gaXRlbXNbaV0ucCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvLyBDb2xvciBtZXJnZXI6IHdlIG5lZWQgdG8gc3BsaXQvY29tYmluZSBSR0JBIGNvbXBvbmVudHMuXG5cbiAgICAgICAgLy8gQ2FsY3VsYXRlIGJlemllciBoZWxwZXIgdmFsdWVzLjtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKCFpdGVtc1tpXS5oYXNPd25Qcm9wZXJ0eSgnc20nKSkge1xuICAgICAgICAgICAgICAgIC8vIFNtb290aG5lc3MuO1xuICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnNtID0gZGVmYXVsdFNtb290aG5lc3M7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KCdzJykpIHtcbiAgICAgICAgICAgICAgICAvLyBTbG9wZS47XG4gICAgICAgICAgICAgICAgaWYgKGkgPT09IDAgfHwgaSA9PT0gbiAtIDEgfHwgKGl0ZW1zW2ldLnAgPT09IDEgLyogZm9yIG9uZXRvdHdvICovKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBIb3Jpem9udGFsIHNsb3BlIGF0IHN0YXJ0IGFuZCBlbmQuO1xuICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXS5zID0gcmdiYSA/IFswLCAwLCAwLCAwXSA6IDA7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGkgPSBpdGVtc1tpIC0gMV07XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG5pID0gaXRlbXNbaSArIDFdO1xuICAgICAgICAgICAgICAgICAgICBpZiAocGkucCA9PT0gbmkucCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IHJnYmEgPyBbMCwgMCwgMCwgMF0gOiAwO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJnYmEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuYyA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKG5pLmx2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYyA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKHBpLmx2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkID0gMSAvIChuaS5wIC0gcGkucCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0ucyA9IFtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCAqIChuY1swXSAtIHBjWzBdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCAqIChuY1sxXSAtIHBjWzFdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCAqIChuY1syXSAtIHBjWzJdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCAqIChuY1szXSAtIHBjWzNdKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnMgPSAobmkubHYgLSBwaS5sdikgLyAobmkucCAtIHBpLnApO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChpID0gMDsgaSA8IG4gLSAxOyBpKyspIHtcbiAgICAgICAgICAgIC8vIENhbGN1bGF0ZSB2YWx1ZSBmdW5jdGlvbi47XG4gICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmYpIHtcblxuICAgICAgICAgICAgICAgIGxldCBsYXN0ID0gKGkgPT09IG4gLSAxKTtcbiAgICAgICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KCd2ZScpKSB7XG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldLnZlID0gbGFzdCA/IGl0ZW1zW2ldLmx2IDogaXRlbXNbaSArIDFdLmx2O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIFdlIGNhbiBvbmx5IGludGVycG9sYXRlIG9uIG51bWVyaWMgdmFsdWVzLiBOb24tbnVtZXJpYyB2YWx1ZXMgYXJlIHNldCBsaXRlcmFsbHkgd2hlbiByZWFjaGVkIHRpbWUuXG4gICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzTnVtYmVyKGl0ZW1zW2ldLnYpICYmIFV0aWxzLmlzTnVtYmVyKGl0ZW1zW2ldLmx2KSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIWl0ZW1zW2ldLmhhc093blByb3BlcnR5KCdzbWUnKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV0uc21lID0gbGFzdCA/IGRlZmF1bHRTbW9vdGhuZXNzIDogaXRlbXNbaSArIDFdLnNtO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGlmICghaXRlbXNbaV0uaGFzT3duUHJvcGVydHkoJ3NlJykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldL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29lcyBmcm9tIDAgdG8gMS5cbiAgICAgICAgbGV0IGRwID0gcDIgLSBwMTtcbiAgICAgICAgczEgKj0gZHA7XG4gICAgICAgIHMyICo9IGRwO1xuXG4gICAgICAgIGxldCBoZWxwZXJzID0gTXVsdGlTcGxpbmUuZ2V0U3BsaW5lSGVscGVycyh2MSwgdjIsIG8xLCBpMiwgczEsIHMyKTtcbiAgICAgICAgaWYgKCFoZWxwZXJzKSB7XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHApIHtcbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gMCkgcmV0dXJuIHYxO1xuICAgICAgICAgICAgICAgIGlmIChwID09PSAxKSByZXR1cm4gdjI7XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gdjIgKiBwICsgdjEgKiAoMSAtIHApO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAocCkge1xuICAgICAgICAgICAgICAgIGlmIChwID09PSAwKSByZXR1cm4gdjE7XG4gICAgICAgICAgICAgICAgaWYgKHAgPT09IDEpIHJldHVybiB2MjtcbiAgICAgICAgICAgICAgICByZXR1cm4gTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnMsIHApO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBzdGF0aWMgZ2V0U3BsaW5lUmdiYVZhbHVlRnVuY3Rpb24odjEsIHYyLCBwMSwgcDIsIG8xLCBpMiwgczEsIHMyKSB7XG4gICAgICAgIC8vIE5vcm1hbGl6ZSBzbG9wZXMgYmVjYXVzZSB3ZSB1c2UgYSBzcGxpbmUgdGhhdCBnb2VzIGZyb20gMCB0byAxLlxuICAgICAgICBsZXQgZHAgPSBwMiAtIHAxO1xuICAgICAgICBzMVswXSAqPSBkcDtcbiAgICAgICAgczFbMV0gKj0gZHA7XG4gICAgICAgIHMxWzJdICo9IGRwO1xuICAgICAgICBzMVszXSAqPSBkcDtcbiAgICAgICAgczJbMF0gKj0gZHA7XG4gICAgICAgIHMyWzFdICo9IGRwO1xuICAgICAgICBzMlsyXSAqPSBkcDtcbiAgICAgICAgczJbM10gKj0gZHA7XG5cbiAgICAgICAgbGV0IGN2MSA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKHYxKTtcbiAgICAgICAgbGV0IGN2MiA9IE11bHRpU3BsaW5lLmdldFJnYmFDb21wb25lbnRzKHYyKTtcblxuICAgICAgICBsZXQgaGVscGVycyA9IFtcbiAgICAgICAgICAgIE11bHRpU3BsaW5lLmdldFNwbGluZUhlbHBlcnMoY3YxWzBdLCBjdjJbMF0sIG8xLCBpMiwgczFbMF0sIHMyWzBdKSxcbiAgICAgICAgICAgIE11bHRpU3BsaW5lLmdldFNwbGluZUhlbHBlcnMoY3YxWzFdLCBjdjJbMV0sIG8xLCBpMiwgczFbMV0sIHMyWzFdKSxcbiAgICAgICAgICAgIE11bHRpU3BsaW5lLmdldFNwbGluZUhlbHBlcnMoY3YxWzJdLCBjdjJbMl0sIG8xLCBpMiwgczFbMl0sIHMyWzJdKSxcbiAgICAgICAgICAgIE11bHRpU3BsaW5lLmdldFNwbGluZUhlbHBlcnMoY3YxWzNdLCBjdjJbM10sIG8xLCBpMiwgczFbM10sIHMyWzNdKVxuICAgICAgICBdO1xuXG4gICAgICAgIGlmICghaGVscGVyc1swXSkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIChwKSB7XG4gICAgICAgICAgICAgICAgLy8gTGluZWFyLlxuICAgICAgICAgICAgICAgIGlmIChwID09PSAwKSByZXR1cm4gdjE7XG4gICAgICAgICAgICAgICAgaWYgKHAgPT09IDEpIHJldHVybiB2MjtcblxuICAgICAgICAgICAgICAgIHJldHVybiBNdWx0aVNwbGluZS5tZXJnZUNvbG9ycyh2MiwgdjEsIHApO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAocCkge1xuICAgICAgICAgICAgICAgIGlmIChwID09PSAwKSByZXR1cm4gdjE7XG4gICAgICAgICAgICAgICAgaWYgKHAgPT09IDEpIHJldHVybiB2MjtcblxuICAgICAgICAgICAgICAgIHJldHVybiBNdWx0aVNwbGluZS5nZXRBcmdiTnVtYmVyKFtcbiAgICAgICAgICAgICAgICAgICAgTWF0aC5taW4oMjU1LCBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVyc1swXSwgcCkpLFxuICAgICAgICAgICAgICAgICAgICBNYXRoLm1pbigyNTUsIE11bHRpU3BsaW5lLmNhbGN1bGF0ZVNwbGluZShoZWxwZXJzWzFdLCBwKSksXG4gICAgICAgICAgICAgICAgICAgIE1hdGgubWluKDI1NSwgTXVsdGlTcGxpbmUuY2FsY3VsYXRlU3BsaW5lKGhlbHBlcnNbMl0sIHApKSxcbiAgICAgICAgICAgICAgICAgICAgTWF0aC5taW4oMjU1LCBNdWx0aVNwbGluZS5jYWxjdWxhdGVTcGxpbmUoaGVscGVyc1szXSwgcCkpXG4gICAgICAgICAgICAgICAgXSk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICB9O1xuXG4gICAgLyoqXG4gICAgICogQ3JlYXRlcyBoZWxwZXJzIHRvIGJlIHVzZWQgaW4gdGhlIHNwbGluZSBmdW5jdGlvbi5cbiAgICAgKiBAcGFyYW0ge251bWJlcn0gdjFcbiAgICAgKiAgIEZyb20gdmFsdWUuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHYyXG4gICAgICogICBUbyB2YWx1ZS5cbiAgICAgKiBAcGFyYW0ge251bWJlcn0gbzFcbiAgICAgKiAgIEZyb20gc21vb3RobmVzcyAoMCA9IGxpbmVhciwgMSA9IHNtb290aCkuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHMxXG4gICAgICogICBGcm9tIHNsb3BlICgwID0gaG9yaXpvbnRhbCwgaW5maW5pd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k9dCoodCoodCphK2IpK2MpLlxuICAgICAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcblxuICAgICAgICAgICAgZHggPSBwIC0gY2J4O1xuICAgICAgICAgICAgaWYgKGR4ID4gLTFlLTggJiYgZHggPCAxZS04KSB7XG4gICAgICAgICAgICAgICAgLy8gU29sdXRpb24gZm91bmQhXG4gICAgICAgICAgICAgICAgcmV0dXJuIHQgKiAodCAqICh0ICogeWEgKyB5YikgKyB5YykgKyB5ZDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gQ3ViaWMgYmV6aWVyIGRlcml2YXRpdmUgZnVuY3Rpb246IGYnKHQpPXQqKHQqKDMqYSkrMipiKStjXG4gICAgICAgICAgICBsZXQgY2J4ZCA9IHQgKiAodCAqICgzICogeGEpICsgMiAqIHhiKSArIHhjO1xuXG4gICAgICAgICAgICBpZiAoY2J4ZCA+IDFlLTEwICYmIGNieGQgPCAxZS0xMCkge1xuICAgICAgICAgICAgICAgIC8vIFByb2JsZW1hdGljLiBGYWxsIGJhY2sgdG8gYmluYXJ5IHNlYXJjaCBtZXRob2QuXG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHQgKz0gZHggLyBjYnhkO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gRmFsbGJhY2s6IGJpbmFyeSBzZWFyY2ggbWV0aG9kLiBUaGlzIGlzIG1vcmUgcmVsaWFibGUgd2hlbiB0aGVyZSBhcmUgbmVhci0wIHNsb3Blcy5cbiAgICAgICAgbGV0IG1pblQgPSAwO1xuICAgICAgICBsZXQgbWF4VCA9IDE7XG4gICAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICAgICAgdCA9IDAuNSAqIChtaW5UICsgbWF4VCk7XG5cbiAgICAgICAgICAgIC8vIEN1YmljIGJlemllciBmdW5jdGlvbjogZih0KT10Kih0Kih0KmErYikrYykrZC5cbiAgICAgICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG5cbiAgICAgICAgICAgIGR4ID0gcCAtIGNieDtcbiAgICAgICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgICAgICAgIC8vIFNvbHV0aW9uIGZvdW5kIVxuICAgICAgICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpICsgeWQ7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChkeCA8IDApIHtcbiAgICAgICAgICAgICAgICBtYXhUID0gdDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbWluVCA9IHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdDtcbiAgICB9O1xuXG4gICAgc3RhdGljIG1lcmdlQ29sb3JzKGMxLCBjMiwgcCkge1xuICAgICAgICBsZXQgcjEgPSAoKGMxIC8gNjU1MzYpIHwgMCkgJSAyNTY7XG4gICAgICAgIGxldCBnMSA9ICgoYzEgLyAyNTYpIHwgMCkgJSAyNTY7XG4gICAgICAgIGxldCBiMSA9IGMxICUgMjU2O1xuICAgICAgICBsZXQgYTEgPSAoKGMxIC8gMTY3NzcyMTYpIHwgMCk7XG5cbiAgICAgICAgbGV0IHIyID0gKChjMiAvIDY1NTM2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgZzIgPSAoKGMyIC8gMjU2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgYjIgPSBjMiAlIDI1NjtcbiAgICAgICAgbGV0IGEyID0gKChjMiAvIDE2Nzc3MjE2KSB8IDApO1xuXG4gICAgICAgIGxldCByID0gcjEgKiBwICsgcjIgKiAoMSAtIHApO1xuICAgICAgICBsZXQgZyA9IGcxICogcCArIGcyICogKDEgLSBwKTtcbiAgICAgICAgbGV0IGIgPSBiMSA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dXJuIGY7XG4gICAgfVxuXG4gICAgc3RhdGljIG1lcmdlKGEsIGIpIHtcbiAgICAgICAgY29uc3QgYWtzID0gT2JqZWN0LmtleXMoYSk7XG4gICAgICAgIGNvbnN0IGJrcyA9IE9iamVjdC5rZXlzKGIpO1xuXG4gICAgICAgIGlmICghYmtzLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIGE7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBDcmVhdGUgaW5kZXggYXJyYXkgZm9yIGFsbCBlbGVtZW50cy5cbiAgICAgICAgY29uc3QgYWkgPSB7fTtcbiAgICAgICAgY29uc3QgYmkgPSB7fTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBia3MubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBrZXkgPSBia3NbaV07XG4gICAgICAgICAgICBhaVtrZXldID0gLTE7XG4gICAgICAgICAgICBiaVtrZXldID0gaTtcbiAgICAgICAgfVxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGFrcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGtleSA9IGFrc1tpXTtcbiAgICAgICAgICAgIGFpW2tleV0gPSBpO1xuICAgICAgICAgICAgaWYgKGJpW2tleV0gPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGJpW2tleV0gPSAtMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IGFrc2wgPSBha3MubGVuZ3RoO1xuXG4gICAgICAgIGNvbnN0IHJlc3VsdCA9IHt9O1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGJrcy5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IGtleSA9IGJrc1tpXTtcblxuICAgICAgICAgICAgLy8gUHJlcGVuZCBhbGwgaXRlbXMgaW4gYSB0aGF0IGFyZSBub3QgaW4gYiAtIGJlZm9yZSB0aGUgbm93IGFkZGVkIGIgYXR0cmlidXRlLlxuICAgICAgICAgICAgY29uc3QgYUluZGV4ID0gYWlba2V5XTtcbiAgICAgICAgICAgIGxldCBjdXJJbmRleCA9IGFJbmRleDtcbiAgICAgICAgICAgIHdoaWxlKC0tY3VySW5kZXggPj0gMCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXhdO1xuICAgICAgICAgICAgICAgIGlmIChiaVtha2V5XSAhPT0gLTEpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQWxyZWFkeSBmb3VuZD8gU3RvcCBwcm9jZXNzaW5nLlxuICAgICAgICAgICAgICAgICAgICAvLyBOb3QgeWV0IGZvdW5kIGJ1dCBleGlzdHMgaW4gYj8gQWxzbyBzdG9wIHByb2Nlc3Npbmc6IHdhaXQgdW50aWwgd2UgZmluZCBpdCBpbiBiLlxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB3aGlsZSgrK2N1ckluZGV4IDwgYUluZGV4KSB7XG4gICAgICAgICAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleF07XG4gICAgICAgICAgICAgICAgcmVzdWx0W2FrZXldID0gYVtha2V5XTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29uc3QgYnYgPSBiW2tleV07XG4gICAgICAgICAgICBjb25zdCBhdiA9IGFba2V5XTtcbiAgICAgICAgICAgIGxldCByO1xuICAgICAgICAgICAgaWYgKHRoaXMuaXNNZihidikpIHtcbiAgICAgICAgICAgICAgICByID0gYnYoYXYpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAoIVV0aWxzLmlzT2JqZWN0TGl0ZXJhbChhdikgfHwgIVV0aWxzLmlzT2JqZWN0TGl0ZXJhbChidikpIHtcbiAgICAgICAgICAgICAgICAgICAgciA9IGJ2O1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHIgPSBPYmpNZXJnZXIubWVyZ2UoYXYsIGJ2KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIFdoZW4gbWFya2VkIGFzIHVuZGVmaW5lZCwgcHJvcGVydHkgaXMgZGVsZXRlZC5cbiAgICAgICAgICAgIGlmIChyICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICByZXN1bHRba2V5XSA9IHI7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvLyBBcHBlbmQgcmVtYWluaW5nIGZpbmFsIGl0ZW1zIGluIGEuXG4gICAgICAgIGxldCBjdXJJbmRleCA9IGFrc2w7XG4gICAgICAgIHdoaWxlKC0tY3VySW5kZXggPj0gMCkge1xuICAgICAgICAgICAgY29uc3QgYWtleSA9IGFrc1tjdXJJbmRleF07XG4gICAgICAgICAgICBpZiAoYmlbYWtleV0gIT09IC0xKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgd2hpbGUoKytjdXJJbmRleCA8IGFrc2wpIHtcbiAgICAgICAgICAgIGNvbnN0IGFrZXkgPSBha3NbY3VySW5kZXhdO1xuICAgICAgICAgICAgcmVzdWx0W2FrZXldID0gYVtha2V5XTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXMgYXBwbHk6XG4gKlxuICogQ29weXJpZ2h0IDIwMjAgTWV0cm9sb2dpY2FsXG4gKlxuICogTGljZW5z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iAgICAgICAgcmV0dXJuIFV0aWxzLmdldE1vZHVsb0luZGV4KGluZGV4LCBhcnIubGVuZ3RoKTtcbiAgICB9XG5cbiAgICBzdGF0aWMgZXF1YWxWYWx1ZXModjEsIHYyKSB7XG4gICAgICAgIGlmICgodHlwZW9mIHYxKSAhPT0gKHR5cGVvZiB2MikpIHJldHVybiBmYWxzZVxuICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHYxKSkge1xuICAgICAgICAgICAgcmV0dXJuIFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2MikgJiYgVXRpbHMuZXF1YWxPYmplY3RMaXRlcmFscyh2MSwgdjIpXG4gICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheSh2MSkpIHtcbiAgICAgICAgICAgIHJldHVybiBBcnJheS5pc0FycmF5KHYyKSAmJiBVdGlscy5lcXVhbEFycmF5cyh2MSwgdjIpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdjEgPT09IHYyXG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZXF1YWxPYmplY3RMaXRlcmFscyhvYmoxLCBvYmoyKSB7XG4gICAgICAgIGxldCBrZXlzMSA9IE9iamVjdC5rZXlzKG9iajEpO1xuICAgICAgICBsZXQga2V5czIgPSBPYmplY3Qua2V5cyhvYmoyKTtcbiAgICAgICAgaWYgKGtleXMxLmxlbmd0aCAhPT0ga2V5czIubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2VcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0ga2V5czEubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBrMSA9IGtleXMxW2ldO1xuICAgICAgICAgICAgY29uc3QgazIgPSBrZXlzMltpXTtcbiAgICAgICAgICAgIGlmIChrMSAhPT0gazIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2VcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29uc3QgdjEgPSBvYmoxW2sxXTtcbiAgICAgICAgICAgIGNvbnN0IHYyID0gb2JqMltrMl07XG5cbiAgICAgICAgICAgIGlmICghVXRpbHMuZXF1YWxWYWx1ZXModjEsIHYyKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgc3RhdGljIGVxdWFsQXJyYXlzKHYxLCB2Mikge1xuICAgICAgICBpZiAodjEubGVuZ3RoICE9PSB2Mi5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgICB9XG4gICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdjEubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuZXF1YWxWYWx1ZXModjFbaV0sIHYyW2ldKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHRydWVcbiAgICB9XG5cbn1cblxuLyoqXG4gKiBNYWludGFpbnMgdGhlIHN0YXRlIG9mIGEgV2ViR0xSZW5kZXJpbmdDb250ZXh0LlxuICovXG5jbGFzcyBXZWJHTFN0YXRlIHtcblxuICAgIGNvbnN0cnVjdG9yKGlkLCBnbCkge1xuICAgICAgICB0aGlzLl9pZCA9IGlkO1xuICAgICAgICB0aGlzLl9nbCA9IGdsO1xuICAgICAgICB0aGlzLl9wcm9ncmFtID0gdW5kZWZpbmVkO1xuICAgICAgICB0aGlzLl9idWZmZXJzID0gbmV3IE1hcCgpO1xuICAgICAgICB0aGlzLl9mcmFtZWJ1ZmZlcnMgPSBuZXcgTWFwKCk7XG4gICAgICAgIHRoaXMuX3JlbmRlcmJ1ZmZlcnMgPSBuZXcgTWFwKC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1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cblxuICAgIHZlcnRleEF0dHJpYlBvaW50ZXIoaW5kZXgsIHByb3BzKSB7XG4gICAgICAgIGxldCB2YSA9IHRoaXMuX3ZlcnRleEF0dHJpYnNbaW5kZXhdO1xuICAgICAgICBsZXQgZXF1YWwgPSBmYWxzZTtcbiAgICAgICAgaWYgKHZhKSB7XG4gICAgICAgICAgICBlcXVhbCA9IHZhWzBdID09PSBwcm9wc1swXSAmJlxuICAgICAgICAgICAgICAgIHZhWzFdID09PSBwcm9wc1sxXSAmJlxuICAgICAgICAgICAgICAgIHZhWzJdID09PSBwcm9wc1syXSAmJlxuICAgICAgICAgICAgICAgIHZhWzNdID09PSBwcm9wc1szXSAmJlxuICAgICAgICAgICAgICAgIHZhWzRdID09PSBwcm9wc1s0XTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChlcXVhbCkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcHJvcHNbNV0gPSB2YSA/IHZhWzVdIDogZmFsc2U7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldEFjdGl2ZVRleHR1cmUodGV4dHVyZSkge1xuICAgICAgICBjb25zdCBjaGFuZ2VkID0gdGhpcy5fYWN0aXZlVGV4dHVyZSAhPT0gdGV4dHVyZTtcbiAgICAgICAgdGhpcy5fYWN0aXZlVGV4dHVyZSA9IHRleHR1cmU7XG4gICAgICAgIHJldHVybiBjaGFuZ2VkO1xuICAgIH1cblxuICAgIGJpbmRUZXh0dXJlKHRhcmdldCwgdGV4dHVyZSkge1xuICAgICAgICBjb25zdCBhY3RpdmVJbmRleCA9IFdlYkdMU3RhdGUuX2dldFRleHR1cmVJbmRleCh0aGlzLl9hY3RpdmVUZXh0dXJlKTtcbiAgICAgICAgdGhpcy5fbWF4VGV4dHVyZSA9IE1hdGgub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ICAgY29uc3QgdGFyZ2V0ID0gV2ViR0xTdGF0ZS5fZ2V0VGV4dHVyZVRhcmdldEJ5SW5kZXgoaik7XG4gICAgICAgICAgICAgICAgaWYgKGFjdGl2ZVRleHR1cmUgIT09IHRleHR1cmVOdW1iKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9hY3RpdmVUZXh0dXJlKHRleHR1cmVOdW1iKTtcbiAgICAgICAgICAgICAgICAgICAgYWN0aXZlVGV4dHVyZSA9IHRleHR1cmVOdW1iO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGNvbnN0IHRleHR1cmUgPSAoc1RhcmdldHMgJiYgc1RhcmdldHNbal0pIHx8IG51bGw7XG4gICAgICAgICAgICAgICAgdGhpcy5fZ2wuX2JpbmRUZXh0dXJlKHRhcmdldCwgdGV4dHVyZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocy5fYWN0aXZlVGV4dHVyZSAhPT0gYWN0aXZlVGV4dHVyZSkge1xuICAgICAgICAgICAgdGhpcy5fZ2wuX2FjdGl2ZVRleHR1cmUocy5fYWN0aXZlVGV4dHVyZSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfbWlncmF0ZUJ1ZmZlcnModCwgcykge1xuICAgICAgICBzLl9idWZmZXJzLmZvckVhY2goKGZyYW1lYnVmZmVyLCB0YXJnZXQpID0+IHtcbiAgICAgICAgICAgIGlmICh0Ll9idWZmZXJzLmdldCh0YXJnZXQpICE9PSBmcmFtZWJ1ZmZlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuX2dsLl9iaW5kQnVmZmVyKHRhcmdldCwgZnJhbWVidWZmZXIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICB0Ll9idWZmZXJzLmZvckVhY2goKGJ1ZmZlciwgdGFyZ2V0KSA9PiB7XG4gICAgICAgICAgICBjb25zdCBiID0gcy5fYnVmZmVycy5nZXQodGF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luZGV4KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9taWdyYXRlU2V0dGluZ3ModCwgcykge1xuICAgICAgICBjb25zdCBkZWZhdWx0cyA9IHRoaXMuY29uc3RydWN0b3IuZ2V0RGVmYXVsdFNldHRpbmdzKCk7XG4gICAgICAgIHQuX3NldHRpbmdzLmZvckVhY2goKHZhbHVlLCBmdW5jKSA9PiB7XG4gICAgICAgICAgICBjb25zdCBuYW1lID0gZnVuYy5uYW1lIHx8IGZ1bmMueG5hbWU7XG4gICAgICAgICAgICBpZiAoIXMuX3NldHRpbmdzLmhhcyhmdW5jKSkge1xuICAgICAgICAgICAgICAgIGxldCBhcmdzID0gZGVmYXVsdHMuZ2V0KG5hbWUpO1xuICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc0Z1bmN0aW9uKGFyZ3MpKSB7XG4gICAgICAgICAgICAgICAgICAgIGFyZ3MgPSBhcmdzKHRoaXMuX2dsKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgLy8gV2UgYXJlIGFjdHVhbGx5IHNldHRpbmcgdGhlIHNldHRpbmcgZm9yIG9wdGltaXphdGlvbiBwdXJwb3Nlcy5cbiAgICAgICAgICAgICAgICBzLl9zZXR0aW5ncy5zZXQoZnVuYywgYXJncyk7XG4gICAgICAgICAgICAgICAgZnVuYy5hcHBseSh0aGlzLl9nbCwgYXJncyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBzLl9zZXR0aW5ncy5mb3JFYWNoKCh2YWx1ZSwgZnVuYykgPT4ge1xuICAgICAgICAgICAgY29uc3QgdFZhbHVlID0gdC5fc2V0dGluZ3MuZ2V0KGZ1bmMpO1xuICAgICAgICAgICAgaWYgKCF0VmFsdWUgfHwgIVV0aWxzLmVxdWFsVmFsdWVzKHRWYWx1ZSwgdmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgZnVuYy5hcHBseSh0aGlzLl9nbCwgdmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBfbWlncmF0ZUZsYWdzKHQsIHMpIHtcbiAgICAgICAgdC5fbm9uRGVmYXVsdEZsYWdzLmZvckVhY2goc2V0dGluZyA9PiB7XG4gICAgICAgICAgICBpZiAoIXMuX25vbkRlZmF1bHRGbGFncy5oYXMoc2V0dGluZykpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fZ2V0RGVmYXVsdEZsYWcoc2V0dGluZykpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZ2wuX2VuYWJsZShzZXR0aW5nKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbC5fZGlzYWJsZShzZXR0aW5nKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBzLl9ub25EZWZhdWx0RmxhZ3MuZm9yRWFjaChzZXR0aW5nID0+IHtcbiAgICAgICAgICAgIGlmICghdC5fbm9uRGVmYXVsdEZsYWdzLmhhcyhzZXR0aW5nKSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9nZXREZWZhdWx0RmxhZyhzZXR0aW5nKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbC5fZGlzYWJsZShzZXR0aW5nKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9nbC5fZW5hYmxlKHNldHRpbmcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldERlZmF1bHRTZXR0aW5ncygpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9kZWZhdWx0U2V0dGluZ3MpIHtcbiAgICAgICAgICAgIHRoaXMuX2RlZmF1bHRTZXR0aW5ncyA9I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EICovXG4gICAgICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgICAgICBjYXNlIDB4ODUxMzpcbiAgICAgICAgICAgICAgICAvKiBURVhUVVJFX0NVQkVfTUFQICovXG4gICAgICAgICAgICAgICAgcmV0dXJuIDE7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIC8vIFNob3VsZG4ndCBoYXBwZW4uXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdVbmtub3duIHRleHR1cmUgdGFyZ2V0OiAnICsgdGFyZ2V0KTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBfZ2V0VGV4dHVyZVRhcmdldEJ5SW5kZXgoaW5kZXgpIHtcbiAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJlVGFyZ2V0SW5kaWNlcykge1xuICAgICAgICAgICAgdGhpcy5fdGV4dHVyZVRhcmdldEluZGljZXMgPSBbMHgwREUxLCAweDg1MTNdO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl90ZXh0dXJlVGFyZ2V0SW5kaWNlc1tpbmRleF1cbiAgICB9XG5cbiAgICBzdGF0aWMgX2dldFRleHR1cmVJbmRleChpbmRleCkge1xuICAgICAgICByZXR1cm4gaW5kZXggLSAweDg0QzAgLyogR0xfVEVYVFVSRTAgKi87XG4gICAgfVxuXG4gICAgc3RhdGljIF9nZXRUZXh0dXJlQnlJbmRleChpbmRleCkge1xuICAgICAgICByZXR1cm4gaW5kZXggKyAweDg0QzA7XG4gICAgfVxuXG4gICAgc3RhdGljIF9nZXRQaXhlbFN0b3JlaUluZGV4KHBuYW1lKSB7XG4gICAgICAgIHN3aXRjaChwbmFtZSkge1xuICAgICAgICAgICAgY2FzZSAweDBEMDU6XG4gICAgICAgICAgICAgICAgLyogUEFDS19BTElHTk1FTlQgKi9cbiAgICAgICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgICAgIGNhc2UgMHgwQ0Y1OlxuICAgICAgICAgICAgICAgIC8qIFVOUEFDS19BTElHTk1FTlQgKi9cbiAgICAgICAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgICAgIGNhc2UgMHg5MjQwOlxuICAgICAgICAgICAgICAgIC8qIFVOUEFDS19GTElQX1lfV0VCR0wgKi9cbiAgICAgICAgICAgICAgICByZXR1cm4gMjtcbiAgICAgICAgICAgIGNhc2UgMHg5MjQxOlxuICAgICAgICAgICAgICAgIC8qIFVOUEFDS19QUkVNVUxUSVBMWV9BTFBIQV9XRUJHTCAqL1xuICAgICAgICAgICAgICAgIHJldHVybiAzO1xuICAgICAgICAgICAgY2FzZSAweDkyNDM6XG4gICAgICAgICAgICAgICAgLyogVU5QQUNLX0NPTE9SU1BBQ0VfQ09OVkVSU0lPTl9XRUJHTCAqL1xuICAgICAgICAgICAgICAgIHJldHVybiA0O1xuICAgICAgICAgICAgICAgIC8vQHRvZG86IHN1cHBvcnQgV2ViR0wyIHByb3BlcnRpZXMsIHNlZSBodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZy9lbi1VUy9kb2NzL1dlYi9BUEkvV2ViR0xSZW5kZXJpbmdDb250ZXh0L3BpeGVsU3RvcmVpXG4gICAgICAgICAgICBjYXNlIDB4OTI0NTpcbiAgICAgICAgICAgICAgICAvKiBVTlBBQ0tfRkxJUF9CTFVFX1JFRCAqL1xuICAgICAgICAgICAgICAgIHJldHVybiA1O1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAvLyBTaG91bGRuJ3QgaGFwcGVuLlxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignVW5rbm93biBwaXhlbHN0b3JlaTogJyArIHBuYW1lKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBfZ2V0UGl4ZWxTdG9yZWlCeUluZGV4KGluZGV4KSB7XG4gICAgICAgIGlmICghdGhpcy5fcGl4ZWxTdG9yZWlJbmRpY2VzKSB7XG4gICAgICAgICAg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9fcHJvdG9fXztcbiAgICAgICAgbmFtZXMuZm9yRWFjaChuYW1lID0+IHtcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBcImNvbnN0cnVjdG9yXCIpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBtZXRob2QgPSBXZWJHTFN0YXRlTWFuYWdlci5wcm90b3R5cGVbbmFtZV07XG4gICAgICAgICAgICAgICAgaWYgKG5hbWUuY2hhckF0KDApID09PSBcIiRcIikge1xuICAgICAgICAgICAgICAgICAgICBuYW1lID0gbmFtZS5zdWJzdHIoMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChnbFtuYW1lXSAhPT0gbWV0aG9kKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChnbFtuYW1lXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFnbFtuYW1lXS5uYW1lKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gV2UgZG8gdGhpcyBmb3IgY29tcGF0aWJpbGl0eSB3aXRoIHRoZSBDaHJvbWUgV2ViR0wgSW5zcGVjdG9yIHBsdWdpbi5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnbFtuYW1lXS54bmFtZSA9IG5hbWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBnbFsnXycgKyBuYW1lXSA9IGdsW25hbWVdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGdsW25hbWVdID0gbWV0aG9kO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgV2ViR0xTdGF0ZU1hbmFnZXIucHJvdG90eXBlLl9pbml0U3RhdGVNYW5hZ2VyLmNhbGwoZ2wsIGlkKTtcblxuICAgICAgICByZXR1cm4gZ2w7XG4gICAgfVxuXG59XG5cbmV4cG9ydCBkZWZhdWx0IFdlYkdMU3RhdGVN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YXVsdFNldHRlcihvYmosIG5hbWUsIHZhbHVlKSB7XG4gICAgICAgIG9ialtuYW1lXSA9IHZhbHVlO1xuICAgIH1cblxuICAgIHN0YXRpYyBwYXRjaE9iamVjdChvYmosIHNldHRpbmdzKSB7XG4gICAgICAgIGlmICghVXRpbHMuaXNPYmplY3RMaXRlcmFsKHNldHRpbmdzKSkge1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcihcIltMaWdodG5pbmddIFNldHRpbmdzIG11c3QgYmUgb2JqZWN0IGxpdGVyYWxcIik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsZXQgbmFtZXMgPSBPYmplY3Qua2V5cyhzZXR0aW5ncyk7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IG5hbWVzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGxldCBuYW1lID0gbmFtZXNbaV07XG5cbiAgICAgICAgICAgICAgICB0aGlzLnBhdGNoT2JqZWN0UHJvcGVydHkob2JqLCBuYW1lLCBzZXR0aW5nc1tuYW1lXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgcGF0Y2hPYmplY3RQcm9wZXJ0eShvYmosIG5hbWUsIHZhbHVlKSB7XG4gICAgICAgIGxldCBzZXR0ZXIgPSBvYmouc2V0U2V0dGluZyB8fCBCYXNlLmRlZmF1bHRTZXR0ZXI7XG5cbiAgICAgICAgaWYgKG5hbWUuY2hhckF0KDApID09PSBcIl9cIikge1xuICAgICAgICAgICAgLy8gRGlzYWxsb3cgcGF0Y2hpbmcgcHJpdmF0ZSB2YXJpYWJsZXMuXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gXCJfX2NyZWF0ZVwiKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcIltMaWdodG5pbmddIFBhdGNoIG9mIHByaXZhdGUgcHJvcGVydHkgJ1wiICsgbmFtZSArIFwiJyBp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cyBhY3RpdmUgd2hlbiBpdCBpcyBlbmFibGVkIGFuZCBpdCBpcyB3aXRoaW4gYm91bmRzLlxuICAgICAgICAgKiBAdHlwZSB7Ym9vbGVhbn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX19hY3RpdmUgPSBmYWxzZTtcblxuICAgICAgICAvKipcbiAgICAgICAgICogQHR5cGUge0VsZW1lbnR9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9fcGFyZW50ID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIHRleHR1cmUgdGhhdCBpcyBjdXJyZW50bHkgc2V0LlxuICAgICAgICAgKiBAdHlwZSB7VGV4dHVyZX1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX190ZXh0dXJlID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIGN1cnJlbnRseSBkaXNwbGF5ZWQgdGV4dHVyZS4gV2hpbGUgdGhpcy50ZXh0dXJlIGlzIGxvYWRpbmcsIHRoaXMgb25lIG1heSBiZSBkaWZmZXJlbnQuXG4gICAgICAgICAqIEB0eXBlIHtUZXh0dXJlfVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fX2Rpc3BsYXllZFRleHR1cmUgPSBudWxsO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBUYWdzIHRoYXQgY2FuIGJlIHVzZWQgdG8gaWRlbnRpZnkvc2VhcmNoIGZvciBhIHNwZWNpZmljIGVsZW1lbnQuXG4gICAgICAgICAqIEB0eXBlIHtTdHJpbmdbXX1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMuX190YWdzID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogVGhlIHRyZWUncyB0YWdzIG1hcHBpbmcuXG4gICAgICAgICAqIFRoaXMgY29udGFpbnMgYWxsIGVsZW1lbnRzIGZvciBhbGwga25vd24gdGFncywgYXQgYWxsIHRpbWVzLlxuICAgICAgICAgKiBAdHlwZSB7TWFwfVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fX3RyZWVUYWdzID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogQ3JlYXRlcyBhIHRhZyBjb250ZXh0OiB0YWdnZWQgZWxlbWVudHMgaW4gdGhpcyBicmFuY2ggd2lsbCBub3QgYmUgcmVhY2hhYmxlIGZyb20gYW5jZXN0b3JzIG9mIHRoaXMgZWxlbWVudHMuXG4gICAgICAgICAqIEB0eXBlIHtib29sZWFufVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5fX3RhZ1Jvb3QgPSBmYWxzZTtcblxuICAgICAgICAvKipcbiAgICAgICAgICogKExhenktaW5pdGlhbGlzZWQpIGxpc3Qgb2YgY2hpbGRyZW4gb3duZWQgYnkgdGhpcyBlbGVtZW50cy5cbiAgICAgICAgICogQHR5cGUge0VsZW1lbnRDaGlsZExpc3R9XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9fY2hpbGRMaXN0ID0gbnVsbDtcblxuICAgICAgICB0aGlzLl93ID0gMDtcblxuICAgICAgICB0aGlzLl9oID0gMDtcbiAgICB9XG5cbiAgICBfX3N0YXJ0KCkge1xuICAgIH1cblxuICAgIGdldCBpZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19pZDtcbiAgICB9XG5cbiAgICBzZXQgcmVmKHJlZikge1xuICAgICAgICBpZiAodGhpcy5fX3JlZiAhPT0gcmVmKSB7XG4gICAgICAgICAgICBjb25zdCBjaGFyY29kZSA9IHJlZi5jaGFyQ29kZUF0KDApO1xuICAgICAgICAgICAgaWYgKCFVdGlscy5pc1VjQ2hhcihjaGFyY29kZSkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90aHJvd0Vycm9yKFwiUmVmIG11c3Qgc3RhcnQgd2l0aCBhbiB1cHBlciBjYXNlIGNoYXJhY3RlcjogXCIgKyByZWYpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX19yZWYgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnJlbW92ZVRhZyh0aGlzLl9fcmVmKTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fX3BhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fcGFyZW50Ll9fY2hpbGRMaXN0LmNsZWFyUmVmKHRoaXMuX19yZWYpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fX3JlZiA9IHJlZjtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX19yZWYpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9hZGRUYWcodGhpcy5fX3JlZik7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX19wYXJlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3BhcmVudC5fX2NoaWxkTGlzdC5zZXRSZWYodGhpcy5fX3JlZiwgdGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHJlZigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19yZWY7XG4gICAgfVxuXG4gICAgZ2V0IGNvcmUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZTtcbiAgICB9XG5cbiAgICBzZXRBc1Jvb3QoKSB7XG4gICAgICAgIHRoaXMuX19jb3JlLnNldEFzUm9vdCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVBdHRhY2hlZEZsYWcoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlRW5hYmxlZEZsYWcoKTtcbiAgICB9XG5cbiAgICBnZXQgaXNSb290KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuaXNSb290O1xuICAgIH1cblxuICAgIF9zZXRQYXJlbnQocGFyZW50KSB7XG4gICAgICAgIGlmICh0aGlzLl9fcGFyZW50ID09PSBwYXJlbnQpIHJldHVybjtcblxuICAgICAgICBpZiAodGhpcy5fX3BhcmVudCkge1xuICAgICAgICAgICAgdGhpcy5fdW5zZXRUYWdzUGFyZW50KCk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9fcGFyZW50ID0gcGFyZW50O1xuXG4gICAgICAgIGlmIChwYXJlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX3NldFRhZ3NQYXJlbnQoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuX3VwZGF0ZUF0dGFjaGVkRmxhZygpO1xuICAgICAgICB0aGlzLl91cGRhdGVFbmFibGVkRmxhZygpO1xuICAgICAgICB0aGlzLl91cGRhdGVDb2xsaXNpb24oKTtcblxuICAgICAgICBpZiAodGhpcy5pc1Jvb3QgJiYgcGFyZW50KSB7XG4gICAgICAgICAgICB0aGlzLl90aHJvd0Vycm9yKFwiUm9vdCBzaG91bGQgbm90IGJlIGFkZGVkIGFzIGEgY2hpbGQhIFJlc3VsdHMgYXJlIHVuc3BlY2lmaWVkIVwiKTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBnZXREZXB0aCgpIHtcbiAgICAgICAgbGV0IGRlcHRoID0gMDtcblxuICAgICAgICBsZXQgcCA9IHRoaXMuX19wYXJlbnQ7XG4gICAgICAgIHdoaWxlKHApIHtcbiAgICAgICAgICAgIGRlcHRoKys7XG4gICAgICAgICAgICBwID0gcC5fX3BhcmVudDtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBkZXB0aDtcbiAgICB9O1xuXG4gICAgZ2V0QW5jZXN0b3IobCkge1xuICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgIHdoaWxlIChsID4gMCAmJiBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgICBwID0gcC5fX3BhcmVudDtcbiAgICAgICAgICAgIGwtLTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcDtcbiAgICB9O1xuXG4gICAgZ2V0QW5jZXN0b3JzKCkge1xuICAgICAgICBjb25zdCBhID0gW107XG4gICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgd2hpbGUgKHApIHtcbiAgICAgICAgICAgIGEucHVzaChwKTtcbiAgICAgICAgICAgIHAgPSBwLl9fcGFyZW50O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBhO1xuICAgIH1cblxuICAgIGdldEFuY2VzdG9yQXREZXB0aChkZXB0aCkge1xuICAgICAgICBsZXQgbGV2ZWxzID0gdGhpcy5nZXREZXB0aCgpIC0gZGVwdGg7XG4gICAgICAgIGlmIChsZXZlbHMgPCAwKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5nZXRBbmNlc3RvcihsZXZlbHMpO1xuICAgIH07XG5cbiAgICBpc0FuY2VzdG9yT2YoYykge1xuICAgICAgICBsZXQgcCA9IGM7XG4gICAgICAgIHdoaWxlKHAgPSBwLnBhcmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMgPT09IHApIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfTtcblxuICAgIGdldFNoYXJlZEFuY2VzdG9yKGMpIHtcbiAgICAgICAgbGV0IG8xID0gdGhpcztcbiAgICAgICAgbGV0IG8yID0gYztcbiAgICAgICAgbGV0IGwxID0gbzEuZ2V0RGVwdGgoKTtcbiAgICAgICAgbGV0IGwyID0gbzIuZ2V0RGVwdGgoKTtcbiAgICAgICAgaWYgKGwxID4gbDIpIHtcbiAgICAgICAgICAgIG8xID0gbzEuZ2V0QW5jZXN0b3IobDEgLSBsMik7XG4gICAgICAgIH0gZWxzZSBpZiAobDIgPiBsMSkge1xuICAgICAgICAgICAgbzIgPSBvMi5nZXRBbmNlc3RvcihsMiAtIGwxKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGRvIHtcbiAgICAgICAgICAgIGlmIChvMSA9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7XG4gICAgICAgIGxldCBuZXdBdHRhY2hlZCA9IHRoaXMuX2lzQXR0YWNoZWQoKTtcbiAgICAgICAgaWYgKHRoaXMuX19hdHRhY2hlZCAhPT0gbmV3QXR0YWNoZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX19hdHRhY2hlZCA9IG5ld0F0dGFjaGVkO1xuXG4gICAgICAgICAgICBpZiAobmV3QXR0YWNoZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vblNldHVwKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBjaGlsZHJlbiA9IHRoaXMuX2NoaWxkcmVuLmdldCgpO1xuICAgICAgICAgICAgaWYgKGNoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgbGV0IG0gPSBjaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgICAgICAgICAgaWYgKG0gPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaGlsZHJlbltpXS5fdXBkYXRlQXR0YWNoZWRGbGFnKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChuZXdBdHRhY2hlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX29uQXR0YWNoKCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX29uRGV0YWNoKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgLyoqXG4gICAgICogVXBkYXRlcyB0aGUgJ2VuYWJsZWQnIGZsYWcgZm9yIHRoaXMgYnJhbmNoLlxuICAgICAqL1xuICAgIF91cGRhdGVFbmFibGVkRmxhZygpIHtcbiAgICAgICAgbGV0IG5ld0VuYWJsZWQgPSB0aGlzLl9pc0VuYWJsZWQoKTtcbiAgICAgICAgaWYgKHRoaXMuX19lbmFibGVkICE9PSBuZXdFbmFibGVkKSB7XG4gICAgICAgICAgICBpZiAobmV3RW5hYmxlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX29uRW5hYmxlZCgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3NldEVuYWJsZWRGbGFnKCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX29uRGlzYWJsZWQoKTtcbiAgICAgICAgICAgICAgICB0aGlzLl91bnNldEVuYWJsZWRGbGFnKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBjaGlsZHJlbiA9IHRoaXMuX2NoaWxkcmVuLmdldCgpO1xuICAgICAgICAgICAgaWYgKGNoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgbGV0IG0gPSBjaGlsZHJlbi5sZW5ndGg7XG4gICAgICAgICAgICAgICAgaWYgKG0gPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaGlsZHJlbltpXS5fdXBkYXRlRW5hYmxlZEZsYWcoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBfc2V0RW5hYmxlZEZsYWcoKSB7XG4gICAgICAgIHRoaXMuX19lbmFibGVkID0gdHJ1ZTtcblxuICAgICAgICAvLyBGb3JjZSByZS1jaGVjayBvZiB0ZXh0dXJlIGJlY2F1c2UgZGltZW5zaW9ucyBtaWdodCBoYXZlIGNoYW5nZWQgKGN1dHRpbmcpLlxuICAgICAgICB0aGlzLl91cGRhdGVEaW1lbnNpb25zKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRleHR1cmVDb29yZHMoKTtcblxuICAgICAgICBpZiAodGhpcy5fX3RleHR1cmUpIHtcbiA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V4dHVyZSkge1xuICAgICAgICAgICAgICAgIEJhc2UucGF0Y2hPYmplY3QodGV4dHVyZSwgdik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAoIXYpIHtcbiAgICAgICAgICAgIHRleHR1cmUgPSBudWxsO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHYuaXNUZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgdGV4dHVyZSA9IHY7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHYuaXNUZXh0dXJlU291cmNlKSB7XG4gICAgICAgICAgICAgICAgdGV4dHVyZSA9IG5ldyBTb3VyY2VUZXh0dXJlKHRoaXMuc3RhZ2UpO1xuICAgICAgICAgICAgICAgIHRleHR1cmUudGV4dHVyZVNvdXJjZSA9IHY7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXCJbTGlnaHRuaW5nXSBQbGVhc2Ugc3BlY2lmeSBhIHRleHR1cmUgdHlwZS5cIik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgY29uc3QgcHJldlRleHR1cmUgPSB0aGlzLl9fdGV4dHVyZTtcbiAgICAgICAgaWYgKHRleHR1cmUgIT09IHByZXZUZXh0dXJlKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGV4dHVyZSA9IHRleHR1cmU7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9fZW5hYmxlZCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fdGV4dHVyZS5hZGRFbGVtZW50KHRoaXMpO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLndpdGhpbkJvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX190ZXh0dXJlLmlzTG9hZGVkKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREaXNwbGF5ZWRUZXh0dXJlKHRoaXMuX190ZXh0dXJlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5hYmxlVGV4dHVyZUVycm9yKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIE1ha2Ugc3VyZSB0aGF0IGN1cnJlbnQgdGV4dHVyZSBpcyBjbGVhcmVkIHdoZW4gdGhlIHRleHR1cmUgaXMgZXhwbGljaXRseSBzZXQgdG8gbnVsbC5cbiAgICAgICAgICAgICAgICB0aGlzLl9zZXREaXNwbGF5ZWRUZXh0dXJlKG51bGwpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocHJldlRleHR1cmUgJiYgcHJldlRleHR1cmUgIT09IHRoaXMuX19kaXNwbGF5ZWRUZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgcHJldlRleHR1cmUucmVtb3ZlRWxlbWVudCh0aGlzKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fdXBkYXRlRGltZW5zaW9ucygpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGRpc3BsYXllZFRleHR1cmUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fZGlzcGxheWVkVGV4dHVyZTtcbiAgICB9XG5cbiAgICBfc2V0RGlzcGxheWVkVGV4dHVyZSh2KSB7XG4gICAgICAgIGxldCBwcmV2VGV4dHVyZSA9IHRoaXMuX19kaXNwbGF5ZWRUZXh0dXJlO1xuXG4gICAgICAgIGlmIChwcmV2VGV4dHVyZSAmJiAodiAhPT0gcHJldlRleHR1cmUpKSB7XG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G1ha2VzIHN1cmUgdGhhdCBpdCBpcyBhYmxlIHRvIGRldGVybWluZSB3aXRoaW5Cb3VuZHMuXG4gICAgICAgICAgICAgICAgdyA9IHcgfHwgdGhpcy5fX3RleHR1cmUubXc7XG4gICAgICAgICAgICAgICAgaCA9IGggfHwgdGhpcy5fX3RleHR1cmUubWg7XG5cbiAgICAgICAgICAgICAgICBpZiAoKCF3IHx8ICFoKSAmJiB0aGlzLl9fdGV4dHVyZS5pc0F1dG9zaXplVGV4dHVyZSgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHVua25vd25TaXplID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fX2NvcmUuc2V0RGltZW5zaW9ucyh3LCBoLCB1bmtub3duU2l6ZSkpIHtcbiAgICAgICAgICAgIHRoaXMuX29uUmVzaXplKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfdXBkYXRlVGV4dHVyZUNvb3JkcygpIHtcbiAgICAgICAgaWYgKHRoaXMuZGlzcGxheWVkVGV4dHVyZSAmJiB0aGlzLmRpc3BsYXllZFRleHR1cmUuX3NvdXJjZSkge1xuICAgICAgICAgICAgbGV0IGRpc3BsYXllZFRleHR1cmUgPSB0aGlzLmRpc3BsYXllZFRleHR1cmU7XG4gICAgICAgICAgICBsZXQgZGlzcGxheWVkVGV4dHVyZVNvdXJjZSA9IHRoaXMuZGlzcGxheWVkVGV4dHVyZS5fc291cmNlO1xuXG4gICAgICAgICAgICBsZXQgdHgxID0gMCwgdHkxID0gMCwgdHgyID0gMS4wLCB0eTIgPSAxLjA7XG4gICAgICAgICAgICBpZiAoZGlzcGxheWVkVGV4dHVyZS5jbGlwcGluZykge1xuICAgICAgICAgICAgICAgIC8vIEFwcGx5IHRleHR1cmUgY2xpcHBpbmcuXG4gICAgICAgICAgICAgICAgbGV0IHcgPSBkaXNwbGF5ZWRUZXh0dXJlU291cmNlLmdldFJlbmRlcldpZHRoKCk7XG4gICAgICAgICAgICAgICAgbGV0IGggPSBkaXNwbGF5ZWRUZXh0dXJlU291cmNlLmdldFJlbmRlckhlaWdodCgpO1xuICAgICAgICAgICAgICAgIGxldCBpdywgaWgsIHJ3LCByaDtcbiAgICAgICAgICAgICAgICBpdyA9IDEgLyB3O1xuICAgICAgICAgICAgICAgIGloID0gMSAvIGg7XG5cbiAgICAgICAgICAgICAgICBpZiAoZGlzcGxheWVkVGV4dHVyZS5wdykge1xuICAgICAgICAgICAgICAgICAgICBydyA9IChkaXNwbGF5ZWRUZXh0dXJlLnB3KSAqIGl3O1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJ3ID0gKHcgLSBkaXNwbGF5ZWRUZXh0dXJlLnB4KSAqIGl3O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChkaXNwbGF5ZWRUZXh0dXJlLnBoKSB7XG4gICAgICAgICAgICAgICAgICAgIHJoID0gZGlzcGxheWVkVGV4dHVyZS5waCAqIGloO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJoID0gKGggLSBkaXNwbGF5ZWRUZXh0dXJlLnB5KSAqIGloO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGl3ICo9IChkaXNwbGF5ZWRUZXh0dXJlLnB4KTtcbiAgICAgICAgICAgICAgICBpaCAqPSAoZGlzcGxheWVkVGV4dHVyZS5weSk7XG5cbiAgICAgICAgICAgICAgICB0eDEgPSBpdztcbiAgICAgICAgICAgICAgICB0eTEgPSBpaDtcbiAgICAgICAgICAgICAgICB0eDIgPSB0eDIgKiBydyArIGl3O1xuICAgICAgICAgICAgICAgIHR5MiA9IHR5MiAqIHJoICsgaWg7XG5cbiAgICAgICAgICAgICAgICB0eDEgPSBNYXRoLm1heCgwLCB0eDEpO1xuICAgICAgICAgICAgICAgIHR5MSA9IE1hdGgubWF4KDAsIHR5MSk7XG4gICAgICAgICAgICAgICAgdHgyID0gTWF0aC5taW4oMSwgdHgyKTtcbiAgICAgICAgICAgICAgICB0eTIgPSBNYXRoLm1pbigxLCB0eTIpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoZGlzcGxheWVkVGV4dHVyZVNvdXJjZS5fZmxpcFRleHR1cmVZKSB7XG4gICAgICAgICAgICAgICAgbGV0IHRlbXB0eSA9IHR5MjtcbiAgICAgICAgICAgICAgICB0eTIgPSB0eTE7XG4gICAgICAgICAgICAgICAgdHkxID0gdGVtcHR5O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fX2NvcmUuc2V0VGV4dHVyZUNvb3Jkcyh0eDEsIHR5MSwgdHgyLCB0eTIpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0Q29ybmVyUG9pbnRzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuZ2V0Q29ybmVyUG9pbnRzKCk7XG4gICAgfVxuXG4gICAgX3Vuc2V0VGFnc1BhcmVudCgpIHtcbiAgICAgICAgaWYgKHRoaXMuX190YWdzKSB7XG4gICAgICAgICAgICB0aGlzLl9fdGFncy5mb3JFYWNoKCh0YWcpID0+IHtcbiAgICAgICAgICAgICAgICAvLyBSZW1vdmUgZnJvbSB0cmVlVGFncy5cbiAgICAgICAgICAgICAgICBsZXQgcCA9IHRoaXM7XG4gICAgICAgICAgICAgICAgd2hpbGUgKHAgPSBwLl9fcGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXJlbnRUcmVlVGFncyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50VHJlZVRhZ3MuZGVsZXRlKHRoaXMpO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCB0YWdzID0gbnVsbDtcbiAgICAgICAgbGV0IG4gPSAwO1xuICAgICAgICBpZiAodGhpcy5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX190YWdSb290KSB7XG4gICAgICAgICAgICAgICAgdGFncyA9IFV0aWxzLml0ZXJhdG9yVG9BcnJheSh0aGlzLl9fdHJlZVRhZ3Mua2V5cygpKTtcbiAgICAgICAgICAgICAgICBuID0gdGFncy5sZW5ndGg7XG5cbiAgICAgICAgICAgICAgICBpZiAobiA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWdTZXQgPSB0aGlzLl9fdHJlZVRhZ3MuZ2V0KHRhZ3NbaV0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBSZW1vdmUgZnJvbSB0cmVlVGFncy5cbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwID0gdGhpcztcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICgocCA9IHAuX19wYXJlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhcmVudFRyZWVUYWdzID0gcC5fX3RyZWVUYWdzLmdldCh0YWdzW2ldKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhZ1NldC5mb3JFYWNoKGZ1bmN0aW9uIChjb21wKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudFRyZWVUYWdzLmRlbGV0ZShjb21wKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgX3NldFRhZ3NQYXJlbnQoKSB7XG4gICAgICAgIC8vIEp1c3QgY29weSBvdmVyIHRoZSAnbG9jYWwnIHRhZ3MuXG4gICAgICAgIGlmICh0aGlzLl9fdGFncykge1xuICAgICAgICAgICAgdGhpcy5fX3RhZ3MuZm9yRWFjaCgodGFnKSA9PiB7XG4gICAgICAgICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgICAgICAgIHdoaWxlIChwID0gcC5fX3BhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXAuX190cmVlVGFncykge1xuICAgICAgICAgICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzID0gbmV3IE1hcCgpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgbGV0IHMgPSBwLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgcyA9IG5ldyBTZXQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAuX190cmVlVGFncy5zZXQodGFnLCBzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIHMuYWRkKHRoaXMpO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9fdHJlZVRhZ3MgJiYgdGhpcy5fX3RyZWVUYWdzLnNpemUpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fX3RhZ1Jvb3QpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9fdHJlZVRhZ3MuZm9yRWFjaCgodGFnU2V0LCB0YWcpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHAgPSB0aGlzO1xuICAgICAgICAgICAgICAgICAgICB3aGlsZSAoIXAuX190YWdSb290ICYmIChwID0gcC5fX3BhcmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwLl9fdGFnUm9vdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIERvIG5vdCBjb3B5IGFsbCBzdWJzLlxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwLl9fdHJlZVRhZ3MpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSBuZXcgTWFwKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcyA9IG5ldyBTZXQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3Muc2V0KHRhZywgcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRhZ1NldC5mb3JFYWNoKGZ1bmN0aW9uIChjb21wKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcy5hZGQoY29tcCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuXG4gICAgX2dldEJ5VGFnKHRhZykge1xuICAgICAgICBpZiAoIXRoaXMuX190cmVlVGFncykge1xuICAgICAgICAgICAgcmV0dXJuIFtdO1xuICAgICAgICB9XG4gICAgICAgIGxldCB0ID0gdGhpcy5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICByZXR1cm4gdCA/IFV0aWxzLnNldFRvQXJyYXkodCkgOiBbXTtcbiAgICB9O1xuXG4gICAgZ2V0VGFncygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX190YWdzID8gdGhpcy5fX3RhZ3MgOiBbXTtcbiAgICB9O1xuXG4gICAgc2V0VGFncyh0YWdzKSB7XG4gICAgICAgIHRhZ3MgPSB0YWdzLnJlZHVjZSgoYWNjLCB0YWcpID0+IHtcbiAgICAgICAgICAgIHJldHVybiBhY2MuY29uY2F0KHRhZy5zcGxpdCgnICcpKTtcbiAgICAgICAgfSwgW10pO1xuXG4gICAgICAgIGlmICh0aGlzLl9fcmVmKSB7XG4gICAgICAgICAgICB0YWdzLnB1c2godGhpcy5fX3JlZik7XG4gICAgICAgIH1cblxuICAgICAgICBsZXQgaSwgbiA9IHRhZ3MubGVuZ3RoO1xuICAgICAgICBsZXQgcmVtb3ZlcyA9IFtdO1xuICAgICAgICBsZXQgYWRkcyA9IFtdO1xuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuaGFzVGFnKHRhZ3NbaV0pKSB7XG4gICAgICAgICAgICAgICAgYWRkcy5wdXNoKHRhZ3NbaV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGN1cnJlbnRUYWdzID0gdGhpcy50YWdzIHx8IFtdO1xuICAgICAgICBuID0gY3VycmVudFRhZ3MubGVuZ3RoO1xuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBpZiAodGFncy5pbmRleE9mKGN1cnJlbnRUYWdzW2ldKSA9PSAtMSkge1xuICAgICAgICAgICAgICAgIHJlbW92ZXMucHVzaChjdXJyZW50VGFnc1tpXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcmVtb3Zlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgdGhpcy5yZW1vdmVUYWcocmVtb3Zlc1tpXSk7XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgYWRkcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgdGhpcy5hZGRUYWcoYWRkc1tpXSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBhZGRUYWcodGFnKSB7XG4gICAgICAgIGlmICh0YWcuaW5kZXhPZignICcpID09PSAtMSkge1xuICAgICAgICAgICAgaWYgKFV0aWxzLmlzVWNDaGFyKHRhZy5jaGFyQ29kZUF0KDApKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJUYWcgbWF5IG5vdCBzdGFydCB3aXRoIGFuIHVwcGVyIGNhc2UgY2hhcmFjdGVyLlwiKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fYWRkVGFnKHRhZyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCB0YWdzID0gdGFnLnNwbGl0KCcgJyk7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbSA9IHRhZ3MubGVuZ3RoOyBpIDwgbTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgdGFnID0gdGFnc1tpXTtcblxuICAgICAgICAgICAgICAgIGlmIChVdGlscy5pc1VjQ2hhcih0YWcuY2hhckNvZGVBdCgwKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGhyb3dFcnJvcihcIlRhZyBtYXkgbm90IHN0YXJ0IHdpdGggYW4gdXBwZXIgY2FzZSBjaGFyYWN0ZXIuXCIpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHRoaXMuX2FkZFRhZyh0YWcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2FkZFRhZyh0YWcpIHtcbiAgICAgICAgaWYgKCF0aGlzLl9fdGFncykge1xuICAgICAgICAgICAgdGhpcy5fX3RhZ3MgPSBbXTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fX3RhZ3MuaW5kZXhPZih0YWcpID09PSAtMSkge1xuICAgICAgICAgICAgdGhpcy5fX3RhZ3MucHVzaCh0YWcpO1xuXG4gICAgICAgICAgICAvLyBBZGQgdG8gdHJlZVRhZ3MgaGllcmFyY2h5LlxuICAgICAgICAgICAgbGV0IHAgPSB0aGlzLl9fcGFyZW50O1xuICAgICAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcC5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwLl9fdHJlZVRhZ3MgPSBuZXcgTWFwKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBsZXQgcyA9IHAuX190cmVlVGFncy5nZXQodGFnKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzID0gbmV3IFNldCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcC5fX3RyZWVUYWdzLnNldCh0YWcsIHMpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgcy5hZGQodGhpcyk7XG5cbiAgICAgICAgICAgICAgICB9IHdoaWxlICghcC5fX3RhZ1Jvb3QgJiYgKHAgPSBwLl9fcGFyZW50KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZW1vdmVUYWcodGFnKSB7XG4gICAgICAgIGxldCBpID0gdGhpcy5fX3RhZ3MuaW5kZXhPZih0YWcpO1xuICAgICAgICBpZiAoaSAhPT0gLTEpIHtcbiAgICAgICAgICAgIHRoaXMuX190YWdzLnNwbGljZShpLCAxKTtcblxuICAgICAgICAgICAgLy8gUmVtb3ZlIGZyb20gdHJlZVRhZ3MgaGllcmFyY2h5LlxuICAgICAgICAgICAgbGV0IHAgPSB0aGlzLl9fcGFyZW50O1xuICAgICAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcC5fX3RyZWVUYWdzLmdldCh0YWcpO1xuICAgICAgICAgICAgICAgICAgICBpZiAobGlzdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGlzdC5kZWxldGUodGhpcyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IHdoaWxlICghcC5fX3RhZ1Jvb3QgJiYgKHAgPSBwLl9fcGFyZW50KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBoYXNUYWcodGFnKSB7XG4gICAgICAgIHJldHVybiAodGhpcy5fX3RhZ3MgJiYgKHRoaXMuX190YWdzLmluZGV4T2YodGFnKSAhPT0gLTEpKTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBSZXR1cm5zIG9uZSBvZiB0aGUgZWxlbWVudHMgZnJvbSB0aGUgc3VidHJlZSB0aGF0IGhhdmUgdGhpcyB0YWcuXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IHRhZ1xuICAgICAqIEByZXR1cm5zIHtFbGVtZW50fVxuICAgICAqL1xuICAgIF90YWcodGFnKSB7XG4gICAgICAgIGlmICh0YWcuaW5kZXhPZihcIi5cIikgIT09IC0xKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5tdGFnKHRhZylbMF07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fX3RyZWVUYWdzKSB7XG4gICAgICAgICAgICAgICAgbGV0IHQgPSB0aGlzLl9fdHJlZVRhZ3MuZ2V0KHRhZyk7XG4gICAgICAgICAgICAgICAgaWYgKHQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IHQudmFsdWVzKCkubmV4dCgpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbSA/IGl0ZW0udmFsdWUgOiB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldCB0YWcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl90YWc7XG4gICAgfVxuXG4gICAgc2V0IHRhZyh0KSB7XG4gICAgICAgIHRoaXMudGFncyA9IHQ7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmV0dXJucyBhbGwgZWxlbWVudHMgZnJvbSB0aGUgc3VidHJlZSB0aGF0IGhhdmUgdGhpcyB0YWcuXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IHRhZ1xuICAgICAqIEByZXR1cm5zIHtFbGVtZW50W119XG4gICAgICovXG4gICAgbXRhZyh0YWcpIHtcbiAgICAgICAgbGV0IGlkeCA9IHRhZy5pbmRleE9mKFwiLlwiKTtcbiAgICAgICAgaWYgKGlkeCA+PSAwKSB7XG4gICAgICAgICAgICBsZXQgcGFydHMgPSB0YWcuc3BsaXQoJy4nKTtcbiAgICAgICAgICAgIGxldCByZXMgPSB0aGlzLl9nZXRCeVRhZyhwYXJ0c1swXSk7XG4gICAgICAgICAgICBsZXQgbGV2ZWwgPSAxO1xuICAgICAgICAgICAgbGV0IGMgPSBwYXJ0cy5sZW5ndGg7XG4gICAgICAgICAgICB3aGlsZSAocmVzLmxlbmd0aCAmJiBsZXZlbCA8IGMpIHtcbiAgICAgICAgICAgICAgICBsZXQgcmVzbiA9IFtdO1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwLCBuID0gcmVzLmxlbmd0aDsgaiA8IG47IGorKykge1xuICAgICAgICAgICAgICAgICAgICByZXNuID0gcmVzbi5jb25jYXQocmVzW2pdLl9nZXRCeVRhZyhwYXJ0c1tsZXZlbF0pKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXMgPSByZXNuO1xuICAgICAgICAgICAgICAgIGxldmVsKys7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcmVzO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2dldEJ5VGFnKHRhZyk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc3RhZyh0YWcsIHNldHRpbmdzKSB7XG4gICAgICAgIGxldCB0ID0gdGhpcy5tdGFnKHRhZyk7XG4gICAgICAgIGxldCBuID0gdC5sZW5ndGg7XG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICBCYXNlLnBhdGNoT2JqZWN0KHRbaV0sIHNldHRpbmdzKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB0YWdSb290KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX3RhZ1Jvb3Q7XG4gICAgfVxuXG4gICAgc2V0IHRhZ1Jvb3Qodikge1xuICAgICAgICBpZiAodGhpcy5fX3RhZ1Jvb3QgIT09IHYpIHtcbiAgICAgICAgICAgIGlmICghdikge1xuICAgICAgICAgICAgICAgIHRoaXMuX3NldFRhZ3NQYXJlbnQoKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdW5zZXRUYWdzUGFyZW50KCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX190YWdSb290ID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNlbChwYXRoKSB7XG4gICAgICAgIGNvbnN0IHJlc3VsdHMgPSB0aGlzLnNlbGVjdChwYXRoKTtcbiAgICAgICAgaWYgKHJlc3VsdHMubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0c1swXTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzZWxlY3QocGF0aCkge1xuICAgICAgICBpZiAocGF0aC5pbmRleE9mKFwiLFwiKSAhPT0gLTEpIHtcbiAgICAgICAgICAgIGxldCBzZWxlY3RvcnMgPSBwYXRoLnNwbGl0KCcsJyk7XG4gICAgICAgICAgICBsZXQgcmVzID0gW107XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNlbGVjdG9ycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIHJlcyA9IHJlcy5jb25jYXQodGhpcy5fc2VsZWN0KHNlbGVjdG9yc1tpXSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHJlcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9zZWxlY3QocGF0aCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfc2VsZWN0KHBhdGgpIHtcbiAgICAgICAgaWYgKHBhdGggPT09IFwiXCIpIHJldHVybiBbdGhpc107XG5cblxuICAgICAgICBsZXQgcG9pbnRJZHggPSBwYXRoLmluZGV4T2YoXCIuXCIpO1xuICAgICAgICBsZXQgYXJyb3dJZHggPSBwYXRoLmluZGV4T2YoXCI+XCIpO1xuICAgICAgICBpZiAocG9pbnRJZHggPT09IC0xICYmIGFycm93SWR4ID09PSAtMSkge1xuICAgICAgICAgICAgLy8gUXVpY2sgY2FzZS5cbiAgICAgICAgICAgIHJldHVybiB0aGlzLm10YWcocGF0aCk7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBEZXRlY3QgYnkgZmlyc3QgY2hhci5cbiAgICAgICAgbGV0IGlzUmVmO1xuICAgICAgICBpZiAoYXJyb3dJZHggPT09IDApIHtcbiAgICAgICAgICAgIGlzUmVmID0gdHJ1ZTtcbiAgICAgICAgICAgIHBhdGggPSBwYXRoLnN1YnN0cigxKTtcbiAgICAgICAgfSBlbHNlIGlmIChwb2ludElkeCA9PT0gMCkge1xuICAgICAgICAgICAgaXNSZWYgPSBmYWxzZTtcbiAgICAgICAgICAgIHBhdGggPSBwYXRoLnN1YnN0cigxKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlzUmVmID0gZmFsc2U7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdGhpcy5fc2VsZWN0Q2hpbGRzKHBhdGgsIGlzUmVmKTtcbiAgICB9XG5cbiAgICBfc2VsZWN0Q2hpbGRzKHBhdGgsIGlzUmVmKSB7XG4gICAgICAgIGNvbnN0IHBvaW50SWR4ID0gcGF0aC5pbmRleE9mKFwiLlwiKTtcbiAgICAgICAgY29uc3QgYXJyb3dJZHggPSBwYXRoLmluZGV4T2YoXCI+XCIpO1xuXG4gICAgICAgIGlmIChwb2ludElkeCA9PT0gLTEgJiYgYXJyb3dJZHggPT09IC0xKSB7XG4gICAgICAgICAgICBpZiAoaXNSZWYpIHtcbiAgICAgICAgICAgICAgICBjb25zdCByZWYgPSB0aGlzLmdldEJ5UmVmKHBhdGgpO1xuICAgICAgICAgICAgICAgIHJldHVybiByZWYgPyBbcmVmXSA6IFtdO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tdGFnKHBhdGgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKChhcnJvd0lkeCA9PT0gLTEpIHx8IChwb2ludElkeCAhPT0gLTEgJiYgcG9pbnRJZHggPCBhcnJvd0lkeCkpIHtcbiAgICAgICAgICAgIGxldCBuZXh0O1xuICAgICAgICAgICAgY29uc3Qgc3RyID0gcGF0aC5zdWJzdHIoMCwgcG9pbnRJZHgpO1xuICAgICAgICAgICAgaWYgKGlzUmVmKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVmID0gdGhpcy5nZXRCeVJlZihzdHIpO1xuICAgICAgICAgICAgICAgIG5leHQgPSByZWYgPyBbcmVmXSA6IFtdO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBuZXh0ID0gdGhpcy5tdGFnKHN0cik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgdG90YWwgPSBbXTtcbiAgICAgICAgICAgIGNvbnN0IHN1YlBhdGggPSBwYXRoLnN1YnN0cihwb2ludElkeCArIDEpO1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBuZXh0Lmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHRvdGFsID0gdG90YWwuY29uY2F0KG5leHRbaV0uX3NlbGVjdENoaWxkcyhzdWJQYXRoLCBmYWxzZSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRvdGFsO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbGV0IG5leHQ7XG4gICAgICAgICAgICBjb25zdCBzdHIgPSBwYXRoLnN1YnN0cigwLCBhcnJvd0lkeCk7XG4gICAgICAgICAgICBpZiAoaXNSZWYpIHtcbiAgICAgICAgICAgICAgICBjb25zdCByZWYgPSB0aGlzLmdldEJ5UmVmKHN0cik7XG4gICAgICAgICAgICAgICAgbmV4dCA9IHJlZiA/IFtyZWZdIDogW107XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG5leHQgPSB0aGlzLm10YWcoc3RyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCB0b3RhbCA9IFtdO1xuICAgICAgICAgICAgY29uc3Qgc3ViUGF0aCA9IHBhdGguc3Vic3RyKGFycm93SWR4ICsgMSk7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IG5leHQubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdG90YWwgPSB0b3RhbC5jb25jYXQobmV4dFtpXS5fc2VsZWN0Q2hpbGRzKHN1YlBhdGgsIHRydWUpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0b3RhbDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldEJ5UmVmKHJlZikge1xuICAgICAgICByZXR1cm4gdGhpcy5jaGlsZExpc3QuZ2V0QnlSZWYocmVmKTtcbiAgICB9XG5cbiAgICBnZXRMb2NhdGlvblN0cmluZygpIHtcbiAgICAgICAgbGV0IGk7XG4gICAgICAgIGkgPSB0aGlzLl9fcGFyZW50ID8gdGhpcy5fX3BhcmVudC5fY2hpbGRyZW4uZ2V0SW5kZXgodGhpcykgOiBcIlJcIjtcbiAgICAgICAgbGV0IGxvY2FsVGFncyA9IHRoaXMuZ2V0VGFncygpO1xuICAgICAgICBsZXQgc3RyID0gdGhpcy5fX3BhcmVudCA/IHRoaXMuX19wYXJlbnQuZ2V0TG9jYXRpb25TdHJpbmcoKTogXCJcIjtcbiAgICAgICAgaWYgKHRoaXMucmVmKSB7XG4gICAgICAgICAgICBzdHIgKz0gXCI6W1wiICsgaSArIFwiXVwiICsgdGhpcy5yZWY7XG4gICAgICAgIH0gZWxzZSBpZiAobG9jYWxUYWdzLmxlbmd0aCkge1xuICAgICAgICAgICAgc3RyICs9IFwiOltcIiArIGkgKyBcIl1cIiArIGxvY2FsVGFncy5qb2luKFwiLFwiKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0ciArPSBcIjpbXCIgKyBpICsgXCJdI1wiICsgdGhpcy5pZDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gc3RyO1xuICAgIH1cblxuICAgIHRvU3RyaW5nKCkge1xuICAgICAgICBsZXQgb2JqID0gdGhpcy5nZXRTZXR0aW5ncygpO1xuICAgICAgICByZXR1cm4gRWxlbWVudC5nZXRQcmV0dHlTdHJpbmcob2JqLCBcIlwiKTtcbiAgICB9O1xuXG4gICAgc3RhdGljIGdldFByZXR0eVN0cmluZyhvYmosIGluZGVudCkge1xuICAgICAgICBsZXQgY2hpbGRyZW4gPSBvYmouY2hpbGRyZW47XG4gICAgICAgIGRlbGV0ZSBvYmouY2hpbGRyZW47XG5cblxuICAgICAgICAvLyBDb252ZXJ0IHNpbmd1bGFyIGpzb24gc2V0dGluZ3Mgb2JqZWN0LlxuICAgICAgICBsZXQgY29sb3JLZXlzID0gW1wiY29sb3JcIiwgXCJjb2xvclVsXCIsIFwiY29sb3JVclwiLCBcImNvbG9yQmxcIiwgXCJjb2xvckJyXCJdO1xuICAgICAgICBsZXQgc3RyID0gSlNPTi5zdHJpbmdpZnkob2JqLCBmdW5jdGlvbiAoaywgdikge1xuICAgICAgICAgICAgaWYgKGNvbG9yS2V5cy5pbmRleE9mKGspICE9PSAtMSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBcIkNPTE9SW1wiICsgdi50b1N0cmluZygxNikgKyBcIl1cIjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB2O1xuICAgICAgICB9KTtcbiAgICAgICAgc3RyID0gc3RyLnJlcGxhY2UoL1wiQ09MT1JcXFsoW2EtZjAtOV17MSw4fSlcXF1cIi9nLCBcIjB4JDFcIik7XG5cbiAgICAgICAgaWYgKGNoaWxkcmVuKSB7XG4gICAgICAgICAgICBsZXQgY2hpbGRTdHIgPSBcIlwiO1xuICAgICAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbChjaGlsZHJlbikpIHtcbiAgICAgICAgICAgICAgICBsZXQgcmVmcyA9IE9iamVjdC5rZXlzKGNoaWxkcmVuKTtcbiAgICAgICAgICAgICAgICBjaGlsZFN0ciA9IFwiXCI7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSByZWZzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgIC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0aCAtIDEpICsgKGlzRW1wdHkgPyBcIlwiIDogXCIsXCIpICsgXCJcXFwiY2hpbGRyZW5cXFwiOlxcblwiICsgaW5kZW50ICsgY2hpbGRTdHIgKyBcIn1cIjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHN0cjtcbiAgICB9XG5cbiAgICBnZXRTZXR0aW5ncygpIHtcbiAgICAgICAgbGV0IHNldHRpbmdzID0gdGhpcy5nZXROb25EZWZhdWx0cygpO1xuXG4gICAgICAgIGxldCBjaGlsZHJlbiA9IHRoaXMuX2NoaWxkcmVuLmdldCgpO1xuICAgICAgICBpZiAoY2hpbGRyZW4pIHtcbiAgICAgICAgICAgIGxldCBuID0gY2hpbGRyZW4ubGVuZ3RoO1xuICAgICAgICAgICAgaWYgKG4pIHtcbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZEFycmF5ID0gW107XG4gICAgICAgICAgICAgICAgbGV0IG1pc3NpbmcgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZEFycmF5LnB1c2goY2hpbGRyZW5baV0uZ2V0U2V0dGluZ3MoKSk7XG4gICAgICAgICAgICAgICAgICAgIG1pc3NpbmcgPSBtaXNzaW5nIHx8ICFjaGlsZHJlbltpXS5yZWY7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCFtaXNzaW5nKSB7XG4gICAgICAgICAgICAgICAgICAgIHNldHRpbmdzLmNoaWxkcmVuID0ge31cbiAgICAgICAgICAgICAgICAgICAgY2hpbGRBcnJheS5mb3JFYWNoKGNoaWxkID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldHRpbmdzLmNoaWxkcmVuW2NoaWxkLnJlZl0gPSBjaGlsZDtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlI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biAgICAgICAgICAgIGlmICh0aGlzLnNjYWxlWCAhPT0gMSkgc2V0dGluZ3Muc2NhbGVYID0gdGhpcy5zY2FsZVg7XG4gICAgICAgICAgICBpZiAodGhpcy5zY2FsZVkgIT09IDEpIHNldHRpbmdzLnNjYWxlWSA9IHRoaXMuc2NhbGVZO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMucGl2b3RYID09PSB0aGlzLnBpdm90WSkge1xuICAgICAgICAgICAgaWYgKHRoaXMucGl2b3RYICE9PSAwLjUpIHNldHRpbmdzLnBpdm90ID0gdGhpcy5waXZvdFg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5waXZvdFggIT09IDAuNSkgc2V0dGluZ3MucGl2b3RYID0gdGhpcy5waXZvdFg7XG4gICAgICAgICAgICBpZiAodGhpcy5waXZvdFkgIT09IDAuNSkgc2V0dGluZ3MucGl2b3RZID0gdGhpcy5waXZvdFk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5tb3VudFggPT09IHRoaXMubW91bnRZKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5tb3VudFggIT09IDApIHNldHRpbmdzLm1vdW50ID0gdGhpcy5tb3VudFg7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodGhpcy5tb3VudFggIT09IDApIHNldHRpbmdzLm1vdW50WCA9IHRoaXMubW91bnRYO1xuICAgICAgICAgICAgaWYgKHRoaXMubW91bnRZICE9PSAwKSBzZXR0aW5ncy5tb3VudFkgPSB0aGlzLm1vdW50WTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLmFscGhhICE9PSAxKSBzZXR0aW5ncy5hbHBoYSA9IHRoaXMuYWxwaGE7XG5cbiAgICAgICAgaWYgKCF0aGlzLnZpc2libGUpIHNldHRpbmdzLnZpc2libGUgPSBmYWxzZTtcblxuICAgICAgICBpZiAodGhpcy5yb3RhdGlvbiAhPT0gMCkgc2V0d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gICAgIGlmICghdGhpcy5jbGlwYm94KSBzZXR0aW5ncy5jbGlwYm94ID0gdGhpcy5jbGlwYm94O1xuXG4gICAgICAgIGlmICh0aGlzLl9fdGV4dHVyZSkge1xuICAgICAgICAgICAgbGV0IHRuZCA9IHRoaXMuX190ZXh0dXJlLmdldE5vbkRlZmF1bHRzKCk7XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXModG5kKS5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICBzZXR0aW5ncy50ZXh0dXJlID0gdG5kO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMuc2hhZGVyICYmIFV0aWxzLmlzRnVuY3Rpb24odGhpcy5zaGFkZXIuZ2V0Tm9uRGVmYXVsdHMpKSB7XG4gICAgICAgICAgICBsZXQgdG5kID0gdGhpcy5zaGFkZXIuZ2V0Tm9uRGVmYXVsdHMoKTtcbiAgICAgICAgICAgIGlmIChPYmplY3Qua2V5cyh0bmQpLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHNldHRpbmdzLnNoYWRlciA9IHRuZDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9oYXNUZXh0dXJpemVyKCkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnRleHR1cml6ZXIuZW5hYmxlZCkge1xuICAgICAgICAgICAgICAgIHNldHRpbmdzLnJlbmRlclRvVGV4dHVyZSA9IHRoaXMudGV4dHVyaXplci5lbmFibGVkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMudGV4dHVyaXplci5sYXp5KSB7XG4gICAgICAgICAgICAgICAgc2V0dGluZ3MucmVuZGVyVG9UZXh0dXJlTGF6eSA9IHRoaXMudGV4dHVyaXplci5sYXp5O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMudGV4dHVyaXplci5jb2xvcml6ZSkge1xuICAgICAgICAgICAgICAgIHNld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gpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLm9mZnNldFg7XG4gICAgfVxuXG4gICAgc2V0IHgodikge1xuICAgICAgICB0aGlzLl9fY29yZS5vZmZzZXRYID0gdjtcbiAgICB9XG5cbiAgICBnZXQgeSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLm9mZnNldFk7XG4gICAgfVxuXG4gICAgc2V0IHkodikge1xuICAgICAgICB0aGlzLl9fY29yZS5vZmZzZXRZID0gdjtcbiAgICB9XG5cbiAgICBnZXQgdygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3c7XG4gICAgfVxuXG4gICAgc2V0IHcodikge1xuICAgICAgICBpZiAoVXRpbHMuaXNGdW5jdGlvbih2KSkge1xuICAgICAgICAgICAgdGhpcy5fdyA9IDA7XG4gICAgICAgICAgICB0aGlzLl9fY29yZS5mdW5jVyA9IHY7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2ID0gTWF0aC5tYXgodiwgMCk7XG4gICAgICAgICAgICBpZiAodGhpcy5fdyAhPT0gdikge1xuICAgICAgICAgICAgICAgIHRoaXMuX19jb3JlLmRpc2FibGVGdW5jVygpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3cgPSB2O1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZURpbWVuc2lvbnMoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG5cbiAgICBzZXQgaCh2KSB7XG4gICAgICAgIGlmIChVdGlscy5pc0Z1bmN0aW9uKHYpKSB7XG4gICAgICAgICAgICB0aGlzLl9oID0gMDtcbiAgICAgICAgICAgIHRoaXMuX19jb3JlLmZ1bmNIID0gdjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHYgPSBNYXRoLm1heCh2LCAwKTtcbiAgICAgICAgICAgIGlmICh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ICByZXR1cm4gdGhpcy5fX2NvcmUuc2NhbGVZO1xuICAgIH1cblxuICAgIHNldCBzY2FsZVkodikge1xuICAgICAgICB0aGlzLl9fY29yZS5zY2FsZVkgPSB2O1xuICAgIH1cblxuICAgIGdldCBzY2FsZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnNjYWxlO1xuICAgIH1cblxuICAgIHNldCBzY2FsZSh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLnNjYWxlID0gdjtcbiAgICB9XG5cbiAgICBnZXQgcGl2b3RYKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUucGl2b3RYO1xuICAgIH1cblxuICAgIHNldCBwaXZvdFgodikge1xuICAgICAgICB0aGlzLl9fY29yZS5waXZvdFggPSB2O1xuICAgIH1cblxuICAgIGdldCBwaXZvdFkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5waXZvdFk7XG4gICAgfVxuXG4gICAgc2V0IHBpdm90WSh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLnBpdm90WSA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHBpdm90KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUucGl2b3Q7XG4gICAgfVxuXG4gICAgc2V0IHBpdm90KHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUucGl2b3QgPSB2O1xuICAgIH1cblxuICAgIGdldCBtb3VudFgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5tb3VudFg7XG4gICAgfVxuXG4gICAgc2V0IG1vdW50WCh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLm1vdW50WCA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IG1vdW50WSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLm1vdW50WTtcbiAgICB9XG5cbiAgICBzZXQgbW91bnRZKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUubW91bnRZID0gdjtcbiAgICB9XG5cbiAgICBnZXQgbW91bnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5tb3VudDtcbiAgICB9XG5cbiAgICBzZXQgbW91bnQodikge1xuICAgICAgICB0aGlzLl9fY29yZS5tb3VudCA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHJvdGF0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUucm90YXRpb247XG4gICAgfVxuXG4gICAgc2V0IHJvdGF0aW9uKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUucm90YXRpb24gPSB2O1xuICAgIH1cblxuICAgIGdldCBhbHBoYSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLmFscGhhO1xuICAgIH1cblxuICAgIHNldCBhbHBoYSh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLmFscGhhID0gdjtcbiAgICB9XG5cbiAgICBnZXQgdmlzaWJsZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX19jb3JlLnZpc2libGU7XG4gICAgfVxuXG4gICAgc2V0IHZpc2libGUodikge1xuICAgICAgICB0aGlzLl9fY29yZS52aXNpYmxlID0gdjtcbiAgICB9XG4gICAgXG4gICAgZ2V0IGNvbG9yVWwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jb2xvclVsO1xuICAgIH1cblxuICAgIHNldCBjb2xvclVsKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuY29sb3JVbCA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yVXIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jb2xvclVyO1xuICAgIH1cblxuICAgIHNldCBjb2xvclVyKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuY29sb3JVciA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yQmwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jb2xvckJsO1xuICAgIH1cblxuICAgIHNldCBjb2xvckJsKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuY29sb3JCbCA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yQnIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5jb2xvckJyO1xuICAgIH1cblxuICAgIHNldCBjb2xvckJyKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuY29sb3JCciA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuY29sb3JVbDtcbiAgICB9XG5cbiAgICBzZXQgY29sb3Iodikge1xuICAgICAgICBpZiAodGhpcy5jb2xvclVsICE9PSB2IHx8IHRoaXMuY29sb3JVciAhPT0gdiB8fCB0aGlzLmNvbG9yQmwgIT09IHYgfHwgdGhpcy5jb2xvckJyICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLmNvbG9yVWwgPSB2O1xuICAgICAgICAgICAgdGhpcy5jb2xvclVyID0gdjtcbiAgICAgICAgICAgIHRoaXMuY29sb3JCbCA9IHY7XG4gICAgICAgICAgICB0aGlzLmNvbG9yQnIgPSB2O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGNvbG9yVG9wKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5jb2xvclVsO1xuICAgIH1cblxuICAgIHNldCBjb2xvclRvcCh2KSB7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yVWwgIT09IHYgfHwgdGhpcy5jb2xvclVyICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLmNvbG9yVWwgPSB2O1xuICAgICAgICAgICAgdGhpcy5jb2xvclVyID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBjb2xvckJvdHRvbSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuY29sb3JCbDtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JCb3R0b20odikge1xuICAgICAgICBpZiAodGhpcy5jb2xvckJsICE9PSB2IHx8IHRoaXMuY29sb3JCciAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5jb2xvckJsID0gdjtcbiAgICAgICAgICAgIHRoaXMuY29sb3JCciA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgY29sb3JMZWZ0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5jb2xvclVsO1xuICAgIH1cblxuICAgIHNldCBjb2xvckxlZnQodikge1xuICAgICAgICBpZiAodGhpcy5jb2xvclVsICE9PSB2IHx8IHRoaXMuY29sb3JCbCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5jb2xvclVsID0gdjtcbiAgICAgICAgICAgIHRoaXMuY29sb3JCbCA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgY29sb3JSaWdodCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuY29sb3JVcjtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JSaWdodCh2KSB7XG4gICAgICAgIGlmICh0aGlzLmNvbG9yVXIgIT09IHYgfHwgdGhpcy5jb2xvckJyICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLmNvbG9yVXIgPSB2O1xuICAgICAgICAgICAgdGhpcy5jb2xvckJyID0gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCB6SW5kZXgoKSB7cmV0dXJuIHRoaXMuX19jb3JlLnpJbmRleH1cbiAgICBzZXQgekluZGV4KHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuekluZGV4ID0gdjtcbiAgICB9XG5cbiAgICBnZXQgZm9yY2VaSW5kZXhDb250ZXh0KCkge3JldHVybiB0aGlzLl9fY29yZS5mb3JjZVpJbmRleENvbnRleHR9XG4gICAgc2V0IGZvcmNlWkluZGV4Q29udGV4dCh2KSB7XG4gICAgICAgIHRoaXMuX19jb3JlLmZvcmNlWkluZGV4Q29udGV4dCA9IHY7XG4gICAgfVxuXG4gICAgZ2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YXRjaCh2KTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldCBvblVwZGF0ZShmKSB7XG4gICAgICAgIHRoaXMuX19jb3JlLm9uVXBkYXRlID0gZjtcbiAgICB9XG5cbiAgICBzZXQgb25BZnRlckNhbGNzKGYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUub25BZnRlckNhbGNzID0gZjtcbiAgICB9XG5cbiAgICBzZXQgb25BZnRlclVwZGF0ZShmKSB7XG4gICAgICAgIHRoaXMuX19jb3JlLm9uQWZ0ZXJVcGRhdGUgPSBmO1xuICAgIH1cblxuICAgIGZvcmNlVXBkYXRlKCkge1xuICAgICAgICAvLyBNYWtlIHN1cmUgdGhhdCB0aGUgdXBkYXRlIGxvb3AgaXMgcnVuLlxuICAgICAgICB0aGlzLl9fY29yZS5fc2V0SGFzVXBkYXRlcygpO1xuICAgIH1cblxuICAgIGdldCBzaGFkZXIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5zaGFkZXI7XG4gICAgfVxuXG4gICAgc2V0IHNoYWRlcih2KSB7XG4gICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodikgJiYgIXYudHlwZSkge1xuICAgICAgICAgICAgLy8gU2V0dGluZyBwcm9wZXJ0aWVzIG9uIGFuIGV4aXN0aW5nIHNoYWRlci5cbiAgICAgICAgICAgIGlmICh0aGlzLnNoYWRlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuc2hhZGVyLnBhdGNoKHYpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3Qgc2hhZGVyID0gU2hhZGVyLmNyZWF0ZSh0aGlzLnN0YWdlLCB2KTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX19lbmFibGVkICYmIHRoaXMuX19jb3JlLnNoYWRlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuX19jb3JlLnNoYWRlci5yZW1vdmVFbGVtZW50KHRoaXMuX19jb3JlKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fX2NvcmUuc2hhZGVyID0gc2hhZGVyO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fX2VuYWJsZWQgJiYgdGhpcy5fX2NvcmUuc2hhZGVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX2NvcmUuc2hhZGVyLmFkZEVsZW1lbnQodGhpcy5fX2NvcmUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2hhc1RleHR1cml6ZXIoKSB7XG4gICAgICAgIHJldHVybiAhIXRoaXMuX19jb3JlLl90ZXh0dXJpemVyO1xuICAgIH1cblxuICAgIGdldCByZW5kZXJUb1RleHR1cmUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnJ0dFxuICAgIH1cblxuICAgIHNldCByZW5kZXJUb1RleHR1cmUodikge1xuICAgICAgICB0aGlzLnJ0dCA9IHZcbiAgICB9XG5cbiAgICBnZXQgcnR0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faGFzVGV4dHVyaXplcigpICYmIHRoaXMudGV4dHVyaXplci5lbmFibGVkO1xuICAgIH1cblxuICAgIHNldCBydHQodikge1xuICAgICAgICB0aGlzLnRleHR1cml6ZXIuZW5hYmxlZCA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHJ0dExhenkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oYXNUZXh0dXJpemVyKCkgJiYgdGhpcy50ZXh0dXJpemVyLmxhenk7XG4gICAgfVxuXG4gICAgc2V0IHJ0dExhenkodikge1xuICAgICAgICB0aGlzLnRleHR1cml6ZXIubGF6eSA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IHJlbmRlck9mZnNjcmVlbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2hhc1RleHR1cml6ZXIoKSAmJiB0aGlzLnRleHR1cml6ZXIucmVuZGVyT2Zmc2NyZWVuO1xuICAgIH1cblxuICAgIHNldCByZW5kZXJPZmZzY3JlZW4odikge1xuICAgICAgICB0aGlzLnRleHR1cml6ZXIucmVuZGVyT2Zmc2NyZWVuID0gdjtcbiAgICB9XG5cbiAgICBnZXQgY29sb3JpemVSZXN1bHRUZXh0dXJlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faGFzVGV4dHVyaXplcigpICYmIHRoaXMudGV4dHVyaXplci5jb2xvcml6ZTtcbiAgICB9XG5cbiAgICBzZXQgY29sb3JpemVSZXN1bHRUZXh0dXJlKHYpIHtcbiAgICAgICAgdGhpcy50ZXh0dXJpemVyLmNvbG9yaXplID0gdjtcbiAgICB9XG5cbiAgICBnZXRUZXh0dXJlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy50ZXh0dXJpemVyLl9nZXRUZXh0dXJlU291cmNlKCk7XG4gICAgfVxuXG4gICAgZ2V0IHRleHR1cml6ZXIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS50ZXh0dXJpemVyO1xuICAgIH1cblxuICAgIHBhdGNoKHNldHRpbmdzKSB7XG4gICAgICAgIGxldCBwYXRocyA9IE9iamVjdC5rZXlzKHNldHRpbmdzKTtcblxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHBhdGhzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbGV0IHBhdGggPSBwYXRoc1tpXTtcbiAgICAgICAgICAgIGNvbnN0IHYgPSBzZXR0aW5nc1twYXRoXTtcblxuICAgICAgICAgICAgY29uc3QgZmlyc3RDaGFyQ29kZSA9IHBhdGguY2hhckNvZGVBdCgwKTtcbiAgICAgICAgICAgIGlmIChVdGlscy5pc1VjQ2hhcihmaXJzdENoYXJDb2RlKSkge1xuICAgICAgICAgICAgICAgIC8vIFJlZi5cbiAgICAgICAgICAgICAgICBjb25zdCBjaGlsZCA9IHRoaXMuZ2V0QnlSZWYocGF0aCk7XG4gICAgICAgICAgICAgICAgaWYgKCFjaGlsZCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodiAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBBZGQgdG8gbGlzdCBpbW1lZGlhdGVseS5cbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENhdGNoIHRoaXMgY2FzZSB0byBjYXB0dXJlIGNyZWF0ZU1vZGUgZmxhZy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gdGhpcy5jaGlsZExpc3QuY3JlYXRlSXRlbSh2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjLnBhdGNoKHYpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdCh2KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGMgPSB2O1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGMuaXNFbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYy5yZWYgPSBwYXRoO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKGMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHYgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLnBhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkLnBhcmVudC5jaGlsZExpc3QucmVtb3ZlKGNoaWxkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwodikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoaWxkLnBhdGNoKHYpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHYuaXNFbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBSZXBsYWNlIGVsZW1lbnQgYnkgbmV3IGVsZW1lbnQuXG4gICAgICAgICAgICAgICAgICAgICAgICB2LnJlZiA9IHBhdGg7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5yZXBsYWNlKHYsIGNoaWxkKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Rocm93RXJyb3IoXCJVbmV4cGVjdGVkIHZhbHVlIGZvciBwYXRoOiBcIiArIHBhdGgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBQcm9wZXJ0eS5cbiAgICAgICAgICAgICAgICBCYXNlLnBhdGNoT2JqZWN0UHJvcGVydHkodGhpcywgcGF0aCwgdik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfdGhyb3dFcnJvcihtZXNzYWdlKSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcih0aGlzLmNvbnN0cnVjdG9yLm5hbWUgKyBcIiAoXCIgKyB0aGlzLmdldExvY2F0aW9uU3RyaW5nKCkgKyBcIik6IFwiICsgbWVzc2FnZSk7XG4gICAgfVxuXG4gICAgYW5pbWF0aW9uKHNldHRpbmdzKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnN0YWdlLmFuaW1hdGlvbnMuY3JlYXRlQW5pbWF0aW9uKHRoaXMsIHNldHRpbmdzKTtcbiAgICB9XG5cbiAgICB0cmFuc2l0aW9uKHByb3BlcnR5LCBzZXR0aW5ncyA9IG51bGwpIHtcbiAgICAgICAgaWYgKHNldHRpbmdzID09PSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fZ2V0VHJhbnNpdGlvbihwcm9wZXJ0eSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9zZXRUcmFuc2l0aW9uKHByb3BlcnR5LCBzZXR0aW5ncyk7XG4gICAgICAgICAgICAvLyBXZSBkbyBub3QgY3JlYXRlL3JldHVybiB0aGUgdHJhbnNpdGlvbiwgYmVjYXVzZSBpdCB3b3VsZCB1bmRvIHRoZSAnbGF6eSB0cmFuc2l0aW9uIGNyZWF0aW9uJyBvcHRpbWl6YXRpb24uXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldCB0cmFuc2l0aW9ucyhvYmplY3QpIHtcbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmplY3QpO1xuICAgICAgICBrZXlzLmZvckVhY2gocHJvcGVydHkgPT4ge1xuICAgICAgICAgICAgdGhpcy50cmFuc2l0aW9uKHByb3BlcnR5LCBvYmplY3RbcHJvcGVydHldKTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgc2V0IHNtb290aChvYmplY3QpIHtcbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhvYmplY3QpO1xuICAgICAgICBrZXlzLmZvckVhY2gocHJvcGVydHkgPT4ge1xuICAgICAgICAgICAgbGV0IHZhbHVlID0gb2JqZWN0W3Byb3BlcnR5XTtcbiAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHZhbHVlKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuc2V0U21vb3RoKHByb3BlcnR5LCB2YWx1ZVswXSwgdmFsdWVbMV0pO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldFNtb290aChwcm9wZXJ0eSwgdmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBmYXN0Rm9yd2FyZChwcm9wZXJ0eSkge1xuICAgICAgICBpZiAodGhpcy5fdHJhbnNpdGlvbnMpIHtcbiAgICAgICAgICAgIGxldCB0ID0gdGhpcy5fdHJhbnNpdGlvbnNbcHJvcGVydHldO1xuICAgICAgICAgICAgaWYgKHQgJiYgdC5pc1RyYW5zaXRpb24pIHtcbiAgICAgICAgICAgICAgICB0LmZpbmlzaCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldFRyYW5zaXRpb24ocHJvcGVydHkpIHtcbiAgICAgICAgaWYgKCF0aGlzLl90cmFuc2l0aW9ucykge1xuICAgICAgICAgICAgdGhpcy5fdHJhbnNpdGlvbnMgPSB7fTtcbiAgICAgICAgfVxuICAgICAgICBsZXQgdCA9IHRoaXMuX3RyYW5zaXRpb25zW3Byb3BlcnR5XTtcbiAgICAgICAgaWYgKCF0KSB7XG4gICAgICAgICAgICAvLyBDcmVhdGUgZGVmYXVsdCB0cmFuc2l0aW9uLlxuICAgICAgICAgICAgdCA9IG5ldyBUcmFuc2l0aW9uKHRoaXMuc3RhZ2UudHJhbnNpdGlvbnMsIHRoaXMuc3RhZ2UudHJhbnNpdGlvbnMuZGVmYXVsdFRyYW5zaXRpb25TZXR0aW5ncywgdGhpcywgcHJvcGVydHkpO1xuICAgICAgICB9IGVsc2UgaWYgKHQuaXNUcmFuc2l0aW9uU2V0dGluZ3MpIHtcbiAgICAgICAgICAgIC8vIFVwZ3JhZGUgdG8gJ3JlYWwnIHRyYW5zaXRpb24uXG4gICAgICAgICAgICB0ID0gbmV3IFRyYW5zaXRpb24oXG4gICAgICAgICAgICAgICAgdGhpcy5zdGFnZS50cmFuc2l0aW9ucyxcbiAgICAgICAgICAgICAgICB0LFxuICAgICAgICAgICAgICAgIHRoaXMsXG4gICAgICAgICAgICAgICAgcHJvcGVydHlcbiAgICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fdHJhbnNpdGlvbnNbcHJvcGVydHldID0gdDtcbiAgICAgICAgcmV0dXJuIHQ7XG4gICAgfVxuXG4gICAgX3NldFRyYW5zaXRpb24ocHJvcGVydHksIHNldHRpbmdzKSB7XG4gICAgICAgIGlmICghc2V0dGluZ3MpIHtcbiAgICAgICAgICAgIHRoaXMuX3JlbW92ZVRyYW5zaXRpb24ocHJvcGVydHkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbChzZXR0aW5ncykpIHtcbiAgICAgICAgICAgICAgICAvLyBDb252ZXJ0IHBsYWluIG9iamVjdCB0byBwcm9wZXIgc2V0dGluZ3Mgb2JqZWN0LlxuICAgICAgICAgICAgICAgIHNldHRpbmdzID0gdGhpcy5zdGFnZS50cmFuc2l0aW9ucy5jcmVhdGVTZXR0aW5ncyhzZXR0aW5ncyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICghdGhpcy5fdHJhbnNpdGlvbnMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl90cmFuc2l0aW9ucyA9IHt9O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgY3VycmVudCA9IHRoaXMuX3RyYW5zaXRpb25zW3Byb3BlcnR5XTtcbiAgICAgICAgICAgIGlmIChjdXJyZW50ICYmIGN1cnJlbnQuaXNUcmFuc2l0aW9uKSB7XG4gICAgICAgICAgICAgICAgLy8gUnVudGltZSBzZXR0aW5ncyBjaGFuZ2UuXG4gICAgICAgICAgICAgICAgY3VycmVudC5zZXR0aW5ncyA9IHNldHRpbmdzO1xuICAgICAgICAgICAgICAgIHJldHVybiBjdXJyZW50O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBJbml0aWFsbHksIG9ubHkgc2V0IHRoZSBzZXR0aW5ncyBhbmQgdXBncmFkZSB0byBhICdyZWFsJyB0cmFuc2l0aW9uIHdoZW4gaXQgaXMgdXNlZC5cbiAgICAgICAgICAgICAgICB0aGlzLl90cmFuc2l0aW9uc1twcm9wZXJ0eV0gPSBzZXR0aW5ncztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9yZW1vdmVUcmFuc2l0aW9uKHByb3BlcnR5KSB7XG4gICAgICAgIGlmICh0aGlzLl90cmFuc2l0aW9ucykge1xuICAgICAgICAgICAgZGVsZXRlIHRoaXMuX3RyYW5zaXRpb25zW3Byb3BlcnR5XTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldFNtb290aChwcm9wZXJ0eSwgdikge1xuICAgICAgICBsZXQgdCA9IHRoaXMuX2dldFRyYW5zaXRpb24ocHJvcGVydHkpO1xuICAgICAgICBpZiAodCAmJiB0LmlzQXR0YWNoZWQoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHQudGFyZ2V0VmFsdWU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gdjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldFNtb290aChwcm9wZXJ0eSwgdiwgc2V0dGluZ3MpIHtcbiAgICAgICAgaWYgKHNldHRpbmdzKSB7XG4gICAgICAgICAgICB0aGlzLl9zZXRUcmFuc2l0aW9uKHByb3BlcnR5LCBzZXR0aW5ncyk7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IHQgPSB0aGlzLl9nZXRUcmFuc2l0aW9uKHByb3BlcnR5KTtcbiAgICAgICAgdC5zdGFydCh2KTtcbiAgICAgICAgcmV0dXJuIHQ7XG4gICAgfVxuXG4gICAgZ2V0IGZsZXgoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9fY29yZS5mbGV4O1xuICAgIH1cblxuICAgIHNldCBmbGV4KHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuZmxleCA9IHY7XG4gICAgfVxuXG4gICAgZ2V0IGZsZXhJdGVtKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fX2NvcmUuZmxleEl0ZW07XG4gICAgfVxuXG4gICAgc2V0IGZsZXhJdGVtKHYpIHtcbiAgICAgICAgdGhpcy5fX2NvcmUuZmxleEl0ZW0gPSB2O1xuICAgIH1cblxuICAgIHN0YXRpYyBpc0NvbG9yUHJvcGVydHkocHJvcGVydHkpIHtcbiAgICAgICAgcmV0dXJuIHByb3BlcnR5LnRvTG93ZXJDYXNlKCkuaW5kZXhPZihcImNvbG9yXCIpID49IDA7XG4gICAgfVxuXG4gICAgc3RhdGljIGdldE1lcmdlcihwcm9wZXJ0eSkge1xuICAgICAgICBpZiAoRWxlbWVudC5pc0NvbG9yUHJvcGVydHkocHJvcGVydHkpKSB7XG4gICAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5tZXJnZUNvbG9ycztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBTdGFnZVV0aWxzLm1lcmdlTnVtYmVycztcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHRvSlNPTigpIHtcbiAgICAgICAgY29uc3QgcmVmID0gW2Ake3RoaXMuY29uc3RydWN0b3IubmFtZX1gXTtcbiAgICAgICAgY29uc3QgdHJlZSA9IHt9O1xuICAgICAgICB0cmVlW3JlZl0gPSB7fTtcblxuICAgICAgICBpZiAodGhpcy5oYXNDaGlsZHJlbigpKSB7XG4gICAgICAgICAgICBFbGVtZW50LmNvbGxlY3RDaGlsZHJlbih0cmVlW3JlZl0sIHRoaXMuX19jaGlsZExpc3QpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdHJlZVtyZWZdID0gey4uLkVsZW1lbnQuZ2V0UHJvcGVydGllcyh0aGlzKX07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRyZWU7XG4gICAgfVxuXG4gICAgc3RhdGljIGNvbGxlY3RDaGlsZHJlbih0cmVlLCBjaGlsZHJlbikge1xuICAgICAgICBjb25zdCBjaGlsZExpc3QgPSBjaGlsZHJlbjtcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIGogPSBjaGlsZExpc3QubGVuZ3RoOyBpIDwgajsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gY2hpbGRMaXN0LmdldEF0KGkpO1xuICAgICAgICAgICAgY29uc3QgcmVmID0gYCR7ZWxlbWVudC5fX3JlZiB8fCBgRWxlbWVudC0ke2VsZW1lbnQuaWR9YH1gO1xuICAgICAgICAgICAgY29uc3QgcHJvcGVydGllcyA9IHRoaXMuZ2V0UHJvcGVydGllcyhlbGVtZW50KTtcblxuICAgICAgICAgICAgdHJlZVtyZWZdID0gey4uLnByb3BlcnRpZXN9O1xuXG4gICAgICAgICAgICBpZiAoZWxlbWVudC5oYXNDaGlsZHJlbigpKSB7XG4gICAgICAgICAgICAgICAgdHJlZVtyZWZdLmNoaWxkcmVuID0ge307XG4gICAgICAgICAgICAgICAgdGhpcy5jb2xsZWN0Q2hpbGRyZW4oXG4gICAgICAgICAgICAgICAgICAgIHRyZWVbcmVmXS5jaGlsZHJlbiwgZWxlbWVudC5fX2NoaWxkTGlzdFxuICAgICAgICAgICAgICAgICk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0UHJvcGVydGllcyhlbGVtZW50KSB7XG4gICAgICAgIGNvbnN0IHByb3BzID0ge307XG4gICAgICAgIGNvbnN0IGxpc3QgPSBbXG4gICAgICAgICAgICBcImFscGhhXCIsIFwiYWN0aXZlXCIsIFwiYXR0YWNoZWRcIiwgXCJib3VuZHNNYXJnaW5cIiwgXCJjb2xvclwiLCBcImNsaXBwaW5nXCIsIFwiZW5hYmxlZFwiLCBcImhcIiwgXCJpZFwiLCBcImlzQ29tcG9uZW50XCIsXG4gICAgICAgICAgICBcIm1vdW50XCIsIFwibW91bnRZXCIsIFwibW91bnRYXCIsIFwicGl2b3RcIiwgXCJwaXZvdFhcIiwgXCJwaXZvdFlcIiwgXCJyZWZcIi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ZW0pO1xuICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ3JlcGxhY2U6IFRoZSBwcmV2aW91cyBpdGVtIGRvZXMgbm90IGV4aXN0Jyk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5zZXRBdChpdGVtLCBpbmRleCk7XG4gICAgfVxuXG4gICAgc2V0QXQoaXRlbSwgaW5kZXgpIHtcbiAgICAgICAgaWYgKGluZGV4ID49IDAgJiYgaW5kZXggPD0gdGhpcy5faXRlbXMubGVuZ3RoKSB7XG5cbiAgICAgICAgICAgIGlmIChVdGlscy5pc09iamVjdExpdGVyYWwoaXRlbSkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBvID0gaXRlbTtcbiAgICAgICAgICAgICAgICBpdGVtID0gdGhpcy5jcmVhdGVJdGVtKG8pO1xuICAgICAgICAgICAgICAgIGl0ZW0ucGF0Y2gobyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBjdXJyZW50SW5kZXggPSB0aGlzLl9pdGVtcy5pbmRleE9mKGl0ZW0pO1xuICAgICAgICAgICAgaWYgKGN1cnJlbnRJbmRleCAhPSAtMSkge1xuICAgICAgICAgICAgICAgIGlmIChjdXJyZW50SW5kZXggIT09IGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGZyb21JbmRleCA9IGN1cnJlbnRJbmRleDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZyb21JbmRleCAhPT0gaW5kZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2l0ZW1zLnNwbGljZShmcm9tSW5kZXgsIDEpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXRlbXMuc3BsaWNlKGluZGV4LCAwLCBpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Nb3ZlKGl0ZW0sIGZyb21JbmRleCwgaW5kZXgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiggaW5kZXggPCB0aGlzLl9pdGVtcy5sZW5ndGgpe1xuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pdGVtc1tpbmRleF0ucmVmKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWZzW3RoaXMuX2l0ZW1zW2luZGV4XS5yZWZdID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldkl0ZW0gPSB0aGlzLl9pdGVtc1tpbmRleF07XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gRG9lc24ndCBleGlzdCB5ZXQ6IG92ZXJ3cml0ZSBjdXJyZW50LlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9pdGVtc1tpbmRleF0gPSBpdGVtO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLnJlZikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVmc1tpdGVtLnJlZl0gPSBpdGVtO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5vblNldChpdGVtLCBpbmRleCwgcHJldkl0ZW0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignc2V0QXQ6IFRoZSBpbmRleCAnICsgaW5kZXggKyAnIGlzIG91dCBvZiBib3VuZHMgJyArIHRoaXMuX2l0ZW1zLmxlbmd0aCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdzZXRBdDogVGhlIGluZGV4ICcgKyBpbmRleCArICcgaXMgb3V0IG9mIGJvdW5kcyAnICsgdGhpcy5faXRlbXMubGVuZ3RoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldEF0KGluZGV4KSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9pdGVtc1tpbmRleF07XG4gICAgfVxuXG4gICAgZ2V0SW5kZXgoaXRlbSkge1xuICAgICAgICByZXR1cm4gdGhpcy5faXRlbXMuaW5kZXhPZihpdGVtKTtcbiAgICB9XG5cbiAgICByZW1vdmUoaXRlbSkge1xuICAgICAgICBsZXQgaW5kZXggPSB0aGlzLl9pdGVtcy5pbmRleE9mKGl0ZW0pO1xuXG4gICAgICAgIGlmIChpbmRleCAhPT0gLTEpIHtcbiAgICAgICAgICAgIHRoaXMucmVtb3ZlQXQoaW5kZXgpO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHJlbW92ZUF0KGluZGV4KSB7XG4gICAgICAgIGlmIChpbmRleCA+PSAwICYmIGluZGV4IDwgdGhpcy5faXRlbXMubGVuZ3RoKSB7XG4gICAgICAgICAgICBjb25zdCBpdGVtID0gdGhpcy5faXRlbXNbaW5kZXhdO1xuXG4gICAgICAgICAgICBpZiAoaXRlbS5yZWYpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZWZzW2l0ZW0ucmVmXSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5faXRlbXMuc3BsaWNlKGluZGV4LCAxKTtcblxuICAgICAgICAgICAgdGhpcy5vblJlbW92ZShpdGVtLCBpbmRleCk7XG5cbiAgICAgICAgICAgIHJldHVybiBpdGVtO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGByZW1vdmVBdDogVGhlIGluZGV4ICR7aW5kZXh9IGlzIG91dCBvZiBib3VuZHMgJHt0aGlzLl9pdGVtcy5sZW5ndGggLSAxfWApO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGNsZWFyKCkge1xuICAgICAgICBsZXQgbiA9IHRoaXMuX2l0ZW1zLmxlbmd0aDtcbiAgICAgICAgaWYgKG4pIHtcbiAgICAgICAgICAgIGxldCBwcmV2ID0gdGhpcy5faXRlbXM7XG4gICAgICAgICAgICB0aGlzLl9pdGVtcyA9IFtdO1xuICAgICAgICAgICAgdGhpcy5fcmVmcyA9IHt9XG4gICAgICAgICAgICB0aGlzLm9uU3luYyhwcmV2LCBbXSwgW10pO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIGEobykge1xuICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKG8pKSB7XG4gICAgICAgICAgICBsZXQgYyA9IHRoaXMuY3JlYXRlSXRlbShvKTtcbiAgICAgICAgICAgIGMucGF0Y2gobyk7XG4gICAgICAgICAgICB0aGlzLmFkZChjKTtcbiAgICAgICAgICAgIHJldHVybiBjO1xuICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkobykpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gby5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB0aGlzLmEob1tpXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLmlzSXRlbShvKSkge1xuICAgICAgICAgICAgdGhpcy5hZGQobyk7XG4gICAgICAgICAgICByZXR1cm4gbztcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBnZXQgbGVuZ3RoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faXRlbXMubGVuZ3RoO1xuICAgIH1cblxuICAgIF9nZXRSZWZzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmVmcztcbiAgICB9XG5cbiAgICBnZXRCeVJlZihyZWYpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3JlZnNbcmVmXTtcbiAgICB9XG5cbiAgICBjbGVhclJlZihyZWYpIHtcbiAgICAgICAgZGVsZXRlIHRoaXMuX3JlZnNbcmVmXTtcbiAgICB9XG5cbiAgICBzZXRSZWYocmVmLCBjaGlsZCkge1xuICAgICAgICB0aGlzLl9yZWZzW3JlZl0gPSBjaGlsZDtcbiAgICB9XG5cbiAgICBwYXRjaChzZXR0aW5ncykge1xuICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHNldHRpbmdzKSkge1xuICAgICAgICAgICAgdGhpcy5fc2V0QnlPYmplY3Qoc2V0dGluZ3MpO1xuICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoc2V0dGluZ3MpKSB7XG4gICAgICAgICAgICB0aGlzLl9zZXRCeUFycmF5KHNldHRpbmdzKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9zZXRCeU9iamVjdChzZXR0aW5ncykge1xuICAgICAgICAvLyBPdmVycnVsZSBzZXR0aW5ncyBvZiBrbm93biByZWZlcmVuY2VkIGl0ZW1zLlxuICAgICAgICBsZXQgcmVmcyA9IHRoaXMuX2dldFJlZnMoKTtcbiAgICAgICAgbGV0IGNyZWZzID0gT2JqZWN0LmtleXMoc2V0dGluZ3MpO1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGNyZWZzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbGV0IGNyZWYgPSBjcmVmc1tpXTtcbiAgICAgICAgICAgIGxldCBzID0gc2V0dGluZ3NbY3JlZl07XG5cbiAgICAgICAgICAgIGxldCBjID0gcmVmc1tjcmVmXTtcbiAgICAgICAgICAgIGlmICghYykge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSXRlbShzKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBSZXBsYWNlIHByZXZpb3VzIGl0ZW07XG4gICAgICAgICAgICAgICAgICAgIHMucmVmID0gY3JlZjtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGQocyk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQ3JlYXRlIG5ldyBpdGVtLlxuICAgICAgICAgICAgICAgICAgICBjID0gdGhpcy5jcmVhdGVJdGVtKHMpO1xuICAgICAgICAgICAgICAgICAgICBjLnJlZiA9IGNyZWY7XG4gICAgICAgICAgICAgICAgICAgIGMucGF0Y2gocyk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkKGMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJdGVtKHMpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjICE9PSBzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBSZXBsYWNlIHByZXZpb3VzIGl0ZW07XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgaWR4ID0gdGhpcy5nZXRJbmRleChjKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMucmVmID0gY3JlZjtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0QXQocywgaWR4KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGMucGF0Y2gocyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2VxdWFsc0FycmF5KGFycmF5KSB7XG4gICAgICAgIGxldCBzYW1lID0gdHJ1ZTtcbiAgICAgICAgaWYgKGFycmF5Lmxlbmd0aCA9PT0gdGhpcy5faXRlbXMubGVuZ3RoKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2l0ZW1zLmxlbmd0aDsgKGkgPCBuKSAmJiBzYW1lOyBpKyspIHtcbiAgICAgICAgICAgICAgICBzYW1lID0gc2FtZSAmJiAodGhpcy5faXRlbXNbaV0gPT09IGFycmF5W2ldKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHNhbWUgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gc2FtZTtcbiAgICB9XG5cbiAgICBfc2V0QnlBcnJheShhcnJheSkge1xuICAgICAgICAvLyBGb3IgcGVyZm9ybWFuY2UgcmVhc29ucywgZmlyc3QgY2hlY2sgaWYgdGhlIGFycmF5cyBtYXRjaCBleGFjdGx5IGFuZCBiYWlsIG91dCBpZiB0aGV5IGRvLlxuICAgICAgICBpZiAodGhpcy5fZXF1YWxzQXJyYXkoYXJyYXkpKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2l0ZW1zLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgdGhpcy5faXRlbXNbaV0ubWFya2VyID0gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCByZWZzO1xuICAgICAgICBsZXQgbmV3SXRlbXMgPSBbXTtcbiAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSBhcnJheS5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgIGxldCBzID0gYXJyYXlbaV07XG4gICAgICAgICAgICBpZiAodGhpcy5pc0l0ZW0ocykpIHtcbiAgICAgICAgICAgICAgICBzLm1hcmtlciA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIG5ld0l0ZW1zLnB1c2gocyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGxldCBjcmVmID0gcy5yZWY7XG4gICAgICAgICAgICAgICAgbGV0IGM7XG4gICAgICAgICAgICAgICAgaWYgKGNyZWYpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFyZWZzKSByZWZzID0gdGhpcy5fZ2V0UmVmcygpO1xuICAgICAgICAgICAgICAgICAgICBjID0gcmVmc1tjcmVmXTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoIWMpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQ3JlYXRlIG5ldyBpdGVtLlxuICAgICAgICAgICAgICAgICAgICBjID0gdGhpcy5jcmVhdGVJdGVtKHMpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGMubWFya2VyID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKFV0aWxzLmlzT2JqZWN0TGl0ZXJhbChzKSkge1xuICAgICAgICAgICAgICAgICAgICBjLnBhdGNoKHMpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIG5ld0l0ZW1zLnB1c2goYyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLl9zZXRJdGVtcyhuZXdJdGVtcyk7XG4gICAgfVxuXG4gICAgX3NldEl0ZW1zKG5ld0l0ZW1zKSB7XG4gICAgICAgIGxldCBwcmV2SXRlbXMgPSB0aGlzLl9pdGVtcztcbiAgICAgICAgdGhpcy5faXRlbXMgPSBuZXdJdGVtcztcblxuICAgICAgICAvLyBSZW1vdmUgdGhlIGl0ZW1zLlxuICAgICAgICBsZXQgcmVtb3ZlZCA9IHByZXZJdGVtcy5maWx0ZXIoaXRlbSA9PiB7bGV0IG0gPSBpdGVtLm1hcmtlcjsgZGVsZXRlIGl0ZW0ubWFya2VyOyByZXR1cm4gbX0pO1xuICAgICAgICBsZXQgYWRkZWQgPSBuZXdJdGVtcy5maWx0ZXIoaXRlbSA9PiAocHJldkl0ZW1zLmluZGV4T2YoaXRlbSkgPT09IC0xKSk7XG5cbiAgICAgICAgaWYgKHJlbW92ZWQubGVuZ3RoIHx8IGFkZGVkLmxlbmd0aCkge1xuICAgICAgICAgICAgLy8gUmVjYWxjdWxhdGUgcmVmcy5cbiAgICAgICAgICAgIHRoaXMuX3JlZnMgPSB7fVxuICAgICAgICAgICAgZ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xuICAgICAgICB9IGVsc2UgaWYgKHYgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgc2hhZGVyID0gbnVsbDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmICh2LmlzU2hhZGVyKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFzdGFnZS5yZW5kZXJlci5pc1ZhbGlkU2hhZGVyVHlwZSh2LmNvbnN0cnVjdG9yKSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiW0xpZ2h0bmluZ10gSW52YWxpZCBzaGFkZXIgdHlwZVwiKTtcbiAgICAgICAgICAgICAgICAgICAgdiA9IG51bGw7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHNoYWRlciA9IHY7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXCJbTGlnaHRuaW5nXSBQbGVhc2Ugc3BlY2lmeSBhIHNoYWRlciB0eXBlLlwiKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gc2hhZGVyO1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXRXZWJHTCgpIHtcbiAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgICB9XG5cbiAgICBzdGF0aWMgZ2V0QzJkKCkge1xuICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xuICAgIH1cblxuICAgIGFkZEVsZW1lbnQoZWxlbWVudENvcmUpIHtcbiAgICAgICAgdGhpcy5fZWxlbWVudHMuYWRkKGVsZW1lbnRDb3JlKTtcbiAgICB9XG5cbiAgICByZW1vdmVFbGVtZW50KGVsZW1lbnRDb3JlKSB7XG4gICAgICAgIHRoaXMuX2VsZW1lbnRzLmRlbGV0ZShlbGVtZW50Q29yZSk7XG4gICAgICAgIGlmICghdGhpcy5fZWxlbWVudHMpIHtcbiAgICAgICAg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gY29uc3QgcmF0aW8gPSB0aGlzLmdldE9wdGlvbignZGV2aWNlUGl4ZWxSYXRpbycpO1xuICAgICAgICAgICAgICAgIC8vIHNldCBjb3JyZWN0IGRpc3BsYXkgc2llXG4gICAgICAgICAgICAgICAgdGhpcy5nZXRDYW52YXMoKS5zdHlsZS53aWR0aCA9IHRoaXMuX29wdGlvbnNbJ3cnXSAvIHJhdGlvICArICdweCc7XG4gICAgICAgICAgICAgICAgdGhpcy5nZXRDYW52YXMoKS5zdHlsZS5oZWlnaHQgPSB0aGlzLl9vcHRpb25zWydoJ10gLyByYXRpbyArICdweCc7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIHNldCBkaXNwbGF5IGJ1ZmZlciBzaXplXG4gICAgICAgICAgICB0aGlzLl9vcHRpb25zLncgPSB0aGlzLmdldENhbnZhcygpLndpZHRoO1xuICAgICAgICAgICAgdGhpcy5fb3B0aW9ucy5oID0gdGhpcy5nZXRDYW52YXMoKS5oZWlnaHQ7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5fbW9kZSA9PT0gMCkge1xuICAgICAgICAgICAgaWYgKFV0aWxzLmlzU3BhcmspIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJlciA9IG5ldyBTcGFya1JlbmRlcmVyKHRoaXMpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJlciA9IG5ldyBXZWJHTFJlbmRlcmVyKHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fcmVuZGVyZXIgPSBuZXcgQzJkUmVuZGVyZXIodGhpcyk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnNldENsZWFyQ29sb3IodGhpcy5nZXRPcHRpb24oJ2NsZWFyQ29sb3InKSk7XG5cbiAgICAgICAgdGhpcy5mcmFtZUNvdW50ZXIgPSAwO1xuXG4gICAgICAg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1cHBvcnRlZCgpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzTm9kZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmV0dXJuICEhd2luZG93LldlYkdMUmVuZGVyaW5nQ29udGV4dDtcbiAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmV0dXJucyB0aGUgcmVuZGVyaW5nIG1vZGUuXG4gICAgICogQHJldHVybnMge251bWJlcn1cbiAgICAgKiAgMDogV2ViR0xcbiAgICAgKiAgMTogQ2FudmFzMmRcbiAgICAgKi9cbiAgICBnZXQgbW9kZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21vZGU7XG4gICAgfVxuXG4gICAgaXNXZWJnbCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMubW9kZSA9PT0gMDtcbiAgICB9XG5cbiAgICBpc0MyZCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMubW9kZSA9PT0gMTtcbiAgICB9XG5cbiAgICBnZXRPcHRpb24obmFtZSkge1xuICAgICAgICByZXR1cm4gdGhpcy5fb3B0aW9uc1tuYW1lXTtcbiAgICB9XG5cbiAgICBfc2V0T3B0aW9ucyhvKSB7XG4gICAgICAgIHRoaXMuX29wdGlvbnMgPSB7fTtcblxuICAgICAgICBsZXQgb3B0ID0gKG5hbWUsIGRlZikgPT4ge1xuICAgICAgICAgICAgbGV0IHZhbHVlID0gb1tuYW1lXTtcblxuICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vcHRpb25zW25hbWVdID0gZGVmO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9vcHRpb25zW25hbWVdID0gdmFsdWU7XG4gICA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ldE9wdGlvbignYXV0b3N0YXJ0JykpIHtcbiAgICAgICAgICAgIHRoaXMucGxhdGZvcm0uc3RhcnRMb29wKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBkZXN0cm95KCkge1xuICAgICAgICB0aGlzLnBsYXRmb3JtLnN0b3BMb29wKCk7XG4gICAgICAgIHRoaXMucGxhdGZvcm0uZGVzdHJveSgpO1xuICAgICAgICB0aGlzLmN0eC5kZXN0cm95KCk7XG4gICAgICAgIHRoaXMudGV4dHVyZU1hbmFnZXIuZGVzdHJveSgpO1xuICAgICAgICB0aGlzLl9yZW5kZXJlci5kZXN0cm95KCk7XG5cbiAgICAgICAgLy8gY2xlYXIgbGFzdCByZW5kZXJlZCBmcmFtZVxuICAgICAgICBpZiAodGhpcy5nbCkge1xuICAgICAgICAgICAgdGhpcy5nbC5jbGVhckNvbG9yKDAuMCwgMC4wLCAwLjAsIDAuMCk7XG4gICAgICAgICAgICB0aGlzLmdsLmNsZWFyKHRoaXMuZ2wuQ09MT1JfQlVGRkVSX0JJVCk7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5jMmQpIHtcbiAgICAgICAgICAgIHRoaXMuYzJkLmNsZWFyUmVjdChcbiAgICAgICAgICAgICAgICAwLCAwLCB0aGlzLmMyZC5jYW52YXMud2lkdGgsIHRoaXMuYzJkLmNhbnZhcy5oZWlnaHRcbiAgICAgICAgICAgICk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLmdsID0gbnVsbDtcbiAgICAgICAgdGhpcy5jMmQgPSBudWxsO1xuICAgICAgICB0aGlzLmN0eCA9IG51bGw7XG4gICAgICAgIHRoaXMuX29wdGlvbnMgPSBudWxsO1xuICAgICAgICB0aGlzLnBsYXRmb3JtID0gbnVsbDtcbiAgICAgICAgdGhpcy50ZXh0dXJlTWFuYWdlciA9IG51bGw7XG4gICAgICAgIHRoaXMuX3JlbmRlcmVyID0gbnVsbDtcblxuICAgICAgICBkZWxldGUgdGhpcy5nbDtcbi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hbWUoKTtcbiAgICB9XG5cbiAgICBmb3JjZVJlbmRlclVwZGF0ZSgpIHtcbiAgICAgICAgLy8gRW5mb3JjZSByZS1yZW5kZXJpbmcuXG4gICAgICAgIGlmICh0aGlzLnJvb3QpIHtcbiAgICAgICAgICAgIHRoaXMucm9vdC5jb3JlLl9wYXJlbnQuc2V0SGFzUmVuZGVyVXBkYXRlcygxKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldENsZWFyQ29sb3IoY2xlYXJDb2xvcikge1xuICAgICAgICB0aGlzLmZvcmNlUmVuZGVyVXBkYXRlKCk7XG4gICAgICAgIGlmIChjbGVhckNvbG9yID09PSBudWxsKSB7XG4gICAgICAgICAgICAvLyBEbyBub3QgY2xlYXIuXG4gICAgICAgICAgICB0aGlzLl9jbGVhckNvbG9yID0gbnVsbDtcbiAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KGNsZWFyQ29sb3IpKSB7XG4gICAgICAgICAgICB0aGlzLl9jbGVhckNvbG9yID0gY2xlYXJDb2xvcjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX2NsZWFyQ29sb3IgPSBTdGFnZVV0aWxzLmdldFJnYmFDb21wb25lbnRzTm9ybWFsaXplZChjbGVhckNvbG9yKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldENsZWFyQ29sb3IoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jbGVhckNvbG9yO1xuICAgIH1cblxuICAgIGNyZWF0ZUVsZW1lbnQoc2V0dGluZ3MpIHtcbiAgICAgICAgaWYgKHNldHRpbmdzKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5lbGVtZW50KHNldHRpbmdzKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBuZXcgRWxlbWVudCh0aGlzKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGNyZWF0ZVNoYWRlcihzZXR0aW5ncykge1xuICAgICAgICByZXR1cm4gU2hhZGVyLmNyZWF0ZSh0aGlzLCBzZXR0aW5ncyk7XG4gICAgfVxuXG4gICAgZWxlbWVudChzZXR0aW5ncykge1xuICAgICAgICBpZiAoc2V0dGluZ3MuaXNFbGVtZW50KSByZXR1cm4gc2V0dGluZ3M7XG5cbiAgICAgICAgbGV0IGVsZW1lbnQ7XG4gICAgICAgIGlmIChzZXR0aW5ncy50eXBlKSB7XG4gICAgICAgICAgICBlbGVtZW50ID0gbmV3IHNldHRpbmdzLnR5cGUodGhpcyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBlbGVtZW50ID0gbmV3IEVsZW1lbnQodGhpcyk7XG4gICAgICAgIH1cblxuICAgICAgICBlbGVtZW50LnBhdGNoKHNldHRpbmdzKTtcblxuICAgICAgICByZXR1cm4gZWxlbWVudDtcbiAgICB9XG5cbiAgICBjKHNldHRpbmdzKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmVsZW1lbnQoc2V0dGluZ3MpO1xuICAgIH1cblxuICAgIGdldCB3KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fb3B0aW9ucy53O1xuICAgIH1cblxuICAgIGdldCBoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fb3B0aW9ucy5oO1xuICAgIH1cblxuICAgIGdldCBjb29yZHNXaWR0aCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudyAvIHRoaXMuX29wdGlvbnMucHJlY2lzaW9uO1xuICAgIH1cblxuICAgIGdldCBjb29yZHNIZWlnaHQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmggLyB0aGlzLl9vcHRpb25zLnByZWNpc2lvbjtcbiAgICB9XG5cbiAgICBhZGRNZW1vcnlVc2FnZShkZWx0YSkge1xuICAgICAgICB0aGlzLl91c2VkTWVtb3J5ICs9IGRlbHRhO1xuICAgICAgICBpZiAoZGVsdGEgPiAwICYmIHRoaXMuX2xhc3RHY0ZyYW1lICE9PSB0aGlzLmZyYW1lQ291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AoMjU1ICogMTY3NzcyMTYpO1xuICAgIH07XG5cbiAgICBzdGF0aWMgcmdiYShyLCBnLCBiLCBhKSB7XG4gICAgICAgIHJldHVybiAociA8PCAxNikgKyAoZyA8PCA4KSArIGIgKyAoKChhICogMjU1KSB8IDApICogMTY3NzcyMTYpO1xuICAgIH07XG5cbiAgICBzdGF0aWMgZ2V0UmdiU3RyaW5nKGNvbG9yKSB7XG4gICAgICAgIGxldCByID0gKChjb2xvciAvIDY1NTM2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgZyA9ICgoY29sb3IgLyAyNTYpIHwgMCkgJSAyNTY7XG4gICAgICAgIGxldCBiID0gY29sb3IgJSAyNTY7XG4gICAgICAgIHJldHVybiAncmdiKCcgKyByICsgJywnICsgZyArICcsJyArIGIgKyAnKSc7XG4gICAgfTtcblxuICAgIHN0YXRpYyBnZXRSZ2JhU3RyaW5nKGNvbG9yKSB7XG4gICAgICAgIGxldCByID0gKChjb2xvciAvIDY1NTM2KSB8IDApICUgMjU2O1xuICAgICAgICBsZXQgZyA9ICgoY29sb3IgLyAyNTYpIHwgMCkgJSAyNTY7XG4gICAgICAgIGxldCBiID0gY29sb3IgJSAyNTY7XG4gICAgICAgIGxldCBhID0gKChjb2xvciAvIDE2Nzc3MjE2KSB8IDApIC8gMjU1O1xuICAgICAgICByZXR1cm4gJ3JnYmEoJyArIHIgKyAnLCcgKyBnICsgJywnICsgYiArICcsJyArIGEudG9GaXhlZCg0KSArICcpJztcbiAgICB9O1xuXG4gICAgc3RhdGljIGdldFJnYmFTdHJpbmdGcm9tQXJyYXkoY29sb3IpIHtcbiAgICAgICAgbGV0IHIgPSBNYXRoLmZsb29yKGNvbG9yWzBdICogMjU1KTtcbiAgICAgICAgbGV0IGcgPSBNYXRoLmZsb29yKGNvbG9yWzFdICogMjU1KTtcbiAgICAgICAgbGV0IGIgPSBNYXRoLmZsb29yKGNvbG9yWzJdICogMjU1KTtcbiAgICAgICAgbGV0IGEgPSBNYXRoLmZ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AgIGxldCByID0gcjEgKiBwICsgcjIgKiAoMSAtIHApO1xuICAgICAgICBsZXQgZyA9IGcxICogcCArIGcyICogKDEgLSBwKTtcbiAgICAgICAgbGV0IGIgPSBiMSAqIHAgKyBiMiAqICgxIC0gcCk7XG4gICAgICAgIGxldCBhID0gYTEgKiBwICsgYTIgKiAoMSAtIHApO1xuXG4gICAgICAgIHJldHVybiBNYXRoLnJvdW5kKGEpICogMTY3NzcyMTYgKyBNYXRoLnJvdW5kKHIpICogNjU1MzYgKyBNYXRoLnJvdW5kKGcpICogMjU2ICsgTWF0aC5yb3VuZChiKTtcbiAgICB9O1xuXG4gICAgc3RhdGljIG1lcmdlTXVsdGlDb2xvcnMoYywgcCkge1xuICAgICAgICBsZXQgciA9IDAsIGcgPSAwLCBiID0gMCwgYSA9IDAsIHQgPSAwO1xuICAgICAgICBsZXQgbiA9IGMubGVuZ3RoO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgbGV0IHIxID0gKChjW2ldIC8gNjU1MzYpIHwgMCkgJSAyNTY7XG4gICAgICAgICAgICBsZXQgZzEgPSAoKGNbaV0gLyAyNTYpIHwgMCkgJSAyNTY7XG4gICAgICAgICAgICBsZXQgYjEgPSBjW2ldICUgMjU2O1xuICAgICAgICAgICAgbGV0IGExID0gKChjW2ldIC8gMTY3NzcyMTYpIHwgMCk7XG4gICAgICAgICAgICByICs9IHIxICogcFtpXTtcbiAgICAgICAgICAgIGcgKz0gZzEgKiBwW2ldO1xuICAgICAgICAgICAgYiArPSBiMSAqIHBbaV07XG4gICAgICAgICAgICBhICs9IGExICogcFtpXTtcbiAgICAgICAgICAgIHQgKz0gcFtpXTtcbiAgICAgICAgfVxuXG4gICAgICAgIHQgPSAxIC8gdDtcbiAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoYSAqIHQpICogMTY3NzcyMTYgKyBNYXRoLnJvdW5kKHIgKiB0KSAqIDY1NTM2ICsgTWF0aC5y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yAyNTUpICYgMHhmZjAwKSArXG4gICAgICAgICAgICAoKCgoKGMgJiAweGZmKSA8PCAxNikgKiBhKSAvIDI1NSkgJiAweGZmMDAwMCkgK1xuICAgICAgICAgICAgKGEgPDwgMjQpO1xuICAgIH07XG5cbiAgICBzdGF0aWMgcmFkKGRlZykge1xuICAgICAgICByZXR1cm4gZGVnICogKE1hdGguUEkgLyAxODApO1xuICAgIH07XG5cbiAgICBzdGF0aWMgZ2V0VGltaW5nQmV6aWVyKGEsIGIsIGMsIGQpIHtcbiAgICAgICAgbGV0IHhjID0gMy4wICogYTtcbiAgICAgICAgbGV0IHhiID0gMy4wICogKGMgLSBhKSAtIHhjO1xuICAgICAgICBsZXQgeGEgPSAxLjAgLSB4YyAtIHhiO1xuICAgICAgICBsZXQgeWMgPSAzLjAgKiBiO1xuICAgICAgICBsZXQgeWIgPSAzLjAgKiAoZCAtIGIpIC0geWM7XG4gICAgICAgIGxldCB5YSA9IDEuMCAtIHljIC0geWI7XG5cbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICh0aW1lKSB7XG4gICAgICAgICAgICBpZiAodGltZSA+PSAxLjApIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aW1lIDw9IDApIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgbGV0IHQgPSAwLjUsIGNieCwgY2J4ZCwgZHg7XG5cbiAgICAgICAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICAgICAgICAgIGNieCA9IHQgKiAodCAqICh0ICogeGEgKyB4YikgKyB4Yyk7XG4gICAgICAgICAgICAgICAgZHggPSB0aW1lIC0gY2J4O1xuICAgICAgICAgICAgICAgIGlmIChkeCA+IC0xZS04ICYmIGR4IDwgMWUtOCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdCAqICh0ICogKHQgKiB5YSArIHliKSArIHljKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBDdWJpYyBiZXppZXIgZGVyaXZhdGl2ZS5cbiAgICAgICAgICAgICAgICBjYnhkID0gdCAqICh0ICogKDMgKiB4YSkgKyAyICogeGIpICsgeGM7XG5cbiAgICAgICAgICAgICAgICBpZiAoY2J4ZCA+IDFlLTEwICYmIGNieGQgPCAxZS0xMCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBQcm9ibGVtYXRpYy4gRmFsbCBiYWNrIHRvIGJpbmFyeSBzZWFyY2ggbWV0aG9kLlxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0ICs9IGR4IC8gY2J4ZDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gRmFsbGJhY2s6IGJpbmFyeSBzZWFyY2ggbWV0aG9kLiBUaGlzIGlzIG1vcmUgcmVsaWFibGUgd2hlbiB0aGVyZSBhcmUgbmVhci0wIHNsb3Blcy5cbiAgICAgICAgICAgIGxldCBtaW5UID0gMDtcbiAgICAgICAgICAgIGxldCBtYXhUID0gMTtcbiAgICAgICAgICAgIGZvciAobGV0IGl0ID0gMDsgaXQgPCAyMDsgaXQrKykge1xuICAgICAgICAgICAgICAgIHQgPSAwLjUgKiAobWluVCArIG1heFQpO1xuXG4gICAgICAgICAgICAgICAgY2J4ID0gdCAqICh0ICogKHQgKiB4YSArIHhiKSArIHhjKTtcblxuICAgICAgICAgICAgICAgIGR4ID0gdGltZSAtIGNieDtcbiAgICAgICAgICAgICAgICBpZiAoZHggPiAtMWUtOCAmJiBkeCA8IDFlLTgpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gU29sdXRpb24gZm91bmQhXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0ICogKHQgKiAodCAqIHlhICsgeWIpICsgeWMpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChkeCA8IDApIHtcbiAgICAgICAgICAgICAgICAgICAgbWF4VCA9IHQ7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbWluVCA9IHQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgIH07XG4gICAgfTtcblxuICAgIHN0YXRpYyBnZXRUaW1pbmdGdW5jdGlvbihzdHIpIHtcbiAgICAgICAgc3dpdGNoIChzdHIpIHtcbiAgICAgICAgICAgIGNhc2UgXCJsaW5lYXJcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHRpbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRpbWVcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgY2FzZSBcImVhc2VcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC4yNSwgMC4xLCAwLjI1LCAxLjApO1xuICAgICAgICAgICAgY2FzZSBcImVhc2UtaW5cIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC40MiwgMCwgMS4wLCAxLjApO1xuICAgICAgICAgICAgY2FzZSBcImVhc2Utb3V0XCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKDAsIDAsIDAuNTgsIDEuMCk7XG4gICAgICAgICAgICBjYXNlIFwiZWFzZS1pbi1vdXRcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gU3RhZ2VVdGlscy5nZXRUaW1pbmdCZXppZXIoMC40MiwgMCwgMC41OCwgMS4wKTtcbiAgICAgICAgICAgIGNhc2UgXCJzdGVwLXN0YXJ0XCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDFcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgY2FzZSBcInN0ZXAtZW5kXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICh0aW1lKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aW1lID09PSAxID8gMSA6IDA7XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgbGV0IHMgPSBcImN1YmljLWJlemllcihcIjtcbiAgICAgICAgICAgICAgICBpZiAoc3RyICYmIHN0ci5pbmRleE9mKHMpID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXJ0cyA9IHN0ci5zdWJzdHIocy5sZW5ndGgsIHN0ci5sZW5ndGggLSBzLmxlbmd0aCAtIDEpLnNwbGl0KFwiLFwiKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcnRzLmxlbmd0aCAhPT0gNCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiW0xpZ2h0bmluZ10gVW5rbm93biB0aW1pbmcgZnVuY3Rpb246IFwiICsgc3RyKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gRmFsbGJhY2s6IHVzZSBsaW5lYXIuXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHRpbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGltZVxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBsZXQgYSA9IHBhcnNlRmxvYXQocGFydHNbMF0pO1xuICAgICAgICAgICAgICAgICAgICBsZXQgYiA9IHBhcnNlRmxvYXQocGFydHNbMV0pO1xuICAgICAgICAgICAgICAgICAgICBsZXQgYyA9IHBhcnNlRmxvYXQocGFydHNbMl0pO1xuICAgICAgICAgICAgICAgICAgICBsZXQgZCA9IHBhcnNlRmxvYXQocGFydHNbM10pO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNOYU4oYSkgfHwgaXNOYU4oYikgfHwgaXNOYU4oYykgfHwgaXNOYU4oZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBGYWxsYmFjazogdXNlIGxpbmVhci5cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAodGltZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aW1lXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0YWdlVXRpbHMuZ2V0VGltaW5nQmV6aWVyKGEsIGIsIGMsIGQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihcIltMaWdodG5pbmddIFVua25vd24gdGltaW5nIGZ1bmN0aW9uOiBcIiArIHN0cik7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZhbGxiYWNrOiB1c2UgbGluZWFyLlxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKHRpbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aW1lXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxufVxuIiwiLypcbiAqIElmIG5vdCBzdGF0ZWQgb3RoZXJ3aXNlIGluIHRoaXMgZmlsZSBvciB0aGlzIGNvbXBvbmVudCdzIExJQ0VOU0UgZmlsZSB0aGVcbiAqIGZvbGxvd2luZyBjb3B5cmlnaHQgYW5kIGxpY2V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dHJ1ZTtcblxuICAgIH1cblxuICAgIGdldCBzb3VyY2UoKSB7XG4gICAgICAgIGlmICh0aGlzLl9tdXN0VXBkYXRlIHx8IHRoaXMuc3RhZ2UuaGFzVXBkYXRlU291cmNlVGV4dHVyZSh0aGlzKSkge1xuICAgICAgICAgICAgdGhpcy5fcGVyZm9ybVVwZGF0ZVNvdXJjZSh0cnVlKTtcbiAgICAgICAgICAgIHRoaXMuc3RhZ2UucmVtb3ZlVXBkYXRlU291cmNlVGV4dHVyZSh0aGlzKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5fc291cmNlO1xuICAgIH1cblxuICAgIGFkZEVsZW1lbnQodikge1xuICAgICAgICBpZiAoIXRoaXMuZWxlbWVudHMuaGFzKHYpKSB7XG4gICAgICAgICAgICB0aGlzLmVsZW1lbnRzLmFkZCh2KTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuZWxlbWVudHMuc2l6ZSA9PT0gMSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc291cmNlLmFkZFRleHR1cmUodGhpcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodi5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmluY0FjdGl2ZUNvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZW1vdmVFbGVtZW50KHYpIHtcbiAgICAgICAgaWYgKHRoaXMuZWxlbWVudHMuZGVsZXRlKHYpKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5lbGVtZW50cy5zaXplID09PSAwKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3NvdXJjZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9zb3VyY2UucmVtb3ZlVGV4dHVyZSh0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4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ICAgICBpZiAodGhpcy5fZ2V0SXNWYWxpZCgpKSB7XG4gICAgICAgICAgICBpZiAobG9va3VwSWQpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tYW5hZ2VyLmdldFJldXNhYmxlVGV4dHVyZVNvdXJjZShsb29rdXBJZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgfVxuXG4gICAgX3JlcGxhY2VUZXh0dXJlU291cmNlKG5ld1NvdXJjZSA9IG51bGwpIHtcbiAgICAgICAgbGV0IG9sZFNvdXJjZSA9IHRoaXMuX3NvdXJjZTtcblxuICAgICAgICB0aGlzLl9zb3VyY2UgPSBuZXdTb3VyY2U7XG5cbiAgICAgICAgaWYgKHRoaXMuZWxlbWVudHMuc2l6ZSkge1xuICAgICAgICAgICAgaWYgKG9sZFNvdXJjZSkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9hY3RpdmVDb3VudCkge1xuICAgICAgICAgICAgICAgICAgICBvbGRTb3VyY2UuZGVjQWN0aXZlVGV4dHVyZUNvdW50KCk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgb2xkU291cmNlLnJlbW92ZVRleHR1cmUodGhpcyk7XG5cbiAgICAgICAgICAgICAgICAvLyBmcmVlIHVwIHVudXNlZCBUZXh0VGV4dHVyZXMgaW1tZWRpYXRlbHkgYXMgdGhleSBhcmUgbm90IHJldXNlZCBhbnl3YXlcbiAgICAgICAgICAgICAgICBpZih0aGlzWyd0ZXh0J10gJiYgIW9sZFNvdXJjZS5pc1VzZWQoKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLm1hbmFnZXIuZnJlZVRleHR1cmVTb3VyY2Uob2xkU291cmNlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChuZXdTb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAvLyBNdXN0IGhhcHBlbiBiZWZvcmUgc2V0RGlzcGxheWVkVGV4dHVyZSB0byBlbnN1cmUgc3ByaXRlIG1hcCB0ZXhjb29yZHMgYXJlIHVzZWQuXG4gICAgICAgICAgICAgICAgbmV3U291cmNlLmFkZFRleHR1cmUodGhpcyk7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2FjdGl2ZUNvdW50KSB7XG4gICAgICAgICAgICAgICAgICAgIG5ld1NvdXJjZS5pbmNBY3RpdmVUZXh0dXJlQ291bnQoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5pc1VzZWQoKSkge1xuICAgICAgICAgICAgaWYgKG5ld1NvdXJjZSkge1xuICAgICAgICAgICAgICAgIGlmIChuZXdTb3VyY2UuaXNMb2FkZWQoKSkge1xuXG4gICAgICAgICAgICAgICAgICAgIC8vIEFwcGx5IHJlc2l6ZU1vZGVcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3Jlc2l6ZU1vZGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2FwcGx5UmVzaXplTW9kZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKGVsZW1lbnQgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5fc2V0RGlzcGxheWVkVGV4dHVyZSh0aGlzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbG9hZEVycm9yID0gbmV3U291cmNlLmxvYWRFcnJvcjtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGxvYWRFcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50cy5mb3JFYWNoKGVsZW1lbnQgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm9uVGV4dHVyZVNvdXJjZUxvYWRFcnJvcihsb2FkRXJyb3IpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmVsZW1lbnRzLmZvckVhY2goZWxlbWVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmFjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5fc2V0RGlzcGxheWVkVGV4dHVyZShudWxsKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgbG9hZCgpIHtcbiAgICAgICAgLy8gTWFrZSBzdXJlIHRoYXQgc291cmNlIGlzIHVwIHRvIGRhdGUuXG4gICAgICAgIGlmICh0aGlzLnNvdXJjZSkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzTG9hZGVkKCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNvdXJjZS5sb2FkKHRydWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgaXNMb2FkZWQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zb3VyY2UgJiYgdGhpcy5fc291cmNlLmlzTG9hZGVkKCk7XG4gICAgfVxuXG4gICAgZ2V0IGxvYWRFcnJvcigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXM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dHlwZSB7RnVuY3Rpb259XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLl9jYW5jZWxDYiA9IG51bGw7XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIExvYWRpbmcgc2luY2UgdGltZXN0YW1wIGluIG1pbGxpcy5cbiAgICAgICAgICogQHR5cGUge251bWJlcn1cbiAgICAgICAgICovXG4gICAgICAgIHRoaXMubG9hZGluZ1NpbmNlID0gMDtcblxuICAgICAgICB0aGlzLncgPSAwO1xuICAgICAgICB0aGlzLmggPSAwO1xuXG4gICAgICAgIHRoaXMuX25hdGl2ZVRleHR1cmUgPSBudWxsO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBJZiB0cnVlLCB0aGVuIHRoaXMudGV4dHVyZSBzb3VyY2UgaXMgbmV2ZXIgZnJlZWQgZnJvbSBtZW1vcnkgZHVyaW5nIGdhcmJhZ2UgY29sbGVjdGlvbi5cbiAgICAgICAgICogQHR5cGUge2Jvb2xlYW59XG4gICAgICAgICAqL1xuICAgICAgICB0aGlzLnBlcm1hbmVudCA9IGZhbHNlO1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBTdWItb2JqZWN0IHdpdGggdGV4dHVyZS1zcGVjaWZpYyByZW5kZXJpbmcgaW5mb3JtYXRpb24uXG4gICAgICAgICAqIEZvciBpbWFnZXMsIGNvbnRhaW5zIHRoZSBzcmMgcHJvcGVydHksIGZvciB0ZXh0cywgY29udGFpbnMgaGFuZHkgcmVuZGVyaW5nIGluZm9ybWF0aW9uLlxuICAgICAgICAgKiBAdHlwZSB7T2JqZWN0fVxuICAgICAgICAgKi9cbiAgICAgICAgdGhpcy5yZW5kZXJJbmZvID0gbnVsbDtcblxuICAgICAgICAvKipcbiAgICAgICAgICogR2VuZXJhdGVkIGZvciAncmVuZGVyVG9UZXh0dXJlJy5cbiAgICAgICAgICogQHR5cGUge2Jvb2xlYW59XG4gICAgICAgICAqIEBwcml2YXRlXG4gICAgICAgICAqL1xuICAgICAgICB0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1xuICAgICAgICByZXR1cm4gdGhpcy50ZXh0dXJlcy5zaXplID4gMDtcbiAgICB9XG5cbiAgICBmb3JFYWNoQWN0aXZlRWxlbWVudChjYikge1xuICAgICAgICB0aGlzLnRleHR1cmVzLmZvckVhY2godGV4dHVyZSA9PiB7XG4gICAgICAgICAgICB0ZXh0dXJlLmVsZW1lbnRzLmZvckVhY2goZWxlbWVudCA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgICAgIGNiKGVsZW1lbnQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cbiAgICBnZXRSZW5kZXJXaWR0aCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudztcbiAgICB9XG5cbiAgICBnZXRSZW5kZXJIZWlnaHQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmg7XG4gICAgfVxuXG4gICAgYWxsb3dDbGVhbnVwKCkge1xuICAgICAgICByZXR1cm4gIXRoaXMucGVybWFuZW50ICYmICF0aGlzLmlzVXNlZCgpO1xuICAgIH1cblxuICAgIGJlY29tZXNVc2VkKCkge1xuICAgICAgICAvLyBFdmVuIHdoaWxlIHRoZSB0ZXh0dXJlIGlzIGJlaW5nIGxvYWRlZCwgbWFrZSBzdXJlIGl0IGlzIG9uIHRoZSBsb29rdXAgbWFwIHNvIHRoYXQgb3RoZXJzIGNhbiByZXVzZSBpdC5cbiAgICAgICAgdGhpcy5sb2FkKCk7XG4gICAgfVxuXG4gICAgYmVjb21lc1VudXNlZCgpIHtcbiAgICAgICAgdGhpcy5jYW5jZWwoKTtcbiAgICB9XG5cbiAgICBjYW5jZWwoKSB7XG4gICAgICAgIGlmICh0aGlzLmlzTG9hZGluZygpKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fY2FuY2VsQ2IpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxDYih0a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gICB0aGlzLmxvYWRpbmdTaW5jZSA9IChuZXcgRGF0ZSgpKS5nZXRUaW1lKCk7XG4gICAgICAgICAgICB0aGlzLl9jYW5jZWxDYiA9IHRoaXMubG9hZGVyKChlcnIsIG9wdGlvbnMpID0+IHtcbiAgICAgICAgICAgICAgICAvLyBJZ25vcmUgbG9hZHMgdGhhdCBjb21lIGluIGFmdGVyIGEgY2FuY2VsLlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzTG9hZGluZygpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIENsZWFyIGNhbGxiYWNrIHRvIGF2b2lkIG1lbW9yeSBsZWFrcy5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FuY2VsQ2IgPSBudWxsO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hbmFnZXIuc3RhZ2UuZGVzdHJveWVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBJZ25vcmUgYXN5bmMgbG9hZCB3aGVuIHN0YWdlIGlzIGRlc3Ryb3llZC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBFbWl0IHR4RXJyb3IuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChvcHRpb25zICYmIG9wdGlvbnMuc291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuc3RhZ2UuaXNVcGRhdGluZ0ZyYW1lKCkgJiYgIWZvcmNlU3luYyAmJiAob3B0aW9ucy50aHJvdHRsZSAhPT0gZmFsc2UpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dHVyZVRocm90dGxlciA9IHRoaXMuc3RhZ2UudGV4dHVyZVRocm90dGxlcjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxDYiA9IHRleHR1cmVUaHJvdHRsZXIuZ2VuZXJpY0NhbmNlbENiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHR1cmVUaHJvdHRsZXIuYWRkKHRoaXMsIG9wdGlvbnMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NMb2FkZWRTb3VyY2Uob3B0aW9ucyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHByb2Nlc3NMb2FkZWRTb3VyY2Uob3B0aW9ucykge1xuICAgICAgICB0aGlzLmxvYWRpbmdTaW5jZSA9IDA7XG4gICAgICAgIHRoaXMuc2V0U291cmNlKG9wdGlvbnMpO1xuICAgIH1cblxuICAgIHNldFNvdXJjZShvcHRpb25zKSB7XG4gICAgICAgIGNvbnN0IHNvdXJjZSA9IG9wdGlvbnMuc291cmNlO1xuXG4gICAgICAgIHRoaXMuX2hhc0FscGhhID0gKG9wdGlvbnMgPyAob3B0aW9ucy5oYXNBbHBoYSB8fCBmYWxzZSkgOiBmYWxzZSk7XG4gICAgICAgIHRoaXMudyA9IHNvdXJjZS53aWR0aCB8fCAob3B0aW9ucyAmJiBvcHRpb25zLncpIHx8IDA7XG4gICAgICAgIHRoaXMuaCA9IHNvdXJjZS5oZWlnaHQgfHwgKG9wdGlvbnMgJiYgb3B0aW9ucy5oKSB8fCAwO1xuXG4gICAgICAgIGlmIChvcHRpb25zICYmIG9wdGlvbnMucmVuZGVySW5mbykge1xuICAgICAgICAgICAgLy8gQXNzaWduIHRvIGlkIGluIGNhY2hlIHNvIHRoYXQgaXQgY2FuIGJl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GgpO1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXRNb2R1bG9JbmRleChpbmRleCwgbGVuKSB7XG4gICAgICAgIGlmIChsZW4gPT09IDApIHJldHVybiBpbmRleDtcbiAgICAgICAgd2hpbGUgKGluZGV4IDwgMCkge1xuICAgICAgICAgICAgaW5kZXggKz0gTWF0aC5jZWlsKC1pbmRleCAvIGxlbikgKiBsZW47XG4gICAgICAgIH1cbiAgICAgICAgaW5kZXggPSBpbmRleCAlIGxlbjtcbiAgICAgICAgcmV0dXJuIGluZGV4O1xuICAgIH1cblxuICAgIHN0YXRpYyBnZXREZWVwQ2xvbmUob2JqKSB7XG4gICAgICAgIGxldCBpLCBjO1xuICAgICAgICBpZiAoVXRpbHMuaXNGdW5jdGlvbihvYmopKSB7XG4gICAgICAgICAgICAvLyBDb3B5IGZ1bmN0aW9ucyBieSByZWZlcmVuY2UuXG4gICAgICAgICAgICByZXR1cm4gb2JqO1xuICAgICAgICB9XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KG9iaikpIHtcbiAgICAgICAgICAgIGMgPSBbXTtcbiAgICAgICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBrZXlzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgY1trZXlzW2ldXSA9IFV0aWxzLmdldERlZXBDbG9uZShvYmpba2V5c1tpXV0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGM7XG4gICAgICAgIH0gZWxzZSBpZiAoVXRpbHMuaXNPYmplY3Qob2JqKSkge1xuICAgICAgICAgICAgYyA9IHt9XG4gICAgICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XG4gICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGNba2V5c1tpXV0gPSBVdGlscy5nZXREZWVwQ2xvbmUob2JqW2tleXNbaV1dKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBjO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIG9iajtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHN0YXRpYyBlcXVhbFZhbHVlcyh2MSwgdjIpIHtcbiAgICAgICAgaWYgKCh0eXBlb2YgdjEpICE9PSAodHlwZW9mIHYyKSkgcmV0dXJuIGZhbHNlO1xuICAgICAgICBpZiAoVXRpbHMuaXNPYmplY3RMaXRlcmFsKHYxKSkge1xuICAgICAgICAgICAgcmV0dXJuIFV0aWxzLmlzT2JqZWN0TGl0ZXJhbCh2MikgJiYgVXRpbHMuZXF1YWxPYmplY3RMaXRlcmFscyh2MSwgdjIpO1xuICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkodjEpKSB7XG4gICAgICAgICAgICByZXR1cm4gQXJyYXkuaXNBcnJheSh2MikgJiYgVXRpbHMuZXF1YWxBcnJheXModjEsIHYyKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB2MSA9PT0gdjI7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBzdGF0aWMgZXF1YWxPYmplY3RMaXRlcmFscyhvYmoxLCBvYmoyKSB7XG4gICAgICAgIGxldCBrZXlzMSA9IE9iamVjdC5rZXlzKG9iajEpO1xuICAgICAgICBsZXQga2V5czIgPSBPYmplY3Qua2V5cyhvYmoyKTtcbiAgICAgICAgaWYgKGtleXMxLmxlbmd0aCAhPT0ga2V5czIubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGtleXMxLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgY29uc3QgazEgPSBrZXlzMVtpXTtcbiAgICAgICAgICAgIGNvbnN0IGsyID0ga2V5czJbaV07XG4gICAgICAgICAgICBpZiAoazEgIT09IGsyKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCB2MSA9IG9iajFbazFdO1xuICAgICAgICAgICAgY29uc3QgdjIgPSBvYmoyW2syXTtcblxuICAgICAgICAgICAgaWYgKCFVdGlscy5lcXVhbFZhbHVlcyh2MSwgdjIpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgc3RhdGljIGVxdWFsQXJyYXlzKHYxLCB2Mikge1xuICAgICAgICBpZiAodjEubGVuZ3RoICE9PSB2Mi5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHYxLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmVxdWFsVmFsdWVzKHYxW2ldLCB2MltpXSkpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICBzdGF0aWMgc2V0VG9BcnJheShzKSB7XG4gICAgICAgIGxldCByZXN1bHQgPSBbXTtcbiAgICAgICAgcy5mb3JFYWNoKGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgcmVzdWx0LnB1c2godmFsdWUpO1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9XG5cbiAgICBzdGF0aWMgaXRlcmF0b3JUb0FycmF5KGl0ZXJhdG9yKSB7XG4gICAgICAgIGxldCByZXN1bHQgPSBbXTtcbiAgICAgICAgbGV0IGl0ZXJhdG9yUmVzdW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ICAgICAgLy8gKGJ1dCBub3QgcmVjdXJzaXZlbHkgdG8gcHJldmVudCBpbmZpbml0ZSBsb29wcykuXG4gICAgICAgIGlmICh0aGlzLnJvb3QuX2hhc1VwZGF0ZXMpIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZSgpO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fcGVyZm9ybUZvcmNlZFpTb3J0cygpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENlcnRhaW4gRWxlbWVudENvcmUgaXRlbXMgbWF5IGJlIGZvcmNlZCB0byB6U29ydCB0byBzdHJpcCBvdXQgcmVmZXJlbmNlcyB0byBwcmV2ZW50IG1lbWxlYWtzLi5cbiAgICAgKi9cbiAgICBfcGVyZm9ybUZvcmNlZFpTb3J0cygpIHtcbiAgICAgICAgY29uc3QgbiA9IHRoaXMuX3pTb3J0cy5sZW5ndGg7XG4gICAgICAgIGlmIChuKSB7XG4gICAgICAgICAgICAvLyBGb3JjZWQgei1zb3J0cyAoRWxlbWVudENvcmUgbWF5IGZvcmNlIGEgei1zb3J0IGluIG9yZGVyIHRvIGZyZWUgbWVtb3J5L3ByZXZlbnQgbWVtb3J5IGxlYWtzKS5cbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5felNvcnRzLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl96U29ydHNbaV0uelNvcnQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5felNvcnRzW2ldLnNvcnRaSW5kZXhlZENoaWxkcmVuKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5felNvcnRzID0gW107XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLnVwZGF0ZVRyZWVPcmRlciA9IDA7XG5cbiAgICAgICAgdGhpcy5yb290LnVwZGF0ZSgp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WRlciB8fCB0aGlzLl9zaGFkZXJPd25lciAhPT0gb3duZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9zaGFkZXIgPSBzaGFkZXI7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2hhZGVyT3duZXIgPSBvd25lcjtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGVjayA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgcmVuZGVyVGV4dHVyZUluZm8oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJUZXh0dXJlSW5mbztcbiAgICB9XG5cbiAgICBzZXRTY2lzc29yKGFyZWEpIHtcbiAgICAgICAgaWYgKHRoaXMuX3NjaXNzb3IgIT09IGFyZWEpIHtcbiAgICAgICAgICAgIGlmIChhcmVhKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IGFyZWE7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fY2hlY2sgPSB0cnVlO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0U2Npc3NvcigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NjaXNzb3I7XG4gICAgfVxuXG4gICAgc2V0UmVuZGVyVGV4dHVyZUluZm8ocmVuZGVyVGV4dHVyZUluZm8pIHtcbiAgICAgICAgaWYgKHRoaXMuX3JlbmRlclRleHR1cmVJbmZvICE9PSByZW5kZXJUZXh0dXJlSW5mbykge1xuICAgICAgICAgICAgdGhpcy5fcmVuZGVyVGV4dHVyZUluZm8gPSByZW5kZXJUZXh0dXJlSW5mbztcbiAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBudWxsO1xuICAgICAgICAgICAgdGhpcy5fY2hlY2sgPSB0cnVlO1xuICAgICAgICB9XG4gICAgfVxuXG4gICA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WFuY2UgYmVuZWZpdCB3aGVuIGZpbHRlcmluZyAoZmFzdCBibHVyKS5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGVtcG9yYXJ5VGV4dHVyaXplcnNbaV0ucmVsZWFzZVJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fdGVtcG9yYXJ5VGV4dHVyaXplcnMgPSBbXTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5fcXVhZE9wZXJhdGlvbiA9IG51bGw7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoY3JlYXRlKSB7XG4gICAgICAgICAgICB0aGlzLl9jcmVhdGVRdWFkT3BlcmF0aW9uKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfY3JlYXRlUXVhZE9wZXJhdGlvbigpIHtcbiAgICAgICAgdGhpcy5fcXVhZE9wZXJhdGlvbiA9IHRoaXMucmVuZGVyZXIuY3JlYXRlQ29yZVF1YWRPcGVyYXRpb24oXG4gICAgICAgICAgICB0aGlzLmN0eCxcbiAgICAgICAgICAgIHRoaXMuX3NoYWRlcixcbiAgICAgICAgICAgIHRoaXMuX3NoYWRlck93bmVyLFxuICAgICAgICAgICAgdGhpcy5fcmVuZGVyVGV4dHVyZUluZm8sXG4gICAgICAgICAgICB0aGlzLl9zY2lzc29yLFxuICAgICAgICAgICAgdGhpcy5sZW5ndGhcbiAgICAgICAgKTtcbiAgICAgICAgdGhpcy5fY2hlY2sgPSBmYWxzZTtcbiAgICB9XG5cbiAgICBmaW5pc2goKSB7XG4gICAgICAgIGlmICh0aGlzLl9xdWFkT3BlcmF0aW9uKSB7XG4gICAgICAgICAgICAvLyBBZGQgcmVtYWluaW5nLlxuICAgICAgICAgICAgdGhpcy5fZmluaXNoUXVhZE9wZXJhdGlvbihmYWxzZSk7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnJlbmRlcmVyLmZpbmlzaFJlbmRlclN0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NsaXBib3ggPSB0cnVlO1xuXG4gICAgICAgIHRoaXMucmVuZGVyID0gdGhpcy5fcmVuZGVyU2ltcGxlO1xuXG4gICAgICAgIHRoaXMuX2xheW91dCA9IG51bGw7XG4gICAgfVxuXG4gICAgZ2V0IG9mZnNldFgoKSB7XG4gICAgICAgIGlmICh0aGlzLl9mdW5jWCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Z1bmNYO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2xheW91dC5vcmlnaW5hbFg7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl94O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgc2V0IG9mZnNldFgodikge1xuICAgICAgICBpZiAoVXRpbHMuaXNGdW5jdGlvbih2KSkge1xuICAgICAgICAgICAgdGhpcy5mdW5jWCA9IHY7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9kaXNhYmxlRnVuY1goKTtcbiAgICAgICAgICAgIGlmICh0aGlzLmhhc0ZsZXhMYXlvdXQoKSkge1xuICAgICAgICAgICAgICAgIHRoaXMueCArPSAodiAtIHRoaXMuX2xheW91dC5vcmlnaW5hbFgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2xheW91dC5zZXRPcmlnaW5hbFhXaXRob3V0VXBkYXRpbmdMYXlvdXQodik7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMueCA9IHY7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgeCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3g7XG4gICAgfVxuXG4gICAgc2V0IHgodikge1xuICAgICAgICBpZiAodiAhPT0gdGhpcy5feCkge1x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0ZsZXhMYXlvdXQoKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9sYXlvdXQub3JpZ2luYWxZO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5feTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHNldCBvZmZzZXRZKHYpIHtcbiAgICAgICAgaWYgKFV0aWxzLmlzRnVuY3Rpb24odikpIHtcbiAgICAgICAgICAgIHRoaXMuZnVuY1kgPSB2O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZGlzYWJsZUZ1bmNZKCk7XG4gICAgICAgICAgICBpZiAodGhpcy5oYXNGbGV4TGF5b3V0KCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnkgKz0gKHYgLSB0aGlzLl9sYXlvdXQub3JpZ2luYWxZKTtcbiAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXQuc2V0T3JpZ2luYWxZV2l0aG91dFVwZGF0aW5nTGF5b3V0KHYpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLnkgPSB2O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHkoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl95O1xuICAgIH1cblxuICAgIHNldCB5KHYpIHtcbiAgICAgICAgaWYgKHYgIT09IHRoaXMuX3kpIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlRGVsdGEoMCwgdiAtIHRoaXMuX3kpO1xuICAgICAgICAgICAgdGhpcy5feSA9IHY7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgZnVuY1koKSB7XG4gICAgICAgIHJldHVybiAodGhpcy5fb3B0RmxhZ3MgJiAyID8gdGhpcy5fZnVuY1kgOiBudWxsKTtcbiAgICB9XG5cbiAgICBzZXQgZnVuY1kodikge1xuICAgICAgICBpZiAodGhpcy5fZnVuY1kgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX29wdEZsYWdzIHw9IDI7XG4gICAgICAgICAgICB0aGlzLl9mdW5jWSA9IHY7XG4gICAgICAgICAgICBpZiAodGhpcy5oYXNGbGV4TGF5b3V0KCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXQuc2V0T3JpZ2luYWxZV2l0aG91dFVwZGF0aW5nTGF5b3V0KDApO1xuICAgICAgICAgICAgICAgIHRoaXMubGF5b3V0LmZvcmNlTGF5b3V0KCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3kgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuX3RyaWdnZXJSZWNhbGNUcmFuc2xhdGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9kaXNhYmxlRnVuY1koKSB7XG4gICAgICAgIHRoaXMuX29wdEZsYWdzID0gdGhpcy5fb3B0RmxhZ3MgJiAoMHhGRkZGIC0gMik7XG4gICAgICAgIHRoaXMuX2Z1bmNZID0gbnVsbDtcbiAgICB9XG5cbiAgICBnZXQgZnVuY1coKSB7XG4gICAgICAgIHJldHVybiAodGhpcy5fb3B0RmxhZ3MgJiA0ID8gdGhpcy5fZnVuY1cgOiBudWxsKTtcbiAgICB9XG5cbiAgICBzZXQgZnVuY1codikge1xuICAgICAgICBpZiAodGhpcy5fZnVuY1cgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX29wdEZsYWdzIHw9IDQ7XG4gICAgICAgICAgICB0aGlzLl9mdW5jVyA9IHY7XG4gICAgICAgICAgICBpZiAodGhpcy5oYXNGbGV4TGF5b3V0KCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXQuX29yaWdpbmFsV2lkdGggPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMubGF5b3V0LmNoYW5nZWREaW1l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AodGhpcy5fcGl2b3RYICE9PSB2IHx8IHRoaXMuX3Bpdm90WSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fcGl2b3RYID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3Bpdm90WSA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IG1vdW50WCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21vdW50WDtcbiAgICB9XG5cbiAgICBzZXQgbW91bnRYKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX21vdW50WCAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fbW91bnRYID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZUxvY2FsVHJhbnNsYXRlKCk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBnZXQgbW91bnRZKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbW91bnRZO1xuICAgIH1cblxuICAgIHNldCBtb3VudFkodikge1xuICAgICAgICBpZiAodGhpcy5fbW91bnRZICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9tb3VudFkgPSB2O1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxUcmFuc2xhdGUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGdldCBtb3VudCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX21vdW50WDtcbiAgICB9XG5cbiAgICBzZXQgbW91bnQodikge1xuICAgICAgICBpZiAodGhpcy5fbW91bnRYICE9PSB2IHx8IHRoaXMuX21vdW50WSAhPT0gdikge1xuICAgICAgICAgICAgdGhpcy5fbW91bnRYID0gdjtcbiAgICAgICAgICAgIHRoaXMuX21vdW50WSA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zbGF0ZSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHJvdGF0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcm90YXRpb247XG4gICAgfVxuXG4gICAgc2V0IHJvdGF0aW9uKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3JvdGF0aW9uICE9PSB2KSB7XG4gICAgICAgICAgICB0aGlzLl9yb3RhdGlvbiA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbFRyYW5zZm9ybSgpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IGFscGhhKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fYWxwaGE7XG4gICAgfVxuXG4gICAgc2V0IGFscGhhKHYpIHtcbiAgICAgICAgLy8gQWNjb3VudCBmb3Igcm91bmRpbmcgZXJyb3JzLlxuICAgICAgICB2ID0gKHYgPiAxID8gMSA6ICh2IDwgMWUtMTQgPyAwIDogdikpO1xuICAgICAgICBpZiAodGhpcy5fYWxwaGEgIT09IHYpIHtcbiAgICAgICAgICAgIGxldCBwcmV2ID0gdGhpcy5fYWxwaGE7XG4gICAgICAgICAgICB0aGlzLl9hbHBoYSA9IHY7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVMb2NhbEFscGhhKCk7XG4gICAgICAgICAgICBpZiAoKHByZXYgPT09IDApICE9PSAodiA9PT0gMCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9lbGVtZW50Ll91cGRhdGVFbmFibGVkRmxhZygpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHZpc2libGUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl92aXNpYmxlO1xuICAgIH1cblxuICAgIHNldCB2aXNpYmxlKHYpIHtcbiAgICAgICAgaWYgKHRoaXMuX3Zpc2libGUgIT09IHYpIHtcbiAgICAgICAgICAgIHRoaXMuX3Zpc2libGUgPSB2O1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlTG9jYWxBbHBoYSgpO1xuICAgICAgICAgICAgdGhpcy5fZWxlbWVudC5fdXBkYXRlRW5hYmxlZEZsYWcoKTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuaGFzRmxleExheW91dCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5sYXlvdXQuc2V0VmlzaWJsZSh2KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIF91cGRhdGVMb2NhbFRyYW5zZm9ybSgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3JvdGF0aW9uICE9PSAwICYmIHRoaXMuX3JvdGF0aW9uICUgKDIgKiBNYXRoLlBJKSkge1xuICAgICAgICAgICAgLy8gY2hlY2sgdG8gc2VlIGlmIHRoZSByb3RhdGlvbiBpcyB0aGUgc2FtZSBhcyB0aGUgcHJldmlvdXMgcmVuZGVyLiBUaGlzIG1lYW5zIHdlIG9ubHkgbmVlZCB0byB1c2Ugc2luIGFuZCBjb3Mgd2hlbiByb3RhdGlvbiBhY3R1YWxseSBjaGFuZ2VzXG4gICAgICAgICAgICBsZXQgX3NyID0gTWF0aC5zaW4odGhpcy5fcm90YXRpb24pO1xuICAgICAgICAgICAgbGV0IF9jciA9IE1hdGguY29zKHRoaXMuX3JvdGF0aW9uKTtcblxuICAgICAgICAgICAgdGhpcy5fc2V0TG9jYWxUcmFuc2Zvcm0oXG4gICAgICAgICAgICAgICAgX2NyICogdGhpcy5fc2NhbGVYLFxuICAgICAgICAgICAgICAgIC1fc3IgKiB0aGlzLl9zY2FsZVksXG4gICAgICAgICAgICAgICAgX3NyICogdGhpcy5fc2NhbGVYLFxuICAgICAgICAgICAgICAgIF9jciAqIHRoaXMuX3NjYWxlWVxuICAgICAgICAgICAgKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3NldExvY2FsVHJhbnNmb3JtKFxuICAgICAgICAgICAgICAgIHRoaXMuX3NjYWxlWCxcbiAgICAgICAgICAgICAgICAwLFxuICAgICAgICAgICAgICAgIDAsXG4gICAgICAgICA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HBhcmVudCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChwcmV2UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgLy8gV2hlbiBlbGVtZW50cyBhcmUgZGVsZXRlZCwgdGhlIHJlbmRlciB0ZXh0dXJlIG11c3QgYmUgcmUtcmVuZGVyZWQuXG4gICAgICAgICAgICAgICAgcHJldlBhcmVudC5zZXRIYXNSZW5kZXJVcGRhdGVzKDMpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9zZXRSZWNhbGMoMSArIDIgKyA0KTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX3BhcmVudCkge1xuICAgICAgICAgICAgICAgIC8vIEZvcmNlIHBhcmVudCB0byBwcm9wYWdhdGUgaGFzVXBkYXRlcyBmbGFnLlxuICAgICAgICAgICAgICAgIHRoaXMuX3BhcmVudC5fc2V0SGFzVXBkYXRlcygpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fekluZGV4ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zZXRaUGFyZW50KHBhcmVudCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuc2V0WlBhcmVudChwYXJlbnQgPyBwYXJlbnQuZmluZFpDb250ZXh0KCkgOiBudWxsKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHByZXZJc1pDb250ZXh0ICE9PSB0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlWkNvbnRleHQoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZVpDb250ZXh0KHByZXZQYXJlbnQuZmluZFpDb250ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gVHJlZSBvcmRlciBkaWQgY2hhbmdlOiBldmVuIGlmIHpQYXJlbnQgc3RheXMgdGhlIHNhbWUsIHdlIG11c3QgcmVzb3J0LlxuICAgICAgICAgICAgdGhpcy5fekluZGV4UmVzb3J0ID0gdHJ1ZTtcbiAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoIXRoaXMuX3NoYWRlcikge1xuICAgICAgICAgICAgICAgIGxldCBuZXdTaGFkZXJPd25lciA9IHBhcmVudCAmJiAhcGFyZW50Ll9yZW5kZXJUb1RleHR1cmVFbmFibGVkID8gcGFyZW50Ll9zaGFkZXJPd25lciA6IG51bGw7XG4gICAgICAgICAgICAgICAgaWYgKG5ld1NoYWRlck93bmVyICE9PSB0aGlzLl9zaGFkZXJPd25lcikge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEhhc1JlbmRlclVwZGF0ZXMoMSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFNoYWRlck93bmVyUmVjdXJzaXZlKG5ld1NoYWRlck93bmVyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZW5hYmxlWlNvcnQoZm9yY2UgPSBmYWxzZSkge1xuICAgICAgICBpZiAoIXRoaXMuX3pTb3J0ICYmIHRoaXMuX3pDb250ZXh0VXNhZ2UgPiAwKSB7XG4gICAgICAgICAgICB0aGlzLl96U29ydCA9IHRydWU7XG4gICAgICAgICAgICBpZiAoZm9yY2UpIHtcbiAgICAgICAgICAgICAgICAvLyBaU29ydCBtdXN0IGJlIGRvbmUsIGV2ZW4gaWYgdGhpcyBlbGVtZW50IGlzIGludmlzaWJsZS5cbiAgICAgICAgICAgICAgICAvLyBU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SsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0uc2V0UGFyZW50KG51bGwpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl9jaGlsZHJlbi5zcGxpY2UoMCk7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl96SW5kZXhlZENoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5zcGxpY2UoMCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc3luY0NoaWxkcmVuKHJlbW92ZWQsIGFkZGVkLCBvcmRlcikge1xuICAgICAgICB0aGlzLl9jaGlsZHJlbiA9IG9yZGVyO1xuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHJlbW92ZWQubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICByZW1vdmVkW2ldLnNldFBhcmVudChudWxsKTtcbiAgICAgICAgfVxuICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IGFkZGVkLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgYWRkZWRbaV0uc2V0UGFyZW50KHRoaXMpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgbW92ZUNoaWxkKGZyb21JbmRleCwgdG9JbmRleCkge1xuICAgICAgICBsZXQgYyA9IHRoaXMuX2NoaWxkcmVuW2Zyb21JbmRleF07XG4gICAgICAgIHRoaXMuX2NoaWxkcmVuLnNwbGljZShmcm9tSW5kZXgsIDEpO1xuICAgICAgICB0aGlzLl9jaGlsZHJlbi5zcGxpY2UodG9JbmRleCwgMCwgYyk7XG5cbiAgICAgICAgLy8gVHJlZSBvcmRlciBjaGFuZ2VkOiBtdXN0IHJlc29ydCE7XG4gICAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICB0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MoMSArIDIgKyA0KTtcbiAgICB9O1xuXG4gICAgaXNBbmNlc3Rvck9mKGMpIHtcbiAgICAgICAgbGV0IHAgPSBjO1xuICAgICAgICB3aGlsZSAocCA9IHAuX3BhcmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMgPT09IHApIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfTtcblxuICAgIGlzWkNvbnRleHQoKSB7XG4gICAgICAgIHJldHVybiAodGhpcy5fZm9yY2VaSW5kZXhDb250ZXh0IHx8IHRoaXMuX3JlbmRlclRvVGV4dHVyZUVuYWJsZWQgfHwgdGhpcy5fekluZGV4ICE9PSAwIHx8IHRoaXMuX2lzUm9vdCB8fCAhdGhpcy5fcGFyZW50KTtcbiAgICB9O1xuXG4gICAgZmluZFpDb250ZXh0KCkge1xuICAgICAgICBpZiAodGhpcy5pc1pDb250ZXh0KCkpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhcmVudC5maW5kWkNvbnRleHQoKTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBzZXRaUGFyZW50KG5ld1pQYXJlbnQpIHtcbiAgICAgICAgaWYgKHRoaXMuX3pQYXJlbnQgIT09IG5ld1pQYXJlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50ICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmRlY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBXZSBtdXN0IGZpbHRlciBvdXQgdGhpcyBpdGVtIHVwb24gdGhlIG5leHQgcmVzb3J0LlxuICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKG5ld1pQYXJlbnQgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICBsZXQgaGFkWkNvbnRleHRVc2FnZSA9IChuZXdaUGFyZW50Ll96Q29udGV4dFVzYWdlID4gMCk7XG5cbiAgICAgICAgICAgICAgICAvLyBAcHJlOiBuZXcgcGFyZW50J3MgY2hpbGRyZW4gYXJyYXkgaGFzIGFscmVhZHkgYmVlbiBtb2RpZmllZC5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIG5ld1pQYXJlbnQuaW5jWkNvbnRleHRVc2FnZSgpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChuZXdaUGFyZW50Ll96Q29udGV4dFVzYWdlID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIWhhZFpDb250ZXh0VXNhZ2UgJiYgKHRoaXMuX3BhcmVudCA9PT0gbmV3WlBhcmVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRoaXMgY2hpbGQgd2FzIGFscmVhZHkgaW4gdGhlIGNoaWxkcmVuIGxpc3QuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBEbyBub3QgYWRkIGRvdWJsZS5cbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEFkZCBuZXcgY2hpbGQgdG8gYXJyYXkuXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdaUGFyZW50Ll96SW5kZXhlZENoaWxkcmVuLnB1c2godGhpcyk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAvLyBPcmRlciBzaG91bGQgYmUgY2hlY2tlZC5cbiAgICAgICAgICAgICAgICAgICAgbmV3WlBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5felBhcmVudCA9IG5ld1pQYXJlbnQ7XG5cbiAgICAgICAgICAgIC8vIE5ld2x5IGFkZGVkIGVsZW1lbnQgbXVzdCBiZSBtYXJrZWQgZm9yIHJlc29ydC5cbiAgICAgICAgICAgIHRoaXMuX3pJbmRleFJlc29ydCA9IHRydWU7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgaW5jWkNvbnRleHRVc2FnZSgpIHtcbiAgICAgICAgdGhpcy5fekNvbnRleHRVc2FnZSsrO1xuICAgICAgICBpZiAodGhpcy5fekNvbnRleHRVc2FnZSA9PT0gMSkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLl96SW5kZXhlZENoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbiA9IFtdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgLy8gQ29weS5cbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl96SW5kZXhlZENoaWxkcmVuLnB1c2godGhpcy5fY2hpbGRyZW5baV0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAvLyBJbml0aWFsbHksIGNoaWxkcmVuIGFyZSBhbHJlYWR5IHNvcnRlZCBwcm9wZXJseSAodHJlZSBvcmRlcikuXG4gICAgICAgICAgICAgICAgdGhpcy5felNvcnQgPSBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBkZWNaQ29udGV4dFVzYWdlKCkge1xuICAgICAgICB0aGlzLl96Q29udGV4dFVzYWdlLS07XG4gICAgICAgIGlmICh0aGlzLl96Q29udGV4dFVzYWdlID09PSAwKSB7XG4gICAgICAgICAgICB0aGlzLl96U29ydCA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbi5zcGxpY2UoMCk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZ2V0IHpJbmRleCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3pJbmRleDtcbiAgICB9XG5cbiAgICBzZXQgekluZGV4KHpJbmRleCkge1xuICAgICAgICBpZiAodGhpcy5fekluZGV4ICE9PSB6SW5kZXgpIHtcbiAgICAgICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcygxKTtcblxuICAgICAgICAgICAgbGV0IG5ld1pQYXJlbnQgPSB0aGlzLl96UGFyZW50O1xuXG4gICAgICAgICAgICBsZXQgcHJldklzWkNvbnRleHQgPSB0aGlzLmlzWkNvbnRleHQoKTtcbiAgICAgICAgICAgIGlmICh6SW5kZXggPT09IDAgJiYgdGhpcy5fekluZGV4ICE9PSAwKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3BhcmVudCA9PT0gdGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5kZWNaQ29udGV4dFVzYWdlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBuZXdaUGFyZW50ID0gdGhpcy5fcGFyZW50O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoekluZGV4ICE9PSAwICYmIHRoaXMuX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgICAgIG5ld1pQYXJlbnQgPSB0aGlzLl9wYXJlbnQgPyB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkgOiBudWxsO1xuICAgICAgICAgICAgICAgIGlmIChuZXdaUGFyZW50ID09PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl96UGFyZW50LmluY1pDb250ZXh0VXNhZ2UoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoekluZGV4ICE9PSB0aGlzLl96SW5kZXgpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5felBhcmVudCAmJiB0aGlzLl96UGFyZW50Ll96Q29udGV4dFVzYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3pQYXJlbnQuZW5hYmxlWlNvcnQoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChuZXdaUGFyZW50ICE9PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zZXRaUGFyZW50KG51bGwpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLl96SW5kZXggPSB6SW5kZXg7XG5cbiAgICAgICAgICAgIGlmIChuZXdaUGFyZW50ICE9PSB0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zZXRaUGFyZW50KG5ld1pQYXJlbnQpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocHJldklzWkNvbnRleHQgIT09IHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmRpc2FibGVaQ29udGV4dCgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlWkNvbnRleHQodGhpcy5fcGFyZW50LmZpbmRaQ29udGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIE1ha2Ugc3VyZSB0aGF0IHJlc29ydCBpcyBkb25lLlxuICAgICAgICAgICAgdGhpcy5fekluZGV4UmVzb3J0ID0gdHJ1ZTtcbiAgICAgICAgICAgIGlmICh0aGlzLl96UGFyZW50KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5felBhcmVudC5lbmFibGVaU29ydCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIGdldCBmb3JjZVpJbmRleENvbnRleHQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9mb3JjZVpJbmRleENvbnRleHQ7XG4gICAgfVxuXG4gICAgc2V0IGZvcmNlWkluZGV4Q29udGV4dCh2KSB7XG4gICAgICAgIHRoaXMuc2V0SGFzUmVuZGVyVXBkYXRlcygxKTtcblxuICAgICAgICBsZXQgcHJldklzWkNvbnRleHQgPSB0aGlzLmlzWkNvbnRleHQoKTtcbiAgICAgICAgdGhpcy5fZm9yY2VaSW5kZXhDb250ZXh0ID0gdjtcblxuICAgICAgICBpZiAocHJldklzWkNvbnRleHQgIT09IHRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuaXNaQ29udGV4dCgpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlWkNvbnRleHQoKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5lbmFibGVaQ29udGV4dCh0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIGVuYWJsZVpDb250ZXh0KHByZXZaQ29udGV4dCkge1xuICAgICAgICBpZiAocHJldlpDb250ZXh0ICYmIHByZXZaQ29udGV4dC5fekNvbnRleHRVc2FnZSA+IDApIHtcbiAgICAgICAgICAgIC8vIFRyYW5zZmVyIGZyb20gdXBwZXIgeiBjb250ZXh0IHRvIHRoaXMgeiBjb250ZXh0LlxuICAgICAgICAgICAgY29uc3QgcmVzdWx0cyA9IHRoaXMuX2dldFpJbmRleGVkRGVzY3MoKTtcbiAgICAgICAgICAgIHJlc3VsdHMuZm9yRWFjaCgoYykgPT4ge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQW5jZXN0b3JPZihjKSAmJiBjLl96SW5kZXggIT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgYy5zZXRaUGFyZW50KHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgX2dldFpJbmRleGVkRGVzY3MoKSB7XG4gICAgICAgIGNvbnN0IHJlc3VsdHMgPSBbXTtcbiAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLl9nZXRaSW5kZXhlZERlc2NzUmVjKHJlc3VsdHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHRzO1xuICAgIH1cblxuICAgIF9nZXRaSW5kZXhlZERlc2NzUmVjKHJlc3VsdHMpIHtcbiAgICAgICAgaWYgKHRoaXMuX3pJbmRleCkge1xuICAgICAgICAgICAgcmVzdWx0cy5wdXNoKHRoaXMpO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2NoaWxkcmVuICYmICF0aGlzLmlzWkNvbnRleHQoKSkge1xuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS5fZ2V0WkluZGV4ZWREZXNjc1JlYyhyZXN1bHRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIGRpc2FibGVaQ29udGV4dCgpIHtcbiAgICAgICAgLy8gVHJhbnNmZXIgZnJvbSB0aGlzIHogY29udGV4dCB0byB1cHBlciB6IGNvbnRleHQuXG4gICAgICAgIGlmICh0aGlzLl96Q29udGV4dFVzYWdlID4gMCkge1xuICAgICAgICAgICAgbGV0IG5ld1pQYXJlbnQgPSB0aGlzLl9wYXJlbnQuZmluZFpDb250ZXh0KCk7XG5cbiAgICAgICAgICAgIC8vIE1ha2Ugc3VyZSB0aGF0IHotaW5kZXhlZCBjaGlsZHJlbiBhcmUgdXAgdG8gZGF0ZSAob2xkIG9uZXMgcmVtb3ZlZCkuXG4gICAgICAgICAgICBpZiAodGhpcy5felNvcnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNvcnRaSW5kZXhlZENoaWxkcmVuKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX3pJbmRleGVkQ2hpbGRyZW4uc2xpY2UoKS5mb3JFYWNoKGZ1bmN0aW9uIChjKSB7XG4gICAgICAgICAgICAgICAgaWYgKGMuX3pJbmRleCAhPT0gMCkge1xuICAgICAgICAgICAgICAgICAgICBjLnNldFpQYXJlbnQobmV3WlBhcmVudCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgZ2V0IGNvbG9yVWwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jb2xvclVsO1xuICAgIH1cblxuICAgIHNldCBjb2xvclVsKGNvbG9yKSB7XG4gICAgICAgIGlmICh0aGlzLl9jb2xvclVsICE9PSB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gYyA9IHRoaXMuX2NoaWxkcmVuW2ldO1xuICAgICAgICAgICAgICAgIGlmICghYy5fc2hhZGVyKSB7XG4gICAgICAgICAgICAgICAgICAgIGMuX3NldFNoYWRlck93bmVyUmVjdXJzaXZlKGVsZW1lbnRDb3JlKTtcbiAgICAgICAgICAgICAgICAgICAgYy5faGFzUmVuZGVyVXBkYXRlcyA9IDM7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIF9oYXNSZW5kZXJDb250ZXh0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyQ29udGV4dCAhPT0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgIH1cblxuICAgIGdldCByZW5kZXJDb250ZXh0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyQ29udGV4dDtcbiAgICB9XG5cbiAgICB1cGRhdGVSZW5kZXJUb1RleHR1cmVFbmFibGVkKCkge1xuICAgICAgICAvLyBFbmZvcmNlIHRleHR1cml6ZXIgaW5pdGlhbGlzYXRpb24uXG4gICAgICAgIGxldCB2ID0gdGhpcy50ZXh0dXJpemVyLl9lbmFibGVkO1xuXG4gICAgICAgIGlmICh2KSB7XG4gICAgICAgICAgICB0aGlzLl9lbmFibGVSZW5kZXJUb1RleHR1cmUoKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSZW5kZXJUb1RleHR1cmUoKTtcbiAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZVJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIF9lbmFibGVSZW5kZXJUb1RleHR1cmUoKSB7XG4gICAgICAgIGlmICghdGhpcy5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCkge1xuICAgICAgICAgICAgbGV0IHByZXZJc1pDb250ZXh0ID0gdGhpcy5pc1pDb250ZXh0KCk7XG5cbi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wZGF0ZSBhbGwgYWxwaGEgdmFsdWVzKVxuICAgICAgICAgKi9cbiAgICAgICAgaWYgKHRoaXMuX2hhc1VwZGF0ZXMgfHwgKHRoaXMuX3JlY2FsYyAmJiB2aXNpYmxlKSB8fCAody5hbHBoYSAmJiAhdmlzaWJsZSkpIHtcbiAgICAgICAgICAgIGxldCByZWNhbGMgPSB0aGlzLl9yZWNhbGM7XG5cbiAgICAgICAgICAgIC8vIFVwZGF0ZSB3b3JsZCBjb29yZHMvYWxwaGEuXG4gICAgICAgICAgICBpZiAocmVjYWxjICYgMSkge1xuICAgICAgICAgICAgICAgIGlmICghdy5hbHBoYSAmJiB2aXNpYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEJlY29tZXMgdmlzaWJsZS5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5faGFzUmVuZGVyVXBkYXRlcyA9IDM7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHcuYWxwaGEgPSBwdy5hbHBoYSAqIHRoaXMuX2xvY2FsQWxwaGE7XG5cbiAgICAgICAgICAgICAgICBpZiAody5hbHBoYSA8IDFlLTE0KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFRpbnkgcm91bmRpbmcgZXJyb3JzIG1heSBjYXVzZSBmYWlsaW5nIHZpc2liaWxpdHkgdGVzdHMuXG4gICAgICAgICAgICAgICAgICAgIHcuYWxwaGEgPSAwO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHJlY2FsYyAmIDYpIHtcbiAgICAgICAgICAgICAgICB3LnB4ID0gcHcucHggKyB0aGlzLl9sb2NhbFB4ICogcHcudGE7XG4gICAgICAgICAgICAgICAgdy5weSA9IHB3LnB5ICsgdGhpcy5fbG9jYWxQeSAqIHB3LnRkO1xuICAgICAgICAgICAgICAgIGlmIChwdy50YiAhPT0gMCkgdy5weCArPSB0aGlzLl9sb2NhbFB5ICogcHcudGI7XG4gICAgICAgICAgICAgICAgaWYgKHB3LnRjICE9PSAwKSB3LnB5ICs9IHRoaXMuX2xvY2FsUHggKiBwdy50YztcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHJlY2FsYyAmIDQpIHtcbiAgICAgICAgICAgICAgICB3LnRhID0gdGhpcy5fbG9jYWxUYSAqIHB3LnRhO1xuICAgICAgICAgICAgICAgIHcudGIgPSB0aGlzLl9sb2NhbFRkICogcHcudGI7XG4gICAgICAgICAgICAgICAgdy50YyA9IHRoaXMuX2xvY2FsVGEgKiBwdy50YztcbiAgICAgICAgICAgICAgICB3LnRkID0gdGhpcy5fbG9jYWxUZCAqIHB3LnRkO1xuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzQ29tcGxleCkge1xuICAgICAgICAgICAgICAgICAgICB3LnRhICs9IHRoaXMuX2xvY2FsVGMgKiBwdy50YjtcbiAgICAgICAgICAgICAgICAgICAgdy50YiArPSB0aGlzLl9sb2NhbFRiICogcHcudGE7XG4gICAgICAgICAgICAgICAgICAgIHcudGMgKz0gdGhpcy5fbG9jYWxUYyAqIHB3LnRkO1xuICAgICAgICAgICAgICAgICAgICB3LnRkICs9IHRoaXMuX2xvY2FsVGIgKiBwdy50YztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIFVwZGF0ZSByZW5kZXIgY29vcmRzL2FscGhhLlxuICAgICAgICAgICAgY29uc3QgcHIgPSB0aGlzLl9wYXJlbnQuX3JlbmRlckNvbnRleHQ7XG4gICAgICAgICAgICBpZiAodGhpcy5fcGFyZW50Ll9oYXNSZW5kZXJDb250ZXh0KCkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBpbml0ID0gdGhpcy5fcmVuZGVyQ29udGV4dCA9PT0gdGhpcy5fd29ybGRDb250ZXh0O1xuICAgICAgICAgICAgICAgIGlmIChpbml0KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZpcnN0IHJlbmRlciBjb250ZXh0IGJ1aWxkOiBtYWtlIHN1cmUgdGhhdCBpdCBpcyBmdWxseSBpbml0aWFsaXplZCBjb3JyZWN0bHkuXG4gICAgICAgICAgICAgICAgICAgIC8vIE90aGVyd2lzZSwgaWYgd2UgZ2V0IGludG8gYm91bmRzIGxhdGVyLCB0aGUgcmVuZGVyIGNvbnRleHQgd291bGQgbm90IGJlIGluaXRpYWxpemVkIGNvcnJlY3RseS5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IG5ldyBFbGVtZW50Q29yZUNvbnRleHQoKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBjb25zdCByID0gdGhpcy5fcmVuZGVyQ29udGV4dDtcblxuICAgICAgICAgICAgICAgIC8vIFVwZGF0ZSB3b3JsZCBjb29yZHMvYWxwaGEuXG4gICAgICAgICAgICAgICAgaWYgKGluaXQgfHwgKHJlY2FsYyAmIDEpKSB7XG4gICAgICAgICAgICAgICAgICAgIHIuYWxwaGEgPSBwci5hbHBoYSAqIHRoaXMuX2xvY2FsQWxwaGE7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHIuYWxwaGEgPCAxZS0xNCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgci5hbHBoYSA9IDA7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoaW5pdCB8fCAocmVjYWxjICYgNikpIHtcbiAgICAgICAgICAgICAgICAgICAgci5weCA9IHByLnB4ICsgdGhpcy5fbG9jYWxQeCAqIHByLnRhO1xuICAgICAgICAgICAgICAgICAgICByLnB5ID0gcHIucHkgKyB0aGlzLl9sb2NhbFB5ICogcHIudGQ7XG4gICAgICAgICAgICAgICAgICAgIGlmIChwci50YiAhPT0gMCkgci5weCArPSB0aGlzLl9sb2NhbFB5ICogcHIudGI7XG4gICAgICAgICAgICAgICAgICAgIGlmIChwci50YyAhPT0gMCkgci5weSArPSB0aGlzLl9sb2NhbFB4ICogcHIudGM7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGluaXQpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gV2Ugc2V0IHRoZSByZWNhbGMgdG9nZ2xlLCBiZWNhdXNlIHdlIG11c3QgbWFrZSBzdXJlIHRoYXQgdGhlIHNjaXNzb3IgaXMgdXBkYXRlZC5cbiAgICAgICAgICAgICAgICAgICAgcmVjYWxjIHw9IDI7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGluaXQgfHwgKHJlY2FsYyAmIDQpKSB7XG4gICAgICAgICAgICAgICAgICAgIHIudGEgPSB0aGlzLl9sb2NhbFRhICogcHIudGE7XG4gICAgICAgICAgICAgICAgICAgIHIudGIgPSB0aGlzLl9sb2NhbFRkICogcHIudGI7XG4gICAgICAgICAgICAgICAgICAgIHIudGMgPSB0aGlzLl9sb2NhbFRhICogcHIudGM7XG4gICAgICAgICAgICAgICAgICAgIHIudGQgPSB0aGlzLl9sb2NhbFRkICogcHIudGQ7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzQ29tcGxleCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgci50YSArPSB0aGlzLl9sb2NhbFRjICogcHIudGI7XG4gICAgICAgICAgICAgICAgICAgICAgICByLnRiICs9IHRoaXMuX2xvY2FsVGIgKiBwci50YTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHIudGMgKz0gdGhpcy5fbG9jYWxUYyAqIHByLnRkO1xuICAgICAgICAgICAgICAgICAgICAgICAgci50ZCArPSB0aGlzLl9sb2NhbFRiICogcHIudGM7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSB0aGlzLl93b3JsZENvbnRleHQ7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLmN0eC51cGRhdGVUcmVlT3JkZXIgPT09IC0xKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyID0gdGhpcy5fdXBkYXRlVHJlZU9yZGVyICsgMTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlVHJlZU9yZGVyID0gdGhpcy5jdHgudXBkYXRlVHJlZU9yZGVyKys7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIERldGVybWluZSB3aGV0aGVyIHdlIG11c3QgdXNlIGEgJ3JlbmRlclRleHR1cmUnLlxuICAgICAgICAgICAgY29uc3QgdXNlUmVuZGVyVG9UZXh0dXJlID0gdGhpcy5fcmVuZGVyVG9UZXh0dXJlRW5hYmxlZCAmJiB0aGlzLl90ZXh0dXJpemVyLm11c3RSZW5kZXJUb1RleHR1cmUoKTtcbiAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUgIT09IHVzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgIC8vIENvb3JkcyBtdXN0IGJlIGNoYW5nZWQuXG4gICAgICAgICAgICAgICAgdGhpcy5fcmVjYWxjIHw9IDIgKyA0O1xuXG4gICAgICAgICAgICAgICAgLy8gU2Npc3NvciBtYXkgY2hhbmdlOiBmb3JjZSB1cGRhdGUuXG4gICAgICAgICAgICAgICAgcmVjYWxjIHw9IDI7XG5cbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBXZSBtdXN0IHJlbGVhc2UgdGhlIHRleHR1cmUuXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSA9IHVzZVJlbmRlclRvVGV4dHVyZTtcblxuICAgICAgICAgICAgY29uc3QgciA9IHRoaXMuX3JlbmRlckNvbnRleHQ7XG5cbiAgICAgICAgICAgIGNvbnN0IGJib3hXID0gdGhpcy5fZGltc1Vua25vd24gPyAyMDQ4IDogdGhpcy5fdztcbiAgICAgICAgICAgIGNvbnN0IGJib3hIID0gdGhpcy5fZGltc1Vua25vd24gPyAyMDQ4IDogdGhpcy5faDtcblxuICAgICAgICAgICAgLy8gQ2FsY3VsYXRlIGEgYmJveCBmb3IgdGhpcyBlbGVtZW50LlxuICAgICAgICAgICAgbGV0IHN4LCBzeSwgZXgsIGV5O1xuICAgICAgICAgICAgY29uc3QgckNvbXBsZXggPSAoci50YiAhPT0gMCkgfHwgKHIudGMgIT09IDApIHx8IChyLnRhIDwgMCkgfHwgKHIudGQgPCAwKTtcbiAgICAgICAgICAgIGlmIChyQ29tcGxleCkge1xuICAgICAgICAgICAgICAgIHN4ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgICAgIGV4ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgICAgIHN5ID0gTWF0aC5taW4oMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgICAgICAgIGV5ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRjLCBiYm94VyAqIHIudGMgKyBiYm94SCAqIHIudGQsIGJib3hIICogci50ZCkgKyByLnB5O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzeCA9IHIucHg7XG4gICAgICAgICAgICAgICAgZXggPSByLnB4ICsgci50YSAqIGJib3hXO1xuICAgICAgICAgICAgICAgIHN5ID0gci5weTtcbiAgICAgICAgICAgICAgICBleSA9IHIucHkgKyByLnRkICogYmJveEg7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9kaW1zVW5rbm93biAmJiAockNvbXBsZXggfHwgdGhpcy5fbG9jYWxUYSA8IDEgfHwgdGhpcy5fbG9jYWxUYiA8IDEpKSB7XG4gICAgICAgICAgICAgICAgLy8gSWYgd2UgYXJlIGRlYWxpbmcgd2l0aCBhIG5vbi1pZGVudGl0eSBtYXRyaXgsIHdlIG11c3QgZXh0ZW5kIHRoZSBiYm94IHNvIHRoYXQgd2l0aGluQm91bmRzIGFuZFxuICAgICAgICAgICAgICAgIC8vICBzY2lzc29ycyB3aWxsIGluY2x1ZGUgdGhlIGNvbXBsZXRlIHJhbmdlIG9mIChwb3NpdGl2ZSkgZGltZW5zaW9ucyB1cCB0byAsbGguXG4gICAgICAgICAgICAgICAgY29uc3QgbnggPSB0aGlzLl94ICogcHIudGEgKyB0aGlzLl95ICogcHIudGIgKyBwci5weDtcbiAgICAgICAgICAgICAgICBjb25zdCBueSA9IHRoaXMuX3ggKiBwci50YyArIHRoaXMuX3kgKiBwci50ZCArIHByLnB5O1xuICAgICAgICAgICAgICAgIGlmIChueCA8IHN4KSBzeCA9IG54O1xuICAgICAgICAgICAgICAgIGlmIChueSA8IHN5KSBzeSA9IG55O1xuICAgICAgICAgICAgICAgIGlmIChueCA+IGV4KSBleCA9IG54O1xuICAgICAgICAgICAgICAgIGlmIChueSA+IGV5KSBleSA9IG55O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocmVjYWxjICYgNiB8fCAhdGhpcy5fc2Npc3NvciAvKiBpbml0aWFsICovKSB7XG4gICAgICAgICAgICAgICAgLy8gRGV0ZXJtaW5lIHdoZXRoZXIgd2UgbXVzdCAnY2xpcCcuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NsaXBwaW5nICYmIHIuaXNTcXVhcmUoKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBJZiB0aGUgcGFyZW50IHJlbmRlcnMgdG8gYSB0ZXh0dXJlLCBpdCdzIHNjaXNzb3Igc2hvdWxkIGJlIGlnbm9yZWQ7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZWEgPSB0aGlzLl9wYXJlbnQuX3VzZVJlbmRlclRvVGV4dHVyZSA/IHRoaXMuX3BhcmVudC5fdmlld3BvcnQgOiB0aGlzLl9wYXJlbnQuX3NjaXNzb3I7XG4gICAgICAgICAgICAgICAgICAgIGlmIChhcmVhKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBNZXJnZSBzY2lzc29yIGFyZWFzLlxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbHggPSBNYXRoLm1heChhcmVhWzBdLCBzeCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBseSA9IE1hdGgubWF4KGFyZWFbMV0sIHN5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBbXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbHgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbHksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgTWF0aC5taW4oYXJlYVsyXSArIGFyZWFbMF0sIGV4KSAtIGx4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWluKGFyZWFbM10gKyBhcmVhWzFdLCBleSkgLSBseVxuICAgICAgICAgICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaXNzb3IgPSBbc3gsIHN5LCBleCAtIHN4LCBleSAtIHN5XTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIE5vIGNsaXBwaW5nOiByZXVzZSBwYXJlbnQgc2Npc3Nvci5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2Npc3NvciA9IHRoaXMuX3BhcmVudC5fdXNlUmVuZGVyVG9UZXh0dXJlID8gdGhpcy5fcGFyZW50Ll92aWV3cG9ydCA6IHRoaXMuX3BhcmVudC5fc2Npc3NvcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIENhbGN1bGF0ZSB0aGUgb3V0T2ZCb3VuZHMgbWFyZ2luLlxuICAgICAgICAgICAgaWYgKHRoaXMuX2JvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICAgIHRoaXMuX3JlY0JvdW5kc01hcmdpbiA9IHRoaXMuX2JvdW5kc01hcmdpbjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fcmVjQm91bmRzTWFyZ2luID0gdGhpcy5fcGFyZW50Ll9yZWNCb3VuZHNNYXJnaW47XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9vbkFmdGVyQ2FsY3MpIHtcbiAgICAgICAgICAgICAgICAvLyBBZnRlciBjYWxjcyBtYXkgY2hhbmdlIHJlbmRlciBjb29yZHMsIHNjaXNzb3IgYW5kL29yIHJlY0JvdW5kc01hcmdpbi5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fb25BZnRlckNhbGNzKHRoaXMuZWxlbWVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gUmVjYWxjdWxhdGUgYmJveC5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHJDb21wbGV4KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzeCA9IE1hdGgubWluKDAsIGJib3hXICogci50YSwgYmJveFcgKiByLnRhICsgYmJveEggKiByLnRiLCBiYm94SCAqIHIudGIpICsgci5weDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4ID0gTWF0aC5tYXgoMCwgYmJveFcgKiByLnRhLCBiYm94VyAqIHIudGEgKyBiYm94SCAqIHIudGIsIGJib3hIICogci50YikgKyByLnB4O1xuICAgICAgICAgICAgICAgICAgICAgICAgc3kgPSBNYXRoLm1pbigwLCBiYm94VyAqIHIudGMsIGJib3hXICogci50YyArIGJib3hIICogci50ZCwgYmJveEggKiByLnRkKSArIHIucHk7XG4gICAgICAgICAgICAgICAgICAgICAgICBleSA9IE1hdGgubWF4KDAsIGJib3hXICogci50YywgYmJveFcgKiByLnRjICsgYmJveEggKiByLnRkLCBiYm94SCAqIHIudGQpICsgci5weTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN4ID0gci5weDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4ID0gci5weCArIHIudGEgKiBiYm94VztcbiAgICAgICAgICAgICAgICAgICAgICAgIHN5ID0gci5weTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV5ID0gci5weSArIHIudGQgKiBiYm94SDtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kaW1zVW5rbm93biAmJiAockNvbXBsZXggfHwgdGhpcy5fbG9jYWxUYSA8IDEgfHwgdGhpcy5fbG9jYWxUYiA8IDEpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBueCA9IHRoaXMuX3ggKiBwci50YSArIHRoaXMuX3kgKiBwci50YiArIHByLnB4O1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbnkgPSB0aGlzLl94ICogcHIudGMgKyB0aGlzLl95ICogcHIudGQgKyBwci5weTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChueCA8IHN4KSBzeCA9IG54O1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG55IDwgc3kpIHN5ID0gbnk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobnggPiBleCkgZXggPSBueDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChueSA+IGV5KSBleSA9IG55O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fcGFyZW50Ll9vdXRPZkJvdW5kcyA9PT0gMikge1xuICAgICAgICAgICAgICAgIC8vIEluaGVyaXQgcGFyZW50IG91dCBvZiBib3VuZHNuZXNzLlxuICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLl93aXRoaW5Cb3VuZHNNYXJnaW4pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fd2l0aGluQm91bmRzTWFyZ2luID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZGlzYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHJlY2FsYyAmIDYpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gUmVjaGVjayBpZiBlbGVtZW50IGlzIG91dC1vZi1ib3VuZHMgKGFsbCBzZXR0aW5ncyB0aGF0IGFmZmVjdCB0aGlzIHNob3VsZCBlbmFibGUgcmVjYWxjIGJpdCAyIG9yIDQpLlxuICAgICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDA7XG4gICAgICAgICAgICAgICAgICAgIGxldCB3aXRoaW5NYXJnaW4gPSB0cnVlO1xuXG4gICAgICAgICAgICAgICAgICAgIC8vIE9mZnNjcmVlbnMgYXJlIGFsd2F5cyByZW5kZXJlZCBhcyBsb25nIGFzIHRoZSBwYXJlbnQgaXMgd2l0aGluIGJvdW5kcy5cbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZW5kZXJUb1RleHR1cmVFbmFibGVkIHx8ICF0aGlzLl90ZXh0dXJpemVyIHx8ICF0aGlzLl90ZXh0dXJpemVyLnJlbmRlck9mZnNjcmVlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3NjaXNzb3IgJiYgKHRoaXMuX3NjaXNzb3JbMl0gPD0gMCB8fCB0aGlzLl9zY2lzc29yWzNdIDw9IDApKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gRW1wdHkgc2Npc3NvciBhcmVhLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVXNlIGJib3ggdG8gY2hlY2sgb3V0LW9mLWJvdW5kbmVzcy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHRoaXMuX3NjaXNzb3JbMF0gPiBleCkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHRoaXMuX3NjaXNzb3JbMV0gPiBleSkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN4ID4gKHRoaXMuX3NjaXNzb3JbMF0gKyB0aGlzLl9zY2lzc29yWzJdKSkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN5ID4gKHRoaXMuX3NjaXNzb3JbMV0gKyB0aGlzLl9zY2lzc29yWzNdKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3V0T2ZCb3VuZHMgPSAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9vdXRPZkJvdW5kcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2xpcHBpbmcgfHwgdGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlIHx8ICh0aGlzLl9jbGlwYm94ICYmIChiYm94VyAmJiBiYm94SCkpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vdXRPZkJvdW5kcyA9IDI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHdpdGhpbk1hcmdpbiA9ICh0aGlzLl9vdXRPZkJvdW5kcyA9PT0gMCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpdGhpbk1hcmdpbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFJlLXRlc3QsIG5vdyB3aXRoIG1hcmdpbnMuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3JlY0JvdW5kc01hcmdpbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoaW5NYXJnaW4gPSAhKChleCA8IHRoaXMuX3NjaXNzb3JbMF0gLSB0aGlzLl9yZWNCb3VuZHNNYXJnaW5bMl0pIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZXkgPCB0aGlzLl9zY2lzc29yWzFdIC0gdGhpcy5fcmVjQm91bmRzTWFyZ2luWzNdKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHN4ID4gdGhpcy5fc2Npc3NvclswXSArIHRoaXMuX3NjaXNzb3JbMl0gKyB0aGlzLl9yZWNCb3VuZHNNYXJnaW5bMF0pIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3kgPiB0aGlzLl9zY2lzc29yWzFdICsgdGhpcy5fc2Npc3NvclszXSArIHRoaXMuX3JlY0JvdW5kc01hcmdpblsxXSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGhpbk1hcmdpbiA9ICEoKGV4IDwgdGhpcy5fc2Npc3NvclswXSAtIDEwMCkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChleSA8IHRoaXMuX3NjaXNzb3JbMV0gLSAxMDApIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3ggPiB0aGlzLl9zY2lzc29yWzBdICsgdGhpcy5fc2Npc3NvclsyXSArIDEwMCkgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzeSA+IHRoaXMuX3NjaXNzb3JbMV0gKyB0aGlzLl9zY2lzc29yWzNdICsgMTAwKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aXRoaW5NYXJnaW4gJiYgdGhpcy5fb3V0T2ZCb3VuZHMgPT09IDIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2hpbGRyZW4gbXVzdCBiZSB2aXNpdGVkIGJlY2F1c2UgdGhleSBtYXkgY29udGFpbiBlbGVtZW50cyB0aGF0IGFyZSB3aXRoaW4gbWFyZ2luLCBzbyBtdXN0IGJlIHZpc2libGUuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX291dE9mQm91bmRzID0gMTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fd2l0aGluQm91bmRzTWFyZ2luICE9PSB3aXRoaW5NYXJnaW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dpdGhpbkJvdW5kc01hcmdpbiA9IHd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c1VwZGF0ZXMgZmxhZyB1bm5lY2Vzc2FyaWx5IGluIGFuY2VzdG9ycy4gV2UgYWNoaWV2ZSB0aGlzIGJ5IG1ha2luZ1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHN1cmUgdGhhdCB0aGUgaGFzVXBkYXRlcyBmbGFnIG9mIHRoaXMgZWxlbWVudCBpcyB0dXJuZWQgb24sIHdoaWNoIGJsb2NrcyBpdCBmb3IgYW5jZXN0b3JzLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hhc1VwZGF0ZXMgPSB0cnVlO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjYWxjID0gdGhpcy5fcmVjYWxjO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlY2FsYyA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbGVtZW50Ll9lbmFibGVXaXRoaW5Cb3VuZHNNYXJnaW4oKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWNhbGMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGhpcyBlbGVtZW50IG5lZWRzIHRvIGJlIHJlLXVwZGF0ZWQgbm93LCBiZWNhdXNlIHdlIHdhbnQgdGhlIGRpbWVuc2lvbnMgKGFuZCBvdGhlciBjaGFuZ2VzKSB0byBiZSB1cGRhdGVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy51cGRhdGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWNhbGMgPSByZWNhbGM7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWxlbWVudC5fZGlzYWJsZVdpdGhpbkJvdW5kc01hcmdpbigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgLy8gU2V0IHZpZXdwb3J0IG5lY2Vzc2FyeSBmb3IgY2hpbGRyZW4gc2Npc3NvciBjYWxjdWxhdGlvbi5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fdmlld3BvcnQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdmlld3BvcnRbMl0gPSBiYm94VztcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdmlld3BvcnRbM10gPSBiYm94SDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl92aWV3cG9ydCA9IFswLCAwLCBiYm94VywgYmJveEhdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gRmlsdGVyIG91dCBiaXRzIHRoYXQgc2hvdWxkIG5vdCBiZSBjb3BpZWQgdG8gdGhlIGNoaWxkcmVuIChjdXJyZW50bHkgYWxsIGFyZSkuXG4gICAgICAgICAgICB0aGlzLl9wUmVjYWxjID0gKHRoaXMuX3JlY2FsYyAmIDEzNSk7XG5cbiAgICAgICAgICAgIC8vIENsZWFyIGZsYWdzIHNvIHRoYXQgZnV0dXJlIHVwZGF0ZXMgYXJlIHByb3Blcmx5IGRldGVjdGVkLlxuICAgICAgICAgICAgdGhpcy5fcmVjYWxjID0gMDtcbiAgICAgICAgICAgIHRoaXMuX2hhc1VwZGF0ZXMgPSBmYWxzZTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuX291dE9mQm91bmRzIDwgMikge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZW5kZXJUb1RleHR1cmUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3dvcmxkQ29udGV4dC5pc0lkZW50aXR5KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIE9wdGltaXphdGlvbi5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRoZSB3b3JsZCBjb250ZXh0IGlzIGFscmVhZHkgaWRlbnRpdHk6IHVzZSB0aGUgd29ybGQgY29udGV4dCBhcyByZW5kZXIgY29udGV4dCB0byBwcmV2ZW50cyB0aGVcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFuY2VzdG9ycyBmcm9tIGhhdmluZyB0byB1cGRhdGUgdGhlIHJlbmRlciBjb250ZXh0LlxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHRoaXMuX3dvcmxkQ29udGV4dDtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRlbXBvcmFyaWx5IHJlcGxhY2UgdGhlIHJlbmRlciBjb29yZCBhdHRyaWJzIGJ5IHRoZSBpZGVudGl0eSBtYXRyaXguXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBUaGlzIGFsbG93cyB0aGUgY2hpbGRyZW4gdG8gY2FsY3VsYXRlIHRoZSByZW5kZXIgY29udGV4dC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlckNvbnRleHQgPSBFbGVtZW50Q29yZUNvbnRleHQuSURFTlRJVFk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl9jaGlsZHJlbi5sZW5ndGg7IGkgPCBuOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnVwZGF0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3VzZVJlbmRlclRvVGV4dHVyZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW5kZXJDb250ZXh0ID0gcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jaGlsZHJlbikge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuW2ldLl9oYXNVcGRhdGVzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2hpbGRyZW5baV0udXBkYXRlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE1ha2Ugc3VyZSB3ZSBkb24ndCBsb3NlIHRoZSAnaW5oZXJpdGVkJyB1cGRhdGVzLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLl9yZWNhbGMgfD0gdGhpcy5fcFJlY2FsYztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGVPdXRPZkJvdW5kcygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fb25BZnRlclVwZGF0ZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX29uQWZ0ZXJVcGRhdGUodGhpcy5lbGVtZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHN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ldCBpID0gMCwgbiA9IHRoaXMuX2NoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGlsZHJlbltpXS51cGRhdGVUcmVlT3JkZXIoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfcmVuZGVyU2ltcGxlKCkge1xuICAgICAgICB0aGlzLl9oYXNSZW5kZXJVcGRhdGVzID0gMDtcblxuICAgICAgICBpZiAodGhpcy5felNvcnQpIHtcbiAgICAgICAgICAgIHRoaXMuc29ydFpJbmRleGVkQ2hpbGRyZW4oKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLl9vdXRPZkJvdW5kcyA8IDIgJiYgdGhpcy5fcmVuZGVyQ29udGV4dC5hbHBoYSkge1xuICAgICAgICAgICAgbGV0IHJlbmRlclN0YXRlID0gdGhpcy5yZW5kZXJTdGF0ZTtcblxuICAgICAgICAgICAgaWYgKCh0aGlzLl9vdXRPZkJvdW5kcyA9PT0gMCkgJiYgdGhpcy5fZGlzcGxheWVkVGV4dHVyZVNvdXJjZSkge1xuICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNoYWRlcih0aGlzLmFjdGl2ZVNoYWRlciwgdGhpcy5fc2hhZGVyT3duZXIpO1xuICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNjaXNzb3IodGhpcy5fc2Npc3Nvcik7XG4gICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJTdGF0ZS5hZGRRdWFkKHRoaXMpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBBbHNvIGFkZCBjaGlsZHJlbiB0byB0aGUgVkJPLlxuICAgICAgICAgICAgaWYgKHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pDb250ZXh0VXNhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbltpXS5yZW5kZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW5baV0uX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIHpJbmRleCBpcyBzZXQsIHRoaXMgaXRlbSBhbHJlYWR5IGJlbG9uZ3MgdG8gYSB6SW5kZXhlZENoaWxkcmVuIGFycmF5IGluIG9uZSBvZiB0aGUgYW5jZXN0b3JzLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBfcmVuZGVyQWR2YW5jZWQoKSB7XG4gICAgICAgIGNvbnN0IGhhc1JlbmRlclVwZGF0ZXMgPSB0aGlzLl9oYXNSZW5kZXJVcGRhdGVzO1xuXG4gICAgICAgIC8vIFdlIG11c3QgY2xlYXIgdGhlIGhhc1JlbmRlclVwZGF0ZXMgZmxhZyBiZWZvcmUgcmVuZGVyaW5nLCBiZWNhdXNlIHVwZGF0aW5nIHJlc3VsdCB0ZXh0dXJlcyBpbiBjb21iaW5hdGlvblxuICAgICAgICAvLyB3aXRoIHotaW5kZXhpbmcgbWF5IHRya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xuICAgICAgICAgICAgICAgICAgICAvLyBUZWxsIHRoZSByZW5kZXJlciB3ZSdyZSByZW5kZXJpbmcgYSByZW5kZXJUb1RleHR1cmUgZWxlbWVudCBpbiB0aGlzIGZyYW1lXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlbmRlclRvVGV4dHVyZUNvdW50Kys7XG4gICAgICAgICAgICAgICAgICAgIC8vIFN3aXRjaCB0byBkZWZhdWx0IHNoYWRlciBmb3IgYnVpbGRpbmcgdXAgdGhlIHJlbmRlciB0ZXh0dXJlLlxuICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRTaGFkZXIocmVuZGVyU3RhdGUuZGVmYXVsdFNoYWRlciwgdGhpcyk7XG5cbiAgICAgICAgICAgICAgICAgICAgcHJldlJlbmRlclRleHR1cmVJbmZvID0gcmVuZGVyU3RhdGUucmVuZGVyVGV4dHVyZUluZm87XG5cbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyVGV4dHVyZUluZm8gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVUZXh0dXJlOiBudWxsLFxuICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0OiAwLCAgLy8gU2V0IGJ5IENvcmVSZW5kZXJTdGF0ZS5cbiAgICAgICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuX3csXG4gICAgICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLl9oLFxuICAgICAgICAgICAgICAgICAgICAgICAgZW1wdHk6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhcmVkOiBmYWxzZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZTogZmFsc2VcbiAgICAgICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdGV4dHVyaXplci5oYXNSZXN1bHRUZXh0dXJlKCkgfHwgKCFyZ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CB3aWxsIGJlIGNhY2hlZCBpbnN0ZWFkLlxuICAgICAgICAgICAgICAgICAgICAgICAgICpcbiAgICAgICAgICAgICAgICAgICAgICAgICAqIEluIGNhc2Ugb2YgdGhlIGZhc3QgYmx1ciBlbGVtZW50LCB0aGlzIHByZXZlbnRzIGhhdmluZyB0byBjYWNoZSBhbGwgYmx1ciBsZXZlbHMgYW5kIHN0YWdlcywgc2F2aW5nIGEgaHVnZSBhbW91bnRcbiAgICAgICAgICAgICAgICAgICAgICAgICAqIG9mIEdQVSBtZW1vcnkhXG4gICAgICAgICAgICAgICAgICAgICAgICAgKlxuICAgICAgICAgICAgICAgICAgICAgICAgICogRXNwZWNpYWxseSB3aGVuIHVzaW5nIG11bHRpcGxlIHN0YWNrZWQgbGF5ZXJzIG9mIHRoZSBzYW1lIGRpbWVuc2lvbnMgdGhhdCBhcmUgUlRUIHRoaXMgd2lsbCBoYXZlIGEgdmVyeVxuICAgICAgICAgICAgICAgICAgICAgICAgICogbm90aWNhYmxlIGVmZmVjdCBvbiBwZXJmb3JtYW5jZSBhcyBsZXNzIHJlbmRlciB0ZXh0dXJlcyBuZWVkIHRvIGJlIGFsbG9jYXRlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAqL1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyVGV4dHVyZUluZm8uY2FjaGUgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuaXNDYWNoaW5nVGV4dHVyaXplciA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3RleHR1cml6ZXIuaGFzUmVzdWx0VGV4dHVyZSgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBXZSBjYW4gYWxyZWFkeSByZWxlYXNlIHRoZSBjdXJyZW50IHRleHR1cmUgdG8gdGhlIHBvb2wsIGFzIGl0IHdpbGwgYmUgcmVidWlsZCBhbnl3YXkuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBJbiBjYXNlIG9mIG11bHRpcGxlIGxheWVycyBvZiAnZmlsdGVyaW5nJywgdGhpcyBtYXkgc2F2ZSB1cyBmcm9tIGhhdmluZyB0byBjcmVhdGUgb25lXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyAgcmVuZGVyLXRvLXRleHR1cmUgbGF5ZXIuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBOb3RpY2UgdGhhdCB3ZSBkb24ndCBkbyB0aGlzIHdoZW4gdGhlcmUgaXMgYSByZXN1bHQgdGV4dHVyZSwgYXMgYW55IG90aGVyIGVsZW1lbnQgbWF5IHJlbHkgb25cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vICB0aGF0IHJlc3VsdCB0ZXh0dXJlIGJlaW5nIGZpbGxlZC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZVJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFJlbmRlclRleHR1cmVJbmZvKHJlbmRlclRleHR1cmVJbmZvKTtcbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2Npc3NvcihudWxsKTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGlzcGxheWVkVGV4dHVyZVNvdXJjZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBVc2UgYW4gaWRlbnRpdHkgY29udGV4dCBmb3IgZHJhd2luZyB0aGUgZGlzcGxheWVkIHRleHR1cmUgdG8gdGhlIHJlbmRlciB0ZXh0dXJlLlxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IEVsZW1lbnRDb3JlQ29udGV4dC5JREVOVElUWTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQWRkIGRpc3BsYXllZCB0ZXh0dXJlIHNvdXJjZSBpbiBsb2NhbCBjb29yZGluYXRlcy5cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVuZGVyU3RhdGUuYWRkUXVhZCh0aGlzKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVuZGVyQ29udGV4dCA9IHI7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBtdXN0UmVuZGVyQ2hpbGRyZW4gPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICgodGhpcy5fb3V0T2ZCb3VuZHMgPT09IDApICYmIHRoaXMuX2Rpc3BsYXllZFRleHR1cmVTb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2hhZGVyKHRoaXMuYWN0aXZlU2hhZGVyLCB0aGlzLl9zaGFkZXJPd25lcik7XG4gICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNjaXNzb3IodGhpcy5fc2Npc3Nvcik7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmVuZGVyU3RhdGUuYWRkUXVhZCh0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEFsc28gYWRkIGNoaWxkcmVuIHRvIHRoZSBWQk8uXG4gICAgICAgICAgICBpZiAobXVzdFJlbmRlckNoaWxkcmVuICYmIHRoaXMuX2NoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX3pDb250ZXh0VXNhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIG4gPSB0aGlzLl96SW5kZXhlZENoaWxkcmVuLmxlbmd0aDsgaSA8IG47IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbltpXS5yZW5kZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBuID0gdGhpcy5fY2hpbGRyZW4ubGVuZ3RoOyBpIDwgbjsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2hpbGRyZW5baV0uX3pJbmRleCA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIElmIHpJbmRleCBpcyBzZXQsIHRoaXMgaXRlbSBhbHJlYWR5IGJlbG9uZ3MgdG8gYSB6SW5kZXhlZENoaWxkcmVuIGFycmF5IGluIG9uZSBvZiB0aGUgYW5jZXN0b3JzLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoaWxkcmVuW2ldLnJlbmRlcigpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodGhpcy5fdXNlUmVuZGVyVG9UZXh0dXJlKSB7XG4gICAgICAgICAgICAgICAgbGV0IHVwZGF0ZVJlc3VsdFRleHR1cmUgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBpZiAobXVzdFJlbmRlckNoaWxkcmVuKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIEZpbmlzaGVkIHJlZnJlc2hpbmcgcmVuZGVyVGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuZmluaXNoZWRSZW5kZXJUZXh0dXJlKCk7XG5cbiAgICAgICAgICAgICAgICAgICAgLy8gSWYgbm90aGluZyB3YXMgcmVuZGVyZWQsIHdlIHN0b3J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ZvLmlnbm9yZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdGV4dHVyaXplci5yZW5kZXJUZXh0dXJlUmV1c2VkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gUXVhZCBvcGVyYXRpb25zIG11c3QgYmUgd3JpdHRlbiB0byBhIHJlbmRlciB0ZXh0dXJlIGFjdHVhbGx5IG93bmVkLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIucmVsZWFzZVJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEp1c3QgY3JlYXRlIHRoZSByZW5kZXIgdGV4dHVyZS5cbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlclRleHR1cmVJbmZvLm5hdGl2ZVRleHR1cmUgPSB0aGlzLl90ZXh0dXJpemVyLmdldFJlbmRlclRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIC8vIFJlc3RvcmUgdGhlIHBhcmVudCdzIHJlbmRlciB0ZXh0dXJlLlxuICAgICAgICAgICAgICAgICAgICByZW5kZXJTdGF0ZS5zZXRSZW5kZXJUZXh0dXJlSW5mbyhwcmV2UmVuZGVyVGV4dHVyZUluZm8pO1xuXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZVJlc3VsdFRleHR1cmUgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5lbXB0eSkge1xuICAgICAgICAgICAgICAgICAgICBsZXQgcmVzdWx0VGV4dHVyZSA9IHRoaXMuX3RleHR1cml6ZXIuZ2V0UmVzdWx0VGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgICAgICBpZiAodXBkYXRlUmVzdWx0VGV4dHVyZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdFRleHR1cmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBMb2dnaW5nIHRoZSB1cGRhdGUgZnJhbWUgY2FuIGJlIGhhbmR5IGZvciB1c2VybGFuZC5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRUZXh0dXJlLnVwZGF0ZSA9IHJlbmRlclN0YXRlLnN0YWdlLmZyYW1lQ291bnRlcjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHR1cml6ZXIudXBkYXRlUmVzdWx0VGV4dHVyZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyLnJlbmRlck9mZnNjcmVlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmVuZGVyIHJlc3VsdCB0ZXh0dXJlIHRvIHRoZSBhY3R1YWwgcmVuZGVyIHRhcmdldC5cbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFNoYWRlcih0aGlzLmFjdGl2ZVNoYWRlciwgdGhpcy5fc2hhZGVyT3duZXIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0U2Npc3Nvcih0aGlzLl9zY2lzc29yKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gSWYgbm8gcmVuZGVyIHRleHR1cmUgaW5mbyBpcyBzZXQsIHRoZSBjYWNoZSBjYW4gYmUgcmV1c2VkLlxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FjaGUgPSAhcmVuZGVyVGV4dHVyZUluZm8gfHwgcmVuZGVyVGV4dHVyZUluZm8uY2FjaGU7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlclN0YXRlLnNldFRleHR1cml6ZXIodGhpcy5fdGV4dHVyaXplciwgY2FjaGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3Rhc2hUZXhDb29yZHMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5jb2xvcml6ZSkgdGhpcy5fc3Rhc2hDb2xvcnMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVuZGVyU3RhdGUuYWRkUXVhZCh0aGlzLCB0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fdGV4dHVyaXplci5jb2xvcml6ZSkgdGhpcy5fdW5zdGFzaENvbG9ycygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdW5zdGFzaFRleENvb3JkcygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuc2V0VGV4dHVyaXplcihudWxsKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHJlbmRlclRleHR1cmVJbmZvICYmIHJlbmRlclRleHR1cmVJbmZvLmNhY2hlKSB7XG4gICAgICAgICAgICAgICAgLy8gQWxsb3cgc2libGluZ3MgdG8gY2FjaGUuXG4gICAgICAgICAgICAgICAgcmVuZGVyU3RhdGUuaXNDYWNoaW5nVGV4dHVyaXplciA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZ2V0IHpTb3J0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5felNvcnQ7XG4gICAgfVxuXG4gICAgc29ydFpJbmRleGVkQ2hpbGRyZW4oKSB7XG4gICAgICAgIC8qKlxuICAgICAgICAgKiBXZSB3YW50IHRvIGF2b2lkIHJlc29ydGluZyBldmVyeXRoaW5nLiBJbnN0ZWFkLCB3ZSBkbyBhIHNpbmdsZSBwYXNzIG9mIHRoZSBmdWxsIG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SW5kZXhSZXNvcnQpIHtcbiAgICAgICAgICAgICAgICAgICAgYi5wdXNoKGFbaV0pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChwdHIgIT09IGkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFbcHRyXSA9IGFbaV07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcHRyKys7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgY29uc3QgbSA9IGIubGVuZ3RoO1xuICAgICAgICBpZiAobSkge1xuICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBtOyBqKyspIHtcbiAgICAgICAgICAgICAgICBiW2pdLl96SW5kZXhSZXNvcnQgPSBmYWxzZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgYi5zb3J0KEVsZW1lbnRDb3JlLnNvcnRaSW5kZXhlZENoaWxkcmVuKTtcbiAgICAgICAgICAgIGNvbnN0IG4gPSBwdHI7XG4gICAgICAgICAgICBpZiAoIW4pIHtcbiAgICAgICAgICAgICAgICBwdHIgPSAwO1xuICAgICAgICAgICAgICAgIGxldCBqID0gMDtcbiAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIGFbcHRyKytdID0gYltqKytdO1xuICAgICAgICAgICAgICAgIH0gd2hpbGUgKGogPCBtKTtcblxuICAgICAgICAgICAgICAgIGlmIChhLmxlbmd0aCA+IHB0cikge1xuICAgICAgICAgICAgICAgICAgICAvLyBTbGljZSBvbGQgKHVubmVjZXNzYXJ5KSBwYXJ0IG9mZiBhcnJheS5cbiAgICAgICAgICAgICAgICAgICAgYS5zcGxpY2UocHRyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGEuc3BsaWNlKG4pOyAvLyBSZW1vdmUgaXRlbXMgdGhhdCB3ZXJlIHNvcnRlZCBpbiBiIGFycmF5LCBzbyB0aGF0IHdlIGNhbiBzb3J0IGFcbisgICAgICAgICAgICAgICAvLyBCZXdhcmUgdGhhdCB0aGUgZnVuY3Rpb24gcGFzc2VkIGhlcmUgdG8gQXJyYXkuc29ydCBtdXN0IGJlIHN0YWJsZVxuKyAgICAgICAgICAgICAgIGEuc29ydChFbGVtZW50Q29yZS5zb3J0WkluZGV4ZWRDaGlsZHJlbik7IC8vIE5lZWRlZCBiZWNhdXNlIGl0ZW1zIHdpdGggc2FtZSBfekluZGV4IG1heSBub3QgYmUgb3JkZXJlZCBieSBfdXBkYXRlVHJlZU9yZGVyXG4gICAgICAgICAgICAgICAgLy8gTWVyZ2Utc29ydCBhcnJheXM7XG4gICAgICAgICAgICAgICAgcHRyID0gMDtcbiAgICAgICAgICAgICAgICBsZXQgaSA9IDA7XG4gICAgICAgICAgICAgICAgbGV0IGogPSAwO1xuICAgICAgICAgICAgICAgIGNvbnN0IG1lcmdlUmVzdWx0ID0gW107XG4gICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCB2ID0gKGFbaV0uX3pJbmRleCA9PT0gYltqXS5fekluZGV4ID8gYVtpXS5fdXBkYXRlVHJlZU9yZGVyIC0gYltqXS5fdXBkYXRlVHJlZU9yZGVyIDogYVtpXS5fekluZGV4IC0gYltqXS5fekluZGV4KTtcblxuICAgICAgICAgICAgICAgICAgICBjb25zdCBhZGQgPSB2ID4gMCA/IGJbaisrXSA6IGFbaSsrXTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAocHRyID09PSAwIHx8IChtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbWVyZ2VSZXN1bHRbcHRyKytdID0gYWRkO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgZG8ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFkZCA9IGJbaisrXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHRyID09PSAwIHx8IChtZXJnZVJlc3VsdFtwdHIgLSAxXSAhPT0gYWRkKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXJnZVJlc3VsdFtwdHIrK10gPSBhZGQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoaiA8IG0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaiA+PSBtKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWRkID0gYVtpKytdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwdHIgPT09IDAgfHwgKG1lcmdlUmVzdWx0W3B0ciAtIDFdICE9PSBhZGQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lcmdlUmVzdWx0W3B0cisrXSA9IGFkZDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9IHdoaWxlIChpIDwgbik7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gd2hpbGUgKHRydWUpO1xuXG4gICAgICAgICAgICAgICAgdGhpcy5fekluZGV4ZWRDaGlsZHJlbiA9IG1lcmdlUmVzdWx0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKGEubGVuZ3RoID4gcHRyKSB7XG4gICAgICAgICAgICAgICAgLy8gU2xpY2Ugb2xkICh1bm5lY2Vzc2FyeSkgcGFydCBvZmYgYXJyYXkuXG4gICAgICAgICAgICAgICAgYS5zcGxpY2UocHRyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuX3pTb3J0ID0gZmFsc2U7XG4gICAgfTtcblxuICAgIGdldCBsb2NhbFRhKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbG9jYWxUYTtcbiAgICB9O1xuXG4gICAgZ2V0IGxvY2FsVGIoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9sb2NhbFRiO1xuICAgIH07XG5cbiAgICBnZXQgbG9jYWxUYygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2xvY2FsVGM7XG4gICAgfTtcblxuICAgIGdldCBsb2NhbFRkKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbG9jYWxUZDtcbiAgICB9O1xuXG4gICAgZ2V0IGVsZW1lbnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9lbGVtZW50O1xuICAgIH1cblxuICAgIGdldCByZW5kZXJVcGRhdGVzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faGFzUmVuZGVyVXBkYXRlcztcbiAgICB9XG5cbiAgICBnZXQgdGV4dHVyaXplcigpIHtcbiAgICAgICAgaWYgKCF0aGlzLl90ZXh0dXJpemVyKSB7XG4gICAgICAgICAgICB0aGlzLl90ZXh0dXJpemVyID0gbmV3IEVsZW1lbnRUZXh0dXJpemVyKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLl90ZXh0dXJpemVyO1xuICAgIH1cblxuICAgIGdldENvcm5lclBvaW50cygpIHtcbiAgICAgICAgbGV0IHcgPSB0aGlzLl93b3JsZENvbnRleHQ7XG5cbiAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgIHcucHgsXG4gICAgICAgICAgICB3LnB5LFxuICAgICAgICAgICAgdy5weCArIHRoaXMuX3cgKiB3LnRhLFxuICAgICAgICAgICAgdy5weSArIHRoaXMuX3cgKiB3LnRjLFxuICAgICAgICAgICAgdy5weCArIHRoaXMuX3cgKiB3LnRhICsgdGhpcy5faCAqIHcudGIsXG4gICAgICAgICAgICB3LnB5ICsgdGhpcy5fdyAqIHcudGMgKyB0aGlzLl9oICogdy50ZCxcbiAgICAgICAgICAgIHcucHggKyB0aGlzLl9oICogdy50YixcbiAgICAgICAgICAgIHcucHkgKyB0aGlzLl9oICogdy50ZFxuICAgICAgICBdO1xuICAgIH07XG5cbiAgICBnZXRSZW5kZXJUZXh0dXJlQ29vcmRzKHJlbFgsIHJlbFkpIHtcbiAgICAgICAgbGV0IHIgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgci5weCArIHIudGEgKiByZWxYICsgci50YiAqIHJlbFksXG4gICAgICAgICAgICByLnB5ICsgci50YyAqIHJlbFggKyByLnRkICogcmVsWVxuICAgICAgICBdO1xuICAgIH1cblxuICAgIGdldEFic29sdXRlQ29vcmRzKHJlbFgsIHJlbFkpIHtcbiAgICAgICAgbGV0IHcgPSB0aGlzLl9yZW5kZXJDb250ZXh0O1xuICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgdy5weCArIHcudGEgKiByZWxYICsgdy50YiAqIHJlbFksXG4gICAgICAgICAgICB3LnB5ICsgdy50YyAqIHJlbFggKyB3LnRkICogcmVsWVxuICAgICAgICBdO1xuICAgIH1cblxuICAgIGNvbGxlY3RBdENvb3JkKHgsIHksIGNoaWxkcmVuKSB7XG4gICAgICAgIC8vIHJldHVybiB3aGVuIGJyYW5jaCBpcyBoaWRkZW5cbiAgICAgICAgaWYgKHRoaXMuX3JlbmRlckNvbnRleHQuYWxwaGEgPT09IDApIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLmluQm91bmQoeCwgeSkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9zY2lzc29yKSB7XG4gICAgICAgICAgICAgICAga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V4TGF5b3V0KCkge1xuICAgICAgICByZXR1cm4gKHRoaXMuX2xheW91dCAmJiB0aGlzLl9sYXlvdXQuaXNFbmFibGVkKCkpO1xuICAgIH1cblxuICAgIHNldExheW91dCh4LCB5LCB3LCBoKSB7XG4gICAgICAgIHRoaXMueCA9IHg7XG4gICAgICAgIHRoaXMueSA9IHk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZURpbWVuc2lvbnModywgaCk7XG4gICAgfVxuXG4gICAgdHJpZ2dlckxheW91dCgpIHtcbiAgICAgICAgdGhpcy5fc2V0UmVjYWxjKDI1Nik7XG4gICAgfVxuXG4gICAgX3RyaWdnZXJSZWNhbGNUcmFuc2xhdGUoKSB7XG4gICAgICAgIHRoaXMuX3NldFJlY2FsYygyKTtcbiAgICB9XG5cbn1cblxuY2xhc3MgRWxlbWVudENvcmVDb250ZXh0IHtcblxuICAgIGNvbnN0cnVjdG9yKCkge1xuICAgICAgICB0aGlzLmFscGhhID0gMTtcblxuICAgICAgICB0aGlzLnB4ID0gMDtcbiAgICAgICAgdGhpcy5weSA9IDA7XG5cbiAgICAgICAgdGhpcy50YSA9IDE7XG4gICAgICAgIHRoaXMudGIgPSAwO1xuICAgICAgICB0aGlzLnRjID0gMDtcbiAgICAgICAgdGhpcy50ZCA9IDE7XG4gICAgfVxuXG4gICAgaXNJZGVudGl0eSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuYWxwaGEgPT09IDEgJiZcbiAgICAgICAgICAgIHRoaXMucHggPT09IDAgJiZcbiAgICAgICAgICAgIHRoaXMucHkgPT09IDAgJiZcbiAgICAgICAgICAgIHRoaXMudGEgPT09IDEgJiZcbiAgICAgICAgICAgIHRoaXMudGIgPT09IDAgJiZcbiAgICAgICAgICAgIHRoaXMudGMgPT09IDAgJiZcbiAgICAgICAgICAgIHRoaXMudGQgPT09IDE7XG4gICAgfVxuXG4gICAgaXNTcXVhcmUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnRiID09PSAwICYmIH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Z0ID0gMFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgbm8tdW5kZWZcbiAgICAgICAgICAgICAgaWYgKGUgaW5zdGFuY2VvZiBTcGVlY2hTeW50aGVzaXNFcnJvckV2ZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKGUuZXJyb3IgPT09ICduZXR3b3JrJykge1xuICAgICAgICAgICAgICAgICAgcmV0cmllc0xlZnQtLVxuICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKGBTcGVlY2ggc3ludGhlc2lzIG5ldHdvcmsgZXJyb3IuIFJldHJpZXMgbGVmdDogJHtyZXRyaWVzTGVmdH1gKVxuICAgICAgICAgICAgICAgICAgYXdhaXQgZGVsYXkoNTAwICogKHRvdGFsUmV0cmllcyAtIHJldHJpZXNMZWZ0KSlcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGUuZXJyb3IgPT09ICdjYW5jZWxlZCcgfHwgZS5lcnJvciA9PT0gJ2ludGVycnVwdGVkJykge1xuICAgICAgICAgICAgICAgICAgLy8gQ2FuY2VsIG9yIGludGVycnVwdCBlcnJvciAoaWdub3JlKVxuICAgICAgICAgICAgICAgICAgcmV0cmllc0xlZnQgPSAwXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgU3BlZWNoU3ludGhlc2lzRXJyb3JFdmVudDogJHtlLmVycm9yfWApXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRocm93IGVcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgcGhyYXNlID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgY29uc3Qgc2VyaWVzUmVzdWx0ID0gc3BlYWt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ZpcnN0UXVhcnRpbGUgJiZcbiAgICAgICAgICB2aWRlb0VsLmN1cnJlbnRUaW1lID49IHRpbWVFdmVudHMuZmlyc3RRdWFydGlsZVxuICAgICAgICApIHtcbiAgICAgICAgICBmaXJlT25Db25zdW1lcignRmlyc3RRdWFydGlsZScsIGFkKVxuICAgICAgICAgIGRlbGV0ZSB0aW1lRXZlbnRzLmZpcnN0UXVhcnRpbGVcbiAgICAgICAgICBzZW5kQmVhY29uKGFkLmNhbGxiYWNrcywgJ2ZpcnN0UXVhcnRpbGUnKVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aW1lRXZlbnRzICYmIHRpbWVFdmVudHMubWlkUG9pbnQgJiYgdmlkZW9FbC5jdXJyZW50VGltZSA+PSB0aW1lRXZlbnRzLm1pZFBvaW50KSB7XG4gICAgICAgICAgZmlyZU9uQ29uc3VtZXIoJ01pZFBvaW50JywgYWQpXG4gICAgICAgICAgZGVsZXRlIHRpbWVFdmVudHMubWlkUG9pbnRcbiAgICAgICAgICBzZW5kQmVhY29uKGFkLmNhbGxiYWNrcywgJ21pZFBvaW50JylcbiAgICAgICAgfVxuICAgICAgICBpZiAoXG4gICAgICAgICAgdGltZUV2ZW50cyAmJlxuICAgICAgICAgIHRpbWVFdmVudHMudGhpcmRRdWFydGlsZSAmJlxuICAgICAgICAgIHZpZGVvRWwuY3VycmVudFRpbWUgPj0gdGltZUV2ZW50cy50aGlyZFF1YXJ0aWxlXG4gICAgICAgICkge1xuICAgICAgICAgIGZpcmVPbkNvbnN1bWVyKCdUaGlyZFF1YXJ0aWxlJywgYWQpXG4gICAgICAgICAgZGVsZXRlIHRpbWVFdmVudHMudGhpcmRRdWFydGlsZVxuICAgICAgICAgIHNlbmRCZWFjb24oYWQuY2FsbGJhY2tzLCAndGhpcmRRdWFydGlsZScpXG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgICBzdGFsbGVkKCkge1xuICAgICAgICBmaXJlT25Db25zdW1lcignU3RhbGxlZCcsIGFkKV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ByZXJvbGwpIHtcbiAgICAgICAgICAgICAgc3RhdGUuYWN0aXZlID0gdHJ1ZVxuICAgICAgICAgICAgICBmaXJlT25Db25zdW1lcignUHJlcm9sbFNsb3RJbXByZXNzaW9uJywgYWRzKVxuICAgICAgICAgICAgICBzZW5kQmVhY29uKGFkcy5wcmVyb2xsLmNhbGxiYWNrcywgJ3Nsb3RJbXByZXNzaW9uJylcbiAgICAgICAgICAgICAgcmV0dXJuIHBsYXlTbG90KGFkcy5wcmVyb2xsLmFkcykudGhlbigoKSA9PiB7XG4gICAgICAgICAgICAgICAgZmlyZU9uQ29uc3VtZXIoJ1ByZXJvbGxTbG90RW5kJywgYWRzKVxuICAgICAgICAgICAgICAgIHNlbmRCZWFjb24oYWRzLnByZXJvbGwuY2FsbGJhY2tzLCAnc2xvdEVuZCcpXG4gICAgICAgICAgICAgICAgc3RhdGUuYWN0aXZlID0gZmFsc2VcbiAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKVxuICAgICAgICAgIH0sXG4gICAgICAgICAgbWlkcm9sbHMoKSB7XG4gICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKClcbiAgICAgICAgICB9LFxuICAgICAgICAgIHBvc3Ryb2xscygpIHtcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKVxuICAgICAgICAgIH0sXG4gICAgICAgIH0pXG4gICAgICB9KVxuICAgIH0pXG4gIH0sXG4gIGNhbmNlbCgpIHtcbiAgICBMb2cuaW5mbygnQWQnLCAnQ2FuY2VsIEFkJylcbiAgICBzdGF0ZS5hY3RpdmUgPSBmYWxzZVxuICB9LFxuICBzdG9wKCkge1xuICAgIExvZy5pbmZvKCdBZCcsICdTdG9wIEFkJylcbiAgICBzdGF0ZS5hY3RpdmUgPSBmYWxzZVxuICAgIC8vIGZpeG1lOiBkdXBsaWNhdGlvblxuICAgIGNvbnN0IHZ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xuICAgICAgICAudGhlbigoKSA9PiB7XG4gICAgICAgICAgTWV0cmljcy5hcHAubG9hZGVkKClcblxuICAgICAgICAgIHRoaXMudyA9IHRoaXMuY29uZmlnLnN0YWdlLncgLyB0aGlzLmNvbmZpZy5zdGFnZS5wcmVjaXNpb25cbiAgICAgICAgICB0aGlzLmggPSB0aGlzLmNvbmZpZy5zdGFnZS5oIC8gdGhpcy5jb25maWcuc3RhZ2UucHJlY2lzaW9uXG5cbiAgICAgICAgICBBcHBEYXRhID0gYXBwRGF0YVxuXG4gICAgICAgICAgQXBwSW5zdGFuY2UgPSB0aGlzLnN0YWdlLmMoe1xuICAgICAgICAgICAgcmVmOiAnQXBwJyxcbiAgICAgICAgICAgIHR5cGU6IEFwcCxcbiAgICAgICAgICAgIHpJbmRleDogMSxcbiAgICAgICAgICAgIGZvcmNlWkluZGV4Q29udGV4dDogISFwbGF0Zm9ybVNldHRpbmdzLnNob3dWZXJzaW9uIHx8ICEhcGxhdGZvcm1TZXR0aW5ncy5zaG93RnBzLFxuICAgICAgICAgIH0pXG5cbiAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKEFwcEluc3RhbmNlKVxuXG4gICAgICAgICAgdGhpcy5fcmVmb2N1cygpXG5cbiAgICAgICAgICBMb2cuaW5mbygnQXBwIHZlcnNpb24nLCB0aGlzLmNvbmZpZy52ZXJzaW9uKVxuICAgICAgICAgIExvZy5pbmZvKCdTREsgdmVyc2lvbicsIHBhY2thZ2VJbmZvLnZlcnNpb24pXG5cbiAgICAgICAgICBpZiAocGxhdGZvcm1TZXR0aW5ncy5zaG93VmVyc2lvbikge1xuICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYSh7XG4gICAgICAgICAgICAgIHJlZjogJ1ZlcnNpb25MYWJlbCcsXG4gICAgICAgICAgICAgIHR5cGU6IFZlcnNpb25MYWJlbCxcbiAgICAgICAgICAgICAgdmVyc2lvbjogdGhpcy5jb25maWcudmVyc2lvbixcbiAgICAgICAgICAgICAg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LmcgLyAyNTVcbiAgY29uc3QgYiA9IGNvbC5iIC8gMjU1XG5cbiAgY29uc3QgbWF4ID0gTWF0aC5tYXgociwgZywgYilcbiAgY29uc3QgbWluID0gTWF0aC5taW4ociwgZywgYilcblxuICBsZXQgaCA9IDBcbiAgbGV0IHMgPSAwXG4gIGNvbnN0IGwgPSAobWluICsgbWF4KSAqIDAuNVxuICBpZiAobCA+IDApIHtcbiAgICBjb25zdCBtYXhNaW4gPSBtYXggLSBtaW5cbiAgICBpZiAobWF4TWluID4gMCkge1xuICAgICAgY29uc3QgcjIgPSAobWF4IC0gcikgLyBtYXhNaW5cbiAgICAgIGNvbnN0IGcyID0gKG1heCAtIGcpIC8gbWF4TWluXG4gICAgICBjb25zdCBiMiA9IChtYXggLSBiKSAvIG1heE1pblxuICAgICAgaWYgKGwgPCAwLjUpIHtcbiAgICAgICAgcyA9IG1heCArIG1pblxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcyA9IDIgLSBtYXggLSBtaW5cbiAgICAgIH1cblxuICAgICAgaWYgKHIgPT09IG1heCAmJiBnID09PSBtaW4pIHtcbiAgICAgICAgaCA9IDUuMCArIGIyXG4gICAgICB9IGVsc2UgaWYgKHIgPT09IG1heCkge1xuICAgICAgICBoID0gMS4wIC0gZzJcbiAgICAgIH0gZWxzZSBpZiAoZyA9PT0gbWF4ICYmIGIgPT09IG1pbikge1xuICAgICAgICBoID0gMS4wICsgcjJcbiAgICAgIH0gZWxzZSBpZiAoZyA9PT0gbWF4KSB7XG4gICAgICAgIGggPSAzLjAgLSBiMlxuICAgICAgfSBlbHNlIGlmIChiID09PSBtYXgpIHtcbiAgICAgICAgaCA9IDMuMCArIGcyXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBoID0gNS4wIC0gcjJcbiAgICAgIH1cbiAgICAgIGggPSBoIC8gNlxuICAgIH1cbiAgfVxuICByZXR1cm4geyBoOiBoICUgMSwgcywgbCwgYTogY29sLmEgfVxufVxuXG5leHBvcnQgY29uc3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nXG5pbXBvcnQgTG9nIGZyb20gJy4uL0xvZydcbmltcG9ydCBVdGlscyBmcm9tICcuLi9VdGlscydcblxubGV0IG1ldGEgPSB7fVxubGV0IHRyYW5zbGF0aW9ucyA9IHt9XG5sZXQgbGFuZ3VhZ2UgPSBudWxsXG5sZXQgZGljdGlvbmFyeSA9IG51bGxcblxuZXhwb3J0IGNvbnN0IGluaXRMYW5ndWFnZSA9IChmaWxlLCBsYW5ndWFnZSA9IG51bGwpID0+IHtcbiAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICBmZXRjaEpzb24oZmlsZSlcbiAgICAgIC50aGVuKGpzb24gPT4ge1xuICAgICAgICBzZXRUcmFuc2xhdGlvbnMoanNvbilcbiAgICAgICAgLy8gc2V0IGxhbmd1YWdlIChkaXJlY3RseSBvciBpbiBhIHByb21pc2UpXG4gICAgICAgIHR5cGVvZiBsYW5ndWFnZSA9PT0gJ29iamVjdCcgJiYgJ3RoZW4nIGluIGxhbmd1YWdlICYmIHR5cGVvZiBsYW5ndWFnZS50aGVuID09PSAnZnVuY3Rpb24nXG4gICAgICAgICAgPyBsYW5ndWFnZVxuICAgICAgICAgICAgICAudGhlbihsYW5nID0+XG4gICAgICAgICAgICAgICAgc2V0TGFuZ3VhZ2UobGFuZylcbiAgICAgICAgICAgICAgICAgIC50aGVuKHJlc29sdmUpXG4gICAgICAgICAgICAgICAgICAuY2F0Y2gocmVqZWN0KVxuICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgIC5jYXRjaChlID0+IHtcbiAgICAgICAgICAgICAgICBMb2cuZXJyb3IoZSlcbiAgICAgICAgICAgICAgICByZWplY3QoZSlcbiAgICAgICAgICAgICAgfSlcbiAgICAgICAgICA6IHNldExhbmd1YWdlKGxhbmd1YWdlKVxuICAgICAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgICAgICAuY2F0Y2gocmVqZWN0KVxuICAgICAgfSlcbiAgICAgI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ICAgICByZXNvbHZlKClcbiAgICAgICAgICB9KVxuICAgICAgICAgIC5jYXRjaChlID0+IHtcbiAgICAgICAgICAgIGNvbnN0IGVycm9yID0gJ0Vycm9yIHdoaWxlIGZldGNoaW5nICcgKyB1cmxcbiAgICAgICAgICAgIExvZy5lcnJvcihlcnJvciwgZSlcbiAgICAgICAgICAgIHJlamVjdChlcnJvcilcbiAgICAgICAgICB9KVxuICAgICAgfVxuICAgIH1cbiAgfSlcbn1cblxuZXhwb3J0IGRlZmF1bHQge1xuICB0cmFuc2xhdGUoa2V5KSB7XG4gICAgbGV0IHJlcGxhY2VtZW50cyA9IFsuLi5hcmd1bWVudHNdLnNsaWNlKDEpXG5cbiAgICAvLyBubyByZXBsYWNlbWVudHMgc28ganVzdCB0cmFuc2xhdGVkIHN0cmluZ1xuICAgIGlmIChyZXBsYWNlbWVudHMubGVuZ3RoID09PSAwKSB7XG4gICAgICByZXR1cm4gKGRpY3Rpb25hcnkgJiYgZGljdGlvbmFyeVtrZXldKSB8fCBrZXlcbiAgICB9IGVsc2Uge1xuICAgICAgaWYgKHJlcGxhY2VtZW50cy5sZW5ndGggPT09IDEgJiYgdHlwZW9mIHJlcGxhY2VtZW50c1swXSA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgcmVwbGFjZW1lbnRzID0gcmVwbGFjZW1lbnRzLnBvcCgpXG4gICAgICB9XG5cbiAgICAgIHJldHVybiBPYmplY3Qua2V5cyhcbiAgICAgICAgLy8gbWFwcyBhcnJheSBpbnB1dCB0byBhbiBvYmplY3QgezA6ICdpdGVtMScsIDE6ICdpdGVtMid9XG4gICAgICAgIEFycmF5LmlzQXJyYXkocmVwbGFjZW1lbnRzKSA/IE9iamVjdC5hc3NpZ24oe30sIHJlcGxhY2VtZW50cykgOiByZXBsYWNlbWVudHNcbiAgICAgICkucmVkdWNlKCh0ZXh0LCByZXBsYWNlbWVudEtleSkgPT4ge1xuICAgICAgICByZXR1cm4gdGV4dC5yZXBsYWNlKFxuICAg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4gICAgcmV0dXJuIHtcbiAgICAgIFBhZ2VzOiB7XG4gICAgICAgIGZvcmNlWkluZGV4Q29udGV4dDogdHJ1ZSxcbiAgICAgIH0sXG4gICAgICAvKipcbiAgICAgICAqIFRoaXMgaXMgYSBkZWZhdWx0IExvYWRpbmcgcGFnZSB0aGF0IHdpbGwgYmUgbWFkZSB2aXNpYmxlXG4gICAgICAgKiBkdXJpbmcgZGF0YS1wcm92aWRlciBvbigpIHlvdSBDQU4gb3ZlcnJpZGUgaW4gY2hpbGQtY2xhc3NcbiAgICAgICAqL1xuICAgICAgTG9hZGluZzoge1xuICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICB3OiAxOTIwLFxuICAgICAgICBoOiAxMDgwLFxuICAgICAgICBjb2xvcjogMHhmZjAwMDAwMCxcbiAgICAgICAgdmlzaWJsZTogZmFsc2UsXG4gICAgICAgIHpJbmRleDogOTksXG4gICAgICAgIExhYmVsOiB7XG4gICAgICAgICAgbW91bnQ6IDAuNSxcbiAgICAgICAgICB4OiA5NjAsXG4gICAgICAgICAgeTogNTQwLFxuICAgICAgICAgIHRleHQ6IHtcbiAgICAgICAgICAgIHRleHQ6ICdMb2FkaW5nLi4nLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgIH1cbiAgfVxuXG4gIHN0YXRpYyBfc3RhdGVzKCkge1xuICAgIHJldHVybiBbXG4gICAgICBjbGFzcyBMb2FkaW5nIGV4dGVuZHMgdGhpcyB7XG4gICAgICAgICRlbnRlcigpIHtcbiAgICAgICAgICB0aGlzLnRhZygnTG9hZGluZycpLnZpc2libGUgPSB0cnVlXG4gICAgICAgIH1cblxuICAgICAgICAkZXhpdCgpIHtcbiAgICAgICAgICB0aGlzLnRhZygnTG9hZGluZycpLnZpc2libGUgPSBmYWxzZVxuICAgICAgICB9XG4gICAgICB9LFxuICAgICAgY2xhc3MgV2lkZ2V0cyBleHRlbmRzIHRoaXMge1xuICAgICAgICAkZW50ZXIoYXJ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Lm9uKCdmaW5pc2gnLCAoKSA9PiB7XG4gICAgICBpZiAobykge1xuICAgICAgICBvLnZpc2libGUgPSBmYWxzZVxuICAgICAgfVxuICAgICAgcmVzb2x2ZSgpXG4gICAgfSlcbiAgfSlcbn1cblxuY29uc3QgY3Jvc3NGYWRlID0gKGksIG8pID0+IHtcbiAgcmV0dXJuIG5ldyBQcm9taXNlKHJlc29sdmUgPT4ge1xuICAgIGkucGF0Y2goe1xuICAgICAgYWxwaGE6IDAsXG4gICAgICB2aXNpYmxlOiB0cnVlLFxuICAgICAgc21vb3RoOiB7XG4gICAgICAgIGFscGhhOiBbMSwgeyBkdXJhdGlvbjogMC41LCBkZWxheTogMC4xIH1dLFxuICAgICAgfSxcbiAgICB9KVxuICAgIGlmIChvKSB7XG4gICAgICBvLnBhdGNoKHtcbiAgICAgICAgc21vb3RoOiB7XG4gICAgICAgICAgYWxwaGE6IFswLCB7IGR1cmF0aW9uOiAwLjUsIGRlbGF5OiAwLjMgfV0sXG4gICAgICAgIH0sXG4gICAgICB9KVxuICAgIH1cbiAgICAvLyByZXNvbHZlIG9uIHkgZmluaXNoXG4gICAgaS50cmFuc2l0aW9uKCdhbHBoYScpLm9uKCdmaW5pc2gnLCAoKSA9PiB7XG4gICAgICByZXNvbHZlKClcbiAgICB9KVxuICB9KVxufVxuXG5jb25zdCBtb3ZlT25BeGVzID0gKGF4aXMsIGRpcmVjdGlvbiwgaSwgbykgPT4ge1xuICBjb25zdCBib3VuZHMgPSBheGlzID09PSAneCcgPyAxOTIwIDogMTA4MFxuICByZXR1cm4gbmV3IFByb21pc2UocmVzb2x2ZSA9PiB7XG4gICAgaS5wYXRjaCh7XG4gICAgICBbYCR7YXhpc31gXTogZGlyZWN0aW9uID8gYm91bmRzICogLTEgOiBib3VuZHMsXG4gICAgICB2aXNpYmxlOiB0cnVlLFxuICAgICAgc21vb3RoOiB7XG4gICAgICAgIFtgJHtheGlzfWBdOiBbMCwgeyBkdXJhdGlvbjogMC40LCBkZWx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ICB9XG4gICAgdmFyIGRlYm91bmNlZCA9IGZ1bmN0aW9uIGRlYm91bmNlZCgpIHtcbiAgICAgICAgY29udGV4dCA9IHRoaXM7XG4gICAgICAgIGFyZ3MgPSBhcmd1bWVudHM7XG4gICAgICAgIHRpbWVzdGFtcCA9IERhdGUubm93KCk7XG4gICAgICAgIHZhciBjYWxsTm93ID0gaW1tZWRpYXRlICYmICF0aW1lb3V0O1xuICAgICAgICBpZiAoIXRpbWVvdXQpIHRpbWVvdXQgPSBzZXRUaW1lb3V0KGxhdGVyLCB3YWl0KTtcbiAgICAgICAgaWYgKGNhbGxOb3cpIHtcbiAgICAgICAgICAgIHJlc3VsdCA9IGZ1bmMuYXBwbHkoY29udGV4dCwgYXJncyk7XG4gICAgICAgICAgICBjb250ZXh0ID0gYXJncyA9IG51bGw7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9O1xuICAgIGRlYm91bmNlZC5jbGVhciA9IGZ1bmN0aW9uKCkge1xuICAgICAgICBpZiAodGltZW91dCkge1xuICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXQpO1xuICAgICAgICAgICAgdGltZW91dCA9IG51bGw7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIGRlYm91bmNlZC5mbHVzaCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICBpZiAodGltZW91dCkge1xuICAgICAgICAgICAgcmVzdWx0ID0gZnVuYy5hcHBseShjb250ZXh0LCBhcmdzKTtcbiAgICAgICAgICAgIGNvbnRleHQgPSBhcmdzID0gbnVsbDtcbiAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lb3V0KTtcbiAgICAgICAgICAgIHRpbWVvdXQgPSBudWxsO1xuICAgICAgICB9XG4gICAgfTtcbiAgICByZXR1cm4gZGVib3VuY2VkO1xufVxuXG5mdW5jdGlvbiBnZXRFdWNsaWRlYW5EaXN0YW5jZSh4QSwgeUEsIHhCLCB5Qikge1xuICAgIHZhciB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vXntJQ09OOiguKj8pP1xcfCguKj8pP30kL2c7XG4gICAgICAgIHZhciBiYWRnZVJlZ0V4ID0gL157QkFER0U6KC4qPyl9JC9nO1xuICAgICAgICB2YXIgbmV3bGluZVJlZ0V4ID0gL157TkVXTElORX0kL2c7XG4gICAgICAgIHZhciB0ZXh0UmVnRXggPSAvXntURVhUOiguKj8pP1xcfCguKj8pP30kL2c7XG4gICAgICAgIHZhciBzcGxpdFN0ciA9IHN0cmluZy5zcGxpdChNQVJLVVBfU1RSSU5HX1BBVFRFUk4pO1xuICAgICAgICBpZiAoc3BsaXRTdHIgJiYgc3BsaXRTdHIubGVuZ3RoKSB7XG4gICAgICAgICAgICBzcGxpdFN0ci5mb3JFYWNoKChpdGVtID0+IHtcbiAgICAgICAgICAgICAgICB2YXIgZm9ybWF0dGVkSXRlbSA9IGl0ZW07XG4gICAgICAgICAgICAgICAgdmFyIGJhZGdlID0gYmFkZ2VSZWdFeC5leGVjKGl0ZW0pO1xuICAgICAgICAgICAgICAgIHZhciBpY29uID0gaWNvblJlZ0V4LmV4ZWMoaXRlbSk7XG4gICAgICAgICAgICAgICAgdmFyIG5ld2xpbmUgPSBuZXdsaW5lUmVnRXguZXhlYyhpdGVtKTtcbiAgICAgICAgICAgICAgICB2YXIgdGV4dCA9IHRleHRSZWdFeC5leGVjKGl0ZW0pO1xuICAgICAgICAgICAgICAgIGlmIChiYWRnZSAmJiBiYWRnZVsxXSkge1xuICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRJdGVtID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgYmFkZ2U6IGJhZGdlWzFdXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpY29uICYmIGljb25bMV0pIHtcbiAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkSXRlbSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpY29uWzFdLFxuICAgICAgICAgICAgICAgICAgICAgICAgaWNvbjogaWNvblsyXSB8fCBpY29uWzFdXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChuZXdsaW5lKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvcm1hdHRlZEl0ZW0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBuZXdsaW5lOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0ZXh0ICYmIHRleHRbMV0pIHtcbiAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkSXRlbSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHQ6IHRleHRbMV0sXG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZTogdGV4dFsyXVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb250ZW50LnB1c2goZm9ybWF0dGVkSXRlbSk7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIGNvbnRlbnQ7XG59XG5cbmZ1bmN0aW9uIG1heCgpIHtcbiAgICBpZiAoIWFyZ3VtZW50cykge1xuICAgICAgICByZXR1cm47XG4gICAgfVxuICAgIHZhciBhcmdzID0gQXJyYXkuZnJvbShhcmd1bWVudHMpLmZpbHRlcigoYXJnID0+ICFpc05hTihhcmcpICYmIGFyZyAhPSBudWxsKSk7XG4gICAgaWYgKCFhcmdzLmxlbmd0aCkge1xuICAgICAgICByZXR1cm47XG4gICAgfVxuICAgIHJldHVybiBNYXRoLm1heCguLi5hcmdzKTtcbn1cblxuZnVuY3Rpb24gY3JlYXRlQ29uZGl0aW9uYWxaQ29udGV4dChjb21wb25lbnQsIHpPZmZzZXQpIHtcbiAgICBpZiAoIWNvbXBvbmVudC56SW5kZXggJiYgdHlwZW9mIHpPZmZzZXQgIT09IFwidW5kZWZpbmVkXCIgJiYgek9m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XRpb24ocHJvcCkuaXNSdW5uaW5nKCkpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgcHJldlZhbHVlS2V5ID0gXCJfX3dhdGNoUHJldlwiLmNvbmNhdChwcm9wKTtcbiAgICAgICAgICAgIHZhciBuZXh0VmFsdWUgPSBlbGVtZW50W3Byb3BdO1xuICAgICAgICAgICAgaWYgKG5leHRWYWx1ZSAhPT0gZWxlbWVudFtwcmV2VmFsdWVLZXldKSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudFtwcmV2VmFsdWVLZXldID0gbmV4dFZhbHVlO1xuICAgICAgICAgICAgICAgIGhhc0NoYW5nZWQgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgICAgIGlmIChoYXNDaGFuZ2VkKSB7XG4gICAgICAgICAgICBzaWRlRWZmZWN0KCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGluaXRpYWxPbkFmdGVyVXBkYXRlKSB7XG4gICAgICAgICAgICBpbml0aWFsT25BZnRlclVwZGF0ZShlbGVtZW50KTtcbiAgICAgICAgfVxuICAgIH0uYmluZCh0aGlzKTtcbiAgICByZXR1cm4gZWxlbWVudDtcbn1cblxuZnVuY3Rpb24gY29udmVydFRleHRBbGlnblRvRmxleEp1c3RpZnkoYWxpZ24pIHtcbiAgICBzd2l0Y2ggKGFsaWduKSB7XG4gICAgICBjYXNlIFwibGVmdFwiOlxuICAgICAgICByZXR1cm4gXCJmbGV4LXN0YXJ0XCI7XG5cbiAgICAgIGNhc2UgXCJjZW50ZXJcIjpcbiAgICAgICAgcmV0dXJuIFwiY2VudGVyXCI7XG5cbiAgICAgIGNhc2UgXCJyaWdodFwiOlxuICAgICAgICByZXR1cm4gXCJmbGV4LWVuZFwiO1xuXG4gICAgICBkZWZhdWx0OlxuICAgICAgICBjb25zb2xlLndhcm4oJ0V4cGVjdGVkIFwidGV4dEFsaWduXCIgdmFsd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AgICBub25lOiAwLFxuICAgICAgICBhbHBoYTE6IC4xLFxuICAgICAgICBhbHBoYTI6IC4zLFxuICAgICAgICBhbHBoYTM6IC41LFxuICAgICAgICBhbHBoYTQ6IC43LFxuICAgICAgICBhbHBoYTU6IC45XG4gICAgfSxcbiAgICBhbmltYXRpb246IHtcbiAgICAgICAgZHVyYXRpb246IHtcbiAgICAgICAgICAgIG5vbmU6IDAsXG4gICAgICAgICAgICB4ZmFzdDogLjEsXG4gICAgICAgICAgICBmYXN0OiAuMjUsXG4gICAgICAgICAgICBub3JtYWw6IC41LFxuICAgICAgICAgICAgc2xvdzogLjc1LFxuICAgICAgICAgICAgeHNsb3c6IC45XG4gICAgICAgIH0sXG4gICAgICAgIGRlbGF5OiB7XG4gICAgICAgICAgICBub25lOiAwLFxuICAgICAgICAgICAgeGZhc3Q6IC4wMSxcbiAgICAgICAgICAgIGZhc3Q6IC4wMjUsXG4gICAgICAgICAgICBub3JtYWw6IC4wNSxcbiAgICAgICAgICAgIHNsb3c6IC4wNzUsXG4gICAgICAgICAgICB4c2xvdzogLjA5XG4gICAgICAgIH0sXG4gICAgICAgIGV4cHJlc3NpdmU6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIGV4cHJlc3NpdmVFbnRyYW5jZToge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSxcbiAgICAgICAgZXhwcmVzc2l2ZUV4aXQ6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIHN0YW5kYXJkOiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9LFxuICAgICAgICBzdGFuZGFyZEVudHJhbmNlOiB7XG4gICAgICAgICAgICB0aW1pbmdGdW5jdGlvbjogXCJjdWJpYy1iZXppZXIoMCwgMCwgMSwgMSlcIixcbiAgICAgICAgICAgIGRlbGF5OiAwLFxuICAgICAgICAgICAgZHVyYXRpb246IC4yNVxuICAgICAgICB9LFxuICAgICAgICBzdGFuZGFyZEV4aXQ6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIHV0aWxpdHk6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljLWJlemllcigwLCAwLCAxLCAxKVwiLFxuICAgICAgICAgICAgZGVsYXk6IDAsXG4gICAgICAgICAgICBkdXJhdGlvbjogLjI1XG4gICAgICAgIH0sXG4gICAgICAgIHV0aWxpdHlFbnRyYW5jZToge1xuICAgICAgICAgICAgdGltaW5nRnVuY3Rpb246IFwiY3ViaWMtYmV6aWVyKDAsIDAsIDEsIDEpXCIsXG4gICAgICAgICAgICBkZWxheTogMCxcbiAgICAgICAgICAgIGR1cmF0aW9uOiAuMjVcbiAgICAgICAgfSxcbiAgICAgICAgdXRpbGl0eUV4aXQ6IHtcbiAgICAgICAgICAgIHRpbWluZ0Z1bmN0aW9uOiBcImN1YmljL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IDAsXG4gICAgICAgIHhzOiAyLFxuICAgICAgICBzbTogNCxcbiAgICAgICAgbWQ6IDgsXG4gICAgICAgIGxnOiAxNixcbiAgICAgICAgeGw6IDI0XG4gICAgfSxcbiAgICBzcGFjZXI6IHtcbiAgICAgICAgbm9uZTogMCxcbiAgICAgICAgeHhzOiAyLFxuICAgICAgICB4czogNCxcbiAgICAgICAgc206IDgsXG4gICAgICAgIG1kOiAxMCxcbiAgICAgICAgbGc6IDIwLFxuICAgICAgICB4bDogMzAsXG4gICAgICAgIHh4bDogNDAsXG4gICAgICAgIHh4eGw6IDUwXG4gICAgfSxcbiAgICBzdHJva2U6IHtcbiAgICAgICAgbm9uZTogMCxcbiAgICAgICAgc206IDIsXG4gICAgICAgIG1kOiA0LFxuICAgICAgICBsZzogNixcbiAgICAgICAgeGw6IDhcbiAgICB9LFxuICAgIHR5cG9ncmFwaHk6IHtcbiAgICAgICAgZGlzcGxheTE6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiA3NSxcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDg1LFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBkaXNwbGF5Mjoge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDUwLFxuICAgICAgICAgICAgbGluZUhlaWdodDogNjAsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGhlYWRsaW5lMToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDM1LFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogNDgsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGhlYWRsaW5lMjoge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDMwLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogNDAsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGhlYWRsaW5lMzoge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDI1LFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMzYsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGJvZHkxOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjUsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiMzAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA0MCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgYm9keTI6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyMixcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCIzMDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDMyLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBib2R5Mzoge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDIwLFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjMwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMzIsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIGJ1dHRvbjE6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyNSxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDMyLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBidXR0b24yOiB7XG4gICAgICAgICAgICBmb250RmFtaWx5OiBcIkFyaWFsXCIsXG4gICAgICAgICAgICBmb250U2l6ZTogMjAsXG4gICAgICAgICAgICBmb250U3R5bGU6IFwiNTAwXCIsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiAzMixcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246IFwibWlkZGxlXCIsXG4gICAgICAgICAgICB0ZXh0QmFzZWxpbmU6IFwiYm90dG9tXCJcbiAgICAgICAgfSxcbiAgICAgICAgY2FsbG91dDE6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyMCxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDMyLFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBjYXB0aW9uMToge1xuICAgICAgICAgICAgZm9udEZhbWlseTogXCJBcmlhbFwiLFxuICAgICAgICAgICAgZm9udFNpemU6IDE1LFxuICAgICAgICAgICAgZm9udFN0eWxlOiBcIjUwMFwiLFxuICAgICAgICAgICAgbGluZUhlaWdodDogMjQsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiBcIm1pZGRsZVwiLFxuICAgICAgICAgICAgdGV4dEJhc2VsaW5lOiBcImJvdHRvbVwiXG4gICAgICAgIH0sXG4gICAgICAgIHRhZzE6IHtcbiAgICAgICAgICAgIGZvbnRGYW1pbHk6IFwiQXJpYWxcIixcbiAgICAgICAgICAgIGZvbnRTaXplOiAyMCxcbiAgICAgICAgICAgIGZvbnRTdHlsZTogXCI1MDBcIixcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDI0LFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogXCJtaWRkbGVcIixcbiAgICAgICAgICAgIHRleHRCYXNlbGluZTogXCJib3R0b21cIlxuICAgICAgICB9LFxuICAgICAgICBmb290bm90ZTE6IHtcbiAgICAgICAgICAgIGZvbnRGYW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dW5jdGlvbigpIHtcbiAgICB2YXIgX3JlZjMgPSBfYXN5bmNUb0dlbmVyYXRvcigoZnVuY3Rpb24qKGZvbnRzKSB7XG4gICAgICAgIGlmIChkb2N1bWVudC5mb250cyAmJiBcImRlbGV0ZVwiIGluIGRvY3VtZW50LmZvbnRzKSB7XG4gICAgICAgICAgICBpZiAoIWN1c3RvbUZvbnRGYWNlcy5sZW5ndGgpIHJldHVybjtcbiAgICAgICAgICAgIGN1c3RvbUZvbnRGYWNlcyA9IGN1c3RvbUZvbnRGYWNlcy5maWx0ZXIoKGZvbnRGYWNlID0+IHtcbiAgICAgICAgICAgICAgICBpZiAoIWZvbnRzLmZpbmQoKGZvbnQgPT4gZm9udC5mYW1pbHkgPT09IGZvbnRGYWNlLmZhbWlseSkpKSB7XG4gICAgICAgICAgICAgICAgICAgIGxvZ2dlckluc3RhbmNlLmluZm8oXCJSZW1vdmluZyBmb250XCIsIGZvbnRGYWNlLmZhbWlseSk7XG4gICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmZvbnRzLmRlbGV0ZShmb250RmFjZSk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZm9udEZhY2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbG9nZ2VySW5zdGFuY2UuaW5mbyhcIlVuYWJsZSB0byByZW1vdmUgbWFudWFsbHktYWRkZWQgZm9udHNcIik7XG4gICAgICAgIH1cbiAgICB9KSk7XG4gICAgcmV0dXJuIGZ1bmN0aW9uIGNsZWFudXBGb250cyhfeCkge1xuICAgICAgICByZXR1cm4gX3JlZjMuYXBwbHkodGhpcywgYXJndW1lbnRzKTtcbiAgICB9O1xufSgpO1xuXG52YXIgVEhFTUVfS0VZX1JFUExBQ0VSID0ge1xuICAgIGZvbnRGY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gICAgICBsb2dnZXJJbnN0YW5jZS5pbmZvKFwiVW5hYmxlIHRvIGNvbnZlcnQgYmFzZTY0IGltYWdlIHRvIFVSTFwiKTtcbiAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgfVxufVxuXG5jbGFzcyBUaGVtZU1hbmFnZXIge1xuICAgIGNvbnN0cnVjdG9yKCkge1xuICAgICAgICB0aGlzLl9jYWNoZSA9IG5ldyBNYXA7XG4gICAgICAgIGlmICh0eXBlb2Ygd2luZG93ID09PSBcInVuZGVmaW5lZFwiKSByZXR1cm47XG4gICAgICAgIGlmICghd2luZG93LkxVSSkge1xuICAgICAgICAgICAgd2luZG93LkxVSSA9IHt9O1xuICAgICAgICB9XG4gICAgICAgIGlmICghd2luZG93LkxVSS50aGVtZU1hbmFnZXJJbnN0YW5jZXMpIHtcbiAgICAgICAgICAgIHdpbmRvdy5MVUkudGhlbWVNYW5hZ2VySW5zdGFuY2VzID0gWyB7XG4gICAgICAgICAgICAgICAgdGhlbWVNYW5hZ2VyOiB0aGlzLFxuICAgICAgICAgICAgICAgIGV2ZW50czogZXZlbnRzXG4gICAgICAgICAgICB9IF07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB3aW5kb3cuTFVJLnRoZW1lTWFuYWdlckluc3RhbmNlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aGVtZU1hbmFnZXI6IHRoaXMsXG4gICAgICAgICAgICAgICAgZXZlbnRzOiBldmVudHNcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9zZXRDYWNoZShrZXksIHBheWxvYWQpIHtcbiAgICAgICAgaWYgKHR5cGVvZiB3aW5kb3cgPT09IFwidW5kZWZpbmVkXCIpIHJldHVybjtcbiAgICAgICAgd2luZG93LkxVSS50aGVtZU1hbmFnZXJJbnN0YW5jZXMuZm9yRWFjaCgoX3JlZjQgPT4ge1xuICAgICAgICAgICAgdmFyIHt0aGVtZU1hbmFnZXI6IHRoZW1lTWF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0KHN1YlRoZW1lTmFtZSksIHtcbiAgICAgICAgICAgICAgICBvcmlnaW5hbDogdmFsdWUsXG4gICAgICAgICAgICAgICAgcmVzdWx0OiBzdWJUaGVtZVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAodHJpZ2dlclVwZGF0ZSkgX3RoaXMyLl9lbWl0KFwidGhlbWVVcGRhdGVcIi5jb25jYXQoc3ViVGhlbWVOYW1lKSk7XG4gICAgICAgICAgICByZXR1cm4gc3ViVGhlbWU7XG4gICAgICAgIH0pKSgpO1xuICAgIH1cbiAgICBfcmVmcmVzaFN1YlRoZW1lcygpIHtcbiAgICAgICAgWyAuLi50aGlzLl9jYWNoZS5rZXlzKCkgXS5mb3JFYWNoKChrZXkgPT4ge1xuICAgICAgICAgICAgaWYgKFwic3RyaW5nXCIgPT09IHR5cGVvZiBrZXkgJiYgaXNTdWJUaGVtZShrZXkpKSB7XG4gICAgICAgICAgICAgICAgdmFyIF9jYWNoZSA9IHRoaXMuX2NhY2hlLmdldChrZXkpO1xuICAgICAgICAgICAgICAgIGlmIChfY2FjaGUub3JpZ2luYWwpIHRoaXMudXBkYXRlU3ViVGhlbWUoa2V5LnJlcGxhY2UoL15zdWJUaGVtZS8sIFwiXCIpLCBfY2FjaGUub3JpZ2luYWwpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF9sb2FkRm9udHMoZm9udEFycmF5KSB7XG4gICAgICAgIHJldHVybiBfYXN5bmNUb0dlbmVyYXRvcigoZnVuY3Rpb24qKCkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICB5aWVsZCBmb250TG9hZGVyKGZvbnRBcnJheSk7XG4gICAgICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS5lcnJvcihcIlVuYWJsZSB0byBsb2FkIGZvbnQ6IFwiLmNvbmNhdChlcnIpKTtcbiAgICAgICAgICAgIH1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ICAgICAgICAgICBpZiAoT2JqZWN0Lmhhc093blByb3BlcnR5LmNhbGwodmFsdWUsIGspICYmIFRIRU1FX0tFWV9SRVBMQUNFUltrXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVwbGFjZW1lbnRbayAmJiBUSEVNRV9LRVlfUkVQTEFDRVJba11dID0gdmFsdWVba107XG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcmVwbGFjZW1lbnRba107XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdmFsdWUgPSByZXBsYWNlbWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciB7aXNJbWFnZTogaXNJbWFnZSwgbWltZVR5cGU6IG1pbWVUeXBlfSA9IGNoZWNrQmFzZTY0RW5jb2RlZEltYWdlKHZhbHVlKTtcbiAgICAgICAgICAgIGlmICh3aW5kb3cuVVJMICYmIHR5cGVvZiB3aW5kb3cuVVJMLmNyZWF0ZU9iamVjdFVSTCA9PT0gXCJmdW5jdGlvblwiICYmIGlzSW1hZ2UpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgYmxvYlVSTCA9IGJhc2U2NFRvQmxvYlVSTCh2YWx1ZSwgbWltZVR5cGUpO1xuICAgICAgICAgICAgICAgICAgICBiYXNlNjRDYWNoZS5wdXNoKGJsb2JVUkwpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gYmxvYlVSTDtcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIDIgPT09IHZhbHVlLmxlbmd0aCAmJiAhdmFsdWVbMF0udGFyZ2V0Q29tcG9uZW50ICYmIHZhbHVlWzBdLmxlbmd0aCAmJiB0eXBlb2YgdmFsdWVbMF0gPT09IFwic3RyaW5nXCIgJiYgdmFsdWVbMF0uc3Vic3RyKDAsIDEpID09PSBcIiNcIiAmJiB0eXBlb2YgdmFsdWVbMV0gPT09IFwibnVtYmVyXCIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2V0SGV4Q29sb3IodmFsdWVbMF0sIHZhbHVlWzFdKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoXCJleHRlbnNpb25zXCIgPT09IGtleSB8fCBcImZ1bmN0aW9uXCIgPT09IHR5cGVvZiB2YWx1ZSB8fCBcIm9iamVjdFwiID09PSB0eXBlb2YgdmFsdWUgJiYgdmFsdWUgIT09IG51bGwgJiYgXCJPYmplY3RcIiAhPT0gdmFsdWUuY29uc3RydWN0b3IubmFtZSAmJiAhQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICB0aGVtZUZ1bmN0aW9uc1trZXldID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChcInN0cmluZ1wiID09PSB0eXBlb2YgdmFsdWUgJiYgdmFsdWUuaW5jbHVkZXMoXCJ0aGVtZS5cIikpIHtcbiAgICAgICAgICAgICAgICB2YXIgdGhlbWVWYWx1ZSA9IGdldFZhbEZyb21PYmpQYXRoKHtcbiAgICAgICAgICAgICAgICAgICAgdGhlbWU6IHRoZW1lXG4gICAgICAgICAgICAgICAgfSwgdmFsdWUpO1xuICAgICAgICAgICAgICAgIGlmICh0aGVtZVZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGVtZVZhbHVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHZhciB2YWxpZENvbG9yID0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bmNhdChjdXJyLCAnXCIgaW5zdGVhZC4nKTtcbiAgICByZXR1cm4ge1xuICAgICAgICBnZXQoKSB7XG4gICAgICAgICAgICBjb25zb2xlLndhcm4oZGVwcmVjYXRpb25XYXJuaW5nKTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzW2N1cnJdO1xuICAgICAgICB9LFxuICAgICAgICBzZXQodmFsdWUpIHtcbiAgICAgICAgICAgIGNvbnNvbGUud2FybihkZXByZWNhdGlvbldhcm5pbmcpO1xuICAgICAgICAgICAgdGhpc1tjdXJyXSA9IHZhbHVlO1xuICAgICAgICB9XG4gICAgfTtcbn1cblxuZnVuY3Rpb24gd2l0aFVwZGF0ZXMoQmFzZSkge1xuICAgIHJldHVybiBjbGFzcyBleHRlbmRzIEJhc2Uge1xuICAgICAgICBzdGF0aWMgZ2V0IG5hbWUoKSB7XG4gICAgICAgICAgICByZXR1cm4gQmFzZS5uYW1lO1xuICAgICAgICB9XG4gICAgICAgIF9jb25zdHJ1Y3QoKSB7XG4gICAgICAgICAgICB2YXIgcHJvdG90eXBlID0gT2JqZWN0LmdldFByb3RvdHlwZU9mKHRoaXMpO1xuICAgICAgICAgICAgaWYgKCFwcm90b3R5cGUuX3dpdGhVcGRhdGVzSW5pdGlhbGl6ZWQpIHtcbiAgICAgICAgICAgICAgICB2YXIgcHJvcHMgPSB0aGlzLmNvbnN0cnVjdG9yLnByb3BlcnRpZXMgfHwgW107XG4gICAgICAgICAgICAgICAgcHJvcHMuZm9yRWFjaCgobmFtZSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBrZXkgPSBcIl9cIiArIG5hbWU7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkZXNjcmlwdG9yID0gZ2V0UHJvcGVydHlEZXNjcmlwdG9yJDEobmFtZSwga2V5KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHByb3RvdHlwZSwgbmFtZSwgZGVzY3JpcHRvcik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgdmFyIGFsaWFzUHJvcHMgPSB0aGlzLmNvbnN0cnVjdG9yLmFsaWFzUHJvcGVydGllcyB8fCBbXTtcbiAgICAgICAgICAgICAgICBhbGlhc1Byb3BzLmZvckVhY2goKGFsaWFzID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFsaWFzICYmIHR5cGVvZiBhbGlhcy5wcmV2ID09PSBcInN0cmluZ1wiICYmIHR5cGVvZiBhbGlhcy5jdXJyID09PSBcInN0cmluZ1wiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgZGVzY3JpcHRvciA9IGdldEFsaWFzUHJvcGVydHlEZXNjcmlwdG9yKGFsaWFzLnByZXYsIGFsaWFzLmN1cnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShwcm90b3R5cGUsIGFsaWFzLnByZXYsIGRlc2NyaXB0b3IpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIHByb3RvdHlwZS5fd2l0aFVwZGF0ZXNJbml0aWFsaXplZCA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl93aGVuRW5hYmxlZCA9IG5ldyBQcm9taXNlKChyZXNvbHZlID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLl93aGVuRW5hYmxlZFJlc29sdmVyID0gcmVzb2x2ZTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QgJi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ICAgICAgIHN1cGVyLl9kZXRhY2goKTtcbiAgICAgICAgICAgIHVwZGF0ZU1hbmFnZXIuZGVsZXRlUmVxdWVzdFVwZGF0ZSh0aGlzKTtcbiAgICAgICAgfVxuICAgICAgICByZXF1ZXN0VXBkYXRlKCkge1xuICAgICAgICAgICAgdmFyIGZvcmNlID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTtcbiAgICAgICAgICAgIGlmICh0aGlzLl9yZWFkeUZvclVwZGF0ZXMgfHwgZm9yY2UpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gdGhpcy5fdXBkYXRlKCk7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXN1bHQgPT09IFwib2JqZWN0XCIgJiYgcmVzdWx0ICE9PSBudWxsICYmIHJlc3VsdC5jYXRjaCkge1xuICAgICAgICAgICAgICAgICAgICByZXN1bHQuY2F0Y2goKGUgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmVycm9yKFwiYXN5bmNyb25vdXMgX3VwZGF0ZSgpIGVycm9yIGluICdcIi5jb25jYXQodGhpcy5jb25zdHJ1Y3Rvci5fX2NvbXBvbmVudE5hbWUsIFwiJ1wiKSwgdGhpcywgZSk7XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgbG9nUHJvcFRhYmxlKCkge1xuICAgICAgICAgICAgY29uc29sZS50YWJsZSh0aGlzLl9wcm9wVGFibGUpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBfcHJvcFRhYmxlKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29uc3RydWN0b3IucHJvcGVydGllcy5yZWR1Y2UoKChhY2MsIHByb3ApID0+IHtcbiAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSB0aGlzW3Byb3BdO1xuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwge30pO1xuICAgICAgICB9XG4gICAgfTtcbn1cblxuZnVuY3Rpb24gZ2V0UHJvcGVydHlEZXNjcmlwdG9yKHBhdGgpIHtcbiAgICByZXR1cm4ge1xuICAgICAgICBnZXQoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy50YWcocGF0aCk7XG4gICAgICAgIH0sXG4gICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgZW51bWVyYWJsZTogdHJ1ZVxuICAgIH07XG59XG5cbmZ1bmN0aW9uIHdpdGhUYWdzKEJhc2UpIHtcbiAgICByZXR1cm4gY2xhc3MgZXh0ZW5kcyBCYXNlIHtcbiAgICAgICAgc3RhdGljIGdldCBuYW1lKCkge1xuICAgICAgICAgICAgcmV0dXJuIEJhc2UubmFtZTtcbiAgICAgICAgfVxuICAgICAgICBfY29uc3RydWN0KCkge1xuICAgICAgICAgICAgdmFyIHByb3RvdHlwZSA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0aGlzKTtcbiAgICAgICAgICAgIGlmICghcHJvdG90eXBlLl93aXRoVGFnc0luaXRpYWxpemVkKSB7XG4gICAgICAgICAgICAgICAgdmFyIHRhZ3MgPSB0aGlzLmNvbnN0cnVjdG9yLnRhZ3MgfHwgW107XG4gICAgICAgICAgICAgICAgdGFncy5mb3JFYWNoKCh0YWcgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRhZyA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHtuYW1lOiBuYW1lLCBwYXRoOiBwYXRofSA9IHRhZztcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBuYW1lID0gdGFnO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBhdGggPSB0YWc7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdmFyIGtleSA9IFwiX1wiICsgbmFtZTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRlc2NyaXB0b3IgPSBnZXRQcm9wZXJ0eURlc2NyaXB0b3IocGF0aCk7XG4gICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShwcm90b3R5cGUsIGtleSwgZGVzY3JpcHRvcik7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIHByb3RvdHlwZS5fd2l0aFRhZ3NJbml0aWFsaXplZCA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdXBlci5fY29uc3RydWN0ICYmIHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICAgICAgfVxuICAgIH07XG59XG5cbmZ1bmN0aW9uIHdpdGhIYW5kbGVLZXkoQmFzZSkge1xuICAgIHJldHVybiBjbGFzcyBleHRlbmRzIEJhc2Uge1xuICAgICAgICBzdGF0aWMgZ2V0IG5hbWUoKSB7XG4gICAgICAgICAgICByZXR1cm4gQmFzZS5uYW1lO1xuICAgICAgICB9XG4gICAgICAgIF9oYW5kbGVLZXkoa2V5RXZlbnQpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9wcm9jZXNzRXZlbnQoa2V5RXZlbnQpO1xuICAgICAgICB9XG4gICAgICAgIF9oYW5kbGVLZXlSZWxlYXNlKGtleUV2ZW50KSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fcHJvY2Vzc0V2ZW50KGtleUV2ZW50LCBcIlJlbGVhc2VcIik7XG4gICAgICAgIH1cbiAgICAgICAgX3Byb2Nlc3NFdmVudChrZXlFdmVudCkge1xuICAgICAgICAgICAgdmFyIHN1ZmZpeCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogXCJcIjtcbiAgICAgICAgICAgIHZhciBrZXlNYXAgPSB0aGlzLnN0YWdlLmFwcGxpY2F0aW9uLl9fa2V5bWFwIHx8IHt9O1xuICAgICAgICAgICAgdmFyIGtleSA9IGtleU1hcFtrZXlFdmVudC5rZXlDb2RlXTtcbiAgICAgICAgICAgIGlmICgha2V5KSB7XG4gICAgICAgICAgICAgICAga2V5ID0ga2V5RXZlbnQua2V5O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGtleSAmJiB0eXBlb2YgdGhpc1tcIm9uXCIuY29uY2F0KGtleSkuY29uY2F0KHN1ZmZpeCldID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9pbnZva2VLZXlQYXlsb2FkQ2FsbGJhY2soa2V5ICsgc3VmZml4KTtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpc1tcIm9uXCIuY29uY2F0KGtleSkuY29uY2F0KHN1ZmZpeCldLmNhbGwodGhpcywgdGhpcywga2V5RXZlbnQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIF9pbnZva2VLZXlQYXlsb2FkQ2FsbGJhY2soa2V5KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5tZXRyaWNzUGF5bG9hZCAmJiB0eXBlb2YgY29udGV4dEluc3RhbmNlLmtleU1ldHJpY3NDYWxsYmFjayA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmtleU1ldHJpY3NDYWxsYmFjayhrZXksIHRoaXMubWV0cmljc1BheWxvYWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbn1cblxuZnVuY3Rpb24gd2l0aExheW91dChCYXNlKSB7XG4gICAgcmV0dXJuIGNsYXNzIGV4dGVuZHMgQmFzZSB7XG4gICAgICAgIF9jb25zdHJ1Y3QoKSB7XG4gICAgICAgICAgICBzdXBlci5fY29uc3RydWN0ICYmIHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICAgICAgICAgIHRoaXMuX3ByZXZpb3VzRGltZW5zaW9uRGF0YSA9IG51bGw7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IGl0ZW1MYXlvdXQoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5faXRlbUxheW91dDtcbiAgICAgICAgfVxuICAgICAgICBzZXQgaXRlbUxheW91dCh2KSB7XG4gICAgICAgICAgICB2YXIgY29tcG9uZW50TmFtZSA9IHRoaXMuY29uc3RydWN0b3IuX2NvbXBvbmVudE5hbWUgfHwgdGhpcy5jb25zdHJ1Y3Rvci5uYW1lO1xuICAgICAgICAgICAgdmFyIGl0ZW1MYXlvdXQ7XG4gICAgICAgICAgICBpZiAodikge1xuICAgICAgICAgICAgICAgIGl0ZW1MYXlvdXQgPSBKU09OLnBhcnNlKEpTT04uc3RyaW5naWZ5KHYsICgoaywgdikgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoayAhPT0gXCJjaXJjbGVcIiAmJiB2IDwgMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmVycm9yKFwiaXRlbUxheW91dCBmb3IgXCIuY29uY2F0KGNvbXBvbmVudE5hbWUsIFwiIHJlY2VpdmVkIGFuIGludmFsaWQgdmFsdWUgb2YgXCIpLmNvbmNhdCh2LCBcIiBmb3IgXCIpLmNvbmNhdChrKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoayA9PT0gXCJjaXJjbGVcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJvb2xlYW4odik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgICAgICAgICAgfSkpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghc3RyaW5naWZ5Q29tcGFyZSh0aGlzLl9pdGVtTGF5b3V0LCBpdGVtTGF5b3V0KSkge1xuICAgICAgICAgICAgICAgIGlmIChpdGVtTGF5b3V0ICYmICFpdGVtTGF5b3V0LnVwQ291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fb3JpZ2luYWxXID0gdGhpcy53O1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcmlnaW5hbEggPSB0aGlzLmg7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2l0ZW1MYXlvdXQgPSBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuX29yaWdpbmFsVyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGg6IHRoaXMuX29yaWdpbmFsSFxuICAgICAgICAgICAgICAgICAgICB9LCBpdGVtTGF5b3V0KTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9pdGVtTGF5b3V0ID0gaXRlbUxheW91dDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlSXRlbUxheW91dCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIF9hbGxvd1VwZGF0ZSgpIHtcbiAgICAgICAgICAgIHZhciB7dzogdyA9IFwiXCIsIGg6IGggPSBcIlwiLCBjaXJjbGU6IGNpcmNsZSA9IFwiXCIsIHJhdGlvWDogcmF0aW9YID0gXCJcIiwgcmF0aW9ZOiByYXRpb1kgPSBcIlwiLCB1cENvdW50OiB1cENvdW50ID0gXCJcIn0gPSB0aGlzLl9pdGVtTGF5b3V0IHx8IHt9O1xuICAgICAgICAgICAgdmFyIGxheW91dFN0cmluZyA9IE9iamVjdC52YWx1ZXMoY29udGV4dEluc3RhbmNlLnRoZW1lLmxheW91dCkuam9pbihcIlwiKSArIFwiXCIuY29uY2F0KHcpLmNvbmNhdChoKS5jb25jYXQoY2lyY2xlID8gMSA6IDApLmNvbmNhdChyYXRpb1gpLmNvbmNhdChyYXRpb1kpLmNvbmNhdCh1cENvdW50KTtcbiAgICAgICAgICAgIGlmIChsYXlvdXRTdHJpbmcgIT09IHRoaXMuX3ByZXZpb3VzRGltZW5zaW9uRGF0YSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3ByZXZpb3VzRGltZW5zaW9uRGF0YSA9IGxheW91dFN0cmluZztcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBfdXBkYXRlSXRlbUxheW91dCgpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fYWxsb3dVcGRhdGUoKSkgcmV0dXJuO1xuICAgICAgICAgICAgdmFyIHt3OiB3LCBoOiBofSA9IGdldERpbWVuc2lvbnModGhpcy50aGVtZSwgdGhpcy5faXRlbUxheW91dCk7XG4gICAgICAgICAgICBpZiAoaCB8fCB3KSB7XG4gICAgICAgICAgICAgICAgdmFyIHdpZHRoID0gY29udGV4dEluc3RhbmNlLnRoZW1lLmxheW91dC5zY3JlZW5XO1xuICAgICAgICAgICAgICAgIHZhciBoZWlnaHQgPSBjb250ZXh0SW5zdGFuY2UudGhlbWUubGF5b3V0LnNjcmVlbkg7XG4gICAgICAgICAgICAgICAgdmFyIGNhbGN1bGF0ZWRXaWR0aCA9IHcgfHwgaCAqICh3aWR0aCAvIGhlaWdodCk7XG4gICAgICAgICAgICAgICAgdmFyIGNhbGN1bGF0ZWRIZWlnaHQgPSBoIHx8IHcgKiAoaGVpZ2h0IC8gd2lkdGgpO1xuICAgICAgICAgICAgICAgIHRoaXMudyA9IHRoaXMuX2l0ZW1MYXlvdXQgJiYgdGhpcy5faXRlbUxheW91dC5jaXJjbGUgPyBjYWxjdWxhdGVkSGVpZ2h0IDogY2FsY3VsY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ciAodmFyIGtleSBpbiBvYmopIHtcbiAgICAgICAgaWYgKG9iai5oYXNPd25Qcm9wZXJ0eShrZXkpICYmIGlzUGxhaW5PYmplY3Qob2JqW2tleV0pKSB7XG4gICAgICAgICAgICByZW1vdmVFbXB0eU9iamVjdHMob2JqW2tleV0pO1xuICAgICAgICAgICAgaWYgKE9iamVjdC5rZXlzKG9ialtrZXldKS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqW2tleV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG9iajtcbn1cblxuZnVuY3Rpb24gY3JlYXRlU2hhcmVkUmVmZXJlbmNlcygpIHtcbiAgICB2YXIgb2JqID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTtcbiAgICB2YXIgc2Vlbk9iamVjdHMgPSBuZXcgTWFwO1xuICAgIGZ1bmN0aW9uIGhhc2gob2JqZWN0KSB7XG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShvYmplY3QsIE9iamVjdC5rZXlzKG9iamVjdCkuc29ydCgpKTtcbiAgICB9XG4gICAgZnVuY3Rpb24gcHJvY2VzcyhjdXJyZW50T2JqKSB7XG4gICAgICAgIGZvciAodmFyIGtleSBpbiBjdXJyZW50T2JqKSB7XG4gICAgICAgICAgICBpZiAoY3VycmVudE9iai5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gY3VycmVudE9ialtrZXldO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09IFwib2JqZWN0XCIgJiYgdmFsdWUgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlSGFzaCA9IGhhc2godmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoc2Vl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dGlvbiBzZWFyY2hOZXN0ZWRLZXlzKG9iaikge1xuICAgICAgICBpZiAodHlwZW9mIG9iaiA9PT0gXCJvYmplY3RcIiAmJiBvYmogIT09IG51bGwpIHtcbiAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBvYmopIHtcbiAgICAgICAgICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgICAgICAgICAgbmVzdGVkS2V5cy5wdXNoKGtleSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIGZ1bmN0aW9uIHNlYXJjaEZvcktleShvYmopIHtcbiAgICAgICAgaWYgKHR5cGVvZiBvYmogPT09IFwib2JqZWN0XCIgJiYgb2JqICE9PSBudWxsKSB7XG4gICAgICAgICAgICBmb3IgKHZhciBrZXkgaW4gb2JqKSB7XG4gICAgICAgICAgICAgICAgaWYgKG9iai5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChrZXkgPT09IGtleVRvRmluZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoTmVzdGVkS2V5cyhvYmpba2V5XSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzZWFyY2hGb3JLZXkob2JqW2tleV0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICBzZWFyY2hGb3JLZXkob2JqKTtcbiAgICByZXR1cm4gbmVzdGVkS2V5cztcbn1cblxudmFyIGdlbmVyYXRlU29sdXRpb24gPSBmdW5jdGlvbiBnZW5lcmF0ZVNvbHV0aW9uKF9yZWY3KSB7XG4gICAgdmFyIHtiYXNlOiBiYXNlID0ge30sIHRvbmU6IHRvbmUgPSB7fSwgbW9kZTogbW9kZSA9IHt9LCBkZWZhd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lcnNlXCIsIFwidW5mb2N1c2VkX2JyYW5kXCIsIFwiZm9jdXNlZF9uZXV0cmFsXCIsIFwiZm9jdXNlZF9pbnZlcnNlXCIsIFwiZm9jdXNlZF9icmFuZFwiLCBcImRpc2FibGVkX25ldXRyYWxcIiwgXCJkaXNhYmxlZF9pbnZlcnNlXCIsIFwiZGlzYWJsZWRfYnJhbmRcIiBdO1xuXG5mdW5jdGlvbiBlbmZvcmNlQ29udHJhY3QoaW5wdXRPYmopIHtcbiAgICB2YXIgcmVzdWx0ID0ge307XG4gICAgZm9yICh2YXIga2V5IG9mIFsgLi4uREVGQVVMVF9LRVlTLCAuLi5PYmplY3Qua2V5cyhpbnB1dE9iaikgXSkge1xuICAgICAgICBpZiAoIWlucHV0T2JqLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgIHZhciBmYWxsYmFja0tleSA9IERFRkFVTFRfS0VZUy5maW5kKChmYWxsYmFjayA9PiBpbnB1dE9iai5oYXNPd25Qcm9wZXJ0eShmYWxsYmFjaykpKTtcbiAgICAgICAgICAgIGlmIChmYWxsYmFja0tleSkge1xuICAgICAgICAgICAgICAgIHZhciBmYWxsYmFjayA9IGlucHV0T2JqW2ZhbGxiYWNrS2V5XTtcbiAgICAgICAgICAgICAgICByZXN1bHRba2V5XSA9IHR5cGVvZiBmYWxsYmFjayAhPT0gXCJvYmplY3RcIiA/IHt9IDogZmFsbGJhY2s7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJlc3VsdFtrZXldID0ge307XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIGlucHV0T2JqW2tleV0gIT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICByZXN1bHRba2V5XSA9IHt9O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXN1bHRba2V5XSA9IGlucHV0T2JqW2tleV07XG4gICA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BzdHlsZX0gPSBfcmVmODtcbiAgICAgICAgaWYgKHR5cGVvZiBzdHlsZSA9PT0gXCJvYmplY3RcIiAmJiAhc3R5bGUuYmFzZSAmJiAhc3R5bGUubW9kZSAmJiAhc3R5bGUudG9uZSAmJiAhc3R5bGUuZGVmYXVsdCkge1xuICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICBiYXNlOiBzdHlsZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHZhciB7YmFzZTogX2Jhc2UgPSB7fSwgbW9kZTogX21vZGUgPSB7fSwgdG9uZTogX3RvbmUgPSB7fX0gPSBzdHlsZTtcbiAgICAgICAgICAgIHZhciBjb21wb25lbnRDb25maWdEZWZhdWx0U3R5bGU7XG4gICAgICAgICAgICBpZiAoc3R5bGUpIHtcbiAgICAgICAgICAgICAgICB2YXIgZGVmYXVsdFN0eWxlID0gSlNPTi5wYXJzZShKU09OLnN0cmluZ2lmeShzdHlsZSkpO1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBkZWZhdWx0U3R5bGUuYmFzZTtcbiAgICAgICAgICAgICAgICBkZWxldGUgZGVmYXVsdFN0eWxlLnRvbmU7XG4gICAgICAgICAgICAgICAgZGVsZXRlIGRlZmF1bHRTdHlsZS5tb2RlO1xuICAgICAgICAgICAgICAgIGNvbXBvbmVudENvbmZpZ0RlZmF1bHRTdHlsZSA9IGRlZmF1bHRTdHlsZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgZGVmYXVsdFN0eWxlOiBjb21wb25lbnRDb25maWdEZWZhdWx0U3R5bGUgfHwge30sXG4gICAgICAgICAgICAgICAgYmFzZTogX2Jhc2UsXG4gICAgICAgICAgICAgICAgbW9kZTogX21vZGUsXG4gICAgICAgICAgICAgICAgdG9uZTogX3RvbmVcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9KSk7XG4gIC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byA/IGNvbXBvbmVudE9iaiA6IE9iamVjdC5nZXRQcm90b3R5cGVPZihwcm90byk7XG4gICAgICAgIGlmICgoKF9wcm90byA9IHByb3RvKSA9PT0gbnVsbCB8fCBfcHJvdG8gPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9wcm90by5jb25zdHJ1Y3RvcikgPT09IE9iamVjdCkgYnJlYWs7XG4gICAgICAgIGlmIChwcm90byAmJiB0eXBlb2YgcHJvdG8gPT09IFwib2JqZWN0XCIgJiYgcHJvdG8uaGFzT3duUHJvcGVydHkoXCJjb25zdHJ1Y3RvclwiKSkge1xuICAgICAgICAgICAgdmFyIHtzdHlsZTogY29tcG9uZW50Q29uZmlnU3R5bGV9ID0gZ2V0Q29tcG9uZW50Q29uZmlnKHByb3RvKTtcbiAgICAgICAgICAgIGlmIChPYmplY3Qua2V5cyhjb21wb25lbnRDb25maWdTdHlsZSB8fCB7fSkubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFzdHlsZU1hcC5oYXMoY29tcG9uZW50Q29uZmlnU3R5bGUpKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlTWFwLnNldChjb21wb25lbnRDb25maWdTdHlsZSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGU6IGNvbXBvbmVudENvbmZpZ1N0eWxlXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciB0aGVtZVN0eWxlID0gcHJvdG8uY29uc3RydWN0b3IuaGFzT3duUHJvcGVydHkoXCJfX3RoZW1lU3R5bGVcIikgJiYgcHJvdG8uY29uc3RydWN0b3IuX190aGVtZVN0eWxlO1xuICAgICAgICAgICAgaWYgKE9iamVjdC5rZXlzKHRoZW1lU3R5bGUgfHwge30pLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGlmICghc3R5bGVNYXAuaGFzKHRoZW1lU3R5bGUpKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlTWFwLnNldCh0aGVtZVN0eWxlLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZTogX29iamVjdFNwcmVhZCh7fSwgdGhlbWVTdHlsZSlcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgdGhlbWVTdHlsZSA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFzdHlsZU1hcC5oYXModGhlbWVTdHlsZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGVNYXAuc2V0KHRoZW1lU3R5bGUsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlOiB0aGVtZVN0eWxlXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBtaXhpblN0eWxlID0gcHJvdG8uY29uc3RydWN0b3IuaGFzT3duUHJvcGVydHkoXCJfX21peGluU3R5bGVcIikgJiYgcHJvdG8uY29uc3RydWN0b3IuX19taXhpblN0eWxlO1xuICAgICAgICAgICAgaWYgKE9iamVjdC5rZXlzKG1peGluU3R5bGUgfHwge30pLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGlmICghc3R5bGVNYXAuaGFzKG1peGluU3R5bGUpKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlTWFwLnNldChtaXhpblN0eWxlLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZTogbWl4aW5TdHlsZVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9IHdoaWxlIChwcm90byk7XG4gICAgdmFyIHVuaXF1ZVN0eWxlcyA9IEFycmF5LmZyb20oc3R5bGVNYXAudmFsdWVzKCkpO1xuICAgIHJldHVybi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Q7XG4gICAgICAgICAgICBpZiAoIXN0eWxlU291cmNlKSB7XG4gICAgICAgICAgICAgICAgc3R5bGVTb3VyY2UgPSBnZW5lcmF0ZUNvbXBvbmVudFN0eWxlU291cmNlKHtcbiAgICAgICAgICAgICAgICAgICAgYWxpYXM6IHRoaXMuY29tcG9uZW50LmNvbnN0cnVjdG9yLmFsaWFzU3R5bGVzLFxuICAgICAgICAgICAgICAgICAgICBpbmxpbmVTdHlsZTogdGhpcy5jb21wb25lbnQuX2NvbXBvbmVudExldmVsU3R5bGUsXG4gICAgICAgICAgICAgICAgICAgIHN0eWxlQ2hhaW46IGdldFN0eWxlQ2hhaW5NZW1vaXplZCh0aGlzLmNvbXBvbmVudCksXG4gICAgICAgICAgICAgICAgICAgIHRoZW1lOiB0aGlzLmNvbXBvbmVudC50aGVtZVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHRoaXMuX2FkZENhY2hlKFwic3R5bGVTb3VyY2VcIiwgc3R5bGVTb3VyY2UpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHN0eWxlID0gKF90aGlzJF9nZXRDYWNoZTIgPSB0aGlzLl9nZXRDYWNoZShcInN0eWxlX1wiLmNvbmNhdChtb2RlLCBcIl9cIikuY29uY2F0KHRvbmUpKSkgPT09IG51bGwgfHwgX3RoaXMkX2dldENhY2hlMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2dldENhY2hlMi5wYXlsb2FkO1xuICAgICAgICAgICAgaWYgKCFzdHlsZSkge1xuICAgICAgICAgICAgICAgIHN0eWxlID0gZ2VuZXJhdGVTdHlsZSh0aGlzLmNvbXBvbmVudCwgc3R5bGVTb3VyY2UpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2FkZENhY2hlKFwic3R5bGVfXCIuY29uY2F0KG1vZGUsIFwiX1wiKS5jb25jYXQodG9uZSksIHN0eWxlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXM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ICAgICBhbGxLZXlzLmZvckVhY2goKGtleSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBmaXJzdE9ialtrZXldID09PSBcIm9iamVjdFwiICYmIGZpcnN0T2JqW2tleV0gIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0W2tleV0gPSBtZXJnZU9iamVjdHNXaXRoU2Vjb25kRG9taW5hbnQoZmlyc3RPYmpba2V5XSwgc2Vjb25kT2JqW2tleV0gfHwge30pO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHNlY29uZE9ialtrZXldID09PSBcIm9iamVjdFwiICYmIHNlY29uZE9ialtrZXldICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdFtrZXldID0gbWVyZ2VPYmplY3RzV2l0aFNlY29uZERvbWluYW50KGZpcnN0T2JqW2tleV0gfHwge30sIHNlY29uZE9ialtrZXldKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZXN1bHRba2V5XSA9IHNlY29uZE9iai5oYXNPd25Qcm9wZXJ0eShrZXkpID8gc2Vjb25kT2JqW2tleV0gOiB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiBmaXJzdE9iajtcbiAgICB9XG59XG5cbmZ1bmN0aW9uIHdpdGhUaGVtZVN0eWxlcyhCYXNlKSB7XG4gICAgdmFyIG1peGluU3R5bGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHt9O1xuICAgIHJldHVybiBjbGFzcyBleHRlbmRzIEJhc2Uge1xuICAgICAgICBfY29uc3RydWN0KCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX3dpdGhUaGVtZVN0eWxlc1NldHVwQ29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5faFNldEJ5VXNlciA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5fd1NldEJ5VXNlciA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5fc3R5bGVNYW5hZ2VyID0gbmV3IFN0eWxlTWFuYWdlcih7XG4gICAgICAgICAgICAgICAgY29tcG9uZW50OiB0aGlzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlID0gdGhpcy5fc3R5bGVNYW5hZ2VyLnN0eWxlO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJvcERlZmF1bHRzKCk7XG4gICAgICAgICAgICB0aGlzLl9zdHlsZU1hbmFnZXIub24oXCJzdHlsZVVwZGF0ZVwiLCAoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0eWxlID0gdGhpcy5fc3R5bGVNYW5hZ2VyLnN0eWxlO1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByb3BEZWZhdWx0cygpO1xuICAgICAgICAgICAgICAgIHRoaXMucXVldWVUaGVtZVVwZGF0ZSgpO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgdGhpcy5fd2l0aFRoZW1lU3R5bGVzU2V0dXBDb21wbGV0ZSA9IHRydWU7XG4gICAgICAgICAgICBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgIH1cbiAgICAgICAgX3NldHVwKCkge1xuICAgICAgICAgICAgc3VwZXIuX3NldHVwICYmIHN1cGVyLl9zZXR1cCgpO1xuICAgICAgICAgICAgdGhpcy5fdGFyZ2V0U3ViVGhlbWUgPSBnZXRTdWJUaGVtZSh0aGlzKTtcbiAgICAgICAgICA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udENvbmZpZ1Byb3BzID0gdGhpcy5fc3R5bGVNYW5hZ2VyLnByb3BzICYmIEpTT04ucGFyc2UoSlNPTi5zdHJpbmdpZnkodGhpcy5fc3R5bGVNYW5hZ2VyLnByb3BzKSk7XG4gICAgICAgICAgICB0aGlzLl9fY29tcG9uZW50Q29uZmlnUHJvcHMgPSBwYXlsb2FkO1xuICAgICAgICB9XG4gICAgICAgIF9hdHRhY2goKSB7XG4gICAgICAgICAgICBzdXBlci5fYXR0YWNoKCk7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX3N0eWxlTWFuYWdlci5pc0FjdGl2ZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci5pbml0KHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIF9kZXRhY2goKSB7XG4gICAgICAgICAgICBzdXBlci5fZGV0YWNoKCk7XG4gICAgICAgICAgICB0aGlzLl9zdHlsZU1hbmFnZXIuZGVzdHJveSgpO1xuICAgICAgICB9XG4gICAgICAgIF91bmZvY3VzKCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX2lzRm9jdXNlZE1vZGUpIHRoaXMubW9kZSA9IFwidW5mb2N1c2VkXCI7XG4gICAgICAgICAgICBzdXBlci5fdW5mb2N1cygpO1xuICAgICAgICB9XG4gICAgICAgIF9mb2N1cygpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5faXNEaXNhYmxlZE1vZGUpIHRoaXMubW9kZSA9IFwiZm9jdXNlZFwiO1xuICAgICAgICAgICAgc3VwZXIuX2ZvY3VzKCk7XG4gICAgICAgIH1cbiAgICAgICAgX2NoZWNrRGltZW5zaW9uVXBkYXRlcygpIHtcbiAgICAgICAgICAgIHZhciBkaW1lbnNpb25VcGRhdGVSZXF1aXJlZCA9IGZhbHNlO1xuICAgICAgICAgICAgaWYgKCF0aGlzLl93U2V0QnlVc2VyICYmIHRoaXMuc3R5bGUudyAmJiB0aGlzLl93ICE9PSB0aGl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AgICAgfVxuICAgICAgICBzdGF0aWMgZ2V0IG5hbWUoKSB7XG4gICAgICAgICAgICByZXR1cm4gQmFzZS5uYW1lO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICAgICAgaWYgKCFzdXBlci5fX2NvbXBvbmVudE5hbWUpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJBIHZhbGlkIHN0YXRpYyBfX2NvbXBvbmVudE5hbWUgcHJvcGVydHkgaXMgcmVxdWlyZWQgZm9yIHRoZW1pbmcgdG8gd29yayBwcm9wZXJseS4gUGxlYXNlIGFkZCB0aGlzIHRvIHRoZSBcIi5jb25jYXQodGhpcy5jb25zdHJ1Y3Rvci5uYW1lLCBcIiBjbGFzcy5cIikpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHN1cGVyLl9fY29tcG9uZW50TmFtZTtcbiAgICAgICAgfVxuICAgICAgICBzdGF0aWMgZ2V0IF9fbWl4aW5TdHlsZSgpIHtcbiAgICAgICAgICAgIHJldHVybiBtaXhpblN0eWxlO1xuICAgICAgICB9XG4gICAgICAgIGdldCB0aGVtZSgpIHtcbiAgICAgICAgICAgIHZhciBzdWJUaGVtZSA9IHRoaXMuX3RhcmdldFN1YlRoZW1lICYmIGNvbnRleHRJbnN0YW5jZS5nZXRTdWJUaGVtZSh0aGlzLl90YXJnZXRTdWJUaGVtZSk7XG4gICAgICAgICAgICByZXR1cm4gc3ViVGhlbWUgfHwgY29udGV4dEluc3RhbmNlLnRoZW1lO1xuICAgICAgICB9XG4gICAgICAgIHNldCBzdHlsZSh2KSB7XG4gICAgICAgICAgICBpZiAoT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKHYpICE9PSBcIltvYmplY3QgT2JqZWN0XVwiKSB7XG4gICAgICAgICAgICAgICAgY29udGV4dEluc3RhbmNlLmVycm9yKFwic3R5bGUgbXVzdCBiZSBhbiBvYmplY3RcIik7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fY29tcG9uZW50TGV2ZWxTdHlsZSA9IHY7XG4gICAgICAgICAgICB0aGlzLl9zdHlsZU1hbmFnZXIuY2xlYXJTdHlsZUNhY2hlKCk7XG4gICAgICAgICAgICB0aGlzLl9zdHlsZU1hbmFnZXIudXBkYXRlKCk7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IHN0eWxlKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N0eWxlO1xuICAgICAgICB9XG4gICAgICAgIGdldCBfY29tcG9uZW50U3R5bGUoKSB7XG4gICAgICAgICAgICBjb250ZXh0SW5zdGFuY2UuaW5mbyhcIl9jb21wb25lbnRTdHlsZSB3aWxsIHNvb24gYmUgZGVwcmVjYXRlZC4gUGxlYXNlIHVzZSBDb21wb25lbnQuc3R5bGVcIik7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc3R5bGU7XG4gICAgICAgIH1cbiAgICAgICAgc2V0IHN0eWxlQ29uZmlnKHYpIHtcbiAgICAgICAgICAgIGNvbnRleHRJbnN0YW5jZS5pbmZvKFwic3R5bGUgY29uZmlnIGlzIGRlcHJlY2F0ZWQuIFBsZWFzZSB1c2Ugc3R5bGUgPSB7IGJhc2U6IHt9LCB0b25lOiB7fSwgbW9kZToge30gfVwiKTtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlQ29uZmlnID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci51cGRhdGUoKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgc3R5bGVDb25maWcoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc3R5bGVDb25maWc7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9jb21wb25lbnRDb25maWcoKSB7XG4gICAgICAgICAgICByZXR1cm4gZ2V0Q29tcG9uZW50Q29uZmlnKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBtb2RlKCkge1xuICAgICAgICAgICAgdmFyIF90aGlzJF9jb21wb25lbnRDb25maTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9tb2RlIHx8ICgoX3RoaXMkX2NvbXBvbmVudENvbmZpID0gdGhpcy5fY29tcG9uZW50Q29uZmlnKSA9PT0gbnVsbCB8fCBfdGhpcyRfY29tcG9uZW50Q29uZmkgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9jb21wb25lbnRDb25maS5tb2RlKSB8fCBcInVuZm9jdXNlZFwiO1xuICAgICAgICB9XG4gICAgICAgIHNldCBtb2RlKHYpIHtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdiAhPT0gXCJzdHJpbmdcIiB8fCB0aGlzLl9tb2RlID09PSB2KSByZXR1cm47XG4gICAgICAgICAgICB0aGlzLl9tb2RlID0gdjtcbiAgICAgICAgICAgIHZhciBldmVudCA9IHRoaXNbXCJvblwiLmNvbmNhdChjYXBpdGFsaXplRmlyc3RMZXR0ZXIodikpXTtcbiAgICAgICAgICAgIGlmIChldmVudCAmJiB0eXBlb2YgZXZlbnQgPT09IFwiZnVuY3Rpb25cIikgZXZlbnQuY2FsbCh0aGlzKTtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci51cGRhdGUoKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgdG9uZSgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl90b25lIHx8IHRoaXMuX2NvbXBvbmVudENvbmZpZy50b25lIHx8IFwibmV1dHJhbFwiO1xuICAgICAgICB9XG4gICAgICAgIHNldCB0b25lKHYpIHtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdiAhPT0gXCJzdHJpbmdcIiB8fCB0aGlzLl90b25lID09PSB2KSByZXR1cm47XG4gICAgICAgICAgICB0aGlzLl90b25lID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3N0eWxlTWFuYWdlci51cGRhdGUoKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgdygpIHtcbiAgICAgICAgICAgIHZhciBfdGhpcyRzdHlsZTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl93U2V0QnlVc2VyICYmIHRoaXMuX3cgfHwgKChfdGhpcyRzdHlsZSA9IHRoaXMuc3R5bGUpID09PSBudWxsIHx8IF90aGlzJHN0eWxlID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRzdHlsZS53KSB8fCAwO1xuICAgICAgICB9XG4gICAgICAgIHNldCB3KHYpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl93ID09PSB2KSByZXR1cm47XG4gICAgICAgICAgICBzdXBlci53ID0gdjtcbiAgICAgICAgICAgIHRoaXMuX3dTZXRCeVVzZXIgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGhlbWVDb21wb25lbnQoKTtcbiAgICAgICAgfVxuICAgICAgICBnZXQgaCgpIHtcbiAgICAgICAgICAgIHZhciBfdGhpcyRzdHlsZTI7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5faFNldEJ5VXNlciAmJiB0aGlzLl9oIHx8ICgoX3RoaXMkc3R5bGUyID0gdGhpcy5zdHlsZSkgPT09IG51bGwgfHwgX3RoaXMkc3R5bGUyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRzdHlsZTIuaCkgfHwgdGhpcy5faCB8fCAwO1xuICAgICAgICB9XG4gICAgICAgIHNldCBoKHYpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9oID09PSB2KSByZXR1cm47XG4gICAgICAgICAgICBzdXBlci5oID0gdjtcbiAgICAgICAgICAgIHRoaXMuX2hTZXRCeVVzZXIgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGhlbWVDb21wb25lbnQoKTtcbiAgICAgICAgfVxuICAgIH07XG59XG5cbnZhciBTVUZGSVggPSBcIl9fb3JpZ2luYWxcIjtcblxuZn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tcbiAgICAgICAgICAgICAgICBwcm90byA9IE9iamVjdC5nZXRQcm90b3R5cGVPZihwcm90byk7XG4gICAgICAgICAgICAgICAgaWYgKG51bGwgIT09IHByb3RvICYmIHR5cGVvZiBwcm90byA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByb3RvLmNvbnN0cnVjdG9yLl9fY29tcG9uZW50TmFtZSkgcHJvdG90eXBlQ2hhaW4uYWRkKHByb3RvLmNvbnN0cnVjdG9yLl9fY29tcG9uZW50TmFtZSk7XG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7fVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gd2hpbGUgKHByb3RvKTtcbiAgICAgICAgICAgIHRoaXMuX19wcm90b3R5cGVDaGFpbiA9IHByb3RvdHlwZUNoYWluO1xuICAgICAgICAgICAgcmV0dXJuIHByb3RvdHlwZUNoYWluO1xuICAgICAgICB9XG4gICAgICAgIGdldCBfZXh0ZW5zaW9ucygpIHtcbiAgICAgICAgICAgIHZhciBleHRlbnNpb25zID0gY29udGV4dEluc3RhbmNlICYmIGNvbnRleHRJbnN0YW5jZS50aGVtZSAmJiBjb250ZXh0SW5zdGFuY2UudGhlbWUuZXh0ZW5zaW9ucztcbiAgICAgICAgICAgIGlmICghZXh0ZW5zaW9ucyB8fCAhQXJyYXkuaXNBcnJheShleHRlbnNpb25zKSB8fCBBcnJheS5pc0FycmF5KGV4dGVuc2lvbnMpICYmICFleHRlbnNpb25zLmxlbmd0aCkgcmV0dXJuIFtdO1xuICAgICAgICAgICAgcmV0dXJuIGV4dGVuc2lvbnMuZmlsdGVyKChfcmVmMTEgPT4ge1xuICAgICAgICAgICAgICAgIHZhciB7dGFyZ2V0Q29tcG9uZW50OiB0YXJnZXRDb21wb25lbnQsIGV4dGVuc2lvbjogZXh0ZW5zaW9ufSA9IF9yZWYxMTtcbiAgICAgICAgICAgICAgICByZXR1cm4gKHR5cGVvZiB0YXJnZXRDb21wb25lbnQgPT09IFwic3RyaW5nXCIgfHwgQXJyYXkuaXNBcnJheSh0YXJnZXRDb21wb25lbnQpKSAmJiB0eXBlb2YgZXh0ZW5zaW9uID09PSBcImZ1bmN0aW9uXCI7XG4gICAgICAgICAgICB9KSkuc2xpY2UoKS5yZXZlcnNlKCkgfHwgW107XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9jb21wb25lbnRFeHRlbnNpb25zKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2V4dGVuc2lvbnMuZmlsdGVyKChfcmVmMTIgPT4ge1xuICAgICAgICAgICAgICAgIHZhciB7dGFyZ2V0Q29tcG9uZW50OiB0YXJnZXRDb21wb25lbnR9ID0gX3JlZjEyO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdGFyZ2V0Q29tcG9uZW50ID09PSBcInN0cmluZ1wiKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0YXJnZXRDb21wb25lbnQgPT09IHRoaXMuY29uc3RydWN0b3IuX19jb21wb25lbnROYW1lIHx8IHRoaXMuX3Byb3RvdHlwZUNoYWluLmhhcyh0YXJnZXRDb21wb25lbnQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheSh0YXJnZXRDb21wb25lbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0YXJnZXRDb21wb25lbnQuZmluZCgocGF0dGVybiA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0dGVybi5zdGFydHNXaXRoKFwiL1wiKSAmJiBwYXR0ZXJuLmVuZHNXaXRoKFwiL1wiKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBDb21wb25lbnRSZWdFeHAgPSBuZXcgUmVnRXhwKHBhdHRlcm4uc2xpY2UoMSwgLTEpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQXJyYXkuZnJvbSh0aGlzLl9wcm90b3R5cGVDaGFpbikuc29tZSgobmFtZSA9PiBDb21wb25lbnRSZWdFeHAudGVzdChuYW1lKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcHJvdG90eXBlQ2hhaW4uaGFzKHBhdHRlcm4pO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH0pKS5yZWR1Y2UoKChhY2MsIF9yZWYxMykgPT4ge1xuICAgICAgICAgICAgICAgIHZhciB7ZXh0ZW5zaW9uOiBleHRlbnNpb259ID0gX3JlZjEzO1xuICAgICAgICAgICAgICAgIGFjYy5wdXNoKGV4dGVuc2lvbik7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgICAgIH0pLCBbXSk7XG4gICAgICAgIH1cbiAgICAgICAgZ2V0IF9leHRlbnNpb25BcHBsaWVkKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2N1cnJlbnRDb21wb25lbnRFeHRlbnNpb25MZW5ndGggPT09IHRoaXMuX2FwcGxpZWRFeHRlbnNpb25MZW5ndGg7XG4gICAgICAgIH1cbiAgICAgICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgICAgIHRoaXMuX2FwcGxpZWRFeHRlbnNpb25MZW5ndGggPSAwO1xuICAgICAgICAgICAgdGhpcy5fZXh0ZW5kZWRMaXN0ID0ge307XG4gICAgICAgICAgICB0aGlzLl9leHRlbnNpb25JbnN0YW5jZSA9IHt9O1xuICAgICAgICAgICAgdGhpcy5fc2V0dXBFeHRlbnNpb25Cb3VuZCA9IHRoaXMuX3NldHVwRXh0ZW5zaW9uLmJpbmQodGhpcyk7XG4g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sYXNzO1xuICAgICAgICAgICAgICAgIHZhciBvcmlnaW5hbENvbXBvbmVudERlc2NyaXB0b3JzID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnMoT2JqZWN0LmdldFByb3RvdHlwZU9mKGluc3RhbmNlKSk7XG4gICAgICAgICAgICAgICAgT2JqZWN0LmtleXMob3JpZ2luYWxDb21wb25lbnREZXNjcmlwdG9ycykuZm9yRWFjaCgocHJvcCA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChbIFwiY29uc3RydWN0b3JcIiBdLmluY2x1ZGVzKHByb3ApKSByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgIGlmIChvcmlnaW5hbENvbXBvbmVudERlc2NyaXB0b3JzW3Byb3BdLmdldCB8fCBvcmlnaW5hbENvbXBvbmVudERlc2NyaXB0b3JzW3Byb3BdLnNldCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5kZWRbcHJvcF0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogXCJhY2Nlc3NvclwiXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgYWNjW3Byb3BdID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpc1twcm9wICsgU1VGRklYXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24gc2V0KHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpc1twcm9wICsgU1VGRklYXSA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBleHRlbmRlZFtwcm9wXSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFwibWV0aG9kXCJcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgYWNjW3Byb3BdID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIHZhbHVlKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbcHJvcCArIFNVRkZJWF0gJiYgdGhpc1twcm9wICsgU1VGRklYXSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICAgICAgfSksIHt9KTtcbiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzKGJhc2VQcm90bywgZXh0ZW5zaW9uT3ZlcnJpZGVzKTtcbiAgICAgICAgICAgIE9iamVjdC5zZXRQcm90b3R5cGVPZihiYXNlUHJvdG8sIHRoaXMpO1xuICAgICAgICAgICAgcmV0dXJuIGV4dGVuZGVkO1xuICAgICAgICB9XG4gICAgICAgIF9zZXRDb21wb25lbnRBbGlhc2VzKGFsaWFzT2JqKSB7XG4gICAgICAgICAgICBPYmplY3Qua2V5cyhhbGlhc09iaikuZm9yRWFjaCgocHJvcCA9PiB7XG4gICAgICAgICAgICAgICAgdGhpc1twcm9wICsgU1VGRklYXSA9IHRoaXNbcHJvcF07XG4gICAgICAgICAgICAgICAgaWYgKGFsaWFzT2JqW3Byb3BdLnR5cGUgPT09IFwibWV0aG9kXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpc1twcm9wXSA9IHRoaXMuX2V4dGVuc2lvbkluc3RhbmNlW3Byb3BdO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoYWxpYXNPYmpbcHJvcF0udHlwZSA9PT0gXCJhY2Nlc3NvclwiKSB7XG4gICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCBwcm9wLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBnZXQoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2V4dGVuc2lvbkluc3RhbmNlW3Byb3BdO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldCh2KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXh0ZW5zaW9uSW5zdGFuY2VbcHJvcF0gPSB2O1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG5jbGFzcyBCYXNlIGV4dGVuZHMgbG5nLkNvbXBvbmVudCB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkJhc2VcIjtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgdGhpcy5jb25zdHJ1Y3Rvci5fX2NvbXBvbmVudE5hbWU7XG4gICAgICAgIHRoaXMuc2tpcFBsaW5rbyA9IGZhbHNlO1xuICAgICAgICB0aGlzLmNlbnRlckluUGFyZW50ID0gZmFsc2U7XG4gICAgICAgIGlmICghdGhpcy5sb2FkZWQpIHRoaXMubG9hZGVkID0gUHJvbWlzZS5yZXNvbHZlKCk7XG4gICAgfVxuICAgIF9pbml0KCkge1xuICAgICAgICB0aGlzLnF1ZXVlUmVxdWVzdFVwZGF0ZSgpO1xuICAgIH1cbiAgICBfcmVzZXRMb2FkZWRQcm9taXNlKCkge1xu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biAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gY2IgPT4ge1xuICAgICAgICAgICAgdmFyIGZpbGVUeXBlID0gY2hlY2tGaWxlVHlwZShzcmMpO1xuICAgICAgICAgICAgc3dpdGNoIChmaWxlVHlwZSkge1xuICAgICAgICAgICAgICBjYXNlIFwiU1ZHXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZVN2ZyhjYiwgdGhpcy5zdGFnZSwgXCJkYXRhOmltYWdlL3N2Zyt4bWwsXCIuY29uY2F0KGVuY29kZVVSSUNvbXBvbmVudChzcmMpKSwgdywgaCk7XG5cbiAgICAgICAgICAgICAgY2FzZSBcIkJsb2JcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gaW1hZ2VMb2FkZXIoe1xuICAgICAgICAgICAgICAgICAgICBzcmM6IHNyY1xuICAgICAgICAgICAgICAgIH0sIGNiKTtcblxuICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnN0YWdlLnBsYXRmb3JtLmxvYWRTcmNUZXh0dXJlKHtcbiAgICAgICAgICAgICAgICAgICAgc3JjOiBzcmMsXG4gICAgICAgICAgICAgICAgICAgIGhhc0FscGhhOiBoYXNBbHBoYVxuICAgICAgICAgICAgICAgIH0sIGNiKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgZ2V0Tm9uRGVmYXVsdHMoKSB7XG4gICAgICAgIHZhciBvYmogPSBzdXBlci5nZXROb25EZWZhdWx0cygpO1xuICAgICAgICBpZiAodGhpcy5fc3JjKSB7XG4gICAgICAgICAgICBvYmouc3JjID0gdGhpcy5fc3JjO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBvYmo7XG4gICAgfVxufVxuXG5jbGFzcyBBcnR3b3JrIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiA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ZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgc3JjID0gdGhpcy5zcmNDYWxsYmFjayh7XG4gICAgICAgICAgICAgICAgY2xvc2VzdEFzcGVjdFJhdGlvOiB0aGlzLl9jbG9zZXN0U3VwcG9ydGVkQXNwZWN0UmF0aW8sXG4gICAgICAgICAgICAgICAgYXNwZWN0UmF0aW86IHRoaXMuX2FjdHVhbEFzcGVjdFJhdGlvLFxuICAgICAgICAgICAgICAgIHNyYzogdGhpcy5zcmMsXG4gICAgICAgICAgICAgICAgdzogdGhpcy53LFxuICAgICAgICAgICAgICAgIGg6IHRoaXMuaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHNyYyAmJiBzcmMudGhlbiA/IHNyYyA6IFByb21pc2UucmVzb2x2ZShzcmMpO1xuICAgIH1cbiAgICBnZXQgX2dyYWRpZW50UGF0Y2goKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBhbHBoYTogIXRoaXMuX0dyYWRpZW50ICYmIHRoaXMuc2hvdWxkU21vb3RoID8gLjAwMSA6IDEsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIGdyYWRpZW50Q29sb3I6IGdldFZhbGlkQ29sb3IodGhpcy5zdHlsZS5ncmFkaWVudENvbG9yKVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGg6IHRoaXMuaCArIDQsXG4gICAgICAgICAgICB0eXBlOiBHcmFkaWVudCxcbiAgICAgICAgICAgIHc6IHRoaXMudyArIDQsXG4gICAgICAgICAgICB4OiAtMixcbiAgICAgICAgICAgIHk6IC0yLFxuICAgICAgICAgICAgekluZGV4OiB0aGlzLmNvcmUuZmluZFpDb250ZXh0KCkuekluZGV4ICsgdGhpcy5zdHlsZS56SW5kZXhTZXQuZ3JhZGllbnRcbiAgICAgICAgfTtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgc3VwZXIuX2NvbnN0cnV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aGlzNS5fdXBkYXRlSW1hZ2UoKTtcbiAgICAgICAgICAgIF90aGlzNS5fdXBkYXRlRmlsbENvbG9yKCk7XG4gICAgICAgICAgICBfdGhpczUuX3VwZGF0ZUZvcmVncm91bmRJbWFnZSgpO1xuICAgICAgICAgICAgaWYgKCFfdGhpczUuc3JjKSB7XG4gICAgICAgICAgICAgICAgX3RoaXM1Ll9zaG93Q29tcG9uZW50KCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICB5aWVsZCBfdGhpczUuX2NvbXBvbmVudFNyYy5jb21wbGV0ZTtcbiAgICAgICAgICAgICAgICB5aWVsZCBfdGhpczUuX3VwZGF0ZUNlbnRlckltYWdlKCk7XG4gICAgICAgICAgICAgICAgX3RoaXM1Ll91cGRhdGVCbHVyKCk7XG4gICAgICAgICAgICAgICAgX3RoaXM1Ll9zaG93Q29tcG9uZW50KCk7XG4gICAgICAgICAgICAgICAgX3RoaXM1Ll91cGRhdGVTY2FsZSgpO1xuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgIF90aGlzNS5faGFuZGxlSW1hZ2VMb2FkRXJyb3IoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChfdGhpczUuc2hvdWxkU21vb3RoID09PSB1bmRlZmluZWQpIF90aGlzNS5zaG91bGRTbW9vdGggPSB0cnVlO1xuICAgICAgICB9KSkoKTtcbiAgICB9XG4gICAgX3VwZGF0ZVNjYWxlKCkge1xuICAgICAgICBpZiAodGhpcy5zaG91bGRTY2FsZSkge1xuICAgICAgICAgICAgdmFyIGltYWdlU2NhbGU7XG4gICAgICAgICAgICBzd2l0Y2ggKHR5cGVvZiB0aGlzLnN0eWxlLmltYWdlU2NhbGUpIHtcbiAgICAgICAgICAgICAgY2FzZSBcImZ1bmN0aW9uXCI6XG4gICAgICAgICAgICAgICAgaW1hZ2VTY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3RhbmNlLmVycm9yKFwiSW1hZ2UgXCIuY29uY2F0KHRoaXMuX3NyYywgXCIgZmFpbGVkIHRvIGxvYWRcIikpO1xuICAgICAgICBpZiAodGhpcy5mYWxsYmFja1NyYyAmJiB0aGlzLmZhbGxiYWNrU3JjICE9PSB0aGlzLnNyYykge1xuICAgICAgICAgICAgdGhpcy5zcmMgPSB0aGlzLmZhbGxiYWNrU3JjO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9zaG93Q29tcG9uZW50KCkge1xuICAgICAgICB0aGlzLnNtb290aCA9IHtcbiAgICAgICAgICAgIGFscGhhOiBbIDEsIHRoaXMuc3R5bGUuYW5pbWF0aW9uQ29tcG9uZW50RW50cmFuY2UgXVxuICAgICAgICB9O1xuICAgIH1cbiAgICBfdXBkYXRlRm9yZWdyb3VuZEltYWdlKCkge1xuICAgICAgICB2YXIgX3RoaXM2ID0gdGhpcztcbiAgICAgICAgcmV0dXJuIF9hc3luY1RvR2VuZXJhdG9yKChmdW5jdGlvbiooKSB7XG4gICAgICAgICAgICBpZiAoIV90aGlzNi5fZm9yZWdyb3VuZFNyYykge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpczYuX0ZvcmVncm91bmRJbWFnZSkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpczYucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgRm9yZWdyb3VuZEltYWdlOiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBmb3JlZ3JvdW5kSW1hZ2VQYXRjaCA9IHtcbiAgICAgICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICAgICAgeDogX3RoaXM2LncgLyAyLFxuICAgICAgICAgICAgICAgIHk6IF90aGlzNi5oIC8gMixcbiAgICAgICAgICAgICAgICB6SW5kZXg6IF90aGlzNi5jb3JlLmZpbmRaQ29udGV4dCgpLnpJbmRleCArIF90aGlzNi5zdHlsZS56SW5kZXhTZXQuZm9yZWdyb3VuZCxcbiAgICAgICAgICAgICAgICB0ZXh0dXJlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEN1c3RvbUltYWdlVGV4dHVyZSxcbiAgICAgICAgICAgICAgICAgICAgc3JjOiBfdGhpczYuX2ZvcmVncm91bmRTcmMsXG4gICAgICAgICAgICAgICAgICAgIGhhc0FscGhhOiB0cnVlXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmIChfdGhpczYuZm9yZWdyb3VuZFdpZHRoICYmIF90aGlzNi5mb3JlZ3JvdW5kSGVpZ2h0KSB7XG4gICAgICAgICAgICAgICAgZm9yZWdyb3VuZEltYWdlUGF0Y2guaCA9IF90aGlzNi5mb3JlZ3JvdW5kSGVpZ2h0O1xuICAgICAgICAgICAgICAgIGZvcmVncm91bmRJbWFnZVBhdGNoLncgPSBfdGhpczYuZm9yZWdyb3VuZFdpZHRoO1xuICAgICAgICAgICAgICAgIF90aGlzNi5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIEZvcmVncm91bmRJbWFnZTogZm9yZWdyb3VuZEltYWdlUGF0Y2hcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoX3RoaXM2LmZvcmVncm91bmRXaWR0aCB8fCBfdGhpczYuZm9yZWdyb3VuZEhlaWdodCkge1xuICAgICAgICAgICAgICAgIF90aGlzNi5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIEZvcmVncm91bmRJbWFnZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBmb3JlZ3JvdW5kSW1hZ2VQYXRjaCksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogLjAwMVxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH0pO1xuIC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zLl9JbWFnZS50ZXh0dXJlICYmIHRoaXMuX0ltYWdlLnRleHR1cmUuc3JjID09PSB0aGlzLmZhbGxiYWNrU3JjKSAmJiB0aGlzLl9CbHVyKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5zaG91bGRTbW9vdGgpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9CbHVyLl9nZXRUcmFuc2l0aW9uKFwiYWxwaGFcIikub25jZShcImZpbmlzaFwiLCAoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIEJsdXI6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgdGhpcy5fQmx1ci5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiBbIDAsIHRoaXMuc3R5bGUuYW5pbWF0aW9uQmx1ckV4aXQgXVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBCbHVyOiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX3NyY0ZhaWxlZCAmJiB0aGlzLl9zaG91bGRCbHVyKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBCbHVyOiB7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiAhdGhpcy5fQmx1ciAmJiB0aGlzLnNob3VsZFNtb290aCA/IC4wMDEgOiAxLFxuICAgICAgICAgICAgICAgICAgICBhbW91bnQ6IHRoaXMuc3R5bGUuYmx1cixcbiAgICAgICAgICAgICAgICAgICAgekluZGV4OiB0aGlzLmNvcmUuZmluZFpDb250ZXh0KCkuekluZGV4ICsgdGhpcy5zdHlsZS56SW5kZXhTZXQuYmx1cixcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgSW1hZ2U6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLmgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dHVyZTogdGhpcy5fSW1hZ2UuZ2V0VGV4dHVyZSgpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHc6IHRoaXMud1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLmgsXG4gICAgICAgICAgICAgICAgICAgIHJ0dDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogbG5nLmNvbXBvbmVudHMuRmFzdEJsdXJDb21wb25lbnQsXG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMud1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaWYgKHRoaXMuX0JsdXIuYWxwaGEgPCAxKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fQmx1ci5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiBbIDEsIHRoaXMuc3R5bGUuYW5pbWF0aW9uQmx1ckVudHJhbmNlIF1cbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVDZW50ZXJJbWFnZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuZm9ybWF0ID09PSBcImNvbnRhaW5cIikge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlRm9ybWF0Q29udGFpbigpO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuZm9ybWF0ID09PSBcImNpcmNsZVwiIHx8IHRoaXMuZm9ybWF0ID09PSBcInNxdWFyZVwiKSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVGb3JtYXRTcXVhcmVDaXJjbGUoKTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9DZW50ZXJJbWFnZSkge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgQ2VudGVySW1hZ2U6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUZvcm1hdENvbnRhaW4oKSB7XG4gICAgICAgIHZhciBfdGhpczcgPSB0aGlzO1xuICAgICAgICByZXR1cm4gX2FzeW5jVG9HZW5lcmF0b3IoKGZ1bmN0aW9uKigpIHtcbiAgICAgICAgICAgIGlmIChfdGhpczcuX0NlbnRlckltYWdlICYmIF90aGlzNy5fQ2VudGVySW1hZ2UubW9kZSAhPT0gX3RoaXM3LmZvcm1hdCB8fCBfdGhpczcuc3JjID09PSBfdGhpczcuZmFsbGJhY2tTcmMgfHwgX3RoaXM3Ll9hc3BlY3RSYXRpb0VxdWFsKSB7XG4gICAgICAgICAgICAgICAgX3RoaXM3LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgQ2VudGVySW1hZ2U6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGlmIChfdGhpczcuc3JjID09PSBfdGhpczcuZmFsbGJhY2tTcmMgfHwgX3RoaXM3Ll9hc3BlY3RSYXRpb0VxdWFsKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzNy5fSW1hZ2UuYWxwaGEgPSAxO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGltYWdlVztcbiAgICAgICAgICAgIHZhciBpbWFnZUg7XG4gICAgICAgICAgICB2YXIgcmF0aW9XID0gTWF0aC5hYnMoX3RoaXM3Ll9JbWFnZS50ZXh0dXJlLnNvdXJjZS53IC8gX3RoaXM3Ll9JbWFnZS50ZXh0dXJlLnNvdXJjZS5oKTtcbiAgICAgICAgICAgIHZhciByYXRpb0ggPSBNYXRoLmFicyhfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLmggLyBfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLncpO1xuICAgICAgICAgICAgaWYgKF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UudyA8IF90aGlzNy5fSW1hZ2UudGV4dHVyZS5zb3VyY2UuaCkge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpczcuaCAqIHJhdGlvVyA8IF90aGlzNy53KSB7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlVyA9IF90aGlzNy5oICogcmF0aW9XO1xuICAgICAgICAgICAgICAgICAgICBpbWFnZUggPSBfdGhpczcuaDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBpbWFnZVcgPSBfdGhpczcudztcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2VIID0gX3RoaXM3LncgKiByYXRpb0g7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmIChfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLncgPiBfdGhpczcuX0ltYWdlLnRleHR1cmUuc291cmNlLmgpIHtcbiAgICAgICAgICAgICAgICBpZiAoX3RoaXM3LncgKiByYXRpb0ggPCBfdGhpczcuaCkge1xuICAgICAgICAgICAgICAgICAgICBpbWFnZVcgPSBfdGhpczcudztcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2VIID0gX3RoaXM3LncgKiByYXRpb0g7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaW1hZ2VXID0gX3RoaXM3LmggKiByYXRpb1c7XG4gICAgICAgICAgICAgICAgICAgIGltYWdlSCA9IF90aGlzNy5oO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaW1hZ2VXID0gTWF0aC5taW4oX3RoaXM3LncsIF90aGlzNy5oKTtcbiAgICAgICAgICAgICAgICBpbWFnZUggPSBpbWFnZVc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgc3JjID0geWllbGQgX3RoaXM3Ll9wcm9jZXNzZWRJbWFnZVNyYztcbiAgICAgICAgICAgIF90aGlzNy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgQ2VudGVySW1hZ2U6IHtcbiAgICAgICAgICAgICAgICAgICAgZm9ybWF0OiBfdGhpczcuZm9ybWF0LFxuICAgICAgICAgICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICAgICAgICAgIHc6IGltYWdlVyxcbiAgICAgICAgICAgICAgICAgICAgaDogaW1hZ2VILFxuICAgICAgICAgICAgICAgICAgICB4OiBfdGhpczcudyAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHk6IF90aGlzNy5oIC8gMixcbiAgICAgICAgICAgICAgICAgICAgekluZGV4OiBfdGhpczcuY29yZS5maW5kWkNvbnRleHQoKS56SW5kZXggKyBfdGhpczcuc3R5bGUuekluZGV4U2V0LmNlbnRlckltYWdlLFxuICAgICAgICAgICAgICAgICAgICB0ZXh0dXJlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzcmM6IHNyYyxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2l6ZU1vZGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoOiBpbWFnZUgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogXCJjb3ZlclwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHc6IGltYWdlV1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IEN1c3RvbUltYWdlVGV4dHVyZVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pKSgpO1xuICAgIH1cbiAgICBfdXBkYXRlRm9ybWF0U3F1YXJlQ2lyY2xlKCkge1xuICAgICAgICBpZiAodGhpcy5fQ2VudGVySW1hZ2UgJiYgdGhpcy5fQ2VudGVySW1hZ2UubW9kZSAhPT0gdGhpcy5mb3JtYXQgfHwgdGhpcy5zcmMgPT09IHRoaXMuZmFsbGJhY2tTcmMpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIENlbnRlckltYWdlOiB1bmRlZmluZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaWYgKHRoaXMuc3JjID09PSB0aGlzLmZhbGxiYWNrU3JjKSByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGltYWdlU2l6ZSA9IE1hdGgubWluKHRoaXMudywgdGhpcy5oKSAtIHRoaXMuc3R5bGUucGFkZGluZyAqIDI7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgQ2VudGVySW1hZ2U6IHtcbiAgICAgICAgICAgICAgICBmb3JtYXQ6IHRoaXMuZm9ybWF0LFxuICAgICAgICAgICAgICAgIGg6IGltYWdlU2l6ZSxcbiAgICAgICAgICAgICAgICBzaGFkZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgcmFkaXVzOiBcImNpcmNsZVwiID09PSB0aGlzLmZvcm1hdCA/IGltYWdlU2l6ZSAvIDIgOiB0aGlzLnN0eWxlLmNlbnRlckltYWdlUmFkaXVzLFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBsbmcuc2hhZGVycy5Sb3VuZGVkUmVjdGFuZ2xlXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB3OiBpbWFnZVNpemUsXG4gICAgICAgICAgICAgICAgekluZGV4OiB0aGlzLmNvcmUuZmluZFpDb250ZXh0KCkuekluZGV4ICsgdGhpcy5zdHlsZS56SW5kZXhTZXQuY2VudGVySW1hZ2UsXG4gICAgICAgICAgICAgICAgSW1hZ2U6IHtcbiAgICAgICAgICAgICAgICAgICAgaDogaW1hZ2VTaXplLFxuICAgICAgICAgICAgICAgICAgICBtb3VudDogLjUsXG4gICAgICAgICAgICAgICAgICAgIHJ0dDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgdzogaW1hZ2VTaXplLFxuICAgICAgICAgICAgICAgICAgICB4OiB0aGlzLncgLyAyLFxuICAgICAgICAgICAgICAgICAgICB5OiB0aGlzLmggLyAyLFxuICAgICAgICAgICAgICAgICAgICB0ZXh0dXJlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzcmM6IHRoaXMuX0ltYWdlLnRleHR1cmUuc3JjLFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzaXplTW9kZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IGltYWdlU2l6ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBcImNvdmVyXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdzogaW1hZ2VTaXplXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogQ3VzdG9tSW1hZ2VUZXh0dXJlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlR3JhZGllbnQoKSB7XG4gICAgICAgIGlmICghdGhpcy5ncmFkaWVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX0dyYWRpZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc2hvdWxkU21vb3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX0dyYWRpZW50Ll9nZXRUcmFuc2l0aW9uKFwiYWxwaGFcIikub25jZShcImZpbmlzaFwiLCAoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zaXRpb24gPSB0aGlzLl9HcmFkaWVudCAmJiB0aGlzLl9HcmFkaWVudC5fZ2V0VHJhbnNpdGlvbihcImFscGhhXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmdyYWRpZW50ICYmIHRyYW5zaXRpb24gJiYgdHJhbnNpdGlvbi5wID09PSAxKSB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBHcmFkaWVudDogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9HcmFkaWVudC5wYXRjaCh0aGlzLl9ncmFkaWVudFBhdGNoKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fR3JhZGllbnQuc21vb3RoID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgYWxwaGE6IFsgMCwgdGhpcy5zdHlsZS5hbmltYXRpb25HcmFkaWVudEV4aXQgXVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgR3JhZGllbnQ6IHVuZGVmaW5lZFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fY3JlYXRlR3JhZGllbnQoKTtcbiAgICB9XG4gICAgX2NyZWF0ZUdyYWRpZW50KCkge1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIEdyYWRpZW50OiB0aGlzLl9ncmFkaWVudFBhdGNoXG4gICAgICAgIH0pO1xuICAgICAgICBpZiAodGhpcy5zaG91bGRTbW9vdGgpIHtcbiAgICAgICAgICAgIHRoaXMuYXBwbHlTbW9vdGgodGhpcy5fR3JhZGllbnQsIHtcbiAgICAgICAgICAgICAgICBhbHBoYTogWyAxLCB0aGlzLnN0eWxlLmFuaW1hdGlvbkdyYWRpZW50RW50cmFuY2UgXVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUltYWdlKCkge1xuICAgICAgICB2YXIgX3RoaXM4ID0gdGhpcztcbiAgICAgICAgcmV0dXJuIF9hc3luY1RvR2VuZXJhdG9yKChmdW5jdGlvbiooKSB7XG4gICAgICAgICAgICBfdGhpczguX2FzcGVjdFJhdGlvRXF1YWwgPSBmYWxzZTtcbiAgICAgICAgICAgIGlmICghX3RoaXM4Ll9wcm9jZXNzZWRJbWFnZVNyYykge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpczguX0ltYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzOC5fSW1hZ2UudGV4dHVyZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHNyYyA9IHlpZWxkIF90aGlzOC5fcHJvY2Vzc2VkSW1hZ2VTcmM7XG4gICAgICAgICAgICBfdGhpczguX0ltYWdlLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBhbHBoYTogX3RoaXM4LnNyYyAhPT0gX3RoaXM4LmZhbGxiYWNrU3JjICYmIChfdGhpczguX2JsdXIgfHwgX3RoaXM4Ll9oYXNDZW50ZXJJbWFnZSkgPyAuMDAxIDogMSxcbiAgICAgICAgICAgICAgICBoOiBfdGhpczguaCxcbiAgICAgICAgICAgICAgICB0ZXh0dXJlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEN1c3RvbUltYWdlVGV4dHVyZSxcbiAgICAgICAgICAgICAgICAgICAgc3JjOiBzcmMsXG4gICAgICAgICAgICAgICAgICAgIHJlc2l6ZU1vZGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFwiY292ZXJcIixcbiAgICAgICAgICAgICAgICAgICAgICAgIHc6IF90aGlzOC53LFxuICAgICAgICAgICAgICAgICAgICAgICAgaDogX3RoaXM4LmhcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgdzogX3RoaXM4LncsXG4gICAgICAgICAgICAgICAgekluZGV4OiBfdGhpczguY29yZS5maW5kWkNvbnRleHQoKS56SW5kZXggKyBfdGhpczguc3R5bGUuekluZGV4U2V0LmltYWdlXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSkpKCk7XG4gICAgfVxuICAgIF91cGRhdGVGaWxsQ29sb3IoKSB7XG4gICAgICAgIGlmICghdGhpcy5maWxsKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBGaWxsQ29sb3I6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBGaWxsQ29sb3I6IHtcbiAgICAgICAgICAgICAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy53LFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLmgsXG4gICAgICAgICAgICAgICAgICAgIGNvbG9yOiB0aGlzLnN0eWxlLmZpbGxDb2xvcixcbiAgICAgICAgICAgICAgICAgICAgekluZGV4OiA1XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVJhZGl1cygpIHtcbiAgICAgICAgdGhpcy5wYXRjaCh0aGlzLnN0eWxlLnJhZGl1cyA/IHtcbiAgICAgICAgICAgIHNoYWRlcjoge1xuICAgICAgICAgICAgICAgIHR5cGU6IGxuZy5zaGFkZXJzLlJv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xvci5zdHJva2VOZXV0cmFsU2Vjb25kYXJ5XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIGJhY2tncm91bmRDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWxTZWNvbmRhcnksXG4gICAgICAgIGljb25Db2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2UsXG4gICAgICAgIHRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVxuICAgICAgICB9LFxuICAgICAgICBzdHJva2VDb2xvcjogdGhlbWUuY29sb3Iuc3Ryb2tlSW52ZXJzZVNlY29uZGFyeVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5maWxsQnJhbmQsXG4gICAgICAgIGljb25Db2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWwsXG4gICAgICAgIHRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBzdHJva2VDb2xvcjogdGhlbWUuY29sb3Iuc3Ryb2tlSW52ZXJzZVNlY29uZGFyeVxuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJFAgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSRQLFxuICAgIHRvbmU6IHRvbmUkblxufSk7XG5cbmNsYXNzIEJhZGdlIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgVGV4dDoge1xuICAgICAgICAgICAgICAgIG1vdW50WTogLjVcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBJY29uOiB7XG4gICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAg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AgfVxuICAgIH1cbiAgICBfdXBkYXRlSWNvbigpIHtcbiAgICAgICAgdGhpcy5fSWNvbi5wYXRjaCh7XG4gICAgICAgICAgICBpY29uOiB0aGlzLmljb24sXG4gICAgICAgICAgICB3OiB0aGlzLmljb25XaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuaWNvbkhlaWdodCxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgY29sb3I6IGdldEhleENvbG9yKHRoaXMuc3R5bGUuaWNvbkNvbG9yKVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZVdpZHRoKCkge1xuICAgICAgICB2YXIgd2lkdGggPSAwO1xuICAgICAgICBpZiAodGhpcy50aXRsZSAmJiB0aGlzLmljb24pIHtcbiAgICAgICAgICAgIHdpZHRoID0gdGhpcy5fVGV4dC5yZW5kZXJXaWR0aCArIHRoaXMuX0ljb24uZmluYWxXICsgdGhpcy5zdHlsZS5jb250ZW50U3BhY2luZyArIHRoaXMuc3R5bGUucGFkZGluZ1ggKiAyO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMudGl0bGUpIHtcbiAgICAgICAgICAgIHdpZHRoID0gdGhpcy5fVGV4dC5yZW5kZXJXaWR0aCArIHRoaXMuc3R5bGUucGFkZGluZ1ggKiAyO1xuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaWNvbikge1xuICAgICAgICAgICAgd2lkdGggPSB0aGlzLl9JY29uLmZpbmFsVyArIHRoaXMuc3R5bGUucGFkZGluZ1ggKiAyO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMudyA9IHdpZHRoO1xuICAgIH1cbiAgICBfdXBkYXRlUG9zaXRpb25zKCkge1xuICAgICAgICB0aGlzLl9JY29uLnkgPSB0aGlzLmggLyAyO1xuICAgICAgICBpZiAodGhpcy5pY29uQWxpZ24gPT09IFwibGVmdFwiICYmIHRoaXMudGl0bGUgJiYgdGhpcy5pY29uKSB7X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GJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX2xhc3RTY3JvbGxJbmRleCA9IGxhc3RTY3JvbGxJbmRleDtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fbGFzdFNjcm9sbEluZGV4ID4gdGhpcy5pdGVtcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHRoaXMuX2xhc3RTY3JvbGxJbmRleCA9IHRoaXMuaXRlbXMubGVuZ3RoIC0gMTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfY2FsY0Nyb3NzRGltZW5zaW9uU2l6ZShjb21wKSB7XG4gICAgICAgIGlmICh0aGlzLl9pc1Jvdykge1xuICAgICAgICAgICAgcmV0dXJuIGdldEgoY29tcCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX2lzQ29sdW1uKSB7XG4gICAgICAgICAgICByZXR1cm4gZ2V0Vyhjb21wKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfY2FsY0F4aXNQb3NpdGlvbihjb21wKSB7XG4gICAgICAgIGlmICh0aGlzLl9pc1Jvdykge1xuICAgICAgICAgICAgcmV0dXJuIGdldFgoY29tcCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX2lzQ29sdW1uKSB7XG4gICAgICAgICAgICByZXR1cm4gZ2V0WShjb21wKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdHJhbnNpdGlvbkxpc3RlbmVyKCkge1xuICAgICAgICB0aGlzLnNob3VsZFNtb290aCA9IGZhbHNlO1xuICAgICAgICB0aGlzLnRyYW5zaXRpb25Eb25lKCk7XG4gICAgfVxuICAgIF93aXRoQWZ0ZXJVcGRhdGUoZWxlbWVudCkge1xuICAgICAgICByZXR1cm4gd2F0Y2hGb3JVcGRhdGVzKHtcbiAgICAgICAgICAgIGVsZW1lbnQ6IGVsZW1lbnQsXG4gICAgICAg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N0eWxlcygpIHtcbiAgICAgICAgcmV0dXJuIFsge1xuICAgICAgICAgICAgcHJldjogXCJpY29uSFwiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uSGVpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJpY29uV1wiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uV2lkdGhcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF9jb25zdHJ1Y3QoKSB7XG4gICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICAgICAgdGhpcy5fbWF4TGluZXNTdWZmaXggPSBcIi4uXCI7XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUNvbnRlbnQoKTtcbiAgICAgICAgdGhpcy5fd2FpdEZvckNvbXBvbmVudExvYWQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnQoKSB7XG4gICAgICAgIHRoaXMuY2hpbGRMaXN0LmNsZWFyKCk7XG4gICAgICAgIGlmICh0aGlzLl9zaG91bGRUcnVuY2F0ZSkge1xuICAgICAgICAgICAgdGhpcy5hbHBoYSA9IC4wMDE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuX3BhcnNlZENvbnRlbnQgJiYgdGhpcy5fcGFyc2VkQ29udGVudC5sZW5ndGgpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIGZsZXg6IHtcbiAgICAgICAgICAgICAgICAgICAgZGlyZWN0aW9uOiBcInJvd1wiLFxuICAgICAgICAgICAgICAgICAgICB3cmFwOiAhIXRoaXMuY29udGVudFdyYXAsXG4gICAgICAgICAgICAgICAgICAgIGp1c3RpZnlDb250ZW50OiB0aGlzLmp1c3RpZnkgIT0gdW5kZWZpbmVkID8gdGhpcy5qdXN0aWZ5IDogdGhpcy5zdHlsZS5qdXN0aWZ5XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB0aGlzLl9wYXJzZWRDb250ZW50LmZvckVhY2goKChpdGVtLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgICAgIHZhciBpc0xhc3QgPSBpbmRleCA9PT0gdGhpcy5fcGFyc2VkQ29udGVudC5sZW5ndGggLSAxO1xuICAgICAgICAgICAgICAgIHZhciBiYXNlID0ge1xuICAgICAgICAgICAgICAgICAgICBmbGV4SXRlbTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLmNvbnRlbnRQcm9wZXJ0aWVzKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hcmdpbkJvdHRvbTogaXNMYXN0ID8gMCA6IHRoaXMuX21hcmdpbkJvdHRvbSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hcmdpblJpZ2h0OiBpc0xhc3QgPyAwIDogdGhpcy5jb250ZW50UHJvcGVydGllcy5tYXJnaW5SaWdodCB8fCB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAoaXNUZXh0KGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBuZXh0SXRlbSA9IHRoaXMuX3BhcnNlZENvbnRlbnRbaW5kZXggKyAxXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5leHRJdGVtICYmIGlzVGV4dChuZXh0SXRlbSkgfHwgdGhpcy5jb250ZW50V3JhcCAmJiBuZXh0SXRlbSAmJiBuZXh0SXRlbS5uZXdsaW5lICYmIHRoaXMuX3BhcnNlZENvbnRlbnRbaW5kZXggKyAyXSAmJiBpc1RleHQodGhpcy5fcGFyc2VkQ29udGVudFtpbmRleCArIDJdKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgYmFzZS5mbGV4SXRlbS5tYXJnaW5SaWdodCA9IDA7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGlsZExpc3QuYSh0aGlzLl9jcmVhdGVUZXh0KGJhc2UsIGl0ZW0pKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzSWNvbihpdGVtKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKHRoaXMuX2NyZWF0ZUljb24oYmFzZSwgaXRlbSkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNCYWRnZShpdGVtKSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hKHRoaXMuX2NyZWF0ZUJhZGdlKGJhc2UsIGl0ZW0uYmFkZ2UpKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0ubmV3bGluZSAmJiB0aGlzLmNvbnRlbnRXcmFwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2hpbGRMaXN0LmEoe1xuICAgICAgICAgICAgICAgICAgICAgICAgaDogMCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHc6IHRoaXMud1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3dhaXRGb3JDb21wb25lbnRMb2FkKCkge1xuICAgICAgICBpZiAodGhpcy5jaGlsZHJlbi5sZW5ndGgpIHtcbiAgICAgICAgICAgIFByb21pc2UuYWxsKHRoaXMuY2hpbGRyZW4ubWFwKChjaGlsZCA9PiBuZXcgUHJvbWlzZSgocmVzb2x2ZSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkLmggPT09IDAgJiYgY2hpbGQudyA9PT0gdGhpcy53KSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc29sdmUoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZC5vbihcInR4TG9h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GljZShsaW5lLnN0YXJ0SW5kZXgsIGxpbmUuZW5kSW5kZXggKyAxKS5zb3J0KCgoYSwgYikgPT4gYlsxXS5oIC0gYVsxXS5oKSlbMF1bMV0uaDtcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLm11bHRpTGluZUhlaWdodCA9IHRvdGFsSGVpZ2h0O1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fc2hvdWxkVHJ1bmNhdGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlck1heExpbmVzKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbm90aWZ5QW5jZXN0b3JzKCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExvYWRlZCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pLCAxMCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9ub3RpZnlBbmNlc3RvcnMoKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfcmVuZGVyTWF4TGluZXMoKSB7XG4gICAgICAgIHZhciBjaGlsZHJlbkRpbWVuc2lvbnMgPSB0aGlzLl9jYWxjQ2hpbGRyZW5EaW1lbnNpb25zKCk7XG4gICAgICAgIHRoaXMuY2hpbGRMaXN0LmNsZWFyKCk7XG4gICAgICAgIHZhciByZW5kZXJlZExhc3RFbGVtZW50ID0gZmFsc2U7XG4gICAgICAgIGNoaWxkcmVuRGltZW5zaW9ucy5mb3JFYWNoKCgoY2hpbGQsIGluZGV4KSA9PiB7XG4gICAgICAgICAgICBpZiAocmVuZGVyZWRMYXN0RWxlbWVudCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBuZXh0Q2hpbGQgPSBjaGlsZ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ZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hZGQoY2hpbGQuY29tcG9uZW50KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKTtcbiAgICAgICAgdGhpcy5hbHBoYSA9IDE7XG4gICAgfVxuICAgIF9jYWxjQ2hpbGRyZW5EaW1lbnNpb25zKCkge1xuICAgICAgICB2YXIgc3VmZml4VyA9IG1lYXN1cmVUZXh0V2lkdGgoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICB0ZXh0OiB0aGlzLm1heExpbmVzU3VmZml4XG4gICAgICAgIH0pKTtcbiAgICAgICAgdmFyIGNvbnRlbnRFbmRYID0gMDtcbiAgICAgICAgdmFyIGxpbmUgPSAxO1xuICAgICAgICByZXR1cm4gdGhpcy5jaGlsZHJlbi5yZWR1Y2UoKChhY2MsIGNoaWxkKSA9PiB7XG4gICAgICAgICAgICB2YXIgY29tcG9uZW50ID0gY2hpbGQ7XG4gICAgICAgICAgICB2YXIgdHlwZSwgY29udGVudCwgdztcbiAgICAgICAgICAgIHZhciBpc05ld0xpbmVFbGVtZW50ID0gY2hpbGQudyA9PSB0aGlzLncgJiYgY2hpbGQuaCA9PT0gMDtcbiAgICAgICAgICAgIGlmIChpc05ld0xpbmVFbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgbGluZSsrO1xuICAgICAgICAgICAgICAgIGNvbnRlbnRFbmRYID0gMDtcbiAgICAgICAgICAgICAgICB2YXIgX2RhdGEgPSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFwibGluZWJyZWFrXCIsXG4gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudDogY29tcG9uZW50LFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBjb250ZW50LFxuICAgICAgICAgICAgICAgICAgICBsaW5lOiBsaW5lLFxuICAgICAgICAgICAgICAgICAgICBoYXNTcGFjZUZvclN1ZmZpeDogdHJ1ZVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgYWNjLnB1c2goX2RhdGEpO1xuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoaXNUZXh0KGNoaWxkKSkge1xuICAgICAgICAgICAgICAgIHR5cGUgPSBcInRleHRcIjtcbiAgICAgICAgICAgICAgICBjb250ZW50ID0gY2hpbGQudGV4dC50ZXh0O1xuICAgICAgICAgICAgICAgIHcgPSBjaGlsZC50ZXh0dXJlLmdldFJlbmRlcldpZHRoKCk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzSWNvbihjaGlsZCkpIHtcbiAgICAgICAgICAgICAgICB0eXBlID0gXCJpY29uXCI7XG4gICAgICAgICAgICAgICAgdyA9IGNoaWxkLnc7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoaWxkLmNvbnN0cnVjdG9yLl9fY29tcG9uZW50TmFtZSA9PT0gXCJCYWRnZVwiKSB7XG4gICAgICAgICAgICAgICAgdHlwZSA9IFwiYmFkZ2VcIjtcbiAgICAgICAgICAgICAgICB3ID0gY2hpbGQudztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnRlbnRFbmRYICs9IHc7XG4gICAgICAgICAgICBjb250ZW50RW5kWCArPSBjaGlsZC5mbGV4SXRlbS5tYXJnaW5SaWdodDtcbiAgICAgICAgICAgIGlmIChNYXRoLmNlaWwoY29udGVudEVuZFgpID49IHRoaXMudykge1xuICAgICAgICAgICAgICAgIGxpbmUrKztcbiAgICAgICAgICAgICAgICBjb250ZW50RW5kWCA9IHc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgaGFzU3BhY2VGb3JTdWZmaXggPSBNYXRoLmNlaWwoY29udGVudEVuZFgpICsgc3VmZml4VyA8PSB0aGlzLnc7XG4gICAgICAgICAgICB2YXIgZGF0YSA9IHtcbiAgICAgICAgICAgICAgICB0eXBlOiB0eXBlLFxuICAgICAgICAgICAgICAgIGNvbXBvbmVudDogY29tcG9uZW50LFxuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGNvbnRlbnQsXG4gICAgICAgICAgICAgICAgbGluZTogbGluZSxcbiAgICAgICAgICAgICAgICBoYXNTcGFjZUZvclN1ZmZpeDogaGFzU3BhY2VGb3JTdWZmaXhcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBhY2MucHVzaChkYXRhKTtcbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCBbXSk7XG4gICAgfVxuICAgIF9hZGRTdWZmaXgoX3JlZjE2KSB7XG4gICAgICAgIHZhciB7dHlwZTogdHlwZSwgY29tcG9uZW50OiBjb21wb25lbnQsIGNvbnRlbnQ6IGNvbnRlbnR9ID0gX3JlZjE2O1xuICAgICAgICB2YXIgbmVnYXRlZFJpZ2h0TWFyZ2luID0gY29tcG9uZW50LmZsZXhJdGVtLm1hcmdpblJpZ2h0ICogLTE7XG4gICAgICAgIHZhciBzdWZmaXg7XG4gICAgICAgIGlmICh0eXBlID09PSBcInRleHRcIikge1xuICAgICAgICAgICAgdmFyIHtmb250RmFjZTogZm9udEZhY2UsIGZvbnRTaXplOiBmb250U2l6ZSwgZm9udFN0eWxlOiBmb250U3R5bGUsIGxpbmVIZWlnaHQ6IGxpbmVIZWlnaHQsIHZlcnRpY2FsQWxpZ246IHZlcnRpY2FsQWxpZ259ID0gY29tcG9uZW50LnRleHQ7XG4gICAgICAgICAgICBzdWZmaXggPSB0aGlzLl9jcmVhdGVUZXh0KHtcbiAgICAgICAgICAgICAgICBmbGV4SXRlbTogdGhpcy5jb250ZW50UHJvcGVydGllc1xuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRleHQ6IFwiXCIuY29uY2F0KGNvbnRlbnQudHJpbSgpKS5jb25jYXQodGhpcy5tYXhMaW5lc1N1ZmZpeCksXG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgZm9udEZhY2U6IGZvbnRGYWNlLFxuICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogZm9udFNpemUsXG4gICAgICAgICAgICAgICAgICAgIGZvbnRTdHlsZTogZm9udFN0eWxlLFxuICAgICAgICAgICAgICAgICAgICBsaW5lSGVpZ2h0OiBsaW5lSGVpZ2h0LFxuICAgICAgICAgICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiB2ZXJ0aWNhbEFsaWduXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLmNoaWxkTGlzdC5hZGQoY29tcG9uZW50KTtcbiAgICAgICAgICAgIHN1ZmZpeCA9IHRoaXMuX2NyZWF0ZVRleHQoe1xuICAgICAgICAgICAgICAgIGZsZXhJdGVtOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuY29udGVudFByb3BlcnRpZXMpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXJnaW5MZWZ0OiBuZWdhdGVkUmlnaHRNYXJnaW5cbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSwgdGhpcy5tYXhMaW5lc1N1ZmZpeCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHN1ZmZpeDtcbiAgICB9XG4gICAgX2NyZWF0ZUljb24oYmFzZSwgaWNvblByb3BzKSB7XG4gICAgICAgIHZhciB5ID0gKHRoaXMudGV4dEhlaWdodCA+IHRoaXMuc3R5bGUudGV4dFN0eWxlLmxpbmVIZWlnaHQgPyB0aGlzLnRleHRIZWlnaHQgOiB0aGlzLnN0eWxlLnRleHRTdHlsZS5saW5lSGVpZ2h0KSAtIHRoaXMuc3R5bGUuaWNvbkhlaWdodDtcbiAgICAgICAgcmV0dXJuIF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ZXh0Q29sb3IsXG4gICAgICAgICAgICAgICAgaDogdGV4dENvbXBvbmVudC5oICogdGhpcy5zdHlsZS5zdHJpa2V0aHJvdWdoUmF0aW8sXG4gICAgICAgICAgICAgICAgeTogdGV4dENvbXBvbmVudC5oIC8gMixcbiAgICAgICAgICAgICAgICBtb3VudFk6IDFcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IGxuZy5Db21wb25lbnQsXG4gICAgICAgICAgICAgICAgdzogdGV4dFdpZHRoICsgdGV4dENvbXBvbmVudC5mbGV4SXRlbS5tYXJnaW5SaWdodCxcbiAgICAgICAgICAgICAgICBoOiB0ZXh0Q29tcG9uZW50LmgsXG4gICAgICAgICAgICAgICAgY2hpbGRyZW46IFsgX29iamVjdFNwcmVhZCh7fSwgdGV4dENvbXBvbmVudCksIF9vYmplY3RTcHJlYWQoe30sIHN0cmlrZXRocm91Z2hMaW5lKSBdXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0ZXh0Q29tcG9uZW50O1xuICAgIH1cbiAgICBfY3JlYXRlQmFkZ2UoYmFzZSwgYmFkZ2UpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBiYXNlKSwge30sIHtcbiAgICAgICAgICAgIHk6IHRoaXMuYmFkZ2VZIHx8IDBcbiAgICAgICAgfSwgdGhpcy5iYWRnZVByb3BlcnRpZXMpLCB7fSwge1xuICAgICAgICAgICAgdHlwZTogQmFkZ2UsXG4gICAgICAgICAgICB0aXRsZTogYmFkZ2UsXG4gICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgbG9hZGVkQmFkZ2U6IFwiX2xvYWRlZEJhZGdlXCJcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVJY29uUG9zaXRpb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jZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBhY2MucHVzaChwYXJzZWQpO1xuICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgfSksIFtdKSkubWFwKCgoaXRlbSwgaW5kZXgsIGFycikgPT4ge1xuICAgICAgICAgICAgaWYgKGl0ZW0gPT09IFwiIFwiKSByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICBpZiAoYXJyW2luZGV4ICsgMV0gPT09IFwiIFwiKSByZXR1cm4gaXRlbSArIFwiIFwiO1xuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XG4gICAgICAgIH0pKS5maWx0ZXIoQm9vbGVhbik7XG4gICAgfVxuICAgIF9zZXRDb250ZW50KGNvbnRlbnQpIHtcbiAgICAgICAgaWYgKGNvbnRlbnQgIT09IHRoaXMuX2NvbnRlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX2NvbnRlbnQgPSBjb250ZW50O1xuICAgICAgICAgICAgdmFyIHBhcnNlZENvbnRlbnQgPSB0aGlzLl9jb250ZW50O1xuICAgICAgICAgICAgaWYgKGNvbnRlbnQgJiYgIUFycmF5LmlzQXJyYXkoY29udGVudCkpIHtcbiAgICAgICAgICAgICAgICBwYXJzZWRDb250ZW50ID0gcGFyc2VJbmxpbmVDb250ZW50KGNvbnRlbnQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fcGFyc2VkQ29udGVudCA9IHRoaXMuX2Zvcm1hdFNwYWNlcyhwYXJzZWRDb250ZW50KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gY29udGVudDtcbiAgICB9XG4gICAgX3NldEJhZGdlUHJvcGVydGllcyhiYWRnZVByb3BlcnRpZXMpIHtcbiAgICAgICAgaWYgKHR5cGVvZiBiYWRnZVByb3BlcnRpZXMgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgIHJldHVybiBiYWRnZVByb3BlcnRpZXM7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2dldEJhZGdlUHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2JhZGdlUHJvcGVydGllcyB8fCB7fTtcbiAgICB9XG4gICAgX3NldENvbnRlbnRQcm9wZXJ0aWVzKGNvbnRlbnRQcm9wZXJ0aWVzKSB7XG4gICAgICAgIGlmICh0eXBlb2YgY29udGVudFByb3BlcnRpZXMgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgIHJldHVybiBjb250ZW50UHJvcGVydGllcztcbiAgICAgICAgfVxuICAgIH1cbiAgICBfZ2V0Q29udGVudFByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50UHJvcGVydGllcyB8fCB7fTtcbiAgICB9XG4gICAgX3NldEN1c3RvbVN0eWxlTWFwcGluZ3MoY3VzdG9tU3R5bGVNYXBwaW5ncykge1xuICAgICAgICBpZiAodHlwZW9mIGN1c3RvbVN0eWxlTWFwcGluZ3MgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgIHJldHVybiBjdXN0b21TdHlsZU1hcHBpbmdzO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9nZXRDdXN0b21TdHlsZU1hcHBpbmdzKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fY3VzdG9tU3R5bGVNYXBwaW5ncyB8fCB7fTtcbiAgICB9XG4gICAgX3NldE1heExpbmVzKG1heExpbmVzKSB7XG4gICAgICAgIHJldHVybiBtYXhMaW5lcyA+PSAxID8gTWF0aC5mbG9vcihtYXhMaW5lcykgOiAwO1xuICAgIH1cbiAgICBnZXQgdGV4dEhlaWdodCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuc3R5bGUudGV4dFN0eWxlLmxpbmVIZWlnaHQgfHwgdGhpcy5zdHlsZS50ZXh0U3R5bGUuZm9udFNpemU7XG4gICAgfVxuICAgIGdldCBfbWFyZ2luQm90dG9tKCkge1xuICAgICAgICBpZiAodGhpcy5jb250ZW50UHJvcGVydGllcy5tYXJnaW5Cb3R0b20gIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGVudFByb3BlcnRpZXMubWFyZ2luQm90dG9tO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLnN0eWxlLm1hcmdpbkJvdHRvbSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3R5bGUubWFyZ2luQm90dG9tO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiAwO1xuICAgIH1cbiAgICBnZXQgX3Nob3VsZFRydW5jYXRlKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5jb250ZW50V3JhcCAmJiB0aGlzLm1heExpbmVzO1xuICAgIH1cbiAgICBzZXQgYW5ub3VuY2UoYW5ub3VuY2UpIHtcbiAgICAgICAgc3VwZXIuYW5ub3VuY2UgPSBhbm5vdW5jZTtcbiAgICB9XG4gICAgZ2V0IGFubm91bmNlKCkge1xuICAgICAgICBpZiAodGhpcy5fYW5ub3VuY2UpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgYW5ub3VuY2UgPSB0aGlzLl9wYXJzZWRDb250ZW50ICYmIHRoaXMuX3BhcnNlZENvbnRlbnQucmVkdWNlKCgoYW5ub3VuY2UsIGl0ZW0pID0+IHtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgIGFubm91bmNlICs9IGl0ZW07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGl0ZW0uYW5ub3VuY2UpIHtcbiAgICAgICAgICAgICAgICBhbm5vdW5jZSArPSBpdGVtLmFubm91bmNlO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpdGVtLnRleHQpIHtcbiAgICAgICAgICAgICAgICB2YXIgX2l0ZW0kc3R5bGU7XG4gICAgICAgICAgICAgICAgYW5ub3VuY2UgKz0gaXRlb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IHQgPSBkb3QocG9zMSwgZCkgLyBkb3QoZCwgZCk7XFxuICAgICAgdCA9IHNtb290aHN0ZXAoMC4wLCAxLjAsIGNsYW1wKHQsIDAuMCwgMS4wKSk7XFxuXFxuICAgICAgdmVjMiBwb3MzID0gdmVjMih2VGV4dHVyZUNvb3JkLnggKiByZXNvbHV0aW9uLngsIHZUZXh0dXJlQ29vcmQueSk7XFxuICAgICAgcG9zMy54IC09IHJlc29sdXRpb24ueCAtIG1hcmdpblsxXTtcXG4gICAgICB2ZWMyIHBvczQgPSB2ZWMyKHZUZXh0dXJlQ29vcmQueCArIG1hcmdpblsxXSwgdlRleHR1cmVDb29yZC55KTtcXG5cXG4gICAgICB2ZWMyIGQyID0gcG9zNCAtIHBvczM7XFxuICAgICAgZmxvYXQgdDIgPSBkb3QocG9zMywgZDIpIC8gZG90KGQyLCBkMik7XFxuICAgICAgdDIgPSBzbW9vdGhzdGVwKDAuMCwgMS4wLCBjbGFtcCh0MiwgMC4wLCAxLjApKTtcXG5cXG4gICAgICBjb2xvciA9IG1peCh2ZWM0KDAuMCksIGNvbG9yLCB0KTtcXG4gICAgICBjb2xvciA9IG1peChjb2xvciwgdmVjNCgwLjApLCB0Mik7XFxuXFxuICAgICAgZ2xfRnJhZ0NvbG9yID0gY29sb3I7XFxuICB9XFxuXCI7XG5cbmNsYXNzIE1hcnF1ZWUgZXh0ZW5kcyBCYXNlJDEge1xuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBDb250ZW50Q2xpcHBlcjoge1xuICAgICAgICAgICAgICAgIGJvdW5kc01hcmdpbjogW10sXG4gICAgICAgICAgICAgICAgQ29udGVudEJveDoge1xuICAgICAgICAgICAgICAgICAgICBDb250ZW50OiB7fSxcbiAgICAgICAgICAgICAgICAgICAgQ29udGVudExvb3BUZXh0dXJlOiB7fVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIk1hcnF1ZWVcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkSTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkNvbnRlbnRDbGlwcGVyXCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiQ29udGVudEJveFwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50Q2xpcHBlci5Db250ZW50Qm94XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJDb250ZW50XCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnRDbGlwcGVyLkNvbnRlbnRCb3guQ29udGVudFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiQ29udGVudExvb3BUZXh0dXJlXCIsXG4gICAgICAgICAgICBwYXRoOiBcIkNvbnRlbnRDbGlwcGVyLkNvbnRlbnRCb3guQ29udGVudExvb3BUZXh0dXJlXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwiYXV0b1N0YXJ0XCIsIFwidGl0bGVcIiwgXCJjb250ZW50VGV4dHVyZVwiLCBcImNvbG9yXCIsIFwiY2VudGVyQWxpZ25cIiwgXCJkZWxheVwiLCBcInJlcGVhdFwiLCBcIm92ZXJyaWRlTG9vcFhcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcImZhZGVXXCIsXG4gICAgICAgICAgICBjdXJyOiBcImZhZGVXaWR0aFwiXG4gICAgICAgIH0gXTtc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XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy50aXRsZSkge1xuICAgICAgICAgICAgY29udGVudC50ZXh0ID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwgdGhpcy50aXRsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgdGV4dDogdGhpcy50ZXh0Q29udGVudFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBDb250ZW50Q2xpcHBlcjoge1xuICAgICAgICAgICAgICAgIHc6IHRoaXMudyArIDE0LFxuICAgICAgICAgICAgICAgIENvbnRlbnRCb3g6IHtcbiAgICAgICAgICAgICAgICAgICAgQ29udGVudDogY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgQ29udGVudExvb3BUZXh0dXJlOiB7fVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuc2lnbmFsKFwibWFycXVlZUNvbnRlbnRMb2FkZWRcIik7XG4gICAgfVxuICAgIF91cGRhdGVTaGFkZXIoKSB7XG4gICAgICAgIHRoaXMuX0NvbnRlbnRDbGlwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgIHc6IHRoaXMudyA+IDAgPyB0aGlzLncgKyB0aGlzLnN0eWxlLmZhZGVXaWR0aCAvIDIgOiAwLFxuICAgICAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgICAgICAgdHlwZTogRmFkZVNoYWRlcixcbiAgICAgICAgICAgICAgICBwb3NpdGlvbkxlZnQ6IDAsXG4gICAgICAgICAgICAgICAgcG9zaXRpb25SaWdodDogdGhpcy5zdHlsZS5mYWRlV2lkdGhcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBydHQ6IHRydWVcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVBbmltYXRpb24oKSB7XG4gICAgICAgIHRoaXMuX3Njcm9sbEFuaW1hdGlvbiAmJiB0aGlzLl9zY3JvbGxBbmltYXRpb24uc3RvcE5vdygpO1xuICAgICAgICB0aGlzLl9zY3JvbGxBbmltYXRpb24gPSB0aGlzLmFuaW1hdGlvbih7XG4gICAgICAgICAgICBkdXJhdGlvbjogdGhpcy5fbG9vcFdpZHRoIC8gNTAsXG4gICAgICAgICAgICBkZWxheTogaXNOYU4odGhpcy5kZWxheSkgPyAxLjUgOiB0aGlzLmRlbGF5LFxuICAgICAgICAgICAgcmVwZWF0OiBpc05hTih0aGlzLnJlcGVhdCkgPyAtMSA6IHRoaXMucmVwZWF0LFxuICAgICAgICAgICAgYWN0aW9uczogWyB7XG4gICAgICAgICAgICAgICAgdDogXCJDb250ZW50Qm94XCIsXG4gICAgICAgICAgICAgICAgcDogXCJ4XCIsXG4gICAgICAgICAgICAgICAgdjoge1xuICAgICAgICAgICAgICAgICAgICBzbTogMCxcbiAgICAgICAgICAgICAgICAgICAgMDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogMFxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAuNToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogLSh0aGlzLl9sb29wV2lkdGggKyB0aGlzLnN0eWxlLm9mZnNldClcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0OiBcIkNvbnRlbnRDbGlwcGVyXCIsXG4gICAgICAgICAgICAgICAgcDogXCJzaGFkZXIucG9zaXRpb25MZWZ0XCIsXG4gICAgICAgICAgICAgICAgdjoge1xuICAgICAgICAgICAgICAgICAgICBzbTogMCxcbiAgICAgICAgICAgICAgICAgICAgMDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogMFxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAuMToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdjogdGhpcy5zdHlsZS5mYWRlV2lkdGhcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgLjQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHY6IHRoaXMuc3R5bGUuZmFkZVdpZHRoXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIC41OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2OiAwXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IF1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF9wb3NpdGlvblRleHR1cmUoKSB7XG4gICAgICAgIHZhciB4ID0gdGhpcy5fc2hvdWxkQ2VudGVyKCkgPyAodGhpcy53IC0gdGhpcy5fdGV4dFJlbmRlcmVkVykgLyAyIDogMDtcbiAgICAgICAgaWYgKHRoaXMuc3R5bGUuc2hvdWxkU21vb3RoKSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50Qm94LnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICB4OiB4XG4gICAgICAgICAgICB9O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudEJveC54ID0geDtcbiAgICAgICAgfVxuICAgIH1cbiAgICBzdGFydFNjcm9sbGluZygpIHtcbiAgICAgICAgdGhpcy5fQ29udGVudC5vZmYoXCJ0eExvYWRlZFwiLCB0aGlzLnN0YXJ0U2Nyb2xsaW5nLmJpbmQodGhpcykpO1xuICAgICAgICB0aGlzLl9zaG91bGRUcnlTY3JvbGxpbmcgPSB0cnVlO1xuICAgICAgICBpZiAodGhpcy5fdGV4dFJlbmRlcmVkVyA9PT0gMCkge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5vbihcInR4TG9hZGVkXCIsIHRoaXMuc3RhcnRTY3JvbGxpbmcuYmluZCh0aGlzKSk7XG4gICAgICA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gICAgICAgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB0aGlzLl9tYXJxdWVlQ29udGVudExpc3RlbmVyQXR0YWNoZWQgPSBmYWxzZTtcbiAgICAgICAgdGhpcy5fbWFycXVlZU92ZXJyaWRlTG9vcFggPSB1bmRlZmluZWQ7XG4gICAgICAgIHRoaXMuX3Jlc2V0TWFycXVlZVByb21pc2UoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9UZXh0IHx8IHRoaXMuX0lubGluZUNvbnRlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLncgPSB0aGlzLmggPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuX25vdGlmeUFuY2VzdG9ycygpO1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZU1hcnF1ZWUoKTtcbiAgICAgICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgVGV4dDogdW5kZWZpbmVkLFxuICAgICAgICAgICAgICAgICAgICBJbmxpbmVDb250ZW50OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9pc0lubGluZUNvbnRlbnQgPyB0aGlzLl91cGRhdGVJbmxpbmVDb250ZW50KCkgOiB0aGlzLl91cGRhdGVUZXh0KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZU1hcnF1ZWUoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUlubGluZUNvbnRlbnQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgVGV4dDogdW5kZWZpbmVkXG4gICAgICAgIH0pO1xuICAgICAgICB2YXIgaW5saW5lQ29udGVudFBhdGNoID0gSW5saW5lQ29udGVudC5wcm9wZXJ0aWVzLnJlZHVjZSgoKGFjYywgcHJvcCkgPT4ge1xuICAgICAgICAgICAgaWYgKHRoaXNbcHJvcF0gIT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgYWNjW3Byb3BdID0gdGhpc1twcm9wXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCB7XG4gICAgICAgICAgICBzdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuX3RleHRTdHlsZVNldFxuICAgICAgICAgICAgfSlcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICh0aGlzLl90ZXh0U3R5bGVTZXQud29yZFdyYXBXaWR0aCkge1xuICAgICAgICAgICAgaW5saW5lQ29udGVudFBhdGNoLncgPSB0aGlzLl90ZXh0U3R5bGVTZXQud29yZFdyYXBXaWR0aDtcbiAgICAgICAgICAgIGlubGluZUNvbnRlbnRQYXRjaC5ydHQgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl90ZXh0U3R5bGVTZXQubWF4TGluZXMpIHtcbiAgICAgICAgICAgIGlubGluZUNvbnRlbnRQYXRjaC5tYXhMaW5lcyA9IHRoaXMuX3RleHRTdHlsZVNldC5tYXhMaW5lcztcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5fdGV4dFN0eWxlU2V0Lm1heExpbmVzU3VmZml4KSB7XG4gICAgICAgICAgICBpbmxpbmVDb250ZW50UGF0Y2gubWF4TGluZXNTdWZmaXggPSB0aGlzLl90ZXh0U3R5bGVTZXQubWF4TGluZXNTdWZmaXg7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICBhbHBoYTogMSxcbiAgICAgICAgICAgIElubGluZUNvbnRlbnQ6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgdHlwZTogSW5saW5lQ29udGVudCxcbiAgICAgICAgICAgICAgICB3OiB0aGlzLndcbiAgICAgICAgICAgIH0sIGlubGluZUNvbnRlbnRQYXRjaCksIHt9LCB7XG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBsb2FkZWRJbmxpbmVDb250ZW50OiBcIl9zZXREaW1lbnNpb25zXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZVRleHQoKSB7XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgSW5saW5lQ29udGVudDogdW5kZWZpbmVkXG4gICAgICAgIH0pO1xuICAgICAgICBpZiAoIXRoaXMuX1RleHQpIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIFRleHQ6IHt9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMuX1RleHQub24oXCJ0eExvYWRlZFwiLCB0aGlzLl9zZXREaW1lbnNpb25zLmJpbmQodGhpcykpO1xuICAgICAgICB9XG4gICAgICAgIHZhciBmb250U3R5bGUgPSB0aGlzLl90ZXh0U3R5bGVTZXQ7XG4gICAgICAgIGlmICh0aGlzLl9UZXh0KSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LnBhdGNoKHtcbiAgICAgICAgICAgICAgICB5OiB0aGlzLnN0eWxlLm9mZnNldFksXG4gICAgICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5vZmZzZXRYLFxuICAgICAgICAgICAgICAgIHRleHQ6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgbGlnaHRuaW5nVGV4dERlZmF1bHRzKSwgZm9udFN0eWxlKVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgc2V0IG1hcnF1ZWVPdmVycmlkZUx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gbWFycXVlZVBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLm1hcnF1ZWVQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICAgICAgdzogdGhpcy5fdGV4dFN0eWxlU2V0LndvcmRXcmFwV2lkdGggfHwgdGhpcy53LFxuICAgICAgICAgICAgICAgIGg6IHRoaXMuaCxcbiAgICAgICAgICAgICAgICB5OiB0aGlzLnN0eWxlLm9mZnNldFksXG4gICAgICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5vZmZzZXRYLFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgbWFycXVlZUNvbnRlbnRMb2FkZWQ6IFwiX2xvYWRlZE1hcnF1ZWVDb250ZW50XCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fTWFycXVlZSkge1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC50eXBlID0gTWFycXVlZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLl9pc0lubGluZUNvbnRlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9JbmxpbmVDb250ZW50LncgPSAwO1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC50aXRsZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICBtYXJxdWVlUGF0Y2guY29udGVudFRleHR1cmUgPSB0aGlzLl9jb250ZW50VGFnLmdldFRleHR1cmUoKTtcbiAgICAgICAgICAgICAgICBtYXJxdWVlUGF0Y2gudyA9IHRoaXMuX3RleHRTdHlsZVNldC53b3JkV3JhcFdpZHRoIHx8IHRoaXMudztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbWFycXVlZVBhdGNoLmNvbnRlbnRUZXh0dXJlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIG1hcnF1ZWVQYXRjaC50aXRsZSA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHRleHQ6IHRoaXMuX2NvbnRlbnRUYWcudGV4dC50ZXh0XG4gICAgICAgICAgICAgICAgfSwgdGhpcy5fdGV4dFN0eWxlU2V0KSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogMCxcbiAgICAgICAgICAgICAgICAgICAgbWF4TGluZXM6IDFcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIE1hcnF1ZWU6IG1hcnF1ZWVQYXRjaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAoIXRoaXMuX21hcnF1ZWVDb250ZW50TGlzdGVuZXJBdHRhY2hlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX21hcnF1ZWVDb250ZW50TGlzdGVuZXJBdHRhY2hlZCA9IHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoXCJ1bmRlZmluZWRcIiAhPT0gdHlwZW9mIHRoaXMuX21hcnF1ZWVPdmVycmlkZUxvb3BYKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fYXdhaXRNYXJxdWVlT3ZlcnJpZGVYLnRoZW4oKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdG9nZ2xlTWFycXVlZSh0aGlzLl9jb250ZW50VGFnKTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3RvZ2dsZU1hcnF1ZWUodGhpcy5fY29udGVudFRhZyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2dldE1hcnF1ZWVQcm9wcygpIHtcbiAgICAgICAgdmFyIF90aGlzJF9tYXJxdWVlUH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HRoICYmIHRoaXMuZml4ZWQpIHtcbiAgICAgICAgICAgIGZvbnRTdHlsZS53b3JkV3JhcFdpZHRoID0gdGhpcy53O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmb250U3R5bGU7XG4gICAgfVxuICAgIGdldCBfY29udGVudFRhZygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2lzSW5saW5lQ29udGVudCA/IHRoaXMuX0lubGluZUNvbnRlbnQgOiB0aGlzLl9UZXh0O1xuICAgIH1cbiAgICBfdG9nZ2xlTWFycXVlZShjb250ZW50VGFnKSB7XG4gICAgICAgIGlmICh0aGlzLm1hcnF1ZWUpIHtcbiAgICAgICAgICAgIGlmIChjb250ZW50VGFnKSB7XG4gICAgICAgICAgICAgICAgY29udGVudFRhZy5hbHBoYSA9IC4wMDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fTWFycXVlZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuYWxwaGEgPSAxO1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuc3RhcnRTY3JvbGxpbmcoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChjb250ZW50VGFnKSB7XG4gICAgICAgICAgICAgICAgY29udGVudFRhZy5hbHBoYSA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5fTWFycXVlZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuYWxwaGEgPSAuMDAxO1xuICAgICAgICAgICAgICAgIHRoaXMuX01hcnF1ZWUuc3RvcFNjcm9sbGluZygpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIHRvZ2dsZU1hcnF1ZWUoKSB7XG4gICAgICAgIHRoaXMuX3RvZ2dsZU1hcnF1ZWUodGhpcy5fY29udGVudFRhZyk7XG4gICAgfVxuICAgIGdldCBhbm5vd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gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCBcIkNvbnRlbnRcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJUZXh0V3JhcHBlclwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlRleHRXcmFwcGVyXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJUaXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlRleHRXcmFwcGVyLlRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJQcmVmaXhcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5QcmVmaXhcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlN1ZmZpeFwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlN1ZmZpeFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkpLCB7fSwge1xuICAgICAgICAgICAgQ29udGVudDoge1xuICAgICAgICAgICAgICAgIG1vdW50OiAuNSxcbiAgICAgICAgICAgICAgICB4OiB3ID0+IHcgLyAyLFxuICAgICAgICAgICAgICAgIHk6IGggPT4gaCAvIDIsXG4gICAgICAgICAgICAgICAgekluZGV4OiAyXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXgoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGl0bGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlU3VmZml4KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUFsbFBvc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maXgoKSB7XG4gICAgICAgIHZhciBwcmVmaXhTdHJpbmcgPSBKU09OLnN0cmluZ2lmeSh0aGlzLnByZWZpeCk7XG4gICAgICAgIGlmICh0aGlzLnByZWZpeCkge1xuICAgICAgICAgICAgdmFyIHByZWZpeFBhdGNoID0ge1xuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIGl0ZW1TcGFjaW5nOiB0aGlzLnN0eWxlLml0ZW1TcGFjaW5nXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fUHJlZml4KSB7XG4gICAgICAgICAgICAgICAgcHJlZml4UGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuX3Jvd1Byb3BzKSwgcHJlZml4UGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgUHJlZml4OiBwcmVmaXhQYXRjaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhTdWZmaXhTdHlsZXMoXCJwcmVmaXhcIik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBQcmVmaXg6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fcHJldlByZWZpeCA9IHByZWZpeFN0cmluZztcbiAgICB9XG4gICAgX3VwZGF0ZVByZWZpeFN1ZmZpeFN0eWxlcygpIHtcbiAgICAgICAgdmFyIHR5cGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IFwicHJlZml4XCI7XG4gICAgICAgIHZhciBtYXAgPSB7XG4gICAgICAgICAgICBwcmVmaXg6IHtcbiAgICAgICAgICAgICAgICB0YWc6IHRoaXMuX1ByZWZpeCxcbiAgICAgICAgICAgICAgICBwcm9wOiB0aGlzLnByZWZpeCxcbiAgICAgICAgICAgICAgICBwcmV2UHJvcDogdGhpcy5fcHJldlByZWZpeFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHN1ZmZpeDoge1xuICAgICAgICAgICAgICAgIHRhZzogdGhpcy5fU3VmZml4LFxuICAgICAgICAgICAgICAgIHByb3A6IHRoaXMuc3VmZml4LFxuICAgICAgICAgICAgICAgIHByZXZQcm9wOiB0aGlzLl9wcmV2U3VmZml4XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIHZhciB7dGFnOiB0YWcsIHByb3A6IHByb3B9ID0gbWFwW3R5cGVdO1xuICAgICAgICB2YXIge3ByZXZQcm9wOiBwcmV2UHJvcH0gPSBtYXBbdHlwZV07XG4gICAgICAgIHZhciBwcm9wU3RyaW5nID0gSlNPTi5zdHJpbmdpZnkocHJvcCk7XG4gICAgICAgIGlmIChwcm9wU3RyaW5nICE9PSBwcmV2UHJvcCkge1xuICAgICAgICAgICAgcHJldlByb3AgPSBwcm9wU3RyaW5nO1xuICAgICAgICAgICAgdGFnLml0ZW1zID0gdGhpcy5fYWRkQnV0dG9uUHJvcHMocHJvcCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0YWcuSXRlbXMuY2hpbGRyZW4uZm9yRWFjaCgoKGl0ZW0sIGlkeCkgPT4ge1xuICAgICAgICAgICAgICAgIGl0ZW0uY29sb3IgPSBBcnJheS5pc0FycmF5KHByb3ApID8gcHJvcFtpZHhdLmNvbG9yIDogcHJvcC5jb2xvcjtcbiAgICAgICAgICAgICAgICBpdGVtLnN0eWxlID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBpdGVtLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY29udGVudENvbG9yXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVRpdGxlKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzVGl0bGUpIHtcbiAgICAgICAgICAgIHZhciB0aXRsZVBhdGNoID0ge1xuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMudGl0bGUsXG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLnRleHRTdHlsZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoIXRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICAgICAgdGl0bGVQYXRjaCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICB5OiBoID0+IGggLyAyLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfb25UaXRsZVRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIHRpdGxlUGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgVGV4dFdyYXBwZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgVGl0bGU6IHRpdGxlUGF0Y2hcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIFRleHRXcmFwcGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIFRpdGxlOiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlU3VmZml4KCkge1xuICAgICAgICBpZiAodGhpcy5zdWZmaXgpIHtcbiAgICAgICAgICAgIHZhciBzdWZmaXhQYXRjaCA9IHtcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICBpdGVtU3BhY2luZzogdGhpcy5zdHlsZS5pdGVtU3BhY2luZ1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoIXRoaXMuX1N1ZmZpeCkge1xuICAgICAgICAgICAgICAgIHN1ZmZpeFBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLl9yb3dQcm9wcyksIHN1ZmZpeFBhdGNoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIFN1ZmZpeDogc3VmZml4UGF0Y2hcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJlZml4U3VmZml4U3R5bGVzKFwic3VmZml4XCIpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgU3VmZml4OiB1bmRlZmluZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVUcnVuY2F0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RpdGxlLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50ZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRoaXMuZml4ZWQsXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLmZpeGVkID8gdGhpcy5fZml4ZWRXb3JkV3JhcFdpZHRoIDogMFxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVDb250ZW50RGltZW5zaW9ucygpIHtcbiAgICAgICAgdmFyIGNvbnRlbnREaW1lbnNpb25zUGF0Y2ggPSB7fTtcbiAgICAgICAgdmFyIHkgPSB0aGlzLmggLyAyO1xuICAgICAgICBpZiAodGhpcy5fQ29udGVudC50cmFuc2l0aW9uKFwid1wiKS50YXJnZXRWYWx1ZSAhPT0gdGhpcy5fY29udGVudFcpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQudyA9IHRoaXMuX2NvbnRlbnRXO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9Db250ZW50LnkgIT09IHkpIHtcbiAgICAgICAgICAgIGNvbnRlbnREaW1lbnNpb25zUGF0Y2gueSA9IHk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKGNvbnRlbnREaW1lbnNpb25zUGF0Y2gpLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goY29udGVudERpbWVuc2lvbnNQYXRjaCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnRQb3NpdGlvbigpIHtcbiAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh0aGlzLl9jb250ZW50UHJvcHMpO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uaXNBcnJheShhcnIpID8gYXJyIDogWyBhcnIgXTtcbiAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCgoaXRlbSA9PiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5fYnV0dG9uUHJvcHMpLCBpdGVtKSwge30sIHtcbiAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5jb250ZW50Q29sb3JcbiAgICAgICAgICAgIH0sIGl0ZW0uc3R5bGUpXG4gICAgICAgIH0pKSk7XG4gICAgfVxuICAgIF9nZXRKdXN0aWZ5KCkge1xuICAgICAgICByZXR1cm4gISF0aGlzLl9qdXN0aWZ5ID8gdGhpcy5fanVzdGlmeSA6IHRoaXMuc3R5bGUuanVzdGlmeTtcbiAgICB9XG4gICAgZ2V0IF9jb250ZW50UHJvcHMoKSB7XG4gICAgICAgIHZhciBtb3VudFg7XG4gICAgICAgIHZhciB4O1xuICAgICAgICBzd2l0Y2ggKHRoaXMuanVzdGlmeSkge1xuICAgICAgICAgIGNhc2UgXCJsZWZ0XCI6XG4gICAgICAgICAgICBtb3VudFggPSAwO1xuICAgICAgICAgICAgeCA9IHRoaXMuX3BhZGRpbmdMZWZ0O1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlIFwicmlnaHRcIjpcbiAgICAgICAgICAgIG1vdW50WCA9IDE7XG4gICAgICAgICAgICB4ID0gdGhpcy53IC0gdGhpcy5fcGFkZGluZ1JpZ2h0O1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlIFwiY2VudGVyXCI6XG4gICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIG1vdW50WCA9IC41O1xuICAgICAgICAgICAgeCA9IHRoaXMudyAvIDI7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgbW91bnRYOiBtb3VudFgsXG4gICAgICAgICAgICB4OiB4XG4gICAgICAgIH07XG4gICAgfVxuICAgIGdldCBfYnV0dG9uUHJvcHMoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBjZW50ZXJJblBhcmVudDogdHJ1ZSxcbiAgICAgICAgICAgIG1vZGU6IHRoaXMubW9kZVxuICAgICAgICB9O1xuICAgIH1cbiAgICBnZXQgX2hhc1ByZWZpeCgpIHtcbiAgICAgICAgcmV0dXJuICEhKHRoaXMucHJlZml4ICYmIE9iamVjdC5rZXlzKHRoaXMucHJlZml4KS5sZW5ndGgpO1xuICAgIH1cbiAgICBnZXQgX3ByZWZpeFcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9oYXNQcmVmaXggJiYgdGhpcy5fUHJlZml4ICE9PSB1bmRlZmluZWQgPyB0aGlzLl9QcmVmaXgudyA6IDA7XG4gICAgfVxuICAgIGdldCBfcHJlZml4WCgpIHtcbiAgICAgICAgcmV0dXJuIDA7XG4gICAgfVxuICAgIGdldCBfaGFzVGl0bGUoKSB7XG4gICAgICAgIHJldHVybiAhIXRoaXMudGl0bGU7XG4gICAgfVxuICAgIGdldCBfdGl0bGVXKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzVGl0bGUgJiYgdGhpcy5fVGl0bGUgJiYgdGhpcy5fVGl0bGUuX1RleHQgJiYgdGhpcy5fVGl0bGUudmlzaWJsZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX1RpdGxlLnc7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIDA7XG4gICAgfVxuICAgIGdldCBfdGl0bGVYKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faGFzUHJlZml4ID8gdGhpcy5fcHJlZml4VyArIHRoaXMuc3R5bGUuY29udGVudFNwYWNpbmcgOiAwO1xuICAgIH1cbiAgICBnZXQgX2hhc1N1ZmZpeCgpIHtcbiAgICAgICAgcm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hlbWUucmFkaXVzLm1kLFxuICAgIHRpdGxlVGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoZW1lLnR5cG9ncmFwaHkuaGVhZGxpbmUxKSwge30sIHtcbiAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgIG1heExpbmVzOiAyLFxuICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgfSksXG4gICAgd2lkdGg6IHV0aWxzJDEuZ2V0V2lkdGhCeVVwQ291bnQodGhlbWUsIDYpXG59KTtcblxudmFyIG1vZGUkZSA9IHRoZW1lID0+ICh7XG4gICAgZm9jdXNlZDoge1xuICAgICAgICB0b25lOiB7XG4gICAgICAgICAgICBuZXV0cmFsOiB7XG4gICAgICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZU5ldXRyYWxGb2N1c1NvZnRcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBpbnZlcnNlOiB7XG4gICAgICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZUludmVyc2VGb2N1c1NvZnRcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBicmFuZDoge1xuICAgICAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjogdGhlbWUuY29sb3IuaW50ZXJhY3RpdmVCcmFuZEZvY3VzU29mdFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBkaXNhYmxlZDoge1xuICAgICAgICB0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRHID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFx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UuY29sb3IuZmlsbEJyYW5kLFxuICAgICAgICBrbm9iQ29sb3I6IHRoZW1lLmNvbG9yLmZpbGxJbnZlcnNlLFxuICAgICAgICBzdHJva2VDb2xvcjogdGhlbWUuY29sb3Iuc3Ryb2tlTmV1dHJhbFNlY29uZGFyeVxuICAgIH1cbn0pO1xuXG52YXIgbW9kZSRiID0gdGhlbWUgPT4gKHtcbiAgICBkaXNhYmxlZDoge1xuICAgICAgICBhbHBoYTogdGhlbWUuYWxwaGEuaW5hY3RpdmVcbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyREID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkRCxcbiAgICBtb2RlOiBtb2RlJGIsXG4gICAgdG9uZTogdG9uZSRrXG59KTtcblxuY2xhc3MgUmFkaW8gZXh0ZW5kcyBCYXNlJDEge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJSYWRpb1wiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyREO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICB2YXIgY2VudGVyID0ge1xuICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgeDogdyA9PiB3IC8gMixcbiAgICAgICAgICAgIHk6IGggPT4gaCAvIDJcbiAgICAgICAgfTtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIEJvZHk6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgcnR0OiB0cnVlXG4gICAgICAgICAgICB9LCBjZW50ZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgIEtub2I6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgY2VudGVyKSwge30sI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7fSwge1xuICAgICAgICAgICAgU3VidGl0bGU6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3VwZGF0ZVBvc2l0aW9uc1wiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVSYWRpbygpO1xuICAgICAgICB0aGlzLl91cGRhdGVTdWJ0aXRsZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVQb3NpdGlvbnMoKTtcbiAgICB9XG4gICAgX3VwZGF0ZVBvc2l0aW9ucygpIHtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZVBvc2l0aW9ucygpO1xuICAgICAgICB0aGlzLl91cGRhdGVTdWJ0aXRsZVBvc2l0aW9uKCk7XG4gICAgfVxuICAgIF91cGRhdGVTdWJ0aXRsZSgpIHtcbiAgICAgICAgdGhpcy5fU3VidGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5zdWJ0aXRsZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuc3VidGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9jYWxjdWxhdGVUZXh0V2lkdGgoKVxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlUmFkaW8oKSB7XG4gICAgICAgIHZhciByYWRpb1BhdGNoID0gX29iamVjdFNwcm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JpY29uSGVpZ2h0XCIsIFwiaWNvblNyY1wiIF07XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHN1cGVyLl91cGRhdGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlSWNvbigpO1xuICAgIH1cbiAgICBfdXBkYXRlSWNvbigpIHtcbiAgICAgICAgdmFyIHtpY29uV2lkdGg6IGljb25XaWR0aCwgaWNvbkhlaWdodDogaWNvbkhlaWdodH0gPSB0aGlzLnN0eWxlO1xuICAgICAgICB2YXIgaWNvbk9iamVjdCA9IHtcbiAgICAgICAgICAgIHc6IGljb25XaWR0aCxcbiAgICAgICAgICAgIGg6IGljb25IZWlnaHQsXG4gICAgICAgICAgICBpY29uOiB0aGlzLmljb25TcmMsXG4gICAgICAgICAgICB4OiB0aGlzLncgLSBpY29uV2lkdGggLSB0aGlzLnN0eWxlLnBhZGRpbmdIb3Jpem9udGFsLFxuICAgICAgICAgICAgeTogKHRoaXMuX1RpdGxlLnN0eWxlLnRleHRTdHlsZS5saW5lSGVpZ2h0IC0gaWNvbkhlaWdodCkgLyAyICsgdGhpcy5zdHlsZS5wYWRkaW5nVmVydGljYWxcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKCF0aGlzLl9JY29uKSB7XG4gICAgICAgICAgICBpY29uT2JqZWN0LnR5cGUgPSBJY29uO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgSWNvbjogaWNvbk9iamVjdFxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX2NhbGN1bGF0ZVRleHRXaWR0aCgpIHtcbiAgICAgICAgdmFyIHRleHRXaWR0aCA9IHRoaXMudyAtIHRoaXMuc3R5bGUucGFkZGluZ0hvcml6b250YWwgKiAyO1xuICAgICAgICByZXR1cm4gdGhpcy5pY29uU3JjID8gdGV4dFdpZHRoIC0gdGhpcy5pY29uV2lkdGggOiB0ZXh0V2lkdGg7XG4gICAgfVxufVxuXG52YXIgYmFzZSRBID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iAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIEJvZHk6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgcnR0OiB0cnVlXG4gICAgICAgICAgICB9LCBjZW50ZXIpLCB7fSwge1xuICAgICAgICAgICAgICAgIENoZWNrOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uXG4gICAgICAgICAgICAgICAgfSwgY2VudGVyKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IDBcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSksXG4gICAgICAgICAgICBTdHJva2U6IGNlbnRlclxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQ2hlY2tcIiwgXCJCb2R5XCIsIFwiU3Ryb2tlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImNoZWNrZWRcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcImNoZWNrU3JjXCIsXG4gICAgICAgICAgICBjdXJyOiBcImljb25cIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBwcmV2OiBcImNoZWNrSFwiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uSGVpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJjaGVja1dcIixcbiAgICAgICAgICAgIGN1cnI6IFwiaWNvbldpZHRoXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJjaGVja0hlaWdodFwiLFxuICAgICAgICAgICAgY3VycjogXCJpY29uSGVpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgcHJldjogXCJjaGVja1dpZHRoXCIsXG4gICAgICAgICAgICBjdXJyOiBcImljb25XaWR0aFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlQm9keSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVTdHJva2UoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ2hlY2soKTtcbiAgICAgICAgaWYgKHRoaXMuX2NoZWNrZWRDaGFuZ2VkKSB7XG4gICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkYW5ub3VuY2VcIiwgdGhpcy5hbm5vdW5jZSk7XG4gICAgICAgICAgICB0aGlzLl9jaGVja2VkQ2hhbmdlZCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3VwZGF0ZU9wYWNpdHkoKTtcbiAgICB9XG4gICAgX3VwZGF0ZUNoZWNrKCkge1xuICAgICAgICB0aGlzLl9DaGVjay5wYXRjaCh7XG4gICAgICAgICAgICB3OiB0aGlzLnN0eWxlLmljb25XaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaWNvbkhlaWdodCxcbiAgICAgICAgICAgIGljb246IHRoaXMuc3R5bGUuaWNvbixcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY2hlY2tDb2xvclxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdmFyIGFscGhhUGF0Y2ggPSB7XG4gICAgICAgICAgICBhbHBoYTogdGhpcy5jaGVja2VkID8gMSA6IDBcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9DaGVjaywgYWxwaGFQYXRjaCk7XG4gICAgfVxuICAgIF91cGRhdGVCb2R5KCkge1xuICAgICAgICB2YXIgYm9keUNvbG9yID0gdGhpcy5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sXG4gICAgdGV4dFN0eWxlOiB0aGVtZS50eXBvZ3JhcGh5LmNhcHRpb24xXG59KTtcblxudmFyIHRvbmUkaSA9IHRoZW1lID0+ICh7XG4gICAgbmV1dHJhbDoge1xuICAgICAgICB0ZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VcbiAgICAgICAgfSxcbiAgICAgICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxuICAgIH0sXG4gICAgaW52ZXJzZToge1xuICAgICAgICB0ZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgfSxcbiAgICAgICAgYmFja2dyb3VuZENvbG9yOiB0aGVtZS5jb2xvci5maWxsSW52ZXJzZVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgdGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIGJhY2tncm91bmRDb2xvcjogdGhlbWUuY29sb3IuZmlsbEJyYW5kXG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkeiA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJHosXG4gICAgdG9uZTogdG9uZSRpXG59KTtcblxuY2xhc3MgTGFiZWwgZXh0ZW5kcyBCYXNlJDEge1xuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBCYWNrZ3JvdW5kOiB7fSxcbiAgICAgICAgICAgIFRleHQ6IHtcbiAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICAgICAgdGV4dDoge31cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkxhYmVsXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHo7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJ0aXRsZVwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJCYWNrZ3JvdW5kXCIsIFwiVGV4dFwiIF07XG4gICAgfVxuICAgIF9pbml0KCkge1xuICAgICAgICB0aGlzLl9UZXh0Lm9uKFwidHhMb2FkZWRcIiwgdGhpcy5fdXBkYXRlQmFja2dyb3VuZC5iaW5kKHRoaXMpKTtcbiAgICAgICAgc3VwZXIuX2luaXQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlQmFja2dyb3VuZCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVUZXh0KCk7XG4gICAgfVxuICAgIF91cGRhdGVUZXh0KCkge1xuICAgICAgICBpZiAodGhpcy5fVGV4dCkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgdGV4dDogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIHRleHQ6IHRoaXMudGl0bGVcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUJhY2tncm91bmQoKSB7XG4gICAgICAgIHRoaXMuX1RleHQueCA9IHRoaXMudyAvIDI7X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gICAgICAgICBpZiAodGhpcy5fc2hvdWxkU3luYykge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVNpZ25hbHMoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBfdXBkYXRlKCkge1xuICAgICAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICAgICAgaWYgKHRoaXMuX3Nob3VsZFN5bmMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVTaWduYWxzKCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX2NsZWFudXBTeW5jVmFsdWVzKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX2NsZWFudXBTeW5jVmFsdWVzKCkge1xuICAgICAgICAgICAgdGhpcy5zeW5jQXJyYXkubWFwKChjb21wb25lbnQgPT4ge1xuICAgICAgICAgICAgICAgIGNvbXBvbmVudC5tYXJxdWVlT3ZlcnJpZGVMb29wWCA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICBjb21wb25lbnQuc2lnbmFscyAmJiBjb21wb25lbnQuc2lnbmFscy53aWxsTWFycXVlZSAmJiBkZWxldGUgY29tcG9uZW50LnNpZ25hbHMud2lsbE1hcnF1ZWU7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICAgICAgX3VwZGF0ZVNpZ25hbHMoKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5zeW5jQXJyYXkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnN5bmNBcnJheS5tYXAoKGNvbXBvbmVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudC5zaWduYWxzID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBjb21wb25lbnQuc2lnbmFscyksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB3aWxsTWFycXVlZTogXCJfd2lsbE1hcnF1ZWVcIlxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX3dpbGxNYXJxdWVlKGNvbXBSZWYpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9zaG91bGRTeW5jKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbG9uZ2VzdE1hcnF1ZWVXaWR0aCA9IE1hdGgubWF4KGNvbXBSZWYuX3RleHRSZW5kZXJlZFcgfHwgMCwgdGhpcy5fbG9uZ2VzdE1hcnF1ZWVXaWR0aCB8fCAwKTtcbiAgICAgICAgICAgICAgICB0aGlzLnN5bmNBcnJheS5tYXAoKGNvbXBvbmVudCA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGNvbXBvbmVudC5tYXJxdWVlT3ZlcnJpZGVMb29wWCA9IHRoaXMuX2xvbmdlc3RNYXJxdWVlV2lkdGg7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGdldCBfc2hvdWxkU3luYygpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnN0eWxlLm1hcnF1ZWVTeW5jID09PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghdGhpcy5zeW5jQXJyYXkpIHtcbiAgICAgICAgICAgICAgICBsb2dnZXJJbnN0YW5jZS53YXJuKFwid2FybmluZzogY29tcG9uZW50cyB1c2luZyBNYXJxdWVlU3luYyBtdXN0IGhhdmUgYSBzeW5jQXJyYXkgZ2V0dGVyIGRlZmluZWQuXCIpO1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoIUFycmF5LmlzQXJyYXkodGhpcy5zeW5jQXJyYXkpKSB7XG4gICAgICAgICAgICAgICAgbG9nZ2VySW5zdGFuY2Uud2Fybihc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RsaW5lMSksIHt9LCB7XG4gICAgICAgIG1heExpbmVzOiAxXG4gICAgfSksXG4gICAgbWFycXVlZVN5bmM6IHRydWUsXG4gICAgYWxwaGE6IHRoZW1lLmFscGhhLnByaW1hcnlcbn0pO1xuXG52YXIgbW9kZSQ5ID0gdGhlbWUgPT4gKHtcbiAgICBkaXNhYmxlZDoge1xuICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgfSxcbiAgICAgICAgYWxwaGE6IHRoZW1lLmFscGhhLmluYWN0aXZlXG4gICAgfVxufSk7XG5cbnZhciB0b25lJGggPSB0aGVtZSA9PiAoe1xuICAgIG5ldXRyYWw6IHtcbiAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgfSxcbiAgICAgICAgc3VidGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFNlY29uZGFyeVxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgaW52ZXJzZToge1xuICAgICAgICB0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVxuICAgICAgICB9LFxuICAgICAgICBzdWJ0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVNlY29uZGFyeVxuICAgICAgICB9LFxuICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlXG4gICAgICAgIH0sXG4gICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGRpc2FibGVkOiB7XG4gICAgICAgICAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIHN1YnRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgfSxcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICB0aXRsZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyR5ID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkeSxcbiAgICBtb2RlOiBtb2RlJDksXG4gICAgdG9uZTogdG9uZSRoXG59KTtcblxuY2xhc3MgTWV0YWRhdGFCYXNlIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTWV0YWRhdGFCYXNlXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHk7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgZmxleDoge1xuICAgICAgICAgICAgICAgICAgICBkaXJlY3Rpb246IFwiY29sdW1uXCIsXG4gICAgICAgICAgICAgICAgICAgIGp1c3RpZnlDb250ZW50OiBcImZsZXgtc3RhcnRcIlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgRGV0YWlsc1dyYXBwZXI6IHt9XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJkZXNjcmlwdGlvblwiLCBcImxvZ29cIiwgXCJsb2dvSGVpZ2h0XCIsIFwibG9nb1Bvc2l0aW9uXCIsIFwibG9nb1RpdGxlXCIsIFwibG9nb1dpZHRoXCIsIFwiZGV0YWlsc1wiLCBcInN1YnRpdGxlXCIsIFwidGl0bGVcIiwgXCJtYXJxdWVlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIlRleHRcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJUaXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LlRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTdWJ0aXRsZVwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LlN1YnRpdGxlXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXRhaWxzV3JhcHBlclwiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0LkRldGFpbHNXcmFwcGVyXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJEZXRhaWxzXCIsXG4gICAgICAgICAgICBwYXRoOiBcIlRleHQuRGV0YWlsc1dyYXBwZXIuRGV0YWlsc1wiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiRGVzY3JpcHRpb25cIixcbiAgICAgICAgICAgIHBhdGg6IFwiVGV4dC5EZXNjcmlwdGlvblwiXG4gICAgICAgIH0sIFwiTG9nb1wiIF07XG4gICAgfVxuICAgIF90aXRsZUxvYWRlZCgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlTGF5b3V0KC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gICAgICBpZiAoIXRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LmNoaWxkTGlzdC5hZGRBdCh7XG4gICAgICAgICAgICAgICAgcmVmOiBcIlRpdGxlXCIsXG4gICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl90aXRsZUxvYWRlZFwiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgMCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fVGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgIG1hcnF1ZWU6IHRoaXMubWFycXVlZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlU3VidGl0bGUoKSB7XG4gICAgICAgIGlmICghdGhpcy5zdWJ0aXRsZSAmJiAhdGhpcy5fU3VidGl0bGUpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAoIXRoaXMuX1N1YnRpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0LmNoaWxkTGlzdC5hZGRBdCh7XG4gICAgICAgICAgICAgICAgcmVmOiBcIlN1YnRpdGxlXCIsXG4gICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9zdWJ0aXRsZUxvYWRlZFwiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgMSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fU3VidGl0bGUucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5zdWJ0aXRsZSxcbiAgICAgICAgICAgIG1hcnF1ZWU6IHRoaXMubWFycXVlZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuc3VidGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICByZXNldE1hcnF1ZWUoKSB7XG4gICAgICAgIGlmICh0aGlzLm1hcnF1ZWUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnRpdGxlKSB7XG4gICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVUaXRsZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLl9UaXRsZS50b2dnbGVNYXJxdWVlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5kZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5fRGVzY3JpcHRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlRGVzY3JpcHRpb24oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5fRGVzY3JpcHRpb24udG9nZ2xlTWFycXVlZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVEZXRhaWxzKCkge1xuICAgICAgICBpZiAoIXRoaXMuZGV0YWlscyAmJiAhdGhpcy5fRGV0YWlscykge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fRGV0YWlscykge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlsc1dyYXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgICAgIERldGFpbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX2RldGFpbHNMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fRGV0YWlscy5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLmRldGFpbHMsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS5kZXRhaWxzVGV4dFN0eWxlXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBpZiAodGhpcy5fRGV0YWlscy5maW5hbFcgPiB0aGlzLl90ZXh0VygpKSB7XG4gICAgICAgICAgICB0aGlzLl9EZXRhaWxzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICB3OiB0aGlzLl90ZXh0VygpICsgdGhpcy5zdHlsZS5mYWRlV2lkdGggLyAyLFxuICAgICAgICAgICAgICAgIHNoYWRlcjoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBGYWRlU2hhZGVyLFxuICAgICAgICAgICAgICAgICAgICBwb3NpdGlvbkxlZnQ6IDAsXG4gICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uUmlnaHQ6IHRoaXMuc3R5bGUuZmFkZVdpZHRoXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBydHQ6IHRydWVcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlsc1dyYXBwZXIuc2hhZGVyID0gdW5kZWZpbmVkO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX0RldGFpbHNXcmFwcGVyLnZpc2libGUgPSB0aGlzLmRldGFpbHMgPyB0cnVlIDogZmFsc2U7XG4gICAgICAgIHRoaXMuX0RldGFpbHNXcmFwcGVyLmFscGhhID0gdGhpcy5zdHlsZS5hbHBoYTtcbiAgICB9XG4gICAgX3VwZGF0ZURlc2NyaXB0aW9uKCkge1xuICAgICAgICBpZiAoIXRoaXMuZGVzY3JpcHRpb24gJiYgIXRoaXMuX0Rlc2NyaXB0aW9uKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLl9EZXNjcmlwdGlvbikge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5jaGlsZExpc3QuYWRkKHtcbiAgICAgICAgICAgICAgICByZWY6IFwiRGVzY3JpcHRpb25cIixcbiAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX2Rlc2NyaXB0aW9uTG9hZGVkXCJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9EZXNjcmlwdGlvbi5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLmRlc2NyaXB0aW9uLFxuICAgICAgICAgICAgbWFycXVlZTogdGhpcy5tYXJxdWVlLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXNjcmlwdGlvblRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogdGhpcy5fVGV4dC53XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVMb2dvKCkge1xuICAgICAgICBpZiAoIXRoaXMubG9nbyAmJiAhdGhpcy5fTG9nbykge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5fTG9nbykge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgTG9nbzoge1xuICAgICAgICAgICAgICAgICAgICBmbGV4SXRlbTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEljb25cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmxvZ29Qb3NpdGlvbiA9IHRoaXMubG9nb1Bvc2l0aW9uIHx8IFwicmlnaHRcIjtcbiAgICAgICAgdmFyIHN1YnRpdGxlSCA9IHRoaXMuc3VidGl0bGUgJiYgdGhpcy5fU3VidGl0bGUgJiYgdGhpcy5fU3VidGl0bGUuaCB8fCAwO1xuICAgICAgICB0aGlzLl9Mb2dvLnBhdGNoKHtcbiAgICAgICAg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2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VTZWNvbmRhcnlcbiAgICAgICAgfSxcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgIH0sXG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGRpc2FibGVkOiB7XG4gICAgICAgICAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsRGlzYWJsZWRcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJHggPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSR4LFxuICAgIHRvbmU6IHRvbmUkZ1xufSk7XG5cbmNsYXNzIE1ldGFkYXRhVGlsZSBleHRlbmRzIE1ldGFkYXRhQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTWV0YWRhdGFUaWxlXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJHg7XG4gICAgfVxuICAgIF91cGRhdGVEZXRhaWxzKCkge1xuICAgICAgICBpZiAoIXRoaXMuZGV0YWlscyAmJiAhdGhpcy5fRGV0YWlscykge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmRlc2NyaXB0aW9uICYmIHRoaXMuX0RldGFpbHMpIHtcbiAgICAgICAgICAgIHRoaXMuX0RldGFpbHMucGF0Y2goe1xuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFwiXCJcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5fRGV0YWlscy5hbHBoYSA9IDA7XG4gICAgICAgICAgICB0aGlzLl9EZ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9XG59KTtcblxudmFyIG1vZGUkOCA9IHRoZW1lID0+ICh7XG4gICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgYWxwaGE6IHRoZW1lLmFscGhhLmluYWN0aXZlXG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkdiA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJHYsXG4gICAgbW9kZTogbW9kZSQ4LFxuICAgIHRvbmU6IHRvbmUkZVxufSk7XG5cbmNsYXNzIFRpbGUgZXh0ZW5kcyBTdXJmYWNlIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiVGlsZVwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyR2O1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fdGVtcGxhdGUoKSksIHt9LCB7XG4gICAgICAgICAgICBUaWxlOiB7XG4gICAgICAgICAgICAgICAgQXJ0d29yazoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBBcnR3b3JrLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbWFnZUxvYWRlZDogXCJfaW1hZ2VMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBtb3VudDogLjVcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIENvbnRlbnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnQ6IC41XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgc3RhdGljIG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AgX3VwZGF0ZUxvZ28oKSB7XG4gICAgICAgIGlmICghdGhpcy5sb2dvKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBMb2dvOiB1bmRlZmluZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBsb2dvT2JqZWN0ID0ge1xuICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5sb2dvV2lkdGgsXG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmxvZ29IZWlnaHQsXG4gICAgICAgICAgICBpY29uOiB0aGlzLmxvZ28sXG4gICAgICAgICAgICBhbHBoYTogdGhpcy5fc2hvdWxkU2hvd0xvZ28gPyB0aGlzLnN0eWxlLmFscGhhIDogLjAwMSxcbiAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUucGFkZGluZ1gsXG4gICAgICAgICAgICB5OiB0aGlzLl9jYWxjdWxhdGVMb2dvWVBvc2l0aW9uKClcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKCF0aGlzLl9Mb2dvKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBMb2dvOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAxXG4gICAgICAgICAgICAgICAgfSwgbG9nb09iamVjdClcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5hcHBseVNtb290aCh0aGlzLl9Mb2dvLCBsb2dvT2JqZWN0KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfY2FsY3VsYXRlTG9nb1lQb3NpdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuX2lzSW5zZXRNZXRhZGF0YSAmJiB0aGlzLl9NZXRhZGF0YSkge1xuICAgICAgICAgICAgcmV0d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ICAgICAgICAgICAgeTogdGhpcy5zdHlsZS5wYWRkaW5nWSxcbiAgICAgICAgICAgIGFscGhhOiB0aGlzLl9zaG91bGRTaG93QmFkZ2VMYWJlbCA/IDEgOiAuMDAxXG4gICAgICAgIH0pO1xuICAgICAgICBpZiAoIXRoaXMuX0JhZGdlKSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBCYWRnZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQmFkZ2VcbiAgICAgICAgICAgICAgICB9LCBiYWRnZVBhdGNoKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkQmFkZ2U6IFwiX3VwZGF0ZUJhZGdlXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX0JhZGdlLnBhdGNoKGJhZGdlUGF0Y2gpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuYXBwbHlTbW9vdGgodGhpcy5fQmFkZ2UsIGJhZGdlUGF0Y2gsIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgYmFkZ2VQYXRjaCksIHRoaXMuX2JhZGdlTGFiZWxUcmFuc2l0aW9ucykpO1xuICAgIH1cbiAgICBfdXBkYXRlTGFiZWwoKSB7XG4gICAgICAgIHZhciBfdGhpcyRsYWJlbDtcbiAgICAgICAgaWYgKCEoKF90aGlzJGxhYmVsID0gdGhpcy5sYWJlbCkgIT09IG51bGwgJiYgX3RoaXMkbGFiZWwgIT09IHZvaWQgMCAmJiBfdGhpcyRsYWJlbC50aXRsZSkgfHwgdGhpcy5faXNDaXJjbGVMYXlvdXQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLl9MYWJlbCkge1xuICAgICAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBMYWJlbDogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGxhYmVsUGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMubGFiZWwpLCB7fSwge1xuICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgeDogdGhpcy5fdyAtIHRoaXMuc3R5bGUucGFkZGluZ1gsXG4gICAgICAgICAgICB5OiB0aGlzLnN0eWxlLnBhZGRpbmdZLFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuX3Nob3VsZFNob3dCYWRnZUxhYmVsID8gMSA6IC4wMDFcbiAgICAgICAgfSk7XG4gICAgICAgIGlmICghdGhpcy5fTGFiZWwpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIExhYmVsOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBMYWJlbCxcbiAgICAgICAgICAgICAgICAgICAgbW91bnRYOiAxXG4gICAgICAgICAgICAgICAgfSwgbGFiZWxQYXRjaCksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZExhYmVsOiBcIl91cGRhdGVMYWJlbFwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9MYWJlbC5w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gIF91cGRhdGVDaGVja2JveCgpIHtcbiAgICAgICAgdmFyIF90aGlzJGNoZWNrYm94O1xuICAgICAgICBpZiAoISh0eXBlb2YgKChfdGhpcyRjaGVja2JveCA9IHRoaXMuY2hlY2tib3gpID09PSBudWxsIHx8IF90aGlzJGNoZWNrYm94ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRjaGVja2JveC5jaGVja2VkKSA9PT0gXCJib29sZWFuXCIgJiYgdGhpcy5jaGVja2JveC5jaGVja2VkKSB8fCB0aGlzLl9pc0NpcmNsZUxheW91dCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuX0NoZWNrYm94KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIENoZWNrYm94OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgY2hlY2tib3hQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5jaGVja2JveCksIHt9LCB7XG4gICAgICAgICAgICBtb2RlOiB0aGlzLm1vZGUsXG4gICAgICAgICAgICB4OiB0aGlzLl93IC0gdGhpcy5zdHlsZS5wYWRkaW5nWCxcbiAgICAgICAgICAgIHk6IHRoaXMuX2ggLSB0aGlzLnN0eWxlLnBhZGRpbmdZXG4gICAgICAgIH0pO1xuICAgICAgICBpZiAoIXRoaXMuX0NoZWNrYm94KSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBDaGVja2JveDogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBjaGVja2JveFBhdGNoKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQ2hlY2tib3gsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAxXG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ICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZW1vdmVQcm9ncmVzc0JhcigpO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX1Byb2dyZXNzQmFyLnNtb290aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFscGhhOiAwXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVtb3ZlUHJvZ3Jlc3NCYXIoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMucHJvZ3Jlc3NCYXIucHJvZ3Jlc3MgPiAwKSB7XG4gICAgICAgICAgICB2YXIgcHJvZ3Jlc3NQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5wcm9ncmVzc0JhciksIHt9LCB7XG4gICAgICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgICAgIHc6IHRoaXMuX3cgLSB0aGlzLnN0eWxlLnBhZGRpbmdYICogMixcbiAgICAgICAgICAgICAgICB4OiB0aGlzLl93IC8gMixcbiAgICAgICAgICAgICAgICB5OiB0aGlzLl9oIC0gdGhpcy5zdHlsZS5wYWRkaW5nWVByb2dyZXNzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fUHJvZ3Jlc3NCYXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgUHJvZ3Jlc3NCYXI6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgcHJvZ3Jlc3NQYXRjaCksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBQcm9ncmVzc0JhcixcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICAgICAgICAgICAgICBtb3VudFk6IDEsXG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogdGhpcy5faGFzTWV0YWRhdGEgJiYgdGhpcy5zaG91bGRTbW9vdGggPyAuMDAxIDogMVxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLnNob3VsZFNtb290aCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9Qcm9ncmVzc0Jhci5zbW9vdGggPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogWyAxLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXk6IHRoaXMuc3R5bGUuYW5pbWF0aW9uRW50cmFuY2UuZHVyYXRpb25cbiAgICAgICAgICAgICAgICAgICAgICAgIH0gXVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmFwcGx5U21vb3RoKHRoaXMuX1Byb2dyZXNzQmFyLCBwcm9ncmVzc1BhdGNoLCBPYmplY3Qua2V5cyhwcm9ncmVzc1BhdGNoKS5yZWR1Y2UoKChhY2MsIHByb3ApID0+IHtcbiAgICAgICAgICAgICAgICBhY2NbcHJvcF0gPSBbIHByb2dyZXNzUGF0Y2hbcHJvcF0sIHRoaXMuX2lzRm9jdXNlZE1vZGUgPyB0aGlzLnN0eWxlLmFuaW1hdGlvbkVudHJhbmNlIDogdGhpcy5zdHlsZS5hbmltYXRpb25FeGl0IF07XG4gICAgICAgICAgICAgICAgcmV0dXJuIGFjYztcbiAgICAgICAgICAgIH0pLCB7fSkpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9yZW1vdmVQcm9ncmVzc0JhcigpIHtcbiAgICAgICAgdGh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GRlbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMucHJvdmlkZXJzLmxlbmd0aCAtIHRoaXMuX3Zpc2libGVDb3VudDtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgdGhpcy5fcHJvdmlkZXJzID0gW107XG4gICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlUHJvdmlkZXJzKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUNvdW50ZXIoKTtcbiAgICB9XG4gICAgX3VwZGF0ZVByb3ZpZGVycygpIHtcbiAgICAgICAgdmFyIHByb3ZpZGVyTGlzdCA9IFtdO1xuICAgICAgICB0aGlzLnByb3ZpZGVycy5zbGljZSgwLCB0aGlzLnZpc2libGVDb3VudCkuZm9yRWFjaCgocHJvdmlkZXIgPT4ge1xuICAgICAgICAgICAgdmFyIHBhdGNoID0ge1xuICAgICAgICAgICAgICAgIGNlbnRlckluUGFyZW50OiB0cnVlLFxuICAgICAgICAgICAgICAgIHJhZGl1czogdGhpcy5kaXNhYmxlUmFkaXVzID8gMCA6IGdldE1heFJvdW5kUmFkaXVzKHRoaXMuc3R5bGUucmFkaXVzLCB0aGlzLnN0eWxlLml0ZW1TaXplLCB0aGlzLnN0eWxlLml0ZW1TaXplKSxcbiAgICAgICAgICAgICAgICBhbHBoYTogdGhpcy5zdHlsZS5hbHBoYSxcbiAgICAgICAgICAgICAgICBzdHlsZTogcHJvdmlkZXIuc3R5bGUgfHwge31cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAocHJvdmlkZXIudHlwZSA9PT0gSWNvbiAmJiBwcm92aWRlci5pY29uICYmIHByb3ZpZGVyLncgJiYgcHJvdmlkZXIuaCkge1xuICAgICAgICAgICAgICAgIHZhciByYXRpbyA9IHByb3ZpZGVyLncgLyBwcm92aWRlci5oO1xuICAgICAgICAgICAgICAgIHBhdGNoID0gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgaWNvbjogcHJvdmlkZXIuaWNvblxuICAgICAgICAgICAgICAgIH0sIHByb3ZpZGVyKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pdGVtU2l6ZSAqIHJhdGlvLFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLml0ZW1TaXplXG4gICAgICAgICAgICAgICAgfSwgcGF0Y2gpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwYXRjaCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLnN0eWxlLml0ZW1TaXplLFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLml0ZW1TaXplXG4gICAgICAgICAgICAgICAgfSwgcGF0Y2gpO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcHJvdmlkZXIgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICAgICAgcGF0Y2ggPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHBhdGNoKSwgcHJvdmlkZXIpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHBhdGNoLmljb24gPSBwcm92aWRlcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcm92aWRlckxpc3QucHVzaChwYXRjaCk7XG4gICAgICAgIH0pKTtcbiAgICAgICAgdGhpcy5fUm93LnBhdGNoKHtcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUuaXRlbVNwYW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ICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WDogLjUsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUuaXRlbVNpemUgLyAyLFxuICAgICAgICAgICAgICAgICAgICB5OiB0aGlzLnN0eWxlLml0ZW1TaXplIC8gMixcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogdGhpcy5jb3VudGVyVGV4dCB8fCBcIitcIi5jb25jYXQocmVtYWluaW5nKSxcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS5jb3VudGVyVGV4dFN0eWxlXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgdGhpcy5fUm93LmFwcGVuZEl0ZW1zKFsgY291bnRlciBdKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICAkaXRlbUNoYW5nZWQoKSB7XG4gICAgICAgIHRoaXMuc2lnbmFsKFwicHJvdmlkZXJDaGFuZ2VkXCIpO1xuICAgIH1cbiAgICBfZ2V0VmlzaWJsZUNvdW50KCkge1xuICAgICAgICB2YXIgbWluID0gMTtcbiAgICAgICAgdmFyIG1heCA9IHRoaXMucHJvdmlkZXJzLmxlbmd0aDtcbiAgICAgICAgdmFyIHZpc2libGVDb3VudCA9IE1hdGgubWluKE1hdGgubWF4KG1pbiwgdGhpcy5fdmlzaWJsZUNvdW50KSwgbWF4KTtcbiAgICAgICAgaWYgKHRoaXMuX3Zpc2libGVDb3VudCA8IG1pbikge1xuICAgICAgICAgICAgY29uc29sZS53YXJuKFwiV2FybmluZzogVGhlIHNwZWNpZmllZCB2aXNpYmxlIGNvdW50I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mVzOiAzXG4gICAgfSxcbiAgICBkZXNjcmlwdGlvbkRldGFpbHNTdHlsZToge1xuICAgICAgICBwYWRkaW5nWTogNVxuICAgIH0sXG4gICAgZmFkZVdpZHRoOiB0aGVtZS5zcGFjZXIubWQgKiB0aGVtZS5zcGFjZXIubWQsXG4gICAgcHJvdmlkZXI6IHtcbiAgICAgICAgaXRlbVNpemU6IHRoZW1lLnNwYWNlci54eHhsICsgdGhlbWUuc3BhY2VyLm1kXG4gICAgfVxufSk7XG5cbnZhciB0b25lJGMgPSB0aGVtZSA9PiAoe1xuICAgIG5ldXRyYWw6IHtcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VcbiAgICAgICAgfSxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBkZXRhaWxzVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgZGV0YWlsc1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICB9LFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGRldGFpbHNUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkdCA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJHQsXG4gICAgdG9uZTogdG9uZSRjXG59KTtcblxuY2xhc3MgTWV0YWRhdGFDYXJkQ29udGVudCBleHRlbmRzIE1ldGFkYXRhQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTWV0YWRhdGFDYXJkQ29udGVudFwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyR0O1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgVGV4dDoge1xuICAgICAgICAgICAgICAgIGZsZXg6IHtcbiAgICAgICAgICAgICAgICAgICAgZGlyZWN0aW9uOiBcImNvbHVtblwiLFxuICAgICAgICAgICAgICAgICAgICBqdXN0aWZ5Q29udGVudDogXCJmbGV4LXN0YXJ0XCJcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFRpdGxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFN1YnRpdGxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIERlc2NyaXB0aW9uOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIERlc2NyaXB0aW9uRGV0YWlsczoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIERldGFpbHNXcmFwcGVyOiB7XG4gICAgICAgICAgICAgICAgRGV0YWlsc0ZhZGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIERldGFpbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9yZXNvbHZlRGV0YWlsc1wiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFByb3ZpZGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIG1vdW50OiAxLFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBQcm92aWRlcixcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvdmlkZXJDaGFuZ2VkOiBcIl9yZXNvbHZlUHJvdmlkZXJcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aW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wZXIuUHJvdmlkZXJcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF9zZXREZXRhaWxzKGRldGFpbHMpIHtcbiAgICAgICAgaWYgKGRldGFpbHMpIHtcbiAgICAgICAgICAgIHRoaXMuX2RldGFpbHNQcm9taXNlID0gbmV3IFByb21pc2UoKHJlc29sdmUgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMuX2RldGFpbHNQcm9taXNlUmVzb2x2ZXIgPSByZXNvbHZlO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fZGV0YWlsc1Byb21pc2UgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGRldGFpbHM7XG4gICAgfVxuICAgIF9zZXRQcm92aWRlcihwcm92aWRlcikge1xuICAgICAgICBpZiAocHJvdmlkZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX3Byb3ZpZGVyUHJvbWlzZSA9IG5ldyBQcm9taXNlKChyZXNvbHZlID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLl9wcm92aWRlclByb21pc2VSZXNvbHZlciA9IHJlc29sdmU7XG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9wcm92aWRlclByb21pc2UgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHByb3ZpZGVyO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB2YXIgX3RoaXM5ID0gdGhpcztcbiAgICAgICAgcmV0dXJuIF9hc3luY1RvR2VuZXJhdG9yKChmdW5jdGlvbiooKSB7XG4gICAgICAgICAgICBfdGhpczkuX3VwZGF0ZUxpbmVzKCk7XG4gICAgICAgICAgICBfdGhpczkuX3VwZGF0ZVByb3ZpZGVyKCk7XG4gICAgICAgICAgICB5aWVsZCBQcm9taXNlLmFsbChbIF90aGlzOS5fZGV0YWlsc1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IDEsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9UZXh0LndcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZURlc2NyaXB0aW9uKCkge1xuICAgICAgICB0aGlzLl9EZXNjcmlwdGlvbi5wYXRjaCh7XG4gICAgICAgICAgICBjb250ZW50OiB0aGlzLmRlc2NyaXB0aW9uLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXNjcmlwdGlvblRleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9UZXh0LndcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZURlc2NyaXB0aW9uRGV0YWlscygpIHtcbiAgICAgICAgdGhpcy5fRGVzY3JpcHRpb25EZXRhaWxzLnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGVzY3JpcHRpb25EZXRhaWxzLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS5kZXNjcmlwdGlvbkRldGFpbHNUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IHRoaXMuX1RleHQud1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgeTogdGhpcy5zdHlsZS5kZXNjcmlwdGlvbkRldGFpbHNTdHlsZS5wYWRkaW5nWVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZURldGFpbHMoKSB7XG4gICAgICAgIHZhciBtYXhXaWR0aCA9IHRoaXMuX2RldGFpbHNNYXhXO1xuICAgICAgICB0aGlzLl9EZXRhaWxzLnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGV0YWlscyxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuZGV0YWlsc1RleHRTdHlsZSksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIHdvcmRXcmFwOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBtYXhMaW5lczogMSxcbiAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogbWF4V2lkdGggKyB0aGlzLnN0eWxlLmZhZGVXaWR0aCAvIDJcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgaWYgKHRoaXMuX0RldGFpbHMuZmluYWxXID4gbWF4V2lkdGgpIHtcbiAgICAgICAgICAgIHRoaXMuX0RldGFpbHNGYWRlci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgdzogbWF4V2lkdGggKyB0aGlzLnN0eWxlLmZhZGVXaWR0aCAvIDIsXG4gICAgICAgICAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEZhZGVTaGFkZXIsXG4gICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uTGVmdDogMCxcbiAgICAgICAgICAgICAgICAgICAgcG9zaXRpb25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ID0gdGhpcy5fb3JpZW50YXRpb24gPT09IFwiaG9yaXpvbnRhbFwiID8gWyByYWRpdXNbMF0sIDAsIDAsIHJhZGl1c1szXSBdIDogWyByYWRpdXNbMF0sIHJhZGl1c1sxXSwgMCwgMCBdO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9vcmllbnRhdGlvbiAhPT0gXCJob3Jpem9udGFsXCIpIHtcbiAgICAgICAgICAgIHcgPSB0aGlzLnN0eWxlLmV4cGFuZGVkV2lkdGg7XG4gICAgICAgICAgICBoID0gdGhpcy5zdHlsZS5pbWFnZVNpemUuaDtcbiAgICAgICAgfVxuICAgICAgICB2YXIgdGlsZSA9IHRoaXMudGlsZTtcbiAgICAgICAgaWYgKHRoaXMuc3JjKSB7XG4gICAgICAgICAgICB0aWxlID0gdXRpbHMkMS5jbG9uZSh7XG4gICAgICAgICAgICAgICAgc3JjOiB0aGlzLnNyY1xuICAgICAgICAgICAgfSwgdGhpcy50aWxlKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9UaWxlLnBhdGNoKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgaDogaFxuICAgICAgICB9LCB0aWxlKSwge30sIHtcbiAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sICgoX3RpbGUgPSB0aWxlKSA9PT0gbnVsbCB8fCBfdGlsZSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RpbGUuc3R5bGUpIHx8IHt9KSwge30sIHtcbiAgICAgICAgICAgICAgICByYWRpdXM6IHRpbGVSYWRpdXNcbiAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgcGVyc2lzdGVudE1ldGFkYXRhOiB0cnVlLFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuX3Nob3VsZFNob3dUaWxlID8gMSA6IDBcbiAgICAgICAgfSkpO1xuICAgIH1cbiAgIC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pb1k6IDksXG4gICAgICAgIHVwQ291bnQ6IDRcbiAgICB9KS5oICsgdGhlbWUuc3BhY2VyLm1kICogMTQsXG4gICAgbWV0YWRhdGE6IHtcbiAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIG1heExpbmVzOiAxXG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRwID0gT2JqZWN0LmZyZWV6ZSh7XG4gICAgX19wcm90b19fOiBudWxsLFxuICAgIGJhc2U6IGJhc2UkcFxufSk7XG5cbmNsYXNzIENhcmRDb250ZW50VmVydGljYWxTbWFsbCBleHRlbmRzIENhcmRDb250ZW50VmVydGljYWwge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJDYXJkQ29udGVudFZlcnRpY2FsU21hbGxcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkcDtcbiAgICB9XG4gICAgX3NldE1ldGFkYXRhKG1ldGFkYXRhKSB7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIG1ldGFkYXRhKSwge30sIHtcbiAgICAgICAgICAgIGRldGFpbHM6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgIHByb3ZpZGVyOiB1bmRlZmluZWRcbiAgICAgICAgfSk7XG4gICAgfVxufVxuXG52YXIgYmFzZSRvID0gdGhlbWUgPT4ge1xuICAgIHZhciBzdHJva2VXaWR0aCA9IHRoZW1lLnN0cm9rZS5zbTtcbiAgICB2YXIgc2l6ZSA9IHRoZW1lLnNwYWNlci54bDtcbiAgICByZXR1cm4ge1xuICAgICAgICB3aWR0aDogc2l6ZSxcbiAgICAgICAgaGVpZ2h0OiBzaXplLFxuICAgICAgICBpY29uV2lkdGg6IHRoZW1lLnNwYWNlci5tZCxcbiAgICAgICAga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AgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghdGhpcy5pdGVtcy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkY29sdW1uRW1wdHlcIik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgJGNvbHVtbkNoYW5nZWQoKSB7XG4gICAgICAgIHRoaXMucXVldWVSZXF1ZXN0VXBkYXRlKCk7XG4gICAgfVxuICAgIF9pc09uU2NyZWVuKGNoaWxkKSB7XG4gICAgICAgIGlmICghY2hpbGQpIHJldHVybiBmYWxzZTtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2lzQ29tcG9uZW50VmVydGljYWxseVZpc2libGUoY2hpbGQpO1xuICAgIH1cbiAgICBvblNjcmVlbkVmZmVjdCgpIHt9XG59XG5cbnZhciBiYXNlJG0gPSB0aGVtZSA9PiB7XG4gICAgdmFyIHBhZGRpbmdYID0gdGhlbWUuc3BhY2VyLmxnO1xuICAgIHZhciByYWRpdXMgPSB0aGVtZS5yYWRpdXMueGw7XG4gICAgdmFyIGxvZ29SYWRpdXMgPSBNYXRoLm1heChyYWRpdXMgLSBwYWRkaW5nWCAvIDIsIDApO1xuICAgIHJldHVybiB7XG4gICAgICAgIGhlaWdodDogdGhlbWUuc3BhY2VyLm1kICogOCxcbiAgICAgICAgaWNvblN0eWxlOiB7XG4gICAgICAgICAgICByYWRpdXM6IHJhZGl1cyxcbiAgICAgICAgICAgIHdpZHRoOiB0aGVtZS5zcGFjZXIueHh4bCxcbiAgICAgICAgICAgIGhlaWdodDogdGhlbWUuc3BhY2VyLnh4eGxcbiAgICAgICAgfSxcbiAgICAgICAgbG9nb1N0eWxlOiB7XG4gICAgICAgICAgICByYWRpdXM6IGxvZ29SYWRpdXMsXG4gICAgICAgICAgICB3aWR0aDogdGhlbWUuc3BhY2VyLm1kICogNyxcbiAgICAgICAgICAgIGhlaWdodDogdGhlbWUuc3BhY2VyLm1kICogN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kYXRlVGl0bGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29sbGFwc2VTdGF0dXMoKTtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgIH1cbiAgICBfdXBkYXRlQ29sbGFwc2VTdGF0dXMoKSB7XG4gICAgICAgIGlmICh0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fVGl0bGUudmlzaWJsZSA9ICF0aGlzLl9jb2xsYXBzZTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlUHJlZml4U3R5bGUoKSB7XG4gICAgICAgIGlmICh0aGlzLl9wcmVmaXgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmxvZ28pIHtcbiAgICAgICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhPYmoodGhpcy5sb2dvLCB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yOiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICAgICAgfSwgdGhpcy5zdHlsZS5sb2dvU3R5bGUpXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaWNvbikge1xuICAgICAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaih0aGlzLmljb24sIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHRoaXMuc3R5bGUuaWNvblN0eWxlXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3BhdGNoVGl0bGUoeCwgbW91bnRYKSB7XG4gICAgICAgIHRoaXMuX1RpdGxlLnBhdGNoKHtcbiAgICAgICAgICAgIHg6IHgsXG4gICAgICAgICAgICBtb3VudFg6IG1vdW50WFxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnRQb3NpdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuX3ByZWZpeCAmJiB0aGlzLl9UaXRsZSkge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgbW91bnRYOiAwLFxuICAgICAgICAgICAgICAgIHg6IHRoaXMuX3BhZGRpbmdMZWZ0XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHN3aXRjaCAodGhpcy5fanVzdGlmeSkge1xuICAgICAgICAgICAgICBjYXNlIFwibGVmdFwiOlxuICAgICAgICAgICAgICAgIHRoaXMuX3BhdGNoVGl0bGUoMCwgMCk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSBcInJpZ2h0XCI6XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMudyA8IHRoaXMuX1ByZWZpeC53ICsgdGhpcy5fVGl0bGUudykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXRjaFRpdGxlKDAsIDApO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBsZWZ0T3ZlclNwYWNlID0gdGhpcy53IC0gKHRoaXMuX3BhZGRpbmdMZWZ0ICsgdGhpcy5fcGFkZGluZ1JpZ2h0ICsgdGhpcy5fUHJlZml4LncgKyB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGF0Y2hUaXRsZShsZWZ0T3ZlclNwYWNlLCAxKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgICAgY2FzZSBcImNlbnRlclwiOlxuICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmZpeGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLncgPCB0aGlzLl9QcmVmaXgudyArIHRoaXMuX1RpdGxlLncpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhdGNoVGl0bGUoMCwgMCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWlkZGxlID0gKHRoaXMudyAtICh0aGlzLl9wYWRkaW5nTGVmdCArIHRoaXMuX1ByZWZpeC53ICsgdGhpcy5fcGFkZGluZ1JpZ2h0KSkgLyAyO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGF0Y2hUaXRsZShtaWRkbGUsIC41KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fUHJlZml4ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIF9taWRkbGUgPSAodGhpcy53IC0gKHRoaXMuX3BhZGRpbmdMZWZ0ICsgdGhpcy5fUHJlZml4LncgKyB0aGlzLnN0eWxlLmNvbnRlbnRTcGFjaW5nICsgdGhpcy5fcGFkZGluZ1JpZ2h0KSkgLyAyO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXRjaFRpdGxlKF9taWRkbGUsIC41KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdXBlci5fdXBkYXRlQ29udGVudFBvc2l0aW9uKCk7XG4gICAgICAgICAgICB0aGlzLl9UaXRsZSAmJiB0aGlzLl9wYXRjaFRpdGxlKDAsIDApO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9zZXRQcmVmaXgoKSB7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG4gICAgX3NldFN1ZmZpeCgpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBfdXBkYXRlUHJlZml4T2JqKGljb24pIHtcbiAgICAgICAgdmFyIHByb3BzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB7fTtcbiAgICAgICAgdGhpcy5fcHJlZml4ID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgaWNvbjogaWNvblxuICAgICAgICB9LCBwcm9wcyk7XG4gICAgfVxuICAgIF9zZXRJY29uKGljb24pIHtcbiAgICAgICAgaWYgKCF0aGlzLmxvZ28pIHtcbiAgICAgICAgICAgIGlmIChpY29uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlUHJlZml4T2JqKGljb24sIHtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHRoaXMuc3R5bGUuaWNvblN0eWxlXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuX3ByZWZpeCA9IGljb247XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGljb247XG4gICAgfVxuICAgIF9zZXRMb2dvKGxvZ28pIHtcbiAgICAgICAgaWYgKGxvZ28pIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaihsb2dvLCB7XG4gICAgICAgICAgICAgICAgc3R5bGU6IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICBjb2xvcjogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfSwgdGhpcy5zdHlsZS5sb2dvU3R5bGUpXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLmljb24pIHtcbiAgICAgICAgICAgIHRoaXMuX3VwZGF0ZVByZWZpeE9iaih0aGlzLmljb24sIHtcbiAgICAgICAgICAgICAgICBzdHlsZTogdGhpcy5zdHlsZS5pY29uU3R5bGVcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IG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PSBbXTtcbiAgICAgICAgdGhpcy5fcmlnaHRDb250cm9scyA9IFtdO1xuICAgICAgICB0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleCA9IC0xO1xuICAgICAgICB0aGlzLl9sYXN0SXRlbUluZGV4ID0gLTE7XG4gICAgICAgIHRoaXMuX2xhenlMb2FkQnVmZmVyID0gMDtcbiAgICB9XG4gICAgX3VwZGF0ZUNvbnRlbnQoKSB7XG4gICAgICAgIHZhciBpdGVtc1RvQXBwZW5kID0gW107XG4gICAgICAgIGlmICh0aGlzLmxlZnRDb250cm9scy5sZW5ndGgpIHtcbiAgICAgICAgICAgIGl0ZW1zVG9BcHBlbmQucHVzaCguLi50aGlzLl93aXRoRXh0cmFTcGFjaW5nKHRoaXMubGVmdENvbnRyb2xzLCB0cnVlKSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuY29udGVudEl0ZW1zLmxlbmd0aCkge1xuICAgICAgICAgICAgaXRlbXNUb0FwcGVuZC5wdXNoKC4uLnRoaXMuX3dpdGhFeHRyYVNwYWNpbmcodGhpcy5jb250ZW50SXRlbXMpKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5yaWdodENvbnRyb2xzLmxlbmd0aCkge1xuICAgICAgICAgICAgaXRlbXNUb0FwcGVuZC5wdXNoKC4uLnRoaXMucmlnaHRDb250cm9scyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGl0ZW1zVG9BcHBlbmQubGVuZ3RoKSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBhbHBoYTogMSxcbiAgICAgICAgICAgICAgICBpdGVtczogaXRlbXNUb0FwcGVuZCxcbiAgICAgICAgICAgICAgICBzZWxlY3RlZEluZGV4OiB0aGlzLmxlZnRDb250cm9scy5sZW5ndGgsXG4gICAgICAgICAgICAgICAgc3RhcnRMYXp5U2Nyb2xsSW5kZXg6IHRoaXMubGVmdENvbnRyb2xzLmxlbmd0aCxcb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kZXggKz0gY29udHJvbHMubGVuZ3RoO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgc3RhcnRMYXp5U2Nyb2xsSW5kZXg6IHRoaXMubGVmdENvbnRyb2xzLmxlbmd0aCxcbiAgICAgICAgICAgIHN0b3BMYXp5U2Nyb2xsSW5kZXg6IHRoaXMubGVmdENvbnRyb2xzLmxlbmd0aCArIHRoaXMuaXRlbXMubGVuZ3RoIC0gMVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgYWRkTGVmdENvbnRyb2xzQXQoY29udHJvbHMsIGluZGV4KSB7XG4gICAgICAgIHZhciBpdGVtc1RvQWRkID0gdGhpcy5fY3JlYXRlQ29udHJvbHMoY29udHJvbHMpO1xuICAgICAgICBpZiAoaW5kZXggPT09IHRoaXMuX2xhc3RMZWZ0Q29udHJvbEluZGV4ICsgMSkge1xuICAgICAgICAgICAgdGhpcy5hZGRMZWZ0Q29udHJvbHMoY29udHJvbHMpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fYXBwZW5kSXRlbXNBdChpdGVtc1RvQWRkLCBpbmRleCk7XG4gICAgICAgICAgICBpZiAodGhpcy5sZWZ0Q29udHJvbHMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9sZWZ0Q29udHJvbHMuc3BsaWNlKGluZGV4LCAwLCAuLi5jb250cm9scyk7XG4gICAgICAgICAgICAgICAgdGhpcy5fbGFzdExlZnRDb250cm9sSW5kZXggPSB0aGlzLl9sZWZ0Q29udHJvbHMubGVuZ3RoIC0gMTtcbiAgICAgICAgICAgICAgICB0aGlzLl9sYXN0SXRlbUluZGV4ICs9IGNvbnRyb2xzLmxlbmd0aDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIHN0YXJ0TGF6eVNjcm9sbEluZGV4OiB0aGlzLmxlZnRDb250cm9scy5sZW5ndGgsXG4gICAgIC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bnRyb2xzLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuc2xpY2UoMCwgdGhpcy5fbGFzdExlZnRDb250cm9sSW5kZXggKyAxKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gW107XG4gICAgfVxuICAgIF9nZXRDb250ZW50SXRlbUl0ZW1zKCkge1xuICAgICAgICBpZiAodGhpcy5jb250ZW50SXRlbXMubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5pdGVtcy5zbGljZSh0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleCArIDEsIHRoaXMuX2xhc3RJdGVtSW5kZXggKyAxKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gW107XG4gICAgfVxuICAgIF9nZXRSaWdodENvbnRyb2xJdGVtcygpIHtcbiAgICAgICAgaWYgKHRoaXMucmlnaHRDb250cm9scy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHZhciBsZWZ0U2libGluZ0luZGV4ID0gdGhpcy5fbGFzdEl0ZW1JbmRleCB8fCB0aGlzLl9sYXN0TGVmdENvbnRyb2xJbmRleDtcbiAgICAgICAgICAgIHJldHVybiBsZWZ0U2libGluZ0luZGV4ID8gdGhpcy5pdGVtcy5zbGljZShsZWZ0U2libGluZ0luZGV4ICsgMSkgOiB0aGlzLml0ZW1zO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBbXTtcbiAgICB9XG4gICAgc2V0IGxlZnRDb250cm9scyhsZWZ0Q29udHJvbHMpIHtcbiAgICAgICAgdGhpcy5fc2V0TGVmdENvbnRyb2xzKGxlZnRDb250cm9scyk7XG4gICAgfVxuICAgIGdldCBsZWZ0Q29udHJvbHMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9nZXRMZWZ0Q29udHJvbHMoKTtcbiAgICB9XG4gICAgc2V0IHJpZ2h0Q29udHJvbHMocmlnaHRDb250cm9scykge1xuICAgICAgICB0aGlzLl9zZXRSaWdodENvb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LFxuICAgIGJhc2U6IGJhc2UkaVxufSk7XG5cbmNsYXNzIFNwYWNlciBleHRlbmRzIEJhc2UkMSB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIlNwYWNlclwiO1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgTGluZToge1xuICAgICAgICAgICAgICAgIGg6IFNwYWNlci5fbGluZVRoaWNrbmVzcyxcbiAgICAgICAgICAgICAgICByZWN0OiB0cnVlLFxuICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgVGlja0xlZnQ6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgU3BhY2VyLl90aWNrKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgeDogU3BhY2VyLl9saW5lVGhpY2tuZXNzICogLTFcbiAgICAgICAgICAgICAgICB9KSxcbiAgICAgICAgICAgICAgICBUaWNrUmlnaHQ6IFNwYWNlci5fdGlja1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIFwibGluZUNvbG9yXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkxpbmVcIiwgXCJUaWNrTGVmdFwiLCBcIlRpY2tSaWdodFwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX2xpbmVUaGlja25lc3MoKSB7XG4gICAgICAgIHJldHVybiAzO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF90aWNrTGVuZ3RoKCkge1xuICAgICAgICByZXR1cm4gMjU7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX3RpY2soKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICByZWN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GVydHk6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX3VwZGF0ZVwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFZhbHVlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBjZW50ZXJJblBhcmVudDogdHJ1ZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIENvbHVtbnM6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICB0eXBlOiBSb3dcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBNYXJnaW5zOiB7XG4gICAgICAgICAgICAgICAgYWxwaGE6IC4wMDEsXG4gICAgICAgICAgICAgICAgSG9yaXpvbnRhbDoge1xuICAgICAgICAgICAgICAgICAgICBMZWZ0OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BhY2VyTG9hZGVkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBSaWdodDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3BhY2VyLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYWNlckxvYWRlZDogXCJfdXBkYXRlXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgVmVydGljYWw6IHtcbiAgICAgICAgICAgICAgICAgICAgVG9wOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICB2ZXJ0aWNhbDogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIFNhZmU6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICBIb3Jpem9udGFsOiB7XG4gICAgICAgICAgICAgICAgICAgIExlZnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjZXJMb2FkZWQ6IFwiX3VwZGF0ZVwiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIFJpZ2h0OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BhY2VyTG9hZGVkOiBcIl91cGRhdGVcIlxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBWZXJ0aWNhbDoge1xuICAgICAgICAgICAgICAgICAgICBUb3A6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFNwYWNlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHZlcnRpY2FsOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIEJvdHRvbToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogU3BhY2VyLFxuICAgICAgICAgICAgICAgICAgICAgICAgdmVydGljYWw6IHRydWVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBHdXR0ZXJzOiB7XG4gICAgICAgICAgICAgICAgYWxwaGE6IC4wMDEsXG4gICAgICAgICAgICAgICAgSG9yaXpvbnRhbDoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBTcGFjZXIsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwYWNlckxvYWRlZDogXCJfdXBkYXRlXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBUZXh0UGFuZWw6IHtcbiAgICAgICAgICAgICAgICBhbHBoYTogLjAwMSxcbiAgICAgICAgICAgICAgICB0eXBlOiBDb2x1bW4sXG4gICAgICAgICAgICAgICAgYXV0b1Jlc2l6ZUhlaWdodDogdHJ1ZSxcbiAgICAgICAgICAgICAgICBJdGVtczoge1xuICAgICAgICAgICAgICAgICAgICBTY3JlZW5XOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBTY3JlZW5IOiB0ZXh0Um93LFxuICAgICAgICAgICAgICAgICAgICBDb2x1bW5Db3VudDogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgTWFyZ2luWDogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgTWFyZ2luWTogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgR3V0dGVyWDogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgR3V0dGVyWTogdGV4dFJvdyxcbiAgICAgICAgICAgICAgICAgICAgU2FmZTogdGV4dFJvd1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcInNob3dDb2x1bW5zXCIsIFwic2hvd01hcmdpbnNcIiwgXCJzaG93U2FmZVwiLCBcInNob3dHdXR0ZXJzXCIsIFwic2hvd1RleHRcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQ29sdW1uc1wiLCBcIk1hcmdpbnNcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5Ib3Jpem9udGFsXCIsXG4gICAgICAgICAgICBwYXRoOiBcIk1hcmdpbnMuSG9yaXpvbnRhbFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiTWFyZ2luTGVmdFwiLFxuICAgICAgICAgICAgcGF0aDogXCJNYXJnaW5zLkhvcml6b250YWwuTGVmdFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiTWFyZ2luUmlnaHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiTWFyZ2lucy5Ib3Jpem9udGFsLlJpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5WZXJ0aWNhbFwiLFxuICAgICAgICAgICAgcGF0aDogXCJNYXJnaW5zLlZlcnRpY2FsXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJNYXJnaW5Ub3BcIixcbiAgICAgICAgICAgIHBhdGg6IFwiTWFyZ2lucy5WZXJ0aWNhbC5Ub3BcIlxuICAgICAgICB9LCBcIlNhZmVcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlSG9yaXpvbnRhbFwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLkhvcml6b250YWxcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNhZmVMZWZ0XCIsXG4gICAgICAgICAgICBwYXRoOiBcIlNhZmUuSG9yaXpvbnRhbC5MZWZ0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlUmlnaHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiU2FmZS5Ib3Jpem9udGFsLlJpZ2h0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTYWZlVmVydGljYWxcIixcbiAgICAgICAgICAgIHBhdGg6IFwiU2FmZS5WZXJ0aWNhbFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiU2FmZVRvcFwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLlZlcnRpY2FsLlRvcFwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiU2FmZUJvdHRvbVwiLFxuICAgICAgICAgICAgcGF0aDogXCJTYWZlLlZlcnRpY2FsLkJvdHRvbVwiXG4gICAgICAgIH0sIFwiR3V0dGVyc1wiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIkd1dHRlckhvcml6b250YWxcIixcbiAgICAgICAgICAgIHBhdGg6IFwiR3V0dGVycy5Ib3Jpem9udGFsXCJcbiAgICAgICAgfSwgXCJUZXh0UGFuZWxcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJUZXh0U2NyZWVuV1wiLFxuICAgICAgICAgICAgcGF0aDogXCJUZXh0UGFuZWwuSXRlbXMuU2NyZWVuV1wiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVGV4dFNjcmVlbkhcIixcbiAgICAgICAgICAgIHBhdGg6IFwiVGV4dFBhbmVs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bWVQcm9wcygpO1xuICAgICAgICB0aGlzLl91cGRhdGVNYXJnaW5zKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVNhZmUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29sdW1ucygpO1xuICAgICAgICB0aGlzLl91cGRhdGVHdXR0ZXJzKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRleHQoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVmlzaWJpbGl0eSgpO1xuICAgIH1cbiAgICBfdXBkYXRlVmlzaWJpbGl0eSgpIHtcbiAgICAgICAgdGhpcy5fQ29sdW1ucy5zbW9vdGggPSB7XG4gICAgICAgICAgICBhbHBoYTogTnVtYmVyKHRoaXMuc2hvd0NvbHVtbnMpXG4gICAgICAgIH07XG4gICAgICAgIHRoaXMuX01hcmdpbnMuc21vb3RoID0ge1xuICAgICAgICAgICAgYWxwaGE6IE51bWJlcih0aGlzLnNob3dNYXJnaW5zKVxuICAgICAgICB9O1xuICAgICAgICB0aGlzLl9TYWZlLnNtb290aCA9IHtcbiAgICAgICAgICAgIGFscGhhOiBOdW1iZXIodGhpcy5zaG93U2FmZSlcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5fR3V0dGVycy5zbW9vdGggPSB7XG4gICAgICAgICAgICBhbHBoYTogTnVtYmVyKHRoaXMuc2hvd0d1dHRlcnMpXG4gICAgICAgIH07XG4gICAgICAgIHRoaXMuX1RleHRQYW5lbC5zbW9vdGggPSB7XG4gICAgICAgICAgICBhbHBoYTogTnVtYmVyKHRoaXMuc2hvd1RleHQpXG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVHbG9iYWxUaGVtZVByb3BzKCkge1xuICAgICAgICB2YXIge2xheW91dDogbGF5b3V0LCBjb2xvcjogY29sb3J9ID0gY29udGV4dEluc3RhbmNlLnRoZW1lO1xuICAgICAgICB2YXIge3NjcmVlblc6IHNjcmVlblcsIHNjcmVlbkg6IHNjcmVlbkgsIGNvbHVtb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V4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFNlY29uZGFyeVxuICAgIH0pLFxuICAgIG1pbldpZHRoOiBnZXRXaWR0aEJ5VXBDb3VudCh0aGVtZSwgNCksXG4gICAgcGFkZGluZ1g6IHRoZW1lLnNwYWNlci54bCxcbiAgICBwYWRkaW5nWTogdGhlbWUuc3BhY2VyLnhsLFxuICAgIGJhY2tncm91bmRDb2xvcjogdGhlbWUuY29sb3IuaW50ZXJhY3RpdmVOZXV0cmFsXG59KTtcblxudmFyIG1vZGUkNiA9IHRoZW1lID0+ICh7XG4gICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgZXllYnJvd1RleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgIH0sXG4gICAgICAgIGhlbHBUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICB9XG4gICAgfSxcbiAgICBmb2N1c2VkOiB7XG4gICAgICAgIGN1cnNvclN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlXG4gICAgICAgIH0sXG4gICAgICAgIGV5ZWJyb3dUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgfSxcbiAgICAgICAgaGVscFRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFNlY29uZGFyeVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciB0b25lJGEgPSB0aGVtZSA9PiAoe1xuICAgIGludmVyc2U6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGV5ZWJyb3dUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgaGVscFRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkaCA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJGgsXG4gICAgbW9kZTogbW9kZSQ2LFxuICAgIHRvbmU6IHRvbmUkYVxufSk7XG5cbmNsYXNzIElucHV0IGV4dGVuZHMgQnV0dG9uIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiSW5wdXRcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkaDtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgc3VwZXIuX3RlbXBsYXRlKCkpLCB7fSwge1xuICAgICAgICAgICAgRXllYnJvdzoge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBIZWxwVGV4dDoge1xuICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3hcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc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iAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RpdGxlLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGhpcy5zdHlsZS50ZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IGZhbHNlXG4gICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZUV5ZWJyb3coKSB7XG4gICAgICAgIHRoaXMuX0V5ZWJyb3cucGF0Y2goe1xuICAgICAgICAgICAgY29udGVudDogdGhpcy5leWVicm93LFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUuZXllYnJvd1RleHRTdHlsZVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIG1vdW50WTogMSxcbiAgICAgICAgICAgIHg6IHRoaXMuc3R5bGUucGFkZGluZ1gsXG4gICAgICAgICAgICB5OiB0aGlzLnkgLSB0aGlzLnN0eWxlLnBhZGRpbmdZXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlSGVscFRleHQoKSB7XG4gICAgICAgIHRoaXMuX0hlbHBUZXh0LnBhdGNoKHtcbiAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuaGVscFRleHQsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS5oZWxwVGV4dFN0eWxlXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5wYWRkaW5nWCxcbiAgICAgICAgICAgIHk6IHRoaXMueSArIHRoaXMuaW5uZXJIICsgdGhpcy5zdHlsZS5wYWRkaW5nWVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX3VwZGF0ZVRleHRXcmFwcGVyKCkge1xuICAgICAgICB0aGlzLl9UZXh0V3JhcHBlci5jbGlwcGluZyA9IHRydWU7XG4gICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLncgPSB0aGlzLl92aXNpYmxlQ29udGVudFdpZHRoO1xuICAgICAgICBpZiAodGhpcy5fVGl0bGUpIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLmggPSB0aGlzLl9UaXRsZS5oO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVIaWRkZW5Db250ZW50KCkge1xuICAgICAgICBpZiAoIXRoaXMuX0hpZGRlbkNvbnRlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuX0NvbnRlbnQucGF0Y2goe1xuICAgICAgICAgICAgICAgIEhpZGRlbkNvbnRlbnQ6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMixcbiAgICAgICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEJveENoYW5nZWQ6IFwiX29uSGlkZGVuVGV4dEJveENoYW5nZWRcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHt0aXRsZTogdmFsdWUgPSBcIlwiLCBwb3NpdGlvbjogcG9zaXRpb24sIHBhc3N3b3JkOiBwYXNzd29yZCwgbWFzazogbWFza30gPSB0aGlzO1xuICAgICAgICB2YXIgdGV4dEJlZm9yZUN1cnNvciA9IHBhc3N3b3JkID8gbWFzay5yZXBlYXQodmFsdWUubGVuZ3RoKS5zdWJzdHJpbmcoMCwgcG9zaXRpb24pIDogdmFsdWUuc3Vic3RyaW5nKDAsIHBvc2l0aW9uKTtcbiAgICAgICAgdGhpcy5fSGlkZGVuQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIHRleHRTdHlsZTogdGhpcy5zdHlsZS50ZXh0U3R5bGVcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb250ZW50OiB0ZXh0QmVmb3JlQ3Vyc29yXG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLl9IaWRkZW5Db250ZW50Ll9UZXh0ICYmIHRoaXMuX0hpZGRlbkNvbnRlbnQuX1RleHQucGF0Y2goe1xuICAgICAgICAgICAgYWxwaGE6IC4wMDFcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVDdXJzb3IoKSB7XG4gICAgICAgIGlmICh0aGlzLnN0eWxlLmN1cnNvclN0eWxlICYmIHRoaXMuc3R5bGUuY3Vyc29yU3R5bGUuYmxpbmspIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5fQ3Vyc29yKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIEN1cnNvcjoge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIHRoaXMuY3Vyc29yQmxpbmsgPSB0aGlzLl9DdXJzb3IuYW5pbWF0aW9uKHtcbiAgICAgICAgICAgICAgICAgICAgZHVyYXRpb246IDEuNSxcbiAgICAgICAgICAgICAgICAgICAgcmVwZWF0OiAtMSxcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uczogWyB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwOiBcImFscGhhXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICB2OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgMDogMCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuNTogMSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAxOiAwXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0gXVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fQ3Vyc29yLnBhdGNoKHRoaXMuc3R5bGUuY3Vyc29yU3R5bGUpO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVDdXJzb3JMaXN0ZW5pbmcoKSB7XG4gICAgICAgIGlmICghdGhpcy5faXNEaXNhYmxlZE1vZGUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmN1cnNvckJsaW5rICYmICF0aGlzLmN1cnNvckJsaW5rLmlzUGxheWluZygpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jdXJzb3JCbGluay5zdGFydCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3Vyc29yQmxpbmspIHRoaXMuaXNDdXJzb3JBY3RpdmUgPyB0aGlzLmN1cnNvckJsaW5rLnN0YXJ0KCkgOiB0aGlzLmN1cnNvckJsaW5rLnN0b3AoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9DdXJzb3Iuc21vb3RoID0ge1xuICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY3Vyc29yU3R5bGUudGV4dENvbG9yXG4gICAgICAgIH07XG4gICAgfVxuICAgIF91cGRhdGVDdXJzb3JCbGluaygpIHtcbiAgICAgICAgaWYgKHRoaXMuY3Vyc29yQmxpbmspIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzQ3Vyc29yQWN0aXZlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jdXJzb3JCbGluay5zdGFydCgpO1xuICAgICAgICAgICAgfSBlbH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ICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SaWdodCA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5vblJpZ2h0KHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICBtb3ZlTGVmdCgpIHtcbiAgICAgICAgdmFyIHtwb3NpdGlvbjogcG9zaXRpb259ID0gdGhpcztcbiAgICAgICAgaWYgKHBvc2l0aW9uID49IDApIHtcbiAgICAgICAgICAgIHRoaXMucG9zaXRpb24tLTtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG4gICAgbW92ZVJpZ2h0KCkge1xuICAgICAgICB2YXIge3Bvc2l0aW9uOiBwb3NpdGlvbiwgdGl0bGU6IHRpdGxlfSA9IHRoaXM7XG4gICAgICAgIGlmIChwb3NpdGlvbiA8IHRpdGxlLmxlbmd0aCkge1xuICAgICAgICAgICAgdGhpcy5wb3NpdGlvbisrO1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbiAgICBzZXQgYW5ub3VuY2UoYW5ub3VuY2UpIHtcbiAgICAgICAgc3VwZXIuYW5ub3VuY2UgPSBhbm5vdW5jZTtcbiAgICB9XG4gICAgZ2V0IGFubm91bmNlKCkge1xuICAgICAgICBpZiAodGhpcy5fYW5ub3VuY2UpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5wYXNzd29yZCkge1xuICAgICAgICAgICAgcmV0dXJuIFsgdGhpcy5leWVicm93LCB0aGlzLmhlbHBUZXh0IF07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gWyB0aGlzLmV5ZWJyb3csIFwiSW5wdXQ6IFw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ZVByZWZpeE9iaih0aGlzLmljb24sIHtcbiAgICAgICAgICAgICAgICBzdHlsZTogdGhpcy5zdHlsZS5pY29uU3R5bGVcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXhPYmooaWNvbikge1xuICAgICAgICB2YXIgcHJvcHMgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHt9O1xuICAgICAgICB0aGlzLl9wcmVmaXggPSBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgIHR5cGU6IEljb24sXG4gICAgICAgICAgICBpY29uOiBpY29uLFxuICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pY29uV2lkdGgsXG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmljb25IZWlnaHRcbiAgICAgICAgfSwgcHJvcHMpO1xuICAgIH1cbiAgICBfc2V0SWNvbihpY29uKSB7XG4gICAgICAgIGlmIChpY29uKSB7XG4gICAgICAgICAgICB0aGlzLl91cGRhdGVQcmVmaXhPYmooaWNvbiwge1xuICAgICAgICAgICAgICAgIHN0eWxlOiB0aGlzLnN0eWxlLmljb25TdHlsZVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9wcmVmaXggPSBpY29uO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBpY29uO1xuICAgIH1cbiAgICBzZXQgYW5ub3VuY2UoYW5ub3VuY2UpIHtcbiAgICAgICAgc3VwZXIuYW5ub3VuY2UgPSBhbm5vdW5jZTtcbiAgICB9XG4gICAgZ2V0IGFubm91bmNlKCkge1xuICAgICAgICBpZiAodGhpcy5fYW5ub3VuY2UpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hbm5vdW5jZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNVcHBlckNhc2UodGhp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RzKCkge1xuICAgICAgICB0aGlzLmNoaWxkTGlzdC5jbGVhcigpO1xuICAgICAgICBPYmplY3Qua2V5cyh0aGlzLmZvcm1hdHMpLmZvckVhY2goKGtleSA9PiB7XG4gICAgICAgICAgICB2YXIgZm9ybWF0ID0gdGhpcy5mb3JtYXRzW2tleV07XG4gICAgICAgICAgICBpZiAoZm9ybWF0KSB7XG4gICAgICAgICAgICAgICAgdmFyIGtleWJvYXJkRGF0YSA9IHRoaXMuX2Zvcm1hdEtleWJvYXJkRGF0YShmb3JtYXQpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZUtleWJvYXJkKGtleSwgdGhpcy5fY3JlYXRlUm93cyhrZXlib2FyZERhdGEsIGtleSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgICAgIHRoaXMuX2Zvcm1hdHNDaGFuZ2VkID0gZmFsc2U7XG4gICAgfVxuICAgIF9jcmVhdGVLZXlib2FyZChrZXkpIHtcbiAgICAgICAgdmFyIHJvd3MgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IFtdO1xuICAgICAgICBrZXkgPSBjYXBpdGFsaXplKGtleSk7XG4gICAgICAgIGlmIChyb3dzLmxlbmd0aCA9PT0gMSkge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgW2tleV06IHJvd3NbMF1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgW2tleV06IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQ29sdW1uLFxuICAgICAgICAgICAgICAgICAgICBwbGlua286IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zOiByb3dzLFxuICAgICAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZ1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBhdXRvUmVzaXplV2lkdGg6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIGF1dG9SZXNpemVIZWlnaHQ6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG5ldmVyU2Nyb2xsOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBhbHBoYToga2V5ID09PSBjYXBpdGFsaXplKHRoaXMuX2N1cnJlbnRGb3JtYXQpID8gMSA6IC4wMDFcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfY3JlYXRlUm93cygpIHtcbiAgICAgICAgdmFyIHJvd3MgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IFtdO1xuICAgICAgICB2YXIga2V5Ym9hcmQgPSBhcmd1bWVudHMubGVuZ3RoID4gMSA/IGFyZ3VtZW50c1sxXSA6IHVuZGVmaW5lZDtcbiAgICAgICAgcmV0dXJuIHJvd3MubWFwKChrZXlzID0+IHtcbiAgICAgICAgICAgIHZhciBfdGhpcyRfY3VycmVudEtleWJvYXI7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHR5cGU6IFJvdyxcbiAgICAgICAgICAgICAgICBhdXRvUmVzaXplSGVpZ2h0OiB0cnVlLFxuICAgICAgICAgICAgICAgIGF1dG9SZXNpemVXaWR0aDogdHJ1ZSxcbiAgICAgICAgICAgICAgICBjZW50ZXJJblBhcmVudDogdGhpcy5jZW50ZXJLZXlzLFxuICAgICAgICAgICAgICAgIG5ldmVyU2Nyb2xsOiB0cnVlLFxuICAgICAgICAgICAgICAgIHdyYXBTZWxlY3RlZDogdGhpcy5yb3dXcmFwICE9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bnQgfHwgS2V5LFxuICAgICAgICAgICAgICAgICAgICBrZXlTcGFjaW5nOiB0aGlzLnN0eWxlLmtleVNwYWNpbmcsXG4gICAgICAgICAgICAgICAgICAgIHNraXBGb2N1czogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IC4wMVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIga2V5ID0ge1xuICAgICAgICAgICAgICAgIHR5cGU6IHRoaXMua2V5Q29tcG9uZW50IHx8IEtleSxcbiAgICAgICAgICAgICAgICBrZXlTcGFjaW5nOiB0aGlzLnN0eWxlLmtleVNwYWNpbmdcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAodHlwZW9mIGtleVByb3BzID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgdmFyIF90aGlzJHN0eWxlJGtleVByb3BzLCBfdGhpcyRzdHlsZSRrZXlQcm9wczI7XG4gICAgICAgICAgICAgICAgdmFyIGtleU5hbWUgPSBrZXlQcm9wcy5rZXlJZCB8fCBrZXlQcm9wcy50aXRsZTtcbiAgICAgICAgICAgICAgICB2YXIga2V5T3ZlcnJpZGVzID0gKChfdGhpcyRzdHlsZSRrZXlQcm9wcyA9IHRoaXMuc3R5bGUua2V5UHJvcHMpID09PSBudWxsIHx8IF90aGlzJHN0eWxlJGtleVByb3BzID09PSB2b2lkIDAgfHwgKF90aGlzJHN0eWxlJGtleVByb3BzID0gX3RoaXMkc3R5bGUka2V5UHJvcHNba2V5Ym9hcmRdKSA9PT0gbnVsbCB8fCBfdGhpcyRzdHlsZSRrZXlQcm9wcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3R5bGUka2V5UHJvcHNba2V5TmFtZV0pIHx8ICgoX3RoaXMkc3R5bGUka2V5UHJvcHMyID0gdGhpcy5zdHlsZS5rZXlQcm9wcykgPT09IG51bGwgfHwgX3RoaXMkc3R5bGUka2V5UHJvcHMyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRzdHlsZSRrZXlQcm9wczJba2V5TmFtZV0pIHx8IHt9O1xuICAgICAgICAgICAgICAgIHZhciBrZXlQYXRjaCA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBrZXkpLCBrZXlQcm9wcyksIGtleU92ZXJyaWRlcyk7XG4gICAgICAgICAgICAgICAgaWYgKGtleU92ZXJyaWRlcyAhPT0gbnVsbCAmJiBrZXlPdmVycmlkZXMgIT09IHZvaWQgMCAmJiBrZXlPdmVycmlkZXMuaWNvbikge1xuICAgICAgICAgICAgICAgICAgICBrZXlQYXRjaC5zdHlsZSA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwga2V5T3ZlcnJpZGVzLnN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGljb25TdHlsZTogX29iamVjdFNwcmVhZCh7fSwga2V5T3ZlcnJpZGVzLmljb25TdHlsZSlcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBrZXlQYXRjaDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGtleSksIHt9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGtleVByb3BzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSkpO1xuICAgIH1cbiAgICBfZm9ybWF0S2V5Ym9hcmREYXRhKCkge1xuICAgICAgICB2YXIgZGF0YSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogW107XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KGRhdGEpICYmIGRhdGEubGVuZ3RoKSB7XG4gICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZGF0YVswXSkgJiYgIXRoaXMuaW5saW5lKSB7XG4gICAgICAgICAgICAgICAgdmFyIGtleVJvd3MgPSBbXTtcbiAgICAgICAgICAgICAgICB2YXIgaWR4LCBjb3VudGVyO1xuICAgICAgICAgICAgICAgIGZvciAoaWR4ID0gMCwgY291bnRlciA9IC0xOyBpZHggPCBkYXRhLmxlbmd0aDsgaWR4KyspIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlkeCAlIHRoaXMuY29sdW1uQ291bnQgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ZXIrKztcbiAgICAgICAgICAgICAgICAgICAgICAgIGtleVJvd3NbY291bnRlcl0gPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBrZXlSb3dzW2NvdW50ZXJdLnB1c2goZGF0YVtpZHhdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGtleVJvd3M7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaW5saW5lKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFsgZGF0YSBdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGRhdGE7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2Zvcm1hdEtleXMoKSB7XG4gICAgICAgIE9iamVjdC5rZXlzKHRoaXMuZm9ybWF0cykuZm9yRWFjaCgoZm9ybWF0ID0+IHtcbiAgICAgICAgICAgIHZhciBlbGVtZW50ID0gdGhpcy50YWcoY2FwaXRhbGl6ZShmb3JtYXQpKTtcbiAgICAgICAgICAgIGlmIChlbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiBmb3JtYXQgPT09IHRoaXMuX2N1cnJlbnRGb3JtYXQgPyAxIDogLjAwMSxcbiAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1TcGFjaW5nOiB0aGlzLnN0eWxlLmtleVNwYWNpbmdcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGVsZW1lbnQuaXRlbXMuZm9yRWFjaCgocm93ID0+IHtcbiAgICAgICAgICAgICAgICAgICAgcm93LnBhdGNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbVNwYWNpbmc6IHRoaXMuc3R5bGUua2V5U3BhY2luZ1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlckluUGFyZW50OiB0aGlzLmNlbnRlcktleXMsXG4gICAgICAgICAgICAgICAgICAgICAgICB3cmFwU2VsZWN0ZWQ6IHRoaXMucm93V3JhcCAhPT0gdW5kZWZpbmVkID8gdGhpcy5yb3dXcmFwIDogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5xdWV1ZVJlcXVlc3RVcGRhdGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSkpO1xuICAgIH1cbiAgICAkdG9nZ2xlS2V5Ym9hcmQobmV4dCkge1xuICAgICAgICB2YXIgbmV4dEtleWJvYXJkID0gY2FwaXRhbGl6ZShuZXh0KTtcbiAgICAgICAgaWYgKG5leHQgIT09IHRoaXMuX2N1cnJlbnRGb3JtYXQpIHtcbiAgICAgICAgICAgIHZhciBuZXh0S2V5Ym9hcmRUYWcgPSB0aGlzLnRhZyhuZXh0S2V5Ym9hcmQpO1xuICAgICAgICAgICAgdGhpcy5zZWxlY3RLZXlPbihuZXh0S2V5Ym9hcmRUYWcpO1xuICAgICAgICAgICAgdGhpcy5fY3VycmVudEtleWJvYXJ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JEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwiUVwiLCBcIldcIiwgXCJFXCIsIFwiUlwiLCBcIlRcIiwgXCJZXCIsIFwiVVwiLCBcIklcIiwgXCJPXCIsIFwiUFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiI0AhXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJzeW1ib2xzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3ltYm9sIG1vZGUsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInN5bWJvbHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiQVwiLCBcIlNcIiwgXCJEXCIsIFwiRlwiLCBcIkdcIiwgXCJIXCIsIFwiSlwiLCBcIktcIiwgXCJMXCIsIFwiQFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiw6HDtsO7XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWNjZW50cywgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiYWNjZW50c1wiXG4gICAgICAgICAgICB9IF0sIFsgXCJaXCIsIFwiWFwiLCBcIkNcIiwgXCJWXCIsIFwiQlwiLCBcIk5cIiwgXCJNXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJsb3dlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvZmYsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvbVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29tXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm5ldFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgbmV0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmVkdVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgZWR1XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm9yZ1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgb3JnXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi51a1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgdWtcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiAgICAgICAgICAgIGxvd2VyY2FzZTogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcInFcIiwgXCJ3XCIsIFwiZVwiLCBcInJcIiwgXCJ0XCIsIFwieVwiLCBcInVcIiwgXCJpXCIsIFwib1wiLCBcInBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIiNAIVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwic3ltYm9sc1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInN5bWJvbCBtb2RlLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzeW1ib2xzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcImFcIiwgXCJzXCIsIFwiZFwiLCBcImZcIiwgXCJnXCIsIFwiaFwiLCBcImpcIiwgXCJrXCIsIFwibFwiLCBcIkBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIsOhw7bDu1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFjY2VudHMsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImFjY2VudHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwielwiLCBcInhcIiwgXCJjXCIsIFwidlwiLCBcImJcIiwgXCJuXCIsIFwibVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBlcmlvZCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJzaGlmdFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwidXBwZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb24sIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvbVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29tXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm5ldFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgbmV0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmVkdVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgZWR1XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLm9yZ1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgb3JnXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLmNvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi51a1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgdWtcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiAgICAgICAgICAgIGFjY2VudHM6IFsgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCLDpFwiLCBcIsOrXCIsIFwiw69cIiwgXCLDtlwiLCBcIsO8XCIsIFwiw79cIiwgXCLDoFwiLCBcIsOoXCIsIFwiw6xcIiwgXCLDslwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiI0AhXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJzeW1ib2xzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3ltYm9sIG1vZGUsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInN5bWJvbHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiw7lcIiwgXCLDoVwiLCBcIsOpXCIsIFwiw61cIiwgXCLDs1wiLCBcIsO6XCIsIFwiw71cIiwgXCLDolwiLCBcIsOqXCIsIFwiQFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiYWJjXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJsb3dlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhbHBoYSBtb2RlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwiw65cIiwgXCLDtFwiLCBcIsO7XCIsIFwiw6NcIiwgXCLDsVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBlcmlvZCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJzaGlmdFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1VwcGVyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb2ZmLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzaGlmdFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb21cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvbVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5uZXRcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG5ldFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5lZHVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGVkdVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5vcmdcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG9yZ1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIudWtcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIHVrXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF0sXG4gICAgICAgICAgICBhY2NlbnRzVXBwZXI6IFsgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCLDhFwiLCBcIsOLXCIsIFwiw49cIiwgXCLDllwiLCBcIsOcXCIsIFwixbhcIiwgXCLDgFwiLCBcIsOIXCIsIFwiw4xcIiwgXCLDklwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiI0AhXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJzeW1ib2xzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3ltYm9sIG1vZGUsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInN5bWJvbHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiw5lcIiwgXCLDgVwiLCBcIsOJXCIsIFwiw41cIiwgXCLDk1wiLCBcIsOaXCIsIFwiw51cIiwgXCLDglwiLCBcIsOKXCIsIFwiQFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiYWJjXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJsb3dlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhbHBoYSBtb2RlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwiw45cIiwgXCLDlFwiLCBcIsObXCIsIFwiw4NcIiwgXCLDkVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBlcmlvZCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCItXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJzaGlmdFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNoaWZ0IG9mZiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29tXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBjb21cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIubmV0XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBuZXRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuZWR1XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBlZHVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIub3JnXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCBvcmdcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuY29cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLnVrXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG90LCB1a1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgc3ltYm9sczogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiIVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImV4Y2xhbWF0aW9uLCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCJAXCIsIFwiI1wiLCBcIiRcIiwgXCIlXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJeXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2FyZXQgY2lyY3VtZmxleCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIFwiJlwiLCBcIipcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIihcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIHBhcmVudGhlc2lzLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIilcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbG9zZSBwYXJlbnRoZXNpcywgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJhYmNcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFscGhhIG1vZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIntcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIGJyYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIn1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbG9zZSBicmFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJbXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwib3BlbiBicmFja2V0LCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbG9zZSBicmFja2V0LCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjtcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzZW1pY29sb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6ICdcIicsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG91YmxlcXVvdGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNvbW1hLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInxcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ2ZXJ0aWNhbCBiYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiXFxcXFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImJhY2tzbGFzaCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIvXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZm9yd2FyZHNsYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIsOhw7bDu1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwiYWNjZW50c1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFjY2VudHMsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImFjY2VudHNcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI8XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwibGVzcyB0aGFuLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIj5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJncmVhdGVyIHRoYW4sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiP1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInF1ZXN0aW9uIG1hcmssIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiPVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImVxdWFsIHNpZ24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiYFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImdyYXZlIGFjY2VudCwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJ+XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidGlsZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiX1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInVuZGVyc2NvcmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiOlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNvbG9uLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIitcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwbHVzIHNpZ24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb21cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGNvbVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5uZXRcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG5ldFwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5lZHVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIGVkdVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5vcmdcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIG9yZ1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5jb1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvdCwgY29cIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIudWtcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3QsIHVrXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF1cbiAgICAgICAgfTtcbiAgICB9XG59XG5cbmNsYXNzIEtleWJvYXJkRnVsbFNjcmVlbiBleHRlbmRzIEtleWJvYXJkIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiS2V5Ym9hcmRGdWxsU2NyZWVuXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJGY7XG4gICAgfVxuICAgIF9jb25zdHJ1Y3QoKSB7XG4gICAgICAgIHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICAgICAgdGhpcy5mb3JtYXRzID0gdGhpcy5mdWxsc2NyZWVuRm9ybWF0O1xuIC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IlBcIiwgXCJRXCIsIFwiUlwiLCBcIlNcIiwgXCJUXCIsIFwiVVwiLCBcIlZcIiwgXCJXXCIsIFwiWFwiLCBcIllcIiwgXCJaXCIgXSBdLFxuICAgICAgICAgICAgc3ltYm9sczogWyBbIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJBQkNcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxldHRlcnNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjYXBzIG9uLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIsIFwiXCIgXSwgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIiFcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXC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XRzID0gdGhpcy5xd2VydHlGb3JtYXQ7XG4gICAgfVxuICAgIGdldCBxd2VydHlGb3JtYXQoKSB7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB1cHBlcmNhc2U6IFsgWyBcIjFcIiwgXCIyXCIsIFwiM1wiLCBcIjRcIiwgXCI1XCIsIFwiNlwiLCBcIjdcIiwgXCI4XCIsIFwiOVwiLCBcIjBcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkZWxldGVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkZWxldGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCJRXCIsIFwiV1wiLCBcIkVcIiwgXCJSXCIsIFwiVFwiLCBcIllcIiwgXCJVXCIsIFwiSVwiLCBcIk9cIiwgXCJQXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9IF0sIFsgXCJBXCIsIFwiU1wiLCBcIkRcIiwgXCJGXCIsIFwiR1wiLCBcIkhcIiwgXCJKXCIsIFwiS1wiLCBcIkxcIiwgXCJAXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLDocO2w7tcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImFjY2VudHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJhY2NlbnRzLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJhY2NlbnRzXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIlpcIiwgXCJYXCIsIFwiQ1wiLCBcIlZcIiwgXCJCXCIsIFwiTlwiLCBcIk1cIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJwZXJpb2QsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwic2hpZnRcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNoaWZ0IG9mZiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgbG93ZXJjYXNlOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIFwicVwiLCBcIndcIiwgXCJlXCIsIFwiclwiLCBcInRcIiwgXCJ5XCIsIFwidVwiLCBcImlcIiwgXCJvXCIsIFwicFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiI0AhXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJzeW1ib2xzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3ltYm9sIG1vZGUsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInN5bWJvbHNcIlxuICAgICAgICAgICAgfSBdLCBbIFwiYVwiLCBcInNcIiwgXCJkXCIsIFwiZlwiLCBcImdcIiwgXCJoXCIsIFwialwiLCBcImtcIiwgXCJsXCIsIFwiQFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiw6HDtsO7XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWNjZW50cywgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiYWNjZW50c1wiXG4gICAgICAgICAgICB9IF0sIFsgXCJ6XCIsIFwieFwiLCBcImNcIiwgXCJ2XCIsIFwiYlwiLCBcIm5cIiwgXCJtXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJ1cHBlcmNhc2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvbiwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic2hpZnRcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJDbGVhclwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJjbGVhclwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsZWFyLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIlNwYWNlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNwYWNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic3BhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRG9uZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibGdcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJkb25lXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZG9uZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSBdLFxuICAgICAgICAgICAgYWNjZW50czogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsOkXCIsIFwiw6tcIiwgXCLDr1wiLCBcIsO2XCIsIFwiw7xcIiwgXCLDv1wiLCBcIsOgXCIsIFwiw6hcIiwgXCLDrFwiLCBcIsOyXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9IF0sIFsgXCLDuVwiLCBcIsOhXCIsIFwiw6lcIiwgXCLDrVwiLCBcIsOzXCIsIFwiw7pcIiwgXCLDvVwiLCBcIsOiXCIsIFwiw6pcIiwgXCJAXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJhYmNcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFscGhhIG1vZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCLDrlwiLCBcIsO0XCIsIFwiw7tcIiwgXCLDo1wiLCBcIsOxXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzVXBwZXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzaGlmdCBvZmYsIGJ1dHRvblwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcInNoaWZ0XCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXSxcbiAgICAgICAgICAgIGFjY2VudHNVcHBlcjogWyBbIFwiMVwiLCBcIjJcIiwgXCIzXCIsIFwiNFwiLCBcIjVcIiwgXCI2XCIsIFwiN1wiLCBcIjhcIiwgXCI5XCIsIFwiMFwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiRGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRlbGV0ZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRlbGV0ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyBcIsOEXCIsIFwiw4tcIiwgXCLDj1wiLCBcIsOWXCIsIFwiw5xcIiwgXCLFuFwiLCBcIsOAXCIsIFwiw4hcIiwgXCLDjFwiLCBcIsOSXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIjQCFcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcInN5bWJvbHNcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzeW1ib2wgbW9kZSwgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3ltYm9sc1wiXG4gICAgICAgICAgICB9IF0sIFsgXCLDmVwiLCBcIsOBXCIsIFwiw4lcIiwgXCLDjVwiLCBcIsOTXCIsIFwiw5pcIiwgXCLDnVwiLCBcIsOCXCIsIFwiw4pcIiwgXCJAXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJhYmNcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAgdG9nZ2xlOiBcImxvd2VyY2FzZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImFscGhhIG1vZGUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0sIFsgXCLDjlwiLCBcIsOUXCIsIFwiw5tcIiwgXCLDg1wiLCBcIsORXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIuXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicGVyaW9kLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi1cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ1bmRlcnNjb3JlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcInNoaWZ0XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJ4bFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwic2hpZnQgb2ZmLCBidXR0b25cIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzaGlmdFwiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkNsZWFyXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImNsZWFyXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY2xlYXIsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEb25lXCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJsZ1wiLFxuICAgICAgICAgICAgICAgIGtleUlkOiBcImRvbmVcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb25lLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF0sXG4gICAgICAgICAgICBzeW1ib2xzOiBbIFsgXCIxXCIsIFwiMlwiLCBcIjNcIiwgXCI0XCIsIFwiNVwiLCBcIjZcIiwgXCI3XCIsIFwiOFwiLCBcIjlcIiwgXCIwXCIsIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIhXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZXhjbGFtYXRpb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCBcIkBcIiwgXCIjXCIsIFwiJFwiLCBcIiVcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIl5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjYXJldCBjaXJjdW1mbGV4LCBidXR0b25cIlxuICAgICAgICAgICAgfSwgXCImXCIsIFwiKlwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiKFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIm9wZW4gcGFyZW50aGVzaXMsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiKVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIHBhcmVudGhlc2lzLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcImFiY1wiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwibWRcIixcbiAgICAgICAgICAgICAgICB0b2dnbGU6IFwibG93ZXJjYXNlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWxwaGEgbW9kZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwie1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcIm9wZW4gYnJhY2UsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwifVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIGJyYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIltcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJvcGVuIGJyYWNrZXQsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiXVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImNsb3NlIGJyYWNrZXQsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiO1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNlbWljb2xvbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogJ1wiJyxcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJkb3VibGVxdW90ZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIsXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY29tbWEsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwifFwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInZlcnRpY2FsIGJhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJcXFxcXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYmFja3NsYXNoLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIi9cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJmb3J3YXJkc2xhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiw6HDtsO7XCIsXG4gICAgICAgICAgICAgICAgc2l6ZTogXCJtZFwiLFxuICAgICAgICAgICAgICAgIHRvZ2dsZTogXCJhY2NlbnRzXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiYWNjZW50cywgYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiYWNjZW50c1wiXG4gICAgICAgICAgICB9IF0sIFsge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjxcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJsZXNzIHRoYW4sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiPlwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImdyZWF0ZXIgdGhhbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI/XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwicXVlc3Rpb24gbWFyaywgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI9XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZXF1YWwgc2lnbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJgXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZ3JhdmUgYWNjZW50LCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIn5cIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJ0aWxkZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJfXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwidW5kZXJzY29yZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI6XCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiY29sb24sIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiLVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRhc2gsIGJ1dHRvblwiXG4gICAgICAgICAgICB9LCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiK1wiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInBsdXMgc2lnbiwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiQ2xlYXJcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiY2xlYXJcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJjbGVhciwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJTcGFjZVwiLFxuICAgICAgICAgICAgICAgIHNpemU6IFwieGxcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJzcGFjZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcInNwYWNlLCBidXR0b25cIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIkRvbmVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcImxnXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZG9uZVwiLFxuICAgICAgICAgICAgICAgIGFubm91bmNlOiBcImRvbmUsIGJ1dHRvblwiXG4gICAgICAgICAgICB9IF0gXVxuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgS2V5Ym9hcmRJbnB1dCBleHRlbmRzIEJhc2UkMSB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIktleWJvYXJkSW5wdXRcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImNlbnRlcktleWJvYXJkXCIsIFwiZGVmYXVsdEZvcm1hdFwiLCBcImlucHV0XCIsIFwia2V5Ym9hcmRUeXBlXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkZjtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIFdyYXBwZXI6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBDb2x1bW4sXG4gICAgICAgICAgICAgICAgbmV2ZXJTY3JvbGw6IHRydWUsXG4gICAgICAgICAgICAgICAgdzogdGhpcy53LFxuICAgICAgICAgICAgICAgIGl0ZW1zOiBbIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSW5wdXQsXG4gICAgICAgICAgICAgICAgICAgIHJlZjogXCJJbnB1dFwiXG4gICAgICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBLZXlib2FyZCxcbiAgICAgICAgICAgICAgICAgICAgcmVmOiBcIktleWJvYXJkXCIsXG4gICAgICAgICAgICAgICAgICAgIHBhc3NTaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBrZXlib2FyZFdpZHRoQ2hhbmdlZDogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBdLFxuICAgICAgICAgICAgICAgIHNlbGVjdGVkSW5kZXg6IDEsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBrZXlib2FyZFdpZHRoQ2hhbmdlZDogXCJfdXBkYXRlV2lkdGhcIlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIldyYXBwZXJcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJJbnB1dFwiLFxuICAgICAgICAgICAgcGF0aDogXCJXcmFwcGVyLklucHV0XCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJLZXlib2FyZFwiLFxuICAgICAgICAgICAgcGF0aDogXCJXcmFwcGVyLktleWJvYXJkXCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICB0aGlzLl9XcmFwcGVyLnN0eWxlLml0ZW1TcGFjaW5nID0gdGhpcy5zdHlsZS5pbnB1dFNwYWNpbmc7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUtleWJvYXJkVHlwZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVJbnB1dCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVLZXlib2FyZCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVDZW50ZXJLZXlib2FyZCgpO1xuICAgIH1cbiAgICBfdXBkYXRlS2V5Ym9hcmRUeXBlKCkge1xuICAgICAgICBpZiAodGhpcy5fS2V5Ym9hcmQuY29uc3RydWN0b3IgIT09IHRoaXMua2V5Ym9hcmRUeXBlKSB7XG4gICAgICAgICAgICB0aGlzLl9XcmFwcGVyLl9yZXNldEl0ZW1zKCk7XG4gICAgICAgICAgICB0aGlzLl9XcmFwcGVyLml0ZW1zID0gWyB7XG4gICAgICAgICAgICAgICAgdHlwZTogSW5wdXQsXG4gICAgICAgICAgICAgICAgcmVmOiBcIklucHV0XCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLmtleWJvYXJkVHlwZSxcbiAgICAgICAgICAgICAgICByZWY6IFwiS2V5Ym9hcmRcIixcbiAgICAgICAgICAgICAgICBwYXNzU2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBrZXlib2FyZFdpZHRoQ2hhbmdlZDogdHJ1ZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gXTtcbiAgICAgICAgfVxuICAg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9hcmQge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJLZXlib2FyZFNlYXJjaFwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRmO1xuICAgIH1cbiAgICBfY29uc3RydWN0KCkge1xuICAgICAgICBzdXBlci5fY29uc3RydWN0KCk7XG4gICAgICAgIHRoaXMuZm9ybWF0cyA9IHRoaXMuc2VhcmNoRm9ybWF0O1xuICAgIH1cbiAgICBnZXQgc2VhcmNoRm9ybWF0KCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdXBwZXJjYXNlOiBbIFsgXCJBXCIsIFwiQlwiLCBcIkNcIiwgXCJEXCIsIFwiRVwiLCBcIkZcIiBdLCBbIFwiR1wiLCBcIkhcIiwgXCJJXCIsIFwiSlwiLCBcIktcIiwgXCJMXCIgXSwgWyBcIk1cIiwgXCJOXCIsIFwiT1wiLCBcIlBcIiwgXCJRXCIsIFwiUlwiIF0sIFsgXCJTXCIsIFwiVFwiLCBcIlVcIiwgXCJWXCIsIFwiV1wiLCBcIlhcIiBdLCBbIFwiWVwiLCBcIlpcIiwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjFcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjJcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjNcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSwge1xuICAgICAgICAgICAgICAgIHRpdGxlOiBcIjRcIixcbiAgICAgICAgICAgICAgICBrZXlJZDogXCJudW1iZXJcIlxuICAgICAgICAgICAgfSBdLCBbIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI1XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI2XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI3XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI4XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCI5XCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCIwXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwibnVtYmVyXCJcbiAgICAgICAgICAgIH0gXSwgWyB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IFwiU3BhY2VcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcInhsXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwic3BhY2VcIixcbiAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJzcGFjZSwgYnV0dG9uXCJcbiAgICAgICAgICAgIH0sIHtcbiAgICAgICAgICAgICAgICB0aXRsZTogXCJEZWxldGVcIixcbiAgICAgICAgICAgICAgICBzaXplOiBcIm1kXCIsXG4gICAgICAgICAgICAgICAga2V5SWQ6IFwiZGVsZXRlXCIsXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiZGVsZXRlLCBidXR0b25cIlxuICAgICAgICAgICAgfSBdIF1cbiAgICAgICAgfTtcbiAgICB9XG59XG5cbnZhciBiYXNlJGUgPSB0aGVtZSA9PiB7XG4gICAgdmFyIHNpemUgPSB0aGVtZS5zcGFjZXIubGc7XG4gICAgcmV0dXJuIHtcbiAgICAgICAgd2lkdGg6IHNpemUsXG4gICAgICAgIGhlaWdodDogc2l6ZSxcbiAgICAgICAgcmFkaXVzOiBzaXplIC8gMlxuICAgIH07XG59O1xuXG52YXIgdG9uZSQ5ID0gdGhlbWUgPT4gKHtcbiAgICBuZXV0cmFsOiB7XG4gICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZU5ldXRyYWxGb2N1cyxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBjaXJjbGVDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWxEaXNhYmxlZFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZUludmVyc2VGb2N1cyxcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZGlzYWJsZWQ6IHtcbiAgICAgICAgICAgICAgICBjaXJjbGVDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2VEaXNhYmxlZFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBjaXJjbGVDb2xvcjogdGhlbWUuY29sb3IuaW50ZXJhY3RpdmVCcmFuZEZvY3VzLFxuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBkaXNhYmxlZDoge1xuICAgICAgICAgICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5maWxsSW52ZXJzZURpc2FibGVkXG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHN0eWxlcyRlID0gT2JqZWN0LmZyZWV6ZSh7X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NvbG9yLnRleHRJbnZlcnNlU2Vjb25kYXJ5XG4gICAgICAgIH0sXG4gICAgICAgIHRpdGxlVGV4dFN0eWxlOiB7XG4gICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlXG4gICAgICAgIH1cbiAgICB9XG59KTtcblxudmFyIHRvbmUkOCA9IHRoZW1lID0+ICh7XG4gICAgaW52ZXJzZToge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgZGVzY3JpcHRpb25UZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgdGl0bGVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJGQgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSRkLFxuICAgIG1vZGU6IG1vZGUkNSxcbiAgICB0b25lOiB0b25lJDhcbn0pO1xuXG5jbGFzcyBMaXN0SXRlbSBleHRlbmRzIEJ1dHRvbiB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIkxpc3RJdGVtXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJGQ7XG4gICAgfVxuICAgIHN0YXRpYyBfdGVtcGxhdGUoKSB7XG4gICAgICAgIHJldHVybiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHN1cGVyLl90ZW1wbGF0ZSgpKSwge30sIHtcbiAgICAgICAgICAgIGp1c3RpZnk6IFwibGVmdFwiLFxuICAgICAgICAgICAgZml4ZWQ6IHRydWUsXG4gICAgICAgICAgICBDb250ZW50OiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHN1cGVyLl90ZW1wbGF0ZSgpLkNvbnRlbnQpLCB7fSwge1xuICAgICAgICAgICAgICAgIFRleHRXcmFwcGVyOiB7XG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIGZsZXg6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRpcmVjdGlvbjogXCJjb2x1bW5cIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBUaXRsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfb25UZXh0Qm94Q2hhbmdlZFwiXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci5wcm9wZXJ0aWVzLCBcImRlc2NyaXB0aW9uXCIsIFwicHJlZml4TG9nb1wiLCBcInN1ZmZpeExvZ29cIiwgXCJzaG91bGRDb2xsYXBzZVwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgYWxpYXNTdHlsZXMoKSB7XG4gICAgICAgIHJldHVybiBbIHtcbiAgICAgICAgICAgIHByZXY6IFwidGl0bGVQYWRkaW5nXCIsXG4gICAgICAgICAgICBjdXJy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kZXNjcmlwdGlvblBhdGNoID0ge1xuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMuZGVzY3JpcHRpb24sXG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUuZGVzY3JpcHRpb25UZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9maXhlZFdvcmRXcmFwV2lkdGhcbiAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHZpc2libGU6ICF0aGlzLl9jb2xsYXBzZVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmICghdGhpcy5fRGVzY3JpcHRpb24pIHtcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvblBhdGNoID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9vblRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIGRlc2NyaXB0aW9uUGF0Y2gpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5fVGV4dFdyYXBwZXIucGF0Y2goe1xuICAgICAgICAgICAgICAgIERlc2NyaXB0aW9uOiBkZXNjcmlwdGlvblBhdGNoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBEZXNjcmlwdGlvbjogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlVHJ1bmNhdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuX1RpdGxlKSB7XG4gICAgICAgICAgICB0aGlzLl9UaXRsZS5wYXRjaCh7XG4gICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGl0bGVUZXh0U3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXA6IHRoaXMuZml4ZWQsXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLmZpeGVkID8gdGhpcy5fZml4ZWRXb3JkV3JhcFdpZHRoIDogMFxuICAgICAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVQcmVmaXhMb2dvKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzUHJlZml4TG9nbykge1xuICAgICAgICAgICAgdGhpcy5fcHJlZml4ID0gdGhpcy5fYWRkTG9nb1Byb3BzKHRoaXMuX3ByZWZpeExvZ28pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVTdWZmaXhMb2dvKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzU3VmZml4TG9nbykge1xuICAgICAgICAgICAgdGhpcy5fc3VmZml4ID0gdGhpcy5fYWRkTG9nb1Byb3BzKHRoaXMuX3N1ZmZpeExvZ28pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF9hZGRMb2dvUHJvcHMoaWNvbikge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgIGljb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m9jdXNlZE1vZGU7XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5vdW5jZSA9IGFubm91bmNlO1xuICAgIH1cbiAgICBnZXQgYW5ub3VuY2UoKSB7XG4gICAgICAgIGlmICh0aGlzLl9hbm5vdW5jZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Fubm91bmNlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLnRpdGxlICsgdGhpcy5kZXNjcmlwdGlvbiArIFwiLCBMaXN0IEl0ZW1cIjtcbiAgICB9XG59XG5cbnZhciBiYXNlJGMgPSAoKSA9PiAoe1xuICAgIHNob3dBcnJvd3M6IGZhbHNlLFxuICAgIHNob3dLbm9iOiBmYWxzZVxufSk7XG5cbnZhciBtb2RlJDQgPSAoKSA9PiAoe1xuICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgc2hvd0Fycm93czogdHJ1ZVxuICAgIH1cbn0pO1xuXG52YXIgdG9uZSQ3ID0gdGhlbWUgPT4gKHtcbiAgICBuZXV0cmFsOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICBhcnJvd0NvbG9yOiB0aGVtZS5jb2xvci5maWxsSW52ZXJzZSxcbiAgICAgICAgICAgICAgICBwcm9ncmVzc0Jhcjoge1xuICAgICAgICAgICAgICAgICAgICBiYXJDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2VUZXJ0aWFyeSxcbiAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NDb2xvcjogdGhlbWUuY29sb3IuZmlsbEludmVyc2VcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGludmVyc2U6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGFycm93Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsLFxuICAgICAgICAgICAgICAgIHByb2dyZXNzQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgIGJhckNvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFRlcnRpYXJ5LFxuICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc0NvbG9yOiB0aGVtZS5jb2xvci5maWxsTmV1dHJhbFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgbW9kZToge1xuICAgICAgICAgICAgZm9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGFycm93Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxJbnZlcnNlLFxuICAgICAgICAgICAgICAgIHByb2dyZXNzQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgIGJhckNvbG9yOiB0aGVtZS5jb2xvci5maWxsQnJhbmRUZXJ0aWFyeSxcbiAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NDb2xvcjogdGhlbWUuY29sb3IuZmlsbEJyYW5kXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkYyA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJGMsXG4gICAgbW9kZTogbW9kZSQ0LFxuICAgIHRvbmU6IHRvbmUkN1xufSk7XG5cbnZhciBiYXNlJGIgPSB0aGVtZSA9PiB7XG4gICAgdmFyIHNpemUgPSB0aGVtZS5zcGFjZXIubGc7XG4gICAgcmV0dXJuIHtcbiAgICAgICAgYXJyb3dBbHBoYVZhbHVlOiB0aGVtZS5hbHBoYS5wcmltYXJ5LFxuICAgICAgICBhcnJvd0FscGhhVmFsdWVMaW1pdDogdGhlbWUuYWxwaGEuc2Vjb25kYXJ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cjogdGhlbWUuY29sb3IuZmlsbEludmVyc2UsXG4gICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZUludmVyc2VGb2N1c1xuICAgIH0sXG4gICAgYnJhbmQ6IHtcbiAgICAgICAgYXJyb3dDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWwsXG4gICAgICAgIGNpcmNsZUNvbG9yOiB0aGVtZS5jb2xvci5pbnRlcmFjdGl2ZU5ldXRyYWxGb2N1c1xuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJGIgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSRiLFxuICAgIG1vZGU6IG1vZGUkMyxcbiAgICB0b25lOiB0b25lJDZcbn0pO1xuXG5jbGFzcyBTbGlkZXIgZXh0ZW5kcyBCYXNlJDEge1xuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJTbGlkZXJcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkYjtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIENvbnRhaW5lcjoge1xuICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMixcbiAgICAgICAgICAgICAgICBCYXI6IHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgU2xpZGVyQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBQcm9ncmVzc0JhcixcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgICAgICBhbm5vdW5jZTogXCJcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBDaXJjbGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IEtub2IsXG4gICAgICAgICAgICAgICAgICAgICAgICB6SW5kZXg6IDVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgTGVmdEFycm93OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEljb24sXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIHk6IGggPT4gaCAvIDJcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFJpZ2h0QXJyb3c6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcIm1heFwiLCBcIm1pblwiLCBcInN0ZXBcIiwgXCJ2YWx1ZVwiLCBcInZlcnRpY2FsXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkNvbnRhaW5lclwiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIkJhclwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250YWluZXIuQmFyXCJcbiAgICAgICAgfSwge1xuICAgICAgICAgICAgbmFtZTogXCJTbGlkZXJCYXJcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGFpbmVyLkJhci5TbGlkZXJCYXJcIlxuICAgICAgICB9LCB7XG4gICAgIC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Z2VkID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fY2hlY2tBbmRTaWduYWxTaXplQ2hhbmdlKCk7XG4gICAgfVxuICAgIF9oYW5kbGVMZWZ0KCkge1xuICAgICAgICBpZiAodGhpcy5faXNEaXNhYmxlZE1vZGUpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9kZWNyZW1lbnRWYWx1ZSgpO1xuICAgICAgICBpZiAodHlwZW9mIHRoaXMub25MZWZ0ID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLm9uTGVmdCh0aGlzKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG4gICAgX2hhbmRsZVJpZ2h0KCkge1xuICAgICAgICBpZiAodGhpcy5faXNEaXNhYmxlZE1vZGUpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9pbmNyZW1lbnRWYWx1ZSgpO1xuICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SaWdodCA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5vblJpZ2h0KHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICBfdXBkYXRlRGlyZWN0aW9uKCkge1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIHBpdm90WDogMCxcbiAgICAgICAgICAgIHJvdGF0aW9uOiB0aGlzLnZlcnRpY2FsID8gZGVncmVlc1RvUmFkaWFucyg5MCkgOiAwLFxuICAgICAgICAgICAgbW91bnRZOiB0aGlzLnZlcnRpY2FsID8gLjUgOiAwXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlU2xpZGVyTGF5b3V0KCkge1xuICAgICAgICB2YXIgdyA9IHRoaXMudyB8fCB0aGlzLnN0eWxlLm1pbldpZHRoO1xuICAgICAgICB0aGlzLl9Db250YWluZXIucGF0Y2goe1xuICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5jb250YWluZXJIZWlnaHQsXG4gICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgQmFyOiB7XG4gICAgICAgICAgICAgICAgeDogdGhpcy5fY2FsY3VsYXRlZFNsaWRlclgsXG4gICAgICAgICAgICAgICAgU2xpZGVyQmFyOiB7XG4gICAgICAgICAgICAgICAgICAgIHk6IHRoaXMuc3R5bGUuY29udGFpbmVySGVpZ2h0IC8gMixcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fY2FsY3VsYXRlZFNsaWRlcldpZHRoLFxuICAgICAgICAgICAgICAgICAgICBzdHlsZTogX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBkdXJhdGlvbjogMFxuICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLnN0eWxlLnByb2dyZXNzQmFyKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuaCA9IE1hdGgubWF4KHRoaXMuc3R5bGUuY29udGFpbmVySGVpZ2h0LCB0aGlzLnN0eWxlLmFycm93SGVpZ2h0KTtcbiAgICB9XG4gICAgX2NoZWNrQW5kU2lnbmFsU2l6ZUNoYW5nZSgpIHtcbiAgICAgICAgaWYgKHRoaXMuaCAhPT0gdGhpcy5wcmV2SCB8fCB0aGlzLl9Db250YWluZXIudyAhPT0gdGhpcy5wcmV2VyB8fCB0aGlzLnJvdGF0aW9uICE9PSB0aGlzLnByZXZSb3RhdGlvbikge1xuICAgICAgICAgICAgdGhpcy5zaWduYWwoXCJvblNpemVDaGFuZ2VcIiwgdGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5wcmV2SCA9IHRoaXMuaDtcbiAgICAgICAgdGhpcy5wcmV2VyA9IHRoaXM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V2lkdGg7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy52YWx1ZSA+IHRoaXMubWF4IHx8IHRoaXMudmFsdWUgLSB0aGlzLnN0ZXAgPiB0aGlzLm1heCkge1xuICAgICAgICAgICAgeENpcmNsZVBvc2l0aW9uID0gdGhpcy5fY2FsY3VsYXRlZFNsaWRlcldpZHRoO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHRoaXMubWluIDwgMCB8fCB0aGlzLm1heCA8IDApIHtcbiAgICAgICAgICAgICAgICB4Q2lyY2xlUG9zaXRpb24gPSAodGhpcy52YWx1ZSAtIHRoaXMubWluKSAvICh0aGlzLm1heCAtIHRoaXMubWluKSAqIHRoaXMuX2NhbGN1bGF0ZWRTbGlkZXJXaWR0aDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgeENpcmNsZVBvc2l0aW9uID0gdGhpcy52YWx1ZSAvIHRoaXMubWF4ICogdGhpcy5fY2FsY3VsYXRlZFNsaWRlcldpZHRoO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9DaXJjbGUpIHtcbiAgICAgICAgICAgIHRoaXMuX0NpcmNsZS5wYXRjaCh7XG4gICAgICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHJhZGl1czogdGhpcy5zdHlsZS5yYWRpdXMsXG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUudyxcbiAgICAgICAgICAgICAgICAgICAgaDogdGhpcy5zdHlsZS5oLFxuICAgICAgICAgICAgICAgICAgICBjaXJjbGVDb2xvcjogdGhpcy5zdHlsZS5jaXJjbGVDb2xvclxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgeTogdGhpcy5fU2xpZGVyQmFyLnkgKyAxLFxuICAgICAgICAgICAgICAgIGFscGhhOiB0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AgICByaWdodEFscGhhID0gYWxwaGE7XG4gICAgICAgIH0gZWxzZSBpZiAoIXRoaXMuX2lzRGlzYWJsZWRNb2RlICYmIHRoaXMudmFsdWUgPj0gdGhpcy5tYXgpIHtcbiAgICAgICAgICAgIGxlZnRBbHBoYSA9IGFscGhhO1xuICAgICAgICAgICAgcmlnaHRBbHBoYSA9IGFscGhhTGltaXQ7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fTGVmdEFycm93LnNtb290aCA9IHtcbiAgICAgICAgICAgIGFscGhhOiBsZWZ0QWxwaGFcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5fUmlnaHRBcnJvdy5zbW9vdGggPSB7XG4gICAgICAgICAgICBhbHBoYTogcmlnaHRBbHBoYVxuICAgICAgICB9O1xuICAgIH1cbiAgICBfdXBkYXRlQXJyb3dzKCkge1xuICAgICAgICB2YXIgYXJyb3dQcm9wcyA9IHtcbiAgICAgICAgICAgIHc6IHRoaXMuc3R5bGUuYXJyb3dXaWR0aCxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuYXJyb3dIZWlnaHQsXG4gICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgIGNvbG9yOiB0aGlzLnN0eWxlLmFycm93Q29sb3JcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5fTGVmdEFycm93LnBhdGNoKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgYXJyb3dQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICBpY29uOiB0aGlzLnN0eWxlLmljb25MZWZ0U3JjXG4gICAgICAgIH0pKTtcbiAgICAgICAgdGhpcy5fUmlnaHRBcnJvdy5wYXRjaChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGFycm93UHJvcHMpLCB7fSwge1xuICAgICAgICAgICAgaWNvbjogdGhpcy5zdHlsZS5pY29uUmlnaHRTcmNcbiAgICAgICAgfSkpO1xuICA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XG4gICAgfVxuICAgIHNldCBhbm5vdW5jZShhbm5vdW5jZSkge1xuICAgICAgICBzdXBlci5hbm5vdW5jZSA9IGFubm91bmNlO1xuICAgIH1cbiAgICBnZXQgYW5ub3VuY2UoKSB7XG4gICAgICAgIGlmICh0aGlzLl9hbm5vdW5jZSAhPT0gdW5kZWZpbmVkICYmIHRoaXMuX2Fubm91bmNlICE9PSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fYW5ub3VuY2U7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMudmFsdWUudG9TdHJpbmcoKTtcbiAgICB9XG4gICAgc3RhdGljIF9zdGF0ZXMoKSB7XG4gICAgICAgIHJldHVybiBbIGNsYXNzIFZlcnRpY2FsU2xpZGVyIGV4dGVuZHModGhpcyl7XG4gICAgICAgICAgICBfaGFuZGxlTGVmdCgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBfaGFuZGxlUmlnaHQoKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX2hhbmRsZVVwKCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX2RlY3JlbWVudFZhbHVlKCk7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uVXAgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5vblVwKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIF9oYW5kbGVEb3duKCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLl9pc0Rpc2FibGVkTW9kZSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMuX2luY3JlbWVudFZhbHVlKCk7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uRG93biA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm9uRG93bih0aGlzKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gXTtcbiAgICB9XG59XG5cbmNsYXNzIE5lc3RlZFNsaWRlciBleHRlbmRzIFNsaWRlciB7XG4gICAgc3RhdGljIGdldCBfX2NvbXBvbmVudE5hbWUoKSB7XG4gICAgICAgIHJldHVybiBcIk5lc3RlZFNsaWRlclwiO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyRjO1xuICAgIH1cbn1cblxudmFyIGJhc2UkYSA9IHRoZW1lID0+ICh7XG4gICAgcGFkZGluZ1k6IHRoZW1lLnNwYWNlci5tZCArIHRoZW1lLnNwYWNlci54cyxcbiAgICB2YWx1ZVRleHRTdHlsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGVtZS50eXBvZ3JhcGh5LmhlYWRsaW5lMyksIHt9LCB7XG4gICAgICAgIG1heExpbmVzOiAxLFxuICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgfSlcbn0pO1xuXG52YXIgbW9kZSQyID0gdGhlbWUgPT4gKHtcbiAgICBkaXNhYmxlZDoge1xuICAgICAgICB2YWx1ZVRleHRTdHlsZToge1xuICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0TmV1dHJhbERpc2FibGVkXG4gICAgICAgIH1cbiAgICB9LFxuICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgdmFsdWVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dEludmVyc2VTZWNvbmRhcnlcbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgdG9uZSQ1ID0gdGhlbWUgPT4gKHtcbiAgICBuZXV0cmFsOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICB2YWx1ZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHRJbnZlcnNlU2Vjb25kYXJ5XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBpbnZlcnNlOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICB2YWx1ZVRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsU2Vjb25kYXJ5XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBicmFuZDoge1xuICAgICAgICBtb2RlOiB7XG4gICAgICAgICAgICBmb2N1c2VkOiB7XG4gICAgICAgICAgICAgICAgdmFsdWVUZXh0U3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiB0aGVtZS5jb2xvci50ZXh0SW52ZXJzZVNlY29uZGFyeVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn0pO1xuXG52YXIgc3R5bGVzJGEgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSRhLFxuICAgIG1vZGU6IG1vZGUkMixcbiAgICB0b25lOiB0b25lJDVcbn0pO1xuXG5jbGFzcyBMaXN0SXRlbVNsaWRlciBleHRlbmRzIExpc3RJdGVtIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiTGlzdEl0ZW1TbGlkZXJcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBfX3RoZW1lU3R5bGUoKSB7XG4gICAgICAgIHJldHVybiBzdHlsZXMkYTtcbiAgICB9XG4gICAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICAgICAgdmFyIHRlbXBsYXRlID0gc3VwZXIuX3RlbXBsYXRlO1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0ZW1wbGF0ZSgpKSwge30sIHtcbiAgICAgICAgICAgIENvbnRlbnQ6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGVtcGxhdGUoKS5Db250ZW50KSwge30sIHtcbiAgICAgICAgICAgICAgICBmbGV4OiB7XG4gICAgICAgICAgICAgICAgICAgIGRpcmVjdGlvbjogXCJjb2x1bW5cIlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgVGV4dFdyYXBwZXI6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgdGVtcGxhdGUoKS5Db250ZW50LlRleHRXcmFwcGVyKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAwLFxuICAgICAgICAgICAgICAgICAgICBmbGV4OiB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICB9KSxcbiAgICAgICAgICAgICAgICBTbGlkZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogTmVzdGVkU2xpZGVyLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFg6IC41LFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBvbkNoYW5nZTogXCJfb25TbGlkZXJDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHByb3BlcnRpZXMoKSB7XG4gICAgICAgIHJldHVybiBbIC4uLnN1cGVyLnByb3BlcnRpZXMsIFwic2xpZGVyXCIsIFwidmFsdWVcIiwgXCJtYXhcIiwgXCJtaW5cIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcInRpdGxlUGFkZGluZ1wiLFxuICAgICAgICAgICAgY3VycjogXCJjb250ZW50U3BhY2luZ1wiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyAuLi5zdXBlci50YWdzLCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNsaWRlclwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50LlNsaWRlclwiXG4gICAgICAgIH0sIHtcbiAgICAgICAgICAgIG5hbWU6IFwiVmFsdWVcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5UZXh0V3JhcHBlci5WYWx1ZVwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgc3VwZXIuX2NvbnN0cnVjdCgpO1xuICAgICAgICB0aGlzLnZhbHVlID0gNTA7XG4gICAgICAgIHRoaXMubWF4ID0gMTAwO1xuICAgICAgICB0aGlzLm1pbiA9IDA7XG4gICAgfVxuICAgIF91cGRhdGUoKSB7XG4gICAgICAgIHN1cGVyLl91cGRhdGUoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlU2xpZGVyUG9zaXRpb24oKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVmFsdWUoKTtcbiAgICB9XG4gICAgX29uVGV4dEJveENoYW5nZWQoKSB7XG4gICAgICAgIHN1cGVyLl9vblRleHRCb3hDaGFuZ2VkKCk7XG4gICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLmggPSBNYXRoLm1heCh0aGlzLl9UaXRsZSA/IHRoaXMuX1RpdGxlLmggOiAwLCB0aGlzLl9WYWx1ZSA/IHRoaXMuX1ZhbHVlLmggOiAwKTtcbiAgICB9XG4gICAgX3VwZGF0ZVZhbHVlKCkge1xuICAgICAgICBpZiAodGhpcy5faGFzVmFsdWUpIHtcbiAgICAgICAgICAgIHZhciB2YWx1ZVBhdGNoID0ge1xuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRoaXMudmFsdWUudG9TdHJpbmcoKSxcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudmFsdWVUZXh0U3R5bGUpXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBtb3VudFg6IDEsXG4gICAgICAgICAgICAgICAgeDogdGhpcy53IC0gdGhpcy5fcGFkZGluZ1hcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoIXRoaXMuX1ZhbHVlKSB7XG4gICAgICAgICAgICAgICAgdmFsdWVQYXRjaCA9IF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Qm94Q2hhbmdlZDogXCJfb25UZXh0Qm94Q2hhbmdlZFwiXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LCB2YWx1ZVBhdGNoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBWYWx1ZTogdmFsdWVQYXRjaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9UZXh0V3JhcHBlci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgVmFsdWU6IHVuZGVmaW5lZFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVNsaWRlclBvc2l0aW9uKCkge1xuICAgICAgICB2YXIgdyA9IHRoaXMudyAtIHRoaXMuX3BhZGRpbmdMZWZ0IC0gdGhpcy5fcGFkZGluZ1JpZ2h0O1xuICAgICAgICB2YXIgc2xpZGVyUHJvcHMgPSBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe1xuICAgICAgICAgICAgbW9kZTogdGhpcy5tb2RlLFxuICAgICAgICAgICAgdG9uZTogdGhpcy50b25lLFxuICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgIHg6IHcgLyAyLFxuICAgICAgICAgICAgdmlzaWJsZTogIXRoaXMuX2NvbGxhcHNlLFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuc3R5bGUuYWxwaGFcbiAgICAgICAgfSwgdGhpcy5zbGlkZXIpLCB7fSwge1xuICAgICAgICAgICAgdmFsdWU6IHRoaXMudmFsdWUsXG4gICAgICAgICAgICBtYXg6IHRoaXMubWF4LFxuICAgICAgICAgICAgbWluOiB0aGlzLm1pblxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5fU2xpZGVyLnBhdGNoKHNsaWRlclByb3BzKTtcbiAgICB9XG4gICAgZ2V0IF9oYXNWYWx1ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudmFsdWUgIT0gdW5kZWZpbmVkIHx8IHRoa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DAxO1xuICAgICAgICAgICAgaWYgKHRoaXMuX0xlZnRBcnJvdykge1xuICAgICAgICAgICAgICAgIHRoaXMuX0xlZnRBcnJvdy5hbHBoYSA9IG9mZkFscGhhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX1JpZ2h0QXJyb3cpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9SaWdodEFycm93LmFscGhhID0gb2ZmQWxwaGE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGFycm93UHJvcHMgPSB7XG4gICAgICAgICAgICB3OiB0aGlzLnN0eWxlLmFycm93V2lkdGgsXG4gICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmFycm93SGVpZ2h0LFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5hcnJvd0NvbG9yXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYWxwaGE6IHRoaXMuc3R5bGUuYXJyb3dBbHBoYVZhbHVlXG4gICAgICAgIH07XG4gICAgICAgIGlmICghdGhpcy5fTGVmdEFycm93KSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBMZWZ0QXJyb3c6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNSxcbiAgICAgICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMlxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuX0xlZnRBcnJvdy5wYXRjaChfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGFycm93UHJvcHMpLCB7fSwge1xuICAgICAgICAgICAgaWNvbjogdGhpcy5zdHlsZS5pY29uTGVmdFNyY1xuICAgICAgICB9KSk7XG4gICAgICAgIHRoaXMuX0xlZnRBcnJvdy5zbW9vdGggPSB7XG4gICAgICAgICAgICB4OiB0aGlzLnN0eWxlLnBhZGRpbmdYXG4gICAgICAgIH07XG4gICAgICAgIGlmICghdGhpcy5fUmlnaHRBcnJvdykge1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgUmlnaHRBcnJvdzoge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBJY29uLFxuICAgICAgICAgICAgICAgICAgICBtb3VudFk6IC41LFxuICAgICAgICAgICAgICAgICAgICBtb3VudFg6IDEsXG4gICAgICAgICAgICAgICAgICAgIHk6IGggPT4gaCAvIDJcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9SaWdodEFycm93LnBhdGNoKF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgYXJyb3dQcm9wcyksIHt9LCB7XG4gICAgICAgICAgICBpY29uOiB0aGlzLnN0eWxlLmljb25SaWdodFNyY1xuICAgICAgICB9KSk7XG4gICAgICAgIHRoaXMuX1JpZ2h0QXJyb3cuc21vb3RoID0ge1xuICAgICAgICAgICAgeDogdGhpcy53IC0gdGhpcy5zdHlsZS5wYWRkaW5nWFxuICAgICAgICB9O1xuICAgIH1cbiAgICBfdXBkYXRlUGlja2VyKCkge1xuICAgICAgICB2YXIgdyA9IHRoaXMudyAtIHRoaXMuX3BhZGRpbmdYIC0gdGhpcy5zdHlsZS5hcnJvd1dpZHRoICogMjtcbiAgICAgICAgaWYgKCF0aGlzLl9QaWNrZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX1RleHRXcmFwcGVyLnBhdGNoKHtcbiAgICAgICAgICAgICAgICBQaWNrZXI6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogUm93LFxuICAgICAgICAgICAgICAgICAgICBjbGlwcGluZzogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgYWx3YXlzU2Nyb2xsOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBzaWduYWxzOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RlZENoYW5nZTogXCJfdXBkYXRlQXJyb3dzQWxwaGFcIlxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fUGlja2VyLnBhdGNoKHtcbiAgICAgICAgICAgIHZpc2libGU6ICF0aGlzLl9jb2xsYXBzZSxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuZGVzY3JpcHRpb25UZXh0U3R5bGUubGluZUhlaWdodCxcbiAgICAgICAgICAgIHc6IHcsXG4gICAgICAgICAgICBpdGVtczogdGhpcy5vcHRpb25zLm1hcCgob3B0aW9uID0+ICh7XG4gICAgICAgICAgICAgICAgdHlwZTogTWFycXVlZSxcbiAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uVGV4dFN0eWxlLmxpbmVIZWlnaHQsXG4gICAgICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgICAgICBjZW50ZXJBbGlnbjogdGhpcy5faXNGb2N1c2VkTW9kZSxcbiAgICAgICAgICAgICAgICB0aXRsZTogX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLmRlc2NyaXB0aW9uVGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgdGV4dDogb3B0aW9uXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pKSksXG4gICAgICAgICAgICBzZWxlY3RlZEluZGV4OiB0aGlzLnNlbGVjdGVkSW5kZXhcbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMuX2FsaWduUGlja2VyKCk7XG4gICAgfVxuICAgIF9hbGlnblBpY2tlcigpIHtcbiAgICAgICAgdGhpcy5fUGlja2VyLnBhdGNoKHtcb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G4gICAgdmFyIHtzY3JvbGw6IHNjcm9sbH0gPSBiYXNlJDgodGhlbWUpO1xuICAgIHJldHVybiB7XG4gICAgICAgIHByb2dyZXNzQmFyOiB7XG4gICAgICAgICAgICBhbmltYXRpb246IHNjcm9sbFxuICAgICAgICB9LFxuICAgICAgICBjaXJjbGVBbmltYXRpb246IHNjcm9sbFxuICAgIH07XG59O1xuXG52YXIgc3R5bGVzJDcgPSBPYmplY3QuZnJlZXplKHtcbiAgICBfX3Byb3RvX186IG51bGwsXG4gICAgYmFzZTogYmFzZSQ3XG59KTtcblxuY2xhc3MgU2Nyb2xsU2xpZGVyIGV4dGVuZHMgU2xpZGVyIHtcbiAgICBzdGF0aWMgZ2V0IF9fY29tcG9uZW50TmFtZSgpIHtcbiAgICAgICAgcmV0dXJuIFwiU2Nyb2xsU2xpZGVyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJDc7XG4gICAgfVxufVxuXG5jbGFzcyBTY3JvbGxXcmFwcGVyIGV4dGVuZHMgQmFzZSQxIHtcbiAgICBzdGF0aWMgZ2V0IF9fdGhlbWVTdHlsZSgpIHtcbiAgICAgICAgcmV0dXJuIHN0eWxlcyQ4O1xuICAgIH1cbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgY2xpcHBpbmc6IHRydWUsXG4gICAgICAgICAgICBGYWRlQ29udGFpbmVyOiB7XG4gICAgICAgICAgICAgICAgU2Nyb2xsQ29udGFpbmVyOiB7XG4gICAgICAgICAgICAgICAgICAgIHc6IF93ID0+IF93LFxuICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBTbGlkZXI6IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBTY3JvbGxTbGlkZXIsXG4gICAgICAgICAgICAgICAgdmVydGljYWw6IHRydWUsXG4gICAgICAgICAgICAgICAgc2lnbmFsczoge1xuICAgICAgICAgICAgICAgICAgICBvblNpemVDaGFuZ2U6IFwiX3VwZGF0ZVNjcm9sbENvbnRhaW5lclNpemVcIlxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgYW5ub3VuY2U6IFwiIFwiXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJTY3JvbGxXcmFwcGVyXCI7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgcHJvcGVydGllcygpIHtcbiAgICAgICAgcmV0dXJuIFsgXCJhdXRvU2Nyb2xsXCIsIFwiYXV0b1Njcm9sbERlbGF5XCIsIFwiYXV0b1Njcm9sbFNwZWVkXCIsIFwiY29udGVudFwiLCBcImZhZGVDb250ZW50XCIsIFwic2Nyb2xsRHVyYXRpb25cIiwgXCJzY3JvbGxTdGVwXCIsIFwic2hvd1Njcm9sbEJhclwiLCBcInNob3VsZFdyYXBcIiwgXCJmbGV4RGlyZWN0aW9uXCIgXTtcbiAgICB9XG4gICAgc3RhdGljIGdldCB0YWdzKCkge1xuICAgICAgICByZXR1cm4gWyBcIkZhZGVDb250YWluZXJcIiwgXCJTbGlkZXJcIiwge1xuICAgICAgICAgICAgbmFtZTogXCJTY3JvbGxDb250YWluZXJcIixcbiAgICAgICAgICAgIHBhdGg6IFwiRmFkZUNvbnRhaW5lci5TY3JvbGxDb250YWluZXJcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlNjcm9sbGFibGVUZXh0XCIsXG4gICAgICAgICAgICBwYXRoOiBcIlNjcm9sbENvbnRhaW5lci5TY3JvbGxhYmxlVGV4dFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX2NvbnN0cnVjdCgpIHtcbiAgICAgICAgc3VwZXIuX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GVudCAmJiBpc1Njcm9sbGFibGUgJiYgIXRoaXMuX2lzRW5kQ29udGVudFZpc2libGU7XG4gICAgICAgIHRoaXMuX0ZhZGVDb250YWluZXIucGF0Y2goe1xuICAgICAgICAgICAgaDogdGhpcy5oLFxuICAgICAgICAgICAgdzogdGhpcy5fY29udGVudFdpZHRoLFxuICAgICAgICAgICAgeTogdGhpcy5zdHlsZS5jb250ZW50TWFyZ2luVG9wLFxuICAgICAgICAgICAgeDogdGhpcy5zdHlsZS5jb250ZW50TWFyZ2luTGVmdCxcbiAgICAgICAgICAgIHJ0dDogdHJ1ZSxcbiAgICAgICAgICAgIHNoYWRlcjogc2hvdWxkRmFkZSA/IHtcbiAgICAgICAgICAgICAgICB0eXBlOiBsbmcuc2hhZGVycy5GYWRlT3V0LFxuICAgICAgICAgICAgICAgIGJvdHRvbTogdGhpcy5zdHlsZS5mYWRlSGVpZ2h0XG4gICAgICAgICAgICB9IDogdW5kZWZpbmVkXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfc2Nyb2xsQ29udGFpbmVyTG9hZGVkKF9yZWYyMykge1xuICAgICAgICB2YXIge2g6IGh9ID0gX3JlZjIzO1xuICAgICAgICB0aGlzLl9TY3JvbGxDb250YWluZXIuaCA9IGg7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVNjcm9sbFdyYXBwZXJMYXlvdXQoKTtcbiAgICB9XG4gICAgX3VwZGF0ZVNjcm9sbENvbnRhaW5lcigpIHtcbiAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnQpIHJldHVybjtcbiAgICAgICAgaWYgKHR5cGVvZiB0aGlzLmNvbnRlbnQgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgIHRoaXMuX1Njcm9sbENvbnRhaW5lci5wYXRjaCh7XG4gICAgICAgICAgICAgICAgZmxleDoge1xuICAgICAgICAgICAgICAgICAgICBkaXJlY3Rpb246IFwiY29sdW1uXCJcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIFNjcm9sbGFibGVUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIGg6IDAsXG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuX2NvbnRlbnRXaWR0aCxcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogVGV4dEJveCxcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogdGhpcy5jb250ZW50LFxuICAgICAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dFN0eWxlOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIHRoaXMuc3R5bGUudGV4dFN0eWxlKSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcFdpZHRoOiB0aGlzLl9jb250ZW50V2lkdGhcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9zY3JvbGxDb250YWluZXJMb2FkZWRcIlxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBvbkFmdGVyVXBkYXRlOiB0aGlzLl9hZnRlclRleHRCb3hVcGRhdGUuYmluZCh0aGlzKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkodGhpcy5jb250ZW50KSkge1xuICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSB7fTtcbiAgICAgICAgICAgIHRoaXMuY29udGVudC5mb3JFYWNoKCgoaXRlbSwgaW5kZXgpID0+IHtcbiAgICAgICAgICAgICAgICB2YXIgaWQgPSBcIlNjcm9sbFRleHRcIi5jb25jYXQoaW5kZXgpO1xuICAgICAgICAgICAgICAgIGNvbnRlbnRbaWRdID0gX29iamVjdFNwcmVhZCh7XG4gICAgICAgICAgICAgICAgICAgIHc6IHRoaXMuX2NvbnRlbnRXaWR0aFxuICAgICAgICAgICAgICAgIH0sIGl0ZW0pO1xuICAgICAgICAgICAgICAgIGlmIChpdGVtLnRleHQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29udGVudFtpZF0gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBUZXh0Qm94LFxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudDogaXRlbS50ZXh0LFxuICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCB0aGlzLnN0eWxlLnRleHRTdHlsZSksIGl0ZW0uc3R5bGUpLCB7fSwge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JkV3JhcDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogdGhpcy5fY29udGVudFdpZHRoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBvbkFmdGVyVXBkYXRlOiB0aGlzLl9hZnRlclRleHRCb3hVcGRhdGUuYmluZCh0aGlzKVxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIHRoaXMuX1Njcm9sbENvbnRhaW5lci5wYXRjaChfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICBmbGV4OiB7XG4gICAgICAgICAgICAgICAgICAgIGRpcmVjdGlvbjogdGhpcy5mbGV4RGlyZWN0aW9uLFxuICAgICAg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SArIHRoaXMuX1Njcm9sbENvbnRhaW5lci5maW5hbEggPiB0aGlzLnJlbmRlckhlaWdodDtcbiAgICAgICAgICAgIGlmIChpc1Njcm9sbGFibGUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9hdXRvU2Nyb2xsQ29tcGxldGUgPSBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLl9zY3JvbGxDb250YWluZXJZID49IDApIHtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoXCIkc2Nyb2xsQ2hhbmdlZFwiLCBcImVuZFVwXCIsIHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHRoaXMuX2lzRW5kQ29udGVudFZpc2libGUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9pc0VuZENvbnRlbnRWaXNpYmxlID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgdGhpcy5fdXBkYXRlRmFkZUNvbnRhaW5lcigpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5zaWduYWwoXCJvblVwQXRUb3BcIik7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmVzZXRTY3JvbGwoKSB7XG4gICAgICAgIHRoaXMuX1Njcm9sbENvbnRhaW5lci55ID0gMDtcbiAgICAgICAgdGhpcy5fU2xpZGVyLnZhbHVlID0gMDtcbiAgICAgICAgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLnRyYW5zaXRpb24oXCJ5XCIpLmZpbmlzaCgpO1xuICAgICAgICBkZWxldGUgdGhpcy5fU2Nyb2xsQ29udGFpbmVyLl90cmFuc2l0aW9ucztcbiAgICAgICAgdGhpcy5fYXV0b1Njcm9sbENvbXBsZXRlID0gZmFsc2U7XG4gICAgfVxuICAgIF9zZXRBdXRvU2Nyb2xsKHZhbCkge1xuICAgICAgICBpZiAodGhpcy5fYXV0b1Njcm9sbCAhPT0gdmFsKSB7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ICAgICAgICAgICAgIHc6IHRoaXMudyArIHNoYWRvd1NpemUgKiAyICsgZXh0cmFCb3VuZHNYLFxuICAgICAgICAgICAgICAgIGg6IHRoaXMuaCArIHNoYWRvd1NpemUgKiAyICsgZXh0cmFCb3VuZHNZLFxuICAgICAgICAgICAgICAgIHg6ICh0aGlzLncgKyBleHRyYUJvdW5kc1gpIC8gMixcbiAgICAgICAgICAgICAgICB5OiAodGhpcy5oICsgZXh0cmFCb3VuZHNZKSAvIDIsXG4gICAgICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgICAgIHJ0dDogdGhpcy5tYXNrU2hhZG93LFxuICAgICAgICAgICAgICAgIHNoYWRlcjogdGhpcy5tYXNrU2hhZG93ID8ge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiBsbmcuc2hhZGVycy5Ib2xlLFxuICAgICAgICAgICAgICAgICAgICB3OiB0aGlzLncgLSBob2xlcHVuY2hFcnJvcixcbiAgICAgICAgICAgICAgICAgICAgaDogdGhpcy5oIC0gaG9sZXB1bmNoRXJyb3IsXG4gICAgICAgICAgICAgICAgICAgIHg6IHNoYWRvd1NpemUgKyBob2xlcHVuY2hFcnJvciAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHk6IHNoYWRvd1NpemUgKyBob2xlcHVuY2hFcnJvciAvIDIsXG4gICAgICAgICAgICAgICAgICAgIHJhZGl1czogcmFkaXVzXG4gICAgICAgICAgICAgICAgfSA6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgICAgICBTaGFkb3c6IHtcbiAgICAgICAgICAgICAgICAgICAgY29sb3I6IHRoaXMuc3R5bGUuY29sb3IsXG4gICAgICAgICAgICAgICAgICAgIHRleHR1cmU6IGxuZy5Ub29scy5nZXRTaGFkb3dSZWN0KHRoaXMudyArIHRoaXMuc3R5bGUuc3ByZWFkICogMiwgdGhpcy5oICsgdGhpcy5zdHlsZS5zcHJlYWQgKiAyLCByYWRpdXMsIHRoaXMuc3R5bGUuYmx1cilcb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IHN1cGVyLl9jb25zdHJ1Y3QoKTtcbiAgICAgICAgdGhpcy5fc2VsZWN0ZWRJbmRleCA9IDA7XG4gICAgICAgIHRoaXMuX2NvbnRlbnRJdGVtcyA9IFtdO1xuICAgIH1cbiAgICBfdXBkYXRlKCkge1xuICAgICAgICBzdXBlci5fdXBkYXRlKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVNlbGVjdGVkKCk7XG4gICAgfVxuICAgIF91cGRhdGVTZWxlY3RlZCgpIHtcbiAgICAgICAgaWYgKHRoaXMuX3ByZXZlU2VsZWN0ZWRJbmRleCAhPT0gdGhpcy5zZWxlY3RlZEluZGV4KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5fcHJldmVTZWxlY3RlZEluZGV4ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICB2YXIgcHJldkNvbnRlbnQgPSB0aGlzLnRhZyhcIkNvbnRlbnRcIi5jb25jYXQodGhpcy5fcHJldmVTZWxlY3RlZEluZGV4KSk7XG4gICAgICAgICAgICAgICAgcHJldkNvbnRlbnQuc21vb3RoID0ge1xuICAgICAgICAgICAgICAgICAgICBhbHBoYTogMFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuX2hhc0NvbnRlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgcHJldkNvbnRlbnQuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mYWRlSW5Db250ZW50KCk7XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuc2VsZWN0ZWRJbmRleCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZhZGVJbkNvbnRlbnQoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2hhc0NvbnRlbnQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9mYWRlSW5Db250ZW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLl9wcmV2ZVNlbGVjdGVkSW5kZXggPSB0aGlzLnNlbGVjdGVkSW5kZXg7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX2ZhZGVJbkNvbnRlbnQoKSB7XG4gICAgICAgIHRoaXMuX3NlbGVjdGVkQ29udGVudC5zbW9vdGggPSB7XG4gICAgICAgICAgICBhbHBoYTogMVxuICAgICAgICB9O1xuICAgICAgICB0aGlzLl9zZWxlY3RlZENvbnRlbnQuX2dldFRyYW5zaXRpb24oXCJhbHBoYVwiKS5vbmNlKFwiZmluaXNoXCIsICgoKSA9PiB7XG4gICAgICAgICAgICB0aGlzLmggPSB0aGlzLl9zZWxlY3RlZENvbnRlbnQuaDtcbiAgICAgICAgICAgIHRoaXMuc2lnbmFsKFwiY29udGVudEhlaWdodENoYW5nZVwiLCB0aGlzLmgpO1xuICAgICAgICB9KSk7XG4gICAgfVxuICAgIF91cGRhdGVDb250ZW50KCkge1xuICAgICAgICB2YXIgYWxsQ29udGVudCA9IHRoaXMuY29udGVudEl0ZW1zLnJlZHVjZSgoKGFjYywgaXRlbSwgaWR4KSA9PiB7XG4gICAgICAgICAgICB2YXIgY29tcG9uZW50O1xuICAgICAgICAgICAgdmFyIHRhZ05hbWUgPSBcIkNvbnRlbnRcIi5jb25jYXQoaWR4KTtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgdmFyIGNvbXBvbmVudExvYWRlciA9IGl0ZW0oKTtcbiAgICAgICAgICAgICAgICBpZiAoY29tcG9uZW50TG9hZGVyLnRoZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZEFzeW5jQ29tcG9uZW50KGNvbXBvbmVudExvYWRlciwgaWR4KTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRMb2FkZXI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb21wb25lbnQgPSBpdGVtO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGNvbXBvbmVudCkge1xuICAgICAgICAgICAgICAgIGFjY1t0YWdOYW1lXSA9IF9vYmplY3RTcHJlYWQoX29iamVjdFNwcmVhZCh7fSwgY29tcG9uZW50KSwge30sIHtcbiAgICAgICAgICAgICAgICAgICAgYWxwaGE6IDBcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgIH0pLCB7fSk7XG4gICAgICAgIHRoaXMucGF0Y2goYWxsQ29udGVudCk7XG4gICAgfVxuICAgIF9sb2FkQXN5bmNDb21wb25lbnQoY29tcG9uZW50TG9hZGVyLCBpZHgpIHtcbiAgICAgICAgY29tcG9uZW50TG9hZGVyLnRoZW4oKGNvbXBvbmVudCA9PiB7XG4gICAgICAgICAgICB2YXIgdGFnTmFtZSA9IFwiQ29udGVudFwiLmNvbmNhdChpZHgpO1xuICAgICAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICAgICAgW3RhZ05hbWVdOiBfb2JqZWN0U3ByZWFkKF9vYmplY3RTcHJlYWQoe30sIGNvbXBvbmVudCksIHt9LCB7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiAwXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KSk7XG4gICAgfVxuICAgIHNldCBjb250ZW50SXRlbXMoY29udGVudEl0ZW1zKSB7XG4gICAgICAgIGlmICghc3RyaW5naWZ5Q29tcGFyZShjb250ZW50SXRlbXMsIHRoaXMuX2NvbnRlbnRJd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hYikge1xuICAgICAgICAgICAgdGhpcy5fdXBkYXRlVGFiQWxwaGFzKCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3VwZGF0ZVRhYkFscGhhcygpIHtcbiAgICAgICAgaWYgKHRoaXMuX2lzVGFic0ZvY3VzZWQpIHtcbiAgICAgICAgICAgIHRoaXMuX1RhYnMuaXRlbXMuZm9yRWFjaCgodGFiID0+IHtcbiAgICAgICAgICAgICAgICB0YWIucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBhbHBoYTogMVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5fVGFicy5pdGVtcy5mb3JFYWNoKCh0YWIgPT4ge1xuICAgICAgICAgICAgICAgIHRhYi5wYXRjaCh7XG4gICAgICAgICAgICAgICAgICAgIGFscGhhOiB0YWIgPT09IHRoaXMuX1RhYnMuc2VsZWN0ZWQgPyAxIDogLjNcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfdXBkYXRlVGFiQ29udGVudCgpIHtcbiAgICAgICAgdmFyIG1hcmdpbiA9IHRoaXMuc3R5bGUudGFic01hcmdpbkJvdHRvbTtcbiAgICAgICAgdGhpcy5fVGFiQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICB5OiB0aGlzLl9UYWJzLmggKyBtYXJnaW4sXG4gICAgICAgICAgICBjb250ZW50SXRlbXM6IHRoaXMuX3RhYkNvbnRlbnQsXG4gICAgICAgICAgICBzZWxlY3RlZEluZGV4OiB0aGlzLl9pc0ZvY3VzZWRNb2RlID8gdGhpcy5fVGFicy5zZWxlY3RlZEluZGV4IDogdW5kZWZpbmVkXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICAkaXRlbUNoYW5nZWQoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRhYkJhckhlaWdodCgpO1xuICA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9jdXNlZDoge1xuICAgICAgICAgICAgICAgIGNvbnRlbnRDb2xvcjogdGhlbWUuY29sb3IuZmlsbE5ldXRyYWwsXG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB7XG4gICAgICAgICAgICAgICAgICAgIHRleHRDb2xvcjogdGhlbWUuY29sb3IudGV4dE5ldXRyYWxcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGJyYW5kOiB7XG4gICAgICAgIG1vZGU6IHtcbiAgICAgICAgICAgIGZvY3VzZWQ6IHtcbiAgICAgICAgICAgICAgICBjb250ZW50Q29sb3I6IHRoZW1lLmNvbG9yLmZpbGxOZXV0cmFsLFxuICAgICAgICAgICAgICAgIHRleHRTdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0Q29sb3I6IHRoZW1lLmNvbG9yLnRleHROZXV0cmFsXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufSk7XG5cbnZhciBzdHlsZXMkMyA9IE9iamVjdC5mcmVlemUoe1xuICAgIF9fcHJvdG9fXzogbnVsbCxcbiAgICBiYXNlOiBiYXNlJDMsXG4gICAgbW9kZTogbW9kZSxcbiAgICB0b25lOiB0b25lJDJcbn0pO1xuXG5jbGFzcyBUYWIgZXh0ZW5kcyBTdXJmYWNlIHtcbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgICByZXR1cm4gX29iamVjdFNwcmVhZChfb2JqZWN0U3ByZWFkKHt9LCBzdXBlci5fdGVtcGxhdGUoKSksIHt9LCB7XG4gICAgICAgICAgICBDb250ZW50OiB7XG4gICAgICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgICAgIHg6IHcgPT4gdyAvIDIsXG4gICAgICAgICAgICAgICAgeTogaCA9PiBoIC8gMixcbiAgICAgICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIG1vdW50WTogLjUsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl9vblRleHRCb3hDaGFuZ2VkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX190aGVtZVN0eWxlKCkge1xuICAgICAgICByZXR1cm4gc3R5bGVzJDM7XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgX19jb21wb25lbnROYW1lKCkge1xuICAgICAgICByZXR1cm4gXCJUYWJcIjtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcImljb25cIiwgXCJ0aXRsZVwiIF07XG4gICAgfVxuICAgIHN0YXRpYyBnZXQgdGFncygpIHtcbiAgICAgICAgcmV0dXJuIFsgLi4uc3VwZXIudGFncywgXCJDb250ZW50XCIsIHtcbiAgICAgICAgICAgIG5hbWU6IFwiSWNvblwiLFxuICAgICAgICAgICAgcGF0aDogXCJDb250ZW50Lkljb25cIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRleHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQ29udGVudC5UZXh0XCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcIm5vVGl0bGVQYWRkaW5nWFwiLFxuICAgICAgICAgICAgY3VycjogXCJwYWRkaW5nWE5vVGl0bGVcIlxuICAgICAgICB9IF07XG4gICAgfVxuICAgIF9vblRleHRCb3hDaGFuZ2VkKCkge1xuICAgICAgICB0aGlzLl91cGRhdGVDb250ZW50KCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRhYlNpemUoKTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgc3VwZXIuX3VwZGF0ZSgpO1xuICAgICAgICB0aGlzLl91cGRhdGVJY29uKCk7XG4gICAgICAgIHRoaXMuX3VwZGF0ZVRleHQoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlQ29udGVudCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVUYWJTaXplKCk7XG4gICAgfVxuICAgIF91cGRhdGVJY29uKCkge1xuICAgICAgICBpZiAoIXRoaXMuaWNvbikge1xuICAgICAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgSWNvbjogdW5kZWZpbmVkXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaWNvblBhdGNoID0ge1xuICAgICAgICAgICAgaWNvbjogdGhpcy5pY29uLFxuICAgICAgICAgICAgdzogdGhpcy5zdHlsZS5pY29uU2l6ZSxcbiAgICAgICAgICAgIGg6IHRoaXMuc3R5bGUuaWNvblNpemUsXG4gICAgICAgICAgICB5OiB0aGlzLl9Db250ZW50LmggLyAyLFxuICAgICAgICAgICAgc3R5bGU6IHtcbiAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5jb250ZW50Q29sb3JcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgaWYgKHRoaXMudGl0bGUpIHtcbiAgICAgICAgICAgIGljb25QYXRjaC54ID0gMDtcbiAgICAgICAgICAgIGljb25QYXRjaC5tb3VudFggPSAwO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWNvblBhdGNoLnggPSB0aGlzLl9Db250ZW50LncgLyAyO1xuICAgICAgICAgICAgaWNvblBhdGNoLm1vdW50WCA9IC41O1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9JY29uKSB7XG4gICAgICAgICAgICB0aGlzLl9JY29uLnBhdGNoKGljb25QYXRjaCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLl9Db250ZW50LnBhdGNoKHtcbiAgICAgICAgICAgICAgICBJY29uOiBfb2JqZWN0U3ByZWFkKHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogSWNvbixcbiAgICAgICAgICAgICAgICAgICAgbW91bnRZOiAuNVxuICAgICAgICAgICAgICAgIH0sIGljb25QYXRjaClcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIF91cGRhdGVUZXh0KCkge1xuICAgICAgICB2YXIgdGV4dFBhdGNoID0ge1xuICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgIHN0eWxlOiB7XG4gICAgICAgICAgICAgICAgdGV4dFN0eWxlOiB0aGlzLnN0eWxlLnRleHRTdHlsZVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHk6IHRoaXMuX0NvbnRlbnQuaCAvIDJcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKHRoaXMuaWNvbikge1xuICAgICAgICAgICAgdGV4dFBhdGNoLnggPSB0aGlzLl9pY29uVyArIHRoaXMuc3R5bGUuaWNvbk1hcmdpblJpZ2h0O1xuICAgICAgICAgICAgdGV4dFBhdGNoLm1vdW50WCA9IDA7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0ZXh0UGF0Y2gueCA9IHRoaXMuX0NvbnRlbnQudyAvIDI7XG4gICAgICAgICAgICB0ZXh0UGF0Y2gubW91bnRYID0gLjU7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh0ZXh0UGF0Y2gpO1xuICAgIH1cbiAgICBfdXBkYXRlQ29udGVudCgpIHtcbiAgICAgICAgdGhpcy5fQ29udGVudC5wYXRjaCh7XG4gICAgICAgICAgICB3OiB0aGlzLl9pY29uVyArICh0aGlzLnRpdGxlID8gdGhpcy5zdHlsZS5pY29uTWFyZ2luUmlnaHQgOiAwKSArIHRoaXMuX3RleHRXLFxuICAgICAgICAgICAgaDogTWF0aC5tYXgodGhpcy5faWNvbkgsIHRoaXMuX1RleHQuaClcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIF91cGRhdGVUYWJTaXplKCkge1xuICAgICAgICBpZiAodGhpcy50aXRsZSB8fCB0aGlzLmljb24pIHtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIHc6IHRoaXMuX3BhZGRpbmdYICogMiArIHRoaXMuX0NvbnRlbnQudyxcbiAgICAgICAgICAgICAgICBoOiB0aGlzLnN0eWxlLnBhZGRpbmdZICogMiArIHRoaXMuX0NvbnRlbnQuaFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgICAgICB3OiAwLFxuICAgICAgICAgICAgICAgIGg6IDBcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIGdldCBfdGV4dFcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnRpdGxlID8gdGhpcy5fVGV4dC53IDogMDtcbiAgICB9XG4gICAgZ2V0IF9pY29uVygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuaWNvbiAmJiB0aGlzLl9JY29uICE9PSB1bmRlZmluZWQgPyB0aGlzLl9JY29uLncgOiAwO1xuICAgIH1cbiAgICBnZXQgX2ljb25IKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5pY29uICYmIHRoaXMuX0ljb24gIT09IHVuZGVmaW5lZCA/IHRoaXMuX0ljb24uaCA6IDA7XG4gICAgfVxuICAgIGdldCBfcGFkZGluZ1goKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnRpdGxlID8gdGhpcy5zdHlsZS5wYWRkaW5nWCA6IHRoaXMuc3R5bGUucGFkZGluZ1hOb1Rp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Y2FsZTogLjUsXG4gICAgICAgICAgICBtb3VudFg6IC41LFxuICAgICAgICAgICAgeDogdyA9PiB3IC8gMixcbiAgICAgICAgICAgIEJhY2tncm91bmQ6IHtcbiAgICAgICAgICAgICAgICBUZXh0OiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFRleHRCb3gsXG4gICAgICAgICAgICAgICAgICAgIHNpZ25hbHM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRleHRCb3hDaGFuZ2VkOiBcIl90ZXh0TG9hZGVkXCJcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9XG4gICAgc3RhdGljIGdldCBwcm9wZXJ0aWVzKCkge1xuICAgICAgICByZXR1cm4gWyBcInRpdGxlXCIsIFwiZGVsYXlWaXNpYmxlXCIsIFwidGltZVZpc2libGVcIiBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IHRhZ3MoKSB7XG4gICAgICAgIHJldHVybiBbIFwiQmFja2dyb3VuZFwiLCB7XG4gICAgICAgICAgICBuYW1lOiBcIlRleHRcIixcbiAgICAgICAgICAgIHBhdGg6IFwiQmFja2dyb3VuZC5UZXh0XCJcbiAgICAgICAgfSBdO1xuICAgIH1cbiAgICBzdGF0aWMgZ2V0IGFsaWFzU3R5bGVzKCkge1xuICAgICAgICByZXR1cm4gWyB7XG4gICAgICAgICAgICBwcmV2OiBcInBvaW50ZXJIXCIsXG4gICAgICAgICAgICBjdXJyOiBcInBvaW50ZXJIZWlnaHRcIlxuICAgICAgICB9LCB7XG4gICAgICAgICAgICBwcmV2OiBcInBvaW50ZXJXXCIsXG4gICAgICAgICAgICBjdXJyOiBcInBvaW50ZXJXaWR0aFwiXG4gICAgICAgIH0gXTtcbiAgICB9XG4gICAgX3VwZGF0ZSgpIHtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGV4dCgpO1xuICAgICAgICB0aGlzLl91cGRhdGVCYWNrZ3JvdW5kKCk7XG4gICAgfVxuICAgIF91cGRhdGVUZXh0KCkge1xuICAgICAgICBpZiAodGhpcy5fVGV4dCkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgY29udGVudDogdGhpcy50aXRsZSxcbiAgICAgICAgICAgICAgICBzdHlsZToge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0U3R5bGU6IHRoaXMuc3R5bGUudGV4dFN0eWxlXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgX3RleHRMb2FkZWQoKSB7XG4gICAgICAgIHRoaXMuX3VwZGF0ZUJhY2tncm91bmRIZWlnaHQoKTtcbiAgICAgICAgdGhpcy5fdXBkYXRlVGV4dFBvc2l0aW9uKCk7XG4gICAgfVxuICAgIF91cGRhdGVCYWNrZ3JvdW5kKCkge1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIEJhY2tncm91bmQ6IHtcbiAgICAgICAgICAgICAgICB0ZXh0dXJlOiB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IEJ1YmJsZSxcbiAgICAgICAgICAgICAgICAgICAgdzogdGhpcy5fQmFja2dyb3VuZC53LFxuICAgICAgICAgICAgICAgICAgICBoOiB0aGlzLl9CYWNrZ3JvdW5kLmgsXG4gICAgICAgICAgICAgICAgICAgIHJhZGl1czogZ2V0TWF4Um91bmRSYWRpdXModGhpcy5zdHlsZS5yYWRpdXMsIHRoaXMuX0JhY2tncm91bmQudyAtIHRoaXMuc3R5bGUucG9pbnRlckhlaWdodCwgdGhpcy5fQmFja2dyb3VuZC5oIC0gdGhpcy5zdHlsZS5wb2ludGVySGVpZ2h0KSxcbiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcldpZHRoOiB0aGlzLnN0eWxlLnBvaW50ZXJXaWR0aCxcbiAgICAgICAgICAgICAgICAgICAgcG9pbnRlckhlaWdodDogdGhpcy5zdHlsZS5wb2ludGVySGVpZ2h0LFxuICAgICAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5zdHlsZS5iYWNrZ3JvdW5kQ29sb3JcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlQmFja2dyb3VuZEhlaWdodCgpIHtcbiAgICAgICAgdmFyIGJhY2tncm91bmRIID0gdGhpcy5fVGV4dC5maW5hbEggKyB0aGlzLnN0eWxlLnBhZGRpbmdZICogMiArIHRoaXMuc3R5bGUucG9pbnRlckhlaWdodDtcbiAgICAgICAgdmFyIGJhY2tncm91bmRXID0gdGhpcy5fVGV4dC5maW5hbFcgKyB0aGlzLnN0eWxlLnBhZGRpbmdYICogMjtcbiAgICAgICAgdGhpcy5wYXRjaCh7XG4gICAgICAgICAgICB3OiBiYWNrZ3JvdW5kVyxcbiAgICAgICAgICAgIGg6IGJhY2tncm91bmRILFxuICAgICAgICAgICAgbW91bnRZOiAxLFxuICAgICAgICAgICAgeTogLXRoaXMuc3R5bGUubWFyZ2luQm90dG9tLFxuICAgICAgICAgICAgQmFja2dyb3VuZDoge1xuICAgICAgICAgICAgICAgIHc6IGJhY2tncm91bmRXLFxuICAgICAgICAgICAgICAgIGg6IGJhY2tncm91bmRILFxuICAgICAgICAgICAgICAgIHRleHR1cmU6IHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogQnViYmxlLFxuICAgICAgICAgICAgICAgICAgICB3OiBiYWNrZ3JvdW5kVyxcbiAgICAgICAgICAgICAgICAgICAgaDogYmFja2dyb3VuZEhcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBfdXBkYXRlVGV4dFBvc2l0aW9uKCkge1xuICAgICAgICBpZiAodGhpcy5fVGV4dCkge1xuICAgICAgICAgICAgdGhpcy5fVGV4dC5wYXRjaCh7XG4gICAgICAgICAgICAgICAgbW91bnQ6IC41LFxuICAgICAgICAgICAgICAgIHg6IHRoaXMuX0JhY2tncm91bmQudyAvIDIsXG4gICAgICAgICAgICAgICAgeTogKHRoaXMuX0JhY2tncm91bmQuaCAtIHRoaXMuc3R5bGUucG9pbnRlckhlaWdodCkgLyAyXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBfY2xlYXJUaW1lcnMoKSB7XG4gICAgICAgIGNsZWFyVGltZW91dCh0aGlzLl9oaWRlVGltZXIpO1xuICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5fc2hvd1RpbWVyKTtcbiAgICB9XG4gICAgX3RyYW5zaXRpb25JbigpIHtcbiAgICAgICAgdmFyIHNtb290aCA9IHtcbiAgICAgICAgICAgIHNtb290aDoge1xuICAgICAgICAgICAgICAgIGFscGhhOiBbIDEsIHRoaXMuc3R5bGUudHJhbnNpdGlvbiBdLFxuICAgICAgICAgICAgICAgIHNjYWxlOiBbIDEsIHRoaXMuc3R5bGUudHJhbnNpdGlvbiBdXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIGlmICh0aGlzLmRlbGF5VmlzaWJsZSkge1xuICAgICAgICAgICAgdGhpcy5fc2hvd1RpbWVyID0gc2V0VGltZW91dCgoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgICAgICBzbW9vdGg6IHNtb290aFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSksIHRoaXMuZGVsYXlWaXNpYmxlKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX3Nob3dUaW1lciA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgIHRoaXMucGF0Y2goe1xuICAgICAgICAgICAgICAgIHNtb290aDogc21vb3RoXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9oaWRlVGltZXIgPSB0aGlzLnRpbWVWaXNpYmxlID8gc2V0VGltZW91dCgoKCkgPT4ge1xuICAgICAgICAgICAgdGhpcy5fdW5mb2N1cygpO1xuICAgICAgICB9KSwgdGhpcy50aW1lVmlzaWJsZSArICh0aGlzLmRlbGF5VmlzaWJsZSB8fCAwKSkgOiB1bmRlZmluZWQ7XG4gICAgfVxuICAgIF90cmFuc2l0aW9uT3V0KCkge1xuICAgICAgICB0aGlzLnBhdGNoKHtcbiAgICAgICAgICAgIHNtb290aDoge1xuICAgICAgICAgICAgICAgIGFscGhhOiBbIDAsIHRoaXMuc3R5bGUudHJhbnNpdGlvbiBdLFxuICAgICAgICAgICAgICAgIHNjYWxlOiBbIC41LCB0aGlzLnN0eWxlLnRyYW5zaXRpb24gXVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgX2ZvY3VzKCkge1xuICAgICAgICB0aGlzLl9jbGVhclRpbWVycygpO1xuICAgICAgICB0aGlzLl90cmFuc2l0aW9uSW4oKTtcbiAgICB9XG4gICAgX3VuZm9jdXMoKSB7XG4gICAgICAgIHRoaXMuX2NsZWFyVGltZXJzKCk7XG4gICAgICAgIHRoaXMuX3RyYW5zaXRpb25PdXQoKTtcbiAgICB9XG4gICAgc2V0IGFubm91bmNlKGFubm91bmNlKSB7XG4gICAgICAgIHN1cGVyLmFubm91bmNlID0gYW5ub3VuY2U7XG4gICAgfVxuICAgIGdldCBhbm5vdW5jZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2Fubm91bmNlIHx8IHRoaXMuX1RleHQgJiYgdGhpcy5fVGV4dC5hbm5vdW5jZTtcbiAgICB9XG59XG5cbnZhciBwb29scyA9IG5ldyBNYXA7XG5cbmZ1bmN0aW9uIGdldChrZXkpIHtcbiAgICBpZiAocG9vbHMuaGFzKGtleSkpIHtcbiAgICAgICAgdmFyIHBvb2wgPSBwb29scy5nZXQoa2V5KTtcbiAgICAgICAgdmFyIF9pbmRleCA9IHBvb2wuaW5kZXg7XG4gICAgICAgIGlmICh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AgICB9IGVsc2UgaWYgKHR5cGVvZiBwaHJhc2UgPT09IFwic3RyaW5nXCIgJiYgcGhyYXNlLmluY2x1ZGVzKFwiUEFVU0UtXCIpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBwYXVzZSA9IHBocmFzZS5zcGxpdChcIlBBVVNFLVwiKVsxXSAqIDFlMztcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzTmFOKHBhdXNlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcGF1c2UgPSAwO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHlpZWxkIGRlbGF5KHBhdXNlKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBwaHJhc2UgPT09IFwic3RyaW5nXCIgJiYgcGhyYXNlLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdG90YWxSZXRyaWVzID0gMztcbiAgICAgICAgICAgICAgICAgICAgdmFyIHJldHJpZXNMZWZ0ID0gdG90YWxSZXRyaWVzO1xuICAgICAgICAgICAgICAgICAgICB3aGlsZSAoYWN0aXZlICYmIHJldHJpZXNMZWZ0ID4gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB5aWVsZCBzcGVhayhwaHJhc2UsIHV0dGVyYW5jZXMsIGxhbmcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHJpZXNMZWZ0ID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZSBpbnN0YW5jZW9mIFNwZWVjaFN5bnRoZXNpc0Vycm9yRXZlbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGUuZXJyb3IgPT09IFwibmV0d29ya1wiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXRyaWVzTGVmdC0tO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKFwiU3BlZWNoIHN5bnRoZXNpcyBuZXR3b3JrIGVycm9yLiBSZXRyaWVzIGxlZnQ6IFwiLmNvbmNhdChyZXRyaWVzTGVmdCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeWllbGQgZGVsYXkoNTAwICogKHRvdGFsUmV0cmllcyAtIHJldHJpZXNMZWZ0KSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZS5lcnJvciA9PT0gXCJjYW5jZWxlZFwiIHx8IGUuZXJyb3IgPT09IFwiaW50ZXJydXB0ZWRcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0cmllc0xlZnQgPSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiU3BlZWNoU3ludGhlc2lzRXJyb3JFdmVudDogXCIuY29uY2F0KGUuZXJyb3IpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgcGhyYXNlID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNlcmllc1Jlc3VsdCA9IHNwZWFrU2VyaWVzKHBocmFzZSgpLCBsYW5nLCBmYWxzZSk7XG4gICAgICAgICAgICAgICAgICAgIG5lc3RlZFNlcmllc1Jlc3VsdHMucHVzaChzZXJpZXNSZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICB5aWVsZCBzZXJpZXNSZXN1bHQuc2VyaWVzO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShwaHJhc2UpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBfc2VyaWVzUmVzdWx0ID0gc3BlYWtTZXJpZXMocGhyYXNlLCBsYW5nLCBmYWxzZSk7XG4gICAgICAgICAgICAgICAgICAgIG5lc3RlZFNlcmllc1Jlc3VsdHMucHVzaChfc2VyaWVzUmVzdWx0KTtcbiAgICAgICAgICAgICAgICAgICAgeWllbGQgX3Nlcmllc1Jlc3VsdC5zZXJpZXM7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgYWN0aXZlID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICB9KSkoKTtcbiAgICByZXR1cm4ge1xuICAgICAgICBzZXJpZXM6IHNlcmllc0NoYWluLFxuICAgICAgICBnZXQgYWN0aXZlKCkge1xuICAgICAgICAgICAgcmV0dXJuIGFjdGl2ZTtcbiAgICAgICAgfSxcbiAgICAgICAgYXBwZW5kOiB0b1NwZWFrID0+IHtcbiAgICAgICAgICAgIHJlbWFpbmluZ1BocmFzZXMucHVzaCh0b1NwZWFrKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiAoKSA9PiB7XG4gICAgICAgICAgICBpZiAoIWFjdGl2ZSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChyb290KSB7XG4gICAgICAgICAgICAgICAgc3ludGguY2FuY2VsKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBuZXN0ZWRTZXJpZXNSZXN1bHRzLmZvckVhY2goKG5lc3RlZFNlcmllc1Jlc3VsdHMgPT4ge1xuICAgICAg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WVjaCA9IHNwZWFrKHRvU3BlYWssIG9wdGlvbnMubGFuZ3VhZ2UpO1xuICAgICAgICAgICAgaWYgKHNwZWVjaCAmJiBzcGVlY2guc2VyaWVzKSB7XG4gICAgICAgICAgICAgICAgc3BlZWNoLnNlcmllcy50aGVuKCgoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhZ2UuZW1pdChcImFubm91bmNlRW5kZWRcIik7XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHRvQW5ub3VuY2VTdHIgPSBBcnJheS5pc0FycmF5KHRvU3BlYWspID8gdG9TcGVhay5jb25jYXQoKS5qb2luKFwiIFwiKSA6IHRvU3BlYWs7XG4gICAgICAgICAgICB2YXIgdG9Bbm5vdW5jZVdvcmRzID0gdG9Bbm5vdW5jZVN0ci5zcGxpdChcIiBcIik7XG4gICAgICAgICAgICB2YXIgdGltZW91dERlbGF5ID0gdG9Bbm5vdW5jZVdvcmRzLmxlbmd0aCAqIGFubm91bmNlck9wdGlvbnMudm9pY2VPdXREZWxheTtcbiAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aGlzLl9hbm5vdW5jZUVuZGVkVGltZW91dCk7XG4gICAgICAgICAgICB0aGlzLl9hbm5vdW5jZUVuZGVkVGltZW91dCA9IHNldFRpbWVvdXQoKCgpID0+IHtcbiAgICAgICAgICAgICAgICB0aGlzLnN0YWdlLmVtaXQoXCJhbm5vdW5jZVRpbWVvdXRFbmRlZFwiKTtcbiAgICAgICAgICAgIH0pLCB0aW1lb3V0RGVsYXkpO1xuICAgICAgICAgICAgcmV0dXJuIHNwZWVjaDtcbiAgICAgICAgfVxuICAgICAgICBfYnVpbGQoKSB7XG4gICAgICAgICAgICBzdXBlci5fYnVpbGQgJiYgc3VwZXIuX2J1aWxkKCk7XG4gICAgICAgICAgICB0aGlzLl9kZWJvdW5jZUFubm91bmNlRm9jdXNDaGFuZ2VzID0gZGVib3VuY2Uod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GlzLmZvY3VzRGlmZkhvb2sgPSBmb2N1c0RpZmY7XG4gICAgICAgICAgICBpZiAoIXRoaXMuYW5ub3VuY2VyRW5hYmxlZCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciB0b0Fubm91bmNlID0gZm9jdXNEaWZmLnJlZHVjZSgoKGFjYywgZWxtKSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVsbS5hbm5vdW5jZSkge1xuICAgICAgICAgICAgICAgICAgICBhY2MucHVzaChbIGVsbU5hbWUoZWxtKSwgXCJBbm5vdW5jZVwiLCBlbG0uYW5ub3VuY2UgXSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbG0udGl0bGUpIHtcbiAgICAgICAgICAgICAgICAgICAgYWNjLnB1c2goWyBlbG1OYW1lKGVsbSksIFwiVGl0bGVcIiwgZWxtLnRpdGxlIHx8IFwiXCIgXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwgW10pO1xuICAgICAgICAgICAgZm9jdXNEaWZmLnJldmVyc2UoKS5yZWR1Y2UoKChhY2MsIGVsbSkgPT4ge1xuICAgICAgICAgICAgICAgIGlmIChlbG0uYW5ub3VuY2VDb250ZXh0KSB7XG4gICAgICAgICAgICAgICAgICAgIGFjYy5wdXNoKFsgZWxtTmFtZShlbG0pLCBcIkNvbnRleHRcIiwgZWxtLmFubm91bmNlQ29udGV4dCBdKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBhY2MucHVzaChbIGVsbU5hbWUoZWxtKSwgXCJObyBDb250ZXh0XCIsIFwiXCIgXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBhY2M7XG4gICAgICAgICAgICB9KSwgdG9Bbm5vdW5jZSk7XG4gICAgICAgICAgICBpZiAodGhpcy5kZWJ1Zykge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUudGFibGUodG9Bbm5vdW5jZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0b0Fubm91bmNlID0gdG9Bbm5vdW5jZS5yZWR1Y2UoKChhY2MsIGEpID0+IHtcbiAgICAgICAgICAgICAgICB2YXIgdHh0ID0gYVsyXTtcbiAgICAgICAgICAgICAgICB0eHQgJiYgYWNjLnB1c2godHh0KTtcbiAgICAgICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICAgICAgfSksIFtdKTtcbiAgICAgICAgICAgIGlmICh0b0Fubm91bmNlLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHRoaXMuJGFubm91bmNlckNhbmNlbCgpO1xuICAgICAgICAgICAgICAgIHRoaXMuX2N1cnJlbnRseVNwZWFraW5nID0gdGhpcy5fdm9pY2VPdXQodG9Bbm5vdW5jZS5yZWR1Y2UoKChhY2MsIHZhbCkgPT4gYWNjLmNvbmNhdCh2YWwpKSwgW10pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICAkYW5ub3VuY2UodG9Bbm5vdW5jZSkge1xuICAgICAgICAgICAgdmFyIHthcHBlbmQ6IGFwcGVuZCA9IGZhbHNlLCBub3RpZmljYXRpb246IG5vdGlmaWNhdGlvbiA9IGZhbHNlfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307XG4gICAgICAgICAgICBpZiAoIXRvQW5ub3VuY2UgfHwgIXRvQW5ub3VuY2UudHJpbSgpLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzLmFubm91bmNlckVuYWJsZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9kZWJvdW5jZUFubm91bmNlRm9jdXNDaGFuZ2VzLmZsdXNoKCk7XG4gICAgICAgICAgICAgICAgaWYgKGFwcGVuZCAmJiB0aGlzLl9jdXJyZW50bHlTcGVha2luZyAmJiB0aGlzLl9jdXJyZW50bHlTcGVha2luZy5hY3RpdmUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3VycmVudGx5U3BlYWtpbmcuYXBwZW5kKHRvQW5ub3VuY2UpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuJGFubm91bmNlckNhbmNlbCgpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jdXJyZW50bHlTcGVha2luZyA9IHRoaXMuX3ZvaWNlT3V0KHRvQW5ub3VuY2UpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAobm90aWZpY2F0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX3ZvaWNlT3V0RGlzYWJsZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jdXJyZW50bHlTcGVha2luZy5zZXJpZXMuZmluYWxseSgoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdm9pY2VPdXREaXNhYmxlZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4kYW5ub3VuY2VyUmVmcmVzaCgpO1xuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgICRhbm5vdW5jZXJDYW5jZWwoKSB7XG4gICAgICAgICAgICB0aGlzLl9jdXJyZW50bHlTcGVha2luZyAmJiB0aGlzLl9jdXJyZW50bHlTcGVha2luZy5jYW5jZWwoKTtcbiAgICAgICAgfVxuICAgICAgICAkYW5ub3VuY2VyUmVmcmVzaChkZXB0aCkge1xuICAgICAgICAgICAgaWYgKGRlcHRoKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fbGFzdEZvY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aWNlKC0xKTtcbiAgICAgICAgICAgICAgICB0aGlzW3NldFNlbGVjdGVkXShzZWxlY3RlZCwgdHJ1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgW1wiJFwiICsgc2V0U2VsZWN0ZWRdKHNlbGVjdGVkLCB2YWwpIHtcbiAgICAgICAgICAgIHRoaXNbc2V0U2VsZWN0ZWRdKHNlbGVjdGVkLCB2YWwpO1xuICAgICAgICB9XG4gICAgICAgIGdldCBbY3VycmVudFNlbGVjdGVkXSgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzW2l0ZW1zXVt0aGlzW2N1cnJlbnRTZWxlY3RlZEluZGV4XV07XG4gICAgICAgIH1cbiAgICB9O1xufVxuXG5mdW5jdGlvbiBpbmRleChCYXNlKSB7XG4gICAgcmV0dXJuIGNsYXNzIGV4dGVuZHMgQmFzZSB7XG4gICAgICAgIF9pbml0KCkge1xuICAgICAgICAgICAgc3VwZXIuX2luaXQoKTtcbiAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdG9nZ2xlRWRpdCgpIHtcbiAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gIXRoaXMuaXNFZGl0aW5nO1xuICAgICAgICB9XG4gICAgICAgIF9zd2FwSXRlbUFycmF5UG9zKGFycmF5LCBjdXJyZW50LCBwcmV2aW91cykge1xuICAgICAgICAgICAgW2FycmF5W2N1cnJlbnRdLCBhcnJheVtwcmV2aW91c11dID0gWyBhcnJheVtwcmV2aW91c10sIGFycmF5W2N1cnJlbnRdIF07XG4gICAgICAgICAgICBzdXBlci5zZWxlY3RlZEluZGV4ID0gY3VycmVudDtcbiAgICAgICAgfVxuICAgICAgICBfdW5mb2N1cygpIHtcbiAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7XG4gICAgICAgICAgICBzdXBlci5fd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VycmVudEl0ZW0ueTtcbiAgICAgICAgICAgIHZhciBuZXdQb3NYID0gbmV4dEl0ZW0udHJhbnNpdGlvbihcInhcIikgPyBuZXh0SXRlbS50cmFuc2l0aW9uKFwieFwiKS50YXJnZXRWYWx1ZSA6IG5leHRJdGVtLng7XG4gICAgICAgICAgICB2YXIgbmV3UG9zWSA9IG5leHRJdGVtLnRyYW5zaXRpb24oXCJ5XCIpID8gbmV4dEl0ZW0udHJhbnNpdGlvbihcInlcIikudGFyZ2V0VmFsdWUgOiBuZXh0SXRlbS55O1xuICAgICAgICAgICAgdGhpcy5fc3dhcEl0ZW1BcnJheVBvcyh0aGlzLml0ZW1zLCBpbmRleCwgcHJldmlvdXNJbmRleCk7XG4gICAgICAgICAgICBfYXN5bmNUb0dlbmVyYXRvcigoZnVuY3Rpb24qKCkge1xuICAgICAgICAgICAgICAgIHlpZWxkIGN1cnJlbnRJdGVtLnNldFNtb290aChcInhcIiwgbmV3UG9zWCk7XG4gICAgICAgICAgICAgICAgeWllbGQgY3VycmVudEl0ZW0uc2V0U21vb3RoKFwieVwiLCBuZXdQb3NZKTtcbiAgICAgICAgICAgICAgICB5aWVsZCBuZXh0SXRlbS5zZXRTbW9vdGgoXCJ4XCIsIG9sZFBvc1gpO1xuICAgICAgICAgICAgICAgIHlpZWxkIG5leHRJdGVtLnNldFNtb290aChcInlcIiwgb2xkUG9zWSk7XG4gICAgICAgICAgICAgICAgaWYgKCFfdGhpczEwLkl0ZW1zLmNoaWxkcmVuLmxlbmd0aCB8fCAhX3RoaXMxMC5JdGVtcy5jaGlsZHJlbltpbmRleF0gfHwgIV90aGlzMTAuSXRlbXMuY2hpbGRyZW5baW5kZXhdLnNraXBGb2N1cykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoX3RoaXMxMC5zZWxlY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMxMC5fc2VsZWN0ZWRJbmRleCA9IGluZGV4O1xuICAgICAgICAgICAgICAgICAgICAg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xuICAgICAgICB5MCA9IGhlaWdodCAvIDIgKyBhO1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSAzOlxuICAgICAgICB4MCA9IHdpZHRoIC8gMiArIGE7XG4gICAgICAgIHkwID0gaGVpZ2h0O1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA0OlxuICAgICAgICB4MCA9IHdpZHRoIC8gMiAtIGE7XG4gICAgICAgIHkwID0gaGVpZ2h0O1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA1OlxuICAgICAgICB5MCA9IGhlaWdodCAvIDIgKyBhO1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA2OlxuICAgICAgICB5MCA9IGhlaWdodCAvIDIgLSBhO1xuICAgICAgICBicmVhaztcblxuICAgICAgY2FzZSA3OlxuICAgICAgICB4MCA9IHdpZHRoIC8gMiAtIGE7XG4gICAgICAgIGJyZWFrO1xuICAgIH1cbiAgICBpZiAoeDAgPT0gMCkge1xuICAgICAgICB4MSA9IHdpZHRoO1xuICAgICAgICB5MSA9IGhlaWdodCAtIHkwO1xuICAgIH1cbiAgICBpZiAoeTAgPT0gMCkge1xuICAgICAgICB5MSA9IGhlaWdodDtcbiAgICAgICAgeDEgPSB3aWR0aCAtIHgwO1xuICAgIH1cbiAgICBpZiAoeDAgPT0gd2lkdGgpIHtcbiAgICAgICAgeDEgPSAwO1xuICAgICAgICB5MSA9IGhlaWdodCAtIHkwO1xuICAgIH1cbiAgICBpZiAoeTAgPT0gaGVpZ2h0KSB7XG4gICAgICAgIHkxID0gMDtcbiAgICAgICAgeDEgPSB3aWR0aCAtIHgwO1xuICAgIH1cbiAgICByZXR1cm4ge1xuICAgICAgICB4MDogeDAsXG4gICAgICAgIHkwOiB5MCxcbiAgICAgICAgeDE6IHgxLFxuICAgICAgICB5MTogeTFcbiAgICB9O1xufTtcblxuY2xhc3MgTGluZWFyR3JhZGllbnQgZXh0ZW5kcyBsbmcuVGV4dHVyZSB7XG4gICAgY29uc3Ryd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BdKTtcbiAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHN0cm9rZVdpZHRoO1xuICAgICAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IGdyYWRpZW50O1xuICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IGdyYWRpZW50O1xuICAgICAgICAgICAgICAgIGN0eC5maWxsUmVjdCgwLCAwLCB3LCBoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgICAgICBzb3VyY2U6IGNhbnZhcyxcbiAgICAgICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgICAgIGg6IGhcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgQ2lyY2xlIGV4dGVuZHMgbG5nLlRleHR1cmUge1xuICAgIGNvbnN0cnVjdG9yKHN0YWdlKSB7XG4gICAgICAgIHN1cGVyKHN0YWdlKTtcbiAgICAgICAgdGhpcy5fY29sb3IgPSBcInJnYigwLDAsMClcIjtcbiAgICAgICAgdGhpcy5fZmlsbCA9IHRydWU7XG4gICAgICAgIHRoaXMuX3JhZGl1cyA9IDEwMDtcbiAgICAgICAgdGhpcy5fc3Ryb2tlID0gZmFsc2U7XG4gICAgICAgIHRoaXMuX3N0cm9rZUNvbG9yID0gXCJyZ2IoMCwwLDApXCI7XG4gICAgICAgIHRoaXMuX3N0cm9rZVdpZHRoID0gMTtcbiAgICB9XG4gICAgZ2V0IGZpbGwoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9maWxsO1xuICAgIH1cbiAgICBzZXQgZmlsbChmaWxsKSB7XG4gICAgICAgIHRoaXMuX2ZpbGwgPSBmaWxsO1xuICAgICAgICB0aGlzLl9jaGFuZ2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nNpb24sIGRpbWVuc2lvbiwgcmFkaXVzLCAwLCAyICogTWF0aC5QSSk7XG4gICAgICAgICAgICBpZiAoZmlsbCkge1xuICAgICAgICAgICAgICAgIGN0eC5maWxsKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc3Ryb2tlKSB7XG4gICAgICAgICAgICAgICAgY3R4LnN0cm9rZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2IobnVsbCwge1xuICAgICAgICAgICAgICAgIHNvdXJjZTogY2FudmFzLFxuICAgICAgICAgICAgICAgIHJhZGl1czogcmFkaXVzXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfTtcbiAgICB9XG59XG5cbmNsYXNzIEFycm93IGV4dGVuZHMgbG5nLlRleHR1cmUge1xuICAgIGNvbnN0cnVjdG9yKHN0YWdlKSB7XG4gICAgICAgIHN1cGVyKHN0YWdlKTtcbiAgICAgICAgdGhpcy5fY29sb3IgPSBcInJnYigxMywgMTMsIDE1KVwiO1xuICAgICAgICB0aGlzLl93ID0gMDtcbiAgICAgICAgdGhpcy5faCA9IDA7XG4gICAgICAgIHRoaXMuX2RpcmVjdGlvbiA9IFwicmlnaHRcIjtcbiAgICB9XG4gICAgZ2V0IHcoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl93O1xuICAgIH1cbiAgICBzZXQgdyhsKSB7XG4gICAgICAgIHRoaXMuX3cgPSBsO1xuICAgICAgICB0aGlzLl9jaGFuZ2VkKCk7XG4gICAgfVxuICAgIGdldCBoKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5faDtcbiAgICB9XG4gICAgc2V0IGgobCkge1xuICAgICAgICB0aGlzLl9oID0gbDtcbiAgICAgICAgdGhpcy5fY2hhbmdlZCgpO1xuICAgIH1cbiAgICBnZXQgZGlyZWN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZGlyZWN0aW9uO1xuICAgIH1cbiAgICBnZXQgY29sb3IoKSB7XG4gICAgICAgIHJldH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mxpbmVDYXAgPSBcInJvdW5kXCI7XG4gICAgICAgICAgICBjdHgubGluZUpvaW4gPSBcInJvdW5kXCI7XG4gICAgICAgICAgICB2YXIgcCA9IGN0eC5saW5lV2lkdGggLyAyO1xuICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgaWYgKGRpcmVjdGlvbiA9PT0gXCJyaWdodFwiKSB7XG4gICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyhwLCBwKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVRvKHAsIGggLSBwKTtcbiAgICAgICAgICAgICAgICBjdHgubGluZVRvKHcgLSBwLCBoIC8gMik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGRpcmVjdGlvbiA9PT0gXCJkb3duXCIpIHtcbiAgICAgICAgICAgICAgICBjdHgubW92ZVRvKHAsIHApO1xuICAgICAgICAgICAgICAgIGN0eC5saW5lVG8odyAtIHAsIHApO1xuICAgICAgICAgICAgICAgIGN0eC5saW5lVG8odyAvIDIsIGggLSBwKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyhwLCBoIC8gMik7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh3IC0gcCwgcCk7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh3IC0gcCwgaCAtIHApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpO1xuICAgICAgICAgICAgY3R4LnN0cm9rZSgpO1xuICAgICAgICAgICAgY3R4LmZpbGwoKTtcbiAgICAgICAgICAgIGNiKG51bGwsIHtcbiAgICAgICAgICAgICAgICBzb3VyY2U6IGNhbnZhcyxcbiAgICAgICAgICAgICAgICB3OiB3LFxuICAgICAgICAgICAgICAgIGg6IGgsXG4gICAgICAgICAgICAgICAgZGlyZWN0aW9uOiBkaXJlY3Rpb25cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9O1xuIC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udmFzID0gdGhpcy5zdGFnZS5wbGF0Zm9ybS5nZXREcmF3aW5nQ2FudmFzKCk7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbihjYikge1xuICAgICAgICAgICAgdmFyIGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KFwiMmRcIik7XG4gICAgICAgICAgICBjYW52YXMud2lkdGggPSB3O1xuICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IGg7XG4gICAgICAgICAgICBjdHgubGluZVdpZHRoID0gaDtcbiAgICAgICAgICAgIGlmIChyb3VuZGVkKSB7XG4gICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSBcInJvdW5kXCI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBcIndoaXRlXCI7XG4gICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7XG4gICAgICAgICAgICBjdHgubW92ZVRvKHJvdW5kZWQgPyAyIDogMCwgaCAvIDIpO1xuICAgICAgICAgICAgY3R4LmxpbmVUbyhyb3VuZGVkID8gdyAtIDIgOiB3LCBoIC8gMik7XG4gICAgICAgICAgICBjdHguc3Ryb2tlKCk7XG4gICAgICAgICAgICBjYihudWxsLCB7XG4gICAgICAgICAgICAgICAgc291cmNlOiBjYW52YXMsXG4gICAgICAgICAgICAgICAgdzogdyxcbiAgICAgICAgICAgICAgICBoOiBoLFxuICAgICAgICAgICAgICAgIHJvdW5kZWQ6IHJvdW5kZWRcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9O1xuICAgIH1cbn1cblxuY2xhc3MgU2lnbmFsQnV0dG9uIGV4dGVuZHMgQnV0dG9uIHtcbiAgICBvbkVudGVyKCkge1xuICAgICAgICB0aGlzLnNpZ25hbCh0aGlzLnNpZ25hbE5hbWUpO1xuICAgIH1cbiAgICBzZXQgc2lnbmFsTmFtZShzaWduYWxOYW1lKSB7XG4gICAgICAgIHRoaXMuX3NpZ25hbE5hbWUgPSBzaWduYWxOYW1lO1xu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oge1xuICAgICAgICAgIHc6IHcgPT4gdyxcbiAgICAgICAgICB5OiAyNCxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiAnJyxcbiAgICAgICAgICAgIHRleHRDb2xvcjogMHhmZjMzMzMzMyxcbiAgICAgICAgICAgIGZvbnRTaXplOiA4MCxcbiAgICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgICAgICB2ZXJ0aWNhbEFsaWduOiAnbWlkZGxlJyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgfVxuICAgIH1cblxuICAgIHNldCBpbmRleCh2KSB7XG4gICAgICB0aGlzLnggPSB2ICogKDEyMCArIDI0KVxuICAgIH1cblxuICAgIHNldCBucih2KSB7XG4gICAgICB0aGlzLl90aW1lb3V0ICYmIGNsZWFyVGltZW91dCh0aGlzLl90aW1lb3V0KVxuXG4gICAgICBpZiAodikge1xuICAgICAgICB0aGlzLnNldFNtb290aCgnYWxwaGEnLCAxKVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhpcy5zZXRTbW9vdGgoJ2FscGhhJywgMC41KVxuICAgICAgfVxuXG4gICAgICB0aGlzLnRhZygnTnInKS5wYXRjaCh7XG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICB0ZXh0OiAodiAmJiB2LnRvU3RyaW5nKCkpIHx8ICcnLFxuICAgICAgICAgIGZvbnRTaXplOiB2ID09PSAnKicgPyAxMjAgOiA4MCxcbiAgICAgICAgfSxcbiAgICAgIH0pXG5cbiAgICAgIGlmICh2ICYmIHYgIT09ICcqJykge1xuICAgICAgICB0aGlzLl90aW1lb3V0ID0gc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgICAgdGhpcy5fdGltZW91dCA9IG51bGxcbiAgICAgICAgICB0aGlzLm5yID0gJyonXG4gICAgICAgIH0sIDc1MClcbiAgICAgIH1cbiAgICB9XG4gIH1cblxufVxuXG5leHBvcnQgZGVmYXVsdCAoKSA9PiB7XG4gIHJldHVybiBjbGFzcyBQaW5EaWFsb2cgZXh0ZW5kcyBMaWdodG5pbmcuQ29tcG9uZW50IHtcbiAgICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgekluZGV4OiAxLFxuICAgICAgICB3OiB3ID0+IHcsXG4gICAgICAgIGg6IGggPT4gaCxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgY29sb3I6IDB4ZGQwMDAwMDAsXG4gICAgICAgIGFscGhhOiAwLjAwMDAwMSxcbiAgICAgICAgRGlhbG9nOiB7XG4gICAgICAgICAgdzogNjQ4LFxuICAgICAgICAgIGg6IDMyMCxcbiAgICAgICAgICB5OiBoID0+IChoIC0gMzIwKSAvIDIsXG4gICAgICAgICAgeDogdyA9PiAodyAtIDY0OCkgLyAyLFxuICAgICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgICAgY29sb3I6IDB4ZGQzMzMzMzMsXG4gICAgICAgICAgc2hhZGVyOiB7IHR5cGU6IExpZ2h0bmluZy5zaGFkZXJzLlJvdW5kZWRSZWN0YW5nbGUsIHJhZGl1czogMTAgfSxcbiAgICAgICAgICBJbmZvOiB7XG4gICAgICAgICAgICB5OiAyNCxcbiAgICAgICAgICAgIHg6IDQ4LFxuICAgICAgICAgICAgdGV4dDogeyB0ZXh0OiAnUGxlYXNlIGVudGVyIHlvdXIgUElOJywgZm9udFNpemU6IDMyIH0sXG4gICAgICAgICAgfSxcbiAgICAgICAgICBNc2c6IHtcbiAgICAgICAgICAgIHk6IDI2MCxcbiAgICAgICAgICAgIHg6IDQ4LFxuICAgICAgICAgICAgdGV4dDogeyB0ZXh0OiAnJywgZm9udFNpemU6IDI4LCB0ZXh0Q29sb3I6IDB4ZmZmZmZmZmYgfSxcbiAgICAgICAgICB9LFxuICAgICAgICAgIENvZGU6IHtcbiAgICAgICAgICAgIHg6IDQ4LFxuICAgICAgICAgICAgeTogOTYsXG4gICAgICA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SB7XG4gICAgICAgIGlmICh0aGlzLnBpbi5sZW5ndGgpIHtcbiAgICAgICAgICB0aGlzLnBpbiA9IHRoaXMucGluLnNsaWNlKDAsIHRoaXMucGluLmxlbmd0aCAtIDEpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgUGluLmhpZGUoKVxuICAgICAgICAgIHRoaXMucmVzb2x2ZShmYWxzZSlcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cblxuICAgIF9oYW5kbGVFbnRlcigpIHtcbiAgICAgIGlmICh0aGlzLm1zZykge1xuICAgICAgICB0aGlzLm1zZyA9IGZhbHNlXG4gICAgICB9IGVsc2Uge1xuICAgICAgICBQaW4uc3VibWl0KHRoaXMucGluKVxuICAgICAgICAgIC50aGVuKHZhbCA9PiB7XG4gICAgICAgICAgICB0aGlzLm1zZyA9ICdVbmxvY2tpbmcgLi4uJ1xuICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgICAgICAgIFBpbi5oaWRlKClcbiAgICAgICAgICAgIH0sIDEwMDApXG4gICAgICAgICAgICB0aGlzLnJlc29sdmUodmFsKVxuICAgICAgICAgIH0pXG4gICAgICAgICAgLmNhdGNoKGUgPT4ge1xuICAgICAgICAgICAgdGhpcy5tc2cgPSBlXG4gICAgICAgICAgICB0aGlzLnJlamVjdChlKVxuICAgICAgICAgIH0pXG4gICAgICB9XG4gICAgfVxuICB9XG59XG4iLCIvKlxuICogSWYgbm90IHN0YXRlZCBvdGhlcndpc2UgaW4gdGhpcyBmaWxlIG9yIHRoaXMgY29tcG9uZW50J3MgTElDRU5TRSBmaWxlIHRoZVxuICogZm9sbG93aW5nIGNvcHlyaWdodCBhbmQgbGljZW5zZXMgYXBwbHk6XG4gKlxuICogQ29weXJpZ2h0IDIwMjAgTWV0cm9sb2dpY2FsXG4gKlxuICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlIExpY2Vuc2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ZWQnKVxuICAgICAgICB9XG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIHJlamVjdChlKVxuICAgICAgfVxuICAgIH0pXG4gIH0sXG4gIHVubG9ja2VkKGNvbnRleHQpIHtcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgdHJ5IHtcbiAgICAgICAgY29udGV4dCA9IGNvbnRleHRDaGVjayhjb250ZXh0KVxuICAgICAgICBpZiAoY29udGV4dCkge1xuICAgICAgICAgIGNoZWNrKGNvbnRleHQpXG4gICAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZWplY3QoJ0luY29ycmVjdCBDb250ZXh0IHByb3ZpZGVkJylcbiAgICAgICAgfVxuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICByZWplY3QoZSlcbiAgICAgIH1cbiAgICB9KVxuICB9LFxuICBsb2NrZWQoY29udGV4dCkge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgICB0cnkge1xuICAgICAgICBjb250ZXh0ID0gY29udGV4dENoZWNrKGNvbnRleHQpXG4gICAgICAgIGlmIChjb250ZXh0KSB7XG4gICAgICAgICAgY2hlY2soY29udGV4dClcbiAgICAgICAgICAgIC50aGVuKHVubG9ja2VkID0+IHJlc29sdmUoISEhdW5sb2NrZWQpKVxuICAgICAgICAgICAgLmNhdGNoKHJlamVjdClcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZWplY3QoJ0luY29ycmVjdCBDb250ZXh0IHByb3ZpZGVkJylcbiAgICAgICAgfVxuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICByZWplY3QoZSlcbiAgICAgIH1cbiAgICB9KVxuICB9LFxufVxuIiwiLypcbiAqIElmIG5vdCBzdGF0ZWQgb3RoZX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tcbiAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICBjb25zdCBlbmRwb2ludCA9IGNzcEVuZHBvaW50c1t0eXBlXVxuXG4gICAgaWYgKCFlbmRwb2ludCkge1xuICAgICAgcmVqZWN0KCdObyBlbmRwb2ludCBmb3VuZCBmb3IgXCInICsgdHlwZSArICdcIiBjYWxsJylcbiAgICB9IGVsc2Uge1xuICAgICAgaWYgKGVuZHBvaW50LmNhbGxiYWNrICYmIHR5cGVvZiBlbmRwb2ludC5jYWxsYmFjayA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICBlbmRwb2ludFxuICAgICAgICAgIC5jYWxsYmFjayhkYXRhLCBwYXJhbXMpXG4gICAgICAgICAgLnRoZW4ocmVzb2x2ZSlcbiAgICAgICAgICAuY2F0Y2gocmVqZWN0KVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmVxdWVzdChcbiAgICAgICAgICBjcmVhdGVVcmwoZW5kcG9pbnQudXJpLCBjc3BVcmwsIHBhcmFtcyksXG4gICAgICAgICAgZW5kcG9pbnQubWV0aG9kLFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIC4uLihlbmRwb2ludC5kYXRhIHx8IHt9KSxcbiAgICAgICAgICAgIC4uLmRhdGEsXG4gICAgICAgICAgfSxcbiAgICAgICAgICBlbmRwb2ludC5oZWFkZXJzIHx8IHt9XG4gICAgICAgIClcbiAgICAgICAgICAudGhlbihyZXNvbHZlKVxuICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICB9XG4gICAgfVxuICB9KVxufVxuXG5jb25zdCBiaWxsaW5nUmVxdWVzdCA9ICh1cmksIGRhdGEsIG1ldGhvZCA9ICdQT1NUJykgPT4ge1xuICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgIHJlcXVlc3QoY3JlYXRlVXJsKHVyaSwgYmlsbGluZ1VybCksIG1ldGhvZCwgZ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BdKVxuICAgICAgICAudGhlbigoW2hvdXNlaG9sZCwgY291bnRyeSwgb3BlcmF0b3IsIG1hYywgdWlkXSkgPT4ge1xuICAgICAgICAgIGJpbGxpbmdSZXF1ZXN0KCcvJywge1xuICAgICAgICAgICAgcHVyY2hhc2U6IHNpZ25hdHVyZSxcbiAgICAgICAgICAgIGlkZW50aWZpZXI6IFNldHRpbmdzLmdldCgnYXBwJywgJ2lkJyksXG4gICAgICAgICAgICBuYW1lOiBTZXR0aW5ncy5nZXQoJ2FwcCcsICdpZCcpLFxuICAgICAgICAgICAgaG91c2Vob2xkLFxuICAgICAgICAgICAgY291bnRyeSxcbiAgICAgICAgICAgIG9wZXJhdG9yLFxuICAgICAgICAgICAgbWFjLFxuICAgICAgICAgICAgdWlkLFxuICAgICAgICAgICAgdHlwZSxcbiAgICAgICAgICB9KVxuICAgICAgICAgICAgLnRoZW4ocmVzb2x2ZSlcbiAgICAgICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgICAgIH0pXG4gICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgfSlcbiAgfSxcbiAgY29uZmlybSh0cmFuc2FjdGlvbklkKSB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIGJpbGxpbmdSZXF1ZXN0KCcvY29uZmlybScsIHtcbiAgICAgICAgdHJhbnNhY3Rpb25JZCxcbiAgICAgIH0pXG4gICAgICAgIC50aGVuKHJlc29sdmUpXG4gICAgICAgIC5jYXRjaChyZWplY3QpXG4gICAgfSlcbiAgfSxcbiAgYnV5KGFzc2V0SWQsIHR5cGUpIHtcbiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgbGV0IHRyYW5zYWN0aW9uSWRcbiAgICAgIHNlcXVlbmNlKFtcbiAgICAgICAgKCkgPT4gdGhpcy5zaWduYXR1cmUoYXNzZXRJZCksXG4gICAgICAgIHNpZ25h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tZUNvdW50ID0gZ2V0VmlkZW9QbGF5YmFja1F1YWxpdHlcbiAgICAgICAgICAgICAgPyBnZXRWaWRlb1BsYXliYWNrUXVhbGl0eS50b3RhbFZpZGVvRnJhbWVzXG4gICAgICAgICAgICAgIDogdGhpcy52aWRlb0VsLndlYmtpdERlY29kZWRGcmFtZUNvdW50XG5cbiAgICAgICAgICAgIGNvbnN0IG11c3RVcGRhdGUgPSBmcmFtZUNvdW50XG4gICAgICAgICAgICAgID8gdGhpcy5fbGFzdEZyYW1lICE9PSBmcmFtZUNvdW50XG4gICAgICAgICAgICAgIDogdGhpcy5fbGFzdFRpbWUgPCBjdXJyZW50VGltZSAtIDMwXG5cbiAgICAgICAgICAgIGlmIChtdXN0VXBkYXRlKSB7XG4gICAgICAgICAgICAgIHRoaXMuX2xhc3RUaW1lID0gY3VycmVudFRpbWVcbiAgICAgICAgICAgICAgdGhpcy5fbGFzdEZyYW1lID0gZnJhbWVDb3VudFxuICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGdsLmJpbmRUZXh0dXJlKGdsLlRFWFRVUkVfMkQsIHRoaXMudmlkZW9UZXh0dXJlLm9wdGlvbnMuc291cmNlKVxuICAgICAgICAgICAgICAgIGdsLnBpeGVsU3RvcmVpKGdsLlVOUEFDS19QUkVNVUxUSVBMWV9BTFBIQV9XRUJHTCwgZmFsc2UpXG4gICAgICAgICAgICAgICAgZ2wudGV4SW1hZ2UyRChnbC5URVhUVVJFXzJELCAwLCBnbC5SR0JBLCBnbC5SR0JBLCBnbC5VTlNJR05FRF9CWVRFLCB0aGlzLnZpZGVvRWwpXG4gICAgICAgICAgICAgICAgdGhpcy5fbGFzdEZyYW1lID0gdGhpcy52aWRlb0VsLndlYmtpdERlY29kZWRGcmFtZUNvdW50XG4gICAgICAgICAgICAgICAgdGhpcy52aWRlb1ZpZXcudmlzaWJsZSA9IHRydWVcblxuICAgICAgICAgICAgICAgIHRoaXMudmlkZW9UZXh0dXJlLm9wdGlvbnMudyA9IHRoaXMudmlkZW9FbC53aWR0aFxuICAgICAgICAgICAgICAgIHRoaXMudmlkZW9UZXh0dXJlLm9wdGlvbnMuaCA9IHRoaXMudmlkZW9FbC5oZWlnaHRcbiAgICAgICAgICAgICAgICBjb25zdCBleHBlY3RlZEFzcGVjdFJhdGlvID0gdGhpcy52aWRlb1ZpZXcudyAvIHRoaXMudmlkZW9WaWV3LmhcbiAgICAgICAgICAgICAgICBjb25zdCByZWFsQXNwZWN0UmF0aW8gPSB0aGlzLnZpZGVvRWwud2lkdGggLyB0aGlzLnZpZGVvRWwuaGVpZ2h0XG5cbiAgICAgICAgICAgICAgICBpZiAoZXhwZWN0ZWRBc3BlY3RSYXRpbyA+IHJlYWxBc3BlY3RSYXRpbykge1xuICAgICAgICAgICAgICAgICAgdGhpcy52aWRlb1ZpZXcuc2NhbGVYID0gcmVhbEFzcGVjdFJhdGlvIC8gZXhwZWN0ZWRBc3BlY3RSYXRpb1xuICAgICAgICAgICAgICAgICAgdGhpcy52aWRlb1ZpZXcuc2NhbGVZID0gMVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICB0aGlzLnZpZGVvVmlldy5zY2FsZVkgPSBleHBlY3RlZEFzcGVjdFJhdGlvIC8gcmVhbEFzcGVjdFJhdGlvXG4gICAgICAgICAgICAgICAgICB0aGlzLnZpZGVvVmlldy5zY2FsZVggPSAxXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgTG9nLmVycm9yKCd0ZXhJbWFnZTJkIHZpZGVvJywgZSlcbiAgICAgICAgICAgICAgICB0aGlzLnN0b3AoKVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHRoaXMudmlkZW9UZXh0dXJlLnNvdXJjZS5mb3JjZVJlbmRlclVwZGF0ZSgpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gIC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0gbGVmdCwgYm90dG9tIC0gdG9wKVxuICB9LFxuXG4gIG9wZW4odXJsLCBjb25maWcgPSB7fSkge1xuICAgIGlmICghdGhpcy5jYW5JbnRlcmFjdCkgcmV0dXJuXG4gICAgbWV0cmljcyA9IE1ldHJpY3MubWVkaWEodXJsKVxuXG4gICAgdGhpcy5oaWRlKClcbiAgICBkZXJlZ2lzdGVyRXZlbnRMaXN0ZW5lcnMoKVxuXG4gICAgaWYgKHRoaXMuc3JjID09IHVybCkge1xuICAgICAgdGhpcy5jbGVhcigpLnRoZW4odGhpcy5vcGVuKHVybCwgY29uZmlnKSlcbiAgICB9IGVsc2Uge1xuICAgICAgY29uc3QgYWRDb25maWcgPSB7IGVuYWJsZWQ6IHN0YXRlLmFkc0VuYWJsZWQsIGR1cmF0aW9uOiAzMDAgfVxuICAgICAgaWYgKGNvbmZpZy52aWRlb0lkKSB7XG4gICAgICAgIGFkQ29uZmlnLmNhaWQgPSBjb25maWcudmlkZW9JZFxuICAgICAgfVxuICAgICAgQWRzLmdldChhZENvbmZpZywgY29uc3VtZXIpLnRoZW4oYWRzID0+IHtcbiAgICAgICAgc3RhdGUucGxheWluZ0FkcyA9IHRydWVcbiAgICAgICAgYWRzLnByZXJvbGxzKCkudGhlbigoKSA9PiB7XG4gICAgICAgICAgc3RhdGUucGxheWluZ0FkcyA9IGZhbHNlXG4gICAgICAgICAgbG9hZGVyKHVybCwgdmlkZW9FbCwgY29uZmlnKVxuICAgICAgICAgICAgLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICByZWdpc3RlckV2ZW50TGlzdGVuZXJzKClcbiAgICAgICAgICAgICAgdGhpcy5zaG93KClcbiAgICAgICAgICAgICAgdGhpcy5wbGF5KClcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuY2F0Y2goZSA9PiB7XG4gICAgICAgICAgICAgIGZpcmVPbkNvbnN1bWVyKCdFcnJvcicsIHsgdmlkZW9FbGVtZW50OiB2aWRlb0VsLCBldmVudDogZ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IH1cblxuICAgICAgICAgIGlmICh0aGlzLnN0cm0uaW5wdXRbbmV4dF9leHBlY3RlZF9oZWFkZXJfYnl0ZV0gPT09IEdaSVBfSEVBREVSX0lEMSkge1xuICAgICAgICAgICAgdGhpcy5nemlwX2lkX2J5dGVzX3JlYWQgPSAxO1xuICAgICAgICAgICAgbmV4dF9leHBlY3RlZF9oZWFkZXJfYnl0ZSsrO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5zdHJtLmF2YWlsX2luID09PSAxKSB7XG4gICAgICAgICAgICAgIC8vIFRoZSBvbmx5IGF2YWlsYWJsZSBieXRlIHdhcyBhbHJlYWR5IHJlYWQuXG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLm1vZGUgPSBleHBvcnRzLklORkxBVEU7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG5cbiAgICAgICAgLy8gZmFsbHRocm91Z2hcbiAgICAgICAgY2FzZSAxOlxuICAgICAgICAgIGlmIChuZXh0X2V4cGVjdGVkX2hlYWRlcl9ieXRlID09PSBudWxsKSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAodGhpcy5zdHJtLmlucHV0W25leHRfZXhwZWN0ZWRfaGVhZGVyX2J5dGVdID09PSBHWklQX0hFQURFUl9JRDIpIHtcbiAgICAgICAgICAgIHRoaXMuZ3ppcF9pZF9ieXRlc19yZWFkID0gMjtcbiAgICAgICAgICAgIHRoaXMubW9kZSA9IGV4cG9ydHMuR1VOWklQO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBUaGVyZSBpcyBubyBhY3R1YWwgZGlmZmVyZW5jZSBiZXR3ZWVuIElORkxBVEUgYW5kIElORkxBVEVSQVdcbiAgICAgICAgICAgIC8vIChhZnRlciBpbml0aWFsaXphdGlvbikuXG4gICAgICAgICAgICB0aGlz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GF0YS5nZXQoZXZlbnQpO1xuICAgIGNvbnNvbGUuYXNzZXJ0KFxuICAgICAgICByZXR2ICE9IG51bGwsXG4gICAgICAgIFwiJ3RoaXMnIGlzIGV4cGVjdGVkIGFuIEV2ZW50IG9iamVjdCwgYnV0IGdvdFwiLFxuICAgICAgICBldmVudFxuICAgICk7XG4gICAgcmV0dXJuIHJldHZcbn1cblxuLyoqXG4gKiBodHRwczovL2RvbS5zcGVjLndoYXR3Zy5vcmcvI3NldC10aGUtY2FuY2VsZWQtZmxhZ1xuICogQHBhcmFtIGRhdGEge1ByaXZhdGVEYXRhfSBwcml2YXRlIGRhdGEuXG4gKi9cbmZ1bmN0aW9uIHNldENhbmNlbEZsYWcoZGF0YSkge1xuICAgIGlmIChkYXRhLnBhc3NpdmVMaXN0ZW5lciAhPSBudWxsKSB7XG4gICAgICAgIGlmIChcbiAgICAgICAgICAgIHR5cGVvZiBjb25zb2xlICE9PSBcInVuZGVmaW5lZFwiICYmXG4gICAgICAgICAgICB0eXBlb2YgY29uc29sZS5lcnJvciA9PT0gXCJmdW5jdGlvblwiXG4gICAgICAgICkge1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcihcbiAgICAgICAgICAgICAgICBcIlVuYWJsZSB0byBwcmV2ZW50RGVmYXVsdCBpbnNpZGUgcGFzc2l2ZSBldmVudCBsaXN0ZW5lciBpbnZvY2F0aW9uLlwiLFxuICAgICAgICAgICAgICAgIGRhdGEucGFzc2l2ZUxpc3RlbmVyXG4gICAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICAgIHJldHVyblxuICAgIH1cbiAgICBpZiAoIWRhdGEuZXZlbnQuY2FuY2VsYWJsZSkge1xuICAgICAgICByZXR1cm5cbiAgICB9XG5cbiAgICBkYXRhLmNhbmNlbGVkID0gdHJ1ZTtcbiAgICBpZiAodHlwZW9mIGRhdGEuZXZlbnQucHJldmVudERlZmF1bHQgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICBkYXRhLmV2ZW50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V2ZW50LlxuICAgICAqL1xuICAgIGNvbXBvc2VkUGF0aCgpIHtcbiAgICAgICAgY29uc3QgY3VycmVudFRhcmdldCA9IHBkKHRoaXMpLmN1cnJlbnRUYXJnZXQ7XG4gICAgICAgIGlmIChjdXJyZW50VGFyZ2V0ID09IG51bGwpIHtcbiAgICAgICAgICAgIHJldHVybiBbXVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBbY3VycmVudFRhcmdldF1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQ29uc3RhbnQgb2YgTk9ORS5cbiAgICAgKiBAdHlwZSB7bnVtYmVyfVxuICAgICAqL1xuICAgIGdldCBOT05FKCkge1xuICAgICAgICByZXR1cm4gMFxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBDb25zdGFudCBvZiBDQVBUVVJJTkdfUEhBU0UuXG4gICAgICogQHR5cGUge251bWJlcn1cbiAgICAgKi9cbiAgICBnZXQgQ0FQVFVSSU5HX1BIQVNFKCkge1xuICAgICAgICByZXR1cm4gMVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBDb25zdGFudCBvZiBBVF9UQVJHRVQuXG4gICAgICogQHR5cGUge251bWJlcn1cbiAgICAgKi9cbiAgICBnZXQgQVRfVEFSR0VUKCkge1xuICAgICAgICByZXR1cm4gMlxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBDb25zdGFudCBvZiBCVUJCTElOR19QSEFTRS5cbiAgICAgKiBAdHlwZSB7bnVtYmVyfVxuICAgICAqL1xuICAgIGdldCBCVUJCTElOR19QSEFTRSgpIHtcbiAgICAgICAgcmV0dXJuIDNcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogVGhlIHRhcmdldCBvZiB0aGlzIGV2ZW50LlxuICAgICAqIEB0eXBlIHtudW1iZXJ9XG4gICAgICovXG4gICAgZ2V0IGV2ZW50UGhhc2UoKSB7XG4gICAgICAgIHJldHVybiBwZCh0aGlzKS5ldmVudFBoYXNlXG4gICAgfSxcbl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CBzcmNFbGVtZW50KCkge1xuICAgICAgICByZXR1cm4gcGQodGhpcykuZXZlbnRUYXJnZXRcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogVGhlIGZsYWcgdG8gc3RvcCBldmVudCBidWJibGluZy5cbiAgICAgKiBAdHlwZSB7Ym9vbGVhbn1cbiAgICAgKiBAZGVwcmVjYXRlZFxuICAgICAqL1xuICAgIGdldCBjYW5jZWxCdWJibGUoKSB7XG4gICAgICAgIHJldHVybiBwZCh0aGlzKS5zdG9wcGVkXG4gICAgfSxcbiAgICBzZXQgY2FuY2VsQnViYmxlKHZhbHVlKSB7XG4gICAgICAgIGlmICghdmFsdWUpIHtcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGRhdGEgPSBwZCh0aGlzKTtcblxuICAgICAgICBkYXRhLnN0b3BwZWQgPSB0cnVlO1xuICAgICAgICBpZiAodHlwZW9mIGRhdGEuZXZlbnQuY2FuY2VsQnViYmxlID09PSBcImJvb2xlYW5cIikge1xuICAgICAgICAgICAgZGF0YS5ldmVudC5jYW5jZWxCdWJibGUgPSB0cnVlO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIFRoZSBmbGFnIHRvIGluZGljYXRlIGNhbmNlbGxhdGlvbiBzdGF0ZS5cbiAgICAgKiBAdHlwZSB7Ym9vbGVhbn1cbiAgICAgKiBAZGVwcmVjYXRlZFxuICAgICAqL1xuICAgIGdldCByZXR1cm5WYWx1ZSgpIHtcbiAgICAgICAgcmV0dXJuICFwZCh0aGlzKS5jYW5jZWxlZFxuICAgIH0sXG4gICAgc2V0IHJldHVyblZhbHVlKHZhbHVlKSB7XG4gICAgICAgIGlmICghdmFsdWUpIHtcbiAgICAgICAgICAgIHNldENhbmNlbEZsYWcocGQodGhpcykpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEluaXRpYWxpemUgdGhpcyBldmVudCBvYmplY3QuIEJ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L1xuZnVuY3Rpb24gZGVmaW5lRXZlbnRBdHRyaWJ1dGVEZXNjcmlwdG9yKGV2ZW50TmFtZSkge1xuICAgIHJldHVybiB7XG4gICAgICAgIGdldCgpIHtcbiAgICAgICAgICAgIGNvbnN0IGxpc3RlbmVycyA9IGdldExpc3RlbmVycyh0aGlzKTtcbiAgICAgICAgICAgIGxldCBub2RlID0gbGlzdGVuZXJzLmdldChldmVudE5hbWUpO1xuICAgICAgICAgICAgd2hpbGUgKG5vZGUgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIGlmIChub2RlLmxpc3RlbmVyVHlwZSA9PT0gQVRUUklCVVRFKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBub2RlLmxpc3RlbmVyXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG5vZGUgPSBub2RlLm5leHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gbnVsbFxuICAgICAgICB9LFxuXG4gICAgICAgIHNldChsaXN0ZW5lcikge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBsaXN0ZW5lciAhPT0gXCJmdW5jdGlvblwiICYmICFpc09iamVjdChsaXN0ZW5lcikpIHtcbiAgICAgICAgICAgICAgICBsaXN0ZW5lciA9IG51bGw7IC8vIGVzbGludC1kaXNhYmxlLWxpbmUgbm8tcGFyYW0tcmVhc3NpZ25cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnN0IGxpc3RlbmVycyA9IGdldExpc3RlbmVycyh0aGlzKTtcblxuICAgICAgICAgICAgLy8gVHJhdmVyc2UgdG8gdGhlIHRhaWwgd2hpbGUgcmVtb3Zpbmcgb2xkIHZhbHVlLlxuICAgICAgICAgICAgbGV0IHByZXYgPSBudWxsO1xuICAgICAgICAgICAgbGV0IG5vZGUgPSBsaXN0ZW5lcnMuZ2V0KGV2ZW50TmFtZSk7XG4gICAgICAgICAgICB3aGlsZSAobm9kZSAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgaWYgKG5vZGUubGlzdGVuZXJUeXBlID09PSBBVFRSSUJVVEUpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gUmVtb3ZlIG9sZCB2YWx1ZS5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHByZXYgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByZXYubmV4dCA9IG5vZGUubmV4dDtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlLm5leHQgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVycy5zZXQoZXZlbnROYW1lLCBub2RlLm5leHQpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXJzLmRlbGV0ZShldmVudE5hbWUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcHJldiA9IG5vZGU7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgbm9kZSA9IG5vZGUubmV4dDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gQWRkIG5ldyB2YWx1ZS5cbiAgICAgICAgICAgIGlmIChsaXN0ZW5lciAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIGNvbnN0IG5ld05vZGUgPSB7XG4gICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyLFxuICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lclR5cGU6IEFUVFJJQlVURSxcbiAgICAgICAgICAgICAgICAgICAgcGFzc2l2ZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIG9uY2U6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICBuZXh0OiBudWxsLFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgaWYgKHByZXYgPT09IG51bGwpIHtcbiAgICAgICAgICAg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Y2FwdHVyZSA9IG9wdGlvbnNJc09ialxuICAgICAgICAgICAgPyBCb29sZWFuKG9wdGlvbnMuY2FwdHVyZSlcbiAgICAgICAgICAgIDogQm9vbGVhbihvcHRpb25zKTtcbiAgICAgICAgY29uc3QgbGlzdGVuZXJUeXBlID0gY2FwdHVyZSA/IENBUFRVUkUgOiBCVUJCTEU7XG4gICAgICAgIGNvbnN0IG5ld05vZGUgPSB7XG4gICAgICAgICAgICBsaXN0ZW5lcixcbiAgICAgICAgICAgIGxpc3RlbmVyVHlwZSxcbiAgICAgICAgICAgIHBhc3NpdmU6IG9wdGlvbnNJc09iaiAmJiBCb29sZWFuKG9wdGlvbnMucGFzc2l2ZSksXG4gICAgICAgICAgICBvbmNlOiBvcHRpb25zSXNPYmogJiYgQm9vbGVhbihvcHRpb25zLm9uY2UpLFxuICAgICAgICAgICAgbmV4dDogbnVsbCxcbiAgICAgICAgfTtcblxuICAgICAgICAvLyBTZXQgaXQgYXMgdGhlIGZpcnN0IG5vZGUgaWYgdGhlIGZpcnN0IG5vZGUgaXMgbnVsbC5cbiAgICAgICAgbGV0IG5vZGUgPSBsaXN0ZW5lcnMuZ2V0KGV2ZW50TmFtZSk7XG4gICAgICAgIGlmIChub2RlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIGxpc3RlbmVycy5zZXQoZXZlbnROYW1lLCBuZXdOb2RlKTtcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICB9XG5cbiAgICAgICAgLy8gVHJhdmVyc2UgdG8gdGhlIHRhaWwgd2hpbGUgY2hlY2tpbmcgZHVwbGljYXRpb24uLlxuICAgICAgICBsZXQgcHJldiA9IG51bGw7XG4gICAgICAgIHdoaWxlIChub2RlICE9IG51bGwpIHtcbiAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICBub2RlLmxpc3RlbmVyID09PSBsaXN0ZW5lciAmJlxuICAgICAgICAgICAgICAgIG5vZGUubGlzdGVuZXJUeXBlID09PSBsaXN0ZW5lclR5cGVcbiAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgIC8vIFNob3VsZCBpZ25vcmUgZHVwbGljYXRpb24uXG4gICAgICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwcmV2ID0gbm9kZTtcbiAgICAgICAgICAgIG5vZGUgPSBub2RlLm5leHQ7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBBZGQgaXQuXG4gICAgICAgIHByZXYubmV4dCA9IG5ld05vZGU7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIFJlbW92ZSBhIGdpdmVuIGxpc3RlbmVyIGZyb20gdGhpcyBldmVudCB0YXJnZXQuXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IGV2ZW50TmFtZSBUaGUgZXZlbnQgbmFtZSB0byByZW1vdmUuXG4gICAgICogQHBhcmFtIHtGdW5jdGlvbn0gbGlzdGVuZXIgVGhlIGxpc3RlbmVyIHRvIHJlbW92ZS5cbiAgICAgKiBAcGFyYW0ge2Jvb2xlYW58e2NhcHR1cmU/OmJvb2xlYW4scGFzc2l2ZT86Ym9vbGVhbixvbmNlPzpib29sZWFufX0gW29wdGlvbnNdIFRoZSBvcHRpb25zIGZvciB0aGlzIGxpc3RlbmVyLlxuICAgICAqIEByZXR1cm5zIHt2b2lkfVxuICAgICAqL1xuICAgIHJlbW92ZUV2ZW50TGlzdGVuZXIoZXZlbnROYW1lLCBsaXN0ZW5lciwgb3B0aW9ucykge1xuICAgICAgICBpZiAobGlzdGVuZXIgPT0gbnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBsaXN0ZW5lcnMgPSBnZXRMaXN0ZW5lcnModGhpcyk7XG4gICAgICAgIGNvbnN0IGNhcHR1cmUgPSBpc09iamVjdChvcHRpb25zKVxuICAgICAgICAgICAgPyBCb29sZWFuKG9wdGlvbnMuY2FwdHVyZSlcbiAgICAgICAgICAgIDogQm9vbGVhbihvcHRpb25zKTtcbiAgICAgICAgY29uc3QgbGlzdGVuZXJUeXBlID0gY2FwdHVyZSA/IENBUFRVUkUgOiBCVUJCTEU7XG5cbiAgICAgICAgbGV0IHByZXYgPSBudWxsO1xuICAgICAgICBsZXQgbm9kZSA9IGxpc3RlbmVycy5nZXQoZXZlbnROYW1lKTtcbiAgICAgICAgd2hpbGUgKG5vZGUgIT0gbnVsbCkge1xuICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICAgIG5vZGUubGlzdGVuZXIgPT09IGxpc3RlbmVyICYmXG4gICAgICAgICAgICAgICAgbm9kZS5saXN0ZW5lclR5cGUgPT09IGxpc3RlbmVyVHlwZVxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgaWYgKHByZXYgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgcHJldi5uZXh0ID0gbm9kZS5uZXh0O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobm9kZS5uZXh0ICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGxpc3RlbmVycy5zZXQoZXZlbnROYW1lLCBub2RlLm5leHQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGxpc3RlbmVycy5kZWxldGUoZXZlbnROYW1lKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHByZXYgPSBub2RlO1xuICAgICAgICAgICAgbm9kZSA9IG5vZGUubmV4dDtcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBEaXNwYXRjaCBhIGdpdmVuIGV2ZW50LlxuICAgICAqIEBwYXJhbSB7RXZlbnR8e3R5cGU6c3RyaW5nfX0gZXZlbnQgVGhlIGV2ZW50IHRvIGRpc3BhdGNoLlxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSBgZmFsc2VgIGlmIGNhbmN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XG4gICAgICAgICAgICAgICAgaWYgKHByZXYgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgcHJldi5uZXh0ID0gbm9kZS5uZXh0O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobm9kZS5uZXh0ICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGxpc3RlbmVycy5zZXQoZXZlbnROYW1lLCBub2RlLm5leHQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGxpc3RlbmVycy5kZWxldGUoZXZlbnROYW1lKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHByZXYgPSBub2RlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBDYWxsIHRoaXMgbGlzdGVuZXJcbiAgICAgICAgICAgIHNldFBhc3NpdmVMaXN0ZW5lcihcbiAgICAgICAgICAgICAgICB3cmFwcGVkRXZlbnQsXG4gICAgICAgICAgICAgICAgbm9kZS5wYXNzaXZlID8gbm9kZS5saXN0ZW5lciA6IG51bGxcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIG5vZGUubGlzdGVuZXIgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG5vZGUubGlzdGVuZXIuY2FsbCh0aGlzLCB3cmFwcGVkRXZlbnQpO1xuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlb2YgY29uc29sZSAhPT0gXCJ1bmRlZmluZWRcIiAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZW9mIGNvbnNvbGUuZXJyb3IgPT09IFwiZnVuY3Rpb25cIlxuICAgICAgICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoXG4gICAgICAgICAgICAgICAgbm9kZS5saXN0ZW5lclR5cGUgIT09IEFUVFJJQlVURSAmJlxuICAgICAgICAgICAgICAgIHR5cGVvZiBub2RlLmxpc3RlbmVyLmhhbmRsZUV2ZW50ID09PSBcImZ1bmN0aW9uXCJcbiAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgIG5vZGUubGlzdGVuZXIuaGFuZGxlRXZlbnQod3JhcHBlZEV2ZW50KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgLy8gQnJlYWsgaWYgYGV2ZW50LnN0b3BJbW1lZGlhdGVQcm9wYWdhdGlvbmAgd2FzIGNhbGxlZC5cbiAgICAgICAgICAgIGlmIChpc1N0b3BwZWQod3JhcHBlZEV2ZW50KSkge1xuICAgICAgICAgICAgICAgIGJyZWFrXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIG5vZGUgPSBub2RlLm5leHQ7XG4gICAgICAgIH1cbiAgICAgICAgc2V0UGFzc2l2ZUxpc3RlbmVyKHdyYXBwZWRFdmVudCwgbnVsbCk7XG4gICAgICAgIHNldEV2ZW50UGhhc2Uod3JhcHBlZEV2ZW50LCAwKTtcbiAgICAgICAgc2V0Q3VycmVudFRhcmdldCh3cmFwcGVkRXZlbnQsIG51bGwpO1xuXG4gICAgICAgIHJldHVybiAhd3JhcHBlZEV2ZW50LmRlZmF1bHRQcmV2ZW50ZWRcbiAgICB9LFxufTtcblxuLy8gYGNvbnN0cnVjdG9yYCBpcyBub3QgZW51bWVyYWJsZS5cbk9iamVjdC5kZWZpbmVQcm9wZXJ0eShFdmVudFRhcmdldC5wcm90b3R5cGUsIFwiY29uc3RydWN0b3JcIiwge1xuICAgIHZhbHVlOiBFdmVudFRhcmdldCxcbiAgICBjb25maWd1c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iAgICAgICAgcmV0dXJuICgob2Zmc2V0ID4gMCA/IFwiLVwiIDogXCIrXCIpICtcbiAgICAgICAgICAgIHBhZChNYXRoLmZsb29yKE1hdGguYWJzKG9mZnNldCkgLyA2MCkgKiAxMDAgKyAoTWF0aC5hYnMob2Zmc2V0KSAlIDYwKSwgNCkpO1xuICAgIH0sXG4gICAgWjogZnVuY3Rpb24gKGRhdGVPYmopIHtcbiAgICAgICAgdmFyIG9mZnNldCA9IGRhdGVPYmouZ2V0VGltZXpvbmVPZmZzZXQoKTtcbiAgICAgICAgcmV0dXJuICgob2Zmc2V0ID4gMCA/IFwiLVwiIDogXCIrXCIpICtcbiAgICAgICAgICAgIHBhZChNYXRoLmZsb29yKE1hdGguYWJzKG9mZnNldCkgLyA2MCksIDIpICtcbiAgICAgICAgICAgIFwiOlwiICtcbiAgICAgICAgICAgIHBhZChNYXRoLmFicyhvZmZzZXQpICUgNjAsIDIpKTtcbiAgICB9XG59O1xudmFyIG1vbnRoUGFyc2UgPSBmdW5jdGlvbiAodikgeyByZXR1cm4gK3YgLSAxOyB9O1xudmFyIGVtcHR5RGlnaXRzID0gW251bGwsIHR3b0RpZ2l0c09wdGlvbmFsXTtcbnZhciBlbXB0eVdvcmQgPSBbbnVsbCwgd29yZF07XG52YXIgYW1QbSA9IFtcbiAgICBcImlzUG1cIixcbiAgICB3b3JkLFxuICAgIGZ1bmN0aW9uICh2LCBpMThuKSB7XG4gICAgICAgIHZhciB2YWwgPSB2LnRvTG93ZXJDYXNlKCk7XG4gICAgICAgIGlmICh2YWwgPT09IGkxOG4uYW1QbVswXSkge1xuICAgICAgICAgICAgcmV0dXJuIDA7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAodmFsID09PSBpMThuLmFtUG1bMV0pIHtcbiAgICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cbl07XG52YXIgdGltZXpvbmVPZmZzZXQgPSBbXG4gICAg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FyZ3VtZW50cylcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgICBpZiAoT2JqZWN0KHJlc3VsdCkgPT09IHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGFyZ2V0LmFwcGx5KFxuICAgICAgICAgICAgdGhhdCxcbiAgICAgICAgICAgIGNvbmNhdHR5KGFyZ3MsIGFyZ3VtZW50cylcbiAgICAgICAgKTtcblxuICAgIH07XG5cbiAgICB2YXIgYm91bmRMZW5ndGggPSBtYXgoMCwgdGFyZ2V0Lmxlbmd0aCAtIGFyZ3MubGVuZ3RoKTtcbiAgICB2YXIgYm91bmRBcmdzID0gW107XG4gICAgZm9yICh2YXIgaSA9IDA7IGkgPCBib3VuZExlbmd0aDsgaSsrKSB7XG4gICAgICAgIGJvdW5kQXJnc1tpXSA9ICckJyArIGk7XG4gICAgfVxuXG4gICAgYm91bmQgPSBGdW5jdGlvbignYmluZGVyJywgJ3JldHVybiBmdW5jdGlvbiAoJyArIGpvaW55KGJvdW5kQXJncywgJywnKSArICcpeyByZXR1cm4gYmluZGVyLmFwcGx5KHRoaXMsYXJndW1lbnRzKTsgfScpKGJpbmRlcik7XG5cbiAgICBpZiAodGFyZ2V0LnByb3RvdHlwZSkge1xuICAgICAgICB2YXIgRW1wdHkgPSBmdW5jdGlvbiBFbXB0eSgpIHt9O1xuICAgICAgICBFbXB0eS5wcm90b3R5cGUgPSB0YXJnZXQucHJvdG90eXBlO1xuICAgICAgICBib3VuZC5wcm90b3R5cGUgPSBuZXcgRW1wdHkoKTtcbiAgICAgICAgRW1wdHkucHJvdG90eXBlID0gbnVsbDtcbiAgICB9XG5cbiAgICByZXR1cm4gYm91bmQ7XG59O1xuIiwiJ3VzZSBzdHJpY3QnO1xuXG52YXIgaW1wbGVtZW50YXRpb24gPSByZXF1aXJlKCcuL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DsgaW5kZXgrKykge1xuICAgICAgICBjaCA9IGRhdGFbaW5kZXhdO1xuICAgICAgICBpZiAoY2ggPT09ICdfJykgY29udGludWU7XG4gICAgICAgIGlmIChjaCAhPT0gJzAnICYmIGNoICE9PSAnMScpIHJldHVybiBmYWxzZTtcbiAgICAgICAgaGFzRGlnaXRzID0gdHJ1ZTtcbiAgICAgIH1cbiAgICAgIHJldHVybiBoYXNEaWdpdHMgJiYgY2ggIT09ICdfJztcbiAgICB9XG5cblxuICAgIGlmIChjaCA9PT0gJ3gnKSB7XG4gICAgICAvLyBiYXNlIDE2XG4gICAgICBpbmRleCsrO1xuXG4gICAgICBmb3IgKDsgaW5kZXggPCBtYXg7IGluZGV4KyspIHtcbiAgICAgICAgY2ggPSBkYXRhW2luZGV4XTtcbiAgICAgICAgaWYgKGNoID09PSAnXycpIGNvbnRpbnVlO1xuICAgICAgICBpZiAoIWlzSGV4Q29kZShkYXRhLmNoYXJDb2RlQXQoaW5kZXgpKSkgcmV0dXJuIGZhbHNlO1xuICAgICAgICBoYXNEaWdpdHMgPSB0cnVlO1xuICAgICAgfVxuICAgICAgcmV0dXJuIGhhc0RpZ2l0cyAmJiBjaCAhPT0gJ18nO1xuICAgIH1cblxuXG4gICAgaWYgKGNoID09PSAnbycpIHtcbiAgICAgIC8vIGJhc2UgOFxuICAgICAgaW5kZXgrKztcblxuICAgICAgZm9yICg7IGluZGV4IDwgbWF4OyBpbmRleCsrKSB7XG4gICAgICAgIGNoID0gZGF0YVtpbmRleF07XG4gICAgICAgIGlmIChjaCA9PT0gJ18nKSBjb250aW51ZTtcbiAgICAgICAgaWYgKCFpc09jdENvZGUoZGF0YS5jaGFyQ29kZUF0KGluZGV4KSkpIHJldHVybiBmYWxzZTtcbiAgICAgICAgaGFzRGlnaXRzID0gdHJ1ZTtcbiAgICAgIH1cbiAgICAgIHJldHVybiBoYXNEaWdpdHMgJiYgY2ggIT09ICdfJztcbiAgICB9XG4gIH1cblxuICAvLyBiYXNlIDEw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FswLTldWzAtOV0/KScgICAgICAgICAgICAgICAgICAgKyAvLyBbM10gZGF5XG4gICcoPzpbVHRdfFsgXFxcXHRdKyknICAgICAgICAgICAgICAgICArIC8vIC4uLlxuICAnKFswLTldWzAtOV0/KScgICAgICAgICAgICAgICAgICAgICsgLy8gWzRdIGhvdXJcbiAgJzooWzAtOV1bMC05XSknICAgICAgICAgICAgICAgICAgICArIC8vIFs1XSBtaW51dGVcbiAgJzooWzAtOV1bMC05XSknICAgICAgICAgICAgICAgICAgICArIC8vIFs2XSBzZWNvbmRcbiAgJyg/OlxcXFwuKFswLTldKikpPycgICAgICAgICAgICAgICAgICsgLy8gWzddIGZyYWN0aW9uXG4gICcoPzpbIFxcXFx0XSooWnwoWy0rXSkoWzAtOV1bMC05XT8pJyArIC8vIFs4XSB0eiBbOV0gdHpfc2lnbiBbMTBdIHR6X2hvdXJcbiAgJyg/OjooWzAtOV1bMC05XSkpPykpPyQnKTsgICAgICAgICAgIC8vIFsxMV0gdHpfbWludXRlXG5cbmZ1bmN0aW9uIHJlc29sdmVZYW1sVGltZXN0YW1wKGRhdGEpIHtcbiAgaWYgKGRhdGEgPT09IG51bGwpIHJldHVybiBmYWxzZTtcbiAgaWYgKFlBTUxfREFURV9SRUdFWFAuZXhlYyhkYXRhKSAhPT0gbnVsbCkgcmV0dXJuIHRydWU7XG4gIGlmIChZQU1MX1RJTUVTVEFNUF9SRUdFWFAuZXhlYyhkYXRhKSAhPT0gbnVsbCkgcmV0dXJuIHRydWU7XG4gIHJldHVybiBmYWxzZTtcbn1cblxuZnVuY3Rpb24gY29uc3RydWN0WWFtbFRpbWVzdGFtcChkYXRhKSB7XG4gIHZhciBtYXRjaCwgeWVhciwgbW9udGgsIGRheSwgaG91ciwgbWludXRlLCBzZWNvbmQsIGZyYWN0aW9uID0gMCxcbiAgICAgIGRlbHRhID0gbnVsbCwgdHpfaG91ciwgdHpfbWludXRlLCBkYXRlO1xuXG4gIG1hdGNoID0gWUFNTF9EQVRFX1J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LykpIHtcbiAgICByZXR1cm4gbGMgLSAweDYxICsgMTA7XG4gIH1cblxuICByZXR1cm4gLTE7XG59XG5cbmZ1bmN0aW9uIGVzY2FwZWRIZXhMZW4oYykge1xuICBpZiAoYyA9PT0gMHg3OC8qIHggKi8pIHsgcmV0dXJuIDI7IH1cbiAgaWYgKGMgPT09IDB4NzUvKiB1ICovKSB7IHJldHVybiA0OyB9XG4gIGlmIChjID09PSAweDU1LyogVSAqLykgeyByZXR1cm4gODsgfVxuICByZXR1cm4gMDtcbn1cblxuZnVuY3Rpb24gZnJvbURlY2ltYWxDb2RlKGMpIHtcbiAgaWYgKCgweDMwLyogMCAqLyA8PSBjKSAmJiAoYyA8PSAweDM5LyogOSAqLykpIHtcbiAgICByZXR1cm4gYyAtIDB4MzA7XG4gIH1cblxuICByZXR1cm4gLTE7XG59XG5cbmZ1bmN0aW9uIHNpbXBsZUVzY2FwZVNlcXVlbmNlKGMpIHtcbiAgLyogZXNsaW50LWRpc2FibGUgaW5kZW50ICovXG4gIHJldHVybiAoYyA9PT0gMHgzMC8qIDAgKi8pID8gJ1xceDAwJyA6XG4gICAgICAgIChjID09PSAweDYxLyogYSAqLykgPyAnXFx4MDcnIDpcbiAgICAgICAgKGMgPT09IDB4NjIvKiBiICovKSA/ICdcXHgwOCcgOlxuICAgICAgICAoYyA9PT0gMHg3NC8qIHQgKi8pID8gJ1xceDA5JyA6XG4gICAgICAgIChjID09PSAweDA5LyogVGFiICovKSA/ICdcXHgwOScgOlxuICAgICAgICAoYyA9PT0gMHg2RS8qIG4gKi8pID8gJ1xceDBBJyA6XG4gICAgICAgIChjID09PSAweDc2LyogdiAqLykgPyAnXFx4MEInIDpcbiAgICAgICAgKGMgPT09IDB4NjYvKiBmICovKSA/ICdcXHgwQycgOlxuICAgICAgICAoYyA9PT0gMHg3Mi8qIHIgKi8pID8gJ1xceDBEJyA6XG4gICAgICAgIChjID09PSAweDY1LyogZSAqLykgPyAnXFx4MUInIDpcbiAgICAgICAgKG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XInO1xuICBzdGF0ZS5yZXN1bHQgPSAnJztcblxuICB3aGlsZSAoY2ggIT09IDApIHtcbiAgICBjaCA9IHN0YXRlLmlucHV0LmNoYXJDb2RlQXQoKytzdGF0ZS5wb3NpdGlvbik7XG5cbiAgICBpZiAoY2ggPT09IDB4MkIvKiArICovIHx8IGNoID09PSAweDJELyogLSAqLykge1xuICAgICAgaWYgKENIT01QSU5HX0NMSVAgPT09IGNob21waW5nKSB7XG4gICAgICAgIGNob21waW5nID0gKGNoID09PSAweDJCLyogKyAqLykgPyBDSE9NUElOR19LRUVQIDogQ0hPTVBJTkdfU1RSSVA7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aHJvd0Vycm9yKHN0YXRlLCAncmVwZWF0IG9mIGEgY2hvbXBpbmcgbW9kZSBpZGVudGlmaWVyJyk7XG4gICAgICB9XG5cbiAgICB9IGVsc2UgaWYgKCh0bXAgPSBmcm9tRGVjaW1hbENvZGUoY2gpKSA+PSAwKSB7XG4gICAgICBpZiAodG1wID09PSAwKSB7XG4gICAgICAgIHRocm93RXJyb3Ioc3RhdGUsICdiYWQgZXhwbGljaXQgaW5kZW50YXRpb24gd2lkdGggb2YgYSBibG9jayBzY2FsYXI7IGl0IGNhbm5vdCBiZSBsZXNzIHRoYW4gb25lJyk7XG4gICAgICB9IGVsc2UgaWYgKCFkZXRlY3RlZEluZGVudCkge1xuICAgICAgICB0ZXh0SW5kZW50ID0gbm9kZUluZGVudCArIHRtcCAtIDE7XG4gICAgICAgIGRldGVjdGVkSW5kZW50ID0gdHJ1ZTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRocm93RXJyb3Ioc3RhdGUsICdyZXBlYXQgb2YgYW4gaW5kZW50YXRpb24gd2lkdGggaWRlbnRpZmllcicpO1xuICAgICAgfVxuXG4gICAgfSBlbHNlIHtcbiAgICAgIGJyZWFrO1xuICAgIH1cbiAgfVxuXG4gIGlmIChpc19XSElURV9TUEFDRShjaCkpIHtcbiAgICBkbyB7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klBR0VfUkVUVVJOICAgICAgPSAweDBEOyAvKiBDUiAqL1xudmFyIENIQVJfU1BBQ0UgICAgICAgICAgICAgICAgPSAweDIwOyAvKiBTcGFjZSAqL1xudmFyIENIQVJfRVhDTEFNQVRJT04gICAgICAgICAgPSAweDIxOyAvKiAhICovXG52YXIgQ0hBUl9ET1VCTEVfUVVPVEUgICAgICAgICA9IDB4MjI7IC8qIFwiICovXG52YXIgQ0hBUl9TSEFSUCAgICAgICAgICAgICAgICA9IDB4MjM7IC8qICMgKi9cbnZhciBDSEFSX1BFUkNFTlQgICAgICAgICAgICAgID0gMHgyNTsgLyogJSAqL1xudmFyIENIQVJfQU1QRVJTQU5EICAgICAgICAgICAgPSAweDI2OyAvKiAmICovXG52YXIgQ0hBUl9TSU5HTEVfUVVPVEUgICAgICAgICA9IDB4Mjc7IC8qICcgKi9cbnZhciBDSEFSX0FTVEVSSVNLICAgICAgICAgICAgID0gMHgyQTsgLyogKiAqL1xudmFyIENIQVJfQ09NTUEgICAgICAgICAgICAgICAgPSAweDJDOyAvKiAsICovXG52YXIgQ0hBUl9NSU5VUyAgICAgICAgICAgICAgICA9IDB4MkQ7IC8qIC0gKi9cbnZhciBDSEFSX0NPTE9OICAgICAgICAgICAgICAgID0gMHgzQTsgLyogOiAqL1xudmFyIENIQVJfRVFVQUxTICAgICAgICAgICAgICAgPSAweDNEOyAvKiA9ICovXG52YXIgQ0hBUl9HUkVBVEVSX1RIQU4gICAgICAgICA9IDB4M0U7IC8qID4gKi9cbnZhciBDSEFSX1FVRVNUSU9OICAgICAgICAgICAgID0gMHgzRjsgLyogPyAqL1xudmFyIENIQVJfQ09NTUVSQ0lBTF9BVCAgICAgICAgPSAweDQwOyAvKiBAICovXG52YXIgQ0hBUl9MRUZUX1NRVUFSRV9CUkFDS0VUICA9IDB4NUI7IC8qIFsgKi9cbnZhciBDSEFSX1JJR0hUX1NRVUFSRV9CUkFDS0VUID0gMHg1RDsgLyogXSAqL1xudmFyIENIQVJfR1JB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9XG4gICAgICAgKi9cbiAgICAgICdldmFsdWF0ZSc6IHJlRXZhbHVhdGUsXG5cbiAgICAgIC8qKlxuICAgICAgICogVXNlZCB0byBkZXRlY3QgYGRhdGFgIHByb3BlcnR5IHZhbHVlcyB0byBpbmplY3QuXG4gICAgICAgKlxuICAgICAgICogQG1lbWJlck9mIF8udGVtcGxhdGVTZXR0aW5nc1xuICAgICAgICogQHR5cGUge1JlZ0V4cH1cbiAgICAgICAqL1xuICAgICAgJ2ludGVycG9sYXRlJzogcmVJbnRlcnBvbGF0ZSxcblxuICAgICAgLyoqXG4gICAgICAgKiBVc2VkIHRvIHJlZmVyZW5jZSB0aGUgZGF0YSBvYmplY3QgaW4gdGhlIHRlbXBsYXRlIHRleHQuXG4gICAgICAgKlxuICAgICAgICogQG1lbWJlck9mIF8udGVtcGxhdGVTZXR0aW5nc1xuICAgICAgICogQHR5cGUge3N0cmluZ31cbiAgICAgICAqL1xuICAgICAgJ3ZhcmlhYmxlJzogJycsXG5cbiAgICAgIC8qKlxuICAgICAgICogVXNlZCB0byBpbXBvcnQgdmFyaWFibGVzIGludG8gdGhlIGNvbXBpbGVkIHRlbXBsYXRlLlxuICAgICAgICpcbiAgICAgICAqIEBtZW1iZXJPZiBfLnRlbXBsYXRlU2V0dGluZ3NcbiAgICAgICAqIEB0eXBlIHtPYmplY3R9XG4gICAgICAgKi9cbiAgICAgICdpbXBvcnRzJzoge1xuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBBIHJlZmVyZW5jZSB0byB0aGUgYGxvZGFzaGAgZnVuY3Rpb24uXG4gICAgICAgICAqXG4gICAgICAgICAqIEBtZW1iZXJPZiBfLnRlbXBsYXRlU2V0dGluZ3MuaW1wb3J0c1xuICAgICAgICAgKiBAdHlwZSB7RnVuY3Rpb259XG4gICAgICAgICAqL1xuICAgICAgICAnXyc6IGxvZGFzaFxuICAgICAgfVxuICAgIH07XG5cbiAgICAvLyBFbnN1cmUgd3JhcHBlcnMgYXJlIGluc3Rh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SxcbiAgICAgICAgICBzZWVuID0gY2FjaGVzWzBdO1xuXG4gICAgICBvdXRlcjpcbiAgICAgIHdoaWxlICgrK2luZGV4IDwgbGVuZ3RoICYmIHJlc3VsdC5sZW5ndGggPCBtYXhMZW5ndGgpIHtcbiAgICAgICAgdmFyIHZhbHVlID0gYXJyYXlbaW5kZXhdLFxuICAgICAgICAgICAgY29tcHV0ZWQgPSBpdGVyYXRlZSA/IGl0ZXJhdGVlKHZhbHVlKSA6IHZhbHVlO1xuXG4gICAgICAgIHZhbHVlID0gKGNvbXBhcmF0b3IgfHwgdmFsdWUgIT09IDApID8gdmFsdWUgOiAwO1xuICAgICAgICBpZiAoIShzZWVuXG4gICAgICAgICAgICAgID8gY2FjaGVIYXMoc2VlbiwgY29tcHV0ZWQpXG4gICAgICAgICAgICAgIDogaW5jbHVkZXMocmVzdWx0LCBjb21wdXRlZCwgY29tcGFyYXRvcilcbiAgICAgICAgICAgICkpIHtcbiAgICAgICAgICBvdGhJbmRleCA9IG90aExlbmd0aDtcbiAgICAgICAgICB3aGlsZSAoLS1vdGhJbmRleCkge1xuICAgICAgICAgICAgdmFyIGNhY2hlID0gY2FjaGVzW290aEluZGV4XTtcbiAgICAgICAgICAgIGlmICghKGNhY2hlXG4gICAgICAgICAgICAgICAgICA/IGNhY2hlSGFzKGNhY2hlLCBjb21wdXRlZClcbiAgICAgICAgICAgICAgICAgIDogaW5jbHVkZXMoYXJyYXlzW290aEluZGV4XSwgY29tcHV0ZWQsIGNvbXBhcmF0b3IpKVxuICAgICAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICBjb250aW51ZSBvdXRlcjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHNlZW4pIHtcbiAgICAgICAgICAgIHNlZW4ucHVzaChjb21wdXRlZCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJlc3VsdC5wdXNoKHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcm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ge1xuICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBvYmpJc0FyciA9IHRydWU7XG4gICAgICAgIG9iaklzT2JqID0gZmFsc2U7XG4gICAgICB9XG4gICAgICBpZiAoaXNTYW1lVGFnICYmICFvYmpJc09iaikge1xuICAgICAgICBzdGFjayB8fCAoc3RhY2sgPSBuZXcgU3RhY2spO1xuICAgICAgICByZXR1cm4gKG9iaklzQXJyIHx8IGlzVHlwZWRBcnJheShvYmplY3QpKVxuICAgICAgICAgID8gZXF1YWxBcnJheXMob2JqZWN0LCBvdGhlciwgYml0bWFzaywgY3VzdG9taXplciwgZXF1YWxGdW5jLCBzdGFjaylcbiAgICAgICAgICA6IGVxdWFsQnlUYWcob2JqZWN0LCBvdGhlciwgb2JqVGFnLCBiaXRtYXNrLCBjdXN0b21pemVyLCBlcXVhbEZ1bmMsIHN0YWNrKTtcbiAgICAgIH1cbiAgICAgIGlmICghKGJpdG1hc2sgJiBDT01QQVJFX1BBUlRJQUxfRkxBRykpIHtcbiAgICAgICAgdmFyIG9iaklzV3JhcHBlZCA9IG9iaklzT2JqICYmIGhhc093blByb3BlcnR5LmNhbGwob2JqZWN0LCAnX193cmFwcGVkX18nKSxcbiAgICAgICAgICAgIG90aElzV3JhcHBlZCA9IG90aElzT2JqICYmIGhhc093blByb3BlcnR5LmNhbGwob3RoZXIsICdfX3dyYXBwZWRfXycpO1xuXG4gICAgICAgIGlmIChvYmpJc1dyYXBwZWQgfHwgb3RoSXNXcmFwcGVkKSB7XG4gICAgICAgICAgdmFyIG9ialVud3JhcHBlZCA9IG9iaklzV3JhcHBlZCA/IG9iamVjdC52YWx1ZSgpIDogb2JqZWN0LFxuICAgICAgICAgICAgICBvdGhVbndyYXBwZWQgPSBvdGhJc1dyYXBwZWQgPyBvdGhlci52YWx1ZSgpIDogb3RoZXI7XG5cbiAgICAgICAgICBzdGFjayB8fCAoc3RhY2sgPSBuZXcgU3RhY2spO1xuICAgICAgICAgIH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pbmRleCA8IGxlbmd0aCkge1xuICAgICAgICBkYXRhID0gbWF0Y2hEYXRhW2luZGV4XTtcbiAgICAgICAgdmFyIGtleSA9IGRhdGFbMF0sXG4gICAgICAgICAgICBvYmpWYWx1ZSA9IG9iamVjdFtrZXldLFxuICAgICAgICAgICAgc3JjVmFsdWUgPSBkYXRhWzFdO1xuXG4gICAgICAgIGlmIChub0N1c3RvbWl6ZXIgJiYgZGF0YVsyXSkge1xuICAgICAgICAgIGlmIChvYmpWYWx1ZSA9PT0gdW5kZWZpbmVkICYmICEoa2V5IGluIG9iamVjdCkpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdmFyIHN0YWNrID0gbmV3IFN0YWNrO1xuICAgICAgICAgIGlmIChjdXN0b21pemVyKSB7XG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gY3VzdG9taXplcihvYmpWYWx1ZSwgc3JjVmFsdWUsIGtleSwgb2JqZWN0LCBzb3VyY2UsIHN0YWNrKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKCEocmVzdWx0ID09PSB1bmRlZmluZWRcbiAgICAgICAgICAgICAgICA/IGJhc2VJc0VxdWFsKHNyY1ZhbHVlLCBvYmpWYWx1ZSwgQ09NUEFSRV9QQVJUSUFMX0ZMQUcgfCBDT01QQVJFX1VOT1JERVJFRF9GTEFHLCBjdXN0b21pemVyLCBzdGFjaylcbiAgICAgICAgICAgICAgICA6IHJlc3VsdFxuICAgICAgICAgICAgICApKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBUaGUgYmFzZSBpbXBsZW1lbnRhdGlvbiBvZiBgXy5pc05hdGl2ZWAgd2l0aG91dCBiYWQgc2hpbSBjaGVja3MuXG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3Rpb24gYmFzZVB1bGxBdChhcnJheSwgaW5kZXhlcykge1xuICAgICAgdmFyIGxlbmd0aCA9IGFycmF5ID8gaW5kZXhlcy5sZW5ndGggOiAwLFxuICAgICAgICAgIGxhc3RJbmRleCA9IGxlbmd0aCAtIDE7XG5cbiAgICAgIHdoaWxlIChsZW5ndGgtLSkge1xuICAgICAgICB2YXIgaW5kZXggPSBpbmRleGVzW2xlbmd0aF07XG4gICAgICAgIGlmIChsZW5ndGggPT0gbGFzdEluZGV4IHx8IGluZGV4ICE9PSBwcmV2aW91cykge1xuICAgICAgICAgIHZhciBwcmV2aW91cyA9IGluZGV4O1xuICAgICAgICAgIGlmIChpc0luZGV4KGluZGV4KSkge1xuICAgICAgICAgICAgc3BsaWNlLmNhbGwoYXJyYXksIGluZGV4LCAxKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgYmFzZVVuc2V0KGFycmF5LCBpbmRleCk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gYXJyYXk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogVGhlIGJhc2UgaW1wbGVtZW50YXRpb24gb2YgYF8ucmFuZG9tYCB3aXRob3V0IHN1cHBvcnQgZm9yIHJldHVybmluZ1xuICAgICAqIGZsb2F0aW5nLXBvaW50IG51bWJlcnMuXG4gICAgICpcbiAgICAgKiBAcHJpdmF0ZVxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBsb3dlciBUaGUgbG93ZXIgYm91bmQuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHVwcGVyIFRoZSB1cHBlciBib3VuZC5cbiAgICAgKiBAcmV0dXJucyB7bnVtYmVyfSBSZXR1cm5zIHRoZSByYW5kb20gbnVtYmVyLlxuICAgICAqL1xuICAgIGZ1bmN0aW9uIGJhc2VSYW5kb20obG93ZXIsIHVwcGVyKSB7XG4gICAgICByZXR1cm4gbG93ZXIgKyBuYXRpdmVGbG9vcihuYXR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hcnJMZW5ndGgpIHtcbiAgICAgICAgdmFyIGFyclZhbHVlID0gYXJyYXlbaW5kZXhdLFxuICAgICAgICAgICAgb3RoVmFsdWUgPSBvdGhlcltpbmRleF07XG5cbiAgICAgICAgaWYgKGN1c3RvbWl6ZXIpIHtcbiAgICAgICAgICB2YXIgY29tcGFyZWQgPSBpc1BhcnRpYWxcbiAgICAgICAgICAgID8gY3VzdG9taXplcihvdGhWYWx1ZSwgYXJyVmFsdWUsIGluZGV4LCBvdGhlciwgYXJyYXksIHN0YWNrKVxuICAgICAgICAgICAgOiBjdXN0b21pemVyKGFyclZhbHVlLCBvdGhWYWx1ZSwgaW5kZXgsIGFycmF5LCBvdGhlciwgc3RhY2spO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjb21wYXJlZCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgaWYgKGNvbXBhcmVkKSB7XG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmVzdWx0ID0gZmFsc2U7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgLy8gUmVjdXJzaXZlbHkgY29tcGFyZSBhcnJheXMgKHN1c2NlcHRpYmxlIHRvIGNhbGwgc3RhY2sgbGltaXRzKS5cbiAgICAgICAgaWYgKHNlZW4pIHtcbiAgICAgICAgICBpZiAoIWFycmF5U29tZShvdGhlciwgZnVuY3Rpb24ob3RoVmFsdWUsIG90aEluZGV4KSB7XG4gICAgICAgICAgICAgICAgaWYgKCFjYWNoZUhhcyhzZWVuLCBvdGhJbmRleCkgJiZcbiAgICAgICAgICAgICAgICAgICAgKGFyclZhbHVlID09PSBvdGhWYWx1ZSB8fCBlcXVhbEZ1bmMoYXJyVmFsdWUsIG90aFZhbHVlLCBiaXRtYXNrLCBjdXN0b21pemVyLCBzdGFjaykpKSB7XG4gICAgICAgICAgICAgICAgICByZXR1cm4gc2Vlbi5wdXNoKG90aEluZGV4KTtcbiAgICAgICA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BkZXRhaWxzLlxuICAgICAgICAgIHJldHVybiBvYmplY3QgPT0gKG90aGVyICsgJycpO1xuXG4gICAgICAgIGNhc2UgbWFwVGFnOlxuICAgICAgICAgIHZhciBjb252ZXJ0ID0gbWFwVG9BcnJheTtcblxuICAgICAgICBjYXNlIHNldFRhZzpcbiAgICAgICAgICB2YXIgaXNQYXJ0aWFsID0gYml0bWFzayAmIENPTVBBUkVfUEFSVElBTF9GTEFHO1xuICAgICAgICAgIGNvbnZlcnQgfHwgKGNvbnZlcnQgPSBzZXRUb0FycmF5KTtcblxuICAgICAgICAgIGlmIChvYmplY3Quc2l6ZSAhPSBvdGhlci5zaXplICYmICFpc1BhcnRpYWwpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy8gQXNzdW1lIGN5Y2xpYyB2YWx1ZXMgYXJlIGVxdWFsLlxuICAgICAgICAgIHZhciBzdGFja2VkID0gc3RhY2suZ2V0KG9iamVjdCk7XG4gICAgICAgICAgaWYgKHN0YWNrZWQpIHtcbiAgICAgICAgICAgIHJldHVybiBzdGFja2VkID09IG90aGVyO1xuICAgICAgICAgIH1cbiAgICAgICAgICBiaXRtYXNrIHw9IENPTVBBUkVfVU5PUkRFUkVEX0ZMQUc7XG5cbiAgICAgICAgICAvLyBSZWN1cnNpdmVseSBjb21wYXJlIG9iamVjdHMgKHN1c2NlcHRpYmxlIHRvIGNhbGwgc3RhY2sgbGltaXRzKS5cbiAgICAgICAgICBzdGFjay5zZXQob2JqZWN0LCBvdGhlcik7XG4gICAgICAgICAgdmFyIHJlc3VsdCA9IGVxdWFsQXJyYXlzKGNvbnZlcnQob2JqZWN0KSwgY29udmVydChvdGhlciksIGJpdG1hc2ssIGN1c3RvbWl6ZXIsIGVxdWFsRnVuYywgc3RhY2spO1xuICAgICAgICAgIHN0YWNrWydkZWxldGUnXShvYmplY3QpO1xuICAgICAgICAgIHJldHVybiByZXN1bHQ7XG5cbiAgICAgICA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ZXIgJiYgb3RoU3RhY2tlZCA9PSBvYmplY3Q7XG4gICAgICB9XG4gICAgICB2YXIgcmVzdWx0ID0gdHJ1ZTtcbiAgICAgIHN0YWNrLnNldChvYmplY3QsIG90aGVyKTtcbiAgICAgIHN0YWNrLnNldChvdGhlciwgb2JqZWN0KTtcblxuICAgICAgdmFyIHNraXBDdG9yID0gaXNQYXJ0aWFsO1xuICAgICAgd2hpbGUgKCsraW5kZXggPCBvYmpMZW5ndGgpIHtcbiAgICAgICAga2V5ID0gb2JqUHJvcHNbaW5kZXhdO1xuICAgICAgICB2YXIgb2JqVmFsdWUgPSBvYmplY3Rba2V5XSxcbiAgICAgICAgICAgIG90aFZhbHVlID0gb3RoZXJba2V5XTtcblxuICAgICAgICBpZiAoY3VzdG9taXplcikge1xuICAgICAgICAgIHZhciBjb21wYXJlZCA9IGlzUGFydGlhbFxuICAgICAgICAgICAgPyBjdXN0b21pemVyKG90aFZhbHVlLCBvYmpWYWx1ZSwga2V5LCBvdGhlciwgb2JqZWN0LCBzdGFjaylcbiAgICAgICAgICAgIDogY3VzdG9taXplcihvYmpWYWx1ZSwgb3RoVmFsdWUsIGtleSwgb2JqZWN0LCBvdGhlciwgc3RhY2spO1xuICAgICAgICB9XG4gICAgICAgIC8vIFJlY3Vyc2l2ZWx5IGNvbXBhcmUgb2JqZWN0cyAoc3VzY2VwdGlibGUgdG8gY2FsbCBzdGFjayBsaW1pdHMpLlxuICAgICAgICBpZiAoIShjb21wYXJlZCA9PT0gdW5kZWZpbmVkXG4gICAgICAgICAgICAgID8gKG9ialZhbHVlID09PSBvdGhWYWx1ZSB8fCBlcXVhbEZ1bmMob2JqVmFsdWUsIG90aFZhbHVlLCBiaXRtYXNrLCBjdXN0b21pemVyLCBzdGFjaykpXG4gICAgICAgICAgICAgIDogY29tcGFyZWRcbiAgICAgICAgICAgICkpIHtcbiAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICA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0YWc7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgZGVsZXRlIHZhbHVlW3N5bVRvU3RyaW5nVGFnXTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBDcmVhdGVzIGFuIGFycmF5IG9mIHRoZSBvd24gZW51bWVyYWJsZSBzeW1ib2xzIG9mIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gb2JqZWN0IFRoZSBvYmplY3QgdG8gcXVlcnkuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5zIHRoZSBhcnJheSBvZiBzeW1ib2xzLlxuICAgICAqL1xuICAgIHZhciBnZXRTeW1ib2xzID0gIW5hdGl2ZUdldFN5bWJvbHMgPyBzdHViQXJyYXkgOiBmdW5jdGlvbihvYmplY3QpIHtcbiAgICAgIGlmIChvYmplY3QgPT0gbnVsbCkge1xuICAgICAgICByZXR1cm4gW107XG4gICAgICB9XG4gICAgICBvYmplY3QgPSBPYmplY3Qob2JqZWN0KTtcbiAgICAgIHJldHVybiBhcnJheUZpbHRlcihuYXRpdmVHZXRTeW1ib2xzKG9iamVjdCksIGZ1bmN0aW9uKHN5bWJvbCkge1xuICAgICAgICByZXR1cm4gcHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChvYmplY3QsIHN5bWJvbCk7XG4gICAgICB9KTtcbiAgICB9O1xuXG4gICAgLyoqXG4gICAgICogQ3JlYXRlcyBhbiBhcnJheSBvZiB0aGUgb3duIGFuZCBpbmhlcml0ZWQgZW51bWVyYWJsZSBzeW1ib2xzIG9mIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gb2JqZWN0IFRoZSBvYmplY3QgdG8gcXVlcnkuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5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lZCk7XG5cbiAgICAgICAgbGFzdENhbGxlZCA9IHN0YW1wO1xuICAgICAgICBpZiAocmVtYWluaW5nID4gMCkge1xuICAgICAgICAgIGlmICgrK2NvdW50ID49IEhPVF9DT1VOVCkge1xuICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50c1swXTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgY291bnQgPSAwO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmdW5jLmFwcGx5KHVuZGVmaW5lZCwgYXJndW1lbnRzKTtcbiAgICAgIH07XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQSBzcGVjaWFsaXplZCB2ZXJzaW9uIG9mIGBfLnNodWZmbGVgIHdoaWNoIG11dGF0ZXMgYW5kIHNldHMgdGhlIHNpemUgb2YgYGFycmF5YC5cbiAgICAgKlxuICAgICAqIEBwcml2YXRlXG4gICAgICogQHBhcmFtIHtBcnJheX0gYXJyYXkgVGhlIGFycmF5IHRvIHNodWZmbGUuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IFtzaXplPWFycmF5Lmxlbmd0aF0gVGhlIHNpemUgb2YgYGFycmF5YC5cbiAgICAgKiBAcmV0dXJucyB7QXJyYXl9IFJldHVybnMgYGFycmF5YC5cbiAgICAgKi9cbiAgICBmdW5jdGlvbiBzaHVmZmxlU2VsZihhcnJheSwgc2l6ZSkge1xuICAgICAgdmFyIGluZGV4ID0gLTEsXG4gICAgICAgICAgbGVuZ3RoID0gYXJyYXkubGVuZ3RoLFxuICAgICAgICAgIGxhc3RJbmRleCA9IGxlbmd0aCAtIDE7XG5cbiAgICAgIHNpemUgPSBzaXplID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiBzaXplO1xuICAgICAgd2hpbGUgKCsraW5kZXggPCBzaXplKSB7XG4gICAgICAgIHZhciByYW5kID0gYmFzZVJhbmRvbShpbmRleCwgbGFzdEluZGV4KSxcbiAgICAgICAgICAgIHZhbHVlID0gYX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GVlIGZvciBtZXRob2RzIGxpa2UgYF8ubWFwYC5cbiAgICAgKiBAcmV0dXJucyB7QXJyYXl9IFJldHVybnMgdGhlIG5ldyBhcnJheSBvZiBjaHVua3MuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8uY2h1bmsoWydhJywgJ2InLCAnYycsICdkJ10sIDIpO1xuICAgICAqIC8vID0+IFtbJ2EnLCAnYiddLCBbJ2MnLCAnZCddXVxuICAgICAqXG4gICAgICogXy5jaHVuayhbJ2EnLCAnYicsICdjJywgJ2QnXSwgMyk7XG4gICAgICogLy8gPT4gW1snYScsICdiJywgJ2MnXSwgWydkJ11dXG4gICAgICovXG4gICAgZnVuY3Rpb24gY2h1bmsoYXJyYXksIHNpemUsIGd1YXJkKSB7XG4gICAgICBpZiAoKGd1YXJkID8gaXNJdGVyYXRlZUNhbGwoYXJyYXksIHNpemUsIGd1YXJkKSA6IHNpemUgPT09IHVuZGVmaW5lZCkpIHtcbiAgICAgICAgc2l6ZSA9IDE7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzaXplID0gbmF0aXZlTWF4KHRvSW50ZWdlcihzaXplKSwgMCk7XG4gICAgICB9XG4gICAgICB2YXIgbGVuZ3RoID0gYXJyYXkgPT0gbnVsbCA/IDAgOiBhcnJheS5sZW5ndGg7XG4gICAgICBpZiAoIWxlbmd0aCB8fCBzaXplIDwgMSkge1xuICAgICAgICByZXR1cm4gW107XG4gICAgICB9XG4gICAgICB2YXIgaW5kZXggPSAwLFxuICAgICAgICAgIHJlc0luZGV4ID0gMCxcbiAgICAgICAgICByZXN1bHQgPSBBcnJheShuYXRpdmVDZWlsKGxlbmd0aCAvIHNpemUpKTtcblxuICAgICAgd2hpbGUgKGluZGV4IDwgbGVuZ3RoKSB7XG4gICAgICAgIHJlc3VsdFtyZXNJbmRleCsrXSA9IGJhc2VTbGljZShhcnJheSwgaW5kZXgsIChpbmRleCArPSBzaXplKSk7XG4gICAgICB9XG4gICAgICByZXR1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tcbiAgICAgKiAgIHJldHVybiBuICUgMiA9PSAwO1xuICAgICAqIH0pO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAzXVxuICAgICAqXG4gICAgICogY29uc29sZS5sb2coZXZlbnMpO1xuICAgICAqIC8vID0+IFsyLCA0XVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIHJlbW92ZShhcnJheSwgcHJlZGljYXRlKSB7XG4gICAgICB2YXIgcmVzdWx0ID0gW107XG4gICAgICBpZiAoIShhcnJheSAmJiBhcnJheS5sZW5ndGgpKSB7XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICB9XG4gICAgICB2YXIgaW5kZXggPSAtMSxcbiAgICAgICAgICBpbmRleGVzID0gW10sXG4gICAgICAgICAgbGVuZ3RoID0gYXJyYXkubGVuZ3RoO1xuXG4gICAgICBwcmVkaWNhdGUgPSBnZXRJdGVyYXRlZShwcmVkaWNhdGUsIDMpO1xuICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgdmFyIHZhbHVlID0gYXJyYXlbaW5kZXhdO1xuICAgICAgICBpZiAocHJlZGljYXRlKHZhbHVlLCBpbmRleCwgYXJyYXkpKSB7XG4gICAgICAgICAgcmVzdWx0LnB1c2godmFsdWUpO1xuICAgICAgICAgIGluZGV4ZXMucHVzaChpbmRleCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGJhc2VQdWxsQXQoYXJyYXksIGluZGV4ZXMpO1xuICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBSZXZlcnNlcyBgYXJyYXlgIHNvIHRoYXQgdGhlIGZpcnN0IGVsZW1lbnQgYmVjb21lcyB0aGUgbGFzdCwgdGhlIHNlY29uZFxuICAgICAqIGVsZW1lbnQgYmVjb21lcyB0aGUgc2Vjb25kIHRvIGxhc3QsIGFuZCBzbyBvbi5cbiAgIC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gQSBzZXF1ZW5jZSB3aXRoIGV4cGxpY2l0IGNoYWluaW5nLlxuICAgICAqIF8odXNlcnMpXG4gICAgICogICAuY2hhaW4oKVxuICAgICAqICAgLmhlYWQoKVxuICAgICAqICAgLnBpY2soJ3VzZXInKVxuICAgICAqICAgLnZhbHVlKCk7XG4gICAgICogLy8gPT4geyAndXNlcic6ICdiYXJuZXknIH1cbiAgICAgKi9cbiAgICBmdW5jdGlvbiB3cmFwcGVyQ2hhaW4oKSB7XG4gICAgICByZXR1cm4gY2hhaW4odGhpcyk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogRXhlY3V0ZXMgdGhlIGNoYWluIHNlcXVlbmNlIGFuZCByZXR1cm5zIHRoZSB3cmFwcGVkIHJlc3VsdC5cbiAgICAgKlxuICAgICAqIEBuYW1lIGNvbW1pdFxuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDMuMi4wXG4gICAgICogQGNhdGVnb3J5IFNlcVxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgdGhlIG5ldyBgbG9kYXNoYCB3cmFwcGVyIGluc3RhbmNlLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiB2YXIgYXJyYXkgPSBbMSwgMl07XG4gICAgICogdmFyIHdyYXBwZWQgPSBfKGFycmF5KS5wdXNoKDMpO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAyXVxuICAgICAqXG4gICAgICogd3JhcHBlZCA9IHdyYXBwZWQuY29tbWl0KCk7XG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAyLCAzXVxuICAgICAqXG4gICAgICogd3JhcHBlZC5sYXN0KCk7XG4gICAgICogLy8gPT4gM1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAyLCAzXVxuICAgICAqL1xuICAgIGZ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WQpIHtcbiAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXJJZCk7XG4gICAgICAgIH1cbiAgICAgICAgbGFzdEludm9rZVRpbWUgPSAwO1xuICAgICAgICBsYXN0QXJncyA9IGxhc3RDYWxsVGltZSA9IGxhc3RUaGlzID0gdGltZXJJZCA9IHVuZGVmaW5lZDtcbiAgICAgIH1cblxuICAgICAgZnVuY3Rpb24gZmx1c2goKSB7XG4gICAgICAgIHJldHVybiB0aW1lcklkID09PSB1bmRlZmluZWQgPyByZXN1bHQgOiB0cmFpbGluZ0VkZ2Uobm93KCkpO1xuICAgICAgfVxuXG4gICAgICBmdW5jdGlvbiBkZWJvdW5jZWQoKSB7XG4gICAgICAgIHZhciB0aW1lID0gbm93KCksXG4gICAgICAgICAgICBpc0ludm9raW5nID0gc2hvdWxkSW52b2tlKHRpbWUpO1xuXG4gICAgICAgIGxhc3RBcmdzID0gYXJndW1lbnRzO1xuICAgICAgICBsYXN0VGhpcyA9IHRoaXM7XG4gICAgICAgIGxhc3RDYWxsVGltZSA9IHRpbWU7XG5cbiAgICAgICAgaWYgKGlzSW52b2tpbmcpIHtcbiAgICAgICAgICBpZiAodGltZXJJZCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICByZXR1cm4gbGVhZGluZ0VkZ2UobGFzdENhbGxUaW1lKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG1heGluZykge1xuICAgICAgICAgICAgLy8gSGFuZGxlIGludm9jYXRpb25zIGluIGEgdGlnaHQgbG9vcC5cbiAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lcklkKTtcbiAgICAgICAgICAgIHRpbWVySWQgPSBzZXRUaW1lb3V0KHRpbWVyRXhwaXJlZCwgd2FpdCk7XG4gICAgICAgICAgICByZXR1cm4gaW52b2tlRnVuYyhsYXN0Q2FsbFRpbWUpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGltZXJJZCA9PT0gdW5kZWZpbmV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mFsdWUgdG8gaW5zcGVjdC5cbiAgICAgKiBAcmV0dXJucyB7QXJyYXl9IFJldHVybnMgdGhlIGNhc3QgYXJyYXkuXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8uY2FzdEFycmF5KDEpO1xuICAgICAqIC8vID0+IFsxXVxuICAgICAqXG4gICAgICogXy5jYXN0QXJyYXkoeyAnYSc6IDEgfSk7XG4gICAgICogLy8gPT4gW3sgJ2EnOiAxIH1dXG4gICAgICpcbiAgICAgKiBfLmNhc3RBcnJheSgnYWJjJyk7XG4gICAgICogLy8gPT4gWydhYmMnXVxuICAgICAqXG4gICAgICogXy5jYXN0QXJyYXkobnVsbCk7XG4gICAgICogLy8gPT4gW251bGxdXG4gICAgICpcbiAgICAgKiBfLmNhc3RBcnJheSh1bmRlZmluZWQpO1xuICAgICAqIC8vID0+IFt1bmRlZmluZWRdXG4gICAgICpcbiAgICAgKiBfLmNhc3RBcnJheSgpO1xuICAgICAqIC8vID0+IFtdXG4gICAgICpcbiAgICAgKiB2YXIgYXJyYXkgPSBbMSwgMiwgM107XG4gICAgICogY29uc29sZS5sb2coXy5jYXN0QXJyYXkoYXJyYXkpID09PSBhcnJheSk7XG4gICAgICogLy8gPT4gdHJ1ZVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIGNhc3RBcnJheSgpIHtcbiAgICAgIGlmICghYXJndW1lbnRzLmxlbmd0aCkge1xuICAgICAgICByZXR1cm4gW107XG4gICAgICB9XG4gICAgICB2YXIgdmFsdWUgPSBhcmd1bWVudHNbMF07XG4gICAgICByZXR1cm4gaXNBcnJheSh2YWx1ZSkgPyB2YWx1ZSA6IFt2YWx1ZV07XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ3JlYXRlcyBhIHNoYWxsb3cgY2xvbmUgb2YgYHZhbHVlYC5cbiAgICAgKlxuICAgICAqICoqTm90ZToqKiBUaGlzIG1ldGhvZCBpcyBsb29zZWx5IGJhc2VkIG9uIHRoZVxuICAgIC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AgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIF8udG9BcnJheSh7ICdhJzogMSwgJ2InOiAyIH0pO1xuICAgICAqIC8vID0+IFsxLCAyXVxuICAgICAqXG4gICAgICogXy50b0FycmF5KCdhYmMnKTtcbiAgICAgKiAvLyA9PiBbJ2EnLCAnYicsICdjJ11cbiAgICAgKlxuICAgICAqIF8udG9BcnJheSgxKTtcbiAgICAgKiAvLyA9PiBbXVxuICAgICAqXG4gICAgICogXy50b0FycmF5KG51bGwpO1xuICAgICAqIC8vID0+IFtdXG4gICAgICovXG4gICAgZnVuY3Rpb24gdG9BcnJheSh2YWx1ZSkge1xuICAgICAgaWYgKCF2YWx1ZSkge1xuICAgICAgICByZXR1cm4gW107XG4gICAgICB9XG4gICAgICBpZiAoaXNBcnJheUxpa2UodmFsdWUpKSB7XG4gICAgICAgIHJldHVybiBpc1N0cmluZyh2YWx1ZSkgPyBzdHJpbmdUb0FycmF5KHZhbHVlKSA6IGNvcHlBcnJheSh2YWx1ZSk7XG4gICAgICB9XG4gICAgICBpZiAoc3ltSXRlcmF0b3IgJiYgdmFsdWVbc3ltSXRlcmF0b3JdKSB7XG4gICAgICAgIHJldHVybiBpdGVyYXRvclRvQXJyYXkodmFsdWVbc3ltSXRlcmF0b3JdKCkpO1xuICAgICAgfVxuICAgICAgdmFyIHRhZyA9IGdldFRhZyh2YWx1ZSksXG4gICAgICAgICAgZnVuYyA9IHRhZyA9PSBtYXBUYWcgPyBtYXBUb0FycmF5IDogKHRhZyA9PSBzZXRUYWcgPyBzZXRUb0FycmF5IDogdmFsdWVzKTtcblxuICAgICAgcmV0dXJuIGZ1bmModmFsdWUpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIENvbnZlcnRzIGB2YWx1ZWAgdG8gYSBmaW5pdGUgbnVtYmVyLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMTIuMFxuICAgICAqIE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gICAgICpcbiAgICAgKiBmdW5jdGlvbiBGb28oKSB7XG4gICAgICogICB0aGlzLmEgPSBfLmNvbnN0YW50KCdhJyk7XG4gICAgICogICB0aGlzLmIgPSBfLmNvbnN0YW50KCdiJyk7XG4gICAgICogfVxuICAgICAqXG4gICAgICogRm9vLnByb3RvdHlwZS5jID0gXy5jb25zdGFudCgnYycpO1xuICAgICAqXG4gICAgICogXy5mdW5jdGlvbnMobmV3IEZvbyk7XG4gICAgICogLy8gPT4gWydhJywgJ2InXVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIGZ1bmN0aW9ucyhvYmplY3QpIHtcbiAgICAgIHJldHVybiBvYmplY3QgPT0gbnVsbCA/IFtdIDogYmFzZUZ1bmN0aW9ucyhvYmplY3QsIGtleXMob2JqZWN0KSk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ3JlYXRlcyBhbiBhcnJheSBvZiBmdW5jdGlvbiBwcm9wZXJ0eSBuYW1lcyBmcm9tIG93biBhbmQgaW5oZXJpdGVkXG4gICAgICogZW51bWVyYWJsZSBwcm9wZXJ0aWVzIG9mIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQHNpbmNlIDQuMC4wXG4gICAgICogQGNhdGVnb3J5IE9iamVjdFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBvYmplY3QgVGhlIG9iamVjdCB0byBpbnNwZWN0LlxuICAgICAqIEByZXR1cm5zIHtBcnJheX0gUmV0dXJucyB0aGUgZnVuY3Rpb24gbmFtZXMuXG4gICAgICogQHNlZSBfLmZ1bmN0aW9uc1xuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiBmdW5jdGlvbiBGb28oKSB7XG4gICAgICogICB0aGlzLmEgPSBfLmNvbnN0YW50KCdhJyk7XG4gICAgICogICB0aGlzLmIgPSBfLmNvbnN0YW50KCdiJyk7XG4gICAgICogfVxuICAgICAqXG4gICAgIC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AgKiAvLyA9PiAyNFxuICAgICAqL1xuICAgIHZhciBtdWx0aXBseSA9IGNyZWF0ZU1hdGhPcGVyYXRpb24oZnVuY3Rpb24obXVsdGlwbGllciwgbXVsdGlwbGljYW5kKSB7XG4gICAgICByZXR1cm4gbXVsdGlwbGllciAqIG11bHRpcGxpY2FuZDtcbiAgICB9LCAxKTtcblxuICAgIC8qKlxuICAgICAqIENvbXB1dGVzIGBudW1iZXJgIHJvdW5kZWQgdG8gYHByZWNpc2lvbmAuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgMy4xMC4wXG4gICAgICogQGNhdGVnb3J5IE1hdGhcbiAgICAgKiBAcGFyYW0ge251bWJlcn0gbnVtYmVyIFRoZSBudW1iZXIgdG8gcm91bmQuXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IFtwcmVjaXNpb249MF0gVGhlIHByZWNpc2lvbiB0byByb3VuZCB0by5cbiAgICAgKiBAcmV0dXJucyB7bnVtYmVyfSBSZXR1cm5zIHRoZSByb3VuZGVkIG51bWJlci5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogXy5yb3VuZCg0LjAwNik7XG4gICAgICogLy8gPT4gNFxuICAgICAqXG4gICAgICogXy5yb3VuZCg0LjAwNiwgMik7XG4gICAgICogLy8gPT4gNC4wMVxuICAgICAqXG4gICAgICogXy5yb3VuZCg0MDYwLCAtMik7XG4gICAgICogLy8gPT4gNDEwMFxuICAgICAqL1xuICAgIHZhciByb3VuZCA9IGNyZWF0ZVJvdW5kKCdyb3VuZCcpO1xuXG4gICAgLyoqXG4gICAgICogU3VidHJhY3QgdHdvIG51bWJlcnMuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAc2luY2UgNC4wLjBcbiAgICAgKiBAY2F0ZWdvcnkgTWF0aFxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB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tbGluZSBuby1wcm90b1xuICAgICAgICB9XG4gICAgICAgIDogbnVsbFxuKTtcblxuZnVuY3Rpb24gYWRkTnVtZXJpY1NlcGFyYXRvcihudW0sIHN0cikge1xuICAgIGlmIChcbiAgICAgICAgbnVtID09PSBJbmZpbml0eVxuICAgICAgICB8fCBudW0gPT09IC1JbmZpbml0eVxuICAgICAgICB8fCBudW0gIT09IG51bVxuICAgICAgICB8fCAobnVtICYmIG51bSA+IC0xMDAwICYmIG51bSA8IDEwMDApXG4gICAgICAgIHx8ICR0ZXN0LmNhbGwoL2UvLCBzdHIpXG4gICAgKSB7XG4gICAgICAgIHJldHVybiBzdHI7XG4gICAgfVxuICAgIHZhciBzZXBSZWdleCA9IC9bMC05XSg/PSg/OlswLTldezN9KSsoPyFbMC05XSkpL2c7XG4gICAgaWYgKHR5cGVvZiBudW0gPT09ICdudW1iZXInKSB7XG4gICAgICAgIHZhciBpbnQgPSBudW0gPCAwID8gLSRmbG9vcigtbnVtKSA6ICRmbG9vcihudW0pOyAvLyB0cnVuYyhudW0pXG4gICAgICAgIGlmIChpbnQgIT09IG51bSkge1xuICAgICAgICAgICAgdmFyIGludFN0ciA9IFN0cmluZyhpbnQpO1xuICAgICAgICAgICAgdmFyIGRlYyA9ICRzbGljZS5jYWxsKHN0ciwgaW50U3RyLmxlbmd0aCArIDEpO1xuICAgICAgICAgICAgcmV0dXJuICRyZXBsYWNlLmNhbGwoaW50U3RyLCBzZXBSZWdleCwgJyQmXycpICsgJy4nICsgJHJlcGxhY2UuY2FsbCgkcmVwbGFjZS5jYWxsKGRlYywgLyhbMC05XXszfSkvZywgJyQmXycpLCAvXyQvLCAnJyk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuICRyZXBsYWNlLmNhbGwoc3RyLCBzZXBSZWdleCwgJyQmXycpO1xufVxuXG52YXIgdXRpbEluc3BlY3QgPSByZXF1aXJlKCcuL3V0aWwuaW5zcGVjdCcpO1xudmFyIGluc3BlY3RDdXN0b20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IHJldHVybiBpc0FycmF5KG9iaikgPyAnW0FycmF5XScgOiAnW09iamVjdF0nO1xuICAgIH1cblxuICAgIHZhciBpbmRlbnQgPSBnZXRJbmRlbnQob3B0cywgZGVwdGgpO1xuXG4gICAgaWYgKHR5cGVvZiBzZWVuID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICBzZWVuID0gW107XG4gICAgfSBlbHNlIGlmIChpbmRleE9mKHNlZW4sIG9iaikgPj0gMCkge1xuICAgICAgICByZXR1cm4gJ1tDaXJjdWxhcl0nO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGluc3BlY3QodmFsdWUsIGZyb20sIG5vSW5kZW50KSB7XG4gICAgICAgIGlmIChmcm9tKSB7XG4gICAgICAgICAgICBzZWVuID0gJGFyclNsaWNlLmNhbGwoc2Vlbik7XG4gICAgICAgICAgICBzZWVuLnB1c2goZnJvbSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG5vSW5kZW50KSB7XG4gICAgICAgICAgICB2YXIgbmV3T3B0cyA9IHtcbiAgICAgICAgICAgICAgICBkZXB0aDogb3B0cy5kZXB0aFxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmIChoYXMob3B0cywgJ3F1b3RlU3R5bGUnKSkge1xuICAgICAgICAgICAgICAgIG5ld09wdHMucXVvdGVTdHlsZSA9IG9wdHMucXVvdGVTdHlsZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBpbnNwZWN0Xyh2YWx1ZSwgbmV3T3B0cywgZGVwdGggKyAxLCBzZWVuKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gaW5zcGVjdF8odmFsdWUsIG9wdHMsIGRlcHRoICsgMSwgc2Vlbik7XG4gICAgfVxuXG4gICAgaWYgKHR5cGVvZiBvYmogPT09ICdmdW5jdGlvbicgJiYgIWlzUmVnRXhwKG9iaikpIHsgLy8gaW4gb2xkZXIgZW5naW5lcywgcmVnZXhlcyBhcmUgY2FsbGFibGVcbiAg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rlcy5sZW5ndGgpIHsgcyArPSAnLi4uJzsgfVxuICAgICAgICBzICs9ICc8LycgKyAkdG9Mb3dlckNhc2UuY2FsbChTdHJpbmcob2JqLm5vZGVOYW1lKSkgKyAnPic7XG4gICAgICAgIHJldHVybiBzO1xuICAgIH1cbiAgICBpZiAoaXNBcnJheShvYmopKSB7XG4gICAgICAgIGlmIChvYmoubGVuZ3RoID09PSAwKSB7IHJldHVybiAnW10nOyB9XG4gICAgICAgIHZhciB4cyA9IGFyck9iaktleXMob2JqLCBpbnNwZWN0KTtcbiAgICAgICAgaWYgKGluZGVudCAmJiAhc2luZ2xlTGluZVZhbHVlcyh4cykpIHtcbiAgICAgICAgICAgIHJldHVybiAnWycgKyBpbmRlbnRlZEpvaW4oeHMsIGluZGVudCkgKyAnXSc7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuICdbICcgKyAkam9pbi5jYWxsKHhzLCAnLCAnKSArICcgXSc7XG4gICAgfVxuICAgIGlmIChpc0Vycm9yKG9iaikpIHtcbiAgICAgICAgdmFyIHBhcnRzID0gYXJyT2JqS2V5cyhvYmosIGluc3BlY3QpO1xuICAgICAgICBpZiAoISgnY2F1c2UnIGluIEVycm9yLnByb3RvdHlwZSkgJiYgJ2NhdXNlJyBpbiBvYmogJiYgIWlzRW51bWVyYWJsZS5jYWxsKG9iaiwgJ2NhdXNlJykpIHtcbiAgICAgICAgICAgIHJldHVybiAneyBbJyArIFN0cmluZyhvYmopICsgJ10gJyArICRqb2luLmNhbGwoJGNvbmNhdC5jYWxsKCdbY2F1c2VdOiAnICsgaW5zcGVjdChvYmouY2F1c2UpLCBwYXJ0cyksICcsICcpICsgJyB9JztcbiAgICAgICAgfVxuICAgICAgICBpZiAocGFydHMubGVuZ3RoID09PSAwKSB7IHJldHVybiAnWycgKyBTdHJpbmcob2JqKSArICddJzsgfVxuICAgICAgICByZXR1cm4gJ3sgWycgKyBTdHJpbmcob2JqKSArICddICcgKyAkam9pbi5jYWxsKHBhcnRzL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FyIFpfRklYRUQgICAgICAgICAgICAgICA9IDQ7XG52YXIgWl9ERUZBVUxUX1NUUkFURUdZICAgID0gMDtcblxuLyogUG9zc2libGUgdmFsdWVzIG9mIHRoZSBkYXRhX3R5cGUgZmllbGQgKHRob3VnaCBzZWUgaW5mbGF0ZSgpKSAqL1xuLy92YXIgWl9CSU5BUlkgICAgICAgICAgICAgID0gMDtcbi8vdmFyIFpfVEVYVCAgICAgICAgICAgICAgICA9IDE7XG4vL3ZhciBaX0FTQ0lJICAgICAgICAgICAgICAgPSAxOyAvLyA9IFpfVEVYVFxudmFyIFpfVU5LTk9XTiAgICAgICAgICAgICA9IDI7XG5cblxuLyogVGhlIGRlZmxhdGUgY29tcHJlc3Npb24gbWV0aG9kICovXG52YXIgWl9ERUZMQVRFRCAgPSA4O1xuXG4vKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuXG5cbnZhciBNQVhfTUVNX0xFVkVMID0gOTtcbi8qIE1heGltdW0gdmFsdWUgZm9yIG1lbUxldmVsIGluIGRlZmxhdGVJbml0MiAqL1xudmFyIE1BWF9XQklUUyA9IDE1O1xuLyogMzJLIExaNzcgd2luZG93ICovXG52YXIgREVGX01FTV9MRVZFTCA9IDg7XG5cblxudmFyIExFTkdUSF9DT0RFUyAgPSAyOTtcbi8qIG51bWJlciBvZiBsZW5ndGggY29kZXMsIG5vdCBjb3VudGluZyB0aGUgc3BlY2lhbCBFTkRfQkxPQ0sgY29kZSAqL1xudmFyIExJVEVSQUxTICAgICAgPSAyNTY7XG4vKiBudW1iZXIgb2YgbGl0ZXJhbCBieXRlcyAwLi4yNTUgKi9cbnZhciBMX0NPREVTICAgICAgID0gTElURVJBTFMgKyAxICsgTEVOR1RIX0NPREVTO1xuLyogbnVtYmVyIG9mIExpdGVyYWwgb3IgTGVuZ3RoIGNvZGVzLCBpbmNsdWRpbmcgdGhlIEVORF9CTE9DSy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aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJlxuICAgICAgICAgICAgIF93aW5bKytzY2FuXSA9PT0gX3dpblsrK21hdGNoXSAmJiBfd2luWysrc2Nhbl0gPT09IF93aW5bKyttYXRjaF0gJiZcbiAgICAgICAgICAgICBzY2FuIDwgc3RyZW5kKTtcblxuICAgIC8vIEFzc2VydChzY2FuIDw9IHMtPndpbmRvdysodW5zaWduZWQpKHMtPndpbmRvd19zaXplLTEpLCBcIndpbGQgc2NhblwiKTtcblxuICAgIGxlbiA9IE1BWF9NQVRDSCAtIChzdHJlbmQgLSBzY2FuKTtcbiAgICBzY2FuID0gc3RyZW5kIC0gTUFYX01BVENIO1xuXG4gICAgaWYgKGxlbiA+IGJlc3RfbGVuKSB7XG4gICAgICBzLm1hdGNoX3N0YXJ0ID0gY3VyX21hdGNoO1xuICAgICAgYmVzdF9sZW4gPSBsZW47XG4gICAgICBpZiAobGVuID49IG5pY2VfbWF0Y2gpIHtcbiAgICAgICAgYnJlYWs7XG4gICAgICB9XG4gICAgICBzY2FuX2VuZDEgID0gX3dpbltzY2FuICsgYmVzdF9sZW4gLSAxXTtcbiAgICAgIHNjYW5fZW5kICAgPSBfd2luW3NjYW4gKyBiZXN0X2xlbl07XG4gICAgfVxuICB9IHdoaWxlICgoY3VyX21hdGNoID0gcHJldltjdXJfbWF0Y2ggJiB3bWFza10pID4gbGltaXQgJiYgLS1jaGFpbl9sZW5ndGggIT09IDApO1xuXG4gIGlmIChiZXN0X2xlbiA8PSBzLmxvb2thaGVhZCkge1xuICAgIHJldHVybiBiZXN0X2xlbjtcbiAgfVxuICByZXR1cm4gcy5sb29rYWhlYWQ7XG59XG5cblxuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4gKiBGaWxsIHRoZSB3aW5kb3cgd2hlbiB0aGUgbG9va2FoZWFkIGJlY29tZXMgaW5zdWZmaWNpZ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dHJhdGVneSA+PSBaX0hVRkZNQU5fT05MWSB8fCBzLmxldmVsIDwgMiA/XG4gICAgICAgICAgICAgICAgICAgICA0IDogMCkpO1xuICAgICAgICBwdXRfYnl0ZShzLCBPU19DT0RFKTtcbiAgICAgICAgcy5zdGF0dXMgPSBCVVNZX1NUQVRFO1xuICAgICAgfVxuICAgICAgZWxzZSB7XG4gICAgICAgIHB1dF9ieXRlKHMsIChzLmd6aGVhZC50ZXh0ID8gMSA6IDApICtcbiAgICAgICAgICAgICAgICAgICAgKHMuZ3poZWFkLmhjcmMgPyAyIDogMCkgK1xuICAgICAgICAgICAgICAgICAgICAoIXMuZ3poZWFkLmV4dHJhID8gMCA6IDQpICtcbiAgICAgICAgICAgICAgICAgICAgKCFzLmd6aGVhZC5uYW1lID8gMCA6IDgpICtcbiAgICAgICAgICAgICAgICAgICAgKCFzLmd6aGVhZC5jb21tZW50ID8gMCA6IDE2KVxuICAgICAgICApO1xuICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC50aW1lICYgMHhmZik7XG4gICAgICAgIHB1dF9ieXRlKHMsIChzLmd6aGVhZC50aW1lID4+IDgpICYgMHhmZik7XG4gICAgICAgIHB1dF9ieXRlKHMsIChzLmd6aGVhZC50aW1lID4+IDE2KSAmIDB4ZmYpO1xuICAgICAgICBwdXRfYnl0ZShzLCAocy5nemhlYWQudGltZSA+PiAyNCkgJiAweGZmKTtcbiAgICAgICAgcHV0X2J5dGUocywgcy5sZXZlbCA9PT0gOSA/IDIgOlxuICAgICAgICAgICAgICAgICAgICAocy5zdHJhdGVneSA+PSBaX0hVRkZNQU5fT05MWSB8fCBzLmxldmVsIDwgMiA/XG4gICAgICAgICAgICAgICAgICAgICA0IDogMCkpO1xuICAgICAgICBwdXRfYnl0ZShzLCBzLmd6aGVhZC5vcyAmIDB4ZmYpO1xuICAgICAgICBpZiAocy5nemhlYWQuZXh0cmEgJiYgcy5nemhlYWQuZXh0cmEubGVuZ3RoKSB7XG4gICAgICAg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8gdXBkYXRlIGNyYyAqL1xuICAgICAgLy9pbnQgdmFsO1xuXG4gICAgICBkbyB7XG4gICAgICAgIGlmIChzLnBlbmRpbmcgPT09IHMucGVuZGluZ19idWZfc2l6ZSkge1xuICAgICAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykge1xuICAgICAgICAgICAgc3RybS5hZGxlciA9IGNyYzMyKHN0cm0uYWRsZXIsIHMucGVuZGluZ19idWYsIHMucGVuZGluZyAtIGJlZywgYmVnKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgZmx1c2hfcGVuZGluZyhzdHJtKTtcbiAgICAgICAgICBiZWcgPSBzLnBlbmRpbmc7XG4gICAgICAgICAgaWYgKHMucGVuZGluZyA9PT0gcy5wZW5kaW5nX2J1Zl9zaXplKSB7XG4gICAgICAgICAgICB2YWwgPSAxO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIC8vIEpTIHNwZWNpZmljOiBsaXR0bGUgbWFnaWMgdG8gYWRkIHplcm8gdGVybWluYXRvciB0byBlbmQgb2Ygc3RyaW5nXG4gICAgICAgIGlmIChzLmd6aW5kZXggPCBzLmd6aGVhZC5jb21tZW50Lmxlbmd0aCkge1xuICAgICAgICAgIHZhbCA9IHMuZ3poZWFkLmNvbW1lbnQuY2hhckNvZGVBdChzLmd6aW5kZXgrKykgJiAweGZmO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHZhbCA9IDA7XG4gICAgICAgIH1cbiAgICAgICAgcHV0X2J5dGUocywgdmFsKTtcbiAgICAgIH0gd2hpbGUgKHZhbCAhPT0gMCk7XG5cbiAgICAgIGlmIChzLmd6aGVhZC5oY3JjICYmIHMucGVuZGluZyA+IGJlZykge1xuICAgICAgICBzdHJtLmFkbGVyID0gY3JjMzIoc3RybS5hZGxlciwgcy5wZW5kaW5nX2J1Ziwgcy5wZW5kaW5nIC0gYmVnLCBiZWcpO1xu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IHVzaW5nIHdpbmRvdyAqL1xuICB2YXIgd2hhdmU7ICAgICAgICAgICAgICAgICAgLyogdmFsaWQgYnl0ZXMgaW4gdGhlIHdpbmRvdyAqL1xuICB2YXIgd25leHQ7ICAgICAgICAgICAgICAgICAgLyogd2luZG93IHdyaXRlIGluZGV4ICovXG4gIC8vIFVzZSBgc193aW5kb3dgIGluc3RlYWQgYHdpbmRvd2AsIGF2b2lkIGNvbmZsaWN0IHdpdGggaW5zdHJ1bWVudGF0aW9uIHRvb2xzXG4gIHZhciBzX3dpbmRvdzsgICAgICAgICAgICAgICAvKiBhbGxvY2F0ZWQgc2xpZGluZyB3aW5kb3csIGlmIHdzaXplICE9IDAgKi9cbiAgdmFyIGhvbGQ7ICAgICAgICAgICAgICAgICAgIC8qIGxvY2FsIHN0cm0uaG9sZCAqL1xuICB2YXIgYml0czsgICAgICAgICAgICAgICAgICAgLyogbG9jYWwgc3RybS5iaXRzICovXG4gIHZhciBsY29kZTsgICAgICAgICAgICAgICAgICAvKiBsb2NhbCBzdHJtLmxlbmNvZGUgKi9cbiAgdmFyIGRjb2RlOyAgICAgICAgICAgICAgICAgIC8qIGxvY2FsIHN0cm0uZGlzdGNvZGUgKi9cbiAgdmFyIGxtYXNrOyAgICAgICAgICAgICAgICAgIC8qIG1hc2sgZm9yIGZpcnN0IGxldmVsIG9mIGxlbmd0aCBjb2RlcyAqL1xuICB2YXIgZG1hc2s7ICAgICAgICAgICAgICAgICAgLyogbWFzayBmb3IgZmlyc3QgbGV2ZWwgb2YgZGlzdGFuY2UgY29kZXMgKi9cbiAgdmFyIGhlcmU7ICAgICAgICAgICAgICAgICAgIC8qIHJldHJpZXZlZCB0YWJsZSBlbnRyeSAqL1xuICB2YXIgb3A7ICAgICAgICAgICAgICAgICAgICAgLyogY29kZSBiaXRzLCBvcGVyYXRpb24sIGV4dHJhIGJpdHMsIG9yICovXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiAgd2luZG93IHBvc2l0aW9uL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CAweCUwMnhcXG5cIiwgaGVyZS52YWwpKTtcbiAgICAgICAgb3V0cHV0W19vdXQrK10gPSBoZXJlICYgMHhmZmZmLypoZXJlLnZhbCovO1xuICAgICAgfVxuICAgICAgZWxzZSBpZiAob3AgJiAxNikgeyAgICAgICAgICAgICAgICAgICAgIC8qIGxlbmd0aCBiYXNlICovXG4gICAgICAgIGxlbiA9IGhlcmUgJiAweGZmZmYvKmhlcmUudmFsKi87XG4gICAgICAgIG9wICY9IDE1OyAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIG51bWJlciBvZiBleHRyYSBiaXRzICovXG4gICAgICAgIGlmIChvcCkge1xuICAgICAgICAgIGlmIChiaXRzIDwgb3ApIHtcbiAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7XG4gICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgfVxuICAgICAgICAgIGxlbiArPSBob2xkICYgKCgxIDw8IG9wKSAtIDEpO1xuICAgICAgICAgIGhvbGQgPj4+PSBvcDtcbiAgICAgICAgICBiaXRzIC09IG9wO1xuICAgICAgICB9XG4gICAgICAgIC8vVHJhY2V2digoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgICAgbGVuZ3RoICV1XFxuXCIsIGxlbikpO1xuICAgICAgICBpZiAoYml0cyA8IDE1KSB7XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtfaW4rK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgaGVyZSA9IGRjb2RlW2hvbGQgJiBkbWFza107XG5cbiAgICAgICAgZG9kaXN0OlxuICAgICAgICBmb3IgKDs7KSB7IC8vIGdvdG8gZW11bGF0aW9uXG4gICAgICAgICAgb3AgPSBoZXJlID4+PiAyNC8qaGVyZS5iaXRzKi87XG4gICAgICAgICAgaG9sZCA+Pj49IG9wO1xuICAgICAgICAgIGJpdHMgLT0gb3A7XG4gICAgICAgICAgb3AgPSAoaGVyZSA+Pj4gMTYpICYgMHhmZi8qaGVyZS5vcCovO1xuXG4gICAgICAgICAgaWYgKG9wICYgMTYpIHsgICAgICAgICAgICAgICAgICAgICAgLyogZGlzdGFuY2UgYmFzZSAqL1xuICAgICAgICAgICAgZGlzdCA9IGhlcmUgJiAweGZmZmYvKmhlcmUudmFsKi87XG4gICAgICAgICAgICBvcCAmPSAxNTsgICAgICAgICAgICAgICAgICAgICAgIC8qIG51bWJlciBvZiBleHRyYSBiaXRzICovXG4gICAgICAgICAgICBpZiAoYml0cyA8IG9wKSB7XG4gICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7XG4gICAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgICAgaWYgKGJpdHMgPCBvcCkge1xuICAgICAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbX2luKytdIDw8IGJpdHM7XG4gICAgICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkaXN0ICs9IGhvbGQgJiAoKDEgPDwgb3ApIC0gMSk7XG4vLyNpZmRlZiBJTkZMQVRFX1NUUklDVFxuICAgICAgICAgICAgaWYgKGRpc3QgPiBkbWF4KSB7XG4gICAgICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgZGlzdGFuY2UgdG9vIGZhciBiYWNrJztcbiAgICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICAgICAgYnJlYWsgdG9wO1xuICAgICAgICAgICAgfVxuLy8jZW5kaWZcbiAgICAgICAgICAgIGhvbGQgPj4+PSBvcDtcbiAgICAgICAgICAgIGJpdHMgLT0gb3A7XG4gICAgICAgICAgICAvL1RyYWNldnYoKHN0ZGVyciwgXCJpbmZsYXRlOiAgICAgICAgIGRpc3RhbmNlICV1XFxuXCIsIGRpc3QpKTtcbiAgICAgICAgICAgIG9wID0gX291dCAtIGJlZzsgICAgICAgICAgICAgICAgLyogbWF4IGRpc3RhbmNlIGluIG91dHB1dCAqL1xuICAgICAgICAgICAgaWYgKGRpc3QgPiBvcCkgeyAgICAgICAgICAgICAgICAvKiBzZWUgaWYgY29weSBmcm9tIHdpbmRvdyAqL1xuICAgICAgICAgICAgICBvcCA9IGRpc3QgLSBvcDsgICAgICAgICAgICAgICAvKiBkaXN0YW5jZSBiYWNrIGluIHdpbmRvdyAqL1xuICAgICAgICAgICAgICBpZiAob3AgPiB3aGF2ZSkge1xuICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5zYW5lKSB7XG4gICAgICAgICAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIGRpc3RhbmNlIHRvbyBmYXIgYmFjayc7XG4gICAgICAgICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgICAgICAgYnJlYWsgdG9wO1xuICAgICAgICAgICAgICAgIH1cblxuLy8gKCEpIFRoaXMgYmxvY2sgaXMgZGlzYWJsZWQgaW4gemxpYiBkZWZhdWx0cyxcbi8vIGRvbid0IGVuYWJsZSBpdCBmb3IgYmluYXJ5IGNvbXBhdGliaWxpdHlcbi8vI2lmZGVmIElORkxBVEVfQUxMT1dfSU5WQUxJRF9ESVNUQU5DRV9UT09GQVJfQVJSUlxuLy8gICAgICAgICAgICAgICAgaWYgKGxlbiA8PSBvcCAtIHdoYXZlKSB7XG4vLyAgICAgICAgICAgICAgICAgIGRvIHtcbi8vICAgICAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IDA7XG4vLyAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tbGVuKTtcbi8vICAgICAgICAgICAgICAgICAgY29udGludWUgdG9wO1xuLy8gICAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgICAgbGVuIC09IG9wIC0gd2hhdmU7XG4vLyAgICAgICAgICAgICAgICBkbyB7XG4vLyAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gMDtcbi8vICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3AgPiB3aGF2ZSk7XG4vLyAgICAgICAgICAgICAgICBpZiAob3AgPT09IDApIHtcbi8vICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0O1xuLy8gICAgICAgICAgICAgICAgICBkbyB7XG4vLyAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTtcbi8vICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1sZW4pO1xuLy8gICAgICAgICAgICAgICAgICBjb250aW51ZSB0b3A7XG4vLyAgICAgICAgICAgICAgICB9XG4vLyNlbmRpZlxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGZyb20gPSAwOyAvLyB3aW5kb3cgaW5kZXhcbiAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBzX3dpbmRvdztcbiAgICAgICAgICAgICAgaWYgKHduZXh0ID09PSAwKSB7ICAgICAgICAgICAvKiB2ZXJ5IGNvbW1vbiBjYXNlICovXG4gICAgICAgICAgICAgICAgZnJvbSArPSB3c2l6ZSAtIG9wO1xuICAgICAgICAgICAgICAgIGlmIChvcCA8IGxlbikgeyAgICAgICAgIC8qIHNvbWUgZnJvbSB3aW5kb3cgKi9cbiAgICAgICAgICAgICAgICAgIGxlbiAtPSBvcDtcbiAgICAgICAgICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdO1xuICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoLS1vcCk7XG4gICAgICAgICAgICAgICAgICBmcm9tID0gX291dCAtIGRpc3Q7ICAvKiByZXN0IGZyb20gb3V0cHV0ICovXG4gICAgICAgICAgICAgICAgICBmcm9tX3NvdXJjZSA9IG91dHB1dDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgZWxzZSBpZiAod25leHQgPCBvcCkgeyAgICAgIC8qIHdyYXAgYXJvdW5kIHdpbmRvdyAqL1xuICAgICAgICAgICAgICAgIGZyb20gKz0gd3NpemUgKyB3bmV4dCAtIG9wO1xuICAgICAgICAgICAgICAgIG9wIC09IHduZXh0O1xuICAgICAgICAgICAgICAgIGlmIChvcCA8IGxlbikgeyAgICAgICAgIC8qIHNvbWUgZnJvbSBlbmQgb2Ygd2luZG93ICovXG4gICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7XG4gICAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApO1xuICAgICAgICAgICAgICAgICAgZnJvbSA9IDA7XG4gICAgICAgICAgICAgICAgICBpZiAod25leHQgPCBsZW4pIHsgIC8qIHNvbWUgZnJvbSBzdGFydCBvZiB3aW5kb3cgKi9cbiAgICAgICAgICAgICAgICAgICAgb3AgPSB3bmV4dDtcbiAgICAgICAgICAgICAgICAgICAgbGVuIC09IG9wO1xuICAgICAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBzX3dpbmRvd1tmcm9tKytdO1xuICAgICAgICAgICAgICAgICAgICB9IHdoaWxlICgtLW9wKTtcbiAgICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OyAgICAgIC8qIHJlc3QgZnJvbSBvdXRwdXQgKi9cbiAgICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGVsc2UgeyAgICAgICAgICAgICAgICAgICAgICAvKiBjb250aWd1b3VzIGluIHdpbmRvdyAqL1xuICAgICAgICAgICAgICAgIGZyb20gKz0gd25leHQgLSBvcDtcbiAgICAgICAgICAgICAgICBpZiAob3AgPCBsZW4pIHsgICAgICAgICAvKiBzb21lIGZyb20gd2luZG93ICovXG4gICAgICAgICAgICAgICAgICBsZW4gLT0gb3A7XG4gICAgICAgICAgICAgICAgICBkbyB7XG4gICAgICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gc193aW5kb3dbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKC0tb3ApO1xuICAgICAgICAgICAgICAgICAgZnJvbSA9IF9vdXQgLSBkaXN0OyAgLyogcmVzdCBmcm9tIG91dHB1dCAqL1xuICAgICAgICAgICAgICAgICAgZnJvbV9zb3VyY2UgPSBvdXRwdXQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHdoaWxlIChsZW4gPiAyKSB7XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdO1xuICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IGZyb21fc291cmNlW2Zyb20rK107XG4gICAgICAgICAgICAgICAgbGVuIC09IDM7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKGxlbikge1xuICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gZnJvbV9zb3VyY2VbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBpZiAobGVuID4gMSkge1xuICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgIGZyb20gPSBfb3V0IC0gZGlzdDsgICAgICAgICAgLyogY29weSBkaXJlY3QgZnJvbSBvdXRwdXQgKi9cbiAgICAgICAgICAgICAgZG8geyAgICAgICAgICAgICAgICAgICAgICAgIC8qIG1pbmltdW0gbGVuZ3RoIGlzIHRocmVlICovXG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBvdXRwdXRbX291dCsrXSA9IG91dHB1dFtmcm9tKytdO1xuICAgICAgICAgICAgICAgIG91dHB1dFtfb3V0KytdID0gb3V0cHV0W2Zyb20rK107XG4gICAgICAgICAgICAgICAgbGVuIC09IDM7XG4gICAgICAgICAgICAgIH0gd2hpbGUgKGxlbiA+IDIpO1xuICAgICAgICAgICAgICBpZiAobGVuKSB7XG4gICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICBpZiAobGVuID4gMSkge1xuICAgICAgICAgICAgICAgICAgb3V0cHV0W19vdXQrK10gPSBvdXRwdXRbZnJvbSsrXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgZWxzZSBpZiAoKG9wICYgNjQpID09PSAwKSB7ICAgICAgICAgIC8qIDJuZCBsZXZlbCBkaXN0YW5jZSBjb2RlICovXG4gICAgICAgICAgICBoZXJlID0gZGNvZGVbKGhlcmUgJiAweGZmZmYpLypoZXJlLnZhbCovICsgKGhvbGQgJiAoKDEgPDwgb3ApIC0gMSkpXTtcbiAgICAgICAgICAgIGNvbnRpbnVlIGRvZGlzdDtcbiAgICAgICAgICB9XG4gICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIGRpc3RhbmNlIGNvZGUnO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICAgIGJyZWFrIHRvcDtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBicmVhazsgLy8gbmVlZCB0byBlbXVsYXRlIGdvdG8gdmlhIFwiY29udGludWVcIlxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBlbHNlIGlmICgob3AgJiA2NCkgPT09IDApIHsgICAgICAgICAgICAgIC8qIDJuZCBsZXZlbCBsZW5ndGggY29kZSAqL1xuICAgICAgICBoZXJlID0gbGNvZGVbKGhlcmUgJiAweGZmZmYpLypoZXJlLnZhbCovICsgKGhvbGQgJiAoKDEgPDwgb3ApIC0gMSkpXTtcbiAgICAgICAgY29udGludWUgZG9sZW47XG4gICAgICB9XG4gICAgICBlbHNlIGlmIChvcCAmIDMyKSB7ICAgICAgICAgICAgICAgICAgICAgLyogZW5kLW9mLWJsb2NrICovXG4gICAgICAgIC8vVHJhY2V2digoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgICAgZW5kIG9mIGJsb2NrXFxuXCIpKTtcbiAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7XG4gICAgICAgIGJyZWFrIHRvcDtcbiAgICAgIH1cbiAgICAgIGVsc2Uge1xuICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIGxpdGVyYWwvbGVuZ3RoIGNvZGUnO1xuICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICBicmVhayB0b3A7XG4gICAgICB9XG5cbiAgICAgIGJyZWFrOyAvLyBuZWVkIHRvIGVtdWxhdGUgZ290byB2aWEgXCJjb250aW51ZVwiXG4gICAgfVxuICB9IHdoaWxlIChfaW4gPCBsYXN0ICYmIF9vdXQgPCBlbmQpO1xuXG4gIC8qIHJldHVybiB1bnVzZWQgYnl0ZXMgKG9uIGVudHJ5LCBiaXRzIDwgOCwgc28gaW4gd29uJ3QgZ28gdG9vIGZhciBiYWNrKSAqL1xuICBsZW4gPSBiaXRzID4+ID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yIExFTlMgPSAxO1xudmFyIERJU1RTID0gMjtcblxuLyogUHVibGljIGNvbnN0YW50cyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki9cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG5cblxuLyogQWxsb3dlZCBmbHVzaCB2YWx1ZXM7IHNlZSBkZWZsYXRlKCkgYW5kIGluZmxhdGUoKSBiZWxvdyBmb3IgZGV0YWlscyAqL1xuLy92YXIgWl9OT19GTFVTSCAgICAgID0gMDtcbi8vdmFyIFpfUEFSVElBTF9GTFVTSCA9IDE7XG4vL3ZhciBaX1NZTkNfRkxVU0ggICAgPSAyO1xuLy92YXIgWl9GVUxMX0ZMVVNIICAgID0gMztcbnZhciBaX0ZJTklTSCAgICAgICAgPSA0O1xudmFyIFpfQkxPQ0sgICAgICAgICA9IDU7XG52YXIgWl9UUkVFUyAgICAgICAgID0gNjtcblxuXG4vKiBSZXR1cm4gY29kZXMgZm9yIHRoZSBjb21wcmVzc2lvbi9kZWNvbXByZXNzaW9uIGZ1bmN0aW9ucy4gTmVnYXRpdmUgdmFsdWVzXG4gKiBhcmUgZXJyb3JzLCBwb3NpdGl2ZSB2YWx1ZXMgYXJlIHVzZWQgZm9yIHNwZWNpYWwgYnV0IG5vcm1hbCBldmVudHMuXG4gKi9cbnZhciBaX09LICAgICAgICAgICAgPSAwO1xudmFyIFpfU1RSRUFNX0VORCAgICA9IDE7XG52YXIgWl9ORUVEX0RJQ1QgICAgID0gMjtcbi8vdmFyIFpfRVJSTk8gICAgICAgICA9IC0xO1xudmFyIFpfU1RSRUFNX0VSUk9SICA9IC0yO1xudmFyIFpfREFUQV9FUlJPUiAgICA9IC0zO1xudmFyIFpfTUVNX0VSUk9SICAgICA9IC00O1xudmFyIFpfQlVGX0VSUk9SICAgICA9IC01O1xuLy92YXIgWl9WRVJTSU9OX0VSUk9SID0gLTY7XG5cbi8qIFRoZSBkZWZsYXRlIGNvbXByZXNzaW9uIG1ldGhvZCAqL1xudmFyIFpfREVGTEFURUQgID0gODtcblxuXG4vKiBTVEFURVMgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki9cblxuXG52YXIgICAgSEVBRCA9IDE7ICAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIG1hZ2ljIGhlYWRlciAqL1xudmFyICAgIEZMQUdTID0gMjsgICAgICAvKiBpOiB3YWl0aW5nIGZvciBtZXRob2QgYW5kIGZsYWdzIChnemlwKSAqL1xudmFyICAgIFRJTUUgPSAzOyAgICAgICAvKiBpOiB3YWl0aW5nIGZvciBtb2RpZmljYXRpb24gdGltZSAoZ3ppcCkgKi9cbnZhciAgICBPUyA9IDQ7ICAgICAgICAgLyogaTogd2FpdGluZyBmb3IgZXh0cmEgZmxhZ3MgYW5kIG9wZXJhdGluZyBzeXN0ZW0gKGd6aXApICovXG52YXIgICAgRVhMRU4gPSA1OyAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIGV4dHJhIGxlbmd0aCAoZ3ppcCkgKi9cbnZhciAgICBFWFRSQSA9IDY7ICAgICAgLyogaTogd2FpdGluZyBmb3IgZXh0cmEgYnl0ZXMgKGd6aXApICovXG52YXIgICAgTkFNRSA9IDc7ICAgICAgIC8qIGk6IHdhaXRpbmcgZm9yIGVuZCBvZiBmaWxlIG5hbWUgKGd6aXApICovXG52YXIgICAgQ09NTUVOVCA9IDg7ICAgIC8qIGk6IHdhaXRpbmcgZm9yIGVuZCBvZiBjb21tZW50IChnemlwKSAqL1xudmFyICAgIEhDUkMgPSA5OyAgICAgICAvKiBpOiB3YWl0aW5nIGZvciBoZWFkZXIgY3JjI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gIC8qIGk6IHNhbWUgYXMgTEVOIGJlbG93LCBidXQgb25seSBmaXJzdCB0aW1lIGluICovXG52YXIgICAgICAgICAgICBMRU4gPSAyMTsgICAgICAgLyogaTogd2FpdGluZyBmb3IgbGVuZ3RoL2xpdC9lb2IgY29kZSAqL1xudmFyICAgICAgICAgICAgTEVORVhUID0gMjI7ICAgIC8qIGk6IHdhaXRpbmcgZm9yIGxlbmd0aCBleHRyYSBiaXRzICovXG52YXIgICAgICAgICAgICBESVNUID0gMjM7ICAgICAgLyogaTogd2FpdGluZyBmb3IgZGlzdGFuY2UgY29kZSAqL1xudmFyICAgICAgICAgICAgRElTVEVYVCA9IDI0OyAgIC8qIGk6IHdhaXRpbmcgZm9yIGRpc3RhbmNlIGV4dHJhIGJpdHMgKi9cbnZhciAgICAgICAgICAgIE1BVENIID0gMjU7ICAgICAvKiBvOiB3YWl0aW5nIGZvciBvdXRwdXQgc3BhY2UgdG8gY29weSBzdHJpbmcgKi9cbnZhciAgICAgICAgICAgIExJVCA9IDI2OyAgICAgICAvKiBvOiB3YWl0aW5nIGZvciBvdXRwdXQgc3BhY2UgdG8gd3JpdGUgbGl0ZXJhbCAqL1xudmFyICAgIENIRUNLID0gMjc7ICAgICAvKiBpOiB3YWl0aW5nIGZvciAzMi1iaXQgY2hlY2sgdmFsdWUgKi9cbnZhciAgICBMRU5HVEggPSAyODsgICAgLyogaTogd2FpdGluZyBmb3IgMzItYml0IGxlbmd0aCAoZ3ppcCkgKi9cbnZhciAgICBET05FID0gMjk7ICAgICAgLyogZmluaXNoZWQgY2hlY2ssIGRvbmUgLS0gcmVtYWluIGhlcmUgdW50aWwgcmVzZXQgKi9cbnZhciAgICBCQUQgPSAzMDsgICAgICAgLyogZ290IGEgZGF0YSBlcnJvciAtLSByZW1haW4gaGVyZSB1bnRpbCByZXNldCAqL1xudmFyICAgIE1FTSA9IDMxOyAgICAgICAvKiBnb3QgYW4gaW5mbGF0ZSgpIG1lbW9yeSBlcnJvciAtLSByZW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UEVETztcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvLz09PSBORUVEQklUUygxNik7XG4gICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICB9XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgaWYgKChzdGF0ZS53cmFwICYgMikgJiYgaG9sZCA9PT0gMHg4YjFmKSB7ICAvKiBnemlwIGhlYWRlciAqL1xuICAgICAgICAgIHN0YXRlLmNoZWNrID0gMC8qY3JjMzIoMEwsIFpfTlVMTCwgMCkqLztcbiAgICAgICAgICAvLz09PSBDUkMyKHN0YXRlLmNoZWNrLCBob2xkKTtcbiAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDB4ZmY7XG4gICAgICAgICAgaGJ1ZlsxXSA9IChob2xkID4+PiA4KSAmIDB4ZmY7XG4gICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7XG4gICAgICAgICAgLy89PT0vL1xuXG4gICAgICAgICAgLy89PT0gSU5JVEJJVFMoKTtcbiAgICAgICAgICBob2xkID0gMDtcbiAgICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgICAvLz09PS8vXG4gICAgICAgICAgc3RhdGUubW9kZSA9IEZMQUdTO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRlLmZsYWdzID0gMDsgICAgICAgICAgIC8qIGV4cGVjdCB6bGliIGhlYWRlciAqL1xuICAgICAgICBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQuZG9uZSA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGlmICghKHN0YXRlLndyYXAgJiAxKSB8fCAgIC8qIGNoZWNrIGlmIHpsaWIgaGVhZGVyIGFsbG93ZWQgKi9cbiAgICAgICAgICAoKChob2xkICYgMHhmZikvKkJJVFMoOCkqLyA8PCA4KSArIChob2xkID4+IDgpKSAlIDMxKSB7XG4gICAgICAgICAgc3RybS5tc2cgPSAnaW5jb3JyZWN0IGhlYWRlciBjaGVjayc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBpZiAoKGhvbGQgJiAweDBmKS8qQklUUyg0KSovICE9PSBaX0RFRkxBVEVEKSB7XG4gICAgICAgICAgc3RybS5tc2cgPSAndW5rbm93biBjb21wcmVzc2lvbiBtZXRob2QnO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgLy8tLS0gRFJPUEJJVFMoNCkgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IDQ7XG4gICAgICAgIGJpdHMgLT0gNDtcbiAgICAgICAgLy8tLS0vL1xuICAgICAgICBsZW4gPSAoaG9sZCAmIDB4MGYpLypCSVRTKDQpKi8gKyA4O1xuICAgICAgICBpZiAoc3RhdGUud2JpdHMgPT09IDApIHtcbiAgICAgICAgICBzdGF0ZS53Yml0cyA9IGxlbjtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChsZW4gPiBzdGF0ZS53Yml0cykge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgd2luZG93IHNpemUnO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUuZG1heCA9IDEgPDwgbGVuO1xuICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgemxpYiBoZWFkZXIgb2tcXG5cIikpO1xuICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSAxLyphZGxlcjMyKDBMLCBaX05VTEwsIDApKi87XG4gICAgICAgIHN0YXRlLm1vZGUgPSBob2xkICYgMHgyMDAgPyBESUNUSUQgOiBUWVBFO1xuICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICBob2xkID0gMDtcbiAgICAgICAgYml0cyA9IDA7XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIEZMQUdTOlxuICAgICAgICAvLz09PSBORUVEQklUUygxNik7ICovXG4gICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICB9XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUuZmxhZ3MgPSBob2xkO1xuICAgICAgICBpZiAoKHN0YXRlLmZsYWdzICYgMHhmZikgIT09IFpfREVGTEFURUQpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICd1bmtub3duIGNvbXByZXNzaW9uIG1ldGhvZCc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweGUwMDApIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICd1bmtub3duIGhlYWRlciBmbGFncyBzZXQnO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLnRleHQgPSAoKGhvbGQgPj4gOCkgJiAxKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDAyMDApIHtcbiAgICAgICAgICAvLz09PSBDUkMyKHN0YXRlLmNoZWNrLCBob2xkKTtcbiAgICAgICAgICBoYnVmWzBdID0gaG9sZCAmIDB4ZmY7XG4gICAgICAgICAgaGJ1ZlsxXSA9IChob2xkID4+PiA4KSAmIDB4ZmY7XG4gICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgMiwgMCk7XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICB9XG4gICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgIGhvbGQgPSAwO1xuICAgICAgICBiaXRzID0gMDtcbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdGF0ZS5tb2RlID0gVElNRTtcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBUSU1FOlxuICAgICAgICAvLz09PSBORUVEQklUUygzMik7ICovXG4gICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICB9XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLnRpbWUgPSBob2xkO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgIC8vPT09IENSQzQoc3RhdGUuY2hlY2ssIGhvbGQpXG4gICAgICAgICAgaGJ1ZlswXSA9IGhvbGQgJiAweGZmO1xuICAgICAgICAgIGhidWZbMV0gPSAoaG9sZCA+Pj4gOCkgJiAweGZmO1xuICAgICAgICAgIGhidWZbMl0gPSAoaG9sZCA+Pj4gMTYpICYgMHhmZjtcbiAgICAgICAgICBoYnVmWzNdID0gKGhvbGQgPj4+IDI0KSAmIDB4ZmY7XG4gICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaGJ1ZiwgNCwgMCk7XG4gICAgICAgICAgLy89PT1cbiAgICAgICAgfVxuICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICBob2xkID0gMDtcbiAgICAgICAgYml0cyA9IDA7XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUubW9kZSA9IE9TO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIE9TOlxuICAgICAgICAvLz09PSBORUVEQklUUygxNik7ICovXG4gICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICB9XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLnhmbGFncyA9IChob2xkICYgMHhmZik7XG4gICAgICAgICAgc3RhdGUuaGVhZC5vcyA9IChob2xkID4+IDgpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgIC8vPT09IENSQzIoc3RhdGUuY2hlY2ssIGhvbGQpO1xuICAgICAgICAgIGhidWZbMF0gPSBob2xkICYgMHhmZjtcbiAgICAgICAgICBoYnVmWzFdID0gKGhvbGQgPj4+IDgpICYgMHhmZjtcbiAgICAgICA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DApO1xuICAgICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIH1cbiAgICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICAgIGhvbGQgPSAwO1xuICAgICAgICAgIGJpdHMgPSAwO1xuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChzdGF0ZS5oZWFkKSB7XG4gICAgICAgICAgc3RhdGUuaGVhZC5leHRyYSA9IG51bGwvKlpfTlVMTCovO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRlLm1vZGUgPSBFWFRSQTtcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBFWFRSQTpcbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwNDAwKSB7XG4gICAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDtcbiAgICAgICAgICBpZiAoY29weSA+IGhhdmUpIHsgY29weSA9IGhhdmU7IH1cbiAgICAgICAgICBpZiAoY29weSkge1xuICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICAgICAgbGVuID0gc3RhdGUuaGVhZC5leHRyYV9sZW4gLSBzdGF0ZS5sZW5ndGg7XG4gICAgICAgICAgICAgIGlmICghc3RhdGUuaGVhZC5leHRyYSkge1xuICAgICAgICAgICAgICAgIC8vIFVzZSB1bnR5cGVkIGFycmF5IGZvciBtb3JlIGNvbnZlbmllbnQgcHJvY2Vzc2luZyBsYXRlclxuICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmEgPSBuZXcgQXJyYXkoc3RhdGUuaGVhZC5leHRyYV9sZW4pO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHV0aWxzLmFycmF5U2V0KFxuICAgICAgICAgICAgICAgIHN0YXRlLmhlYWQuZXh0cmEsXG4gICAgICAgICAgICAgICAgaW5wdXQsXG4gICAgICAgICAgICAgICAgbmV4dCxcbiAgICAgICAgICAgICAgICAvLyBleHRyYSBmaWVsZCBpcyBsaW1pdGVkIHRvIDY1NTM2IGJ5dGVzXG4gICAgICAgICAgICAgICAgLy8gLSBubyBuZWVkIGZvciBhZGRpdGlvbmFsIHNpemUgY2hlY2tcbiAgICAgICAgICAgICAgICBjb3B5LFxuICAgICAgICAgICAgICAgIC8qbGVuICsgY29weSA+IHN0YXRlLmhlYWQuZXh0cmFfbWF4IC0gbGVuID8gc3RhdGUuaGVhZC5leHRyYV9tYXggOiBjb3B5LCovXG4gICAgICAgICAgICAgICAgbGVuXG4gICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgIC8vem1lbWNweShzdGF0ZS5oZWFkLmV4dHJhICsgbGVuLCBuZXh0LFxuICAgICAgICAgICAgICAvLyAgICAgICAgbGVuICsgY29weSA+IHN0YXRlLmhlYWQuZXh0cmFfbWF4ID9cbiAgICAgICAgICAgICAgLy8gICAgICAgIHN0YXRlLmhlYWQuZXh0cmFfbWF4IC0gbGVuIDogY29weSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDAyMDApIHtcbiAgICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaW5wdXQsIGNvcHksIG5leHQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaGF2ZSAtPSBjb3B5O1xuICAgICAgICAgICAgbmV4dCArPSBjb3B5O1xuICAgICAgICAgICAgc3RhdGUubGVuZ3RoIC09IGNvcHk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzdGF0ZS5sZW5ndGgpIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUubGVuZ3RoID0gMDtcbiAgICAgICAgc3RhdGUubW9kZSA9IE5BTUU7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgTkFNRTpcbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwODAwKSB7XG4gICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgY29weSA9IDA7XG4gICAgICAgICAgZG8ge1xuICAgICAgICAgICAgLy8gVE9ETzogMiBvciAxIGJ5dGVzP1xuICAgICAgICAgICAgbGVuID0gaW5wdXRbbmV4dCArIGNvcHkrK107XG4gICAgICAgICAgICAvKiB1c2UgY29uc3RhbnQgbGltaXQgYmVjYXVzZSBpbiBqcyB3ZSBzaG91bGQgbm90IHByZWFsbG9jYXRlIG1lbW9yeSAqL1xuICAgICAgICAgICAgaWYgKHN0YXRlLmhlYWQgJiYgbGVuICYmXG4gICAgICAgICAgICAgICAgKHN0YXRlLmxlbmd0aCA8IDY1NTM2IC8qc3RhdGUuaGVhZC5uYW1lX21heCovKSkge1xuICAgICAgICAgICAgICBzdGF0ZS5oZWFkLm5hbWUgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShsZW4pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gd2hpbGUgKGxlbiAmJiBjb3B5IDwgaGF2ZSk7XG5cbiAgICAgICAgICBpZiAoc3RhdGUuZmxhZ3MgJiAweDAyMDApIHtcbiAgICAgICAgICAgIHN0YXRlLmNoZWNrID0gY3JjMzIoc3RhdGUuY2hlY2ssIGlucHV0LCBjb3B5LCBuZXh0KTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaGF2ZSAtPSBjb3B5O1xuICAgICAgICAgIG5leHQgKz0gY29weTtcbiAgICAgICAgICBpZiAobGVuKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKHN0YXRlLmhlYWQpIHtcbiAgICAgICAgICBzdGF0ZS5oZWFkLm5hbWUgPSBudWxsO1xuICAgICAgICB9XG4gICAgICAgIHN0YXRlLmxlbmd0aCA9IDA7XG4gICAgICAgIHN0YXRlLm1vZGUgPSBDT01NRU5UO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIENPTU1FTlQ6XG4gICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MTAwMCkge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGNvcHkgPSAwO1xuICAgICAgICAgIGRvIHtcbiAgICAgICAgICAgIGxlbiA9IGlucHV0W25leHQgKyBjb3B5KytdO1xuICAgICAgICAgICAgLyogdXNlIGNvbnN0YW50IGxpbWl0IGJlY2F1c2UgaW4ganMgd2Ugc2hvdWxkIG5vdCBwcmVhbGxvY2F0ZSBtZW1vcnkgKi9cbiAgICAgICAgICAgIGlmIChzdGF0ZS5oZWFkICYmIGxlbiAmJlxuICAgICAgICAgICAgICAgIChzdGF0ZS5sZW5ndGggPCA2NTUzNiAvKnN0YXRlLmhlYWQuY29tbV9tYXgqLykpIHtcbiAgICAgICAgICAgICAgc3RhdGUuaGVhZC5jb21tZW50ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUobGVuKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IHdoaWxlIChsZW4gJiYgY29weSA8IGhhdmUpO1xuICAgICAgICAgIGlmIChzdGF0ZS5mbGFncyAmIDB4MDIwMCkge1xuICAgICAgICAgICAgc3RhdGUuY2hlY2sgPSBjcmMzMihzdGF0ZS5jaGVjaywgaW5wdXQsIGNvcHksIG5leHQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBoYXZlIC09IGNvcHk7XG4gICAgICAgICAgbmV4dCArPSBjb3B5O1xuICAgICAgICAgIGlmIChsZW4pIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoc3RhdGUuaGVhZCkge1xuICAgICAgICAgIHN0YXRlLmhlYWQuY29tbWVudCA9IG51bGw7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUubW9kZSA9IEhDUkM7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgSENSQzpcbiAgICAgICAgaWYgKHN0YXRlLmZsYWdzICYgMHgwMjAwKSB7XG4gICAgICAgICAgLy89PT0gTkVFREJJVFMoMTYpOyAqL1xuICAgICAgICAgIHdoaWxlIChiaXRzIDwgMTYpIHtcbiAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgfVxuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgICBpZiAoaG9sZCAhPT0gKHN0YXRlLmNoZWNrICYgMHhmZmZmKSkge1xuICAgICAgICAgICAgc3RybS5tc2cgPSAnaGVhZGVyIGNyYyBtaXNtYXRjaCc7XG4gICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgICAgaG9sZCA9IDA7XG4gICAgICAgICAgYml0cyA9IDA7XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICB9XG4gICAgICAgIGlmIChzdGF0ZS5oZWFkKSB7XG4gICAgICAgICAgc3RhdGUuaGVhZC5oY3JjID0gKChzdGF0ZS5mbGFncyA+PiA5KSAmIDEpO1xuICAgICAgICAgIHN0YXRlLmhlYWQuZG9uZSA9IHRydWU7XG4gICAgICAgIH1cbiAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLmNoZWNrID0gMDtcbiAgICAgICAgc3RhdGUubW9kZSA9IFRZUEU7XG4gICAgICAgIGJyZWFrO1xuICAgICAgY2FzZSBESUNUSUQ6XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDMyKTsgKi9cbiAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikge1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgIH1cbiAgICAgICAgLy89PT0vL1xuICAgICAgICBzdHJtLmFkbGVyID0gc3RhdGUuY2hlY2sgPSB6c3dhcDMyKGhvbGQpO1xuICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICBob2xkID0gMDtcbiAgICAgICAgYml0cyA9IDA7XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUubW9kZSA9IERJQ1Q7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgRElDVDpcbiAgICAgICAgaWYgKHN0YXRlLmhhdmVkaWN0ID09PSAwKSB7XG4gICAgICAgICAgLy8tLS0gUkVTVE9SRSgpIC0tLVxuICAgICAgICAgIHN0cm0ubmV4dF9vdXQgPSBwdXQ7XG4gICAgICAgICAgc3RybS5hdmFpbF9vdXQgPSBsZWZ0O1xuICAgICAgICAgIHN0cm0ubmV4dF9pbiA9IG5leHQ7XG4gICAgICAgICAgc3RybS5hdmFpbF9pbiA9IGhhdmU7XG4gICAgICAgICAgc3RhdGUuaG9sZCA9IGhvbGQ7XG4gICAgICAgICAgc3RhdGUuYml0cyA9IGJpdHM7XG4gICAgICAgICAgLy8tLS1cbiAgICAgICAgICByZXR1cm4gWl9ORUVEX0RJQ1Q7XG4gICAgICAgIH1cbiAgICAgICAgc3RybS5hZGxlciA9IHN0YXRlLmNoZWNrID0gMS8qYWRsZXIzMigwTCwgWl9OVUxMLCAwKSovO1xuICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTtcbiAgICAgICAgLyogZmFsbHMgdGhyb3VnaCAqL1xuICAgICAgY2FzZSBUWVBFOlxuICAgICAgICBpZiAoZmx1c2ggPT09IFpfQkxPQ0sgfHwgZmx1c2ggPT09IFpfVFJFRVMpIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgVFlQRURPOlxuICAgICAgICBpZiAoc3RhdGUubGFzdCkge1xuICAgICAgICAgIC8vLS0tIEJZVEVCSVRTKCkgLS0tLy9cbiAgICAgICAgICBob2xkID4+Pj0gYml0cyAmIDc7XG4gICAgICAgICAgYml0cyAtPSBiaXRzICYgNztcbiAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgc3RhdGUubW9kZSA9IENIRUNLO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIC8vPT09IE5FRURCSVRTKDMpOyAqL1xuICAgICAgICB3aGlsZSAoYml0cyA8IDMpIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICB9XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUubGFzdCA9IChob2xkICYgMHgwMSkvKkJJVFMoMSkqLztcbiAgICAgICAgLy8tLS0gRFJPUEJJVFMoMSkgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IDE7XG4gICAgICAgIGJpdHMgLT0gMTtcbiAgICAgICAgLy8tLS0vL1xuXG4gICAgICAgIHN3aXRjaCAoKGhvbGQgJiAweDAzKS8qQklUUygyKSovKSB7XG4gICAgICAgICAgY2FzZSAwOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogc3RvcmVkIGJsb2NrICovXG4gICAgICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgICBzdG9yZWQgYmxvY2slc1xcblwiLFxuICAgICAgICAgICAgLy8gICAgICAgIHN0YXRlLmxhc3QgPyBcIiAobGFzdClcIiA6IFwiXCIpKTtcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBTVE9SRUQ7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICBjYXNlIDE6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBmaXhlZCBibG9jayAqL1xuICAgICAgICAgICAgZml4ZWR0YWJsZXMoc3RhdGUpO1xuICAgICAgICAgICAgLy9UcmFjZXYoKHN0ZGVyciwgXCJpbmZsYXRlOiAgICAgZml4ZWQgY29kZXMgYmxvY2slc1xcblwiLFxuICAgICAgICAgICAgLy8gICAgICAgIHN0YXRlLmxhc3QgPyBcIiAobGFzdClcIiA6IFwiXCIpKTtcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBMRU5fOyAgICAgICAgICAgICAvKiBkZWNvZGUgY29kZXMgKi9cbiAgICAgICAgICAgIGlmIChmbHVzaCA9PT0gWl9UUkVFUykge1xuICAgICAgICAgICAgICAvLy0tLSBEUk9QQklUUygyKSAtLS0vL1xuICAgICAgICAgICAgICBob2xkID4+Pj0gMjtcbiAgICAgICAgICAgICAgYml0cyAtPSAyO1xuICAgICAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgICAgIGJyZWFrIGluZl9sZWF2ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIGNhc2UgMjogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIGR5bmFtaWMgYmxvY2sgKi9cbiAgICAgICAgICAgIC8vVHJhY2V2KChzdGRlcnIsIFwiaW5mbGF0ZTogICAgIGR5bmFtaWMgY29kZXMgYmxvY2slc1xcblwiLFxuICAgICAgICAgICAgLy8gICAgICAgIHN0YXRlLmxhc3QgPyBcIiAobGFzdClcIiA6IFwiXCIpKTtcbiAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBUQUJMRTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgYmxvY2sgdHlwZSc7XG4gICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICB9XG4gICAgICAgIC8vLS0tIERST1BCSVRTKDIpIC0tLS8vXG4gICAgICAgIGhvbGQgPj4+PSAyO1xuICAgICAgICBiaXRzIC09IDI7XG4gICAgICAgIC8vLS0tLy9cbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIFNUT1JFRDpcbiAgICAgICAgLy8tLS0gQllURUJJVFMoKSAtLS0vLyAvKiBnbyB0byBieXRlIGJvdW5kYXJ5ICovXG4gICAgICAgIGhvbGQgPj4+PSBiaXRzICYgNztcbiAgICAgICAgYml0cyAtPSBiaXRzICYgNztcbiAgICAgICAgLy8tLS0vL1xuICAgICAgICAvLz09PSBORUVEQklUUygzMik7ICovXG4gICAgICAgIHdoaWxlIChiaXRzIDwgMzIpIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICB9XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgaWYgKChob2xkICYgMHhmZmZmKSAhPT0gKChob2xkID4+PiAxNikgXiAweGZmZmYpKSB7XG4gICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBzdG9yZWQgYmxvY2sgbGVuZ3Rocyc7XG4gICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5sZW5ndGggPSBob2xkICYgMHhmZmZmO1xuICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgIHN0b3JlZCBsZW5ndGggJXVcXG5cIixcbiAgICAgICAgLy8gICAgICAgIHN0YXRlLmxlbmd0aCkpO1xuICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICBob2xkID0gMDtcbiAgICAgICAgYml0cyA9IDA7XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUubW9kZSA9IENPUFlfO1xuICAgICAgICBpZiAoZmx1c2ggPT09IFpfVFJFRVMpIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgQ09QWV86XG4gICAgICAgIHN0YXRlLm1vZGUgPSBDT1BZO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIENPUFk6XG4gICAgICAgIGNvcHkgPSBzdGF0ZS5sZW5ndGg7XG4gICAgICAgIGlmIChjb3B5KSB7XG4gICAgICAgICAgaWYgKGNvcHkgPiBoYXZlKSB7IGNvcHkgPSBoYXZlOyB9XG4gICAgICAgICAgaWYgKGNvcHkgPiBsZWZ0KSB7IGNvcHkgPSBsZWZ0OyB9XG4gICAgICAgICAgaWYgKGNvcHkgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgLy8tLS0gem1lbWNweShwdXQsIG5leHQsIGNvcHkpOyAtLS1cbiAgICAgICAgICB1dGlscy5hcnJheVNldChvdXRwdXQsIGlucHV0LCBuZXh0LCBjb3B5LCBwdXQpO1xuICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICBoYXZlIC09IGNvcHk7XG4gICAgICAgICAgbmV4dCArPSBjb3B5O1xuICAgICAgICAgIGxlZnQgLT0gY29weTtcbiAgICAgICAgICBwdXQgKz0gY29weTtcbiAgICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgIHN0b3JlZCBlbmRcXG5cIikpO1xuICAgICAgICBzdGF0ZS5tb2RlID0gVFlQRTtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIFRBQkxFOlxuICAgICAgICAvLz09PSBORUVEQklUUygxNCk7ICovXG4gICAgICAgIHdoaWxlIChiaXRzIDwgMTQpIHtcbiAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICB9XG4gICAgICAgIC8vPT09Ly9cbiAgICAgICAgc3RhdGUubmxlbiA9IChob2xkICYgMHgxZikvKkJJVFMoNSkqLyArIDI1NztcbiAgICAgICAgLy8tLS0gRFJPUEJJVFMoNSkgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IDU7XG4gICAgICAgIGJpdHMgLT0gNTtcbiAgICAgICAgLy8tLS0vL1xuICAgICAgICBzdGF0ZS5uZGlzdCA9IChob2xkICYgMHgxZikvKkJJVFMoNSkqLyArIDE7XG4gICAgICAgIC8vLS0tIERST1BCSVRTKDUpIC0tLS8vXG4gICAgICAgIGhvbGQgPj4+PSA1O1xuICAgICAgICBiaXRzIC09IDU7XG4gICAgICAgIC8vLS0tLy9cbiAgICAgICAgc3RhdGUubmNvZGUgPSAoaG9sZCAmIDB4MGYpLypCSVRTKDQpKi8gKyA0O1xuICAgICAgICAvLy0tLSBEUk9QQklUUyg0KSAtLS0vL1xuICAgICAgICBob2xkID4+Pj0gNDtcbiAgICAgICAgYml0cyAtPSA0O1xuICAgICAgICAvLy0tLS8vXG4vLyNpZm5kZWYgUEtaSVBfQlVHX1dPUktBUk9VTkRcbiAgICAgICAgaWYgKHN0YXRlLm5sZW4gPiAyODYgfHwgc3RhdGUubmRpc3QgPiAzMCkge1xuICAgICAgICAgIHN0cm0ubXNnID0gJ3RvbyBtYW55IGxlbmd0aCBvciBkaXN0YW5jZSBzeW1ib2xzJztcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4vLyNlbmRpZlxuICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgICAgIHRhYmxlIHNpemVzIG9rXFxuXCIpKTtcbiAgICAgICAgc3RhdGUuaGF2ZSA9IDA7XG4gICAgICAgIHN0YXRlLm1vZGUgPSBMRU5MRU5TO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIExFTkxFTlM6XG4gICAgICAgIHdoaWxlIChzdGF0ZS5oYXZlIDwgc3RhdGUubmNvZGUpIHtcbiAgICAgICAgICAvLz09PSBORUVEQklUUygzKTtcbiAgICAgICAgICB3aGlsZSAoYml0cyA8IDMpIHtcbiAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgaGF2ZS0tO1xuICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgfVxuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgICBzdGF0ZS5sZW5zW29yZGVyW3N0YXRlLmhhdmUrK11dID0gKGhvbGQgJiAweDA3KTsvL0JJVFMoMyk7XG4gICAgICAgICAgLy8tLS0gRFJPUEJJVFMoMykgLS0tLy9cbiAgICAgICAgICBob2xkID4+Pj0gMztcbiAgICAgICAgICBiaXRzIC09IDM7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICB9XG4gICAgICAgIHdoaWxlIChzdGF0ZS5oYXZlIDwgMTkpIHtcbiAgICAgICAgICBzdGF0ZS5sZW5zW29yZGVyW3N0YXRlLmhhdmUrK11dID0gMDtcbiAgICAgICAgfVxuICAgICAgICAvLyBXZSBoYXZlIHNl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GF0ZS5sZW5jb2RlW2hvbGQgJiAoKDEgPDwgc3RhdGUubGVuYml0cykgLSAxKV07LypCSVRTKHN0YXRlLmxlbmJpdHMpKi9cbiAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0O1xuICAgICAgICAgICAgaGVyZV9vcCA9IChoZXJlID4+PiAxNikgJiAweGZmO1xuICAgICAgICAgICAgaGVyZV92YWwgPSBoZXJlICYgMHhmZmZmO1xuXG4gICAgICAgICAgICBpZiAoKGhlcmVfYml0cykgPD0gYml0cykgeyBicmVhazsgfVxuICAgICAgICAgICAgLy8tLS0gUFVMTEJZVEUoKSAtLS0vL1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGhlcmVfdmFsIDwgMTYpIHtcbiAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7XG4gICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0cztcbiAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgIHN0YXRlLmxlbnNbc3RhdGUuaGF2ZSsrXSA9IGhlcmVfdmFsO1xuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGlmIChoZXJlX3ZhbCA9PT0gMTYpIHtcbiAgICAgICAgICAgICAgLy89PT0gTkVFREJJVFMoaGVyZS5iaXRzICsgMik7XG4gICAgICAgICAgICAgIG4gPSBoZXJlX2JpdHMgKyAyO1xuICAgICAgICAgICAgICB3aGlsZSAoYml0cyA8IG4pIHtcbiAgICAgICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICAgICAgaG9sZCArPSBpbnB1dFtuZXh0KytdIDw8IGJpdHM7XG4gICAgICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgICAgICAgLy8tLS0gRFJPUEJJVFMoaGVyZS5iaXRzKSAtLS0vL1xuICAgICAgICAgICAgICBob2xkID4+Pj0gaGVyZV9iaXRzO1xuICAgICAgICAgICAgICBiaXRzIC09IGhlcmVfYml0cztcbiAgICAgICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZSA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHN0cm0ubXNnID0gJ2ludmFsaWQgYml0IGxlbmd0aCByZXBlYXQnO1xuICAgICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgbGVuID0gc3RhdGUubGVuc1tzdGF0ZS5oYXZlIC0gMV07XG4gICAgICAgICAgICAgIGNvcHkgPSAzICsgKGhvbGQgJiAweDAzKTsvL0JJVFMoMik7XG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKDIpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSAyO1xuICAgICAgICAgICAgICBiaXRzIC09IDI7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKGhlcmVfdmFsID09PSAxNykge1xuICAgICAgICAgICAgICAvLz09PSBORUVEQklUUyhoZXJlLmJpdHMgKyAzKTtcbiAgICAgICAgICAgICAgbiA9IGhlcmVfYml0cyArIDM7XG4gICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikge1xuICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgLy89PT0vL1xuICAgICAgICAgICAgICAvLy0tLSBEUk9QQklUUyhoZXJlLmJpdHMpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzO1xuICAgICAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgICAgIGxlbiA9IDA7XG4gICAgICAgICAgICAgIGNvcHkgPSAzICsgKGhvbGQgJiAweDA3KTsvL0JJVFMoMyk7XG4gICAgICAgICAgICAgIC8vLS0tIERST1BCSVRTKDMpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSAzO1xuICAgICAgICAgICAgICBiaXRzIC09IDM7XG4gICAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAvLz09PSBORUVEQklUUyhoZXJlLmJpdHMgKyA3KTtcbiAgICAgICAgICAgICAgbiA9IGhlcmVfYml0cyArIDc7XG4gICAgICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikge1xuICAgICAgICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgLy89PT0vL1xuICAgICAgICAgICAgICAvLy0tLSBEUk9QQklUUyhoZXJlLmJpdHMpIC0tLS8vXG4gICAgICAgICAgICAgIGhvbGQgPj4+PSBoZXJlX2JpdHM7XG4gICAgICAgICAgICAgIGJpdHMgLT0gaGVyZV9iaXRzO1xuICAgICAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgICAgIGxlbiA9IDA7XG4gICAgICAgICAgICAgIGNvcHkgPSAxMSArIChob2xkICYgMHg3Zik7Ly9CSVRTKDcpO1xuICAgICAgICAgICAgICAvLy0tLSBEUk9QQklUUyg3KSAtLS0vL1xuICAgICAgICAgICAgICBob2xkID4+Pj0gNztcbiAgICAgICAgICAgICAgYml0cyAtPSA3O1xuICAgICAgICAgICAgICAvLy0tLS8vXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc3RhdGUuaGF2ZSArIGNvcHkgPiBzdGF0ZS5ubGVuICsgc3RhdGUubmRpc3QpIHtcbiAgICAgICAgICAgICAgc3RybS5tc2cgPSAnaW52YWxpZCBiaXQgbGVuZ3RoIHJlcGVhdCc7XG4gICAgICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgd2hpbGUgKGNvcHktLSkge1xuICAgICAgICAgICAgICBzdGF0ZS5sZW5zW3N0YXRlLmhhdmUrK10gPSBsZW47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyogaGFuZGxlIGVycm9yIGJyZWFrcyBpbiB3aGlsZSAqL1xuICAgICAgICBpZiAoc3RhdGUubW9kZSA9PT0gQkFEKSB7IGJyZWFrOyB9XG5cbiAgICAgICAgLyogY2hlY2sgZm9yIGVuZC1vZi1ibG9jayBjb2RlIChiZXR0ZXIgaGF2ZSBvbmUpICovXG4gICAgICAgIGlmIChzdGF0ZS5sZW5zWzI1Nl0gPT09IDApIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICdpbn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xuICAgICAgY2FzZSBMRU5fOlxuICAgICAgICBzdGF0ZS5tb2RlID0gTEVOO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIExFTjpcbiAgICAgICAgaWYgKGhhdmUgPj0gNiAmJiBsZWZ0ID49IDI1OCkge1xuICAgICAgICAgIC8vLS0tIFJFU1RPUkUoKSAtLS1cbiAgICAgICAgICBzdHJtLm5leHRfb3V0ID0gcHV0O1xuICAgICAgICAgIHN0cm0uYXZhaWxfb3V0ID0gbGVmdDtcbiAgICAgICAgICBzdHJtLm5leHRfaW4gPSBuZXh0O1xuICAgICAgICAgIHN0cm0uYXZhaWxfaW4gPSBoYXZlO1xuICAgICAgICAgIHN0YXRlLmhvbGQgPSBob2xkO1xuICAgICAgICAgIHN0YXRlLmJpdHMgPSBiaXRzO1xuICAgICAgICAgIC8vLS0tXG4gICAgICAgICAgaW5mbGF0ZV9mYXN0KHN0cm0sIF9vdXQpO1xuICAgICAgICAgIC8vLS0tIExPQUQoKSAtLS1cbiAgICAgICAgICBwdXQgPSBzdHJtLm5leHRfb3V0O1xuICAgICAgICAgIG91dHB1dCA9IHN0cm0ub3V0cHV0O1xuICAgICAgICAgIGxlZnQgPSBzdHJtLmF2YWlsX291dDtcbiAgICAgICAgICBuZXh0ID0gc3RybS5uZXh0X2luO1xuICAgICAgICAgIGlucHV0ID0gc3RybS5pbnB1dDtcbiAgICAgICAgICBoYXZlID0gc3RybS5hdmFpbF9pbjtcbiAgICAgICAgICBob2xkID0gc3RhdGUuaG9sZDtcbiAgICAgICAgICBiaXRzID0gc3RhdGUuYml0cztcbiAgICAgICAgICAvLy0tLVxuXG4gICAgICAgICAgaWYgKHN0YXRlLm1vZGUgPT09IFRZUEUpIHtcbiAgICAgICAgICAgIHN0YXRlLmJhY2sgPSAtMTtcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUuYmFjayA9IDA7XG4gICAgICAgIGZvciAoOzspIHtcbiAgICAgICAgICBoZXJlID0gc3RhdGUubGVuY29kZVtob2xkICYgKCgxIDw8IHN0YXRlLmxlbmJpdHMpIC0gMSldOyAgLypCSVRTKHN0YXRlLmxlbmJpdHMpKi9cbiAgICAgICAgICBoZXJlX2JpdHMgPSBoZXJlID4+PiAyNDtcbiAgICAgICAgICBoZXJlX29wID0gKGhlcmUgPj4+IDE2KSAmIDB4ZmY7XG4gICAgICAgICAgaGVyZV92YWwgPSBoZXJlICYgMHhmZmZmO1xuXG4gICAgICAgICAgaWYgKGhlcmVfYml0cyA8PSBiaXRzKSB7IGJyZWFrOyB9XG4gICAgICAgICAgLy8tLS0gUFVMTEJZVEUoKSAtLS0vL1xuICAgICAgICAgIGlmIChoYXZlID09PSAwKSB7IGJyZWFrIGluZl9sZWF2ZTsgfVxuICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICB9XG4gICAgICAgIGlmIChoZXJlX29wICYmIChoZXJlX29wICYgMHhmMCkgPT09IDApIHtcbiAgICAgICAgICBsYXN0X2JpdHMgPSBoZXJlX2JpdHM7XG4gICAgICAgICAgbGFzdF9vcCA9IGhlcmVfb3A7XG4gICAgICAgICAgbGFzdF92YWwgPSBoZXJlX3ZhbDtcbiAgICAgICAgICBmb3IgKDs7KSB7XG4gICAgICAgICAgICBoZXJlID0gc3RhdGUubGVuY29kZVtsYXN0X3ZhbCArXG4gICAgICAgICAgICAgICAgICAgICgoaG9sZCAmICgoMSA8PCAobGFzdF9iaXRzICsgbGFzdF9vcCkpIC0gMSkpLypCSVRTKGxhc3QuYml0cyArIGxhc3Qub3ApKi8gPj4gbGFzdF9iaXRzKV07XG4gICAgICAgICAgICBoZXJlX2JpdHMgPSBoZXJlID4+PiAyNDtcbiAgICAgICAgICAgIGhlcmVfb3AgPSAoaGV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OlxuICAgICAgICAgIC8vICAgICAgICBcImluZmxhdGU6ICAgICAgICAgbGl0ZXJhbCAweCUwMnhcXG5cIiwgaGVyZS52YWwpKTtcbiAgICAgICAgICBzdGF0ZS5tb2RlID0gTElUO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGlmIChoZXJlX29wICYgMzIpIHtcbiAgICAgICAgICAvL1RyYWNldnYoKHN0ZGVyciwgXCJpbmZsYXRlOiAgICAgICAgIGVuZCBvZiBibG9ja1xcblwiKSk7XG4gICAgICAgICAgc3RhdGUuYmFjayA9IC0xO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBUWVBFO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGlmIChoZXJlX29wICYgNjQpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIGxpdGVyYWwvbGVuZ3RoIGNvZGUnO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUuZXh0cmEgPSBoZXJlX29wICYgMTU7XG4gICAgICAgIHN0YXRlLm1vZGUgPSBMRU5FWFQ7XG4gICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgIGNhc2UgTEVORVhUOlxuICAgICAgICBpZiAoc3RhdGUuZXh0cmEpIHtcbiAgICAgICAgICAvLz09PSBORUVEQklUUyhzdGF0ZS5leHRyYSk7XG4gICAgICAgICAgbiA9IHN0YXRlLmV4dHJhO1xuICAgICAgICAgIHdoaWxlIChiaXRzIDwgbikge1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAg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UtLTtcbiAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICBiaXRzICs9IDg7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICB9XG4gICAgICAgIGlmICgoaGVyZV9vcCAmIDB4ZjApID09PSAwKSB7XG4gICAgICAgICAgbGFzdF9iaXRzID0gaGVyZV9iaXRzO1xuICAgICAgICAgIGxhc3Rfb3AgPSBoZXJlX29wO1xuICAgICAgICAgIGxhc3RfdmFsID0gaGVyZV92YWw7XG4gICAgICAgICAgZm9yICg7Oykge1xuICAgICAgICAgICAgaGVyZSA9IHN0YXRlLmRpc3Rjb2RlW2xhc3RfdmFsICtcbiAgICAgICAgICAgICAgICAgICAgKChob2xkICYgKCgxIDw8IChsYXN0X2JpdHMgKyBsYXN0X29wKSkgLSAxKSkvKkJJVFMobGFzdC5iaXRzICsgbGFzdC5vcCkqLyA+PiBsYXN0X2JpdHMpXTtcbiAgICAgICAgICAgIGhlcmVfYml0cyA9IGhlcmUgPj4+IDI0O1xuICAgICAgICAgICAgaGVyZV9vcCA9IChoZXJlID4+PiAxNikgJiAweGZmO1xuICAgICAgICAgICAgaGVyZV92YWwgPSBoZXJlICYgMHhmZmZmO1xuXG4gICAgICAgICAgICBpZiAoKGxhc3RfYml0cyArIGhlcmVfYml0cykgPD0gYml0cykgeyBicmVhazsgfVxuICAgICAgICAgICAgLy8tLS0gUFVMTEJZVEUoKSAtLS0vL1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICAgIC8vLS0tLy9cbiAgICAgICAgICB9XG4gICAgICAgICAgLy8tLS0gRFJPUEJJVFMobGFzdC5iaXRzKSAtLS0vL1xuICAgICAgICAgIGhvbGQgPj4+PSBsYXN0X2JpdHM7XG4gICAgICAgICAgYml0cyAtPSBsYXN0X2JpdHM7XG4gICAgICAgICAgLy8tLS0vL1xuICAgICAgICAgIHN0YXRlLmJhY2sgKz0gbGFzdF9iaXRzO1xuICAgICAgICB9XG4gICAgICAgIC8vLS0tIERST1BCSVRTKGhlcmUuYml0cykgLS0tLy9cbiAgICAgICAgaG9sZCA+Pj49IGhlcmVfYml0cztcbiAgICAgICAgYml0cyAtPSBoZXJlX2JpdHM7XG4gICAgICAgIC8vLS0tLy9cbiAgICAgICAgc3RhdGUuYmFjayArPSBoZXJlX2JpdHM7XG4gICAgICAgIGlmIChoZXJlX29wICYgNjQpIHtcbiAgICAgICAgICBzdHJtLm1zZyA9ICdpbnZhbGlkIGRpc3RhbmNlIGNvZGUnO1xuICAgICAgICAgIHN0YXRlLm1vZGUgPSBCQUQ7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgc3RhdGUub2Zmc2V0ID0gaGVyZV92YWw7XG4gICAgICAgIHN0YXRlLmV4dHJhID0gKGhlcmVfb3ApICYgMTU7XG4gICAgICAgIHN0YXRlLm1vZGUgPSBESVNURVhUO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIERJU1RFWFQ6XG4gICAgICAgIGlmIChzdGF0ZS5leHRyYSkge1xuICAgICAgICAgIC8vPT09IE5FRURCSVRTKHN0YXRlLmV4dHJhKTtcbiAgICAgICAgICBuID0gc3RhdGUuZXh0cmE7XG4gICAgICAgICAgd2hpbGUgKGJpdHMgPCBuKSB7XG4gICAgICAgICAgICBpZiAoaGF2ZSA9PT0gMCkgeyBicmVhayBpbmZfbGVhdmU7IH1cbiAgICAgICAgICAgIGhhdmUtLTtcbiAgICAgICAgICAgIGhvbGQgKz0gaW5wdXRbbmV4dCsrXSA8PCBiaXRzO1xuICAgICAgICAgICAgYml0cyArPSA4O1xuICAgICAgICAgIH1cbiAgICAgICAgICAvLz09PS8vXG4gICA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N0YXRlLndzaXplIC0gY29weTtcbiAgICAgICAgICB9XG4gICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBmcm9tID0gc3RhdGUud25leHQgLSBjb3B5O1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoY29weSA+IHN0YXRlLmxlbmd0aCkgeyBjb3B5ID0gc3RhdGUubGVuZ3RoOyB9XG4gICAgICAgICAgZnJvbV9zb3VyY2UgPSBzdGF0ZS53aW5kb3c7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogY29weSBmcm9tIG91dHB1dCAqL1xuICAgICAgICAgIGZyb21fc291cmNlID0gb3V0cHV0O1xuICAgICAgICAgIGZyb20gPSBwdXQgLSBzdGF0ZS5vZmZzZXQ7XG4gICAgICAgICAgY29weSA9IHN0YXRlLmxlbmd0aDtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY29weSA+IGxlZnQpIHsgY29weSA9IGxlZnQ7IH1cbiAgICAgICAgbGVmdCAtPSBjb3B5O1xuICAgICAgICBzdGF0ZS5sZW5ndGggLT0gY29weTtcbiAgICAgICAgZG8ge1xuICAgICAgICAgIG91dHB1dFtwdXQrK10gPSBmcm9tX3NvdXJjZVtmcm9tKytdO1xuICAgICAgICB9IHdoaWxlICgtLWNvcHkpO1xuICAgICAgICBpZiAoc3RhdGUubGVuZ3RoID09PSAwKSB7IHN0YXRlLm1vZGUgPSBMRU47IH1cbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIExJVDpcbiAgICAgICAgaWYgKGxlZnQgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgIG91dHB1dFtwdXQrK10gPSBzdGF0ZS5sZW5ndGg7XG4gICAgICAgIGxlZnQtLTtcbiAgICAgICAgc3RhdGUubW9kZSA9IExFTjtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlIENIRUNLOlxuICAgICAgICBpZiAoc3RhdGUud3JhcC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ge1xuICAgICAgICAgICAgc3RybS5tc2cgPSAnaW5jb3JyZWN0IGRhdGEgY2hlY2snO1xuICAgICAgICAgICAgc3RhdGUubW9kZSA9IEJBRDtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgICAvLz09PSBJTklUQklUUygpO1xuICAgICAgICAgIGhvbGQgPSAwO1xuICAgICAgICAgIGJpdHMgPSAwO1xuICAgICAgICAgIC8vPT09Ly9cbiAgICAgICAgICAvL1RyYWNldigoc3RkZXJyLCBcImluZmxhdGU6ICAgY2hlY2sgbWF0Y2hlcyB0cmFpbGVyXFxuXCIpKTtcbiAgICAgICAgfVxuICAgICAgICBzdGF0ZS5tb2RlID0gTEVOR1RIO1xuICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICBjYXNlIExFTkdUSDpcbiAgICAgICAgaWYgKHN0YXRlLndyYXAgJiYgc3RhdGUuZmxhZ3MpIHtcbiAgICAgICAgICAvLz09PSBORUVEQklUUygzMik7XG4gICAgICAgICAgd2hpbGUgKGJpdHMgPCAzMikge1xuICAgICAgICAgICAgaWYgKGhhdmUgPT09IDApIHsgYnJlYWsgaW5mX2xlYXZlOyB9XG4gICAgICAgICAgICBoYXZlLS07XG4gICAgICAgICAgICBob2xkICs9IGlucHV0W25leHQrK10gPDwgYml0cztcbiAgICAgICAgICAgIGJpdHMgKz0gODtcbiAgICAgICAgICB9XG4gICAgICAgICAgLy89PT0vL1xuICAgICAgICAgIGlmIChob2xkICE9PSAoc3RhdGUudG90YWwgJiAweGZmZmZmZmZmKSkge1xuICAgICAgICAgICAgc3RybS5tc2cgPSAnaW5jb3JyZWN0IGxlbmd0aCBjaGVjayc7XG4gICAgICAgICAgICBzdGF0ZS5tb2RlID0gQkFEO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICAgIC8vPT09IElOSVRCSVRTKCk7XG4gICAgICAgICAgaG9sZCA9IDA7XG4gICAgICAgICAgYml0c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Bwcm9kdWN0IGRvY3VtZW50YXRpb24gd291bGQgYmVcbi8vICAgYXBwcmVjaWF0ZWQgYnV0IGlzIG5vdCByZXF1aXJlZC5cbi8vIDIuIEFsdGVyZWQgc291cmNlIHZlcnNpb25zIG11c3QgYmUgcGxhaW5seSBtYXJrZWQgYXMgc3VjaCwgYW5kIG11c3Qgbm90IGJlXG4vLyAgIG1pc3JlcHJlc2VudGVkIGFzIGJlaW5nIHRoZSBvcmlnaW5hbCBzb2Z0d2FyZS5cbi8vIDMuIFRoaXMgbm90aWNlIG1heSBub3QgYmUgcmVtb3ZlZCBvciBhbHRlcmVkIGZyb20gYW55IHNvdXJjZSBkaXN0cmlidXRpb24uXG5cbm1vZHVsZS5leHBvcnRzID0ge1xuICAyOiAgICAgICduZWVkIGRpY3Rpb25hcnknLCAgICAgLyogWl9ORUVEX0RJQ1QgICAgICAgMiAgKi9cbiAgMTogICAgICAnc3RyZWFtIGVuZCcsICAgICAgICAgIC8qIFpfU1RSRUFNX0VORCAgICAgIDEgICovXG4gIDA6ICAgICAgJycsICAgICAgICAgICAgICAgICAgICAvKiBaX09LICAgICAgICAgICAgICAwICAqL1xuICAnLTEnOiAgICdmaWxlIGVycm9yJywgICAgICAgICAgLyogWl9FUlJOTyAgICAgICAgICgtMSkgKi9cbiAgJy0yJzogICAnc3RyZWFtIGVycm9yJywgICAgICAgIC8qIFpfU1RSRUFNX0VSUk9SICAoLTIpICovXG4gICctMyc6ICAgJ2RhdGEgZXJyb3InLCAgICAgICAgICAvKiBaX0RBVEFfRVJST1IgICAgKC0zKSAqL1xuICAnLTQnOiAgICdpbnN1ZmZpY2llbnQgbWVtb3J5JywgLyogWl9NRU1fRVJST1IgICAgICgtNCkgKi9cbiAgJy01JzogICAnYnVmZmVyIGVycm9yJywgICAgICAgIC8qIFpfQlVGX0VSUk9SICAgICAoLTUpICovXG4gICctNic6ICAgJ2luY29tcGF0aWJsZSB2ZXJzaW9uJyAvKiBaX1ZFUlNJT05fRVJST1IgK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ZWQuXG4vLyAyLiBBbHRlcmVkIHNvdXJjZSB2ZXJzaW9ucyBtdXN0IGJlIHBsYWlubHkgbWFya2VkIGFzIHN1Y2gsIGFuZCBtdXN0IG5vdCBiZVxuLy8gICBtaXNyZXByZXNlbnRlZCBhcyBiZWluZyB0aGUgb3JpZ2luYWwgc29mdHdhcmUuXG4vLyAzLiBUaGlzIG5vdGljZSBtYXkgbm90IGJlIHJlbW92ZWQgb3IgYWx0ZXJlZCBmcm9tIGFueSBzb3VyY2UgZGlzdHJpYnV0aW9uLlxuXG4vKiBlc2xpbnQtZGlzYWJsZSBzcGFjZS11bmFyeS1vcHMgKi9cblxudmFyIHV0aWxzID0gcmVxdWlyZSgnLi4vdXRpbHMvY29tbW9uJyk7XG5cbi8qIFB1YmxpYyBjb25zdGFudHMgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovXG4vKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuXG5cbi8vdmFyIFpfRklMVEVSRUQgICAgICAgICAgPSAxO1xuLy92YXIgWl9IVUZGTUFOX09OTFkgICAgICA9IDI7XG4vL3ZhciBaX1JMRSAgICAgICAgICAgICAgID0gMztcbnZhciBaX0ZJWEVEICAgICAgICAgICAgICAgPSA0O1xuLy92YXIgWl9ERUZBVUxUX1NUUkFURUdZICA9IDA7XG5cbi8qIFBvc3NpYmxlIHZhbHVlcyBvZiB0aGUgZGF0YV90eXBlIGZpZWxkICh0aG91Z2ggc2VlIGluZmxhdGUoKSkgKi9cbnZhciBaX0JJTkFSWSAgICAgICAgICAgICAgPSAwO1xudmFyIFpfVEVYVCAgICAgICAgICAgICAgICA9IDE7XG4vL3ZhciBaX0FTQ0lJICAgICAgICAgICAgID0gMTsgLy8gPSBaX1RFWFRcbnZhciBaX1VOS05PV04gICAgICAgICAgICAgPSAyO1xuXG4vKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qL1xuXG5cbmZ1bmN0aW9uIHplcm8oYnVmKSB7IHZhciBsZW4gPSBidWYubGVuZ3RoOyB3aGlsZSAoLS1sZW4gPj0gMCkgeyBidWZbbGVuXSA9IDA7IH0gfVxuXG4vLyBGcm9tIHp1dGlsLmhcblxudmFyIFNUT1JFRF9CTE9DSyA9IDA7XG52YXIgU1RBVElDX1RSRUVTID0gMTtcbnZhciBEWU5fVFJFRVMgICAgPSAyO1xuLyogVGhlIHRocmVlIGtpbmRzIG9mIGJsb2NrIHR5cGUgKi9cblxudmFyIE1JTl9NQVRDSCAgICA9IDM7XG52YXIgTUFYX01BVENIICAgID0gMjU4O1xuLyogVGhlIG1pbmltdW0gYW5kIG1heGltdW0gbWF0Y2ggbGVuZ3RocyAqL1xuXG4vLyBGcm9tIGRlZmxhdGUuaFxuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4gKiBJbnRlcm5hbCBjb21wcmVzc2lvbiBzdGF0ZS5cbiAqL1xuXG52YXIgTEVOR1RIX0NPREVTICA9IDI5O1xuLyogbnVtYmVyIG9mIGxlbmd0aCBjb2Rlcywgbm90IGNvdW50aW5nIHRoZSBzcGVjaWFsIEVORF9CTE9DSyBjb2RlICovXG5cbnZhciBMSVRFUkFMUyAgICAgID0gMjU2O1xuLyogbnVtYmVyIG9mIGxpdGVyYWwgYnl0ZXMgMC4uMjU1ICovXG5cbnZhciBMX0NPREVTICAgICAgID0gTElURVJBTFMgKyAxICsgTEVOR1RIX0NPREVTO1xuLyogbnVtYmVyIG9mIExpdGVyYWwgb3IgTGVuZ3RoIGNvZGVzLCBpbmNsdWRpbmcgdGhlIEVORF9CTE9DSyBjb2RlICovXG5cbnZhciBEX0NPREVTICAgICAgID0gMzA7XG4vKiBudW1iZXIgb2YgZGlzdGFuY2UgY29kZXMgKi9cblxudmFyIEJMX0NPREVTICAgICAgPSAxOTtcbi8qIG51bWJlciBvZiBjb2RlcyB1c2VkIHRvIHRyYW5zZmVyIHRoZSBiaXQgbGVuZ3RocyAqL1xuXG52YXIgSEVBUF9TSVpFICAgICA9IDIgKiBMX0NPREVTICsgMTtcbi8qIG1heGltdW0gaGVhcCBzaXplICovXG5cbnZhciBNQVhfQklUUyAgICAgID0gMTU7XG4vKiBBbGwgY29kZXMgbXVzdCBub3QgZXhjZWVkIE1BWF9CSVRTIGJpdHMgKi9cblxudmFyIEJ1Zl9zaXplICAgICAgPSAxNjtcbi8qIHNpemUgb2YgYml0IGJ1ZmZlciBpbiBiaV9idWYgKi9cblxuXG4vKiA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbiAqIENvbnN0YW50c1xuICovXG5cbnZhciBNQVhfQkxfQklUUyA9IDc7XG4vKiBCaXQgbGVuZ3RoIGNvZGVzIG11c3Qgbm90IGV4Y2VlZCBNQVhfQkxfQklUUyBiaXRzICovXG5cbnZhciBFTkRfQkxPQ0sgICA9IDI1Njtcbi8qIGVuZCBvZiBibG9jayBsaXRlcmFsIGNvZGUgKi9cblxudmFyIFJFUF8zXzYgICAgID0gMTY7XG4vKiByZXBlYXQgcHJldmlvdXMgYml0IGxlbmd0aCAzLTYgdGltZXMgKDIgYml0cyBvZiByZXBlYXQgY291bnQpICovXG5cbnZhciBSRVBaXzNfMTAgICA9IDE3O1xuLyogcmVwZWF0IGEgemVybyBsZW5ndGggMy0xMCB0aW1lcyAgKDMgYml0cyBvZiByZXBlYXQgY291bnQpICovXG5cbnZhciBSRVBaXzExXzEzOCA9IDE4O1xuLyogcmVwZWF0IGEgemVybyBsZW5ndGggMTEtMTM4IHRpbWVzICAoNyBiaXRzIG9mIHJlcGVhdCBjb3VudCkgKi9cblxuLyogZXNsaW50LWRpc2Fib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WVbUkVQWl8xMV8xMzggKiAyXS8qLkZyZXEqLysrO1xuICAgIH1cblxuICAgIGNvdW50ID0gMDtcbiAgICBwcmV2bGVuID0gY3VybGVuO1xuXG4gICAgaWYgKG5leHRsZW4gPT09IDApIHtcbiAgICAgIG1heF9jb3VudCA9IDEzODtcbiAgICAgIG1pbl9jb3VudCA9IDM7XG5cbiAgICB9IGVsc2UgaWYgKGN1cmxlbiA9PT0gbmV4dGxlbikge1xuICAgICAgbWF4X2NvdW50ID0gNjtcbiAgICAgIG1pbl9jb3VudCA9IDM7XG5cbiAgICB9IGVsc2Uge1xuICAgICAgbWF4X2NvdW50ID0gNztcbiAgICAgIG1pbl9jb3VudCA9IDQ7XG4gICAgfVxuICB9XG59XG5cblxuLyogPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4gKiBTZW5kIGEgbGl0ZXJhbCBvciBkaXN0YW5jZSB0cmVlIGluIGNvbXByZXNzZWQgZm9ybSwgdXNpbmcgdGhlIGNvZGVzIGluXG4gKiBibF90cmVlLlxuICovXG5mdW5jdGlvbiBzZW5kX3RyZWUocywgdHJlZSwgbWF4X2NvZGUpXG4vLyAgICBkZWZsYXRlX3N0YXRlICpzO1xuLy8gICAgY3RfZGF0YSAqdHJlZTsgLyogdGhlIHRyZWUgdG8gYmUgc2Nhbm5lZCAqL1xuLy8gICAgaW50IG1heF9jb2RlOyAgICAgICAvKiBhbmQgaXRzIGxhcmdlc3QgY29kZSBvZiBub24gemVybyBmcmVxdWVuY3kgKi9cbntcbiAgdmFyIG47ICAgICAgICAgICAgICAgICAgICAgLyogaXRlcmF0ZXMgb3ZlciBhbGwgdHJlZSBlbGVtZW50cyAqL1xuICB2YXIgcHJldmxlbiA9IC0xOyAgICAgICAgICAvKiBsYXN0IGVtaXR0ZWQgbGVuZ3RoICovXG4gIHZhciBjdXJsZW47ICAgICAgICAgICAgICAgIC8qIGxlbmd0aC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zZXJ0KGNvdW50ID49IDMgJiYgY291bnQgPD0gNiwgXCIgM182P1wiKTtcbiAgICAgIHNlbmRfY29kZShzLCBSRVBfM182LCBzLmJsX3RyZWUpO1xuICAgICAgc2VuZF9iaXRzKHMsIGNvdW50IC0gMywgMik7XG5cbiAgICB9IGVsc2UgaWYgKGNvdW50IDw9IDEwKSB7XG4gICAgICBzZW5kX2NvZGUocywgUkVQWl8zXzEwLCBzLmJsX3RyZWUpO1xuICAgICAgc2VuZF9iaXRzKHMsIGNvdW50IC0gMywgMyk7XG5cbiAgICB9IGVsc2Uge1xuICAgICAgc2VuZF9jb2RlKHMsIFJFUFpfMTFfMTM4LCBzLmJsX3RyZWUpO1xuICAgICAgc2VuZF9iaXRzKHMsIGNvdW50IC0gMTEsIDcpO1xuICAgIH1cblxuICAgIGNvdW50ID0gMDtcbiAgICBwcmV2bGVuID0gY3VybGVuO1xuICAgIGlmIChuZXh0bGVuID09PSAwKSB7XG4gICAgICBtYXhfY291bnQgPSAxMzg7XG4gICAgICBtaW5fY291bnQgPSAzO1xuXG4gICAgfSBlbHNlIGlmIChjdXJsZW4gPT09IG5leHRsZW4pIHtcbiAgICAgIG1heF9jb3VudCA9IDY7XG4gICAgICBtaW5fY291bnQgPSAzO1xuXG4gICAgfSBlbHNlIHtcbiAgICAgIG1heF9jb3VudCA9IDc7XG4gICAgICBtaW5fY291bnQgPSA0O1xuICAgIH1cbiAgfVxufVxuXG5cbi8qID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuICogQ29uc3RydWN0IHRoZSBIdWZmbWFuIHRyZWUgZm9yIHRoZSBiaXQgbGVuZ3RocyBhbmQgcmV0dXJuIHRoZSBpbmRleCBpblxuICogYmxfb3JkZXIgb2YgdGhlIGxhc3QgYml0IGxlbmd0aCBjb2RlIHRvIHNlbmQuXG4gKi9cbmZ1bmN0aW9uIGJ1aWxkX2JsX3RyZWUocykge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AgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICB9XG4gICAgICAgIHZhciBwYXJ0ID0gcGFydHNbaV07XG5cbiAgICAgICAgdmFyIGJyYWNrZXRFcXVhbHNQb3MgPSBwYXJ0LmluZGV4T2YoJ109Jyk7XG4gICAgICAgIHZhciBwb3MgPSBicmFja2V0RXF1YWxzUG9zID09PSAtMSA/IHBhcnQuaW5kZXhPZignPScpIDogYnJhY2tldEVxdWFsc1BvcyArIDE7XG5cbiAgICAgICAgdmFyIGtleSwgdmFsO1xuICAgICAgICBpZiAocG9zID09PSAtMSkge1xuICAgICAgICAgICAga2V5ID0gb3B0aW9ucy5kZWNvZGVyKHBhcnQsIGRlZmF1bHRzLmRlY29kZXIsIGNoYXJzZXQsICdrZXknKTtcbiAgICAgICAgICAgIHZhbCA9IG9wdGlvbnMuc3RyaWN0TnVsbEhhbmRsaW5nID8gbnVsbCA6ICcnO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAga2V5ID0gb3B0aW9ucy5kZWNvZGVyKHBhcnQuc2xpY2UoMCwgcG9zKSwgZGVmYXVsdHMuZGVjb2RlciwgY2hhcnNldCwgJ2tleScpO1xuICAgICAgICAgICAgdmFsID0gdXRpbHMubWF5YmVNYXAoXG4gICAgICAgICAgICAgICAgcGFyc2VBcnJheVZhbHVlKHBhcnQuc2xpY2UocG9zICsgMSksIG9wdGlvbnMpLFxuICAgICAgICAgICAgICAgIGZ1bmN0aW9uIChlbmNvZGVkVmFsKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBvcHRpb25zLmRlY29kZXIoZW5jb2RlZFZhbCwgZGVmYXVsdHMuZGVjb2RlciwgY2hhcnNldCwgJ3ZhbHVlJyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh2YWwgJiYgb3B0aW9ucy5pbnRlcnByZXROdW1lcmljRW50aXRpZXMgJiYgY2hhcnNldCA9PT0gJ2l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ROdWxsSGFuZGxpbmcgJiYgbGVhZiA9PT0gbnVsbCkpXG4gICAgICAgICAgICAgICAgPyBbXVxuICAgICAgICAgICAgICAgIDogW10uY29uY2F0KGxlYWYpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgb2JqID0gb3B0aW9ucy5wbGFpbk9iamVjdHMgPyBPYmplY3QuY3JlYXRlKG51bGwpIDoge307XG4gICAgICAgICAgICB2YXIgY2xlYW5Sb290ID0gcm9vdC5jaGFyQXQoMCkgPT09ICdbJyAmJiByb290LmNoYXJBdChyb290Lmxlbmd0aCAtIDEpID09PSAnXScgPyByb290LnNsaWNlKDEsIC0xKSA6IHJvb3Q7XG4gICAgICAgICAgICB2YXIgZGVjb2RlZFJvb3QgPSBvcHRpb25zLmRlY29kZURvdEluS2V5cyA/IGNsZWFuUm9vdC5yZXBsYWNlKC8lMkUvZywgJy4nKSA6IGNsZWFuUm9vdDtcbiAgICAgICAgICAgIHZhciBpbmRleCA9IHBhcnNlSW50KGRlY29kZWRSb290LCAxMCk7XG4gICAgICAgICAgICBpZiAoIW9wdGlvbnMucGFyc2VBcnJheXMgJiYgZGVjb2RlZFJvb3QgPT09ICcnKSB7XG4gICAgICAgICAgICAgICAgb2JqID0geyAwOiBsZWFmIH07XG4gICAgICAgICAgICB9IGVsc2UgaWYgKFxuICAgICAgICAgICAgICAgICFpc05hTihpbmRleClcbiAgICAgICAgICAgICAgICAmJiByb290ICE9PSBkZWNvZGVkUm9vdFxuICAgICAgICAgICAgICAgICYmIFN0cmluZyhpbmRleCkgPT09IGRlY29kZWRSb290XG4gICAgICAgICAgICAgICAgJiYgaW5kZXggPj0gMFxuICAgICAgICAgICAgICAgICYmIChvcHRpb25zLnBhcnNlQXJyYXlzICYmIGluZGV4IDw9IG9wdGlvbnMuYXJyYXlMaW1pdClcbiAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgIG9iaiA9IFtdO1xuICAgICAgICAgICAgICAgIG9ialtpbmRleF0gPSBsZWF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7XG4gICAgdmFyIG9iaiA9IG9iamVjdDtcblxuICAgIHZhciB0bXBTYyA9IHNpZGVDaGFubmVsO1xuICAgIHZhciBzdGVwID0gMDtcbiAgICB2YXIgZmluZEZsYWcgPSBmYWxzZTtcbiAgICB3aGlsZSAoKHRtcFNjID0gdG1wU2MuZ2V0KHNlbnRpbmVsKSkgIT09IHZvaWQgdW5kZWZpbmVkICYmICFmaW5kRmxhZykge1xuICAgICAgICAvLyBXaGVyZSBvYmplY3QgbGFzdCBhcHBlYXJlZCBpbiB0aGUgcmVmIHRyZWVcbiAgICAgICAgdmFyIHBvcyA9IHRtcFNjLmdldChvYmplY3QpO1xuICAgICAgICBzdGVwICs9IDE7XG4gICAgICAgIGlmICh0eXBlb2YgcG9zICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgaWYgKHBvcyA9PT0gc3RlcCkge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBSYW5nZUVycm9yKCdDeWNsaWMgb2JqZWN0IHZhbHVlJyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGZpbmRGbGFnID0gdHJ1ZTsgLy8gQnJlYWsgd2hpbGVcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodHlwZW9mIHRtcFNjLmdldChzZW50aW5lbCkgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICBzdGVwID0gMDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGlmICh0eXBlb2YgZmlsdGVyID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIG9iaiA9IGZpbHRlcihwcmVmaXgsIG9iaik7XG4gICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBEYXRlKSB7XG4gICAgICAgIG9iaiA9IHNlcmlhbGl6ZURhdGUob2JqKTtcbiAgICB9IGVsc2UgaWYgKGdlbmVyYXRlQXJyYXlQcmVmaXggPT09ICdjb21tYScgJiYgaXNBcnJheShvYmopKS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heSh2YWx1ZXMsIHN0cmluZ2lmeShcbiAgICAgICAgICAgIHZhbHVlLFxuICAgICAgICAgICAga2V5UHJlZml4LFxuICAgICAgICAgICAgZ2VuZXJhdGVBcnJheVByZWZpeCxcbiAgICAgICAgICAgIGNvbW1hUm91bmRUcmlwLFxuICAgICAgICAgICAgYWxsb3dFbXB0eUFycmF5cyxcbiAgICAgICAgICAgIHN0cmljdE51bGxIYW5kbGluZyxcbiAgICAgICAgICAgIHNraXBOdWxscyxcbiAgICAgICAgICAgIGVuY29kZURvdEluS2V5cyxcbiAgICAgICAgICAgIGdlbmVyYXRlQXJyYXlQcmVmaXggPT09ICdjb21tYScgJiYgZW5jb2RlVmFsdWVzT25seSAmJiBpc0FycmF5KG9iaikgPyBudWxsIDogZW5jb2RlcixcbiAgICAgICAgICAgIGZpbHRlcixcbiAgICAgICAgICAgIHNvcnQsXG4gICAgICAgICAgICBhbGxvd0RvdHMsXG4gICAgICAgICAgICBzZXJpYWxpemVEYXRlLFxuICAgICAgICAgICAgZm9ybWF0LFxuICAgICAgICAgICAgZm9ybWF0dGVyLFxuICAgICAgICAgICAgZW5jb2RlVmFsdWVzT25seSxcbiAgICAgICAgICAgIGNoYXJzZXQsXG4gICAgICAgICAgICB2YWx1ZVNpZGVDaGFubmVsXG4gICAgICAgICkpO1xuICAgIH1cblxuICAgIHJldHVybiB2YWx1ZXM7XG59O1xuXG52YXIgbm9ybWFsaXplU3RyaW5naWZ5T3B0aW9ucyA9IGZ1bmN0aW9uIG5vcm1hbGl6ZVN0cmluZ2lmeU9wdGlvbnMob3B0cykge1xuICAgIGlmICghb3B0cykge1xuICAgICAgICByZXR1cm4gZGVmYXVsdHM7XG4gICAgfVxuXG4gICAgaWYgKHR5cGVvZiBvcHRzLmFsbG93RW1wdHlBcnJheXMgIT09ICd1bmRlZmluZWQnICYmIHR5cGVvZiBvcHRzLmFsbG93RW1wdHlBcnJheXMgIT09ICdib29sZWFuJykge1xuICAgICAgICB0aHJvdyBuZXcg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cHRpb25zLnNvcnQpIHtcbiAgICAgICAgb2JqS2V5cy5zb3J0KG9wdGlvbnMuc29ydCk7XG4gICAgfVxuXG4gICAgdmFyIHNpZGVDaGFubmVsID0gZ2V0U2lkZUNoYW5uZWwoKTtcbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IG9iaktleXMubGVuZ3RoOyArK2kpIHtcbiAgICAgICAgdmFyIGtleSA9IG9iaktleXNbaV07XG5cbiAgICAgICAgaWYgKG9wdGlvbnMuc2tpcE51bGxzICYmIG9ialtrZXldID09PSBudWxsKSB7XG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuICAgICAgICBwdXNoVG9BcnJheShrZXlzLCBzdHJpbmdpZnkoXG4gICAgICAgICAgICBvYmpba2V5XSxcbiAgICAgICAgICAgIGtleSxcbiAgICAgICAgICAgIGdlbmVyYXRlQXJyYXlQcmVmaXgsXG4gICAgICAgICAgICBjb21tYVJvdW5kVHJpcCxcbiAgICAgICAgICAgIG9wdGlvbnMuYWxsb3dFbXB0eUFycmF5cyxcbiAgICAgICAgICAgIG9wdGlvbnMuc3RyaWN0TnVsbEhhbmRsaW5nLFxuICAgICAgICAgICAgb3B0aW9ucy5za2lwTnVsbHMsXG4gICAgICAgICAgICBvcHRpb25zLmVuY29kZURvdEluS2V5cyxcbiAgICAgICAgICAgIG9wdGlvbnMuZW5jb2RlID8gb3B0aW9ucy5lbmNvZGVyIDogbnVsbCxcbiAgICAgICAgICAgIG9wdGlvbnMuZmlsdGVyLFxuICAgICAgICAgICAgb3B0aW9ucy5zb3J0LFxuICAgICAgICAgICAgb3B0aW9ucy5hbGxvd0RvdHMsXG4gICAgICAgICAgICBvcHRpb25zLnNlcmlhbGl6ZURhdGUsXG4gICAgICAgICAgICBvcHRpb25zLmZvcm1hdCxcbiAgICAgICAgICAgIG9wdGlvbnMuZm9ybWF0dGVyLFxuICAgICAgICAgICAgb3B0aW9ucy5lbmNvZGVWYWx1ZXNPbmx5LFxuICAgICAgICAgIC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CBzZWdtZW50Lmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICB2YXIgYyA9IHNlZ21lbnQuY2hhckNvZGVBdChpKTtcbiAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICBjID09PSAweDJEIC8vIC1cbiAgICAgICAgICAgICAgICB8fCBjID09PSAweDJFIC8vIC5cbiAgICAgICAgICAgICAgICB8fCBjID09PSAweDVGIC8vIF9cbiAgICAgICAgICAgICAgICB8fCBjID09PSAweDdFIC8vIH5cbiAgICAgICAgICAgICAgICB8fCAoYyA+PSAweDMwICYmIGMgPD0gMHgzOSkgLy8gMC05XG4gICAgICAgICAgICAgICAgfHwgKGMgPj0gMHg0MSAmJiBjIDw9IDB4NUEpIC8vIGEtelxuICAgICAgICAgICAgICAgIHx8IChjID49IDB4NjEgJiYgYyA8PSAweDdBKSAvLyBBLVpcbiAgICAgICAgICAgICAgICB8fCAoZm9ybWF0ID09PSBmb3JtYXRzLlJGQzE3MzggJiYgKGMgPT09IDB4MjggfHwgYyA9PT0gMHgyOSkpIC8vICggKVxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgYXJyW2Fyci5sZW5ndGhdID0gc2VnbWVudC5jaGFyQXQoaSk7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChjIDwgMHg4MCkge1xuICAgICAgICAgICAgICAgIGFyclthcnIubGVuZ3RoXSA9IGhleFRhYmxlW2NdO1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoYyA8IDB4ODAwKSB7XG4gICAgICAgICAgICAgICAgYXJyW2Fyci5sZW5ndGhdID0gaGV4VGFibGVbMHhDMCB8IChjID4+IDYpXVxuICAgICAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoYyAmIDB4M0YpXTtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGMgPCAweEQ4MDAgfHwgYyA+PSAweEUwMDApIHtcbiAgICAgICAgICAgICAgICBhcnJbYXJyLmxlbmd0aF0gPSBoZXhUYWJsZVsweEUwIHwgKGMgPj4gMTIpXVxuICAgICAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoKGMgPj4gNikgJiAweDNGKV1cbiAgICAgICAgICAgICAgICAgICAgKyBoZXhUYWJsZVsweDgwIHwgKGMgJiAweDNGKV07XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGkgKz0gMTtcbiAgICAgICAgICAgIGMgPSAweDEwMDAwICsgKCgoYyAmIDB4M0ZGKSA8PCAxMCkgfCAoc2VnbWVudC5jaGFyQ29kZUF0KGkpICYgMHgzRkYpKTtcblxuICAgICAgICAgICAgYXJyW2Fyci5sZW5ndGhdID0gaGV4VGFibGVbMHhGMCB8IChjID4+IDE4KV1cbiAgICAgICAgICAgICAgICArIGhleFRhYmxlWzB4ODAgfCAoKGMgPj4gMTIpICYgMHgzRildXG4gICAgICAgICAgICAgICAgKyBoZXhUYWJsZVsweDgwIHwgKChjID4+IDYpICYgMHgzRildXG4gICAgICAgICAgICAgICAgKyBoZXhUYWJsZVsweDgwIHwgKGMgJiAweDNGKV07XG4gICAgICAgIH1cblxuICAgICAgICBvdXQgKz0gYXJyLmpvaW4oJycpO1xuICAgIH1cblxuICAgIHJldHVybiBvdXQ7XG59O1xuXG52YXIgY29tcGFjdCA9IGZ1bmN0aW9uIGNvbXBhY3QodmFsdWUpIHtcbiAgICB2YXIgcXVldWUgPSBbeyBvYmo6IHsgbzogdmFsdWUgfSwgcHJvcDogJ28nIH1dO1xuICAgIHZhciByZWZzID0gW107XG5cbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IHF1ZXVlLmxlbmd0aDsgKytpKSB7XG4gICAgICAgIHZhciBpdGVtID0gcXVldWVbaV07XG4gICAgICAgIHZhciBvYmogPSBpdGVtLm9ialtpdGVtLnByb3BdO1xuXG4gICAgICAgIHZhciBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcbiAgICAgICAgZm9yICh2YXIgaiA9IDA7IGogPCBrZXlzLmxlbmd0aDsgKytqKSB7XG4gICAgICAgICAgICB2YXIga2V5ID0ga2V5c1tqXTtcbiAgICAgICAgICAgIHZhciB2YWwgPSBvYmpba2V5XTtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsID09PSAnb2JqZWN0JyAmJiB2YWwgIT09IG51bGwgJiYgcmVmcy5pbmRleE9mKHZhbCkgPT09IC0xKSB7XG4gICAgICAgICAgICAgICAgcXVldWUucHVzaCh7IG9iajogb2JqLCBwcm9wOiBrZXkgfSk7XG4gICAgICAgICAgICAgICAgcmVmcy5wdXNoKHZhbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjb21wYWN0UXVldWUocXVldWUpO1xuXG4gICAgcmV0dXJuIHZhbHVlO1xufTtcblxudmFyIGlzUmVnRXhwID0gZnVuY3Rpb24gaXNSZWdFeHAob2JqKSB7XG4gICAgcmV0dXJuIE9iamVjdC5wcm90b3R5cGUudG9TdHJpbmcuY2FsbChvYmopID09PSAnW29iamVjdCBSZWdFeHBdJztcbn07XG5cbnZhciBpc0J1ZmZlciA9IGZ1bmN0aW9uIGlzQnVmZmVyKG9iaikge1xuICAgIGlmICghb2JqIHx8IHR5cGVvZiBvYmogIT09ICdvYmplY3QnKSB7XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG5cbiAgICByZXR1cm4gISEob2JqLmNvbnN0cnVjdG9yICYmIG9iai5jb25zdHJ1Y3Rvci5pc0J1ZmZlciAmJiBvYmouY29uc3RydWN0b3IuaXNCdWZmZXIob2JqKSk7XG59O1xuXG52YXIgY29tYmluZSA9IGZ1bmN0aW9uIGNvbWJpbmUoYSwgYikge1xuICAgIHJldHVybiBbXS5jb25jYXQoYS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ZXN1bHQgPSBraW5kID09PSAnTidcbiAgICAgICAgICAgID9cbiAgICAgICAgICAgICAgICBvZih2YWx1ZSlcbiAgICAgICAgICAgIDpcbiAgICAgICAgICAgICAgICBraW5kID09PSAnRSdcbiAgICAgICAgICAgICAgICAgICAgP1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dFcnJvcihmdW5jdGlvbiAoKSB7IHJldHVybiBlcnJvcjsgfSlcbiAgICAgICAgICAgICAgICAgICAgOlxuICAgICAgICAgICAgICAgICAgICAgICAga2luZCA9PT0gJ0MnXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgP1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFTVBUWVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMDtcbiAgICAgICAgaWYgKCFyZXN1bHQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoXCJVbmV4cGVjdGVkIG5vdGlmaWNhdGlvbiBraW5kIFwiICsga2luZCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9O1xuICAgIE5vdGlmaWNhdGlvbi5jcmVhdGVOZXh0ID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgIHJldHVybiBuZXcgTm90aWZpY2F0aW9uKCdOJywgdmFsdWUpO1xuICAgIH07XG4gICAgTm90aWZpY2F0aW9uLmNyZWF0ZUVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICByZXR1cm4gbmV3IE5vdGlmaWNhdGlvbignRScsIHVuZGVmaW5lZCwgZXJyKTtcbiAgICB9O1xuICAgIE5vdGlmaWNhdGlvbi5jcmVhdGVDb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgcmV0dXJuIE5vdGlmaWNhdGlvbi5jb21wbGV0ZU5vdGlmaWNhdGlvbjtcbiAgICB9O1xuICAgIE5vdGl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VxuICAgICAgICAgICAgICAgICAgICA/XG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5fc3Vic2NyaWJlKHN1YnNjcmliZXIpXG4gICAgICAgICAgICAgICAgICAgIDpcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLl90cnlTdWJzY3JpYmUoc3Vic2NyaWJlcikpO1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIHN1YnNjcmliZXI7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZS5fdHJ5U3Vic2NyaWJlID0gZnVuY3Rpb24gKHNpbmspIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdWJzY3JpYmUoc2luayk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgc2luay5lcnJvcihlcnIpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZS5mb3JFYWNoID0gZnVuY3Rpb24gKG5leHQsIHByb21pc2VDdG9yKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHByb21pc2VDdG9yID0gZ2V0UHJvbWlzZUN0b3IocHJvbWlzZUN0b3IpO1xuICAgICAgICByZXR1cm4gbmV3IHByb21pc2VDdG9yKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgICAgIHZhciBzdWJzY3JpcHRpb247XG4gICAgICAgICAgICBzdWJzY3JpcHRpb24gPSBfdGhpcy5zdWJzY3JpYmUoZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgbmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVqZWN0KGVycik7XG4gICAgICAgICAgICAgIC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AgICAgIGZvciAodmFyIGNvcHlfMSA9IF9fdmFsdWVzKGNvcHkpLCBjb3B5XzFfMSA9IGNvcHlfMS5uZXh0KCk7ICFjb3B5XzFfMS5kb25lOyBjb3B5XzFfMSA9IGNvcHlfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYnNlcnZlciA9IGNvcHlfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgb2JzZXJ2ZXIubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVfMV8xKSB7IGVfMSA9IHsgZXJyb3I6IGVfMV8xIH07IH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3B5XzFfMSAmJiAhY29weV8xXzEuZG9uZSAmJiAoX2EgPSBjb3B5XzEucmV0dXJuKSkgX2EuY2FsbChjb3B5XzEpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGZpbmFsbHkgeyBpZiAoZV8xKSB0aHJvdyBlXzEuZXJyb3I7IH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgU3ViamVjdC5wcm90b3R5cGUuZXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIGVycm9yQ29udGV4dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBfdGhpcy5fdGhyb3dJZkNsb3NlZCgpO1xuICAgICAgICAgICAgaWYgKCFfdGhpcy5pc1N0b3BwZWQpIHtcbiAgICAgICAgICAgICAgICBfdGhpcy5oYXNFcnJvciA9IF90aGlzLmlzU3RvcHBlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgX3RoaXMudGhyb3duRXJyb3IgPSBlcnI7XG4gICAgICAgICAgICAgICAgdmFyIG9ic2VydmVycyA9IF90aGlzLm9ic2VydmVycztcbiAgICAgICAgICAgICAgICB3aGlsZSAob2JzZXJ2ZXJzLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBvYnNlcnZlcnMuc2hpZnQoKS5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS5jb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgZXJyb3JDb250ZXh0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIF90aGlzLl90aHJvd0lmQ2xvc2VkKCk7XG4gICAgICAgICAgICBpZiAoIV90aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgICAgIF90aGlzLmlzU3RvcHBlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgdmFyIG9ic2VydmVycyA9IF90aGlzLm9ic2VydmVycztcbiAgICAgICAgICAgICAgICB3aGlsZSAob2JzZXJ2ZXJzLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBvYnNlcnZlcnMuc2hpZnQoKS5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS51bnN1YnNjcmliZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdGhpcy5pc1N0b3BwZWQgPSB0aGlzLmNsb3NlZCA9IHRydWU7XG4gICAgICAgIHRoaXMub2JzZXJ2ZXJzID0gbnVsbDtcbiAgICB9O1xuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShTdWJqZWN0LnByb3RvdHlwZSwgXCJvYnNlcnZl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lKTtcbiAgICB9O1xuICAgIFN1YnNjcmliZXIucHJvdG90eXBlLm5leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgaWYgKHRoaXMuaXNTdG9wcGVkKSB7XG4gICAgICAgICAgICBoYW5kbGVTdG9wcGVkTm90aWZpY2F0aW9uKG5leHROb3RpZmljYXRpb24odmFsdWUpLCB0aGlzKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuX25leHQodmFsdWUpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBTdWJzY3JpYmVyLnByb3RvdHlwZS5lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgaWYgKHRoaXMuaXNTdG9wcGVkKSB7XG4gICAgICAgICAgICBoYW5kbGVTdG9wcGVkTm90aWZpY2F0aW9uKGVycm9yTm90aWZpY2F0aW9uKGVyciksIHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5pc1N0b3BwZWQgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5fZXJyb3IoZXJyKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgU3Vic2NyaWJlci5wcm90b3R5cGUuY29tcGxldGUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGlmICh0aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgaGFuZGxlU3RvcHBlZE5vdGlmaWNhdGlvbihDT01QTEVURV9OT1RJRklDQVRJT04sIHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5pc1N0b3BwZWQgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5fY29tcGxldGUoKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgU3Vic2NyaWJlci5wcm90b3R5cGUudW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGlmICghdGhpcy5jbG9zZ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ldGUpIHtcbiAgICAgICAgdmFyIF90aGlzID0gX3N1cGVyLmNhbGwodGhpcykgfHwgdGhpcztcbiAgICAgICAgdmFyIG5leHQ7XG4gICAgICAgIGlmIChpc0Z1bmN0aW9uKG9ic2VydmVyT3JOZXh0KSkge1xuICAgICAgICAgICAgbmV4dCA9IG9ic2VydmVyT3JOZXh0O1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKG9ic2VydmVyT3JOZXh0KSB7XG4gICAgICAgICAgICAobmV4dCA9IG9ic2VydmVyT3JOZXh0Lm5leHQsIGVycm9yID0gb2JzZXJ2ZXJPck5leHQuZXJyb3IsIGNvbXBsZXRlID0gb2JzZXJ2ZXJPck5leHQuY29tcGxldGUpO1xuICAgICAgICAgICAgdmFyIGNvbnRleHRfMTtcbiAgICAgICAgICAgIGlmIChfdGhpcyAmJiBjb25maWcudXNlRGVwcmVjYXRlZE5leHRDb250ZXh0KSB7XG4gICAgICAgICAgICAgICAgY29udGV4dF8xID0gT2JqZWN0LmNyZWF0ZShvYnNlcnZlck9yTmV4dCk7XG4gICAgICAgICAgICAgICAgY29udGV4dF8xLnVuc3Vic2NyaWJlID0gZnVuY3Rpb24gKCkgeyByZXR1cm4gX3RoaXMudW5zdWJzY3JpYmUoKTsgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnRleHRfMSA9IG9ic2VydmVyT3JOZXh0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbmV4dCA9IG5leHQgPT09IG51bGwgfHwgbmV4dCA9PT0gdm9pZCAwID8gdm9pZCAwIDogbmV4dC5iaW5kKGNvbnRleHRfMSk7XG4gICAgICAgICAgICBlcnJvciA9IGVycm9yID09PSBudWxsIHx8IGVycm9yID09PSB2b2lkIDAgPyB2b2lkIDAgOiBlcnJvci5iaW5kKGNvbnRleHRfMSk7XG4gICAgICAgICAgICBjb21wbGV0ZSA9IGNvbXBsZXRlID09PSBudWxs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gICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwYXJlbnRfMSA9IF9wYXJlbnRhZ2VfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudF8xLnJlbW92ZSh0aGlzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICAgICAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9wYXJlbnRhZ2VfMV8xICYmICFfcGFyZW50YWdlXzFfMS5kb25lICYmIChfYSA9IF9wYXJlbnRhZ2VfMS5yZXR1cm4pKSBfYS5jYWxsKF9wYXJlbnRhZ2VfMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMSkgdGhyb3cgZV8xLmVycm9yOyB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIF9wYXJlbnRhZ2UucmVtb3ZlKHRoaXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBpbml0aWFsVGVhcmRvd24gPSB0aGlzLmluaXRpYWxUZWFyZG93bjtcbiAgICAgICAgICAgIGlmIChpc0Z1bmN0aW9uKGluaXRpYWxUZWFyZG93bikpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBpbml0aWFsVGVhcmRvd24oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gZSBpbnN0YW5jZW9mIFVuc3Vic2NyaXB0aW9uRXJyb3IgPyBlLmVycm9ycyA6IFtlXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgX3RlYXJkb3ducyA9IHRoaXMuX3RlYXJkb3ducztcbiAgICAgICAgICAgIGlmIChfdGVhcmRvd25zKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdGVhcmRvd25zID0gbnVsbDtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBfdGVhcmRvd25zXzEgPSBfX3ZhbHVlcyhfdGVhcmRvd25zKSwgX3RlYXJkb3duc18xXzEgPSBfdGVhcmRvd25zXzEubmV4dCgpOyAhX3RlYXJkb3duc18xXzEuZG9uZTsgX3RlYXJkb3duc18xXzEgPSBfdGVhcmRvd25zXzEubmV4dCgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVhcmRvd25fMSA9IF90ZWFyZG93bnNfMV8xLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleGVjVGVhcmRvd24odGVhcmRvd25fMSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gZXJyb3JzICE9PSBudWxsICYmIGVycm9ycyAhPT0gdm9pZCAwID8gZXJyb3JzIDogW107XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIFVuc3Vic2NyaXB0aW9uRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gX19zcHJlYWRBcnJheShfX3NwcmVhZEFycmF5KFtdLCBfX3JlYWQoZXJyb3JzKSksIF9fcmVhZChlcnIuZXJyb3JzKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZV8yXzEpIHsgZV8yID0geyBlcnJvcjogZV8yXzEgfTsgfVxuICAgICAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF90ZWFyZG93bnNfMV8xICYmICFfdGVhcmRvd25zXzFfMS5kb25lICYmIChfYiA9IF90ZWFyZG93bnNfMS5yZXR1cm4pKSBfYi5jYWxsKF90ZWFyZG93bnNfMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzIpIHRocm93IGVfMi5lcnJvcjsgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChlcnJvcnMpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgVW5zdWJzY3JpcHRpb25FcnJvcihlcnJvcnMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBTdWJzY3JpcHRpb24ucHJvdG90eXBlLmFkZCA9IGZ1bmN0aW9uICh0ZWFyZG93bikge1xuICAgICAgICB2YXIgX2E7XG4gICAgICAgIGlmICh0ZWFyZG93biAmJiB0ZWFyZG93biAhPT0gdGhpcykge1xuICAgICAgICAgICAgaWYgKHRoaXMuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgZXhlY1RlYXJkb3duKHRlYXJkb3duK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mlyc3RWYWx1ZUZyb20oc291cmNlLCBjb25maWcpIHtcbiAgICB2YXIgaGFzQ29uZmlnID0gdHlwZW9mIGNvbmZpZyA9PT0gJ29iamVjdCc7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgdmFyIHN1YnNjcmliZXIgPSBuZXcgU2FmZVN1YnNjcmliZXIoe1xuICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgcmVzb2x2ZSh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGVycm9yOiByZWplY3QsXG4gICAgICAgICAgICBjb21wbGV0ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGlmIChoYXNDb25maWcpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShjb25maWcuZGVmYXVsdFZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRW1wdHlFcnJvcigpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICB9KTtcbiAgICAgICAgc291cmNlLnN1YnNjcmliZShzdWJzY3JpYmVyKTtcbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWZpcnN0VmFsdWVGcm9tLmpzLm1hcCIsImltcG9ydCB7IEVtcHR5RXJyb3IgfSBmcm9tICcuL3V0aWwvRW1wdHlFcnJvcic7XG5leHBvcnQgZnVuY3Rpb24gbGFzdFZhbHVlRnJvbShzb3VyY2UsIGNvbmZpZykge1xuICAgIHZhciBoYXNDb25maWcgPSB0eXBlb2YgY29uZmlnID09PSAnb2JqZWN0JztcbiAgICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICB2YXIgX2hhc1ZhbHVlID0gZmFsc2U7XG4gICAgICAgIHZhciBfdmFsdWU7XG4gICAgICAgIHNvdXJjZS5zdWJzY3JpYmUoe1xuICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgX3ZhbHVlID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgX2hhc1ZhbHVlID0gdHJ1ZTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBlcnJvcjogcmVqZWN0LFxuICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpZiAoX2hhc1ZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc29sdmUoX3ZhbHVlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoaGFzQ29uZmlnKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc29sdmUoY29uZmlnLmRlZmF1bHRWYWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVtcHR5RXJyb3IoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1sYXN0VmFsdWVGcm9tLmpzLm1hcCIsImltcG9ydCB7IF9fZXh0ZW5kcyB9IGZyb20gXCJ0c2xpYlwiO1xuaW1wb3J0IHsgT2JzZXJ2YWJsZSB9IGZyb20gJy4uL09ic2VydmFibGUnO1xuaW1wb3J0IHsgU3Vic2NyaXB0aW9uIH0gZnJvbSAnLi4vU3Vic2NyaXB0aW9uJztcbmltcG9ydCB7IHJlZkNvdW50IGFzIGhpZ2hlck9yZGVyUmVmQ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ic2NyaWJlcihzdWJqZWN0XzEsIHVuZGVmaW5lZCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIF90aGlzLl90ZWFyZG93bigpO1xuICAgICAgICAgICAgICAgIHN1YmplY3RfMS5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfSwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIF90aGlzLl90ZWFyZG93bigpO1xuICAgICAgICAgICAgICAgIHN1YmplY3RfMS5lcnJvcihlcnIpO1xuICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkgeyByZXR1cm4gX3RoaXMuX3RlYXJkb3duKCk7IH0pKSk7XG4gICAgICAgICAgICBpZiAoY29ubmVjdGlvbi5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9jb25uZWN0aW9uID0gbnVsbDtcbiAgICAgICAgICAgICAgICBjb25uZWN0aW9uID0gU3Vic2NyaXB0aW9uLkVNUFRZO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjb25uZWN0aW9uO1xuICAgIH07XG4gICAgQ29ubmVjdGFibGVPYnNlcnZhYmxlLnByb3RvdHlwZS5yZWZDb3VudCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgcmV0dXJuIGhpZ2hlck9yZGVyUmVmQ291bnQoKSh0aGlzKTtcbiAgICB9O1xuICAgIHJldHVybiBDb25uZWN0YWJsZU9ic2VydmFibGU7XG59KE9ic2VydmFibGUpKTtcbmV4cG9ydCB7IENvbm5lY3RhYmxlT2JzZXJ2YWJsZSB9O1xuLy8jIHNvdXJjZU1hcHBpbmdVUkw9Q29ubmVjdGFibGVPYnNlcnZhYmxlLmpzLm1hcCIsImltcG9ydCB7IGJpbmRDYWxsYmFja0ludGVybmFscyB9IGZyb20gJy4vYmluZENhbGxiYWNrSW50ZXJuYWxzJztcbmV4cG9ydCBmdW5jdGlvbiBiaW5kQ2FsbGJhY2soY2FsbGJhY2tGdW5jLCByZX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gICAgdmFyIGFyZ3MgPSBbXTtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBfaSA9IDA7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xuICAgICAgICAgICAgICAgICAgICBhcmdzW19pXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBiaW5kQ2FsbGJhY2tJbnRlcm5hbHMoaXNOb2RlU3R5bGUsIGNhbGxiYWNrRnVuYywgc2NoZWR1bGVyKVxuICAgICAgICAgICAgICAgICAgICAuYXBwbHkodGhpcywgYXJncylcbiAgICAgICAgICAgICAgICAgICAgLnBpcGUobWFwT25lT3JNYW55QXJncyhyZXN1bHRTZWxlY3RvcikpO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBpZiAoc2NoZWR1bGVyKSB7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgYXJncyA9IFtdO1xuICAgICAgICAgICAgZm9yICh2YXIgX2kgPSAwOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgICAgICBhcmdzW19pXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gYmluZENhbGxiYWNrSW50ZXJuYWxzKGlzTm9kZVN0eWxlLCBjYWxsYmFja0Z1bmMpXG4gICAgICAgICAgICAgICAgLmFwcGx5KHRoaXMsIGFyZ3MpXG4gICAgICAgICAgICAgICAgLnBpcGUoc3Vic2NyaWJlT24oc2NoZWR1bGVyKSwgb2JzZXJ2ZU9uKHNjaGVkdWxlcikpO1xuICAgICAgICB9O1xuICAgIH1cbiAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgYXJncyA9IFtdO1xuICAgICAgICBmb3IgKHZhciBfaSA9IDA7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xuICAgICAgICAgICAgYXJnc1tfaV0gPSBhcmd1bWVudHNbX2ldO1xuICAgICAgICB9XG4gICAgICAgIHZhciBzdWJqZWN0ID0gbmV3IEFzeW5jU3ViamVjdCgpO1xuICAgICAgICB2YXIgdW5pbml0aWFsaXplZCA9IHRydWU7XG4gICAgICAgIHJldHVybiBuZXcgT2JzZXJ2YWJsZShmdW5jdGlvbiAoc3Vic2NyaWJlcikge1xuICAgICAgICAgICAgdmFyIHN1YnMgPSBzdWJqZWN0LnN1YnNjcmliZShzdWJzY3JpYmVyKTtcbiAgICAgICAgICAgIGlmICh1bmluaXRpYWxpemVkKSB7XG4gICAgICAgICAgICAgICAgdW5pbml0aWFsaXplZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHZhciBpc0FzeW5jXzEgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB2YXIgaXNDb21wbGV0ZV8xID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgY2FsbGJhY2tGdW5jLmFwcGx5KF90aGlzLCBfX3NwcmVhZEFycmF5KF9fc3ByZWFkQXJyYXkoW10sIF9fcmVhZChhcmdzKSksIFtcbiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdHMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0c1tfaV0gPSBhcmd1bWVudHNbX2ldO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTm9kZVN0eWxlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVyciA9IHJlc3VsdHMuc2hpZnQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5lcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5uZXh0KDEgPCByZXN1bHRzLmxlbmd0aCA/IHJlc3VsdHMgOiByZXN1bHRzWzBdKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlzQ29tcGxldGVfMSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBc3luY18xKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIF0pKTtcbiAgICAgICAgICAgICAgICBpZiAoaXNDb21wbGV0ZV8xKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YmplY3QuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaXNBc3luY18xID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBzdWJzO1xuICAgICAgICB9KTtcbiAgICB9O1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9YmluZENhbGxiYWNrSW50ZXJuYWxzLmpzLm1hcCIsImltcG9ydCB7IGJpbmRDYWxsYmFja0ludGVybmFscyB9IGZyb20gJy4vYmluZENhbGxiYWNrSW50ZXJuYWxzJztcbmV4cG9ydCBmdW5jdGlvbiBiaW5kTm9kZUNhbGxiYWNrKGNhbGxiYWNrRnVuYywgcmVzdWx0U2VsZWN0b3IsIHNjaGVkdWxlcikge1xuICAgIHJldHVybiBiaW5k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aW5nRmlyc3RWYWx1ZXMgPSBsZW5ndGg7XG4gICAgICAgICAgICB2YXIgX2xvb3BfMSA9IGZ1bmN0aW9uIChpKSB7XG4gICAgICAgICAgICAgICAgbWF5YmVTY2hlZHVsZShzY2hlZHVsZXIsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNvdXJjZSA9IGZyb20ob2JzZXJ2YWJsZXNbaV0sIHNjaGVkdWxlcik7XG4gICAgICAgICAgICAgICAgICAgIHZhciBoYXNGaXJzdFZhbHVlID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIHNvdXJjZS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlc1tpXSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNGaXJzdFZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzRmlyc3RWYWx1ZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtYWluaW5nRmlyc3RWYWx1ZXMtLTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcmVtYWluaW5nRmlyc3RWYWx1ZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWVUcmFuc2Zvcm0odmFsdWVzLnNsaWNlKCkpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEtLWFjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH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gKHNvdXJjZUluZGV4KSB7XG4gICAgICAgICAgICB2YXIgaGFzVmFsdWUgPSBmYWxzZTtcbiAgICAgICAgICAgIGlubmVyRnJvbShzb3VyY2VzW3NvdXJjZUluZGV4XSkuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFoYXNWYWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBoYXNWYWx1ZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIHJlbWFpbmluZ0VtaXNzaW9ucy0tO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YWx1ZXNbc291cmNlSW5kZXhdID0gdmFsdWU7XG4gICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaWYgKCEtLXJlbWFpbmluZ0NvbXBsZXRpb25zIHx8ICFoYXNWYWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXJlbWFpbmluZ0VtaXNzaW9ucykge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KGtleXMgPyBjcmVhdGVPYmplY3Qoa2V5cywgdmFsdWVzKSA6IHZhbHVlcyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfTtcbiAgICAgICAgZm9yICh2YXIgc291cmNlSW5kZXggPSAwOyBzb3VyY2VJbmRleCA8IGxlbmd0aDsgc291cmNlSW5kZXgrKykge1xuICAgICAgICAgICAgX2xvb3BfMShzb3VyY2VJbmRleCk7XG4gICAgICAgIH1cbiAgICB9KTtcbiAgICByZXR1cm4gcmVzdWx0U2VsZWN0b3IgPyByZXN1bHQucGlwZShtYXBPbmVPck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NyaWJlcikge1xuICAgICAgICBwcm9taXNlXG4gICAgICAgICAgICAudGhlbihmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIGlmICghc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZnVuY3Rpb24gKGVycikgeyByZXR1cm4gc3Vic2NyaWJlci5lcnJvcihlcnIpOyB9KVxuICAgICAgICAgICAgLnRoZW4obnVsbCwgcmVwb3J0VW5oYW5kbGVkRXJyb3IpO1xuICAgIH0pO1xufVxuZnVuY3Rpb24gZnJvbUl0ZXJhYmxlKGl0ZXJhYmxlKSB7XG4gICAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBlXzEsIF9hO1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgZm9yICh2YXIgaXRlcmFibGVfMSA9IF9fdmFsdWVzKGl0ZXJhYmxlKSwgaXRlcmFibGVfMV8xID0gaXRlcmFibGVfMS5uZXh0KCk7ICFpdGVyYWJsZV8xXzEuZG9uZTsgaXRlcmFibGVfMV8xID0gaXRlcmFibGVfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBpdGVyYWJsZV8xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICBpZiAoc3Vic2NyaWJlci5jbG9zZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZV8xXzEpIHsgZV8xID0geyBlcnJvcjogZV8xXzEgfTsgfVxuICA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BfX2dlbmVyYXRvcih0aGlzLCBmdW5jdGlvbiAoX2IpIHtcbiAgICAgICAgICAgIHN3aXRjaCAoX2IubGFiZWwpIHtcbiAgICAgICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgICAgIF9iLnRyeXMucHVzaChbMCwgNSwgNiwgMTFdKTtcbiAgICAgICAgICAgICAgICAgICAgYXN5bmNJdGVyYWJsZV8xID0gX19hc3luY1ZhbHVlcyhhc3luY0l0ZXJhYmxlKTtcbiAgICAgICAgICAgICAgICAgICAgX2IubGFiZWwgPSAxO1xuICAgICAgICAgICAgICAgIGNhc2UgMTogcmV0dXJuIFs0LCBhc3luY0l0ZXJhYmxlXzEubmV4dCgpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDI6XG4gICAgICAgICAgICAgICAgICAgIGlmICghKGFzeW5jSXRlcmFibGVfMV8xID0gX2Iuc2VudCgpLCAhYXN5bmNJdGVyYWJsZV8xXzEuZG9uZSkpIHJldHVybiBbMywgNF07XG4gICAgICAgICAgICAgICAgICAgIHZhbHVlID0gYXN5bmNJdGVyYWJsZV8xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBfYi5sYWJlbCA9IDM7XG4gICAgICAgICAgICAgICAgY2FzZSAzOiByZXR1cm4gWzMsIDFdO1xuICAgICAgICAgICAgICAgIGNhc2UgNDogcmV0dXJuIFszLCAxMV07XG4gICAgICAgICAgICAgICAgY2FzZSA1OlxuICAgICAgICAgICAgICAgICAgICBlXzJfMSA9IF9iLnNlbnQoKTtcbiAgICAgICAgICAgICAgICAgICAgZV8yID0geyBlcnJvcjogZV8yXzEgfTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFszLCAxMV07XG4gICAgICAgICAgICAgICAgY2FzZSA2OlxuICAgICAgICAgICAgICAgICAgICBfYi50cnlzLnB1c2goWzYsICwgOSwgMTBdKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCEoYXN5bmNJdGVyYWJsZV8xXzEgJiYgIWFzeW5jSXRlcmFibGVfMV8xLmRvbmUgJiYgKF9hID0gYXN5bmNJdGVyYWJsZV8xLnJldHVybikpKSByZXR1cm4gWzMsIDhdO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzQsIF9hLmNhbGwoYXN5bmNJdGVyYWJsZV8xKV07XG4gICAgICAgICAgICAgICAgY2FzZSA3OlxuICAgICAgICAgICAgICAgICAgICBfYi5zZW50KCk7XG4gICAgICAgICAgICAgICAgICAgIF9iLmxhYmVsID0gODtcbiAgICAgICAgICAgICAgICBjYXNlIDg6IHJldHVybiBbMywgMTBdO1xuICAgICAgICAgICAgICAgIGNhc2UgOTpcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVfMikgdGhyb3cgZV8yLmVycm9yO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzddO1xuICAgICAgICAgICAgICAgIGNhc2UgMTA6IHJldHVybiBbN107XG4gICAgICAgICAgICAgICAgY2FzZSAxMTpcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzJdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWZyb20uanMubWFwIiwiaW1wb3J0IHsgc2NoZWR1bGVBcnJheSB9IGZyb20gJy4uL3NjaGVkdWxlZC9zY2hlZHVsZUFycmF5JztcbmltcG9ydCB7IGZyb21BcnJheUxpa2UgfSBmcm9tICcuL2Zyb20nO1xuZXhwb3J0IGZ1bmN0aW9uIGludGVybmFsRnJvbUFycmF5KGlucHV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iAgICB9XG4gICAgZnVuY3Rpb24gZ2VuKCkge1xuICAgICAgICB2YXIgc3RhdGU7XG4gICAgICAgIHJldHVybiBfX2dlbmVyYXRvcih0aGlzLCBmdW5jdGlvbiAoX2EpIHtcbiAgICAgICAgICAgIHN3aXRjaCAoX2EubGFiZWwpIHtcbiAgICAgICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgICAgIHN0YXRlID0gaW5pdGlhbFN0YXRlO1xuICAgICAgICAgICAgICAgICAgICBfYS5sYWJlbCA9IDE7XG4gICAgICAgICAgICAgICAgY2FzZSAxOlxuICAgICAgICAgICAgICAgICAgICBpZiAoISghY29uZGl0aW9uIHx8IGNvbmRpdGlvbihzdGF0ZSkpKSByZXR1cm4gWzMsIDRdO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzQsIHJlc3VsdFNlbGVjdG9yKHN0YXRlKV07XG4gICAgICAgICAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgICAgICAgICBfYS5zZW50KCk7XG4gICAgICAgICAgICAgICAgICAgIF9hLmxhYmVsID0gMztcbiAgICAgICAgICAgICAgICBjYXNlIDM6XG4gICAgICAgICAgICAgICAgICAgIHN0YXRlID0gaXRlcmF0ZShzdGF0ZSk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbMywgMV07XG4gICAgICAgICAgICAgICAgY2FzZSA0OiByZXR1cm4gWzJdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9XG4gICAgcmV0dXJuIGRlZmVyKChzY2hlZHVsZXJcbiAgICAgICAgP1xuICAgICAgICAgICAgZnVuY3Rpb24gKCkgeyByZXR1cm4gc2NoZWR1bGVJdGVyYWJsZShnZW4oKSwgc2NoZWR1bGVyKTsgfVxuICAgICAgICA6XG4gICAgICAgICAgICBnZW4pKTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWdlbmVyYXRlLmpzLm1hcCIsImltcG9ydCB7IGRlZmVyIH0gZnJvbS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VudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgIHNvdXJjZXNbX2ldID0gYXJndW1lbnRzW19pXTtcbiAgICB9XG4gICAgc291cmNlcyA9IGFyZ3NPckFyZ0FycmF5KHNvdXJjZXMpO1xuICAgIHJldHVybiBzb3VyY2VzLmxlbmd0aCA9PT0gMSA/IGlubmVyRnJvbShzb3VyY2VzWzBdKSA6IG5ldyBPYnNlcnZhYmxlKHJhY2VJbml0KHNvdXJjZXMpKTtcbn1cbmV4cG9ydCBmdW5jdGlvbiByYWNlSW5pdChzb3VyY2VzKSB7XG4gICAgcmV0dXJuIGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBzdWJzY3JpcHRpb25zID0gW107XG4gICAgICAgIHZhciBfbG9vcF8xID0gZnVuY3Rpb24gKGkpIHtcbiAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMucHVzaChpbm5lckZyb20oc291cmNlc1tpXSkuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHN1YnNjcmlwdGlvbnMpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgcyA9IDA7IHMgPCBzdWJzY3JpcHRpb25zLmxlbmd0aDsgcysrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzICE9PSBpICYmIHN1YnNjcmlwdGlvbnNbc10udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb25zID0gbnVsbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgIH0pKSk7XG4gICAgICAgIH07XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBzdWJzY3JpcHRpb25zICYmICFzdWJzY3JpYmVyLmNsb3NlZCAmJiBpIDwgc291cmNlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgX2xvb3BfMShpKTtcbiAgICAgICAgfVxuICAgIH07XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1yYWNlLmpzLm1hcCIsImltcG9ydCB7IE9ic2VydmFibGUgfSBmcm9tICcuLi9PYnNlcnZhYmxlJztcbmltcG9ydCB7IEVNUFRZIH0gZnJvbSAnLi9lbXB0eSc7XG5leHBvcnQgZnVuY3Rpb24gcmFuZ2Uoc3RhcnQsIGNvdW50LCBzY2hlZHVsZXIpIHtcbiAgICBpZiAoY291bnQgPT0gbnVsbCkge1xuICAgICAgICBjb3VudCA9IHN0YXJ0O1xuICAgICAgICBzdGFydCA9IDA7XG4gICAgfVxuICAgIGlmIChjb3VudCA8PSAwKSB7XG4gICAgICAgIHJldHVybiBFTVBUWTtcbiAgICB9XG4gICAgdmFyIGVuZCA9IGNvdW50ICsgc3RhcnQ7XG4gICAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKHNjaGVkdWxlclxuICAgICAgICA/XG4gICAgICAgICAgICBmdW5jdGlvbiAoc3Vic2NyaWJlcikge1xuICAgICAgICAgICAgICAgIHZhciBuID0gc3RhcnQ7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChuIDwgZW5kKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQobisrKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2NoZWR1bGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAg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DtcbiAgICAgICAgfVxuICAgICAgICB2YXIgbiA9IDA7XG4gICAgICAgIHJldHVybiBzY2hlZHVsZXIuc2NoZWR1bGUoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKCFzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dChuKyspO1xuICAgICAgICAgICAgICAgIGlmICgwIDw9IGludGVydmFsRHVyYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2hlZHVsZSh1bmRlZmluZWQsIGludGVydmFsRHVyYXRpb24pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZHVlKTtcbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXRpbWVyLmpzLm1hcCIsImltcG9ydCB7IE9ic2VydmFibGUgfSBmcm9tICcuLi9PYnNlcnZhYmxlJztcbmltcG9ydCB7IGlubmVyRnJvbSB9IGZyb20gJy4vZnJvbSc7XG5pbXBvcnQgeyBFTVBUWSB9IGZyb20gJy4vZW1wdHknO1xuZXhwb3J0IGZ1bmN0aW9uIHVzaW5nKHJlc291cmNlRmFjdG9yeSwgb2JzZXJ2YWJsZUZhY3RvcnkpIHtcbiAgICByZXR1cm4gbmV3IE9ic2VydmFibGUoZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIHJlc291cmNlID0gcmVzb3VyY2VGYWN0b3J5KCk7XG4gICAgICAgIHZhciByZXN1bHQgPSBvYnNlcnZhYmxlRmFjdG9yeShyZXNvdXJjZSk7XG4gICAgICAgIHZhciBzb3VyY2UgPSByZXN1bHQgPyBpbm5lckZyb20ocmVzdWx0KSA6IEVNUFRZO1xuICAgICAgICBzb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AgICAgICAgICAgICAgICAgICAgIGlmIChidWZmZXJzLnNvbWUoZnVuY3Rpb24gKGJ1ZmZlciwgaSkgeyByZXR1cm4gIWJ1ZmZlci5sZW5ndGggJiYgY29tcGxldGVkW2ldOyB9KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgY29tcGxldGVkW3NvdXJjZUluZGV4XSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICFidWZmZXJzW3NvdXJjZUluZGV4XS5sZW5ndGggJiYgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBmb3IgKHZhciBzb3VyY2VJbmRleCA9IDA7ICFzdWJzY3JpYmVyLmNsb3NlZCAmJiBzb3VyY2VJbmRleCA8IHNvdXJjZXMubGVuZ3RoOyBzb3VyY2VJbmRleCsrKSB7XG4gICAgICAgICAgICAgICAgX2xvb3BfMShzb3VyY2VJbmRleCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGJ1ZmZlcnMgPSBjb21wbGV0ZWQgPSBudWxsO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSlcbiAgICAgICAgOiBFTVBUWTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXppcC5qcy5tYXAiLCJpbXBvcnQgeyBfX2V4dGVuZHMgfSBmcm9tIFwidHNsaWJcIjtcbmltcG9ydCB7IFN1YnNjcmliZXIgfSBmcm9tICcuLi9TdWJzY3JpYmVyJztcbnZhciBPcGVyYXRvclN1YnNjcmliZXIgPSAoZnVuY3Rpb24gKF9zdXBlcikge1xuICAgIF9fZXh0ZW5kcyhPcGVyYXRvclN1YnNjcmliZXIsIF9zdXBlcik7XG4gICAgZnVuY3Rpb24gT3BlcmF0b3JTdWJzY3JpYmVyKGRlc3RpbmF0aW9uLCBvbk5leHQsIG9uQ29tcGxldGUsIG9uRXJyb3IsIG9uRmluYWxpemUpIHtcbiAgICAgICAgdmFyIF90aGlzID0gX3N1cGVyLmNhbGwodGhpcywgZGVzdGluYXRpb24pIHx8IHRoaXM7XG4gICAgICAgIF90aGlzLm9uRmluYWxpemUgPSBvbkZpbmFsaXplO1xuICAgICAgICBfdGhpcy5fbmV4dCA9IG9uTmV4dFxuICAgICAgICAgICAgPyBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBvbk5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIGRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgOiBfc3VwZXIucHJvdG90eXBlLl9uZXh0O1xuICAgICAgICBfdGhpcy5fZXJyb3IgPSBvbkVycm9yXG4gICAgICAgICAgICA/IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBvbkVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICA6IF9zdXBlci5wcm90b3R5cGUuX2Vycm9yO1xuICAgICAgICBfdGhpcy5fY29tcGxldGUgPSBvbkNvbXBsZXRlXG4gICAgICAgICAgICA/IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBvbkNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICA6IF9zdXBlci5wcm90b3R5cGUuX2NvbXBsZXRlO1xuICAgICAgICByZXR1cm4gX3RoaXM7XG4gICAgfVxuICAgIE9wZXJhdG9yU3Vic2NyaWJlci5wcm90b3R5cGUudW5zdWJzY3JpYmUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfYTtcbiAgICAgICAgdmFyIGNsb3NlZCA9IHRoaXMuY2xvc2VkO1xuICAgICAgICBfc3VwZXIucHJvdG90eXBlLnVuc3Vic2NyaWJlLmNhbGwodGhpcyk7XG4gICAgICAgICFjbG9zZWQgJiYgKChfYSA9IHRoaXMub25GaW5hbGl6ZSkgPT09IG51bGwgfHwgX2EgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9hLmNhbGwodGhpcykpO1xuICAgIH07XG4gICAgcmV0dXJuIE9wZXJhdG9yU3Vic2NyaWJlcjtcbn0oU3Vic2NyaWJlcikpO1xuZXhwb3J0IHsgT3BlcmF0b3JTdWJzY3JpYmVyIH07XG4vLyMgc291cmNlTWFwcGluZ1VSTD1PcGVyYXRvclN1YnNjcmliZXIuanMubWFwIiwiaW1wb3J0IHsgb3BlcmF0ZSB9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yaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICB2YXIgZV8xLCBfYSwgZV8yLCBfYjtcbiAgICAgICAgICAgIHZhciB0b0VtaXQgPSBudWxsO1xuICAgICAgICAgICAgaWYgKGNvdW50KysgJSBzdGFydEJ1ZmZlckV2ZXJ5ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgYnVmZmVycy5wdXNoKFtdKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgYnVmZmVyc18xID0gX192YWx1ZXMoYnVmZmVycyksIGJ1ZmZlcnNfMV8xID0gYnVmZmVyc18xLm5leHQoKTsgIWJ1ZmZlcnNfMV8xLmRvbmU7IGJ1ZmZlcnNfMV8xID0gYnVmZmVyc18xLm5leHQoKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgYnVmZmVyID0gYnVmZmVyc18xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGJ1ZmZlclNpemUgPD0gYnVmZmVyLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdG9FbWl0ID0gdG9FbWl0ICE9PSBudWxsICYmIHRvRW1pdCAhPT0gdm9pZCAwID8gdG9FbWl0IDogW107XG4gICAgICAgICAgICAgICAgICAgICAgICB0b0VtaXQucHVzaChidWZmZXIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGVfMV8xKSB7IGVfMSA9IHsgZXJyb3I6IGVfMV8xIH07IH1cbiAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChidWZmZXJzXzFfMSAmJiAhYnVmZmVyc18xXzEuZG9uZSAmJiAoX2EgPSBidWZmZXJzXzEucmV0dXJuKSkgX2EuY2FsbChidWZmZXJzXzEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHsgaWYgKGVfMSkgdGhyb3cgZV8xLmVycm9yOyB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodG9FbWl0KSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgdG9FbWl0XzEgPSBfX3ZhbHVlcyh0b0VtaXQpLCB0b0VtaXRfMV8xID0gdG9FbWl0XzEubmV4dCgpOyAhdG9FbWl0XzFfMS5kb25lOyB0b0VtaXRfMV8xID0gdG9FbWl0XzEubmV4dCgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgYnVmZmVyID0gdG9FbWl0XzFfMS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyclJlbW92ZShidWZmZXJzLCBidWZmZXIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KGJ1ZmZlcik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVfMl8xKSB7IGVfMiA9IHsgZXJyb3I6IGVfMl8xIH07IH1cbiAgICAgICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0b0VtaXRfMV8xICYmICF0b0VtaXRfMV8xLmRvbmUgJiYgKF9iID0gdG9FbWl0XzEucmV0dXJuKSkgX2IuY2FsbCh0b0VtaXRfMSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzIpIHRocm93IGVfMi5lcnJvcjsgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSw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107XG4gICAgICAgIHZhciByZXN0YXJ0T25FbWl0ID0gZmFsc2U7XG4gICAgICAgIHZhciBlbWl0ID0gZnVuY3Rpb24gKHJlY29yZCkge1xuICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IHJlY29yZC5idWZmZXIsIHN1YnMgPSByZWNvcmQuc3VicztcbiAgICAgICAgICAgIHN1YnMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIGFyclJlbW92ZShidWZmZXJSZWNvcmRzLCByZWNvcmQpO1xuICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KGJ1ZmZlcik7XG4gICAgICAgICAgICByZXN0YXJ0T25FbWl0ICYmIHN0YXJ0QnVmZmVyKCk7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBzdGFydEJ1ZmZlciA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlmIChidWZmZXJSZWNvcmRzKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN1YnMgPSBuZXcgU3Vic2NyaXB0aW9uKCk7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5hZGQoc3Vicyk7XG4gICAgICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IFtdO1xuICAgICAgICAgICAgICAgIHZhciByZWNvcmRfMSA9IHtcbiAgICAgICAgICAgICAgICAgICAgYnVmZmVyOiBidWZmZXIsXG4gICAgICAgICAgICAgICAgICAgIHN1YnM6IHN1YnMsXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBidWZmZXJSZWNvcmRzLnB1c2gocmVjb3JkXzEpO1xuICAgICAgICAgICAgICAgIHN1YnMuYWRkKHNjaGVkdWxlci5zY2hlZHVsZShmdW5jdGlvbiAoKSB7IHJldHVybiBlbWl0KHJlY29yZF8xKTsgfSwgYnVmZmVyVGltZVNwYW4pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgYnVmZmVyQ3JlYXRpb25JbnRlcnZhbCAhPT0gbnVsbCA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dGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoYWN0aXZlVGFzaykge1xuICAgICAgICAgICAgICAgIGFjdGl2ZVRhc2sudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICBhY3RpdmVUYXNrID0gbnVsbDtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBsYXN0VmFsdWU7XG4gICAgICAgICAgICAgICAgbGFzdFZhbHVlID0gbnVsbDtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICBmdW5jdGlvbiBlbWl0V2hlbklkbGUoKSB7XG4gICAgICAgICAgICB2YXIgdGFyZ2V0VGltZSA9IGxhc3RUaW1lICsgZHVlVGltZTtcbiAgICAgICAgICAgIHZhciBub3cgPSBzY2hlZHVsZXIubm93KCk7XG4gICAgICAgICAgICBpZiAobm93IDwgdGFyZ2V0VGltZSkge1xuICAgICAgICAgICAgICAgIGFjdGl2ZVRhc2sgPSB0aGlzLnNjaGVkdWxlKHVuZGVmaW5lZCwgdGFyZ2V0VGltZSAtIG5vdyk7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5hZGQoYWN0aXZlVGFzayk7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZW1pdCgpO1xuICAgICAgICB9XG4gICAgICAgIHNvdXJjZS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIGxhc3RWYWx1ZSA9IHZhbHVlO1xuICAgICAgICAgICAgbGFzdFRpbWUgPSBzY2hlZHVsZXIubm93KCk7XG4gICAgICAgICAgICBpZiAoIWFjdGl2ZVRhc2spIHtcbiAgICAgICAgICAgICAgICBhY3RpdmVUYXNrID0gc2NoZWR1bGVyLnNjaGVkdWxlKGVtaXRX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CwgcmVzdWx0U2VsZWN0b3IpIHtcbiAgICBpZiAocmVzdWx0U2VsZWN0b3IpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIChzb3VyY2UpIHtcbiAgICAgICAgICAgIHJldHVybiBzb3VyY2UucGlwZShleGhhdXN0TWFwKGZ1bmN0aW9uIChhLCBpKSB7IHJldHVybiBpbm5lckZyb20ocHJvamVjdChhLCBpKSkucGlwZShtYXAoZnVuY3Rpb24gKGIsIGlpKSB7IHJldHVybiByZXN1bHRTZWxlY3RvcihhLCBiLCBpLCBpaSk7IH0pKTsgfSkpO1xuICAgICAgICB9O1xuICAgIH1cbiAgICByZXR1cm4gb3BlcmF0ZShmdW5jdGlvbiAoc291cmNlLCBzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBpbmRleCA9IDA7XG4gICAgICAgIHZhciBpbm5lclN1YiA9IG51bGw7XG4gICAgICAgIHZhciBpc0NvbXBsZXRlID0gZmFsc2U7XG4gICAgICAgIHNvdXJjZS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAob3V0ZXJWYWx1ZSkge1xuICAgICAgICAgICAgaWYgKCFpbm5lclN1Yikge1xuICAgICAgICAgICAgICAgIGlubmVyU3ViID0gbmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWIgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICBpc0NvbXBsZXRlICYmIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpbm5lckZyb20ocHJvamVjdChvdXRlclZhbHVlLCBpbmRleCsrKSkuc3Vic2NyaWJlKGlubmVyU3ViKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgZnVuY3Rpb24gKCkge1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jcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKGlubmVyVmFsdWUpIHtcbiAgICAgICAgICAgIG9uQmVmb3JlTmV4dCA9PT0gbnVsbCB8fCBvbkJlZm9yZU5leHQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IG9uQmVmb3JlTmV4dChpbm5lclZhbHVlKTtcbiAgICAgICAgICAgIGlmIChleHBhbmQpIHtcbiAgICAgICAgICAgICAgICBvdXRlck5leHQoaW5uZXJWYWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQoaW5uZXJWYWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlubmVyQ29tcGxldGUgPSB0cnVlO1xuICAgICAgICB9LCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlmIChpbm5lckNvbXBsZXRlKSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgYWN0aXZlLS07XG4gICAgICAgICAgICAgICAgICAgIHZhciBfbG9vcF8xID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJ1ZmZlcmVkVmFsdWUgPSBidWZmZXIuc2hpZnQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyU3ViU2NoZWR1bGVyID8gc3Vic2NyaWJlci5hZGQoaW5uZXJTdWJTY2hlZHVsZXIuc2NoZWR1bGUoZnVuY3Rpb24gKCkgeyByZXR1cm4gZG9Jbm5lclN1YihidWZmZXJlZFZhbHVlKTsgfSkpIDogZG9Jbm5lclN1YihidWZmZXJlZFZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGJ1ZmZlci5sZW5ndGggJiYgYWN0aXZlIDwgY29uY3VycmVudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgX2xvb3BfMSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNoZWNrQ29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgfTtcbiAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgb3V0ZXJOZXh0LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGlzQ29tcGxldGUgPSB0cnVlO1xuICAgICAgICBjaGVja0NvbXBsZXRlKCk7XG4gICAgfSkpO1xuICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGFkZGl0aW9uYWxUZWFyZG93biA9PT0gbnVsbCB8fCBhZGRpdGlvbmFsVGVhcmRvd24gPT09IHZvaWQgMCA/IHZvaWQgMCA6IGFkZGl0aW9uYWxUZWFyZG93bigpO1xuICAgIH07XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1tZXJnZUludGVybmFscy5qcy5tYXAiLCJpbXBvcnQgeyBtYXAgfSBmcm9tICcuL21hcCc7XG5pbXBvcnQgeyBpbm5lckZyb20gfSBmcm9tICcuLi9vYnNlcnZhYmxlL2Zyb20nO1xuaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlmdCc7XG5pbXBvcnQgeyBtZXJnZUludGVybmFscyB9IGZyb20gJy4vbWVyZ2VJbnRlcm5hbHMnO1xuaW1wb3J0IHsgaXNGdW5jdGlvbiB9IGZyb20gJy4uL3V0aWwvaXNGdW5jdGlvbic7XG5leHBvcnQgZnVuY3Rpb24gbWVyZ2VNYXAocHJvamVjdCwg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jdGlvbiBvbkVycm9yUmVzdW1lTmV4dCgpIHtcbiAgICB2YXIgc291cmNlcyA9IFtdO1xuICAgIGZvciAodmFyIF9pID0gMDsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgIHNvdXJjZXNbX2ldID0gYXJndW1lbnRzW19pXTtcbiAgICB9XG4gICAgdmFyIG5leHRTb3VyY2VzID0gYXJnc09yQXJnQXJyYXkoc291cmNlcyk7XG4gICAgcmV0dXJuIG9wZXJhdGUoZnVuY3Rpb24gKHNvdXJjZSwgc3Vic2NyaWJlcikge1xuICAgICAgICB2YXIgcmVtYWluaW5nID0gX19zcHJlYWRBcnJheShbc291cmNlXSwgX19yZWFkKG5leHRTb3VyY2VzKSk7XG4gICAgICAgIHZhciBzdWJzY3JpYmVOZXh0ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKCFzdWJzY3JpYmVyLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgIGlmIChyZW1haW5pbmcubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dFNvdXJjZSA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRTb3VyY2UgPSBpbm5lckZyb20ocmVtYWluaW5nLnNoaWZ0KCkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZU5leHQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB2YXIgaW5uZXJTdWIgPSBuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIHVuZGVmaW5lZCwgbm9vcCwgbm9vcCk7XG4gICAgICAgICAgICAgICAgICAgIHN1YnN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IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCsrc29GYXIgPCBjb3VudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlubmVyU3ViKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbm5lclN1YiA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmVwZWF0KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzeW5jVW5zdWIgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIGlmIChzeW5jVW5zdWIpIHtcbiAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWIgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVGb3JSZXBlYXQoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmVwZWF0KCk7XG4gICAgICAgIH0pO1xufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9cmVwZWF0LmpzLm1hcCIsImltcG9ydCB7IFN1YmplY3QgfSBmcm9tICcuLi9TdWJqZWN0Jztcb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HNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN5bmNSZXN1YiA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlzTm90aWZpZXJDb21wbGV0ZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIGNoZWNrQ29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gY29tcGxldGlvbnMkO1xuICAgICAgICB9O1xuICAgICAgICB2YXIgc3Vic2NyaWJlRm9yUmVwZWF0V2hlbiA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlzTWFpbkNvbXBsZXRlID0gZmFsc2U7XG4gICAgICAgICAgICBpbm5lclN1YiA9IHNvdXJjZS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCB1bmRlZmluZWQsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpc01haW5Db21wbGV0ZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgIWNoZWNrQ29tcGxldGUoKSAmJiBnZXRDb21wbGV0aW9uU3ViamVjdCgpLm5leHQoKTtcbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIGlmIChzeW5jUmVzdWIpIHtcbiAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIGlubmVyU3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICBzeW5jUmVzdWIgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVGb3JSZXBlYXRXaGVuKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIHN1YnNjcmliZUZvclJlcGVhdFdoZW4oKTtcbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwa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ICAgICAgICAgICBpbm5lclN1YiA9IHNvdXJjZS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHJlc2V0T25TdWNjZXNzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzb0ZhciA9IDA7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICB9LCB1bmRlZmluZWQsIGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNvRmFyKysgPCBjb3VudCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlubmVyU3ViKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJTdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbm5lclN1YiA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlRm9yUmV0cnkoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN5bmNVbnN1YiA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgaWYgKHN5bmNVbnN1Yikge1xuICAgICAgICAgICAgICAgICAgICBpbm5lclN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICBpbm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ICAgICAgICAgICAgICAgcmV0dXJuIGlubmVyU3ViID8gc3Vic2NyaWJlRm9yUmV0cnlXaGVuKCkgOiAoc3luY1Jlc3ViID0gdHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGVycm9ycyQpIHtcbiAgICAgICAgICAgICAgICAgICAgZXJyb3JzJC5uZXh0KGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgaWYgKHN5bmNSZXN1Yikge1xuICAgICAgICAgICAgICAgIGlubmVyU3ViLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgaW5uZXJTdWIgPSBudWxsO1xuICAgICAgICAgICAgICAgIHN5bmNSZXN1YiA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZUZvclJldHJ5V2hlbigpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICBzdWJzY3JpYmVGb3JSZXRyeVdoZW4oKTtcbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXJldHJ5V2hlbi5qcy5tYXAiLCJpbXBvcnQgeyBvcGVyYXRlIH0gZnJvbSAnLi4vdXRpbC9saWZ0JztcbmltcG9ydCB7IG5vb3AgfSBmcm9tICcuLi91dGlsL25vb3AnO1xuaW1wb3J0IHsgT3BlcmF0b3JTdWJzY3JpYmVyIH0gZnJvbSAnLi9PcGVyYXRvclN1YnNjcmliZXInO1xuZXhwb3J0IGZ1bmN0aW9uIHNhbXBsZShub3RpZmllcikge1xuICAgIHJldHVybiBvcGVyYXRlKGZ1bmN0aW9uIChzb3VyY2UsIHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIGhhc1ZhbHVlID0gZmFsc2U7XG4gICAgICAgIHZhciBsYXN0VmFsdWUgPSBudWxsO1xuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ld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QgMCA/IHRydWUgOiBfYiwgX2MgPSBvcHRpb25zLnJlc2V0T25Db21wbGV0ZSwgcmVzZXRPbkNvbXBsZXRlID0gX2MgPT09IHZvaWQgMCA/IHRydWUgOiBfYywgX2QgPSBvcHRpb25zLnJlc2V0T25SZWZDb3VudFplcm8sIHJlc2V0T25SZWZDb3VudFplcm8gPSBfZCA9PT0gdm9pZCAwID8gdHJ1ZSA6IF9kO1xuICAgIHJldHVybiBmdW5jdGlvbiAod3JhcHBlclNvdXJjZSkge1xuICAgICAgICB2YXIgY29ubmVjdGlvbiA9IG51bGw7XG4gICAgICAgIHZhciByZXNldENvbm5lY3Rpb24gPSBudWxsO1xuICAgICAgICB2YXIgc3ViamVjdCA9IG51bGw7XG4gICAgICAgIHZhciByZWZDb3VudCA9IDA7XG4gICAgICAgIHZhciBoYXNDb21wbGV0ZWQgPSBmYWxzZTtcbiAgICAgICAgdmFyIGhhc0Vycm9yZWQgPSBmYWxzZTtcbiAgICAgICAgdmFyIGNhbmNlbFJlc2V0ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgcmVzZXRDb25uZWN0aW9uID09PSBudWxsIHx8IHJlc2V0Q29ubmVjdGlvbiA9PT0gdm9pZCAwID8gdm9pZCAwIDogcmVzZXRDb25uZWN0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICByZXNldENvbm5lY3Rpb24gPSBudWxsO1xuICAgICAgICB9O1xuICAgICAgICB2YXIgcmVzZXQgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBjYW5jZWxSZXNldCgpO1xuICAgICAgICAgICAgY29ubmVjdGlvbiA9IHN1YmplY3QgPSBudWxsO1xuICAgICAgICAgICAgaGFzQ29tcGxldGVkID0gaGFzRXJyb3JlZCA9IGZhbHNlO1xuICAgICAgICB9O1xuICAgICAgICB2YXIgcmVzZXRBbmRVbnN1YnNjcmliZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBjb25uID0gY29ubmVjdGlvbjtcbiAgICAgICAgICAgIHJlc2V0KCk7XG4gICAgICAgICAgICBjb25uID09PSBudWxsIHx8IGNvbm4gPT09IHZvaWQgMCA/IHZvaWQgMCA6IGNvbm4udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgfTtcbiAgICAgICAgcmV0dXJuIG9wZXJhdGUoZnVuY3Rpb24gKHNvdXJjZSwgc3Vic2NyaWJlcikge1xuICAgICAgICAgICAgcmVmQ291bnQrKztcbiAgICAgICAgICAgIGlmICghaGFzRXJyb3JlZCAmJiAhaGFzQ29tcGxldGVkKSB7XG4gICAgICAgICAgICAgICAgY2FuY2VsUmVzZXQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBkZXN0ID0gKHN1YmplY3QgPSBzdWJqZWN0ICE9PSBudWxsICYmIHN1YmplY3QgIT09IHZvaWQgMCA/IHN1YmplY3QgOiBjb25uZWN0b3IoKSk7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgcmVmQ291bnQtLTtcbiAgICAgICAgICAgICAgICBpZiAocmVmQ291bnQgPT09IDAgJiYgIWhhc0Vycm9yZWQgJiYgIWhhc0NvbXBsZXRlZCkge1xuICAgICAgICAgICAgICAgICAgICByZXNldENvbm5lY3Rpb24gPSBoYW5kbGVSZXNldChyZXNldEFuZFVuc3Vic2NyaWJlLCByZXNldE9uUmVmQ291bnRaZXJvKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGRlc3Quc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgICAgICAgICAgaWYgKCFjb25uZWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgY29ubmVjdGlvbiA9IG5ldyBTYWZlU3Vic2NyaWJlcih7XG4gICAgICAgICAgICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uICh2YWx1ZSkgeyByZXR1cm4gZGVzdC5uZXh0KHZhbHVlKTsgfSxcbiAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0Vycm9yZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsUmVzZXQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q29ubmVjdGlvbiA9IGhhbmRsZVJlc2V0KHJlc2V0LCByZXNldE9uRXJyb3IsIGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZXN0LmVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBoYXNDb21wbGV0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsUmVzZXQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q29ubmVjdGlvbiA9IGhhbmRsZVJlc2V0KHJlc2V0LCByZXNldE9uQ29tcGxldGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZGVzdC5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGZyb20oc291cmNlKS5zdWJzY3JpYmUoY29ubmVjdGlvbik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKHdyYXBwZXJTb3VyY2UpO1xuICAgIH07XG59XG5mdW5jdGlvbiBoYW5kbGVSZXNldChyZXNldCwgb24pIHtcbiAgICB2YXIgYXJncyA9IFtdO1xuICAgIGZvciAodmFyIF9pID0gMjsgX2kgPCBhcmd1bWVudHMubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgIGFyZ3NbX2kgLSAyXSA9IGFyZ3VtZW50c1tfaV07XG4gICAgfVxuICAgIGlmIChvbiA9PT0gdHJ1ZSk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yYXRvclN1YnNjcmliZXInO1xuZXhwb3J0IGZ1bmN0aW9uIHRha2UoY291bnQpIHtcbiAgICByZXR1cm4gY291bnQgPD0gMFxuICAgICAgICA/XG4gICAgICAgICAgICBmdW5jdGlvbiAoKSB7IHJldHVybiBFTVBUWTsgfVxuICAgICAgICA6IG9wZXJhdGUoZnVuY3Rpb24gKHNvdXJjZSwgc3Vic2NyaWJlcikge1xuICAgICAgICAgICAgdmFyIHNlZW4gPSAwO1xuICAgICAgICAgICAgc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgIGlmICgrK3NlZW4gPD0gY291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGNvdW50IDw9IHNlZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKTtcbiAgICAgICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD10YWtlLmpzLm1hcCIsImltcG9ydCB7IF9fdmFsdWVzIH0gZnJvbSBcInRzbGliXCI7XG5pbXBvcnQgeyBFTVBUWSB9IGZyb20gJy4uL29ic2VydmFibGUvZW1wdHknO1xuaW1wb3J0IHsgb3BlcmF0ZSB9IGZyb20gJy4uL3V0aWwvbGlmdCc7XG5pbXBvcnQgeyBPcGVyYXRvclN1YnNjcmliZXIgfSBmcm9tICcuL09wZXJhdG9yU3Vic2NyaWJlcic7XG5leHBvcnQgZnVuY3Rpb24gdGFrZUxhc3QoY291bnQpIHtcbiAgICByZXR1cm4gY291bnQgPD0gMFxuICAgICAgICA/IGZ1bmN0aW9uICgpIHsgcmV0dXJuIEVNUFRZOyB9XG4gICAgICAgIDogb3BlcmF0ZShmdW5jdGlvbiAoc291cmNlLCBzdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICB2YXIgYnVmZmVyID0gW107XG4gICAgICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgYnVmZmVyLnB1c2godmFsdWUpO1xuICAgICAgICAgICAgICAgIGNvdW50IDwgYnVmZmVyLmxlbmd0aCAmJiBidWZmZXIuc2hpZnQoKTtcbiAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgZV8xLCBfYTtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBidWZmZXJfMSA9IF9fdmFsdWVzKGJ1ZmZlciksIGJ1ZmZlcl8xXzEgPSBidWZmZXJfMS5uZXh0KCk7ICFidWZmZXJfMV8xLmRvbmU7IGJ1ZmZlcl8xXzEgPSBidWZmZXJfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IGJ1ZmZlcl8xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlXzFfMSkgeyBlXzEgPSB7IGVycm9yOiBlXzFfMSB9OyB9XG4gICAgICAgICAgICAgICAgZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYnVmZmVyXzFfMSAmJiAhYnVmZmVyXzFfMS5kb25lICYmIChfYSA9IGJ1ZmZlcl8xLnJldHVybikpIF9hLmNhbGwoYnVmZmVyXzEpO1xuIC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AwIDogdGhyb3R0bGVkLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB0aHJvdHRsZWQgPSBudWxsO1xuICAgICAgICAgICAgaWYgKHRyYWlsaW5nKSB7XG4gICAgICAgICAgICAgICAgc2VuZCgpO1xuICAgICAgICAgICAgICAgIGlzQ29tcGxldGUgJiYgc3Vic2NyaWJlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICB2YXIgY2xlYW51cFRocm90dGxpbmcgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB0aHJvdHRsZWQgPSBudWxsO1xuICAgICAgICAgICAgaXNDb21wbGV0ZSAmJiBzdWJzY3JpYmVyLmNvbXBsZXRlKCk7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBzdGFydFRocm90dGxlID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICByZXR1cm4gKHRocm90dGxlZCA9IGlubmVyRnJvbShkdXJhdGlvblNlbGVjdG9yKHZhbHVlKSkuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZW5kVGhyb3R0bGluZywgY2xlYW51cFRocm90dGxpbmcpKSk7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBzZW5kID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKGhhc1ZhbHVlKSB7XG4gICAgICAgICAgICAgICAgaGFzVmFsdWUgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBzZW5kVmFsdWU7XG4gICAgICAgICAgICAgICAgc2VuZFZhbHVlID0gbnVsbDtcbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgICFpc0NvbXBsZXRlICYmIHN0YXJ0VGhyb3R0bGUodmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICBzb3VyY2Uuc3V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W5hbFNvdXJjZVN1YnNjcmlwdGlvbjtcbiAgICAgICAgdmFyIHRpbWVyU3Vic2NyaXB0aW9uO1xuICAgICAgICB2YXIgbGFzdFZhbHVlID0gbnVsbDtcbiAgICAgICAgdmFyIHNlZW4gPSAwO1xuICAgICAgICB2YXIgc3RhcnRUaW1lciA9IGZ1bmN0aW9uIChkZWxheSkge1xuICAgICAgICAgICAgdGltZXJTdWJzY3JpcHRpb24gPSBjYXVnaHRTY2hlZHVsZShzdWJzY3JpYmVyLCBzY2hlZHVsZXIsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBvcmlnaW5hbFNvdXJjZVN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIGlubmVyRnJvbShfd2l0aCh7XG4gICAgICAgICAgICAgICAgICAgIG1ldGE6IG1ldGEsXG4gICAgICAgICAgICAgICAgICAgIGxhc3RWYWx1ZTogbGFzdFZhbHVlLFxuICAgICAgICAgICAgICAgICAgICBzZWVuOiBzZWVuLFxuICAgICAgICAgICAgICAgIH0pKS5zdWJzY3JpYmUoc3Vic2NyaWJlcik7XG4gICAgICAgICAgICB9LCBkZWxheSk7XG4gICAgICAgIH07XG4gICAgICAgIG9yaWdpbmFsU291cmNlU3Vic2NyaXB0aW9uID0gc291cmNlLnN1YnNjcmliZShuZXcgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgdGltZXJTdWJzY3JpcHRpb24gPT09IG51bGwgfHwgdGltZXJTdWJzY3JpcHRpb24gPT09IHZvaWQgMCA/IHZvaWQgMCA6IHRpbWVyU3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICBzZWVuKys7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQoKGxhc3RWYWx1ZSA9IHZhbHVlKSk7XG4gICAgICAgICAgICBlYWNoID4gMCAmJiBz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cgT3BlcmF0b3JTdWJzY3JpYmVyKHN1YnNjcmliZXIsIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgdmFyIGVfMSwgX2E7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGZvciAodmFyIHdpbmRvd3NfMSA9IF9fdmFsdWVzKHdpbmRvd3MpLCB3aW5kb3dzXzFfMSA9IHdpbmRvd3NfMS5uZXh0KCk7ICF3aW5kb3dzXzFfMS5kb25lOyB3aW5kb3dzXzFfMSA9IHdpbmRvd3NfMS5uZXh0KCkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHdpbmRvd18xID0gd2luZG93c18xXzEudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIHdpbmRvd18xLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlXzFfMSkgeyBlXzEgPSB7IGVycm9yOiBlXzFfMSB9OyB9XG4gICAgICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBpZiAod2luZG93c18xXzEgJiYgIXdpbmRvd3NfMV8xLmRvbmUgJiYgKF9hID0gd2luZG93c18xLnJldHVybikpIF9hLmNhbGwod2luZG93c18xKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZmluYWxseSB7IGlmIChlXzEpIHRocm93IGVfMS5lcnJvcjsgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGMgPSBjb3VudCAtIHdpbmRvd1NpemUgKyAxO1xuICAgICAgICAgICAgaWYgKGMgPj0gMCAmJiBjICUgc3RhcnRFdmVyeSA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHdpbmRvd3Muc2hpZnQoKS5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCsrY291bnQgJSBzdGFydEV2ZXJ5ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHdpbmRvd18yID0gbmV3IFN1YmplY3QoKTtcbiAgICAgICAgICAgICAgICB3aW5kb3dzLnB1c2god2luZG93XzIpO1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh3aW5kb3dfMi5hc09ic2VydmFibGUoKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHdoaWxlICh3aW5kb3dzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgICAgICB3aW5kb3dzLnNoaWZ0KCkuY29tcGxldGUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN1YnNjcmliZXIuY29tcGxldGUoKTtcbiAgICAgICAgfSwgZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgd2hpbGUgKHdpbmRvd3MubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgIHdpbmRvd3Muc2hpZnQoKS5lcnJvcihlcnIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaWJlci5lcnJvcihlcnIpO1xuICAgICAgICB9LCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBzdGFydHMgPSBudWxsO1xuICAgICAgICAgICAgd2luZG93cyA9IG51bGw7XG4gICAgICAgIH0pKTtcbiAgICB9KTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPXdpbmRvd0NvdW50LmpzLm1hcCIsImltcG9ydCB7IFN1YmplY3QgfSBmcm9tICcuLi9TdWJqZWN0JztcbmltcG9ydCB7IGFzeW5jU2NoZWR1bGVyIH0gZnJvbSAnLi4vc2NoZWR1bGVyL2FzeW5jJztcbmltcG9ydCB7IFN1YnNjcmlwdGlvbiB9IGZyb20gJy4uL1N1YnNjcmlwdGlvbic7XG5pbXBvcnQgeyBvcGVyYXRlIH0gZnJvbSAnLi4vdXRpbC9saWZ0JztcbmltcG9ydCB7IE9wZXJhdG9yU3V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4gICAgICAgICAgICBzdWJzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICBhcnJSZW1vdmUod2luZG93UmVjb3JkcywgcmVjb3JkKTtcbiAgICAgICAgICAgIHJlc3RhcnRPbkNsb3NlICYmIHN0YXJ0V2luZG93KCk7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBzdGFydFdpbmRvdyA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlmICh3aW5kb3dSZWNvcmRzKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN1YnMgPSBuZXcgU3Vic2NyaXB0aW9uKCk7XG4gICAgICAgICAgICAgICAgc3Vic2NyaWJlci5hZGQoc3Vicyk7XG4gICAgICAgICAgICAgICAgdmFyIHdpbmRvd18xID0gbmV3IFN1YmplY3QoKTtcbiAgICAgICAgICAgICAgICB2YXIgcmVjb3JkXzEgPSB7XG4gICAgICAgICAgICAgICAgICAgIHdpbmRvdzogd2luZG93XzEsXG4gICAgICAgICAgICAgICAgICAgIHN1YnM6IHN1YnMsXG4gICAgICAgICAgICAgICAgICAgIHNlZW46IDAsXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB3aW5kb3dSZWNvcmRzLnB1c2gocmVjb3JkXzEpO1xuICAgICAgICAgICAgICAgIHN1YnNjcmliZXIubmV4dCh3aW5kb3dfMS5hc09ic2VydmFibGUoKSk7XG4gICAgICAgICAgICAgICAgc3Vicy5hZGQoc2NoZWR1bGVyLnNjaGVkdWxlKGZ1bmN0aW9uICgpIHsgcmV0dXJuIGNsb3NlV2luZG93KHJlY29yZF8xKTsgfSwgd2luZG93VGltZVNwYW4pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgd2luZG93Q3JlYXRpb25JbnRlcnZhbCAhPT0gbnVsbCAmJiB3aW5kb3dDcmVhdGlvbkludGVydmFsID49IDBcbiAgICAgICAgICAgID9cbiAgICAgICAgICAgICAgICBzdWJzY3JpYmVyLmFkZChzY2hlZHVsZXIuc2NoZWR1bGUoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICBzdGFydFdpbmRvdygpO1xuICAgICAgICAgICAgICAgICAgICAhdGhpcy5jbG9zZWQgJiYgc3Vic2NyaWJlci5hZGQodGhpcy5zY2hlZHVsZShudWxsLCB3aW5kb3dDcmVhdGlvbkludGVydmFsKSk7XG4gICAgICAgICAgICAgICAgfSwgd2luZG93Q3JlYXRpb25JbnRlcnZhbCkpXG4gICAgICAgICAgICA6IChyZXN0YXJ0T25DbG9zZSA9IHRydWUpO1xuICAgICAgICBzdGFydFdpbmRvdygpO1xuICAgICAgICB2YXIgbG9vcCA9IGZ1bmN0aW9uIChjYikgeyByZXR1cm4gd2luZG93UmVjb3Jkcy5zbGljZSgpLmZvckVhY2goY2IpOyB9O1xuICAgICAgICB2YXIgdGVybWluYXRlID0gZnVuY3Rpb24gKGNiKSB7XG4gICAgICAgICAgICBsb29wKGZ1bmN0aW9uIChfYSkge1xuICAgICAgICAgICAgICAgIHZhciB3aW5kb3cgPSBfYS53aW5kb3c7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNiKHdpbmRvdyk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGNiKHN1YnNjcmliZXIpO1xuICAgICAgICAgICAgc3Vic2NyaWJlci51bnN1YnNjcmliZSgpO1xuICAgICAgICB9O1xuICAgICAgICBzb3VyY2Uuc3Vic2NyaWJlKG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICBsb29wKGZ1bmN0aW9uIChyZWNvcmQpIHtcbiAgICAgICAgICAgICAgICByZWNvcmQud2luZG93Lm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIG1heFdpbmRvd1NpemUgPD0gKytyZWNvcmQuc2VlbiAmJiBjbG9zZVdpbmRvdyhyZWNvcmQpO1xuICAgICAgICAgICAgfSk7XG4gICAgICA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0gW107XG4gICAgICAgIHZhciBoYW5kbGVFcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgIHdoaWxlICgwIDwgd2luZG93cy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB3aW5kb3dzLnNoaWZ0KCkuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN1YnNjcmliZXIuZXJyb3IoZXJyKTtcbiAgICAgICAgfTtcbiAgICAgICAgaW5uZXJGcm9tKG9wZW5pbmdzKS5zdWJzY3JpYmUobmV3IE9wZXJhdG9yU3Vic2NyaWJlcihzdWJzY3JpYmVyLCBmdW5jdGlvbiAob3BlblZhbHVlKSB7XG4gICAgICAgICAgICB2YXIgd2luZG93ID0gbmV3IFN1YmplY3QoKTtcbiAgICAgICAgICAgIHdpbmRvd3MucHVzaCh3aW5kb3cpO1xuICAgICAgICAgICAgdmFyIGNsb3NpbmdTdWJzY3JpcHRpb24gPSBuZXcgU3Vic2NyaXB0aW9uKCk7XG4gICAgICAgICAgICB2YXIgY2xvc2VXaW5kb3cgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgYXJyUmVtb3ZlKHdpbmRvd3MsIHdpbmRvdyk7XG4gICAgICAgICAgICAgICAgd2luZG93LmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgY2xvc2luZ1N1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHZhciBjbG9zaW5nTm90aWZpZXI7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGNsb3NpbmdOb3RpZmllciA9IGlubmVyRnJvbShjbG9zaW5nU2VsZWN0b3Iob3BlblZhbHVlKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgaGFuZGxlRXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICByZXR1cm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B7XG4gICAgICAgIHZhciB3aW5kb3c7XG4gICAgICAgIHZhciBjbG9zaW5nU3Vic2NyaWJlcjtcbiAgICAgICAgdmFyIGhhbmRsZUVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgd2luZG93LmVycm9yKGVycik7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLmVycm9yKGVycik7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBvcGVuV2luZG93ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgY2xvc2luZ1N1YnNjcmliZXIgPT09IG51bGwgfHwgY2xvc2luZ1N1YnNjcmliZXIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IGNsb3NpbmdTdWJzY3JpYmVyLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB3aW5kb3cgPT09IG51bGwgfHwgd2luZG93ID09PSB2b2lkIDAgPyB2b2lkIDAgOiB3aW5kb3cuY29tcGxldGUoKTtcbiAgICAgICAgICAgIHdpbmRvdyA9IG5ldyBTdWJqZWN0KCk7XG4gICAgICAgICAgICBzdWJzY3JpYmVyLm5leHQod2luZG93LmFzT2JzZXJ2YWJsZSgpKTtcbiAgICAgICAgICAgIHZhciBjbG9zaW5nTm90aWZpZXI7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGNsb3NpbmdOb3RpZmllciA9IGlubmVyRnJvbShjbG9zaW5nU2VsZWN0b3IoKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgaGFuZGxlRXJyb3IoZXJyKTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjbG9zaW5nTm90aWZpZXIuc3Vic2NyaWJlKChjbG9zaW5nU3Vic2NyaWJlciA9IG5ldyBPcGVyYXRvclN1YnNjcmliZXIoc3Vic2NyaWJlciwgb3BlbldpbmRvdywgb3BlbldpbmRvdywgaGF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XkpIHtcbiAgICAgICAgdmFyIGVycm9yZWQgPSBmYWxzZTtcbiAgICAgICAgdmFyIGVycm9yVmFsdWU7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICB0aGlzLndvcmsoc3RhdGUpO1xuICAgICAgICB9XG4gICAgICAgIGNhdGNoIChlKSB7XG4gICAgICAgICAgICBlcnJvcmVkID0gdHJ1ZTtcbiAgICAgICAgICAgIGVycm9yVmFsdWUgPSAoISFlICYmIGUpIHx8IG5ldyBFcnJvcihlKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZXJyb3JlZCkge1xuICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgcmV0dXJuIGVycm9yVmFsdWU7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIEFzeW5jQWN0aW9uLnByb3RvdHlwZS51bnN1YnNjcmliZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKCF0aGlzLmNsb3NlZCkge1xuICAgICAgICAgICAgdmFyIF9hID0gdGhpcywgaWQgPSBfYS5pZCwgc2NoZWR1bGVyID0gX2Euc2NoZWR1bGVyO1xuICAgICAgICAgICAgdmFyIGFjdGlvbnMgPSBzY2hlZHVsZXIuYWN0aW9ucztcbiAgICAgICAgICAgIHRoaXMud29yayA9IHRoaXMuc3RhdGUgPSB0aGlzLnNjaGVkdWxlciA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLnBlbmRpbmcgPSBmYWxzZTtcbiAgICAgICAgICAgIGFyclJlbW92ZShhY3Rpb25zLCB0aGlzKTtcbiAgICAgICAgICAgIGlmIChpZCAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5pZCA9IHRoaXMucmVjeWNsZUFzeW5jSWQoc2NoZWR1bGVyLCBpZCwgbnVsbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmRlbGF5ID0gbnVsbDtcbiAgICAgICAgICAgIF9zdXBlci5wcm90b3R5cGUudW5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cbiAgICByZXR1cm4gdHlwZW9mIGxhc3QoYXJncykgPT09ICdudW1iZXInID8gYXJncy5wb3AoKSA6IGRlZmF1bHRWYWx1ZTtcbn1cbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWFyZ3MuanMubWFwIiwidmFyIGlzQXJyYXkgPSBBcnJheS5pc0FycmF5O1xudmFyIGdldFByb3RvdHlwZU9mID0gT2JqZWN0LmdldFByb3RvdHlwZU9mLCBvYmplY3RQcm90byA9IE9iamVjdC5wcm90b3R5cGUsIGdldEtleXMgPSBPYmplY3Qua2V5cztcbmV4cG9ydCBmdW5jdGlvbiBhcmdzQXJnQXJyYXlPck9iamVjdChhcmdzKSB7XG4gICAgaWYgKGFyZ3MubGVuZ3RoID09PSAxKSB7XG4gICAgICAgIHZhciBmaXJzdF8xID0gYXJnc1swXTtcbiAgICAgICAgaWYgKGlzQXJyYXkoZmlyc3RfMSkpIHtcbiAgICAgICAgICAgIHJldHVybiB7IGFyZ3M6IGZpcnN0XzEsIGtleXM6IG51bGwgfTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNQT0pPKGZpcnN0XzEpKSB7XG4gICAgICAgICAgICB2YXIga2V5cyA9IGdldEtleXMoZmlyc3RfMSk7XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIGFyZ3M6IGtleXMubWFwKGZ1bmN0aW9uIChrZXkpIHsgcmV0dXJuIGZpcnN0XzFba2V5XTsgfSksXG4gICAgICAgICAgICAgICAga2V5czoga2V5cyxcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHsgYXJnczogYXJncywga2V5czogbnVsbCB9O1xufVxuZnVuY3Rpb24gaXNQT0pPKG9iaikge1xuICAgIHJldHVybiBvYmogJiYgdHlwZW9mIG9iaiA9PT0gJ29iamVjdCcgJiYgZ2V0UHJvdG90eXBlT2Yob2JqKSA9PT0gb2JqZWN0UHJvdG87XG59XG4vLyMgc291cmNlTWFwcGluZ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3Rpb24nO1xuZXhwb3J0IGZ1bmN0aW9uIHJlYWRhYmxlU3RyZWFtTGlrZVRvQXN5bmNHZW5lcmF0b3IocmVhZGFibGVTdHJlYW0pIHtcbiAgICByZXR1cm4gX19hc3luY0dlbmVyYXRvcih0aGlzLCBhcmd1bWVudHMsIGZ1bmN0aW9uIHJlYWRhYmxlU3RyZWFtTGlrZVRvQXN5bmNHZW5lcmF0b3JfMSgpIHtcbiAgICAgICAgdmFyIHJlYWRlciwgX2EsIHZhbHVlLCBkb25lO1xuICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgZnVuY3Rpb24gKF9iKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKF9iLmxhYmVsKSB7XG4gICAgICAgICAgICAgICAgY2FzZSAwOlxuICAgICAgICAgICAgICAgICAgICByZWFkZXIgPSByZWFkYWJsZVN0cmVhbS5nZXRSZWFkZXIoKTtcbiAgICAgICAgICAgICAgICAgICAgX2IubGFiZWwgPSAxO1xuICAgICAgICAgICAgICAgIGNhc2UgMTpcbiAgICAgICAgICAgICAgICAgICAgX2IudHJ5cy5wdXNoKFsxLCAsIDksIDEwXSk7XG4gICAgICAgICAgICAgICAgICAgIF9iLmxhYmVsID0gMjtcbiAgICAgICAgICAgICAgICBjYXNlIDI6XG4gICAgICAgICAgICAgICAgICAgIGlmICghdHJ1ZSkgcmV0dXJuIFszLCA4XTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFs0LCBfX2F3YWl0KHJlYWRlci5yZWFkKCkpXTtcbiAgICAgICAgICAgICAgICBjYXNlIDM6XG4gICAgICAgICAgICAgICAgICAgIF9hID0gX2Iuc2VudCgpLCB2YWx1ZSA9IF9hLnZhbHVlLCBkb25lID0gX2EuZG9uZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkb25lKSByZXR1cm4gWzMsIDVdO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzQsIF9fYXdhaXQodm9pZCAwKV07XG4gICAgICAgIC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AgICAgIGlmIChBcnJheS5pc0FycmF5KHZhbHVlKSkge1xuICAgICAgICAgIGlmICh2YWx1ZS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgIHJldHVybiAnW10nXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChtYXhpbXVtRGVwdGggPCBzdGFjay5sZW5ndGggKyAxKSB7XG4gICAgICAgICAgICByZXR1cm4gJ1wiW0FycmF5XVwiJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBzdGFjay5wdXNoKHZhbHVlKVxuICAgICAgICAgIGlmIChzcGFjZXIgIT09ICcnKSB7XG4gICAgICAgICAgICBpbmRlbnRhdGlvbiArPSBzcGFjZXJcbiAgICAgICAgICAgIHJlcyArPSBgXFxuJHtpbmRlbnRhdGlvbn1gXG4gICAgICAgICAgICBqb2luID0gYCxcXG4ke2luZGVudGF0aW9ufWBcbiAgICAgICAgICB9XG4gICAgICAgICAgY29uc3QgbWF4aW11bVZhbHVlc1RvU3RyaW5naWZ5ID0gTWF0aC5taW4odmFsdWUubGVuZ3RoLCBtYXhpbXVtQnJlYWR0aClcbiAgICAgICAgICBsZXQgaSA9IDBcbiAgICAgICAgICBmb3IgKDsgaSA8IG1heGltdW1WYWx1ZXNUb1N0cmluZ2lmeSAtIDE7IGkrKykge1xuICAgICAgICAgICAgY29uc3QgdG1wID0gc3RyaW5naWZ5Rm5SZXBsYWNlcihTdHJpbmcoaSksIHZhbHVlLCBzdGFjaywgcmVwbGFjZXIsIHNwYWNlciwgaW5kZW50YXRpb24pXG4gICAgICAgICAgICByZXMgKz0gdG1wICE9PSB1bmRlZmluZWQgPyB0bXAgOiAnbnVsbCdcbiAgICAgICAgICAgIHJlcyArPSBqb2luXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeUZuUmVwbGFjZXIoU3RyaW5nKGkpLCB2YWx1ZSwgc3RhY2ssIHJlcGxhY2VyLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIHJlcyArPSB0bXAgIT09IHVuZGVmaW5lZCA/IHRtcCA6ICdudWxsJ1xuICAgICAgICAgIGlmICh2YWx1ZS5sZW5ndGggLSAxID4gbWF4aW11bUJyZWFkdGgpIHtcbiAgICAgICAgICAgIGNvbnN0IHJlbW92ZWRLZXlzID0gdmFsdWUubGVuZ3RoIC0gbWF4aW11bUJyZWFkdGggLSAxXG4gICAgICAgICAgICByZXMgKz0gYCR7am9pbn1cIi4uLiAke2dldEl0ZW1Db3VudChyZW1vdmVkS2V5cyl9IG5vdCBzdHJpbmdpZmllZFwiYFxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoc3BhY2VyICE9PSAnJykge1xuICAgICAgICAgICAgcmVzICs9IGBcXG4ke29yaWdpbmFsSW5kZW50YXRpb259YFxuICAgICAgICAgIH1cbiAgICAgICAgICBzdGFjay5wb3AoKVxuICAgICAgICAgIHJldHVybiBgWyR7cmVzfV1gXG4gICAgICAgIH1cblxuICAgICAgICBsZXQga2V5cyA9IE9iamVjdC5rZXlzKHZhbHVlKVxuICAgICAgICBjb25zdCBrZXlMZW5ndGggPSBrZXlzLmxlbmd0aFxuICAgICAgICBpZiAoa2V5TGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgcmV0dXJuICd7fSdcbiAgICAgICAgfVxuICAgICAgICBpZiAobWF4aW11bURlcHRoIDwgc3RhY2subGVuZ3RoICsgMSkge1xuICAgICAgICAgIHJldHVybiAnXCJbT2JqZWN0XVwiJ1xuICAgICAgICB9XG4gICAgICAgIGxldCB3aGl0ZXNwYWNlID0gJydcbiAgICAgICAgbGV0IHNlcGFyYXRvciA9ICcnXG4gICAgICAgIGlmIChzcGFjZXIgIT09ICcnKSB7XG4gICAgICAgICAgaW5kZW50YXRpb24gKz0gc3BhY2VyXG4gICAgICAgICAgam9pbiA9IGAsXFxuJHtpbmRlbnRhdGlvbn1gXG4gICAgICAgICAgd2hpdGVzcGFjZSA9ICcgJ1xuICAgICAgICB9XG4gIC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UpIHtcbiAgICAgIGNhc2UgJ3N0cmluZyc6XG4gICAgICAgIHJldHVybiBzdHJFc2NhcGUodmFsdWUpXG4gICAgICBjYXNlICdvYmplY3QnOiB7XG4gICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCkge1xuICAgICAgICAgIHJldHVybiAnbnVsbCdcbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RhY2suaW5kZXhPZih2YWx1ZSkgIT09IC0xKSB7XG4gICAgICAgICAgcmV0dXJuIGNpcmN1bGFyVmFsdWVcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IG9yaWdpbmFsSW5kZW50YXRpb24gPSBpbmRlbnRhdGlvblxuICAgICAgICBsZXQgcmVzID0gJydcbiAgICAgICAgbGV0IGpvaW4gPSAnLCdcblxuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICBpZiAodmFsdWUubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICByZXR1cm4gJ1tdJ1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAobWF4aW11bURlcHRoIDwgc3RhY2subGVuZ3RoICsgMSkge1xuICAgICAgICAgICAgcmV0dXJuICdcIltBcnJheV1cIidcbiAgICAgICAgICB9XG4gICAgICAgICAgc3RhY2sucHVzaCh2YWx1ZSlcbiAgICAgICAgICBpZiAoc3BhY2VyICE9PSAnJykge1xuICAgICAgICAgICAgaW5kZW50YXRpb24gKz0gc3BhY2VyXG4gICAgICAgICAgICByZXMgKz0gYFxcbiR7aW5kZW50YXRpb259YFxuICAgICAgICAgICAgam9pbiA9IGAsXFxuJHtpbmRlbnRhdGlvbn1gXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnN0IG1heGltdW1WYWx1ZXNUb1N0cmluZ2lmeSA9IE1hdGgubWluKHZhbHVlLmxlbmd0aCwgbWF4aW11bUJyZWFkdGgpXG4gICAgICAgICAgbGV0IGkgPSAwXG4gICAgICAgICAgZm9yICg7IGkgPCBtYXhpbXVtVmFsdWVzVG9TdHJpbmdpZnkgLSAxOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeUFycmF5UmVwbGFjZXIoU3RyaW5nKGkpLCB2YWx1ZVtpXSwgc3RhY2ssIHJlcGxhY2VyLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgICAgcmVzICs9IHRtcCAhPT0gdW5kZWZpbmVkID8gdG1wIDogJ251bGwnXG4gICAgICAgICAgICByZXMgKz0gam9pblxuICAgICAgICAgIH1cbiAgICAgICAgICBjb25zdCB0bXAgPSBzdHJpbmdpZnlBcnJheVJlcGxhY2VyKFN0cmluZyhpKSwgdmFsdWVbaV0sIHN0YWNrLCByZXBsYWNlciwgc3BhY2VyLCBpbmRlbnRhdGlvbilcbiAgICAgICAgICByZXMgKz0gdG1wICE9PSB1bmRlZmluZWQgPyB0bXAgOiAnbnVsbCdcbiAgICAgICAgICBpZiAodmFsdWUubGVuZ3RoIC0gMSA+IG1heGltdW1CcmVhZHRoKSB7XG4gICAgICAgICAgICBjb25zdCByZW1vdmVkS2V5cyA9IHZhbHVlLmxlbmd0aCAtIG1heGltdW1CcmVhZHRoIC0gMVxuICAgICAgICAgICAgcmVzICs9IGAke2pvaW59XCIuLi4gJHtnZXRJdGVtQ291bnQocmVtb3ZlZEtleXMpfSBub3Qgc3RyaW5naWZpZWRcImBcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHNwYWNlciAhPT0gJycpIHtcbiAgICAgICAgICAgIHJlcyArPSBgXFxuJHtvcmlnaW5hbEluZGVudGF0aW9ufWBcbiAgICAgICAgICB9XG4gICAgICAgICAgc3RhY2sucG9wKClcbiAgICAgICAgICByZXR1cm4gYFske3Jlc31dYFxuICAgICAgICB9XG4gICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgIGxldCB3aGl0ZXNwYWNlID0gJydcbiAgICAgICAgaWYgKHNwYWNlciAhPT0gJycpIHtc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HJldHVybiB1bmRlZmluZWRcbiAgICAgIGNhc2UgJ2JpZ2ludCc6XG4gICAgICAgIGlmIChiaWdpbnQpIHtcbiAgICAgICAgICByZXR1cm4gU3RyaW5nKHZhbHVlKVxuICAgICAgICB9XG4gICAgICAgIC8vIGZhbGx0aHJvdWdoXG4gICAgICBkZWZhdWx0OlxuICAgICAgICByZXR1cm4gZmFpbCA/IGZhaWwodmFsdWUpIDogdW5kZWZpbmVkXG4gICAgfVxuICB9XG5cbiAgZnVuY3Rpb24gc3RyaW5naWZ5SW5kZW50IChrZXksIHZhbHVlLCBzdGFjaywgc3BhY2VyLCBpbmRlbnRhdGlvbikge1xuICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7XG4gICAgICBjYXNlICdzdHJpbmcnOlxuICAgICAgICByZXR1cm4gc3RyRXNjYXBlKHZhbHVlKVxuICAgICAgY2FzZSAnb2JqZWN0Jzoge1xuICAgICAgICBpZiAodmFsdWUgPT09IG51bGwpIHtcbiAgICAgICAgICByZXR1cm4gJ251bGwnXG4gICAgICAgIH1cbiAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZS50b0pTT04gPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICB2YWx1ZSA9IHZhbHVlLnRvSlNPTihrZXkpXG4gICAgICAgICAgLy8gUHJldmVudCBjYWxsaW5nIGB0b0pTT05gIGFnYWluLlxuICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgIT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICByZXR1cm4gc3RyaW5naWZ5SW5kZW50KGtleSwgdmFsdWUsIHN0YWNrLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodmFsdWUgPT09IG51bGwpIHtcbiAgICAgICAgICAgIHJldHVybiAnbnVsbCdcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YWNrLmluZGV4T2YodmFsdWUpICE9PSAtMSkge1xuICAgICAgICAgIHJldHVybiBjaXJjdWxhclZhbHVlXG4gICAgICAgIH1cbiAgICAgICAgY29uc3Qgb3JpZ2luYWxJbmRlbnRhdGlvbiA9IGluZGVudGF0aW9uXG5cbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuICdbXSdcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG1heGltdW1EZXB0aCA8IHN0YWNrLmxlbmd0aCArIDEpIHtcbiAgICAgICAgICAgIHJldHVybiAnXCJbQXJyYXldXCInXG4gICAgICAgICAgfVxuICAgICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgICAgaW5kZW50YXRpb24gKz0gc3BhY2VyXG4gICAgICAgICAgbGV0IHJlcyA9IGBcXG4ke2luZGVudGF0aW9ufWBcbiAgICAgICAgICBjb25zdCBqb2luID0gYCxcXG4ke2luZGVudGF0aW9ufWBcbiAgICAgICAgICBjb25zdCBtYXhpbXVtVmFsdWVzVG9TdHJpbmdpZnkgPSBNYXRoLm1pbih2YWx1ZS5sZW5ndGgsIG1heGltdW1CcmVhZHRoKVxuICAgICAgICAgIGxldCBpID0gMFxuICAgICAgICAgIGZvciAoOyBpIDwgbWF4aW11bVZhbHVlc1RvU3RyaW5naWZ5IC0gMTsgaSsrKSB7XG4gICAgICAgICAgICBjb25zdCB0bXAgPSBzdHJpbmdpZnlJbmRlbnQoU3RyaW5nKGkpLCB2YWx1ZVtpXSwgc3RhY2ssIHNwYWNlciwgaW5kZW50YXRpb24pXG4gICAgICAgICAgICByZXMgKz0gdG1wICE9PSB1bmRlZmluZWQgPyB0bXAgOiAnbnVsbCdcbiAgICAgICAgICAgIHJlcyArPSBqb2luXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeUluZGVudChTdHJpbmcoaSksIHZhbHVlW2ldLCBzdGFjaywgc3BhY2VyLCBpbmRlbnRhdGlvbilcbiAgICAgICAgICByZXMgKz0gdG1wICE9PSB1bmRlZmluZWQgPyB0bXAgOiAnbnVsbCdcbiAgICAgICAgICBpZiAodmFsdWUubGVuZ3RoIC0gMSA+IG1heGltdW1CcmVhZHRoKSB7XG4gICAgICAgICAgICBjb25zdCByZW1vdmVkS2V5cyA9IHZhbHVlLmxlbmd0aCAtIG1heGltdW1CcmVhZHRoIC0gMVxuICAgICAgICAgICAgcmVzICs9IGAke2pvaW59XCIuLi4gJHtnZXRJdGVtQ291bnQocmVtb3ZlZEtleXMpfSBub3Qgc3RyaW5naWZpZWRcImBcbiAgICAgICAgICB9XG4gICAgICAgICAgcmVzICs9IGBcXG4ke29yaWdpbmFsSW5kZW50YXRpb259YFxuICAgICAgICAgIHN0YWNrLnBvcCgpXG4gICAgICAgICAgcmV0dXJuIGBbJHtyZXN9XWBcbiAgICAgICAgfVxuXG4gICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXModmFsdWUpXG4gICAgICAgIGNvbnN0IGtleUxlbmd0aCA9IGtleXMubGVuZ3RoXG4gICAgICAgIGlmIChrZXlMZW5ndGggPT09IDApIHtcbiAgICAgICAgICByZXR1cm4gJ3t9J1xuICAgICAgICB9XG4gICAgICAgIGlmIChtYXhpbXVtRGVwdGggPCBzdGFjay5sZW5ndGggKyAxKSB7XG4gICAgICAgICAgcmV0dXJuICdcIltPYmplY3RdXCInXG4gICAgICAgIH1cbiAgICAgICAgaW5kZW50YXRpb24gKz0gc3BhY2VyXG4gICAgICAgIGNvbnN0IGpvaW4gPSBgLFxcbiR7aW5kZW50YXRpb259YFxuICAgICAgICBsZXQgcmVzID0gJydcbiAgICAgICAgbGV0IHNlcGFyYXRvciA9ICcnXG4gICAgICAgIGxldCBtYXhpbXVtUHJvcGVydGllc1RvU3RyaW5naWZ5ID0gTWF0aC5taW4oa2V5TGVuZ3RoLCBtYXhpbXVtQnJlYWR0aClcbiAgICAgICAgaWYgKGlzVHlwZWRBcnJheVdpdGhFbnRyaWVzKHZhbHVlKSkge1xuICAgICAgICAgIHJlcyArPSBzdHJpbmdpZnlUeXBlZEFycmF5KHZhbHVlLCBqb2luLCBtYXhpbXVtQnJlYWR0aClcbiAgICAgICAgICBrZXlzID0ga2V5cy5zbGljZSh2YWx1ZS5sZW5ndGgpXG4gICAgICAgICAgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeSAtPSB2YWx1ZS5sZW5ndGhcbiAgICAgICAgICBzZXBhcmF0b3IgPSBqb2luXG4gICAgICAgIH1cbiAgICAgICAgaWYgKGRldGVybWluaXN0aWMpIHtcbiAgICAgICAgICBrZXlzID0gc29ydChrZXlzLCBjb21wYXJhdG9yKVxuICAgICAgICB9XG4gICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbWF4aW11bVByb3BlcnRpZXNUb1N0cmluZ2lmeTsgaSsrKSB7XG4gICAgICAgICAgY29uc3Qga2V5ID0ga2V5c1tpXVxuICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeUluZGVudChrZXksIHZhbHVlW2tleV0sIHN0YWNrLCBzcGFjZXIsIGluZGVudGF0aW9uKVxuICAgICAgICAgIGlmICh0bXAgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmVzICs9IGAke3NlcGFyYXRvcn0ke3N0ckVzY2FwZShrZXkpfTogJHt0bXB9YFxuICAgICAgICAgICAgc2VwYXJhdG9yID0gam9pblxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoa2V5TGVuZ3RoID4gbWF4aW11bUJyZWFkdGgpIHtcbiAgICAgICAgICBjb25zdCByZW1vdmVkS2V5cyA9IGtleUxlbmd0aCAtIG1heGltdW1CcmVhZHRoXG4gICAgICAgICAgcmVzICs9IGAke3NlcGFyYXRvcn1cIi4uLlwiOiBcIiR7Z2V0SXRlbUNvdW50KHJlbW92ZWR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KSB7XG4gICAgICAgICAgcmV0dXJuICdudWxsJ1xuICAgICAgICB9XG4gICAgICAgIGlmICh0eXBlb2YgdmFsdWUudG9KU09OID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgdmFsdWUgPSB2YWx1ZS50b0pTT04oa2V5KVxuICAgICAgICAgIC8vIFByZXZlbnQgY2FsbGluZyBgdG9KU09OYCBhZ2FpblxuICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgIT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICByZXR1cm4gc3RyaW5naWZ5U2ltcGxlKGtleSwgdmFsdWUsIHN0YWNrKVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodmFsdWUgPT09IG51bGwpIHtcbiAgICAgICAgICAgIHJldHVybiAnbnVsbCdcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YWNrLmluZGV4T2YodmFsdWUpICE9PSAtMSkge1xuICAgICAgICAgIHJldHVybiBjaXJjdWxhclZhbHVlXG4gICAgICAgIH1cblxuICAgICAgICBsZXQgcmVzID0gJydcblxuICAgICAgICBjb25zdCBoYXNMZW5ndGggPSB2YWx1ZS5sZW5ndGggIT09IHVuZGVmaW5lZFxuICAgICAgICBpZiAoaGFzTGVuZ3RoICYmIEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuICdbXSdcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG1heGltdW1EZXB0aCA8IHN0YWNrLmxlbmd0aCArIDEpIHtcbiAgICAgICAgICAgIHJldHVybiAnXCJbQXJyYXldXCInXG4gICAgICAgICAgfVxuICAgICAgICAgIHN0YWNrLnB1c2godmFsdWUpXG4gICAgICAgICAgY29uc3QgbWF4aW11bVZhbHVlc1RvU3RyaW5naWZ5ID0gTWF0aC5taW4odmFsdWUubGVuZ3RoLCBtYXhpbXVtQnJlYWR0aClcbiAgICAgICAgICBsZXQgaSA9IDBcbiAgICAgICAgICBmb3IgKDsgaSA8IG1heGltdW1WYWx1ZXNUb1N0cmluZ2lmeSAtIDE7IGkrKykge1xuICAgICAgICAgICAgY29uc3QgdG1wID0gc3RyaW5naWZ5U2ltcGxlKFN0cmluZyhpKSwgdmFsdWVbaV0sIHN0YWNrKVxuICAgICAgICAgICAgcmVzICs9IHRtcCAhPT0gdW5kZWZpbmVkID8gdG1wIDogJ251bGwnXG4gICAgICAgICAgICByZXMgKz0gJywnXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnN0IHRtcCA9IHN0cmluZ2lmeVNpbXBsZShTdHJpbmcoaSksIHZhbHVlW2ldLCBzdGFjaylcbiAgICAgICAgICByZXMgKz0gdG1wICE9PSB1bmRlZmluZWQgPyB0bXAgOiAnbnVsbCdcbiAgICAgICAgICBpZiAodmFsdWUubGVuZ3RoIC0gMSA+IG1heGltdW1CcmVhZHRoKSB7XG4gICAgICAgICAgICBjb25zdCByZW1vdmVkS2V5cyA9IHZhbHVlLmxlbmd0aCAtIG1heGltdW1CcmVhZHRoIC0gMVxuICAgICAgICAgICAgcmVzICs9IGAsXCIuLi4gJHtnZXRJdGVtQ291bnQocmVtb3ZlZEtleXMpfSBub3Qgc3RyaW5naWZpZWRcImBcbiAgICAgICAgICB9XG4gICAgICAgICAgc3RhY2sucG9wKClcbiAgICAgICAgICByZXR1cm4gYFske3Jlc31dYFxuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyh2YWx1ZSlcbiAgICAgICAgY29uc3Qga2V5TGVuZ3RoID0ga2V5cy5sZW5ndGhcbiAgICAgICAgaWYgKGtleUxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgIHJldHVybiAne30nXG4gICAgICAgIH1cbiAgICAgICAgaWYgKG1heGltdW1EZXB0aCA8IHN0YWNrLmxlbmd0aCArIDEpIHtcbiAgICAgICAgICByZXR1cm4gJ1wiW09iamVjdF1cIidcbiAgICAgICAgfVxuICAgICAgICBsZXQgc2VwYXJhdG9yID0gJydcbiAgICAgICAgbGV0IG1heGltdW1Qcm9wZXJ0aWVzVG9TdHJpbmdpZnkgPSBNYXRoLm1pbihrZXlMZW5ndGgsIG1heGltdW1CcmVhZHRoKVxuICAgICAgICBpZiAoaGFzTGVuZ3RoICYmIGlzVHlwZWRBcnJheVdpdGhFbnRyaWVzKHZhbHVlKSkge1xuICAgICAgICAgIHJlcyArPSBzdHJpbmdpZnlUeXBlZEFycmF5KHZhbHVlLCAnLCcsIG1heGltdW1CcmVhZHRoKVxuICAgICAgICAgIGtleXMgPSBrZXlzLnNsaWNlKHZhbHVlLmxlbmd0aClcbiAgICAgICAgICBtYXhpbXVtUHJvcGVydGllc1RvU3RyaW5naWZ5IC09IHZhbHVlLmxlbmd0aFxuICAgICAgICAgIHNlcGFyYXRvciA9ICcsJ1xuICAgICAgICB9XG4gICAgICAgIGlmIChkZXRlcm1pbmlzdGljKSB7XG4gICAgICAgICAga2V5cyA9IHNvcnQoa2V5cywgY29tcGFyYXRvcilcbiAgICAgICAgfVxuICAgICAgICBzdGFjay5wdXNoKHZhbHVlKVxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG1heGltdW1Qcm9wZXJ0aWVzVG9TdHJpbmdpZnk7IGkrKykge1xuICAgICAgICAgIGNvbnN0IGtleSA9IGtleXNbaV1cbiAgICAgICAgICBjb25zdCB0bXAgPSBzdHJpbmdpZnlTaW1wbGUoa2V5LCB2YWx1ZVtrZXldLCBzdGFjaylcbiAgICAgICAgICBpZiAodG1wICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIHJlcyArPSBgJHtzZXBhcmF0b3J9JHtzdHJFc2NhcGUoa2V5KX06JHt0bXB9YFxuICAgICAgICAgICAgc2VwYXJhdG9yID0gJywnXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChrZXlMZW5ndGggPiBtYXhpbXVtQnJlYWR0a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gICAncGVybWlsJzogODI0MCxcbiAgICAncHJpbWUnOiA4MjQyLFxuICAgICdQcmltZSc6IDgyNDMsXG4gICAgJ2xzYXF1byc6IDgyNDksXG4gICAgJ3JzYXF1byc6IDgyNTAsXG4gICAgJ29saW5lJzogODI1NCxcbiAgICAnZnJhc2wnOiA4MjYwLFxuICAgICdldXJvJzogODM2NCxcbiAgICAnaW1hZ2UnOiA4NDY1LFxuICAgICd3ZWllcnAnOiA4NDcyLFxuICAgICdyZWFsJzogODQ3NixcbiAgICAndHJhZGUnOiA4NDgyLFxuICAgICdhbGVmc3ltJzogODUwMSxcbiAgICAnbGFycic6IDg1OTIsXG4gICAgJ3VhcnInOiA4NTkzLFxuICAgICdyYXJyJzogODU5NCxcbiAgICAnZGFycic6IDg1OTUsXG4gICAgJ2hhcnInOiA4NTk2LFxuICAgICdjcmFycic6IDg2MjksXG4gICAgJ2xBcnInOiA4NjU2LFxuICAgICd1QXJyJzogODY1NyxcbiAgICAnckFycic6IDg2NTgsXG4gICAgJ2RBcnInOiA4NjU5LFxuICAgICdoQXJyJzogODY2MCxcbiAgICAnZm9yYWxsJzogODcwNCxcbiAgICAncGFydCc6IDg3MDYsXG4gICAgJ2V4aXN0JzogODcwNyxcbiAgICAnZW1wdHknOiA4NzA5LFxuICAgICduYWJsYSc6IDg3MTEsXG4gICAgJ2lzaW4nOiA4NzEyLFxuICAgICdub3Rpbic6IDg3MTMsXG4gICAgJ25pJzogODcxNSxcbiAgICAncHJvZCc6IDg3MTksXG4gICAgJ3N1bSc6IDg3MjEsXG4gICAgJ21pbnVzJzogODcyMixcbiAgICAnbG93YXN0JzogODcyNyxcbiAgICAncmFkaWMnOiA4NzMwLFxuICAgICdwcm9wJzogODczMyxcbiAgICAnaW5maW4nOiA4NzM0LFxuICAgICdhbmcnOiA4NzM2LFxuICAgICdhbmQnOiA4NzQzLFxuICAgICdvcic6IDg3NDQsXG4gICAgJ2NhcCc6IDg3NDUsXG4gICAgJ2N1cCc6IDg3NDY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N0cmluZygpXG4gICAgfVxuICAgIHZhciBpID0gMFxuICAgIHZhciBjID0gJydcbiAgICB3aGlsZSAodHJ1ZSkge1xuICAgICAgYyA9IGNoYXJBdChjaHVuaywgaSsrKVxuICAgICAgcGFyc2VyLmMgPSBjXG5cbiAgICAgIGlmICghYykge1xuICAgICAgICBicmVha1xuICAgICAgfVxuXG4gICAgICBpZiAocGFyc2VyLnRyYWNrUG9zaXRpb24pIHtcbiAgICAgICAgcGFyc2VyLnBvc2l0aW9uKytcbiAgICAgICAgaWYgKGMgPT09ICdcXG4nKSB7XG4gICAgICAgICAgcGFyc2VyLmxpbmUrK1xuICAgICAgICAgIHBhcnNlci5jb2x1bW4gPSAwXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGFyc2VyLmNvbHVtbisrXG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgc3dpdGNoIChwYXJzZXIuc3RhdGUpIHtcbiAgICAgICAgY2FzZSBTLkJFR0lOOlxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQkVHSU5fV0hJVEVTUEFDRVxuICAgICAgICAgIGlmIChjID09PSAnXFx1RkVGRicpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgfVxuICAgICAgICAgIGJlZ2luV2hpdGVTcGFjZShwYXJzZXIsIGMpXG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQkVHSU5fV0hJVEVTUEFDRTpcbiAgICAgICAgICBiZWdpbldoaXRlU3BhY2UocGFyc2VyLCBjKVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlRFWFQ6XG4gICAgICAgICAgaWYgKHBhcnNlci5zYXdSb290ICYmICFwYXJzZXIuY2xvc2VkUm9vdCkge1xuICAgICAgICAgICAgdmFyIHN0YXJ0aSA9IGkgLSAxXG4gICAgICAgICAgICB3aGlsZSAoYyAmJiBjICE9PSAnPCcgJiYgYyAhPT0gJyYnKSB7XG4gICAgICAgICAgICAgIGMgPSBjaGFyQXQoY2h1bmssIGkrKylcbiAgICAgICAgICAgICAgaWYgKGMgJiYgcGFyc2VyLnRyYWNrUG9zaXRpb24pIHtcbiAgICAgICAgICAgICAgICBwYXJzZXIucG9zaXRpb24rK1xuICAgICAgICAgICAgICAgIGlmIChjID09PSAnXFxuJykge1xuICAgICAgICAgICAgICAgICAgcGFyc2VyLmxpbmUrK1xuICAgICAgICAgICAgICAgICAgcGFyc2VyLmNvbHVtbiA9IDBcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgcGFyc2VyLmNvbHVtbisrXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXJzZXIudGV4dE5vZGUgKz0gY2h1bmsuc3Vic3RyaW5nKHN0YXJ0aSwgaSAtIDEpXG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChjID09PSAnPCcgJiYgIShwYXJzZXIuc2F3Um9vdCAmJiBwYXJzZXIuY2xvc2VkUm9vdCAmJiAhcGFyc2VyLnN0cmljdCkpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuT1BFTl9XQUtBXG4gICAgICAgICAgICBwYXJzZXIuc3RhcnRUYWdQb3NpdGlvbiA9IHBhcnNlci5wb3NpdGlvblxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoIWlzV2hpdGVzcGFjZShjKSAmJiAoIXBhcnNlci5zYXdSb290IHx8IHBhcnNlci5jbG9zZWRSb290KSkge1xuICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ1RleHQgZGF0YSBvdXRzaWRlIG9mIHJvb3Qgbm9kZS4nKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGMgPT09ICcmJykge1xuICAgICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRfRU5USVRZXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwYXJzZXIudGV4dE5vZGUgKz0gY1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5TQ1JJUFQ6XG4gICAgICAgICAgLy8gb25seSBub24tc3RyaWN0XG4gICAgICAgICAgaWYgKGMgPT09ICc8Jykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRfRU5ESU5HXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5zY3JpcHQgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5TQ1JJUFRfRU5ESU5HOlxuICAgICAgICAgIGlmIChjID09PSAnLycpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0xPU0VfVEFHXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5zY3JpcHQgKz0gJzwnICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuT1BFTl9XQUtBOlxuICAgICAgICAgIC8vIGVpdGhlciBhIC8sID8sICEsIG9yIHRleHQgaXMgY29taW5nIG5leHQuXG4gICAgICAgICAgaWYgKGMgPT09ICchJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TR01MX0RFQ0xcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgfSBlbHNlIGlmIChpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIC8vIHdhaXQgZm9yIGl0Li4uXG4gICAgICAgICAgfSBlbHNlIGlmIChpc01hdGNoKG5hbWVTdGFydCwgYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuT1BFTl9UQUdcbiAgICAgICAgICAgIHBhcnNlci50YWdOYW1lID0gY1xuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJy8nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNMT1NFX1RBR1xuICAgICAgICAgICAgcGFyc2VyLnRhZ05hbWUgPSAnJ1xuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJz8nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlBST0NfSU5TVFxuICAgICAgICAgICAgcGFyc2VyLnByb2NJbnN0TmFtZSA9IHBhcnNlci5wcm9jSW5zdEJvZHkgPSAnJ1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ1VuZW5jb2RlZCA8JylcbiAgICAgICAgICAgIC8vIGlmIHRoZXJlIHdhcyBzb21lIHdoaXRlc3BhY2UsIHRoZW4gYWRkIHRoYXQgaW4uXG4gICAgICAgICAgICBpZiAocGFyc2VyLnN0YXJ0VGFnUG9zaXRpb24gKyAxIDwgcGFyc2VyLnBvc2l0aW9uKSB7XG4gICAgICAgICAgICAgIHZhciBwYWQgPSBwYXJzZXIucG9zaXRpb24gLSBwYXJzZXIuc3RhcnRUYWdQb3NpdGlvblxuICAgICAgICAgICAgICBjID0gbmV3IEFycmF5KHBhZCkuam9pbignICcpICsgY1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcGFyc2VyLnRleHROb2RlICs9ICc8JyArIGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5TR01MX0RFQ0w6XG4gICAgICAgICAgaWYgKHBhcnNlci5zZ21sRGVjbCArIGMgPT09ICctLScpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ09NTUVOVFxuICAgICAg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4gICAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgPSAnJ1xuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsICdvbnNnbWxkZWNsYXJhdGlvbicsIHBhcnNlci5zZ21sRGVjbClcbiAgICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzUXVvdGUoYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0dNTF9ERUNMX1FVT1RFRFxuICAgICAgICAgICAgcGFyc2VyLnNnbWxEZWNsICs9IGNcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnNnbWxEZWNsICs9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuU0dNTF9ERUNMX1FVT1RFRDpcbiAgICAgICAgICBpZiAoYyA9PT0gcGFyc2VyLnEpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0dNTF9ERUNMXG4gICAgICAgICAgICBwYXJzZXIucSA9ICcnXG4gICAgICAgICAgfVxuICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCArPSBjXG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuRE9DVFlQRTpcbiAgICAgICAgICBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uZG9jdHlwZScsIHBhcnNlci5kb2N0eXBlKVxuICAgICAgICAgICAgcGFyc2VyLmRvY3R5cGUgPSB0cnVlIC8vIGp1c3QgcmVtZW1iZXIgdGhhdCB3ZSBzYXcgaXQuXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICAgIGlmIChjID09PSAnWycpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX0RURFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpc1F1b3RlKGMpKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9RVU9URURcbiAgICAgICAgICAgICAgcGFyc2VyLnEgPSBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkRPQ1RZUEVfUVVPVEVEOlxuICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICBpZiAoYyA9PT0gcGFyc2VyLnEpIHtcbiAgICAgICAgICAgIHBhcnNlci5xID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5ET0NUWVBFX0RURDpcbiAgICAgICAgICBpZiAoYyA9PT0gJ10nKSB7XG4gICAgICAgICAgICBwYXJzZXIuZG9jdHlwZSArPSBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVcbiAgICAgICAgICB9IGVsc2UgaWYgKGMgPT09ICc8Jykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1dBS0FcbiAgICAgICAgICAgIHBhcnNlci5zdGFydFRhZ1Bvc2l0aW9uID0gcGFyc2VyLnBvc2l0aW9uXG4gICAgICAgICAgfSBlbHNlIGlmIChpc1F1b3RlKGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuZG9jdHlwZSArPSBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVfRFREX1FVT1RFRFxuICAgICAgICAgICAgcGFyc2VyLnEgPSBjXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuRE9DVFlQRV9EVERfUVVPVEVEOlxuICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICBpZiAoYyA9PT0gcGFyc2VyLnEpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9EVERcbiAgICAgICAgICAgIHBhcnNlci5xID0gJydcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ09NTUVOVDpcbiAgICAgICAgICBpZiAoYyA9PT0gJy0nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRfRU5ESU5HXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5jb21tZW50ICs9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ09NTUVOVF9FTkRJTkc6XG4gICAgICAgICAgaWYgKGMgPT09ICctJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UX0VOREVEXG4gICAgICAgICAgICBwYXJzZXIuY29tbWVudCA9IHRleHRvcHRzKHBhcnNlci5vcHQsIHBhcnNlci5jb21tZW50KVxuICAgICAgICAgICAgaWYgKHBhcnNlci5jb21tZW50KSB7XG4gICAgICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgJ29uY29tbWVudCcsIHBhcnNlci5jb21tZW50KVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcGFyc2VyLmNvbW1lbnQgPSAnJ1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuY29tbWVudCArPSAnLScgKyBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ09NTUVOVF9FTkRFRDpcbiAgICAgICAgICBpZiAoYyAhPT0gJz4nKSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ01hbGZvcm1lZCBjb21tZW50JylcbiAgICAgICAgICAgIC8vIGFsbG93IDwhLS0gYmxhaCAtLSBibG9vIC0tPiBpbiBub24tc3RyaWN0IG1vZGUsXG4gICAgICAgICAgICAvLyB3aGljaCBpcyBhIGNvbW1lbnQgb2YgXCIgYmxhaCAtLSBibG9vIFwiXG4gICAgICAgICAgICBwYXJzZXIuY29tbWVudCArPSAnLS0nICsgY1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UXG4gICAgICAgICAgfSBlbHNlIGlmIChwYXJzZXIuZG9jdHlwZSAmJiBwYXJzZXIuZG9jdHlwZSAhPT0gdHJ1ZSkge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFX0RURFxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ0RBVEE6XG4gICAgICAgICAgaWYgKGMgPT09ICddJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQV9FTkRJTkdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmNkYXRhICs9IGNcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ0RBVEFfRU5ESU5HOlxuICAgICAgICAgIGlmIChjID09PSAnXScpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0RBVEFfRU5ESU5HXzJcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLmNkYXRhICs9ICddJyArIGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0RBVEFcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQ0RBVEFfRU5ESU5HXzI6XG4gICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgaWYgKHBhcnNlci5jZGF0YSkge1xuICAgICAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsICdvbmNkYXRhJywgcGFyc2VyLmNkYXRhKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZW1pdE5vZGUocGFyc2VyLCAnb25jbG9zZWNkYXRhJylcbiAgICAgICAgICAgIHBhcnNlci5jZGF0YSA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgICB9IGVsc2UgaWYgKGMgPT09ICddJykge1xuICAgICAgICAgICAgcGFyc2VyLmNkYXRhICs9ICddJ1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gJ11dJyArIGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0RBVEFcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuUFJPQ19JTlNUOlxuICAgICAgICAgIGlmIChjID09PSAnPycpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0VORElOR1xuICAgICAgICAgIH0gZWxzZSBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlBST0NfSU5TVF9CT0RZXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhcnNlci5wcm9jSW5zdE5hbWUgKz0gY1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5QUk9DX0lOU1RfQk9EWTpcbiAgICAgICAgICBpZiAoIXBhcnNlci5wcm9jSW5zdEJvZHkgJiYgaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJz8nKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlBST0NfSU5TVF9FTkRJTkdcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnByb2NJbnN0Qm9keSArPSBjXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlBST0NfSU5TVF9FTkRJTkc6XG4gICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgZW1pdE5vZGUocGFyc2VyLCAnb25wcm9jZXNzaW5naW5zdHJ1Y3Rpb24nLCB7XG4gICAgICAgICAgICAgIG5hbWU6IHBhcnNlci5wcm9jSW5zdE5hbWUsXG4gICAgICAgICAgICAgIGJvZHk6IHBhcnNlci5wcm9jSW5zdEJvZHlcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICBwYXJzZXIucHJvY0luc3ROYW1lID0gcGFyc2VyLnByb2NJbnN0Qm9keSA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGFyc2VyLnByb2NJbnN0Qm9keSArPSAnPycgKyBjXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlBST0NfSU5TVF9CT0RZXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLk9QRU5fVEFHOlxuICAgICAgICAgIGlmIChpc01hdGNoKG5hbWVCb2R5LCBjKSkge1xuICAgICAgICAgICAgcGFyc2VyLnRhZ05hbWUgKz0gY1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBuZXdUYWcocGFyc2VyKVxuICAgICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJy8nKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuT1BFTl9UQUdfU0xBU0hcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGlmICghaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdJbnZhbGlkIGNoYXJhY3RlciBpbiB0YWcgbmFtZScpXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuT1BFTl9UQUdfU0xBU0g6XG4gICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgb3BlblRhZyhwYXJzZXIsIHRydWUpXG4gICAgICAgICAgICBjbG9zZVRhZyhwYXJzZXIpXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCAnRm9yd2FyZC1zbGFzaCBpbiBvcGVuaW5nIHRhZyBub3QgZm9sbG93ZWQgYnkgPicpXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUI6XG4gICAgICAgICAgLy8gaGF2ZW4ndCByZWFkIHRoZSBhdHRyaWJ1dGUgbmFtZSB5ZXQuXG4gICAgICAgICAgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgY29udGlud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NoKG5hbWVCb2R5LCBjKSkge1xuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYk5hbWUgKz0gY1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgYXR0cmlidXRlIG5hbWUnKVxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5BVFRSSUJfTkFNRV9TQVdfV0hJVEU6XG4gICAgICAgICAgaWYgKGMgPT09ICc9Jykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdBdHRyaWJ1dGUgd2l0aG91dCB2YWx1ZScpXG4gICAgICAgICAgICBwYXJzZXIudGFnLmF0dHJpYnV0ZXNbcGFyc2VyLmF0dHJpYk5hbWVdID0gJydcbiAgICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSA9ICcnXG4gICAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsICdvbmF0dHJpYnV0ZScsIHtcbiAgICAgICAgICAgICAgbmFtZTogcGFyc2VyLmF0dHJpYk5hbWUsXG4gICAgICAgICAgICAgIHZhbHVlOiAnJ1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIHBhcnNlci5hdHRyaWJOYW1lID0gJydcbiAgICAgICAgICAgIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgICAgb3BlblRhZyhwYXJzZXIpXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlzTWF0Y2gobmFtZVN0YXJ0LCBjKSkge1xuICAgICAgICAgICAgICBwYXJzZXIuYXR0cmliTmFtZSA9IGNcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfTkFNRVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdJbnZhbGlkIGF0dHJpYnV0ZSBuYW1lJylcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFOlxuICAgICAgICAgIGlmIChpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgICAgfSBlbHNlIGlmIChpc1F1b3RlKGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIucSA9IGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX1FVT1RFRFxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoIXBhcnNlci5vcHQudW5xdW90ZWRBdHRyaWJ1dGVWYWx1ZXMpIHtcbiAgICAgICAgICAgICAgZXJyb3IocGFyc2VyLCAnVW5xdW90ZWQgYXR0cmlidXRlIHZhbHVlJylcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX1VOUVVPVEVEXG4gICAgICAgICAgICBwYXJzZXIuYXR0cmliVmFsdWUgPSBjXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkFUVFJJQl9WQUxVRV9RVU9URUQ6XG4gICAgICAgICAgaWYgKGMgIT09IHBhcnNlci5xKSB7XG4gICAgICAgICAgICBpZiAoYyA9PT0gJyYnKSB7XG4gICAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX0VOVElUWV9RXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwYXJzZXIuYXR0cmliVmFsdWUgKz0gY1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9XG4gICAgICAgICAgYXR0cmliKHBhcnNlcilcbiAgICAgICAgICBwYXJzZXIucSA9ICcnXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfQ0xPU0VEXG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX0NMT1NFRDpcbiAgICAgICAgICBpZiAoaXNXaGl0ZXNwYWNlKGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gJz4nKSB7XG4gICAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICB9IGVsc2UgaWYgKGMgPT09ICcvJykge1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR19TTEFTSFxuICAgICAgICAgIH0gZWxzZSBpZiAoaXNNYXRjaChuYW1lU3RhcnQsIGMpKSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ05vIHdoaXRlc3BhY2UgYmV0d2VlbiBhdHRyaWJ1dGVzJylcbiAgICAgICAgICAgIHBhcnNlci5hdHRyaWJOYW1lID0gY1xuICAgICAgICAgICAgcGFyc2VyLmF0dHJpYlZhbHVlID0gJydcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX05BTUVcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdJbnZhbGlkIGF0dHJpYnV0ZSBuYW1lJylcbiAgICAgICAgICB9XG4gICAgICAgICAgY29udGludWVcblxuICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX1VOUVVPVEVEOlxuICAgICAgICAgIGlmICghaXNBdHRyaWJFbmQoYykpIHtcbiAgICAgICAgICAgIGlmIChjID09PSAnJicpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfRU5USVRZX1VcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSArPSBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgIH1cbiAgICAgICAgICBhdHRyaWIocGFyc2VyKVxuICAgICAgICAgIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIG9wZW5UYWcocGFyc2VyKVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgIH1cbiAgICAgICAgICBjb250aW51ZVxuXG4gICAgICAgIGNhc2UgUy5DTE9TRV9UQUc6XG4gICAgICAgICAgaWYgKCFwYXJzZXIudGFnTmFtZSkge1xuICAgICAgICAgICAgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgICAgfSBlbHNlIGlmIChub3RNYXRjaChuYW1lU3RhcnQsIGMpKSB7XG4gICAgICAgICAgICAgIGlmIChwYXJzZXIuc2NyaXB0KSB7XG4gICAgICAgICAgICAgICAgcGFyc2VyLnNjcmlwdCArPSAnPC8nICsgY1xuICAgICAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0NSSVBUXG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdJbnZhbGlkIHRhZ25hbWUgaW4gY2xvc2luZyB0YWcuJylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnRhZ05hbWUgPSBjXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmIChjID09PSAnPicpIHtcbiAgICAgICAgICAgIGNsb3NlVGFnKHBhcnNlcilcbiAgICAgICAgICB9IGVsc2UgaWYgKGlzTWF0Y2gobmFtZUJvZHksIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIudGFnTmFtZSArPSBjXG4gICAgICAgICAgfSBlbHNlIGlmIChwYXJzZXIuc2NyaXB0KSB7XG4gICAgICAgICAgICBwYXJzZXIuc2NyaXB0ICs9ICc8LycgKyBwYXJzZXIudGFnTmFtZVxuICAgICAgICAgICAgcGFyc2VyLnRhZ05hbWUgPSAnJ1xuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKCFpc1doaXRlc3BhY2UoYykpIHtcbiAgICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdJbnZhbGlkIHRhZ25hbWUgaW4gY2xvc2luZyB0YWcnKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DTE9TRV9UQUdfU0FXX1dISVRFXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLkNMT1NFX1RBR19TQVdfV0hJVEU6XG4gICAgICAgICAgaWYgKGlzV2hpdGVzcGFjZShjKSkge1xuICAgICAgICAgICAgY29udGludWVcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKGMgPT09ICc+Jykge1xuICAgICAgICAgICAgY2xvc2VUYWcocGFyc2VyKVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgJ0ludmFsaWQgY2hhcmFjdGVycyBpbiBjbG9zaW5nIHRhZycpXG4gICAgICAgICAgfVxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgY2FzZSBTLlRFWFRfRU5USVRZOlxuICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX0VOVElUWV9ROlxuICAgICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX0VOVElUWV9VOlxuICAgICAgICAgIHZhciByZXR1cm5TdGF0ZVxuICAgICAgICAgIHZhciBidWZmZXJcbiAgICAgICAgICBzd2l0Y2ggKHBhcnNlci5zdGF0ZSkge1xuICAgICAgICAgICAgY2FzZSBTLlRFWFRfRU5USVRZOlxuICAgICAgICAgICAgICByZXR1cm5TdGF0ZSA9IFMuVEVYVFxuICAgICAgICAgICAgICBidWZmZXIgPSAndGV4dE5vZGUnXG4gICAgICAgICAgICAgIGJyZWFrXG5cbiAgICAgICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfRU5USVRZX1E6XG4gICAgICAgICAgICAgIHJldHVyblN0YXRlID0gUy5BVFRSSUJfVkFMVUVfUVVPVEVEXG4gICAgICAgICAgICAgIGJ1ZmZlciA9ICdhdHRyaWJWYWx1ZSdcbiAgICAgICAgICAgICAgYnJlYWtcblxuICAgICAgICAgICAgY2FzZSBTLkFUVFJJQl9WQUxVRV9FTlRJVFlfVTpcbiAgICAgICAgICAgICAgcmV0dXJuU3RhdGUgPSBTLkFUVFJJQl9WQUxVRV9VTlFVT1RFRFxuICAgICAgICAgICAgICBidWZmZXIgPSAnYXR0cmliVmFsdWUnXG4gICAgICAgICAgICAgIGJyZWFrXG4gICAgICAgICAgfVxuXG4gICAgICAgICAgaWYgKGMgPT09ICc7Jykge1xuICAgICAgICAgICAgdmFyIHBhcnNlZEVudGl0eSA9IHBhcnNlRW50aXR5KHBhcnNlcilcbiAgICAgICAgICAgIGlmIChwYXJzZXIub3B0LnVucGFyc2VkRW50aXRpZXMgJiYgIU9iamVjdC52YWx1ZXMoc2F4LlhNTF9FTlRJVElFUykuaW5jbHVkZXMocGFyc2VkRW50aXR5KSkge1xuICAgICAgICAgICAgICBwYXJzZXIuZW50aXR5ID0gJydcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gcmV0dXJuU3RhdGVcbiAgICAgICAgICAgICAgcGFyc2VyLndyaXRlKHBhcnNlZEVudGl0eSlcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBhcnNlcltidWZmZXJdICs9IHBhcnNlZEVudGl0eVxuICAgICAgICAgICAgICBwYXJzZXIuZW50aXR5ID0gJydcbiAgICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gcmV0dXJuU3RhdGVcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2UgaWYgKGlzTWF0Y2gocGFyc2VyLmVudGl0eS5sZW5ndGggPyBlbnRpdHlCb2R5IDogZW50aXR5U3RhcnQsIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuZW50aXR5ICs9IGNcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsICdJbnZhbGlkIGNoYXJhY3RlciBpbiBlbnRpdHkgbmFtZScpXG4gICAgICAgICAgICBwYXJzZXJbYnVmZmVyXSArPSAnJicgKyBwYXJzZXIuZW50aXR5ICsgY1xuICAgICAgICAgICAgcGFyc2VyLmVudGl0eSA9ICcnXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSByZXR1cm5TdGF0ZVxuICAgICAgICAgIH1cblxuICAgICAgICAgIGNvbnRpbnVlXG5cbiAgICAgICAgZGVmYXVsdDogLyogaXN0YW5idWwgaWdub3JlIG5leHQgKi8ge1xuICAgICAgICAgIHRocm93IG5ldyBFcnJvcihwYXJzZXIsICdVbmtub3duIHN0YXRlOiAnICsgcGFyc2VyLnN0YXRlKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSAvLyB3aGlsZVxuXG4gICAgaWYgKHBhcnNlci5wb3NpdGlvbiA+PSBwYXJzZXIuYnVmZmVyQ2hlY2tQb3NpdGlvbikge1xuICAgICAgY2hlY2tCdWZmZXJMZW5ndGgocGFyc2VyKVxuICAgIH1cbiAgICByZXR1cm4gcGFyc2VyXG4gIH1cblxuICAvKiEgaHR0cDovL210aHMuY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xuICAgICAgICAvLyBGcm9tIHRoZSBzcGVjOiBcIldhaXQgdW50aWwgYW55IGludm9jYXRpb25zIG9mIHRoaXMgYWxnb3JpdGhtIHN0YXJ0ZWQgYmVmb3JlIHRoaXMgb25lIGhhdmUgY29tcGxldGVkLlwiXG4gICAgICAgIC8vIFNvIGlmIHdlJ3JlIGN1cnJlbnRseSBydW5uaW5nIGEgdGFzaywgd2UnbGwgbmVlZCB0byBkZWxheSB0aGlzIGludm9jYXRpb24uXG4gICAgICAgIGlmIChjdXJyZW50bHlSdW5uaW5nQVRhc2spIHtcbiAgICAgICAgICAgIC8vIERlbGF5IGJ5IGRvaW5nIGEgc2V0VGltZW91dC4gc2V0SW1tZWRpYXRlIHdhcyB0cmllZCBpbnN0ZWFkLCBidXQgaW4gRmlyZWZveCA3IGl0IGdlbmVyYXRlZCBhXG4gICAgICAgICAgICAvLyBcInRvbyBtdWNoIHJlY3Vyc2lvblwiIGVycm9yLlxuICAgICAgICAgICAgc2V0VGltZW91dChydW5JZlByZXNlbnQsIDAsIGhhbmRsZSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2YXIgdGFzayA9IHRhc2tzQnlIYW5kbGVbaGFuZGxlXTtcbiAgICAgICAgICAgIGlmICh0YXNrKSB7XG4gICAgICAgICAgICAgICAgY3VycmVudGx5UnVubmluZ0FUYXNrID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBydW4odGFzayk7XG4gICAgICAgICAgICAgICAgfSBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJJbW1lZGlhdGUoaGFuZGxlKTtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudGx5UnVubmluZ0FUYXNrID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gaW5zdGFsbE5leHRUaWNrSW1wbGVtZW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ZvciAodmFyIHMsIGkgPSAxLCBuID0gYXJndW1lbnRzLmxlbmd0aDsgaSA8IG47IGkrKykge1xyXG4gICAgICAgICAgICBzID0gYXJndW1lbnRzW2ldO1xyXG4gICAgICAgICAgICBmb3IgKHZhciBwIGluIHMpIGlmIChPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwocywgcCkpIHRbcF0gPSBzW3BdO1xyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gdDtcclxuICAgIH1cclxuICAgIHJldHVybiBfX2Fzc2lnbi5hcHBseSh0aGlzLCBhcmd1bWVudHMpO1xyXG59XHJcblxyXG5leHBvcnQgZnVuY3Rpb24gX19yZXN0KHMsIGUpIHtcclxuICAgIHZhciB0ID0ge307XHJcbiAgICBmb3IgKHZhciBwIGluIHMpIGlmIChPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwocywgcCkgJiYgZS5pbmRleE9mKHApIDwgMClcclxuICAgICAgICB0W3BdID0gc1twXTtcclxuICAgIGlmIChzICE9IG51bGwgJiYgdHlwZW9mIE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMgPT09IFwiZnVuY3Rpb25cIilcclxuICAgICAgICBmb3IgKHZhciBpID0gMCwgcCA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMocyk7IGkgPCBwLmxlbmd0aDsgaSsrKSB7XHJcbiAgICAgICAgICAgIGlmIChlLmluZGV4T2YocFtpXSkgPCAwICYmIE9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChzLCBwW2ldKSlcclxuICAgICAgICAgICAgICAgIHRbcFtpXV0gPSBzW3BbaV1dO1xyXG4gICAgICAgIH1cclxuICAgIHJldHVybiB0O1xyXG59XHJcblxyXG5leHBvcnQgZnVuY3Rpb24gX19kZWNvcmF0ZShkZWNvcmF0b3JzLCB0YXJnZXQsIGtleSwgZGVzYykge1xyXG4gICAgdmFyIGMg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Bkb25lOiBmYWxzZSB9O1xyXG4gICAgICAgICAgICAgICAgY2FzZSA1OiBfLmxhYmVsKys7IHkgPSBvcFsxXTsgb3AgPSBbMF07IGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgY2FzZSA3OiBvcCA9IF8ub3BzLnBvcCgpOyBfLnRyeXMucG9wKCk7IGNvbnRpbnVlO1xyXG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcclxuICAgICAgICAgICAgICAgICAgICBpZiAoISh0ID0gXy50cnlzLCB0ID0gdC5sZW5ndGggPiAwICYmIHRbdC5sZW5ndGggLSAxXSkgJiYgKG9wWzBdID09PSA2IHx8IG9wWzBdID09PSAyKSkgeyBfID0gMDsgY29udGludWU7IH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAob3BbMF0gPT09IDMgJiYgKCF0IHx8IChvcFsxXSA+IHRbMF0gJiYgb3BbMV0gPCB0WzNdKSkpIHsgXy5sYWJlbCA9IG9wWzFdOyBicmVhazsgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmIChvcFswXSA9PT0gNiAmJiBfLmxhYmVsIDwgdFsxXSkgeyBfLmxhYmVsID0gdFsxXTsgdCA9IG9wOyBicmVhazsgfVxyXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ICYmIF8ubGFiZWwgPCB0WzJdKSB7IF8ubGFiZWwgPSB0WzJdOyBfLm9wcy5wdXNoKG9wKTsgYnJlYWs7IH1cclxuICAgICAgICAgICAgICAgICAgICBpZiAodFsyXSkgXy5vcHMucG9wKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgXy50cnlzLnBvcCgpOyBjb250aW51ZTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBvcCA9IGJvZHkuY2FsbCh0aGlzQXJnLCBfKTtcclxuICAgICAgICB9IGNhdGNoIChlKSB7IG9wID0gWzYsIGVdOyB5ID0gMDsgfSBmaW5hbGx5IHsgZiA9IHQgPSAwOyB9XHJcbiAgICAgICAgaWYgKG9wWz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aChob3N0bmFtZVBhcnRQYXR0ZXJuKSkge1xuICAgICAgICAgIHZhciBuZXdwYXJ0ID0gJyc7XG4gICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGsgPSBwYXJ0Lmxlbmd0aDsgaiA8IGs7IGorKykge1xuICAgICAgICAgICAgaWYgKHBhcnQuY2hhckNvZGVBdChqKSA+IDEyNykge1xuICAgICAgICAgICAgICAvKlxuICAgICAgICAgICAgICAgKiB3ZSByZXBsYWNlIG5vbi1BU0NJSSBjaGFyIHdpdGggYSB0ZW1wb3JhcnkgcGxhY2Vob2xkZXJcbiAgICAgICAgICAgICAgICogd2UgbmVlZCB0aGlzIHRvIG1ha2Ugc3VyZSBzaXplIG9mIGhvc3RuYW1lIGlzIG5vdFxuICAgICAgICAgICAgICAgKiBicm9rZW4gYnkgcmVwbGFjaW5nIG5vbi1BU0NJSSBieSBub3RoaW5nXG4gICAgICAgICAgICAgICAqL1xuICAgICAgICAgICAgICBuZXdwYXJ0ICs9ICd4JztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIG5ld3BhcnQgKz0gcGFydFtqXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgLy8gd2UgdGVzdCBhZ2FpbiB3aXRoIEFTQ0lJIGNoYXIgb25seVxuICAgICAgICAgIGlmICghbmV3cGFydC5tYXRjaChob3N0bmFtZVBhcnRQYXR0ZXJuKSkge1xuICAgICAgICAgICAgdmFyIHZhbGlkUGFydHMgPSBob3N0cGFydHMuc2xpY2UoMCwgaSk7XG4gICAgICAgICAgICB2YXIgbm90SG9zdCA9IGhvc3RwYXJ0cy5zbGljZShpICsgMSk7XG4gICAgICAgICAgICB2YXIgYml0ID0gcGFydC5tYXRjaChob3N0bmFtZVBhcnRTdGFydCk7XG4gICAgICAgICAgICBpZiAoYml0KSB7XG4gICAgICAgICAgICAgIHZhbGlkUGFydHMucHVzaChiaXRbMV0pO1xuICAgICAgICAgICAgICBub3RIb3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aW5nKSkge1xuICAgICAgICAgIGNhbGxiYWNrKClcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBvbmRyYWluID0gY2FsbGJhY2tcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgZC5fZmluYWwgPSBmdW5jdGlvbiAoY2FsbGJhY2spIHtcbiAgICAgICAgaGVhZC5lbmQoKVxuICAgICAgICBvbmZpbmlzaCA9IGNhbGxiYWNrXG4gICAgICB9XG4gICAgICBoZWFkLm9uKCdkcmFpbicsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKG9uZHJhaW4pIHtcbiAgICAgICAgICBjb25zdCBjYiA9IG9uZHJhaW5cbiAgICAgICAgICBvbmRyYWluID0gbnVsbFxuICAgICAgICAgIGNiKClcbiAgICAgICAgfVxuICAgICAgfSlcbiAgICB9IGVsc2UgaWYgKGlzV2ViU3RyZWFtKGhlYWQpKSB7XG4gICAgICBjb25zdCB3cml0YWJsZSA9IGlzVHJhbnNmb3JtU3RyZWFtKGhlYWQpID8gaGVhZC53cml0YWJsZSA6IGhlYWRcbiAgICAgIGNvbnN0IHdyaXRlciA9IHdyaXRhYmxlLmdldFdyaXRlcigpXG4gICAgICBkLl93cml0ZSA9IGFzeW5jIGZ1bmN0aW9uIChjaHVuaywgZW5jb2RpbmcsIGNhbGxiYWNrKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgYXdhaXQgd3JpdGVyLnJlYWR5XG4gICAgICAgICAgd3JpdGVyLndyaXRlKGNodW5rKS5jYXRjaCgoKSA9PiB7fSlcbiAgICAgICAgICBjYWxsYmFjaygpXG4gICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgIGNhbGxiYWNrKGVycilcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgZC5fZmluYWwgPSBhc3luYyBmdW5jdGlvbiAoY2FsbGJhY2spIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBhd2FpdCB3cml0ZXIucmVhZHlcbiAgICAgICAgICB3cml0ZXIuY2xvc2UoKS5jYXRjaCgoKSA9PiB7fSlcbiAgICAgICAgICBvbmZpbmlzaCA9IGNhbGxiYWNrXG4gICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgIGNhbGxiYWNrKGVycilcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBjb25zdCB0b1JlYWQgPSBpc1RyYW5zZm9ybVN0cmVhbSh0YWlsKSA/IHRhaWwucmVhZGFibGUgOiB0YWlsXG4gICAgZW9zKHRvUmVhZCwgKCkgPT4ge1xuICAgICAgaWYgKG9uZmluaXNoKSB7XG4gICAgICAgIGNvbnN0IGNiID0gb25maW5pc2hcbiAgICAgICAgb25maW5pc2ggPSBudWxsXG4gICAgICAgIGNiKClcbiAgICAgIH1cbiAgICB9KVxuICB9XG4gIGlmIChyZWFkYWJsZSkge1xuICAgIGlmIChpc05vZGVTdHJlYW0odGFpbCkpIHtcbiAgICAgIHRhaWwub24oJ3JlYWRhYmxlJywgZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAob25yZWFkYWJsZSkge1xuICAgICAgICAgIGNvbnN0IGNiID0gb25yZWFkYWJsZVxuICAgICAgICAgIG9ucmVhZGFibGUgPSBudWxsXG4gICAgICAgICAgY2IoKVxuICAgICAgICB9XG4gICAgICB9KVxuICAgICAgdGFpbC5vbignZW5kJywgZnVuY3Rpb24gKCkge1xuICAgICAgICBkLnB1c2gobnVsbClcbiAgICAgIH0pXG4gICAgICBkLl9yZWFkID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB3aGlsZSAodHJ1ZSkge1xuICAgICAgICAgIGNvbnN0IGJ1ZiA9IHRhaWwucmVhZCgpXG4gICAgICAgICAgaWYgKGJ1ZiA9PT0gbnVsbCkge1xuICAgICAgICAgICAgb25yZWFkYWJsZSA9IGQuX3JlYWRcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoIWQucHVzaChidWYpKSB7XG4gICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9IGVsc2UgaWYgKGlzV2ViU3RyZWFtKHRhaWwpKSB7XG4gICAgICBjb25zdCByZWFkYWJsZSA9IGlzVHJhbnNmb3JtU3RyZWFtKHRhaWwpID8gdGFpbC5yZWFkYWJsZSA6IHRhaWxcbiAgICAgIGNvbnN0IHJlYWRlciA9IHJlYWRhYmxlLmdldFJlYWRlcigpXG4gICAgICBkLl9yZWFkID0gYXN5bmMgZnVuY3Rpb24gKCkge1xuICAgICAgICB3aGlsZSAodHJ1ZSkge1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBjb25zdCB7IHZhbHVlLCBkb25lIH0gPSBhd2FpdCByZWFkZXIucmVhZCgpXG4gICAgICAgICAgICBpZiAoIWQucHVzaCh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoZG9uZSkge1xuICAgICAgICAgICAgICBkLnB1c2gobnVsbClcbiAgICAgICAgICAgICAgcmV0dXJuXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBjYXRjaCB7XG4gICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgZC5fZGVzdHJveSA9IGZ1bmN0aW9uIChlcnIsIGNhbGxiYWNrKSB7XG4gICAgaWYgKCFlcnIgJiYgb25jbG9zZSAhPT0gbnVsbCkge1xuICAgICAgZXJyID0gbmV3IEFib3J0RXJyb3IoKVxuICAgIH1cbiAgICBvbnJlYWRhYmxlID0gbnVsbFxuICAgIG9uZHJhaW4gPSBudWxsXG4gICAgb25maW5pc2ggPSBudWxsXG4gICAgaWYgKG9uY2xvc2UgPT09IG51bGwpIHtcbiAgICAgIGNhbGxiYWNrKGVycilcbiAgICB9IGVsc2Uge1xuICAgICAgb25jbG9zZSA9IGNhbGxiYWN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R5cGVvZiB0aGVuID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICBsZXQgZFxuICAgICAgY29uc3QgcHJvbWlzZSA9IEZ1bmN0aW9uUHJvdG90eXBlQ2FsbChcbiAgICAgICAgdGhlbixcbiAgICAgICAgdmFsdWUsXG4gICAgICAgICh2YWwpID0+IHtcbiAgICAgICAgICBpZiAodmFsICE9IG51bGwpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFUlJfSU5WQUxJRF9SRVRVUk5fVkFMVUUoJ251bGx5JywgJ2JvZHknLCB2YWwpXG4gICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICAoZXJyKSA9PiB7XG4gICAgICAgICAgZGVzdHJveWVyKGQsIGVycilcbiAgICAgICAgfVxuICAgICAgKVxuICAgICAgcmV0dXJuIChkID0gbmV3IER1cGxleGlmeSh7XG4gICAgICAgIC8vIFRPRE8gKHJvbmFnKTogaGlnaFdhdGVyTWFyaz9cbiAgICAgICAgb2JqZWN0TW9kZTogdHJ1ZSxcbiAgICAgICAgcmVhZGFibGU6IGZhbHNlLFxuICAgICAgICB3cml0ZSxcbiAgICAgICAgZmluYWwoY2IpIHtcbiAgICAgICAgICBmaW5hbChhc3luYyAoKSA9PiB7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICBhd2FpdCBwcm9taXNlXG4gICAgICAgICAgICAgIHByb2Nlc3MubmV4dFRpY2soY2IsIG51bGwpXG4gICAgICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgcHJvY2Vzcy5uZXh0VGljayhjYiwgZXJyKVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pXG4gICAgICAgIH0sXG4gICAgICAgIGRlc3Ryb3lcbiAgICAgIH0pKVxuICAgIH1cbiAgICB0aHJvdyBuZXcgRVJSX0lOVkFMSURfUkVUVVJOX1ZBTFVFKCdJdGVyYWJsZSwgQXN5bmNJdGVyYWJsZSBvciBBc3luY0Z1bmN0aW9uJywgbmFtZ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lZmluZWQgOiBib2R5LnJlYWRhYmxlKVxuICAgICAgICAgID8gYm9keSA9PT0gbnVsbCB8fCBib2R5ID09PSB1bmRlZmluZWRcbiAgICAgICAgICAgID8gdW5kZWZpbmVkXG4gICAgICAgICAgICA6IGJvZHkucmVhZGFibGVcbiAgICAgICAgICA6IGR1cGxleGlmeShib2R5LnJlYWRhYmxlKVxuICAgICAgICA6IHVuZGVmaW5lZFxuICAgIGNvbnN0IHdyaXRhYmxlID1cbiAgICAgIGJvZHkgIT09IG51bGwgJiYgYm9keSAhPT0gdW5kZWZpbmVkICYmIGJvZHkud3JpdGFibGVcbiAgICAgICAgPyBpc1dyaXRhYmxlTm9kZVN0cmVhbShib2R5ID09PSBudWxsIHx8IGJvZHkgPT09IHVuZGVmaW5lZCA/IHVuZGVmaW5lZCA6IGJvZHkud3JpdGFibGUpXG4gICAgICAgICAgPyBib2R5ID09PSBudWxsIHx8IGJvZHkgPT09IHVuZGVmaW5lZFxuICAgICAgICAgICAgPyB1bmRlZmluZWRcbiAgICAgICAgICAgIDogYm9keS53cml0YWJsZVxuICAgICAgICAgIDogZHVwbGV4aWZ5KGJvZHkud3JpdGFibGUpXG4gICAgICAgIDogdW5kZWZpbmVkXG4gICAgcmV0dXJuIF9kdXBsZXhpZnkoe1xuICAgICAgcmVhZGFibGUsXG4gICAgICB3cml0YWJsZVxuICAgIH0pXG4gIH1cbiAgY29uc3QgdGhlbiA9IGJvZHkgPT09IG51bGwgfHwgYm9keSA9PT0gdW5kZWZpbmVkID8gdW5kZWZpbmVkIDogYm9keS50aGVuXG4gIGlmICh0eXBlb2YgdGhlbiA9PT0gJ2Z1bmN0aW9uJykge1xuICAgIGxldCBkXG4gICAgRnVuY3Rpb25Qcm90b3R5cGVDYWxsKFxuICAgICAgdGhlbixcbiAgICAgIGJvZHksXG4gICAgICAodmFsKSA9PiB7XG4gICAgICAgIGlmICh2YWwgIT0gbnVsbCkge1xuICAgICAgICAgIGQucHVzaCh2YWwpXG4gICAgICA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4gICAgICAgIGRlc3Ryb3llcihyLCBlcnIpXG4gICAgICB9XG4gICAgICBvbmZpbmlzaGVkKGVycilcbiAgICB9KVxuICAgIGQuX3dyaXRlID0gZnVuY3Rpb24gKGNodW5rLCBlbmNvZGluZywgY2FsbGJhY2spIHtcbiAgICAgIGlmICh3LndyaXRlKGNodW5rLCBlbmNvZGluZykpIHtcbiAgICAgICAgY2FsbGJhY2soKVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgb25kcmFpbiA9IGNhbGxiYWNrXG4gICAgICB9XG4gICAgfVxuICAgIGQuX2ZpbmFsID0gZnVuY3Rpb24gKGNhbGxiYWNrKSB7XG4gICAgICB3LmVuZCgpXG4gICAgICBvbmZpbmlzaCA9IGNhbGxiYWNrXG4gICAgfVxuICAgIHcub24oJ2RyYWluJywgZnVuY3Rpb24gKCkge1xuICAgICAgaWYgKG9uZHJhaW4pIHtcbiAgICAgICAgY29uc3QgY2IgPSBvbmRyYWluXG4gICAgICAgIG9uZHJhaW4gPSBudWxsXG4gICAgICAgIGNiKClcbiAgICAgIH1cbiAgICB9KVxuICAgIHcub24oJ2ZpbmlzaCcsIGZ1bmN0aW9uICgpIHtcbiAgICAgIGlmIChvbmZpbmlzaCkge1xuICAgICAgICBjb25zdCBjYiA9IG9uZmluaXNoXG4gICAgICAgIG9uZmluaXNoID0gbnVsbFxuICAgICAgICBjYigpXG4gICAgICB9XG4gICAgfSlcbiAgfVxuICBpZiAocmVhZGFibGUpIHtcbiAgICBlb3MociwgKGVycikgPT4ge1xuICAgICAgcmVhZGFibGUgPSBmYWxzZVxuICAgICAgaWYgKGVycikge1xuICAgICAgICBkZXN0cm95ZXIociwgZXJyKVxuICAgICAgfVxuICAgICAgb25maW5pc2hlZChlcnIpXG4gICAgfSlcbiAgICByLm9uKCdyZWFkYWJsZScsIGZ1bmN0aW9uICgpIHtcbiAgICAgIGlmIChvbnJlYWRhYmxlKSB7XG4gICAgICAgIGNvbnN0IGNiID0gb25yZWFkYWJsZV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ICAgICAgcmVzdW1lID0gbnVsbFxuICAgICAgfVxuICAgIH1cbiAgICBhc3luYyBmdW5jdGlvbiBwdW1wKCkge1xuICAgICAgdHJ5IHtcbiAgICAgICAgZm9yIGF3YWl0IChsZXQgdmFsIG9mIHN0cmVhbSkge1xuICAgICAgICAgIGlmIChkb25lKSB7XG4gICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHNpZ25hbC5hYm9ydGVkKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgQWJvcnRFcnJvcigpXG4gICAgICAgICAgfVxuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICB2YWwgPSBmbih2YWwsIHNpZ25hbE9wdClcbiAgICAgICAgICAgIGlmICh2YWwgPT09IGtFbXB0eSkge1xuICAgICAgICAgICAgICBjb250aW51ZVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFsID0gUHJvbWlzZVJlc29sdmUodmFsKVxuICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdmFsID0gUHJvbWlzZVJlamVjdChlcnIpXG4gICAgICAgICAgfVxuICAgICAgICAgIGNudCArPSAxXG4gICAgICAgICAgUHJvbWlzZVByb3RvdHlwZVRoZW4odmFsLCBhZnRlckl0ZW1Qcm9jZXNzZWQsIG9uQ2F0Y2gpXG4gICAgICAgICAgcXVldWUucHVzaCh2YWwpXG4gICAgICAgICAgaWYgKG5leHQpIHtcbiAgICAgICAgICAgIG5leHQoKVxuICAgICAgICAgICAgbmV4dCA9IG51bGxcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKCFkb25lICYmIChxdWV1ZS5sZW5ndGggPj0gaGlnaFdhdGVyTWFyayB8fCBjbnQgPj0gY29uY3VycmVuY3kpKSB7XG4gICAgICAgICAgICBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSkgPT4ge1xuICAgICAgICAgICAgICByZXN1bWUgPSByZXNvbHZlXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBxdWV1ZS5wdXNoKGtFb2YpXG4gICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgY29uc3QgdmFsID0gUHJvbWlzZVJlamVjdChlcnIpXG4gICAgICAgIFByb21pc2VQcm90b3R5cGVUaGVuKHZhbCwgYWZ0ZXJJdGVtUHJvY2Vzc2VkLCBvbkNhdGNoKVxuICAgICAgICBxdWV1ZS5wdXNoKHZhbClcbiAgICAgIH0gZmluYWxseSB7XG4gICAgICAgIGRvbmUgPSB0cnVlXG4gICAgICAgIGlmIChuZXh0KSB7XG4gICAgICAgICAgbmV4dCgpXG4gICAgICAgICAgbmV4dCA9IG51bGxcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgICBwdW1wKClcbiAgICB0cnkge1xuICAgICAgd2hpbGUgKHRydWUpIHtcbiAgICAgICAgd2hpbGUgKHF1ZXVlLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICBjb25zdCB2YWwgPSBhd2FpdCBxdWV1ZVswXVxuICAgICAgICAgIGlmICh2YWwgPT09IGtFb2YpIHtcbiAgICAgICAgICAgIHJldHVyblxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoc2lnbmFsLmFib3J0ZWQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBBYm9ydEVycm9yKClcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHZhbCAhPT0ga0VtcHR5KSB7XG4gICAgICAgICAgICB5aWVsZCB2YWxcbiAgICAgICAgICB9XG4gICAgICAgICAgcXVldWUuc2hpZnQoKVxuICAgICAgICAgIG1heWJlUmVzdW1lKClcbiAgICAgICAgfVxuICAgICAgICBhd2FpdCBuZXcgUHJvbWlzZSgocmVzb2x2ZSkgPT4ge1xuICAgICAgICAgIG5leHQgPSByZXNvbHZlXG4gICAgICAgIH0pXG4gICAgICB9XG4gICAgfSBmaW5hbGx5IHtcbiAgICAgIGRvbmUgPSB0cnVlXG4gIC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HN0cmVhbVxuICAgICAgICAvLyB3ZSBtdXN0IGNyZWF0ZSBhIHByb3h5IHN0cmVhbSBzbyB0aGF0IHBpcGVsaW5lKC4uLilcbiAgICAgICAgLy8gYWx3YXlzIHJldHVybnMgYSBzdHJlYW0gd2hpY2ggY2FuIGJlIGZ1cnRoZXJcbiAgICAgICAgLy8gY29tcG9zZWQgdGhyb3VnaCBgLnBpcGUoc3RyZWFtKWAuXG5cbiAgICAgICAgY29uc3QgcHQgPSBuZXcgUGFzc1Rocm91Z2goe1xuICAgICAgICAgIG9iamVjdE1vZGU6IHRydWVcbiAgICAgICAgfSlcblxuICAgICAgICAvLyBIYW5kbGUgUHJvbWlzZXMvQSsgc3BlYywgYHRoZW5gIGNvdWxkIGJlIGEgZ2V0dGVyIHRoYXQgdGhyb3dzIG9uXG4gICAgICAgIC8vIHNlY29uZCB1c2UuXG4gICAgICAgIGNvbnN0IHRoZW4gPSAoX3JldDIgPSByZXQpID09PSBudWxsIHx8IF9yZXQyID09PSB1bmRlZmluZWQgPyB1bmRlZmluZWQgOiBfcmV0Mi50aGVuXG4gICAgICAgIGlmICh0eXBlb2YgdGhlbiA9PT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgIGZpbmlzaENvdW50KytcbiAgICAgICAgICB0aGVuLmNhbGwoXG4gICAgICAgICAgICByZXQsXG4gICAgICAgICAgICAodmFsKSA9PiB7XG4gICAgICAgICAgICAgIHZhbHVlID0gdmFsXG4gICAgICAgICAgICAgIGlmICh2YWwgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIHB0LndyaXRlKHZhbClcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoZW5kKSB7XG4gICAgICAgICAgICAgICAgcHQuZW5kKClcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBwcm9jZXNzLm5leHRUaWNrKGZpbmlzaClcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAoZXJyKSA9PiB7XG4gICAgICAgICAgICAg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uZ3RoLCBwb3MsIChlcnJvciwgYnl0ZXMpID0+IHtcbiAgICAgICAgaWYgKGVycm9yKSB7XG4gICAgICAgICAgaWYgKCFpdGVyKSB7XG4gICAgICAgICAgICBzdHJlYW0uZW1pdCgnZXJyb3InLCBlcnJvcik7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGl0ZXIoZXJyb3IpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzdHJlYW0uZGVzdHJveSgpO1xuICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICghYnl0ZXMpIHtcbiAgICAgICAgICBpZiAoYnVmZikge1xuICAgICAgICAgICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIGVxZXFlcVxuICAgICAgICAgICAgaWYgKG9wdGlvbnMuc3RhcnQgPT0gbnVsbCB8fCByb3cgPiBvcHRpb25zLnN0YXJ0KSB7XG4gICAgICAgICAgICAgIGlmICghaXRlcikge1xuICAgICAgICAgICAgICAgIHN0cmVhbS5lbWl0KCdsaW5lJywgYnVmZik7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaXRlcihudWxsLCBidWZmKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcm93Kys7XG4gICAgICAgICAgICBidWZmID0gJyc7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJldHVybiBzZXRUaW1lb3V0KHJlYWQsIDEwMDApO1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IGRhdGEgPSBkZWNvZGUud3JpdGUoYnVmZmVyLnNsaWNlKDAsIGJ5dGVzKSk7XG4gICAgICAgIGlmICghaXRlcikge1xuICAgICAgICAgIHN0cmVhbS5lbWl0KCdkYXRhJywgZGF0YSk7XG4gICAgICAgIH1cblxuICAgICAgICBkYXRhID0gKGJ1ZmYgKyBkYXRhKS5zcGxpdCgvXFxuKy8pO1xuXG4gICAgICAgIGNvbnN0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IGF0dGVtcHQpIHtcbiAgICAgIHRyeSB7XG4gICAgICAgIGNvbnN0IGxvZyA9IEpTT04ucGFyc2UoYnVmZik7XG4gICAgICAgIGlmIChjaGVjayhsb2cpKSB7XG4gICAgICAgICAgcHVzaChsb2cpO1xuICAgICAgICB9XG4gICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgIGlmICghYXR0ZW1wdCkge1xuICAgICAgICAgIHN0cmVhbS5lbWl0KCdlcnJvcicsIGUpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcHVzaChsb2cpIHtcbiAgICAgIGlmIChcbiAgICAgICAgb3B0aW9ucy5yb3dzICYmXG4gICAgICAgIHJlc3VsdHMubGVuZ3RoID49IG9wdGlvbnMucm93cyAmJlxuICAgICAgICBvcHRpb25zLm9yZGVyICE9PSAnZGVzYydcbiAgICAgICkge1xuICAgICAgICBpZiAoc3RyZWFtLnJlYWRhYmxlKSB7XG4gICAgICAgICAgc3RyZWFtLmRlc3Ryb3koKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIGlmIChvcHRpb25zLmZpZWxkcykge1xuICAgICAgICBsb2cgPSBvcHRpb25zLmZpZWxkcy5yZWR1Y2UoKG9iaiwga2V5KSA9PiB7XG4gICAgICAgICAgb2JqW2tleV0gPSBsb2dba2V5XTtcbiAgICAgICAgICByZXR1cm4gb2JqO1xuICAgICAgICB9LCB7fSk7XG4gICAgICB9XG5cbiAgICAgIGlmIChvcHRpb25zLm9yZGVyID09PSAnZGVzYycpIHtcbiAgICAgICAgaWYgKHJlc3VsdHMubGVuZ3RoID49IG9wdGlvbnMucm93cykge1xuICAgICAgICAgIHJlc3VsdHMuc2hpZnQoKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmVzdWx0cy5wdXNoKGxvZyk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY2hlY2sobG9nKSB7XG4gICAgICBpZiAoIWxvZykge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIGlmICh0eXBlb2YgbG9nICE9PSAnb2JqZWN0Jykge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIGNvbnN0IHRpbWUgPSBuZXcgRGF0ZShsb2cudGltZXN0YW1wKTtcbiAgICAgIGlmIChcbiAgICAgICAgKG9wdGlvbnMuZnJvbSAmJiB0aW1lIDwgb3B0aW9ucy5mcm9tKSB8fFxuICAgICAgICAob3B0aW9ucy51bnRpbCAmJiB0aW1lID4gb3B0aW9ucy51bnRpbCkgfHxcbiAgICAgICAgKG9wdGlvbnMubGV2ZWwgJiYgb3B0aW9ucy5sZXZlbCAhPT0gbG9nLmxldmVsKVxuICAgICAgKSB7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gbm9ybWFsaXplUXVlcnkob3B0aW9ucykge1xuICAgICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307XG5cbiAgICAgIC8vIGxpbWl0XG4gICAgICBvcHRpb25zLnJvd3MgPSBvcHRpb25zLnJvd3MgfHwgb3B0aW9ucy5saW1pdCB8fCAxMDtcblxuICAgICAgLy8gc3RhcnRpbmcgcm93IG9mZnNldFxuICAgICAgb3B0aW9ucy5zdGFydCA9IG9wdGlvbnMuc3RhcnQgfHwgMDtcblxuICAgICAgLy8gbm93XG4gICAgICBvcHRpb25zLnVudGlsID0gb3B0aW9ucy51bnRpbCB8fCBuZXcgRGF0ZSgpO1xuICAgICAgaWYgKHR5cGVvZiBvcHRpb25zLnVudGlsICE9PSAnb2JqZWN0Jykge1xuICAgICAgICBvcHRpb25zLnVudGlsID0gbmV3IERhdGUob3B0aW9ucy51bnRpbCk7XG4gICAgICB9XG5cbiAgICAgIC8vIG5vdyAtIDI0XG4gICAgICBvcHRpb25zLmZyb20gPSBvcHRpb25zLmZyb20gfHwgKG9wdGl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AocnVubmluZyA+PSBsaW1pdCB8fCBhd2FpdGluZyB8fCBkb25lKSByZXR1cm47XG4gICAgICAgIC8vY29uc29sZS5sb2coJ3JlcGxlbmlzaCBhd2FpdGluZycpXG4gICAgICAgIGF3YWl0aW5nID0gdHJ1ZTtcbiAgICAgICAgZ2VuZXJhdG9yLm5leHQoKS50aGVuKCh7IHZhbHVlLCBkb25lOiBpdGVyRG9uZSB9KSA9PiB7XG4gICAgICAgICAgICAvL2NvbnNvbGUubG9nKCdnb3QgdmFsdWUnLCB2YWx1ZSlcbiAgICAgICAgICAgIGlmIChjYW5jZWxlZCB8fCBkb25lKSByZXR1cm47XG4gICAgICAgICAgICBhd2FpdGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgaWYgKGl0ZXJEb25lKSB7XG4gICAgICAgICAgICAgICAgZG9uZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgaWYgKHJ1bm5pbmcgPD0gMCkge1xuICAgICAgICAgICAgICAgICAgICAvL2NvbnNvbGUubG9nKCdkb25lIG5leHRDYicpXG4gICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBydW5uaW5nKys7XG4gICAgICAgICAgICBpdGVyYXRlZSh2YWx1ZSwgaWR4LCBpdGVyYXRlZUNhbGxiYWNrKTtcbiAgICAgICAgICAgIGlkeCsrO1xuICAgICAgICAgICAgcmVwbGVuaXNoKCk7XG4gICAgICAgIH0pLmNhdGNoKGhhbmRsZUVycm9yKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBpdGVyYXRlZUNhbGxiYWNrKGVyciwgcmVzdWx0KSB7XG4gICAgICAgIC8vY29uc29sZS5sb2coJ2l0ZXJhdGVlQ2FsbGJhY2snKVxuICAgICAgICBydW5uaW5nIC09IDE7XG4gICAgICAgIGlmIChjYW5jZWxlZCkgcmV0dXJuO1xuICA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xlZCkgcmV0dXJuO1xuICAgICAgICAgICAgcnVubmluZyAtPSAxO1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIGRvbmUgPSB0cnVlO1xuICAgICAgICAgICAgICAgIGNhbGxiYWNrKGVycik7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGVyciA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICBkb25lID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBjYW5jZWxlZCA9IHRydWU7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSBfYnJlYWtMb29wMi5kZWZhdWx0IHx8IGRvbmUgJiYgcnVubmluZyA8PSAwKSB7XG4gICAgICAgICAgICAgICAgZG9uZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGNhbGxiYWNrKG51bGwpO1xuICAgICAgICAgICAgfSBlbHNlIGlmICghbG9vcGluZykge1xuICAgICAgICAgICAgICAgIHJlcGxlbmlzaCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gcmVwbGVuaXNoKCkge1xuICAgICAgICAgICAgbG9vcGluZyA9IHRydWU7XG4gICAgICAgICAgICB3aGlsZSAocnVubmluZyA8IGxpbWl0ICYmICFkb25lKSB7XG4gICAgICAgICAgICAgICAgdmFyIGVsZW0gPSBuZXh0RWxlbSgpO1xuICAgICAgICAgICAgICAgIGlmIChlbGVtID09PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBpZiAocnVubmluZyA8PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJ1bm5pbmcgKz0gMTtcbiAgICAgICAgICAgICA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b25lJyk7XG4gKiAgICAgICAgIH0sIDIwMCk7XG4gKiAgICAgfSxcbiAqICAgICBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsICd0d28nKTtcbiAqICAgICAgICAgfSwgMTAwKTtcbiAqICAgICB9XG4gKiBdLCBmdW5jdGlvbihlcnIsIHJlc3VsdHMpIHtcbiAqICAgICBjb25zb2xlLmxvZyhyZXN1bHRzKTtcbiAqICAgICAvLyByZXN1bHRzIGlzIGVxdWFsIHRvIFsnb25lJywndHdvJ11cbiAqIH0pO1xuICpcbiAqIC8vIGFuIGV4YW1wbGUgdXNpbmcgb2JqZWN0cyBpbnN0ZWFkIG9mIGFycmF5c1xuICogYXN5bmMuc2VyaWVzKHtcbiAqICAgICBvbmU6IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICAvLyBkbyBzb21lIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDEpO1xuICogICAgICAgICB9LCAyMDApO1xuICogICAgIH0sXG4gKiAgICAgdHdvOiBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDIpO1xuICogICAgICAgICB9LCAxMDApO1xuICogICAgIH1cbiAqIH0sIGZ1bmN0aW9uKGVyciwgcmVzdWx0cykge1xuICogICAgIGNvbnNvbGUubG9nKHJlc3VsdHMpO1xuICogICAgIC8vIHJlc3VsdHMgaXMgZXF1YWwgdG86IHsgb25lOiAxLCB0d286IDIgfVxuICogfSk7XG4gKlxuICogLy9Vc2luZyBQcm9taXNlc1xuICogYXN5bmMuc2VyaWVzKFtcbiAqICAgICBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgJ29uZScpO1xuICogICAgICAgICB9LCAyMDApO1xuICogICAgIH0sXG4gKiAgICAgZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsICd0d28nKTtcbiAqICAgICAgICAgfSwgMTAwKTtcbiAqICAgICB9XG4gKiBdKS50aGVuKHJlc3VsdHMgPT4ge1xuICogICAgIGNvbnNvbGUubG9nKHJlc3VsdHMpO1xuICogICAgIC8vIHJlc3VsdHMgaXMgZXF1YWwgdG8gWydvbmUnLCd0d28nXVxuICogfSkuY2F0Y2goZXJyID0+IHtcbiAqICAgICBjb25zb2xlLmxvZyhlcnIpO1xuICogfSk7XG4gKlxuICogLy8gYW4gZXhhbXBsZSB1c2luZyBhbiBvYmplY3QgaW5zdGVhZCBvZiBhbiBhcnJheVxuICogYXN5bmMuc2VyaWVzKHtcbiAqICAgICBvbmU6IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gKiAgICAgICAgICAgICAvLyBkbyBzb21lIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDEpO1xuICogICAgICAgICB9LCAyMDApO1xuICogICAgIH0sXG4gKiAgICAgdHdvOiBmdW5jdGlvbihjYWxsYmFjaykge1xuICogICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDIpO1xuICogICAgICAgICB9LCAxMDApO1xuICogICAgIH1cbiAqIH0pLnRoZW4ocmVzdWx0cyA9PiB7XG4gKiAgICAgY29uc29sZS5sb2cocmVzdWx0cyk7XG4gKiAgICAgLy8gcmVzdWx0cyBpcyBlcXVhbCB0bzogeyBvbmU6IDEsIHR3bzogMiB9XG4gKiB9KS5jYXRjaChlcnIgPT4ge1xuICogICAgIGNvbnNvbGUubG9nKGVycik7XG4gKiB9KTtcbiAqXG4gKiAvL1VzaW5nIGFzeW5jL2F3YWl0XG4gKiBhc3luYyAoKSA9PiB7XG4gKiAgICAgdHJ5IHtcbiAqICAgICAgICAgbGV0IHJlc3VsdHMgPSBhd2FpdCBhc3luYy5zZXJpZXMoW1xuICogICAgICAgICAgICAgZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgICAgICAgICAvLyBkbyBzb21lIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgJ29uZScpO1xuICogICAgICAgICAgICAgICAgIH0sIDIwMCk7XG4gKiAgICAgICAgICAgICB9LFxuICogICAgICAgICAgICAgZnVuY3Rpb24oY2FsbGJhY2spIHtcbiAqICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICogICAgICAgICAgICAgICAgICAgICAvLyB0aGVuIGRvIGFub3RoZXIgYXN5bmMgdGFza1xuICogICAgICAgICAgICAgICAgICAgICBjYWxsYmFjayhudWxsLCAndHdvJyk7XG4gKiAgICAgICAgICAgICAgICAgfSwgMTAwKTtcbiAqICAgICAgICAgICAgIH1cbiAqICAgICAgICAgXSk7XG4gKiAgICAgICAgIGNvbnNvbGUubG9nKHJlc3VsdHMpO1xuICogICAgICAgICAvLyByZXN1bHRzIGlzIGVxdWFsIHRvIFsnb25lJywndHdvJ11cbiAqICAgICB9XG4gKiAgICAgY2F0Y2ggKGVycikge1xuICogICAgICAgICBjb25zb2xlLmxvZyhlcnIpO1xuICogICAgIH1cbiAqIH1cbiAqXG4gKiAvLyBhbiBleGFtcGxlIHVzaW5nIGFuIG9iamVjdCBpbnN0ZWFkIG9mIGFuIGFycmF5XG4gKiBhc3luYyAoKSA9PiB7XG4gKiAgICAgdHJ5IHtcbiAqICAgICAgICAgbGV0IHJlc3VsdHMgPSBhd2FpdCBhc3luYy5wYXJhbGxlbCh7XG4gKiAgICAgICAgICAgICBvbmU6IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAqICAgICAgICAgICAgICAgICAgICAgLy8gZG8gc29tZSBhc3luYyB0YXNrXG4gKiAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrKG51bGwsIDEpO1xuICogICAgICAgICAgICAgICAgIH0sIDIwMCk7XG4gKiAgICAgICAgICAgICB9LFxuICogICAgICAgICAgICB0d286IGZ1bmN0aW9uKGNhbGxiYWNrKSB7XG4gKiAgICAgICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbigpIHtcbiAqICAgICAgICAgICAgICAgICAgICAgLy8gdGhlbiBkbyBhbm90aGVyIGFzeW5jIHRhc2tcbiAqICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgMik7XG4gKiAgICAgICAgICAgICAgICAgfSwgMTAwKTtcbiAqICAgICAgICAgICAgfVxuICogICAgICAgICB9KTtcbiAqICAgICAgICAgY29uc29sZS5sb2cocmVzdWx0cyk7XG4gKiAgICAgICAgIC8vIHJlc3VsdHMgaXMgZXF1YWwgdG86IHsgb25lOiAxLCB0d286IDIgfVxuICogICAgIH1cbiAqICAgICBjYXRjaCAoZXJyKSB7XG4gKiAgICAgICAgIGNvbnNvbGUubG9nKGVycik7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0aCkge1xuICAgICAgICAgICAgKytjO1xuICAgICAgICAgICAgaWYgKHAubmV4dCkgdGhpcy5oZWFkID0gcC5uZXh0O2Vsc2UgdGhpcy5oZWFkID0gdGhpcy50YWlsID0gbnVsbDtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5oZWFkID0gcDtcbiAgICAgICAgICAgIHAuZGF0YSA9IHN0ci5zbGljZShuYik7XG4gICAgICAgICAgfVxuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgICsrYztcbiAgICAgIH1cbiAgICAgIHRoaXMubGVuZ3RoIC09IGM7XG4gICAgICByZXR1cm4gcmV0O1xuICAgIH1cblxuICAgIC8vIENvbnN1bWVzIGEgc3BlY2lmaWVkIGFtb3VudCBvZiBieXRlcyBmcm9tIHRoZSBidWZmZXJlZCBkYXRhLlxuICB9LCB7XG4gICAga2V5OiBcIl9nZXRCdWZmZXJcIixcbiAgICB2YWx1ZTogZnVuY3Rpb24gX2dldEJ1ZmZlcihuKSB7XG4gICAgICB2YXIgcmV0ID0gQnVmZmVyLmFsbG9jVW5zYWZlKG4pO1xuICAgICAgdmFyIHAgPSB0aGlzLmhlYWQ7XG4gICAgICB2YXIgYyA9IDE7XG4gICAgICBwLmRhdGEuY29weShyZXQpO1xuICAgICAgbiAtPSBwLmRhdGEubGVuZ3RoO1xuICAgICAgd2hpbGUgKHAgPSBwLm5leHQpIHtcbiAgICAgICAgdmFyIGJ1ZiA9IHAuZGF0YTtcbiAgICAgICAgdmFyIG5iID0gbiA+IGJ1Zi5sZW5ndGggPyBidWYubGVuZ3RoIDogbjtcbiAgICAgICAgYnVmLmNvcHkocmV0LCByZXQubGVuZ3RoIC0gbiwgMCwgbmIpO1xuICAgICAgICBuIC09IG5iO1xuICAgICAgICBpZiAobiA9PT0gMCkge1xuICAgICAgICAgIGlmIChuYiA9PT0gYnVmLmxlbmd0aCkge1xuICAgICAgICAgICAgKytjO1xuICAgICAgICAgICAgaWYg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kYXRhICYmIHJlcXVpcmVzQ0RBVEEob2JqKSkge1xuICAgICAgICAgICAgICBlbGVtZW50LnJhdyh3cmFwQ0RBVEEob2JqKSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBlbGVtZW50LnR4dChvYmopO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShvYmopKSB7XG4gICAgICAgICAgICBmb3IgKGluZGV4IGluIG9iaikge1xuICAgICAgICAgICAgICBpZiAoIWhhc1Byb3AuY2FsbChvYmosIGluZGV4KSkgY29udGludWU7XG4gICAgICAgICAgICAgIGNoaWxkID0gb2JqW2luZGV4XTtcbiAgICAgICAgICAgICAgZm9yIChrZXkgaW4gY2hpbGQpIHtcbiAgICAgICAgICAgICAgICBlbnRyeSA9IGNoaWxkW2tleV07XG4gICAgICAgICAgICAgICAgZWxlbWVudCA9IHJlbmRlcihlbGVtZW50LmVsZShrZXkpLCBlbnRyeSkudXAoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBmb3IgKGtleSBpbiBvYmopIHtcbiAgICAgICAgICAgICAgaWYgKCFoYXNQcm9wLmNhbGwob2JqLCBrZXkpKSBjb250aW51ZTtcbiAgICAgICAgICAgICAgY2hpbGQgPSBvYmpba2V5XTtcbiAgICAgICAgICAgICAgaWYgKGtleSA9PT0gYXR0cmtleSkge1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgY2hpbGQgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICAgIGZvciAoYXR0ciBpbiBjaGlsZCkge1xuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IGNoaWxkW2F0dHJdO1xuICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZWxlbWVudC5hdHQoYXR0ciwgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChrZXkgPT09IGNoYXJrZXkpIHtcbiAgICAgICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5jZGF0YSAmJiByZXF1aXJlc0NEQVRBKGNoaWxkKSkge1xuICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQucmF3KHdyYXBDREFUQShjaGlsZCkpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZWxlbWVudC50eHQoY2hpbGQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChBcnJheS5pc0FycmF5KGNoaWxkKSkge1xuICAgICAgICAgICAgICAgIGZvciAoaW5kZXggaW4gY2hpbGQpIHtcbiAgICAgICAgICAgICAgICAgIGlmICghaGFzUHJvcC5jYWxsKGNoaWxkLCBpbmRleCkpIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgICAgZW50cnkgPSBjaGlsZFtpbmRleF07XG4gICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5jZGF0YSAmJiByZXF1aXJlc0NEQVRBKGVudHJ5KSkge1xuICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LmVsZShrZXkpLnJhdyh3cmFwQ0RBVEEoZW50cnkpKS51cCgpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LmVsZShrZXksIGVudHJ5KS51cCgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gcmVuZGVyKGVsZW1lbnQuZWxlKGtleSksIGVudHJ5KS51cCgpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgY2hpbGQgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICBlbGVtZW50ID0gcmVuZGVyKGVsZW1lbnQuZWxlKGtleSksIGNoaWxkKS51cCgpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgY2hpbGQgPT09ICdzdHJpbmcnICYmIF90aGlzLm9wdGlvbnMuY2RhdGEgJiYgcmVxdWlyZXNDREFUQShjaGlsZCkpIHtcbiAgICAgICAgICAgICAgICAgIGVsZW1lbnQgPSBlbGVtZW50LmVsZShrZXkpLnJhdyh3cmFwQ0RBVEEoY2hpbGQpKS51cCgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBjaGlsZCA9ICcnO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGVsZW1lbnQuZWxlKGtleSwgY2hpbGQudG9TdHJpbmcoKSkudXAoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIGVsZW1lbnQ7XG4gICAgICAgIH07XG4gICAgICB9KSh0aGlzKTtcbiAgICAgIHJvb3RFbGVtZW50ID0gYnVpbGRlci5jcmVhdGUocm9vdE5hbWUsIHRoaXMub3B0aW9ucy54bWxkZWMsIHRoaXMub3B0aW9ucy5kb2N0eXBlLCB7XG4gICAgICAgIGhlYWRsZXNzOiB0aGlzLm9wdGlvbnMuaGVhZGxlc3MsXG4gICAgICAgIGFsbG93U3Vycm9nYXRlQ2hhcnM6IHRoaXMub3B0aW9ucy5hbGxvd1N1cnJv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Y2F0Y2ggKGVycm9yMSkge1xuICAgICAgICBlcnIgPSBlcnJvcjE7XG4gICAgICAgIGlmICghdGhpcy5zYXhQYXJzZXIuZXJyVGhyb3duKSB7XG4gICAgICAgICAgdGhpcy5zYXhQYXJzZXIuZXJyVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICByZXR1cm4gdGhpcy5lbWl0KGVycik7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9O1xuXG4gICAgUGFyc2VyLnByb3RvdHlwZS5hc3NpZ25PclB1c2ggPSBmdW5jdGlvbihvYmosIGtleSwgbmV3VmFsdWUpIHtcbiAgICAgIGlmICghKGtleSBpbiBvYmopKSB7XG4gICAgICAgIGlmICghdGhpcy5vcHRpb25zLmV4cGxpY2l0QXJyYXkpIHtcbiAgICAgICAgICByZXR1cm4gb2JqW2tleV0gPSBuZXdWYWx1ZTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZXR1cm4gb2JqW2tleV0gPSBbbmV3VmFsdWVdO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAoIShvYmpba2V5XSBpbnN0YW5jZW9mIEFycmF5KSkge1xuICAgICAgICAgIG9ialtrZXldID0gW29ialtrZXldXTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gb2JqW2tleV0ucHVzaChuZXdWYWx1ZSk7XG4gICAgICB9XG4gICAgfTtcblxuICAgIFBhcnNlci5wcm90b3R5cGUucmVzZXQgPSBmdW5jdGlvbigpIHtcbiAgICAgIHZhciBhdHRya2V5LCBjaGFya2V5LCBvbnRleHQsIHN0YWNrO1xuICAgICAgdGhpcy5yZW1vdmVBbGxMaXN0ZW5lcnMoKTtcbiAgICAgIHRoaXMuc2F4UGFyc2VyID0gc2F4LnBhcnNlcih0aGlzLm9wdGlvbnMuc3RyaWN0LCB7XG4gICAgICAgIHRyaW06IGZhbHNlLFxuICAgICAgICBub3JtYWxpemU6IGZhbHNlLFxuICAgICAgICB4bWxuczog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AgICBpZiAoIV90aGlzLm9wdGlvbnMuZXhwbGljaXRDaGlsZHJlbiB8fCAhX3RoaXMub3B0aW9ucy5wcmVzZXJ2ZUNoaWxkcmVuT3JkZXIpIHtcbiAgICAgICAgICAgIGRlbGV0ZSBvYmpbXCIjbmFtZVwiXTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKG9iai5jZGF0YSA9PT0gdHJ1ZSkge1xuICAgICAgICAgICAgY2RhdGEgPSBvYmouY2RhdGE7XG4gICAgICAgICAgICBkZWxldGUgb2JqLmNkYXRhO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gMV07XG4gICAgICAgICAgaWYgKG9ialtjaGFya2V5XS5tYXRjaCgvXlxccyokLykgJiYgIWNkYXRhKSB7XG4gICAgICAgICAgICBlbXB0eVN0ciA9IG9ialtjaGFya2V5XTtcbiAgICAgICAgICAgIGRlbGV0ZSBvYmpbY2hhcmtleV07XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLnRyaW0pIHtcbiAgICAgICAgICAgICAgb2JqW2NoYXJrZXldID0gb2JqW2NoYXJrZXldLnRyaW0oKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLm5vcm1hbGl6ZSkge1xuICAgICAgICAgICAgICBvYmpbY2hhcmtleV0gPSBvYmpbY2hhcmtleV0ucmVwbGFjZSgvXFxzezIsfS9nLCBcIiBcIikudHJpbSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgb2JqW2NoYXJrZXldID0gX3RoaXMub3B0aW9ucy52YWx1ZVByb2Nlc3NvcnMgPyBwcm9jZXNzSXRlbShfdGhpcy5vcHRpb25zLnZhbHVlUHJvY2Vzc29ycywgb2JqW2NoYXJrZXldLCBub2RlTmFtZSkgOiBvYmpbY2hhcmtleV07XG4gICAgICAgICAgICBpZiAoT2JqZWN0LmtleXMob2JqKS5sZW5ndGggPT09IDEgJiYgY2hhcmtleSBpbiBvYmogJiYgIV90aGlzLkVYUExJQ0lUX0NIQVJLRVkpIHtcbiAgICAgICAgICAgICAgb2JqID0gb2JqW2NoYXJrZXldO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoaXNFbXB0eShvYmopKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIF90aGlzLm9wdGlvbnMuZW1wdHlUYWcgPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICAgICAgb2JqID0gX3RoaXMub3B0aW9ucy5lbXB0eVRhZygpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgb2JqID0gX3RoaXMub3B0aW9ucy5lbXB0eVRhZyAhPT0gJycgPyBfdGhpcy5vcHRpb25zLmVtcHR5VGFnIDogZW1wdHlTdHI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLnZhbGlkYXRvciAhPSBudWxsKSB7XG4gICAgICAgICAgICB4cGF0aCA9IFwiL1wiICsgKChmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgdmFyIGksIGxlbiwgcmVzdWx0cztcbiAgICAgICAgICAgICAgcmVzdWx0cyA9IFtdO1xuICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBzdGFjay5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgICAgIG5vZGUgPSBzdGFja1tpXTtcbiAgICAgICAgICAgICAgICByZXN1bHRzLnB1c2gobm9kZVtcIiNuYW1lXCJdKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0cztcbiAgICAgICAgICAgIH0pKCkpLmNvbmNhdChub2RlTmFtZSkuam9pbihcIi9cIik7XG4gICAgICAgICAgICAoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgIHZhciBlcnI7XG4gICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iaiA9IF90aGlzLm9wdGlvbnMudmFsaWRhdG9yKHhwYXRoLCBzICYmIHNbbm9kZU5hbWVdLCBvYmopO1xuICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcjEpIHtcbiAgICAgICAgICAgICAgICBlcnIgPSBlcnJvcjE7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLmVtaXQoXCJlcnJvclwiLCBlcnIpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5leHBsaWNpdENoaWxkcmVuICYmICFfdGhpcy5vcHRpb25zLm1lcmdlQXR0cnMgJiYgdHlwZW9mIG9iaiA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgIGlmICghX3RoaXMub3B0aW9ucy5wcmVzZXJ2ZUNoaWxkcmVuT3JkZXIpIHtcbiAgICAgICAgICAgICAgbm9kZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgICAgICAgICAgIGlmIChfdGhpcy5vcHRpb25zLmF0dHJrZXkgaW4gb2JqKSB7XG4gICAgICAgICAgICAgICAgbm9kZVtfdGhpcy5vcHRpb25zLmF0dHJrZXldID0gb2JqW190aGlzLm9wdGlvbnMuYXR0cmtleV07XG4gICAgICAgICAgICAgICAgZGVsZXRlIG9ialtfdGhpcy5vcHRpb25zLmF0dHJrZXldO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmICghX3RoaXMub3B0aW9ucy5jaGFyc0FzQ2hpbGRyZW4gJiYgX3RoaXMub3B0aW9ucy5jaGFya2V5IGluIG9iaikge1xuICAgICAgICAgICAgICAgIG5vZGVbX3RoaXMub3B0aW9ucy5jaGFya2V5XSA9IG9ialtfdGhpcy5vcHRpb25zLmNoYXJrZXldO1xuICAgICAgICAgICAgICAgIGRlbGV0ZSBvYmpbX3RoaXMub3B0aW9ucy5jaGFya2V5XTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMob2JqKS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgbm9kZVtfdGhpcy5vcHRpb25zLmNoaWxka2V5XSA9IG9iajtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBvYmogPSBub2RlO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChzKSB7XG4gICAgICAgICAgICAgIHNbX3RoaXMub3B0aW9ucy5jaGlsZGtleV0gPSBzW190aGlzLm9wdGlvbnMuY2hpbGRrZXldIHx8IFtdO1xuICAgICAgICAgICAgICBvYmpDbG9uZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgICAgICAgICAgIGZvciAoa2V5IGluIG9iaikge1xuICAgICAgICAgICAgICAgIGlmICghaGFzUHJvcC5jYWxsKG9iaiwga2V5KSkgY29udGludWU7XG4gICAgICAgICAgICAgICAgb2JqQ2xvbmVba2V5XSA9IG9ialtrZXldO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHNbX3RoaXMub3B0aW9ucy5jaGlsZGtleV0ucHVzaChvYmpDbG9uZSk7XG4gICAgICAgICAgICAgIGRlbGV0ZSBvYmpbXCIjbmFtZVwiXTtcbiAgICAgICAgICAgICAgaWYgKE9iamVjdC5rZXlzKG9iaikubGVuZ3RoID09PSAxICYmIGNoYXJrZXkgaW4gb2JqICYmICFfdGhpcy5FWFBMSUNJVF9DSEFSS0VZKSB7XG4gICAgICAgICAgICAgICAgb2JqID0gb2JqW2NoYXJrZXldO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICByZXR1cm4gX3RoaXMuYXNzaWduT3JQdXNoKHMsIG5vZGVOYW1lLCBvYmopO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoX3RoaXMub3B0aW9ucy5leHBsaWNpdFJvb3QpIHtcbiAgICAgICAgICAgICAgb2xkID0gb2JqO1xuICAgICAgICAgICAgICBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICAgICAgICBvYmpbbm9kZU5hbWVdID0gb2xkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgX3RoaXMucmVzdWx0T2JqZWN0ID0gb2JqO1xuICAgICAgICAgICAgX3RoaXMuc2F4UGFyc2VyLmVuZGVkID0gdHJ1ZTtcbiAgICAgICAgICAgIHJldHVybiBfdGhpcy5lbWl0KFwiZW5kXCIsIF90aGlzLnJlc3VsdE9iamVjdCk7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgfSkodGhpcyk7XG4gICAgICBvbnRleHQgPSAoZnVuY3Rpb24oX3RoaXMpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRleHQpIHtcbiAgICAgICAgICB2YXIgY2hhckNoaWxkLCBzO1xuICAgICAgICAgIHMgPSBzdGFja1tzdGFjay5sZW5ndGggLSAxXTtcbiAgICAgICAgICBpZiAocykge1xuICAgICAgICAgICAgc1tjaGFya2V5XSArPSB0ZXh0O1xuICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMuZXhwbGljaXRDaGlsZHJlbiAmJiBfdGhpcy5vcHRpb25zLnByZXNlcnZlQ2hpbGRyZW5PcmRlciAmJiBfdGhpcy5vcHRpb25zLmNoYXJzQXNDaGlsZHJlbiAmJiAoX3RoaXMub3B0aW9ucy5pbmNsdWRlV2hpdGVDaGFycyB8fCB0ZXh0LnJlcGxhY2UoL1xcXFxuL2csICcnKS50cmltKCkgIT09ICcnKSkge1xuICAgICAgICAgICAgICBzW190aGlzLm9wdGlvbnMuY2hpbGRrZXldID0gc1tfdGhpcy5vcHRpb25zLmNoaWxka2V5XSB8fCBbXTtcbiAgICAgICAgICAgICAgY2hhckNoaWxkID0ge1xuICAgICAgICAgICAgICAgICcjbmFtZSc6ICdfX3RleHRfXydcbiAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgY2hhckNoaWxkW2NoYXJrZXldID0gdGV4dDtcbiAgICAgICAgICAgICAgaWYgKF90aGlzLm9wdGlvbnMubm9ybWFsaXplKSB7XG4gICAgICAgICAgICAgICAgY2hhckNoaWxkW2NoYXJrZXldID0gY2hhckNoaWxkW2NoYXJrZXldLnJlcGxhY2UoL1xcc3syLH0vZywgXCIgXCIpLnRyaW0oKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBzW190aGlzLm9wdGlvbnMuY2hpbGRrZXldLnB1c2goY2hhckNoaWxkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBzO1xuICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgIH0pKHRoaXMpO1xuICAgICAgdGhpcy5zYXhQYXJzZXIub250ZXh0ID0gb250ZXh0O1xuICAgICAgcmV0dXJuIHRoaXMuc2F4UGFyc2VyLm9uY2RhdGEgPSAoZnVuY3Rpb24oX3RoaXMpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKHRleHQpIHtcbiAgICAgICAgICB2YXIgcztcbiAgICAgICAgICBzID0gb250ZXh0KHRleHQpO1xuICAgICAgICAgIGlmIChzKSB7XG4gICAgICAgICAgICByZXR1cm4gcy5jZGF0YSA9IHRydWU7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgfSkodGhpcyk7XG4gICAgfTtcblxuICAgIFBhcnNlci5wcm90b3R5cGUucGFyc2VTdHJpbmcgPSBmdW5jdGlvbihzdHIsIGNiKSB7XG4gICAgICB2YXIgZXJyO1xuICAgICAgaWYgKChjYiAhPSBudWxsKSAmJiB0eXBlb2YgY2IgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICB0aGlzLm9uKFwiZW5kXCIsIGZ1bmN0aW9uKHJlc3VsdCkge1xuICAgICAgICAgIHRoaXMucmVzZXQoKTtcbiAgICAgICAgICByZXR1cm4gY2IobnVsbCwgcmVzdWx0KTtcbiAgICAgICAgfSk7XG4gICAgICAgIHRoaXMub24oXCJlcnJvclwiLCBmdW5jdGlvbihlcnIpIHtcbiAgICAgICAgICB0aGlzLnJlc2V0KCk7XG4gICAgICAgICAgcmV0dXJuIGNiKGVycik7XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgICAgdHJ5IHtcbiAgICAgICAgc3RyID0gc3RyLnRvU3RyaW5nKCk7XG4gICAgICAgIGlmIChzdHIudHJpbSgpID09PSAnJykge1xuICAgICAgICAgIHRoaXMuZW1pdChcImVuZFwiLCBudWxsKTtcbiAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICBzdHIgPSBib20uc3RyaXBCT00oc3RyKTtcbiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5hc3luYykge1xuICAgICAgICAgIHRoaXMucmVtYWluaW5nID0gc3RyO1xuICAgICAgICAgIHNldEltbWVkaWF0ZSh0aGlzLnByb2Nlc3NBc3luYyk7XG4gICAgICAgICAgcmV0dXJuIHRoaXMuc2F4UGFyc2VyO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLnNheFBhcnNlci53cml0ZShzdHIpLmNsb3NlKCk7XG4gICAgICB9IGNhdGNoIChlcnJvcjEpIHtcbiAgICAgICAgZXJyID0gZXJyb3IxO1xuICAgICAgICBpZiAoISh0aGlzLnNheFBhcnNlci5lcnJUaHJvd24gfHwgdGhpcy5zYXhQYXJzZXIuZW5kZWQpKSB7XG4gICAgICAgICAgdGhpcy5lbWl0KCdlcnJvcicsIGVycik7XG4gICAgICAgICAgcmV0dXJuIHRoaXMuc2F4UGFyc2VyLmVyclRocm93biA9IHRydWU7XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5zYXhQYXJzZXIuZW5kZWQpIHtcbiAgICAgICAgICB0aHJvdyBlcnI7XG4gICA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RCAmJiBub2RlLnN5c0lEKSB7XG4gICAgICAgICAgICBjaHVuayArPSAnIFBVQkxJQyBcIicgKyBub2RlLnB1YklEICsgJ1wiIFwiJyArIG5vZGUuc3lzSUQgKyAnXCInO1xuICAgICAgICAgIH0gZWxzZSBpZiAobm9kZS5zeXNJRCkge1xuICAgICAgICAgICAgY2h1bmsgKz0gJyBTWVNURU0gXCInICsgbm9kZS5zeXNJRCArICdcIic7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChub2RlLmNoaWxkcmVuKSB7XG4gICAgICAgICAgICBjaHVuayArPSAnIFsnO1xuICAgICAgICAgICAgdGhpcy53cml0ZXJPcHRpb25zLnN0YXRlID0gV3JpdGVyU3RhdGUuSW5zaWRlVGFnO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLndyaXRlck9wdGlvbnMuc3RhdGUgPSBXcml0ZXJTdGF0ZS5DbG9zZVRhZztcbiAgICAgICAgICAgIGNodW5rICs9ICc+JztcbiAgICAgICAgICB9XG4gICAgICAgICAgY2h1bmsgKz0gdGhpcy53cml0ZXIuZW5kbGluZShub2RlLCB0aGlzLndyaXRlck9wdGlvbnMsIHRoaXMuY3VycmVudExldmVsKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm9uRGF0YShjaHVuaywgdGhpcy5jdXJyZW50TGV2ZWwpO1xuICAgICAgICByZXR1cm4gbm9kZS5pc09wZW4gPSB0cnVlO1xuICAgICAgfVxuICAgIH07XG5cbiAgICBYTUxEb2N1bWVudENCLnByb3RvdHlwZS5jbG9zZU5vZGUgPSBmdW5jdGlvbihub2RlKSB7XG4gICAgICB2YXIgY2h1bms7XG4gICAgICBpZiAoIW5vZGUuaXNDbG9zZWQpIHtcbiAgICAgICAgY2h1bmsgPSAnJztcbiAgICAgICAgdGhpcy53cml0ZXJPcHRpb25zLnN0YXRlID0gV3JpdGVyU3RhdGUuQ2xvc2VUYWc7XG4gICAgICAgIGlmIChub2RlLnR5cGUgP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GosIGxlbiwgcmVmMiwgc3RyO1xuICAgICAgICBpZiAodGhpcy5ub2RlVHlwZSA9PT0gTm9kZVR5cGUuRWxlbWVudCB8fCB0aGlzLm5vZGVUeXBlID09PSBOb2RlVHlwZS5Eb2N1bWVudEZyYWdtZW50KSB7XG4gICAgICAgICAgc3RyID0gJyc7XG4gICAgICAgICAgcmVmMiA9IHRoaXMuY2hpbGRyZW47XG4gICAgICAgICAgZm9yIChqID0gMCwgbGVuID0gcmVmMi5sZW5ndGg7IGogPCBsZW47IGorKykge1xuICAgICAgICAgICAgY2hpbGQgPSByZWYyW2pdO1xuICAgICAgICAgICAgaWYgKGNoaWxkLnRleHRDb250ZW50KSB7XG4gICAgICAgICAgICAgIHN0ciArPSBjaGlsZC50ZXh0Q29udGVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgcmV0dXJuIHN0cjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiVGhpcyBET00gbWV0aG9kIGlzIG5vdCBpbXBsZW1lbnRlZC5cIiArIHRoaXMuZGVidWdJbmZvKCkpO1xuICAgICAgfVxuICAgIH0pO1xuXG4gICAgWE1MTm9kZS5wcm90b3R5cGUuc2V0UGFyZW50ID0gZnVuY3Rpb24ocGFyZW50KSB7XG4gICAgICB2YXIgY2hpbGQsIGosIGxlbiwgcmVmMiwgcmVzdWx0cztcbiAgICAgIHRoaXMucGFyZW50ID0gcGFyZW50O1xuICAgICAgaWYgKHBhcmVudCkge1xuICAgICAgICB0aGlzLm9wdGlvbnMgPSBwYXJlbnQub3B0aW9ucztcbiAgICAgICAgdGhpcy5zdHJpbmdpZnkgPSBwYXJlbnQuc3RyaW5naWZ5O1xuICAgICAgfVxuICAgICAgcmVmMiA9IHRoaXMuY2hp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KHRoaXMuaXNSb290KSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcIlRoZSByb290IG5vZGUgaGFzIG5vIHBhcmVudC4gVXNlIGRvYygpIGlmIHlvdSBuZWVkIHRvIGdldCB0aGUgZG9jdW1lbnQgb2JqZWN0LlwiKTtcbiAgICAgIH1cbiAgICAgIHJldHVybiB0aGlzLnBhcmVudDtcbiAgICB9O1xuXG4gICAgWE1MTm9kZS5wcm90b3R5cGUucm9vdCA9IGZ1bmN0aW9uKCkge1xuICAgICAgdmFyIG5vZGU7XG4gICAgICBub2RlID0gdGhpcztcbiAgICAgIHdoaWxlIChub2RlKSB7XG4gICAgICAgIGlmIChub2RlLnR5cGUgPT09IE5vZGVUeXBlLkRvY3VtZW50KSB7XG4gICAgICAgICAgcmV0dXJuIG5vZGUucm9vdE9iamVjdDtcbiAgICAgICAgfSBlbHNlIGlmIChub2RlLmlzUm9vdCkge1xuICAgICAgICAgIHJldHVybiBub2RlO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG5vZGUgPSBub2RlLnBhcmVudDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH07XG5cbiAgICBYTUxOb2RlLnByb3RvdHlwZS5kb2N1bWVudCA9IGZ1bmN0aW9uKCkge1xuICAgICAgdmFyIG5vZGU7XG4gICAgICBub2RlID0gdGhpcztcbiAgICAgIHdoaWxlIChub2RlKSB7XG4gICAgICAgIGlmIChub2RlLnR5cGUgPT09IE5vZGVUeXBlLkRvY3VtZW50KSB7XG4gICAgICAgICAgcmV0dXJuIG5vZGU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbm9kZSA9IG5vZGUucGFyZW50O1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfTtcblxuICAgIFhNTE5vZGUucHJvdG90eXBlLmVuZCA9IGZ1bmN0aW9uKG9wdGlvbnMpIHtcbiAgICAgIHJldHVybiB0aGlzLmRvY3VtZW50KCkuZW5kKG9wdGlvbnMpO1xuICAgIH07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ICAgICByZXR1cm4gZmlsdGVyZWRPcHRpb25zO1xuICAgIH07XG5cbiAgICBYTUxXcml0ZXJCYXNlLnByb3RvdHlwZS5pbmRlbnQgPSBmdW5jdGlvbihub2RlLCBvcHRpb25zLCBsZXZlbCkge1xuICAgICAgdmFyIGluZGVudExldmVsO1xuICAgICAgaWYgKCFvcHRpb25zLnByZXR0eSB8fCBvcHRpb25zLnN1cHByZXNzUHJldHR5Q291bnQpIHtcbiAgICAgICAgcmV0dXJuICcnO1xuICAgICAgfSBlbHNlIGlmIChvcHRpb25zLnByZXR0eSkge1xuICAgICAgICBpbmRlbnRMZXZlbCA9IChsZXZlbCB8fCAwKSArIG9wdGlvbnMub2Zmc2V0ICsgMTtcbiAgICAgICAgaWYgKGluZGVudExldmVsID4gMCkge1xuICAgICAgICAgIHJldHVybiBuZXcgQXJyYXkoaW5kZW50TGV2ZWwpLmpvaW4ob3B0aW9ucy5pbmRlbnQpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gJyc7XG4gICAgfTtcblxuICAgIFhNTFdyaXRlckJhc2UucHJvdG90eXBlLmVuZGxpbmUgPSBmdW5jdGlvbihub2RlLCBvcHRpb25zLCBsZXZlbCkge1xuICAgICAgaWYgKCFvcHRpb25zLnByZXR0eSB8fCBvcHRpb25zLnN1cHByZXNzUHJldHR5Q291bnQpIHtcbiAgICAgICAgcmV0dXJuICcnO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcmV0dXJuIG9wdGlvbnMubmV3bGluZTtcbiAgICAgIH1cbiAgICB9O1xuXG4gICAgWE1MV3JpdGVyQmFzZS5wcm90b3R5cGUuYXR0cmlidXRlID0gZnVuY3Rpb24oYXR0LCBvcHRpb25zLCBsZXZlbCkge1xuICAgICAgdmFyIHI7XG4gICAgICB0aGlzLm9wZW5BdHRyaWJ1dGUoYXR0LCBvcHRpb25zLCBsZXZlbCk7XG4gICAgICByID0gJyAnICsgYXR0Lm5hbWUgKyAnPVwiJyArIGF0d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VmMSA9IG5vZGUuY2hpbGRyZW47XG4gICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcmVmMS5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgICAgY2hpbGQgPSByZWYxW2ldO1xuICAgICAgICAgICAgaWYgKChjaGlsZC50eXBlID09PSBOb2RlVHlwZS5UZXh0IHx8IGNoaWxkLnR5cGUgPT09IE5vZGVUeXBlLlJhdykgJiYgKGNoaWxkLnZhbHVlICE9IG51bGwpKSB7XG4gICAgICAgICAgICAgIG9wdGlvbnMuc3VwcHJlc3NQcmV0dHlDb3VudCsrO1xuICAgICAgICAgICAgICBwcmV0dHlTdXBwcmVzc2VkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHIgKz0gJz4nICsgdGhpcy5lbmRsaW5lKG5vZGUsIG9wdGlvbnMsIGxldmVsKTtcbiAgICAgICAgb3B0aW9ucy5zdGF0ZSA9IFdyaXRlclN0YXRlLkluc2lkZVRhZztcbiAgICAgICAgcmVmMiA9IG5vZGUuY2hpbGRyZW47XG4gICAgICAgIGZvciAoaiA9IDAsIGxlbjEgPSByZWYyLmxlbmd0aDsgaiA8IGxlbjE7IGorKykge1xuICAgICAgICAgIGNoaWxkID0gcmVmMltqXTtcbiAgICAgICAgICByICs9IHRoaXMud3JpdGVDaGlsZE5vZGUoY2hpbGQsIG9wdGlvbnMsIGxldmVsICsgMSk7XG4gICAgICAgIH1cbiAgICAgICAgb3B0aW9ucy5zdGF0ZSA9IFdyaXRlclN0YXRlLkNsb3NlVGFnO1xuICAgICAgICByICs9IHRoaXMuaW5kZW50KG5vZGUsIG9wdGlvbnMsIGxldmVsKSArICc8LycgKyBub2RlLm5hbWUgKyAnPic7XG4gICAgICAgIGlmIChwcmV0dHlTdXBwcmVzc2VkKSB7XG4gICAgICAgICAgb3B0aW9ucy5zdXBwcmVzc1ByZXR0e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kVDVCA9IHRoaXM7XG4gICAgICAgICAgICBjb25zdCBtZW51c0J1aWxkZXIgPSBuZXcgTWVudUJ1aWxkZXIoKTtcbiAgICAgICAgICAgIExpZmVjeWNsZUhpc3RvcnkuZ2V0KCkuaW5pdCh0aGlzKTtcbiAgICAgICAgICAgIGNvbnN0IG1lbnUgPSBuZXcgVVJMU2VhcmNoUGFyYW1zKHdpbmRvdy5sb2NhdGlvbi5zZWFyY2gpLmdldCgnbWVudScpO1xuICAgICAgICAgICAgdGhpcy50YWcoJ01haW4nKS5wYXRjaCh7XG4gICAgICAgICAgICAgIE1haW5NZW51OiB7XG4gICAgICAgICAgICAgICAgdHlwZTogTWVudSxcbiAgICAgICAgICAgICAgICBtZW51czogbWVudXNCdWlsZGVyLmJ1aWxkKCksXG4gICAgICAgICAgICAgICAgaW5pdGlhbE1lbnU6IG1lbnUsXG4gICAgICAgICAgICAgICAgeDogNTAsXG4gICAgICAgICAgICAgICAgeTogNTAsXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgaWYgKCF0aGlzLnB1YlN1YlV1aWRQcmVzZW50ICYmIHN5c3RlbXVpID09PSAndHJ1ZScpIHtcbiAgICAgICAgICAgICAgdGhpcy5zZXRBcHBJZChDT05TVEFOVFMuRklSRUJPTFRfQ0VSVF9VSV9BUFBJRCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB0aGlzLmdldEFwcElkKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHRoaXMuX3JlZm9jdXMoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX2dldEZvY3VzZWQoKSB7XG4gICAgICAgICAgaWYgKHRoaXMub3ZlcmxheWVkKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy50YWcoJ092ZXJsYXlzLk92ZXJsYXknKTtcbiAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMudG9hc3RTdGF0ZXM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ChxdWVyeS5wYXJhbXMubWFjYWRkcmVzcykge1xuICAgICAgICAgICAgcHJvY2Vzcy5lbnYuTUFDQUREUkVTUyA9IHF1ZXJ5LnBhcmFtcy5tYWNhZGRyZXNzO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBsb2dnZXIuZXJyb3IoJ05vIE1hYyBBZGRyZXNzIEZvdW5kIGluIFBhcmFtZXRlciBJbml0aWFsaXphdGlvbiByZXNwb25zZS4uLicsICdnZXRQYXJhbWV0ZXJJbml0aWFsaXphdGlvblZhbHVlcycpO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGlmIChxdWVyeS5wYXJhbXMuaGFzT3duUHJvcGVydHkoQ09OU1RBTlRTLlJFR0lTVEVSUFJPVklERVIpKSB7XG4gICAgICAgICAgICBwcm9jZXNzLmVudi5SRUdJU1RFUlBST1ZJREVSID0gcXVlcnkucGFyYW1zLnJlZ2lzdGVycHJvdmlkZXI7XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgLy8gU2V0IHRoZSBwdWJTdWIgVVJMIGlmIHByZXNlbnRcbiAgICAgICAgICBpZiAocXVlcnkucGFyYW1zLnB1YlN1YlVybCkge1xuICAgICAgICAgICAgcHJvY2Vzcy5lbnYuUFVCX1NVQl9VUkwgPSBxdWVyeS5wYXJhbXMucHViU3ViVXJsO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGlmIChxdWVyeS50YXNrKSB7XG4gICAgICAgICAgICBzZXRUaW1lb3V0KCgpID0+IHtcbiAgICAgICAgICAgICAgY29uc3QgaW50ZW50UmVhZGVyID0gbmV3IEludGVudFJlYWRlcigpO1xuICAgICAgICAgICAgICBpbnRlbnRSZWFkZXIucHJvY2Vzc0ludGVudChxdWVyeSk7XG4gICAgICAgICAgICB9LCA4MDAwKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9KTtcbiAgfVxufVxuIiwiLyoqXG4gKiBDb3B5cmlnaHQgMjAyMyBDb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3OiA3NTAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogMzUsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgRXhhbXBsZVRleHQ6IHtcbiAgICAgICAgeDogMTAwLFxuICAgICAgICB5OiAzMDAsXG4gICAgICAgIHc6IDc1MCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAzMCxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBSZXN1bHRUZXh0Qmc6IHtcbiAgICAgICAgeDogODAwLFxuICAgICAgICB5OiAwLFxuICAgICAgICBoOiAxMDgwLFxuICAgICAgICB3OiAxOTIwIC0gOTAwLCAvLyBUT0RPXG4gICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgIGNvbG9yOiAweGJiZmZmZmZmLFxuICAgICAgfSxcbiAgICAgIFJlc3VsdFRleHQ6IHtcbiAgICAgICAgeDogODI1LFxuICAgICAgICB5OiAyNSxcbiAgICAgICAgdzogMTkyMCAtIDkwMCwgLy8gVE9ET1xuICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgZm9udFNpemU6IDMwLFxuICAgICAgICB9LFxuICAgICAgICBjb2xvcjogMHhmZjAwMDAwMCxcbiAgICAgIH0sXG4gICAgICBFeGVjdXRlQnV0dG9uOiB7XG4gICAgICAgIHg6IDEwMCxcbiAgICAgICAgeTogNzAwLFxuICAgICAgICB0eXBlOiBCdXR0b24sXG4gICAgICAgIHRpdGxlOiAnSW52b2tlJyxcbiAgICAgICAgYmFja2dyb3VuZFR5cGU6ICdzdHJva2UnLFxuICAgICAgICBvbkVudGVyOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKCckaW52b2tlTWV0aG9kJyk7XG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgIH07XG4gIH1cblxuICBzZXQgcGFyYW1zKHBhcmFtcykge1xuICAgIHRoaXMuX3BhcmFtcyA9IHBh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uaW5nanMvY29yZSc7XG5pbXBvcnQgeyBNZWRpYVBsYXllciB9IGZyb20gJ0BsaWdodG5pbmdqcy9zZGsnO1xuaW1wb3J0IFRvZ2dsZVdpdGhUZXh0IGZyb20gJy4vVG9nZ2xlV2l0aFRleHQnO1xuY29uc3QgbG9nZ2VyID0gcmVxdWlyZSgnLi91dGlscy9Mb2dnZXInKSgnTWVkaWFWaWV3LmpzJyk7XG5leHBvcnQgZGVmYXVsdCBjbGFzcyBNZWRpYVZpZXcgZXh0ZW5kcyBsbmcuQ29tcG9uZW50IHtcbiAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICByZXR1cm4ge1xuICAgICAgeDogMCxcbiAgICAgIHk6IDAsXG4gICAgICB3OiAodykgPT4gdyxcbiAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgUGxheWVyOiB7XG4gICAgICAgIHg6IDUwLFxuICAgICAgICB5OiA1MCxcbiAgICAgICAgdzogOTYwLFxuICAgICAgICBoOiA1NDAsXG4gICAgICAgIHR5cGU6IE1lZGlhUGxheWVyLFxuICAgICAgfSxcbiAgICAgIFJvdzoge1xuICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgIG5ldmVyU2Nyb2xsOiB0cnVlLFxuICAgICAgICB4OiA1MCxcbiAgICAgICAgeTogMTA4MCAtIDIwMCxcbiAgICAgICAgdzogKHcpID0+IHcsXG4gICAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgICBpdGVtU3BhY2luZzogNTAsXG4gICAgICAgIGl0ZW1zOiBbXG4gICAgICAgICAge1xuICAgICAgICAgICAgcmVmOiAnUGxheScsXG4gICAgICAgICAgICB0eXBlOiBCdXR0b24sXG4gICAgICAgICAgICB0aXRsZTogJ1BsYXknLFxuICAgICAgICAgICAgdzogMjAwLFxuICAgICAgICAgICAgZml4ZWQ6IHRydWUsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kVHlwZTogJ3N0cm9rZScsXG4gICAgICAgICAgICBvbkVudGVyOiBmdW5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G4gICAgICBoOiAoaCkgPT4gaCxcbiAgICAgIE1lbnU6IHtcbiAgICAgICAgdHlwZTogQ29sdW1uLFxuICAgICAgICB3OiAodykgPT4gdyxcbiAgICAgICAgaDogKGgpID0+IGgsXG4gICAgICAgIHg6IDEwMCxcbiAgICAgICAgeTogMTAwLFxuICAgICAgfSxcbiAgICB9O1xuICB9XG5cbiAgX2luaXQoKSB7fVxuXG4gIHNldCBtZW51cyhtZW51cykge1xuICAgIHRoaXMuX21lbnVTdGFjayA9IFtdO1xuICAgIHRoaXMuX21lbnVzID0gbWVudXM7XG4gICAgdGhpcy5fcHVzaE1lbnUobWVudXMpO1xuICB9XG5cbiAgc2V0IGluaXRpYWxNZW51KGltKSB7XG4gICAgaWYgKGltID09IG51bGwpIHJldHVybjtcbiAgICBjb25zdCBtZW51UGF0aHMgPSBpbS5zcGxpdCgnLycpO1xuICAgIGxldCBjdXJJdGVtID0gdGhpcy5tZW51cztcbiAgICBmb3IgKGxldCBpID0gMDsgaSA8IG1lbnVQYXRocy5sZW5ndGg7IGkrKykge1xuICAgICAgY29uc3QgbmV4dEl0ZW0gPSBjdXJJdGVtLmZpbmQoKG0pID0+IG0udGl0bGUudG9Mb3dlckNhc2UoKS5yZXBsYWNlKC9cXHMvZywgJycpID09PSBtZW51UGF0aHNbaV0udG9Mb3dlckNhc2UoKS5yZXBsYWNlKC9cXHMvZywgJycpKTtcbiAgICAgIGlmIChuZXh0SXRlbSkge1xuICAgICAgICBjdXJJdGVtID0gbmV4dEl0ZW0ubWVudXM7XG4gICAgICAgIHRoaXMuX3NlbGVjdEl0ZW0obmV4dEl0ZW0pO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgbG9nZ2VyLmVycm9yKCdDb3VsZCBub3QgZmluZCBtZW51ICcgKyBtZW51UGF0aHNbaV0pO1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG4gICAgfVxuICB9XG5cbiAgZ2V0IG1lbnVzKCkge1xuICAgIHJldHVybiB0aGlzLl9t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GFyYW1zOiBbXG4gICAgICAgICAge1xuICAgICAgICAgICAgbmFtZTogJ2NhbGxiYWNrJyxcbiAgICAgICAgICAgIHZhbHVlOiAoKSA9PiB7fSxcbiAgICAgICAgICB9LFxuICAgICAgICBdLFxuICAgICAgICByZXN1bHQ6IHtcbiAgICAgICAgICBuYW1lOiAnbGlzdGVuZXJJZCcsXG4gICAgICAgICAgdmFsdWU6ICcxMjMnLFxuICAgICAgICB9LFxuICAgICAgfSk7XG4gICAgfVxuICB9XG5cbiAgYWRkUHJvcGVydHlFeGFtcGxlcyhtZXRob2RPYmosIE9QRU5fUlBDKSB7XG4gICAgY29uc3QgZXhhbXBsZXMgPSBtZXRob2RPYmouZXhhbXBsZXM7XG4gICAgaWYgKChoYXNUYWcobWV0aG9kT2JqLCAncHJvcGVydHknKSB8fCBoYXNUYWcobWV0aG9kT2JqLCAncHJvcGVydHk6cmVhZG9ubHknKSkgJiYgIWhhc1RhZyhtZXRob2RPYmosICdwcm9wZXJ0eTppbW11dGFibGUnKSkge1xuICAgICAgZXhhbXBsZXMucHVzaCh7XG4gICAgICAgIG5hbWU6IENPTlNUQU5UUy5TVUJTQ1JJQkUgKyAnICcgKyBtZXRob2RPYmoubmFtZSxcbiAgICAgICAgc2NoZW1hOiB7XG4gICAgICAgICAgdHlwZTogJ251bWJlcicsXG4gICAgICAgIH0sXG4gICAgICAgIHBhcmFtczogW1xuICAgICAgICAgIHtcbiAgICAgICAgICAgIG5hbWU6ICdjYWxsYmFjaycsXG4gICAgICAgICAgICB2YWx1ZTogKCkgPT4ge30sXG4gICAgICAgICAgfSxcbiAgICAgICAgXSxcbiAgICAgICAgcmVzdWx0OiB7XG4gICAgICAgICAgbmFtZTogJ2xpc3RlbmVySWQnLFxuICAgICAgICAgIHZhbHVlOiAnMTIzJyxcbiAgICAgICAgfSxcbiAgICAgIH0pO1xuICAgIH1cbiAgfVxuXG4gIGJ1aWxkTWVudXNGcm9tT3BlblJwYygpIHtcbiAgICBjb25zdCBidW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Rob2QubmFtZS50b0xvd2VyQ2FzZSgpKTtcbiAgICAgICAgICAgICAgaWYgKGZvdW5kKSB7XG4gICAgICAgICAgICAgICAgZm91bmQuZXhhbXBsZXMucHVzaCguLi5tZXRob2QuZXhhbXBsZXMpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IE9QRU5fUlBDLm1ldGhvZHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IG1vZHVsZSA9IE9QRU5fUlBDLm1ldGhvZHNbaV0ubmFtZS5zcGxpdCgnLicpWzBdO1xuICAgICAgICAgICAgY29uc3QgbWV0aG9kID0gT1BFTl9SUEMubWV0aG9kc1tpXS5uYW1lLnNwbGl0KCcuJylbMV07XG4gICAgICAgICAgICBjb25zdCBtZXRob2RPYmogPSBPUEVOX1JQQy5tZXRob2RzW2ldO1xuXG4gICAgICAgICAgICBpZiAobWV0aG9kT2JqKSB7XG4gICAgICAgICAgICAgIG92ZXJyaWRlUGFyYW1zRnJvbVRlc3REYXRhKG1ldGhvZE9iaik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoSUdOT1JFX01PRFVMRVMuaW5kZXhPZihtb2R1bGUpID09PSAtMSkge1xuICAgICAgICAgICAgICBjb25zdCBtb2R1bGVDYXAgPSBtb2R1bGUuY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgKyBtb2R1bGUuc2xpY2UoMSk7XG4gICAgICAgICAgICAgIGNvbnN0IGZpbmQgPSBtZW51cy5maWx0ZXIoKG0pID0+IG0udGl0bGUgPT09IG1vZHVsZUNhcCk7XG4gICAgICAgICAgICAgIGxldCBtb2R1bGVNZW51SXRlbSA9IGZpbmQubGVuZ3RoID09PSAwID8gbnVsbCA6IGZpbmRbMF07XG4gICAgICAgICAgICAgIGlmIChtb2R1bGVNZW51SXRlbSA9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0gPSB7XG4gICAgICAgICAgICAgICAgICB0aXRsZTogbW9kdWxlQ2FwLFxuICAgICAgICAgICAgICAgICAgbWVudXM6IFtdLFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbWVudXMucHVzaChtb2R1bGVNZW51SXRlbSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKE9QRU5fUlBDLm1ldGhvZHNbaV0uZXhhbXBsZXMgJiYgT1BFTl9SUEMubWV0aG9kc1tpXS5leGFtcGxlcy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmFkZFByb3BlcnR5RXhhbXBsZXMobWV0aG9kT2JqLCBPUEVOX1JQQyk7XG4gICAgICAgICAgICAgICAgdGhpcy5hZGRQb2x5bW9ycGhpY1B1bGxFeGFtcGxlcyhtZXRob2RPYmopO1xuICAgICAgICAgICAgICAgIGlmIChPUEVOX1JQQy5tZXRob2RzW2ldLmV4YW1wbGVzLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgICAgICAgIGNvbnN0IG1ldGhvZE1lbnVJdGVtID0ge1xuICAgICAgICAgICAgICAgICAgICB0aXRsZTogbWV0aG9kLFxuICAgICAgICAgICAgICAgICAgICBtZW51czogW10sXG4gICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0ubWVudXMucHVzaChtZXRob2RNZW51SXRlbSk7XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBleElkeCA9IDA7IGV4SWR4IDwgT1BFTl9SUEMubWV0aG9kc1tpXS5leGFtcGxlcy5sZW5ndGg7IGV4SWR4KyspIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9ICcgLSAnICsgT1BFTl9SUEMubWV0aG9kc1tpXS5leGFtcGxlc1tleElkeF0ubmFtZTtcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kTWVudUl0ZW0ubWVudXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IG1ldGhvZCArIG5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgdmlldzogQ2FyZCxcbiAgICAgICAgICAgICAgICAgICAgICBwYXJhbXM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNkazogc2RrLFxuICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBPUEVOX1JQQy5tZXRob2RzW2ldLFxuICAgICAgICAgICAgICAgICAgICAgICAgZXhhbXBsZUluZGV4OiBleElkeCxcbiAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0ubWVudXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBtZXRob2QsXG4gICAgICAgICAgICAgICAgICAgIHZpZXc6IENhcmQsXG4gICAgICAgICAgICAgICAgICAgIHBhcmFtczoge1xuICAgICAgICAgICAgICAgICAgICAgIHNkazogc2RrLFxuICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogT1BFTl9SUEMubWV0aG9kc1tpXSxcbiAgICAgICAgICAgICAgICAgICAgICBleGFtcGxlSW5kZXg6IDAsXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgbW9kdWxlTWVudUl0ZW0ubWVudXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICB0aXRsZTogbWV0aG9kLFxuICAgICAgICAgICAgICAgICAgdmlldzogQ2FyZCxcbiAgICAgICAgICAgICAgICAgIHBhcmFtczoge1xuICAgICAgICAgICAgICAgICAgICBzZGs6IHNkayxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOi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3MgTW9kYWwgZXh0ZW5kcyBsbmcuQ29tcG9uZW50IHtcbiAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICByZXR1cm4ge1xuICAgICAgeDogNTAsXG4gICAgICB5OiA1MCxcbiAgICAgIHpJbmRleDogMyxcbiAgICAgIGZsZXg6IHsgZGlzcGxheTogJ2ZsZXgnLCBhbGxpZ25JdGVtczogJ2NlbnRlcicsIGp1c3RpZnlDb250ZW50OiAnY2VudGVyJyB9LFxuICAgICAgSGVhZGVyOiB7XG4gICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgIHc6IDYwMCxcbiAgICAgICAgaDogMzAwLFxuICAgICAgICBjb2xvcjogMHhmZjFmMmYyZixcblxuICAgICAgICBUaXRsZToge1xuICAgICAgICAgIHg6IDE0MCxcbiAgICAgICAgICB5OiAxMDAsXG4gICAgICAgICAgbW91bnRZOiAwLjUsXG4gICAgICAgICAgdGV4dDoge1xuICAgICAgICAgICAgdGV4dDogQ09OU1RBTlRTLkVYSVRfTU9EQUxfVElUTEUsIC8vIHRleHQgZGlzcGxheWVkIGluIG1vZGFsXG4gICAgICAgICAgICBmb250U2l6ZTogMzAsXG4gICAgICAgICAgICB0ZXh0QWxpZ246ICdjZW50ZXInLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICAgIHRleHR1cmU6IGxuZy5Ub29scy5nZXRTaGFkb3dSZWN0KDE1MCwgNDAsIDQsIDEsIDQpLFxuICAgICAgICBCdXR0b25zOiB7XG4gICAgICAgICAgeDogMTAwLFxuICAgICAgICAgIHk6IDE1MCxcbiAgICAgICAgICBMZWZ0QnV0dG9uOiB7XG4gICAgICAgICAgICB0eXBlOiBCdXR0b25TbWFsbCxcbiAgICAgICAgICAgIHRpdGxlOiBDT05TVEFOVFMuWUVTLFxuICAgICAgICAgICAgYmFja2dyb3VuZFR5cGU6ICdzdHJva2UnLFxuICAgICAgICAgICAgYnV0dG9uVGV4dDogJ0xlZnQnLFxuICAgICAgICA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GV4YW1wbGVJbmRleCA9IDA7IGV4YW1wbGVJbmRleCA8IG1ldGhvZC5leGFtcGxlcy5sZW5ndGg7IGV4YW1wbGVJbmRleCsrKSB7XG4gICAgICAgICAgICAgIGxldCBwYXJhbVZhbHVlcyA9IFtdO1xuICAgICAgICAgICAgICBpZiAodGhpcy5tZXRob2RGaWx0ZXJzLmlzU3Vic2NyaWJlTWV0aG9kKG1ldGhvZC5leGFtcGxlc1tleGFtcGxlSW5kZXhdKSB8fCB0aGlzLm1ldGhvZEZpbHRlcnMuaXNTZXRNZXRob2QobWV0aG9kLmV4YW1wbGVzW2V4YW1wbGVJbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKHRoaXMubWV0aG9kRmlsdGVycy5pc1NldE1ldGhvZChtZXRob2QuZXhhbXBsZXNbZXhhbXBsZUluZGV4XSkpIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIGlmICh0aGlzLm1ldGhvZEZpbHRlcnMuc2hvdWxkRXhjbHVkZUV4YW1wbGUobWV0aG9kLmV4YW1wbGVzW2V4YW1wbGVJbmRleF0pKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIG1ldGhvZFdpdGhFeGFtcGxlTmFtZSA9IG1ldGhvZE9iai5uYW1lICsgJy4nICsgbWV0aG9kT2JqLmV4YW1wbGVzW2V4YW1wbGVJbmRleF0ubmFtZTtcbiAgICAgICAgICAgICAgICBtZXRob2RVdWlkID0gdGhpcy5jcmVhdGVVVUlEKCk7XG4gICAgICAgICAgICAgICAgZXhhbXBsZSA9IG1ldGhvZC5leGFtcGxlc1tleGFtcGxlSW5kZXhdO1xuICAgICAgICAgICAgICAgIHBhcmFtVmFsdWVzID0gZXhhbXBsZS5wYXJhbXMubWFwKChwKSA9PiBwLnZhbHVlKTtcblxuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBudWxsO1xuXG4gICAgICAgICAgICAgICAgLy8gT3ZlcnJpZGluZyB0aGUgc2NoZW1hIHdpdGggdGhlIGJlbG93IGZvcm1hdFxuICAgICAgICAgICAgICAgIGNvbnN0IHNjaGVtYUZvcm1hdCA9IHtcbiAgICAgICAgICAgICAgICAgIHR5cGU6ICdvYmplY3QnLFxuICAgICAgICAgICAgICAgICAgcHJvcGVydGllczoge30sXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBpZiAobWV0aG9kLmV4YW1wbGVzW2V4YW1wbGVJbmRleF0uc2NoZW1hKSB7XG4gICAgICAgICAgICAgICAgICBzY2hlbWFNYXAgPSBtZXRob2QuZXhhbXBsZXNbZXhhbXBsZUluZGV4XTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgc2NoZW1hTWFwID0gbWV0aG9kLnJlc3VsdDtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiB0aGUgbWV0aG9kIGlzIGFuIGV4Y2VwdGlvbiBtZXRob2RcbiAgICAgICAgICAgICAgICBjb25zdCBpc0V4Y2VwdGlvbk1ldGhvZCA9IHRoaXMubWV0aG9kRmlsdGVycy5pc0V4Y2VwdGlvbk1ldGhvZChtZXRob2RPYmoubmFtZSwgZXhhbXBsZS5wYXJhbXMpO1xuICAgICAgICAgICAgICAgIGNvbnN0IHByb3BlcnR5S2V5ID0gaXNFeGNlcHRpb25NZXRob2QgPyAnZXJyb3InIDogJ3Jlc3VsdCc7XG5cbiAgICAgICAgICAgICAgICAvLyBJZiB0aGUgc2NoZW1hIGFscmVhZHkgaGFzIGEgXCJwcm9wZXJ0aWVzXCIgZmllbGQgYW5kIGRvZXMgbm90IGhhdmUgXCJlcnJvclwiIG9yIFwicmVzdWx0XCIsIG92ZXJy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b2tlZFNkayk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgY29uc3QgcmVzcG9uc2UgPSB7IHJlc3VsdDogcmVzdWx0IH07XG4gICAgICAgICAgICAgICAgbGV0IHNjaGVtYVZhbGlkYXRpb25SZXN1bHRGb3JFYWNoRXhhbXBsZSA9IHZhbGlkYXRvci52YWxpZGF0ZShyZXNwb25zZSwgc2NoZW1hTWFwLnNjaGVtYSk7XG5cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5tZXRob2RGaWx0ZXJzLmlzRXZlbnRNZXRob2QobWV0aG9kT2JqKSkge1xuICAgICAgICAgICAgICAgICAgbG9nZ2VyLmluZm8oVEFHICsgYCR7bWV0aG9kT2JqLm5hbWV9IFJlc3VsdCA9PiAke0pTT04uc3RyaW5naWZ5KHJlc3BvbnNlKX1gLCAnbm9ydGhCb3VuZFNjaGVtYVZhbGlkYXRpb25BbmRSZXBvcnRHZW5lcmF0aW9uJyk7XG4gICAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2UgJiYgcmVzcG9uc2UucmVzdWx0ICYmIHR5cGVvZiByZXNwb25zZS5yZXN1bHQuaW5jbHVkZXMgPT09ICdmdW5jdGlvbicgJiYgcmVzcG9uc2UucmVzdWx0LmluY2x1ZGVzKCdTdWNjZXNzZnVsJykpIHtcbiAgICAgICAgICAgICAgICAgICAgc2NoZW1hVmFsaWRhdGlvblJlc3VsdEZvckVhY2hFeGFtcGxlID0geyBlcnJvcnM6IFtdIH07XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnN0IHNjaGVtYVZhbGlkYXRpb25SZXN1bHRGb3JFYWNoRXhhbXBsZVNldCA9IHtcbiAgICAgICAgICAgICAgICAgIHJlc3BvbnNlOiByZXNwb25zZSxcbiAgICAgICAgICAgICAgICAgIHBhcmFtOiBleGFtcGxlLnBhcmFtcyxcbiAgICAgICAgICAgICAgICAgIHZhbGlkYXR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mFtZSwgJ25vcnRoQm91bmRTY2hlbWFWYWxpZGF0aW9uQW5kUmVwb3J0R2VuZXJhdGlvbicpO1xuICAgICAgICAgICAgICAgIC8vIERvaW5nIHNjaGVtYSB2YWxpZGF0aW9uIGZvciBlcnJvciByZXNwb25zZSBvbmx5IGlmIHNjaGVtYSBpcyBwcmVzZW50XG4gICAgICAgICAgICAgICAgaWYgKHNjaGVtYU1hcC5zY2hlbWEpIHtcbiAgICAgICAgICAgICAgICAgIGNvbnN0IHNjaGVtYVZhbGlkYXRpb25SZXN1bHQgPSB2YWxpZGF0b3IudmFsaWRhdGUoZXJyb3JSZXNwb25zZSwgc2NoZW1hTWFwLnNjaGVtYSk7XG4gICAgICAgICAgICAgICAgICBvYmogPSB7XG4gICAgICAgICAgICAgICAgICAgIGVycm9yOiBlcnJvclJlc3BvbnNlLFxuICAgICAgICAgICAgICAgICAgICBwYXJhbTogZXhhbXBsZS5wYXJhbXMsXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZFdpdGhFeGFtcGxlTmFtZTogbWV0aG9kV2l0aEV4YW1wbGVOYW1lLFxuICAgICAgICAgICAgICAgICAgICB2YWxpZGF0aW9uUmVzdWx0OiBzY2hlbWFWYWxpZGF0aW9uUmVzdWx0LFxuICAgICAgICAgICAgICAgICAgICBtZXRob2RVdWlkOiBtZXRob2RVdWlkLFxuICAgICAgICAgICAgICAgICAgICBzY2hlbWFEYXRhOiBzY2hlbWFNYXAuc2NoZW1hLFxuICAgICAgICAgICAgICAgICAgICBhcGlFeGVjdXRpb25TdGFydFRpbWU6IGFwaUV4ZWN1dGlvblN0YXJ0VGltZSxcbiAgICAgICAgICAgICAgICAgICAgYXBpRXhlY3V0aW9uRW5kVGltZTogYXBpRXhlY3V0aW9uRW5kVGltZSxcbiAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgIG9iaiA9IHtcbiAgICAgICAgICAgICAgICAgICAgZXJy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RhdGlvblZpZXcgZXh0ZW5kcyBsbmcuQ29tcG9uZW50IHtcbiAgc3RhdGljIF90ZW1wbGF0ZSgpIHtcbiAgICByZXR1cm4ge1xuICAgICAgeDogMCxcbiAgICAgIHk6IDAsXG4gICAgICB3OiAodykgPT4gdyxcbiAgICAgIGg6IChoKSA9PiBoLFxuICAgICAgSGlzdG9yeToge1xuICAgICAgICB3OiAodykgPT4gdyxcbiAgICAgICAgaDogKGgpID0+IGgsXG4gICAgICAgIHR5cGU6IENvbHVtbixcbiAgICAgIH0sXG4gICAgICBDb25zb2xlVmlldzoge1xuICAgICAgICB4OiA1MjAsXG4gICAgICAgIHk6IDAsXG4gICAgICAgIGg6IDk5MCxcbiAgICAgICAgdzogMTkyMCAtIDYwMCxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgejogMTAwMCxcbiAgICAgIH0sXG4gICAgICBOb3RpZmljYXRpb246IHtcbiAgICAgICAgdmlzaWJsZTogZmFsc2UsXG4gICAgICAgIHJlY3Q6IHRydWUsXG4gICAgICAgIGNvbG9yOiAweGZmMDAwMDAwLCAvLyBCbGFjayBjb2xvclxuICAgICAgICBvcGFjaXR5OiAwLjgsIC8vIE9wYWNpdHkgdmFsdWUgKDAuMCB0byAxLjApXG4gICAgICAgIHc6IDUwMCxcbiAgICAgICAgaDogMjAwLFxuICAgICAgICB4OiAxMzMwLFxuICAgICAgICB5OiA3NzUsXG4gICAgICAgIEVycm9yOiB7XG4gICAgICAgICAgeDogMjAsXG4gICAgICAgICAgeTogMTUsXG4gICAgICAgICAgdGV4dDoge1xuICAgICAgICAgICAgdGV4dDogQ09OU1RBTlRTLlBMQVRGT1JNX0VSUk9SX01FU1NBR0UsXG4gICAgICAgICAgICBmb250U2l6ZTogMjYsXG4gICAgICAgICAgICB0ZXh0Q29sb3I6IDB4ZmZmZjAwMDAsIC8vIFJlZCBjb2xvclxuICAgICAgICAgICAgd29yZFdyYXA6IGZhbHNlLFxuICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogMjgwLFxuICAgICAgICAgICAgdGV4dEFsaWduOiAnbGVmdCcsXG4gICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgICAgUGxhdGZvcm06IHtcbiAgICAgICAgICB4OiAyMCxcbiAgICAgICAgICB5OiA2MCxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiBwcm9jZXNzLmVudi5QTEFURk9STSxcbiAgICAgICAgICAgIGZvbnRTaXplOiAxOCxcbiAgICAgICAgICAgIHRleHRDb2xvcjogMHhmZmZmZmZmZiwgLy8gd2hpdGUgY29sb3JcbiAgICAgICAgICAgIHdvcmRXcmFwOiBmYWxzZSxcbiAgICAgICAgICAgIHdvcmRXcmFwV2lkdGg6IDI4MCxcbiAgICAgICAgICAgIHRleHRBbGlnbjogJ2xlZnQnLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICAgIFRhcmdldDoge1xuICAgICAgICAgIHg6IDE1LFxuICAgICAgICAgIHk6IDExMCxcbiAgICAgICAgICB0ZXh0OiB7XG4gICAgICAgICAgICB0ZXh0OiBDT05TVEFOVFMuUExBVEZPUk1fVEFSR0VULFxuICAgICAgICAgICAgZm9udFNpemU6IDE4LFxuICAgICAgICAgICAgdGV4dENvbG9yOiAweGZmZmZmZmZmLCAvLyB3aGl0ZSBjb2xvclxuICAgICAgICAgICAgd29yZFdyYXA6IGZhbHNlLFxuICAgICAgICAgICAgd29yZFdyYXBXaWR0aDogMjgwLFxuICAgICAgICAgICAgdGV4dEFsaWduOiAnbGVmdCcsXG4gICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBVcGRhdGVUZXh0OiB7XG4gICAgICAgIHg6IDgyNSxcbiAgICAgICAgeTogMjUsXG4gICAgICAgIHc6IDE5MjAgLSA3MDAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogMzAsXG4gICAgICAgIH0sXG4gICAgICAgIGNvbG9yOiAweGZmZmYwMDBmLFxuICAgICAgfSxcbiAgICAgIEFwaXRpdGxlVGV4dDoge1xuICAgICAgICB4OiA1MzAsXG4gICAgICAgIHk6IDEwMCxcbiAgICAgICAgdzogMTkyMCAtIDcwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAyNyxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMjM0NTYsXG4gICAgICB9LFxuICAgICAgU2NoZW1hVmFsaWRhdGlvblN0YXRlVGV4dDoge1xuICAgICAgICB4OiA1MzAsXG4gICAgICAgIHk6IDE1MCxcbiAgICAgICAgdzogMTkyMCAtIDcwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAyNyxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMjM0NTYsXG4gICAgICB9LFxuICAgICAgTWVzc2FnZToge1xuICAgICAgICB4OiA1MzAsXG4gICAgICAgIHk6IDIwMCxcbiAgICAgICAgdzogMTkyMCAtIDcwMCxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIGZvbnRTaXplOiAyNyxcbiAgICAgICAgfSxcbiAgICAgICAgY29sb3I6IDB4ZmYxMjM0NTYsXG4gICAgICB9LFxuICAgICAgVmFsaWRhdGlvbkRhdGE6IHtcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgeDogNTMwLFxuICAgICAgICB5OiAyNTAsXG4gICAgICAgIHc6IDE5MjAgLSA5MDAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogMjcsXG4gICAgICAgIH0sXG4gICAgICAgIGNvbG9yOiAweGZmMTIzNDU2LFxuICAgICAgfSxcbiAgICAgIEV4ZWN1dGVCdXR0b246IHtcbiAgICAgICAgdHlwZTogQnV0dG9uLFxuICAgICAgICB0aXRsZTogJ0ludm9rZScsXG4gICAgICAgIGJhY2tncm91bmRUeXBlOiAnc3Ryb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0dXJuIHB1cmNoYXNlZENvbnRlbnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbnN0IFBVUkNIQVNFRENPTlRFTlRFWEFNUExFU19ORUcgPSBQVVJDSEFTRURDT05URU5URVhBTVBMRVM7XG4gICAgICAgICAgICBkZWxldGUgUFVSQ0hBU0VEQ09OVEVOVEVYQU1QTEVTX05FRy5QVVJDSEFTRURDT05URU5UX1BPU0lUSVZFO1xuICAgICAgICAgICAgY29uc3QgcHVyY2hhc2VkQ29udGVudCA9IFBVUkNIQVNFRENPTlRFTlRFWEFNUExFU19ORUc7XG4gICAgICAgICAgICByZXR1cm4gcHVyY2hhc2VkQ29udGVudFtwcm9jZXNzLmVudi5wdXJjaGFzZWRDb250ZW50VGVzdENhc2VdO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgIH0pO1xuICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICB9KTtcbiAgfVxuXG4gIGVudGl0eUluZm8oKSB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlKSA9PiB7XG4gICAgICBEaXNjb3ZlcnkuZW50aXR5SW5mbyhhc3luYyAocmVxKSA9PiB7XG4gICAgICAgIGlmIChyZXEgPT0gbnVsbCkge1xuICAgICAgICAgIC8vIGRvbid0IGNhcmUgYWJvdXQgdGhlIGxpc3RlbmluZyBhY2tcbiAgICAgICAgICByZXNvbHZlKHsgbWVzc2FnZTogJ2VudGl0eUluZm8gaGFzIGJlZW4gcmVxdWVzdGVkJyB9KTtcbiAgICAgICAgICBjb25zdCBydiA9IHsgLi4uTU9DS19FTklUWV9JTkZPIH07XG4gICAgICAgICAgcnYuZW50aXR5LmlkZW50aWZpZXJzLmVudGl0eUlkID0gcmVxLmVudGl0eUlkO1xuICAgICAgICAgIHJldHVybiBydjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBj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ICAgICAgICAgdzogMTAwMCxcbiAgICAgICAgICBoOiAzMDAsXG4gICAgICAgICAgcGFyYW1zOiB7XG4gICAgICAgICAgICB0aXRsZTogJ0RvIHlvdSBnaXZlIGFjY2VzcyB0byAnICsgY2hhbGxlbmdlLnJlcXVlc3Rvci5uYW1lICsgJyB0byAnICsgY2hhbGxlbmdlLmNhcGFiaWxpdHkgKyAnPycsXG4gICAgICAgICAgICBncmFudENhbGxiYWNrOiAoKSA9PiB7XG4gICAgICAgICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgICAgICAgZ3JhbnRlZDogdHJ1ZSxcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lcik7XG4gICAgICAgICAgICAgIHJlc29sdmUodHJ1ZSk7XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZGVueUNhbGxiYWNrOiAoKSA9PiB7XG4gICAgICAgICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgICAgICAgZ3JhbnRlZDogZmFsc2UsXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGRlZmVycmVkQ2FsbGJhY2soKSB7XG4gICAgICAgICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgICAgICAgZ3JhbnRlZDogbnVsbCxcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lcik7XG4gICAgICAgICAgICAgIHJlc29sdmUodHJ1ZSk7XG4gICAgICAgICAgICB9LFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICB9KTtcbiAgICB9KTtcbiAgICB0aGlzLl9hcHAuX3JlZm9jdXMoKTtcbiAgfVxufVxuIiwiLyoqXG4gKiBDb3B5cmlnaHQgMjAyMyBDb21jYXN0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iAqL1xuXG5pbXBvcnQgeyBCdXR0b24sIFJvdyB9IGZyb20gJ0BsaWdodG5pbmdqcy91aS1jb21wb25lbnRzJztcbmltcG9ydCBsbmcgZnJvbSAnQGxpZ2h0bmluZ2pzL2NvcmUnO1xuXG5leHBvcnQgZGVmYXVsdCBjbGFzcyBBY2tub3dsZWRnZVByb21wdCBleHRlbmRzIGxuZy5Db21wb25lbnQge1xuICBzdGF0aWMgX3RlbXBsYXRlKCkge1xuICAgIHJldHVybiB7XG4gICAgICB4OiAwLFxuICAgICAgeTogMCxcbiAgICAgIHc6ICh3KSA9PiB3LFxuICAgICAgaDogKGgpID0+IGgsXG4gICAgICBCYWNrZ3JvdW5kOiB7XG4gICAgICAgIHc6ICh3KSA9PiB3LFxuICAgICAgICBoOiAoaCkgPT4gaCxcbiAgICAgICAgcmVjdDogdHJ1ZSxcbiAgICAgICAgc2hhZGVyOiB7XG4gICAgICAgICAgdHlwZTogbG5nLnNoYWRlcnMuUm91bmRlZFJlY3RhbmdsZSxcbiAgICAgICAgICByYWRpdXM6IDQwLFxuICAgICAgICB9LFxuICAgICAgICBjb2xvcjogMHhmZjExMTExMSxcbiAgICAgIH0sXG4gICAgICBUaXRsZToge1xuICAgICAgICB4OiA1MCxcbiAgICAgICAgeTogNTAsXG4gICAgICAgIHc6ICh3KSA9PiB3IC0gMTAwLFxuICAgICAgICBoOiAxMDAsXG4gICAgICAgIHRleHQ6IHtcbiAgICAgICAgICBmb250U2l6ZTogNDUsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgQWN0aW9uQnV0dG9uczoge1xuICAgICAgICB0eXBlOiBSb3csXG4gICAgICAgIHg6ICh3KSA9PiAodyAtIDI0MCkgLyAyLFxuICAgICAgICB5OiAoaCkgPT4gaCAtIDEwMCxcbiAgICAgICAgaXRlbVNwYWNpbmc6IDQwLFxuICAgICAgICBpdGVtczogW1xuICAgICAgICAgIHtcbiAgICAgICAgICAgIHJlZjogJ0dyYW50QnV0dG9uJyxcbiAgICAgICAgICAgIG1pbldpZHRoOiAxMDAsXG4gICAgICAgICAgICB0eXBlOiBCdXR0b24sXG4gICAgICAgICAgICB0aXRsZTogJ1llcycsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kVHlwZTogJ3N0cm9rZScsXG4gICAgICAgICAgICBvbkVudGVyUmVsZWFzZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoJyRncmFudCcpO1xuICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoJyRkaXNtaXNzT3ZlcmxheScpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9LFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIHJlZjogJ0RlbnlCdXR0b24nLFxuICAgICAgICAgICAgbWluV2lkdGg6IDEwMCxcbiAgICAgICAgICAgIHR5cGU6IEJ1dHRvbixcbiAgICAgICAgICAgIHRpdGxlOiAnTm8nLFxuICAgICAgICAgICAgYmFja2dyb3VuZFR5cGU6ICdzdHJva2UnLFxuICAgICAgICAgICAgb25FbnRlclJlbGVhc2U6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgdGhpcy5maXJlQW5jZXN0b3JzKCckZGVueScpO1xuICAgICAgICAgICAgICB0aGlzLmZpcmVBbmNlc3RvcnMoJyRkaXNtaXNzT3ZlcmxheScpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9LFxuICAgICAgICBdLFxuICAgICAgfSxcbiAgICB9O1xuICB9XG5cbiAgJGdyYW50KCkge1xuICAgIGlmICh0aGlzLl9wYXJhbXMuZ3JhbnRDYWxsYmFjaykge1xuICAgICAgdGhpcy5fcGFyYW1zLmdyYW50Q2FsbGJhY2soKTtcbiAgICB9XG4gIH1cblxuICAkZGVueSgpIHtcbiAgICBpZiAodGhpcy5fcGFyYW1zLmRlbnlDYWxsYmFjaykge1xuICAgICAgdGhpcy5fcGFyYW1zLmRlbnlDYWxsYmFjaygpO1xuICAg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ICAgICAgICAgbGFiZWw6ICcnLFxuICAgICAgICAgICAgcmVmOiAnSW5wdXQnLFxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgdGV4dHVyZTogbG5nLlRvb2xzLmdldFJvdW5kUmVjdCg4NjAsIDQwMCwgMTYsIDAsIDAsIHRydWUsIDB4ZmYxNDE0MTcpLFxuICAgICAgICAgICAgS2V5Ym9hcmQ6IHtcbiAgICAgICAgICAgICAgeDogMTYsXG4gICAgICAgICAgICAgIHk6IDI0LFxuICAgICAgICAgICAgICB3OiA4MjgsXG4gICAgICAgICAgICAgIHR5cGU6IEtleWJvYXJkUXdlcnR5LFxuICAgICAgICAgICAgICBkZWZhdWx0Rm9ybWF0OiAnbG93ZXJjYXNlJyxcbiAgICAgICAgICAgICAgcmVmOiAnS2V5Ym9hcmQnLFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9LFxuICAgICAgICBdLFxuICAgICAgICBzZWxlY3RlZEluZGV4OiAxLFxuICAgICAgfSxcbiAgICB9O1xuICB9XG5cbiAgJG9uU29mdEtleSh7IGtleSB9KSB7XG4gICAgc3dpdGNoIChrZXkpIHtcbiAgICAgIGNhc2UgJ2RlbGV0ZSc6XG4gICAgICAgIHRoaXMuX0lucHV0LmJhY2tzcGFjZSgpO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgJ2RvbmUnOlxuICAgICAgICB0aGlzLmRvbmVQZW5kaW5nID0gdHJ1ZTtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlICdzcGFjZSc6XG4gICAgICAgIHRoaXMuX0lucHV0Lmluc2VydCgnICcpO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgJ2NsZWFyJzpcbiAgICAgICAgdGhpcy5fSW5wdXQuY2xlYXIoKTtcbiAgICAgICAgYnJlYWs7XG4gICAgICBjYXNlICdzaGlmdCc6XG4gICAgICBjYXNlICcmMTIzJzpcbiAgICAgIGNhc2UgJ2FiYyc6XG4gICAgICB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KHtcbiAgICAgICAgICBncmFudGVkOiBudWxsLFxuICAgICAgICAgIHJlYXNvbjogUGluQ2hhbGxlbmdlLlJlc3VsdFJlYXNvbi5DQU5DRUxMRUQsXG4gICAgICAgIH0pO1xuICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgfSwgMTUwMDApO1xuXG4gICAgICBjb25zdCBzZWxmID0gdGhpcztcbiAgICAgIGxldCBwcm9tcHQgPSBudWxsO1xuICAgICAgdGhpcy5fYXBwLm92ZXJsYXllZCA9IHRydWU7XG4gICAgICB0aGlzLl9hcHAudGFnKCdPdmVybGF5cycpLmFscGhhID0gMTtcbiAgICAgIHRoaXMuX2FwcC50YWcoJ092ZXJsYXlzJykucGF0Y2goe1xuICAgICAgICBPdmVybGF5OiB7XG4gICAgICAgICAgdHlwZTogUGluUHJvbXB0LFxuICAgICAgICAgIHBhcmFtczoge1xuICAgICAgICAgICAgaGVhZGVyOiBjaGFsbGVuZ2UucmVxdWVzdG9yLm5hbWUgKyAnIGlzIHJlcXVlc3RpbmcgdGhhdCB5b3UgZW50ZXIgeW91ciAnICsgY2hhbGxlbmdlLnBpblNwYWNlICsgJyBwaW4uJyxcbiAgICAgICAgICAgIGRldGFpbDogJyAnLFxuICAgICAgICAgICAgbGlzdGVuZXI6IG5ldyAoY2xhc3MgZXh0ZW5kcyBQaW5Qcm9tcHQuUGluUHJvbXB0TGlzdGVuZXIge1xuICAgICAgICAgICAgICBvblBpbkVudGVyZWQocGluKSB7XG4gICAgICAgICAgICAgICAgaWYgKHBpbiA9PT0gQ09OU1RBTlRTLlBJTlNbY2hhbGxlbmdlLnBpblNwYWNlXSkge1xuICAgICAgICAgICAgICAgICAgcmVzcG9uZGVyKHtcbiAgICAgICAgICAgICAgICAgICAgZ3JhbnRlZDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgcmVhc29uOiBQaW5DaGFsbGVuZ2UuUmVzdWx0UmVhc29uLkNPUlJFQ1RfUElOLFxuICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgICAgICAgIHByb21wdC5maXJlQW5jZXN0b3JzKCckZGlzbWlzc092ZXJsYXknKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgc2VsZi5udW1GYWlsdXJlcysrO1xuICAgICAgICAgICAgICAgICAgaWYgKHNlbGYubnVtRmFpbHVyZXMgPj0gQ09OU1RBTlRTLk1BWF9GQUlMVVJFUykge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmxvY2tlZFRpbWUgPSBEYXRlLm5vdygpO1xuICAgICAgICAgICAgICAgICAgICByZXNwb25kZXIoe1xuICAgICAgICAgICAgICAgICAgICAgIGdyYW50ZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogUGluQ2hhbGxlbmdlLlJlc3VsdFJlYXNvbi5FWENFRURFRF9QSU5fRkFJTFVSRVMsXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICBwcm9tcHQuZmlyZUFuY2VzdG9ycygnJGRpc21pc3NPdmVybGF5Jyk7XG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBzaG93IGFnYWluXG4gICAgICAgICAgICAgICAgICAgIHByb21wdC5wYXJhbXMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiAnVGhhdCB3YXMgd3JvbmcsIHRyeSBhZ2Fpbi4nLFxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBvbkRpc21pc3NSZXF1ZXN0ZWQoKSB7XG4gICAgICAgICAgICAgICAgcmVzcG9uZGVyKHtcbiAgICAgICAgICAgICAgICAgIGdyYW50ZWQ6IG51bGwsXG4gICAgICAgICAgICAgICAgICByZWFzb246IFBpbkNoYWxsZW5nZS5SZXN1bHRSZWFzb24uQ0FOQ0VMTEVELFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lcik7XG4gICAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgICAgICBwcm9tcHQuZmlyZUFuY2VzdG9ycygnJGRpc21pc3NPdmVybGF5Jyk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgb25Mb2FkZWQodmlldykge1xuICAgICAgICAgICAgICAgIHByb21wdCA9IHZpZXc7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pKCksXG4gICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgIH0pO1xuICAgIH0pO1xuICAgIHRoaXMuX2FwcC5fcmVmb2N1cygpO1xuICB9XG59XG4iLCIvKipcbiAqIENvcHlyaWdodCAyMDIzIENvbWNhc3QgQ2FibGUgQ29tbXVuaWNhdGlvbnMgTWFuYWdlbWVudCwgTExDXG4gKlxuICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlIFwiTGljZW5zZVwiKTtcbiAqIHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2Ugd2l0aCB0aGUgTGljZW5zZS5cbiAqIFlvdSBtYXkgb2J0YWluIGEgY29weSBvZiB0aGUgTGljZW5zZSBhdFxuICpcbiAqIGh0dHA6Ly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GVyIHlvdXIgJyArIGNoYWxsZW5nZS5waW5TcGFjZSArICcgcGluLicsXG4gICAgICAgICAgZGV0YWlsOiAnICcsXG4gICAgICAgICAgbGlzdGVuZXI6IG5ldyAoY2xhc3MgZXh0ZW5kcyBQaW5Qcm9tcHQuUGluUHJvbXB0TGlzdGVuZXIge1xuICAgICAgICAgICAgb25QaW5FbnRlcmVkKHBpbikge1xuICAgICAgICAgICAgICBhZnRlclBpbkVudGVyZWQocGluLCByZXNwb25kZXIsIGNoYWxsZW5nZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBvbkRpc21pc3NSZXF1ZXN0ZWQoKSB7XG4gICAgICAgICAgICAgIGRpc21pc3NQaW5PdmVybGF5KHJlc3BvbmRlcik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBvbkxvYWRlZCh2aWV3KSB7XG4gICAgICAgICAgICAgIHByb21wdCA9IHZpZXc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSkoKSxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgfSk7XG4gICAgdGhpcy5fYXBwLl9yZWZvY3VzKCk7XG4gIH1cblxuICBhZnRlclBpbkVudGVyZWQocGluLCByZXNwb25kZXIsIGNoYWxsZW5nZSkge1xuICAgIG5ldyBQcm9taXNlKGFzeW5jIChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIGNvbnN0IHRpbWVyID0gc2V0VGltZW91dCgoKSA9PiB7XG4gICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgZ3JhbnRlZDogbnVsbCxcbiAgICAgICAgICByZWFzb246IFBpbkNoYWxsZW5nZS5SZXN1bHRSZWFzb24uQ0FOQ0VMTEVELFxuICAgICAgICB9KTtcbiAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgIH0sIDUwMDApO1xuICAgICAgaWYgKHBpbikge1xuICAgICAgICBpZiAocGluID09PSBDT05TVEFOVFMuUElOUy5wdXJjaGFzZSkge1xuICAgICAgICAgIC8vIENoZWNrIHdoZXRoZXIgY2hhbGxlbmdlLnBpbnNwYWNlIGlzIGZldGVjaGluZyB0aGUgcGluICcxMTExJ1xuICAgICAgICAgIHJlc3BvbmRlcih7XG4gICAgICAgICAgICBncmFudGVkOiB0cnVlLFxuICAgICAgICAgICAgcmVhc29uOiBQaW5DaGFsbGVuZ2UuUmVzdWx0UmVhc29uLkNPUlJFQ1RfUElOLFxuICAgICAgICAgIH0pO1xuICAgICAgICAgIC8vIHByb21wdC5maXJlQW5jZXN0b3JzKCckZGlzbWlzc092ZXJsYXknKVxuICAgICAgICAgIHRoaXMuX2FwcC4kZGlzbWlzc092ZXJsYXkoKTtcbiAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgIHJlc29sdmUodHJ1ZSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgZm9yIChsZXQgbnVtT2ZGYWlsdXJlcyA9IDE7IG51bU9mRmFpbHVyZXMgPD0gcHJvY2Vzcy5lbnYubWF4QXR0ZW1wdHM7IG51bU9mRmFpbHVyZXMrKykge1xuICAgICAgICAgICAgaWYgKG51bU9mRmFpbHVyZXMgPT0gcHJvY2Vzcy5lbnYubWF4QXR0ZW1wdHMpIHtcbiAgICAgICAgICAgICAgdGhpcy5fYXBwLiRkaXNtaXNzT3ZlcmxheSgpO1xuICAgICAgICAgICAgICByZXNwb25kZXIoe1xuICAgICAgICAgICAgICAgIGdyYW50ZWQ6IGZhbHNlLFxuICAgICAgICAgICAgICAgIHJlYXNvbjogUGluQ2hhbGxlbmdlLlJlc3VsdFJlYXNvbi5FWENFRURFRF9QSU5fRkFJTFVSRVMsXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpO1xuICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0pO1xuICB9XG5cbi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TAuNCxcbiAgICAgICAgICAgIGxpbmVIZWlnaHQ6IDY0LFxuICAgICAgICAgICAgdmVydGljYWxBbGlnbjogJ21pZGRsZScsXG4gICAgICAgICAgfSxcbiAgICAgICAgICB0ZXh0Q29sb3I6ICcjNDA3Njg2MzQ4NycsXG4gICAgICAgICAgdGV4dEFsaWduOiAnY2VudGVyJyxcbiAgICAgICAgfSxcbiAgICAgIH0sXG4gICAgICBEZXRhaWw6IHtcbiAgICAgICAgeDogMCxcbiAgICAgICAgeTogQk9EWV9ZLFxuICAgICAgICB3OiBTQ1JFRU4udyxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIC4uLntcbiAgICAgICAgICAgIGZvbnRGYWNlOiAnWGZpbml0eVN0YW5kYXJkTWVkaXVtJyxcbiAgICAgICAgICAgIGZvbnRTaXplOiAzMixcbiAgICAgICAgICAgIGZvbnRXZWlnaHQ6IDUwMCxcbiAgICAgICAgICAgIGxldHRlclNwYWNpbmc6IDAsXG4gICAgICAgICAgICBsaW5lSGVpZ2h0OiA0MCxcbiAgICAgICAgICAgIHZlcnRpY2FsQWxpZ246ICdtaWRkbGUnLFxuICAgICAgICAgIH0sXG4gICAgICAgICAgdGV4dENvbG9yOiAnIzM0MzkzMjkyNzknLFxuICAgICAgICAgIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gICAgICAgIH0sXG4gICAgICB9LFxuICAgICAgUGluRGlzcGxheToge1xuICAgICAgICB4OiAwLFxuICAgICAgICB5OiBQSU5fRElTUExBWV9ZLFxuICAgICAgICB3OiBTQ1JFRU4udyxcbiAgICAgICAgdGV4dDoge1xuICAgICAgICAgIC4uLntcbiAgICAgICAgICAgIGZvbnRGYWNlOiAnWGZpbml0eUJyb3duQm9sZCcsXG4gICAgICAgICAgICBmb250U2l6ZTogNTYsXG4gICAgICAgICAgICBmb250V2VpZ2h0OiA3MDAsXG4gICAgICAgICAgICBsZXR0ZXJTcGFjaW5nOiAtMC40LFxuICAgICAgICAgICAgbGluZUhla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KSB7XG4gICAgICAgICAgY29uc3QgYnVmZmVyT2JqID0gQnVmZmVyLmZyb20ocmVzdWx0LnZhbHVlLCAnYmFzZTY0Jyk7XG4gICAgICAgICAgY29uc3QgeG1sRGF0YSA9IGJ1ZmZlck9iai50b1N0cmluZygndXRmOCcpO1xuICAgICAgICAgIGF3YWl0IG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgICAgICAgIHBhcnNlci5wYXJzZVN0cmluZyh4bWxEYXRhLCBmdW5jdGlvbiAoZXJyLCByZXN1bHQpIHtcbiAgICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHBhcnNpbmdTdWNjZXNzZnVsID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgcmVzb2x2ZSgpO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnN0IHJlcyA9IHJlc3VsdFsnbnMyOnhjYWwtYXV0aC1tZXNzYWdlJ11bJ2F0dHJpYnV0ZSddO1xuICAgICAgICAgICAgICAgIHBhcnNpbmdTdWNjZXNzZnVsID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlc0l0ZW0gb2YgcmVzKSB7XG4gICAgICAgICAgICAgICAgICBpZiAocmVzSXRlbS4kLmtleSA9PT0gJ2RldmljZTpjY3BQa2k6ZXN0Yk1hYycpIHtcbiAgICAgICAgICAgICAgICAgICAgbG9nZ2VyLmluZm8ocmVzSXRlbS5fLCAncHVzaFJlcG9ydFRvUzMnKTtcbiAgICAgICAgICAgICAgICAgICAgbWFjQWRkcmVzcyA9IHJlc0l0ZW0uXztcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmVzb2x2ZSgpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAg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ZXJyb3IpLCAnb3ZlcnJpZGVQYXJhbXMnKTtcbiAgfVxufVxuXG5leHBvcnQge1xuICBoYW5kbGVBc3luY0Z1bmN0aW9uLFxuICBjaGVja01vY2tPU1Jlc3RJbnRlcmZhY2UsXG4gIFRSVUVfVkFMVUVTLFxuICBkZXJlZmVyZW5jZU9wZW5SUEMsXG4gIGdldHNjaGVtYVZhbGlkYXRpb25Eb25lLFxuICBwdXNoUmVwb3J0VG9TMyxcbiAgdGVzdERhdGFIYW5kbGVyLFxuICBjZW5zb3JEYXRhLFxuICBmaWx0ZXJFeGFtcGxlcyxcbiAgZXJyb3JTY2hlbWFDaGVjayxcbiAgcmVtb3ZlU2V0SW5NZXRob2ROYW1lLFxuICBnZXRDdXJyZW50QXBwSUQsXG4gIGdldE1ldGhvZEV4Y2x1ZGVkTGlzdEJhc2VkT25Nb2RlLFxuICBmaW5kVHlwZUluT25lT0YsXG4gIG92ZXJyaWRlUGFyYW1zRnJvbVRlc3REYXRhLFxuICBwYXJzZVhBQ1QsXG59O1xuIiwiLyogKGlnbm9yZWQpICovIiwiLyogKGlnbm9yZWQpICovIiwiLyogKGlnbm9yZWQpICovIiwiLyogKGlnbm9yZWQpICovIiwiLyogKGlnbm9yZWQpICovIiwiLyogKGlnbm9yZWQpICovIl0sInNvdXJjZVJvb3QiOiIifQ==
\ No newline at end of file
diff --git a/PR-230/startupScripts.bundle.ae1e8dfa958062da1084.js b/PR-230/startupScripts.bundle.85da6884b014c81f1769.js
similarity index 99%
rename from PR-230/startupScripts.bundle.ae1e8dfa958062da1084.js
rename to PR-230/startupScripts.bundle.85da6884b014c81f1769.js
index ee1bed4b..0b824439 100644
--- a/PR-230/startupScripts.bundle.ae1e8dfa958062da1084.js
+++ b/PR-230/startupScripts.bundle.85da6884b014c81f1769.js
@@ -170,4 +170,4 @@ module.exports = __webpack_require__(/*! ./plugins/startupScripts/index.js */"./
/***/ })
/******/ });
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZX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