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C,GAC7N,IAAK7D,OAAOC,UAAU6Y,eAAejW,MAAM7B,EAAEyV,QAAS,CAAC,cAAe,MAAM,IAAItQ,EAAejB,EAAEI,iBAAkB,uDACnH,OAAO,IAAI4Z,GAAWle,EAAEyV,QAAQ0I,UAAWtb,GAF0I,CAGrLlD,EAAGZ,GAAIY,GACT,OAAOsH,EAAIjI,OAAO2hB,OAAO,CACvB1C,gBAAiBpb,GAChBoE,GAAIpH,EAAEwrD,aAAapkD,GAAIpH,IACzB,UAAU40D,sBAAqB,KAAM,QAAgB3yD,EAAG,QAAS9B,IACpE,QAAgB8B,EAAG,QAAS,WAhB7B","sources":["webpack://berrylanding/./node_modules/@firebase/firestore/dist/index.esm2017.js"],"sourcesContent":["import _construct from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/construct.js\";\nimport _get from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/get.js\";\nimport _slicedToArray from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";\nimport _wrapNativeSuper from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js\";\nimport _asyncToGenerator from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport _inherits from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/inherits.js\";\nimport _possibleConstructorReturn from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js\";\nimport _getPrototypeOf from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js\";\nimport _toConsumableArray from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js\";\nimport _classCallCheck from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/classCallCheck.js\";\nimport _createClass from \"F:/Work/Abo soltan/accounting-lp/node_modules/@babel/runtime/helpers/esm/createClass.js\";\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e141) { throw _e141; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e142) { didErr = true; err = _e142; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nimport _regeneratorRuntime from \"F:\\\\Work\\\\Abo soltan\\\\accounting-lp\\\\node_modules\\\\@babel\\\\runtime\\\\regenerator\\\\index.js\";\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nimport { _registerComponent, registerVersion, _getProvider, getApp, _removeServiceInstance, SDK_VERSION } from '@firebase/app';\nimport { Component } from '@firebase/component';\nimport { Logger, LogLevel } from '@firebase/logger';\nimport { FirebaseError, createMockUserToken, getModularInstance, deepEqual, getDefaultEmulatorHostnameAndPort, getUA, isIndexedDBAvailable, isSafari } from '@firebase/util';\nimport { Integer, XhrIo, EventType, ErrorCode, createWebChannelTransport, getStatEventTarget, WebChannel, Event, Stat, Md5 } from '@firebase/webchannel-wrapper';\nvar w = \"@firebase/firestore\";\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Simple wrapper around a nullable UID. Mostly exists to make code more\n * readable.\n */\n\nvar User = /*#__PURE__*/function () {\n function User(e) {\n _classCallCheck(this, User);\n\n this.uid = e;\n }\n\n _createClass(User, [{\n key: \"isAuthenticated\",\n value: function isAuthenticated() {\n return null != this.uid;\n }\n /**\n * Returns a key representing this user, suitable for inclusion in a\n * dictionary.\n */\n\n }, {\n key: \"toKey\",\n value: function toKey() {\n return this.isAuthenticated() ? \"uid:\" + this.uid : \"anonymous-user\";\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e.uid === this.uid;\n }\n }]);\n\n return User;\n}();\n/** A user with a null UID. */\n\n\nUser.UNAUTHENTICATED = new User(null), // TODO(mikelehen): Look into getting a proper uid-equivalent for\n// non-FirebaseAuth providers.\nUser.GOOGLE_CREDENTIALS = new User(\"google-credentials-uid\"), User.FIRST_PARTY = new User(\"first-party-uid\"), User.MOCK_USER = new User(\"mock-user\");\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nvar S = \"10.8.0\";\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nvar b = new Logger(\"@firebase/firestore\"); // Helper methods are needed because variables can't be exported as read/write\n\nfunction __PRIVATE_getLogLevel() {\n return b.logLevel;\n}\n/**\n * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).\n *\n * @param logLevel - The verbosity you set for activity and error logging. Can\n * be any of the following values:\n *\n * \n */\n\n\nfunction setLogLevel(e) {\n b.setLogLevel(e);\n}\n\nfunction __PRIVATE_logDebug(e) {\n if (b.logLevel <= LogLevel.DEBUG) {\n for (var _len = arguments.length, t = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n t[_key - 1] = arguments[_key];\n }\n\n var n = t.map(__PRIVATE_argToString);\n b.debug.apply(b, [\"Firestore (\".concat(S, \"): \").concat(e)].concat(_toConsumableArray(n)));\n }\n}\n\nfunction __PRIVATE_logError(e) {\n if (b.logLevel <= LogLevel.ERROR) {\n for (var _len2 = arguments.length, t = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n t[_key2 - 1] = arguments[_key2];\n }\n\n var n = t.map(__PRIVATE_argToString);\n b.error.apply(b, [\"Firestore (\".concat(S, \"): \").concat(e)].concat(_toConsumableArray(n)));\n }\n}\n/**\n * @internal\n */\n\n\nfunction __PRIVATE_logWarn(e) {\n if (b.logLevel <= LogLevel.WARN) {\n for (var _len3 = arguments.length, t = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n t[_key3 - 1] = arguments[_key3];\n }\n\n var n = t.map(__PRIVATE_argToString);\n b.warn.apply(b, [\"Firestore (\".concat(S, \"): \").concat(e)].concat(_toConsumableArray(n)));\n }\n}\n/**\n * Converts an additional log parameter to a string representation.\n */\n\n\nfunction __PRIVATE_argToString(e) {\n if (\"string\" == typeof e) return e;\n\n try {\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n /** Formats an object as a JSON string, suitable for logging. */\n return function __PRIVATE_formatJSON(e) {\n return JSON.stringify(e);\n }(e);\n } catch (t) {\n // Converting to JSON failed, just log the object directly\n return e;\n }\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Unconditionally fails, throwing an Error with the given message.\n * Messages are stripped in production builds.\n *\n * Returns `never` and can be used in expressions:\n * @example\n * let futureVar = fail('not implemented yet');\n */\n\n\nfunction fail() {\n var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"Unexpected state\";\n // Log the failure in addition to throw an exception, just in case the\n // exception is swallowed.\n var t = \"FIRESTORE (\".concat(S, \") INTERNAL ASSERTION FAILED: \") + e; // NOTE: We don't use FirestoreError here because these are internal failures\n // that cannot be handled by the user. (Also it would create a circular\n // dependency between the error and assert modules which doesn't work.)\n\n throw __PRIVATE_logError(t), new Error(t);\n}\n/**\n * Fails if the given assertion condition is false, throwing an Error with the\n * given message if it did.\n *\n * Messages are stripped in production builds.\n */\n\n\nfunction __PRIVATE_hardAssert(e, t) {\n e || fail();\n}\n/**\n * Fails if the given assertion condition is false, throwing an Error with the\n * given message if it did.\n *\n * The code of callsites invoking this function are stripped out in production\n * builds. Any side-effects of code within the debugAssert() invocation will not\n * happen in this case.\n *\n * @internal\n */\n\n\nfunction __PRIVATE_debugAssert(e, t) {\n e || fail();\n}\n/**\n * Casts `obj` to `T`. In non-production builds, verifies that `obj` is an\n * instance of `T` before casting.\n */\n\n\nfunction __PRIVATE_debugCast(e, // eslint-disable-next-line @typescript-eslint/no-explicit-any\nt) {\n return e;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar D = {\n // Causes are copied from:\n // https://github.com/grpc/grpc/blob/bceec94ea4fc5f0085d81235d8e1c06798dc341a/include/grpc%2B%2B/impl/codegen/status_code_enum.h\n\n /** Not an error; returned on success. */\n OK: \"ok\",\n\n /** The operation was cancelled (typically by the caller). */\n CANCELLED: \"cancelled\",\n\n /** Unknown error or an error from a different error domain. */\n UNKNOWN: \"unknown\",\n\n /**\n * Client specified an invalid argument. Note that this differs from\n * FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are\n * problematic regardless of the state of the system (e.g., a malformed file\n * name).\n */\n INVALID_ARGUMENT: \"invalid-argument\",\n\n /**\n * Deadline expired before operation could complete. For operations that\n * change the state of the system, this error may be returned even if the\n * operation has completed successfully. For example, a successful response\n * from a server could have been delayed long enough for the deadline to\n * expire.\n */\n DEADLINE_EXCEEDED: \"deadline-exceeded\",\n\n /** Some requested entity (e.g., file or directory) was not found. */\n NOT_FOUND: \"not-found\",\n\n /**\n * Some entity that we attempted to create (e.g., file or directory) already\n * exists.\n */\n ALREADY_EXISTS: \"already-exists\",\n\n /**\n * The caller does not have permission to execute the specified operation.\n * PERMISSION_DENIED must not be used for rejections caused by exhausting\n * some resource (use RESOURCE_EXHAUSTED instead for those errors).\n * PERMISSION_DENIED must not be used if the caller can not be identified\n * (use UNAUTHENTICATED instead for those errors).\n */\n PERMISSION_DENIED: \"permission-denied\",\n\n /**\n * The request does not have valid authentication credentials for the\n * operation.\n */\n UNAUTHENTICATED: \"unauthenticated\",\n\n /**\n * Some resource has been exhausted, perhaps a per-user quota, or perhaps the\n * entire file system is out of space.\n */\n RESOURCE_EXHAUSTED: \"resource-exhausted\",\n\n /**\n * Operation was rejected because the system is not in a state required for\n * the operation's execution. For example, directory to be deleted may be\n * non-empty, an rmdir operation is applied to a non-directory, etc.\n *\n * A litmus test that may help a service implementor in deciding\n * between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:\n * (a) Use UNAVAILABLE if the client can retry just the failing call.\n * (b) Use ABORTED if the client should retry at a higher-level\n * (e.g., restarting a read-modify-write sequence).\n * (c) Use FAILED_PRECONDITION if the client should not retry until\n * the system state has been explicitly fixed. E.g., if an \"rmdir\"\n * fails because the directory is non-empty, FAILED_PRECONDITION\n * should be returned since the client should not retry unless\n * they have first fixed up the directory by deleting files from it.\n * (d) Use FAILED_PRECONDITION if the client performs conditional\n * REST Get/Update/Delete on a resource and the resource on the\n * server does not match the condition. E.g., conflicting\n * read-modify-write on the same resource.\n */\n FAILED_PRECONDITION: \"failed-precondition\",\n\n /**\n * The operation was aborted, typically due to a concurrency issue like\n * sequencer check failures, transaction aborts, etc.\n *\n * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED,\n * and UNAVAILABLE.\n */\n ABORTED: \"aborted\",\n\n /**\n * Operation was attempted past the valid range. E.g., seeking or reading\n * past end of file.\n *\n * Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed\n * if the system state changes. For example, a 32-bit file system will\n * generate INVALID_ARGUMENT if asked to read at an offset that is not in the\n * range [0,2^32-1], but it will generate OUT_OF_RANGE if asked to read from\n * an offset past the current file size.\n *\n * There is a fair bit of overlap between FAILED_PRECONDITION and\n * OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error)\n * when it applies so that callers who are iterating through a space can\n * easily look for an OUT_OF_RANGE error to detect when they are done.\n */\n OUT_OF_RANGE: \"out-of-range\",\n\n /** Operation is not implemented or not supported/enabled in this service. */\n UNIMPLEMENTED: \"unimplemented\",\n\n /**\n * Internal errors. Means some invariants expected by underlying System has\n * been broken. If you see one of these errors, Something is very broken.\n */\n INTERNAL: \"internal\",\n\n /**\n * The service is currently unavailable. This is a most likely a transient\n * condition and may be corrected by retrying with a backoff.\n *\n * See litmus test above for deciding between FAILED_PRECONDITION, ABORTED,\n * and UNAVAILABLE.\n */\n UNAVAILABLE: \"unavailable\",\n\n /** Unrecoverable data loss or corruption. */\n DATA_LOSS: \"data-loss\"\n};\n/** An error returned by a Firestore operation. */\n\nvar FirestoreError = /*#__PURE__*/function (_FirebaseError) {\n _inherits(FirestoreError, _FirebaseError);\n\n var _super = _createSuper(FirestoreError);\n\n /** @hideconstructor */\n function FirestoreError(\n /**\n * The backend error code associated with this error.\n */\n e,\n /**\n * A custom error description.\n */\n t) {\n var _this;\n\n _classCallCheck(this, FirestoreError);\n\n _this = _super.call(this, e, t), _this.code = e, _this.message = t, // HACK: We write a toString property directly because Error is not a real\n // class and so inheritance does not work correctly. We could alternatively\n // do the same \"back-door inheritance\" trick that FirebaseError does.\n _this.toString = function () {\n return \"\".concat(_this.name, \": [code=\").concat(_this.code, \"]: \").concat(_this.message);\n };\n return _this;\n }\n\n return _createClass(FirestoreError);\n}(FirebaseError);\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_Deferred = /*#__PURE__*/_createClass(function __PRIVATE_Deferred() {\n var _this2 = this;\n\n _classCallCheck(this, __PRIVATE_Deferred);\n\n this.promise = new Promise(function (e, t) {\n _this2.resolve = e, _this2.reject = t;\n });\n});\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_OAuthToken = /*#__PURE__*/_createClass(function __PRIVATE_OAuthToken(e, t) {\n _classCallCheck(this, __PRIVATE_OAuthToken);\n\n this.user = t, this.type = \"OAuth\", this.headers = new Map(), this.headers.set(\"Authorization\", \"Bearer \".concat(e));\n});\n/**\n * A CredentialsProvider that always yields an empty token.\n * @internal\n */\n\n\nvar __PRIVATE_EmptyAuthCredentialsProvider = /*#__PURE__*/function () {\n function __PRIVATE_EmptyAuthCredentialsProvider() {\n _classCallCheck(this, __PRIVATE_EmptyAuthCredentialsProvider);\n }\n\n _createClass(__PRIVATE_EmptyAuthCredentialsProvider, [{\n key: \"getToken\",\n value: function getToken() {\n return Promise.resolve(null);\n }\n }, {\n key: \"invalidateToken\",\n value: function invalidateToken() {}\n }, {\n key: \"start\",\n value: function start(e, t) {\n // Fire with initial user.\n e.enqueueRetryable(function () {\n return t(User.UNAUTHENTICATED);\n });\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {}\n }]);\n\n return __PRIVATE_EmptyAuthCredentialsProvider;\n}();\n/**\n * A CredentialsProvider that always returns a constant token. Used for\n * emulator token mocking.\n */\n\n\nvar __PRIVATE_EmulatorAuthCredentialsProvider = /*#__PURE__*/function () {\n function __PRIVATE_EmulatorAuthCredentialsProvider(e) {\n _classCallCheck(this, __PRIVATE_EmulatorAuthCredentialsProvider);\n\n this.token = e,\n /**\n * Stores the listener registered with setChangeListener()\n * This isn't actually necessary since the UID never changes, but we use this\n * to verify the listen contract is adhered to in tests.\n */\n this.changeListener = null;\n }\n\n _createClass(__PRIVATE_EmulatorAuthCredentialsProvider, [{\n key: \"getToken\",\n value: function getToken() {\n return Promise.resolve(this.token);\n }\n }, {\n key: \"invalidateToken\",\n value: function invalidateToken() {}\n }, {\n key: \"start\",\n value: function start(e, t) {\n var _this3 = this;\n\n this.changeListener = t, // Fire with initial user.\n e.enqueueRetryable(function () {\n return t(_this3.token.user);\n });\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {\n this.changeListener = null;\n }\n }]);\n\n return __PRIVATE_EmulatorAuthCredentialsProvider;\n}();\n\nvar __PRIVATE_FirebaseAuthCredentialsProvider = /*#__PURE__*/function () {\n function __PRIVATE_FirebaseAuthCredentialsProvider(e) {\n _classCallCheck(this, __PRIVATE_FirebaseAuthCredentialsProvider);\n\n this.t = e,\n /** Tracks the current User. */\n this.currentUser = User.UNAUTHENTICATED,\n /**\n * Counter used to detect if the token changed while a getToken request was\n * outstanding.\n */\n this.i = 0, this.forceRefresh = !1, this.auth = null;\n }\n\n _createClass(__PRIVATE_FirebaseAuthCredentialsProvider, [{\n key: \"start\",\n value: function start(e, t) {\n var _this4 = this;\n\n var n = this.i; // A change listener that prevents double-firing for the same token change.\n\n var __PRIVATE_guardedChangeListener = function __PRIVATE_guardedChangeListener(e) {\n return _this4.i !== n ? (n = _this4.i, t(e)) : Promise.resolve();\n }; // A promise that can be waited on to block on the next token change.\n // This promise is re-created after each change.\n\n\n var r = new __PRIVATE_Deferred();\n\n this.o = function () {\n _this4.i++, _this4.currentUser = _this4.u(), r.resolve(), r = new __PRIVATE_Deferred(), e.enqueueRetryable(function () {\n return __PRIVATE_guardedChangeListener(_this4.currentUser);\n });\n };\n\n var __PRIVATE_awaitNextToken = function __PRIVATE_awaitNextToken() {\n var t = r;\n e.enqueueRetryable( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return t.promise;\n\n case 2:\n _context.next = 4;\n return __PRIVATE_guardedChangeListener(_this4.currentUser);\n\n case 4:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee);\n })));\n },\n __PRIVATE_registerAuth = function __PRIVATE_registerAuth(e) {\n __PRIVATE_logDebug(\"FirebaseAuthCredentialsProvider\", \"Auth detected\"), _this4.auth = e, _this4.auth.addAuthTokenListener(_this4.o), __PRIVATE_awaitNextToken();\n };\n\n this.t.onInit(function (e) {\n return __PRIVATE_registerAuth(e);\n }), // Our users can initialize Auth right after Firestore, so we give it\n // a chance to register itself with the component framework before we\n // determine whether to start up in unauthenticated mode.\n setTimeout(function () {\n if (!_this4.auth) {\n var _e2 = _this4.t.getImmediate({\n optional: !0\n });\n\n _e2 ? __PRIVATE_registerAuth(_e2) : ( // If auth is still not available, proceed with `null` user\n __PRIVATE_logDebug(\"FirebaseAuthCredentialsProvider\", \"Auth not yet detected\"), r.resolve(), r = new __PRIVATE_Deferred());\n }\n }, 0), __PRIVATE_awaitNextToken();\n }\n }, {\n key: \"getToken\",\n value: function getToken() {\n var _this5 = this;\n\n // Take note of the current value of the tokenCounter so that this method\n // can fail (with an ABORTED error) if there is a token change while the\n // request is outstanding.\n var e = this.i,\n t = this.forceRefresh;\n return this.forceRefresh = !1, this.auth ? this.auth.getToken(t).then(function (t) {\n return (// Cancel the request since the token changed while the request was\n // outstanding so the response is potentially for a previous user (which\n // user, we can't be sure).\n _this5.i !== e ? (__PRIVATE_logDebug(\"FirebaseAuthCredentialsProvider\", \"getToken aborted due to token change.\"), _this5.getToken()) : t ? (__PRIVATE_hardAssert(\"string\" == typeof t.accessToken), new __PRIVATE_OAuthToken(t.accessToken, _this5.currentUser)) : null\n );\n }) : Promise.resolve(null);\n }\n }, {\n key: \"invalidateToken\",\n value: function invalidateToken() {\n this.forceRefresh = !0;\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {\n this.auth && this.auth.removeAuthTokenListener(this.o);\n } // Auth.getUid() can return null even with a user logged in. It is because\n // getUid() is synchronous, but the auth code populating Uid is asynchronous.\n // This method should only be called in the AuthTokenListener callback\n // to guarantee to get the actual user.\n\n }, {\n key: \"u\",\n value: function u() {\n var e = this.auth && this.auth.getUid();\n return __PRIVATE_hardAssert(null === e || \"string\" == typeof e), new User(e);\n }\n }]);\n\n return __PRIVATE_FirebaseAuthCredentialsProvider;\n}();\n/*\n * FirstPartyToken provides a fresh token each time its value\n * is requested, because if the token is too old, requests will be rejected.\n * Technically this may no longer be necessary since the SDK should gracefully\n * recover from unauthenticated errors (see b/33147818 for context), but it's\n * safer to keep the implementation as-is.\n */\n\n\nvar __PRIVATE_FirstPartyToken = /*#__PURE__*/function () {\n function __PRIVATE_FirstPartyToken(e, t, n) {\n _classCallCheck(this, __PRIVATE_FirstPartyToken);\n\n this.l = e, this.h = t, this.P = n, this.type = \"FirstParty\", this.user = User.FIRST_PARTY, this.I = new Map();\n }\n /**\n * Gets an authorization token, using a provided factory function, or return\n * null.\n */\n\n\n _createClass(__PRIVATE_FirstPartyToken, [{\n key: \"T\",\n value: function T() {\n return this.P ? this.P() : null;\n }\n }, {\n key: \"headers\",\n get: function get() {\n this.I.set(\"X-Goog-AuthUser\", this.l); // Use array notation to prevent minification\n\n var e = this.T();\n return e && this.I.set(\"Authorization\", e), this.h && this.I.set(\"X-Goog-Iam-Authorization-Token\", this.h), this.I;\n }\n }]);\n\n return __PRIVATE_FirstPartyToken;\n}();\n/*\n * Provides user credentials required for the Firestore JavaScript SDK\n * to authenticate the user, using technique that is only available\n * to applications hosted by Google.\n */\n\n\nvar __PRIVATE_FirstPartyAuthCredentialsProvider = /*#__PURE__*/function () {\n function __PRIVATE_FirstPartyAuthCredentialsProvider(e, t, n) {\n _classCallCheck(this, __PRIVATE_FirstPartyAuthCredentialsProvider);\n\n this.l = e, this.h = t, this.P = n;\n }\n\n _createClass(__PRIVATE_FirstPartyAuthCredentialsProvider, [{\n key: \"getToken\",\n value: function getToken() {\n return Promise.resolve(new __PRIVATE_FirstPartyToken(this.l, this.h, this.P));\n }\n }, {\n key: \"start\",\n value: function start(e, t) {\n // Fire with initial uid.\n e.enqueueRetryable(function () {\n return t(User.FIRST_PARTY);\n });\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {}\n }, {\n key: \"invalidateToken\",\n value: function invalidateToken() {}\n }]);\n\n return __PRIVATE_FirstPartyAuthCredentialsProvider;\n}();\n\nvar AppCheckToken = /*#__PURE__*/_createClass(function AppCheckToken(e) {\n _classCallCheck(this, AppCheckToken);\n\n this.value = e, this.type = \"AppCheck\", this.headers = new Map(), e && e.length > 0 && this.headers.set(\"x-firebase-appcheck\", this.value);\n});\n\nvar __PRIVATE_FirebaseAppCheckTokenProvider = /*#__PURE__*/function () {\n function __PRIVATE_FirebaseAppCheckTokenProvider(e) {\n _classCallCheck(this, __PRIVATE_FirebaseAppCheckTokenProvider);\n\n this.A = e, this.forceRefresh = !1, this.appCheck = null, this.R = null;\n }\n\n _createClass(__PRIVATE_FirebaseAppCheckTokenProvider, [{\n key: \"start\",\n value: function start(e, t) {\n var _this6 = this;\n\n var onTokenChanged = function onTokenChanged(e) {\n null != e.error && __PRIVATE_logDebug(\"FirebaseAppCheckTokenProvider\", \"Error getting App Check token; using placeholder token instead. Error: \".concat(e.error.message));\n var n = e.token !== _this6.R;\n return _this6.R = e.token, __PRIVATE_logDebug(\"FirebaseAppCheckTokenProvider\", \"Received \".concat(n ? \"new\" : \"existing\", \" token.\")), n ? t(e.token) : Promise.resolve();\n };\n\n this.o = function (t) {\n e.enqueueRetryable(function () {\n return onTokenChanged(t);\n });\n };\n\n var __PRIVATE_registerAppCheck = function __PRIVATE_registerAppCheck(e) {\n __PRIVATE_logDebug(\"FirebaseAppCheckTokenProvider\", \"AppCheck detected\"), _this6.appCheck = e, _this6.appCheck.addTokenListener(_this6.o);\n };\n\n this.A.onInit(function (e) {\n return __PRIVATE_registerAppCheck(e);\n }), // Our users can initialize AppCheck after Firestore, so we give it\n // a chance to register itself with the component framework.\n setTimeout(function () {\n if (!_this6.appCheck) {\n var _e3 = _this6.A.getImmediate({\n optional: !0\n });\n\n _e3 ? __PRIVATE_registerAppCheck(_e3) : // If AppCheck is still not available, proceed without it.\n __PRIVATE_logDebug(\"FirebaseAppCheckTokenProvider\", \"AppCheck not yet detected\");\n }\n }, 0);\n }\n }, {\n key: \"getToken\",\n value: function getToken() {\n var _this7 = this;\n\n var e = this.forceRefresh;\n return this.forceRefresh = !1, this.appCheck ? this.appCheck.getToken(e).then(function (e) {\n return e ? (__PRIVATE_hardAssert(\"string\" == typeof e.token), _this7.R = e.token, new AppCheckToken(e.token)) : null;\n }) : Promise.resolve(null);\n }\n }, {\n key: \"invalidateToken\",\n value: function invalidateToken() {\n this.forceRefresh = !0;\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {\n this.appCheck && this.appCheck.removeTokenListener(this.o);\n }\n }]);\n\n return __PRIVATE_FirebaseAppCheckTokenProvider;\n}();\n/**\n * An AppCheck token provider that always yields an empty token.\n * @internal\n */\n\n\nvar __PRIVATE_EmptyAppCheckTokenProvider = /*#__PURE__*/function () {\n function __PRIVATE_EmptyAppCheckTokenProvider() {\n _classCallCheck(this, __PRIVATE_EmptyAppCheckTokenProvider);\n }\n\n _createClass(__PRIVATE_EmptyAppCheckTokenProvider, [{\n key: \"getToken\",\n value: function getToken() {\n return Promise.resolve(new AppCheckToken(\"\"));\n }\n }, {\n key: \"invalidateToken\",\n value: function invalidateToken() {}\n }, {\n key: \"start\",\n value: function start(e, t) {}\n }, {\n key: \"shutdown\",\n value: function shutdown() {}\n }]);\n\n return __PRIVATE_EmptyAppCheckTokenProvider;\n}();\n/**\n * Builds a CredentialsProvider depending on the type of\n * the credentials passed in.\n */\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Generates `nBytes` of random bytes.\n *\n * If `nBytes < 0` , an error will be thrown.\n */\n\n\nfunction __PRIVATE_randomBytes(e) {\n // Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.\n var t = // eslint-disable-next-line @typescript-eslint/no-explicit-any\n \"undefined\" != typeof self && (self.crypto || self.msCrypto),\n n = new Uint8Array(e);\n if (t && \"function\" == typeof t.getRandomValues) t.getRandomValues(n);else // Falls back to Math.random\n for (var _t = 0; _t < e; _t++) {\n n[_t] = Math.floor(256 * Math.random());\n }\n return n;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A utility class for generating unique alphanumeric IDs of a specified length.\n *\n * @internal\n * Exported internally for testing purposes.\n */\n\n\nvar __PRIVATE_AutoId = /*#__PURE__*/function () {\n function __PRIVATE_AutoId() {\n _classCallCheck(this, __PRIVATE_AutoId);\n }\n\n _createClass(__PRIVATE_AutoId, null, [{\n key: \"newId\",\n value: function newId() {\n // Alphanumeric characters\n var e = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\",\n t = Math.floor(256 / e.length) * e.length; // The largest byte value that is a multiple of `char.length`.\n\n var n = \"\";\n\n for (; n.length < 20;) {\n var r = __PRIVATE_randomBytes(40);\n\n for (var i = 0; i < r.length; ++i) {\n // Only accept values that are [0, maxMultiple), this ensures they can\n // be evenly mapped to indices of `chars` via a modulo operation.\n n.length < 20 && r[i] < t && (n += e.charAt(r[i] % e.length));\n }\n }\n\n return n;\n }\n }]);\n\n return __PRIVATE_AutoId;\n}();\n\nfunction __PRIVATE_primitiveComparator(e, t) {\n return e < t ? -1 : e > t ? 1 : 0;\n}\n/** Helper to compare arrays using isEqual(). */\n\n\nfunction __PRIVATE_arrayEquals(e, t, n) {\n return e.length === t.length && e.every(function (e, r) {\n return n(e, t[r]);\n });\n}\n/**\n * Returns the immediate lexicographically-following string. This is useful to\n * construct an inclusive range for indexeddb iterators.\n */\n\n\nfunction __PRIVATE_immediateSuccessor(e) {\n // Return the input string, with an additional NUL byte appended.\n return e + \"\\0\";\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// The earliest date supported by Firestore timestamps (0001-01-01T00:00:00Z).\n\n/**\n * A `Timestamp` represents a point in time independent of any time zone or\n * calendar, represented as seconds and fractions of seconds at nanosecond\n * resolution in UTC Epoch time.\n *\n * It is encoded using the Proleptic Gregorian Calendar which extends the\n * Gregorian calendar backwards to year one. It is encoded assuming all minutes\n * are 60 seconds long, i.e. leap seconds are \"smeared\" so that no leap second\n * table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to\n * 9999-12-31T23:59:59.999999999Z.\n *\n * For examples and further specifications, refer to the\n * {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.\n */\n\n\nvar Timestamp = /*#__PURE__*/function () {\n /**\n * Creates a new timestamp.\n *\n * @param seconds - The number of seconds of UTC time since Unix epoch\n * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n * 9999-12-31T23:59:59Z inclusive.\n * @param nanoseconds - The non-negative fractions of a second at nanosecond\n * resolution. Negative second values with fractions must still have\n * non-negative nanoseconds values that count forward in time. Must be\n * from 0 to 999,999,999 inclusive.\n */\n function Timestamp(\n /**\n * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.\n */\n e,\n /**\n * The fractions of a second at nanosecond resolution.*\n */\n t) {\n _classCallCheck(this, Timestamp);\n\n if (this.seconds = e, this.nanoseconds = t, t < 0) throw new FirestoreError(D.INVALID_ARGUMENT, \"Timestamp nanoseconds out of range: \" + t);\n if (t >= 1e9) throw new FirestoreError(D.INVALID_ARGUMENT, \"Timestamp nanoseconds out of range: \" + t);\n if (e < -62135596800) throw new FirestoreError(D.INVALID_ARGUMENT, \"Timestamp seconds out of range: \" + e); // This will break in the year 10,000.\n\n if (e >= 253402300800) throw new FirestoreError(D.INVALID_ARGUMENT, \"Timestamp seconds out of range: \" + e);\n }\n /**\n * Creates a new timestamp with the current date, with millisecond precision.\n *\n * @returns a new timestamp representing the current date.\n */\n\n\n _createClass(Timestamp, [{\n key: \"toDate\",\n value:\n /**\n * Converts a `Timestamp` to a JavaScript `Date` object. This conversion\n * causes a loss of precision since `Date` objects only support millisecond\n * precision.\n *\n * @returns JavaScript `Date` object representing the same point in time as\n * this `Timestamp`, with millisecond precision.\n */\n function toDate() {\n return new Date(this.toMillis());\n }\n /**\n * Converts a `Timestamp` to a numeric timestamp (in milliseconds since\n * epoch). This operation causes a loss of precision.\n *\n * @returns The point in time corresponding to this timestamp, represented as\n * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.\n */\n\n }, {\n key: \"toMillis\",\n value: function toMillis() {\n return 1e3 * this.seconds + this.nanoseconds / 1e6;\n }\n }, {\n key: \"_compareTo\",\n value: function _compareTo(e) {\n return this.seconds === e.seconds ? __PRIVATE_primitiveComparator(this.nanoseconds, e.nanoseconds) : __PRIVATE_primitiveComparator(this.seconds, e.seconds);\n }\n /**\n * Returns true if this `Timestamp` is equal to the provided one.\n *\n * @param other - The `Timestamp` to compare against.\n * @returns true if this `Timestamp` is equal to the provided one.\n */\n\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e.seconds === this.seconds && e.nanoseconds === this.nanoseconds;\n }\n /** Returns a textual representation of this `Timestamp`. */\n\n }, {\n key: \"toString\",\n value: function toString() {\n return \"Timestamp(seconds=\" + this.seconds + \", nanoseconds=\" + this.nanoseconds + \")\";\n }\n /** Returns a JSON-serializable representation of this `Timestamp`. */\n\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n seconds: this.seconds,\n nanoseconds: this.nanoseconds\n };\n }\n /**\n * Converts this object to a primitive string, which allows `Timestamp` objects\n * to be compared using the `>`, `<=`, `>=` and `>` operators.\n */\n\n }, {\n key: \"valueOf\",\n value: function valueOf() {\n // This method returns a string of the form . where\n // is translated to have a non-negative value and both \n // and are left-padded with zeroes to be a consistent length.\n // Strings with this format then have a lexiographical ordering that matches\n // the expected ordering. The translation is done to avoid having\n // a leading negative sign (i.e. a leading '-' character) in its string\n // representation, which would affect its lexiographical ordering.\n var e = this.seconds - -62135596800; // Note: Up to 12 decimal digits are required to represent all valid\n // 'seconds' values.\n\n return String(e).padStart(12, \"0\") + \".\" + String(this.nanoseconds).padStart(9, \"0\");\n }\n }], [{\n key: \"now\",\n value: function now() {\n return Timestamp.fromMillis(Date.now());\n }\n /**\n * Creates a new timestamp from the given date.\n *\n * @param date - The date to initialize the `Timestamp` from.\n * @returns A new `Timestamp` representing the same point in time as the given\n * date.\n */\n\n }, {\n key: \"fromDate\",\n value: function fromDate(e) {\n return Timestamp.fromMillis(e.getTime());\n }\n /**\n * Creates a new timestamp from the given number of milliseconds.\n *\n * @param milliseconds - Number of milliseconds since Unix epoch\n * 1970-01-01T00:00:00Z.\n * @returns A new `Timestamp` representing the same point in time as the given\n * number of milliseconds.\n */\n\n }, {\n key: \"fromMillis\",\n value: function fromMillis(e) {\n var t = Math.floor(e / 1e3),\n n = Math.floor(1e6 * (e - 1e3 * t));\n return new Timestamp(t, n);\n }\n }]);\n\n return Timestamp;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A version of a document in Firestore. This corresponds to the version\n * timestamp, such as update_time or read_time.\n */\n\n\nvar SnapshotVersion = /*#__PURE__*/function () {\n function SnapshotVersion(e) {\n _classCallCheck(this, SnapshotVersion);\n\n this.timestamp = e;\n }\n\n _createClass(SnapshotVersion, [{\n key: \"compareTo\",\n value: function compareTo(e) {\n return this.timestamp._compareTo(e.timestamp);\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return this.timestamp.isEqual(e.timestamp);\n }\n /** Returns a number representation of the version for use in spec tests. */\n\n }, {\n key: \"toMicroseconds\",\n value: function toMicroseconds() {\n // Convert to microseconds.\n return 1e6 * this.timestamp.seconds + this.timestamp.nanoseconds / 1e3;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return \"SnapshotVersion(\" + this.timestamp.toString() + \")\";\n }\n }, {\n key: \"toTimestamp\",\n value: function toTimestamp() {\n return this.timestamp;\n }\n }], [{\n key: \"fromTimestamp\",\n value: function fromTimestamp(e) {\n return new SnapshotVersion(e);\n }\n }, {\n key: \"min\",\n value: function min() {\n return new SnapshotVersion(new Timestamp(0, 0));\n }\n }, {\n key: \"max\",\n value: function max() {\n return new SnapshotVersion(new Timestamp(253402300799, 999999999));\n }\n }]);\n\n return SnapshotVersion;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Path represents an ordered sequence of string segments.\n */\n\n\nvar BasePath = /*#__PURE__*/function () {\n function BasePath(e, t, n) {\n _classCallCheck(this, BasePath);\n\n void 0 === t ? t = 0 : t > e.length && fail(), void 0 === n ? n = e.length - t : n > e.length - t && fail(), this.segments = e, this.offset = t, this.len = n;\n }\n\n _createClass(BasePath, [{\n key: \"length\",\n get: function get() {\n return this.len;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return 0 === BasePath.comparator(this, e);\n }\n }, {\n key: \"child\",\n value: function child(e) {\n var t = this.segments.slice(this.offset, this.limit());\n return e instanceof BasePath ? e.forEach(function (e) {\n t.push(e);\n }) : t.push(e), this.construct(t);\n }\n /** The index of one past the last segment of the path. */\n\n }, {\n key: \"limit\",\n value: function limit() {\n return this.offset + this.length;\n }\n }, {\n key: \"popFirst\",\n value: function popFirst(e) {\n return e = void 0 === e ? 1 : e, this.construct(this.segments, this.offset + e, this.length - e);\n }\n }, {\n key: \"popLast\",\n value: function popLast() {\n return this.construct(this.segments, this.offset, this.length - 1);\n }\n }, {\n key: \"firstSegment\",\n value: function firstSegment() {\n return this.segments[this.offset];\n }\n }, {\n key: \"lastSegment\",\n value: function lastSegment() {\n return this.get(this.length - 1);\n }\n }, {\n key: \"get\",\n value: function get(e) {\n return this.segments[this.offset + e];\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return 0 === this.length;\n }\n }, {\n key: \"isPrefixOf\",\n value: function isPrefixOf(e) {\n if (e.length < this.length) return !1;\n\n for (var t = 0; t < this.length; t++) {\n if (this.get(t) !== e.get(t)) return !1;\n }\n\n return !0;\n }\n }, {\n key: \"isImmediateParentOf\",\n value: function isImmediateParentOf(e) {\n if (this.length + 1 !== e.length) return !1;\n\n for (var t = 0; t < this.length; t++) {\n if (this.get(t) !== e.get(t)) return !1;\n }\n\n return !0;\n }\n }, {\n key: \"forEach\",\n value: function forEach(e) {\n for (var t = this.offset, n = this.limit(); t < n; t++) {\n e(this.segments[t]);\n }\n }\n }, {\n key: \"toArray\",\n value: function toArray() {\n return this.segments.slice(this.offset, this.limit());\n }\n }], [{\n key: \"comparator\",\n value: function comparator(e, t) {\n var n = Math.min(e.length, t.length);\n\n for (var r = 0; r < n; r++) {\n var _n = e.get(r),\n i = t.get(r);\n\n if (_n < i) return -1;\n if (_n > i) return 1;\n }\n\n return e.length < t.length ? -1 : e.length > t.length ? 1 : 0;\n }\n }]);\n\n return BasePath;\n}();\n/**\n * A slash-separated path for navigating resources (documents and collections)\n * within Firestore.\n *\n * @internal\n */\n\n\nvar ResourcePath = /*#__PURE__*/function (_BasePath) {\n _inherits(ResourcePath, _BasePath);\n\n var _super2 = _createSuper(ResourcePath);\n\n function ResourcePath() {\n _classCallCheck(this, ResourcePath);\n\n return _super2.apply(this, arguments);\n }\n\n _createClass(ResourcePath, [{\n key: \"construct\",\n value: function construct(e, t, n) {\n return new ResourcePath(e, t, n);\n }\n }, {\n key: \"canonicalString\",\n value: function canonicalString() {\n // NOTE: The client is ignorant of any path segments containing escape\n // sequences (e.g. __id123__) and just passes them through raw (they exist\n // for legacy reasons and should not be used frequently).\n return this.toArray().join(\"/\");\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.canonicalString();\n }\n /**\n * Returns a string representation of this path\n * where each path segment has been encoded with\n * `encodeURIComponent`.\n */\n\n }, {\n key: \"toUriEncodedString\",\n value: function toUriEncodedString() {\n return this.toArray().map(encodeURIComponent).join(\"/\");\n }\n /**\n * Creates a resource path from the given slash-delimited string. If multiple\n * arguments are provided, all components are combined. Leading and trailing\n * slashes from all components are ignored.\n */\n\n }], [{\n key: \"fromString\",\n value: function fromString() {\n // NOTE: The client is ignorant of any path segments containing escape\n // sequences (e.g. __id123__) and just passes them through raw (they exist\n // for legacy reasons and should not be used frequently).\n var t = [];\n\n for (var _len4 = arguments.length, e = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n e[_key4] = arguments[_key4];\n }\n\n for (var _i = 0, _e4 = e; _i < _e4.length; _i++) {\n var n = _e4[_i];\n if (n.indexOf(\"//\") >= 0) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid segment (\".concat(n, \"). Paths must not contain // in them.\")); // Strip leading and traling slashed.\n\n t.push.apply(t, _toConsumableArray(n.split(\"/\").filter(function (e) {\n return e.length > 0;\n })));\n }\n\n return new ResourcePath(t);\n }\n }, {\n key: \"emptyPath\",\n value: function emptyPath() {\n return new ResourcePath([]);\n }\n }]);\n\n return ResourcePath;\n}(BasePath);\n\nvar C = /^[_a-zA-Z][_a-zA-Z0-9]*$/;\n/**\n * A dot-separated path for navigating sub-objects within a document.\n * @internal\n */\n\nvar FieldPath$1 = /*#__PURE__*/function (_BasePath2) {\n _inherits(FieldPath$1, _BasePath2);\n\n var _super3 = _createSuper(FieldPath$1);\n\n function FieldPath$1() {\n _classCallCheck(this, FieldPath$1);\n\n return _super3.apply(this, arguments);\n }\n\n _createClass(FieldPath$1, [{\n key: \"construct\",\n value: function construct(e, t, n) {\n return new FieldPath$1(e, t, n);\n }\n /**\n * Returns true if the string could be used as a segment in a field path\n * without escaping.\n */\n\n }, {\n key: \"canonicalString\",\n value: function canonicalString() {\n return this.toArray().map(function (e) {\n return e = e.replace(/\\\\/g, \"\\\\\\\\\").replace(/`/g, \"\\\\`\"), FieldPath$1.isValidIdentifier(e) || (e = \"`\" + e + \"`\"), e;\n }).join(\".\");\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.canonicalString();\n }\n /**\n * Returns true if this field references the key of a document.\n */\n\n }, {\n key: \"isKeyField\",\n value: function isKeyField() {\n return 1 === this.length && \"__name__\" === this.get(0);\n }\n /**\n * The field designating the key of a document.\n */\n\n }], [{\n key: \"isValidIdentifier\",\n value: function isValidIdentifier(e) {\n return C.test(e);\n }\n }, {\n key: \"keyField\",\n value: function keyField() {\n return new FieldPath$1([\"__name__\"]);\n }\n /**\n * Parses a field string from the given server-formatted string.\n *\n * - Splitting the empty string is not allowed (for now at least).\n * - Empty segments within the string (e.g. if there are two consecutive\n * separators) are not allowed.\n *\n * TODO(b/37244157): we should make this more strict. Right now, it allows\n * non-identifier path components, even if they aren't escaped.\n */\n\n }, {\n key: \"fromServerFormat\",\n value: function fromServerFormat(e) {\n var t = [];\n var n = \"\",\n r = 0;\n\n var __PRIVATE_addCurrentSegment = function __PRIVATE_addCurrentSegment() {\n if (0 === n.length) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid field path (\".concat(e, \"). Paths must not be empty, begin with '.', end with '.', or contain '..'\"));\n t.push(n), n = \"\";\n };\n\n var i = !1;\n\n for (; r < e.length;) {\n var _t2 = e[r];\n\n if (\"\\\\\" === _t2) {\n if (r + 1 === e.length) throw new FirestoreError(D.INVALID_ARGUMENT, \"Path has trailing escape character: \" + e);\n var _t3 = e[r + 1];\n if (\"\\\\\" !== _t3 && \".\" !== _t3 && \"`\" !== _t3) throw new FirestoreError(D.INVALID_ARGUMENT, \"Path has invalid escape sequence: \" + e);\n n += _t3, r += 2;\n } else \"`\" === _t2 ? (i = !i, r++) : \".\" !== _t2 || i ? (n += _t2, r++) : (__PRIVATE_addCurrentSegment(), r++);\n }\n\n if (__PRIVATE_addCurrentSegment(), i) throw new FirestoreError(D.INVALID_ARGUMENT, \"Unterminated ` in path: \" + e);\n return new FieldPath$1(t);\n }\n }, {\n key: \"emptyPath\",\n value: function emptyPath() {\n return new FieldPath$1([]);\n }\n }]);\n\n return FieldPath$1;\n}(BasePath);\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @internal\n */\n\n\nvar DocumentKey = /*#__PURE__*/function () {\n function DocumentKey(e) {\n _classCallCheck(this, DocumentKey);\n\n this.path = e;\n }\n\n _createClass(DocumentKey, [{\n key: \"collectionGroup\",\n get: function get() {\n return this.path.popLast().lastSegment();\n }\n /** Returns true if the document is in the specified collectionId. */\n\n }, {\n key: \"hasCollectionId\",\n value: function hasCollectionId(e) {\n return this.path.length >= 2 && this.path.get(this.path.length - 2) === e;\n }\n /** Returns the collection group (i.e. the name of the parent collection) for this key. */\n\n }, {\n key: \"getCollectionGroup\",\n value: function getCollectionGroup() {\n return this.path.get(this.path.length - 2);\n }\n /** Returns the fully qualified path to the parent collection. */\n\n }, {\n key: \"getCollectionPath\",\n value: function getCollectionPath() {\n return this.path.popLast();\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return null !== e && 0 === ResourcePath.comparator(this.path, e.path);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.path.toString();\n }\n }], [{\n key: \"fromPath\",\n value: function fromPath(e) {\n return new DocumentKey(ResourcePath.fromString(e));\n }\n }, {\n key: \"fromName\",\n value: function fromName(e) {\n return new DocumentKey(ResourcePath.fromString(e).popFirst(5));\n }\n }, {\n key: \"empty\",\n value: function empty() {\n return new DocumentKey(ResourcePath.emptyPath());\n }\n }, {\n key: \"comparator\",\n value: function comparator(e, t) {\n return ResourcePath.comparator(e.path, t.path);\n }\n }, {\n key: \"isDocumentKey\",\n value: function isDocumentKey(e) {\n return e.length % 2 == 0;\n }\n /**\n * Creates and returns a new document key with the given segments.\n *\n * @param segments - The segments of the path to the document\n * @returns A new instance of DocumentKey\n */\n\n }, {\n key: \"fromSegments\",\n value: function fromSegments(e) {\n return new DocumentKey(new ResourcePath(e.slice()));\n }\n }]);\n\n return DocumentKey;\n}();\n/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The initial mutation batch id for each index. Gets updated during index\n * backfill.\n */\n\n/**\n * An index definition for field indexes in Firestore.\n *\n * Every index is associated with a collection. The definition contains a list\n * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or\n * `CONTAINS` for ArrayContains/ArrayContainsAny queries).\n *\n * Unlike the backend, the SDK does not differentiate between collection or\n * collection group-scoped indices. Every index can be used for both single\n * collection and collection group queries.\n */\n\n\nvar FieldIndex = /*#__PURE__*/_createClass(function FieldIndex(\n/**\n * The index ID. Returns -1 if the index ID is not available (e.g. the index\n * has not yet been persisted).\n */\ne,\n/** The collection ID this index applies to. */\nt,\n/** The field segments for this index. */\nn,\n/** Shows how up-to-date the index is for the current user. */\nr) {\n _classCallCheck(this, FieldIndex);\n\n this.indexId = e, this.collectionGroup = t, this.fields = n, this.indexState = r;\n});\n/** An ID for an index that has not yet been added to persistence. */\n\n/** Returns the ArrayContains/ArrayContainsAny segment for this index. */\n\n\nfunction __PRIVATE_fieldIndexGetArraySegment(e) {\n return e.fields.find(function (e) {\n return 2\n /* IndexKind.CONTAINS */\n === e.kind;\n });\n}\n/** Returns all directional (ascending/descending) segments for this index. */\n\n\nfunction __PRIVATE_fieldIndexGetDirectionalSegments(e) {\n return e.fields.filter(function (e) {\n return 2\n /* IndexKind.CONTAINS */\n !== e.kind;\n });\n}\n/**\n * Returns the order of the document key component for the given index.\n *\n * PORTING NOTE: This is only used in the Web IndexedDb implementation.\n */\n\n/**\n * Compares indexes by collection group and segments. Ignores update time and\n * index ID.\n */\n\n\nfunction __PRIVATE_fieldIndexSemanticComparator(e, t) {\n var n = __PRIVATE_primitiveComparator(e.collectionGroup, t.collectionGroup);\n\n if (0 !== n) return n;\n\n for (var r = 0; r < Math.min(e.fields.length, t.fields.length); ++r) {\n if (n = __PRIVATE_indexSegmentComparator(e.fields[r], t.fields[r]), 0 !== n) return n;\n }\n\n return __PRIVATE_primitiveComparator(e.fields.length, t.fields.length);\n}\n/** Returns a debug representation of the field index */\n\n\nFieldIndex.UNKNOWN_ID = -1;\n/** An index component consisting of field path and index type. */\n\nvar IndexSegment = /*#__PURE__*/_createClass(function IndexSegment(\n/** The field path of the component. */\ne,\n/** The fields sorting order. */\nt) {\n _classCallCheck(this, IndexSegment);\n\n this.fieldPath = e, this.kind = t;\n});\n\nfunction __PRIVATE_indexSegmentComparator(e, t) {\n var n = FieldPath$1.comparator(e.fieldPath, t.fieldPath);\n return 0 !== n ? n : __PRIVATE_primitiveComparator(e.kind, t.kind);\n}\n/**\n * Stores the \"high water mark\" that indicates how updated the Index is for the\n * current user.\n */\n\n\nvar IndexState = /*#__PURE__*/function () {\n function IndexState(\n /**\n * Indicates when the index was last updated (relative to other indexes).\n */\n e,\n /** The the latest indexed read time, document and batch id. */\n t) {\n _classCallCheck(this, IndexState);\n\n this.sequenceNumber = e, this.offset = t;\n }\n /** The state of an index that has not yet been backfilled. */\n\n\n _createClass(IndexState, null, [{\n key: \"empty\",\n value: function empty() {\n return new IndexState(0, IndexOffset.min());\n }\n }]);\n\n return IndexState;\n}();\n/**\n * Creates an offset that matches all documents with a read time higher than\n * `readTime`.\n */\n\n\nfunction __PRIVATE_newIndexOffsetSuccessorFromReadTime(e, t) {\n // We want to create an offset that matches all documents with a read time\n // greater than the provided read time. To do so, we technically need to\n // create an offset for `(readTime, MAX_DOCUMENT_KEY)`. While we could use\n // Unicode codepoints to generate MAX_DOCUMENT_KEY, it is much easier to use\n // `(readTime + 1, DocumentKey.empty())` since `> DocumentKey.empty()` matches\n // all valid document IDs.\n var n = e.toTimestamp().seconds,\n r = e.toTimestamp().nanoseconds + 1,\n i = SnapshotVersion.fromTimestamp(1e9 === r ? new Timestamp(n + 1, 0) : new Timestamp(n, r));\n return new IndexOffset(i, DocumentKey.empty(), t);\n}\n/** Creates a new offset based on the provided document. */\n\n\nfunction __PRIVATE_newIndexOffsetFromDocument(e) {\n return new IndexOffset(e.readTime, e.key, -1);\n}\n/**\n * Stores the latest read time, document and batch ID that were processed for an\n * index.\n */\n\n\nvar IndexOffset = /*#__PURE__*/function () {\n function IndexOffset(\n /**\n * The latest read time version that has been indexed by Firestore for this\n * field index.\n */\n e,\n /**\n * The key of the last document that was indexed for this query. Use\n * `DocumentKey.empty()` if no document has been indexed.\n */\n t,\n /*\n * The largest mutation batch id that's been processed by Firestore.\n */\n n) {\n _classCallCheck(this, IndexOffset);\n\n this.readTime = e, this.documentKey = t, this.largestBatchId = n;\n }\n /** Returns an offset that sorts before all regular offsets. */\n\n\n _createClass(IndexOffset, null, [{\n key: \"min\",\n value: function min() {\n return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), -1);\n }\n /** Returns an offset that sorts after all regular offsets. */\n\n }, {\n key: \"max\",\n value: function max() {\n return new IndexOffset(SnapshotVersion.max(), DocumentKey.empty(), -1);\n }\n }]);\n\n return IndexOffset;\n}();\n\nfunction __PRIVATE_indexOffsetComparator(e, t) {\n var n = e.readTime.compareTo(t.readTime);\n return 0 !== n ? n : (n = DocumentKey.comparator(e.documentKey, t.documentKey), 0 !== n ? n : __PRIVATE_primitiveComparator(e.largestBatchId, t.largestBatchId));\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar v = \"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.\";\n/**\n * A base class representing a persistence transaction, encapsulating both the\n * transaction's sequence numbers as well as a list of onCommitted listeners.\n *\n * When you call Persistence.runTransaction(), it will create a transaction and\n * pass it to your callback. You then pass it to any method that operates\n * on persistence.\n */\n\nvar PersistenceTransaction = /*#__PURE__*/function () {\n function PersistenceTransaction() {\n _classCallCheck(this, PersistenceTransaction);\n\n this.onCommittedListeners = [];\n }\n\n _createClass(PersistenceTransaction, [{\n key: \"addOnCommittedListener\",\n value: function addOnCommittedListener(e) {\n this.onCommittedListeners.push(e);\n }\n }, {\n key: \"raiseOnCommittedEvent\",\n value: function raiseOnCommittedEvent() {\n this.onCommittedListeners.forEach(function (e) {\n return e();\n });\n }\n }]);\n\n return PersistenceTransaction;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Verifies the error thrown by a LocalStore operation. If a LocalStore\n * operation fails because the primary lease has been taken by another client,\n * we ignore the error (the persistence layer will immediately call\n * `applyPrimaryLease` to propagate the primary state change). All other errors\n * are re-thrown.\n *\n * @param err - An error returned by a LocalStore operation.\n * @returns A Promise that resolves after we recovered, or the original error.\n */\n\n\nfunction __PRIVATE_ignoreIfPrimaryLeaseLoss(_x) {\n return _PRIVATE_ignoreIfPrimaryLeaseLoss.apply(this, arguments);\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * PersistencePromise is essentially a re-implementation of Promise except\n * it has a .next() method instead of .then() and .next() and .catch() callbacks\n * are executed synchronously when a PersistencePromise resolves rather than\n * asynchronously (Promise implementations use setImmediate() or similar).\n *\n * This is necessary to interoperate with IndexedDB which will automatically\n * commit transactions if control is returned to the event loop without\n * synchronously initiating another operation on the transaction.\n *\n * NOTE: .then() and .catch() only allow a single consumer, unlike normal\n * Promises.\n */\n\n\nfunction _PRIVATE_ignoreIfPrimaryLeaseLoss() {\n _PRIVATE_ignoreIfPrimaryLeaseLoss = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee77(e) {\n return _regeneratorRuntime.wrap(function _callee77$(_context77) {\n while (1) {\n switch (_context77.prev = _context77.next) {\n case 0:\n if (!(e.code !== D.FAILED_PRECONDITION || e.message !== v)) {\n _context77.next = 2;\n break;\n }\n\n throw e;\n\n case 2:\n __PRIVATE_logDebug(\"LocalStore\", \"Unexpectedly lost primary lease\");\n\n case 3:\n case \"end\":\n return _context77.stop();\n }\n }\n }, _callee77);\n }));\n return _PRIVATE_ignoreIfPrimaryLeaseLoss.apply(this, arguments);\n}\n\nvar PersistencePromise = /*#__PURE__*/function () {\n function PersistencePromise(e) {\n var _this8 = this;\n\n _classCallCheck(this, PersistencePromise);\n\n // NOTE: next/catchCallback will always point to our own wrapper functions,\n // not the user's raw next() or catch() callbacks.\n this.nextCallback = null, this.catchCallback = null, // When the operation resolves, we'll set result or error and mark isDone.\n this.result = void 0, this.error = void 0, this.isDone = !1, // Set to true when .then() or .catch() are called and prevents additional\n // chaining.\n this.callbackAttached = !1, e(function (e) {\n _this8.isDone = !0, _this8.result = e, _this8.nextCallback && // value should be defined unless T is Void, but we can't express\n // that in the type system.\n _this8.nextCallback(e);\n }, function (e) {\n _this8.isDone = !0, _this8.error = e, _this8.catchCallback && _this8.catchCallback(e);\n });\n }\n\n _createClass(PersistencePromise, [{\n key: \"catch\",\n value: function _catch(e) {\n return this.next(void 0, e);\n }\n }, {\n key: \"next\",\n value: function next(e, t) {\n var _this9 = this;\n\n return this.callbackAttached && fail(), this.callbackAttached = !0, this.isDone ? this.error ? this.wrapFailure(t, this.error) : this.wrapSuccess(e, this.result) : new PersistencePromise(function (n, r) {\n _this9.nextCallback = function (t) {\n _this9.wrapSuccess(e, t).next(n, r);\n }, _this9.catchCallback = function (e) {\n _this9.wrapFailure(t, e).next(n, r);\n };\n });\n }\n }, {\n key: \"toPromise\",\n value: function toPromise() {\n var _this10 = this;\n\n return new Promise(function (e, t) {\n _this10.next(e, t);\n });\n }\n }, {\n key: \"wrapUserFunction\",\n value: function wrapUserFunction(e) {\n try {\n var t = e();\n return t instanceof PersistencePromise ? t : PersistencePromise.resolve(t);\n } catch (e) {\n return PersistencePromise.reject(e);\n }\n }\n }, {\n key: \"wrapSuccess\",\n value: function wrapSuccess(e, t) {\n return e ? this.wrapUserFunction(function () {\n return e(t);\n }) : PersistencePromise.resolve(t);\n }\n }, {\n key: \"wrapFailure\",\n value: function wrapFailure(e, t) {\n return e ? this.wrapUserFunction(function () {\n return e(t);\n }) : PersistencePromise.reject(t);\n }\n }], [{\n key: \"resolve\",\n value: function resolve(e) {\n return new PersistencePromise(function (t, n) {\n t(e);\n });\n }\n }, {\n key: \"reject\",\n value: function reject(e) {\n return new PersistencePromise(function (t, n) {\n n(e);\n });\n }\n }, {\n key: \"waitFor\",\n value: function waitFor( // Accept all Promise types in waitFor().\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n e) {\n return new PersistencePromise(function (t, n) {\n var r = 0,\n i = 0,\n s = !1;\n e.forEach(function (e) {\n ++r, e.next(function () {\n ++i, s && i === r && t();\n }, function (e) {\n return n(e);\n });\n }), s = !0, i === r && t();\n });\n }\n /**\n * Given an array of predicate functions that asynchronously evaluate to a\n * boolean, implements a short-circuiting `or` between the results. Predicates\n * will be evaluated until one of them returns `true`, then stop. The final\n * result will be whether any of them returned `true`.\n */\n\n }, {\n key: \"or\",\n value: function or(e) {\n var t = PersistencePromise.resolve(!1);\n\n var _iterator = _createForOfIteratorHelper(e),\n _step;\n\n try {\n var _loop = function _loop() {\n var n = _step.value;\n t = t.next(function (e) {\n return e ? PersistencePromise.resolve(e) : n();\n });\n };\n\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n _loop();\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return t;\n }\n }, {\n key: \"forEach\",\n value: function forEach(e, t) {\n var _this11 = this;\n\n var n = [];\n return e.forEach(function (e, r) {\n n.push(t.call(_this11, e, r));\n }), this.waitFor(n);\n }\n /**\n * Concurrently map all array elements through asynchronous function.\n */\n\n }, {\n key: \"mapArray\",\n value: function mapArray(e, t) {\n return new PersistencePromise(function (n, r) {\n var i = e.length,\n s = new Array(i);\n var o = 0;\n\n var _loop2 = function _loop2(_) {\n var a = _;\n t(e[a]).next(function (e) {\n s[a] = e, ++o, o === i && n(s);\n }, function (e) {\n return r(e);\n });\n };\n\n for (var _ = 0; _ < i; _++) {\n _loop2(_);\n }\n });\n }\n /**\n * An alternative to recursive PersistencePromise calls, that avoids\n * potential memory problems from unbounded chains of promises.\n *\n * The `action` will be called repeatedly while `condition` is true.\n */\n\n }, {\n key: \"doWhile\",\n value: function doWhile(e, t) {\n return new PersistencePromise(function (n, r) {\n var process = function process() {\n !0 === e() ? t().next(function () {\n process();\n }, r) : n();\n };\n\n process();\n });\n }\n }]);\n\n return PersistencePromise;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// References to `window` are guarded by SimpleDb.isAvailable()\n\n/* eslint-disable no-restricted-globals */\n\n/**\n * Wraps an IDBTransaction and exposes a store() method to get a handle to a\n * specific object store.\n */\n\n\nvar __PRIVATE_SimpleDbTransaction = /*#__PURE__*/function () {\n function __PRIVATE_SimpleDbTransaction(e, t) {\n var _this12 = this;\n\n _classCallCheck(this, __PRIVATE_SimpleDbTransaction);\n\n this.action = e, this.transaction = t, this.aborted = !1,\n /**\n * A `Promise` that resolves with the result of the IndexedDb transaction.\n */\n this.V = new __PRIVATE_Deferred(), this.transaction.oncomplete = function () {\n _this12.V.resolve();\n }, this.transaction.onabort = function () {\n t.error ? _this12.V.reject(new __PRIVATE_IndexedDbTransactionError(e, t.error)) : _this12.V.resolve();\n }, this.transaction.onerror = function (t) {\n var n = __PRIVATE_checkForAndReportiOSError(t.target.error);\n\n _this12.V.reject(new __PRIVATE_IndexedDbTransactionError(e, n));\n };\n }\n\n _createClass(__PRIVATE_SimpleDbTransaction, [{\n key: \"m\",\n get: function get() {\n return this.V.promise;\n }\n }, {\n key: \"abort\",\n value: function abort(e) {\n e && this.V.reject(e), this.aborted || (__PRIVATE_logDebug(\"SimpleDb\", \"Aborting transaction:\", e ? e.message : \"Client-initiated abort\"), this.aborted = !0, this.transaction.abort());\n }\n }, {\n key: \"g\",\n value: function g() {\n // If the browser supports V3 IndexedDB, we invoke commit() explicitly to\n // speed up index DB processing if the event loop remains blocks.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n var e = this.transaction;\n this.aborted || \"function\" != typeof e.commit || e.commit();\n }\n /**\n * Returns a SimpleDbStore for the specified store. All\n * operations performed on the SimpleDbStore happen within the context of this\n * transaction and it cannot be used anymore once the transaction is\n * completed.\n *\n * Note that we can't actually enforce that the KeyType and ValueType are\n * correct, but they allow type safety through the rest of the consuming code.\n */\n\n }, {\n key: \"store\",\n value: function store(e) {\n var t = this.transaction.objectStore(e);\n return new __PRIVATE_SimpleDbStore(t);\n }\n }], [{\n key: \"open\",\n value: function open(e, t, n, r) {\n try {\n return new __PRIVATE_SimpleDbTransaction(t, e.transaction(r, n));\n } catch (e) {\n throw new __PRIVATE_IndexedDbTransactionError(t, e);\n }\n }\n }]);\n\n return __PRIVATE_SimpleDbTransaction;\n}();\n/**\n * Provides a wrapper around IndexedDb with a simplified interface that uses\n * Promise-like return values to chain operations. Real promises cannot be used\n * since .then() continuations are executed asynchronously (e.g. via\n * .setImmediate), which would cause IndexedDB to end the transaction.\n * See PersistencePromise for more details.\n */\n\n\nvar __PRIVATE_SimpleDb = /*#__PURE__*/function () {\n /*\n * Creates a new SimpleDb wrapper for IndexedDb database `name`.\n *\n * Note that `version` must not be a downgrade. IndexedDB does not support\n * downgrading the schema version. We currently do not support any way to do\n * versioning outside of IndexedDB's versioning mechanism, as only\n * version-upgrade transactions are allowed to do things like create\n * objectstores.\n */\n function __PRIVATE_SimpleDb(e, t, n) {\n _classCallCheck(this, __PRIVATE_SimpleDb);\n\n this.name = e, this.version = t, this.p = n; // NOTE: According to https://bugs.webkit.org/show_bug.cgi?id=197050, the\n // bug we're checking for should exist in iOS >= 12.2 and < 13, but for\n // whatever reason it's much harder to hit after 12.2 so we only proactively\n // log on 12.2.\n\n 12.2 === __PRIVATE_SimpleDb.S(getUA()) && __PRIVATE_logError(\"Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.\");\n }\n /** Deletes the specified database. */\n\n\n _createClass(__PRIVATE_SimpleDb, [{\n key: \"O\",\n value:\n /**\n * Opens the specified database, creating or upgrading it if necessary.\n */\n function () {\n var _O = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(e) {\n var _this13 = this;\n\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.t0 = this.db;\n\n if (_context2.t0) {\n _context2.next = 6;\n break;\n }\n\n __PRIVATE_logDebug(\"SimpleDb\", \"Opening database:\", this.name);\n\n _context2.next = 5;\n return new Promise(function (t, n) {\n // TODO(mikelehen): Investigate browser compatibility.\n // https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB\n // suggests IE9 and older WebKit browsers handle upgrade\n // differently. They expect setVersion, as described here:\n // https://developer.mozilla.org/en-US/docs/Web/API/IDBVersionChangeRequest/setVersion\n var r = indexedDB.open(_this13.name, _this13.version);\n r.onsuccess = function (e) {\n var n = e.target.result;\n t(n);\n }, r.onblocked = function () {\n n(new __PRIVATE_IndexedDbTransactionError(e, \"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed.\"));\n }, r.onerror = function (t) {\n var r = t.target.error;\n \"VersionError\" === r.name ? n(new FirestoreError(D.FAILED_PRECONDITION, \"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.\")) : \"InvalidStateError\" === r.name ? n(new FirestoreError(D.FAILED_PRECONDITION, \"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: \" + r)) : n(new __PRIVATE_IndexedDbTransactionError(e, r));\n }, r.onupgradeneeded = function (e) {\n __PRIVATE_logDebug(\"SimpleDb\", 'Database \"' + _this13.name + '\" requires upgrade from version:', e.oldVersion);\n\n var t = e.target.result;\n\n _this13.p.N(t, r.transaction, e.oldVersion, _this13.version).next(function () {\n __PRIVATE_logDebug(\"SimpleDb\", \"Database upgrade to version \" + _this13.version + \" complete\");\n });\n };\n });\n\n case 5:\n this.db = _context2.sent;\n\n case 6:\n this.B && (this.db.onversionchange = function (e) {\n return _this13.B(e);\n });\n return _context2.abrupt(\"return\", this.db);\n\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n\n function O(_x2) {\n return _O.apply(this, arguments);\n }\n\n return O;\n }()\n }, {\n key: \"L\",\n value: function L(e) {\n this.B = e, this.db && (this.db.onversionchange = function (t) {\n return e(t);\n });\n }\n }, {\n key: \"runTransaction\",\n value: function () {\n var _runTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(e, t, n, r) {\n var _this14 = this;\n\n var i, s, _ret, _t4, _n2;\n\n return _regeneratorRuntime.wrap(function _callee4$(_context4) {\n while (1) {\n switch (_context4.prev = _context4.next) {\n case 0:\n i = \"readonly\" === t;\n s = 0;\n\n case 2:\n ++s;\n _context4.prev = 3;\n return _context4.delegateYield( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {\n var t, s;\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return _this14.O(e);\n\n case 2:\n _this14.db = _context3.sent;\n t = __PRIVATE_SimpleDbTransaction.open(_this14.db, e, i ? \"readonly\" : \"readwrite\", n), s = r(t).next(function (e) {\n return t.g(), e;\n }).catch(function (e) {\n return (// Abort the transaction if there was an error.\n t.abort(e), PersistencePromise.reject(e)\n );\n }).toPromise(); // As noted above, errors are propagated by aborting the transaction. So\n // we swallow any error here to avoid the browser logging it as unhandled.\n\n s.catch(function () {});\n _context3.next = 7;\n return t.m;\n\n case 7:\n _context3.t0 = s;\n return _context3.abrupt(\"return\", {\n v: _context3.t0\n });\n\n case 9:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3);\n })(), \"t0\", 5);\n\n case 5:\n _ret = _context4.t0;\n\n if (!(typeof _ret === \"object\")) {\n _context4.next = 8;\n break;\n }\n\n return _context4.abrupt(\"return\", _ret.v);\n\n case 8:\n _context4.next = 15;\n break;\n\n case 10:\n _context4.prev = 10;\n _context4.t1 = _context4[\"catch\"](3);\n _t4 = _context4.t1, _n2 = \"FirebaseError\" !== _t4.name && s < 3; // TODO(schmidt-sebastian): We could probably be smarter about this and\n // not retry exceptions that are likely unrecoverable (such as quota\n // exceeded errors).\n // Note: We cannot use an instanceof check for FirestoreException, since the\n // exception is wrapped in a generic error by our async/await handling.\n\n if (!(__PRIVATE_logDebug(\"SimpleDb\", \"Transaction failed with error:\", _t4.message, \"Retrying:\", _n2), this.close(), !_n2)) {\n _context4.next = 15;\n break;\n }\n\n return _context4.abrupt(\"return\", Promise.reject(_t4));\n\n case 15:\n _context4.next = 2;\n break;\n\n case 17:\n case \"end\":\n return _context4.stop();\n }\n }\n }, _callee4, this, [[3, 10]]);\n }));\n\n function runTransaction(_x3, _x4, _x5, _x6) {\n return _runTransaction.apply(this, arguments);\n }\n\n return runTransaction;\n }()\n }, {\n key: \"close\",\n value: function close() {\n this.db && this.db.close(), this.db = void 0;\n }\n }], [{\n key: \"delete\",\n value: function _delete(e) {\n return __PRIVATE_logDebug(\"SimpleDb\", \"Removing database:\", e), __PRIVATE_wrapRequest(window.indexedDB.deleteDatabase(e)).toPromise();\n }\n /** Returns true if IndexedDB is available in the current environment. */\n\n }, {\n key: \"D\",\n value: function D() {\n if (!isIndexedDBAvailable()) return !1;\n if (__PRIVATE_SimpleDb.C()) return !0; // We extensively use indexed array values and compound keys,\n // which IE and Edge do not support. However, they still have indexedDB\n // defined on the window, so we need to check for them here and make sure\n // to return that persistence is not enabled for those browsers.\n // For tracking support of this feature, see here:\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/status/indexeddbarraysandmultientrysupport/\n // Check the UA string to find out the browser.\n\n var e = getUA(),\n t = __PRIVATE_SimpleDb.S(e),\n n = 0 < t && t < 10,\n r = __PRIVATE_SimpleDb.v(e),\n i = 0 < r && r < 4.5; // IE 10\n // ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';\n // IE 11\n // ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';\n // Edge\n // ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML,\n // like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';\n // iOS Safari: Disable for users running iOS version < 10.\n\n\n return !(e.indexOf(\"MSIE \") > 0 || e.indexOf(\"Trident/\") > 0 || e.indexOf(\"Edge/\") > 0 || n || i);\n }\n /**\n * Returns true if the backing IndexedDB store is the Node IndexedDBShim\n * (see https://github.com/axemclion/IndexedDBShim).\n */\n\n }, {\n key: \"C\",\n value: function C() {\n var e;\n return \"undefined\" != typeof process && \"YES\" === (null === (e = process.__PRIVATE_env) || void 0 === e ? void 0 : e.F);\n }\n /** Helper to get a typed SimpleDbStore from a transaction. */\n\n }, {\n key: \"M\",\n value: function M(e, t) {\n return e.store(t);\n } // visible for testing\n\n /** Parse User Agent to determine iOS version. Returns -1 if not found. */\n\n }, {\n key: \"S\",\n value: function S(e) {\n var t = e.match(/i(?:phone|pad|pod) os ([\\d_]+)/i),\n n = t ? t[1].split(\"_\").slice(0, 2).join(\".\") : \"-1\";\n return Number(n);\n } // visible for testing\n\n /** Parse User Agent to determine Android version. Returns -1 if not found. */\n\n }, {\n key: \"v\",\n value: function v(e) {\n var t = e.match(/Android ([\\d.]+)/i),\n n = t ? t[1].split(\".\").slice(0, 2).join(\".\") : \"-1\";\n return Number(n);\n }\n }]);\n\n return __PRIVATE_SimpleDb;\n}();\n/**\n * A controller for iterating over a key range or index. It allows an iterate\n * callback to delete the currently-referenced object, or jump to a new key\n * within the key range or index.\n */\n\n\nvar __PRIVATE_IterationController = /*#__PURE__*/function () {\n function __PRIVATE_IterationController(e) {\n _classCallCheck(this, __PRIVATE_IterationController);\n\n this.k = e, this.q = !1, this.K = null;\n }\n\n _createClass(__PRIVATE_IterationController, [{\n key: \"isDone\",\n get: function get() {\n return this.q;\n }\n }, {\n key: \"$\",\n get: function get() {\n return this.K;\n }\n }, {\n key: \"cursor\",\n set: function set(e) {\n this.k = e;\n }\n /**\n * This function can be called to stop iteration at any point.\n */\n\n }, {\n key: \"done\",\n value: function done() {\n this.q = !0;\n }\n /**\n * This function can be called to skip to that next key, which could be\n * an index or a primary key.\n */\n\n }, {\n key: \"U\",\n value: function U(e) {\n this.K = e;\n }\n /**\n * Delete the current cursor value from the object store.\n *\n * NOTE: You CANNOT do this with a keysOnly query.\n */\n\n }, {\n key: \"delete\",\n value: function _delete() {\n return __PRIVATE_wrapRequest(this.k.delete());\n }\n }]);\n\n return __PRIVATE_IterationController;\n}();\n/** An error that wraps exceptions that thrown during IndexedDB execution. */\n\n\nvar __PRIVATE_IndexedDbTransactionError = /*#__PURE__*/function (_FirestoreError) {\n _inherits(__PRIVATE_IndexedDbTransactionError, _FirestoreError);\n\n var _super4 = _createSuper(__PRIVATE_IndexedDbTransactionError);\n\n function __PRIVATE_IndexedDbTransactionError(e, t) {\n var _this15;\n\n _classCallCheck(this, __PRIVATE_IndexedDbTransactionError);\n\n _this15 = _super4.call(this, D.UNAVAILABLE, \"IndexedDB transaction '\".concat(e, \"' failed: \").concat(t)), _this15.name = \"IndexedDbTransactionError\";\n return _this15;\n }\n\n return _createClass(__PRIVATE_IndexedDbTransactionError);\n}(FirestoreError);\n/** Verifies whether `e` is an IndexedDbTransactionError. */\n\n\nfunction __PRIVATE_isIndexedDbTransactionError(e) {\n // Use name equality, as instanceof checks on errors don't work with errors\n // that wrap other errors.\n return \"IndexedDbTransactionError\" === e.name;\n}\n/**\n * A wrapper around an IDBObjectStore providing an API that:\n *\n * 1) Has generic KeyType / ValueType parameters to provide strongly-typed\n * methods for acting against the object store.\n * 2) Deals with IndexedDB's onsuccess / onerror event callbacks, making every\n * method return a PersistencePromise instead.\n * 3) Provides a higher-level API to avoid needing to do excessive wrapping of\n * intermediate IndexedDB types (IDBCursorWithValue, etc.)\n */\n\n\nvar __PRIVATE_SimpleDbStore = /*#__PURE__*/function () {\n function __PRIVATE_SimpleDbStore(e) {\n _classCallCheck(this, __PRIVATE_SimpleDbStore);\n\n this.store = e;\n }\n\n _createClass(__PRIVATE_SimpleDbStore, [{\n key: \"put\",\n value: function put(e, t) {\n var n;\n return void 0 !== t ? (__PRIVATE_logDebug(\"SimpleDb\", \"PUT\", this.store.name, e, t), n = this.store.put(t, e)) : (__PRIVATE_logDebug(\"SimpleDb\", \"PUT\", this.store.name, \"\", e), n = this.store.put(e)), __PRIVATE_wrapRequest(n);\n }\n /**\n * Adds a new value into an Object Store and returns the new key. Similar to\n * IndexedDb's `add()`, this method will fail on primary key collisions.\n *\n * @param value - The object to write.\n * @returns The key of the value to add.\n */\n\n }, {\n key: \"add\",\n value: function add(e) {\n __PRIVATE_logDebug(\"SimpleDb\", \"ADD\", this.store.name, e, e);\n\n return __PRIVATE_wrapRequest(this.store.add(e));\n }\n /**\n * Gets the object with the specified key from the specified store, or null\n * if no object exists with the specified key.\n *\n * @key The key of the object to get.\n * @returns The object with the specified key or null if no object exists.\n */\n\n }, {\n key: \"get\",\n value: function get(e) {\n var _this16 = this;\n\n // We're doing an unsafe cast to ValueType.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return __PRIVATE_wrapRequest(this.store.get(e)).next(function (t) {\n return (// Normalize nonexistence to null.\n void 0 === t && (t = null), __PRIVATE_logDebug(\"SimpleDb\", \"GET\", _this16.store.name, e, t), t\n );\n });\n }\n }, {\n key: \"delete\",\n value: function _delete(e) {\n __PRIVATE_logDebug(\"SimpleDb\", \"DELETE\", this.store.name, e);\n\n return __PRIVATE_wrapRequest(this.store.delete(e));\n }\n /**\n * If we ever need more of the count variants, we can add overloads. For now,\n * all we need is to count everything in a store.\n *\n * Returns the number of rows in the store.\n */\n\n }, {\n key: \"count\",\n value: function count() {\n __PRIVATE_logDebug(\"SimpleDb\", \"COUNT\", this.store.name);\n\n return __PRIVATE_wrapRequest(this.store.count());\n }\n }, {\n key: \"W\",\n value: function W(e, t) {\n var n = this.options(e, t),\n r = n.index ? this.store.index(n.index) : this.store; // Use `getAll()` if the browser supports IndexedDB v3, as it is roughly\n // 20% faster.\n\n if (\"function\" == typeof r.getAll) {\n var _e5 = r.getAll(n.range);\n\n return new PersistencePromise(function (t, n) {\n _e5.onerror = function (e) {\n n(e.target.error);\n }, _e5.onsuccess = function (e) {\n t(e.target.result);\n };\n });\n }\n\n {\n var _e6 = this.cursor(n),\n _t5 = [];\n\n return this.G(_e6, function (e, n) {\n _t5.push(n);\n }).next(function () {\n return _t5;\n });\n }\n }\n /**\n * Loads the first `count` elements from the provided index range. Loads all\n * elements if no limit is provided.\n */\n\n }, {\n key: \"j\",\n value: function j(e, t) {\n var n = this.store.getAll(e, null === t ? void 0 : t);\n return new PersistencePromise(function (e, t) {\n n.onerror = function (e) {\n t(e.target.error);\n }, n.onsuccess = function (t) {\n e(t.target.result);\n };\n });\n }\n }, {\n key: \"H\",\n value: function H(e, t) {\n __PRIVATE_logDebug(\"SimpleDb\", \"DELETE ALL\", this.store.name);\n\n var n = this.options(e, t);\n n.J = !1;\n var r = this.cursor(n);\n return this.G(r, function (e, t, n) {\n return n.delete();\n });\n }\n }, {\n key: \"Y\",\n value: function Y(e, t) {\n var n;\n t ? n = e : (n = {}, t = e);\n var r = this.cursor(n);\n return this.G(r, t);\n }\n /**\n * Iterates over a store, but waits for the given callback to complete for\n * each entry before iterating the next entry. This allows the callback to do\n * asynchronous work to determine if this iteration should continue.\n *\n * The provided callback should return `true` to continue iteration, and\n * `false` otherwise.\n */\n\n }, {\n key: \"Z\",\n value: function Z(e) {\n var t = this.cursor({});\n return new PersistencePromise(function (n, r) {\n t.onerror = function (e) {\n var t = __PRIVATE_checkForAndReportiOSError(e.target.error);\n\n r(t);\n }, t.onsuccess = function (t) {\n var r = t.target.result;\n r ? e(r.primaryKey, r.value).next(function (e) {\n e ? r.continue() : n();\n }) : n();\n };\n });\n }\n }, {\n key: \"G\",\n value: function G(e, t) {\n var n = [];\n return new PersistencePromise(function (r, i) {\n e.onerror = function (e) {\n i(e.target.error);\n }, e.onsuccess = function (e) {\n var i = e.target.result;\n if (!i) return void r();\n var s = new __PRIVATE_IterationController(i),\n o = t(i.primaryKey, i.value, s);\n\n if (o instanceof PersistencePromise) {\n var _e7 = o.catch(function (e) {\n return s.done(), PersistencePromise.reject(e);\n });\n\n n.push(_e7);\n }\n\n s.isDone ? r() : null === s.$ ? i.continue() : i.continue(s.$);\n };\n }).next(function () {\n return PersistencePromise.waitFor(n);\n });\n }\n }, {\n key: \"options\",\n value: function options(e, t) {\n var n;\n return void 0 !== e && (\"string\" == typeof e ? n = e : t = e), {\n index: n,\n range: t\n };\n }\n }, {\n key: \"cursor\",\n value: function cursor(e) {\n var t = \"next\";\n\n if (e.reverse && (t = \"prev\"), e.index) {\n var n = this.store.index(e.index);\n return e.J ? n.openKeyCursor(e.range, t) : n.openCursor(e.range, t);\n }\n\n return this.store.openCursor(e.range, t);\n }\n }]);\n\n return __PRIVATE_SimpleDbStore;\n}();\n/**\n * Wraps an IDBRequest in a PersistencePromise, using the onsuccess / onerror\n * handlers to resolve / reject the PersistencePromise as appropriate.\n */\n\n\nfunction __PRIVATE_wrapRequest(e) {\n return new PersistencePromise(function (t, n) {\n e.onsuccess = function (e) {\n var n = e.target.result;\n t(n);\n }, e.onerror = function (e) {\n var t = __PRIVATE_checkForAndReportiOSError(e.target.error);\n\n n(t);\n };\n });\n} // Guard so we only report the error once.\n\n\nvar F = !1;\n\nfunction __PRIVATE_checkForAndReportiOSError(e) {\n var t = __PRIVATE_SimpleDb.S(getUA());\n\n if (t >= 12.2 && t < 13) {\n var _t6 = \"An internal error was encountered in the Indexed Database server\";\n\n if (e.message.indexOf(_t6) >= 0) {\n // Wrap error in a more descriptive one.\n var _e8 = new FirestoreError(\"internal\", \"IOS_INDEXEDDB_BUG1: IndexedDb has thrown '\".concat(_t6, \"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.\"));\n\n return F || (F = !0, // Throw a global exception outside of this promise chain, for the user to\n // potentially catch.\n setTimeout(function () {\n throw _e8;\n }, 0)), _e8;\n }\n }\n\n return e;\n}\n/** This class is responsible for the scheduling of Index Backfiller. */\n\n\nvar __PRIVATE_IndexBackfillerScheduler = /*#__PURE__*/function () {\n function __PRIVATE_IndexBackfillerScheduler(e, t) {\n _classCallCheck(this, __PRIVATE_IndexBackfillerScheduler);\n\n this.asyncQueue = e, this.X = t, this.task = null;\n }\n\n _createClass(__PRIVATE_IndexBackfillerScheduler, [{\n key: \"start\",\n value: function start() {\n this.ee(15e3);\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.task && (this.task.cancel(), this.task = null);\n }\n }, {\n key: \"started\",\n get: function get() {\n return null !== this.task;\n }\n }, {\n key: \"ee\",\n value: function ee(e) {\n var _this17 = this;\n\n __PRIVATE_logDebug(\"IndexBackfiller\", \"Scheduled in \".concat(e, \"ms\")), this.task = this.asyncQueue.enqueueAfterDelay(\"index_backfill\"\n /* TimerId.IndexBackfill */\n , e, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {\n return _regeneratorRuntime.wrap(function _callee5$(_context5) {\n while (1) {\n switch (_context5.prev = _context5.next) {\n case 0:\n _this17.task = null;\n _context5.prev = 1;\n _context5.t0 = __PRIVATE_logDebug;\n _context5.t1 = \"Documents written: \";\n _context5.next = 6;\n return _this17.X.te();\n\n case 6:\n _context5.t2 = _context5.sent;\n _context5.t3 = _context5.t1.concat.call(_context5.t1, _context5.t2);\n (0, _context5.t0)(\"IndexBackfiller\", _context5.t3);\n _context5.next = 19;\n break;\n\n case 11:\n _context5.prev = 11;\n _context5.t4 = _context5[\"catch\"](1);\n\n if (!__PRIVATE_isIndexedDbTransactionError(_context5.t4)) {\n _context5.next = 17;\n break;\n }\n\n __PRIVATE_logDebug(\"IndexBackfiller\", \"Ignoring IndexedDB error during index backfill: \", _context5.t4);\n\n _context5.next = 19;\n break;\n\n case 17:\n _context5.next = 19;\n return __PRIVATE_ignoreIfPrimaryLeaseLoss(_context5.t4);\n\n case 19:\n _context5.next = 21;\n return _this17.ee(6e4);\n\n case 21:\n case \"end\":\n return _context5.stop();\n }\n }\n }, _callee5, null, [[1, 11]]);\n })));\n }\n }]);\n\n return __PRIVATE_IndexBackfillerScheduler;\n}();\n/** Implements the steps for backfilling indexes. */\n\n\nvar __PRIVATE_IndexBackfiller = /*#__PURE__*/function () {\n function __PRIVATE_IndexBackfiller(\n /**\n * LocalStore provides access to IndexManager and LocalDocumentView.\n * These properties will update when the user changes. Consequently,\n * making a local copy of IndexManager and LocalDocumentView will require\n * updates over time. The simpler solution is to rely on LocalStore to have\n * an up-to-date references to IndexManager and LocalDocumentStore.\n */\n e, t) {\n _classCallCheck(this, __PRIVATE_IndexBackfiller);\n\n this.localStore = e, this.persistence = t;\n }\n\n _createClass(__PRIVATE_IndexBackfiller, [{\n key: \"te\",\n value: function () {\n var _te = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {\n var _this18 = this;\n\n var e,\n _args6 = arguments;\n return _regeneratorRuntime.wrap(function _callee6$(_context6) {\n while (1) {\n switch (_context6.prev = _context6.next) {\n case 0:\n e = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : 50;\n return _context6.abrupt(\"return\", this.persistence.runTransaction(\"Backfill Indexes\", \"readwrite-primary\", function (t) {\n return _this18.ne(t, e);\n }));\n\n case 2:\n case \"end\":\n return _context6.stop();\n }\n }\n }, _callee6, this);\n }));\n\n function te() {\n return _te.apply(this, arguments);\n }\n\n return te;\n }()\n /** Writes index entries until the cap is reached. Returns the number of documents processed. */\n\n }, {\n key: \"ne\",\n value: function ne(e, t) {\n var _this19 = this;\n\n var n = new Set();\n var r = t,\n i = !0;\n return PersistencePromise.doWhile(function () {\n return !0 === i && r > 0;\n }, function () {\n return _this19.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(function (t) {\n if (null !== t && !n.has(t)) return __PRIVATE_logDebug(\"IndexBackfiller\", \"Processing collection: \".concat(t)), _this19.re(e, t, r).next(function (e) {\n r -= e, n.add(t);\n });\n i = !1;\n });\n }).next(function () {\n return t - r;\n });\n }\n /**\n * Writes entries for the provided collection group. Returns the number of documents processed.\n */\n\n }, {\n key: \"re\",\n value: function re(e, t, n) {\n var _this20 = this;\n\n // Use the earliest offset of all field indexes to query the local cache.\n return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e, t).next(function (r) {\n return _this20.localStore.localDocuments.getNextDocuments(e, t, r, n).next(function (n) {\n var i = n.changes;\n return _this20.localStore.indexManager.updateIndexEntries(e, i).next(function () {\n return _this20.ie(r, n);\n }).next(function (n) {\n return __PRIVATE_logDebug(\"IndexBackfiller\", \"Updating offset: \".concat(n)), _this20.localStore.indexManager.updateCollectionGroup(e, t, n);\n }).next(function () {\n return i.size;\n });\n });\n });\n }\n /** Returns the next offset based on the provided documents. */\n\n }, {\n key: \"ie\",\n value: function ie(e, t) {\n var n = e;\n return t.changes.forEach(function (e, t) {\n var r = __PRIVATE_newIndexOffsetFromDocument(t);\n\n __PRIVATE_indexOffsetComparator(r, n) > 0 && (n = r);\n }), new IndexOffset(n.readTime, n.documentKey, Math.max(t.batchId, e.largestBatchId));\n }\n }]);\n\n return __PRIVATE_IndexBackfiller;\n}();\n/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * `ListenSequence` is a monotonic sequence. It is initialized with a minimum value to\n * exceed. All subsequent calls to next will return increasing values. If provided with a\n * `SequenceNumberSyncer`, it will additionally bump its next value when told of a new value, as\n * well as write out sequence numbers that it produces via `next()`.\n */\n\n\nvar __PRIVATE_ListenSequence = /*#__PURE__*/function () {\n function __PRIVATE_ListenSequence(e, t) {\n var _this21 = this;\n\n _classCallCheck(this, __PRIVATE_ListenSequence);\n\n this.previousValue = e, t && (t.sequenceNumberHandler = function (e) {\n return _this21.se(e);\n }, this.oe = function (e) {\n return t.writeSequenceNumber(e);\n });\n }\n\n _createClass(__PRIVATE_ListenSequence, [{\n key: \"se\",\n value: function se(e) {\n return this.previousValue = Math.max(e, this.previousValue), this.previousValue;\n }\n }, {\n key: \"next\",\n value: function next() {\n var e = ++this.previousValue;\n return this.oe && this.oe(e), e;\n }\n }]);\n\n return __PRIVATE_ListenSequence;\n}();\n\n__PRIVATE_ListenSequence._e = -1;\n/**\n * Returns whether a variable is either undefined or null.\n */\n\nfunction __PRIVATE_isNullOrUndefined(e) {\n return null == e;\n}\n/** Returns whether the value represents -0. */\n\n\nfunction __PRIVATE_isNegativeZero(e) {\n // Detect if the value is -0.0. Based on polyfill from\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n return 0 === e && 1 / e == -1 / 0;\n}\n/**\n * Returns whether a value is an integer and in the safe integer range\n * @param value - The value to test for being an integer and in the safe range\n */\n\n\nfunction isSafeInteger(e) {\n return \"number\" == typeof e && Number.isInteger(e) && !__PRIVATE_isNegativeZero(e) && e <= Number.MAX_SAFE_INTEGER && e >= Number.MIN_SAFE_INTEGER;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Encodes a resource path into a IndexedDb-compatible string form.\n */\n\n\nfunction __PRIVATE_encodeResourcePath(e) {\n var t = \"\";\n\n for (var n = 0; n < e.length; n++) {\n t.length > 0 && (t = __PRIVATE_encodeSeparator(t)), t = __PRIVATE_encodeSegment(e.get(n), t);\n }\n\n return __PRIVATE_encodeSeparator(t);\n}\n/** Encodes a single segment of a resource path into the given result */\n\n\nfunction __PRIVATE_encodeSegment(e, t) {\n var n = t;\n var r = e.length;\n\n for (var _t7 = 0; _t7 < r; _t7++) {\n var _r = e.charAt(_t7);\n\n switch (_r) {\n case \"\\0\":\n n += \"\u0001\u0010\";\n break;\n\n case \"\u0001\":\n n += \"\u0001\u0011\";\n break;\n\n default:\n n += _r;\n }\n }\n\n return n;\n}\n/** Encodes a path separator into the given result */\n\n\nfunction __PRIVATE_encodeSeparator(e) {\n return e + \"\u0001\u0001\";\n}\n/**\n * Decodes the given IndexedDb-compatible string form of a resource path into\n * a ResourcePath instance. Note that this method is not suitable for use with\n * decoding resource names from the server; those are One Platform format\n * strings.\n */\n\n\nfunction __PRIVATE_decodeResourcePath(e) {\n // Event the empty path must encode as a path of at least length 2. A path\n // with exactly 2 must be the empty path.\n var t = e.length;\n if (__PRIVATE_hardAssert(t >= 2), 2 === t) return __PRIVATE_hardAssert(\"\u0001\" === e.charAt(0) && \"\u0001\" === e.charAt(1)), ResourcePath.emptyPath(); // Escape characters cannot exist past the second-to-last position in the\n // source value.\n\n var __PRIVATE_lastReasonableEscapeIndex = t - 2,\n n = [];\n\n var r = \"\";\n\n for (var i = 0; i < t;) {\n // The last two characters of a valid encoded path must be a separator, so\n // there must be an end to this segment.\n var _t8 = e.indexOf(\"\u0001\", i);\n\n (_t8 < 0 || _t8 > __PRIVATE_lastReasonableEscapeIndex) && fail();\n\n switch (e.charAt(_t8 + 1)) {\n case \"\u0001\":\n var s = e.substring(i, _t8);\n var o = void 0;\n 0 === r.length ? // Avoid copying for the common case of a segment that excludes \\0\n // and \\001\n o = s : (r += s, o = r, r = \"\"), n.push(o);\n break;\n\n case \"\u0010\":\n r += e.substring(i, _t8), r += \"\\0\";\n break;\n\n case \"\u0011\":\n // The escape character can be used in the output to encode itself.\n r += e.substring(i, _t8 + 1);\n break;\n\n default:\n fail();\n }\n\n i = _t8 + 2;\n }\n\n return new ResourcePath(n);\n}\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar M = [\"userId\", \"batchId\"];\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Name of the IndexedDb object store.\n *\n * Note that the name 'owner' is chosen to ensure backwards compatibility with\n * older clients that only supported single locked access to the persistence\n * layer.\n */\n\n/**\n * Creates a [userId, encodedPath] key for use in the DbDocumentMutations\n * index to iterate over all at document mutations for a given path or lower.\n */\n\nfunction __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {\n return [e, __PRIVATE_encodeResourcePath(t)];\n}\n/**\n * Creates a full index key of [userId, encodedPath, batchId] for inserting\n * and deleting into the DbDocumentMutations index.\n */\n\n\nfunction __PRIVATE_newDbDocumentMutationKey(e, t, n) {\n return [e, __PRIVATE_encodeResourcePath(t), n];\n}\n/**\n * Because we store all the useful information for this store in the key,\n * there is no useful information to store as the value. The raw (unencoded)\n * path cannot be stored because IndexedDb doesn't store prototype\n * information.\n */\n\n\nvar x = {},\n O = [\"prefixPath\", \"collectionGroup\", \"readTime\", \"documentId\"],\n _N = [\"prefixPath\", \"collectionGroup\", \"documentId\"],\n B = [\"collectionGroup\", \"readTime\", \"prefixPath\", \"documentId\"],\n L = [\"canonicalId\", \"targetId\"],\n k = [\"targetId\", \"path\"],\n q = [\"path\", \"targetId\"],\n Q = [\"collectionId\", \"parent\"],\n K = [\"indexId\", \"uid\"],\n $ = [\"uid\", \"sequenceNumber\"],\n U = [\"indexId\", \"uid\", \"arrayValue\", \"directionalValue\", \"orderedDocumentKey\", \"documentKey\"],\n W = [\"indexId\", \"uid\", \"orderedDocumentKey\"],\n G = [\"userId\", \"collectionPath\", \"documentId\"],\n z = [\"userId\", \"collectionPath\", \"largestBatchId\"],\n j = [\"userId\", \"collectionGroup\", \"largestBatchId\"],\n H = [\"mutationQueues\", \"mutations\", \"documentMutations\", \"remoteDocuments\", \"targets\", \"owner\", \"targetGlobal\", \"targetDocuments\"].concat([\"clientMetadata\"]).concat([\"remoteDocumentGlobal\"]).concat([\"collectionParents\"]).concat([\"bundles\", \"namedQueries\"]),\n J = [].concat(_toConsumableArray(H), [\"documentOverlays\"]),\n Y = [\"mutationQueues\", \"mutations\", \"documentMutations\", \"remoteDocumentsV14\", \"targets\", \"owner\", \"targetGlobal\", \"targetDocuments\", \"clientMetadata\", \"remoteDocumentGlobal\", \"collectionParents\", \"bundles\", \"namedQueries\", \"documentOverlays\"],\n Z = Y,\n X = [].concat(Z, [\"indexConfiguration\", \"indexState\", \"indexEntries\"]);\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nvar __PRIVATE_IndexedDbTransaction = /*#__PURE__*/function (_PersistenceTransacti) {\n _inherits(__PRIVATE_IndexedDbTransaction, _PersistenceTransacti);\n\n var _super5 = _createSuper(__PRIVATE_IndexedDbTransaction);\n\n function __PRIVATE_IndexedDbTransaction(e, t) {\n var _this22;\n\n _classCallCheck(this, __PRIVATE_IndexedDbTransaction);\n\n _this22 = _super5.call(this), _this22.ae = e, _this22.currentSequenceNumber = t;\n return _this22;\n }\n\n return _createClass(__PRIVATE_IndexedDbTransaction);\n}(PersistenceTransaction);\n\nfunction __PRIVATE_getStore(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return __PRIVATE_SimpleDb.M(n.ae, t);\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nfunction __PRIVATE_objectSize(e) {\n var t = 0;\n\n for (var n in e) {\n Object.prototype.hasOwnProperty.call(e, n) && t++;\n }\n\n return t;\n}\n\nfunction _forEach(e, t) {\n for (var n in e) {\n Object.prototype.hasOwnProperty.call(e, n) && t(n, e[n]);\n }\n}\n\nfunction _isEmpty(e) {\n for (var t in e) {\n if (Object.prototype.hasOwnProperty.call(e, t)) return !1;\n }\n\n return !0;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// An immutable sorted map implementation, based on a Left-leaning Red-Black\n// tree.\n\n\nvar SortedMap = /*#__PURE__*/function () {\n function SortedMap(e, t) {\n _classCallCheck(this, SortedMap);\n\n this.comparator = e, this.root = t || LLRBNode.EMPTY;\n } // Returns a copy of the map, with the specified key/value added or replaced.\n\n\n _createClass(SortedMap, [{\n key: \"insert\",\n value: function insert(e, t) {\n return new SortedMap(this.comparator, this.root.insert(e, t, this.comparator).copy(null, null, LLRBNode.BLACK, null, null));\n } // Returns a copy of the map, with the specified key removed.\n\n }, {\n key: \"remove\",\n value: function remove(e) {\n return new SortedMap(this.comparator, this.root.remove(e, this.comparator).copy(null, null, LLRBNode.BLACK, null, null));\n } // Returns the value of the node with the given key, or null.\n\n }, {\n key: \"get\",\n value: function get(e) {\n var t = this.root;\n\n for (; !t.isEmpty();) {\n var n = this.comparator(e, t.key);\n if (0 === n) return t.value;\n n < 0 ? t = t.left : n > 0 && (t = t.right);\n }\n\n return null;\n } // Returns the index of the element in this sorted map, or -1 if it doesn't\n // exist.\n\n }, {\n key: \"indexOf\",\n value: function indexOf(e) {\n // Number of nodes that were pruned when descending right\n var t = 0,\n n = this.root;\n\n for (; !n.isEmpty();) {\n var r = this.comparator(e, n.key);\n if (0 === r) return t + n.left.size;\n r < 0 ? n = n.left : ( // Count all nodes left of the node plus the node itself\n t += n.left.size + 1, n = n.right);\n } // Node not found\n\n\n return -1;\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return this.root.isEmpty();\n } // Returns the total number of nodes in the map.\n\n }, {\n key: \"size\",\n get: function get() {\n return this.root.size;\n } // Returns the minimum key in the map.\n\n }, {\n key: \"minKey\",\n value: function minKey() {\n return this.root.minKey();\n } // Returns the maximum key in the map.\n\n }, {\n key: \"maxKey\",\n value: function maxKey() {\n return this.root.maxKey();\n } // Traverses the map in key order and calls the specified action function\n // for each key/value pair. If action returns true, traversal is aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n\n }, {\n key: \"inorderTraversal\",\n value: function inorderTraversal(e) {\n return this.root.inorderTraversal(e);\n }\n }, {\n key: \"forEach\",\n value: function forEach(e) {\n this.inorderTraversal(function (t, n) {\n return e(t, n), !1;\n });\n }\n }, {\n key: \"toString\",\n value: function toString() {\n var e = [];\n return this.inorderTraversal(function (t, n) {\n return e.push(\"\".concat(t, \":\").concat(n)), !1;\n }), \"{\".concat(e.join(\", \"), \"}\");\n } // Traverses the map in reverse key order and calls the specified action\n // function for each key/value pair. If action returns true, traversal is\n // aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n\n }, {\n key: \"reverseTraversal\",\n value: function reverseTraversal(e) {\n return this.root.reverseTraversal(e);\n } // Returns an iterator over the SortedMap.\n\n }, {\n key: \"getIterator\",\n value: function getIterator() {\n return new SortedMapIterator(this.root, null, this.comparator, !1);\n }\n }, {\n key: \"getIteratorFrom\",\n value: function getIteratorFrom(e) {\n return new SortedMapIterator(this.root, e, this.comparator, !1);\n }\n }, {\n key: \"getReverseIterator\",\n value: function getReverseIterator() {\n return new SortedMapIterator(this.root, null, this.comparator, !0);\n }\n }, {\n key: \"getReverseIteratorFrom\",\n value: function getReverseIteratorFrom(e) {\n return new SortedMapIterator(this.root, e, this.comparator, !0);\n }\n }]);\n\n return SortedMap;\n}(); // end SortedMap\n// An iterator over an LLRBNode.\n\n\nvar SortedMapIterator = /*#__PURE__*/function () {\n function SortedMapIterator(e, t, n, r) {\n _classCallCheck(this, SortedMapIterator);\n\n this.isReverse = r, this.nodeStack = [];\n var i = 1;\n\n for (; !e.isEmpty();) {\n if (i = t ? n(e.key, t) : 1, // flip the comparison if we're going in reverse\n t && r && (i *= -1), i < 0) // This node is less than our start key. ignore it\n e = this.isReverse ? e.left : e.right;else {\n if (0 === i) {\n // This node is exactly equal to our start key. Push it on the stack,\n // but stop iterating;\n this.nodeStack.push(e);\n break;\n } // This node is greater than our start key, add it to the stack and move\n // to the next one\n\n\n this.nodeStack.push(e), e = this.isReverse ? e.right : e.left;\n }\n }\n }\n\n _createClass(SortedMapIterator, [{\n key: \"getNext\",\n value: function getNext() {\n var e = this.nodeStack.pop();\n var t = {\n key: e.key,\n value: e.value\n };\n if (this.isReverse) for (e = e.left; !e.isEmpty();) {\n this.nodeStack.push(e), e = e.right;\n } else for (e = e.right; !e.isEmpty();) {\n this.nodeStack.push(e), e = e.left;\n }\n return t;\n }\n }, {\n key: \"hasNext\",\n value: function hasNext() {\n return this.nodeStack.length > 0;\n }\n }, {\n key: \"peek\",\n value: function peek() {\n if (0 === this.nodeStack.length) return null;\n var e = this.nodeStack[this.nodeStack.length - 1];\n return {\n key: e.key,\n value: e.value\n };\n }\n }]);\n\n return SortedMapIterator;\n}(); // end SortedMapIterator\n// Represents a node in a Left-leaning Red-Black tree.\n\n\nvar LLRBNode = /*#__PURE__*/function () {\n function LLRBNode(e, t, n, r, i) {\n _classCallCheck(this, LLRBNode);\n\n this.key = e, this.value = t, this.color = null != n ? n : LLRBNode.RED, this.left = null != r ? r : LLRBNode.EMPTY, this.right = null != i ? i : LLRBNode.EMPTY, this.size = this.left.size + 1 + this.right.size;\n } // Returns a copy of the current node, optionally replacing pieces of it.\n\n\n _createClass(LLRBNode, [{\n key: \"copy\",\n value: function copy(e, t, n, r, i) {\n return new LLRBNode(null != e ? e : this.key, null != t ? t : this.value, null != n ? n : this.color, null != r ? r : this.left, null != i ? i : this.right);\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !1;\n } // Traverses the tree in key order and calls the specified action function\n // for each node. If action returns true, traversal is aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n\n }, {\n key: \"inorderTraversal\",\n value: function inorderTraversal(e) {\n return this.left.inorderTraversal(e) || e(this.key, this.value) || this.right.inorderTraversal(e);\n } // Traverses the tree in reverse key order and calls the specified action\n // function for each node. If action returns true, traversal is aborted.\n // Returns the first truthy value returned by action, or the last falsey\n // value returned by action.\n\n }, {\n key: \"reverseTraversal\",\n value: function reverseTraversal(e) {\n return this.right.reverseTraversal(e) || e(this.key, this.value) || this.left.reverseTraversal(e);\n } // Returns the minimum node in the tree.\n\n }, {\n key: \"min\",\n value: function min() {\n return this.left.isEmpty() ? this : this.left.min();\n } // Returns the maximum key in the tree.\n\n }, {\n key: \"minKey\",\n value: function minKey() {\n return this.min().key;\n } // Returns the maximum key in the tree.\n\n }, {\n key: \"maxKey\",\n value: function maxKey() {\n return this.right.isEmpty() ? this.key : this.right.maxKey();\n } // Returns new tree, with the key/value added.\n\n }, {\n key: \"insert\",\n value: function insert(e, t, n) {\n var r = this;\n var i = n(e, r.key);\n return r = i < 0 ? r.copy(null, null, null, r.left.insert(e, t, n), null) : 0 === i ? r.copy(null, t, null, null, null) : r.copy(null, null, null, null, r.right.insert(e, t, n)), r.fixUp();\n }\n }, {\n key: \"removeMin\",\n value: function removeMin() {\n if (this.left.isEmpty()) return LLRBNode.EMPTY;\n var e = this;\n return e.left.isRed() || e.left.left.isRed() || (e = e.moveRedLeft()), e = e.copy(null, null, null, e.left.removeMin(), null), e.fixUp();\n } // Returns new tree, with the specified item removed.\n\n }, {\n key: \"remove\",\n value: function remove(e, t) {\n var n,\n r = this;\n if (t(e, r.key) < 0) r.left.isEmpty() || r.left.isRed() || r.left.left.isRed() || (r = r.moveRedLeft()), r = r.copy(null, null, null, r.left.remove(e, t), null);else {\n if (r.left.isRed() && (r = r.rotateRight()), r.right.isEmpty() || r.right.isRed() || r.right.left.isRed() || (r = r.moveRedRight()), 0 === t(e, r.key)) {\n if (r.right.isEmpty()) return LLRBNode.EMPTY;\n n = r.right.min(), r = r.copy(n.key, n.value, null, null, r.right.removeMin());\n }\n\n r = r.copy(null, null, null, null, r.right.remove(e, t));\n }\n return r.fixUp();\n }\n }, {\n key: \"isRed\",\n value: function isRed() {\n return this.color;\n } // Returns new tree after performing any needed rotations.\n\n }, {\n key: \"fixUp\",\n value: function fixUp() {\n var e = this;\n return e.right.isRed() && !e.left.isRed() && (e = e.rotateLeft()), e.left.isRed() && e.left.left.isRed() && (e = e.rotateRight()), e.left.isRed() && e.right.isRed() && (e = e.colorFlip()), e;\n }\n }, {\n key: \"moveRedLeft\",\n value: function moveRedLeft() {\n var e = this.colorFlip();\n return e.right.left.isRed() && (e = e.copy(null, null, null, null, e.right.rotateRight()), e = e.rotateLeft(), e = e.colorFlip()), e;\n }\n }, {\n key: \"moveRedRight\",\n value: function moveRedRight() {\n var e = this.colorFlip();\n return e.left.left.isRed() && (e = e.rotateRight(), e = e.colorFlip()), e;\n }\n }, {\n key: \"rotateLeft\",\n value: function rotateLeft() {\n var e = this.copy(null, null, LLRBNode.RED, null, this.right.left);\n return this.right.copy(null, null, this.color, e, null);\n }\n }, {\n key: \"rotateRight\",\n value: function rotateRight() {\n var e = this.copy(null, null, LLRBNode.RED, this.left.right, null);\n return this.left.copy(null, null, this.color, null, e);\n }\n }, {\n key: \"colorFlip\",\n value: function colorFlip() {\n var e = this.left.copy(null, null, !this.left.color, null, null),\n t = this.right.copy(null, null, !this.right.color, null, null);\n return this.copy(null, null, !this.color, e, t);\n } // For testing.\n\n }, {\n key: \"checkMaxDepth\",\n value: function checkMaxDepth() {\n var e = this.check();\n return Math.pow(2, e) <= this.size + 1;\n } // In a balanced RB tree, the black-depth (number of black nodes) from root to\n // leaves is equal on both sides. This function verifies that or asserts.\n\n }, {\n key: \"check\",\n value: function check() {\n if (this.isRed() && this.left.isRed()) throw fail();\n if (this.right.isRed()) throw fail();\n var e = this.left.check();\n if (e !== this.right.check()) throw fail();\n return e + (this.isRed() ? 0 : 1);\n }\n }]);\n\n return LLRBNode;\n}(); // end LLRBNode\n// Empty node is shared between all LLRB trees.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n\nLLRBNode.EMPTY = null, LLRBNode.RED = !0, LLRBNode.BLACK = !1; // end LLRBEmptyNode\n\nLLRBNode.EMPTY = new (\n/*#__PURE__*/\n// Represents an empty node (a leaf node in the Red-Black Tree).\nfunction () {\n function LLRBEmptyNode() {\n _classCallCheck(this, LLRBEmptyNode);\n\n this.size = 0;\n }\n\n _createClass(LLRBEmptyNode, [{\n key: \"key\",\n get: function get() {\n throw fail();\n }\n }, {\n key: \"value\",\n get: function get() {\n throw fail();\n }\n }, {\n key: \"color\",\n get: function get() {\n throw fail();\n }\n }, {\n key: \"left\",\n get: function get() {\n throw fail();\n }\n }, {\n key: \"right\",\n get: function get() {\n throw fail();\n } // Returns a copy of the current node.\n\n }, {\n key: \"copy\",\n value: function copy(e, t, n, r, i) {\n return this;\n } // Returns a copy of the tree, with the specified key/value added.\n\n }, {\n key: \"insert\",\n value: function insert(e, t, n) {\n return new LLRBNode(e, t);\n } // Returns a copy of the tree, with the specified key removed.\n\n }, {\n key: \"remove\",\n value: function remove(e, t) {\n return this;\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return !0;\n }\n }, {\n key: \"inorderTraversal\",\n value: function inorderTraversal(e) {\n return !1;\n }\n }, {\n key: \"reverseTraversal\",\n value: function reverseTraversal(e) {\n return !1;\n }\n }, {\n key: \"minKey\",\n value: function minKey() {\n return null;\n }\n }, {\n key: \"maxKey\",\n value: function maxKey() {\n return null;\n }\n }, {\n key: \"isRed\",\n value: function isRed() {\n return !1;\n } // For testing.\n\n }, {\n key: \"checkMaxDepth\",\n value: function checkMaxDepth() {\n return !0;\n }\n }, {\n key: \"check\",\n value: function check() {\n return 0;\n }\n }]);\n\n return LLRBEmptyNode;\n}())();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * SortedSet is an immutable (copy-on-write) collection that holds elements\n * in order specified by the provided comparator.\n *\n * NOTE: if provided comparator returns 0 for two elements, we consider them to\n * be equal!\n */\n\nvar SortedSet = /*#__PURE__*/function () {\n function SortedSet(e) {\n _classCallCheck(this, SortedSet);\n\n this.comparator = e, this.data = new SortedMap(this.comparator);\n }\n\n _createClass(SortedSet, [{\n key: \"has\",\n value: function has(e) {\n return null !== this.data.get(e);\n }\n }, {\n key: \"first\",\n value: function first() {\n return this.data.minKey();\n }\n }, {\n key: \"last\",\n value: function last() {\n return this.data.maxKey();\n }\n }, {\n key: \"size\",\n get: function get() {\n return this.data.size;\n }\n }, {\n key: \"indexOf\",\n value: function indexOf(e) {\n return this.data.indexOf(e);\n }\n /** Iterates elements in order defined by \"comparator\" */\n\n }, {\n key: \"forEach\",\n value: function forEach(e) {\n this.data.inorderTraversal(function (t, n) {\n return e(t), !1;\n });\n }\n /** Iterates over `elem`s such that: range[0] <= elem < range[1]. */\n\n }, {\n key: \"forEachInRange\",\n value: function forEachInRange(e, t) {\n var n = this.data.getIteratorFrom(e[0]);\n\n for (; n.hasNext();) {\n var r = n.getNext();\n if (this.comparator(r.key, e[1]) >= 0) return;\n t(r.key);\n }\n }\n /**\n * Iterates over `elem`s such that: start <= elem until false is returned.\n */\n\n }, {\n key: \"forEachWhile\",\n value: function forEachWhile(e, t) {\n var n;\n\n for (n = void 0 !== t ? this.data.getIteratorFrom(t) : this.data.getIterator(); n.hasNext();) {\n if (!e(n.getNext().key)) return;\n }\n }\n /** Finds the least element greater than or equal to `elem`. */\n\n }, {\n key: \"firstAfterOrEqual\",\n value: function firstAfterOrEqual(e) {\n var t = this.data.getIteratorFrom(e);\n return t.hasNext() ? t.getNext().key : null;\n }\n }, {\n key: \"getIterator\",\n value: function getIterator() {\n return new SortedSetIterator(this.data.getIterator());\n }\n }, {\n key: \"getIteratorFrom\",\n value: function getIteratorFrom(e) {\n return new SortedSetIterator(this.data.getIteratorFrom(e));\n }\n /** Inserts or updates an element */\n\n }, {\n key: \"add\",\n value: function add(e) {\n return this.copy(this.data.remove(e).insert(e, !0));\n }\n /** Deletes an element */\n\n }, {\n key: \"delete\",\n value: function _delete(e) {\n return this.has(e) ? this.copy(this.data.remove(e)) : this;\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return this.data.isEmpty();\n }\n }, {\n key: \"unionWith\",\n value: function unionWith(e) {\n var t = this; // Make sure `result` always refers to the larger one of the two sets.\n\n return t.size < e.size && (t = e, e = this), e.forEach(function (e) {\n t = t.add(e);\n }), t;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n if (!(e instanceof SortedSet)) return !1;\n if (this.size !== e.size) return !1;\n var t = this.data.getIterator(),\n n = e.data.getIterator();\n\n for (; t.hasNext();) {\n var _e9 = t.getNext().key,\n r = n.getNext().key;\n if (0 !== this.comparator(_e9, r)) return !1;\n }\n\n return !0;\n }\n }, {\n key: \"toArray\",\n value: function toArray() {\n var e = [];\n return this.forEach(function (t) {\n e.push(t);\n }), e;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n var e = [];\n return this.forEach(function (t) {\n return e.push(t);\n }), \"SortedSet(\" + e.toString() + \")\";\n }\n }, {\n key: \"copy\",\n value: function copy(e) {\n var t = new SortedSet(this.comparator);\n return t.data = e, t;\n }\n }]);\n\n return SortedSet;\n}();\n\nvar SortedSetIterator = /*#__PURE__*/function () {\n function SortedSetIterator(e) {\n _classCallCheck(this, SortedSetIterator);\n\n this.iter = e;\n }\n\n _createClass(SortedSetIterator, [{\n key: \"getNext\",\n value: function getNext() {\n return this.iter.getNext().key;\n }\n }, {\n key: \"hasNext\",\n value: function hasNext() {\n return this.iter.hasNext();\n }\n }]);\n\n return SortedSetIterator;\n}();\n/**\n * Compares two sorted sets for equality using their natural ordering. The\n * method computes the intersection and invokes `onAdd` for every element that\n * is in `after` but not `before`. `onRemove` is invoked for every element in\n * `before` but missing from `after`.\n *\n * The method creates a copy of both `before` and `after` and runs in O(n log\n * n), where n is the size of the two lists.\n *\n * @param before - The elements that exist in the original set.\n * @param after - The elements to diff against the original set.\n * @param comparator - The comparator for the elements in before and after.\n * @param onAdd - A function to invoke for every element that is part of `\n * after` but not `before`.\n * @param onRemove - A function to invoke for every element that is part of\n * `before` but not `after`.\n */\n\n/**\n * Returns the next element from the iterator or `undefined` if none available.\n */\n\n\nfunction __PRIVATE_advanceIterator(e) {\n return e.hasNext() ? e.getNext() : void 0;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Provides a set of fields that can be used to partially patch a document.\n * FieldMask is used in conjunction with ObjectValue.\n * Examples:\n * foo - Overwrites foo entirely with the provided value. If foo is not\n * present in the companion ObjectValue, the field is deleted.\n * foo.bar - Overwrites only the field bar of the object foo.\n * If foo is not an object, foo is replaced with an object\n * containing foo\n */\n\n\nvar FieldMask = /*#__PURE__*/function () {\n function FieldMask(e) {\n _classCallCheck(this, FieldMask);\n\n this.fields = e, // TODO(dimond): validation of FieldMask\n // Sort the field mask to support `FieldMask.isEqual()` and assert below.\n e.sort(FieldPath$1.comparator);\n }\n\n _createClass(FieldMask, [{\n key: \"unionWith\",\n value:\n /**\n * Returns a new FieldMask object that is the result of adding all the given\n * fields paths to this field mask.\n */\n function unionWith(e) {\n var t = new SortedSet(FieldPath$1.comparator);\n\n var _iterator2 = _createForOfIteratorHelper(this.fields),\n _step2;\n\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var _e10 = _step2.value;\n t = t.add(_e10);\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n\n var _iterator3 = _createForOfIteratorHelper(e),\n _step3;\n\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var n = _step3.value;\n t = t.add(n);\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n\n return new FieldMask(t.toArray());\n }\n /**\n * Verifies that `fieldPath` is included by at least one field in this field\n * mask.\n *\n * This is an O(n) operation, where `n` is the size of the field mask.\n */\n\n }, {\n key: \"covers\",\n value: function covers(e) {\n var _iterator4 = _createForOfIteratorHelper(this.fields),\n _step4;\n\n try {\n for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {\n var t = _step4.value;\n if (t.isPrefixOf(e)) return !0;\n }\n } catch (err) {\n _iterator4.e(err);\n } finally {\n _iterator4.f();\n }\n\n return !1;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return __PRIVATE_arrayEquals(this.fields, e.fields, function (e, t) {\n return e.isEqual(t);\n });\n }\n }], [{\n key: \"empty\",\n value: function empty() {\n return new FieldMask([]);\n }\n }]);\n\n return FieldMask;\n}();\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An error encountered while decoding base64 string.\n */\n\n\nvar __PRIVATE_Base64DecodeError = /*#__PURE__*/function (_Error) {\n _inherits(__PRIVATE_Base64DecodeError, _Error);\n\n var _super6 = _createSuper(__PRIVATE_Base64DecodeError);\n\n function __PRIVATE_Base64DecodeError() {\n var _this23;\n\n _classCallCheck(this, __PRIVATE_Base64DecodeError);\n\n _this23 = _super6.apply(this, arguments), _this23.name = \"Base64DecodeError\";\n return _this23;\n }\n\n return _createClass(__PRIVATE_Base64DecodeError);\n}( /*#__PURE__*/_wrapNativeSuper(Error));\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Converts a Base64 encoded string to a binary string. */\n\n/** True if and only if the Base64 conversion functions are available. */\n\n\nfunction __PRIVATE_isBase64Available() {\n return \"undefined\" != typeof atob;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Immutable class that represents a \"proto\" byte string.\n *\n * Proto byte strings can either be Base64-encoded strings or Uint8Arrays when\n * sent on the wire. This class abstracts away this differentiation by holding\n * the proto byte string in a common class that must be converted into a string\n * before being sent as a proto.\n * @internal\n */\n\n\nvar ByteString = /*#__PURE__*/function (_Symbol$iterator) {\n function ByteString(e) {\n _classCallCheck(this, ByteString);\n\n this.binaryString = e;\n }\n\n _createClass(ByteString, [{\n key: _Symbol$iterator,\n value: function value() {\n var _this24 = this;\n\n var e = 0;\n return {\n next: function next() {\n return e < _this24.binaryString.length ? {\n value: _this24.binaryString.charCodeAt(e++),\n done: !1\n } : {\n value: void 0,\n done: !0\n };\n }\n };\n }\n }, {\n key: \"toBase64\",\n value: function toBase64() {\n return function __PRIVATE_encodeBase64(e) {\n return btoa(e);\n }(this.binaryString);\n }\n }, {\n key: \"toUint8Array\",\n value: function toUint8Array() {\n return function __PRIVATE_uint8ArrayFromBinaryString(e) {\n var t = new Uint8Array(e.length);\n\n for (var n = 0; n < e.length; n++) {\n t[n] = e.charCodeAt(n);\n }\n\n return t;\n }\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // A RegExp matching ISO 8601 UTC timestamps with optional fraction.\n (this.binaryString);\n }\n }, {\n key: \"approximateByteSize\",\n value: function approximateByteSize() {\n return 2 * this.binaryString.length;\n }\n }, {\n key: \"compareTo\",\n value: function compareTo(e) {\n return __PRIVATE_primitiveComparator(this.binaryString, e.binaryString);\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return this.binaryString === e.binaryString;\n }\n }], [{\n key: \"fromBase64String\",\n value: function fromBase64String(e) {\n var t = function __PRIVATE_decodeBase64(e) {\n try {\n return atob(e);\n } catch (e) {\n // Check that `DOMException` is defined before using it to avoid\n // \"ReferenceError: Property 'DOMException' doesn't exist\" in react-native.\n // (https://github.com/firebase/firebase-js-sdk/issues/7115)\n throw \"undefined\" != typeof DOMException && e instanceof DOMException ? new __PRIVATE_Base64DecodeError(\"Invalid base64 string: \" + e) : e;\n }\n }\n /** Converts a binary string to a Base64 encoded string. */\n (e);\n\n return new ByteString(t);\n }\n }, {\n key: \"fromUint8Array\",\n value: function fromUint8Array(e) {\n // TODO(indexing); Remove the copy of the byte string here as this method\n // is frequently called during indexing.\n var t =\n /**\n * Helper function to convert an Uint8array to a binary string.\n */\n function __PRIVATE_binaryStringFromUint8Array(e) {\n var t = \"\";\n\n for (var n = 0; n < e.length; ++n) {\n t += String.fromCharCode(e[n]);\n }\n\n return t;\n }\n /**\n * Helper function to convert a binary string to an Uint8Array.\n */\n (e);\n\n return new ByteString(t);\n }\n }]);\n\n return ByteString;\n}(Symbol.iterator);\n\nByteString.EMPTY_BYTE_STRING = new ByteString(\"\");\nvar ee = new RegExp(/^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.(\\d+))?Z$/);\n/**\n * Converts the possible Proto values for a timestamp value into a \"seconds and\n * nanos\" representation.\n */\n\nfunction __PRIVATE_normalizeTimestamp(e) {\n // The json interface (for the browser) will return an iso timestamp string,\n // while the proto js library (for node) will return a\n // google.protobuf.Timestamp instance.\n if (__PRIVATE_hardAssert(!!e), \"string\" == typeof e) {\n // The date string can have higher precision (nanos) than the Date class\n // (millis), so we do some custom parsing here.\n // Parse the nanos right out of the string.\n var t = 0;\n var n = ee.exec(e);\n\n if (__PRIVATE_hardAssert(!!n), n[1]) {\n // Pad the fraction out to 9 digits (nanos).\n var _e11 = n[1];\n _e11 = (_e11 + \"000000000\").substr(0, 9), t = Number(_e11);\n } // Parse the date to get the seconds.\n\n\n var r = new Date(e);\n return {\n seconds: Math.floor(r.getTime() / 1e3),\n nanos: t\n };\n }\n\n return {\n seconds: __PRIVATE_normalizeNumber(e.seconds),\n nanos: __PRIVATE_normalizeNumber(e.nanos)\n };\n}\n/**\n * Converts the possible Proto types for numbers into a JavaScript number.\n * Returns 0 if the value is not numeric.\n */\n\n\nfunction __PRIVATE_normalizeNumber(e) {\n // TODO(bjornick): Handle int64 greater than 53 bits.\n return \"number\" == typeof e ? e : \"string\" == typeof e ? Number(e) : 0;\n}\n/** Converts the possible Proto types for Blobs into a ByteString. */\n\n\nfunction __PRIVATE_normalizeByteString(e) {\n return \"string\" == typeof e ? ByteString.fromBase64String(e) : ByteString.fromUint8Array(e);\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents a locally-applied ServerTimestamp.\n *\n * Server Timestamps are backed by MapValues that contain an internal field\n * `__type__` with a value of `server_timestamp`. The previous value and local\n * write time are stored in its `__previous_value__` and `__local_write_time__`\n * fields respectively.\n *\n * Notes:\n * - ServerTimestampValue instances are created as the result of applying a\n * transform. They can only exist in the local view of a document. Therefore\n * they do not need to be parsed or serialized.\n * - When evaluated locally (e.g. for snapshot.data()), they by default\n * evaluate to `null`. This behavior can be configured by passing custom\n * FieldValueOptions to value().\n * - With respect to other ServerTimestampValues, they sort by their\n * localWriteTime.\n */\n\n\nfunction __PRIVATE_isServerTimestamp(e) {\n var t, n;\n return \"server_timestamp\" === (null === (n = ((null === (t = null == e ? void 0 : e.mapValue) || void 0 === t ? void 0 : t.fields) || {}).__type__) || void 0 === n ? void 0 : n.stringValue);\n}\n/**\n * Creates a new ServerTimestamp proto value (using the internal format).\n */\n\n/**\n * Returns the value of the field before this ServerTimestamp was set.\n *\n * Preserving the previous values allows the user to display the last resoled\n * value until the backend responds with the timestamp.\n */\n\n\nfunction __PRIVATE_getPreviousValue(e) {\n var t = e.mapValue.fields.__previous_value__;\n return __PRIVATE_isServerTimestamp(t) ? __PRIVATE_getPreviousValue(t) : t;\n}\n/**\n * Returns the local time at which this timestamp was first set.\n */\n\n\nfunction __PRIVATE_getLocalWriteTime(e) {\n var t = __PRIVATE_normalizeTimestamp(e.mapValue.fields.__local_write_time__.timestampValue);\n\n return new Timestamp(t.seconds, t.nanos);\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar DatabaseInfo = /*#__PURE__*/_createClass(\n/**\n * Constructs a DatabaseInfo using the provided host, databaseId and\n * persistenceKey.\n *\n * @param databaseId - The database to use.\n * @param appId - The Firebase App Id.\n * @param persistenceKey - A unique identifier for this Firestore's local\n * storage (used in conjunction with the databaseId).\n * @param host - The Firestore backend host to connect to.\n * @param ssl - Whether to use SSL when connecting.\n * @param forceLongPolling - Whether to use the forceLongPolling option\n * when using WebChannel as the network transport.\n * @param autoDetectLongPolling - Whether to use the detectBufferingProxy\n * option when using WebChannel as the network transport.\n * @param longPollingOptions Options that configure long-polling.\n * @param useFetchStreams Whether to use the Fetch API instead of\n * XMLHTTPRequest\n */\nfunction DatabaseInfo(e, t, n, r, i, s, o, _, a) {\n _classCallCheck(this, DatabaseInfo);\n\n this.databaseId = e, this.appId = t, this.persistenceKey = n, this.host = r, this.ssl = i, this.forceLongPolling = s, this.autoDetectLongPolling = o, this.longPollingOptions = _, this.useFetchStreams = a;\n});\n/** The default database name for a project. */\n\n/**\n * Represents the database ID a Firestore client is associated with.\n * @internal\n */\n\n\nvar DatabaseId = /*#__PURE__*/function () {\n function DatabaseId(e, t) {\n _classCallCheck(this, DatabaseId);\n\n this.projectId = e, this.database = t || \"(default)\";\n }\n\n _createClass(DatabaseId, [{\n key: \"isDefaultDatabase\",\n get: function get() {\n return \"(default)\" === this.database;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e instanceof DatabaseId && e.projectId === this.projectId && e.database === this.database;\n }\n }], [{\n key: \"empty\",\n value: function empty() {\n return new DatabaseId(\"\", \"\");\n }\n }]);\n\n return DatabaseId;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar te = {\n mapValue: {\n fields: {\n __type__: {\n stringValue: \"__max__\"\n }\n }\n }\n},\n ne = {\n nullValue: \"NULL_VALUE\"\n};\n/** Extracts the backend's type order for the provided value. */\n\nfunction __PRIVATE_typeOrder(e) {\n return \"nullValue\" in e ? 0\n /* TypeOrder.NullValue */\n : \"booleanValue\" in e ? 1\n /* TypeOrder.BooleanValue */\n : \"integerValue\" in e || \"doubleValue\" in e ? 2\n /* TypeOrder.NumberValue */\n : \"timestampValue\" in e ? 3\n /* TypeOrder.TimestampValue */\n : \"stringValue\" in e ? 5\n /* TypeOrder.StringValue */\n : \"bytesValue\" in e ? 6\n /* TypeOrder.BlobValue */\n : \"referenceValue\" in e ? 7\n /* TypeOrder.RefValue */\n : \"geoPointValue\" in e ? 8\n /* TypeOrder.GeoPointValue */\n : \"arrayValue\" in e ? 9\n /* TypeOrder.ArrayValue */\n : \"mapValue\" in e ? __PRIVATE_isServerTimestamp(e) ? 4\n /* TypeOrder.ServerTimestampValue */\n : __PRIVATE_isMaxValue(e) ? 9007199254740991\n /* TypeOrder.MaxValue */\n : 10\n /* TypeOrder.ObjectValue */\n : fail();\n}\n/** Tests `left` and `right` for equality based on the backend semantics. */\n\n\nfunction __PRIVATE_valueEquals(e, t) {\n if (e === t) return !0;\n\n var n = __PRIVATE_typeOrder(e);\n\n if (n !== __PRIVATE_typeOrder(t)) return !1;\n\n switch (n) {\n case 0\n /* TypeOrder.NullValue */\n :\n case 9007199254740991\n /* TypeOrder.MaxValue */\n :\n return !0;\n\n case 1\n /* TypeOrder.BooleanValue */\n :\n return e.booleanValue === t.booleanValue;\n\n case 4\n /* TypeOrder.ServerTimestampValue */\n :\n return __PRIVATE_getLocalWriteTime(e).isEqual(__PRIVATE_getLocalWriteTime(t));\n\n case 3\n /* TypeOrder.TimestampValue */\n :\n return function __PRIVATE_timestampEquals(e, t) {\n if (\"string\" == typeof e.timestampValue && \"string\" == typeof t.timestampValue && e.timestampValue.length === t.timestampValue.length) // Use string equality for ISO 8601 timestamps\n return e.timestampValue === t.timestampValue;\n\n var n = __PRIVATE_normalizeTimestamp(e.timestampValue),\n r = __PRIVATE_normalizeTimestamp(t.timestampValue);\n\n return n.seconds === r.seconds && n.nanos === r.nanos;\n }(e, t);\n\n case 5\n /* TypeOrder.StringValue */\n :\n return e.stringValue === t.stringValue;\n\n case 6\n /* TypeOrder.BlobValue */\n :\n return function __PRIVATE_blobEquals(e, t) {\n return __PRIVATE_normalizeByteString(e.bytesValue).isEqual(__PRIVATE_normalizeByteString(t.bytesValue));\n }(e, t);\n\n case 7\n /* TypeOrder.RefValue */\n :\n return e.referenceValue === t.referenceValue;\n\n case 8\n /* TypeOrder.GeoPointValue */\n :\n return function __PRIVATE_geoPointEquals(e, t) {\n return __PRIVATE_normalizeNumber(e.geoPointValue.latitude) === __PRIVATE_normalizeNumber(t.geoPointValue.latitude) && __PRIVATE_normalizeNumber(e.geoPointValue.longitude) === __PRIVATE_normalizeNumber(t.geoPointValue.longitude);\n }(e, t);\n\n case 2\n /* TypeOrder.NumberValue */\n :\n return function __PRIVATE_numberEquals(e, t) {\n if (\"integerValue\" in e && \"integerValue\" in t) return __PRIVATE_normalizeNumber(e.integerValue) === __PRIVATE_normalizeNumber(t.integerValue);\n\n if (\"doubleValue\" in e && \"doubleValue\" in t) {\n var _n3 = __PRIVATE_normalizeNumber(e.doubleValue),\n r = __PRIVATE_normalizeNumber(t.doubleValue);\n\n return _n3 === r ? __PRIVATE_isNegativeZero(_n3) === __PRIVATE_isNegativeZero(r) : isNaN(_n3) && isNaN(r);\n }\n\n return !1;\n }(e, t);\n\n case 9\n /* TypeOrder.ArrayValue */\n :\n return __PRIVATE_arrayEquals(e.arrayValue.values || [], t.arrayValue.values || [], __PRIVATE_valueEquals);\n\n case 10\n /* TypeOrder.ObjectValue */\n :\n return function __PRIVATE_objectEquals(e, t) {\n var n = e.mapValue.fields || {},\n r = t.mapValue.fields || {};\n if (__PRIVATE_objectSize(n) !== __PRIVATE_objectSize(r)) return !1;\n\n for (var _e12 in n) {\n if (n.hasOwnProperty(_e12) && (void 0 === r[_e12] || !__PRIVATE_valueEquals(n[_e12], r[_e12]))) return !1;\n }\n\n return !0;\n }\n /** Returns true if the ArrayValue contains the specified element. */\n (e, t);\n\n default:\n return fail();\n }\n}\n\nfunction __PRIVATE_arrayValueContains(e, t) {\n return void 0 !== (e.values || []).find(function (e) {\n return __PRIVATE_valueEquals(e, t);\n });\n}\n\nfunction __PRIVATE_valueCompare(e, t) {\n if (e === t) return 0;\n\n var n = __PRIVATE_typeOrder(e),\n r = __PRIVATE_typeOrder(t);\n\n if (n !== r) return __PRIVATE_primitiveComparator(n, r);\n\n switch (n) {\n case 0\n /* TypeOrder.NullValue */\n :\n case 9007199254740991\n /* TypeOrder.MaxValue */\n :\n return 0;\n\n case 1\n /* TypeOrder.BooleanValue */\n :\n return __PRIVATE_primitiveComparator(e.booleanValue, t.booleanValue);\n\n case 2\n /* TypeOrder.NumberValue */\n :\n return function __PRIVATE_compareNumbers(e, t) {\n var n = __PRIVATE_normalizeNumber(e.integerValue || e.doubleValue),\n r = __PRIVATE_normalizeNumber(t.integerValue || t.doubleValue);\n\n return n < r ? -1 : n > r ? 1 : n === r ? 0 : // one or both are NaN.\n isNaN(n) ? isNaN(r) ? 0 : -1 : 1;\n }(e, t);\n\n case 3\n /* TypeOrder.TimestampValue */\n :\n return __PRIVATE_compareTimestamps(e.timestampValue, t.timestampValue);\n\n case 4\n /* TypeOrder.ServerTimestampValue */\n :\n return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e), __PRIVATE_getLocalWriteTime(t));\n\n case 5\n /* TypeOrder.StringValue */\n :\n return __PRIVATE_primitiveComparator(e.stringValue, t.stringValue);\n\n case 6\n /* TypeOrder.BlobValue */\n :\n return function __PRIVATE_compareBlobs(e, t) {\n var n = __PRIVATE_normalizeByteString(e),\n r = __PRIVATE_normalizeByteString(t);\n\n return n.compareTo(r);\n }(e.bytesValue, t.bytesValue);\n\n case 7\n /* TypeOrder.RefValue */\n :\n return function __PRIVATE_compareReferences(e, t) {\n var n = e.split(\"/\"),\n r = t.split(\"/\");\n\n for (var _e13 = 0; _e13 < n.length && _e13 < r.length; _e13++) {\n var _t9 = __PRIVATE_primitiveComparator(n[_e13], r[_e13]);\n\n if (0 !== _t9) return _t9;\n }\n\n return __PRIVATE_primitiveComparator(n.length, r.length);\n }(e.referenceValue, t.referenceValue);\n\n case 8\n /* TypeOrder.GeoPointValue */\n :\n return function __PRIVATE_compareGeoPoints(e, t) {\n var n = __PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.latitude), __PRIVATE_normalizeNumber(t.latitude));\n\n if (0 !== n) return n;\n return __PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.longitude), __PRIVATE_normalizeNumber(t.longitude));\n }(e.geoPointValue, t.geoPointValue);\n\n case 9\n /* TypeOrder.ArrayValue */\n :\n return function __PRIVATE_compareArrays(e, t) {\n var n = e.values || [],\n r = t.values || [];\n\n for (var _e14 = 0; _e14 < n.length && _e14 < r.length; ++_e14) {\n var _t10 = __PRIVATE_valueCompare(n[_e14], r[_e14]);\n\n if (_t10) return _t10;\n }\n\n return __PRIVATE_primitiveComparator(n.length, r.length);\n }(e.arrayValue, t.arrayValue);\n\n case 10\n /* TypeOrder.ObjectValue */\n :\n return function __PRIVATE_compareMaps(e, t) {\n if (e === te.mapValue && t === te.mapValue) return 0;\n if (e === te.mapValue) return 1;\n if (t === te.mapValue) return -1;\n var n = e.fields || {},\n r = Object.keys(n),\n i = t.fields || {},\n s = Object.keys(i); // Even though MapValues are likely sorted correctly based on their insertion\n // order (e.g. when received from the backend), local modifications can bring\n // elements out of order. We need to re-sort the elements to ensure that\n // canonical IDs are independent of insertion order.\n\n r.sort(), s.sort();\n\n for (var _e15 = 0; _e15 < r.length && _e15 < s.length; ++_e15) {\n var _t11 = __PRIVATE_primitiveComparator(r[_e15], s[_e15]);\n\n if (0 !== _t11) return _t11;\n\n var o = __PRIVATE_valueCompare(n[r[_e15]], i[s[_e15]]);\n\n if (0 !== o) return o;\n }\n\n return __PRIVATE_primitiveComparator(r.length, s.length);\n }\n /**\n * Generates the canonical ID for the provided field value (as used in Target\n * serialization).\n */\n (e.mapValue, t.mapValue);\n\n default:\n throw fail();\n }\n}\n\nfunction __PRIVATE_compareTimestamps(e, t) {\n if (\"string\" == typeof e && \"string\" == typeof t && e.length === t.length) return __PRIVATE_primitiveComparator(e, t);\n\n var n = __PRIVATE_normalizeTimestamp(e),\n r = __PRIVATE_normalizeTimestamp(t),\n i = __PRIVATE_primitiveComparator(n.seconds, r.seconds);\n\n return 0 !== i ? i : __PRIVATE_primitiveComparator(n.nanos, r.nanos);\n}\n\nfunction canonicalId(e) {\n return __PRIVATE_canonifyValue(e);\n}\n\nfunction __PRIVATE_canonifyValue(e) {\n return \"nullValue\" in e ? \"null\" : \"booleanValue\" in e ? \"\" + e.booleanValue : \"integerValue\" in e ? \"\" + e.integerValue : \"doubleValue\" in e ? \"\" + e.doubleValue : \"timestampValue\" in e ? function __PRIVATE_canonifyTimestamp(e) {\n var t = __PRIVATE_normalizeTimestamp(e);\n\n return \"time(\".concat(t.seconds, \",\").concat(t.nanos, \")\");\n }(e.timestampValue) : \"stringValue\" in e ? e.stringValue : \"bytesValue\" in e ? function __PRIVATE_canonifyByteString(e) {\n return __PRIVATE_normalizeByteString(e).toBase64();\n }(e.bytesValue) : \"referenceValue\" in e ? function __PRIVATE_canonifyReference(e) {\n return DocumentKey.fromName(e).toString();\n }(e.referenceValue) : \"geoPointValue\" in e ? function __PRIVATE_canonifyGeoPoint(e) {\n return \"geo(\".concat(e.latitude, \",\").concat(e.longitude, \")\");\n }(e.geoPointValue) : \"arrayValue\" in e ? function __PRIVATE_canonifyArray(e) {\n var t = \"[\",\n n = !0;\n\n var _iterator5 = _createForOfIteratorHelper(e.values || []),\n _step5;\n\n try {\n for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {\n var r = _step5.value;\n n ? n = !1 : t += \",\", t += __PRIVATE_canonifyValue(r);\n }\n } catch (err) {\n _iterator5.e(err);\n } finally {\n _iterator5.f();\n }\n\n return t + \"]\";\n }\n /**\n * Returns an approximate (and wildly inaccurate) in-memory size for the field\n * value.\n *\n * The memory size takes into account only the actual user data as it resides\n * in memory and ignores object overhead.\n */\n (e.arrayValue) : \"mapValue\" in e ? function __PRIVATE_canonifyMap(e) {\n // Iteration order in JavaScript is not guaranteed. To ensure that we generate\n // matching canonical IDs for identical maps, we need to sort the keys.\n var t = Object.keys(e.fields || {}).sort();\n var n = \"{\",\n r = !0;\n\n var _iterator6 = _createForOfIteratorHelper(t),\n _step6;\n\n try {\n for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {\n var i = _step6.value;\n r ? r = !1 : n += \",\", n += \"\".concat(i, \":\").concat(__PRIVATE_canonifyValue(e.fields[i]));\n }\n } catch (err) {\n _iterator6.e(err);\n } finally {\n _iterator6.f();\n }\n\n return n + \"}\";\n }(e.mapValue) : fail();\n}\n\nfunction __PRIVATE_estimateByteSize(e) {\n switch (__PRIVATE_typeOrder(e)) {\n case 0\n /* TypeOrder.NullValue */\n :\n case 1\n /* TypeOrder.BooleanValue */\n :\n return 4;\n\n case 2\n /* TypeOrder.NumberValue */\n :\n return 8;\n\n case 3\n /* TypeOrder.TimestampValue */\n :\n case 8\n /* TypeOrder.GeoPointValue */\n :\n // GeoPoints are made up of two distinct numbers (latitude + longitude)\n return 16;\n\n case 4\n /* TypeOrder.ServerTimestampValue */\n :\n var t = __PRIVATE_getPreviousValue(e);\n\n return t ? 16 + __PRIVATE_estimateByteSize(t) : 16;\n\n case 5\n /* TypeOrder.StringValue */\n :\n // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures:\n // \"JavaScript's String type is [...] a set of elements of 16-bit unsigned\n // integer values\"\n return 2 * e.stringValue.length;\n\n case 6\n /* TypeOrder.BlobValue */\n :\n return __PRIVATE_normalizeByteString(e.bytesValue).approximateByteSize();\n\n case 7\n /* TypeOrder.RefValue */\n :\n return e.referenceValue.length;\n\n case 9\n /* TypeOrder.ArrayValue */\n :\n return function __PRIVATE_estimateArrayByteSize(e) {\n return (e.values || []).reduce(function (e, t) {\n return e + __PRIVATE_estimateByteSize(t);\n }, 0);\n }\n /** Returns a reference value for the provided database and key. */\n (e.arrayValue);\n\n case 10\n /* TypeOrder.ObjectValue */\n :\n return function __PRIVATE_estimateMapByteSize(e) {\n var t = 0;\n return _forEach(e.fields, function (e, n) {\n t += e.length + __PRIVATE_estimateByteSize(n);\n }), t;\n }(e.mapValue);\n\n default:\n throw fail();\n }\n}\n\nfunction __PRIVATE_refValue(e, t) {\n return {\n referenceValue: \"projects/\".concat(e.projectId, \"/databases/\").concat(e.database, \"/documents/\").concat(t.path.canonicalString())\n };\n}\n/** Returns true if `value` is an IntegerValue . */\n\n\nfunction isInteger(e) {\n return !!e && \"integerValue\" in e;\n}\n/** Returns true if `value` is a DoubleValue. */\n\n/** Returns true if `value` is an ArrayValue. */\n\n\nfunction isArray(e) {\n return !!e && \"arrayValue\" in e;\n}\n/** Returns true if `value` is a NullValue. */\n\n\nfunction __PRIVATE_isNullValue(e) {\n return !!e && \"nullValue\" in e;\n}\n/** Returns true if `value` is NaN. */\n\n\nfunction __PRIVATE_isNanValue(e) {\n return !!e && \"doubleValue\" in e && isNaN(Number(e.doubleValue));\n}\n/** Returns true if `value` is a MapValue. */\n\n\nfunction __PRIVATE_isMapValue(e) {\n return !!e && \"mapValue\" in e;\n}\n/** Creates a deep copy of `source`. */\n\n\nfunction __PRIVATE_deepClone(e) {\n if (e.geoPointValue) return {\n geoPointValue: Object.assign({}, e.geoPointValue)\n };\n if (e.timestampValue && \"object\" == typeof e.timestampValue) return {\n timestampValue: Object.assign({}, e.timestampValue)\n };\n\n if (e.mapValue) {\n var t = {\n mapValue: {\n fields: {}\n }\n };\n return _forEach(e.mapValue.fields, function (e, n) {\n return t.mapValue.fields[e] = __PRIVATE_deepClone(n);\n }), t;\n }\n\n if (e.arrayValue) {\n var _t12 = {\n arrayValue: {\n values: []\n }\n };\n\n for (var n = 0; n < (e.arrayValue.values || []).length; ++n) {\n _t12.arrayValue.values[n] = __PRIVATE_deepClone(e.arrayValue.values[n]);\n }\n\n return _t12;\n }\n\n return Object.assign({}, e);\n}\n/** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */\n\n\nfunction __PRIVATE_isMaxValue(e) {\n return \"__max__\" === (((e.mapValue || {}).fields || {}).__type__ || {}).stringValue;\n}\n/** Returns the lowest value for the given value type (inclusive). */\n\n\nfunction __PRIVATE_valuesGetLowerBound(e) {\n return \"nullValue\" in e ? ne : \"booleanValue\" in e ? {\n booleanValue: !1\n } : \"integerValue\" in e || \"doubleValue\" in e ? {\n doubleValue: NaN\n } : \"timestampValue\" in e ? {\n timestampValue: {\n seconds: Number.MIN_SAFE_INTEGER\n }\n } : \"stringValue\" in e ? {\n stringValue: \"\"\n } : \"bytesValue\" in e ? {\n bytesValue: \"\"\n } : \"referenceValue\" in e ? __PRIVATE_refValue(DatabaseId.empty(), DocumentKey.empty()) : \"geoPointValue\" in e ? {\n geoPointValue: {\n latitude: -90,\n longitude: -180\n }\n } : \"arrayValue\" in e ? {\n arrayValue: {}\n } : \"mapValue\" in e ? {\n mapValue: {}\n } : fail();\n}\n/** Returns the largest value for the given value type (exclusive). */\n\n\nfunction __PRIVATE_valuesGetUpperBound(e) {\n return \"nullValue\" in e ? {\n booleanValue: !1\n } : \"booleanValue\" in e ? {\n doubleValue: NaN\n } : \"integerValue\" in e || \"doubleValue\" in e ? {\n timestampValue: {\n seconds: Number.MIN_SAFE_INTEGER\n }\n } : \"timestampValue\" in e ? {\n stringValue: \"\"\n } : \"stringValue\" in e ? {\n bytesValue: \"\"\n } : \"bytesValue\" in e ? __PRIVATE_refValue(DatabaseId.empty(), DocumentKey.empty()) : \"referenceValue\" in e ? {\n geoPointValue: {\n latitude: -90,\n longitude: -180\n }\n } : \"geoPointValue\" in e ? {\n arrayValue: {}\n } : \"arrayValue\" in e ? {\n mapValue: {}\n } : \"mapValue\" in e ? te : fail();\n}\n\nfunction __PRIVATE_lowerBoundCompare(e, t) {\n var n = __PRIVATE_valueCompare(e.value, t.value);\n\n return 0 !== n ? n : e.inclusive && !t.inclusive ? -1 : !e.inclusive && t.inclusive ? 1 : 0;\n}\n\nfunction __PRIVATE_upperBoundCompare(e, t) {\n var n = __PRIVATE_valueCompare(e.value, t.value);\n\n return 0 !== n ? n : e.inclusive && !t.inclusive ? 1 : !e.inclusive && t.inclusive ? -1 : 0;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An ObjectValue represents a MapValue in the Firestore Proto and offers the\n * ability to add and remove fields (via the ObjectValueBuilder).\n */\n\n\nvar ObjectValue = /*#__PURE__*/function () {\n function ObjectValue(e) {\n _classCallCheck(this, ObjectValue);\n\n this.value = e;\n }\n\n _createClass(ObjectValue, [{\n key: \"field\",\n value:\n /**\n * Returns the value at the given path or null.\n *\n * @param path - the path to search\n * @returns The value at the path or null if the path is not set.\n */\n function field(e) {\n if (e.isEmpty()) return this.value;\n {\n var t = this.value;\n\n for (var n = 0; n < e.length - 1; ++n) {\n if (t = (t.mapValue.fields || {})[e.get(n)], !__PRIVATE_isMapValue(t)) return null;\n }\n\n return t = (t.mapValue.fields || {})[e.lastSegment()], t || null;\n }\n }\n /**\n * Sets the field to the provided value.\n *\n * @param path - The field path to set.\n * @param value - The value to set.\n */\n\n }, {\n key: \"set\",\n value: function set(e, t) {\n this.getFieldsMap(e.popLast())[e.lastSegment()] = __PRIVATE_deepClone(t);\n }\n /**\n * Sets the provided fields to the provided values.\n *\n * @param data - A map of fields to values (or null for deletes).\n */\n\n }, {\n key: \"setAll\",\n value: function setAll(e) {\n var _this25 = this;\n\n var t = FieldPath$1.emptyPath(),\n n = {},\n r = [];\n e.forEach(function (e, i) {\n if (!t.isImmediateParentOf(i)) {\n // Insert the accumulated changes at this parent location\n var _e16 = _this25.getFieldsMap(t);\n\n _this25.applyChanges(_e16, n, r), n = {}, r = [], t = i.popLast();\n }\n\n e ? n[i.lastSegment()] = __PRIVATE_deepClone(e) : r.push(i.lastSegment());\n });\n var i = this.getFieldsMap(t);\n this.applyChanges(i, n, r);\n }\n /**\n * Removes the field at the specified path. If there is no field at the\n * specified path, nothing is changed.\n *\n * @param path - The field path to remove.\n */\n\n }, {\n key: \"delete\",\n value: function _delete(e) {\n var t = this.field(e.popLast());\n __PRIVATE_isMapValue(t) && t.mapValue.fields && delete t.mapValue.fields[e.lastSegment()];\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return __PRIVATE_valueEquals(this.value, e.value);\n }\n /**\n * Returns the map that contains the leaf element of `path`. If the parent\n * entry does not yet exist, or if it is not a map, a new map will be created.\n */\n\n }, {\n key: \"getFieldsMap\",\n value: function getFieldsMap(e) {\n var t = this.value;\n t.mapValue.fields || (t.mapValue = {\n fields: {}\n });\n\n for (var n = 0; n < e.length; ++n) {\n var r = t.mapValue.fields[e.get(n)];\n __PRIVATE_isMapValue(r) && r.mapValue.fields || (r = {\n mapValue: {\n fields: {}\n }\n }, t.mapValue.fields[e.get(n)] = r), t = r;\n }\n\n return t.mapValue.fields;\n }\n /**\n * Modifies `fieldsMap` by adding, replacing or deleting the specified\n * entries.\n */\n\n }, {\n key: \"applyChanges\",\n value: function applyChanges(e, t, n) {\n _forEach(t, function (t, n) {\n return e[t] = n;\n });\n\n var _iterator7 = _createForOfIteratorHelper(n),\n _step7;\n\n try {\n for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {\n var _t13 = _step7.value;\n delete e[_t13];\n }\n } catch (err) {\n _iterator7.e(err);\n } finally {\n _iterator7.f();\n }\n }\n }, {\n key: \"clone\",\n value: function clone() {\n return new ObjectValue(__PRIVATE_deepClone(this.value));\n }\n }], [{\n key: \"empty\",\n value: function empty() {\n return new ObjectValue({\n mapValue: {}\n });\n }\n }]);\n\n return ObjectValue;\n}();\n/**\n * Returns a FieldMask built from all fields in a MapValue.\n */\n\n\nfunction __PRIVATE_extractFieldMask(e) {\n var t = [];\n return _forEach(e.fields, function (e, n) {\n var r = new FieldPath$1([e]);\n\n if (__PRIVATE_isMapValue(n)) {\n var _e17 = __PRIVATE_extractFieldMask(n.mapValue).fields;\n\n if (0 === _e17.length) // Preserve the empty map by adding it to the FieldMask.\n t.push(r);else {\n // For nested and non-empty ObjectValues, add the FieldPath of the\n // leaf nodes.\n var _iterator8 = _createForOfIteratorHelper(_e17),\n _step8;\n\n try {\n for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {\n var _n4 = _step8.value;\n t.push(r.child(_n4));\n }\n } catch (err) {\n _iterator8.e(err);\n } finally {\n _iterator8.f();\n }\n }\n } else // For nested and non-empty ObjectValues, add the FieldPath of the leaf\n // nodes.\n t.push(r);\n }), new FieldMask(t);\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents a document in Firestore with a key, version, data and whether it\n * has local mutations applied to it.\n *\n * Documents can transition between states via `convertToFoundDocument()`,\n * `convertToNoDocument()` and `convertToUnknownDocument()`. If a document does\n * not transition to one of these states even after all mutations have been\n * applied, `isValidDocument()` returns false and the document should be removed\n * from all views.\n */\n\n\nvar MutableDocument = /*#__PURE__*/function () {\n function MutableDocument(e, t, n, r, i, s, o) {\n _classCallCheck(this, MutableDocument);\n\n this.key = e, this.documentType = t, this.version = n, this.readTime = r, this.createTime = i, this.data = s, this.documentState = o;\n }\n /**\n * Creates a document with no known version or data, but which can serve as\n * base document for mutations.\n */\n\n\n _createClass(MutableDocument, [{\n key: \"convertToFoundDocument\",\n value:\n /**\n * Changes the document type to indicate that it exists and that its version\n * and data are known.\n */\n function convertToFoundDocument(e, t) {\n // If a document is switching state from being an invalid or deleted\n // document to a valid (FOUND_DOCUMENT) document, either due to receiving an\n // update from Watch or due to applying a local set mutation on top\n // of a deleted document, our best guess about its createTime would be the\n // version at which the document transitioned to a FOUND_DOCUMENT.\n return !this.createTime.isEqual(SnapshotVersion.min()) || 2\n /* DocumentType.NO_DOCUMENT */\n !== this.documentType && 0\n /* DocumentType.INVALID */\n !== this.documentType || (this.createTime = e), this.version = e, this.documentType = 1\n /* DocumentType.FOUND_DOCUMENT */\n , this.data = t, this.documentState = 0\n /* DocumentState.SYNCED */\n , this;\n }\n /**\n * Changes the document type to indicate that it doesn't exist at the given\n * version.\n */\n\n }, {\n key: \"convertToNoDocument\",\n value: function convertToNoDocument(e) {\n return this.version = e, this.documentType = 2\n /* DocumentType.NO_DOCUMENT */\n , this.data = ObjectValue.empty(), this.documentState = 0\n /* DocumentState.SYNCED */\n , this;\n }\n /**\n * Changes the document type to indicate that it exists at a given version but\n * that its data is not known (e.g. a document that was updated without a known\n * base document).\n */\n\n }, {\n key: \"convertToUnknownDocument\",\n value: function convertToUnknownDocument(e) {\n return this.version = e, this.documentType = 3\n /* DocumentType.UNKNOWN_DOCUMENT */\n , this.data = ObjectValue.empty(), this.documentState = 2\n /* DocumentState.HAS_COMMITTED_MUTATIONS */\n , this;\n }\n }, {\n key: \"setHasCommittedMutations\",\n value: function setHasCommittedMutations() {\n return this.documentState = 2\n /* DocumentState.HAS_COMMITTED_MUTATIONS */\n , this;\n }\n }, {\n key: \"setHasLocalMutations\",\n value: function setHasLocalMutations() {\n return this.documentState = 1\n /* DocumentState.HAS_LOCAL_MUTATIONS */\n , this.version = SnapshotVersion.min(), this;\n }\n }, {\n key: \"setReadTime\",\n value: function setReadTime(e) {\n return this.readTime = e, this;\n }\n }, {\n key: \"hasLocalMutations\",\n get: function get() {\n return 1\n /* DocumentState.HAS_LOCAL_MUTATIONS */\n === this.documentState;\n }\n }, {\n key: \"hasCommittedMutations\",\n get: function get() {\n return 2\n /* DocumentState.HAS_COMMITTED_MUTATIONS */\n === this.documentState;\n }\n }, {\n key: \"hasPendingWrites\",\n get: function get() {\n return this.hasLocalMutations || this.hasCommittedMutations;\n }\n }, {\n key: \"isValidDocument\",\n value: function isValidDocument() {\n return 0\n /* DocumentType.INVALID */\n !== this.documentType;\n }\n }, {\n key: \"isFoundDocument\",\n value: function isFoundDocument() {\n return 1\n /* DocumentType.FOUND_DOCUMENT */\n === this.documentType;\n }\n }, {\n key: \"isNoDocument\",\n value: function isNoDocument() {\n return 2\n /* DocumentType.NO_DOCUMENT */\n === this.documentType;\n }\n }, {\n key: \"isUnknownDocument\",\n value: function isUnknownDocument() {\n return 3\n /* DocumentType.UNKNOWN_DOCUMENT */\n === this.documentType;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e instanceof MutableDocument && this.key.isEqual(e.key) && this.version.isEqual(e.version) && this.documentType === e.documentType && this.documentState === e.documentState && this.data.isEqual(e.data);\n }\n }, {\n key: \"mutableCopy\",\n value: function mutableCopy() {\n return new MutableDocument(this.key, this.documentType, this.version, this.readTime, this.createTime, this.data.clone(), this.documentState);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return \"Document(\".concat(this.key, \", \").concat(this.version, \", \").concat(JSON.stringify(this.data.value), \", {createTime: \").concat(this.createTime, \"}), {documentType: \").concat(this.documentType, \"}), {documentState: \").concat(this.documentState, \"})\");\n }\n }], [{\n key: \"newInvalidDocument\",\n value: function newInvalidDocument(e) {\n return new MutableDocument(e, 0\n /* DocumentType.INVALID */\n ,\n /* version */\n SnapshotVersion.min(),\n /* readTime */\n SnapshotVersion.min(),\n /* createTime */\n SnapshotVersion.min(), ObjectValue.empty(), 0\n /* DocumentState.SYNCED */\n );\n }\n /**\n * Creates a new document that is known to exist with the given data at the\n * given version.\n */\n\n }, {\n key: \"newFoundDocument\",\n value: function newFoundDocument(e, t, n, r) {\n return new MutableDocument(e, 1\n /* DocumentType.FOUND_DOCUMENT */\n ,\n /* version */\n t,\n /* readTime */\n SnapshotVersion.min(),\n /* createTime */\n n, r, 0\n /* DocumentState.SYNCED */\n );\n }\n /** Creates a new document that is known to not exist at the given version. */\n\n }, {\n key: \"newNoDocument\",\n value: function newNoDocument(e, t) {\n return new MutableDocument(e, 2\n /* DocumentType.NO_DOCUMENT */\n ,\n /* version */\n t,\n /* readTime */\n SnapshotVersion.min(),\n /* createTime */\n SnapshotVersion.min(), ObjectValue.empty(), 0\n /* DocumentState.SYNCED */\n );\n }\n /**\n * Creates a new document that is known to exist at the given version but\n * whose data is not known (e.g. a document that was updated without a known\n * base document).\n */\n\n }, {\n key: \"newUnknownDocument\",\n value: function newUnknownDocument(e, t) {\n return new MutableDocument(e, 3\n /* DocumentType.UNKNOWN_DOCUMENT */\n ,\n /* version */\n t,\n /* readTime */\n SnapshotVersion.min(),\n /* createTime */\n SnapshotVersion.min(), ObjectValue.empty(), 2\n /* DocumentState.HAS_COMMITTED_MUTATIONS */\n );\n }\n }]);\n\n return MutableDocument;\n}();\n/**\n * Compares the value for field `field` in the provided documents. Throws if\n * the field does not exist in both documents.\n */\n\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents a bound of a query.\n *\n * The bound is specified with the given components representing a position and\n * whether it's just before or just after the position (relative to whatever the\n * query order is).\n *\n * The position represents a logical index position for a query. It's a prefix\n * of values for the (potentially implicit) order by clauses of a query.\n *\n * Bound provides a function to determine whether a document comes before or\n * after a bound. This is influenced by whether the position is just before or\n * just after the provided values.\n */\n\n\nvar Bound = /*#__PURE__*/_createClass(function Bound(e, t) {\n _classCallCheck(this, Bound);\n\n this.position = e, this.inclusive = t;\n});\n\nfunction __PRIVATE_boundCompareToDocument(e, t, n) {\n var r = 0;\n\n for (var i = 0; i < e.position.length; i++) {\n var s = t[i],\n o = e.position[i];\n if (s.field.isKeyField()) r = DocumentKey.comparator(DocumentKey.fromName(o.referenceValue), n.key);else {\n r = __PRIVATE_valueCompare(o, n.data.field(s.field));\n }\n if (\"desc\"\n /* Direction.DESCENDING */\n === s.dir && (r *= -1), 0 !== r) break;\n }\n\n return r;\n}\n/**\n * Returns true if a document sorts after a bound using the provided sort\n * order.\n */\n\n\nfunction __PRIVATE_boundEquals(e, t) {\n if (null === e) return null === t;\n if (null === t) return !1;\n if (e.inclusive !== t.inclusive || e.position.length !== t.position.length) return !1;\n\n for (var n = 0; n < e.position.length; n++) {\n if (!__PRIVATE_valueEquals(e.position[n], t.position[n])) return !1;\n }\n\n return !0;\n}\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An ordering on a field, in some Direction. Direction defaults to ASCENDING.\n */\n\n\nvar OrderBy = /*#__PURE__*/_createClass(function OrderBy(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"asc\";\n\n _classCallCheck(this, OrderBy);\n\n this.field = e, this.dir = t;\n});\n\nfunction __PRIVATE_orderByEquals(e, t) {\n return e.dir === t.dir && e.field.isEqual(t.field);\n}\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar Filter = /*#__PURE__*/_createClass(function Filter() {\n _classCallCheck(this, Filter);\n});\n\nvar FieldFilter = /*#__PURE__*/function (_Filter) {\n _inherits(FieldFilter, _Filter);\n\n var _super7 = _createSuper(FieldFilter);\n\n function FieldFilter(e, t, n) {\n var _this26;\n\n _classCallCheck(this, FieldFilter);\n\n _this26 = _super7.call(this), _this26.field = e, _this26.op = t, _this26.value = n;\n return _this26;\n }\n /**\n * Creates a filter based on the provided arguments.\n */\n\n\n _createClass(FieldFilter, [{\n key: \"matches\",\n value: function matches(e) {\n var t = e.data.field(this.field); // Types do not have to match in NOT_EQUAL filters.\n\n return \"!=\"\n /* Operator.NOT_EQUAL */\n === this.op ? null !== t && this.matchesComparison(__PRIVATE_valueCompare(t, this.value)) : null !== t && __PRIVATE_typeOrder(this.value) === __PRIVATE_typeOrder(t) && this.matchesComparison(__PRIVATE_valueCompare(t, this.value)); // Only compare types with matching backend order (such as double and int).\n }\n }, {\n key: \"matchesComparison\",\n value: function matchesComparison(e) {\n switch (this.op) {\n case \"<\"\n /* Operator.LESS_THAN */\n :\n return e < 0;\n\n case \"<=\"\n /* Operator.LESS_THAN_OR_EQUAL */\n :\n return e <= 0;\n\n case \"==\"\n /* Operator.EQUAL */\n :\n return 0 === e;\n\n case \"!=\"\n /* Operator.NOT_EQUAL */\n :\n return 0 !== e;\n\n case \">\"\n /* Operator.GREATER_THAN */\n :\n return e > 0;\n\n case \">=\"\n /* Operator.GREATER_THAN_OR_EQUAL */\n :\n return e >= 0;\n\n default:\n return fail();\n }\n }\n }, {\n key: \"isInequality\",\n value: function isInequality() {\n return [\"<\"\n /* Operator.LESS_THAN */\n , \"<=\"\n /* Operator.LESS_THAN_OR_EQUAL */\n , \">\"\n /* Operator.GREATER_THAN */\n , \">=\"\n /* Operator.GREATER_THAN_OR_EQUAL */\n , \"!=\"\n /* Operator.NOT_EQUAL */\n , \"not-in\"\n /* Operator.NOT_IN */\n ].indexOf(this.op) >= 0;\n }\n }, {\n key: \"getFlattenedFilters\",\n value: function getFlattenedFilters() {\n return [this];\n }\n }, {\n key: \"getFilters\",\n value: function getFilters() {\n return [this];\n }\n }], [{\n key: \"create\",\n value: function create(e, t, n) {\n return e.isKeyField() ? \"in\"\n /* Operator.IN */\n === t || \"not-in\"\n /* Operator.NOT_IN */\n === t ? this.createKeyFieldInFilter(e, t, n) : new __PRIVATE_KeyFieldFilter(e, t, n) : \"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n === t ? new __PRIVATE_ArrayContainsFilter(e, n) : \"in\"\n /* Operator.IN */\n === t ? new __PRIVATE_InFilter(e, n) : \"not-in\"\n /* Operator.NOT_IN */\n === t ? new __PRIVATE_NotInFilter(e, n) : \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n === t ? new __PRIVATE_ArrayContainsAnyFilter(e, n) : new FieldFilter(e, t, n);\n }\n }, {\n key: \"createKeyFieldInFilter\",\n value: function createKeyFieldInFilter(e, t, n) {\n return \"in\"\n /* Operator.IN */\n === t ? new __PRIVATE_KeyFieldInFilter(e, n) : new __PRIVATE_KeyFieldNotInFilter(e, n);\n }\n }]);\n\n return FieldFilter;\n}(Filter);\n\nvar CompositeFilter = /*#__PURE__*/function (_Filter2) {\n _inherits(CompositeFilter, _Filter2);\n\n var _super8 = _createSuper(CompositeFilter);\n\n function CompositeFilter(e, t) {\n var _this27;\n\n _classCallCheck(this, CompositeFilter);\n\n _this27 = _super8.call(this), _this27.filters = e, _this27.op = t, _this27.ue = null;\n return _this27;\n }\n /**\n * Creates a filter based on the provided arguments.\n */\n\n\n _createClass(CompositeFilter, [{\n key: \"matches\",\n value: function matches(e) {\n return __PRIVATE_compositeFilterIsConjunction(this) ? void 0 === this.filters.find(function (t) {\n return !t.matches(e);\n }) : void 0 !== this.filters.find(function (t) {\n return t.matches(e);\n });\n }\n }, {\n key: \"getFlattenedFilters\",\n value: function getFlattenedFilters() {\n return null !== this.ue || (this.ue = this.filters.reduce(function (e, t) {\n return e.concat(t.getFlattenedFilters());\n }, [])), this.ue;\n } // Returns a mutable copy of `this.filters`\n\n }, {\n key: \"getFilters\",\n value: function getFilters() {\n return Object.assign([], this.filters);\n }\n }], [{\n key: \"create\",\n value: function create(e, t) {\n return new CompositeFilter(e, t);\n }\n }]);\n\n return CompositeFilter;\n}(Filter);\n\nfunction __PRIVATE_compositeFilterIsConjunction(e) {\n return \"and\"\n /* CompositeOperator.AND */\n === e.op;\n}\n\nfunction __PRIVATE_compositeFilterIsDisjunction(e) {\n return \"or\"\n /* CompositeOperator.OR */\n === e.op;\n}\n/**\n * Returns true if this filter is a conjunction of field filters only. Returns false otherwise.\n */\n\n\nfunction __PRIVATE_compositeFilterIsFlatConjunction(e) {\n return __PRIVATE_compositeFilterIsFlat(e) && __PRIVATE_compositeFilterIsConjunction(e);\n}\n/**\n * Returns true if this filter does not contain any composite filters. Returns false otherwise.\n */\n\n\nfunction __PRIVATE_compositeFilterIsFlat(e) {\n var _iterator9 = _createForOfIteratorHelper(e.filters),\n _step9;\n\n try {\n for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {\n var t = _step9.value;\n if (t instanceof CompositeFilter) return !1;\n }\n } catch (err) {\n _iterator9.e(err);\n } finally {\n _iterator9.f();\n }\n\n return !0;\n}\n\nfunction __PRIVATE_canonifyFilter(e) {\n if (e instanceof FieldFilter) // TODO(b/29183165): Technically, this won't be unique if two values have\n // the same description, such as the int 3 and the string \"3\". So we should\n // add the types in here somehow, too.\n return e.field.canonicalString() + e.op.toString() + canonicalId(e.value);\n if (__PRIVATE_compositeFilterIsFlatConjunction(e)) // Older SDK versions use an implicit AND operation between their filters.\n // In the new SDK versions, the developer may use an explicit AND filter.\n // To stay consistent with the old usages, we add a special case to ensure\n // the canonical ID for these two are the same. For example:\n // `col.whereEquals(\"a\", 1).whereEquals(\"b\", 2)` should have the same\n // canonical ID as `col.where(and(equals(\"a\",1), equals(\"b\",2)))`.\n return e.filters.map(function (e) {\n return __PRIVATE_canonifyFilter(e);\n }).join(\",\");\n {\n // filter instanceof CompositeFilter\n var t = e.filters.map(function (e) {\n return __PRIVATE_canonifyFilter(e);\n }).join(\",\");\n return \"\".concat(e.op, \"(\").concat(t, \")\");\n }\n}\n\nfunction __PRIVATE_filterEquals(e, t) {\n return e instanceof FieldFilter ? function __PRIVATE_fieldFilterEquals(e, t) {\n return t instanceof FieldFilter && e.op === t.op && e.field.isEqual(t.field) && __PRIVATE_valueEquals(e.value, t.value);\n }(e, t) : e instanceof CompositeFilter ? function __PRIVATE_compositeFilterEquals(e, t) {\n if (t instanceof CompositeFilter && e.op === t.op && e.filters.length === t.filters.length) {\n return e.filters.reduce(function (e, n, r) {\n return e && __PRIVATE_filterEquals(n, t.filters[r]);\n }, !0);\n }\n\n return !1;\n }\n /**\n * Returns a new composite filter that contains all filter from\n * `compositeFilter` plus all the given filters in `otherFilters`.\n */\n (e, t) : void fail();\n}\n\nfunction __PRIVATE_compositeFilterWithAddedFilters(e, t) {\n var n = e.filters.concat(t);\n return CompositeFilter.create(n, e.op);\n}\n/** Returns a debug description for `filter`. */\n\n\nfunction __PRIVATE_stringifyFilter(e) {\n return e instanceof FieldFilter ? function __PRIVATE_stringifyFieldFilter(e) {\n return \"\".concat(e.field.canonicalString(), \" \").concat(e.op, \" \").concat(canonicalId(e.value));\n }\n /** Filter that matches on key fields (i.e. '__name__'). */\n (e) : e instanceof CompositeFilter ? function __PRIVATE_stringifyCompositeFilter(e) {\n return e.op.toString() + \" {\" + e.getFilters().map(__PRIVATE_stringifyFilter).join(\" ,\") + \"}\";\n }(e) : \"Filter\";\n}\n\nvar __PRIVATE_KeyFieldFilter = /*#__PURE__*/function (_FieldFilter) {\n _inherits(__PRIVATE_KeyFieldFilter, _FieldFilter);\n\n var _super9 = _createSuper(__PRIVATE_KeyFieldFilter);\n\n function __PRIVATE_KeyFieldFilter(e, t, n) {\n var _this28;\n\n _classCallCheck(this, __PRIVATE_KeyFieldFilter);\n\n _this28 = _super9.call(this, e, t, n), _this28.key = DocumentKey.fromName(n.referenceValue);\n return _this28;\n }\n\n _createClass(__PRIVATE_KeyFieldFilter, [{\n key: \"matches\",\n value: function matches(e) {\n var t = DocumentKey.comparator(e.key, this.key);\n return this.matchesComparison(t);\n }\n }]);\n\n return __PRIVATE_KeyFieldFilter;\n}(FieldFilter);\n/** Filter that matches on key fields within an array. */\n\n\nvar __PRIVATE_KeyFieldInFilter = /*#__PURE__*/function (_FieldFilter2) {\n _inherits(__PRIVATE_KeyFieldInFilter, _FieldFilter2);\n\n var _super10 = _createSuper(__PRIVATE_KeyFieldInFilter);\n\n function __PRIVATE_KeyFieldInFilter(e, t) {\n var _this29;\n\n _classCallCheck(this, __PRIVATE_KeyFieldInFilter);\n\n _this29 = _super10.call(this, e, \"in\"\n /* Operator.IN */\n , t), _this29.keys = __PRIVATE_extractDocumentKeysFromArrayValue(\"in\"\n /* Operator.IN */\n , t);\n return _this29;\n }\n\n _createClass(__PRIVATE_KeyFieldInFilter, [{\n key: \"matches\",\n value: function matches(e) {\n return this.keys.some(function (t) {\n return t.isEqual(e.key);\n });\n }\n }]);\n\n return __PRIVATE_KeyFieldInFilter;\n}(FieldFilter);\n/** Filter that matches on key fields not present within an array. */\n\n\nvar __PRIVATE_KeyFieldNotInFilter = /*#__PURE__*/function (_FieldFilter3) {\n _inherits(__PRIVATE_KeyFieldNotInFilter, _FieldFilter3);\n\n var _super11 = _createSuper(__PRIVATE_KeyFieldNotInFilter);\n\n function __PRIVATE_KeyFieldNotInFilter(e, t) {\n var _this30;\n\n _classCallCheck(this, __PRIVATE_KeyFieldNotInFilter);\n\n _this30 = _super11.call(this, e, \"not-in\"\n /* Operator.NOT_IN */\n , t), _this30.keys = __PRIVATE_extractDocumentKeysFromArrayValue(\"not-in\"\n /* Operator.NOT_IN */\n , t);\n return _this30;\n }\n\n _createClass(__PRIVATE_KeyFieldNotInFilter, [{\n key: \"matches\",\n value: function matches(e) {\n return !this.keys.some(function (t) {\n return t.isEqual(e.key);\n });\n }\n }]);\n\n return __PRIVATE_KeyFieldNotInFilter;\n}(FieldFilter);\n\nfunction __PRIVATE_extractDocumentKeysFromArrayValue(e, t) {\n var n;\n return ((null === (n = t.arrayValue) || void 0 === n ? void 0 : n.values) || []).map(function (e) {\n return DocumentKey.fromName(e.referenceValue);\n });\n}\n/** A Filter that implements the array-contains operator. */\n\n\nvar __PRIVATE_ArrayContainsFilter = /*#__PURE__*/function (_FieldFilter4) {\n _inherits(__PRIVATE_ArrayContainsFilter, _FieldFilter4);\n\n var _super12 = _createSuper(__PRIVATE_ArrayContainsFilter);\n\n function __PRIVATE_ArrayContainsFilter(e, t) {\n _classCallCheck(this, __PRIVATE_ArrayContainsFilter);\n\n return _super12.call(this, e, \"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n , t);\n }\n\n _createClass(__PRIVATE_ArrayContainsFilter, [{\n key: \"matches\",\n value: function matches(e) {\n var t = e.data.field(this.field);\n return isArray(t) && __PRIVATE_arrayValueContains(t.arrayValue, this.value);\n }\n }]);\n\n return __PRIVATE_ArrayContainsFilter;\n}(FieldFilter);\n/** A Filter that implements the IN operator. */\n\n\nvar __PRIVATE_InFilter = /*#__PURE__*/function (_FieldFilter5) {\n _inherits(__PRIVATE_InFilter, _FieldFilter5);\n\n var _super13 = _createSuper(__PRIVATE_InFilter);\n\n function __PRIVATE_InFilter(e, t) {\n _classCallCheck(this, __PRIVATE_InFilter);\n\n return _super13.call(this, e, \"in\"\n /* Operator.IN */\n , t);\n }\n\n _createClass(__PRIVATE_InFilter, [{\n key: \"matches\",\n value: function matches(e) {\n var t = e.data.field(this.field);\n return null !== t && __PRIVATE_arrayValueContains(this.value.arrayValue, t);\n }\n }]);\n\n return __PRIVATE_InFilter;\n}(FieldFilter);\n/** A Filter that implements the not-in operator. */\n\n\nvar __PRIVATE_NotInFilter = /*#__PURE__*/function (_FieldFilter6) {\n _inherits(__PRIVATE_NotInFilter, _FieldFilter6);\n\n var _super14 = _createSuper(__PRIVATE_NotInFilter);\n\n function __PRIVATE_NotInFilter(e, t) {\n _classCallCheck(this, __PRIVATE_NotInFilter);\n\n return _super14.call(this, e, \"not-in\"\n /* Operator.NOT_IN */\n , t);\n }\n\n _createClass(__PRIVATE_NotInFilter, [{\n key: \"matches\",\n value: function matches(e) {\n if (__PRIVATE_arrayValueContains(this.value.arrayValue, {\n nullValue: \"NULL_VALUE\"\n })) return !1;\n var t = e.data.field(this.field);\n return null !== t && !__PRIVATE_arrayValueContains(this.value.arrayValue, t);\n }\n }]);\n\n return __PRIVATE_NotInFilter;\n}(FieldFilter);\n/** A Filter that implements the array-contains-any operator. */\n\n\nvar __PRIVATE_ArrayContainsAnyFilter = /*#__PURE__*/function (_FieldFilter7) {\n _inherits(__PRIVATE_ArrayContainsAnyFilter, _FieldFilter7);\n\n var _super15 = _createSuper(__PRIVATE_ArrayContainsAnyFilter);\n\n function __PRIVATE_ArrayContainsAnyFilter(e, t) {\n _classCallCheck(this, __PRIVATE_ArrayContainsAnyFilter);\n\n return _super15.call(this, e, \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n , t);\n }\n\n _createClass(__PRIVATE_ArrayContainsAnyFilter, [{\n key: \"matches\",\n value: function matches(e) {\n var _this31 = this;\n\n var t = e.data.field(this.field);\n return !(!isArray(t) || !t.arrayValue.values) && t.arrayValue.values.some(function (e) {\n return __PRIVATE_arrayValueContains(_this31.value.arrayValue, e);\n });\n }\n }]);\n\n return __PRIVATE_ArrayContainsAnyFilter;\n}(FieldFilter);\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Visible for testing\n\n\nvar __PRIVATE_TargetImpl = /*#__PURE__*/_createClass(function __PRIVATE_TargetImpl(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;\n var s = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;\n var o = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;\n\n _classCallCheck(this, __PRIVATE_TargetImpl);\n\n this.path = e, this.collectionGroup = t, this.orderBy = n, this.filters = r, this.limit = i, this.startAt = s, this.endAt = o, this.ce = null;\n});\n/**\n * Initializes a Target with a path and optional additional query constraints.\n * Path must currently be empty if this is a collection group query.\n *\n * NOTE: you should always construct `Target` from `Query.toTarget` instead of\n * using this factory method, because `Query` provides an implicit `orderBy`\n * property.\n */\n\n\nfunction __PRIVATE_newTarget(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;\n var s = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;\n var o = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;\n return new __PRIVATE_TargetImpl(e, t, n, r, i, s, o);\n}\n\nfunction __PRIVATE_canonifyTarget(e) {\n var t = __PRIVATE_debugCast(e);\n\n if (null === t.ce) {\n var _e18 = t.path.canonicalString();\n\n null !== t.collectionGroup && (_e18 += \"|cg:\" + t.collectionGroup), _e18 += \"|f:\", _e18 += t.filters.map(function (e) {\n return __PRIVATE_canonifyFilter(e);\n }).join(\",\"), _e18 += \"|ob:\", _e18 += t.orderBy.map(function (e) {\n return function __PRIVATE_canonifyOrderBy(e) {\n // TODO(b/29183165): Make this collision robust.\n return e.field.canonicalString() + e.dir;\n }(e);\n }).join(\",\"), __PRIVATE_isNullOrUndefined(t.limit) || (_e18 += \"|l:\", _e18 += t.limit), t.startAt && (_e18 += \"|lb:\", _e18 += t.startAt.inclusive ? \"b:\" : \"a:\", _e18 += t.startAt.position.map(function (e) {\n return canonicalId(e);\n }).join(\",\")), t.endAt && (_e18 += \"|ub:\", _e18 += t.endAt.inclusive ? \"a:\" : \"b:\", _e18 += t.endAt.position.map(function (e) {\n return canonicalId(e);\n }).join(\",\")), t.ce = _e18;\n }\n\n return t.ce;\n}\n\nfunction __PRIVATE_targetEquals(e, t) {\n if (e.limit !== t.limit) return !1;\n if (e.orderBy.length !== t.orderBy.length) return !1;\n\n for (var n = 0; n < e.orderBy.length; n++) {\n if (!__PRIVATE_orderByEquals(e.orderBy[n], t.orderBy[n])) return !1;\n }\n\n if (e.filters.length !== t.filters.length) return !1;\n\n for (var _n5 = 0; _n5 < e.filters.length; _n5++) {\n if (!__PRIVATE_filterEquals(e.filters[_n5], t.filters[_n5])) return !1;\n }\n\n return e.collectionGroup === t.collectionGroup && !!e.path.isEqual(t.path) && !!__PRIVATE_boundEquals(e.startAt, t.startAt) && __PRIVATE_boundEquals(e.endAt, t.endAt);\n}\n\nfunction __PRIVATE_targetIsDocumentTarget(e) {\n return DocumentKey.isDocumentKey(e.path) && null === e.collectionGroup && 0 === e.filters.length;\n}\n/** Returns the field filters that target the given field path. */\n\n\nfunction __PRIVATE_targetGetFieldFiltersForPath(e, t) {\n return e.filters.filter(function (e) {\n return e instanceof FieldFilter && e.field.isEqual(t);\n });\n}\n/**\n * Returns the values that are used in ARRAY_CONTAINS or ARRAY_CONTAINS_ANY\n * filters. Returns `null` if there are no such filters.\n */\n\n/**\n * Returns the value to use as the lower bound for ascending index segment at\n * the provided `fieldPath` (or the upper bound for an descending segment).\n */\n\n\nfunction __PRIVATE_targetGetAscendingBound(e, t, n) {\n var r = ne,\n i = !0; // Process all filters to find a value for the current field segment\n\n var _iterator10 = _createForOfIteratorHelper(__PRIVATE_targetGetFieldFiltersForPath(e, t)),\n _step10;\n\n try {\n for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {\n var _n6 = _step10.value;\n\n var _e20 = ne,\n _t14 = !0;\n\n switch (_n6.op) {\n case \"<\"\n /* Operator.LESS_THAN */\n :\n case \"<=\"\n /* Operator.LESS_THAN_OR_EQUAL */\n :\n _e20 = __PRIVATE_valuesGetLowerBound(_n6.value);\n break;\n\n case \"==\"\n /* Operator.EQUAL */\n :\n case \"in\"\n /* Operator.IN */\n :\n case \">=\"\n /* Operator.GREATER_THAN_OR_EQUAL */\n :\n _e20 = _n6.value;\n break;\n\n case \">\"\n /* Operator.GREATER_THAN */\n :\n _e20 = _n6.value, _t14 = !1;\n break;\n\n case \"!=\"\n /* Operator.NOT_EQUAL */\n :\n case \"not-in\"\n /* Operator.NOT_IN */\n :\n _e20 = ne;\n // Remaining filters cannot be used as lower bounds.\n }\n\n __PRIVATE_lowerBoundCompare({\n value: r,\n inclusive: i\n }, {\n value: _e20,\n inclusive: _t14\n }) < 0 && (r = _e20, i = _t14);\n } // If there is an additional bound, compare the values against the existing\n // range to see if we can narrow the scope.\n\n } catch (err) {\n _iterator10.e(err);\n } finally {\n _iterator10.f();\n }\n\n if (null !== n) for (var s = 0; s < e.orderBy.length; ++s) {\n if (e.orderBy[s].field.isEqual(t)) {\n var _e19 = n.position[s];\n __PRIVATE_lowerBoundCompare({\n value: r,\n inclusive: i\n }, {\n value: _e19,\n inclusive: n.inclusive\n }) < 0 && (r = _e19, i = n.inclusive);\n break;\n }\n }\n return {\n value: r,\n inclusive: i\n };\n}\n/**\n * Returns the value to use as the upper bound for ascending index segment at\n * the provided `fieldPath` (or the lower bound for a descending segment).\n */\n\n\nfunction __PRIVATE_targetGetDescendingBound(e, t, n) {\n var r = te,\n i = !0; // Process all filters to find a value for the current field segment\n\n var _iterator11 = _createForOfIteratorHelper(__PRIVATE_targetGetFieldFiltersForPath(e, t)),\n _step11;\n\n try {\n for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {\n var _n7 = _step11.value;\n\n var _e22 = te,\n _t15 = !0;\n\n switch (_n7.op) {\n case \">=\"\n /* Operator.GREATER_THAN_OR_EQUAL */\n :\n case \">\"\n /* Operator.GREATER_THAN */\n :\n _e22 = __PRIVATE_valuesGetUpperBound(_n7.value), _t15 = !1;\n break;\n\n case \"==\"\n /* Operator.EQUAL */\n :\n case \"in\"\n /* Operator.IN */\n :\n case \"<=\"\n /* Operator.LESS_THAN_OR_EQUAL */\n :\n _e22 = _n7.value;\n break;\n\n case \"<\"\n /* Operator.LESS_THAN */\n :\n _e22 = _n7.value, _t15 = !1;\n break;\n\n case \"!=\"\n /* Operator.NOT_EQUAL */\n :\n case \"not-in\"\n /* Operator.NOT_IN */\n :\n _e22 = te;\n // Remaining filters cannot be used as upper bounds.\n }\n\n __PRIVATE_upperBoundCompare({\n value: r,\n inclusive: i\n }, {\n value: _e22,\n inclusive: _t15\n }) > 0 && (r = _e22, i = _t15);\n } // If there is an additional bound, compare the values against the existing\n // range to see if we can narrow the scope.\n\n } catch (err) {\n _iterator11.e(err);\n } finally {\n _iterator11.f();\n }\n\n if (null !== n) for (var s = 0; s < e.orderBy.length; ++s) {\n if (e.orderBy[s].field.isEqual(t)) {\n var _e21 = n.position[s];\n __PRIVATE_upperBoundCompare({\n value: r,\n inclusive: i\n }, {\n value: _e21,\n inclusive: n.inclusive\n }) > 0 && (r = _e21, i = n.inclusive);\n break;\n }\n }\n return {\n value: r,\n inclusive: i\n };\n}\n/** Returns the number of segments of a perfect index for this target. */\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Query encapsulates all the query attributes we support in the SDK. It can\n * be run against the LocalStore, as well as be converted to a `Target` to\n * query the RemoteStore results.\n *\n * Visible for testing.\n */\n\n\nvar __PRIVATE_QueryImpl = /*#__PURE__*/_createClass(\n/**\n * Initializes a Query with a path and optional additional query constraints.\n * Path must currently be empty if this is a collection group query.\n */\nfunction __PRIVATE_QueryImpl(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;\n var s = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : \"F\";\n var o = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;\n\n var _ = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;\n\n _classCallCheck(this, __PRIVATE_QueryImpl);\n\n this.path = e, this.collectionGroup = t, this.explicitOrderBy = n, this.filters = r, this.limit = i, this.limitType = s, this.startAt = o, this.endAt = _, this.le = null, // The corresponding `Target` of this `Query` instance, for use with\n // non-aggregate queries.\n this.he = null, // The corresponding `Target` of this `Query` instance, for use with\n // aggregate queries. Unlike targets for non-aggregate queries,\n // aggregate query targets do not contain normalized order-bys, they only\n // contain explicit order-bys.\n this.Pe = null, this.startAt, this.endAt;\n});\n/** Creates a new Query instance with the options provided. */\n\n\nfunction __PRIVATE_newQuery(e, t, n, r, i, s, o, _) {\n return new __PRIVATE_QueryImpl(e, t, n, r, i, s, o, _);\n}\n/** Creates a new Query for a query that matches all documents at `path` */\n\n\nfunction __PRIVATE_newQueryForPath(e) {\n return new __PRIVATE_QueryImpl(e);\n}\n/**\n * Helper to convert a collection group query into a collection query at a\n * specific path. This is used when executing collection group queries, since\n * we have to split the query into a set of collection queries at multiple\n * paths.\n */\n\n/**\n * Returns true if this query does not specify any query constraints that\n * could remove results.\n */\n\n\nfunction __PRIVATE_queryMatchesAllDocuments(e) {\n return 0 === e.filters.length && null === e.limit && null == e.startAt && null == e.endAt && (0 === e.explicitOrderBy.length || 1 === e.explicitOrderBy.length && e.explicitOrderBy[0].field.isKeyField());\n} // Returns the sorted set of inequality filter fields used in this query.\n\n/**\n * Returns whether the query matches a collection group rather than a specific\n * collection.\n */\n\n\nfunction __PRIVATE_isCollectionGroupQuery(e) {\n return null !== e.collectionGroup;\n}\n/**\n * Returns the normalized order-by constraint that is used to execute the Query,\n * which can be different from the order-by constraints the user provided (e.g.\n * the SDK and backend always orders by `__name__`). The normalized order-by\n * includes implicit order-bys in addition to the explicit user provided\n * order-bys.\n */\n\n\nfunction __PRIVATE_queryNormalizedOrderBy(e) {\n var t = __PRIVATE_debugCast(e);\n\n if (null === t.le) {\n t.le = [];\n\n var _e23 = new Set(); // Any explicit order by fields should be added as is.\n\n\n var _iterator12 = _createForOfIteratorHelper(t.explicitOrderBy),\n _step12;\n\n try {\n for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {\n var _n8 = _step12.value;\n t.le.push(_n8), _e23.add(_n8.field.canonicalString());\n } // The order of the implicit ordering always matches the last explicit order by.\n\n } catch (err) {\n _iterator12.e(err);\n } finally {\n _iterator12.f();\n }\n\n var n = t.explicitOrderBy.length > 0 ? t.explicitOrderBy[t.explicitOrderBy.length - 1].dir : \"asc\"\n /* Direction.ASCENDING */\n ,\n r = function __PRIVATE_getInequalityFilterFields(e) {\n var t = new SortedSet(FieldPath$1.comparator);\n return e.filters.forEach(function (e) {\n e.getFlattenedFilters().forEach(function (e) {\n e.isInequality() && (t = t.add(e.field));\n });\n }), t;\n }\n /**\n * Creates a new Query for a collection group query that matches all documents\n * within the provided collection group.\n */\n (t); // Any inequality fields not explicitly ordered should be implicitly ordered in a lexicographical\n // order. When there are multiple inequality filters on the same field, the field should be added\n // only once.\n // Note: `SortedSet` sorts the key field before other fields. However, we want the key\n // field to be sorted last.\n\n\n r.forEach(function (r) {\n _e23.has(r.canonicalString()) || r.isKeyField() || t.le.push(new OrderBy(r, n));\n }), // Add the document key field to the last if it is not explicitly ordered.\n _e23.has(FieldPath$1.keyField().canonicalString()) || t.le.push(new OrderBy(FieldPath$1.keyField(), n));\n }\n\n return t.le;\n}\n/**\n * Converts this `Query` instance to its corresponding `Target` representation.\n */\n\n\nfunction __PRIVATE_queryToTarget(e) {\n var t = __PRIVATE_debugCast(e);\n\n return t.he || (t.he = __PRIVATE__queryToTarget(t, __PRIVATE_queryNormalizedOrderBy(e))), t.he;\n}\n/**\n * Converts this `Query` instance to its corresponding `Target` representation,\n * for use within an aggregate query. Unlike targets for non-aggregate queries,\n * aggregate query targets do not contain normalized order-bys, they only\n * contain explicit order-bys.\n */\n\n\nfunction __PRIVATE__queryToTarget(e, t) {\n if (\"F\"\n /* LimitType.First */\n === e.limitType) return __PRIVATE_newTarget(e.path, e.collectionGroup, t, e.filters, e.limit, e.startAt, e.endAt);\n {\n // Flip the orderBy directions since we want the last results\n t = t.map(function (e) {\n var t = \"desc\"\n /* Direction.DESCENDING */\n === e.dir ? \"asc\"\n /* Direction.ASCENDING */\n : \"desc\"\n /* Direction.DESCENDING */\n ;\n return new OrderBy(e.field, t);\n }); // We need to swap the cursors to match the now-flipped query ordering.\n\n var n = e.endAt ? new Bound(e.endAt.position, e.endAt.inclusive) : null,\n r = e.startAt ? new Bound(e.startAt.position, e.startAt.inclusive) : null; // Now return as a LimitType.First query.\n\n return __PRIVATE_newTarget(e.path, e.collectionGroup, t, e.filters, e.limit, n, r);\n }\n}\n\nfunction __PRIVATE_queryWithAddedFilter(e, t) {\n var n = e.filters.concat([t]);\n return new __PRIVATE_QueryImpl(e.path, e.collectionGroup, e.explicitOrderBy.slice(), n, e.limit, e.limitType, e.startAt, e.endAt);\n}\n\nfunction __PRIVATE_queryWithLimit(e, t, n) {\n return new __PRIVATE_QueryImpl(e.path, e.collectionGroup, e.explicitOrderBy.slice(), e.filters.slice(), t, n, e.startAt, e.endAt);\n}\n\nfunction __PRIVATE_queryEquals(e, t) {\n return __PRIVATE_targetEquals(__PRIVATE_queryToTarget(e), __PRIVATE_queryToTarget(t)) && e.limitType === t.limitType;\n} // TODO(b/29183165): This is used to get a unique string from a query to, for\n// example, use as a dictionary key, but the implementation is subject to\n// collisions. Make it collision-free.\n\n\nfunction __PRIVATE_canonifyQuery(e) {\n return \"\".concat(__PRIVATE_canonifyTarget(__PRIVATE_queryToTarget(e)), \"|lt:\").concat(e.limitType);\n}\n\nfunction __PRIVATE_stringifyQuery(e) {\n return \"Query(target=\".concat(function __PRIVATE_stringifyTarget(e) {\n var t = e.path.canonicalString();\n return null !== e.collectionGroup && (t += \" collectionGroup=\" + e.collectionGroup), e.filters.length > 0 && (t += \", filters: [\".concat(e.filters.map(function (e) {\n return __PRIVATE_stringifyFilter(e);\n }).join(\", \"), \"]\")), __PRIVATE_isNullOrUndefined(e.limit) || (t += \", limit: \" + e.limit), e.orderBy.length > 0 && (t += \", orderBy: [\".concat(e.orderBy.map(function (e) {\n return function __PRIVATE_stringifyOrderBy(e) {\n return \"\".concat(e.field.canonicalString(), \" (\").concat(e.dir, \")\");\n }(e);\n }).join(\", \"), \"]\")), e.startAt && (t += \", startAt: \", t += e.startAt.inclusive ? \"b:\" : \"a:\", t += e.startAt.position.map(function (e) {\n return canonicalId(e);\n }).join(\",\")), e.endAt && (t += \", endAt: \", t += e.endAt.inclusive ? \"a:\" : \"b:\", t += e.endAt.position.map(function (e) {\n return canonicalId(e);\n }).join(\",\")), \"Target(\".concat(t, \")\");\n }(__PRIVATE_queryToTarget(e)), \"; limitType=\").concat(e.limitType, \")\");\n}\n/** Returns whether `doc` matches the constraints of `query`. */\n\n\nfunction __PRIVATE_queryMatches(e, t) {\n return t.isFoundDocument() && function __PRIVATE_queryMatchesPathAndCollectionGroup(e, t) {\n var n = t.key.path;\n return null !== e.collectionGroup ? t.key.hasCollectionId(e.collectionGroup) && e.path.isPrefixOf(n) : DocumentKey.isDocumentKey(e.path) ? e.path.isEqual(n) : e.path.isImmediateParentOf(n);\n }\n /**\n * A document must have a value for every ordering clause in order to show up\n * in the results.\n */\n (e, t) && function __PRIVATE_queryMatchesOrderBy(e, t) {\n // We must use `queryNormalizedOrderBy()` to get the list of all orderBys (both implicit and explicit).\n // Note that for OR queries, orderBy applies to all disjunction terms and implicit orderBys must\n // be taken into account. For example, the query \"a > 1 || b==1\" has an implicit \"orderBy a\" due\n // to the inequality, and is evaluated as \"a > 1 orderBy a || b==1 orderBy a\".\n // A document with content of {b:1} matches the filters, but does not match the orderBy because\n // it's missing the field 'a'.\n var _iterator13 = _createForOfIteratorHelper(__PRIVATE_queryNormalizedOrderBy(e)),\n _step13;\n\n try {\n for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {\n var n = _step13.value;\n // order-by key always matches\n if (!n.field.isKeyField() && null === t.data.field(n.field)) return !1;\n }\n } catch (err) {\n _iterator13.e(err);\n } finally {\n _iterator13.f();\n }\n\n return !0;\n }(e, t) && function __PRIVATE_queryMatchesFilters(e, t) {\n var _iterator14 = _createForOfIteratorHelper(e.filters),\n _step14;\n\n try {\n for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {\n var n = _step14.value;\n if (!n.matches(t)) return !1;\n }\n } catch (err) {\n _iterator14.e(err);\n } finally {\n _iterator14.f();\n }\n\n return !0;\n }\n /** Makes sure a document is within the bounds, if provided. */\n (e, t) && function __PRIVATE_queryMatchesBounds(e, t) {\n if (e.startAt && !\n /**\n * Returns true if a document sorts before a bound using the provided sort\n * order.\n */\n function __PRIVATE_boundSortsBeforeDocument(e, t, n) {\n var r = __PRIVATE_boundCompareToDocument(e, t, n);\n\n return e.inclusive ? r <= 0 : r < 0;\n }(e.startAt, __PRIVATE_queryNormalizedOrderBy(e), t)) return !1;\n if (e.endAt && !function __PRIVATE_boundSortsAfterDocument(e, t, n) {\n var r = __PRIVATE_boundCompareToDocument(e, t, n);\n\n return e.inclusive ? r >= 0 : r > 0;\n }(e.endAt, __PRIVATE_queryNormalizedOrderBy(e), t)) return !1;\n return !0;\n }\n /**\n * Returns the collection group that this query targets.\n *\n * PORTING NOTE: This is only used in the Web SDK to facilitate multi-tab\n * synchronization for query results.\n */\n (e, t);\n}\n\nfunction __PRIVATE_queryCollectionGroup(e) {\n return e.collectionGroup || (e.path.length % 2 == 1 ? e.path.lastSegment() : e.path.get(e.path.length - 2));\n}\n/**\n * Returns a new comparator function that can be used to compare two documents\n * based on the Query's ordering constraint.\n */\n\n\nfunction __PRIVATE_newQueryComparator(e) {\n return function (t, n) {\n var r = !1;\n\n var _iterator15 = _createForOfIteratorHelper(__PRIVATE_queryNormalizedOrderBy(e)),\n _step15;\n\n try {\n for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {\n var i = _step15.value;\n\n var _e24 = __PRIVATE_compareDocs(i, t, n);\n\n if (0 !== _e24) return _e24;\n r = r || i.field.isKeyField();\n }\n } catch (err) {\n _iterator15.e(err);\n } finally {\n _iterator15.f();\n }\n\n return 0;\n };\n}\n\nfunction __PRIVATE_compareDocs(e, t, n) {\n var r = e.field.isKeyField() ? DocumentKey.comparator(t.key, n.key) : function __PRIVATE_compareDocumentsByField(e, t, n) {\n var r = t.data.field(e),\n i = n.data.field(e);\n return null !== r && null !== i ? __PRIVATE_valueCompare(r, i) : fail();\n }(e.field, t, n);\n\n switch (e.dir) {\n case \"asc\"\n /* Direction.ASCENDING */\n :\n return r;\n\n case \"desc\"\n /* Direction.DESCENDING */\n :\n return -1 * r;\n\n default:\n return fail();\n }\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A map implementation that uses objects as keys. Objects must have an\n * associated equals function and must be immutable. Entries in the map are\n * stored together with the key being produced from the mapKeyFn. This map\n * automatically handles collisions of keys.\n */\n\n\nvar ObjectMap = /*#__PURE__*/function () {\n function ObjectMap(e, t) {\n _classCallCheck(this, ObjectMap);\n\n this.mapKeyFn = e, this.equalsFn = t,\n /**\n * The inner map for a key/value pair. Due to the possibility of collisions we\n * keep a list of entries that we do a linear search through to find an actual\n * match. Note that collisions should be rare, so we still expect near\n * constant time lookups in practice.\n */\n this.inner = {},\n /** The number of entries stored in the map */\n this.innerSize = 0;\n }\n /** Get a value for this key, or undefined if it does not exist. */\n\n\n _createClass(ObjectMap, [{\n key: \"get\",\n value: function get(e) {\n var t = this.mapKeyFn(e),\n n = this.inner[t];\n\n if (void 0 !== n) {\n var _iterator16 = _createForOfIteratorHelper(n),\n _step16;\n\n try {\n for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {\n var _step16$value = _slicedToArray(_step16.value, 2),\n _t16 = _step16$value[0],\n r = _step16$value[1];\n\n if (this.equalsFn(_t16, e)) return r;\n }\n } catch (err) {\n _iterator16.e(err);\n } finally {\n _iterator16.f();\n }\n }\n }\n }, {\n key: \"has\",\n value: function has(e) {\n return void 0 !== this.get(e);\n }\n /** Put this key and value in the map. */\n\n }, {\n key: \"set\",\n value: function set(e, t) {\n var n = this.mapKeyFn(e),\n r = this.inner[n];\n if (void 0 === r) return this.inner[n] = [[e, t]], void this.innerSize++;\n\n for (var _n9 = 0; _n9 < r.length; _n9++) {\n if (this.equalsFn(r[_n9][0], e)) // This is updating an existing entry and does not increase `innerSize`.\n return void (r[_n9] = [e, t]);\n }\n\n r.push([e, t]), this.innerSize++;\n }\n /**\n * Remove this key from the map. Returns a boolean if anything was deleted.\n */\n\n }, {\n key: \"delete\",\n value: function _delete(e) {\n var t = this.mapKeyFn(e),\n n = this.inner[t];\n if (void 0 === n) return !1;\n\n for (var r = 0; r < n.length; r++) {\n if (this.equalsFn(n[r][0], e)) return 1 === n.length ? delete this.inner[t] : n.splice(r, 1), this.innerSize--, !0;\n }\n\n return !1;\n }\n }, {\n key: \"forEach\",\n value: function forEach(e) {\n _forEach(this.inner, function (t, n) {\n var _iterator17 = _createForOfIteratorHelper(n),\n _step17;\n\n try {\n for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {\n var _step17$value = _slicedToArray(_step17.value, 2),\n _t17 = _step17$value[0],\n r = _step17$value[1];\n\n e(_t17, r);\n }\n } catch (err) {\n _iterator17.e(err);\n } finally {\n _iterator17.f();\n }\n });\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return _isEmpty(this.inner);\n }\n }, {\n key: \"size\",\n value: function size() {\n return this.innerSize;\n }\n }]);\n\n return ObjectMap;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar re = new SortedMap(DocumentKey.comparator);\n\nfunction __PRIVATE_mutableDocumentMap() {\n return re;\n}\n\nvar ie = new SortedMap(DocumentKey.comparator);\n\nfunction documentMap() {\n var t = ie;\n\n for (var _len5 = arguments.length, e = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n e[_key5] = arguments[_key5];\n }\n\n for (var _i2 = 0, _e25 = e; _i2 < _e25.length; _i2++) {\n var n = _e25[_i2];\n t = t.insert(n.key, n);\n }\n\n return t;\n}\n\nfunction __PRIVATE_convertOverlayedDocumentMapToDocumentMap(e) {\n var t = ie;\n return e.forEach(function (e, n) {\n return t = t.insert(e, n.overlayedDocument);\n }), t;\n}\n\nfunction __PRIVATE_newOverlayMap() {\n return __PRIVATE_newDocumentKeyMap();\n}\n\nfunction __PRIVATE_newMutationMap() {\n return __PRIVATE_newDocumentKeyMap();\n}\n\nfunction __PRIVATE_newDocumentKeyMap() {\n return new ObjectMap(function (e) {\n return e.toString();\n }, function (e, t) {\n return e.isEqual(t);\n });\n}\n\nvar se = new SortedMap(DocumentKey.comparator);\nvar oe = new SortedSet(DocumentKey.comparator);\n\nfunction __PRIVATE_documentKeySet() {\n var t = oe;\n\n for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n e[_key6] = arguments[_key6];\n }\n\n for (var _i3 = 0, _e26 = e; _i3 < _e26.length; _i3++) {\n var n = _e26[_i3];\n t = t.add(n);\n }\n\n return t;\n}\n\nvar _e = new SortedSet(__PRIVATE_primitiveComparator);\n\nfunction __PRIVATE_targetIdSet() {\n return _e;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns an DoubleValue for `value` that is encoded based the serializer's\n * `useProto3Json` setting.\n */\n\n\nfunction __PRIVATE_toDouble(e, t) {\n if (e.useProto3Json) {\n if (isNaN(t)) return {\n doubleValue: \"NaN\"\n };\n if (t === 1 / 0) return {\n doubleValue: \"Infinity\"\n };\n if (t === -1 / 0) return {\n doubleValue: \"-Infinity\"\n };\n }\n\n return {\n doubleValue: __PRIVATE_isNegativeZero(t) ? \"-0\" : t\n };\n}\n/**\n * Returns an IntegerValue for `value`.\n */\n\n\nfunction __PRIVATE_toInteger(e) {\n return {\n integerValue: \"\" + e\n };\n}\n/**\n * Returns a value for a number that's appropriate to put into a proto.\n * The return value is an IntegerValue if it can safely represent the value,\n * otherwise a DoubleValue is returned.\n */\n\n\nfunction toNumber(e, t) {\n return isSafeInteger(t) ? __PRIVATE_toInteger(t) : __PRIVATE_toDouble(e, t);\n}\n/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Used to represent a field transform on a mutation. */\n\n\nvar TransformOperation = /*#__PURE__*/_createClass(function TransformOperation() {\n _classCallCheck(this, TransformOperation);\n\n // Make sure that the structural type of `TransformOperation` is unique.\n // See https://github.com/microsoft/TypeScript/issues/5451\n this._ = void 0;\n});\n/**\n * Computes the local transform result against the provided `previousValue`,\n * optionally using the provided localWriteTime.\n */\n\n\nfunction __PRIVATE_applyTransformOperationToLocalView(e, t, n) {\n return e instanceof __PRIVATE_ServerTimestampTransform ? function serverTimestamp$1(e, t) {\n var n = {\n fields: {\n __type__: {\n stringValue: \"server_timestamp\"\n },\n __local_write_time__: {\n timestampValue: {\n seconds: e.seconds,\n nanos: e.nanoseconds\n }\n }\n }\n }; // We should avoid storing deeply nested server timestamp map values\n // because we never use the intermediate \"previous values\".\n // For example:\n // previous: 42L, add: t1, result: t1 -> 42L\n // previous: t1, add: t2, result: t2 -> 42L (NOT t2 -> t1 -> 42L)\n // previous: t2, add: t3, result: t3 -> 42L (NOT t3 -> t2 -> t1 -> 42L)\n // `getPreviousValue` recursively traverses server timestamps to find the\n // least recent Value.\n\n return t && __PRIVATE_isServerTimestamp(t) && (t = __PRIVATE_getPreviousValue(t)), t && (n.fields.__previous_value__ = t), {\n mapValue: n\n };\n }(n, t) : e instanceof __PRIVATE_ArrayUnionTransformOperation ? __PRIVATE_applyArrayUnionTransformOperation(e, t) : e instanceof __PRIVATE_ArrayRemoveTransformOperation ? __PRIVATE_applyArrayRemoveTransformOperation(e, t) : function __PRIVATE_applyNumericIncrementTransformOperationToLocalView(e, t) {\n // PORTING NOTE: Since JavaScript's integer arithmetic is limited to 53 bit\n // precision and resolves overflows by reducing precision, we do not\n // manually cap overflows at 2^63.\n var n = __PRIVATE_computeTransformOperationBaseValue(e, t),\n r = asNumber(n) + asNumber(e.Ie);\n\n return isInteger(n) && isInteger(e.Ie) ? __PRIVATE_toInteger(r) : __PRIVATE_toDouble(e.serializer, r);\n }(e, t);\n}\n/**\n * Computes a final transform result after the transform has been acknowledged\n * by the server, potentially using the server-provided transformResult.\n */\n\n\nfunction __PRIVATE_applyTransformOperationToRemoteDocument(e, t, n) {\n // The server just sends null as the transform result for array operations,\n // so we have to calculate a result the same as we do for local\n // applications.\n return e instanceof __PRIVATE_ArrayUnionTransformOperation ? __PRIVATE_applyArrayUnionTransformOperation(e, t) : e instanceof __PRIVATE_ArrayRemoveTransformOperation ? __PRIVATE_applyArrayRemoveTransformOperation(e, t) : n;\n}\n/**\n * If this transform operation is not idempotent, returns the base value to\n * persist for this transform. If a base value is returned, the transform\n * operation is always applied to this base value, even if document has\n * already been updated.\n *\n * Base values provide consistent behavior for non-idempotent transforms and\n * allow us to return the same latency-compensated value even if the backend\n * has already applied the transform operation. The base value is null for\n * idempotent transforms, as they can be re-played even if the backend has\n * already applied them.\n *\n * @returns a base value to store along with the mutation, or null for\n * idempotent transforms.\n */\n\n\nfunction __PRIVATE_computeTransformOperationBaseValue(e, t) {\n return e instanceof __PRIVATE_NumericIncrementTransformOperation ?\n /** Returns true if `value` is either an IntegerValue or a DoubleValue. */\n function __PRIVATE_isNumber(e) {\n return isInteger(e) || function __PRIVATE_isDouble(e) {\n return !!e && \"doubleValue\" in e;\n }(e);\n }(t) ? t : {\n integerValue: 0\n } : null;\n}\n/** Transforms a value into a server-generated timestamp. */\n\n\nvar __PRIVATE_ServerTimestampTransform = /*#__PURE__*/function (_TransformOperation) {\n _inherits(__PRIVATE_ServerTimestampTransform, _TransformOperation);\n\n var _super16 = _createSuper(__PRIVATE_ServerTimestampTransform);\n\n function __PRIVATE_ServerTimestampTransform() {\n _classCallCheck(this, __PRIVATE_ServerTimestampTransform);\n\n return _super16.apply(this, arguments);\n }\n\n return _createClass(__PRIVATE_ServerTimestampTransform);\n}(TransformOperation);\n/** Transforms an array value via a union operation. */\n\n\nvar __PRIVATE_ArrayUnionTransformOperation = /*#__PURE__*/function (_TransformOperation2) {\n _inherits(__PRIVATE_ArrayUnionTransformOperation, _TransformOperation2);\n\n var _super17 = _createSuper(__PRIVATE_ArrayUnionTransformOperation);\n\n function __PRIVATE_ArrayUnionTransformOperation(e) {\n var _this32;\n\n _classCallCheck(this, __PRIVATE_ArrayUnionTransformOperation);\n\n _this32 = _super17.call(this), _this32.elements = e;\n return _this32;\n }\n\n return _createClass(__PRIVATE_ArrayUnionTransformOperation);\n}(TransformOperation);\n\nfunction __PRIVATE_applyArrayUnionTransformOperation(e, t) {\n var n = __PRIVATE_coercedFieldValuesArray(t);\n\n var _iterator18 = _createForOfIteratorHelper(e.elements),\n _step18;\n\n try {\n var _loop3 = function _loop3() {\n var t = _step18.value;\n n.some(function (e) {\n return __PRIVATE_valueEquals(e, t);\n }) || n.push(t);\n };\n\n for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {\n _loop3();\n }\n } catch (err) {\n _iterator18.e(err);\n } finally {\n _iterator18.f();\n }\n\n return {\n arrayValue: {\n values: n\n }\n };\n}\n/** Transforms an array value via a remove operation. */\n\n\nvar __PRIVATE_ArrayRemoveTransformOperation = /*#__PURE__*/function (_TransformOperation3) {\n _inherits(__PRIVATE_ArrayRemoveTransformOperation, _TransformOperation3);\n\n var _super18 = _createSuper(__PRIVATE_ArrayRemoveTransformOperation);\n\n function __PRIVATE_ArrayRemoveTransformOperation(e) {\n var _this33;\n\n _classCallCheck(this, __PRIVATE_ArrayRemoveTransformOperation);\n\n _this33 = _super18.call(this), _this33.elements = e;\n return _this33;\n }\n\n return _createClass(__PRIVATE_ArrayRemoveTransformOperation);\n}(TransformOperation);\n\nfunction __PRIVATE_applyArrayRemoveTransformOperation(e, t) {\n var n = __PRIVATE_coercedFieldValuesArray(t);\n\n var _iterator19 = _createForOfIteratorHelper(e.elements),\n _step19;\n\n try {\n var _loop4 = function _loop4() {\n var t = _step19.value;\n n = n.filter(function (e) {\n return !__PRIVATE_valueEquals(e, t);\n });\n };\n\n for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {\n _loop4();\n }\n } catch (err) {\n _iterator19.e(err);\n } finally {\n _iterator19.f();\n }\n\n return {\n arrayValue: {\n values: n\n }\n };\n}\n/**\n * Implements the backend semantics for locally computed NUMERIC_ADD (increment)\n * transforms. Converts all field values to integers or doubles, but unlike the\n * backend does not cap integer values at 2^63. Instead, JavaScript number\n * arithmetic is used and precision loss can occur for values greater than 2^53.\n */\n\n\nvar __PRIVATE_NumericIncrementTransformOperation = /*#__PURE__*/function (_TransformOperation4) {\n _inherits(__PRIVATE_NumericIncrementTransformOperation, _TransformOperation4);\n\n var _super19 = _createSuper(__PRIVATE_NumericIncrementTransformOperation);\n\n function __PRIVATE_NumericIncrementTransformOperation(e, t) {\n var _this34;\n\n _classCallCheck(this, __PRIVATE_NumericIncrementTransformOperation);\n\n _this34 = _super19.call(this), _this34.serializer = e, _this34.Ie = t;\n return _this34;\n }\n\n return _createClass(__PRIVATE_NumericIncrementTransformOperation);\n}(TransformOperation);\n\nfunction asNumber(e) {\n return __PRIVATE_normalizeNumber(e.integerValue || e.doubleValue);\n}\n\nfunction __PRIVATE_coercedFieldValuesArray(e) {\n return isArray(e) && e.arrayValue.values ? e.arrayValue.values.slice() : [];\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** A field path and the TransformOperation to perform upon it. */\n\n\nvar FieldTransform = /*#__PURE__*/_createClass(function FieldTransform(e, t) {\n _classCallCheck(this, FieldTransform);\n\n this.field = e, this.transform = t;\n});\n\nfunction __PRIVATE_fieldTransformEquals(e, t) {\n return e.field.isEqual(t.field) && function __PRIVATE_transformOperationEquals(e, t) {\n return e instanceof __PRIVATE_ArrayUnionTransformOperation && t instanceof __PRIVATE_ArrayUnionTransformOperation || e instanceof __PRIVATE_ArrayRemoveTransformOperation && t instanceof __PRIVATE_ArrayRemoveTransformOperation ? __PRIVATE_arrayEquals(e.elements, t.elements, __PRIVATE_valueEquals) : e instanceof __PRIVATE_NumericIncrementTransformOperation && t instanceof __PRIVATE_NumericIncrementTransformOperation ? __PRIVATE_valueEquals(e.Ie, t.Ie) : e instanceof __PRIVATE_ServerTimestampTransform && t instanceof __PRIVATE_ServerTimestampTransform;\n }(e.transform, t.transform);\n}\n/** The result of successfully applying a mutation to the backend. */\n\n\nvar MutationResult = /*#__PURE__*/_createClass(function MutationResult(\n/**\n * The version at which the mutation was committed:\n *\n * - For most operations, this is the updateTime in the WriteResult.\n * - For deletes, the commitTime of the WriteResponse (because deletes are\n * not stored and have no updateTime).\n *\n * Note that these versions can be different: No-op writes will not change\n * the updateTime even though the commitTime advances.\n */\ne,\n/**\n * The resulting fields returned from the backend after a mutation\n * containing field transforms has been committed. Contains one FieldValue\n * for each FieldTransform that was in the mutation.\n *\n * Will be empty if the mutation did not contain any field transforms.\n */\nt) {\n _classCallCheck(this, MutationResult);\n\n this.version = e, this.transformResults = t;\n});\n/**\n * Encodes a precondition for a mutation. This follows the model that the\n * backend accepts with the special case of an explicit \"empty\" precondition\n * (meaning no precondition).\n */\n\n\nvar Precondition = /*#__PURE__*/function () {\n function Precondition(e, t) {\n _classCallCheck(this, Precondition);\n\n this.updateTime = e, this.exists = t;\n }\n /** Creates a new empty Precondition. */\n\n\n _createClass(Precondition, [{\n key: \"isNone\",\n get:\n /** Returns whether this Precondition is empty. */\n function get() {\n return void 0 === this.updateTime && void 0 === this.exists;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return this.exists === e.exists && (this.updateTime ? !!e.updateTime && this.updateTime.isEqual(e.updateTime) : !e.updateTime);\n }\n }], [{\n key: \"none\",\n value: function none() {\n return new Precondition();\n }\n /** Creates a new Precondition with an exists flag. */\n\n }, {\n key: \"exists\",\n value: function exists(e) {\n return new Precondition(void 0, e);\n }\n /** Creates a new Precondition based on a version a document exists at. */\n\n }, {\n key: \"updateTime\",\n value: function updateTime(e) {\n return new Precondition(e);\n }\n }]);\n\n return Precondition;\n}();\n/** Returns true if the preconditions is valid for the given document. */\n\n\nfunction __PRIVATE_preconditionIsValidForDocument(e, t) {\n return void 0 !== e.updateTime ? t.isFoundDocument() && t.version.isEqual(e.updateTime) : void 0 === e.exists || e.exists === t.isFoundDocument();\n}\n/**\n * A mutation describes a self-contained change to a document. Mutations can\n * create, replace, delete, and update subsets of documents.\n *\n * Mutations not only act on the value of the document but also its version.\n *\n * For local mutations (mutations that haven't been committed yet), we preserve\n * the existing version for Set and Patch mutations. For Delete mutations, we\n * reset the version to 0.\n *\n * Here's the expected transition table.\n *\n * MUTATION APPLIED TO RESULTS IN\n *\n * SetMutation Document(v3) Document(v3)\n * SetMutation NoDocument(v3) Document(v0)\n * SetMutation InvalidDocument(v0) Document(v0)\n * PatchMutation Document(v3) Document(v3)\n * PatchMutation NoDocument(v3) NoDocument(v3)\n * PatchMutation InvalidDocument(v0) UnknownDocument(v3)\n * DeleteMutation Document(v3) NoDocument(v0)\n * DeleteMutation NoDocument(v3) NoDocument(v0)\n * DeleteMutation InvalidDocument(v0) NoDocument(v0)\n *\n * For acknowledged mutations, we use the updateTime of the WriteResponse as\n * the resulting version for Set and Patch mutations. As deletes have no\n * explicit update time, we use the commitTime of the WriteResponse for\n * Delete mutations.\n *\n * If a mutation is acknowledged by the backend but fails the precondition check\n * locally, we transition to an `UnknownDocument` and rely on Watch to send us\n * the updated version.\n *\n * Field transforms are used only with Patch and Set Mutations. We use the\n * `updateTransforms` message to store transforms, rather than the `transforms`s\n * messages.\n *\n * ## Subclassing Notes\n *\n * Every type of mutation needs to implement its own applyToRemoteDocument() and\n * applyToLocalView() to implement the actual behavior of applying the mutation\n * to some source document (see `setMutationApplyToRemoteDocument()` for an\n * example).\n */\n\n\nvar Mutation = /*#__PURE__*/_createClass(function Mutation() {\n _classCallCheck(this, Mutation);\n});\n/**\n * A utility method to calculate a `Mutation` representing the overlay from the\n * final state of the document, and a `FieldMask` representing the fields that\n * are mutated by the local mutations.\n */\n\n\nfunction __PRIVATE_calculateOverlayMutation(e, t) {\n if (!e.hasLocalMutations || t && 0 === t.fields.length) return null; // mask is null when sets or deletes are applied to the current document.\n\n if (null === t) return e.isNoDocument() ? new __PRIVATE_DeleteMutation(e.key, Precondition.none()) : new __PRIVATE_SetMutation(e.key, e.data, Precondition.none());\n {\n var n = e.data,\n r = ObjectValue.empty();\n var i = new SortedSet(FieldPath$1.comparator);\n\n var _iterator20 = _createForOfIteratorHelper(t.fields),\n _step20;\n\n try {\n for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {\n var _e27 = _step20.value;\n\n if (!i.has(_e27)) {\n var _t18 = n.field(_e27); // If we are deleting a nested field, we take the immediate parent as\n // the mask used to construct the resulting mutation.\n // Justification: Nested fields can create parent fields implicitly. If\n // only a leaf entry is deleted in later mutations, the parent field\n // should still remain, but we may have lost this information.\n // Consider mutation (foo.bar 1), then mutation (foo.bar delete()).\n // This leaves the final result (foo, {}). Despite the fact that `doc`\n // has the correct result, `foo` is not in `mask`, and the resulting\n // mutation would miss `foo`.\n\n\n null === _t18 && _e27.length > 1 && (_e27 = _e27.popLast(), _t18 = n.field(_e27)), null === _t18 ? r.delete(_e27) : r.set(_e27, _t18), i = i.add(_e27);\n }\n }\n } catch (err) {\n _iterator20.e(err);\n } finally {\n _iterator20.f();\n }\n\n return new __PRIVATE_PatchMutation(e.key, r, new FieldMask(i.toArray()), Precondition.none());\n }\n}\n/**\n * Applies this mutation to the given document for the purposes of computing a\n * new remote document. If the input document doesn't match the expected state\n * (e.g. it is invalid or outdated), the document type may transition to\n * unknown.\n *\n * @param mutation - The mutation to apply.\n * @param document - The document to mutate. The input document can be an\n * invalid document if the client has no knowledge of the pre-mutation state\n * of the document.\n * @param mutationResult - The result of applying the mutation from the backend.\n */\n\n\nfunction __PRIVATE_mutationApplyToRemoteDocument(e, t, n) {\n e instanceof __PRIVATE_SetMutation ? function __PRIVATE_setMutationApplyToRemoteDocument(e, t, n) {\n // Unlike setMutationApplyToLocalView, if we're applying a mutation to a\n // remote document the server has accepted the mutation so the precondition\n // must have held.\n var r = e.value.clone(),\n i = __PRIVATE_serverTransformResults(e.fieldTransforms, t, n.transformResults);\n\n r.setAll(i), t.convertToFoundDocument(n.version, r).setHasCommittedMutations();\n }(e, t, n) : e instanceof __PRIVATE_PatchMutation ? function __PRIVATE_patchMutationApplyToRemoteDocument(e, t, n) {\n if (!__PRIVATE_preconditionIsValidForDocument(e.precondition, t)) // Since the mutation was not rejected, we know that the precondition\n // matched on the backend. We therefore must not have the expected version\n // of the document in our cache and convert to an UnknownDocument with a\n // known updateTime.\n return void t.convertToUnknownDocument(n.version);\n\n var r = __PRIVATE_serverTransformResults(e.fieldTransforms, t, n.transformResults),\n i = t.data;\n\n i.setAll(__PRIVATE_getPatch(e)), i.setAll(r), t.convertToFoundDocument(n.version, i).setHasCommittedMutations();\n }(e, t, n) : function __PRIVATE_deleteMutationApplyToRemoteDocument(e, t, n) {\n // Unlike applyToLocalView, if we're applying a mutation to a remote\n // document the server has accepted the mutation so the precondition must\n // have held.\n t.convertToNoDocument(n.version).setHasCommittedMutations();\n }(0, t, n);\n}\n/**\n * Applies this mutation to the given document for the purposes of computing\n * the new local view of a document. If the input document doesn't match the\n * expected state, the document is not modified.\n *\n * @param mutation - The mutation to apply.\n * @param document - The document to mutate. The input document can be an\n * invalid document if the client has no knowledge of the pre-mutation state\n * of the document.\n * @param previousMask - The fields that have been updated before applying this mutation.\n * @param localWriteTime - A timestamp indicating the local write time of the\n * batch this mutation is a part of.\n * @returns A `FieldMask` representing the fields that are changed by applying this mutation.\n */\n\n\nfunction __PRIVATE_mutationApplyToLocalView(e, t, n, r) {\n return e instanceof __PRIVATE_SetMutation ? function __PRIVATE_setMutationApplyToLocalView(e, t, n, r) {\n if (!__PRIVATE_preconditionIsValidForDocument(e.precondition, t)) // The mutation failed to apply (e.g. a document ID created with add()\n // caused a name collision).\n return n;\n\n var i = e.value.clone(),\n s = __PRIVATE_localTransformResults(e.fieldTransforms, r, t);\n\n return i.setAll(s), t.convertToFoundDocument(t.version, i).setHasLocalMutations(), null; // SetMutation overwrites all fields.\n }\n /**\n * A mutation that modifies fields of the document at the given key with the\n * given values. The values are applied through a field mask:\n *\n * * When a field is in both the mask and the values, the corresponding field\n * is updated.\n * * When a field is in neither the mask nor the values, the corresponding\n * field is unmodified.\n * * When a field is in the mask but not in the values, the corresponding field\n * is deleted.\n * * When a field is not in the mask but is in the values, the values map is\n * ignored.\n */\n (e, t, n, r) : e instanceof __PRIVATE_PatchMutation ? function __PRIVATE_patchMutationApplyToLocalView(e, t, n, r) {\n if (!__PRIVATE_preconditionIsValidForDocument(e.precondition, t)) return n;\n\n var i = __PRIVATE_localTransformResults(e.fieldTransforms, r, t),\n s = t.data;\n\n if (s.setAll(__PRIVATE_getPatch(e)), s.setAll(i), t.convertToFoundDocument(t.version, s).setHasLocalMutations(), null === n) return null;\n return n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(function (e) {\n return e.field;\n }));\n }\n /**\n * Returns a FieldPath/Value map with the content of the PatchMutation.\n */\n (e, t, n, r) : function __PRIVATE_deleteMutationApplyToLocalView(e, t, n) {\n if (__PRIVATE_preconditionIsValidForDocument(e.precondition, t)) return t.convertToNoDocument(t.version).setHasLocalMutations(), null;\n return n;\n }\n /**\n * A mutation that verifies the existence of the document at the given key with\n * the provided precondition.\n *\n * The `verify` operation is only used in Transactions, and this class serves\n * primarily to facilitate serialization into protos.\n */\n (e, t, n);\n}\n/**\n * If this mutation is not idempotent, returns the base value to persist with\n * this mutation. If a base value is returned, the mutation is always applied\n * to this base value, even if document has already been updated.\n *\n * The base value is a sparse object that consists of only the document\n * fields for which this mutation contains a non-idempotent transformation\n * (e.g. a numeric increment). The provided value guarantees consistent\n * behavior for non-idempotent transforms and allow us to return the same\n * latency-compensated value even if the backend has already applied the\n * mutation. The base value is null for idempotent mutations, as they can be\n * re-played even if the backend has already applied them.\n *\n * @returns a base value to store along with the mutation, or null for\n * idempotent mutations.\n */\n\n\nfunction __PRIVATE_mutationExtractBaseValue(e, t) {\n var n = null;\n\n var _iterator21 = _createForOfIteratorHelper(e.fieldTransforms),\n _step21;\n\n try {\n for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {\n var r = _step21.value;\n\n var _e28 = t.data.field(r.field),\n i = __PRIVATE_computeTransformOperationBaseValue(r.transform, _e28 || null);\n\n null != i && (null === n && (n = ObjectValue.empty()), n.set(r.field, i));\n }\n } catch (err) {\n _iterator21.e(err);\n } finally {\n _iterator21.f();\n }\n\n return n || null;\n}\n\nfunction __PRIVATE_mutationEquals(e, t) {\n return e.type === t.type && !!e.key.isEqual(t.key) && !!e.precondition.isEqual(t.precondition) && !!function __PRIVATE_fieldTransformsAreEqual(e, t) {\n return void 0 === e && void 0 === t || !(!e || !t) && __PRIVATE_arrayEquals(e, t, function (e, t) {\n return __PRIVATE_fieldTransformEquals(e, t);\n });\n }(e.fieldTransforms, t.fieldTransforms) && (0\n /* MutationType.Set */\n === e.type ? e.value.isEqual(t.value) : 1\n /* MutationType.Patch */\n !== e.type || e.data.isEqual(t.data) && e.fieldMask.isEqual(t.fieldMask));\n}\n/**\n * A mutation that creates or replaces the document at the given key with the\n * object value contents.\n */\n\n\nvar __PRIVATE_SetMutation = /*#__PURE__*/function (_Mutation) {\n _inherits(__PRIVATE_SetMutation, _Mutation);\n\n var _super20 = _createSuper(__PRIVATE_SetMutation);\n\n function __PRIVATE_SetMutation(e, t, n) {\n var _this35;\n\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n\n _classCallCheck(this, __PRIVATE_SetMutation);\n\n _this35 = _super20.call(this), _this35.key = e, _this35.value = t, _this35.precondition = n, _this35.fieldTransforms = r, _this35.type = 0\n /* MutationType.Set */\n ;\n return _this35;\n }\n\n _createClass(__PRIVATE_SetMutation, [{\n key: \"getFieldMask\",\n value: function getFieldMask() {\n return null;\n }\n }]);\n\n return __PRIVATE_SetMutation;\n}(Mutation);\n\nvar __PRIVATE_PatchMutation = /*#__PURE__*/function (_Mutation2) {\n _inherits(__PRIVATE_PatchMutation, _Mutation2);\n\n var _super21 = _createSuper(__PRIVATE_PatchMutation);\n\n function __PRIVATE_PatchMutation(e, t, n, r) {\n var _this36;\n\n var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];\n\n _classCallCheck(this, __PRIVATE_PatchMutation);\n\n _this36 = _super21.call(this), _this36.key = e, _this36.data = t, _this36.fieldMask = n, _this36.precondition = r, _this36.fieldTransforms = i, _this36.type = 1\n /* MutationType.Patch */\n ;\n return _this36;\n }\n\n _createClass(__PRIVATE_PatchMutation, [{\n key: \"getFieldMask\",\n value: function getFieldMask() {\n return this.fieldMask;\n }\n }]);\n\n return __PRIVATE_PatchMutation;\n}(Mutation);\n\nfunction __PRIVATE_getPatch(e) {\n var t = new Map();\n return e.fieldMask.fields.forEach(function (n) {\n if (!n.isEmpty()) {\n var r = e.data.field(n);\n t.set(n, r);\n }\n }), t;\n}\n/**\n * Creates a list of \"transform results\" (a transform result is a field value\n * representing the result of applying a transform) for use after a mutation\n * containing transforms has been acknowledged by the server.\n *\n * @param fieldTransforms - The field transforms to apply the result to.\n * @param mutableDocument - The current state of the document after applying all\n * previous mutations.\n * @param serverTransformResults - The transform results received by the server.\n * @returns The transform results list.\n */\n\n\nfunction __PRIVATE_serverTransformResults(e, t, n) {\n var r = new Map();\n\n __PRIVATE_hardAssert(e.length === n.length);\n\n for (var i = 0; i < n.length; i++) {\n var s = e[i],\n o = s.transform,\n _ = t.data.field(s.field);\n\n r.set(s.field, __PRIVATE_applyTransformOperationToRemoteDocument(o, _, n[i]));\n }\n\n return r;\n}\n/**\n * Creates a list of \"transform results\" (a transform result is a field value\n * representing the result of applying a transform) for use when applying a\n * transform locally.\n *\n * @param fieldTransforms - The field transforms to apply the result to.\n * @param localWriteTime - The local time of the mutation (used to\n * generate ServerTimestampValues).\n * @param mutableDocument - The document to apply transforms on.\n * @returns The transform results list.\n */\n\n\nfunction __PRIVATE_localTransformResults(e, t, n) {\n var r = new Map();\n\n var _iterator22 = _createForOfIteratorHelper(e),\n _step22;\n\n try {\n for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {\n var i = _step22.value;\n var _e29 = i.transform,\n s = n.data.field(i.field);\n r.set(i.field, __PRIVATE_applyTransformOperationToLocalView(_e29, s, t));\n }\n } catch (err) {\n _iterator22.e(err);\n } finally {\n _iterator22.f();\n }\n\n return r;\n}\n/** A mutation that deletes the document at the given key. */\n\n\nvar __PRIVATE_DeleteMutation = /*#__PURE__*/function (_Mutation3) {\n _inherits(__PRIVATE_DeleteMutation, _Mutation3);\n\n var _super22 = _createSuper(__PRIVATE_DeleteMutation);\n\n function __PRIVATE_DeleteMutation(e, t) {\n var _this37;\n\n _classCallCheck(this, __PRIVATE_DeleteMutation);\n\n _this37 = _super22.call(this), _this37.key = e, _this37.precondition = t, _this37.type = 2\n /* MutationType.Delete */\n , _this37.fieldTransforms = [];\n return _this37;\n }\n\n _createClass(__PRIVATE_DeleteMutation, [{\n key: \"getFieldMask\",\n value: function getFieldMask() {\n return null;\n }\n }]);\n\n return __PRIVATE_DeleteMutation;\n}(Mutation);\n\nvar __PRIVATE_VerifyMutation = /*#__PURE__*/function (_Mutation4) {\n _inherits(__PRIVATE_VerifyMutation, _Mutation4);\n\n var _super23 = _createSuper(__PRIVATE_VerifyMutation);\n\n function __PRIVATE_VerifyMutation(e, t) {\n var _this38;\n\n _classCallCheck(this, __PRIVATE_VerifyMutation);\n\n _this38 = _super23.call(this), _this38.key = e, _this38.precondition = t, _this38.type = 3\n /* MutationType.Verify */\n , _this38.fieldTransforms = [];\n return _this38;\n }\n\n _createClass(__PRIVATE_VerifyMutation, [{\n key: \"getFieldMask\",\n value: function getFieldMask() {\n return null;\n }\n }]);\n\n return __PRIVATE_VerifyMutation;\n}(Mutation);\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A batch of mutations that will be sent as one unit to the backend.\n */\n\n\nvar MutationBatch = /*#__PURE__*/function () {\n /**\n * @param batchId - The unique ID of this mutation batch.\n * @param localWriteTime - The original write time of this mutation.\n * @param baseMutations - Mutations that are used to populate the base\n * values when this mutation is applied locally. This can be used to locally\n * overwrite values that are persisted in the remote document cache. Base\n * mutations are never sent to the backend.\n * @param mutations - The user-provided mutations in this mutation batch.\n * User-provided mutations are applied both locally and remotely on the\n * backend.\n */\n function MutationBatch(e, t, n, r) {\n _classCallCheck(this, MutationBatch);\n\n this.batchId = e, this.localWriteTime = t, this.baseMutations = n, this.mutations = r;\n }\n /**\n * Applies all the mutations in this MutationBatch to the specified document\n * to compute the state of the remote document\n *\n * @param document - The document to apply mutations to.\n * @param batchResult - The result of applying the MutationBatch to the\n * backend.\n */\n\n\n _createClass(MutationBatch, [{\n key: \"applyToRemoteDocument\",\n value: function applyToRemoteDocument(e, t) {\n var n = t.mutationResults;\n\n for (var _t19 = 0; _t19 < this.mutations.length; _t19++) {\n var r = this.mutations[_t19];\n\n if (r.key.isEqual(e.key)) {\n __PRIVATE_mutationApplyToRemoteDocument(r, e, n[_t19]);\n }\n }\n }\n /**\n * Computes the local view of a document given all the mutations in this\n * batch.\n *\n * @param document - The document to apply mutations to.\n * @param mutatedFields - Fields that have been updated before applying this mutation batch.\n * @returns A `FieldMask` representing all the fields that are mutated.\n */\n\n }, {\n key: \"applyToLocalView\",\n value: function applyToLocalView(e, t) {\n // First, apply the base state. This allows us to apply non-idempotent\n // transform against a consistent set of values.\n var _iterator23 = _createForOfIteratorHelper(this.baseMutations),\n _step23;\n\n try {\n for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {\n var n = _step23.value;\n n.key.isEqual(e.key) && (t = __PRIVATE_mutationApplyToLocalView(n, e, t, this.localWriteTime));\n } // Second, apply all user-provided mutations.\n\n } catch (err) {\n _iterator23.e(err);\n } finally {\n _iterator23.f();\n }\n\n var _iterator24 = _createForOfIteratorHelper(this.mutations),\n _step24;\n\n try {\n for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {\n var _n10 = _step24.value;\n _n10.key.isEqual(e.key) && (t = __PRIVATE_mutationApplyToLocalView(_n10, e, t, this.localWriteTime));\n }\n } catch (err) {\n _iterator24.e(err);\n } finally {\n _iterator24.f();\n }\n\n return t;\n }\n /**\n * Computes the local view for all provided documents given the mutations in\n * this batch. Returns a `DocumentKey` to `Mutation` map which can be used to\n * replace all the mutation applications.\n */\n\n }, {\n key: \"applyToLocalDocumentSet\",\n value: function applyToLocalDocumentSet(e, t) {\n var _this39 = this;\n\n // TODO(mrschmidt): This implementation is O(n^2). If we apply the mutations\n // directly (as done in `applyToLocalView()`), we can reduce the complexity\n // to O(n).\n var n = __PRIVATE_newMutationMap();\n\n return this.mutations.forEach(function (r) {\n var i = e.get(r.key),\n s = i.overlayedDocument; // TODO(mutabledocuments): This method should take a MutableDocumentMap\n // and we should remove this cast.\n\n var o = _this39.applyToLocalView(s, i.mutatedFields); // Set mutatedFields to null if the document is only from local mutations.\n // This creates a Set or Delete mutation, instead of trying to create a\n // patch mutation as the overlay.\n\n\n o = t.has(r.key) ? null : o;\n\n var _ = __PRIVATE_calculateOverlayMutation(s, o);\n\n null !== _ && n.set(r.key, _), s.isValidDocument() || s.convertToNoDocument(SnapshotVersion.min());\n }), n;\n }\n }, {\n key: \"keys\",\n value: function keys() {\n return this.mutations.reduce(function (e, t) {\n return e.add(t.key);\n }, __PRIVATE_documentKeySet());\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return this.batchId === e.batchId && __PRIVATE_arrayEquals(this.mutations, e.mutations, function (e, t) {\n return __PRIVATE_mutationEquals(e, t);\n }) && __PRIVATE_arrayEquals(this.baseMutations, e.baseMutations, function (e, t) {\n return __PRIVATE_mutationEquals(e, t);\n });\n }\n }]);\n\n return MutationBatch;\n}();\n/** The result of applying a mutation batch to the backend. */\n\n\nvar MutationBatchResult = /*#__PURE__*/function () {\n function MutationBatchResult(e, t, n,\n /**\n * A pre-computed mapping from each mutated document to the resulting\n * version.\n */\n r) {\n _classCallCheck(this, MutationBatchResult);\n\n this.batch = e, this.commitVersion = t, this.mutationResults = n, this.docVersions = r;\n }\n /**\n * Creates a new MutationBatchResult for the given batch and results. There\n * must be one result for each mutation in the batch. This static factory\n * caches a document=>version mapping (docVersions).\n */\n\n\n _createClass(MutationBatchResult, null, [{\n key: \"from\",\n value: function from(e, t, n) {\n __PRIVATE_hardAssert(e.mutations.length === n.length);\n\n var r = function __PRIVATE_documentVersionMap() {\n return se;\n }();\n\n var i = e.mutations;\n\n for (var _e30 = 0; _e30 < i.length; _e30++) {\n r = r.insert(i[_e30].key, n[_e30].version);\n }\n\n return new MutationBatchResult(e, t, n, r);\n }\n }]);\n\n return MutationBatchResult;\n}();\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Representation of an overlay computed by Firestore.\n *\n * Holds information about a mutation and the largest batch id in Firestore when\n * the mutation was created.\n */\n\n\nvar Overlay = /*#__PURE__*/function () {\n function Overlay(e, t) {\n _classCallCheck(this, Overlay);\n\n this.largestBatchId = e, this.mutation = t;\n }\n\n _createClass(Overlay, [{\n key: \"getKey\",\n value: function getKey() {\n return this.mutation.key;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return null !== e && this.mutation === e.mutation;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return \"Overlay{\\n largestBatchId: \".concat(this.largestBatchId, \",\\n mutation: \").concat(this.mutation.toString(), \"\\n }\");\n }\n }]);\n\n return Overlay;\n}();\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Concrete implementation of the Aggregate type.\n */\n\n\nvar __PRIVATE_AggregateImpl = /*#__PURE__*/_createClass(function __PRIVATE_AggregateImpl(e, t, n) {\n _classCallCheck(this, __PRIVATE_AggregateImpl);\n\n this.alias = e, this.aggregateType = t, this.fieldPath = n;\n});\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar ExistenceFilter = /*#__PURE__*/_createClass(function ExistenceFilter(e, t) {\n _classCallCheck(this, ExistenceFilter);\n\n this.count = e, this.unchangedNames = t;\n});\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Error Codes describing the different ways GRPC can fail. These are copied\n * directly from GRPC's sources here:\n *\n * https://github.com/grpc/grpc/blob/bceec94ea4fc5f0085d81235d8e1c06798dc341a/include/grpc%2B%2B/impl/codegen/status_code_enum.h\n *\n * Important! The names of these identifiers matter because the string forms\n * are used for reverse lookups from the webchannel stream. Do NOT change the\n * names of these identifiers or change this into a const enum.\n */\n\n\nvar ae, ue;\n/**\n * Determines whether an error code represents a permanent error when received\n * in response to a non-write operation.\n *\n * See isPermanentWriteError for classifying write errors.\n */\n\nfunction __PRIVATE_isPermanentError(e) {\n switch (e) {\n default:\n return fail();\n\n case D.CANCELLED:\n case D.UNKNOWN:\n case D.DEADLINE_EXCEEDED:\n case D.RESOURCE_EXHAUSTED:\n case D.INTERNAL:\n case D.UNAVAILABLE: // Unauthenticated means something went wrong with our token and we need\n // to retry with new credentials which will happen automatically.\n\n case D.UNAUTHENTICATED:\n return !1;\n\n case D.INVALID_ARGUMENT:\n case D.NOT_FOUND:\n case D.ALREADY_EXISTS:\n case D.PERMISSION_DENIED:\n case D.FAILED_PRECONDITION: // Aborted might be retried in some scenarios, but that is dependant on\n // the context and should handled individually by the calling code.\n // See https://cloud.google.com/apis/design/errors.\n\n case D.ABORTED:\n case D.OUT_OF_RANGE:\n case D.UNIMPLEMENTED:\n case D.DATA_LOSS:\n return !0;\n }\n}\n/**\n * Determines whether an error code represents a permanent error when received\n * in response to a write operation.\n *\n * Write operations must be handled specially because as of b/119437764, ABORTED\n * errors on the write stream should be retried too (even though ABORTED errors\n * are not generally retryable).\n *\n * Note that during the initial handshake on the write stream an ABORTED error\n * signals that we should discard our stream token (i.e. it is permanent). This\n * means a handshake error should be classified with isPermanentError, above.\n */\n\n/**\n * Maps an error Code from GRPC status code number, like 0, 1, or 14. These\n * are not the same as HTTP status codes.\n *\n * @returns The Code equivalent to the given GRPC status code. Fails if there\n * is no match.\n */\n\n\nfunction __PRIVATE_mapCodeFromRpcCode(e) {\n if (void 0 === e) // This shouldn't normally happen, but in certain error cases (like trying\n // to send invalid proto messages) we may get an error with no GRPC code.\n return __PRIVATE_logError(\"GRPC error has no .code\"), D.UNKNOWN;\n\n switch (e) {\n case ae.OK:\n return D.OK;\n\n case ae.CANCELLED:\n return D.CANCELLED;\n\n case ae.UNKNOWN:\n return D.UNKNOWN;\n\n case ae.DEADLINE_EXCEEDED:\n return D.DEADLINE_EXCEEDED;\n\n case ae.RESOURCE_EXHAUSTED:\n return D.RESOURCE_EXHAUSTED;\n\n case ae.INTERNAL:\n return D.INTERNAL;\n\n case ae.UNAVAILABLE:\n return D.UNAVAILABLE;\n\n case ae.UNAUTHENTICATED:\n return D.UNAUTHENTICATED;\n\n case ae.INVALID_ARGUMENT:\n return D.INVALID_ARGUMENT;\n\n case ae.NOT_FOUND:\n return D.NOT_FOUND;\n\n case ae.ALREADY_EXISTS:\n return D.ALREADY_EXISTS;\n\n case ae.PERMISSION_DENIED:\n return D.PERMISSION_DENIED;\n\n case ae.FAILED_PRECONDITION:\n return D.FAILED_PRECONDITION;\n\n case ae.ABORTED:\n return D.ABORTED;\n\n case ae.OUT_OF_RANGE:\n return D.OUT_OF_RANGE;\n\n case ae.UNIMPLEMENTED:\n return D.UNIMPLEMENTED;\n\n case ae.DATA_LOSS:\n return D.DATA_LOSS;\n\n default:\n return fail();\n }\n}\n/**\n * Converts an HTTP response's error status to the equivalent error code.\n *\n * @param status - An HTTP error response status (\"FAILED_PRECONDITION\",\n * \"UNKNOWN\", etc.)\n * @returns The equivalent Code. Non-matching responses are mapped to\n * Code.UNKNOWN.\n */\n\n\n(ue = ae || (ae = {}))[ue.OK = 0] = \"OK\", ue[ue.CANCELLED = 1] = \"CANCELLED\", ue[ue.UNKNOWN = 2] = \"UNKNOWN\", ue[ue.INVALID_ARGUMENT = 3] = \"INVALID_ARGUMENT\", ue[ue.DEADLINE_EXCEEDED = 4] = \"DEADLINE_EXCEEDED\", ue[ue.NOT_FOUND = 5] = \"NOT_FOUND\", ue[ue.ALREADY_EXISTS = 6] = \"ALREADY_EXISTS\", ue[ue.PERMISSION_DENIED = 7] = \"PERMISSION_DENIED\", ue[ue.UNAUTHENTICATED = 16] = \"UNAUTHENTICATED\", ue[ue.RESOURCE_EXHAUSTED = 8] = \"RESOURCE_EXHAUSTED\", ue[ue.FAILED_PRECONDITION = 9] = \"FAILED_PRECONDITION\", ue[ue.ABORTED = 10] = \"ABORTED\", ue[ue.OUT_OF_RANGE = 11] = \"OUT_OF_RANGE\", ue[ue.UNIMPLEMENTED = 12] = \"UNIMPLEMENTED\", ue[ue.INTERNAL = 13] = \"INTERNAL\", ue[ue.UNAVAILABLE = 14] = \"UNAVAILABLE\", ue[ue.DATA_LOSS = 15] = \"DATA_LOSS\";\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The global, singleton instance of TestingHooksSpi.\n *\n * This variable will be `null` in all cases _except_ when running from\n * integration tests that have registered callbacks to be notified of events\n * that happen during the test execution.\n */\n\nvar ce = null;\n/**\n * Sets the value of the `testingHooksSpi` object.\n * @param instance the instance to set.\n */\n\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An instance of the Platform's 'TextEncoder' implementation.\n */\n\nfunction __PRIVATE_newTextEncoder() {\n return new TextEncoder();\n}\n/**\n * An instance of the Platform's 'TextDecoder' implementation.\n */\n\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar le = new Integer([4294967295, 4294967295], 0); // Hash a string using md5 hashing algorithm.\n\nfunction __PRIVATE_getMd5HashValue(e) {\n var t = __PRIVATE_newTextEncoder().encode(e),\n n = new Md5();\n\n return n.update(t), new Uint8Array(n.digest());\n} // Interpret the 16 bytes array as two 64-bit unsigned integers, encoded using\n// 2’s complement using little endian.\n\n\nfunction __PRIVATE_get64BitUints(e) {\n var t = new DataView(e.buffer),\n n = t.getUint32(0,\n /* littleEndian= */\n !0),\n r = t.getUint32(4,\n /* littleEndian= */\n !0),\n i = t.getUint32(8,\n /* littleEndian= */\n !0),\n s = t.getUint32(12,\n /* littleEndian= */\n !0);\n return [new Integer([n, r], 0), new Integer([i, s], 0)];\n}\n\nvar BloomFilter = /*#__PURE__*/function () {\n function BloomFilter(e, t, n) {\n _classCallCheck(this, BloomFilter);\n\n if (this.bitmap = e, this.padding = t, this.hashCount = n, t < 0 || t >= 8) throw new __PRIVATE_BloomFilterError(\"Invalid padding: \".concat(t));\n if (n < 0) throw new __PRIVATE_BloomFilterError(\"Invalid hash count: \".concat(n));\n if (e.length > 0 && 0 === this.hashCount) // Only empty bloom filter can have 0 hash count.\n throw new __PRIVATE_BloomFilterError(\"Invalid hash count: \".concat(n));\n if (0 === e.length && 0 !== t) // Empty bloom filter should have 0 padding.\n throw new __PRIVATE_BloomFilterError(\"Invalid padding when bitmap length is 0: \".concat(t));\n this.Te = 8 * e.length - t, // Set the bit count in Integer to avoid repetition in mightContain().\n this.Ee = Integer.fromNumber(this.Te);\n } // Calculate the ith hash value based on the hashed 64bit integers,\n // and calculate its corresponding bit index in the bitmap to be checked.\n\n\n _createClass(BloomFilter, [{\n key: \"de\",\n value: function de(e, t, n) {\n // Calculate hashed value h(i) = h1 + (i * h2).\n var r = e.add(t.multiply(Integer.fromNumber(n))); // Wrap if hash value overflow 64bit.\n\n return 1 === r.compare(le) && (r = new Integer([r.getBits(0), r.getBits(1)], 0)), r.modulo(this.Ee).toNumber();\n } // Return whether the bit on the given index in the bitmap is set to 1.\n\n }, {\n key: \"Ae\",\n value: function Ae(e) {\n return 0 != (this.bitmap[Math.floor(e / 8)] & 1 << e % 8);\n }\n }, {\n key: \"mightContain\",\n value: function mightContain(e) {\n // Empty bitmap should always return false on membership check.\n if (0 === this.Te) return !1;\n\n var t = __PRIVATE_getMd5HashValue(e),\n _PRIVATE_get64BitUin = __PRIVATE_get64BitUints(t),\n _PRIVATE_get64BitUin2 = _slicedToArray(_PRIVATE_get64BitUin, 2),\n n = _PRIVATE_get64BitUin2[0],\n r = _PRIVATE_get64BitUin2[1];\n\n for (var _e31 = 0; _e31 < this.hashCount; _e31++) {\n var _t20 = this.de(n, r, _e31);\n\n if (!this.Ae(_t20)) return !1;\n }\n\n return !0;\n }\n /** Create bloom filter for testing purposes only. */\n\n }, {\n key: \"insert\",\n value: function insert(e) {\n if (0 === this.Te) return;\n\n var t = __PRIVATE_getMd5HashValue(e),\n _PRIVATE_get64BitUin3 = __PRIVATE_get64BitUints(t),\n _PRIVATE_get64BitUin4 = _slicedToArray(_PRIVATE_get64BitUin3, 2),\n n = _PRIVATE_get64BitUin4[0],\n r = _PRIVATE_get64BitUin4[1];\n\n for (var _e32 = 0; _e32 < this.hashCount; _e32++) {\n var _t21 = this.de(n, r, _e32);\n\n this.Re(_t21);\n }\n }\n }, {\n key: \"Re\",\n value: function Re(e) {\n var t = Math.floor(e / 8),\n n = e % 8;\n this.bitmap[t] |= 1 << n;\n }\n }], [{\n key: \"create\",\n value: function create(e, t, n) {\n var r = e % 8 == 0 ? 0 : 8 - e % 8,\n i = new Uint8Array(Math.ceil(e / 8)),\n s = new BloomFilter(i, r, t);\n return n.forEach(function (e) {\n return s.insert(e);\n }), s;\n }\n }]);\n\n return BloomFilter;\n}();\n\nvar __PRIVATE_BloomFilterError = /*#__PURE__*/function (_Error2) {\n _inherits(__PRIVATE_BloomFilterError, _Error2);\n\n var _super24 = _createSuper(__PRIVATE_BloomFilterError);\n\n function __PRIVATE_BloomFilterError() {\n var _this40;\n\n _classCallCheck(this, __PRIVATE_BloomFilterError);\n\n _this40 = _super24.apply(this, arguments), _this40.name = \"BloomFilterError\";\n return _this40;\n }\n\n return _createClass(__PRIVATE_BloomFilterError);\n}( /*#__PURE__*/_wrapNativeSuper(Error));\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An event from the RemoteStore. It is split into targetChanges (changes to the\n * state or the set of documents in our watched targets) and documentUpdates\n * (changes to the actual documents).\n */\n\n\nvar RemoteEvent = /*#__PURE__*/function () {\n function RemoteEvent(\n /**\n * The snapshot version this event brings us up to, or MIN if not set.\n */\n e,\n /**\n * A map from target to changes to the target. See TargetChange.\n */\n t,\n /**\n * A map of targets that is known to be inconsistent, and the purpose for\n * re-listening. Listens for these targets should be re-established without\n * resume tokens.\n */\n n,\n /**\n * A set of which documents have changed or been deleted, along with the\n * doc's new values (if not deleted).\n */\n r,\n /**\n * A set of which document updates are due only to limbo resolution targets.\n */\n i) {\n _classCallCheck(this, RemoteEvent);\n\n this.snapshotVersion = e, this.targetChanges = t, this.targetMismatches = n, this.documentUpdates = r, this.resolvedLimboDocuments = i;\n }\n /**\n * HACK: Views require RemoteEvents in order to determine whether the view is\n * CURRENT, but secondary tabs don't receive remote events. So this method is\n * used to create a synthesized RemoteEvent that can be used to apply a\n * CURRENT status change to a View, for queries executed in a different tab.\n */\n // PORTING NOTE: Multi-tab only\n\n\n _createClass(RemoteEvent, null, [{\n key: \"createSynthesizedRemoteEventForCurrentChange\",\n value: function createSynthesizedRemoteEventForCurrentChange(e, t, n) {\n var r = new Map();\n return r.set(e, TargetChange.createSynthesizedTargetChangeForCurrentChange(e, t, n)), new RemoteEvent(SnapshotVersion.min(), r, new SortedMap(__PRIVATE_primitiveComparator), __PRIVATE_mutableDocumentMap(), __PRIVATE_documentKeySet());\n }\n }]);\n\n return RemoteEvent;\n}();\n/**\n * A TargetChange specifies the set of changes for a specific target as part of\n * a RemoteEvent. These changes track which documents are added, modified or\n * removed, as well as the target's resume token and whether the target is\n * marked CURRENT.\n * The actual changes *to* documents are not part of the TargetChange since\n * documents may be part of multiple targets.\n */\n\n\nvar TargetChange = /*#__PURE__*/function () {\n function TargetChange(\n /**\n * An opaque, server-assigned token that allows watching a query to be resumed\n * after disconnecting without retransmitting all the data that matches the\n * query. The resume token essentially identifies a point in time from which\n * the server should resume sending results.\n */\n e,\n /**\n * The \"current\" (synced) status of this target. Note that \"current\"\n * has special meaning in the RPC protocol that implies that a target is\n * both up-to-date and consistent with the rest of the watch stream.\n */\n t,\n /**\n * The set of documents that were newly assigned to this target as part of\n * this remote event.\n */\n n,\n /**\n * The set of documents that were already assigned to this target but received\n * an update during this remote event.\n */\n r,\n /**\n * The set of documents that were removed from this target as part of this\n * remote event.\n */\n i) {\n _classCallCheck(this, TargetChange);\n\n this.resumeToken = e, this.current = t, this.addedDocuments = n, this.modifiedDocuments = r, this.removedDocuments = i;\n }\n /**\n * This method is used to create a synthesized TargetChanges that can be used to\n * apply a CURRENT status change to a View (for queries executed in a different\n * tab) or for new queries (to raise snapshots with correct CURRENT status).\n */\n\n\n _createClass(TargetChange, null, [{\n key: \"createSynthesizedTargetChangeForCurrentChange\",\n value: function createSynthesizedTargetChangeForCurrentChange(e, t, n) {\n return new TargetChange(n, t, __PRIVATE_documentKeySet(), __PRIVATE_documentKeySet(), __PRIVATE_documentKeySet());\n }\n }]);\n\n return TargetChange;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents a changed document and a list of target ids to which this change\n * applies.\n *\n * If document has been deleted NoDocument will be provided.\n */\n\n\nvar __PRIVATE_DocumentWatchChange = /*#__PURE__*/_createClass(function __PRIVATE_DocumentWatchChange(\n/** The new document applies to all of these targets. */\ne,\n/** The new document is removed from all of these targets. */\nt,\n/** The key of the document for this change. */\nn,\n/**\n * The new document or NoDocument if it was deleted. Is null if the\n * document went out of view without the server sending a new document.\n */\nr) {\n _classCallCheck(this, __PRIVATE_DocumentWatchChange);\n\n this.Ve = e, this.removedTargetIds = t, this.key = n, this.me = r;\n});\n\nvar __PRIVATE_ExistenceFilterChange = /*#__PURE__*/_createClass(function __PRIVATE_ExistenceFilterChange(e, t) {\n _classCallCheck(this, __PRIVATE_ExistenceFilterChange);\n\n this.targetId = e, this.fe = t;\n});\n\nvar __PRIVATE_WatchTargetChange = /*#__PURE__*/_createClass(function __PRIVATE_WatchTargetChange(\n/** What kind of change occurred to the watch target. */\ne,\n/** The target IDs that were added/removed/set. */\nt) {\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ByteString.EMPTY_BYTE_STRING;\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n\n _classCallCheck(this, __PRIVATE_WatchTargetChange);\n\n this.state = e, this.targetIds = t, this.resumeToken = n, this.cause = r;\n});\n/** Tracks the internal state of a Watch target. */\n\n\nvar __PRIVATE_TargetState = /*#__PURE__*/function () {\n function __PRIVATE_TargetState() {\n _classCallCheck(this, __PRIVATE_TargetState);\n\n /**\n * The number of pending responses (adds or removes) that we are waiting on.\n * We only consider targets active that have no pending responses.\n */\n this.ge = 0,\n /**\n * Keeps track of the document changes since the last raised snapshot.\n *\n * These changes are continuously updated as we receive document updates and\n * always reflect the current set of changes against the last issued snapshot.\n */\n this.pe = __PRIVATE_snapshotChangesMap(),\n /** See public getters for explanations of these fields. */\n this.ye = ByteString.EMPTY_BYTE_STRING, this.we = !1,\n /**\n * Whether this target state should be included in the next snapshot. We\n * initialize to true so that newly-added targets are included in the next\n * RemoteEvent.\n */\n this.Se = !0;\n }\n /**\n * Whether this target has been marked 'current'.\n *\n * 'Current' has special meaning in the RPC protocol: It implies that the\n * Watch backend has sent us all changes up to the point at which the target\n * was added and that the target is consistent with the rest of the watch\n * stream.\n */\n\n\n _createClass(__PRIVATE_TargetState, [{\n key: \"current\",\n get: function get() {\n return this.we;\n }\n /** The last resume token sent to us for this target. */\n\n }, {\n key: \"resumeToken\",\n get: function get() {\n return this.ye;\n }\n /** Whether this target has pending target adds or target removes. */\n\n }, {\n key: \"be\",\n get: function get() {\n return 0 !== this.ge;\n }\n /** Whether we have modified any state that should trigger a snapshot. */\n\n }, {\n key: \"De\",\n get: function get() {\n return this.Se;\n }\n /**\n * Applies the resume token to the TargetChange, but only when it has a new\n * value. Empty resumeTokens are discarded.\n */\n\n }, {\n key: \"Ce\",\n value: function Ce(e) {\n e.approximateByteSize() > 0 && (this.Se = !0, this.ye = e);\n }\n /**\n * Creates a target change from the current set of changes.\n *\n * To reset the document changes after raising this snapshot, call\n * `clearPendingChanges()`.\n */\n\n }, {\n key: \"ve\",\n value: function ve() {\n var e = __PRIVATE_documentKeySet(),\n t = __PRIVATE_documentKeySet(),\n n = __PRIVATE_documentKeySet();\n\n return this.pe.forEach(function (r, i) {\n switch (i) {\n case 0\n /* ChangeType.Added */\n :\n e = e.add(r);\n break;\n\n case 2\n /* ChangeType.Modified */\n :\n t = t.add(r);\n break;\n\n case 1\n /* ChangeType.Removed */\n :\n n = n.add(r);\n break;\n\n default:\n fail();\n }\n }), new TargetChange(this.ye, this.we, e, t, n);\n }\n /**\n * Resets the document changes and sets `hasPendingChanges` to false.\n */\n\n }, {\n key: \"Fe\",\n value: function Fe() {\n this.Se = !1, this.pe = __PRIVATE_snapshotChangesMap();\n }\n }, {\n key: \"Me\",\n value: function Me(e, t) {\n this.Se = !0, this.pe = this.pe.insert(e, t);\n }\n }, {\n key: \"xe\",\n value: function xe(e) {\n this.Se = !0, this.pe = this.pe.remove(e);\n }\n }, {\n key: \"Oe\",\n value: function Oe() {\n this.ge += 1;\n }\n }, {\n key: \"Ne\",\n value: function Ne() {\n this.ge -= 1, __PRIVATE_hardAssert(this.ge >= 0);\n }\n }, {\n key: \"Be\",\n value: function Be() {\n this.Se = !0, this.we = !0;\n }\n }]);\n\n return __PRIVATE_TargetState;\n}();\n/**\n * A helper class to accumulate watch changes into a RemoteEvent.\n */\n\n\nvar __PRIVATE_WatchChangeAggregator = /*#__PURE__*/function () {\n function __PRIVATE_WatchChangeAggregator(e) {\n _classCallCheck(this, __PRIVATE_WatchChangeAggregator);\n\n this.Le = e,\n /** The internal state of all tracked targets. */\n this.ke = new Map(),\n /** Keeps track of the documents to update since the last raised snapshot. */\n this.qe = __PRIVATE_mutableDocumentMap(),\n /** A mapping of document keys to their set of target IDs. */\n this.Qe = __PRIVATE_documentTargetMap(),\n /**\n * A map of targets with existence filter mismatches. These targets are\n * known to be inconsistent and their listens needs to be re-established by\n * RemoteStore.\n */\n this.Ke = new SortedMap(__PRIVATE_primitiveComparator);\n }\n /**\n * Processes and adds the DocumentWatchChange to the current set of changes.\n */\n\n\n _createClass(__PRIVATE_WatchChangeAggregator, [{\n key: \"$e\",\n value: function $e(e) {\n var _iterator25 = _createForOfIteratorHelper(e.Ve),\n _step25;\n\n try {\n for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {\n var t = _step25.value;\n e.me && e.me.isFoundDocument() ? this.Ue(t, e.me) : this.We(t, e.key, e.me);\n }\n } catch (err) {\n _iterator25.e(err);\n } finally {\n _iterator25.f();\n }\n\n var _iterator26 = _createForOfIteratorHelper(e.removedTargetIds),\n _step26;\n\n try {\n for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {\n var _t22 = _step26.value;\n this.We(_t22, e.key, e.me);\n }\n } catch (err) {\n _iterator26.e(err);\n } finally {\n _iterator26.f();\n }\n }\n /** Processes and adds the WatchTargetChange to the current set of changes. */\n\n }, {\n key: \"Ge\",\n value: function Ge(e) {\n var _this41 = this;\n\n this.forEachTarget(e, function (t) {\n var n = _this41.ze(t);\n\n switch (e.state) {\n case 0\n /* WatchTargetChangeState.NoChange */\n :\n _this41.je(t) && n.Ce(e.resumeToken);\n break;\n\n case 1\n /* WatchTargetChangeState.Added */\n :\n // We need to decrement the number of pending acks needed from watch\n // for this targetId.\n n.Ne(), n.be || // We have a freshly added target, so we need to reset any state\n // that we had previously. This can happen e.g. when remove and add\n // back a target for existence filter mismatches.\n n.Fe(), n.Ce(e.resumeToken);\n break;\n\n case 2\n /* WatchTargetChangeState.Removed */\n :\n // We need to keep track of removed targets to we can post-filter and\n // remove any target changes.\n // We need to decrement the number of pending acks needed from watch\n // for this targetId.\n n.Ne(), n.be || _this41.removeTarget(t);\n break;\n\n case 3\n /* WatchTargetChangeState.Current */\n :\n _this41.je(t) && (n.Be(), n.Ce(e.resumeToken));\n break;\n\n case 4\n /* WatchTargetChangeState.Reset */\n :\n _this41.je(t) && ( // Reset the target and synthesizes removes for all existing\n // documents. The backend will re-add any documents that still\n // match the target before it sends the next global snapshot.\n _this41.He(t), n.Ce(e.resumeToken));\n break;\n\n default:\n fail();\n }\n });\n }\n /**\n * Iterates over all targetIds that the watch change applies to: either the\n * targetIds explicitly listed in the change or the targetIds of all currently\n * active targets.\n */\n\n }, {\n key: \"forEachTarget\",\n value: function forEachTarget(e, t) {\n var _this42 = this;\n\n e.targetIds.length > 0 ? e.targetIds.forEach(t) : this.ke.forEach(function (e, n) {\n _this42.je(n) && t(n);\n });\n }\n /**\n * Handles existence filters and synthesizes deletes for filter mismatches.\n * Targets that are invalidated by filter mismatches are added to\n * `pendingTargetResets`.\n */\n\n }, {\n key: \"Je\",\n value: function Je(e) {\n var t = e.targetId,\n n = e.fe.count,\n r = this.Ye(t);\n\n if (r) {\n var i = r.target;\n if (__PRIVATE_targetIsDocumentTarget(i)) {\n if (0 === n) {\n // The existence filter told us the document does not exist. We deduce\n // that this document does not exist and apply a deleted document to\n // our updates. Without applying this deleted document there might be\n // another query that will raise this document as part of a snapshot\n // until it is resolved, essentially exposing inconsistency between\n // queries.\n var _e33 = new DocumentKey(i.path);\n\n this.We(t, _e33, MutableDocument.newNoDocument(_e33, SnapshotVersion.min()));\n } else __PRIVATE_hardAssert(1 === n);\n } else {\n var _r2 = this.Ze(t); // Existence filter mismatch. Mark the documents as being in limbo, and\n // raise a snapshot with `isFromCache:true`.\n\n\n if (_r2 !== n) {\n // Apply bloom filter to identify and mark removed documents.\n var _n11 = this.Xe(e),\n _i4 = _n11 ? this.et(_n11, e, _r2) : 1\n /* BloomFilterApplicationStatus.Skipped */\n ;\n\n if (0\n /* BloomFilterApplicationStatus.Success */\n !== _i4) {\n // If bloom filter application fails, we reset the mapping and\n // trigger re-run of the query.\n this.He(t);\n\n var _e34 = 2\n /* BloomFilterApplicationStatus.FalsePositive */\n === _i4 ? \"TargetPurposeExistenceFilterMismatchBloom\"\n /* TargetPurpose.ExistenceFilterMismatchBloom */\n : \"TargetPurposeExistenceFilterMismatch\"\n /* TargetPurpose.ExistenceFilterMismatch */\n ;\n\n this.Ke = this.Ke.insert(t, _e34);\n }\n\n null == ce || ce.tt(function __PRIVATE_createExistenceFilterMismatchInfoForTestingHooks(e, t, n, r, i) {\n var s, o, _, a, u, c;\n\n var l = {\n localCacheCount: e,\n existenceFilterCount: t.count,\n databaseId: n.database,\n projectId: n.projectId\n },\n h = t.unchangedNames;\n h && (l.bloomFilter = {\n applied: 0\n /* BloomFilterApplicationStatus.Success */\n === i,\n hashCount: null !== (s = null == h ? void 0 : h.hashCount) && void 0 !== s ? s : 0,\n bitmapLength: null !== (a = null === (_ = null === (o = null == h ? void 0 : h.bits) || void 0 === o ? void 0 : o.bitmap) || void 0 === _ ? void 0 : _.length) && void 0 !== a ? a : 0,\n padding: null !== (c = null === (u = null == h ? void 0 : h.bits) || void 0 === u ? void 0 : u.padding) && void 0 !== c ? c : 0,\n mightContain: function mightContain(e) {\n var t;\n return null !== (t = null == r ? void 0 : r.mightContain(e)) && void 0 !== t && t;\n }\n });\n return l;\n }\n /**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n (_r2, e.fe, this.Le.nt(), _n11, _i4));\n }\n }\n }\n }\n /**\n * Parse the bloom filter from the \"unchanged_names\" field of an existence\n * filter.\n */\n\n }, {\n key: \"Xe\",\n value: function Xe(e) {\n var t = e.fe.unchangedNames;\n if (!t || !t.bits) return null;\n var _t$bits = t.bits,\n _t$bits$bitmap = _t$bits.bitmap,\n n = _t$bits$bitmap === void 0 ? \"\" : _t$bits$bitmap,\n _t$bits$padding = _t$bits.padding,\n r = _t$bits$padding === void 0 ? 0 : _t$bits$padding,\n _t$hashCount = t.hashCount,\n i = _t$hashCount === void 0 ? 0 : _t$hashCount;\n var s, o;\n\n try {\n s = __PRIVATE_normalizeByteString(n).toUint8Array();\n } catch (e) {\n if (e instanceof __PRIVATE_Base64DecodeError) return __PRIVATE_logWarn(\"Decoding the base64 bloom filter in existence filter failed (\" + e.message + \"); ignoring the bloom filter and falling back to full re-query.\"), null;\n throw e;\n }\n\n try {\n // BloomFilter throws error if the inputs are invalid.\n o = new BloomFilter(s, r, i);\n } catch (e) {\n return __PRIVATE_logWarn(e instanceof __PRIVATE_BloomFilterError ? \"BloomFilter error: \" : \"Applying bloom filter failed: \", e), null;\n }\n\n return 0 === o.Te ? null : o;\n }\n /**\n * Apply bloom filter to remove the deleted documents, and return the\n * application status.\n */\n\n }, {\n key: \"et\",\n value: function et(e, t, n) {\n return t.fe.count === n - this.rt(e, t.targetId) ? 0\n /* BloomFilterApplicationStatus.Success */\n : 2\n /* BloomFilterApplicationStatus.FalsePositive */\n ;\n }\n /**\n * Filter out removed documents based on bloom filter membership result and\n * return number of documents removed.\n */\n\n }, {\n key: \"rt\",\n value: function rt(e, t) {\n var _this43 = this;\n\n var n = this.Le.getRemoteKeysForTarget(t);\n var r = 0;\n return n.forEach(function (n) {\n var i = _this43.Le.nt(),\n s = \"projects/\".concat(i.projectId, \"/databases/\").concat(i.database, \"/documents/\").concat(n.path.canonicalString());\n\n e.mightContain(s) || (_this43.We(t, n,\n /*updatedDocument=*/\n null), r++);\n }), r;\n }\n /**\n * Converts the currently accumulated state into a remote event at the\n * provided snapshot version. Resets the accumulated changes before returning.\n */\n\n }, {\n key: \"it\",\n value: function it(e) {\n var _this44 = this;\n\n var t = new Map();\n this.ke.forEach(function (n, r) {\n var i = _this44.Ye(r);\n\n if (i) {\n if (n.current && __PRIVATE_targetIsDocumentTarget(i.target)) {\n // Document queries for document that don't exist can produce an empty\n // result set. To update our local cache, we synthesize a document\n // delete if we have not previously received the document. This\n // resolves the limbo state of the document, removing it from\n // limboDocumentRefs.\n // TODO(dimond): Ideally we would have an explicit lookup target\n // instead resulting in an explicit delete message and we could\n // remove this special logic.\n var _t23 = new DocumentKey(i.target.path);\n\n null !== _this44.qe.get(_t23) || _this44.st(r, _t23) || _this44.We(r, _t23, MutableDocument.newNoDocument(_t23, e));\n }\n\n n.De && (t.set(r, n.ve()), n.Fe());\n }\n });\n\n var n = __PRIVATE_documentKeySet(); // We extract the set of limbo-only document updates as the GC logic\n // special-cases documents that do not appear in the target cache.\n // TODO(gsoltis): Expand on this comment once GC is available in the JS\n // client.\n\n\n this.Qe.forEach(function (e, t) {\n var r = !0;\n t.forEachWhile(function (e) {\n var t = _this44.Ye(e);\n\n return !t || \"TargetPurposeLimboResolution\"\n /* TargetPurpose.LimboResolution */\n === t.purpose || (r = !1, !1);\n }), r && (n = n.add(e));\n }), this.qe.forEach(function (t, n) {\n return n.setReadTime(e);\n });\n var r = new RemoteEvent(e, t, this.Ke, this.qe, n);\n return this.qe = __PRIVATE_mutableDocumentMap(), this.Qe = __PRIVATE_documentTargetMap(), this.Ke = new SortedMap(__PRIVATE_primitiveComparator), r;\n }\n /**\n * Adds the provided document to the internal list of document updates and\n * its document key to the given target's mapping.\n */\n // Visible for testing.\n\n }, {\n key: \"Ue\",\n value: function Ue(e, t) {\n if (!this.je(e)) return;\n var n = this.st(e, t.key) ? 2\n /* ChangeType.Modified */\n : 0\n /* ChangeType.Added */\n ;\n this.ze(e).Me(t.key, n), this.qe = this.qe.insert(t.key, t), this.Qe = this.Qe.insert(t.key, this.ot(t.key).add(e));\n }\n /**\n * Removes the provided document from the target mapping. If the\n * document no longer matches the target, but the document's state is still\n * known (e.g. we know that the document was deleted or we received the change\n * that caused the filter mismatch), the new document can be provided\n * to update the remote document cache.\n */\n // Visible for testing.\n\n }, {\n key: \"We\",\n value: function We(e, t, n) {\n if (!this.je(e)) return;\n var r = this.ze(e);\n this.st(e, t) ? r.Me(t, 1\n /* ChangeType.Removed */\n ) : // The document may have entered and left the target before we raised a\n // snapshot, so we can just ignore the change.\n r.xe(t), this.Qe = this.Qe.insert(t, this.ot(t).delete(e)), n && (this.qe = this.qe.insert(t, n));\n }\n }, {\n key: \"removeTarget\",\n value: function removeTarget(e) {\n this.ke.delete(e);\n }\n /**\n * Returns the current count of documents in the target. This includes both\n * the number of documents that the LocalStore considers to be part of the\n * target as well as any accumulated changes.\n */\n\n }, {\n key: \"Ze\",\n value: function Ze(e) {\n var t = this.ze(e).ve();\n return this.Le.getRemoteKeysForTarget(e).size + t.addedDocuments.size - t.removedDocuments.size;\n }\n /**\n * Increment the number of acks needed from watch before we can consider the\n * server to be 'in-sync' with the client's active targets.\n */\n\n }, {\n key: \"Oe\",\n value: function Oe(e) {\n this.ze(e).Oe();\n }\n }, {\n key: \"ze\",\n value: function ze(e) {\n var t = this.ke.get(e);\n return t || (t = new __PRIVATE_TargetState(), this.ke.set(e, t)), t;\n }\n }, {\n key: \"ot\",\n value: function ot(e) {\n var t = this.Qe.get(e);\n return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.Qe = this.Qe.insert(e, t)), t;\n }\n /**\n * Verifies that the user is still interested in this target (by calling\n * `getTargetDataForTarget()`) and that we are not waiting for pending ADDs\n * from watch.\n */\n\n }, {\n key: \"je\",\n value: function je(e) {\n var t = null !== this.Ye(e);\n return t || __PRIVATE_logDebug(\"WatchChangeAggregator\", \"Detected inactive target\", e), t;\n }\n /**\n * Returns the TargetData for an active target (i.e. a target that the user\n * is still interested in that has no outstanding target change requests).\n */\n\n }, {\n key: \"Ye\",\n value: function Ye(e) {\n var t = this.ke.get(e);\n return t && t.be ? null : this.Le._t(e);\n }\n /**\n * Resets the state of a Watch target to its initial state (e.g. sets\n * 'current' to false, clears the resume token and removes its target mapping\n * from all documents).\n */\n\n }, {\n key: \"He\",\n value: function He(e) {\n var _this45 = this;\n\n this.ke.set(e, new __PRIVATE_TargetState());\n this.Le.getRemoteKeysForTarget(e).forEach(function (t) {\n _this45.We(e, t,\n /*updatedDocument=*/\n null);\n });\n }\n /**\n * Returns whether the LocalStore considers the document to be part of the\n * specified target.\n */\n\n }, {\n key: \"st\",\n value: function st(e, t) {\n return this.Le.getRemoteKeysForTarget(e).has(t);\n }\n }]);\n\n return __PRIVATE_WatchChangeAggregator;\n}();\n\nfunction __PRIVATE_documentTargetMap() {\n return new SortedMap(DocumentKey.comparator);\n}\n\nfunction __PRIVATE_snapshotChangesMap() {\n return new SortedMap(DocumentKey.comparator);\n}\n\nvar he = function () {\n var e = {\n asc: \"ASCENDING\",\n desc: \"DESCENDING\"\n };\n return e;\n}(),\n Pe = function () {\n var e = {\n \"<\": \"LESS_THAN\",\n \"<=\": \"LESS_THAN_OR_EQUAL\",\n \">\": \"GREATER_THAN\",\n \">=\": \"GREATER_THAN_OR_EQUAL\",\n \"==\": \"EQUAL\",\n \"!=\": \"NOT_EQUAL\",\n \"array-contains\": \"ARRAY_CONTAINS\",\n in: \"IN\",\n \"not-in\": \"NOT_IN\",\n \"array-contains-any\": \"ARRAY_CONTAINS_ANY\"\n };\n return e;\n}(),\n Ie = function () {\n var e = {\n and: \"AND\",\n or: \"OR\"\n };\n return e;\n}();\n/**\n * This class generates JsonObject values for the Datastore API suitable for\n * sending to either GRPC stub methods or via the JSON/HTTP REST API.\n *\n * The serializer supports both Protobuf.js and Proto3 JSON formats. By\n * setting `useProto3Json` to true, the serializer will use the Proto3 JSON\n * format.\n *\n * For a description of the Proto3 JSON format check\n * https://developers.google.com/protocol-buffers/docs/proto3#json\n *\n * TODO(klimt): We can remove the databaseId argument if we keep the full\n * resource name in documents.\n */\n\n\nvar JsonProtoSerializer = /*#__PURE__*/_createClass(function JsonProtoSerializer(e, t) {\n _classCallCheck(this, JsonProtoSerializer);\n\n this.databaseId = e, this.useProto3Json = t;\n});\n/**\n * Returns a value for a number (or null) that's appropriate to put into\n * a google.protobuf.Int32Value proto.\n * DO NOT USE THIS FOR ANYTHING ELSE.\n * This method cheats. It's typed as returning \"number\" because that's what\n * our generated proto interfaces say Int32Value must be. But GRPC actually\n * expects a { value: } struct.\n */\n\n\nfunction __PRIVATE_toInt32Proto(e, t) {\n return e.useProto3Json || __PRIVATE_isNullOrUndefined(t) ? t : {\n value: t\n };\n}\n/**\n * Returns a number (or null) from a google.protobuf.Int32Value proto.\n */\n\n/**\n * Returns a value for a Date that's appropriate to put into a proto.\n */\n\n\nfunction toTimestamp(e, t) {\n if (e.useProto3Json) {\n return \"\".concat(new Date(1e3 * t.seconds).toISOString().replace(/\\.\\d*/, \"\").replace(\"Z\", \"\"), \".\").concat((\"000000000\" + t.nanoseconds).slice(-9), \"Z\");\n }\n\n return {\n seconds: \"\" + t.seconds,\n nanos: t.nanoseconds\n };\n}\n/**\n * Returns a value for bytes that's appropriate to put in a proto.\n *\n * Visible for testing.\n */\n\n\nfunction __PRIVATE_toBytes(e, t) {\n return e.useProto3Json ? t.toBase64() : t.toUint8Array();\n}\n/**\n * Returns a ByteString based on the proto string value.\n */\n\n\nfunction __PRIVATE_toVersion(e, t) {\n return toTimestamp(e, t.toTimestamp());\n}\n\nfunction __PRIVATE_fromVersion(e) {\n return __PRIVATE_hardAssert(!!e), SnapshotVersion.fromTimestamp(function fromTimestamp(e) {\n var t = __PRIVATE_normalizeTimestamp(e);\n\n return new Timestamp(t.seconds, t.nanos);\n }(e));\n}\n\nfunction __PRIVATE_toResourceName(e, t) {\n return __PRIVATE_toResourcePath(e, t).canonicalString();\n}\n\nfunction __PRIVATE_toResourcePath(e, t) {\n var n = function __PRIVATE_fullyQualifiedPrefixPath(e) {\n return new ResourcePath([\"projects\", e.projectId, \"databases\", e.database]);\n }(e).child(\"documents\");\n\n return void 0 === t ? n : n.child(t);\n}\n\nfunction __PRIVATE_fromResourceName(e) {\n var t = ResourcePath.fromString(e);\n return __PRIVATE_hardAssert(__PRIVATE_isValidResourceName(t)), t;\n}\n\nfunction __PRIVATE_toName(e, t) {\n return __PRIVATE_toResourceName(e.databaseId, t.path);\n}\n\nfunction fromName(e, t) {\n var n = __PRIVATE_fromResourceName(t);\n\n if (n.get(1) !== e.databaseId.projectId) throw new FirestoreError(D.INVALID_ARGUMENT, \"Tried to deserialize key from different project: \" + n.get(1) + \" vs \" + e.databaseId.projectId);\n if (n.get(3) !== e.databaseId.database) throw new FirestoreError(D.INVALID_ARGUMENT, \"Tried to deserialize key from different database: \" + n.get(3) + \" vs \" + e.databaseId.database);\n return new DocumentKey(__PRIVATE_extractLocalPathFromResourceName(n));\n}\n\nfunction __PRIVATE_toQueryPath(e, t) {\n return __PRIVATE_toResourceName(e.databaseId, t);\n}\n\nfunction __PRIVATE_fromQueryPath(e) {\n var t = __PRIVATE_fromResourceName(e); // In v1beta1 queries for collections at the root did not have a trailing\n // \"/documents\". In v1 all resource paths contain \"/documents\". Preserve the\n // ability to read the v1beta1 form for compatibility with queries persisted\n // in the local target cache.\n\n\n return 4 === t.length ? ResourcePath.emptyPath() : __PRIVATE_extractLocalPathFromResourceName(t);\n}\n\nfunction __PRIVATE_getEncodedDatabaseId(e) {\n return new ResourcePath([\"projects\", e.databaseId.projectId, \"databases\", e.databaseId.database]).canonicalString();\n}\n\nfunction __PRIVATE_extractLocalPathFromResourceName(e) {\n return __PRIVATE_hardAssert(e.length > 4 && \"documents\" === e.get(4)), e.popFirst(5);\n}\n/** Creates a Document proto from key and fields (but no create/update time) */\n\n\nfunction __PRIVATE_toMutationDocument(e, t, n) {\n return {\n name: __PRIVATE_toName(e, t),\n fields: n.value.mapValue.fields\n };\n}\n\nfunction __PRIVATE_fromDocument(e, t, n) {\n var r = fromName(e, t.name),\n i = __PRIVATE_fromVersion(t.updateTime),\n s = t.createTime ? __PRIVATE_fromVersion(t.createTime) : SnapshotVersion.min(),\n o = new ObjectValue({\n mapValue: {\n fields: t.fields\n }\n }),\n _ = MutableDocument.newFoundDocument(r, i, s, o);\n\n return n && _.setHasCommittedMutations(), n ? _.setHasCommittedMutations() : _;\n}\n\nfunction __PRIVATE_fromBatchGetDocumentsResponse(e, t) {\n return \"found\" in t ? function __PRIVATE_fromFound(e, t) {\n __PRIVATE_hardAssert(!!t.found), t.found.name, t.found.updateTime;\n\n var n = fromName(e, t.found.name),\n r = __PRIVATE_fromVersion(t.found.updateTime),\n i = t.found.createTime ? __PRIVATE_fromVersion(t.found.createTime) : SnapshotVersion.min(),\n s = new ObjectValue({\n mapValue: {\n fields: t.found.fields\n }\n });\n\n return MutableDocument.newFoundDocument(n, r, i, s);\n }(e, t) : \"missing\" in t ? function __PRIVATE_fromMissing(e, t) {\n __PRIVATE_hardAssert(!!t.missing), __PRIVATE_hardAssert(!!t.readTime);\n\n var n = fromName(e, t.missing),\n r = __PRIVATE_fromVersion(t.readTime);\n\n return MutableDocument.newNoDocument(n, r);\n }(e, t) : fail();\n}\n\nfunction __PRIVATE_fromWatchChange(e, t) {\n var n;\n\n if (\"targetChange\" in t) {\n t.targetChange; // proto3 default value is unset in JSON (undefined), so use 'NO_CHANGE'\n // if unset\n\n var r = function __PRIVATE_fromWatchTargetChangeState(e) {\n return \"NO_CHANGE\" === e ? 0\n /* WatchTargetChangeState.NoChange */\n : \"ADD\" === e ? 1\n /* WatchTargetChangeState.Added */\n : \"REMOVE\" === e ? 2\n /* WatchTargetChangeState.Removed */\n : \"CURRENT\" === e ? 3\n /* WatchTargetChangeState.Current */\n : \"RESET\" === e ? 4\n /* WatchTargetChangeState.Reset */\n : fail();\n }(t.targetChange.targetChangeType || \"NO_CHANGE\"),\n i = t.targetChange.targetIds || [],\n s = function __PRIVATE_fromBytes(e, t) {\n return e.useProto3Json ? (__PRIVATE_hardAssert(void 0 === t || \"string\" == typeof t), ByteString.fromBase64String(t || \"\")) : (__PRIVATE_hardAssert(void 0 === t || t instanceof Uint8Array), ByteString.fromUint8Array(t || new Uint8Array()));\n }(e, t.targetChange.resumeToken),\n o = t.targetChange.cause,\n _ = o && function __PRIVATE_fromRpcStatus(e) {\n var t = void 0 === e.code ? D.UNKNOWN : __PRIVATE_mapCodeFromRpcCode(e.code);\n return new FirestoreError(t, e.message || \"\");\n }(o);\n\n n = new __PRIVATE_WatchTargetChange(r, i, s, _ || null);\n } else if (\"documentChange\" in t) {\n t.documentChange;\n var _r3 = t.documentChange;\n _r3.document, _r3.document.name, _r3.document.updateTime;\n\n var _i5 = fromName(e, _r3.document.name),\n _s = __PRIVATE_fromVersion(_r3.document.updateTime),\n _o = _r3.document.createTime ? __PRIVATE_fromVersion(_r3.document.createTime) : SnapshotVersion.min(),\n _2 = new ObjectValue({\n mapValue: {\n fields: _r3.document.fields\n }\n }),\n a = MutableDocument.newFoundDocument(_i5, _s, _o, _2),\n u = _r3.targetIds || [],\n c = _r3.removedTargetIds || [];\n\n n = new __PRIVATE_DocumentWatchChange(u, c, a.key, a);\n } else if (\"documentDelete\" in t) {\n t.documentDelete;\n var _r4 = t.documentDelete;\n _r4.document;\n\n var _i6 = fromName(e, _r4.document),\n _s2 = _r4.readTime ? __PRIVATE_fromVersion(_r4.readTime) : SnapshotVersion.min(),\n _o2 = MutableDocument.newNoDocument(_i6, _s2),\n _3 = _r4.removedTargetIds || [];\n\n n = new __PRIVATE_DocumentWatchChange([], _3, _o2.key, _o2);\n } else if (\"documentRemove\" in t) {\n t.documentRemove;\n var _r5 = t.documentRemove;\n _r5.document;\n\n var _i7 = fromName(e, _r5.document),\n _s3 = _r5.removedTargetIds || [];\n\n n = new __PRIVATE_DocumentWatchChange([], _s3, _i7, null);\n } else {\n if (!(\"filter\" in t)) return fail();\n {\n t.filter;\n var _e35 = t.filter;\n _e35.targetId;\n\n var _e35$count = _e35.count,\n _r6 = _e35$count === void 0 ? 0 : _e35$count,\n _i8 = _e35.unchangedNames,\n _s4 = new ExistenceFilter(_r6, _i8),\n _o3 = _e35.targetId;\n\n n = new __PRIVATE_ExistenceFilterChange(_o3, _s4);\n }\n }\n\n return n;\n}\n\nfunction toMutation(e, t) {\n var n;\n if (t instanceof __PRIVATE_SetMutation) n = {\n update: __PRIVATE_toMutationDocument(e, t.key, t.value)\n };else if (t instanceof __PRIVATE_DeleteMutation) n = {\n delete: __PRIVATE_toName(e, t.key)\n };else if (t instanceof __PRIVATE_PatchMutation) n = {\n update: __PRIVATE_toMutationDocument(e, t.key, t.data),\n updateMask: __PRIVATE_toDocumentMask(t.fieldMask)\n };else {\n if (!(t instanceof __PRIVATE_VerifyMutation)) return fail();\n n = {\n verify: __PRIVATE_toName(e, t.key)\n };\n }\n return t.fieldTransforms.length > 0 && (n.updateTransforms = t.fieldTransforms.map(function (e) {\n return function __PRIVATE_toFieldTransform(e, t) {\n var n = t.transform;\n if (n instanceof __PRIVATE_ServerTimestampTransform) return {\n fieldPath: t.field.canonicalString(),\n setToServerValue: \"REQUEST_TIME\"\n };\n if (n instanceof __PRIVATE_ArrayUnionTransformOperation) return {\n fieldPath: t.field.canonicalString(),\n appendMissingElements: {\n values: n.elements\n }\n };\n if (n instanceof __PRIVATE_ArrayRemoveTransformOperation) return {\n fieldPath: t.field.canonicalString(),\n removeAllFromArray: {\n values: n.elements\n }\n };\n if (n instanceof __PRIVATE_NumericIncrementTransformOperation) return {\n fieldPath: t.field.canonicalString(),\n increment: n.Ie\n };\n throw fail();\n }(0, e);\n })), t.precondition.isNone || (n.currentDocument = function __PRIVATE_toPrecondition(e, t) {\n return void 0 !== t.updateTime ? {\n updateTime: __PRIVATE_toVersion(e, t.updateTime)\n } : void 0 !== t.exists ? {\n exists: t.exists\n } : fail();\n }(e, t.precondition)), n;\n}\n\nfunction __PRIVATE_fromMutation(e, t) {\n var n = t.currentDocument ? function __PRIVATE_fromPrecondition(e) {\n return void 0 !== e.updateTime ? Precondition.updateTime(__PRIVATE_fromVersion(e.updateTime)) : void 0 !== e.exists ? Precondition.exists(e.exists) : Precondition.none();\n }(t.currentDocument) : Precondition.none(),\n r = t.updateTransforms ? t.updateTransforms.map(function (t) {\n return function __PRIVATE_fromFieldTransform(e, t) {\n var n = null;\n if (\"setToServerValue\" in t) __PRIVATE_hardAssert(\"REQUEST_TIME\" === t.setToServerValue), n = new __PRIVATE_ServerTimestampTransform();else if (\"appendMissingElements\" in t) {\n var _e36 = t.appendMissingElements.values || [];\n\n n = new __PRIVATE_ArrayUnionTransformOperation(_e36);\n } else if (\"removeAllFromArray\" in t) {\n var _e37 = t.removeAllFromArray.values || [];\n\n n = new __PRIVATE_ArrayRemoveTransformOperation(_e37);\n } else \"increment\" in t ? n = new __PRIVATE_NumericIncrementTransformOperation(e, t.increment) : fail();\n var r = FieldPath$1.fromServerFormat(t.fieldPath);\n return new FieldTransform(r, n);\n }(e, t);\n }) : [];\n\n if (t.update) {\n t.update.name;\n var i = fromName(e, t.update.name),\n s = new ObjectValue({\n mapValue: {\n fields: t.update.fields\n }\n });\n\n if (t.updateMask) {\n var _e38 = function __PRIVATE_fromDocumentMask(e) {\n var t = e.fieldPaths || [];\n return new FieldMask(t.map(function (e) {\n return FieldPath$1.fromServerFormat(e);\n }));\n }(t.updateMask);\n\n return new __PRIVATE_PatchMutation(i, s, _e38, n, r);\n }\n\n return new __PRIVATE_SetMutation(i, s, n, r);\n }\n\n if (t.delete) {\n var _r7 = fromName(e, t.delete);\n\n return new __PRIVATE_DeleteMutation(_r7, n);\n }\n\n if (t.verify) {\n var _r8 = fromName(e, t.verify);\n\n return new __PRIVATE_VerifyMutation(_r8, n);\n }\n\n return fail();\n}\n\nfunction __PRIVATE_fromWriteResults(e, t) {\n return e && e.length > 0 ? (__PRIVATE_hardAssert(void 0 !== t), e.map(function (e) {\n return function __PRIVATE_fromWriteResult(e, t) {\n // NOTE: Deletes don't have an updateTime.\n var n = e.updateTime ? __PRIVATE_fromVersion(e.updateTime) : __PRIVATE_fromVersion(t);\n return n.isEqual(SnapshotVersion.min()) && ( // The Firestore Emulator currently returns an update time of 0 for\n // deletes of non-existing documents (rather than null). This breaks the\n // test \"get deleted doc while offline with source=cache\" as NoDocuments\n // with version 0 are filtered by IndexedDb's RemoteDocumentCache.\n // TODO(#2149): Remove this when Emulator is fixed\n n = __PRIVATE_fromVersion(t)), new MutationResult(n, e.transformResults || []);\n }(e, t);\n })) : [];\n}\n\nfunction __PRIVATE_toDocumentsTarget(e, t) {\n return {\n documents: [__PRIVATE_toQueryPath(e, t.path)]\n };\n}\n\nfunction __PRIVATE_toQueryTarget(e, t) {\n // Dissect the path into parent, collectionId, and optional key filter.\n var n = {\n structuredQuery: {}\n },\n r = t.path;\n var i;\n null !== t.collectionGroup ? (i = r, n.structuredQuery.from = [{\n collectionId: t.collectionGroup,\n allDescendants: !0\n }]) : (i = r.popLast(), n.structuredQuery.from = [{\n collectionId: r.lastSegment()\n }]), n.parent = __PRIVATE_toQueryPath(e, i);\n\n var s = function __PRIVATE_toFilters(e) {\n if (0 === e.length) return;\n return __PRIVATE_toFilter(CompositeFilter.create(e, \"and\"\n /* CompositeOperator.AND */\n ));\n }(t.filters);\n\n s && (n.structuredQuery.where = s);\n\n var o = function __PRIVATE_toOrder(e) {\n if (0 === e.length) return;\n return e.map(function (e) {\n return (// visible for testing\n function __PRIVATE_toPropertyOrder(e) {\n return {\n field: __PRIVATE_toFieldPathReference(e.field),\n direction: __PRIVATE_toDirection(e.dir)\n };\n }(e)\n );\n });\n }(t.orderBy);\n\n o && (n.structuredQuery.orderBy = o);\n\n var _ = __PRIVATE_toInt32Proto(e, t.limit);\n\n return null !== _ && (n.structuredQuery.limit = _), t.startAt && (n.structuredQuery.startAt = function __PRIVATE_toStartAtCursor(e) {\n return {\n before: e.inclusive,\n values: e.position\n };\n }(t.startAt)), t.endAt && (n.structuredQuery.endAt = function __PRIVATE_toEndAtCursor(e) {\n return {\n before: !e.inclusive,\n values: e.position\n };\n }(t.endAt)), {\n ut: n,\n parent: i\n };\n}\n\nfunction __PRIVATE_convertQueryTargetToQuery(e) {\n var t = __PRIVATE_fromQueryPath(e.parent);\n\n var n = e.structuredQuery,\n r = n.from ? n.from.length : 0;\n var i = null;\n\n if (r > 0) {\n __PRIVATE_hardAssert(1 === r);\n\n var _e39 = n.from[0];\n _e39.allDescendants ? i = _e39.collectionId : t = t.child(_e39.collectionId);\n }\n\n var s = [];\n n.where && (s = function __PRIVATE_fromFilters(e) {\n var t = __PRIVATE_fromFilter(e);\n\n if (t instanceof CompositeFilter && __PRIVATE_compositeFilterIsFlatConjunction(t)) return t.getFilters();\n return [t];\n }(n.where));\n var o = [];\n n.orderBy && (o = function __PRIVATE_fromOrder(e) {\n return e.map(function (e) {\n return function __PRIVATE_fromPropertyOrder(e) {\n return new OrderBy(__PRIVATE_fromFieldPathReference(e.field), // visible for testing\n function __PRIVATE_fromDirection(e) {\n switch (e) {\n case \"ASCENDING\":\n return \"asc\"\n /* Direction.ASCENDING */\n ;\n\n case \"DESCENDING\":\n return \"desc\"\n /* Direction.DESCENDING */\n ;\n\n default:\n return;\n }\n } // visible for testing\n (e.direction));\n } // visible for testing\n (e);\n });\n }(n.orderBy));\n var _ = null;\n n.limit && (_ = function __PRIVATE_fromInt32Proto(e) {\n var t;\n return t = \"object\" == typeof e ? e.value : e, __PRIVATE_isNullOrUndefined(t) ? null : t;\n }(n.limit));\n var a = null;\n n.startAt && (a = function __PRIVATE_fromStartAtCursor(e) {\n var t = !!e.before,\n n = e.values || [];\n return new Bound(n, t);\n }(n.startAt));\n var u = null;\n return n.endAt && (u = function __PRIVATE_fromEndAtCursor(e) {\n var t = !e.before,\n n = e.values || [];\n return new Bound(n, t);\n } // visible for testing\n (n.endAt)), __PRIVATE_newQuery(t, i, o, s, _, \"F\"\n /* LimitType.First */\n , a, u);\n}\n\nfunction __PRIVATE_toListenRequestLabels(e, t) {\n var n = function __PRIVATE_toLabel(e) {\n switch (e) {\n case \"TargetPurposeListen\"\n /* TargetPurpose.Listen */\n :\n return null;\n\n case \"TargetPurposeExistenceFilterMismatch\"\n /* TargetPurpose.ExistenceFilterMismatch */\n :\n return \"existence-filter-mismatch\";\n\n case \"TargetPurposeExistenceFilterMismatchBloom\"\n /* TargetPurpose.ExistenceFilterMismatchBloom */\n :\n return \"existence-filter-mismatch-bloom\";\n\n case \"TargetPurposeLimboResolution\"\n /* TargetPurpose.LimboResolution */\n :\n return \"limbo-document\";\n\n default:\n return fail();\n }\n }(t.purpose);\n\n return null == n ? null : {\n \"goog-listen-tags\": n\n };\n}\n\nfunction __PRIVATE_fromFilter(e) {\n return void 0 !== e.unaryFilter ? function __PRIVATE_fromUnaryFilter(e) {\n switch (e.unaryFilter.op) {\n case \"IS_NAN\":\n var t = __PRIVATE_fromFieldPathReference(e.unaryFilter.field);\n\n return FieldFilter.create(t, \"==\"\n /* Operator.EQUAL */\n , {\n doubleValue: NaN\n });\n\n case \"IS_NULL\":\n var n = __PRIVATE_fromFieldPathReference(e.unaryFilter.field);\n\n return FieldFilter.create(n, \"==\"\n /* Operator.EQUAL */\n , {\n nullValue: \"NULL_VALUE\"\n });\n\n case \"IS_NOT_NAN\":\n var r = __PRIVATE_fromFieldPathReference(e.unaryFilter.field);\n\n return FieldFilter.create(r, \"!=\"\n /* Operator.NOT_EQUAL */\n , {\n doubleValue: NaN\n });\n\n case \"IS_NOT_NULL\":\n var i = __PRIVATE_fromFieldPathReference(e.unaryFilter.field);\n\n return FieldFilter.create(i, \"!=\"\n /* Operator.NOT_EQUAL */\n , {\n nullValue: \"NULL_VALUE\"\n });\n\n default:\n return fail();\n }\n }(e) : void 0 !== e.fieldFilter ? function __PRIVATE_fromFieldFilter(e) {\n return FieldFilter.create(__PRIVATE_fromFieldPathReference(e.fieldFilter.field), function __PRIVATE_fromOperatorName(e) {\n switch (e) {\n case \"EQUAL\":\n return \"==\"\n /* Operator.EQUAL */\n ;\n\n case \"NOT_EQUAL\":\n return \"!=\"\n /* Operator.NOT_EQUAL */\n ;\n\n case \"GREATER_THAN\":\n return \">\"\n /* Operator.GREATER_THAN */\n ;\n\n case \"GREATER_THAN_OR_EQUAL\":\n return \">=\"\n /* Operator.GREATER_THAN_OR_EQUAL */\n ;\n\n case \"LESS_THAN\":\n return \"<\"\n /* Operator.LESS_THAN */\n ;\n\n case \"LESS_THAN_OR_EQUAL\":\n return \"<=\"\n /* Operator.LESS_THAN_OR_EQUAL */\n ;\n\n case \"ARRAY_CONTAINS\":\n return \"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n ;\n\n case \"IN\":\n return \"in\"\n /* Operator.IN */\n ;\n\n case \"NOT_IN\":\n return \"not-in\"\n /* Operator.NOT_IN */\n ;\n\n case \"ARRAY_CONTAINS_ANY\":\n return \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n ;\n\n default:\n return fail();\n }\n }(e.fieldFilter.op), e.fieldFilter.value);\n }(e) : void 0 !== e.compositeFilter ? function __PRIVATE_fromCompositeFilter(e) {\n return CompositeFilter.create(e.compositeFilter.filters.map(function (e) {\n return __PRIVATE_fromFilter(e);\n }), function __PRIVATE_fromCompositeOperatorName(e) {\n switch (e) {\n case \"AND\":\n return \"and\"\n /* CompositeOperator.AND */\n ;\n\n case \"OR\":\n return \"or\"\n /* CompositeOperator.OR */\n ;\n\n default:\n return fail();\n }\n }(e.compositeFilter.op));\n }(e) : fail();\n}\n\nfunction __PRIVATE_toDirection(e) {\n return he[e];\n}\n\nfunction __PRIVATE_toOperatorName(e) {\n return Pe[e];\n}\n\nfunction __PRIVATE_toCompositeOperatorName(e) {\n return Ie[e];\n}\n\nfunction __PRIVATE_toFieldPathReference(e) {\n return {\n fieldPath: e.canonicalString()\n };\n}\n\nfunction __PRIVATE_fromFieldPathReference(e) {\n return FieldPath$1.fromServerFormat(e.fieldPath);\n}\n\nfunction __PRIVATE_toFilter(e) {\n return e instanceof FieldFilter ? function __PRIVATE_toUnaryOrFieldFilter(e) {\n if (\"==\"\n /* Operator.EQUAL */\n === e.op) {\n if (__PRIVATE_isNanValue(e.value)) return {\n unaryFilter: {\n field: __PRIVATE_toFieldPathReference(e.field),\n op: \"IS_NAN\"\n }\n };\n if (__PRIVATE_isNullValue(e.value)) return {\n unaryFilter: {\n field: __PRIVATE_toFieldPathReference(e.field),\n op: \"IS_NULL\"\n }\n };\n } else if (\"!=\"\n /* Operator.NOT_EQUAL */\n === e.op) {\n if (__PRIVATE_isNanValue(e.value)) return {\n unaryFilter: {\n field: __PRIVATE_toFieldPathReference(e.field),\n op: \"IS_NOT_NAN\"\n }\n };\n if (__PRIVATE_isNullValue(e.value)) return {\n unaryFilter: {\n field: __PRIVATE_toFieldPathReference(e.field),\n op: \"IS_NOT_NULL\"\n }\n };\n }\n\n return {\n fieldFilter: {\n field: __PRIVATE_toFieldPathReference(e.field),\n op: __PRIVATE_toOperatorName(e.op),\n value: e.value\n }\n };\n }(e) : e instanceof CompositeFilter ? function __PRIVATE_toCompositeFilter(e) {\n var t = e.getFilters().map(function (e) {\n return __PRIVATE_toFilter(e);\n });\n if (1 === t.length) return t[0];\n return {\n compositeFilter: {\n op: __PRIVATE_toCompositeOperatorName(e.op),\n filters: t\n }\n };\n }(e) : fail();\n}\n\nfunction __PRIVATE_toDocumentMask(e) {\n var t = [];\n return e.fields.forEach(function (e) {\n return t.push(e.canonicalString());\n }), {\n fieldPaths: t\n };\n}\n\nfunction __PRIVATE_isValidResourceName(e) {\n // Resource names have at least 4 components (project ID, database ID)\n return e.length >= 4 && \"projects\" === e.get(0) && \"databases\" === e.get(2);\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An immutable set of metadata that the local store tracks for each target.\n */\n\n\nvar TargetData = /*#__PURE__*/function () {\n function TargetData(\n /** The target being listened to. */\n e,\n /**\n * The target ID to which the target corresponds; Assigned by the\n * LocalStore for user listens and by the SyncEngine for limbo watches.\n */\n t,\n /** The purpose of the target. */\n n,\n /**\n * The sequence number of the last transaction during which this target data\n * was modified.\n */\n r) {\n var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : SnapshotVersion.min();\n var s = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : SnapshotVersion.min();\n var o = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ByteString.EMPTY_BYTE_STRING;\n\n var _ = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;\n\n _classCallCheck(this, TargetData);\n\n this.target = e, this.targetId = t, this.purpose = n, this.sequenceNumber = r, this.snapshotVersion = i, this.lastLimboFreeSnapshotVersion = s, this.resumeToken = o, this.expectedCount = _;\n }\n /** Creates a new target data instance with an updated sequence number. */\n\n\n _createClass(TargetData, [{\n key: \"withSequenceNumber\",\n value: function withSequenceNumber(e) {\n return new TargetData(this.target, this.targetId, this.purpose, e, this.snapshotVersion, this.lastLimboFreeSnapshotVersion, this.resumeToken, this.expectedCount);\n }\n /**\n * Creates a new target data instance with an updated resume token and\n * snapshot version.\n */\n\n }, {\n key: \"withResumeToken\",\n value: function withResumeToken(e, t) {\n return new TargetData(this.target, this.targetId, this.purpose, this.sequenceNumber, t, this.lastLimboFreeSnapshotVersion, e,\n /* expectedCount= */\n null);\n }\n /**\n * Creates a new target data instance with an updated expected count.\n */\n\n }, {\n key: \"withExpectedCount\",\n value: function withExpectedCount(e) {\n return new TargetData(this.target, this.targetId, this.purpose, this.sequenceNumber, this.snapshotVersion, this.lastLimboFreeSnapshotVersion, this.resumeToken, e);\n }\n /**\n * Creates a new target data instance with an updated last limbo free\n * snapshot version number.\n */\n\n }, {\n key: \"withLastLimboFreeSnapshotVersion\",\n value: function withLastLimboFreeSnapshotVersion(e) {\n return new TargetData(this.target, this.targetId, this.purpose, this.sequenceNumber, this.snapshotVersion, e, this.resumeToken, this.expectedCount);\n }\n }]);\n\n return TargetData;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Serializer for values stored in the LocalStore. */\n\n\nvar __PRIVATE_LocalSerializer = /*#__PURE__*/_createClass(function __PRIVATE_LocalSerializer(e) {\n _classCallCheck(this, __PRIVATE_LocalSerializer);\n\n this.ct = e;\n});\n/** Decodes a remote document from storage locally to a Document. */\n\n\nfunction __PRIVATE_fromDbRemoteDocument(e, t) {\n var n;\n if (t.document) n = __PRIVATE_fromDocument(e.ct, t.document, !!t.hasCommittedMutations);else if (t.noDocument) {\n var _e40 = DocumentKey.fromSegments(t.noDocument.path),\n r = __PRIVATE_fromDbTimestamp(t.noDocument.readTime);\n\n n = MutableDocument.newNoDocument(_e40, r), t.hasCommittedMutations && n.setHasCommittedMutations();\n } else {\n if (!t.unknownDocument) return fail();\n {\n var _e41 = DocumentKey.fromSegments(t.unknownDocument.path),\n _r9 = __PRIVATE_fromDbTimestamp(t.unknownDocument.version);\n\n n = MutableDocument.newUnknownDocument(_e41, _r9);\n }\n }\n return t.readTime && n.setReadTime(function __PRIVATE_fromDbTimestampKey(e) {\n var t = new Timestamp(e[0], e[1]);\n return SnapshotVersion.fromTimestamp(t);\n }(t.readTime)), n;\n}\n/** Encodes a document for storage locally. */\n\n\nfunction __PRIVATE_toDbRemoteDocument(e, t) {\n var n = t.key,\n r = {\n prefixPath: n.getCollectionPath().popLast().toArray(),\n collectionGroup: n.collectionGroup,\n documentId: n.path.lastSegment(),\n readTime: __PRIVATE_toDbTimestampKey(t.readTime),\n hasCommittedMutations: t.hasCommittedMutations\n };\n if (t.isFoundDocument()) r.document = function __PRIVATE_toDocument(e, t) {\n return {\n name: __PRIVATE_toName(e, t.key),\n fields: t.data.value.mapValue.fields,\n updateTime: toTimestamp(e, t.version.toTimestamp()),\n createTime: toTimestamp(e, t.createTime.toTimestamp())\n };\n }(e.ct, t);else if (t.isNoDocument()) r.noDocument = {\n path: n.path.toArray(),\n readTime: __PRIVATE_toDbTimestamp(t.version)\n };else {\n if (!t.isUnknownDocument()) return fail();\n r.unknownDocument = {\n path: n.path.toArray(),\n version: __PRIVATE_toDbTimestamp(t.version)\n };\n }\n return r;\n}\n\nfunction __PRIVATE_toDbTimestampKey(e) {\n var t = e.toTimestamp();\n return [t.seconds, t.nanoseconds];\n}\n\nfunction __PRIVATE_toDbTimestamp(e) {\n var t = e.toTimestamp();\n return {\n seconds: t.seconds,\n nanoseconds: t.nanoseconds\n };\n}\n\nfunction __PRIVATE_fromDbTimestamp(e) {\n var t = new Timestamp(e.seconds, e.nanoseconds);\n return SnapshotVersion.fromTimestamp(t);\n}\n/** Encodes a batch of mutations into a DbMutationBatch for local storage. */\n\n/** Decodes a DbMutationBatch into a MutationBatch */\n\n\nfunction __PRIVATE_fromDbMutationBatch(e, t) {\n var n = (t.baseMutations || []).map(function (t) {\n return __PRIVATE_fromMutation(e.ct, t);\n }); // Squash old transform mutations into existing patch or set mutations.\n // The replacement of representing `transforms` with `update_transforms`\n // on the SDK means that old `transform` mutations stored in IndexedDB need\n // to be updated to `update_transforms`.\n // TODO(b/174608374): Remove this code once we perform a schema migration.\n\n for (var _e42 = 0; _e42 < t.mutations.length - 1; ++_e42) {\n var _n12 = t.mutations[_e42];\n\n if (_e42 + 1 < t.mutations.length && void 0 !== t.mutations[_e42 + 1].transform) {\n var _r10 = t.mutations[_e42 + 1];\n _n12.updateTransforms = _r10.transform.fieldTransforms, t.mutations.splice(_e42 + 1, 1), ++_e42;\n }\n }\n\n var r = t.mutations.map(function (t) {\n return __PRIVATE_fromMutation(e.ct, t);\n }),\n i = Timestamp.fromMillis(t.localWriteTimeMs);\n return new MutationBatch(t.batchId, i, n, r);\n}\n/** Decodes a DbTarget into TargetData */\n\n\nfunction __PRIVATE_fromDbTarget(e) {\n var t = __PRIVATE_fromDbTimestamp(e.readTime),\n n = void 0 !== e.lastLimboFreeSnapshotVersion ? __PRIVATE_fromDbTimestamp(e.lastLimboFreeSnapshotVersion) : SnapshotVersion.min();\n\n var r;\n return r =\n /**\n * A helper function for figuring out what kind of query has been stored.\n */\n function __PRIVATE_isDocumentQuery(e) {\n return void 0 !== e.documents;\n }\n /** Encodes a DbBundle to a BundleMetadata object. */\n (e.query) ? function __PRIVATE_fromDocumentsTarget(e) {\n return __PRIVATE_hardAssert(1 === e.documents.length), __PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(__PRIVATE_fromQueryPath(e.documents[0])));\n }(e.query) : function __PRIVATE_fromQueryTarget(e) {\n return __PRIVATE_queryToTarget(__PRIVATE_convertQueryTargetToQuery(e));\n }(e.query), new TargetData(r, e.targetId, \"TargetPurposeListen\"\n /* TargetPurpose.Listen */\n , e.lastListenSequenceNumber, t, n, ByteString.fromBase64String(e.resumeToken));\n}\n/** Encodes TargetData into a DbTarget for storage locally. */\n\n\nfunction __PRIVATE_toDbTarget(e, t) {\n var n = __PRIVATE_toDbTimestamp(t.snapshotVersion),\n r = __PRIVATE_toDbTimestamp(t.lastLimboFreeSnapshotVersion);\n\n var i;\n i = __PRIVATE_targetIsDocumentTarget(t.target) ? __PRIVATE_toDocumentsTarget(e.ct, t.target) : __PRIVATE_toQueryTarget(e.ct, t.target).ut; // We can't store the resumeToken as a ByteString in IndexedDb, so we\n // convert it to a base64 string for storage.\n\n var s = t.resumeToken.toBase64(); // lastListenSequenceNumber is always 0 until we do real GC.\n\n return {\n targetId: t.targetId,\n canonicalId: __PRIVATE_canonifyTarget(t.target),\n readTime: n,\n resumeToken: s,\n lastListenSequenceNumber: t.sequenceNumber,\n lastLimboFreeSnapshotVersion: r,\n query: i\n };\n}\n/**\n * Encodes a `BundledQuery` from bundle proto to a Query object.\n *\n * This reconstructs the original query used to build the bundle being loaded,\n * including features exists only in SDKs (for example: limit-to-last).\n */\n\n\nfunction __PRIVATE_fromBundledQuery(e) {\n var t = __PRIVATE_convertQueryTargetToQuery({\n parent: e.parent,\n structuredQuery: e.structuredQuery\n });\n\n return \"LAST\" === e.limitType ? __PRIVATE_queryWithLimit(t, t.limit, \"L\"\n /* LimitType.Last */\n ) : t;\n}\n/** Encodes a NamedQuery proto object to a NamedQuery model object. */\n\n/** Encodes a DbDocumentOverlay object to an Overlay model object. */\n\n\nfunction __PRIVATE_fromDbDocumentOverlay(e, t) {\n return new Overlay(t.largestBatchId, __PRIVATE_fromMutation(e.ct, t.overlayMutation));\n}\n/** Decodes an Overlay model object into a DbDocumentOverlay object. */\n\n/**\n * Returns the DbDocumentOverlayKey corresponding to the given user and\n * document key.\n */\n\n\nfunction __PRIVATE_toDbDocumentOverlayKey(e, t) {\n var n = t.path.lastSegment();\n return [e, __PRIVATE_encodeResourcePath(t.path.popLast()), n];\n}\n\nfunction __PRIVATE_toDbIndexState(e, t, n, r) {\n return {\n indexId: e,\n uid: t,\n sequenceNumber: n,\n readTime: __PRIVATE_toDbTimestamp(r.readTime),\n documentKey: __PRIVATE_encodeResourcePath(r.documentKey.path),\n largestBatchId: r.largestBatchId\n };\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_IndexedDbBundleCache = /*#__PURE__*/function () {\n function __PRIVATE_IndexedDbBundleCache() {\n _classCallCheck(this, __PRIVATE_IndexedDbBundleCache);\n }\n\n _createClass(__PRIVATE_IndexedDbBundleCache, [{\n key: \"getBundleMetadata\",\n value: function getBundleMetadata(e, t) {\n return __PRIVATE_bundlesStore(e).get(t).next(function (e) {\n if (e) return function __PRIVATE_fromDbBundle(e) {\n return {\n id: e.bundleId,\n createTime: __PRIVATE_fromDbTimestamp(e.createTime),\n version: e.version\n };\n }\n /** Encodes a BundleMetadata to a DbBundle. */\n (e);\n });\n }\n }, {\n key: \"saveBundleMetadata\",\n value: function saveBundleMetadata(e, t) {\n return __PRIVATE_bundlesStore(e).put(function __PRIVATE_toDbBundle(e) {\n return {\n bundleId: e.id,\n createTime: __PRIVATE_toDbTimestamp(__PRIVATE_fromVersion(e.createTime)),\n version: e.version\n };\n }\n /** Encodes a DbNamedQuery to a NamedQuery. */\n (t));\n }\n }, {\n key: \"getNamedQuery\",\n value: function getNamedQuery(e, t) {\n return __PRIVATE_namedQueriesStore(e).get(t).next(function (e) {\n if (e) return function __PRIVATE_fromDbNamedQuery(e) {\n return {\n name: e.name,\n query: __PRIVATE_fromBundledQuery(e.bundledQuery),\n readTime: __PRIVATE_fromDbTimestamp(e.readTime)\n };\n }\n /** Encodes a NamedQuery from a bundle proto to a DbNamedQuery. */\n (e);\n });\n }\n }, {\n key: \"saveNamedQuery\",\n value: function saveNamedQuery(e, t) {\n return __PRIVATE_namedQueriesStore(e).put(function __PRIVATE_toDbNamedQuery(e) {\n return {\n name: e.name,\n readTime: __PRIVATE_toDbTimestamp(__PRIVATE_fromVersion(e.readTime)),\n bundledQuery: e.bundledQuery\n };\n }(t));\n }\n }]);\n\n return __PRIVATE_IndexedDbBundleCache;\n}();\n/**\n * Helper to get a typed SimpleDbStore for the bundles object store.\n */\n\n\nfunction __PRIVATE_bundlesStore(e) {\n return __PRIVATE_getStore(e, \"bundles\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the namedQueries object store.\n */\n\n\nfunction __PRIVATE_namedQueriesStore(e) {\n return __PRIVATE_getStore(e, \"namedQueries\");\n}\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Implementation of DocumentOverlayCache using IndexedDb.\n */\n\n\nvar __PRIVATE_IndexedDbDocumentOverlayCache = /*#__PURE__*/function () {\n /**\n * @param serializer - The document serializer.\n * @param userId - The userId for which we are accessing overlays.\n */\n function __PRIVATE_IndexedDbDocumentOverlayCache(e, t) {\n _classCallCheck(this, __PRIVATE_IndexedDbDocumentOverlayCache);\n\n this.serializer = e, this.userId = t;\n }\n\n _createClass(__PRIVATE_IndexedDbDocumentOverlayCache, [{\n key: \"getOverlay\",\n value: function getOverlay(e, t) {\n var _this46 = this;\n\n return __PRIVATE_documentOverlayStore(e).get(__PRIVATE_toDbDocumentOverlayKey(this.userId, t)).next(function (e) {\n return e ? __PRIVATE_fromDbDocumentOverlay(_this46.serializer, e) : null;\n });\n }\n }, {\n key: \"getOverlays\",\n value: function getOverlays(e, t) {\n var _this47 = this;\n\n var n = __PRIVATE_newOverlayMap();\n\n return PersistencePromise.forEach(t, function (t) {\n return _this47.getOverlay(e, t).next(function (e) {\n null !== e && n.set(t, e);\n });\n }).next(function () {\n return n;\n });\n }\n }, {\n key: \"saveOverlays\",\n value: function saveOverlays(e, t, n) {\n var _this48 = this;\n\n var r = [];\n return n.forEach(function (n, i) {\n var s = new Overlay(t, i);\n r.push(_this48.ht(e, s));\n }), PersistencePromise.waitFor(r);\n }\n }, {\n key: \"removeOverlaysForBatchId\",\n value: function removeOverlaysForBatchId(e, t, n) {\n var _this49 = this;\n\n var r = new Set(); // Get the set of unique collection paths.\n\n t.forEach(function (e) {\n return r.add(__PRIVATE_encodeResourcePath(e.getCollectionPath()));\n });\n var i = [];\n return r.forEach(function (t) {\n var r = IDBKeyRange.bound([_this49.userId, t, n], [_this49.userId, t, n + 1],\n /*lowerOpen=*/\n !1,\n /*upperOpen=*/\n !0);\n i.push(__PRIVATE_documentOverlayStore(e).H(\"collectionPathOverlayIndex\", r));\n }), PersistencePromise.waitFor(i);\n }\n }, {\n key: \"getOverlaysForCollection\",\n value: function getOverlaysForCollection(e, t, n) {\n var _this50 = this;\n\n var r = __PRIVATE_newOverlayMap(),\n i = __PRIVATE_encodeResourcePath(t),\n s = IDBKeyRange.bound([this.userId, i, n], [this.userId, i, Number.POSITIVE_INFINITY],\n /*lowerOpen=*/\n !0);\n\n return __PRIVATE_documentOverlayStore(e).W(\"collectionPathOverlayIndex\", s).next(function (e) {\n var _iterator27 = _createForOfIteratorHelper(e),\n _step27;\n\n try {\n for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {\n var _t24 = _step27.value;\n\n var _e43 = __PRIVATE_fromDbDocumentOverlay(_this50.serializer, _t24);\n\n r.set(_e43.getKey(), _e43);\n }\n } catch (err) {\n _iterator27.e(err);\n } finally {\n _iterator27.f();\n }\n\n return r;\n });\n }\n }, {\n key: \"getOverlaysForCollectionGroup\",\n value: function getOverlaysForCollectionGroup(e, t, n, r) {\n var _this51 = this;\n\n var i = __PRIVATE_newOverlayMap();\n\n var s; // We want batch IDs larger than `sinceBatchId`, and so the lower bound\n // is not inclusive.\n\n var o = IDBKeyRange.bound([this.userId, t, n], [this.userId, t, Number.POSITIVE_INFINITY],\n /*lowerOpen=*/\n !0);\n return __PRIVATE_documentOverlayStore(e).Y({\n index: \"collectionGroupOverlayIndex\",\n range: o\n }, function (e, t, n) {\n // We do not want to return partial batch overlays, even if the size\n // of the result set exceeds the given `count` argument. Therefore, we\n // continue to aggregate results even after the result size exceeds\n // `count` if there are more overlays from the `currentBatchId`.\n var o = __PRIVATE_fromDbDocumentOverlay(_this51.serializer, t);\n\n i.size() < r || o.largestBatchId === s ? (i.set(o.getKey(), o), s = o.largestBatchId) : n.done();\n }).next(function () {\n return i;\n });\n }\n }, {\n key: \"ht\",\n value: function ht(e, t) {\n return __PRIVATE_documentOverlayStore(e).put(function __PRIVATE_toDbDocumentOverlay(e, t, n) {\n var _PRIVATE_toDbDocumen = __PRIVATE_toDbDocumentOverlayKey(t, n.mutation.key),\n _PRIVATE_toDbDocumen2 = _slicedToArray(_PRIVATE_toDbDocumen, 3),\n r = _PRIVATE_toDbDocumen2[0],\n i = _PRIVATE_toDbDocumen2[1],\n s = _PRIVATE_toDbDocumen2[2];\n\n return {\n userId: t,\n collectionPath: i,\n documentId: s,\n collectionGroup: n.mutation.key.getCollectionGroup(),\n largestBatchId: n.largestBatchId,\n overlayMutation: toMutation(e.ct, n.mutation)\n };\n }(this.serializer, this.userId, t));\n }\n }], [{\n key: \"lt\",\n value: function lt(e, t) {\n var n = t.uid || \"\";\n return new __PRIVATE_IndexedDbDocumentOverlayCache(e, n);\n }\n }]);\n\n return __PRIVATE_IndexedDbDocumentOverlayCache;\n}();\n/**\n * Helper to get a typed SimpleDbStore for the document overlay object store.\n */\n\n\nfunction __PRIVATE_documentOverlayStore(e) {\n return __PRIVATE_getStore(e, \"documentOverlays\");\n}\n/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Note: This code is copied from the backend. Code that is not used by\n// Firestore was removed.\n\n/** Firestore index value writer. */\n\n\nvar __PRIVATE_FirestoreIndexValueWriter = /*#__PURE__*/function () {\n function __PRIVATE_FirestoreIndexValueWriter() {\n _classCallCheck(this, __PRIVATE_FirestoreIndexValueWriter);\n } // The write methods below short-circuit writing terminators for values\n // containing a (terminating) truncated value.\n // As an example, consider the resulting encoding for:\n // [\"bar\", [2, \"foo\"]] -> (STRING, \"bar\", TERM, ARRAY, NUMBER, 2, STRING, \"foo\", TERM, TERM, TERM)\n // [\"bar\", [2, truncated(\"foo\")]] -> (STRING, \"bar\", TERM, ARRAY, NUMBER, 2, STRING, \"foo\", TRUNC)\n // [\"bar\", truncated([\"foo\"])] -> (STRING, \"bar\", TERM, ARRAY. STRING, \"foo\", TERM, TRUNC)\n\n /** Writes an index value. */\n\n\n _createClass(__PRIVATE_FirestoreIndexValueWriter, [{\n key: \"Pt\",\n value: function Pt(e, t) {\n this.It(e, t), // Write separator to split index values\n // (see go/firestore-storage-format#encodings).\n t.Tt();\n }\n }, {\n key: \"It\",\n value: function It(e, t) {\n if (\"nullValue\" in e) this.Et(t, 5);else if (\"booleanValue\" in e) this.Et(t, 10), t.dt(e.booleanValue ? 1 : 0);else if (\"integerValue\" in e) this.Et(t, 15), t.dt(__PRIVATE_normalizeNumber(e.integerValue));else if (\"doubleValue\" in e) {\n var n = __PRIVATE_normalizeNumber(e.doubleValue);\n\n isNaN(n) ? this.Et(t, 13) : (this.Et(t, 15), __PRIVATE_isNegativeZero(n) ? // -0.0, 0 and 0.0 are all considered the same\n t.dt(0) : t.dt(n));\n } else if (\"timestampValue\" in e) {\n var _n13 = e.timestampValue;\n this.Et(t, 20), \"string\" == typeof _n13 ? t.At(_n13) : (t.At(\"\".concat(_n13.seconds || \"\")), t.dt(_n13.nanos || 0));\n } else if (\"stringValue\" in e) this.Rt(e.stringValue, t), this.Vt(t);else if (\"bytesValue\" in e) this.Et(t, 30), t.ft(__PRIVATE_normalizeByteString(e.bytesValue)), this.Vt(t);else if (\"referenceValue\" in e) this.gt(e.referenceValue, t);else if (\"geoPointValue\" in e) {\n var _n14 = e.geoPointValue;\n this.Et(t, 45), t.dt(_n14.latitude || 0), t.dt(_n14.longitude || 0);\n } else \"mapValue\" in e ? __PRIVATE_isMaxValue(e) ? this.Et(t, Number.MAX_SAFE_INTEGER) : (this.yt(e.mapValue, t), this.Vt(t)) : \"arrayValue\" in e ? (this.wt(e.arrayValue, t), this.Vt(t)) : fail();\n }\n }, {\n key: \"Rt\",\n value: function Rt(e, t) {\n this.Et(t, 25), this.St(e, t);\n }\n }, {\n key: \"St\",\n value: function St(e, t) {\n t.At(e);\n }\n }, {\n key: \"yt\",\n value: function yt(e, t) {\n var n = e.fields || {};\n this.Et(t, 55);\n\n for (var _i9 = 0, _Object$keys = Object.keys(n); _i9 < _Object$keys.length; _i9++) {\n var _e44 = _Object$keys[_i9];\n this.Rt(_e44, t), this.It(n[_e44], t);\n }\n }\n }, {\n key: \"wt\",\n value: function wt(e, t) {\n var n = e.values || [];\n this.Et(t, 50);\n\n var _iterator28 = _createForOfIteratorHelper(n),\n _step28;\n\n try {\n for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {\n var _e45 = _step28.value;\n this.It(_e45, t);\n }\n } catch (err) {\n _iterator28.e(err);\n } finally {\n _iterator28.f();\n }\n }\n }, {\n key: \"gt\",\n value: function gt(e, t) {\n var _this52 = this;\n\n this.Et(t, 37);\n DocumentKey.fromName(e).path.forEach(function (e) {\n _this52.Et(t, 60), _this52.St(e, t);\n });\n }\n }, {\n key: \"Et\",\n value: function Et(e, t) {\n e.dt(t);\n }\n }, {\n key: \"Vt\",\n value: function Vt(e) {\n // While the SDK does not implement truncation, the truncation marker is\n // used to terminate all variable length values (which are strings, bytes,\n // references, arrays and maps).\n e.dt(2);\n }\n }]);\n\n return __PRIVATE_FirestoreIndexValueWriter;\n}();\n\n__PRIVATE_FirestoreIndexValueWriter.bt = new __PRIVATE_FirestoreIndexValueWriter();\n/**\n * Counts the number of zeros in a byte.\n *\n * Visible for testing.\n */\n\nfunction __PRIVATE_numberOfLeadingZerosInByte(e) {\n if (0 === e) return 8;\n var t = 0;\n return e >> 4 == 0 && ( // Test if the first four bits are zero.\n t += 4, e <<= 4), e >> 6 == 0 && ( // Test if the first two (or next two) bits are zero.\n t += 2, e <<= 2), e >> 7 == 0 && ( // Test if the remaining bit is zero.\n t += 1), t;\n}\n/** Counts the number of leading zeros in the given byte array. */\n\n/**\n * Returns the number of bytes required to store \"value\". Leading zero bytes\n * are skipped.\n */\n\n\nfunction __PRIVATE_unsignedNumLength(e) {\n // This is just the number of bytes for the unsigned representation of the number.\n var t = 64 - function __PRIVATE_numberOfLeadingZeros(e) {\n var t = 0;\n\n for (var n = 0; n < 8; ++n) {\n var r = __PRIVATE_numberOfLeadingZerosInByte(255 & e[n]);\n\n if (t += r, 8 !== r) break;\n }\n\n return t;\n }(e);\n\n return Math.ceil(t / 8);\n}\n/**\n * OrderedCodeWriter is a minimal-allocation implementation of the writing\n * behavior defined by the backend.\n *\n * The code is ported from its Java counterpart.\n */\n\n\nvar __PRIVATE_OrderedCodeWriter = /*#__PURE__*/function () {\n function __PRIVATE_OrderedCodeWriter() {\n _classCallCheck(this, __PRIVATE_OrderedCodeWriter);\n\n this.buffer = new Uint8Array(1024), this.position = 0;\n }\n\n _createClass(__PRIVATE_OrderedCodeWriter, [{\n key: \"Dt\",\n value: function Dt(e) {\n var t = e[Symbol.iterator]();\n var n = t.next();\n\n for (; !n.done;) {\n this.Ct(n.value), n = t.next();\n }\n\n this.vt();\n }\n }, {\n key: \"Ft\",\n value: function Ft(e) {\n var t = e[Symbol.iterator]();\n var n = t.next();\n\n for (; !n.done;) {\n this.Mt(n.value), n = t.next();\n }\n\n this.xt();\n }\n /** Writes utf8 bytes into this byte sequence, ascending. */\n\n }, {\n key: \"Ot\",\n value: function Ot(e) {\n var _iterator29 = _createForOfIteratorHelper(e),\n _step29;\n\n try {\n for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {\n var t = _step29.value;\n\n var _e46 = t.charCodeAt(0);\n\n if (_e46 < 128) this.Ct(_e46);else if (_e46 < 2048) this.Ct(960 | _e46 >>> 6), this.Ct(128 | 63 & _e46);else if (t < \"\\uD800\" || \"\\uDBFF\" < t) this.Ct(480 | _e46 >>> 12), this.Ct(128 | 63 & _e46 >>> 6), this.Ct(128 | 63 & _e46);else {\n var _e47 = t.codePointAt(0);\n\n this.Ct(240 | _e47 >>> 18), this.Ct(128 | 63 & _e47 >>> 12), this.Ct(128 | 63 & _e47 >>> 6), this.Ct(128 | 63 & _e47);\n }\n }\n } catch (err) {\n _iterator29.e(err);\n } finally {\n _iterator29.f();\n }\n\n this.vt();\n }\n /** Writes utf8 bytes into this byte sequence, descending */\n\n }, {\n key: \"Nt\",\n value: function Nt(e) {\n var _iterator30 = _createForOfIteratorHelper(e),\n _step30;\n\n try {\n for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {\n var t = _step30.value;\n\n var _e48 = t.charCodeAt(0);\n\n if (_e48 < 128) this.Mt(_e48);else if (_e48 < 2048) this.Mt(960 | _e48 >>> 6), this.Mt(128 | 63 & _e48);else if (t < \"\\uD800\" || \"\\uDBFF\" < t) this.Mt(480 | _e48 >>> 12), this.Mt(128 | 63 & _e48 >>> 6), this.Mt(128 | 63 & _e48);else {\n var _e49 = t.codePointAt(0);\n\n this.Mt(240 | _e49 >>> 18), this.Mt(128 | 63 & _e49 >>> 12), this.Mt(128 | 63 & _e49 >>> 6), this.Mt(128 | 63 & _e49);\n }\n }\n } catch (err) {\n _iterator30.e(err);\n } finally {\n _iterator30.f();\n }\n\n this.xt();\n }\n }, {\n key: \"Bt\",\n value: function Bt(e) {\n // Values are encoded with a single byte length prefix, followed by the\n // actual value in big-endian format with leading 0 bytes dropped.\n var t = this.Lt(e),\n n = __PRIVATE_unsignedNumLength(t);\n\n this.kt(1 + n), this.buffer[this.position++] = 255 & n; // Write the length\n\n for (var _e50 = t.length - n; _e50 < t.length; ++_e50) {\n this.buffer[this.position++] = 255 & t[_e50];\n }\n }\n }, {\n key: \"qt\",\n value: function qt(e) {\n // Values are encoded with a single byte length prefix, followed by the\n // inverted value in big-endian format with leading 0 bytes dropped.\n var t = this.Lt(e),\n n = __PRIVATE_unsignedNumLength(t);\n\n this.kt(1 + n), this.buffer[this.position++] = ~(255 & n); // Write the length\n\n for (var _e51 = t.length - n; _e51 < t.length; ++_e51) {\n this.buffer[this.position++] = ~(255 & t[_e51]);\n }\n }\n /**\n * Writes the \"infinity\" byte sequence that sorts after all other byte\n * sequences written in ascending order.\n */\n\n }, {\n key: \"Qt\",\n value: function Qt() {\n this.Kt(255), this.Kt(255);\n }\n /**\n * Writes the \"infinity\" byte sequence that sorts before all other byte\n * sequences written in descending order.\n */\n\n }, {\n key: \"$t\",\n value: function $t() {\n this.Ut(255), this.Ut(255);\n }\n /**\n * Resets the buffer such that it is the same as when it was newly\n * constructed.\n */\n\n }, {\n key: \"reset\",\n value: function reset() {\n this.position = 0;\n }\n }, {\n key: \"seed\",\n value: function seed(e) {\n this.kt(e.length), this.buffer.set(e, this.position), this.position += e.length;\n }\n /** Makes a copy of the encoded bytes in this buffer. */\n\n }, {\n key: \"Wt\",\n value: function Wt() {\n return this.buffer.slice(0, this.position);\n }\n /**\n * Encodes `val` into an encoding so that the order matches the IEEE 754\n * floating-point comparison results with the following exceptions:\n * -0.0 < 0.0\n * all non-NaN < NaN\n * NaN = NaN\n */\n\n }, {\n key: \"Lt\",\n value: function Lt(e) {\n var t =\n /** Converts a JavaScript number to a byte array (using big endian encoding). */\n function __PRIVATE_doubleToLongBits(e) {\n var t = new DataView(new ArrayBuffer(8));\n return t.setFloat64(0, e,\n /* littleEndian= */\n !1), new Uint8Array(t.buffer);\n }(e),\n n = 0 != (128 & t[0]); // Check if the first bit is set. We use a bit mask since value[0] is\n // encoded as a number from 0 to 255.\n // Revert the two complement to get natural ordering\n\n\n t[0] ^= n ? 255 : 128;\n\n for (var _e52 = 1; _e52 < t.length; ++_e52) {\n t[_e52] ^= n ? 255 : 0;\n }\n\n return t;\n }\n /** Writes a single byte ascending to the buffer. */\n\n }, {\n key: \"Ct\",\n value: function Ct(e) {\n var t = 255 & e;\n 0 === t ? (this.Kt(0), this.Kt(255)) : 255 === t ? (this.Kt(255), this.Kt(0)) : this.Kt(t);\n }\n /** Writes a single byte descending to the buffer. */\n\n }, {\n key: \"Mt\",\n value: function Mt(e) {\n var t = 255 & e;\n 0 === t ? (this.Ut(0), this.Ut(255)) : 255 === t ? (this.Ut(255), this.Ut(0)) : this.Ut(e);\n }\n }, {\n key: \"vt\",\n value: function vt() {\n this.Kt(0), this.Kt(1);\n }\n }, {\n key: \"xt\",\n value: function xt() {\n this.Ut(0), this.Ut(1);\n }\n }, {\n key: \"Kt\",\n value: function Kt(e) {\n this.kt(1), this.buffer[this.position++] = e;\n }\n }, {\n key: \"Ut\",\n value: function Ut(e) {\n this.kt(1), this.buffer[this.position++] = ~e;\n }\n }, {\n key: \"kt\",\n value: function kt(e) {\n var t = e + this.position;\n if (t <= this.buffer.length) return; // Try doubling.\n\n var n = 2 * this.buffer.length; // Still not big enough? Just allocate the right size.\n\n n < t && (n = t); // Create the new buffer.\n\n var r = new Uint8Array(n);\n r.set(this.buffer), // copy old data\n this.buffer = r;\n }\n }]);\n\n return __PRIVATE_OrderedCodeWriter;\n}();\n\nvar __PRIVATE_AscendingIndexByteEncoder = /*#__PURE__*/function () {\n function __PRIVATE_AscendingIndexByteEncoder(e) {\n _classCallCheck(this, __PRIVATE_AscendingIndexByteEncoder);\n\n this.Gt = e;\n }\n\n _createClass(__PRIVATE_AscendingIndexByteEncoder, [{\n key: \"ft\",\n value: function ft(e) {\n this.Gt.Dt(e);\n }\n }, {\n key: \"At\",\n value: function At(e) {\n this.Gt.Ot(e);\n }\n }, {\n key: \"dt\",\n value: function dt(e) {\n this.Gt.Bt(e);\n }\n }, {\n key: \"Tt\",\n value: function Tt() {\n this.Gt.Qt();\n }\n }]);\n\n return __PRIVATE_AscendingIndexByteEncoder;\n}();\n\nvar __PRIVATE_DescendingIndexByteEncoder = /*#__PURE__*/function () {\n function __PRIVATE_DescendingIndexByteEncoder(e) {\n _classCallCheck(this, __PRIVATE_DescendingIndexByteEncoder);\n\n this.Gt = e;\n }\n\n _createClass(__PRIVATE_DescendingIndexByteEncoder, [{\n key: \"ft\",\n value: function ft(e) {\n this.Gt.Ft(e);\n }\n }, {\n key: \"At\",\n value: function At(e) {\n this.Gt.Nt(e);\n }\n }, {\n key: \"dt\",\n value: function dt(e) {\n this.Gt.qt(e);\n }\n }, {\n key: \"Tt\",\n value: function Tt() {\n this.Gt.$t();\n }\n }]);\n\n return __PRIVATE_DescendingIndexByteEncoder;\n}();\n/**\n * Implements `DirectionalIndexByteEncoder` using `OrderedCodeWriter` for the\n * actual encoding.\n */\n\n\nvar __PRIVATE_IndexByteEncoder = /*#__PURE__*/function () {\n function __PRIVATE_IndexByteEncoder() {\n _classCallCheck(this, __PRIVATE_IndexByteEncoder);\n\n this.Gt = new __PRIVATE_OrderedCodeWriter(), this.zt = new __PRIVATE_AscendingIndexByteEncoder(this.Gt), this.jt = new __PRIVATE_DescendingIndexByteEncoder(this.Gt);\n }\n\n _createClass(__PRIVATE_IndexByteEncoder, [{\n key: \"seed\",\n value: function seed(e) {\n this.Gt.seed(e);\n }\n }, {\n key: \"Ht\",\n value: function Ht(e) {\n return 0\n /* IndexKind.ASCENDING */\n === e ? this.zt : this.jt;\n }\n }, {\n key: \"Wt\",\n value: function Wt() {\n return this.Gt.Wt();\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this.Gt.reset();\n }\n }]);\n\n return __PRIVATE_IndexByteEncoder;\n}();\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Represents an index entry saved by the SDK in persisted storage. */\n\n\nvar __PRIVATE_IndexEntry = /*#__PURE__*/function () {\n function __PRIVATE_IndexEntry(e, t, n, r) {\n _classCallCheck(this, __PRIVATE_IndexEntry);\n\n this.indexId = e, this.documentKey = t, this.arrayValue = n, this.directionalValue = r;\n }\n /**\n * Returns an IndexEntry entry that sorts immediately after the current\n * directional value.\n */\n\n\n _createClass(__PRIVATE_IndexEntry, [{\n key: \"Jt\",\n value: function Jt() {\n var e = this.directionalValue.length,\n t = 0 === e || 255 === this.directionalValue[e - 1] ? e + 1 : e,\n n = new Uint8Array(t);\n return n.set(this.directionalValue, 0), t !== e ? n.set([0], this.directionalValue.length) : ++n[n.length - 1], new __PRIVATE_IndexEntry(this.indexId, this.documentKey, this.arrayValue, n);\n }\n }]);\n\n return __PRIVATE_IndexEntry;\n}();\n\nfunction __PRIVATE_indexEntryComparator(e, t) {\n var n = e.indexId - t.indexId;\n return 0 !== n ? n : (n = __PRIVATE_compareByteArrays(e.arrayValue, t.arrayValue), 0 !== n ? n : (n = __PRIVATE_compareByteArrays(e.directionalValue, t.directionalValue), 0 !== n ? n : DocumentKey.comparator(e.documentKey, t.documentKey)));\n}\n\nfunction __PRIVATE_compareByteArrays(e, t) {\n for (var n = 0; n < e.length && n < t.length; ++n) {\n var r = e[n] - t[n];\n if (0 !== r) return r;\n }\n\n return e.length - t.length;\n}\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A light query planner for Firestore.\n *\n * This class matches a `FieldIndex` against a Firestore Query `Target`. It\n * determines whether a given index can be used to serve the specified target.\n *\n * The following table showcases some possible index configurations:\n *\n * Query | Index\n * -----------------------------------------------------------------------------\n * where('a', '==', 'a').where('b', '==', 'b') | a ASC, b DESC\n * where('a', '==', 'a').where('b', '==', 'b') | a ASC\n * where('a', '==', 'a').where('b', '==', 'b') | b DESC\n * where('a', '>=', 'a').orderBy('a') | a ASC\n * where('a', '>=', 'a').orderBy('a', 'desc') | a DESC\n * where('a', '>=', 'a').orderBy('a').orderBy('b') | a ASC, b ASC\n * where('a', '>=', 'a').orderBy('a').orderBy('b') | a ASC\n * where('a', 'array-contains', 'a').orderBy('b') | a CONTAINS, b ASCENDING\n * where('a', 'array-contains', 'a').orderBy('b') | a CONTAINS\n */\n\n\nvar __PRIVATE_TargetIndexMatcher = /*#__PURE__*/function () {\n function __PRIVATE_TargetIndexMatcher(e) {\n _classCallCheck(this, __PRIVATE_TargetIndexMatcher);\n\n // The inequality filters of the target (if it exists).\n // Note: The sort on FieldFilters is not required. Using SortedSet here just to utilize the custom\n // comparator.\n this.Yt = new SortedSet(function (e, t) {\n return FieldPath$1.comparator(e.field, t.field);\n }), this.collectionId = null != e.collectionGroup ? e.collectionGroup : e.path.lastSegment(), this.Zt = e.orderBy, this.Xt = [];\n\n var _iterator31 = _createForOfIteratorHelper(e.filters),\n _step31;\n\n try {\n for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {\n var t = _step31.value;\n var _e53 = t;\n _e53.isInequality() ? this.Yt = this.Yt.add(_e53) : this.Xt.push(_e53);\n }\n } catch (err) {\n _iterator31.e(err);\n } finally {\n _iterator31.f();\n }\n }\n\n _createClass(__PRIVATE_TargetIndexMatcher, [{\n key: \"en\",\n get: function get() {\n return this.Yt.size > 1;\n }\n /**\n * Returns whether the index can be used to serve the TargetIndexMatcher's\n * target.\n *\n * An index is considered capable of serving the target when:\n * - The target uses all index segments for its filters and orderBy clauses.\n * The target can have additional filter and orderBy clauses, but not\n * fewer.\n * - If an ArrayContains/ArrayContainsAnyfilter is used, the index must also\n * have a corresponding `CONTAINS` segment.\n * - All directional index segments can be mapped to the target as a series of\n * equality filters, a single inequality filter and a series of orderBy\n * clauses.\n * - The segments that represent the equality filters may appear out of order.\n * - The optional segment for the inequality filter must appear after all\n * equality segments.\n * - The segments that represent that orderBy clause of the target must appear\n * in order after all equality and inequality segments. Single orderBy\n * clauses cannot be skipped, but a continuous orderBy suffix may be\n * omitted.\n */\n\n }, {\n key: \"tn\",\n value: function tn(e) {\n if (__PRIVATE_hardAssert(e.collectionGroup === this.collectionId), this.en) // Only single inequality is supported for now.\n // TODO(Add support for multiple inequality query): b/298441043\n return !1; // If there is an array element, find a matching filter.\n\n var t = __PRIVATE_fieldIndexGetArraySegment(e);\n\n if (void 0 !== t && !this.nn(t)) return !1;\n\n var n = __PRIVATE_fieldIndexGetDirectionalSegments(e);\n\n var r = new Set(),\n i = 0,\n s = 0; // Process all equalities first. Equalities can appear out of order.\n\n for (; i < n.length && this.nn(n[i]); ++i) {\n r = r.add(n[i].fieldPath.canonicalString());\n } // If we already have processed all segments, all segments are used to serve\n // the equality filters and we do not need to map any segments to the\n // target's inequality and orderBy clauses.\n\n\n if (i === n.length) return !0;\n\n if (this.Yt.size > 0) {\n // Only a single inequality is currently supported. Get the only entry in the set.\n var _e54 = this.Yt.getIterator().getNext(); // If there is an inequality filter and the field was not in one of the\n // equality filters above, the next segment must match both the filter\n // and the first orderBy clause.\n\n\n if (!r.has(_e54.field.canonicalString())) {\n var _t25 = n[i];\n if (!this.rn(_e54, _t25) || !this.sn(this.Zt[s++], _t25)) return !1;\n }\n\n ++i;\n } // All remaining segments need to represent the prefix of the target's\n // orderBy.\n\n\n for (; i < n.length; ++i) {\n var _e55 = n[i];\n if (s >= this.Zt.length || !this.sn(this.Zt[s++], _e55)) return !1;\n }\n\n return !0;\n }\n /**\n * Returns a full matched field index for this target. Currently multiple\n * inequality query is not supported so function returns null.\n */\n\n }, {\n key: \"on\",\n value: function on() {\n if (this.en) return null; // We want to make sure only one segment created for one field. For example,\n // in case like a == 3 and a > 2, Index {a ASCENDING} will only be created\n // once.\n\n var e = new SortedSet(FieldPath$1.comparator);\n var t = [];\n\n var _iterator32 = _createForOfIteratorHelper(this.Xt),\n _step32;\n\n try {\n for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {\n var n = _step32.value;\n if (n.field.isKeyField()) continue;\n if (\"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n === n.op || \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n === n.op) t.push(new IndexSegment(n.field, 2\n /* IndexKind.CONTAINS */\n ));else {\n if (e.has(n.field)) continue;\n e = e.add(n.field), t.push(new IndexSegment(n.field, 0\n /* IndexKind.ASCENDING */\n ));\n }\n } // Note: We do not explicitly check `this.inequalityFilter` but rather rely\n // on the target defining an appropriate \"order by\" to ensure that the\n // required index segment is added. The query engine would reject a query\n // with an inequality filter that lacks the required order-by clause.\n\n } catch (err) {\n _iterator32.e(err);\n } finally {\n _iterator32.f();\n }\n\n var _iterator33 = _createForOfIteratorHelper(this.Zt),\n _step33;\n\n try {\n for (_iterator33.s(); !(_step33 = _iterator33.n()).done;) {\n var _n15 = _step33.value;\n // Stop adding more segments if we see a order-by on key. Typically this\n // is the default implicit order-by which is covered in the index_entry\n // table as a separate column. If it is not the default order-by, the\n // generated index will be missing some segments optimized for order-bys,\n // which is probably fine.\n _n15.field.isKeyField() || e.has(_n15.field) || (e = e.add(_n15.field), t.push(new IndexSegment(_n15.field, \"asc\"\n /* Direction.ASCENDING */\n === _n15.dir ? 0\n /* IndexKind.ASCENDING */\n : 1\n /* IndexKind.DESCENDING */\n )));\n }\n } catch (err) {\n _iterator33.e(err);\n } finally {\n _iterator33.f();\n }\n\n return new FieldIndex(FieldIndex.UNKNOWN_ID, this.collectionId, t, IndexState.empty());\n }\n }, {\n key: \"nn\",\n value: function nn(e) {\n var _iterator34 = _createForOfIteratorHelper(this.Xt),\n _step34;\n\n try {\n for (_iterator34.s(); !(_step34 = _iterator34.n()).done;) {\n var t = _step34.value;\n if (this.rn(t, e)) return !0;\n }\n } catch (err) {\n _iterator34.e(err);\n } finally {\n _iterator34.f();\n }\n\n return !1;\n }\n }, {\n key: \"rn\",\n value: function rn(e, t) {\n if (void 0 === e || !e.field.isEqual(t.fieldPath)) return !1;\n var n = \"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n === e.op || \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n === e.op;\n return 2\n /* IndexKind.CONTAINS */\n === t.kind === n;\n }\n }, {\n key: \"sn\",\n value: function sn(e, t) {\n return !!e.field.isEqual(t.fieldPath) && (0\n /* IndexKind.ASCENDING */\n === t.kind && \"asc\"\n /* Direction.ASCENDING */\n === e.dir || 1\n /* IndexKind.DESCENDING */\n === t.kind && \"desc\"\n /* Direction.DESCENDING */\n === e.dir);\n }\n }]);\n\n return __PRIVATE_TargetIndexMatcher;\n}();\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Provides utility functions that help with boolean logic transformations needed for handling\n * complex filters used in queries.\n */\n\n/**\n * The `in` filter is only a syntactic sugar over a disjunction of equalities. For instance: `a in\n * [1,2,3]` is in fact `a==1 || a==2 || a==3`. This method expands any `in` filter in the given\n * input into a disjunction of equality filters and returns the expanded filter.\n */\n\n\nfunction __PRIVATE_computeInExpansion(e) {\n var t, n;\n\n if (__PRIVATE_hardAssert(e instanceof FieldFilter || e instanceof CompositeFilter), e instanceof FieldFilter) {\n if (e instanceof __PRIVATE_InFilter) {\n var _r11 = (null === (n = null === (t = e.value.arrayValue) || void 0 === t ? void 0 : t.values) || void 0 === n ? void 0 : n.map(function (t) {\n return FieldFilter.create(e.field, \"==\"\n /* Operator.EQUAL */\n , t);\n })) || [];\n\n return CompositeFilter.create(_r11, \"or\"\n /* CompositeOperator.OR */\n );\n } // We have reached other kinds of field filters.\n\n\n return e;\n } // We have a composite filter.\n\n\n var r = e.filters.map(function (e) {\n return __PRIVATE_computeInExpansion(e);\n });\n return CompositeFilter.create(r, e.op);\n}\n/**\n * Given a composite filter, returns the list of terms in its disjunctive normal form.\n *\n *

Each element in the return value is one term of the resulting DNF. For instance: For the\n * input: (A || B) && C, the DNF form is: (A && C) || (B && C), and the return value is a list\n * with two elements: a composite filter that performs (A && C), and a composite filter that\n * performs (B && C).\n *\n * @param filter the composite filter to calculate DNF transform for.\n * @return the terms in the DNF transform.\n */\n\n\nfunction __PRIVATE_getDnfTerms(e) {\n if (0 === e.getFilters().length) return [];\n\n var t = __PRIVATE_computeDistributedNormalForm(__PRIVATE_computeInExpansion(e));\n\n return __PRIVATE_hardAssert(__PRIVATE_isDisjunctiveNormalForm(t)), __PRIVATE_isSingleFieldFilter(t) || __PRIVATE_isFlatConjunction(t) ? [t] : t.getFilters();\n}\n/** Returns true if the given filter is a single field filter. e.g. (a == 10). */\n\n\nfunction __PRIVATE_isSingleFieldFilter(e) {\n return e instanceof FieldFilter;\n}\n/**\n * Returns true if the given filter is the conjunction of one or more field filters. e.g. (a == 10\n * && b == 20)\n */\n\n\nfunction __PRIVATE_isFlatConjunction(e) {\n return e instanceof CompositeFilter && __PRIVATE_compositeFilterIsFlatConjunction(e);\n}\n/**\n * Returns whether or not the given filter is in disjunctive normal form (DNF).\n *\n *

In boolean logic, a disjunctive normal form (DNF) is a canonical normal form of a logical\n * formula consisting of a disjunction of conjunctions; it can also be described as an OR of ANDs.\n *\n *

For more info, visit: https://en.wikipedia.org/wiki/Disjunctive_normal_form\n */\n\n\nfunction __PRIVATE_isDisjunctiveNormalForm(e) {\n return __PRIVATE_isSingleFieldFilter(e) || __PRIVATE_isFlatConjunction(e) ||\n /**\n * Returns true if the given filter is the disjunction of one or more \"flat conjunctions\" and\n * field filters. e.g. (a == 10) || (b==20 && c==30)\n */\n function __PRIVATE_isDisjunctionOfFieldFiltersAndFlatConjunctions(e) {\n if (e instanceof CompositeFilter && __PRIVATE_compositeFilterIsDisjunction(e)) {\n var _iterator35 = _createForOfIteratorHelper(e.getFilters()),\n _step35;\n\n try {\n for (_iterator35.s(); !(_step35 = _iterator35.n()).done;) {\n var t = _step35.value;\n if (!__PRIVATE_isSingleFieldFilter(t) && !__PRIVATE_isFlatConjunction(t)) return !1;\n }\n } catch (err) {\n _iterator35.e(err);\n } finally {\n _iterator35.f();\n }\n\n return !0;\n }\n\n return !1;\n }(e);\n}\n\nfunction __PRIVATE_computeDistributedNormalForm(e) {\n if (__PRIVATE_hardAssert(e instanceof FieldFilter || e instanceof CompositeFilter), e instanceof FieldFilter) return e;\n if (1 === e.filters.length) return __PRIVATE_computeDistributedNormalForm(e.filters[0]); // Compute DNF for each of the subfilters first\n\n var t = e.filters.map(function (e) {\n return __PRIVATE_computeDistributedNormalForm(e);\n });\n var n = CompositeFilter.create(t, e.op);\n return n = __PRIVATE_applyAssociation(n), __PRIVATE_isDisjunctiveNormalForm(n) ? n : (__PRIVATE_hardAssert(n instanceof CompositeFilter), __PRIVATE_hardAssert(__PRIVATE_compositeFilterIsConjunction(n)), __PRIVATE_hardAssert(n.filters.length > 1), n.filters.reduce(function (e, t) {\n return __PRIVATE_applyDistribution(e, t);\n }));\n}\n\nfunction __PRIVATE_applyDistribution(e, t) {\n var n;\n return __PRIVATE_hardAssert(e instanceof FieldFilter || e instanceof CompositeFilter), __PRIVATE_hardAssert(t instanceof FieldFilter || t instanceof CompositeFilter), // FieldFilter FieldFilter\n n = e instanceof FieldFilter ? t instanceof FieldFilter ? function __PRIVATE_applyDistributionFieldFilters(e, t) {\n // Conjunction distribution for two field filters is the conjunction of them.\n return CompositeFilter.create([e, t], \"and\"\n /* CompositeOperator.AND */\n );\n }(e, t) : __PRIVATE_applyDistributionFieldAndCompositeFilters(e, t) : t instanceof FieldFilter ? __PRIVATE_applyDistributionFieldAndCompositeFilters(t, e) : function __PRIVATE_applyDistributionCompositeFilters(e, t) {\n // There are four cases:\n // (A & B) & (C & D) --> (A & B & C & D)\n // (A & B) & (C | D) --> (A & B & C) | (A & B & D)\n // (A | B) & (C & D) --> (C & D & A) | (C & D & B)\n // (A | B) & (C | D) --> (A & C) | (A & D) | (B & C) | (B & D)\n // Case 1 is a merge.\n if (__PRIVATE_hardAssert(e.filters.length > 0 && t.filters.length > 0), __PRIVATE_compositeFilterIsConjunction(e) && __PRIVATE_compositeFilterIsConjunction(t)) return __PRIVATE_compositeFilterWithAddedFilters(e, t.getFilters()); // Case 2,3,4 all have at least one side (lhs or rhs) that is a disjunction. In all three cases\n // we should take each element of the disjunction and distribute it over the other side, and\n // return the disjunction of the distribution results.\n\n var n = __PRIVATE_compositeFilterIsDisjunction(e) ? e : t,\n r = __PRIVATE_compositeFilterIsDisjunction(e) ? t : e,\n i = n.filters.map(function (e) {\n return __PRIVATE_applyDistribution(e, r);\n });\n return CompositeFilter.create(i, \"or\"\n /* CompositeOperator.OR */\n );\n }(e, t), __PRIVATE_applyAssociation(n);\n}\n\nfunction __PRIVATE_applyDistributionFieldAndCompositeFilters(e, t) {\n // There are two cases:\n // A & (B & C) --> (A & B & C)\n // A & (B | C) --> (A & B) | (A & C)\n if (__PRIVATE_compositeFilterIsConjunction(t)) // Case 1\n return __PRIVATE_compositeFilterWithAddedFilters(t, e.getFilters());\n {\n // Case 2\n var n = t.filters.map(function (t) {\n return __PRIVATE_applyDistribution(e, t);\n });\n return CompositeFilter.create(n, \"or\"\n /* CompositeOperator.OR */\n );\n }\n}\n/**\n * Applies the associativity property to the given filter and returns the resulting filter.\n *\n *

    \n *
  • A | (B | C) == (A | B) | C == (A | B | C)\n *
  • A & (B & C) == (A & B) & C == (A & B & C)\n *
\n *\n *

For more info, visit: https://en.wikipedia.org/wiki/Associative_property#Propositional_logic\n */\n\n\nfunction __PRIVATE_applyAssociation(e) {\n if (__PRIVATE_hardAssert(e instanceof FieldFilter || e instanceof CompositeFilter), e instanceof FieldFilter) return e;\n var t = e.getFilters(); // If the composite filter only contains 1 filter, apply associativity to it.\n\n if (1 === t.length) return __PRIVATE_applyAssociation(t[0]); // Associativity applied to a flat composite filter results is itself.\n\n if (__PRIVATE_compositeFilterIsFlat(e)) return e; // First apply associativity to all subfilters. This will in turn recursively apply\n // associativity to all nested composite filters and field filters.\n\n var n = t.map(function (e) {\n return __PRIVATE_applyAssociation(e);\n }),\n r = []; // For composite subfilters that perform the same kind of logical operation as `compositeFilter`\n // take out their filters and add them to `compositeFilter`. For example:\n // compositeFilter = (A | (B | C | D))\n // compositeSubfilter = (B | C | D)\n // Result: (A | B | C | D)\n // Note that the `compositeSubfilter` has been eliminated, and its filters (B, C, D) have been\n // added to the top-level \"compositeFilter\".\n\n return n.forEach(function (t) {\n t instanceof FieldFilter ? r.push(t) : t instanceof CompositeFilter && (t.op === e.op ? // compositeFilter: (A | (B | C))\n // compositeSubfilter: (B | C)\n // Result: (A | B | C)\n r.push.apply(r, _toConsumableArray(t.filters)) : // compositeFilter: (A | (B & C))\n // compositeSubfilter: (B & C)\n // Result: (A | (B & C))\n r.push(t));\n }), 1 === r.length ? r[0] : CompositeFilter.create(r, e.op);\n}\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An in-memory implementation of IndexManager.\n */\n\n\nvar __PRIVATE_MemoryIndexManager = /*#__PURE__*/function () {\n function __PRIVATE_MemoryIndexManager() {\n _classCallCheck(this, __PRIVATE_MemoryIndexManager);\n\n this._n = new __PRIVATE_MemoryCollectionParentIndex();\n }\n\n _createClass(__PRIVATE_MemoryIndexManager, [{\n key: \"addToCollectionParentIndex\",\n value: function addToCollectionParentIndex(e, t) {\n return this._n.add(t), PersistencePromise.resolve();\n }\n }, {\n key: \"getCollectionParents\",\n value: function getCollectionParents(e, t) {\n return PersistencePromise.resolve(this._n.getEntries(t));\n }\n }, {\n key: \"addFieldIndex\",\n value: function addFieldIndex(e, t) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve();\n }\n }, {\n key: \"deleteFieldIndex\",\n value: function deleteFieldIndex(e, t) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve();\n }\n }, {\n key: \"deleteAllFieldIndexes\",\n value: function deleteAllFieldIndexes(e) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve();\n }\n }, {\n key: \"createTargetIndexes\",\n value: function createTargetIndexes(e, t) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve();\n }\n }, {\n key: \"getDocumentsMatchingTarget\",\n value: function getDocumentsMatchingTarget(e, t) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve(null);\n }\n }, {\n key: \"getIndexType\",\n value: function getIndexType(e, t) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve(0\n /* IndexType.NONE */\n );\n }\n }, {\n key: \"getFieldIndexes\",\n value: function getFieldIndexes(e, t) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve([]);\n }\n }, {\n key: \"getNextCollectionGroupToUpdate\",\n value: function getNextCollectionGroupToUpdate(e) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve(null);\n }\n }, {\n key: \"getMinOffset\",\n value: function getMinOffset(e, t) {\n return PersistencePromise.resolve(IndexOffset.min());\n }\n }, {\n key: \"getMinOffsetFromCollectionGroup\",\n value: function getMinOffsetFromCollectionGroup(e, t) {\n return PersistencePromise.resolve(IndexOffset.min());\n }\n }, {\n key: \"updateCollectionGroup\",\n value: function updateCollectionGroup(e, t, n) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve();\n }\n }, {\n key: \"updateIndexEntries\",\n value: function updateIndexEntries(e, t) {\n // Field indices are not supported with memory persistence.\n return PersistencePromise.resolve();\n }\n }]);\n\n return __PRIVATE_MemoryIndexManager;\n}();\n/**\n * Internal implementation of the collection-parent index exposed by MemoryIndexManager.\n * Also used for in-memory caching by IndexedDbIndexManager and initial index population\n * in indexeddb_schema.ts\n */\n\n\nvar __PRIVATE_MemoryCollectionParentIndex = /*#__PURE__*/function () {\n function __PRIVATE_MemoryCollectionParentIndex() {\n _classCallCheck(this, __PRIVATE_MemoryCollectionParentIndex);\n\n this.index = {};\n } // Returns false if the entry already existed.\n\n\n _createClass(__PRIVATE_MemoryCollectionParentIndex, [{\n key: \"add\",\n value: function add(e) {\n var t = e.lastSegment(),\n n = e.popLast(),\n r = this.index[t] || new SortedSet(ResourcePath.comparator),\n i = !r.has(n);\n return this.index[t] = r.add(n), i;\n }\n }, {\n key: \"has\",\n value: function has(e) {\n var t = e.lastSegment(),\n n = e.popLast(),\n r = this.index[t];\n return r && r.has(n);\n }\n }, {\n key: \"getEntries\",\n value: function getEntries(e) {\n return (this.index[e] || new SortedSet(ResourcePath.comparator)).toArray();\n }\n }]);\n\n return __PRIVATE_MemoryCollectionParentIndex;\n}();\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar Te = new Uint8Array(0);\n/**\n * A persisted implementation of IndexManager.\n *\n * PORTING NOTE: Unlike iOS and Android, the Web SDK does not memoize index\n * data as it supports multi-tab access.\n */\n\nvar __PRIVATE_IndexedDbIndexManager = /*#__PURE__*/function () {\n function __PRIVATE_IndexedDbIndexManager(e, t) {\n _classCallCheck(this, __PRIVATE_IndexedDbIndexManager);\n\n this.databaseId = t,\n /**\n * An in-memory copy of the index entries we've already written since the SDK\n * launched. Used to avoid re-writing the same entry repeatedly.\n *\n * This is *NOT* a complete cache of what's in persistence and so can never be\n * used to satisfy reads.\n */\n this.an = new __PRIVATE_MemoryCollectionParentIndex(),\n /**\n * Maps from a target to its equivalent list of sub-targets. Each sub-target\n * contains only one term from the target's disjunctive normal form (DNF).\n */\n this.un = new ObjectMap(function (e) {\n return __PRIVATE_canonifyTarget(e);\n }, function (e, t) {\n return __PRIVATE_targetEquals(e, t);\n }), this.uid = e.uid || \"\";\n }\n /**\n * Adds a new entry to the collection parent index.\n *\n * Repeated calls for the same collectionPath should be avoided within a\n * transaction as IndexedDbIndexManager only caches writes once a transaction\n * has been committed.\n */\n\n\n _createClass(__PRIVATE_IndexedDbIndexManager, [{\n key: \"addToCollectionParentIndex\",\n value: function addToCollectionParentIndex(e, t) {\n var _this53 = this;\n\n if (!this.an.has(t)) {\n var n = t.lastSegment(),\n r = t.popLast();\n e.addOnCommittedListener(function () {\n // Add the collection to the in memory cache only if the transaction was\n // successfully committed.\n _this53.an.add(t);\n });\n var i = {\n collectionId: n,\n parent: __PRIVATE_encodeResourcePath(r)\n };\n return __PRIVATE_collectionParentsStore(e).put(i);\n }\n\n return PersistencePromise.resolve();\n }\n }, {\n key: \"getCollectionParents\",\n value: function getCollectionParents(e, t) {\n var n = [],\n r = IDBKeyRange.bound([t, \"\"], [__PRIVATE_immediateSuccessor(t), \"\"],\n /*lowerOpen=*/\n !1,\n /*upperOpen=*/\n !0);\n return __PRIVATE_collectionParentsStore(e).W(r).next(function (e) {\n var _iterator36 = _createForOfIteratorHelper(e),\n _step36;\n\n try {\n for (_iterator36.s(); !(_step36 = _iterator36.n()).done;) {\n var _r12 = _step36.value;\n // This collectionId guard shouldn't be necessary (and isn't as long\n // as we're running in a real browser), but there's a bug in\n // indexeddbshim that breaks our range in our tests running in node:\n // https://github.com/axemclion/IndexedDBShim/issues/334\n if (_r12.collectionId !== t) break;\n n.push(__PRIVATE_decodeResourcePath(_r12.parent));\n }\n } catch (err) {\n _iterator36.e(err);\n } finally {\n _iterator36.f();\n }\n\n return n;\n });\n }\n }, {\n key: \"addFieldIndex\",\n value: function addFieldIndex(e, t) {\n var _this54 = this;\n\n // TODO(indexing): Verify that the auto-incrementing index ID works in\n // Safari & Firefox.\n var n = __PRIVATE_indexConfigurationStore(e),\n r = function __PRIVATE_toDbIndexConfiguration(e) {\n return {\n indexId: e.indexId,\n collectionGroup: e.collectionGroup,\n fields: e.fields.map(function (e) {\n return [e.fieldPath.canonicalString(), e.kind];\n })\n };\n }(t);\n\n delete r.indexId; // `indexId` is auto-populated by IndexedDb\n\n var i = n.add(r);\n\n if (t.indexState) {\n var _n16 = __PRIVATE_indexStateStore(e);\n\n return i.next(function (e) {\n _n16.put(__PRIVATE_toDbIndexState(e, _this54.uid, t.indexState.sequenceNumber, t.indexState.offset));\n });\n }\n\n return i.next();\n }\n }, {\n key: \"deleteFieldIndex\",\n value: function deleteFieldIndex(e, t) {\n var n = __PRIVATE_indexConfigurationStore(e),\n r = __PRIVATE_indexStateStore(e),\n i = __PRIVATE_indexEntriesStore(e);\n\n return n.delete(t.indexId).next(function () {\n return r.delete(IDBKeyRange.bound([t.indexId], [t.indexId + 1],\n /*lowerOpen=*/\n !1,\n /*upperOpen=*/\n !0));\n }).next(function () {\n return i.delete(IDBKeyRange.bound([t.indexId], [t.indexId + 1],\n /*lowerOpen=*/\n !1,\n /*upperOpen=*/\n !0));\n });\n }\n }, {\n key: \"deleteAllFieldIndexes\",\n value: function deleteAllFieldIndexes(e) {\n var t = __PRIVATE_indexConfigurationStore(e),\n n = __PRIVATE_indexEntriesStore(e),\n r = __PRIVATE_indexStateStore(e);\n\n return t.H().next(function () {\n return n.H();\n }).next(function () {\n return r.H();\n });\n }\n }, {\n key: \"createTargetIndexes\",\n value: function createTargetIndexes(e, t) {\n var _this55 = this;\n\n return PersistencePromise.forEach(this.cn(t), function (t) {\n return _this55.getIndexType(e, t).next(function (n) {\n if (0\n /* IndexType.NONE */\n === n || 1\n /* IndexType.PARTIAL */\n === n) {\n var _n17 = new __PRIVATE_TargetIndexMatcher(t).on();\n\n if (null != _n17) return _this55.addFieldIndex(e, _n17);\n }\n });\n });\n }\n }, {\n key: \"getDocumentsMatchingTarget\",\n value: function getDocumentsMatchingTarget(e, t) {\n var _this56 = this;\n\n var n = __PRIVATE_indexEntriesStore(e);\n\n var r = !0;\n var i = new Map();\n return PersistencePromise.forEach(this.cn(t), function (t) {\n return _this56.ln(e, t).next(function (e) {\n r && (r = !!e), i.set(t, e);\n });\n }).next(function () {\n if (r) {\n var _e56 = __PRIVATE_documentKeySet();\n\n var _r13 = [];\n return PersistencePromise.forEach(i, function (i, s) {\n __PRIVATE_logDebug(\"IndexedDbIndexManager\", \"Using index \".concat(function __PRIVATE_fieldIndexToString(e) {\n return \"id=\".concat(e.indexId, \"|cg=\").concat(e.collectionGroup, \"|f=\").concat(e.fields.map(function (e) {\n return \"\".concat(e.fieldPath, \":\").concat(e.kind);\n }).join(\",\"));\n }(i), \" to execute \").concat(__PRIVATE_canonifyTarget(t)));\n\n var o = function __PRIVATE_targetGetArrayValues(e, t) {\n var n = __PRIVATE_fieldIndexGetArraySegment(t);\n\n if (void 0 === n) return null;\n\n var _iterator37 = _createForOfIteratorHelper(__PRIVATE_targetGetFieldFiltersForPath(e, n.fieldPath)),\n _step37;\n\n try {\n for (_iterator37.s(); !(_step37 = _iterator37.n()).done;) {\n var _t26 = _step37.value;\n\n switch (_t26.op) {\n case \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n :\n return _t26.value.arrayValue.values || [];\n\n case \"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n :\n return [_t26.value];\n // Remaining filters are not array filters.\n }\n }\n } catch (err) {\n _iterator37.e(err);\n } finally {\n _iterator37.f();\n }\n\n return null;\n }\n /**\n * Returns the list of values that are used in != or NOT_IN filters. Returns\n * `null` if there are no such filters.\n */\n (s, i),\n _ = function __PRIVATE_targetGetNotInValues(e, t) {\n var n = new Map();\n\n var _iterator38 = _createForOfIteratorHelper(__PRIVATE_fieldIndexGetDirectionalSegments(t)),\n _step38;\n\n try {\n for (_iterator38.s(); !(_step38 = _iterator38.n()).done;) {\n var _r14 = _step38.value;\n\n var _iterator39 = _createForOfIteratorHelper(__PRIVATE_targetGetFieldFiltersForPath(e, _r14.fieldPath)),\n _step39;\n\n try {\n for (_iterator39.s(); !(_step39 = _iterator39.n()).done;) {\n var _t27 = _step39.value;\n\n switch (_t27.op) {\n case \"==\"\n /* Operator.EQUAL */\n :\n case \"in\"\n /* Operator.IN */\n :\n // Encode equality prefix, which is encoded in the index value before\n // the inequality (e.g. `a == 'a' && b != 'b'` is encoded to\n // `value != 'ab'`).\n n.set(_r14.fieldPath.canonicalString(), _t27.value);\n break;\n\n case \"not-in\"\n /* Operator.NOT_IN */\n :\n case \"!=\"\n /* Operator.NOT_EQUAL */\n :\n // NotIn/NotEqual is always a suffix. There cannot be any remaining\n // segments and hence we can return early here.\n return n.set(_r14.fieldPath.canonicalString(), _t27.value), Array.from(n.values());\n // Remaining filters cannot be used as notIn bounds.\n }\n }\n } catch (err) {\n _iterator39.e(err);\n } finally {\n _iterator39.f();\n }\n }\n } catch (err) {\n _iterator38.e(err);\n } finally {\n _iterator38.f();\n }\n\n return null;\n }\n /**\n * Returns a lower bound of field values that can be used as a starting point to\n * scan the index defined by `fieldIndex`. Returns `MIN_VALUE` if no lower bound\n * exists.\n */\n (s, i),\n a = function __PRIVATE_targetGetLowerBound(e, t) {\n var n = [];\n var r = !0; // For each segment, retrieve a lower bound if there is a suitable filter or\n // startAt.\n\n var _iterator40 = _createForOfIteratorHelper(__PRIVATE_fieldIndexGetDirectionalSegments(t)),\n _step40;\n\n try {\n for (_iterator40.s(); !(_step40 = _iterator40.n()).done;) {\n var _i10 = _step40.value;\n\n var _t28 = 0\n /* IndexKind.ASCENDING */\n === _i10.kind ? __PRIVATE_targetGetAscendingBound(e, _i10.fieldPath, e.startAt) : __PRIVATE_targetGetDescendingBound(e, _i10.fieldPath, e.startAt);\n\n n.push(_t28.value), r && (r = _t28.inclusive);\n }\n } catch (err) {\n _iterator40.e(err);\n } finally {\n _iterator40.f();\n }\n\n return new Bound(n, r);\n }\n /**\n * Returns an upper bound of field values that can be used as an ending point\n * when scanning the index defined by `fieldIndex`. Returns `MAX_VALUE` if no\n * upper bound exists.\n */\n (s, i),\n u = function __PRIVATE_targetGetUpperBound(e, t) {\n var n = [];\n var r = !0; // For each segment, retrieve an upper bound if there is a suitable filter or\n // endAt.\n\n var _iterator41 = _createForOfIteratorHelper(__PRIVATE_fieldIndexGetDirectionalSegments(t)),\n _step41;\n\n try {\n for (_iterator41.s(); !(_step41 = _iterator41.n()).done;) {\n var _i11 = _step41.value;\n\n var _t29 = 0\n /* IndexKind.ASCENDING */\n === _i11.kind ? __PRIVATE_targetGetDescendingBound(e, _i11.fieldPath, e.endAt) : __PRIVATE_targetGetAscendingBound(e, _i11.fieldPath, e.endAt);\n\n n.push(_t29.value), r && (r = _t29.inclusive);\n }\n } catch (err) {\n _iterator41.e(err);\n } finally {\n _iterator41.f();\n }\n\n return new Bound(n, r);\n }(s, i),\n c = _this56.hn(i, s, a),\n l = _this56.hn(i, s, u),\n h = _this56.Pn(i, s, _),\n P = _this56.In(i.indexId, o, c, a.inclusive, l, u.inclusive, h);\n\n return PersistencePromise.forEach(P, function (i) {\n return n.j(i, t.limit).next(function (t) {\n t.forEach(function (t) {\n var n = DocumentKey.fromSegments(t.documentKey);\n _e56.has(n) || (_e56 = _e56.add(n), _r13.push(n));\n });\n });\n });\n }).next(function () {\n return _r13;\n });\n }\n\n return PersistencePromise.resolve(null);\n });\n }\n }, {\n key: \"cn\",\n value: function cn(e) {\n var t = this.un.get(e);\n if (t) return t;\n if (0 === e.filters.length) t = [e];else {\n t = __PRIVATE_getDnfTerms(CompositeFilter.create(e.filters, \"and\"\n /* CompositeOperator.AND */\n )).map(function (t) {\n return __PRIVATE_newTarget(e.path, e.collectionGroup, e.orderBy, t.getFilters(), e.limit, e.startAt, e.endAt);\n });\n }\n return this.un.set(e, t), t;\n }\n /**\n * Constructs a key range query on `DbIndexEntryStore` that unions all\n * bounds.\n */\n\n }, {\n key: \"In\",\n value: function In(e, t, n, r, i, s, o) {\n var _this57 = this;\n\n // The number of total index scans we union together. This is similar to a\n // distributed normal form, but adapted for array values. We create a single\n // index range per value in an ARRAY_CONTAINS or ARRAY_CONTAINS_ANY filter\n // combined with the values from the query bounds.\n var _ = (null != t ? t.length : 1) * Math.max(n.length, i.length),\n a = _ / (null != t ? t.length : 1),\n u = [];\n\n var _loop5 = function _loop5(c) {\n var _ = t ? _this57.Tn(t[c / a]) : Te,\n l = _this57.En(e, _, n[c % a], r),\n h = _this57.dn(e, _, i[c % a], s),\n P = o.map(function (t) {\n return _this57.En(e, _, t,\n /* inclusive= */\n !0);\n });\n\n u.push.apply(u, _toConsumableArray(_this57.createRange(l, h, P)));\n };\n\n for (var c = 0; c < _; ++c) {\n _loop5(c);\n }\n\n return u;\n }\n /** Generates the lower bound for `arrayValue` and `directionalValue`. */\n\n }, {\n key: \"En\",\n value: function En(e, t, n, r) {\n var i = new __PRIVATE_IndexEntry(e, DocumentKey.empty(), t, n);\n return r ? i : i.Jt();\n }\n /** Generates the upper bound for `arrayValue` and `directionalValue`. */\n\n }, {\n key: \"dn\",\n value: function dn(e, t, n, r) {\n var i = new __PRIVATE_IndexEntry(e, DocumentKey.empty(), t, n);\n return r ? i.Jt() : i;\n }\n }, {\n key: \"ln\",\n value: function ln(e, t) {\n var n = new __PRIVATE_TargetIndexMatcher(t),\n r = null != t.collectionGroup ? t.collectionGroup : t.path.lastSegment();\n return this.getFieldIndexes(e, r).next(function (e) {\n // Return the index with the most number of segments.\n var t = null;\n\n var _iterator42 = _createForOfIteratorHelper(e),\n _step42;\n\n try {\n for (_iterator42.s(); !(_step42 = _iterator42.n()).done;) {\n var _r15 = _step42.value;\n n.tn(_r15) && (!t || _r15.fields.length > t.fields.length) && (t = _r15);\n }\n } catch (err) {\n _iterator42.e(err);\n } finally {\n _iterator42.f();\n }\n\n return t;\n });\n }\n }, {\n key: \"getIndexType\",\n value: function getIndexType(e, t) {\n var _this58 = this;\n\n var n = 2\n /* IndexType.FULL */\n ;\n var r = this.cn(t);\n return PersistencePromise.forEach(r, function (t) {\n return _this58.ln(e, t).next(function (e) {\n e ? 0\n /* IndexType.NONE */\n !== n && e.fields.length < function __PRIVATE_targetGetSegmentCount(e) {\n var t = new SortedSet(FieldPath$1.comparator),\n n = !1;\n\n var _iterator43 = _createForOfIteratorHelper(e.filters),\n _step43;\n\n try {\n for (_iterator43.s(); !(_step43 = _iterator43.n()).done;) {\n var _r16 = _step43.value;\n\n var _iterator45 = _createForOfIteratorHelper(_r16.getFlattenedFilters()),\n _step45;\n\n try {\n for (_iterator45.s(); !(_step45 = _iterator45.n()).done;) {\n var _e57 = _step45.value;\n // __name__ is not an explicit segment of any index, so we don't need to\n // count it.\n _e57.field.isKeyField() || ( // ARRAY_CONTAINS or ARRAY_CONTAINS_ANY filters must be counted separately.\n // For instance, it is possible to have an index for \"a ARRAY a ASC\". Even\n // though these are on the same field, they should be counted as two\n // separate segments in an index.\n \"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n === _e57.op || \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n === _e57.op ? n = !0 : t = t.add(_e57.field));\n }\n } catch (err) {\n _iterator45.e(err);\n } finally {\n _iterator45.f();\n }\n }\n } catch (err) {\n _iterator43.e(err);\n } finally {\n _iterator43.f();\n }\n\n var _iterator44 = _createForOfIteratorHelper(e.orderBy),\n _step44;\n\n try {\n for (_iterator44.s(); !(_step44 = _iterator44.n()).done;) {\n var _n18 = _step44.value;\n // __name__ is not an explicit segment of any index, so we don't need to\n // count it.\n _n18.field.isKeyField() || (t = t.add(_n18.field));\n }\n } catch (err) {\n _iterator44.e(err);\n } finally {\n _iterator44.f();\n }\n\n return t.size + (n ? 1 : 0);\n }(t) && (n = 1\n /* IndexType.PARTIAL */\n ) : n = 0\n /* IndexType.NONE */\n ;\n });\n }).next(function () {\n return (// OR queries have more than one sub-target (one sub-target per DNF term). We currently consider\n // OR queries that have a `limit` to have a partial index. For such queries we perform sorting\n // and apply the limit in memory as a post-processing step.\n function __PRIVATE_targetHasLimit(e) {\n return null !== e.limit;\n }(t) && r.length > 1 && 2\n /* IndexType.FULL */\n === n ? 1\n /* IndexType.PARTIAL */\n : n\n );\n });\n }\n /**\n * Returns the byte encoded form of the directional values in the field index.\n * Returns `null` if the document does not have all fields specified in the\n * index.\n */\n\n }, {\n key: \"An\",\n value: function An(e, t) {\n var n = new __PRIVATE_IndexByteEncoder();\n\n var _iterator46 = _createForOfIteratorHelper(__PRIVATE_fieldIndexGetDirectionalSegments(e)),\n _step46;\n\n try {\n for (_iterator46.s(); !(_step46 = _iterator46.n()).done;) {\n var r = _step46.value;\n\n var _e58 = t.data.field(r.fieldPath);\n\n if (null == _e58) return null;\n var i = n.Ht(r.kind);\n\n __PRIVATE_FirestoreIndexValueWriter.bt.Pt(_e58, i);\n }\n } catch (err) {\n _iterator46.e(err);\n } finally {\n _iterator46.f();\n }\n\n return n.Wt();\n }\n /** Encodes a single value to the ascending index format. */\n\n }, {\n key: \"Tn\",\n value: function Tn(e) {\n var t = new __PRIVATE_IndexByteEncoder();\n return __PRIVATE_FirestoreIndexValueWriter.bt.Pt(e, t.Ht(0\n /* IndexKind.ASCENDING */\n )), t.Wt();\n }\n /**\n * Returns an encoded form of the document key that sorts based on the key\n * ordering of the field index.\n */\n\n }, {\n key: \"Rn\",\n value: function Rn(e, t) {\n var n = new __PRIVATE_IndexByteEncoder();\n return __PRIVATE_FirestoreIndexValueWriter.bt.Pt(__PRIVATE_refValue(this.databaseId, t), n.Ht(function __PRIVATE_fieldIndexGetKeyOrder(e) {\n var t = __PRIVATE_fieldIndexGetDirectionalSegments(e);\n\n return 0 === t.length ? 0\n /* IndexKind.ASCENDING */\n : t[t.length - 1].kind;\n }(e))), n.Wt();\n }\n /**\n * Encodes the given field values according to the specification in `target`.\n * For IN queries, a list of possible values is returned.\n */\n\n }, {\n key: \"Pn\",\n value: function Pn(e, t, n) {\n if (null === n) return [];\n var r = [];\n r.push(new __PRIVATE_IndexByteEncoder());\n var i = 0;\n\n var _iterator47 = _createForOfIteratorHelper(__PRIVATE_fieldIndexGetDirectionalSegments(e)),\n _step47;\n\n try {\n for (_iterator47.s(); !(_step47 = _iterator47.n()).done;) {\n var s = _step47.value;\n var _e59 = n[i++];\n\n var _iterator48 = _createForOfIteratorHelper(r),\n _step48;\n\n try {\n for (_iterator48.s(); !(_step48 = _iterator48.n()).done;) {\n var _n19 = _step48.value;\n if (this.Vn(t, s.fieldPath) && isArray(_e59)) r = this.mn(r, s, _e59);else {\n var _t30 = _n19.Ht(s.kind);\n\n __PRIVATE_FirestoreIndexValueWriter.bt.Pt(_e59, _t30);\n }\n }\n } catch (err) {\n _iterator48.e(err);\n } finally {\n _iterator48.f();\n }\n }\n } catch (err) {\n _iterator47.e(err);\n } finally {\n _iterator47.f();\n }\n\n return this.fn(r);\n }\n /**\n * Encodes the given bounds according to the specification in `target`. For IN\n * queries, a list of possible values is returned.\n */\n\n }, {\n key: \"hn\",\n value: function hn(e, t, n) {\n return this.Pn(e, t, n.position);\n }\n /** Returns the byte representation for the provided encoders. */\n\n }, {\n key: \"fn\",\n value: function fn(e) {\n var t = [];\n\n for (var n = 0; n < e.length; ++n) {\n t[n] = e[n].Wt();\n }\n\n return t;\n }\n /**\n * Creates a separate encoder for each element of an array.\n *\n * The method appends each value to all existing encoders (e.g. filter(\"a\",\n * \"==\", \"a1\").filter(\"b\", \"in\", [\"b1\", \"b2\"]) becomes [\"a1,b1\", \"a1,b2\"]). A\n * list of new encoders is returned.\n */\n\n }, {\n key: \"mn\",\n value: function mn(e, t, n) {\n var r = _toConsumableArray(e),\n i = [];\n\n var _iterator49 = _createForOfIteratorHelper(n.arrayValue.values || []),\n _step49;\n\n try {\n for (_iterator49.s(); !(_step49 = _iterator49.n()).done;) {\n var _e60 = _step49.value;\n\n var _iterator50 = _createForOfIteratorHelper(r),\n _step50;\n\n try {\n for (_iterator50.s(); !(_step50 = _iterator50.n()).done;) {\n var _n20 = _step50.value;\n\n var _r17 = new __PRIVATE_IndexByteEncoder();\n\n _r17.seed(_n20.Wt()), __PRIVATE_FirestoreIndexValueWriter.bt.Pt(_e60, _r17.Ht(t.kind)), i.push(_r17);\n }\n } catch (err) {\n _iterator50.e(err);\n } finally {\n _iterator50.f();\n }\n }\n } catch (err) {\n _iterator49.e(err);\n } finally {\n _iterator49.f();\n }\n\n return i;\n }\n }, {\n key: \"Vn\",\n value: function Vn(e, t) {\n return !!e.filters.find(function (e) {\n return e instanceof FieldFilter && e.field.isEqual(t) && (\"in\"\n /* Operator.IN */\n === e.op || \"not-in\"\n /* Operator.NOT_IN */\n === e.op);\n });\n }\n }, {\n key: \"getFieldIndexes\",\n value: function getFieldIndexes(e, t) {\n var _this59 = this;\n\n var n = __PRIVATE_indexConfigurationStore(e),\n r = __PRIVATE_indexStateStore(e);\n\n return (t ? n.W(\"collectionGroupIndex\", IDBKeyRange.bound(t, t)) : n.W()).next(function (e) {\n var t = [];\n return PersistencePromise.forEach(e, function (e) {\n return r.get([e.indexId, _this59.uid]).next(function (n) {\n t.push(function __PRIVATE_fromDbIndexConfiguration(e, t) {\n var n = t ? new IndexState(t.sequenceNumber, new IndexOffset(__PRIVATE_fromDbTimestamp(t.readTime), new DocumentKey(__PRIVATE_decodeResourcePath(t.documentKey)), t.largestBatchId)) : IndexState.empty(),\n r = e.fields.map(function (_ref3) {\n var _ref4 = _slicedToArray(_ref3, 2),\n e = _ref4[0],\n t = _ref4[1];\n\n return new IndexSegment(FieldPath$1.fromServerFormat(e), t);\n });\n return new FieldIndex(e.indexId, e.collectionGroup, r, n);\n }(e, n));\n });\n }).next(function () {\n return t;\n });\n });\n }\n }, {\n key: \"getNextCollectionGroupToUpdate\",\n value: function getNextCollectionGroupToUpdate(e) {\n return this.getFieldIndexes(e).next(function (e) {\n return 0 === e.length ? null : (e.sort(function (e, t) {\n var n = e.indexState.sequenceNumber - t.indexState.sequenceNumber;\n return 0 !== n ? n : __PRIVATE_primitiveComparator(e.collectionGroup, t.collectionGroup);\n }), e[0].collectionGroup);\n });\n }\n }, {\n key: \"updateCollectionGroup\",\n value: function updateCollectionGroup(e, t, n) {\n var _this60 = this;\n\n var r = __PRIVATE_indexConfigurationStore(e),\n i = __PRIVATE_indexStateStore(e);\n\n return this.gn(e).next(function (e) {\n return r.W(\"collectionGroupIndex\", IDBKeyRange.bound(t, t)).next(function (t) {\n return PersistencePromise.forEach(t, function (t) {\n return i.put(__PRIVATE_toDbIndexState(t.indexId, _this60.uid, e, n));\n });\n });\n });\n }\n }, {\n key: \"updateIndexEntries\",\n value: function updateIndexEntries(e, t) {\n var _this61 = this;\n\n // Porting Note: `getFieldIndexes()` on Web does not cache index lookups as\n // it could be used across different IndexedDB transactions. As any cached\n // data might be invalidated by other multi-tab clients, we can only trust\n // data within a single IndexedDB transaction. We therefore add a cache\n // here.\n var n = new Map();\n return PersistencePromise.forEach(t, function (t, r) {\n var i = n.get(t.collectionGroup);\n return (i ? PersistencePromise.resolve(i) : _this61.getFieldIndexes(e, t.collectionGroup)).next(function (i) {\n return n.set(t.collectionGroup, i), PersistencePromise.forEach(i, function (n) {\n return _this61.pn(e, t, n).next(function (t) {\n var i = _this61.yn(r, n);\n\n return t.isEqual(i) ? PersistencePromise.resolve() : _this61.wn(e, r, n, t, i);\n });\n });\n });\n });\n }\n }, {\n key: \"Sn\",\n value: function Sn(e, t, n, r) {\n return __PRIVATE_indexEntriesStore(e).put({\n indexId: r.indexId,\n uid: this.uid,\n arrayValue: r.arrayValue,\n directionalValue: r.directionalValue,\n orderedDocumentKey: this.Rn(n, t.key),\n documentKey: t.key.path.toArray()\n });\n }\n }, {\n key: \"bn\",\n value: function bn(e, t, n, r) {\n return __PRIVATE_indexEntriesStore(e).delete([r.indexId, this.uid, r.arrayValue, r.directionalValue, this.Rn(n, t.key), t.key.path.toArray()]);\n }\n }, {\n key: \"pn\",\n value: function pn(e, t, n) {\n var r = __PRIVATE_indexEntriesStore(e);\n\n var i = new SortedSet(__PRIVATE_indexEntryComparator);\n return r.Y({\n index: \"documentKeyIndex\",\n range: IDBKeyRange.only([n.indexId, this.uid, this.Rn(n, t)])\n }, function (e, r) {\n i = i.add(new __PRIVATE_IndexEntry(n.indexId, t, r.arrayValue, r.directionalValue));\n }).next(function () {\n return i;\n });\n }\n /** Creates the index entries for the given document. */\n\n }, {\n key: \"yn\",\n value: function yn(e, t) {\n var n = new SortedSet(__PRIVATE_indexEntryComparator);\n var r = this.An(t, e);\n if (null == r) return n;\n\n var i = __PRIVATE_fieldIndexGetArraySegment(t);\n\n if (null != i) {\n var s = e.data.field(i.fieldPath);\n\n if (isArray(s)) {\n var _iterator51 = _createForOfIteratorHelper(s.arrayValue.values || []),\n _step51;\n\n try {\n for (_iterator51.s(); !(_step51 = _iterator51.n()).done;) {\n var _i12 = _step51.value;\n n = n.add(new __PRIVATE_IndexEntry(t.indexId, e.key, this.Tn(_i12), r));\n }\n } catch (err) {\n _iterator51.e(err);\n } finally {\n _iterator51.f();\n }\n }\n } else n = n.add(new __PRIVATE_IndexEntry(t.indexId, e.key, Te, r));\n\n return n;\n }\n /**\n * Updates the index entries for the provided document by deleting entries\n * that are no longer referenced in `newEntries` and adding all newly added\n * entries.\n */\n\n }, {\n key: \"wn\",\n value: function wn(e, t, n, r, i) {\n var _this62 = this;\n\n __PRIVATE_logDebug(\"IndexedDbIndexManager\", \"Updating index entries for document '%s'\", t.key);\n\n var s = [];\n return function __PRIVATE_diffSortedSets(e, t, n, r, i) {\n var s = e.getIterator(),\n o = t.getIterator();\n\n var _ = __PRIVATE_advanceIterator(s),\n a = __PRIVATE_advanceIterator(o); // Walk through the two sets at the same time, using the ordering defined by\n // `comparator`.\n\n\n for (; _ || a;) {\n var _e61 = !1,\n _t31 = !1;\n\n if (_ && a) {\n var _r18 = n(_, a);\n\n _r18 < 0 ? // The element was removed if the next element in our ordered\n // walkthrough is only in `before`.\n _t31 = !0 : _r18 > 0 && ( // The element was added if the next element in our ordered walkthrough\n // is only in `after`.\n _e61 = !0);\n } else null != _ ? _t31 = !0 : _e61 = !0;\n\n _e61 ? (r(a), a = __PRIVATE_advanceIterator(o)) : _t31 ? (i(_), _ = __PRIVATE_advanceIterator(s)) : (_ = __PRIVATE_advanceIterator(s), a = __PRIVATE_advanceIterator(o));\n }\n }(r, i, __PRIVATE_indexEntryComparator,\n /* onAdd= */\n function (r) {\n s.push(_this62.Sn(e, t, n, r));\n },\n /* onRemove= */\n function (r) {\n s.push(_this62.bn(e, t, n, r));\n }), PersistencePromise.waitFor(s);\n }\n }, {\n key: \"gn\",\n value: function gn(e) {\n var t = 1;\n return __PRIVATE_indexStateStore(e).Y({\n index: \"sequenceNumberIndex\",\n reverse: !0,\n range: IDBKeyRange.upperBound([this.uid, Number.MAX_SAFE_INTEGER])\n }, function (e, n, r) {\n r.done(), t = n.sequenceNumber + 1;\n }).next(function () {\n return t;\n });\n }\n /**\n * Returns a new set of IDB ranges that splits the existing range and excludes\n * any values that match the `notInValue` from these ranges. As an example,\n * '[foo > 2 && foo != 3]` becomes `[foo > 2 && < 3, foo > 3]`.\n */\n\n }, {\n key: \"createRange\",\n value: function createRange(e, t, n) {\n // The notIn values need to be sorted and unique so that we can return a\n // sorted set of non-overlapping ranges.\n n = n.sort(function (e, t) {\n return __PRIVATE_indexEntryComparator(e, t);\n }).filter(function (e, t, n) {\n return !t || 0 !== __PRIVATE_indexEntryComparator(e, n[t - 1]);\n });\n var r = [];\n r.push(e);\n\n var _iterator52 = _createForOfIteratorHelper(n),\n _step52;\n\n try {\n for (_iterator52.s(); !(_step52 = _iterator52.n()).done;) {\n var _i13 = _step52.value;\n\n var _n22 = __PRIVATE_indexEntryComparator(_i13, e),\n s = __PRIVATE_indexEntryComparator(_i13, t);\n\n if (0 === _n22) // `notInValue` is the lower bound. We therefore need to raise the bound\n // to the next value.\n r[0] = e.Jt();else if (_n22 > 0 && s < 0) // `notInValue` is in the middle of the range\n r.push(_i13), r.push(_i13.Jt());else if (s > 0) // `notInValue` (and all following values) are out of the range\n break;\n }\n } catch (err) {\n _iterator52.e(err);\n } finally {\n _iterator52.f();\n }\n\n r.push(t);\n var i = [];\n\n for (var _e62 = 0; _e62 < r.length; _e62 += 2) {\n // If we encounter two bounds that will create an unmatchable key range,\n // then we return an empty set of key ranges.\n if (this.Dn(r[_e62], r[_e62 + 1])) return [];\n var _t32 = [r[_e62].indexId, this.uid, r[_e62].arrayValue, r[_e62].directionalValue, Te, []],\n _n21 = [r[_e62 + 1].indexId, this.uid, r[_e62 + 1].arrayValue, r[_e62 + 1].directionalValue, Te, []];\n i.push(IDBKeyRange.bound(_t32, _n21));\n }\n\n return i;\n }\n }, {\n key: \"Dn\",\n value: function Dn(e, t) {\n // If lower bound is greater than the upper bound, then the key\n // range can never be matched.\n return __PRIVATE_indexEntryComparator(e, t) > 0;\n }\n }, {\n key: \"getMinOffsetFromCollectionGroup\",\n value: function getMinOffsetFromCollectionGroup(e, t) {\n return this.getFieldIndexes(e, t).next(__PRIVATE_getMinOffsetFromFieldIndexes);\n }\n }, {\n key: \"getMinOffset\",\n value: function getMinOffset(e, t) {\n var _this63 = this;\n\n return PersistencePromise.mapArray(this.cn(t), function (t) {\n return _this63.ln(e, t).next(function (e) {\n return e || fail();\n });\n }).next(__PRIVATE_getMinOffsetFromFieldIndexes);\n }\n }]);\n\n return __PRIVATE_IndexedDbIndexManager;\n}();\n/**\n * Helper to get a typed SimpleDbStore for the collectionParents\n * document store.\n */\n\n\nfunction __PRIVATE_collectionParentsStore(e) {\n return __PRIVATE_getStore(e, \"collectionParents\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the index entry object store.\n */\n\n\nfunction __PRIVATE_indexEntriesStore(e) {\n return __PRIVATE_getStore(e, \"indexEntries\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the index configuration object store.\n */\n\n\nfunction __PRIVATE_indexConfigurationStore(e) {\n return __PRIVATE_getStore(e, \"indexConfiguration\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the index state object store.\n */\n\n\nfunction __PRIVATE_indexStateStore(e) {\n return __PRIVATE_getStore(e, \"indexState\");\n}\n\nfunction __PRIVATE_getMinOffsetFromFieldIndexes(e) {\n __PRIVATE_hardAssert(0 !== e.length);\n\n var t = e[0].indexState.offset,\n n = t.largestBatchId;\n\n for (var r = 1; r < e.length; r++) {\n var i = e[r].indexState.offset;\n __PRIVATE_indexOffsetComparator(i, t) < 0 && (t = i), n < i.largestBatchId && (n = i.largestBatchId);\n }\n\n return new IndexOffset(t.readTime, t.documentKey, n);\n}\n/**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar Ee = {\n didRun: !1,\n sequenceNumbersCollected: 0,\n targetsRemoved: 0,\n documentsRemoved: 0\n};\n\nvar LruParams = /*#__PURE__*/function () {\n function LruParams( // When we attempt to collect, we will only do so if the cache size is greater than this\n // threshold. Passing `COLLECTION_DISABLED` here will cause collection to always be skipped.\n e, // The percentage of sequence numbers that we will attempt to collect\n t, // A cap on the total number of sequence numbers that will be collected. This prevents\n // us from collecting a huge number of sequence numbers if the cache has grown very large.\n n) {\n _classCallCheck(this, LruParams);\n\n this.cacheSizeCollectionThreshold = e, this.percentileToCollect = t, this.maximumSequenceNumbersToCollect = n;\n }\n\n _createClass(LruParams, null, [{\n key: \"withCacheSize\",\n value: function withCacheSize(e) {\n return new LruParams(e, LruParams.DEFAULT_COLLECTION_PERCENTILE, LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT);\n }\n }]);\n\n return LruParams;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Delete a mutation batch and the associated document mutations.\n * @returns A PersistencePromise of the document mutations that were removed.\n */\n\n\nfunction _removeMutationBatch(e, t, n) {\n var r = e.store(\"mutations\"),\n i = e.store(\"documentMutations\"),\n s = [],\n o = IDBKeyRange.only(n.batchId);\n var _ = 0;\n var a = r.Y({\n range: o\n }, function (e, t, n) {\n return _++, n.delete();\n });\n s.push(a.next(function () {\n __PRIVATE_hardAssert(1 === _);\n }));\n var u = [];\n\n var _iterator53 = _createForOfIteratorHelper(n.mutations),\n _step53;\n\n try {\n for (_iterator53.s(); !(_step53 = _iterator53.n()).done;) {\n var _e63 = _step53.value;\n\n var _r19 = __PRIVATE_newDbDocumentMutationKey(t, _e63.key.path, n.batchId);\n\n s.push(i.delete(_r19)), u.push(_e63.key);\n }\n } catch (err) {\n _iterator53.e(err);\n } finally {\n _iterator53.f();\n }\n\n return PersistencePromise.waitFor(s).next(function () {\n return u;\n });\n}\n/**\n * Returns an approximate size for the given document.\n */\n\n\nfunction __PRIVATE_dbDocumentSize(e) {\n if (!e) return 0;\n var t;\n if (e.document) t = e.document;else if (e.unknownDocument) t = e.unknownDocument;else {\n if (!e.noDocument) throw fail();\n t = e.noDocument;\n }\n return JSON.stringify(t).length;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** A mutation queue for a specific user, backed by IndexedDB. */\n\n\nLruParams.DEFAULT_COLLECTION_PERCENTILE = 10, LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1e3, LruParams.DEFAULT = new LruParams(41943040, LruParams.DEFAULT_COLLECTION_PERCENTILE, LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT), LruParams.DISABLED = new LruParams(-1, 0, 0);\n\nvar __PRIVATE_IndexedDbMutationQueue = /*#__PURE__*/function () {\n function __PRIVATE_IndexedDbMutationQueue(\n /**\n * The normalized userId (e.g. null UID => \"\" userId) used to store /\n * retrieve mutations.\n */\n e, t, n, r) {\n _classCallCheck(this, __PRIVATE_IndexedDbMutationQueue);\n\n this.userId = e, this.serializer = t, this.indexManager = n, this.referenceDelegate = r,\n /**\n * Caches the document keys for pending mutation batches. If the mutation\n * has been removed from IndexedDb, the cached value may continue to\n * be used to retrieve the batch's document keys. To remove a cached value\n * locally, `removeCachedMutationKeys()` should be invoked either directly\n * or through `removeMutationBatches()`.\n *\n * With multi-tab, when the primary client acknowledges or rejects a mutation,\n * this cache is used by secondary clients to invalidate the local\n * view of the documents that were previously affected by the mutation.\n */\n // PORTING NOTE: Multi-tab only.\n this.Cn = {};\n }\n /**\n * Creates a new mutation queue for the given user.\n * @param user - The user for which to create a mutation queue.\n * @param serializer - The serializer to use when persisting to IndexedDb.\n */\n\n\n _createClass(__PRIVATE_IndexedDbMutationQueue, [{\n key: \"checkEmpty\",\n value: function checkEmpty(e) {\n var t = !0;\n var n = IDBKeyRange.bound([this.userId, Number.NEGATIVE_INFINITY], [this.userId, Number.POSITIVE_INFINITY]);\n return __PRIVATE_mutationsStore(e).Y({\n index: \"userMutationsIndex\",\n range: n\n }, function (e, n, r) {\n t = !1, r.done();\n }).next(function () {\n return t;\n });\n }\n }, {\n key: \"addMutationBatch\",\n value: function addMutationBatch(e, t, n, r) {\n var _this64 = this;\n\n var i = __PRIVATE_documentMutationsStore(e),\n s = __PRIVATE_mutationsStore(e); // The IndexedDb implementation in Chrome (and Firefox) does not handle\n // compound indices that include auto-generated keys correctly. To ensure\n // that the index entry is added correctly in all browsers, we perform two\n // writes: The first write is used to retrieve the next auto-generated Batch\n // ID, and the second write populates the index and stores the actual\n // mutation batch.\n // See: https://bugs.chromium.org/p/chromium/issues/detail?id=701972\n // We write an empty object to obtain key\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n\n return s.add({}).next(function (o) {\n __PRIVATE_hardAssert(\"number\" == typeof o);\n\n var _ = new MutationBatch(o, t, n, r),\n a = function __PRIVATE_toDbMutationBatch(e, t, n) {\n var r = n.baseMutations.map(function (t) {\n return toMutation(e.ct, t);\n }),\n i = n.mutations.map(function (t) {\n return toMutation(e.ct, t);\n });\n return {\n userId: t,\n batchId: n.batchId,\n localWriteTimeMs: n.localWriteTime.toMillis(),\n baseMutations: r,\n mutations: i\n };\n }(_this64.serializer, _this64.userId, _),\n u = [];\n\n var c = new SortedSet(function (e, t) {\n return __PRIVATE_primitiveComparator(e.canonicalString(), t.canonicalString());\n });\n\n var _iterator54 = _createForOfIteratorHelper(r),\n _step54;\n\n try {\n for (_iterator54.s(); !(_step54 = _iterator54.n()).done;) {\n var _e64 = _step54.value;\n\n var _t33 = __PRIVATE_newDbDocumentMutationKey(_this64.userId, _e64.key.path, o);\n\n c = c.add(_e64.key.path.popLast()), u.push(s.put(a)), u.push(i.put(_t33, x));\n }\n } catch (err) {\n _iterator54.e(err);\n } finally {\n _iterator54.f();\n }\n\n return c.forEach(function (t) {\n u.push(_this64.indexManager.addToCollectionParentIndex(e, t));\n }), e.addOnCommittedListener(function () {\n _this64.Cn[o] = _.keys();\n }), PersistencePromise.waitFor(u).next(function () {\n return _;\n });\n });\n }\n }, {\n key: \"lookupMutationBatch\",\n value: function lookupMutationBatch(e, t) {\n var _this65 = this;\n\n return __PRIVATE_mutationsStore(e).get(t).next(function (e) {\n return e ? (__PRIVATE_hardAssert(e.userId === _this65.userId), __PRIVATE_fromDbMutationBatch(_this65.serializer, e)) : null;\n });\n }\n /**\n * Returns the document keys for the mutation batch with the given batchId.\n * For primary clients, this method returns `null` after\n * `removeMutationBatches()` has been called. Secondary clients return a\n * cached result until `removeCachedMutationKeys()` is invoked.\n */\n // PORTING NOTE: Multi-tab only.\n\n }, {\n key: \"vn\",\n value: function vn(e, t) {\n var _this66 = this;\n\n return this.Cn[t] ? PersistencePromise.resolve(this.Cn[t]) : this.lookupMutationBatch(e, t).next(function (e) {\n if (e) {\n var n = e.keys();\n return _this66.Cn[t] = n, n;\n }\n\n return null;\n });\n }\n }, {\n key: \"getNextMutationBatchAfterBatchId\",\n value: function getNextMutationBatchAfterBatchId(e, t) {\n var _this67 = this;\n\n var n = t + 1,\n r = IDBKeyRange.lowerBound([this.userId, n]);\n var i = null;\n return __PRIVATE_mutationsStore(e).Y({\n index: \"userMutationsIndex\",\n range: r\n }, function (e, t, r) {\n t.userId === _this67.userId && (__PRIVATE_hardAssert(t.batchId >= n), i = __PRIVATE_fromDbMutationBatch(_this67.serializer, t)), r.done();\n }).next(function () {\n return i;\n });\n }\n }, {\n key: \"getHighestUnacknowledgedBatchId\",\n value: function getHighestUnacknowledgedBatchId(e) {\n var t = IDBKeyRange.upperBound([this.userId, Number.POSITIVE_INFINITY]);\n var n = -1;\n return __PRIVATE_mutationsStore(e).Y({\n index: \"userMutationsIndex\",\n range: t,\n reverse: !0\n }, function (e, t, r) {\n n = t.batchId, r.done();\n }).next(function () {\n return n;\n });\n }\n }, {\n key: \"getAllMutationBatches\",\n value: function getAllMutationBatches(e) {\n var _this68 = this;\n\n var t = IDBKeyRange.bound([this.userId, -1], [this.userId, Number.POSITIVE_INFINITY]);\n return __PRIVATE_mutationsStore(e).W(\"userMutationsIndex\", t).next(function (e) {\n return e.map(function (e) {\n return __PRIVATE_fromDbMutationBatch(_this68.serializer, e);\n });\n });\n }\n }, {\n key: \"getAllMutationBatchesAffectingDocumentKey\",\n value: function getAllMutationBatchesAffectingDocumentKey(e, t) {\n var _this69 = this;\n\n // Scan the document-mutation index starting with a prefix starting with\n // the given documentKey.\n var n = __PRIVATE_newDbDocumentMutationPrefixForPath(this.userId, t.path),\n r = IDBKeyRange.lowerBound(n),\n i = [];\n\n return __PRIVATE_documentMutationsStore(e).Y({\n range: r\n }, function (n, r, s) {\n var _n23 = _slicedToArray(n, 3),\n o = _n23[0],\n _ = _n23[1],\n a = _n23[2],\n u = __PRIVATE_decodeResourcePath(_); // Only consider rows matching exactly the specific key of\n // interest. Note that because we order by path first, and we\n // order terminators before path separators, we'll encounter all\n // the index rows for documentKey contiguously. In particular, all\n // the rows for documentKey will occur before any rows for\n // documents nested in a subcollection beneath documentKey so we\n // can stop as soon as we hit any such row.\n\n\n if (o === _this69.userId && t.path.isEqual(u)) // Look up the mutation batch in the store.\n return __PRIVATE_mutationsStore(e).get(a).next(function (e) {\n if (!e) throw fail();\n __PRIVATE_hardAssert(e.userId === _this69.userId), i.push(__PRIVATE_fromDbMutationBatch(_this69.serializer, e));\n });\n s.done();\n }).next(function () {\n return i;\n });\n }\n }, {\n key: \"getAllMutationBatchesAffectingDocumentKeys\",\n value: function getAllMutationBatchesAffectingDocumentKeys(e, t) {\n var _this70 = this;\n\n var n = new SortedSet(__PRIVATE_primitiveComparator);\n var r = [];\n return t.forEach(function (t) {\n var i = __PRIVATE_newDbDocumentMutationPrefixForPath(_this70.userId, t.path),\n s = IDBKeyRange.lowerBound(i),\n o = __PRIVATE_documentMutationsStore(e).Y({\n range: s\n }, function (e, r, i) {\n var _e65 = _slicedToArray(e, 3),\n s = _e65[0],\n o = _e65[1],\n _ = _e65[2],\n a = __PRIVATE_decodeResourcePath(o); // Only consider rows matching exactly the specific key of\n // interest. Note that because we order by path first, and we\n // order terminators before path separators, we'll encounter all\n // the index rows for documentKey contiguously. In particular, all\n // the rows for documentKey will occur before any rows for\n // documents nested in a subcollection beneath documentKey so we\n // can stop as soon as we hit any such row.\n\n\n s === _this70.userId && t.path.isEqual(a) ? n = n.add(_) : i.done();\n });\n\n r.push(o);\n }), PersistencePromise.waitFor(r).next(function () {\n return _this70.Fn(e, n);\n });\n }\n }, {\n key: \"getAllMutationBatchesAffectingQuery\",\n value: function getAllMutationBatchesAffectingQuery(e, t) {\n var _this71 = this;\n\n var n = t.path,\n r = n.length + 1,\n i = __PRIVATE_newDbDocumentMutationPrefixForPath(this.userId, n),\n s = IDBKeyRange.lowerBound(i); // Collect up unique batchIDs encountered during a scan of the index. Use a\n // SortedSet to accumulate batch IDs so they can be traversed in order in a\n // scan of the main table.\n\n\n var o = new SortedSet(__PRIVATE_primitiveComparator);\n return __PRIVATE_documentMutationsStore(e).Y({\n range: s\n }, function (e, t, i) {\n var _e66 = _slicedToArray(e, 3),\n s = _e66[0],\n _ = _e66[1],\n a = _e66[2],\n u = __PRIVATE_decodeResourcePath(_);\n\n s === _this71.userId && n.isPrefixOf(u) ? // Rows with document keys more than one segment longer than the\n // query path can't be matches. For example, a query on 'rooms'\n // can't match the document /rooms/abc/messages/xyx.\n // TODO(mcg): we'll need a different scanner when we implement\n // ancestor queries.\n u.length === r && (o = o.add(a)) : i.done();\n }).next(function () {\n return _this71.Fn(e, o);\n });\n }\n }, {\n key: \"Fn\",\n value: function Fn(e, t) {\n var _this72 = this;\n\n var n = [],\n r = []; // TODO(rockwood): Implement this using iterate.\n\n return t.forEach(function (t) {\n r.push(__PRIVATE_mutationsStore(e).get(t).next(function (e) {\n if (null === e) throw fail();\n __PRIVATE_hardAssert(e.userId === _this72.userId), n.push(__PRIVATE_fromDbMutationBatch(_this72.serializer, e));\n }));\n }), PersistencePromise.waitFor(r).next(function () {\n return n;\n });\n }\n }, {\n key: \"removeMutationBatch\",\n value: function removeMutationBatch(e, t) {\n var _this73 = this;\n\n return _removeMutationBatch(e.ae, this.userId, t).next(function (n) {\n return e.addOnCommittedListener(function () {\n _this73.Mn(t.batchId);\n }), PersistencePromise.forEach(n, function (t) {\n return _this73.referenceDelegate.markPotentiallyOrphaned(e, t);\n });\n });\n }\n /**\n * Clears the cached keys for a mutation batch. This method should be\n * called by secondary clients after they process mutation updates.\n *\n * Note that this method does not have to be called from primary clients as\n * the corresponding cache entries are cleared when an acknowledged or\n * rejected batch is removed from the mutation queue.\n */\n // PORTING NOTE: Multi-tab only\n\n }, {\n key: \"Mn\",\n value: function Mn(e) {\n delete this.Cn[e];\n }\n }, {\n key: \"performConsistencyCheck\",\n value: function performConsistencyCheck(e) {\n var _this74 = this;\n\n return this.checkEmpty(e).next(function (t) {\n if (!t) return PersistencePromise.resolve(); // Verify that there are no entries in the documentMutations index if\n // the queue is empty.\n\n var n = IDBKeyRange.lowerBound(\n /**\n * Creates a [userId] key for use in the DbDocumentMutations index to iterate\n * over all of a user's document mutations.\n */\n function __PRIVATE_newDbDocumentMutationPrefixForUser(e) {\n return [e];\n }(_this74.userId)),\n r = [];\n return __PRIVATE_documentMutationsStore(e).Y({\n range: n\n }, function (e, t, n) {\n if (e[0] === _this74.userId) {\n var _t34 = __PRIVATE_decodeResourcePath(e[1]);\n\n r.push(_t34);\n } else n.done();\n }).next(function () {\n __PRIVATE_hardAssert(0 === r.length);\n });\n });\n }\n }, {\n key: \"containsKey\",\n value: function containsKey(e, t) {\n return __PRIVATE_mutationQueueContainsKey(e, this.userId, t);\n } // PORTING NOTE: Multi-tab only (state is held in memory in other clients).\n\n /** Returns the mutation queue's metadata from IndexedDb. */\n\n }, {\n key: \"xn\",\n value: function xn(e) {\n var _this75 = this;\n\n return __PRIVATE_mutationQueuesStore(e).get(this.userId).next(function (e) {\n return e || {\n userId: _this75.userId,\n lastAcknowledgedBatchId: -1,\n lastStreamToken: \"\"\n };\n });\n }\n }], [{\n key: \"lt\",\n value: function lt(e, t, n, r) {\n // TODO(mcg): Figure out what constraints there are on userIDs\n // In particular, are there any reserved characters? are empty ids allowed?\n // For the moment store these together in the same mutations table assuming\n // that empty userIDs aren't allowed.\n __PRIVATE_hardAssert(\"\" !== e.uid);\n\n var i = e.isAuthenticated() ? e.uid : \"\";\n return new __PRIVATE_IndexedDbMutationQueue(i, t, n, r);\n }\n }]);\n\n return __PRIVATE_IndexedDbMutationQueue;\n}();\n/**\n * @returns true if the mutation queue for the given user contains a pending\n * mutation for the given key.\n */\n\n\nfunction __PRIVATE_mutationQueueContainsKey(e, t, n) {\n var r = __PRIVATE_newDbDocumentMutationPrefixForPath(t, n.path),\n i = r[1],\n s = IDBKeyRange.lowerBound(r);\n\n var o = !1;\n return __PRIVATE_documentMutationsStore(e).Y({\n range: s,\n J: !0\n }, function (e, n, r) {\n var _e67 = _slicedToArray(e, 3),\n s = _e67[0],\n _ = _e67[1],\n\n /*batchID*/\n a = _e67[2];\n\n s === t && _ === i && (o = !0), r.done();\n }).next(function () {\n return o;\n });\n}\n/** Returns true if any mutation queue contains the given document. */\n\n/**\n * Helper to get a typed SimpleDbStore for the mutations object store.\n */\n\n\nfunction __PRIVATE_mutationsStore(e) {\n return __PRIVATE_getStore(e, \"mutations\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the mutationQueues object store.\n */\n\n\nfunction __PRIVATE_documentMutationsStore(e) {\n return __PRIVATE_getStore(e, \"documentMutations\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the mutationQueues object store.\n */\n\n\nfunction __PRIVATE_mutationQueuesStore(e) {\n return __PRIVATE_getStore(e, \"mutationQueues\");\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Offset to ensure non-overlapping target ids. */\n\n/**\n * Generates monotonically increasing target IDs for sending targets to the\n * watch stream.\n *\n * The client constructs two generators, one for the target cache, and one for\n * for the sync engine (to generate limbo documents targets). These\n * generators produce non-overlapping IDs (by using even and odd IDs\n * respectively).\n *\n * By separating the target ID space, the query cache can generate target IDs\n * that persist across client restarts, while sync engine can independently\n * generate in-memory target IDs that are transient and can be reused after a\n * restart.\n */\n\n\nvar __PRIVATE_TargetIdGenerator = /*#__PURE__*/function () {\n function __PRIVATE_TargetIdGenerator(e) {\n _classCallCheck(this, __PRIVATE_TargetIdGenerator);\n\n this.On = e;\n }\n\n _createClass(__PRIVATE_TargetIdGenerator, [{\n key: \"next\",\n value: function next() {\n return this.On += 2, this.On;\n }\n }], [{\n key: \"Nn\",\n value: function Nn() {\n // The target cache generator must return '2' in its first call to `next()`\n // as there is no differentiation in the protocol layer between an unset\n // number and the number '0'. If we were to sent a target with target ID\n // '0', the backend would consider it unset and replace it with its own ID.\n return new __PRIVATE_TargetIdGenerator(0);\n }\n }, {\n key: \"Bn\",\n value: function Bn() {\n // Sync engine assigns target IDs for limbo document detection.\n return new __PRIVATE_TargetIdGenerator(-1);\n }\n }]);\n\n return __PRIVATE_TargetIdGenerator;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_IndexedDbTargetCache = /*#__PURE__*/function () {\n function __PRIVATE_IndexedDbTargetCache(e, t) {\n _classCallCheck(this, __PRIVATE_IndexedDbTargetCache);\n\n this.referenceDelegate = e, this.serializer = t;\n } // PORTING NOTE: We don't cache global metadata for the target cache, since\n // some of it (in particular `highestTargetId`) can be modified by secondary\n // tabs. We could perhaps be more granular (and e.g. still cache\n // `lastRemoteSnapshotVersion` in memory) but for simplicity we currently go\n // to IndexedDb whenever we need to read metadata. We can revisit if it turns\n // out to have a meaningful performance impact.\n\n\n _createClass(__PRIVATE_IndexedDbTargetCache, [{\n key: \"allocateTargetId\",\n value: function allocateTargetId(e) {\n var _this76 = this;\n\n return this.Ln(e).next(function (t) {\n var n = new __PRIVATE_TargetIdGenerator(t.highestTargetId);\n return t.highestTargetId = n.next(), _this76.kn(e, t).next(function () {\n return t.highestTargetId;\n });\n });\n }\n }, {\n key: \"getLastRemoteSnapshotVersion\",\n value: function getLastRemoteSnapshotVersion(e) {\n return this.Ln(e).next(function (e) {\n return SnapshotVersion.fromTimestamp(new Timestamp(e.lastRemoteSnapshotVersion.seconds, e.lastRemoteSnapshotVersion.nanoseconds));\n });\n }\n }, {\n key: \"getHighestSequenceNumber\",\n value: function getHighestSequenceNumber(e) {\n return this.Ln(e).next(function (e) {\n return e.highestListenSequenceNumber;\n });\n }\n }, {\n key: \"setTargetsMetadata\",\n value: function setTargetsMetadata(e, t, n) {\n var _this77 = this;\n\n return this.Ln(e).next(function (r) {\n return r.highestListenSequenceNumber = t, n && (r.lastRemoteSnapshotVersion = n.toTimestamp()), t > r.highestListenSequenceNumber && (r.highestListenSequenceNumber = t), _this77.kn(e, r);\n });\n }\n }, {\n key: \"addTargetData\",\n value: function addTargetData(e, t) {\n var _this78 = this;\n\n return this.qn(e, t).next(function () {\n return _this78.Ln(e).next(function (n) {\n return n.targetCount += 1, _this78.Qn(t, n), _this78.kn(e, n);\n });\n });\n }\n }, {\n key: \"updateTargetData\",\n value: function updateTargetData(e, t) {\n return this.qn(e, t);\n }\n }, {\n key: \"removeTargetData\",\n value: function removeTargetData(e, t) {\n var _this79 = this;\n\n return this.removeMatchingKeysForTargetId(e, t.targetId).next(function () {\n return __PRIVATE_targetsStore(e).delete(t.targetId);\n }).next(function () {\n return _this79.Ln(e);\n }).next(function (t) {\n return __PRIVATE_hardAssert(t.targetCount > 0), t.targetCount -= 1, _this79.kn(e, t);\n });\n }\n /**\n * Drops any targets with sequence number less than or equal to the upper bound, excepting those\n * present in `activeTargetIds`. Document associations for the removed targets are also removed.\n * Returns the number of targets removed.\n */\n\n }, {\n key: \"removeTargets\",\n value: function removeTargets(e, t, n) {\n var _this80 = this;\n\n var r = 0;\n var i = [];\n return __PRIVATE_targetsStore(e).Y(function (s, o) {\n var _ = __PRIVATE_fromDbTarget(o);\n\n _.sequenceNumber <= t && null === n.get(_.targetId) && (r++, i.push(_this80.removeTargetData(e, _)));\n }).next(function () {\n return PersistencePromise.waitFor(i);\n }).next(function () {\n return r;\n });\n }\n /**\n * Call provided function with each `TargetData` that we have cached.\n */\n\n }, {\n key: \"forEachTarget\",\n value: function forEachTarget(e, t) {\n return __PRIVATE_targetsStore(e).Y(function (e, n) {\n var r = __PRIVATE_fromDbTarget(n);\n\n t(r);\n });\n }\n }, {\n key: \"Ln\",\n value: function Ln(e) {\n return __PRIVATE_globalTargetStore(e).get(\"targetGlobalKey\").next(function (e) {\n return __PRIVATE_hardAssert(null !== e), e;\n });\n }\n }, {\n key: \"kn\",\n value: function kn(e, t) {\n return __PRIVATE_globalTargetStore(e).put(\"targetGlobalKey\", t);\n }\n }, {\n key: \"qn\",\n value: function qn(e, t) {\n return __PRIVATE_targetsStore(e).put(__PRIVATE_toDbTarget(this.serializer, t));\n }\n /**\n * In-place updates the provided metadata to account for values in the given\n * TargetData. Saving is done separately. Returns true if there were any\n * changes to the metadata.\n */\n\n }, {\n key: \"Qn\",\n value: function Qn(e, t) {\n var n = !1;\n return e.targetId > t.highestTargetId && (t.highestTargetId = e.targetId, n = !0), e.sequenceNumber > t.highestListenSequenceNumber && (t.highestListenSequenceNumber = e.sequenceNumber, n = !0), n;\n }\n }, {\n key: \"getTargetCount\",\n value: function getTargetCount(e) {\n return this.Ln(e).next(function (e) {\n return e.targetCount;\n });\n }\n }, {\n key: \"getTargetData\",\n value: function getTargetData(e, t) {\n // Iterating by the canonicalId may yield more than one result because\n // canonicalId values are not required to be unique per target. This query\n // depends on the queryTargets index to be efficient.\n var n = __PRIVATE_canonifyTarget(t),\n r = IDBKeyRange.bound([n, Number.NEGATIVE_INFINITY], [n, Number.POSITIVE_INFINITY]);\n\n var i = null;\n return __PRIVATE_targetsStore(e).Y({\n range: r,\n index: \"queryTargetsIndex\"\n }, function (e, n, r) {\n var s = __PRIVATE_fromDbTarget(n); // After finding a potential match, check that the target is\n // actually equal to the requested target.\n\n\n __PRIVATE_targetEquals(t, s.target) && (i = s, r.done());\n }).next(function () {\n return i;\n });\n }\n }, {\n key: \"addMatchingKeys\",\n value: function addMatchingKeys(e, t, n) {\n var _this81 = this;\n\n // PORTING NOTE: The reverse index (documentsTargets) is maintained by\n // IndexedDb.\n var r = [],\n i = __PRIVATE_documentTargetStore(e);\n\n return t.forEach(function (t) {\n var s = __PRIVATE_encodeResourcePath(t.path);\n\n r.push(i.put({\n targetId: n,\n path: s\n })), r.push(_this81.referenceDelegate.addReference(e, n, t));\n }), PersistencePromise.waitFor(r);\n }\n }, {\n key: \"removeMatchingKeys\",\n value: function removeMatchingKeys(e, t, n) {\n var _this82 = this;\n\n // PORTING NOTE: The reverse index (documentsTargets) is maintained by\n // IndexedDb.\n var r = __PRIVATE_documentTargetStore(e);\n\n return PersistencePromise.forEach(t, function (t) {\n var i = __PRIVATE_encodeResourcePath(t.path);\n\n return PersistencePromise.waitFor([r.delete([n, i]), _this82.referenceDelegate.removeReference(e, n, t)]);\n });\n }\n }, {\n key: \"removeMatchingKeysForTargetId\",\n value: function removeMatchingKeysForTargetId(e, t) {\n var n = __PRIVATE_documentTargetStore(e),\n r = IDBKeyRange.bound([t], [t + 1],\n /*lowerOpen=*/\n !1,\n /*upperOpen=*/\n !0);\n\n return n.delete(r);\n }\n }, {\n key: \"getMatchingKeysForTargetId\",\n value: function getMatchingKeysForTargetId(e, t) {\n var n = IDBKeyRange.bound([t], [t + 1],\n /*lowerOpen=*/\n !1,\n /*upperOpen=*/\n !0),\n r = __PRIVATE_documentTargetStore(e);\n\n var i = __PRIVATE_documentKeySet();\n\n return r.Y({\n range: n,\n J: !0\n }, function (e, t, n) {\n var r = __PRIVATE_decodeResourcePath(e[1]),\n s = new DocumentKey(r);\n\n i = i.add(s);\n }).next(function () {\n return i;\n });\n }\n }, {\n key: \"containsKey\",\n value: function containsKey(e, t) {\n var n = __PRIVATE_encodeResourcePath(t.path),\n r = IDBKeyRange.bound([n], [__PRIVATE_immediateSuccessor(n)],\n /*lowerOpen=*/\n !1,\n /*upperOpen=*/\n !0);\n\n var i = 0;\n return __PRIVATE_documentTargetStore(e).Y({\n index: \"documentTargetsIndex\",\n J: !0,\n range: r\n }, function (_ref5, n, r) {\n var _ref6 = _slicedToArray(_ref5, 2),\n e = _ref6[0],\n t = _ref6[1];\n\n // Having a sentinel row for a document does not count as containing that document;\n // For the target cache, containing the document means the document is part of some\n // target.\n 0 !== e && (i++, r.done());\n }).next(function () {\n return i > 0;\n });\n }\n /**\n * Looks up a TargetData entry by target ID.\n *\n * @param targetId - The target ID of the TargetData entry to look up.\n * @returns The cached TargetData entry, or null if the cache has no entry for\n * the target.\n */\n // PORTING NOTE: Multi-tab only.\n\n }, {\n key: \"_t\",\n value: function _t(e, t) {\n return __PRIVATE_targetsStore(e).get(t).next(function (e) {\n return e ? __PRIVATE_fromDbTarget(e) : null;\n });\n }\n }]);\n\n return __PRIVATE_IndexedDbTargetCache;\n}();\n/**\n * Helper to get a typed SimpleDbStore for the queries object store.\n */\n\n\nfunction __PRIVATE_targetsStore(e) {\n return __PRIVATE_getStore(e, \"targets\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the target globals object store.\n */\n\n\nfunction __PRIVATE_globalTargetStore(e) {\n return __PRIVATE_getStore(e, \"targetGlobal\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the document target object store.\n */\n\n\nfunction __PRIVATE_documentTargetStore(e) {\n return __PRIVATE_getStore(e, \"targetDocuments\");\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nfunction __PRIVATE_bufferEntryComparator(_ref7, _ref8) {\n var _ref9 = _slicedToArray(_ref7, 2),\n e = _ref9[0],\n t = _ref9[1];\n\n var _ref10 = _slicedToArray(_ref8, 2),\n n = _ref10[0],\n r = _ref10[1];\n\n var i = __PRIVATE_primitiveComparator(e, n);\n\n return 0 === i ? __PRIVATE_primitiveComparator(t, r) : i;\n}\n/**\n * Used to calculate the nth sequence number. Keeps a rolling buffer of the\n * lowest n values passed to `addElement`, and finally reports the largest of\n * them in `maxValue`.\n */\n\n\nvar __PRIVATE_RollingSequenceNumberBuffer = /*#__PURE__*/function () {\n function __PRIVATE_RollingSequenceNumberBuffer(e) {\n _classCallCheck(this, __PRIVATE_RollingSequenceNumberBuffer);\n\n this.Kn = e, this.buffer = new SortedSet(__PRIVATE_bufferEntryComparator), this.$n = 0;\n }\n\n _createClass(__PRIVATE_RollingSequenceNumberBuffer, [{\n key: \"Un\",\n value: function Un() {\n return ++this.$n;\n }\n }, {\n key: \"Wn\",\n value: function Wn(e) {\n var t = [e, this.Un()];\n if (this.buffer.size < this.Kn) this.buffer = this.buffer.add(t);else {\n var _e68 = this.buffer.last();\n\n __PRIVATE_bufferEntryComparator(t, _e68) < 0 && (this.buffer = this.buffer.delete(_e68).add(t));\n }\n }\n }, {\n key: \"maxValue\",\n get: function get() {\n // Guaranteed to be non-empty. If we decide we are not collecting any\n // sequence numbers, nthSequenceNumber below short-circuits. If we have\n // decided that we are collecting n sequence numbers, it's because n is some\n // percentage of the existing sequence numbers. That means we should never\n // be in a situation where we are collecting sequence numbers but don't\n // actually have any.\n return this.buffer.last()[0];\n }\n }]);\n\n return __PRIVATE_RollingSequenceNumberBuffer;\n}();\n/**\n * This class is responsible for the scheduling of LRU garbage collection. It handles checking\n * whether or not GC is enabled, as well as which delay to use before the next run.\n */\n\n\nvar __PRIVATE_LruScheduler = /*#__PURE__*/function () {\n function __PRIVATE_LruScheduler(e, t, n) {\n _classCallCheck(this, __PRIVATE_LruScheduler);\n\n this.garbageCollector = e, this.asyncQueue = t, this.localStore = n, this.Gn = null;\n }\n\n _createClass(__PRIVATE_LruScheduler, [{\n key: \"start\",\n value: function start() {\n -1 !== this.garbageCollector.params.cacheSizeCollectionThreshold && this.zn(6e4);\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.Gn && (this.Gn.cancel(), this.Gn = null);\n }\n }, {\n key: \"started\",\n get: function get() {\n return null !== this.Gn;\n }\n }, {\n key: \"zn\",\n value: function zn(e) {\n var _this83 = this;\n\n __PRIVATE_logDebug(\"LruGarbageCollector\", \"Garbage collection scheduled in \".concat(e, \"ms\")), this.Gn = this.asyncQueue.enqueueAfterDelay(\"lru_garbage_collection\"\n /* TimerId.LruGarbageCollection */\n , e, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {\n return _regeneratorRuntime.wrap(function _callee7$(_context7) {\n while (1) {\n switch (_context7.prev = _context7.next) {\n case 0:\n _this83.Gn = null;\n _context7.prev = 1;\n _context7.next = 4;\n return _this83.localStore.collectGarbage(_this83.garbageCollector);\n\n case 4:\n _context7.next = 14;\n break;\n\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](1);\n\n if (!__PRIVATE_isIndexedDbTransactionError(_context7.t0)) {\n _context7.next = 12;\n break;\n }\n\n __PRIVATE_logDebug(\"LruGarbageCollector\", \"Ignoring IndexedDB error during garbage collection: \", _context7.t0);\n\n _context7.next = 14;\n break;\n\n case 12:\n _context7.next = 14;\n return __PRIVATE_ignoreIfPrimaryLeaseLoss(_context7.t0);\n\n case 14:\n _context7.next = 16;\n return _this83.zn(3e5);\n\n case 16:\n case \"end\":\n return _context7.stop();\n }\n }\n }, _callee7, null, [[1, 6]]);\n })));\n }\n }]);\n\n return __PRIVATE_LruScheduler;\n}();\n/**\n * Implements the steps for LRU garbage collection.\n */\n\n\nvar __PRIVATE_LruGarbageCollectorImpl = /*#__PURE__*/function () {\n function __PRIVATE_LruGarbageCollectorImpl(e, t) {\n _classCallCheck(this, __PRIVATE_LruGarbageCollectorImpl);\n\n this.jn = e, this.params = t;\n }\n\n _createClass(__PRIVATE_LruGarbageCollectorImpl, [{\n key: \"calculateTargetCount\",\n value: function calculateTargetCount(e, t) {\n return this.jn.Hn(e).next(function (e) {\n return Math.floor(t / 100 * e);\n });\n }\n }, {\n key: \"nthSequenceNumber\",\n value: function nthSequenceNumber(e, t) {\n var _this84 = this;\n\n if (0 === t) return PersistencePromise.resolve(__PRIVATE_ListenSequence._e);\n var n = new __PRIVATE_RollingSequenceNumberBuffer(t);\n return this.jn.forEachTarget(e, function (e) {\n return n.Wn(e.sequenceNumber);\n }).next(function () {\n return _this84.jn.Jn(e, function (e) {\n return n.Wn(e);\n });\n }).next(function () {\n return n.maxValue;\n });\n }\n }, {\n key: \"removeTargets\",\n value: function removeTargets(e, t, n) {\n return this.jn.removeTargets(e, t, n);\n }\n }, {\n key: \"removeOrphanedDocuments\",\n value: function removeOrphanedDocuments(e, t) {\n return this.jn.removeOrphanedDocuments(e, t);\n }\n }, {\n key: \"collect\",\n value: function collect(e, t) {\n var _this85 = this;\n\n return -1 === this.params.cacheSizeCollectionThreshold ? (__PRIVATE_logDebug(\"LruGarbageCollector\", \"Garbage collection skipped; disabled\"), PersistencePromise.resolve(Ee)) : this.getCacheSize(e).next(function (n) {\n return n < _this85.params.cacheSizeCollectionThreshold ? (__PRIVATE_logDebug(\"LruGarbageCollector\", \"Garbage collection skipped; Cache size \".concat(n, \" is lower than threshold \").concat(_this85.params.cacheSizeCollectionThreshold)), Ee) : _this85.Yn(e, t);\n });\n }\n }, {\n key: \"getCacheSize\",\n value: function getCacheSize(e) {\n return this.jn.getCacheSize(e);\n }\n }, {\n key: \"Yn\",\n value: function Yn(e, t) {\n var _this86 = this;\n\n var n, r, i, s, o, a, u;\n var c = Date.now();\n return this.calculateTargetCount(e, this.params.percentileToCollect).next(function (t) {\n return (// Cap at the configured max\n t > _this86.params.maximumSequenceNumbersToCollect ? (__PRIVATE_logDebug(\"LruGarbageCollector\", \"Capping sequence numbers to collect down to the maximum of \".concat(_this86.params.maximumSequenceNumbersToCollect, \" from \").concat(t)), r = _this86.params.maximumSequenceNumbersToCollect) : r = t, s = Date.now(), _this86.nthSequenceNumber(e, r)\n );\n }).next(function (r) {\n return n = r, o = Date.now(), _this86.removeTargets(e, n, t);\n }).next(function (t) {\n return i = t, a = Date.now(), _this86.removeOrphanedDocuments(e, n);\n }).next(function (e) {\n if (u = Date.now(), __PRIVATE_getLogLevel() <= LogLevel.DEBUG) {\n __PRIVATE_logDebug(\"LruGarbageCollector\", \"LRU Garbage Collection\\n\\tCounted targets in \".concat(s - c, \"ms\\n\\tDetermined least recently used \").concat(r, \" in \") + (o - s) + \"ms\\n\" + \"\\tRemoved \".concat(i, \" targets in \") + (a - o) + \"ms\\n\" + \"\\tRemoved \".concat(e, \" documents in \") + (u - a) + \"ms\\n\" + \"Total Duration: \".concat(u - c, \"ms\"));\n }\n\n return PersistencePromise.resolve({\n didRun: !0,\n sequenceNumbersCollected: r,\n targetsRemoved: i,\n documentsRemoved: e\n });\n });\n }\n }]);\n\n return __PRIVATE_LruGarbageCollectorImpl;\n}();\n\nfunction __PRIVATE_newLruGarbageCollector(e, t) {\n return new __PRIVATE_LruGarbageCollectorImpl(e, t);\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Provides LRU functionality for IndexedDB persistence. */\n\n\nvar __PRIVATE_IndexedDbLruDelegateImpl = /*#__PURE__*/function () {\n function __PRIVATE_IndexedDbLruDelegateImpl(e, t) {\n _classCallCheck(this, __PRIVATE_IndexedDbLruDelegateImpl);\n\n this.db = e, this.garbageCollector = __PRIVATE_newLruGarbageCollector(this, t);\n }\n\n _createClass(__PRIVATE_IndexedDbLruDelegateImpl, [{\n key: \"Hn\",\n value: function Hn(e) {\n var t = this.Zn(e);\n return this.db.getTargetCache().getTargetCount(e).next(function (e) {\n return t.next(function (t) {\n return e + t;\n });\n });\n }\n }, {\n key: \"Zn\",\n value: function Zn(e) {\n var t = 0;\n return this.Jn(e, function (e) {\n t++;\n }).next(function () {\n return t;\n });\n }\n }, {\n key: \"forEachTarget\",\n value: function forEachTarget(e, t) {\n return this.db.getTargetCache().forEachTarget(e, t);\n }\n }, {\n key: \"Jn\",\n value: function Jn(e, t) {\n return this.Xn(e, function (e, n) {\n return t(n);\n });\n }\n }, {\n key: \"addReference\",\n value: function addReference(e, t, n) {\n return __PRIVATE_writeSentinelKey(e, n);\n }\n }, {\n key: \"removeReference\",\n value: function removeReference(e, t, n) {\n return __PRIVATE_writeSentinelKey(e, n);\n }\n }, {\n key: \"removeTargets\",\n value: function removeTargets(e, t, n) {\n return this.db.getTargetCache().removeTargets(e, t, n);\n }\n }, {\n key: \"markPotentiallyOrphaned\",\n value: function markPotentiallyOrphaned(e, t) {\n return __PRIVATE_writeSentinelKey(e, t);\n }\n /**\n * Returns true if anything would prevent this document from being garbage\n * collected, given that the document in question is not present in any\n * targets and has a sequence number less than or equal to the upper bound for\n * the collection run.\n */\n\n }, {\n key: \"er\",\n value: function er(e, t) {\n return function __PRIVATE_mutationQueuesContainKey(e, t) {\n var n = !1;\n return __PRIVATE_mutationQueuesStore(e).Z(function (r) {\n return __PRIVATE_mutationQueueContainsKey(e, r, t).next(function (e) {\n return e && (n = !0), PersistencePromise.resolve(!e);\n });\n }).next(function () {\n return n;\n });\n }(e, t);\n }\n }, {\n key: \"removeOrphanedDocuments\",\n value: function removeOrphanedDocuments(e, t) {\n var _this87 = this;\n\n var n = this.db.getRemoteDocumentCache().newChangeBuffer(),\n r = [];\n var i = 0;\n return this.Xn(e, function (s, o) {\n if (o <= t) {\n var _t35 = _this87.er(e, s).next(function (t) {\n if (!t) // Our size accounting requires us to read all documents before\n // removing them.\n return i++, n.getEntry(e, s).next(function () {\n return n.removeEntry(s, SnapshotVersion.min()), __PRIVATE_documentTargetStore(e).delete(function __PRIVATE_sentinelKey$1(e) {\n return [0, __PRIVATE_encodeResourcePath(e.path)];\n }\n /**\n * @returns A value suitable for writing a sentinel row in the target-document\n * store.\n */\n (s));\n });\n });\n\n r.push(_t35);\n }\n }).next(function () {\n return PersistencePromise.waitFor(r);\n }).next(function () {\n return n.apply(e);\n }).next(function () {\n return i;\n });\n }\n }, {\n key: \"removeTarget\",\n value: function removeTarget(e, t) {\n var n = t.withSequenceNumber(e.currentSequenceNumber);\n return this.db.getTargetCache().updateTargetData(e, n);\n }\n }, {\n key: \"updateLimboDocument\",\n value: function updateLimboDocument(e, t) {\n return __PRIVATE_writeSentinelKey(e, t);\n }\n /**\n * Call provided function for each document in the cache that is 'orphaned'. Orphaned\n * means not a part of any target, so the only entry in the target-document index for\n * that document will be the sentinel row (targetId 0), which will also have the sequence\n * number for the last time the document was accessed.\n */\n\n }, {\n key: \"Xn\",\n value: function Xn(e, t) {\n var n = __PRIVATE_documentTargetStore(e);\n\n var r,\n i = __PRIVATE_ListenSequence._e;\n return n.Y({\n index: \"documentTargetsIndex\"\n }, function (_ref12, _ref13) {\n var _ref14 = _slicedToArray(_ref12, 2),\n e = _ref14[0],\n n = _ref14[1];\n\n var s = _ref13.path,\n o = _ref13.sequenceNumber;\n 0 === e ? ( // if nextToReport is valid, report it, this is a new key so the\n // last one must not be a member of any targets.\n i !== __PRIVATE_ListenSequence._e && t(new DocumentKey(__PRIVATE_decodeResourcePath(r)), i), // set nextToReport to be this sequence number. It's the next one we\n // might report, if we don't find any targets for this document.\n // Note that the sequence number must be defined when the targetId\n // is 0.\n i = o, r = s) : // set nextToReport to be invalid, we know we don't need to report\n // this one since we found a target for it.\n i = __PRIVATE_ListenSequence._e;\n }).next(function () {\n // Since we report sequence numbers after getting to the next key, we\n // need to check if the last key we iterated over was an orphaned\n // document and report it.\n i !== __PRIVATE_ListenSequence._e && t(new DocumentKey(__PRIVATE_decodeResourcePath(r)), i);\n });\n }\n }, {\n key: \"getCacheSize\",\n value: function getCacheSize(e) {\n return this.db.getRemoteDocumentCache().getSize(e);\n }\n }]);\n\n return __PRIVATE_IndexedDbLruDelegateImpl;\n}();\n\nfunction __PRIVATE_writeSentinelKey(e, t) {\n return __PRIVATE_documentTargetStore(e).put(function __PRIVATE_sentinelRow(e, t) {\n return {\n targetId: 0,\n path: __PRIVATE_encodeResourcePath(e.path),\n sequenceNumber: t\n };\n }(t, e.currentSequenceNumber));\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An in-memory buffer of entries to be written to a RemoteDocumentCache.\n * It can be used to batch up a set of changes to be written to the cache, but\n * additionally supports reading entries back with the `getEntry()` method,\n * falling back to the underlying RemoteDocumentCache if no entry is\n * buffered.\n *\n * Entries added to the cache *must* be read first. This is to facilitate\n * calculating the size delta of the pending changes.\n *\n * PORTING NOTE: This class was implemented then removed from other platforms.\n * If byte-counting ends up being needed on the other platforms, consider\n * porting this class as part of that implementation work.\n */\n\n\nvar RemoteDocumentChangeBuffer = /*#__PURE__*/function () {\n function RemoteDocumentChangeBuffer() {\n _classCallCheck(this, RemoteDocumentChangeBuffer);\n\n // A mapping of document key to the new cache entry that should be written.\n this.changes = new ObjectMap(function (e) {\n return e.toString();\n }, function (e, t) {\n return e.isEqual(t);\n }), this.changesApplied = !1;\n }\n /**\n * Buffers a `RemoteDocumentCache.addEntry()` call.\n *\n * You can only modify documents that have already been retrieved via\n * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).\n */\n\n\n _createClass(RemoteDocumentChangeBuffer, [{\n key: \"addEntry\",\n value: function addEntry(e) {\n this.assertNotApplied(), this.changes.set(e.key, e);\n }\n /**\n * Buffers a `RemoteDocumentCache.removeEntry()` call.\n *\n * You can only remove documents that have already been retrieved via\n * `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).\n */\n\n }, {\n key: \"removeEntry\",\n value: function removeEntry(e, t) {\n this.assertNotApplied(), this.changes.set(e, MutableDocument.newInvalidDocument(e).setReadTime(t));\n }\n /**\n * Looks up an entry in the cache. The buffered changes will first be checked,\n * and if no buffered change applies, this will forward to\n * `RemoteDocumentCache.getEntry()`.\n *\n * @param transaction - The transaction in which to perform any persistence\n * operations.\n * @param documentKey - The key of the entry to look up.\n * @returns The cached document or an invalid document if we have nothing\n * cached.\n */\n\n }, {\n key: \"getEntry\",\n value: function getEntry(e, t) {\n this.assertNotApplied();\n var n = this.changes.get(t);\n return void 0 !== n ? PersistencePromise.resolve(n) : this.getFromCache(e, t);\n }\n /**\n * Looks up several entries in the cache, forwarding to\n * `RemoteDocumentCache.getEntry()`.\n *\n * @param transaction - The transaction in which to perform any persistence\n * operations.\n * @param documentKeys - The keys of the entries to look up.\n * @returns A map of cached documents, indexed by key. If an entry cannot be\n * found, the corresponding key will be mapped to an invalid document.\n */\n\n }, {\n key: \"getEntries\",\n value: function getEntries(e, t) {\n return this.getAllFromCache(e, t);\n }\n /**\n * Applies buffered changes to the underlying RemoteDocumentCache, using\n * the provided transaction.\n */\n\n }, {\n key: \"apply\",\n value: function apply(e) {\n return this.assertNotApplied(), this.changesApplied = !0, this.applyChanges(e);\n }\n /** Helper to assert this.changes is not null */\n\n }, {\n key: \"assertNotApplied\",\n value: function assertNotApplied() {}\n }]);\n\n return RemoteDocumentChangeBuffer;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The RemoteDocumentCache for IndexedDb. To construct, invoke\n * `newIndexedDbRemoteDocumentCache()`.\n */\n\n\nvar __PRIVATE_IndexedDbRemoteDocumentCacheImpl = /*#__PURE__*/function () {\n function __PRIVATE_IndexedDbRemoteDocumentCacheImpl(e) {\n _classCallCheck(this, __PRIVATE_IndexedDbRemoteDocumentCacheImpl);\n\n this.serializer = e;\n }\n\n _createClass(__PRIVATE_IndexedDbRemoteDocumentCacheImpl, [{\n key: \"setIndexManager\",\n value: function setIndexManager(e) {\n this.indexManager = e;\n }\n /**\n * Adds the supplied entries to the cache.\n *\n * All calls of `addEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()` to ensure proper accounting of metadata.\n */\n\n }, {\n key: \"addEntry\",\n value: function addEntry(e, t, n) {\n return __PRIVATE_remoteDocumentsStore(e).put(n);\n }\n /**\n * Removes a document from the cache.\n *\n * All calls of `removeEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()` to ensure proper accounting of metadata.\n */\n\n }, {\n key: \"removeEntry\",\n value: function removeEntry(e, t, n) {\n return __PRIVATE_remoteDocumentsStore(e).delete(\n /**\n * Returns a key that can be used for document lookups via the primary key of\n * the DbRemoteDocument object store.\n */\n function __PRIVATE_dbReadTimeKey(e, t) {\n var n = e.path.toArray();\n return [\n /* prefix path */\n n.slice(0, n.length - 2),\n /* collection id */\n n[n.length - 2], __PRIVATE_toDbTimestampKey(t),\n /* document id */\n n[n.length - 1]];\n }\n /**\n * Returns a key that can be used for document lookups on the\n * `DbRemoteDocumentDocumentCollectionGroupIndex` index.\n */\n (t, n));\n }\n /**\n * Updates the current cache size.\n *\n * Callers to `addEntry()` and `removeEntry()` *must* call this afterwards to update the\n * cache's metadata.\n */\n\n }, {\n key: \"updateMetadata\",\n value: function updateMetadata(e, t) {\n var _this88 = this;\n\n return this.getMetadata(e).next(function (n) {\n return n.byteSize += t, _this88.tr(e, n);\n });\n }\n }, {\n key: \"getEntry\",\n value: function getEntry(e, t) {\n var _this89 = this;\n\n var n = MutableDocument.newInvalidDocument(t);\n return __PRIVATE_remoteDocumentsStore(e).Y({\n index: \"documentKeyIndex\",\n range: IDBKeyRange.only(__PRIVATE_dbKey(t))\n }, function (e, r) {\n n = _this89.nr(t, r);\n }).next(function () {\n return n;\n });\n }\n /**\n * Looks up an entry in the cache.\n *\n * @param documentKey - The key of the entry to look up.\n * @returns The cached document entry and its size.\n */\n\n }, {\n key: \"rr\",\n value: function rr(e, t) {\n var _this90 = this;\n\n var n = {\n size: 0,\n document: MutableDocument.newInvalidDocument(t)\n };\n return __PRIVATE_remoteDocumentsStore(e).Y({\n index: \"documentKeyIndex\",\n range: IDBKeyRange.only(__PRIVATE_dbKey(t))\n }, function (e, r) {\n n = {\n document: _this90.nr(t, r),\n size: __PRIVATE_dbDocumentSize(r)\n };\n }).next(function () {\n return n;\n });\n }\n }, {\n key: \"getEntries\",\n value: function getEntries(e, t) {\n var _this91 = this;\n\n var n = __PRIVATE_mutableDocumentMap();\n\n return this.ir(e, t, function (e, t) {\n var r = _this91.nr(e, t);\n\n n = n.insert(e, r);\n }).next(function () {\n return n;\n });\n }\n /**\n * Looks up several entries in the cache.\n *\n * @param documentKeys - The set of keys entries to look up.\n * @returns A map of documents indexed by key and a map of sizes indexed by\n * key (zero if the document does not exist).\n */\n\n }, {\n key: \"sr\",\n value: function sr(e, t) {\n var _this92 = this;\n\n var n = __PRIVATE_mutableDocumentMap(),\n r = new SortedMap(DocumentKey.comparator);\n\n return this.ir(e, t, function (e, t) {\n var i = _this92.nr(e, t);\n\n n = n.insert(e, i), r = r.insert(e, __PRIVATE_dbDocumentSize(t));\n }).next(function () {\n return {\n documents: n,\n _r: r\n };\n });\n }\n }, {\n key: \"ir\",\n value: function ir(e, t, n) {\n if (t.isEmpty()) return PersistencePromise.resolve();\n var r = new SortedSet(__PRIVATE_dbKeyComparator);\n t.forEach(function (e) {\n return r = r.add(e);\n });\n var i = IDBKeyRange.bound(__PRIVATE_dbKey(r.first()), __PRIVATE_dbKey(r.last())),\n s = r.getIterator();\n var o = s.getNext();\n return __PRIVATE_remoteDocumentsStore(e).Y({\n index: \"documentKeyIndex\",\n range: i\n }, function (e, t, r) {\n var i = DocumentKey.fromSegments([].concat(_toConsumableArray(t.prefixPath), [t.collectionGroup, t.documentId])); // Go through keys not found in cache.\n\n for (; o && __PRIVATE_dbKeyComparator(o, i) < 0;) {\n n(o, null), o = s.getNext();\n }\n\n o && o.isEqual(i) && ( // Key found in cache.\n n(o, t), o = s.hasNext() ? s.getNext() : null), // Skip to the next key (if there is one).\n o ? r.U(__PRIVATE_dbKey(o)) : r.done();\n }).next(function () {\n // The rest of the keys are not in the cache. One case where `iterate`\n // above won't go through them is when the cache is empty.\n for (; o;) {\n n(o, null), o = s.hasNext() ? s.getNext() : null;\n }\n });\n }\n }, {\n key: \"getDocumentsMatchingQuery\",\n value: function getDocumentsMatchingQuery(e, t, n, r, i) {\n var _this93 = this;\n\n var s = t.path,\n o = [s.popLast().toArray(), s.lastSegment(), __PRIVATE_toDbTimestampKey(n.readTime), n.documentKey.path.isEmpty() ? \"\" : n.documentKey.path.lastSegment()],\n _ = [s.popLast().toArray(), s.lastSegment(), [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER], \"\"];\n return __PRIVATE_remoteDocumentsStore(e).W(IDBKeyRange.bound(o, _, !0)).next(function (e) {\n null == i || i.incrementDocumentReadCount(e.length);\n\n var n = __PRIVATE_mutableDocumentMap();\n\n var _iterator55 = _createForOfIteratorHelper(e),\n _step55;\n\n try {\n for (_iterator55.s(); !(_step55 = _iterator55.n()).done;) {\n var _i14 = _step55.value;\n\n var _e69 = _this93.nr(DocumentKey.fromSegments(_i14.prefixPath.concat(_i14.collectionGroup, _i14.documentId)), _i14);\n\n _e69.isFoundDocument() && (__PRIVATE_queryMatches(t, _e69) || r.has(_e69.key)) && ( // Either the document matches the given query, or it is mutated.\n n = n.insert(_e69.key, _e69));\n }\n } catch (err) {\n _iterator55.e(err);\n } finally {\n _iterator55.f();\n }\n\n return n;\n });\n }\n }, {\n key: \"getAllFromCollectionGroup\",\n value: function getAllFromCollectionGroup(e, t, n, r) {\n var _this94 = this;\n\n var i = __PRIVATE_mutableDocumentMap();\n\n var s = __PRIVATE_dbCollectionGroupKey(t, n),\n o = __PRIVATE_dbCollectionGroupKey(t, IndexOffset.max());\n\n return __PRIVATE_remoteDocumentsStore(e).Y({\n index: \"collectionGroupIndex\",\n range: IDBKeyRange.bound(s, o, !0)\n }, function (e, t, n) {\n var s = _this94.nr(DocumentKey.fromSegments(t.prefixPath.concat(t.collectionGroup, t.documentId)), t);\n\n i = i.insert(s.key, s), i.size === r && n.done();\n }).next(function () {\n return i;\n });\n }\n }, {\n key: \"newChangeBuffer\",\n value: function newChangeBuffer(e) {\n return new __PRIVATE_IndexedDbRemoteDocumentChangeBuffer(this, !!e && e.trackRemovals);\n }\n }, {\n key: \"getSize\",\n value: function getSize(e) {\n return this.getMetadata(e).next(function (e) {\n return e.byteSize;\n });\n }\n }, {\n key: \"getMetadata\",\n value: function getMetadata(e) {\n return __PRIVATE_documentGlobalStore(e).get(\"remoteDocumentGlobalKey\").next(function (e) {\n return __PRIVATE_hardAssert(!!e), e;\n });\n }\n }, {\n key: \"tr\",\n value: function tr(e, t) {\n return __PRIVATE_documentGlobalStore(e).put(\"remoteDocumentGlobalKey\", t);\n }\n /**\n * Decodes `dbRemoteDoc` and returns the document (or an invalid document if\n * the document corresponds to the format used for sentinel deletes).\n */\n\n }, {\n key: \"nr\",\n value: function nr(e, t) {\n if (t) {\n var _e70 = __PRIVATE_fromDbRemoteDocument(this.serializer, t); // Whether the document is a sentinel removal and should only be used in the\n // `getNewDocumentChanges()`\n\n\n if (!(_e70.isNoDocument() && _e70.version.isEqual(SnapshotVersion.min()))) return _e70;\n }\n\n return MutableDocument.newInvalidDocument(e);\n }\n }]);\n\n return __PRIVATE_IndexedDbRemoteDocumentCacheImpl;\n}();\n/** Creates a new IndexedDbRemoteDocumentCache. */\n\n\nfunction __PRIVATE_newIndexedDbRemoteDocumentCache(e) {\n return new __PRIVATE_IndexedDbRemoteDocumentCacheImpl(e);\n}\n/**\n * Handles the details of adding and updating documents in the IndexedDbRemoteDocumentCache.\n *\n * Unlike the MemoryRemoteDocumentChangeBuffer, the IndexedDb implementation computes the size\n * delta for all submitted changes. This avoids having to re-read all documents from IndexedDb\n * when we apply the changes.\n */\n\n\nvar __PRIVATE_IndexedDbRemoteDocumentChangeBuffer = /*#__PURE__*/function (_RemoteDocumentChange) {\n _inherits(__PRIVATE_IndexedDbRemoteDocumentChangeBuffer, _RemoteDocumentChange);\n\n var _super25 = _createSuper(__PRIVATE_IndexedDbRemoteDocumentChangeBuffer);\n\n /**\n * @param documentCache - The IndexedDbRemoteDocumentCache to apply the changes to.\n * @param trackRemovals - Whether to create sentinel deletes that can be tracked by\n * `getNewDocumentChanges()`.\n */\n function __PRIVATE_IndexedDbRemoteDocumentChangeBuffer(e, t) {\n var _this95;\n\n _classCallCheck(this, __PRIVATE_IndexedDbRemoteDocumentChangeBuffer);\n\n _this95 = _super25.call(this), _this95.ar = e, _this95.trackRemovals = t, // A map of document sizes and read times prior to applying the changes in\n // this buffer.\n _this95.ur = new ObjectMap(function (e) {\n return e.toString();\n }, function (e, t) {\n return e.isEqual(t);\n });\n return _this95;\n }\n\n _createClass(__PRIVATE_IndexedDbRemoteDocumentChangeBuffer, [{\n key: \"applyChanges\",\n value: function applyChanges(e) {\n var _this96 = this;\n\n var t = [];\n var n = 0,\n r = new SortedSet(function (e, t) {\n return __PRIVATE_primitiveComparator(e.canonicalString(), t.canonicalString());\n });\n return this.changes.forEach(function (i, s) {\n var o = _this96.ur.get(i);\n\n if (t.push(_this96.ar.removeEntry(e, i, o.readTime)), s.isValidDocument()) {\n var _ = __PRIVATE_toDbRemoteDocument(_this96.ar.serializer, s);\n\n r = r.add(i.path.popLast());\n\n var a = __PRIVATE_dbDocumentSize(_);\n\n n += a - o.size, t.push(_this96.ar.addEntry(e, i, _));\n } else if (n -= o.size, _this96.trackRemovals) {\n // In order to track removals, we store a \"sentinel delete\" in the\n // RemoteDocumentCache. This entry is represented by a NoDocument\n // with a version of 0 and ignored by `maybeDecodeDocument()` but\n // preserved in `getNewDocumentChanges()`.\n var _n24 = __PRIVATE_toDbRemoteDocument(_this96.ar.serializer, s.convertToNoDocument(SnapshotVersion.min()));\n\n t.push(_this96.ar.addEntry(e, i, _n24));\n }\n }), r.forEach(function (n) {\n t.push(_this96.ar.indexManager.addToCollectionParentIndex(e, n));\n }), t.push(this.ar.updateMetadata(e, n)), PersistencePromise.waitFor(t);\n }\n }, {\n key: \"getFromCache\",\n value: function getFromCache(e, t) {\n var _this97 = this;\n\n // Record the size of everything we load from the cache so we can compute a delta later.\n return this.ar.rr(e, t).next(function (e) {\n return _this97.ur.set(t, {\n size: e.size,\n readTime: e.document.readTime\n }), e.document;\n });\n }\n }, {\n key: \"getAllFromCache\",\n value: function getAllFromCache(e, t) {\n var _this98 = this;\n\n // Record the size of everything we load from the cache so we can compute\n // a delta later.\n return this.ar.sr(e, t).next(function (_ref15) {\n var e = _ref15.documents,\n t = _ref15._r;\n return (// Note: `getAllFromCache` returns two maps instead of a single map from\n // keys to `DocumentSizeEntry`s. This is to allow returning the\n // `MutableDocumentMap` directly, without a conversion.\n t.forEach(function (t, n) {\n _this98.ur.set(t, {\n size: n,\n readTime: e.get(t).readTime\n });\n }), e\n );\n });\n }\n }]);\n\n return __PRIVATE_IndexedDbRemoteDocumentChangeBuffer;\n}(RemoteDocumentChangeBuffer);\n\nfunction __PRIVATE_documentGlobalStore(e) {\n return __PRIVATE_getStore(e, \"remoteDocumentGlobal\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the remoteDocuments object store.\n */\n\n\nfunction __PRIVATE_remoteDocumentsStore(e) {\n return __PRIVATE_getStore(e, \"remoteDocumentsV14\");\n}\n/**\n * Returns a key that can be used for document lookups on the\n * `DbRemoteDocumentDocumentKeyIndex` index.\n */\n\n\nfunction __PRIVATE_dbKey(e) {\n var t = e.path.toArray();\n return [\n /* prefix path */\n t.slice(0, t.length - 2),\n /* collection id */\n t[t.length - 2],\n /* document id */\n t[t.length - 1]];\n}\n\nfunction __PRIVATE_dbCollectionGroupKey(e, t) {\n var n = t.documentKey.path.toArray();\n return [\n /* collection id */\n e, __PRIVATE_toDbTimestampKey(t.readTime),\n /* prefix path */\n n.slice(0, n.length - 2),\n /* document id */\n n.length > 0 ? n[n.length - 1] : \"\"];\n}\n/**\n * Comparator that compares document keys according to the primary key sorting\n * used by the `DbRemoteDocumentDocument` store (by prefix path, collection id\n * and then document ID).\n *\n * Visible for testing.\n */\n\n\nfunction __PRIVATE_dbKeyComparator(e, t) {\n var n = e.path.toArray(),\n r = t.path.toArray(); // The ordering is based on https://chromium.googlesource.com/chromium/blink/+/fe5c21fef94dae71c1c3344775b8d8a7f7e6d9ec/Source/modules/indexeddb/IDBKey.cpp#74\n\n var i = 0;\n\n for (var _e71 = 0; _e71 < n.length - 2 && _e71 < r.length - 2; ++_e71) {\n if (i = __PRIVATE_primitiveComparator(n[_e71], r[_e71]), i) return i;\n }\n\n return i = __PRIVATE_primitiveComparator(n.length, r.length), i || (i = __PRIVATE_primitiveComparator(n[n.length - 2], r[r.length - 2]), i || __PRIVATE_primitiveComparator(n[n.length - 1], r[r.length - 1]));\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Schema Version for the Web client:\n * 1. Initial version including Mutation Queue, Query Cache, and Remote\n * Document Cache\n * 2. Used to ensure a targetGlobal object exists and add targetCount to it. No\n * longer required because migration 3 unconditionally clears it.\n * 3. Dropped and re-created Query Cache to deal with cache corruption related\n * to limbo resolution. Addresses\n * https://github.com/firebase/firebase-ios-sdk/issues/1548\n * 4. Multi-Tab Support.\n * 5. Removal of held write acks.\n * 6. Create document global for tracking document cache size.\n * 7. Ensure every cached document has a sentinel row with a sequence number.\n * 8. Add collection-parent index for Collection Group queries.\n * 9. Change RemoteDocumentChanges store to be keyed by readTime rather than\n * an auto-incrementing ID. This is required for Index-Free queries.\n * 10. Rewrite the canonical IDs to the explicit Protobuf-based format.\n * 11. Add bundles and named_queries for bundle support.\n * 12. Add document overlays.\n * 13. Rewrite the keys of the remote document cache to allow for efficient\n * document lookup via `getAll()`.\n * 14. Add overlays.\n * 15. Add indexing support.\n */\n\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents a local view (overlay) of a document, and the fields that are\n * locally mutated.\n */\n\n\nvar OverlayedDocument = /*#__PURE__*/_createClass(function OverlayedDocument(e,\n/**\n * The fields that are locally mutated by patch mutations.\n *\n * If the overlayed\tdocument is from set or delete mutations, this is `null`.\n * If there is no overlay (mutation) for the document, this is an empty `FieldMask`.\n */\nt) {\n _classCallCheck(this, OverlayedDocument);\n\n this.overlayedDocument = e, this.mutatedFields = t;\n});\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A readonly view of the local state of all documents we're tracking (i.e. we\n * have a cached version in remoteDocumentCache or local mutations for the\n * document). The view is computed by applying the mutations in the\n * MutationQueue to the RemoteDocumentCache.\n */\n\n\nvar LocalDocumentsView = /*#__PURE__*/function () {\n function LocalDocumentsView(e, t, n, r) {\n _classCallCheck(this, LocalDocumentsView);\n\n this.remoteDocumentCache = e, this.mutationQueue = t, this.documentOverlayCache = n, this.indexManager = r;\n }\n /**\n * Get the local view of the document identified by `key`.\n *\n * @returns Local view of the document or null if we don't have any cached\n * state for it.\n */\n\n\n _createClass(LocalDocumentsView, [{\n key: \"getDocument\",\n value: function getDocument(e, t) {\n var _this99 = this;\n\n var n = null;\n return this.documentOverlayCache.getOverlay(e, t).next(function (r) {\n return n = r, _this99.remoteDocumentCache.getEntry(e, t);\n }).next(function (e) {\n return null !== n && __PRIVATE_mutationApplyToLocalView(n.mutation, e, FieldMask.empty(), Timestamp.now()), e;\n });\n }\n /**\n * Gets the local view of the documents identified by `keys`.\n *\n * If we don't have cached state for a document in `keys`, a NoDocument will\n * be stored for that key in the resulting set.\n */\n\n }, {\n key: \"getDocuments\",\n value: function getDocuments(e, t) {\n var _this100 = this;\n\n return this.remoteDocumentCache.getEntries(e, t).next(function (t) {\n return _this100.getLocalViewOfDocuments(e, t, __PRIVATE_documentKeySet()).next(function () {\n return t;\n });\n });\n }\n /**\n * Similar to `getDocuments`, but creates the local view from the given\n * `baseDocs` without retrieving documents from the local store.\n *\n * @param transaction - The transaction this operation is scoped to.\n * @param docs - The documents to apply local mutations to get the local views.\n * @param existenceStateChanged - The set of document keys whose existence state\n * is changed. This is useful to determine if some documents overlay needs\n * to be recalculated.\n */\n\n }, {\n key: \"getLocalViewOfDocuments\",\n value: function getLocalViewOfDocuments(e, t) {\n var _this101 = this;\n\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : __PRIVATE_documentKeySet();\n\n var r = __PRIVATE_newOverlayMap();\n\n return this.populateOverlays(e, r, t).next(function () {\n return _this101.computeViews(e, t, r, n).next(function (e) {\n var t = documentMap();\n return e.forEach(function (e, n) {\n t = t.insert(e, n.overlayedDocument);\n }), t;\n });\n });\n }\n /**\n * Gets the overlayed documents for the given document map, which will include\n * the local view of those documents and a `FieldMask` indicating which fields\n * are mutated locally, `null` if overlay is a Set or Delete mutation.\n */\n\n }, {\n key: \"getOverlayedDocuments\",\n value: function getOverlayedDocuments(e, t) {\n var _this102 = this;\n\n var n = __PRIVATE_newOverlayMap();\n\n return this.populateOverlays(e, n, t).next(function () {\n return _this102.computeViews(e, t, n, __PRIVATE_documentKeySet());\n });\n }\n /**\n * Fetches the overlays for {@code docs} and adds them to provided overlay map\n * if the map does not already contain an entry for the given document key.\n */\n\n }, {\n key: \"populateOverlays\",\n value: function populateOverlays(e, t, n) {\n var r = [];\n return n.forEach(function (e) {\n t.has(e) || r.push(e);\n }), this.documentOverlayCache.getOverlays(e, r).next(function (e) {\n e.forEach(function (e, n) {\n t.set(e, n);\n });\n });\n }\n /**\n * Computes the local view for the given documents.\n *\n * @param docs - The documents to compute views for. It also has the base\n * version of the documents.\n * @param overlays - The overlays that need to be applied to the given base\n * version of the documents.\n * @param existenceStateChanged - A set of documents whose existence states\n * might have changed. This is used to determine if we need to re-calculate\n * overlays from mutation queues.\n * @return A map represents the local documents view.\n */\n\n }, {\n key: \"computeViews\",\n value: function computeViews(e, t, n, r) {\n var i = __PRIVATE_mutableDocumentMap();\n\n var s = __PRIVATE_newDocumentKeyMap(),\n o = function __PRIVATE_newOverlayedDocumentMap() {\n return __PRIVATE_newDocumentKeyMap();\n }();\n\n return t.forEach(function (e, t) {\n var o = n.get(t.key); // Recalculate an overlay if the document's existence state changed due to\n // a remote event *and* the overlay is a PatchMutation. This is because\n // document existence state can change if some patch mutation's\n // preconditions are met.\n // NOTE: we recalculate when `overlay` is undefined as well, because there\n // might be a patch mutation whose precondition does not match before the\n // change (hence overlay is undefined), but would now match.\n\n r.has(t.key) && (void 0 === o || o.mutation instanceof __PRIVATE_PatchMutation) ? i = i.insert(t.key, t) : void 0 !== o ? (s.set(t.key, o.mutation.getFieldMask()), __PRIVATE_mutationApplyToLocalView(o.mutation, t, o.mutation.getFieldMask(), Timestamp.now())) : // no overlay exists\n // Using EMPTY to indicate there is no overlay for the document.\n s.set(t.key, FieldMask.empty());\n }), this.recalculateAndSaveOverlays(e, i).next(function (e) {\n return e.forEach(function (e, t) {\n return s.set(e, t);\n }), t.forEach(function (e, t) {\n var n;\n return o.set(e, new OverlayedDocument(t, null !== (n = s.get(e)) && void 0 !== n ? n : null));\n }), o;\n });\n }\n }, {\n key: \"recalculateAndSaveOverlays\",\n value: function recalculateAndSaveOverlays(e, t) {\n var _this103 = this;\n\n var n = __PRIVATE_newDocumentKeyMap(); // A reverse lookup map from batch id to the documents within that batch.\n\n\n var r = new SortedMap(function (e, t) {\n return e - t;\n }),\n i = __PRIVATE_documentKeySet();\n\n return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e, t).next(function (e) {\n var _iterator56 = _createForOfIteratorHelper(e),\n _step56;\n\n try {\n var _loop6 = function _loop6() {\n var i = _step56.value;\n i.keys().forEach(function (e) {\n var s = t.get(e);\n if (null === s) return;\n var o = n.get(e) || FieldMask.empty();\n o = i.applyToLocalView(s, o), n.set(e, o);\n\n var _ = (r.get(i.batchId) || __PRIVATE_documentKeySet()).add(e);\n\n r = r.insert(i.batchId, _);\n });\n };\n\n for (_iterator56.s(); !(_step56 = _iterator56.n()).done;) {\n _loop6();\n }\n } catch (err) {\n _iterator56.e(err);\n } finally {\n _iterator56.f();\n }\n }).next(function () {\n var s = [],\n o = r.getReverseIterator(); // Iterate in descending order of batch IDs, and skip documents that are\n // already saved.\n\n var _loop7 = function _loop7() {\n var r = o.getNext(),\n _ = r.key,\n a = r.value,\n u = __PRIVATE_newMutationMap();\n\n a.forEach(function (e) {\n if (!i.has(e)) {\n var _r20 = __PRIVATE_calculateOverlayMutation(t.get(e), n.get(e));\n\n null !== _r20 && u.set(e, _r20), i = i.add(e);\n }\n }), s.push(_this103.documentOverlayCache.saveOverlays(e, _, u));\n };\n\n for (; o.hasNext();) {\n _loop7();\n }\n\n return PersistencePromise.waitFor(s);\n }).next(function () {\n return n;\n });\n }\n /**\n * Recalculates overlays by reading the documents from remote document cache\n * first, and saves them after they are calculated.\n */\n\n }, {\n key: \"recalculateAndSaveOverlaysForDocumentKeys\",\n value: function recalculateAndSaveOverlaysForDocumentKeys(e, t) {\n var _this104 = this;\n\n return this.remoteDocumentCache.getEntries(e, t).next(function (t) {\n return _this104.recalculateAndSaveOverlays(e, t);\n });\n }\n /**\n * Performs a query against the local view of all documents.\n *\n * @param transaction - The persistence transaction.\n * @param query - The query to match documents against.\n * @param offset - Read time and key to start scanning by (exclusive).\n * @param context - A optional tracker to keep a record of important details\n * during database local query execution.\n */\n\n }, {\n key: \"getDocumentsMatchingQuery\",\n value: function getDocumentsMatchingQuery(e, t, n, r) {\n /**\n * Returns whether the query matches a single document by path (rather than a\n * collection).\n */\n return function __PRIVATE_isDocumentQuery$1(e) {\n return DocumentKey.isDocumentKey(e.path) && null === e.collectionGroup && 0 === e.filters.length;\n }(t) ? this.getDocumentsMatchingDocumentQuery(e, t.path) : __PRIVATE_isCollectionGroupQuery(t) ? this.getDocumentsMatchingCollectionGroupQuery(e, t, n, r) : this.getDocumentsMatchingCollectionQuery(e, t, n, r);\n }\n /**\n * Given a collection group, returns the next documents that follow the provided offset, along\n * with an updated batch ID.\n *\n *

The documents returned by this method are ordered by remote version from the provided\n * offset. If there are no more remote documents after the provided offset, documents with\n * mutations in order of batch id from the offset are returned. Since all documents in a batch are\n * returned together, the total number of documents returned can exceed {@code count}.\n *\n * @param transaction\n * @param collectionGroup The collection group for the documents.\n * @param offset The offset to index into.\n * @param count The number of documents to return\n * @return A LocalWriteResult with the documents that follow the provided offset and the last processed batch id.\n */\n\n }, {\n key: \"getNextDocuments\",\n value: function getNextDocuments(e, t, n, r) {\n var _this105 = this;\n\n return this.remoteDocumentCache.getAllFromCollectionGroup(e, t, n, r).next(function (i) {\n var s = r - i.size > 0 ? _this105.documentOverlayCache.getOverlaysForCollectionGroup(e, t, n.largestBatchId, r - i.size) : PersistencePromise.resolve(__PRIVATE_newOverlayMap()); // The callsite will use the largest batch ID together with the latest read time to create\n // a new index offset. Since we only process batch IDs if all remote documents have been read,\n // no overlay will increase the overall read time. This is why we only need to special case\n // the batch id.\n\n var o = -1,\n _ = i;\n return s.next(function (t) {\n return PersistencePromise.forEach(t, function (t, n) {\n return o < n.largestBatchId && (o = n.largestBatchId), i.get(t) ? PersistencePromise.resolve() : _this105.remoteDocumentCache.getEntry(e, t).next(function (e) {\n _ = _.insert(t, e);\n });\n }).next(function () {\n return _this105.populateOverlays(e, t, i);\n }).next(function () {\n return _this105.computeViews(e, _, t, __PRIVATE_documentKeySet());\n }).next(function (e) {\n return {\n batchId: o,\n changes: __PRIVATE_convertOverlayedDocumentMapToDocumentMap(e)\n };\n });\n });\n });\n }\n }, {\n key: \"getDocumentsMatchingDocumentQuery\",\n value: function getDocumentsMatchingDocumentQuery(e, t) {\n // Just do a simple document lookup.\n return this.getDocument(e, new DocumentKey(t)).next(function (e) {\n var t = documentMap();\n return e.isFoundDocument() && (t = t.insert(e.key, e)), t;\n });\n }\n }, {\n key: \"getDocumentsMatchingCollectionGroupQuery\",\n value: function getDocumentsMatchingCollectionGroupQuery(e, t, n, r) {\n var _this106 = this;\n\n var i = t.collectionGroup;\n var s = documentMap();\n return this.indexManager.getCollectionParents(e, i).next(function (o) {\n return PersistencePromise.forEach(o, function (o) {\n var _ = function __PRIVATE_asCollectionQueryAtPath(e, t) {\n return new __PRIVATE_QueryImpl(t,\n /*collectionGroup=*/\n null, e.explicitOrderBy.slice(), e.filters.slice(), e.limit, e.limitType, e.startAt, e.endAt);\n }(t, o.child(i));\n\n return _this106.getDocumentsMatchingCollectionQuery(e, _, n, r).next(function (e) {\n e.forEach(function (e, t) {\n s = s.insert(e, t);\n });\n });\n }).next(function () {\n return s;\n });\n });\n }\n }, {\n key: \"getDocumentsMatchingCollectionQuery\",\n value: function getDocumentsMatchingCollectionQuery(e, t, n, r) {\n var _this107 = this;\n\n // Query the remote documents and overlay mutations.\n var i;\n return this.documentOverlayCache.getOverlaysForCollection(e, t.path, n.largestBatchId).next(function (s) {\n return i = s, _this107.remoteDocumentCache.getDocumentsMatchingQuery(e, t, n, i, r);\n }).next(function (e) {\n // As documents might match the query because of their overlay we need to\n // include documents for all overlays in the initial document set.\n i.forEach(function (t, n) {\n var r = n.getKey();\n null === e.get(r) && (e = e.insert(r, MutableDocument.newInvalidDocument(r)));\n }); // Apply the overlays and match against the query.\n\n var n = documentMap();\n return e.forEach(function (e, r) {\n var s = i.get(e);\n void 0 !== s && __PRIVATE_mutationApplyToLocalView(s.mutation, r, FieldMask.empty(), Timestamp.now()), // Finally, insert the documents that still match the query\n __PRIVATE_queryMatches(t, r) && (n = n.insert(e, r));\n }), n;\n });\n }\n }]);\n\n return LocalDocumentsView;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_MemoryBundleCache = /*#__PURE__*/function () {\n function __PRIVATE_MemoryBundleCache(e) {\n _classCallCheck(this, __PRIVATE_MemoryBundleCache);\n\n this.serializer = e, this.cr = new Map(), this.lr = new Map();\n }\n\n _createClass(__PRIVATE_MemoryBundleCache, [{\n key: \"getBundleMetadata\",\n value: function getBundleMetadata(e, t) {\n return PersistencePromise.resolve(this.cr.get(t));\n }\n }, {\n key: \"saveBundleMetadata\",\n value: function saveBundleMetadata(e, t) {\n return this.cr.set(t.id,\n /** Decodes a BundleMetadata proto into a BundleMetadata object. */\n function __PRIVATE_fromBundleMetadata(e) {\n return {\n id: e.id,\n version: e.version,\n createTime: __PRIVATE_fromVersion(e.createTime)\n };\n }(t)), PersistencePromise.resolve();\n }\n }, {\n key: \"getNamedQuery\",\n value: function getNamedQuery(e, t) {\n return PersistencePromise.resolve(this.lr.get(t));\n }\n }, {\n key: \"saveNamedQuery\",\n value: function saveNamedQuery(e, t) {\n return this.lr.set(t.name, function __PRIVATE_fromProtoNamedQuery(e) {\n return {\n name: e.name,\n query: __PRIVATE_fromBundledQuery(e.bundledQuery),\n readTime: __PRIVATE_fromVersion(e.readTime)\n };\n }(t)), PersistencePromise.resolve();\n }\n }]);\n\n return __PRIVATE_MemoryBundleCache;\n}();\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An in-memory implementation of DocumentOverlayCache.\n */\n\n\nvar __PRIVATE_MemoryDocumentOverlayCache = /*#__PURE__*/function () {\n function __PRIVATE_MemoryDocumentOverlayCache() {\n _classCallCheck(this, __PRIVATE_MemoryDocumentOverlayCache);\n\n // A map sorted by DocumentKey, whose value is a pair of the largest batch id\n // for the overlay and the overlay itself.\n this.overlays = new SortedMap(DocumentKey.comparator), this.hr = new Map();\n }\n\n _createClass(__PRIVATE_MemoryDocumentOverlayCache, [{\n key: \"getOverlay\",\n value: function getOverlay(e, t) {\n return PersistencePromise.resolve(this.overlays.get(t));\n }\n }, {\n key: \"getOverlays\",\n value: function getOverlays(e, t) {\n var _this108 = this;\n\n var n = __PRIVATE_newOverlayMap();\n\n return PersistencePromise.forEach(t, function (t) {\n return _this108.getOverlay(e, t).next(function (e) {\n null !== e && n.set(t, e);\n });\n }).next(function () {\n return n;\n });\n }\n }, {\n key: \"saveOverlays\",\n value: function saveOverlays(e, t, n) {\n var _this109 = this;\n\n return n.forEach(function (n, r) {\n _this109.ht(e, t, r);\n }), PersistencePromise.resolve();\n }\n }, {\n key: \"removeOverlaysForBatchId\",\n value: function removeOverlaysForBatchId(e, t, n) {\n var _this110 = this;\n\n var r = this.hr.get(n);\n return void 0 !== r && (r.forEach(function (e) {\n return _this110.overlays = _this110.overlays.remove(e);\n }), this.hr.delete(n)), PersistencePromise.resolve();\n }\n }, {\n key: \"getOverlaysForCollection\",\n value: function getOverlaysForCollection(e, t, n) {\n var r = __PRIVATE_newOverlayMap(),\n i = t.length + 1,\n s = new DocumentKey(t.child(\"\")),\n o = this.overlays.getIteratorFrom(s);\n\n for (; o.hasNext();) {\n var _e72 = o.getNext().value,\n _s5 = _e72.getKey();\n\n if (!t.isPrefixOf(_s5.path)) break; // Documents from sub-collections\n\n _s5.path.length === i && _e72.largestBatchId > n && r.set(_e72.getKey(), _e72);\n }\n\n return PersistencePromise.resolve(r);\n }\n }, {\n key: \"getOverlaysForCollectionGroup\",\n value: function getOverlaysForCollectionGroup(e, t, n, r) {\n var i = new SortedMap(function (e, t) {\n return e - t;\n });\n var s = this.overlays.getIterator();\n\n for (; s.hasNext();) {\n var _e73 = s.getNext().value;\n\n if (_e73.getKey().getCollectionGroup() === t && _e73.largestBatchId > n) {\n var _t36 = i.get(_e73.largestBatchId);\n\n null === _t36 && (_t36 = __PRIVATE_newOverlayMap(), i = i.insert(_e73.largestBatchId, _t36)), _t36.set(_e73.getKey(), _e73);\n }\n }\n\n var o = __PRIVATE_newOverlayMap(),\n _ = i.getIterator();\n\n for (; _.hasNext();) {\n if (_.getNext().value.forEach(function (e, t) {\n return o.set(e, t);\n }), o.size() >= r) break;\n }\n\n return PersistencePromise.resolve(o);\n }\n }, {\n key: \"ht\",\n value: function ht(e, t, n) {\n // Remove the association of the overlay to its batch id.\n var r = this.overlays.get(n.key);\n\n if (null !== r) {\n var _e74 = this.hr.get(r.largestBatchId).delete(n.key);\n\n this.hr.set(r.largestBatchId, _e74);\n }\n\n this.overlays = this.overlays.insert(n.key, new Overlay(t, n)); // Create the association of this overlay to the given largestBatchId.\n\n var i = this.hr.get(t);\n void 0 === i && (i = __PRIVATE_documentKeySet(), this.hr.set(t, i)), this.hr.set(t, i.add(n.key));\n }\n }]);\n\n return __PRIVATE_MemoryDocumentOverlayCache;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A collection of references to a document from some kind of numbered entity\n * (either a target ID or batch ID). As references are added to or removed from\n * the set corresponding events are emitted to a registered garbage collector.\n *\n * Each reference is represented by a DocumentReference object. Each of them\n * contains enough information to uniquely identify the reference. They are all\n * stored primarily in a set sorted by key. A document is considered garbage if\n * there's no references in that set (this can be efficiently checked thanks to\n * sorting by key).\n *\n * ReferenceSet also keeps a secondary set that contains references sorted by\n * IDs. This one is used to efficiently implement removal of all references by\n * some target ID.\n */\n\n\nvar __PRIVATE_ReferenceSet = /*#__PURE__*/function () {\n function __PRIVATE_ReferenceSet() {\n _classCallCheck(this, __PRIVATE_ReferenceSet);\n\n // A set of outstanding references to a document sorted by key.\n this.Pr = new SortedSet(__PRIVATE_DocReference.Ir), // A set of outstanding references to a document sorted by target id.\n this.Tr = new SortedSet(__PRIVATE_DocReference.Er);\n }\n /** Returns true if the reference set contains no references. */\n\n\n _createClass(__PRIVATE_ReferenceSet, [{\n key: \"isEmpty\",\n value: function isEmpty() {\n return this.Pr.isEmpty();\n }\n /** Adds a reference to the given document key for the given ID. */\n\n }, {\n key: \"addReference\",\n value: function addReference(e, t) {\n var n = new __PRIVATE_DocReference(e, t);\n this.Pr = this.Pr.add(n), this.Tr = this.Tr.add(n);\n }\n /** Add references to the given document keys for the given ID. */\n\n }, {\n key: \"dr\",\n value: function dr(e, t) {\n var _this111 = this;\n\n e.forEach(function (e) {\n return _this111.addReference(e, t);\n });\n }\n /**\n * Removes a reference to the given document key for the given\n * ID.\n */\n\n }, {\n key: \"removeReference\",\n value: function removeReference(e, t) {\n this.Ar(new __PRIVATE_DocReference(e, t));\n }\n }, {\n key: \"Rr\",\n value: function Rr(e, t) {\n var _this112 = this;\n\n e.forEach(function (e) {\n return _this112.removeReference(e, t);\n });\n }\n /**\n * Clears all references with a given ID. Calls removeRef() for each key\n * removed.\n */\n\n }, {\n key: \"Vr\",\n value: function Vr(e) {\n var _this113 = this;\n\n var t = new DocumentKey(new ResourcePath([])),\n n = new __PRIVATE_DocReference(t, e),\n r = new __PRIVATE_DocReference(t, e + 1),\n i = [];\n return this.Tr.forEachInRange([n, r], function (e) {\n _this113.Ar(e), i.push(e.key);\n }), i;\n }\n }, {\n key: \"mr\",\n value: function mr() {\n var _this114 = this;\n\n this.Pr.forEach(function (e) {\n return _this114.Ar(e);\n });\n }\n }, {\n key: \"Ar\",\n value: function Ar(e) {\n this.Pr = this.Pr.delete(e), this.Tr = this.Tr.delete(e);\n }\n }, {\n key: \"gr\",\n value: function gr(e) {\n var t = new DocumentKey(new ResourcePath([])),\n n = new __PRIVATE_DocReference(t, e),\n r = new __PRIVATE_DocReference(t, e + 1);\n\n var i = __PRIVATE_documentKeySet();\n\n return this.Tr.forEachInRange([n, r], function (e) {\n i = i.add(e.key);\n }), i;\n }\n }, {\n key: \"containsKey\",\n value: function containsKey(e) {\n var t = new __PRIVATE_DocReference(e, 0),\n n = this.Pr.firstAfterOrEqual(t);\n return null !== n && e.isEqual(n.key);\n }\n }]);\n\n return __PRIVATE_ReferenceSet;\n}();\n\nvar __PRIVATE_DocReference = /*#__PURE__*/function () {\n function __PRIVATE_DocReference(e, t) {\n _classCallCheck(this, __PRIVATE_DocReference);\n\n this.key = e, this.pr = t;\n }\n /** Compare by key then by ID */\n\n\n _createClass(__PRIVATE_DocReference, null, [{\n key: \"Ir\",\n value: function Ir(e, t) {\n return DocumentKey.comparator(e.key, t.key) || __PRIVATE_primitiveComparator(e.pr, t.pr);\n }\n /** Compare by ID then by key */\n\n }, {\n key: \"Er\",\n value: function Er(e, t) {\n return __PRIVATE_primitiveComparator(e.pr, t.pr) || DocumentKey.comparator(e.key, t.key);\n }\n }]);\n\n return __PRIVATE_DocReference;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_MemoryMutationQueue = /*#__PURE__*/function () {\n function __PRIVATE_MemoryMutationQueue(e, t) {\n _classCallCheck(this, __PRIVATE_MemoryMutationQueue);\n\n this.indexManager = e, this.referenceDelegate = t,\n /**\n * The set of all mutations that have been sent but not yet been applied to\n * the backend.\n */\n this.mutationQueue = [],\n /** Next value to use when assigning sequential IDs to each mutation batch. */\n this.yr = 1,\n /** An ordered mapping between documents and the mutations batch IDs. */\n this.wr = new SortedSet(__PRIVATE_DocReference.Ir);\n }\n\n _createClass(__PRIVATE_MemoryMutationQueue, [{\n key: \"checkEmpty\",\n value: function checkEmpty(e) {\n return PersistencePromise.resolve(0 === this.mutationQueue.length);\n }\n }, {\n key: \"addMutationBatch\",\n value: function addMutationBatch(e, t, n, r) {\n var i = this.yr;\n this.yr++, this.mutationQueue.length > 0 && this.mutationQueue[this.mutationQueue.length - 1];\n var s = new MutationBatch(i, t, n, r);\n this.mutationQueue.push(s); // Track references by document key and index collection parents.\n\n var _iterator57 = _createForOfIteratorHelper(r),\n _step57;\n\n try {\n for (_iterator57.s(); !(_step57 = _iterator57.n()).done;) {\n var _t37 = _step57.value;\n this.wr = this.wr.add(new __PRIVATE_DocReference(_t37.key, i)), this.indexManager.addToCollectionParentIndex(e, _t37.key.path.popLast());\n }\n } catch (err) {\n _iterator57.e(err);\n } finally {\n _iterator57.f();\n }\n\n return PersistencePromise.resolve(s);\n }\n }, {\n key: \"lookupMutationBatch\",\n value: function lookupMutationBatch(e, t) {\n return PersistencePromise.resolve(this.Sr(t));\n }\n }, {\n key: \"getNextMutationBatchAfterBatchId\",\n value: function getNextMutationBatchAfterBatchId(e, t) {\n var n = t + 1,\n r = this.br(n),\n i = r < 0 ? 0 : r; // The requested batchId may still be out of range so normalize it to the\n // start of the queue.\n\n return PersistencePromise.resolve(this.mutationQueue.length > i ? this.mutationQueue[i] : null);\n }\n }, {\n key: \"getHighestUnacknowledgedBatchId\",\n value: function getHighestUnacknowledgedBatchId() {\n return PersistencePromise.resolve(0 === this.mutationQueue.length ? -1 : this.yr - 1);\n }\n }, {\n key: \"getAllMutationBatches\",\n value: function getAllMutationBatches(e) {\n return PersistencePromise.resolve(this.mutationQueue.slice());\n }\n }, {\n key: \"getAllMutationBatchesAffectingDocumentKey\",\n value: function getAllMutationBatchesAffectingDocumentKey(e, t) {\n var _this115 = this;\n\n var n = new __PRIVATE_DocReference(t, 0),\n r = new __PRIVATE_DocReference(t, Number.POSITIVE_INFINITY),\n i = [];\n return this.wr.forEachInRange([n, r], function (e) {\n var t = _this115.Sr(e.pr);\n\n i.push(t);\n }), PersistencePromise.resolve(i);\n }\n }, {\n key: \"getAllMutationBatchesAffectingDocumentKeys\",\n value: function getAllMutationBatchesAffectingDocumentKeys(e, t) {\n var _this116 = this;\n\n var n = new SortedSet(__PRIVATE_primitiveComparator);\n return t.forEach(function (e) {\n var t = new __PRIVATE_DocReference(e, 0),\n r = new __PRIVATE_DocReference(e, Number.POSITIVE_INFINITY);\n\n _this116.wr.forEachInRange([t, r], function (e) {\n n = n.add(e.pr);\n });\n }), PersistencePromise.resolve(this.Dr(n));\n }\n }, {\n key: \"getAllMutationBatchesAffectingQuery\",\n value: function getAllMutationBatchesAffectingQuery(e, t) {\n // Use the query path as a prefix for testing if a document matches the\n // query.\n var n = t.path,\n r = n.length + 1; // Construct a document reference for actually scanning the index. Unlike\n // the prefix the document key in this reference must have an even number of\n // segments. The empty segment can be used a suffix of the query path\n // because it precedes all other segments in an ordered traversal.\n\n var i = n;\n DocumentKey.isDocumentKey(i) || (i = i.child(\"\"));\n var s = new __PRIVATE_DocReference(new DocumentKey(i), 0); // Find unique batchIDs referenced by all documents potentially matching the\n // query.\n\n var o = new SortedSet(__PRIVATE_primitiveComparator);\n return this.wr.forEachWhile(function (e) {\n var t = e.key.path;\n return !!n.isPrefixOf(t) && ( // Rows with document keys more than one segment longer than the query\n // path can't be matches. For example, a query on 'rooms' can't match\n // the document /rooms/abc/messages/xyx.\n // TODO(mcg): we'll need a different scanner when we implement\n // ancestor queries.\n t.length === r && (o = o.add(e.pr)), !0);\n }, s), PersistencePromise.resolve(this.Dr(o));\n }\n }, {\n key: \"Dr\",\n value: function Dr(e) {\n var _this117 = this;\n\n // Construct an array of matching batches, sorted by batchID to ensure that\n // multiple mutations affecting the same document key are applied in order.\n var t = [];\n return e.forEach(function (e) {\n var n = _this117.Sr(e);\n\n null !== n && t.push(n);\n }), t;\n }\n }, {\n key: \"removeMutationBatch\",\n value: function removeMutationBatch(e, t) {\n var _this118 = this;\n\n __PRIVATE_hardAssert(0 === this.Cr(t.batchId, \"removed\")), this.mutationQueue.shift();\n var n = this.wr;\n return PersistencePromise.forEach(t.mutations, function (r) {\n var i = new __PRIVATE_DocReference(r.key, t.batchId);\n return n = n.delete(i), _this118.referenceDelegate.markPotentiallyOrphaned(e, r.key);\n }).next(function () {\n _this118.wr = n;\n });\n }\n }, {\n key: \"Mn\",\n value: function Mn(e) {// No-op since the memory mutation queue does not maintain a separate cache.\n }\n }, {\n key: \"containsKey\",\n value: function containsKey(e, t) {\n var n = new __PRIVATE_DocReference(t, 0),\n r = this.wr.firstAfterOrEqual(n);\n return PersistencePromise.resolve(t.isEqual(r && r.key));\n }\n }, {\n key: \"performConsistencyCheck\",\n value: function performConsistencyCheck(e) {\n return this.mutationQueue.length, PersistencePromise.resolve();\n }\n /**\n * Finds the index of the given batchId in the mutation queue and asserts that\n * the resulting index is within the bounds of the queue.\n *\n * @param batchId - The batchId to search for\n * @param action - A description of what the caller is doing, phrased in passive\n * form (e.g. \"acknowledged\" in a routine that acknowledges batches).\n */\n\n }, {\n key: \"Cr\",\n value: function Cr(e, t) {\n return this.br(e);\n }\n /**\n * Finds the index of the given batchId in the mutation queue. This operation\n * is O(1).\n *\n * @returns The computed index of the batch with the given batchId, based on\n * the state of the queue. Note this index can be negative if the requested\n * batchId has already been remvoed from the queue or past the end of the\n * queue if the batchId is larger than the last added batch.\n */\n\n }, {\n key: \"br\",\n value: function br(e) {\n if (0 === this.mutationQueue.length) // As an index this is past the end of the queue\n return 0; // Examine the front of the queue to figure out the difference between the\n // batchId and indexes in the array. Note that since the queue is ordered\n // by batchId, if the first batch has a larger batchId then the requested\n // batchId doesn't exist in the queue.\n\n return e - this.mutationQueue[0].batchId;\n }\n /**\n * A version of lookupMutationBatch that doesn't return a promise, this makes\n * other functions that uses this code easier to read and more efficent.\n */\n\n }, {\n key: \"Sr\",\n value: function Sr(e) {\n var t = this.br(e);\n if (t < 0 || t >= this.mutationQueue.length) return null;\n return this.mutationQueue[t];\n }\n }]);\n\n return __PRIVATE_MemoryMutationQueue;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The memory-only RemoteDocumentCache for IndexedDb. To construct, invoke\n * `newMemoryRemoteDocumentCache()`.\n */\n\n\nvar __PRIVATE_MemoryRemoteDocumentCacheImpl = /*#__PURE__*/function () {\n /**\n * @param sizer - Used to assess the size of a document. For eager GC, this is\n * expected to just return 0 to avoid unnecessarily doing the work of\n * calculating the size.\n */\n function __PRIVATE_MemoryRemoteDocumentCacheImpl(e) {\n _classCallCheck(this, __PRIVATE_MemoryRemoteDocumentCacheImpl);\n\n this.vr = e,\n /** Underlying cache of documents and their read times. */\n this.docs = function __PRIVATE_documentEntryMap() {\n return new SortedMap(DocumentKey.comparator);\n }(),\n /** Size of all cached documents. */\n this.size = 0;\n }\n\n _createClass(__PRIVATE_MemoryRemoteDocumentCacheImpl, [{\n key: \"setIndexManager\",\n value: function setIndexManager(e) {\n this.indexManager = e;\n }\n /**\n * Adds the supplied entry to the cache and updates the cache size as appropriate.\n *\n * All calls of `addEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()`.\n */\n\n }, {\n key: \"addEntry\",\n value: function addEntry(e, t) {\n var n = t.key,\n r = this.docs.get(n),\n i = r ? r.size : 0,\n s = this.vr(t);\n return this.docs = this.docs.insert(n, {\n document: t.mutableCopy(),\n size: s\n }), this.size += s - i, this.indexManager.addToCollectionParentIndex(e, n.path.popLast());\n }\n /**\n * Removes the specified entry from the cache and updates the cache size as appropriate.\n *\n * All calls of `removeEntry` are required to go through the RemoteDocumentChangeBuffer\n * returned by `newChangeBuffer()`.\n */\n\n }, {\n key: \"removeEntry\",\n value: function removeEntry(e) {\n var t = this.docs.get(e);\n t && (this.docs = this.docs.remove(e), this.size -= t.size);\n }\n }, {\n key: \"getEntry\",\n value: function getEntry(e, t) {\n var n = this.docs.get(t);\n return PersistencePromise.resolve(n ? n.document.mutableCopy() : MutableDocument.newInvalidDocument(t));\n }\n }, {\n key: \"getEntries\",\n value: function getEntries(e, t) {\n var _this119 = this;\n\n var n = __PRIVATE_mutableDocumentMap();\n\n return t.forEach(function (e) {\n var t = _this119.docs.get(e);\n\n n = n.insert(e, t ? t.document.mutableCopy() : MutableDocument.newInvalidDocument(e));\n }), PersistencePromise.resolve(n);\n }\n }, {\n key: \"getDocumentsMatchingQuery\",\n value: function getDocumentsMatchingQuery(e, t, n, r) {\n var i = __PRIVATE_mutableDocumentMap(); // Documents are ordered by key, so we can use a prefix scan to narrow down\n // the documents we need to match the query against.\n\n\n var s = t.path,\n o = new DocumentKey(s.child(\"\")),\n _ = this.docs.getIteratorFrom(o);\n\n for (; _.hasNext();) {\n var _$getNext = _.getNext(),\n _e75 = _$getNext.key,\n _o4 = _$getNext.value.document;\n\n if (!s.isPrefixOf(_e75.path)) break;\n _e75.path.length > s.length + 1 || __PRIVATE_indexOffsetComparator(__PRIVATE_newIndexOffsetFromDocument(_o4), n) <= 0 || (r.has(_o4.key) || __PRIVATE_queryMatches(t, _o4)) && (i = i.insert(_o4.key, _o4.mutableCopy()));\n }\n\n return PersistencePromise.resolve(i);\n }\n }, {\n key: \"getAllFromCollectionGroup\",\n value: function getAllFromCollectionGroup(e, t, n, r) {\n // This method should only be called from the IndexBackfiller if persistence\n // is enabled.\n fail();\n }\n }, {\n key: \"Fr\",\n value: function Fr(e, t) {\n return PersistencePromise.forEach(this.docs, function (e) {\n return t(e);\n });\n }\n }, {\n key: \"newChangeBuffer\",\n value: function newChangeBuffer(e) {\n // `trackRemovals` is ignores since the MemoryRemoteDocumentCache keeps\n // a separate changelog and does not need special handling for removals.\n return new __PRIVATE_MemoryRemoteDocumentChangeBuffer(this);\n }\n }, {\n key: \"getSize\",\n value: function getSize(e) {\n return PersistencePromise.resolve(this.size);\n }\n }]);\n\n return __PRIVATE_MemoryRemoteDocumentCacheImpl;\n}();\n/**\n * Creates a new memory-only RemoteDocumentCache.\n *\n * @param sizer - Used to assess the size of a document. For eager GC, this is\n * expected to just return 0 to avoid unnecessarily doing the work of\n * calculating the size.\n */\n\n/**\n * Handles the details of adding and updating documents in the MemoryRemoteDocumentCache.\n */\n\n\nvar __PRIVATE_MemoryRemoteDocumentChangeBuffer = /*#__PURE__*/function (_RemoteDocumentChange2) {\n _inherits(__PRIVATE_MemoryRemoteDocumentChangeBuffer, _RemoteDocumentChange2);\n\n var _super26 = _createSuper(__PRIVATE_MemoryRemoteDocumentChangeBuffer);\n\n function __PRIVATE_MemoryRemoteDocumentChangeBuffer(e) {\n var _this120;\n\n _classCallCheck(this, __PRIVATE_MemoryRemoteDocumentChangeBuffer);\n\n _this120 = _super26.call(this), _this120.ar = e;\n return _this120;\n }\n\n _createClass(__PRIVATE_MemoryRemoteDocumentChangeBuffer, [{\n key: \"applyChanges\",\n value: function applyChanges(e) {\n var _this121 = this;\n\n var t = [];\n return this.changes.forEach(function (n, r) {\n r.isValidDocument() ? t.push(_this121.ar.addEntry(e, r)) : _this121.ar.removeEntry(n);\n }), PersistencePromise.waitFor(t);\n }\n }, {\n key: \"getFromCache\",\n value: function getFromCache(e, t) {\n return this.ar.getEntry(e, t);\n }\n }, {\n key: \"getAllFromCache\",\n value: function getAllFromCache(e, t) {\n return this.ar.getEntries(e, t);\n }\n }]);\n\n return __PRIVATE_MemoryRemoteDocumentChangeBuffer;\n}(RemoteDocumentChangeBuffer);\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_MemoryTargetCache = /*#__PURE__*/function () {\n function __PRIVATE_MemoryTargetCache(e) {\n _classCallCheck(this, __PRIVATE_MemoryTargetCache);\n\n this.persistence = e,\n /**\n * Maps a target to the data about that target\n */\n this.Mr = new ObjectMap(function (e) {\n return __PRIVATE_canonifyTarget(e);\n }, __PRIVATE_targetEquals),\n /** The last received snapshot version. */\n this.lastRemoteSnapshotVersion = SnapshotVersion.min(),\n /** The highest numbered target ID encountered. */\n this.highestTargetId = 0,\n /** The highest sequence number encountered. */\n this.Or = 0,\n /**\n * A ordered bidirectional mapping between documents and the remote target\n * IDs.\n */\n this.Nr = new __PRIVATE_ReferenceSet(), this.targetCount = 0, this.Br = __PRIVATE_TargetIdGenerator.Nn();\n }\n\n _createClass(__PRIVATE_MemoryTargetCache, [{\n key: \"forEachTarget\",\n value: function forEachTarget(e, t) {\n return this.Mr.forEach(function (e, n) {\n return t(n);\n }), PersistencePromise.resolve();\n }\n }, {\n key: \"getLastRemoteSnapshotVersion\",\n value: function getLastRemoteSnapshotVersion(e) {\n return PersistencePromise.resolve(this.lastRemoteSnapshotVersion);\n }\n }, {\n key: \"getHighestSequenceNumber\",\n value: function getHighestSequenceNumber(e) {\n return PersistencePromise.resolve(this.Or);\n }\n }, {\n key: \"allocateTargetId\",\n value: function allocateTargetId(e) {\n return this.highestTargetId = this.Br.next(), PersistencePromise.resolve(this.highestTargetId);\n }\n }, {\n key: \"setTargetsMetadata\",\n value: function setTargetsMetadata(e, t, n) {\n return n && (this.lastRemoteSnapshotVersion = n), t > this.Or && (this.Or = t), PersistencePromise.resolve();\n }\n }, {\n key: \"qn\",\n value: function qn(e) {\n this.Mr.set(e.target, e);\n var t = e.targetId;\n t > this.highestTargetId && (this.Br = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t), e.sequenceNumber > this.Or && (this.Or = e.sequenceNumber);\n }\n }, {\n key: \"addTargetData\",\n value: function addTargetData(e, t) {\n return this.qn(t), this.targetCount += 1, PersistencePromise.resolve();\n }\n }, {\n key: \"updateTargetData\",\n value: function updateTargetData(e, t) {\n return this.qn(t), PersistencePromise.resolve();\n }\n }, {\n key: \"removeTargetData\",\n value: function removeTargetData(e, t) {\n return this.Mr.delete(t.target), this.Nr.Vr(t.targetId), this.targetCount -= 1, PersistencePromise.resolve();\n }\n }, {\n key: \"removeTargets\",\n value: function removeTargets(e, t, n) {\n var _this122 = this;\n\n var r = 0;\n var i = [];\n return this.Mr.forEach(function (s, o) {\n o.sequenceNumber <= t && null === n.get(o.targetId) && (_this122.Mr.delete(s), i.push(_this122.removeMatchingKeysForTargetId(e, o.targetId)), r++);\n }), PersistencePromise.waitFor(i).next(function () {\n return r;\n });\n }\n }, {\n key: \"getTargetCount\",\n value: function getTargetCount(e) {\n return PersistencePromise.resolve(this.targetCount);\n }\n }, {\n key: \"getTargetData\",\n value: function getTargetData(e, t) {\n var n = this.Mr.get(t) || null;\n return PersistencePromise.resolve(n);\n }\n }, {\n key: \"addMatchingKeys\",\n value: function addMatchingKeys(e, t, n) {\n return this.Nr.dr(t, n), PersistencePromise.resolve();\n }\n }, {\n key: \"removeMatchingKeys\",\n value: function removeMatchingKeys(e, t, n) {\n this.Nr.Rr(t, n);\n var r = this.persistence.referenceDelegate,\n i = [];\n return r && t.forEach(function (t) {\n i.push(r.markPotentiallyOrphaned(e, t));\n }), PersistencePromise.waitFor(i);\n }\n }, {\n key: \"removeMatchingKeysForTargetId\",\n value: function removeMatchingKeysForTargetId(e, t) {\n return this.Nr.Vr(t), PersistencePromise.resolve();\n }\n }, {\n key: \"getMatchingKeysForTargetId\",\n value: function getMatchingKeysForTargetId(e, t) {\n var n = this.Nr.gr(t);\n return PersistencePromise.resolve(n);\n }\n }, {\n key: \"containsKey\",\n value: function containsKey(e, t) {\n return PersistencePromise.resolve(this.Nr.containsKey(t));\n }\n }]);\n\n return __PRIVATE_MemoryTargetCache;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A memory-backed instance of Persistence. Data is stored only in RAM and\n * not persisted across sessions.\n */\n\n\nvar __PRIVATE_MemoryPersistence = /*#__PURE__*/function () {\n /**\n * The constructor accepts a factory for creating a reference delegate. This\n * allows both the delegate and this instance to have strong references to\n * each other without having nullable fields that would then need to be\n * checked or asserted on every access.\n */\n function __PRIVATE_MemoryPersistence(e, t) {\n var _this123 = this;\n\n _classCallCheck(this, __PRIVATE_MemoryPersistence);\n\n this.Lr = {}, this.overlays = {}, this.kr = new __PRIVATE_ListenSequence(0), this.qr = !1, this.qr = !0, this.referenceDelegate = e(this), this.Qr = new __PRIVATE_MemoryTargetCache(this);\n this.indexManager = new __PRIVATE_MemoryIndexManager(), this.remoteDocumentCache = function __PRIVATE_newMemoryRemoteDocumentCache(e) {\n return new __PRIVATE_MemoryRemoteDocumentCacheImpl(e);\n }(function (e) {\n return _this123.referenceDelegate.Kr(e);\n }), this.serializer = new __PRIVATE_LocalSerializer(t), this.$r = new __PRIVATE_MemoryBundleCache(this.serializer);\n }\n\n _createClass(__PRIVATE_MemoryPersistence, [{\n key: \"start\",\n value: function start() {\n return Promise.resolve();\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {\n // No durable state to ensure is closed on shutdown.\n return this.qr = !1, Promise.resolve();\n }\n }, {\n key: \"started\",\n get: function get() {\n return this.qr;\n }\n }, {\n key: \"setDatabaseDeletedListener\",\n value: function setDatabaseDeletedListener() {// No op.\n }\n }, {\n key: \"setNetworkEnabled\",\n value: function setNetworkEnabled() {// No op.\n }\n }, {\n key: \"getIndexManager\",\n value: function getIndexManager(e) {\n // We do not currently support indices for memory persistence, so we can\n // return the same shared instance of the memory index manager.\n return this.indexManager;\n }\n }, {\n key: \"getDocumentOverlayCache\",\n value: function getDocumentOverlayCache(e) {\n var t = this.overlays[e.toKey()];\n return t || (t = new __PRIVATE_MemoryDocumentOverlayCache(), this.overlays[e.toKey()] = t), t;\n }\n }, {\n key: \"getMutationQueue\",\n value: function getMutationQueue(e, t) {\n var n = this.Lr[e.toKey()];\n return n || (n = new __PRIVATE_MemoryMutationQueue(t, this.referenceDelegate), this.Lr[e.toKey()] = n), n;\n }\n }, {\n key: \"getTargetCache\",\n value: function getTargetCache() {\n return this.Qr;\n }\n }, {\n key: \"getRemoteDocumentCache\",\n value: function getRemoteDocumentCache() {\n return this.remoteDocumentCache;\n }\n }, {\n key: \"getBundleCache\",\n value: function getBundleCache() {\n return this.$r;\n }\n }, {\n key: \"runTransaction\",\n value: function runTransaction(e, t, n) {\n var _this124 = this;\n\n __PRIVATE_logDebug(\"MemoryPersistence\", \"Starting transaction:\", e);\n\n var r = new __PRIVATE_MemoryTransaction(this.kr.next());\n return this.referenceDelegate.Ur(), n(r).next(function (e) {\n return _this124.referenceDelegate.Wr(r).next(function () {\n return e;\n });\n }).toPromise().then(function (e) {\n return r.raiseOnCommittedEvent(), e;\n });\n }\n }, {\n key: \"Gr\",\n value: function Gr(e, t) {\n return PersistencePromise.or(Object.values(this.Lr).map(function (n) {\n return function () {\n return n.containsKey(e, t);\n };\n }));\n }\n }]);\n\n return __PRIVATE_MemoryPersistence;\n}();\n/**\n * Memory persistence is not actually transactional, but future implementations\n * may have transaction-scoped state.\n */\n\n\nvar __PRIVATE_MemoryTransaction = /*#__PURE__*/function (_PersistenceTransacti2) {\n _inherits(__PRIVATE_MemoryTransaction, _PersistenceTransacti2);\n\n var _super27 = _createSuper(__PRIVATE_MemoryTransaction);\n\n function __PRIVATE_MemoryTransaction(e) {\n var _this125;\n\n _classCallCheck(this, __PRIVATE_MemoryTransaction);\n\n _this125 = _super27.call(this), _this125.currentSequenceNumber = e;\n return _this125;\n }\n\n return _createClass(__PRIVATE_MemoryTransaction);\n}(PersistenceTransaction);\n\nvar __PRIVATE_MemoryEagerDelegate = /*#__PURE__*/function () {\n function __PRIVATE_MemoryEagerDelegate(e) {\n _classCallCheck(this, __PRIVATE_MemoryEagerDelegate);\n\n this.persistence = e,\n /** Tracks all documents that are active in Query views. */\n this.zr = new __PRIVATE_ReferenceSet(),\n /** The list of documents that are potentially GCed after each transaction. */\n this.jr = null;\n }\n\n _createClass(__PRIVATE_MemoryEagerDelegate, [{\n key: \"Jr\",\n get: function get() {\n if (this.jr) return this.jr;\n throw fail();\n }\n }, {\n key: \"addReference\",\n value: function addReference(e, t, n) {\n return this.zr.addReference(n, t), this.Jr.delete(n.toString()), PersistencePromise.resolve();\n }\n }, {\n key: \"removeReference\",\n value: function removeReference(e, t, n) {\n return this.zr.removeReference(n, t), this.Jr.add(n.toString()), PersistencePromise.resolve();\n }\n }, {\n key: \"markPotentiallyOrphaned\",\n value: function markPotentiallyOrphaned(e, t) {\n return this.Jr.add(t.toString()), PersistencePromise.resolve();\n }\n }, {\n key: \"removeTarget\",\n value: function removeTarget(e, t) {\n var _this126 = this;\n\n this.zr.Vr(t.targetId).forEach(function (e) {\n return _this126.Jr.add(e.toString());\n });\n var n = this.persistence.getTargetCache();\n return n.getMatchingKeysForTargetId(e, t.targetId).next(function (e) {\n e.forEach(function (e) {\n return _this126.Jr.add(e.toString());\n });\n }).next(function () {\n return n.removeTargetData(e, t);\n });\n }\n }, {\n key: \"Ur\",\n value: function Ur() {\n this.jr = new Set();\n }\n }, {\n key: \"Wr\",\n value: function Wr(e) {\n var _this127 = this;\n\n // Remove newly orphaned documents.\n var t = this.persistence.getRemoteDocumentCache().newChangeBuffer();\n return PersistencePromise.forEach(this.Jr, function (n) {\n var r = DocumentKey.fromPath(n);\n return _this127.Yr(e, r).next(function (e) {\n e || t.removeEntry(r, SnapshotVersion.min());\n });\n }).next(function () {\n return _this127.jr = null, t.apply(e);\n });\n }\n }, {\n key: \"updateLimboDocument\",\n value: function updateLimboDocument(e, t) {\n var _this128 = this;\n\n return this.Yr(e, t).next(function (e) {\n e ? _this128.Jr.delete(t.toString()) : _this128.Jr.add(t.toString());\n });\n }\n }, {\n key: \"Kr\",\n value: function Kr(e) {\n // For eager GC, we don't care about the document size, there are no size thresholds.\n return 0;\n }\n }, {\n key: \"Yr\",\n value: function Yr(e, t) {\n var _this129 = this;\n\n return PersistencePromise.or([function () {\n return PersistencePromise.resolve(_this129.zr.containsKey(t));\n }, function () {\n return _this129.persistence.getTargetCache().containsKey(e, t);\n }, function () {\n return _this129.persistence.Gr(e, t);\n }]);\n }\n }], [{\n key: \"Hr\",\n value: function Hr(e) {\n return new __PRIVATE_MemoryEagerDelegate(e);\n }\n }]);\n\n return __PRIVATE_MemoryEagerDelegate;\n}();\n\nvar __PRIVATE_MemoryLruDelegate = /*#__PURE__*/function () {\n function __PRIVATE_MemoryLruDelegate(e, t) {\n _classCallCheck(this, __PRIVATE_MemoryLruDelegate);\n\n this.persistence = e, this.Zr = new ObjectMap(function (e) {\n return __PRIVATE_encodeResourcePath(e.path);\n }, function (e, t) {\n return e.isEqual(t);\n }), this.garbageCollector = __PRIVATE_newLruGarbageCollector(this, t);\n }\n\n _createClass(__PRIVATE_MemoryLruDelegate, [{\n key: \"Ur\",\n value: // No-ops, present so memory persistence doesn't have to care which delegate\n // it has.\n function Ur() {}\n }, {\n key: \"Wr\",\n value: function Wr(e) {\n return PersistencePromise.resolve();\n }\n }, {\n key: \"forEachTarget\",\n value: function forEachTarget(e, t) {\n return this.persistence.getTargetCache().forEachTarget(e, t);\n }\n }, {\n key: \"Hn\",\n value: function Hn(e) {\n var t = this.Zn(e);\n return this.persistence.getTargetCache().getTargetCount(e).next(function (e) {\n return t.next(function (t) {\n return e + t;\n });\n });\n }\n }, {\n key: \"Zn\",\n value: function Zn(e) {\n var t = 0;\n return this.Jn(e, function (e) {\n t++;\n }).next(function () {\n return t;\n });\n }\n }, {\n key: \"Jn\",\n value: function Jn(e, t) {\n var _this130 = this;\n\n return PersistencePromise.forEach(this.Zr, function (n, r) {\n return _this130.er(e, n, r).next(function (e) {\n return e ? PersistencePromise.resolve() : t(r);\n });\n });\n }\n }, {\n key: \"removeTargets\",\n value: function removeTargets(e, t, n) {\n return this.persistence.getTargetCache().removeTargets(e, t, n);\n }\n }, {\n key: \"removeOrphanedDocuments\",\n value: function removeOrphanedDocuments(e, t) {\n var _this131 = this;\n\n var n = 0;\n var r = this.persistence.getRemoteDocumentCache(),\n i = r.newChangeBuffer();\n return r.Fr(e, function (r) {\n return _this131.er(e, r, t).next(function (e) {\n e || (n++, i.removeEntry(r, SnapshotVersion.min()));\n });\n }).next(function () {\n return i.apply(e);\n }).next(function () {\n return n;\n });\n }\n }, {\n key: \"markPotentiallyOrphaned\",\n value: function markPotentiallyOrphaned(e, t) {\n return this.Zr.set(t, e.currentSequenceNumber), PersistencePromise.resolve();\n }\n }, {\n key: \"removeTarget\",\n value: function removeTarget(e, t) {\n var n = t.withSequenceNumber(e.currentSequenceNumber);\n return this.persistence.getTargetCache().updateTargetData(e, n);\n }\n }, {\n key: \"addReference\",\n value: function addReference(e, t, n) {\n return this.Zr.set(n, e.currentSequenceNumber), PersistencePromise.resolve();\n }\n }, {\n key: \"removeReference\",\n value: function removeReference(e, t, n) {\n return this.Zr.set(n, e.currentSequenceNumber), PersistencePromise.resolve();\n }\n }, {\n key: \"updateLimboDocument\",\n value: function updateLimboDocument(e, t) {\n return this.Zr.set(t, e.currentSequenceNumber), PersistencePromise.resolve();\n }\n }, {\n key: \"Kr\",\n value: function Kr(e) {\n var t = e.key.toString().length;\n return e.isFoundDocument() && (t += __PRIVATE_estimateByteSize(e.data.value)), t;\n }\n }, {\n key: \"er\",\n value: function er(e, t, n) {\n var _this132 = this;\n\n return PersistencePromise.or([function () {\n return _this132.persistence.Gr(e, t);\n }, function () {\n return _this132.persistence.getTargetCache().containsKey(e, t);\n }, function () {\n var e = _this132.Zr.get(t);\n\n return PersistencePromise.resolve(void 0 !== e && e > n);\n }]);\n }\n }, {\n key: \"getCacheSize\",\n value: function getCacheSize(e) {\n return this.persistence.getRemoteDocumentCache().getSize(e);\n }\n }], [{\n key: \"Hr\",\n value: function Hr(e, t) {\n return new __PRIVATE_MemoryLruDelegate(e, t);\n }\n }]);\n\n return __PRIVATE_MemoryLruDelegate;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Performs database creation and schema upgrades. */\n\n\nvar __PRIVATE_SchemaConverter = /*#__PURE__*/function () {\n function __PRIVATE_SchemaConverter(e) {\n _classCallCheck(this, __PRIVATE_SchemaConverter);\n\n this.serializer = e;\n }\n /**\n * Performs database creation and schema upgrades.\n *\n * Note that in production, this method is only ever used to upgrade the schema\n * to SCHEMA_VERSION. Different values of toVersion are only used for testing\n * and local feature development.\n */\n\n\n _createClass(__PRIVATE_SchemaConverter, [{\n key: \"N\",\n value: function N(e, t, n, r) {\n var _this133 = this;\n\n var i = new __PRIVATE_SimpleDbTransaction(\"createOrUpgrade\", t);\n n < 1 && r >= 1 && (!function __PRIVATE_createPrimaryClientStore(e) {\n e.createObjectStore(\"owner\");\n }(e), function __PRIVATE_createMutationQueue(e) {\n e.createObjectStore(\"mutationQueues\", {\n keyPath: \"userId\"\n });\n e.createObjectStore(\"mutations\", {\n keyPath: \"batchId\",\n autoIncrement: !0\n }).createIndex(\"userMutationsIndex\", M, {\n unique: !0\n }), e.createObjectStore(\"documentMutations\");\n }\n /**\n * Upgrade function to migrate the 'mutations' store from V1 to V3. Loads\n * and rewrites all data.\n */\n (e), __PRIVATE_createQueryCache(e), function __PRIVATE_createLegacyRemoteDocumentCache(e) {\n e.createObjectStore(\"remoteDocuments\");\n }(e)); // Migration 2 to populate the targetGlobal object no longer needed since\n // migration 3 unconditionally clears it.\n\n var s = PersistencePromise.resolve();\n return n < 3 && r >= 3 && ( // Brand new clients don't need to drop and recreate--only clients that\n // potentially have corrupt data.\n 0 !== n && (!function __PRIVATE_dropQueryCache(e) {\n e.deleteObjectStore(\"targetDocuments\"), e.deleteObjectStore(\"targets\"), e.deleteObjectStore(\"targetGlobal\");\n }(e), __PRIVATE_createQueryCache(e)), s = s.next(function () {\n return (\n /**\n * Creates the target global singleton row.\n *\n * @param txn - The version upgrade transaction for indexeddb\n */\n function __PRIVATE_writeEmptyTargetGlobalEntry(e) {\n var t = e.store(\"targetGlobal\"),\n n = {\n highestTargetId: 0,\n highestListenSequenceNumber: 0,\n lastRemoteSnapshotVersion: SnapshotVersion.min().toTimestamp(),\n targetCount: 0\n };\n return t.put(\"targetGlobalKey\", n);\n }(i)\n );\n })), n < 4 && r >= 4 && (0 !== n && ( // Schema version 3 uses auto-generated keys to generate globally unique\n // mutation batch IDs (this was previously ensured internally by the\n // client). To migrate to the new schema, we have to read all mutations\n // and write them back out. We preserve the existing batch IDs to guarantee\n // consistency with other object stores. Any further mutation batch IDs will\n // be auto-generated.\n s = s.next(function () {\n return function __PRIVATE_upgradeMutationBatchSchemaAndMigrateData(e, t) {\n return t.store(\"mutations\").W().next(function (n) {\n e.deleteObjectStore(\"mutations\");\n e.createObjectStore(\"mutations\", {\n keyPath: \"batchId\",\n autoIncrement: !0\n }).createIndex(\"userMutationsIndex\", M, {\n unique: !0\n });\n var r = t.store(\"mutations\"),\n i = n.map(function (e) {\n return r.put(e);\n });\n return PersistencePromise.waitFor(i);\n });\n }(e, i);\n })), s = s.next(function () {\n !function __PRIVATE_createClientMetadataStore(e) {\n e.createObjectStore(\"clientMetadata\", {\n keyPath: \"clientId\"\n });\n }(e);\n })), n < 5 && r >= 5 && (s = s.next(function () {\n return _this133.Xr(i);\n })), n < 6 && r >= 6 && (s = s.next(function () {\n return function __PRIVATE_createDocumentGlobalStore(e) {\n e.createObjectStore(\"remoteDocumentGlobal\");\n }(e), _this133.ei(i);\n })), n < 7 && r >= 7 && (s = s.next(function () {\n return _this133.ti(i);\n })), n < 8 && r >= 8 && (s = s.next(function () {\n return _this133.ni(e, i);\n })), n < 9 && r >= 9 && (s = s.next(function () {\n // Multi-Tab used to manage its own changelog, but this has been moved\n // to the DbRemoteDocument object store itself. Since the previous change\n // log only contained transient data, we can drop its object store.\n !function __PRIVATE_dropRemoteDocumentChangesStore(e) {\n e.objectStoreNames.contains(\"remoteDocumentChanges\") && e.deleteObjectStore(\"remoteDocumentChanges\");\n }(e); // Note: Schema version 9 used to create a read time index for the\n // RemoteDocumentCache. This is now done with schema version 13.\n })), n < 10 && r >= 10 && (s = s.next(function () {\n return _this133.ri(i);\n })), n < 11 && r >= 11 && (s = s.next(function () {\n !function __PRIVATE_createBundlesStore(e) {\n e.createObjectStore(\"bundles\", {\n keyPath: \"bundleId\"\n });\n }(e), function __PRIVATE_createNamedQueriesStore(e) {\n e.createObjectStore(\"namedQueries\", {\n keyPath: \"name\"\n });\n }(e);\n })), n < 12 && r >= 12 && (s = s.next(function () {\n !function __PRIVATE_createDocumentOverlayStore(e) {\n var t = e.createObjectStore(\"documentOverlays\", {\n keyPath: G\n });\n t.createIndex(\"collectionPathOverlayIndex\", z, {\n unique: !1\n }), t.createIndex(\"collectionGroupOverlayIndex\", j, {\n unique: !1\n });\n }(e);\n })), n < 13 && r >= 13 && (s = s.next(function () {\n return function __PRIVATE_createRemoteDocumentCache(e) {\n var t = e.createObjectStore(\"remoteDocumentsV14\", {\n keyPath: O\n });\n t.createIndex(\"documentKeyIndex\", _N), t.createIndex(\"collectionGroupIndex\", B);\n }(e);\n }).next(function () {\n return _this133.ii(e, i);\n }).next(function () {\n return e.deleteObjectStore(\"remoteDocuments\");\n })), n < 14 && r >= 14 && (s = s.next(function () {\n return _this133.si(e, i);\n })), n < 15 && r >= 15 && (s = s.next(function () {\n return function __PRIVATE_createFieldIndex(e) {\n e.createObjectStore(\"indexConfiguration\", {\n keyPath: \"indexId\",\n autoIncrement: !0\n }).createIndex(\"collectionGroupIndex\", \"collectionGroup\", {\n unique: !1\n });\n e.createObjectStore(\"indexState\", {\n keyPath: K\n }).createIndex(\"sequenceNumberIndex\", $, {\n unique: !1\n });\n e.createObjectStore(\"indexEntries\", {\n keyPath: U\n }).createIndex(\"documentKeyIndex\", W, {\n unique: !1\n });\n }(e);\n })), s;\n }\n }, {\n key: \"ei\",\n value: function ei(e) {\n var t = 0;\n return e.store(\"remoteDocuments\").Y(function (e, n) {\n t += __PRIVATE_dbDocumentSize(n);\n }).next(function () {\n var n = {\n byteSize: t\n };\n return e.store(\"remoteDocumentGlobal\").put(\"remoteDocumentGlobalKey\", n);\n });\n }\n }, {\n key: \"Xr\",\n value: function Xr(e) {\n var _this134 = this;\n\n var t = e.store(\"mutationQueues\"),\n n = e.store(\"mutations\");\n return t.W().next(function (t) {\n return PersistencePromise.forEach(t, function (t) {\n var r = IDBKeyRange.bound([t.userId, -1], [t.userId, t.lastAcknowledgedBatchId]);\n return n.W(\"userMutationsIndex\", r).next(function (n) {\n return PersistencePromise.forEach(n, function (n) {\n __PRIVATE_hardAssert(n.userId === t.userId);\n\n var r = __PRIVATE_fromDbMutationBatch(_this134.serializer, n);\n\n return _removeMutationBatch(e, t.userId, r).next(function () {});\n });\n });\n });\n });\n }\n /**\n * Ensures that every document in the remote document cache has a corresponding sentinel row\n * with a sequence number. Missing rows are given the most recently used sequence number.\n */\n\n }, {\n key: \"ti\",\n value: function ti(e) {\n var t = e.store(\"targetDocuments\"),\n n = e.store(\"remoteDocuments\");\n return e.store(\"targetGlobal\").get(\"targetGlobalKey\").next(function (e) {\n var r = [];\n return n.Y(function (n, i) {\n var s = new ResourcePath(n),\n o = function __PRIVATE_sentinelKey(e) {\n return [0, __PRIVATE_encodeResourcePath(e)];\n }(s);\n\n r.push(t.get(o).next(function (n) {\n return n ? PersistencePromise.resolve() : function (n) {\n return t.put({\n targetId: 0,\n path: __PRIVATE_encodeResourcePath(n),\n sequenceNumber: e.highestListenSequenceNumber\n });\n }(s);\n }));\n }).next(function () {\n return PersistencePromise.waitFor(r);\n });\n });\n }\n }, {\n key: \"ni\",\n value: function ni(e, t) {\n // Create the index.\n e.createObjectStore(\"collectionParents\", {\n keyPath: Q\n });\n\n var n = t.store(\"collectionParents\"),\n r = new __PRIVATE_MemoryCollectionParentIndex(),\n addEntry = function addEntry(e) {\n if (r.add(e)) {\n var _t38 = e.lastSegment(),\n _r21 = e.popLast();\n\n return n.put({\n collectionId: _t38,\n parent: __PRIVATE_encodeResourcePath(_r21)\n });\n }\n }; // Helper to add an index entry iff we haven't already written it.\n // Index existing remote documents.\n\n\n return t.store(\"remoteDocuments\").Y({\n J: !0\n }, function (e, t) {\n var n = new ResourcePath(e);\n return addEntry(n.popLast());\n }).next(function () {\n return t.store(\"documentMutations\").Y({\n J: !0\n }, function (_ref16, r) {\n var _ref17 = _slicedToArray(_ref16, 3),\n e = _ref17[0],\n t = _ref17[1],\n n = _ref17[2];\n\n var i = __PRIVATE_decodeResourcePath(t);\n\n return addEntry(i.popLast());\n });\n });\n }\n }, {\n key: \"ri\",\n value: function ri(e) {\n var _this135 = this;\n\n var t = e.store(\"targets\");\n return t.Y(function (e, n) {\n var r = __PRIVATE_fromDbTarget(n),\n i = __PRIVATE_toDbTarget(_this135.serializer, r);\n\n return t.put(i);\n });\n }\n }, {\n key: \"ii\",\n value: function ii(e, t) {\n var n = t.store(\"remoteDocuments\"),\n r = [];\n return n.Y(function (e, n) {\n var i = t.store(\"remoteDocumentsV14\"),\n s = function __PRIVATE_extractKey(e) {\n return e.document ? new DocumentKey(ResourcePath.fromString(e.document.name).popFirst(5)) : e.noDocument ? DocumentKey.fromSegments(e.noDocument.path) : e.unknownDocument ? DocumentKey.fromSegments(e.unknownDocument.path) : fail();\n }\n /**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n (n).path.toArray(),\n o = {\n prefixPath: s.slice(0, s.length - 2),\n collectionGroup: s[s.length - 2],\n documentId: s[s.length - 1],\n readTime: n.readTime || [0, 0],\n unknownDocument: n.unknownDocument,\n noDocument: n.noDocument,\n document: n.document,\n hasCommittedMutations: !!n.hasCommittedMutations\n };\n\n r.push(i.put(o));\n }).next(function () {\n return PersistencePromise.waitFor(r);\n });\n }\n }, {\n key: \"si\",\n value: function si(e, t) {\n var _this136 = this;\n\n var n = t.store(\"mutations\"),\n r = __PRIVATE_newIndexedDbRemoteDocumentCache(this.serializer),\n i = new __PRIVATE_MemoryPersistence(__PRIVATE_MemoryEagerDelegate.Hr, this.serializer.ct);\n\n return n.W().next(function (e) {\n var n = new Map();\n return e.forEach(function (e) {\n var t;\n var r = null !== (t = n.get(e.userId)) && void 0 !== t ? t : __PRIVATE_documentKeySet();\n __PRIVATE_fromDbMutationBatch(_this136.serializer, e).keys().forEach(function (e) {\n return r = r.add(e);\n }), n.set(e.userId, r);\n }), PersistencePromise.forEach(n, function (e, n) {\n var s = new User(n),\n o = __PRIVATE_IndexedDbDocumentOverlayCache.lt(_this136.serializer, s),\n _ = i.getIndexManager(s),\n a = __PRIVATE_IndexedDbMutationQueue.lt(s, _this136.serializer, _, i.referenceDelegate);\n\n return new LocalDocumentsView(r, a, o, _).recalculateAndSaveOverlaysForDocumentKeys(new __PRIVATE_IndexedDbTransaction(t, __PRIVATE_ListenSequence._e), e).next();\n });\n });\n }\n }]);\n\n return __PRIVATE_SchemaConverter;\n}();\n\nfunction __PRIVATE_createQueryCache(e) {\n e.createObjectStore(\"targetDocuments\", {\n keyPath: k\n }).createIndex(\"documentTargetsIndex\", q, {\n unique: !0\n }); // NOTE: This is unique only because the TargetId is the suffix.\n\n e.createObjectStore(\"targets\", {\n keyPath: \"targetId\"\n }).createIndex(\"queryTargetsIndex\", L, {\n unique: !0\n }), e.createObjectStore(\"targetGlobal\");\n}\n\nvar de = \"Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.\";\n/**\n * Oldest acceptable age in milliseconds for client metadata before the client\n * is considered inactive and its associated data is garbage collected.\n */\n\n/**\n * An IndexedDB-backed instance of Persistence. Data is stored persistently\n * across sessions.\n *\n * On Web only, the Firestore SDKs support shared access to its persistence\n * layer. This allows multiple browser tabs to read and write to IndexedDb and\n * to synchronize state even without network connectivity. Shared access is\n * currently optional and not enabled unless all clients invoke\n * `enablePersistence()` with `{synchronizeTabs:true}`.\n *\n * In multi-tab mode, if multiple clients are active at the same time, the SDK\n * will designate one client as the “primary client”. An effort is made to pick\n * a visible, network-connected and active client, and this client is\n * responsible for letting other clients know about its presence. The primary\n * client writes a unique client-generated identifier (the client ID) to\n * IndexedDb’s “owner” store every 4 seconds. If the primary client fails to\n * update this entry, another client can acquire the lease and take over as\n * primary.\n *\n * Some persistence operations in the SDK are designated as primary-client only\n * operations. This includes the acknowledgment of mutations and all updates of\n * remote documents. The effects of these operations are written to persistence\n * and then broadcast to other tabs via LocalStorage (see\n * `WebStorageSharedClientState`), which then refresh their state from\n * persistence.\n *\n * Similarly, the primary client listens to notifications sent by secondary\n * clients to discover persistence changes written by secondary clients, such as\n * the addition of new mutations and query targets.\n *\n * If multi-tab is not enabled and another tab already obtained the primary\n * lease, IndexedDbPersistence enters a failed state and all subsequent\n * operations will automatically fail.\n *\n * Additionally, there is an optimization so that when a tab is closed, the\n * primary lease is released immediately (this is especially important to make\n * sure that a refreshed tab is able to immediately re-acquire the primary\n * lease). Unfortunately, IndexedDB cannot be reliably used in window.unload\n * since it is an asynchronous API. So in addition to attempting to give up the\n * lease, the leaseholder writes its client ID to a \"zombiedClient\" entry in\n * LocalStorage which acts as an indicator that another tab should go ahead and\n * take the primary lease immediately regardless of the current lease timestamp.\n *\n * TODO(b/114226234): Remove `synchronizeTabs` section when multi-tab is no\n * longer optional.\n */\n\nvar __PRIVATE_IndexedDbPersistence = /*#__PURE__*/function () {\n function __PRIVATE_IndexedDbPersistence(\n /**\n * Whether to synchronize the in-memory state of multiple tabs and share\n * access to local persistence.\n */\n e, t, n, r, i, s, o, _, a,\n /**\n * If set to true, forcefully obtains database access. Existing tabs will\n * no longer be able to access IndexedDB.\n */\n u) {\n var c = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : 15;\n\n _classCallCheck(this, __PRIVATE_IndexedDbPersistence);\n\n if (this.allowTabSynchronization = e, this.persistenceKey = t, this.clientId = n, this.oi = i, this.window = s, this.document = o, this._i = a, this.ai = u, this.ui = c, this.kr = null, this.qr = !1, this.isPrimary = !1, this.networkEnabled = !0,\n /** Our window.unload handler, if registered. */\n this.ci = null, this.inForeground = !1,\n /** Our 'visibilitychange' listener if registered. */\n this.li = null,\n /** The client metadata refresh task. */\n this.hi = null,\n /** The last time we garbage collected the client metadata object store. */\n this.Pi = Number.NEGATIVE_INFINITY,\n /** A listener to notify on primary state changes. */\n this.Ii = function (e) {\n return Promise.resolve();\n }, !__PRIVATE_IndexedDbPersistence.D()) throw new FirestoreError(D.UNIMPLEMENTED, \"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.\");\n this.referenceDelegate = new __PRIVATE_IndexedDbLruDelegateImpl(this, r), this.Ti = t + \"main\", this.serializer = new __PRIVATE_LocalSerializer(_), this.Ei = new __PRIVATE_SimpleDb(this.Ti, this.ui, new __PRIVATE_SchemaConverter(this.serializer)), this.Qr = new __PRIVATE_IndexedDbTargetCache(this.referenceDelegate, this.serializer), this.remoteDocumentCache = __PRIVATE_newIndexedDbRemoteDocumentCache(this.serializer), this.$r = new __PRIVATE_IndexedDbBundleCache(), this.window && this.window.localStorage ? this.di = this.window.localStorage : (this.di = null, !1 === u && __PRIVATE_logError(\"IndexedDbPersistence\", \"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page.\"));\n }\n /**\n * Attempt to start IndexedDb persistence.\n *\n * @returns Whether persistence was enabled.\n */\n\n\n _createClass(__PRIVATE_IndexedDbPersistence, [{\n key: \"start\",\n value: function start() {\n var _this137 = this;\n\n // NOTE: This is expected to fail sometimes (in the case of another tab\n // already having the persistence lock), so it's the first thing we should\n // do.\n return this.Ai().then(function () {\n if (!_this137.isPrimary && !_this137.allowTabSynchronization) // Fail `start()` if `synchronizeTabs` is disabled and we cannot\n // obtain the primary lease.\n throw new FirestoreError(D.FAILED_PRECONDITION, de);\n return _this137.Ri(), _this137.Vi(), _this137.mi(), _this137.runTransaction(\"getHighestListenSequenceNumber\", \"readonly\", function (e) {\n return _this137.Qr.getHighestSequenceNumber(e);\n });\n }).then(function (e) {\n _this137.kr = new __PRIVATE_ListenSequence(e, _this137._i);\n }).then(function () {\n _this137.qr = !0;\n }).catch(function (e) {\n return _this137.Ei && _this137.Ei.close(), Promise.reject(e);\n });\n }\n /**\n * Registers a listener that gets called when the primary state of the\n * instance changes. Upon registering, this listener is invoked immediately\n * with the current primary state.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n\n }, {\n key: \"fi\",\n value: function fi(e) {\n var _this138 = this;\n\n return this.Ii = /*#__PURE__*/function () {\n var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(t) {\n return _regeneratorRuntime.wrap(function _callee8$(_context8) {\n while (1) {\n switch (_context8.prev = _context8.next) {\n case 0:\n if (!_this138.started) {\n _context8.next = 2;\n break;\n }\n\n return _context8.abrupt(\"return\", e(t));\n\n case 2:\n case \"end\":\n return _context8.stop();\n }\n }\n }, _callee8);\n }));\n\n return function (_x7) {\n return _ref18.apply(this, arguments);\n };\n }(), e(this.isPrimary);\n }\n /**\n * Registers a listener that gets called when the database receives a\n * version change event indicating that it has deleted.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n\n }, {\n key: \"setDatabaseDeletedListener\",\n value: function setDatabaseDeletedListener(e) {\n this.Ei.L( /*#__PURE__*/function () {\n var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(t) {\n return _regeneratorRuntime.wrap(function _callee9$(_context9) {\n while (1) {\n switch (_context9.prev = _context9.next) {\n case 0:\n _context9.t0 = null === t.newVersion;\n\n if (!_context9.t0) {\n _context9.next = 4;\n break;\n }\n\n _context9.next = 4;\n return e();\n\n case 4:\n case \"end\":\n return _context9.stop();\n }\n }\n }, _callee9);\n }));\n\n return function (_x8) {\n return _ref19.apply(this, arguments);\n };\n }());\n }\n /**\n * Adjusts the current network state in the client's metadata, potentially\n * affecting the primary lease.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n\n }, {\n key: \"setNetworkEnabled\",\n value: function setNetworkEnabled(e) {\n var _this139 = this;\n\n this.networkEnabled !== e && (this.networkEnabled = e, // Schedule a primary lease refresh for immediate execution. The eventual\n // lease update will be propagated via `primaryStateListener`.\n this.oi.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {\n return _regeneratorRuntime.wrap(function _callee10$(_context10) {\n while (1) {\n switch (_context10.prev = _context10.next) {\n case 0:\n _context10.t0 = _this139.started;\n\n if (!_context10.t0) {\n _context10.next = 4;\n break;\n }\n\n _context10.next = 4;\n return _this139.Ai();\n\n case 4:\n case \"end\":\n return _context10.stop();\n }\n }\n }, _callee10);\n }))));\n }\n /**\n * Updates the client metadata in IndexedDb and attempts to either obtain or\n * extend the primary lease for the local client. Asynchronously notifies the\n * primary state listener if the client either newly obtained or released its\n * primary lease.\n */\n\n }, {\n key: \"Ai\",\n value: function Ai() {\n var _this140 = this;\n\n return this.runTransaction(\"updateClientMetadataAndTryBecomePrimary\", \"readwrite\", function (e) {\n return __PRIVATE_clientMetadataStore(e).put({\n clientId: _this140.clientId,\n updateTimeMs: Date.now(),\n networkEnabled: _this140.networkEnabled,\n inForeground: _this140.inForeground\n }).next(function () {\n if (_this140.isPrimary) return _this140.gi(e).next(function (e) {\n e || (_this140.isPrimary = !1, _this140.oi.enqueueRetryable(function () {\n return _this140.Ii(!1);\n }));\n });\n }).next(function () {\n return _this140.pi(e);\n }).next(function (t) {\n return _this140.isPrimary && !t ? _this140.yi(e).next(function () {\n return !1;\n }) : !!t && _this140.wi(e).next(function () {\n return !0;\n });\n });\n }).catch(function (e) {\n if (__PRIVATE_isIndexedDbTransactionError(e)) // Proceed with the existing state. Any subsequent access to\n // IndexedDB will verify the lease.\n return __PRIVATE_logDebug(\"IndexedDbPersistence\", \"Failed to extend owner lease: \", e), _this140.isPrimary;\n if (!_this140.allowTabSynchronization) throw e;\n return __PRIVATE_logDebug(\"IndexedDbPersistence\", \"Releasing owner lease after error during lease refresh\", e),\n /* isPrimary= */\n !1;\n }).then(function (e) {\n _this140.isPrimary !== e && _this140.oi.enqueueRetryable(function () {\n return _this140.Ii(e);\n }), _this140.isPrimary = e;\n });\n }\n }, {\n key: \"gi\",\n value: function gi(e) {\n var _this141 = this;\n\n return __PRIVATE_primaryClientStore(e).get(\"owner\").next(function (e) {\n return PersistencePromise.resolve(_this141.Si(e));\n });\n }\n }, {\n key: \"bi\",\n value: function bi(e) {\n return __PRIVATE_clientMetadataStore(e).delete(this.clientId);\n }\n /**\n * If the garbage collection threshold has passed, prunes the\n * RemoteDocumentChanges and the ClientMetadata store based on the last update\n * time of all clients.\n */\n\n }, {\n key: \"Di\",\n value: function () {\n var _Di = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {\n var _this142 = this;\n\n var e, _iterator58, _step58, t;\n\n return _regeneratorRuntime.wrap(function _callee11$(_context11) {\n while (1) {\n switch (_context11.prev = _context11.next) {\n case 0:\n if (!(this.isPrimary && !this.Ci(this.Pi, 18e5))) {\n _context11.next = 6;\n break;\n }\n\n this.Pi = Date.now();\n _context11.next = 4;\n return this.runTransaction(\"maybeGarbageCollectMultiClientState\", \"readwrite-primary\", function (e) {\n var t = __PRIVATE_getStore(e, \"clientMetadata\");\n\n return t.W().next(function (e) {\n var n = _this142.vi(e, 18e5),\n r = e.filter(function (e) {\n return -1 === n.indexOf(e);\n }); // Delete metadata for clients that are no longer considered active.\n\n\n // Delete metadata for clients that are no longer considered active.\n return PersistencePromise.forEach(r, function (e) {\n return t.delete(e.clientId);\n }).next(function () {\n return r;\n });\n });\n }).catch(function () {\n return [];\n });\n\n case 4:\n e = _context11.sent;\n\n // Delete potential leftover entries that may continue to mark the\n // inactive clients as zombied in LocalStorage.\n // Ideally we'd delete the IndexedDb and LocalStorage zombie entries for\n // the client atomically, but we can't. So we opt to delete the IndexedDb\n // entries first to avoid potentially reviving a zombied client.\n if (this.di) {\n _iterator58 = _createForOfIteratorHelper(e);\n\n try {\n for (_iterator58.s(); !(_step58 = _iterator58.n()).done;) {\n t = _step58.value;\n this.di.removeItem(this.Fi(t.clientId));\n }\n } catch (err) {\n _iterator58.e(err);\n } finally {\n _iterator58.f();\n }\n }\n\n case 6:\n case \"end\":\n return _context11.stop();\n }\n }\n }, _callee11, this);\n }));\n\n function Di() {\n return _Di.apply(this, arguments);\n }\n\n return Di;\n }()\n /**\n * Schedules a recurring timer to update the client metadata and to either\n * extend or acquire the primary lease if the client is eligible.\n */\n\n }, {\n key: \"mi\",\n value: function mi() {\n var _this143 = this;\n\n this.hi = this.oi.enqueueAfterDelay(\"client_metadata_refresh\"\n /* TimerId.ClientMetadataRefresh */\n , 4e3, function () {\n return _this143.Ai().then(function () {\n return _this143.Di();\n }).then(function () {\n return _this143.mi();\n });\n });\n }\n /** Checks whether `client` is the local client. */\n\n }, {\n key: \"Si\",\n value: function Si(e) {\n return !!e && e.ownerId === this.clientId;\n }\n /**\n * Evaluate the state of all active clients and determine whether the local\n * client is or can act as the holder of the primary lease. Returns whether\n * the client is eligible for the lease, but does not actually acquire it.\n * May return 'false' even if there is no active leaseholder and another\n * (foreground) client should become leaseholder instead.\n */\n\n }, {\n key: \"pi\",\n value: function pi(e) {\n var _this144 = this;\n\n if (this.ai) return PersistencePromise.resolve(!0);\n return __PRIVATE_primaryClientStore(e).get(\"owner\").next(function (t) {\n // A client is eligible for the primary lease if:\n // - its network is enabled and the client's tab is in the foreground.\n // - its network is enabled and no other client's tab is in the\n // foreground.\n // - every clients network is disabled and the client's tab is in the\n // foreground.\n // - every clients network is disabled and no other client's tab is in\n // the foreground.\n // - the `forceOwningTab` setting was passed in.\n if (null !== t && _this144.Ci(t.leaseTimestampMs, 5e3) && !_this144.Mi(t.ownerId)) {\n if (_this144.Si(t) && _this144.networkEnabled) return !0;\n\n if (!_this144.Si(t)) {\n if (!t.allowTabSynchronization) // Fail the `canActAsPrimary` check if the current leaseholder has\n // not opted into multi-tab synchronization. If this happens at\n // client startup, we reject the Promise returned by\n // `enablePersistence()` and the user can continue to use Firestore\n // with in-memory persistence.\n // If this fails during a lease refresh, we will instead block the\n // AsyncQueue from executing further operations. Note that this is\n // acceptable since mixing & matching different `synchronizeTabs`\n // settings is not supported.\n // TODO(b/114226234): Remove this check when `synchronizeTabs` can\n // no longer be turned off.\n throw new FirestoreError(D.FAILED_PRECONDITION, de);\n return !1;\n }\n }\n\n return !(!_this144.networkEnabled || !_this144.inForeground) || __PRIVATE_clientMetadataStore(e).W().next(function (e) {\n return void 0 === _this144.vi(e, 5e3).find(function (e) {\n if (_this144.clientId !== e.clientId) {\n var _t39 = !_this144.networkEnabled && e.networkEnabled,\n n = !_this144.inForeground && e.inForeground,\n r = _this144.networkEnabled === e.networkEnabled;\n\n if (_t39 || n && r) return !0;\n }\n\n return !1;\n });\n });\n }).next(function (e) {\n return _this144.isPrimary !== e && __PRIVATE_logDebug(\"IndexedDbPersistence\", \"Client \".concat(e ? \"is\" : \"is not\", \" eligible for a primary lease.\")), e;\n });\n }\n }, {\n key: \"shutdown\",\n value: function () {\n var _shutdown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {\n var _this145 = this;\n\n return _regeneratorRuntime.wrap(function _callee12$(_context12) {\n while (1) {\n switch (_context12.prev = _context12.next) {\n case 0:\n this.qr = !1;\n this.xi();\n this.hi && (this.hi.cancel(), this.hi = null);\n this.Oi();\n this.Ni();\n _context12.next = 7;\n return this.Ei.runTransaction(\"shutdown\", \"readwrite\", [\"owner\", \"clientMetadata\"], function (e) {\n var t = new __PRIVATE_IndexedDbTransaction(e, __PRIVATE_ListenSequence._e);\n return _this145.yi(t).next(function () {\n return _this145.bi(t);\n });\n });\n\n case 7:\n this.Ei.close();\n // Remove the entry marking the client as zombied from LocalStorage since\n // we successfully deleted its metadata from IndexedDb.\n this.Bi();\n\n case 9:\n case \"end\":\n return _context12.stop();\n }\n }\n }, _callee12, this);\n }));\n\n function shutdown() {\n return _shutdown.apply(this, arguments);\n }\n\n return shutdown;\n }()\n /**\n * Returns clients that are not zombied and have an updateTime within the\n * provided threshold.\n */\n\n }, {\n key: \"vi\",\n value: function vi(e, t) {\n var _this146 = this;\n\n return e.filter(function (e) {\n return _this146.Ci(e.updateTimeMs, t) && !_this146.Mi(e.clientId);\n });\n }\n /**\n * Returns the IDs of the clients that are currently active. If multi-tab\n * is not supported, returns an array that only contains the local client's\n * ID.\n *\n * PORTING NOTE: This is only used for Web multi-tab.\n */\n\n }, {\n key: \"Li\",\n value: function Li() {\n var _this147 = this;\n\n return this.runTransaction(\"getActiveClients\", \"readonly\", function (e) {\n return __PRIVATE_clientMetadataStore(e).W().next(function (e) {\n return _this147.vi(e, 18e5).map(function (e) {\n return e.clientId;\n });\n });\n });\n }\n }, {\n key: \"started\",\n get: function get() {\n return this.qr;\n }\n }, {\n key: \"getMutationQueue\",\n value: function getMutationQueue(e, t) {\n return __PRIVATE_IndexedDbMutationQueue.lt(e, this.serializer, t, this.referenceDelegate);\n }\n }, {\n key: \"getTargetCache\",\n value: function getTargetCache() {\n return this.Qr;\n }\n }, {\n key: \"getRemoteDocumentCache\",\n value: function getRemoteDocumentCache() {\n return this.remoteDocumentCache;\n }\n }, {\n key: \"getIndexManager\",\n value: function getIndexManager(e) {\n return new __PRIVATE_IndexedDbIndexManager(e, this.serializer.ct.databaseId);\n }\n }, {\n key: \"getDocumentOverlayCache\",\n value: function getDocumentOverlayCache(e) {\n return __PRIVATE_IndexedDbDocumentOverlayCache.lt(this.serializer, e);\n }\n }, {\n key: \"getBundleCache\",\n value: function getBundleCache() {\n return this.$r;\n }\n }, {\n key: \"runTransaction\",\n value: function runTransaction(e, t, n) {\n var _this148 = this;\n\n __PRIVATE_logDebug(\"IndexedDbPersistence\", \"Starting transaction:\", e);\n\n var r = \"readonly\" === t ? \"readonly\" : \"readwrite\",\n i =\n /** Returns the object stores for the provided schema. */\n function __PRIVATE_getObjectStores(e) {\n return 15 === e ? X : 14 === e ? Z : 13 === e ? Y : 12 === e ? J : 11 === e ? H : void fail();\n }(this.ui);\n\n var s; // Do all transactions as readwrite against all object stores, since we\n // are the only reader/writer.\n\n return this.Ei.runTransaction(e, r, i, function (r) {\n return s = new __PRIVATE_IndexedDbTransaction(r, _this148.kr ? _this148.kr.next() : __PRIVATE_ListenSequence._e), \"readwrite-primary\" === t ? _this148.gi(s).next(function (e) {\n return !!e || _this148.pi(s);\n }).next(function (t) {\n if (!t) throw __PRIVATE_logError(\"Failed to obtain primary lease for action '\".concat(e, \"'.\")), _this148.isPrimary = !1, _this148.oi.enqueueRetryable(function () {\n return _this148.Ii(!1);\n }), new FirestoreError(D.FAILED_PRECONDITION, v);\n return n(s);\n }).next(function (e) {\n return _this148.wi(s).next(function () {\n return e;\n });\n }) : _this148.ki(s).next(function () {\n return n(s);\n });\n }).then(function (e) {\n return s.raiseOnCommittedEvent(), e;\n });\n }\n /**\n * Verifies that the current tab is the primary leaseholder or alternatively\n * that the leaseholder has opted into multi-tab synchronization.\n */\n // TODO(b/114226234): Remove this check when `synchronizeTabs` can no longer\n // be turned off.\n\n }, {\n key: \"ki\",\n value: function ki(e) {\n var _this149 = this;\n\n return __PRIVATE_primaryClientStore(e).get(\"owner\").next(function (e) {\n if (null !== e && _this149.Ci(e.leaseTimestampMs, 5e3) && !_this149.Mi(e.ownerId) && !_this149.Si(e) && !(_this149.ai || _this149.allowTabSynchronization && e.allowTabSynchronization)) throw new FirestoreError(D.FAILED_PRECONDITION, de);\n });\n }\n /**\n * Obtains or extends the new primary lease for the local client. This\n * method does not verify that the client is eligible for this lease.\n */\n\n }, {\n key: \"wi\",\n value: function wi(e) {\n var t = {\n ownerId: this.clientId,\n allowTabSynchronization: this.allowTabSynchronization,\n leaseTimestampMs: Date.now()\n };\n return __PRIVATE_primaryClientStore(e).put(\"owner\", t);\n }\n }, {\n key: \"yi\",\n value:\n /** Checks the primary lease and removes it if we are the current primary. */\n function yi(e) {\n var _this150 = this;\n\n var t = __PRIVATE_primaryClientStore(e);\n\n return t.get(\"owner\").next(function (e) {\n return _this150.Si(e) ? (__PRIVATE_logDebug(\"IndexedDbPersistence\", \"Releasing primary lease.\"), t.delete(\"owner\")) : PersistencePromise.resolve();\n });\n }\n /** Verifies that `updateTimeMs` is within `maxAgeMs`. */\n\n }, {\n key: \"Ci\",\n value: function Ci(e, t) {\n var n = Date.now();\n return !(e < n - t) && (!(e > n) || (__PRIVATE_logError(\"Detected an update time that is in the future: \".concat(e, \" > \").concat(n)), !1));\n }\n }, {\n key: \"Ri\",\n value: function Ri() {\n var _this151 = this;\n\n null !== this.document && \"function\" == typeof this.document.addEventListener && (this.li = function () {\n _this151.oi.enqueueAndForget(function () {\n return _this151.inForeground = \"visible\" === _this151.document.visibilityState, _this151.Ai();\n });\n }, this.document.addEventListener(\"visibilitychange\", this.li), this.inForeground = \"visible\" === this.document.visibilityState);\n }\n }, {\n key: \"Oi\",\n value: function Oi() {\n this.li && (this.document.removeEventListener(\"visibilitychange\", this.li), this.li = null);\n }\n /**\n * Attaches a window.unload handler that will synchronously write our\n * clientId to a \"zombie client id\" location in LocalStorage. This can be used\n * by tabs trying to acquire the primary lease to determine that the lease\n * is no longer valid even if the timestamp is recent. This is particularly\n * important for the refresh case (so the tab correctly re-acquires the\n * primary lease). LocalStorage is used for this rather than IndexedDb because\n * it is a synchronous API and so can be used reliably from an unload\n * handler.\n */\n\n }, {\n key: \"Vi\",\n value: function Vi() {\n var _this152 = this;\n\n var e;\n \"function\" == typeof (null === (e = this.window) || void 0 === e ? void 0 : e.addEventListener) && (this.ci = function () {\n // Note: In theory, this should be scheduled on the AsyncQueue since it\n // accesses internal state. We execute this code directly during shutdown\n // to make sure it gets a chance to run.\n _this152.xi();\n\n var e = /(?:Version|Mobile)\\/1[456]/;\n isSafari() && (navigator.appVersion.match(e) || navigator.userAgent.match(e)) && // On Safari 14, 15, and 16, we do not run any cleanup actions as it might\n // trigger a bug that prevents Safari from re-opening IndexedDB during\n // the next page load.\n // See https://bugs.webkit.org/show_bug.cgi?id=226547\n _this152.oi.enterRestrictedMode(\n /* purgeExistingTasks= */\n !0), _this152.oi.enqueueAndForget(function () {\n return _this152.shutdown();\n });\n }, this.window.addEventListener(\"pagehide\", this.ci));\n }\n }, {\n key: \"Ni\",\n value: function Ni() {\n this.ci && (this.window.removeEventListener(\"pagehide\", this.ci), this.ci = null);\n }\n /**\n * Returns whether a client is \"zombied\" based on its LocalStorage entry.\n * Clients become zombied when their tab closes without running all of the\n * cleanup logic in `shutdown()`.\n */\n\n }, {\n key: \"Mi\",\n value: function Mi(e) {\n var t;\n\n try {\n var n = null !== (null === (t = this.di) || void 0 === t ? void 0 : t.getItem(this.Fi(e)));\n return __PRIVATE_logDebug(\"IndexedDbPersistence\", \"Client '\".concat(e, \"' \").concat(n ? \"is\" : \"is not\", \" zombied in LocalStorage\")), n;\n } catch (e) {\n // Gracefully handle if LocalStorage isn't working.\n return __PRIVATE_logError(\"IndexedDbPersistence\", \"Failed to get zombied client id.\", e), !1;\n }\n }\n /**\n * Record client as zombied (a client that had its tab closed). Zombied\n * clients are ignored during primary tab selection.\n */\n\n }, {\n key: \"xi\",\n value: function xi() {\n if (this.di) try {\n this.di.setItem(this.Fi(this.clientId), String(Date.now()));\n } catch (e) {\n // Gracefully handle if LocalStorage isn't available / working.\n __PRIVATE_logError(\"Failed to set zombie client id.\", e);\n }\n }\n /** Removes the zombied client entry if it exists. */\n\n }, {\n key: \"Bi\",\n value: function Bi() {\n if (this.di) try {\n this.di.removeItem(this.Fi(this.clientId));\n } catch (e) {// Ignore\n }\n }\n }, {\n key: \"Fi\",\n value: function Fi(e) {\n return \"firestore_zombie_\".concat(this.persistenceKey, \"_\").concat(e);\n }\n }], [{\n key: \"D\",\n value: function D() {\n return __PRIVATE_SimpleDb.D();\n }\n }]);\n\n return __PRIVATE_IndexedDbPersistence;\n}();\n/**\n * Helper to get a typed SimpleDbStore for the primary client object store.\n */\n\n\nfunction __PRIVATE_primaryClientStore(e) {\n return __PRIVATE_getStore(e, \"owner\");\n}\n/**\n * Helper to get a typed SimpleDbStore for the client metadata object store.\n */\n\n\nfunction __PRIVATE_clientMetadataStore(e) {\n return __PRIVATE_getStore(e, \"clientMetadata\");\n}\n/**\n * Generates a string used as a prefix when storing data in IndexedDB and\n * LocalStorage.\n */\n\n\nfunction __PRIVATE_indexedDbStoragePrefix(e, t) {\n // Use two different prefix formats:\n // * firestore / persistenceKey / projectID . databaseID / ...\n // * firestore / persistenceKey / projectID / ...\n // projectIDs are DNS-compatible names and cannot contain dots\n // so there's no danger of collisions.\n var n = e.projectId;\n return e.isDefaultDatabase || (n += \".\" + e.database), \"firestore/\" + t + \"/\" + n + \"/\";\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A set of changes to what documents are currently in view and out of view for\n * a given query. These changes are sent to the LocalStore by the View (via\n * the SyncEngine) and are used to pin / unpin documents as appropriate.\n */\n\n\nvar __PRIVATE_LocalViewChanges = /*#__PURE__*/function () {\n function __PRIVATE_LocalViewChanges(e, t, n, r) {\n _classCallCheck(this, __PRIVATE_LocalViewChanges);\n\n this.targetId = e, this.fromCache = t, this.qi = n, this.Qi = r;\n }\n\n _createClass(__PRIVATE_LocalViewChanges, null, [{\n key: \"Ki\",\n value: function Ki(e, t) {\n var n = __PRIVATE_documentKeySet(),\n r = __PRIVATE_documentKeySet();\n\n var _iterator59 = _createForOfIteratorHelper(t.docChanges),\n _step59;\n\n try {\n for (_iterator59.s(); !(_step59 = _iterator59.n()).done;) {\n var _e76 = _step59.value;\n\n switch (_e76.type) {\n case 0\n /* ChangeType.Added */\n :\n n = n.add(_e76.doc.key);\n break;\n\n case 1\n /* ChangeType.Removed */\n :\n r = r.add(_e76.doc.key);\n // do nothing\n }\n }\n } catch (err) {\n _iterator59.e(err);\n } finally {\n _iterator59.f();\n }\n\n return new __PRIVATE_LocalViewChanges(e, t.fromCache, n, r);\n }\n }]);\n\n return __PRIVATE_LocalViewChanges;\n}();\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A tracker to keep a record of important details during database local query\n * execution.\n */\n\n\nvar QueryContext = /*#__PURE__*/function () {\n function QueryContext() {\n _classCallCheck(this, QueryContext);\n\n /**\n * Counts the number of documents passed through during local query execution.\n */\n this._documentReadCount = 0;\n }\n\n _createClass(QueryContext, [{\n key: \"documentReadCount\",\n get: function get() {\n return this._documentReadCount;\n }\n }, {\n key: \"incrementDocumentReadCount\",\n value: function incrementDocumentReadCount(e) {\n this._documentReadCount += e;\n }\n }]);\n\n return QueryContext;\n}();\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The Firestore query engine.\n *\n * Firestore queries can be executed in three modes. The Query Engine determines\n * what mode to use based on what data is persisted. The mode only determines\n * the runtime complexity of the query - the result set is equivalent across all\n * implementations.\n *\n * The Query engine will use indexed-based execution if a user has configured\n * any index that can be used to execute query (via `setIndexConfiguration()`).\n * Otherwise, the engine will try to optimize the query by re-using a previously\n * persisted query result. If that is not possible, the query will be executed\n * via a full collection scan.\n *\n * Index-based execution is the default when available. The query engine\n * supports partial indexed execution and merges the result from the index\n * lookup with documents that have not yet been indexed. The index evaluation\n * matches the backend's format and as such, the SDK can use indexing for all\n * queries that the backend supports.\n *\n * If no index exists, the query engine tries to take advantage of the target\n * document mapping in the TargetCache. These mappings exists for all queries\n * that have been synced with the backend at least once and allow the query\n * engine to only read documents that previously matched a query plus any\n * documents that were edited after the query was last listened to.\n *\n * There are some cases when this optimization is not guaranteed to produce\n * the same results as full collection scans. In these cases, query\n * processing falls back to full scans. These cases are:\n *\n * - Limit queries where a document that matched the query previously no longer\n * matches the query.\n *\n * - Limit queries where a document edit may cause the document to sort below\n * another document that is in the local cache.\n *\n * - Queries that have never been CURRENT or free of limbo documents.\n */\n\n\nvar __PRIVATE_QueryEngine = /*#__PURE__*/function () {\n function __PRIVATE_QueryEngine() {\n _classCallCheck(this, __PRIVATE_QueryEngine);\n\n this.$i = !1, this.Ui = !1,\n /**\n * SDK only decides whether it should create index when collection size is\n * larger than this.\n */\n this.Wi = 100, this.Gi =\n /**\n * This cost represents the evaluation result of\n * (([index, docKey] + [docKey, docContent]) per document in the result set)\n * / ([docKey, docContent] per documents in full collection scan) coming from\n * experiment [enter PR experiment URL here].\n */\n function __PRIVATE_getDefaultRelativeIndexReadCostPerDocument() {\n // These values were derived from an experiment where several members of the\n // Firestore SDK team ran a performance test in various environments.\n // Googlers can see b/299284287 for details.\n return isSafari() ? 8 : __PRIVATE_SimpleDb.v(getUA()) > 0 ? 6 : 4;\n }();\n }\n /** Sets the document view to query against. */\n\n\n _createClass(__PRIVATE_QueryEngine, [{\n key: \"initialize\",\n value: function initialize(e, t) {\n this.zi = e, this.indexManager = t, this.$i = !0;\n }\n /** Returns all local documents matching the specified query. */\n\n }, {\n key: \"getDocumentsMatchingQuery\",\n value: function getDocumentsMatchingQuery(e, t, n, r) {\n var _this153 = this;\n\n // Stores the result from executing the query; using this object is more\n // convenient than passing the result between steps of the persistence\n // transaction and improves readability comparatively.\n var i = {\n result: null\n };\n return this.ji(e, t).next(function (e) {\n i.result = e;\n }).next(function () {\n if (!i.result) return _this153.Hi(e, t, r, n).next(function (e) {\n i.result = e;\n });\n }).next(function () {\n if (i.result) return;\n var n = new QueryContext();\n return _this153.Ji(e, t, n).next(function (r) {\n if (i.result = r, _this153.Ui) return _this153.Yi(e, t, n, r.size);\n });\n }).next(function () {\n return i.result;\n });\n }\n }, {\n key: \"Yi\",\n value: function Yi(e, t, n, r) {\n return n.documentReadCount < this.Wi ? (__PRIVATE_getLogLevel() <= LogLevel.DEBUG && __PRIVATE_logDebug(\"QueryEngine\", \"SDK will not create cache indexes for query:\", __PRIVATE_stringifyQuery(t), \"since it only creates cache indexes for collection contains\", \"more than or equal to\", this.Wi, \"documents\"), PersistencePromise.resolve()) : (__PRIVATE_getLogLevel() <= LogLevel.DEBUG && __PRIVATE_logDebug(\"QueryEngine\", \"Query:\", __PRIVATE_stringifyQuery(t), \"scans\", n.documentReadCount, \"local documents and returns\", r, \"documents as results.\"), n.documentReadCount > this.Gi * r ? (__PRIVATE_getLogLevel() <= LogLevel.DEBUG && __PRIVATE_logDebug(\"QueryEngine\", \"The SDK decides to create cache indexes for query:\", __PRIVATE_stringifyQuery(t), \"as using cache indexes may help improve performance.\"), this.indexManager.createTargetIndexes(e, __PRIVATE_queryToTarget(t))) : PersistencePromise.resolve());\n }\n /**\n * Performs an indexed query that evaluates the query based on a collection's\n * persisted index values. Returns `null` if an index is not available.\n */\n\n }, {\n key: \"ji\",\n value: function ji(e, t) {\n var _this154 = this;\n\n if (__PRIVATE_queryMatchesAllDocuments(t)) // Queries that match all documents don't benefit from using\n // key-based lookups. It is more efficient to scan all documents in a\n // collection, rather than to perform individual lookups.\n return PersistencePromise.resolve(null);\n\n var n = __PRIVATE_queryToTarget(t);\n\n return this.indexManager.getIndexType(e, n).next(function (r) {\n return 0\n /* IndexType.NONE */\n === r ? null : (null !== t.limit && 1\n /* IndexType.PARTIAL */\n === r && ( // We cannot apply a limit for targets that are served using a partial\n // index. If a partial index will be used to serve the target, the\n // query may return a superset of documents that match the target\n // (e.g. if the index doesn't include all the target's filters), or\n // may return the correct set of documents in the wrong order (e.g. if\n // the index doesn't include a segment for one of the orderBys).\n // Therefore, a limit should not be applied in such cases.\n t = __PRIVATE_queryWithLimit(t, null, \"F\"\n /* LimitType.First */\n ), n = __PRIVATE_queryToTarget(t)), _this154.indexManager.getDocumentsMatchingTarget(e, n).next(function (r) {\n var i = __PRIVATE_documentKeySet.apply(void 0, _toConsumableArray(r));\n\n return _this154.zi.getDocuments(e, i).next(function (r) {\n return _this154.indexManager.getMinOffset(e, n).next(function (n) {\n var s = _this154.Zi(t, r);\n\n return _this154.Xi(t, s, i, n.readTime) ? _this154.ji(e, __PRIVATE_queryWithLimit(t, null, \"F\"\n /* LimitType.First */\n )) : _this154.es(e, s, t, n);\n });\n });\n }));\n });\n }\n /**\n * Performs a query based on the target's persisted query mapping. Returns\n * `null` if the mapping is not available or cannot be used.\n */\n\n }, {\n key: \"Hi\",\n value: function Hi(e, t, n, r) {\n var _this155 = this;\n\n return __PRIVATE_queryMatchesAllDocuments(t) || r.isEqual(SnapshotVersion.min()) ? PersistencePromise.resolve(null) : this.zi.getDocuments(e, n).next(function (i) {\n var s = _this155.Zi(t, i);\n\n return _this155.Xi(t, s, n, r) ? PersistencePromise.resolve(null) : (__PRIVATE_getLogLevel() <= LogLevel.DEBUG && __PRIVATE_logDebug(\"QueryEngine\", \"Re-using previous result from %s to execute query: %s\", r.toString(), __PRIVATE_stringifyQuery(t)), _this155.es(e, s, t, __PRIVATE_newIndexOffsetSuccessorFromReadTime(r, -1)).next(function (e) {\n return e;\n }));\n }); // Queries that have never seen a snapshot without limbo free documents\n // should also be run as a full collection scan.\n }\n /** Applies the query filter and sorting to the provided documents. */\n\n }, {\n key: \"Zi\",\n value: function Zi(e, t) {\n // Sort the documents and re-apply the query filter since previously\n // matching documents do not necessarily still match the query.\n var n = new SortedSet(__PRIVATE_newQueryComparator(e));\n return t.forEach(function (t, r) {\n __PRIVATE_queryMatches(e, r) && (n = n.add(r));\n }), n;\n }\n /**\n * Determines if a limit query needs to be refilled from cache, making it\n * ineligible for index-free execution.\n *\n * @param query - The query.\n * @param sortedPreviousResults - The documents that matched the query when it\n * was last synchronized, sorted by the query's comparator.\n * @param remoteKeys - The document keys that matched the query at the last\n * snapshot.\n * @param limboFreeSnapshotVersion - The version of the snapshot when the\n * query was last synchronized.\n */\n\n }, {\n key: \"Xi\",\n value: function Xi(e, t, n, r) {\n if (null === e.limit) // Queries without limits do not need to be refilled.\n return !1;\n if (n.size !== t.size) // The query needs to be refilled if a previously matching document no\n // longer matches.\n return !0; // Limit queries are not eligible for index-free query execution if there is\n // a potential that an older document from cache now sorts before a document\n // that was previously part of the limit. This, however, can only happen if\n // the document at the edge of the limit goes out of limit.\n // If a document that is not the limit boundary sorts differently,\n // the boundary of the limit itself did not change and documents from cache\n // will continue to be \"rejected\" by this boundary. Therefore, we can ignore\n // any modifications that don't affect the last document.\n\n var i = \"F\"\n /* LimitType.First */\n === e.limitType ? t.last() : t.first();\n return !!i && (i.hasPendingWrites || i.version.compareTo(r) > 0);\n }\n }, {\n key: \"Ji\",\n value: function Ji(e, t, n) {\n return __PRIVATE_getLogLevel() <= LogLevel.DEBUG && __PRIVATE_logDebug(\"QueryEngine\", \"Using full collection scan to execute query:\", __PRIVATE_stringifyQuery(t)), this.zi.getDocumentsMatchingQuery(e, t, IndexOffset.min(), n);\n }\n /**\n * Combines the results from an indexed execution with the remaining documents\n * that have not yet been indexed.\n */\n\n }, {\n key: \"es\",\n value: function es(e, t, n, r) {\n // Retrieve all results for documents that were updated since the offset.\n return this.zi.getDocumentsMatchingQuery(e, n, r).next(function (e) {\n return (// Merge with existing results\n t.forEach(function (t) {\n e = e.insert(t.key, t);\n }), e\n );\n });\n }\n }]);\n\n return __PRIVATE_QueryEngine;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Implements `LocalStore` interface.\n *\n * Note: some field defined in this class might have public access level, but\n * the class is not exported so they are only accessible from this module.\n * This is useful to implement optional features (like bundles) in free\n * functions, such that they are tree-shakeable.\n */\n\n\nvar __PRIVATE_LocalStoreImpl = /*#__PURE__*/function () {\n function __PRIVATE_LocalStoreImpl(\n /** Manages our in-memory or durable persistence. */\n e, t, n, r) {\n _classCallCheck(this, __PRIVATE_LocalStoreImpl);\n\n this.persistence = e, this.ts = t, this.serializer = r,\n /**\n * Maps a targetID to data about its target.\n *\n * PORTING NOTE: We are using an immutable data structure on Web to make re-runs\n * of `applyRemoteEvent()` idempotent.\n */\n this.ns = new SortedMap(__PRIVATE_primitiveComparator),\n /** Maps a target to its targetID. */\n // TODO(wuandy): Evaluate if TargetId can be part of Target.\n this.rs = new ObjectMap(function (e) {\n return __PRIVATE_canonifyTarget(e);\n }, __PRIVATE_targetEquals),\n /**\n * A per collection group index of the last read time processed by\n * `getNewDocumentChanges()`.\n *\n * PORTING NOTE: This is only used for multi-tab synchronization.\n */\n this.ss = new Map(), this.os = e.getRemoteDocumentCache(), this.Qr = e.getTargetCache(), this.$r = e.getBundleCache(), this._s(n);\n }\n\n _createClass(__PRIVATE_LocalStoreImpl, [{\n key: \"_s\",\n value: function _s(e) {\n // TODO(indexing): Add spec tests that test these components change after a\n // user change\n this.documentOverlayCache = this.persistence.getDocumentOverlayCache(e), this.indexManager = this.persistence.getIndexManager(e), this.mutationQueue = this.persistence.getMutationQueue(e, this.indexManager), this.localDocuments = new LocalDocumentsView(this.os, this.mutationQueue, this.documentOverlayCache, this.indexManager), this.os.setIndexManager(this.indexManager), this.ts.initialize(this.localDocuments, this.indexManager);\n }\n }, {\n key: \"collectGarbage\",\n value: function collectGarbage(e) {\n var _this156 = this;\n\n return this.persistence.runTransaction(\"Collect garbage\", \"readwrite-primary\", function (t) {\n return e.collect(t, _this156.ns);\n });\n }\n }]);\n\n return __PRIVATE_LocalStoreImpl;\n}();\n\nfunction __PRIVATE_newLocalStore(\n/** Manages our in-memory or durable persistence. */\ne, t, n, r) {\n return new __PRIVATE_LocalStoreImpl(e, t, n, r);\n}\n/**\n * Tells the LocalStore that the currently authenticated user has changed.\n *\n * In response the local store switches the mutation queue to the new user and\n * returns any resulting document changes.\n */\n// PORTING NOTE: Android and iOS only return the documents affected by the\n// change.\n\n\nfunction __PRIVATE_localStoreHandleUserChange(_x9, _x10) {\n return _PRIVATE_localStoreHandleUserChange.apply(this, arguments);\n}\n/* Accepts locally generated Mutations and commit them to storage. */\n\n/**\n * Acknowledges the given batch.\n *\n * On the happy path when a batch is acknowledged, the local store will\n *\n * + remove the batch from the mutation queue;\n * + apply the changes to the remote document cache;\n * + recalculate the latency compensated view implied by those changes (there\n * may be mutations in the queue that affect the documents but haven't been\n * acknowledged yet); and\n * + give the changed documents back the sync engine\n *\n * @returns The resulting (modified) documents.\n */\n\n\nfunction _PRIVATE_localStoreHandleUserChange() {\n _PRIVATE_localStoreHandleUserChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee78(e, t) {\n var n;\n return _regeneratorRuntime.wrap(function _callee78$(_context78) {\n while (1) {\n switch (_context78.prev = _context78.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n _context78.next = 3;\n return n.persistence.runTransaction(\"Handle user change\", \"readonly\", function (e) {\n // Swap out the mutation queue, grabbing the pending mutation batches\n // before and after.\n var r;\n return n.mutationQueue.getAllMutationBatches(e).next(function (i) {\n return r = i, n._s(t), n.mutationQueue.getAllMutationBatches(e);\n }).next(function (t) {\n var i = [],\n s = []; // Union the old/new changed keys.\n\n // Union the old/new changed keys.\n var o = __PRIVATE_documentKeySet();\n\n var _iterator88 = _createForOfIteratorHelper(r),\n _step88;\n\n try {\n for (_iterator88.s(); !(_step88 = _iterator88.n()).done;) {\n var _e118 = _step88.value;\n i.push(_e118.batchId);\n\n var _iterator90 = _createForOfIteratorHelper(_e118.mutations),\n _step90;\n\n try {\n for (_iterator90.s(); !(_step90 = _iterator90.n()).done;) {\n var _t57 = _step90.value;\n o = o.add(_t57.key);\n }\n } catch (err) {\n _iterator90.e(err);\n } finally {\n _iterator90.f();\n }\n }\n } catch (err) {\n _iterator88.e(err);\n } finally {\n _iterator88.f();\n }\n\n var _iterator89 = _createForOfIteratorHelper(t),\n _step89;\n\n try {\n for (_iterator89.s(); !(_step89 = _iterator89.n()).done;) {\n var _e119 = _step89.value;\n s.push(_e119.batchId);\n\n var _iterator91 = _createForOfIteratorHelper(_e119.mutations),\n _step91;\n\n try {\n for (_iterator91.s(); !(_step91 = _iterator91.n()).done;) {\n var _t58 = _step91.value;\n o = o.add(_t58.key);\n }\n } catch (err) {\n _iterator91.e(err);\n } finally {\n _iterator91.f();\n }\n } // Return the set of all (potentially) changed documents and the list\n // of mutation batch IDs that were affected by change.\n\n } catch (err) {\n _iterator89.e(err);\n } finally {\n _iterator89.f();\n } // Return the set of all (potentially) changed documents and the list\n // of mutation batch IDs that were affected by change.\n\n\n // Return the set of all (potentially) changed documents and the list\n // of mutation batch IDs that were affected by change.\n return n.localDocuments.getDocuments(e, o).next(function (e) {\n return {\n us: e,\n removedBatchIds: i,\n addedBatchIds: s\n };\n });\n });\n });\n\n case 3:\n return _context78.abrupt(\"return\", _context78.sent);\n\n case 4:\n case \"end\":\n return _context78.stop();\n }\n }\n }, _callee78);\n }));\n return _PRIVATE_localStoreHandleUserChange.apply(this, arguments);\n}\n\nfunction __PRIVATE_localStoreAcknowledgeBatch(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return n.persistence.runTransaction(\"Acknowledge batch\", \"readwrite-primary\", function (e) {\n var r = t.batch.keys(),\n i = n.os.newChangeBuffer({\n trackRemovals: !0\n });\n return function __PRIVATE_applyWriteToRemoteDocuments(e, t, n, r) {\n var i = n.batch,\n s = i.keys();\n var o = PersistencePromise.resolve();\n return s.forEach(function (e) {\n o = o.next(function () {\n return r.getEntry(t, e);\n }).next(function (t) {\n var s = n.docVersions.get(e);\n __PRIVATE_hardAssert(null !== s), t.version.compareTo(s) < 0 && (i.applyToRemoteDocument(t, n), t.isValidDocument() && ( // We use the commitVersion as the readTime rather than the\n // document's updateTime since the updateTime is not advanced\n // for updates that do not modify the underlying document.\n t.setReadTime(n.commitVersion), r.addEntry(t)));\n });\n }), o.next(function () {\n return e.mutationQueue.removeMutationBatch(t, i);\n });\n }\n /** Returns the local view of the documents affected by a mutation batch. */\n // PORTING NOTE: Multi-Tab only.\n (n, e, t, i).next(function () {\n return i.apply(e);\n }).next(function () {\n return n.mutationQueue.performConsistencyCheck(e);\n }).next(function () {\n return n.documentOverlayCache.removeOverlaysForBatchId(e, r, t.batch.batchId);\n }).next(function () {\n return n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e, function __PRIVATE_getKeysWithTransformResults(e) {\n var t = __PRIVATE_documentKeySet();\n\n for (var _n25 = 0; _n25 < e.mutationResults.length; ++_n25) {\n e.mutationResults[_n25].transformResults.length > 0 && (t = t.add(e.batch.mutations[_n25].key));\n }\n\n return t;\n }\n /**\n * Removes mutations from the MutationQueue for the specified batch;\n * LocalDocuments will be recalculated.\n *\n * @returns The resulting modified documents.\n */\n (t));\n }).next(function () {\n return n.localDocuments.getDocuments(e, r);\n });\n });\n}\n/**\n * Returns the last consistent snapshot processed (used by the RemoteStore to\n * determine whether to buffer incoming snapshots from the backend).\n */\n\n\nfunction __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e) {\n var t = __PRIVATE_debugCast(e);\n\n return t.persistence.runTransaction(\"Get last remote snapshot version\", \"readonly\", function (e) {\n return t.Qr.getLastRemoteSnapshotVersion(e);\n });\n}\n/**\n * Updates the \"ground-state\" (remote) documents. We assume that the remote\n * event reflects any write batches that have been acknowledged or rejected\n * (i.e. we do not re-apply local mutations to updates from this event).\n *\n * LocalDocuments are re-calculated if there are remaining mutations in the\n * queue.\n */\n\n\nfunction __PRIVATE_localStoreApplyRemoteEventToLocalCache(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = t.snapshotVersion;\n\n var i = n.ns;\n return n.persistence.runTransaction(\"Apply remote event\", \"readwrite-primary\", function (e) {\n var s = n.os.newChangeBuffer({\n trackRemovals: !0\n }); // Reset newTargetDataByTargetMap in case this transaction gets re-run.\n\n i = n.ns;\n var o = [];\n t.targetChanges.forEach(function (s, _) {\n var a = i.get(_);\n if (!a) return; // Only update the remote keys if the target is still active. This\n // ensures that we can persist the updated target data along with\n // the updated assignment.\n\n o.push(n.Qr.removeMatchingKeys(e, s.removedDocuments, _).next(function () {\n return n.Qr.addMatchingKeys(e, s.addedDocuments, _);\n }));\n var u = a.withSequenceNumber(e.currentSequenceNumber);\n null !== t.targetMismatches.get(_) ? u = u.withResumeToken(ByteString.EMPTY_BYTE_STRING, SnapshotVersion.min()).withLastLimboFreeSnapshotVersion(SnapshotVersion.min()) : s.resumeToken.approximateByteSize() > 0 && (u = u.withResumeToken(s.resumeToken, r)), i = i.insert(_, u), // Update the target data if there are target changes (or if\n // sufficient time has passed since the last update).\n\n /**\n * Returns true if the newTargetData should be persisted during an update of\n * an active target. TargetData should always be persisted when a target is\n * being released and should not call this function.\n *\n * While the target is active, TargetData updates can be omitted when nothing\n * about the target has changed except metadata like the resume token or\n * snapshot version. Occasionally it's worth the extra write to prevent these\n * values from getting too stale after a crash, but this doesn't have to be\n * too frequent.\n */\n function __PRIVATE_shouldPersistTargetData(e, t, n) {\n // Always persist target data if we don't already have a resume token.\n if (0 === e.resumeToken.approximateByteSize()) return !0; // Don't allow resume token changes to be buffered indefinitely. This\n // allows us to be reasonably up-to-date after a crash and avoids needing\n // to loop over all active queries on shutdown. Especially in the browser\n // we may not get time to do anything interesting while the current tab is\n // closing.\n\n if (t.snapshotVersion.toMicroseconds() - e.snapshotVersion.toMicroseconds() >= 3e8) return !0; // Otherwise if the only thing that has changed about a target is its resume\n // token it's not worth persisting. Note that the RemoteStore keeps an\n // in-memory view of the currently active targets which includes the current\n // resume token, so stream failure or user changes will still use an\n // up-to-date resume token regardless of what we do here.\n\n return n.addedDocuments.size + n.modifiedDocuments.size + n.removedDocuments.size > 0;\n }\n /**\n * Notifies local store of the changed views to locally pin documents.\n */\n (a, u, s) && o.push(n.Qr.updateTargetData(e, u));\n });\n\n var _ = __PRIVATE_mutableDocumentMap(),\n a = __PRIVATE_documentKeySet(); // HACK: The only reason we allow a null snapshot version is so that we\n // can synthesize remote events when we get permission denied errors while\n // trying to resolve the state of a locally cached document that is in\n // limbo.\n\n\n if (t.documentUpdates.forEach(function (r) {\n t.resolvedLimboDocuments.has(r) && o.push(n.persistence.referenceDelegate.updateLimboDocument(e, r));\n }), // Each loop iteration only affects its \"own\" doc, so it's safe to get all\n // the remote documents in advance in a single call.\n o.push(__PRIVATE_populateDocumentChangeBuffer(e, s, t.documentUpdates).next(function (e) {\n _ = e.cs, a = e.ls;\n })), !r.isEqual(SnapshotVersion.min())) {\n var _t40 = n.Qr.getLastRemoteSnapshotVersion(e).next(function (t) {\n return n.Qr.setTargetsMetadata(e, e.currentSequenceNumber, r);\n });\n\n o.push(_t40);\n }\n\n return PersistencePromise.waitFor(o).next(function () {\n return s.apply(e);\n }).next(function () {\n return n.localDocuments.getLocalViewOfDocuments(e, _, a);\n }).next(function () {\n return _;\n });\n }).then(function (e) {\n return n.ns = i, e;\n });\n}\n/**\n * Populates document change buffer with documents from backend or a bundle.\n * Returns the document changes resulting from applying those documents, and\n * also a set of documents whose existence state are changed as a result.\n *\n * @param txn - Transaction to use to read existing documents from storage.\n * @param documentBuffer - Document buffer to collect the resulted changes to be\n * applied to storage.\n * @param documents - Documents to be applied.\n */\n\n\nfunction __PRIVATE_populateDocumentChangeBuffer(e, t, n) {\n var r = __PRIVATE_documentKeySet(),\n i = __PRIVATE_documentKeySet();\n\n return n.forEach(function (e) {\n return r = r.add(e);\n }), t.getEntries(e, r).next(function (e) {\n var r = __PRIVATE_mutableDocumentMap();\n\n return n.forEach(function (n, s) {\n var o = e.get(n); // Check if see if there is a existence state change for this document.\n\n s.isFoundDocument() !== o.isFoundDocument() && (i = i.add(n)), // Note: The order of the steps below is important, since we want\n // to ensure that rejected limbo resolutions (which fabricate\n // NoDocuments with SnapshotVersion.min()) never add documents to\n // cache.\n s.isNoDocument() && s.version.isEqual(SnapshotVersion.min()) ? ( // NoDocuments with SnapshotVersion.min() are used in manufactured\n // events. We remove these documents from cache since we lost\n // access.\n t.removeEntry(n, s.readTime), r = r.insert(n, s)) : !o.isValidDocument() || s.version.compareTo(o.version) > 0 || 0 === s.version.compareTo(o.version) && o.hasPendingWrites ? (t.addEntry(s), r = r.insert(n, s)) : __PRIVATE_logDebug(\"LocalStore\", \"Ignoring outdated watch update for \", n, \". Current version:\", o.version, \" Watch version:\", s.version);\n }), {\n cs: r,\n ls: i\n };\n });\n}\n/**\n * Gets the mutation batch after the passed in batchId in the mutation queue\n * or null if empty.\n * @param afterBatchId - If provided, the batch to search after.\n * @returns The next mutation or null if there wasn't one.\n */\n\n\nfunction __PRIVATE_localStoreGetNextMutationBatch(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return n.persistence.runTransaction(\"Get next mutation batch\", \"readonly\", function (e) {\n return void 0 === t && (t = -1), n.mutationQueue.getNextMutationBatchAfterBatchId(e, t);\n });\n}\n/**\n * Reads the current value of a Document with a given key or null if not\n * found - used for testing.\n */\n\n/**\n * Assigns the given target an internal ID so that its results can be pinned so\n * they don't get GC'd. A target must be allocated in the local store before\n * the store can be used to manage its view.\n *\n * Allocating an already allocated `Target` will return the existing `TargetData`\n * for that `Target`.\n */\n\n\nfunction __PRIVATE_localStoreAllocateTarget(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return n.persistence.runTransaction(\"Allocate target\", \"readwrite\", function (e) {\n var r;\n return n.Qr.getTargetData(e, t).next(function (i) {\n return i ? ( // This target has been listened to previously, so reuse the\n // previous targetID.\n // TODO(mcg): freshen last accessed date?\n r = i, PersistencePromise.resolve(r)) : n.Qr.allocateTargetId(e).next(function (i) {\n return r = new TargetData(t, i, \"TargetPurposeListen\"\n /* TargetPurpose.Listen */\n , e.currentSequenceNumber), n.Qr.addTargetData(e, r).next(function () {\n return r;\n });\n });\n });\n }).then(function (e) {\n // If Multi-Tab is enabled, the existing target data may be newer than\n // the in-memory data\n var r = n.ns.get(e.targetId);\n return (null === r || e.snapshotVersion.compareTo(r.snapshotVersion) > 0) && (n.ns = n.ns.insert(e.targetId, e), n.rs.set(t, e.targetId)), e;\n });\n}\n/**\n * Returns the TargetData as seen by the LocalStore, including updates that may\n * have not yet been persisted to the TargetCache.\n */\n// Visible for testing.\n\n/**\n * Unpins all the documents associated with the given target. If\n * `keepPersistedTargetData` is set to false and Eager GC enabled, the method\n * directly removes the associated target data from the target cache.\n *\n * Releasing a non-existing `Target` is a no-op.\n */\n// PORTING NOTE: `keepPersistedTargetData` is multi-tab only.\n\n\nfunction __PRIVATE_localStoreReleaseTarget(_x11, _x12, _x13) {\n return _PRIVATE_localStoreReleaseTarget.apply(this, arguments);\n}\n/**\n * Runs the specified query against the local store and returns the results,\n * potentially taking advantage of query data from previous executions (such\n * as the set of remote keys).\n *\n * @param usePreviousResults - Whether results from previous executions can\n * be used to optimize this query execution.\n */\n\n\nfunction _PRIVATE_localStoreReleaseTarget() {\n _PRIVATE_localStoreReleaseTarget = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee79(e, t, n) {\n var r, i, s;\n return _regeneratorRuntime.wrap(function _callee79$(_context79) {\n while (1) {\n switch (_context79.prev = _context79.next) {\n case 0:\n r = __PRIVATE_debugCast(e), i = r.ns.get(t), s = n ? \"readwrite\" : \"readwrite-primary\";\n _context79.prev = 1;\n _context79.t0 = n;\n\n if (_context79.t0) {\n _context79.next = 6;\n break;\n }\n\n _context79.next = 6;\n return r.persistence.runTransaction(\"Release target\", s, function (e) {\n return r.persistence.referenceDelegate.removeTarget(e, i);\n });\n\n case 6:\n _context79.next = 13;\n break;\n\n case 8:\n _context79.prev = 8;\n _context79.t1 = _context79[\"catch\"](1);\n\n if (__PRIVATE_isIndexedDbTransactionError(_context79.t1)) {\n _context79.next = 12;\n break;\n }\n\n throw _context79.t1;\n\n case 12:\n // All `releaseTarget` does is record the final metadata state for the\n // target, but we've been recording this periodically during target\n // activity. If we lose this write this could cause a very slight\n // difference in the order of target deletion during GC, but we\n // don't define exact LRU semantics so this is acceptable.\n __PRIVATE_logDebug(\"LocalStore\", \"Failed to update sequence numbers for target \".concat(t, \": \").concat(_context79.t1));\n\n case 13:\n r.ns = r.ns.remove(t), r.rs.delete(i.target);\n\n case 14:\n case \"end\":\n return _context79.stop();\n }\n }\n }, _callee79, null, [[1, 8]]);\n }));\n return _PRIVATE_localStoreReleaseTarget.apply(this, arguments);\n}\n\nfunction __PRIVATE_localStoreExecuteQuery(e, t, n) {\n var r = __PRIVATE_debugCast(e);\n\n var i = SnapshotVersion.min(),\n s = __PRIVATE_documentKeySet();\n\n return r.persistence.runTransaction(\"Execute query\", \"readwrite\", // Use readwrite instead of readonly so indexes can be created\n // Use readwrite instead of readonly so indexes can be created\n function (e) {\n return function __PRIVATE_localStoreGetTargetData(e, t, n) {\n var r = __PRIVATE_debugCast(e),\n i = r.rs.get(n);\n\n return void 0 !== i ? PersistencePromise.resolve(r.ns.get(i)) : r.Qr.getTargetData(t, n);\n }(r, e, __PRIVATE_queryToTarget(t)).next(function (t) {\n if (t) return i = t.lastLimboFreeSnapshotVersion, r.Qr.getMatchingKeysForTargetId(e, t.targetId).next(function (e) {\n s = e;\n });\n }).next(function () {\n return r.ts.getDocumentsMatchingQuery(e, t, n ? i : SnapshotVersion.min(), n ? s : __PRIVATE_documentKeySet());\n }).next(function (e) {\n return __PRIVATE_setMaxReadTime(r, __PRIVATE_queryCollectionGroup(t), e), {\n documents: e,\n hs: s\n };\n });\n });\n} // PORTING NOTE: Multi-Tab only.\n\n\nfunction __PRIVATE_localStoreGetCachedTarget(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = __PRIVATE_debugCast(n.Qr),\n i = n.ns.get(t);\n\n return i ? Promise.resolve(i.target) : n.persistence.runTransaction(\"Get target data\", \"readonly\", function (e) {\n return r._t(e, t).next(function (e) {\n return e ? e.target : null;\n });\n });\n}\n/**\n * Returns the set of documents that have been updated since the last call.\n * If this is the first call, returns the set of changes since client\n * initialization. Further invocations will return document that have changed\n * since the prior call.\n */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction __PRIVATE_localStoreGetNewDocumentChanges(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = n.ss.get(t) || SnapshotVersion.min(); // Get the current maximum read time for the collection. This should always\n // exist, but to reduce the chance for regressions we default to\n // SnapshotVersion.Min()\n // TODO(indexing): Consider removing the default value.\n\n\n return n.persistence.runTransaction(\"Get new document changes\", \"readonly\", function (e) {\n return n.os.getAllFromCollectionGroup(e, t, __PRIVATE_newIndexOffsetSuccessorFromReadTime(r, -1),\n /* limit= */\n Number.MAX_SAFE_INTEGER);\n }).then(function (e) {\n return __PRIVATE_setMaxReadTime(n, t, e), e;\n });\n}\n/** Sets the collection group's maximum read time from the given documents. */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction __PRIVATE_setMaxReadTime(e, t, n) {\n var r = e.ss.get(t) || SnapshotVersion.min();\n n.forEach(function (e, t) {\n t.readTime.compareTo(r) > 0 && (r = t.readTime);\n }), e.ss.set(t, r);\n}\n/**\n * Creates a new target using the given bundle name, which will be used to\n * hold the keys of all documents from the bundle in query-document mappings.\n * This ensures that the loaded documents do not get garbage collected\n * right away.\n */\n\n/**\n * Applies the documents from a bundle to the \"ground-state\" (remote)\n * documents.\n *\n * LocalDocuments are re-calculated if there are remaining mutations in the\n * queue.\n */\n\n\nfunction __PRIVATE_localStoreApplyBundledDocuments(_x14, _x15, _x16, _x17) {\n return _PRIVATE_localStoreApplyBundledDocuments.apply(this, arguments);\n}\n/**\n * Returns a promise of a boolean to indicate if the given bundle has already\n * been loaded and the create time is newer than the current loading bundle.\n */\n\n/**\n * Saves the given `NamedQuery` to local persistence.\n */\n\n\nfunction _PRIVATE_localStoreApplyBundledDocuments() {\n _PRIVATE_localStoreApplyBundledDocuments = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee80(e, t, n, r) {\n var i, s, o, _iterator92, _step92, _e120, _n38, _r37, _, a;\n\n return _regeneratorRuntime.wrap(function _callee80$(_context80) {\n while (1) {\n switch (_context80.prev = _context80.next) {\n case 0:\n i = __PRIVATE_debugCast(e);\n s = __PRIVATE_documentKeySet(), o = __PRIVATE_mutableDocumentMap();\n _iterator92 = _createForOfIteratorHelper(n);\n\n try {\n for (_iterator92.s(); !(_step92 = _iterator92.n()).done;) {\n _e120 = _step92.value;\n _n38 = t.Ps(_e120.metadata.name);\n _e120.document && (s = s.add(_n38));\n _r37 = t.Is(_e120);\n _r37.setReadTime(t.Ts(_e120.metadata.readTime)), o = o.insert(_n38, _r37);\n }\n } catch (err) {\n _iterator92.e(err);\n } finally {\n _iterator92.f();\n }\n\n _ = i.os.newChangeBuffer({\n trackRemovals: !0\n });\n _context80.next = 7;\n return __PRIVATE_localStoreAllocateTarget(i, function __PRIVATE_umbrellaTarget(e) {\n // It is OK that the path used for the query is not valid, because this will\n // not be read and queried.\n return __PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(ResourcePath.fromString(\"__bundle__/docs/\".concat(e))));\n }(r));\n\n case 7:\n a = _context80.sent;\n return _context80.abrupt(\"return\", i.persistence.runTransaction(\"Apply bundle documents\", \"readwrite\", function (e) {\n return __PRIVATE_populateDocumentChangeBuffer(e, _, o).next(function (t) {\n return _.apply(e), t;\n }).next(function (t) {\n return i.Qr.removeMatchingKeysForTargetId(e, a.targetId).next(function () {\n return i.Qr.addMatchingKeys(e, s, a.targetId);\n }).next(function () {\n return i.localDocuments.getLocalViewOfDocuments(e, t.cs, t.ls);\n }).next(function () {\n return t.cs;\n });\n });\n }));\n\n case 9:\n case \"end\":\n return _context80.stop();\n }\n }\n }, _callee80);\n }));\n return _PRIVATE_localStoreApplyBundledDocuments.apply(this, arguments);\n}\n\nfunction __PRIVATE_localStoreSaveNamedQuery(_x18, _x19) {\n return _PRIVATE_localStoreSaveNamedQuery.apply(this, arguments);\n}\n/** Assembles the key for a client state in WebStorage */\n\n\nfunction _PRIVATE_localStoreSaveNamedQuery() {\n _PRIVATE_localStoreSaveNamedQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee81(e, t) {\n var n,\n r,\n i,\n _args81 = arguments;\n return _regeneratorRuntime.wrap(function _callee81$(_context81) {\n while (1) {\n switch (_context81.prev = _context81.next) {\n case 0:\n n = _args81.length > 2 && _args81[2] !== undefined ? _args81[2] : __PRIVATE_documentKeySet();\n _context81.next = 3;\n return __PRIVATE_localStoreAllocateTarget(e, __PRIVATE_queryToTarget(__PRIVATE_fromBundledQuery(t.bundledQuery)));\n\n case 3:\n r = _context81.sent;\n i = __PRIVATE_debugCast(e);\n return _context81.abrupt(\"return\", i.persistence.runTransaction(\"Save named query\", \"readwrite\", function (e) {\n var s = __PRIVATE_fromVersion(t.readTime); // Simply save the query itself if it is older than what the SDK already\n // has.\n\n\n // Simply save the query itself if it is older than what the SDK already\n // has.\n if (r.snapshotVersion.compareTo(s) >= 0) return i.$r.saveNamedQuery(e, t); // Update existing target data because the query from the bundle is newer.\n\n // Update existing target data because the query from the bundle is newer.\n var o = r.withResumeToken(ByteString.EMPTY_BYTE_STRING, s);\n return i.ns = i.ns.insert(o.targetId, o), i.Qr.updateTargetData(e, o).next(function () {\n return i.Qr.removeMatchingKeysForTargetId(e, r.targetId);\n }).next(function () {\n return i.Qr.addMatchingKeys(e, n, r.targetId);\n }).next(function () {\n return i.$r.saveNamedQuery(e, t);\n });\n }));\n\n case 6:\n case \"end\":\n return _context81.stop();\n }\n }\n }, _callee81);\n }));\n return _PRIVATE_localStoreSaveNamedQuery.apply(this, arguments);\n}\n\nfunction createWebStorageClientStateKey(e, t) {\n return \"firestore_clients_\".concat(e, \"_\").concat(t);\n} // The format of the WebStorage key that stores the mutation state is:\n// firestore_mutations__\n// (for unauthenticated users)\n// or: firestore_mutations___\n// 'user_uid' is last to avoid needing to escape '_' characters that it might\n// contain.\n\n/** Assembles the key for a mutation batch in WebStorage */\n\n\nfunction createWebStorageMutationBatchKey(e, t, n) {\n var r = \"firestore_mutations_\".concat(e, \"_\").concat(n);\n return t.isAuthenticated() && (r += \"_\".concat(t.uid)), r;\n} // The format of the WebStorage key that stores a query target's metadata is:\n// firestore_targets__\n\n/** Assembles the key for a query state in WebStorage */\n\n\nfunction createWebStorageQueryTargetMetadataKey(e, t) {\n return \"firestore_targets_\".concat(e, \"_\").concat(t);\n} // The WebStorage prefix that stores the primary tab's online state. The\n// format of the key is:\n// firestore_online_state_\n\n/**\n * Holds the state of a mutation batch, including its user ID, batch ID and\n * whether the batch is 'pending', 'acknowledged' or 'rejected'.\n */\n// Visible for testing\n\n\nvar __PRIVATE_MutationMetadata = /*#__PURE__*/function () {\n function __PRIVATE_MutationMetadata(e, t, n, r) {\n _classCallCheck(this, __PRIVATE_MutationMetadata);\n\n this.user = e, this.batchId = t, this.state = n, this.error = r;\n }\n /**\n * Parses a MutationMetadata from its JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */\n\n\n _createClass(__PRIVATE_MutationMetadata, [{\n key: \"ds\",\n value: function ds() {\n var e = {\n state: this.state,\n updateTimeMs: Date.now()\n };\n return this.error && (e.error = {\n code: this.error.code,\n message: this.error.message\n }), JSON.stringify(e);\n }\n }], [{\n key: \"Es\",\n value: function Es(e, t, n) {\n var r = JSON.parse(n);\n var i,\n s = \"object\" == typeof r && -1 !== [\"pending\", \"acknowledged\", \"rejected\"].indexOf(r.state) && (void 0 === r.error || \"object\" == typeof r.error);\n return s && r.error && (s = \"string\" == typeof r.error.message && \"string\" == typeof r.error.code, s && (i = new FirestoreError(r.error.code, r.error.message))), s ? new __PRIVATE_MutationMetadata(e, t, r.state, i) : (__PRIVATE_logError(\"SharedClientState\", \"Failed to parse mutation state for ID '\".concat(t, \"': \").concat(n)), null);\n }\n }]);\n\n return __PRIVATE_MutationMetadata;\n}();\n/**\n * Holds the state of a query target, including its target ID and whether the\n * target is 'not-current', 'current' or 'rejected'.\n */\n// Visible for testing\n\n\nvar __PRIVATE_QueryTargetMetadata = /*#__PURE__*/function () {\n function __PRIVATE_QueryTargetMetadata(e, t, n) {\n _classCallCheck(this, __PRIVATE_QueryTargetMetadata);\n\n this.targetId = e, this.state = t, this.error = n;\n }\n /**\n * Parses a QueryTargetMetadata from its JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */\n\n\n _createClass(__PRIVATE_QueryTargetMetadata, [{\n key: \"ds\",\n value: function ds() {\n var e = {\n state: this.state,\n updateTimeMs: Date.now()\n };\n return this.error && (e.error = {\n code: this.error.code,\n message: this.error.message\n }), JSON.stringify(e);\n }\n }], [{\n key: \"Es\",\n value: function Es(e, t) {\n var n = JSON.parse(t);\n var r,\n i = \"object\" == typeof n && -1 !== [\"not-current\", \"current\", \"rejected\"].indexOf(n.state) && (void 0 === n.error || \"object\" == typeof n.error);\n return i && n.error && (i = \"string\" == typeof n.error.message && \"string\" == typeof n.error.code, i && (r = new FirestoreError(n.error.code, n.error.message))), i ? new __PRIVATE_QueryTargetMetadata(e, n.state, r) : (__PRIVATE_logError(\"SharedClientState\", \"Failed to parse target state for ID '\".concat(e, \"': \").concat(t)), null);\n }\n }]);\n\n return __PRIVATE_QueryTargetMetadata;\n}();\n/**\n * This class represents the immutable ClientState for a client read from\n * WebStorage, containing the list of active query targets.\n */\n\n\nvar __PRIVATE_RemoteClientState = /*#__PURE__*/function () {\n function __PRIVATE_RemoteClientState(e, t) {\n _classCallCheck(this, __PRIVATE_RemoteClientState);\n\n this.clientId = e, this.activeTargetIds = t;\n }\n /**\n * Parses a RemoteClientState from the JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */\n\n\n _createClass(__PRIVATE_RemoteClientState, null, [{\n key: \"Es\",\n value: function Es(e, t) {\n var n = JSON.parse(t);\n\n var r = \"object\" == typeof n && n.activeTargetIds instanceof Array,\n i = __PRIVATE_targetIdSet();\n\n for (var _e77 = 0; r && _e77 < n.activeTargetIds.length; ++_e77) {\n r = isSafeInteger(n.activeTargetIds[_e77]), i = i.add(n.activeTargetIds[_e77]);\n }\n\n return r ? new __PRIVATE_RemoteClientState(e, i) : (__PRIVATE_logError(\"SharedClientState\", \"Failed to parse client data for instance '\".concat(e, \"': \").concat(t)), null);\n }\n }]);\n\n return __PRIVATE_RemoteClientState;\n}();\n/**\n * This class represents the online state for all clients participating in\n * multi-tab. The online state is only written to by the primary client, and\n * used in secondary clients to update their query views.\n */\n\n\nvar __PRIVATE_SharedOnlineState = /*#__PURE__*/function () {\n function __PRIVATE_SharedOnlineState(e, t) {\n _classCallCheck(this, __PRIVATE_SharedOnlineState);\n\n this.clientId = e, this.onlineState = t;\n }\n /**\n * Parses a SharedOnlineState from its JSON representation in WebStorage.\n * Logs a warning and returns null if the format of the data is not valid.\n */\n\n\n _createClass(__PRIVATE_SharedOnlineState, null, [{\n key: \"Es\",\n value: function Es(e) {\n var t = JSON.parse(e);\n return \"object\" == typeof t && -1 !== [\"Unknown\", \"Online\", \"Offline\"].indexOf(t.onlineState) && \"string\" == typeof t.clientId ? new __PRIVATE_SharedOnlineState(t.clientId, t.onlineState) : (__PRIVATE_logError(\"SharedClientState\", \"Failed to parse online state: \".concat(e)), null);\n }\n }]);\n\n return __PRIVATE_SharedOnlineState;\n}();\n/**\n * Metadata state of the local client. Unlike `RemoteClientState`, this class is\n * mutable and keeps track of all pending mutations, which allows us to\n * update the range of pending mutation batch IDs as new mutations are added or\n * removed.\n *\n * The data in `LocalClientState` is not read from WebStorage and instead\n * updated via its instance methods. The updated state can be serialized via\n * `toWebStorageJSON()`.\n */\n// Visible for testing.\n\n\nvar __PRIVATE_LocalClientState = /*#__PURE__*/function () {\n function __PRIVATE_LocalClientState() {\n _classCallCheck(this, __PRIVATE_LocalClientState);\n\n this.activeTargetIds = __PRIVATE_targetIdSet();\n }\n\n _createClass(__PRIVATE_LocalClientState, [{\n key: \"As\",\n value: function As(e) {\n this.activeTargetIds = this.activeTargetIds.add(e);\n }\n }, {\n key: \"Rs\",\n value: function Rs(e) {\n this.activeTargetIds = this.activeTargetIds.delete(e);\n }\n /**\n * Converts this entry into a JSON-encoded format we can use for WebStorage.\n * Does not encode `clientId` as it is part of the key in WebStorage.\n */\n\n }, {\n key: \"ds\",\n value: function ds() {\n var e = {\n activeTargetIds: this.activeTargetIds.toArray(),\n updateTimeMs: Date.now()\n };\n return JSON.stringify(e);\n }\n }]);\n\n return __PRIVATE_LocalClientState;\n}();\n/**\n * `WebStorageSharedClientState` uses WebStorage (window.localStorage) as the\n * backing store for the SharedClientState. It keeps track of all active\n * clients and supports modifications of the local client's data.\n */\n\n\nvar __PRIVATE_WebStorageSharedClientState = /*#__PURE__*/function () {\n function __PRIVATE_WebStorageSharedClientState(e, t, n, r, i) {\n _classCallCheck(this, __PRIVATE_WebStorageSharedClientState);\n\n this.window = e, this.oi = t, this.persistenceKey = n, this.Vs = r, this.syncEngine = null, this.onlineStateHandler = null, this.sequenceNumberHandler = null, this.fs = this.gs.bind(this), this.ps = new SortedMap(__PRIVATE_primitiveComparator), this.started = !1,\n /**\n * Captures WebStorage events that occur before `start()` is called. These\n * events are replayed once `WebStorageSharedClientState` is started.\n */\n this.ys = []; // Escape the special characters mentioned here:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n\n var s = n.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n this.storage = this.window.localStorage, this.currentUser = i, this.ws = createWebStorageClientStateKey(this.persistenceKey, this.Vs), this.Ss =\n /** Assembles the key for the current sequence number. */\n function createWebStorageSequenceNumberKey(e) {\n return \"firestore_sequence_number_\".concat(e);\n }\n /**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n (this.persistenceKey), this.ps = this.ps.insert(this.Vs, new __PRIVATE_LocalClientState()), this.bs = new RegExp(\"^firestore_clients_\".concat(s, \"_([^_]*)$\")), this.Ds = new RegExp(\"^firestore_mutations_\".concat(s, \"_(\\\\d+)(?:_(.*))?$\")), this.Cs = new RegExp(\"^firestore_targets_\".concat(s, \"_(\\\\d+)$\")), this.vs =\n /** Assembles the key for the online state of the primary tab. */\n function createWebStorageOnlineStateKey(e) {\n return \"firestore_online_state_\".concat(e);\n } // The WebStorage prefix that plays as a event to indicate the remote documents\n // might have changed due to some secondary tabs loading a bundle.\n // format of the key is:\n // firestore_bundle_loaded_v2_\n // The version ending with \"v2\" stores the list of modified collection groups.\n (this.persistenceKey), this.Fs = function createBundleLoadedKey(e) {\n return \"firestore_bundle_loaded_v2_\".concat(e);\n } // The WebStorage key prefix for the key that stores the last sequence number allocated. The key\n // looks like 'firestore_sequence_number_'.\n (this.persistenceKey), // Rather than adding the storage observer during start(), we add the\n // storage observer during initialization. This ensures that we collect\n // events before other components populate their initial state (during their\n // respective start() calls). Otherwise, we might for example miss a\n // mutation that is added after LocalStore's start() processed the existing\n // mutations but before we observe WebStorage events.\n this.window.addEventListener(\"storage\", this.fs);\n }\n /** Returns 'true' if WebStorage is available in the current environment. */\n\n\n _createClass(__PRIVATE_WebStorageSharedClientState, [{\n key: \"start\",\n value: function () {\n var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {\n var _this157 = this;\n\n var e, _iterator60, _step60, _t41, _e79, n, t, _e78, _iterator61, _step61, _e80;\n\n return _regeneratorRuntime.wrap(function _callee13$(_context13) {\n while (1) {\n switch (_context13.prev = _context13.next) {\n case 0:\n _context13.next = 2;\n return this.syncEngine.Li();\n\n case 2:\n e = _context13.sent;\n _iterator60 = _createForOfIteratorHelper(e);\n _context13.prev = 4;\n\n _iterator60.s();\n\n case 6:\n if ((_step60 = _iterator60.n()).done) {\n _context13.next = 14;\n break;\n }\n\n _t41 = _step60.value;\n\n if (!(_t41 === this.Vs)) {\n _context13.next = 10;\n break;\n }\n\n return _context13.abrupt(\"continue\", 12);\n\n case 10:\n _e79 = this.getItem(createWebStorageClientStateKey(this.persistenceKey, _t41));\n\n if (_e79) {\n n = __PRIVATE_RemoteClientState.Es(_t41, _e79);\n n && (this.ps = this.ps.insert(n.clientId, n));\n }\n\n case 12:\n _context13.next = 6;\n break;\n\n case 14:\n _context13.next = 19;\n break;\n\n case 16:\n _context13.prev = 16;\n _context13.t0 = _context13[\"catch\"](4);\n\n _iterator60.e(_context13.t0);\n\n case 19:\n _context13.prev = 19;\n\n _iterator60.f();\n\n return _context13.finish(19);\n\n case 22:\n this.Ms(); // Check if there is an existing online state and call the callback handler\n // if applicable.\n\n t = this.storage.getItem(this.vs);\n\n if (t) {\n _e78 = this.xs(t);\n _e78 && this.Os(_e78);\n }\n\n _iterator61 = _createForOfIteratorHelper(this.ys);\n\n try {\n for (_iterator61.s(); !(_step61 = _iterator61.n()).done;) {\n _e80 = _step61.value;\n this.gs(_e80);\n }\n } catch (err) {\n _iterator61.e(err);\n } finally {\n _iterator61.f();\n }\n\n this.ys = [], // Register a window unload hook to remove the client metadata entry from\n // WebStorage even if `shutdown()` was not called.\n this.window.addEventListener(\"pagehide\", function () {\n return _this157.shutdown();\n }), this.started = !0;\n\n case 28:\n case \"end\":\n return _context13.stop();\n }\n }\n }, _callee13, this, [[4, 16, 19, 22]]);\n }));\n\n function start() {\n return _start.apply(this, arguments);\n }\n\n return start;\n }()\n }, {\n key: \"writeSequenceNumber\",\n value: function writeSequenceNumber(e) {\n this.setItem(this.Ss, JSON.stringify(e));\n }\n }, {\n key: \"getAllActiveQueryTargets\",\n value: function getAllActiveQueryTargets() {\n return this.Ns(this.ps);\n }\n }, {\n key: \"isActiveQueryTarget\",\n value: function isActiveQueryTarget(e) {\n var t = !1;\n return this.ps.forEach(function (n, r) {\n r.activeTargetIds.has(e) && (t = !0);\n }), t;\n }\n }, {\n key: \"addPendingMutation\",\n value: function addPendingMutation(e) {\n this.Bs(e, \"pending\");\n }\n }, {\n key: \"updateMutationState\",\n value: function updateMutationState(e, t, n) {\n this.Bs(e, t, n), // Once a final mutation result is observed by other clients, they no longer\n // access the mutation's metadata entry. Since WebStorage replays events\n // in order, it is safe to delete the entry right after updating it.\n this.Ls(e);\n }\n }, {\n key: \"addLocalQueryTarget\",\n value: function addLocalQueryTarget(e) {\n var t = \"not-current\"; // Lookup an existing query state if the target ID was already registered\n // by another tab\n\n if (this.isActiveQueryTarget(e)) {\n var n = this.storage.getItem(createWebStorageQueryTargetMetadataKey(this.persistenceKey, e));\n\n if (n) {\n var r = __PRIVATE_QueryTargetMetadata.Es(e, n);\n\n r && (t = r.state);\n }\n }\n\n return this.ks.As(e), this.Ms(), t;\n }\n }, {\n key: \"removeLocalQueryTarget\",\n value: function removeLocalQueryTarget(e) {\n this.ks.Rs(e), this.Ms();\n }\n }, {\n key: \"isLocalQueryTarget\",\n value: function isLocalQueryTarget(e) {\n return this.ks.activeTargetIds.has(e);\n }\n }, {\n key: \"clearQueryState\",\n value: function clearQueryState(e) {\n this.removeItem(createWebStorageQueryTargetMetadataKey(this.persistenceKey, e));\n }\n }, {\n key: \"updateQueryState\",\n value: function updateQueryState(e, t, n) {\n this.qs(e, t, n);\n }\n }, {\n key: \"handleUserChange\",\n value: function handleUserChange(e, t, n) {\n var _this158 = this;\n\n t.forEach(function (e) {\n _this158.Ls(e);\n }), this.currentUser = e, n.forEach(function (e) {\n _this158.addPendingMutation(e);\n });\n }\n }, {\n key: \"setOnlineState\",\n value: function setOnlineState(e) {\n this.Qs(e);\n }\n }, {\n key: \"notifyBundleLoaded\",\n value: function notifyBundleLoaded(e) {\n this.Ks(e);\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {\n this.started && (this.window.removeEventListener(\"storage\", this.fs), this.removeItem(this.ws), this.started = !1);\n }\n }, {\n key: \"getItem\",\n value: function getItem(e) {\n var t = this.storage.getItem(e);\n return __PRIVATE_logDebug(\"SharedClientState\", \"READ\", e, t), t;\n }\n }, {\n key: \"setItem\",\n value: function setItem(e, t) {\n __PRIVATE_logDebug(\"SharedClientState\", \"SET\", e, t), this.storage.setItem(e, t);\n }\n }, {\n key: \"removeItem\",\n value: function removeItem(e) {\n __PRIVATE_logDebug(\"SharedClientState\", \"REMOVE\", e), this.storage.removeItem(e);\n }\n }, {\n key: \"gs\",\n value: function gs(e) {\n var _this159 = this;\n\n // Note: The function is typed to take Event to be interface-compatible with\n // `Window.addEventListener`.\n var t = e;\n\n if (t.storageArea === this.storage) {\n if (__PRIVATE_logDebug(\"SharedClientState\", \"EVENT\", t.key, t.newValue), t.key === this.ws) return void __PRIVATE_logError(\"Received WebStorage notification for local change. Another client might have garbage-collected our state\");\n this.oi.enqueueRetryable( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {\n var _e81, _e82, _e83, _e84, _e85, _e86, _e87;\n\n return _regeneratorRuntime.wrap(function _callee14$(_context14) {\n while (1) {\n switch (_context14.prev = _context14.next) {\n case 0:\n if (!_this159.started) {\n _context14.next = 43;\n break;\n }\n\n if (!(null !== t.key)) {\n _context14.next = 41;\n break;\n }\n\n if (!_this159.bs.test(t.key)) {\n _context14.next = 11;\n break;\n }\n\n if (!(null == t.newValue)) {\n _context14.next = 6;\n break;\n }\n\n _e81 = _this159.$s(t.key);\n return _context14.abrupt(\"return\", _this159.Us(_e81, null));\n\n case 6:\n _e82 = _this159.Ws(t.key, t.newValue);\n\n if (!_e82) {\n _context14.next = 9;\n break;\n }\n\n return _context14.abrupt(\"return\", _this159.Us(_e82.clientId, _e82));\n\n case 9:\n _context14.next = 41;\n break;\n\n case 11:\n if (!_this159.Ds.test(t.key)) {\n _context14.next = 18;\n break;\n }\n\n if (!(null !== t.newValue)) {\n _context14.next = 16;\n break;\n }\n\n _e83 = _this159.Gs(t.key, t.newValue);\n\n if (!_e83) {\n _context14.next = 16;\n break;\n }\n\n return _context14.abrupt(\"return\", _this159.zs(_e83));\n\n case 16:\n _context14.next = 41;\n break;\n\n case 18:\n if (!_this159.Cs.test(t.key)) {\n _context14.next = 25;\n break;\n }\n\n if (!(null !== t.newValue)) {\n _context14.next = 23;\n break;\n }\n\n _e84 = _this159.js(t.key, t.newValue);\n\n if (!_e84) {\n _context14.next = 23;\n break;\n }\n\n return _context14.abrupt(\"return\", _this159.Hs(_e84));\n\n case 23:\n _context14.next = 41;\n break;\n\n case 25:\n if (!(t.key === _this159.vs)) {\n _context14.next = 32;\n break;\n }\n\n if (!(null !== t.newValue)) {\n _context14.next = 30;\n break;\n }\n\n _e85 = _this159.xs(t.newValue);\n\n if (!_e85) {\n _context14.next = 30;\n break;\n }\n\n return _context14.abrupt(\"return\", _this159.Os(_e85));\n\n case 30:\n _context14.next = 41;\n break;\n\n case 32:\n if (!(t.key === _this159.Ss)) {\n _context14.next = 37;\n break;\n }\n\n _e86 = function __PRIVATE_fromWebStorageSequenceNumber(e) {\n var t = __PRIVATE_ListenSequence._e;\n if (null != e) try {\n var n = JSON.parse(e);\n __PRIVATE_hardAssert(\"number\" == typeof n), t = n;\n } catch (e) {\n __PRIVATE_logError(\"SharedClientState\", \"Failed to read sequence number from WebStorage\", e);\n }\n return t;\n }\n /**\n * `MemorySharedClientState` is a simple implementation of SharedClientState for\n * clients using memory persistence. The state in this class remains fully\n * isolated and no synchronization is performed.\n */\n (t.newValue);\n\n _e86 !== __PRIVATE_ListenSequence._e && _this159.sequenceNumberHandler(_e86);\n _context14.next = 41;\n break;\n\n case 37:\n if (!(t.key === _this159.Fs)) {\n _context14.next = 41;\n break;\n }\n\n _e87 = _this159.Js(t.newValue);\n _context14.next = 41;\n return Promise.all(_e87.map(function (e) {\n return _this159.syncEngine.Ys(e);\n }));\n\n case 41:\n _context14.next = 44;\n break;\n\n case 43:\n _this159.ys.push(t);\n\n case 44:\n case \"end\":\n return _context14.stop();\n }\n }\n }, _callee14);\n })));\n }\n }\n }, {\n key: \"ks\",\n get: function get() {\n return this.ps.get(this.Vs);\n }\n }, {\n key: \"Ms\",\n value: function Ms() {\n this.setItem(this.ws, this.ks.ds());\n }\n }, {\n key: \"Bs\",\n value: function Bs(e, t, n) {\n var r = new __PRIVATE_MutationMetadata(this.currentUser, e, t, n),\n i = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);\n this.setItem(i, r.ds());\n }\n }, {\n key: \"Ls\",\n value: function Ls(e) {\n var t = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);\n this.removeItem(t);\n }\n }, {\n key: \"Qs\",\n value: function Qs(e) {\n var t = {\n clientId: this.Vs,\n onlineState: e\n };\n this.storage.setItem(this.vs, JSON.stringify(t));\n }\n }, {\n key: \"qs\",\n value: function qs(e, t, n) {\n var r = createWebStorageQueryTargetMetadataKey(this.persistenceKey, e),\n i = new __PRIVATE_QueryTargetMetadata(e, t, n);\n this.setItem(r, i.ds());\n }\n }, {\n key: \"Ks\",\n value: function Ks(e) {\n var t = JSON.stringify(Array.from(e));\n this.setItem(this.Fs, t);\n }\n /**\n * Parses a client state key in WebStorage. Returns null if the key does not\n * match the expected key format.\n */\n\n }, {\n key: \"$s\",\n value: function $s(e) {\n var t = this.bs.exec(e);\n return t ? t[1] : null;\n }\n /**\n * Parses a client state in WebStorage. Returns 'null' if the value could not\n * be parsed.\n */\n\n }, {\n key: \"Ws\",\n value: function Ws(e, t) {\n var n = this.$s(e);\n return __PRIVATE_RemoteClientState.Es(n, t);\n }\n /**\n * Parses a mutation batch state in WebStorage. Returns 'null' if the value\n * could not be parsed.\n */\n\n }, {\n key: \"Gs\",\n value: function Gs(e, t) {\n var n = this.Ds.exec(e),\n r = Number(n[1]),\n i = void 0 !== n[2] ? n[2] : null;\n return __PRIVATE_MutationMetadata.Es(new User(i), r, t);\n }\n /**\n * Parses a query target state from WebStorage. Returns 'null' if the value\n * could not be parsed.\n */\n\n }, {\n key: \"js\",\n value: function js(e, t) {\n var n = this.Cs.exec(e),\n r = Number(n[1]);\n return __PRIVATE_QueryTargetMetadata.Es(r, t);\n }\n /**\n * Parses an online state from WebStorage. Returns 'null' if the value\n * could not be parsed.\n */\n\n }, {\n key: \"xs\",\n value: function xs(e) {\n return __PRIVATE_SharedOnlineState.Es(e);\n }\n }, {\n key: \"Js\",\n value: function Js(e) {\n return JSON.parse(e);\n }\n }, {\n key: \"zs\",\n value: function () {\n var _zs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(e) {\n return _regeneratorRuntime.wrap(function _callee15$(_context15) {\n while (1) {\n switch (_context15.prev = _context15.next) {\n case 0:\n if (!(e.user.uid === this.currentUser.uid)) {\n _context15.next = 2;\n break;\n }\n\n return _context15.abrupt(\"return\", this.syncEngine.Zs(e.batchId, e.state, e.error));\n\n case 2:\n __PRIVATE_logDebug(\"SharedClientState\", \"Ignoring mutation for non-active user \".concat(e.user.uid));\n\n case 3:\n case \"end\":\n return _context15.stop();\n }\n }\n }, _callee15, this);\n }));\n\n function zs(_x20) {\n return _zs.apply(this, arguments);\n }\n\n return zs;\n }()\n }, {\n key: \"Hs\",\n value: function Hs(e) {\n return this.syncEngine.Xs(e.targetId, e.state, e.error);\n }\n }, {\n key: \"Us\",\n value: function Us(e, t) {\n var _this160 = this;\n\n var n = t ? this.ps.insert(e, t) : this.ps.remove(e),\n r = this.Ns(this.ps),\n i = this.Ns(n),\n s = [],\n o = [];\n return i.forEach(function (e) {\n r.has(e) || s.push(e);\n }), r.forEach(function (e) {\n i.has(e) || o.push(e);\n }), this.syncEngine.eo(s, o).then(function () {\n _this160.ps = n;\n });\n }\n }, {\n key: \"Os\",\n value: function Os(e) {\n // We check whether the client that wrote this online state is still active\n // by comparing its client ID to the list of clients kept active in\n // IndexedDb. If a client does not update their IndexedDb client state\n // within 5 seconds, it is considered inactive and we don't emit an online\n // state event.\n this.ps.get(e.clientId) && this.onlineStateHandler(e.onlineState);\n }\n }, {\n key: \"Ns\",\n value: function Ns(e) {\n var t = __PRIVATE_targetIdSet();\n\n return e.forEach(function (e, n) {\n t = t.unionWith(n.activeTargetIds);\n }), t;\n }\n }], [{\n key: \"D\",\n value: function D(e) {\n return !(!e || !e.localStorage);\n }\n }]);\n\n return __PRIVATE_WebStorageSharedClientState;\n}();\n\nvar __PRIVATE_MemorySharedClientState = /*#__PURE__*/function () {\n function __PRIVATE_MemorySharedClientState() {\n _classCallCheck(this, __PRIVATE_MemorySharedClientState);\n\n this.no = new __PRIVATE_LocalClientState(), this.ro = {}, this.onlineStateHandler = null, this.sequenceNumberHandler = null;\n }\n\n _createClass(__PRIVATE_MemorySharedClientState, [{\n key: \"addPendingMutation\",\n value: function addPendingMutation(e) {// No op.\n }\n }, {\n key: \"updateMutationState\",\n value: function updateMutationState(e, t, n) {// No op.\n }\n }, {\n key: \"addLocalQueryTarget\",\n value: function addLocalQueryTarget(e) {\n return this.no.As(e), this.ro[e] || \"not-current\";\n }\n }, {\n key: \"updateQueryState\",\n value: function updateQueryState(e, t, n) {\n this.ro[e] = t;\n }\n }, {\n key: \"removeLocalQueryTarget\",\n value: function removeLocalQueryTarget(e) {\n this.no.Rs(e);\n }\n }, {\n key: \"isLocalQueryTarget\",\n value: function isLocalQueryTarget(e) {\n return this.no.activeTargetIds.has(e);\n }\n }, {\n key: \"clearQueryState\",\n value: function clearQueryState(e) {\n delete this.ro[e];\n }\n }, {\n key: \"getAllActiveQueryTargets\",\n value: function getAllActiveQueryTargets() {\n return this.no.activeTargetIds;\n }\n }, {\n key: \"isActiveQueryTarget\",\n value: function isActiveQueryTarget(e) {\n return this.no.activeTargetIds.has(e);\n }\n }, {\n key: \"start\",\n value: function start() {\n return this.no = new __PRIVATE_LocalClientState(), Promise.resolve();\n }\n }, {\n key: \"handleUserChange\",\n value: function handleUserChange(e, t, n) {// No op.\n }\n }, {\n key: \"setOnlineState\",\n value: function setOnlineState(e) {// No op.\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {}\n }, {\n key: \"writeSequenceNumber\",\n value: function writeSequenceNumber(e) {}\n }, {\n key: \"notifyBundleLoaded\",\n value: function notifyBundleLoaded(e) {// No op.\n }\n }]);\n\n return __PRIVATE_MemorySharedClientState;\n}();\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_NoopConnectivityMonitor = /*#__PURE__*/function () {\n function __PRIVATE_NoopConnectivityMonitor() {\n _classCallCheck(this, __PRIVATE_NoopConnectivityMonitor);\n }\n\n _createClass(__PRIVATE_NoopConnectivityMonitor, [{\n key: \"io\",\n value: function io(e) {// No-op.\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {// No-op.\n }\n }]);\n\n return __PRIVATE_NoopConnectivityMonitor;\n}();\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// References to `window` are guarded by BrowserConnectivityMonitor.isAvailable()\n\n/* eslint-disable no-restricted-globals */\n\n/**\n * Browser implementation of ConnectivityMonitor.\n */\n\n\nvar __PRIVATE_BrowserConnectivityMonitor = /*#__PURE__*/function () {\n function __PRIVATE_BrowserConnectivityMonitor() {\n var _this161 = this;\n\n _classCallCheck(this, __PRIVATE_BrowserConnectivityMonitor);\n\n this.so = function () {\n return _this161.oo();\n }, this._o = function () {\n return _this161.ao();\n }, this.uo = [], this.co();\n }\n\n _createClass(__PRIVATE_BrowserConnectivityMonitor, [{\n key: \"io\",\n value: function io(e) {\n this.uo.push(e);\n }\n }, {\n key: \"shutdown\",\n value: function shutdown() {\n window.removeEventListener(\"online\", this.so), window.removeEventListener(\"offline\", this._o);\n }\n }, {\n key: \"co\",\n value: function co() {\n window.addEventListener(\"online\", this.so), window.addEventListener(\"offline\", this._o);\n }\n }, {\n key: \"oo\",\n value: function oo() {\n __PRIVATE_logDebug(\"ConnectivityMonitor\", \"Network connectivity changed: AVAILABLE\");\n\n var _iterator62 = _createForOfIteratorHelper(this.uo),\n _step62;\n\n try {\n for (_iterator62.s(); !(_step62 = _iterator62.n()).done;) {\n var e = _step62.value;\n e(0\n /* NetworkStatus.AVAILABLE */\n );\n }\n } catch (err) {\n _iterator62.e(err);\n } finally {\n _iterator62.f();\n }\n }\n }, {\n key: \"ao\",\n value: function ao() {\n __PRIVATE_logDebug(\"ConnectivityMonitor\", \"Network connectivity changed: UNAVAILABLE\");\n\n var _iterator63 = _createForOfIteratorHelper(this.uo),\n _step63;\n\n try {\n for (_iterator63.s(); !(_step63 = _iterator63.n()).done;) {\n var e = _step63.value;\n e(1\n /* NetworkStatus.UNAVAILABLE */\n );\n }\n } catch (err) {\n _iterator63.e(err);\n } finally {\n _iterator63.f();\n }\n } // TODO(chenbrian): Consider passing in window either into this component or\n // here for testing via FakeWindow.\n\n /** Checks that all used attributes of window are available. */\n\n }], [{\n key: \"D\",\n value: function D() {\n return \"undefined\" != typeof window && void 0 !== window.addEventListener && void 0 !== window.removeEventListener;\n }\n }]);\n\n return __PRIVATE_BrowserConnectivityMonitor;\n}();\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The value returned from the most recent invocation of\n * `generateUniqueDebugId()`, or null if it has never been invoked.\n */\n\n\nvar Ae = null;\n/**\n * Generates and returns an initial value for `lastUniqueDebugId`.\n *\n * The returned value is randomly selected from a range of integers that are\n * represented as 8 hexadecimal digits. This means that (within reason) any\n * numbers generated by incrementing the returned number by 1 will also be\n * represented by 8 hexadecimal digits. This leads to all \"IDs\" having the same\n * length when converted to a hexadecimal string, making reading logs containing\n * these IDs easier to follow. And since the return value is randomly selected\n * it will help to differentiate between logs from different executions.\n */\n\n/**\n * Generates and returns a unique ID as a hexadecimal string.\n *\n * The returned ID is intended to be used in debug logging messages to help\n * correlate log messages that may be spatially separated in the logs, but\n * logically related. For example, a network connection could include the same\n * \"debug ID\" string in all of its log messages to help trace a specific\n * connection over time.\n *\n * @return the 10-character generated ID (e.g. \"0xa1b2c3d4\").\n */\n\nfunction __PRIVATE_generateUniqueDebugId() {\n return null === Ae ? Ae = function __PRIVATE_generateInitialUniqueDebugId() {\n return 268435456 + Math.round(2147483648 * Math.random());\n }() : Ae++, \"0x\" + Ae.toString(16);\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar Re = {\n BatchGetDocuments: \"batchGet\",\n Commit: \"commit\",\n RunQuery: \"runQuery\",\n RunAggregationQuery: \"runAggregationQuery\"\n};\n/**\n * Maps RPC names to the corresponding REST endpoint name.\n *\n * We use array notation to avoid mangling.\n */\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Provides a simple helper class that implements the Stream interface to\n * bridge to other implementations that are streams but do not implement the\n * interface. The stream callbacks are invoked with the callOn... methods.\n */\n\nvar __PRIVATE_StreamBridge = /*#__PURE__*/function () {\n function __PRIVATE_StreamBridge(e) {\n _classCallCheck(this, __PRIVATE_StreamBridge);\n\n this.lo = e.lo, this.ho = e.ho;\n }\n\n _createClass(__PRIVATE_StreamBridge, [{\n key: \"Po\",\n value: function Po(e) {\n this.Io = e;\n }\n }, {\n key: \"To\",\n value: function To(e) {\n this.Eo = e;\n }\n }, {\n key: \"onMessage\",\n value: function onMessage(e) {\n this.Ao = e;\n }\n }, {\n key: \"close\",\n value: function close() {\n this.ho();\n }\n }, {\n key: \"send\",\n value: function send(e) {\n this.lo(e);\n }\n }, {\n key: \"Ro\",\n value: function Ro() {\n this.Io();\n }\n }, {\n key: \"Vo\",\n value: function Vo(e) {\n this.Eo(e);\n }\n }, {\n key: \"mo\",\n value: function mo(e) {\n this.Ao(e);\n }\n }]);\n\n return __PRIVATE_StreamBridge;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar Ve = \"WebChannelConnection\";\n\nvar __PRIVATE_WebChannelConnection = /*#__PURE__*/function (_PRIVATE_RestConnect) {\n _inherits(__PRIVATE_WebChannelConnection, _PRIVATE_RestConnect);\n\n var _super28 = _createSuper(__PRIVATE_WebChannelConnection);\n\n function __PRIVATE_WebChannelConnection(e) {\n var _this162;\n\n _classCallCheck(this, __PRIVATE_WebChannelConnection);\n\n _this162 = _super28.call(this, e), _this162.forceLongPolling = e.forceLongPolling, _this162.autoDetectLongPolling = e.autoDetectLongPolling, _this162.useFetchStreams = e.useFetchStreams, _this162.longPollingOptions = e.longPollingOptions;\n return _this162;\n }\n\n _createClass(__PRIVATE_WebChannelConnection, [{\n key: \"Co\",\n value: function Co(e, t, n, r) {\n var i = __PRIVATE_generateUniqueDebugId();\n\n return new Promise(function (s, o) {\n var _ = new XhrIo();\n\n _.setWithCredentials(!0), _.listenOnce(EventType.COMPLETE, function () {\n try {\n switch (_.getLastErrorCode()) {\n case ErrorCode.NO_ERROR:\n var _t42 = _.getResponseJson();\n\n __PRIVATE_logDebug(Ve, \"XHR for RPC '\".concat(e, \"' \").concat(i, \" received:\"), JSON.stringify(_t42)), s(_t42);\n break;\n\n case ErrorCode.TIMEOUT:\n __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' \").concat(i, \" timed out\")), o(new FirestoreError(D.DEADLINE_EXCEEDED, \"Request time out\"));\n break;\n\n case ErrorCode.HTTP_ERROR:\n var _n26 = _.getStatus();\n\n if (__PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' \").concat(i, \" failed with status:\"), _n26, \"response text:\", _.getResponseText()), _n26 > 0) {\n var _e88 = _.getResponseJson();\n\n Array.isArray(_e88) && (_e88 = _e88[0]);\n\n var _t43 = null == _e88 ? void 0 : _e88.error;\n\n if (_t43 && _t43.status && _t43.message) {\n var _e89 = function __PRIVATE_mapCodeFromHttpResponseErrorStatus(e) {\n var t = e.toLowerCase().replace(/_/g, \"-\");\n return Object.values(D).indexOf(t) >= 0 ? t : D.UNKNOWN;\n }(_t43.status);\n\n o(new FirestoreError(_e89, _t43.message));\n } else o(new FirestoreError(D.UNKNOWN, \"Server responded with status \" + _.getStatus()));\n } else // If we received an HTTP_ERROR but there's no status code,\n // it's most probably a connection issue\n o(new FirestoreError(D.UNAVAILABLE, \"Connection failed.\"));\n\n break;\n\n default:\n fail();\n }\n } finally {\n __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' \").concat(i, \" completed.\"));\n }\n });\n var a = JSON.stringify(r);\n __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' \").concat(i, \" sending request:\"), r), _.send(t, \"POST\", a, n, 15);\n });\n }\n }, {\n key: \"Fo\",\n value: function Fo(e, t, n) {\n var r = __PRIVATE_generateUniqueDebugId(),\n i = [this.fo, \"/\", \"google.firestore.v1.Firestore\", \"/\", e, \"/channel\"],\n s = createWebChannelTransport(),\n o = getStatEventTarget(),\n _ = {\n // Required for backend stickiness, routing behavior is based on this\n // parameter.\n httpSessionIdParam: \"gsessionid\",\n initMessageHeaders: {},\n messageUrlParams: {\n // This param is used to improve routing and project isolation by the\n // backend and must be included in every request.\n database: \"projects/\".concat(this.databaseId.projectId, \"/databases/\").concat(this.databaseId.database)\n },\n sendRawJson: !0,\n supportsCrossDomainXhr: !0,\n internalChannelParams: {\n // Override the default timeout (randomized between 10-20 seconds) since\n // a large write batch on a slow internet connection may take a long\n // time to send to the backend. Rather than have WebChannel impose a\n // tight timeout which could lead to infinite timeouts and retries, we\n // set it very large (5-10 minutes) and rely on the browser's builtin\n // timeouts to kick in if the request isn't working.\n forwardChannelRequestTimeoutMs: 6e5\n },\n forceLongPolling: this.forceLongPolling,\n detectBufferingProxy: this.autoDetectLongPolling\n },\n a = this.longPollingOptions.timeoutSeconds;\n\n void 0 !== a && (_.longPollingTimeout = Math.round(1e3 * a)), this.useFetchStreams && (_.useFetchStreams = !0), this.Do(_.initMessageHeaders, t, n), // Sending the custom headers we just added to request.initMessageHeaders\n // (Authorization, etc.) will trigger the browser to make a CORS preflight\n // request because the XHR will no longer meet the criteria for a \"simple\"\n // CORS request:\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests\n // Therefore to avoid the CORS preflight request (an extra network\n // roundtrip), we use the encodeInitMessageHeaders option to specify that\n // the headers should instead be encoded in the request's POST payload,\n // which is recognized by the webchannel backend.\n _.encodeInitMessageHeaders = !0;\n var u = i.join(\"\");\n\n __PRIVATE_logDebug(Ve, \"Creating RPC '\".concat(e, \"' stream \").concat(r, \": \").concat(u), _);\n\n var c = s.createWebChannel(u, _); // WebChannel supports sending the first message with the handshake - saving\n // a network round trip. However, it will have to call send in the same\n // JS event loop as open. In order to enforce this, we delay actually\n // opening the WebChannel until send is called. Whether we have called\n // open is tracked with this variable.\n\n var l = !1,\n h = !1; // A flag to determine whether the stream was closed (by us or through an\n // error/close event) to avoid delivering multiple close events or sending\n // on a closed stream\n\n var P = new __PRIVATE_StreamBridge({\n lo: function lo(t) {\n h ? __PRIVATE_logDebug(Ve, \"Not sending because RPC '\".concat(e, \"' stream \").concat(r, \" is closed:\"), t) : (l || (__PRIVATE_logDebug(Ve, \"Opening RPC '\".concat(e, \"' stream \").concat(r, \" transport.\")), c.open(), l = !0), __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" sending:\"), t), c.send(t));\n },\n ho: function ho() {\n return c.close();\n }\n }),\n __PRIVATE_unguardedEventListen = function __PRIVATE_unguardedEventListen(e, t, n) {\n // TODO(dimond): closure typing seems broken because WebChannel does\n // not implement goog.events.Listenable\n e.listen(t, function (e) {\n try {\n n(e);\n } catch (e) {\n setTimeout(function () {\n throw e;\n }, 0);\n }\n });\n }; // Closure events are guarded and exceptions are swallowed, so catch any\n // exception and rethrow using a setTimeout so they become visible again.\n // Note that eventually this function could go away if we are confident\n // enough the code is exception free.\n\n\n return __PRIVATE_unguardedEventListen(c, WebChannel.EventType.OPEN, function () {\n h || __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" transport opened.\"));\n }), __PRIVATE_unguardedEventListen(c, WebChannel.EventType.CLOSE, function () {\n h || (h = !0, __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" transport closed\")), P.Vo());\n }), __PRIVATE_unguardedEventListen(c, WebChannel.EventType.ERROR, function (t) {\n h || (h = !0, __PRIVATE_logWarn(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" transport errored:\"), t), P.Vo(new FirestoreError(D.UNAVAILABLE, \"The operation could not be completed\")));\n }), __PRIVATE_unguardedEventListen(c, WebChannel.EventType.MESSAGE, function (t) {\n var n;\n\n if (!h) {\n var _i15 = t.data[0];\n\n __PRIVATE_hardAssert(!!_i15); // TODO(b/35143891): There is a bug in One Platform that caused errors\n // (and only errors) to be wrapped in an extra array. To be forward\n // compatible with the bug we need to check either condition. The latter\n // can be removed once the fix has been rolled out.\n // Use any because msgData.error is not typed.\n\n\n var _s6 = _i15,\n _o5 = _s6.error || (null === (n = _s6[0]) || void 0 === n ? void 0 : n.error);\n\n if (_o5) {\n __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" received error:\"), _o5); // error.status will be a string like 'OK' or 'NOT_FOUND'.\n\n\n var _t44 = _o5.status;\n\n var _n27 =\n /**\n * Maps an error Code from a GRPC status identifier like 'NOT_FOUND'.\n *\n * @returns The Code equivalent to the given status string or undefined if\n * there is no match.\n */\n function __PRIVATE_mapCodeFromRpcStatus(e) {\n // lookup by string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n var t = ae[e];\n if (void 0 !== t) return __PRIVATE_mapCodeFromRpcCode(t);\n }(_t44),\n _i16 = _o5.message;\n\n void 0 === _n27 && (_n27 = D.INTERNAL, _i16 = \"Unknown error status: \" + _t44 + \" with message \" + _o5.message), // Mark closed so no further events are propagated\n h = !0, P.Vo(new FirestoreError(_n27, _i16)), c.close();\n } else __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" received:\"), _i15), P.mo(_i15);\n }\n }), __PRIVATE_unguardedEventListen(o, Event.STAT_EVENT, function (t) {\n t.stat === Stat.PROXY ? __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" detected buffering proxy\")) : t.stat === Stat.NOPROXY && __PRIVATE_logDebug(Ve, \"RPC '\".concat(e, \"' stream \").concat(r, \" detected no buffering proxy\"));\n }), setTimeout(function () {\n // Technically we could/should wait for the WebChannel opened event,\n // but because we want to send the first message with the WebChannel\n // handshake we pretend the channel opened here (asynchronously), and\n // then delay the actual open until the first message is sent.\n P.Ro();\n }, 0), P;\n }\n }]);\n\n return __PRIVATE_WebChannelConnection;\n}(\n/*#__PURE__*/\n\n/**\n * Base class for all Rest-based connections to the backend (WebChannel and\n * HTTP).\n */\nfunction () {\n function __PRIVATE_RestConnection(e) {\n _classCallCheck(this, __PRIVATE_RestConnection);\n\n this.databaseInfo = e, this.databaseId = e.databaseId;\n var t = e.ssl ? \"https\" : \"http\",\n n = encodeURIComponent(this.databaseId.projectId),\n r = encodeURIComponent(this.databaseId.database);\n this.fo = t + \"://\" + e.host, this.po = \"projects/\".concat(n, \"/databases/\").concat(r), this.yo = \"(default)\" === this.databaseId.database ? \"project_id=\".concat(n) : \"project_id=\".concat(n, \"&database_id=\").concat(r);\n }\n\n _createClass(__PRIVATE_RestConnection, [{\n key: \"wo\",\n get: function get() {\n // Both `invokeRPC()` and `invokeStreamingRPC()` use their `path` arguments to determine\n // where to run the query, and expect the `request` to NOT specify the \"path\".\n return !1;\n }\n }, {\n key: \"So\",\n value: function So(e, t, n, r, i) {\n var s = __PRIVATE_generateUniqueDebugId(),\n o = this.bo(e, t.toUriEncodedString());\n\n __PRIVATE_logDebug(\"RestConnection\", \"Sending RPC '\".concat(e, \"' \").concat(s, \":\"), o, n);\n\n var _ = {\n \"google-cloud-resource-prefix\": this.po,\n \"x-goog-request-params\": this.yo\n };\n return this.Do(_, r, i), this.Co(e, o, _, n).then(function (t) {\n return __PRIVATE_logDebug(\"RestConnection\", \"Received RPC '\".concat(e, \"' \").concat(s, \": \"), t), t;\n }, function (t) {\n throw __PRIVATE_logWarn(\"RestConnection\", \"RPC '\".concat(e, \"' \").concat(s, \" failed with error: \"), t, \"url: \", o, \"request:\", n), t;\n });\n }\n }, {\n key: \"vo\",\n value: function vo(e, t, n, r, i, s) {\n // The REST API automatically aggregates all of the streamed results, so we\n // can just use the normal invoke() method.\n return this.So(e, t, n, r, i);\n }\n /**\n * Modifies the headers for a request, adding any authorization token if\n * present and any additional headers for the request.\n */\n\n }, {\n key: \"Do\",\n value:\n /**\n * Modifies the headers for a request, adding any authorization token if\n * present and any additional headers for the request.\n */\n function Do(e, t, n) {\n e[\"X-Goog-Api-Client\"] = // SDK_VERSION is updated to different value at runtime depending on the entry point,\n // so we need to get its value when we need it in a function.\n function __PRIVATE_getGoogApiClientValue() {\n return \"gl-js/ fire/\" + S;\n }(), // Content-Type: text/plain will avoid preflight requests which might\n // mess with CORS and redirects by proxies. If we add custom headers\n // we will need to change this code to potentially use the $httpOverwrite\n // parameter supported by ESF to avoid triggering preflight requests.\n e[\"Content-Type\"] = \"text/plain\", this.databaseInfo.appId && (e[\"X-Firebase-GMPID\"] = this.databaseInfo.appId), t && t.headers.forEach(function (t, n) {\n return e[n] = t;\n }), n && n.headers.forEach(function (t, n) {\n return e[n] = t;\n });\n }\n }, {\n key: \"bo\",\n value: function bo(e, t) {\n var n = Re[e];\n return \"\".concat(this.fo, \"/v1/\").concat(t, \":\").concat(n);\n }\n /**\n * Closes and cleans up any resources associated with the connection. This\n * implementation is a no-op because there are no resources associated\n * with the RestConnection that need to be cleaned up.\n */\n\n }, {\n key: \"terminate\",\n value:\n /**\n * Closes and cleans up any resources associated with the connection. This\n * implementation is a no-op because there are no resources associated\n * with the RestConnection that need to be cleaned up.\n */\n function terminate() {// No-op\n }\n }]);\n\n return __PRIVATE_RestConnection;\n}());\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Initializes the WebChannelConnection for the browser. */\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** The Platform's 'window' implementation or null if not available. */\n\n\nfunction __PRIVATE_getWindow() {\n // `window` is not always available, e.g. in ReactNative and WebWorkers.\n // eslint-disable-next-line no-restricted-globals\n return \"undefined\" != typeof window ? window : null;\n}\n/** The Platform's 'document' implementation or null if not available. */\n\n\nfunction getDocument() {\n // `document` is not always available, e.g. in ReactNative and WebWorkers.\n // eslint-disable-next-line no-restricted-globals\n return \"undefined\" != typeof document ? document : null;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nfunction __PRIVATE_newSerializer(e) {\n return new JsonProtoSerializer(e,\n /* useProto3Json= */\n !0);\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A helper for running delayed tasks following an exponential backoff curve\n * between attempts.\n *\n * Each delay is made up of a \"base\" delay which follows the exponential\n * backoff curve, and a +/- 50% \"jitter\" that is calculated and added to the\n * base delay. This prevents clients from accidentally synchronizing their\n * delays causing spikes of load to the backend.\n */\n\n\nvar __PRIVATE_ExponentialBackoff = /*#__PURE__*/function () {\n function __PRIVATE_ExponentialBackoff(\n /**\n * The AsyncQueue to run backoff operations on.\n */\n e,\n /**\n * The ID to use when scheduling backoff operations on the AsyncQueue.\n */\n t) {\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1e3;\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1.5;\n var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 6e4;\n\n _classCallCheck(this, __PRIVATE_ExponentialBackoff);\n\n this.oi = e, this.timerId = t, this.Mo = n, this.xo = r, this.Oo = i, this.No = 0, this.Bo = null,\n /** The last backoff attempt, as epoch milliseconds. */\n this.Lo = Date.now(), this.reset();\n }\n /**\n * Resets the backoff delay.\n *\n * The very next backoffAndWait() will have no delay. If it is called again\n * (i.e. due to an error), initialDelayMs (plus jitter) will be used, and\n * subsequent ones will increase according to the backoffFactor.\n */\n\n\n _createClass(__PRIVATE_ExponentialBackoff, [{\n key: \"reset\",\n value: function reset() {\n this.No = 0;\n }\n /**\n * Resets the backoff delay to the maximum delay (e.g. for use after a\n * RESOURCE_EXHAUSTED error).\n */\n\n }, {\n key: \"ko\",\n value: function ko() {\n this.No = this.Oo;\n }\n /**\n * Returns a promise that resolves after currentDelayMs, and increases the\n * delay for any subsequent attempts. If there was a pending backoff operation\n * already, it will be canceled.\n */\n\n }, {\n key: \"qo\",\n value: function qo(e) {\n var _this163 = this;\n\n // Cancel any pending backoff operation.\n this.cancel(); // First schedule using the current base (which may be 0 and should be\n // honored as such).\n\n var t = Math.floor(this.No + this.Qo()),\n n = Math.max(0, Date.now() - this.Lo),\n r = Math.max(0, t - n); // Guard against lastAttemptTime being in the future due to a clock change.\n\n r > 0 && __PRIVATE_logDebug(\"ExponentialBackoff\", \"Backing off for \".concat(r, \" ms (base delay: \").concat(this.No, \" ms, delay with jitter: \").concat(t, \" ms, last attempt: \").concat(n, \" ms ago)\")), this.Bo = this.oi.enqueueAfterDelay(this.timerId, r, function () {\n return _this163.Lo = Date.now(), e();\n }), // Apply backoff factor to determine next delay and ensure it is within\n // bounds.\n this.No *= this.xo, this.No < this.Mo && (this.No = this.Mo), this.No > this.Oo && (this.No = this.Oo);\n }\n }, {\n key: \"Ko\",\n value: function Ko() {\n null !== this.Bo && (this.Bo.skipDelay(), this.Bo = null);\n }\n }, {\n key: \"cancel\",\n value: function cancel() {\n null !== this.Bo && (this.Bo.cancel(), this.Bo = null);\n }\n /** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */\n\n }, {\n key: \"Qo\",\n value: function Qo() {\n return (Math.random() - .5) * this.No;\n }\n }]);\n\n return __PRIVATE_ExponentialBackoff;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A PersistentStream is an abstract base class that represents a streaming RPC\n * to the Firestore backend. It's built on top of the connections own support\n * for streaming RPCs, and adds several critical features for our clients:\n *\n * - Exponential backoff on failure\n * - Authentication via CredentialsProvider\n * - Dispatching all callbacks into the shared worker queue\n * - Closing idle streams after 60 seconds of inactivity\n *\n * Subclasses of PersistentStream implement serialization of models to and\n * from the JSON representation of the protocol buffers for a specific\n * streaming RPC.\n *\n * ## Starting and Stopping\n *\n * Streaming RPCs are stateful and need to be start()ed before messages can\n * be sent and received. The PersistentStream will call the onOpen() function\n * of the listener once the stream is ready to accept requests.\n *\n * Should a start() fail, PersistentStream will call the registered onClose()\n * listener with a FirestoreError indicating what went wrong.\n *\n * A PersistentStream can be started and stopped repeatedly.\n *\n * Generic types:\n * SendType: The type of the outgoing message of the underlying\n * connection stream\n * ReceiveType: The type of the incoming message of the underlying\n * connection stream\n * ListenerType: The type of the listener that will be used for callbacks\n */\n\n\nvar __PRIVATE_PersistentStream = /*#__PURE__*/function () {\n function __PRIVATE_PersistentStream(e, t, n, r, i, s, o, _) {\n _classCallCheck(this, __PRIVATE_PersistentStream);\n\n this.oi = e, this.$o = n, this.Uo = r, this.connection = i, this.authCredentialsProvider = s, this.appCheckCredentialsProvider = o, this.listener = _, this.state = 0\n /* PersistentStreamState.Initial */\n ,\n /**\n * A close count that's incremented every time the stream is closed; used by\n * getCloseGuardedDispatcher() to invalidate callbacks that happen after\n * close.\n */\n this.Wo = 0, this.Go = null, this.zo = null, this.stream = null, this.jo = new __PRIVATE_ExponentialBackoff(e, t);\n }\n /**\n * Returns true if start() has been called and no error has occurred. True\n * indicates the stream is open or in the process of opening (which\n * encompasses respecting backoff, getting auth tokens, and starting the\n * actual RPC). Use isOpen() to determine if the stream is open and ready for\n * outbound requests.\n */\n\n\n _createClass(__PRIVATE_PersistentStream, [{\n key: \"Ho\",\n value: function Ho() {\n return 1\n /* PersistentStreamState.Starting */\n === this.state || 5\n /* PersistentStreamState.Backoff */\n === this.state || this.Jo();\n }\n /**\n * Returns true if the underlying RPC is open (the onOpen() listener has been\n * called) and the stream is ready for outbound requests.\n */\n\n }, {\n key: \"Jo\",\n value: function Jo() {\n return 2\n /* PersistentStreamState.Open */\n === this.state || 3\n /* PersistentStreamState.Healthy */\n === this.state;\n }\n /**\n * Starts the RPC. Only allowed if isStarted() returns false. The stream is\n * not immediately ready for use: onOpen() will be invoked when the RPC is\n * ready for outbound requests, at which point isOpen() will return true.\n *\n * When start returns, isStarted() will return true.\n */\n\n }, {\n key: \"start\",\n value: function start() {\n 4\n /* PersistentStreamState.Error */\n !== this.state ? this.auth() : this.Yo();\n }\n /**\n * Stops the RPC. This call is idempotent and allowed regardless of the\n * current isStarted() state.\n *\n * When stop returns, isStarted() and isOpen() will both return false.\n */\n\n }, {\n key: \"stop\",\n value: function () {\n var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {\n return _regeneratorRuntime.wrap(function _callee16$(_context16) {\n while (1) {\n switch (_context16.prev = _context16.next) {\n case 0:\n _context16.t0 = this.Ho();\n\n if (!_context16.t0) {\n _context16.next = 4;\n break;\n }\n\n _context16.next = 4;\n return this.close(0\n /* PersistentStreamState.Initial */\n );\n\n case 4:\n case \"end\":\n return _context16.stop();\n }\n }\n }, _callee16, this);\n }));\n\n function stop() {\n return _stop.apply(this, arguments);\n }\n\n return stop;\n }()\n /**\n * After an error the stream will usually back off on the next attempt to\n * start it. If the error warrants an immediate restart of the stream, the\n * sender can use this to indicate that the receiver should not back off.\n *\n * Each error will call the onClose() listener. That function can decide to\n * inhibit backoff if required.\n */\n\n }, {\n key: \"Zo\",\n value: function Zo() {\n this.state = 0\n /* PersistentStreamState.Initial */\n , this.jo.reset();\n }\n /**\n * Marks this stream as idle. If no further actions are performed on the\n * stream for one minute, the stream will automatically close itself and\n * notify the stream's onClose() handler with Status.OK. The stream will then\n * be in a !isStarted() state, requiring the caller to start the stream again\n * before further use.\n *\n * Only streams that are in state 'Open' can be marked idle, as all other\n * states imply pending network operations.\n */\n\n }, {\n key: \"Xo\",\n value: function Xo() {\n var _this164 = this;\n\n // Starts the idle time if we are in state 'Open' and are not yet already\n // running a timer (in which case the previous idle timeout still applies).\n this.Jo() && null === this.Go && (this.Go = this.oi.enqueueAfterDelay(this.$o, 6e4, function () {\n return _this164.e_();\n }));\n }\n /** Sends a message to the underlying stream. */\n\n }, {\n key: \"t_\",\n value: function t_(e) {\n this.n_(), this.stream.send(e);\n }\n /** Called by the idle timer when the stream should close due to inactivity. */\n\n }, {\n key: \"e_\",\n value: function () {\n var _e_ = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {\n return _regeneratorRuntime.wrap(function _callee17$(_context17) {\n while (1) {\n switch (_context17.prev = _context17.next) {\n case 0:\n if (!this.Jo()) {\n _context17.next = 2;\n break;\n }\n\n return _context17.abrupt(\"return\", this.close(0\n /* PersistentStreamState.Initial */\n ));\n\n case 2:\n case \"end\":\n return _context17.stop();\n }\n }\n }, _callee17, this);\n }));\n\n function e_() {\n return _e_.apply(this, arguments);\n }\n\n return e_;\n }()\n /** Marks the stream as active again. */\n\n }, {\n key: \"n_\",\n value: function n_() {\n this.Go && (this.Go.cancel(), this.Go = null);\n }\n /** Cancels the health check delayed operation. */\n\n }, {\n key: \"r_\",\n value: function r_() {\n this.zo && (this.zo.cancel(), this.zo = null);\n }\n /**\n * Closes the stream and cleans up as necessary:\n *\n * * closes the underlying GRPC stream;\n * * calls the onClose handler with the given 'error';\n * * sets internal stream state to 'finalState';\n * * adjusts the backoff timer based on the error\n *\n * A new stream can be opened by calling start().\n *\n * @param finalState - the intended state of the stream after closing.\n * @param error - the error the connection was closed with.\n */\n\n }, {\n key: \"close\",\n value: function () {\n var _close = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(e, t) {\n return _regeneratorRuntime.wrap(function _callee18$(_context18) {\n while (1) {\n switch (_context18.prev = _context18.next) {\n case 0:\n this.n_();\n this.r_();\n this.jo.cancel();\n // Invalidates any stream-related callbacks (e.g. from auth or the\n // underlying stream), guaranteeing they won't execute.\n this.Wo++;\n 4\n /* PersistentStreamState.Error */\n !== e ? // If this is an intentional close ensure we don't delay our next connection attempt.\n this.jo.reset() : t && t.code === D.RESOURCE_EXHAUSTED ? ( // Log the error. (Probably either 'quota exceeded' or 'max queue length reached'.)\n __PRIVATE_logError(t.toString()), __PRIVATE_logError(\"Using maximum backoff delay to prevent overloading the backend.\"), this.jo.ko()) : t && t.code === D.UNAUTHENTICATED && 3\n /* PersistentStreamState.Healthy */\n !== this.state && ( // \"unauthenticated\" error means the token was rejected. This should rarely\n // happen since both Auth and AppCheck ensure a sufficient TTL when we\n // request a token. If a user manually resets their system clock this can\n // fail, however. In this case, we should get a Code.UNAUTHENTICATED error\n // before we received the first message and we need to invalidate the token\n // to ensure that we fetch a new token.\n this.authCredentialsProvider.invalidateToken(), this.appCheckCredentialsProvider.invalidateToken());\n // Clean up the underlying stream because we are no longer interested in events.\n null !== this.stream && (this.i_(), this.stream.close(), this.stream = null);\n // This state must be assigned before calling onClose() to allow the callback to\n // inhibit backoff or otherwise manipulate the state in its non-started state.\n this.state = e;\n _context18.next = 9;\n return this.listener.To(t);\n\n case 9:\n case \"end\":\n return _context18.stop();\n }\n }\n }, _callee18, this);\n }));\n\n function close(_x21, _x22) {\n return _close.apply(this, arguments);\n }\n\n return close;\n }()\n /**\n * Can be overridden to perform additional cleanup before the stream is closed.\n * Calling super.tearDown() is not required.\n */\n\n }, {\n key: \"i_\",\n value: function i_() {}\n }, {\n key: \"auth\",\n value: function auth() {\n var _this165 = this;\n\n this.state = 1\n /* PersistentStreamState.Starting */\n ;\n var e = this.s_(this.Wo),\n t = this.Wo; // TODO(mikelehen): Just use dispatchIfNotClosed, but see TODO below.\n\n Promise.all([this.authCredentialsProvider.getToken(), this.appCheckCredentialsProvider.getToken()]).then(function (_ref22) {\n var _ref23 = _slicedToArray(_ref22, 2),\n e = _ref23[0],\n n = _ref23[1];\n\n // Stream can be stopped while waiting for authentication.\n // TODO(mikelehen): We really should just use dispatchIfNotClosed\n // and let this dispatch onto the queue, but that opened a spec test can\n // of worms that I don't want to deal with in this PR.\n _this165.Wo === t && // Normally we'd have to schedule the callback on the AsyncQueue.\n // However, the following calls are safe to be called outside the\n // AsyncQueue since they don't chain asynchronous calls\n _this165.o_(e, n);\n }, function (t) {\n e(function () {\n var e = new FirestoreError(D.UNKNOWN, \"Fetching auth token failed: \" + t.message);\n return _this165.__(e);\n });\n });\n }\n }, {\n key: \"o_\",\n value: function o_(e, t) {\n var _this166 = this;\n\n var n = this.s_(this.Wo);\n this.stream = this.a_(e, t), this.stream.Po(function () {\n n(function () {\n return _this166.state = 2\n /* PersistentStreamState.Open */\n , _this166.zo = _this166.oi.enqueueAfterDelay(_this166.Uo, 1e4, function () {\n return _this166.Jo() && (_this166.state = 3\n /* PersistentStreamState.Healthy */\n ), Promise.resolve();\n }), _this166.listener.Po();\n });\n }), this.stream.To(function (e) {\n n(function () {\n return _this166.__(e);\n });\n }), this.stream.onMessage(function (e) {\n n(function () {\n return _this166.onMessage(e);\n });\n });\n }\n }, {\n key: \"Yo\",\n value: function Yo() {\n var _this167 = this;\n\n this.state = 5\n /* PersistentStreamState.Backoff */\n , this.jo.qo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {\n return _regeneratorRuntime.wrap(function _callee19$(_context19) {\n while (1) {\n switch (_context19.prev = _context19.next) {\n case 0:\n _this167.state = 0\n /* PersistentStreamState.Initial */\n , _this167.start();\n\n case 1:\n case \"end\":\n return _context19.stop();\n }\n }\n }, _callee19);\n })));\n } // Visible for tests\n\n }, {\n key: \"__\",\n value: function __(e) {\n // In theory the stream could close cleanly, however, in our current model\n // we never expect this to happen because if we stop a stream ourselves,\n // this callback will never be called. To prevent cases where we retry\n // without a backoff accidentally, we set the stream to error in all cases.\n return __PRIVATE_logDebug(\"PersistentStream\", \"close with error: \".concat(e)), this.stream = null, this.close(4\n /* PersistentStreamState.Error */\n , e);\n }\n /**\n * Returns a \"dispatcher\" function that dispatches operations onto the\n * AsyncQueue but only runs them if closeCount remains unchanged. This allows\n * us to turn auth / stream callbacks into no-ops if the stream is closed /\n * re-opened, etc.\n */\n\n }, {\n key: \"s_\",\n value: function s_(e) {\n var _this168 = this;\n\n return function (t) {\n _this168.oi.enqueueAndForget(function () {\n return _this168.Wo === e ? t() : (__PRIVATE_logDebug(\"PersistentStream\", \"stream callback skipped by getCloseGuardedDispatcher.\"), Promise.resolve());\n });\n };\n }\n }]);\n\n return __PRIVATE_PersistentStream;\n}();\n/**\n * A PersistentStream that implements the Listen RPC.\n *\n * Once the Listen stream has called the onOpen() listener, any number of\n * listen() and unlisten() calls can be made to control what changes will be\n * sent from the server for ListenResponses.\n */\n\n\nvar __PRIVATE_PersistentListenStream = /*#__PURE__*/function (_PRIVATE_PersistentS) {\n _inherits(__PRIVATE_PersistentListenStream, _PRIVATE_PersistentS);\n\n var _super29 = _createSuper(__PRIVATE_PersistentListenStream);\n\n function __PRIVATE_PersistentListenStream(e, t, n, r, i, s) {\n var _this169;\n\n _classCallCheck(this, __PRIVATE_PersistentListenStream);\n\n _this169 = _super29.call(this, e, \"listen_stream_connection_backoff\"\n /* TimerId.ListenStreamConnectionBackoff */\n , \"listen_stream_idle\"\n /* TimerId.ListenStreamIdle */\n , \"health_check_timeout\"\n /* TimerId.HealthCheckTimeout */\n , t, n, r, s), _this169.serializer = i;\n return _this169;\n }\n\n _createClass(__PRIVATE_PersistentListenStream, [{\n key: \"a_\",\n value: function a_(e, t) {\n return this.connection.Fo(\"Listen\", e, t);\n }\n }, {\n key: \"onMessage\",\n value: function onMessage(e) {\n // A successful response means the stream is healthy\n this.jo.reset();\n\n var t = __PRIVATE_fromWatchChange(this.serializer, e),\n n = function __PRIVATE_versionFromListenResponse(e) {\n // We have only reached a consistent snapshot for the entire stream if there\n // is a read_time set and it applies to all targets (i.e. the list of\n // targets is empty). The backend is guaranteed to send such responses.\n if (!(\"targetChange\" in e)) return SnapshotVersion.min();\n var t = e.targetChange;\n return t.targetIds && t.targetIds.length ? SnapshotVersion.min() : t.readTime ? __PRIVATE_fromVersion(t.readTime) : SnapshotVersion.min();\n }(e);\n\n return this.listener.u_(t, n);\n }\n /**\n * Registers interest in the results of the given target. If the target\n * includes a resumeToken it will be included in the request. Results that\n * affect the target will be streamed back as WatchChange messages that\n * reference the targetId.\n */\n\n }, {\n key: \"c_\",\n value: function c_(e) {\n var t = {};\n t.database = __PRIVATE_getEncodedDatabaseId(this.serializer), t.addTarget = function __PRIVATE_toTarget(e, t) {\n var n;\n var r = t.target;\n\n if (n = __PRIVATE_targetIsDocumentTarget(r) ? {\n documents: __PRIVATE_toDocumentsTarget(e, r)\n } : {\n query: __PRIVATE_toQueryTarget(e, r).ut\n }, n.targetId = t.targetId, t.resumeToken.approximateByteSize() > 0) {\n n.resumeToken = __PRIVATE_toBytes(e, t.resumeToken);\n\n var _r22 = __PRIVATE_toInt32Proto(e, t.expectedCount);\n\n null !== _r22 && (n.expectedCount = _r22);\n } else if (t.snapshotVersion.compareTo(SnapshotVersion.min()) > 0) {\n // TODO(wuandy): Consider removing above check because it is most likely true.\n // Right now, many tests depend on this behaviour though (leaving min() out\n // of serialization).\n n.readTime = toTimestamp(e, t.snapshotVersion.toTimestamp());\n\n var _r23 = __PRIVATE_toInt32Proto(e, t.expectedCount);\n\n null !== _r23 && (n.expectedCount = _r23);\n }\n\n return n;\n }(this.serializer, e);\n\n var n = __PRIVATE_toListenRequestLabels(this.serializer, e);\n\n n && (t.labels = n), this.t_(t);\n }\n /**\n * Unregisters interest in the results of the target associated with the\n * given targetId.\n */\n\n }, {\n key: \"l_\",\n value: function l_(e) {\n var t = {};\n t.database = __PRIVATE_getEncodedDatabaseId(this.serializer), t.removeTarget = e, this.t_(t);\n }\n }]);\n\n return __PRIVATE_PersistentListenStream;\n}(__PRIVATE_PersistentStream);\n/**\n * A Stream that implements the Write RPC.\n *\n * The Write RPC requires the caller to maintain special streamToken\n * state in between calls, to help the server understand which responses the\n * client has processed by the time the next request is made. Every response\n * will contain a streamToken; this value must be passed to the next\n * request.\n *\n * After calling start() on this stream, the next request must be a handshake,\n * containing whatever streamToken is on hand. Once a response to this\n * request is received, all pending mutations may be submitted. When\n * submitting multiple batches of mutations at the same time, it's\n * okay to use the same streamToken for the calls to writeMutations.\n *\n * TODO(b/33271235): Use proto types\n */\n\n\nvar __PRIVATE_PersistentWriteStream = /*#__PURE__*/function (_PRIVATE_PersistentS2) {\n _inherits(__PRIVATE_PersistentWriteStream, _PRIVATE_PersistentS2);\n\n var _super30 = _createSuper(__PRIVATE_PersistentWriteStream);\n\n function __PRIVATE_PersistentWriteStream(e, t, n, r, i, s) {\n var _this170;\n\n _classCallCheck(this, __PRIVATE_PersistentWriteStream);\n\n _this170 = _super30.call(this, e, \"write_stream_connection_backoff\"\n /* TimerId.WriteStreamConnectionBackoff */\n , \"write_stream_idle\"\n /* TimerId.WriteStreamIdle */\n , \"health_check_timeout\"\n /* TimerId.HealthCheckTimeout */\n , t, n, r, s), _this170.serializer = i, _this170.h_ = !1;\n return _this170;\n }\n /**\n * Tracks whether or not a handshake has been successfully exchanged and\n * the stream is ready to accept mutations.\n */\n\n\n _createClass(__PRIVATE_PersistentWriteStream, [{\n key: \"P_\",\n get: function get() {\n return this.h_;\n } // Override of PersistentStream.start\n\n }, {\n key: \"start\",\n value: function start() {\n this.h_ = !1, this.lastStreamToken = void 0, _get(_getPrototypeOf(__PRIVATE_PersistentWriteStream.prototype), \"start\", this).call(this);\n }\n }, {\n key: \"i_\",\n value: function i_() {\n this.h_ && this.I_([]);\n }\n }, {\n key: \"a_\",\n value: function a_(e, t) {\n return this.connection.Fo(\"Write\", e, t);\n }\n }, {\n key: \"onMessage\",\n value: function onMessage(e) {\n if ( // Always capture the last stream token.\n __PRIVATE_hardAssert(!!e.streamToken), this.lastStreamToken = e.streamToken, this.h_) {\n // A successful first write response means the stream is healthy,\n // Note, that we could consider a successful handshake healthy, however,\n // the write itself might be causing an error we want to back off from.\n this.jo.reset();\n\n var t = __PRIVATE_fromWriteResults(e.writeResults, e.commitTime),\n n = __PRIVATE_fromVersion(e.commitTime);\n\n return this.listener.T_(n, t);\n } // The first response is always the handshake response\n\n\n return __PRIVATE_hardAssert(!e.writeResults || 0 === e.writeResults.length), this.h_ = !0, this.listener.E_();\n }\n /**\n * Sends an initial streamToken to the server, performing the handshake\n * required to make the StreamingWrite RPC work. Subsequent\n * calls should wait until onHandshakeComplete was called.\n */\n\n }, {\n key: \"d_\",\n value: function d_() {\n // TODO(dimond): Support stream resumption. We intentionally do not set the\n // stream token on the handshake, ignoring any stream token we might have.\n var e = {};\n e.database = __PRIVATE_getEncodedDatabaseId(this.serializer), this.t_(e);\n }\n /** Sends a group of mutations to the Firestore backend to apply. */\n\n }, {\n key: \"I_\",\n value: function I_(e) {\n var _this171 = this;\n\n var t = {\n streamToken: this.lastStreamToken,\n writes: e.map(function (e) {\n return toMutation(_this171.serializer, e);\n })\n };\n this.t_(t);\n }\n }]);\n\n return __PRIVATE_PersistentWriteStream;\n}(__PRIVATE_PersistentStream);\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Datastore and its related methods are a wrapper around the external Google\n * Cloud Datastore grpc API, which provides an interface that is more convenient\n * for the rest of the client SDK architecture to consume.\n */\n\n/**\n * An implementation of Datastore that exposes additional state for internal\n * consumption.\n */\n\n\nvar __PRIVATE_DatastoreImpl = /*#__PURE__*/function (_Datastore) {\n _inherits(__PRIVATE_DatastoreImpl, _Datastore);\n\n var _super31 = _createSuper(__PRIVATE_DatastoreImpl);\n\n function __PRIVATE_DatastoreImpl(e, t, n, r) {\n var _this172;\n\n _classCallCheck(this, __PRIVATE_DatastoreImpl);\n\n _this172 = _super31.call(this), _this172.authCredentials = e, _this172.appCheckCredentials = t, _this172.connection = n, _this172.serializer = r, _this172.A_ = !1;\n return _this172;\n }\n\n _createClass(__PRIVATE_DatastoreImpl, [{\n key: \"R_\",\n value: function R_() {\n if (this.A_) throw new FirestoreError(D.FAILED_PRECONDITION, \"The client has already been terminated.\");\n }\n /** Invokes the provided RPC with auth and AppCheck tokens. */\n\n }, {\n key: \"So\",\n value: function So(e, t, n, r) {\n var _this173 = this;\n\n return this.R_(), Promise.all([this.authCredentials.getToken(), this.appCheckCredentials.getToken()]).then(function (_ref25) {\n var _ref26 = _slicedToArray(_ref25, 2),\n i = _ref26[0],\n s = _ref26[1];\n\n return _this173.connection.So(e, __PRIVATE_toResourcePath(t, n), r, i, s);\n }).catch(function (e) {\n throw \"FirebaseError\" === e.name ? (e.code === D.UNAUTHENTICATED && (_this173.authCredentials.invalidateToken(), _this173.appCheckCredentials.invalidateToken()), e) : new FirestoreError(D.UNKNOWN, e.toString());\n });\n }\n /** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */\n\n }, {\n key: \"vo\",\n value: function vo(e, t, n, r, i) {\n var _this174 = this;\n\n return this.R_(), Promise.all([this.authCredentials.getToken(), this.appCheckCredentials.getToken()]).then(function (_ref27) {\n var _ref28 = _slicedToArray(_ref27, 2),\n s = _ref28[0],\n o = _ref28[1];\n\n return _this174.connection.vo(e, __PRIVATE_toResourcePath(t, n), r, s, o, i);\n }).catch(function (e) {\n throw \"FirebaseError\" === e.name ? (e.code === D.UNAUTHENTICATED && (_this174.authCredentials.invalidateToken(), _this174.appCheckCredentials.invalidateToken()), e) : new FirestoreError(D.UNKNOWN, e.toString());\n });\n }\n }, {\n key: \"terminate\",\n value: function terminate() {\n this.A_ = !0, this.connection.terminate();\n }\n }]);\n\n return __PRIVATE_DatastoreImpl;\n}( /*#__PURE__*/_createClass(function Datastore() {\n _classCallCheck(this, Datastore);\n})); // TODO(firestorexp): Make sure there is only one Datastore instance per\n// firestore-exp client.\n\n\nfunction __PRIVATE_invokeRunAggregationQueryRpc(_x23, _x24, _x25) {\n return _PRIVATE_invokeRunAggregationQueryRpc.apply(this, arguments);\n}\n/**\n * A component used by the RemoteStore to track the OnlineState (that is,\n * whether or not the client as a whole should be considered to be online or\n * offline), implementing the appropriate heuristics.\n *\n * In particular, when the client is trying to connect to the backend, we\n * allow up to MAX_WATCH_STREAM_FAILURES within ONLINE_STATE_TIMEOUT_MS for\n * a connection to succeed. If we have too many failures or the timeout elapses,\n * then we set the OnlineState to Offline, and the client will behave as if\n * it is offline (get()s will return cached data, etc.).\n */\n\n\nfunction _PRIVATE_invokeRunAggregationQueryRpc() {\n _PRIVATE_invokeRunAggregationQueryRpc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee82(e, t, n) {\n var r, i, _PRIVATE_toRunAggreg, s, o, _, a, u;\n\n return _regeneratorRuntime.wrap(function _callee82$(_context82) {\n while (1) {\n switch (_context82.prev = _context82.next) {\n case 0:\n i = __PRIVATE_debugCast(e), _PRIVATE_toRunAggreg = function __PRIVATE_toRunAggregationQueryRequest(e, t, n) {\n var _PRIVATE_toQueryTarg = __PRIVATE_toQueryTarget(e, t),\n r = _PRIVATE_toQueryTarg.ut,\n i = _PRIVATE_toQueryTarg.parent,\n s = {},\n o = [];\n\n var _ = 0;\n return n.forEach(function (e) {\n // Map all client-side aliases to a unique short-form\n // alias. This avoids issues with client-side aliases that\n // exceed the 1500-byte string size limit.\n var t = \"aggregate_\" + _++;\n s[t] = e.alias, \"count\" === e.aggregateType ? o.push({\n alias: t,\n count: {}\n }) : \"avg\" === e.aggregateType ? o.push({\n alias: t,\n avg: {\n field: __PRIVATE_toFieldPathReference(e.fieldPath)\n }\n }) : \"sum\" === e.aggregateType && o.push({\n alias: t,\n sum: {\n field: __PRIVATE_toFieldPathReference(e.fieldPath)\n }\n });\n }), {\n request: {\n structuredAggregationQuery: {\n aggregations: o,\n structuredQuery: r.structuredQuery\n },\n parent: r.parent\n },\n V_: s,\n parent: i\n };\n }(i.serializer, function __PRIVATE_queryToAggregateTarget(e) {\n var t = __PRIVATE_debugCast(e);\n\n return t.Pe || ( // Do not include implicit order-bys for aggregate queries.\n t.Pe = __PRIVATE__queryToTarget(t, e.explicitOrderBy)), t.Pe;\n }(t), n), s = _PRIVATE_toRunAggreg.request, o = _PRIVATE_toRunAggreg.V_, _ = _PRIVATE_toRunAggreg.parent;\n i.connection.wo || delete s.parent;\n _context82.next = 4;\n return i.vo(\"RunAggregationQuery\", i.serializer.databaseId, _, s,\n /*expectedResponseCount=*/\n 1);\n\n case 4:\n a = _context82.sent.filter(function (e) {\n return !!e.result;\n });\n\n // Omit RunAggregationQueryResponse that only contain readTimes.\n __PRIVATE_hardAssert(1 === a.length); // Remap the short-form aliases that were sent to the server\n // to the client-side aliases. Users will access the results\n // using the client-side alias.\n\n\n u = null === (r = a[0].result) || void 0 === r ? void 0 : r.aggregateFields;\n return _context82.abrupt(\"return\", Object.keys(u).reduce(function (e, t) {\n return e[o[t]] = u[t], e;\n }, {}));\n\n case 8:\n case \"end\":\n return _context82.stop();\n }\n }\n }, _callee82);\n }));\n return _PRIVATE_invokeRunAggregationQueryRpc.apply(this, arguments);\n}\n\nvar __PRIVATE_OnlineStateTracker = /*#__PURE__*/function () {\n function __PRIVATE_OnlineStateTracker(e, t) {\n _classCallCheck(this, __PRIVATE_OnlineStateTracker);\n\n this.asyncQueue = e, this.onlineStateHandler = t,\n /** The current OnlineState. */\n this.state = \"Unknown\"\n /* OnlineState.Unknown */\n ,\n /**\n * A count of consecutive failures to open the stream. If it reaches the\n * maximum defined by MAX_WATCH_STREAM_FAILURES, we'll set the OnlineState to\n * Offline.\n */\n this.m_ = 0,\n /**\n * A timer that elapses after ONLINE_STATE_TIMEOUT_MS, at which point we\n * transition from OnlineState.Unknown to OnlineState.Offline without waiting\n * for the stream to actually fail (MAX_WATCH_STREAM_FAILURES times).\n */\n this.f_ = null,\n /**\n * Whether the client should log a warning message if it fails to connect to\n * the backend (initially true, cleared after a successful stream, or if we've\n * logged the message already).\n */\n this.g_ = !0;\n }\n /**\n * Called by RemoteStore when a watch stream is started (including on each\n * backoff attempt).\n *\n * If this is the first attempt, it sets the OnlineState to Unknown and starts\n * the onlineStateTimer.\n */\n\n\n _createClass(__PRIVATE_OnlineStateTracker, [{\n key: \"p_\",\n value: function p_() {\n var _this175 = this;\n\n 0 === this.m_ && (this.y_(\"Unknown\"\n /* OnlineState.Unknown */\n ), this.f_ = this.asyncQueue.enqueueAfterDelay(\"online_state_timeout\"\n /* TimerId.OnlineStateTimeout */\n , 1e4, function () {\n return _this175.f_ = null, _this175.w_(\"Backend didn't respond within 10 seconds.\"), _this175.y_(\"Offline\"\n /* OnlineState.Offline */\n ), Promise.resolve();\n }));\n }\n /**\n * Updates our OnlineState as appropriate after the watch stream reports a\n * failure. The first failure moves us to the 'Unknown' state. We then may\n * allow multiple failures (based on MAX_WATCH_STREAM_FAILURES) before we\n * actually transition to the 'Offline' state.\n */\n\n }, {\n key: \"S_\",\n value: function S_(e) {\n \"Online\"\n /* OnlineState.Online */\n === this.state ? this.y_(\"Unknown\"\n /* OnlineState.Unknown */\n ) : (this.m_++, this.m_ >= 1 && (this.b_(), this.w_(\"Connection failed 1 times. Most recent error: \".concat(e.toString())), this.y_(\"Offline\"\n /* OnlineState.Offline */\n )));\n }\n /**\n * Explicitly sets the OnlineState to the specified state.\n *\n * Note that this resets our timers / failure counters, etc. used by our\n * Offline heuristics, so must not be used in place of\n * handleWatchStreamStart() and handleWatchStreamFailure().\n */\n\n }, {\n key: \"set\",\n value: function set(e) {\n this.b_(), this.m_ = 0, \"Online\"\n /* OnlineState.Online */\n === e && ( // We've connected to watch at least once. Don't warn the developer\n // about being offline going forward.\n this.g_ = !1), this.y_(e);\n }\n }, {\n key: \"y_\",\n value: function y_(e) {\n e !== this.state && (this.state = e, this.onlineStateHandler(e));\n }\n }, {\n key: \"w_\",\n value: function w_(e) {\n var t = \"Could not reach Cloud Firestore backend. \".concat(e, \"\\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.\");\n this.g_ ? (__PRIVATE_logError(t), this.g_ = !1) : __PRIVATE_logDebug(\"OnlineStateTracker\", t);\n }\n }, {\n key: \"b_\",\n value: function b_() {\n null !== this.f_ && (this.f_.cancel(), this.f_ = null);\n }\n }]);\n\n return __PRIVATE_OnlineStateTracker;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_RemoteStoreImpl = /*#__PURE__*/_createClass(function __PRIVATE_RemoteStoreImpl(\n/**\n * The local store, used to fill the write pipeline with outbound mutations.\n */\ne,\n/** The client-side proxy for interacting with the backend. */\nt, n, r, i) {\n var _this176 = this;\n\n _classCallCheck(this, __PRIVATE_RemoteStoreImpl);\n\n this.localStore = e, this.datastore = t, this.asyncQueue = n, this.remoteSyncer = {},\n /**\n * A list of up to MAX_PENDING_WRITES writes that we have fetched from the\n * LocalStore via fillWritePipeline() and have or will send to the write\n * stream.\n *\n * Whenever writePipeline.length > 0 the RemoteStore will attempt to start or\n * restart the write stream. When the stream is established the writes in the\n * pipeline will be sent in order.\n *\n * Writes remain in writePipeline until they are acknowledged by the backend\n * and thus will automatically be re-sent if the stream is interrupted /\n * restarted before they're acknowledged.\n *\n * Write responses from the backend are linked to their originating request\n * purely based on order, and so we can just shift() writes from the front of\n * the writePipeline as we receive responses.\n */\n this.D_ = [],\n /**\n * A mapping of watched targets that the client cares about tracking and the\n * user has explicitly called a 'listen' for this target.\n *\n * These targets may or may not have been sent to or acknowledged by the\n * server. On re-establishing the listen stream, these targets should be sent\n * to the server. The targets removed with unlistens are removed eagerly\n * without waiting for confirmation from the listen stream.\n */\n this.C_ = new Map(),\n /**\n * A set of reasons for why the RemoteStore may be offline. If empty, the\n * RemoteStore may start its network connections.\n */\n this.v_ = new Set(),\n /**\n * Event handlers that get called when the network is disabled or enabled.\n *\n * PORTING NOTE: These functions are used on the Web client to create the\n * underlying streams (to support tree-shakeable streams). On Android and iOS,\n * the streams are created during construction of RemoteStore.\n */\n this.F_ = [], this.M_ = i, this.M_.io(function (e) {\n n.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {\n return _regeneratorRuntime.wrap(function _callee21$(_context21) {\n while (1) {\n switch (_context21.prev = _context21.next) {\n case 0:\n _context21.t0 = __PRIVATE_canUseNetwork(_this176);\n\n if (!_context21.t0) {\n _context21.next = 5;\n break;\n }\n\n __PRIVATE_logDebug(\"RemoteStore\", \"Restarting streams for network reachability change.\");\n\n _context21.next = 5;\n return function () {\n var _PRIVATE_restartNetwork = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(e) {\n var t;\n return _regeneratorRuntime.wrap(function _callee20$(_context20) {\n while (1) {\n switch (_context20.prev = _context20.next) {\n case 0:\n t = __PRIVATE_debugCast(e);\n t.v_.add(4\n /* OfflineCause.ConnectivityChange */\n );\n _context20.next = 4;\n return __PRIVATE_disableNetworkInternal(t);\n\n case 4:\n t.x_.set(\"Unknown\"\n /* OnlineState.Unknown */\n );\n t.v_.delete(4\n /* OfflineCause.ConnectivityChange */\n );\n _context20.next = 8;\n return __PRIVATE_enableNetworkInternal(t);\n\n case 8:\n case \"end\":\n return _context20.stop();\n }\n }\n }, _callee20);\n }));\n\n function __PRIVATE_restartNetwork(_x26) {\n return _PRIVATE_restartNetwork.apply(this, arguments);\n }\n\n return __PRIVATE_restartNetwork;\n }()(_this176);\n\n case 5:\n case \"end\":\n return _context21.stop();\n }\n }\n }, _callee21);\n })));\n }), this.x_ = new __PRIVATE_OnlineStateTracker(n, r);\n});\n\nfunction __PRIVATE_enableNetworkInternal(_x27) {\n return _PRIVATE_enableNetworkInternal.apply(this, arguments);\n}\n/**\n * Temporarily disables the network. The network can be re-enabled using\n * enableNetwork().\n */\n\n\nfunction _PRIVATE_enableNetworkInternal() {\n _PRIVATE_enableNetworkInternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee83(e) {\n var _iterator93, _step93, t;\n\n return _regeneratorRuntime.wrap(function _callee83$(_context83) {\n while (1) {\n switch (_context83.prev = _context83.next) {\n case 0:\n if (!__PRIVATE_canUseNetwork(e)) {\n _context83.next = 18;\n break;\n }\n\n _iterator93 = _createForOfIteratorHelper(e.F_);\n _context83.prev = 2;\n\n _iterator93.s();\n\n case 4:\n if ((_step93 = _iterator93.n()).done) {\n _context83.next = 10;\n break;\n }\n\n t = _step93.value;\n _context83.next = 8;\n return t(\n /* enabled= */\n !0);\n\n case 8:\n _context83.next = 4;\n break;\n\n case 10:\n _context83.next = 15;\n break;\n\n case 12:\n _context83.prev = 12;\n _context83.t0 = _context83[\"catch\"](2);\n\n _iterator93.e(_context83.t0);\n\n case 15:\n _context83.prev = 15;\n\n _iterator93.f();\n\n return _context83.finish(15);\n\n case 18:\n case \"end\":\n return _context83.stop();\n }\n }\n }, _callee83, null, [[2, 12, 15, 18]]);\n }));\n return _PRIVATE_enableNetworkInternal.apply(this, arguments);\n}\n\nfunction __PRIVATE_disableNetworkInternal(_x28) {\n return _PRIVATE_disableNetworkInternal.apply(this, arguments);\n}\n/**\n * Starts new listen for the given target. Uses resume token if provided. It\n * is a no-op if the target of given `TargetData` is already being listened to.\n */\n\n\nfunction _PRIVATE_disableNetworkInternal() {\n _PRIVATE_disableNetworkInternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee84(e) {\n var _iterator94, _step94, t;\n\n return _regeneratorRuntime.wrap(function _callee84$(_context84) {\n while (1) {\n switch (_context84.prev = _context84.next) {\n case 0:\n _iterator94 = _createForOfIteratorHelper(e.F_);\n _context84.prev = 1;\n\n _iterator94.s();\n\n case 3:\n if ((_step94 = _iterator94.n()).done) {\n _context84.next = 9;\n break;\n }\n\n t = _step94.value;\n _context84.next = 7;\n return t(\n /* enabled= */\n !1);\n\n case 7:\n _context84.next = 3;\n break;\n\n case 9:\n _context84.next = 14;\n break;\n\n case 11:\n _context84.prev = 11;\n _context84.t0 = _context84[\"catch\"](1);\n\n _iterator94.e(_context84.t0);\n\n case 14:\n _context84.prev = 14;\n\n _iterator94.f();\n\n return _context84.finish(14);\n\n case 17:\n case \"end\":\n return _context84.stop();\n }\n }\n }, _callee84, null, [[1, 11, 14, 17]]);\n }));\n return _PRIVATE_disableNetworkInternal.apply(this, arguments);\n}\n\nfunction __PRIVATE_remoteStoreListen(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n n.C_.has(t.targetId) || ( // Mark this as something the client is currently listening for.\n n.C_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ? // The listen will be sent in onWatchStreamOpen\n __PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).Jo() && __PRIVATE_sendWatchRequest(n, t));\n}\n/**\n * Removes the listen from server. It is a no-op if the given target id is\n * not being listened to.\n */\n\n\nfunction __PRIVATE_remoteStoreUnlisten(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = __PRIVATE_ensureWatchStream(n);\n\n n.C_.delete(t), r.Jo() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.C_.size && (r.Jo() ? r.Xo() : __PRIVATE_canUseNetwork(n) && // Revert to OnlineState.Unknown if the watch stream is not open and we\n // have no listeners, since without any listens to send we cannot\n // confirm if the stream is healthy and upgrade to OnlineState.Online.\n n.x_.set(\"Unknown\"\n /* OnlineState.Unknown */\n ));\n}\n/**\n * We need to increment the the expected number of pending responses we're due\n * from watch so we wait for the ack to process any messages from this target.\n */\n\n\nfunction __PRIVATE_sendWatchRequest(e, t) {\n if (e.O_.Oe(t.targetId), t.resumeToken.approximateByteSize() > 0 || t.snapshotVersion.compareTo(SnapshotVersion.min()) > 0) {\n var n = e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;\n t = t.withExpectedCount(n);\n }\n\n __PRIVATE_ensureWatchStream(e).c_(t);\n}\n/**\n * We need to increment the expected number of pending responses we're due\n * from watch so we wait for the removal on the server before we process any\n * messages from this target.\n */\n\n\nfunction __PRIVATE_sendUnwatchRequest(e, t) {\n e.O_.Oe(t), __PRIVATE_ensureWatchStream(e).l_(t);\n}\n\nfunction __PRIVATE_startWatchStream(e) {\n e.O_ = new __PRIVATE_WatchChangeAggregator({\n getRemoteKeysForTarget: function getRemoteKeysForTarget(t) {\n return e.remoteSyncer.getRemoteKeysForTarget(t);\n },\n _t: function _t(t) {\n return e.C_.get(t) || null;\n },\n nt: function nt() {\n return e.datastore.serializer.databaseId;\n }\n }), __PRIVATE_ensureWatchStream(e).start(), e.x_.p_();\n}\n/**\n * Returns whether the watch stream should be started because it's necessary\n * and has not yet been started.\n */\n\n\nfunction __PRIVATE_shouldStartWatchStream(e) {\n return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).Ho() && e.C_.size > 0;\n}\n\nfunction __PRIVATE_canUseNetwork(e) {\n return 0 === __PRIVATE_debugCast(e).v_.size;\n}\n\nfunction __PRIVATE_cleanUpWatchStreamState(e) {\n e.O_ = void 0;\n}\n\nfunction __PRIVATE_onWatchStreamOpen(_x29) {\n return _PRIVATE_onWatchStreamOpen.apply(this, arguments);\n}\n\nfunction _PRIVATE_onWatchStreamOpen() {\n _PRIVATE_onWatchStreamOpen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee85(e) {\n return _regeneratorRuntime.wrap(function _callee85$(_context85) {\n while (1) {\n switch (_context85.prev = _context85.next) {\n case 0:\n e.C_.forEach(function (t, n) {\n __PRIVATE_sendWatchRequest(e, t);\n });\n\n case 1:\n case \"end\":\n return _context85.stop();\n }\n }\n }, _callee85);\n }));\n return _PRIVATE_onWatchStreamOpen.apply(this, arguments);\n}\n\nfunction __PRIVATE_onWatchStreamClose(_x30, _x31) {\n return _PRIVATE_onWatchStreamClose.apply(this, arguments);\n}\n\nfunction _PRIVATE_onWatchStreamClose() {\n _PRIVATE_onWatchStreamClose = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee86(e, t) {\n return _regeneratorRuntime.wrap(function _callee86$(_context86) {\n while (1) {\n switch (_context86.prev = _context86.next) {\n case 0:\n __PRIVATE_cleanUpWatchStreamState(e), // If we still need the watch stream, retry the connection.\n __PRIVATE_shouldStartWatchStream(e) ? (e.x_.S_(t), __PRIVATE_startWatchStream(e)) : // No need to restart watch stream because there are no active targets.\n // The online state is set to unknown because there is no active attempt\n // at establishing a connection\n e.x_.set(\"Unknown\"\n /* OnlineState.Unknown */\n );\n\n case 1:\n case \"end\":\n return _context86.stop();\n }\n }\n }, _callee86);\n }));\n return _PRIVATE_onWatchStreamClose.apply(this, arguments);\n}\n\nfunction __PRIVATE_onWatchStreamChange(_x32, _x33, _x34) {\n return _PRIVATE_onWatchStreamChange.apply(this, arguments);\n}\n/**\n * Recovery logic for IndexedDB errors that takes the network offline until\n * `op` succeeds. Retries are scheduled with backoff using\n * `enqueueRetryable()`. If `op()` is not provided, IndexedDB access is\n * validated via a generic operation.\n *\n * The returned Promise is resolved once the network is disabled and before\n * any retry attempt.\n */\n\n\nfunction _PRIVATE_onWatchStreamChange() {\n _PRIVATE_onWatchStreamChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee88(e, t, n) {\n var _t59;\n\n return _regeneratorRuntime.wrap(function _callee88$(_context88) {\n while (1) {\n switch (_context88.prev = _context88.next) {\n case 0:\n if (!( // Mark the client as online since we got a message from the server\n e.x_.set(\"Online\"\n /* OnlineState.Online */\n ), t instanceof __PRIVATE_WatchTargetChange && 2\n /* WatchTargetChangeState.Removed */\n === t.state && t.cause)) {\n _context88.next = 13;\n break;\n }\n\n _context88.prev = 1;\n _context88.next = 4;\n return (\n /** Handles an error on a target */\n function () {\n var _PRIVATE_handleTargetError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee87(e, t) {\n var n, _iterator95, _step95, r;\n\n return _regeneratorRuntime.wrap(function _callee87$(_context87) {\n while (1) {\n switch (_context87.prev = _context87.next) {\n case 0:\n n = t.cause;\n _iterator95 = _createForOfIteratorHelper(t.targetIds);\n _context87.prev = 2;\n\n _iterator95.s();\n\n case 4:\n if ((_step95 = _iterator95.n()).done) {\n _context87.next = 14;\n break;\n }\n\n r = _step95.value;\n _context87.t0 = e.C_.has(r);\n\n if (!_context87.t0) {\n _context87.next = 12;\n break;\n }\n\n _context87.next = 10;\n return e.remoteSyncer.rejectListen(r, n);\n\n case 10:\n e.C_.delete(r);\n e.O_.removeTarget(r);\n\n case 12:\n _context87.next = 4;\n break;\n\n case 14:\n _context87.next = 19;\n break;\n\n case 16:\n _context87.prev = 16;\n _context87.t1 = _context87[\"catch\"](2);\n\n _iterator95.e(_context87.t1);\n\n case 19:\n _context87.prev = 19;\n\n _iterator95.f();\n\n return _context87.finish(19);\n\n case 22:\n case \"end\":\n return _context87.stop();\n }\n }\n }, _callee87, null, [[2, 16, 19, 22]]);\n }));\n\n function __PRIVATE_handleTargetError(_x139, _x140) {\n return _PRIVATE_handleTargetError.apply(this, arguments);\n }\n\n return __PRIVATE_handleTargetError;\n }()\n /**\n * Attempts to fill our write pipeline with writes from the LocalStore.\n *\n * Called internally to bootstrap or refill the write pipeline and by\n * SyncEngine whenever there are new mutations to process.\n *\n * Starts the write stream if necessary.\n */\n (e, t)\n );\n\n case 4:\n _context88.next = 11;\n break;\n\n case 6:\n _context88.prev = 6;\n _context88.t0 = _context88[\"catch\"](1);\n\n __PRIVATE_logDebug(\"RemoteStore\", \"Failed to remove targets %s: %s \", t.targetIds.join(\",\"), _context88.t0);\n\n _context88.next = 11;\n return __PRIVATE_disableNetworkUntilRecovery(e, _context88.t0);\n\n case 11:\n _context88.next = 29;\n break;\n\n case 13:\n if (!(t instanceof __PRIVATE_DocumentWatchChange ? e.O_.$e(t) : t instanceof __PRIVATE_ExistenceFilterChange ? e.O_.Je(t) : e.O_.Ge(t), !n.isEqual(SnapshotVersion.min()))) {\n _context88.next = 29;\n break;\n }\n\n _context88.prev = 14;\n _context88.next = 17;\n return __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e.localStore);\n\n case 17:\n _t59 = _context88.sent;\n _context88.t1 = n.compareTo(_t59) >= 0;\n\n if (!_context88.t1) {\n _context88.next = 22;\n break;\n }\n\n _context88.next = 22;\n return (\n /**\n * Takes a batch of changes from the Datastore, repackages them as a\n * RemoteEvent, and passes that on to the listener, which is typically the\n * SyncEngine.\n */\n function __PRIVATE_raiseWatchSnapshot(e, t) {\n var n = e.O_.it(t); // Update in-memory resume tokens. LocalStore will update the\n // persistent view of these when applying the completed RemoteEvent.\n\n // Update in-memory resume tokens. LocalStore will update the\n // persistent view of these when applying the completed RemoteEvent.\n return n.targetChanges.forEach(function (n, r) {\n if (n.resumeToken.approximateByteSize() > 0) {\n var i = e.C_.get(r); // A watched target might have been removed already.\n\n // A watched target might have been removed already.\n i && e.C_.set(r, i.withResumeToken(n.resumeToken, t));\n }\n }), // Re-establish listens for the targets that have been invalidated by\n // existence filter mismatches.\n n.targetMismatches.forEach(function (t, n) {\n var r = e.C_.get(t);\n if (!r) // A watched target might have been removed already.\n return; // Clear the resume token for the target, since we're in a known mismatch\n // state.\n\n // Clear the resume token for the target, since we're in a known mismatch\n // state.\n e.C_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)), // Cause a hard reset by unwatching and rewatching immediately, but\n // deliberately don't send a resume token so that we get a full update.\n __PRIVATE_sendUnwatchRequest(e, t); // Mark the target we send as being on behalf of an existence filter\n // mismatch, but don't actually retain that in listenTargets. This ensures\n // that we flag the first re-listen this way without impacting future\n // listens of this target (that might happen e.g. on reconnect).\n\n // Mark the target we send as being on behalf of an existence filter\n // mismatch, but don't actually retain that in listenTargets. This ensures\n // that we flag the first re-listen this way without impacting future\n // listens of this target (that might happen e.g. on reconnect).\n var i = new TargetData(r.target, t, n, r.sequenceNumber);\n\n __PRIVATE_sendWatchRequest(e, i);\n }), e.remoteSyncer.applyRemoteEvent(n);\n }(e, n)\n );\n\n case 22:\n _context88.next = 29;\n break;\n\n case 24:\n _context88.prev = 24;\n _context88.t2 = _context88[\"catch\"](14);\n\n __PRIVATE_logDebug(\"RemoteStore\", \"Failed to raise snapshot:\", _context88.t2);\n\n _context88.next = 29;\n return __PRIVATE_disableNetworkUntilRecovery(e, _context88.t2);\n\n case 29:\n case \"end\":\n return _context88.stop();\n }\n }\n }, _callee88, null, [[1, 6], [14, 24]]);\n }));\n return _PRIVATE_onWatchStreamChange.apply(this, arguments);\n}\n\nfunction __PRIVATE_disableNetworkUntilRecovery(_x35, _x36, _x37) {\n return _PRIVATE_disableNetworkUntilRecovery.apply(this, arguments);\n}\n/**\n * Executes `op`. If `op` fails, takes the network offline until `op`\n * succeeds. Returns after the first attempt.\n */\n\n\nfunction _PRIVATE_disableNetworkUntilRecovery() {\n _PRIVATE_disableNetworkUntilRecovery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee90(e, t, n) {\n return _regeneratorRuntime.wrap(function _callee90$(_context90) {\n while (1) {\n switch (_context90.prev = _context90.next) {\n case 0:\n if (__PRIVATE_isIndexedDbTransactionError(t)) {\n _context90.next = 2;\n break;\n }\n\n throw t;\n\n case 2:\n e.v_.add(1\n /* OfflineCause.IndexedDbFailed */\n );\n _context90.next = 5;\n return __PRIVATE_disableNetworkInternal(e);\n\n case 5:\n e.x_.set(\"Offline\"\n /* OnlineState.Offline */\n );\n n || ( // Use a simple read operation to determine if IndexedDB recovered.\n // Ideally, we would expose a health check directly on SimpleDb, but\n // RemoteStore only has access to persistence through LocalStore.\n n = function n() {\n return __PRIVATE_localStoreGetLastRemoteSnapshotVersion(e.localStore);\n });\n // Probe IndexedDB periodically and re-enable network\n e.asyncQueue.enqueueRetryable( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee89() {\n return _regeneratorRuntime.wrap(function _callee89$(_context89) {\n while (1) {\n switch (_context89.prev = _context89.next) {\n case 0:\n __PRIVATE_logDebug(\"RemoteStore\", \"Retrying IndexedDB access\");\n\n _context89.next = 3;\n return n();\n\n case 3:\n e.v_.delete(1\n /* OfflineCause.IndexedDbFailed */\n );\n _context89.next = 6;\n return __PRIVATE_enableNetworkInternal(e);\n\n case 6:\n case \"end\":\n return _context89.stop();\n }\n }\n }, _callee89);\n })));\n\n case 8:\n case \"end\":\n return _context90.stop();\n }\n }\n }, _callee90);\n }));\n return _PRIVATE_disableNetworkUntilRecovery.apply(this, arguments);\n}\n\nfunction __PRIVATE_executeWithRecovery(e, t) {\n return t().catch(function (n) {\n return __PRIVATE_disableNetworkUntilRecovery(e, n, t);\n });\n}\n\nfunction __PRIVATE_fillWritePipeline(_x38) {\n return _PRIVATE_fillWritePipeline.apply(this, arguments);\n}\n/**\n * Returns true if we can add to the write pipeline (i.e. the network is\n * enabled and the write pipeline is not full).\n */\n\n\nfunction _PRIVATE_fillWritePipeline() {\n _PRIVATE_fillWritePipeline = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee91(e) {\n var t, n, r, _e121;\n\n return _regeneratorRuntime.wrap(function _callee91$(_context91) {\n while (1) {\n switch (_context91.prev = _context91.next) {\n case 0:\n t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);\n r = t.D_.length > 0 ? t.D_[t.D_.length - 1].batchId : -1;\n\n case 2:\n if (!__PRIVATE_canAddToWritePipeline(t)) {\n _context91.next = 19;\n break;\n }\n\n _context91.prev = 3;\n _context91.next = 6;\n return __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);\n\n case 6:\n _e121 = _context91.sent;\n\n if (!(null === _e121)) {\n _context91.next = 10;\n break;\n }\n\n 0 === t.D_.length && n.Xo();\n return _context91.abrupt(\"break\", 19);\n\n case 10:\n r = _e121.batchId, __PRIVATE_addToWritePipeline(t, _e121);\n _context91.next = 17;\n break;\n\n case 13:\n _context91.prev = 13;\n _context91.t0 = _context91[\"catch\"](3);\n _context91.next = 17;\n return __PRIVATE_disableNetworkUntilRecovery(t, _context91.t0);\n\n case 17:\n _context91.next = 2;\n break;\n\n case 19:\n __PRIVATE_shouldStartWriteStream(t) && __PRIVATE_startWriteStream(t);\n\n case 20:\n case \"end\":\n return _context91.stop();\n }\n }\n }, _callee91, null, [[3, 13]]);\n }));\n return _PRIVATE_fillWritePipeline.apply(this, arguments);\n}\n\nfunction __PRIVATE_canAddToWritePipeline(e) {\n return __PRIVATE_canUseNetwork(e) && e.D_.length < 10;\n}\n/**\n * Queues additional writes to be sent to the write stream, sending them\n * immediately if the write stream is established.\n */\n\n\nfunction __PRIVATE_addToWritePipeline(e, t) {\n e.D_.push(t);\n\n var n = __PRIVATE_ensureWriteStream(e);\n\n n.Jo() && n.P_ && n.I_(t.mutations);\n}\n\nfunction __PRIVATE_shouldStartWriteStream(e) {\n return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).Ho() && e.D_.length > 0;\n}\n\nfunction __PRIVATE_startWriteStream(e) {\n __PRIVATE_ensureWriteStream(e).start();\n}\n\nfunction __PRIVATE_onWriteStreamOpen(_x39) {\n return _PRIVATE_onWriteStreamOpen.apply(this, arguments);\n}\n\nfunction _PRIVATE_onWriteStreamOpen() {\n _PRIVATE_onWriteStreamOpen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee92(e) {\n return _regeneratorRuntime.wrap(function _callee92$(_context92) {\n while (1) {\n switch (_context92.prev = _context92.next) {\n case 0:\n __PRIVATE_ensureWriteStream(e).d_();\n\n case 1:\n case \"end\":\n return _context92.stop();\n }\n }\n }, _callee92);\n }));\n return _PRIVATE_onWriteStreamOpen.apply(this, arguments);\n}\n\nfunction __PRIVATE_onWriteHandshakeComplete(_x40) {\n return _PRIVATE_onWriteHandshakeComplete.apply(this, arguments);\n}\n\nfunction _PRIVATE_onWriteHandshakeComplete() {\n _PRIVATE_onWriteHandshakeComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee93(e) {\n var t, _iterator96, _step96, n;\n\n return _regeneratorRuntime.wrap(function _callee93$(_context93) {\n while (1) {\n switch (_context93.prev = _context93.next) {\n case 0:\n t = __PRIVATE_ensureWriteStream(e); // Send the write pipeline now that the stream is established.\n\n _iterator96 = _createForOfIteratorHelper(e.D_);\n\n try {\n for (_iterator96.s(); !(_step96 = _iterator96.n()).done;) {\n n = _step96.value;\n t.I_(n.mutations);\n }\n } catch (err) {\n _iterator96.e(err);\n } finally {\n _iterator96.f();\n }\n\n case 3:\n case \"end\":\n return _context93.stop();\n }\n }\n }, _callee93);\n }));\n return _PRIVATE_onWriteHandshakeComplete.apply(this, arguments);\n}\n\nfunction __PRIVATE_onMutationResult(_x41, _x42, _x43) {\n return _PRIVATE_onMutationResult.apply(this, arguments);\n}\n\nfunction _PRIVATE_onMutationResult() {\n _PRIVATE_onMutationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee94(e, t, n) {\n var r, i;\n return _regeneratorRuntime.wrap(function _callee94$(_context94) {\n while (1) {\n switch (_context94.prev = _context94.next) {\n case 0:\n r = e.D_.shift(), i = MutationBatchResult.from(r, t, n);\n _context94.next = 3;\n return __PRIVATE_executeWithRecovery(e, function () {\n return e.remoteSyncer.applySuccessfulWrite(i);\n });\n\n case 3:\n _context94.next = 5;\n return __PRIVATE_fillWritePipeline(e);\n\n case 5:\n case \"end\":\n return _context94.stop();\n }\n }\n }, _callee94);\n }));\n return _PRIVATE_onMutationResult.apply(this, arguments);\n}\n\nfunction __PRIVATE_onWriteStreamClose(_x44, _x45) {\n return _PRIVATE_onWriteStreamClose.apply(this, arguments);\n}\n\nfunction _PRIVATE_onWriteStreamClose() {\n _PRIVATE_onWriteStreamClose = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee96(e, t) {\n return _regeneratorRuntime.wrap(function _callee96$(_context96) {\n while (1) {\n switch (_context96.prev = _context96.next) {\n case 0:\n _context96.t0 = t && __PRIVATE_ensureWriteStream(e).P_;\n\n if (!_context96.t0) {\n _context96.next = 4;\n break;\n }\n\n _context96.next = 4;\n return function () {\n var _PRIVATE_handleWriteError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee95(e, t) {\n var n;\n return _regeneratorRuntime.wrap(function _callee95$(_context95) {\n while (1) {\n switch (_context95.prev = _context95.next) {\n case 0:\n if (!function __PRIVATE_isPermanentWriteError(e) {\n return __PRIVATE_isPermanentError(e) && e !== D.ABORTED;\n }(t.code)) {\n _context95.next = 7;\n break;\n }\n\n // This was a permanent error, the request itself was the problem\n // so it's not going to succeed if we resend it.\n n = e.D_.shift(); // In this case it's also unlikely that the server itself is melting\n // down -- this was just a bad request so inhibit backoff on the next\n // restart.\n\n __PRIVATE_ensureWriteStream(e).Zo();\n\n _context95.next = 5;\n return __PRIVATE_executeWithRecovery(e, function () {\n return e.remoteSyncer.rejectFailedWrite(n.batchId, t);\n });\n\n case 5:\n _context95.next = 7;\n return __PRIVATE_fillWritePipeline(e);\n\n case 7:\n case \"end\":\n return _context95.stop();\n }\n }\n }, _callee95);\n }));\n\n function __PRIVATE_handleWriteError(_x141, _x142) {\n return _PRIVATE_handleWriteError.apply(this, arguments);\n }\n\n return __PRIVATE_handleWriteError;\n }()(e, t);\n\n case 4:\n // The write stream might have been started by refilling the write\n // pipeline for failed writes\n __PRIVATE_shouldStartWriteStream(e) && __PRIVATE_startWriteStream(e);\n\n case 5:\n case \"end\":\n return _context96.stop();\n }\n }\n }, _callee96);\n }));\n return _PRIVATE_onWriteStreamClose.apply(this, arguments);\n}\n\nfunction __PRIVATE_remoteStoreHandleCredentialChange(_x46, _x47) {\n return _PRIVATE_remoteStoreHandleCredentialChange.apply(this, arguments);\n}\n/**\n * Toggles the network state when the client gains or loses its primary lease.\n */\n\n\nfunction _PRIVATE_remoteStoreHandleCredentialChange() {\n _PRIVATE_remoteStoreHandleCredentialChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee97(e, t) {\n var n, r;\n return _regeneratorRuntime.wrap(function _callee97$(_context97) {\n while (1) {\n switch (_context97.prev = _context97.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n n.asyncQueue.verifyOperationInProgress(), __PRIVATE_logDebug(\"RemoteStore\", \"RemoteStore received new credentials\");\n r = __PRIVATE_canUseNetwork(n); // Tear down and re-create our network streams. This will ensure we get a\n // fresh auth token for the new user and re-fill the write pipeline with\n // new mutations from the LocalStore (since mutations are per-user).\n\n n.v_.add(3\n /* OfflineCause.CredentialChange */\n );\n _context97.next = 6;\n return __PRIVATE_disableNetworkInternal(n);\n\n case 6:\n r && // Don't set the network status to Unknown if we are offline.\n n.x_.set(\"Unknown\"\n /* OnlineState.Unknown */\n );\n _context97.next = 9;\n return n.remoteSyncer.handleCredentialChange(t);\n\n case 9:\n n.v_.delete(3\n /* OfflineCause.CredentialChange */\n );\n _context97.next = 12;\n return __PRIVATE_enableNetworkInternal(n);\n\n case 12:\n case \"end\":\n return _context97.stop();\n }\n }\n }, _callee97);\n }));\n return _PRIVATE_remoteStoreHandleCredentialChange.apply(this, arguments);\n}\n\nfunction __PRIVATE_remoteStoreApplyPrimaryState(_x48, _x49) {\n return _PRIVATE_remoteStoreApplyPrimaryState.apply(this, arguments);\n}\n/**\n * If not yet initialized, registers the WatchStream and its network state\n * callback with `remoteStoreImpl`. Returns the existing stream if one is\n * already available.\n *\n * PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.\n * This is not done on Web to allow it to be tree-shaken.\n */\n\n\nfunction _PRIVATE_remoteStoreApplyPrimaryState() {\n _PRIVATE_remoteStoreApplyPrimaryState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee98(e, t) {\n var n;\n return _regeneratorRuntime.wrap(function _callee98$(_context98) {\n while (1) {\n switch (_context98.prev = _context98.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n\n if (!t) {\n _context98.next = 7;\n break;\n }\n\n n.v_.delete(2\n /* OfflineCause.IsSecondary */\n );\n _context98.next = 5;\n return __PRIVATE_enableNetworkInternal(n);\n\n case 5:\n _context98.next = 13;\n break;\n\n case 7:\n _context98.t0 = t;\n\n if (_context98.t0) {\n _context98.next = 13;\n break;\n }\n\n n.v_.add(2\n /* OfflineCause.IsSecondary */\n );\n _context98.next = 12;\n return __PRIVATE_disableNetworkInternal(n);\n\n case 12:\n n.x_.set(\"Unknown\"\n /* OnlineState.Unknown */\n );\n\n case 13:\n case \"end\":\n return _context98.stop();\n }\n }\n }, _callee98);\n }));\n return _PRIVATE_remoteStoreApplyPrimaryState.apply(this, arguments);\n}\n\nfunction __PRIVATE_ensureWatchStream(e) {\n return e.N_ || ( // Create stream (but note that it is not started yet).\n e.N_ = function __PRIVATE_newPersistentWatchStream(e, t, n) {\n var r = __PRIVATE_debugCast(e);\n\n return r.R_(), new __PRIVATE_PersistentListenStream(t, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);\n }\n /**\n * @license\n * Copyright 2018 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n (e.datastore, e.asyncQueue, {\n Po: __PRIVATE_onWatchStreamOpen.bind(null, e),\n To: __PRIVATE_onWatchStreamClose.bind(null, e),\n u_: __PRIVATE_onWatchStreamChange.bind(null, e)\n }), e.F_.push( /*#__PURE__*/function () {\n var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(t) {\n return _regeneratorRuntime.wrap(function _callee22$(_context22) {\n while (1) {\n switch (_context22.prev = _context22.next) {\n case 0:\n if (!t) {\n _context22.next = 4;\n break;\n }\n\n e.N_.Zo(), __PRIVATE_shouldStartWatchStream(e) ? __PRIVATE_startWatchStream(e) : e.x_.set(\"Unknown\"\n /* OnlineState.Unknown */\n );\n _context22.next = 7;\n break;\n\n case 4:\n _context22.next = 6;\n return e.N_.stop();\n\n case 6:\n __PRIVATE_cleanUpWatchStreamState(e);\n\n case 7:\n case \"end\":\n return _context22.stop();\n }\n }\n }, _callee22);\n }));\n\n return function (_x50) {\n return _ref30.apply(this, arguments);\n };\n }())), e.N_;\n}\n/**\n * If not yet initialized, registers the WriteStream and its network state\n * callback with `remoteStoreImpl`. Returns the existing stream if one is\n * already available.\n *\n * PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.\n * This is not done on Web to allow it to be tree-shaken.\n */\n\n\nfunction __PRIVATE_ensureWriteStream(e) {\n return e.B_ || ( // Create stream (but note that it is not started yet).\n e.B_ = function __PRIVATE_newPersistentWriteStream(e, t, n) {\n var r = __PRIVATE_debugCast(e);\n\n return r.R_(), new __PRIVATE_PersistentWriteStream(t, r.connection, r.authCredentials, r.appCheckCredentials, r.serializer, n);\n }(e.datastore, e.asyncQueue, {\n Po: __PRIVATE_onWriteStreamOpen.bind(null, e),\n To: __PRIVATE_onWriteStreamClose.bind(null, e),\n E_: __PRIVATE_onWriteHandshakeComplete.bind(null, e),\n T_: __PRIVATE_onMutationResult.bind(null, e)\n }), e.F_.push( /*#__PURE__*/function () {\n var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(t) {\n return _regeneratorRuntime.wrap(function _callee23$(_context23) {\n while (1) {\n switch (_context23.prev = _context23.next) {\n case 0:\n if (!t) {\n _context23.next = 6;\n break;\n }\n\n e.B_.Zo();\n _context23.next = 4;\n return __PRIVATE_fillWritePipeline(e);\n\n case 4:\n _context23.next = 9;\n break;\n\n case 6:\n _context23.next = 8;\n return e.B_.stop();\n\n case 8:\n e.D_.length > 0 && (__PRIVATE_logDebug(\"RemoteStore\", \"Stopping write stream with \".concat(e.D_.length, \" pending writes\")), e.D_ = []);\n\n case 9:\n case \"end\":\n return _context23.stop();\n }\n }\n }, _callee23);\n }));\n\n return function (_x51) {\n return _ref31.apply(this, arguments);\n };\n }())), e.B_;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents an operation scheduled to be run in the future on an AsyncQueue.\n *\n * It is created via DelayedOperation.createAndSchedule().\n *\n * Supports cancellation (via cancel()) and early execution (via skipDelay()).\n *\n * Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type\n * in newer versions of TypeScript defines `finally`, which is not available in\n * IE.\n */\n\n\nvar DelayedOperation = /*#__PURE__*/function () {\n function DelayedOperation(e, t, n, r, i) {\n _classCallCheck(this, DelayedOperation);\n\n this.asyncQueue = e, this.timerId = t, this.targetTimeMs = n, this.op = r, this.removalCallback = i, this.deferred = new __PRIVATE_Deferred(), this.then = this.deferred.promise.then.bind(this.deferred.promise), // It's normal for the deferred promise to be canceled (due to cancellation)\n // and so we attach a dummy catch callback to avoid\n // 'UnhandledPromiseRejectionWarning' log spam.\n this.deferred.promise.catch(function (e) {});\n }\n\n _createClass(DelayedOperation, [{\n key: \"promise\",\n get: function get() {\n return this.deferred.promise;\n }\n /**\n * Creates and returns a DelayedOperation that has been scheduled to be\n * executed on the provided asyncQueue after the provided delayMs.\n *\n * @param asyncQueue - The queue to schedule the operation on.\n * @param id - A Timer ID identifying the type of operation this is.\n * @param delayMs - The delay (ms) before the operation should be scheduled.\n * @param op - The operation to run.\n * @param removalCallback - A callback to be called synchronously once the\n * operation is executed or canceled, notifying the AsyncQueue to remove it\n * from its delayedOperations list.\n * PORTING NOTE: This exists to prevent making removeDelayedOperation() and\n * the DelayedOperation class public.\n */\n\n }, {\n key: \"start\",\n value:\n /**\n * Starts the timer. This is called immediately after construction by\n * createAndSchedule().\n */\n function start(e) {\n var _this177 = this;\n\n this.timerHandle = setTimeout(function () {\n return _this177.handleDelayElapsed();\n }, e);\n }\n /**\n * Queues the operation to run immediately (if it hasn't already been run or\n * canceled).\n */\n\n }, {\n key: \"skipDelay\",\n value: function skipDelay() {\n return this.handleDelayElapsed();\n }\n /**\n * Cancels the operation if it hasn't already been executed or canceled. The\n * promise will be rejected.\n *\n * As long as the operation has not yet been run, calling cancel() provides a\n * guarantee that the operation will not be run.\n */\n\n }, {\n key: \"cancel\",\n value: function cancel(e) {\n null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new FirestoreError(D.CANCELLED, \"Operation cancelled\" + (e ? \": \" + e : \"\"))));\n }\n }, {\n key: \"handleDelayElapsed\",\n value: function handleDelayElapsed() {\n var _this178 = this;\n\n this.asyncQueue.enqueueAndForget(function () {\n return null !== _this178.timerHandle ? (_this178.clearTimeout(), _this178.op().then(function (e) {\n return _this178.deferred.resolve(e);\n })) : Promise.resolve();\n });\n }\n }, {\n key: \"clearTimeout\",\n value: function (_clearTimeout) {\n function clearTimeout() {\n return _clearTimeout.apply(this, arguments);\n }\n\n clearTimeout.toString = function () {\n return _clearTimeout.toString();\n };\n\n return clearTimeout;\n }(function () {\n null !== this.timerHandle && (this.removalCallback(this), clearTimeout(this.timerHandle), this.timerHandle = null);\n })\n }], [{\n key: \"createAndSchedule\",\n value: function createAndSchedule(e, t, n, r, i) {\n var s = Date.now() + n,\n o = new DelayedOperation(e, t, s, r, i);\n return o.start(n), o;\n }\n }]);\n\n return DelayedOperation;\n}();\n/**\n * Returns a FirestoreError that can be surfaced to the user if the provided\n * error is an IndexedDbTransactionError. Re-throws the error otherwise.\n */\n\n\nfunction __PRIVATE_wrapInUserErrorIfRecoverable(e, t) {\n if (__PRIVATE_logError(\"AsyncQueue\", \"\".concat(t, \": \").concat(e)), __PRIVATE_isIndexedDbTransactionError(e)) return new FirestoreError(D.UNAVAILABLE, \"\".concat(t, \": \").concat(e));\n throw e;\n}\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * DocumentSet is an immutable (copy-on-write) collection that holds documents\n * in order specified by the provided comparator. We always add a document key\n * comparator on top of what is provided to guarantee document equality based on\n * the key.\n */\n\n\nvar DocumentSet = /*#__PURE__*/function () {\n /** The default ordering is by key if the comparator is omitted */\n function DocumentSet(e) {\n _classCallCheck(this, DocumentSet);\n\n // We are adding document key comparator to the end as it's the only\n // guaranteed unique property of a document.\n this.comparator = e ? function (t, n) {\n return e(t, n) || DocumentKey.comparator(t.key, n.key);\n } : function (e, t) {\n return DocumentKey.comparator(e.key, t.key);\n }, this.keyedMap = documentMap(), this.sortedSet = new SortedMap(this.comparator);\n }\n /**\n * Returns an empty copy of the existing DocumentSet, using the same\n * comparator.\n */\n\n\n _createClass(DocumentSet, [{\n key: \"has\",\n value: function has(e) {\n return null != this.keyedMap.get(e);\n }\n }, {\n key: \"get\",\n value: function get(e) {\n return this.keyedMap.get(e);\n }\n }, {\n key: \"first\",\n value: function first() {\n return this.sortedSet.minKey();\n }\n }, {\n key: \"last\",\n value: function last() {\n return this.sortedSet.maxKey();\n }\n }, {\n key: \"isEmpty\",\n value: function isEmpty() {\n return this.sortedSet.isEmpty();\n }\n /**\n * Returns the index of the provided key in the document set, or -1 if the\n * document key is not present in the set;\n */\n\n }, {\n key: \"indexOf\",\n value: function indexOf(e) {\n var t = this.keyedMap.get(e);\n return t ? this.sortedSet.indexOf(t) : -1;\n }\n }, {\n key: \"size\",\n get: function get() {\n return this.sortedSet.size;\n }\n /** Iterates documents in order defined by \"comparator\" */\n\n }, {\n key: \"forEach\",\n value: function forEach(e) {\n this.sortedSet.inorderTraversal(function (t, n) {\n return e(t), !1;\n });\n }\n /** Inserts or updates a document with the same key */\n\n }, {\n key: \"add\",\n value: function add(e) {\n // First remove the element if we have it.\n var t = this.delete(e.key);\n return t.copy(t.keyedMap.insert(e.key, e), t.sortedSet.insert(e, null));\n }\n /** Deletes a document with a given key */\n\n }, {\n key: \"delete\",\n value: function _delete(e) {\n var t = this.get(e);\n return t ? this.copy(this.keyedMap.remove(e), this.sortedSet.remove(t)) : this;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n if (!(e instanceof DocumentSet)) return !1;\n if (this.size !== e.size) return !1;\n var t = this.sortedSet.getIterator(),\n n = e.sortedSet.getIterator();\n\n for (; t.hasNext();) {\n var _e90 = t.getNext().key,\n r = n.getNext().key;\n if (!_e90.isEqual(r)) return !1;\n }\n\n return !0;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n var e = [];\n return this.forEach(function (t) {\n e.push(t.toString());\n }), 0 === e.length ? \"DocumentSet ()\" : \"DocumentSet (\\n \" + e.join(\" \\n\") + \"\\n)\";\n }\n }, {\n key: \"copy\",\n value: function copy(e, t) {\n var n = new DocumentSet();\n return n.comparator = this.comparator, n.keyedMap = e, n.sortedSet = t, n;\n }\n }], [{\n key: \"emptySet\",\n value: function emptySet(e) {\n return new DocumentSet(e.comparator);\n }\n }]);\n\n return DocumentSet;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * DocumentChangeSet keeps track of a set of changes to docs in a query, merging\n * duplicate events for the same doc.\n */\n\n\nvar __PRIVATE_DocumentChangeSet = /*#__PURE__*/function () {\n function __PRIVATE_DocumentChangeSet() {\n _classCallCheck(this, __PRIVATE_DocumentChangeSet);\n\n this.L_ = new SortedMap(DocumentKey.comparator);\n }\n\n _createClass(__PRIVATE_DocumentChangeSet, [{\n key: \"track\",\n value: function track(e) {\n var t = e.doc.key,\n n = this.L_.get(t);\n n ? // Merge the new change with the existing change.\n 0\n /* ChangeType.Added */\n !== e.type && 3\n /* ChangeType.Metadata */\n === n.type ? this.L_ = this.L_.insert(t, e) : 3\n /* ChangeType.Metadata */\n === e.type && 1\n /* ChangeType.Removed */\n !== n.type ? this.L_ = this.L_.insert(t, {\n type: n.type,\n doc: e.doc\n }) : 2\n /* ChangeType.Modified */\n === e.type && 2\n /* ChangeType.Modified */\n === n.type ? this.L_ = this.L_.insert(t, {\n type: 2\n /* ChangeType.Modified */\n ,\n doc: e.doc\n }) : 2\n /* ChangeType.Modified */\n === e.type && 0\n /* ChangeType.Added */\n === n.type ? this.L_ = this.L_.insert(t, {\n type: 0\n /* ChangeType.Added */\n ,\n doc: e.doc\n }) : 1\n /* ChangeType.Removed */\n === e.type && 0\n /* ChangeType.Added */\n === n.type ? this.L_ = this.L_.remove(t) : 1\n /* ChangeType.Removed */\n === e.type && 2\n /* ChangeType.Modified */\n === n.type ? this.L_ = this.L_.insert(t, {\n type: 1\n /* ChangeType.Removed */\n ,\n doc: n.doc\n }) : 0\n /* ChangeType.Added */\n === e.type && 1\n /* ChangeType.Removed */\n === n.type ? this.L_ = this.L_.insert(t, {\n type: 2\n /* ChangeType.Modified */\n ,\n doc: e.doc\n }) : // This includes these cases, which don't make sense:\n // Added->Added\n // Removed->Removed\n // Modified->Added\n // Removed->Modified\n // Metadata->Added\n // Removed->Metadata\n fail() : this.L_ = this.L_.insert(t, e);\n }\n }, {\n key: \"k_\",\n value: function k_() {\n var e = [];\n return this.L_.inorderTraversal(function (t, n) {\n e.push(n);\n }), e;\n }\n }]);\n\n return __PRIVATE_DocumentChangeSet;\n}();\n\nvar ViewSnapshot = /*#__PURE__*/function () {\n function ViewSnapshot(e, t, n, r, i, s, o, _, a) {\n _classCallCheck(this, ViewSnapshot);\n\n this.query = e, this.docs = t, this.oldDocs = n, this.docChanges = r, this.mutatedKeys = i, this.fromCache = s, this.syncStateChanged = o, this.excludesMetadataChanges = _, this.hasCachedResults = a;\n }\n /** Returns a view snapshot as if all documents in the snapshot were added. */\n\n\n _createClass(ViewSnapshot, [{\n key: \"hasPendingWrites\",\n get: function get() {\n return !this.mutatedKeys.isEmpty();\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n if (!(this.fromCache === e.fromCache && this.hasCachedResults === e.hasCachedResults && this.syncStateChanged === e.syncStateChanged && this.mutatedKeys.isEqual(e.mutatedKeys) && __PRIVATE_queryEquals(this.query, e.query) && this.docs.isEqual(e.docs) && this.oldDocs.isEqual(e.oldDocs))) return !1;\n var t = this.docChanges,\n n = e.docChanges;\n if (t.length !== n.length) return !1;\n\n for (var _e91 = 0; _e91 < t.length; _e91++) {\n if (t[_e91].type !== n[_e91].type || !t[_e91].doc.isEqual(n[_e91].doc)) return !1;\n }\n\n return !0;\n }\n }], [{\n key: \"fromInitialDocuments\",\n value: function fromInitialDocuments(e, t, n, r, i) {\n var s = [];\n return t.forEach(function (e) {\n s.push({\n type: 0\n /* ChangeType.Added */\n ,\n doc: e\n });\n }), new ViewSnapshot(e, t, DocumentSet.emptySet(t), s, n, r,\n /* syncStateChanged= */\n !0,\n /* excludesMetadataChanges= */\n !1, i);\n }\n }]);\n\n return ViewSnapshot;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Holds the listeners and the last received ViewSnapshot for a query being\n * tracked by EventManager.\n */\n\n\nvar __PRIVATE_QueryListenersInfo = /*#__PURE__*/_createClass(function __PRIVATE_QueryListenersInfo() {\n _classCallCheck(this, __PRIVATE_QueryListenersInfo);\n\n this.q_ = void 0, this.Q_ = [];\n});\n\nvar __PRIVATE_EventManagerImpl = /*#__PURE__*/_createClass(function __PRIVATE_EventManagerImpl() {\n _classCallCheck(this, __PRIVATE_EventManagerImpl);\n\n this.queries = new ObjectMap(function (e) {\n return __PRIVATE_canonifyQuery(e);\n }, __PRIVATE_queryEquals), this.onlineState = \"Unknown\"\n /* OnlineState.Unknown */\n , this.K_ = new Set();\n});\n\nfunction __PRIVATE_eventManagerListen(_x52, _x53) {\n return _PRIVATE_eventManagerListen.apply(this, arguments);\n}\n\nfunction _PRIVATE_eventManagerListen() {\n _PRIVATE_eventManagerListen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee99(e, t) {\n var n, r, i, s, _n39;\n\n return _regeneratorRuntime.wrap(function _callee99$(_context99) {\n while (1) {\n switch (_context99.prev = _context99.next) {\n case 0:\n n = __PRIVATE_debugCast(e), r = t.query;\n i = !1, s = n.queries.get(r);\n\n if (!(s || (i = !0, s = new __PRIVATE_QueryListenersInfo()), i)) {\n _context99.next = 13;\n break;\n }\n\n _context99.prev = 3;\n _context99.next = 6;\n return n.onListen(r);\n\n case 6:\n s.q_ = _context99.sent;\n _context99.next = 13;\n break;\n\n case 9:\n _context99.prev = 9;\n _context99.t0 = _context99[\"catch\"](3);\n _n39 = __PRIVATE_wrapInUserErrorIfRecoverable(_context99.t0, \"Initialization of query '\".concat(__PRIVATE_stringifyQuery(t.query), \"' failed\"));\n return _context99.abrupt(\"return\", void t.onError(_n39));\n\n case 13:\n if (n.queries.set(r, s), s.Q_.push(t), // Run global snapshot listeners if a consistent snapshot has been emitted.\n t.U_(n.onlineState), s.q_) {\n t.W_(s.q_) && __PRIVATE_raiseSnapshotsInSyncEvent(n);\n }\n\n case 14:\n case \"end\":\n return _context99.stop();\n }\n }\n }, _callee99, null, [[3, 9]]);\n }));\n return _PRIVATE_eventManagerListen.apply(this, arguments);\n}\n\nfunction __PRIVATE_eventManagerUnlisten(_x54, _x55) {\n return _PRIVATE_eventManagerUnlisten.apply(this, arguments);\n}\n\nfunction _PRIVATE_eventManagerUnlisten() {\n _PRIVATE_eventManagerUnlisten = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee100(e, t) {\n var n, r, i, s, _e122;\n\n return _regeneratorRuntime.wrap(function _callee100$(_context100) {\n while (1) {\n switch (_context100.prev = _context100.next) {\n case 0:\n n = __PRIVATE_debugCast(e), r = t.query;\n i = !1;\n s = n.queries.get(r);\n\n if (s) {\n _e122 = s.Q_.indexOf(t);\n _e122 >= 0 && (s.Q_.splice(_e122, 1), i = 0 === s.Q_.length);\n }\n\n if (!i) {\n _context100.next = 6;\n break;\n }\n\n return _context100.abrupt(\"return\", (n.queries.delete(r), n.onUnlisten(r)));\n\n case 6:\n case \"end\":\n return _context100.stop();\n }\n }\n }, _callee100);\n }));\n return _PRIVATE_eventManagerUnlisten.apply(this, arguments);\n}\n\nfunction __PRIVATE_eventManagerOnWatchChange(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n var r = !1;\n\n var _iterator64 = _createForOfIteratorHelper(t),\n _step64;\n\n try {\n for (_iterator64.s(); !(_step64 = _iterator64.n()).done;) {\n var _e92 = _step64.value;\n var _t45 = _e92.query,\n i = n.queries.get(_t45);\n\n if (i) {\n var _iterator65 = _createForOfIteratorHelper(i.Q_),\n _step65;\n\n try {\n for (_iterator65.s(); !(_step65 = _iterator65.n()).done;) {\n var _t46 = _step65.value;\n _t46.W_(_e92) && (r = !0);\n }\n } catch (err) {\n _iterator65.e(err);\n } finally {\n _iterator65.f();\n }\n\n i.q_ = _e92;\n }\n }\n } catch (err) {\n _iterator64.e(err);\n } finally {\n _iterator64.f();\n }\n\n r && __PRIVATE_raiseSnapshotsInSyncEvent(n);\n}\n\nfunction __PRIVATE_eventManagerOnWatchError(e, t, n) {\n var r = __PRIVATE_debugCast(e),\n i = r.queries.get(t);\n\n if (i) {\n var _iterator66 = _createForOfIteratorHelper(i.Q_),\n _step66;\n\n try {\n for (_iterator66.s(); !(_step66 = _iterator66.n()).done;) {\n var _e93 = _step66.value;\n\n _e93.onError(n);\n }\n } catch (err) {\n _iterator66.e(err);\n } finally {\n _iterator66.f();\n }\n } // Remove all listeners. NOTE: We don't need to call syncEngine.unlisten()\n // after an error.\n\n\n r.queries.delete(t);\n} // Call all global snapshot listeners that have been set.\n\n\nfunction __PRIVATE_raiseSnapshotsInSyncEvent(e) {\n e.K_.forEach(function (e) {\n e.next();\n });\n}\n/**\n * QueryListener takes a series of internal view snapshots and determines\n * when to raise the event.\n *\n * It uses an Observer to dispatch events.\n */\n\n\nvar __PRIVATE_QueryListener = /*#__PURE__*/function () {\n function __PRIVATE_QueryListener(e, t, n) {\n _classCallCheck(this, __PRIVATE_QueryListener);\n\n this.query = e, this.G_ = t,\n /**\n * Initial snapshots (e.g. from cache) may not be propagated to the wrapped\n * observer. This flag is set to true once we've actually raised an event.\n */\n this.z_ = !1, this.j_ = null, this.onlineState = \"Unknown\"\n /* OnlineState.Unknown */\n , this.options = n || {};\n }\n /**\n * Applies the new ViewSnapshot to this listener, raising a user-facing event\n * if applicable (depending on what changed, whether the user has opted into\n * metadata-only changes, etc.). Returns true if a user-facing event was\n * indeed raised.\n */\n\n\n _createClass(__PRIVATE_QueryListener, [{\n key: \"W_\",\n value: function W_(e) {\n if (!this.options.includeMetadataChanges) {\n // Remove the metadata only changes.\n var _t47 = [];\n\n var _iterator67 = _createForOfIteratorHelper(e.docChanges),\n _step67;\n\n try {\n for (_iterator67.s(); !(_step67 = _iterator67.n()).done;) {\n var n = _step67.value;\n 3\n /* ChangeType.Metadata */\n !== n.type && _t47.push(n);\n }\n } catch (err) {\n _iterator67.e(err);\n } finally {\n _iterator67.f();\n }\n\n e = new ViewSnapshot(e.query, e.docs, e.oldDocs, _t47, e.mutatedKeys, e.fromCache, e.syncStateChanged,\n /* excludesMetadataChanges= */\n !0, e.hasCachedResults);\n }\n\n var t = !1;\n return this.z_ ? this.H_(e) && (this.G_.next(e), t = !0) : this.J_(e, this.onlineState) && (this.Y_(e), t = !0), this.j_ = e, t;\n }\n }, {\n key: \"onError\",\n value: function onError(e) {\n this.G_.error(e);\n }\n /** Returns whether a snapshot was raised. */\n\n }, {\n key: \"U_\",\n value: function U_(e) {\n this.onlineState = e;\n var t = !1;\n return this.j_ && !this.z_ && this.J_(this.j_, e) && (this.Y_(this.j_), t = !0), t;\n }\n }, {\n key: \"J_\",\n value: function J_(e, t) {\n // Always raise the first event when we're synced\n if (!e.fromCache) return !0; // NOTE: We consider OnlineState.Unknown as online (it should become Offline\n // or Online if we wait long enough).\n\n var n = \"Offline\"\n /* OnlineState.Offline */\n !== t; // Don't raise the event if we're online, aren't synced yet (checked\n // above) and are waiting for a sync.\n\n return (!this.options.Z_ || !n) && (!e.docs.isEmpty() || e.hasCachedResults || \"Offline\"\n /* OnlineState.Offline */\n === t); // Raise data from cache if we have any documents, have cached results before,\n // or we are offline.\n }\n }, {\n key: \"H_\",\n value: function H_(e) {\n // We don't need to handle includeDocumentMetadataChanges here because\n // the Metadata only changes have already been stripped out if needed.\n // At this point the only changes we will see are the ones we should\n // propagate.\n if (e.docChanges.length > 0) return !0;\n var t = this.j_ && this.j_.hasPendingWrites !== e.hasPendingWrites;\n return !(!e.syncStateChanged && !t) && !0 === this.options.includeMetadataChanges; // Generally we should have hit one of the cases above, but it's possible\n // to get here if there were only metadata docChanges and they got\n // stripped out.\n }\n }, {\n key: \"Y_\",\n value: function Y_(e) {\n e = ViewSnapshot.fromInitialDocuments(e.query, e.docs, e.mutatedKeys, e.fromCache, e.hasCachedResults), this.z_ = !0, this.G_.next(e);\n }\n }]);\n\n return __PRIVATE_QueryListener;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A complete element in the bundle stream, together with the byte length it\n * occupies in the stream.\n */\n\n\nvar __PRIVATE_SizedBundleElement = /*#__PURE__*/function () {\n function __PRIVATE_SizedBundleElement(e, // How many bytes this element takes to store in the bundle.\n t) {\n _classCallCheck(this, __PRIVATE_SizedBundleElement);\n\n this.X_ = e, this.byteLength = t;\n }\n\n _createClass(__PRIVATE_SizedBundleElement, [{\n key: \"ea\",\n value: function ea() {\n return \"metadata\" in this.X_;\n }\n }]);\n\n return __PRIVATE_SizedBundleElement;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Helper to convert objects from bundles to model objects in the SDK.\n */\n\n\nvar __PRIVATE_BundleConverterImpl = /*#__PURE__*/function () {\n function __PRIVATE_BundleConverterImpl(e) {\n _classCallCheck(this, __PRIVATE_BundleConverterImpl);\n\n this.serializer = e;\n }\n\n _createClass(__PRIVATE_BundleConverterImpl, [{\n key: \"Ps\",\n value: function Ps(e) {\n return fromName(this.serializer, e);\n }\n /**\n * Converts a BundleDocument to a MutableDocument.\n */\n\n }, {\n key: \"Is\",\n value: function Is(e) {\n return e.metadata.exists ? __PRIVATE_fromDocument(this.serializer, e.document, !1) : MutableDocument.newNoDocument(this.Ps(e.metadata.name), this.Ts(e.metadata.readTime));\n }\n }, {\n key: \"Ts\",\n value: function Ts(e) {\n return __PRIVATE_fromVersion(e);\n }\n }]);\n\n return __PRIVATE_BundleConverterImpl;\n}();\n/**\n * A class to process the elements from a bundle, load them into local\n * storage and provide progress update while loading.\n */\n\n\nvar __PRIVATE_BundleLoader = /*#__PURE__*/function () {\n function __PRIVATE_BundleLoader(e, t, n) {\n _classCallCheck(this, __PRIVATE_BundleLoader);\n\n this.ta = e, this.localStore = t, this.serializer = n,\n /** Batched queries to be saved into storage */\n this.queries = [],\n /** Batched documents to be saved into storage */\n this.documents = [],\n /** The collection groups affected by this bundle. */\n this.collectionGroups = new Set(), this.progress = __PRIVATE_bundleInitialProgress(e);\n }\n /**\n * Adds an element from the bundle to the loader.\n *\n * Returns a new progress if adding the element leads to a new progress,\n * otherwise returns null.\n */\n\n\n _createClass(__PRIVATE_BundleLoader, [{\n key: \"na\",\n value: function na(e) {\n this.progress.bytesLoaded += e.byteLength;\n var t = this.progress.documentsLoaded;\n if (e.X_.namedQuery) this.queries.push(e.X_.namedQuery);else if (e.X_.documentMetadata) {\n this.documents.push({\n metadata: e.X_.documentMetadata\n }), e.X_.documentMetadata.exists || ++t;\n var n = ResourcePath.fromString(e.X_.documentMetadata.name);\n this.collectionGroups.add(n.get(n.length - 2));\n } else e.X_.document && (this.documents[this.documents.length - 1].document = e.X_.document, ++t);\n return t !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = t, Object.assign({}, this.progress)) : null;\n }\n }, {\n key: \"ra\",\n value: function ra(e) {\n var t = new Map(),\n n = new __PRIVATE_BundleConverterImpl(this.serializer);\n\n var _iterator68 = _createForOfIteratorHelper(e),\n _step68;\n\n try {\n for (_iterator68.s(); !(_step68 = _iterator68.n()).done;) {\n var r = _step68.value;\n\n if (r.metadata.queries) {\n var _e94 = n.Ps(r.metadata.name);\n\n var _iterator69 = _createForOfIteratorHelper(r.metadata.queries),\n _step69;\n\n try {\n for (_iterator69.s(); !(_step69 = _iterator69.n()).done;) {\n var _n28 = _step69.value;\n\n var _r24 = (t.get(_n28) || __PRIVATE_documentKeySet()).add(_e94);\n\n t.set(_n28, _r24);\n }\n } catch (err) {\n _iterator69.e(err);\n } finally {\n _iterator69.f();\n }\n }\n }\n } catch (err) {\n _iterator68.e(err);\n } finally {\n _iterator68.f();\n }\n\n return t;\n }\n /**\n * Update the progress to 'Success' and return the updated progress.\n */\n\n }, {\n key: \"complete\",\n value: function () {\n var _complete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {\n var e, t, _iterator70, _step70, _e95;\n\n return _regeneratorRuntime.wrap(function _callee24$(_context24) {\n while (1) {\n switch (_context24.prev = _context24.next) {\n case 0:\n _context24.next = 2;\n return __PRIVATE_localStoreApplyBundledDocuments(this.localStore, new __PRIVATE_BundleConverterImpl(this.serializer), this.documents, this.ta.id);\n\n case 2:\n e = _context24.sent;\n t = this.ra(this.documents);\n _iterator70 = _createForOfIteratorHelper(this.queries);\n _context24.prev = 5;\n\n _iterator70.s();\n\n case 7:\n if ((_step70 = _iterator70.n()).done) {\n _context24.next = 13;\n break;\n }\n\n _e95 = _step70.value;\n _context24.next = 11;\n return __PRIVATE_localStoreSaveNamedQuery(this.localStore, _e95, t.get(_e95.name));\n\n case 11:\n _context24.next = 7;\n break;\n\n case 13:\n _context24.next = 18;\n break;\n\n case 15:\n _context24.prev = 15;\n _context24.t0 = _context24[\"catch\"](5);\n\n _iterator70.e(_context24.t0);\n\n case 18:\n _context24.prev = 18;\n\n _iterator70.f();\n\n return _context24.finish(18);\n\n case 21:\n return _context24.abrupt(\"return\", (this.progress.taskState = \"Success\", {\n progress: this.progress,\n ia: this.collectionGroups,\n sa: e\n }));\n\n case 22:\n case \"end\":\n return _context24.stop();\n }\n }\n }, _callee24, this, [[5, 15, 18, 21]]);\n }));\n\n function complete() {\n return _complete.apply(this, arguments);\n }\n\n return complete;\n }()\n }]);\n\n return __PRIVATE_BundleLoader;\n}();\n/**\n * Returns a `LoadBundleTaskProgress` representing the initial progress of\n * loading a bundle.\n */\n\n\nfunction __PRIVATE_bundleInitialProgress(e) {\n return {\n taskState: \"Running\",\n documentsLoaded: 0,\n bytesLoaded: 0,\n totalDocuments: e.totalDocuments,\n totalBytes: e.totalBytes\n };\n}\n/**\n * Returns a `LoadBundleTaskProgress` representing the progress that the loading\n * has succeeded.\n */\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_AddedLimboDocument = /*#__PURE__*/_createClass(function __PRIVATE_AddedLimboDocument(e) {\n _classCallCheck(this, __PRIVATE_AddedLimboDocument);\n\n this.key = e;\n});\n\nvar __PRIVATE_RemovedLimboDocument = /*#__PURE__*/_createClass(function __PRIVATE_RemovedLimboDocument(e) {\n _classCallCheck(this, __PRIVATE_RemovedLimboDocument);\n\n this.key = e;\n});\n/**\n * View is responsible for computing the final merged truth of what docs are in\n * a query. It gets notified of local and remote changes to docs, and applies\n * the query filters and limits to determine the most correct possible results.\n */\n\n\nvar __PRIVATE_View = /*#__PURE__*/function () {\n function __PRIVATE_View(e,\n /** Documents included in the remote target */\n t) {\n _classCallCheck(this, __PRIVATE_View);\n\n this.query = e, this.oa = t, this._a = null, this.hasCachedResults = !1,\n /**\n * A flag whether the view is current with the backend. A view is considered\n * current after it has seen the current flag from the backend and did not\n * lose consistency within the watch stream (e.g. because of an existence\n * filter mismatch).\n */\n this.current = !1,\n /** Documents in the view but not in the remote target */\n this.aa = __PRIVATE_documentKeySet(),\n /** Document Keys that have local changes */\n this.mutatedKeys = __PRIVATE_documentKeySet(), this.ua = __PRIVATE_newQueryComparator(e), this.ca = new DocumentSet(this.ua);\n }\n /**\n * The set of remote documents that the server has told us belongs to the target associated with\n * this view.\n */\n\n\n _createClass(__PRIVATE_View, [{\n key: \"la\",\n get: function get() {\n return this.oa;\n }\n /**\n * Iterates over a set of doc changes, applies the query limit, and computes\n * what the new results should be, what the changes were, and whether we may\n * need to go back to the local cache for more results. Does not make any\n * changes to the view.\n * @param docChanges - The doc changes to apply to this view.\n * @param previousChanges - If this is being called with a refill, then start\n * with this set of docs and changes instead of the current view.\n * @returns a new set of docs, changes, and refill flag.\n */\n\n }, {\n key: \"ha\",\n value: function ha(e, t) {\n var _this179 = this;\n\n var n = t ? t.Pa : new __PRIVATE_DocumentChangeSet(),\n r = t ? t.ca : this.ca;\n var i = t ? t.mutatedKeys : this.mutatedKeys,\n s = r,\n o = !1; // Track the last doc in a (full) limit. This is necessary, because some\n // update (a delete, or an update moving a doc past the old limit) might\n // mean there is some other document in the local cache that either should\n // come (1) between the old last limit doc and the new last document, in the\n // case of updates, or (2) after the new last document, in the case of\n // deletes. So we keep this doc at the old limit to compare the updates to.\n // Note that this should never get used in a refill (when previousChanges is\n // set), because there will only be adds -- no deletes or updates.\n\n var _ = \"F\"\n /* LimitType.First */\n === this.query.limitType && r.size === this.query.limit ? r.last() : null,\n a = \"L\"\n /* LimitType.Last */\n === this.query.limitType && r.size === this.query.limit ? r.first() : null; // Drop documents out to meet limit/limitToLast requirement.\n\n\n if (e.inorderTraversal(function (e, t) {\n var u = r.get(e),\n c = __PRIVATE_queryMatches(_this179.query, t) ? t : null,\n l = !!u && _this179.mutatedKeys.has(u.key),\n h = !!c && (c.hasLocalMutations || // We only consider committed mutations for documents that were\n // mutated during the lifetime of the view.\n _this179.mutatedKeys.has(c.key) && c.hasCommittedMutations);\n\n var P = !1; // Calculate change\n\n if (u && c) {\n u.data.isEqual(c.data) ? l !== h && (n.track({\n type: 3\n /* ChangeType.Metadata */\n ,\n doc: c\n }), P = !0) : _this179.Ia(u, c) || (n.track({\n type: 2\n /* ChangeType.Modified */\n ,\n doc: c\n }), P = !0, (_ && _this179.ua(c, _) > 0 || a && _this179.ua(c, a) < 0) && ( // This doc moved from inside the limit to outside the limit.\n // That means there may be some other doc in the local cache\n // that should be included instead.\n o = !0));\n } else !u && c ? (n.track({\n type: 0\n /* ChangeType.Added */\n ,\n doc: c\n }), P = !0) : u && !c && (n.track({\n type: 1\n /* ChangeType.Removed */\n ,\n doc: u\n }), P = !0, (_ || a) && ( // A doc was removed from a full limit query. We'll need to\n // requery from the local cache to see if we know about some other\n // doc that should be in the results.\n o = !0));\n\n P && (c ? (s = s.add(c), i = h ? i.add(e) : i.delete(e)) : (s = s.delete(e), i = i.delete(e)));\n }), null !== this.query.limit) for (; s.size > this.query.limit;) {\n var _e96 = \"F\"\n /* LimitType.First */\n === this.query.limitType ? s.last() : s.first();\n\n s = s.delete(_e96.key), i = i.delete(_e96.key), n.track({\n type: 1\n /* ChangeType.Removed */\n ,\n doc: _e96\n });\n }\n return {\n ca: s,\n Pa: n,\n Xi: o,\n mutatedKeys: i\n };\n }\n }, {\n key: \"Ia\",\n value: function Ia(e, t) {\n // We suppress the initial change event for documents that were modified as\n // part of a write acknowledgment (e.g. when the value of a server transform\n // is applied) as Watch will send us the same document again.\n // By suppressing the event, we only raise two user visible events (one with\n // `hasPendingWrites` and the final state of the document) instead of three\n // (one with `hasPendingWrites`, the modified document with\n // `hasPendingWrites` and the final state of the document).\n return e.hasLocalMutations && t.hasCommittedMutations && !t.hasLocalMutations;\n }\n /**\n * Updates the view with the given ViewDocumentChanges and optionally updates\n * limbo docs and sync state from the provided target change.\n * @param docChanges - The set of changes to make to the view's docs.\n * @param limboResolutionEnabled - Whether to update limbo documents based on\n * this change.\n * @param targetChange - A target change to apply for computing limbo docs and\n * sync state.\n * @param targetIsPendingReset - Whether the target is pending to reset due to\n * existence filter mismatch. If not explicitly specified, it is treated\n * equivalently to `false`.\n * @returns A new ViewChange with the given docs, changes, and sync state.\n */\n // PORTING NOTE: The iOS/Android clients always compute limbo document changes.\n\n }, {\n key: \"applyChanges\",\n value: function applyChanges(e, t, n, r) {\n var _this180 = this;\n\n var i = this.ca;\n this.ca = e.ca, this.mutatedKeys = e.mutatedKeys; // Sort changes based on type and query comparator\n\n var s = e.Pa.k_();\n s.sort(function (e, t) {\n return function __PRIVATE_compareChangeType(e, t) {\n var order = function order(e) {\n switch (e) {\n case 0\n /* ChangeType.Added */\n :\n return 1;\n\n case 2\n /* ChangeType.Modified */\n :\n case 3\n /* ChangeType.Metadata */\n :\n // A metadata change is converted to a modified change at the public\n // api layer. Since we sort by document key and then change type,\n // metadata and modified changes must be sorted equivalently.\n return 2;\n\n case 1\n /* ChangeType.Removed */\n :\n return 0;\n\n default:\n return fail();\n }\n };\n\n return order(e) - order(t);\n }\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n (e.type, t.type) || _this180.ua(e.doc, t.doc);\n }), this.Ta(n), r = null != r && r;\n\n var o = t && !r ? this.Ea() : [],\n _ = 0 === this.aa.size && this.current && !r ? 1\n /* SyncState.Synced */\n : 0\n /* SyncState.Local */\n ,\n a = _ !== this._a; // We are at synced state if there is no limbo docs are waiting to be resolved, view is current\n // with the backend, and the query is not pending to reset due to existence filter mismatch.\n\n\n if (this._a = _, 0 !== s.length || a) {\n return {\n snapshot: new ViewSnapshot(this.query, e.ca, i, s, e.mutatedKeys, 0\n /* SyncState.Local */\n === _, a,\n /* excludesMetadataChanges= */\n !1, !!n && n.resumeToken.approximateByteSize() > 0),\n da: o\n };\n } // no changes\n\n\n return {\n da: o\n };\n }\n /**\n * Applies an OnlineState change to the view, potentially generating a\n * ViewChange if the view's syncState changes as a result.\n */\n\n }, {\n key: \"U_\",\n value: function U_(e) {\n return this.current && \"Offline\"\n /* OnlineState.Offline */\n === e ? ( // If we're offline, set `current` to false and then call applyChanges()\n // to refresh our syncState and generate a ViewChange as appropriate. We\n // are guaranteed to get a new TargetChange that sets `current` back to\n // true once the client is back online.\n this.current = !1, this.applyChanges({\n ca: this.ca,\n Pa: new __PRIVATE_DocumentChangeSet(),\n mutatedKeys: this.mutatedKeys,\n Xi: !1\n },\n /* limboResolutionEnabled= */\n !1)) : {\n da: []\n };\n }\n /**\n * Returns whether the doc for the given key should be in limbo.\n */\n\n }, {\n key: \"Aa\",\n value: function Aa(e) {\n // If the remote end says it's part of this query, it's not in limbo.\n return !this.oa.has(e) && // The local store doesn't think it's a result, so it shouldn't be in limbo.\n !!this.ca.has(e) && !this.ca.get(e).hasLocalMutations;\n }\n /**\n * Updates syncedDocuments, current, and limbo docs based on the given change.\n * Returns the list of changes to which docs are in limbo.\n */\n\n }, {\n key: \"Ta\",\n value: function Ta(e) {\n var _this181 = this;\n\n e && (e.addedDocuments.forEach(function (e) {\n return _this181.oa = _this181.oa.add(e);\n }), e.modifiedDocuments.forEach(function (e) {}), e.removedDocuments.forEach(function (e) {\n return _this181.oa = _this181.oa.delete(e);\n }), this.current = e.current);\n }\n }, {\n key: \"Ea\",\n value: function Ea() {\n var _this182 = this;\n\n // We can only determine limbo documents when we're in-sync with the server.\n if (!this.current) return []; // TODO(klimt): Do this incrementally so that it's not quadratic when\n // updating many documents.\n\n var e = this.aa;\n this.aa = __PRIVATE_documentKeySet(), this.ca.forEach(function (e) {\n _this182.Aa(e.key) && (_this182.aa = _this182.aa.add(e.key));\n }); // Diff the new limbo docs with the old limbo docs.\n\n var t = [];\n return e.forEach(function (e) {\n _this182.aa.has(e) || t.push(new __PRIVATE_RemovedLimboDocument(e));\n }), this.aa.forEach(function (n) {\n e.has(n) || t.push(new __PRIVATE_AddedLimboDocument(n));\n }), t;\n }\n /**\n * Update the in-memory state of the current view with the state read from\n * persistence.\n *\n * We update the query view whenever a client's primary status changes:\n * - When a client transitions from primary to secondary, it can miss\n * LocalStorage updates and its query views may temporarily not be\n * synchronized with the state on disk.\n * - For secondary to primary transitions, the client needs to update the list\n * of `syncedDocuments` since secondary clients update their query views\n * based purely on synthesized RemoteEvents.\n *\n * @param queryResult.documents - The documents that match the query according\n * to the LocalStore.\n * @param queryResult.remoteKeys - The keys of the documents that match the\n * query according to the backend.\n *\n * @returns The ViewChange that resulted from this synchronization.\n */\n // PORTING NOTE: Multi-tab only.\n\n }, {\n key: \"Ra\",\n value: function Ra(e) {\n this.oa = e.hs, this.aa = __PRIVATE_documentKeySet();\n var t = this.ha(e.documents);\n return this.applyChanges(t,\n /* limboResolutionEnabled= */\n !0);\n }\n /**\n * Returns a view snapshot as if this query was just listened to. Contains\n * a document add for every existing document and the `fromCache` and\n * `hasPendingWrites` status of the already established view.\n */\n // PORTING NOTE: Multi-tab only.\n\n }, {\n key: \"Va\",\n value: function Va() {\n return ViewSnapshot.fromInitialDocuments(this.query, this.ca, this.mutatedKeys, 0\n /* SyncState.Local */\n === this._a, this.hasCachedResults);\n }\n }]);\n\n return __PRIVATE_View;\n}();\n/**\n * QueryView contains all of the data that SyncEngine needs to keep track of for\n * a particular query.\n */\n\n\nvar __PRIVATE_QueryView = /*#__PURE__*/_createClass(function __PRIVATE_QueryView(\n/**\n * The query itself.\n */\ne,\n/**\n * The target number created by the client that is used in the watch\n * stream to identify this query.\n */\nt,\n/**\n * The view is responsible for computing the final merged truth of what\n * docs are in the query. It gets notified of local and remote changes,\n * and applies the query filters and limits to determine the most correct\n * possible results.\n */\nn) {\n _classCallCheck(this, __PRIVATE_QueryView);\n\n this.query = e, this.targetId = t, this.view = n;\n});\n/** Tracks a limbo resolution. */\n\n\nvar LimboResolution = /*#__PURE__*/_createClass(function LimboResolution(e) {\n _classCallCheck(this, LimboResolution);\n\n this.key = e,\n /**\n * Set to true once we've received a document. This is used in\n * getRemoteKeysForTarget() and ultimately used by WatchChangeAggregator to\n * decide whether it needs to manufacture a delete event for the target once\n * the target is CURRENT.\n */\n this.ma = !1;\n});\n/**\n * An implementation of `SyncEngine` coordinating with other parts of SDK.\n *\n * The parts of SyncEngine that act as a callback to RemoteStore need to be\n * registered individually. This is done in `syncEngineWrite()` and\n * `syncEngineListen()` (as well as `applyPrimaryState()`) as these methods\n * serve as entry points to RemoteStore's functionality.\n *\n * Note: some field defined in this class might have public access level, but\n * the class is not exported so they are only accessible from this module.\n * This is useful to implement optional features (like bundles) in free\n * functions, such that they are tree-shakeable.\n */\n\n\nvar __PRIVATE_SyncEngineImpl = /*#__PURE__*/function () {\n function __PRIVATE_SyncEngineImpl(e, t, n, // PORTING NOTE: Manages state synchronization in multi-tab environments.\n r, i, s) {\n _classCallCheck(this, __PRIVATE_SyncEngineImpl);\n\n this.localStore = e, this.remoteStore = t, this.eventManager = n, this.sharedClientState = r, this.currentUser = i, this.maxConcurrentLimboResolutions = s, this.fa = {}, this.ga = new ObjectMap(function (e) {\n return __PRIVATE_canonifyQuery(e);\n }, __PRIVATE_queryEquals), this.pa = new Map(),\n /**\n * The keys of documents that are in limbo for which we haven't yet started a\n * limbo resolution query. The strings in this set are the result of calling\n * `key.path.canonicalString()` where `key` is a `DocumentKey` object.\n *\n * The `Set` type was chosen because it provides efficient lookup and removal\n * of arbitrary elements and it also maintains insertion order, providing the\n * desired queue-like FIFO semantics.\n */\n this.ya = new Set(),\n /**\n * Keeps track of the target ID for each document that is in limbo with an\n * active target.\n */\n this.wa = new SortedMap(DocumentKey.comparator),\n /**\n * Keeps track of the information about an active limbo resolution for each\n * active target ID that was started for the purpose of limbo resolution.\n */\n this.Sa = new Map(), this.ba = new __PRIVATE_ReferenceSet(),\n /** Stores user completion handlers, indexed by User and BatchId. */\n this.Da = {},\n /** Stores user callbacks waiting for all pending writes to be acknowledged. */\n this.Ca = new Map(), this.va = __PRIVATE_TargetIdGenerator.Bn(), this.onlineState = \"Unknown\"\n /* OnlineState.Unknown */\n , // The primary state is set to `true` or `false` immediately after Firestore\n // startup. In the interim, a client should only be considered primary if\n // `isPrimary` is true.\n this.Fa = void 0;\n }\n\n _createClass(__PRIVATE_SyncEngineImpl, [{\n key: \"isPrimaryClient\",\n get: function get() {\n return !0 === this.Fa;\n }\n }]);\n\n return __PRIVATE_SyncEngineImpl;\n}();\n/**\n * Initiates the new listen, resolves promise when listen enqueued to the\n * server. All the subsequent view snapshots or errors are sent to the\n * subscribed handlers. Returns the initial snapshot.\n */\n\n\nfunction __PRIVATE_syncEngineListen(_x56, _x57) {\n return _PRIVATE_syncEngineListen.apply(this, arguments);\n}\n/**\n * Registers a view for a previously unknown query and computes its initial\n * snapshot.\n */\n\n\nfunction _PRIVATE_syncEngineListen() {\n _PRIVATE_syncEngineListen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee101(e, t) {\n var n, r, i, s, _e123, _s10;\n\n return _regeneratorRuntime.wrap(function _callee101$(_context101) {\n while (1) {\n switch (_context101.prev = _context101.next) {\n case 0:\n n = __PRIVATE_ensureWatchCallbacks(e);\n s = n.ga.get(t);\n\n if (!s) {\n _context101.next = 6;\n break;\n }\n\n // PORTING NOTE: With Multi-Tab Web, it is possible that a query view\n // already exists when EventManager calls us for the first time. This\n // happens when the primary tab is already listening to this query on\n // behalf of another tab and the user of the primary also starts listening\n // to the query. EventManager will not have an assigned target ID in this\n // case and calls `listen` to obtain this ID.\n r = s.targetId, n.sharedClientState.addLocalQueryTarget(r), i = s.view.Va();\n _context101.next = 15;\n break;\n\n case 6:\n _context101.next = 8;\n return __PRIVATE_localStoreAllocateTarget(n.localStore, __PRIVATE_queryToTarget(t));\n\n case 8:\n _e123 = _context101.sent;\n _s10 = n.sharedClientState.addLocalQueryTarget(_e123.targetId);\n r = _e123.targetId;\n _context101.next = 13;\n return __PRIVATE_initializeViewAndComputeSnapshot(n, t, r, \"current\" === _s10, _e123.resumeToken);\n\n case 13:\n i = _context101.sent;\n n.isPrimaryClient && __PRIVATE_remoteStoreListen(n.remoteStore, _e123);\n\n case 15:\n return _context101.abrupt(\"return\", i);\n\n case 16:\n case \"end\":\n return _context101.stop();\n }\n }\n }, _callee101);\n }));\n return _PRIVATE_syncEngineListen.apply(this, arguments);\n}\n\nfunction __PRIVATE_initializeViewAndComputeSnapshot(_x58, _x59, _x60, _x61, _x62) {\n return _PRIVATE_initializeViewAndComputeSnapshot.apply(this, arguments);\n}\n/** Stops listening to the query. */\n\n\nfunction _PRIVATE_initializeViewAndComputeSnapshot() {\n _PRIVATE_initializeViewAndComputeSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee103(e, t, n, r, i) {\n var s, o, _, a, u, c;\n\n return _regeneratorRuntime.wrap(function _callee103$(_context103) {\n while (1) {\n switch (_context103.prev = _context103.next) {\n case 0:\n // PORTING NOTE: On Web only, we inject the code that registers new Limbo\n // targets based on view changes. This allows us to only depend on Limbo\n // changes when user code includes queries.\n e.Ma = function (t, n, r) {\n return function () {\n var _PRIVATE_applyDocChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee102(e, t, n, r) {\n var i, s, o, _;\n\n return _regeneratorRuntime.wrap(function _callee102$(_context102) {\n while (1) {\n switch (_context102.prev = _context102.next) {\n case 0:\n i = t.view.ha(n);\n _context102.t0 = i.Xi;\n\n if (!_context102.t0) {\n _context102.next = 6;\n break;\n }\n\n _context102.next = 5;\n return __PRIVATE_localStoreExecuteQuery(e.localStore, t.query,\n /* usePreviousResults= */\n !1).then(function (_ref59) {\n var e = _ref59.documents;\n return t.view.ha(e, i);\n });\n\n case 5:\n i = _context102.sent;\n\n case 6:\n s = r && r.targetChanges.get(t.targetId), o = r && null != r.targetMismatches.get(t.targetId), _ = t.view.applyChanges(i,\n /* limboResolutionEnabled= */\n e.isPrimaryClient, s, o);\n return _context102.abrupt(\"return\", (__PRIVATE_updateTrackedLimbos(e, t.targetId, _.da), _.snapshot));\n\n case 8:\n case \"end\":\n return _context102.stop();\n }\n }\n }, _callee102);\n }));\n\n function __PRIVATE_applyDocChanges(_x143, _x144, _x145, _x146) {\n return _PRIVATE_applyDocChanges.apply(this, arguments);\n }\n\n return __PRIVATE_applyDocChanges;\n }()(e, t, n, r);\n };\n\n _context103.next = 3;\n return __PRIVATE_localStoreExecuteQuery(e.localStore, t,\n /* usePreviousResults= */\n !0);\n\n case 3:\n s = _context103.sent;\n o = new __PRIVATE_View(t, s.hs);\n _ = o.ha(s.documents);\n a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && \"Offline\"\n /* OnlineState.Offline */\n !== e.onlineState, i);\n u = o.applyChanges(_,\n /* limboResolutionEnabled= */\n e.isPrimaryClient, a);\n\n __PRIVATE_updateTrackedLimbos(e, n, u.da);\n\n c = new __PRIVATE_QueryView(t, n, o);\n return _context103.abrupt(\"return\", (e.ga.set(t, c), e.pa.has(n) ? e.pa.get(n).push(t) : e.pa.set(n, [t]), u.snapshot));\n\n case 11:\n case \"end\":\n return _context103.stop();\n }\n }\n }, _callee103);\n }));\n return _PRIVATE_initializeViewAndComputeSnapshot.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineUnlisten(_x63, _x64) {\n return _PRIVATE_syncEngineUnlisten.apply(this, arguments);\n}\n/**\n * Initiates the write of local mutation batch which involves adding the\n * writes to the mutation queue, notifying the remote store about new\n * mutations and raising events for any changes this write caused.\n *\n * The promise returned by this call is resolved when the above steps\n * have completed, *not* when the write was acked by the backend. The\n * userCallback is resolved once the write was acked/rejected by the\n * backend (or failed locally for any other reason).\n */\n\n\nfunction _PRIVATE_syncEngineUnlisten() {\n _PRIVATE_syncEngineUnlisten = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee104(e, t) {\n var n, r, i;\n return _regeneratorRuntime.wrap(function _callee104$(_context104) {\n while (1) {\n switch (_context104.prev = _context104.next) {\n case 0:\n n = __PRIVATE_debugCast(e), r = n.ga.get(t), i = n.pa.get(r.targetId);\n\n if (!(i.length > 1)) {\n _context104.next = 3;\n break;\n }\n\n return _context104.abrupt(\"return\", (n.pa.set(r.targetId, i.filter(function (e) {\n return !__PRIVATE_queryEquals(e, t);\n })), void n.ga.delete(t)));\n\n case 3:\n if (!n.isPrimaryClient) {\n _context104.next = 11;\n break;\n }\n\n // We need to remove the local query target first to allow us to verify\n // whether any other client is still interested in this target.\n n.sharedClientState.removeLocalQueryTarget(r.targetId);\n _context104.t0 = n.sharedClientState.isActiveQueryTarget(r.targetId);\n\n if (_context104.t0) {\n _context104.next = 9;\n break;\n }\n\n _context104.next = 9;\n return __PRIVATE_localStoreReleaseTarget(n.localStore, r.targetId,\n /*keepPersistedTargetData=*/\n !1).then(function () {\n n.sharedClientState.clearQueryState(r.targetId), __PRIVATE_remoteStoreUnlisten(n.remoteStore, r.targetId), __PRIVATE_removeAndCleanupTarget(n, r.targetId);\n }).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);\n\n case 9:\n _context104.next = 14;\n break;\n\n case 11:\n __PRIVATE_removeAndCleanupTarget(n, r.targetId);\n\n _context104.next = 14;\n return __PRIVATE_localStoreReleaseTarget(n.localStore, r.targetId,\n /*keepPersistedTargetData=*/\n !0);\n\n case 14:\n case \"end\":\n return _context104.stop();\n }\n }\n }, _callee104);\n }));\n return _PRIVATE_syncEngineUnlisten.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineWrite(_x65, _x66, _x67) {\n return _PRIVATE_syncEngineWrite.apply(this, arguments);\n}\n/**\n * Applies one remote event to the sync engine, notifying any views of the\n * changes, and releasing any pending mutation batches that would become\n * visible because of the snapshot version the remote event contains.\n */\n\n\nfunction _PRIVATE_syncEngineWrite() {\n _PRIVATE_syncEngineWrite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee105(e, t, n) {\n var r, _e124, _t61;\n\n return _regeneratorRuntime.wrap(function _callee105$(_context105) {\n while (1) {\n switch (_context105.prev = _context105.next) {\n case 0:\n r = __PRIVATE_syncEngineEnsureWriteCallbacks(e);\n _context105.prev = 1;\n _context105.next = 4;\n return function __PRIVATE_localStoreWriteLocally(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = Timestamp.now(),\n i = t.reduce(function (e, t) {\n return e.add(t.key);\n }, __PRIVATE_documentKeySet());\n\n var s, o;\n return n.persistence.runTransaction(\"Locally write mutations\", \"readwrite\", function (e) {\n // Figure out which keys do not have a remote version in the cache, this\n // is needed to create the right overlay mutation: if no remote version\n // presents, we do not need to create overlays as patch mutations.\n // TODO(Overlay): Is there a better way to determine this? Using the\n // document version does not work because local mutations set them back\n // to 0.\n var _ = __PRIVATE_mutableDocumentMap(),\n a = __PRIVATE_documentKeySet();\n\n return n.os.getEntries(e, i).next(function (e) {\n _ = e, _.forEach(function (e, t) {\n t.isValidDocument() || (a = a.add(e));\n });\n }).next(function () {\n return n.localDocuments.getOverlayedDocuments(e, _);\n }).next(function (i) {\n s = i; // For non-idempotent mutations (such as `FieldValue.increment()`),\n // we record the base state in a separate patch mutation. This is\n // later used to guarantee consistent values and prevents flicker\n // even if the backend sends us an update that already includes our\n // transform.\n\n // For non-idempotent mutations (such as `FieldValue.increment()`),\n // we record the base state in a separate patch mutation. This is\n // later used to guarantee consistent values and prevents flicker\n // even if the backend sends us an update that already includes our\n // transform.\n var o = [];\n\n var _iterator97 = _createForOfIteratorHelper(t),\n _step97;\n\n try {\n for (_iterator97.s(); !(_step97 = _iterator97.n()).done;) {\n var _e125 = _step97.value;\n\n var _t60 = __PRIVATE_mutationExtractBaseValue(_e125, s.get(_e125.key).overlayedDocument);\n\n null != _t60 && // NOTE: The base state should only be applied if there's some\n // existing document to override, so use a Precondition of\n // exists=true\n o.push(new __PRIVATE_PatchMutation(_e125.key, _t60, __PRIVATE_extractFieldMask(_t60.value.mapValue), Precondition.exists(!0)));\n }\n } catch (err) {\n _iterator97.e(err);\n } finally {\n _iterator97.f();\n }\n\n return n.mutationQueue.addMutationBatch(e, r, o, t);\n }).next(function (t) {\n o = t;\n var r = t.applyToLocalDocumentSet(s, a);\n return n.documentOverlayCache.saveOverlays(e, t.batchId, r);\n });\n }).then(function () {\n return {\n batchId: o.batchId,\n changes: __PRIVATE_convertOverlayedDocumentMapToDocumentMap(s)\n };\n });\n }(r.localStore, t);\n\n case 4:\n _e124 = _context105.sent;\n r.sharedClientState.addPendingMutation(_e124.batchId);\n\n (function __PRIVATE_addMutationCallback(e, t, n) {\n var r = e.Da[e.currentUser.toKey()];\n r || (r = new SortedMap(__PRIVATE_primitiveComparator));\n r = r.insert(t, n), e.Da[e.currentUser.toKey()] = r;\n }\n /**\n * Resolves or rejects the user callback for the given batch and then discards\n * it.\n */\n )(r, _e124.batchId, n);\n\n _context105.next = 9;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(r, _e124.changes);\n\n case 9:\n _context105.next = 11;\n return __PRIVATE_fillWritePipeline(r.remoteStore);\n\n case 11:\n _context105.next = 17;\n break;\n\n case 13:\n _context105.prev = 13;\n _context105.t0 = _context105[\"catch\"](1);\n // If we can't persist the mutation, we reject the user callback and\n // don't send the mutation. The user can then retry the write.\n _t61 = __PRIVATE_wrapInUserErrorIfRecoverable(_context105.t0, \"Failed to persist write\");\n n.reject(_t61);\n\n case 17:\n case \"end\":\n return _context105.stop();\n }\n }\n }, _callee105, null, [[1, 13]]);\n }));\n return _PRIVATE_syncEngineWrite.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineApplyRemoteEvent(_x68, _x69) {\n return _PRIVATE_syncEngineApplyRemoteEvent.apply(this, arguments);\n}\n/**\n * Applies an OnlineState change to the sync engine and notifies any views of\n * the change.\n */\n\n\nfunction _PRIVATE_syncEngineApplyRemoteEvent() {\n _PRIVATE_syncEngineApplyRemoteEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee106(e, t) {\n var n, _e126;\n\n return _regeneratorRuntime.wrap(function _callee106$(_context106) {\n while (1) {\n switch (_context106.prev = _context106.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n _context106.prev = 1;\n _context106.next = 4;\n return __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);\n\n case 4:\n _e126 = _context106.sent;\n t.targetChanges.forEach(function (e, t) {\n var r = n.Sa.get(t);\n r && ( // Since this is a limbo resolution lookup, it's for a single document\n // and it could be added, modified, or removed, but not a combination.\n __PRIVATE_hardAssert(e.addedDocuments.size + e.modifiedDocuments.size + e.removedDocuments.size <= 1), e.addedDocuments.size > 0 ? r.ma = !0 : e.modifiedDocuments.size > 0 ? __PRIVATE_hardAssert(r.ma) : e.removedDocuments.size > 0 && (__PRIVATE_hardAssert(r.ma), r.ma = !1));\n });\n _context106.next = 8;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, _e126, t);\n\n case 8:\n _context106.next = 14;\n break;\n\n case 10:\n _context106.prev = 10;\n _context106.t0 = _context106[\"catch\"](1);\n _context106.next = 14;\n return __PRIVATE_ignoreIfPrimaryLeaseLoss(_context106.t0);\n\n case 14:\n case \"end\":\n return _context106.stop();\n }\n }\n }, _callee106, null, [[1, 10]]);\n }));\n return _PRIVATE_syncEngineApplyRemoteEvent.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineApplyOnlineStateChange(e, t, n) {\n var r = __PRIVATE_debugCast(e); // If we are the secondary client, we explicitly ignore the remote store's\n // online state (the local client may go offline, even though the primary\n // tab remains online) and only apply the primary tab's online state from\n // SharedClientState.\n\n\n if (r.isPrimaryClient && 0\n /* OnlineStateSource.RemoteStore */\n === n || !r.isPrimaryClient && 1\n /* OnlineStateSource.SharedClientState */\n === n) {\n var _e97 = [];\n r.ga.forEach(function (n, r) {\n var i = r.view.U_(t);\n i.snapshot && _e97.push(i.snapshot);\n }), function __PRIVATE_eventManagerOnOnlineStateChange(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n n.onlineState = t;\n var r = !1;\n n.queries.forEach(function (e, n) {\n var _iterator71 = _createForOfIteratorHelper(n.Q_),\n _step71;\n\n try {\n for (_iterator71.s(); !(_step71 = _iterator71.n()).done;) {\n var _e98 = _step71.value;\n // Run global snapshot listeners if a consistent snapshot has been emitted.\n _e98.U_(t) && (r = !0);\n }\n } catch (err) {\n _iterator71.e(err);\n } finally {\n _iterator71.f();\n }\n }), r && __PRIVATE_raiseSnapshotsInSyncEvent(n);\n }(r.eventManager, t), _e97.length && r.fa.u_(_e97), r.onlineState = t, r.isPrimaryClient && r.sharedClientState.setOnlineState(t);\n }\n}\n/**\n * Rejects the listen for the given targetID. This can be triggered by the\n * backend for any active target.\n *\n * @param syncEngine - The sync engine implementation.\n * @param targetId - The targetID corresponds to one previously initiated by the\n * user as part of TargetData passed to listen() on RemoteStore.\n * @param err - A description of the condition that has forced the rejection.\n * Nearly always this will be an indication that the user is no longer\n * authorized to see the data matching the target.\n */\n\n\nfunction __PRIVATE_syncEngineRejectListen(_x70, _x71, _x72) {\n return _PRIVATE_syncEngineRejectListen.apply(this, arguments);\n}\n\nfunction _PRIVATE_syncEngineRejectListen() {\n _PRIVATE_syncEngineRejectListen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee107(e, t, n) {\n var r, i, s, _e127, _n40, _i20;\n\n return _regeneratorRuntime.wrap(function _callee107$(_context107) {\n while (1) {\n switch (_context107.prev = _context107.next) {\n case 0:\n r = __PRIVATE_debugCast(e); // PORTING NOTE: Multi-tab only.\n\n r.sharedClientState.updateQueryState(t, \"rejected\", n);\n i = r.Sa.get(t), s = i && i.key;\n\n if (!s) {\n _context107.next = 14;\n break;\n }\n\n // TODO(klimt): We really only should do the following on permission\n // denied errors, but we don't have the cause code here.\n // It's a limbo doc. Create a synthetic event saying it was deleted.\n // This is kind of a hack. Ideally, we would have a method in the local\n // store to purge a document. However, it would be tricky to keep all of\n // the local store's invariants with another method.\n _e127 = new SortedMap(DocumentKey.comparator); // TODO(b/217189216): This limbo document should ideally have a read time,\n // so that it is picked up by any read-time based scans. The backend,\n // however, does not send a read time for target removals.\n\n _e127 = _e127.insert(s, MutableDocument.newNoDocument(s, SnapshotVersion.min()));\n _n40 = __PRIVATE_documentKeySet().add(s), _i20 = new RemoteEvent(SnapshotVersion.min(),\n /* targetChanges= */\n new Map(),\n /* targetMismatches= */\n new SortedMap(__PRIVATE_primitiveComparator), _e127, _n40);\n _context107.next = 9;\n return __PRIVATE_syncEngineApplyRemoteEvent(r, _i20);\n\n case 9:\n // Since this query failed, we won't want to manually unlisten to it.\n // We only remove it from bookkeeping after we successfully applied the\n // RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to\n // this query when the RemoteStore restarts the Watch stream, which should\n // re-trigger the target failure.\n r.wa = r.wa.remove(s);\n r.Sa.delete(t);\n\n __PRIVATE_pumpEnqueuedLimboResolutions(r);\n\n _context107.next = 16;\n break;\n\n case 14:\n _context107.next = 16;\n return __PRIVATE_localStoreReleaseTarget(r.localStore, t,\n /* keepPersistedTargetData */\n !1).then(function () {\n return __PRIVATE_removeAndCleanupTarget(r, t, n);\n }).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);\n\n case 16:\n case \"end\":\n return _context107.stop();\n }\n }\n }, _callee107);\n }));\n return _PRIVATE_syncEngineRejectListen.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineApplySuccessfulWrite(_x73, _x74) {\n return _PRIVATE_syncEngineApplySuccessfulWrite.apply(this, arguments);\n}\n\nfunction _PRIVATE_syncEngineApplySuccessfulWrite() {\n _PRIVATE_syncEngineApplySuccessfulWrite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee108(e, t) {\n var n, r, _e128;\n\n return _regeneratorRuntime.wrap(function _callee108$(_context108) {\n while (1) {\n switch (_context108.prev = _context108.next) {\n case 0:\n n = __PRIVATE_debugCast(e), r = t.batch.batchId;\n _context108.prev = 1;\n _context108.next = 4;\n return __PRIVATE_localStoreAcknowledgeBatch(n.localStore, t);\n\n case 4:\n _e128 = _context108.sent;\n\n __PRIVATE_processUserCallback(n, r,\n /*error=*/\n null);\n\n __PRIVATE_triggerPendingWritesCallbacks(n, r);\n\n n.sharedClientState.updateMutationState(r, \"acknowledged\");\n _context108.next = 10;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, _e128);\n\n case 10:\n _context108.next = 16;\n break;\n\n case 12:\n _context108.prev = 12;\n _context108.t0 = _context108[\"catch\"](1);\n _context108.next = 16;\n return __PRIVATE_ignoreIfPrimaryLeaseLoss(_context108.t0);\n\n case 16:\n case \"end\":\n return _context108.stop();\n }\n }\n }, _callee108, null, [[1, 12]]);\n }));\n return _PRIVATE_syncEngineApplySuccessfulWrite.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineRejectFailedWrite(_x75, _x76, _x77) {\n return _PRIVATE_syncEngineRejectFailedWrite.apply(this, arguments);\n}\n/**\n * Registers a user callback that resolves when all pending mutations at the moment of calling\n * are acknowledged .\n */\n\n\nfunction _PRIVATE_syncEngineRejectFailedWrite() {\n _PRIVATE_syncEngineRejectFailedWrite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee109(e, t, n) {\n var r, _e129;\n\n return _regeneratorRuntime.wrap(function _callee109$(_context109) {\n while (1) {\n switch (_context109.prev = _context109.next) {\n case 0:\n r = __PRIVATE_debugCast(e);\n _context109.prev = 1;\n _context109.next = 4;\n return function __PRIVATE_localStoreRejectBatch(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return n.persistence.runTransaction(\"Reject batch\", \"readwrite-primary\", function (e) {\n var r;\n return n.mutationQueue.lookupMutationBatch(e, t).next(function (t) {\n return __PRIVATE_hardAssert(null !== t), r = t.keys(), n.mutationQueue.removeMutationBatch(e, t);\n }).next(function () {\n return n.mutationQueue.performConsistencyCheck(e);\n }).next(function () {\n return n.documentOverlayCache.removeOverlaysForBatchId(e, r, t);\n }).next(function () {\n return n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e, r);\n }).next(function () {\n return n.localDocuments.getDocuments(e, r);\n });\n });\n }\n /**\n * Returns the largest (latest) batch id in mutation queue that is pending\n * server response.\n *\n * Returns `BATCHID_UNKNOWN` if the queue is empty.\n */\n (r.localStore, t);\n\n case 4:\n _e129 = _context109.sent;\n\n __PRIVATE_processUserCallback(r, t, n);\n\n __PRIVATE_triggerPendingWritesCallbacks(r, t);\n\n r.sharedClientState.updateMutationState(t, \"rejected\", n);\n _context109.next = 10;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(r, _e129);\n\n case 10:\n _context109.next = 16;\n break;\n\n case 12:\n _context109.prev = 12;\n _context109.t0 = _context109[\"catch\"](1);\n _context109.next = 16;\n return __PRIVATE_ignoreIfPrimaryLeaseLoss(_context109.t0);\n\n case 16:\n case \"end\":\n return _context109.stop();\n }\n }\n }, _callee109, null, [[1, 12]]);\n }));\n return _PRIVATE_syncEngineRejectFailedWrite.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineRegisterPendingWritesCallback(_x78, _x79) {\n return _PRIVATE_syncEngineRegisterPendingWritesCallback.apply(this, arguments);\n}\n/**\n * Triggers the callbacks that are waiting for this batch id to get acknowledged by server,\n * if there are any.\n */\n\n\nfunction _PRIVATE_syncEngineRegisterPendingWritesCallback() {\n _PRIVATE_syncEngineRegisterPendingWritesCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee110(e, t) {\n var n, _e130, r, _n41;\n\n return _regeneratorRuntime.wrap(function _callee110$(_context110) {\n while (1) {\n switch (_context110.prev = _context110.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n __PRIVATE_canUseNetwork(n.remoteStore) || __PRIVATE_logDebug(\"SyncEngine\", \"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.\");\n _context110.prev = 2;\n _context110.next = 5;\n return function __PRIVATE_localStoreGetHighestUnacknowledgedBatchId(e) {\n var t = __PRIVATE_debugCast(e);\n\n return t.persistence.runTransaction(\"Get highest unacknowledged batch id\", \"readonly\", function (e) {\n return t.mutationQueue.getHighestUnacknowledgedBatchId(e);\n });\n }(n.localStore);\n\n case 5:\n _e130 = _context110.sent;\n\n if (!(-1 === _e130)) {\n _context110.next = 8;\n break;\n }\n\n return _context110.abrupt(\"return\", void t.resolve());\n\n case 8:\n r = n.Ca.get(_e130) || [];\n r.push(t), n.Ca.set(_e130, r);\n _context110.next = 16;\n break;\n\n case 12:\n _context110.prev = 12;\n _context110.t0 = _context110[\"catch\"](2);\n _n41 = __PRIVATE_wrapInUserErrorIfRecoverable(_context110.t0, \"Initialization of waitForPendingWrites() operation failed\");\n t.reject(_n41);\n\n case 16:\n case \"end\":\n return _context110.stop();\n }\n }\n }, _callee110, null, [[2, 12]]);\n }));\n return _PRIVATE_syncEngineRegisterPendingWritesCallback.apply(this, arguments);\n}\n\nfunction __PRIVATE_triggerPendingWritesCallbacks(e, t) {\n (e.Ca.get(t) || []).forEach(function (e) {\n e.resolve();\n }), e.Ca.delete(t);\n}\n/** Reject all outstanding callbacks waiting for pending writes to complete. */\n\n\nfunction __PRIVATE_processUserCallback(e, t, n) {\n var r = __PRIVATE_debugCast(e);\n\n var i = r.Da[r.currentUser.toKey()]; // NOTE: Mutations restored from persistence won't have callbacks, so it's\n // okay for there to be no callback for this ID.\n\n if (i) {\n var _e99 = i.get(t);\n\n _e99 && (n ? _e99.reject(n) : _e99.resolve(), i = i.remove(t)), r.Da[r.currentUser.toKey()] = i;\n }\n}\n\nfunction __PRIVATE_removeAndCleanupTarget(e, t) {\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n e.sharedClientState.removeLocalQueryTarget(t);\n\n var _iterator72 = _createForOfIteratorHelper(e.pa.get(t)),\n _step72;\n\n try {\n for (_iterator72.s(); !(_step72 = _iterator72.n()).done;) {\n var r = _step72.value;\n e.ga.delete(r), n && e.fa.xa(r, n);\n }\n } catch (err) {\n _iterator72.e(err);\n } finally {\n _iterator72.f();\n }\n\n if (e.pa.delete(t), e.isPrimaryClient) {\n e.ba.Vr(t).forEach(function (t) {\n e.ba.containsKey(t) || // We removed the last reference for this key\n __PRIVATE_removeLimboTarget(e, t);\n });\n }\n}\n\nfunction __PRIVATE_removeLimboTarget(e, t) {\n e.ya.delete(t.path.canonicalString()); // It's possible that the target already got removed because the query failed. In that case,\n // the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.\n\n var n = e.wa.get(t);\n null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.wa = e.wa.remove(t), e.Sa.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));\n}\n\nfunction __PRIVATE_updateTrackedLimbos(e, t, n) {\n var _iterator73 = _createForOfIteratorHelper(n),\n _step73;\n\n try {\n for (_iterator73.s(); !(_step73 = _iterator73.n()).done;) {\n var r = _step73.value;\n if (r instanceof __PRIVATE_AddedLimboDocument) e.ba.addReference(r.key, t), __PRIVATE_trackLimboChange(e, r);else if (r instanceof __PRIVATE_RemovedLimboDocument) {\n __PRIVATE_logDebug(\"SyncEngine\", \"Document no longer in limbo: \" + r.key), e.ba.removeReference(r.key, t);\n e.ba.containsKey(r.key) || // We removed the last reference for this key\n __PRIVATE_removeLimboTarget(e, r.key);\n } else fail();\n }\n } catch (err) {\n _iterator73.e(err);\n } finally {\n _iterator73.f();\n }\n}\n\nfunction __PRIVATE_trackLimboChange(e, t) {\n var n = t.key,\n r = n.path.canonicalString();\n e.wa.get(n) || e.ya.has(r) || (__PRIVATE_logDebug(\"SyncEngine\", \"New document in limbo: \" + n), e.ya.add(r), __PRIVATE_pumpEnqueuedLimboResolutions(e));\n}\n/**\n * Starts listens for documents in limbo that are enqueued for resolution,\n * subject to a maximum number of concurrent resolutions.\n *\n * Without bounding the number of concurrent resolutions, the server can fail\n * with \"resource exhausted\" errors which can lead to pathological client\n * behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.\n */\n\n\nfunction __PRIVATE_pumpEnqueuedLimboResolutions(e) {\n for (; e.ya.size > 0 && e.wa.size < e.maxConcurrentLimboResolutions;) {\n var t = e.ya.values().next().value;\n e.ya.delete(t);\n var n = new DocumentKey(ResourcePath.fromString(t)),\n r = e.va.next();\n e.Sa.set(r, new LimboResolution(n)), e.wa = e.wa.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, \"TargetPurposeLimboResolution\"\n /* TargetPurpose.LimboResolution */\n , __PRIVATE_ListenSequence._e));\n }\n}\n\nfunction __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(_x80, _x81, _x82) {\n return _PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore.apply(this, arguments);\n}\n\nfunction _PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore() {\n _PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee112(e, t, n) {\n var r, i, s, o;\n return _regeneratorRuntime.wrap(function _callee112$(_context112) {\n while (1) {\n switch (_context112.prev = _context112.next) {\n case 0:\n r = __PRIVATE_debugCast(e), i = [], s = [], o = [];\n _context112.t0 = r.ga.isEmpty();\n\n if (_context112.t0) {\n _context112.next = 9;\n break;\n }\n\n r.ga.forEach(function (e, _) {\n o.push(r.Ma(_, t, n).then(function (e) {\n // Update views if there are actual changes.\n if ( // If there are changes, or we are handling a global snapshot, notify\n // secondary clients to update query state.\n (e || n) && r.isPrimaryClient && r.sharedClientState.updateQueryState(_.targetId, (null == e ? void 0 : e.fromCache) ? \"not-current\" : \"current\"), e) {\n i.push(e);\n\n var _t62 = __PRIVATE_LocalViewChanges.Ki(_.targetId, e);\n\n s.push(_t62);\n }\n }));\n });\n _context112.next = 6;\n return Promise.all(o);\n\n case 6:\n r.fa.u_(i);\n _context112.next = 9;\n return function () {\n var _PRIVATE_localStoreNotifyLocalViewChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee111(e, t) {\n var n, _iterator98, _step98, _e131, _t63, _e132, _r38, _i21;\n\n return _regeneratorRuntime.wrap(function _callee111$(_context111) {\n while (1) {\n switch (_context111.prev = _context111.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n _context111.prev = 1;\n _context111.next = 4;\n return n.persistence.runTransaction(\"notifyLocalViewChanges\", \"readwrite\", function (e) {\n return PersistencePromise.forEach(t, function (t) {\n return PersistencePromise.forEach(t.qi, function (r) {\n return n.persistence.referenceDelegate.addReference(e, t.targetId, r);\n }).next(function () {\n return PersistencePromise.forEach(t.Qi, function (r) {\n return n.persistence.referenceDelegate.removeReference(e, t.targetId, r);\n });\n });\n });\n });\n\n case 4:\n _context111.next = 11;\n break;\n\n case 6:\n _context111.prev = 6;\n _context111.t0 = _context111[\"catch\"](1);\n\n if (__PRIVATE_isIndexedDbTransactionError(_context111.t0)) {\n _context111.next = 10;\n break;\n }\n\n throw _context111.t0;\n\n case 10:\n // If `notifyLocalViewChanges` fails, we did not advance the sequence\n // number for the documents that were included in this transaction.\n // This might trigger them to be deleted earlier than they otherwise\n // would have, but it should not invalidate the integrity of the data.\n __PRIVATE_logDebug(\"LocalStore\", \"Failed to update sequence numbers: \" + _context111.t0);\n\n case 11:\n _iterator98 = _createForOfIteratorHelper(t);\n\n try {\n for (_iterator98.s(); !(_step98 = _iterator98.n()).done;) {\n _e131 = _step98.value;\n _t63 = _e131.targetId;\n\n if (!_e131.fromCache) {\n _e132 = n.ns.get(_t63), _r38 = _e132.snapshotVersion, _i21 = _e132.withLastLimboFreeSnapshotVersion(_r38); // Advance the last limbo free snapshot version\n\n // Advance the last limbo free snapshot version\n n.ns = n.ns.insert(_t63, _i21);\n }\n }\n } catch (err) {\n _iterator98.e(err);\n } finally {\n _iterator98.f();\n }\n\n case 13:\n case \"end\":\n return _context111.stop();\n }\n }\n }, _callee111, null, [[1, 6]]);\n }));\n\n function __PRIVATE_localStoreNotifyLocalViewChanges(_x147, _x148) {\n return _PRIVATE_localStoreNotifyLocalViewChanges.apply(this, arguments);\n }\n\n return __PRIVATE_localStoreNotifyLocalViewChanges;\n }()(r.localStore, s);\n\n case 9:\n case \"end\":\n return _context112.stop();\n }\n }\n }, _callee112);\n }));\n return _PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineHandleCredentialChange(_x83, _x84) {\n return _PRIVATE_syncEngineHandleCredentialChange.apply(this, arguments);\n}\n\nfunction _PRIVATE_syncEngineHandleCredentialChange() {\n _PRIVATE_syncEngineHandleCredentialChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee113(e, t) {\n var n, _e133;\n\n return _regeneratorRuntime.wrap(function _callee113$(_context113) {\n while (1) {\n switch (_context113.prev = _context113.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n\n if (n.currentUser.isEqual(t)) {\n _context113.next = 11;\n break;\n }\n\n __PRIVATE_logDebug(\"SyncEngine\", \"User change. New user:\", t.toKey());\n\n _context113.next = 5;\n return __PRIVATE_localStoreHandleUserChange(n.localStore, t);\n\n case 5:\n _e133 = _context113.sent;\n n.currentUser = t;\n\n // Fails tasks waiting for pending writes requested by previous user.\n (function __PRIVATE_rejectOutstandingPendingWritesCallbacks(e, t) {\n e.Ca.forEach(function (e) {\n e.forEach(function (e) {\n e.reject(new FirestoreError(D.CANCELLED, t));\n });\n }), e.Ca.clear();\n })(n, \"'waitForPendingWrites' promise is rejected due to a user change.\");\n\n // TODO(b/114226417): Consider calling this only in the primary tab.\n n.sharedClientState.handleUserChange(t, _e133.removedBatchIds, _e133.addedBatchIds);\n _context113.next = 11;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, _e133.us);\n\n case 11:\n case \"end\":\n return _context113.stop();\n }\n }\n }, _callee113);\n }));\n return _PRIVATE_syncEngineHandleCredentialChange.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = n.Sa.get(t);\n\n if (r && r.ma) return __PRIVATE_documentKeySet().add(r.key);\n {\n var _e100 = __PRIVATE_documentKeySet();\n\n var _r25 = n.pa.get(t);\n\n if (!_r25) return _e100;\n\n var _iterator74 = _createForOfIteratorHelper(_r25),\n _step74;\n\n try {\n for (_iterator74.s(); !(_step74 = _iterator74.n()).done;) {\n var _t48 = _step74.value;\n\n var _r26 = n.ga.get(_t48);\n\n _e100 = _e100.unionWith(_r26.view.la);\n }\n } catch (err) {\n _iterator74.e(err);\n } finally {\n _iterator74.f();\n }\n\n return _e100;\n }\n}\n/**\n * Reconcile the list of synced documents in an existing view with those\n * from persistence.\n */\n\n\nfunction __PRIVATE_synchronizeViewAndComputeSnapshot(_x85, _x86) {\n return _PRIVATE_synchronizeViewAndComputeSnapshot.apply(this, arguments);\n}\n/**\n * Retrieves newly changed documents from remote document cache and raises\n * snapshots if needed.\n */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction _PRIVATE_synchronizeViewAndComputeSnapshot() {\n _PRIVATE_synchronizeViewAndComputeSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee114(e, t) {\n var n, r, i;\n return _regeneratorRuntime.wrap(function _callee114$(_context114) {\n while (1) {\n switch (_context114.prev = _context114.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n _context114.next = 3;\n return __PRIVATE_localStoreExecuteQuery(n.localStore, t.query,\n /* usePreviousResults= */\n !0);\n\n case 3:\n r = _context114.sent;\n i = t.view.Ra(r);\n return _context114.abrupt(\"return\", (n.isPrimaryClient && __PRIVATE_updateTrackedLimbos(n, t.targetId, i.da), i));\n\n case 6:\n case \"end\":\n return _context114.stop();\n }\n }\n }, _callee114);\n }));\n return _PRIVATE_synchronizeViewAndComputeSnapshot.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineSynchronizeWithChangedDocuments(_x87, _x88) {\n return _PRIVATE_syncEngineSynchronizeWithChangedDocuments.apply(this, arguments);\n}\n/** Applies a mutation state to an existing batch. */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction _PRIVATE_syncEngineSynchronizeWithChangedDocuments() {\n _PRIVATE_syncEngineSynchronizeWithChangedDocuments = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee115(e, t) {\n var n;\n return _regeneratorRuntime.wrap(function _callee115$(_context115) {\n while (1) {\n switch (_context115.prev = _context115.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n return _context115.abrupt(\"return\", __PRIVATE_localStoreGetNewDocumentChanges(n.localStore, t).then(function (e) {\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(n, e);\n }));\n\n case 2:\n case \"end\":\n return _context115.stop();\n }\n }\n }, _callee115);\n }));\n return _PRIVATE_syncEngineSynchronizeWithChangedDocuments.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineApplyBatchState(_x89, _x90, _x91, _x92) {\n return _PRIVATE_syncEngineApplyBatchState.apply(this, arguments);\n}\n/** Applies a query target change from a different tab. */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction _PRIVATE_syncEngineApplyBatchState() {\n _PRIVATE_syncEngineApplyBatchState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee116(e, t, n, r) {\n var i, s;\n return _regeneratorRuntime.wrap(function _callee116$(_context116) {\n while (1) {\n switch (_context116.prev = _context116.next) {\n case 0:\n i = __PRIVATE_debugCast(e);\n _context116.next = 3;\n return function __PRIVATE_localStoreLookupMutationDocuments(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = __PRIVATE_debugCast(n.mutationQueue);\n\n return n.persistence.runTransaction(\"Lookup mutation documents\", \"readonly\", function (e) {\n return r.vn(e, t).next(function (t) {\n return t ? n.localDocuments.getDocuments(e, t) : PersistencePromise.resolve(null);\n });\n });\n } // PORTING NOTE: Multi-Tab only.\n (i.localStore, t);\n\n case 3:\n s = _context116.sent;\n\n if (!(null !== s)) {\n _context116.next = 15;\n break;\n }\n\n if (!(\"pending\" === n)) {\n _context116.next = 10;\n break;\n }\n\n _context116.next = 8;\n return __PRIVATE_fillWritePipeline(i.remoteStore);\n\n case 8:\n _context116.next = 11;\n break;\n\n case 10:\n \"acknowledged\" === n || \"rejected\" === n ? ( // NOTE: Both these methods are no-ops for batches that originated from\n // other clients.\n __PRIVATE_processUserCallback(i, t, r || null), __PRIVATE_triggerPendingWritesCallbacks(i, t), function __PRIVATE_localStoreRemoveCachedMutationBatchMetadata(e, t) {\n __PRIVATE_debugCast(__PRIVATE_debugCast(e).mutationQueue).Mn(t);\n } // PORTING NOTE: Multi-Tab only.\n (i.localStore, t)) : fail();\n\n case 11:\n _context116.next = 13;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(i, s);\n\n case 13:\n _context116.next = 16;\n break;\n\n case 15:\n // A throttled tab may not have seen the mutation before it was completed\n // and removed from the mutation queue, in which case we won't have cached\n // the affected documents. In this case we can safely ignore the update\n // since that means we didn't apply the mutation locally at all (if we\n // had, we would have cached the affected documents), and so we will just\n // see any resulting document changes via normal remote document updates\n // as applicable.\n __PRIVATE_logDebug(\"SyncEngine\", \"Cannot apply mutation batch with id: \" + t);\n\n case 16:\n case \"end\":\n return _context116.stop();\n }\n }\n }, _callee116);\n }));\n return _PRIVATE_syncEngineApplyBatchState.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineApplyPrimaryState(_x93, _x94) {\n return _PRIVATE_syncEngineApplyPrimaryState.apply(this, arguments);\n}\n\nfunction _PRIVATE_syncEngineApplyPrimaryState() {\n _PRIVATE_syncEngineApplyPrimaryState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee117(e, t) {\n var n, _e134, _t64, _iterator99, _step99, _e135, _e136, _t65;\n\n return _regeneratorRuntime.wrap(function _callee117$(_context117) {\n while (1) {\n switch (_context117.prev = _context117.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n\n if (!(__PRIVATE_ensureWatchCallbacks(n), __PRIVATE_syncEngineEnsureWriteCallbacks(n), !0 === t && !0 !== n.Fa)) {\n _context117.next = 13;\n break;\n }\n\n _e134 = n.sharedClientState.getAllActiveQueryTargets();\n _context117.next = 5;\n return __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(n, _e134.toArray());\n\n case 5:\n _t64 = _context117.sent;\n n.Fa = !0;\n _context117.next = 9;\n return __PRIVATE_remoteStoreApplyPrimaryState(n.remoteStore, !0);\n\n case 9:\n _iterator99 = _createForOfIteratorHelper(_t64);\n\n try {\n for (_iterator99.s(); !(_step99 = _iterator99.n()).done;) {\n _e135 = _step99.value;\n\n __PRIVATE_remoteStoreListen(n.remoteStore, _e135);\n }\n } catch (err) {\n _iterator99.e(err);\n } finally {\n _iterator99.f();\n }\n\n _context117.next = 25;\n break;\n\n case 13:\n if (!(!1 === t && !1 !== n.Fa)) {\n _context117.next = 25;\n break;\n }\n\n _e136 = [];\n _t65 = Promise.resolve();\n n.pa.forEach(function (r, i) {\n n.sharedClientState.isLocalQueryTarget(i) ? _e136.push(i) : _t65 = _t65.then(function () {\n return __PRIVATE_removeAndCleanupTarget(n, i), __PRIVATE_localStoreReleaseTarget(n.localStore, i,\n /*keepPersistedTargetData=*/\n !0);\n }), __PRIVATE_remoteStoreUnlisten(n.remoteStore, i);\n });\n _context117.next = 19;\n return _t65;\n\n case 19:\n _context117.next = 21;\n return __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(n, _e136);\n\n case 21:\n // PORTING NOTE: Multi-Tab only.\n (function __PRIVATE_resetLimboDocuments(e) {\n var t = __PRIVATE_debugCast(e);\n\n t.Sa.forEach(function (e, n) {\n __PRIVATE_remoteStoreUnlisten(t.remoteStore, n);\n }), t.ba.mr(), t.Sa = new Map(), t.wa = new SortedMap(DocumentKey.comparator);\n }\n /**\n * Reconcile the query views of the provided query targets with the state from\n * persistence. Raises snapshots for any changes that affect the local\n * client and returns the updated state of all target's query data.\n *\n * @param syncEngine - The sync engine implementation\n * @param targets - the list of targets with views that need to be recomputed\n * @param transitionToPrimary - `true` iff the tab transitions from a secondary\n * tab to a primary tab\n */\n // PORTING NOTE: Multi-Tab only.\n )(n);\n\n n.Fa = !1;\n _context117.next = 25;\n return __PRIVATE_remoteStoreApplyPrimaryState(n.remoteStore, !1);\n\n case 25:\n case \"end\":\n return _context117.stop();\n }\n }\n }, _callee117);\n }));\n return _PRIVATE_syncEngineApplyPrimaryState.apply(this, arguments);\n}\n\nfunction __PRIVATE_synchronizeQueryViewsAndRaiseSnapshots(_x95, _x96, _x97) {\n return _PRIVATE_synchronizeQueryViewsAndRaiseSnapshots.apply(this, arguments);\n}\n/**\n * Creates a `Query` object from the specified `Target`. There is no way to\n * obtain the original `Query`, so we synthesize a `Query` from the `Target`\n * object.\n *\n * The synthesized result might be different from the original `Query`, but\n * since the synthesized `Query` should return the same results as the\n * original one (only the presentation of results might differ), the potential\n * difference will not cause issues.\n */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction _PRIVATE_synchronizeQueryViewsAndRaiseSnapshots() {\n _PRIVATE_synchronizeQueryViewsAndRaiseSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee118(e, t, n) {\n var r, i, s, _iterator100, _step100, _e137, _t66, _n42, _iterator101, _step101, _e138, _t67, _n43, _n44;\n\n return _regeneratorRuntime.wrap(function _callee118$(_context118) {\n while (1) {\n switch (_context118.prev = _context118.next) {\n case 0:\n r = __PRIVATE_debugCast(e), i = [], s = [];\n _iterator100 = _createForOfIteratorHelper(t);\n _context118.prev = 2;\n\n _iterator100.s();\n\n case 4:\n if ((_step100 = _iterator100.n()).done) {\n _context118.next = 45;\n break;\n }\n\n _e137 = _step100.value;\n _t66 = void 0;\n _n42 = r.pa.get(_e137);\n\n if (!(_n42 && 0 !== _n42.length)) {\n _context118.next = 34;\n break;\n }\n\n _context118.next = 11;\n return __PRIVATE_localStoreAllocateTarget(r.localStore, __PRIVATE_queryToTarget(_n42[0]));\n\n case 11:\n _t66 = _context118.sent;\n _iterator101 = _createForOfIteratorHelper(_n42);\n _context118.prev = 13;\n\n _iterator101.s();\n\n case 15:\n if ((_step101 = _iterator101.n()).done) {\n _context118.next = 24;\n break;\n }\n\n _e138 = _step101.value;\n _t67 = r.ga.get(_e138);\n _context118.next = 20;\n return __PRIVATE_synchronizeViewAndComputeSnapshot(r, _t67);\n\n case 20:\n _n43 = _context118.sent;\n _n43.snapshot && s.push(_n43.snapshot);\n\n case 22:\n _context118.next = 15;\n break;\n\n case 24:\n _context118.next = 29;\n break;\n\n case 26:\n _context118.prev = 26;\n _context118.t0 = _context118[\"catch\"](13);\n\n _iterator101.e(_context118.t0);\n\n case 29:\n _context118.prev = 29;\n\n _iterator101.f();\n\n return _context118.finish(29);\n\n case 32:\n _context118.next = 42;\n break;\n\n case 34:\n _context118.next = 36;\n return __PRIVATE_localStoreGetCachedTarget(r.localStore, _e137);\n\n case 36:\n _n44 = _context118.sent;\n _context118.next = 39;\n return __PRIVATE_localStoreAllocateTarget(r.localStore, _n44);\n\n case 39:\n _t66 = _context118.sent;\n _context118.next = 42;\n return __PRIVATE_initializeViewAndComputeSnapshot(r, __PRIVATE_synthesizeTargetToQuery(_n44), _e137,\n /*current=*/\n !1, _t66.resumeToken);\n\n case 42:\n i.push(_t66);\n\n case 43:\n _context118.next = 4;\n break;\n\n case 45:\n _context118.next = 50;\n break;\n\n case 47:\n _context118.prev = 47;\n _context118.t1 = _context118[\"catch\"](2);\n\n _iterator100.e(_context118.t1);\n\n case 50:\n _context118.prev = 50;\n\n _iterator100.f();\n\n return _context118.finish(50);\n\n case 53:\n return _context118.abrupt(\"return\", (r.fa.u_(s), i));\n\n case 54:\n case \"end\":\n return _context118.stop();\n }\n }\n }, _callee118, null, [[2, 47, 50, 53], [13, 26, 29, 32]]);\n }));\n return _PRIVATE_synchronizeQueryViewsAndRaiseSnapshots.apply(this, arguments);\n}\n\nfunction __PRIVATE_synthesizeTargetToQuery(e) {\n return __PRIVATE_newQuery(e.path, e.collectionGroup, e.orderBy, e.filters, e.limit, \"F\"\n /* LimitType.First */\n , e.startAt, e.endAt);\n}\n/** Returns the IDs of the clients that are currently active. */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction __PRIVATE_syncEngineGetActiveClients(e) {\n return function __PRIVATE_localStoreGetActiveClients(e) {\n return __PRIVATE_debugCast(__PRIVATE_debugCast(e).persistence).Li();\n }(__PRIVATE_debugCast(e).localStore);\n}\n/** Applies a query target change from a different tab. */\n// PORTING NOTE: Multi-Tab only.\n\n\nfunction __PRIVATE_syncEngineApplyTargetState(_x98, _x99, _x100, _x101) {\n return _PRIVATE_syncEngineApplyTargetState.apply(this, arguments);\n}\n/** Adds or removes Watch targets for queries from different tabs. */\n\n\nfunction _PRIVATE_syncEngineApplyTargetState() {\n _PRIVATE_syncEngineApplyTargetState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee119(e, t, n, r) {\n var i, s, _e139, _r39;\n\n return _regeneratorRuntime.wrap(function _callee119$(_context119) {\n while (1) {\n switch (_context119.prev = _context119.next) {\n case 0:\n i = __PRIVATE_debugCast(e);\n\n if (!i.Fa) {\n _context119.next = 3;\n break;\n }\n\n return _context119.abrupt(\"return\", void __PRIVATE_logDebug(\"SyncEngine\", \"Ignoring unexpected query state notification.\"));\n\n case 3:\n s = i.pa.get(t);\n\n if (!(s && s.length > 0)) {\n _context119.next = 20;\n break;\n }\n\n _context119.t0 = n;\n _context119.next = _context119.t0 === \"current\" ? 8 : _context119.t0 === \"not-current\" ? 8 : _context119.t0 === \"rejected\" ? 15 : 19;\n break;\n\n case 8:\n _context119.next = 10;\n return __PRIVATE_localStoreGetNewDocumentChanges(i.localStore, __PRIVATE_queryCollectionGroup(s[0]));\n\n case 10:\n _e139 = _context119.sent;\n _r39 = RemoteEvent.createSynthesizedRemoteEventForCurrentChange(t, \"current\" === n, ByteString.EMPTY_BYTE_STRING);\n _context119.next = 14;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(i, _e139, _r39);\n\n case 14:\n return _context119.abrupt(\"break\", 20);\n\n case 15:\n _context119.next = 17;\n return __PRIVATE_localStoreReleaseTarget(i.localStore, t,\n /* keepPersistedTargetData */\n !0);\n\n case 17:\n __PRIVATE_removeAndCleanupTarget(i, t, r);\n\n return _context119.abrupt(\"break\", 20);\n\n case 19:\n fail();\n\n case 20:\n case \"end\":\n return _context119.stop();\n }\n }\n }, _callee119);\n }));\n return _PRIVATE_syncEngineApplyTargetState.apply(this, arguments);\n}\n\nfunction __PRIVATE_syncEngineApplyActiveTargetsChange(_x102, _x103, _x104) {\n return _PRIVATE_syncEngineApplyActiveTargetsChange.apply(this, arguments);\n}\n\nfunction _PRIVATE_syncEngineApplyActiveTargetsChange() {\n _PRIVATE_syncEngineApplyActiveTargetsChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee120(e, t, n) {\n var r, _iterator102, _step102, _e140, _t68, _n45, _iterator103, _step103, _loop8;\n\n return _regeneratorRuntime.wrap(function _callee120$(_context121) {\n while (1) {\n switch (_context121.prev = _context121.next) {\n case 0:\n r = __PRIVATE_ensureWatchCallbacks(e);\n\n if (!r.Fa) {\n _context121.next = 45;\n break;\n }\n\n _iterator102 = _createForOfIteratorHelper(t);\n _context121.prev = 3;\n\n _iterator102.s();\n\n case 5:\n if ((_step102 = _iterator102.n()).done) {\n _context121.next = 21;\n break;\n }\n\n _e140 = _step102.value;\n\n if (!r.pa.has(_e140)) {\n _context121.next = 10;\n break;\n }\n\n // A target might have been added in a previous attempt\n __PRIVATE_logDebug(\"SyncEngine\", \"Adding an already active target \" + _e140);\n\n return _context121.abrupt(\"continue\", 19);\n\n case 10:\n _context121.next = 12;\n return __PRIVATE_localStoreGetCachedTarget(r.localStore, _e140);\n\n case 12:\n _t68 = _context121.sent;\n _context121.next = 15;\n return __PRIVATE_localStoreAllocateTarget(r.localStore, _t68);\n\n case 15:\n _n45 = _context121.sent;\n _context121.next = 18;\n return __PRIVATE_initializeViewAndComputeSnapshot(r, __PRIVATE_synthesizeTargetToQuery(_t68), _n45.targetId,\n /*current=*/\n !1, _n45.resumeToken);\n\n case 18:\n __PRIVATE_remoteStoreListen(r.remoteStore, _n45);\n\n case 19:\n _context121.next = 5;\n break;\n\n case 21:\n _context121.next = 26;\n break;\n\n case 23:\n _context121.prev = 23;\n _context121.t0 = _context121[\"catch\"](3);\n\n _iterator102.e(_context121.t0);\n\n case 26:\n _context121.prev = 26;\n\n _iterator102.f();\n\n return _context121.finish(26);\n\n case 29:\n _iterator103 = _createForOfIteratorHelper(n);\n _context121.prev = 30;\n _loop8 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop8() {\n var e;\n return _regeneratorRuntime.wrap(function _loop8$(_context120) {\n while (1) {\n switch (_context120.prev = _context120.next) {\n case 0:\n e = _step103.value;\n _context120.t0 = r.pa.has(e);\n\n if (!_context120.t0) {\n _context120.next = 5;\n break;\n }\n\n _context120.next = 5;\n return __PRIVATE_localStoreReleaseTarget(r.localStore, e,\n /* keepPersistedTargetData */\n !1).then(function () {\n __PRIVATE_remoteStoreUnlisten(r.remoteStore, e), __PRIVATE_removeAndCleanupTarget(r, e);\n }).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);\n\n case 5:\n case \"end\":\n return _context120.stop();\n }\n }\n }, _loop8);\n });\n\n _iterator103.s();\n\n case 33:\n if ((_step103 = _iterator103.n()).done) {\n _context121.next = 37;\n break;\n }\n\n return _context121.delegateYield(_loop8(), \"t1\", 35);\n\n case 35:\n _context121.next = 33;\n break;\n\n case 37:\n _context121.next = 42;\n break;\n\n case 39:\n _context121.prev = 39;\n _context121.t2 = _context121[\"catch\"](30);\n\n _iterator103.e(_context121.t2);\n\n case 42:\n _context121.prev = 42;\n\n _iterator103.f();\n\n return _context121.finish(42);\n\n case 45:\n case \"end\":\n return _context121.stop();\n }\n }\n }, _callee120, null, [[3, 23, 26, 29], [30, 39, 42, 45]]);\n }));\n return _PRIVATE_syncEngineApplyActiveTargetsChange.apply(this, arguments);\n}\n\nfunction __PRIVATE_ensureWatchCallbacks(e) {\n var t = __PRIVATE_debugCast(e);\n\n return t.remoteStore.remoteSyncer.applyRemoteEvent = __PRIVATE_syncEngineApplyRemoteEvent.bind(null, t), t.remoteStore.remoteSyncer.getRemoteKeysForTarget = __PRIVATE_syncEngineGetRemoteKeysForTarget.bind(null, t), t.remoteStore.remoteSyncer.rejectListen = __PRIVATE_syncEngineRejectListen.bind(null, t), t.fa.u_ = __PRIVATE_eventManagerOnWatchChange.bind(null, t.eventManager), t.fa.xa = __PRIVATE_eventManagerOnWatchError.bind(null, t.eventManager), t;\n}\n\nfunction __PRIVATE_syncEngineEnsureWriteCallbacks(e) {\n var t = __PRIVATE_debugCast(e);\n\n return t.remoteStore.remoteSyncer.applySuccessfulWrite = __PRIVATE_syncEngineApplySuccessfulWrite.bind(null, t), t.remoteStore.remoteSyncer.rejectFailedWrite = __PRIVATE_syncEngineRejectFailedWrite.bind(null, t), t;\n}\n/**\n * Loads a Firestore bundle into the SDK. The returned promise resolves when\n * the bundle finished loading.\n *\n * @param syncEngine - SyncEngine to use.\n * @param bundleReader - Bundle to load into the SDK.\n * @param task - LoadBundleTask used to update the loading progress to public API.\n */\n\n\nfunction __PRIVATE_syncEngineLoadBundle(e, t, n) {\n var r = __PRIVATE_debugCast(e); // eslint-disable-next-line @typescript-eslint/no-floating-promises\n\n\n /** Loads a bundle and returns the list of affected collection groups. */\n (function () {\n var _PRIVATE_loadBundleImpl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(e, t, n) {\n var _r27, i, s, _e101, o;\n\n return _regeneratorRuntime.wrap(function _callee25$(_context25) {\n while (1) {\n switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n _context25.next = 3;\n return t.getMetadata();\n\n case 3:\n _r27 = _context25.sent;\n _context25.next = 6;\n return function __PRIVATE_localStoreHasNewerBundle(e, t) {\n var n = __PRIVATE_debugCast(e),\n r = __PRIVATE_fromVersion(t.createTime);\n\n return n.persistence.runTransaction(\"hasNewerBundle\", \"readonly\", function (e) {\n return n.$r.getBundleMetadata(e, t.id);\n }).then(function (e) {\n return !!e && e.createTime.compareTo(r) >= 0;\n });\n }\n /**\n * Saves the given `BundleMetadata` to local persistence.\n */\n (e.localStore, _r27);\n\n case 6:\n if (!_context25.sent) {\n _context25.next = 11;\n break;\n }\n\n _context25.next = 9;\n return t.close();\n\n case 9:\n n._completeWith(function __PRIVATE_bundleSuccessProgress(e) {\n return {\n taskState: \"Success\",\n documentsLoaded: e.totalDocuments,\n bytesLoaded: e.totalBytes,\n totalDocuments: e.totalDocuments,\n totalBytes: e.totalBytes\n };\n }(_r27));\n\n return _context25.abrupt(\"return\", Promise.resolve(new Set()));\n\n case 11:\n n._updateProgress(__PRIVATE_bundleInitialProgress(_r27));\n\n i = new __PRIVATE_BundleLoader(_r27, e.localStore, t.serializer);\n _context25.next = 15;\n return t.Oa();\n\n case 15:\n s = _context25.sent;\n\n case 16:\n if (!s) {\n _context25.next = 26;\n break;\n }\n\n _context25.next = 19;\n return i.na(s);\n\n case 19:\n _e101 = _context25.sent;\n _e101 && n._updateProgress(_e101);\n _context25.next = 23;\n return t.Oa();\n\n case 23:\n s = _context25.sent;\n\n case 24:\n _context25.next = 16;\n break;\n\n case 26:\n _context25.next = 28;\n return i.complete();\n\n case 28:\n o = _context25.sent;\n _context25.next = 31;\n return __PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore(e, o.sa,\n /* remoteEvent */\n void 0);\n\n case 31:\n _context25.next = 33;\n return function __PRIVATE_localStoreSaveBundle(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return n.persistence.runTransaction(\"Save bundle\", \"readwrite\", function (e) {\n return n.$r.saveBundleMetadata(e, t);\n });\n }\n /**\n * Returns a promise of a `NamedQuery` associated with given query name. Promise\n * resolves to undefined if no persisted data can be found.\n */\n (e.localStore, _r27);\n\n case 33:\n n._completeWith(o.progress);\n\n return _context25.abrupt(\"return\", Promise.resolve(o.ia));\n\n case 37:\n _context25.prev = 37;\n _context25.t0 = _context25[\"catch\"](0);\n return _context25.abrupt(\"return\", (__PRIVATE_logWarn(\"SyncEngine\", \"Loading bundle failed with \".concat(_context25.t0)), n._failWith(_context25.t0), Promise.resolve(new Set())));\n\n case 40:\n case \"end\":\n return _context25.stop();\n }\n }\n }, _callee25, null, [[0, 37]]);\n }));\n\n function __PRIVATE_loadBundleImpl(_x105, _x106, _x107) {\n return _PRIVATE_loadBundleImpl.apply(this, arguments);\n }\n\n return __PRIVATE_loadBundleImpl;\n })()\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n /**\n * Provides all components needed for Firestore with in-memory persistence.\n * Uses EagerGC garbage collection.\n */\n (r, t, n).then(function (e) {\n r.sharedClientState.notifyBundleLoaded(e);\n });\n}\n\nvar MemoryOfflineComponentProvider = /*#__PURE__*/function () {\n function MemoryOfflineComponentProvider() {\n _classCallCheck(this, MemoryOfflineComponentProvider);\n\n this.synchronizeTabs = !1;\n }\n\n _createClass(MemoryOfflineComponentProvider, [{\n key: \"initialize\",\n value: function () {\n var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(e) {\n return _regeneratorRuntime.wrap(function _callee26$(_context26) {\n while (1) {\n switch (_context26.prev = _context26.next) {\n case 0:\n this.serializer = __PRIVATE_newSerializer(e.databaseInfo.databaseId);\n this.sharedClientState = this.createSharedClientState(e);\n this.persistence = this.createPersistence(e);\n _context26.next = 5;\n return this.persistence.start();\n\n case 5:\n this.localStore = this.createLocalStore(e);\n this.gcScheduler = this.createGarbageCollectionScheduler(e, this.localStore);\n this.indexBackfillerScheduler = this.createIndexBackfillerScheduler(e, this.localStore);\n\n case 8:\n case \"end\":\n return _context26.stop();\n }\n }\n }, _callee26, this);\n }));\n\n function initialize(_x108) {\n return _initialize.apply(this, arguments);\n }\n\n return initialize;\n }()\n }, {\n key: \"createGarbageCollectionScheduler\",\n value: function createGarbageCollectionScheduler(e, t) {\n return null;\n }\n }, {\n key: \"createIndexBackfillerScheduler\",\n value: function createIndexBackfillerScheduler(e, t) {\n return null;\n }\n }, {\n key: \"createLocalStore\",\n value: function createLocalStore(e) {\n return __PRIVATE_newLocalStore(this.persistence, new __PRIVATE_QueryEngine(), e.initialUser, this.serializer);\n }\n }, {\n key: \"createPersistence\",\n value: function createPersistence(e) {\n return new __PRIVATE_MemoryPersistence(__PRIVATE_MemoryEagerDelegate.Hr, this.serializer);\n }\n }, {\n key: \"createSharedClientState\",\n value: function createSharedClientState(e) {\n return new __PRIVATE_MemorySharedClientState();\n }\n }, {\n key: \"terminate\",\n value: function () {\n var _terminate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {\n var e, t;\n return _regeneratorRuntime.wrap(function _callee27$(_context27) {\n while (1) {\n switch (_context27.prev = _context27.next) {\n case 0:\n null === (e = this.gcScheduler) || void 0 === e || e.stop();\n null === (t = this.indexBackfillerScheduler) || void 0 === t || t.stop();\n this.sharedClientState.shutdown();\n _context27.next = 5;\n return this.persistence.shutdown();\n\n case 5:\n case \"end\":\n return _context27.stop();\n }\n }\n }, _callee27, this);\n }));\n\n function terminate() {\n return _terminate.apply(this, arguments);\n }\n\n return terminate;\n }()\n }]);\n\n return MemoryOfflineComponentProvider;\n}();\n\nvar __PRIVATE_LruGcMemoryOfflineComponentProvider = /*#__PURE__*/function (_MemoryOfflineCompone) {\n _inherits(__PRIVATE_LruGcMemoryOfflineComponentProvider, _MemoryOfflineCompone);\n\n var _super32 = _createSuper(__PRIVATE_LruGcMemoryOfflineComponentProvider);\n\n function __PRIVATE_LruGcMemoryOfflineComponentProvider(e) {\n var _this183;\n\n _classCallCheck(this, __PRIVATE_LruGcMemoryOfflineComponentProvider);\n\n _this183 = _super32.call(this), _this183.cacheSizeBytes = e;\n return _this183;\n }\n\n _createClass(__PRIVATE_LruGcMemoryOfflineComponentProvider, [{\n key: \"createGarbageCollectionScheduler\",\n value: function createGarbageCollectionScheduler(e, t) {\n __PRIVATE_hardAssert(this.persistence.referenceDelegate instanceof __PRIVATE_MemoryLruDelegate);\n\n var n = this.persistence.referenceDelegate.garbageCollector;\n return new __PRIVATE_LruScheduler(n, e.asyncQueue, t);\n }\n }, {\n key: \"createPersistence\",\n value: function createPersistence(e) {\n var t = void 0 !== this.cacheSizeBytes ? LruParams.withCacheSize(this.cacheSizeBytes) : LruParams.DEFAULT;\n return new __PRIVATE_MemoryPersistence(function (e) {\n return __PRIVATE_MemoryLruDelegate.Hr(e, t);\n }, this.serializer);\n }\n }]);\n\n return __PRIVATE_LruGcMemoryOfflineComponentProvider;\n}(MemoryOfflineComponentProvider);\n/**\n * Provides all components needed for Firestore with IndexedDB persistence.\n */\n\n\nvar __PRIVATE_IndexedDbOfflineComponentProvider = /*#__PURE__*/function (_MemoryOfflineCompone2) {\n _inherits(__PRIVATE_IndexedDbOfflineComponentProvider, _MemoryOfflineCompone2);\n\n var _super33 = _createSuper(__PRIVATE_IndexedDbOfflineComponentProvider);\n\n function __PRIVATE_IndexedDbOfflineComponentProvider(e, t, n) {\n var _this184;\n\n _classCallCheck(this, __PRIVATE_IndexedDbOfflineComponentProvider);\n\n _this184 = _super33.call(this), _this184.Na = e, _this184.cacheSizeBytes = t, _this184.forceOwnership = n, _this184.synchronizeTabs = !1;\n return _this184;\n }\n\n _createClass(__PRIVATE_IndexedDbOfflineComponentProvider, [{\n key: \"initialize\",\n value: function () {\n var _initialize2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(e) {\n var _this185 = this;\n\n return _regeneratorRuntime.wrap(function _callee28$(_context28) {\n while (1) {\n switch (_context28.prev = _context28.next) {\n case 0:\n _context28.next = 2;\n return _get(_getPrototypeOf(__PRIVATE_IndexedDbOfflineComponentProvider.prototype), \"initialize\", this).call(this, e);\n\n case 2:\n _context28.next = 4;\n return this.Na.initialize(this, e);\n\n case 4:\n _context28.next = 6;\n return __PRIVATE_syncEngineEnsureWriteCallbacks(this.Na.syncEngine);\n\n case 6:\n _context28.next = 8;\n return __PRIVATE_fillWritePipeline(this.Na.remoteStore);\n\n case 8:\n _context28.next = 10;\n return this.persistence.fi(function () {\n return _this185.gcScheduler && !_this185.gcScheduler.started && _this185.gcScheduler.start(), _this185.indexBackfillerScheduler && !_this185.indexBackfillerScheduler.started && _this185.indexBackfillerScheduler.start(), Promise.resolve();\n });\n\n case 10:\n case \"end\":\n return _context28.stop();\n }\n }\n }, _callee28, this);\n }));\n\n function initialize(_x109) {\n return _initialize2.apply(this, arguments);\n }\n\n return initialize;\n }()\n }, {\n key: \"createLocalStore\",\n value: function createLocalStore(e) {\n return __PRIVATE_newLocalStore(this.persistence, new __PRIVATE_QueryEngine(), e.initialUser, this.serializer);\n }\n }, {\n key: \"createGarbageCollectionScheduler\",\n value: function createGarbageCollectionScheduler(e, t) {\n var n = this.persistence.referenceDelegate.garbageCollector;\n return new __PRIVATE_LruScheduler(n, e.asyncQueue, t);\n }\n }, {\n key: \"createIndexBackfillerScheduler\",\n value: function createIndexBackfillerScheduler(e, t) {\n var n = new __PRIVATE_IndexBackfiller(t, this.persistence);\n return new __PRIVATE_IndexBackfillerScheduler(e.asyncQueue, n);\n }\n }, {\n key: \"createPersistence\",\n value: function createPersistence(e) {\n var t = __PRIVATE_indexedDbStoragePrefix(e.databaseInfo.databaseId, e.databaseInfo.persistenceKey),\n n = void 0 !== this.cacheSizeBytes ? LruParams.withCacheSize(this.cacheSizeBytes) : LruParams.DEFAULT;\n\n return new __PRIVATE_IndexedDbPersistence(this.synchronizeTabs, t, e.clientId, n, e.asyncQueue, __PRIVATE_getWindow(), getDocument(), this.serializer, this.sharedClientState, !!this.forceOwnership);\n }\n }, {\n key: \"createSharedClientState\",\n value: function createSharedClientState(e) {\n return new __PRIVATE_MemorySharedClientState();\n }\n }]);\n\n return __PRIVATE_IndexedDbOfflineComponentProvider;\n}(MemoryOfflineComponentProvider);\n/**\n * Provides all components needed for Firestore with multi-tab IndexedDB\n * persistence.\n *\n * In the legacy client, this provider is used to provide both multi-tab and\n * non-multi-tab persistence since we cannot tell at build time whether\n * `synchronizeTabs` will be enabled.\n */\n\n\nvar __PRIVATE_MultiTabOfflineComponentProvider = /*#__PURE__*/function (_PRIVATE_IndexedDbOf) {\n _inherits(__PRIVATE_MultiTabOfflineComponentProvider, _PRIVATE_IndexedDbOf);\n\n var _super34 = _createSuper(__PRIVATE_MultiTabOfflineComponentProvider);\n\n function __PRIVATE_MultiTabOfflineComponentProvider(e, t) {\n var _this186;\n\n _classCallCheck(this, __PRIVATE_MultiTabOfflineComponentProvider);\n\n _this186 = _super34.call(this, e, t,\n /* forceOwnership= */\n !1), _this186.Na = e, _this186.cacheSizeBytes = t, _this186.synchronizeTabs = !0;\n return _this186;\n }\n\n _createClass(__PRIVATE_MultiTabOfflineComponentProvider, [{\n key: \"initialize\",\n value: function () {\n var _initialize3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(e) {\n var _this187 = this;\n\n var t;\n return _regeneratorRuntime.wrap(function _callee30$(_context30) {\n while (1) {\n switch (_context30.prev = _context30.next) {\n case 0:\n _context30.next = 2;\n return _get(_getPrototypeOf(__PRIVATE_MultiTabOfflineComponentProvider.prototype), \"initialize\", this).call(this, e);\n\n case 2:\n t = this.Na.syncEngine;\n _context30.t0 = this.sharedClientState instanceof __PRIVATE_WebStorageSharedClientState;\n\n if (!_context30.t0) {\n _context30.next = 8;\n break;\n }\n\n this.sharedClientState.syncEngine = {\n Zs: __PRIVATE_syncEngineApplyBatchState.bind(null, t),\n Xs: __PRIVATE_syncEngineApplyTargetState.bind(null, t),\n eo: __PRIVATE_syncEngineApplyActiveTargetsChange.bind(null, t),\n Li: __PRIVATE_syncEngineGetActiveClients.bind(null, t),\n Ys: __PRIVATE_syncEngineSynchronizeWithChangedDocuments.bind(null, t)\n };\n _context30.next = 8;\n return this.sharedClientState.start();\n\n case 8:\n _context30.next = 10;\n return this.persistence.fi( /*#__PURE__*/function () {\n var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(e) {\n return _regeneratorRuntime.wrap(function _callee29$(_context29) {\n while (1) {\n switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return __PRIVATE_syncEngineApplyPrimaryState(_this187.Na.syncEngine, e);\n\n case 2:\n _this187.gcScheduler && (e && !_this187.gcScheduler.started ? _this187.gcScheduler.start() : e || _this187.gcScheduler.stop());\n _this187.indexBackfillerScheduler && (e && !_this187.indexBackfillerScheduler.started ? _this187.indexBackfillerScheduler.start() : e || _this187.indexBackfillerScheduler.stop());\n\n case 4:\n case \"end\":\n return _context29.stop();\n }\n }\n }, _callee29);\n }));\n\n return function (_x111) {\n return _ref32.apply(this, arguments);\n };\n }());\n\n case 10:\n case \"end\":\n return _context30.stop();\n }\n }\n }, _callee30, this);\n }));\n\n function initialize(_x110) {\n return _initialize3.apply(this, arguments);\n }\n\n return initialize;\n }()\n }, {\n key: \"createSharedClientState\",\n value: function createSharedClientState(e) {\n var t = __PRIVATE_getWindow();\n\n if (!__PRIVATE_WebStorageSharedClientState.D(t)) throw new FirestoreError(D.UNIMPLEMENTED, \"IndexedDB persistence is only available on platforms that support LocalStorage.\");\n\n var n = __PRIVATE_indexedDbStoragePrefix(e.databaseInfo.databaseId, e.databaseInfo.persistenceKey);\n\n return new __PRIVATE_WebStorageSharedClientState(t, e.asyncQueue, n, e.clientId, e.initialUser);\n }\n }]);\n\n return __PRIVATE_MultiTabOfflineComponentProvider;\n}(__PRIVATE_IndexedDbOfflineComponentProvider);\n/**\n * Initializes and wires the components that are needed to interface with the\n * network.\n */\n\n\nvar OnlineComponentProvider = /*#__PURE__*/function () {\n function OnlineComponentProvider() {\n _classCallCheck(this, OnlineComponentProvider);\n }\n\n _createClass(OnlineComponentProvider, [{\n key: \"initialize\",\n value: function () {\n var _initialize4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(e, t) {\n var _this188 = this;\n\n return _regeneratorRuntime.wrap(function _callee31$(_context31) {\n while (1) {\n switch (_context31.prev = _context31.next) {\n case 0:\n _context31.t0 = this.localStore;\n\n if (_context31.t0) {\n _context31.next = 12;\n break;\n }\n\n this.localStore = e.localStore;\n this.sharedClientState = e.sharedClientState;\n this.datastore = this.createDatastore(t);\n this.remoteStore = this.createRemoteStore(t);\n this.eventManager = this.createEventManager(t);\n this.syncEngine = this.createSyncEngine(t,\n /* startAsPrimary=*/\n !e.synchronizeTabs);\n\n this.sharedClientState.onlineStateHandler = function (e) {\n return __PRIVATE_syncEngineApplyOnlineStateChange(_this188.syncEngine, e, 1\n /* OnlineStateSource.SharedClientState */\n );\n };\n\n this.remoteStore.remoteSyncer.handleCredentialChange = __PRIVATE_syncEngineHandleCredentialChange.bind(null, this.syncEngine);\n _context31.next = 12;\n return __PRIVATE_remoteStoreApplyPrimaryState(this.remoteStore, this.syncEngine.isPrimaryClient);\n\n case 12:\n case \"end\":\n return _context31.stop();\n }\n }\n }, _callee31, this);\n }));\n\n function initialize(_x112, _x113) {\n return _initialize4.apply(this, arguments);\n }\n\n return initialize;\n }()\n }, {\n key: \"createEventManager\",\n value: function createEventManager(e) {\n return function __PRIVATE_newEventManager() {\n return new __PRIVATE_EventManagerImpl();\n }();\n }\n }, {\n key: \"createDatastore\",\n value: function createDatastore(e) {\n var t = __PRIVATE_newSerializer(e.databaseInfo.databaseId),\n n = function __PRIVATE_newConnection(e) {\n return new __PRIVATE_WebChannelConnection(e);\n }\n /** Return the Platform-specific connectivity monitor. */\n (e.databaseInfo);\n\n return function __PRIVATE_newDatastore(e, t, n, r) {\n return new __PRIVATE_DatastoreImpl(e, t, n, r);\n }(e.authCredentials, e.appCheckCredentials, n, t);\n }\n }, {\n key: \"createRemoteStore\",\n value: function createRemoteStore(e) {\n var _this189 = this;\n\n return function __PRIVATE_newRemoteStore(e, t, n, r, i) {\n return new __PRIVATE_RemoteStoreImpl(e, t, n, r, i);\n }\n /** Re-enables the network. Idempotent. */\n (this.localStore, this.datastore, e.asyncQueue, function (e) {\n return __PRIVATE_syncEngineApplyOnlineStateChange(_this189.syncEngine, e, 0\n /* OnlineStateSource.RemoteStore */\n );\n }, function __PRIVATE_newConnectivityMonitor() {\n return __PRIVATE_BrowserConnectivityMonitor.D() ? new __PRIVATE_BrowserConnectivityMonitor() : new __PRIVATE_NoopConnectivityMonitor();\n }());\n }\n }, {\n key: \"createSyncEngine\",\n value: function createSyncEngine(e, t) {\n return function __PRIVATE_newSyncEngine(e, t, n, // PORTING NOTE: Manages state synchronization in multi-tab environments.\n r, i, s, o) {\n var _ = new __PRIVATE_SyncEngineImpl(e, t, n, r, i, s);\n\n return o && (_.Fa = !0), _;\n }(this.localStore, this.remoteStore, this.eventManager, this.sharedClientState, e.initialUser, e.maxConcurrentLimboResolutions, t);\n }\n }, {\n key: \"terminate\",\n value: function () {\n var _terminate2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {\n var e;\n return _regeneratorRuntime.wrap(function _callee33$(_context33) {\n while (1) {\n switch (_context33.prev = _context33.next) {\n case 0:\n _context33.next = 2;\n return function () {\n var _PRIVATE_remoteStoreShutdown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(e) {\n var t;\n return _regeneratorRuntime.wrap(function _callee32$(_context32) {\n while (1) {\n switch (_context32.prev = _context32.next) {\n case 0:\n t = __PRIVATE_debugCast(e);\n\n __PRIVATE_logDebug(\"RemoteStore\", \"RemoteStore shutting down.\");\n\n t.v_.add(5\n /* OfflineCause.Shutdown */\n );\n _context32.next = 5;\n return __PRIVATE_disableNetworkInternal(t);\n\n case 5:\n t.M_.shutdown();\n // Set the OnlineState to Unknown (rather than Offline) to avoid potentially\n // triggering spurious listener events with cached data, etc.\n t.x_.set(\"Unknown\"\n /* OnlineState.Unknown */\n );\n\n case 7:\n case \"end\":\n return _context32.stop();\n }\n }\n }, _callee32);\n }));\n\n function __PRIVATE_remoteStoreShutdown(_x114) {\n return _PRIVATE_remoteStoreShutdown.apply(this, arguments);\n }\n\n return __PRIVATE_remoteStoreShutdown;\n }()(this.remoteStore);\n\n case 2:\n null === (e = this.datastore) || void 0 === e || e.terminate();\n\n case 3:\n case \"end\":\n return _context33.stop();\n }\n }\n }, _callee33, this);\n }));\n\n function terminate() {\n return _terminate2.apply(this, arguments);\n }\n\n return terminate;\n }()\n }]);\n\n return OnlineComponentProvider;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * How many bytes to read each time when `ReadableStreamReader.read()` is\n * called. Only applicable for byte streams that we control (e.g. those backed\n * by an UInt8Array).\n */\n\n/**\n * Builds a `ByteStreamReader` from a UInt8Array.\n * @param source - The data source to use.\n * @param bytesPerRead - How many bytes each `read()` from the returned reader\n * will read.\n */\n\n\nfunction __PRIVATE_toByteStreamReaderHelper(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10240;\n var n = 0; // The TypeScript definition for ReadableStreamReader changed. We use\n // `any` here to allow this code to compile with different versions.\n // See https://github.com/microsoft/TypeScript/issues/42970\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n read: function read() {\n return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {\n var r;\n return _regeneratorRuntime.wrap(function _callee34$(_context34) {\n while (1) {\n switch (_context34.prev = _context34.next) {\n case 0:\n if (!(n < e.byteLength)) {\n _context34.next = 3;\n break;\n }\n\n r = {\n value: e.slice(n, n + t),\n done: !1\n };\n return _context34.abrupt(\"return\", (n += t, r));\n\n case 3:\n return _context34.abrupt(\"return\", {\n done: !0\n });\n\n case 4:\n case \"end\":\n return _context34.stop();\n }\n }\n }, _callee34);\n }))();\n },\n cancel: function cancel() {\n return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35() {\n return _regeneratorRuntime.wrap(function _callee35$(_context35) {\n while (1) {\n switch (_context35.prev = _context35.next) {\n case 0:\n case \"end\":\n return _context35.stop();\n }\n }\n }, _callee35);\n }))();\n },\n releaseLock: function releaseLock() {},\n closed: Promise.resolve()\n };\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * On web, a `ReadableStream` is wrapped around by a `ByteStreamReader`.\n */\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * A wrapper implementation of Observer that will dispatch events\n * asynchronously. To allow immediate silencing, a mute call is added which\n * causes events scheduled to no longer be raised.\n */\n\n\nvar __PRIVATE_AsyncObserver = /*#__PURE__*/function () {\n function __PRIVATE_AsyncObserver(e) {\n _classCallCheck(this, __PRIVATE_AsyncObserver);\n\n this.observer = e,\n /**\n * When set to true, will not raise future events. Necessary to deal with\n * async detachment of listener.\n */\n this.muted = !1;\n }\n\n _createClass(__PRIVATE_AsyncObserver, [{\n key: \"next\",\n value: function next(e) {\n this.observer.next && this.Ba(this.observer.next, e);\n }\n }, {\n key: \"error\",\n value: function error(e) {\n this.observer.error ? this.Ba(this.observer.error, e) : __PRIVATE_logError(\"Uncaught Error in snapshot listener:\", e.toString());\n }\n }, {\n key: \"La\",\n value: function La() {\n this.muted = !0;\n }\n }, {\n key: \"Ba\",\n value: function Ba(e, t) {\n var _this190 = this;\n\n this.muted || setTimeout(function () {\n _this190.muted || e(t);\n }, 0);\n }\n }]);\n\n return __PRIVATE_AsyncObserver;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A class representing a bundle.\n *\n * Takes a bundle stream or buffer, and presents abstractions to read bundled\n * elements out of the underlying content.\n */\n\n\nvar __PRIVATE_BundleReaderImpl = /*#__PURE__*/function () {\n function __PRIVATE_BundleReaderImpl(\n /** The reader to read from underlying binary bundle data source. */\n e, t) {\n var _this191 = this;\n\n _classCallCheck(this, __PRIVATE_BundleReaderImpl);\n\n this.ka = e, this.serializer = t,\n /** Cached bundle metadata. */\n this.metadata = new __PRIVATE_Deferred(),\n /**\n * Internal buffer to hold bundle content, accumulating incomplete element\n * content.\n */\n this.buffer = new Uint8Array(), this.qa = function __PRIVATE_newTextDecoder() {\n return new TextDecoder(\"utf-8\");\n }(), // Read the metadata (which is the first element).\n this.Qa().then(function (e) {\n e && e.ea() ? _this191.metadata.resolve(e.X_.metadata) : _this191.metadata.reject(new Error(\"The first element of the bundle is not a metadata, it is\\n \".concat(JSON.stringify(null == e ? void 0 : e.X_))));\n }, function (e) {\n return _this191.metadata.reject(e);\n });\n }\n\n _createClass(__PRIVATE_BundleReaderImpl, [{\n key: \"close\",\n value: function close() {\n return this.ka.cancel();\n }\n }, {\n key: \"getMetadata\",\n value: function () {\n var _getMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee36() {\n return _regeneratorRuntime.wrap(function _callee36$(_context36) {\n while (1) {\n switch (_context36.prev = _context36.next) {\n case 0:\n return _context36.abrupt(\"return\", this.metadata.promise);\n\n case 1:\n case \"end\":\n return _context36.stop();\n }\n }\n }, _callee36, this);\n }));\n\n function getMetadata() {\n return _getMetadata.apply(this, arguments);\n }\n\n return getMetadata;\n }()\n }, {\n key: \"Oa\",\n value: function () {\n var _Oa = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee37() {\n return _regeneratorRuntime.wrap(function _callee37$(_context37) {\n while (1) {\n switch (_context37.prev = _context37.next) {\n case 0:\n _context37.next = 2;\n return this.getMetadata();\n\n case 2:\n return _context37.abrupt(\"return\", this.Qa());\n\n case 3:\n case \"end\":\n return _context37.stop();\n }\n }\n }, _callee37, this);\n }));\n\n function Oa() {\n return _Oa.apply(this, arguments);\n }\n\n return Oa;\n }()\n /**\n * Reads from the head of internal buffer, and pulling more data from\n * underlying stream if a complete element cannot be found, until an\n * element(including the prefixed length and the JSON string) is found.\n *\n * Once a complete element is read, it is dropped from internal buffer.\n *\n * Returns either the bundled element, or null if we have reached the end of\n * the stream.\n */\n\n }, {\n key: \"Qa\",\n value: function () {\n var _Qa = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38() {\n var e, t, n, r;\n return _regeneratorRuntime.wrap(function _callee38$(_context38) {\n while (1) {\n switch (_context38.prev = _context38.next) {\n case 0:\n _context38.next = 2;\n return this.Ka();\n\n case 2:\n e = _context38.sent;\n\n if (!(null === e)) {\n _context38.next = 5;\n break;\n }\n\n return _context38.abrupt(\"return\", null);\n\n case 5:\n t = this.qa.decode(e), n = Number(t);\n isNaN(n) && this.$a(\"length string (\".concat(t, \") is not valid number\"));\n _context38.next = 9;\n return this.Ua(n);\n\n case 9:\n r = _context38.sent;\n return _context38.abrupt(\"return\", new __PRIVATE_SizedBundleElement(JSON.parse(r), e.length + n));\n\n case 11:\n case \"end\":\n return _context38.stop();\n }\n }\n }, _callee38, this);\n }));\n\n function Qa() {\n return _Qa.apply(this, arguments);\n }\n\n return Qa;\n }()\n /** First index of '{' from the underlying buffer. */\n\n }, {\n key: \"Wa\",\n value: function Wa() {\n return this.buffer.findIndex(function (e) {\n return e === \"{\".charCodeAt(0);\n });\n }\n /**\n * Reads from the beginning of the internal buffer, until the first '{', and\n * return the content.\n *\n * If reached end of the stream, returns a null.\n */\n\n }, {\n key: \"Ka\",\n value: function () {\n var _Ka = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39() {\n var e, t;\n return _regeneratorRuntime.wrap(function _callee39$(_context39) {\n while (1) {\n switch (_context39.prev = _context39.next) {\n case 0:\n if (!(this.Wa() < 0)) {\n _context39.next = 7;\n break;\n }\n\n _context39.next = 3;\n return this.Ga();\n\n case 3:\n if (!_context39.sent) {\n _context39.next = 5;\n break;\n }\n\n return _context39.abrupt(\"break\", 7);\n\n case 5:\n _context39.next = 0;\n break;\n\n case 7:\n if (!(0 === this.buffer.length)) {\n _context39.next = 9;\n break;\n }\n\n return _context39.abrupt(\"return\", null);\n\n case 9:\n e = this.Wa(); // Broke out of the loop because underlying stream is closed, but still\n // cannot find an open bracket.\n\n e < 0 && this.$a(\"Reached the end of bundle when a length string is expected.\");\n t = this.buffer.slice(0, e); // Update the internal buffer to drop the read length.\n\n return _context39.abrupt(\"return\", (this.buffer = this.buffer.slice(e), t));\n\n case 13:\n case \"end\":\n return _context39.stop();\n }\n }\n }, _callee39, this);\n }));\n\n function Ka() {\n return _Ka.apply(this, arguments);\n }\n\n return Ka;\n }()\n /**\n * Reads from a specified position from the internal buffer, for a specified\n * number of bytes, pulling more data from the underlying stream if needed.\n *\n * Returns a string decoded from the read bytes.\n */\n\n }, {\n key: \"Ua\",\n value: function () {\n var _Ua = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40(e) {\n var t;\n return _regeneratorRuntime.wrap(function _callee40$(_context40) {\n while (1) {\n switch (_context40.prev = _context40.next) {\n case 0:\n if (!(this.buffer.length < e)) {\n _context40.next = 8;\n break;\n }\n\n _context40.next = 3;\n return this.Ga();\n\n case 3:\n _context40.t0 = _context40.sent;\n\n if (!_context40.t0) {\n _context40.next = 6;\n break;\n }\n\n this.$a(\"Reached the end of bundle when more is expected.\");\n\n case 6:\n _context40.next = 0;\n break;\n\n case 8:\n t = this.qa.decode(this.buffer.slice(0, e)); // Update the internal buffer to drop the read json string.\n\n return _context40.abrupt(\"return\", (this.buffer = this.buffer.slice(e), t));\n\n case 10:\n case \"end\":\n return _context40.stop();\n }\n }\n }, _callee40, this);\n }));\n\n function Ua(_x115) {\n return _Ua.apply(this, arguments);\n }\n\n return Ua;\n }()\n }, {\n key: \"$a\",\n value: function $a(e) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n throw this.ka.cancel(), new Error(\"Invalid bundle format: \".concat(e));\n }\n /**\n * Pulls more data from underlying stream to internal buffer.\n * Returns a boolean indicating whether the stream is finished.\n */\n\n }, {\n key: \"Ga\",\n value: function () {\n var _Ga = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41() {\n var e, t;\n return _regeneratorRuntime.wrap(function _callee41$(_context41) {\n while (1) {\n switch (_context41.prev = _context41.next) {\n case 0:\n _context41.next = 2;\n return this.ka.read();\n\n case 2:\n e = _context41.sent;\n\n if (!e.done) {\n t = new Uint8Array(this.buffer.length + e.value.length);\n t.set(this.buffer), t.set(e.value, this.buffer.length), this.buffer = t;\n }\n\n return _context41.abrupt(\"return\", e.done);\n\n case 5:\n case \"end\":\n return _context41.stop();\n }\n }\n }, _callee41, this);\n }));\n\n function Ga() {\n return _Ga.apply(this, arguments);\n }\n\n return Ga;\n }()\n }]);\n\n return __PRIVATE_BundleReaderImpl;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Internal transaction object responsible for accumulating the mutations to\n * perform and the base versions for any documents read.\n */\n\n\nvar Transaction$2 = /*#__PURE__*/function () {\n function Transaction$2(e) {\n _classCallCheck(this, Transaction$2);\n\n this.datastore = e, // The version of each document that was read during this transaction.\n this.readVersions = new Map(), this.mutations = [], this.committed = !1,\n /**\n * A deferred usage error that occurred previously in this transaction that\n * will cause the transaction to fail once it actually commits.\n */\n this.lastTransactionError = null,\n /**\n * Set of documents that have been written in the transaction.\n *\n * When there's more than one write to the same key in a transaction, any\n * writes after the first are handled differently.\n */\n this.writtenDocs = new Set();\n }\n\n _createClass(Transaction$2, [{\n key: \"lookup\",\n value: function () {\n var _lookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43(e) {\n var _this192 = this;\n\n var t;\n return _regeneratorRuntime.wrap(function _callee43$(_context43) {\n while (1) {\n switch (_context43.prev = _context43.next) {\n case 0:\n if (!(this.ensureCommitNotCalled(), this.mutations.length > 0)) {\n _context43.next = 2;\n break;\n }\n\n throw this.lastTransactionError = new FirestoreError(D.INVALID_ARGUMENT, \"Firestore transactions require all reads to be executed before all writes.\"), this.lastTransactionError;\n\n case 2:\n _context43.next = 4;\n return function () {\n var _PRIVATE_invokeBatchGetDocumentsRpc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42(e, t) {\n var n, r, i, s, o;\n return _regeneratorRuntime.wrap(function _callee42$(_context42) {\n while (1) {\n switch (_context42.prev = _context42.next) {\n case 0:\n n = __PRIVATE_debugCast(e);\n r = {\n documents: t.map(function (e) {\n return __PRIVATE_toName(n.serializer, e);\n })\n };\n _context42.next = 4;\n return n.vo(\"BatchGetDocuments\", n.serializer.databaseId, ResourcePath.emptyPath(), r, t.length);\n\n case 4:\n i = _context42.sent;\n s = new Map();\n i.forEach(function (e) {\n var t = __PRIVATE_fromBatchGetDocumentsResponse(n.serializer, e);\n\n s.set(t.key.toString(), t);\n });\n o = [];\n return _context42.abrupt(\"return\", (t.forEach(function (e) {\n var t = s.get(e.toString());\n __PRIVATE_hardAssert(!!t), o.push(t);\n }), o));\n\n case 9:\n case \"end\":\n return _context42.stop();\n }\n }\n }, _callee42);\n }));\n\n function __PRIVATE_invokeBatchGetDocumentsRpc(_x117, _x118) {\n return _PRIVATE_invokeBatchGetDocumentsRpc.apply(this, arguments);\n }\n\n return __PRIVATE_invokeBatchGetDocumentsRpc;\n }()(this.datastore, e);\n\n case 4:\n t = _context43.sent;\n return _context43.abrupt(\"return\", (t.forEach(function (e) {\n return _this192.recordVersion(e);\n }), t));\n\n case 6:\n case \"end\":\n return _context43.stop();\n }\n }\n }, _callee43, this);\n }));\n\n function lookup(_x116) {\n return _lookup.apply(this, arguments);\n }\n\n return lookup;\n }()\n }, {\n key: \"set\",\n value: function set(e, t) {\n this.write(t.toMutation(e, this.precondition(e))), this.writtenDocs.add(e.toString());\n }\n }, {\n key: \"update\",\n value: function update(e, t) {\n try {\n this.write(t.toMutation(e, this.preconditionForUpdate(e)));\n } catch (e) {\n this.lastTransactionError = e;\n }\n\n this.writtenDocs.add(e.toString());\n }\n }, {\n key: \"delete\",\n value: function _delete(e) {\n this.write(new __PRIVATE_DeleteMutation(e, this.precondition(e))), this.writtenDocs.add(e.toString());\n }\n }, {\n key: \"commit\",\n value: function () {\n var _commit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45() {\n var _this193 = this;\n\n var e;\n return _regeneratorRuntime.wrap(function _callee45$(_context45) {\n while (1) {\n switch (_context45.prev = _context45.next) {\n case 0:\n if (!(this.ensureCommitNotCalled(), this.lastTransactionError)) {\n _context45.next = 2;\n break;\n }\n\n throw this.lastTransactionError;\n\n case 2:\n e = this.readVersions; // For each mutation, note that the doc was written.\n\n this.mutations.forEach(function (t) {\n e.delete(t.key.toString());\n });\n // For each document that was read but not written to, we want to perform\n // a `verify` operation.\n e.forEach(function (e, t) {\n var n = DocumentKey.fromPath(t);\n\n _this193.mutations.push(new __PRIVATE_VerifyMutation(n, _this193.precondition(n)));\n });\n _context45.next = 7;\n return function () {\n var _PRIVATE_invokeCommitRpc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44(e, t) {\n var n, r;\n return _regeneratorRuntime.wrap(function _callee44$(_context44) {\n while (1) {\n switch (_context44.prev = _context44.next) {\n case 0:\n n = __PRIVATE_debugCast(e), r = {\n writes: t.map(function (e) {\n return toMutation(n.serializer, e);\n })\n };\n _context44.next = 3;\n return n.So(\"Commit\", n.serializer.databaseId, ResourcePath.emptyPath(), r);\n\n case 3:\n case \"end\":\n return _context44.stop();\n }\n }\n }, _callee44);\n }));\n\n function __PRIVATE_invokeCommitRpc(_x119, _x120) {\n return _PRIVATE_invokeCommitRpc.apply(this, arguments);\n }\n\n return __PRIVATE_invokeCommitRpc;\n }()(this.datastore, this.mutations);\n\n case 7:\n this.committed = !0;\n\n case 8:\n case \"end\":\n return _context45.stop();\n }\n }\n }, _callee45, this);\n }));\n\n function commit() {\n return _commit.apply(this, arguments);\n }\n\n return commit;\n }()\n }, {\n key: \"recordVersion\",\n value: function recordVersion(e) {\n var t;\n if (e.isFoundDocument()) t = e.version;else {\n if (!e.isNoDocument()) throw fail(); // Represent a deleted doc using SnapshotVersion.min().\n\n t = SnapshotVersion.min();\n }\n var n = this.readVersions.get(e.key.toString());\n\n if (n) {\n if (!t.isEqual(n)) // This transaction will fail no matter what.\n throw new FirestoreError(D.ABORTED, \"Document version changed between two reads.\");\n } else this.readVersions.set(e.key.toString(), t);\n }\n /**\n * Returns the version of this document when it was read in this transaction,\n * as a precondition, or no precondition if it was not read.\n */\n\n }, {\n key: \"precondition\",\n value: function precondition(e) {\n var t = this.readVersions.get(e.toString());\n return !this.writtenDocs.has(e.toString()) && t ? t.isEqual(SnapshotVersion.min()) ? Precondition.exists(!1) : Precondition.updateTime(t) : Precondition.none();\n }\n /**\n * Returns the precondition for a document if the operation is an update.\n */\n\n }, {\n key: \"preconditionForUpdate\",\n value: function preconditionForUpdate(e) {\n var t = this.readVersions.get(e.toString()); // The first time a document is written, we want to take into account the\n // read time and existence\n\n if (!this.writtenDocs.has(e.toString()) && t) {\n if (t.isEqual(SnapshotVersion.min())) // The document doesn't exist, so fail the transaction.\n // This has to be validated locally because you can't send a\n // precondition that a document does not exist without changing the\n // semantics of the backend write to be an insert. This is the reverse\n // of what we want, since we want to assert that the document doesn't\n // exist but then send the update and have it fail. Since we can't\n // express that to the backend, we have to validate locally.\n // Note: this can change once we can send separate verify writes in the\n // transaction.\n throw new FirestoreError(D.INVALID_ARGUMENT, \"Can't update a document that doesn't exist.\"); // Document exists, base precondition on document update time.\n\n return Precondition.updateTime(t);\n } // Document was not read, so we just use the preconditions for a blind\n // update.\n\n\n return Precondition.exists(!0);\n }\n }, {\n key: \"write\",\n value: function write(e) {\n this.ensureCommitNotCalled(), this.mutations.push(e);\n }\n }, {\n key: \"ensureCommitNotCalled\",\n value: function ensureCommitNotCalled() {}\n }]);\n\n return Transaction$2;\n}();\n/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * TransactionRunner encapsulates the logic needed to run and retry transactions\n * with backoff.\n */\n\n\nvar __PRIVATE_TransactionRunner = /*#__PURE__*/function () {\n function __PRIVATE_TransactionRunner(e, t, n, r, i) {\n _classCallCheck(this, __PRIVATE_TransactionRunner);\n\n this.asyncQueue = e, this.datastore = t, this.options = n, this.updateFunction = r, this.deferred = i, this.za = n.maxAttempts, this.jo = new __PRIVATE_ExponentialBackoff(this.asyncQueue, \"transaction_retry\"\n /* TimerId.TransactionRetry */\n );\n }\n /** Runs the transaction and sets the result on deferred. */\n\n\n _createClass(__PRIVATE_TransactionRunner, [{\n key: \"ja\",\n value: function ja() {\n this.za -= 1, this.Ha();\n }\n }, {\n key: \"Ha\",\n value: function Ha() {\n var _this194 = this;\n\n this.jo.qo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46() {\n var e, t;\n return _regeneratorRuntime.wrap(function _callee46$(_context46) {\n while (1) {\n switch (_context46.prev = _context46.next) {\n case 0:\n e = new Transaction$2(_this194.datastore), t = _this194.Ja(e);\n t && t.then(function (t) {\n _this194.asyncQueue.enqueueAndForget(function () {\n return e.commit().then(function () {\n _this194.deferred.resolve(t);\n }).catch(function (e) {\n _this194.Ya(e);\n });\n });\n }).catch(function (e) {\n _this194.Ya(e);\n });\n\n case 2:\n case \"end\":\n return _context46.stop();\n }\n }\n }, _callee46);\n })));\n }\n }, {\n key: \"Ja\",\n value: function Ja(e) {\n try {\n var t = this.updateFunction(e);\n return !__PRIVATE_isNullOrUndefined(t) && t.catch && t.then ? t : (this.deferred.reject(Error(\"Transaction callback must return a Promise\")), null);\n } catch (e) {\n // Do not retry errors thrown by user provided updateFunction.\n return this.deferred.reject(e), null;\n }\n }\n }, {\n key: \"Ya\",\n value: function Ya(e) {\n var _this195 = this;\n\n this.za > 0 && this.Za(e) ? (this.za -= 1, this.asyncQueue.enqueueAndForget(function () {\n return _this195.Ha(), Promise.resolve();\n })) : this.deferred.reject(e);\n }\n }, {\n key: \"Za\",\n value: function Za(e) {\n if (\"FirebaseError\" === e.name) {\n // In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and\n // non-matching document versions with ABORTED. These errors should be retried.\n var t = e.code;\n return \"aborted\" === t || \"failed-precondition\" === t || \"already-exists\" === t || !__PRIVATE_isPermanentError(t);\n }\n\n return !1;\n }\n }]);\n\n return __PRIVATE_TransactionRunner;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * FirestoreClient is a top-level class that constructs and owns all of the //\n * pieces of the client SDK architecture. It is responsible for creating the //\n * async queue that is shared by all of the other components in the system. //\n */\n\n\nvar FirestoreClient = /*#__PURE__*/function () {\n function FirestoreClient(e, t,\n /**\n * Asynchronous queue responsible for all of our internal processing. When\n * we get incoming work from the user (via public API) or the network\n * (incoming GRPC messages), we should always schedule onto this queue.\n * This ensures all of our work is properly serialized (e.g. we don't\n * start processing a new operation while the previous one is waiting for\n * an async I/O to complete).\n */\n n, r) {\n var _this196 = this;\n\n _classCallCheck(this, FirestoreClient);\n\n this.authCredentials = e, this.appCheckCredentials = t, this.asyncQueue = n, this.databaseInfo = r, this.user = User.UNAUTHENTICATED, this.clientId = __PRIVATE_AutoId.newId(), this.authCredentialListener = function () {\n return Promise.resolve();\n }, this.appCheckCredentialListener = function () {\n return Promise.resolve();\n }, this.authCredentials.start(n, /*#__PURE__*/function () {\n var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee47(e) {\n return _regeneratorRuntime.wrap(function _callee47$(_context47) {\n while (1) {\n switch (_context47.prev = _context47.next) {\n case 0:\n __PRIVATE_logDebug(\"FirestoreClient\", \"Received user=\", e.uid);\n\n _context47.next = 3;\n return _this196.authCredentialListener(e);\n\n case 3:\n _this196.user = e;\n\n case 4:\n case \"end\":\n return _context47.stop();\n }\n }\n }, _callee47);\n }));\n\n return function (_x121) {\n return _ref34.apply(this, arguments);\n };\n }()), this.appCheckCredentials.start(n, function (e) {\n return __PRIVATE_logDebug(\"FirestoreClient\", \"Received new app check token=\", e), _this196.appCheckCredentialListener(e, _this196.user);\n });\n }\n\n _createClass(FirestoreClient, [{\n key: \"configuration\",\n get: function get() {\n return {\n asyncQueue: this.asyncQueue,\n databaseInfo: this.databaseInfo,\n clientId: this.clientId,\n authCredentials: this.authCredentials,\n appCheckCredentials: this.appCheckCredentials,\n initialUser: this.user,\n maxConcurrentLimboResolutions: 100\n };\n }\n }, {\n key: \"setCredentialChangeListener\",\n value: function setCredentialChangeListener(e) {\n this.authCredentialListener = e;\n }\n }, {\n key: \"setAppCheckTokenChangeListener\",\n value: function setAppCheckTokenChangeListener(e) {\n this.appCheckCredentialListener = e;\n }\n /**\n * Checks that the client has not been terminated. Ensures that other methods on //\n * this class cannot be called after the client is terminated. //\n */\n\n }, {\n key: \"verifyNotTerminated\",\n value: function verifyNotTerminated() {\n if (this.asyncQueue.isShuttingDown) throw new FirestoreError(D.FAILED_PRECONDITION, \"The client has already been terminated.\");\n }\n }, {\n key: \"terminate\",\n value: function terminate() {\n var _this197 = this;\n\n this.asyncQueue.enterRestrictedMode();\n var e = new __PRIVATE_Deferred();\n return this.asyncQueue.enqueueAndForgetEvenWhileRestricted( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee48() {\n var n;\n return _regeneratorRuntime.wrap(function _callee48$(_context48) {\n while (1) {\n switch (_context48.prev = _context48.next) {\n case 0:\n _context48.prev = 0;\n _context48.t0 = _this197._onlineComponents;\n\n if (!_context48.t0) {\n _context48.next = 5;\n break;\n }\n\n _context48.next = 5;\n return _this197._onlineComponents.terminate();\n\n case 5:\n _context48.t1 = _this197._offlineComponents;\n\n if (!_context48.t1) {\n _context48.next = 9;\n break;\n }\n\n _context48.next = 9;\n return _this197._offlineComponents.terminate();\n\n case 9:\n // The credentials provider must be terminated after shutting down the\n // RemoteStore as it will prevent the RemoteStore from retrieving auth\n // tokens.\n _this197.authCredentials.shutdown();\n\n _this197.appCheckCredentials.shutdown();\n\n e.resolve();\n _context48.next = 18;\n break;\n\n case 14:\n _context48.prev = 14;\n _context48.t2 = _context48[\"catch\"](0);\n n = __PRIVATE_wrapInUserErrorIfRecoverable(_context48.t2, \"Failed to shutdown persistence\");\n e.reject(n);\n\n case 18:\n case \"end\":\n return _context48.stop();\n }\n }\n }, _callee48, null, [[0, 14]]);\n }))), e.promise;\n }\n }]);\n\n return FirestoreClient;\n}();\n\nfunction __PRIVATE_setOfflineComponentProvider(_x122, _x123) {\n return _PRIVATE_setOfflineComponentProvider.apply(this, arguments);\n}\n\nfunction _PRIVATE_setOfflineComponentProvider() {\n _PRIVATE_setOfflineComponentProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee122(e, t) {\n var n, r;\n return _regeneratorRuntime.wrap(function _callee122$(_context123) {\n while (1) {\n switch (_context123.prev = _context123.next) {\n case 0:\n e.asyncQueue.verifyOperationInProgress(), __PRIVATE_logDebug(\"FirestoreClient\", \"Initializing OfflineComponentProvider\");\n n = e.configuration;\n _context123.next = 4;\n return t.initialize(n);\n\n case 4:\n r = n.initialUser;\n e.setCredentialChangeListener( /*#__PURE__*/function () {\n var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee121(e) {\n return _regeneratorRuntime.wrap(function _callee121$(_context122) {\n while (1) {\n switch (_context122.prev = _context122.next) {\n case 0:\n _context122.t0 = r.isEqual(e);\n\n if (_context122.t0) {\n _context122.next = 5;\n break;\n }\n\n _context122.next = 4;\n return __PRIVATE_localStoreHandleUserChange(t.localStore, e);\n\n case 4:\n r = e;\n\n case 5:\n case \"end\":\n return _context122.stop();\n }\n }\n }, _callee121);\n }));\n\n return function (_x149) {\n return _ref60.apply(this, arguments);\n };\n }()), // When a user calls clearPersistence() in one client, all other clients\n // need to be terminated to allow the delete to succeed.\n t.persistence.setDatabaseDeletedListener(function () {\n return e.terminate();\n }), e._offlineComponents = t;\n\n case 6:\n case \"end\":\n return _context123.stop();\n }\n }\n }, _callee122);\n }));\n return _PRIVATE_setOfflineComponentProvider.apply(this, arguments);\n}\n\nfunction __PRIVATE_setOnlineComponentProvider(_x124, _x125) {\n return _PRIVATE_setOnlineComponentProvider.apply(this, arguments);\n}\n/**\n * Decides whether the provided error allows us to gracefully disable\n * persistence (as opposed to crashing the client).\n */\n\n\nfunction _PRIVATE_setOnlineComponentProvider() {\n _PRIVATE_setOnlineComponentProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee123(e, t) {\n var n;\n return _regeneratorRuntime.wrap(function _callee123$(_context124) {\n while (1) {\n switch (_context124.prev = _context124.next) {\n case 0:\n e.asyncQueue.verifyOperationInProgress();\n _context124.next = 3;\n return __PRIVATE_ensureOfflineComponents(e);\n\n case 3:\n n = _context124.sent;\n\n __PRIVATE_logDebug(\"FirestoreClient\", \"Initializing OnlineComponentProvider\");\n\n _context124.next = 7;\n return t.initialize(n, e.configuration);\n\n case 7:\n // The CredentialChangeListener of the online component provider takes\n // precedence over the offline component provider.\n e.setCredentialChangeListener(function (e) {\n return __PRIVATE_remoteStoreHandleCredentialChange(t.remoteStore, e);\n });\n e.setAppCheckTokenChangeListener(function (e, n) {\n return __PRIVATE_remoteStoreHandleCredentialChange(t.remoteStore, n);\n });\n e._onlineComponents = t;\n\n case 10:\n case \"end\":\n return _context124.stop();\n }\n }\n }, _callee123);\n }));\n return _PRIVATE_setOnlineComponentProvider.apply(this, arguments);\n}\n\nfunction __PRIVATE_canFallbackFromIndexedDbError(e) {\n return \"FirebaseError\" === e.name ? e.code === D.FAILED_PRECONDITION || e.code === D.UNIMPLEMENTED : !(\"undefined\" != typeof DOMException && e instanceof DOMException) || // When the browser is out of quota we could get either quota exceeded\n // or an aborted error depending on whether the error happened during\n // schema migration.\n 22 === e.code || 20 === e.code || // Firefox Private Browsing mode disables IndexedDb and returns\n // INVALID_STATE for any usage.\n 11 === e.code;\n}\n\nfunction __PRIVATE_ensureOfflineComponents(_x126) {\n return _PRIVATE_ensureOfflineComponents.apply(this, arguments);\n}\n\nfunction _PRIVATE_ensureOfflineComponents() {\n _PRIVATE_ensureOfflineComponents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee124(e) {\n var n;\n return _regeneratorRuntime.wrap(function _callee124$(_context125) {\n while (1) {\n switch (_context125.prev = _context125.next) {\n case 0:\n if (e._offlineComponents) {\n _context125.next = 21;\n break;\n }\n\n if (!e._uninitializedComponentsProvider) {\n _context125.next = 18;\n break;\n }\n\n __PRIVATE_logDebug(\"FirestoreClient\", \"Using user provided OfflineComponentProvider\");\n\n _context125.prev = 3;\n _context125.next = 6;\n return __PRIVATE_setOfflineComponentProvider(e, e._uninitializedComponentsProvider._offline);\n\n case 6:\n _context125.next = 16;\n break;\n\n case 8:\n _context125.prev = 8;\n _context125.t0 = _context125[\"catch\"](3);\n n = _context125.t0;\n\n if (__PRIVATE_canFallbackFromIndexedDbError(n)) {\n _context125.next = 13;\n break;\n }\n\n throw n;\n\n case 13:\n __PRIVATE_logWarn(\"Error using user provided cache. Falling back to memory cache: \" + n);\n\n _context125.next = 16;\n return __PRIVATE_setOfflineComponentProvider(e, new MemoryOfflineComponentProvider());\n\n case 16:\n _context125.next = 21;\n break;\n\n case 18:\n __PRIVATE_logDebug(\"FirestoreClient\", \"Using default OfflineComponentProvider\");\n\n _context125.next = 21;\n return __PRIVATE_setOfflineComponentProvider(e, new MemoryOfflineComponentProvider());\n\n case 21:\n return _context125.abrupt(\"return\", e._offlineComponents);\n\n case 22:\n case \"end\":\n return _context125.stop();\n }\n }\n }, _callee124, null, [[3, 8]]);\n }));\n return _PRIVATE_ensureOfflineComponents.apply(this, arguments);\n}\n\nfunction __PRIVATE_ensureOnlineComponents(_x127) {\n return _PRIVATE_ensureOnlineComponents.apply(this, arguments);\n}\n\nfunction _PRIVATE_ensureOnlineComponents() {\n _PRIVATE_ensureOnlineComponents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee125(e) {\n return _regeneratorRuntime.wrap(function _callee125$(_context126) {\n while (1) {\n switch (_context126.prev = _context126.next) {\n case 0:\n _context126.t0 = e._onlineComponents;\n\n if (_context126.t0) {\n _context126.next = 11;\n break;\n }\n\n if (!e._uninitializedComponentsProvider) {\n _context126.next = 8;\n break;\n }\n\n __PRIVATE_logDebug(\"FirestoreClient\", \"Using user provided OnlineComponentProvider\");\n\n _context126.next = 6;\n return __PRIVATE_setOnlineComponentProvider(e, e._uninitializedComponentsProvider._online);\n\n case 6:\n _context126.next = 11;\n break;\n\n case 8:\n __PRIVATE_logDebug(\"FirestoreClient\", \"Using default OnlineComponentProvider\");\n\n _context126.next = 11;\n return __PRIVATE_setOnlineComponentProvider(e, new OnlineComponentProvider());\n\n case 11:\n return _context126.abrupt(\"return\", e._onlineComponents);\n\n case 12:\n case \"end\":\n return _context126.stop();\n }\n }\n }, _callee125);\n }));\n return _PRIVATE_ensureOnlineComponents.apply(this, arguments);\n}\n\nfunction __PRIVATE_getPersistence(e) {\n return __PRIVATE_ensureOfflineComponents(e).then(function (e) {\n return e.persistence;\n });\n}\n\nfunction __PRIVATE_getLocalStore(e) {\n return __PRIVATE_ensureOfflineComponents(e).then(function (e) {\n return e.localStore;\n });\n}\n\nfunction __PRIVATE_getRemoteStore(e) {\n return __PRIVATE_ensureOnlineComponents(e).then(function (e) {\n return e.remoteStore;\n });\n}\n\nfunction __PRIVATE_getSyncEngine(e) {\n return __PRIVATE_ensureOnlineComponents(e).then(function (e) {\n return e.syncEngine;\n });\n}\n\nfunction __PRIVATE_getDatastore(e) {\n return __PRIVATE_ensureOnlineComponents(e).then(function (e) {\n return e.datastore;\n });\n}\n\nfunction __PRIVATE_getEventManager(_x128) {\n return _PRIVATE_getEventManager.apply(this, arguments);\n}\n/** Enables the network connection and re-enqueues all pending operations. */\n\n\nfunction _PRIVATE_getEventManager() {\n _PRIVATE_getEventManager = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee126(e) {\n var t, n;\n return _regeneratorRuntime.wrap(function _callee126$(_context127) {\n while (1) {\n switch (_context127.prev = _context127.next) {\n case 0:\n _context127.next = 2;\n return __PRIVATE_ensureOnlineComponents(e);\n\n case 2:\n t = _context127.sent;\n n = t.eventManager;\n return _context127.abrupt(\"return\", (n.onListen = __PRIVATE_syncEngineListen.bind(null, t.syncEngine), n.onUnlisten = __PRIVATE_syncEngineUnlisten.bind(null, t.syncEngine), n));\n\n case 5:\n case \"end\":\n return _context127.stop();\n }\n }\n }, _callee126);\n }));\n return _PRIVATE_getEventManager.apply(this, arguments);\n}\n\nfunction __PRIVATE_firestoreClientEnableNetwork(e) {\n return e.asyncQueue.enqueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee49() {\n var t, n;\n return _regeneratorRuntime.wrap(function _callee49$(_context49) {\n while (1) {\n switch (_context49.prev = _context49.next) {\n case 0:\n _context49.next = 2;\n return __PRIVATE_getPersistence(e);\n\n case 2:\n t = _context49.sent;\n _context49.next = 5;\n return __PRIVATE_getRemoteStore(e);\n\n case 5:\n n = _context49.sent;\n return _context49.abrupt(\"return\", (t.setNetworkEnabled(!0), function __PRIVATE_remoteStoreEnableNetwork(e) {\n var t = __PRIVATE_debugCast(e);\n\n return t.v_.delete(0\n /* OfflineCause.UserDisabled */\n ), __PRIVATE_enableNetworkInternal(t);\n }(n)));\n\n case 7:\n case \"end\":\n return _context49.stop();\n }\n }\n }, _callee49);\n })));\n}\n/** Disables the network connection. Pending operations will not complete. */\n\n\nfunction __PRIVATE_firestoreClientDisableNetwork(e) {\n return e.asyncQueue.enqueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee51() {\n var t, n;\n return _regeneratorRuntime.wrap(function _callee51$(_context51) {\n while (1) {\n switch (_context51.prev = _context51.next) {\n case 0:\n _context51.next = 2;\n return __PRIVATE_getPersistence(e);\n\n case 2:\n t = _context51.sent;\n _context51.next = 5;\n return __PRIVATE_getRemoteStore(e);\n\n case 5:\n n = _context51.sent;\n return _context51.abrupt(\"return\", (t.setNetworkEnabled(!1), function () {\n var _PRIVATE_remoteStoreDisableNetwork = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee50(e) {\n var t;\n return _regeneratorRuntime.wrap(function _callee50$(_context50) {\n while (1) {\n switch (_context50.prev = _context50.next) {\n case 0:\n t = __PRIVATE_debugCast(e);\n t.v_.add(0\n /* OfflineCause.UserDisabled */\n );\n _context50.next = 4;\n return __PRIVATE_disableNetworkInternal(t);\n\n case 4:\n // Set the OnlineState to Offline so get()s return from cache, etc.\n t.x_.set(\"Offline\"\n /* OnlineState.Offline */\n );\n\n case 5:\n case \"end\":\n return _context50.stop();\n }\n }\n }, _callee50);\n }));\n\n function __PRIVATE_remoteStoreDisableNetwork(_x129) {\n return _PRIVATE_remoteStoreDisableNetwork.apply(this, arguments);\n }\n\n return __PRIVATE_remoteStoreDisableNetwork;\n }()(n)));\n\n case 7:\n case \"end\":\n return _context51.stop();\n }\n }\n }, _callee51);\n })));\n}\n/**\n * Returns a Promise that resolves when all writes that were pending at the time\n * this method was called received server acknowledgement. An acknowledgement\n * can be either acceptance or rejection.\n */\n\n\nfunction __PRIVATE_firestoreClientGetDocumentFromLocalCache(e, t) {\n var n = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee53() {\n return _regeneratorRuntime.wrap(function _callee53$(_context53) {\n while (1) {\n switch (_context53.prev = _context53.next) {\n case 0:\n _context53.t0 = function () {\n var _PRIVATE_readDocumentFromCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee52(e, t, n) {\n var r, _r28;\n\n return _regeneratorRuntime.wrap(function _callee52$(_context52) {\n while (1) {\n switch (_context52.prev = _context52.next) {\n case 0:\n _context52.prev = 0;\n _context52.next = 3;\n return function __PRIVATE_localStoreReadDocument(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return n.persistence.runTransaction(\"read document\", \"readonly\", function (e) {\n return n.localDocuments.getDocument(e, t);\n });\n }(e, t);\n\n case 3:\n r = _context52.sent;\n r.isFoundDocument() ? n.resolve(r) : r.isNoDocument() ? n.resolve(null) : n.reject(new FirestoreError(D.UNAVAILABLE, \"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)\"));\n _context52.next = 11;\n break;\n\n case 7:\n _context52.prev = 7;\n _context52.t0 = _context52[\"catch\"](0);\n _r28 = __PRIVATE_wrapInUserErrorIfRecoverable(_context52.t0, \"Failed to get document '\".concat(t, \" from cache\"));\n n.reject(_r28);\n\n case 11:\n case \"end\":\n return _context52.stop();\n }\n }\n }, _callee52, null, [[0, 7]]);\n }));\n\n function __PRIVATE_readDocumentFromCache(_x130, _x131, _x132) {\n return _PRIVATE_readDocumentFromCache.apply(this, arguments);\n }\n\n return __PRIVATE_readDocumentFromCache;\n }()\n /**\n * Retrieves a latency-compensated document from the backend via a\n * SnapshotListener.\n */\n ;\n\n _context53.next = 3;\n return __PRIVATE_getLocalStore(e);\n\n case 3:\n _context53.t1 = _context53.sent;\n _context53.t2 = t;\n _context53.t3 = n;\n return _context53.abrupt(\"return\", (0, _context53.t0)(_context53.t1, _context53.t2, _context53.t3));\n\n case 7:\n case \"end\":\n return _context53.stop();\n }\n }\n }, _callee53);\n }))), n.promise;\n}\n\nfunction __PRIVATE_firestoreClientGetDocumentViaSnapshotListener(e, t) {\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var r = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee54() {\n return _regeneratorRuntime.wrap(function _callee54$(_context54) {\n while (1) {\n switch (_context54.prev = _context54.next) {\n case 0:\n _context54.t0 = function __PRIVATE_readDocumentViaSnapshotListener(e, t, n, r, i) {\n var s = new __PRIVATE_AsyncObserver({\n next: function next(s) {\n // Remove query first before passing event to user to avoid\n // user actions affecting the now stale query.\n t.enqueueAndForget(function () {\n return __PRIVATE_eventManagerUnlisten(e, o);\n });\n\n var _ = s.docs.has(n);\n\n !_ && s.fromCache ? // TODO(dimond): If we're online and the document doesn't\n // exist then we resolve with a doc.exists set to false. If\n // we're offline however, we reject the Promise in this\n // case. Two options: 1) Cache the negative response from\n // the server so we can deliver that even when you're\n // offline 2) Actually reject the Promise in the online case\n // if the document doesn't exist.\n i.reject(new FirestoreError(D.UNAVAILABLE, \"Failed to get document because the client is offline.\")) : _ && s.fromCache && r && \"server\" === r.source ? i.reject(new FirestoreError(D.UNAVAILABLE, 'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to \"server\" to retrieve the cached document.)')) : i.resolve(s);\n },\n error: function error(e) {\n return i.reject(e);\n }\n }),\n o = new __PRIVATE_QueryListener(__PRIVATE_newQueryForPath(n.path), s, {\n includeMetadataChanges: !0,\n Z_: !0\n });\n return __PRIVATE_eventManagerListen(e, o);\n };\n\n _context54.next = 3;\n return __PRIVATE_getEventManager(e);\n\n case 3:\n _context54.t1 = _context54.sent;\n _context54.t2 = e.asyncQueue;\n _context54.t3 = t;\n _context54.t4 = n;\n _context54.t5 = r;\n return _context54.abrupt(\"return\", (0, _context54.t0)(_context54.t1, _context54.t2, _context54.t3, _context54.t4, _context54.t5));\n\n case 9:\n case \"end\":\n return _context54.stop();\n }\n }\n }, _callee54);\n }))), r.promise;\n}\n\nfunction __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {\n var n = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee56() {\n return _regeneratorRuntime.wrap(function _callee56$(_context56) {\n while (1) {\n switch (_context56.prev = _context56.next) {\n case 0:\n _context56.t0 = function () {\n var _PRIVATE_executeQueryFromCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee55(e, t, n) {\n var r, i, s, o, _r29;\n\n return _regeneratorRuntime.wrap(function _callee55$(_context55) {\n while (1) {\n switch (_context55.prev = _context55.next) {\n case 0:\n _context55.prev = 0;\n _context55.next = 3;\n return __PRIVATE_localStoreExecuteQuery(e, t,\n /* usePreviousResults= */\n !0);\n\n case 3:\n r = _context55.sent;\n i = new __PRIVATE_View(t, r.hs);\n s = i.ha(r.documents);\n o = i.applyChanges(s,\n /* limboResolutionEnabled= */\n !1);\n n.resolve(o.snapshot);\n _context55.next = 14;\n break;\n\n case 10:\n _context55.prev = 10;\n _context55.t0 = _context55[\"catch\"](0);\n _r29 = __PRIVATE_wrapInUserErrorIfRecoverable(_context55.t0, \"Failed to execute query '\".concat(t, \" against cache\"));\n n.reject(_r29);\n\n case 14:\n case \"end\":\n return _context55.stop();\n }\n }\n }, _callee55, null, [[0, 10]]);\n }));\n\n function __PRIVATE_executeQueryFromCache(_x133, _x134, _x135) {\n return _PRIVATE_executeQueryFromCache.apply(this, arguments);\n }\n\n return __PRIVATE_executeQueryFromCache;\n }()\n /**\n * Retrieves a latency-compensated query snapshot from the backend via a\n * SnapshotListener.\n */\n ;\n\n _context56.next = 3;\n return __PRIVATE_getLocalStore(e);\n\n case 3:\n _context56.t1 = _context56.sent;\n _context56.t2 = t;\n _context56.t3 = n;\n return _context56.abrupt(\"return\", (0, _context56.t0)(_context56.t1, _context56.t2, _context56.t3));\n\n case 7:\n case \"end\":\n return _context56.stop();\n }\n }\n }, _callee56);\n }))), n.promise;\n}\n\nfunction __PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(e, t) {\n var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var r = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee57() {\n return _regeneratorRuntime.wrap(function _callee57$(_context57) {\n while (1) {\n switch (_context57.prev = _context57.next) {\n case 0:\n _context57.t0 = function __PRIVATE_executeQueryViaSnapshotListener(e, t, n, r, i) {\n var s = new __PRIVATE_AsyncObserver({\n next: function next(n) {\n // Remove query first before passing event to user to avoid\n // user actions affecting the now stale query.\n t.enqueueAndForget(function () {\n return __PRIVATE_eventManagerUnlisten(e, o);\n }), n.fromCache && \"server\" === r.source ? i.reject(new FirestoreError(D.UNAVAILABLE, 'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to \"server\" to retrieve the cached documents.)')) : i.resolve(n);\n },\n error: function error(e) {\n return i.reject(e);\n }\n }),\n o = new __PRIVATE_QueryListener(n, s, {\n includeMetadataChanges: !0,\n Z_: !0\n });\n return __PRIVATE_eventManagerListen(e, o);\n };\n\n _context57.next = 3;\n return __PRIVATE_getEventManager(e);\n\n case 3:\n _context57.t1 = _context57.sent;\n _context57.t2 = e.asyncQueue;\n _context57.t3 = t;\n _context57.t4 = n;\n _context57.t5 = r;\n return _context57.abrupt(\"return\", (0, _context57.t0)(_context57.t1, _context57.t2, _context57.t3, _context57.t4, _context57.t5));\n\n case 9:\n case \"end\":\n return _context57.stop();\n }\n }\n }, _callee57);\n }))), r.promise;\n}\n\nfunction __PRIVATE_firestoreClientAddSnapshotsInSyncListener(e, t) {\n var n = new __PRIVATE_AsyncObserver(t);\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee58() {\n return _regeneratorRuntime.wrap(function _callee58$(_context58) {\n while (1) {\n switch (_context58.prev = _context58.next) {\n case 0:\n _context58.t0 = function __PRIVATE_addSnapshotsInSyncListener(e, t) {\n __PRIVATE_debugCast(e).K_.add(t), // Immediately fire an initial event, indicating all existing listeners\n // are in-sync.\n t.next();\n };\n\n _context58.next = 3;\n return __PRIVATE_getEventManager(e);\n\n case 3:\n _context58.t1 = _context58.sent;\n _context58.t2 = n;\n return _context58.abrupt(\"return\", (0, _context58.t0)(_context58.t1, _context58.t2));\n\n case 6:\n case \"end\":\n return _context58.stop();\n }\n }\n }, _callee58);\n }))), function () {\n n.La(), e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee59() {\n return _regeneratorRuntime.wrap(function _callee59$(_context59) {\n while (1) {\n switch (_context59.prev = _context59.next) {\n case 0:\n _context59.t0 = function __PRIVATE_removeSnapshotsInSyncListener(e, t) {\n __PRIVATE_debugCast(e).K_.delete(t);\n };\n\n _context59.next = 3;\n return __PRIVATE_getEventManager(e);\n\n case 3:\n _context59.t1 = _context59.sent;\n _context59.t2 = n;\n return _context59.abrupt(\"return\", (0, _context59.t0)(_context59.t1, _context59.t2));\n\n case 6:\n case \"end\":\n return _context59.stop();\n }\n }\n }, _callee59);\n })));\n };\n}\n/**\n * Takes an updateFunction in which a set of reads and writes can be performed\n * atomically. In the updateFunction, the client can read and write values\n * using the supplied transaction object. After the updateFunction, all\n * changes will be committed. If a retryable error occurs (ex: some other\n * client has changed any of the data referenced), then the updateFunction\n * will be called again after a backoff. If the updateFunction still fails\n * after all retries, then the transaction will be rejected.\n *\n * The transaction object passed to the updateFunction contains methods for\n * accessing documents and collections. Unlike other datastore access, data\n * accessed with the transaction will not reflect local changes that have not\n * been committed. For this reason, it is required that all reads are\n * performed before any writes. Transactions must be performed while online.\n */\n\n\nfunction __PRIVATE_firestoreClientLoadBundle(e, t, n, r) {\n var i = function __PRIVATE_createBundleReader(e, t) {\n var n;\n n = \"string\" == typeof e ? __PRIVATE_newTextEncoder().encode(e) : e;\n return function __PRIVATE_newBundleReader(e, t) {\n return new __PRIVATE_BundleReaderImpl(e, t);\n }(function __PRIVATE_toByteStreamReader(e, t) {\n if (e instanceof Uint8Array) return __PRIVATE_toByteStreamReaderHelper(e, t);\n if (e instanceof ArrayBuffer) return __PRIVATE_toByteStreamReaderHelper(new Uint8Array(e), t);\n if (e instanceof ReadableStream) return e.getReader();\n throw new Error(\"Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream\");\n }(n), t);\n }(n, __PRIVATE_newSerializer(t));\n\n e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee60() {\n return _regeneratorRuntime.wrap(function _callee60$(_context60) {\n while (1) {\n switch (_context60.prev = _context60.next) {\n case 0:\n _context60.t0 = __PRIVATE_syncEngineLoadBundle;\n _context60.next = 3;\n return __PRIVATE_getSyncEngine(e);\n\n case 3:\n _context60.t1 = _context60.sent;\n _context60.t2 = i;\n _context60.t3 = r;\n (0, _context60.t0)(_context60.t1, _context60.t2, _context60.t3);\n\n case 7:\n case \"end\":\n return _context60.stop();\n }\n }\n }, _callee60);\n })));\n}\n\nfunction __PRIVATE_firestoreClientGetNamedQuery(e, t) {\n return e.asyncQueue.enqueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee61() {\n return _regeneratorRuntime.wrap(function _callee61$(_context61) {\n while (1) {\n switch (_context61.prev = _context61.next) {\n case 0:\n _context61.t0 = function __PRIVATE_localStoreGetNamedQuery(e, t) {\n var n = __PRIVATE_debugCast(e);\n\n return n.persistence.runTransaction(\"Get named query\", \"readonly\", function (e) {\n return n.$r.getNamedQuery(e, t);\n });\n };\n\n _context61.next = 3;\n return __PRIVATE_getLocalStore(e);\n\n case 3:\n _context61.t1 = _context61.sent;\n _context61.t2 = t;\n return _context61.abrupt(\"return\", (0, _context61.t0)(_context61.t1, _context61.t2));\n\n case 6:\n case \"end\":\n return _context61.stop();\n }\n }\n }, _callee61);\n })));\n}\n\nfunction __PRIVATE_firestoreClientSetIndexConfiguration(e, t) {\n return e.asyncQueue.enqueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee63() {\n return _regeneratorRuntime.wrap(function _callee63$(_context63) {\n while (1) {\n switch (_context63.prev = _context63.next) {\n case 0:\n _context63.t0 = function () {\n var _PRIVATE_localStoreConfigureFieldIndexes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee62(e, t) {\n var n, r, i;\n return _regeneratorRuntime.wrap(function _callee62$(_context62) {\n while (1) {\n switch (_context62.prev = _context62.next) {\n case 0:\n n = __PRIVATE_debugCast(e), r = n.indexManager, i = [];\n return _context62.abrupt(\"return\", n.persistence.runTransaction(\"Configure indexes\", \"readwrite\", function (e) {\n return r.getFieldIndexes(e).next(function (n) {\n return (\n /**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n /**\n * Compares two array for equality using comparator. The method computes the\n * intersection and invokes `onAdd` for every element that is in `after` but not\n * `before`. `onRemove` is invoked for every element in `before` but missing\n * from `after`.\n *\n * The method creates a copy of both `before` and `after` and runs in O(n log\n * n), where n is the size of the two lists.\n *\n * @param before - The elements that exist in the original array.\n * @param after - The elements to diff against the original array.\n * @param comparator - The comparator for the elements in before and after.\n * @param onAdd - A function to invoke for every element that is part of `\n * after` but not `before`.\n * @param onRemove - A function to invoke for every element that is part of\n * `before` but not `after`.\n */\n function __PRIVATE_diffArrays(e, t, n, r, i) {\n e = _toConsumableArray(e), t = _toConsumableArray(t), e.sort(n), t.sort(n);\n var s = e.length,\n o = t.length;\n var _ = 0,\n a = 0;\n\n for (; _ < o && a < s;) {\n var _s7 = n(e[a], t[_]);\n\n _s7 < 0 ? // The element was removed if the next element in our ordered\n // walkthrough is only in `before`.\n i(e[a++]) : _s7 > 0 ? // The element was added if the next element in our ordered walkthrough\n // is only in `after`.\n r(t[_++]) : (_++, a++);\n }\n\n for (; _ < o;) {\n r(t[_++]);\n }\n\n for (; a < s;) {\n i(e[a++]);\n }\n }(n, t, __PRIVATE_fieldIndexSemanticComparator, function (t) {\n i.push(r.addFieldIndex(e, t));\n }, function (t) {\n i.push(r.deleteFieldIndex(e, t));\n })\n );\n }).next(function () {\n return PersistencePromise.waitFor(i);\n });\n }));\n\n case 2:\n case \"end\":\n return _context62.stop();\n }\n }\n }, _callee62);\n }));\n\n function __PRIVATE_localStoreConfigureFieldIndexes(_x136, _x137) {\n return _PRIVATE_localStoreConfigureFieldIndexes.apply(this, arguments);\n }\n\n return __PRIVATE_localStoreConfigureFieldIndexes;\n }();\n\n _context63.next = 3;\n return __PRIVATE_getLocalStore(e);\n\n case 3:\n _context63.t1 = _context63.sent;\n _context63.t2 = t;\n return _context63.abrupt(\"return\", (0, _context63.t0)(_context63.t1, _context63.t2));\n\n case 6:\n case \"end\":\n return _context63.stop();\n }\n }\n }, _callee63);\n })));\n}\n\nfunction __PRIVATE_firestoreClientSetPersistentCacheIndexAutoCreationEnabled(e, t) {\n return e.asyncQueue.enqueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee64() {\n return _regeneratorRuntime.wrap(function _callee64$(_context64) {\n while (1) {\n switch (_context64.prev = _context64.next) {\n case 0:\n _context64.t0 = function __PRIVATE_localStoreSetIndexAutoCreationEnabled(e, t) {\n __PRIVATE_debugCast(e).ts.Ui = t;\n };\n\n _context64.next = 3;\n return __PRIVATE_getLocalStore(e);\n\n case 3:\n _context64.t1 = _context64.sent;\n _context64.t2 = t;\n return _context64.abrupt(\"return\", (0, _context64.t0)(_context64.t1, _context64.t2));\n\n case 6:\n case \"end\":\n return _context64.stop();\n }\n }\n }, _callee64);\n })));\n}\n\nfunction __PRIVATE_firestoreClientDeleteAllFieldIndexes(e) {\n return e.asyncQueue.enqueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee65() {\n return _regeneratorRuntime.wrap(function _callee65$(_context65) {\n while (1) {\n switch (_context65.prev = _context65.next) {\n case 0:\n _context65.t0 = function __PRIVATE_localStoreDeleteAllFieldIndexes(e) {\n var t = __PRIVATE_debugCast(e),\n n = t.indexManager;\n\n return t.persistence.runTransaction(\"Delete All Indexes\", \"readwrite\", function (e) {\n return n.deleteAllFieldIndexes(e);\n });\n }\n /**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // The format of the LocalStorage key that stores the client state is:\n // firestore_clients__\n ;\n\n _context65.next = 3;\n return __PRIVATE_getLocalStore(e);\n\n case 3:\n _context65.t1 = _context65.sent;\n return _context65.abrupt(\"return\", (0, _context65.t0)(_context65.t1));\n\n case 5:\n case \"end\":\n return _context65.stop();\n }\n }\n }, _callee65);\n })));\n}\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Compares two `ExperimentalLongPollingOptions` objects for equality.\n */\n\n/**\n * Creates and returns a new `ExperimentalLongPollingOptions` with the same\n * option values as the given instance.\n */\n\n\nfunction __PRIVATE_cloneLongPollingOptions(e) {\n var t = {};\n return void 0 !== e.timeoutSeconds && (t.timeoutSeconds = e.timeoutSeconds), t;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar me = new Map();\n/**\n * An instance map that ensures only one Datastore exists per Firestore\n * instance.\n */\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nfunction __PRIVATE_validateNonEmptyArgument(e, t, n) {\n if (!n) throw new FirestoreError(D.INVALID_ARGUMENT, \"Function \".concat(e, \"() cannot be called with an empty \").concat(t, \".\"));\n}\n/**\n * Validates that two boolean options are not set at the same time.\n * @internal\n */\n\n\nfunction __PRIVATE_validateIsNotUsedTogether(e, t, n, r) {\n if (!0 === t && !0 === r) throw new FirestoreError(D.INVALID_ARGUMENT, \"\".concat(e, \" and \").concat(n, \" cannot be used together.\"));\n}\n/**\n * Validates that `path` refers to a document (indicated by the fact it contains\n * an even numbers of segments).\n */\n\n\nfunction __PRIVATE_validateDocumentPath(e) {\n if (!DocumentKey.isDocumentKey(e)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid document reference. Document references must have an even number of segments, but \".concat(e, \" has \").concat(e.length, \".\"));\n}\n/**\n * Validates that `path` refers to a collection (indicated by the fact it\n * contains an odd numbers of segments).\n */\n\n\nfunction __PRIVATE_validateCollectionPath(e) {\n if (DocumentKey.isDocumentKey(e)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid collection reference. Collection references must have an odd number of segments, but \".concat(e, \" has \").concat(e.length, \".\"));\n}\n/**\n * Returns true if it's a non-null object without a custom prototype\n * (i.e. excludes Array, Date, etc.).\n */\n\n/** Returns a string describing the type / value of the provided input. */\n\n\nfunction __PRIVATE_valueDescription(e) {\n if (void 0 === e) return \"undefined\";\n if (null === e) return \"null\";\n if (\"string\" == typeof e) return e.length > 20 && (e = \"\".concat(e.substring(0, 20), \"...\")), JSON.stringify(e);\n if (\"number\" == typeof e || \"boolean\" == typeof e) return \"\" + e;\n\n if (\"object\" == typeof e) {\n if (e instanceof Array) return \"an array\";\n {\n var t =\n /** try to get the constructor name for an object. */\n function __PRIVATE_tryGetCustomObjectType(e) {\n if (e.constructor) return e.constructor.name;\n return null;\n }\n /**\n * Casts `obj` to `T`, optionally unwrapping Compat types to expose the\n * underlying instance. Throws if `obj` is not an instance of `T`.\n *\n * This cast is used in the Lite and Full SDK to verify instance types for\n * arguments passed to the public API.\n * @internal\n */\n (e);\n\n return t ? \"a custom \".concat(t, \" object\") : \"an object\";\n }\n }\n\n return \"function\" == typeof e ? \"a function\" : fail();\n}\n\nfunction __PRIVATE_cast(e, // eslint-disable-next-line @typescript-eslint/no-explicit-any\nt) {\n if (\"_delegate\" in e && ( // Unwrap Compat types\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n e = e._delegate), !(e instanceof t)) {\n if (t.name === e.constructor.name) throw new FirestoreError(D.INVALID_ARGUMENT, \"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?\");\n {\n var n = __PRIVATE_valueDescription(e);\n\n throw new FirestoreError(D.INVALID_ARGUMENT, \"Expected type '\".concat(t.name, \"', but it was: \").concat(n));\n }\n }\n\n return e;\n}\n\nfunction __PRIVATE_validatePositiveNumber(e, t) {\n if (t <= 0) throw new FirestoreError(D.INVALID_ARGUMENT, \"Function \".concat(e, \"() requires a positive number, but it was: \").concat(t, \".\"));\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// settings() defaults:\n\n/**\n * A concrete type describing all the values that can be applied via a\n * user-supplied `FirestoreSettings` object. This is a separate type so that\n * defaults can be supplied and the value can be checked for equality.\n */\n\n\nvar FirestoreSettingsImpl = /*#__PURE__*/function () {\n function FirestoreSettingsImpl(e) {\n _classCallCheck(this, FirestoreSettingsImpl);\n\n var t, n;\n\n if (void 0 === e.host) {\n if (void 0 !== e.ssl) throw new FirestoreError(D.INVALID_ARGUMENT, \"Can't provide ssl option if host option is not set\");\n this.host = \"firestore.googleapis.com\", this.ssl = true;\n } else this.host = e.host, this.ssl = null === (t = e.ssl) || void 0 === t || t;\n\n if (this.credentials = e.credentials, this.ignoreUndefinedProperties = !!e.ignoreUndefinedProperties, this.localCache = e.localCache, void 0 === e.cacheSizeBytes) this.cacheSizeBytes = 41943040;else {\n if (-1 !== e.cacheSizeBytes && e.cacheSizeBytes < 1048576) throw new FirestoreError(D.INVALID_ARGUMENT, \"cacheSizeBytes must be at least 1048576\");\n this.cacheSizeBytes = e.cacheSizeBytes;\n }\n __PRIVATE_validateIsNotUsedTogether(\"experimentalForceLongPolling\", e.experimentalForceLongPolling, \"experimentalAutoDetectLongPolling\", e.experimentalAutoDetectLongPolling), this.experimentalForceLongPolling = !!e.experimentalForceLongPolling, this.experimentalForceLongPolling ? this.experimentalAutoDetectLongPolling = !1 : void 0 === e.experimentalAutoDetectLongPolling ? this.experimentalAutoDetectLongPolling = true : // For backwards compatibility, coerce the value to boolean even though\n // the TypeScript compiler has narrowed the type to boolean already.\n // noinspection PointlessBooleanExpressionJS\n this.experimentalAutoDetectLongPolling = !!e.experimentalAutoDetectLongPolling, this.experimentalLongPollingOptions = __PRIVATE_cloneLongPollingOptions(null !== (n = e.experimentalLongPollingOptions) && void 0 !== n ? n : {}), function __PRIVATE_validateLongPollingOptions(e) {\n if (void 0 !== e.timeoutSeconds) {\n if (isNaN(e.timeoutSeconds)) throw new FirestoreError(D.INVALID_ARGUMENT, \"invalid long polling timeout: \".concat(e.timeoutSeconds, \" (must not be NaN)\"));\n if (e.timeoutSeconds < 5) throw new FirestoreError(D.INVALID_ARGUMENT, \"invalid long polling timeout: \".concat(e.timeoutSeconds, \" (minimum allowed value is 5)\"));\n if (e.timeoutSeconds > 30) throw new FirestoreError(D.INVALID_ARGUMENT, \"invalid long polling timeout: \".concat(e.timeoutSeconds, \" (maximum allowed value is 30)\"));\n }\n }\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n /**\n * The Cloud Firestore service interface.\n *\n * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.\n */\n (this.experimentalLongPollingOptions), this.useFetchStreams = !!e.useFetchStreams;\n }\n\n _createClass(FirestoreSettingsImpl, [{\n key: \"isEqual\",\n value: function isEqual(e) {\n return this.host === e.host && this.ssl === e.ssl && this.credentials === e.credentials && this.cacheSizeBytes === e.cacheSizeBytes && this.experimentalForceLongPolling === e.experimentalForceLongPolling && this.experimentalAutoDetectLongPolling === e.experimentalAutoDetectLongPolling && function __PRIVATE_longPollingOptionsEqual(e, t) {\n return e.timeoutSeconds === t.timeoutSeconds;\n }(this.experimentalLongPollingOptions, e.experimentalLongPollingOptions) && this.ignoreUndefinedProperties === e.ignoreUndefinedProperties && this.useFetchStreams === e.useFetchStreams;\n }\n }]);\n\n return FirestoreSettingsImpl;\n}();\n\nvar Firestore$1 = /*#__PURE__*/function () {\n /** @hideconstructor */\n function Firestore$1(e, t, n, r) {\n _classCallCheck(this, Firestore$1);\n\n this._authCredentials = e, this._appCheckCredentials = t, this._databaseId = n, this._app = r,\n /**\n * Whether it's a Firestore or Firestore Lite instance.\n */\n this.type = \"firestore-lite\", this._persistenceKey = \"(lite)\", this._settings = new FirestoreSettingsImpl({}), this._settingsFrozen = !1;\n }\n /**\n * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service\n * instance.\n */\n\n\n _createClass(Firestore$1, [{\n key: \"app\",\n get: function get() {\n if (!this._app) throw new FirestoreError(D.FAILED_PRECONDITION, \"Firestore was not initialized using the Firebase SDK. 'app' is not available\");\n return this._app;\n }\n }, {\n key: \"_initialized\",\n get: function get() {\n return this._settingsFrozen;\n }\n }, {\n key: \"_terminated\",\n get: function get() {\n return void 0 !== this._terminateTask;\n }\n }, {\n key: \"_setSettings\",\n value: function _setSettings(e) {\n if (this._settingsFrozen) throw new FirestoreError(D.FAILED_PRECONDITION, \"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.\");\n this._settings = new FirestoreSettingsImpl(e), void 0 !== e.credentials && (this._authCredentials = function __PRIVATE_makeAuthCredentialsProvider(e) {\n if (!e) return new __PRIVATE_EmptyAuthCredentialsProvider();\n\n switch (e.type) {\n case \"firstParty\":\n return new __PRIVATE_FirstPartyAuthCredentialsProvider(e.sessionIndex || \"0\", e.iamToken || null, e.authTokenFactory || null);\n\n case \"provider\":\n return e.client;\n\n default:\n throw new FirestoreError(D.INVALID_ARGUMENT, \"makeAuthCredentialsProvider failed due to invalid credential type\");\n }\n }(e.credentials));\n }\n }, {\n key: \"_getSettings\",\n value: function _getSettings() {\n return this._settings;\n }\n }, {\n key: \"_freezeSettings\",\n value: function _freezeSettings() {\n return this._settingsFrozen = !0, this._settings;\n }\n }, {\n key: \"_delete\",\n value: function _delete() {\n return this._terminateTask || (this._terminateTask = this._terminate()), this._terminateTask;\n }\n /** Returns a JSON-serializable representation of this `Firestore` instance. */\n\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n app: this._app,\n databaseId: this._databaseId,\n settings: this._settings\n };\n }\n /**\n * Terminates all components used by this client. Subclasses can override\n * this method to clean up their own dependencies, but must also call this\n * method.\n *\n * Only ever called once.\n */\n\n }, {\n key: \"_terminate\",\n value: function _terminate() {\n /**\n * Removes all components associated with the provided instance. Must be called\n * when the `Firestore` instance is terminated.\n */\n return function __PRIVATE_removeComponents(e) {\n var t = me.get(e);\n t && (__PRIVATE_logDebug(\"ComponentProvider\", \"Removing Datastore\"), me.delete(e), t.terminate());\n }(this), Promise.resolve();\n }\n }]);\n\n return Firestore$1;\n}();\n/**\n * Modify this instance to communicate with the Cloud Firestore emulator.\n *\n * Note: This must be called before this instance has been used to do any\n * operations.\n *\n * @param firestore - The `Firestore` instance to configure to connect to the\n * emulator.\n * @param host - the emulator host (ex: localhost).\n * @param port - the emulator port (ex: 9000).\n * @param options.mockUserToken - the mock auth token to use for unit testing\n * Security Rules.\n */\n\n\nfunction connectFirestoreEmulator(e, t, n) {\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var i;\n\n var s = (e = __PRIVATE_cast(e, Firestore$1))._getSettings(),\n o = \"\".concat(t, \":\").concat(n);\n\n if (\"firestore.googleapis.com\" !== s.host && s.host !== o && __PRIVATE_logWarn(\"Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.\"), e._setSettings(Object.assign(Object.assign({}, s), {\n host: o,\n ssl: !1\n })), r.mockUserToken) {\n var _t49, _n29;\n\n if (\"string\" == typeof r.mockUserToken) _t49 = r.mockUserToken, _n29 = User.MOCK_USER;else {\n // Let createMockUserToken validate first (catches common mistakes like\n // invalid field \"uid\" and missing field \"sub\" / \"user_id\".)\n _t49 = createMockUserToken(r.mockUserToken, null === (i = e._app) || void 0 === i ? void 0 : i.options.projectId);\n\n var _s8 = r.mockUserToken.sub || r.mockUserToken.user_id;\n\n if (!_s8) throw new FirestoreError(D.INVALID_ARGUMENT, \"mockUserToken must contain 'sub' or 'user_id' field!\");\n _n29 = new User(_s8);\n }\n e._authCredentials = new __PRIVATE_EmulatorAuthCredentialsProvider(new __PRIVATE_OAuthToken(_t49, _n29));\n }\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A `Query` refers to a query which you can read or listen to. You can also\n * construct refined `Query` objects by adding filters and ordering.\n */\n\n\nvar Query = /*#__PURE__*/function () {\n // This is the lite version of the Query class in the main SDK.\n\n /** @hideconstructor protected */\n function Query(e,\n /**\n * If provided, the `FirestoreDataConverter` associated with this instance.\n */\n t, n) {\n _classCallCheck(this, Query);\n\n this.converter = t, this._query = n,\n /** The type of this Firestore reference. */\n this.type = \"query\", this.firestore = e;\n }\n\n _createClass(Query, [{\n key: \"withConverter\",\n value: function withConverter(e) {\n return new Query(this.firestore, e, this._query);\n }\n }]);\n\n return Query;\n}();\n/**\n * A `DocumentReference` refers to a document location in a Firestore database\n * and can be used to write, read, or listen to the location. The document at\n * the referenced location may or may not exist.\n */\n\n\nvar DocumentReference = /*#__PURE__*/function () {\n /** @hideconstructor */\n function DocumentReference(e,\n /**\n * If provided, the `FirestoreDataConverter` associated with this instance.\n */\n t, n) {\n _classCallCheck(this, DocumentReference);\n\n this.converter = t, this._key = n,\n /** The type of this Firestore reference. */\n this.type = \"document\", this.firestore = e;\n }\n\n _createClass(DocumentReference, [{\n key: \"_path\",\n get: function get() {\n return this._key.path;\n }\n /**\n * The document's identifier within its collection.\n */\n\n }, {\n key: \"id\",\n get: function get() {\n return this._key.path.lastSegment();\n }\n /**\n * A string representing the path of the referenced document (relative\n * to the root of the database).\n */\n\n }, {\n key: \"path\",\n get: function get() {\n return this._key.path.canonicalString();\n }\n /**\n * The collection this `DocumentReference` belongs to.\n */\n\n }, {\n key: \"parent\",\n get: function get() {\n return new CollectionReference(this.firestore, this.converter, this._key.path.popLast());\n }\n }, {\n key: \"withConverter\",\n value: function withConverter(e) {\n return new DocumentReference(this.firestore, e, this._key);\n }\n }]);\n\n return DocumentReference;\n}();\n/**\n * A `CollectionReference` object can be used for adding documents, getting\n * document references, and querying for documents (using {@link (query:1)}).\n */\n\n\nvar CollectionReference = /*#__PURE__*/function (_Query) {\n _inherits(CollectionReference, _Query);\n\n var _super35 = _createSuper(CollectionReference);\n\n /** @hideconstructor */\n function CollectionReference(e, t, n) {\n var _this198;\n\n _classCallCheck(this, CollectionReference);\n\n _this198 = _super35.call(this, e, t, __PRIVATE_newQueryForPath(n)), _this198._path = n,\n /** The type of this Firestore reference. */\n _this198.type = \"collection\";\n return _this198;\n }\n /** The collection's identifier. */\n\n\n _createClass(CollectionReference, [{\n key: \"id\",\n get: function get() {\n return this._query.path.lastSegment();\n }\n /**\n * A string representing the path of the referenced collection (relative\n * to the root of the database).\n */\n\n }, {\n key: \"path\",\n get: function get() {\n return this._query.path.canonicalString();\n }\n /**\n * A reference to the containing `DocumentReference` if this is a\n * subcollection. If this isn't a subcollection, the reference is null.\n */\n\n }, {\n key: \"parent\",\n get: function get() {\n var e = this._path.popLast();\n\n return e.isEmpty() ? null : new DocumentReference(this.firestore,\n /* converter= */\n null, new DocumentKey(e));\n }\n }, {\n key: \"withConverter\",\n value: function withConverter(e) {\n return new CollectionReference(this.firestore, e, this._path);\n }\n }]);\n\n return CollectionReference;\n}(Query);\n\nfunction collection(e, t) {\n for (var _len7 = arguments.length, n = new Array(_len7 > 2 ? _len7 - 2 : 0), _key7 = 2; _key7 < _len7; _key7++) {\n n[_key7 - 2] = arguments[_key7];\n }\n\n if (e = getModularInstance(e), __PRIVATE_validateNonEmptyArgument(\"collection\", \"path\", t), e instanceof Firestore$1) {\n var r = ResourcePath.fromString.apply(ResourcePath, [t].concat(n));\n return __PRIVATE_validateCollectionPath(r), new CollectionReference(e,\n /* converter= */\n null, r);\n }\n\n {\n if (!(e instanceof DocumentReference || e instanceof CollectionReference)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore\");\n\n var _r30 = e._path.child(ResourcePath.fromString.apply(ResourcePath, [t].concat(n)));\n\n return __PRIVATE_validateCollectionPath(_r30), new CollectionReference(e.firestore,\n /* converter= */\n null, _r30);\n }\n} // TODO(firestorelite): Consider using ErrorFactory -\n// https://github.com/firebase/firebase-js-sdk/blob/0131e1f/packages/util/src/errors.ts#L106\n\n/**\n * Creates and returns a new `Query` instance that includes all documents in the\n * database that are contained in a collection or subcollection with the\n * given `collectionId`.\n *\n * @param firestore - A reference to the root `Firestore` instance.\n * @param collectionId - Identifies the collections to query over. Every\n * collection or subcollection with this ID as the last segment of its path\n * will be included. Cannot contain a slash.\n * @returns The created `Query`.\n */\n\n\nfunction collectionGroup(e, t) {\n if (e = __PRIVATE_cast(e, Firestore$1), __PRIVATE_validateNonEmptyArgument(\"collectionGroup\", \"collection id\", t), t.indexOf(\"/\") >= 0) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid collection ID '\".concat(t, \"' passed to function collectionGroup(). Collection IDs must not contain '/'.\"));\n return new Query(e,\n /* converter= */\n null, function __PRIVATE_newQueryForCollectionGroup(e) {\n return new __PRIVATE_QueryImpl(ResourcePath.emptyPath(), e);\n }(t));\n}\n\nfunction doc(e, t) {\n for (var _len8 = arguments.length, n = new Array(_len8 > 2 ? _len8 - 2 : 0), _key8 = 2; _key8 < _len8; _key8++) {\n n[_key8 - 2] = arguments[_key8];\n }\n\n if (e = getModularInstance(e), // We allow omission of 'pathString' but explicitly prohibit passing in both\n // 'undefined' and 'null'.\n 1 === arguments.length && (t = __PRIVATE_AutoId.newId()), __PRIVATE_validateNonEmptyArgument(\"doc\", \"path\", t), e instanceof Firestore$1) {\n var r = ResourcePath.fromString.apply(ResourcePath, [t].concat(n));\n return __PRIVATE_validateDocumentPath(r), new DocumentReference(e,\n /* converter= */\n null, new DocumentKey(r));\n }\n\n {\n if (!(e instanceof DocumentReference || e instanceof CollectionReference)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore\");\n\n var _r31 = e._path.child(ResourcePath.fromString.apply(ResourcePath, [t].concat(n)));\n\n return __PRIVATE_validateDocumentPath(_r31), new DocumentReference(e.firestore, e instanceof CollectionReference ? e.converter : null, new DocumentKey(_r31));\n }\n}\n/**\n * Returns true if the provided references are equal.\n *\n * @param left - A reference to compare.\n * @param right - A reference to compare.\n * @returns true if the references point to the same location in the same\n * Firestore database.\n */\n\n\nfunction refEqual(e, t) {\n return e = getModularInstance(e), t = getModularInstance(t), (e instanceof DocumentReference || e instanceof CollectionReference) && (t instanceof DocumentReference || t instanceof CollectionReference) && e.firestore === t.firestore && e.path === t.path && e.converter === t.converter;\n}\n/**\n * Returns true if the provided queries point to the same collection and apply\n * the same constraints.\n *\n * @param left - A `Query` to compare.\n * @param right - A `Query` to compare.\n * @returns true if the references point to the same location in the same\n * Firestore database.\n */\n\n\nfunction queryEqual(e, t) {\n return e = getModularInstance(e), t = getModularInstance(t), e instanceof Query && t instanceof Query && e.firestore === t.firestore && __PRIVATE_queryEquals(e._query, t._query) && e.converter === t.converter;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar __PRIVATE_AsyncQueueImpl = /*#__PURE__*/function () {\n function __PRIVATE_AsyncQueueImpl() {\n var _this199 = this;\n\n _classCallCheck(this, __PRIVATE_AsyncQueueImpl);\n\n // The last promise in the queue.\n this.Xa = Promise.resolve(), // A list of retryable operations. Retryable operations are run in order and\n // retried with backoff.\n this.eu = [], // Is this AsyncQueue being shut down? Once it is set to true, it will not\n // be changed again.\n this.tu = !1, // Operations scheduled to be queued in the future. Operations are\n // automatically removed after they are run or canceled.\n this.nu = [], // visible for testing\n this.ru = null, // Flag set while there's an outstanding AsyncQueue operation, used for\n // assertion sanity-checks.\n this.iu = !1, // Enabled during shutdown on Safari to prevent future access to IndexedDB.\n this.su = !1, // List of TimerIds to fast-forward delays for.\n this.ou = [], // Backoff timer used to schedule retries for retryable operations\n this.jo = new __PRIVATE_ExponentialBackoff(this, \"async_queue_retry\"\n /* TimerId.AsyncQueueRetry */\n ), // Visibility handler that triggers an immediate retry of all retryable\n // operations. Meant to speed up recovery when we regain file system access\n // after page comes into foreground.\n this._u = function () {\n var e = getDocument();\n e && __PRIVATE_logDebug(\"AsyncQueue\", \"Visibility state changed to \" + e.visibilityState), _this199.jo.Ko();\n };\n var e = getDocument();\n e && \"function\" == typeof e.addEventListener && e.addEventListener(\"visibilitychange\", this._u);\n }\n\n _createClass(__PRIVATE_AsyncQueueImpl, [{\n key: \"isShuttingDown\",\n get: function get() {\n return this.tu;\n }\n /**\n * Adds a new operation to the queue without waiting for it to complete (i.e.\n * we ignore the Promise result).\n */\n\n }, {\n key: \"enqueueAndForget\",\n value: function enqueueAndForget(e) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.enqueue(e);\n }\n }, {\n key: \"enqueueAndForgetEvenWhileRestricted\",\n value: function enqueueAndForgetEvenWhileRestricted(e) {\n this.au(), // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.uu(e);\n }\n }, {\n key: \"enterRestrictedMode\",\n value: function enterRestrictedMode(e) {\n if (!this.tu) {\n this.tu = !0, this.su = e || !1;\n var t = getDocument();\n t && \"function\" == typeof t.removeEventListener && t.removeEventListener(\"visibilitychange\", this._u);\n }\n }\n }, {\n key: \"enqueue\",\n value: function enqueue(e) {\n var _this200 = this;\n\n if (this.au(), this.tu) // Return a Promise which never resolves.\n return new Promise(function () {}); // Create a deferred Promise that we can return to the callee. This\n // allows us to return a \"hanging Promise\" only to the callee and still\n // advance the queue even when the operation is not run.\n\n var t = new __PRIVATE_Deferred();\n return this.uu(function () {\n return _this200.tu && _this200.su ? Promise.resolve() : (e().then(t.resolve, t.reject), t.promise);\n }).then(function () {\n return t.promise;\n });\n }\n }, {\n key: \"enqueueRetryable\",\n value: function enqueueRetryable(e) {\n var _this201 = this;\n\n this.enqueueAndForget(function () {\n return _this201.eu.push(e), _this201.cu();\n });\n }\n /**\n * Runs the next operation from the retryable queue. If the operation fails,\n * reschedules with backoff.\n */\n\n }, {\n key: \"cu\",\n value: function () {\n var _cu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66() {\n var _this202 = this;\n\n return _regeneratorRuntime.wrap(function _callee66$(_context66) {\n while (1) {\n switch (_context66.prev = _context66.next) {\n case 0:\n if (!(0 !== this.eu.length)) {\n _context66.next = 14;\n break;\n }\n\n _context66.prev = 1;\n _context66.next = 4;\n return this.eu[0]();\n\n case 4:\n this.eu.shift();\n this.jo.reset();\n _context66.next = 13;\n break;\n\n case 8:\n _context66.prev = 8;\n _context66.t0 = _context66[\"catch\"](1);\n\n if (__PRIVATE_isIndexedDbTransactionError(_context66.t0)) {\n _context66.next = 12;\n break;\n }\n\n throw _context66.t0;\n\n case 12:\n // Failure will be handled by AsyncQueue\n __PRIVATE_logDebug(\"AsyncQueue\", \"Operation failed with retryable error: \" + _context66.t0);\n\n case 13:\n this.eu.length > 0 && // If there are additional operations, we re-schedule `retryNextOp()`.\n // This is necessary to run retryable operations that failed during\n // their initial attempt since we don't know whether they are already\n // enqueued. If, for example, `op1`, `op2`, `op3` are enqueued and `op1`\n // needs to be re-run, we will run `op1`, `op1`, `op2` using the\n // already enqueued calls to `retryNextOp()`. `op3()` will then run in the\n // call scheduled here.\n // Since `backoffAndRun()` cancels an existing backoff and schedules a\n // new backoff on every call, there is only ever a single additional\n // operation in the queue.\n this.jo.qo(function () {\n return _this202.cu();\n });\n\n case 14:\n case \"end\":\n return _context66.stop();\n }\n }\n }, _callee66, this, [[1, 8]]);\n }));\n\n function cu() {\n return _cu.apply(this, arguments);\n }\n\n return cu;\n }()\n }, {\n key: \"uu\",\n value: function uu(e) {\n var _this203 = this;\n\n var t = this.Xa.then(function () {\n return _this203.iu = !0, e().catch(function (e) {\n _this203.ru = e, _this203.iu = !1;\n\n var t =\n /**\n * Chrome includes Error.message in Error.stack. Other browsers do not.\n * This returns expected output of message + stack when available.\n * @param error - Error or FirestoreError\n */\n function __PRIVATE_getMessageOrStack(e) {\n var t = e.message || \"\";\n e.stack && (t = e.stack.includes(e.message) ? e.stack : e.message + \"\\n\" + e.stack);\n return t;\n }\n /**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n (e); // Re-throw the error so that this.tail becomes a rejected Promise and\n // all further attempts to chain (via .then) will just short-circuit\n // and return the rejected Promise.\n\n\n throw __PRIVATE_logError(\"INTERNAL UNHANDLED ERROR: \", t), e;\n }).then(function (e) {\n return _this203.iu = !1, e;\n });\n });\n return this.Xa = t, t;\n }\n }, {\n key: \"enqueueAfterDelay\",\n value: function enqueueAfterDelay(e, t, n) {\n var _this204 = this;\n\n this.au(), // Fast-forward delays for timerIds that have been overriden.\n this.ou.indexOf(e) > -1 && (t = 0);\n var r = DelayedOperation.createAndSchedule(this, e, t, n, function (e) {\n return _this204.lu(e);\n });\n return this.nu.push(r), r;\n }\n }, {\n key: \"au\",\n value: function au() {\n this.ru && fail();\n }\n }, {\n key: \"verifyOperationInProgress\",\n value: function verifyOperationInProgress() {}\n /**\n * Waits until all currently queued tasks are finished executing. Delayed\n * operations are not run.\n */\n\n }, {\n key: \"hu\",\n value: function () {\n var _hu = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee67() {\n var e;\n return _regeneratorRuntime.wrap(function _callee67$(_context67) {\n while (1) {\n switch (_context67.prev = _context67.next) {\n case 0:\n e = this.Xa;\n _context67.next = 3;\n return e;\n\n case 3:\n if (e !== this.Xa) {\n _context67.next = 0;\n break;\n }\n\n case 4:\n case \"end\":\n return _context67.stop();\n }\n }\n }, _callee67, this);\n }));\n\n function hu() {\n return _hu.apply(this, arguments);\n }\n\n return hu;\n }()\n /**\n * For Tests: Determine if a delayed operation with a particular TimerId\n * exists.\n */\n\n }, {\n key: \"Pu\",\n value: function Pu(e) {\n var _iterator75 = _createForOfIteratorHelper(this.nu),\n _step75;\n\n try {\n for (_iterator75.s(); !(_step75 = _iterator75.n()).done;) {\n var t = _step75.value;\n if (t.timerId === e) return !0;\n }\n } catch (err) {\n _iterator75.e(err);\n } finally {\n _iterator75.f();\n }\n\n return !1;\n }\n /**\n * For Tests: Runs some or all delayed operations early.\n *\n * @param lastTimerId - Delayed operations up to and including this TimerId\n * will be drained. Pass TimerId.All to run all delayed operations.\n * @returns a Promise that resolves once all operations have been run.\n */\n\n }, {\n key: \"Iu\",\n value: function Iu(e) {\n var _this205 = this;\n\n // Note that draining may generate more delayed ops, so we do that first.\n return this.hu().then(function () {\n // Run ops in the same order they'd run if they ran naturally.\n _this205.nu.sort(function (e, t) {\n return e.targetTimeMs - t.targetTimeMs;\n });\n\n var _iterator76 = _createForOfIteratorHelper(_this205.nu),\n _step76;\n\n try {\n for (_iterator76.s(); !(_step76 = _iterator76.n()).done;) {\n var t = _step76.value;\n if (t.skipDelay(), \"all\"\n /* TimerId.All */\n !== e && t.timerId === e) break;\n }\n } catch (err) {\n _iterator76.e(err);\n } finally {\n _iterator76.f();\n }\n\n return _this205.hu();\n });\n }\n /**\n * For Tests: Skip all subsequent delays for a timer id.\n */\n\n }, {\n key: \"Tu\",\n value: function Tu(e) {\n this.ou.push(e);\n }\n /** Called once a DelayedOperation is run or canceled. */\n\n }, {\n key: \"lu\",\n value: function lu(e) {\n // NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.\n var t = this.nu.indexOf(e);\n this.nu.splice(t, 1);\n }\n }]);\n\n return __PRIVATE_AsyncQueueImpl;\n}();\n\nfunction __PRIVATE_isPartialObserver(e) {\n /**\n * Returns true if obj is an object and contains at least one of the specified\n * methods.\n */\n return function __PRIVATE_implementsAnyMethods(e, t) {\n if (\"object\" != typeof e || null === e) return !1;\n var n = e;\n\n var _iterator77 = _createForOfIteratorHelper(t),\n _step77;\n\n try {\n for (_iterator77.s(); !(_step77 = _iterator77.n()).done;) {\n var _e102 = _step77.value;\n if (_e102 in n && \"function\" == typeof n[_e102]) return !0;\n }\n } catch (err) {\n _iterator77.e(err);\n } finally {\n _iterator77.f();\n }\n\n return !1;\n }\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n /**\n * Represents the task of loading a Firestore bundle. It provides progress of bundle\n * loading, as well as task completion and error events.\n *\n * The API is compatible with `Promise`.\n */\n (e, [\"next\", \"error\", \"complete\"]);\n}\n\nvar LoadBundleTask = /*#__PURE__*/function () {\n function LoadBundleTask() {\n _classCallCheck(this, LoadBundleTask);\n\n this._progressObserver = {}, this._taskCompletionResolver = new __PRIVATE_Deferred(), this._lastProgress = {\n taskState: \"Running\",\n totalBytes: 0,\n totalDocuments: 0,\n bytesLoaded: 0,\n documentsLoaded: 0\n };\n }\n /**\n * Registers functions to listen to bundle loading progress events.\n * @param next - Called when there is a progress update from bundle loading. Typically `next` calls occur\n * each time a Firestore document is loaded from the bundle.\n * @param error - Called when an error occurs during bundle loading. The task aborts after reporting the\n * error, and there should be no more updates after this.\n * @param complete - Called when the loading task is complete.\n */\n\n\n _createClass(LoadBundleTask, [{\n key: \"onProgress\",\n value: function onProgress(e, t, n) {\n this._progressObserver = {\n next: e,\n error: t,\n complete: n\n };\n }\n /**\n * Implements the `Promise.catch` interface.\n *\n * @param onRejected - Called when an error occurs during bundle loading.\n */\n\n }, {\n key: \"catch\",\n value: function _catch(e) {\n return this._taskCompletionResolver.promise.catch(e);\n }\n /**\n * Implements the `Promise.then` interface.\n *\n * @param onFulfilled - Called on the completion of the loading task with a final `LoadBundleTaskProgress` update.\n * The update will always have its `taskState` set to `\"Success\"`.\n * @param onRejected - Called when an error occurs during bundle loading.\n */\n\n }, {\n key: \"then\",\n value: function then(e, t) {\n return this._taskCompletionResolver.promise.then(e, t);\n }\n /**\n * Notifies all observers that bundle loading has completed, with a provided\n * `LoadBundleTaskProgress` object.\n *\n * @private\n */\n\n }, {\n key: \"_completeWith\",\n value: function _completeWith(e) {\n this._updateProgress(e), this._progressObserver.complete && this._progressObserver.complete(), this._taskCompletionResolver.resolve(e);\n }\n /**\n * Notifies all observers that bundle loading has failed, with a provided\n * `Error` as the reason.\n *\n * @private\n */\n\n }, {\n key: \"_failWith\",\n value: function _failWith(e) {\n this._lastProgress.taskState = \"Error\", this._progressObserver.next && this._progressObserver.next(this._lastProgress), this._progressObserver.error && this._progressObserver.error(e), this._taskCompletionResolver.reject(e);\n }\n /**\n * Notifies a progress update of loading a bundle.\n * @param progress - The new progress.\n *\n * @private\n */\n\n }, {\n key: \"_updateProgress\",\n value: function _updateProgress(e) {\n this._lastProgress = e, this._progressObserver.next && this._progressObserver.next(e);\n }\n }]);\n\n return LoadBundleTask;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Constant used to indicate the LRU garbage collection should be disabled.\n * Set this value as the `cacheSizeBytes` on the settings passed to the\n * {@link Firestore} instance.\n */\n\n\nvar fe = -1;\n/**\n * The Cloud Firestore service interface.\n *\n * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.\n */\n\nvar Firestore = /*#__PURE__*/function (_Firestore$) {\n _inherits(Firestore, _Firestore$);\n\n var _super36 = _createSuper(Firestore);\n\n /** @hideconstructor */\n function Firestore(e, t, n, r) {\n var _this206;\n\n _classCallCheck(this, Firestore);\n\n _this206 = _super36.call(this, e, t, n, r),\n /**\n * Whether it's a {@link Firestore} or Firestore Lite instance.\n */\n _this206.type = \"firestore\", _this206._queue = function __PRIVATE_newAsyncQueue() {\n return new __PRIVATE_AsyncQueueImpl();\n }(), _this206._persistenceKey = (null == r ? void 0 : r.name) || \"[DEFAULT]\";\n return _this206;\n }\n\n _createClass(Firestore, [{\n key: \"_terminate\",\n value: function _terminate() {\n return this._firestoreClient || // The client must be initialized to ensure that all subsequent API\n // usage throws an exception.\n __PRIVATE_configureFirestore(this), this._firestoreClient.terminate();\n }\n }]);\n\n return Firestore;\n}(Firestore$1);\n/**\n * Initializes a new instance of {@link Firestore} with the provided settings.\n * Can only be called before any other function, including\n * {@link (getFirestore:1)}. If the custom settings are empty, this function is\n * equivalent to calling {@link (getFirestore:1)}.\n *\n * @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will\n * be associated.\n * @param settings - A settings object to configure the {@link Firestore} instance.\n * @param databaseId - The name of the database.\n * @returns A newly initialized {@link Firestore} instance.\n */\n\n\nfunction initializeFirestore(e, t, n) {\n n || (n = \"(default)\");\n\n var r = _getProvider(e, \"firestore\");\n\n if (r.isInitialized(n)) {\n var _e103 = r.getImmediate({\n identifier: n\n }),\n i = r.getOptions(n);\n\n if (deepEqual(i, t)) return _e103;\n throw new FirestoreError(D.FAILED_PRECONDITION, \"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.\");\n }\n\n if (void 0 !== t.cacheSizeBytes && void 0 !== t.localCache) throw new FirestoreError(D.INVALID_ARGUMENT, \"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object\");\n if (void 0 !== t.cacheSizeBytes && -1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new FirestoreError(D.INVALID_ARGUMENT, \"cacheSizeBytes must be at least 1048576\");\n return r.initialize({\n options: t,\n instanceIdentifier: n\n });\n}\n\nfunction getFirestore(t, n) {\n var r = \"object\" == typeof t ? t : getApp(),\n i = \"string\" == typeof t ? t : n || \"(default)\",\n s = _getProvider(r, \"firestore\").getImmediate({\n identifier: i\n });\n\n if (!s._initialized) {\n var e = getDefaultEmulatorHostnameAndPort(\"firestore\");\n e && connectFirestoreEmulator.apply(void 0, [s].concat(_toConsumableArray(e)));\n }\n\n return s;\n}\n/**\n * @internal\n */\n\n\nfunction ensureFirestoreConfigured(e) {\n return e._firestoreClient || __PRIVATE_configureFirestore(e), e._firestoreClient.verifyNotTerminated(), e._firestoreClient;\n}\n\nfunction __PRIVATE_configureFirestore(e) {\n var t, n, r;\n\n var i = e._freezeSettings(),\n s = function __PRIVATE_makeDatabaseInfo(e, t, n, r) {\n return new DatabaseInfo(e, t, n, r.host, r.ssl, r.experimentalForceLongPolling, r.experimentalAutoDetectLongPolling, __PRIVATE_cloneLongPollingOptions(r.experimentalLongPollingOptions), r.useFetchStreams);\n }(e._databaseId, (null === (t = e._app) || void 0 === t ? void 0 : t.options.appId) || \"\", e._persistenceKey, i);\n\n e._firestoreClient = new FirestoreClient(e._authCredentials, e._appCheckCredentials, e._queue, s), (null === (n = i.localCache) || void 0 === n ? void 0 : n._offlineComponentProvider) && (null === (r = i.localCache) || void 0 === r ? void 0 : r._onlineComponentProvider) && (e._firestoreClient._uninitializedComponentsProvider = {\n _offlineKind: i.localCache.kind,\n _offline: i.localCache._offlineComponentProvider,\n _online: i.localCache._onlineComponentProvider\n });\n}\n/**\n * Attempts to enable persistent storage, if possible.\n *\n * On failure, `enableIndexedDbPersistence()` will reject the promise or\n * throw an exception. There are several reasons why this can fail, which can be\n * identified by the `code` on the error.\n *\n * * failed-precondition: The app is already open in another browser tab.\n * * unimplemented: The browser is incompatible with the offline persistence\n * implementation.\n *\n * Note that even after a failure, the {@link Firestore} instance will remain\n * usable, however offline persistence will be disabled.\n *\n * Note: `enableIndexedDbPersistence()` must be called before any other functions\n * (other than {@link initializeFirestore}, {@link (getFirestore:1)} or\n * {@link clearIndexedDbPersistence}.\n *\n * Persistence cannot be used in a Node.js environment.\n *\n * @param firestore - The {@link Firestore} instance to enable persistence for.\n * @param persistenceSettings - Optional settings object to configure\n * persistence.\n * @returns A `Promise` that represents successfully enabling persistent storage.\n * @deprecated This function will be removed in a future major release. Instead, set\n * `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to\n * turn on IndexedDb cache. Calling this function when `FirestoreSettings.localCache`\n * is already specified will throw an exception.\n */\n\n\nfunction enableIndexedDbPersistence(e, t) {\n __PRIVATE_verifyNotInitialized(e = __PRIVATE_cast(e, Firestore));\n\n var n = ensureFirestoreConfigured(e);\n if (n._uninitializedComponentsProvider) throw new FirestoreError(D.FAILED_PRECONDITION, \"SDK cache is already specified.\");\n\n __PRIVATE_logWarn(\"enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.\");\n\n var r = e._freezeSettings(),\n i = new OnlineComponentProvider();\n\n return __PRIVATE_setPersistenceProviders(n, i, new __PRIVATE_IndexedDbOfflineComponentProvider(i, r.cacheSizeBytes, null == t ? void 0 : t.forceOwnership));\n}\n/**\n * Attempts to enable multi-tab persistent storage, if possible. If enabled\n * across all tabs, all operations share access to local persistence, including\n * shared execution of queries and latency-compensated local document updates\n * across all connected instances.\n *\n * On failure, `enableMultiTabIndexedDbPersistence()` will reject the promise or\n * throw an exception. There are several reasons why this can fail, which can be\n * identified by the `code` on the error.\n *\n * * failed-precondition: The app is already open in another browser tab and\n * multi-tab is not enabled.\n * * unimplemented: The browser is incompatible with the offline persistence\n * implementation.\n *\n * Note that even after a failure, the {@link Firestore} instance will remain\n * usable, however offline persistence will be disabled.\n *\n * @param firestore - The {@link Firestore} instance to enable persistence for.\n * @returns A `Promise` that represents successfully enabling persistent\n * storage.\n * @deprecated This function will be removed in a future major release. Instead, set\n * `FirestoreSettings.localCache` to an instance of `PersistentLocalCache` to\n * turn on indexeddb cache. Calling this function when `FirestoreSettings.localCache`\n * is already specified will throw an exception.\n */\n\n\nfunction enableMultiTabIndexedDbPersistence(e) {\n __PRIVATE_verifyNotInitialized(e = __PRIVATE_cast(e, Firestore));\n\n var t = ensureFirestoreConfigured(e);\n if (t._uninitializedComponentsProvider) throw new FirestoreError(D.FAILED_PRECONDITION, \"SDK cache is already specified.\");\n\n __PRIVATE_logWarn(\"enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.\");\n\n var n = e._freezeSettings(),\n r = new OnlineComponentProvider();\n\n return __PRIVATE_setPersistenceProviders(t, r, new __PRIVATE_MultiTabOfflineComponentProvider(r, n.cacheSizeBytes));\n}\n/**\n * Registers both the `OfflineComponentProvider` and `OnlineComponentProvider`.\n * If the operation fails with a recoverable error (see\n * `canRecoverFromIndexedDbError()` below), the returned Promise is rejected\n * but the client remains usable.\n */\n\n\nfunction __PRIVATE_setPersistenceProviders(e, t, n) {\n var r = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee68() {\n var _t50;\n\n return _regeneratorRuntime.wrap(function _callee68$(_context68) {\n while (1) {\n switch (_context68.prev = _context68.next) {\n case 0:\n _context68.prev = 0;\n _context68.next = 3;\n return __PRIVATE_setOfflineComponentProvider(e, n);\n\n case 3:\n _context68.next = 5;\n return __PRIVATE_setOnlineComponentProvider(e, t);\n\n case 5:\n r.resolve();\n _context68.next = 14;\n break;\n\n case 8:\n _context68.prev = 8;\n _context68.t0 = _context68[\"catch\"](0);\n _t50 = _context68.t0;\n\n if (__PRIVATE_canFallbackFromIndexedDbError(_t50)) {\n _context68.next = 13;\n break;\n }\n\n throw _t50;\n\n case 13:\n __PRIVATE_logWarn(\"Error enabling indexeddb cache. Falling back to memory cache: \" + _t50), r.reject(_t50);\n\n case 14:\n case \"end\":\n return _context68.stop();\n }\n }\n }, _callee68, null, [[0, 8]]);\n }))).then(function () {\n return r.promise;\n });\n}\n/**\n * Clears the persistent storage. This includes pending writes and cached\n * documents.\n *\n * Must be called while the {@link Firestore} instance is not started (after the app is\n * terminated or when the app is first initialized). On startup, this function\n * must be called before other functions (other than {@link\n * initializeFirestore} or {@link (getFirestore:1)})). If the {@link Firestore}\n * instance is still running, the promise will be rejected with the error code\n * of `failed-precondition`.\n *\n * Note: `clearIndexedDbPersistence()` is primarily intended to help write\n * reliable tests that use Cloud Firestore. It uses an efficient mechanism for\n * dropping existing data but does not attempt to securely overwrite or\n * otherwise make cached data unrecoverable. For applications that are sensitive\n * to the disclosure of cached data in between user sessions, we strongly\n * recommend not enabling persistence at all.\n *\n * @param firestore - The {@link Firestore} instance to clear persistence for.\n * @returns A `Promise` that is resolved when the persistent storage is\n * cleared. Otherwise, the promise is rejected with an error.\n */\n\n\nfunction clearIndexedDbPersistence(e) {\n if (e._initialized && !e._terminated) throw new FirestoreError(D.FAILED_PRECONDITION, \"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.\");\n var t = new __PRIVATE_Deferred();\n return e._queue.enqueueAndForgetEvenWhileRestricted( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee70() {\n return _regeneratorRuntime.wrap(function _callee70$(_context70) {\n while (1) {\n switch (_context70.prev = _context70.next) {\n case 0:\n _context70.prev = 0;\n _context70.next = 3;\n return function () {\n var _PRIVATE_indexedDbClearPersistence = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee69(e) {\n var t;\n return _regeneratorRuntime.wrap(function _callee69$(_context69) {\n while (1) {\n switch (_context69.prev = _context69.next) {\n case 0:\n if (__PRIVATE_SimpleDb.D()) {\n _context69.next = 2;\n break;\n }\n\n return _context69.abrupt(\"return\", Promise.resolve());\n\n case 2:\n t = e + \"main\";\n _context69.next = 5;\n return __PRIVATE_SimpleDb.delete(t);\n\n case 5:\n case \"end\":\n return _context69.stop();\n }\n }\n }, _callee69);\n }));\n\n function __PRIVATE_indexedDbClearPersistence(_x138) {\n return _PRIVATE_indexedDbClearPersistence.apply(this, arguments);\n }\n\n return __PRIVATE_indexedDbClearPersistence;\n }()(__PRIVATE_indexedDbStoragePrefix(e._databaseId, e._persistenceKey));\n\n case 3:\n t.resolve();\n _context70.next = 9;\n break;\n\n case 6:\n _context70.prev = 6;\n _context70.t0 = _context70[\"catch\"](0);\n t.reject(_context70.t0);\n\n case 9:\n case \"end\":\n return _context70.stop();\n }\n }\n }, _callee70, null, [[0, 6]]);\n }))), t.promise;\n}\n/**\n * Waits until all currently pending writes for the active user have been\n * acknowledged by the backend.\n *\n * The returned promise resolves immediately if there are no outstanding writes.\n * Otherwise, the promise waits for all previously issued writes (including\n * those written in a previous app session), but it does not wait for writes\n * that were added after the function is called. If you want to wait for\n * additional writes, call `waitForPendingWrites()` again.\n *\n * Any outstanding `waitForPendingWrites()` promises are rejected during user\n * changes.\n *\n * @returns A `Promise` which resolves when all currently pending writes have been\n * acknowledged by the backend.\n */\n\n\nfunction waitForPendingWrites(e) {\n return function __PRIVATE_firestoreClientWaitForPendingWrites(e) {\n var t = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee71() {\n return _regeneratorRuntime.wrap(function _callee71$(_context71) {\n while (1) {\n switch (_context71.prev = _context71.next) {\n case 0:\n _context71.t0 = __PRIVATE_syncEngineRegisterPendingWritesCallback;\n _context71.next = 3;\n return __PRIVATE_getSyncEngine(e);\n\n case 3:\n _context71.t1 = _context71.sent;\n _context71.t2 = t;\n return _context71.abrupt(\"return\", (0, _context71.t0)(_context71.t1, _context71.t2));\n\n case 6:\n case \"end\":\n return _context71.stop();\n }\n }\n }, _callee71);\n }))), t.promise;\n }(ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore)));\n}\n/**\n * Re-enables use of the network for this {@link Firestore} instance after a prior\n * call to {@link disableNetwork}.\n *\n * @returns A `Promise` that is resolved once the network has been enabled.\n */\n\n\nfunction enableNetwork(e) {\n return __PRIVATE_firestoreClientEnableNetwork(ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore)));\n}\n/**\n * Disables network usage for this instance. It can be re-enabled via {@link\n * enableNetwork}. While the network is disabled, any snapshot listeners,\n * `getDoc()` or `getDocs()` calls will return results from cache, and any write\n * operations will be queued until the network is restored.\n *\n * @returns A `Promise` that is resolved once the network has been disabled.\n */\n\n\nfunction disableNetwork(e) {\n return __PRIVATE_firestoreClientDisableNetwork(ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore)));\n}\n/**\n * Terminates the provided {@link Firestore} instance.\n *\n * After calling `terminate()` only the `clearIndexedDbPersistence()` function\n * may be used. Any other function will throw a `FirestoreError`.\n *\n * To restart after termination, create a new instance of FirebaseFirestore with\n * {@link (getFirestore:1)}.\n *\n * Termination does not cancel any pending writes, and any promises that are\n * awaiting a response from the server will not be resolved. If you have\n * persistence enabled, the next time you start this instance, it will resume\n * sending these writes to the server.\n *\n * Note: Under normal circumstances, calling `terminate()` is not required. This\n * function is useful only when you want to force this instance to release all\n * of its resources or in combination with `clearIndexedDbPersistence()` to\n * ensure that all local state is destroyed between test runs.\n *\n * @returns A `Promise` that is resolved when the instance has been successfully\n * terminated.\n */\n\n\nfunction terminate(e) {\n return _removeServiceInstance(e.app, \"firestore\", e._databaseId.database), e._delete();\n}\n/**\n * Loads a Firestore bundle into the local cache.\n *\n * @param firestore - The {@link Firestore} instance to load bundles for.\n * @param bundleData - An object representing the bundle to be loaded. Valid\n * objects are `ArrayBuffer`, `ReadableStream` or `string`.\n *\n * @returns A `LoadBundleTask` object, which notifies callers with progress\n * updates, and completion or error events. It can be used as a\n * `Promise`.\n */\n\n\nfunction loadBundle(e, t) {\n var n = ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore)),\n r = new LoadBundleTask();\n return __PRIVATE_firestoreClientLoadBundle(n, e._databaseId, t, r), r;\n}\n/**\n * Reads a Firestore {@link Query} from local cache, identified by the given\n * name.\n *\n * The named queries are packaged into bundles on the server side (along\n * with resulting documents), and loaded to local cache using `loadBundle`. Once\n * in local cache, use this method to extract a {@link Query} by name.\n *\n * @param firestore - The {@link Firestore} instance to read the query from.\n * @param name - The name of the query.\n * @returns A `Promise` that is resolved with the Query or `null`.\n */\n\n\nfunction namedQuery(e, t) {\n return __PRIVATE_firestoreClientGetNamedQuery(ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore)), t).then(function (t) {\n return t ? new Query(e, null, t.query) : null;\n });\n}\n\nfunction __PRIVATE_verifyNotInitialized(e) {\n if (e._initialized || e._terminated) throw new FirestoreError(D.FAILED_PRECONDITION, \"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.\");\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Represents an aggregation that can be performed by Firestore.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\n\nvar AggregateField = /*#__PURE__*/_createClass(\n/**\n * Create a new AggregateField\n * @param aggregateType Specifies the type of aggregation operation to perform.\n * @param _internalFieldPath Optionally specifies the field that is aggregated.\n * @internal\n */\nfunction AggregateField() {\n var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"count\";\n var t = arguments.length > 1 ? arguments[1] : undefined;\n\n _classCallCheck(this, AggregateField);\n\n this._internalFieldPath = t,\n /** A type string to uniquely identify instances of this class. */\n this.type = \"AggregateField\", this.aggregateType = e;\n});\n/**\n * The results of executing an aggregation query.\n */\n\n\nvar AggregateQuerySnapshot = /*#__PURE__*/function () {\n /** @hideconstructor */\n function AggregateQuerySnapshot(e, t, n) {\n _classCallCheck(this, AggregateQuerySnapshot);\n\n this._userDataWriter = t, this._data = n,\n /** A type string to uniquely identify instances of this class. */\n this.type = \"AggregateQuerySnapshot\", this.query = e;\n }\n /**\n * Returns the results of the aggregations performed over the underlying\n * query.\n *\n * The keys of the returned object will be the same as those of the\n * `AggregateSpec` object specified to the aggregation method, and the values\n * will be the corresponding aggregation result.\n *\n * @returns The results of the aggregations performed over the underlying\n * query.\n */\n\n\n _createClass(AggregateQuerySnapshot, [{\n key: \"data\",\n value: function data() {\n return this._userDataWriter.convertObjectMap(this._data);\n }\n }]);\n\n return AggregateQuerySnapshot;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An immutable object representing an array of bytes.\n */\n\n\nvar Bytes = /*#__PURE__*/function () {\n /** @hideconstructor */\n function Bytes(e) {\n _classCallCheck(this, Bytes);\n\n this._byteString = e;\n }\n /**\n * Creates a new `Bytes` object from the given Base64 string, converting it to\n * bytes.\n *\n * @param base64 - The Base64 string used to create the `Bytes` object.\n */\n\n\n _createClass(Bytes, [{\n key: \"toBase64\",\n value:\n /**\n * Returns the underlying bytes as a Base64-encoded string.\n *\n * @returns The Base64-encoded string created from the `Bytes` object.\n */\n function toBase64() {\n return this._byteString.toBase64();\n }\n /**\n * Returns the underlying bytes in a new `Uint8Array`.\n *\n * @returns The Uint8Array created from the `Bytes` object.\n */\n\n }, {\n key: \"toUint8Array\",\n value: function toUint8Array() {\n return this._byteString.toUint8Array();\n }\n /**\n * Returns a string representation of the `Bytes` object.\n *\n * @returns A string representation of the `Bytes` object.\n */\n\n }, {\n key: \"toString\",\n value: function toString() {\n return \"Bytes(base64: \" + this.toBase64() + \")\";\n }\n /**\n * Returns true if this `Bytes` object is equal to the provided one.\n *\n * @param other - The `Bytes` object to compare against.\n * @returns true if this `Bytes` object is equal to the provided one.\n */\n\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return this._byteString.isEqual(e._byteString);\n }\n }], [{\n key: \"fromBase64String\",\n value: function fromBase64String(e) {\n try {\n return new Bytes(ByteString.fromBase64String(e));\n } catch (e) {\n throw new FirestoreError(D.INVALID_ARGUMENT, \"Failed to construct data from Base64 string: \" + e);\n }\n }\n /**\n * Creates a new `Bytes` object from the given Uint8Array.\n *\n * @param array - The Uint8Array used to create the `Bytes` object.\n */\n\n }, {\n key: \"fromUint8Array\",\n value: function fromUint8Array(e) {\n return new Bytes(ByteString.fromUint8Array(e));\n }\n }]);\n\n return Bytes;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A `FieldPath` refers to a field in a document. The path may consist of a\n * single field name (referring to a top-level field in the document), or a\n * list of field names (referring to a nested field in the document).\n *\n * Create a `FieldPath` by providing field names. If more than one field\n * name is provided, the path will point to a nested field in a document.\n */\n\n\nvar FieldPath = /*#__PURE__*/function () {\n /**\n * Creates a `FieldPath` from the provided field names. If more than one field\n * name is provided, the path will point to a nested field in a document.\n *\n * @param fieldNames - A list of field names.\n */\n function FieldPath() {\n _classCallCheck(this, FieldPath);\n\n for (var _len9 = arguments.length, e = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {\n e[_key9] = arguments[_key9];\n }\n\n for (var t = 0; t < e.length; ++t) {\n if (0 === e[t].length) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid field name at argument $(i + 1). Field names must not be empty.\");\n }\n\n this._internalPath = new FieldPath$1(e);\n }\n /**\n * Returns true if this `FieldPath` is equal to the provided one.\n *\n * @param other - The `FieldPath` to compare against.\n * @returns true if this `FieldPath` is equal to the provided one.\n */\n\n\n _createClass(FieldPath, [{\n key: \"isEqual\",\n value: function isEqual(e) {\n return this._internalPath.isEqual(e._internalPath);\n }\n }]);\n\n return FieldPath;\n}();\n/**\n * Returns a special sentinel `FieldPath` to refer to the ID of a document.\n * It can be used in queries to sort or filter by the document ID.\n */\n\n\nfunction documentId() {\n return new FieldPath(\"__name__\");\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Sentinel values that can be used when writing document fields with `set()`\n * or `update()`.\n */\n\n\nvar FieldValue = /*#__PURE__*/_createClass(\n/**\n * @param _methodName - The public API endpoint that returns this class.\n * @hideconstructor\n */\nfunction FieldValue(e) {\n _classCallCheck(this, FieldValue);\n\n this._methodName = e;\n});\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * An immutable object representing a geographic location in Firestore. The\n * location is represented as latitude/longitude pair.\n *\n * Latitude values are in the range of [-90, 90].\n * Longitude values are in the range of [-180, 180].\n */\n\n\nvar GeoPoint = /*#__PURE__*/function () {\n /**\n * Creates a new immutable `GeoPoint` object with the provided latitude and\n * longitude values.\n * @param latitude - The latitude as number between -90 and 90.\n * @param longitude - The longitude as number between -180 and 180.\n */\n function GeoPoint(e, t) {\n _classCallCheck(this, GeoPoint);\n\n if (!isFinite(e) || e < -90 || e > 90) throw new FirestoreError(D.INVALID_ARGUMENT, \"Latitude must be a number between -90 and 90, but was: \" + e);\n if (!isFinite(t) || t < -180 || t > 180) throw new FirestoreError(D.INVALID_ARGUMENT, \"Longitude must be a number between -180 and 180, but was: \" + t);\n this._lat = e, this._long = t;\n }\n /**\n * The latitude of this `GeoPoint` instance.\n */\n\n\n _createClass(GeoPoint, [{\n key: \"latitude\",\n get: function get() {\n return this._lat;\n }\n /**\n * The longitude of this `GeoPoint` instance.\n */\n\n }, {\n key: \"longitude\",\n get: function get() {\n return this._long;\n }\n /**\n * Returns true if this `GeoPoint` is equal to the provided one.\n *\n * @param other - The `GeoPoint` to compare against.\n * @returns true if this `GeoPoint` is equal to the provided one.\n */\n\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return this._lat === e._lat && this._long === e._long;\n }\n /** Returns a JSON-serializable representation of this GeoPoint. */\n\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n latitude: this._lat,\n longitude: this._long\n };\n }\n /**\n * Actually private to JS consumers of our API, so this function is prefixed\n * with an underscore.\n */\n\n }, {\n key: \"_compareTo\",\n value: function _compareTo(e) {\n return __PRIVATE_primitiveComparator(this._lat, e._lat) || __PRIVATE_primitiveComparator(this._long, e._long);\n }\n }]);\n\n return GeoPoint;\n}();\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar ge = /^__.*__$/;\n/** The result of parsing document data (e.g. for a setData call). */\n\nvar ParsedSetData = /*#__PURE__*/function () {\n function ParsedSetData(e, t, n) {\n _classCallCheck(this, ParsedSetData);\n\n this.data = e, this.fieldMask = t, this.fieldTransforms = n;\n }\n\n _createClass(ParsedSetData, [{\n key: \"toMutation\",\n value: function toMutation(e, t) {\n return null !== this.fieldMask ? new __PRIVATE_PatchMutation(e, this.data, this.fieldMask, t, this.fieldTransforms) : new __PRIVATE_SetMutation(e, this.data, t, this.fieldTransforms);\n }\n }]);\n\n return ParsedSetData;\n}();\n/** The result of parsing \"update\" data (i.e. for an updateData call). */\n\n\nvar ParsedUpdateData = /*#__PURE__*/function () {\n function ParsedUpdateData(e, // The fieldMask does not include document transforms.\n t, n) {\n _classCallCheck(this, ParsedUpdateData);\n\n this.data = e, this.fieldMask = t, this.fieldTransforms = n;\n }\n\n _createClass(ParsedUpdateData, [{\n key: \"toMutation\",\n value: function toMutation(e, t) {\n return new __PRIVATE_PatchMutation(e, this.data, this.fieldMask, t, this.fieldTransforms);\n }\n }]);\n\n return ParsedUpdateData;\n}();\n\nfunction __PRIVATE_isWrite(e) {\n switch (e) {\n case 0\n /* UserDataSource.Set */\n : // fall through\n\n case 2\n /* UserDataSource.MergeSet */\n : // fall through\n\n case 1\n /* UserDataSource.Update */\n :\n return !0;\n\n case 3\n /* UserDataSource.Argument */\n :\n case 4\n /* UserDataSource.ArrayArgument */\n :\n return !1;\n\n default:\n throw fail();\n }\n}\n/** A \"context\" object passed around while parsing user data. */\n\n\nvar __PRIVATE_ParseContextImpl = /*#__PURE__*/function () {\n /**\n * Initializes a ParseContext with the given source and path.\n *\n * @param settings - The settings for the parser.\n * @param databaseId - The database ID of the Firestore instance.\n * @param serializer - The serializer to use to generate the Value proto.\n * @param ignoreUndefinedProperties - Whether to ignore undefined properties\n * rather than throw.\n * @param fieldTransforms - A mutable list of field transforms encountered\n * while parsing the data.\n * @param fieldMask - A mutable list of field paths encountered while parsing\n * the data.\n *\n * TODO(b/34871131): We don't support array paths right now, so path can be\n * null to indicate the context represents any location within an array (in\n * which case certain features will not work and errors will be somewhat\n * compromised).\n */\n function __PRIVATE_ParseContextImpl(e, t, n, r, i, s) {\n _classCallCheck(this, __PRIVATE_ParseContextImpl);\n\n this.settings = e, this.databaseId = t, this.serializer = n, this.ignoreUndefinedProperties = r, // Minor hack: If fieldTransforms is undefined, we assume this is an\n // external call and we need to validate the entire path.\n void 0 === i && this.Eu(), this.fieldTransforms = i || [], this.fieldMask = s || [];\n }\n\n _createClass(__PRIVATE_ParseContextImpl, [{\n key: \"path\",\n get: function get() {\n return this.settings.path;\n }\n }, {\n key: \"du\",\n get: function get() {\n return this.settings.du;\n }\n /** Returns a new context with the specified settings overwritten. */\n\n }, {\n key: \"Au\",\n value: function Au(e) {\n return new __PRIVATE_ParseContextImpl(Object.assign(Object.assign({}, this.settings), e), this.databaseId, this.serializer, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);\n }\n }, {\n key: \"Ru\",\n value: function Ru(e) {\n var t;\n var n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e),\n r = this.Au({\n path: n,\n Vu: !1\n });\n return r.mu(e), r;\n }\n }, {\n key: \"fu\",\n value: function fu(e) {\n var t;\n var n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e),\n r = this.Au({\n path: n,\n Vu: !1\n });\n return r.Eu(), r;\n }\n }, {\n key: \"gu\",\n value: function gu(e) {\n // TODO(b/34871131): We don't support array paths right now; so make path\n // undefined.\n return this.Au({\n path: void 0,\n Vu: !0\n });\n }\n }, {\n key: \"pu\",\n value: function pu(e) {\n return __PRIVATE_createError(e, this.settings.methodName, this.settings.yu || !1, this.path, this.settings.wu);\n }\n /** Returns 'true' if 'fieldPath' was traversed when creating this context. */\n\n }, {\n key: \"contains\",\n value: function contains(e) {\n return void 0 !== this.fieldMask.find(function (t) {\n return e.isPrefixOf(t);\n }) || void 0 !== this.fieldTransforms.find(function (t) {\n return e.isPrefixOf(t.field);\n });\n }\n }, {\n key: \"Eu\",\n value: function Eu() {\n // TODO(b/34871131): Remove null check once we have proper paths for fields\n // within arrays.\n if (this.path) for (var e = 0; e < this.path.length; e++) {\n this.mu(this.path.get(e));\n }\n }\n }, {\n key: \"mu\",\n value: function mu(e) {\n if (0 === e.length) throw this.pu(\"Document fields must not be empty\");\n if (__PRIVATE_isWrite(this.du) && ge.test(e)) throw this.pu('Document fields cannot begin and end with \"__\"');\n }\n }]);\n\n return __PRIVATE_ParseContextImpl;\n}();\n/**\n * Helper for parsing raw user input (provided via the API) into internal model\n * classes.\n */\n\n\nvar __PRIVATE_UserDataReader = /*#__PURE__*/function () {\n function __PRIVATE_UserDataReader(e, t, n) {\n _classCallCheck(this, __PRIVATE_UserDataReader);\n\n this.databaseId = e, this.ignoreUndefinedProperties = t, this.serializer = n || __PRIVATE_newSerializer(e);\n }\n /** Creates a new top-level parse context. */\n\n\n _createClass(__PRIVATE_UserDataReader, [{\n key: \"Su\",\n value: function Su(e, t, n) {\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;\n return new __PRIVATE_ParseContextImpl({\n du: e,\n methodName: t,\n wu: n,\n path: FieldPath$1.emptyPath(),\n Vu: !1,\n yu: r\n }, this.databaseId, this.serializer, this.ignoreUndefinedProperties);\n }\n }]);\n\n return __PRIVATE_UserDataReader;\n}();\n\nfunction __PRIVATE_newUserDataReader(e) {\n var t = e._freezeSettings(),\n n = __PRIVATE_newSerializer(e._databaseId);\n\n return new __PRIVATE_UserDataReader(e._databaseId, !!t.ignoreUndefinedProperties, n);\n}\n/** Parse document data from a set() call. */\n\n\nfunction __PRIVATE_parseSetData(e, t, n, r, i) {\n var s = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n var o = e.Su(s.merge || s.mergeFields ? 2\n /* UserDataSource.MergeSet */\n : 0\n /* UserDataSource.Set */\n , t, n, i);\n\n __PRIVATE_validatePlainObject(\"Data must be an object, but it was:\", o, r);\n\n var _ = __PRIVATE_parseObject(r, o);\n\n var a, u;\n if (s.merge) a = new FieldMask(o.fieldMask), u = o.fieldTransforms;else if (s.mergeFields) {\n var _e104 = [];\n\n var _iterator78 = _createForOfIteratorHelper(s.mergeFields),\n _step78;\n\n try {\n for (_iterator78.s(); !(_step78 = _iterator78.n()).done;) {\n var _r32 = _step78.value;\n\n var _i17 = __PRIVATE_fieldPathFromArgument$1(t, _r32, n);\n\n if (!o.contains(_i17)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Field '\".concat(_i17, \"' is specified in your field mask but missing from your input data.\"));\n __PRIVATE_fieldMaskContains(_e104, _i17) || _e104.push(_i17);\n }\n } catch (err) {\n _iterator78.e(err);\n } finally {\n _iterator78.f();\n }\n\n a = new FieldMask(_e104), u = o.fieldTransforms.filter(function (e) {\n return a.covers(e.field);\n });\n } else a = null, u = o.fieldTransforms;\n return new ParsedSetData(new ObjectValue(_), a, u);\n}\n\nvar __PRIVATE_DeleteFieldValueImpl = /*#__PURE__*/function (_FieldValue) {\n _inherits(__PRIVATE_DeleteFieldValueImpl, _FieldValue);\n\n var _super37 = _createSuper(__PRIVATE_DeleteFieldValueImpl);\n\n function __PRIVATE_DeleteFieldValueImpl() {\n _classCallCheck(this, __PRIVATE_DeleteFieldValueImpl);\n\n return _super37.apply(this, arguments);\n }\n\n _createClass(__PRIVATE_DeleteFieldValueImpl, [{\n key: \"_toFieldTransform\",\n value: function _toFieldTransform(e) {\n if (2\n /* UserDataSource.MergeSet */\n !== e.du) throw 1\n /* UserDataSource.Update */\n === e.du ? e.pu(\"\".concat(this._methodName, \"() can only appear at the top level of your update data\")) : e.pu(\"\".concat(this._methodName, \"() cannot be used with set() unless you pass {merge:true}\")); // No transform to add for a delete, but we need to add it to our\n // fieldMask so it gets deleted.\n\n return e.fieldMask.push(e.path), null;\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e instanceof __PRIVATE_DeleteFieldValueImpl;\n }\n }]);\n\n return __PRIVATE_DeleteFieldValueImpl;\n}(FieldValue);\n/**\n * Creates a child context for parsing SerializableFieldValues.\n *\n * This is different than calling `ParseContext.contextWith` because it keeps\n * the fieldTransforms and fieldMask separate.\n *\n * The created context has its `dataSource` set to `UserDataSource.Argument`.\n * Although these values are used with writes, any elements in these FieldValues\n * are not considered writes since they cannot contain any FieldValue sentinels,\n * etc.\n *\n * @param fieldValue - The sentinel FieldValue for which to create a child\n * context.\n * @param context - The parent context.\n * @param arrayElement - Whether or not the FieldValue has an array.\n */\n\n\nfunction __PRIVATE_createSentinelChildContext(e, t, n) {\n return new __PRIVATE_ParseContextImpl({\n du: 3\n /* UserDataSource.Argument */\n ,\n wu: t.settings.wu,\n methodName: e._methodName,\n Vu: n\n }, t.databaseId, t.serializer, t.ignoreUndefinedProperties);\n}\n\nvar __PRIVATE_ServerTimestampFieldValueImpl = /*#__PURE__*/function (_FieldValue2) {\n _inherits(__PRIVATE_ServerTimestampFieldValueImpl, _FieldValue2);\n\n var _super38 = _createSuper(__PRIVATE_ServerTimestampFieldValueImpl);\n\n function __PRIVATE_ServerTimestampFieldValueImpl() {\n _classCallCheck(this, __PRIVATE_ServerTimestampFieldValueImpl);\n\n return _super38.apply(this, arguments);\n }\n\n _createClass(__PRIVATE_ServerTimestampFieldValueImpl, [{\n key: \"_toFieldTransform\",\n value: function _toFieldTransform(e) {\n return new FieldTransform(e.path, new __PRIVATE_ServerTimestampTransform());\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e instanceof __PRIVATE_ServerTimestampFieldValueImpl;\n }\n }]);\n\n return __PRIVATE_ServerTimestampFieldValueImpl;\n}(FieldValue);\n\nvar __PRIVATE_ArrayUnionFieldValueImpl = /*#__PURE__*/function (_FieldValue3) {\n _inherits(__PRIVATE_ArrayUnionFieldValueImpl, _FieldValue3);\n\n var _super39 = _createSuper(__PRIVATE_ArrayUnionFieldValueImpl);\n\n function __PRIVATE_ArrayUnionFieldValueImpl(e, t) {\n var _this207;\n\n _classCallCheck(this, __PRIVATE_ArrayUnionFieldValueImpl);\n\n _this207 = _super39.call(this, e), _this207.bu = t;\n return _this207;\n }\n\n _createClass(__PRIVATE_ArrayUnionFieldValueImpl, [{\n key: \"_toFieldTransform\",\n value: function _toFieldTransform(e) {\n var t = __PRIVATE_createSentinelChildContext(this, e,\n /*array=*/\n !0),\n n = this.bu.map(function (e) {\n return __PRIVATE_parseData(e, t);\n }),\n r = new __PRIVATE_ArrayUnionTransformOperation(n);\n\n return new FieldTransform(e.path, r);\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e instanceof __PRIVATE_ArrayUnionFieldValueImpl && deepEqual(this.bu, e.bu);\n }\n }]);\n\n return __PRIVATE_ArrayUnionFieldValueImpl;\n}(FieldValue);\n\nvar __PRIVATE_ArrayRemoveFieldValueImpl = /*#__PURE__*/function (_FieldValue4) {\n _inherits(__PRIVATE_ArrayRemoveFieldValueImpl, _FieldValue4);\n\n var _super40 = _createSuper(__PRIVATE_ArrayRemoveFieldValueImpl);\n\n function __PRIVATE_ArrayRemoveFieldValueImpl(e, t) {\n var _this208;\n\n _classCallCheck(this, __PRIVATE_ArrayRemoveFieldValueImpl);\n\n _this208 = _super40.call(this, e), _this208.bu = t;\n return _this208;\n }\n\n _createClass(__PRIVATE_ArrayRemoveFieldValueImpl, [{\n key: \"_toFieldTransform\",\n value: function _toFieldTransform(e) {\n var t = __PRIVATE_createSentinelChildContext(this, e,\n /*array=*/\n !0),\n n = this.bu.map(function (e) {\n return __PRIVATE_parseData(e, t);\n }),\n r = new __PRIVATE_ArrayRemoveTransformOperation(n);\n\n return new FieldTransform(e.path, r);\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e instanceof __PRIVATE_ArrayRemoveFieldValueImpl && deepEqual(this.bu, e.bu);\n }\n }]);\n\n return __PRIVATE_ArrayRemoveFieldValueImpl;\n}(FieldValue);\n\nvar __PRIVATE_NumericIncrementFieldValueImpl = /*#__PURE__*/function (_FieldValue5) {\n _inherits(__PRIVATE_NumericIncrementFieldValueImpl, _FieldValue5);\n\n var _super41 = _createSuper(__PRIVATE_NumericIncrementFieldValueImpl);\n\n function __PRIVATE_NumericIncrementFieldValueImpl(e, t) {\n var _this209;\n\n _classCallCheck(this, __PRIVATE_NumericIncrementFieldValueImpl);\n\n _this209 = _super41.call(this, e), _this209.Du = t;\n return _this209;\n }\n\n _createClass(__PRIVATE_NumericIncrementFieldValueImpl, [{\n key: \"_toFieldTransform\",\n value: function _toFieldTransform(e) {\n var t = new __PRIVATE_NumericIncrementTransformOperation(e.serializer, toNumber(e.serializer, this.Du));\n return new FieldTransform(e.path, t);\n }\n }, {\n key: \"isEqual\",\n value: function isEqual(e) {\n return e instanceof __PRIVATE_NumericIncrementFieldValueImpl && this.Du === e.Du;\n }\n }]);\n\n return __PRIVATE_NumericIncrementFieldValueImpl;\n}(FieldValue);\n/** Parse update data from an update() call. */\n\n\nfunction __PRIVATE_parseUpdateData(e, t, n, r) {\n var i = e.Su(1\n /* UserDataSource.Update */\n , t, n);\n\n __PRIVATE_validatePlainObject(\"Data must be an object, but it was:\", i, r);\n\n var s = [],\n o = ObjectValue.empty();\n\n _forEach(r, function (e, r) {\n var _ = __PRIVATE_fieldPathFromDotSeparatedString(t, e, n); // For Compat types, we have to \"extract\" the underlying types before\n // performing validation.\n\n\n r = getModularInstance(r);\n var a = i.fu(_);\n if (r instanceof __PRIVATE_DeleteFieldValueImpl) // Add it to the field mask, but don't add anything to updateData.\n s.push(_);else {\n var _e105 = __PRIVATE_parseData(r, a);\n\n null != _e105 && (s.push(_), o.set(_, _e105));\n }\n });\n\n var _ = new FieldMask(s);\n\n return new ParsedUpdateData(o, _, i.fieldTransforms);\n}\n/** Parse update data from a list of field/value arguments. */\n\n\nfunction __PRIVATE_parseUpdateVarargs(e, t, n, r, i, s) {\n var o = e.Su(1\n /* UserDataSource.Update */\n , t, n),\n _ = [__PRIVATE_fieldPathFromArgument$1(t, r, n)],\n a = [i];\n if (s.length % 2 != 0) throw new FirestoreError(D.INVALID_ARGUMENT, \"Function \".concat(t, \"() needs to be called with an even number of arguments that alternate between field names and values.\"));\n\n for (var _e106 = 0; _e106 < s.length; _e106 += 2) {\n _.push(__PRIVATE_fieldPathFromArgument$1(t, s[_e106])), a.push(s[_e106 + 1]);\n }\n\n var u = [],\n c = ObjectValue.empty(); // We iterate in reverse order to pick the last value for a field if the\n // user specified the field multiple times.\n\n for (var _e107 = _.length - 1; _e107 >= 0; --_e107) {\n if (!__PRIVATE_fieldMaskContains(u, _[_e107])) {\n var _t51 = _[_e107];\n var _n30 = a[_e107]; // For Compat types, we have to \"extract\" the underlying types before\n // performing validation.\n\n _n30 = getModularInstance(_n30);\n\n var _r33 = o.fu(_t51);\n\n if (_n30 instanceof __PRIVATE_DeleteFieldValueImpl) // Add it to the field mask, but don't add anything to updateData.\n u.push(_t51);else {\n var _e108 = __PRIVATE_parseData(_n30, _r33);\n\n null != _e108 && (u.push(_t51), c.set(_t51, _e108));\n }\n }\n }\n\n var l = new FieldMask(u);\n return new ParsedUpdateData(c, l, o.fieldTransforms);\n}\n/**\n * Parse a \"query value\" (e.g. value in a where filter or a value in a cursor\n * bound).\n *\n * @param allowArrays - Whether the query value is an array that may directly\n * contain additional arrays (e.g. the operand of an `in` query).\n */\n\n\nfunction __PRIVATE_parseQueryValue(e, t, n) {\n var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;\n return __PRIVATE_parseData(n, e.Su(r ? 4\n /* UserDataSource.ArrayArgument */\n : 3\n /* UserDataSource.Argument */\n , t));\n}\n/**\n * Parses user data to Protobuf Values.\n *\n * @param input - Data to be parsed.\n * @param context - A context object representing the current path being parsed,\n * the source of the data being parsed, etc.\n * @returns The parsed value, or null if the value was a FieldValue sentinel\n * that should not be included in the resulting parsed data.\n */\n\n\nfunction __PRIVATE_parseData(e, t) {\n if (__PRIVATE_looksLikeJsonObject( // Unwrap the API type from the Compat SDK. This will return the API type\n // from firestore-exp.\n e = getModularInstance(e))) return __PRIVATE_validatePlainObject(\"Unsupported field value:\", t, e), __PRIVATE_parseObject(e, t);\n if (e instanceof FieldValue) // FieldValues usually parse into transforms (except deleteField())\n // in which case we do not want to include this field in our parsed data\n // (as doing so will overwrite the field directly prior to the transform\n // trying to transform it). So we don't add this location to\n // context.fieldMask and we return null as our parsing result.\n\n /**\n * \"Parses\" the provided FieldValueImpl, adding any necessary transforms to\n * context.fieldTransforms.\n */\n return function __PRIVATE_parseSentinelFieldValue(e, t) {\n // Sentinels are only supported with writes, and not within arrays.\n if (!__PRIVATE_isWrite(t.du)) throw t.pu(\"\".concat(e._methodName, \"() can only be used with update() and set()\"));\n if (!t.path) throw t.pu(\"\".concat(e._methodName, \"() is not currently supported inside arrays\"));\n\n var n = e._toFieldTransform(t);\n\n n && t.fieldTransforms.push(n);\n }\n /**\n * Helper to parse a scalar value (i.e. not an Object, Array, or FieldValue)\n *\n * @returns The parsed value\n */\n (e, t), null;\n if (void 0 === e && t.ignoreUndefinedProperties) // If the input is undefined it can never participate in the fieldMask, so\n // don't handle this below. If `ignoreUndefinedProperties` is false,\n // `parseScalarValue` will reject an undefined value.\n return null;\n\n if ( // If context.path is null we are inside an array and we don't support\n // field mask paths more granular than the top-level array.\n t.path && t.fieldMask.push(t.path), e instanceof Array) {\n // TODO(b/34871131): Include the path containing the array in the error\n // message.\n // In the case of IN queries, the parsed data is an array (representing\n // the set of values to be included for the IN query) that may directly\n // contain additional arrays (each representing an individual field\n // value), so we disable this validation.\n if (t.settings.Vu && 4\n /* UserDataSource.ArrayArgument */\n !== t.du) throw t.pu(\"Nested arrays are not supported\");\n return function __PRIVATE_parseArray(e, t) {\n var n = [];\n var r = 0;\n\n var _iterator79 = _createForOfIteratorHelper(e),\n _step79;\n\n try {\n for (_iterator79.s(); !(_step79 = _iterator79.n()).done;) {\n var i = _step79.value;\n\n var _e109 = __PRIVATE_parseData(i, t.gu(r));\n\n null == _e109 && ( // Just include nulls in the array for fields being replaced with a\n // sentinel.\n _e109 = {\n nullValue: \"NULL_VALUE\"\n }), n.push(_e109), r++;\n }\n } catch (err) {\n _iterator79.e(err);\n } finally {\n _iterator79.f();\n }\n\n return {\n arrayValue: {\n values: n\n }\n };\n }(e, t);\n }\n\n return function __PRIVATE_parseScalarValue(e, t) {\n if (null === (e = getModularInstance(e))) return {\n nullValue: \"NULL_VALUE\"\n };\n if (\"number\" == typeof e) return toNumber(t.serializer, e);\n if (\"boolean\" == typeof e) return {\n booleanValue: e\n };\n if (\"string\" == typeof e) return {\n stringValue: e\n };\n\n if (e instanceof Date) {\n var n = Timestamp.fromDate(e);\n return {\n timestampValue: toTimestamp(t.serializer, n)\n };\n }\n\n if (e instanceof Timestamp) {\n // Firestore backend truncates precision down to microseconds. To ensure\n // offline mode works the same with regards to truncation, perform the\n // truncation immediately without waiting for the backend to do that.\n var _n31 = new Timestamp(e.seconds, 1e3 * Math.floor(e.nanoseconds / 1e3));\n\n return {\n timestampValue: toTimestamp(t.serializer, _n31)\n };\n }\n\n if (e instanceof GeoPoint) return {\n geoPointValue: {\n latitude: e.latitude,\n longitude: e.longitude\n }\n };\n if (e instanceof Bytes) return {\n bytesValue: __PRIVATE_toBytes(t.serializer, e._byteString)\n };\n\n if (e instanceof DocumentReference) {\n var _n32 = t.databaseId,\n r = e.firestore._databaseId;\n if (!r.isEqual(_n32)) throw t.pu(\"Document reference is for database \".concat(r.projectId, \"/\").concat(r.database, \" but should be for database \").concat(_n32.projectId, \"/\").concat(_n32.database));\n return {\n referenceValue: __PRIVATE_toResourceName(e.firestore._databaseId || t.databaseId, e._key.path)\n };\n }\n\n throw t.pu(\"Unsupported field value: \".concat(__PRIVATE_valueDescription(e)));\n }\n /**\n * Checks whether an object looks like a JSON object that should be converted\n * into a struct. Normal class/prototype instances are considered to look like\n * JSON objects since they should be converted to a struct value. Arrays, Dates,\n * GeoPoints, etc. are not considered to look like JSON objects since they map\n * to specific FieldValue types other than ObjectValue.\n */\n (e, t);\n}\n\nfunction __PRIVATE_parseObject(e, t) {\n var n = {};\n return _isEmpty(e) ? // If we encounter an empty object, we explicitly add it to the update\n // mask to ensure that the server creates a map entry.\n t.path && t.path.length > 0 && t.fieldMask.push(t.path) : _forEach(e, function (e, r) {\n var i = __PRIVATE_parseData(r, t.Ru(e));\n\n null != i && (n[e] = i);\n }), {\n mapValue: {\n fields: n\n }\n };\n}\n\nfunction __PRIVATE_looksLikeJsonObject(e) {\n return !(\"object\" != typeof e || null === e || e instanceof Array || e instanceof Date || e instanceof Timestamp || e instanceof GeoPoint || e instanceof Bytes || e instanceof DocumentReference || e instanceof FieldValue);\n}\n\nfunction __PRIVATE_validatePlainObject(e, t, n) {\n if (!__PRIVATE_looksLikeJsonObject(n) || !function __PRIVATE_isPlainObject(e) {\n return \"object\" == typeof e && null !== e && (Object.getPrototypeOf(e) === Object.prototype || null === Object.getPrototypeOf(e));\n }(n)) {\n var r = __PRIVATE_valueDescription(n);\n\n throw \"an object\" === r ? t.pu(e + \" a custom object\") : t.pu(e + \" \" + r);\n }\n}\n/**\n * Helper that calls fromDotSeparatedString() but wraps any error thrown.\n */\n\n\nfunction __PRIVATE_fieldPathFromArgument$1(e, t, n) {\n if (( // If required, replace the FieldPath Compat class with with the firestore-exp\n // FieldPath.\n t = getModularInstance(t)) instanceof FieldPath) return t._internalPath;\n if (\"string\" == typeof t) return __PRIVATE_fieldPathFromDotSeparatedString(e, t);\n throw __PRIVATE_createError(\"Field path arguments must be of type string or \", e,\n /* hasConverter= */\n !1,\n /* path= */\n void 0, n);\n}\n/**\n * Matches any characters in a field path string that are reserved.\n */\n\n\nvar pe = new RegExp(\"[~\\\\*/\\\\[\\\\]]\");\n/**\n * Wraps fromDotSeparatedString with an error message about the method that\n * was thrown.\n * @param methodName - The publicly visible method name\n * @param path - The dot-separated string form of a field path which will be\n * split on dots.\n * @param targetDoc - The document against which the field path will be\n * evaluated.\n */\n\nfunction __PRIVATE_fieldPathFromDotSeparatedString(e, t, n) {\n if (t.search(pe) >= 0) throw __PRIVATE_createError(\"Invalid field path (\".concat(t, \"). Paths must not contain '~', '*', '/', '[', or ']'\"), e,\n /* hasConverter= */\n !1,\n /* path= */\n void 0, n);\n\n try {\n return _construct(FieldPath, _toConsumableArray(t.split(\".\")))._internalPath;\n } catch (r) {\n throw __PRIVATE_createError(\"Invalid field path (\".concat(t, \"). Paths must not be empty, begin with '.', end with '.', or contain '..'\"), e,\n /* hasConverter= */\n !1,\n /* path= */\n void 0, n);\n }\n}\n\nfunction __PRIVATE_createError(e, t, n, r, i) {\n var s = r && !r.isEmpty(),\n o = void 0 !== i;\n\n var _ = \"Function \".concat(t, \"() called with invalid data\");\n\n n && (_ += \" (via `toFirestore()`)\"), _ += \". \";\n var a = \"\";\n return (s || o) && (a += \" (found\", s && (a += \" in field \".concat(r)), o && (a += \" in document \".concat(i)), a += \")\"), new FirestoreError(D.INVALID_ARGUMENT, _ + e + a);\n}\n/** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */\n\n\nfunction __PRIVATE_fieldMaskContains(e, t) {\n return e.some(function (e) {\n return e.isEqual(t);\n });\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A `DocumentSnapshot` contains data read from a document in your Firestore\n * database. The data can be extracted with `.data()` or `.get()` to\n * get a specific field.\n *\n * For a `DocumentSnapshot` that points to a non-existing document, any data\n * access will return 'undefined'. You can use the `exists()` method to\n * explicitly verify a document's existence.\n */\n\n\nvar DocumentSnapshot$1 = /*#__PURE__*/function () {\n // Note: This class is stripped down version of the DocumentSnapshot in\n // the legacy SDK. The changes are:\n // - No support for SnapshotMetadata.\n // - No support for SnapshotOptions.\n\n /** @hideconstructor protected */\n function DocumentSnapshot$1(e, t, n, r, i) {\n _classCallCheck(this, DocumentSnapshot$1);\n\n this._firestore = e, this._userDataWriter = t, this._key = n, this._document = r, this._converter = i;\n }\n /** Property of the `DocumentSnapshot` that provides the document's ID. */\n\n\n _createClass(DocumentSnapshot$1, [{\n key: \"id\",\n get: function get() {\n return this._key.path.lastSegment();\n }\n /**\n * The `DocumentReference` for the document included in the `DocumentSnapshot`.\n */\n\n }, {\n key: \"ref\",\n get: function get() {\n return new DocumentReference(this._firestore, this._converter, this._key);\n }\n /**\n * Signals whether or not the document at the snapshot's location exists.\n *\n * @returns true if the document exists.\n */\n\n }, {\n key: \"exists\",\n value: function exists() {\n return null !== this._document;\n }\n /**\n * Retrieves all fields in the document as an `Object`. Returns `undefined` if\n * the document doesn't exist.\n *\n * @returns An `Object` containing all fields in the document or `undefined`\n * if the document doesn't exist.\n */\n\n }, {\n key: \"data\",\n value: function data() {\n if (this._document) {\n if (this._converter) {\n // We only want to use the converter and create a new DocumentSnapshot\n // if a converter has been provided.\n var e = new QueryDocumentSnapshot$1(this._firestore, this._userDataWriter, this._key, this._document,\n /* converter= */\n null);\n return this._converter.fromFirestore(e);\n }\n\n return this._userDataWriter.convertValue(this._document.data.value);\n }\n }\n /**\n * Retrieves the field specified by `fieldPath`. Returns `undefined` if the\n * document or field doesn't exist.\n *\n * @param fieldPath - The path (for example 'foo' or 'foo.bar') to a specific\n * field.\n * @returns The data at the specified field location or undefined if no such\n * field exists in the document.\n */\n // We are using `any` here to avoid an explicit cast by our users.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n }, {\n key: \"get\",\n value: function get(e) {\n if (this._document) {\n var t = this._document.data.field(__PRIVATE_fieldPathFromArgument(\"DocumentSnapshot.get\", e));\n\n if (null !== t) return this._userDataWriter.convertValue(t);\n }\n }\n }]);\n\n return DocumentSnapshot$1;\n}();\n/**\n * A `QueryDocumentSnapshot` contains data read from a document in your\n * Firestore database as part of a query. The document is guaranteed to exist\n * and its data can be extracted with `.data()` or `.get()` to get a\n * specific field.\n *\n * A `QueryDocumentSnapshot` offers the same API surface as a\n * `DocumentSnapshot`. Since query results contain only existing documents, the\n * `exists` property will always be true and `data()` will never return\n * 'undefined'.\n */\n\n\nvar QueryDocumentSnapshot$1 = /*#__PURE__*/function (_DocumentSnapshot$) {\n _inherits(QueryDocumentSnapshot$1, _DocumentSnapshot$);\n\n var _super42 = _createSuper(QueryDocumentSnapshot$1);\n\n function QueryDocumentSnapshot$1() {\n _classCallCheck(this, QueryDocumentSnapshot$1);\n\n return _super42.apply(this, arguments);\n }\n\n _createClass(QueryDocumentSnapshot$1, [{\n key: \"data\",\n value:\n /**\n * Retrieves all fields in the document as an `Object`.\n *\n * @override\n * @returns An `Object` containing all fields in the document.\n */\n function data() {\n return _get(_getPrototypeOf(QueryDocumentSnapshot$1.prototype), \"data\", this).call(this);\n }\n }]);\n\n return QueryDocumentSnapshot$1;\n}(DocumentSnapshot$1);\n/**\n * Helper that calls `fromDotSeparatedString()` but wraps any error thrown.\n */\n\n\nfunction __PRIVATE_fieldPathFromArgument(e, t) {\n return \"string\" == typeof t ? __PRIVATE_fieldPathFromDotSeparatedString(e, t) : t instanceof FieldPath ? t._internalPath : t._delegate._internalPath;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nfunction __PRIVATE_validateHasExplicitOrderByForLimitToLast(e) {\n if (\"L\"\n /* LimitType.Last */\n === e.limitType && 0 === e.explicitOrderBy.length) throw new FirestoreError(D.UNIMPLEMENTED, \"limitToLast() queries require specifying at least one orderBy() clause\");\n}\n/**\n * An `AppliableConstraint` is an abstraction of a constraint that can be applied\n * to a Firestore query.\n */\n\n\nvar AppliableConstraint = /*#__PURE__*/_createClass(function AppliableConstraint() {\n _classCallCheck(this, AppliableConstraint);\n});\n/**\n * A `QueryConstraint` is used to narrow the set of documents returned by a\n * Firestore query. `QueryConstraint`s are created by invoking {@link where},\n * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link\n * (endBefore:1)}, {@link (endAt:1)}, {@link limit}, {@link limitToLast} and\n * can then be passed to {@link (query:1)} to create a new query instance that\n * also contains this `QueryConstraint`.\n */\n\n\nvar QueryConstraint = /*#__PURE__*/function (_AppliableConstraint) {\n _inherits(QueryConstraint, _AppliableConstraint);\n\n var _super43 = _createSuper(QueryConstraint);\n\n function QueryConstraint() {\n _classCallCheck(this, QueryConstraint);\n\n return _super43.apply(this, arguments);\n }\n\n return _createClass(QueryConstraint);\n}(AppliableConstraint);\n\nfunction query(e, t) {\n var r = [];\n\n for (var _len10 = arguments.length, n = new Array(_len10 > 2 ? _len10 - 2 : 0), _key10 = 2; _key10 < _len10; _key10++) {\n n[_key10 - 2] = arguments[_key10];\n }\n\n t instanceof AppliableConstraint && r.push(t), r = r.concat(n), function __PRIVATE_validateQueryConstraintArray(e) {\n var t = e.filter(function (e) {\n return e instanceof QueryCompositeFilterConstraint;\n }).length,\n n = e.filter(function (e) {\n return e instanceof QueryFieldFilterConstraint;\n }).length;\n if (t > 1 || t > 0 && n > 0) throw new FirestoreError(D.INVALID_ARGUMENT, \"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.\");\n }\n /**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n /**\n * Converts Firestore's internal types to the JavaScript types that we expose\n * to the user.\n *\n * @internal\n */\n (r);\n\n var _iterator80 = _createForOfIteratorHelper(r),\n _step80;\n\n try {\n for (_iterator80.s(); !(_step80 = _iterator80.n()).done;) {\n var _t52 = _step80.value;\n e = _t52._apply(e);\n }\n } catch (err) {\n _iterator80.e(err);\n } finally {\n _iterator80.f();\n }\n\n return e;\n}\n/**\n * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by\n * a Firestore query by filtering on one or more document fields.\n * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then\n * be passed to {@link (query:1)} to create a new query instance that also contains\n * this `QueryFieldFilterConstraint`.\n */\n\n\nvar QueryFieldFilterConstraint = /*#__PURE__*/function (_QueryConstraint) {\n _inherits(QueryFieldFilterConstraint, _QueryConstraint);\n\n var _super44 = _createSuper(QueryFieldFilterConstraint);\n\n /**\n * @internal\n */\n function QueryFieldFilterConstraint(e, t, n) {\n var _this210;\n\n _classCallCheck(this, QueryFieldFilterConstraint);\n\n _this210 = _super44.call(this), _this210._field = e, _this210._op = t, _this210._value = n,\n /** The type of this query constraint */\n _this210.type = \"where\";\n return _this210;\n }\n\n _createClass(QueryFieldFilterConstraint, [{\n key: \"_apply\",\n value: function _apply(e) {\n var t = this._parse(e);\n\n return __PRIVATE_validateNewFieldFilter(e._query, t), new Query(e.firestore, e.converter, __PRIVATE_queryWithAddedFilter(e._query, t));\n }\n }, {\n key: \"_parse\",\n value: function _parse(e) {\n var t = __PRIVATE_newUserDataReader(e.firestore),\n n = function __PRIVATE_newQueryFilter(e, t, n, r, i, s, o) {\n var _;\n\n if (i.isKeyField()) {\n if (\"array-contains\"\n /* Operator.ARRAY_CONTAINS */\n === s || \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n === s) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid Query. You can't perform '\".concat(s, \"' queries on documentId().\"));\n\n if (\"in\"\n /* Operator.IN */\n === s || \"not-in\"\n /* Operator.NOT_IN */\n === s) {\n __PRIVATE_validateDisjunctiveFilterElements(o, s);\n\n var _t53 = [];\n\n var _iterator81 = _createForOfIteratorHelper(o),\n _step81;\n\n try {\n for (_iterator81.s(); !(_step81 = _iterator81.n()).done;) {\n var _n33 = _step81.value;\n\n _t53.push(__PRIVATE_parseDocumentIdValue(r, e, _n33));\n }\n } catch (err) {\n _iterator81.e(err);\n } finally {\n _iterator81.f();\n }\n\n _ = {\n arrayValue: {\n values: _t53\n }\n };\n } else _ = __PRIVATE_parseDocumentIdValue(r, e, o);\n } else \"in\"\n /* Operator.IN */\n !== s && \"not-in\"\n /* Operator.NOT_IN */\n !== s && \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n !== s || __PRIVATE_validateDisjunctiveFilterElements(o, s), _ = __PRIVATE_parseQueryValue(n, t, o,\n /* allowArrays= */\n \"in\"\n /* Operator.IN */\n === s || \"not-in\"\n /* Operator.NOT_IN */\n === s);\n\n return FieldFilter.create(i, s, _);\n }(e._query, \"where\", t, e.firestore._databaseId, this._field, this._op, this._value);\n\n return n;\n }\n }], [{\n key: \"_create\",\n value: function _create(e, t, n) {\n return new QueryFieldFilterConstraint(e, t, n);\n }\n }]);\n\n return QueryFieldFilterConstraint;\n}(QueryConstraint);\n/**\n * Creates a {@link QueryFieldFilterConstraint} that enforces that documents\n * must contain the specified field and that the value should satisfy the\n * relation constraint provided.\n *\n * @param fieldPath - The path to compare\n * @param opStr - The operation string (e.g \"<\", \"<=\", \"==\", \"<\",\n * \"<=\", \"!=\").\n * @param value - The value for comparison\n * @returns The created {@link QueryFieldFilterConstraint}.\n */\n\n\nfunction where(e, t, n) {\n var r = t,\n i = __PRIVATE_fieldPathFromArgument(\"where\", e);\n\n return QueryFieldFilterConstraint._create(i, r, n);\n}\n/**\n * A `QueryCompositeFilterConstraint` is used to narrow the set of documents\n * returned by a Firestore query by performing the logical OR or AND of multiple\n * {@link QueryFieldFilterConstraint}s or {@link QueryCompositeFilterConstraint}s.\n * `QueryCompositeFilterConstraint`s are created by invoking {@link or} or\n * {@link and} and can then be passed to {@link (query:1)} to create a new query\n * instance that also contains the `QueryCompositeFilterConstraint`.\n */\n\n\nvar QueryCompositeFilterConstraint = /*#__PURE__*/function (_AppliableConstraint2) {\n _inherits(QueryCompositeFilterConstraint, _AppliableConstraint2);\n\n var _super45 = _createSuper(QueryCompositeFilterConstraint);\n\n /**\n * @internal\n */\n function QueryCompositeFilterConstraint(\n /** The type of this query constraint */\n e, t) {\n var _this211;\n\n _classCallCheck(this, QueryCompositeFilterConstraint);\n\n _this211 = _super45.call(this), _this211.type = e, _this211._queryConstraints = t;\n return _this211;\n }\n\n _createClass(QueryCompositeFilterConstraint, [{\n key: \"_parse\",\n value: function _parse(e) {\n var t = this._queryConstraints.map(function (t) {\n return t._parse(e);\n }).filter(function (e) {\n return e.getFilters().length > 0;\n });\n\n return 1 === t.length ? t[0] : CompositeFilter.create(t, this._getOperator());\n }\n }, {\n key: \"_apply\",\n value: function _apply(e) {\n var t = this._parse(e);\n\n return 0 === t.getFilters().length ? e : (function __PRIVATE_validateNewFilter(e, t) {\n var n = e;\n var r = t.getFlattenedFilters();\n\n var _iterator82 = _createForOfIteratorHelper(r),\n _step82;\n\n try {\n for (_iterator82.s(); !(_step82 = _iterator82.n()).done;) {\n var _e110 = _step82.value;\n __PRIVATE_validateNewFieldFilter(n, _e110), n = __PRIVATE_queryWithAddedFilter(n, _e110);\n }\n } catch (err) {\n _iterator82.e(err);\n } finally {\n _iterator82.f();\n }\n } // Checks if any of the provided filter operators are included in the given list of filters and\n // returns the first one that is, or null if none are.\n (e._query, t), new Query(e.firestore, e.converter, __PRIVATE_queryWithAddedFilter(e._query, t)));\n }\n }, {\n key: \"_getQueryConstraints\",\n value: function _getQueryConstraints() {\n return this._queryConstraints;\n }\n }, {\n key: \"_getOperator\",\n value: function _getOperator() {\n return \"and\" === this.type ? \"and\"\n /* CompositeOperator.AND */\n : \"or\"\n /* CompositeOperator.OR */\n ;\n }\n }], [{\n key: \"_create\",\n value: function _create(e, t) {\n return new QueryCompositeFilterConstraint(e, t);\n }\n }]);\n\n return QueryCompositeFilterConstraint;\n}(AppliableConstraint);\n/**\n * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of\n * the given filter constraints. A disjunction filter includes a document if it\n * satisfies any of the given filters.\n *\n * @param queryConstraints - Optional. The list of\n * {@link QueryFilterConstraint}s to perform a disjunction for. These must be\n * created with calls to {@link where}, {@link or}, or {@link and}.\n * @returns The newly created {@link QueryCompositeFilterConstraint}.\n */\n\n\nfunction or() {\n for (var _len11 = arguments.length, e = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {\n e[_key11] = arguments[_key11];\n }\n\n // Only support QueryFilterConstraints\n return e.forEach(function (e) {\n return __PRIVATE_validateQueryFilterConstraint(\"or\", e);\n }), QueryCompositeFilterConstraint._create(\"or\"\n /* CompositeOperator.OR */\n , e);\n}\n/**\n * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of\n * the given filter constraints. A conjunction filter includes a document if it\n * satisfies all of the given filters.\n *\n * @param queryConstraints - Optional. The list of\n * {@link QueryFilterConstraint}s to perform a conjunction for. These must be\n * created with calls to {@link where}, {@link or}, or {@link and}.\n * @returns The newly created {@link QueryCompositeFilterConstraint}.\n */\n\n\nfunction and() {\n for (var _len12 = arguments.length, e = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {\n e[_key12] = arguments[_key12];\n }\n\n // Only support QueryFilterConstraints\n return e.forEach(function (e) {\n return __PRIVATE_validateQueryFilterConstraint(\"and\", e);\n }), QueryCompositeFilterConstraint._create(\"and\"\n /* CompositeOperator.AND */\n , e);\n}\n/**\n * A `QueryOrderByConstraint` is used to sort the set of documents returned by a\n * Firestore query. `QueryOrderByConstraint`s are created by invoking\n * {@link orderBy} and can then be passed to {@link (query:1)} to create a new query\n * instance that also contains this `QueryOrderByConstraint`.\n *\n * Note: Documents that do not contain the orderBy field will not be present in\n * the query result.\n */\n\n\nvar QueryOrderByConstraint = /*#__PURE__*/function (_QueryConstraint2) {\n _inherits(QueryOrderByConstraint, _QueryConstraint2);\n\n var _super46 = _createSuper(QueryOrderByConstraint);\n\n /**\n * @internal\n */\n function QueryOrderByConstraint(e, t) {\n var _this212;\n\n _classCallCheck(this, QueryOrderByConstraint);\n\n _this212 = _super46.call(this), _this212._field = e, _this212._direction = t,\n /** The type of this query constraint */\n _this212.type = \"orderBy\";\n return _this212;\n }\n\n _createClass(QueryOrderByConstraint, [{\n key: \"_apply\",\n value: function _apply(e) {\n var t = function __PRIVATE_newQueryOrderBy(e, t, n) {\n if (null !== e.startAt) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. You must not call startAt() or startAfter() before calling orderBy().\");\n if (null !== e.endAt) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. You must not call endAt() or endBefore() before calling orderBy().\");\n return new OrderBy(t, n);\n }\n /**\n * Create a `Bound` from a query and a document.\n *\n * Note that the `Bound` will always include the key of the document\n * and so only the provided document will compare equal to the returned\n * position.\n *\n * Will throw if the document does not contain all fields of the order by\n * of the query or if any of the fields in the order by are an uncommitted\n * server timestamp.\n */\n (e._query, this._field, this._direction);\n\n return new Query(e.firestore, e.converter, function __PRIVATE_queryWithAddedOrderBy(e, t) {\n // TODO(dimond): validate that orderBy does not list the same key twice.\n var n = e.explicitOrderBy.concat([t]);\n return new __PRIVATE_QueryImpl(e.path, e.collectionGroup, n, e.filters.slice(), e.limit, e.limitType, e.startAt, e.endAt);\n }(e._query, t));\n }\n }], [{\n key: \"_create\",\n value: function _create(e, t) {\n return new QueryOrderByConstraint(e, t);\n }\n }]);\n\n return QueryOrderByConstraint;\n}(QueryConstraint);\n/**\n * Creates a {@link QueryOrderByConstraint} that sorts the query result by the\n * specified field, optionally in descending order instead of ascending.\n *\n * Note: Documents that do not contain the specified field will not be present\n * in the query result.\n *\n * @param fieldPath - The field to sort by.\n * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If\n * not specified, order will be ascending.\n * @returns The created {@link QueryOrderByConstraint}.\n */\n\n\nfunction orderBy(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"asc\";\n\n var n = t,\n r = __PRIVATE_fieldPathFromArgument(\"orderBy\", e);\n\n return QueryOrderByConstraint._create(r, n);\n}\n/**\n * A `QueryLimitConstraint` is used to limit the number of documents returned by\n * a Firestore query.\n * `QueryLimitConstraint`s are created by invoking {@link limit} or\n * {@link limitToLast} and can then be passed to {@link (query:1)} to create a new\n * query instance that also contains this `QueryLimitConstraint`.\n */\n\n\nvar QueryLimitConstraint = /*#__PURE__*/function (_QueryConstraint3) {\n _inherits(QueryLimitConstraint, _QueryConstraint3);\n\n var _super47 = _createSuper(QueryLimitConstraint);\n\n /**\n * @internal\n */\n function QueryLimitConstraint(\n /** The type of this query constraint */\n e, t, n) {\n var _this213;\n\n _classCallCheck(this, QueryLimitConstraint);\n\n _this213 = _super47.call(this), _this213.type = e, _this213._limit = t, _this213._limitType = n;\n return _this213;\n }\n\n _createClass(QueryLimitConstraint, [{\n key: \"_apply\",\n value: function _apply(e) {\n return new Query(e.firestore, e.converter, __PRIVATE_queryWithLimit(e._query, this._limit, this._limitType));\n }\n }], [{\n key: \"_create\",\n value: function _create(e, t, n) {\n return new QueryLimitConstraint(e, t, n);\n }\n }]);\n\n return QueryLimitConstraint;\n}(QueryConstraint);\n/**\n * Creates a {@link QueryLimitConstraint} that only returns the first matching\n * documents.\n *\n * @param limit - The maximum number of items to return.\n * @returns The created {@link QueryLimitConstraint}.\n */\n\n\nfunction limit(e) {\n return __PRIVATE_validatePositiveNumber(\"limit\", e), QueryLimitConstraint._create(\"limit\", e, \"F\"\n /* LimitType.First */\n );\n}\n/**\n * Creates a {@link QueryLimitConstraint} that only returns the last matching\n * documents.\n *\n * You must specify at least one `orderBy` clause for `limitToLast` queries,\n * otherwise an exception will be thrown during execution.\n *\n * @param limit - The maximum number of items to return.\n * @returns The created {@link QueryLimitConstraint}.\n */\n\n\nfunction limitToLast(e) {\n return __PRIVATE_validatePositiveNumber(\"limitToLast\", e), QueryLimitConstraint._create(\"limitToLast\", e, \"L\"\n /* LimitType.Last */\n );\n}\n/**\n * A `QueryStartAtConstraint` is used to exclude documents from the start of a\n * result set returned by a Firestore query.\n * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or\n * {@link (startAfter:1)} and can then be passed to {@link (query:1)} to create a\n * new query instance that also contains this `QueryStartAtConstraint`.\n */\n\n\nvar QueryStartAtConstraint = /*#__PURE__*/function (_QueryConstraint4) {\n _inherits(QueryStartAtConstraint, _QueryConstraint4);\n\n var _super48 = _createSuper(QueryStartAtConstraint);\n\n /**\n * @internal\n */\n function QueryStartAtConstraint(\n /** The type of this query constraint */\n e, t, n) {\n var _this214;\n\n _classCallCheck(this, QueryStartAtConstraint);\n\n _this214 = _super48.call(this), _this214.type = e, _this214._docOrFields = t, _this214._inclusive = n;\n return _this214;\n }\n\n _createClass(QueryStartAtConstraint, [{\n key: \"_apply\",\n value: function _apply(e) {\n var t = __PRIVATE_newQueryBoundFromDocOrFields(e, this.type, this._docOrFields, this._inclusive);\n\n return new Query(e.firestore, e.converter, function __PRIVATE_queryWithStartAt(e, t) {\n return new __PRIVATE_QueryImpl(e.path, e.collectionGroup, e.explicitOrderBy.slice(), e.filters.slice(), e.limit, e.limitType, t, e.endAt);\n }(e._query, t));\n }\n }], [{\n key: \"_create\",\n value: function _create(e, t, n) {\n return new QueryStartAtConstraint(e, t, n);\n }\n }]);\n\n return QueryStartAtConstraint;\n}(QueryConstraint);\n\nfunction startAt() {\n for (var _len13 = arguments.length, e = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {\n e[_key13] = arguments[_key13];\n }\n\n return QueryStartAtConstraint._create(\"startAt\", e,\n /*inclusive=*/\n !0);\n}\n\nfunction startAfter() {\n for (var _len14 = arguments.length, e = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {\n e[_key14] = arguments[_key14];\n }\n\n return QueryStartAtConstraint._create(\"startAfter\", e,\n /*inclusive=*/\n !1);\n}\n/**\n * A `QueryEndAtConstraint` is used to exclude documents from the end of a\n * result set returned by a Firestore query.\n * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or\n * {@link (endBefore:1)} and can then be passed to {@link (query:1)} to create a new\n * query instance that also contains this `QueryEndAtConstraint`.\n */\n\n\nvar QueryEndAtConstraint = /*#__PURE__*/function (_QueryConstraint5) {\n _inherits(QueryEndAtConstraint, _QueryConstraint5);\n\n var _super49 = _createSuper(QueryEndAtConstraint);\n\n /**\n * @internal\n */\n function QueryEndAtConstraint(\n /** The type of this query constraint */\n e, t, n) {\n var _this215;\n\n _classCallCheck(this, QueryEndAtConstraint);\n\n _this215 = _super49.call(this), _this215.type = e, _this215._docOrFields = t, _this215._inclusive = n;\n return _this215;\n }\n\n _createClass(QueryEndAtConstraint, [{\n key: \"_apply\",\n value: function _apply(e) {\n var t = __PRIVATE_newQueryBoundFromDocOrFields(e, this.type, this._docOrFields, this._inclusive);\n\n return new Query(e.firestore, e.converter, function __PRIVATE_queryWithEndAt(e, t) {\n return new __PRIVATE_QueryImpl(e.path, e.collectionGroup, e.explicitOrderBy.slice(), e.filters.slice(), e.limit, e.limitType, e.startAt, t);\n }(e._query, t));\n }\n }], [{\n key: \"_create\",\n value: function _create(e, t, n) {\n return new QueryEndAtConstraint(e, t, n);\n }\n }]);\n\n return QueryEndAtConstraint;\n}(QueryConstraint);\n\nfunction endBefore() {\n for (var _len15 = arguments.length, e = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {\n e[_key15] = arguments[_key15];\n }\n\n return QueryEndAtConstraint._create(\"endBefore\", e,\n /*inclusive=*/\n !1);\n}\n\nfunction endAt() {\n for (var _len16 = arguments.length, e = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {\n e[_key16] = arguments[_key16];\n }\n\n return QueryEndAtConstraint._create(\"endAt\", e,\n /*inclusive=*/\n !0);\n}\n/** Helper function to create a bound from a document or fields */\n\n\nfunction __PRIVATE_newQueryBoundFromDocOrFields(e, t, n, r) {\n if (n[0] = getModularInstance(n[0]), n[0] instanceof DocumentSnapshot$1) return function __PRIVATE_newQueryBoundFromDocument(e, t, n, r, i) {\n if (!r) throw new FirestoreError(D.NOT_FOUND, \"Can't use a DocumentSnapshot that doesn't exist for \".concat(n, \"().\"));\n var s = []; // Because people expect to continue/end a query at the exact document\n // provided, we need to use the implicit sort order rather than the explicit\n // sort order, because it's guaranteed to contain the document key. That way\n // the position becomes unambiguous and the query continues/ends exactly at\n // the provided document. Without the key (by using the explicit sort\n // orders), multiple documents could match the position, yielding duplicate\n // results.\n\n var _iterator83 = _createForOfIteratorHelper(__PRIVATE_queryNormalizedOrderBy(e)),\n _step83;\n\n try {\n for (_iterator83.s(); !(_step83 = _iterator83.n()).done;) {\n var _n34 = _step83.value;\n if (_n34.field.isKeyField()) s.push(__PRIVATE_refValue(t, r.key));else {\n var _e111 = r.data.field(_n34.field);\n\n if (__PRIVATE_isServerTimestamp(_e111)) throw new FirestoreError(D.INVALID_ARGUMENT, 'Invalid query. You are trying to start or end a query using a document for which the field \"' + _n34.field + '\" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');\n\n if (null === _e111) {\n var _e112 = _n34.field.canonicalString();\n\n throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. You are trying to start or end a query using a document for which the field '\".concat(_e112, \"' (used as the orderBy) does not exist.\"));\n }\n\n s.push(_e111);\n }\n }\n } catch (err) {\n _iterator83.e(err);\n } finally {\n _iterator83.f();\n }\n\n return new Bound(s, i);\n }\n /**\n * Converts a list of field values to a `Bound` for the given query.\n */\n (e._query, e.firestore._databaseId, t, n[0]._document, r);\n {\n var i = __PRIVATE_newUserDataReader(e.firestore);\n\n return function __PRIVATE_newQueryBoundFromFields(e, t, n, r, i, s) {\n // Use explicit order by's because it has to match the query the user made\n var o = e.explicitOrderBy;\n if (i.length > o.length) throw new FirestoreError(D.INVALID_ARGUMENT, \"Too many arguments provided to \".concat(r, \"(). The number of arguments must be less than or equal to the number of orderBy() clauses\"));\n var _ = [];\n\n for (var _s9 = 0; _s9 < i.length; _s9++) {\n var a = i[_s9];\n\n if (o[_s9].field.isKeyField()) {\n if (\"string\" != typeof a) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. Expected a string for document ID in \".concat(r, \"(), but got a \").concat(typeof a));\n if (!__PRIVATE_isCollectionGroupQuery(e) && -1 !== a.indexOf(\"/\")) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. When querying a collection and ordering by documentId(), the value passed to \".concat(r, \"() must be a plain document ID, but '\").concat(a, \"' contains a slash.\"));\n\n var _n35 = e.path.child(ResourcePath.fromString(a));\n\n if (!DocumentKey.isDocumentKey(_n35)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. When querying a collection group and ordering by documentId(), the value passed to \".concat(r, \"() must result in a valid document path, but '\").concat(_n35, \"' is not because it contains an odd number of segments.\"));\n\n var _i18 = new DocumentKey(_n35);\n\n _.push(__PRIVATE_refValue(t, _i18));\n } else {\n var _e113 = __PRIVATE_parseQueryValue(n, r, a);\n\n _.push(_e113);\n }\n }\n\n return new Bound(_, s);\n }\n /**\n * Parses the given `documentIdValue` into a `ReferenceValue`, throwing\n * appropriate errors if the value is anything other than a `DocumentReference`\n * or `string`, or if the string is malformed.\n */\n (e._query, e.firestore._databaseId, i, t, n, r);\n }\n}\n\nfunction __PRIVATE_parseDocumentIdValue(e, t, n) {\n if (\"string\" == typeof (n = getModularInstance(n))) {\n if (\"\" === n) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.\");\n if (!__PRIVATE_isCollectionGroupQuery(t) && -1 !== n.indexOf(\"/\")) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '\".concat(n, \"' contains a '/' character.\"));\n var r = t.path.child(ResourcePath.fromString(n));\n if (!DocumentKey.isDocumentKey(r)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '\".concat(r, \"' is not because it has an odd number of segments (\").concat(r.length, \").\"));\n return __PRIVATE_refValue(e, new DocumentKey(r));\n }\n\n if (n instanceof DocumentReference) return __PRIVATE_refValue(e, n._key);\n throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: \".concat(__PRIVATE_valueDescription(n), \".\"));\n}\n/**\n * Validates that the value passed into a disjunctive filter satisfies all\n * array requirements.\n */\n\n\nfunction __PRIVATE_validateDisjunctiveFilterElements(e, t) {\n if (!Array.isArray(e) || 0 === e.length) throw new FirestoreError(D.INVALID_ARGUMENT, \"Invalid Query. A non-empty array is required for '\".concat(t.toString(), \"' filters.\"));\n}\n/**\n * Given an operator, returns the set of operators that cannot be used with it.\n *\n * This is not a comprehensive check, and this function should be removed in the\n * long term. Validations should occur in the Firestore backend.\n *\n * Operators in a query must adhere to the following set of rules:\n * 1. Only one inequality per query.\n * 2. `NOT_IN` cannot be used with array, disjunctive, or `NOT_EQUAL` operators.\n */\n\n\nfunction __PRIVATE_validateNewFieldFilter(e, t) {\n var n = function __PRIVATE_findOpInsideFilters(e, t) {\n var _iterator84 = _createForOfIteratorHelper(e),\n _step84;\n\n try {\n for (_iterator84.s(); !(_step84 = _iterator84.n()).done;) {\n var _n36 = _step84.value;\n\n var _iterator85 = _createForOfIteratorHelper(_n36.getFlattenedFilters()),\n _step85;\n\n try {\n for (_iterator85.s(); !(_step85 = _iterator85.n()).done;) {\n var _e114 = _step85.value;\n if (t.indexOf(_e114.op) >= 0) return _e114.op;\n }\n } catch (err) {\n _iterator85.e(err);\n } finally {\n _iterator85.f();\n }\n }\n } catch (err) {\n _iterator84.e(err);\n } finally {\n _iterator84.f();\n }\n\n return null;\n }(e.filters, function __PRIVATE_conflictingOps(e) {\n switch (e) {\n case \"!=\"\n /* Operator.NOT_EQUAL */\n :\n return [\"!=\"\n /* Operator.NOT_EQUAL */\n , \"not-in\"\n /* Operator.NOT_IN */\n ];\n\n case \"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n :\n case \"in\"\n /* Operator.IN */\n :\n return [\"not-in\"\n /* Operator.NOT_IN */\n ];\n\n case \"not-in\"\n /* Operator.NOT_IN */\n :\n return [\"array-contains-any\"\n /* Operator.ARRAY_CONTAINS_ANY */\n , \"in\"\n /* Operator.IN */\n , \"not-in\"\n /* Operator.NOT_IN */\n , \"!=\"\n /* Operator.NOT_EQUAL */\n ];\n\n default:\n return [];\n }\n }(t.op));\n\n if (null !== n) // Special case when it's a duplicate op to give a slightly clearer error message.\n throw n === t.op ? new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. You cannot use more than one '\".concat(t.op.toString(), \"' filter.\")) : new FirestoreError(D.INVALID_ARGUMENT, \"Invalid query. You cannot use '\".concat(t.op.toString(), \"' filters with '\").concat(n.toString(), \"' filters.\"));\n}\n\nfunction __PRIVATE_validateQueryFilterConstraint(e, t) {\n if (!(t instanceof QueryFieldFilterConstraint || t instanceof QueryCompositeFilterConstraint)) throw new FirestoreError(D.INVALID_ARGUMENT, \"Function \".concat(e, \"() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.\"));\n}\n\nvar AbstractUserDataWriter = /*#__PURE__*/function () {\n function AbstractUserDataWriter() {\n _classCallCheck(this, AbstractUserDataWriter);\n }\n\n _createClass(AbstractUserDataWriter, [{\n key: \"convertValue\",\n value: function convertValue(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"none\";\n\n switch (__PRIVATE_typeOrder(e)) {\n case 0\n /* TypeOrder.NullValue */\n :\n return null;\n\n case 1\n /* TypeOrder.BooleanValue */\n :\n return e.booleanValue;\n\n case 2\n /* TypeOrder.NumberValue */\n :\n return __PRIVATE_normalizeNumber(e.integerValue || e.doubleValue);\n\n case 3\n /* TypeOrder.TimestampValue */\n :\n return this.convertTimestamp(e.timestampValue);\n\n case 4\n /* TypeOrder.ServerTimestampValue */\n :\n return this.convertServerTimestamp(e, t);\n\n case 5\n /* TypeOrder.StringValue */\n :\n return e.stringValue;\n\n case 6\n /* TypeOrder.BlobValue */\n :\n return this.convertBytes(__PRIVATE_normalizeByteString(e.bytesValue));\n\n case 7\n /* TypeOrder.RefValue */\n :\n return this.convertReference(e.referenceValue);\n\n case 8\n /* TypeOrder.GeoPointValue */\n :\n return this.convertGeoPoint(e.geoPointValue);\n\n case 9\n /* TypeOrder.ArrayValue */\n :\n return this.convertArray(e.arrayValue, t);\n\n case 10\n /* TypeOrder.ObjectValue */\n :\n return this.convertObject(e.mapValue, t);\n\n default:\n throw fail();\n }\n }\n }, {\n key: \"convertObject\",\n value: function convertObject(e, t) {\n return this.convertObjectMap(e.fields, t);\n }\n /**\n * @internal\n */\n\n }, {\n key: \"convertObjectMap\",\n value: function convertObjectMap(e) {\n var _this216 = this;\n\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"none\";\n var n = {};\n return _forEach(e, function (e, r) {\n n[e] = _this216.convertValue(r, t);\n }), n;\n }\n }, {\n key: \"convertGeoPoint\",\n value: function convertGeoPoint(e) {\n return new GeoPoint(__PRIVATE_normalizeNumber(e.latitude), __PRIVATE_normalizeNumber(e.longitude));\n }\n }, {\n key: \"convertArray\",\n value: function convertArray(e, t) {\n var _this217 = this;\n\n return (e.values || []).map(function (e) {\n return _this217.convertValue(e, t);\n });\n }\n }, {\n key: \"convertServerTimestamp\",\n value: function convertServerTimestamp(e, t) {\n switch (t) {\n case \"previous\":\n var n = __PRIVATE_getPreviousValue(e);\n\n return null == n ? null : this.convertValue(n, t);\n\n case \"estimate\":\n return this.convertTimestamp(__PRIVATE_getLocalWriteTime(e));\n\n default:\n return null;\n }\n }\n }, {\n key: \"convertTimestamp\",\n value: function convertTimestamp(e) {\n var t = __PRIVATE_normalizeTimestamp(e);\n\n return new Timestamp(t.seconds, t.nanos);\n }\n }, {\n key: \"convertDocumentKey\",\n value: function convertDocumentKey(e, t) {\n var n = ResourcePath.fromString(e);\n\n __PRIVATE_hardAssert(__PRIVATE_isValidResourceName(n));\n\n var r = new DatabaseId(n.get(1), n.get(3)),\n i = new DocumentKey(n.popFirst(5));\n return r.isEqual(t) || // TODO(b/64130202): Somehow support foreign references.\n __PRIVATE_logError(\"Document \".concat(i, \" contains a document reference within a different database (\").concat(r.projectId, \"/\").concat(r.database, \") which is not supported. It will be treated as a reference in the current database (\").concat(t.projectId, \"/\").concat(t.database, \") instead.\")), i;\n }\n }]);\n\n return AbstractUserDataWriter;\n}();\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Converts custom model object of type T into `DocumentData` by applying the\n * converter if it exists.\n *\n * This function is used when converting user objects to `DocumentData`\n * because we want to provide the user with a more specific error message if\n * their `set()` or fails due to invalid data originating from a `toFirestore()`\n * call.\n */\n\n\nfunction __PRIVATE_applyFirestoreDataConverter(e, t, n) {\n var r; // Cast to `any` in order to satisfy the union type constraint on\n // toFirestore().\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n return r = e ? n && (n.merge || n.mergeFields) ? e.toFirestore(t, n) : e.toFirestore(t) : t, r;\n}\n\nvar __PRIVATE_LiteUserDataWriter = /*#__PURE__*/function (_AbstractUserDataWrit) {\n _inherits(__PRIVATE_LiteUserDataWriter, _AbstractUserDataWrit);\n\n var _super50 = _createSuper(__PRIVATE_LiteUserDataWriter);\n\n function __PRIVATE_LiteUserDataWriter(e) {\n var _this218;\n\n _classCallCheck(this, __PRIVATE_LiteUserDataWriter);\n\n _this218 = _super50.call(this), _this218.firestore = e;\n return _this218;\n }\n\n _createClass(__PRIVATE_LiteUserDataWriter, [{\n key: \"convertBytes\",\n value: function convertBytes(e) {\n return new Bytes(e);\n }\n }, {\n key: \"convertReference\",\n value: function convertReference(e) {\n var t = this.convertDocumentKey(e, this.firestore._databaseId);\n return new DocumentReference(this.firestore,\n /* converter= */\n null, t);\n }\n }]);\n\n return __PRIVATE_LiteUserDataWriter;\n}(AbstractUserDataWriter);\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Create an AggregateField object that can be used to compute the sum of\n * a specified field over a range of documents in the result set of a query.\n * @param field Specifies the field to sum across the result set.\n */\n\n\nfunction sum(e) {\n return new AggregateField(\"sum\", __PRIVATE_fieldPathFromArgument$1(\"sum\", e));\n}\n/**\n * Create an AggregateField object that can be used to compute the average of\n * a specified field over a range of documents in the result set of a query.\n * @param field Specifies the field to average across the result set.\n */\n\n\nfunction average(e) {\n return new AggregateField(\"avg\", __PRIVATE_fieldPathFromArgument$1(\"average\", e));\n}\n/**\n * Create an AggregateField object that can be used to compute the count of\n * documents in the result set of a query.\n */\n\n\nfunction count() {\n return new AggregateField(\"count\");\n}\n/**\n * Compares two 'AggregateField` instances for equality.\n *\n * @param left Compare this AggregateField to the `right`.\n * @param right Compare this AggregateField to the `left`.\n */\n\n\nfunction aggregateFieldEqual(e, t) {\n var n, r;\n return e instanceof AggregateField && t instanceof AggregateField && e.aggregateType === t.aggregateType && (null === (n = e._internalFieldPath) || void 0 === n ? void 0 : n.canonicalString()) === (null === (r = t._internalFieldPath) || void 0 === r ? void 0 : r.canonicalString());\n}\n/**\n * Compares two `AggregateQuerySnapshot` instances for equality.\n *\n * Two `AggregateQuerySnapshot` instances are considered \"equal\" if they have\n * underlying queries that compare equal, and the same data.\n *\n * @param left - The first `AggregateQuerySnapshot` to compare.\n * @param right - The second `AggregateQuerySnapshot` to compare.\n *\n * @returns `true` if the objects are \"equal\", as defined above, or `false`\n * otherwise.\n */\n\n\nfunction aggregateQuerySnapshotEqual(e, t) {\n return queryEqual(e.query, t.query) && deepEqual(e.data(), t.data());\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Metadata about a snapshot, describing the state of the snapshot.\n */\n\n\nvar SnapshotMetadata = /*#__PURE__*/function () {\n /** @hideconstructor */\n function SnapshotMetadata(e, t) {\n _classCallCheck(this, SnapshotMetadata);\n\n this.hasPendingWrites = e, this.fromCache = t;\n }\n /**\n * Returns true if this `SnapshotMetadata` is equal to the provided one.\n *\n * @param other - The `SnapshotMetadata` to compare against.\n * @returns true if this `SnapshotMetadata` is equal to the provided one.\n */\n\n\n _createClass(SnapshotMetadata, [{\n key: \"isEqual\",\n value: function isEqual(e) {\n return this.hasPendingWrites === e.hasPendingWrites && this.fromCache === e.fromCache;\n }\n }]);\n\n return SnapshotMetadata;\n}();\n/**\n * A `DocumentSnapshot` contains data read from a document in your Firestore\n * database. The data can be extracted with `.data()` or `.get()` to\n * get a specific field.\n *\n * For a `DocumentSnapshot` that points to a non-existing document, any data\n * access will return 'undefined'. You can use the `exists()` method to\n * explicitly verify a document's existence.\n */\n\n\nvar DocumentSnapshot = /*#__PURE__*/function (_DocumentSnapshot$2) {\n _inherits(DocumentSnapshot, _DocumentSnapshot$2);\n\n var _super51 = _createSuper(DocumentSnapshot);\n\n /** @hideconstructor protected */\n function DocumentSnapshot(e, t, n, r, i, s) {\n var _this219;\n\n _classCallCheck(this, DocumentSnapshot);\n\n _this219 = _super51.call(this, e, t, n, r, s), _this219._firestore = e, _this219._firestoreImpl = e, _this219.metadata = i;\n return _this219;\n }\n /**\n * Returns whether or not the data exists. True if the document exists.\n */\n\n\n _createClass(DocumentSnapshot, [{\n key: \"exists\",\n value: function exists() {\n return _get(_getPrototypeOf(DocumentSnapshot.prototype), \"exists\", this).call(this);\n }\n /**\n * Retrieves all fields in the document as an `Object`. Returns `undefined` if\n * the document doesn't exist.\n *\n * By default, `serverTimestamp()` values that have not yet been\n * set to their final value will be returned as `null`. You can override\n * this by passing an options object.\n *\n * @param options - An options object to configure how data is retrieved from\n * the snapshot (for example the desired behavior for server timestamps that\n * have not yet been set to their final value).\n * @returns An `Object` containing all fields in the document or `undefined` if\n * the document doesn't exist.\n */\n\n }, {\n key: \"data\",\n value: function data() {\n var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (this._document) {\n if (this._converter) {\n // We only want to use the converter and create a new DocumentSnapshot\n // if a converter has been provided.\n var t = new QueryDocumentSnapshot(this._firestore, this._userDataWriter, this._key, this._document, this.metadata,\n /* converter= */\n null);\n return this._converter.fromFirestore(t, e);\n }\n\n return this._userDataWriter.convertValue(this._document.data.value, e.serverTimestamps);\n }\n }\n /**\n * Retrieves the field specified by `fieldPath`. Returns `undefined` if the\n * document or field doesn't exist.\n *\n * By default, a `serverTimestamp()` that has not yet been set to\n * its final value will be returned as `null`. You can override this by\n * passing an options object.\n *\n * @param fieldPath - The path (for example 'foo' or 'foo.bar') to a specific\n * field.\n * @param options - An options object to configure how the field is retrieved\n * from the snapshot (for example the desired behavior for server timestamps\n * that have not yet been set to their final value).\n * @returns The data at the specified field location or undefined if no such\n * field exists in the document.\n */\n // We are using `any` here to avoid an explicit cast by our users.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\n }, {\n key: \"get\",\n value: function get(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (this._document) {\n var n = this._document.data.field(__PRIVATE_fieldPathFromArgument(\"DocumentSnapshot.get\", e));\n\n if (null !== n) return this._userDataWriter.convertValue(n, t.serverTimestamps);\n }\n }\n }]);\n\n return DocumentSnapshot;\n}(DocumentSnapshot$1);\n/**\n * A `QueryDocumentSnapshot` contains data read from a document in your\n * Firestore database as part of a query. The document is guaranteed to exist\n * and its data can be extracted with `.data()` or `.get()` to get a\n * specific field.\n *\n * A `QueryDocumentSnapshot` offers the same API surface as a\n * `DocumentSnapshot`. Since query results contain only existing documents, the\n * `exists` property will always be true and `data()` will never return\n * 'undefined'.\n */\n\n\nvar QueryDocumentSnapshot = /*#__PURE__*/function (_DocumentSnapshot) {\n _inherits(QueryDocumentSnapshot, _DocumentSnapshot);\n\n var _super52 = _createSuper(QueryDocumentSnapshot);\n\n function QueryDocumentSnapshot() {\n _classCallCheck(this, QueryDocumentSnapshot);\n\n return _super52.apply(this, arguments);\n }\n\n _createClass(QueryDocumentSnapshot, [{\n key: \"data\",\n value:\n /**\n * Retrieves all fields in the document as an `Object`.\n *\n * By default, `serverTimestamp()` values that have not yet been\n * set to their final value will be returned as `null`. You can override\n * this by passing an options object.\n *\n * @override\n * @param options - An options object to configure how data is retrieved from\n * the snapshot (for example the desired behavior for server timestamps that\n * have not yet been set to their final value).\n * @returns An `Object` containing all fields in the document.\n */\n function data() {\n var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _get(_getPrototypeOf(QueryDocumentSnapshot.prototype), \"data\", this).call(this, e);\n }\n }]);\n\n return QueryDocumentSnapshot;\n}(DocumentSnapshot);\n/**\n * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects\n * representing the results of a query. The documents can be accessed as an\n * array via the `docs` property or enumerated using the `forEach` method. The\n * number of documents can be determined via the `empty` and `size`\n * properties.\n */\n\n\nvar QuerySnapshot = /*#__PURE__*/function () {\n /** @hideconstructor */\n function QuerySnapshot(e, t, n, r) {\n _classCallCheck(this, QuerySnapshot);\n\n this._firestore = e, this._userDataWriter = t, this._snapshot = r, this.metadata = new SnapshotMetadata(r.hasPendingWrites, r.fromCache), this.query = n;\n }\n /** An array of all the documents in the `QuerySnapshot`. */\n\n\n _createClass(QuerySnapshot, [{\n key: \"docs\",\n get: function get() {\n var e = [];\n return this.forEach(function (t) {\n return e.push(t);\n }), e;\n }\n /** The number of documents in the `QuerySnapshot`. */\n\n }, {\n key: \"size\",\n get: function get() {\n return this._snapshot.docs.size;\n }\n /** True if there are no documents in the `QuerySnapshot`. */\n\n }, {\n key: \"empty\",\n get: function get() {\n return 0 === this.size;\n }\n /**\n * Enumerates all of the documents in the `QuerySnapshot`.\n *\n * @param callback - A callback to be called with a `QueryDocumentSnapshot` for\n * each document in the snapshot.\n * @param thisArg - The `this` binding for the callback.\n */\n\n }, {\n key: \"forEach\",\n value: function forEach(e, t) {\n var _this220 = this;\n\n this._snapshot.docs.forEach(function (n) {\n e.call(t, new QueryDocumentSnapshot(_this220._firestore, _this220._userDataWriter, n.key, n, new SnapshotMetadata(_this220._snapshot.mutatedKeys.has(n.key), _this220._snapshot.fromCache), _this220.query.converter));\n });\n }\n /**\n * Returns an array of the documents changes since the last snapshot. If this\n * is the first snapshot, all documents will be in the list as 'added'\n * changes.\n *\n * @param options - `SnapshotListenOptions` that control whether metadata-only\n * changes (i.e. only `DocumentSnapshot.metadata` changed) should trigger\n * snapshot events.\n */\n\n }, {\n key: \"docChanges\",\n value: function docChanges() {\n var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var t = !!e.includeMetadataChanges;\n if (t && this._snapshot.excludesMetadataChanges) throw new FirestoreError(D.INVALID_ARGUMENT, \"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().\");\n return this._cachedChanges && this._cachedChangesIncludeMetadataChanges === t || (this._cachedChanges =\n /** Calculates the array of `DocumentChange`s for a given `ViewSnapshot`. */\n function __PRIVATE_changesFromSnapshot(e, t) {\n if (e._snapshot.oldDocs.isEmpty()) {\n var _t54 = 0;\n return e._snapshot.docChanges.map(function (n) {\n var r = new QueryDocumentSnapshot(e._firestore, e._userDataWriter, n.doc.key, n.doc, new SnapshotMetadata(e._snapshot.mutatedKeys.has(n.doc.key), e._snapshot.fromCache), e.query.converter);\n return n.doc, {\n type: \"added\",\n doc: r,\n oldIndex: -1,\n newIndex: _t54++\n };\n });\n }\n\n {\n // A `DocumentSet` that is updated incrementally as changes are applied to use\n // to lookup the index of a document.\n var n = e._snapshot.oldDocs;\n return e._snapshot.docChanges.filter(function (e) {\n return t || 3\n /* ChangeType.Metadata */\n !== e.type;\n }).map(function (t) {\n var r = new QueryDocumentSnapshot(e._firestore, e._userDataWriter, t.doc.key, t.doc, new SnapshotMetadata(e._snapshot.mutatedKeys.has(t.doc.key), e._snapshot.fromCache), e.query.converter);\n var i = -1,\n s = -1;\n return 0\n /* ChangeType.Added */\n !== t.type && (i = n.indexOf(t.doc.key), n = n.delete(t.doc.key)), 1\n /* ChangeType.Removed */\n !== t.type && (n = n.add(t.doc), s = n.indexOf(t.doc.key)), {\n type: __PRIVATE_resultChangeType(t.type),\n doc: r,\n oldIndex: i,\n newIndex: s\n };\n });\n }\n }(this, t), this._cachedChangesIncludeMetadataChanges = t), this._cachedChanges;\n }\n }]);\n\n return QuerySnapshot;\n}();\n\nfunction __PRIVATE_resultChangeType(e) {\n switch (e) {\n case 0\n /* ChangeType.Added */\n :\n return \"added\";\n\n case 2\n /* ChangeType.Modified */\n :\n case 3\n /* ChangeType.Metadata */\n :\n return \"modified\";\n\n case 1\n /* ChangeType.Removed */\n :\n return \"removed\";\n\n default:\n return fail();\n }\n} // TODO(firestoreexp): Add tests for snapshotEqual with different snapshot\n// metadata\n\n/**\n * Returns true if the provided snapshots are equal.\n *\n * @param left - A snapshot to compare.\n * @param right - A snapshot to compare.\n * @returns true if the snapshots are equal.\n */\n\n\nfunction snapshotEqual(e, t) {\n return e instanceof DocumentSnapshot && t instanceof DocumentSnapshot ? e._firestore === t._firestore && e._key.isEqual(t._key) && (null === e._document ? null === t._document : e._document.isEqual(t._document)) && e._converter === t._converter : e instanceof QuerySnapshot && t instanceof QuerySnapshot && e._firestore === t._firestore && queryEqual(e.query, t.query) && e.metadata.isEqual(t.metadata) && e._snapshot.isEqual(t._snapshot);\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Reads the document referred to by this `DocumentReference`.\n *\n * Note: `getDoc()` attempts to provide up-to-date data when possible by waiting\n * for data from the server, but it may return cached data or fail if you are\n * offline and the server cannot be reached. To specify this behavior, invoke\n * {@link getDocFromCache} or {@link getDocFromServer}.\n *\n * @param reference - The reference of the document to fetch.\n * @returns A Promise resolved with a `DocumentSnapshot` containing the\n * current document contents.\n */\n\n\nfunction getDoc(e) {\n e = __PRIVATE_cast(e, DocumentReference);\n\n var t = __PRIVATE_cast(e.firestore, Firestore);\n\n return __PRIVATE_firestoreClientGetDocumentViaSnapshotListener(ensureFirestoreConfigured(t), e._key).then(function (n) {\n return __PRIVATE_convertToDocSnapshot(t, e, n);\n });\n}\n\nvar __PRIVATE_ExpUserDataWriter = /*#__PURE__*/function (_AbstractUserDataWrit2) {\n _inherits(__PRIVATE_ExpUserDataWriter, _AbstractUserDataWrit2);\n\n var _super53 = _createSuper(__PRIVATE_ExpUserDataWriter);\n\n function __PRIVATE_ExpUserDataWriter(e) {\n var _this221;\n\n _classCallCheck(this, __PRIVATE_ExpUserDataWriter);\n\n _this221 = _super53.call(this), _this221.firestore = e;\n return _this221;\n }\n\n _createClass(__PRIVATE_ExpUserDataWriter, [{\n key: \"convertBytes\",\n value: function convertBytes(e) {\n return new Bytes(e);\n }\n }, {\n key: \"convertReference\",\n value: function convertReference(e) {\n var t = this.convertDocumentKey(e, this.firestore._databaseId);\n return new DocumentReference(this.firestore,\n /* converter= */\n null, t);\n }\n }]);\n\n return __PRIVATE_ExpUserDataWriter;\n}(AbstractUserDataWriter);\n/**\n * Reads the document referred to by this `DocumentReference` from cache.\n * Returns an error if the document is not currently cached.\n *\n * @returns A `Promise` resolved with a `DocumentSnapshot` containing the\n * current document contents.\n */\n\n\nfunction getDocFromCache(e) {\n e = __PRIVATE_cast(e, DocumentReference);\n\n var t = __PRIVATE_cast(e.firestore, Firestore),\n n = ensureFirestoreConfigured(t),\n r = new __PRIVATE_ExpUserDataWriter(t);\n\n return __PRIVATE_firestoreClientGetDocumentFromLocalCache(n, e._key).then(function (n) {\n return new DocumentSnapshot(t, r, e._key, n, new SnapshotMetadata(null !== n && n.hasLocalMutations,\n /* fromCache= */\n !0), e.converter);\n });\n}\n/**\n * Reads the document referred to by this `DocumentReference` from the server.\n * Returns an error if the network is not available.\n *\n * @returns A `Promise` resolved with a `DocumentSnapshot` containing the\n * current document contents.\n */\n\n\nfunction getDocFromServer(e) {\n e = __PRIVATE_cast(e, DocumentReference);\n\n var t = __PRIVATE_cast(e.firestore, Firestore);\n\n return __PRIVATE_firestoreClientGetDocumentViaSnapshotListener(ensureFirestoreConfigured(t), e._key, {\n source: \"server\"\n }).then(function (n) {\n return __PRIVATE_convertToDocSnapshot(t, e, n);\n });\n}\n/**\n * Executes the query and returns the results as a `QuerySnapshot`.\n *\n * Note: `getDocs()` attempts to provide up-to-date data when possible by\n * waiting for data from the server, but it may return cached data or fail if\n * you are offline and the server cannot be reached. To specify this behavior,\n * invoke {@link getDocsFromCache} or {@link getDocsFromServer}.\n *\n * @returns A `Promise` that will be resolved with the results of the query.\n */\n\n\nfunction getDocs(e) {\n e = __PRIVATE_cast(e, Query);\n\n var t = __PRIVATE_cast(e.firestore, Firestore),\n n = ensureFirestoreConfigured(t),\n r = new __PRIVATE_ExpUserDataWriter(t);\n\n return __PRIVATE_validateHasExplicitOrderByForLimitToLast(e._query), __PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(n, e._query).then(function (n) {\n return new QuerySnapshot(t, r, e, n);\n });\n}\n/**\n * Executes the query and returns the results as a `QuerySnapshot` from cache.\n * Returns an empty result set if no documents matching the query are currently\n * cached.\n *\n * @returns A `Promise` that will be resolved with the results of the query.\n */\n\n\nfunction getDocsFromCache(e) {\n e = __PRIVATE_cast(e, Query);\n\n var t = __PRIVATE_cast(e.firestore, Firestore),\n n = ensureFirestoreConfigured(t),\n r = new __PRIVATE_ExpUserDataWriter(t);\n\n return __PRIVATE_firestoreClientGetDocumentsFromLocalCache(n, e._query).then(function (n) {\n return new QuerySnapshot(t, r, e, n);\n });\n}\n/**\n * Executes the query and returns the results as a `QuerySnapshot` from the\n * server. Returns an error if the network is not available.\n *\n * @returns A `Promise` that will be resolved with the results of the query.\n */\n\n\nfunction getDocsFromServer(e) {\n e = __PRIVATE_cast(e, Query);\n\n var t = __PRIVATE_cast(e.firestore, Firestore),\n n = ensureFirestoreConfigured(t),\n r = new __PRIVATE_ExpUserDataWriter(t);\n\n return __PRIVATE_firestoreClientGetDocumentsViaSnapshotListener(n, e._query, {\n source: \"server\"\n }).then(function (n) {\n return new QuerySnapshot(t, r, e, n);\n });\n}\n\nfunction setDoc(e, t, n) {\n e = __PRIVATE_cast(e, DocumentReference);\n\n var r = __PRIVATE_cast(e.firestore, Firestore),\n i = __PRIVATE_applyFirestoreDataConverter(e.converter, t, n);\n\n return executeWrite(r, [__PRIVATE_parseSetData(__PRIVATE_newUserDataReader(r), \"setDoc\", e._key, i, null !== e.converter, n).toMutation(e._key, Precondition.none())]);\n}\n\nfunction updateDoc(e, t, n) {\n e = __PRIVATE_cast(e, DocumentReference);\n\n var i = __PRIVATE_cast(e.firestore, Firestore),\n s = __PRIVATE_newUserDataReader(i);\n\n var o;\n\n for (var _len17 = arguments.length, r = new Array(_len17 > 3 ? _len17 - 3 : 0), _key17 = 3; _key17 < _len17; _key17++) {\n r[_key17 - 3] = arguments[_key17];\n }\n\n o = \"string\" == typeof ( // For Compat types, we have to \"extract\" the underlying types before\n // performing validation.\n t = getModularInstance(t)) || t instanceof FieldPath ? __PRIVATE_parseUpdateVarargs(s, \"updateDoc\", e._key, t, n, r) : __PRIVATE_parseUpdateData(s, \"updateDoc\", e._key, t);\n return executeWrite(i, [o.toMutation(e._key, Precondition.exists(!0))]);\n}\n/**\n * Deletes the document referred to by the specified `DocumentReference`.\n *\n * @param reference - A reference to the document to delete.\n * @returns A Promise resolved once the document has been successfully\n * deleted from the backend (note that it won't resolve while you're offline).\n */\n\n\nfunction deleteDoc(e) {\n return executeWrite(__PRIVATE_cast(e.firestore, Firestore), [new __PRIVATE_DeleteMutation(e._key, Precondition.none())]);\n}\n/**\n * Add a new document to specified `CollectionReference` with the given data,\n * assigning it a document ID automatically.\n *\n * @param reference - A reference to the collection to add this document to.\n * @param data - An Object containing the data for the new document.\n * @returns A `Promise` resolved with a `DocumentReference` pointing to the\n * newly created document after it has been written to the backend (Note that it\n * won't resolve while you're offline).\n */\n\n\nfunction addDoc(e, t) {\n var n = __PRIVATE_cast(e.firestore, Firestore),\n r = doc(e),\n i = __PRIVATE_applyFirestoreDataConverter(e.converter, t);\n\n return executeWrite(n, [__PRIVATE_parseSetData(__PRIVATE_newUserDataReader(e.firestore), \"addDoc\", r._key, i, null !== e.converter, {}).toMutation(r._key, Precondition.exists(!1))]).then(function () {\n return r;\n });\n}\n\nfunction onSnapshot(e) {\n for (var _len18 = arguments.length, t = new Array(_len18 > 1 ? _len18 - 1 : 0), _key18 = 1; _key18 < _len18; _key18++) {\n t[_key18 - 1] = arguments[_key18];\n }\n\n var n, r, i;\n e = getModularInstance(e);\n var s = {\n includeMetadataChanges: !1\n },\n o = 0;\n \"object\" != typeof t[o] || __PRIVATE_isPartialObserver(t[o]) || (s = t[o], o++);\n var _ = {\n includeMetadataChanges: s.includeMetadataChanges\n };\n\n if (__PRIVATE_isPartialObserver(t[o])) {\n var _e115 = t[o];\n t[o] = null === (n = _e115.next) || void 0 === n ? void 0 : n.bind(_e115), t[o + 1] = null === (r = _e115.error) || void 0 === r ? void 0 : r.bind(_e115), t[o + 2] = null === (i = _e115.complete) || void 0 === i ? void 0 : i.bind(_e115);\n }\n\n var a, u, c;\n if (e instanceof DocumentReference) u = __PRIVATE_cast(e.firestore, Firestore), c = __PRIVATE_newQueryForPath(e._key.path), a = {\n next: function next(n) {\n t[o] && t[o](__PRIVATE_convertToDocSnapshot(u, e, n));\n },\n error: t[o + 1],\n complete: t[o + 2]\n };else {\n var _n37 = __PRIVATE_cast(e, Query);\n\n u = __PRIVATE_cast(_n37.firestore, Firestore), c = _n37._query;\n\n var _r34 = new __PRIVATE_ExpUserDataWriter(u);\n\n a = {\n next: function next(e) {\n t[o] && t[o](new QuerySnapshot(u, _r34, _n37, e));\n },\n error: t[o + 1],\n complete: t[o + 2]\n }, __PRIVATE_validateHasExplicitOrderByForLimitToLast(e._query);\n }\n return function __PRIVATE_firestoreClientListen(e, t, n, r) {\n var i = new __PRIVATE_AsyncObserver(r),\n s = new __PRIVATE_QueryListener(t, i, n);\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee72() {\n return _regeneratorRuntime.wrap(function _callee72$(_context72) {\n while (1) {\n switch (_context72.prev = _context72.next) {\n case 0:\n _context72.t0 = __PRIVATE_eventManagerListen;\n _context72.next = 3;\n return __PRIVATE_getEventManager(e);\n\n case 3:\n _context72.t1 = _context72.sent;\n _context72.t2 = s;\n return _context72.abrupt(\"return\", (0, _context72.t0)(_context72.t1, _context72.t2));\n\n case 6:\n case \"end\":\n return _context72.stop();\n }\n }\n }, _callee72);\n }))), function () {\n i.La(), e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee73() {\n return _regeneratorRuntime.wrap(function _callee73$(_context73) {\n while (1) {\n switch (_context73.prev = _context73.next) {\n case 0:\n _context73.t0 = __PRIVATE_eventManagerUnlisten;\n _context73.next = 3;\n return __PRIVATE_getEventManager(e);\n\n case 3:\n _context73.t1 = _context73.sent;\n _context73.t2 = s;\n return _context73.abrupt(\"return\", (0, _context73.t0)(_context73.t1, _context73.t2));\n\n case 6:\n case \"end\":\n return _context73.stop();\n }\n }\n }, _callee73);\n })));\n };\n }(ensureFirestoreConfigured(u), c, _, a);\n}\n\nfunction onSnapshotsInSync(e, t) {\n return __PRIVATE_firestoreClientAddSnapshotsInSyncListener(ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore)), __PRIVATE_isPartialObserver(t) ? t : {\n next: t\n });\n}\n/**\n * Locally writes `mutations` on the async queue.\n * @internal\n */\n\n\nfunction executeWrite(e, t) {\n return function __PRIVATE_firestoreClientWrite(e, t) {\n var n = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee74() {\n return _regeneratorRuntime.wrap(function _callee74$(_context74) {\n while (1) {\n switch (_context74.prev = _context74.next) {\n case 0:\n _context74.t0 = __PRIVATE_syncEngineWrite;\n _context74.next = 3;\n return __PRIVATE_getSyncEngine(e);\n\n case 3:\n _context74.t1 = _context74.sent;\n _context74.t2 = t;\n _context74.t3 = n;\n return _context74.abrupt(\"return\", (0, _context74.t0)(_context74.t1, _context74.t2, _context74.t3));\n\n case 7:\n case \"end\":\n return _context74.stop();\n }\n }\n }, _callee74);\n }))), n.promise;\n }(ensureFirestoreConfigured(e), t);\n}\n/**\n * Converts a {@link ViewSnapshot} that contains the single document specified by `ref`\n * to a {@link DocumentSnapshot}.\n */\n\n\nfunction __PRIVATE_convertToDocSnapshot(e, t, n) {\n var r = n.docs.get(t._key),\n i = new __PRIVATE_ExpUserDataWriter(e);\n return new DocumentSnapshot(e, i, t._key, r, new SnapshotMetadata(n.hasPendingWrites, n.fromCache), t.converter);\n}\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Calculates the number of documents in the result set of the given query\n * without actually downloading the documents.\n *\n * Using this function to count the documents is efficient because only the\n * final count, not the documents' data, is downloaded. This function can\n * count the documents in cases where the result set is prohibitively large to\n * download entirely (thousands of documents).\n *\n * The result received from the server is presented, unaltered, without\n * considering any local state. That is, documents in the local cache are not\n * taken into consideration, neither are local modifications not yet\n * synchronized with the server. Previously-downloaded results, if any, are not\n * used. Every invocation of this function necessarily involves a round trip to\n * the server.\n *\n * @param query The query whose result set size is calculated.\n * @returns A Promise that will be resolved with the count; the count can be\n * retrieved from `snapshot.data().count`, where `snapshot` is the\n * `AggregateQuerySnapshot` to which the returned Promise resolves.\n */\n\n\nfunction getCountFromServer(e) {\n return getAggregateFromServer(e, {\n count: count()\n });\n}\n/**\n * Calculates the specified aggregations over the documents in the result\n * set of the given query without actually downloading the documents.\n *\n * Using this function to perform aggregations is efficient because only the\n * final aggregation values, not the documents' data, are downloaded. This\n * function can perform aggregations of the documents in cases where the result\n * set is prohibitively large to download entirely (thousands of documents).\n *\n * The result received from the server is presented, unaltered, without\n * considering any local state. That is, documents in the local cache are not\n * taken into consideration, neither are local modifications not yet\n * synchronized with the server. Previously-downloaded results, if any, are not\n * used. Every invocation of this function necessarily involves a round trip to\n * the server.\n *\n * @param query The query whose result set is aggregated over.\n * @param aggregateSpec An `AggregateSpec` object that specifies the aggregates\n * to perform over the result set. The AggregateSpec specifies aliases for each\n * aggregate, which can be used to retrieve the aggregate result.\n * @example\n * ```typescript\n * const aggregateSnapshot = await getAggregateFromServer(query, {\n * countOfDocs: count(),\n * totalHours: sum('hours'),\n * averageScore: average('score')\n * });\n *\n * const countOfDocs: number = aggregateSnapshot.data().countOfDocs;\n * const totalHours: number = aggregateSnapshot.data().totalHours;\n * const averageScore: number | null = aggregateSnapshot.data().averageScore;\n * ```\n */\n\n\nfunction getAggregateFromServer(e, t) {\n var n = __PRIVATE_cast(e.firestore, Firestore),\n r = ensureFirestoreConfigured(n),\n i = function __PRIVATE_mapToArray(e, t) {\n var n = [];\n\n for (var _r35 in e) {\n Object.prototype.hasOwnProperty.call(e, _r35) && n.push(t(e[_r35], _r35, e));\n }\n\n return n;\n }(t, function (e, t) {\n return new __PRIVATE_AggregateImpl(t, e.aggregateType, e._internalFieldPath);\n }); // Run the aggregation and convert the results\n\n\n return function __PRIVATE_firestoreClientRunAggregateQuery(e, t, n) {\n var r = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee75() {\n var _i19;\n\n return _regeneratorRuntime.wrap(function _callee75$(_context75) {\n while (1) {\n switch (_context75.prev = _context75.next) {\n case 0:\n _context75.prev = 0;\n _context75.next = 3;\n return __PRIVATE_getDatastore(e);\n\n case 3:\n _i19 = _context75.sent;\n r.resolve(__PRIVATE_invokeRunAggregationQueryRpc(_i19, t, n));\n _context75.next = 10;\n break;\n\n case 7:\n _context75.prev = 7;\n _context75.t0 = _context75[\"catch\"](0);\n r.reject(_context75.t0);\n\n case 10:\n case \"end\":\n return _context75.stop();\n }\n }\n }, _callee75, null, [[0, 7]]);\n }))), r.promise;\n }(r, e._query, i).then(function (t) {\n return (\n /**\n * Converts the core aggregration result to an `AggregateQuerySnapshot`\n * that can be returned to the consumer.\n * @param query\n * @param aggregateResult Core aggregation result\n * @internal\n */\n function __PRIVATE_convertToAggregateQuerySnapshot(e, t, n) {\n var r = new __PRIVATE_ExpUserDataWriter(e);\n return new AggregateQuerySnapshot(t, r, n);\n }\n /**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n (n, e, t)\n );\n });\n}\n\nvar __PRIVATE_MemoryLocalCacheImpl = /*#__PURE__*/function () {\n function __PRIVATE_MemoryLocalCacheImpl(e) {\n _classCallCheck(this, __PRIVATE_MemoryLocalCacheImpl);\n\n this.kind = \"memory\", this._onlineComponentProvider = new OnlineComponentProvider(), (null == e ? void 0 : e.garbageCollector) ? this._offlineComponentProvider = e.garbageCollector._offlineComponentProvider : this._offlineComponentProvider = new MemoryOfflineComponentProvider();\n }\n\n _createClass(__PRIVATE_MemoryLocalCacheImpl, [{\n key: \"toJSON\",\n value: function toJSON() {\n return {\n kind: this.kind\n };\n }\n }]);\n\n return __PRIVATE_MemoryLocalCacheImpl;\n}();\n\nvar __PRIVATE_PersistentLocalCacheImpl = /*#__PURE__*/function () {\n function __PRIVATE_PersistentLocalCacheImpl(e) {\n _classCallCheck(this, __PRIVATE_PersistentLocalCacheImpl);\n\n var t;\n this.kind = \"persistent\", (null == e ? void 0 : e.tabManager) ? (e.tabManager._initialize(e), t = e.tabManager) : (t = persistentSingleTabManager(void 0), t._initialize(e)), this._onlineComponentProvider = t._onlineComponentProvider, this._offlineComponentProvider = t._offlineComponentProvider;\n }\n\n _createClass(__PRIVATE_PersistentLocalCacheImpl, [{\n key: \"toJSON\",\n value: function toJSON() {\n return {\n kind: this.kind\n };\n }\n }]);\n\n return __PRIVATE_PersistentLocalCacheImpl;\n}();\n\nvar __PRIVATE_MemoryEagerGabageCollectorImpl = /*#__PURE__*/function () {\n function __PRIVATE_MemoryEagerGabageCollectorImpl() {\n _classCallCheck(this, __PRIVATE_MemoryEagerGabageCollectorImpl);\n\n this.kind = \"memoryEager\", this._offlineComponentProvider = new MemoryOfflineComponentProvider();\n }\n\n _createClass(__PRIVATE_MemoryEagerGabageCollectorImpl, [{\n key: \"toJSON\",\n value: function toJSON() {\n return {\n kind: this.kind\n };\n }\n }]);\n\n return __PRIVATE_MemoryEagerGabageCollectorImpl;\n}();\n\nvar __PRIVATE_MemoryLruGabageCollectorImpl = /*#__PURE__*/function () {\n function __PRIVATE_MemoryLruGabageCollectorImpl(e) {\n _classCallCheck(this, __PRIVATE_MemoryLruGabageCollectorImpl);\n\n this.kind = \"memoryLru\", this._offlineComponentProvider = new __PRIVATE_LruGcMemoryOfflineComponentProvider(e);\n }\n\n _createClass(__PRIVATE_MemoryLruGabageCollectorImpl, [{\n key: \"toJSON\",\n value: function toJSON() {\n return {\n kind: this.kind\n };\n }\n }]);\n\n return __PRIVATE_MemoryLruGabageCollectorImpl;\n}();\n/**\n * Creates an instance of `MemoryEagerGarbageCollector`. This is also the\n * default garbage collector unless it is explicitly specified otherwise.\n */\n\n\nfunction memoryEagerGarbageCollector() {\n return new __PRIVATE_MemoryEagerGabageCollectorImpl();\n}\n/**\n * Creates an instance of `MemoryLruGarbageCollector`.\n *\n * A target size can be specified as part of the setting parameter. The\n * collector will start deleting documents once the cache size exceeds\n * the given size. The default cache size is 40MB (40 * 1024 * 1024 bytes).\n */\n\n\nfunction memoryLruGarbageCollector(e) {\n return new __PRIVATE_MemoryLruGabageCollectorImpl(null == e ? void 0 : e.cacheSizeBytes);\n}\n/**\n * Creates an instance of `MemoryLocalCache`. The instance can be set to\n * `FirestoreSettings.cache` to tell the SDK which cache layer to use.\n */\n\n\nfunction memoryLocalCache(e) {\n return new __PRIVATE_MemoryLocalCacheImpl(e);\n}\n/**\n * Creates an instance of `PersistentLocalCache`. The instance can be set to\n * `FirestoreSettings.cache` to tell the SDK which cache layer to use.\n *\n * Persistent cache cannot be used in a Node.js environment.\n */\n\n\nfunction persistentLocalCache(e) {\n return new __PRIVATE_PersistentLocalCacheImpl(e);\n}\n\nvar __PRIVATE_SingleTabManagerImpl = /*#__PURE__*/function () {\n function __PRIVATE_SingleTabManagerImpl(e) {\n _classCallCheck(this, __PRIVATE_SingleTabManagerImpl);\n\n this.forceOwnership = e, this.kind = \"persistentSingleTab\";\n }\n\n _createClass(__PRIVATE_SingleTabManagerImpl, [{\n key: \"toJSON\",\n value: function toJSON() {\n return {\n kind: this.kind\n };\n }\n /**\n * @internal\n */\n\n }, {\n key: \"_initialize\",\n value: function _initialize(e) {\n this._onlineComponentProvider = new OnlineComponentProvider(), this._offlineComponentProvider = new __PRIVATE_IndexedDbOfflineComponentProvider(this._onlineComponentProvider, null == e ? void 0 : e.cacheSizeBytes, this.forceOwnership);\n }\n }]);\n\n return __PRIVATE_SingleTabManagerImpl;\n}();\n\nvar __PRIVATE_MultiTabManagerImpl = /*#__PURE__*/function () {\n function __PRIVATE_MultiTabManagerImpl() {\n _classCallCheck(this, __PRIVATE_MultiTabManagerImpl);\n\n this.kind = \"PersistentMultipleTab\";\n }\n\n _createClass(__PRIVATE_MultiTabManagerImpl, [{\n key: \"toJSON\",\n value: function toJSON() {\n return {\n kind: this.kind\n };\n }\n /**\n * @internal\n */\n\n }, {\n key: \"_initialize\",\n value: function _initialize(e) {\n this._onlineComponentProvider = new OnlineComponentProvider(), this._offlineComponentProvider = new __PRIVATE_MultiTabOfflineComponentProvider(this._onlineComponentProvider, null == e ? void 0 : e.cacheSizeBytes);\n }\n }]);\n\n return __PRIVATE_MultiTabManagerImpl;\n}();\n/**\n * Creates an instance of `PersistentSingleTabManager`.\n *\n * @param settings Configures the created tab manager.\n */\n\n\nfunction persistentSingleTabManager(e) {\n return new __PRIVATE_SingleTabManagerImpl(null == e ? void 0 : e.forceOwnership);\n}\n/**\n * Creates an instance of `PersistentMultipleTabManager`.\n */\n\n\nfunction persistentMultipleTabManager() {\n return new __PRIVATE_MultiTabManagerImpl();\n}\n/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nvar ye = {\n maxAttempts: 5\n};\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A write batch, used to perform multiple writes as a single atomic unit.\n *\n * A `WriteBatch` object can be acquired by calling {@link writeBatch}. It\n * provides methods for adding writes to the write batch. None of the writes\n * will be committed (or visible locally) until {@link WriteBatch.commit} is\n * called.\n */\n\nvar WriteBatch = /*#__PURE__*/function () {\n /** @hideconstructor */\n function WriteBatch(e, t) {\n _classCallCheck(this, WriteBatch);\n\n this._firestore = e, this._commitHandler = t, this._mutations = [], this._committed = !1, this._dataReader = __PRIVATE_newUserDataReader(e);\n }\n\n _createClass(WriteBatch, [{\n key: \"set\",\n value: function set(e, t, n) {\n this._verifyNotCommitted();\n\n var r = __PRIVATE_validateReference(e, this._firestore),\n i = __PRIVATE_applyFirestoreDataConverter(r.converter, t, n),\n s = __PRIVATE_parseSetData(this._dataReader, \"WriteBatch.set\", r._key, i, null !== r.converter, n);\n\n return this._mutations.push(s.toMutation(r._key, Precondition.none())), this;\n }\n }, {\n key: \"update\",\n value: function update(e, t, n) {\n this._verifyNotCommitted();\n\n var i = __PRIVATE_validateReference(e, this._firestore); // For Compat types, we have to \"extract\" the underlying types before\n // performing validation.\n\n\n var s;\n\n for (var _len19 = arguments.length, r = new Array(_len19 > 3 ? _len19 - 3 : 0), _key19 = 3; _key19 < _len19; _key19++) {\n r[_key19 - 3] = arguments[_key19];\n }\n\n return s = \"string\" == typeof (t = getModularInstance(t)) || t instanceof FieldPath ? __PRIVATE_parseUpdateVarargs(this._dataReader, \"WriteBatch.update\", i._key, t, n, r) : __PRIVATE_parseUpdateData(this._dataReader, \"WriteBatch.update\", i._key, t), this._mutations.push(s.toMutation(i._key, Precondition.exists(!0))), this;\n }\n /**\n * Deletes the document referred to by the provided {@link DocumentReference}.\n *\n * @param documentRef - A reference to the document to be deleted.\n * @returns This `WriteBatch` instance. Used for chaining method calls.\n */\n\n }, {\n key: \"delete\",\n value: function _delete(e) {\n this._verifyNotCommitted();\n\n var t = __PRIVATE_validateReference(e, this._firestore);\n\n return this._mutations = this._mutations.concat(new __PRIVATE_DeleteMutation(t._key, Precondition.none())), this;\n }\n /**\n * Commits all of the writes in this write batch as a single atomic unit.\n *\n * The result of these writes will only be reflected in document reads that\n * occur after the returned promise resolves. If the client is offline, the\n * write fails. If you would like to see local modifications or buffer writes\n * until the client is online, use the full Firestore SDK.\n *\n * @returns A `Promise` resolved once all of the writes in the batch have been\n * successfully written to the backend as an atomic unit (note that it won't\n * resolve while you're offline).\n */\n\n }, {\n key: \"commit\",\n value: function commit() {\n return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();\n }\n }, {\n key: \"_verifyNotCommitted\",\n value: function _verifyNotCommitted() {\n if (this._committed) throw new FirestoreError(D.FAILED_PRECONDITION, \"A write batch can no longer be used after commit() has been called.\");\n }\n }]);\n\n return WriteBatch;\n}();\n\nfunction __PRIVATE_validateReference(e, t) {\n if ((e = getModularInstance(e)).firestore !== t) throw new FirestoreError(D.INVALID_ARGUMENT, \"Provided document reference is from a different Firestore instance.\");\n return e;\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// TODO(mrschmidt) Consider using `BaseTransaction` as the base class in the\n// legacy SDK.\n\n/**\n * A reference to a transaction.\n *\n * The `Transaction` object passed to a transaction's `updateFunction` provides\n * the methods to read and write data within the transaction context. See\n * {@link runTransaction}.\n */\n\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A reference to a transaction.\n *\n * The `Transaction` object passed to a transaction's `updateFunction` provides\n * the methods to read and write data within the transaction context. See\n * {@link runTransaction}.\n */\n\n\nvar Transaction = /*#__PURE__*/function (_Transaction$) {\n _inherits(Transaction, _Transaction$);\n\n var _super54 = _createSuper(Transaction);\n\n // This class implements the same logic as the Transaction API in the Lite SDK\n // but is subclassed in order to return its own DocumentSnapshot types.\n\n /** @hideconstructor */\n function Transaction(e, t) {\n var _this222;\n\n _classCallCheck(this, Transaction);\n\n _this222 = _super54.call(this, e, t), _this222._firestore = e;\n return _this222;\n }\n /**\n * Reads the document referenced by the provided {@link DocumentReference}.\n *\n * @param documentRef - A reference to the document to be read.\n * @returns A `DocumentSnapshot` with the read data.\n */\n\n\n _createClass(Transaction, [{\n key: \"get\",\n value: function get(e) {\n var _this223 = this;\n\n var t = __PRIVATE_validateReference(e, this._firestore),\n n = new __PRIVATE_ExpUserDataWriter(this._firestore);\n\n return _get(_getPrototypeOf(Transaction.prototype), \"get\", this).call(this, e).then(function (e) {\n return new DocumentSnapshot(_this223._firestore, n, t._key, e._document, new SnapshotMetadata(\n /* hasPendingWrites= */\n !1,\n /* fromCache= */\n !1), t.converter);\n });\n }\n }]);\n\n return Transaction;\n}( /*#__PURE__*/function () {\n /** @hideconstructor */\n function Transaction$1(e, t) {\n _classCallCheck(this, Transaction$1);\n\n this._firestore = e, this._transaction = t, this._dataReader = __PRIVATE_newUserDataReader(e);\n }\n /**\n * Reads the document referenced by the provided {@link DocumentReference}.\n *\n * @param documentRef - A reference to the document to be read.\n * @returns A `DocumentSnapshot` with the read data.\n */\n\n\n _createClass(Transaction$1, [{\n key: \"get\",\n value:\n /**\n * Reads the document referenced by the provided {@link DocumentReference}.\n *\n * @param documentRef - A reference to the document to be read.\n * @returns A `DocumentSnapshot` with the read data.\n */\n function get(e) {\n var _this224 = this;\n\n var t = __PRIVATE_validateReference(e, this._firestore),\n n = new __PRIVATE_LiteUserDataWriter(this._firestore);\n\n return this._transaction.lookup([t._key]).then(function (e) {\n if (!e || 1 !== e.length) return fail();\n var r = e[0];\n if (r.isFoundDocument()) return new DocumentSnapshot$1(_this224._firestore, n, r.key, r, t.converter);\n if (r.isNoDocument()) return new DocumentSnapshot$1(_this224._firestore, n, t._key, null, t.converter);\n throw fail();\n });\n }\n }, {\n key: \"set\",\n value: function set(e, t, n) {\n var r = __PRIVATE_validateReference(e, this._firestore),\n i = __PRIVATE_applyFirestoreDataConverter(r.converter, t, n),\n s = __PRIVATE_parseSetData(this._dataReader, \"Transaction.set\", r._key, i, null !== r.converter, n);\n\n return this._transaction.set(r._key, s), this;\n }\n }, {\n key: \"update\",\n value: function update(e, t, n) {\n var i = __PRIVATE_validateReference(e, this._firestore); // For Compat types, we have to \"extract\" the underlying types before\n // performing validation.\n\n\n // For Compat types, we have to \"extract\" the underlying types before\n // performing validation.\n var s;\n\n for (var _len20 = arguments.length, r = new Array(_len20 > 3 ? _len20 - 3 : 0), _key20 = 3; _key20 < _len20; _key20++) {\n r[_key20 - 3] = arguments[_key20];\n }\n\n return s = \"string\" == typeof (t = getModularInstance(t)) || t instanceof FieldPath ? __PRIVATE_parseUpdateVarargs(this._dataReader, \"Transaction.update\", i._key, t, n, r) : __PRIVATE_parseUpdateData(this._dataReader, \"Transaction.update\", i._key, t), this._transaction.update(i._key, s), this;\n }\n /**\n * Deletes the document referred to by the provided {@link DocumentReference}.\n *\n * @param documentRef - A reference to the document to be deleted.\n * @returns This `Transaction` instance. Used for chaining method calls.\n */\n\n }, {\n key: \"delete\",\n value:\n /**\n * Deletes the document referred to by the provided {@link DocumentReference}.\n *\n * @param documentRef - A reference to the document to be deleted.\n * @returns This `Transaction` instance. Used for chaining method calls.\n */\n function _delete(e) {\n var t = __PRIVATE_validateReference(e, this._firestore);\n\n return this._transaction.delete(t._key), this;\n }\n }]);\n\n return Transaction$1;\n}());\n/**\n * Executes the given `updateFunction` and then attempts to commit the changes\n * applied within the transaction. If any document read within the transaction\n * has changed, Cloud Firestore retries the `updateFunction`. If it fails to\n * commit after 5 attempts, the transaction fails.\n *\n * The maximum number of writes allowed in a single transaction is 500.\n *\n * @param firestore - A reference to the Firestore database to run this\n * transaction against.\n * @param updateFunction - The function to execute within the transaction\n * context.\n * @param options - An options object to configure maximum number of attempts to\n * commit.\n * @returns If the transaction completed successfully or was explicitly aborted\n * (the `updateFunction` returned a failed promise), the promise returned by the\n * `updateFunction `is returned here. Otherwise, if the transaction failed, a\n * rejected promise with the corresponding failure error is returned.\n */\n\n\nfunction runTransaction(e, t, n) {\n e = __PRIVATE_cast(e, Firestore);\n var r = Object.assign(Object.assign({}, ye), n);\n !function __PRIVATE_validateTransactionOptions(e) {\n if (e.maxAttempts < 1) throw new FirestoreError(D.INVALID_ARGUMENT, \"Max attempts must be at least 1\");\n }(r);\n return function __PRIVATE_firestoreClientTransaction(e, t, n) {\n var r = new __PRIVATE_Deferred();\n return e.asyncQueue.enqueueAndForget( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee76() {\n var i;\n return _regeneratorRuntime.wrap(function _callee76$(_context76) {\n while (1) {\n switch (_context76.prev = _context76.next) {\n case 0:\n _context76.next = 2;\n return __PRIVATE_getDatastore(e);\n\n case 2:\n i = _context76.sent;\n new __PRIVATE_TransactionRunner(e.asyncQueue, i, n, t, r).ja();\n\n case 4:\n case \"end\":\n return _context76.stop();\n }\n }\n }, _callee76);\n }))), r.promise;\n }(ensureFirestoreConfigured(e), function (n) {\n return t(new Transaction(e, n));\n }, r);\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or\n * {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.\n */\n\n\nfunction deleteField() {\n return new __PRIVATE_DeleteFieldValueImpl(\"deleteField\");\n}\n/**\n * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to\n * include a server-generated timestamp in the written data.\n */\n\n\nfunction serverTimestamp() {\n return new __PRIVATE_ServerTimestampFieldValueImpl(\"serverTimestamp\");\n}\n/**\n * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link\n * @firebase/firestore/lite#(updateDoc:1)} that tells the server to union the given elements with any array\n * value that already exists on the server. Each specified element that doesn't\n * already exist in the array will be added to the end. If the field being\n * modified is not already an array it will be overwritten with an array\n * containing exactly the specified elements.\n *\n * @param elements - The elements to union into the array.\n * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or\n * `updateDoc()`.\n */\n\n\nfunction arrayUnion() {\n for (var _len21 = arguments.length, e = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {\n e[_key21] = arguments[_key21];\n }\n\n // NOTE: We don't actually parse the data until it's used in set() or\n // update() since we'd need the Firestore instance to do this.\n return new __PRIVATE_ArrayUnionFieldValueImpl(\"arrayUnion\", e);\n}\n/**\n * Returns a special value that can be used with {@link (setDoc:1)} or {@link\n * updateDoc:1} that tells the server to remove the given elements from any\n * array value that already exists on the server. All instances of each element\n * specified will be removed from the array. If the field being modified is not\n * already an array it will be overwritten with an empty array.\n *\n * @param elements - The elements to remove from the array.\n * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or\n * `updateDoc()`\n */\n\n\nfunction arrayRemove() {\n for (var _len22 = arguments.length, e = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {\n e[_key22] = arguments[_key22];\n }\n\n // NOTE: We don't actually parse the data until it's used in set() or\n // update() since we'd need the Firestore instance to do this.\n return new __PRIVATE_ArrayRemoveFieldValueImpl(\"arrayRemove\", e);\n}\n/**\n * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link\n * @firebase/firestore/lite#(updateDoc:1)} that tells the server to increment the field's current value by\n * the given value.\n *\n * If either the operand or the current field value uses floating point\n * precision, all arithmetic follows IEEE 754 semantics. If both values are\n * integers, values outside of JavaScript's safe number range\n * (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to\n * precision loss. Furthermore, once processed by the Firestore backend, all\n * integer operations are capped between -2^63 and 2^63-1.\n *\n * If the current field value is not of type `number`, or if the field does not\n * yet exist, the transformation sets the field to the given value.\n *\n * @param n - The value to increment by.\n * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or\n * `updateDoc()`\n */\n\n\nfunction increment(e) {\n return new __PRIVATE_NumericIncrementFieldValueImpl(\"increment\", e);\n}\n/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Creates a write batch, used for performing multiple writes as a single\n * atomic operation. The maximum number of writes allowed in a single {@link WriteBatch}\n * is 500.\n *\n * Unlike transactions, write batches are persisted offline and therefore are\n * preferable when you don't need to condition your writes on read data.\n *\n * @returns A {@link WriteBatch} that can be used to atomically execute multiple\n * writes.\n */\n\n\nfunction writeBatch(e) {\n return ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore)), new WriteBatch(e, function (t) {\n return executeWrite(e, t);\n });\n}\n/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nfunction setIndexConfiguration(e, t) {\n var n;\n var r = ensureFirestoreConfigured(e = __PRIVATE_cast(e, Firestore));\n if (!r._uninitializedComponentsProvider || \"memory\" === (null === (n = r._uninitializedComponentsProvider) || void 0 === n ? void 0 : n._offlineKind)) // PORTING NOTE: We don't return an error if the user has not enabled\n // persistence since `enableIndexeddbPersistence()` can fail on the Web.\n return __PRIVATE_logWarn(\"Cannot enable indexes when persistence is disabled\"), Promise.resolve();\n\n var i = function __PRIVATE_parseIndexes(e) {\n var t = \"string\" == typeof e ? function __PRIVATE_tryParseJson(e) {\n try {\n return JSON.parse(e);\n } catch (e) {\n throw new FirestoreError(D.INVALID_ARGUMENT, \"Failed to parse JSON: \" + (null == e ? void 0 : e.message));\n }\n }(e) : e,\n n = [];\n\n if (Array.isArray(t.indexes)) {\n var _iterator86 = _createForOfIteratorHelper(t.indexes),\n _step86;\n\n try {\n for (_iterator86.s(); !(_step86 = _iterator86.n()).done;) {\n var _e116 = _step86.value;\n\n var _t55 = __PRIVATE_tryGetString(_e116, \"collectionGroup\"),\n _r36 = [];\n\n if (Array.isArray(_e116.fields)) {\n var _iterator87 = _createForOfIteratorHelper(_e116.fields),\n _step87;\n\n try {\n for (_iterator87.s(); !(_step87 = _iterator87.n()).done;) {\n var _t56 = _step87.value;\n\n var _e117 = __PRIVATE_fieldPathFromDotSeparatedString(\"setIndexConfiguration\", __PRIVATE_tryGetString(_t56, \"fieldPath\"));\n\n \"CONTAINS\" === _t56.arrayConfig ? _r36.push(new IndexSegment(_e117, 2\n /* IndexKind.CONTAINS */\n )) : \"ASCENDING\" === _t56.order ? _r36.push(new IndexSegment(_e117, 0\n /* IndexKind.ASCENDING */\n )) : \"DESCENDING\" === _t56.order && _r36.push(new IndexSegment(_e117, 1\n /* IndexKind.DESCENDING */\n ));\n }\n } catch (err) {\n _iterator87.e(err);\n } finally {\n _iterator87.f();\n }\n }\n\n n.push(new FieldIndex(FieldIndex.UNKNOWN_ID, _t55, _r36, IndexState.empty()));\n }\n } catch (err) {\n _iterator86.e(err);\n } finally {\n _iterator86.f();\n }\n }\n\n return n;\n }(t);\n\n return __PRIVATE_firestoreClientSetIndexConfiguration(r, i);\n}\n\nfunction __PRIVATE_tryGetString(e, t) {\n if (\"string\" != typeof e[t]) throw new FirestoreError(D.INVALID_ARGUMENT, \"Missing string value for: \" + t);\n return e[t];\n}\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A `PersistentCacheIndexManager` for configuring persistent cache indexes used\n * for local query execution.\n *\n * To use, call `getPersistentCacheIndexManager()` to get an instance.\n */\n\n\nvar PersistentCacheIndexManager = /*#__PURE__*/_createClass(\n/** @hideconstructor */\nfunction PersistentCacheIndexManager(e) {\n _classCallCheck(this, PersistentCacheIndexManager);\n\n this._client = e,\n /** A type string to uniquely identify instances of this class. */\n this.type = \"PersistentCacheIndexManager\";\n});\n/**\n * Returns the PersistentCache Index Manager used by the given `Firestore`\n * object.\n *\n * @return The `PersistentCacheIndexManager` instance, or `null` if local\n * persistent storage is not in use.\n */\n\n\nfunction getPersistentCacheIndexManager(e) {\n var t;\n e = __PRIVATE_cast(e, Firestore);\n var n = we.get(e);\n if (n) return n;\n var r = ensureFirestoreConfigured(e);\n if (\"persistent\" !== (null === (t = r._uninitializedComponentsProvider) || void 0 === t ? void 0 : t._offlineKind)) return null;\n var i = new PersistentCacheIndexManager(r);\n return we.set(e, i), i;\n}\n/**\n * Enables the SDK to create persistent cache indexes automatically for local\n * query execution when the SDK believes cache indexes can help improve\n * performance.\n *\n * This feature is disabled by default.\n */\n\n\nfunction enablePersistentCacheIndexAutoCreation(e) {\n __PRIVATE_setPersistentCacheIndexAutoCreationEnabled(e, !0);\n}\n/**\n * Stops creating persistent cache indexes automatically for local query\n * execution. The indexes which have been created by calling\n * `enablePersistentCacheIndexAutoCreation()` still take effect.\n */\n\n\nfunction disablePersistentCacheIndexAutoCreation(e) {\n __PRIVATE_setPersistentCacheIndexAutoCreationEnabled(e, !1);\n}\n/**\n * Removes all persistent cache indexes.\n *\n * Please note this function will also deletes indexes generated by\n * `setIndexConfiguration()`, which is deprecated.\n */\n\n\nfunction deleteAllPersistentCacheIndexes(e) {\n e._client.verifyNotTerminated();\n\n __PRIVATE_firestoreClientDeleteAllFieldIndexes(e._client).then(function (e) {\n return __PRIVATE_logDebug(\"deleting all persistent cache indexes succeeded\");\n }).catch(function (e) {\n return __PRIVATE_logWarn(\"deleting all persistent cache indexes failed\", e);\n });\n}\n\nfunction __PRIVATE_setPersistentCacheIndexAutoCreationEnabled(e, t) {\n e._client.verifyNotTerminated();\n\n __PRIVATE_firestoreClientSetPersistentCacheIndexAutoCreationEnabled(e._client, t).then(function (e) {\n return __PRIVATE_logDebug(\"setting persistent cache index auto creation isEnabled=\".concat(t, \" succeeded\"));\n }).catch(function (e) {\n return __PRIVATE_logWarn(\"setting persistent cache index auto creation isEnabled=\".concat(t, \" failed\"), e);\n });\n}\n/**\n * Maps `Firestore` instances to their corresponding\n * `PersistentCacheIndexManager` instances.\n *\n * Use a `WeakMap` so that the mapping will be automatically dropped when the\n * `Firestore` instance is garbage collected. This emulates a private member\n * as described in https://goo.gle/454yvug.\n */\n\n\nvar we = new WeakMap();\n/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Testing hooks for use by Firestore's integration test suite to reach into the\n * SDK internals to validate logic and behavior that is not visible from the\n * public API surface.\n *\n * @internal\n */\n\nvar TestingHooks = /*#__PURE__*/function () {\n function TestingHooks() {\n _classCallCheck(this, TestingHooks);\n\n throw new Error(\"instances of this class should not be created\");\n }\n /**\n * Registers a callback to be notified when an existence filter mismatch\n * occurs in the Watch listen stream.\n *\n * The relative order in which callbacks are notified is unspecified; do not\n * rely on any particular ordering. If a given callback is registered multiple\n * times then it will be notified multiple times, once per registration.\n *\n * @param callback the callback to invoke upon existence filter mismatch.\n *\n * @return a function that, when called, unregisters the given callback; only\n * the first invocation of the returned function does anything; all subsequent\n * invocations do nothing.\n */\n\n\n _createClass(TestingHooks, null, [{\n key: \"onExistenceFilterMismatch\",\n value: function onExistenceFilterMismatch(e) {\n return __PRIVATE_TestingHooksSpiImpl.instance.onExistenceFilterMismatch(e);\n }\n }]);\n\n return TestingHooks;\n}();\n/**\n * The implementation of `TestingHooksSpi`.\n */\n\n\nvar __PRIVATE_TestingHooksSpiImpl = /*#__PURE__*/function () {\n function __PRIVATE_TestingHooksSpiImpl() {\n _classCallCheck(this, __PRIVATE_TestingHooksSpiImpl);\n\n this.Cu = new Map();\n }\n\n _createClass(__PRIVATE_TestingHooksSpiImpl, [{\n key: \"tt\",\n value: function tt(e) {\n this.Cu.forEach(function (t) {\n return t(e);\n });\n }\n }, {\n key: \"onExistenceFilterMismatch\",\n value: function onExistenceFilterMismatch(e) {\n var t = Symbol(),\n n = this.Cu;\n return n.set(t, e), function () {\n return n.delete(t);\n };\n }\n }], [{\n key: \"instance\",\n get: function get() {\n return Se || (Se = new __PRIVATE_TestingHooksSpiImpl(), function __PRIVATE_setTestingHooksSpi(e) {\n if (ce) throw new Error(\"a TestingHooksSpi instance is already set\");\n ce = e;\n }(Se)), Se;\n }\n }]);\n\n return __PRIVATE_TestingHooksSpiImpl;\n}();\n\nvar Se = null;\n/**\n * Cloud Firestore\n *\n * @packageDocumentation\n */\n\n!function __PRIVATE_registerFirestore(e) {\n var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;\n !function __PRIVATE_setSDKVersion(e) {\n S = e;\n }(SDK_VERSION), _registerComponent(new Component(\"firestore\", function (e, _ref57) {\n var n = _ref57.instanceIdentifier,\n r = _ref57.options;\n var i = e.getProvider(\"app\").getImmediate(),\n s = new Firestore(new __PRIVATE_FirebaseAuthCredentialsProvider(e.getProvider(\"auth-internal\")), new __PRIVATE_FirebaseAppCheckTokenProvider(e.getProvider(\"app-check-internal\")), function __PRIVATE_databaseIdFromApp(e, t) {\n if (!Object.prototype.hasOwnProperty.apply(e.options, [\"projectId\"])) throw new FirestoreError(D.INVALID_ARGUMENT, '\"projectId\" not provided in firebase.initializeApp.');\n return new DatabaseId(e.options.projectId, t);\n }(i, n), i);\n return r = Object.assign({\n useFetchStreams: t\n }, r), s._setSettings(r), s;\n }, \"PUBLIC\").setMultipleInstances(!0)), registerVersion(w, \"4.4.2\", e), // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation\n registerVersion(w, \"4.4.2\", \"esm2017\");\n}();\nexport { AbstractUserDataWriter, AggregateField, AggregateQuerySnapshot, Bytes, fe as CACHE_SIZE_UNLIMITED, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, LoadBundleTask, PersistentCacheIndexManager, Query, QueryCompositeFilterConstraint, QueryConstraint, QueryDocumentSnapshot, QueryEndAtConstraint, QueryFieldFilterConstraint, QueryLimitConstraint, QueryOrderByConstraint, QuerySnapshot, QueryStartAtConstraint, SnapshotMetadata, Timestamp, Transaction, WriteBatch, __PRIVATE_AutoId as _AutoId, ByteString as _ByteString, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, __PRIVATE_EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, __PRIVATE_EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, TestingHooks as _TestingHooks, __PRIVATE_cast as _cast, __PRIVATE_debugAssert as _debugAssert, __PRIVATE_isBase64Available as _isBase64Available, __PRIVATE_logWarn as _logWarn, __PRIVATE_validateIsNotUsedTogether as _validateIsNotUsedTogether, addDoc, aggregateFieldEqual, aggregateQuerySnapshotEqual, and, arrayRemove, arrayUnion, average, clearIndexedDbPersistence, collection, collectionGroup, connectFirestoreEmulator, count, deleteAllPersistentCacheIndexes, deleteDoc, deleteField, disableNetwork, disablePersistentCacheIndexAutoCreation, doc, documentId, enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence, enableNetwork, enablePersistentCacheIndexAutoCreation, endAt, endBefore, ensureFirestoreConfigured, executeWrite, getAggregateFromServer, getCountFromServer, getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, getFirestore, getPersistentCacheIndexManager, increment, initializeFirestore, limit, limitToLast, loadBundle, memoryEagerGarbageCollector, memoryLocalCache, memoryLruGarbageCollector, namedQuery, onSnapshot, onSnapshotsInSync, or, orderBy, persistentLocalCache, persistentMultipleTabManager, persistentSingleTabManager, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setIndexConfiguration, setLogLevel, snapshotEqual, startAfter, startAt, sum, terminate, updateDoc, waitForPendingWrites, where, writeBatch };"],"names":["_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","from","test","_unsupportedIterableToArray","length","i","F","s","done","value","e","_e141","f","TypeError","err","normalCompletion","didErr","step","next","_e142","return","arr","len","arr2","_createSuper","Derived","hasNativeReflectConstruct","Reflect","construct","sham","Proxy","Boolean","valueOf","_isNativeReflectConstruct","result","Super","NewTarget","this","arguments","apply","w","User","uid","key","isAuthenticated","UNAUTHENTICATED","GOOGLE_CREDENTIALS","FIRST_PARTY","MOCK_USER","S","b","__PRIVATE_getLogLevel","logLevel","__PRIVATE_logDebug","_len","t","_key","map","__PRIVATE_argToString","debug","concat","__PRIVATE_logError","_len2","_key2","error","__PRIVATE_logWarn","_len3","_key3","warn","JSON","stringify","fail","undefined","Error","__PRIVATE_hardAssert","__PRIVATE_debugCast","D","OK","CANCELLED","UNKNOWN","INVALID_ARGUMENT","DEADLINE_EXCEEDED","NOT_FOUND","ALREADY_EXISTS","PERMISSION_DENIED","RESOURCE_EXHAUSTED","FAILED_PRECONDITION","ABORTED","OUT_OF_RANGE","UNIMPLEMENTED","INTERNAL","UNAVAILABLE","DATA_LOSS","FirestoreError","_FirebaseError","_super","_this","code","message","__PRIVATE_Deferred","_this2","promise","Promise","resolve","reject","__PRIVATE_OAuthToken","user","type","headers","Map","set","__PRIVATE_EmptyAuthCredentialsProvider","enqueueRetryable","__PRIVATE_EmulatorAuthCredentialsProvider","token","changeListener","_this3","__PRIVATE_FirebaseAuthCredentialsProvider","currentUser","forceRefresh","auth","_this4","__PRIVATE_guardedChangeListener","r","u","__PRIVATE_awaitNextToken","_callee","_context","prev","stop","__PRIVATE_registerAuth","addAuthTokenListener","onInit","setTimeout","_e2","getImmediate","optional","_this5","getToken","then","accessToken","removeAuthTokenListener","getUid","__PRIVATE_FirstPartyToken","l","h","P","I","get","T","__PRIVATE_FirstPartyAuthCredentialsProvider","AppCheckToken","__PRIVATE_FirebaseAppCheckTokenProvider","A","appCheck","R","_this6","onTokenChanged","__PRIVATE_registerAppCheck","addTokenListener","_e3","_this7","removeTokenListener","__PRIVATE_randomBytes","self","crypto","msCrypto","Uint8Array","getRandomValues","_t","Math","floor","random","__PRIVATE_AutoId","charAt","__PRIVATE_primitiveComparator","__PRIVATE_arrayEquals","every","Timestamp","seconds","nanoseconds","Date","toMillis","String","padStart","fromMillis","now","getTime","SnapshotVersion","timestamp","_compareTo","isEqual","BasePath","segments","offset","comparator","limit","forEach","push","min","_n","ResourcePath","_BasePath","_super2","toArray","join","canonicalString","encodeURIComponent","_len4","_key4","_i","_e4","indexOf","split","filter","C","FieldPath$1","_BasePath2","_super3","replace","isValidIdentifier","__PRIVATE_addCurrentSegment","_t2","_t3","DocumentKey","path","popLast","lastSegment","fromString","popFirst","emptyPath","FieldIndex","indexId","collectionGroup","fields","indexState","UNKNOWN_ID","__PRIVATE_newIndexOffsetSuccessorFromReadTime","toTimestamp","fromTimestamp","IndexOffset","empty","__PRIVATE_newIndexOffsetFromDocument","readTime","documentKey","largestBatchId","max","__PRIVATE_indexOffsetComparator","compareTo","v","PersistenceTransaction","onCommittedListeners","__PRIVATE_ignoreIfPrimaryLeaseLoss","_x","_PRIVATE_ignoreIfPrimaryLeaseLoss","_callee77","_context77","PersistencePromise","_this8","nextCallback","catchCallback","isDone","callbackAttached","_this9","wrapFailure","wrapSuccess","_this10","wrapUserFunction","_step","_iterator","_loop","_this11","waitFor","_loop2","_","a","process","__PRIVATE_SimpleDbTransaction","_this12","action","transaction","aborted","V","oncomplete","onabort","__PRIVATE_IndexedDbTransactionError","onerror","__PRIVATE_checkForAndReportiOSError","target","abort","commit","objectStore","__PRIVATE_SimpleDbStore","__PRIVATE_SimpleDb","version","p","_runTransaction","_O","_callee2","_this13","_context2","t0","db","indexedDB","open","onsuccess","onblocked","onupgradeneeded","oldVersion","N","sent","B","onversionchange","abrupt","_x2","_callee4","_ret","_t4","_n2","_this14","_context4","delegateYield","_callee3","_context3","O","g","catch","toPromise","m","t1","close","_x3","_x4","_x5","_x6","__PRIVATE_wrapRequest","window","deleteDatabase","__PRIVATE_env","store","match","Number","__PRIVATE_IterationController","k","q","K","delete","_FirestoreError","_super4","_this15","__PRIVATE_isIndexedDbTransactionError","put","add","_this16","count","options","index","getAll","_e5","range","_e6","cursor","_t5","G","J","primaryKey","continue","_e7","$","reverse","openKeyCursor","openCursor","_t6","_e8","__PRIVATE_ListenSequence","_this21","previousValue","sequenceNumberHandler","se","oe","writeSequenceNumber","__PRIVATE_isNullOrUndefined","__PRIVATE_isNegativeZero","isSafeInteger","isInteger","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","_e","H","Y","Z","__PRIVATE_objectSize","hasOwnProperty","_forEach","_isEmpty","SortedMap","root","LLRBNode","EMPTY","insert","copy","BLACK","remove","isEmpty","left","right","size","minKey","maxKey","inorderTraversal","reverseTraversal","SortedMapIterator","isReverse","nodeStack","pop","color","RED","fixUp","isRed","moveRedLeft","removeMin","rotateRight","moveRedRight","rotateLeft","colorFlip","check","pow","LLRBEmptyNode","SortedSet","data","getIteratorFrom","hasNext","getNext","getIterator","SortedSetIterator","has","_e9","iter","FieldMask","sort","_step2","_iterator2","_e10","_step3","_iterator3","_step4","_iterator4","isPrefixOf","__PRIVATE_Base64DecodeError","_Error","_super6","_this23","ByteString","_Symbol$iterator","binaryString","_this24","charCodeAt","btoa","atob","DOMException","fromCharCode","EMPTY_BYTE_STRING","ee","RegExp","__PRIVATE_normalizeTimestamp","exec","_e11","substr","nanos","__PRIVATE_normalizeNumber","__PRIVATE_normalizeByteString","fromBase64String","fromUint8Array","__PRIVATE_isServerTimestamp","mapValue","__type__","stringValue","__PRIVATE_getPreviousValue","__previous_value__","__PRIVATE_getLocalWriteTime","__local_write_time__","timestampValue","DatabaseInfo","databaseId","appId","persistenceKey","host","ssl","forceLongPolling","autoDetectLongPolling","longPollingOptions","useFetchStreams","DatabaseId","projectId","database","te","__PRIVATE_typeOrder","__PRIVATE_isMaxValue","__PRIVATE_valueEquals","booleanValue","bytesValue","referenceValue","geoPointValue","latitude","longitude","integerValue","_n3","doubleValue","isNaN","arrayValue","values","_e12","__PRIVATE_arrayValueContains","find","__PRIVATE_valueCompare","__PRIVATE_compareTimestamps","_e13","_t9","_e14","_t10","keys","_e15","_t11","canonicalId","__PRIVATE_canonifyValue","toBase64","fromName","_step5","_iterator5","_step6","_iterator6","__PRIVATE_isMapValue","__PRIVATE_deepClone","assign","_t12","ObjectValue","getFieldsMap","_this25","isImmediateParentOf","_e16","applyChanges","field","_step7","_iterator7","_t13","__PRIVATE_extractFieldMask","_e17","_step8","_iterator8","_n4","child","MutableDocument","documentType","createTime","documentState","hasLocalMutations","hasCommittedMutations","clone","Bound","position","inclusive","__PRIVATE_boundCompareToDocument","isKeyField","dir","__PRIVATE_boundEquals","OrderBy","__PRIVATE_orderByEquals","Filter","FieldFilter","_Filter","_super7","_this26","op","matchesComparison","createKeyFieldInFilter","__PRIVATE_KeyFieldFilter","__PRIVATE_ArrayContainsFilter","__PRIVATE_InFilter","__PRIVATE_NotInFilter","__PRIVATE_ArrayContainsAnyFilter","__PRIVATE_KeyFieldInFilter","__PRIVATE_KeyFieldNotInFilter","CompositeFilter","_Filter2","_super8","_this27","filters","ue","__PRIVATE_compositeFilterIsConjunction","matches","reduce","getFlattenedFilters","__PRIVATE_compositeFilterIsFlatConjunction","__PRIVATE_compositeFilterIsFlat","_step9","_iterator9","__PRIVATE_canonifyFilter","__PRIVATE_filterEquals","__PRIVATE_stringifyFilter","getFilters","_FieldFilter","_super9","_this28","_FieldFilter2","_super10","_this29","__PRIVATE_extractDocumentKeysFromArrayValue","some","_FieldFilter3","_super11","_this30","_FieldFilter4","_super12","_FieldFilter5","_super13","_FieldFilter6","_super14","nullValue","_FieldFilter7","_super15","_this31","__PRIVATE_TargetImpl","orderBy","startAt","endAt","ce","__PRIVATE_newTarget","__PRIVATE_canonifyTarget","_e18","__PRIVATE_targetEquals","_n5","__PRIVATE_QueryImpl","explicitOrderBy","limitType","le","he","Pe","__PRIVATE_newQuery","__PRIVATE_newQueryForPath","__PRIVATE_queryMatchesAllDocuments","__PRIVATE_isCollectionGroupQuery","__PRIVATE_queryNormalizedOrderBy","_step12","_e23","Set","_iterator12","_n8","isInequality","keyField","__PRIVATE_queryToTarget","__PRIVATE__queryToTarget","__PRIVATE_queryWithLimit","__PRIVATE_queryEquals","__PRIVATE_canonifyQuery","__PRIVATE_stringifyQuery","__PRIVATE_queryMatches","isFoundDocument","hasCollectionId","isDocumentKey","_step13","_iterator13","_step14","_iterator14","__PRIVATE_newQueryComparator","_step15","_iterator15","_e24","__PRIVATE_compareDocs","ObjectMap","mapKeyFn","equalsFn","inner","innerSize","_step16","_iterator16","_step16$value","_t16","_n9","splice","_step17","_iterator17","_step17$value","_t17","re","__PRIVATE_mutableDocumentMap","ie","documentMap","_len5","_key5","_i2","_e25","__PRIVATE_convertOverlayedDocumentMapToDocumentMap","overlayedDocument","__PRIVATE_newOverlayMap","__PRIVATE_newDocumentKeyMap","__PRIVATE_newMutationMap","__PRIVATE_documentKeySet","_len6","_key6","_i3","_e26","__PRIVATE_targetIdSet","__PRIVATE_toDouble","useProto3Json","__PRIVATE_toInteger","toNumber","TransformOperation","__PRIVATE_applyTransformOperationToLocalView","__PRIVATE_ServerTimestampTransform","__PRIVATE_ArrayUnionTransformOperation","__PRIVATE_applyArrayUnionTransformOperation","__PRIVATE_ArrayRemoveTransformOperation","__PRIVATE_applyArrayRemoveTransformOperation","__PRIVATE_computeTransformOperationBaseValue","asNumber","Ie","serializer","__PRIVATE_applyTransformOperationToRemoteDocument","__PRIVATE_NumericIncrementTransformOperation","_TransformOperation","_super16","_TransformOperation2","_super17","_this32","elements","_step18","__PRIVATE_coercedFieldValuesArray","_iterator18","_loop3","_TransformOperation3","_super18","_this33","_step19","_iterator19","_loop4","_TransformOperation4","_super19","_this34","MutationResult","transformResults","Precondition","updateTime","exists","__PRIVATE_preconditionIsValidForDocument","Mutation","__PRIVATE_calculateOverlayMutation","isNoDocument","__PRIVATE_DeleteMutation","none","__PRIVATE_SetMutation","_step20","_iterator20","_e27","_t18","__PRIVATE_PatchMutation","__PRIVATE_mutationApplyToRemoteDocument","__PRIVATE_serverTransformResults","fieldTransforms","setAll","convertToFoundDocument","setHasCommittedMutations","precondition","__PRIVATE_getPatch","convertToUnknownDocument","convertToNoDocument","__PRIVATE_mutationApplyToLocalView","__PRIVATE_localTransformResults","setHasLocalMutations","unionWith","fieldMask","__PRIVATE_mutationExtractBaseValue","_step21","_iterator21","_e28","transform","__PRIVATE_mutationEquals","__PRIVATE_fieldTransformEquals","_Mutation","_super20","_this35","_Mutation2","_super21","_this36","_step22","_iterator22","_e29","ae","_Mutation3","_super22","_this37","__PRIVATE_VerifyMutation","_Mutation4","_super23","_this38","MutationBatch","batchId","localWriteTime","baseMutations","mutations","mutationResults","_t19","_step23","_iterator23","_step24","_iterator24","_n10","_this39","applyToLocalView","mutatedFields","isValidDocument","MutationBatchResult","batch","commitVersion","docVersions","_e30","Overlay","mutation","__PRIVATE_isPermanentError","__PRIVATE_mapCodeFromRpcCode","JsonProtoSerializer","toISOString","__PRIVATE_toBytes","toUint8Array","__PRIVATE_toVersion","__PRIVATE_fromVersion","__PRIVATE_toResourceName","__PRIVATE_toResourcePath","__PRIVATE_fromResourceName","__PRIVATE_isValidResourceName","__PRIVATE_toName","__PRIVATE_fromQueryPath","__PRIVATE_extractLocalPathFromResourceName","__PRIVATE_getEncodedDatabaseId","__PRIVATE_toMutationDocument","toMutation","update","updateMask","__PRIVATE_toDocumentMask","verify","updateTransforms","fieldPath","setToServerValue","appendMissingElements","removeAllFromArray","increment","isNone","currentDocument","__PRIVATE_convertQueryTargetToQuery","parent","structuredQuery","_e39","allDescendants","collectionId","where","__PRIVATE_fromFilter","__PRIVATE_fromFieldPathReference","direction","before","unaryFilter","create","NaN","fieldFilter","compositeFilter","fromServerFormat","fieldPaths","__PRIVATE_LocalSerializer","ct","__PRIVATE_fromBundledQuery","__PRIVATE_FirestoreIndexValueWriter","It","Tt","Et","dt","_n13","At","Rt","Vt","ft","gt","_n14","yt","wt","St","_i9","_Object$keys","_e44","_step28","_iterator28","_e45","_this52","bt","__PRIVATE_MemoryIndexManager","__PRIVATE_MemoryCollectionParentIndex","getEntries","LruParams","cacheSizeCollectionThreshold","percentileToCollect","maximumSequenceNumbersToCollect","DEFAULT_COLLECTION_PERCENTILE","DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT","DEFAULT","DISABLED","__PRIVATE_TargetIdGenerator","On","RemoteDocumentChangeBuffer","changes","changesApplied","assertNotApplied","newInvalidDocument","setReadTime","getFromCache","getAllFromCache","OverlayedDocument","LocalDocumentsView","remoteDocumentCache","mutationQueue","documentOverlayCache","indexManager","_this99","getOverlay","getEntry","_this100","getLocalViewOfDocuments","_this101","populateOverlays","computeViews","_this102","getOverlays","getFieldMask","recalculateAndSaveOverlays","_this103","getAllMutationBatchesAffectingDocumentKeys","_step56","_iterator56","_loop6","getReverseIterator","_loop7","_r20","saveOverlays","_this104","getDocumentsMatchingDocumentQuery","getDocumentsMatchingCollectionGroupQuery","getDocumentsMatchingCollectionQuery","_this105","getAllFromCollectionGroup","getOverlaysForCollectionGroup","getDocument","_this106","getCollectionParents","_this107","getOverlaysForCollection","getDocumentsMatchingQuery","getKey","__PRIVATE_MemoryBundleCache","cr","lr","id","query","bundledQuery","__PRIVATE_MemoryDocumentOverlayCache","overlays","hr","_this108","_this109","ht","_this110","_e72","_s5","_e73","getCollectionGroup","_t36","_e74","__PRIVATE_ReferenceSet","Pr","__PRIVATE_DocReference","Ir","Tr","Er","_this111","addReference","Ar","_this112","removeReference","_this113","forEachInRange","_this114","firstAfterOrEqual","pr","__PRIVATE_MemoryMutationQueue","referenceDelegate","yr","wr","_step57","_iterator57","_t37","addToCollectionParentIndex","Sr","br","_this115","POSITIVE_INFINITY","_this116","Dr","forEachWhile","_this117","_this118","Cr","shift","markPotentiallyOrphaned","__PRIVATE_MemoryRemoteDocumentCacheImpl","vr","docs","document","mutableCopy","_this119","_$getNext","_e75","_o4","__PRIVATE_MemoryRemoteDocumentChangeBuffer","_RemoteDocumentChange2","_super26","_this120","ar","_this121","addEntry","removeEntry","__PRIVATE_MemoryTargetCache","persistence","Mr","lastRemoteSnapshotVersion","highestTargetId","Or","Nr","targetCount","Br","Nn","targetId","sequenceNumber","qn","Vr","_this122","removeMatchingKeysForTargetId","dr","Rr","gr","containsKey","__PRIVATE_MemoryPersistence","_this123","Lr","kr","qr","Qr","Kr","$r","toKey","_this124","__PRIVATE_MemoryTransaction","Ur","Wr","raiseOnCommittedEvent","or","_PersistenceTransacti2","_super27","_this125","currentSequenceNumber","__PRIVATE_MemoryEagerDelegate","zr","jr","Jr","_this126","getTargetCache","getMatchingKeysForTargetId","removeTargetData","_this127","getRemoteDocumentCache","newChangeBuffer","fromPath","Yr","_this128","_this129","Gr","__PRIVATE_LocalViewChanges","fromCache","qi","Qi","_step59","_iterator59","docChanges","_e76","doc","QueryContext","_documentReadCount","__PRIVATE_QueryEngine","$i","Ui","Wi","Gi","zi","_this153","ji","Hi","Ji","Yi","documentReadCount","createTargetIndexes","_this154","getIndexType","getDocumentsMatchingTarget","getDocuments","getMinOffset","Zi","Xi","es","_this155","last","first","hasPendingWrites","__PRIVATE_LocalStoreImpl","ts","ns","rs","ss","os","getBundleCache","_s","getDocumentOverlayCache","getIndexManager","getMutationQueue","localDocuments","setIndexManager","initialize","_this156","runTransaction","collect","__PRIVATE_newLocalStore","__PRIVATE_localStoreHandleUserChange","_x9","_x10","_PRIVATE_localStoreHandleUserChange","_callee78","_context78","getAllMutationBatches","_step88","_iterator88","_e118","_step90","_iterator90","_t57","_step89","_iterator89","_e119","_step91","_iterator91","_t58","us","removedBatchIds","addedBatchIds","__PRIVATE_localStoreAcknowledgeBatch","trackRemovals","applyToRemoteDocument","removeMutationBatch","performConsistencyCheck","removeOverlaysForBatchId","recalculateAndSaveOverlaysForDocumentKeys","_n25","__PRIVATE_localStoreGetLastRemoteSnapshotVersion","getLastRemoteSnapshotVersion","__PRIVATE_localStoreGetNextMutationBatch","getNextMutationBatchAfterBatchId","__PRIVATE_LocalClientState","activeTargetIds","updateTimeMs","__PRIVATE_MemorySharedClientState","no","ro","onlineStateHandler","As","Rs","__PRIVATE_NoopConnectivityMonitor","__PRIVATE_BrowserConnectivityMonitor","_this161","so","oo","_o","ao","uo","co","removeEventListener","addEventListener","_step62","_iterator62","_step63","_iterator63","Ae","__PRIVATE_generateUniqueDebugId","round","Re","BatchGetDocuments","Commit","RunQuery","RunAggregationQuery","__PRIVATE_StreamBridge","lo","ho","Io","Eo","Ao","Ve","__PRIVATE_WebChannelConnection","_PRIVATE_RestConnect","_super28","_this162","setWithCredentials","listenOnce","getLastErrorCode","_t42","getResponseJson","_n26","getStatus","getResponseText","_e88","_t43","status","_e89","toLowerCase","send","fo","httpSessionIdParam","initMessageHeaders","messageUrlParams","sendRawJson","supportsCrossDomainXhr","internalChannelParams","forwardChannelRequestTimeoutMs","detectBufferingProxy","timeoutSeconds","longPollingTimeout","Do","encodeInitMessageHeaders","c","createWebChannel","__PRIVATE_unguardedEventListen","listen","Vo","_i15","_s6","_o5","_t44","_n27","_i16","mo","stat","Ro","__PRIVATE_RestConnection","databaseInfo","po","yo","bo","toUriEncodedString","Co","So","__PRIVATE_newSerializer","__PRIVATE_ExponentialBackoff","oi","timerId","Mo","xo","Oo","No","Bo","Lo","reset","_this163","cancel","Qo","enqueueAfterDelay","skipDelay","__PRIVATE_PersistentStream","$o","Uo","connection","authCredentialsProvider","appCheckCredentialsProvider","listener","state","Wo","Go","zo","stream","jo","_close","_e_","_stop","Jo","Yo","_callee16","_context16","Ho","_this164","e_","n_","_callee17","_context17","_callee18","_context18","r_","ko","invalidateToken","i_","To","_x21","_x22","_this165","s_","all","_ref22","_ref23","o_","__","_this166","a_","Po","onMessage","_this167","qo","_callee19","_context19","start","_this168","enqueueAndForget","__PRIVATE_PersistentWriteStream","_PRIVATE_PersistentS2","_super30","_this170","h_","lastStreamToken","I_","Fo","streamToken","__PRIVATE_fromWriteResults","writeResults","commitTime","T_","E_","t_","_this171","writes","__PRIVATE_DatastoreImpl","_Datastore","_super31","_this172","authCredentials","appCheckCredentials","A_","_this173","R_","_ref25","_ref26","_this174","_ref27","_ref28","vo","terminate","Datastore","__PRIVATE_OnlineStateTracker","asyncQueue","m_","f_","g_","_this175","y_","w_","b_","__PRIVATE_RemoteStoreImpl","_this176","localStore","datastore","remoteSyncer","D_","C_","v_","F_","M_","io","_callee21","_context21","__PRIVATE_canUseNetwork","_PRIVATE_restartNetwork","_callee20","_context20","__PRIVATE_disableNetworkInternal","x_","__PRIVATE_enableNetworkInternal","_x26","_x27","_PRIVATE_enableNetworkInternal","_callee83","_iterator93","_step93","_context83","finish","_x28","_PRIVATE_disableNetworkInternal","_callee84","_iterator94","_step94","_context84","__PRIVATE_disableNetworkUntilRecovery","_x35","_x36","_x37","_PRIVATE_disableNetworkUntilRecovery","_callee90","_context90","_callee89","_context89","__PRIVATE_executeWithRecovery","__PRIVATE_fillWritePipeline","_x38","_PRIVATE_fillWritePipeline","_callee91","_e121","_context91","__PRIVATE_ensureWriteStream","__PRIVATE_canAddToWritePipeline","Xo","__PRIVATE_addToWritePipeline","__PRIVATE_shouldStartWriteStream","__PRIVATE_startWriteStream","P_","__PRIVATE_onWriteStreamOpen","_x39","_PRIVATE_onWriteStreamOpen","_callee92","_context92","d_","__PRIVATE_onWriteHandshakeComplete","_x40","_PRIVATE_onWriteHandshakeComplete","_callee93","_iterator96","_step96","_context93","__PRIVATE_onMutationResult","_x41","_x42","_x43","_PRIVATE_onMutationResult","_callee94","_context94","applySuccessfulWrite","__PRIVATE_onWriteStreamClose","_x44","_x45","_PRIVATE_onWriteStreamClose","_callee96","_context96","_PRIVATE_handleWriteError","_callee95","_context95","Zo","rejectFailedWrite","_x141","_x142","__PRIVATE_remoteStoreHandleCredentialChange","_x46","_x47","_PRIVATE_remoteStoreHandleCredentialChange","_callee97","_context97","verifyOperationInProgress","handleCredentialChange","__PRIVATE_remoteStoreApplyPrimaryState","_x48","_x49","_PRIVATE_remoteStoreApplyPrimaryState","_callee98","_context98","B_","bind","_ref31","_callee23","_context23","_x51","DelayedOperation","targetTimeMs","removalCallback","deferred","_this177","timerHandle","handleDelayElapsed","clearTimeout","_this178","_clearTimeout","__PRIVATE_wrapInUserErrorIfRecoverable","__PRIVATE_EventManagerImpl","queries","onlineState","K_","__PRIVATE_raiseSnapshotsInSyncEvent","__PRIVATE_SyncEngineImpl","remoteStore","eventManager","sharedClientState","maxConcurrentLimboResolutions","fa","ga","pa","ya","wa","Sa","ba","Da","Ca","va","Bn","Fa","__PRIVATE_syncEngineWrite","_x65","_x66","_x67","_PRIVATE_syncEngineWrite","_callee105","_e124","_t61","_context105","__PRIVATE_syncEngineEnsureWriteCallbacks","getOverlayedDocuments","_step97","_iterator97","_e125","_t60","addMutationBatch","applyToLocalDocumentSet","addPendingMutation","__PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore","__PRIVATE_syncEngineApplyOnlineStateChange","isPrimaryClient","_e97","view","U_","snapshot","_step71","_iterator71","Q_","u_","setOnlineState","__PRIVATE_syncEngineApplySuccessfulWrite","_x73","_x74","_PRIVATE_syncEngineApplySuccessfulWrite","_callee108","_e128","_context108","__PRIVATE_processUserCallback","__PRIVATE_triggerPendingWritesCallbacks","updateMutationState","__PRIVATE_syncEngineRejectFailedWrite","_x75","_x76","_x77","_PRIVATE_syncEngineRejectFailedWrite","_callee109","_e129","_context109","lookupMutationBatch","_e99","_x80","_x81","_x82","_PRIVATE_syncEngineEmitNewSnapsAndNotifyLocalStore","_callee112","_context112","Ma","updateQueryState","_t62","Ki","_PRIVATE_localStoreNotifyLocalViewChanges","_callee111","_iterator98","_step98","_e131","_t63","_e132","_r38","_i21","_context111","snapshotVersion","withLastLimboFreeSnapshotVersion","_x147","_x148","__PRIVATE_syncEngineHandleCredentialChange","_x83","_x84","_PRIVATE_syncEngineHandleCredentialChange","_callee113","_e133","_context113","clear","handleUserChange","MemoryOfflineComponentProvider","synchronizeTabs","_terminate","_initialize","_callee26","_context26","createSharedClientState","createPersistence","createLocalStore","gcScheduler","createGarbageCollectionScheduler","indexBackfillerScheduler","createIndexBackfillerScheduler","_x108","initialUser","Hr","_callee27","_context27","shutdown","OnlineComponentProvider","_terminate2","_initialize4","_callee31","_this188","_context31","createDatastore","createRemoteStore","createEventManager","syncEngine","createSyncEngine","_x112","_x113","_this189","_callee33","_context33","_PRIVATE_remoteStoreShutdown","_callee32","_context32","_x114","FirestoreClient","_this196","clientId","newId","authCredentialListener","appCheckCredentialListener","_ref34","_callee47","_context47","_x121","isShuttingDown","_this197","enterRestrictedMode","enqueueAndForgetEvenWhileRestricted","_callee48","_context48","_onlineComponents","_offlineComponents","t2","__PRIVATE_setOfflineComponentProvider","_x122","_x123","_PRIVATE_setOfflineComponentProvider","_callee122","_context123","configuration","setCredentialChangeListener","_ref60","_callee121","_context122","_x149","setDatabaseDeletedListener","__PRIVATE_setOnlineComponentProvider","_x124","_x125","_PRIVATE_setOnlineComponentProvider","_callee123","_context124","__PRIVATE_ensureOfflineComponents","setAppCheckTokenChangeListener","__PRIVATE_canFallbackFromIndexedDbError","_x126","_PRIVATE_ensureOfflineComponents","_callee124","_context125","_uninitializedComponentsProvider","_offline","__PRIVATE_ensureOnlineComponents","_x127","_PRIVATE_ensureOnlineComponents","_callee125","_context126","_online","__PRIVATE_getSyncEngine","__PRIVATE_cloneLongPollingOptions","me","__PRIVATE_validateNonEmptyArgument","__PRIVATE_validateDocumentPath","__PRIVATE_validateCollectionPath","__PRIVATE_valueDescription","substring","__PRIVATE_cast","_delegate","FirestoreSettingsImpl","credentials","ignoreUndefinedProperties","localCache","cacheSizeBytes","__PRIVATE_validateIsNotUsedTogether","experimentalForceLongPolling","experimentalAutoDetectLongPolling","experimentalLongPollingOptions","Firestore$1","_authCredentials","_appCheckCredentials","_databaseId","_app","_persistenceKey","_settings","_settingsFrozen","_terminateTask","sessionIndex","iamToken","authTokenFactory","client","app","settings","connectFirestoreEmulator","_getSettings","_setSettings","mockUserToken","_t49","_n29","_s8","sub","user_id","Query","converter","_query","firestore","DocumentReference","CollectionReference","_Query","_super35","_this198","_path","collection","_len7","_key7","_r30","__PRIVATE_AsyncQueueImpl","_this199","Xa","eu","tu","nu","ru","iu","su","ou","_u","visibilityState","Ko","_hu","_cu","enqueue","au","uu","_this200","_this201","cu","_callee66","_this202","_context66","_this203","stack","includes","_this204","createAndSchedule","lu","_callee67","_context67","_step75","_iterator75","_this205","hu","_step76","_iterator76","Firestore","_Firestore$","_super36","_this206","_queue","_firestoreClient","__PRIVATE_configureFirestore","getFirestore","identifier","_initialized","ensureFirestoreConfigured","verifyNotTerminated","_freezeSettings","_offlineComponentProvider","_onlineComponentProvider","_offlineKind","kind","Bytes","_byteString","FieldPath","_len9","_key9","_internalPath","FieldValue","_methodName","GeoPoint","isFinite","_lat","_long","ge","ParsedSetData","__PRIVATE_isWrite","__PRIVATE_ParseContextImpl","Eu","du","Au","Vu","mu","__PRIVATE_createError","methodName","yu","wu","pu","__PRIVATE_UserDataReader","__PRIVATE_newUserDataReader","__PRIVATE_parseSetData","Su","merge","mergeFields","__PRIVATE_validatePlainObject","__PRIVATE_parseObject","_step78","_e104","_iterator78","_r32","_i17","__PRIVATE_fieldPathFromArgument$1","contains","__PRIVATE_fieldMaskContains","covers","__PRIVATE_parseData","__PRIVATE_looksLikeJsonObject","_toFieldTransform","_step79","_iterator79","_e109","gu","fromDate","_n31","_n32","Ru","getPrototypeOf","__PRIVATE_fieldPathFromDotSeparatedString","pe","search","__PRIVATE_applyFirestoreDataConverter","toFirestore","addDoc","_len8","_key8","_r31","executeWrite","_callee74","_context74","t3","WeakMap","_ref57","instanceIdentifier","getProvider","setMultipleInstances"],"sourceRoot":""}