-
Notifications
You must be signed in to change notification settings - Fork 6
/
rpc.client.ts
3 lines (3 loc) · 22.7 KB
/
rpc.client.ts
1
2
3
// Automatically generated by "tools/generate_rpc_client.ts"
export const BASE64_ENCODED_RPC_CLIENT_SOURCE =
"InVzZSBzdHJpY3QiOwp2YXIgX19hd2FpdGVyID0gKHRoaXMgJiYgdGhpcy5fX2F3YWl0ZXIpIHx8IGZ1bmN0aW9uICh0aGlzQXJnLCBfYXJndW1lbnRzLCBQLCBnZW5lcmF0b3IpIHsKICAgIGZ1bmN0aW9uIGFkb3B0KHZhbHVlKSB7IHJldHVybiB2YWx1ZSBpbnN0YW5jZW9mIFAgPyB2YWx1ZSA6IG5ldyBQKGZ1bmN0aW9uIChyZXNvbHZlKSB7IHJlc29sdmUodmFsdWUpOyB9KTsgfQogICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7CiAgICAgICAgZnVuY3Rpb24gZnVsZmlsbGVkKHZhbHVlKSB7IHRyeSB7IHN0ZXAoZ2VuZXJhdG9yLm5leHQodmFsdWUpKTsgfSBjYXRjaCAoZSkgeyByZWplY3QoZSk7IH0gfQogICAgICAgIGZ1bmN0aW9uIHJlamVjdGVkKHZhbHVlKSB7IHRyeSB7IHN0ZXAoZ2VuZXJhdG9yWyJ0aHJvdyJdKHZhbHVlKSk7IH0gY2F0Y2ggKGUpIHsgcmVqZWN0KGUpOyB9IH0KICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQogICAgICAgIHN0ZXAoKGdlbmVyYXRvciA9IGdlbmVyYXRvci5hcHBseSh0aGlzQXJnLCBfYXJndW1lbnRzIHx8IFtdKSkubmV4dCgpKTsKICAgIH0pOwp9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A7IGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSA0OiBfLmxhYmVsKys7IHJldHVybiB7IHZhbHVlOiBvcFsxXSwgZG9uZTogZmFsc2UgfTsKICAgICAgICAgICAgICAgIGNhc2UgNTogXy5sYWJlbCsrOyB5ID0gb3BbMV07IG9wID0gWzBdOyBjb250aW51ZTsKICAgICAgICAgICAgICAgIGNhc2UgNzogb3AgPSBfLm9wcy5wb3AoKTsgXy50cnlzLnBvcCgpOyBjb250aW51ZTsKICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgaWYgKCEodCA9IF8udHJ5cywgdCA9IHQubGVuZ3RoID4gMCAmJiB0W3QubGVuZ3RoIC0gMV0pICYmIChvcFswXSA9PT0gNiB8fCBvcFswXSA9PT0gMikpIHsgXyA9IDA7IGNvbnRpbnVlOyB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wWzBdID09PSAzICYmICghdCB8fCAob3BbMV0gPiB0WzBdICYmIG9wWzFdIDwgdFszXSkpKSB7IF8ubGFiZWwgPSBvcFsxXTsgYnJlYWs7IH0KICAgICAgICAgICAgICAgICAgICBpZiAob3BbMF0gPT09IDYgJiYgXy5sYWJlbCA8IHRbMV0pIHsgXy5sYWJlbCA9IHRbMV07IHQgPSBvcDsgYnJlYWs7IH0KICAgICAgICAgICAgICAgICAgICBpZiAodCAmJiBfLmxhYmVsIDwgdFsyXSkgeyBfLmxhYmVsID0gdFsyXTsgXy5vcHMucHVzaChvcCk7IGJyZWFrOyB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHRbMl0pIF8ub3BzLnBvcCgpOwogICAgICAgICAgICAgICAgICAgIF8udHJ5cy5wb3AoKTsgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgb3AgPSBib2R5LmNhbGwodGhpc0FyZywgXyk7CiAgICAgICAgfSBjYXRjaCAoZSkgeyBvcCA9IFs2LCBlXTsgeSA9IDA7IH0gZmluYWxseSB7IGYgPSB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5kbGUsIG1ldGhvZE5hbWUpOwogICAgfTsKICAgIEhhbmRsZS5wcm90b3R5cGUuY2FsbE1ldGhvZF8gPSBmdW5jdGlvbiAobWV0aG9kKSB7CiAgICAgICAgdmFyIGFyZ3MgPSBbXTsKICAgICAgICBmb3IgKHZhciBfaSA9IDE7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykgewogICAgICAgICAgICBhcmdzW19pIC0gMV0gPSBhcmd1bWVudHNbX2ldOwogICAgICAgIH0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgUHJvbWlzZSwgZnVuY3Rpb24gKCkgewogICAgICAgICAgICB2YXIgbWVzc2FnZSwgcmVzcG9uc2U7CiAgICAgICAgICAgIHJldHVybiBfX2dlbmVyYXRvcih0aGlzLCBmdW5jdGlvbiAoX2EpIHsKICAgICAgICAgICAgICAgIHN3aXRjaCAoX2EubGFiZWwpIHsKICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtOiBtZXRob2QsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwOiB0aGlzLnJwY18ud3JhcF8oYXJncyksCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgdGhpcy5ycGNfLnNlbmRDb21tYW5kXyh0aGlzLmFkZHJlc3NfLCB0aGlzLmxvY2FsQWRkcmVzc18sIG1lc3NhZ2UpXTsKICAgICAgICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gX2Euc2VudCgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzIsIHRoaXMucnBjXy51bndyYXBfKHJlc3BvbnNlKV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgfTsKICAgIEhhbmRsZS5wcm90b3R5cGUuZGlzcGF0Y2hNZXNzYWdlXyA9IGZ1bmN0aW9uIChtZXNzYWdlKSB7CiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIFByb21pc2UsIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgdmFyIHJlc3VsdF8xLCB2YWx1ZSwgcmVzdWx0OwogICAgICAgICAgICB2YXIgX2E7CiAgICAgICAgICAgIHJldHVybiBfX2dlbmVyYXRvcih0aGlzLCBmdW5jdGlvbiAoX2IpIHsKICAgICAgICAgICAgICAgIHN3aXRjaCAoX2IubGFiZWwpIHsKICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgIGFzc2VydCh0aGlzLm9iamVjdF8pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZGVzY3JpcHRvcl8uaXNGdW5jKSByZXR1cm4gWzMsIDJdOwogICAgICAgICAgICAgICAgICAgICAgICBhc3NlcnQodHlwZW9mIHRoaXMub2JqZWN0XyA9PT0gImZ1bmN0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgdGhpcy5vYmplY3RfLmFwcGx5KHRoaXMsIHRoaXMucnBjXy51bndyYXBfKG1lc3NhZ2UucCkpXTsKICAgICAgICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdF8xID0gX2Iuc2VudCgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzIsIHRoaXMucnBjXy53cmFwXyhyZXN1bHRfMSldOwogICAgICAgICAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1lc3NhZ2UubS5zdGFydHNXaXRoKCJfIikgfHwgbWVzc2FnZS5tLmVuZHNXaXRoKCJfIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiUHJpdmF0ZSBtZW1iZXJzIGFyZSBub3QgZXhwb3NlZCBvdmVyIFJQQzogJyIgKyBtZXNzYWdlLm0gKyAiJyIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGFzc2VydCh0eXBlb2YgdGhpcy5vYmplY3RfID09PSAib2JqZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKG1lc3NhZ2UubSBpbiB0aGlzLm9iamVjdF8pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlRoZXJlIGlzIG5vIG1lbWJlciAnIiArIG1lc3NhZ2UubSArICInIGluICciICsgdGhpcy5kZXNjcmlwdG9yXy5uYW1lICsgIiciKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRoaXMub2JqZWN0X1ttZXNzYWdlLm1dOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWVzc2FnZS5wLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiJyIgKyBtZXNzYWdlLm0gKyAiJyBpcyBub3QgYSBmdW5jdGlvbiwgY2FuJ3QgcGFzcyBhcmdzICciICsgbWVzc2FnZS5wICsgIiciKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMiwgdGhpcy5ycGNfLndyYXBfKHZhbHVlKV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFs0LCAoX2EgPSB0aGlzLm9iamVjdF8pW21lc3NhZ2UubV0uYXBwbHkoX2EsIHRoaXMucnBjXy51bndyYXBfKG1lc3NhZ2UucCkpXTsKICAgICAgICAgICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IF9iLnNlbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyLCB0aGlzLnJwY18ud3JhcF8ocmVzdWx0KV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgfTsKICAgIEhhbmRsZS5wcm90b3R5cGUucHJveHkgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgcmV0dXJuIHRoaXMucHJveHlfOwogICAgfTsKICAgIHJldHVybiBIYW5kbGU7Cn0oKSk7CnZhciBScGMgPSAoZnVuY3Rpb24gKCkgewogICAgZnVuY3Rpb24gUnBjKCkgewogICAgICAgIHRoaXMubGFzdEhhbmRsZUlkXyA9IDA7CiAgICAgICAgdGhpcy5sYXN0V29ybGRJZF8gPSAwOwogICAgICAgIHRoaXMud29ybGRzXyA9IG5ldyBNYXAoKTsKICAgICAgICB0aGlzLmlkVG9IYW5kbGVfID0gbmV3IE1hcCgpOwogICAgICAgIHRoaXMubGFzdE1lc3NhZ2VJZF8gPSAwOwogICAgICAgIHRoaXMuY2FsbGJhY2tzXyA9IG5ldyBNYXAoKTsKICAgICAgICB0aGlzLndvcmxkSWRfID0gIi4iOwogICAgICAgIHRoaXMuY29va2llUmVzcG9uc2VDYWxsYmFja3NfID0gbmV3IE1hcCgpOwogICAgICAgIHRoaXMuZGVidWdfID0gZmFsc2U7CiAgICB9CiAgICBScGMucHJvdG90eXBlLnBhcmFtcyA9IGZ1bmN0aW9uICgpIHsKICAgICAgICByZXR1cm4gdGhpcy53b3JsZFBhcmFtc187CiAgICB9OwogICAgUnBjLnByb3RvdHlwZS5jcmVhdGVXb3JsZCA9IGZ1bmN0aW9uICh0cmFuc3BvcnQpIHsKICAgICAgICB2YXIgX3RoaXMgPSB0aGlzOwogICAgICAgIHZhciBhcmdzID0gW107CiAgICAgICAgZm9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HRoaXMsIHRydWUpKTsKICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKGYpIHsKICAgICAgICAgICAgcmV0dXJuIF90aGlzLmNvb2tpZUNhbGxiYWNrXyA9IGY7CiAgICAgICAgfSkKICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKGFyZ3MpIHsgcmV0dXJuIGluaXRpYWxpemVyID8gaW5pdGlhbGl6ZXIuYXBwbHkodm9pZCAwLCBhcmdzKSA6IHVuZGVmaW5lZDsgfSkKICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKHJlc3BvbnNlKSB7CiAgICAgICAgICAgIHJldHVybiBfdGhpcy5zZW5kVG9QYXJlbnRfKHsKICAgICAgICAgICAgICAgIGNvb2tpZVJlc3BvbnNlOiB0cnVlLAogICAgICAgICAgICAgICAgd29ybGRJZDogX3RoaXMud29ybGRJZF8sCiAgICAgICAgICAgICAgICByOiBfdGhpcy53cmFwXyhyZXNwb25zZSksCiAgICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgfTsKICAgIFJwYy5wcm90b3R5cGUuaGFuZGxlID0gZnVuY3Rpb24gKG9iamVjdCkgewogICAgICAgIGlmICghb2JqZWN0KSB7CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ2FuIG9ubHkgY3JlYXRlIGhhbmRsZXMgZm9yIG9iamVjdHMiKTsKICAgICAgICB9CiAgICAgICAgaWYgKHR5cGVvZiBvYmplY3QgPT09ICJvYmplY3QiICYmIGhhbmRsZVN5bWJvbCBpbiBvYmplY3QpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW4gbm90IHJldHVybiBoYW5kbGUgdG8gaGFuZGxlLiIpOwogICAgICAgIH0KICAgICAgICB2YXIgZGVzY3JpcHRvciA9IHRoaXMuZGVzY3JpYmVfKG9iamVjdCk7CiAgICAgICAgdmFyIGFkZHJlc3MgPSBbCiAgICAgICAgICAgIHRoaXMud29ybGRJZF8sCiAgICAgICAgICAgIGRlc2NyaXB0b3IubmFtZSArICIjIiArICgrK3RoaXMubGFzdEhhbmRsZUlkXyksCiAgICAgICAgXTsKICAgICAgICB2YXIgaGFuZGxlID0gbmV3IEhhbmRsZShhZGRyZXNzLCBhZGRyZXNzLCBkZXNjcmlwdG9yLCB0aGlzKTsKICAgICAgICBoYW5kbGUub2JqZWN0XyA9IG9iamVjdDsKICAgICAgICB0aGlzLmlkVG9IYW5kbGVfLnNldChhZGRyZXNzWzFdLCBoYW5kbGUpOwogICAgICAgIHJldHVybiBoYW5kbGUucHJveHkoKTsKICAgIH07CiAgICBScGMucHJvdG90eXBlLm9iamVjdCA9IGZ1bmN0aW9uIChwcm94eSkgewogICAgICAgIHJldHVybiBwcm94eVtoYW5kbGVTeW1ib2xdLm9iamVjdF8gfHwgbnVsbDsKICAgIH07CiAgICBScGMucHJvdG90eXBlLmRpc3Bvc2UgPSBmdW5jdGlvbiAocHJveHkpIHsKICAgICAgICB2YXIgaGFuZGxlID0gcHJveHlbaGFuZGxlU3ltYm9sXTsKICAgICAgICBpZiAoIWhhbmRsZS5vYmplY3RfKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ2FuIG9ubHkgZGlwb3NlIGhhbmRsZSB0aGF0IHdhcyBleHBsaWNpdGx5IGNyZWF0ZWQgd2l0aCBycGMuaGFuZGxlKCkiKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5pZFRvSGFuZGxlXy5kZWxldGUoaGFuZGxlLmFkZHJlc3NfWzFdKTsKICAgIH07CiAgICBScGMucHJvdG90eXBlLmRlc2NyaWJlXyA9IGZ1bmN0aW9uIChvKSB7CiAgICAgICAgaWYgKHR5cGVvZiBvID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgIHJldHVybiB7IGlzRnVuYzogdHJ1ZSB9OwogICAgICAgIH0KICAgICAgICByZXR1cm4geyBuYW1lOiBvLmNvbnN0cnVjdG9yLm5hbWUgfTsKICAgIH07CiAgICBScGMucHJvdG90eXBlLndyYXBfID0gZnVuY3Rpb24gKHBhcmFtLCBtYXhEZXB0aCkgewogICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgaWYgKG1heERlcHRoID09PSB2b2lkIDApIHsgbWF4RGVwdGggPSAxMDAwOyB9CiAgICAgICAgaWYgKCFtYXhEZXB0aCkgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIk9iamVjdCByZWZlcmVuY2UgY2hhaW4gaXMgdG9vIGxvbmciKTsKICAgICAgICB9CiAgICAgICAgbWF4RGVwdGgtLTsKICAgICAgICBpZiAoIXBhcmFtKSB7CiAgICAgICAgICAgIHJldHVybiBwYXJhbTsKICAgICAgICB9CiAgICAgICAgaWYgKHBhcmFtW2hhbmRsZVN5bWJvbF0pIHsKICAgICAgICAgICAgdmFyIGhhbmRsZSA9IHBhcmFtW2hhbmRsZVN5bWJvbF07CiAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICBfX3JwY19hX186IGhhbmRsZS5hZGRyZXNzXywKICAgICAgICAgICAgICAgIGRlc2NyaXB0b3I6IGhhbmRsZS5kZXNjcmlwdG9yXywKICAgICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgaWYgKHBhcmFtIGluc3RhbmNlb2YgQXJyYXkpIHsKICAgICAgICAgICAgcmV0dXJuIHBhcmFtLm1hcChmdW5jdGlvbiAoaXRlbSkgeyByZXR1cm4gX3RoaXMud3JhcF8oaXRlbSwgbWF4RGVwdGgpOyB9KTsKICAgICAgICB9CiAgICAgICAgaWYgKHR5cGVvZiBwYXJhbSA9PT0gIm9iamVjdCIpIHsKICAgICAgICAgICAgdmFyIHJlc3VsdCA9IHt9OwogICAgICAgICAgICBmb3IgKHZhciBrZXkgaW4gcGFyYW0pIHsKICAgICAgICAgICAgICAgIHJlc3VsdFtrZXldID0gdGhpcy53cmFwXyhwYXJhbVtrZXldLCBtYXhEZXB0aCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhcmFtOwogICAgfTsKICAgIFJwYy5wcm90b3R5cGUudW53cmFwXyA9IGZ1bmN0aW9uIChwYXJhbSkgewogICAgICAgIHZhciBfdGhpcyA9IHRoaXM7CiAgICAgICAgaWYgKCFwYXJhbSkgewogICAgICAgICAgICByZXR1cm4gcGFyYW07CiAgICAgICAgfQogICAgICAgIGlmIChwYXJhbS5fX3JwY19hX18pIHsKICAgICAgICAgICAgdmFyIGhhbmRsZV8xID0gdGhpcy5jcmVhdGVIYW5kbGVfKHBhcmFtLl9fcnBjX2FfXywgcGFyYW0uZGVzY3JpcHRvcik7CiAgICAgICAgICAgIGlmIChoYW5kbGVfMS5kZXNjcmlwdG9yXy5pc0Z1bmMpIHsKICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGFyZ3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBfaSA9IDA7IF9pIDwgYXJndW1lbnRzLmxlbmd0aDsgX2krKykgewogICAgICAgICAgICAgICAgICAgICAgICBhcmdzW19pXSA9IGFyZ3VtZW50c1tfaV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYW5kbGVfMS5jYWxsTWV0aG9kXy5hcHBseShoYW5kbGVfMSwgX19zcHJlYWRBcnJheXMoWyJjYWxsIl0sIGFyZ3MpKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGhhbmRsZV8xLnByb3h5KCk7CiAgICAgICAgfQogICAgICAgIGlmIChwYXJhbSBpbnN0YW5jZW9mIEFycmF5KSB7CiAgICAgICAgICAgIHJldHVybiBwYXJhbS5tYXAoZnVuY3Rpb24gKGl0ZW0pIHsgcmV0dXJuIF90aGlzLnVud3JhcF8oaXRlbSk7IH0pOwogICAgICAgIH0KICAgICAgICBpZiAodHlwZW9mIHBhcmFtID09PSAib2JqZWN0IikgewogICAgICAgICAgICB2YXIgcmVzdWx0ID0ge307CiAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBwYXJhbSkgewogICAgICAgICAgICAgICAgcmVzdWx0W2tleV0gPSB0aGlzLnVud3JhcF8ocGFyYW1ba2V5XSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhcmFtOwogICAgfTsKICAgIFJwYy5wcm90b3R5cGUuY3JlYXRlSGFuZGxlXyA9IGZ1bmN0aW9uIChhZGRyZXNzLCBkZXNjcmlwdG9yKSB7CiAgICAgICAgaWYgKGFkZHJlc3NbMF0gPT09IHRoaXMud29ybGRJZF8pIHsKICAgICAgICAgICAgdmFyIGV4aXN0aW5nID0gdGhpcy5pZFRvSGFuZGxlXy5nZXQoYWRkcmVzc1sxXSk7CiAgICAgICAgICAgIGlmIChleGlzdGluZykgewogICAgICAgICAgICAgICAgcmV0dXJuIGV4aXN0aW5nOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHZhciBsb2NhbEFkZHJlc3MgPSBbCiAgICAgICAgICAgIHRoaXMud29ybGRJZF8sCiAgICAgICAgICAgIGRlc2NyaXB0b3IubmFtZSArICIjIiArICgrK3RoaXMubGFzdEhhbmRsZUlkXyksCiAgICAgICAgXTsKICAgICAgICByZXR1cm4gbmV3IEhhbmRsZShsb2NhbEFkZHJlc3MsIGFkZHJlc3MsIGRlc2NyaXB0b3IsIHRoaXMpOwogICAgfTsKICAgIFJwYy5wcm90b3R5cGUuc2VuZENvbW1hbmRfID0gZnVuY3Rpb24gKHRvLCBmcm9tLCBtZXNzYWdlKSB7CiAgICAgICAgdmFyIF90aGlzID0gdGhpczsKICAgICAgICB2YXIgcGF5bG9hZCA9IHsKICAgICAgICAgICAgdG86IHRvLAogICAgICAgICAgICBmcm9tOiBmcm9tLAogICAgICAgICAgICBtZXNzYWdlOiBtZXNzYWdlLAogICAgICAgICAgICBpZDogKyt0aGlzLmxhc3RNZXNzYWdlSWRfLAogICAgICAgIH07CiAgICAgICAgaWYgKHRoaXMuZGVidWdfKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKCJcblNFTkQiLCBwYXlsb2FkKTsKICAgICAgICB9CiAgICAgICAgdmFyIHJlc3VsdCA9IG5ldyBQcm9taXNlKGZ1bmN0aW9uIChmdWxmaWxsLCByZWplY3QpIHsKICAgICAgICAgICAgcmV0dXJuIF90aGlzLmNhbGxiYWNrc18uc2V0KHBheWxvYWQuaWQsIHsgZnVsZmlsbDogZnVsZmlsbCwgcmVqZWN0OiByZWplY3QgfSk7CiAgICAgICAgfSk7CiAgICAgICAgdGhpcy5yb3V0ZU1lc3NhZ2VfKGZhbHNlLCBwYXlsb2FkKTsKICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgfTsKICAgIFJwYy5wcm90b3R5cGUucm91dGVNZXNzYWdlXyA9IGZ1bmN0aW9uIChmcm9tUGFyZW50LCBwYXlsb2FkKSB7CiAgICAgICAgaWYgKHRoaXMuZGVidWdfKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKCJcblJPVVRFWyIgKyB0aGlzLndvcmxkSWRfICsgIl0iLCBwYXlsb2FkKTsKICAgICAgICB9CiAgICAgICAgaWYgKGlzQ29va2llUGF5bG9hZChwYXlsb2FkKSkgewogICAgICAgICAgICB0aGlzLndvcmxkSWRfID0gcGF5bG9hZC53b3JsZElkOwogICAgICAgICAgICB0aGlzLmNvb2tpZUNhbGxiYWNrXyh0aGlzLnVud3JhcF8ocGF5bG9hZC5hcmdzKSk7CiAgICAgICAgICAgIHRoaXMuY29va2llQ2FsbGJhY2tfID0gbnVsbDsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAoaXNDb29raWVSZXNwb25zZShwYXlsb2FkKSkgewogICAgICAgICAgICB2YXIgY2FsbGJhY2sgPSB0aGlzLmNvb2tpZVJlc3BvbnNlQ2FsbGJhY2tzXy5nZXQocGF5bG9hZC53b3JsZElkKTsKICAgICAgICAgICAgdGhpcy5jb29raWVSZXNwb25zZUNhbGxiYWNrc18uZGVsZXRlKHBheWxvYWQud29ybGRJZCk7CiAgICAgICAgICAgIGNhbGxiYWNrKHsgcmVzdWx0OiB0aGlzLnVud3JhcF8ocGF5bG9hZC5yKSwgd29ybGRJZDogcGF5bG9hZC53b3JsZElkIH0pOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGlmICghZnJvbVBhcmVudCAmJiAhdGhpcy5pc0FjdGl2ZVdvcmxkXyhwYXlsb2FkLmZyb21bMF0pKSB7CiAgICAgICAgICAgIGlmICh0aGlzLmRlYnVnXykgewogICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkRST1AgT04gVEhFIEZMT09SIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAocGF5bG9hZC50b1swXSA9PT0gdGhpcy53b3JsZElkXykgewogICAgICAgICAgICBpZiAodGhpcy5kZWJ1Z18pIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJST1VURUQgVE8gU0VMRiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHRoaXMuZGlzcGF0Y2hNZXNzYWdlTG9jYWxseV8ocGF5bG9hZCk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgZm9yICh2YXIgX2kgPSAwLCBfYSA9IHRoaXMud29ybGRzXzsgX2kgPCBfYS5sZW5ndGg7IF9pKyspIHsKICAgICAgICAgICAgdmFyIF9iID0gX2FbX2ldLCB3b3JsZElkID0gX2JbMF0sIHdvcmxkU2VuZCA9IF9iWzFdOwogICAgICAgICAgICBpZiAocGF5bG9hZC50b1swXS5zdGFydHNXaXRoKHdvcmxkSWQpKSB7CiAgICAgICAgICAgICAgICBpZiAodGhpcy5kZWJ1Z18pIHsKICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygiUk9VVEVEIFRPIENISUxEICIgKyB3b3JsZElkKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdvcmxkU2VuZChwYXlsb2FkKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAocGF5bG9hZC50b1swXS5zdGFydHNXaXRoKHRoaXMud29ybGRJZF8pKSB7CiAgICAgICAgICAgIGlmICh0aGlzLmRlYnVnXykgewogICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkRST1AgT04gVEhFIEZMT09SIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5kZWJ1Z18pIHsKICAgICAgICAgICAgY29uc29sZS5sb2coIlJPVVRFRCBUTyBQQVJFTlQiKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5zZW5kVG9QYXJlbnRfKHBheWxvYWQpOwogICAgfTsKICAgIFJwYy5wcm90b3R5cGUuaXNBY3RpdmVXb3JsZF8gPSBmdW5jdGlvbiAod29ybGRJZCkgewogICAgICAgIGlmICh0aGlzLndvcmxkSWRfID09PSB3b3JsZElkKSB7CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBmb3IgKHZhciBfaSA9IDAsIF9hID0gdGhpcy53b3JsZHNfLmtleXMoKTsgX2kgPCBfYS5sZW5ndGg7IF9pKyspIHsKICAgICAgICAgICAgdmFyIHdpZCA9IF9hW19pXTsKICAgICAgICAgICAgaWYgKHdvcmxkSWQuc3RhcnRzV2l0aCh3aWQpKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9OwogICAgUnBjLnByb3RvdHlwZS5kaXNwYXRjaE1lc3NhZ2VMb2NhbGx5XyA9IGZ1bmN0aW9uIChwYXlsb2FkKSB7CiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIFByb21pc2UsIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgdmFyIF9hLCBmdWxmaWxsLCByZWplY3QsIG1lc3NhZ2UsIGhhbmRsZSwgX2IsIGVfMTsKICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIGZ1bmN0aW9uIChfYykgewogICAgICAgICAgICAgICAgc3dpdGNoIChfYy5sYWJlbCkgewogICAgICAgICAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVidWdfKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygiXG5ESVNQQVRDSCIsIHBheWxvYWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc1Jlc3BvbnNlKHBheWxvYWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfYSA9IHRoaXMuY2FsbGJhY2tzXy5nZXQocGF5bG9hZC5yaWQpLCBmdWxmaWxsID0gX2EuZnVsZmlsbCwgcmVqZWN0ID0gX2EucmVqZWN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWxsYmFja3NfLmRlbGV0ZShwYXlsb2FkLnJpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF5bG9hZC5lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihwYXlsb2FkLmUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bGZpbGwocGF5bG9hZC5yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMl07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb206IHBheWxvYWQudG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByaWQ6IHBheWxvYWQuaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bzogcGF5bG9hZC5mcm9tLAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGUgPSB0aGlzLmlkVG9IYW5kbGVfLmdldChwYXlsb2FkLnRvWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEhaGFuZGxlKSByZXR1cm4gWzMsIDFdOwogICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlLmUgPSAiT2JqZWN0IGhhcyBiZWVuIGRpcG9zZWQuIjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFszLCA0XTsKICAgICAgICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICAgICAgICAgIF9jLnRyeXMucHVzaChbMSwgMywgLCA0XSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9iID0gbWVzc2FnZTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFs0LCBoYW5kbGUuZGlzcGF0Y2hNZXNzYWdlXyhwYXlsb2FkLm1lc3NhZ2UpXTsKICAgICAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgICAgIF9iLnIgPSBfYy5zZW50KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMywgNF07CiAgICAgICAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgICAgICAgICBlXzEgPSBfYy5zZW50KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UuZSA9IGVfMS50b1N0cmluZygpICsgIlxuIiArIGVfMS5zdGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFszLCA0XTsKICAgICAgICAgICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucm91dGVNZXNzYWdlXyhmYWxzZSwgbWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMl07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgfTsKICAgIHJldHVybiBScGM7Cn0oKSk7CmV4cG9ydHMuZGVmYXVsdCA9IG5ldyBScGMoKTsK";