@firebase/firestore 3.7.1 → 3.7.2-canary.457fc2eeb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,7 +66,7 @@ P.MOCK_USER = new P("mock-user");
66
66
  * See the License for the specific language governing permissions and
67
67
  * limitations under the License.
68
68
  */
69
- let v = "9.12.1";
69
+ let v = "9.13.0-canary.457fc2eeb";
70
70
 
71
71
  /**
72
72
  * @license
@@ -12520,11 +12520,12 @@ class {
12520
12520
  return new Promise(((i, r) => {
12521
12521
  const o = new XhrIo;
12522
12522
  o.setWithCredentials(!0), o.listenOnce(EventType.COMPLETE, (() => {
12523
+ var e;
12523
12524
  try {
12524
12525
  switch (o.getLastErrorCode()) {
12525
12526
  case ErrorCode.NO_ERROR:
12526
- const e = o.getResponseJson();
12527
- C("Connection", "XHR received:", JSON.stringify(e)), i(e);
12527
+ const n = o.getResponseJson();
12528
+ C("Connection", "XHR received:", JSON.stringify(n)), i(n);
12528
12529
  break;
12529
12530
 
12530
12531
  case ErrorCode.TIMEOUT:
@@ -12532,16 +12533,18 @@ class {
12532
12533
  break;
12533
12534
 
12534
12535
  case ErrorCode.HTTP_ERROR:
12535
- const n = o.getStatus();
12536
- if (C("Connection", 'RPC "' + t + '" failed with status:', n, "response text:", o.getResponseText()),
12537
- n > 0) {
12538
- const t = o.getResponseJson().error;
12539
- if (t && t.status && t.message) {
12540
- const e = function(t) {
12536
+ const s = o.getStatus();
12537
+ if (C("Connection", 'RPC "' + t + '" failed with status:', s, "response text:", o.getResponseText()),
12538
+ s > 0) {
12539
+ let t = o.getResponseJson();
12540
+ Array.isArray(t) && (t = t[0]);
12541
+ const n = null === (e = t) || void 0 === e ? void 0 : e.error;
12542
+ if (n && n.status && n.message) {
12543
+ const t = function(t) {
12541
12544
  const e = t.toLowerCase().replace(/_/g, "-");
12542
12545
  return Object.values(B).indexOf(e) >= 0 ? e : B.UNKNOWN;
12543
- }(t.status);
12544
- r(new L(e, t.message));
12546
+ }(n.status);
12547
+ r(new L(t, n.message));
12545
12548
  } else r(new L(B.UNKNOWN, "Server responded with status " + o.getStatus()));
12546
12549
  } else
12547
12550
  // If we received an HTTP_ERROR but there's no status code,
@@ -12883,14 +12886,14 @@ class tu {
12883
12886
  */
12884
12887
  class eu {
12885
12888
  constructor(t, e, n, s, i, r, o, u) {
12886
- this.Hs = t, this.vo = n, this.Vo = s, this.So = i, this.authCredentialsProvider = r,
12889
+ this.Hs = t, this.vo = n, this.Vo = s, this.connection = i, this.authCredentialsProvider = r,
12887
12890
  this.appCheckCredentialsProvider = o, this.listener = u, this.state = 0 /* Initial */ ,
12888
12891
  /**
12889
12892
  * A close count that's incremented every time the stream is closed; used by
12890
12893
  * getCloseGuardedDispatcher() to invalidate callbacks that happen after
12891
12894
  * close.
12892
12895
  */
12893
- this.Do = 0, this.Co = null, this.xo = null, this.stream = null, this.No = new tu(t, e);
12896
+ this.So = 0, this.Do = null, this.Co = null, this.stream = null, this.xo = new tu(t, e);
12894
12897
  }
12895
12898
  /**
12896
12899
  * Returns true if start() has been called and no error has occurred. True
@@ -12898,13 +12901,13 @@ class eu {
12898
12901
  * encompasses respecting backoff, getting auth tokens, and starting the
12899
12902
  * actual RPC). Use isOpen() to determine if the stream is open and ready for
12900
12903
  * outbound requests.
12901
- */ ko() {
12902
- return 1 /* Starting */ === this.state || 5 /* Backoff */ === this.state || this.Oo();
12904
+ */ No() {
12905
+ return 1 /* Starting */ === this.state || 5 /* Backoff */ === this.state || this.ko();
12903
12906
  }
12904
12907
  /**
12905
12908
  * Returns true if the underlying RPC is open (the onOpen() listener has been
12906
12909
  * called) and the stream is ready for outbound requests.
12907
- */ Oo() {
12910
+ */ ko() {
12908
12911
  return 2 /* Open */ === this.state || 3 /* Healthy */ === this.state;
12909
12912
  }
12910
12913
  /**
@@ -12914,7 +12917,7 @@ class eu {
12914
12917
  *
12915
12918
  * When start returns, isStarted() will return true.
12916
12919
  */ start() {
12917
- 4 /* Error */ !== this.state ? this.auth() : this.Mo();
12920
+ 4 /* Error */ !== this.state ? this.auth() : this.Oo();
12918
12921
  }
12919
12922
  /**
12920
12923
  * Stops the RPC. This call is idempotent and allowed regardless of the
@@ -12922,7 +12925,7 @@ class eu {
12922
12925
  *
12923
12926
  * When stop returns, isStarted() and isOpen() will both return false.
12924
12927
  */ async stop() {
12925
- this.ko() && await this.close(0 /* Initial */);
12928
+ this.No() && await this.close(0 /* Initial */);
12926
12929
  }
12927
12930
  /**
12928
12931
  * After an error the stream will usually back off on the next attempt to
@@ -12931,8 +12934,8 @@ class eu {
12931
12934
  *
12932
12935
  * Each error will call the onClose() listener. That function can decide to
12933
12936
  * inhibit backoff if required.
12934
- */ Fo() {
12935
- this.state = 0 /* Initial */ , this.No.reset();
12937
+ */ Mo() {
12938
+ this.state = 0 /* Initial */ , this.xo.reset();
12936
12939
  }
12937
12940
  /**
12938
12941
  * Marks this stream as idle. If no further actions are performed on the
@@ -12943,25 +12946,25 @@ class eu {
12943
12946
  *
12944
12947
  * Only streams that are in state 'Open' can be marked idle, as all other
12945
12948
  * states imply pending network operations.
12946
- */ $o() {
12949
+ */ Fo() {
12947
12950
  // Starts the idle time if we are in state 'Open' and are not yet already
12948
12951
  // running a timer (in which case the previous idle timeout still applies).
12949
- this.Oo() && null === this.Co && (this.Co = this.Hs.enqueueAfterDelay(this.vo, 6e4, (() => this.Bo())));
12952
+ this.ko() && null === this.Do && (this.Do = this.Hs.enqueueAfterDelay(this.vo, 6e4, (() => this.$o())));
12950
12953
  }
12951
- /** Sends a message to the underlying stream. */ Lo(t) {
12952
- this.Uo(), this.stream.send(t);
12954
+ /** Sends a message to the underlying stream. */ Bo(t) {
12955
+ this.Lo(), this.stream.send(t);
12953
12956
  }
12954
- /** Called by the idle timer when the stream should close due to inactivity. */ async Bo() {
12955
- if (this.Oo())
12957
+ /** Called by the idle timer when the stream should close due to inactivity. */ async $o() {
12958
+ if (this.ko())
12956
12959
  // When timing out an idle stream there's no reason to force the stream into backoff when
12957
12960
  // it restarts so set the stream state to Initial instead of Error.
12958
12961
  return this.close(0 /* Initial */);
12959
12962
  }
12960
- /** Marks the stream as active again. */ Uo() {
12961
- this.Co && (this.Co.cancel(), this.Co = null);
12963
+ /** Marks the stream as active again. */ Lo() {
12964
+ this.Do && (this.Do.cancel(), this.Do = null);
12962
12965
  }
12963
- /** Cancels the health check delayed operation. */ qo() {
12964
- this.xo && (this.xo.cancel(), this.xo = null);
12966
+ /** Cancels the health check delayed operation. */ Uo() {
12967
+ this.Co && (this.Co.cancel(), this.Co = null);
12965
12968
  }
12966
12969
  /**
12967
12970
  * Closes the stream and cleans up as necessary:
@@ -12977,15 +12980,15 @@ class eu {
12977
12980
  * @param error - the error the connection was closed with.
12978
12981
  */ async close(t, e) {
12979
12982
  // Cancel any outstanding timers (they're guaranteed not to execute).
12980
- this.Uo(), this.qo(), this.No.cancel(),
12983
+ this.Lo(), this.Uo(), this.xo.cancel(),
12981
12984
  // Invalidates any stream-related callbacks (e.g. from auth or the
12982
12985
  // underlying stream), guaranteeing they won't execute.
12983
- this.Do++, 4 /* Error */ !== t ?
12986
+ this.So++, 4 /* Error */ !== t ?
12984
12987
  // If this is an intentional close ensure we don't delay our next connection attempt.
12985
- this.No.reset() : e && e.code === B.RESOURCE_EXHAUSTED ? (
12988
+ this.xo.reset() : e && e.code === B.RESOURCE_EXHAUSTED ? (
12986
12989
  // Log the error. (Probably either 'quota exceeded' or 'max queue length reached'.)
12987
12990
  x(e.toString()), x("Using maximum backoff delay to prevent overloading the backend."),
12988
- this.No.Ao()) : e && e.code === B.UNAUTHENTICATED && 3 /* Healthy */ !== this.state && (
12991
+ this.xo.Ao()) : e && e.code === B.UNAUTHENTICATED && 3 /* Healthy */ !== this.state && (
12989
12992
  // "unauthenticated" error means the token was rejected. This should rarely
12990
12993
  // happen since both Auth and AppCheck ensure a sufficient TTL when we
12991
12994
  // request a token. If a user manually resets their system clock this can
@@ -12994,7 +12997,7 @@ class eu {
12994
12997
  // to ensure that we fetch a new token.
12995
12998
  this.authCredentialsProvider.invalidateToken(), this.appCheckCredentialsProvider.invalidateToken()),
12996
12999
  // Clean up the underlying stream because we are no longer interested in events.
12997
- null !== this.stream && (this.Ko(), this.stream.close(), this.stream = null),
13000
+ null !== this.stream && (this.qo(), this.stream.close(), this.stream = null),
12998
13001
  // This state must be assigned before calling onClose() to allow the callback to
12999
13002
  // inhibit backoff or otherwise manipulate the state in its non-started state.
13000
13003
  this.state = t,
@@ -13004,46 +13007,46 @@ class eu {
13004
13007
  /**
13005
13008
  * Can be overridden to perform additional cleanup before the stream is closed.
13006
13009
  * Calling super.tearDown() is not required.
13007
- */ Ko() {}
13010
+ */ qo() {}
13008
13011
  auth() {
13009
13012
  this.state = 1 /* Starting */;
13010
- const t = this.Go(this.Do), e = this.Do;
13013
+ const t = this.Ko(this.So), e = this.So;
13011
13014
  // TODO(mikelehen): Just use dispatchIfNotClosed, but see TODO below.
13012
13015
  Promise.all([ this.authCredentialsProvider.getToken(), this.appCheckCredentialsProvider.getToken() ]).then((([t, n]) => {
13013
13016
  // Stream can be stopped while waiting for authentication.
13014
13017
  // TODO(mikelehen): We really should just use dispatchIfNotClosed
13015
13018
  // and let this dispatch onto the queue, but that opened a spec test can
13016
13019
  // of worms that I don't want to deal with in this PR.
13017
- this.Do === e &&
13020
+ this.So === e &&
13018
13021
  // Normally we'd have to schedule the callback on the AsyncQueue.
13019
13022
  // However, the following calls are safe to be called outside the
13020
13023
  // AsyncQueue since they don't chain asynchronous calls
13021
- this.Qo(t, n);
13024
+ this.Go(t, n);
13022
13025
  }), (e => {
13023
13026
  t((() => {
13024
13027
  const t = new L(B.UNKNOWN, "Fetching auth token failed: " + e.message);
13025
- return this.jo(t);
13028
+ return this.Qo(t);
13026
13029
  }));
13027
13030
  }));
13028
13031
  }
13029
- Qo(t, e) {
13030
- const n = this.Go(this.Do);
13031
- this.stream = this.Wo(t, e), this.stream.Yr((() => {
13032
- n((() => (this.state = 2 /* Open */ , this.xo = this.Hs.enqueueAfterDelay(this.Vo, 1e4, (() => (this.Oo() && (this.state = 3 /* Healthy */),
13032
+ Go(t, e) {
13033
+ const n = this.Ko(this.So);
13034
+ this.stream = this.jo(t, e), this.stream.Yr((() => {
13035
+ n((() => (this.state = 2 /* Open */ , this.Co = this.Hs.enqueueAfterDelay(this.Vo, 1e4, (() => (this.ko() && (this.state = 3 /* Healthy */),
13033
13036
  Promise.resolve()))), this.listener.Yr())));
13034
13037
  })), this.stream.Zr((t => {
13035
- n((() => this.jo(t)));
13038
+ n((() => this.Qo(t)));
13036
13039
  })), this.stream.onMessage((t => {
13037
13040
  n((() => this.onMessage(t)));
13038
13041
  }));
13039
13042
  }
13040
- Mo() {
13041
- this.state = 5 /* Backoff */ , this.No.Ro((async () => {
13043
+ Oo() {
13044
+ this.state = 5 /* Backoff */ , this.xo.Ro((async () => {
13042
13045
  this.state = 0 /* Initial */ , this.start();
13043
13046
  }));
13044
13047
  }
13045
13048
  // Visible for tests
13046
- jo(t) {
13049
+ Qo(t) {
13047
13050
  // In theory the stream could close cleanly, however, in our current model
13048
13051
  // we never expect this to happen because if we stop a stream ourselves,
13049
13052
  // this callback will never be called. To prevent cases where we retry
@@ -13055,9 +13058,9 @@ class eu {
13055
13058
  * AsyncQueue but only runs them if closeCount remains unchanged. This allows
13056
13059
  * us to turn auth / stream callbacks into no-ops if the stream is closed /
13057
13060
  * re-opened, etc.
13058
- */ Go(t) {
13061
+ */ Ko(t) {
13059
13062
  return e => {
13060
- this.Hs.enqueueAndForget((() => this.Do === t ? e() : (C("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
13063
+ this.Hs.enqueueAndForget((() => this.So === t ? e() : (C("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
13061
13064
  Promise.resolve())));
13062
13065
  };
13063
13066
  }
@@ -13074,12 +13077,12 @@ class eu {
13074
13077
  super(t, "listen_stream_connection_backoff" /* ListenStreamConnectionBackoff */ , "listen_stream_idle" /* ListenStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, s, r),
13075
13078
  this.It = i;
13076
13079
  }
13077
- Wo(t, e) {
13078
- return this.So.wo("Listen", t, e);
13080
+ jo(t, e) {
13081
+ return this.connection.wo("Listen", t, e);
13079
13082
  }
13080
13083
  onMessage(t) {
13081
13084
  // A successful response means the stream is healthy
13082
- this.No.reset();
13085
+ this.xo.reset();
13083
13086
  const e = qs(this.It, t), n = function(t) {
13084
13087
  // We have only reached a consistent snapshot for the entire stream if there
13085
13088
  // is a read_time set and it applies to all targets (i.e. the list of
@@ -13088,14 +13091,14 @@ class eu {
13088
13091
  const e = t.targetChange;
13089
13092
  return e.targetIds && e.targetIds.length ? st.min() : e.readTime ? Ds(e.readTime) : st.min();
13090
13093
  }(t);
13091
- return this.listener.zo(e, n);
13094
+ return this.listener.Wo(e, n);
13092
13095
  }
13093
13096
  /**
13094
13097
  * Registers interest in the results of the given target. If the target
13095
13098
  * includes a resumeToken it will be included in the request. Results that
13096
13099
  * affect the target will be streamed back as WatchChange messages that
13097
13100
  * reference the targetId.
13098
- */ Ho(t) {
13101
+ */ zo(t) {
13099
13102
  const e = {};
13100
13103
  e.database = Fs(this.It), e.addTarget = function(t, e) {
13101
13104
  let n;
@@ -13111,14 +13114,14 @@ class eu {
13111
13114
  n.readTime = vs(t, e.snapshotVersion.toTimestamp())), n;
13112
13115
  }(this.It, t);
13113
13116
  const n = Hs(this.It, t);
13114
- n && (e.labels = n), this.Lo(e);
13117
+ n && (e.labels = n), this.Bo(e);
13115
13118
  }
13116
13119
  /**
13117
13120
  * Unregisters interest in the results of the target associated with the
13118
13121
  * given targetId.
13119
- */ Jo(t) {
13122
+ */ Ho(t) {
13120
13123
  const e = {};
13121
- e.database = Fs(this.It), e.removeTarget = t, this.Lo(e);
13124
+ e.database = Fs(this.It), e.removeTarget = t, this.Bo(e);
13122
13125
  }
13123
13126
  }
13124
13127
 
@@ -13141,54 +13144,54 @@ class eu {
13141
13144
  */ class su extends eu {
13142
13145
  constructor(t, e, n, s, i, r) {
13143
13146
  super(t, "write_stream_connection_backoff" /* WriteStreamConnectionBackoff */ , "write_stream_idle" /* WriteStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, s, r),
13144
- this.It = i, this.Yo = !1;
13147
+ this.It = i, this.Jo = !1;
13145
13148
  }
13146
13149
  /**
13147
13150
  * Tracks whether or not a handshake has been successfully exchanged and
13148
13151
  * the stream is ready to accept mutations.
13149
- */ get Xo() {
13150
- return this.Yo;
13152
+ */ get Yo() {
13153
+ return this.Jo;
13151
13154
  }
13152
13155
  // Override of PersistentStream.start
13153
13156
  start() {
13154
- this.Yo = !1, this.lastStreamToken = void 0, super.start();
13157
+ this.Jo = !1, this.lastStreamToken = void 0, super.start();
13155
13158
  }
13156
- Ko() {
13157
- this.Yo && this.Zo([]);
13159
+ qo() {
13160
+ this.Jo && this.Xo([]);
13158
13161
  }
13159
- Wo(t, e) {
13160
- return this.So.wo("Write", t, e);
13162
+ jo(t, e) {
13163
+ return this.connection.wo("Write", t, e);
13161
13164
  }
13162
13165
  onMessage(t) {
13163
13166
  if (
13164
13167
  // Always capture the last stream token.
13165
- M(!!t.streamToken), this.lastStreamToken = t.streamToken, this.Yo) {
13168
+ M(!!t.streamToken), this.lastStreamToken = t.streamToken, this.Jo) {
13166
13169
  // A successful first write response means the stream is healthy,
13167
13170
  // Note, that we could consider a successful handshake healthy, however,
13168
13171
  // the write itself might be causing an error we want to back off from.
13169
- this.No.reset();
13172
+ this.xo.reset();
13170
13173
  const e = Qs(t.writeResults, t.commitTime), n = Ds(t.commitTime);
13171
- return this.listener.tu(n, e);
13174
+ return this.listener.Zo(n, e);
13172
13175
  }
13173
13176
  // The first response is always the handshake response
13174
- return M(!t.writeResults || 0 === t.writeResults.length), this.Yo = !0, this.listener.eu();
13177
+ return M(!t.writeResults || 0 === t.writeResults.length), this.Jo = !0, this.listener.tu();
13175
13178
  }
13176
13179
  /**
13177
13180
  * Sends an initial streamToken to the server, performing the handshake
13178
13181
  * required to make the StreamingWrite RPC work. Subsequent
13179
13182
  * calls should wait until onHandshakeComplete was called.
13180
- */ nu() {
13183
+ */ eu() {
13181
13184
  // TODO(dimond): Support stream resumption. We intentionally do not set the
13182
13185
  // stream token on the handshake, ignoring any stream token we might have.
13183
13186
  const t = {};
13184
- t.database = Fs(this.It), this.Lo(t);
13187
+ t.database = Fs(this.It), this.Bo(t);
13185
13188
  }
13186
- /** Sends a group of mutations to the Firestore backend to apply. */ Zo(t) {
13189
+ /** Sends a group of mutations to the Firestore backend to apply. */ Xo(t) {
13187
13190
  const e = {
13188
13191
  streamToken: this.lastStreamToken,
13189
13192
  writes: t.map((t => Ks(this.It, t)))
13190
13193
  };
13191
- this.Lo(e);
13194
+ this.Bo(e);
13192
13195
  }
13193
13196
  }
13194
13197
 
@@ -13219,26 +13222,26 @@ class eu {
13219
13222
  */
13220
13223
  class iu extends class {} {
13221
13224
  constructor(t, e, n, s) {
13222
- super(), this.authCredentials = t, this.appCheckCredentials = e, this.So = n, this.It = s,
13223
- this.su = !1;
13225
+ super(), this.authCredentials = t, this.appCheckCredentials = e, this.connection = n,
13226
+ this.It = s, this.nu = !1;
13224
13227
  }
13225
- iu() {
13226
- if (this.su) throw new L(B.FAILED_PRECONDITION, "The client has already been terminated.");
13228
+ su() {
13229
+ if (this.nu) throw new L(B.FAILED_PRECONDITION, "The client has already been terminated.");
13227
13230
  }
13228
13231
  /** Invokes the provided RPC with auth and AppCheck tokens. */ ao(t, e, n) {
13229
- return this.iu(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([s, i]) => this.So.ao(t, e, n, s, i))).catch((t => {
13232
+ return this.su(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([s, i]) => this.connection.ao(t, e, n, s, i))).catch((t => {
13230
13233
  throw "FirebaseError" === t.name ? (t.code === B.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
13231
13234
  this.appCheckCredentials.invalidateToken()), t) : new L(B.UNKNOWN, t.toString());
13232
13235
  }));
13233
13236
  }
13234
13237
  /** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ _o(t, e, n, s) {
13235
- return this.iu(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, r]) => this.So._o(t, e, n, i, r, s))).catch((t => {
13238
+ return this.su(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, r]) => this.connection._o(t, e, n, i, r, s))).catch((t => {
13236
13239
  throw "FirebaseError" === t.name ? (t.code === B.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
13237
13240
  this.appCheckCredentials.invalidateToken()), t) : new L(B.UNKNOWN, t.toString());
13238
13241
  }));
13239
13242
  }
13240
13243
  terminate() {
13241
- this.su = !0;
13244
+ this.nu = !0;
13242
13245
  }
13243
13246
  }
13244
13247
 
@@ -13258,7 +13261,7 @@ async function ru(t, e) {
13258
13261
  parent: n.parent
13259
13262
  };
13260
13263
  }(n.It, cn(e)), i = s.parent;
13261
- n.So.co || delete s.parent;
13264
+ n.connection.co || delete s.parent;
13262
13265
  return (await n._o("RunAggregationQuery", i, s, /*expectedResponseCount=*/ 1)).filter((t => !!t.result)).map((t => t.result.aggregateFields));
13263
13266
  }
13264
13267
 
@@ -13283,19 +13286,19 @@ class ou {
13283
13286
  * maximum defined by MAX_WATCH_STREAM_FAILURES, we'll set the OnlineState to
13284
13287
  * Offline.
13285
13288
  */
13286
- this.ru = 0,
13289
+ this.iu = 0,
13287
13290
  /**
13288
13291
  * A timer that elapses after ONLINE_STATE_TIMEOUT_MS, at which point we
13289
13292
  * transition from OnlineState.Unknown to OnlineState.Offline without waiting
13290
13293
  * for the stream to actually fail (MAX_WATCH_STREAM_FAILURES times).
13291
13294
  */
13292
- this.ou = null,
13295
+ this.ru = null,
13293
13296
  /**
13294
13297
  * Whether the client should log a warning message if it fails to connect to
13295
13298
  * the backend (initially true, cleared after a successful stream, or if we've
13296
13299
  * logged the message already).
13297
13300
  */
13298
- this.uu = !0;
13301
+ this.ou = !0;
13299
13302
  }
13300
13303
  /**
13301
13304
  * Called by RemoteStore when a watch stream is started (including on each
@@ -13303,9 +13306,9 @@ class ou {
13303
13306
  *
13304
13307
  * If this is the first attempt, it sets the OnlineState to Unknown and starts
13305
13308
  * the onlineStateTimer.
13306
- */ cu() {
13307
- 0 === this.ru && (this.au("Unknown" /* Unknown */), this.ou = this.asyncQueue.enqueueAfterDelay("online_state_timeout" /* OnlineStateTimeout */ , 1e4, (() => (this.ou = null,
13308
- this.hu("Backend didn't respond within 10 seconds."), this.au("Offline" /* Offline */),
13309
+ */ uu() {
13310
+ 0 === this.iu && (this.cu("Unknown" /* Unknown */), this.ru = this.asyncQueue.enqueueAfterDelay("online_state_timeout" /* OnlineStateTimeout */ , 1e4, (() => (this.ru = null,
13311
+ this.au("Backend didn't respond within 10 seconds."), this.cu("Offline" /* Offline */),
13309
13312
  Promise.resolve()))));
13310
13313
  }
13311
13314
  /**
@@ -13313,10 +13316,10 @@ class ou {
13313
13316
  * failure. The first failure moves us to the 'Unknown' state. We then may
13314
13317
  * allow multiple failures (based on MAX_WATCH_STREAM_FAILURES) before we
13315
13318
  * actually transition to the 'Offline' state.
13316
- */ lu(t) {
13317
- "Online" /* Online */ === this.state ? this.au("Unknown" /* Unknown */) : (this.ru++,
13318
- this.ru >= 1 && (this.fu(), this.hu(`Connection failed 1 times. Most recent error: ${t.toString()}`),
13319
- this.au("Offline" /* Offline */)));
13319
+ */ hu(t) {
13320
+ "Online" /* Online */ === this.state ? this.cu("Unknown" /* Unknown */) : (this.iu++,
13321
+ this.iu >= 1 && (this.lu(), this.au(`Connection failed 1 times. Most recent error: ${t.toString()}`),
13322
+ this.cu("Offline" /* Offline */)));
13320
13323
  }
13321
13324
  /**
13322
13325
  * Explicitly sets the OnlineState to the specified state.
@@ -13325,20 +13328,20 @@ class ou {
13325
13328
  * Offline heuristics, so must not be used in place of
13326
13329
  * handleWatchStreamStart() and handleWatchStreamFailure().
13327
13330
  */ set(t) {
13328
- this.fu(), this.ru = 0, "Online" /* Online */ === t && (
13331
+ this.lu(), this.iu = 0, "Online" /* Online */ === t && (
13329
13332
  // We've connected to watch at least once. Don't warn the developer
13330
13333
  // about being offline going forward.
13331
- this.uu = !1), this.au(t);
13334
+ this.ou = !1), this.cu(t);
13332
13335
  }
13333
- au(t) {
13336
+ cu(t) {
13334
13337
  t !== this.state && (this.state = t, this.onlineStateHandler(t));
13335
13338
  }
13336
- hu(t) {
13339
+ au(t) {
13337
13340
  const e = `Could not reach Cloud Firestore backend. ${t}\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.`;
13338
- this.uu ? (x(e), this.uu = !1) : C("OnlineStateTracker", e);
13341
+ this.ou ? (x(e), this.ou = !1) : C("OnlineStateTracker", e);
13339
13342
  }
13340
- fu() {
13341
- null !== this.ou && (this.ou.cancel(), this.ou = null);
13343
+ lu() {
13344
+ null !== this.ru && (this.ru.cancel(), this.ru = null);
13342
13345
  }
13343
13346
  }
13344
13347
 
@@ -13383,7 +13386,7 @@ class ou {
13383
13386
  * purely based on order, and so we can just shift() writes from the front of
13384
13387
  * the writePipeline as we receive responses.
13385
13388
  */
13386
- this.du = [],
13389
+ this.fu = [],
13387
13390
  /**
13388
13391
  * A mapping of watched targets that the client cares about tracking and the
13389
13392
  * user has explicitly called a 'listen' for this target.
@@ -13393,12 +13396,12 @@ class ou {
13393
13396
  * to the server. The targets removed with unlistens are removed eagerly
13394
13397
  * without waiting for confirmation from the listen stream.
13395
13398
  */
13396
- this._u = new Map,
13399
+ this.du = new Map,
13397
13400
  /**
13398
13401
  * A set of reasons for why the RemoteStore may be offline. If empty, the
13399
13402
  * RemoteStore may start its network connections.
13400
13403
  */
13401
- this.wu = new Set,
13404
+ this._u = new Set,
13402
13405
  /**
13403
13406
  * Event handlers that get called when the network is disabled or enabled.
13404
13407
  *
@@ -13406,7 +13409,7 @@ class ou {
13406
13409
  * underlying streams (to support tree-shakeable streams). On Android and iOS,
13407
13410
  * the streams are created during construction of RemoteStore.
13408
13411
  */
13409
- this.mu = [], this.gu = i, this.gu.qr((t => {
13412
+ this.wu = [], this.mu = i, this.mu.qr((t => {
13410
13413
  n.enqueueAndForget((async () => {
13411
13414
  // Porting Note: Unlike iOS, `restartNetwork()` is called even when the
13412
13415
  // network becomes unreachable as we don't have any other way to tear
@@ -13414,23 +13417,23 @@ class ou {
13414
13417
  mu(this) && (C("RemoteStore", "Restarting streams for network reachability change."),
13415
13418
  await async function(t) {
13416
13419
  const e = $(t);
13417
- e.wu.add(4 /* ConnectivityChange */), await au(e), e.yu.set("Unknown" /* Unknown */),
13418
- e.wu.delete(4 /* ConnectivityChange */), await cu(e);
13420
+ e._u.add(4 /* ConnectivityChange */), await au(e), e.gu.set("Unknown" /* Unknown */),
13421
+ e._u.delete(4 /* ConnectivityChange */), await cu(e);
13419
13422
  }(this));
13420
13423
  }));
13421
- })), this.yu = new ou(n, s);
13424
+ })), this.gu = new ou(n, s);
13422
13425
  }
13423
13426
  }
13424
13427
 
13425
13428
  async function cu(t) {
13426
- if (mu(t)) for (const e of t.mu) await e(/* enabled= */ !0);
13429
+ if (mu(t)) for (const e of t.wu) await e(/* enabled= */ !0);
13427
13430
  }
13428
13431
 
13429
13432
  /**
13430
13433
  * Temporarily disables the network. The network can be re-enabled using
13431
13434
  * enableNetwork().
13432
13435
  */ async function au(t) {
13433
- for (const e of t.mu) await e(/* enabled= */ !1);
13436
+ for (const e of t.wu) await e(/* enabled= */ !1);
13434
13437
  }
13435
13438
 
13436
13439
  /**
@@ -13439,11 +13442,11 @@ async function cu(t) {
13439
13442
  */
13440
13443
  function hu(t, e) {
13441
13444
  const n = $(t);
13442
- n._u.has(e.targetId) || (
13445
+ n.du.has(e.targetId) || (
13443
13446
  // Mark this as something the client is currently listening for.
13444
- n._u.set(e.targetId, e), wu(n) ?
13447
+ n.du.set(e.targetId, e), wu(n) ?
13445
13448
  // The listen will be sent in onWatchStreamOpen
13446
- _u(n) : ku(n).Oo() && fu(n, e));
13449
+ _u(n) : ku(n).ko() && fu(n, e));
13447
13450
  }
13448
13451
 
13449
13452
  /**
@@ -13451,18 +13454,18 @@ function hu(t, e) {
13451
13454
  * not being listened to.
13452
13455
  */ function lu(t, e) {
13453
13456
  const n = $(t), s = ku(n);
13454
- n._u.delete(e), s.Oo() && du(n, e), 0 === n._u.size && (s.Oo() ? s.$o() : mu(n) &&
13457
+ n.du.delete(e), s.ko() && du(n, e), 0 === n.du.size && (s.ko() ? s.Fo() : mu(n) &&
13455
13458
  // Revert to OnlineState.Unknown if the watch stream is not open and we
13456
13459
  // have no listeners, since without any listens to send we cannot
13457
13460
  // confirm if the stream is healthy and upgrade to OnlineState.Online.
13458
- n.yu.set("Unknown" /* Unknown */));
13461
+ n.gu.set("Unknown" /* Unknown */));
13459
13462
  }
13460
13463
 
13461
13464
  /**
13462
13465
  * We need to increment the the expected number of pending responses we're due
13463
13466
  * from watch so we wait for the ack to process any messages from this target.
13464
13467
  */ function fu(t, e) {
13465
- t.pu.Mt(e.targetId), ku(t).Ho(e);
13468
+ t.yu.Mt(e.targetId), ku(t).zo(e);
13466
13469
  }
13467
13470
 
13468
13471
  /**
@@ -13470,33 +13473,33 @@ function hu(t, e) {
13470
13473
  * from watch so we wait for the removal on the server before we process any
13471
13474
  * messages from this target.
13472
13475
  */ function du(t, e) {
13473
- t.pu.Mt(e), ku(t).Jo(e);
13476
+ t.yu.Mt(e), ku(t).Ho(e);
13474
13477
  }
13475
13478
 
13476
13479
  function _u(t) {
13477
- t.pu = new Ts({
13480
+ t.yu = new Ts({
13478
13481
  getRemoteKeysForTarget: e => t.remoteSyncer.getRemoteKeysForTarget(e),
13479
- se: e => t._u.get(e) || null
13480
- }), ku(t).start(), t.yu.cu();
13482
+ se: e => t.du.get(e) || null
13483
+ }), ku(t).start(), t.gu.uu();
13481
13484
  }
13482
13485
 
13483
13486
  /**
13484
13487
  * Returns whether the watch stream should be started because it's necessary
13485
13488
  * and has not yet been started.
13486
13489
  */ function wu(t) {
13487
- return mu(t) && !ku(t).ko() && t._u.size > 0;
13490
+ return mu(t) && !ku(t).No() && t.du.size > 0;
13488
13491
  }
13489
13492
 
13490
13493
  function mu(t) {
13491
- return 0 === $(t).wu.size;
13494
+ return 0 === $(t)._u.size;
13492
13495
  }
13493
13496
 
13494
13497
  function gu(t) {
13495
- t.pu = void 0;
13498
+ t.yu = void 0;
13496
13499
  }
13497
13500
 
13498
13501
  async function yu(t) {
13499
- t._u.forEach(((e, n) => {
13502
+ t.du.forEach(((e, n) => {
13500
13503
  fu(t, e);
13501
13504
  }));
13502
13505
  }
@@ -13504,17 +13507,17 @@ async function yu(t) {
13504
13507
  async function pu(t, e) {
13505
13508
  gu(t),
13506
13509
  // If we still need the watch stream, retry the connection.
13507
- wu(t) ? (t.yu.lu(e), _u(t)) :
13510
+ wu(t) ? (t.gu.hu(e), _u(t)) :
13508
13511
  // No need to restart watch stream because there are no active targets.
13509
13512
  // The online state is set to unknown because there is no active attempt
13510
13513
  // at establishing a connection
13511
- t.yu.set("Unknown" /* Unknown */);
13514
+ t.gu.set("Unknown" /* Unknown */);
13512
13515
  }
13513
13516
 
13514
13517
  async function Iu(t, e, n) {
13515
13518
  if (
13516
13519
  // Mark the client as online since we got a message from the server
13517
- t.yu.set("Online" /* Online */), e instanceof ps && 2 /* Removed */ === e.state && e.cause)
13520
+ t.gu.set("Online" /* Online */), e instanceof ps && 2 /* Removed */ === e.state && e.cause)
13518
13521
  // There was an error on a target, don't wait for a consistent snapshot
13519
13522
  // to raise events
13520
13523
  try {
@@ -13524,7 +13527,7 @@ async function Iu(t, e, n) {
13524
13527
  const n = e.cause;
13525
13528
  for (const s of e.targetIds)
13526
13529
  // A watched target might have been removed already.
13527
- t._u.has(s) && (await t.remoteSyncer.rejectListen(s, n), t._u.delete(s), t.pu.removeTarget(s));
13530
+ t.du.has(s) && (await t.remoteSyncer.rejectListen(s, n), t.du.delete(s), t.yu.removeTarget(s));
13528
13531
  }
13529
13532
  /**
13530
13533
  * Attempts to fill our write pipeline with writes from the LocalStore.
@@ -13537,7 +13540,7 @@ async function Iu(t, e, n) {
13537
13540
  } catch (n) {
13538
13541
  C("RemoteStore", "Failed to remove targets %s: %s ", e.targetIds.join(","), n),
13539
13542
  await Tu(t, n);
13540
- } else if (e instanceof gs ? t.pu.Gt(e) : e instanceof ys ? t.pu.Yt(e) : t.pu.Wt(e),
13543
+ } else if (e instanceof gs ? t.yu.Gt(e) : e instanceof ys ? t.yu.Yt(e) : t.yu.Wt(e),
13541
13544
  !n.isEqual(st.min())) try {
13542
13545
  const e = await Ro(t.localStore);
13543
13546
  n.compareTo(e) >= 0 &&
@@ -13550,26 +13553,26 @@ async function Iu(t, e, n) {
13550
13553
  * SyncEngine.
13551
13554
  */
13552
13555
  function(t, e) {
13553
- const n = t.pu.te(e);
13556
+ const n = t.yu.te(e);
13554
13557
  // Update in-memory resume tokens. LocalStore will update the
13555
13558
  // persistent view of these when applying the completed RemoteEvent.
13556
13559
  return n.targetChanges.forEach(((n, s) => {
13557
13560
  if (n.resumeToken.approximateByteSize() > 0) {
13558
- const i = t._u.get(s);
13561
+ const i = t.du.get(s);
13559
13562
  // A watched target might have been removed already.
13560
- i && t._u.set(s, i.withResumeToken(n.resumeToken, e));
13563
+ i && t.du.set(s, i.withResumeToken(n.resumeToken, e));
13561
13564
  }
13562
13565
  })),
13563
13566
  // Re-establish listens for the targets that have been invalidated by
13564
13567
  // existence filter mismatches.
13565
13568
  n.targetMismatches.forEach((e => {
13566
- const n = t._u.get(e);
13569
+ const n = t.du.get(e);
13567
13570
  if (!n)
13568
13571
  // A watched target might have been removed already.
13569
13572
  return;
13570
13573
  // Clear the resume token for the target, since we're in a known mismatch
13571
13574
  // state.
13572
- t._u.set(e, n.withResumeToken(Wt.EMPTY_BYTE_STRING, n.snapshotVersion)),
13575
+ t.du.set(e, n.withResumeToken(Wt.EMPTY_BYTE_STRING, n.snapshotVersion)),
13573
13576
  // Cause a hard reset by unwatching and rewatching immediately, but
13574
13577
  // deliberately don't send a resume token so that we get a full update.
13575
13578
  du(t, e);
@@ -13596,16 +13599,16 @@ async function Iu(t, e, n) {
13596
13599
  * any retry attempt.
13597
13600
  */ async function Tu(t, e, n) {
13598
13601
  if (!Vt(e)) throw e;
13599
- t.wu.add(1 /* IndexedDbFailed */),
13602
+ t._u.add(1 /* IndexedDbFailed */),
13600
13603
  // Disable network and raise offline snapshots
13601
- await au(t), t.yu.set("Offline" /* Offline */), n || (
13604
+ await au(t), t.gu.set("Offline" /* Offline */), n || (
13602
13605
  // Use a simple read operation to determine if IndexedDB recovered.
13603
13606
  // Ideally, we would expose a health check directly on SimpleDb, but
13604
13607
  // RemoteStore only has access to persistence through LocalStore.
13605
13608
  n = () => Ro(t.localStore)),
13606
13609
  // Probe IndexedDB periodically and re-enable network
13607
13610
  t.asyncQueue.enqueueRetryable((async () => {
13608
- C("RemoteStore", "Retrying IndexedDB access"), await n(), t.wu.delete(1 /* IndexedDbFailed */),
13611
+ C("RemoteStore", "Retrying IndexedDB access"), await n(), t._u.delete(1 /* IndexedDbFailed */),
13609
13612
  await cu(t);
13610
13613
  }));
13611
13614
  }
@@ -13619,11 +13622,11 @@ async function Iu(t, e, n) {
13619
13622
 
13620
13623
  async function Au(t) {
13621
13624
  const e = $(t), n = Ou(e);
13622
- let s = e.du.length > 0 ? e.du[e.du.length - 1].batchId : -1;
13625
+ let s = e.fu.length > 0 ? e.fu[e.fu.length - 1].batchId : -1;
13623
13626
  for (;Ru(e); ) try {
13624
13627
  const t = await vo(e.localStore, s);
13625
13628
  if (null === t) {
13626
- 0 === e.du.length && n.$o();
13629
+ 0 === e.fu.length && n.Fo();
13627
13630
  break;
13628
13631
  }
13629
13632
  s = t.batchId, bu(e, t);
@@ -13637,20 +13640,20 @@ async function Au(t) {
13637
13640
  * Returns true if we can add to the write pipeline (i.e. the network is
13638
13641
  * enabled and the write pipeline is not full).
13639
13642
  */ function Ru(t) {
13640
- return mu(t) && t.du.length < 10;
13643
+ return mu(t) && t.fu.length < 10;
13641
13644
  }
13642
13645
 
13643
13646
  /**
13644
13647
  * Queues additional writes to be sent to the write stream, sending them
13645
13648
  * immediately if the write stream is established.
13646
13649
  */ function bu(t, e) {
13647
- t.du.push(e);
13650
+ t.fu.push(e);
13648
13651
  const n = Ou(t);
13649
- n.Oo() && n.Xo && n.Zo(e.mutations);
13652
+ n.ko() && n.Yo && n.Xo(e.mutations);
13650
13653
  }
13651
13654
 
13652
13655
  function Pu(t) {
13653
- return mu(t) && !Ou(t).ko() && t.du.length > 0;
13656
+ return mu(t) && !Ou(t).No() && t.fu.length > 0;
13654
13657
  }
13655
13658
 
13656
13659
  function vu(t) {
@@ -13658,17 +13661,17 @@ function vu(t) {
13658
13661
  }
13659
13662
 
13660
13663
  async function Vu(t) {
13661
- Ou(t).nu();
13664
+ Ou(t).eu();
13662
13665
  }
13663
13666
 
13664
13667
  async function Su(t) {
13665
13668
  const e = Ou(t);
13666
13669
  // Send the write pipeline now that the stream is established.
13667
- for (const n of t.du) e.Zo(n.mutations);
13670
+ for (const n of t.fu) e.Xo(n.mutations);
13668
13671
  }
13669
13672
 
13670
13673
  async function Du(t, e, n) {
13671
- const s = t.du.shift(), i = Oi.from(s, e, n);
13674
+ const s = t.fu.shift(), i = Oi.from(s, e, n);
13672
13675
  await Eu(t, (() => t.remoteSyncer.applySuccessfulWrite(i))),
13673
13676
  // It's possible that with the completion of this mutation another
13674
13677
  // slot has freed up.
@@ -13678,7 +13681,7 @@ async function Du(t, e, n) {
13678
13681
  async function Cu(t, e) {
13679
13682
  // If the write stream closed after the write handshake completes, a write
13680
13683
  // operation failed and we fail the pending operation.
13681
- e && Ou(t).Xo &&
13684
+ e && Ou(t).Yo &&
13682
13685
  // This error affects the actual write.
13683
13686
  await async function(t, e) {
13684
13687
  // Only handle permanent errors here. If it's transient, just let the retry
@@ -13686,11 +13689,11 @@ async function Cu(t, e) {
13686
13689
  if (n = e.code, Zn(n) && n !== B.ABORTED) {
13687
13690
  // This was a permanent error, the request itself was the problem
13688
13691
  // so it's not going to succeed if we resend it.
13689
- const n = t.du.shift();
13692
+ const n = t.fu.shift();
13690
13693
  // In this case it's also unlikely that the server itself is melting
13691
13694
  // down -- this was just a bad request so inhibit backoff on the next
13692
13695
  // restart.
13693
- Ou(t).Fo(), await Eu(t, (() => t.remoteSyncer.rejectFailedWrite(n.batchId, e))),
13696
+ Ou(t).Mo(), await Eu(t, (() => t.remoteSyncer.rejectFailedWrite(n.batchId, e))),
13694
13697
  // It's possible that with the completion of this mutation
13695
13698
  // another slot has freed up.
13696
13699
  await Au(t);
@@ -13709,18 +13712,18 @@ async function xu(t, e) {
13709
13712
  // Tear down and re-create our network streams. This will ensure we get a
13710
13713
  // fresh auth token for the new user and re-fill the write pipeline with
13711
13714
  // new mutations from the LocalStore (since mutations are per-user).
13712
- n.wu.add(3 /* CredentialChange */), await au(n), s &&
13715
+ n._u.add(3 /* CredentialChange */), await au(n), s &&
13713
13716
  // Don't set the network status to Unknown if we are offline.
13714
- n.yu.set("Unknown" /* Unknown */), await n.remoteSyncer.handleCredentialChange(e),
13715
- n.wu.delete(3 /* CredentialChange */), await cu(n);
13717
+ n.gu.set("Unknown" /* Unknown */), await n.remoteSyncer.handleCredentialChange(e),
13718
+ n._u.delete(3 /* CredentialChange */), await cu(n);
13716
13719
  }
13717
13720
 
13718
13721
  /**
13719
13722
  * Toggles the network state when the client gains or loses its primary lease.
13720
13723
  */ async function Nu(t, e) {
13721
13724
  const n = $(t);
13722
- e ? (n.wu.delete(2 /* IsSecondary */), await cu(n)) : e || (n.wu.add(2 /* IsSecondary */),
13723
- await au(n), n.yu.set("Unknown" /* Unknown */));
13725
+ e ? (n._u.delete(2 /* IsSecondary */), await cu(n)) : e || (n._u.add(2 /* IsSecondary */),
13726
+ await au(n), n.gu.set("Unknown" /* Unknown */));
13724
13727
  }
13725
13728
 
13726
13729
  /**
@@ -13731,11 +13734,11 @@ async function xu(t, e) {
13731
13734
  * PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.
13732
13735
  * This is not done on Web to allow it to be tree-shaken.
13733
13736
  */ function ku(t) {
13734
- return t.Iu || (
13737
+ return t.pu || (
13735
13738
  // Create stream (but note that it is not started yet).
13736
- t.Iu = function(t, e, n) {
13739
+ t.pu = function(t, e, n) {
13737
13740
  const s = $(t);
13738
- return s.iu(), new nu(e, s.So, s.authCredentials, s.appCheckCredentials, s.It, n);
13741
+ return s.su(), new nu(e, s.connection, s.authCredentials, s.appCheckCredentials, s.It, n);
13739
13742
  }
13740
13743
  /**
13741
13744
  * @license
@@ -13755,11 +13758,11 @@ async function xu(t, e) {
13755
13758
  */ (t.datastore, t.asyncQueue, {
13756
13759
  Yr: yu.bind(null, t),
13757
13760
  Zr: pu.bind(null, t),
13758
- zo: Iu.bind(null, t)
13759
- }), t.mu.push((async e => {
13760
- e ? (t.Iu.Fo(), wu(t) ? _u(t) : t.yu.set("Unknown" /* Unknown */)) : (await t.Iu.stop(),
13761
+ Wo: Iu.bind(null, t)
13762
+ }), t.wu.push((async e => {
13763
+ e ? (t.pu.Mo(), wu(t) ? _u(t) : t.gu.set("Unknown" /* Unknown */)) : (await t.pu.stop(),
13761
13764
  gu(t));
13762
- }))), t.Iu;
13765
+ }))), t.pu;
13763
13766
  }
13764
13767
 
13765
13768
  /**
@@ -13770,22 +13773,22 @@ async function xu(t, e) {
13770
13773
  * PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.
13771
13774
  * This is not done on Web to allow it to be tree-shaken.
13772
13775
  */ function Ou(t) {
13773
- return t.Tu || (
13776
+ return t.Iu || (
13774
13777
  // Create stream (but note that it is not started yet).
13775
- t.Tu = function(t, e, n) {
13778
+ t.Iu = function(t, e, n) {
13776
13779
  const s = $(t);
13777
- return s.iu(), new su(e, s.So, s.authCredentials, s.appCheckCredentials, s.It, n);
13780
+ return s.su(), new su(e, s.connection, s.authCredentials, s.appCheckCredentials, s.It, n);
13778
13781
  }(t.datastore, t.asyncQueue, {
13779
13782
  Yr: Vu.bind(null, t),
13780
13783
  Zr: Cu.bind(null, t),
13781
- eu: Su.bind(null, t),
13782
- tu: Du.bind(null, t)
13783
- }), t.mu.push((async e => {
13784
- e ? (t.Tu.Fo(),
13784
+ tu: Su.bind(null, t),
13785
+ Zo: Du.bind(null, t)
13786
+ }), t.wu.push((async e => {
13787
+ e ? (t.Iu.Mo(),
13785
13788
  // This will start the write stream if necessary.
13786
- await Au(t)) : (await t.Tu.stop(), t.du.length > 0 && (C("RemoteStore", `Stopping write stream with ${t.du.length} pending writes`),
13787
- t.du = []));
13788
- }))), t.Tu;
13789
+ await Au(t)) : (await t.Iu.stop(), t.fu.length > 0 && (C("RemoteStore", `Stopping write stream with ${t.fu.length} pending writes`),
13790
+ t.fu = []));
13791
+ }))), t.Iu;
13789
13792
  }
13790
13793
 
13791
13794
  /**
@@ -13995,25 +13998,25 @@ class Mu {
13995
13998
  * duplicate events for the same doc.
13996
13999
  */ class Bu {
13997
14000
  constructor() {
13998
- this.Eu = new Bt(ct.comparator);
14001
+ this.Tu = new Bt(ct.comparator);
13999
14002
  }
14000
14003
  track(t) {
14001
- const e = t.doc.key, n = this.Eu.get(e);
14004
+ const e = t.doc.key, n = this.Tu.get(e);
14002
14005
  n ?
14003
14006
  // Merge the new change with the existing change.
14004
- 0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.Eu = this.Eu.insert(e, t) : 3 /* Metadata */ === t.type && 1 /* Removed */ !== n.type ? this.Eu = this.Eu.insert(e, {
14007
+ 0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.Tu = this.Tu.insert(e, t) : 3 /* Metadata */ === t.type && 1 /* Removed */ !== n.type ? this.Tu = this.Tu.insert(e, {
14005
14008
  type: n.type,
14006
14009
  doc: t.doc
14007
- }) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.Eu = this.Eu.insert(e, {
14010
+ }) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.Tu = this.Tu.insert(e, {
14008
14011
  type: 2 /* Modified */ ,
14009
14012
  doc: t.doc
14010
- }) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.Eu = this.Eu.insert(e, {
14013
+ }) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.Tu = this.Tu.insert(e, {
14011
14014
  type: 0 /* Added */ ,
14012
14015
  doc: t.doc
14013
- }) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.Eu = this.Eu.remove(e) : 1 /* Removed */ === t.type && 2 /* Modified */ === n.type ? this.Eu = this.Eu.insert(e, {
14016
+ }) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.Tu = this.Tu.remove(e) : 1 /* Removed */ === t.type && 2 /* Modified */ === n.type ? this.Tu = this.Tu.insert(e, {
14014
14017
  type: 1 /* Removed */ ,
14015
14018
  doc: n.doc
14016
- }) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.Eu = this.Eu.insert(e, {
14019
+ }) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.Tu = this.Tu.insert(e, {
14017
14020
  type: 2 /* Modified */ ,
14018
14021
  doc: t.doc
14019
14022
  }) :
@@ -14024,11 +14027,11 @@ class Mu {
14024
14027
  // Removed->Modified
14025
14028
  // Metadata->Added
14026
14029
  // Removed->Metadata
14027
- O() : this.Eu = this.Eu.insert(e, t);
14030
+ O() : this.Tu = this.Tu.insert(e, t);
14028
14031
  }
14029
- Au() {
14032
+ Eu() {
14030
14033
  const t = [];
14031
- return this.Eu.inorderTraversal(((e, n) => {
14034
+ return this.Tu.inorderTraversal(((e, n) => {
14032
14035
  t.push(n);
14033
14036
  })), t;
14034
14037
  }
@@ -14084,14 +14087,14 @@ class Lu {
14084
14087
  * tracked by EventManager.
14085
14088
  */ class Uu {
14086
14089
  constructor() {
14087
- this.Ru = void 0, this.listeners = [];
14090
+ this.Au = void 0, this.listeners = [];
14088
14091
  }
14089
14092
  }
14090
14093
 
14091
14094
  class qu {
14092
14095
  constructor() {
14093
14096
  this.queries = new es((t => ln(t)), hn), this.onlineState = "Unknown" /* Unknown */ ,
14094
- this.bu = new Set;
14097
+ this.Ru = new Set;
14095
14098
  }
14096
14099
  }
14097
14100
 
@@ -14099,15 +14102,15 @@ async function Ku(t, e) {
14099
14102
  const n = $(t), s = e.query;
14100
14103
  let i = !1, r = n.queries.get(s);
14101
14104
  if (r || (i = !0, r = new Uu), i) try {
14102
- r.Ru = await n.onListen(s);
14105
+ r.Au = await n.onListen(s);
14103
14106
  } catch (t) {
14104
14107
  const n = Fu(t, `Initialization of query '${fn(e.query)}' failed`);
14105
14108
  return void e.onError(n);
14106
14109
  }
14107
14110
  if (n.queries.set(s, r), r.listeners.push(e),
14108
14111
  // Run global snapshot listeners if a consistent snapshot has been emitted.
14109
- e.Pu(n.onlineState), r.Ru) {
14110
- e.vu(r.Ru) && Wu(n);
14112
+ e.bu(n.onlineState), r.Au) {
14113
+ e.Pu(r.Au) && Wu(n);
14111
14114
  }
14112
14115
  }
14113
14116
 
@@ -14128,8 +14131,8 @@ function Qu(t, e) {
14128
14131
  for (const t of e) {
14129
14132
  const e = t.query, i = n.queries.get(e);
14130
14133
  if (i) {
14131
- for (const e of i.listeners) e.vu(t) && (s = !0);
14132
- i.Ru = t;
14134
+ for (const e of i.listeners) e.Pu(t) && (s = !0);
14135
+ i.Au = t;
14133
14136
  }
14134
14137
  }
14135
14138
  s && Wu(n);
@@ -14145,7 +14148,7 @@ function ju(t, e, n) {
14145
14148
 
14146
14149
  // Call all global snapshot listeners that have been set.
14147
14150
  function Wu(t) {
14148
- t.bu.forEach((t => {
14151
+ t.Ru.forEach((t => {
14149
14152
  t.next();
14150
14153
  }));
14151
14154
  }
@@ -14157,19 +14160,19 @@ function Wu(t) {
14157
14160
  * It uses an Observer to dispatch events.
14158
14161
  */ class zu {
14159
14162
  constructor(t, e, n) {
14160
- this.query = t, this.Vu = e,
14163
+ this.query = t, this.vu = e,
14161
14164
  /**
14162
14165
  * Initial snapshots (e.g. from cache) may not be propagated to the wrapped
14163
14166
  * observer. This flag is set to true once we've actually raised an event.
14164
14167
  */
14165
- this.Su = !1, this.Du = null, this.onlineState = "Unknown" /* Unknown */ , this.options = n || {};
14168
+ this.Vu = !1, this.Su = null, this.onlineState = "Unknown" /* Unknown */ , this.options = n || {};
14166
14169
  }
14167
14170
  /**
14168
14171
  * Applies the new ViewSnapshot to this listener, raising a user-facing event
14169
14172
  * if applicable (depending on what changed, whether the user has opted into
14170
14173
  * metadata-only changes, etc.). Returns true if a user-facing event was
14171
14174
  * indeed raised.
14172
- */ vu(t) {
14175
+ */ Pu(t) {
14173
14176
  if (!this.options.includeMetadataChanges) {
14174
14177
  // Remove the metadata only changes.
14175
14178
  const e = [];
@@ -14178,19 +14181,19 @@ function Wu(t) {
14178
14181
  /* excludesMetadataChanges= */ !0, t.hasCachedResults);
14179
14182
  }
14180
14183
  let e = !1;
14181
- return this.Su ? this.Cu(t) && (this.Vu.next(t), e = !0) : this.xu(t, this.onlineState) && (this.Nu(t),
14182
- e = !0), this.Du = t, e;
14184
+ return this.Vu ? this.Du(t) && (this.vu.next(t), e = !0) : this.Cu(t, this.onlineState) && (this.xu(t),
14185
+ e = !0), this.Su = t, e;
14183
14186
  }
14184
14187
  onError(t) {
14185
- this.Vu.error(t);
14188
+ this.vu.error(t);
14186
14189
  }
14187
- /** Returns whether a snapshot was raised. */ Pu(t) {
14190
+ /** Returns whether a snapshot was raised. */ bu(t) {
14188
14191
  this.onlineState = t;
14189
14192
  let e = !1;
14190
- return this.Du && !this.Su && this.xu(this.Du, t) && (this.Nu(this.Du), e = !0),
14193
+ return this.Su && !this.Vu && this.Cu(this.Su, t) && (this.xu(this.Su), e = !0),
14191
14194
  e;
14192
14195
  }
14193
- xu(t, e) {
14196
+ Cu(t, e) {
14194
14197
  // Always raise the first event when we're synced
14195
14198
  if (!t.fromCache) return !0;
14196
14199
  // NOTE: We consider OnlineState.Unknown as online (it should become Offline
@@ -14198,25 +14201,25 @@ function Wu(t) {
14198
14201
  const n = "Offline" /* Offline */ !== e;
14199
14202
  // Don't raise the event if we're online, aren't synced yet (checked
14200
14203
  // above) and are waiting for a sync.
14201
- return (!this.options.ku || !n) && (!t.docs.isEmpty() || t.hasCachedResults || "Offline" /* Offline */ === e);
14204
+ return (!this.options.Nu || !n) && (!t.docs.isEmpty() || t.hasCachedResults || "Offline" /* Offline */ === e);
14202
14205
  // Raise data from cache if we have any documents, have cached results before,
14203
14206
  // or we are offline.
14204
14207
  }
14205
- Cu(t) {
14208
+ Du(t) {
14206
14209
  // We don't need to handle includeDocumentMetadataChanges here because
14207
14210
  // the Metadata only changes have already been stripped out if needed.
14208
14211
  // At this point the only changes we will see are the ones we should
14209
14212
  // propagate.
14210
14213
  if (t.docChanges.length > 0) return !0;
14211
- const e = this.Du && this.Du.hasPendingWrites !== t.hasPendingWrites;
14214
+ const e = this.Su && this.Su.hasPendingWrites !== t.hasPendingWrites;
14212
14215
  return !(!t.syncStateChanged && !e) && !0 === this.options.includeMetadataChanges;
14213
14216
  // Generally we should have hit one of the cases above, but it's possible
14214
14217
  // to get here if there were only metadata docChanges and they got
14215
14218
  // stripped out.
14216
14219
  }
14217
- Nu(t) {
14220
+ xu(t) {
14218
14221
  t = Lu.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache, t.hasCachedResults),
14219
- this.Su = !0, this.Vu.next(t);
14222
+ this.Vu = !0, this.vu.next(t);
14220
14223
  }
14221
14224
  }
14222
14225
 
@@ -14243,10 +14246,10 @@ function Wu(t) {
14243
14246
  constructor(t,
14244
14247
  // How many bytes this element takes to store in the bundle.
14245
14248
  e) {
14246
- this.payload = t, this.byteLength = e;
14249
+ this.ku = t, this.byteLength = e;
14247
14250
  }
14248
14251
  Ou() {
14249
- return "metadata" in this.payload;
14252
+ return "metadata" in this.ku;
14250
14253
  }
14251
14254
  }
14252
14255
 
@@ -14306,13 +14309,13 @@ function Wu(t) {
14306
14309
  */ Fu(t) {
14307
14310
  this.progress.bytesLoaded += t.byteLength;
14308
14311
  let e = this.progress.documentsLoaded;
14309
- if (t.payload.namedQuery) this.queries.push(t.payload.namedQuery); else if (t.payload.documentMetadata) {
14312
+ if (t.ku.namedQuery) this.queries.push(t.ku.namedQuery); else if (t.ku.documentMetadata) {
14310
14313
  this.documents.push({
14311
- metadata: t.payload.documentMetadata
14312
- }), t.payload.documentMetadata.exists || ++e;
14313
- const n = rt.fromString(t.payload.documentMetadata.name);
14314
+ metadata: t.ku.documentMetadata
14315
+ }), t.ku.documentMetadata.exists || ++e;
14316
+ const n = rt.fromString(t.ku.documentMetadata.name);
14314
14317
  this.collectionGroups.add(n.get(n.length - 2));
14315
- } else t.payload.document && (this.documents[this.documents.length - 1].document = t.payload.document,
14318
+ } else t.ku.document && (this.documents[this.documents.length - 1].document = t.ku.document,
14316
14319
  ++e);
14317
14320
  return e !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = e,
14318
14321
  Object.assign({}, this.progress)) : null;
@@ -14505,7 +14508,7 @@ class tc {
14505
14508
  const s = this.Qu;
14506
14509
  this.Qu = t.Qu, this.mutatedKeys = t.mutatedKeys;
14507
14510
  // Sort changes based on type and query comparator
14508
- const i = t.zu.Au();
14511
+ const i = t.zu.Eu();
14509
14512
  i.sort(((t, e) => function(t, e) {
14510
14513
  const n = t => {
14511
14514
  switch (t) {
@@ -14560,7 +14563,7 @@ class tc {
14560
14563
  /**
14561
14564
  * Applies an OnlineState change to the view, potentially generating a
14562
14565
  * ViewChange if the view's syncState changes as a result.
14563
- */ Pu(t) {
14566
+ */ bu(t) {
14564
14567
  return this.current && "Offline" /* Offline */ === t ? (
14565
14568
  // If we're offline, set `current` to false and then call applyChanges()
14566
14569
  // to refresh our syncState and generate a ViewChange as appropriate. We
@@ -14911,7 +14914,7 @@ async function rc(t, e) {
14911
14914
  if (s.isPrimaryClient && 0 /* RemoteStore */ === n || !s.isPrimaryClient && 1 /* SharedClientState */ === n) {
14912
14915
  const t = [];
14913
14916
  s.ic.forEach(((n, s) => {
14914
- const i = s.view.Pu(e);
14917
+ const i = s.view.bu(e);
14915
14918
  i.snapshot && t.push(i.snapshot);
14916
14919
  })), function(t, e) {
14917
14920
  const n = $(t);
@@ -14920,9 +14923,9 @@ async function rc(t, e) {
14920
14923
  n.queries.forEach(((t, n) => {
14921
14924
  for (const t of n.listeners)
14922
14925
  // Run global snapshot listeners if a consistent snapshot has been emitted.
14923
- t.Pu(e) && (s = !0);
14926
+ t.bu(e) && (s = !0);
14924
14927
  })), s && Wu(n);
14925
- }(s.eventManager, e), t.length && s.sc.zo(t), s.onlineState = e, s.isPrimaryClient && s.sharedClientState.setOnlineState(e);
14928
+ }(s.eventManager, e), t.length && s.sc.Wo(t), s.onlineState = e, s.isPrimaryClient && s.sharedClientState.setOnlineState(e);
14926
14929
  }
14927
14930
  }
14928
14931
 
@@ -15118,7 +15121,7 @@ async function Ec(t, e, n) {
15118
15121
  r.push(e);
15119
15122
  }
15120
15123
  })));
15121
- })), await Promise.all(o), s.sc.zo(i), await async function(t, e) {
15124
+ })), await Promise.all(o), s.sc.Wo(i), await async function(t, e) {
15122
15125
  const n = $(t);
15123
15126
  try {
15124
15127
  await n.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (t => At.forEach(e, (e => At.forEach(e.Si, (s => n.persistence.referenceDelegate.addReference(t, e.targetId, s))).next((() => At.forEach(e.Di, (s => n.persistence.referenceDelegate.removeReference(t, e.targetId, s)))))))));
@@ -15293,7 +15296,7 @@ async function Sc(t, e, n) {
15293
15296
  }
15294
15297
  i.push(e);
15295
15298
  }
15296
- return s.sc.zo(r), i;
15299
+ return s.sc.Wo(r), i;
15297
15300
  }
15298
15301
 
15299
15302
  /**
@@ -15374,7 +15377,7 @@ async function xc(t, e, n, s) {
15374
15377
  function kc(t) {
15375
15378
  const e = $(t);
15376
15379
  return e.remoteStore.remoteSyncer.applyRemoteEvent = ac.bind(null, e), e.remoteStore.remoteSyncer.getRemoteKeysForTarget = Rc.bind(null, e),
15377
- e.remoteStore.remoteSyncer.rejectListen = lc.bind(null, e), e.sc.zo = Qu.bind(null, e.eventManager),
15380
+ e.remoteStore.remoteSyncer.rejectListen = lc.bind(null, e), e.sc.Wo = Qu.bind(null, e.eventManager),
15378
15381
  e.sc.wc = ju.bind(null, e.eventManager), e;
15379
15382
  }
15380
15383
 
@@ -15601,11 +15604,11 @@ class Fc {
15601
15604
  terminate() {
15602
15605
  return async function(t) {
15603
15606
  const e = $(t);
15604
- C("RemoteStore", "RemoteStore shutting down."), e.wu.add(5 /* Shutdown */), await au(e),
15605
- e.gu.shutdown(),
15607
+ C("RemoteStore", "RemoteStore shutting down."), e._u.add(5 /* Shutdown */), await au(e),
15608
+ e.mu.shutdown(),
15606
15609
  // Set the OnlineState to Unknown (rather than Offline) to avoid potentially
15607
15610
  // triggering spurious listener events with cached data, etc.
15608
- e.yu.set("Unknown" /* Unknown */);
15611
+ e.gu.set("Unknown" /* Unknown */);
15609
15612
  }(this.remoteStore);
15610
15613
  }
15611
15614
  }
@@ -16168,7 +16171,7 @@ class ua {
16168
16171
  this.observer.next && this.Rc(this.observer.next, t);
16169
16172
  }
16170
16173
  error(t) {
16171
- this.observer.error ? this.Rc(this.observer.error, t) : x("Uncaught Error in snapshot listener:", t);
16174
+ this.observer.error ? this.Rc(this.observer.error, t) : x("Uncaught Error in snapshot listener:", t.toString());
16172
16175
  }
16173
16176
  bc() {
16174
16177
  this.muted = !0;
@@ -16215,7 +16218,7 @@ class ua {
16215
16218
  this.buffer = new Uint8Array, this.vc = new TextDecoder("utf-8"),
16216
16219
  // Read the metadata (which is the first element).
16217
16220
  this.Vc().then((t => {
16218
- t && t.Ou() ? this.metadata.resolve(t.payload.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == t ? void 0 : t.payload)}`));
16221
+ t && t.Ou() ? this.metadata.resolve(t.ku.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == t ? void 0 : t.ku)}`));
16219
16222
  }), (t => this.metadata.reject(t)));
16220
16223
  }
16221
16224
  close() {
@@ -16545,13 +16548,13 @@ class aa {
16545
16548
  */ class da {
16546
16549
  constructor(t, e, n, s, i) {
16547
16550
  this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = s,
16548
- this.deferred = i, this.kc = n.maxAttempts, this.No = new tu(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
16551
+ this.deferred = i, this.kc = n.maxAttempts, this.xo = new tu(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
16549
16552
  }
16550
16553
  /** Runs the transaction and sets the result on deferred. */ run() {
16551
16554
  this.kc -= 1, this.Oc();
16552
16555
  }
16553
16556
  Oc() {
16554
- this.No.Ro((async () => {
16557
+ this.xo.Ro((async () => {
16555
16558
  const t = new fa(this.datastore), e = this.Mc(t);
16556
16559
  e && e.then((e => {
16557
16560
  this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
@@ -16583,7 +16586,7 @@ class aa {
16583
16586
  // In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
16584
16587
  // non-matching document versions with ABORTED. These errors should be retried.
16585
16588
  const e = t.code;
16586
- return "aborted" === e || "failed-precondition" === e || !Zn(e);
16589
+ return "aborted" === e || "failed-precondition" === e || "already-exists" === e || !Zn(e);
16587
16590
  }
16588
16591
  return !1;
16589
16592
  }
@@ -16736,7 +16739,7 @@ async function Ra(t) {
16736
16739
  const e = await pa(t), n = await Ta(t);
16737
16740
  return e.setNetworkEnabled(!0), function(t) {
16738
16741
  const e = $(t);
16739
- return e.wu.delete(0 /* UserDisabled */), cu(e);
16742
+ return e._u.delete(0 /* UserDisabled */), cu(e);
16740
16743
  }(n);
16741
16744
  }));
16742
16745
  }
@@ -16746,9 +16749,9 @@ async function Ra(t) {
16746
16749
  const e = await pa(t), n = await Ta(t);
16747
16750
  return e.setNetworkEnabled(!1), async function(t) {
16748
16751
  const e = $(t);
16749
- e.wu.add(0 /* UserDisabled */), await au(e),
16752
+ e._u.add(0 /* UserDisabled */), await au(e),
16750
16753
  // Set the OnlineState to Offline so get()s return from cache, etc.
16751
- e.yu.set("Offline" /* Offline */);
16754
+ e.gu.set("Offline" /* Offline */);
16752
16755
  }(n);
16753
16756
  }));
16754
16757
  }
@@ -16799,7 +16802,7 @@ function Va(t, e, n = {}) {
16799
16802
  error: t => i.reject(t)
16800
16803
  }), o = new zu(en(n.path), r, {
16801
16804
  includeMetadataChanges: !0,
16802
- ku: !0
16805
+ Nu: !0
16803
16806
  });
16804
16807
  return Ku(t, o);
16805
16808
  }(await Ra(t), t.asyncQueue, e, n, s))), s.promise;
@@ -16836,7 +16839,7 @@ function Da(t, e, n = {}) {
16836
16839
  error: t => i.reject(t)
16837
16840
  }), o = new zu(n, r, {
16838
16841
  includeMetadataChanges: !0,
16839
- ku: !0
16842
+ Nu: !0
16840
16843
  });
16841
16844
  return Ku(t, o);
16842
16845
  }(await Ra(t), t.asyncQueue, e, n, s))), s.promise;
@@ -16845,13 +16848,13 @@ function Da(t, e, n = {}) {
16845
16848
  function Ca(t, e) {
16846
16849
  const n = new ua(e);
16847
16850
  return t.asyncQueue.enqueueAndForget((async () => function(t, e) {
16848
- $(t).bu.add(e),
16851
+ $(t).Ru.add(e),
16849
16852
  // Immediately fire an initial event, indicating all existing listeners
16850
16853
  // are in-sync.
16851
16854
  e.next();
16852
16855
  }(await Ra(t), n))), () => {
16853
16856
  n.bc(), t.asyncQueue.enqueueAndForget((async () => function(t, e) {
16854
- $(t).bu.delete(e);
16857
+ $(t).Ru.delete(e);
16855
16858
  }(await Ra(t), n)));
16856
16859
  };
16857
16860
  }
@@ -16934,13 +16937,13 @@ class ka {
16934
16937
  // List of TimerIds to fast-forward delays for.
16935
16938
  this.jc = [],
16936
16939
  // Backoff timer used to schedule retries for retryable operations
16937
- this.No = new tu(this, "async_queue_retry" /* AsyncQueueRetry */),
16940
+ this.xo = new tu(this, "async_queue_retry" /* AsyncQueueRetry */),
16938
16941
  // Visibility handler that triggers an immediate retry of all retryable
16939
16942
  // operations. Meant to speed up recovery when we regain file system access
16940
16943
  // after page comes into foreground.
16941
16944
  this.Wc = () => {
16942
16945
  const t = Xo();
16943
- t && C("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.No.Po();
16946
+ t && C("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.xo.Po();
16944
16947
  };
16945
16948
  const t = Xo();
16946
16949
  t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Wc);
@@ -16987,7 +16990,7 @@ class ka {
16987
16990
  */ async Jc() {
16988
16991
  if (0 !== this.Lc.length) {
16989
16992
  try {
16990
- await this.Lc[0](), this.Lc.shift(), this.No.reset();
16993
+ await this.Lc[0](), this.Lc.shift(), this.xo.reset();
16991
16994
  } catch (t) {
16992
16995
  if (!Vt(t)) throw t;
16993
16996
  // Failure will be handled by AsyncQueue
@@ -17004,7 +17007,7 @@ class ka {
17004
17007
  // Since `backoffAndRun()` cancels an existing backoff and schedules a
17005
17008
  // new backoff on every call, there is only ever a single additional
17006
17009
  // operation in the queue.
17007
- this.No.Ro((() => this.Jc()));
17010
+ this.xo.Ro((() => this.Jc()));
17008
17011
  }
17009
17012
  }
17010
17013
  Hc(t) {
@@ -19117,12 +19120,15 @@ class nl extends tl {
19117
19120
  function(t, e) {
19118
19121
  if (t._snapshot.oldDocs.isEmpty()) {
19119
19122
  let e = 0;
19120
- return t._snapshot.docChanges.map((n => ({
19121
- type: "added",
19122
- doc: new rl(t._firestore, t._userDataWriter, n.doc.key, n.doc, new sl(t._snapshot.mutatedKeys.has(n.doc.key), t._snapshot.fromCache), t.query.converter),
19123
- oldIndex: -1,
19124
- newIndex: e++
19125
- })));
19123
+ return t._snapshot.docChanges.map((n => {
19124
+ const s = new rl(t._firestore, t._userDataWriter, n.doc.key, n.doc, new sl(t._snapshot.mutatedKeys.has(n.doc.key), t._snapshot.fromCache), t.query.converter);
19125
+ return n.doc, {
19126
+ type: "added",
19127
+ doc: s,
19128
+ oldIndex: -1,
19129
+ newIndex: e++
19130
+ };
19131
+ }));
19126
19132
  }
19127
19133
  {
19128
19134
  // A `DocumentSet` that is updated incrementally as changes are applied to use
@@ -19953,9 +19959,9 @@ function $l(t, e) {
19953
19959
  return s = Object.assign({
19954
19960
  useFetchStreams: e
19955
19961
  }, s), r._setSettings(s), r;
19956
- }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.7.1", t),
19962
+ }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, "3.7.2-canary.457fc2eeb", t),
19957
19963
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
19958
- registerVersion(b, "3.7.1", "esm2017");
19964
+ registerVersion(b, "3.7.2-canary.457fc2eeb", "esm2017");
19959
19965
  }();
19960
19966
 
19961
19967
  export { tl as AbstractUserDataWriter, aa as AggregateField, ha as AggregateQuerySnapshot, th as Bytes, Fa as CACHE_SIZE_UNLIMITED, ta as CollectionReference, Xc as DocumentReference, il as DocumentSnapshot, eh as FieldPath, sh as FieldValue, $a as Firestore, L as FirestoreError, ih as GeoPoint, Ma as LoadBundleTask, Zc as Query, Oh as QueryConstraint, rl as QueryDocumentSnapshot, ol as QuerySnapshot, sl as SnapshotMetadata, nt as Timestamp, Sl as Transaction, vl as WriteBatch, ne as _DatabaseId, ct as _DocumentKey, J as _EmptyAppCheckTokenProvider, K as _EmptyAuthCredentialsProvider, ut as _FieldPath, jc as _cast, F as _debugAssert, jt as _isBase64Available, N as _logWarn, qc as _validateIsNotUsedTogether, pl as addDoc, Rl as aggregateQuerySnapshotEqual, kl as arrayRemove, Nl as arrayUnion, ja as clearIndexedDbPersistence, ea as collection, na as collectionGroup, Yc as connectFirestoreEmulator, yl as deleteDoc, Cl as deleteField, Ha as disableNetwork, sa as doc, nh as documentId, Ka as enableIndexedDbPersistence, Ga as enableMultiTabIndexedDbPersistence, za as enableNetwork, Hh as endAt, zh as endBefore, Ua as ensureFirestoreConfigured, El as executeWrite, bl as getCountFromServer, al as getDoc, ll as getDocFromCache, fl as getDocFromServer, dl as getDocs, _l as getDocsFromCache, wl as getDocsFromServer, La as getFirestore, Ol as increment, Ba as initializeFirestore, qh as limit, Kh as limitToLast, Ya as loadBundle, Xa as namedQuery, Il as onSnapshot, Tl as onSnapshotsInSync, Lh as orderBy, Mh as query, ra as queryEqual, ia as refEqual, Dl as runTransaction, xl as serverTimestamp, ml as setDoc, Fl as setIndexConfiguration, D as setLogLevel, cl as snapshotEqual, jh as startAfter, Qh as startAt, Ja as terminate, gl as updateDoc, Wa as waitForPendingWrites, $h as where, Ml as writeBatch };