decidim-bulletin_board 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89508952fe24e1a37013a1442a4036ab031f946e0baa753f7242659174ec527c
4
- data.tar.gz: 1f5749ff18b9269d44b8e3010cac399436d76947fc994c00b458b77c15c884f0
3
+ metadata.gz: 556770adb7b217010fa4661fcffbdc73503e9d9cb2695d85cf685706c181365d
4
+ data.tar.gz: 135832d76c003aef0c3696bb92dbd9f3db3dd7f14695edfdbf812244eb30e125
5
5
  SHA512:
6
- metadata.gz: 42c3c0b98e458351cf4cf10dd0eddf75cb8dfbcdfd24090307eb6941d0517c2ef7db10996265ff033de32fa064d8595613f96c6d543296d61ccbfc32679da1f5
7
- data.tar.gz: 12578ad77bb5098b9b644f9146dee269ffb50492de881eefac26cc7a2bc9f55bf986588d184284ab54ce093fb2c69b31365417982dab829cdd61d155424f01a6
6
+ metadata.gz: 33a668e3690302d876867326e4153c3b9959245053b20a7542db157550a4d75b4ee4ea0fab8eb229107b9461d6879984ccbcf28f0edd96033f9f48127b3a9fea
7
+ data.tar.gz: 5b0a284e352328e3f3b1fb0d3a5c593950e881c5b38bf70fc67f38bb642f25a5fc7c8714f14d12ab8e1ed66e77f0d12dfda8b1411a61f7ef3fcf4cbc19eb33a4
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## [0.8.0] - 2021-01-27
11
+
12
+ ## Changed
13
+
14
+ - `getPendingMessage` can get queried by `messageId` and by `id`.
15
+ - `get_status` renamed to `get_election_status` in the `Decidim::BulletinBoard::Client`.
16
+
17
+ ## Added
18
+
19
+ - `getPendingMessageStatus` method to the `Decidim::BulletinBoard::Client`.
20
+ - `waitForPendingMessageToBeProcessed` method to the Voter class.
21
+ - The `KeyCeremonyComponent` has been added. It will be used as a glue code between the key ceremony process and the UI.
22
+
10
23
  ## [0.7.0] - 2021-01-26
11
24
 
12
25
  ## Changed
@@ -21,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
34
  - `start_tally` method to the `Decidim::BulletinBoard::Client`.
22
35
  - `publish_results` method to the `Decidim::BulletinBoard::Client`.
23
36
  - `Election` class in the JS package to handle the election state. An instance of this class will be used by the key ceremony and the trustee to check anything related to log entries.
24
- - The `Trustee` class now have a `teardown` method that is called automatically to clean a few things. It can be called early to avoid memory leaks if needed.
37
+ - The `Trustee` class now has a `teardown` method that is called automatically to clean a few things. It can be called early to avoid memory leaks if needed.
25
38
  - The `EventManager` class now handles the `events` stream and exports some useful constants.
26
39
 
27
40
  ## Removed
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- decidim-bulletin_board (0.7.0)
4
+ decidim-bulletin_board (0.8.0)
5
5
  byebug (~> 11.0)
6
6
  graphlient (~> 0.4.0)
7
7
  jwt (~> 2.2.2)
@@ -7886,6 +7886,141 @@ module.exports = function (data, opts) {
7886
7886
 
7887
7887
 
7888
7888
 
7889
+ /***/ }),
7890
+
7891
+ /***/ "./src/client/operations/get_pending_message_by_message_id.gql":
7892
+ /*!*********************************************************************!*\
7893
+ !*** ./src/client/operations/get_pending_message_by_message_id.gql ***!
7894
+ \*********************************************************************/
7895
+ /*! unknown exports (runtime-defined) */
7896
+ /*! runtime requirements: module */
7897
+ /*! CommonJS bailout: module.exports is used directly at 119:4-18 */
7898
+ /***/ ((module) => {
7899
+
7900
+
7901
+ var doc = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPendingMessageByMessageId"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"messageId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},"directives":[]}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"pendingMessage"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"messageId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"messageId"}}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"status"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":117}};
7902
+ doc.loc.source = {"body":"query GetPendingMessageByMessageId($messageId: String!) {\n pendingMessage(messageId: $messageId) {\n status\n }\n}\n","name":"GraphQL request","locationOffset":{"line":1,"column":1}};
7903
+
7904
+
7905
+ var names = {};
7906
+ function unique(defs) {
7907
+ return defs.filter(
7908
+ function(def) {
7909
+ if (def.kind !== 'FragmentDefinition') return true;
7910
+ var name = def.name.value
7911
+ if (names[name]) {
7912
+ return false;
7913
+ } else {
7914
+ names[name] = true;
7915
+ return true;
7916
+ }
7917
+ }
7918
+ )
7919
+ }
7920
+
7921
+
7922
+ // Collect any fragment/type references from a node, adding them to the refs Set
7923
+ function collectFragmentReferences(node, refs) {
7924
+ if (node.kind === "FragmentSpread") {
7925
+ refs.add(node.name.value);
7926
+ } else if (node.kind === "VariableDefinition") {
7927
+ var type = node.type;
7928
+ if (type.kind === "NamedType") {
7929
+ refs.add(type.name.value);
7930
+ }
7931
+ }
7932
+
7933
+ if (node.selectionSet) {
7934
+ node.selectionSet.selections.forEach(function(selection) {
7935
+ collectFragmentReferences(selection, refs);
7936
+ });
7937
+ }
7938
+
7939
+ if (node.variableDefinitions) {
7940
+ node.variableDefinitions.forEach(function(def) {
7941
+ collectFragmentReferences(def, refs);
7942
+ });
7943
+ }
7944
+
7945
+ if (node.definitions) {
7946
+ node.definitions.forEach(function(def) {
7947
+ collectFragmentReferences(def, refs);
7948
+ });
7949
+ }
7950
+ }
7951
+
7952
+ var definitionRefs = {};
7953
+ (function extractReferences() {
7954
+ doc.definitions.forEach(function(def) {
7955
+ if (def.name) {
7956
+ var refs = new Set();
7957
+ collectFragmentReferences(def, refs);
7958
+ definitionRefs[def.name.value] = refs;
7959
+ }
7960
+ });
7961
+ })();
7962
+
7963
+ function findOperation(doc, name) {
7964
+ for (var i = 0; i < doc.definitions.length; i++) {
7965
+ var element = doc.definitions[i];
7966
+ if (element.name && element.name.value == name) {
7967
+ return element;
7968
+ }
7969
+ }
7970
+ }
7971
+
7972
+ function oneQuery(doc, operationName) {
7973
+ // Copy the DocumentNode, but clear out the definitions
7974
+ var newDoc = {
7975
+ kind: doc.kind,
7976
+ definitions: [findOperation(doc, operationName)]
7977
+ };
7978
+ if (doc.hasOwnProperty("loc")) {
7979
+ newDoc.loc = doc.loc;
7980
+ }
7981
+
7982
+ // Now, for the operation we're running, find any fragments referenced by
7983
+ // it or the fragments it references
7984
+ var opRefs = definitionRefs[operationName] || new Set();
7985
+ var allRefs = new Set();
7986
+ var newRefs = new Set();
7987
+
7988
+ // IE 11 doesn't support "new Set(iterable)", so we add the members of opRefs to newRefs one by one
7989
+ opRefs.forEach(function(refName) {
7990
+ newRefs.add(refName);
7991
+ });
7992
+
7993
+ while (newRefs.size > 0) {
7994
+ var prevRefs = newRefs;
7995
+ newRefs = new Set();
7996
+
7997
+ prevRefs.forEach(function(refName) {
7998
+ if (!allRefs.has(refName)) {
7999
+ allRefs.add(refName);
8000
+ var childRefs = definitionRefs[refName] || new Set();
8001
+ childRefs.forEach(function(childRef) {
8002
+ newRefs.add(childRef);
8003
+ });
8004
+ }
8005
+ });
8006
+ }
8007
+
8008
+ allRefs.forEach(function(refName) {
8009
+ var op = findOperation(doc, refName);
8010
+ if (op) {
8011
+ newDoc.definitions.push(op);
8012
+ }
8013
+ });
8014
+
8015
+ return newDoc;
8016
+ }
8017
+
8018
+ module.exports = doc;
8019
+
8020
+ module.exports.GetPendingMessageByMessageId = oneQuery(doc, "GetPendingMessageByMessageId");
8021
+
8022
+
8023
+
7889
8024
  /***/ }),
7890
8025
 
7891
8026
  /***/ "./src/client/operations/process_key_ceremony_step.gql":
@@ -16463,6 +16598,18 @@ class Client {
16463
16598
  processTallyStep(params) {
16464
16599
  return this.apiClient.processTallyStep(params);
16465
16600
  }
16601
+
16602
+ /**
16603
+ * Query PendingMessages for a given messageId
16604
+ *
16605
+ * @param {Object} params - An object that include the following options.
16606
+ * - {String} messageId - The messageId
16607
+ * @returns {Promise<Object>} - The pending message received.
16608
+ * @throws Will throw an error if the request is rejected.
16609
+ */
16610
+ getPendingMessageByMessageId({ messageId }) {
16611
+ return this.apiClient.getPendingMessageByMessageId({ messageId });
16612
+ }
16466
16613
  }
16467
16614
 
16468
16615
 
@@ -16492,6 +16639,8 @@ __webpack_require__.r(__webpack_exports__);
16492
16639
  /* harmony import */ var _operations_process_tally_step__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_operations_process_tally_step__WEBPACK_IMPORTED_MODULE_3__);
16493
16640
  /* harmony import */ var _operations_get_log_entry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./operations/get_log_entry */ "./src/client/operations/get_log_entry.gql");
16494
16641
  /* harmony import */ var _operations_get_log_entry__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_operations_get_log_entry__WEBPACK_IMPORTED_MODULE_4__);
16642
+ /* harmony import */ var _operations_get_pending_message_by_message_id__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./operations/get_pending_message_by_message_id */ "./src/client/operations/get_pending_message_by_message_id.gql");
16643
+ /* harmony import */ var _operations_get_pending_message_by_message_id__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_operations_get_pending_message_by_message_id__WEBPACK_IMPORTED_MODULE_5__);
16495
16644
  ;
16496
16645
 
16497
16646
 
@@ -16499,6 +16648,7 @@ __webpack_require__.r(__webpack_exports__);
16499
16648
 
16500
16649
 
16501
16650
 
16651
+
16502
16652
  /**
16503
16653
  * This is the Bulletin Board API client that will use Apollo's client to
16504
16654
  * interact with our GraphQL schema using both http and websocket connections.
@@ -16543,7 +16693,6 @@ class GraphQLClient {
16543
16693
  contentHash,
16544
16694
  },
16545
16695
  });
16546
-
16547
16696
  return result.data.logEntry;
16548
16697
  }
16549
16698
 
@@ -16594,6 +16743,25 @@ class GraphQLClient {
16594
16743
  return result.data.processKeyCeremonyStep.pendingMessage;
16595
16744
  }
16596
16745
 
16746
+ /**
16747
+ * Query PendingMessages for a given messageId
16748
+ *
16749
+ * @param {Object} params - An object that include the following options.
16750
+ * - {String} messageId - The messageId
16751
+ * @returns {Promise<Object>} - The pending message received.
16752
+ * @throws Will throw an error if the request is rejected.
16753
+ */
16754
+ async getPendingMessageByMessageId({ messageId }) {
16755
+ const result = await this.apolloClient.query({
16756
+ query: (_operations_get_pending_message_by_message_id__WEBPACK_IMPORTED_MODULE_5___default()),
16757
+ variables: {
16758
+ messageId,
16759
+ },
16760
+ });
16761
+
16762
+ return result.data.pendingMessage;
16763
+ }
16764
+
16597
16765
  /**
16598
16766
  * Process a tally step sending a signed message.
16599
16767
  *
@@ -16828,6 +16996,7 @@ class Election {
16828
16996
  /*! namespace exports */
16829
16997
  /*! export Client [provided] [maybe used in main (runtime-defined)] [usage prevents renaming] -> ./src/client/client.js .Client */
16830
16998
  /*! export Election [provided] [maybe used in main (runtime-defined)] [usage prevents renaming] -> ./src/election/election.js .Election */
16999
+ /*! export KeyCeremonyComponent [provided] [maybe used in main (runtime-defined)] [usage prevents renaming] -> ./src/key-ceremony/key-ceremony.component.js .KeyCeremonyComponent */
16831
17000
  /*! export MESSAGE_PROCESSED [provided] [maybe used in main (runtime-defined)] [usage prevents renaming] -> ./src/trustee/event_manager.js .MESSAGE_PROCESSED */
16832
17001
  /*! export MESSAGE_RECEIVED [provided] [maybe used in main (runtime-defined)] [usage prevents renaming] -> ./src/trustee/event_manager.js .MESSAGE_RECEIVED */
16833
17002
  /*! export MessageIdentifier [provided] [maybe used in main (runtime-defined)] [usage prevents renaming] -> ./src/client/message-identifier.js .MessageIdentifier */
@@ -16846,7 +17015,8 @@ __webpack_require__.r(__webpack_exports__);
16846
17015
  /* harmony export */ "Voter": () => /* reexport safe */ _voter_voter__WEBPACK_IMPORTED_MODULE_3__.Voter,
16847
17016
  /* harmony export */ "MessageIdentifier": () => /* reexport safe */ _client_message_identifier__WEBPACK_IMPORTED_MODULE_4__.MessageIdentifier,
16848
17017
  /* harmony export */ "MESSAGE_PROCESSED": () => /* reexport safe */ _trustee_event_manager__WEBPACK_IMPORTED_MODULE_5__.MESSAGE_PROCESSED,
16849
- /* harmony export */ "MESSAGE_RECEIVED": () => /* reexport safe */ _trustee_event_manager__WEBPACK_IMPORTED_MODULE_5__.MESSAGE_RECEIVED
17018
+ /* harmony export */ "MESSAGE_RECEIVED": () => /* reexport safe */ _trustee_event_manager__WEBPACK_IMPORTED_MODULE_5__.MESSAGE_RECEIVED,
17019
+ /* harmony export */ "KeyCeremonyComponent": () => /* reexport safe */ _key_ceremony_key_ceremony_component__WEBPACK_IMPORTED_MODULE_6__.KeyCeremonyComponent
16850
17020
  /* harmony export */ });
16851
17021
  /* harmony import */ var _client_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./client/client */ "./src/client/client.js");
16852
17022
  /* harmony import */ var _election_election__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./election/election */ "./src/election/election.js");
@@ -16854,6 +17024,7 @@ __webpack_require__.r(__webpack_exports__);
16854
17024
  /* harmony import */ var _voter_voter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./voter/voter */ "./src/voter/voter.js");
16855
17025
  /* harmony import */ var _client_message_identifier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./client/message-identifier */ "./src/client/message-identifier.js");
16856
17026
  /* harmony import */ var _trustee_event_manager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./trustee/event_manager */ "./src/trustee/event_manager.js");
17027
+ /* harmony import */ var _key_ceremony_key_ceremony_component__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./key-ceremony/key-ceremony.component */ "./src/key-ceremony/key-ceremony.component.js");
16857
17028
  ;
16858
17029
 
16859
17030
 
@@ -16865,6 +17036,147 @@ __webpack_require__.r(__webpack_exports__);
16865
17036
 
16866
17037
 
16867
17038
 
17039
+ /***/ }),
17040
+
17041
+ /***/ "./src/key-ceremony/key-ceremony.component.js":
17042
+ /*!****************************************************!*\
17043
+ !*** ./src/key-ceremony/key-ceremony.component.js ***!
17044
+ \****************************************************/
17045
+ /*! namespace exports */
17046
+ /*! export KeyCeremonyComponent [provided] [no usage info] [missing usage info prevents renaming] */
17047
+ /*! other exports [not provided] [no usage info] */
17048
+ /*! runtime requirements: __webpack_require__, __webpack_require__.r, __webpack_exports__, __webpack_require__.d, __webpack_require__.* */
17049
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
17050
+
17051
+ "use strict";
17052
+ __webpack_require__.r(__webpack_exports__);
17053
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
17054
+ /* harmony export */ "KeyCeremonyComponent": () => /* binding */ KeyCeremonyComponent
17055
+ /* harmony export */ });
17056
+ /* harmony import */ var _client_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/client */ "./src/client/client.js");
17057
+ /* harmony import */ var _election_election__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../election/election */ "./src/election/election.js");
17058
+ /* harmony import */ var _trustee_trustee__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../trustee/trustee */ "./src/trustee/trustee.js");
17059
+ ;
17060
+
17061
+
17062
+
17063
+ /**
17064
+ * This class is used to bind any UI elements to a key ceremony process.
17065
+ */
17066
+ class KeyCeremonyComponent {
17067
+ /**
17068
+ * Initialises the class with the given params.
17069
+ * @param {Object} params - An object that contains the initialization params.
17070
+ * - {Object} bulletinBoardClientParams - An object to configure the bulletin board client.
17071
+ * - {String} electionUniqueId - The unique identifier of an election.
17072
+ * - {String} trusteeUniqueId - The unique identifier of a trustee.
17073
+ * - {Object} trusteeIdentificationKeys - An object that contains both the public and private key for
17074
+ * the corresponding trustee.
17075
+ * @constructor
17076
+ */
17077
+ constructor({
17078
+ bulletinBoardClientParams,
17079
+ electionUniqueId,
17080
+ trusteeUniqueId,
17081
+ trusteeIdentificationKeys,
17082
+ }) {
17083
+ const bulletinBoardClient = new _client_client__WEBPACK_IMPORTED_MODULE_0__.Client(bulletinBoardClientParams);
17084
+
17085
+ this.election = new _election_election__WEBPACK_IMPORTED_MODULE_1__.Election({
17086
+ uniqueId: electionUniqueId,
17087
+ bulletinBoardClient,
17088
+ });
17089
+
17090
+ this.trustee = new _trustee_trustee__WEBPACK_IMPORTED_MODULE_2__.Trustee({
17091
+ uniqueId: trusteeUniqueId,
17092
+ bulletinBoardClient,
17093
+ identificationKeys: trusteeIdentificationKeys,
17094
+ election: this.election,
17095
+ });
17096
+ }
17097
+
17098
+ /**
17099
+ * Bind UI events to the key ceremony process.
17100
+ *
17101
+ * @method bindEvents
17102
+ * @param {Object} eventCallbacks - An object that contains event callback functions.
17103
+ * - {Function} onSetup - a function that is called when the trustee is set up.
17104
+ * - {Function} onEvent - a function that is called when an event is emitted from the trustee.
17105
+ * - {Function} onBindRestoreButton - a function that receives a callback function that will be called when
17106
+ * the restore process must be started.
17107
+ * - {Function} onBindStartButton - a function that receives a callback function that will be called when
17108
+ * the key ceremony must be started.
17109
+ * - {Function} onRestore - a function that is called when the trustee is restored.
17110
+ * - {Function} onComplete - a function that is called when the key ceremony is done.
17111
+ * - {Function} onStart - a function that is called when the key ceremony has started.
17112
+ * - {Function} onTrusteeNeedsToBeRestored - a function that is called when the trustee must be restored.
17113
+ * - {Function} onBackupNeeded - a function that is called when the trustee backup is required.
17114
+ * - {Function} onBindBackupButton - a function that receives a callback function that will be called when
17115
+ * the trustee backup must be started.
17116
+ * - {Function} onBackupStarted - a function that is called when the backup has started.
17117
+ *
17118
+ * @returns {Promise<undefined>}
17119
+ */
17120
+ async bindEvents({
17121
+ onSetup,
17122
+ onEvent,
17123
+ onBindRestoreButton,
17124
+ onBindStartButton,
17125
+ onRestore,
17126
+ onComplete,
17127
+ onStart,
17128
+ onTrusteeNeedsToBeRestored,
17129
+ onBackupNeeded,
17130
+ onBindBackupButton,
17131
+ onBackupStarted,
17132
+ }) {
17133
+ this.trustee.events.subscribe(onEvent);
17134
+
17135
+ onBindRestoreButton((event) => {
17136
+ const file = event.target.files[0];
17137
+ const reader = new FileReader();
17138
+ reader.onload = async ({ target }) => {
17139
+ const content = target.result;
17140
+ if (this.trustee.restore(content)) {
17141
+ onRestore();
17142
+ await this.trustee.runKeyCeremony();
17143
+ onComplete();
17144
+ }
17145
+ };
17146
+ reader.readAsText(file);
17147
+ });
17148
+
17149
+ onBindStartButton(async (event) => {
17150
+ event.preventDefault();
17151
+
17152
+ onStart();
17153
+
17154
+ if (this.trustee.needsToBeRestored()) {
17155
+ onTrusteeNeedsToBeRestored();
17156
+ } else {
17157
+ const keyCeremonySetup = this.trustee.setupKeyCeremony();
17158
+ const { value: backupData } = await keyCeremonySetup.next();
17159
+
17160
+ onBackupNeeded();
17161
+ onBindBackupButton(
17162
+ backupData,
17163
+ `${this.trustee.uniqueId}-election-${this.election.uniqueId}.bak`,
17164
+ async () => {
17165
+ onBackupStarted();
17166
+ await keyCeremonySetup.next();
17167
+ await this.trustee.runKeyCeremony();
17168
+ onComplete();
17169
+ }
17170
+ );
17171
+ }
17172
+ });
17173
+
17174
+ await this.trustee.setup();
17175
+ onSetup();
17176
+ }
17177
+ }
17178
+
17179
+
16868
17180
  /***/ }),
16869
17181
 
16870
17182
  /***/ "./src/trustee/event_manager.js":
@@ -17544,25 +17856,45 @@ class Voter {
17544
17856
  return this.wrapper.encrypt(data);
17545
17857
  }
17546
17858
 
17547
- async verifyVote(voteHash) {
17548
- const { id: electionUniqueId } = this.electionContext;
17549
-
17550
- return new Promise((resolve) => {
17859
+ /**
17860
+ * Confirms if a vote was processed
17861
+ *
17862
+ * @param {Object} messageId - An object that includes the following options.
17863
+ * - {String} messageId - the unique identifier of a message
17864
+ * @returns {Promise<Object>} - Returns the PendingMessage
17865
+ */
17866
+ waitForPendingMessageToBeProcessed(messageId) {
17867
+ return new Promise((resolve, reject) => {
17551
17868
  const intervalId = setInterval(() => {
17552
17869
  this.bulletinBoardClient
17553
- .getLogEntry({
17554
- electionUniqueId,
17555
- contentHash: voteHash,
17870
+ .getPendingMessageByMessageId({
17871
+ messageId,
17556
17872
  })
17557
- .then((logEntry) => {
17558
- if (logEntry) {
17873
+ .then((pendingMessage) => {
17874
+ if (pendingMessage.status !== "enqueued") {
17559
17875
  clearInterval(intervalId);
17560
- resolve();
17876
+ resolve(pendingMessage);
17561
17877
  }
17562
17878
  });
17563
17879
  }, this.options.bulletinBoardWaitTime);
17564
17880
  });
17565
17881
  }
17882
+
17883
+ /**
17884
+ * Verifies a vote
17885
+ *
17886
+ * @param {String} contentHash - An object that includes the following options.
17887
+ * - {String} contentHash - the contentHash of a vote
17888
+ * @returns {Promise<Object>} - Returns a logEntry
17889
+ */
17890
+ verifyVote(contentHash) {
17891
+ const { id: electionUniqueId } = this.electionContext;
17892
+
17893
+ return this.bulletinBoardClient.getLogEntry({
17894
+ electionUniqueId,
17895
+ contentHash,
17896
+ });
17897
+ }
17566
17898
  }
17567
17899
 
17568
17900
 
@@ -17703,4 +18035,4 @@ class VoterWrapper {
17703
18035
  /******/ return __webpack_require__("./src/index.js");
17704
18036
  /******/ })()
17705
18037
  ;
17706
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9kZWNpZGltQnVsbGV0aW5Cb2FyZC8uL25vZGVfbW9kdWxlcy9AYXBvbGxvL2NsaWVudC9jYWNoZS9jb3JlL2NhY2hlLmpzIiwid2VicGFjazovL2RlY2lkaW1CdWxsZXRpbkJvYXJkLy4vbm9kZV9tb2R1bGVzL0BhcG9sbG8vY2xpZW50L2NhY2hlL2NvcmUvdHlwZXMvQ2FjaGUuanMiLC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ICAgICAgICA/IF90aGlzLmdldChvYmplY3RPclJlZmVyZW5jZS5fX3JlZiwgc3RvcmVGaWVsZE5hbWUpXG4gICAgICAgICAgICA6IG9iamVjdE9yUmVmZXJlbmNlICYmIG9iamVjdE9yUmVmZXJlbmNlW3N0b3JlRmllbGROYW1lXSk7IH07XG4gICAgICAgIHRoaXMuY2FuUmVhZCA9IGZ1bmN0aW9uIChvYmpPclJlZikge1xuICAgICAgICAgICAgcmV0dXJuIGlzUmVmZXJlbmNlKG9iak9yUmVmKVxuICAgICAgICAgICAgICAgID8gX3RoaXMuaGFzKG9iak9yUmVmLl9fcmVmKVxuICAgICAgICAgICAgICAgIDogdHlwZW9mIG9iak9yUmVmID09PSBcIm9iamVjdFwiO1xuICAgICAgICB9O1xuICAgICAgICB0aGlzLnRvUmVmZXJlbmNlID0gZnVuY3Rpb24gKG9iak9ySWRPclJlZiwgbWVyZ2VJbnRvU3RvcmUpIHtcbiAgICAgICAgICAgIGlmICh0eXBlb2Ygb2JqT3JJZE9yUmVmID09PSBcInN0cmluZ1wiKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG1ha2VSZWZlcmVuY2Uob2JqT3JJZE9yUmVmKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpc1JlZmVyZW5jZShvYmpPcklkT3JSZWYpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iak9ySWRPclJlZjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBpZCA9IF90aGlzLnBvbGljaWVzLmlkZW50aWZ5KG9iak9ySWRPclJlZilbMF07XG4gICAgICAgICAgICBpZiAoaWQpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmVmID0gbWFrZVJlZmVyZW5jZShpZCk7XG4gICAgICAgICAgICAgICAgaWYgKG1lcmdlSW50b1N0b3JlKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLm1lcmdlKGlkLCBvYmpPcklkT3JSZWYpO1xuICAgICAgICAgIC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RpcnR5XzEgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICAgICAgICAgIGlmICghZXhpc3RpbmcpXG4gICAgICAgICAgICAgICAgICAgIGZpZWxkc1RvRGlydHlfMS5fX2V4aXN0cyA9IDE7XG4gICAgICAgICAgICAgICAgT2JqZWN0LmtleXMoaW5jb21pbmcpLmZvckVhY2goZnVuY3Rpb24gKHN0b3JlRmllbGROYW1lKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghZXhpc3RpbmcgfHwgZXhpc3Rpbmdbc3RvcmVGaWVsZE5hbWVdICE9PSBtZXJnZWRbc3RvcmVGaWVsZE5hbWVdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHNUb0RpcnR5XzFbZmllbGROYW1lRnJvbVN0b3JlTmFtZShzdG9yZUZpZWxkTmFtZSldID0gMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtZXJnZWRbc3RvcmVGaWVsZE5hbWVdID09PSB2b2lkIDAgJiYgIShfdGhpcyBpbnN0YW5jZW9mIExheWVyKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBtZXJnZWRbc3RvcmVGaWVsZE5hbWVdO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgT2JqZWN0LmtleXMoZmllbGRzVG9EaXJ0eV8xKS5mb3JFYWNoKGZ1bmN0aW9uIChmaWVsZE5hbWUpIHsgcmV0dXJuIF90aGlzLmdyb3VwLmRpcnR5KGRhdGFJZCwgZmllbGROYW1lKTsgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIEVudGl0eVN0b3JlLnByb3RvdHlwZS5tb2RpZnkgPSBmdW5jdGlvbiAoZGF0YUlkLCBmaWVsZHMpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHN0b3JlT2JqZWN0ID0gdGhpcy5sb29rdXAoZGF0YUlkKTtcbiAgICAgICAgaWYgKHN0b3JlT2JqZWN0KSB7XG4gICAgICAgICAgICB2YXIgY2hhbmdlZEZpZWxkc18xID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgICAgICAgIHZhciBuZWVkVG9NZXJnZV8xID0gZmFsc2U7XG4gICAgICAgICAgICB2YXIgYWxsRGVsZXRlZF8xID0gdHJ1ZTtcbiAgICAgICAgICAgIHZhciBzaGFyZWREZXRhaWxzXzEgPSB7XG4gICAgICAgICAgICAgICAgREVMRVRFOiBERUxFVEUsXG4gICAgICAgICAgICAgICAgSU5WQUxJREFURTogSU5WQUxJREFURSxcbiAgICAgICAgICAgICAgICBpc1JlZmVyZW5jZTogaXNSZWZlcmVuY2UsXG4gICAgICAgICAgICAgICAgdG9SZWZlcmVuY2U6IHRoaXMudG9SZWZlcmVuY2UsXG4gICAgICAgICAgICAgICAgY2FuUmVhZDogdGhpcy5jYW5SZWFkLFxuICAgICAgICAgICAgICAgIHJlYWRGaWVsZDogZnVuY3Rpb24gKGZpZWxkTmFtZU9yT3B0aW9ucywgZnJvbSkgeyByZXR1cm4gX3RoaXMucG9saWNpZXMucmVhZEZpZWxkKHR5cGVvZiBmaWVsZE5hbWVPck9wdGlvbnMgPT09IFwic3RyaW5nXCIgPyB7XG4gICAgICAgICAgICAgICAgICAgIGZpZWxkTmFtZTogZmllbGROYW1lT3JPcHRpb25zLFxuICAgICAgICAgICAgICAgICAgICBmcm9tOiBmcm9tIHx8IG1ha2VSZWZlcmVuY2UoZGF0YUlkKSxcbiAgICAgICAgICAgICAgICB9IDogZmllbGROYW1lT3JPcHRpb25zLCB7IHN0b3JlOiBfdGhpcyB9KTsgfSxcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBPYmplY3Qua2V5cyhzdG9yZU9iamVjdCkuZm9yRWFjaChmdW5jdGlvbiAoc3RvcmVGaWVsZE5hbWUpIHtcbiAgICAgICAgICAgICAgICB2YXIgZmllbGROYW1lID0gZmllbGROYW1lRnJvbVN0b3JlTmFtZShzdG9yZUZpZWxkTmFtZSk7XG4gICAgICAgICAgICAgICAgdmFyIGZpZWxkVmFsdWUgPSBzdG9yZU9iamVjdFtzdG9yZUZpZWxkTmFtZV07XG4gICAgICAgICAgICAgICAgaWYgKGZpZWxkVmFsdWUgPT09IHZvaWQgMClcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIHZhciBtb2RpZnkgPSB0eXBlb2YgZmllbGRzID09PSBcImZ1bmN0aW9uXCJcbiAgICAgICAgICAgICAgICAgICAgPyBmaWVsZHNcbiAgICAgICAgICAgICAgICAgICAgOiBmaWVsZHNbc3RvcmVGaWVsZE5hbWVdIHx8IGZpZWxkc1tmaWVsZE5hbWVdO1xuICAgICAgICAgICAgICAgIGlmIChtb2RpZnkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIG5ld1ZhbHVlID0gbW9kaWZ5ID09PSBkZWxNb2RpZmllciA/IERFTEVURSA6XG4gICAgICAgICAgICAgICAgICAgICAgICBtb2RpZnkobWF5YmVEZWVwRnJlZXplKGZpZWxkVmFsdWUpLCBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgc2hhcmVkRGV0YWlsc18xKSwgeyBmaWVsZE5hbWU6IGZpZWxkTmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yZUZpZWxkTmFtZTogc3RvcmVGaWVsZE5hbWUsIHN0b3JhZ2U6IF90aGlzLmdldFN0b3JhZ2UoZGF0YUlkLCBzdG9yZUZpZWxkTmFtZSkgfSkpO1xuICAgICAgICAgICAgICAgICAgICBpZiAobmV3VmFsdWUgPT09IElOVkFMSURBVEUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLmdyb3VwLmRpcnR5KGRhdGFJZCwgc3RvcmVGaWVsZE5hbWUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5ld1ZhbHVlID09PSBERUxFVEUpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3VmFsdWUgPSB2b2lkIDA7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV3VmFsdWUgIT09IGZpZWxkVmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2VkRmllbGRzXzFbc3RvcmVGaWVsZE5hbWVdID0gbmV3VmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmVlZFRvTWVyZ2VfMSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZmllbGRWYWx1ZSA9IG5ld1ZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChmaWVsZFZhbHVlICE9PSB2b2lkIDApIHtcbiAgICAgICAgICAgICAgICAgICAgYWxsRGVsZXRlZF8xID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBpZiAobmVlZFRvTWVyZ2VfMSkge1xuICAgICAgICAgICAgICAgIHRoaXMubWVyZ2UoZGF0YUlkLCBjaGFuZ2VkRmllbGRzXzEpO1xuICAgICAgICAgICAgICAgIGlmIChhbGxEZWxldGVkXzEpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMgaW5zdGFuY2VvZiBMYXllcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kYXRhW2RhdGFJZF0gPSB2b2lkIDA7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5kYXRhW2RhdGFJZF07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cC5kaXJ0eShkYXRhSWQsIFwiX19leGlzdHNcIik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9O1xuICAgIEVudGl0eVN0b3JlLnByb3RvdHlwZS5kZWxldGUgPSBmdW5jdGlvbiAoZGF0YUlkLCBmaWVsZE5hbWUsIGFyZ3MpIHtcbiAgICAgICAgdmFyIF9hO1xuICAgICAgICB2YXIgc3RvcmVPYmplY3QgPSB0aGlzLmxvb2t1cChkYXRhSWQpO1xuICAgICAgICBpZiAoc3RvcmVPYmplY3QpIHtcbiAgICAgICAgICAgIHZhciB0eXBlbmFtZSA9IHRoaXMuZ2V0RmllbGRWYWx1ZShzdG9yZU9iamVjdCwgXCJfX3R5cGVuYW1lXCIpO1xuICAgICAgICAgICAgdmFyIHN0b3JlRmllbGROYW1lID0gZmllbGROYW1lICYmIGFyZ3NcbiAgICAgICAgICAgICAgICA/IHRoaXMucG9saWNpZXMuZ2V0U3RvcmVGaWVsZE5hbWUoeyB0eXBlbmFtZTogdHlwZW5hbWUsIGZpZWxkTmFtZTogZmllbGROYW1lLCBhcmdzOiBhcmdzIH0pXG4gICAgICAgICAgICAgICAgOiBmaWVsZE5hbWU7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5tb2RpZnkoZGF0YUlkLCBzdG9yZUZpZWxkTmFtZSA/IChfYSA9IHt9LFxuICAgICAgICAgICAgICAgIF9hW3N0b3JlRmllbGROYW1lXSA9IGRlbE1vZGlmaWVyLFxuICAgICAgICAgICAgICAgIF9hKSA6IGRlbE1vZGlmaWVyKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfTtcbiAgICBFbnRpdHlTdG9yZS5wcm90b3R5cGUuZXZpY3QgPSBmdW5jdGlvbiAob3B0aW9ucykge1xuICAgICAgICB2YXIgZXZpY3RlZCA9IGZhbHNlO1xuICAgICAgICBpZiAob3B0aW9ucy5pZCkge1xuICAgICAgICAgICAgaWYgKGhhc093bi5jYWxsKHRoaXMuZGF0YSwgb3B0aW9ucy5pZCkpIHtcbiAgICAgICAgICAgICAgICBldmljdGVkID0gdGhpcy5kZWxldGUob3B0aW9ucy5pZCwgb3B0aW9ucy5maWVsZE5hbWUsIG9wdGlvbnMuYXJncyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcyBpbnN0YW5jZW9mIExheWVyKSB7XG4gICAgICAgICAgICAgICAgZXZpY3RlZCA9IHRoaXMucGFyZW50LmV2aWN0KG9wdGlvbnMpIHx8IGV2aWN0ZWQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAob3B0aW9ucy5maWVsZE5hbWUgfHwgZXZpY3RlZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXAuZGlydHkob3B0aW9ucy5pZCwgb3B0aW9ucy5maWVsZE5hbWUgfHwgXCJfX2V4aXN0c1wiKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZXZpY3RlZDtcbiAgICB9O1xuICAgIEVudGl0eVN0b3JlLnByb3RvdHlwZS5jbGVhciA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdGhpcy5yZXBsYWNlKG51bGwpO1xuICAgIH07XG4gICAgRW50aXR5U3RvcmUucHJvdG90eXBlLnJlcGxhY2UgPSBmdW5jdGlvbiAobmV3RGF0YSkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBPYmplY3Qua2V5cyh0aGlzLmRhdGEpLmZvckVhY2goZnVuY3Rpb24gKGRhdGFJZCkge1xuICAgICAgICAgICAgaWYgKCEobmV3RGF0YSAmJiBoYXNPd24uY2FsbChuZXdEYXRhLCBkYXRhSWQpKSkge1xuICAgICAgICAgICAgICAgIF90aGlzLmRlbGV0ZShkYXRhSWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgaWYgKG5ld0RhdGEpIHtcbiAgICAgICAgICAgIE9iamVjdC5rZXlzKG5ld0RhdGEpLmZvckVhY2goZnVuY3Rpb24gKGRhdGFJZCkge1xuICAgICAgICAgICAgICAgIF90aGlzLm1lcmdlKGRhdGFJZCwgbmV3RGF0YVtkYXRhSWRdKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBFbnRpdHlTdG9yZS5wcm90b3R5cGUucmV0YWluID0gZnVuY3Rpb24gKHJvb3RJZCkge1xuICAgICAgICByZXR1cm4gdGhpcy5yb290SWRzW3Jvb3RJZF0gPSAodGhpcy5yb290SWRzW3Jvb3RJZF0gfHwgMCkgKyAxO1xuICAgIH07XG4gICAgRW50aXR5U3RvcmUucHJvdG90eXBlLnJlbGVhc2UgPSBmdW5jdGlvbiAocm9vdElkKSB7XG4gICAgICAgIGlmICh0aGlzLnJvb3RJZHNbcm9vdElkXSA+IDApIHtcbiAgICAgICAgICAgIHZhciBjb3VudCA9IC0tdGhpcy5yb290SWRzW3Jvb3RJZF07XG4gICAgICAgICAgICBpZiAoIWNvdW50KVxuICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnJvb3RJZHNbcm9vdElkXTtcbiAgICAgICAgICAgIHJldHVybiBjb3VudDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gMDtcbiAgICB9O1xuICAgIEVudGl0eVN0b3JlLnByb3RvdHlwZS5nZXRSb290SWRTZXQgPSBmdW5jdGlvbiAoaWRzKSB7XG4gICAgICAgIGlmIChpZHMgPT09IHZvaWQgMCkgeyBpZHMgPSBuZXcgU2V0KCk7IH1cbiAgICAgICAgT2JqZWN0LmtleXModGhpcy5yb290SWRzKS5mb3JFYWNoKGlkcy5hZGQsIGlkcyk7XG4gICAgICAgIGlmICh0aGlzIGluc3RhbmNlb2YgTGF5ZXIpIHtcbiAgICAgICAgICAgIHRoaXMucGFyZW50LmdldFJvb3RJZFNldChpZHMpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgT2JqZWN0LmtleXModGhpcy5wb2xpY2llcy5yb290VHlwZW5hbWVzQnlJZCkuZm9yRWFjaChpZHMuYWRkLCBpZHMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBpZHM7XG4gICAgfTtcbiAgICBFbnRpdHlTdG9yZS5wcm90b3R5cGUuZ2MgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHZhciBpZHMgPSB0aGlzLmdldFJvb3RJZFNldCgpO1xuICAgICAgICB2YXIgc25hcHNob3QgPSB0aGlzLnRvT2JqZWN0KCk7XG4gICAgICAgIGlkcy5mb3JFYWNoKGZ1bmN0aW9uIChpZCkge1xuICAgICAgICAgICAgaWYgKGhhc093bi5jYWxsKHNuYXBzaG90LCBpZCkpIHtcbiAgICAgICAgICAgICAgICBPYmplY3Qua2V5cyhfdGhpcy5maW5kQ2hpbGRSZWZJZHMoaWQpKS5mb3JFYWNoKGlkcy5hZGQsIGlkcyk7XG4gICAgICAgICAgICAgICAgZGVsZXRlIHNuYXBzaG90W2lkXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHZhciBpZHNUb1JlbW92ZSA9IE9iamVjdC5rZXlzKHNuYXBzaG90KTtcbiAgICAgICAgaWYgKGlkc1RvUmVtb3ZlLmxlbmd0aCkge1xuICAgICAgICAgICAgdmFyIHJvb3RfMSA9IHRoaXM7XG4gICAgICAgICAgICB3aGlsZSAocm9vdF8xIGluc3RhbmNlb2YgTGF5ZXIpXG4gICAgICAgICAgICAgICAgcm9vdF8xID0gcm9vdF8xLnBhcmVudDtcbiAgICAgICAgICAgIGlkc1RvUmVtb3ZlLmZvckVhY2goZnVuY3Rpb24gKGlkKSB7IHJldHVybiByb290XzEuZGV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yID0gZnVuY3Rpb24gKGxheWVySWQsIHJlcGxheSkge1xuICAgICAgICByZXR1cm4gbmV3IExheWVyKGxheWVySWQsIHRoaXMsIHJlcGxheSwgdGhpcy5ncm91cCk7XG4gICAgfTtcbiAgICBMYXllci5wcm90b3R5cGUucmVtb3ZlTGF5ZXIgPSBmdW5jdGlvbiAobGF5ZXJJZCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgcGFyZW50ID0gdGhpcy5wYXJlbnQucmVtb3ZlTGF5ZXIobGF5ZXJJZCk7XG4gICAgICAgIGlmIChsYXllcklkID09PSB0aGlzLmlkKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5ncm91cC5jYWNoaW5nKSB7XG4gICAgICAgICAgICAgICAgT2JqZWN0LmtleXModGhpcy5kYXRhKS5mb3JFYWNoKGZ1bmN0aW9uIChkYXRhSWQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKF90aGlzLmRhdGFbZGF0YUlkXSAhPT0gcGFyZW50Lmxvb2t1cChkYXRhSWQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5kZWxldGUoZGF0YUlkKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHBhcmVudDtcbiAgICAgICAgfVxuICAgICAgICBpZiAocGFyZW50ID09PSB0aGlzLnBhcmVudClcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICByZXR1cm4gcGFyZW50LmFkZExheWVyKHRoaXMuaWQsIHRoaXMucmVwbGF5KTtcbiAgICB9O1xuICAgIExheWVyLnByb3RvdHlwZS50b09iamVjdCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgcmV0dXJuIF9fYXNzaWduKF9fYXNzaWduKHt9LCB0aGlzLnBhcmVudC50b09iamVjdCgpKSwgdGhpcy5kYXRhKTtcbiAgICB9O1xuICAg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Yy5vcHRpbWlzdGljLCByb290SWQgPSBjLnJvb3RJZCwgdmFyaWFibGVzID0gYy52YXJpYWJsZXM7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBzdG9yZS5tYWtlQ2FjaGVLZXkoYy5xdWVyeSwgYy5jYWxsYmFjaywgSlNPTi5zdHJpbmdpZnkoeyBvcHRpbWlzdGljOiBvcHRpbWlzdGljLCByb290SWQ6IHJvb3RJZCwgdmFyaWFibGVzOiB2YXJpYWJsZXMgfSkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIF90aGlzLndhdGNoRGVwID0gZGVwKCk7XG4gICAgICAgIF90aGlzLmNvbmZpZyA9IF9fYXNzaWduKF9fYXNzaWduKHt9LCBkZWZhdWx0Q29uZmlnKSwgY29uZmlnKTtcbiAgICAgICAgX3RoaXMuYWRkVHlwZW5hbWUgPSAhIV90aGlzLmNvbmZpZy5hZGRUeXBlbmFtZTtcbiAgICAgICAgX3RoaXMucG9saWNpZXMgPSBuZXcgUG9saWNpZXMoe1xuICAgICAgICAgICAgY2FjaGU6IF90aGlzLFxuICAgICAgICAgICAgZGF0YUlkRnJvbU9iamVjdDogX3RoaXMuY29uZmlnLmRhdGFJZEZyb21PYmplY3QsXG4gICAgICAgICAgICBwb3NzaWJsZVR5cGVzOiBfdGhpcy5jb25maWcucG9zc2libGVUeXBlcyxcbiAgICAgICAgICAgIHR5cGVQb2xpY2llczogX3RoaXMuY29uZmlnLnR5cGVQb2xpY2llcyxcbiAgICAgICAgfSk7XG4gICAgICAgIF90aGlzLmRhdGEgPSBuZXcgRW50aXR5U3RvcmUuUm9vdCh7XG4gICAgICAgICAgICBwb2xpY2llczogX3RoaXMucG9saWNpZXMsXG4gICAgICAgICAgICByZXN1bHRDYWNoaW5nOiBfdGhpcy5jb25maWcucmVzdWx0Q2FjaGluZyxcbiAgICAgICAgfSk7XG4gICAgICAgIF90aGlzLm9wdGltaXN0aWNEY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ZXR1cm4gdGhpcy5zdG9yZVJlYWRlci5kaWZmUXVlcnlBZ2FpbnN0U3RvcmUoe1xuICAgICAgICAgICAgc3RvcmU6IHN0b3JlLFxuICAgICAgICAgICAgcXVlcnk6IG9wdGlvbnMucXVlcnksXG4gICAgICAgICAgICB2YXJpYWJsZXM6IG9wdGlvbnMudmFyaWFibGVzLFxuICAgICAgICAgICAgcm9vdElkOiBvcHRpb25zLnJvb3RJZCxcbiAgICAgICAgICAgIGNvbmZpZzogdGhpcy5jb25maWcsXG4gICAgICAgICAgICByZXR1cm5QYXJ0aWFsRGF0YTogZmFsc2UsXG4gICAgICAgIH0pLnJlc3VsdCB8fCBudWxsO1xuICAgIH07XG4gICAgSW5NZW1vcnlDYWNoZS5wcm90b3R5cGUud3JpdGUgPSBmdW5jdGlvbiAob3B0aW9ucykge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgKyt0aGlzLnR4Q291bnQ7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5zdG9yZVdyaXRlci53cml0ZVRvU3RvcmUoe1xuICAgICAgICAgICAgICAgIHN0b3JlOiB0aGlzLmRhdGEsXG4gICAgICAgICAgICAgICAgcXVlcnk6IG9wdGlvbnMucXVlcnksXG4gICAgICAgICAgICAgICAgcmVzdWx0OiBvcHRpb25zLnJlc3VsdCxcbiAgICAgICAgICAgICAgICBkYXRhSWQ6IG9wdGlvbnMuZGF0YUlkLFxuICAgICAgICAgICAgICAgIHZhcmlhYmxlczogb3B0aW9ucy52YXJpYWJsZXMsXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgIGlmICghLS10aGlzLnR4Q291bnQgJiYgb3B0aW9ucy5icm9hZGNhc3QgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5icm9hZGNhc3RXYXRjaGVzKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIEluTWVtb3J5Q2FjaGUucHJvdG90eXBlLm1vZGlmeSA9IGZ1bmN0aW9uIChvcHRpb25zKSB7XG4gICAgICAgIGlmIChoYXNPd24uY2FsbChvcHRpb25zLCBcImlkXCIpICYmICFvcHRpb25zLmlkKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHN0b3JlID0gb3B0aW9ucy5vcHRpbWlzdGljXG4gICAgICAgICAgICA/IHRoaXMub3B0aW1pc3RpY0RhdGFcbiAgICAgICAgICAgIDogdGhpcy5kYXRhO1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgKyt0aGlzLnR4Q291bnQ7XG4gICAgICAgICAgICByZXR1cm4gc3RvcmUubW9kaWZ5KG9wdGlvbnMuaWQgfHwgXCJST09UX1FVRVJZXCIsIG9wdGlvbnMuZmllbGRzKTtcbiAgICAgICAgfVxuICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgIGlmICghLS10aGlzLnR4Q291bnQgJiYgb3B0aW9ucy5icm9hZGNhc3QgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5icm9hZGNhc3RXYXRjaGVzKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIEluTWVtb3J5Q2FjaGUucHJvdG90eXBlLmRpZmYgPSBmdW5jdGlvbiAob3B0aW9ucykge1xuICAgICAgICByZXR1cm4gdGhpcy5zdG9yZVJlYWRlci5kaWZmUXVlcnlBZ2FpbnN0U3RvcmUoe1xuICAgICAgICAgICAgc3RvcmU6IG9wdGlvbnMub3B0aW1pc3RpYyA/IHRoaXMub3B0aW1pc3RpY0RhdGEgOiB0aGlzLmRhdGEsXG4gICAgICAgICAgICByb290SWQ6IG9wdGlvbnMuaWQgfHwgXCJST09UX1FVRVJZXCIsXG4gICAgICAgICAgICBxdWVyeTogb3B0aW9ucy5xdWVyeSxcbiAgICAgICAgICAgIHZhcmlhYmxlczogb3B0aW9ucy52YXJp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lzdGljKSB7XG4gICAgICAgIHJldHVybiAob3B0aW1pc3RpYyA/IHRoaXMub3B0aW1pc3RpY0RhdGEgOiB0aGlzLmRhdGEpLnJlbGVhc2Uocm9vdElkKTtcbiAgICB9O1xuICAgIEluTWVtb3J5Q2FjaGUucHJvdG90eXBlLmlkZW50aWZ5ID0gZnVuY3Rpb24gKG9iamVjdCkge1xuICAgICAgICByZXR1cm4gaXNSZWZlcmVuY2Uob2JqZWN0KSA/IG9iamVjdC5fX3JlZiA6XG4gICAgICAgICAgICB0aGlzLnBvbGljaWVzLmlkZW50aWZ5KG9iamVjdClbMF07XG4gICAgfTtcbiAgICBJbk1lbW9yeUNhY2hlLnByb3RvdHlwZS5ldmljdCA9IGZ1bmN0aW9uIChvcHRpb25zKSB7XG4gICAgICAgIGlmICghb3B0aW9ucy5pZCkge1xuICAgICAgICAgICAgaWYgKGhhc093bi5jYWxsKG9wdGlvbnMsIFwiaWRcIikpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBvcHRpb25zID0gX19hc3NpZ24oX19hc3NpZ24oe30sIG9wdGlvbnMpLCB7IGlkOiBcIlJPT1RfUVVFUllcIiB9KTtcbiAgICAgICAgfVxuICAgICAgICB0cnkge1xuICAgICAgICAgICAgKyt0aGlzLnR4Q291bnQ7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5vcHRpbWlzdGljRGF0YS5ldmljdChvcHRpb25zKTtcbiAgICAgICAgfVxuICAgICAgICBmaW5hbGx5IHtcbiAgICAgICAgICAgIGlmICghLS10aGlzLnR4Q291bnQgJiYgb3B0aW9ucy5icm9hZGNhc3QgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5icm9hZGNhc3RXYXRjaGVzKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIEluTWVtb3J5Q2FjaGUucHJvdG90eXBlLnJlc2V0ID0gZnVuY3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AgICAgICAgICB9XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHRyYW5zYWN0aW9uKF90aGlzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgICAgIC0tX3RoaXMudHhDb3VudDtcbiAgICAgICAgICAgICAgICBfdGhpcy5kYXRhID0gZGF0YTtcbiAgICAgICAgICAgICAgICBfdGhpcy5vcHRpbWlzdGljRGF0YSA9IG9wdGltaXN0aWNEYXRhO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICB2YXIgZnJvbU9wdGltaXN0aWNUcmFuc2FjdGlvbiA9IGZhbHNlO1xuICAgICAgICBpZiAodHlwZW9mIG9wdGltaXN0aWNJZCA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgIHRoaXMub3B0aW1pc3RpY0RhdGEgPSB0aGlzLm9wdGltaXN0aWNEYXRhLmFkZExheWVyKG9wdGltaXN0aWNJZCwgcGVyZm9ybSk7XG4gICAgICAgICAgICBmcm9tT3B0aW1pc3RpY1RyYW5zYWN0aW9uID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChvcHRpbWlzdGljSWQgPT09IG51bGwpIHtcbiAgICAgICAgICAgIHBlcmZvcm0odGhpcy5kYXRhKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHBlcmZvcm0oKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmJyb2FkY2FzdFdhdGNoZXMoZnJvbU9wdGltaXN0aWNUcmFuc2FjdGlvbik7XG4gICAgfTtcbiAgICBJbk1lbW9yeUNhY2hlLnByb3RvdHlwZS50cmFuc2Zvcm1Eb2N1bWVudCA9IGZ1bmN0aW9uIChkb2N1bWVudCkge1xuICAgICAgICBpZiAodGhpcy5hZGRUeXBlbmFtZSkge1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHRoaXMudHlwZW5hbWVEb2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XhwLCB9IGZyb20gXCIuL2hlbHBlcnMuanNcIjtcbmltcG9ydCB7IGNhY2hlU2xvdCB9IGZyb20gXCIuL3JlYWN0aXZlVmFycy5qc1wiO1xuZnVuY3Rpb24gYXJnc0Zyb21GaWVsZFNwZWNpZmllcihzcGVjKSB7XG4gICAgcmV0dXJuIHNwZWMuYXJncyAhPT0gdm9pZCAwID8gc3BlYy5hcmdzIDpcbiAgICAgICAgc3BlYy5maWVsZCA/IGFyZ3VtZW50c09iamVjdEZyb21GaWVsZChzcGVjLmZpZWxkLCBzcGVjLnZhcmlhYmxlcykgOiBudWxsO1xufVxuZXhwb3J0IHZhciBkZWZhdWx0RGF0YUlkRnJvbU9iamVjdCA9IGZ1bmN0aW9uIChfYSwgY29udGV4dCkge1xuICAgIHZhciBfX3R5cGVuYW1lID0gX2EuX190eXBlbmFtZSwgaWQgPSBfYS5pZCwgX2lkID0gX2EuX2lkO1xuICAgIGlmICh0eXBlb2YgX190eXBlbmFtZSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICBpZiAoY29udGV4dCkge1xuICAgICAgICAgICAgY29udGV4dC5rZXlPYmplY3QgPVxuICAgICAgICAgICAgICAgIGlkICE9PSB2b2lkIDAgPyB7IGlkOiBpZCB9IDpcbiAgICAgICAgICAgICAgICAgICAgX2lkICE9PSB2b2lkIDAgPyB7IF9pZDogX2lkIH0gOlxuICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCAwO1xuICAgICAgICB9XG4gICAgICAgIGlmIChpZCA9PT0gdm9pZCAwKVxuICAgICAgICAgICAgaWQgPSBfaWQ7XG4gICAgICAgIGlmIChpZCAhPT0gdm9pZCAwKSB7XG4gICAgICAgICAgICByZXR1cm4gX190eXBlbmFtZSArIFwiOlwiICsgKCh0eXBlb2YgaWQgPT09IFwibnVtYmVyXCIgfHxcbiAgICAgICAgICAgICAgICB0eXBlb2YgaWQgPT09IFwic3RyaW5nXCIpID8gaWQgOiBKU09OLnN0cmluZ2lmeShpZCkpO1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dGlvblNldCxcbiAgICAgICAgICAgIGZyYWdtZW50TWFwOiBmcmFnbWVudE1hcCxcbiAgICAgICAgfTtcbiAgICAgICAgdmFyIGlkO1xuICAgICAgICB2YXIgcG9saWN5ID0gdGhpcy5nZXRUeXBlUG9saWN5KHR5cGVuYW1lLCBmYWxzZSk7XG4gICAgICAgIHZhciBrZXlGbiA9IHBvbGljeSAmJiBwb2xpY3kua2V5Rm4gfHwgdGhpcy5jb25maWcuZGF0YUlkRnJvbU9iamVjdDtcbiAgICAgICAgd2hpbGUgKGtleUZuKSB7XG4gICAgICAgICAgICB2YXIgc3BlY2lmaWVyT3JJZCA9IGtleUZuKG9iamVjdCwgY29udGV4dCk7XG4gICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShzcGVjaWZpZXJPcklkKSkge1xuICAgICAgICAgICAgICAgIGtleUZuID0ga2V5RmllbGRzRm5Gcm9tU3BlY2lmaWVyKHNwZWNpZmllck9ySWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgaWQgPSBzcGVjaWZpZXJPcklkO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlkID0gaWQgJiYgU3RyaW5nKGlkKTtcbiAgICAgICAgcmV0dXJuIGNvbnRleHQua2V5T2JqZWN0ID8gW2lkLCBjb250ZXh0LmtleU9iamVjdF0gOiBbaWRdO1xuICAgIH07XG4gICAgUG9saWNpZXMucHJvdG90eXBlLmFkZFR5cGVQb2xpY2llcyA9IGZ1bmN0aW9uICh0eXBlUG9saWNpZXMpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgT2JqZWN0LmtleXModHlwZVBvbGljaWVzKS5mb3JFYWNoKGZ1bmN0aW9uICh0eXBlbmFtZSkge1xuICAgICAgICAgICAgdmFyIGV4aXN0aW5nID0gX3RoaXMuZ2V0VHlwZVBvbGljeSh0eXBlbmFtZSwgdHJ1ZSk7XG4gICAgICAgICAgICB2YXIgaW5jb21pbmcgPSB0eXBlUG9saWNpZXNbdHlwZW5hbWVdO1xuICAgICAgICAgICAgdmFyIGtleUZpZWxkcyA9IGluY29taW5nLmtleUZpZWxkcywgZmllbGRzID0gaW5jb21pbmcuZmllbGRzO1xuICAgICAgICAgICAgaWYgKGluY29taW5nLnF1ZXJ5VHlwZSlcbiAgICAgICAgICAgICAgICBfdGhpcy5zZXRSb290VHlwZW5hbWUoXCJRdWVyeVwiLCB0eXBlbmFtZSk7XG4gICAgICAgICAgICBpZiAoaW5jb21pbmcubXV0YXRpb25UeXBlKVxuICAgICAgICAgICAgICAgIF90aGlzLnNldFJvb3RUeXBlbmFtZShcIk11dGF0aW9uXCIsIHR5cGVuYW1lKTtcbiAgICAgICAgICAgIGlmIChpbmNvbWluZy5zdWJzY3JpcHRpb25UeXBlKVxuICAgICAgICAgICAgICAgIF90aGlzLnNldFJvb3RUeXBlbmFtZShcIlN1YnNjcmlwdGlvblwiLCB0eXBlbmFtZSk7XG4gICAgICAgICAgICBleGlzdGluZy5rZXlGbiA9XG4gICAgICAgICAgICAgICAga2V5RmllbGRzID09PSBmYWxzZSA/IG51bGxLZXlGaWVsZHNGbiA6XG4gICAgICAgICAgICAgICAgICAgIEFycmF5LmlzQXJyYXkoa2V5RmllbGRzKSA/IGtleUZpZWxkc0ZuRnJvbVNwZWNpZmllcihrZXlGaWVsZHMpIDpcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVvZiBrZXlGaWVsZHMgPT09IFwiZnVuY3Rpb25cIiA/IGtleUZpZWxkcyA6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhpc3Rpbmcua2V5Rm47XG4gICAgICAgICAgICBpZiAoZmllbGRzKSB7XG4gICAgICAgICAgICAgICAgT2JqZWN0LmtleXMoZmllbGRzKS5mb3JFYWNoKGZ1bmN0aW9uIChmaWVsZE5hbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGV4aXN0aW5nID0gX3RoaXMuZ2V0RmllbGRQb2xpY3kodHlwZW5hbWUsIGZpZWxkTmFtZSwgdHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbmNvbWluZyA9IGZpZWxkc1tmaWVsZE5hbWVdO1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGluY29taW5nID09PSBcImZ1bmN0aW9uXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aW5nLnJlYWQgPSBpbmNvbWluZztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBrZXlBcmdzID0gaW5jb21pbmcua2V5QXJncywgcmVhZCA9IGluY29taW5nLnJlYWQsIG1lcmdlID0gaW5jb21pbmcubWVyZ2U7XG4gICAgICAgICAgICAgICAgICAgICAgICBleGlzdGluZy5rZXlGbiA9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5QXJncyA9PT0gZmFsc2UgPyBzaW1wbGVLZXlBcmdzRm4gOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnJheS5pc0FycmF5KGtleUFyZ3MpID8ga2V5QXJnc0ZuRnJvbVNwZWNpZmllcihrZXlBcmdzKSA6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlb2Yga2V5QXJncyA9PT0gXCJmdW5jdGlvblwiID8ga2V5QXJncyA6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhpc3Rpbmcua2V5Rm47XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlYWQgPT09IFwiZnVuY3Rpb25cIilcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleGlzdGluZy5yZWFkID0gcmVhZDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aW5nLm1lcmdlID1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlb2YgbWVyZ2UgPT09IFwiZnVuY3Rpb25cIiA/IG1lcmdlIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVyZ2UgPT09IHRydWUgPyBtZXJnZVRydWVGbiA6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXJnZSA9PT0gZmFsc2UgPyBtZXJnZUZhbHNlRm4gOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aW5nLm1lcmdlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGlmIChleGlzdGluZy5yZWFkICYmIGV4aXN0aW5nLm1lcmdlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBleGlzdGluZy5rZXlGbiA9IGV4aXN0aW5nLmtleUZuIHx8IHNpbXBsZUtleUFyZ3NGbjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9O1xuICAgIFBvbGljaWVzLnByb3RvdHlwZS5zZXRSb290VHlwZW5hbWUgPSBmdW5jdGlvbiAod2hpY2gsIHR5cGVuYW1lKSB7XG4gICAgICAgIGlmICh0eXBlbmFtZSA9PT0gdm9pZCAwKSB7IHR5cGVuYW1lID0gd2hpY2g7IH1cbiAgICAgICAgdmFyIHJvb3RJZCA9IFwiUk9PVF9cIiArIHdoaWNoLnRvVXBwZXJDYXNlKCk7XG4gICAgICAgIHZhciBvbGQgPSB0aGlzLnJvb3RUeXBlbmFtZXNCeUlkW3Jvb3RJZF07XG4gICAgICAgIGlmICh0eXBlbmFtZSAhPT0gb2xkKSB7XG4gICAgICAgICAgICBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgPyBpbnZhcmlhbnQoIW9sZCB8fCBvbGQgPT09IHdoaWNoLCAxKSA6IGludmFyaWFudC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hlY2tpbmdGdXp6eVN1YnR5cGVzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzcy5lbnYuTk9ERV9FTlYgPT09IFwicHJvZHVjdGlvblwiIHx8IGludmFyaWFudC53YXJuKFwiSW5mZXJyaW5nIHN1YnR5cGUgXCIgKyB0eXBlbmFtZSArIFwiIG9mIHN1cGVydHlwZSBcIiArIHN1cGVydHlwZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlbmFtZVN1cGVydHlwZVNldC5hZGQoc3VwZXJ0eXBlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc3VwZXJ0eXBlU2V0LmZvckVhY2gobWF5YmVFbnF1ZXVlXzEpO1xuICAgICAgICAgICAgICAgIGlmIChuZWVkVG9DaGVja0Z1enp5U3VidHlwZXMgJiZcbiAgICAgICAgICAgICAgICAgICAgaSA9PT0gd29ya1F1ZXVlXzEubGVuZ3RoIC0gMSAmJlxuICAgICAgICAgICAgICAgICAgICBzZWxlY3Rpb25TZXRNYXRjaGVzUmVzdWx0KGZyYWdtZW50LnNlbGVjdGlvblNldCwgcmVzdWx0LCB2YXJpYWJsZXMpKSB7XG4gICAgICAgICAgICAgICAgICAgIG5lZWRUb0NoZWNrRnV6enlTdWJ0eXBlcyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICBjaGVja2luZ0Z1enp5U3VidHlwZXMgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZ1enp5U3VidHlwZXMuZm9yRWFjaChmdW5jdGlvbiAocmVnRXhwLCBmdXp6eVN0cmluZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIG1hdGNoID0gdHlwZW5hbWUubWF0Y2gocmVnRXhwKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRjaCAmJiBtYXRjaFswXSA9PT0gdHlwZW5hbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXliZUVucXVldWVfMShmdXp6eVN0cmluZyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfTtcbiAgICBQb2xpY2llcy5wcm90b3R5cGUuZ2V0U3RvcmVGaWVsZE5hbWUgPSBmdW5jdGlvbiAoZmllbGRTcGVjKSB7XG4gICAgICAgIHZhciB0eXBlbmFtZSA9IGZpZWxkU3BlYy50eXBlbmFtZSwgZmllbGROYW1lID0gZmllbGRTcGVjLmZpZWxkTmFtZTtcbiAgICAgICAgdmFyIHBvbGljeSA9IHRoaXMuZ2V0RmllbGRQb2xpY3kodHlwZW5hbWUsIGZpZWxkTmFtZSwgZmFsc2UpO1xuICAgICAgICB2YXIgc3RvcmVGaWVsZE5hbWU7XG4gICAgICAgIHZhciBrZXlGbiA9IHBvbGljeSAmJiBwb2xpY3kua2V5Rm47XG4gICAgICAgIGlmIChrZXlGbiAmJiB0eXBlbmFtZSkge1xuICAgICAgICAgICAgdmFyIGNvbnRleHQgPSB7XG4gICAgICAgICAgICAgICAgdHlwZW5hbWU6IHR5cGVuYW1lLFxuICAgICAgICAgICAgICAgIGZpZWxkTmFtZTogZmllbGROYW1lLFxuICAgICAgICAgICAgICAgIGZpZWxkOiBmaWVsZFNwZWMuZmllbGQgfHwgbnVsbCxcbiAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IGZpZWxkU3BlYy52YXJpYWJsZXMsXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgdmFyIGFyZ3MgPSBhcmdzRnJvbUZpZWxkU3BlY2lmaWVyKGZpZWxkU3BlYyk7XG4gICAgICAgICAgICB3aGlsZSAoa2V5Rm4pIHtcbiAgICAgICAgICAgICAgICB2YXIgc3BlY2lmaWVyT3JTdHJpbmcgPSBrZXlGbihhcmdzLCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShzcGVjaWZpZXJPclN0cmluZykpIHtcbiAgICAgICAgICAgICAgICAgICAga2V5Rm4gPSBrZXlBcmdzRm5Gcm9tU3BlY2lmaWVyKHNwZWNpZmllck9yU3RyaW5nKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHN0b3JlRmllbGROYW1lID0gc3BlY2lmaWVyT3JTdHJpbmcgfHwgZmllbGROYW1lO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0b3JlRmllbGROYW1lID09PSB2b2lkIDApIHtcbiAgICAgICAgICAgIHN0b3JlRmllbGROYW1lID0gZmllbGRTcGVjLmZpZWxkXG4gICAgICAgICAgICAgICAgPyBzdG9yZUtleU5hbWVGcm9tRmllbGQoZmllbGRTcGVjLmZpZWxkLCBmaWVsZFNwZWMudmFyaWFibGVzKVxuICAgICAgICAgICAgICAgIDogZ2V0U3RvcmVLZXlOYW1lKGZpZWxkTmFtZSwgYXJnc0Zyb21GaWVsZFNwZWNpZmllcihmaWVsZFNwZWMpKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZmllbGROYW1lID09PSBmaWVsZE5hbWVGcm9tU3RvcmVOYW1lKHN0b3JlRmllbGROYW1lKVxuICAgICAgICAgICAgPyBzdG9yZUZpZWxkTmFtZVxuICAgICAgICAgICAgOiBmaWVsZE5hbWUgKyBcIjpcIiArIHN0b3JlRmllbGROYW1lO1xuICAgIH07XG4gICAgUG9saWNpZXMucHJvdG90eXBlLnJlYWRGaWVsZCA9IGZ1bmN0aW9uIChvcHRpb25zLCBjb250ZXh0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lcmdlID0gdGhpcy5nZXRGaWVsZFBvbGljeShpbmNvbWluZy5fX3R5cGVuYW1lLCBmaWVsZE5hbWUsIGZhbHNlKS5tZXJnZTtcbiAgICAgICAgICAgIGluY29taW5nID0gbWVyZ2UoZXhpc3RpbmcsIGluY29taW5nLl9fdmFsdWUsIG1ha2VGaWVsZEZ1bmN0aW9uT3B0aW9ucyh0aGlzLCB2b2lkIDAsIHsgdHlwZW5hbWU6IGluY29taW5nLl9fdHlwZW5hbWUsIGZpZWxkTmFtZTogZmllbGROYW1lLFxuICAgICAgICAgICAgICAgIGZpZWxkOiBmaWVsZCwgdmFyaWFibGVzOiBjb250ZXh0LnZhcmlhYmxlcyB9LCBjb250ZXh0LCBzdG9yYWdlS2V5c1xuICAgICAgICAgICAgICAgID8gKF9hID0gY29udGV4dC5zdG9yZSkuZ2V0U3RvcmFnZS5hcHBseShfYSwgc3RvcmFnZUtleXMpIDogT2JqZWN0LmNyZWF0ZShudWxsKSkpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KGluY29taW5nKSkge1xuICAgICAgICAgICAgcmV0dXJuIGluY29taW5nLm1hcChmdW5jdGlvbiAoaXRlbSkgeyByZXR1cm4gX3RoaXMuYXBwbHlNZXJnZXModm9pZCAwLCBpdGVtLCBjb250ZXh0KTsgfSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0b3JlVmFsdWVJc1N0b3JlT2JqZWN0KGluY29taW5nKSkge1xuICAgICAgICAgICAgdmFyIGVfMSA9IGV4aXN0aW5nO1xuICAgICAgICAgICAgdmFyIGlfMSA9IGluY29taW5nO1xuICAgICAgICAgICAgdmFyIGZpcnN0U3RvcmFnZUtleV8xID0gaXNSZWZlcmVuY2UoZV8xKVxuICAgICAgICAgICAgICAgID8gZV8xLl9fcmVmXG4gICAgICAgICAgICAgICAgOiB0eXBlb2YgZV8xID09PSBcIm9iamVjdFwiICYmIGVfMTtcbiAgICAgICAgICAgIHZhciBuZXdGaW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G4gICAgICAgICAgICAgICAgZmllbGROYW1lOiBmaWVsZE5hbWVPck9wdGlvbnMsXG4gICAgICAgICAgICAgICAgZnJvbTogZnJvbSxcbiAgICAgICAgICAgIH0gOiBfX2Fzc2lnbih7fSwgZmllbGROYW1lT3JPcHRpb25zKTtcbiAgICAgICAgICAgIGlmICh2b2lkIDAgPT09IG9wdGlvbnMuZnJvbSkge1xuICAgICAgICAgICAgICAgIG9wdGlvbnMuZnJvbSA9IG9iamVjdE9yUmVmZXJlbmNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHZvaWQgMCA9PT0gb3B0aW9ucy52YXJpYWJsZXMpIHtcbiAgICAgICAgICAgICAgICBvcHRpb25zLnZhcmlhYmxlcyA9IHZhcmlhYmxlcztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBwb2xpY2llcy5yZWFkRmllbGQob3B0aW9ucywgY29udGV4dCk7XG4gICAgICAgIH0sXG4gICAgICAgIG1lcmdlT2JqZWN0czogZnVuY3Rpb24gKGV4aXN0aW5nLCBpbmNvbWluZykge1xuICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoZXhpc3RpbmcpIHx8IEFycmF5LmlzQXJyYXkoaW5jb21pbmcpKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgcHJvY2Vzcy5lbnYuTk9ERV9FTlYgPT09IFwicHJvZHVjdGlvblwiID8gbmV3IEludmFyaWFudEVycm9yKDIpIDogbmV3IEludmFyaWFudEVycm9yKFwiQ2Fubm90IGF1dG9tYXRpY2FsbHkgbWVyZ2UgYXJyYXlzXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGV4aXN0aW5nICYmIHR5cGVvZiBleGlzdGluZyA9PT0gXCJvYmplY3RcIiAmJlxuICAgICAgICAgICAgICAgIGluY29taW5nICYmIHR5cGVvZiBpbmNvbWluZyA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgIHZhciBlVHlwZSA9IGdldEZpZWxkVmFsdWUoZXhpc3RpbmcsIFwiX190eXBlbmFtZVwiKTtcbiAgICAgICAgICAgICAgICB2YXIgaVR5cGUgPSBnZXRGaWVsZFZhbHVlKGluY29taW5nLCBcIl9fdHlwZW5hbWVcIik7XG4gICAgICAgICAgICAgICAgdmFyIHR5cGVzRGlmZmVyID0gZVR5cGUgJiYgaVR5cGUgJiYgZVR5cGUgIT09IGlUeXBlO1xuICAgICAgICAgICAgICAgIHZhciBhcHBsaWVkID0gcG9saWNpZXMuYXBwbHlNZXJnZXModHlwZXNEaWZmZXIgPyB2b2lkIDAgOiBleGlzdGluZywgaW5jb21pbmcsIGNvbnRleHQpO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlc0RpZmZlciB8fFxuICAgICAgICAgICAgICAgICAgICAhc3RvcmVWYWx1ZUlzU3RvcmVPYmplY3QoZXhpc3RpbmcpIHx8XG4gICAgICAgICAgICAgICAgICAgICFzdG9yZVZhbHVlSXNTdG9yZU9iamVjdChhcHBsaWVkKSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXBwbGllZDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9fYXNzaWduKF9fYXNzaWduKHt9LCBleGlzdGluZyksIGFwcGxpZWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGluY29taW5nO1xuICAgICAgICB9XG4gICAgfTtcbn1cbmZ1bmN0aW9uIGtleUFyZ3NGbkZyb21TcGVjaWZpZXIoc3BlY2lmaWVyKSB7XG4gICAgcmV0dXJuIGZ1bmN0aW9uIChhcmdzLCBjb250ZXh0KSB7XG4gICAgICAgIHJldHVybiBhcmdzID8gY29udGV4dC5maWVsZE5hbWUgKyBcIjpcIiArIEpTT04uc3RyaW5naWZ5KGNvbXB1dGVLZXlPYmplY3QoYXJncywgc3BlY2lmaWVyKSkgOiBjb250ZXh0LmZpZWxkTmFtZTtcbiAgICB9O1xufVxuZnVuY3Rpb24ga2V5RmllbGRzRm5Gcm9tU3BlY2lmaWVyKHNwZWNpZmllcikge1xuICAgIHZhciB0cmllID0gbmV3IEtleVRyaWUoY2FuVXNlV2Vha01hcCk7XG4gICAgcmV0dXJuIGZ1bmN0aW9uIChvYmplY3QsIGNvbnRleHQpIHtcbiAgICAgICAgdmFyIGFsaWFzTWFwO1xuICAgICAgICBpZiAoY29udGV4dC5zZWxlY3Rpb25TZXQgJiYgY29udGV4dC5mcmFnbWVudE1hcCkge1xuICAgICAgICAgICAgdmFyIGluZm8gPSB0cmllLmxvb2t1cEFycmF5KFtcbiAgICAgICAgICAgICAgICBjb250ZXh0LnNlbGVjdGlvblNldCxcbiAgICAgICAgICAgICAgICBjb250ZXh0LmZyYWdtZW50TWFwLFxuICAgICAgICAgICAgXSk7XG4gICAgICAgICAgICBhbGlhc01hcCA9IGluZm8uYWxpYXNNYXAgfHwgKGluZm8uYWxpYXNNYXAgPSBtYWtlQWxpYXNNYXAoY29udGV4dC5zZWxlY3Rpb25TZXQsIGNvbnRleHQuZnJhZ21lbnRNYXApKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIga2V5T2JqZWN0ID0gY29udGV4dC5rZXlPYmplY3QgPVxuICAgICAgICAgICAgY29tcHV0ZUtleU9iamVjdChvYmplY3QsIHNwZWNpZmllciwgYWxpYXNNYXApO1xuICAgICAgICByZXR1cm4gY29udGV4dC50eXBlbmFtZSArIFwiOlwiICsgSlNPTi5zdHJpbmdpZnkoa2V5T2JqZWN0KTtcbiAgICB9O1xufVxuZnVuY3Rpb24gbWFrZUFsaWFzTWFwKHNlbGVjdGlvblNldCwgZnJhZ21lbnRNYXApIHtcbiAgICB2YXIgbWFwID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICB2YXIgd29ya1F1ZXVlID0gbmV3IFNldChbc2VsZWN0aW9uU2V0XSk7XG4gICAgd29ya1F1ZXVlLmZvckVhY2goZnVuY3Rpb24gKHNlbGVjdGlvblNldCkge1xuICAgICAgICBzZWxlY3Rpb25TZXQuc2VsZWN0aW9ucy5mb3JFYWNoKGZ1bmN0aW9uIChzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgIGlmIChpc0ZpZWxkKHNlbGVjdGlvbikpIHtcbiAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uLmFsaWFzKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciByZXNwb25zZUtleSA9IHNlbGVjdGlvbi5hbGlhcy52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3JlS2V5ID0gc2VsZWN0aW9uLm5hbWUudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzdG9yZUtleSAhPT0gcmVzcG9uc2VLZXkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBhbGlhc2VzID0gbWFwLmFsaWFzZXMgfHwgKG1hcC5hbGlhc2VzID0gT2JqZWN0LmNyZWF0ZShudWxsKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBhbGlhc2VzW3N0b3JlS2V5XSA9IHJlc3BvbnNlS2V5O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChzZWxlY3Rpb24uc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBzdWJzZXRzID0gbWFwLnN1YnNldHMgfHwgKG1hcC5zdWJzZXRzID0gT2JqZWN0LmNyZWF0ZShudWxsKSk7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNldHNbc2VsZWN0aW9uLm5hbWUudmFsdWVdID1cbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VBbGlhc01hcChzZWxlY3Rpb24uc2VsZWN0aW9uU2V0LCBmcmFnbWVudE1hcCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdmFyIGZyYWdtZW50ID0gZ2V0RnJhZ21lbnRGcm9tU2VsZWN0aW9uKHNlbGVjdGlvbiwgZnJhZ21lbnRNYXApO1xuICAgICAgICAgICAgICAgIGlmIChmcmFnbWVudCkge1xuICAgICAgICAgICAgICAgICAgICB3b3JrUXVldWUuYWRkKGZyYWdtZW50LnNlbGVjdGlvblNldCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9KTtcbiAgICByZXR1cm4gbWFwO1xufVxuZnVuY3Rpb24gY29tcHV0ZUtleU9iamVjdChyZXNwb25zZSwgc3BlY2lmaWVyLCBhbGlhc01hcCkge1xuICAgIHZhciBrZXlPYmogPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgIHZhciBwcmV2S2V5O1xuICAgIHNwZWNpZmllci5mb3JFYWNoKGZ1bmN0aW9uIChzKSB7XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KHMpKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHByZXZLZXkgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICB2YXIgc3Vic2V0cyA9IGFsaWFzTWFwICYmIGFsaWFzTWFwLnN1YnNldHM7XG4gICAgICAgICAgICAgICAgdmFyIHN1YnNldCA9IHN1YnNldHMgJiYgc3Vic2V0c1twcmV2S2V5XTtcbiAgICAgICAgICAgICAgICBrZXlPYmpbcHJldktleV0gPSBjb21wdXRlS2V5T2JqZWN0KHJlc3BvbnNlW3ByZXZLZXldLCBzLCBzdWJzZXQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdmFyIGFsaWFzZXMgPSBhbGlhc01hcCAmJiBhbGlhc01hcC5hbGlhc2VzO1xuICAgICAgICAgICAgdmFyIHJlc3BvbnNlTmFtZSA9IGFsaWFzZXMgJiYgYWxpYXNlc1tzXSB8fCBzO1xuICAgICAgICAgICAgcHJvY2Vzcy5lbnYuTk9ERV9FTlYgPT09IFwicHJv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UmVhZGVyKGNvbmZpZykge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB0aGlzLmNvbmZpZyA9IGNvbmZpZztcbiAgICAgICAgdGhpcy5leGVjdXRlU2VsZWN0aW9uU2V0ID0gd3JhcChmdW5jdGlvbiAob3B0aW9ucykgeyByZXR1cm4gX3RoaXMuZXhlY1NlbGVjdGlvblNldEltcGwob3B0aW9ucyk7IH0sIHtcbiAgICAgICAgICAgIGtleUFyZ3M6IGZ1bmN0aW9uIChvcHRpb25zKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy5zZWxlY3Rpb25TZXQsXG4gICAgICAgICAgICAgICAgICAgIG9wdGlvbnMub2JqZWN0T3JSZWZlcmVuY2UsXG4gICAgICAgICAgICAgICAgICAgIG9wdGlvbnMuY29udGV4dCxcbiAgICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIG1ha2VDYWNoZUtleTogZnVuY3Rpb24gKHNlbGVjdGlvblNldCwgcGFyZW50LCBjb250ZXh0KSB7XG4gICAgICAgICAgICAgICAgaWYgKHN1cHBvcnRzUmVzdWx0Q2FjaGluZyhjb250ZXh0LnN0b3JlKSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29udGV4dC5zdG9yZS5tYWtlQ2FjaGVLZXkoc2VsZWN0aW9uU2V0LCBpc1JlZmVyZW5jZShwYXJlbnQpID8gcGFyZW50Ll9fcmVmIDogcGFyZW50LCBjb250ZXh0LnZhclN0cmluZyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5rbm93blJlc3VsdHMgPSBuZXcgV2Vha01hcCgpO1xuICAgICAgICB0aGlzLmV4ZWN1dGVTdWJTZWxlY3RlZEFycmF5ID0gd3JhcChmdW5jdGlvbiAob3B0aW9ucykge1xuICAgICAgICAgICAgcmV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YWx1ZXMoZ2V0UXVlcnlEZWZpbml0aW9uKHF1ZXJ5KSkpLCB2YXJpYWJsZXMpO1xuICAgICAgICB2YXIgZXhlY1Jlc3VsdCA9IHRoaXMuZXhlY3V0ZVNlbGVjdGlvblNldCh7XG4gICAgICAgICAgICBzZWxlY3Rpb25TZXQ6IGdldE1haW5EZWZpbml0aW9uKHF1ZXJ5KS5zZWxlY3Rpb25TZXQsXG4gICAgICAgICAgICBvYmplY3RPclJlZmVyZW5jZTogbWFrZVJlZmVyZW5jZShyb290SWQpLFxuICAgICAgICAgICAgY29udGV4dDoge1xuICAgICAgICAgICAgICAgIHN0b3JlOiBzdG9yZSxcbiAgICAgICAgICAgICAgICBxdWVyeTogcXVlcnksXG4gICAgICAgICAgICAgICAgcG9saWNpZXM6IHBvbGljaWVzLFxuICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgIHZhclN0cmluZzogSlNPTi5zdHJpbmdpZnkodmFyaWFibGVzKSxcbiAgICAgICAgICAgICAgICBmcmFnbWVudE1hcDogY3JlYXRlRnJhZ21lbnRNYXAoZ2V0RnJhZ21lbnREZWZpbml0aW9ucyhxdWVyeSkpLFxuICAgICAgICAgICAgICAgIHBhdGg6IFtdLFxuICAgICAgICAgICAgICAgIGNsaWVudE9ubHk6IGZhbHNlLFxuICAgICAgICAgICAgfSxcbiAgICAgICAgfSk7XG4gICAgICAgIHZhciBoYXNNaXNzaW5nRmllbGRzID0gZXhlY1Jlc3VsdC5taXNzaW5nICYmIGV4ZWNSZXN1bHQubWlzc2luZy5sZW5ndGggPiAwO1xuICAgICAgICBpZiAoaGFzTWlzc2luZ0ZpZWxkcyAmJiAhcmV0dXJuUGFydGlhbERhdGEpIHtcbiAgICAgICAgICAgIHRocm93IGV4ZWNSZXN1bHQubWlzc2luZ1swXTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgcmVzdWx0OiBleGVjUmVzdWx0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W5hbWU6IHR5cGVuYW1lIH0pO1xuICAgICAgICB9XG4gICAgICAgIGZ1bmN0aW9uIGdldE1pc3NpbmcoKSB7XG4gICAgICAgICAgICByZXR1cm4gZmluYWxSZXN1bHQubWlzc2luZyB8fCAoZmluYWxSZXN1bHQubWlzc2luZyA9IFtdKTtcbiAgICAgICAgfVxuICAgICAgICBmdW5jdGlvbiBoYW5kbGVNaXNzaW5nKHJlc3VsdCkge1xuICAgICAgICAgICAgdmFyIF9hO1xuICAgICAgICAgICAgaWYgKHJlc3VsdC5taXNzaW5nKVxuICAgICAgICAgICAgICAgIChfYSA9IGdldE1pc3NpbmcoKSkucHVzaC5hcHBseShfYSwgcmVzdWx0Lm1pc3NpbmcpO1xuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdC5yZXN1bHQ7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHdvcmtTZXQgPSBuZXcgU2V0KHNlbGVjdGlvblNldC5zZWxlY3Rpb25zKTtcbiAgICAgICAgd29ya1NldC5mb3JFYWNoKGZ1bmN0aW9uIChzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciBfYTtcbiAgICAgICAgICAgIGlmICghc2hvdWxkSW5jbHVkZShzZWxlY3Rpb24sIHZhcmlhYmxlcykpXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgaWYgKGlzRmllbGQoc2VsZWN0aW9uKSkge1xuICAgICAgICAgICAgICAgIHZhciBmaWVsZFZhbHVlID0gcG9saWNpZXMucmVhZEZpZWxkKHtcbiAgICAgICAgICAgICAgICAgICAgZmllbGROYW1lOiBzZWxlY3Rpb24ubmFtZS52YWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgZmllbGQ6IHNlbGVjdGlvbixcbiAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiBjb250ZXh0LnZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgZnJvbTogb2JqZWN0T3JSZWZlcmVuY2UsXG4gICAgICAgICAgICAgICAgfSwgY29udGV4dCk7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3VsdE5hbWUgPSByZXN1bHRLZXlOYW1lRnJvbUZpZWxkKHNlbGVjdGlvbik7XG4gICAgICAgICAgICAgICAgY29udGV4dC5wYXRoLnB1c2gocmVzdWx0TmFtZSk7XG4gICAgICAgICAgICAgICAgdmFyIHdhc0NsaWVudE9ubHkgPSBjb250ZXh0LmNsaWVudE9ubHk7XG4gICAgICAgICAgICAgICAgY29udGV4dC5jbGllbnRPbmx5ID0gd2FzQ2xpZW50T25seSB8fCAhIShzZWxlY3Rpb24uZGlyZWN0aXZlcyAmJlxuICAgICAgICAgICAgICAgICAgICBzZWxlY3Rpb24uZGlyZWN0aXZlcy5zb21lKGZ1bmN0aW9uIChkKSB7IHJldHVybiBkLm5hbWUudmFsdWUgPT09IFwiY2xpZW50XCI7IH0pKTtcbiAgICAgICAgICAgICAgICBpZiAoZmllbGRWYWx1ZSA9PT0gdm9pZCAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghYWRkVHlwZW5hbWVUb0RvY3VtZW50LmFkZGVkKHNlbGVjdGlvbikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdldE1pc3NpbmcoKS5wdXNoKG1pc3NpbmdGcm9tSW52YXJpYW50KHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiA/IG5ldyBJbnZhcmlhbnRFcnJvcig1KSA6IG5ldyBJbnZhcmlhbnRFcnJvcihcIkNhbid0IGZpbmQgZmllbGQgJ1wiICsgc2VsZWN0aW9uLm5hbWUudmFsdWUgKyBcIicgb24gXCIgKyAoaXNSZWZlcmVuY2Uob2JqZWN0T3JSZWZlcmVuY2UpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBvYmplY3RPclJlZmVyZW5jZS5fX3JlZiArIFwiIG9iamVjdFwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBcIm9iamVjdCBcIiArIEpTT04uc3RyaW5naWZ5KG9iamVjdE9yUmVmZXJlbmNlLCBudWxsLCAyKSkpLCBjb250ZXh0KSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoQXJyYXkuaXNBcnJheShmaWVsZFZhbHVlKSkge1xuICAgICAgICAgICAgICAgICAgICBmaWVsZFZhbHVlID0gaGFuZGxlTWlzc2luZyhfdGhpcy5leGVjdXRlU3ViU2VsZWN0ZWRBcnJheSh7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaWVsZDogc2VsZWN0aW9uLFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyYXk6IGZpZWxkVmFsdWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBjb250ZXh0LFxuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKCFzZWxlY3Rpb24uc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChwcm9jZXNzLmVudi5OT0RFX0VOViAhPT0gJ3Byb2R1Y3Rpb24nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBhc3NlcnRTZWxlY3Rpb25TZXRGb3JJZFZhbHVlKGNvbnRleHQuc3RvcmUsIHNlbGVjdGlvbiwgZmllbGRWYWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYXliZURlZXBGcmVlemUoZmllbGRWYWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoZmllbGRWYWx1ZSAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpZWxkVmFsdWUgPSBoYW5kbGVNaXNzaW5nKF90aGlzLmV4ZWN1dGVTZWxlY3Rpb25TZXQoe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0aW9uU2V0OiBzZWxlY3Rpb24uc2VsZWN0aW9uU2V0LFxuICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0T3JSZWZlcmVuY2U6IGZpZWxkVmFsdWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBjb250ZXh0LFxuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChmaWVsZFZhbHVlICE9PSB2b2lkIDApIHtcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0c1RvTWVyZ2UucHVzaCgoX2EgPSB7fSwgX2FbcmVzdWx0TmFtZV0gPSBmaWVsZFZhbHVlLCBfYSkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb250ZXh0LmNsaWVudE9ubHkgPSB3YXNDbGllbnRPbmx5O1xuICAgICAgICAgICAgICAgIGludmFyaWFudChjb250ZXh0LnBhdGgucG9wKCkgPT09IHJlc3VsdE5hbWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdmFyIGZyYWdtZW50ID0gZ2V0RnJhZ21lbnRGcm9tU2VsZWN0aW9uKHNlbGVjdGlvbiwgY29udGV4dC5mcmFnbWVudE1hcCk7XG4gICAgICAgICAgICAgICAgaWYgKGZyYWdtZW50ICYmIHBvbGljaWVzLmZyYWdtZW50TWF0Y2hlcyhmcmFnbWVudCwgdHlwZW5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGZyYWdtZW50LnNlbGVjdGlvblNldC5zZWxlY3Rpb25zLmZvckVhY2god29ya1NldC5hZGQsIHdvcmtTZXQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIGZpbmFsUmVzdWx0LnJlc3VsdCA9IG1lcmdlRGVlcEFycmF5KG9iamVjdHNUb01lcmdlKTtcbiAgICAgICAgaWYgKHByb2Nl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rpb24gKGl0ZW0sIGkpIHtcbiAgICAgICAgICAgIGlmIChpdGVtID09PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb250ZXh0LnBhdGgucHVzaChpKTtcbiAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGhhbmRsZU1pc3NpbmcoX3RoaXMuZXhlY3V0ZVN1YlNlbGVjdGVkQXJyYXkoe1xuICAgICAgICAgICAgICAgICAgICBmaWVsZDogZmllbGQsXG4gICAgICAgICAgICAgICAgICAgIGFycmF5OiBpdGVtLFxuICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBjb250ZXh0LFxuICAgICAgICAgICAgICAgIH0pLCBpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChmaWVsZC5zZWxlY3Rpb25TZXQpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaGFuZGxlTWlzc2luZyhfdGhpcy5leGVjdXRlU2VsZWN0aW9uU2V0KHtcbiAgICAgICAgICAgICAgICAgICAgc2VsZWN0aW9uU2V0OiBmaWVsZC5zZWxlY3Rpb25TZXQsXG4gICAgICAgICAgICAgICAgICAgIG9iamVjdE9yUmVmZXJlbmNlOiBpdGVtLFxuICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBjb250ZXh0LFxuICAgICAgICAgICAgICAgIH0pLCBpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChwcm9jZXNzLmVudi5OT0RFX0VOViAhPT0gJ3Byb2R1Y3Rpb24nKSB7XG4gICAgICAgICAgICAgICAgYXNzZXJ0U2VsZWN0aW9uU2V0Rm9ySWRWYWx1ZShjb250ZXh0LnN0b3JlLCBmaWVsZCwgaXRlbSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpbnZhcmlhbnQoY29udGV4dC5wYXRoLnBvcCgp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gKGRhdGFJZCAmJiBjb250ZXh0LnN0b3JlLmdldChkYXRhSWQsIFwiX190eXBlbmFtZVwiKSk7XG4gICAgICAgIGlmIChcInN0cmluZ1wiID09PSB0eXBlb2YgdHlwZW5hbWUpIHtcbiAgICAgICAgICAgIG1lcmdlZEZpZWxkcy5fX3R5cGVuYW1lID0gdHlwZW5hbWU7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHdvcmtTZXQgPSBuZXcgU2V0KHNlbGVjdGlvblNldC5zZWxlY3Rpb25zKTtcbiAgICAgICAgd29ya1NldC5mb3JFYWNoKGZ1bmN0aW9uIChzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciBfYTtcbiAgICAgICAgICAgIGlmICghc2hvdWxkSW5jbHVkZShzZWxlY3Rpb24sIGNvbnRleHQudmFyaWFibGVzKSlcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICBpZiAoaXNGaWVsZChzZWxlY3Rpb24pKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3VsdEZpZWxkS2V5ID0gcmVzdWx0S2V5TmFtZUZyb21GaWVsZChzZWxlY3Rpb24pO1xuICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IHJlc3VsdFtyZXN1bHRGaWVsZEtleV07XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3JlRmllbGROYW1lID0gcG9saWNpZXMuZ2V0U3RvcmVGaWVsZE5hbWUoe1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZW5hbWU6IHR5cGVuYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgZmllbGROYW1lOiBzZWxlY3Rpb24ubmFtZS52YWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkOiBzZWxlY3Rpb24sXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IGNvbnRleHQudmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGluY29taW5nVmFsdWUgPSBfdGhpcy5wcm9jZXNzRmllbGRWYWx1ZSh2YWx1ZSwgc2VsZWN0aW9uLCBjb250ZXh0LCBvdXQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAocG9saWNpZXMuaGFzTWVyZ2VGdW5jdGlvbih0eXBlbmFtZSwgc2VsZWN0aW9uLm5hbWUudmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbmNvbWluZ1ZhbHVlID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fZmllbGQ6IHNlbGVjdGlvbixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX3R5cGVuYW1lOiB0eXBlbmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX3ZhbHVlOiBpbmNvbWluZ1ZhbHVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG91dC5zaG91bGRBcHBseU1lcmdlcyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgbWVyZ2VkRmllbGRzID0gY29udGV4dC5tZXJnZShtZXJnZWRGaWVsZHMsIChfYSA9IHt9LFxuICAgICAgICAgICAgICAgICAgICAgICAgX2Fbc3RvcmVGaWVsZE5hbWVdID0gaW5jb21pbmdWYWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIF9hKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKHBvbGljaWVzLnVzaW5nUG9zc2libGVUeXBlcyAmJlxuICAgICAgICAgICAgICAgICAgICAhaGFzRGlyZWN0aXZlcyhbXCJkZWZlclwiLCBcImNsaWVudFwiXSwgc2VsZWN0aW9uKSkge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgPyBuZXcgSW52YXJpYW50RXJyb3IoOCkgOiBuZXcgSW52YXJpYW50RXJyb3IoXCJNaXNzaW5nIGZpZWxkICdcIiArIHJlc3VsdEZpZWxkS2V5ICsgXCInIGluIFwiICsgSlNPTi5zdHJpbmdpZnkocmVzdWx0LCBudWxsLCAyKS5zdWJzdHJpbmcoMCwgMTAwKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdmFyIGZyYWdtZW50ID0gZ2V0RnJhZ21lbnRGcm9tU2VsZWN0aW9uKHNlbGVjdGlvbiwgY29udGV4dC5mcmFnbWVudE1hcCk7XG4gICAgICAgICAgICAgICAgaWYgKGZyYWdtZW50ICYmXG4gICAgICAgICAgICAgICAgICAgIHBvbGljaWVzLmZyYWdtZW50TWF0Y2hlcyhmcmFnbWVudCwgdHlwZW5hbWUsIHJlc3VsdCwgY29udGV4dC52YXJpYWJsZXMpKSB7XG4gICAgICAgICAgICAgICAgICAgIGZyYWdtZW50LnNlbGVjdGlvblNldC5zZWxlY3Rpb25zLmZvckVhY2god29ya1NldC5hZGQsIHdvcmtTZXQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIGlmIChcInN0cmluZ1wiID09PSB0eXBlb2YgZGF0YUlkKSB7XG4gICAgICAgICAgICB2YXIgZW50aXR5UmVmXzEgPSBtYWtlUmVmZXJlbmNlKGRhdGFJZCk7XG4gICAgICAgICAgICBpZiAob3V0LnNob3VsZEFwcGx5TWVyZ2VzKSB7XG4gICAgICAgICAgICAgICAgbWVyZ2VkRmllbGRzID0gcG9saWNpZXMuYXBwbHlNZXJnZXMoZW50aXR5UmVmXzEsIG1lcmdlZEZpZWxkcywgY29udGV4dCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09IFwicHJvZHVjdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgT2JqZWN0LmtleXMobWVyZ2VkRmllbGRzKS5mb3JFYWNoKGZ1bmN0aW9uIChzdG9yZUZpZWxkTmFtZSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZmllbGROYW1lID0gZmllbGROYW1lRnJvbVN0b3JlTmFtZShzdG9yZUZpZWxkTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcG9saWNpZXMuaGFzTWVyZ2VGdW5jdGlvbih0eXBlbmFtZSwgZmllbGROYW1lKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgd2FybkFib3V0RGF0YUxvc3MoZW50aXR5UmVmXzEsIG1lcmdlZEZpZWxkcywgc3RvcmVGaWVsZE5hbWUsIGNvbnRleHQuc3RvcmUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb250ZXh0LnN0b3JlLm1lcmdlKGRhdGFJZCwgbWVyZ2VkRmllbGRzKTtcbiAgICAgICAgICAgIHJldHVybiBlbnRpdHlSZWZfMTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbWVyZ2VkRmllbGRzO1xuICAgIH07XG4gICAgU3RvcmVXcml0ZXIucHJvdG90eXBlLnByb2Nlc3NGaWVsZFZhbHVlID0gZnVuY3Rpb24gKHZhbHVlLCBmaWVsZCwgY29udGV4dCwgb3V0KSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIGlmICghZmllbGQuc2VsZWN0aW9uU2V0IHx8IHZhbHVlID09PSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gcHJvY2Vzcy5lbnYuTk9ERV9FTlYgPT09ICdwcm9kdWN0aW9uJyA/IHZhbHVlIDogY2xvbmVEZWVwKHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICBpZi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AmJiB0eXBlb2Ygd2luZG93ICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgd2luZG93Ll9fQVBPTExPX0NMSUVOVF9fID0gdGhpcztcbiAgICAgICAgfVxuICAgICAgICBpZiAoIWhhc1N1Z2dlc3RlZERldnRvb2xzICYmIHByb2Nlc3MuZW52Lk5PREVfRU5WICE9PSAncHJvZHVjdGlvbicpIHtcbiAgICAgICAgICAgIGhhc1N1Z2dlc3RlZERldnRvb2xzID0gdHJ1ZTtcbiAgICAgICAgICAgIGlmICh0eXBlb2Ygd2luZG93ICE9PSAndW5kZWZpbmVkJyAmJlxuICAgICAgICAgICAgICAgIHdpbmRvdy5kb2N1bWVudCAmJlxuICAgICAgICAgICAgICAgIHdpbmRvdy50b3AgPT09IHdpbmRvdy5zZWxmKSB7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB3aW5kb3cuX19BUE9MTE9fREVWVE9PTFNfR0xPQkFMX0hPT0tfXyA9PT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHdpbmRvdy5uYXZpZ2F0b3IgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5uYXZpZ2F0b3IudXNlckFnZW50ICYmXG4gICAgICAgICAgICAgICAgICAgICAgICB3aW5kb3cubmF2aWdhdG9yLnVzZXJBZ2VudC5pbmRleE9mKCdDaHJvbWUnKSA+IC0xKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmRlYnVnKCdEb3dubG9hZCB0aGUgQXBvbGxvIERldlRvb2xzICcgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdmb3IgYSBiZXR0ZXIgZGV2ZWxvcG1lbnQgZXhwZXJpZW5jZTogJyArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2h0dHBzOi8vY2hyb21lLmdvb2dsZS5jb20vd2Vic3RvcmUvZGV0YWlsL2Fwb2xsby1jbGllbnQtZGV2ZWxvcGVyLXQvamRra25ra2JlYmJhcGlsZ29lY2NjaWdsa2ZibWJuZm0nKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLnZlcnNpb24gPSB2ZXJzaW9uO1xuICAgICAgICB0aGlzLmxvY2FsU3RhdGUgPSBuZXcgTG9jYWxTdGF0ZSh7XG4gICAgICAgICAgICBjYWNoZTogY2FjaGUsXG4gICAgICAgICAgICBjbGllbnQ6IHRoaXMsXG4gICAgICAgICAgICByZXNvbHZlcnM6IHJlc29sdmVycyxcbiAgICAgICAgICAgIGZyYWdtZW50TWF0Y2hlcjogZnJhZ21lbnRNYXRjaGVyLFxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5xdWVyeU1hbmFnZXIgPSBuZXcgUXVlcnlNYW5hZ2VyKHtcbiAgICAgICAgICAgIGNhY2hlOiB0aGlzLmNhY2hlLFxuICAgICAgICAgICAgbGluazogdGhpcy5saW5rLFxuICAgICAgICAgICAgcXVlcnlEZWR1cGxpY2F0aW9uOiBxdWVyeURlZHVwbGljYXRpb24sXG4gICAgICAgICAgICBzc3JNb2RlOiBzc3JNb2RlLFxuICAgICAgICAgICAgY2xpZW50QXdhcmVuZXNzOiB7XG4gICAgICAgICAgICAgICAgbmFtZTogY2xpZW50QXdhcmVuZXNzTmFtZSxcbiAgICAgICAgICAgICAgICB2ZXJzaW9uOiBjbGllbnRBd2FyZW5lc3NWZXJzaW9uLFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGxvY2FsU3RhdGU6IHRoaXMubG9jYWxTdGF0ZSxcbiAgICAgICAgICAgIGFzc3VtZUltbXV0YWJsZVJlc3VsdHM6IGFzc3VtZUltbXV0YWJsZVJlc3VsdHMsXG4gICAgICAgICAgICBvbkJyb2FkY2FzdDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpcy5kZXZUb29sc0hvb2tDYikge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5kZXZUb29sc0hvb2tDYih7XG4gICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246IHt9LFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyaWVzOiBfdGhpcy5xdWVyeU1hbmFnZXIuZ2V0UXVlcnlTdG9yZSgpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG11dGF0aW9uczogX3RoaXMucXVlcnlNYW5hZ2VyLm11dGF0aW9uU3RvcmUuZ2V0U3RvcmUoKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhV2l0aE9wdGltaXN0aWNSZXN1bHRzOiBfdGhpcy5jYWNoZS5leHRyYWN0KHRydWUpLFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICB9KTtcbiAgICB9XG4gICAgQXBvbGxvQ2xpZW50LnByb3RvdHlwZS5zdG9wID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnF1ZXJ5TWFuYWdlci5zdG9wKCk7XG4gICAgfTtcbiAgICBBcG9sbG9DbGllbnQucHJvdG90eXBlLndhdGNoUXVlcnkgPSBmdW5jdGlvbiAob3B0aW9ucykge1xuICAgICAgICBpZiAodGhpcy5kZWZhdWx0T3B0aW9ucy53YXRjaFF1ZXJ5KSB7XG4gICAgICAgICAgICBvcHRpb25zID0gY29tcGFjdCh0aGlzLmRlZmF1bHRPcHRpb25zLndhdGNoUXVlcnksIG9wdGlvbnMpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmRpc2FibGVOZXR3b3JrRmV0Y2hlcyAmJlxuICAgICAgICAgICAgKG9wdGlvbnMuZmV0Y2hQb2xpY3kgPT09ICduZXR3b3JrLW9ubHknIHx8XG4gICAgICAgICAgICAg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nJhZ21lbnRNYXRjaGVyKSB7XG4gICAgICAgIHRoaXMuZnJhZ21lbnRNYXRjaGVyID0gZnJhZ21lbnRNYXRjaGVyO1xuICAgIH07XG4gICAgTG9jYWxTdGF0ZS5wcm90b3R5cGUuZ2V0RnJhZ21lbnRNYXRjaGVyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5mcmFnbWVudE1hdGNoZXI7XG4gICAgfTtcbiAgICBMb2NhbFN0YXRlLnByb3RvdHlwZS5jbGllbnRRdWVyeSA9IGZ1bmN0aW9uIChkb2N1bWVudCkge1xuICAgICAgICBpZiAoaGFzRGlyZWN0aXZlcyhbJ2NsaWVudCddLCBkb2N1bWVudCkpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnJlc29sdmVycykge1xuICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICB9O1xuICAgIExvY2FsU3RhdGUucHJvdG90eXBlLnNlcnZlclF1ZXJ5ID0gZnVuY3Rpb24gKGRvY3VtZW50KSB7XG4gICAgICAgIHJldHVybiByZW1vdmVDbGllbnRTZXRzRnJvbURvY3VtZW50KGRvY3VtZW50KTtcbiAgICB9O1xuICAgIExvY2FsU3RhdGUucHJvdG90eXBlLnByZXBhcmVDb250ZXh0ID0gZnVuY3Rpb24gKGNvbnRleHQpIHtcbiAgICAgICAgdmFyIGNhY2hlID0gdGhpcy5jYWNoZTtcbiAgICAgICAgcmV0dXJuIF9fYXNzaWduKF9fYXNzaWduKHt9LCBjb250ZXh0KSwgeyBjYWNoZTogY2FjaGUsXG4gICAgICAgICAgICBnZXRDYWNoZUtleTogZnVuY3Rpb24gKG9iaikge1xuICAgICAgICAgICAgICAgIHJldHVybiBjYWNoZS5pZGVudGlmeShvYmopO1xuICAgICAgICAgICAgfSB9KTtcbiAgICB9O1xuICAgIExvY2FsU3RhdGUucHJvdG90eXB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lyZWN0aXZlOiB7XG4gICAgICAgICAgICAgICAgZW50ZXI6IGZ1bmN0aW9uIChub2RlKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChub2RlLm5hbWUudmFsdWUgPT09ICdjbGllbnQnICYmIG5vZGUuYXJndW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3JjZVJlc29sdmVycyA9IG5vZGUuYXJndW1lbnRzLnNvbWUoZnVuY3Rpb24gKGFyZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmcubmFtZS52YWx1ZSA9PT0gJ2Fsd2F5cycgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJnLnZhbHVlLmtpbmQgPT09ICdCb29sZWFuVmFsdWUnICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZy52YWx1ZS52YWx1ZSA9PT0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlUmVzb2x2ZXJzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJSRUFLO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gZm9yY2VSZXNvbHZlcnM7XG4gICAgfTtcbiAgICBMb2NhbFN0YXRlLnByb3RvdHlwZS5idWlsZFJvb3RWYWx1ZUZyb21DYWNoZSA9IGZ1bmN0aW9uIChkb2N1bWVudCwgdmFyaWFibGVzKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmNhY2hlLmRpZmYoe1xuICAgICAgICAgICAgcXVlcnk6IGJ1aWxkUXVlcnlGcm9tU2VsZWN0aW9uU2V0KGRvY3VtZW50KSxcbiAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibG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7XG4gICAgICAgICAgICAgICAgZnJhZ21lbnRzID0gZ2V0RnJhZ21lbnREZWZpbml0aW9ucyhkb2N1bWVudCk7XG4gICAgICAgICAgICAgICAgZnJhZ21lbnRNYXAgPSBjcmVhdGVGcmFnbWVudE1hcChmcmFnbWVudHMpO1xuICAgICAgICAgICAgICAgIGRlZmluaXRpb25PcGVyYXRpb24gPSBtYWluRGVmaW5pdGlvblxuICAgICAgICAgICAgICAgICAgICAub3BlcmF0aW9uO1xuICAgICAgICAgICAgICAgIGRlZmF1bHRPcGVyYXRpb25UeXBlID0gZGVmaW5pdGlvbk9wZXJhdGlvblxuICAgICAgICAgICAgICAgICAgICA/IGRlZmluaXRpb25PcGVyYXRpb24uY2hhckF0KDApLnRvVXBwZXJDYXNlKCkgK1xuICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5pdGlvbk9wZXJhdGlvbi5zbGljZSgxKVxuICAgICAgICAgICAgICAgICAgICA6ICdRdWVyeSc7XG4gICAgICAgICAgICAgICAgX2EgPSB0aGlzLCBjYWNoZSA9IF9hLmNhY2hlLCBjbGllbnQgPSBfYS5jbGllbnQ7XG4gICAgICAgICAgICAgICAgZXhlY0NvbnRleHQgPSB7XG4gICAgICAgICAgICAgICAgICAgIGZyYWdtZW50TWFwOiBmcmFnbWVudE1hcCxcbiAgICAgICAgICAgICAgICAgICAgY29udGV4dDogX19hc3NpZ24oX19hc3NpZ24oe30sIGNvbnRleHQpLCB7IGNhY2hlOiBjYWNoZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudDogY2xpZW50IH0pLFxuICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IHZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgZnJhZ21lbnRNYXRjaGVyOiBmcmFnbWVudE1hdGNoZXIsXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHRPcGVyYXRpb25UeXBlOiBkZWZhdWx0T3BlcmF0aW9uVHlwZSxcbiAgICAgICAgICAg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NvbnRleHQsIHZhcmlhYmxlcyA9IGV4ZWNDb250ZXh0LnZhcmlhYmxlcztcbiAgICAgICAgICAgICAgICByZXN1bHRzVG9NZXJnZSA9IFtyb290VmFsdWVdO1xuICAgICAgICAgICAgICAgIGV4ZWN1dGUgPSBmdW5jdGlvbiAoc2VsZWN0aW9uKSB7IHJldHVybiBfX2F3YWl0ZXIoX3RoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBmcmFnbWVudCwgdHlwZUNvbmRpdGlvbjtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIGZ1bmN0aW9uIChfYSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzaG91bGRJbmNsdWRlKHNlbGVjdGlvbiwgdmFyaWFibGVzKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMl07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNGaWVsZChzZWxlY3Rpb24pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyLCB0aGlzLnJlc29sdmVGaWVsZChzZWxlY3Rpb24sIHJvb3RWYWx1ZSwgZXhlY0NvbnRleHQpLnRoZW4oZnVuY3Rpb24gKGZpZWxkUmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2E7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGZpZWxkUmVzdWx0ICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNUb01lcmdlLnB1c2goKF9hID0ge30sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9hW3Jlc3VsdEtleU5hbWVGcm9tRmllbGQoc2VsZWN0aW9uKV0gPSBmaWVsZFJlc3VsdCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2EpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSldO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzSW5saW5lRnJhZ21lbnQoc2VsZWN0aW9uKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyYWdtZW50ID0gc2VsZWN0aW9uO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhZ21lbnQgPSBmcmFnbWVudE1hcFtzZWxlY3Rpb24ubmFtZS52YWx1ZV07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzcy5lbnYuTk9ERV9FTlYgPT09IFwicHJvZHVjdGlvblwiID8gaW52YXJpYW50KGZyYWdtZW50LCAxMSkgOiBpbnZhcmlhbnQoZnJhZ21lbnQsIFwiTm8gZnJhZ21lbnQgbmFtZWQgXCIgKyBzZWxlY3Rpb24ubmFtZS52YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZnJhZ21lbnQgJiYgZnJhZ21lbnQudHlwZUNvbmRpdGlvbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVDb25kaXRpb24gPSBmcmFnbWVudC50eXBlQ29uZGl0aW9uLm5hbWUudmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV4ZWNDb250ZXh0LmZyYWdtZW50TWF0Y2hlcihyb290VmFsdWUsIHR5cGVDb25kaXRpb24sIGNvbnRleHQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMiwgdGhpcy5yZXNvbHZlU2VsZWN0aW9uU2V0KGZyYWdtZW50LnNlbGVjdGlvblNldCwgcm9vdFZhbHVlLCBleGVjQ29udGV4dCkudGhlbihmdW5jdGlvbiAoZnJhZ21lbnRSZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzVG9NZXJnZS5wdXNoKGZyYWdtZW50UmVzdWx0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzJdO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9KTsgfTtcbiAgICAgICAgICAgICAgICByZXR1cm4gWzIsIFByb21pc2UuYWxsKHNlbGVjdGlvblNldC5zZWxlY3Rpb25zLm1hcChleGVjdXRlKSkudGhlbihmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWVyZ2VEZWVwQXJyYXkocmVzdWx0c1RvTWVyZ2UpO1xuICAgICAgICAgICAgICAgICAgICB9KV07XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBMb2NhbFN0YXRlLnByb3RvdHlwZS5yZXNvbHZlRmllbGQgPSBmdW5jdGlvbiAoZmllbGQsIHJvb3RWYWx1ZSwgZXhlY0NvbnRleHQpIHtcbiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgdmFyIHZhcmlhYmxlcywgZmllbGROYW1lLCBhbGlhc2VkRmllbGROYW1lLCBhbGlhc1VzZWQsIGRlZmF1bHRSZXN1bHQsIHJlc3VsdFByb21pc2UsIHJlc29sdmVyVHlwZSwgcmVzb2x2ZXJNYXAsIHJlc29sdmU7XG4gICAgICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIGZ1bmN0aW9uIChfYSkge1xuICAgICAgICAgICAgICAgIHZhcmlhYmxlcyA9IGV4ZWNDb250ZXh0LnZhcmlhYmxlcztcbiAgICAgICAgICAgICAgICBmaWVsZE5hbWUgPSBmaWVsZC5uYW1lLnZhbHVlO1xuICAgICAgICAgICAgICAgIGFsaWFzZWRGaWVsZE5hbWUgPSByZXN1bHRLZXlOYW1lRnJvbUZpZWxkKGZpZWxkKTtcbiAgICAgICAgICAgICAgICBhbGlhc1VzZWQgPSBmaWVsZE5hbWUgIT09IGFsaWFzZWRGaWVsZE5hbWU7XG4gICAgICAgICAgICAgICAgZGVmYXVsdFJlc3VsdCA9IHJvb3RWYWx1ZVthbGlhc2VkRmllbGROYW1lXSB8fCByb290VmFsdWVbZmllbGROYW1lXTtcbiAgICAgICAgICAgICAgICByZXN1bHRQcm9taXNlID0gUHJvbWlzZS5yZXNvbHZlKGRlZmF1bHRSZXN1bHQpO1xuICAgICAgICAgICAgICAgIGlmICghZXhlY0NvbnRleHQub25seVJ1bkZvcmNlZFJlc29sdmVycyB8fFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnNob3VsZEZvcmNlUmVzb2x2ZXJzKGZpZWxkKSkge1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlclR5cGUgPSByb290VmFsdWUuX190eXBlbmFtZSB8fCBleGVjQ29udGV4dC5kZWZhdWx0T3BlcmF0aW9uVHlwZTtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZXJNYXAgPSB0aGlzLnJlc29sdmVycyAmJiB0aGlzLnJlc29sdmVyc1tyZXNvbHZlclR5cGVdO1xuICAgICAgICAgICAgICAgICAgICBpZiAocmVzb2x2ZXJNYXApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUgPSByZXNvbHZlck1hcFthbGlhc1VzZWQgPyBmaWVsZE5hbWUgOiBhbGlhc2VkRmllbGROYW1lXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXNvbHZlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0UHJvbWlzZSA9IFByb21pc2UucmVzb2x2ZShjYWNoZVNsb3Qud2l0aFZhbHVlKHRoaXMuY2FjaGUsIHJlc29sdmUsIFtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdFZhbHVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmd1bWVudHNPYmplY3RGcm9tRmllbGQoZmllbGQsIHZhcmlhYmxlcyksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4ZWNDb250ZXh0LmNvbnRleHQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsgZmllbGQ6IGZpZWxkLCBmcmFnbWVudE1hcDogZXhlY0NvbnRleHQuZnJhZ21lbnRNYXAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIFsyLCByZXN1bHRQcm9taXNlLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gdm9pZCAwKSB7IHJlc3VsdCA9IGRlZmF1bHRSZXN1bHQ7IH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWVsZC5kaXJlY3RpdmVzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZmllbGQuZGlyZWN0aXZlcy5mb3JFYWNoKGZ1bmN0aW9uIChkaXJlY3RpdmUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRpcmVjdGl2ZS5uYW1lLnZhbHVlID09PSAnZXhwb3J0JyAmJiBkaXJlY3RpdmUuYXJndW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJlY3RpdmUuYXJndW1lbnRzLmZvckVhY2goZnVuY3Rpb24gKGFyZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcmcubmFtZS52YWx1ZSA9PT0gJ2FzJyAmJiBhcmcudmFsdWUua2luZCA9PT0gJ1N0cmluZ1ZhbHVlJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleGVjQ29udGV4dC5leHBvcnRlZFZhcmlhYmxlc1thcmcudmFsdWUudmFsdWVdID0gcmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZpZWxkLnNlbGVjdGlvblNldCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkocmVzdWx0KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdGhpcy5yZXNvbHZlU3ViU2VsZWN0ZWRBcnJheShmaWVsZCwgcmVzdWx0LCBleGVjQ29udGV4dCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmllbGQuc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLnJlc29sdmVTZWxlY3Rpb25TZXQoZmllbGQuc2VsZWN0aW9uU2V0LCByZXN1bHQsIGV4ZWNDb250ZXh0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSldO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgTG9jYWxTdGF0ZS5wcm90b3R5cGUucmVzb2x2ZVN1YlNlbGVjdGVkQXJyYXkgPSBmdW5jdGlvbiAoZmllbGQsIHJlc3VsdCwgZXhlY0NvbnRleHQpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHJlc3VsdC5tYXAoZnVuY3Rpb24gKGl0ZW0pIHtcbiAgICAgICAgICAgIGlmIChpdGVtID09PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShpdGVtKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBfdGhpcy5yZXNvbHZlU3ViU2VsZWN0ZWRBcnJheShmaWVsZCwgaXRlbSwgZXhlY0NvbnRleHQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGZpZWxkLnNlbGVjdGlvblNldCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBfdGhpcy5yZXNvbHZlU2VsZWN0aW9uU2V0KGZpZWxkLnNlbGVjdGlvblNldCwgaXRlbSwgZXhlY0NvbnRleHQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KSk7XG4gICAgfTtcbiAgICByZXR1cm4gTG9j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ICAgICAgcmV0dXJuIHRoaXMub3B0aW9ucy52YXJpYWJsZXM7XG4gICAgICAgIH0sXG4gICAgICAgIGVudW1lcmFibGU6IGZhbHNlLFxuICAgICAgICBjb25maWd1cmFibGU6IHRydWVcbiAgICB9KTtcbiAgICBPYnNlcnZhYmxlUXVlcnkucHJvdG90eXBlLnJlc3VsdCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgICAgIHZhciBvYnNlcnZlciA9IHtcbiAgICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAocmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc29sdmUocmVzdWx0KTtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMub2JzZXJ2ZXJzLmRlbGV0ZShvYnNlcnZlcik7XG4gICAgICAgICAgICAgICAgICAgIGlmICghX3RoaXMub2JzZXJ2ZXJzLnNpemUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnF1ZXJ5TWFuYWdlci5yZW1vdmVRdWVyeShfdGhpcy5xdWVyeUlkKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICB9LCAwKTtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIGVycm9yOiByZWplY3QsXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgdmFyIHN1YnNjcmlwdGlvbiA9IF90aGlzLnN1YnNjcmliZShvYnNlcnZlcik7XG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgT2JzZXJ2YWJsZVF1ZXJ5LnByb3Rvd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FuYWdlci50cmFuc2Zvcm0odGhpcy5vcHRpb25zLnF1ZXJ5KS5oYXNGb3JjZWRSZXNvbHZlcnMpIHtcbiAgICAgICAgICAgIHZhciBkaWZmID0gdGhpcy5xdWVyeUluZm8uZ2V0RGlmZigpO1xuICAgICAgICAgICAgcmVzdWx0LmRhdGEgPSAoZGlmZi5jb21wbGV0ZSB8fFxuICAgICAgICAgICAgICAgIHRoaXMub3B0aW9ucy5yZXR1cm5QYXJ0aWFsRGF0YSkgPyBkaWZmLnJlc3VsdCA6IHZvaWQgMDtcbiAgICAgICAgICAgIGlmIChkaWZmLmNvbXBsZXRlKSB7XG4gICAgICAgICAgICAgICAgaWYgKHJlc3VsdC5uZXR3b3JrU3RhdHVzID09PSBOZXR3b3JrU3RhdHVzLmxvYWRpbmcgJiZcbiAgICAgICAgICAgICAgICAgICAgKGZldGNoUG9saWN5ID09PSAnY2FjaGUtZmlyc3QnIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICBmZXRjaFBvbGljeSA9PT0gJ2NhY2hlLW9ubHknKSkge1xuICAgICAgICAgICAgICAgICAgICByZXN1bHQubmV0d29ya1N0YXR1cyA9IE5ldHdvcmtTdGF0dXMucmVhZHk7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdC5sb2FkaW5nID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGRlbGV0ZSByZXN1bHQucGFydGlhbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHJlc3VsdC5wYXJ0aWFsID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoc2F2ZUFzTGFzdFJlc3VsdCkge1xuICAgICAgICAgICAgdGhpcy51cGRhdGVMYXN0UmVzdWx0KHJlc3VsdCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9O1xuICAgIE9ic2VydmF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xuICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IGNvbWJpbmVkT3B0aW9ucy52YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgfSk7IH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgX3RoaXMucXVlcnlNYW5hZ2VyLmNhY2hlLndyaXRlUXVlcnkoe1xuICAgICAgICAgICAgICAgICAgICBxdWVyeTogY29tYmluZWRPcHRpb25zLnF1ZXJ5LFxuICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IGNvbWJpbmVkT3B0aW9ucy52YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgIGRhdGE6IGRhdGEsXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZmV0Y2hNb3JlUmVzdWx0O1xuICAgICAgICB9KS5maW5hbGx5KGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIF90aGlzLnF1ZXJ5TWFuYWdlci5zdG9wUXVlcnkocWlkKTtcbiAgICAgICAgICAgIF90aGlzLnJlb2JzZXJ2ZSgpO1xuICAgICAgICB9KTtcbiAgICB9O1xuICAgIE9ic2VydmFibGVRdWVyeS5wcm90b3R5cGUuc3Vic2NyaWJlVG9Nb3JlID0gZnVuY3Rpb24gKG9wdGlvbnMpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIHN1YnNjcmlwdGlvbiA9IHRoaXMucXVlcnlNYW5hZ2VyXG4gICAgICAgICAgICAuc3RhcnRHcmFwaFFMU3Vic2NyaXB0aW9uKHtcbiAgICAgICAgICAgIHF1ZXJ5OiBvcHRpb25zLmRvY3VtZW50LFxuICAgICAgICAgICAgdmFyaWFibGVzOiBvcHRpb25zLnZhcmlhYmxlcyxcbiAgICAgICAgICAgIGNvbnRleHQ6IG9wdGlvbnMuY29udGV4dCxcbiAgICAgICAgfSlcbiAgICAgICAgICAgIC5zdWJzY3JpYmUoe1xuICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHN1YnNjcmlwdGlvbkRhdGEpIHtcbiAgICAgICAgICAgICAgICB2YXIgdXBkYXRlUXVlcnkgPSBvcHRpb25zLnVwZGF0ZVF1ZXJ5O1xuICAgICAgICAgICAgICAgIGlmICh1cGRhdGVRdWVyeSkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy51cGRhdGVRdWVyeShmdW5jdGlvbiAocHJldmlvdXMsIF9hKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdmFyaWFibGVzID0gX2EudmFyaWFibGVzO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVwZGF0ZVF1ZXJ5KHByZXZpb3VzLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uRGF0YTogc3Vic2NyaXB0aW9uRGF0YSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IHZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5vbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgIG9wdGlvbnMub25FcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiB8fCBpbnZhcmlhbnQuZXJyb3IoJ1VuaGFuZGxlZCBHcmFwaFFMIHN1YnNjcmlwdGlvbiBlcnJvcicsIGVycik7XG4gICAgICAgICAgICB9LFxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5zdWJzY3JpcHRpb25zLmFkZChzdWJzY3JpcHRpb24pO1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgaWYgKF90aGlzLnN1YnNjcmlwdGlvbnMuZGVsZXRlKHN1YnNjcmlwdGlvbikpIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICB9O1xuICAgIE9ic2VydmFibGVRdWVyeS5wcm90b3R5cGUuc2V0T3B0aW9ucyA9IGZ1bmN0aW9uIChuZXdPcHRpb25zKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnJlb2JzZXJ2ZShuZXdPcHRpb25zKTtcbiAgICB9O1xuICAgIE9ic2VydmFibGVRdWVyeS5wcm90b3R5cGUuc2V0VmFyaWFibGVzID0gZnVuY3Rpb24gKHZhcmlhYmxlcykge1xuICAgICAgICBpZiAoZXF1YWwodGhpcy52YXJpYWJsZXMsIHZhcmlhYmxlcykpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLm9ic2VydmVycy5zaXplXG4gICAgICAgICAgICAgICAgPyB0aGlzLnJlc3VsdCgpXG4gICAgICAgICAgICAgICAgOiBQcm9taXNlLnJlc29sdmUoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm9wdGlvbnMudmFyaWFibGVzID0gdmFyaWFibGVzO1xuICAgICAgICBpZiAoIXRoaXMub2JzZXJ2ZXJzLnNpemUpIHtcbiAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUoKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgX2EgPSB0aGlzLm9wdGlvbnMuZmV0Y2hQb2xpY3ksIGZldGNoUG9saWN5ID0gX2EgPT09IHZvaWQgMCA/ICdjYWNoZS1maXJzdCcgOiBfYTtcbiAgICAgICAgdmFyIHJlb2JzZXJ2ZU9wdGlvbnMgPSB7XG4gICAgICAgICAgICBmZXRjaFBvbGlj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4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIGlmIChvcSA9PT0gdGhpcy5vYnNlcnZhYmxlUXVlcnkpXG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIGlmICh0aGlzLm9xTGlzdGVuZXIpIHtcbiAgICAgICAgICAgIHRoaXMubGlzdGVuZXJzLmRlbGV0ZSh0aGlzLm9xTGlzdGVuZXIpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMub2JzZXJ2YWJsZVF1ZXJ5ID0gb3E7XG4gICAgICAgIGlmIChvcSkge1xuICAgICAgICAgICAgb3FbXCJxdWVyeUluZm9cIl0gPSB0aGlzO1xuICAgICAgICAgICAgdGhpcy5saXN0ZW5lcnMuYWRkKHRoaXMub3FMaXN0ZW5lciA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpZiAoX3RoaXMuZ2V0RGlmZigpLmZyb21PcHRpbWlzdGljVHJhbnNhY3Rpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgb3FbXCJvYnNlcnZlXCJdKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBvcS5yZW9ic2VydmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLm9xTGlzdGVuZXI7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFF1ZXJ5SW5mby5wcm90b3R5cGUubm90aWZ5ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBpZiAodGhpcy5ub3RpZnlUaW1lb3V0KSB7XG4gICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5ub3RpZnlUaW1lb3V0KTtcbiAgICAgICAgICAgIHRoaXMubm90aWZ5VGltZW91dCA9IHZvaWQgMDtcb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YWN0aW9uKGZ1bmN0aW9uIChjYWNoZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoX3RoaXMuc2hvdWxkV3JpdGUocmVzdWx0LCBvcHRpb25zLnZhcmlhYmxlcykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLndyaXRlUXVlcnkoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5OiBfdGhpcy5kb2N1bWVudCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhOiByZXN1bHQuZGF0YSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IG9wdGlvbnMudmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5sYXN0V3JpdGUgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0OiByZXN1bHQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiBvcHRpb25zLnZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbUNvdW50OiBkZXN0cnVjdGl2ZU1ldGhvZENvdW50cy5nZXQoX3RoaXMuY2FjaGUpLFxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfdGhpcy5kaWZmICYmIF90aGlzLmRpZmYuY29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQuZGF0YSA9IF90aGlzLmRpZmYucmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB2YXIgZGlmZiA9IGNhY2hlLmRpZmYoe1xuICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnk6IF90aGlzLmRvY3VtZW50LFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiBvcHRpb25zLnZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVyblBhcnRpYWxEYXRhOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW1pc3RpYzogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLnVwZGF0ZVdhdGNoKG9wdGlvbnMudmFyaWFibGVzKTtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMuZGlmZiA9IGRpZmY7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkaWZmLmNvbXBsZXRlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQuZGF0YSA9IGRpZmYucmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmxhc3RXcml0ZSA9IHZvaWQgMDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgUXVlcnlJbmZvLnByb3RvdHlwZS5tYXJrUmVhZHkgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHRoaXMubmV0d29ya0Vycm9yID0gbnVsbDtcbiAgICAgICAgcmV0dXJuIHRoaXMubmV0d29ya1N0YXR1cyA9IE5ldHdvcmtTdGF0dXMucmVhZHk7XG4gICAgfTtcbiAgICBRdWVyeUluZm8ucHJvdG90eXBlLm1hcmtFcnJvciA9IGZ1bmN0aW9uIChlcnJvcikge1xuICAgICAgICB0aGlzLm5ldHdvcmtTdGF0dXMgPSBOZXR3b3JrU3RhdHVzLmVycm9yO1xuICAgICAgICB0aGlzLmxhc3RXcml0ZSA9IHZvaWQgMDtcbiA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uZXJhdGVNdXRhdGlvbklkKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtdXRhdGlvbiA9IHRoaXMudHJhbnNmb3JtKG11dGF0aW9uKS5kb2N1bWVudDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlcyA9IHRoaXMuZ2V0VmFyaWFibGVzKG11dGF0aW9uLCB2YXJpYWJsZXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLnRyYW5zZm9ybShtdXRhdGlvbikuaGFzQ2xpZW50RXhwb3J0cykgcmV0dXJuIFszLCAyXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgdGhpcy5sb2NhbFN0YXRlLmFkZEV4cG9ydGVkVmFyaWFibGVzKG11dGF0aW9uLCB2YXJpYWJsZXMsIGNvbnRleHQpXTtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAxOlxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzID0gX2Yuc2VudCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgX2YubGFiZWwgPSAyO1xuICAgICAgICAgICAgICAgICAgICBjYXNlIDI6XG4gICAgICAgICAgICAgICAgICAgICAgICBnZW5lcmF0ZVVwZGF0ZVF1ZXJpZXNJbmZvID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZXQgPSB7fTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodXBkYXRlUXVlcmllc0J5TmFtZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5xdWVyaWVzLmZvckVhY2goZnVuY3Rpb24gKF9hLCBxdWVyeUlkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgb2JzZXJ2YWJsZVF1ZXJ5ID0gX2Eub2JzZXJ2YWJsZVF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9ic2VydmFibGVRdWVyeSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBxdWVyeU5hbWUgPSBvYnNlcnZhYmxlUXVlcnkucXVlcnlOYW1lO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChxdWVyeU5hbWUgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzT3duUHJvcGVydHkuY2FsbCh1cGRhdGVRdWVyaWVzQnlOYW1lLCBxdWVyeU5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldFtxdWVyeUlkXSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZXI6IHVwZGF0ZVF1ZXJpZXNCeU5hbWVbcXVlcnlOYW1lXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5SW5mbzogX3RoaXMucXVlcmllcy5nZXQocXVlcnlJZCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm11dGF0aW9uU3RvcmUuaW5pdE11dGF0aW9uKG11dGF0aW9uSWQsIG11dGF0aW9uLCB2YXJpYWJsZXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGltaXN0aWNSZXNwb25zZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGltaXN0aWNfMSA9IHR5cGVvZiBvcHRpbWlzdGljUmVzcG9uc2UgPT09ICdmdW5jdGlvbidcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBvcHRpbWlzdGljUmVzcG9uc2UodmFyaWFibGVzKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IG9wdGltaXN0aWNSZXNwb25zZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlLnJlY29yZE9wdGltaXN0aWNUcmFuc2FjdGlvbihmdW5jdGlvbiAoY2FjaGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hcmtNdXRhdGlvblJlc3VsdCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXV0YXRpb25JZDogbXV0YXRpb25JZCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQ6IHsgZGF0YTogb3B0aW1pc3RpY18xIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQ6IG11dGF0aW9uLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yUG9saWN5OiBlcnJvclBvbGljeSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeVVwZGF0ZXJzQnlJZDogZ2VuZXJhdGVVcGRhdGVRdWVyaWVzSW5mbygpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZTogdXBkYXRlV2l0aFByb3h5Rm4sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBjYWNoZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgfHwgaW52YXJpYW50LmVycm9yKGVycm9yKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIG11dGF0aW9uSWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5icm9hZGNhc3RRdWVyaWVzKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxmID0gdGhpcztcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMiwgbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmVSZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlcnJvcjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5nZXRPYnNlcnZhYmxlRnJvbUxpbmsobXV0YXRpb24sIF9fYXNzaWduKF9fYXNzaWduKHt9LCBjb250ZXh0KSwgeyBvcHRpbWlzdGljUmVzcG9uc2U6IG9wdGltaXN0aWNSZXNwb25zZSB9KSwgdmFyaWFibGVzLCBmYWxzZSkuc3Vic2NyaWJlKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uIChyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ3JhcGhRTFJlc3VsdEhhc0Vycm9yKHJlc3VsdCkgJiYgZXJyb3JQb2xpY3kgPT09ICdub25lJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvciA9IG5ldyBBcG9sbG9FcnJvcih7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFwaFFMRXJyb3JzOiByZXN1bHQuZXJyb3JzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLm11dGF0aW9uU3RvcmUubWFya011dGF0aW9uUmVzdWx0KG11dGF0aW9uSWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmZXRjaFBvbGljeSAhPT0gJ25vLWNhY2hlJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya011dGF0aW9uUmVzdWx0KHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXRhdGlvbklkOiBtdXRhdGlvbklkLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdDogcmVzdWx0LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY3VtZW50OiBtdXRhdGlvbixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IHZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvclBvbGljeTogZXJyb3JQb2xpY3ksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnlVcGRhdGVyc0J5SWQ6IGdlbmVyYXRlVXBkYXRlUXVlcmllc0luZm8oKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGU6IHVwZGF0ZVdpdGhQcm94eUZuLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgc2VsZi5jYWNoZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yID0gbmV3IEFwb2xsb0Vycm9yKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrRXJyb3I6IGUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yZVJlc3VsdCA9IHJlc3VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYubXV0YXRpb25TdG9yZS5tYXJrTXV0YXRpb25FcnJvcihtdXRhdGlvbklkLCBlcnIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpbWlzdGljUmVzcG9uc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5jYWNoZS5yZW1vdmVPcHRpbWlzdGljKG11dGF0aW9uSWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmJyb2FkY2FzdFF1ZXJpZXMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEFwb2xsb0Vycm9yKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV0d29ya0Vycm9yOiBlcnIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYubXV0YXRpb25TdG9yZS5tYXJrTXV0YXRpb25FcnJvcihtdXRhdGlvbklkLCBlcnJvcik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpbWlzdGljUmVzcG9uc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5jYWNoZS5yZW1vdmVPcHRpbWlzdGljKG11dGF0aW9uSWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmJyb2FkY2FzdFF1ZXJpZXMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KGVycm9yKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlZmV0Y2hRdWVyaWVzID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZmV0Y2hRdWVyaWVzID0gcmVmZXRjaFF1ZXJpZXMoc3RvcmVSZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVmZXRjaFF1ZXJ5UHJvbWlzZXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNOb25FbXB0eUFycmF5KHJlZmV0Y2hRdWVyaWVzKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZldGNoUXVlcmllcy5mb3JFYWNoKGZ1bmN0aW9uIChyZWZldGNoUXVlcnkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVmZXRjaFF1ZXJ5ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYucXVlcmllcy5mb3JFYWNoKGZ1bmN0aW9uIChfYSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgb2JzZXJ2YWJsZVF1ZXJ5ID0gX2Eub2JzZXJ2YWJsZVF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JzZXJ2YWJsZVF1ZXJ5ICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYnNlcnZhYmxlUXVlcnkucXVlcnlOYW1lID09PSByZWZldGNoUXVlcnkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZmV0Y2hRdWVyeVByb21pc2VzLnB1c2gob2JzZXJ2YWJsZVF1ZXJ5LnJlZmV0Y2goKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBxdWVyeU9wdGlvbnMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5OiByZWZldGNoUXVlcnkucXVlcnksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogcmVmZXRjaFF1ZXJ5LnZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmV0Y2hQb2xpY3k6ICduZXR3b3JrLW9ubHknLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlZmV0Y2hRdWVyeS5jb250ZXh0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5T3B0aW9ucy5jb250ZXh0ID0gcmVmZXRjaFF1ZXJ5LmNvbnRleHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZmV0Y2hRdWVyeVByb21pc2VzLnB1c2goc2VsZi5xdWVyeShxdWVyeU9wdGlvbnMpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFByb21pc2UuYWxsKGF3YWl0UmVmZXRjaFF1ZXJpZXMgPyByZWZldGNoUXVlcnlQcm9taXNlcyA6IFtdKS50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yUG9saWN5ID09PSAnaWdub3JlJyAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmVSZXN1bHQgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoUUxSZXN1bHRIYXNFcnJvcihzdG9yZVJlc3VsdCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdG9yZVJlc3VsdC5lcnJvcnM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShzdG9yZVJlc3VsdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgcmVqZWN0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBRdWVyeU1hbmFnZXIucHJvdG90eXBlLmZldGNoUXVlcnkgPSBmdW5jdGlvbiAocXVlcnlJZCwgb3B0aW9ucywgbmV0d29ya1N0YXR1cykge1xuICAgICAgICByZXR1cm4gdGhpcy5mZXRjaFF1ZXJ5T2JzZXJ2YWJsZShxdWVyeUlkLCBvcHRpb25zLCBuZXR3b3JrU3RhdHVzKS5wcm9taXNlO1xuICAgIH07XG4gICAgUXVlcnlNYW5hZ2VyLnByb3RvdHlwZS5nZXRRdWVyeVN0b3JlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgc3RvcmUgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICB0aGlzLnF1ZXJpZXMuZm9yRWFjaChmdW5jdGlvbiAoaW5mbywgcXVlcnlJZCkge1xuICAgICAgICAgICAgc3RvcmVbcXVlcnlJZF0gPSB7XG4gICAgICAgICAgICAgICAgdmFyaWFibGVzOiBp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iAgICAgICAgICAgIHZhciBjbGllbnRRdWVyeSA9IHRoaXMubG9jYWxTdGF0ZS5jbGllbnRRdWVyeSh0cmFuc2Zvcm1lZCk7XG4gICAgICAgICAgICB2YXIgc2VydmVyUXVlcnkgPSBmb3JMaW5rICYmIHRoaXMubG9jYWxTdGF0ZS5zZXJ2ZXJRdWVyeShmb3JMaW5rKTtcbiAgICAgICAgICAgIHZhciBjYWNoZUVudHJ5XzEgPSB7XG4gICAgICAgICAgICAgICAgZG9jdW1lbnQ6IHRyYW5zZm9ybWVkLFxuICAgICAgICAgICAgICAgIGhhc0NsaWVudEV4cG9ydHM6IGhhc0NsaWVudEV4cG9ydHModHJhbnNmb3JtZWQpLFxuICAgICAgICAgICAgICAgIGhhc0ZvcmNlZFJlc29sdmVyczogdGhpcy5sb2NhbFN0YXRlLnNob3VsZEZvcmNlUmVzb2x2ZXJzKHRyYW5zZm9ybWVkKSxcbiAgICAgICAgICAgICAgICBjbGllbnRRdWVyeTogY2xpZW50UXVlcnksXG4gICAgICAgICAgICAgICAgc2VydmVyUXVlcnk6IHNlcnZlclF1ZXJ5LFxuICAgICAgICAgICAgICAgIGRlZmF1bHRWYXJzOiBnZXREZWZhdWx0VmFsdWVzKGdldE9wZXJhdGlvbkRlZmluaXRpb24odHJhbnNmb3JtZWQpKSxcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICB2YXIgYWRkID0gZnVuY3Rpb24gKGRvYykge1xuICAgICAgICAgICAgICAgIGlmIChkb2MgJiYgIXRyYW5zZm9ybUNhY2hlLmhhcyhkb2MpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybUNhY2hlLnNldChkb2MsIGNhY2hlRW50cnlfMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGFkZChkb2N1bWVudCk7XG4gICAgICAgICAgICBhZGQodHJhbnNmb3JtZWQpO1xuICAgICAgICAgICAgYWRkKGNsaWVudFF1ZXJ5KTt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9hLmNvbnRleHQsIGNvbnRleHQgPSBfYiA9PT0gdm9pZCAwID8ge30gOiBfYjtcbiAgICAgICAgcXVlcnkgPSB0aGlzLnRyYW5zZm9ybShxdWVyeSkuZG9jdW1lbnQ7XG4gICAgICAgIHZhcmlhYmxlcyA9IHRoaXMuZ2V0VmFyaWFibGVzKHF1ZXJ5LCB2YXJpYWJsZXMpO1xuICAgICAgICB2YXIgbWFrZU9ic2VydmFibGUgPSBmdW5jdGlvbiAodmFyaWFibGVzKSB7XG4gICAgICAgICAgICByZXR1cm4gX3RoaXMuZ2V0T2JzZXJ2YWJsZUZyb21MaW5rKHF1ZXJ5LCBjb250ZXh0LCB2YXJpYWJsZXMsIGZhbHNlKS5tYXAoZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIGlmIChmZXRjaFBvbGljeSAhPT0gJ25vLWNhY2hlJykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkV3JpdGVSZXN1bHQocmVzdWx0LCBlcnJvclBvbGljeSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLmNhY2hlLndyaXRlKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeTogcXVlcnksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0OiByZXN1bHQuZGF0YSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhSWQ6ICdST09UX1NVQlNDUklQVElPTicsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBfdGhpcy5icm9hZGNhc3RRdWVyaWVzKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChncmFwaFFMUmVzdWx0SGFzRXJyb3IocmVzdWx0KSkge1xuICAgICAgICAgICAgICAg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biAgICAgICAgICAgIGNvbnRleHQgPSBvcGVyYXRpb24uY29udGV4dDtcbiAgICAgICAgICAgIGlmIChkZWR1cGxpY2F0aW9uKSB7XG4gICAgICAgICAgICAgICAgdmFyIGJ5VmFyaWFibGVzXzEgPSBpbkZsaWdodExpbmtPYnNlcnZhYmxlc18xLmdldChzZXJ2ZXJRdWVyeSkgfHwgbmV3IE1hcCgpO1xuICAgICAgICAgICAgICAgIGluRmxpZ2h0TGlua09ic2VydmFibGVzXzEuc2V0KHNlcnZlclF1ZXJ5LCBieVZhcmlhYmxlc18xKTtcbiAgICAgICAgICAgICAgICB2YXIgdmFySnNvbl8xID0gSlNPTi5zdHJpbmdpZnkodmFyaWFibGVzKTtcbiAgICAgICAgICAgICAgICBvYnNlcnZhYmxlID0gYnlWYXJpYWJsZXNfMS5nZXQodmFySnNvbl8xKTtcbiAgICAgICAgICAgICAgICBpZiAoIW9ic2VydmFibGUpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGNvbmNhc3QgPSBuZXcgQ29uY2FzdChbXG4gICAgICAgICAgICAgICAgICAgICAgICBleGVjdXRlKGxpbmssIG9wZXJhdGlvbilcbiAgICAgICAgICAgICAgICAgICAgXSk7XG4gICAgICAgICAgICAgICAgICAgIGJ5VmFyaWFibGVzXzEuc2V0KHZhckpzb25fMSwgb2JzZXJ2YWJsZSA9IGNvbmNhc3QpO1xuICAgICAgICAgICAgICAgICAgICBjb25jYXN0LmNsZWFudXAoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJ5VmFyaWFibGVzXzEuZGVsZXRlKHZhckpzb25fMSkgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieVZhcmlhYmxlc18xLnNpemUgPCAxKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5GbGlnaHRMaW5rT2JzZXJ2YWJsZXNfMS5kZWxldGUoc2VydmVyUXVlcnkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBvYnNlcnZhYmxlID0gbmV3IENvbmNhc3QoW1xuICAgICAgICAgICAgICAgICAgICBleGVjdXRlKGxpbmssIG9wZXJhdGlvbilcbiAgICAgICAgICAgICAgICBdKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIG9ic2VydmFibGUgPSBuZXcgQ29uY2FzdChbXG4gICAgICAgICAgICAgICAgT2JzZXJ2YWJsZS5vZih7IGRhdGE6IHt9IH0pXG4gICAgICAgICAgICBdKTtcbiAgICAgICAgICAgIGNvbnRleHQgPSB0aGlzLnByZXBhcmVDb250ZXh0KGNvbnRleHQpO1xuICAgICAgICB9XG4gICAgICAgIHZhciBjbGllbnRRdWVyeSA9IHRoaXMudHJhbnNmb3JtKHF1ZXJ5KS5jbGllbnRRdWVyeTtcbiAgICAgICAgaWYgKGNsaWVudFF1ZXJ5KSB7XG4gICAgICAgICAgICBvYnNlcnZhYmxlID0gYXN5bmNNYXAob2JzZXJ2YWJsZSwgZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBfdGhpcy5sb2NhbFN0YXRlLnJ1blJlc29sdmVycyh7XG4gICAgICAgICAgICAgICAgICAgIGRvY3VtZW50OiBjbGllbnRRdWVyeSxcbiAgICAgICAgICAgICAgICAgICAgcmVtb3RlUmVzdWx0OiByZXN1bHQsXG4gICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG9ic2VydmFibGU7XG4gICAgfTtcbiAgICBRdWVyeU1hbmFnZXIucHJvdG90eXBlLmdldFJlc3VsdHNGcm9tTGluayA9IGZ1bmN0aW9uIChxdWVyeUluZm8sIGFsbG93Q2FjaGVXcml0ZSwgb3B0aW9ucykge1xuICAgICAgICB2YXIgbGFzdFJlcXVlc3RJZCA9IHF1ZXJ5SW5mby5sYXN0UmVxdWVzdElkO1xuICAgICAgICByZXR1cm4gYXN5bmNNYXAodGhpcy5nZXRPYnNlcnZhYmxlRnJvbUxpbmsocXVlcnlJbmZvLmRvY3VtZW50LCBvcHRpb25zLmNvbnRleHQsIG9wdGlvbnMudmFyaWFibGVzKSwgZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgdmFyIGhhc0Vycm9ycyA9IGlzTm9uRW1wdHlBcnJheShyZXN1bHQuZXJyb3JzKTtcbiAgICAgICAgICAgIGlmIChsYXN0UmVxdWVzdElkID49IHF1ZXJ5SW5mby5sYXN0UmVxdWVzdElkKSB7XG4gICAgICAgICAgICAgICAgaWYgKGhhc0Vycm9ycyAmJiBvcHRpb25zLmVycm9yUG9saWN5ID09PSBcIm5vbmVcIikge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBxdWVyeUluZm8ubWFya0Vycm9yKG5ldyBBcG9sbG9FcnJvcih7XG4gICAgICAgICAgICAgICAgICAgICAgICBncmFwaFFMRXJyb3JzOiByZXN1bHQuZXJyb3JzLFxuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHF1ZXJ5SW5mby5tYXJrUmVzdWx0KHJlc3VsdCwgb3B0aW9ucywgYWxsb3dDYWNoZVdyaXRlKTtcbiAgICAgICAgICAgICAgICBxdWVyeUluZm8ubWFya1JlYWR5KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgYXFyID0ge1xuICAgICAgICAgICAgICAgIGRhdGE6IHJlc3VsdC5kYXRhLFxuICAgICAgICAgICAgICAgIGxvYWRpbmc6IGZhbHN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VsbCA6IHsgcGFydGlhbDogdHJ1ZSB9KSkpOyB9O1xuICAgICAgICAgICAgaWYgKF90aGlzLnRyYW5zZm9ybShxdWVyeSkuaGFzRm9yY2VkUmVzb2x2ZXJzKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLmxvY2FsU3RhdGUucnVuUmVzb2x2ZXJzKHtcbiAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQ6IHF1ZXJ5LFxuICAgICAgICAgICAgICAgICAgICByZW1vdGVSZXN1bHQ6IHsgZGF0YTogZGF0YSB9LFxuICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBjb250ZXh0LFxuICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IHZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgb25seVJ1bkZvcmNlZFJlc29sdmVyczogdHJ1ZSxcbiAgICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uIChyZXNvbHZlZCkgeyByZXR1cm4gZnJvbURhdGEocmVzb2x2ZWQuZGF0YSk7IH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGZyb21EYXRhKGRhdGEpO1xuICAgICAgICB9O1xuICAgICAgICB2YXIgcmVzdWx0c0Zyb21MaW5rID0gZnVuY3Rpb24gKGFsbG93Q2FjaGVXcml0ZSkge1xuICAgICAgICAgICAgcmV0dXJuIF90aGlzLmdldFJlc3VsdHNGcm9tTGluayhxdWVyeUluZm8sIGFsbG93Q2FjaGVXcml0ZSwge1xuICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgICAgICAgICAgZmV0Y2hQb2xpY3k6IGZldGNoUG9saWN5LFxuICAgICAgICAgICAgICAgIGVycm9yUG9saWN5OiBlcnJvclBvbGljeSxcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9O1xuICAgICAgICBzd2l0Y2ggKGZldGNoUG9saWN5KSB7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgY2FzZSBcImNhY2hlLWZpcnN0XCI6IHtcbiAgICAgICAgICAgICAgICB2YXIgZGlmZiA9IHJlYWRDYWNoZSgpO1xuICAgICAgICAgICAgICAgIGlmIChkaWZmLmNvbXBsZXRlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbXG4gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzRnJvbUNhY2hlKGRpZmYsIHF1ZXJ5SW5mby5tYXJrUmVhZHkoKSksXG4gICAgICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXR1cm5QYXJ0aWFsRGF0YSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0c0Zyb21DYWNoZShkaWZmKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNGcm9tTGluayh0cnVlKSxcbiAgICAgICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0c0Zyb21MaW5rKHRydWUpLFxuICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXNlIFwiY2FjaGUtYW5kLW5ldHdvcmtcIjoge1xuICAgICAgICAgICAgICAgIHZhciBkaWZmID0gcmVhZENhY2hlKCk7XG4gICAgICAgICAgICAgICAgaWYgKGRpZmYuY29tcGxldGUgfHwgcmV0dXJuUGFydGlhbERhdGEpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNGcm9tQ2FjaGUoZGlmZiksXG4gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzRnJvbUxpbmsodHJ1ZSksXG4gICAgICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBbXG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdHNGcm9tTGluayh0cnVlKSxcbiAgICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2FzZSBcImNhY2hlLW9ubHlcIjpcbiAgICAgICAgICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgICAgICAgICByZXN1bHRzRnJvbUNhY2hlKHJlYWRDYWNoZSgpLCBxdWVyeUluZm8ubWFya1JlYWR5KCkpLFxuICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICBjYXNlIFwibmV0d29yay1vbmx5XCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIFtyZXN1bHRzRnJvbUxpbmsodHJ1ZSldO1xuICAgICAgICAgICAgY2FzZSBcIm5vLWNhY2hlXCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIFtyZXN1bHRzRnJvbUxpbmsoZmFsc2UpXTtcbiAgICAgICAgICAgIGNhc2UgXCJzdGFuZGJ5XCI6XG4gICAgICAgICAgICAgICAgcmV0dXJuIFtdO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBRdWVyeU1hbmFnZXIucHJvdG90eXBlLmdldFF1ZXJ5ID0gZnVuY3Rpb24gKHF1ZXJ5SWQpIHtcbiAgICAgICAgaWYgKHF1ZXJ5SWQgJiYgIXRoaXMucXVlcmllcy5oYXMocXVlcnlJZCkpIHtcbiAgICAgICAgICAgIHRoaXMucXVlcmllcy5zZXQocXVlcnlJZCwgbmV3IFF1ZXJ5SW5mbyh0aGlzLmNhY2hlKSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMucXVlcmllcy5nZXQocXVlcnlJZCk7XG4gICAgfTtcbiAgICBRdWVyeU1hbmFnZXIucHJvdG90eXBlLnByZXBhcmVDb250ZXh0ID0gZnVuY3Rpb24gKGNvbnRleHQpIHtc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0ZXJzQnlJZF8xW2lkXSwgdXBkYXRlciA9IF9hLnVwZGF0ZXIsIF9iID0gX2EucXVlcnlJbmZvLCBkb2N1bWVudCA9IF9iLmRvY3VtZW50LCB2YXJpYWJsZXMgPSBfYi52YXJpYWJsZXM7XG4gICAgICAgICAgICAgICAgdmFyIF9jID0gY2FjaGUuZGlmZih7XG4gICAgICAgICAgICAgICAgICAgIHF1ZXJ5OiBkb2N1bWVudCxcbiAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgIHJldHVyblBhcnRpYWxEYXRhOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICBvcHRpbWlzdGljOiBmYWxzZSxcbiAgICAgICAgICAgICAgICB9KSwgY3VycmVudFF1ZXJ5UmVzdWx0ID0gX2MucmVzdWx0LCBjb21wbGV0ZSA9IF9jLmNvbXBsZXRlO1xuICAgICAgICAgICAgICAgIGlmIChjb21wbGV0ZSAmJiBjdXJyZW50UXVlcnlSZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIG5leHRRdWVyeVJlc3VsdCA9IHVwZGF0ZXIoY3VycmVudFF1ZXJ5UmVzdWx0LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBtdXRhdGlvblJlc3VsdDogbXV0YXRpb24ucmVzdWx0LFxuICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnlOYW1lOiBnZXRPcGVyYXRpb25OYW1lKGRvY3VtZW50KSB8fCB1bmRlZmluZWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBxdWVyeVZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5leHRRdWVyeVJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2FjaGVXcml0ZXNfMS5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQ6IG5leHRRdWVyeVJlc3VsdCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhSWQ6ICdST09UX1FVRVJZJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeTogZG9jdW1lbnQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGNhY2hlLnBlcmZvcm1UcmFuc2FjdGlvbihmdW5jdGlvbiAoYykge1xuICAgICAgICAgICAgY2FjaGVXcml0ZXNfMS5mb3JFYWNoKGZ1bmN0aW9uICh3cml0ZSkgeyByZXR1cm4gYy53cml0ZSh3cml0ZSk7IH0pO1xuICAgICAgICAgICAgdmFyIHVwZGF0ZSA9IG11dGF0aW9uLnVwZGF0ZTtcbiAgICAgICAgICAgIGlmICh1cGRhdGUpIHtcbiAgICAgICAgICAgICAgICB1cGRhdGUoYywgbXV0YXRpb24ucmVzdWx0KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSwgbnVsbCk7XG4gICAgfVxufVxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9UXVlcnlNYW5hZ2VyLmpzLm1hcCIsImltcG9ydCB7IE5ldHdvcmtTdGF0dXMgfSBmcm9tIFwiLi9uZXR3b3JrU3RhdHVzLmpzXCI7XG5pbXBvcnQgeyBjb21wYWN0IH0gZnJvbSBcIi4uL3V0aWxpdGllcy9pbmRleC5qc1wiO1xuaW1wb3J0IHsgaW52YXJpYW50IH0gZnJvbSAndHMtaW52YXJpYW50JztcbnZhciBSZW9ic2VydmVyID0gKGZ1bmN0aW9uICgpIHtcbiAgICBmdW5jdGlvbiBSZW9ic2VydmVyKG9ic2VydmVyLCBvcHRpb25zLCBmZXRjaCwgc2hvdWxkRmV0Y2gpIHtcbiAgICA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Zlci5wcm90b3R5cGUuc3RvcCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKHRoaXMuY29uY2FzdCkge1xuICAgICAgICAgICAgdGhpcy5jb25jYXN0LnJlbW92ZU9ic2VydmVyKHRoaXMub2JzZXJ2ZXIpO1xuICAgICAgICAgICAgZGVsZXRlIHRoaXMuY29uY2FzdDtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5wb2xsaW5nSW5mbykge1xuICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRoaXMucG9sbGluZ0luZm8udGltZW91dCk7XG4gICAgICAgICAgICB0aGlzLm9wdGlvbnMucG9sbEludGVydmFsID0gMDtcbiAgICAgICAgICAgIHRoaXMudXBkYXRlUG9sbGluZygpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBSZW9ic2VydmVyLnByb3RvdHlwZS51cGRhdGVQb2xsaW5nID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgX2EgPSB0aGlzLCBwb2xsaW5nSW5mbyA9IF9hLnBvbGxpbmdJbmZvLCBwb2xsSW50ZXJ2YWwgPSBfYS5vcHRpb25zLnBvbGxJbnRlcnZhbDtcbiAgICAgICAgaWYgKCFwb2xsSW50ZXJ2YWwpIHtcbiAgICAgICAgICAgIGlmIChwb2xsaW5nSW5mbykge1xuICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dChwb2xsaW5nSW5mby50aW1lb3V0KTtcbiAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5wb2xsaW5nSW5mbztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBpZiAocG9sbGluZ0luZm8gJiZcbiAgICAgICAgICAgIHBvbGxpbmdJbmZvLmludGVydmFsID09PSBwb2xsSW50ZXJ2YWwpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgPyBpbnZhcmlhbnQocG9sbEludGVydmFsLCAyMCkgOiBpbnZhcmlhbnQocG9sbEludGVydmFsLCAnQXR0ZW1wdGVkIHRvIHN0YXJ0IGEgcG9sbGluZyBxdWVyeSB3aXRob3V0IGEgcG9sbGluZyBpbnRlcnZhbC4nKTtcbiAgICAgICAgaWYgKHRoaXMuc2hvdWxkRmV0Y2ggPT09IGZhbHNlKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGluZm8gPSBwb2xsaW5nSW5mbyB8fCAodGhpcy5wb2xsaW5nSW5mbyA9IHt9KTtcbiAgICAgICAgaW5mby5pbnRlcnZhbCA9IHBvbGxJbnRlcnZhbDtcbiAgICAgICAgdmFyIG1heWJlRmV0Y2ggPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoX3RoaXMucG9sbGluZ0luZm8pIHtcbiAgICAgICAgICAgICAgICBpZiAoX3RoaXMuc2hvdWxkRmV0Y2ggJiYgX3RoaXMuc2hvdWxkRmV0Y2goKSkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5yZW9ic2VydmUoe1xuICAgICAgICAgICAgICAgICAgICAgICAgZmV0Y2hQb2xpY3k6IFwibmV0d29yay1vbmx5XCIsXG4gICAgICAgICAgICAgICAgICAgICAgICBuZXh0RmV0Y2hQb2xpY3k6IF90aGlzLm9wdGlvbnMuZmV0Y2hQb2xpY3kgfHwgXCJjYWNoZS1maXJzdFwiLFxuICAgICAgICAgICAgICAgICAgICB9LCBOZXR3b3JrU3RhdHVzLnBvbGwpLnRoZW4ocG9sbCwgcG9sbCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBwb2xsKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgO1xuICAgICAg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LCBsZWZ0LCByaWdodCkge1xuICAgICAgICB2YXIgbGVmdExpbmsgPSB0b0xpbmsobGVmdCk7XG4gICAgICAgIHZhciByaWdodExpbmsgPSB0b0xpbmsocmlnaHQgfHwgbmV3IEFwb2xsb0xpbmsocGFzc3Rocm91Z2gpKTtcbiAgICAgICAgaWYgKGlzVGVybWluYXRpbmcobGVmdExpbmspICYmIGlzVGVybWluYXRpbmcocmlnaHRMaW5rKSkge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBBcG9sbG9MaW5rKGZ1bmN0aW9uIChvcGVyYXRpb24pIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGVzdChvcGVyYXRpb24pXG4gICAgICAgICAgICAgICAgICAgID8gbGVmdExpbmsucmVxdWVzdChvcGVyYXRpb24pIHx8IE9ic2VydmFibGUub2YoKVxuICAgICAgICAgICAgICAgICAgICA6IHJpZ2h0TGluay5yZXF1ZXN0KG9wZXJhdGlvbikgfHwgT2JzZXJ2YWJsZS5vZigpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gbmV3IEFwb2xsb0xpbmsoZnVuY3Rpb24gKG9wZXJhdGlvbiwgZm9yd2FyZCkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0ZXN0KG9wZXJhdGlvbilcbiAgICAgICAgICAgICAgICAgICAgPyBsZWZ0TGluay5yZXF1ZXN0KG9wZXJhdGlvbiwgZm9yd2FyZCkgfHwgT2JzZXJ2YWJsZS5vZigpXG4gICAgICAgICAgICAgICAgICAgIDogcmlnaHRMaW5rLnJlcXVlc3Qob3BlcmF0aW9uLCBmb3J3YXJkKSB8fCBPYnNlcnZhYmxlLm9mKCk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgQXBvbGxvTGluay5leGVjdXRlID0gZnVuY3Rpb24gKGxpbmssIG9wZXJhdGlvbikge1xuICAgICAgICByZXR1cm4gKGxp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gICAgICAgdmFyIGNsaWVudEF3YXJlbmVzc0hlYWRlcnMgPSB7fTtcbiAgICAgICAgaWYgKGNvbnRleHQuY2xpZW50QXdhcmVuZXNzKSB7XG4gICAgICAgICAgICB2YXIgX2EgPSBjb250ZXh0LmNsaWVudEF3YXJlbmVzcywgbmFtZV8xID0gX2EubmFtZSwgdmVyc2lvbiA9IF9hLnZlcnNpb247XG4gICAgICAgICAgICBpZiAobmFtZV8xKSB7XG4gICAgICAgICAgICAgICAgY2xpZW50QXdhcmVuZXNzSGVhZGVyc1snYXBvbGxvZ3JhcGhxbC1jbGllbnQtbmFtZSddID0gbmFtZV8xO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHZlcnNpb24pIHtcbiAgICAgICAgICAgICAgICBjbGllbnRBd2FyZW5lc3NIZWFkZXJzWydhcG9sbG9ncmFwaHFsLWNsaWVudC12ZXJzaW9uJ10gPSB2ZXJzaW9uO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHZhciBjb250ZXh0SGVhZGVycyA9IF9fYXNzaWduKF9fYXNzaWduKHt9LCBjbGllbnRBd2FyZW5lc3NIZWFkZXJzKSwgY29udGV4dC5oZWFkZXJzKTtcbiAgICAgICAgdmFyIGNvbnRleHRDb25maWcgPSB7XG4gICAgICAgICAgICBodHRwOiBjb250ZXh0Lmh0dHAsXG4gICAgICAgICAgICBvcHRpb25zOiBjb250ZXh0LmZldGNoT3B0aW9ucyxcbiAgICAgICAgICAgIGNyZWRlbnRpYWxzOiBjb250ZXh0LmNyZWRlbnRpYWxzLFxuICAgICAgICAgICAgaGVhZGVyczogY29udGV4dEhlYWRlcnMsXG4gICAgICAgIH07XG4gICAgICAgIHZhciBfYiA9IHNlbGVjdEh0dHBPcHRpb25zQW5kQm9keShvcGVyYXRpb24sIGZhbGxiYWNrSHR0cENvbmZpZywgbGlua0NvbmZpZywgY29udGV4dENvbmZpZyksIG9wdGlvbnMgPSBfYi5vcHRpb25zLCBib2R5ID0gX2IuYm9keTtcbiAgICAgICAgdmFyIGNvbnRyb2xsZXI7XG4gICAgICAgIGlmICghb3B0aW9ucy5zaWduYWwpIHtcbiAgICAgICAgICAgIHZhciBfYyA9IGNyZWF0ZVNpZ25hbElmU3VwcG9ydGVkKCksIF9jb250cm9sbGVyID0gX2MuY29udHJvbGxlciwgc2lnbmFsID0gX2Muc2lnbmFsO1xuICAgICAgICAgICAgY29udHJvbGxlciA9IF9jb250cm9sbGVyO1xuICAgICAgICAgICAgaWYgKGNvbnRyb2xsZXIpXG4gICAgICAgICAgICAgICAgb3B0aW9ucy5zaWduYWwgPSBzaWduYWw7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGRlZmluaXRpb25Jc011dGF0aW9uID0gZnVuY3Rpb24gKGQpIHtcbiAgICAgICAgICAgIHJldHVybiBkLmtpbmQgPT09ICdPcGVyYXRpb25EZWZpbml0aW9uJyAmJiBkLm9wZXJhdGlvbiA9PT0gJ211dGF0aW9uJztcbiAgICAgICAgfTtcbiAgICAgICAgaWYgKHVzZUdFVEZvclF1ZXJpZXMgJiZcbiAgICAgICAgICAgICFvcGVyYXRpb24ucXVlcnkuZGVmaW5pdGlvbnMuc29tZShkZWZpbml0aW9uSXNNdXRhdGlvbikpIHtcbiAgICAgICAgICAgIG9wdGlvbnMubWV0aG9kID0gJ0dFVCc7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKG9wdGlvbnMubWV0aG9kID09PSAnR0VUJykge1xuICAgICAgICAgICAgdmFyIF9kID0gcmV3cml0ZVVSSUZvckdFVChjaG9zZW5VUkksIGJvZHkpLCBuZXdVUkkgPSBfZC5uZXdVUkksIHBhcnNlRXJyb3IgPSBfZC5wYXJzZUVycm9yO1xuICAgICAgICAgICAgaWYgKHBhcnNlRXJyb3IpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZnJvbUVycm9yKHBhcnNlRXJyb3IpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2hvc2VuVVJJID0gbmV3VVJJO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBvcHRpb25zLmJvZHkgPSBzZXJpYWxpemVGZXRjaFBhcmFtZXRlcihib2R5LCAnUGF5bG9hZCcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKHBhcnNlRXJyb3IpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZnJvbUVycm9yKHBhcnNlRXJyb3IpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBuZXcgT2JzZXJ2YWJsZShmdW5jdGlvbiAob2JzZXJ2ZXIpIHtcbiAgICAgICAgICAgIGZldGNoZXIoY2hvc2VuVVJJLCBvcHRpb25zKVxuICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uIChyZXNwb25zZSkge1xuICAgICAgICAgICAgICAgIG9wZXJhdGlvbi5zZXRDb250ZXh0KHsgcmVzcG9uc2U6IHJlc3BvbnNlIH0pO1xuICAgICAgICAgICAgICAgIHJldHVybiByZXNwb25zZTtcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgLnRoZW4ocGFyc2VBbmRDaGVja0h0dHBSZXNwb25zZShvcGVyYXRpb24pKVxuICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uIChyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHJlc3VsdCk7XG4gICAgICAgICAgICAgICAgb2JzZXJ2ZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAuY2F0Y2goZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIGlmIChlcnIubmFtZSA9PT0gJ0Fib3J0RXJyb3InKVxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgaWYgKGVy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ZlckVycm9yLmpzLm1hcCIsImltcG9ydCB7IGludmFyaWFudCB9IGZyb20gJ3RzLWludmFyaWFudCc7XG5leHBvcnQgZnVuY3Rpb24gdG9Qcm9taXNlKG9ic2VydmFibGUpIHtcbiAgICB2YXIgY29tcGxldGVkID0gZmFsc2U7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgb2JzZXJ2YWJsZS5zdWJzY3JpYmUoe1xuICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICBpZiAoY29tcGxldGVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiB8fCBpbnZhcmlhbnQud2FybihcIlByb21pc2UgV3JhcHBlciBkb2VzIG5vdCBzdXBwb3J0IG11bHRpcGxlIHJlc3VsdHMgZnJvbSBPYnNlcnZhYmxlXCIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgY29tcGxldGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShkYXRhKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZXJyb3I6IHJlamVjdCxcbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD10b1Byb21pc2UuanMubWFwIiwiaW1wb3J0IHsgZ2V0T3BlcmF0aW9uTmFtZSB9IGZyb20gXCIuLi8uLi91dGlsaXRpZXMvaW5kZXguanNcIjtcbmV4cG9ydCBmdW5jdGlvbiB0cmFuc2Zvcm1PcGVyYXRpb24ob3BlcmF0aW9uKSB7XG4gICAgdmFyIHRyYW5zZm9ybWVkT3BlcmF0aW9uID0ge1xuICAgICAgICB2YXJpYWJsZXM6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HZhbCkpIHtcbiAgICAgICAgY2FzZSBcIltvYmplY3QgQXJyYXldXCI6IHtcbiAgICAgICAgICAgIHNlZW4gPSBzZWVuIHx8IG5ldyBNYXA7XG4gICAgICAgICAgICBpZiAoc2Vlbi5oYXModmFsKSlcbiAgICAgICAgICAgICAgICByZXR1cm4gc2Vlbi5nZXQodmFsKTtcbiAgICAgICAgICAgIHZhciBjb3B5XzEgPSB2YWwuc2xpY2UoMCk7XG4gICAgICAgICAgICBzZWVuLnNldCh2YWwsIGNvcHlfMSk7XG4gICAgICAgICAgICBjb3B5XzEuZm9yRWFjaChmdW5jdGlvbiAoY2hpbGQsIGkpIHtcbiAgICAgICAgICAgICAgICBjb3B5XzFbaV0gPSBjbG9uZURlZXBIZWxwZXIoY2hpbGQsIHNlZW4pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm4gY29weV8xO1xuICAgICAgICB9XG4gICAgICAgIGNhc2UgXCJbb2JqZWN0IE9iamVjdF1cIjoge1xuICAgICAgICAgICAgc2VlbiA9IHNlZW4gfHwgbmV3IE1hcDtcbiAgICAgICAgICAgIGlmIChzZWVuLmhhcyh2YWwpKVxuICAgICAgICAgICAgICAgIHJldHVybiBzZWVuLmdldCh2YWwpO1xuICAgICAgICAgICAgdmFyIGNvcHlfMiA9IE9iamVjdC5jcmVhdGUoT2JqZWN0LmdldFByb3RvdHlwZU9mKHZhbCkpO1xuICAgICAgICAgICAgc2Vlbi5zZXQodmFsLCBjb3B5XzIpO1xuICAgICAgICAgICAgT2JqZWN0LmtleXModmFsKS5mb3JFYWNoKGZ1bmN0aW9uIChrZXkpIHtcbiAgICAgICAgICAgICAgICBjb3B5XzJba2V5XSA9IGNsb25lRGVlcEhlbHBlcih2YWxba2V5XSwgc2Vlbik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybiBjb3B5XzI7XG4gICAgICAgIH1cbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHJldHVybiB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Sh0YXJnZXQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldFtzb3VyY2VLZXldID0gcmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0YXJnZXQgPSBfdGhpcy5zaGFsbG93Q29weUZvck1lcmdlKHRhcmdldCk7XG4gICAgICAgICAgICAgICAgICAgIHRhcmdldFtzb3VyY2VLZXldID0gc291cmNlW3NvdXJjZUtleV07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm4gdGFyZ2V0O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzb3VyY2U7XG4gICAgfTtcbiAgICBEZWVwTWVyZ2VyLnByb3RvdHlwZS5zaGFsbG93Q29weUZvck1lcmdlID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgIGlmIChpc09iamVjdCh2YWx1ZSkgJiYgIXRoaXMucGFzdENvcGllcy5oYXModmFsdWUpKSB7XG4gICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlLnNsaWNlKDApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdmFsdWUgPSBfX2Fzc2lnbih7IF9fcHJvdG9fXzogT2JqZWN0LmdldFByb3RvdHlwZU9mKHZhbHVlKSB9LCB2YWx1ZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnBhc3RDb3BpZXMuYWRkKHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgfTtcbiAgICByZXR1cm4gRGVlcE1lcmdlcjtcbn0oKSk7XG5leHBvcnQgeyBEZWVwTWV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nRzLmxlbmd0aCA9PT0gMSwgNDMpIDogaW52YXJpYW50KGZyYWdtZW50cy5sZW5ndGggPT09IDEsIFwiRm91bmQgXCIgKyBmcmFnbWVudHMubGVuZ3RoICsgXCIgZnJhZ21lbnRzLiBgZnJhZ21lbnROYW1lYCBtdXN0IGJlIHByb3ZpZGVkIHdoZW4gdGhlcmUgaXMgbm90IGV4YWN0bHkgMSBmcmFnbWVudC5cIik7XG4gICAgICAgIGFjdHVhbEZyYWdtZW50TmFtZSA9IGZyYWdtZW50c1swXS5uYW1lLnZhbHVlO1xuICAgIH1cbiAgICB2YXIgcXVlcnkgPSBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgZG9jdW1lbnQpLCB7IGRlZmluaXRpb25zOiBfX3NwcmVhZEFycmF5cyhbXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAga2luZDogJ09wZXJhdGlvbkRlZmluaXRpb24nLFxuICAgICAgICAgICAgICAgIG9wZXJhdGlvbjogJ3F1ZXJ5JyxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25TZXQ6IHtcbiAgICAgICAgICAgICAgICAgICAga2luZDogJ1NlbGVjdGlvblNldCcsXG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvbnM6IFtcbiAgICAgICAgICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiAnRnJhZ21lbnRTcHJlYWQnLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2luZDogJ05hbWUnLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogYWN0dWFsRnJhZ21lbnROYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBdLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9XG4gIC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F0aW9uID09PSAnbXV0YXRpb24nIHx8XG4gICAgICAgICAgICAgICAgb3BlcmF0aW9uID09PSAnc3Vic2NyaXB0aW9uJykge1xuICAgICAgICAgICAgICAgIHJldHVybiBkZWZpbml0aW9uO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChkZWZpbml0aW9uLmtpbmQgPT09ICdGcmFnbWVudERlZmluaXRpb24nICYmICFmcmFnbWVudERlZmluaXRpb24pIHtcbiAgICAgICAgICAgIGZyYWdtZW50RGVmaW5pdGlvbiA9IGRlZmluaXRpb247XG4gICAgICAgIH1cbiAgICB9XG4gICAgaWYgKGZyYWdtZW50RGVmaW5pdGlvbikge1xuICAgICAgICByZXR1cm4gZnJhZ21lbnREZWZpbml0aW9uO1xuICAgIH1cbiAgICB0aHJvdyBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgPyBuZXcgSW52YXJpYW50RXJyb3IoNTIpIDogbmV3IEludmFyaWFudEVycm9yKCdFeHBlY3RlZCBhIHBhcnNlZCBHcmFwaFFMIHF1ZXJ5IHdpdGggYSBxdWVyeSwgbXV0YXRpb24sIHN1YnNjcmlwdGlvbiwgb3IgYSBmcmFnbWVudC4nKTtcbn1cbmV4cG9ydCBmdW5jdGlvbiBnZXREZWZhdWx0VmFsdWVzKGRlZmluaXRpb24pIHtcbiAgICB2YXIgZGVmYXVsdFZhbHVlcyA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgdmFyIGRlZnMgPSBkZWZpbml0aW9uICYmIGRlZmluaXRpb24udmFyaWFibGVEZWZpbml0aW9ucztcbiAgICBpZiAoZGVmcyAmJiBkZWZzLmxlbmd0aCkge1xuICAgICAgICBkZWZzLmZvckVhY2goZnVuY3Rpb24gKGRlZikge1xuICAgICAgICAgICAgaWYgKGRlZi5kZWZhdWx0VmFsdWUpIHtcbiAgICAgICAgICAgICAgICB2YWx1ZVRvT2JqZWN0UmVwcmVzZW50YXRpb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2YXIgZnJhZ21lbnRTcHJlYWRzSW5Vc2UgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgIHZhciBmcmFnbWVudFNwcmVhZHNUb1JlbW92ZSA9IFtdO1xuICAgIHZhciBtb2RpZmllZERvYyA9IG51bGxJZkRvY0lzRW1wdHkodmlzaXQoZG9jLCB7XG4gICAgICAgIFZhcmlhYmxlOiB7XG4gICAgICAgICAgICBlbnRlcjogZnVuY3Rpb24gKG5vZGUsIF9rZXksIHBhcmVudCkge1xuICAgICAgICAgICAgICAgIGlmIChwYXJlbnQua2luZCAhPT0gJ1ZhcmlhYmxlRGVmaW5pdGlvbicpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzSW5Vc2Vbbm9kZS5uYW1lLnZhbHVlXSA9IHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgICAgRmllbGQ6IHtcbiAgICAgICAgICAgIGVudGVyOiBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICAgICAgICAgIGlmIChkaXJlY3RpdmVzICYmIG5vZGUuZGlyZWN0aXZlcykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgc2hvdWxkUmVtb3ZlRmllbGQgPSBkaXJlY3RpdmVzLnNvbWUoZnVuY3Rpb24gKGRpcmVjdGl2ZSkgeyByZXR1cm4gZGlyZWN0aXZlLnJlbW92ZTsgfSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzaG91bGRSZW1vdmVGaWVsZCAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5kaXJlY3RpdmVzICYmXG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmRpcmVjdGl2ZXMuc29tZShnZXREaXJlY3RpdmVNYXRjaGVyKGRpcmVjdGl2ZXMpKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUuYXJndW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hcmd1bWVudHMuZm9yRWFjaChmdW5jdGlvbiAoYXJnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcmcudmFsdWUua2luZCA9PT0gJ1ZhcmlhYmxlJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzVG9SZW1vdmUucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogYXJnLnZhbHVlLm5hbWUudmFsdWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUuc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0QWxsRnJhZ21lbnRTcHJlYWRzRnJvbVNlbGVjdGlvblNldChub2RlLnNlbGVjdGlvblNldCkuZm9yRWFjaChmdW5jdGlvbiAoZnJhZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFnbWVudFNwcmVhZHNUb1JlbW92ZS5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGZyYWcubmFtZS52YWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICAgIEZyYWdtZW50U3ByZWFkOiB7XG4gICAgICAgICAgICBlbnRlc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JuIG1vZGlmaWVkRG9jO1xufVxuZXhwb3J0IGZ1bmN0aW9uIGFkZFR5cGVuYW1lVG9Eb2N1bWVudChkb2MpIHtcbiAgICByZXR1cm4gdmlzaXQoY2hlY2tEb2N1bWVudChkb2MpLCB7XG4gICAgICAgIFNlbGVjdGlvblNldDoge1xuICAgICAgICAgICAgZW50ZXI6IGZ1bmN0aW9uIChub2RlLCBfa2V5LCBwYXJlbnQpIHtcbiAgICAgICAgICAgICAgICBpZiAocGFyZW50ICYmXG4gICAgICAgICAgICAgICAgICAgIHBhcmVudC5raW5kID09PSAnT3BlcmF0aW9uRGVmaW5pdGlvbicpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YXIgc2VsZWN0aW9ucyA9IG5vZGUuc2VsZWN0aW9ucztcbiAgICAgICAgICAgICAgICBpZiAoIXNlbGVjdGlvbnMpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YXIgc2tpcCA9IHNlbGVjdGlvbnMuc29tZShmdW5jdGlvbiAoc2VsZWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAoaXNGaWVsZChzZWxlY3Rpb24pICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAoc2VsZWN0aW9uLm5hbWUudmFsdWUgPT09ICdfX3R5cGVuYW1lJyB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvbi5uYW1lLnZhbHVlLmxhc3RJbmRleE9mKCdfXycsIDApID09PSAwKSk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgaWYgKHNraXApIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YXIgZmllbGQgPSBwYXJlbnQ7XG4gICAgICAgICAgICAgICAgaWYgKGlzRmllbGQoZmllbGQpICYmXG4gICAgICAgICAgICAgICAgICAgIGZpZWxkLmRpcmVjdGl2ZXMgJiZcbiAgICAgICAgICAgICAgICAgICAgZmllbGQuZGlyZWN0aXZlcy5zb21lKGZ1bmN0aW9uIChkKSB7IHJldHVybiBkLm5hbWUudmFsdWUgPT09ICdleHBvcnQnOyB9KSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgbm9kZSksIHsgc2VsZWN0aW9uczogX19zcHJlYWRBcnJheXMoc2VsZWN0aW9ucywgW1RZUEVOQU1FX0ZJRUxEXSkgfSk7XG4gICAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgIH0pO1xufVxuYWRkVHlwZW5hbWVUb0RvY3VtZW50LmFkZGVkID0gZnVuY3Rpb24gKGZpZWxkKSB7XG4gICAgcmV0dXJuIGZpZWxkID09PSBUWVBFTkFNRV9GSUVMRDtcbn07XG52YXIgY29ubmVjdGlvblJlbW92ZUNvbmZpZyA9IHtcbiAgICB0ZXN0OiBmdW5jdGlvbiAoZGlyZWN0aXZlKSB7XG4gICAgICAgIHZhciB3aWxsUmVtb3ZlID0gZGlyZWN0aXZlLm5hbWUudmFsdWUgPT09ICdjb25uZWN0aW9uJztcbiAgICAgICAgaWYgKHdpbGxSZW1vdmUpIHtcbiAgICAgICAgICAgIGlmICghZGlyZWN0aXZlLmFyZ3VtZW50cyB8fFxuICAgICAgICAgICAgICAgICFkaXJlY3RpdmUuYXJndW1lbnRzLnNvbWUoZnVuY3Rpb24gKGFyZykgeyByZXR1cm4gYXJnLm5hbWUudmFsdWUgPT09ICdrZXknOyB9KSkge1xuICAgICAgICAgICAgICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiB8fCBpbnZhcmlhbnQud2FybignUmVtb3ZpbmcgYW4gQGN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1bWVudChjb25maWcsIGRvYykge1xuICAgIHZhciBhcmdNYXRjaGVyID0gZ2V0QXJndW1lbnRNYXRjaGVyKGNvbmZpZyk7XG4gICAgcmV0dXJuIG51bGxJZkRvY0lzRW1wdHkodmlzaXQoZG9jLCB7XG4gICAgICAgIE9wZXJhdGlvbkRlZmluaXRpb246IHtcbiAgICAgICAgICAgIGVudGVyOiBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgbm9kZSksIHsgdmFyaWFibGVEZWZpbml0aW9uczogbm9kZS52YXJpYWJsZURlZmluaXRpb25zID8gbm9kZS52YXJpYWJsZURlZmluaXRpb25zLmZpbHRlcihmdW5jdGlvbiAodmFyRGVmKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWNvbmZpZy5zb21lKGZ1bmN0aW9uIChhcmcpIHsgcmV0dXJuIGFyZy5uYW1lID09PSB2YXJEZWYudmFyaWFibGUubmFtZS52YWx1ZTsgfSk7XG4gICAgICAgICAgICAgICAgICAgIH0pIDogW10gfSk7XG4gICAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgICBGaWVsZDoge1xuICAgICAgICAgICAgZW50ZXI6IGZ1bmN0aW9uIChub2RlKSB7XG4gICAgICAgICAgICAgICAgdmFyIHNob3VsZFJlbW92ZUZpZWxkID0gY29uZmlnLnNvbWUoZnVuY3Rpb24gKGFyZ0NvbmZpZykgeyByZXR1cm4gYXJnQ29uZmlnLnJlbW92ZTsgfSk7XG4gICAgICAgICAgICAgICAgaWYgKHNob3VsZFJlbW92ZUZpZWxkKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBhcmdNYXRjaENvdW50XzEgPSAwO1xuICAgICAgICAgICAgICAgICAgICBpZiAobm9kZS5hcmd1bWVudHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuYXJndW1lbnRzLmZvckVhY2goZnVuY3Rpb24gKGFyZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcmdNYXRjaGVyKGFyZykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJnTWF0Y2hDb3VudF8xICs9IDE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ01hdGNoQ291bnRfMSA9PT0gMSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgICBBcmd1bWVudDoge1xuICAgICAgICAgICAgZW50ZXI6IGZ1bmN0aW9uIChub2RlKSB7XG4gICAgICAgICAgICAgICAgaWYgKGFyZ01hdGNoZXIobm9kZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICB9KSk7XG59XG5leHBvcnQgZnVuY3Rpb24gcmVtb3ZlRnJhZ21lbnRTcHJlYWRGcm9tRG9jdW1lbnQoY29uZmlnLCBkb2MpIHtcbiAgICBmdW5jdGlvbiBlbnRlcihub2RlKSB7XG4gICAgICAgIGlmIChjb25maWcuc29tZShmdW5jdGlvbiAoZGVmKSB7IHJldHVybiBkZWYubmFtZSA9PT0gbm9kZS5uYW1lLnZhbHVlOyB9KSkge1xuICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG51bGxJZkRvY0lzRW1wdHkodmlzaXQoZG9jLCB7XG4gICAgICAgIEZyYWdtZW50U3ByZWFkOiB7IGVudGVyOiBlbnRlciB9LFxuICAgICAgICBGcmFnbWVudERlZmluaXRpb246IHsg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ZXR1cm4gZnVuY3Rpb24gKCkgeyByZXR1cm4gX3RoaXMucmVtb3ZlT2JzZXJ2ZXIob2JzZXJ2ZXIpOyB9O1xuICAgICAgICB9KSB8fCB0aGlzO1xuICAgICAgICBfdGhpcy5vYnNlcnZlcnMgPSBuZXcgU2V0KCk7XG4gICAgICAgIF90aGlzLnByb21pc2UgPSBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7XG4gICAgICAgICAgICBfdGhpcy5yZXNvbHZlID0gcmVzb2x2ZTtcbiAgICAgICAgICAgIF90aGlzLnJlamVjdCA9IHJlamVjdDtcbiAgICAgICAgfSk7XG4gICAgICAgIF90aGlzLmhhbmRsZXJzID0ge1xuICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpcy5zdWIgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMubGF0ZXN0ID0gW1wibmV4dFwiLCByZXN1bHRdO1xuICAgICAgICAgICAgICAgICAgICBpdGVyYXRlT2JzZXJ2ZXJzU2FmZWx5KF90aGlzLm9ic2VydmVycywgXCJuZXh0XCIsIHJlc3VsdCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGVycm9yOiBmdW5jdGlvbiAoZXJyb3IpIHtcbiAgICAgICAgICAgICAgICBpZiAoX3RoaXMuc3ViICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChfdGhpcy5zdWIpXG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5zdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMuc3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMubGF0ZXN0ID0gW1wiZXJyb3JcIiwgZXJyb3JdO1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5yZWplY3QoZXJyb3IpO1xuICAgICAgICAgICAgICAgICAgICBpdGVyYXRlT2JzZXJ2ZXJzU2FmZWx5KF90aGlzLm9ic2VydmVycywgXCJlcnJvclwiLCBlcnJvcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzLnN1YiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBfdGhpcy5zb3VyY2VzLnNoaWZ0KCk7XG4gICAgICAgICAgICAgICAgICAgIGlmICghdmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnN1YiA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoX3RoaXMubGF0ZXN0ICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMubGF0ZXN0WzBdID09PSBcIm5leHRcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnJlc29sdmUoX3RoaXMubGF0ZXN0WzFdKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnJlc29sdmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXJhdGVPYnNlcnZlcnNTYWZlbHkoX3RoaXMub2JzZXJ2ZXJzLCBcImNvbXBsZXRlXCIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKGlzUHJvbWlzZUxpa2UodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS50aGVuKGZ1bmN0aW9uIChvYnMpIHsgcmV0dXJuIF90aGlzLnN1YiA9IG9icy5zdWJzY3JpYmUoX3RoaXMuaGFuZGxlcnMpOyB9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnN1YiA9IHZhbHVlLnN1YnNjcmliZShfdGhpcy5oYW5kbGVycyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICB9O1xuICAgICAgICBfdGhpcy5jYW5jZWwgPSBmdW5jdGlvbiAocmVhc29uKSB7XG4gICAgICAgICAgICBfdGhpcy5yZWplY3QocmVhc29uKTtcbiAgICAgICAgICAgIF90aGlzLnNvdXJjZXMgPSBbXTtcbiAgICAgICAgICAgIF90aGlzLmhhbmRsZXJzLmNvbXBsZXRlKCk7XG4gICAgICAgIH07XG4gICAgICAgIF90aGlzLnByb21pc2UuY2F0Y2goZnVuY3Rpb24gKF8pIHsgfSk7XG4gICAgICAgIGlmIChpc1Byb21pc2VMaWtlKHNvdXJjZXMpKSB7XG4gICAgICAgICAgICBzb3VyY2VzLnRoZW4oZnVuY3Rpb24gKGl0ZXJhYmxlKSB7IHJldHVybiBfdGhpcy5zdGFydChpdGVyYWJsZSk7IH0sIF90aGlzLmhhbmRsZXJzLmVycm9yKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIF90aGlzLnN0YXJ0KHNvdXJjZXMpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBfdGhpcztcbiAgICB9XG4gICAgQ29uY2FzdC5wcm90b3R5cGUuc3RhcnQgPSBmdW5jdGlvbiAoc291cmNlcykge1xuICAgICAgICBpZiAodGhpcy5zdWIgIT09IHZvaWQgMClcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgdGhpcy5zb3VyY2VzID0gQXJyYXkuZnJvbShzb3VyY2VzKTtcbiAgICAgICAgdGhpcy5oYW5kbGVycy5jb21wbGV0ZSgpO1xuICAgIH07XG4gICAgQ29uY2FzdC5wcm90b3R5cGUuYWRkT2JzZXJ2ZXIgPSBmdW5jdGlvbiAob2JzZXJ2ZXIpIHtcbiAgICAgICAgaWYgKCF0aGlzLm9ic2VydmVycy5oYXMob2JzZXJ2ZXIpKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5sYXRlc3QpIHtcbiAgICAgICAgICAgICAgICB2YXIgbmV4dE9yRXJyb3IgPSB0aGlzLmxhdGVzdFswXTtcbiAgICAgICAgICAgICAgICB2YXIgbWV0aG9kID0gb2JzZXJ2ZXJbbmV4dE9yRXJyb3JdO1xuICAgICAgICAgICAgICAgIGlmIChtZXRob2QpIHtcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kLmNhbGwob2JzZXJ2ZXIsIHRoaXMubGF0ZXN0WzFdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuc3ViID09PSBudWxsICYmXG4gICAgICAgICAgICAgICAgICAgIG5leHRPckVycm9yID09PSBcIm5leHRcIiAmJlxuICAgICAgICAgICAgICAgICAgICBvYnNlcnZlci5jb21wbGV0ZSkge1xuICAgICAgICAgICAgICAgICAgICBvYnNlcnZlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMub2JzZXJ2ZXJzLmFkZChvYnNlcnZlcik7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIENvbmNhc3QucHJvdG90eXBlLnJlbW92ZU9ic2VydmVyID0gZnVuY3Rpb24gKG9ic2VydmVyLCBxdWlldGx5KSB7XG4gICAgICAgIGlmICh0aGlzLm9ic2VydmVycy5kZWxldGUob2JzZXJ2ZXIpICYmXG4gICAgICAgICAgICB0aGlzLm9ic2VydmVycy5zaXplIDwgMSkge1xuICAgICAgICAgICAgaWYgKHF1aWV0bHkpXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgaWYgKHRoaXMuc3ViKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB0aGlzLnJlamVjdChuZXcgRXJyb3IoXCJPYnNlcnZhYmxlIGNhbmNlbGxlZCBwcmVtYXR1cmVseVwiKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnN1YiA9IG51bGw7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIENvbmNhc3QucHJvdG90eXBlLmNsZWFudXAgPSBmdW5jdGlvbiAoY2FsbGJhY2spIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIGNhbGxlZCA9IGZhbHNlO1xuICAgICAgICB2YXIgb25jZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlmICghY2FsbGVkKSB7XG4gICAgICAgICAgICAgICAgY2FsbGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBfdGhpcy5vYnNlcnZlcnMuZGVsZXRlKG9ic2VydmVyKTtcbiAgICAgICAgICAgICAgICBjYWxsYmFjaygpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgICB2YXIgb2JzZXJ2ZXIgPSB7XG4gICAgICAgICAgICBuZXh0OiBvbmNlLFxuICAgICAgICAgICAgZXJyb3I6IG9uY2UsXG4gICAgICAgICAgICBjb21wbGV0ZTogb25jZSxcbiAgICAgICAgfTtcbiAgICAgICAgdGhpcy5hZGRPYnNlcnZlcihvYnNlcnZlcik7XG4gICAgfTtcbiAgICByZXR1cm4gQ29uY2FzdDtcbn0oT2JzZXJ2YWJsZSkpO1xuZXhwb3J0IHsgQ29uY2FzdCB9O1xuaWYgKHR5cGVvZiBTeW1ib2wgPT09IFwiZnVuY3Rpb25cIiAmJiBTeW1ib2wuc3BlY2llcykge1xuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShDb25jYXN0LCBTeW1ib2wuc3BlY2llcywge1xuICAgICAgICB2YWx1ZTogT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NvbHZlKGV4YW1pbmVyKGFyZykpOyB9KS50aGVuKGZ1bmN0aW9uIChyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC0tYWN0aXZlQ2FsbGJhY2tDb3VudDtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHQgJiYgbmV4dC5jYWxsKG9ic2VydmVyLCByZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbXBsZXRlZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSwgZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC0tYWN0aXZlQ2FsbGJhY2tDb3VudDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yICYmIGVycm9yLmNhbGwob2JzZXJ2ZXIsIGUpO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIChhcmcpIHsgcmV0dXJuIGRlbGVnYXRlICYmIGRlbGVnYXRlLmNhbGwob2JzZXJ2ZXIsIGFyZyk7IH07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGhhbmRsZXIgPSB7XG4gICAgICAgICAgICBuZXh0OiBtYWtlQ2FsbGJhY2sobWFwRm4sIG5leHQpLFxuICAgICAgICAgICAgZXJyb3I6IG1ha2VDYWxsYmFjayhjYXRjaEZuLCBlcnJvciksXG4gICAgICAgICAgICBjb21wbGV0ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGNvbXBsZXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgaWYgKCFhY3RpdmVDYWxsYmFja0NvdW50KSB7XG4gICAgICAgIC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ZXlBcmdzID0gZmFsc2U7IH1cbiAgICByZXR1cm4ge1xuICAgICAgICBrZXlBcmdzOiBrZXlBcmdzLFxuICAgICAgICBtZXJnZTogZnVuY3Rpb24gKGV4aXN0aW5nLCBpbmNvbWluZykge1xuICAgICAgICAgICAgcmV0dXJuIGV4aXN0aW5nID8gX19zcHJlYWRBcnJheXMoZXhpc3RpbmcsIGluY29taW5nKSA6IGluY29taW5nO1xuICAgICAgICB9LFxuICAgIH07XG59XG5leHBvcnQgZnVuY3Rpb24gb2Zmc2V0TGltaXRQYWdpbmF0aW9uKGtleUFyZ3MpIHtcbiAgICBpZiAoa2V5QXJncyA9PT0gdm9pZCAwKSB7IGtleUFyZ3MgPSBmYWxzZTsgfVxuICAgIHJldHVybiB7XG4gICAgICAgIGtleUFyZ3M6IGtleUFyZ3MsXG4gICAgICAgIG1lcmdlOiBmdW5jdGlvbiAoZXhpc3RpbmcsIGluY29taW5nLCBfYSkge1xuICAgICAgICAgICAgdmFyIGFyZ3MgPSBfYS5hcmdzO1xuICAgICAgICAgICAgdmFyIG1lcmdlZCA9IGV4aXN0aW5nID8gZXhpc3Rpbmcuc2xpY2UoMCkgOiBbXTtcbiAgICAgICAgICAgIGlmIChhcmdzKSB7XG4gICAgICAgICAgICAgICAgdmFyIF9iID0gYXJncy5vZmZzZXQsIG9mZnNldCA9IF9iID09PSB2b2lkIDAgPyAwIDogX2I7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBpbmNvbWluZy5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgICAgICAgICBtZXJnZWRbb2Zmc2V0ICsgaV0gPSBpbmNvbWluZ1tpXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBtZXJnZWQucHVzaC5hcHBseShtZXJnZWQsIGluY29taW5nKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBtZXJnZWQ7XG4gICAgICAgIH0sXG4gICAgfTtcbn1cbmV4cG9ydCBmdW5jdGlvbiByZWxheVN0eWxlUGFnaW5hdGlvbihrZXlBcmdzKSB7XG4gICAgaWYgKGtleUFyZ3MgPT09IHZvaWQgMCkgeyBrZXlBcmdzID0gZmFsc2U7IH1cbiAgICByZXR1cm4ge1xuICAgICAgICBrZXlBcmdzOiBrZXlBcmdzLFxuICAgICAgICByZWFkOiBmdW5jdGlvbiAoZXhpc3RpbmcsIF9hKSB7XG4gICAgICAgICAgICB2YXIgY2FuUmVhZCA9IF9hLmNhblJlYWQsIHJlYWRGaWVsZCA9IF9hLnJlYWRGaWVsZDtcbiAgICAgICAgICAgIGlmICghZXhpc3RpbmcpXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgdmFyIGVkZ2VzID0gW107XG4gICAgICAgICAgICB2YXIgc3RhcnRDdXJzb3IgPSBcIlwiO1xuICAgICAgICAgICAgdmFyIGVuZEN1cnNvciA9IFwiXCI7XG4gICAgICAgICAgICBleGlzdGluZy5lZGdlcy5mb3JFYWNoKGZ1bmN0aW9uIChlZGdlKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNhblJlYWQocmVhZEZpZWxkKFwibm9kZVwiLCBlZGdlKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgZWRnZXMucHVzaChlZGdlKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVkZ2UuY3Vyc29yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdGFydEN1cnNvciA9IHN0YXJ0Q3Vyc29yIHx8IGVkZ2UuY3Vyc29yO1xuICAgICAgICAgICAgICAgICAgICAgICAgZW5kQ3Vyc29yID0gZWRnZS5jdXJzb3I7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybiBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgZ2V0RXh0cmFzKGV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mRDdXJzb3I7XG4gICAgICAgICAgICAgICAgdmFyIGZpcnN0RWRnZSA9IGluY29taW5nRWRnZXNbMF07XG4gICAgICAgICAgICAgICAgdmFyIGxhc3RFZGdlID0gaW5jb21pbmdFZGdlc1tpbmNvbWluZ0VkZ2VzLmxlbmd0aCAtIDFdO1xuICAgICAgICAgICAgICAgIGlmIChmaXJzdEVkZ2UgJiYgc3RhcnRDdXJzb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlyc3RFZGdlLmN1cnNvciA9IHN0YXJ0Q3Vyc29yO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAobGFzdEVkZ2UgJiYgZW5kQ3Vyc29yKSB7XG4gICAgICAgICAgICAgICAgICAgIGxhc3RFZGdlLmN1cnNvciA9IGVuZEN1cnNvcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdmFyIGZpcnN0Q3Vyc29yID0gZmlyc3RFZGdlICYmIGZpcnN0RWRnZS5jdXJzb3I7XG4gICAgICAgICAgICAgICAgaWYgKGZpcnN0Q3Vyc29yICYmICFzdGFydEN1cnNvcikge1xuICAgICAgICAgICAgICAgICAgICBpbmNvbWluZyA9IG1lcmdlRGVlcChpbmNvbWluZywge1xuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZm86IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydEN1cnNvcjogZmlyc3RDdXJzb3IsXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdmFyIGxhc3RDdXJzb3IgPSBsYXN0RWRnZSAmJiBsYXN0RWRnZS5jdXJzb3I7XG4gICAgICAgICAgICAgICAgaWYgKGxhc3RDdXJzb3IgJiYgIWVuZEN1cnNvcikge1xuICAgICAgICAgICAgICAgICAgICBpbmNvbWluZyA9IG1lcmdlRGVlcChpbmNvbWluZywge1xuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZm86IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmRDdXJzb3I6IGxhc3RDdXJzb3IsXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgcHJlZml4ID0gZXhpc3RpbmcuZWRnZXM7XG4gICAgICAgICAgICB2YXIgc3VmZml4ID0gW107XG4gICAgICAgICAgICBpZiAoYXJncyAmJiBhcmdzLmFmdGVyKSB7XG4gICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gcHJlZml4LmZpbmRJbmRleChmdW5jdGlvbiAoZWRnZSkgeyByZXR1cm4gZWRnZS5jdXJzb3IgPT09IGFyZ3MuYWZ0ZXI7IH0pO1xuICAgICAgICAgICAgICAgIGlmIChpbmRleCA+PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHByZWZpeCA9IHByZWZpeC5zbGljZSgwLCBpbmRleCArIDEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKGFyZ3MgJiYgYXJncy5iZWZvcmUpIHtcbiAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBwcmVmaXguZmluZEluZGV4KGZ1bmN0aW9uIChlZGdlKSB7IHJldHVybiBlZGdlLmN1cnNvciA9PT0gYXJncy5iZWZvcmU7IH0pO1xuICAgICAgICAgICAgICAgIHN1ZmZpeCA9IGluZGV4IDwgMCA/IHByZWZpeCA6IHByZWZpeC5zbGljZShpbmRleCk7XG4gICAgICAgICAgICAgICAgcHJlZml4ID0gW107XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIGlmIChpbmNvbWluZy5lZGdlcykge1xuICAgICAgICAgICAgICAgIHByZWZpeCA9IFtdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGVkZ2VzID0gX19zcHJlYWRBcnJheXMocHJlZml4LCBpbmNvbWluZ0VkZ2VzLCBzdWZmaXgpO1xuICAgICAgICAgICAgdmFyIHBhZ2VJbmZvID0gX19hc3NpZ24oX19hc3NpZ24oe30sIGluY29taW5nLnBhZ2VJbmZvKSwgZXhpc3RpbmcucGFnZUluZm8pO1xuICAgICAgICAgICAgaWYgKGluY29taW5nLnBhZ2VJbmZvKSB7XG4gICAgICAgICAgICAgICAgdmFyIF9iID0gaW5jb21pbmcucGFnZUluZm8sIGhhc1ByZXZpb3VzUGFnZSA9IF9iLmhhc1ByZXZpb3VzUGFnZSwgaGFzTmV4dFBhZ2UgPSBfYi5oYXNOZXh0UGFnZSwgc3RhcnRDdXJzb3IgPSBfYi5zdGFydEN1cnNvciwgZW5kQ3Vyc29yID0gX2IuZW5kQ3Vyc29yO1xuICAgICAgICAgICAgICAgIGlmICghcHJlZml4Lmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodm9pZCAwICE9PSBoYXNQcmV2aW91c1BhZ2UpXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5mby5oYXNQcmV2aW91c1BhZ2UgPSBoYXNQcmV2aW91c1BhZ2U7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2b2lkIDAgIT09IHN0YXJ0Q3Vyc29yKVxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZm8uc3RhcnRDdXJzb3IgPSBzdGFydEN1cnNvcjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKCFzdWZmaXgubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2b2lkIDAgIT09IGhhc05leHRQYWdlKVxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZm8uaGFzTmV4dFBhZ2UgPSBoYXNOZXh0UGFnZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZvaWQgMCAhPT0gZW5kQ3Vyc29yKVxuICAgICAgICAgICAgIC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bWl6ZWQgc3VmZml4LlxyXG4gICAgICAgIHRoaXMuaWQgPSBbXHJcbiAgICAgICAgICAgIFwic2xvdFwiLFxyXG4gICAgICAgICAgICBpZENvdW50ZXIrKyxcclxuICAgICAgICAgICAgRGF0ZS5ub3coKSxcclxuICAgICAgICAgICAgTWF0aC5yYW5kb20oKS50b1N0cmluZygzNikuc2xpY2UoMiksXHJcbiAgICAgICAgXS5qb2luKFwiOlwiKTtcclxuICAgIH1cclxuICAgIFNsb3QucHJvdG90eXBlLmhhc1ZhbHVlID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgIGZvciAodmFyIGNvbnRleHRfMSA9IGN1cnJlbnRDb250ZXh0OyBjb250ZXh0XzE7IGNvbnRleHRfMSA9IGNvbnRleHRfMS5wYXJlbnQpIHtcclxuICAgICAgICAgICAgLy8gV2UgdXNlIHRoZSBTbG90IG9iamVjdCBpc2VsZiBhcyBhIGtleSB0byBpdHMgdmFsdWUsIHdoaWNoIG1lYW5zIHRoZVxyXG4gICAgICAgICAgICAvLyB2YWx1ZSBjYW5ub3QgYmUgb2J0YWluZWQgd2l0aG91dCBhIHJlZmVyZW5jZSB0byB0aGUgU2xvdCBvYmplY3QuXHJcbiAgICAgICAgICAgIGlmICh0aGlzLmlkIGluIGNvbnRleHRfMS5zbG90cykge1xyXG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gY29udGV4dF8xLnNsb3RzW3RoaXMuaWRdO1xyXG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSBNSVNTSU5HX1ZBTFVFKVxyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgaWYgKGNvbnRleHRfMSAhPT0gY3VycmVudENvbnRleHQpIHtcclxuICAgICAgICAgICAgICAgICAgICAvLyBDYWNoZSB0aGUgdmFsdWUgaW4gY3VycmVudENvbnRleHQuc2xvdHMgc28gdGhlIG5leHQgbG9va3VwIHdpbGxcclxuICAgICAgICAgICAgICAgICAgICAvLyBiZSBmYXN0ZXIuIFRoaXMgY2FjaGluZyBpcyBzYWZlIGJlY2F1c2UgdGhlIHRyZWUgb2YgY29udGV4dHMgYW5kXHJcbiAgICAgICAgICAgICAgICAgICAgLy8gdGhlIHZhbHVlcyBvZiB0aGUgc2xvdHMgYXJlIGxvZ2ljYWxseSBpbW11dGFibGUuXHJcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudENvbnRleHQuc2xvdHNbdGhpcy5pZF0gPSB2YWx1ZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmIChjdXJyZW50Q29udGV4dCkge1xyXG4gICAgICAgICAgICAvLyBJZiBhIHZhbHVlIHdhcyBub3QgZm91bmQgZm9yIHRoaXMgU2xvdCwgaXQncyBuZXZlciBnb2luZyB0byBiZSBmb3VuZFxyXG4gICAgICAgICAgICAvLyBubyBtYXR0ZXIgaG93IG1hbnkgdGltZXMgd2UgbG9vayBpdCB1cCwgc28gd2UgbWlnaHQgYXMgd2VsbCBjYWNoZVxyXG4gICAgICAgICAgICAvLyB0aGUgYWJzZW5jZSBvZiB0aGUgdmFsdWUsIHRvby5cclxuICAgICAgICAgICAgY3VycmVudENvbnRleHQuc2xvdHNbdGhpcy5pZF0gPSBNSVNTSU5HX1ZBTFVFO1xyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICB9O1xyXG4gICAgU2xvdC5wcm90b3R5cGUuZ2V0VmFsdWUgPSBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgaWYgKHRoaXMuaGFzVmFsdWUoKSkge1xyXG4gICAgICAgICAgICByZXR1cm4gY3VycmVudENvbnRleHQuc2xvdHNbdGhpcy5pZF07XHJcbiAgICAgICAgfVxyXG4gICAgfTtcclxuICAgIFNsb3QucHJvdG90eXBlLndpdGhWYWx1ZSA9IGZ1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uIHNldFRpbWVvdXRXaXRoQ29udGV4dChjYWxsYmFjaywgZGVsYXkpIHtcclxuICAgIHJldHVybiBzZXRUaW1lb3V0KGJpbmQoY2FsbGJhY2spLCBkZWxheSk7XHJcbn1cclxuLy8gVHVybiBhbnkgZ2VuZXJhdG9yIGZ1bmN0aW9uIGludG8gYW4gYXN5bmMgZnVuY3Rpb24gKHVzaW5nIHlpZWxkIGluc3RlYWRcclxuLy8gb2YgYXdhaXQpLCB3aXRoIGNvbnRleHQgYXV0b21hdGljYWxseSBwcmVzZXJ2ZWQgYWNyb3NzIHlpZWxkcy5cclxuZnVuY3Rpb24gYXN5bmNGcm9tR2VuKGdlbkZuKSB7XHJcbiAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgIHZhciBnZW4gPSBnZW5Gbi5hcHBseSh0aGlzLCBhcmd1bWVudHMpO1xyXG4gICAgICAgIHZhciBib3VuZE5leHQgPSBiaW5kKGdlbi5uZXh0KTtcclxuICAgICAgICB2YXIgYm91bmRUaHJvdyA9IGJpbmQoZ2VuLnRocm93KTtcclxuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkge1xyXG4gICAgICAgICAgICBmdW5jdGlvbiBpbnZva2UobWV0aG9kLCBhcmd1bWVudCkge1xyXG4gICAgICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gbWV0aG9kLmNhbGwoZ2VuLCBhcmd1bWVudCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBjYXRjaCAoZXJyb3IpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVqZWN0KGVycm9yKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIHZhciBuZXh0ID0gcmVzdWx0LmRvbmUgPyByZXNvbHZlIDogaW52b2tlTmV4dDtcclxuICAgICAgICAgICAgICAgIGlmIChpc1Byb21pc2VMaWtlKHJlc3VsdC52YWx1ZSkpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXN1bHQudmFsdWUudGhlbihuZXh0LCByZXN1bHQuZG9uZSA/IHJlamVjdCA6IGludm9rZVRocm93KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIG5leHQocmVzdWx0LnZhbHVlKTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB2YXIgaW52b2tlTmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkgeyByZXR1cm4gaW52b2tlKGJvdW5kTmV4dCwgdmFsdWUpOyB9O1xyXG4gICAgICAgICAgICB2YXIgaW52b2tlVGhyb3cgPSBmdW5jdGlvbiAoZXJyb3IpIHsgcmV0dXJuIGludm9rZShib3VuZFRocm93LCBlcnJvcik7IH07XHJcbiAgICAgICAgICAgIGludm9rZU5leHQoKTtcclxuICAgICAgICB9KTtcclxuICAgIH07XHJcbn1cclxuZnVuY3Rpb24gaXNQcm9taXNlTGlrZSh2YWx1ZSkge1xyXG4gICAgcmV0dXJuIHZhbHVlICYmIHR5cGVvZiB2YWx1ZS50aGVuID09PSBcImZ1bmN0aW9uXCI7XHJcbn1cclxuLy8gSWYgeW91IHVzZSB0aGUgZmliZXJzIG5wbSBwYWNrYWdlIHRvIGltcGxlbWVudCBjb3JvdXRpbmVzIGluIE5vZGUuanMsXHJcbi8vIHlvdSBzaG91bGQgY2FsbCB0aGlzIGZ1bmN0aW9uIGF0IGxlYXN0IG9uY2UgdG8gZW5zdXJlIGNvbnRleHQgbWFuYWdlbWVudFxyXG4vLyByZW1haW5zIGNvaGVyZW50IGFjcm9zcyBhbnkgeWllbGRzLlxyXG52YXIgd3JhcHBlZEZpYmVycyA9IFtdO1xyXG5mdW5jdGlvbiB3cmFwWWllbGRpbmdGaWJlck1ldGhvZHMoRmliZ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9IE9iamVjdC5rZXlzKGEpO1xyXG4gICAgICAgICAgICB2YXIgYktleXMgPSBPYmplY3Qua2V5cyhiKTtcclxuICAgICAgICAgICAgLy8gSWYgYGFgIGFuZCBgYmAgaGF2ZSBhIGRpZmZlcmVudCBudW1iZXIgb2YgZW51bWVyYWJsZSBrZXlzLCB0aGV5XHJcbiAgICAgICAgICAgIC8vIG11c3QgYmUgZGlmZmVyZW50LlxyXG4gICAgICAgICAgICB2YXIga2V5Q291bnQgPSBhS2V5cy5sZW5ndGg7XHJcbiAgICAgICAgICAgIGlmIChrZXlDb3VudCAhPT0gYktleXMubGVuZ3RoKVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAvLyBOb3cgbWFrZSBzdXJlIHRoZXkgaGF2ZSB0aGUgc2FtZSBrZXlzLlxyXG4gICAgICAgICAgICBmb3IgKHZhciBrID0gMDsgayA8IGtleUNvdW50OyArK2spIHtcclxuICAgICAgICAgICAgICAgIGlmICghaGFzT3duUHJvcGVydHkuY2FsbChiLCBhS2V5c1trXSkpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgLy8gRmluYWxseSwgY2hlY2sgZGVlcCBlcXVhbGl0eSBvZiBhbGwgY2hpbGQgcHJvcGVydGllcy5cclxuICAgICAgICAgICAgZm9yICh2YXIgayA9IDA7IGsgPCBrZXlDb3VudDsgKytrKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gYUtleXNba107XHJcbiAgICAgICAgICAgICAgICBpZiAoIWNoZWNrKGFba2V5XSwgYltrZXldKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgICAgICB9XHJcbiAgICAgICAgY2FzZSAnW29iamVjdCBFcnJvcl0nOlxyXG4gICAgICAgICAgICByZXR1cm4gYS5uYW1lID09PSBiLm5hbWUgJiYgYS5tZXNzYWdlID09PSBiLm1lc3NhZ2U7XHJcbiAgICAgICAgY2FzZSAnW29iamVjdCBOdW1iZXJdJzpcclxuICAgICAgICAgICAgLy8gSGFuZGxlIE5hTiwgd2hpY2ggaXMgIT09IGl0c2VsZi5cclxuICAgICAgICAgICAgaWYgKGEgIT09IGEpXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gYiAhPT0gYjtcclxuICAgICAgICAvLyBGYWxsIHRocm91Z2ggdG8gc2hhcmVkICthID09PSArYiBjYXNlLi4uXHJcbiAgICAgICAgY2FzZSAnW29iamVjdCBCb29sZWFuXSc6XHJcbiAgICAgICAgY2FzZSAnW29iamVjdCBEYXRlXSc6XHJcbiAgICAgICAgICAgIHJldHVybiArYSA9PT0gK2I7XHJcbiAgICAgICAgY2FzZSAnW29iamVjdCBSZWdFeHBdJzpcclxuICAgICAgICBjYXNlICdbb2JqZWN0IFN0cmluZ10nOlxyXG4gICAgICAgICAgICByZXR1cm4gYSA9PSBcIlwiICsgYjtcclxuICAgICAgICBjYXNlICdbb2JqZWN0IE1hcF0nOlxyXG4gICAgICAgIGNhc2UgJ1tvYmplY3QgU2V0XSc6IHtcclxuICAgICAgICAgICAgaWYgKGEuc2l6ZSAhPT0gYi5zaXplKVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICBpZiAocHJldmlvdXNseUNvbXBhcmVkKGEsIGIpKVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgICAgIHZhciBhSXRlcmF0b3IgPSBhLmVudHJpZXMoKTtcclxuICAgICAgICAgICAgdmFyIGlzTWFwID0gYVRhZyA9PT0gJ1tvYmplY3QgTWFwXSc7XHJcbiAgICAgICAgICAgIHdoaWxlICh0cnVlKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgaW5mbyA9IGFJdGVyYXRvci5uZXh0KCk7XHJcbiAgICAgICAgICAgICAgICBpZiAoaW5mby5kb25lKVxyXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgLy8gSWYgYSBpbnN0YW5jZW9mIFNldCwgYVZhbHVlID09PSBhS2V5LlxyXG4gICAgICAgICAgICAgICAgdmFyIF9hID0gaW5mby52YWx1ZSwgYUtleSA9IF9hWzBdLCBhVmFsdWUgPSBfYVsxXTtcclxuICAgICAgICAgICAgICAgIC8vIFNvIHRoaXMgd29ya3MgdGhlIHNhbWUgd2F5IGZvciBib3RoIFNldCBhbmQgTWFwLlxyXG4gICAgICAgICAgICAgICAgaWYgKCFiLmhhcyhhS2V5KSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIC8vIEhvd2V2ZXIsIHdlIGNhcmUgYWJvdXQgZGVlcCBlcXVhbGl0eSBvZiB2YWx1ZXMgb25seSB3aGVuIGRlYWxpbmdcclxuICAgICAgICAgICAgICAgIC8vIHdpdGggTWFwIHN0cnVjdHVyZXMuXHJcbiAgICAgICAgICAgICAgICBpZiAoaXNNYXAgJiYgIWNoZWNrKGFWYWx1ZSwgYi5nZXQoYUtleSkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgIH1cclxuICAgICAgICBjYXNlICdbb2JqZWN0IEZ1bmN0aW9uXSc6IHtcclxuICAgICAgICAgICAgdmFyIGFDb2RlID0gZm5Ub1N0ci5jYWxsKGEpO1xyXG4gICAgICAgICAgICBpZiAoYUNvZGUgIT09IGZuVG9TdHIuY2FsbChiKSkge1xyXG4gICAgICAgICAgICAg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KU09OID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICBub2RlID0gbm9kZS50b0pTT04oKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChub2RlID09PSB1bmRlZmluZWQpIHJldHVybjtcbiAgICAgICAgaWYgKHR5cGVvZiBub2RlID09ICdudW1iZXInKSByZXR1cm4gaXNGaW5pdGUobm9kZSkgPyAnJyArIG5vZGUgOiAnbnVsbCc7XG4gICAgICAgIGlmICh0eXBlb2Ygbm9kZSAhPT0gJ29iamVjdCcpIHJldHVybiBKU09OLnN0cmluZ2lmeShub2RlKTtcblxuICAgICAgICB2YXIgaSwgb3V0O1xuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShub2RlKSkge1xuICAgICAgICAgICAgb3V0ID0gJ1snO1xuICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IG5vZGUubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBpZiAoaSkgb3V0ICs9ICcsJztcbiAgICAgICAgICAgICAgICBvdXQgKz0gc3RyaW5naWZ5KG5vZGVbaV0pIHx8ICdudWxsJztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBvdXQgKyAnXSc7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobm9kZSA9PT0gbnVsbCkgcmV0dXJuICdudWxsJztcblxuICAgICAgICBpZiAoc2Vlbi5pbmRleE9mKG5vZGUpICE9PSAtMSkge1xuICAgICAgICAgICAgaWYgKGN5Y2xlcykgcmV0dXJuIEpTT04uc3RyaW5naWZ5KCdfX2N5Y2xlX18nKTtcbiAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoJ0NvbnZlcnRpbmcgY2lyY3VsYXIgc3RydWN0dXJlIHRvIEpTT04nKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBzZWVuSW5kZXggPSBzZWVuLnB1c2gobm9kZSkgLSAxO1xuICAgICAgICB2YXIga2V5cyA9IE9iamVjdC5rZXlzKG5vZ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9XFxufVxcblwiLFwibmFtZVwiOlwiR3JhcGhRTCByZXF1ZXN0XCIsXCJsb2NhdGlvbk9mZnNldFwiOntcImxpbmVcIjoxLFwiY29sdW1uXCI6MX19O1xuICBcblxuICAgIHZhciBuYW1lcyA9IHt9O1xuICAgIGZ1bmN0aW9uIHVuaXF1ZShkZWZzKSB7XG4gICAgICByZXR1cm4gZGVmcy5maWx0ZXIoXG4gICAgICAgIGZ1bmN0aW9uKGRlZikge1xuICAgICAgICAgIGlmIChkZWYua2luZCAhPT0gJ0ZyYWdtZW50RGVmaW5pdGlvbicpIHJldHVybiB0cnVlO1xuICAgICAgICAgIHZhciBuYW1lID0gZGVmLm5hbWUudmFsdWVcbiAgICAgICAgICBpZiAobmFtZXNbbmFtZV0pIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgbmFtZXNbbmFtZV0gPSB0cnVlO1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICApXG4gICAgfVxuICBcblxuICAgIC8vIENvbGxlY3QgYW55IGZyYWdtZW50L3R5cGUgcmVmZXJlbmNlcyBmcm9tIGEgbm9kZSwgYWRkaW5nIHRoZW0gdG8gdGhlIHJlZnMgU2V0XG4gICAgZnVuY3Rpb24gY29sbGVjdEZyYWdtZW50UmVmZXJlbmNlcyhub2RlLCByZWZzKSB7XG4gICAgICBpZiAobm9kZS5raW5kID09PSBcIkZyYWdtZW50U3ByZWFkXCIpIHtcbiAgICAgICAgcmVmcy5hZGQobm9kZS5uYW1lLnZhbHVlKTtcbiAgICAgIH0gZWxzZSBpZiAobm9kZS5raW5kID09PSBcIlZhcmlhYmxlRGVmaW5pdGlvblwiKSB7XG4gICAgICAgIHZhciB0eXBlID0gbm9kZS50eXBlO1xuICAgICAgICBpZiAodHlwZS5raW5kID09PSBcIk5hbWVkVHlwZVwiKSB7XG4gICAgICAgICAgcmVm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xuICAgICAgICAvLyAgXFxyXG4gICAgICAgIGlmIChib2R5LmNoYXJDb2RlQXQocG9zICsgMSkgPT09IDEwKSB7XG4gICAgICAgICAgcG9zICs9IDI7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgKytwb3M7XG4gICAgICAgIH1cblxuICAgICAgICArK2xleGVyLmxpbmU7XG4gICAgICAgIGxleGVyLmxpbmVTdGFydCA9IHBvcztcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgIGNhc2UgMzM6XG4gICAgICAgIC8vICAhXG4gICAgICAgIHJldHVybiBuZXcgX2FzdC5Ub2tlbihfdG9rZW5LaW5kLlRva2VuS2luZC5CQU5HLCBwb3MsIHBvcyArIDEsIF9saW5lLCBfY29sLCBwcmV2KTtcblxuICAgICAgY2FzZSAzNTpcbiAgICAgICAgLy8gICNcbiAgICAgICAgcmV0dXJuIHJlYWRDb21tZW50KHNvdXJjZSwgcG9zLCBfbGluZSwgX2NvbCwgcHJldik7XG5cbiAgICAgIGNhc2UgMzY6XG4gICAgICAgIC8vICAkXG4gICAgICAgIHJldHVybiBuZXcgX2FzdC5Ub2tlbihfdG9rZW5LaW5kLlRva2VuS2luZC5ET0xMQVIsIHBvcywgcG9zICsgMSwgX2xpbmUsIF9jb2wsIHByZXYpO1xuXG4gICAgICBjYXNlIDM4OlxuICAgICAgICAvLyAgJlxuICAgICAgICByZXR1cm4gbmV3IF9hc3QuVG9rZW4oX3Rva2VuS2luZC5Ub2tlbktpbmQuQU1QLCBwb3MsIHBvcyArIDEsIF9saW5lLCBfY29sLCBwcmV2KTtcblxuICAgICAgY2FzZSA0MDpcbiAgICAgICAgLy8gIChcbiAgICAgICAgcmV0dXJuIG5ldyBfYXN0LlRva2VuKF90b2tlbktpbmQuVG9rZW5LaW5kLlBBUkVOX0wsIHBvcywgcG9zICsgMSwgX2xpbmUsIF9jb2wsIHByZXYpO1xuXG4gICAgICBjYXNlIDQxOlxuICAgICAgICAvLyAgKVxuICAgICAgICByZXR1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iAvLyAgV1xuXG4gICAgICBjYXNlIDg4OiAvLyAgWFxuXG4gICAgICBjYXNlIDg5OiAvLyAgWVxuXG4gICAgICBjYXNlIDkwOiAvLyAgWlxuXG4gICAgICBjYXNlIDk1OiAvLyAgX1xuXG4gICAgICBjYXNlIDk3OiAvLyAgYVxuXG4gICAgICBjYXNlIDk4OiAvLyAgYlxuXG4gICAgICBjYXNlIDk5OiAvLyAgY1xuXG4gICAgICBjYXNlIDEwMDogLy8gZFxuXG4gICAgICBjYXNlIDEwMTogLy8gZVxuXG4gICAgICBjYXNlIDEwMjogLy8gZlxuXG4gICAgICBjYXNlIDEwMzogLy8gZ1xuXG4gICAgICBjYXNlIDEwNDogLy8gaFxuXG4gICAgICBjYXNlIDEwNTogLy8gaVxuXG4gICAgICBjYXNlIDEwNjogLy8galxuXG4gICAgICBjYXNlIDEwNzogLy8ga1xuXG4gICAgICBjYXNlIDEwODogLy8gbFxuXG4gICAgICBjYXNlIDEwOTogLy8gbVxuXG4gICAgICBjYXNlIDExMDogLy8gblxuXG4gICAgICBjYXNlIDExMTogLy8gb1xuXG4gICAgICBjYXNlIDExMjogLy8gcFxuXG4gICAgICBjYXNlIDExMzogLy8gcVxuXG4gICAgICBjYXNlIDExNDogLy8gclxuXG4gICAgICBjYXNlIDExNTogLy8gc1xuXG4gICAgICBjYXNlIDExNjogLy8gdFxuXG4gICAgICBjYXNlIDExNzogLy8gdVxuXG4gICAgICBjYXNlIDExODogLy8gdlxuXG4gICAgICBjYXNlIDExOTogLy8gd1xuXG4gICAgICBjYXNlIDEyMDogLy8geFxuXG4gICAgICBjYXNlIDEyMTogLy8geVxuXG4gICAgICBjYXNlIDEyMjpcbiAgICAgICAgLy8gelxuICAgICAgICByZXR1cm4gcmVhZE5hbWUoc291cmNlLCBwb3MsIF9saW5lLCBfY29sLCBwcmV2KTtcbiAgICB9XG5cbiAgICB0aHJvdyAoMCwgX3N5bnRheEVycm9yLnN5bnRheEVycm9yKShzb3VyY2UsIHBvcyw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vZHkuc2xpY2UoY2h1bmtTdGFydCwgcG9zaXRpb24pO1xuICAgICAgcmV0dXJuIG5ldyBfYXN0LlRva2VuKF90b2tlbktpbmQuVG9rZW5LaW5kLlNUUklORywgc3RhcnQsIHBvc2l0aW9uICsgMSwgbGluZSwgY29sLCBwcmV2LCB2YWx1ZSk7XG4gICAgfSAvLyBTb3VyY2VDaGFyYWN0ZXJcblxuXG4gICAgaWYgKGNvZGUgPCAweDAwMjAgJiYgY29kZSAhPT0gMHgwMDA5KSB7XG4gICAgICB0aHJvdyAoMCwgX3N5bnRheEVycm9yLnN5bnRheEVycm9yKShzb3VyY2UsIHBvc2l0aW9uLCBcIkludmFsaWQgY2hhcmFjdGVyIHdpdGhpbiBTdHJpbmc6IFwiLmNvbmNhdChwcmludENoYXJDb2RlKGNvZGUpLCBcIi5cIikpO1xuICAgIH1cblxuICAgICsrcG9zaXRpb247XG5cbiAgICBpZiAoY29kZSA9PT0gOTIpIHtcbiAgICAgIC8vIFxcXG4gICAgICB2YWx1ZSArPSBib2R5LnNsaWNlKGNodW5rU3RhcnQsIHBvc2l0aW9uIC0gMSk7XG4gICAgICBjb2RlID0gYm9keS5jaGFyQ29kZUF0KHBvc2l0aW9uKTtcblxuICAgICAgc3dpdGNoIChjb2RlKSB7XG4gICAgICAgIGNhc2UgMzQ6XG4gICAgICAgICAgdmFsdWUgKz0gJ1wiJztcbiAgICAgICAgICBicmVhaztcblxuICAgICAgICBjYXNlIDQ3OlxuICAgICAgICAgIHZhbHVlICs9ICcvJztcbiAgICAgICAgICBicmVhaztcblxuICAgICAgICBjYXNlIDkyOlxuICAgICAgICAgIHZhbHVlICs9ICdcXFxcJztcbiAgICAgICAgICBicmVhaztcblxuICAgICAgICBjYXNlIDk4OlxuICAgICAgICAgIHZhbHVlICs9ICdcXGInO1xuICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgIGNhc2UgMTAyOlxuICAgICAgICAgIHZhbHVlICs9ICdcXGYnO1xuICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgIGNhc2UgMTEwOlxuICAgICAgICAgIHZhbHVlICs9ICdcXG4nO1xuICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgIGNhc2UgMTE0OlxuICAgICAgICAgIHZhbHVlICs9ICdcXHInO1xuICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgIGNhc2UgMTE2OlxuICAgICAgICAgIHZhbHVlICs9ICdcXHQnO1xuICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgIGNhc2UgMTE3OlxuICAgICAgICAgIHtcbiAgICAgICAgICAgIC8vIHVYWFhYXG4gICAgICAgICAgICB2YXIgY2hhckNvZGUgPSB1bmlDaGFyQ29kZShib2R5LmNoYXJDb2RlQXQocG9zaXRpb24gKyAxKSwgYm9keS5jaGFyQ29kZUF0KHBvc2l0aW9uICsgMiksIGJvZHkuY2hhckNvZGVBdChwb3NpdGlvbiArIDMpLCBib2R5LmNoYXJDb2RlQXQocG9zaXRpb24gKyA0KSk7XG5cbiAgICAgICAgICAgIGlmIChjaGFyQ29kZSA8IDApIHtcbiAgICAgICAgICAgICAgdmFyIGludmFsaWRTZXF1ZW5jZSA9IGJvZHkuc2xpY2UocG9zaXRpb24gKyAxLCBwb3NpdGlvbiArIDUpO1xuICAgICAgICAgICAgICB0aHJvdyAoMCwgX3N5bnRheEVycm9yLnN5bnRheEVycm9yKShzb3VyY2UsIHBvc2l0aW9uLCBcIkludmFsaWQgY2hhcmFjdGVyIGVzY2FwZSBzZXF1ZW5jZTogXFxcXHVcIi5jb25jYXQoaW52YWxpZFNlcXVlbmNlLCBcIi5cIikpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YWx1ZSArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGNoYXJDb2RlKTtcbiAgICAgICAgICAgIHBvc2l0aW9uICs9IDQ7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG5cbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICB0aH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ZWN1dGFibGVEZWZpbml0aW9uIDpcbiAgICogICAtIE9wZXJhdGlvbkRlZmluaXRpb25cbiAgICogICAtIEZyYWdtZW50RGVmaW5pdGlvblxuICAgKi9cbiAgO1xuXG4gIF9wcm90by5wYXJzZURlZmluaXRpb24gPSBmdW5jdGlvbiBwYXJzZURlZmluaXRpb24oKSB7XG4gICAgaWYgKHRoaXMucGVlayhfdG9rZW5LaW5kLlRva2VuS2luZC5OQU1FKSkge1xuICAgICAgc3dpdGNoICh0aGlzLl9sZXhlci50b2tlbi52YWx1ZSkge1xuICAgICAgICBjYXNlICdxdWVyeSc6XG4gICAgICAgIGNhc2UgJ211dGF0aW9uJzpcbiAgICAgICAgY2FzZSAnc3Vic2NyaXB0aW9uJzpcbiAgICAgICAgICByZXR1cm4gdGhpcy5wYXJzZU9wZXJhdGlvbkRlZmluaXRpb24oKTtcblxuICAgICAgICBjYXNlICdmcmFnbWVudCc6XG4gICAgICAgICAgcmV0dXJuIHRoaXMucGFyc2VGcmFnbWVudERlZmluaXRpb24oKTtcblxuICAgICAgICBjYXNlICdzY2hlbWEnOlxuICAgICAgICBjYXNlICdzY2FsYXInOlxuICAgICAgICBjYXNlICd0eXBlJzpcbiAgICAgICAgY2FzZSAnaW50ZXJmYWNlJzpcbiAgICAgICAgY2FzZSAndW5pb24nOlxuICAgICAgICBjYXNlICdlbnVtJzpcbiAgICAgICAgY2FzZSAnaW5wdXQnOlxuICAgICAgICBjYXNlICdkaXJlY3RpdmUnOlxuICAgICAgICAgIHJldHVybiB0aGlzLnBhcnNlVHlwZVN5c3RlbURlZmluaXRpb24oKTtcblxuICAgICAgICBjYXNlICdleHRlbmQnOlxuICAgICAgICAgIHJldHVybiB0aGlzLnBhcnNlVHlwZVN5c3RlbUV4dGVuc2lvbigpO1xuICAgICAgfVxuICAgIH0gZWxzZSBpZiAodGhpcy5wZWVrKF90b2tlbktpbmQuVG9rZW5LaW5kLkJSQUNFX0wpKSB7XG4gICAgICByZXR1cm4gdGhp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zLktpbmQuRkxPQVQsXG4gICAgICAgICAgdmFsdWU6IHRva2VuLnZhbHVlLFxuICAgICAgICAgIGxvYzogdGhpcy5sb2ModG9rZW4pXG4gICAgICAgIH07XG5cbiAgICAgIGNhc2UgX3Rva2VuS2luZC5Ub2tlbktpbmQuU1RSSU5HOlxuICAgICAgY2FzZSBfdG9rZW5LaW5kLlRva2VuS2luZC5CTE9DS19TVFJJTkc6XG4gICAgICAgIHJldHVybiB0aGlzLnBhcnNlU3RyaW5nTGl0ZXJhbCgpO1xuXG4gICAgICBjYXNlIF90b2tlbktpbmQuVG9rZW5LaW5kLk5BTUU6XG4gICAgICAgIHRoaXMuX2xleGVyLmFkdmFuY2UoKTtcblxuICAgICAgICBzd2l0Y2ggKHRva2VuLnZhbHVlKSB7XG4gICAgICAgICAgY2FzZSAndHJ1ZSc6XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICBraW5kOiBfa2luZHMuS2luZC5CT09MRUFOLFxuICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZSxcbiAgICAgICAgICAgICAgbG9jOiB0aGlzLmxvYyh0b2tlbilcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICBjYXNlICdmYWxzZSc6XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICBraW5kOiBfa2luZHMuS2luZC5CT09MRUFOLFxuICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UsXG4gICAgICAgICAgICAgIGxvYzogdGhpcy5sb2ModG9rZW4pXG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgY2FzZSAnbnVsbCc6XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICBraW5kOiBfa2luZHMuS2luZC5OVUxMLFxuICAgICAgICAgICAgICBsb2M6IHRoaXMubG9jKHRva2VuKVxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICBraW5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2RlXG4gKiAgICAgICAgIH1cbiAqICAgICAgIH1cbiAqICAgICB9KVxuICpcbiAqIDMpIEdlbmVyaWMgdmlzaXRvcnMgdGhhdCB0cmlnZ2VyIHVwb24gZW50ZXJpbmcgYW5kIGxlYXZpbmcgYW55IG5vZGUuXG4gKlxuICogICAgIHZpc2l0KGFzdCwge1xuICogICAgICAgZW50ZXIobm9kZSkge1xuICogICAgICAgICAvLyBlbnRlciBhbnkgbm9kZVxuICogICAgICAgfSxcbiAqICAgICAgIGxlYXZlKG5vZGUpIHtcbiAqICAgICAgICAgLy8gbGVhdmUgYW55IG5vZGVcbiAqICAgICAgIH1cbiAqICAgICB9KVxuICpcbiAqIDQpIFBhcmFsbGVsIHZpc2l0b3JzIGZvciBlbnRlcmluZyBhbmQgbGVhdmluZyBub2RlcyBvZiBhIHNwZWNpZmljIGtpbmQuXG4gKlxuICogICAgIHZpc2l0KGFzdCwge1xuICogICAgICAgZW50ZXI6IHtcbiAqICAgICAgICAgS2luZChub2RlKSB7XG4gKiAgICAgICAgICAgLy8gZW50ZXIgdGhlIFwiS2luZFwiIG5vZGVcbiAqICAgICAgICAgfVxuICogICAgICAgfSxcbiAqICAgICAgIGxlYXZlOiB7XG4gKiAgICAgICAgIEtpbmQobm9kZSkge1xuICogICAgICAgICAgIC8vIGxlYXZlIHRoZSBcIktpbmRcIiBub2RlXG4gKiAgICAgICAgIH1cbiAqICAgICAgIH1cbiAqICAgICB9KVxuICovXG5cbmV4cG9ydCBmdW5jdGlvbiB2aXNpdChyb290LCB2aXNpdG9yKSB7XG4gIHZhciB2aXNpdG9yS2V5cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogUXVlcnlEb2N1bWVudEtleXM7XG5cbiAgLyogZXNsaW50LWRpc2FibGUgbm8tdW5kZWYtaW5pdCAqL1xuICB2YXIgc3RhY2sgPSB1bmRlZmluZWQ7XG4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25lW2tdID0gbm9kZVtrXTtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBub2RlID0gY2xvbmU7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgZWRpdE9mZnNldCA9IDA7XG5cbiAgICAgICAgZm9yICh2YXIgaWkgPSAwOyBpaSA8IGVkaXRzLmxlbmd0aDsgaWkrKykge1xuICAgICAgICAgIHZhciBlZGl0S2V5ID0gZWRpdHNbaWldWzBdO1xuICAgICAgICAgIHZhciBlZGl0VmFsdWUgPSBlZGl0c1tpaV1bMV07XG5cbiAgICAgICAgICBpZiAoaW5BcnJheSkge1xuICAgICAgICAgICAgZWRpdEtleSAtPSBlZGl0T2Zmc2V0O1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGlmIChpbkFycmF5ICYmIGVkaXRWYWx1ZSA9PT0gbnVsbCkge1xuICAgICAgICAgICAgbm9kZS5zcGxpY2UoZWRpdEtleSwgMSk7XG4gICAgICAgICAgICBlZGl0T2Zmc2V0Kys7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5vZGVbZWRpdEtleV0gPSBlZGl0VmFsdWU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIGluZGV4ID0gc3RhY2suaW5kZXg7XG4gICAgICBrZXlzID0gc3RhY2sua2V5cztcbiAgICAgIGVkaXRzID0gc3RhY2suZWRpdHM7XG4gICAgICBpbkFycmF5ID0gc3RhY2suaW5BcnJheTtcbiAgICAgIHN0YWNrID0gc3RhY2sucHJldjtcbiAgICB9IGVsc2Uge1xuICAgICAga2V5ID0gcGFyZW50ID8gaW5BcnJheSA/IGluZGV4IDoga2V5c1tpbmRleF0gOiB1bmRlZmluZWQ7XG4gICAgICBub2RlID0gcGFyZW50ID8gcGFyZW50W2tleV0gOiBuZXdSb290O1xuXG4gICAgICBpZiAobm9kZSA9PT0gbnVsbCB8fCBub2RlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgY29udGludWU7XG4gICAgICB9XG5cbiAgICAgIGlmIChwYXJlbnQpIHtcbiAgICAgICAgcGF0aC5wdXNoKGtleSk7XG4gICAgICB9XG4gICAgfVxuXG4gICAgdmFyIHJlc3VsdCA9IHZvaWQgMDtcblxuICAgIGlmICghQXJyYXkuaXNBcnJheShub2RlKSkge1xuICAgICAgaWYgKCFpc05vZGUobm9kZSkpIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwiSW52YWxpZCBBU1QgTm9kZTogXCIuY29uY2F0KGluc3BlY3Qobm9kZSksIFwiLlwiKSk7XG4gICAgICB9XG5cbiAgICAgIHZhciB2aXNpdEZuID0gZ2V0VmlzaXRGbih2aXNpdG9yLCBub2RlLmtpbmQsIGlzTGVhdmluZyk7XG5cbiAgICAgIGlmICh2aXNpdEZuKSB7XG4gICAgICAgIHJlc3VsdCA9IHZpc2l0Rm4uY2FsbCh2aXNpdG9yLCBub2RlLCBrZXksIHBhcmVudCwgcGF0aCwgYW5jZXN0b3JzKTtcblxuICAgICAgICBpZiAocmVzdWx0ID09PSBCUkVBSykge1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHJlc3VsdCA9PT0gZmFsc2UpIHtcbiAgICAgICAgICBpZiAoIWlzTGVhdmluZykge1xuICAgICAgICAgICAgcGF0aC5wb3AoKTtcbiAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmIChyZXN1bHQgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgIGVkaXRzLnB1c2goW2tleSwgcmVzdWx0XSk7XG5cbiAgICAgICAgICBpZiAoIWlzTGVhdmluZykge1xuICAgICAgICAgICAgaWYgKGlzTm9kZShyZXN1bHQpKSB7XG4gICAgICAgICAgICAgIG5vZGUgPSByZXN1bHQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwYXRoLnBvcCgpO1xuICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG5cbiAgICBpZiAocmVzdWx0ID09PSB1bmRlZmluZWQgJiYgaXNFZGl0ZWQpIHtcbiAgICAgIGVkaXRzLnB1c2goW2tleSwgbm9kZV0pO1xuICAgIH1cblxuICAgIGlmIChpc0xlYXZpbmcpIHtcbiAgICAgIHBhdGgucG9wKCk7XG4gICAgfSBlbHNlIHtcbiAgICAgIHZhciBfdmlzaXRvcktleXMkbm9kZSRraW47XG5cbiAgICAgIHN0YWNrID0ge1xuICAgICAgICBpbkFycmF5OiBpbkFycmF5LFxuICAgICAgICBpbmRleDogaW5kZXgsXG4gICAgICAgIGtleXM6IGtleXMsXG4gICAgICAgIGVkaXRzOiBlZGl0cyxcbiAgICAgICAgcHJldjogc3RhY2tcbiAgICAgIH07XG4gICAgICBpbkFycmF5ID0gQXJyYXkuaXNBcnJheShub2RlKTtcbiAgICAgIGtleXMgPSBpbkFycmF5ID8gbm9kZSA6IChfdmlzaXRvcktleXMkbm9kZSRraW4gPSB2aXNpdG9yS2V5c1tub2RlLmtpbmRdKSAhPT0gbnVsbCAmJiBfdmlzaXRvcktleXMkbm9kZSRraW4gIT09IHZvaWQgMCA/IF92aXNpdG9yS2V5cyRub2RlJGtpbiA6IFtdO1xuICAgICAgaW5kZXggPSAtMTtcbiAgICAgIGVkaXRzID0gW107XG5cbiAgICAgIGlmIChwYXJlbnQpIHtcbiAgICAgICAgYW5jZXN0b3JzLnB1c2gocGFyZW50KTtcbiAgICAgIH1cblxuICAgICAgcGFyZW50ID0gbm9kZTtcbiAgICB9XG4gIH0gd2hpbGUgKHN0YWNrICE9PSB1bmRlZmluZWQpO1xuXG4gIGlmIChlZGl0cy5sZW5ndGggIT09IDApIHtcbiAgICBuZXdSb290ID0gZWRpdHNbZWRpdHMubGVuZ3RoIC0gMV1bMV07XG4gIH1cblxuICByZXR1cm4gbmV3Um9vdDtcbn1cbi8qKlx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WYgKHJlc3VsdCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgICBsZWF2ZTogZnVuY3Rpb24gbGVhdmUobm9kZSkge1xuICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCB2aXNpdG9ycy5sZW5ndGg7IGkrKykge1xuICAgICAgICBpZiAoc2tpcHBpbmdbaV0gPT0gbnVsbCkge1xuICAgICAgICAgIHZhciBmbiA9IGdldFZpc2l0Rm4odmlzaXRvcnNbaV0sIG5vZGUua2luZCxcbiAgICAgICAgICAvKiBpc0xlYXZpbmcgKi9cbiAgICAgICAgICB0cnVlKTtcblxuICAgICAgICAgIGlmIChmbikge1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IGZuLmFwcGx5KHZpc2l0b3JzW2ldLCBhcmd1bWVudHMpO1xuXG4gICAgICAgICAgICBpZiAocmVzdWx0ID09PSBCUkVBSykge1xuICAgICAgICAgICAgICBza2lwcGluZ1tpXSA9IEJSRUFLO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChyZXN1bHQgIT09IHVuZGVmaW5lZCAmJiByZXN1bHQgIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHNraXBwaW5nW2ldID09PSBub2RlKSB7XG4gICAgICAgICAgc2tpcHBpbmdbaV0gPSBudWxsO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICB9O1xufVxuLyoqXG4gKiBHaXZlbiBhIHZpc2l0b3IgaW5zdGFuY2UsIGlmIGl0IGlzIGxlYXZpbmcgb3Igbm90LCBhbmQgYSBub2RlIGtpbmQsIHJldHVyblxuICogdGhlIGZ1bmN0aW9uIHRoZSB2aXNpdG9yIHJ1bnRpbWUgc2h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gMCkgeyBkaXNwb3NlID0gZGVmYXVsdERpc3Bvc2U7IH1cclxuICAgICAgICB0aGlzLm1heCA9IG1heDtcclxuICAgICAgICB0aGlzLmRpc3Bvc2UgPSBkaXNwb3NlO1xyXG4gICAgICAgIHRoaXMubWFwID0gbmV3IE1hcCgpO1xyXG4gICAgICAgIHRoaXMubmV3ZXN0ID0gbnVsbDtcclxuICAgICAgICB0aGlzLm9sZGVzdCA9IG51bGw7XHJcbiAgICB9XHJcbiAgICBDYWNoZS5wcm90b3R5cGUuaGFzID0gZnVuY3Rpb24gKGtleSkge1xyXG4gICAgICAgIHJldHVybiB0aGlzLm1hcC5oYXMoa2V5KTtcclxuICAgIH07XHJcbiAgICBDYWNoZS5wcm90b3R5cGUuZ2V0ID0gZnVuY3Rpb24gKGtleSkge1xyXG4gICAgICAgIHZhciBlbnRyeSA9IHRoaXMuZ2V0RW50cnkoa2V5KTtcclxuICAgICAgICByZXR1cm4gZW50cnkgJiYgZW50cnkudmFsdWU7XHJcbiAgICB9O1xyXG4gICAgQ2FjaGUucHJvdG90eXBlLmdldEVudHJ5ID0gZnVuY3Rpb24gKGtleSkge1xyXG4gICAgICAgIHZhciBlbnRyeSA9IHRoaXMubWFwLmdldChrZXkpO1xyXG4gICAgICAgIGlmIChlbnRyeSAmJiBlbnRyeSAhPT0gdGhpcy5uZXdlc3QpIHtcclxuICAgICAgICAgICAgdmFyIG9sZGVyID0gZW50cnkub2xkZXIsIG5ld2VyID0gZW50cnkubmV3ZXI7XHJcbiAgICAgICAgICAgIGlmIChuZXdlcikge1xyXG4gICAgICAgICAgICAgICAgbmV3ZXIub2xkZXIgPSBvbGRlcjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAob2xkZXIpIHtcclxuICAgICAgICAgICAgICAgIG9sZGVyLm5ld2VyID0gbmV3ZXI7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgZW50cnkub2xkZXIgPSB0aGlzLm5ld2VzdDtcclxuICAgICAgICAgICAgZW50cnkub2xkZXIubmV3ZXIgPSBlbnRyeTtcclxuICAgICAgICAgICAgZW50cnkubmV3ZXIgPSBudWxsO1xyXG4gICAgICAgICAgICB0aGlzLm5ld2VzdCA9IGVudHJ5O1xyXG4gICAgICAgICAgICBpZiAoZW50cnkgPT09IHRoaXMub2xkZXN0KSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLm9sZGVzdCA9IG5ld2VyO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBlbnRyeTtcclxuICAgIH07XHJcbiAgICBDYWNoZS5wcm90b3R5cGUuc2V0ID0gZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcclxuICAgICAgICB2YXIgZW50cnkgPSB0aGlzLmdldEVudHJ5KGtleSk7XHJcbiAgICAgICAgaWYgKGVudHJ5KSB7XHJcbiAgICAgICAgICAgIHJldHVybiBlbnRyeS52YWx1ZSA9IHZhbHVlO1xyXG4gICAgICAgIH1cclxuICAgICAgICBlbnRyeSA9IHtcclxuICAgICAgICAgICAga2V5OiBrZXksXHJcbiAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSxcclxuICAgICAgICAgICAgbmV3ZXI6IG51bGwsXHJcbiAgICAgICAgICAgIG9sZGVyOiB0aGlzLm5ld2VzdFxyXG4gICAgICAgIH07XHJcbiAgICAgICAgaWYgKHRoaXMubmV3ZXN0KSB7XHJcbiAgICAgICAgICAgIHRoaXMubmV3ZXN0Lm5ld2VyID0gZW50cnk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMubmV3ZXN0ID0gZW50cnk7XHJcbiAgICAgICAgdGhpcy5vbGRlc3QgPSB0aGlzLm9sZGVzdCB8fCBlbnRyeTtcclxuICAgICAgICB0aGlzLm1hcC5zZXQoa2V5LCBlbnRyeSk7XHJcbiAgICAgICAgcmV0dXJuIGVudHJ5LnZhbHVlO1xyXG4gICAgfTtcclxuICAgIENhY2hlLnByb3RvdHlwZS5jbGVhbiA9IGZ1bmN0aW9uICgpIHtcclxuICAgICAgICB3aGlsZSAodGhpcy5vbGRlc3QgJiYgdGhpcy5tYXAuc2l6ZSA+IHRoaXMubWF4KSB7XHJcbiAgICAgICAgICAgIHRoaXMuZGVsZXRlKHRoaXMub2xkZXN0LmtleSk7XHJcbiAgICAgICAgfVxyXG4gICAgfTtcclxuICAgIENhY2hlLnByb3RvdHlwZS5kZWxldGUgPSBmdW5jdGlvbiAoa2V5KSB7XHJcbiAgICAgICAgdmFyIGVudHJ5ID0gdGhpcy5tYXAuZ2V0KGtleSk7XHJcbiAgICAgICAgaWYgKGVudHJ5KSB7XHJcbiAgICAgICAgICAgIGlmIChlbnRyeSA9PT0gdGhpcy5uZXdlc3QpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMubmV3ZXN0ID0gZW50cnkub2xkZXI7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKGVudHJ5ID09PSB0aGlzLm9sZGVzdCkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5vbGRlc3QgPSBlbnRyeS5uZXdlcjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoZW50cnkubmV3ZXIpIHtcclxuICAgICAgICAgICAgICAgIGVudHJ5Lm5ld2VyLm9sZGVyID0gZW50cnkub2xkZXI7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYgKGVudHJ5Lm9sZGVyKSB7XHJcbiAgICAgICAgICAgICAgICBlbnRyeS5vbGRlci5uZXdlciA9IGVudHJ5Lm5ld2VyO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHRoaXMubWFwLmRlbGV0ZShrZXkpO1xyXG4gICAgICAgICAgICB0aGlzLmRpc3Bvc2UoZW50cnkudmFsdWUsIGtleSk7XHJcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgIH1cclxuICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICB9O1xyXG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mspIDpcbiAgICAgICAgICAgICAgICB0aGlzLl90cnlTdWJzY3JpYmUoc2luaykpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChjb25maWcudXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZykge1xuICAgICAgICAgICAgaWYgKHNpbmsuc3luY0Vycm9yVGhyb3dhYmxlKSB7XG4gICAgICAgICAgICAgICAgc2luay5zeW5jRXJyb3JUaHJvd2FibGUgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBpZiAoc2luay5zeW5jRXJyb3JUaHJvd24pIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgc2luay5zeW5jRXJyb3JWYWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHNpbms7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZS5fdHJ5U3Vic2NyaWJlID0gZnVuY3Rpb24gKHNpbmspIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdWJzY3JpYmUoc2luayk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgaWYgKGNvbmZpZy51c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nKSB7XG4gICAgICAgICAgICAgICAgc2luay5zeW5jRXJyb3JUaHJvd24gPSB0cnVlO1xuICAgICAgICAgICAgICAgIHNpbmsuc3luY0Vycm9yVmFsdWUgPSBlcnI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY2FuUmVwb3J0RXJyb3Ioc2luaykpIHtcbiAgICAgICAgICAgICAgICBzaW5rLmVycm9yKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLndhcm4oZXJyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgT2JzZXJ2YWJsZS5wcm90b3R5cGUuZm9yRWFjaCA9IGZ1bmN0aW9uIChuZXh0LCBwcm9taXNlQ3Rvcikge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBwcm9taXNlQ3RvciA9IGdldFByb21pc2VDdG9yKHByb21pc2VDdG9yKTtcbiAgICAgICAgcmV0dXJuIG5ldyBwcm9taXNlQ3RvcihmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7XG4gICAgICAgICAgICB2YXIgc3Vic2NyaXB0aW9uO1xuICAgICAgICAgICAgc3Vic2NyaXB0aW9uID0gX3RoaXMuc3Vic2NyaWJlKGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIG5leHQodmFsdWUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlamVjdChlcnIpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoc3Vic2NyaXB0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sIHJlamVjdCwgcmVzb2x2ZSk7XG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgT2JzZXJ2YWJsZS5wcm90b3R5cGUuX3N1YnNjcmliZSA9IGZ1bmN0aW9uIChzdWJzY3JpYmVyKSB7XG4gICAgICAgIHZhciBzb3VyY2UgPSB0aGlzLnNvdXJjZTtcbiAgICAgICAgcmV0dXJuIHNvdXJjZSAmJiBzb3VyY2Uuc3Vic2NyaWJlKHN1YnNjcmliZXIpO1xuICAgIH07XG4gICAgT2JzZXJ2YWJsZS5wcm90b3R5cGVbU3ltYm9sX29ic2VydmFibG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wgZXJyb3IsIGNvbXBsZXRlKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IF9zdXBlci5jYWxsKHRoaXMpIHx8IHRoaXM7XG4gICAgICAgIF90aGlzLnN5bmNFcnJvclZhbHVlID0gbnVsbDtcbiAgICAgICAgX3RoaXMuc3luY0Vycm9yVGhyb3duID0gZmFsc2U7XG4gICAgICAgIF90aGlzLnN5bmNFcnJvclRocm93YWJsZSA9IGZhbHNlO1xuICAgICAgICBfdGhpcy5pc1N0b3BwZWQgPSBmYWxzZTtcbiAgICAgICAgc3dpdGNoIChhcmd1bWVudHMubGVuZ3RoKSB7XG4gICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgX3RoaXMuZGVzdGluYXRpb24gPSBlbXB0eU9ic2VydmVyO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAxOlxuICAgICAgICAgICAgICAgIGlmICghZGVzdGluYXRpb25Pck5leHQpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMuZGVzdGluYXRpb24gPSBlbXB0eU9ic2VydmVyO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkZXN0aW5hdGlvbk9yTmV4dCA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc3RpbmF0aW9uT3JOZXh0IGluc3RhbmNlb2YgU3Vic2NyaWJlcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuc3luY0Vycm9yVGhyb3dhYmxlID0gZGVzdGluYXRpb25Pck5leHQuc3luY0Vycm9yVGhyb3dhYmxlO1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuZGVzdGluYXRpb24gPSBkZXN0aW5hdGlvbk9yTmV4dDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RpbmF0aW9uT3JOZXh0LmFkZChfdGhpcyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5zeW5jRXJyb3JUaHJvd2FibGUgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuZGVzdGluYXRpb24gPSBuZXcgU2FmZVN1YnNjcmliZXIoX3RoaXMsIGRlc3RpbmF0aW9uT3JOZXh0KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIF90aGlzLnN5bmNFcnJvclRocm93YWJsZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgX3RoaXMuZGVzdGluYXRpb24gPSBuZXcgU2FmZVN1YnNjcmliZXIoX3RoaXMsIGRlc3RpbmF0aW9uT3JOZXh0LCBlcnJvciwgY29tcGxldGUpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBfdGhpcztcbiAgICB9XG4gICAgU3Vic2NyaWJlci5wcm90b3R5cGVbcnhTdWJzY3JpYmVyU3ltYm9sXSA9IGZ1bmN0aW9uICgpIHsgcmV0dXJuIHRoaXM7IH07XG4gICAgU3Vic2NyaWJlci5jcmVhdGUgPSBmdW5jdGlvbiAobmV4dCwgZXJyb3IsIGNvbXBsZXRlKSB7XG4gICAgICAgIHZhciBzdWJzY3JpYmVyID0gbmV3IFN1YnNjcmliZXIobmV4dCwgZXJyb3IsIGNvbXBsZXRlKTtcbiAgICAgICAgc3Vic2NyaWJlci5zeW5jRXJyb3JUaHJvd2FibGUgPSBmYWxzZTtcbiAgICAgICAgcmV0dXJuIHN1YnNjcmliZXI7XG4gICAgfTtcbiAgICBTdWJzY3JpYmVyLnByb3RvdHlwZS5uZXh0ID0gZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgIG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IHZhciBuZXh0O1xuICAgICAgICB2YXIgY29udGV4dCA9IF90aGlzO1xuICAgICAgICBpZiAoaXNGdW5jdGlvbihvYnNlcnZlck9yTmV4dCkpIHtcbiAgICAgICAgICAgIG5leHQgPSBvYnNlcnZlck9yTmV4dDtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChvYnNlcnZlck9yTmV4dCkge1xuICAgICAgICAgICAgbmV4dCA9IG9ic2VydmVyT3JOZXh0Lm5leHQ7XG4gICAgICAgICAgICBlcnJvciA9IG9ic2VydmVyT3JOZXh0LmVycm9yO1xuICAgICAgICAgICAgY29tcGxldGUgPSBvYnNlcnZlck9yTmV4dC5jb21wbGV0ZTtcbiAgICAgICAgICAgIGlmIChvYnNlcnZlck9yTmV4dCAhPT0gZW1wdHlPYnNlcnZlcikge1xuICAgICAgICAgICAgICAgIGNvbnRleHQgPSBPYmplY3QuY3JlYXRlKG9ic2VydmVyT3JOZXh0KTtcbiAgICAgICAgICAgICAgICBpZiAoaXNGdW5jdGlvbihjb250ZXh0LnVuc3Vic2NyaWJlKSkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5hZGQoY29udGV4dC51bnN1YnNjcmliZS5iaW5kKGNvbnRleHQpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29udGV4dC51bnN1YnNjcmliZSA9IF90aGlzLnVuc3Vic2NyaWJlLmJpbmQoX3RoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIF90aGlzLl9jb250ZXh0ID0gY29udGV4dDtcbiAgICAgICAgX3RoaXMuX25leHQgPSBuZXh0O1xuICAgICAgICBfdGhpcy5fZXJyb3IgPSBlcnJvcjtcbiAgICAgICAgX3RoaXMuX2NvbXBsZXRlID0gY29tcGxldGU7XG4gICAgICAgIHJldHVybiBfdGhpcztcbiAgICB9XG4gICAgU2FmZVN1YnNjcmliZXIucHJvdG90eXBlLm5leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCAmJiB0aGlzLl9uZXh0KSB7XG4gICAgICAgICAgICB2YXIgX3BhcmVudFN1YnNjcmliZXIgPSB0aGlzLl9wYXJlbnRTdWJzY3JpYmVyO1xuICAgICAgICAgICAgaWYgKCFjb25maWcudXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZyB8fCAhX3BhcmVudFN1YnNjcmliZXIuc3luY0Vycm9yVGhyb3dhYmxlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fX3RyeU9yVW5zdWIodGhpcy5fbmV4dCwgdmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAodGhpcy5fX3RyeU9yU2V0RXJyb3IoX3BhcmVudFN1YnNjcmliZXIsIHRoaXMuX25leHQsIHZhbHVlKSkge1xuICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgU2FmZVN1YnNjcmliZXIucHJvdG90eXBlLmVycm9yID0gZnVuY3Rpb24gKGVycikge1xuICAgICAgICBpZiAoIXRoaXMuaXNTdG9wcGVkKSB7XG4gICAgICAgICAgICB2YXIgX3BhcmVudFN1YnNjcmliZXIgPSB0aGlzLl9wYXJlbnRTdWJzY3JpYmVyO1xuICAgICAgICAgICAgdmFyIHVzZURlcHJlY2F0ZWRTeW5jaHJvbm91c0Vycm9ySGFuZGxpbmcgPSBjb25maWcudXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZztcbiAgICAgICAgICAgIGlmICh0aGlzLl9lcnJvcikge1xuICAgICAgICAgICAgICAgIGlmICghdXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZyB8fCAhX3BhcmVudFN1YnNjcmliZXIuc3luY0Vycm9yVGhyb3dhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX190cnlPclVuc3ViKHRoaXMuX2Vycm9yLCBlcnIpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9fdHJ5T3JTZXRFcnJvcihfcGFyZW50U3Vic2NyaWJlciwgdGhpcy5fZXJyb3IsIGVycik7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIGlmICghX3BhcmVudFN1YnNjcmliZXIuc3luY0Vycm9yVGhyb3dhYmxlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIGlmICh1c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaG9zdFJlcG9ydEVycm9yKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZykge1xuICAgICAgICAgICAgICAgICAgICBfcGFyZW50U3Vic2NyaWJlci5zeW5jRXJyb3JWYWx1ZSA9IGVycjtcbiAgICAgICAgICAgICAgICAgICAgX3BhcmVudFN1YnNjcmliZXIuc3luY0Vycm9yVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGhvc3RSZXBvcnRFcnJvcihlcnIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFNhZmVTdWJzY3JpYmVyLnByb3RvdHlwZS5jb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCkge1xuICAgICAgICAgICAgdmFyIF9wYXJlbnRTdWJzY3JpYmVyID0gdGhpcy5fcGFyZW50U3Vic2NyaWJlcjtcbiAgICAgICAgICAgIGlmICh0aGlzLl9jb21wbGV0ZSkge1xuICAgICAgICAgICAgICAgIHZhciB3cmFwcGVkQ29tcGxldGUgPSBmdW5jdGlvbiAoKSB7IHJldHVybiBfdGhpcy5fY29tcGxldGUuY2FsbChfdGhpcy5fY29udGV4dCk7IH07XG4gICAgICAgICAgICAgICAgaWYgKCFjb25maWcudXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZyB8fCAhX3BhcmVudFN1YnNjcmliZXIuc3luY0Vycm9yVGhyb3dhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX190cnlPclVuc3ViKHdyYXBwZWRDb21wbGV0ZSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX190cnlPclNldEVycm9yKF9wYXJlbnRTdWJzY3JpYmVyLCB3cmFwcGVkQ29tcGxldGUpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBTYWZlU3Vic2NyaWJlci5wcm90b3R5cGUuX190cnlPclVuc3ViID0gZnVuY3Rpb24gKGZuLCB2YWx1ZSkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgZm4uY2FsbCh0aGlzLl9jb250ZXh0LCB2YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgaWYgKGNvbmZpZy51c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgZXJyO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgaG9zdFJlcG9ydEVycm9yKGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFNhZmVTdWJzY3JpYmVyLnByb3RvdHlwZS5fX3RyeU9yU2V0RXJyb3IgPSBmdW5jdGlvbiAocGFyZW50LCBmbiwgdmFsdWUpIHtcbiAgICAgICAgaWYgKCFjb25maWcudXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZykge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdiYWQgY2FsbCcpO1xuICAgICAgICB9XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBmbi5jYWxsKHRoaXMuX2NvbnRleHQsIHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBpZiAoY29uZmlnLnVzZURlcHJlY2F0ZWRTeW5jaHJvbm91c0Vycm9ySGFuZGxpbmcpIHtcbiAgICAgICAgICAgICAgICBwYXJlbnQuc3luY0Vycm9yVmFsdWUgPSBlcnI7XG4gICAgICAgICAgICAgICAgcGFyZW50LnN5bmNFcnJvclRocm93biA9IHRydWU7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAg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ZlKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKF9wYXJlbnRPclBhcmVudHMgIT09IG51bGwpIHtcbiAgICAgICAgICAgIGZvciAodmFyIGluZGV4ID0gMDsgaW5kZXggPCBfcGFyZW50T3JQYXJlbnRzLmxlbmd0aDsgKytpbmRleCkge1xuICAgICAgICAgICAgICAgIHZhciBwYXJlbnRfMSA9IF9wYXJlbnRPclBhcmVudHNbaW5kZXhdO1xuICAgICAgICAgICAgICAgIHBhcmVudF8xLnJlbW92ZSh0aGlzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNGdW5jdGlvbihfdW5zdWJzY3JpYmUpKSB7XG4gICAgICAgICAgICBpZiAoX2N0b3JVbnN1YnNjcmliZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuX3Vuc3Vic2NyaWJlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBfdW5zdWJzY3JpYmUuY2FsbCh0aGlzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgZXJyb3JzID0gZSBpbnN0YW5jZW9mIFVuc3Vic2NyaXB0aW9uRXJyb3IgPyBmbGF0dGVuVW5zdWJzY3JpcHRpb25FcnJvcnMoZS5lcnJvcnMpIDogW2VdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChpc0FycmF5KF9zdWJzY3JpcHRpb25zKSkge1xuICAgICAgICAgICAgdmFyIGluZGV4ID0gLTE7XG4gICAgICAgICAgICB2YXIgbGVuID0gX3N1YnNjcmlwdGlvbnMubGVuZ3RoO1xuICAgICAgICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW4pIHtcbiAgICAgICAgICAgICAgICB2YXIgc3ViID0gX3N1YnNjcmlwdGlvbnNbaW5kZXhdO1xuICAgICAgICAgICAgICAgIGlmIChpc09iamVjdChzdWIpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWIudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gZXJyb3JzIHx8IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGUgaW5zdGFuY2VvZiBVbnN1YnNjcmlwdGlvbkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gZXJyb3JzLmNvbmNhdChmbGF0dGVuVW5zdWJzY3JpcHRpb25FcnJvcnMoZS5lcnJvcnMpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChlcnJvcnMpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBVbnN1YnNjcmlwdGlvbkVycm9yKGVycm9ycyk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFN1YnNjcmlwdGlvbi5wcm90b3R5cGUuYWRkID0gZnVuY3Rpb24gKHRlYXJkb3duKSB7XG4gICAgICAgIHZhciBzdWJzY3JpcHRpb24gPSB0ZWFyZG93bjtcbiAgICAgICAgaWYgKCF0ZWFyZG93bikge1xuICAgICAgICAgICAgcmV0dXJuIFN1YnNjcmlwdGlvbi5FTVBUWTtcbiAgICAgICAgfVxuICAgICAgICBzd2l0Y2ggKHR5cGVvZiB0ZWFyZG93bikge1xuICAgICAgICAgICAgY2FzZSAnZnVuY3Rpb24nOlxuICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbiA9IG5ldyBTdWJzY3JpcHRpb24odGVhcmRvd24pO1xuICAgICAgICAgICAgY2FzZSAnb2JqZWN0JzpcbiAgICAgICAgICAgICAgICBpZiAoc3Vic2NyaXB0aW9uID09PSB0aGlzIHx8IHN1YnNjcmlwdGlvbi5jbG9zZWQgfHwgdHlwZW9mIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSAhPT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3Vic2NyaXB0aW9uO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIGlmICh0aGlzLmNsb3NlZCkge1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN1YnNjcmlwdGlvbjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoIShzdWJzY3JpcHRpb24gaW5zdGFuY2VvZiBTdWJzY3JpcHRpb24pKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0bXAgPSBzdWJzY3JpcHRpb247XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbiA9IG5ldyBTdWJzY3JpcHRpb24oKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uLl9zdWJzY3JpcHRpb25zID0gW3RtcF07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgZGVmYXVsdDoge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigndW5yZWNvZ25pemVkIHRlYXJkb3duICcgKyB0ZWFyZG93biArICcgYWRkZWQgdG8gU3Vic2NyaXB0aW9uLicpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHZhciBfcGFyZW50T3JQYXJlbnRzID0gc3Vic2NyaXB0aW9uLl9wYXJlbnRPclBhcmVudHM7XG4gICAgICAgIGlmIChfcGFyZW50T3JQYXJlbnRzID09PSBudWxsKSB7XG4gICAgICAgICAgICBzdWJzY3JpcHRpb24uX3BhcmVudE9yUGFyZW50cyA9IHRoaXM7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoX3BhcmVudE9yUGFyZW50cyBpbnN0YW5jZW9mIFN1YnNjcmlwdGlvbikge1xuICAgICAgICAgICAgaWYgKF9wYXJlbnRPclBhcmVudHMgPT09IHRoaXMpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gc3Vic2NyaXB0aW9uO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3Vic2NyaXB0aW9uLl9wYXJlbnRPclBhcmVudHMgPSBbX3BhcmVudE9yUGFyZW50cywgdGhpc107XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoX3BhcmVudE9yUGFyZW50cy5pbmRleE9mKHRoaXMpID09PSAtMSkge1xuICAgICAgICAgICAgX3BhcmVudE9yUGFyZW50cy5wdXNoKHRoaXMpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHN1YnNjcmlwdGlvbjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgc3Vic2NyaXB0aW9ucyA9IHRoaXMuX3N1YnNjcmlwdGlvbnM7XG4gICAgICAgIGlmIChzdWJzY3JpcHRpb25zID09PSBudWxsKSB7XG4gICAgICAgICAgICB0aGlzLl9zdWJzY3JpcHRpb25zID0gW3N1YnNjcmlwdGlvbl07XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBzdWJzY3JpcHRpb25zLnB1c2goc3Vic2NyaXB0aW9uKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gc3Vic2NyaXB0aW9uO1xuICAgIH07XG4gICAgU3Vic2NyaXB0aW9uLnByb3RvdHlwZS5yZW1vdmUgPSBmd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ICAgICAgICBfdGhpcy5fdGFwQ29tcGxldGUgPSBvYnNlcnZlck9yTmV4dC5jb21wbGV0ZSB8fCBub29wO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBfdGhpcztcbiAgICB9XG4gICAgVGFwU3Vic2NyaWJlci5wcm90b3R5cGUuX25leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHRoaXMuX3RhcE5leHQuY2FsbCh0aGlzLl9jb250ZXh0LCB2YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24ubmV4dCh2YWx1ZSk7XG4gICAgfTtcbiAgICBUYXBTdWJzY3JpYmVyLnByb3RvdHlwZS5fZXJyb3IgPSBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICB0aGlzLl90YXBFcnJvci5jYWxsKHRoaXMuX2NvbnRleHQsIGVycik7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGVzdGluYXRpb24uZXJyb3IoZXJyKTtcbiAgICB9O1xuICAgIFRhcFN1YnNjcmliZXIucHJvdG90eXBlLl9jb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHRoaXMuX3RhcENvbXBsZXRlLmNhbGwodGhpcy5fY29udGV4dCk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5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rpb24nKSk7XG4gICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gZG9uZSgpIHtcbiAgICAgICAgICBzdWJzY3JpcHRpb24udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICByZXNvbHZlKCk7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgc3Vic2NyaXB0aW9uID0gX3RoaXMuc3Vic2NyaWJlKHtcbiAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgIGZuKHZhbHVlLCBkb25lKTtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgcmVqZWN0KGUpO1xuICAgICAgICAgICAgICBzdWJzY3JpcHRpb24udW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgIGVycm9yOiByZWplY3QsXG4gICAgICAgICAgY29tcGxldGU6IHJlc29sdmVcbiAgICAgICAgfSk7XG4gICAgICB9KTtcbiAgICB9XG4gIH0sIHtcbiAgICBrZXk6IFwibWFwXCIsXG4gICAgdmFsdWU6IGZ1bmN0aW9uIG1hcChmbikge1xuICAgICAgdmFyIF90aGlzMiA9IHRoaXM7XG5cbiAgICAgIGlmICh0eXBlb2YgZm4gIT09ICdmdW5jdGlvbicpIHRocm93IG5ldyBUeXBlRXJyb3IoZm4gKyAnIGlzIG5vdCBhIGZ1bmN0aW9uJyk7XG4gICAgICB2YXIgQyA9IGdldFNwZWNpZXModGhpcyk7XG4gICAgICByZXR1cm4gbmV3IEMoZnVuY3Rpb24gKG9ic2VydmVyKSB7XG4gICAgICAgIHJldHVybiBfdGhpczIuc3Vic2NyaWJlKHtcbiAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgIHZhbHVlID0gZm4odmFsdWUpO1xuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICByZXR1cm4gb2JzZXJ2ZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIG9ic2VydmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgIH0sXG4gICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICBvYnNlcnZlci5lcnJvcihlKTtcbiAgICAgICAgICB9LFxuICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBvYnNlcnZlci5jb21wbGV0ZSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICB9KTtcbiAgICB9XG4gIH0sIHtcbiAgICBrZXk6IFwiZmlsdGVyXCIsXG4gICAgdmFsdWU6IGZ1bmN0aW9uIGZpbHRlcihmbikge1xuICAgICAgdmFyIF90aGlzMyA9IHRoaXM7XG5cbiAgICAgIGlmICh0eXBlb2YgZm4gIT09ICdmdW5jdGlvbicpIHRocm93IG5ldyBUeXBlRXJyb3IoZm4gKyAnIGlzIG5vdCBhIGZ1bmN0aW9uJyk7XG4gICAgICB2YXIgQyA9IGdldFNwZWNpZXModGhpcyk7XG4gICAgICByZXR1cm4gbmV3IEMoZnVuY3Rpb24gKG9ic2VydmVyKSB7XG4gICAgICAgIHJldHVybiBfdGhpczMuc3Vic2NyaWJlKHtcbiAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgIGlmICghZm4odmFsdWUpKSByZXR1cm47XG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgIHJldHVybiBvYnNlcnZlci5lcnJvcihlKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgb2JzZXJ2ZXIubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgfSxcbiAgICAgICAgICBl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gICAgICByZXR1cm4gb2JzZXJ2ZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGFjYyA9IHZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICBvYnNlcnZlci5lcnJvcihlKTtcbiAgICAgICAgICB9LFxuICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoIWhhc1ZhbHVlICYmICFoYXNTZWVkKSByZXR1cm4gb2JzZXJ2ZXIuZXJyb3IobmV3IFR5cGVFcnJvcignQ2Fubm90IHJlZHVjZSBhbiBlbXB0eSBzZXF1ZW5jZScpKTtcbiAgICAgICAgICAgIG9ic2VydmVyLm5leHQoYWNjKTtcbiAgICAgICAgICAgIG9ic2VydmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH0pO1xuICAgIH1cbiAgfSwge1xuICAgIGtleTogXCJjb25jYXRcIixcbiAgICB2YWx1ZTogZnVuY3Rpb24gY29uY2F0KCkge1xuICAgICAgdmFyIF90aGlzNSA9IHRoaXM7XG5cbiAgICAgIGZvciAodmFyIF9sZW4gPSBhcmd1bWVudHMubGVuZ3RoLCBzb3VyY2VzID0gbmV3IEFycmF5KF9sZW4pLCBfa2V5ID0gMDsgX2tleSA8IF9sZW47IF9rZXkrKykge1xuICAgICAgICBzb3VyY2VzW19rZXldID0gYXJndW1lbnRzW19rZXldO1xuICAgICAgfVxuXG4gICAgICB2YXIgQyA9IGdldFNwZWNpZXModGhpcyk7XG4gICAgICByZXR1cm4gbmV3IEMoZnVuY3Rpb24gKG9ic2VydmVyKSB7XG4gICAgICAgIHZhciBzdWJzY3JpcHRpb247XG4gICAgICAgIHZhciBpbmRleCA9IDA7XG5cbiAgICAgICAgZnVuY3Rpb24gc3RhcnROZXh0KG5leHQpIHtcbiAgICAgICAgICBzdWJzY3JpcHRpb24gPSBuZXh0LnN1YnNjcmliZSh7XG4gICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodikge1xuICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHYpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGVycm9yOiBmdW5jdGlvbiAoZSkge1xuICAgICAgICAgICAgICBvYnNlcnZlci5lcnJvcihlKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjb21wbGV0ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IHNvdXJjZXMubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIG9ic2VydmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgc3RhcnROZXh0KEMuZnJvbShzb3VyY2VzW2luZGV4KytdKSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHN0YXJ0TmV4dChfdGhpczUpO1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xuICAgICAgICAgIGlmIChzdWJzY3JpcHRpb24pIHtcbiAgICAgICAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgc3Vic2NyaXB0aW9uID0gdW5kZWZpbmVkO1xuICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgIH0pO1xuICAgIH1cbiAgfSwge1xuICAgIGtleTogXCJmbGF0TWFwXCIsXG4gICAgdmFsdWU6IGZ1bmN0aW9uIGZsYXRNYXAoZm4pIHtcbiAgICAgIHZhciBfdGhpczYgPSB0aGlzO1xuXG4gICAgICBpZiAodHlwZW9mIGZuICE9PSAnZnVuY3Rpb24nKSB0aHJvdyBuZXcgVHlwZUVycm9yKGZuICsgJyBpcyBub3QgYSBmdW5jdGlvbicpO1xuICAgICAgdmFyIEMgPSBnZXRTcGVjaWVzKHRoaXMpO1xuICAgICAgcmV0dXJuIG5ldyBDKGZ1bmN0aW9uIChvYnNlcnZlcikge1xuICAgICAgICB2YXIgc3Vic2NyaXB0aW9ucyA9IFtdO1xuXG4gICAgICAgIHZhciBvdXRlciA9IF90aGlzNi5zdWJzY3JpYmUoe1xuICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgaWYgKGZuKSB7XG4gICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgdmFsdWUgPSBmbih2YWx1ZSk7XG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gb2JzZXJ2ZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIGlubmVyID0gQy5mcm9tKHZhbHVlKS5zdWJzY3JpYmUoe1xuICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgICAgb2JzZXJ2ZXIuZXJyb3IoZSk7XG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdmFyIGkgPSBzdWJzY3JpcHRpb25zLmluZGV4T2YoaW5uZXIpO1xuICAgICAgICAgICAgICAgIGlmIChpID49IDApIHN1YnNjcmlwdGlvbnMuc3BsaWNlKGksIDEpO1xuICAgICAgICAgICAgICAgIGNvbXBsZXRlSWZEb25lKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgc3Vic2NyaXB0aW9ucy5wdXNoKGlubmVyKTtcbiAgICAgICAgICB9LFxuICAgICAgICAgIGVycm9yOiBmdW5jdGlvbiAoZSkge1xuICAgICAgICAgICAgb2JzZXJ2ZXIuZXJyb3IoZSk7XG4gICAgICAgICAgfSxcbiAgICAgICAgICBjb21wbGV0ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgY29tcGxldGVJZkRvbmUoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGZ1bmN0aW9uIGNvbXBsZXRlSWZEb25lKCkge1xuICAgICAgICAgIGlmIChvdXRlci5jbG9zZWQgJiYgc3Vic2NyaXB0aW9ucy5sZW5ndGggPT09IDApIG9ic2VydmVyLmNvbXBsZXRlKCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkge1xuICAgICAgICAgIHN1YnNjcmlwdGlvbnMuZm9yRWFjaChmdW5jdGlvbiAocykge1xuICAgICAgICAgICAgcmV0dXJuIHMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgICBvdXRlci51bnN1YnNjcmliZSgpO1xuICAgICAgICB9O1xuICAgICAgfSk7XG4gICAgfVxuICB9LCB7XG4gICAga2V5OiBTeW1ib2xPYnNlcnZhYmxlLFxuICAgIHZhbHVlOiBmdW5jdGlvbiAoKSB7XG4gICAgICByZXR1cm4gdGhpcztcbiAgICB9XG4gIH1dLCBbe1xuICAgIGtleTogXCJmcm9tXCIsXG4gICAgdmFsdWU6IGZ1bmN0aW9uIGZyb20oeCkge1xuICAgICAgdmFyIEMgPSB0eXBlb2YgdGhpcyA9PT0gJ2Z1bmN0aW9uJyA/IHRoaXMgOiBPYnNlcnZhYmxlO1xuICAgICAgaWYgKHggPT0gbnVsbCkgdGhyb3cgbmV3IFR5cGVFcnJvcih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ICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgX2l0ZXJhdG9yID0gbWV0aG9kLmNhbGwoeClbU3ltYm9sLml0ZXJhdG9yXSgpLCBfc3RlcDsgIShfaXRlcmF0b3JOb3JtYWxDb21wbGV0aW9uID0gKF9zdGVwID0gX2l0ZXJhdG9yLm5leHQoKSkuZG9uZSk7IF9pdGVyYXRvck5vcm1hbENvbXBsZXRpb24gPSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICB2YXIgX2l0ZW0gPSBfc3RlcC52YWx1ZTtcbiAgICAgICAgICAgICAgICAgIG9ic2VydmVyLm5leHQoX2l0ZW0pO1xuICAgICAgICAgICAgICAgICAgaWYgKG9ic2VydmVyLmNsb3NlZCkgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgX2RpZEl0ZXJhdG9yRXJyb3IgPSB0cnVlO1xuICAgICAgICAgICAgICAgIF9pdGVyYXRvckVycm9yID0gZXJyO1xuICAgICAgICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICBpZiAoIV9pdGVyYXRvck5vcm1hbENvbXBsZXRpb24gJiYgX2l0ZXJhdG9yLnJldHVybiAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIF9pdGVyYXRvci5yZXR1cm4oKTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgaWYgKF9kaWRJdGVyYXRvckVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IF9pdGVyYXRvckVycm9yO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIG9ic2VydmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICBpZiAoQXJyYXkuaXNBcnJheSh4KSkge1xuICAgICAgICByZXR1cm4gbmV3IEMoZnVuY3Rpb24gKG9ic2VydmVyKSB7XG4gICAgICAgICAgZW5xdWV1ZShmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAob2JzZXJ2ZXIuY2xvc2VkKSByZXR1cm47XG5cbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgeC5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgICBvYnNlcnZlci5uZXh0KHhbaV0pO1xuICAgICAgICAgICAgICBpZiAob2JzZXJ2ZXIuY2xvc2VkKSByZXR1cm47XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIG9ic2VydmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgICAgfVxuXG4gICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKHggKyAnIGlzIG5vdCBvYnNlcnZhYmxlJyk7XG4gICAgfVxuICB9LCB7XG4gICAga2V5OiBcIm9mXCIsXG4gICAgdmFsdWU6IGZ1bmN0aW9uIG9mKCkge1xuICAgICAgZm9yICh2YXIgX2xlbjIgPSBhcmd1bWVudHMubGVuZ3RoLCBpdGVtcyA9IG5ldyBBcnJheShfbGVuMiksIF9rZXkyID0gMDsgX2tleTIgPCBfbGVuMjsgX2tleTIrKykge1xuICAgICAgICBpdGVtc1tfa2V5Ml0gPSBhcmd1bWVudHNbX2tleTJdO1xuICAgICAgfVxuXG4gICAgICB2YXIgQyA9IHR5cGVvZiB0aGlzID09PSAnZnVuY3Rpb24nID8gdGhpcyA6IE9ic2VydmFibGU7XG4gICAgICByZXR1cm4gbmV3IEMoZnVuY3Rpb24gKG9ic2VydmVyKSB7XG4gICAgICAgIGVucXVldWUoZnVuY3Rpb24gKCkge1xuICAgICAgICAgIGlmIChv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gICAgc3dpdGNoICh0aGlzLnN0YXR1cykge1xuICAgICAgY2FzZSBDUkVBVEVfRUxFQ1RJT046IHtcbiAgICAgICAgaWYgKG1lc3NhZ2VJZGVudGlmaWVyLnR5cGUgPT09IENSRUFURV9FTEVDVElPTikge1xuICAgICAgICAgIHRoaXMuc3RhdHVzID0gS0VZX0NFUkVNT05ZX1NURVBfMTtcbiAgICAgICAgICB0aGlzLmVsZWN0aW9uSWQgPSBtZXNzYWdlSWRlbnRpZmllci5lbGVjdGlvbklkO1xuICAgICAgICAgIHRoaXMucHJvY2Vzc2VkTWVzc2FnZXMgPSBbXTtcbiAgICAgICAgICB0aGlzLmVsZWN0aW9uVHJ1c3RlZXNDb3VudCA9IG1lc3NhZ2UudHJ1c3RlZXMubGVuZ3RoO1xuICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBtZXNzYWdlX2lkOiBNZXNzYWdlSWRlbnRpZmllci5mb3JtYXQoXG4gICAgICAgICAgICAgIHRoaXMuZWxlY3Rpb25JZCxcbiAgICAgICAgICAgICAgS0VZX0NFUkVNT05ZX1NURVBfMSxcbiAgICAgICAgICAgICAgVFJVU1RFRV9UWVBFLFxuICAgICAgICAgICAgICB0aGlzLnRydXN0ZWVJZFxuICAgICAgICAgICAgKSxcbiAgICAgICAgICAgIGNvbnRlbnQ6IEpTT04uc3RyaW5naWZ5KHtcbiAgICAgICAgICAgICAgZWxlY3Rpb25fcHVibGljX2tleTogNyxcbiAgICAgICAgICAgICAgb3duZXJfaWQ6IHRoaXMudHJ1c3RlZUlkLFxuICAgICAgICAgICAgfSksXG4gICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgICAgICBicmVhaztcbiAgICAgIH1cbiAgICAgIGNhc2UgS0VZX0NFUkVNT05ZX1NURVBfMToge1xuICAgICAgICBpZiAobWVzc2FnZUlkZW50aWZpZXIudHlwZVN1YnR5cGUgPT09IEtFWV9DRVJFTU9OWV9TVEVQXzEpIHtcbiAgICAgICAgICB0aGlzLnByb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VmKSB7XG4gICAgICAgICAgICByZXR1cm4gaXNSZWZlcmVuY2Uob2JqT3JSZWYpXG4gICAgICAgICAgICAgICAgPyBfdGhpcy5oYXMob2JqT3JSZWYuX19yZWYpXG4gICAgICAgICAgICAgICAgOiB0eXBlb2Ygb2JqT3JSZWYgPT09IFwib2JqZWN0XCI7XG4gICAgICAgIH07XG4gICAgICAgIHRoaXMudG9SZWZlcmVuY2UgPSBmdW5jdGlvbiAob2JqT3JJZE9yUmVmLCBtZXJnZUludG9TdG9yZSkge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBvYmpPcklkT3JSZWYgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gbWFrZVJlZmVyZW5jZShvYmpPcklkT3JSZWYpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGlzUmVmZXJlbmNlKG9iak9ySWRPclJlZikpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gb2JqT3JJZE9yUmVmO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGlkID0gX3RoaXMucG9saWNpZXMuaWRlbnRpZnkob2JqT3JJZE9yUmVmKVswXTtcbiAgICAgICAgICAgIGlmIChpZCkge1xuICAgICAgICAgICAgICAgIHZhciByZWYgPSBtYWtlUmVmZXJlbmNlKGlkKTtcbiAgICAgICAgICAgICAgICBpZiAobWVyZ2VJbnRvU3RvcmUpIHtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMubWVyZ2UoaWQsIG9iak9ySWRPclJlZik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiByZWY7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfVxuICAgIEVudGl0eVN0b3JlLnByb3RvdHlwZS50b09iamVjdCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgcmV0dXJuIF9fYXNzaWduKHt9LCB0aGlzLmRhdGEpO1xuICAgIH07XG4gICAgRW50aXR5U3R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cbiAgICAgICAgICAgICAgICAgICAgaWYgKCFleGlzdGluZyB8fCBleGlzdGluZ1tzdG9yZUZpZWxkTmFtZV0gIT09IG1lcmdlZFtzdG9yZUZpZWxkTmFtZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkc1RvRGlydHlfMVtmaWVsZE5hbWVGcm9tU3RvcmVOYW1lKHN0b3JlRmllbGROYW1lKV0gPSAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1lcmdlZFtzdG9yZUZpZWxkTmFtZV0gPT09IHZvaWQgMCAmJiAhKF90aGlzIGluc3RhbmNlb2YgTGF5ZXIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIG1lcmdlZFtzdG9yZUZpZWxkTmFtZV07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBPYmplY3Qua2V5cyhmaWVsZHNUb0RpcnR5XzEpLmZvckVhY2goZnVuY3Rpb24gKGZpZWxkTmFtZSkgeyByZXR1cm4gX3RoaXMuZ3JvdXAuZGlydHkoZGF0YUlkLCBmaWVsZE5hbWUpOyB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgRW50aXR5U3RvcmUucHJvdG90eXBlLm1vZGlmeSA9IGZ1bmN0aW9uIChkYXRhSWQsIGZpZWxkcykge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgc3RvcmVPYmplY3QgPSB0aGlzLmxvb2t1cChkYXRhSWQpO1xuICAgICAgICBpZiAoc3RvcmVPYmplY3QpIHtcbiAgICAgICAgICAgIHZhciBjaGFuZ2VkRmllbGRzXzEgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICAgICAgdmFyIG5lZWRUb01lcmdlXzEgPSBmYWxzZTtcbiAgICAgICAgICAgIHZhciBhbGxEZWxldGVkXzEgPSB0cnVlO1xuICAgICAgICAgICAgdmFyIHNoYXJlZERldGFpbHNfMSA9IHtcbiAgICAgICAgICAgICAgICBERUxFVEU6IERFTEVURSxcbiAgICAgICAgICAgICAgICBJTlZBTElEQVRFOiBJTlZBTElEQVRFLFxuICAgICAgICAgICAgICAgIGlzUmVmZXJlbmNlOiBpc1JlZmVyZW5jZSxcbiAgICAgICAgICAgICAgICB0b1JlZmVyZW5jZTogdGhpcy50b1JlZmVyZW5jZSxcbiAgICAgICAgICAgICAgICBjYW5SZWFkOiB0aGlzLmNhblJlYWQsXG4gICAgICAgICAgICAgICAgcmVhZEZpZWxkOiBmdW5jdGlvbiAoZmllbGROYW1lT3JPcHRpb25zLCBmcm9tKSB7IHJldHVybiBfdGhpcy5wb2xpY2llcy5yZWFkRmllbGQodHlwZW9mIGZpZWxkTmFtZU9yT3B0aW9ucyA9PT0gXCJzdHJpbmdcIiA/IHtcbiAgICAgICAgICAgICAgICAgICAgZmllbGROYW1lOiBmaWVsZE5hbWVPck9wdGlvbnMsXG4gICAgICAgICAgICAgICAgICAgIGZyb206IGZyb20gfHwgbWFrZVJlZmVyZW5jZShkYXRhSWQpLFxuICAgICAgICAgICAgICAgIH0gOiBmaWVsZE5hbWVPck9wdGlvbnMsIHsgc3RvcmU6IF90aGlzIH0pOyB9LFxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIE9iamVjdC5rZXlzKHN0b3JlT2JqZWN0KS5mb3JFYWNoKGZ1bmN0aW9uIChzdG9yZUZpZWxkTmFtZSkge1xuICAgICAgICAgICAgICAgIHZhciBmaWVsZE5hbWUgPSBmaWVsZE5hbWVGcm9tU3RvcmVOYW1lKHN0b3JlRmllbGROYW1lKTtcbiAgICAgICAgICAgICAgICB2YXIgZmllbGRWYWx1ZSA9IHN0b3JlT2JqZWN0W3N0b3JlRmllbGROYW1lXTtcbiAgICAgICAgICAgICAgICBpZiAoZmllbGRWYWx1ZSA9PT0gdm9pZCAwKVxuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgdmFyIG1vZGlmeSA9IHR5cGVvZiBmaWVsZHMgPT09IFwiZnVuY3Rpb25cIlxuICAgICAgICAgICAgICAgICAgICA/IGZpZWxkc1xuICAgICAgICAgICAgICAgICAgICA6IGZpZWxkc1tzdG9yZUZpZWxkTmFtZV0gfHwgZmllbGRzW2ZpZWxkTmFtZV07XG4gICAgICAgICAgICAgICAgaWYgKG1vZGlmeSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgbmV3VmFsdWUgPSBtb2RpZnkgPT09IGRlbE1vZGlmaWVyID8gREVMRVRFIDpcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmeShtYXliZURlZXBGcmVlemUoZmllbGRWYWx1ZSksIF9fYXNzaWduKF9fYXNzaWduKHt9LCBzaGFyZWREZXRhaWxzXzEpLCB7IGZpZWxkTmFtZTogZmllbGROYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JlRmllbGROYW1lOiBzdG9yZUZpZWxkTmFtZSwgc3RvcmFnZTogX3RoaXMuZ2V0U3RvcmFnZShkYXRhSWQsIHN0b3JlRmllbGROYW1lKSB9KSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChuZXdWYWx1ZSA9PT0gSU5WQUxJREFURSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuZ3JvdXAuZGlydHkoZGF0YUlkLCBzdG9yZUZpZWxkTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV3VmFsdWUgPT09IERFTEVURSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdWYWx1ZSA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXdWYWx1ZSAhPT0gZmllbGRWYWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5nZWRGaWVsZHNfMVtzdG9yZUZpZWxkTmFtZV0gPSBuZXdWYWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkVG9NZXJnZV8xID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZFZhbHVlID0gbmV3VmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGZpZWxkVmFsdWUgIT09IHZvaWQgMCkge1xuICAgICAgICAgICAgICAgICAgICBhbGxEZWxldGVkXzEgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGlmIChuZWVkVG9NZXJnZV8xKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5tZXJnZShkYXRhSWQsIGNoYW5nZWRGaWVsZHNfMSk7XG4gICAgICAgICAgICAgICAgaWYgKGFsbERlbGV0ZWRfMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcyBpbnN0YW5jZW9mIExheWVyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGFbZGF0YUlkXSA9IHZvaWQgMDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmRhdGFbZGF0YUlkXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB0aGlzLmdyb3VwLmRpcnR5KGRhdGFJZCwgXCJfX2V4aXN0c1wiKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH07XG4gICAgRW50aXR5U3Rv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zLmZpZWxkTmFtZSwgb3B0aW9ucy5hcmdzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh0aGlzIGluc3RhbmNlb2YgTGF5ZXIpIHtcbiAgICAgICAgICAgICAgICBldmljdGVkID0gdGhpcy5wYXJlbnQuZXZpY3Qob3B0aW9ucykgfHwgZXZpY3RlZDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChvcHRpb25zLmZpZWxkTmFtZSB8fCBldmljdGVkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5ncm91cC5kaXJ0eShvcHRpb25zLmlkLCBvcHRpb25zLmZpZWxkTmFtZSB8fCBcIl9fZXhpc3RzXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBldmljdGVkO1xuICAgIH07XG4gICAgRW50aXR5U3RvcmUucHJvdG90eXBlLmNsZWFyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnJlcGxhY2UobnVsbCk7XG4gICAgfTtcbiAgICBFbnRpdHlTdG9yZS5wcm90b3R5cGUucmVwbGFjZSA9IGZ1bmN0aW9uIChuZXdEYXRhKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIE9iamVjdC5rZXlzKHRoaXMuZGF0YSkuZm9yRWFjaChmdW5jdGlvbiAoZGF0YUlkKSB7XG4gICAgICAgICAgICBpZiAoIShuZXdEYXRhICYmIGhhc093bi5jYWxsKG5ld0RhdGEsIGRhdGFJZCkpKSB7XG4gICAgICAgICAgICAgICAgX3RoaXMuZGVsZXRlKGRhdGFJZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICBpZiAobmV3RGF0YSkge1xuICAgICAgICAgICAgT2JqZWN0LmtleXMobmV3RGF0YSkuZm9yRWFjaChmdW5jdGlvbiAoZGF0YUlkKSB7XG4gICAgICAgICAgICAgICAgX3RoaXMubWVyZ2UoZGF0YUlkLCBuZXdEYXRhW2RhdGFJZF0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIEVudGl0eVN0b3JlLnByb3RvdHlwZS5yZXRhaW4gPSBmdW5jdGlvbiAocm9vdElkKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnJvb3RJZHNbcm9vdElkXSA9ICh0aGlzLnJvb3RJZHNbcm9vdElkXSB8fCAwKSArIDE7XG4gICAgfTtcbiAgICBFbnRpdHlTdG9yZS5wcm90b3R5cGUucmVsZWFzZSA9IGZ1bmN0aW9uIChyb290SWQpIHtcbiAgICAgICAgaWYgKHRoaXMucm9vdElkc1tyb290SWRdID4gMCkge1xuICAgICAgICAgICAgdmFyIGNvdW50ID0gLS10aGlzLnJvb3RJZHNbcm9vdElkXTtcbiAgICAgICAgICAgIGlmICghY291bnQpXG4gICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucm9vdElkc1tyb290SWRdO1xuICAgICAgICAgICAgcmV0dXJuIGNvdW50O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiAwO1xuICAgIH07XG4gICAgRW50aXR5U3RvcmUucHJvdG90eXBlLmdldFJvb3RJZFNldCA9IGZ1bmN0aW9uIChpZHMpIHtcbiAgICAgICAgaWYgKGlkcyA9PT0gdm9pZCAwKSB7IGlkcyA9IG5ldyBTZXQoKTsgfVxuICAgICAgICBPYmplY3Qua2V5cyh0aGlzLnJvb3RJZHMpLmZvckVhY2goaWRzLmFkZCwgaWRzKTtcbiAgICAgICAgaWYgKHRoaXMgaW5zdGFuY2VvZiBMYXllcikge1xuICAgICAgICAgICAgdGhpcy5wYXJlbnQuZ2V0Um9vdElkU2V0KGlkcyk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBPYmplY3Qua2V5cyh0aGlzLnBvbGljaWVzLnJvb3RUeXBlbmFtZXNCeUlkKS5mb3JFYWNoKGlkcy5hZGQsIGlkcyk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGlkcztcbiAgICB9O1xuICAgIEVudGl0eVN0b3JlLnByb3RvdHlwZS5nYyA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIGlkcyA9IHRoaXMuZ2V0Um9vdElkU2V0KCk7XG4gICAgICAgIHZhciBzbmFwc2hvdCA9IHRoaXMudG9PYmplY3QoKTtcbiAgICAgICAgaWRzLmZvckVhY2goZnVuY3Rpb24gKGlkKSB7XG4gICAgICAgICAgICBpZiAoaGFzT3duLmNhbGwoc25hcHNob3QsIGlkKSkge1xuICAgICAgICAgICAgICAgIE9iamVjdC5rZXlzKF90aGlzLmZpbmRDaGlsZFJlZklkcyhpZCkpLmZvckVhY2goaWRzLmFkZCwgaWRzKTtcbiAgICAgICAgICAgICAgICBkZWxldGUgc25hcHNob3RbaWRdO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdmFyIGlkc1RvUmVtb3ZlID0gT2JqZWN0LmtleXMoc25hcHNob3QpO1xuICAgICAgICBpZiAoaWRzVG9SZW1vdmUubGVuZ3RoKSB7XG4gICAgICAgICAgICB2YXIgcm9vdF8xID0gdGhpcztcbiAgICAgICAgICAgIHdoaWxlIChyb290XzEgaW5zdGFuY2VvZiBMYXllcilcbiAgICAgICAgICAgICAgICByb290XzEgPSByb290XzEucGFyZW50O1xuICAgICAgICAgICAgaWRzVG9SZW1vdmUuZm9yRWFjaChmdW5jdGlvbiAoaWQpIHsgcmV0dXJuIHJvb3RfMS5kZWxldGUoaWQpOyB9KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gaWRzVG9SZW1vdmU7XG4gICAgfTtcbiAgICBFbnRpdHlTdG9yZS5wcm90b3R5cGUuZmluZENoaWxkUmVmSWRzID0gZnVuY3Rpb24gKGRhdGFJZCkge1xuICAgICAgICBpZiAoIWhhc093bi5jYWxsKHRoaXMucmVmcywgZGF0YUlkKSkge1xuICAgICAgICAgICAgdmFyIGZvdW5kXzEgPSB0aGlzLnJlZnNbZGF0YUlkXSA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgICAgICAgICB2YXIgd29ya1NldF8xID0gbmV3IFNldChbdGhpcy5kYXRhW2RhdGFJZF1dKTtcbiAgICAgICAgICAgIHZhciBjYW5UcmF2ZXJzZV8xID0gZnVuY3Rpb24gKG9iaikgeyByZXR1cm4gb2JqICE9PSBudWxsICYmIHR5cGVvZiBvYmogPT09ICdvYmplY3QnOyB9O1xuICAgICAgICAgICAgd29ya1NldF8xLmZvckVhY2goZnVuY3Rpb24gKG9iaikge1xuICAgICAgICAgICAgICAgIGlmIChpc1JlZmVyZW5jZShvYmopKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvdW5kXzFbb2JqLl9fcmVmXSA9IHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKGNhblRyYXZlcnNlXzEob2JqKSkge1xuICAgICAgICAgICAgICAgICAgICBPYmplY3QudmFsdWVzKG9iailcbiAgICAgICAgICAgICAgICAgICAgICAgIC5maWx0ZXIoY2FuVHJhdmVyc2VfMSlcbiAgICAgICAgICAgICAgICAgICAgICAgIC5mb3JFYWNoKHdvcmtTZXRfMS5hZGQsIHdvcmtTZXRfMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXMucmVmc1tkYXRhSWRdO1xuICAgIH07XG4gICAgRW50aXR5U3RvcmUucHJvdG90eXBlLm1ha2VDYWNoZUtleSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIGFyZ3MgPSBbXTtcbiAgICAgICAgZm9yICh2YXIgX2kgPSAwOyBfaSA8IGFyZ3VtZW50cy5sZW5ndGg7IF9pKyspIHtcbiAgICAgICAgICAgIGFyZ3NbX2ldID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5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50aXR5U3RvcmUpIHtcbiAgICB2YXIgUm9vdCA9IChmdW5jdGlvbiAoX3N1cGVyKSB7XG4gICAgICAgIF9fZXh0ZW5kcyhSb290LCBfc3VwZXIpO1xuICAgICAgICBmdW5jdGlvbiBSb290KF9hKSB7XG4gICAgICAgICAgICB2YXIgcG9saWNpZXMgPSBfYS5wb2xpY2llcywgX2IgPSBfYS5yZXN1bHRDYWNoaW5nLCByZXN1bHRDYWNoaW5nID0gX2IgPT09IHZvaWQgMCA/IHRydWUgOiBfYiwgc2VlZCA9IF9hLnNlZWQ7XG4gICAgICAgICAgICB2YXIgX3RoaXMgPSBfc3VwZXIuY2FsbCh0aGlzLCBwb2xpY2llcywgbmV3IENhY2hlR3JvdXAocmVzdWx0Q2FjaGluZykpIHx8IHRoaXM7XG4gICAgICAgICAgICBfdGhpcy5zdG9yYWdlVHJpZSA9IG5ldyBLZXlUcmllKGNhblVzZVdlYWtNYXApO1xuICAgICAgICAgICAgX3RoaXMuc2hhcmVkTGF5ZXJHcm91cCA9IG5ldyBDYWNoZUdyb3VwKHJlc3VsdENhY2hpbmcpO1xuICAgICAgICAgICAgaWYgKHNlZWQpXG4gICAgICAgICAgICAgICAgX3RoaXMucmVwbGFjZShzZWVkKTtcbiAgICAgICAgICAgIHJldHVybiBfdGhpcztcbiAgICAgICAgfVxuICAgICAgICBSb290LnByb3RvdHlwZS5hZGRMYXllciA9IGZ1bmN0aW9uIChsYXllcklkLCByZXBsYXkpIHtcbiAgICAgICAgICAgIHJldHVybiBuZXcgTGF5ZXIobGF5ZXJJZCwgdGhpcywgcmVwbGF5LCB0aGlzLnNoYXJlZExheWVyR3JvdXApO1xuICAgICAgICB9O1xuICAgICAgICBSb290LnByb3RvdHlwZS5yZW1vdmVMYXllciA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9O1xuICAgICAgICBSb290LnByb3RvdHlwZS5nZXRTdG9yYWdlID0gZnVuY3Rpb24g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udC5yZW1vdmVMYXllcihsYXllcklkKTtcbiAgICAgICAgaWYgKGxheWVySWQgPT09IHRoaXMuaWQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmdyb3VwLmNhY2hpbmcpIHtcbiAgICAgICAgICAgICAgICBPYmplY3Qua2V5cyh0aGlzLmRhdGEpLmZvckVhY2goZnVuY3Rpb24gKGRhdGFJZCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoX3RoaXMuZGF0YVtkYXRhSWRdICE9PSBwYXJlbnQubG9va3VwKGRhdGFJZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLmRlbGV0ZShkYXRhSWQpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcGFyZW50O1xuICAgICAgICB9XG4gICAgICAgIGlmIChwYXJlbnQgPT09IHRoaXMucGFyZW50KVxuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgIHJldHVybiBwYXJlbnQuYWRkTGF5ZXIodGhpcy5pZCwgdGhpcy5yZXBsYXkpO1xuICAgIH07XG4gICAgTGF5ZXIucHJvdG90eXBlLnRvT2JqZWN0ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gX19hc3NpZ24oX19hc3NpZ24oe30sIHRoaXMucGFyZW50LnRvT2JqZWN0KCkpLCB0aGlzLmRhdGEpO1xuICAgIH07XG4gICAgTGF5ZXIucHJvdG90eXBlLmZpbmRDaGlsZFJlZklkcyA9IGZ1bmN0aW9uIChkYXRhSWQpIHtcbiAgICAgICAgdmFyIGZyb21QYXJlbnQgPSB0aGlzLnBhcmVudC5maW5kQ2hpbGRSZWZJZHMoZGF0YUlkKTtcbiAgICAgICAgcmV0dXJuIGhhc093bi5jYWxsKHRoaXMuZGF0YSwgZGF0YUlkKSA/IF9fYXNzaWduKF9fYXNzaWduKHt9LCBmcm9tUGFyZW50KSwgX3N1c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29uZmlnOiB0aGlzLmNvbmZpZyxcbiAgICAgICAgICAgIHJldHVyblBhcnRpYWxEYXRhOiBmYWxzZSxcbiAgICAgICAgfSkucmVzdWx0IHx8IG51bGw7XG4gICAgfTtcbiAgICBJbk1lbW9yeUNhY2hlLnByb3RvdHlwZS53cml0ZSA9IGZ1bmN0aW9uIChvcHRpb25zKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICArK3RoaXMudHhDb3VudDtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnN0b3JlV3JpdGVyLndyaXRlVG9TdG9yZSh7XG4gICAgICAgICAgICAgICAgc3RvcmU6IHRoaXMuZGF0YSxcbiAgICAgICAgICAgICAgICBxdWVyeTogb3B0aW9ucy5xdWVyeSxcbiAgICAgICAgICAgICAgICByZXN1bHQ6IG9wdGlvbnMucmVzdWx0LFxuICAgICAgICAgICAgICAgIGRhdGFJZDogb3B0aW9ucy5kYXRhSWQsXG4gICAgICAgICAgICAgICAgdmFyaWFibGVzOiBvcHRpb25zLnZhcmlhYmxlcyxcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGZpbmFsbHkge1xuICAgICAgICAgICAgaWYgKCEtLXRoaXMudHhDb3VudCAmJiBvcHRpb25zLmJyb2FkY2FzdCAhPT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmJyb2FkY2FzdFdhdGNoZXMoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgSW5NZW1vcnlDYWNoZS5wcm90b3R5cGUubW9kaWZ5ID0gZnVuY3Rpb24gKG9wdGlvbnMpIHtcbiAgICAgICAgaWYgKGhhc093bi5jYWxsKG9wdGlvbnMsIFwiaWRcIikgJiYgIW9wdGlvbnMuaWQpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgc3RvcmUgPSBvcHRpb25zLm9wdGltaXN0aWNcbiAgICAgICAgICA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AgICAgdmFyIGtleUZuID0gcG9saWN5ICYmIHBvbGljeS5rZXlGbiB8fCB0aGlzLmNvbmZpZy5kYXRhSWRGcm9tT2JqZWN0O1xuICAgICAgICB3aGlsZSAoa2V5Rm4pIHtcbiAgICAgICAgICAgIHZhciBzcGVjaWZpZXJPcklkID0ga2V5Rm4ob2JqZWN0LCBjb250ZXh0KTtcbiAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHNwZWNpZmllck9ySWQpKSB7XG4gICAgICAgICAgICAgICAga2V5Rm4gPSBrZXlGaWVsZHNGbkZyb21TcGVjaWZpZXIoc3BlY2lmaWVyT3JJZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZCA9IHNwZWNpZmllck9ySWQ7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWQgPSBpZCAmJiBTdHJpbmcoaWQpO1xuICAgICAgICByZXR1cm4gY29udGV4dC5rZXlPYmplY3QgPyBbaWQsIGNvbnRleHQua2V5T2JqZWN0XSA6IFtpZF07XG4gICAgfTtcbiAgICBQb2xpY2llcy5wcm90b3R5cGUuYWRkVHlwZVBvbGljaWVzID0gZnVuY3Rpb24gKHR5cGVQb2xpY2llcykge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBPYmplY3Qua2V5cyh0eXBlUG9saWNpZXMpLmZvckVhY2goZnVuY3Rpb24gKHR5cGVuYW1lKSB7XG4gICAgICAgICAgICB2YXIgZXhpc3RpbmcgPSBfdGhpcy5nZXRUeXBlUG9saWN5KHR5cGVuYW1lLCB0cnVlKTtcbiAgICAgICAgICAgIHZhciBpbmNvbWluZyA9IHR5cGVQb2xpY2llc1t0eXBlbmFtZV07XG4gICAgICAgICAgICB2YXIga2V5RmllbGRzID0gaW5jb21pbmcua2V5RmllbGRzLCBmaWVsZHMgPSBpbmNvbWluZy5maWVsZHM7XG4gICAgICAgICAgICBpZiAoaW5jb21pbmcucXVlcnlUeXBlKVxuICAgICAgICAgICAgICAgIF90aGlzLnNldFJvb3RUeXBlbmFtZShcIlF1ZXJ5XCIsIHR5cGVuYW1lKTtcbiAgICAgICAgICAgIGlmIChpbmNvbWluZy5tdXRhdGlvblR5cGUpXG4gICAgICAgICAgICAgICAgX3RoaXMuc2V0Um9vdFR5cGVuYW1lKFwiTXV0YXRpb25cIiwgdHlwZW5hbWUpO1xuICAgICAgICAgICAgaWYgKGluY29taW5nLnN1YnNjcmlwdGlvblR5cGUpXG4gICAgICAgICAgICAgICAgX3RoaXMuc2V0Um9vdFR5cGVuYW1lKFwiU3Vic2NyaXB0aW9uXCIsIHR5cGVuYW1lKTtcbiAgICAgICAgICAgIGV4aXN0aW5nLmtleUZuID1cbiAgICAgICAgICAgICAgICBrZXlGaWVsZHMgPT09IGZhbHNlID8gbnVsbEtleUZpZWxkc0ZuIDpcbiAgICAgICAgICAgICAgICAgICAgQXJyYXkuaXNBcnJheShrZXlGaWVsZHMpID8ga2V5RmllbGRzRm5Gcm9tU3BlY2lmaWVyKGtleUZpZWxkcykgOlxuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZW9mIGtleUZpZWxkcyA9PT0gXCJmdW5jdGlvblwiID8ga2V5RmllbGRzIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleGlzdGluZy5rZXlGbjtcbiAgICAgICAgICAgIGlmIChmaWVsZHMpIHtcbiAgICAgICAgICAgICAgICBPYmplY3Qua2V5cyhmaWVsZHMpLmZvckVhY2goZnVuY3Rpb24gKGZpZWxkTmFtZSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZXhpc3RpbmcgPSBfdGhpcy5nZXRGaWVsZFBvbGljeSh0eXBlbmFtZSwgZmllbGROYW1lLCB0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGluY29taW5nID0gZmllbGRzW2ZpZWxkTmFtZV07XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaW5jb21pbmcgPT09IFwiZnVuY3Rpb25cIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhpc3RpbmcucmVhZCA9IGluY29taW5nO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGtleUFyZ3MgPSBpbmNvbWluZy5rZXlBcmdzLCByZWFkID0gaW5jb21pbmcucmVhZCwgbWVyZ2UgPSBpbmNvbWluZy5tZXJnZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aW5nLmtleUZuID1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXlBcmdzID09PSBmYWxzZSA/IHNpbXBsZUtleUFyZ3NGbiA6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFycmF5LmlzQXJyYXkoa2V5QXJncykgPyBrZXlBcmdzRm5Gcm9tU3BlY2lmaWVyKGtleUFyZ3MpIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVvZiBrZXlBcmdzID09PSBcImZ1bmN0aW9uXCIgPyBrZXlBcmdzIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleGlzdGluZy5rZXlGbjtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVhZCA9PT0gXCJmdW5jdGlvblwiKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aW5nLnJlYWQgPSByZWFkO1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhpc3RpbmcubWVyZ2UgPVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVvZiBtZXJnZSA9PT0gXCJmdW5jdGlvblwiID8gbWVyZ2UgOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXJnZSA9PT0gdHJ1ZSA/IG1lcmdlVHJ1ZUZuIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lcmdlID09PSBmYWxzZSA/IG1lcmdlRmFsc2VGbiA6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhpc3RpbmcubWVyZ2U7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGV4aXN0aW5nLnJlYWQgJiYgZXhpc3RpbmcubWVyZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aW5nLmtleUZuID0gZXhpc3Rpbmcua2V5Rm4gfHwgc2ltcGxlS2V5QXJnc0ZuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgUG9saWNpZXMucHJvdG90eXBlLnNldFJvb3RUeXBlbmFtZSA9IGZ1bmN0aW9uICh3aGljaCwgdHlwZW5hbWUpIHtcbiAgICAgICAgaWYgKHR5cGVuYW1lID09PSB2b2lkIDApIHsgdHlwZW5hbWUgPSB3aGljaDsgfVxuICAgICAgICB2YXIgcm9vdElkID0gXCJST09UX1wiICsgd2hpY2gudG9VcHBlckNhc2UoKTtcbiAgICAgICAgdmFyIG9sZCA9IHRoaXMucm9vdFR5cGVuYW1lc0J5SWRbcm9vdElkXTtcbiAgICAgICAgaWYgKHR5cGVuYW1lICE9PSBvbGQpIHtcbiAgICAgICAgICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiA/IGludmFyaWFudCghb2xkIHx8IG9sZCA9PT0gd2hpY2gsIDEpIDogaW52YXJpYW50KCFvbGQgfHwgb2xkID09PSB3aGljaCwgXCJDYW5ub3QgY2hhbmdlIHJvb3QgXCIgKyB3aGljaCArIFwiIF9fdHlwZW5hbWUgbW9yZSB0aGFuIG9uY2VcIik7XG4gICAgICAgICAgICBpZiAob2xkKVxuICAgICAgICAgICAgICAgIGR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lXzEgPSBmdW5jdGlvbiAoc3VidHlwZSkge1xuICAgICAgICAgICAgICAgIHZhciBzdXBlcnR5cGVTZXQgPSBfdGhpcy5nZXRTdXBlcnR5cGVTZXQoc3VidHlwZSwgZmFsc2UpO1xuICAgICAgICAgICAgICAgIGlmIChzdXBlcnR5cGVTZXQgJiZcbiAgICAgICAgICAgICAgICAgICAgc3VwZXJ0eXBlU2V0LnNpemUgJiZcbiAgICAgICAgICAgICAgICAgICAgd29ya1F1ZXVlXzEuaW5kZXhPZihzdXBlcnR5cGVTZXQpIDwgMCkge1xuICAgICAgICAgICAgICAgICAgICB3b3JrUXVldWVfMS5wdXNoKHN1cGVydHlwZVNldCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHZhciBuZWVkVG9DaGVja0Z1enp5U3VidHlwZXMgPSAhIShyZXN1bHQgJiYgdGhpcy5mdXp6eVN1YnR5cGVzLnNpemUpO1xuICAgICAgICAgICAgdmFyIGNoZWNraW5nRnV6enlTdWJ0eXBlcyA9IGZhbHNlO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCB3b3JrUXVldWVfMS5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgICAgIHZhciBzdXBlcnR5cGVTZXQgPSB3b3JrUXVldWVfMVtpXTtcbiAgICAgICAgICAgICAgICBpZiAoc3VwZXJ0eXBlU2V0LmhhcyhzdXBlcnR5cGUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghdHlwZW5hbWVTdXBlcnR5cGVTZXQuaGFzKHN1cGVydHlwZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGVja2luZ0Z1enp5U3VidHlwZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgfHwgaW52YXJpYW50Lndhcm4oXCJJbmZlcnJpbmcgc3VidHlwZSBcIiArIHR5cGVuYW1lICsgXCIgb2Ygc3VwZXJ0eXBlIFwiICsgc3VwZXJ0eXBlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGVuYW1lU3VwZXJ0eXBlU2V0LmFkZChzdXBlcnR5cGUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzdXBlcnR5cGVTZXQuZm9yRWFjaChtYXliZUVucXVldWVfMSk7XG4gICAgICAgICAgICAgICAgaWYgKG5lZWRUb0NoZWNrRnV6enlTdWJ0eXBlcyAmJlxuICAgICAgICAgICAgICAgICAgICBpID09PSB3b3JrUXVldWVfMS5sZW5ndGggLSAxICYmXG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvblNldE1hdGNoZXNSZXN1bHQoZnJhZ21lbnQuc2VsZWN0aW9uU2V0LCByZXN1bHQsIHZhcmlhYmxlcykpIHtcbiAgICAgICAgICAgICAgICAgICAgbmVlZFRvQ2hlY2tGdXp6eVN1YnR5cGVzID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIGNoZWNraW5nRnV6enlTdWJ0eXBlcyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZnV6enlTdWJ0eXBlcy5mb3JFYWNoKGZ1bmN0aW9uIChyZWdFeHAsIGZ1enp5U3RyaW5nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWF0Y2ggPSB0eXBlbmFtZS5tYXRjaChyZWdFeHApO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1hdGNoICYmIG1hdGNoWzBdID09PSB0eXBlbmFtZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heWJlRW5xdWV1ZV8xKGZ1enp5U3RyaW5nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9O1xuICAgIFBvbGljaWVzLnByb3RvdHlwZS5nZXRTdG9yZUZpZWxkTmFtZSA9IGZ1bmN0aW9uIChmaWVsZFNwZWMpIHtcbiAgICAgICAgdmFyIHR5cGVuYW1lID0gZmllbGRTcGVjLnR5cGVuYW1lLCBmaWVsZE5hbWUgPSBmaWVsZFNwZWMuZmllbGROYW1lO1xuICAgICAgICB2YXIgcG9saWN5ID0gdGhpcy5nZXRGaWVsZFBvbGljeSh0eXBlbmFtZSwgZmllbGROYW1lLCBmYWxzZSk7XG4gICAgICAgIHZhciBzdG9yZUZpZWxkTmFtZTtcbiAgICAgICAgdmFyIGtleUZuID0gcG9saWN5ICYmIHBvbGljeS5rZXlGbjtcbiAgICAgICAgaWYgKGtleUZuICYmIHR5cGVuYW1lKSB7XG4gICAgICAgICAgICB2YXIgY29udGV4dCA9IHtcbiAgICAgICAgICAgICAgICB0eXBlbmFtZTogdHlwZW5hbWUsXG4gICAgICAgICAgICAgICAgZmllbGROYW1lOiBmaWVsZE5hbWUsXG4gICAgICAgICAgICAgICAgZmllbGQ6IGZpZWxkU3BlYy5maWVsZCB8fCBudWxsLFxuICAgICAgICAgICAgICAgIHZhcmlhYmxlczogZmllbGRTcGVjLnZhcmlhYmxlcyxcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICB2YXIgYXJncyA9IGFyZ3NGcm9tRmllbGRTcGVjaWZpZXIoZmllbGRTcGVjKTtcbiAgICAgICAgICAgIHdoaWxlIChrZXlGbikge1xuICAgICAgICAgICAgICAgIHZhciBzcGVjaWZpZXJPclN0cmluZyA9IGtleUZuKGFyZ3MsIGNvbnRleHQpO1xuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHNwZWNpZmllck9yU3RyaW5nKSkge1xuICAgICAgICAgICAgICAgICAgICBrZXlGbiA9IGtleUFyZ3NGbkZyb21TcGVjaWZpZXIoc3BlY2lmaWVyT3JTdHJpbmcpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgc3RvcmVGaWVsZE5hbWUgPSBzcGVjaWZpZXJPclN0cmluZyB8fCBmaWVsZE5hbWU7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoc3RvcmVGaWVsZE5hbWUgPT09IHZvaWQgMCkge1xuICAgICAgICAgICAgc3RvcmVGaWVsZE5hbWUgPSBmaWVsZFNwZWMuZmllbGRcbiAgICAgICAgICAgICAgICA/IHN0b3JlS2V5TmFtZUZyb21GaWVsZChmaWVsZFNwZWMuZmllbGQsIGZpZWxkU3BlYy52YXJpYWJsZXMpXG4gICAgICAgICAgICAgICAgOiBnZXRTdG9yZUtleU5hbWUoZmllbGROYW1lLCBhcmdzRnJvbUZpZWxkU3BlY2lmaWVyKGZpZWxkU3BlYykpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmaWVsZE5hbWUgPT09IGZpZWxkTmFtZUZyb21TdG9yZU5hbWUoc3RvcmVGaWVsZE5hbWUpXG4gICAgICAgICAgICA/IHN0b3JlRmllbGROYW1lXG4gICAgICAgICAgICA6IGZpZWxkTmFtZSArIFwiOlwiICsgc3RvcmVGaWVsZE5hbWU7XG4gICAgfTtcbiAgICBQb2xpY2llcy5wcm90b3R5cGUucmVhZEZpZWxkID0gZnVuY3Rpb24gKG9wdGlvbnMsIGNvbnRleHQpIHtcbiAgICAgICAgdmFyIG9iamVjdE9yUmVmZXJlbmNlID0gb3B0aW9ucy5mcm9tO1xuICAgICAgICBpZiAoIW9iamVjdE9yUmVmZXJlbmNlKVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB2YXIgbmFtZU9yRmllbGQ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GlvbnMpO1xuICAgICAgICAgICAgaWYgKHZvaWQgMCA9PT0gb3B0aW9ucy5mcm9tKSB7XG4gICAgICAgICAgICAgICAgb3B0aW9ucy5mcm9tID0gb2JqZWN0T3JSZWZlcmVuY2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodm9pZCAwID09PSBvcHRpb25zLnZhcmlhYmxlcykge1xuICAgICAgICAgICAgICAgIG9wdGlvbnMudmFyaWFibGVzID0gdmFyaWFibGVzO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHBvbGljaWVzLnJlYWRGaWVsZChvcHRpb25zLCBjb250ZXh0KTtcbiAgICAgICAgfSxcbiAgICAgICAgbWVyZ2VPYmplY3RzOiBmdW5jdGlvbiAoZXhpc3RpbmcsIGluY29taW5nKSB7XG4gICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShleGlzdGluZykgfHwgQXJyYXkuaXNBcnJheShpbmNvbWluZykpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgPyBuZXcgSW52YXJpYW50RXJyb3IoMikgOiBuZXcgSW52YXJpYW50RXJyb3IoXCJDYW5ub3QgYXV0b21hdGljYWxseSBtZXJnZSBhcnJheXNcIik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoZXhpc3RpbmcgJiYgdHlwZW9mIGV4aXN0aW5nID09PSBcIm9iamVjdFwiICYmXG4gICAgICAgICAgICAgICAgaW5jb21pbmcgJiYgdHlwZW9mIGluY29taW5nID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgdmFyIGVUeXBlID0gZ2V0RmllbGRWYWx1ZShleGlzdGluZywgXCJfX3R5cGVuYW1lXCIpO1xuICAgICAgICAgICAgICAgIHZhciBpVHlwZSA9IGdldEZpZWxkVmFsdWUoaW5jb21pbmcsIFwiX190eXBlbmFtZVwiKTtcbiAgICAgICAg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gKG9iamVjdCwgY29udGV4dCkge1xuICAgICAgICB2YXIgYWxpYXNNYXA7XG4gICAgICAgIGlmIChjb250ZXh0LnNlbGVjdGlvblNldCAmJiBjb250ZXh0LmZyYWdtZW50TWFwKSB7XG4gICAgICAgICAgICB2YXIgaW5mbyA9IHRyaWUubG9va3VwQXJyYXkoW1xuICAgICAgICAgICAgICAgIGNvbnRleHQuc2VsZWN0aW9uU2V0LFxuICAgICAgICAgICAgICAgIGNvbnRleHQuZnJhZ21lbnRNYXAsXG4gICAgICAgICAgICBdKTtcbiAgICAgICAgICAgIGFsaWFzTWFwID0gaW5mby5hbGlhc01hcCB8fCAoaW5mby5hbGlhc01hcCA9IG1ha2VBbGlhc01hcChjb250ZXh0LnNlbGVjdGlvblNldCwgY29udGV4dC5mcmFnbWVudE1hcCkpO1xuICAgICAgICB9XG4gICAgICAgIHZhciBrZXlPYmplY3QgPSBjb250ZXh0LmtleU9iamVjdCA9XG4gICAgICAgICAgICBjb21wdXRlS2V5T2JqZWN0KG9iamVjdCwgc3BlY2lmaWVyLCBhbGlhc01hcCk7XG4gICAgICAgIHJldHVybiBjb250ZXh0LnR5cGVuYW1lICsgXCI6XCIgKyBKU09OLnN0cmluZ2lmeShrZXlPYmplY3QpO1xuICAgIH07XG59XG5mdW5jdGlvbiBtYWtlQWxpYXNNYXAoc2VsZWN0aW9uU2V0LCBmcmFnbWVudE1hcCkge1xuICAgIHZhciBtYXAgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgIHZhciB3b3JrUXVldWUgPSBuZXcgU2V0KFtzZWxlY3Rpb25TZXRdKTtcbiAgICB3b3JrUXVldWUuZm9yRWFjaChmdW5jdGlvbiAoc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgIHNlbGVjdGlvblNldC5zZWxlY3Rpb25zLmZvckVhY2goZnVuY3Rpb24gKHNlbGVjdGlvbikge1xuICAgICAgICAgICAgaWYgKGlzRmllbGQoc2VsZWN0aW9uKSkge1xuICAgICAgICAgICAgICAgIGlmIChzZWxlY3Rpb24uYWxpYXMpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3BvbnNlS2V5ID0gc2VsZWN0aW9uLmFsaWFzLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmVLZXkgPSBzZWxlY3Rpb24ubmFtZS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlS2V5ICE9PSByZXNwb25zZUtleSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGFsaWFzZXMgPSBtYXAuYWxpYXNlcyB8fCAobWFwLmFsaWFzZXMgPSBPYmplY3QuY3JlYXRlKG51bGwpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFsaWFzZXNbc3RvcmVLZXldID0gcmVzcG9uc2VLZXk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHNlbGVjdGlvbi5zZWxlY3Rpb25TZXQpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHN1YnNldHMgPSBtYXAuc3Vic2V0cyB8fCAobWFwLnN1YnNldHMgPSBPYmplY3QuY3JlYXRlKG51bGwpKTtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2V0c1tzZWxlY3Rpb24ubmFtZS52YWx1ZV0gPVxuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUFsaWFzTWFwKHNlbGVjdGlvbi5zZWxlY3Rpb25TZXQsIGZyYWdtZW50TWFwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB2YXIgZnJhZ21lbnQgPSBnZXRGcmFnbWVudEZyb21TZWxlY3Rpb24oc2VsZWN0aW9uLCBmcmFnbWVudE1hcCk7XG4gICAgICAgICAgICAgICAgaWYgKGZyYWdtZW50KSB7XG4gICAgICAgICAgICAgICAgICAgIHdvcmtRdWV1ZS5hZG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VTZWxlY3Rpb25TZXQgPSB3cmFwKGZ1bmN0aW9uIChvcHRpb25zKSB7IHJldHVybiBfdGhpcy5leGVjU2VsZWN0aW9uU2V0SW1wbChvcHRpb25zKTsgfSwge1xuICAgICAgICAgICAga2V5QXJnczogZnVuY3Rpb24gKG9wdGlvbnMpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgICAgICAgICBvcHRpb25zLnNlbGVjdGlvblNldCxcbiAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy5vYmplY3RPclJlZmVyZW5jZSxcbiAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy5jb250ZXh0LFxuICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgbWFrZUNhY2hlS2V5OiBmdW5jdGlvbiAoc2VsZWN0aW9uU2V0LCBwYXJlbnQsIGNvbnRleHQpIHtcbiAgICAgICAgICAgICAgICBpZiAoc3VwcG9ydHNSZXN1bHRDYWNoaW5nKGNvbnRleHQuc3RvcmUpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBjb250ZXh0LnN0b3JlLm1ha2VDYWNoZUtleShzZWxlY3Rpb25TZXQsIGlzUmVmZXJlbmNlKHBhcmVudCkgPyBwYXJlbnQuX19yZWYgOiBwYXJlbnQsIGNvbnRleHQudmFyU3RyaW5nKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmtub3duUmVzdWx0cyA9IG5ldyBXZWFrTWFwKCk7XG4gICAgICAgIHRoaXMuZXhlY3V0ZVN1YlNlbGVjdGVkQXJyYXkgPSB3cmFwKGZ1bmN0aW9uIChvcHRpb25zKSB7XG4gICAgICAgICAgICByZXR1cm4gX3RoaXMuZXhlY1N1YlNlbGVjdGVkQXJyYXlJbXBsKG9wdGlvbnMpO1xuICAgICAgICB9LCB7XG4gICAgICAgICAgICBtYWtlQ2FjaGVLZXk6IGZ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W9uU2V0KHtcbiAgICAgICAgICAgIHNlbGVjdGlvblNldDogZ2V0TWFpbkRlZmluaXRpb24ocXVlcnkpLnNlbGVjdGlvblNldCxcbiAgICAgICAgICAgIG9iamVjdE9yUmVmZXJlbmNlOiBtYWtlUmVmZXJlbmNlKHJvb3RJZCksXG4gICAgICAgICAgICBjb250ZXh0OiB7XG4gICAgICAgICAgICAgICAgc3RvcmU6IHN0b3JlLFxuICAgICAgICAgICAgICAgIHF1ZXJ5OiBxdWVyeSxcbiAgICAgICAgICAgICAgICBwb2xpY2llczogcG9saWNpZXMsXG4gICAgICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgdmFyU3RyaW5nOiBKU09OLnN0cmluZ2lmeSh2YXJpYWJsZXMpLFxuICAgICAgICAgICAgICAgIGZyYWdtZW50TWFwOiBjcmVhdGVGcmFnbWVudE1hcChnZXRGcmFnbWVudERlZmluaXRpb25zKHF1ZXJ5KSksXG4gICAgICAgICAgICAgICAgcGF0aDogW10sXG4gICAgICAgICAgICAgICAgY2xpZW50T25seTogZmFsc2UsXG4gICAgICAgICAgICB9LFxuICAgICAgICB9KTtcbiAgICAgICAgdmFyIGhhc01pc3NpbmdGaWVsZHMgPSBleGVjUmVzdWx0Lm1pc3NpbmcgJiYgZXhlY1Jlc3VsdC5taXNzaW5nLmxlbmd0aCA+IDA7XG4gICAgICAgIGlmIChoYXNNaXNzaW5nRmllbGRzICYmICFyZXR1cm5QYXJ0aWFsRGF0YSkge1xuICAgICAgICAgICAgdGhyb3cgZXhlY1Jlc3VsdC5taXNzaW5nWzBdO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICByZXN1bHQ6IGV4ZWNSZXN1bHQucmVzdWx0LFxuICAgICAgICAgICAgbWlzc2luZzogZXhlY1Jlc3VsdC5taXNzaW5nLFxuICAgICAgICAgICAgY29tcGxldGU6ICFoYXNNaXNzaW5nRmllbGRzLFxuICAgIC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W5hbFJlc3VsdC5taXNzaW5nID0gW10pO1xuICAgICAgICB9XG4gICAgICAgIGZ1bmN0aW9uIGhhbmRsZU1pc3NpbmcocmVzdWx0KSB7XG4gICAgICAgICAgICB2YXIgX2E7XG4gICAgICAgICAgICBpZiAocmVzdWx0Lm1pc3NpbmcpXG4gICAgICAgICAgICAgICAgKF9hID0gZ2V0TWlzc2luZygpKS5wdXNoLmFwcGx5KF9hLCByZXN1bHQubWlzc2luZyk7XG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0LnJlc3VsdDtcbiAgICAgICAgfVxuICAgICAgICB2YXIgd29ya1NldCA9IG5ldyBTZXQoc2VsZWN0aW9uU2V0LnNlbGVjdGlvbnMpO1xuICAgICAgICB3b3JrU2V0LmZvckVhY2goZnVuY3Rpb24gKHNlbGVjdGlvbikge1xuICAgICAgICAgICAgdmFyIF9hO1xuICAgICAgICAgICAgaWYgKCFzaG91bGRJbmNsdWRlKHNlbGVjdGlvbiwgdmFyaWFibGVzKSlcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICBpZiAoaXNGaWVsZChzZWxlY3Rpb24pKSB7XG4gICAgICAgICAgICAgICAgdmFyIGZpZWxkVmFsdWUgPSBwb2xpY2llcy5yZWFkRmllbGQoe1xuICAgICAgICAgICAgICAgICAgICBmaWVsZE5hbWU6IHNlbGVjdGlvbi5uYW1lLnZhbHVlLFxuICAgICAgICAgICAgICAgICAgICBmaWVsZDogc2VsZWN0aW9uLFxuICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IGNvbnRleHQudmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICBmcm9tOiBvYmplY3RPclJlZmVyZW5jZSxcbiAgICAgICAgICAgICAgICB9LCBjb250ZXh0KTtcbiAgICAgICAgICAgICAgICB2YXIgcmVzdWx0TmFtZSA9IHJlc3VsdEtleU5hbWVGcm9tRmllbGQoc2VsZWN0aW9uKTtcbiAgICAgICAgICAgICAgICBjb250ZXh0LnBhdGgucHVzaChyZXN1bHROYW1lKTtcbiAgICAgICAgICAgICAgICB2YXIgd2FzQ2xpZW50T25seSA9IGNvbnRleHQuY2xpZW50T25seTtcbiAgICAgICAgICAgICAgICBjb250ZXh0LmNsaWVudE9ubHkgPSB3YXNDbGllbnRPbmx5IHx8ICEhKHNlbGVjdGlvbi5kaXJlY3RpdmVzICYmXG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvbi5kaXJlY3RpdmVzLnNvbWUoZnVuY3Rpb24gKGQpIHsgcmV0dXJuIGQubmFtZS52YWx1ZSA9PT0gXCJjbGllbnRcIjsgfSkpO1xuICAgICAgICAgICAgICAgIGlmIChmaWVsZFZhbHVlID09PSB2b2lkIDApIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFhZGRUeXBlbmFtZVRvRG9jdW1lbnQuYWRkZWQoc2VsZWN0aW9uKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZ2V0TWlzc2luZygpLnB1c2gobWlzc2luZ0Zyb21JbnZhcmlhbnQocHJvY2Vzcy5lbnYuTk9ERV9FTlYgPT09IFwicHJvZHVjdGlvblwiID8gbmV3IEludmFyaWFudEVycm9yKDUpIDogbmV3IEludmFyaWFudEVycm9yKFwiQ2FuJ3QgZmluZCBmaWVsZCAnXCIgKyBzZWxlY3Rpb24ubmFtZS52YWx1ZSArIFwiJyBvbiBcIiArIChpc1JlZmVyZW5jZShvYmplY3RPclJlZmVyZW5jZSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IG9iamVjdE9yUmVmZXJlbmNlLl9fcmVmICsgXCIgb2JqZWN0XCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IFwib2JqZWN0IFwiICsgSlNPTi5zdHJpbmdpZnkob2JqZWN0T3JSZWZlcmVuY2UsIG51bGwsIDIpKSksIGNvbnRleHQpKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIGlmIChBcnJheS5pc0FycmF5KGZpZWxkVmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpZWxkVmFsdWUgPSBoYW5kbGVNaXNzaW5nKF90aGlzLmV4ZWN1dGVTdWJTZWxlY3RlZEFycmF5KHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkOiBzZWxlY3Rpb24sXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnJheTogZmllbGRWYWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoIXNlbGVjdGlvbi5zZWxlY3Rpb25TZXQpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHByb2Nlc3MuZW52Lk5PREVfRU5WICE9PSAncHJvZHVjdGlvbicpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFzc2VydFNlbGVjdGlvblNldEZvcklkVmFsdWUoY29udGV4dC5zdG9yZSwgc2VsZWN0aW9uLCBmaWVsZFZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1heWJlRGVlcEZyZWV6ZShmaWVsZFZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIGlmIChmaWVsZFZhbHVlICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgZmllbGRWYWx1ZSA9IGhhbmRsZU1pc3NpbmcoX3RoaXMuZXhlY3V0ZVNlbGVjdGlvblNldCh7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3Rpb25TZXQ6IHNlbGVjdGlvbi5zZWxlY3Rpb25TZXQsXG4gICAgICAgICAgICAgICAgICAgICAgICBvYmplY3RPclJlZmVyZW5jZTogZmllbGRWYWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGZpZWxkVmFsdWUgIT09IHZvaWQgMCkge1xuICAgICAgICAgICAgICAgICAgICBvYmplY3RzVG9NZXJnZS5wdXNoKChfYSA9IHt9LCBfYVtyZXN1bHROYW1lXSA9IGZpZWxkVmFsdWUsIF9hKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnRleHQuY2xpZW50T25seSA9IHdhc0NsaWVudE9ubHk7XG4gICAgICAgICAgICAgICAgaW52YXJpYW50KGNvbnRleHQucGF0aC5wb3AoKSA9PT0gcmVzdWx0TmFtZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB2YXIgZnJhZ21lbnQgPSBnZXRGcmFnbWVudEZyb21TZWxlY3Rpb24oc2VsZWN0aW9uLCBjb250ZXh0LmZyYWdtZW50TWFwKTtcbiAgICAgICAgICAgICAgICBpZiAoZnJhZ21lbnQgJiYgcG9saWNpZXMuZnJhZ21lbnRNYXRjaGVzKGZyYWdtZW50LCB0eXBlbmFtZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgZnJhZ21lbnQuc2VsZWN0aW9uU2V0LnNlbGVjdGlvbnMuZm9yRWFjaCh3b3JrU2V0LmFkZCwgd29ya1NldCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgZmluYWxSZXN1bHQucmVzdWx0ID0gbWVyZ2VEZWVwQXJyYXkob2JqZWN0c1RvTWVyZ2UpO1xuICAgICAgICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09ICdwcm9kdWN0aW9uJykge1xuICAgICAgICAgICAgT2JqZWN0LmZyZWV6ZShmaW5hbFJlc3VsdC5yZXN1bHQpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMua25vd25SZXN1bHRzLnNldChmaW5hbFJlc3VsdC5yZXN1bHQsIHNlbGVjdGlvblNldCk7XG4gICAgICAgIHJldHVybiBmaW5hbFJlc3VsdDtcbiAgICB9O1xuICAgIFN0b3JlUmVhZGVyLnByb3RvdHlwZS5leGVjU3ViU2VsZWN0ZWRBcnJheUltcGwgPSBmdW5jdGlvbiAoX2EpIHtcbiAgICAgICAgdmFyIF90aGlzID0gdGhpcztcbiAgICAgICAgdmFyIGZpZWxkID0gX2EuZmllbGQsIGFycmF5ID0gX2EuYXJyYXksIGNvbnRleHQgPSBfYS5jb250ZXh0O1xuICAgICAgICB2YXIgbWlzc2luZztcbiAgICAgICAgZnVuY3Rpb24gaGFuZGxlTWlzc2luZyhjaGlsZFJlc3VsdCwgaSkge1xuICAgICAgICAgICAgaWYgKGNoaWxkUmVzdWx0Lm1pc3NpbmcpIHtcbiAgICAgICAgICAgICAgICBtaXNzaW5nID0gbWlzc2luZyB8fCBbXTtcbiAgICAgICAgICAgICAgICBtaXNzaW5nLnB1c2guYXBwbHkobWlzc2luZywgY2hpbGRSZXN1bHQubWlzc2luZyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpbnZhcmlhbnQoY29udGV4dC5wYXRoLnBvcCgpID09PSBpKTtcbiAgICAgICAgICAgIHJldHVybiBjaGlsZFJlc3VsdC5yZXN1bHQ7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGZpZWxkLnNlbGVjdGlvblNldCkge1xuICAgICAgICAgICAgYXJyYXkgPSBhcnJheS5maWx0ZXIoY29udGV4dC5zdG9yZS5jYW5SZWFkKTtcbiAgICAgICAgfVxuICAgICAgICBhcnJheSA9IGFycmF5Lm1hcChmdW5jdGlvbiAoaXRlbSwgaSkge1xuICAgICAgICAgICAgaWYgKGl0ZW0gPT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbnRleHQucGF0aC5wdXNoKGkpO1xuICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaXRlbSkpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaGFuZGxlTWlzc2luZyhfdGhpcy5leGVjdXRlU3ViU2VsZWN0ZWRBcnJheSh7XG4gICAgICAgICAgICAgICAgICAgIGZpZWxkOiBmaWVsZCxcbiAgICAgICAgICAgICAgICAgICAgYXJyYXk6IGl0ZW0sXG4gICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgICAgICAgICAgfSksIGkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGZpZWxkLnNlbGVjdGlvblNldCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBoYW5kbGVNaXNzaW5nKF90aGlzLmV4ZWN1dGVTZWxlY3Rpb25TZXQoe1xuICAgICAgICAgICAgICAgICAgICBzZWxlY3Rpb25TZXQ6IGZpZWxkLnNlbGVjdGlvblNldCxcbiAgICAgICAgICAgICAgICAgICAgb2JqZWN0T3JSZWZlcmVuY2U6IGl0ZW0sXG4gICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgICAgICAgICAgfSksIGkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHByb2Nlc3MuZW52Lk5PREVfRU5WICE9PSAncHJvZHVjdGlvbicpIHtcbiAgICAgICAgICAgICAgICBhc3NlcnRTZWxlY3Rpb25TZXRGb3JJZFZhbHVlKGNvbnRleHQuc3RvcmUsIGZpZWxkLCBpdGVtKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGludmFyaWFudChjb250ZXh0LnBhdGgucG9wKCkgPT09IGkpO1xuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XG4gICAgICAgIH0pO1xuICAgICAgICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09ICdwcm9kdWN0aW9uJykge1xuICAgICAgICAgICAgT2JqZWN0LmZyZWV6ZShhc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GFJZCkge1xuICAgICAgICAgICAgdmFyIHNldHMgPSBjb250ZXh0LndyaXR0ZW5bZGF0YUlkXSB8fCAoY29udGV4dC53cml0dGVuW2RhdGFJZF0gPSBbXSk7XG4gICAgICAgICAgICB2YXIgcmVmID0gbWFrZVJlZmVyZW5jZShkYXRhSWQpO1xuICAgICAgICAgICAgaWYgKHNldHMuaW5kZXhPZihzZWxlY3Rpb25TZXQpID49IDApXG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlZjtcbiAgICAgICAgICAgIHNldHMucHVzaChzZWxlY3Rpb25TZXQpO1xuICAgICAgICAgICAgaWYgKHRoaXMucmVhZGVyICYmIHRoaXMucmVhZGVyLmlzRnJlc2gocmVzdWx0LCByZWYsIHNlbGVjdGlvblNldCwgY29udGV4dCkpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gcmVmO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHZhciBtZXJnZWRGaWVsZHMgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICBpZiAoa2V5T2JqZWN0KSB7XG4gICAgICAgICAgICBtZXJnZWRGaWVsZHMgPSBjb250ZXh0Lm1lcmdlKG1lcmdlZEZpZWxkcywga2V5T2JqZWN0KTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgdHlwZW5hbWUgPSAoZGF0YUlkICYmIHBvbGljaWVzLnJvb3RUeXBlbmFtZXNCeUlkW2RhdGFJZF0pIHx8XG4gICAgICAgICAgICBnZXRUeXBlbmFtZUZyb21SZXN1bHQocmVzdWx0LCBzZWxlY3Rpb25TZXQsIGNvbnRleHQuZnJhZ21lbnRNYXApIHx8XG4gICAgICAgICAgICAoZGF0YUlkICYmIGNvbnRleHQuc3RvcmUuZ2V0KGRhdGFJZCwgXCJfX3R5cGVuYW1lXCIpKTtcbiAgICAgICAgaWYgKFwic3RyaW5nXCIgPT09IHR5cGVvZiB0eXBlbmFtZSkge1xuICAgICAgICAgICAgbWVyZ2VkRmllbGRzLl9fdHlwZW5hbWUgPSB0eXBlbmFtZTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgd29ya1NldCA9IG5ldyBTZXQoc2VsZWN0aW9uU2V0LnNlbGVjdGlvbnMpO1xuICAgICAgICB3b3JrU2V0LmZvckVhY2goZnVuY3Rpb24gKHNlbGVjdGlvbikge1xuICAgICAgICAgICAgdmFyIF9hO1xuICAgICAgICAgICAgaWYgKCFzaG91bGRJbmNsdWRlKHNlbGVjdGlvbiwgY29udGV4dC52YXJpYWJsZXMpKVxuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIGlmIChpc0ZpZWxkKHNlbGVjdGlvbikpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmVzdWx0RmllbGRLZXkgPSByZXN1bHRLZXlOYW1lRnJvbUZpZWxkKHNlbGVjdGlvbik7XG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gcmVzdWx0W3Jlc3VsdEZpZWxkS2V5XTtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmVGaWVsZE5hbWUgPSBwb2xpY2llcy5nZXRTdG9yZUZpZWxkTmFtZSh7XG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlbmFtZTogdHlwZW5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWVsZE5hbWU6IHNlbGVjdGlvbi5uYW1lLnZhbHVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgZmllbGQ6IHNlbGVjdGlvbixcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogY29udGV4dC52YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB2YXIgaW5jb21pbmdWYWx1ZSA9IF90aGlzLnByb2Nlc3NGaWVsZFZhbHVlKHZhbHVlLCBzZWxlY3Rpb24sIGNvbnRleHQsIG91dCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChwb2xpY2llcy5oYXNNZXJnZUZ1bmN0aW9uKHR5cGVuYW1lLCBzZWxlY3Rpb24ubmFtZS52YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGluY29taW5nVmFsdWUgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgX19maWVsZDogc2VsZWN0aW9uLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fdHlwZW5hbWU6IHR5cGVuYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fdmFsdWU6IGluY29taW5nVmFsdWUsXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgb3V0LnNob3VsZEFwcGx5TWVyZ2VzID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBtZXJnZWRGaWVsZHMgPSBjb250ZXh0Lm1lcmdlKG1lcmdlZEZpZWxkcywgKF9hID0ge30sXG4gICAgICAgICAgICAgICAgICAgICAgICBfYVtzdG9yZUZpZWxkTmFtZV0gPSBpbmNvbWluZ1ZhbHVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgX2EpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAocG9saWNpZXMudXNpbmdQb3NzaWJsZVR5cGVzICYmXG4gICAgICAgICAgICAgICAgICAgICFoYXNEaXJlY3RpdmVzKFtcImRlZmVyXCIsIFwiY2xpZW50XCJdLCBzZWxlY3Rpb24pKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiA/IG5ldyBJbnZhcmlhbnRFcnJvcig4KSA6IG5ldyBJbnZhcmlhbnRFcnJvcihcIk1pc3NpbmcgZmllbGQgJ1wiICsgcmVzdWx0RmllbGRLZXkgKyBcIicgaW4gXCIgK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AgbGluayA9IHVyaVxuICAgICAgICAgICAgICAgID8gbmV3IEh0dHBMaW5rKHsgdXJpOiB1cmksIGNyZWRlbnRpYWxzOiBjcmVkZW50aWFscywgaGVhZGVyczogaGVhZGVycyB9KVxuICAgICAgICAgICAgICAgIDogQXBvbGxvTGluay5lbXB0eSgpO1xuICAgICAgICB9XG4gICAgICAgIGlmICghY2FjaGUpIHtcbiAgICAgICAgICAgIHRocm93IHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiA/IG5ldyBJbnZhcmlhbnRFcnJvcig5KSA6IG5ldyBJbnZhcmlhbnRFcnJvcihcIlRvIGluaXRpYWxpemUgQXBvbGxvIENsaWVudCwgeW91IG11c3Qgc3BlY2lmeSBhICdjYWNoZScgcHJvcGVydHkgXCIgK1xuICAgICAgICAgICAgICAgIFwiaW4gdGhlIG9wdGlvbnMgb2JqZWN0LiBcXG5cIiArXG4gICAgICAgICAgICAgICAgXCJGb3IgbW9yZSBpbmZvcm1hdGlvbiwgcGxlYXNlIHZpc2l0OiBodHRwczovL2dvLmFwb2xsby5kZXYvYy9kb2NzXCIpO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMubGluayA9IGxpbms7XG4gICAgICAgIHRoaXMuY2FjaGUgPSBjYWNoZTtcbiAgICAgICAgdGhpcy5kaXNhYmxlTmV0d29ya0ZldGNoZXMgPSBzc3JNb2RlIHx8IHNzckZvcmNlRmV0Y2hEZWxheSA+IDA7XG4gICAgICAgIHRoaXMucXVlcnlEZWR1cGxpY2F0aW9uID0gcXVlcnlEZWR1cGxpY2F0aW9uO1xuICAgICAgICB0aGlzLmRlZmF1bHRPcHRpb25zID0gZGVmYXVsdE9wdGlvbnMgfHwge307XG4gICAgICAgIHRoaXMudHlwZURlZnMgPSB0eXBlRGVmcztcbiAgICAgICAgaWYgKHNzckZvcmNlRmV0Y2hEZWxheSkge1xuICAgICAgICAgICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7IHJldH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W9uJykge1xuICAgICAgICAgICAgaGFzU3VnZ2VzdGVkRGV2dG9vbHMgPSB0cnVlO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB3aW5kb3cgIT09ICd1bmRlZmluZWQnICYmXG4gICAgICAgICAgICAgICAgd2luZG93LmRvY3VtZW50ICYmXG4gICAgICAgICAgICAgICAgd2luZG93LnRvcCA9PT0gd2luZG93LnNlbGYpIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHdpbmRvdy5fX0FQT0xMT19ERVZUT09MU19HTE9CQUxfSE9PS19fID09PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICBpZiAod2luZG93Lm5hdmlnYXRvciAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgd2luZG93Lm5hdmlnYXRvci51c2VyQWdlbnQgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5uYXZpZ2F0b3IudXNlckFnZW50LmluZGV4T2YoJ0Nocm9tZScpID4gLTEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZGVidWcoJ0Rvd25sb2FkIHRoZSBBcG9sbG8gRGV2VG9vbHMgJyArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2ZvciBhIGJldHRlciBkZXZlbG9wbWVudCBleHBlcmllbmNlOiAnICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnaHR0cHM6Ly9jaHJvbWUuZ29vZ2xlLmNvbS93ZWJzdG9yZS9kZXRhaWwvYXBvbGxvLWNsaWVudC1kZXZlbG9wZXItdC9qZGtrbmtrYmViYmFwaWxnb2VjY2NpZ2xrZmJtYm5mbScpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMudmVyc2lvbiA9IHZlcnNpb247XG4gICAgICAgIHRoaXMubG9jYWxTdGF0ZSA9IG5ldyBMb2NhbFN0YXRlKHtcbiAgICAgICAgICAgIGNhY2hlOiBjYWNoZSxcbiAgICAgICAgICAgIGNsaWVudDogdGhpcyxcbiAgICAgICAgICAgIHJlc29sdmVyczogcmVzb2x2ZXJzLFxuICAgICAgICAgICAgZnJhZ21lbnRNYXRjaGVyOiBmcmFnbWVudE1hdGNoZXIsXG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLnF1ZXJ5TWFuYWdlciA9IG5ldyBRdWVyeU1hbmFnZXIoe1xuICAgICAgICAgICAgY2FjaGU6IHRoaXMuY2FjaGUsXG4gICAgICAgICAgICBsaW5rOiB0aGlzLmxpbmssXG4gICAgICAgICAgICBxdWVyeURlZHVwbGljYXRpb246IHF1ZXJ5RGVkdXBsaWNhdGlvbixcbiAgICAgICAgICAgIHNzck1vZGU6IHNzck1vZGUsXG4gICAgICAgICAgICBjbGllbnRBd2FyZW5lc3M6IHtcbiAgICAgICAgICAgICAgICBuYW1lOiBjbGllbnRBd2FyZW5lc3NOYW1lLFxuICAgICAgICAgICAgICAgIHZlcnNpb246IGNsaWVudEF3YXJlbmVzc1ZlcnNpb24sXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgbG9jYWxTdGF0ZTogdGhpcy5sb2NhbFN0YXRlLFxuICAgICAgICAgICAgYXNzdW1lSW1tdXRhYmxlUmVzdWx0czogYXNzdW1lSW1tdXRhYmxlUmVzdWx0cyxcbiAgICAgICAgICAgIG9uQnJvYWRjYXN0OiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzLmRldlRvb2xzSG9va0NiKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLmRldlRvb2xzSG9va0NiKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjoge30sXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJpZXM6IF90aGlzLnF1ZXJ5TWFuYWdlci5nZXRRdWVyeVN0b3JlKCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbXV0YXRpb25zOiBfdGhpcy5xdWVyeU1hbmFnZXIubXV0YXRpb25TdG9yZS5nZXRTdG9yZSgpLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFXaXRoT3B0aW1pc3RpY1Jlc3VsdHM6IF90aGlzLmNhY2hlLmV4dHJhY3QodHJ1ZSksXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBBcG9sbG9DbGllbnQucHJvdG90eXBlLnN0b3AgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHRoaXMucXVlcnlNYW5hZ2VyLnN0b3AoKTtcbiAgICB9O1xuICAgIEFwb2xsb0NsaWVudC5wcm90b3R5cGUud2F0Y2hRdWVyeSA9IGZ1bmN0aW9uIChvcHRpb25zKSB7XG4gICAgICAgIGlmICh0aGlzLmRlZmF1bHRPcHRpb25zLndhdGNoUXVlcnkpIHtcbiAgICAgICAgICAgIG9wdGlvbnMgPSBjb21wYWN0KHRoaXMuZGVmYXVsdE9wdGlvbnMud2F0Y2hRdWVyeSwgb3B0aW9ucyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuZGlzYWJsZU5ldHdvcmtGZXRjaGVzICYmXG4gICAgICAgICAgICAob3B0aW9ucy5mZXRjaFBvbGljeSA9PT0gJ25ldHdvcmstb25seScgfHxcbiAgICAgICAgICAgICAgICBvcHRpb25zLmZldGNoUG9saWN5ID09PSAnY2FjaGUtYW5kLW5ldHdvcmsnKSkge1xuICAgICAgICAgICAgb3B0aW9ucyA9IF9fYXNzaWduKF9fYXNzaWduKHt9LCBvcHRpb25zKSwgeyBmZXRjaFBvbGljeTogJ2NhY2hlLWZpcnN0JyB9KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5xd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m9kZS5hcmd1bWVudHMuc29tZShmdW5jdGlvbiAoYXJnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZy5uYW1lLnZhbHVlID09PSAnYWx3YXlzJyAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmcudmFsdWUua2luZCA9PT0gJ0Jvb2xlYW5WYWx1ZScgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJnLnZhbHVlLnZhbHVlID09PSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9yY2VSZXNvbHZlcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQlJFQUs7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgfSxcbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiBmb3JjZVJlc29sdmVycztcbiAgICB9O1xuICAgIExvY2FsU3RhdGUucHJvdG90eXBlLmJ1aWxkUm9vdFZhbHVlRnJvbUNhY2hlID0gZnVuY3Rpb24gKGRvY3VtZW50LCB2YXJpYWJsZXMpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuY2FjaGUuZGlmZih7XG4gICAgICAgICAgICBxdWVyeTogYnVpbGRRdWVyeUZyb21TZWxlY3Rpb25TZXQoZG9jdW1lbnQpLFxuICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICByZXR1cm5QYXJ0aWFsRGF0YTogdHJ1ZSxcbiAgICAgICAgICAgIG9wdGltaXN0aWM6IGZhbHNlLFxuICAgICAgICB9KS5yZXN1bHQ7XG4gICAgfTtcbiAgICBMb2NhbFN0YXRlLnByb3RvdHlwZS5yZXNvbHZlRG9jdW1lbnQgPSBmdW5jdGlvbiAoZG9jdW1lbnQsI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A9IG1haW5EZWZpbml0aW9uXG4gICAgICAgICAgICAgICAgICAgIC5vcGVyYXRpb247XG4gICAgICAgICAgICAgICAgZGVmYXVsdE9wZXJhdGlvblR5cGUgPSBkZWZpbml0aW9uT3BlcmF0aW9uXG4gICAgICAgICAgICAgICAgICAgID8gZGVmaW5pdGlvbk9wZXJhdGlvbi5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZpbml0aW9uT3BlcmF0aW9uLnNsaWNlKDEpXG4gICAgICAgICAgICAgICAgICAgIDogJ1F1ZXJ5JztcbiAgICAgICAgICAgICAgICBfYSA9IHRoaXMsIGNhY2hlID0gX2EuY2FjaGUsIGNsaWVudCA9IF9hLmNsaWVudDtcbiAgICAgICAgICAgICAgICBleGVjQ29udGV4dCA9IHtcbiAgICAgICAgICAgICAgICAgICAgZnJhZ21lbnRNYXA6IGZyYWdtZW50TWFwLFxuICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgY29udGV4dCksIHsgY2FjaGU6IGNhY2hlLFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50OiBjbGllbnQgfSksXG4gICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICBmcmFnbWVudE1hdGNoZXI6IGZyYWdtZW50TWF0Y2hlcixcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdE9wZXJhdGlvblR5cGU6IGRlZmF1bHRPcGVyYXRpb25UeXBlLFxuICAgICAgICAgICAgICAgICAgICBleHBvcnRlZFZhcmlhYmxlczoge30sXG4gICAgICAgICAgICAgICAgICAgIG9ubHlSdW5Gb3JjZWRSZXNvbHZlcnM6IG9ubHlSdW5Gb3JjZWRSZXNvbHZlcnMsXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICByZXR1cm4gWzIsIHRoaXMucmVzb2x2ZVN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RlcihfdGhpcywgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGZyYWdtZW50LCB0eXBlQ29uZGl0aW9uO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgZnVuY3Rpb24gKF9hKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXNob3VsZEluY2x1ZGUoc2VsZWN0aW9uLCB2YXJpYWJsZXMpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0ZpZWxkKHNlbGVjdGlvbikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzIsIHRoaXMucmVzb2x2ZUZpZWxkKHNlbGVjdGlvbiwgcm9vdFZhbHVlLCBleGVjQ29udGV4dCkudGhlbihmdW5jdGlvbiAoZmllbGRSZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfYTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZmllbGRSZXN1bHQgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0c1RvTWVyZ2UucHVzaCgoX2EgPSB7fSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2FbcmVzdWx0S2V5TmFtZUZyb21GaWVsZChzZWxlY3Rpb24pXSA9IGZpZWxkUmVzdWx0LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfYSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KV07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbmxpbmVGcmFnbWVudChzZWxlY3Rpb24pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhZ21lbnQgPSBzZWxlY3Rpb247XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFnbWVudCA9IGZyYWdtZW50TWFwW3NlbGVjdGlvbi5uYW1lLnZhbHVlXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgPyBpbnZhcmlhbnQoZnJhZ21lbnQsIDExKSA6IGludmFyaWFudChmcmFnbWVudCwgXCJObyBmcmFnbWVudCBuYW1lZCBcIiArIHNlbGVjdGlvbi5uYW1lLnZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmcmFnbWVudCAmJiBmcmFnbWVudC50eXBlQ29uZGl0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZUNvbmRpdGlvbiA9IGZyYWdtZW50LnR5cGVDb25kaXRpb24ubmFtZS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXhlY0NvbnRleHQuZnJhZ21lbnRNYXRjaGVyKHJvb3RWYWx1ZSwgdHlwZUNvbmRpdGlvbiwgY29udGV4dCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyLCB0aGlzLnJlc29sdmVTZWxlY3Rpb25TZXQoZnJhZ21lbnQuc2VsZWN0aW9uU2V0LCByb290VmFsdWUsIGV4ZWNDb250ZXh0KS50aGVuKGZ1bmN0aW9uIChmcmFnbWVudFJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNUb01lcmdlLnB1c2goZnJhZ21lbnRSZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSldO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMl07XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH0pOyB9O1xuICAgICAgICAgICAgICAgIHJldHVybiBbMiwgUHJvbWlzZS5hbGwoc2VsZWN0aW9uU2V0LnNlbGVjdGlvbnMubWFwKGV4ZWN1dGUpKS50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXJnZURlZXBBcnJheShyZXN1bHRzVG9NZXJnZSk7XG4gICAgICAgICAgICAgICAgICAgIH0pXTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9O1xuICAgIExvY2FsU3RhdGUucHJvdG90eXBlLnJlc29sdmVGaWVsZCA9IGZ1bmN0aW9uIChmaWVsZCwgcm9vdFZhbHVlLCBleGVjQ29udGV4dCkge1xuICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgdmFyaWFibGVzLCBmaWVsZE5hbWUsIGFsaWFzZWRGaWVsZE5hbWUsIGFsaWFzVXNlZCwgZGVmYXVsdFJlc3VsdCwgcmVzdWx0UHJvbWlzZSwgcmVzb2x2ZXJUeXBlLCByZXNvbHZlck1hcCwgcmVzb2x2ZTtcbiAgICAgICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgZnVuY3Rpb24gKF9hKSB7XG4gICAgICAgICAgICAgICAgdmFyaWFibGVzID0gZ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1bHRQcm9taXNlID0gUHJvbWlzZS5yZXNvbHZlKGNhY2hlU2xvdC53aXRoVmFsdWUodGhpcy5jYWNoZSwgcmVzb2x2ZSwgW1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb290VmFsdWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50c09iamVjdEZyb21GaWVsZChmaWVsZCwgdmFyaWFibGVzKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhlY0NvbnRleHQuY29udGV4dCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyBmaWVsZDogZmllbGQsIGZyYWdtZW50TWFwOiBleGVjQ29udGV4dC5mcmFnbWVudE1hcCB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gWzIsIHJlc3VsdFByb21pc2UudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09PSB2b2lkIDApIHsgcmVzdWx0ID0gZGVmYXVsdFJlc3VsdDsgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkLmRpcmVjdGl2ZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZC5kaXJlY3RpdmVzLmZvckVhY2goZnVuY3Rpb24gKGRpcmVjdGl2ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlyZWN0aXZlLm5hbWUudmFsdWUgPT09ICdleHBvcnQnICYmIGRpcmVjdGl2ZS5hcmd1bWVudHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcmVjdGl2ZS5hcmd1bWVudHMuZm9yRWFjaChmdW5jdGlvbiAoYXJnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZy5uYW1lLnZhbHVlID09PSAnYXMnICYmIGFyZy52YWx1ZS5raW5kID09PSAnU3RyaW5nVmFsdWUnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4ZWNDb250ZXh0LmV4cG9ydGVkVmFyaWFibGVzW2FyZy52YWx1ZS52YWx1ZV0gPSByZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmllbGQuc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHQgPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZXN1bHQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLnJlc29sdmVTdWJTZWxlY3RlZEFycmF5KGZpZWxkLCByZXN1bHQsIGV4ZWNDb250ZXh0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWVsZC5zZWxlY3Rpb25TZXQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3RoaXMucmVzb2x2ZVNlbGVjdGlvblNldChmaWVsZC5zZWxlY3Rpb25TZXQsIHJlc3VsdCwgZXhlY0NvbnRleHQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KV07XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBMb2NhbFN0YXRlLnByb3RvdHlwZS5yZXNvbHZlU3ViU2VsZWN0ZWRBcnJheSA9IGZ1bmN0aW9uIChmaWVsZCwgcmVzdWx0LCBleGVjQ29udGV4dCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwocmVzdWx0Lm1hcChmdW5jdGlvbiAoaXRlbSkge1xuICAgICAgICAgICAgaWYgKGl0ZW0gPT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLnJlc29sdmVTdWJTZWxlY3RlZEFycmF5KGZpZWxkLCBpdGVtLCBleGVjQ29udGV4dCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoZmllbGQuc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLnJlc29sdmVTZWxlY3Rpb25TZXQoZmllbGQuc2VsZWN0aW9uU2V0LCBpdGVtLCBleGVjQ29udGV4dCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pKTtcbiAgICB9O1xuICAgIHJldHVybiBMb2NhbFN0YXRlO1xufSgpKTtcbmV4cG9ydCB7IExvY2FsU3RhdGUgfTtcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPUxvY2FsU3RhdGUuanMubWFwIiwidmFyIE11dGF0aW9uU3RvcmUgPSAoZnVuY3Rpb24gKCkge1xuICAgIGZ1bmN0aW9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3R5cGUucmVzdWx0ID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkge1xuICAgICAgICAgICAgdmFyIG9ic2VydmVyID0ge1xuICAgICAgICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uIChyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShyZXN1bHQpO1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5vYnNlcnZlcnMuZGVsZXRlKG9ic2VydmVyKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFfdGhpcy5vYnNlcnZlcnMuc2l6ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMucXVlcnlNYW5hZ2VyLnJlbW92ZVF1ZXJ5KF90aGlzLnF1ZXJ5SWQpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgICAgIH0sIDApO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgZXJyb3I6IHJlamVjdCxcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICB2YXIgc3Vic2NyaXB0aW9uID0gX3RoaXMuc3Vic2NyaWJlKG9ic2VydmVyKTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlUXVlcnkucHJvdG90eXBlLmdldEN1cnJlbnRSZXN1bHQgPSBmdW5jdGlvbiAoc2F2ZUFzTGFzdFJlc3VsdCkge1xuICAgICAgICBpZiAoc2F2ZUFzTGFzdFJlc3VsdCA9PT0gdm9pZCAwKSB7IHNhdmVBc0xhc3RSZXN1bHQgPSB0cnVlOyB9XG4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YSA9IChkaWZmLmNvbXBsZXRlIHx8XG4gICAgICAgICAgICAgICAgdGhpcy5vcHRpb25zLnJldHVyblBhcnRpYWxEYXRhKSA/IGRpZmYucmVzdWx0IDogdm9pZCAwO1xuICAgICAgICAgICAgaWYgKGRpZmYuY29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICBpZiAocmVzdWx0Lm5ldHdvcmtTdGF0dXMgPT09IE5ldHdvcmtTdGF0dXMubG9hZGluZyAmJlxuICAgICAgICAgICAgICAgICAgICAoZmV0Y2hQb2xpY3kgPT09ICdjYWNoZS1maXJzdCcgfHxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZldGNoUG9saWN5ID09PSAnY2FjaGUtb25seScpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdC5uZXR3b3JrU3RhdHVzID0gTmV0d29ya1N0YXR1cy5yZWFkeTtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0LmxvYWRpbmcgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZGVsZXRlIHJlc3VsdC5wYXJ0aWFsO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0LnBhcnRpYWwgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChzYXZlQXNMYXN0UmVzdWx0KSB7XG4gICAgICAgICAgICB0aGlzLnVwZGF0ZUxhc3RSZXN1bHQocmVzdWx0KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH07XG4gICAgT2JzZXJ2YWJsZVF1ZXJ5LnByb3RvdHlwZS5pc0RpZmZlcmVudEZyb21MYXN0UmVzdWx0ID0gZnVuY3Rpb24gKG5ld1Jlc3VsdCkge1xuICAgICAgICByZXR1cm4gIWVxdWFsKHRoaXMubGFzdFJlc3VsdFNuYXBzaG90LCBuZXdSZXN1bHQpO1xuICAgIH07X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ICAgICAgICBfdGhpcy5xdWVyeU1hbmFnZXIuY2FjaGUud3JpdGVRdWVyeSh7XG4gICAgICAgICAgICAgICAgICAgIHF1ZXJ5OiBjb21iaW5lZE9wdGlvbnMucXVlcnksXG4gICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogY29tYmluZWRPcHRpb25zLnZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgZGF0YTogZGF0YSxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBmZXRjaE1vcmVSZXN1bHQ7XG4gICAgICAgIH0pLmZpbmFsbHkoZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgX3RoaXMucXVlcnlNYW5hZ2VyLnN0b3BRdWVyeShxaWQpO1xuICAgICAgICAgICAgX3RoaXMucmVvYnNlcnZlKCk7XG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgT2JzZXJ2YWJsZVF1ZXJ5LnByb3RvdHlwZS5zdWJzY3JpYmVUb01vcmUgPSBmdW5jdGlvbiAob3B0aW9ucykge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgc3Vic2NyaXB0aW9uID0gdGhpcy5xdWVyeU1hbmFnZXJcbiAgICAgICAgICAgIC5zdGFydEdyYXBoUUxTdWJzY3JpcHRpb24oe1xuICAgICAgICAgICAgcXVlcnk6IG9wdGlvbnMuZG9jdW1lbnQsXG4gICAgICAgICAgICB2YXJpYWJsZXM6IG9wdGlvbnMudmFyaWFibGVzLFxuICAgICAgICAgICAgY29udGV4dDogb3B0aW9ucy5jb250ZXh0LFxuICAgICAgICB9KVxuICAgICAgICAgICAgLnN1YnNjcmliZSh7XG4gICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAoc3Vic2NyaXB0aW9uRGF0YSkge1xuICAgICAgICAgICAgICAgIHZhciB1cGRhdGVRdWVyeSA9IG9wdGlvbnMudXBkYXRlUXVlcnk7XG4gICAgICAgICAgICAgICAgaWYgKHVwZGF0ZVF1ZXJ5KSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLnVwZGF0ZVF1ZXJ5KGZ1bmN0aW9uIChwcmV2aW91cywgX2EpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB2YXJpYWJsZXMgPSBfYS52YXJpYWJsZXM7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdXBkYXRlUXVlcnkocHJldmlvdXMsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb25EYXRhOiBzdWJzY3JpcHRpb25EYXRhLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGVycikge1xuICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLm9uRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy5vbkVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcHJvY2Vzcy5lbnYuTk9ERV9FTlYgPT09IFwicHJvZHVjdGlvblwiIHx8IGludmFyaWFudC5lcnJvcignVW5oYW5kbGVkIEdyYXBoUUwgc3Vic2NyaXB0aW9uIGVycm9yJywgZXJyKTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLnN1YnNjcmlwdGlvbnMuYWRkKHN1YnNjcmlwdGlvbik7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICBpZiAoX3RoaXMuc3Vic2NyaXB0aW9ucy5kZWxldGUoc3Vic2NyaXB0aW9uKSkge1xuICAgICAgICAgIC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ge1xuICAgICAgICAgICAgdGhpcy5saXN0ZW5lcnMuZGVsZXRlKHRoaXMub3FMaXN0ZW5lcik7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5vYnNlcnZhYmxlUXVlcnkgPSBvcTtcbiAgICAgICAgaWYgKG9xKSB7XG4gICAgICAgICAgICBvcVtcInF1ZXJ5SW5mb1wiXSA9IHRoaXM7XG4gICAgICAgICAgICB0aGlzLmxpc3RlbmVycy5hZGQodGhpcy5vcUxpc3RlbmVyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpcy5nZXREaWZmKCkuZnJvbU9wdGltaXN0aWNUcmFuc2FjdGlvbikge1xuICAgICAgICAgICAgICAgICAgICBvcVtcIm9ic2VydmVcIl0oKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG9xLnJlb2JzZXJ2ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgZGVsZXRlIHRoaXMub3FMaXN0ZW5lcjtcbiAgICAgICAgfVxuICAgIH07XG4gICAgUXVlcnlJbmZvLnByb3RvdHlwZS5ub3RpZnkgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIGlmICh0aGlzLm5vdGlmeVRpbWVvdXQpIHtcbiAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aGlzLm5vdGlmeVRpbWVvdXQpO1xuICAgICAgICAgICAgdGhpcy5ub3RpZnlUaW1lb3V0ID0gdm9pZCAwO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLnNob3VsZE5vdGlmeSgpKSB7XG4gICAgICAgICAgICB0aGlzLmxpc3RlbmVycy5mb3JFYWNoKGZ1bmN0aW9uIChsaXN0ZW5lcikgeyByZXR1cm4gbGlzdGVuZ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VRdWVyeSh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnk6IF90aGlzLmRvY3VtZW50LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IHJlc3VsdC5kYXRhLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogb3B0aW9ucy52YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLmxhc3RXcml0ZSA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQ6IHJlc3VsdCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IG9wdGlvbnMudmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRtQ291bnQ6IGRlc3RydWN0aXZlTWV0aG9kQ291bnRzLmdldChfdGhpcy5jYWNoZSksXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF90aGlzLmRpZmYgJiYgX3RoaXMuZGlmZi5jb21wbGV0ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdC5kYXRhID0gX3RoaXMuZGlmZi5yZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHZhciBkaWZmID0gY2FjaGUuZGlmZih7XG4gICAgICAgICAgICAgICAgICAgICAgICBxdWVyeTogX3RoaXMuZG9jdW1lbnQsXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IG9wdGlvbnMudmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuUGFydGlhbERhdGE6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBvcHRpbWlzdGljOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgX3RoaXMudXBkYXRlV2F0Y2gob3B0aW9ucy52YXJpYWJsZXMpO1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5kaWZmID0gZGlmZjtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpZmYuY29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdC5kYXRhID0gZGlmZi5yZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMubGFzdFdyaXRlID0gdm9pZCAwO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBRdWVyeUluZm8ucHJvdG90eXBlLm1hcmtSZWFkeSA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdGhpcy5uZXR3b3JrRXJyb3IgPSBudWxsO1xuICAgICAgICByZXR1cm4gdGhpcy5uZXR3b3JrU3RhdHVzID0gTmV0d29ya1N0YXR1cy5yZWFkeTtcbiAgICB9O1xuICAgIFF1ZXJ5SW5mby5wcm90b3R5cGUubWFya0Vycm9yID0gZnVuY3Rpb24gKGVycm9yKSB7XG4gICAgICAgIHRoaXMubmV0d29ya1N0YXR1cyA9IE5ldHdvcmtTdGF0dXMuZXJyb3I7XG4gICAgICAgIHRoaXMubGFzdFdyaXRlID0gdm9pZCAwO1xuICAgICAgICBpZiAoZXJyb3IuZ3JhcGhRTEVycm9ycykge1xuICAgICAgICAgICAgdGhpcy5ncmFwaFFMRXJyb3JzID0gZXJyb3IuZ3JhcGhRTEVycm9ycztcbiAgICAgICAgfVxuICAgICAgICBpZiAoZXJyb3IubmV0d29ya0Vycm9yKSB7XG4gICA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7XG4gICAgICAgICAgICAgICAgc3dpdGNoIChfZi5sYWJlbCkge1xuICAgICAgICAgICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJwcm9kdWN0aW9uXCIgPyBpbnZhcmlhbnQobXV0YXRpb24sIDEzKSA6IGludmFyaWFudChtdXRhdGlvbiwgJ211dGF0aW9uIG9wdGlvbiBpcyByZXF1aXJlZC4gWW91IG11c3Qgc3BlY2lmeSB5b3VyIEdyYXBoUUwgZG9jdW1lbnQgaW4gdGhlIG11dGF0aW9uIG9wdGlvbi4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiA/IGludmFyaWFudCghZmV0Y2hQb2xpY3kgfHwgZmV0Y2hQb2xpY3kgPT09ICduby1jYWNoZScsIDE0KSA6IGludmFyaWFudCghZmV0Y2hQb2xpY3kgfHwgZmV0Y2hQb2xpY3kgPT09ICduby1jYWNoZScsIFwiTXV0YXRpb25zIG9ubHkgc3VwcG9ydCBhICduby1jYWNoZScgZmV0Y2hQb2xpY3kuIElmIHlvdSBkb24ndCB3YW50IHRvIGRpc2FibGUgdGhlIGNhY2hlLCByZW1vdmUgeW91ciBmZXRjaFBvbGljeSBzZXR0aW5nIHRvIHByb2NlZWQgd2l0aCB0aGUgZGVmYXVsdCBtdXRhdGlvbiBiZWhhdmlvci5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBtdXRhdGlvbklkID0gdGhpcy5nZW5lcmF0ZU11dGF0aW9uSWQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG11dGF0aW9uID0gdGhpcy50cmFuc2Zvcm0obXV0YXRpb24pLmRvY3VtZW50O1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzID0gdGhpcy5nZXRWYXJpYWJsZXMobXV0YXRpb24sIHZhcmlhYmxlcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMudHJhbnNmb3JtKG11dGF0aW9uKS5oYXNDbGllbnRFeHBvcnRzKSByZXR1cm4gWzMsIDJdO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFs0LCB0aGlzLmxvY2FsU3RhdGUuYWRkRXhwb3J0ZWRWYXJpYWJsZXMobXV0YXRpb24sIHZhcmlhYmxlcywgY29udGV4dCldO1xuICAgICAgICAgICAgICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXMgPSBfZi5zZW50KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBfZi5sYWJlbCA9IDI7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgMjpcbiAgICAgICAgICAgICAgICAgICAgICAgIGdlbmVyYXRlVXBkYXRlUXVlcmllc0luZm8gPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJldCA9IHt9O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1cGRhdGVRdWVyaWVzQnlOYW1lKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnF1ZXJpZXMuZm9yRWFjaChmdW5jdGlvbiAoX2EsIHF1ZXJ5SWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYnNlcnZhYmxlUXVlcnkgPSBfYS5vYnNlcnZhYmxlUXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JzZXJ2YWJsZVF1ZXJ5KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHF1ZXJ5TmFtZSA9IG9ic2VydmFibGVRdWVyeS5xdWVyeU5hbWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHF1ZXJ5TmFtZSAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNPd25Qcm9wZXJ0eS5jYWxsKHVwZGF0ZVF1ZXJpZXNCeU5hbWUsIHF1ZXJ5TmFtZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0W3F1ZXJ5SWRdID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlcjogdXBkYXRlUXVlcmllc0J5TmFtZVtxdWVyeU5hbWVdLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnlJbmZvOiBfdGhpcy5xdWVyaWVzLmdldChxdWVyeUlkKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmV0O1xuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubXV0YXRpb25TdG9yZS5pbml0TXV0YXRpb24obXV0YXRpb25JZCwgbXV0YXRpb24sIHZhcmlhYmxlcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW1pc3RpY1Jlc3BvbnNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW1pc3RpY18xID0gdHlwZW9mIG9wdGltaXN0aWNSZXNwb25zZSA9PT0gJ2Z1bmN0aW9uJ1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IG9wdGltaXN0aWNSZXNwb25zZSh2YXJpYWJsZXMpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogb3B0aW1pc3RpY1Jlc3BvbnNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGUucmVjb3JkT3B0aW1pc3RpY1RyYW5zYWN0aW9uKGZ1bmN0aW9uIChjYWNoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya011dGF0aW9uUmVzdWx0KHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXRhdGlvbklkOiBtdXRhdGlvbklkLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdDogeyBkYXRhOiBvcHRpbWlzdGljXzEgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb2N1bWVudDogbXV0YXRpb24sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JQb2xpY3k6IGVycm9yUG9saWN5LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5VXBkYXRlcnNCeUlkOiBnZW5lcmF0ZVVwZGF0ZVF1ZXJpZXNJbmZvKCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlOiB1cGRhdGVXaXRoUHJveHlGbixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGNhY2hlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiB8fCBpbnZhcmlhbnQuZXJyb3IoZXJyb3IpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgbXV0YXRpb25JZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJyb2FkY2FzdFF1ZXJpZXMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYgPSB0aGlzO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyLCBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdG9yZVJlc3VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmdldE9ic2VydmFibGVGcm9tTGluayhtdXRhdGlvbiwgX19hc3NpZ24oX19hc3NpZ24oe30sIGNvbnRleHQpLCB7IG9wdGltaXN0aWNSZXNwb25zZTogb3B0aW1pc3RpY1Jlc3BvbnNlIH0pLCB2YXJpYWJsZXMsIGZhbHNlKS5zdWJzY3JpYmUoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncmFwaFFMUmVzdWx0SGFzRXJyb3IocmVzdWx0KSAmJiBlcnJvclBvbGljeSA9PT0gJ25vbmUnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yID0gbmV3IEFwb2xsb0Vycm9yKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoUUxFcnJvcnM6IHJlc3VsdC5lcnJvcnMsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYubXV0YXRpb25TdG9yZS5tYXJrTXV0YXRpb25SZXN1bHQobXV0YXRpb25JZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZldGNoUG9saWN5ICE9PSAnbm8tY2FjaGUnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXJrTXV0YXRpb25SZXN1bHQoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG11dGF0aW9uSWQ6IG11dGF0aW9uSWQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0OiByZXN1bHQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQ6IG11dGF0aW9uLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yUG9saWN5OiBlcnJvclBvbGljeSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeVVwZGF0ZXJzQnlJZDogZ2VuZXJhdGVVcGRhdGVRdWVyaWVzSW5mbygpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZTogdXBkYXRlV2l0aFByb3h5Rm4sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBzZWxmLmNhY2hlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3IgPSBuZXcgQXBvbGxvRXJyb3Ioe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldHdvcmtFcnJvcjogZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JlUmVzdWx0ID0gcmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yOiBmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5tdXRhdGlvblN0b3JlLm1hcmtNdXRhdGlvbkVycm9yKG11dGF0aW9uSWQsIGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGltaXN0aWNSZXNwb25zZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmNhY2hlLnJlbW92ZU9wdGltaXN0aWMobXV0YXRpb25JZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuYnJvYWRjYXN0UXVlcmllcygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgQXBvbGxvRXJyb3Ioe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrRXJyb3I6IGVycixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5tdXRhdGlvblN0b3JlLm1hcmtNdXRhdGlvbkVycm9yKG11dGF0aW9uSWQsIGVycm9yKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGltaXN0aWNSZXNwb25zZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxmLmNhY2hlLnJlbW92ZU9wdGltaXN0aWMobXV0YXRpb25JZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGYuYnJvYWRjYXN0UXVlcmllcygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QoZXJyb3IpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVmZXRjaFF1ZXJpZXMgPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmZXRjaFF1ZXJpZXMgPSByZWZldGNoUXVlcmllcyhzdG9yZVJlc3VsdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZWZldGNoUXVlcnlQcm9taXNlcyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc05vbkVtcHR5QXJyYXkocmVmZXRjaFF1ZXJpZXMpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZmV0Y2hRdWVyaWVzLmZvckVhY2goZnVuY3Rpb24gKHJlZmV0Y2hRdWVyeSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZWZldGNoUXVlcnkgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZi5xdWVyaWVzLmZvckVhY2goZnVuY3Rpb24gKF9hKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYnNlcnZhYmxlUXVlcnkgPSBfYS5vYnNlcnZhYmxlUXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvYnNlcnZhYmxlUXVlcnkgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9ic2VydmFibGVRdWVyeS5xdWVyeU5hbWUgPT09IHJlZmV0Y2hRdWVyeSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmZXRjaFF1ZXJ5UHJvbWlzZXMucHVzaChvYnNlcnZhYmxlUXVlcnkucmVmZXRjaCgpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHF1ZXJ5T3B0aW9ucyA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnk6IHJlZmV0Y2hRdWVyeS5xdWVyeSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiByZWZldGNoUXVlcnkudmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmZXRjaFBvbGljeTogJ25ldHdvcmstb25seScsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVmZXRjaFF1ZXJ5LmNvbnRleHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnlPcHRpb25zLmNvbnRleHQgPSByZWZldGNoUXVlcnkuY29udGV4dDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmZXRjaFF1ZXJ5UHJvbWlzZXMucHVzaChzZWxmLnF1ZXJ5KHF1ZXJ5T3B0aW9ucykpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5hbGwoYXdhaXRSZWZldGNoUXVlcmllcyA/IHJlZmV0Y2hRdWVyeVByb21pc2VzIDogW10pLnRoZW4oZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3JQb2xpY3kgPT09ICdpZ25vcmUnICYmXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yZVJlc3VsdCAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhRTFJlc3VsdEhhc0Vycm9yKHN0b3JlUmVzdWx0KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHN0b3JlUmVzdWx0LmVycm9ycztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHN0b3JlUmVzdWx0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCByZWplY3QpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSldO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9O1xuICAgIFF1ZXJ5TWFuYWdlci5wcm90b3R5cGUuZmV0Y2hRdWVyeSA9IGZ1bmN0aW9uIChxdWVyeUlkLCBvcHRpb25zLCBuZXR3b3JrU3RhdHVzKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmZldGNoUXVlcnlPYnNlcnZhYmxlKHF1ZXJ5SWQsIG9wdGlvbnMsIG5ldHdvcmtTdGF0dXMpLnByb21pc2U7XG4gICAgfTtcbiAgICBRdWVyeU1hbmFnZXIucHJvdG90eXBlLmdldFF1ZXJ5U3RvcmUgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBzdG9yZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gICAgICAgIHRoaXMucXVlcmllcy5mb3JFYWNoKGZ1bmN0aW9uIChpbmZvLCBxdWVyeUlkKSB7XG4gICAgICAgICAgICBzdG9yZVtxdWVyeUlkXSA9IHtcbiAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IGluZm8udmFyaWFibGVzLFxuICAgICAgICAgICAgICAgIG5ldHdvcmtTdGF0dXM6IGluZm8ubmV0d29ya1N0YXR1cyxcbiAgICAgICAgICAgICAgICBuZXR3b3JrRXJyb3I6IGluZm8ubmV0d29ya0Vycm9yLFxuICAgICAgICAgICAgICAgIGdyYXBoUUxFcnJvcnM6IGluZm8uZ3JhcGhRTEVycm9ycyxcbiAgICAgICAgICAg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gIHZhciBtYWtlT2JzZXJ2YWJsZSA9IGZ1bmN0aW9uICh2YXJpYWJsZXMpIHtcbiAgICAgICAgICAgIHJldHVybiBfdGhpcy5nZXRPYnNlcnZhYmxlRnJvbUxpbmsocXVlcnksIGNvbnRleHQsIHZhcmlhYmxlcywgZmFsc2UpLm1hcChmdW5jdGlvbiAocmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgaWYgKGZldGNoUG9saWN5ICE9PSAnbm8tY2FjaGUnKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzaG91bGRXcml0ZVJlc3VsdChyZXN1bHQsIGVycm9yUG9saWN5KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuY2FjaGUud3JpdGUoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5OiBxdWVyeSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQ6IHJlc3VsdC5kYXRhLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFJZDogJ1JPT1RfU1VCU0NSSVBUSU9OJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IHZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLmJyb2FkY2FzdFF1ZXJpZXMoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGdyYXBoUUxSZXN1bHRIYXNFcnJvcihyZXN1bHQpKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBBcG9sbG9FcnJvcih7XG4gICAgICAgICAgICAgICAgICAgICAgICBncmFwaFFMRXJyb3JzOiByZXN1bHQuZXJyb3JzLFxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgIC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51bGwgfHwgY29udGV4dCA9PT0gdm9pZCAwID8gdm9pZCAwIDogY29udGV4dC5xdWVyeURlZHVwbGljYXRpb24pICE9PSBudWxsICYmIF9hICE9PSB2b2lkIDAgPyBfYSA6IHRoaXMucXVlcnlEZWR1cGxpY2F0aW9uOyB9XG4gICAgICAgIHZhciBvYnNlcnZhYmxlO1xuICAgICAgICB2YXIgc2VydmVyUXVlcnkgPSB0aGlzLnRyYW5zZm9ybShxdWVyeSkuc2VydmVyUXVlcnk7XG4gICAgICAgIGlmIChzZXJ2ZXJRdWVyeSkge1xuICAgICAgICAgICAgdmFyIF9iID0gdGhpcywgaW5GbGlnaHRMaW5rT2JzZXJ2YWJsZXNfMSA9IF9iLmluRmxpZ2h0TGlua09ic2VydmFibGVzLCBsaW5rID0gX2IubGluaztcbiAgICAgICAgICAgIHZhciBvcGVyYXRpb24gPSB7XG4gICAgICAgICAgICAgICAgcXVlcnk6IHNlcnZlclF1ZXJ5LFxuICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgIG9wZXJhdGlvbk5hbWU6IGdldE9wZXJhdGlvbk5hbWUoc2VydmVyUXVlcnkpIHx8IHZvaWQgMCxcbiAgICAgICAgICAgICAgICBjb250ZXh0OiB0aGlzLnByZXBhcmVDb250ZXh0KF9fYXNzaWduKF9fYXNzaWduKHt9LCBjb250ZXh0KSwgeyBmb3JjZUZldGNoOiAhZGVkdXBsaWNhdGlvbiB9KSksXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgY29udGV4dCA9IG9wZXJhdGlvbi5jb250ZXh0O1xuICAgICAgICAgICAgaWYgKGRlZHVwbGljYXRpb24pIHtcbiAgICAgICAgICAgICAgICB2YXIgYnlWYXJpYWJsZXNfMSA9IGluRmxpZ2h0TGlua09ic2VydmFibGVzXzEuZ2V0KHNlcnZlclF1ZXJ5KSB8fCBuZXcgTWFwKCk7XG4gICAgICAgICAgICAgICAgaW5GbGlnaHRMaW5rT2JzZXJ2YWJsZXNfMS5zZXQoc2VydmVyUXVlcnksIGJ5VmFyaWFibGVzXzEpO1xuICAgICAgICAgICAgICAgIHZhciB2YXJKc29uXzEgPSBKU09OLnN0cmluZ2lmeSh2YXJpYWJsZXMpO1xuICAgICAgICAgICAgICAgIG9ic2VydmFibGUgPSBieVZhcmlhYmxlc18xLmdldCh2YXJKc29uXzEpO1xuICAgICAgICAgICAgICAgIGlmICghb2JzZXJ2YWJsZSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgY29uY2FzdCA9IG5ldyBDb25jYXN0KFtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4ZWN1dGUobGluaywgb3BlcmF0aW9uKVxuICAgICAgICAgICAgICAgICAgICBdKTtcbiAgICAgICAgICAgICAgICAgICAgYnlWYXJpYWJsZXNfMS5zZXQodmFySnNvbl8xLCBvYnNlcnZhYmxlID0gY29uY2FzdCk7XG4gICAgICAgICAgICAgICAgICAgIGNvbmNhc3QuY2xlYW51cChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYnlWYXJpYWJsZXNfMS5kZWxldGUodmFySnNvbl8xKSAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5VmFyaWFibGVzXzEuc2l6ZSA8IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbkZsaWdodExpbmtPYnNlcnZhYmxlc18xLmRlbGV0ZShzZXJ2ZXJRdWVyeSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIG9ic2VydmFibGUgPSBuZXcgQ29uY2FzdChbXG4gICAgICAgICAgICAgICAgICAgIGV4ZWN1dGUobGluaywgb3BlcmF0aW9uKVxuICAgICAgICAgICAgICAgIF0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgb2JzZXJ2YWJsZSA9IG5ldyBDb25jYXN0KFtcbiAgICAgICAgICAgICAgICBPYnNlcnZhYmxlLm9mKHsgZGF0YToge30gfSlcbiAgICAgICAgICAgIF0pO1xuICAgICAgICAgICAgY29udGV4dCA9IHRoaXMucHJlcGFyZUNvbnRleHQoY29udGV4dCk7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGNsaWVudFF1ZXJ5ID0gdGhpcy50cmFuc2Zvcm0ocXVlcnkpLmNsaWVudFF1ZXJ5O1xuICAgICAgICBpZiAoY2xpZW50UXVlcnkpIHtcbiAgICAgICAgICAgIG9ic2VydmFibGUgPSBhc3luY01hcChvYnNlcnZhYmxlLCBmdW5jdGlvbiAocmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzLmxvY2FsU3RhdGUucnVuUmVzb2x2ZXJzKHtcbiAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQ6IGNsaWVudFF1ZXJ5LFxuICAgICAgICAgICAgICAgICAgICByZW1vdGVSZXN1bHQ6IHJlc3VsdCxcbiAgICAgICAgICAgICAgICAgICAgY29udGV4dDogY29udGV4dCxcbiAgICAgICAgICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gb2JzZXJ2YWJsZTtcbiAgICB9O1xuICAgIFF1ZXJ5TWFuYWdlci5wcm90b3R5cGUuZ2V0UmVzdWx0c0Zyb21MaW5rID0gZnVuY3Rpb24gKHF1ZXJ5SW5mbywgYWxsb3dDYWNoZVdyaXRlLCBvcHRpb25zKSB7XG4gICAgICAgIHZhciBsYXN0UmVxdWVzdElkID0gcXVlcnlJbmZvLmxhc3RSZXF1ZXN0SWQ7XG4gICAgICAgIHJldHVybiBhc3luY01hcCh0aGlzLmdldE9ic2VydmFibGVGcm9tTGluayhxdWVyeUluZm8uZG9jdW1lbnQsIG9wdGlvbnMuY29udGV4dCwgb3B0aW9ucy52YXJpYWJsZXMpLCBmdW5jdGlvbiAocmVzdWx0KSB7XG4gICAgICAgICAgICB2YXIgaGFzRXJyb3JzID0gaXNOb25FbXB0eUFycmF5KHJlc3VsdC5lcnJvcnMpO1xuICAgICAgICAgICAgaWYgKGxhc3RSZXF1ZXN0SWQgPj0gcXVlcnlJbmZvLmxhc3RSZXF1ZXN0SWQpIHtcbiAgICAgICAgICAgICAgICBpZiAoaGFzRXJyb3JzICYmIG9wdGlvbnMuZXJyb3JQb2xpY3kgPT09IFwibm9uZVwiKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IHF1ZXJ5SW5mby5tYXJrRXJyb3IobmV3IEFwb2xsb0Vycm9yKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoUUxFcnJvcnM6IHJlc3VsdC5lcnJvcnMsXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcXVlcnlJbmZvLm1hcmtSZXN1bHQocmVzdWx0LCBvcHRpb25zLCBhbGxvd0NhY2hlV3JpdGUpO1xuICAgICAgICAgICAgICAgIHF1ZXJ5SW5mby5tYXJrUmVhZHkoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBhcXIgPSB7XG4gICAgICAgICAgICAgICAgZGF0YTogcmVzdWx0LmRhdGEsXG4gICAgICAgICAgICAgICAgbG9hZGluZzogZmFsc2UsXG4gICAgICAgICAgICAgICAgbmV0d29ya1N0YXR1czogcXVlcnlJbmZvLm5ldHdvcmtTdGF0dXMgfHwgTmV0d29ya1N0YXR1cy5yZWFkeSxcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoaGFzRXJyb3JzICYmIG9wdGlvbnMuZXJyb3JQb2xpY3kgIT09IFwiaWdub3JlXCIpIHtcbiAgICAgICAgICAg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29ya1N0YXR1cyAmJlxuICAgICAgICAgICAgaXNOZXR3b3JrUmVxdWVzdEluRmxpZ2h0KG5ldHdvcmtTdGF0dXMpKSB7XG4gICAgICAgICAgICBpZiAoZmV0Y2hQb2xpY3kgIT09IFwiY2FjaGUtZmlyc3RcIikge1xuICAgICAgICAgICAgICAgIGZldGNoUG9saWN5ID0gXCJjYWNoZS1hbmQtbmV0d29ya1wiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuUGFydGlhbERhdGEgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHZhciBub3JtYWxpemVkID0gT2JqZWN0LmFzc2lnbih7fSwgb3B0aW9ucywge1xuICAgICAgICAgICAgcXVlcnk6IHF1ZXJ5LFxuICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICBmZXRjaFBvbGljeTogZmV0Y2hQb2xpY3ksXG4gICAgICAgICAgICBlcnJvclBvbGljeTogZXJyb3JQb2xpY3ksXG4gICAgICAgICAgICByZXR1cm5QYXJ0aWFsRGF0YTogcmV0dXJuUGFydGlhbERhdGEsXG4gICAgICAgICAgICBub3RpZnlPbk5ldHdvcmtTdGF0dXNDaGFuZ2U6IG5vdGlmeU9uTmV0d29ya1N0YXR1c0NoYW5nZSxcbiAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgIH0pO1xuICAgICAgICB2YXIgZnJvbVZhcmlhYmxlcyA9IGZ1bmN0aW9uICh2YXJpYWJsZXMpIHtcbiAgICAgICAgICAgIG5vcm1hbGl6ZWQudmFyaWFibGVzID0gdmFyaWFibGVzO1xuICAgICAgICAgICAgcmV0dXJuIF90aGlzLmZldGNoUXVlcnlCeVBvbGljeShxdWVyeUluZm8sIG5vcm1hbGl6ZWQsIG5ldHdvcmtTdGF0dXMpO1xuICAgICAgICB9O1xuICAgICAgICB0aGlzLmZldGNoQ2FuY2VsRm5zLnNldChxdWVyeUlkLCBmdW5jdGlv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ICAgICAgICAgICAgIHJlbW90ZVJlc3VsdDogeyBkYXRhOiBkYXRhIH0sXG4gICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNvbnRleHQsXG4gICAgICAgICAgICAgICAgICAgIHZhcmlhYmxlczogdmFyaWFibGVzLFxuICAgICAgICAgICAgICAgICAgICBvbmx5UnVuRm9yY2VkUmVzb2x2ZXJzOiB0cnVlLFxuICAgICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKHJlc29sdmVkKSB7IHJldHVybiBmcm9tRGF0YShyZXNvbHZlZC5kYXRhKTsgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZnJvbURhdGEoZGF0YSk7XG4gICAgICAgIH07XG4gICAgICAgIHZhciByZXN1bHRzRnJvbUxpbmsgPSBmdW5jdGlvbiAoYWxsb3dDYWNoZVdyaXRlKSB7XG4gICAgICAgICAgICByZXR1cm4gX3RoaXMuZ2V0UmVzdWx0c0Zyb21MaW5rKHF1ZXJ5SW5mbywgYWxsb3dDYWNoZVdyaXRlLCB7XG4gICAgICAgICAgICAgICAgdmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgY29udGV4dDogY29udGV4dCxcbiAgICAgICAgICAgICAgICBmZXRjaFBvbGljeTogZmV0Y2hQb2xpY3ksXG4gICAgICAgICAgICAgICAgZXJyb3JQb2xpY3k6IGVycm9yUG9saWN5LFxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH07XG4gICAgICAgIHN3aXRjaCAoZmV0Y2hQb2xpY3kpIHtcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICBjYXNlIFwiY2FjaGUtZmlyc3RcIjoge1xuICAgICAgICAgICAgICAgIHZhciBkaWZmID0gcmVhZENhY2hlKCk7XG4gICAgICAgICAgICAgICAgaWYgKGRpZmYuY29tcGxldGUpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNGcm9tQ2FjaGUoZGlmZiwgcXVlcnlJbmZvLm1hcmtSZWFkeSgpKSxcbiAgICAgICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHJldHVyblBhcnRpYWxEYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBbXG4gICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzRnJvbUNhY2hlKGRpZmYpLFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0c0Zyb21MaW5rKHRydWUpLFxuICAgICAgICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgICAgICAgICByZXN1bHRzRnJvbUxpbmsodHJ1ZSksXG4gICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhc2UgXCJjYWNoZS1hbmQtbmV0d29ya1wiOiB7XG4gICAgICAgICAgICAgICAgdmFyIGRpZmYgPSByZWFkQ2FjaGUoKTtcbiAgICAgICAgICAgICAgICBpZiAoZGlmZi5jb21wbGV0ZSB8fCByZXR1cm5QYXJ0aWFsRGF0YSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gW1xuICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0c0Zyb21DYWNoZShkaWZmKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNGcm9tTGluayh0cnVlKSxcbiAgICAgICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIFtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0c0Zyb21MaW5rKHRydWUpLFxuICAgICAgICAgICAgICAgIF07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXNlIFwiY2FjaGUtb25seVwiOlxuICAgICAgICAgICAgICAgIHJldHVybiBb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AgICAgICAgICAgICB2YXJpYWJsZXM6IHZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuUGFydGlhbERhdGE6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIG9wdGltaXN0aWM6IGZhbHNlLFxuICAgICAgICAgICAgICAgIH0pLCBjdXJyZW50UXVlcnlSZXN1bHQgPSBfYy5yZXN1bHQsIGNvbXBsZXRlID0gX2MuY29tcGxldGU7XG4gICAgICAgICAgICAgICAgaWYgKGNvbXBsZXRlICYmIGN1cnJlbnRRdWVyeVJlc3VsdCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dFF1ZXJ5UmVzdWx0ID0gdXBkYXRlcihjdXJyZW50UXVlcnlSZXN1bHQsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG11dGF0aW9uUmVzdWx0OiBtdXRhdGlvbi5yZXN1bHQsXG4gICAgICAgICAgICAgICAgICAgICAgICBxdWVyeU5hbWU6IGdldE9wZXJhdGlvbk5hbWUoZG9jdW1lbnQpIHx8IHVuZGVmaW5lZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5VmFyaWFibGVzOiB2YXJpYWJsZXMsXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICBpZiAobmV4dFF1ZXJ5UmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZVdyaXRlc18xLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdDogbmV4dFF1ZXJ5UmVzdWx0LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFJZDogJ1JPT1RfUVVFUlknLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5OiBkb2N1bWVudCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXM6IHZhcmlhYmxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICA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Ghpcy5zaG91bGRGZXRjaCA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgaW5mbyA9IHBvbGxpbmdJbmZvIHx8ICh0aGlzLnBvbGxpbmdJbmZvID0ge30pO1xuICAgICAgICBpbmZvLmludGVydmFsID0gcG9sbEludGVydmFsO1xuICAgICAgICB2YXIgbWF5YmVGZXRjaCA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlmIChfdGhpcy5wb2xsaW5nSW5mbykge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpcy5zaG91bGRGZXRjaCAmJiBfdGhpcy5zaG91bGRGZXRjaCgpKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLnJlb2JzZXJ2ZSh7XG4gICAgICAgICAgICAgICAgICAgICAgICBmZXRjaFBvbGljeTogXCJuZXR3b3JrLW9ubHlcIixcbiAgICAgICAgICAgICAgICAgICAgICAgIG5leHRGZXRjaFBvbGljeTogX3RoaXMub3B0aW9ucy5mZXRjaFBvbGljeSB8fCBcImNhY2hlLWZpcnN0XCIsXG4gICAgICAgICAgICAgICAgICAgIH0sIE5ldHdvcmtTdGF0dXMucG9sbCkudGhlbihwb2xsLCBwb2xsKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHBvbGwoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICA7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBwb2xsID0gZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgdmFyIGluZm8gPSBfdGhpcy5wb2xsaW5nSW5mbztcbiAgICAgICAgICAgIGlmIChpbmZvKSB7XG4gICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KGluZm8udGltZW91dCk7XG4gICAgICAgICAgICAgICAgaW5mby50aW1lb3V0ID0gc2V0VGltZW91dChtYXliZU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Ryb2xsZXIgPSBfYy5jb250cm9sbGVyLCBzaWduYWwgPSBfYy5zaWduYWw7XG4gICAgICAgICAgICBjb250cm9sbGVyID0gX2NvbnRyb2xsZXI7XG4gICAgICAgICAgICBpZiAoY29udHJvbGxlcilcbiAgICAgICAgICAgICAgICBvcHRpb25zLnNpZ25hbCA9IHNpZ25hbDtcbiAgICAgICAgfVxuICAgICAgICB2YXIgZGVmaW5pdGlvbklzTXV0YXRpb24gPSBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgcmV0dXJuIGQua2luZCA9PT0gJ09wZXJhdGlvbkRlZmluaXRpb24nICYmIGQub3BlcmF0aW9uID09PSAnbXV0YXRpb24nO1xuICAgICAgICB9O1xuICAgICAgICBpZiAodXNlR0VURm9yUXVlcmllcyAmJlxuICAgICAgICAgICAgIW9wZXJhdGlvbi5xdWVyeS5kZWZpbml0aW9ucy5zb21lKGRlZmluaXRpb25Jc011dGF0aW9uKSkge1xuICAgICAgICAgICAgb3B0aW9ucy5tZXRob2QgPSAnR0VUJztcbiAgICAgICAgfVxuICAgICAgICBpZiAob3B0aW9ucy5tZXRob2QgPT09ICdHRVQnKSB7XG4gICAgICAgICAgICB2YXIgX2QgPSByZXdyaXRlVVJJRm9yR0VUKGNob3NlblVSSSwgYm9keSksIG5ld1VSSSA9IF9kLm5ld1VSSSwgcGFyc2VFcnJvciA9IF9kLnBhcnNlRXJyb3I7XG4gICAgICAgICAgICBpZiAocGFyc2VFcnJvcikge1xuICAgICAgICAgICAgICAgIHJldHVybiBmcm9tRXJyb3IocGFyc2VFcnJvcik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjaG9zZW5VUkkgPSBuZXdVUkk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIG9wdGlvbnMuYm9keSA9IHNlcmlhbGl6ZUZldGNoUGFyYW1ldGVyKGJvZHksICdQYXlsb2FkJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYXRjaCAocGFyc2VFcnJvcikge1xuICAgICAgICAgICAgICAgIHJldHVybiBmcm9tRXJyb3IocGFyc2VFcnJvcik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG5ldyBPYnNlcnZhYmxlKGZ1bmN0aW9uIChvYnNlcnZlcikge1xuICAgICAgICAgICAgZmV0Y2hlcihjaG9zZW5VUkksIG9wdGlvbnMpXG4gICAgICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKHJlc3BvbnNlKSB7XG4gICAgICAgICAgICAgICAgb3BlcmF0aW9uLnNldENvbnRleHQoeyByZXNwb25zZTogcmVzcG9uc2UgfSk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3BvbnNlO1xuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAudGhlbihwYXJzZUFuZENoZWNrSHR0cFJlc3BvbnNlKG9wZXJhdGlvbikpXG4gICAgICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkge1xuICAgICAgICAgICAgICAgIG9ic2VydmVyLm5leHQocmVzdWx0KTtcbiAgICAgICAgICAgICAgICBvYnNlcnZlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIC5jYXRjaChmdW5jdGlvbiAoZXJyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGVyci5uYW1lID09PSAnQWJvcnRFcnJvcicpXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICBpZiAoZXJyLnJlc3VsdCAmJiBlcnIucmVzdWx0LmVycm9ycyAmJiBlcnIucmVzdWx0LmRhdGEpIHtcbiAgICAgICAgICAgICAgICAgICAgb2JzZXJ2ZXIubmV4dChlcnIucmVzdWx0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgb2JzZXJ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ICAgICAgICAgICAgICAgIHJldHVybiBzZWVuLmdldCh2YWwpO1xuICAgICAgICAgICAgdmFyIGNvcHlfMSA9IHZhbC5zbGljZSgwKTtcbiAgICAgICAgICAgIHNlZW4uc2V0KHZhbCwgY29weV8xKTtcbiAgICAgICAgICAgIGNvcHlfMS5mb3JFYWNoKGZ1bmN0aW9uIChjaGlsZCwgaSkge1xuICAgICAgICAgICAgICAgIGNvcHlfMVtpXSA9IGNsb25lRGVlcEhlbHBlcihjaGlsZCwgc2Vlbik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybiBjb3B5XzE7XG4gICAgICAgIH1cbiAgICAgICAgY2FzZSBcIltvYmplY3QgT2JqZWN0XVwiOiB7XG4gICAgICAgICAgICBzZWVuID0gc2VlbiB8fCBuZXcgTWFwO1xuICAgICAgICAgICAgaWYgKHNlZW4uaGFzKHZhbCkpXG4gICAgICAgICAgICAgICAgcmV0dXJuIHNlZW4uZ2V0KHZhbCk7XG4gICAgICAgICAgICB2YXIgY29weV8yID0gT2JqZWN0LmNyZWF0ZShPYmplY3QuZ2V0UHJvdG90eXBlT2YodmFsKSk7XG4gICAgICAgICAgICBzZWVuLnNldCh2YWwsIGNvcHlfMik7XG4gICAgICAgICAgICBPYmplY3Qua2V5cyh2YWwpLmZvckVhY2goZnVuY3Rpb24gKGtleSkge1xuICAgICAgICAgICAgICAgIGNvcHlfMltrZXldID0gY2xvbmVEZWVwSGVscGVyKHZhbFtrZXldLCBzZWVuKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuIGNvcHlfMjtcbiAgICAgICAgfVxuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgcmV0dXJuIHZhbDtcbiAgICB9XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD1jbG9uZURlZXAuanMubWFwIiwiZXhwb3J0IGZ1bmN0aW9uIGNvbXBhY3QoKSB7XG4gICAgdmFyIG9iamVjdHMgPSBbXTtcbiAgICBm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XJjZSkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgY29udGV4dCA9IFtdO1xuICAgICAgICBmb3IgKHZhciBfaSA9IDI7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykge1xuICAgICAgICAgICAgY29udGV4dFtfaSAtIDJdID0gYXJndW1lbnRzW19pXTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNPYmplY3Qoc291cmNlKSAmJiBpc09iamVjdCh0YXJnZXQpKSB7XG4gICAgICAgICAgICBPYmplY3Qua2V5cyhzb3VyY2UpLmZvckVhY2goZnVuY3Rpb24gKHNvdXJjZUtleSkge1xuICAgICAgICAgICAgICAgIGlmIChoYXNPd25Qcm9wZXJ0eS5jYWxsKHRhcmdldCwgc291cmNlS2V5KSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0VmFsdWUgPSB0YXJnZXRbc291cmNlS2V5XTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZVtzb3VyY2VLZXldICE9PSB0YXJnZXRWYWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9IF90aGlzLnJlY29uY2lsZXIuYXBwbHkoX3RoaXMsIF9fc3ByZWFkQXJyYXlzKFt0YXJnZXQsIHNvdXJjZSwgc291cmNlS2V5XSwgY29udGV4dCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAhPT0gdGFyZ2V0VmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQgPSBfdGhpcy5zaGFsbG93Q29weUZvck1lcmdlKHRhcmdldCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0W3NvdXJjZUtleV0gPSByZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZ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iB0aGVyZSBpcyBub3QgZXhhY3RseSAxIGZyYWdtZW50LlwiKTtcbiAgICAgICAgYWN0dWFsRnJhZ21lbnROYW1lID0gZnJhZ21lbnRzWzBdLm5hbWUudmFsdWU7XG4gICAgfVxuICAgIHZhciBxdWVyeSA9IF9fYXNzaWduKF9fYXNzaWduKHt9LCBkb2N1bWVudCksIHsgZGVmaW5pdGlvbnM6IF9fc3ByZWFkQXJyYXlzKFtcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICBraW5kOiAnT3BlcmF0aW9uRGVmaW5pdGlvbicsXG4gICAgICAgICAgICAgICAgb3BlcmF0aW9uOiAncXVlcnknLFxuICAgICAgICAgICAgICAgIHNlbGVjdGlvblNldDoge1xuICAgICAgICAgICAgICAgICAgICBraW5kOiAnU2VsZWN0aW9uU2V0JyxcbiAgICAgICAgICAgICAgICAgICAgc2VsZWN0aW9uczogW1xuICAgICAgICAgICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtpbmQ6ICdGcmFnbWVudFNwcmVhZCcsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZToge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiAnTmFtZScsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBhY3R1YWxGcmFnbWVudE5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIF0sXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIH1cbiAgICAgICAgXSwgZG9jdW1lbnQuZGVmaW5pdGlvbnMpIH0pO1xuICAgIHJldHVybiBxdWVyeTtcbn1cbmV4cG9ydCBmdW5jdGlvbiBjcmVhdGVGcmFnbWVudE1hcChmcmFnbWVudHMpIHtcbiAgICBpZiAoZnJhZ21lbnRzID09PSB2b2lkIDApIHsgZnJhZ21l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bXVzdCBoYXZlIGV4YWN0bHkgb25lIGRlZmluaXRpb24uJyk7XG4gICAgdmFyIGZyYWdtZW50RGVmID0gZG9jLmRlZmluaXRpb25zWzBdO1xuICAgIHByb2Nlc3MuZW52Lk5PREVfRU5WID09PSBcInByb2R1Y3Rpb25cIiA/IGludmFyaWFudChmcmFnbWVudERlZi5raW5kID09PSAnRnJhZ21lbnREZWZpbml0aW9uJywgNTEpIDogaW52YXJpYW50KGZyYWdtZW50RGVmLmtpbmQgPT09ICdGcmFnbWVudERlZmluaXRpb24nLCAnTXVzdCBiZSBhIGZyYWdtZW50IGRlZmluaXRpb24uJyk7XG4gICAgcmV0dXJuIGZyYWdtZW50RGVmO1xufVxuZXhwb3J0IGZ1bmN0aW9uIGdldE1haW5EZWZpbml0aW9uKHF1ZXJ5RG9jKSB7XG4gICAgY2hlY2tEb2N1bWVudChxdWVyeURvYyk7XG4gICAgdmFyIGZyYWdtZW50RGVmaW5pdGlvbjtcbiAgICBmb3IgKHZhciBfaSA9IDAsIF9hID0gcXVlcnlEb2MuZGVmaW5pdGlvbnM7IF9pIDwgX2EubGVuZ3RoOyBfaSsrKSB7XG4gICAgICAgIHZhciBkZWZpbml0aW9uID0gX2FbX2ldO1xuICAgICAgICBpZiAoZGVmaW5pdGlvbi5raW5kID09PSAnT3BlcmF0aW9uRGVmaW5pdGlvbicpIHtcbiAgICAgICAgICAgIHZhciBvcGVyYXRpb24gPSBkZWZpbml0aW9uLm9wZXJhdGlvbjtcbiAgICAgICAgICAgIGlmIChvcGVyYXRpb24gPT09ICdxdWVyeScgfHxcbiAgICAgICAgICAgICAgICBvcGVyYXRpb24gPT09ICdtdXRhdGlvbicgfHxcbiAgICAgICAgICAgICAgICBvcGVyYXRpb24gPT09ICdzdWJzY3JpcHRpb24nKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluaXRpb247XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGRlZmluaXRpb24ua2luZ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ddWydmaWx0ZXInXVxuICAgICAgICAgICAgICAgIDogW107XG4gICAgICAgICAgICBmaWx0ZXJLZXlzLnNvcnQoKTtcbiAgICAgICAgICAgIHZhciBmaWx0ZXJlZEFyZ3NfMSA9IHt9O1xuICAgICAgICAgICAgZmlsdGVyS2V5cy5mb3JFYWNoKGZ1bmN0aW9uIChrZXkpIHtcbiAgICAgICAgICAgICAgICBmaWx0ZXJlZEFyZ3NfMVtrZXldID0gYXJnc1trZXldO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm4gZGlyZWN0aXZlc1snY29ubmVjdGlvbiddWydrZXknXSArIFwiKFwiICsgSlNPTi5zdHJpbmdpZnkoZmlsdGVyZWRBcmdzXzEpICsgXCIpXCI7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gZGlyZWN0aXZlc1snY29ubmVjdGlvbiddWydrZXknXTtcbiAgICAgICAgfVxuICAgIH1cbiAgICB2YXIgY29tcGxldGVGaWVsZE5hbWUgPSBmaWVsZE5hbWU7XG4gICAgaWYgKGFyZ3MpIHtcbiAgICAgICAgdmFyIHN0cmluZ2lmaWVkQXJncyA9IHN0cmluZ2lmeShhcmdzKTtcbiAgICAgICAgY29tcGxldGVGaWVsZE5hbWUgKz0gXCIoXCIgKyBzdHJpbmdpZmllZEFyZ3MgKyBcIilcIjtcbiAgICB9XG4gICAgaWYgKGRpcmVjdGl2ZXMpIHtcbiAgICAgICAgT2JqZWN0LmtleXMoZGlyZWN0aXZlcykuZm9yRWFjaChmdW5jdGlvbiAoa2V5KSB7XG4gICAgICAgICAgICBpZiAoS05PV05fRElSRUNUSVZFUy5pbmRleE9mKGtleSkgIT09IC0xKVxuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIGlmIChkaXJlY3RpdmVzW2tleV0gJiYgT2JqZWN0LmtleXMoZGlyZWN0aXZlc1trZXldKS5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgIC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biAgICAgICAgVmFyaWFibGU6IHtcbiAgICAgICAgICAgIGVudGVyOiBmdW5jdGlvbiAobm9kZSwgX2tleSwgcGFyZW50KSB7XG4gICAgICAgICAgICAgICAgaWYgKHBhcmVudC5raW5kICE9PSAnVmFyaWFibGVEZWZpbml0aW9uJykge1xuICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXNJblVzZVtub2RlLm5hbWUudmFsdWVdID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgICBGaWVsZDoge1xuICAgICAgICAgICAgZW50ZXI6IGZ1bmN0aW9uIChub2RlKSB7XG4gICAgICAgICAgICAgICAgaWYgKGRpcmVjdGl2ZXMgJiYgbm9kZS5kaXJlY3RpdmVzKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBzaG91bGRSZW1vdmVGaWVsZCA9IGRpcmVjdGl2ZXMuc29tZShmdW5jdGlvbiAoZGlyZWN0aXZlKSB7IHJldHVybiBkaXJlY3RpdmUucmVtb3ZlOyB9KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNob3VsZFJlbW92ZUZpZWxkICYmXG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlLmRpcmVjdGl2ZXMgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGUuZGlyZWN0aXZlcy5zb21lKGdldERpcmVjdGl2ZU1hdGNoZXIoZGlyZWN0aXZlcykpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobm9kZS5hcmd1bWVudHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlLmFyZ3VtZW50cy5mb3JFYWNoKGZ1bmN0aW9uIChhcmcpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZy52YWx1ZS5raW5kID09PSAnVmFyaWFibGUnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXJpYWJsZXNUb1JlbW92ZS5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiBhcmcudmFsdWUubmFtZS52YWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobm9kZS5zZWxlY3Rpb25TZXQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRBbGxGcmFnbWVudFNwcmVhZHNGcm9tU2VsZWN0aW9uU2V0KG5vZGUuc2VsZWN0aW9uU2V0KS5mb3JFYWNoKGZ1bmN0aW9uIChmcmFnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyYWdtZW50U3ByZWFkc1RvUmVtb3ZlLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogZnJhZy5uYW1lLnZhbHVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgICAgRnJhZ21lbnRTcHJlYWQ6IHtcbiAgICAgICAgICAgIGVudGVyOiBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICAgICAgICAgIGZyYWdtZW50U3ByZWFkc0luVXNlW25vZGUubmFtZS52YWx1ZV0gPSB0cnVlO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICAgICAgRGlyZWN0aXZlOiB7XG4gICAgICAgICAgICBlbnR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b24gKG5vZGUsIF9rZXksIHBhcmVudCkge1xuICAgICAgICAgICAgICAgIGlmIChwYXJlbnQgJiZcbiAgICAgICAgICAgICAgICAgICAgcGFyZW50LmtpbmQgPT09ICdPcGVyYXRpb25EZWZpbml0aW9uJykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBzZWxlY3Rpb25zID0gbm9kZS5zZWxlY3Rpb25zO1xuICAgICAgICAgICAgICAgIGlmICghc2VsZWN0aW9ucykge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBza2lwID0gc2VsZWN0aW9ucy5zb21lKGZ1bmN0aW9uIChzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChpc0ZpZWxkKHNlbGVjdGlvbikgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgIChzZWxlY3Rpb24ubmFtZS52YWx1ZSA9PT0gJ19fdHlwZW5hbWUnIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0aW9uLm5hbWUudmFsdWUubGFzdEluZGV4T2YoJ19fJywgMCkgPT09IDApKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpZiAoc2tpcCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBmaWVsZCA9IHBhcmVudDtcbiAgICAgICAgICAgICAgICBpZiAoaXNGaWVsZChmaWVsZCkgJiZcbiAgICAgICAgICAgICAgICAgICAgZmllbGQuZGlyZWN0aXZlcyAmJlxuICAgICAgICAgICAgICAgICAgICBmaWVsZC5kaXJlY3RpdmVzLnNvbWUoZnVuY3Rpb24gKGQpIHsgcmV0dXJuIGQubmFtZS52YWx1ZSA9PT0gJ2V4cG9ydCc7IH0pKSB7XG4gICAgICA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gZW50ZXI6IGZ1bmN0aW9uIChub2RlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF9fYXNzaWduKF9fYXNzaWduKHt9LCBub2RlKSwgeyB2YXJpYWJsZURlZmluaXRpb25zOiBub2RlLnZhcmlhYmxlRGVmaW5pdGlvbnMgPyBub2RlLnZhcmlhYmxlRGVmaW5pdGlvbnMuZmlsdGVyKGZ1bmN0aW9uICh2YXJEZWYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhY29uZmlnLnNvbWUoZnVuY3Rpb24gKGFyZykgeyByZXR1cm4gYXJnLm5hbWUgPT09IHZhckRlZi52YXJpYWJsZS5uYW1lLnZhbHVlOyB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSkgOiBbXSB9KTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICAgIEZpZWxkOiB7XG4gICAgICAgICAgICBlbnRlcjogZnVuY3Rpb24gKG5vZGUpIHtcbiAgICAgICAgICAgICAgICB2YXIgc2hvdWxkUmVtb3ZlRmllbGQgPSBjb25maWcuc29tZShmdW5jdGlvbiAoYXJnQ29uZmlnKSB7IHJldHVybiBhcmdDb25maWcucmVtb3ZlOyB9KTtcbiAgICAgICAgICAgICAgICBpZiAoc2hvdWxkUmVtb3ZlRmllbGQpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGFyZ01hdGNoQ291bnRfMSA9IDA7XG4gICAgICAgICAgICAgICAgICAgIGlmIChub2RlLmFyZ3VtZW50cykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZS5hcmd1bWVudHMuZm9yRWFjaChmdW5jdGlvbiAoYXJnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ01hdGNoZXIoYXJnKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdNYXRjaENvdW50XzEgKz0gMTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoYXJnTWF0Y2hDb3VudF8xID09PSAxKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICAgIEFyZ3VtZW50OiB7XG4gICAgICAgICAgICBlbnRlcjogZnVuY3Rpb24gKG5vZGUpIHtcbiAgICAgICAgICAgICAgICBpZiAoYXJnTWF0Y2hlcihub2RlKSkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgIH0pKTtcbn1cbmV4cG9ydCBmdW5jdGlvbiByZW1vdmVGcmFnbWVudFNwcmVhZEZyb21Eb2N1bWVudChjb25maWcsIGRvYykge1xuICAgIGZ1bmN0aW9uIGVudGVyKG5vZGUpIHtcbiAgICAgICAgaWYgKGNvbmZpZy5zb21lKGZ1bmN0aW9uIChkZWYpIHsgcmV0dXJuIGRlZi5uYW1lID09PSBub2RlLm5hbWUudmFsdWU7IH0pKSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gbnVsbElmRG9jSXNFbXB0eSh2aXNpdChkb2MsIHtcbiAgICAgICAgRnJhZ21lbnRTcHJlYWQ6IHsgZW50ZXI6IGVudGVyIH0sXG4gICAgICAgIEZyYWdtZW50RGVmaW5pdGlvbjogeyBlbnRlcjogZW50ZXIgfSxcbiAgICB9KSk7XG59XG5mdW5jdGlvbiBnZXRBbGxGcmFnbWVudFNwcmVhZHNGcm9tU2VsZWN0aW9uU2V0KHNlbGVjdGlvblNldCkge1xuICAgIHZhciBhbGxGcmFnbWVudHMgPSBbXTtcbiAgICBzZWxlY3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fX2Fzc2lnbihfX2Fzc2lnbih7fSwgbm9kZSksIHsgb3BlcmF0aW9uOiAncXVlcnknIH0pO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgfSxcbiAgICB9KTtcbiAgICByZXR1cm4gbW9kaWZpZWREb2M7XG59XG5leHBvcnQgZnVuY3Rpb24gcmVtb3ZlQ2xpZW50U2V0c0Zyb21Eb2N1bWVudChkb2N1bWVudCkge1xuICAgIGNoZWNrRG9jdW1lbnQoZG9jdW1lbnQpO1xuICAgIHZhciBtb2RpZmllZERvYyA9IHJlbW92ZURpcmVjdGl2ZXNGcm9tRG9jdW1lbnQoW1xuICAgICAgICB7XG4gICAgICAgICAgICB0ZXN0OiBmdW5jdGlvbiAoZGlyZWN0aXZlKSB7IHJldHVybiBkaXJlY3RpdmUubmFtZS52YWx1ZSA9PT0gJ2NsaWVudCc7IH0sXG4gICAgICAgICAgICByZW1vdmU6IHRydWUsXG4gICAgICAgIH0sXG4gICAgXSwgZG9jdW1lbnQpO1xuICAgIGlmIChtb2RpZmllZERvYykge1xuICAgICAgICBtb2RpZmllZERvYyA9IHZpc2l0KG1vZGlmaWVkRG9jLCB7XG4gICAgICAgICAgICBGcmFnbWVudERlZmluaXRpb246IHtcbiAgICAgICAgICAgICAgICBlbnRlcjogZnVuY3Rpb24gKG5vZGUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG5vZGUuc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaXNUeXBlbmFtZU9ubHkgPSBub2RlLnNlbGVjdGlvblNldC5zZWxlY3Rpb25zLmV2ZXJ5KGZ1bmN0aW9uIChzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNGaWVsZChzZWxlY3Rpb24pICYmIHNlbGVjdGlvbi5uYW1lLnZhbHVlID09PSAnX190eXBlbmFtZSc7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICA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biAgICAgICAgX3RoaXMucHJvbWlzZSA9IG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgICAgIF90aGlzLnJlc29sdmUgPSByZXNvbHZlO1xuICAgICAgICAgICAgX3RoaXMucmVqZWN0ID0gcmVqZWN0O1xuICAgICAgICB9KTtcbiAgICAgICAgX3RoaXMuaGFuZGxlcnMgPSB7XG4gICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAocmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgaWYgKF90aGlzLnN1YiAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5sYXRlc3QgPSBbXCJuZXh0XCIsIHJlc3VsdF07XG4gICAgICAgICAgICAgICAgICAgIGl0ZXJhdGVPYnNlcnZlcnNTYWZlbHkoX3RoaXMub2JzZXJ2ZXJzLCBcIm5leHRcIiwgcmVzdWx0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlcnJvcikge1xuICAgICAgICAgICAgICAgIGlmIChfdGhpcy5zdWIgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKF90aGlzLnN1YilcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5zdWIgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5sYXRlc3QgPSBbXCJlcnJvclwiLCBlcnJvcl07XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLnJlamVjdChlcnJvcik7XG4gICAgICAgICAgICAgICAgICAgIGl0ZXJhdGVPYnNlcnZlcnNTYWZlbHkoX3RoaXMub2JzZXJ2ZXJzLCBcImVycm9yXCIsIGVycm9yKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICBpZiAoX3RoaXMuc3ViICE9PSBudWxsKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB2YWx1ZSA9IF90aGlzLnNvdXJjZXMuc2hpZnQoKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuc3ViID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfdGhpcy5sYXRlc3QgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5sYXRlc3RbMF0gPT09IFwibmV4dFwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMucmVzb2x2ZShfdGhpcy5sYXRlc3RbMV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMucmVzb2x2ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZU9ic2VydmVyc1NhZmVseShfdGhpcy5vYnNlcnZlcnMsIFwiY29tcGxldGVcIik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiAoaXNQcm9taXNlTGlrZSh2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLnRoZW4oZnVuY3Rpb24gKG9icykgeyByZXR1cm4gX3RoaXMuc3ViID0gb2JzLnN1YnNjcmliZShfdGhpcy5oYW5kbGVycyk7IH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgX3RoaXMuc3ViID0gdmFsdWUuc3Vic2NyaWJlKF90aGlzLmhhbmRsZXJzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgIH07XG4gICAgICAgIF90aGlzLmNhbmNlbCA9IGZ1bmN0aW9uIChyZWFzb24pIHtcbiAgICAgICAgICAgIF90aGlzLnJlamVjdChyZWFzb24pO1xuICAgICAgICAgICAgX3RoaXMuc291cmNlcyA9IFtdO1xuICAgICAgICAgICAgX3RoaXMuaGFuZGxlcnMuY29tcGxldGUoKTtcbiAgICAgICAgfTtcbiAgICAgICAgX3RoaXMucHJvbWlzZS5jYXRjaChmdW5jdGlvbiAoXykgeyB9KTtcbiAgICAgICAgaWYgKGlzUHJvbWlzZUxpa2Uoc291cmNlcykpIHtcbiAgICAgICAgICAgIHNvdXJjZXMudGhlbihmdW5jdGlvbiAoaXRlcmFibGUpIHsgcmV0dXJuIF90aGlzLnN0YXJ0KGl0ZXJhYmxlKTsgfSwgX3RoaXMuaGFuZGxlcnMuZXJyb3IpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgX3RoaXMuc3RhcnQoc291cmNlcyk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIF90aGlzO1xuICAgIH1cbiAgICBDb25jYXN0LnByb3RvdHlwZS5zdGFydCA9IGZ1bmN0aW9uIChzb3VyY2VzKSB7XG4gICAgICAgIGlmICh0aGlzLnN1YiAhPT0gdm9pZCAwKVxuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB0aGlzLnNvdXJjZXMgPSBBcnJheS5mcm9tKHNvdXJjZXMpO1xuICAgICAgICB0aGlzLmhhbmRsZXJzLmNvbXBsZXRlKCk7XG4gICAgfTtcbiAgICBDb25jYXN0LnByb3RvdHlwZS5hZGRPYnNlcnZlciA9IGZ1bmN0aW9uIChvYnNlcnZlcikge1xuICAgICAgICBpZiAoIXRoaXMub2JzZXJ2ZXJzLmhhcyhvYnNlcnZlcikpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmxhdGVzdCkge1xuICAgICAgICAgICAgICAgIHZhciBuZXh0T3JFcnJvciA9IHRoaXMubGF0ZXN0WzBdO1xuICAgICAgICAgICAgICAgIHZhciBtZXRob2QgPSBvYnNlcnZlcltuZXh0T3JFcnJvcl07XG4gICAgICAgICAgICAgICAgaWYgKG1ldGhvZCkge1xuICAgICAgICAgICAgICAgICAgICBtZXRob2QuY2FsbChvYnNlcnZlciwgdGhpcy5sYXRlc3RbMV0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zdWIgPT09IG51bGwgJiZcbiAgICAgICAgICAgICAgICAgICAgbmV4dE9yRXJyb3IgPT09IFwibmV4dFwiICYmXG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmNvbXBsZXRlKSB7XG4gICAgICAgICAgICAgICAgICAgIG9ic2VydmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5vYnNlcnZlcnMuYWRkKG9ic2VydmVyKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgQ29uY2FzdC5wcm90b3R5cGUucmVtb3ZlT2JzZXJ2ZXIgPSBmdW5jdGlvbiAob2JzZXJ2ZXIsIHF1aWV0bHkpIHtcbiAgICAgICAgaWYgKHRoaXMub2JzZXJ2ZXJzLmRlbGV0ZShvYnNlcnZlcikgJiZcbiAgICAgICAgICAgIHRoaXMub2JzZXJ2ZXJzLnNpemUgPCAxKSB7XG4gICAgICAgICAgICBpZiAocXVpZXRseSlcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICBpZiAodGhpcy5zdWIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIHRoaXMucmVqZWN0KG5ldyBFcnJvcihcIk9ic2VydmFibGUgY2FuY2VsbGVkIHByZW1hdHVyZWx5XCIpKTtcbiAgICAg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IsIHJlc3VsdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29tcGxldGVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlci5jb21wbGV0ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLS1hY3RpdmVDYWxsYmFja0NvdW50O1xuICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3IgJiYgZXJyb3IuY2FsbChvYnNlcnZlciwgZSk7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKGFyZykgeyByZXR1cm4gZGVsZWdhdGUgJiYgZGVsZWdhdGUuY2FsbChvYnNlcnZlciwgYXJnKTsgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB2YXIgaGFuZGxlciA9IHtcbiAgICAgICAgICAgIG5leHQ6IG1ha2VDYWxsYmFjayhtYXBGbiwgbmV4dCksXG4gICAgICAgICAgICBlcnJvcjogbWFrZUNhbGxiYWNrKGNhdGNoRm4sIGVycm9yKSxcbiAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgY29tcGxldGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBpZiAoIWFjdGl2ZUNhbGxiYWNrQ291bnQpIHtcbiAgICAgICAgICAgICAgICAgICAgY29tcGxldGUgJiYgY29tcGxldGUuY2FsbChvYnNlcnZlcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgfTtcbiAgICAgICAgdmFyIHN1YiA9IG9ic2VydmFibGUuc3Vic2NyaWJlKGhhbmRsZXIpO1xuICAgICAgICByZXR1c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ywgaW5jb21pbmcpIDogaW5jb21pbmc7XG4gICAgICAgIH0sXG4gICAgfTtcbn1cbmV4cG9ydCBmdW5jdGlvbiBvZmZzZXRMaW1pdFBhZ2luYXRpb24oa2V5QXJncykge1xuICAgIGlmIChrZXlBcmdzID09PSB2b2lkIDApIHsga2V5QXJncyA9IGZhbHNlOyB9XG4gICAgcmV0dXJuIHtcbiAgICAgICAga2V5QXJnczoga2V5QXJncyxcbiAgICAgICAgbWVyZ2U6IGZ1bmN0aW9uIChleGlzdGluZywgaW5jb21pbmcsIF9hKSB7XG4gICAgICAgICAgICB2YXIgYXJncyA9IF9hLmFyZ3M7XG4gICAgICAgICAgICB2YXIgbWVyZ2VkID0gZXhpc3RpbmcgPyBleGlzdGluZy5zbGljZSgwKSA6IFtdO1xuICAgICAgICAgICAgaWYgKGFyZ3MpIHtcbiAgICAgICAgICAgICAgICB2YXIgX2IgPSBhcmdzLm9mZnNldCwgb2Zmc2V0ID0gX2IgPT09IHZvaWQgMCA/IDAgOiBfYjtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGluY29taW5nLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICAgICAgICAgIG1lcmdlZFtvZmZzZXQgKyBpXSA9IGluY29taW5nW2ldO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIG1lcmdlZC5wdXNoLmFwcGx5KG1lcmdlZCwgaW5jb21pbmcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIG1lcmdlZDtcbiAgICAgICAgfSxcbiAgICB9O1xufVxuZXhwb3J0IGZ1bmN0aW9uIHJlbGF5U3R5bGVQYWdpbmF0aW9uKGtleUFyZ3MpIHtcbiAgICBpZiAoa2V5QXJncyA9PT0gdm9pZCAwKSB7IGtleUFyZ3MgPSBmYWxzZTsgfVxuICAgIHJldHVybiB7XG4gICAgICAgIGtleUFyZ3M6IGtleUFyZ3MsXG4gICAgICAgIHJlYWQ6IGZ1bmN0aW9uIChleGlzdGluZywgX2EpIHtcbiAgICAgICAgICAgIHZhciBjYW5SZWFkID0gX2EuY2FuUmVhZCwgcmVhZEZpZWxkID0gX2EucmVhZEZpZWxkO1xuICAgICAgICAgICAgaWYgKCFleGlzdGluZylcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB2YXIgZWRnZXMgPSBbXTtcbiAgICAgICAgICAgIHZhciBzdGFydEN1cnNvciA9IFwiXCI7XG4gICAgICAgICAgICB2YXIgZW5kQ3Vyc29yID0gXCJcIjtcbiAgICAgICAgICAgIGV4aXN0aW5nLmVkZ2VzLmZvckVhY2goZnVuY3Rpb24gKGVkZ2UpIHtcbiAgICAgICAgICAgICAgICBpZiAoY2FuUmVhZChyZWFkRmllbGQoXCJub2RlXCIsIGVkZ2UpKSkge1xuICAgICAgICAgICAgICAgICAgICBlZGdlcy5wdXNoKGVkZ2UpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZWRnZS5jdXJzb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q3Vyc29yID0gc3RhcnRDdXJzb3IgfHwgZWRnZS5jdXJzb3I7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbmRDdXJzb3IgPSBlZGdlLmN1cnNvcjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmV0dXJuIF9fYXNzaWduKF9fYXNzaWduKHt9LCBnZXRFeHRyYXMoZXhpc3RpbmcpKSwgeyBlZGdlczogZWRnZXMsIHBhZ2VJbmZvOiBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgZXhpc3RpbmcucGFnZUluZm8pLCB7IHN0YXJ0Q3Vyc29yOiBzdGFydEN1cnNvcixcbiAgICAgICAgICAgICAgICAgICAgZW5kQ3Vyc29yOiBlbmRDdXJzb3IgfSkgfSk7XG4gICAgICAgIH0sXG4gICAgICAgIG1lcmdlOiBmdW5jdGlvbiAoZXhpc3RpbmcsIGluY29taW5nLCBfYSkge1xuICAgICAgICAgICAgaWYgKGV4aXN0aW5nID09PSB2b2lkIDApIHsgZXhpc3RpbmcgPSBtYWtlRW1wdHlEYXRhKCk7IH1cbiAgICAgICAgICAgIHZhciBhcmdzID0gX2EuYXJncywgaXNSZWZlcmVuY2UgPSBfYS5pc1JlZmVyZW5jZSwgcmVhZEZpZWxkID0gX2EucmVhZEZpZWxkO1xuICAgICAgICAgICAgdmFyIGluY29taW5nRWRnZXMgPSBpbmNvbWluZy5lZGdlcyA/IGluY29taW5nLmVkZ2VzLm1hcChmdW5jdGlvbiAoZWRnZSkge1xuICAgICAgICAgICAgICAgIGlmIChpc1JlZmVyZW5jZShlZGdlID0gX19hc3NpZ24oe30sIGVkZ2UpKSkge1xuICAgICAgICAgICAgICAgICAgICBlZGdlLmN1cnNvciA9IHJlYWRGaWVsZChcImN1cnNvclwiLCBlZGdlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGVkZ2U7XG4gICAgICAgICAgICB9KSA6IFtdO1xuICAgICAgICAgICAgaWYgKGluY29taW5nLnBhZ2VJbmZvKSB7XG4gICAgICAgICAgICAgICAgdmFyIHBhZ2VJbmZvXzEgPSBpbmNvbWluZy5wYWdlSW5mbztcbiAgICAgICAgICAgICAgICB2YXIgc3RhcnRDdXJzb3IgPSBwYWdlSW5mb18xLnN0YXJ0Q3Vyc29yLCBlbmRDdXJzb3IgPSBwYWdlSW5mb18xLmVuZEN1cnNvcjtcbiAgICAgICAgICAgICAgICB2YXIgZmlyc3RFZGdlID0gaW5jb21pbmdFZGdlc1swXTtcbiAgICAgICAgICAgICAgICB2YXIgbGFzdEVkZ2UgPSBpbmNvbWluZ0VkZ2VzW2luY29taW5nRWRnZXMubGVuZ3RoIC0gMV07XG4gICAgICAgICAgICAgICAgaWYgKGZpcnN0RWRnZSAmJiBzdGFydEN1cnNvcikge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdEVkZ2UuY3Vyc29yID0gc3RhcnRDdXJzb3I7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChsYXN0RWRnZSAmJiBlbmRDdXJzb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgbGFzdEVkZ2UuY3Vyc29yID0gZW5kQ3Vyc29yO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YXIgZmlyc3RDdXJzb3IgPSBmaXJzdEVkZ2UgJiYgZmlyc3RFZGdlLmN1cnNvcjtcbiAgICAgICAgICAgICAgICBpZiAoZmlyc3RDdXJzb3IgJiYgIXN0YXJ0Q3Vyc29yKSB7XG4gICAgICAgICAgICAgICAgICAgIGluY29taW5nID0gbWVyZ2VEZWVwKGluY29taW5nLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5mbzoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q3Vyc29yOiBmaXJzdEN1cnNvcixcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YXIgbGFzdEN1cnNvciA9IGxhc3RFZGdlICYmIGxhc3RFZGdlLmN1cnNvcjtcbiAgICAgICAgICAgICAgICBpZiAobGFzdEN1cnNvciAmJiAhZW5kQ3Vyc29yKSB7XG4gICAgICAgICAgICAgICAgICAgIGluY29taW5nID0gbWVyZ2VEZWVwKGluY29taW5nLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5mbzoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZEN1cnNvcjogbGFzdEN1cnNvcixcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBwcmVmaXggPSBleGlzdGluZy5lZGdlcztcbiAgICAgICAgICAgIHZhciBzdWZmaXggPSBbXTtcbiAgICAgICAgICAgIGlmIChhcmdzICYmIGFyZ3MuYWZ0ZXIpIHtcbiAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBwcmVmaXguZmluZEluZGV4KGZ1bmN0aW9uIChlZGdlKSB7IHJldHVybiBlZGdlLmN1cnNvciA9PT0gYXJncy5hZnRlcjsgfSk7XG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID49IDApIHtcbiAgICAgICAgICAgICAgICAgICAgcHJlZml4ID0gcHJlZml4LnNsaWNlKDAsIGluZGV4ICsgMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAoYXJncyAmJiBhcmdzLmJlZm9yZSkge1xuICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IHByZWZpeC5maW5kSW5kZXgoZnVuY3Rpb24gKGVkZ2UpIHsgcmV0dXJuIGVkZ2UuY3Vyc29yID09PSBhcmdzLmJlZm9yZTsgfSk7XG4gICAgICAgICAgICAgICAgc3VmZml4ID0gaW5kZXggPCAwID8gcHJlZml4IDogcHJlZml4LnNsaWNlKGluZGV4KTtcbiAgICAgICAgICAgICAgICBwcmVmaXggPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKGluY29taW5nLmVkZ2VzKSB7XG4gICAgICAgICAgICAgICAgcHJlZml4ID0gW107XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgZWRnZXMgPSBfX3NwcmVhZEFycmF5cyhwcmVmaXgsIGluY29taW5nRWRnZXMsIHN1ZmZpeCk7XG4gICAgICAgICAgICB2YXIgcGFnZUluZm8gPSBfX2Fzc2lnbihfX2Fzc2lnbih7fSwgaW5jb21pbmcucGFnZUluZm8pLCBleGlzdGluZy5wYWdlSW5mbyk7XG4gICAgICAgICAgICBpZiAoaW5jb21pbmcucGFnZUluZm8pIHtcbiAgICAgICAgICAgICAgICB2YXIgX2IgPSBpbmNvbWluZy5wYWdlSW5mbywgaGFzUHJldmlvdXNQYWdlID0gX2IuaGFzUHJldmlvdXNQYWdlLCBoYXNOZXh0UGFnZSA9IF9iLmhhc05leHRQYWdlLCBzdGFydEN1cnNvciA9IF9iLnN0YXJ0Q3Vyc29yLCBlbmRDdXJzb3IgPSBfYi5lbmRDdXJzb3I7XG4gICAgICAgICAgICAgICAgaWYgKCFwcmVmaXgubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh2b2lkIDAgIT09IGhhc1ByZXZpb3VzUGFnZSlcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmZvLmhhc1ByZXZpb3VzUGFnZSA9IGhhc1ByZXZpb3VzUGFnZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZvaWQgMCAhPT0gc3RhcnRDdXJzb3IpXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5mby5zdGFydEN1cnNvciA9IHN0YXJ0Q3Vyc29yO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoIXN1ZmZpeC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHZvaWQgMCAhPT0gaGFzTmV4dFBhZ2UpXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5mby5oYXNOZXh0UGFnZSA9IGhhc05leHRQYWdlO1xuICAgICAgICAgICAgICAgICAgICBpZiAodm9pZCAwICE9PSBlbmRDdXJzb3IpXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5mby5lbmRDdXJzb3IgPSBlbmRDdXJzb3I7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIF9fYXNzaWduKF9fYXNzaWduKF9fYXNzaWduKHt9LCBnZXRFeHRyYXMoZXhpc3RpbmcpKSwgZ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yXG4gICAgICAgIHZhciBjb250ZXh0ID0gY3VycmVudENvbnRleHQ7XHJcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcclxuICAgICAgICAgICAgdmFyIHNhdmVkID0gY3VycmVudENvbnRleHQ7XHJcbiAgICAgICAgICAgIHRyeSB7XHJcbiAgICAgICAgICAgICAgICBjdXJyZW50Q29udGV4dCA9IGNvbnRleHQ7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gY2FsbGJhY2suYXBwbHkodGhpcywgYXJndW1lbnRzKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBmaW5hbGx5IHtcclxuICAgICAgICAgICAgICAgIGN1cnJlbnRDb250ZXh0ID0gc2F2ZWQ7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9O1xyXG4gICAgfTtcclxuICAgIC8vIEltbWVkaWF0ZWx5IHJ1biBhIGNhbGxiYWNrIGZ1bmN0aW9uIHdpdGhvdXQgYW55IGNhcHR1cmVkIGNvbnRleHQuXHJcbiAgICBTbG90Lm5vQ29udGV4dCA9IGZ1bmN0aW9uIChjYWxsYmFjaywgXHJcbiAgICAvLyBHaXZlbiB0aGUgcHJldmFsZW5jZSBvZiBhcnJvdyBmdW5jdGlvbnMsIHNwZWNpZnlpbmcgYXJndW1lbnRzIGlzIGxpa2VseVxyXG4gICAgLy8gdG8gYmUgbXVjaCBtb3JlIGNvbW1vbiB0aGFuIHNwZWNpZnlpbmcgYHRoaXNgLCBoZW5jZSB0aGlzIG9yZGVyaW5nOlxyXG4gICAgYXJncywgdGhpc0FyZykge1xyXG4gICAgICAgIGlmIChjdXJyZW50Q29udGV4dCkge1xyXG4gICAgICAgICAgICB2YXIgc2F2ZWQgPSBjdXJyZW50Q29udGV4dDtcclxuICAgICAgICAgICAgdHJ5IHtcclxuICAgICAgICAgICAgICAgIGN1cnJlbnRDb250ZXh0ID0gbnVsbDtcclxuICAgICAgICAgICAgICAgIC8vIEZ1bmN0aW9uLnByb3R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24gaW50byBhbiBhc3luYyBmdW5jdGlvbiAodXNpbmcgeWllbGQgaW5zdGVhZFxyXG4vLyBvZiBhd2FpdCksIHdpdGggY29udGV4dCBhdXRvbWF0aWNhbGx5IHByZXNlcnZlZCBhY3Jvc3MgeWllbGRzLlxyXG5mdW5jdGlvbiBhc3luY0Zyb21HZW4oZ2VuRm4pIHtcclxuICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgdmFyIGdlbiA9IGdlbkZuLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XHJcbiAgICAgICAgdmFyIGJvdW5kTmV4dCA9IGJpbmQoZ2VuLm5leHQpO1xyXG4gICAgICAgIHZhciBib3VuZFRocm93ID0gYmluZChnZW4udGhyb3cpO1xyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7XHJcbiAgICAgICAgICAgIGZ1bmN0aW9uIGludm9rZShtZXRob2QsIGFyZ3VtZW50KSB7XHJcbiAgICAgICAgICAgICAgICB0cnkge1xyXG4gICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBtZXRob2QuY2FsbChnZW4sIGFyZ3VtZW50KTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnJvcikge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiByZWplY3QoZXJyb3IpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgdmFyIG5leHQgPSByZXN1bHQuZG9uZSA/IHJlc29sdmUgOiBpbnZva2VOZXh0O1xyXG4gICAgICAgICAgICAgICAgaWYgKGlzUHJvbWlzZUxpa2UocmVzdWx0LnZhbHVlKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdC52YWx1ZS50aGVuKG5leHQsIHJlc3VsdC5kb25lID8gcmVqZWN0IDogaW52b2tlVGhyb3cpO1xyXG4gICAgICAgICAgIC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JhYmxlIGtleXMsIHRoZXlcclxuICAgICAgICAgICAgLy8gbXVzdCBiZSBkaWZmZXJlbnQuXHJcbiAgICAgICAgICAgIHZhciBrZXlDb3VudCA9IGFLZXlzLmxlbmd0aDtcclxuICAgICAgICAgICAgaWYgKGtleUNvdW50ICE9PSBiS2V5cy5sZW5ndGgpXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIC8vIE5vdyBtYWtlIHN1cmUgdGhleSBoYXZlIHRoZSBzYW1lIGtleXMuXHJcbiAgICAgICAgICAgIGZvciAodmFyIGsgPSAwOyBrIDwga2V5Q291bnQ7ICsraykge1xyXG4gICAgICAgICAgICAgICAgaWYgKCFoYXNPd25Qcm9wZXJ0eS5jYWxsKGIsIGFLZXlzW2tdKSkge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAvLyBGaW5hbGx5LCBjaGVjayBkZWVwIGVxdWFsaXR5IG9mIGFsbCBjaGlsZCBwcm9wZXJ0aWVzLlxyXG4gICAgICAgICAgICBmb3IgKHZhciBrID0gMDsgayA8IGtleUNvdW50OyArK2spIHtcclxuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBhS2V5c1trXTtcclxuICAgICAgICAgICAgICAgIGlmICghY2hlY2soYVtrZXldLCBiW2tleV0pKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICAgIH1cclxuICAgICAgICBjYXNlICdbb2JqZWN0IEVycm9yXSc6XHJcbiAgICAgICAgICAgIHJldHVybiBhLm5hbWUgPT09IGIubmFtZSAmJiBhLm1lc3NhZ2UgPT09IGIubWVzc2FnZTtcclxuICAgICAgICBjYXNlICdbb2JqZWN0IE51bWJlcl0nOlxyXG4gICAgICAgICAgICAvLyBIYW5kbGUgTmFOLCB3aGljaCBpcyAhPT0gaXRzZWxmLlxyXG4gICAgICAgICAgICBpZiAoYSAhPT0gYSlcclxuICAgICAgICAgICAgICAgIHJldHVybiBiICE9PSBiO1xyXG4gICAgICAgIC8vIEZhbGwgdGhyb3VnaCB0byBzaGFyZWQgK2EgPT09ICtiIGNhc2UuLi5cclxuICAgICAgICBjYXNlICdbb2JqZWN0IEJvb2xlYW5dJzpcclxuICAgICAgICBjYXNlICdbb2JqZWN0IERhdGVdJzpcclxuICAgICAgICAgICAgcmV0dXJuICthID09PSArYjtcclxuICAgICAgICBjYXNlICdbb2JqZWN0IFJlZ0V4cF0nOlxyXG4gICAgICAgIGNhc2UgJ1tvYmplY3QgU3RyaW5nXSc6XHJcbiAgICAgICAgICAgIHJldHVybiBhID09IFwiXCIgKyBiO1xyXG4gICAgICAgIGNhc2UgJ1tvYmplY3QgTWFwXSc6XHJcbiAgICAgICAgY2FzZSAnW29iamVjdCBTZXRdJzoge1xyXG4gICAgICAgICAgICBpZiAoYS5zaXplICE9PSBiLnNpemUpXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIGlmIChwcmV2aW91c2x5Q29tcGFyZWQoYSwgYikpXHJcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcclxuICAgICAgICAgICAgdmFyIGFJdGVyYXRvciA9IGEuZW50cmllcygpO1xyXG4gICAgICAgICAgICB2YXIgaXNNYXAgPSBhVGFnID09PSAnW29iamVjdCBNYXBdJztcclxuICAgICAgICAgICAgd2hpbGUgKHRydWUpIHtcclxuICAgICAgICAgICAgICAgIHZhciBpbmZvID0gYUl0ZXJhdG9yLm5leHQoKTtcclxuICAgICAgICAgICAgICAgIGlmIChpbmZvLmRvbmUpXHJcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgICAgICAvLyBJZiBhIGluc3RhbmNlb2YgU2V0LCBhVmFsdWUgPT09IGFLZXkuXHJcbiAgICAgICAgICAgICAgICB2YXIgX2EgPSBpbmZvLnZhbHVlLCBhS2V5ID0gX2FbMF0sIGFWYWx1ZSA9IF9hWzFdO1xyXG4gICAgICAgICAgICAgICAgLy8gU28gdGhpcyB3b3JrcyB0aGUgc2FtZSB3YXkgZm9yIGJvdGggU2V0IGFuZCBNYXAuXHJcbiAgICAgICAgICAgICAgICBpZiAoIWIuaGFzKGFLZXkpKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgLy8gSG93ZXZlciwgd2UgY2FyZSBhYm91dCBkZWVwIGVxdWFsaXR5IG9mIHZhbHVlcyBvbmx5IHdoZW4gZGVhbGluZ1xyXG4gICAgICAgICAgICAgICAgLy8gd2l0aCBNYXAgc3RydWN0dXJlcy5cclxuICAgICAgICAgICAgICAgIGlmIChpc01hcCAmJiAhY2hlY2soYVZhbHVlLCBiLmdldChhS2V5KSkpIHtcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGNhc2UgJ1tvYmplY3QgRnVuY3Rpb25dJzoge1xyXG4gICAgICAgICAgICB2YXIgYUNvZGUgPSBmblRvU3RyLmNhbGwoYSk7XHJcbiAgICAgICAgICAgIGlmIChhQ29kZSAhPT0gZm5Ub1N0ci5jYWxsKGIpKSB7XHJcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgLy8gV2UgY29uc2lkZXIgbm9uLW5hdGl2ZSBmdW5jdGlvbnMgZXF1YWwgaWYgdGhleSBoYXZlIHRoZSBzYW1lIGNvZGVc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ICBpZiAodHlwZW9mIG5vZGUgPT0gJ251bWJlcicpIHJldHVybiBpc0Zpbml0ZShub2RlKSA/ICcnICsgbm9kZSA6ICdudWxsJztcbiAgICAgICAgaWYgKHR5cGVvZiBub2RlICE9PSAnb2JqZWN0JykgcmV0dXJuIEpTT04uc3RyaW5naWZ5KG5vZGUpO1xuXG4gICAgICAgIHZhciBpLCBvdXQ7XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KG5vZGUpKSB7XG4gICAgICAgICAgICBvdXQgPSAnWyc7XG4gICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbm9kZS5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGlmIChpKSBvdXQgKz0gJywnO1xuICAgICAgICAgICAgICAgIG91dCArPSBzdHJpbmdpZnkobm9kZVtpXSkgfHwgJ251bGwnO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIG91dCArICddJztcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChub2RlID09PSBudWxsKSByZXR1cm4gJ251bGwnO1xuXG4gICAgICAgIGlmIChzZWVuLmluZGV4T2Yobm9kZSkgIT09IC0xKSB7XG4gICAgICAgICAgICBpZiAoY3ljbGVzKSByZXR1cm4gSlNPTi5zdHJpbmdpZnkoJ19fY3ljbGVfXycpO1xuICAgICAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignQ29udmVydGluZyBjaXJjdWxhciBzdHJ1Y3R1cmUgdG8gSlNPTicpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIHNlZW5JbmRleCA9IHNlZW4ucHVzaChub2RlKSAtIDE7XG4gICAgICAgIHZhciBrZXlzID0gT2JqZWN0LmtleXMobm9kZSkuc29ydChjbXAgJiYgY21wKG5vZGUpKTtcbiAgICAgICAgb3V0ID0gJyc7XG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBrZXlzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICB2YXIga2V5ID0ga2V5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29sbGVjdCBhbnkgZnJhZ21lbnQvdHlwZSByZWZlcmVuY2VzIGZyb20gYSBub2RlLCBhZGRpbmcgdGhlbSB0byB0aGUgcmVmcyBTZXRcbiAgICBmdW5jdGlvbiBjb2xsZWN0RnJhZ21lbnRSZWZlcmVuY2VzKG5vZGUsIHJlZnMpIHtcbiAgICAgIGlmIChub2RlLmtpbmQgPT09IFwiRnJhZ21lbnRTcHJlYWRcIikge1xuICAgICAgICByZWZzLmFkZChub2RlLm5hbWUudmFsdWUpO1xuICAgICAgfSBlbHNlIGlmIChub2RlLmtpbmQgPT09IFwiVmFyaWFibGVEZWZpbml0aW9uXCIpIHtcbiAgICAgICAgdmFyIHR5cGUgPSBub2RlLnR5cGU7XG4gICAgICAgIGlmICh0eXBlLmtpbmQgPT09IFwiTmFtZWRUeXBlXCIpIHtcbiAgICAgICAgICByZWZzLmFkZCh0eXBlLm5hbWUudmFsdWUpO1xuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIGlmIChub2RlLnNlbGVjdGlvblNldCkge1xuICAgICAgICBub2RlLnNlbGVjdGlvblNldC5zZWxlY3Rpb25zLmZvckVhY2goZnVuY3Rpb24oc2VsZWN0aW9uKSB7XG4gICAgICAgICAgY29sbGVjdEZyYWdtZW50UmVmZXJlbmNlcyhzZWxlY3Rpb24sIHJlZnMpO1xuICAgICAgICB9KTtcbiAgICAgIH1cblxuICAgICAgaWYgKG5vZGUudmFyaWFibGVEZWZpbml0aW9ucykge1xuICAgICAgICBub2RlLnZhcmlhYmxlRGVmaW5pdGlvbnMuZm9yRWFjaChmdW5jdGlvbihkZWYpIHtcbiAgICAgICAgICBjb2xsZWN0RnJhZ21lbnRSZWZlcmVuY2VzKGRlZiwgcmVmcyk7XG4gICAgICAgIH0pO1xuICAgICAgfVxuXG4gICAgICBpZiAobm9kZS5kZWZpbml0aW9ucykge1xuICAgICAgICBub2RlLmRlZmluaXRpb25zLmZvckVhY2goZnVuY3Rpb24oZGVmKSB7XG4gICAgICAg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2LmVuZDtcblxuICB3aGlsZSAocG9zIDwgYm9keUxlbmd0aCkge1xuICAgIHZhciBjb2RlID0gYm9keS5jaGFyQ29kZUF0KHBvcyk7XG4gICAgdmFyIF9saW5lID0gbGV4ZXIubGluZTtcblxuICAgIHZhciBfY29sID0gMSArIHBvcyAtIGxleGVyLmxpbmVTdGFydDsgLy8gU291cmNlQ2hhcmFjdGVyXG5cblxuICAgIHN3aXRjaCAoY29kZSkge1xuICAgICAgY2FzZSAweGZlZmY6IC8vIDxCT00+XG5cbiAgICAgIGNhc2UgOTogLy8gICBcXHRcblxuICAgICAgY2FzZSAzMjogLy8gIDxzcGFjZT5cblxuICAgICAgY2FzZSA0NDpcbiAgICAgICAgLy8gICxcbiAgICAgICAgKytwb3M7XG4gICAgICAgIGNvbnRpbnVlO1xuXG4gICAgICBjYXNlIDEwOlxuICAgICAgICAvLyAgXFxuXG4gICAgICAgICsrcG9zO1xuICAgICAgICArK2xleGVyLmxpbmU7XG4gICAgICAgIGxleGVyLmxpbmVTdGFydCA9IHBvcztcbiAgICAgICAgY29udGludWU7XG5cbiAgICAgIGNhc2UgMTM6XG4gICAgICAgIC8vICBcXHJcbiAgICAgICAgaWYgKGJvZHkuY2hhckNvZGVBdChwb3MgKyAxKSA9PT0gMTApIHtcbiAgICAgICAgICBwb3MgKz0gMjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICArK3BvcztcbiAgICAgICAgfVxuXG4gICAgICAgICsrbGV4ZXIubGluZTtcbiAgICAgICAgbGV4ZXIubGluZVN0YXJ0ID0gcG9zO1xuICAgICAgICBjb250aW51ZTtcblxuICAgICAgY2FzZSAzMzpcbiAgICAgICAgLy8gICFcbiAgICAgICAgcmV0dXJuIG5ldyBfYXN0LlRva2VuKF90b2tlbktpbmQuVG9rZW5LaW5kLkJBTkcsIHBvcywgcG9zICsgMSwgX2xpbmUsIF9jb2wsIHByZXYpO1xuXG4gICAgICBjYXNlIDM1OlxuICAgICAgICAvLyAgI1xuICA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5Ub2tlbktpbmQuTkFNRTpcbiAgICAgICAgdGhpcy5fbGV4ZXIuYWR2YW5jZSgpO1xuXG4gICAgICAgIHN3aXRjaCAodG9rZW4udmFsdWUpIHtcbiAgICAgICAgICBjYXNlICd0cnVlJzpcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgIGtpbmQ6IF9raW5kcy5LaW5kLkJPT0xFQU4sXG4gICAgICAgICAgICAgIHZhbHVlOiB0cnVlLFxuICAgICAgICAgICAgICBsb2M6IHRoaXMubG9jKHRva2VuKVxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgIGNhc2UgJ2ZhbHNlJzpcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgIGtpbmQ6IF9raW5kcy5LaW5kLkJPT0xFQU4sXG4gICAgICAgICAgICAgIHZhbHVlOiBmYWxzZSxcbiAgICAgICAgICAgICAgbG9jOiB0aGlzLmxvYyh0b2tlbilcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICBjYXNlICdudWxsJzpcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgIGtpbmQ6IF9raW5kcy5LaW5kLk5VTEwsXG4gICAgICAgICAgICAgIGxvYzogdGhpcy5sb2ModG9rZW4pXG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgIGtpbmQ6IF9raW5kcy5LaW5kLkVOVU0sXG4gICAgICAgICAgICAgIHZhbHVlOiB0b2tlbi52YWx1ZSxcbiAgICAgICAgICAgICAgbG9jOiB0aGlzLmxvYyh0b2tlbilcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgY2FzZSBfdG9rZW5LaW5kLlRva2VuS2luZC5ET0xMQVI6XG4gICAgICAgIGlmICghaXNDb25zdCkge1xuICAgICAgICAgIHJldHVybiB0aGlzLnBhcnNlVmFyaWFibGUoKTtcbiAgICAgICAgfVxuX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KlxuICogMykgR2VuZXJpYyB2aXNpdG9ycyB0aGF0IHRyaWdnZXIgdXBvbiBlbnRlcmluZyBhbmQgbGVhdmluZyBhbnkgbm9kZS5cbiAqXG4gKiAgICAgdmlzaXQoYXN0LCB7XG4gKiAgICAgICBlbnRlcihub2RlKSB7XG4gKiAgICAgICAgIC8vIGVudGVyIGFueSBub2RlXG4gKiAgICAgICB9LFxuICogICAgICAgbGVhdmUobm9kZSkge1xuICogICAgICAgICAvLyBsZWF2ZSBhbnkgbm9kZVxuICogICAgICAgfVxuICogICAgIH0pXG4gKlxuICogNCkgUGFyYWxsZWwgdmlzaXRvcnMgZm9yIGVudGVyaW5nIGFuZCBsZWF2aW5nIG5vZGVzIG9mIGEgc3BlY2lmaWMga2luZC5cbiAqXG4gKiAgICAgdmlzaXQoYXN0LCB7XG4gKiAgICAgICBlbnRlcjoge1xuICogICAgICAgICBLaW5kKG5vZGUpIHtcbiAqICAgICAgICAgICAvLyBlbnRlciB0aGUgXCJLaW5kXCIgbm9kZVxuICogICAgICAgICB9XG4gKiAgICAgICB9LFxuICogICAgICAgbGVhdmU6IHtcbiAqICAgICAgICAgS2luZChub2RlKSB7XG4gKiAgICAgICAgICAgLy8gbGVhdmUgdGhlIFwiS2luZFwiIG5vZGVcbiAqICAgICAgICAgfVxuICogICAgICAgfVxuICogICAgIH0pXG4gKi9cblxuZXhwb3J0IGZ1bmN0aW9uIHZpc2l0KHJvb3QsIHZpc2l0b3IpIHtcbiAgdmFyIHZpc2l0b3JLZXlzID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBRdWVyeURvY3VtZW50S2V5cztcblxuICAvKiBlc2xpbnQtZGlzYWJsZSBuby11bmRlZi1pbml0ICovXG4gIHZhciBzdGFjayA9IHVuZGVmaW5lZDtcbiAgdmFyIGluQXJyYXkgPSBBcnJheS5pc0FycmF5KHJvb3QpO1xuICB2Y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Ckge1xuICAgICAgICBwYXRoLnB1c2goa2V5KTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICB2YXIgcmVzdWx0ID0gdm9pZCAwO1xuXG4gICAgaWYgKCFBcnJheS5pc0FycmF5KG5vZGUpKSB7XG4gICAgICBpZiAoIWlzTm9kZShub2RlKSkge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXCJJbnZhbGlkIEFTVCBOb2RlOiBcIi5jb25jYXQoaW5zcGVjdChub2RlKSwgXCIuXCIpKTtcbiAgICAgIH1cblxuICAgICAgdmFyIHZpc2l0Rm4gPSBnZXRWaXNpdEZuKHZpc2l0b3IsIG5vZGUua2luZCwgaXNMZWF2aW5nKTtcblxuICAgICAgaWYgKHZpc2l0Rm4pIHtcbiAgICAgICAgcmVzdWx0ID0gdmlzaXRGbi5jYWxsKHZpc2l0b3IsIG5vZGUsIGtleSwgcGFyZW50LCBwYXRoLCBhbmNlc3RvcnMpO1xuXG4gICAgICAgIGlmIChyZXN1bHQgPT09IEJSRUFLKSB7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAocmVzdWx0ID09PSBmYWxzZSkge1xuICAgICAgICAgIGlmICghaXNMZWF2aW5nKSB7XG4gICAgICAgICAgICBwYXRoLnBvcCgpO1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHJlc3VsdCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgZWRpdHMucHVzaChba2V5LCByZXN1bHRdKTtcblxuICAgICAgICAgIGlmICghaXNMZWF2aW5nKSB7XG4gICAgICAgICAgICBpZiAoaXNOb2RlKHJlc3VsdCkpIHtcbiAgICAgICAgICAgICAgbm9kZSA9IHJlc3VsdDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBhdGgucG9wKCk7XG4gICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cblxuICAgIGlmIChyZXN1bHQgPT09IHVuZGVmaW5lZCAmJiBpc0VkaXRlZCkge1xuICAgICAgZWRpdHMucHVzaChba2V5LCBub2RlXSk7XG4gICAgfVxuXG4gICAgaWYgKGlzTGVhdmluZykge1xuICAgICAgcGF0aC5wb3AoKTtcbiAgICB9IGVsc2Uge1xuICAgICAgdmFyIF92aXNpdG9yS2V5cyRub2RlJGtpbjtcblxuICAgICAgc3RhY2sgPSB7XG4gICAgICAgIGluQXJyYXk6IGluQXJyYXksXG4gICAgICAgIGluZGV4OiBpbmRleCxcbiAgICAgICAga2V5czoga2V5cyxcbiAgICAgICAgZWRpdHM6IGVkaXRzLFxuICAgICAgICBwcmV2OiBzdGFja1xuICAgICAgfTtcbiAgICAgIGluQXJyYXkgPSBBcnJheS5pc0FycmF5KG5vZGUpO1xuICAgICAga2V5cyA9IGluQXJyYXkgPyBub2RlIDogKF92aXNpdG9yS2V5cyRub2RlJGtpbiA9IHZpc2l0b3JLZXlzW25vZGUua2luZF0pICE9PSBudWxsICYmIF92aXNpdG9yS2V5cyRub2RlJGtpbiAhPT0gdm9pZCAwID8gX3Zpc2l0b3JLZXlzJG5vZGUka2luIDogW107XG4gICAgICBpbmRleCA9IC0xO1xuICAgICAgZWRpdHMgPSBbXTtcblxuICAgICAgaWYgKHBhcmVudCkge1xuICAgICAgICBhbmNlc3RvcnMucHVzaChwYXJlbnQpO1xuICAgICAgfVxuXG4gICAgICBwYXJlbnQgPSBub2RlO1xuICAgIH1cbiAgfSB3aGlsZSAoc3RhY2sgIT09IHVuZGVmaW5lZCk7XG5cbiAgaWYgKGVkaXRzLmxlbmd0aCAhPT0gMCkge1xuICAgIG5ld1Jvb3QgPSBlZGl0c1tlZGl0cy5sZW5ndGggLSAxXVsxXTtcbiAgfVxuXG4gIHJldHVybiBuZXdSb290O1xufVxuLyoqXG4gKiBDcmVhdGVzIGEgbmV3IHZpc2l0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ZXN0O1xyXG4gICAgICAgICAgICBlbnRyeS5vbGRlci5uZXdlciA9IGVudHJ5O1xyXG4gICAgICAgICAgICBlbnRyeS5uZXdlciA9IG51bGw7XHJcbiAgICAgICAgICAgIHRoaXMubmV3ZXN0ID0gZW50cnk7XHJcbiAgICAgICAgICAgIGlmIChlbnRyeSA9PT0gdGhpcy5vbGRlc3QpIHtcclxuICAgICAgICAgICAgICAgIHRoaXMub2xkZXN0ID0gbmV3ZXI7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIGVudHJ5O1xyXG4gICAgfTtcclxuICAgIENhY2hlLnByb3RvdHlwZS5zZXQgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkge1xyXG4gICAgICAgIHZhciBlbnRyeSA9IHRoaXMuZ2V0RW50cnkoa2V5KTtcclxuICAgICAgICBpZiAoZW50cnkpIHtcclxuICAgICAgICAgICAgcmV0dXJuIGVudHJ5LnZhbHVlID0gdmFsdWU7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGVudHJ5ID0ge1xyXG4gICAgICAgICAgICBrZXk6IGtleSxcclxuICAgICAgICAgICAgdmFsdWU6IHZhbHVlLFxyXG4gICAgICAgICAgICBuZXdlcjogbnVsbCxcclxuICAgICAgICAgICAgb2xkZXI6IHRoaXMubmV3ZXN0XHJcbiAgICAgICAgfTtcclxuICAgICAgICBpZiAodGhpcy5uZXdlc3QpIHtcclxuICAgICAgICAgICAgdGhpcy5uZXdlc3QubmV3ZXIgPSBlbnRyeTtcclxuICAgICAgICB9XHJcbiAgICAgICAgdGhpcy5uZXdlc3QgPSBlbnRyeTtcclxuICAgICAgICB0aGlzLm9sZGVzdCA9IHRoaXMub2xkZXN0IHx8IGVudHJ5O1xyXG4gICAgICAgIHRoaXMubWFwLnNldChrZXksIGVudHJ5KTtcclxuICAgICAgICByZXR1cm4gZW50cnkudmFsdWU7XHJcbiAgICB9O1xyXG4gICAgQ2FjaGUucHJvdG90eXBlLmNsZWFuID0gZnVuY3Rpb24gKCkge1xyXG4gICAgICAgIHdoaWxlICh0aGlzLm9sZGVzdCAmJiB0aGlzLm1hcC5zaXplID4gdGhpcy5tYXgpIHtcclxuICAgICAgICAgICAgdGhpcy5kZWxldGUodGhpcy5vbGRlc3Qua2V5KTtcclxuICAgICAgICB9XHJcbiAgICB9O1xyXG4gICAgQ2FjaGUucHJvdG90eXBlLmRlbGV0ZSA9IGZ1bmN0aW9uIChrZXkpIHtcclxuICAgICAgICB2YXIgZW50cnkgPSB0aGlzLm1hcC5nZXQoa2V5KTtcclxuICAgICAgICBpZiAoZW50cnkpIHtcclxuICAgICAgICAgICAgaWYgKGVudHJ5ID09PSB0aGlzLm5ld2VzdCkge1xyXG4gICAgICAgICAgICAgICAgdGhpcy5uZXdlc3QgPSBlbnRyeS5vbGRlcjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoZW50cnkgPT09IHRoaXMub2xkZXN0KSB7XHJcbiAgICAgICAgICAgICAgICB0aGlzLm9sZGVzdCA9IGVudHJ5Lm5ld2VyO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIGlmIChlbnRyeS5uZXdlcikge1xyXG4gICAgICAgICAgICAgICAgZW50cnkubmV3ZXIub2xkZXIgPSBlbnRyeS5vbGRlcjtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBpZiAoZW50cnkub2xkZXIpIHtcclxuICAgICAgICAgICAgICAgIGVudHJ5Lm9sZGVyLm5ld2VyID0gZW50cnkubmV3ZXI7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgdGhpcy5tYXAuZGVsZXRlKGtleSk7XHJcbiAgICAgICAgICAgIHRoaXMuZGlzcG9zZShlbnRyeS52YWx1ZSwga2V5KTtcclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBmYWxzZTtcclxuICAgIH07XHJcbiAgICByZXR1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lxyXG4gICAgICAgICAgICBpZiAodmFsdWUgPT09IG51bGwpXHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICAvLyBGYWxsIHRocm91Z2ggdG8gcmV0dXJuIHRydWUuLi5cclxuICAgICAgICBjYXNlIFwiZnVuY3Rpb25cIjpcclxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XHJcbiAgICB9XHJcbiAgICByZXR1cm4gZmFsc2U7XHJcbn1cblxuZnVuY3Rpb24gZGVwKG9wdGlvbnMpIHtcclxuICAgIHZhciBkZXBzQnlLZXkgPSBuZXcgTWFwKCk7XHJcbiAgICB2YXIgc3Vic2NyaWJlID0gb3B0aW9ucyAmJiBvcHRpb25zLnN1YnNjcmliZTtcclxuICAgIGZ1bmN0aW9uIGRlcGVuZChrZXkpIHtcclxuICAgICAgICB2YXIgcGFyZW50ID0gcGFyZW50RW50cnlTbG90LmdldFZhbHVlKCk7XHJcbiAgICAgICAgaWYgKHBhcmVudCkge1xyXG4gICAgICAgICAgICB2YXIgZGVwXzEgPSBkZXBzQnlLZXkuZ2V0KGtleSk7XHJcbiAgICAgICAgICAgIGlmICghZGVwXzEpIHtcclxuICAgICAgICAgICAgICAgIGRlcHNCeUtleS5zZXQoa2V5LCBkZXBfMSA9IG5ldyBTZXQpO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIHBhcmVudC5kZXBlbmRPbihkZXBfMSk7XHJcbiAgICAgICAgICAgIGlmICh0eXBlb2Ygc3Vic2NyaWJlID09PSBcImZ1bmN0aW9uXCIpIHtcclxuICAgICAgICAgICAgICAgIG1heWJlVW5zdWJzY3JpYmUoZGVwXzEpO1xyXG4gICAgICAgICAgICAgICAgZGVwXzEudW5zdWJzY3JpYmUgPSBzdWJzY3JpYmUoa2V5KTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgIH1cclxuICAgIH1cclxuICAgIGRlcGVuZC5kaXJ0eSA9IGZ1bmN0aW9uIGRpcnR5KGtleSkge1xyXG4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ICAgICAgICAgICAgIHRoaXMuX3RyeVN1YnNjcmliZShzaW5rKSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGNvbmZpZy51c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nKSB7XG4gICAgICAgICAgICBpZiAoc2luay5zeW5jRXJyb3JUaHJvd2FibGUpIHtcbiAgICAgICAgICAgICAgICBzaW5rLnN5bmNFcnJvclRocm93YWJsZSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGlmIChzaW5rLnN5bmNFcnJvclRocm93bikge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBzaW5rLnN5bmNFcnJvclZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gc2luaztcbiAgICB9O1xuICAgIE9ic2VydmFibGUucHJvdG90eXBlLl90cnlTdWJzY3JpYmUgPSBmdW5jdGlvbiAoc2luaykge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N1YnNjcmliZShzaW5rKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICBpZiAoY29uZmlnLnVzZURlcHJlY2F0ZWRTeW5jaHJvbm91c0Vycm9ySGFuZGxpbmcpIHtcbiAgICAgICAgICAgICAgICBzaW5rLnN5bmNFcnJvclRocm93biA9IHRydWU7XG4gICAgICAgICAgICAgICAgc2luay5zeW5jRXJyb3JWYWx1ZSA9IGVycjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChjYW5SZXBvcnRFcnJvcihzaW5rKSkge1xuICAgICAgICAgICAgICAgIHNpbmsuZXJyb3IoZXJyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIGNvbnNvbGUud2FybihlcnIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZS5mb3JFYWNoID0gZnVuY3Rpb24gKG5leHQsIHByb21pc2VDdG9yKSB7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHByb21pc2VDdG9yID0gZ2V0UHJvbWlzZUN0b3IocHJvbWlzZUN0b3IpO1xuICAgICAgICByZXR1cm4gbmV3IHByb21pc2VDdG9yKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgICAgIHZhciBzdWJzY3JpcHRpb247XG4gICAgICAgICAgICBzdWJzY3JpcHRpb24gPSBfdGhpcy5zdWJzY3JpYmUoZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgbmV4dCh2YWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVqZWN0KGVycik7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzdWJzY3JpcHRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSwgcmVqZWN0LCByZXNvbHZlKTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZS5fc3Vic2NyaWJlID0gZnVuY3Rpb24gKHN1YnNjcmliZXIpIHtcbiAgICAgICAgdmFyIHNvdXJjZSA9IHRoaXMuc291cmNlO1xuICAgICAgICByZXR1cm4gc291cmNlICYmIHNvdXJjZS5zdWJzY3JpYmUoc3Vic2NyaWJlcik7XG4gICAgfTtcbiAgICBPYnNlcnZhYmxlLnByb3RvdHlwZVtTeW1ib2xfb2JzZXJ2YWJsZV0gPSBmdW5jdGlvbiAoKSB7XG4gIC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ubmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICBpZiAodGhpcy5jbG9zZWQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBPYmplY3RVbnN1YnNjcmliZWRFcnJvcigpO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5pc1N0b3BwZWQpIHtcbiAgICAgICAgICAgIHZhciBvYnNlcnZlcnMgPSB0aGlzLm9ic2VydmVycztcbiAgICAgICAgICAgIHZhciBsZW4gPSBvYnNlcnZlcnMubGVuZ3RoO1xuICAgICAgICAgICAgdmFyIGNvcHkgPSBvYnNlcnZlcnMuc2xpY2UoKTtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjb3B5W2ldLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBTdWJqZWN0LnByb3RvdHlwZS5lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgaWYgKHRoaXMuY2xvc2VkKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgT2JqZWN0VW5zdWJzY3JpYmVkRXJyb3IoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmhhc0Vycm9yID0gdHJ1ZTtcbiAgICAgICAgdGhpcy50aHJvd25FcnJvciA9IGVycjtcbiAgICAgICAgdGhpcy5pc1N0b3BwZWQgPSB0cnVlO1xuICAgICAgICB2YXIgb2JzZXJ2ZXJzID0gdGhpcy5vYnNlcnZlcnM7XG4gICAgICAgIHZhciBsZW4gPSBvYnNlcnZlcnMubGVuZ3RoO1xuICAgICAgICB2YXIgY29weSA9IG9ic2VydmVycy5zbGljZSgpO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbjsgaSsrKSB7XG4gICAgICAgICAgICBjb3B5W2ldLmVycm9yKGVycik7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5vYnNlc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aGlzID0gX3N1cGVyLmNhbGwodGhpcykgfHwgdGhpcztcbiAgICAgICAgX3RoaXMuc3luY0Vycm9yVmFsdWUgPSBudWxsO1xuICAgICAgICBfdGhpcy5zeW5jRXJyb3JUaHJvd24gPSBmYWxzZTtcbiAgICAgICAgX3RoaXMuc3luY0Vycm9yVGhyb3dhYmxlID0gZmFsc2U7XG4gICAgICAgIF90aGlzLmlzU3RvcHBlZCA9IGZhbHNlO1xuICAgICAgICBzd2l0Y2ggKGFyZ3VtZW50cy5sZW5ndGgpIHtcbiAgICAgICAgICAgIGNhc2UgMDpcbiAgICAgICAgICAgICAgICBfdGhpcy5kZXN0aW5hdGlvbiA9IGVtcHR5T2JzZXJ2ZXI7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICAgICAgaWYgKCFkZXN0aW5hdGlvbk9yTmV4dCkge1xuICAgICAgICAgICAgICAgICAgICBfdGhpcy5kZXN0aW5hdGlvbiA9IGVtcHR5T2JzZXJ2ZXI7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRlc3RpbmF0aW9uT3JOZXh0ID09PSAnb2JqZWN0Jykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZGVzdGluYXRpb25Pck5leHQgaW5zdGFuY2VvZiBTdWJzY3JpYmVyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5zeW5jRXJyb3JUaHJvd2FibGUgPSBkZXN0aW5hdGlvbk9yTmV4dC5zeW5jRXJyb3JUaHJvd2FibGU7XG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5kZXN0aW5hdGlvbiA9IGRlc3RpbmF0aW9uT3JOZXh0O1xuICAgICAgICAgICAgICAgICAgICAgICAgZGVzdGluYXRpb25Pck5leHQuYWRkKF90aGlzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF90aGlzLnN5bmNFcnJvclRocm93YWJsZSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBfdGhpcy5kZXN0aW5hdGlvbiA9IG5ldyBTYWZlU3Vic2NyaWJlcihfdGhpcywgZGVzdGluYXRpb25Pck5leHQpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgX3RoaXMuc3luY0Vycm9yVGhyb3dhYmxlID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBfdGhpcy5kZXN0aW5hdGlvbiA9IG5ldyBTYWZlU3Vic2NyaWJlcihfdGhpcywgZGVzdGluYXRpb25Pck5leHQsIGVycm9yLCBjb21wbGV0ZSk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIF90aGlzO1xuICAgIH1cbiAgICBTdWJzY3JpYmVyLnByb3RvdHlwZVtyeFN1YnNjcmliZXJTeW1ib2xdID0gZnVuY3Rpb24gKCkgeyByZXR1cm4gdGhpczsgfTtcbiAgICBTdWJzY3JpYmVyLmNyZWF0ZSA9IGZ1bmN0aW9uIChuZXh0LCBlcnJvciwgY29tcGxldGUpIHtcbiAgICAgICAgdmFyIHN1YnNjcmliZXIgPSBuZXcgU3Vic2NyaWJlcihuZXh0LCBlcnJvciwgY29tcGxldGUpO1xuICAgICAgICBzdWJzY3JpYmVyLnN5bmNFcnJvclRocm93YWJsZSA9IGZhbHNlO1xuICAgICAgICByZXR1cm4gc3Vic2NyaWJlcjtcbiAgICB9O1xuICAgIFN1YnNjcmliZXIucHJvdG90eXBlLm5leHQgPSBmdW5jdGlvbiAodmFsdWUpIHtcbiAgICAgICAgaWYgKCF0aGlzLmlzU3RvcHBlZCkge1x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b250ZXh0ID0gX3RoaXM7XG4gICAgICAgIGlmIChpc0Z1bmN0aW9uKG9ic2VydmVyT3JOZXh0KSkge1xuICAgICAgICAgICAgbmV4dCA9IG9ic2VydmVyT3JOZXh0O1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKG9ic2VydmVyT3JOZXh0KSB7XG4gICAgICAgICAgICBuZXh0ID0gb2JzZXJ2ZXJPck5leHQubmV4dDtcbiAgICAgICAgICAgIGVycm9yID0gb2JzZXJ2ZXJPck5leHQuZXJyb3I7XG4gICAgICAgICAgICBjb21wbGV0ZSA9IG9ic2VydmVyT3JOZXh0LmNvbXBsZXRlO1xuICAgICAgICAgICAgaWYgKG9ic2VydmVyT3JOZXh0ICE9PSBlbXB0eU9ic2VydmVyKSB7XG4gICAgICAgICAgICAgICAgY29udGV4dCA9IE9iamVjdC5jcmVhdGUob2JzZXJ2ZXJPck5leHQpO1xuICAgICAgICAgICAgICAgIGlmIChpc0Z1bmN0aW9uKGNvbnRleHQudW5zdWJzY3JpYmUpKSB7XG4gICAgICAgICAgICAgICAgICAgIF90aGlzLmFkZChjb250ZXh0LnVuc3Vic2NyaWJlLmJpbmQoY29udGV4dCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb250ZXh0LnVuc3Vic2NyaWJlID0gX3RoaXMudW5zdWJzY3JpYmUuYmluZChfdGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgX3RoaXMuX2NvbnRleHQgPSBjb250ZXh0O1xuICAgICAgICBfdGhpcy5fbmV4dCA9IG5leHQ7XG4gICAgICAgIF90aGlzLl9lcnJvciA9IGVycm9yO1xuICAgICAgICBfdGhpcy5fY29tcGxldGUgPSBjb21wbGV0ZTtcbiAgICAgICAgcmV0dXJuIF90aGlzO1xuICAgIH1cbiAgICBTYWZlU3Vic2NyaWJlci5wcm90b3R5cGUubmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICBpZ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3RyeU9yVW5zdWIodGhpcy5fZXJyb3IsIGVycik7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX190cnlPclNldEVycm9yKF9wYXJlbnRTdWJzY3JpYmVyLCB0aGlzLl9lcnJvciwgZXJyKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKCFfcGFyZW50U3Vic2NyaWJlci5zeW5jRXJyb3JUaHJvd2FibGUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICAgICAgaWYgKHVzZURlcHJlY2F0ZWRTeW5jaHJvbm91c0Vycm9ySGFuZGxpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXJyO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBob3N0UmVwb3J0RXJyb3IoZXJyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICh1c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nKSB7XG4gICAgICAgICAgICAgICAgICAgIF9wYXJlbnRTdWJzY3JpYmVyLnN5bmNFcnJvclZhbHVlID0gZXJyO1xuICAgICAgICAgICAgICAgICAgICBfcGFyZW50U3Vic2NyaWJlci5zeW5jRXJyb3JUaHJvd24gPSB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaG9zdFJlcG9ydEVycm9yKGVycik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgU2FmZVN1YnNjcmliZXIucHJvdG90eXBlLmNvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBpZiAoIXRoaXMuaXNTdG9wcGVkKSB7XG4gICAgICAgICAgICB2YXIgX3BhcmVudFN1YnNjcmliZXIgPSB0aGlzLl9wYXJlbnRTdWJzY3JpYmVyO1xuICAgICAgICAgICAgaWYgKHRoaXMuX2NvbXBsZXRlKSB7XG4gICAgICAgICAgICAgICAgdmFyIHdyYXBwZWRDb21wbGV0ZSA9IGZ1bmN0aW9uICgpIHsgcmV0dXJuIF90aGlzLl9jb21wbGV0ZS5jYWxsKF90aGlzLl9jb250ZXh0KTsgfTtcbiAgICAgICAgICAgICAgICBpZiAoIWNvbmZpZy51c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nIHx8ICFfcGFyZW50U3Vic2NyaWJlci5zeW5jRXJyb3JUaHJvd2FibGUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3RyeU9yVW5zdWIod3JhcHBlZENvbXBsZXRlKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fX3RyeU9yU2V0RXJyb3IoX3BhcmVudFN1YnNjcmliZXIsIHdyYXBwZWRDb21wbGV0ZSk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudW5zdWJzY3JpYmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIFNhZmVTdWJzY3JpYmVyLnByb3RvdHlwZS5fX3RyeU9yVW5zdWIgPSBmdW5jdGlvbiAoZm4sIHZhbHVlKSB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICBmbi5jYWxsKHRoaXMuX2NvbnRleHQsIHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICBpZiAoY29uZmlnLnVzZURlcHJlY2F0ZWRTeW5jaHJvbm91c0Vycm9ySGFuZGxpbmcpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBob3N0UmVwb3J0RXJyb3IoZXJyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG4gICAgU2FmZVN1YnNjcmliZXIucHJvdG90eXBlLl9fdHJ5T3JTZXRFcnJvciA9IGZ1bmN0aW9uIChwYXJlbnQsIGZuLCB2YWx1ZSkge1xuICAgICAgICBpZiAoIWNvbmZpZy51c2VEZXByZWNhdGVkU3luY2hyb25vdXNFcnJvckhhbmRsaW5nKSB7XG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ2JhZCBjYWxsJyk7XG4gICAgICAgIH1cbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIGZuLmNhbGwodGhpcy5fY29udGV4dCwgdmFsdWUpO1xuICAgICAgICB9XG4gICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgIGlmIChjb25maWcudXNlRGVwcmVjYXRlZFN5bmNocm9ub3VzRXJyb3JIYW5kbGluZykge1xuICAgICAgICAgICAgICAgIHBhcmVudC5zeW5jRXJyb3JWYWx1ZSA9IGVycjtcbiAgICAgICAgICAgICAgICBwYXJlbnQuc3luY0Vycm9yVGhyb3duID0gdHJ1ZTtcbiAgICAgICAgICAgIC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AgICAgICAgX3BhcmVudE9yUGFyZW50cy5yZW1vdmUodGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoX3BhcmVudE9yUGFyZW50cyAhPT0gbnVsbCkge1xuICAgICAgICAgICAgZm9yICh2YXIgaW5kZXggPSAwOyBpbmRleCA8IF9wYXJlbnRPclBhcmVudHMubGVuZ3RoOyArK2luZGV4KSB7XG4gICAgICAgICAgICAgICAgdmFyIHBhcmVudF8xID0gX3BhcmVudE9yUGFyZW50c1tpbmRleF07XG4gICAgICAgICAgICAgICAgcGFyZW50XzEucmVtb3ZlKHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChpc0Z1bmN0aW9uKF91bnN1YnNjcmliZSkpIHtcbiAgICAgICAgICAgIGlmIChfY3RvclVuc3Vic2NyaWJlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fdW5zdWJzY3JpYmUgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIF91bnN1YnNjcmliZS5jYWxsKHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICBlcnJvcnMgPSBlIGluc3RhbmNlb2YgVW5zdWJzY3JpcHRpb25FcnJvciA/IGZsYXR0ZW5VbnN1YnNjcmlwdGlvbkVycm9ycyhlLmVycm9ycykgOiBbZV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGlzQXJyYXkoX3N1YnNjcmlwdGlvbnMpKSB7XG4gICAgICAgICAgICB2YXIgaW5kZXggPSAtMTtcbiAgICAgICAgICAgIHZhciBsZW4gPSBfc3Vic2NyaXB0aW9ucy5sZW5ndGg7XG4gICAgICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbikge1xuICAgICAgICAgICAgICAgIHZhciBzdWIgPSBfc3Vic2NyaXB0aW9uc1tpbmRleF07XG4gICAgICAgICAgICAgICAgaWYgKGlzT2JqZWN0KHN1YikpIHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1Yi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMgfHwgW107XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZSBpbnN0YW5jZW9mIFVuc3Vic2NyaXB0aW9uRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMuY29uY2F0KGZsYXR0ZW5VbnN1YnNjcmlwdGlvbkVycm9ycyhlLmVycm9ycykpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzLnB1c2goZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGVycm9ycykge1xuICAgICAgICAgICAgdGhyb3cgbmV3IFVuc3Vic2NyaXB0aW9uRXJyb3IoZXJyb3JzKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgU3Vic2NyaXB0aW9uLnByb3RvdHlwZS5hZGQgPSBmdW5jdGlvbiAodGVhcmRvd24pIHtcbiAgICAgICAgdmFyIHN1YnNjcmlwdGlvbiA9IHRlYXJkb3duO1xuICAgICAgICBpZiAoIXRlYXJkb3duKSB7XG4gICAgICAgICAgICByZXR1cm4gU3Vic2NyaXB0aW9uLkVNUFRZO1xuICAgICAgICB9XG4gICAgICAgIHN3aXRjaCAodHlwZW9mIHRlYXJkb3duKSB7XG4gICAgICAgICAgICBjYXNlICdmdW5jdGlvbic6XG4gICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uID0gbmV3IFN1YnNjcmlwdGlvbih0ZWFyZG93bik7XG4gICAgICAgICAgICBjYXNlICdvYmplY3QnOlxuICAgICAgICAgICAgICAgIGlmIChzdWJzY3JpcHRpb24gPT09IHRoaXMgfHwgc3Vic2NyaXB0aW9uLmNsb3NlZCB8fCB0eXBlb2Ygc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlICE9PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBzdWJzY3JpcHRpb247XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGVsc2UgaWYgKHRoaXMuY2xvc2VkKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3Vic2NyaXB0aW9uO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIGlmICghKHN1YnNjcmlwdGlvbiBpbnN0YW5jZW9mIFN1YnNjcmlwdGlvbikpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHRtcCA9IHN1YnNjcmlwdGlvbjtcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaXB0aW9uID0gbmV3IFN1YnNjcmlwdGlvbigpO1xuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24uX3N1YnNjcmlwdGlvbnMgPSBbdG1wXTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBkZWZhdWx0OiB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCd1bnJlY29nbml6ZWQgdGVhcmRvd24gJyArIHRlYXJkb3duICsgJyBhZGRlZCB0byBTdWJzY3JpcHRpb24uJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdmFyIF9wYXJlbnRPclBhcmVudHMgPSBzdWJzY3JpcHRpb24uX3BhcmVudE9yUGFyZW50cztcbiAgICAgICAgaWYgKF9wYXJlbnRPclBhcmVudHMgPT09IG51bGwpIHtcbiAgICAgICAgICAgIHN1YnNjcmlwdGlvbi5fcGFyZW50T3JQYXJlbnRzID0gdGhpcztcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChfcGFyZW50T3JQYXJlbnRzIGluc3RhbmNlb2YgU3Vic2NyaXB0aW9uKSB7XG4gICAgICAgICAgICBpZiAoX3BhcmVudE9yUGFyZW50cyA9PT0gdGhpcykge1xuICAgICAgICAgICAgICAgIHJldHVybiBzdWJzY3JpcHRpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzdWJzY3JpcHRpb24uX3BhcmVudE9yUGFyZW50cyA9IFtfcGFyZW50T3JQYXJlbnRzLCB0aGlzXTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChfcGFyZW50T3JQYXJlbnRzLmluZGV4T2YodGhpcykgPT09IC0xKSB7XG4gICAgICAgICAgICBfcGFyZW50T3JQYXJlbnRzLnB1c2godGhpcyk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gc3Vic2NyaXB0aW9uO1xuICAgICAgICB9XG4gICAgICAgIHZhciBzdWJzY3JpcHRpb25zID0gdGhpcy5fc3Vic2NyaXB0aW9ucztcbiAgICAgICAgaWYgKHN1YnNjcmlwdGlvbnMgPT09IG51bGwpIHtcbiAgICAgICAgICAgIHRoaXMuX3N1YnNjcmlwdGlvbnMgPSBbc3Vic2NyaXB0aW9uXTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHN1YnNjcmlwdGlvbnMucHVzaChzdWJzY3JpcHRpb24pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzdWJzY3JpcHRpb247XG4gICAgfTtcbiAgICBTdWJzY3JpcH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zZXJ2ZXJPck5leHQuZXJyb3IgfHwgbm9vcDtcbiAgICAgICAgICAgIF90aGlzLl90YXBDb21wbGV0ZSA9IG9ic2VydmVyT3JOZXh0LmNvbXBsZXRlIHx8IG5vb3A7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIF90aGlzO1xuICAgIH1cbiAgICBUYXBTdWJzY3JpYmVyLnByb3RvdHlwZS5fbmV4dCA9IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgdGhpcy5fdGFwTmV4dC5jYWxsKHRoaXMuX2NvbnRleHQsIHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5uZXh0KHZhbHVlKTtcbiAgICB9O1xuICAgIFRhcFN1YnNjcmliZXIucHJvdG90eXBlLl9lcnJvciA9IGZ1bmN0aW9uIChlcnIpIHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHRoaXMuX3RhcEVycm9yLmNhbGwodGhpcy5fY29udGV4dCwgZXJyKTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICB0aGlzLmRlc3RpbmF0aW9uLmVycm9yKGVycik7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5kZXN0aW5hdGlvbi5lcnJvcihlcnIpO1xuICAgIH07XG4gICAgVGFwU3Vic2NyaWJlci5wcm90b3R5cGUuX2NvbXBsZXRlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgdGhpcy5fdGFwQ29tcGxldGUuY2FsbCh0aGlzLl9jb250ZXh0KTtcbiAgICAgICAgfVxuICAgICAgICBjYXRjaCAoZXJ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lcChvcCkge1xyXG4gICAgICAgIGlmIChmKSB0aHJvdyBuZXcgVHlwZUVycm9yKFwiR2VuZXJhdG9yIGlzIGFscmVhZHkgZXhlY3V0aW5nLlwiKTtcclxuICAgICAgICB3aGlsZSAoXykgdHJ5IHtcclxuICAgICAgICAgICAgaWYgKGYgPSAxLCB5ICYmICh0ID0gb3BbMF0gJiAyID8geVtcInJldHVyblwiXSA6IG9wWzBdID8geVtcInRocm93XCJdIHx8ICgodCA9IHlbXCJyZXR1cm5cIl0pICYmIHQuY2FsbCh5KSwgMCkgOiB5Lm5leHQpICYmICEodCA9IHQuY2FsbCh5LCBvcFsxXSkpLmRvbmUpIHJldHVybiB0O1xyXG4gICAgICAgICAgICBpZiAoeSA9IDAsIHQpIG9wID0gW29wWzBdICYgMiwgdC52YWx1ZV07XHJcbiAgICAgICAgICAgIHN3aXRjaCAob3BbMF0pIHtcclxuICAgICAgICAgICAgICAgIGNhc2UgMDogY2FzZSAxOiB0ID0gb3A7IGJyZWFrO1xyXG4gICAgICAgICAgICAgICAgY2FzZSA0OiBfLmxhYmVsKys7IHJldHVybiB7IHZhbHVlOiBvcFsxXSwgZG9uZTogZmFsc2UgfTtcclxuICAgICAgICAgICAgICAgIGNhc2UgNTogXy5sYWJlbCsrOyB5ID0gb3BbMV07IG9wID0gWzBdOyBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIGNhc2UgNzogb3AgPSBfLm9wcy5wb3AoKTsgXy50cnlzLnBvcCgpOyBjb250aW51ZTtcclxuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKCEodCA9IF8udHJ5cywgdCA9IHQubGVuZ3RoID4gMCAmJiB0W3QubGVuZ3RoIC0gMV0pICYmIChvcFswXSA9PT0gNiB8fCBvcFswXSA9PT0gMikpIHsgXyA9IDA7IGNvbnRpbnVlOyB9XHJcbiAgICAgICAgICAgICAgICAgICAgaWYgKG9wWzBdID09PSAzICYmICghdCB8fCAob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gICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBkb25lKCkge1xuICAgICAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgIHJlc29sdmUoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBzdWJzY3JpcHRpb24gPSBfdGhpcy5zdWJzY3JpYmUoe1xuICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgZm4odmFsdWUsIGRvbmUpO1xuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICByZWplY3QoZSk7XG4gICAgICAgICAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0sXG4gICAgICAgICAgZXJyb3I6IHJlamVjdCxcbiAgICAgICAgICBjb21wbGV0ZTogcmVzb2x2ZVxuICAgICAgICB9KTtcbiAgICAgIH0pO1xuICAgIH1cbiAgfSwge1xuICAgIGtleTogXCJtYXBcIixcbiAgICB2YWx1ZTogZnVuY3Rpb24gbWFwKGZuKSB7XG4gICAgICB2YXIgX3RoaXMyID0gdGhpcztcblxuICAgICAgaWYgKHR5cGVvZiBmbiAhPT0gJ2Z1bmN0aW9uJykgdGhyb3cgbmV3IFR5cGVFcnJvcihmbiArICcgaXMgbm90IGEgZnVuY3Rpb24nKTtcbiAgICAgIHZhciBDID0gZ2V0U3BlY2llcyh0aGlzKTtcbiAgICAgIHJldHVybiBuZXcgQyhmdW5jdGlvbiAob2JzZXJ2ZXIpIHtcbiAgICAgICAgcmV0dXJuIF90aGlzMi5zdWJzY3JpYmUoe1xuICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgdmFsdWUgPSBmbih2YWx1ZSk7XG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgIHJldHVybiBvYnNlcnZlci5lcnJvcihlKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgb2JzZXJ2ZXIubmV4dCh2YWx1ZSk7XG4gICAgICAgICAgfSxcbiAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGUpO1xuICAgICAgICAgIH0sXG4gICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIG9ic2VydmVyLmNvbXBsZXRlKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgIH0pO1xuICAgIH1cbiAgfSwge1xuICAgIGtleTogXCJmaWx0ZXJcIixcbiAgICB2YWx1ZTogZnVuY3Rpb24gZmlsdGVyKGZuKSB7XG4gICAgICB2YXIgX3RoaXMzID0gdGhpcztcblxuICAgICAgaWYgKHR5cGVvZiBmbiAhPT0gJ2Z1bmN0aW9uJykgdGhyb3cgbmV3IFR5cGVFcnJvcihmbiArICcgaXMgbm90IGEgZnVuY3Rpb24nKTtcbiAgICAgIHZhciBDID0gZ2V0U3BlY2llcyh0aGlzKTtcbiAgICAgIHJldHVybiBuZXcgQyhmdW5jdGlvbiAob2JzZXJ2ZXIpIHtcbiAgICAgICAgcmV0dXJuIF90aGlzMy5zdWJzY3JpYmUoe1xuICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgaWYgKCFmbih2YWx1ZSkpIHJldHVybjtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgcmV0dXJuIG9ic2VydmVyLmVycm9yKGUpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBvYnNlcnZlci5uZXh0KHZhbHVlKTtcbiAgICAgICAgICB9LFxuICAgICAgICAgIGVycm9yOiBmdW5jdGlvbiAoZSkge1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lcnJvcihlKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgYWNjID0gdmFsdWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSxcbiAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGUpO1xuICAgICAgICAgIH0sXG4gICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlmICghaGFzVmFsdWUgJiYgIWhhc1NlZWQpIHJldHVybiBvYnNlcnZlci5lcnJvcihuZXcgVHlwZUVycm9yKCdDYW5ub3QgcmVkdWNlIGFuIGVtcHR5IHNlcXVlbmNlJykpO1xuICAgICAgICAgICAgb2JzZXJ2ZXIubmV4dChhY2MpO1xuICAgICAgICAgICAgb2JzZXJ2ZXIuY29tcGxldGUoKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfSk7XG4gICAgfVxuICB9LCB7XG4gICAga2V5OiBcImNvbmNhdFwiLFxuICAgIHZhbHVlOiBmdW5jdGlvbiBjb25jYXQoKSB7XG4gICAgICB2YXIgX3RoaXM1ID0gdGhpcztcblxuICAgICAgZm9yICh2YXIgX2xlbiA9IGFyZ3VtZW50cy5sZW5ndGgsIHNvdXJjZXMgPSBuZXcgQXJyYXkoX2xlbiksIF9rZXkgPSAwOyBfa2V5IDwgX2xlbjsgX2tleSsrKSB7XG4gICAgICAgIHNvdXJjZXNbX2tleV0gPSBhcmd1bWVudHNbX2tleV07XG4gICAgICB9XG5cbiAgICAgIHZhciBDID0gZ2V0U3BlY2llcyh0aGlzKTtcbiAgICAgIHJldHVybiBuZXcgQyhmdW5jdGlvbiAob2JzZXJ2ZXIpIHtcbiAgICAgICAgdmFyIHN1YnNjcmlwdGlvbjtcbiAgICAgICAgdmFyIGluZGV4ID0gMDtcblxuICAgICAgICBmdW5jdGlvbiBzdGFydE5leHQobmV4dCkge1xuICAgICAgICAgIHN1YnNjcmlwdGlvbiA9IG5leHQuc3Vic2NyaWJlKHtcbiAgICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uICh2KSB7XG4gICAgICAgICAgICAgIG9ic2VydmVyLm5leHQodik7XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgIG9ic2VydmVyLmVycm9yKGUpO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNvbXBsZXRlOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gc291cmNlcy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICBzdWJzY3JpcHRpb24gPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgb2JzZXJ2ZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdGFydE5leHQoQy5mcm9tKHNvdXJjZXNbaW5kZXgrK10pKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgc3RhcnROZXh0KF90aGlzNSk7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgaWYgKHN1YnNjcmlwdGlvbikge1xuICAgICAgICAgICAgc3Vic2NyaXB0aW9uLnVuc3Vic2NyaWJlKCk7XG4gICAgICAgICAgICBzdWJzY3JpcHRpb24gPSB1bmRlZmluZWQ7XG4gICAgICAgICAgfVxuICAgICAgICB9O1xuICAgICAgfSk7XG4gICAgfVxuICB9LCB7XG4gICAga2V5OiBcImZsYXRNYXBcIixcbiAgICB2YWx1ZTogZnVuY3Rpb24gZmxhdE1hcChmbikge1xuICAgICAgdmFyIF90aGlzNiA9IHRoaXM7XG5cbiAgICAgIGlmICh0eXBlb2YgZm4gIT09ICdmdW5jdGlvbicpIHRocm93IG5ldyBUeXBlRXJyb3IoZm4gKyAnIGlzIG5vdCBhIGZ1bmN0aW9uJyk7XG4gICAgICB2YXIgQyA9IGdldFNwZWNpZXModGhpcyk7XG4gICAgICByZXR1cm4gbmV3IEMoZnVuY3Rpb24gKG9ic2VydmVyKSB7XG4gICAgICAgIHZhciBzdWJzY3JpcHRpb25zID0gW107XG5cbiAgICAgICAgdmFyIG91dGVyID0gX3RoaXM2LnN1YnNjcmliZSh7XG4gICAgICAgICAgbmV4dDogZnVuY3Rpb24gKHZhbHVlKSB7XG4gICAgICAgICAgICBpZiAoZm4pIHtcbiAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IGZuKHZhbHVlKTtcbiAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBvYnNlcnZlci5lcnJvcihlKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgaW5uZXIgPSBDLmZyb20odmFsdWUpLnN1YnNjcmliZSh7XG4gICAgICAgICAgICAgIG5leHQ6IGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgICAgIG9ic2VydmVyLm5leHQodmFsdWUpO1xuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgICAgICAgICBvYnNlcnZlci5lcnJvcihlKTtcbiAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICB2YXIgaSA9IHN1YnNjcmlwdGlvbnMuaW5kZXhPZihpbm5lcik7XG4gICAgICAgICAgICAgICAgaWYgKGkgPj0gMCkgc3Vic2NyaXB0aW9ucy5zcGxpY2UoaSwgMSk7XG4gICAgICAgICAgICAgICAgY29tcGxldGVJZkRvbmUoKTtcbiAgICAgICAgICAgICAgfVxuICAgICAg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cbiAgICAgICAgICAgICAgICBmb3IgKHZhciBfaXRlcmF0b3IgPSBtZXRob2QuY2FsbCh4KVtTeW1ib2wuaXRlcmF0b3JdKCksIF9zdGVwOyAhKF9pdGVyYXRvck5vcm1hbENvbXBsZXRpb24gPSAoX3N0ZXAgPSBfaXRlcmF0b3IubmV4dCgpKS5kb25lKTsgX2l0ZXJhdG9yTm9ybWFsQ29tcGxldGlvbiA9IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgIHZhciBfaXRlbSA9IF9zdGVwLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgb2JzZXJ2ZXIubmV4dChfaXRlbSk7XG4gICAgICAgICAgICAgICAgICBpZiAob2JzZXJ2ZXIuY2xvc2VkKSByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBfZGlkSXRlcmF0b3JFcnJvciA9IHRydWU7XG4gICAgICAgICAgICAgICAgX2l0ZXJhdG9yRXJyb3IgPSBlcnI7XG4gICAgICAgICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgIGlmICghX2l0ZXJhdG9yTm9ybWFsQ29tcGxldGlvbiAmJiBfaXRlcmF0b3IucmV0dXJuICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgX2l0ZXJhdG9yLnJldHVybigpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICBpZiAoX2RpZEl0ZXJhdG9yRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgX2l0ZXJhdG9yRXJyb3I7XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgb2JzZXJ2ZXIuY29tcGxldGUoKTtcbiAgICAgICAgICAgIH0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