@purr-core/services.firebase 0.0.7 → 0.0.9
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.
- package/package.json +5 -3
- package/dist/_api.d.ts +0 -8
- package/dist/_init.d.ts +0 -6
- package/dist/_types.d.ts +0 -9
- package/dist/index-Bb-UMLbg.cjs +0 -2647
- package/dist/index-Cfwu2WEL.js +0 -21110
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.esm-BE0Pdipi.js +0 -119
- package/dist/index.esm-BIT1xOwF.js +0 -44
- package/dist/index.esm-Bng7WOuv.cjs +0 -16
- package/dist/index.esm-CASCXGKx.cjs +0 -400
- package/dist/index.esm-DRjOyAw_.js +0 -2136
- package/dist/index.esm-DS_RlbEp.cjs +0 -1
- package/dist/index.js +0 -11
package/dist/index-Bb-UMLbg.cjs
DELETED
|
@@ -1,2647 +0,0 @@
|
|
|
1
|
-
"use strict";const Qr=require("@purr-core/utils.helpers");/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*//**
|
|
17
|
-
* @license
|
|
18
|
-
* Copyright 2017 Google LLC
|
|
19
|
-
*
|
|
20
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
-
* you may not use this file except in compliance with the License.
|
|
22
|
-
* You may obtain a copy of the License at
|
|
23
|
-
*
|
|
24
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
-
*
|
|
26
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
27
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
-
* See the License for the specific language governing permissions and
|
|
30
|
-
* limitations under the License.
|
|
31
|
-
*/const sl=function(r){const t=[];let e=0;for(let n=0;n<r.length;n++){let i=r.charCodeAt(n);i<128?t[e++]=i:i<2048?(t[e++]=i>>6|192,t[e++]=i&63|128):(i&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(r.charCodeAt(++n)&1023),t[e++]=i>>18|240,t[e++]=i>>12&63|128,t[e++]=i>>6&63|128,t[e++]=i&63|128):(t[e++]=i>>12|224,t[e++]=i>>6&63|128,t[e++]=i&63|128)}return t},jf=function(r){const t=[];let e=0,n=0;for(;e<r.length;){const i=r[e++];if(i<128)t[n++]=String.fromCharCode(i);else if(i>191&&i<224){const s=r[e++];t[n++]=String.fromCharCode((i&31)<<6|s&63)}else if(i>239&&i<365){const s=r[e++],a=r[e++],u=r[e++],c=((i&7)<<18|(s&63)<<12|(a&63)<<6|u&63)-65536;t[n++]=String.fromCharCode(55296+(c>>10)),t[n++]=String.fromCharCode(56320+(c&1023))}else{const s=r[e++],a=r[e++];t[n++]=String.fromCharCode((i&15)<<12|(s&63)<<6|a&63)}}return t.join("")},ol={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(r,t){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();const e=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let i=0;i<r.length;i+=3){const s=r[i],a=i+1<r.length,u=a?r[i+1]:0,c=i+2<r.length,h=c?r[i+2]:0,f=s>>2,g=(s&3)<<4|u>>4;let _=(u&15)<<2|h>>6,R=h&63;c||(R=64,a||(_=64)),n.push(e[f],e[g],e[_],e[R])}return n.join("")},encodeString(r,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(r):this.encodeByteArray(sl(r),t)},decodeString(r,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(r):jf(this.decodeStringToByteArray(r,t))},decodeStringToByteArray(r,t){this.init_();const e=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let i=0;i<r.length;){const s=e[r.charAt(i++)],u=i<r.length?e[r.charAt(i)]:0;++i;const h=i<r.length?e[r.charAt(i)]:64;++i;const g=i<r.length?e[r.charAt(i)]:64;if(++i,s==null||u==null||h==null||g==null)throw new Gf;const _=s<<2|u>>4;if(n.push(_),h!==64){const R=u<<4&240|h>>2;if(n.push(R),g!==64){const C=h<<6&192|g;n.push(C)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let r=0;r<this.ENCODED_VALS.length;r++)this.byteToCharMap_[r]=this.ENCODED_VALS.charAt(r),this.charToByteMap_[this.byteToCharMap_[r]]=r,this.byteToCharMapWebSafe_[r]=this.ENCODED_VALS_WEBSAFE.charAt(r),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[r]]=r,r>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(r)]=r,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(r)]=r)}}};class Gf extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Kf=function(r){const t=sl(r);return ol.encodeByteArray(t,!0)},Gi=function(r){return Kf(r).replace(/\./g,"")},$f=function(r){try{return ol.decodeString(r,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};/**
|
|
32
|
-
* @license
|
|
33
|
-
* Copyright 2022 Google LLC
|
|
34
|
-
*
|
|
35
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
36
|
-
* you may not use this file except in compliance with the License.
|
|
37
|
-
* You may obtain a copy of the License at
|
|
38
|
-
*
|
|
39
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
40
|
-
*
|
|
41
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
42
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
43
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
44
|
-
* See the License for the specific language governing permissions and
|
|
45
|
-
* limitations under the License.
|
|
46
|
-
*/function Qf(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
|
|
47
|
-
* @license
|
|
48
|
-
* Copyright 2022 Google LLC
|
|
49
|
-
*
|
|
50
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
51
|
-
* you may not use this file except in compliance with the License.
|
|
52
|
-
* You may obtain a copy of the License at
|
|
53
|
-
*
|
|
54
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
55
|
-
*
|
|
56
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
57
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
58
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
59
|
-
* See the License for the specific language governing permissions and
|
|
60
|
-
* limitations under the License.
|
|
61
|
-
*/const Wf=()=>Qf().__FIREBASE_DEFAULTS__,Hf=()=>{if(typeof process>"u"||typeof process.env>"u")return;const r=process.env.__FIREBASE_DEFAULTS__;if(r)return JSON.parse(r)},Jf=()=>{if(typeof document>"u")return;let r;try{r=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const t=r&&$f(r[1]);return t&&JSON.parse(t)},Fo=()=>{try{return Wf()||Hf()||Jf()}catch(r){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${r}`);return}},Yf=r=>{var t,e;return(e=(t=Fo())===null||t===void 0?void 0:t.emulatorHosts)===null||e===void 0?void 0:e[r]},al=r=>{const t=Yf(r);if(!t)return;const e=t.lastIndexOf(":");if(e<=0||e+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const n=parseInt(t.substring(e+1),10);return t[0]==="["?[t.substring(1,e-1),n]:[t.substring(0,e),n]},ul=()=>{var r;return(r=Fo())===null||r===void 0?void 0:r.config};/**
|
|
62
|
-
* @license
|
|
63
|
-
* Copyright 2017 Google LLC
|
|
64
|
-
*
|
|
65
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
66
|
-
* you may not use this file except in compliance with the License.
|
|
67
|
-
* You may obtain a copy of the License at
|
|
68
|
-
*
|
|
69
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
70
|
-
*
|
|
71
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
72
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
73
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
74
|
-
* See the License for the specific language governing permissions and
|
|
75
|
-
* limitations under the License.
|
|
76
|
-
*/class Xf{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}wrapCallback(t){return(e,n)=>{e?this.reject(e):this.resolve(n),typeof t=="function"&&(this.promise.catch(()=>{}),t.length===1?t(e):t(e,n))}}}/**
|
|
77
|
-
* @license
|
|
78
|
-
* Copyright 2021 Google LLC
|
|
79
|
-
*
|
|
80
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
81
|
-
* you may not use this file except in compliance with the License.
|
|
82
|
-
* You may obtain a copy of the License at
|
|
83
|
-
*
|
|
84
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
85
|
-
*
|
|
86
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
87
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
88
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
89
|
-
* See the License for the specific language governing permissions and
|
|
90
|
-
* limitations under the License.
|
|
91
|
-
*/function cl(r,t){if(r.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const e={alg:"none",type:"JWT"},n=t||"demo-project",i=r.iat||0,s=r.sub||r.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:i,exp:i+3600,auth_time:i,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},r);return[Gi(JSON.stringify(e)),Gi(JSON.stringify(a)),""].join(".")}/**
|
|
92
|
-
* @license
|
|
93
|
-
* Copyright 2017 Google LLC
|
|
94
|
-
*
|
|
95
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
96
|
-
* you may not use this file except in compliance with the License.
|
|
97
|
-
* You may obtain a copy of the License at
|
|
98
|
-
*
|
|
99
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
100
|
-
*
|
|
101
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
102
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
103
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
104
|
-
* See the License for the specific language governing permissions and
|
|
105
|
-
* limitations under the License.
|
|
106
|
-
*/function Ki(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Zf(){var r;const t=(r=Fo())===null||r===void 0?void 0:r.forceEnvironment;if(t==="node")return!0;if(t==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function tm(){return typeof window<"u"||ll()}function ll(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function hl(){return!Zf()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function dl(){try{return typeof indexedDB=="object"}catch{return!1}}function em(){return new Promise((r,t)=>{try{let e=!0;const n="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(n);i.onsuccess=()=>{i.result.close(),e||self.indexedDB.deleteDatabase(n),r(!0)},i.onupgradeneeded=()=>{e=!1},i.onerror=()=>{var s;t(((s=i.error)===null||s===void 0?void 0:s.message)||"")}}catch(e){t(e)}})}/**
|
|
107
|
-
* @license
|
|
108
|
-
* Copyright 2017 Google LLC
|
|
109
|
-
*
|
|
110
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
111
|
-
* you may not use this file except in compliance with the License.
|
|
112
|
-
* You may obtain a copy of the License at
|
|
113
|
-
*
|
|
114
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
115
|
-
*
|
|
116
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
117
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
118
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
119
|
-
* See the License for the specific language governing permissions and
|
|
120
|
-
* limitations under the License.
|
|
121
|
-
*/const nm="FirebaseError";class un extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name=nm,Object.setPrototypeOf(this,un.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,fl.prototype.create)}}class fl{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},i=`${this.service}/${t}`,s=this.errors[t],a=s?rm(s,n):"Error",u=`${this.serviceName}: ${a} (${i}).`;return new un(i,u,n)}}function rm(r,t){return r.replace(im,(e,n)=>{const i=t[n];return i!=null?String(i):`<${n}?>`})}const im=/\{\$([^}]+)}/g;function Ye(r,t){if(r===t)return!0;const e=Object.keys(r),n=Object.keys(t);for(const i of e){if(!n.includes(i))return!1;const s=r[i],a=t[i];if(Bu(s)&&Bu(a)){if(!Ye(s,a))return!1}else if(s!==a)return!1}for(const i of n)if(!e.includes(i))return!1;return!0}function Bu(r){return r!==null&&typeof r=="object"}/**
|
|
122
|
-
* @license
|
|
123
|
-
* Copyright 2021 Google LLC
|
|
124
|
-
*
|
|
125
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
126
|
-
* you may not use this file except in compliance with the License.
|
|
127
|
-
* You may obtain a copy of the License at
|
|
128
|
-
*
|
|
129
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
130
|
-
*
|
|
131
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
132
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
133
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
134
|
-
* See the License for the specific language governing permissions and
|
|
135
|
-
* limitations under the License.
|
|
136
|
-
*/function yt(r){return r&&r._delegate?r._delegate:r}class bn{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}/**
|
|
137
|
-
* @license
|
|
138
|
-
* Copyright 2019 Google LLC
|
|
139
|
-
*
|
|
140
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
141
|
-
* you may not use this file except in compliance with the License.
|
|
142
|
-
* You may obtain a copy of the License at
|
|
143
|
-
*
|
|
144
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
145
|
-
*
|
|
146
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
147
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
148
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
149
|
-
* See the License for the specific language governing permissions and
|
|
150
|
-
* limitations under the License.
|
|
151
|
-
*/const ze="[DEFAULT]";/**
|
|
152
|
-
* @license
|
|
153
|
-
* Copyright 2019 Google LLC
|
|
154
|
-
*
|
|
155
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
156
|
-
* you may not use this file except in compliance with the License.
|
|
157
|
-
* You may obtain a copy of the License at
|
|
158
|
-
*
|
|
159
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
160
|
-
*
|
|
161
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
162
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
163
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
164
|
-
* See the License for the specific language governing permissions and
|
|
165
|
-
* limitations under the License.
|
|
166
|
-
*/class sm{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const n=new Xf;if(this.instancesDeferred.set(e,n),this.isInitialized(e)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:e});i&&n.resolve(i)}catch{}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const n=this.normalizeInstanceIdentifier(t==null?void 0:t.identifier),i=(e=t==null?void 0:t.optional)!==null&&e!==void 0?e:!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(s){if(i)return null;throw s}else{if(i)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,!!this.shouldAutoInitialize()){if(am(t))try{this.getOrInitializeService({instanceIdentifier:ze})}catch{}for(const[e,n]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(e);try{const s=this.getOrInitializeService({instanceIdentifier:i});n.resolve(s)}catch{}}}}clearInstance(t=ze){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...t.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(t=ze){return this.instances.has(t)}getOptions(t=ze){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,n=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:e});for(const[s,a]of this.instancesDeferred.entries()){const u=this.normalizeInstanceIdentifier(s);n===u&&a.resolve(i)}return i}onInit(t,e){var n;const i=this.normalizeInstanceIdentifier(e),s=(n=this.onInitCallbacks.get(i))!==null&&n!==void 0?n:new Set;s.add(t),this.onInitCallbacks.set(i,s);const a=this.instances.get(i);return a&&t(a,i),()=>{s.delete(t)}}invokeOnInitCallbacks(t,e){const n=this.onInitCallbacks.get(e);if(n)for(const i of n)try{i(t,e)}catch{}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let n=this.instances.get(t);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:om(t),options:e}),this.instances.set(t,n),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(n,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,n)}catch{}return n||null}normalizeInstanceIdentifier(t=ze){return this.component?this.component.multipleInstances?t:ze:t}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function om(r){return r===ze?void 0:r}function am(r){return r.instantiationMode==="EAGER"}/**
|
|
167
|
-
* @license
|
|
168
|
-
* Copyright 2019 Google LLC
|
|
169
|
-
*
|
|
170
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
171
|
-
* you may not use this file except in compliance with the License.
|
|
172
|
-
* You may obtain a copy of the License at
|
|
173
|
-
*
|
|
174
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
175
|
-
*
|
|
176
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
177
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
178
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
179
|
-
* See the License for the specific language governing permissions and
|
|
180
|
-
* limitations under the License.
|
|
181
|
-
*/class ml{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new sm(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}/**
|
|
182
|
-
* @license
|
|
183
|
-
* Copyright 2017 Google LLC
|
|
184
|
-
*
|
|
185
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
186
|
-
* you may not use this file except in compliance with the License.
|
|
187
|
-
* You may obtain a copy of the License at
|
|
188
|
-
*
|
|
189
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
190
|
-
*
|
|
191
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
192
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
193
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
194
|
-
* See the License for the specific language governing permissions and
|
|
195
|
-
* limitations under the License.
|
|
196
|
-
*/const Mo=[];var J;(function(r){r[r.DEBUG=0]="DEBUG",r[r.VERBOSE=1]="VERBOSE",r[r.INFO=2]="INFO",r[r.WARN=3]="WARN",r[r.ERROR=4]="ERROR",r[r.SILENT=5]="SILENT"})(J||(J={}));const gl={debug:J.DEBUG,verbose:J.VERBOSE,info:J.INFO,warn:J.WARN,error:J.ERROR,silent:J.SILENT},um=J.INFO,cm={[J.DEBUG]:"log",[J.VERBOSE]:"log",[J.INFO]:"info",[J.WARN]:"warn",[J.ERROR]:"error"},lm=(r,t,...e)=>{if(t<r.logLevel)return;const n=new Date().toISOString(),i=cm[t];if(i)console[i](`[${n}] ${r.name}:`,...e);else throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`)};class pl{constructor(t){this.name=t,this._logLevel=um,this._logHandler=lm,this._userLogHandler=null,Mo.push(this)}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in J))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel=typeof t=="string"?gl[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if(typeof t!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,J.DEBUG,...t),this._logHandler(this,J.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,J.VERBOSE,...t),this._logHandler(this,J.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,J.INFO,...t),this._logHandler(this,J.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,J.WARN,...t),this._logHandler(this,J.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,J.ERROR,...t),this._logHandler(this,J.ERROR,...t)}}function hm(r){Mo.forEach(t=>{t.setLogLevel(r)})}function dm(r,t){for(const e of Mo){let n=null;t&&t.level&&(n=gl[t.level]),r===null?e.userLogHandler=null:e.userLogHandler=(i,s,...a)=>{const u=a.map(c=>{if(c==null)return null;if(typeof c=="string")return c;if(typeof c=="number"||typeof c=="boolean")return c.toString();if(c instanceof Error)return c.message;try{return JSON.stringify(c)}catch{return null}}).filter(c=>c).join(" ");s>=(n??i.logLevel)&&r({level:J[s].toLowerCase(),message:u,args:a,type:i.name})}}}const fm=(r,t)=>t.some(e=>r instanceof e);let Uu,qu;function mm(){return Uu||(Uu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function gm(){return qu||(qu=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const _l=new WeakMap,co=new WeakMap,yl=new WeakMap,Zs=new WeakMap,Oo=new WeakMap;function pm(r){const t=new Promise((e,n)=>{const i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",a)},s=()=>{e(Ie(r.result)),i()},a=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",a)});return t.then(e=>{e instanceof IDBCursor&&_l.set(e,r)}).catch(()=>{}),Oo.set(t,r),t}function _m(r){if(co.has(r))return;const t=new Promise((e,n)=>{const i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",a),r.removeEventListener("abort",a)},s=()=>{e(),i()},a=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",a),r.addEventListener("abort",a)});co.set(r,t)}let lo={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return co.get(r);if(t==="objectStoreNames")return r.objectStoreNames||yl.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Ie(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function ym(r){lo=r(lo)}function Im(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){const n=r.call(to(this),t,...e);return yl.set(n,t.sort?t.sort():[t]),Ie(n)}:gm().includes(r)?function(...t){return r.apply(to(this),t),Ie(_l.get(this))}:function(...t){return Ie(r.apply(to(this),t))}}function Em(r){return typeof r=="function"?Im(r):(r instanceof IDBTransaction&&_m(r),fm(r,mm())?new Proxy(r,lo):r)}function Ie(r){if(r instanceof IDBRequest)return pm(r);if(Zs.has(r))return Zs.get(r);const t=Em(r);return t!==r&&(Zs.set(r,t),Oo.set(t,r)),t}const to=r=>Oo.get(r);function Tm(r,t,{blocked:e,upgrade:n,blocking:i,terminated:s}={}){const a=indexedDB.open(r,t),u=Ie(a);return n&&a.addEventListener("upgradeneeded",c=>{n(Ie(a.result),c.oldVersion,c.newVersion,Ie(a.transaction),c)}),e&&a.addEventListener("blocked",c=>e(c.oldVersion,c.newVersion,c)),u.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",h=>i(h.oldVersion,h.newVersion,h))}).catch(()=>{}),u}const vm=["get","getKey","getAll","getAllKeys","count"],wm=["put","add","delete","clear"],eo=new Map;function zu(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(eo.get(t))return eo.get(t);const e=t.replace(/FromIndex$/,""),n=t!==e,i=wm.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(i||vm.includes(e)))return;const s=async function(a,...u){const c=this.transaction(a,i?"readwrite":"readonly");let h=c.store;return n&&(h=h.index(u.shift())),(await Promise.all([h[e](...u),i&&c.done]))[0]};return eo.set(t,s),s}ym(r=>({...r,get:(t,e,n)=>zu(t,e)||r.get(t,e,n),has:(t,e)=>!!zu(t,e)||r.has(t,e)}));/**
|
|
197
|
-
* @license
|
|
198
|
-
* Copyright 2019 Google LLC
|
|
199
|
-
*
|
|
200
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
201
|
-
* you may not use this file except in compliance with the License.
|
|
202
|
-
* You may obtain a copy of the License at
|
|
203
|
-
*
|
|
204
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
205
|
-
*
|
|
206
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
207
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
208
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
209
|
-
* See the License for the specific language governing permissions and
|
|
210
|
-
* limitations under the License.
|
|
211
|
-
*/class Am{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(Rm(e)){const n=e.getImmediate();return`${n.library}/${n.version}`}else return null}).filter(e=>e).join(" ")}}function Rm(r){const t=r.getComponent();return(t==null?void 0:t.type)==="VERSION"}const $i="@firebase/app",ho="0.10.13";/**
|
|
212
|
-
* @license
|
|
213
|
-
* Copyright 2019 Google LLC
|
|
214
|
-
*
|
|
215
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
216
|
-
* you may not use this file except in compliance with the License.
|
|
217
|
-
* You may obtain a copy of the License at
|
|
218
|
-
*
|
|
219
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
220
|
-
*
|
|
221
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
222
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
223
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
224
|
-
* See the License for the specific language governing permissions and
|
|
225
|
-
* limitations under the License.
|
|
226
|
-
*/const ee=new pl("@firebase/app"),bm="@firebase/app-compat",Pm="@firebase/analytics-compat",Sm="@firebase/analytics",Vm="@firebase/app-check-compat",Cm="@firebase/app-check",Dm="@firebase/auth",xm="@firebase/auth-compat",Nm="@firebase/database",km="@firebase/data-connect",Fm="@firebase/database-compat",Mm="@firebase/functions",Om="@firebase/functions-compat",Lm="@firebase/installations",Bm="@firebase/installations-compat",Um="@firebase/messaging",qm="@firebase/messaging-compat",zm="@firebase/performance",jm="@firebase/performance-compat",Gm="@firebase/remote-config",Km="@firebase/remote-config-compat",$m="@firebase/storage",Qm="@firebase/storage-compat",Wm="@firebase/firestore",Hm="@firebase/vertexai-preview",Jm="@firebase/firestore-compat",Ym="firebase",Xm="10.14.1";/**
|
|
227
|
-
* @license
|
|
228
|
-
* Copyright 2019 Google LLC
|
|
229
|
-
*
|
|
230
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
231
|
-
* you may not use this file except in compliance with the License.
|
|
232
|
-
* You may obtain a copy of the License at
|
|
233
|
-
*
|
|
234
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
235
|
-
*
|
|
236
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
237
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
238
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
239
|
-
* See the License for the specific language governing permissions and
|
|
240
|
-
* limitations under the License.
|
|
241
|
-
*/const kr="[DEFAULT]",Zm={[$i]:"fire-core",[bm]:"fire-core-compat",[Sm]:"fire-analytics",[Pm]:"fire-analytics-compat",[Cm]:"fire-app-check",[Vm]:"fire-app-check-compat",[Dm]:"fire-auth",[xm]:"fire-auth-compat",[Nm]:"fire-rtdb",[km]:"fire-data-connect",[Fm]:"fire-rtdb-compat",[Mm]:"fire-fn",[Om]:"fire-fn-compat",[Lm]:"fire-iid",[Bm]:"fire-iid-compat",[Um]:"fire-fcm",[qm]:"fire-fcm-compat",[zm]:"fire-perf",[jm]:"fire-perf-compat",[Gm]:"fire-rc",[Km]:"fire-rc-compat",[$m]:"fire-gcs",[Qm]:"fire-gcs-compat",[Wm]:"fire-fst",[Jm]:"fire-fst-compat",[Hm]:"fire-vertex","fire-js":"fire-js",[Ym]:"fire-js-all"};/**
|
|
242
|
-
* @license
|
|
243
|
-
* Copyright 2019 Google LLC
|
|
244
|
-
*
|
|
245
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
246
|
-
* you may not use this file except in compliance with the License.
|
|
247
|
-
* You may obtain a copy of the License at
|
|
248
|
-
*
|
|
249
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
250
|
-
*
|
|
251
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
252
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
253
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
254
|
-
* See the License for the specific language governing permissions and
|
|
255
|
-
* limitations under the License.
|
|
256
|
-
*/const Ee=new Map,Pn=new Map,Sn=new Map;function fo(r,t){try{r.container.addComponent(t)}catch(e){ee.debug(`Component ${t.name} failed to register with FirebaseApp ${r.name}`,e)}}function tg(r,t){r.container.addOrOverwriteComponent(t)}function Fr(r){const t=r.name;if(Sn.has(t))return ee.debug(`There were multiple attempts to register component ${t}.`),!1;Sn.set(t,r);for(const e of Ee.values())fo(e,r);for(const e of Pn.values())fo(e,r);return!0}function os(r,t){const e=r.container.getProvider("heartbeat").getImmediate({optional:!0});return e&&e.triggerHeartbeat(),r.container.getProvider(t)}function Il(r,t,e=kr){os(r,t).clearInstance(e)}function El(r){return r.options!==void 0}function eg(r){return r.settings!==void 0}function ng(){Sn.clear()}/**
|
|
257
|
-
* @license
|
|
258
|
-
* Copyright 2019 Google LLC
|
|
259
|
-
*
|
|
260
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
261
|
-
* you may not use this file except in compliance with the License.
|
|
262
|
-
* You may obtain a copy of the License at
|
|
263
|
-
*
|
|
264
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
265
|
-
*
|
|
266
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
267
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
268
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
269
|
-
* See the License for the specific language governing permissions and
|
|
270
|
-
* limitations under the License.
|
|
271
|
-
*/const rg={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},jt=new fl("app","Firebase",rg);/**
|
|
272
|
-
* @license
|
|
273
|
-
* Copyright 2019 Google LLC
|
|
274
|
-
*
|
|
275
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
276
|
-
* you may not use this file except in compliance with the License.
|
|
277
|
-
* You may obtain a copy of the License at
|
|
278
|
-
*
|
|
279
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
280
|
-
*
|
|
281
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
282
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
283
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
284
|
-
* See the License for the specific language governing permissions and
|
|
285
|
-
* limitations under the License.
|
|
286
|
-
*/class Tl{constructor(t,e,n){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new bn("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw jt.create("app-deleted",{appName:this._name})}}/**
|
|
287
|
-
* @license
|
|
288
|
-
* Copyright 2023 Google LLC
|
|
289
|
-
*
|
|
290
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
291
|
-
* you may not use this file except in compliance with the License.
|
|
292
|
-
* You may obtain a copy of the License at
|
|
293
|
-
*
|
|
294
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
295
|
-
*
|
|
296
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
297
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
298
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
299
|
-
* See the License for the specific language governing permissions and
|
|
300
|
-
* limitations under the License.
|
|
301
|
-
*/class ig extends Tl{constructor(t,e,n,i){const s=e.automaticDataCollectionEnabled!==void 0?e.automaticDataCollectionEnabled:!1,a={name:n,automaticDataCollectionEnabled:s};if(t.apiKey!==void 0)super(t,a,i);else{const u=t;super(u.options,a,i)}this._serverConfig=Object.assign({automaticDataCollectionEnabled:s},e),this._finalizationRegistry=null,typeof FinalizationRegistry<"u"&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=void 0,e.releaseOnDeref=void 0,We($i,ho,"serverapp")}toJSON(){}get refCount(){return this._refCount}incRefCount(t){this.isDeleted||(this._refCount++,t!==void 0&&this._finalizationRegistry!==null&&this._finalizationRegistry.register(t,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){Rl(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw jt.create("server-app-deleted")}}/**
|
|
302
|
-
* @license
|
|
303
|
-
* Copyright 2019 Google LLC
|
|
304
|
-
*
|
|
305
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
306
|
-
* you may not use this file except in compliance with the License.
|
|
307
|
-
* You may obtain a copy of the License at
|
|
308
|
-
*
|
|
309
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
310
|
-
*
|
|
311
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
312
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
313
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
314
|
-
* See the License for the specific language governing permissions and
|
|
315
|
-
* limitations under the License.
|
|
316
|
-
*/const vl=Xm;function wl(r,t={}){let e=r;typeof t!="object"&&(t={name:t});const n=Object.assign({name:kr,automaticDataCollectionEnabled:!1},t),i=n.name;if(typeof i!="string"||!i)throw jt.create("bad-app-name",{appName:String(i)});if(e||(e=ul()),!e)throw jt.create("no-options");const s=Ee.get(i);if(s){if(Ye(e,s.options)&&Ye(n,s.config))return s;throw jt.create("duplicate-app",{appName:i})}const a=new ml(i);for(const c of Sn.values())a.addComponent(c);const u=new Tl(e,n,a);return Ee.set(i,u),u}function sg(r,t){if(tm()&&!ll())throw jt.create("invalid-server-app-environment");t.automaticDataCollectionEnabled===void 0&&(t.automaticDataCollectionEnabled=!1);let e;El(r)?e=r.options:e=r;const n=Object.assign(Object.assign({},t),e);n.releaseOnDeref!==void 0&&delete n.releaseOnDeref;const i=h=>[...h].reduce((f,g)=>Math.imul(31,f)+g.charCodeAt(0)|0,0);if(t.releaseOnDeref!==void 0&&typeof FinalizationRegistry>"u")throw jt.create("finalization-registry-not-supported",{});const s=""+i(JSON.stringify(n)),a=Pn.get(s);if(a)return a.incRefCount(t.releaseOnDeref),a;const u=new ml(s);for(const h of Sn.values())u.addComponent(h);const c=new ig(e,t,s,u);return Pn.set(s,c),c}function Al(r=kr){const t=Ee.get(r);if(!t&&r===kr&&ul())return wl();if(!t)throw jt.create("no-app",{appName:r});return t}function og(){return Array.from(Ee.values())}async function Rl(r){let t=!1;const e=r.name;Ee.has(e)?(t=!0,Ee.delete(e)):Pn.has(e)&&r.decRefCount()<=0&&(Pn.delete(e),t=!0),t&&(await Promise.all(r.container.getProviders().map(n=>n.delete())),r.isDeleted=!0)}function We(r,t,e){var n;let i=(n=Zm[r])!==null&&n!==void 0?n:r;e&&(i+=`-${e}`);const s=i.match(/\s|\//),a=t.match(/\s|\//);if(s||a){const u=[`Unable to register library "${i}" with version "${t}":`];s&&u.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&a&&u.push("and"),a&&u.push(`version name "${t}" contains illegal characters (whitespace or "/")`),ee.warn(u.join(" "));return}Fr(new bn(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}function ag(r,t){if(r!==null&&typeof r!="function")throw jt.create("invalid-log-argument");dm(r,t)}function ug(r){hm(r)}/**
|
|
317
|
-
* @license
|
|
318
|
-
* Copyright 2021 Google LLC
|
|
319
|
-
*
|
|
320
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
321
|
-
* you may not use this file except in compliance with the License.
|
|
322
|
-
* You may obtain a copy of the License at
|
|
323
|
-
*
|
|
324
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
325
|
-
*
|
|
326
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
327
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
328
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
329
|
-
* See the License for the specific language governing permissions and
|
|
330
|
-
* limitations under the License.
|
|
331
|
-
*/const cg="firebase-heartbeat-database",lg=1,Mr="firebase-heartbeat-store";let no=null;function bl(){return no||(no=Tm(cg,lg,{upgrade:(r,t)=>{switch(t){case 0:try{r.createObjectStore(Mr)}catch(e){console.warn(e)}}}}).catch(r=>{throw jt.create("idb-open",{originalErrorMessage:r.message})})),no}async function hg(r){try{const e=(await bl()).transaction(Mr),n=await e.objectStore(Mr).get(Pl(r));return await e.done,n}catch(t){if(t instanceof un)ee.warn(t.message);else{const e=jt.create("idb-get",{originalErrorMessage:t==null?void 0:t.message});ee.warn(e.message)}}}async function ju(r,t){try{const n=(await bl()).transaction(Mr,"readwrite");await n.objectStore(Mr).put(t,Pl(r)),await n.done}catch(e){if(e instanceof un)ee.warn(e.message);else{const n=jt.create("idb-set",{originalErrorMessage:e==null?void 0:e.message});ee.warn(n.message)}}}function Pl(r){return`${r.name}!${r.options.appId}`}/**
|
|
332
|
-
* @license
|
|
333
|
-
* Copyright 2021 Google LLC
|
|
334
|
-
*
|
|
335
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
336
|
-
* you may not use this file except in compliance with the License.
|
|
337
|
-
* You may obtain a copy of the License at
|
|
338
|
-
*
|
|
339
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
340
|
-
*
|
|
341
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
342
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
343
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
344
|
-
* See the License for the specific language governing permissions and
|
|
345
|
-
* limitations under the License.
|
|
346
|
-
*/const dg=1024,fg=30*24*60*60*1e3;class mg{constructor(t){this.container=t,this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new pg(e),this._heartbeatsCachePromise=this._storage.read().then(n=>(this._heartbeatsCache=n,n))}async triggerHeartbeat(){var t,e;try{const i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=Gu();return((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===s||this._heartbeatsCache.heartbeats.some(a=>a.date===s)?void 0:(this._heartbeatsCache.heartbeats.push({date:s,agent:i}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(a=>{const u=new Date(a.date).valueOf();return Date.now()-u<=fg}),this._storage.overwrite(this._heartbeatsCache))}catch(n){ee.warn(n)}}async getHeartbeatsHeader(){var t;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=Gu(),{heartbeatsToSend:n,unsentEntries:i}=gg(this._heartbeatsCache.heartbeats),s=Gi(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=e,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(e){return ee.warn(e),""}}}function Gu(){return new Date().toISOString().substring(0,10)}function gg(r,t=dg){const e=[];let n=r.slice();for(const i of r){const s=e.find(a=>a.agent===i.agent);if(s){if(s.dates.push(i.date),Ku(e)>t){s.dates.pop();break}}else if(e.push({agent:i.agent,dates:[i.date]}),Ku(e)>t){e.pop();break}n=n.slice(1)}return{heartbeatsToSend:e,unsentEntries:n}}class pg{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return dl()?em().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const e=await hg(this.app);return e!=null&&e.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(t){var e;if(await this._canUseIndexedDBPromise){const i=await this.read();return ju(this.app,{lastSentHeartbeatDate:(e=t.lastSentHeartbeatDate)!==null&&e!==void 0?e:i.lastSentHeartbeatDate,heartbeats:t.heartbeats})}else return}async add(t){var e;if(await this._canUseIndexedDBPromise){const i=await this.read();return ju(this.app,{lastSentHeartbeatDate:(e=t.lastSentHeartbeatDate)!==null&&e!==void 0?e:i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...t.heartbeats]})}else return}}function Ku(r){return Gi(JSON.stringify({version:2,heartbeats:r})).length}/**
|
|
347
|
-
* @license
|
|
348
|
-
* Copyright 2019 Google LLC
|
|
349
|
-
*
|
|
350
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
351
|
-
* you may not use this file except in compliance with the License.
|
|
352
|
-
* You may obtain a copy of the License at
|
|
353
|
-
*
|
|
354
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
355
|
-
*
|
|
356
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
357
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
358
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
359
|
-
* See the License for the specific language governing permissions and
|
|
360
|
-
* limitations under the License.
|
|
361
|
-
*/function _g(r){Fr(new bn("platform-logger",t=>new Am(t),"PRIVATE")),Fr(new bn("heartbeat",t=>new mg(t),"PRIVATE")),We($i,ho,r),We($i,ho,"esm2017"),We("fire-js","")}_g("");var $u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
|
|
362
|
-
Copyright The Closure Library Authors.
|
|
363
|
-
SPDX-License-Identifier: Apache-2.0
|
|
364
|
-
*/var He,Sl;(function(){var r;/** @license
|
|
365
|
-
|
|
366
|
-
Copyright The Closure Library Authors.
|
|
367
|
-
SPDX-License-Identifier: Apache-2.0
|
|
368
|
-
*/function t(E,p){function I(){}I.prototype=p.prototype,E.D=p.prototype,E.prototype=new I,E.prototype.constructor=E,E.C=function(T,v,b){for(var y=Array(arguments.length-2),Yt=2;Yt<arguments.length;Yt++)y[Yt-2]=arguments[Yt];return p.prototype[v].apply(T,y)}}function e(){this.blockSize=-1}function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}t(n,e),n.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(E,p,I){I||(I=0);var T=Array(16);if(typeof p=="string")for(var v=0;16>v;++v)T[v]=p.charCodeAt(I++)|p.charCodeAt(I++)<<8|p.charCodeAt(I++)<<16|p.charCodeAt(I++)<<24;else for(v=0;16>v;++v)T[v]=p[I++]|p[I++]<<8|p[I++]<<16|p[I++]<<24;p=E.g[0],I=E.g[1],v=E.g[2];var b=E.g[3],y=p+(b^I&(v^b))+T[0]+3614090360&4294967295;p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[1]+3905402710&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[2]+606105819&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[3]+3250441966&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[4]+4118548399&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[5]+1200080426&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[6]+2821735955&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[7]+4249261313&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[8]+1770035416&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[9]+2336552879&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[10]+4294925233&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[11]+2304563134&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(b^I&(v^b))+T[12]+1804603682&4294967295,p=I+(y<<7&4294967295|y>>>25),y=b+(v^p&(I^v))+T[13]+4254626195&4294967295,b=p+(y<<12&4294967295|y>>>20),y=v+(I^b&(p^I))+T[14]+2792965006&4294967295,v=b+(y<<17&4294967295|y>>>15),y=I+(p^v&(b^p))+T[15]+1236535329&4294967295,I=v+(y<<22&4294967295|y>>>10),y=p+(v^b&(I^v))+T[1]+4129170786&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[6]+3225465664&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[11]+643717713&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[0]+3921069994&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[5]+3593408605&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[10]+38016083&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[15]+3634488961&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[4]+3889429448&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[9]+568446438&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[14]+3275163606&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[3]+4107603335&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[8]+1163531501&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(v^b&(I^v))+T[13]+2850285829&4294967295,p=I+(y<<5&4294967295|y>>>27),y=b+(I^v&(p^I))+T[2]+4243563512&4294967295,b=p+(y<<9&4294967295|y>>>23),y=v+(p^I&(b^p))+T[7]+1735328473&4294967295,v=b+(y<<14&4294967295|y>>>18),y=I+(b^p&(v^b))+T[12]+2368359562&4294967295,I=v+(y<<20&4294967295|y>>>12),y=p+(I^v^b)+T[5]+4294588738&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[8]+2272392833&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[11]+1839030562&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[14]+4259657740&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[1]+2763975236&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[4]+1272893353&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[7]+4139469664&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[10]+3200236656&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[13]+681279174&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[0]+3936430074&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[3]+3572445317&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[6]+76029189&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(I^v^b)+T[9]+3654602809&4294967295,p=I+(y<<4&4294967295|y>>>28),y=b+(p^I^v)+T[12]+3873151461&4294967295,b=p+(y<<11&4294967295|y>>>21),y=v+(b^p^I)+T[15]+530742520&4294967295,v=b+(y<<16&4294967295|y>>>16),y=I+(v^b^p)+T[2]+3299628645&4294967295,I=v+(y<<23&4294967295|y>>>9),y=p+(v^(I|~b))+T[0]+4096336452&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[7]+1126891415&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[14]+2878612391&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[5]+4237533241&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[12]+1700485571&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[3]+2399980690&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[10]+4293915773&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[1]+2240044497&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[8]+1873313359&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[15]+4264355552&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[6]+2734768916&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[13]+1309151649&4294967295,I=v+(y<<21&4294967295|y>>>11),y=p+(v^(I|~b))+T[4]+4149444226&4294967295,p=I+(y<<6&4294967295|y>>>26),y=b+(I^(p|~v))+T[11]+3174756917&4294967295,b=p+(y<<10&4294967295|y>>>22),y=v+(p^(b|~I))+T[2]+718787259&4294967295,v=b+(y<<15&4294967295|y>>>17),y=I+(b^(v|~p))+T[9]+3951481745&4294967295,E.g[0]=E.g[0]+p&4294967295,E.g[1]=E.g[1]+(v+(y<<21&4294967295|y>>>11))&4294967295,E.g[2]=E.g[2]+v&4294967295,E.g[3]=E.g[3]+b&4294967295}n.prototype.u=function(E,p){p===void 0&&(p=E.length);for(var I=p-this.blockSize,T=this.B,v=this.h,b=0;b<p;){if(v==0)for(;b<=I;)i(this,E,b),b+=this.blockSize;if(typeof E=="string"){for(;b<p;)if(T[v++]=E.charCodeAt(b++),v==this.blockSize){i(this,T),v=0;break}}else for(;b<p;)if(T[v++]=E[b++],v==this.blockSize){i(this,T),v=0;break}}this.h=v,this.o+=p},n.prototype.v=function(){var E=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);E[0]=128;for(var p=1;p<E.length-8;++p)E[p]=0;var I=8*this.o;for(p=E.length-8;p<E.length;++p)E[p]=I&255,I/=256;for(this.u(E),E=Array(16),p=I=0;4>p;++p)for(var T=0;32>T;T+=8)E[I++]=this.g[p]>>>T&255;return E};function s(E,p){var I=u;return Object.prototype.hasOwnProperty.call(I,E)?I[E]:I[E]=p(E)}function a(E,p){this.h=p;for(var I=[],T=!0,v=E.length-1;0<=v;v--){var b=E[v]|0;T&&b==p||(I[v]=b,T=!1)}this.g=I}var u={};function c(E){return-128<=E&&128>E?s(E,function(p){return new a([p|0],0>p?-1:0)}):new a([E|0],0>E?-1:0)}function h(E){if(isNaN(E)||!isFinite(E))return g;if(0>E)return V(h(-E));for(var p=[],I=1,T=0;E>=I;T++)p[T]=E/I|0,I*=4294967296;return new a(p,0)}function f(E,p){if(E.length==0)throw Error("number format error: empty string");if(p=p||10,2>p||36<p)throw Error("radix out of range: "+p);if(E.charAt(0)=="-")return V(f(E.substring(1),p));if(0<=E.indexOf("-"))throw Error('number format error: interior "-" character');for(var I=h(Math.pow(p,8)),T=g,v=0;v<E.length;v+=8){var b=Math.min(8,E.length-v),y=parseInt(E.substring(v,v+b),p);8>b?(b=h(Math.pow(p,b)),T=T.j(b).add(h(y))):(T=T.j(I),T=T.add(h(y)))}return T}var g=c(0),_=c(1),R=c(16777216);r=a.prototype,r.m=function(){if(N(this))return-V(this).m();for(var E=0,p=1,I=0;I<this.g.length;I++){var T=this.i(I);E+=(0<=T?T:4294967296+T)*p,p*=4294967296}return E},r.toString=function(E){if(E=E||10,2>E||36<E)throw Error("radix out of range: "+E);if(C(this))return"0";if(N(this))return"-"+V(this).toString(E);for(var p=h(Math.pow(E,6)),I=this,T="";;){var v=$(I,p).g;I=q(I,v.j(p));var b=((0<I.g.length?I.g[0]:I.h)>>>0).toString(E);if(I=v,C(I))return b+T;for(;6>b.length;)b="0"+b;T=b+T}},r.i=function(E){return 0>E?0:E<this.g.length?this.g[E]:this.h};function C(E){if(E.h!=0)return!1;for(var p=0;p<E.g.length;p++)if(E.g[p]!=0)return!1;return!0}function N(E){return E.h==-1}r.l=function(E){return E=q(this,E),N(E)?-1:C(E)?0:1};function V(E){for(var p=E.g.length,I=[],T=0;T<p;T++)I[T]=~E.g[T];return new a(I,~E.h).add(_)}r.abs=function(){return N(this)?V(this):this},r.add=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0,v=0;v<=p;v++){var b=T+(this.i(v)&65535)+(E.i(v)&65535),y=(b>>>16)+(this.i(v)>>>16)+(E.i(v)>>>16);T=y>>>16,b&=65535,y&=65535,I[v]=y<<16|b}return new a(I,I[I.length-1]&-2147483648?-1:0)};function q(E,p){return E.add(V(p))}r.j=function(E){if(C(this)||C(E))return g;if(N(this))return N(E)?V(this).j(V(E)):V(V(this).j(E));if(N(E))return V(this.j(V(E)));if(0>this.l(R)&&0>E.l(R))return h(this.m()*E.m());for(var p=this.g.length+E.g.length,I=[],T=0;T<2*p;T++)I[T]=0;for(T=0;T<this.g.length;T++)for(var v=0;v<E.g.length;v++){var b=this.i(T)>>>16,y=this.i(T)&65535,Yt=E.i(v)>>>16,nr=E.i(v)&65535;I[2*T+2*v]+=y*nr,z(I,2*T+2*v),I[2*T+2*v+1]+=b*nr,z(I,2*T+2*v+1),I[2*T+2*v+1]+=y*Yt,z(I,2*T+2*v+1),I[2*T+2*v+2]+=b*Yt,z(I,2*T+2*v+2)}for(T=0;T<p;T++)I[T]=I[2*T+1]<<16|I[2*T];for(T=p;T<2*p;T++)I[T]=0;return new a(I,0)};function z(E,p){for(;(E[p]&65535)!=E[p];)E[p+1]+=E[p]>>>16,E[p]&=65535,p++}function B(E,p){this.g=E,this.h=p}function $(E,p){if(C(p))throw Error("division by zero");if(C(E))return new B(g,g);if(N(E))return p=$(V(E),p),new B(V(p.g),V(p.h));if(N(p))return p=$(E,V(p)),new B(V(p.g),p.h);if(30<E.g.length){if(N(E)||N(p))throw Error("slowDivide_ only works with positive integers.");for(var I=_,T=p;0>=T.l(E);)I=Z(I),T=Z(T);var v=K(I,1),b=K(T,1);for(T=K(T,2),I=K(I,2);!C(T);){var y=b.add(T);0>=y.l(E)&&(v=v.add(I),b=y),T=K(T,1),I=K(I,1)}return p=q(E,v.j(p)),new B(v,p)}for(v=g;0<=E.l(p);){for(I=Math.max(1,Math.floor(E.m()/p.m())),T=Math.ceil(Math.log(I)/Math.LN2),T=48>=T?1:Math.pow(2,T-48),b=h(I),y=b.j(p);N(y)||0<y.l(E);)I-=T,b=h(I),y=b.j(p);C(b)&&(b=_),v=v.add(b),E=q(E,y)}return new B(v,E)}r.A=function(E){return $(this,E).h},r.and=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)&E.i(T);return new a(I,this.h&E.h)},r.or=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)|E.i(T);return new a(I,this.h|E.h)},r.xor=function(E){for(var p=Math.max(this.g.length,E.g.length),I=[],T=0;T<p;T++)I[T]=this.i(T)^E.i(T);return new a(I,this.h^E.h)};function Z(E){for(var p=E.g.length+1,I=[],T=0;T<p;T++)I[T]=E.i(T)<<1|E.i(T-1)>>>31;return new a(I,E.h)}function K(E,p){var I=p>>5;p%=32;for(var T=E.g.length-I,v=[],b=0;b<T;b++)v[b]=0<p?E.i(b+I)>>>p|E.i(b+I+1)<<32-p:E.i(b+I);return new a(v,E.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,Sl=n,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=h,a.fromString=f,He=a}).apply(typeof $u<"u"?$u:typeof self<"u"?self:typeof window<"u"?window:{});var Vi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
|
|
369
|
-
Copyright The Closure Library Authors.
|
|
370
|
-
SPDX-License-Identifier: Apache-2.0
|
|
371
|
-
*/var Vl,Ar,Cl,Mi,mo,Dl,xl,Nl;(function(){var r,t=typeof Object.defineProperties=="function"?Object.defineProperty:function(o,l,d){return o==Array.prototype||o==Object.prototype||(o[l]=d.value),o};function e(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof Vi=="object"&&Vi];for(var l=0;l<o.length;++l){var d=o[l];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var n=e(this);function i(o,l){if(l)t:{var d=n;o=o.split(".");for(var m=0;m<o.length-1;m++){var A=o[m];if(!(A in d))break t;d=d[A]}o=o[o.length-1],m=d[o],l=l(m),l!=m&&l!=null&&t(d,o,{configurable:!0,writable:!0,value:l})}}function s(o,l){o instanceof String&&(o+="");var d=0,m=!1,A={next:function(){if(!m&&d<o.length){var S=d++;return{value:l(S,o[S]),done:!1}}return m=!0,{done:!0,value:void 0}}};return A[Symbol.iterator]=function(){return A},A}i("Array.prototype.values",function(o){return o||function(){return s(this,function(l,d){return d})}});/** @license
|
|
372
|
-
|
|
373
|
-
Copyright The Closure Library Authors.
|
|
374
|
-
SPDX-License-Identifier: Apache-2.0
|
|
375
|
-
*/var a=a||{},u=this||self;function c(o){var l=typeof o;return l=l!="object"?l:o?Array.isArray(o)?"array":l:"null",l=="array"||l=="object"&&typeof o.length=="number"}function h(o){var l=typeof o;return l=="object"&&o!=null||l=="function"}function f(o,l,d){return o.call.apply(o.bind,arguments)}function g(o,l,d){if(!o)throw Error();if(2<arguments.length){var m=Array.prototype.slice.call(arguments,2);return function(){var A=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(A,m),o.apply(l,A)}}return function(){return o.apply(l,arguments)}}function _(o,l,d){return _=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?f:g,_.apply(null,arguments)}function R(o,l){var d=Array.prototype.slice.call(arguments,1);return function(){var m=d.slice();return m.push.apply(m,arguments),o.apply(this,m)}}function C(o,l){function d(){}d.prototype=l.prototype,o.aa=l.prototype,o.prototype=new d,o.prototype.constructor=o,o.Qb=function(m,A,S){for(var F=Array(arguments.length-2),rt=2;rt<arguments.length;rt++)F[rt-2]=arguments[rt];return l.prototype[A].apply(m,F)}}function N(o){const l=o.length;if(0<l){const d=Array(l);for(let m=0;m<l;m++)d[m]=o[m];return d}return[]}function V(o,l){for(let d=1;d<arguments.length;d++){const m=arguments[d];if(c(m)){const A=o.length||0,S=m.length||0;o.length=A+S;for(let F=0;F<S;F++)o[A+F]=m[F]}else o.push(m)}}class q{constructor(l,d){this.i=l,this.j=d,this.h=0,this.g=null}get(){let l;return 0<this.h?(this.h--,l=this.g,this.g=l.next,l.next=null):l=this.i(),l}}function z(o){return/^[\s\xa0]*$/.test(o)}function B(){var o=u.navigator;return o&&(o=o.userAgent)?o:""}function $(o){return $[" "](o),o}$[" "]=function(){};var Z=B().indexOf("Gecko")!=-1&&!(B().toLowerCase().indexOf("webkit")!=-1&&B().indexOf("Edge")==-1)&&!(B().indexOf("Trident")!=-1||B().indexOf("MSIE")!=-1)&&B().indexOf("Edge")==-1;function K(o,l,d){for(const m in o)l.call(d,o[m],m,o)}function E(o,l){for(const d in o)l.call(void 0,o[d],d,o)}function p(o){const l={};for(const d in o)l[d]=o[d];return l}const I="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(o,l){let d,m;for(let A=1;A<arguments.length;A++){m=arguments[A];for(d in m)o[d]=m[d];for(let S=0;S<I.length;S++)d=I[S],Object.prototype.hasOwnProperty.call(m,d)&&(o[d]=m[d])}}function v(o){var l=1;o=o.split(":");const d=[];for(;0<l&&o.length;)d.push(o.shift()),l--;return o.length&&d.push(o.join(":")),d}function b(o){u.setTimeout(()=>{throw o},0)}function y(){var o=Vs;let l=null;return o.g&&(l=o.g,o.g=o.g.next,o.g||(o.h=null),l.next=null),l}class Yt{constructor(){this.h=this.g=null}add(l,d){const m=nr.get();m.set(l,d),this.h?this.h.next=m:this.g=m,this.h=m}}var nr=new q(()=>new uf,o=>o.reset());class uf{constructor(){this.next=this.g=this.h=null}set(l,d){this.h=l,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let rr,ir=!1,Vs=new Yt,Ba=()=>{const o=u.Promise.resolve(void 0);rr=()=>{o.then(cf)}};var cf=()=>{for(var o;o=y();){try{o.h.call(o.g)}catch(d){b(d)}var l=nr;l.j(o),100>l.h&&(l.h++,o.next=l.g,l.g=o)}ir=!1};function ue(){this.s=this.s,this.C=this.C}ue.prototype.s=!1,ue.prototype.ma=function(){this.s||(this.s=!0,this.N())},ue.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Pt(o,l){this.type=o,this.g=this.target=l,this.defaultPrevented=!1}Pt.prototype.h=function(){this.defaultPrevented=!0};var lf=function(){if(!u.addEventListener||!Object.defineProperty)return!1;var o=!1,l=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const d=()=>{};u.addEventListener("test",d,l),u.removeEventListener("test",d,l)}catch{}return o}();function sr(o,l){if(Pt.call(this,o?o.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,o){var d=this.type=o.type,m=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;if(this.target=o.target||o.srcElement,this.g=l,l=o.relatedTarget){if(Z){t:{try{$(l.nodeName);var A=!0;break t}catch{}A=!1}A||(l=null)}}else d=="mouseover"?l=o.fromElement:d=="mouseout"&&(l=o.toElement);this.relatedTarget=l,m?(this.clientX=m.clientX!==void 0?m.clientX:m.pageX,this.clientY=m.clientY!==void 0?m.clientY:m.pageY,this.screenX=m.screenX||0,this.screenY=m.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=typeof o.pointerType=="string"?o.pointerType:hf[o.pointerType]||"",this.state=o.state,this.i=o,o.defaultPrevented&&sr.aa.h.call(this)}}C(sr,Pt);var hf={2:"touch",3:"pen",4:"mouse"};sr.prototype.h=function(){sr.aa.h.call(this);var o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var li="closure_listenable_"+(1e6*Math.random()|0),df=0;function ff(o,l,d,m,A){this.listener=o,this.proxy=null,this.src=l,this.type=d,this.capture=!!m,this.ha=A,this.key=++df,this.da=this.fa=!1}function hi(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function di(o){this.src=o,this.g={},this.h=0}di.prototype.add=function(o,l,d,m,A){var S=o.toString();o=this.g[S],o||(o=this.g[S]=[],this.h++);var F=Ds(o,l,m,A);return-1<F?(l=o[F],d||(l.fa=!1)):(l=new ff(l,this.src,S,!!m,A),l.fa=d,o.push(l)),l};function Cs(o,l){var d=l.type;if(d in o.g){var m=o.g[d],A=Array.prototype.indexOf.call(m,l,void 0),S;(S=0<=A)&&Array.prototype.splice.call(m,A,1),S&&(hi(l),o.g[d].length==0&&(delete o.g[d],o.h--))}}function Ds(o,l,d,m){for(var A=0;A<o.length;++A){var S=o[A];if(!S.da&&S.listener==l&&S.capture==!!d&&S.ha==m)return A}return-1}var xs="closure_lm_"+(1e6*Math.random()|0),Ns={};function Ua(o,l,d,m,A){if(Array.isArray(l)){for(var S=0;S<l.length;S++)Ua(o,l[S],d,m,A);return null}return d=ja(d),o&&o[li]?o.K(l,d,h(m)?!!m.capture:!!m,A):mf(o,l,d,!1,m,A)}function mf(o,l,d,m,A,S){if(!l)throw Error("Invalid event type");var F=h(A)?!!A.capture:!!A,rt=Fs(o);if(rt||(o[xs]=rt=new di(o)),d=rt.add(l,d,m,F,S),d.proxy)return d;if(m=gf(),d.proxy=m,m.src=o,m.listener=d,o.addEventListener)lf||(A=F),A===void 0&&(A=!1),o.addEventListener(l.toString(),m,A);else if(o.attachEvent)o.attachEvent(za(l.toString()),m);else if(o.addListener&&o.removeListener)o.addListener(m);else throw Error("addEventListener and attachEvent are unavailable.");return d}function gf(){function o(d){return l.call(o.src,o.listener,d)}const l=pf;return o}function qa(o,l,d,m,A){if(Array.isArray(l))for(var S=0;S<l.length;S++)qa(o,l[S],d,m,A);else m=h(m)?!!m.capture:!!m,d=ja(d),o&&o[li]?(o=o.i,l=String(l).toString(),l in o.g&&(S=o.g[l],d=Ds(S,d,m,A),-1<d&&(hi(S[d]),Array.prototype.splice.call(S,d,1),S.length==0&&(delete o.g[l],o.h--)))):o&&(o=Fs(o))&&(l=o.g[l.toString()],o=-1,l&&(o=Ds(l,d,m,A)),(d=-1<o?l[o]:null)&&ks(d))}function ks(o){if(typeof o!="number"&&o&&!o.da){var l=o.src;if(l&&l[li])Cs(l.i,o);else{var d=o.type,m=o.proxy;l.removeEventListener?l.removeEventListener(d,m,o.capture):l.detachEvent?l.detachEvent(za(d),m):l.addListener&&l.removeListener&&l.removeListener(m),(d=Fs(l))?(Cs(d,o),d.h==0&&(d.src=null,l[xs]=null)):hi(o)}}}function za(o){return o in Ns?Ns[o]:Ns[o]="on"+o}function pf(o,l){if(o.da)o=!0;else{l=new sr(l,this);var d=o.listener,m=o.ha||o.src;o.fa&&ks(o),o=d.call(m,l)}return o}function Fs(o){return o=o[xs],o instanceof di?o:null}var Ms="__closure_events_fn_"+(1e9*Math.random()>>>0);function ja(o){return typeof o=="function"?o:(o[Ms]||(o[Ms]=function(l){return o.handleEvent(l)}),o[Ms])}function St(){ue.call(this),this.i=new di(this),this.M=this,this.F=null}C(St,ue),St.prototype[li]=!0,St.prototype.removeEventListener=function(o,l,d,m){qa(this,o,l,d,m)};function Ft(o,l){var d,m=o.F;if(m)for(d=[];m;m=m.F)d.push(m);if(o=o.M,m=l.type||l,typeof l=="string")l=new Pt(l,o);else if(l instanceof Pt)l.target=l.target||o;else{var A=l;l=new Pt(m,o),T(l,A)}if(A=!0,d)for(var S=d.length-1;0<=S;S--){var F=l.g=d[S];A=fi(F,m,!0,l)&&A}if(F=l.g=o,A=fi(F,m,!0,l)&&A,A=fi(F,m,!1,l)&&A,d)for(S=0;S<d.length;S++)F=l.g=d[S],A=fi(F,m,!1,l)&&A}St.prototype.N=function(){if(St.aa.N.call(this),this.i){var o=this.i,l;for(l in o.g){for(var d=o.g[l],m=0;m<d.length;m++)hi(d[m]);delete o.g[l],o.h--}}this.F=null},St.prototype.K=function(o,l,d,m){return this.i.add(String(o),l,!1,d,m)},St.prototype.L=function(o,l,d,m){return this.i.add(String(o),l,!0,d,m)};function fi(o,l,d,m){if(l=o.i.g[String(l)],!l)return!0;l=l.concat();for(var A=!0,S=0;S<l.length;++S){var F=l[S];if(F&&!F.da&&F.capture==d){var rt=F.listener,At=F.ha||F.src;F.fa&&Cs(o.i,F),A=rt.call(At,m)!==!1&&A}}return A&&!m.defaultPrevented}function Ga(o,l,d){if(typeof o=="function")d&&(o=_(o,d));else if(o&&typeof o.handleEvent=="function")o=_(o.handleEvent,o);else throw Error("Invalid listener argument");return 2147483647<Number(l)?-1:u.setTimeout(o,l||0)}function Ka(o){o.g=Ga(()=>{o.g=null,o.i&&(o.i=!1,Ka(o))},o.l);const l=o.h;o.h=null,o.m.apply(null,l)}class _f extends ue{constructor(l,d){super(),this.m=l,this.l=d,this.h=null,this.i=!1,this.g=null}j(l){this.h=arguments,this.g?this.i=!0:Ka(this)}N(){super.N(),this.g&&(u.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function or(o){ue.call(this),this.h=o,this.g={}}C(or,ue);var $a=[];function Qa(o){K(o.g,function(l,d){this.g.hasOwnProperty(d)&&ks(l)},o),o.g={}}or.prototype.N=function(){or.aa.N.call(this),Qa(this)},or.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Os=u.JSON.stringify,yf=u.JSON.parse,If=class{stringify(o){return u.JSON.stringify(o,void 0)}parse(o){return u.JSON.parse(o,void 0)}};function Ls(){}Ls.prototype.h=null;function Wa(o){return o.h||(o.h=o.i())}function Ha(){}var ar={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Bs(){Pt.call(this,"d")}C(Bs,Pt);function Us(){Pt.call(this,"c")}C(Us,Pt);var Oe={},Ja=null;function mi(){return Ja=Ja||new St}Oe.La="serverreachability";function Ya(o){Pt.call(this,Oe.La,o)}C(Ya,Pt);function ur(o){const l=mi();Ft(l,new Ya(l))}Oe.STAT_EVENT="statevent";function Xa(o,l){Pt.call(this,Oe.STAT_EVENT,o),this.stat=l}C(Xa,Pt);function Mt(o){const l=mi();Ft(l,new Xa(l,o))}Oe.Ma="timingevent";function Za(o,l){Pt.call(this,Oe.Ma,o),this.size=l}C(Za,Pt);function cr(o,l){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return u.setTimeout(function(){o()},l)}function lr(){this.g=!0}lr.prototype.xa=function(){this.g=!1};function Ef(o,l,d,m,A,S){o.info(function(){if(o.g)if(S)for(var F="",rt=S.split("&"),At=0;At<rt.length;At++){var X=rt[At].split("=");if(1<X.length){var Vt=X[0];X=X[1];var Ct=Vt.split("_");F=2<=Ct.length&&Ct[1]=="type"?F+(Vt+"="+X+"&"):F+(Vt+"=redacted&")}}else F=null;else F=S;return"XMLHTTP REQ ("+m+") [attempt "+A+"]: "+l+`
|
|
376
|
-
`+d+`
|
|
377
|
-
`+F})}function Tf(o,l,d,m,A,S,F){o.info(function(){return"XMLHTTP RESP ("+m+") [ attempt "+A+"]: "+l+`
|
|
378
|
-
`+d+`
|
|
379
|
-
`+S+" "+F})}function dn(o,l,d,m){o.info(function(){return"XMLHTTP TEXT ("+l+"): "+wf(o,d)+(m?" "+m:"")})}function vf(o,l){o.info(function(){return"TIMEOUT: "+l})}lr.prototype.info=function(){};function wf(o,l){if(!o.g)return l;if(!l)return null;try{var d=JSON.parse(l);if(d){for(o=0;o<d.length;o++)if(Array.isArray(d[o])){var m=d[o];if(!(2>m.length)){var A=m[1];if(Array.isArray(A)&&!(1>A.length)){var S=A[0];if(S!="noop"&&S!="stop"&&S!="close")for(var F=1;F<A.length;F++)A[F]=""}}}}return Os(d)}catch{return l}}var gi={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},tu={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},qs;function pi(){}C(pi,Ls),pi.prototype.g=function(){return new XMLHttpRequest},pi.prototype.i=function(){return{}},qs=new pi;function ce(o,l,d,m){this.j=o,this.i=l,this.l=d,this.R=m||1,this.U=new or(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new eu}function eu(){this.i=null,this.g="",this.h=!1}var nu={},zs={};function js(o,l,d){o.L=1,o.v=Ei(Xt(l)),o.m=d,o.P=!0,ru(o,null)}function ru(o,l){o.F=Date.now(),_i(o),o.A=Xt(o.v);var d=o.A,m=o.R;Array.isArray(m)||(m=[String(m)]),_u(d.i,"t",m),o.C=0,d=o.j.J,o.h=new eu,o.g=Fu(o.j,d?l:null,!o.m),0<o.O&&(o.M=new _f(_(o.Y,o,o.g),o.O)),l=o.U,d=o.g,m=o.ca;var A="readystatechange";Array.isArray(A)||(A&&($a[0]=A.toString()),A=$a);for(var S=0;S<A.length;S++){var F=Ua(d,A[S],m||l.handleEvent,!1,l.h||l);if(!F)break;l.g[F.key]=F}l=o.H?p(o.H):{},o.m?(o.u||(o.u="POST"),l["Content-Type"]="application/x-www-form-urlencoded",o.g.ea(o.A,o.u,o.m,l)):(o.u="GET",o.g.ea(o.A,o.u,null,l)),ur(),Ef(o.i,o.u,o.A,o.l,o.R,o.m)}ce.prototype.ca=function(o){o=o.target;const l=this.M;l&&Zt(o)==3?l.j():this.Y(o)},ce.prototype.Y=function(o){try{if(o==this.g)t:{const Ct=Zt(this.g);var l=this.g.Ba();const gn=this.g.Z();if(!(3>Ct)&&(Ct!=3||this.g&&(this.h.h||this.g.oa()||Au(this.g)))){this.J||Ct!=4||l==7||(l==8||0>=gn?ur(3):ur(2)),Gs(this);var d=this.g.Z();this.X=d;e:if(iu(this)){var m=Au(this.g);o="";var A=m.length,S=Zt(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Le(this),hr(this);var F="";break e}this.h.i=new u.TextDecoder}for(l=0;l<A;l++)this.h.h=!0,o+=this.h.i.decode(m[l],{stream:!(S&&l==A-1)});m.length=0,this.h.g+=o,this.C=0,F=this.h.g}else F=this.g.oa();if(this.o=d==200,Tf(this.i,this.u,this.A,this.l,this.R,Ct,d),this.o){if(this.T&&!this.K){e:{if(this.g){var rt,At=this.g;if((rt=At.g?At.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!z(rt)){var X=rt;break e}}X=null}if(d=X)dn(this.i,this.l,d,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Ks(this,d);else{this.o=!1,this.s=3,Mt(12),Le(this),hr(this);break t}}if(this.P){d=!0;let Gt;for(;!this.J&&this.C<F.length;)if(Gt=Af(this,F),Gt==zs){Ct==4&&(this.s=4,Mt(14),d=!1),dn(this.i,this.l,null,"[Incomplete Response]");break}else if(Gt==nu){this.s=4,Mt(15),dn(this.i,this.l,F,"[Invalid Chunk]"),d=!1;break}else dn(this.i,this.l,Gt,null),Ks(this,Gt);if(iu(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Ct!=4||F.length!=0||this.h.h||(this.s=1,Mt(16),d=!1),this.o=this.o&&d,!d)dn(this.i,this.l,F,"[Invalid Chunked Response]"),Le(this),hr(this);else if(0<F.length&&!this.W){this.W=!0;var Vt=this.j;Vt.g==this&&Vt.ba&&!Vt.M&&(Vt.j.info("Great, no buffering proxy detected. Bytes received: "+F.length),Ys(Vt),Vt.M=!0,Mt(11))}}else dn(this.i,this.l,F,null),Ks(this,F);Ct==4&&Le(this),this.o&&!this.J&&(Ct==4?Du(this.j,this):(this.o=!1,_i(this)))}else qf(this.g),d==400&&0<F.indexOf("Unknown SID")?(this.s=3,Mt(12)):(this.s=0,Mt(13)),Le(this),hr(this)}}}catch{}finally{}};function iu(o){return o.g?o.u=="GET"&&o.L!=2&&o.j.Ca:!1}function Af(o,l){var d=o.C,m=l.indexOf(`
|
|
380
|
-
`,d);return m==-1?zs:(d=Number(l.substring(d,m)),isNaN(d)?nu:(m+=1,m+d>l.length?zs:(l=l.slice(m,m+d),o.C=m+d,l)))}ce.prototype.cancel=function(){this.J=!0,Le(this)};function _i(o){o.S=Date.now()+o.I,su(o,o.I)}function su(o,l){if(o.B!=null)throw Error("WatchDog timer not null");o.B=cr(_(o.ba,o),l)}function Gs(o){o.B&&(u.clearTimeout(o.B),o.B=null)}ce.prototype.ba=function(){this.B=null;const o=Date.now();0<=o-this.S?(vf(this.i,this.A),this.L!=2&&(ur(),Mt(17)),Le(this),this.s=2,hr(this)):su(this,this.S-o)};function hr(o){o.j.G==0||o.J||Du(o.j,o)}function Le(o){Gs(o);var l=o.M;l&&typeof l.ma=="function"&&l.ma(),o.M=null,Qa(o.U),o.g&&(l=o.g,o.g=null,l.abort(),l.ma())}function Ks(o,l){try{var d=o.j;if(d.G!=0&&(d.g==o||$s(d.h,o))){if(!o.K&&$s(d.h,o)&&d.G==3){try{var m=d.Da.g.parse(l)}catch{m=null}if(Array.isArray(m)&&m.length==3){var A=m;if(A[0]==0){t:if(!d.u){if(d.g)if(d.g.F+3e3<o.F)bi(d),Ai(d);else break t;Js(d),Mt(18)}}else d.za=A[1],0<d.za-d.T&&37500>A[2]&&d.F&&d.v==0&&!d.C&&(d.C=cr(_(d.Za,d),6e3));if(1>=uu(d.h)&&d.ca){try{d.ca()}catch{}d.ca=void 0}}else Ue(d,11)}else if((o.K||d.g==o)&&bi(d),!z(l))for(A=d.Da.g.parse(l),l=0;l<A.length;l++){let X=A[l];if(d.T=X[0],X=X[1],d.G==2)if(X[0]=="c"){d.K=X[1],d.ia=X[2];const Vt=X[3];Vt!=null&&(d.la=Vt,d.j.info("VER="+d.la));const Ct=X[4];Ct!=null&&(d.Aa=Ct,d.j.info("SVER="+d.Aa));const gn=X[5];gn!=null&&typeof gn=="number"&&0<gn&&(m=1.5*gn,d.L=m,d.j.info("backChannelRequestTimeoutMs_="+m)),m=d;const Gt=o.g;if(Gt){const Si=Gt.g?Gt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Si){var S=m.h;S.g||Si.indexOf("spdy")==-1&&Si.indexOf("quic")==-1&&Si.indexOf("h2")==-1||(S.j=S.l,S.g=new Set,S.h&&(Qs(S,S.h),S.h=null))}if(m.D){const Xs=Gt.g?Gt.g.getResponseHeader("X-HTTP-Session-Id"):null;Xs&&(m.ya=Xs,st(m.I,m.D,Xs))}}d.G=3,d.l&&d.l.ua(),d.ba&&(d.R=Date.now()-o.F,d.j.info("Handshake RTT: "+d.R+"ms")),m=d;var F=o;if(m.qa=ku(m,m.J?m.ia:null,m.W),F.K){cu(m.h,F);var rt=F,At=m.L;At&&(rt.I=At),rt.B&&(Gs(rt),_i(rt)),m.g=F}else Vu(m);0<d.i.length&&Ri(d)}else X[0]!="stop"&&X[0]!="close"||Ue(d,7);else d.G==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?Ue(d,7):Hs(d):X[0]!="noop"&&d.l&&d.l.ta(X),d.v=0)}}ur(4)}catch{}}var Rf=class{constructor(o,l){this.g=o,this.map=l}};function ou(o){this.l=o||10,u.PerformanceNavigationTiming?(o=u.performance.getEntriesByType("navigation"),o=0<o.length&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(u.chrome&&u.chrome.loadTimes&&u.chrome.loadTimes()&&u.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function au(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function uu(o){return o.h?1:o.g?o.g.size:0}function $s(o,l){return o.h?o.h==l:o.g?o.g.has(l):!1}function Qs(o,l){o.g?o.g.add(l):o.h=l}function cu(o,l){o.h&&o.h==l?o.h=null:o.g&&o.g.has(l)&&o.g.delete(l)}ou.prototype.cancel=function(){if(this.i=lu(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function lu(o){if(o.h!=null)return o.i.concat(o.h.D);if(o.g!=null&&o.g.size!==0){let l=o.i;for(const d of o.g.values())l=l.concat(d.D);return l}return N(o.i)}function bf(o){if(o.V&&typeof o.V=="function")return o.V();if(typeof Map<"u"&&o instanceof Map||typeof Set<"u"&&o instanceof Set)return Array.from(o.values());if(typeof o=="string")return o.split("");if(c(o)){for(var l=[],d=o.length,m=0;m<d;m++)l.push(o[m]);return l}l=[],d=0;for(m in o)l[d++]=o[m];return l}function Pf(o){if(o.na&&typeof o.na=="function")return o.na();if(!o.V||typeof o.V!="function"){if(typeof Map<"u"&&o instanceof Map)return Array.from(o.keys());if(!(typeof Set<"u"&&o instanceof Set)){if(c(o)||typeof o=="string"){var l=[];o=o.length;for(var d=0;d<o;d++)l.push(d);return l}l=[],d=0;for(const m in o)l[d++]=m;return l}}}function hu(o,l){if(o.forEach&&typeof o.forEach=="function")o.forEach(l,void 0);else if(c(o)||typeof o=="string")Array.prototype.forEach.call(o,l,void 0);else for(var d=Pf(o),m=bf(o),A=m.length,S=0;S<A;S++)l.call(void 0,m[S],d&&d[S],o)}var du=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Sf(o,l){if(o){o=o.split("&");for(var d=0;d<o.length;d++){var m=o[d].indexOf("="),A=null;if(0<=m){var S=o[d].substring(0,m);A=o[d].substring(m+1)}else S=o[d];l(S,A?decodeURIComponent(A.replace(/\+/g," ")):"")}}}function Be(o){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,o instanceof Be){this.h=o.h,yi(this,o.j),this.o=o.o,this.g=o.g,Ii(this,o.s),this.l=o.l;var l=o.i,d=new mr;d.i=l.i,l.g&&(d.g=new Map(l.g),d.h=l.h),fu(this,d),this.m=o.m}else o&&(l=String(o).match(du))?(this.h=!1,yi(this,l[1]||"",!0),this.o=dr(l[2]||""),this.g=dr(l[3]||"",!0),Ii(this,l[4]),this.l=dr(l[5]||"",!0),fu(this,l[6]||"",!0),this.m=dr(l[7]||"")):(this.h=!1,this.i=new mr(null,this.h))}Be.prototype.toString=function(){var o=[],l=this.j;l&&o.push(fr(l,mu,!0),":");var d=this.g;return(d||l=="file")&&(o.push("//"),(l=this.o)&&o.push(fr(l,mu,!0),"@"),o.push(encodeURIComponent(String(d)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.s,d!=null&&o.push(":",String(d))),(d=this.l)&&(this.g&&d.charAt(0)!="/"&&o.push("/"),o.push(fr(d,d.charAt(0)=="/"?Df:Cf,!0))),(d=this.i.toString())&&o.push("?",d),(d=this.m)&&o.push("#",fr(d,Nf)),o.join("")};function Xt(o){return new Be(o)}function yi(o,l,d){o.j=d?dr(l,!0):l,o.j&&(o.j=o.j.replace(/:$/,""))}function Ii(o,l){if(l){if(l=Number(l),isNaN(l)||0>l)throw Error("Bad port number "+l);o.s=l}else o.s=null}function fu(o,l,d){l instanceof mr?(o.i=l,kf(o.i,o.h)):(d||(l=fr(l,xf)),o.i=new mr(l,o.h))}function st(o,l,d){o.i.set(l,d)}function Ei(o){return st(o,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),o}function dr(o,l){return o?l?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function fr(o,l,d){return typeof o=="string"?(o=encodeURI(o).replace(l,Vf),d&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function Vf(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var mu=/[#\/\?@]/g,Cf=/[#\?:]/g,Df=/[#\?]/g,xf=/[#\?@]/g,Nf=/#/g;function mr(o,l){this.h=this.g=null,this.i=o||null,this.j=!!l}function le(o){o.g||(o.g=new Map,o.h=0,o.i&&Sf(o.i,function(l,d){o.add(decodeURIComponent(l.replace(/\+/g," ")),d)}))}r=mr.prototype,r.add=function(o,l){le(this),this.i=null,o=fn(this,o);var d=this.g.get(o);return d||this.g.set(o,d=[]),d.push(l),this.h+=1,this};function gu(o,l){le(o),l=fn(o,l),o.g.has(l)&&(o.i=null,o.h-=o.g.get(l).length,o.g.delete(l))}function pu(o,l){return le(o),l=fn(o,l),o.g.has(l)}r.forEach=function(o,l){le(this),this.g.forEach(function(d,m){d.forEach(function(A){o.call(l,A,m,this)},this)},this)},r.na=function(){le(this);const o=Array.from(this.g.values()),l=Array.from(this.g.keys()),d=[];for(let m=0;m<l.length;m++){const A=o[m];for(let S=0;S<A.length;S++)d.push(l[m])}return d},r.V=function(o){le(this);let l=[];if(typeof o=="string")pu(this,o)&&(l=l.concat(this.g.get(fn(this,o))));else{o=Array.from(this.g.values());for(let d=0;d<o.length;d++)l=l.concat(o[d])}return l},r.set=function(o,l){return le(this),this.i=null,o=fn(this,o),pu(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[l]),this.h+=1,this},r.get=function(o,l){return o?(o=this.V(o),0<o.length?String(o[0]):l):l};function _u(o,l,d){gu(o,l),0<d.length&&(o.i=null,o.g.set(fn(o,l),N(d)),o.h+=d.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],l=Array.from(this.g.keys());for(var d=0;d<l.length;d++){var m=l[d];const S=encodeURIComponent(String(m)),F=this.V(m);for(m=0;m<F.length;m++){var A=S;F[m]!==""&&(A+="="+encodeURIComponent(String(F[m]))),o.push(A)}}return this.i=o.join("&")};function fn(o,l){return l=String(l),o.j&&(l=l.toLowerCase()),l}function kf(o,l){l&&!o.j&&(le(o),o.i=null,o.g.forEach(function(d,m){var A=m.toLowerCase();m!=A&&(gu(this,m),_u(this,A,d))},o)),o.j=l}function Ff(o,l){const d=new lr;if(u.Image){const m=new Image;m.onload=R(he,d,"TestLoadImage: loaded",!0,l,m),m.onerror=R(he,d,"TestLoadImage: error",!1,l,m),m.onabort=R(he,d,"TestLoadImage: abort",!1,l,m),m.ontimeout=R(he,d,"TestLoadImage: timeout",!1,l,m),u.setTimeout(function(){m.ontimeout&&m.ontimeout()},1e4),m.src=o}else l(!1)}function Mf(o,l){const d=new lr,m=new AbortController,A=setTimeout(()=>{m.abort(),he(d,"TestPingServer: timeout",!1,l)},1e4);fetch(o,{signal:m.signal}).then(S=>{clearTimeout(A),S.ok?he(d,"TestPingServer: ok",!0,l):he(d,"TestPingServer: server error",!1,l)}).catch(()=>{clearTimeout(A),he(d,"TestPingServer: error",!1,l)})}function he(o,l,d,m,A){try{A&&(A.onload=null,A.onerror=null,A.onabort=null,A.ontimeout=null),m(d)}catch{}}function Of(){this.g=new If}function Lf(o,l,d){const m=d||"";try{hu(o,function(A,S){let F=A;h(A)&&(F=Os(A)),l.push(m+S+"="+encodeURIComponent(F))})}catch(A){throw l.push(m+"type="+encodeURIComponent("_badmap")),A}}function Ti(o){this.l=o.Ub||null,this.j=o.eb||!1}C(Ti,Ls),Ti.prototype.g=function(){return new vi(this.l,this.j)},Ti.prototype.i=function(o){return function(){return o}}({});function vi(o,l){St.call(this),this.D=o,this.o=l,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}C(vi,St),r=vi.prototype,r.open=function(o,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=o,this.A=l,this.readyState=1,pr(this)},r.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const l={headers:this.u,method:this.B,credentials:this.m,cache:void 0};o&&(l.body=o),(this.D||u).fetch(new Request(this.A,l)).then(this.Sa.bind(this),this.ga.bind(this))},r.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,gr(this)),this.readyState=0},r.Sa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,pr(this)),this.g&&(this.readyState=3,pr(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof u.ReadableStream<"u"&&"body"in o){if(this.j=o.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;yu(this)}else o.text().then(this.Ra.bind(this),this.ga.bind(this))};function yu(o){o.j.read().then(o.Pa.bind(o)).catch(o.ga.bind(o))}r.Pa=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var l=o.value?o.value:new Uint8Array(0);(l=this.v.decode(l,{stream:!o.done}))&&(this.response=this.responseText+=l)}o.done?gr(this):pr(this),this.readyState==3&&yu(this)}},r.Ra=function(o){this.g&&(this.response=this.responseText=o,gr(this))},r.Qa=function(o){this.g&&(this.response=o,gr(this))},r.ga=function(){this.g&&gr(this)};function gr(o){o.readyState=4,o.l=null,o.j=null,o.v=null,pr(o)}r.setRequestHeader=function(o,l){this.u.append(o,l)},r.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],l=this.h.entries();for(var d=l.next();!d.done;)d=d.value,o.push(d[0]+": "+d[1]),d=l.next();return o.join(`\r
|
|
381
|
-
`)};function pr(o){o.onreadystatechange&&o.onreadystatechange.call(o)}Object.defineProperty(vi.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(o){this.m=o?"include":"same-origin"}});function Iu(o){let l="";return K(o,function(d,m){l+=m,l+=":",l+=d,l+=`\r
|
|
382
|
-
`}),l}function Ws(o,l,d){t:{for(m in d){var m=!1;break t}m=!0}m||(d=Iu(d),typeof o=="string"?d!=null&&encodeURIComponent(String(d)):st(o,l,d))}function ft(o){St.call(this),this.headers=new Map,this.o=o||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}C(ft,St);var Bf=/^https?$/i,Uf=["POST","PUT"];r=ft.prototype,r.Ha=function(o){this.J=o},r.ea=function(o,l,d,m){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+o);l=l?l.toUpperCase():"GET",this.D=o,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():qs.g(),this.v=this.o?Wa(this.o):Wa(qs),this.g.onreadystatechange=_(this.Ea,this);try{this.B=!0,this.g.open(l,String(o),!0),this.B=!1}catch(S){Eu(this,S);return}if(o=d||"",d=new Map(this.headers),m)if(Object.getPrototypeOf(m)===Object.prototype)for(var A in m)d.set(A,m[A]);else if(typeof m.keys=="function"&&typeof m.get=="function")for(const S of m.keys())d.set(S,m.get(S));else throw Error("Unknown input type for opt_headers: "+String(m));m=Array.from(d.keys()).find(S=>S.toLowerCase()=="content-type"),A=u.FormData&&o instanceof u.FormData,!(0<=Array.prototype.indexOf.call(Uf,l,void 0))||m||A||d.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[S,F]of d)this.g.setRequestHeader(S,F);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{wu(this),this.u=!0,this.g.send(o),this.u=!1}catch(S){Eu(this,S)}};function Eu(o,l){o.h=!1,o.g&&(o.j=!0,o.g.abort(),o.j=!1),o.l=l,o.m=5,Tu(o),wi(o)}function Tu(o){o.A||(o.A=!0,Ft(o,"complete"),Ft(o,"error"))}r.abort=function(o){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=o||7,Ft(this,"complete"),Ft(this,"abort"),wi(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),wi(this,!0)),ft.aa.N.call(this)},r.Ea=function(){this.s||(this.B||this.u||this.j?vu(this):this.bb())},r.bb=function(){vu(this)};function vu(o){if(o.h&&typeof a<"u"&&(!o.v[1]||Zt(o)!=4||o.Z()!=2)){if(o.u&&Zt(o)==4)Ga(o.Ea,0,o);else if(Ft(o,"readystatechange"),Zt(o)==4){o.h=!1;try{const F=o.Z();t:switch(F){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var l=!0;break t;default:l=!1}var d;if(!(d=l)){var m;if(m=F===0){var A=String(o.D).match(du)[1]||null;!A&&u.self&&u.self.location&&(A=u.self.location.protocol.slice(0,-1)),m=!Bf.test(A?A.toLowerCase():"")}d=m}if(d)Ft(o,"complete"),Ft(o,"success");else{o.m=6;try{var S=2<Zt(o)?o.g.statusText:""}catch{S=""}o.l=S+" ["+o.Z()+"]",Tu(o)}}finally{wi(o)}}}}function wi(o,l){if(o.g){wu(o);const d=o.g,m=o.v[0]?()=>{}:null;o.g=null,o.v=null,l||Ft(o,"ready");try{d.onreadystatechange=m}catch{}}}function wu(o){o.I&&(u.clearTimeout(o.I),o.I=null)}r.isActive=function(){return!!this.g};function Zt(o){return o.g?o.g.readyState:0}r.Z=function(){try{return 2<Zt(this)?this.g.status:-1}catch{return-1}},r.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},r.Oa=function(o){if(this.g){var l=this.g.responseText;return o&&l.indexOf(o)==0&&(l=l.substring(o.length)),yf(l)}};function Au(o){try{if(!o.g)return null;if("response"in o.g)return o.g.response;switch(o.H){case"":case"text":return o.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in o.g)return o.g.mozResponseArrayBuffer}return null}catch{return null}}function qf(o){const l={};o=(o.g&&2<=Zt(o)&&o.g.getAllResponseHeaders()||"").split(`\r
|
|
383
|
-
`);for(let m=0;m<o.length;m++){if(z(o[m]))continue;var d=v(o[m]);const A=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const S=l[A]||[];l[A]=S,S.push(d)}E(l,function(m){return m.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function _r(o,l,d){return d&&d.internalChannelParams&&d.internalChannelParams[o]||l}function Ru(o){this.Aa=0,this.i=[],this.j=new lr,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=_r("failFast",!1,o),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=_r("baseRetryDelayMs",5e3,o),this.cb=_r("retryDelaySeedMs",1e4,o),this.Wa=_r("forwardChannelMaxRetries",2,o),this.wa=_r("forwardChannelRequestTimeoutMs",2e4,o),this.pa=o&&o.xmlHttpFactory||void 0,this.Xa=o&&o.Tb||void 0,this.Ca=o&&o.useFetchStreams||!1,this.L=void 0,this.J=o&&o.supportsCrossDomainXhr||!1,this.K="",this.h=new ou(o&&o.concurrentRequestLimit),this.Da=new Of,this.P=o&&o.fastHandshake||!1,this.O=o&&o.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=o&&o.Rb||!1,o&&o.xa&&this.j.xa(),o&&o.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&o&&o.detectBufferingProxy||!1,this.ja=void 0,o&&o.longPollingTimeout&&0<o.longPollingTimeout&&(this.ja=o.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=Ru.prototype,r.la=8,r.G=1,r.connect=function(o,l,d,m){Mt(0),this.W=o,this.H=l||{},d&&m!==void 0&&(this.H.OSID=d,this.H.OAID=m),this.F=this.X,this.I=ku(this,null,this.W),Ri(this)};function Hs(o){if(bu(o),o.G==3){var l=o.U++,d=Xt(o.I);if(st(d,"SID",o.K),st(d,"RID",l),st(d,"TYPE","terminate"),yr(o,d),l=new ce(o,o.j,l),l.L=2,l.v=Ei(Xt(d)),d=!1,u.navigator&&u.navigator.sendBeacon)try{d=u.navigator.sendBeacon(l.v.toString(),"")}catch{}!d&&u.Image&&(new Image().src=l.v,d=!0),d||(l.g=Fu(l.j,null),l.g.ea(l.v)),l.F=Date.now(),_i(l)}Nu(o)}function Ai(o){o.g&&(Ys(o),o.g.cancel(),o.g=null)}function bu(o){Ai(o),o.u&&(u.clearTimeout(o.u),o.u=null),bi(o),o.h.cancel(),o.s&&(typeof o.s=="number"&&u.clearTimeout(o.s),o.s=null)}function Ri(o){if(!au(o.h)&&!o.s){o.s=!0;var l=o.Ga;rr||Ba(),ir||(rr(),ir=!0),Vs.add(l,o),o.B=0}}function zf(o,l){return uu(o.h)>=o.h.j-(o.s?1:0)?!1:o.s?(o.i=l.D.concat(o.i),!0):o.G==1||o.G==2||o.B>=(o.Va?0:o.Wa)?!1:(o.s=cr(_(o.Ga,o,l),xu(o,o.B)),o.B++,!0)}r.Ga=function(o){if(this.s)if(this.s=null,this.G==1){if(!o){this.U=Math.floor(1e5*Math.random()),o=this.U++;const A=new ce(this,this.j,o);let S=this.o;if(this.S&&(S?(S=p(S),T(S,this.S)):S=this.S),this.m!==null||this.O||(A.H=S,S=null),this.P)t:{for(var l=0,d=0;d<this.i.length;d++){e:{var m=this.i[d];if("__data__"in m.map&&(m=m.map.__data__,typeof m=="string")){m=m.length;break e}m=void 0}if(m===void 0)break;if(l+=m,4096<l){l=d;break t}if(l===4096||d===this.i.length-1){l=d+1;break t}}l=1e3}else l=1e3;l=Su(this,A,l),d=Xt(this.I),st(d,"RID",o),st(d,"CVER",22),this.D&&st(d,"X-HTTP-Session-Id",this.D),yr(this,d),S&&(this.O?l="headers="+encodeURIComponent(String(Iu(S)))+"&"+l:this.m&&Ws(d,this.m,S)),Qs(this.h,A),this.Ua&&st(d,"TYPE","init"),this.P?(st(d,"$req",l),st(d,"SID","null"),A.T=!0,js(A,d,null)):js(A,d,l),this.G=2}}else this.G==3&&(o?Pu(this,o):this.i.length==0||au(this.h)||Pu(this))};function Pu(o,l){var d;l?d=l.l:d=o.U++;const m=Xt(o.I);st(m,"SID",o.K),st(m,"RID",d),st(m,"AID",o.T),yr(o,m),o.m&&o.o&&Ws(m,o.m,o.o),d=new ce(o,o.j,d,o.B+1),o.m===null&&(d.H=o.o),l&&(o.i=l.D.concat(o.i)),l=Su(o,d,1e3),d.I=Math.round(.5*o.wa)+Math.round(.5*o.wa*Math.random()),Qs(o.h,d),js(d,m,l)}function yr(o,l){o.H&&K(o.H,function(d,m){st(l,m,d)}),o.l&&hu({},function(d,m){st(l,m,d)})}function Su(o,l,d){d=Math.min(o.i.length,d);var m=o.l?_(o.l.Na,o.l,o):null;t:{var A=o.i;let S=-1;for(;;){const F=["count="+d];S==-1?0<d?(S=A[0].g,F.push("ofs="+S)):S=0:F.push("ofs="+S);let rt=!0;for(let At=0;At<d;At++){let X=A[At].g;const Vt=A[At].map;if(X-=S,0>X)S=Math.max(0,A[At].g-100),rt=!1;else try{Lf(Vt,F,"req"+X+"_")}catch{m&&m(Vt)}}if(rt){m=F.join("&");break t}}}return o=o.i.splice(0,d),l.D=o,m}function Vu(o){if(!o.g&&!o.u){o.Y=1;var l=o.Fa;rr||Ba(),ir||(rr(),ir=!0),Vs.add(l,o),o.v=0}}function Js(o){return o.g||o.u||3<=o.v?!1:(o.Y++,o.u=cr(_(o.Fa,o),xu(o,o.v)),o.v++,!0)}r.Fa=function(){if(this.u=null,Cu(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var o=2*this.R;this.j.info("BP detection timer enabled: "+o),this.A=cr(_(this.ab,this),o)}},r.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Mt(10),Ai(this),Cu(this))};function Ys(o){o.A!=null&&(u.clearTimeout(o.A),o.A=null)}function Cu(o){o.g=new ce(o,o.j,"rpc",o.Y),o.m===null&&(o.g.H=o.o),o.g.O=0;var l=Xt(o.qa);st(l,"RID","rpc"),st(l,"SID",o.K),st(l,"AID",o.T),st(l,"CI",o.F?"0":"1"),!o.F&&o.ja&&st(l,"TO",o.ja),st(l,"TYPE","xmlhttp"),yr(o,l),o.m&&o.o&&Ws(l,o.m,o.o),o.L&&(o.g.I=o.L);var d=o.g;o=o.ia,d.L=1,d.v=Ei(Xt(l)),d.m=null,d.P=!0,ru(d,o)}r.Za=function(){this.C!=null&&(this.C=null,Ai(this),Js(this),Mt(19))};function bi(o){o.C!=null&&(u.clearTimeout(o.C),o.C=null)}function Du(o,l){var d=null;if(o.g==l){bi(o),Ys(o),o.g=null;var m=2}else if($s(o.h,l))d=l.D,cu(o.h,l),m=1;else return;if(o.G!=0){if(l.o)if(m==1){d=l.m?l.m.length:0,l=Date.now()-l.F;var A=o.B;m=mi(),Ft(m,new Za(m,d)),Ri(o)}else Vu(o);else if(A=l.s,A==3||A==0&&0<l.X||!(m==1&&zf(o,l)||m==2&&Js(o)))switch(d&&0<d.length&&(l=o.h,l.i=l.i.concat(d)),A){case 1:Ue(o,5);break;case 4:Ue(o,10);break;case 3:Ue(o,6);break;default:Ue(o,2)}}}function xu(o,l){let d=o.Ta+Math.floor(Math.random()*o.cb);return o.isActive()||(d*=2),d*l}function Ue(o,l){if(o.j.info("Error code "+l),l==2){var d=_(o.fb,o),m=o.Xa;const A=!m;m=new Be(m||"//www.google.com/images/cleardot.gif"),u.location&&u.location.protocol=="http"||yi(m,"https"),Ei(m),A?Ff(m.toString(),d):Mf(m.toString(),d)}else Mt(2);o.G=0,o.l&&o.l.sa(l),Nu(o),bu(o)}r.fb=function(o){o?(this.j.info("Successfully pinged google.com"),Mt(2)):(this.j.info("Failed to ping google.com"),Mt(1))};function Nu(o){if(o.G=0,o.ka=[],o.l){const l=lu(o.h);(l.length!=0||o.i.length!=0)&&(V(o.ka,l),V(o.ka,o.i),o.h.i.length=0,N(o.i),o.i.length=0),o.l.ra()}}function ku(o,l,d){var m=d instanceof Be?Xt(d):new Be(d);if(m.g!="")l&&(m.g=l+"."+m.g),Ii(m,m.s);else{var A=u.location;m=A.protocol,l=l?l+"."+A.hostname:A.hostname,A=+A.port;var S=new Be(null);m&&yi(S,m),l&&(S.g=l),A&&Ii(S,A),d&&(S.l=d),m=S}return d=o.D,l=o.ya,d&&l&&st(m,d,l),st(m,"VER",o.la),yr(o,m),m}function Fu(o,l,d){if(l&&!o.J)throw Error("Can't create secondary domain capable XhrIo object.");return l=o.Ca&&!o.pa?new ft(new Ti({eb:d})):new ft(o.pa),l.Ha(o.J),l}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function Mu(){}r=Mu.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function Pi(){}Pi.prototype.g=function(o,l){return new Ut(o,l)};function Ut(o,l){St.call(this),this.g=new Ru(l),this.l=o,this.h=l&&l.messageUrlParams||null,o=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(o?o["X-WebChannel-Content-Type"]=l.messageContentType:o={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.va&&(o?o["X-WebChannel-Client-Profile"]=l.va:o={"X-WebChannel-Client-Profile":l.va}),this.g.S=o,(o=l&&l.Sb)&&!z(o)&&(this.g.m=o),this.v=l&&l.supportsCrossDomainXhr||!1,this.u=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!z(l)&&(this.g.D=l,o=this.h,o!==null&&l in o&&(o=this.h,l in o&&delete o[l])),this.j=new mn(this)}C(Ut,St),Ut.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ut.prototype.close=function(){Hs(this.g)},Ut.prototype.o=function(o){var l=this.g;if(typeof o=="string"){var d={};d.__data__=o,o=d}else this.u&&(d={},d.__data__=Os(o),o=d);l.i.push(new Rf(l.Ya++,o)),l.G==3&&Ri(l)},Ut.prototype.N=function(){this.g.l=null,delete this.j,Hs(this.g),delete this.g,Ut.aa.N.call(this)};function Ou(o){Bs.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var l=o.__sm__;if(l){t:{for(const d in l){o=d;break t}o=void 0}(this.i=o)&&(o=this.i,l=l!==null&&o in l?l[o]:void 0),this.data=l}else this.data=o}C(Ou,Bs);function Lu(){Us.call(this),this.status=1}C(Lu,Us);function mn(o){this.g=o}C(mn,Mu),mn.prototype.ua=function(){Ft(this.g,"a")},mn.prototype.ta=function(o){Ft(this.g,new Ou(o))},mn.prototype.sa=function(o){Ft(this.g,new Lu)},mn.prototype.ra=function(){Ft(this.g,"b")},Pi.prototype.createWebChannel=Pi.prototype.g,Ut.prototype.send=Ut.prototype.o,Ut.prototype.open=Ut.prototype.m,Ut.prototype.close=Ut.prototype.close,Nl=function(){return new Pi},xl=function(){return mi()},Dl=Oe,mo={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},gi.NO_ERROR=0,gi.TIMEOUT=8,gi.HTTP_ERROR=6,Mi=gi,tu.COMPLETE="complete",Cl=tu,Ha.EventType=ar,ar.OPEN="a",ar.CLOSE="b",ar.ERROR="c",ar.MESSAGE="d",St.prototype.listen=St.prototype.K,Ar=Ha,ft.prototype.listenOnce=ft.prototype.L,ft.prototype.getLastError=ft.prototype.Ka,ft.prototype.getLastErrorCode=ft.prototype.Ba,ft.prototype.getStatus=ft.prototype.Z,ft.prototype.getResponseJson=ft.prototype.Oa,ft.prototype.getResponseText=ft.prototype.oa,ft.prototype.send=ft.prototype.ea,ft.prototype.setWithCredentials=ft.prototype.Ha,Vl=ft}).apply(typeof Vi<"u"?Vi:typeof self<"u"?self:typeof window<"u"?window:{});const Qu="@firebase/firestore";/**
|
|
384
|
-
* @license
|
|
385
|
-
* Copyright 2017 Google LLC
|
|
386
|
-
*
|
|
387
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
388
|
-
* you may not use this file except in compliance with the License.
|
|
389
|
-
* You may obtain a copy of the License at
|
|
390
|
-
*
|
|
391
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
392
|
-
*
|
|
393
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
394
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
395
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
396
|
-
* See the License for the specific language governing permissions and
|
|
397
|
-
* limitations under the License.
|
|
398
|
-
*/class Tt{constructor(t){this.uid=t}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}Tt.UNAUTHENTICATED=new Tt(null),Tt.GOOGLE_CREDENTIALS=new Tt("google-credentials-uid"),Tt.FIRST_PARTY=new Tt("first-party-uid"),Tt.MOCK_USER=new Tt("mock-user");/**
|
|
399
|
-
* @license
|
|
400
|
-
* Copyright 2017 Google LLC
|
|
401
|
-
*
|
|
402
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
403
|
-
* you may not use this file except in compliance with the License.
|
|
404
|
-
* You may obtain a copy of the License at
|
|
405
|
-
*
|
|
406
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
407
|
-
*
|
|
408
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
409
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
410
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
411
|
-
* See the License for the specific language governing permissions and
|
|
412
|
-
* limitations under the License.
|
|
413
|
-
*/let Gn="10.14.0";/**
|
|
414
|
-
* @license
|
|
415
|
-
* Copyright 2017 Google LLC
|
|
416
|
-
*
|
|
417
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
418
|
-
* you may not use this file except in compliance with the License.
|
|
419
|
-
* You may obtain a copy of the License at
|
|
420
|
-
*
|
|
421
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
422
|
-
*
|
|
423
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
424
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
425
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
426
|
-
* See the License for the specific language governing permissions and
|
|
427
|
-
* limitations under the License.
|
|
428
|
-
*/const Te=new pl("@firebase/firestore");function En(){return Te.logLevel}function yg(r){Te.setLogLevel(r)}function x(r,...t){if(Te.logLevel<=J.DEBUG){const e=t.map(Lo);Te.debug(`Firestore (${Gn}): ${r}`,...e)}}function gt(r,...t){if(Te.logLevel<=J.ERROR){const e=t.map(Lo);Te.error(`Firestore (${Gn}): ${r}`,...e)}}function qt(r,...t){if(Te.logLevel<=J.WARN){const e=t.map(Lo);Te.warn(`Firestore (${Gn}): ${r}`,...e)}}function Lo(r){if(typeof r=="string")return r;try{/**
|
|
429
|
-
* @license
|
|
430
|
-
* Copyright 2020 Google LLC
|
|
431
|
-
*
|
|
432
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
433
|
-
* you may not use this file except in compliance with the License.
|
|
434
|
-
* You may obtain a copy of the License at
|
|
435
|
-
*
|
|
436
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
437
|
-
*
|
|
438
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
439
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
440
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
441
|
-
* See the License for the specific language governing permissions and
|
|
442
|
-
* limitations under the License.
|
|
443
|
-
*/return function(e){return JSON.stringify(e)}(r)}catch{return r}}/**
|
|
444
|
-
* @license
|
|
445
|
-
* Copyright 2017 Google LLC
|
|
446
|
-
*
|
|
447
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
448
|
-
* you may not use this file except in compliance with the License.
|
|
449
|
-
* You may obtain a copy of the License at
|
|
450
|
-
*
|
|
451
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
452
|
-
*
|
|
453
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
454
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
455
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
456
|
-
* See the License for the specific language governing permissions and
|
|
457
|
-
* limitations under the License.
|
|
458
|
-
*/function O(r="Unexpected state"){const t=`FIRESTORE (${Gn}) INTERNAL ASSERTION FAILED: `+r;throw gt(t),new Error(t)}function L(r,t){r||O()}function Ig(r,t){r||O()}function k(r,t){return r}/**
|
|
459
|
-
* @license
|
|
460
|
-
* Copyright 2017 Google LLC
|
|
461
|
-
*
|
|
462
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
463
|
-
* you may not use this file except in compliance with the License.
|
|
464
|
-
* You may obtain a copy of the License at
|
|
465
|
-
*
|
|
466
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
467
|
-
*
|
|
468
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
469
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
470
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
471
|
-
* See the License for the specific language governing permissions and
|
|
472
|
-
* limitations under the License.
|
|
473
|
-
*/const P={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class D extends un{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
|
|
474
|
-
* @license
|
|
475
|
-
* Copyright 2017 Google LLC
|
|
476
|
-
*
|
|
477
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
478
|
-
* you may not use this file except in compliance with the License.
|
|
479
|
-
* You may obtain a copy of the License at
|
|
480
|
-
*
|
|
481
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
482
|
-
*
|
|
483
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
484
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
485
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
486
|
-
* See the License for the specific language governing permissions and
|
|
487
|
-
* limitations under the License.
|
|
488
|
-
*/class vt{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}/**
|
|
489
|
-
* @license
|
|
490
|
-
* Copyright 2017 Google LLC
|
|
491
|
-
*
|
|
492
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
493
|
-
* you may not use this file except in compliance with the License.
|
|
494
|
-
* You may obtain a copy of the License at
|
|
495
|
-
*
|
|
496
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
497
|
-
*
|
|
498
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
499
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
500
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
501
|
-
* See the License for the specific language governing permissions and
|
|
502
|
-
* limitations under the License.
|
|
503
|
-
*/class kl{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class Fl{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable(()=>e(Tt.UNAUTHENTICATED))}shutdown(){}}class Eg{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable(()=>e(this.token.user))}shutdown(){this.changeListener=null}}class Tg{constructor(t){this.t=t,this.currentUser=Tt.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){L(this.o===void 0);let n=this.i;const i=c=>this.i!==n?(n=this.i,e(c)):Promise.resolve();let s=new vt;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new vt,t.enqueueRetryable(()=>i(this.currentUser))};const a=()=>{const c=s;t.enqueueRetryable(async()=>{await c.promise,await i(this.currentUser)})},u=c=>{x("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(c=>u(c)),setTimeout(()=>{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?u(c):(x("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new vt)}},0),a()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(n=>this.i!==t?(x("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):n?(L(typeof n.accessToken=="string"),new kl(n.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const t=this.auth&&this.auth.getUid();return L(t===null||typeof t=="string"),new Tt(t)}}class vg{constructor(t,e,n){this.l=t,this.h=e,this.P=n,this.type="FirstParty",this.user=Tt.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const t=this.T();return t&&this.I.set("Authorization",t),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class wg{constructor(t,e,n){this.l=t,this.h=e,this.P=n}getToken(){return Promise.resolve(new vg(this.l,this.h,this.P))}start(t,e){t.enqueueRetryable(()=>e(Tt.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class Ml{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Ag{constructor(t){this.A=t,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(t,e){L(this.o===void 0);const n=s=>{s.error!=null&&x("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${s.error.message}`);const a=s.token!==this.R;return this.R=s.token,x("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?e(s.token):Promise.resolve()};this.o=s=>{t.enqueueRetryable(()=>n(s))};const i=s=>{x("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=s,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(s=>i(s)),setTimeout(()=>{if(!this.appCheck){const s=this.A.getImmediate({optional:!0});s?i(s):x("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then(e=>e?(L(typeof e.token=="string"),this.R=e.token,new Ml(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class Rg{getToken(){return Promise.resolve(new Ml(""))}invalidateToken(){}start(t,e){}shutdown(){}}/**
|
|
504
|
-
* @license
|
|
505
|
-
* Copyright 2020 Google LLC
|
|
506
|
-
*
|
|
507
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
508
|
-
* you may not use this file except in compliance with the License.
|
|
509
|
-
* You may obtain a copy of the License at
|
|
510
|
-
*
|
|
511
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
512
|
-
*
|
|
513
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
514
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
515
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
516
|
-
* See the License for the specific language governing permissions and
|
|
517
|
-
* limitations under the License.
|
|
518
|
-
*/function bg(r){const t=typeof self<"u"&&(self.crypto||self.msCrypto),e=new Uint8Array(r);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<r;n++)e[n]=Math.floor(256*Math.random());return e}/**
|
|
519
|
-
* @license
|
|
520
|
-
* Copyright 2017 Google LLC
|
|
521
|
-
*
|
|
522
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
523
|
-
* you may not use this file except in compliance with the License.
|
|
524
|
-
* You may obtain a copy of the License at
|
|
525
|
-
*
|
|
526
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
527
|
-
*
|
|
528
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
529
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
530
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
531
|
-
* See the License for the specific language governing permissions and
|
|
532
|
-
* limitations under the License.
|
|
533
|
-
*/class Bo{static newId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const i=bg(40);for(let s=0;s<i.length;++s)n.length<20&&i[s]<e&&(n+=t.charAt(i[s]%t.length))}return n}}function j(r,t){return r<t?-1:r>t?1:0}function Vn(r,t,e){return r.length===t.length&&r.every((n,i)=>e(n,t[i]))}function Ol(r){return r+"\0"}/**
|
|
534
|
-
* @license
|
|
535
|
-
* Copyright 2017 Google LLC
|
|
536
|
-
*
|
|
537
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
538
|
-
* you may not use this file except in compliance with the License.
|
|
539
|
-
* You may obtain a copy of the License at
|
|
540
|
-
*
|
|
541
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
542
|
-
*
|
|
543
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
544
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
545
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
546
|
-
* See the License for the specific language governing permissions and
|
|
547
|
-
* limitations under the License.
|
|
548
|
-
*/class lt{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new D(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new D(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new D(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new D(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}static now(){return lt.fromMillis(Date.now())}static fromDate(t){return lt.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new lt(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?j(this.nanoseconds,t.nanoseconds):j(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/**
|
|
549
|
-
* @license
|
|
550
|
-
* Copyright 2017 Google LLC
|
|
551
|
-
*
|
|
552
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
553
|
-
* you may not use this file except in compliance with the License.
|
|
554
|
-
* You may obtain a copy of the License at
|
|
555
|
-
*
|
|
556
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
557
|
-
*
|
|
558
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
559
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
560
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
561
|
-
* See the License for the specific language governing permissions and
|
|
562
|
-
* limitations under the License.
|
|
563
|
-
*/class U{constructor(t){this.timestamp=t}static fromTimestamp(t){return new U(t)}static min(){return new U(new lt(0,0))}static max(){return new U(new lt(253402300799,999999999))}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
|
|
564
|
-
* @license
|
|
565
|
-
* Copyright 2017 Google LLC
|
|
566
|
-
*
|
|
567
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
568
|
-
* you may not use this file except in compliance with the License.
|
|
569
|
-
* You may obtain a copy of the License at
|
|
570
|
-
*
|
|
571
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
572
|
-
*
|
|
573
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
574
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
575
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
576
|
-
* See the License for the specific language governing permissions and
|
|
577
|
-
* limitations under the License.
|
|
578
|
-
*/class Or{constructor(t,e,n){e===void 0?e=0:e>t.length&&O(),n===void 0?n=t.length-e:n>t.length-e&&O(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return Or.comparator(this,t)===0}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof Or?t.forEach(n=>{e.push(n)}):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++){const s=t.get(i),a=e.get(i);if(s<a)return-1;if(s>a)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class W extends Or{construct(t,e,n){return new W(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new D(P.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter(i=>i.length>0))}return new W(e)}static emptyPath(){return new W([])}}const Pg=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class at extends Or{construct(t,e,n){return new at(t,e,n)}static isValidIdentifier(t){return Pg.test(t)}canonicalString(){return this.toArray().map(t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),at.isValidIdentifier(t)||(t="`"+t+"`"),t)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new at(["__name__"])}static fromServerFormat(t){const e=[];let n="",i=0;const s=()=>{if(n.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let a=!1;for(;i<t.length;){const u=t[i];if(u==="\\"){if(i+1===t.length)throw new D(P.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const c=t[i+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new D(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=c,i+=2}else u==="`"?(a=!a,i++):u!=="."||a?(n+=u,i++):(s(),i++)}if(s(),a)throw new D(P.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new at(e)}static emptyPath(){return new at([])}}/**
|
|
579
|
-
* @license
|
|
580
|
-
* Copyright 2017 Google LLC
|
|
581
|
-
*
|
|
582
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
583
|
-
* you may not use this file except in compliance with the License.
|
|
584
|
-
* You may obtain a copy of the License at
|
|
585
|
-
*
|
|
586
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
587
|
-
*
|
|
588
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
589
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
590
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
591
|
-
* See the License for the specific language governing permissions and
|
|
592
|
-
* limitations under the License.
|
|
593
|
-
*/class M{constructor(t){this.path=t}static fromPath(t){return new M(W.fromString(t))}static fromName(t){return new M(W.fromString(t).popFirst(5))}static empty(){return new M(W.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return t!==null&&W.comparator(this.path,t.path)===0}toString(){return this.path.toString()}static comparator(t,e){return W.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new M(new W(t.slice()))}}/**
|
|
594
|
-
* @license
|
|
595
|
-
* Copyright 2021 Google LLC
|
|
596
|
-
*
|
|
597
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
598
|
-
* you may not use this file except in compliance with the License.
|
|
599
|
-
* You may obtain a copy of the License at
|
|
600
|
-
*
|
|
601
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
602
|
-
*
|
|
603
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
604
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
605
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
606
|
-
* See the License for the specific language governing permissions and
|
|
607
|
-
* limitations under the License.
|
|
608
|
-
*/class Cn{constructor(t,e,n,i){this.indexId=t,this.collectionGroup=e,this.fields=n,this.indexState=i}}function go(r){return r.fields.find(t=>t.kind===2)}function je(r){return r.fields.filter(t=>t.kind!==2)}function Sg(r,t){let e=j(r.collectionGroup,t.collectionGroup);if(e!==0)return e;for(let n=0;n<Math.min(r.fields.length,t.fields.length);++n)if(e=Vg(r.fields[n],t.fields[n]),e!==0)return e;return j(r.fields.length,t.fields.length)}Cn.UNKNOWN_ID=-1;class Je{constructor(t,e){this.fieldPath=t,this.kind=e}}function Vg(r,t){const e=at.comparator(r.fieldPath,t.fieldPath);return e!==0?e:j(r.kind,t.kind)}class Dn{constructor(t,e){this.sequenceNumber=t,this.offset=e}static empty(){return new Dn(0,zt.min())}}function Ll(r,t){const e=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,i=U.fromTimestamp(n===1e9?new lt(e+1,0):new lt(e,n));return new zt(i,M.empty(),t)}function Bl(r){return new zt(r.readTime,r.key,-1)}class zt{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new zt(U.min(),M.empty(),-1)}static max(){return new zt(U.max(),M.empty(),-1)}}function Uo(r,t){let e=r.readTime.compareTo(t.readTime);return e!==0?e:(e=M.comparator(r.documentKey,t.documentKey),e!==0?e:j(r.largestBatchId,t.largestBatchId))}/**
|
|
609
|
-
* @license
|
|
610
|
-
* Copyright 2020 Google LLC
|
|
611
|
-
*
|
|
612
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
613
|
-
* you may not use this file except in compliance with the License.
|
|
614
|
-
* You may obtain a copy of the License at
|
|
615
|
-
*
|
|
616
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
617
|
-
*
|
|
618
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
619
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
620
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
621
|
-
* See the License for the specific language governing permissions and
|
|
622
|
-
* limitations under the License.
|
|
623
|
-
*/const Ul="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class ql{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(t=>t())}}/**
|
|
624
|
-
* @license
|
|
625
|
-
* Copyright 2017 Google LLC
|
|
626
|
-
*
|
|
627
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
628
|
-
* you may not use this file except in compliance with the License.
|
|
629
|
-
* You may obtain a copy of the License at
|
|
630
|
-
*
|
|
631
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
632
|
-
*
|
|
633
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
634
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
635
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
636
|
-
* See the License for the specific language governing permissions and
|
|
637
|
-
* limitations under the License.
|
|
638
|
-
*/async function Ce(r){if(r.code!==P.FAILED_PRECONDITION||r.message!==Ul)throw r;x("LocalStore","Unexpectedly lost primary lease")}/**
|
|
639
|
-
* @license
|
|
640
|
-
* Copyright 2017 Google LLC
|
|
641
|
-
*
|
|
642
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
643
|
-
* you may not use this file except in compliance with the License.
|
|
644
|
-
* You may obtain a copy of the License at
|
|
645
|
-
*
|
|
646
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
647
|
-
*
|
|
648
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
649
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
650
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
651
|
-
* See the License for the specific language governing permissions and
|
|
652
|
-
* limitations under the License.
|
|
653
|
-
*/class w{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&O(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new w((n,i)=>{this.nextCallback=s=>{this.wrapSuccess(t,s).next(n,i)},this.catchCallback=s=>{this.wrapFailure(e,s).next(n,i)}})}toPromise(){return new Promise((t,e)=>{this.next(t,e)})}wrapUserFunction(t){try{const e=t();return e instanceof w?e:w.resolve(e)}catch(e){return w.reject(e)}}wrapSuccess(t,e){return t?this.wrapUserFunction(()=>t(e)):w.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction(()=>t(e)):w.reject(e)}static resolve(t){return new w((e,n)=>{e(t)})}static reject(t){return new w((e,n)=>{n(t)})}static waitFor(t){return new w((e,n)=>{let i=0,s=0,a=!1;t.forEach(u=>{++i,u.next(()=>{++s,a&&s===i&&e()},c=>n(c))}),a=!0,s===i&&e()})}static or(t){let e=w.resolve(!1);for(const n of t)e=e.next(i=>i?w.resolve(i):n());return e}static forEach(t,e){const n=[];return t.forEach((i,s)=>{n.push(e.call(this,i,s))}),this.waitFor(n)}static mapArray(t,e){return new w((n,i)=>{const s=t.length,a=new Array(s);let u=0;for(let c=0;c<s;c++){const h=c;e(t[h]).next(f=>{a[h]=f,++u,u===s&&n(a)},f=>i(f))}})}static doWhile(t,e){return new w((n,i)=>{const s=()=>{t()===!0?e().next(()=>{s()},i):n()};s()})}}/**
|
|
654
|
-
* @license
|
|
655
|
-
* Copyright 2017 Google LLC
|
|
656
|
-
*
|
|
657
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
658
|
-
* you may not use this file except in compliance with the License.
|
|
659
|
-
* You may obtain a copy of the License at
|
|
660
|
-
*
|
|
661
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
662
|
-
*
|
|
663
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
664
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
665
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
666
|
-
* See the License for the specific language governing permissions and
|
|
667
|
-
* limitations under the License.
|
|
668
|
-
*/class as{constructor(t,e){this.action=t,this.transaction=e,this.aborted=!1,this.V=new vt,this.transaction.oncomplete=()=>{this.V.resolve()},this.transaction.onabort=()=>{e.error?this.V.reject(new Sr(t,e.error)):this.V.resolve()},this.transaction.onerror=n=>{const i=qo(n.target.error);this.V.reject(new Sr(t,i))}}static open(t,e,n,i){try{return new as(e,t.transaction(i,n))}catch(s){throw new Sr(e,s)}}get m(){return this.V.promise}abort(t){t&&this.V.reject(t),this.aborted||(x("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}g(){const t=this.transaction;this.aborted||typeof t.commit!="function"||t.commit()}store(t){const e=this.transaction.objectStore(t);return new Dg(e)}}class Wt{constructor(t,e,n){this.name=t,this.version=e,this.p=n,Wt.S(Ki())===12.2&>("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.")}static delete(t){return x("SimpleDb","Removing database:",t),Ge(window.indexedDB.deleteDatabase(t)).toPromise()}static D(){if(!dl())return!1;if(Wt.v())return!0;const t=Ki(),e=Wt.S(t),n=0<e&&e<10,i=zl(t),s=0<i&&i<4.5;return!(t.indexOf("MSIE ")>0||t.indexOf("Trident/")>0||t.indexOf("Edge/")>0||n||s)}static v(){var t;return typeof process<"u"&&((t=process.__PRIVATE_env)===null||t===void 0?void 0:t.C)==="YES"}static F(t,e){return t.store(e)}static S(t){const e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)}async M(t){return this.db||(x("SimpleDb","Opening database:",this.name),this.db=await new Promise((e,n)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=s=>{const a=s.target.result;e(a)},i.onblocked=()=>{n(new Sr(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=s=>{const a=s.target.error;a.name==="VersionError"?n(new D(P.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.")):a.name==="InvalidStateError"?n(new D(P.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: "+a)):n(new Sr(t,a))},i.onupgradeneeded=s=>{x("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',s.oldVersion);const a=s.target.result;this.p.O(a,i.transaction,s.oldVersion,this.version).next(()=>{x("SimpleDb","Database upgrade to version "+this.version+" complete")})}})),this.N&&(this.db.onversionchange=e=>this.N(e)),this.db}L(t){this.N=t,this.db&&(this.db.onversionchange=e=>t(e))}async runTransaction(t,e,n,i){const s=e==="readonly";let a=0;for(;;){++a;try{this.db=await this.M(t);const u=as.open(this.db,t,s?"readonly":"readwrite",n),c=i(u).next(h=>(u.g(),h)).catch(h=>(u.abort(h),w.reject(h))).toPromise();return c.catch(()=>{}),await u.m,c}catch(u){const c=u,h=c.name!=="FirebaseError"&&a<3;if(x("SimpleDb","Transaction failed with error:",c.message,"Retrying:",h),this.close(),!h)return Promise.reject(c)}}}close(){this.db&&this.db.close(),this.db=void 0}}function zl(r){const t=r.match(/Android ([\d.]+)/i),e=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(e)}class Cg{constructor(t){this.B=t,this.k=!1,this.q=null}get isDone(){return this.k}get K(){return this.q}set cursor(t){this.B=t}done(){this.k=!0}$(t){this.q=t}delete(){return Ge(this.B.delete())}}class Sr extends D{constructor(t,e){super(P.UNAVAILABLE,`IndexedDB transaction '${t}' failed: ${e}`),this.name="IndexedDbTransactionError"}}function De(r){return r.name==="IndexedDbTransactionError"}class Dg{constructor(t){this.store=t}put(t,e){let n;return e!==void 0?(x("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(x("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Ge(n)}add(t){return x("SimpleDb","ADD",this.store.name,t,t),Ge(this.store.add(t))}get(t){return Ge(this.store.get(t)).next(e=>(e===void 0&&(e=null),x("SimpleDb","GET",this.store.name,t,e),e))}delete(t){return x("SimpleDb","DELETE",this.store.name,t),Ge(this.store.delete(t))}count(){return x("SimpleDb","COUNT",this.store.name),Ge(this.store.count())}U(t,e){const n=this.options(t,e),i=n.index?this.store.index(n.index):this.store;if(typeof i.getAll=="function"){const s=i.getAll(n.range);return new w((a,u)=>{s.onerror=c=>{u(c.target.error)},s.onsuccess=c=>{a(c.target.result)}})}{const s=this.cursor(n),a=[];return this.W(s,(u,c)=>{a.push(c)}).next(()=>a)}}G(t,e){const n=this.store.getAll(t,e===null?void 0:e);return new w((i,s)=>{n.onerror=a=>{s(a.target.error)},n.onsuccess=a=>{i(a.target.result)}})}j(t,e){x("SimpleDb","DELETE ALL",this.store.name);const n=this.options(t,e);n.H=!1;const i=this.cursor(n);return this.W(i,(s,a,u)=>u.delete())}J(t,e){let n;e?n=t:(n={},e=t);const i=this.cursor(n);return this.W(i,e)}Y(t){const e=this.cursor({});return new w((n,i)=>{e.onerror=s=>{const a=qo(s.target.error);i(a)},e.onsuccess=s=>{const a=s.target.result;a?t(a.primaryKey,a.value).next(u=>{u?a.continue():n()}):n()}})}W(t,e){const n=[];return new w((i,s)=>{t.onerror=a=>{s(a.target.error)},t.onsuccess=a=>{const u=a.target.result;if(!u)return void i();const c=new Cg(u),h=e(u.primaryKey,u.value,c);if(h instanceof w){const f=h.catch(g=>(c.done(),w.reject(g)));n.push(f)}c.isDone?i():c.K===null?u.continue():u.continue(c.K)}}).next(()=>w.waitFor(n))}options(t,e){let n;return t!==void 0&&(typeof t=="string"?n=t:e=t),{index:n,range:e}}cursor(t){let e="next";if(t.reverse&&(e="prev"),t.index){const n=this.store.index(t.index);return t.H?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)}}function Ge(r){return new w((t,e)=>{r.onsuccess=n=>{const i=n.target.result;t(i)},r.onerror=n=>{const i=qo(n.target.error);e(i)}})}let Wu=!1;function qo(r){const t=Wt.S(Ki());if(t>=12.2&&t<13){const e="An internal error was encountered in the Indexed Database server";if(r.message.indexOf(e)>=0){const n=new D("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${e}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Wu||(Wu=!0,setTimeout(()=>{throw n},0)),n}}return r}class xg{constructor(t,e){this.asyncQueue=t,this.Z=e,this.task=null}start(){this.X(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}X(t){x("IndexBackfiller",`Scheduled in ${t}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",t,async()=>{this.task=null;try{x("IndexBackfiller",`Documents written: ${await this.Z.ee()}`)}catch(e){De(e)?x("IndexBackfiller","Ignoring IndexedDB error during index backfill: ",e):await Ce(e)}await this.X(6e4)})}}class Ng{constructor(t,e){this.localStore=t,this.persistence=e}async ee(t=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",e=>this.te(e,t))}te(t,e){const n=new Set;let i=e,s=!0;return w.doWhile(()=>s===!0&&i>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(t).next(a=>{if(a!==null&&!n.has(a))return x("IndexBackfiller",`Processing collection: ${a}`),this.ne(t,a,i).next(u=>{i-=u,n.add(a)});s=!1})).next(()=>e-i)}ne(t,e,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(t,e).next(i=>this.localStore.localDocuments.getNextDocuments(t,e,i,n).next(s=>{const a=s.changes;return this.localStore.indexManager.updateIndexEntries(t,a).next(()=>this.re(i,s)).next(u=>(x("IndexBackfiller",`Updating offset: ${u}`),this.localStore.indexManager.updateCollectionGroup(t,e,u))).next(()=>a.size)}))}re(t,e){let n=t;return e.changes.forEach((i,s)=>{const a=Bl(s);Uo(a,n)>0&&(n=a)}),new zt(n.readTime,n.documentKey,Math.max(e.batchId,t.largestBatchId))}}/**
|
|
669
|
-
* @license
|
|
670
|
-
* Copyright 2018 Google LLC
|
|
671
|
-
*
|
|
672
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
673
|
-
* you may not use this file except in compliance with the License.
|
|
674
|
-
* You may obtain a copy of the License at
|
|
675
|
-
*
|
|
676
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
677
|
-
*
|
|
678
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
679
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
680
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
681
|
-
* See the License for the specific language governing permissions and
|
|
682
|
-
* limitations under the License.
|
|
683
|
-
*/class Ot{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=n=>this.ie(n),this.se=n=>e.writeSequenceNumber(n))}ie(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.se&&this.se(t),t}}Ot.oe=-1;function Wr(r){return r==null}function Lr(r){return r===0&&1/r==-1/0}function jl(r){return typeof r=="number"&&Number.isInteger(r)&&!Lr(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}/**
|
|
684
|
-
* @license
|
|
685
|
-
* Copyright 2017 Google LLC
|
|
686
|
-
*
|
|
687
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
688
|
-
* you may not use this file except in compliance with the License.
|
|
689
|
-
* You may obtain a copy of the License at
|
|
690
|
-
*
|
|
691
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
692
|
-
*
|
|
693
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
694
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
695
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
696
|
-
* See the License for the specific language governing permissions and
|
|
697
|
-
* limitations under the License.
|
|
698
|
-
*/function Nt(r){let t="";for(let e=0;e<r.length;e++)t.length>0&&(t=Hu(t)),t=kg(r.get(e),t);return Hu(t)}function kg(r,t){let e=t;const n=r.length;for(let i=0;i<n;i++){const s=r.charAt(i);switch(s){case"\0":e+="";break;case"":e+="";break;default:e+=s}}return e}function Hu(r){return r+""}function $t(r){const t=r.length;if(L(t>=2),t===2)return L(r.charAt(0)===""&&r.charAt(1)===""),W.emptyPath();const e=t-2,n=[];let i="";for(let s=0;s<t;){const a=r.indexOf("",s);switch((a<0||a>e)&&O(),r.charAt(a+1)){case"":const u=r.substring(s,a);let c;i.length===0?c=u:(i+=u,c=i,i=""),n.push(c);break;case"":i+=r.substring(s,a),i+="\0";break;case"":i+=r.substring(s,a+1);break;default:O()}s=a+2}return new W(n)}/**
|
|
699
|
-
* @license
|
|
700
|
-
* Copyright 2022 Google LLC
|
|
701
|
-
*
|
|
702
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
703
|
-
* you may not use this file except in compliance with the License.
|
|
704
|
-
* You may obtain a copy of the License at
|
|
705
|
-
*
|
|
706
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
707
|
-
*
|
|
708
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
709
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
710
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
711
|
-
* See the License for the specific language governing permissions and
|
|
712
|
-
* limitations under the License.
|
|
713
|
-
*/const Ju=["userId","batchId"];/**
|
|
714
|
-
* @license
|
|
715
|
-
* Copyright 2022 Google LLC
|
|
716
|
-
*
|
|
717
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
718
|
-
* you may not use this file except in compliance with the License.
|
|
719
|
-
* You may obtain a copy of the License at
|
|
720
|
-
*
|
|
721
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
722
|
-
*
|
|
723
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
724
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
725
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
726
|
-
* See the License for the specific language governing permissions and
|
|
727
|
-
* limitations under the License.
|
|
728
|
-
*/function Oi(r,t){return[r,Nt(t)]}function Gl(r,t,e){return[r,Nt(t),e]}const Fg={},Mg=["prefixPath","collectionGroup","readTime","documentId"],Og=["prefixPath","collectionGroup","documentId"],Lg=["collectionGroup","readTime","prefixPath","documentId"],Bg=["canonicalId","targetId"],Ug=["targetId","path"],qg=["path","targetId"],zg=["collectionId","parent"],jg=["indexId","uid"],Gg=["uid","sequenceNumber"],Kg=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],$g=["indexId","uid","orderedDocumentKey"],Qg=["userId","collectionPath","documentId"],Wg=["userId","collectionPath","largestBatchId"],Hg=["userId","collectionGroup","largestBatchId"],Kl=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],Jg=[...Kl,"documentOverlays"],$l=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],Ql=$l,zo=[...Ql,"indexConfiguration","indexState","indexEntries"],Yg=zo,Xg=[...zo,"globals"];/**
|
|
729
|
-
* @license
|
|
730
|
-
* Copyright 2020 Google LLC
|
|
731
|
-
*
|
|
732
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
733
|
-
* you may not use this file except in compliance with the License.
|
|
734
|
-
* You may obtain a copy of the License at
|
|
735
|
-
*
|
|
736
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
737
|
-
*
|
|
738
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
739
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
740
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
741
|
-
* See the License for the specific language governing permissions and
|
|
742
|
-
* limitations under the License.
|
|
743
|
-
*/class po extends ql{constructor(t,e){super(),this._e=t,this.currentSequenceNumber=e}}function It(r,t){const e=k(r);return Wt.F(e._e,t)}/**
|
|
744
|
-
* @license
|
|
745
|
-
* Copyright 2017 Google LLC
|
|
746
|
-
*
|
|
747
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
748
|
-
* you may not use this file except in compliance with the License.
|
|
749
|
-
* You may obtain a copy of the License at
|
|
750
|
-
*
|
|
751
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
752
|
-
*
|
|
753
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
754
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
755
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
756
|
-
* See the License for the specific language governing permissions and
|
|
757
|
-
* limitations under the License.
|
|
758
|
-
*/function Yu(r){let t=0;for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t++;return t}function xe(r,t){for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t(e,r[e])}function Wl(r,t){const e=[];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.push(t(r[n],n,r));return e}function Hl(r){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0}/**
|
|
759
|
-
* @license
|
|
760
|
-
* Copyright 2017 Google LLC
|
|
761
|
-
*
|
|
762
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
763
|
-
* you may not use this file except in compliance with the License.
|
|
764
|
-
* You may obtain a copy of the License at
|
|
765
|
-
*
|
|
766
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
767
|
-
*
|
|
768
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
769
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
770
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
771
|
-
* See the License for the specific language governing permissions and
|
|
772
|
-
* limitations under the License.
|
|
773
|
-
*/class it{constructor(t,e){this.comparator=t,this.root=e||Rt.EMPTY}insert(t,e){return new it(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,Rt.BLACK,null,null))}remove(t){return new it(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Rt.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(n===0)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const i=this.comparator(t,n.key);if(i===0)return e+n.left.size;i<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal((e,n)=>(t(e,n),!1))}toString(){const t=[];return this.inorderTraversal((e,n)=>(t.push(`${e}:${n}`),!1)),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Ci(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Ci(this.root,t,this.comparator,!1)}getReverseIterator(){return new Ci(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Ci(this.root,t,this.comparator,!0)}}class Ci{constructor(t,e,n,i){this.isReverse=i,this.nodeStack=[];let s=1;for(;!t.isEmpty();)if(s=e?n(t.key,e):1,e&&i&&(s*=-1),s<0)t=this.isReverse?t.left:t.right;else{if(s===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class Rt{constructor(t,e,n,i,s){this.key=t,this.value=e,this.color=n??Rt.RED,this.left=i??Rt.EMPTY,this.right=s??Rt.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,i,s){return new Rt(t??this.key,e??this.value,n??this.color,i??this.left,s??this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let i=this;const s=n(t,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(t,e,n),null):s===0?i.copy(null,e,null,null,null):i.copy(null,null,null,null,i.right.insert(t,e,n)),i.fixUp()}removeMin(){if(this.left.isEmpty())return Rt.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,i=this;if(e(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,e),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),e(t,i.key)===0){if(i.right.isEmpty())return Rt.EMPTY;n=i.right.min(),i=i.copy(n.key,n.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,e))}return i.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,Rt.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,Rt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw O();const t=this.left.check();if(t!==this.right.check())throw O();return t+(this.isRed()?0:1)}}Rt.EMPTY=null,Rt.RED=!0,Rt.BLACK=!1;Rt.EMPTY=new class{constructor(){this.size=0}get key(){throw O()}get value(){throw O()}get color(){throw O()}get left(){throw O()}get right(){throw O()}copy(t,e,n,i,s){return this}insert(t,e,n){return new Rt(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
|
|
774
|
-
* @license
|
|
775
|
-
* Copyright 2017 Google LLC
|
|
776
|
-
*
|
|
777
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
778
|
-
* you may not use this file except in compliance with the License.
|
|
779
|
-
* You may obtain a copy of the License at
|
|
780
|
-
*
|
|
781
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
782
|
-
*
|
|
783
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
784
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
785
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
786
|
-
* See the License for the specific language governing permissions and
|
|
787
|
-
* limitations under the License.
|
|
788
|
-
*/class et{constructor(t){this.comparator=t,this.data=new it(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal((e,n)=>(t(e),!1))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,t[1])>=0)return;e(i.key)}}forEachWhile(t,e){let n;for(n=e!==void 0?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Xu(this.data.getIterator())}getIteratorFrom(t){return new Xu(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach(n=>{e=e.add(n)}),e}isEqual(t){if(!(t instanceof et)||this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const i=e.getNext().key,s=n.getNext().key;if(this.comparator(i,s)!==0)return!1}return!0}toArray(){const t=[];return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(t){const e=new et(this.comparator);return e.data=t,e}}class Xu{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function pn(r){return r.hasNext()?r.getNext():void 0}/**
|
|
789
|
-
* @license
|
|
790
|
-
* Copyright 2020 Google LLC
|
|
791
|
-
*
|
|
792
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
793
|
-
* you may not use this file except in compliance with the License.
|
|
794
|
-
* You may obtain a copy of the License at
|
|
795
|
-
*
|
|
796
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
797
|
-
*
|
|
798
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
799
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
800
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
801
|
-
* See the License for the specific language governing permissions and
|
|
802
|
-
* limitations under the License.
|
|
803
|
-
*/class Lt{constructor(t){this.fields=t,t.sort(at.comparator)}static empty(){return new Lt([])}unionWith(t){let e=new et(at.comparator);for(const n of this.fields)e=e.add(n);for(const n of t)e=e.add(n);return new Lt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Vn(this.fields,t.fields,(e,n)=>e.isEqual(n))}}/**
|
|
804
|
-
* @license
|
|
805
|
-
* Copyright 2023 Google LLC
|
|
806
|
-
*
|
|
807
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
808
|
-
* you may not use this file except in compliance with the License.
|
|
809
|
-
* You may obtain a copy of the License at
|
|
810
|
-
*
|
|
811
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
812
|
-
*
|
|
813
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
814
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
815
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
816
|
-
* See the License for the specific language governing permissions and
|
|
817
|
-
* limitations under the License.
|
|
818
|
-
*/class Jl extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
|
|
819
|
-
* @license
|
|
820
|
-
* Copyright 2020 Google LLC
|
|
821
|
-
*
|
|
822
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
823
|
-
* you may not use this file except in compliance with the License.
|
|
824
|
-
* You may obtain a copy of the License at
|
|
825
|
-
*
|
|
826
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
827
|
-
*
|
|
828
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
829
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
830
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
831
|
-
* See the License for the specific language governing permissions and
|
|
832
|
-
* limitations under the License.
|
|
833
|
-
*/function Zg(){return typeof atob<"u"}/**
|
|
834
|
-
* @license
|
|
835
|
-
* Copyright 2020 Google LLC
|
|
836
|
-
*
|
|
837
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
838
|
-
* you may not use this file except in compliance with the License.
|
|
839
|
-
* You may obtain a copy of the License at
|
|
840
|
-
*
|
|
841
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
842
|
-
*
|
|
843
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
844
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
845
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
846
|
-
* See the License for the specific language governing permissions and
|
|
847
|
-
* limitations under the License.
|
|
848
|
-
*/class dt{constructor(t){this.binaryString=t}static fromBase64String(t){const e=function(i){try{return atob(i)}catch(s){throw typeof DOMException<"u"&&s instanceof DOMException?new Jl("Invalid base64 string: "+s):s}}(t);return new dt(e)}static fromUint8Array(t){const e=function(i){let s="";for(let a=0;a<i.length;++a)s+=String.fromCharCode(i[a]);return s}(t);return new dt(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function(e){const n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return n}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return j(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}dt.EMPTY_BYTE_STRING=new dt("");const tp=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ne(r){if(L(!!r),typeof r=="string"){let t=0;const e=tp.exec(r);if(L(!!e),e[1]){let i=e[1];i=(i+"000000000").substr(0,9),t=Number(i)}const n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:t}}return{seconds:ut(r.seconds),nanos:ut(r.nanos)}}function ut(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function re(r){return typeof r=="string"?dt.fromBase64String(r):dt.fromUint8Array(r)}/**
|
|
849
|
-
* @license
|
|
850
|
-
* Copyright 2020 Google LLC
|
|
851
|
-
*
|
|
852
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
853
|
-
* you may not use this file except in compliance with the License.
|
|
854
|
-
* You may obtain a copy of the License at
|
|
855
|
-
*
|
|
856
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
857
|
-
*
|
|
858
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
859
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
860
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
861
|
-
* See the License for the specific language governing permissions and
|
|
862
|
-
* limitations under the License.
|
|
863
|
-
*/function us(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{}).__type__)===null||e===void 0?void 0:e.stringValue)==="server_timestamp"}function cs(r){const t=r.mapValue.fields.__previous_value__;return us(t)?cs(t):t}function Br(r){const t=ne(r.mapValue.fields.__local_write_time__.timestampValue);return new lt(t.seconds,t.nanos)}/**
|
|
864
|
-
* @license
|
|
865
|
-
* Copyright 2017 Google LLC
|
|
866
|
-
*
|
|
867
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
868
|
-
* you may not use this file except in compliance with the License.
|
|
869
|
-
* You may obtain a copy of the License at
|
|
870
|
-
*
|
|
871
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
872
|
-
*
|
|
873
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
874
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
875
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
876
|
-
* See the License for the specific language governing permissions and
|
|
877
|
-
* limitations under the License.
|
|
878
|
-
*/class ep{constructor(t,e,n,i,s,a,u,c,h){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=i,this.ssl=s,this.forceLongPolling=a,this.autoDetectLongPolling=u,this.longPollingOptions=c,this.useFetchStreams=h}}class ve{constructor(t,e){this.projectId=t,this.database=e||"(default)"}static empty(){return new ve("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(t){return t instanceof ve&&t.projectId===this.projectId&&t.database===this.database}}/**
|
|
879
|
-
* @license
|
|
880
|
-
* Copyright 2020 Google LLC
|
|
881
|
-
*
|
|
882
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
883
|
-
* you may not use this file except in compliance with the License.
|
|
884
|
-
* You may obtain a copy of the License at
|
|
885
|
-
*
|
|
886
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
887
|
-
*
|
|
888
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
889
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
890
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
891
|
-
* See the License for the specific language governing permissions and
|
|
892
|
-
* limitations under the License.
|
|
893
|
-
*/const _e={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},Li={nullValue:"NULL_VALUE"};function we(r){return"nullValue"in r?0:"booleanValue"in r?1:"integerValue"in r||"doubleValue"in r?2:"timestampValue"in r?3:"stringValue"in r?5:"bytesValue"in r?6:"referenceValue"in r?7:"geoPointValue"in r?8:"arrayValue"in r?9:"mapValue"in r?us(r)?4:Yl(r)?9007199254740991:ls(r)?10:11:O()}function Jt(r,t){if(r===t)return!0;const e=we(r);if(e!==we(t))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===t.booleanValue;case 4:return Br(r).isEqual(Br(t));case 3:return function(i,s){if(typeof i.timestampValue=="string"&&typeof s.timestampValue=="string"&&i.timestampValue.length===s.timestampValue.length)return i.timestampValue===s.timestampValue;const a=ne(i.timestampValue),u=ne(s.timestampValue);return a.seconds===u.seconds&&a.nanos===u.nanos}(r,t);case 5:return r.stringValue===t.stringValue;case 6:return function(i,s){return re(i.bytesValue).isEqual(re(s.bytesValue))}(r,t);case 7:return r.referenceValue===t.referenceValue;case 8:return function(i,s){return ut(i.geoPointValue.latitude)===ut(s.geoPointValue.latitude)&&ut(i.geoPointValue.longitude)===ut(s.geoPointValue.longitude)}(r,t);case 2:return function(i,s){if("integerValue"in i&&"integerValue"in s)return ut(i.integerValue)===ut(s.integerValue);if("doubleValue"in i&&"doubleValue"in s){const a=ut(i.doubleValue),u=ut(s.doubleValue);return a===u?Lr(a)===Lr(u):isNaN(a)&&isNaN(u)}return!1}(r,t);case 9:return Vn(r.arrayValue.values||[],t.arrayValue.values||[],Jt);case 10:case 11:return function(i,s){const a=i.mapValue.fields||{},u=s.mapValue.fields||{};if(Yu(a)!==Yu(u))return!1;for(const c in a)if(a.hasOwnProperty(c)&&(u[c]===void 0||!Jt(a[c],u[c])))return!1;return!0}(r,t);default:return O()}}function Ur(r,t){return(r.values||[]).find(e=>Jt(e,t))!==void 0}function Ae(r,t){if(r===t)return 0;const e=we(r),n=we(t);if(e!==n)return j(e,n);switch(e){case 0:case 9007199254740991:return 0;case 1:return j(r.booleanValue,t.booleanValue);case 2:return function(s,a){const u=ut(s.integerValue||s.doubleValue),c=ut(a.integerValue||a.doubleValue);return u<c?-1:u>c?1:u===c?0:isNaN(u)?isNaN(c)?0:-1:1}(r,t);case 3:return Zu(r.timestampValue,t.timestampValue);case 4:return Zu(Br(r),Br(t));case 5:return j(r.stringValue,t.stringValue);case 6:return function(s,a){const u=re(s),c=re(a);return u.compareTo(c)}(r.bytesValue,t.bytesValue);case 7:return function(s,a){const u=s.split("/"),c=a.split("/");for(let h=0;h<u.length&&h<c.length;h++){const f=j(u[h],c[h]);if(f!==0)return f}return j(u.length,c.length)}(r.referenceValue,t.referenceValue);case 8:return function(s,a){const u=j(ut(s.latitude),ut(a.latitude));return u!==0?u:j(ut(s.longitude),ut(a.longitude))}(r.geoPointValue,t.geoPointValue);case 9:return tc(r.arrayValue,t.arrayValue);case 10:return function(s,a){var u,c,h,f;const g=s.fields||{},_=a.fields||{},R=(u=g.value)===null||u===void 0?void 0:u.arrayValue,C=(c=_.value)===null||c===void 0?void 0:c.arrayValue,N=j(((h=R==null?void 0:R.values)===null||h===void 0?void 0:h.length)||0,((f=C==null?void 0:C.values)===null||f===void 0?void 0:f.length)||0);return N!==0?N:tc(R,C)}(r.mapValue,t.mapValue);case 11:return function(s,a){if(s===_e.mapValue&&a===_e.mapValue)return 0;if(s===_e.mapValue)return 1;if(a===_e.mapValue)return-1;const u=s.fields||{},c=Object.keys(u),h=a.fields||{},f=Object.keys(h);c.sort(),f.sort();for(let g=0;g<c.length&&g<f.length;++g){const _=j(c[g],f[g]);if(_!==0)return _;const R=Ae(u[c[g]],h[f[g]]);if(R!==0)return R}return j(c.length,f.length)}(r.mapValue,t.mapValue);default:throw O()}}function Zu(r,t){if(typeof r=="string"&&typeof t=="string"&&r.length===t.length)return j(r,t);const e=ne(r),n=ne(t),i=j(e.seconds,n.seconds);return i!==0?i:j(e.nanos,n.nanos)}function tc(r,t){const e=r.values||[],n=t.values||[];for(let i=0;i<e.length&&i<n.length;++i){const s=Ae(e[i],n[i]);if(s)return s}return j(e.length,n.length)}function xn(r){return _o(r)}function _o(r){return"nullValue"in r?"null":"booleanValue"in r?""+r.booleanValue:"integerValue"in r?""+r.integerValue:"doubleValue"in r?""+r.doubleValue:"timestampValue"in r?function(e){const n=ne(e);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(e){return re(e).toBase64()}(r.bytesValue):"referenceValue"in r?function(e){return M.fromName(e).toString()}(r.referenceValue):"geoPointValue"in r?function(e){return`geo(${e.latitude},${e.longitude})`}(r.geoPointValue):"arrayValue"in r?function(e){let n="[",i=!0;for(const s of e.values||[])i?i=!1:n+=",",n+=_o(s);return n+"]"}(r.arrayValue):"mapValue"in r?function(e){const n=Object.keys(e.fields||{}).sort();let i="{",s=!0;for(const a of n)s?s=!1:i+=",",i+=`${a}:${_o(e.fields[a])}`;return i+"}"}(r.mapValue):O()}function Bi(r){switch(we(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=cs(r);return t?16+Bi(t):16;case 5:return 2*r.stringValue.length;case 6:return re(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return function(n){return(n.values||[]).reduce((i,s)=>i+Bi(s),0)}(r.arrayValue);case 10:case 11:return function(n){let i=0;return xe(n.fields,(s,a)=>{i+=s.length+Bi(a)}),i}(r.mapValue);default:throw O()}}function Xe(r,t){return{referenceValue:`projects/${r.projectId}/databases/${r.database}/documents/${t.path.canonicalString()}`}}function yo(r){return!!r&&"integerValue"in r}function qr(r){return!!r&&"arrayValue"in r}function ec(r){return!!r&&"nullValue"in r}function nc(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function Ui(r){return!!r&&"mapValue"in r}function ls(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{}).__type__)===null||e===void 0?void 0:e.stringValue)==="__vector__"}function Vr(r){if(r.geoPointValue)return{geoPointValue:Object.assign({},r.geoPointValue)};if(r.timestampValue&&typeof r.timestampValue=="object")return{timestampValue:Object.assign({},r.timestampValue)};if(r.mapValue){const t={mapValue:{fields:{}}};return xe(r.mapValue.fields,(e,n)=>t.mapValue.fields[e]=Vr(n)),t}if(r.arrayValue){const t={arrayValue:{values:[]}};for(let e=0;e<(r.arrayValue.values||[]).length;++e)t.arrayValue.values[e]=Vr(r.arrayValue.values[e]);return t}return Object.assign({},r)}function Yl(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}const Xl={mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{}}}}};function np(r){return"nullValue"in r?Li:"booleanValue"in r?{booleanValue:!1}:"integerValue"in r||"doubleValue"in r?{doubleValue:NaN}:"timestampValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in r?{stringValue:""}:"bytesValue"in r?{bytesValue:""}:"referenceValue"in r?Xe(ve.empty(),M.empty()):"geoPointValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in r?{arrayValue:{}}:"mapValue"in r?ls(r)?Xl:{mapValue:{}}:O()}function rp(r){return"nullValue"in r?{booleanValue:!1}:"booleanValue"in r?{doubleValue:NaN}:"integerValue"in r||"doubleValue"in r?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in r?{stringValue:""}:"stringValue"in r?{bytesValue:""}:"bytesValue"in r?Xe(ve.empty(),M.empty()):"referenceValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in r?{arrayValue:{}}:"arrayValue"in r?Xl:"mapValue"in r?ls(r)?{mapValue:{}}:_e:O()}function rc(r,t){const e=Ae(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?-1:!r.inclusive&&t.inclusive?1:0}function ic(r,t){const e=Ae(r.value,t.value);return e!==0?e:r.inclusive&&!t.inclusive?1:!r.inclusive&&t.inclusive?-1:0}/**
|
|
894
|
-
* @license
|
|
895
|
-
* Copyright 2017 Google LLC
|
|
896
|
-
*
|
|
897
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
898
|
-
* you may not use this file except in compliance with the License.
|
|
899
|
-
* You may obtain a copy of the License at
|
|
900
|
-
*
|
|
901
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
902
|
-
*
|
|
903
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
904
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
905
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
906
|
-
* See the License for the specific language governing permissions and
|
|
907
|
-
* limitations under the License.
|
|
908
|
-
*/class bt{constructor(t){this.value=t}static empty(){return new bt({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!Ui(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=Vr(e)}setAll(t){let e=at.emptyPath(),n={},i=[];t.forEach((a,u)=>{if(!e.isImmediateParentOf(u)){const c=this.getFieldsMap(e);this.applyChanges(c,n,i),n={},i=[],e=u.popLast()}a?n[u.lastSegment()]=Vr(a):i.push(u.lastSegment())});const s=this.getFieldsMap(e);this.applyChanges(s,n,i)}delete(t){const e=this.field(t.popLast());Ui(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Jt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let i=e.mapValue.fields[t.get(n)];Ui(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=i),e=i}return e.mapValue.fields}applyChanges(t,e,n){xe(e,(i,s)=>t[i]=s);for(const i of n)delete t[i]}clone(){return new bt(Vr(this.value))}}function Zl(r){const t=[];return xe(r.fields,(e,n)=>{const i=new at([e]);if(Ui(n)){const s=Zl(n.mapValue).fields;if(s.length===0)t.push(i);else for(const a of s)t.push(i.child(a))}else t.push(i)}),new Lt(t)}/**
|
|
909
|
-
* @license
|
|
910
|
-
* Copyright 2017 Google LLC
|
|
911
|
-
*
|
|
912
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
913
|
-
* you may not use this file except in compliance with the License.
|
|
914
|
-
* You may obtain a copy of the License at
|
|
915
|
-
*
|
|
916
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
917
|
-
*
|
|
918
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
919
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
920
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
921
|
-
* See the License for the specific language governing permissions and
|
|
922
|
-
* limitations under the License.
|
|
923
|
-
*/class ot{constructor(t,e,n,i,s,a,u){this.key=t,this.documentType=e,this.version=n,this.readTime=i,this.createTime=s,this.data=a,this.documentState=u}static newInvalidDocument(t){return new ot(t,0,U.min(),U.min(),U.min(),bt.empty(),0)}static newFoundDocument(t,e,n,i){return new ot(t,1,e,U.min(),n,i,0)}static newNoDocument(t,e){return new ot(t,2,e,U.min(),U.min(),bt.empty(),0)}static newUnknownDocument(t,e){return new ot(t,3,e,U.min(),U.min(),bt.empty(),2)}convertToFoundDocument(t,e){return!this.createTime.isEqual(U.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=t),this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=bt.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=bt.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=U.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof ot&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new ot(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/**
|
|
924
|
-
* @license
|
|
925
|
-
* Copyright 2022 Google LLC
|
|
926
|
-
*
|
|
927
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
928
|
-
* you may not use this file except in compliance with the License.
|
|
929
|
-
* You may obtain a copy of the License at
|
|
930
|
-
*
|
|
931
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
932
|
-
*
|
|
933
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
934
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
935
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
936
|
-
* See the License for the specific language governing permissions and
|
|
937
|
-
* limitations under the License.
|
|
938
|
-
*/class Re{constructor(t,e){this.position=t,this.inclusive=e}}function sc(r,t,e){let n=0;for(let i=0;i<r.position.length;i++){const s=t[i],a=r.position[i];if(s.field.isKeyField()?n=M.comparator(M.fromName(a.referenceValue),e.key):n=Ae(a,e.data.field(s.field)),s.dir==="desc"&&(n*=-1),n!==0)break}return n}function oc(r,t){if(r===null)return t===null;if(t===null||r.inclusive!==t.inclusive||r.position.length!==t.position.length)return!1;for(let e=0;e<r.position.length;e++)if(!Jt(r.position[e],t.position[e]))return!1;return!0}/**
|
|
939
|
-
* @license
|
|
940
|
-
* Copyright 2022 Google LLC
|
|
941
|
-
*
|
|
942
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
943
|
-
* you may not use this file except in compliance with the License.
|
|
944
|
-
* You may obtain a copy of the License at
|
|
945
|
-
*
|
|
946
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
947
|
-
*
|
|
948
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
949
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
950
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
951
|
-
* See the License for the specific language governing permissions and
|
|
952
|
-
* limitations under the License.
|
|
953
|
-
*/class zr{constructor(t,e="asc"){this.field=t,this.dir=e}}function ip(r,t){return r.dir===t.dir&&r.field.isEqual(t.field)}/**
|
|
954
|
-
* @license
|
|
955
|
-
* Copyright 2022 Google LLC
|
|
956
|
-
*
|
|
957
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
958
|
-
* you may not use this file except in compliance with the License.
|
|
959
|
-
* You may obtain a copy of the License at
|
|
960
|
-
*
|
|
961
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
962
|
-
*
|
|
963
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
964
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
965
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
966
|
-
* See the License for the specific language governing permissions and
|
|
967
|
-
* limitations under the License.
|
|
968
|
-
*/class th{}class H extends th{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?e==="in"||e==="not-in"?this.createKeyFieldInFilter(t,e,n):new sp(t,e,n):e==="array-contains"?new up(t,n):e==="in"?new oh(t,n):e==="not-in"?new cp(t,n):e==="array-contains-any"?new lp(t,n):new H(t,e,n)}static createKeyFieldInFilter(t,e,n){return e==="in"?new op(t,n):new ap(t,n)}matches(t){const e=t.data.field(this.field);return this.op==="!="?e!==null&&this.matchesComparison(Ae(e,this.value)):e!==null&&we(this.value)===we(e)&&this.matchesComparison(Ae(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return t===0;case"!=":return t!==0;case">":return t>0;case">=":return t>=0;default:return O()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class tt extends th{constructor(t,e){super(),this.filters=t,this.op=e,this.ae=null}static create(t,e){return new tt(t,e)}matches(t){return Nn(this)?this.filters.find(e=>!e.matches(t))===void 0:this.filters.find(e=>e.matches(t))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((t,e)=>t.concat(e.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function Nn(r){return r.op==="and"}function Io(r){return r.op==="or"}function jo(r){return eh(r)&&Nn(r)}function eh(r){for(const t of r.filters)if(t instanceof tt)return!1;return!0}function Eo(r){if(r instanceof H)return r.field.canonicalString()+r.op.toString()+xn(r.value);if(jo(r))return r.filters.map(t=>Eo(t)).join(",");{const t=r.filters.map(e=>Eo(e)).join(",");return`${r.op}(${t})`}}function nh(r,t){return r instanceof H?function(n,i){return i instanceof H&&n.op===i.op&&n.field.isEqual(i.field)&&Jt(n.value,i.value)}(r,t):r instanceof tt?function(n,i){return i instanceof tt&&n.op===i.op&&n.filters.length===i.filters.length?n.filters.reduce((s,a,u)=>s&&nh(a,i.filters[u]),!0):!1}(r,t):void O()}function rh(r,t){const e=r.filters.concat(t);return tt.create(e,r.op)}function ih(r){return r instanceof H?function(e){return`${e.field.canonicalString()} ${e.op} ${xn(e.value)}`}(r):r instanceof tt?function(e){return e.op.toString()+" {"+e.getFilters().map(ih).join(" ,")+"}"}(r):"Filter"}class sp extends H{constructor(t,e,n){super(t,e,n),this.key=M.fromName(n.referenceValue)}matches(t){const e=M.comparator(t.key,this.key);return this.matchesComparison(e)}}class op extends H{constructor(t,e){super(t,"in",e),this.keys=sh("in",e)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class ap extends H{constructor(t,e){super(t,"not-in",e),this.keys=sh("not-in",e)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function sh(r,t){var e;return(((e=t.arrayValue)===null||e===void 0?void 0:e.values)||[]).map(n=>M.fromName(n.referenceValue))}class up extends H{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return qr(e)&&Ur(e.arrayValue,this.value)}}class oh extends H{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return e!==null&&Ur(this.value.arrayValue,e)}}class cp extends H{constructor(t,e){super(t,"not-in",e)}matches(t){if(Ur(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return e!==null&&!Ur(this.value.arrayValue,e)}}class lp extends H{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!qr(e)||!e.arrayValue.values)&&e.arrayValue.values.some(n=>Ur(this.value.arrayValue,n))}}/**
|
|
969
|
-
* @license
|
|
970
|
-
* Copyright 2019 Google LLC
|
|
971
|
-
*
|
|
972
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
973
|
-
* you may not use this file except in compliance with the License.
|
|
974
|
-
* You may obtain a copy of the License at
|
|
975
|
-
*
|
|
976
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
977
|
-
*
|
|
978
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
979
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
980
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
981
|
-
* See the License for the specific language governing permissions and
|
|
982
|
-
* limitations under the License.
|
|
983
|
-
*/class hp{constructor(t,e=null,n=[],i=[],s=null,a=null,u=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=i,this.limit=s,this.startAt=a,this.endAt=u,this.ue=null}}function To(r,t=null,e=[],n=[],i=null,s=null,a=null){return new hp(r,t,e,n,i,s,a)}function Ze(r){const t=k(r);if(t.ue===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(n=>Eo(n)).join(","),e+="|ob:",e+=t.orderBy.map(n=>function(s){return s.field.canonicalString()+s.dir}(n)).join(","),Wr(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(n=>xn(n)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(n=>xn(n)).join(",")),t.ue=e}return t.ue}function Hr(r,t){if(r.limit!==t.limit||r.orderBy.length!==t.orderBy.length)return!1;for(let e=0;e<r.orderBy.length;e++)if(!ip(r.orderBy[e],t.orderBy[e]))return!1;if(r.filters.length!==t.filters.length)return!1;for(let e=0;e<r.filters.length;e++)if(!nh(r.filters[e],t.filters[e]))return!1;return r.collectionGroup===t.collectionGroup&&!!r.path.isEqual(t.path)&&!!oc(r.startAt,t.startAt)&&oc(r.endAt,t.endAt)}function Qi(r){return M.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}function Wi(r,t){return r.filters.filter(e=>e instanceof H&&e.field.isEqual(t))}function ac(r,t,e){let n=Li,i=!0;for(const s of Wi(r,t)){let a=Li,u=!0;switch(s.op){case"<":case"<=":a=np(s.value);break;case"==":case"in":case">=":a=s.value;break;case">":a=s.value,u=!1;break;case"!=":case"not-in":a=Li}rc({value:n,inclusive:i},{value:a,inclusive:u})<0&&(n=a,i=u)}if(e!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(t)){const a=e.position[s];rc({value:n,inclusive:i},{value:a,inclusive:e.inclusive})<0&&(n=a,i=e.inclusive);break}}return{value:n,inclusive:i}}function uc(r,t,e){let n=_e,i=!0;for(const s of Wi(r,t)){let a=_e,u=!0;switch(s.op){case">=":case">":a=rp(s.value),u=!1;break;case"==":case"in":case"<=":a=s.value;break;case"<":a=s.value,u=!1;break;case"!=":case"not-in":a=_e}ic({value:n,inclusive:i},{value:a,inclusive:u})>0&&(n=a,i=u)}if(e!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(t)){const a=e.position[s];ic({value:n,inclusive:i},{value:a,inclusive:e.inclusive})>0&&(n=a,i=e.inclusive);break}}return{value:n,inclusive:i}}/**
|
|
984
|
-
* @license
|
|
985
|
-
* Copyright 2017 Google LLC
|
|
986
|
-
*
|
|
987
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
988
|
-
* you may not use this file except in compliance with the License.
|
|
989
|
-
* You may obtain a copy of the License at
|
|
990
|
-
*
|
|
991
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
992
|
-
*
|
|
993
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
994
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
995
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
996
|
-
* See the License for the specific language governing permissions and
|
|
997
|
-
* limitations under the License.
|
|
998
|
-
*/class ie{constructor(t,e=null,n=[],i=[],s=null,a="F",u=null,c=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=i,this.limit=s,this.limitType=a,this.startAt=u,this.endAt=c,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function ah(r,t,e,n,i,s,a,u){return new ie(r,t,e,n,i,s,a,u)}function Kn(r){return new ie(r)}function cc(r){return r.filters.length===0&&r.limit===null&&r.startAt==null&&r.endAt==null&&(r.explicitOrderBy.length===0||r.explicitOrderBy.length===1&&r.explicitOrderBy[0].field.isKeyField())}function Go(r){return r.collectionGroup!==null}function An(r){const t=k(r);if(t.ce===null){t.ce=[];const e=new Set;for(const s of t.explicitOrderBy)t.ce.push(s),e.add(s.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(a){let u=new et(at.comparator);return a.filters.forEach(c=>{c.getFlattenedFilters().forEach(h=>{h.isInequality()&&(u=u.add(h.field))})}),u})(t).forEach(s=>{e.has(s.canonicalString())||s.isKeyField()||t.ce.push(new zr(s,n))}),e.has(at.keyField().canonicalString())||t.ce.push(new zr(at.keyField(),n))}return t.ce}function kt(r){const t=k(r);return t.le||(t.le=ch(t,An(r))),t.le}function uh(r){const t=k(r);return t.he||(t.he=ch(t,r.explicitOrderBy)),t.he}function ch(r,t){if(r.limitType==="F")return To(r.path,r.collectionGroup,t,r.filters,r.limit,r.startAt,r.endAt);{t=t.map(i=>{const s=i.dir==="desc"?"asc":"desc";return new zr(i.field,s)});const e=r.endAt?new Re(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new Re(r.startAt.position,r.startAt.inclusive):null;return To(r.path,r.collectionGroup,t,r.filters,r.limit,e,n)}}function vo(r,t){const e=r.filters.concat([t]);return new ie(r.path,r.collectionGroup,r.explicitOrderBy.slice(),e,r.limit,r.limitType,r.startAt,r.endAt)}function Hi(r,t,e){return new ie(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),t,e,r.startAt,r.endAt)}function Jr(r,t){return Hr(kt(r),kt(t))&&r.limitType===t.limitType}function lh(r){return`${Ze(kt(r))}|lt:${r.limitType}`}function Tn(r){return`Query(target=${function(e){let n=e.path.canonicalString();return e.collectionGroup!==null&&(n+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(n+=`, filters: [${e.filters.map(i=>ih(i)).join(", ")}]`),Wr(e.limit)||(n+=", limit: "+e.limit),e.orderBy.length>0&&(n+=`, orderBy: [${e.orderBy.map(i=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(i)).join(", ")}]`),e.startAt&&(n+=", startAt: ",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(i=>xn(i)).join(",")),e.endAt&&(n+=", endAt: ",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(i=>xn(i)).join(",")),`Target(${n})`}(kt(r))}; limitType=${r.limitType})`}function Yr(r,t){return t.isFoundDocument()&&function(n,i){const s=i.key.path;return n.collectionGroup!==null?i.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(s):M.isDocumentKey(n.path)?n.path.isEqual(s):n.path.isImmediateParentOf(s)}(r,t)&&function(n,i){for(const s of An(n))if(!s.field.isKeyField()&&i.data.field(s.field)===null)return!1;return!0}(r,t)&&function(n,i){for(const s of n.filters)if(!s.matches(i))return!1;return!0}(r,t)&&function(n,i){return!(n.startAt&&!function(a,u,c){const h=sc(a,u,c);return a.inclusive?h<=0:h<0}(n.startAt,An(n),i)||n.endAt&&!function(a,u,c){const h=sc(a,u,c);return a.inclusive?h>=0:h>0}(n.endAt,An(n),i))}(r,t)}function hh(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function dh(r){return(t,e)=>{let n=!1;for(const i of An(r)){const s=dp(i,t,e);if(s!==0)return s;n=n||i.field.isKeyField()}return 0}}function dp(r,t,e){const n=r.field.isKeyField()?M.comparator(t.key,e.key):function(s,a,u){const c=a.data.field(s),h=u.data.field(s);return c!==null&&h!==null?Ae(c,h):O()}(r.field,t,e);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return O()}}/**
|
|
999
|
-
* @license
|
|
1000
|
-
* Copyright 2017 Google LLC
|
|
1001
|
-
*
|
|
1002
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1003
|
-
* you may not use this file except in compliance with the License.
|
|
1004
|
-
* You may obtain a copy of the License at
|
|
1005
|
-
*
|
|
1006
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1007
|
-
*
|
|
1008
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1009
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1010
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1011
|
-
* See the License for the specific language governing permissions and
|
|
1012
|
-
* limitations under the License.
|
|
1013
|
-
*/class se{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n!==void 0){for(const[i,s]of n)if(this.equalsFn(i,t))return s}}has(t){return this.get(t)!==void 0}set(t,e){const n=this.mapKeyFn(t),i=this.inner[n];if(i===void 0)return this.inner[n]=[[t,e]],void this.innerSize++;for(let s=0;s<i.length;s++)if(this.equalsFn(i[s][0],t))return void(i[s]=[t,e]);i.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n===void 0)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],t))return n.length===1?delete this.inner[e]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(t){xe(this.inner,(e,n)=>{for(const[i,s]of n)t(i,s)})}isEmpty(){return Hl(this.inner)}size(){return this.innerSize}}/**
|
|
1014
|
-
* @license
|
|
1015
|
-
* Copyright 2017 Google LLC
|
|
1016
|
-
*
|
|
1017
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1018
|
-
* you may not use this file except in compliance with the License.
|
|
1019
|
-
* You may obtain a copy of the License at
|
|
1020
|
-
*
|
|
1021
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1022
|
-
*
|
|
1023
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1024
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1025
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1026
|
-
* See the License for the specific language governing permissions and
|
|
1027
|
-
* limitations under the License.
|
|
1028
|
-
*/const fp=new it(M.comparator);function Bt(){return fp}const fh=new it(M.comparator);function Rr(...r){let t=fh;for(const e of r)t=t.insert(e.key,e);return t}function mh(r){let t=fh;return r.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function Qt(){return Cr()}function gh(){return Cr()}function Cr(){return new se(r=>r.toString(),(r,t)=>r.isEqual(t))}const mp=new it(M.comparator),gp=new et(M.comparator);function G(...r){let t=gp;for(const e of r)t=t.add(e);return t}const pp=new et(j);function Ko(){return pp}/**
|
|
1029
|
-
* @license
|
|
1030
|
-
* Copyright 2020 Google LLC
|
|
1031
|
-
*
|
|
1032
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1033
|
-
* you may not use this file except in compliance with the License.
|
|
1034
|
-
* You may obtain a copy of the License at
|
|
1035
|
-
*
|
|
1036
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1037
|
-
*
|
|
1038
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1039
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1040
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1041
|
-
* See the License for the specific language governing permissions and
|
|
1042
|
-
* limitations under the License.
|
|
1043
|
-
*/function $o(r,t){if(r.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Lr(t)?"-0":t}}function ph(r){return{integerValue:""+r}}function _h(r,t){return jl(t)?ph(t):$o(r,t)}/**
|
|
1044
|
-
* @license
|
|
1045
|
-
* Copyright 2018 Google LLC
|
|
1046
|
-
*
|
|
1047
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1048
|
-
* you may not use this file except in compliance with the License.
|
|
1049
|
-
* You may obtain a copy of the License at
|
|
1050
|
-
*
|
|
1051
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1052
|
-
*
|
|
1053
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1054
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1055
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1056
|
-
* See the License for the specific language governing permissions and
|
|
1057
|
-
* limitations under the License.
|
|
1058
|
-
*/class hs{constructor(){this._=void 0}}function _p(r,t,e){return r instanceof kn?function(i,s){const a={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return s&&us(s)&&(s=cs(s)),s&&(a.fields.__previous_value__=s),{mapValue:a}}(e,t):r instanceof tn?Ih(r,t):r instanceof en?Eh(r,t):function(i,s){const a=yh(i,s),u=lc(a)+lc(i.Pe);return yo(a)&&yo(i.Pe)?ph(u):$o(i.serializer,u)}(r,t)}function yp(r,t,e){return r instanceof tn?Ih(r,t):r instanceof en?Eh(r,t):e}function yh(r,t){return r instanceof Fn?function(n){return yo(n)||function(s){return!!s&&"doubleValue"in s}(n)}(t)?t:{integerValue:0}:null}class kn extends hs{}class tn extends hs{constructor(t){super(),this.elements=t}}function Ih(r,t){const e=Th(t);for(const n of r.elements)e.some(i=>Jt(i,n))||e.push(n);return{arrayValue:{values:e}}}class en extends hs{constructor(t){super(),this.elements=t}}function Eh(r,t){let e=Th(t);for(const n of r.elements)e=e.filter(i=>!Jt(i,n));return{arrayValue:{values:e}}}class Fn extends hs{constructor(t,e){super(),this.serializer=t,this.Pe=e}}function lc(r){return ut(r.integerValue||r.doubleValue)}function Th(r){return qr(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}/**
|
|
1059
|
-
* @license
|
|
1060
|
-
* Copyright 2017 Google LLC
|
|
1061
|
-
*
|
|
1062
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1063
|
-
* you may not use this file except in compliance with the License.
|
|
1064
|
-
* You may obtain a copy of the License at
|
|
1065
|
-
*
|
|
1066
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1067
|
-
*
|
|
1068
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1069
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1070
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1071
|
-
* See the License for the specific language governing permissions and
|
|
1072
|
-
* limitations under the License.
|
|
1073
|
-
*/class Xr{constructor(t,e){this.field=t,this.transform=e}}function Ip(r,t){return r.field.isEqual(t.field)&&function(n,i){return n instanceof tn&&i instanceof tn||n instanceof en&&i instanceof en?Vn(n.elements,i.elements,Jt):n instanceof Fn&&i instanceof Fn?Jt(n.Pe,i.Pe):n instanceof kn&&i instanceof kn}(r.transform,t.transform)}class Ep{constructor(t,e){this.version=t,this.transformResults=e}}class ct{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new ct}static exists(t){return new ct(void 0,t)}static updateTime(t){return new ct(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function qi(r,t){return r.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(r.updateTime):r.exists===void 0||r.exists===t.isFoundDocument()}class ds{}function vh(r,t){if(!r.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return r.isNoDocument()?new Qn(r.key,ct.none()):new $n(r.key,r.data,ct.none());{const e=r.data,n=bt.empty();let i=new et(at.comparator);for(let s of t.fields)if(!i.has(s)){let a=e.field(s);a===null&&s.length>1&&(s=s.popLast(),a=e.field(s)),a===null?n.delete(s):n.set(s,a),i=i.add(s)}return new oe(r.key,n,new Lt(i.toArray()),ct.none())}}function Tp(r,t,e){r instanceof $n?function(i,s,a){const u=i.value.clone(),c=dc(i.fieldTransforms,s,a.transformResults);u.setAll(c),s.convertToFoundDocument(a.version,u).setHasCommittedMutations()}(r,t,e):r instanceof oe?function(i,s,a){if(!qi(i.precondition,s))return void s.convertToUnknownDocument(a.version);const u=dc(i.fieldTransforms,s,a.transformResults),c=s.data;c.setAll(wh(i)),c.setAll(u),s.convertToFoundDocument(a.version,c).setHasCommittedMutations()}(r,t,e):function(i,s,a){s.convertToNoDocument(a.version).setHasCommittedMutations()}(0,t,e)}function Dr(r,t,e,n){return r instanceof $n?function(s,a,u,c){if(!qi(s.precondition,a))return u;const h=s.value.clone(),f=fc(s.fieldTransforms,c,a);return h.setAll(f),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),null}(r,t,e,n):r instanceof oe?function(s,a,u,c){if(!qi(s.precondition,a))return u;const h=fc(s.fieldTransforms,c,a),f=a.data;return f.setAll(wh(s)),f.setAll(h),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),u===null?null:u.unionWith(s.fieldMask.fields).unionWith(s.fieldTransforms.map(g=>g.field))}(r,t,e,n):function(s,a,u){return qi(s.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):u}(r,t,e)}function vp(r,t){let e=null;for(const n of r.fieldTransforms){const i=t.data.field(n.field),s=yh(n.transform,i||null);s!=null&&(e===null&&(e=bt.empty()),e.set(n.field,s))}return e||null}function hc(r,t){return r.type===t.type&&!!r.key.isEqual(t.key)&&!!r.precondition.isEqual(t.precondition)&&!!function(n,i){return n===void 0&&i===void 0||!(!n||!i)&&Vn(n,i,(s,a)=>Ip(s,a))}(r.fieldTransforms,t.fieldTransforms)&&(r.type===0?r.value.isEqual(t.value):r.type!==1||r.data.isEqual(t.data)&&r.fieldMask.isEqual(t.fieldMask))}class $n extends ds{constructor(t,e,n,i=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class oe extends ds{constructor(t,e,n,i,s=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=i,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function wh(r){const t=new Map;return r.fieldMask.fields.forEach(e=>{if(!e.isEmpty()){const n=r.data.field(e);t.set(e,n)}}),t}function dc(r,t,e){const n=new Map;L(r.length===e.length);for(let i=0;i<e.length;i++){const s=r[i],a=s.transform,u=t.data.field(s.field);n.set(s.field,yp(a,u,e[i]))}return n}function fc(r,t,e){const n=new Map;for(const i of r){const s=i.transform,a=e.data.field(i.field);n.set(i.field,_p(s,a,t))}return n}class Qn extends ds{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Qo extends ds{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
|
|
1074
|
-
* @license
|
|
1075
|
-
* Copyright 2017 Google LLC
|
|
1076
|
-
*
|
|
1077
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1078
|
-
* you may not use this file except in compliance with the License.
|
|
1079
|
-
* You may obtain a copy of the License at
|
|
1080
|
-
*
|
|
1081
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1082
|
-
*
|
|
1083
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1084
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1085
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1086
|
-
* See the License for the specific language governing permissions and
|
|
1087
|
-
* limitations under the License.
|
|
1088
|
-
*/class Wo{constructor(t,e,n,i){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let i=0;i<this.mutations.length;i++){const s=this.mutations[i];s.key.isEqual(t.key)&&Tp(s,t,n[i])}}applyToLocalView(t,e){for(const n of this.baseMutations)n.key.isEqual(t.key)&&(e=Dr(n,t,e,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(t.key)&&(e=Dr(n,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){const n=gh();return this.mutations.forEach(i=>{const s=t.get(i.key),a=s.overlayedDocument;let u=this.applyToLocalView(a,s.mutatedFields);u=e.has(i.key)?null:u;const c=vh(a,u);c!==null&&n.set(i.key,c),a.isValidDocument()||a.convertToNoDocument(U.min())}),n}keys(){return this.mutations.reduce((t,e)=>t.add(e.key),G())}isEqual(t){return this.batchId===t.batchId&&Vn(this.mutations,t.mutations,(e,n)=>hc(e,n))&&Vn(this.baseMutations,t.baseMutations,(e,n)=>hc(e,n))}}class Ho{constructor(t,e,n,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=i}static from(t,e,n){L(t.mutations.length===n.length);let i=function(){return mp}();const s=t.mutations;for(let a=0;a<s.length;a++)i=i.insert(s[a].key,n[a].version);return new Ho(t,e,n,i)}}/**
|
|
1089
|
-
* @license
|
|
1090
|
-
* Copyright 2022 Google LLC
|
|
1091
|
-
*
|
|
1092
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1093
|
-
* you may not use this file except in compliance with the License.
|
|
1094
|
-
* You may obtain a copy of the License at
|
|
1095
|
-
*
|
|
1096
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1097
|
-
*
|
|
1098
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1099
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1100
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1101
|
-
* See the License for the specific language governing permissions and
|
|
1102
|
-
* limitations under the License.
|
|
1103
|
-
*/class Jo{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return t!==null&&this.mutation===t.mutation}toString(){return`Overlay{
|
|
1104
|
-
largestBatchId: ${this.largestBatchId},
|
|
1105
|
-
mutation: ${this.mutation.toString()}
|
|
1106
|
-
}`}}/**
|
|
1107
|
-
* @license
|
|
1108
|
-
* Copyright 2023 Google LLC
|
|
1109
|
-
*
|
|
1110
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1111
|
-
* you may not use this file except in compliance with the License.
|
|
1112
|
-
* You may obtain a copy of the License at
|
|
1113
|
-
*
|
|
1114
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1115
|
-
*
|
|
1116
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1117
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1118
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1119
|
-
* See the License for the specific language governing permissions and
|
|
1120
|
-
* limitations under the License.
|
|
1121
|
-
*/class Ah{constructor(t,e,n){this.alias=t,this.aggregateType=e,this.fieldPath=n}}/**
|
|
1122
|
-
* @license
|
|
1123
|
-
* Copyright 2017 Google LLC
|
|
1124
|
-
*
|
|
1125
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1126
|
-
* you may not use this file except in compliance with the License.
|
|
1127
|
-
* You may obtain a copy of the License at
|
|
1128
|
-
*
|
|
1129
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1130
|
-
*
|
|
1131
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1132
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1133
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1134
|
-
* See the License for the specific language governing permissions and
|
|
1135
|
-
* limitations under the License.
|
|
1136
|
-
*/class wp{constructor(t,e){this.count=t,this.unchangedNames=e}}/**
|
|
1137
|
-
* @license
|
|
1138
|
-
* Copyright 2017 Google LLC
|
|
1139
|
-
*
|
|
1140
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1141
|
-
* you may not use this file except in compliance with the License.
|
|
1142
|
-
* You may obtain a copy of the License at
|
|
1143
|
-
*
|
|
1144
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1145
|
-
*
|
|
1146
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1147
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1148
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1149
|
-
* See the License for the specific language governing permissions and
|
|
1150
|
-
* limitations under the License.
|
|
1151
|
-
*/var _t,Y;function Rh(r){switch(r){default:return O();case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0}}function bh(r){if(r===void 0)return gt("GRPC error has no .code"),P.UNKNOWN;switch(r){case _t.OK:return P.OK;case _t.CANCELLED:return P.CANCELLED;case _t.UNKNOWN:return P.UNKNOWN;case _t.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case _t.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case _t.INTERNAL:return P.INTERNAL;case _t.UNAVAILABLE:return P.UNAVAILABLE;case _t.UNAUTHENTICATED:return P.UNAUTHENTICATED;case _t.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case _t.NOT_FOUND:return P.NOT_FOUND;case _t.ALREADY_EXISTS:return P.ALREADY_EXISTS;case _t.PERMISSION_DENIED:return P.PERMISSION_DENIED;case _t.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case _t.ABORTED:return P.ABORTED;case _t.OUT_OF_RANGE:return P.OUT_OF_RANGE;case _t.UNIMPLEMENTED:return P.UNIMPLEMENTED;case _t.DATA_LOSS:return P.DATA_LOSS;default:return O()}}(Y=_t||(_t={}))[Y.OK=0]="OK",Y[Y.CANCELLED=1]="CANCELLED",Y[Y.UNKNOWN=2]="UNKNOWN",Y[Y.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Y[Y.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Y[Y.NOT_FOUND=5]="NOT_FOUND",Y[Y.ALREADY_EXISTS=6]="ALREADY_EXISTS",Y[Y.PERMISSION_DENIED=7]="PERMISSION_DENIED",Y[Y.UNAUTHENTICATED=16]="UNAUTHENTICATED",Y[Y.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Y[Y.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Y[Y.ABORTED=10]="ABORTED",Y[Y.OUT_OF_RANGE=11]="OUT_OF_RANGE",Y[Y.UNIMPLEMENTED=12]="UNIMPLEMENTED",Y[Y.INTERNAL=13]="INTERNAL",Y[Y.UNAVAILABLE=14]="UNAVAILABLE",Y[Y.DATA_LOSS=15]="DATA_LOSS";/**
|
|
1152
|
-
* @license
|
|
1153
|
-
* Copyright 2023 Google LLC
|
|
1154
|
-
*
|
|
1155
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1156
|
-
* you may not use this file except in compliance with the License.
|
|
1157
|
-
* You may obtain a copy of the License at
|
|
1158
|
-
*
|
|
1159
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1160
|
-
*
|
|
1161
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1162
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1163
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1164
|
-
* See the License for the specific language governing permissions and
|
|
1165
|
-
* limitations under the License.
|
|
1166
|
-
*/let Ji=null;/**
|
|
1167
|
-
* @license
|
|
1168
|
-
* Copyright 2023 Google LLC
|
|
1169
|
-
*
|
|
1170
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1171
|
-
* you may not use this file except in compliance with the License.
|
|
1172
|
-
* You may obtain a copy of the License at
|
|
1173
|
-
*
|
|
1174
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1175
|
-
*
|
|
1176
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1177
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1178
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1179
|
-
* See the License for the specific language governing permissions and
|
|
1180
|
-
* limitations under the License.
|
|
1181
|
-
*/function Ph(){return new TextEncoder}/**
|
|
1182
|
-
* @license
|
|
1183
|
-
* Copyright 2022 Google LLC
|
|
1184
|
-
*
|
|
1185
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1186
|
-
* you may not use this file except in compliance with the License.
|
|
1187
|
-
* You may obtain a copy of the License at
|
|
1188
|
-
*
|
|
1189
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1190
|
-
*
|
|
1191
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1192
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1193
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1194
|
-
* See the License for the specific language governing permissions and
|
|
1195
|
-
* limitations under the License.
|
|
1196
|
-
*/const Ap=new He([4294967295,4294967295],0);function mc(r){const t=Ph().encode(r),e=new Sl;return e.update(t),new Uint8Array(e.digest())}function gc(r){const t=new DataView(r.buffer),e=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new He([e,n],0),new He([i,s],0)]}class Yo{constructor(t,e,n){if(this.bitmap=t,this.padding=e,this.hashCount=n,e<0||e>=8)throw new br(`Invalid padding: ${e}`);if(n<0)throw new br(`Invalid hash count: ${n}`);if(t.length>0&&this.hashCount===0)throw new br(`Invalid hash count: ${n}`);if(t.length===0&&e!==0)throw new br(`Invalid padding when bitmap length is 0: ${e}`);this.Ie=8*t.length-e,this.Te=He.fromNumber(this.Ie)}Ee(t,e,n){let i=t.add(e.multiply(He.fromNumber(n)));return i.compare(Ap)===1&&(i=new He([i.getBits(0),i.getBits(1)],0)),i.modulo(this.Te).toNumber()}de(t){return(this.bitmap[Math.floor(t/8)]&1<<t%8)!=0}mightContain(t){if(this.Ie===0)return!1;const e=mc(t),[n,i]=gc(e);for(let s=0;s<this.hashCount;s++){const a=this.Ee(n,i,s);if(!this.de(a))return!1}return!0}static create(t,e,n){const i=t%8==0?0:8-t%8,s=new Uint8Array(Math.ceil(t/8)),a=new Yo(s,i,e);return n.forEach(u=>a.insert(u)),a}insert(t){if(this.Ie===0)return;const e=mc(t),[n,i]=gc(e);for(let s=0;s<this.hashCount;s++){const a=this.Ee(n,i,s);this.Ae(a)}}Ae(t){const e=Math.floor(t/8),n=t%8;this.bitmap[e]|=1<<n}}class br extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
|
|
1197
|
-
* @license
|
|
1198
|
-
* Copyright 2017 Google LLC
|
|
1199
|
-
*
|
|
1200
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1201
|
-
* you may not use this file except in compliance with the License.
|
|
1202
|
-
* You may obtain a copy of the License at
|
|
1203
|
-
*
|
|
1204
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1205
|
-
*
|
|
1206
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1207
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1208
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1209
|
-
* See the License for the specific language governing permissions and
|
|
1210
|
-
* limitations under the License.
|
|
1211
|
-
*/class Zr{constructor(t,e,n,i,s){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=i,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(t,e,n){const i=new Map;return i.set(t,ti.createSynthesizedTargetChangeForCurrentChange(t,e,n)),new Zr(U.min(),i,new it(j),Bt(),G())}}class ti{constructor(t,e,n,i,s){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=i,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(t,e,n){return new ti(n,e,G(),G(),G())}}/**
|
|
1212
|
-
* @license
|
|
1213
|
-
* Copyright 2017 Google LLC
|
|
1214
|
-
*
|
|
1215
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1216
|
-
* you may not use this file except in compliance with the License.
|
|
1217
|
-
* You may obtain a copy of the License at
|
|
1218
|
-
*
|
|
1219
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1220
|
-
*
|
|
1221
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1222
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1223
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1224
|
-
* See the License for the specific language governing permissions and
|
|
1225
|
-
* limitations under the License.
|
|
1226
|
-
*/class zi{constructor(t,e,n,i){this.Re=t,this.removedTargetIds=e,this.key=n,this.Ve=i}}class Sh{constructor(t,e){this.targetId=t,this.me=e}}class Vh{constructor(t,e,n=dt.EMPTY_BYTE_STRING,i=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=i}}class pc{constructor(){this.fe=0,this.ge=yc(),this.pe=dt.EMPTY_BYTE_STRING,this.ye=!1,this.we=!0}get current(){return this.ye}get resumeToken(){return this.pe}get Se(){return this.fe!==0}get be(){return this.we}De(t){t.approximateByteSize()>0&&(this.we=!0,this.pe=t)}ve(){let t=G(),e=G(),n=G();return this.ge.forEach((i,s)=>{switch(s){case 0:t=t.add(i);break;case 2:e=e.add(i);break;case 1:n=n.add(i);break;default:O()}}),new ti(this.pe,this.ye,t,e,n)}Ce(){this.we=!1,this.ge=yc()}Fe(t,e){this.we=!0,this.ge=this.ge.insert(t,e)}Me(t){this.we=!0,this.ge=this.ge.remove(t)}xe(){this.fe+=1}Oe(){this.fe-=1,L(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class Rp{constructor(t){this.Le=t,this.Be=new Map,this.ke=Bt(),this.qe=_c(),this.Qe=new it(j)}Ke(t){for(const e of t.Re)t.Ve&&t.Ve.isFoundDocument()?this.$e(e,t.Ve):this.Ue(e,t.key,t.Ve);for(const e of t.removedTargetIds)this.Ue(e,t.key,t.Ve)}We(t){this.forEachTarget(t,e=>{const n=this.Ge(e);switch(t.state){case 0:this.ze(e)&&n.De(t.resumeToken);break;case 1:n.Oe(),n.Se||n.Ce(),n.De(t.resumeToken);break;case 2:n.Oe(),n.Se||this.removeTarget(e);break;case 3:this.ze(e)&&(n.Ne(),n.De(t.resumeToken));break;case 4:this.ze(e)&&(this.je(e),n.De(t.resumeToken));break;default:O()}})}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Be.forEach((n,i)=>{this.ze(i)&&e(i)})}He(t){const e=t.targetId,n=t.me.count,i=this.Je(e);if(i){const s=i.target;if(Qi(s))if(n===0){const a=new M(s.path);this.Ue(e,a,ot.newNoDocument(a,U.min()))}else L(n===1);else{const a=this.Ye(e);if(a!==n){const u=this.Ze(t),c=u?this.Xe(u,t,a):1;if(c!==0){this.je(e);const h=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(e,h)}Ji==null||Ji.et(function(f,g,_,R,C){var N,V,q,z,B,$;const Z={localCacheCount:f,existenceFilterCount:g.count,databaseId:_.database,projectId:_.projectId},K=g.unchangedNames;return K&&(Z.bloomFilter={applied:C===0,hashCount:(N=K==null?void 0:K.hashCount)!==null&&N!==void 0?N:0,bitmapLength:(z=(q=(V=K==null?void 0:K.bits)===null||V===void 0?void 0:V.bitmap)===null||q===void 0?void 0:q.length)!==null&&z!==void 0?z:0,padding:($=(B=K==null?void 0:K.bits)===null||B===void 0?void 0:B.padding)!==null&&$!==void 0?$:0,mightContain:E=>{var p;return(p=R==null?void 0:R.mightContain(E))!==null&&p!==void 0&&p}}),Z}(a,t.me,this.Le.tt(),u,c))}}}}Ze(t){const e=t.me.unchangedNames;if(!e||!e.bits)return null;const{bits:{bitmap:n="",padding:i=0},hashCount:s=0}=e;let a,u;try{a=re(n).toUint8Array()}catch(c){if(c instanceof Jl)return qt("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{u=new Yo(a,i,s)}catch(c){return qt(c instanceof br?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return u.Ie===0?null:u}Xe(t,e,n){return e.me.count===n-this.nt(t,e.targetId)?0:2}nt(t,e){const n=this.Le.getRemoteKeysForTarget(e);let i=0;return n.forEach(s=>{const a=this.Le.tt(),u=`projects/${a.projectId}/databases/${a.database}/documents/${s.path.canonicalString()}`;t.mightContain(u)||(this.Ue(e,s,null),i++)}),i}rt(t){const e=new Map;this.Be.forEach((s,a)=>{const u=this.Je(a);if(u){if(s.current&&Qi(u.target)){const c=new M(u.target.path);this.ke.get(c)!==null||this.it(a,c)||this.Ue(a,c,ot.newNoDocument(c,t))}s.be&&(e.set(a,s.ve()),s.Ce())}});let n=G();this.qe.forEach((s,a)=>{let u=!0;a.forEachWhile(c=>{const h=this.Je(c);return!h||h.purpose==="TargetPurposeLimboResolution"||(u=!1,!1)}),u&&(n=n.add(s))}),this.ke.forEach((s,a)=>a.setReadTime(t));const i=new Zr(t,e,this.Qe,this.ke,n);return this.ke=Bt(),this.qe=_c(),this.Qe=new it(j),i}$e(t,e){if(!this.ze(t))return;const n=this.it(t,e.key)?2:0;this.Ge(t).Fe(e.key,n),this.ke=this.ke.insert(e.key,e),this.qe=this.qe.insert(e.key,this.st(e.key).add(t))}Ue(t,e,n){if(!this.ze(t))return;const i=this.Ge(t);this.it(t,e)?i.Fe(e,1):i.Me(e),this.qe=this.qe.insert(e,this.st(e).delete(t)),n&&(this.ke=this.ke.insert(e,n))}removeTarget(t){this.Be.delete(t)}Ye(t){const e=this.Ge(t).ve();return this.Le.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}xe(t){this.Ge(t).xe()}Ge(t){let e=this.Be.get(t);return e||(e=new pc,this.Be.set(t,e)),e}st(t){let e=this.qe.get(t);return e||(e=new et(j),this.qe=this.qe.insert(t,e)),e}ze(t){const e=this.Je(t)!==null;return e||x("WatchChangeAggregator","Detected inactive target",t),e}Je(t){const e=this.Be.get(t);return e&&e.Se?null:this.Le.ot(t)}je(t){this.Be.set(t,new pc),this.Le.getRemoteKeysForTarget(t).forEach(e=>{this.Ue(t,e,null)})}it(t,e){return this.Le.getRemoteKeysForTarget(t).has(e)}}function _c(){return new it(M.comparator)}function yc(){return new it(M.comparator)}const bp={asc:"ASCENDING",desc:"DESCENDING"},Pp={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},Sp={and:"AND",or:"OR"};class Vp{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function wo(r,t){return r.useProto3Json||Wr(t)?t:{value:t}}function Mn(r,t){return r.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function Ch(r,t){return r.useProto3Json?t.toBase64():t.toUint8Array()}function Cp(r,t){return Mn(r,t.toTimestamp())}function pt(r){return L(!!r),U.fromTimestamp(function(e){const n=ne(e);return new lt(n.seconds,n.nanos)}(r))}function Xo(r,t){return Ao(r,t).canonicalString()}function Ao(r,t){const e=function(i){return new W(["projects",i.projectId,"databases",i.database])}(r).child("documents");return t===void 0?e:e.child(t)}function Dh(r){const t=W.fromString(r);return L(qh(t)),t}function jr(r,t){return Xo(r.databaseId,t.path)}function Ht(r,t){const e=Dh(t);if(e.get(1)!==r.databaseId.projectId)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+r.databaseId.projectId);if(e.get(3)!==r.databaseId.database)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+r.databaseId.database);return new M(kh(e))}function xh(r,t){return Xo(r.databaseId,t)}function Nh(r){const t=Dh(r);return t.length===4?W.emptyPath():kh(t)}function Ro(r){return new W(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function kh(r){return L(r.length>4&&r.get(4)==="documents"),r.popFirst(5)}function Ic(r,t,e){return{name:jr(r,t),fields:e.value.mapValue.fields}}function Fh(r,t,e){const n=Ht(r,t.name),i=pt(t.updateTime),s=t.createTime?pt(t.createTime):U.min(),a=new bt({mapValue:{fields:t.fields}}),u=ot.newFoundDocument(n,i,s,a);return e&&u.setHasCommittedMutations(),e?u.setHasCommittedMutations():u}function Dp(r,t){return"found"in t?function(n,i){L(!!i.found),i.found.name,i.found.updateTime;const s=Ht(n,i.found.name),a=pt(i.found.updateTime),u=i.found.createTime?pt(i.found.createTime):U.min(),c=new bt({mapValue:{fields:i.found.fields}});return ot.newFoundDocument(s,a,u,c)}(r,t):"missing"in t?function(n,i){L(!!i.missing),L(!!i.readTime);const s=Ht(n,i.missing),a=pt(i.readTime);return ot.newNoDocument(s,a)}(r,t):O()}function xp(r,t){let e;if("targetChange"in t){t.targetChange;const n=function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:O()}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],s=function(h,f){return h.useProto3Json?(L(f===void 0||typeof f=="string"),dt.fromBase64String(f||"")):(L(f===void 0||f instanceof Buffer||f instanceof Uint8Array),dt.fromUint8Array(f||new Uint8Array))}(r,t.targetChange.resumeToken),a=t.targetChange.cause,u=a&&function(h){const f=h.code===void 0?P.UNKNOWN:bh(h.code);return new D(f,h.message||"")}(a);e=new Vh(n,i,s,u||null)}else if("documentChange"in t){t.documentChange;const n=t.documentChange;n.document,n.document.name,n.document.updateTime;const i=Ht(r,n.document.name),s=pt(n.document.updateTime),a=n.document.createTime?pt(n.document.createTime):U.min(),u=new bt({mapValue:{fields:n.document.fields}}),c=ot.newFoundDocument(i,s,a,u),h=n.targetIds||[],f=n.removedTargetIds||[];e=new zi(h,f,c.key,c)}else if("documentDelete"in t){t.documentDelete;const n=t.documentDelete;n.document;const i=Ht(r,n.document),s=n.readTime?pt(n.readTime):U.min(),a=ot.newNoDocument(i,s),u=n.removedTargetIds||[];e=new zi([],u,a.key,a)}else if("documentRemove"in t){t.documentRemove;const n=t.documentRemove;n.document;const i=Ht(r,n.document),s=n.removedTargetIds||[];e=new zi([],s,i,null)}else{if(!("filter"in t))return O();{t.filter;const n=t.filter;n.targetId;const{count:i=0,unchangedNames:s}=n,a=new wp(i,s),u=n.targetId;e=new Sh(u,a)}}return e}function Gr(r,t){let e;if(t instanceof $n)e={update:Ic(r,t.key,t.value)};else if(t instanceof Qn)e={delete:jr(r,t.key)};else if(t instanceof oe)e={update:Ic(r,t.key,t.data),updateMask:Lp(t.fieldMask)};else{if(!(t instanceof Qo))return O();e={verify:jr(r,t.key)}}return t.fieldTransforms.length>0&&(e.updateTransforms=t.fieldTransforms.map(n=>function(s,a){const u=a.transform;if(u instanceof kn)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(u instanceof tn)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:u.elements}};if(u instanceof en)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:u.elements}};if(u instanceof Fn)return{fieldPath:a.field.canonicalString(),increment:u.Pe};throw O()}(0,n))),t.precondition.isNone||(e.currentDocument=function(i,s){return s.updateTime!==void 0?{updateTime:Cp(i,s.updateTime)}:s.exists!==void 0?{exists:s.exists}:O()}(r,t.precondition)),e}function bo(r,t){const e=t.currentDocument?function(s){return s.updateTime!==void 0?ct.updateTime(pt(s.updateTime)):s.exists!==void 0?ct.exists(s.exists):ct.none()}(t.currentDocument):ct.none(),n=t.updateTransforms?t.updateTransforms.map(i=>function(a,u){let c=null;if("setToServerValue"in u)L(u.setToServerValue==="REQUEST_TIME"),c=new kn;else if("appendMissingElements"in u){const f=u.appendMissingElements.values||[];c=new tn(f)}else if("removeAllFromArray"in u){const f=u.removeAllFromArray.values||[];c=new en(f)}else"increment"in u?c=new Fn(a,u.increment):O();const h=at.fromServerFormat(u.fieldPath);return new Xr(h,c)}(r,i)):[];if(t.update){t.update.name;const i=Ht(r,t.update.name),s=new bt({mapValue:{fields:t.update.fields}});if(t.updateMask){const a=function(c){const h=c.fieldPaths||[];return new Lt(h.map(f=>at.fromServerFormat(f)))}(t.updateMask);return new oe(i,s,a,e,n)}return new $n(i,s,e,n)}if(t.delete){const i=Ht(r,t.delete);return new Qn(i,e)}if(t.verify){const i=Ht(r,t.verify);return new Qo(i,e)}return O()}function Np(r,t){return r&&r.length>0?(L(t!==void 0),r.map(e=>function(i,s){let a=i.updateTime?pt(i.updateTime):pt(s);return a.isEqual(U.min())&&(a=pt(s)),new Ep(a,i.transformResults||[])}(e,t))):[]}function Mh(r,t){return{documents:[xh(r,t.path)]}}function fs(r,t){const e={structuredQuery:{}},n=t.path;let i;t.collectionGroup!==null?(i=n,e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=n.popLast(),e.structuredQuery.from=[{collectionId:n.lastSegment()}]),e.parent=xh(r,i);const s=function(h){if(h.length!==0)return Uh(tt.create(h,"and"))}(t.filters);s&&(e.structuredQuery.where=s);const a=function(h){if(h.length!==0)return h.map(f=>function(_){return{field:me(_.field),direction:Fp(_.dir)}}(f))}(t.orderBy);a&&(e.structuredQuery.orderBy=a);const u=wo(r,t.limit);return u!==null&&(e.structuredQuery.limit=u),t.startAt&&(e.structuredQuery.startAt=function(h){return{before:h.inclusive,values:h.position}}(t.startAt)),t.endAt&&(e.structuredQuery.endAt=function(h){return{before:!h.inclusive,values:h.position}}(t.endAt)),{_t:e,parent:i}}function Oh(r,t,e,n){const{_t:i,parent:s}=fs(r,t),a={},u=[];let c=0;return e.forEach(h=>{const f=n?h.alias:"aggregate_"+c++;a[f]=h.alias,h.aggregateType==="count"?u.push({alias:f,count:{}}):h.aggregateType==="avg"?u.push({alias:f,avg:{field:me(h.fieldPath)}}):h.aggregateType==="sum"&&u.push({alias:f,sum:{field:me(h.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:u,structuredQuery:i.structuredQuery},parent:i.parent},ut:a,parent:s}}function Lh(r){let t=Nh(r.parent);const e=r.structuredQuery,n=e.from?e.from.length:0;let i=null;if(n>0){L(n===1);const f=e.from[0];f.allDescendants?i=f.collectionId:t=t.child(f.collectionId)}let s=[];e.where&&(s=function(g){const _=Bh(g);return _ instanceof tt&&jo(_)?_.getFilters():[_]}(e.where));let a=[];e.orderBy&&(a=function(g){return g.map(_=>function(C){return new zr(vn(C.field),function(V){switch(V){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(C.direction))}(_))}(e.orderBy));let u=null;e.limit&&(u=function(g){let _;return _=typeof g=="object"?g.value:g,Wr(_)?null:_}(e.limit));let c=null;e.startAt&&(c=function(g){const _=!!g.before,R=g.values||[];return new Re(R,_)}(e.startAt));let h=null;return e.endAt&&(h=function(g){const _=!g.before,R=g.values||[];return new Re(R,_)}(e.endAt)),ah(t,i,a,s,u,"F",c,h)}function kp(r,t){const e=function(i){switch(i){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return O()}}(t.purpose);return e==null?null:{"goog-listen-tags":e}}function Bh(r){return r.unaryFilter!==void 0?function(e){switch(e.unaryFilter.op){case"IS_NAN":const n=vn(e.unaryFilter.field);return H.create(n,"==",{doubleValue:NaN});case"IS_NULL":const i=vn(e.unaryFilter.field);return H.create(i,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const s=vn(e.unaryFilter.field);return H.create(s,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=vn(e.unaryFilter.field);return H.create(a,"!=",{nullValue:"NULL_VALUE"});default:return O()}}(r):r.fieldFilter!==void 0?function(e){return H.create(vn(e.fieldFilter.field),function(i){switch(i){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return O()}}(e.fieldFilter.op),e.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(e){return tt.create(e.compositeFilter.filters.map(n=>Bh(n)),function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return O()}}(e.compositeFilter.op))}(r):O()}function Fp(r){return bp[r]}function Mp(r){return Pp[r]}function Op(r){return Sp[r]}function me(r){return{fieldPath:r.canonicalString()}}function vn(r){return at.fromServerFormat(r.fieldPath)}function Uh(r){return r instanceof H?function(e){if(e.op==="=="){if(nc(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NAN"}};if(ec(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(nc(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NOT_NAN"}};if(ec(e.value))return{unaryFilter:{field:me(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:me(e.field),op:Mp(e.op),value:e.value}}}(r):r instanceof tt?function(e){const n=e.getFilters().map(i=>Uh(i));return n.length===1?n[0]:{compositeFilter:{op:Op(e.op),filters:n}}}(r):O()}function Lp(r){const t=[];return r.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function qh(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}/**
|
|
1227
|
-
* @license
|
|
1228
|
-
* Copyright 2017 Google LLC
|
|
1229
|
-
*
|
|
1230
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1231
|
-
* you may not use this file except in compliance with the License.
|
|
1232
|
-
* You may obtain a copy of the License at
|
|
1233
|
-
*
|
|
1234
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1235
|
-
*
|
|
1236
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1237
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1238
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1239
|
-
* See the License for the specific language governing permissions and
|
|
1240
|
-
* limitations under the License.
|
|
1241
|
-
*/class te{constructor(t,e,n,i,s=U.min(),a=U.min(),u=dt.EMPTY_BYTE_STRING,c=null){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=i,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=u,this.expectedCount=c}withSequenceNumber(t){return new te(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,e){return new te(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new te(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new te(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}/**
|
|
1242
|
-
* @license
|
|
1243
|
-
* Copyright 2017 Google LLC
|
|
1244
|
-
*
|
|
1245
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1246
|
-
* you may not use this file except in compliance with the License.
|
|
1247
|
-
* You may obtain a copy of the License at
|
|
1248
|
-
*
|
|
1249
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1250
|
-
*
|
|
1251
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1252
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1253
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1254
|
-
* See the License for the specific language governing permissions and
|
|
1255
|
-
* limitations under the License.
|
|
1256
|
-
*/class zh{constructor(t){this.ct=t}}function Bp(r,t){let e;if(t.document)e=Fh(r.ct,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const n=M.fromSegments(t.noDocument.path),i=rn(t.noDocument.readTime);e=ot.newNoDocument(n,i),t.hasCommittedMutations&&e.setHasCommittedMutations()}else{if(!t.unknownDocument)return O();{const n=M.fromSegments(t.unknownDocument.path),i=rn(t.unknownDocument.version);e=ot.newUnknownDocument(n,i)}}return t.readTime&&e.setReadTime(function(i){const s=new lt(i[0],i[1]);return U.fromTimestamp(s)}(t.readTime)),e}function Ec(r,t){const e=t.key,n={prefixPath:e.getCollectionPath().popLast().toArray(),collectionGroup:e.collectionGroup,documentId:e.path.lastSegment(),readTime:Yi(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())n.document=function(s,a){return{name:jr(s,a.key),fields:a.data.value.mapValue.fields,updateTime:Mn(s,a.version.toTimestamp()),createTime:Mn(s,a.createTime.toTimestamp())}}(r.ct,t);else if(t.isNoDocument())n.noDocument={path:e.path.toArray(),readTime:nn(t.version)};else{if(!t.isUnknownDocument())return O();n.unknownDocument={path:e.path.toArray(),version:nn(t.version)}}return n}function Yi(r){const t=r.toTimestamp();return[t.seconds,t.nanoseconds]}function nn(r){const t=r.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function rn(r){const t=new lt(r.seconds,r.nanoseconds);return U.fromTimestamp(t)}function Ke(r,t){const e=(t.baseMutations||[]).map(s=>bo(r.ct,s));for(let s=0;s<t.mutations.length-1;++s){const a=t.mutations[s];if(s+1<t.mutations.length&&t.mutations[s+1].transform!==void 0){const u=t.mutations[s+1];a.updateTransforms=u.transform.fieldTransforms,t.mutations.splice(s+1,1),++s}}const n=t.mutations.map(s=>bo(r.ct,s)),i=lt.fromMillis(t.localWriteTimeMs);return new Wo(t.batchId,i,e,n)}function Pr(r){const t=rn(r.readTime),e=r.lastLimboFreeSnapshotVersion!==void 0?rn(r.lastLimboFreeSnapshotVersion):U.min();let n;return n=function(s){return s.documents!==void 0}(r.query)?function(s){return L(s.documents.length===1),kt(Kn(Nh(s.documents[0])))}(r.query):function(s){return kt(Lh(s))}(r.query),new te(n,r.targetId,"TargetPurposeListen",r.lastListenSequenceNumber,t,e,dt.fromBase64String(r.resumeToken))}function jh(r,t){const e=nn(t.snapshotVersion),n=nn(t.lastLimboFreeSnapshotVersion);let i;i=Qi(t.target)?Mh(r.ct,t.target):fs(r.ct,t.target)._t;const s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:Ze(t.target),readTime:e,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:n,query:i}}function Zo(r){const t=Lh({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?Hi(t,t.limit,"L"):t}function ro(r,t){return new Jo(t.largestBatchId,bo(r.ct,t.overlayMutation))}function Tc(r,t){const e=t.path.lastSegment();return[r,Nt(t.path.popLast()),e]}function vc(r,t,e,n){return{indexId:r,uid:t,sequenceNumber:e,readTime:nn(n.readTime),documentKey:Nt(n.documentKey.path),largestBatchId:n.largestBatchId}}/**
|
|
1257
|
-
* @license
|
|
1258
|
-
* Copyright 2020 Google LLC
|
|
1259
|
-
*
|
|
1260
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1261
|
-
* you may not use this file except in compliance with the License.
|
|
1262
|
-
* You may obtain a copy of the License at
|
|
1263
|
-
*
|
|
1264
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1265
|
-
*
|
|
1266
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1267
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1268
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1269
|
-
* See the License for the specific language governing permissions and
|
|
1270
|
-
* limitations under the License.
|
|
1271
|
-
*/class Up{getBundleMetadata(t,e){return wc(t).get(e).next(n=>{if(n)return function(s){return{id:s.bundleId,createTime:rn(s.createTime),version:s.version}}(n)})}saveBundleMetadata(t,e){return wc(t).put(function(i){return{bundleId:i.id,createTime:nn(pt(i.createTime)),version:i.version}}(e))}getNamedQuery(t,e){return Ac(t).get(e).next(n=>{if(n)return function(s){return{name:s.name,query:Zo(s.bundledQuery),readTime:rn(s.readTime)}}(n)})}saveNamedQuery(t,e){return Ac(t).put(function(i){return{name:i.name,readTime:nn(pt(i.readTime)),bundledQuery:i.bundledQuery}}(e))}}function wc(r){return It(r,"bundles")}function Ac(r){return It(r,"namedQueries")}/**
|
|
1272
|
-
* @license
|
|
1273
|
-
* Copyright 2022 Google LLC
|
|
1274
|
-
*
|
|
1275
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1276
|
-
* you may not use this file except in compliance with the License.
|
|
1277
|
-
* You may obtain a copy of the License at
|
|
1278
|
-
*
|
|
1279
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1280
|
-
*
|
|
1281
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1282
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1283
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1284
|
-
* See the License for the specific language governing permissions and
|
|
1285
|
-
* limitations under the License.
|
|
1286
|
-
*/class ms{constructor(t,e){this.serializer=t,this.userId=e}static lt(t,e){const n=e.uid||"";return new ms(t,n)}getOverlay(t,e){return Ir(t).get(Tc(this.userId,e)).next(n=>n?ro(this.serializer,n):null)}getOverlays(t,e){const n=Qt();return w.forEach(e,i=>this.getOverlay(t,i).next(s=>{s!==null&&n.set(i,s)})).next(()=>n)}saveOverlays(t,e,n){const i=[];return n.forEach((s,a)=>{const u=new Jo(e,a);i.push(this.ht(t,u))}),w.waitFor(i)}removeOverlaysForBatchId(t,e,n){const i=new Set;e.forEach(a=>i.add(Nt(a.getCollectionPath())));const s=[];return i.forEach(a=>{const u=IDBKeyRange.bound([this.userId,a,n],[this.userId,a,n+1],!1,!0);s.push(Ir(t).j("collectionPathOverlayIndex",u))}),w.waitFor(s)}getOverlaysForCollection(t,e,n){const i=Qt(),s=Nt(e),a=IDBKeyRange.bound([this.userId,s,n],[this.userId,s,Number.POSITIVE_INFINITY],!0);return Ir(t).U("collectionPathOverlayIndex",a).next(u=>{for(const c of u){const h=ro(this.serializer,c);i.set(h.getKey(),h)}return i})}getOverlaysForCollectionGroup(t,e,n,i){const s=Qt();let a;const u=IDBKeyRange.bound([this.userId,e,n],[this.userId,e,Number.POSITIVE_INFINITY],!0);return Ir(t).J({index:"collectionGroupOverlayIndex",range:u},(c,h,f)=>{const g=ro(this.serializer,h);s.size()<i||g.largestBatchId===a?(s.set(g.getKey(),g),a=g.largestBatchId):f.done()}).next(()=>s)}ht(t,e){return Ir(t).put(function(i,s,a){const[u,c,h]=Tc(s,a.mutation.key);return{userId:s,collectionPath:c,documentId:h,collectionGroup:a.mutation.key.getCollectionGroup(),largestBatchId:a.largestBatchId,overlayMutation:Gr(i.ct,a.mutation)}}(this.serializer,this.userId,e))}}function Ir(r){return It(r,"documentOverlays")}/**
|
|
1287
|
-
* @license
|
|
1288
|
-
* Copyright 2024 Google LLC
|
|
1289
|
-
*
|
|
1290
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1291
|
-
* you may not use this file except in compliance with the License.
|
|
1292
|
-
* You may obtain a copy of the License at
|
|
1293
|
-
*
|
|
1294
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1295
|
-
*
|
|
1296
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1297
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1298
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1299
|
-
* See the License for the specific language governing permissions and
|
|
1300
|
-
* limitations under the License.
|
|
1301
|
-
*/class qp{Pt(t){return It(t,"globals")}getSessionToken(t){return this.Pt(t).get("sessionToken").next(e=>{const n=e==null?void 0:e.value;return n?dt.fromUint8Array(n):dt.EMPTY_BYTE_STRING})}setSessionToken(t,e){return this.Pt(t).put({name:"sessionToken",value:e.toUint8Array()})}}/**
|
|
1302
|
-
* @license
|
|
1303
|
-
* Copyright 2021 Google LLC
|
|
1304
|
-
*
|
|
1305
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1306
|
-
* you may not use this file except in compliance with the License.
|
|
1307
|
-
* You may obtain a copy of the License at
|
|
1308
|
-
*
|
|
1309
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1310
|
-
*
|
|
1311
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1312
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1313
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1314
|
-
* See the License for the specific language governing permissions and
|
|
1315
|
-
* limitations under the License.
|
|
1316
|
-
*/class $e{constructor(){}It(t,e){this.Tt(t,e),e.Et()}Tt(t,e){if("nullValue"in t)this.dt(e,5);else if("booleanValue"in t)this.dt(e,10),e.At(t.booleanValue?1:0);else if("integerValue"in t)this.dt(e,15),e.At(ut(t.integerValue));else if("doubleValue"in t){const n=ut(t.doubleValue);isNaN(n)?this.dt(e,13):(this.dt(e,15),Lr(n)?e.At(0):e.At(n))}else if("timestampValue"in t){let n=t.timestampValue;this.dt(e,20),typeof n=="string"&&(n=ne(n)),e.Rt(`${n.seconds||""}`),e.At(n.nanos||0)}else if("stringValue"in t)this.Vt(t.stringValue,e),this.ft(e);else if("bytesValue"in t)this.dt(e,30),e.gt(re(t.bytesValue)),this.ft(e);else if("referenceValue"in t)this.yt(t.referenceValue,e);else if("geoPointValue"in t){const n=t.geoPointValue;this.dt(e,45),e.At(n.latitude||0),e.At(n.longitude||0)}else"mapValue"in t?Yl(t)?this.dt(e,Number.MAX_SAFE_INTEGER):ls(t)?this.wt(t.mapValue,e):(this.St(t.mapValue,e),this.ft(e)):"arrayValue"in t?(this.bt(t.arrayValue,e),this.ft(e)):O()}Vt(t,e){this.dt(e,25),this.Dt(t,e)}Dt(t,e){e.Rt(t)}St(t,e){const n=t.fields||{};this.dt(e,55);for(const i of Object.keys(n))this.Vt(i,e),this.Tt(n[i],e)}wt(t,e){var n,i;const s=t.fields||{};this.dt(e,53);const a="value",u=((i=(n=s[a].arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.length)||0;this.dt(e,15),e.At(ut(u)),this.Vt(a,e),this.Tt(s[a],e)}bt(t,e){const n=t.values||[];this.dt(e,50);for(const i of n)this.Tt(i,e)}yt(t,e){this.dt(e,37),M.fromName(t).path.forEach(n=>{this.dt(e,60),this.Dt(n,e)})}dt(t,e){t.At(e)}ft(t){t.At(2)}}$e.vt=new $e;function zp(r){if(r===0)return 8;let t=0;return!(r>>4)&&(t+=4,r<<=4),!(r>>6)&&(t+=2,r<<=2),!(r>>7)&&(t+=1),t}function Rc(r){const t=64-function(n){let i=0;for(let s=0;s<8;++s){const a=zp(255&n[s]);if(i+=a,a!==8)break}return i}(r);return Math.ceil(t/8)}class jp{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ct(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Ft(n.value),n=e.next();this.Mt()}xt(t){const e=t[Symbol.iterator]();let n=e.next();for(;!n.done;)this.Ot(n.value),n=e.next();this.Nt()}Lt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Ft(n);else if(n<2048)this.Ft(960|n>>>6),this.Ft(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Ft(480|n>>>12),this.Ft(128|63&n>>>6),this.Ft(128|63&n);else{const i=e.codePointAt(0);this.Ft(240|i>>>18),this.Ft(128|63&i>>>12),this.Ft(128|63&i>>>6),this.Ft(128|63&i)}}this.Mt()}Bt(t){for(const e of t){const n=e.charCodeAt(0);if(n<128)this.Ot(n);else if(n<2048)this.Ot(960|n>>>6),this.Ot(128|63&n);else if(e<"\uD800"||"\uDBFF"<e)this.Ot(480|n>>>12),this.Ot(128|63&n>>>6),this.Ot(128|63&n);else{const i=e.codePointAt(0);this.Ot(240|i>>>18),this.Ot(128|63&i>>>12),this.Ot(128|63&i>>>6),this.Ot(128|63&i)}}this.Nt()}kt(t){const e=this.qt(t),n=Rc(e);this.Qt(1+n),this.buffer[this.position++]=255&n;for(let i=e.length-n;i<e.length;++i)this.buffer[this.position++]=255&e[i]}Kt(t){const e=this.qt(t),n=Rc(e);this.Qt(1+n),this.buffer[this.position++]=~(255&n);for(let i=e.length-n;i<e.length;++i)this.buffer[this.position++]=~(255&e[i])}$t(){this.Ut(255),this.Ut(255)}Wt(){this.Gt(255),this.Gt(255)}reset(){this.position=0}seed(t){this.Qt(t.length),this.buffer.set(t,this.position),this.position+=t.length}zt(){return this.buffer.slice(0,this.position)}qt(t){const e=function(s){const a=new DataView(new ArrayBuffer(8));return a.setFloat64(0,s,!1),new Uint8Array(a.buffer)}(t),n=(128&e[0])!=0;e[0]^=n?255:128;for(let i=1;i<e.length;++i)e[i]^=n?255:0;return e}Ft(t){const e=255&t;e===0?(this.Ut(0),this.Ut(255)):e===255?(this.Ut(255),this.Ut(0)):this.Ut(e)}Ot(t){const e=255&t;e===0?(this.Gt(0),this.Gt(255)):e===255?(this.Gt(255),this.Gt(0)):this.Gt(t)}Mt(){this.Ut(0),this.Ut(1)}Nt(){this.Gt(0),this.Gt(1)}Ut(t){this.Qt(1),this.buffer[this.position++]=t}Gt(t){this.Qt(1),this.buffer[this.position++]=~t}Qt(t){const e=t+this.position;if(e<=this.buffer.length)return;let n=2*this.buffer.length;n<e&&(n=e);const i=new Uint8Array(n);i.set(this.buffer),this.buffer=i}}class Gp{constructor(t){this.jt=t}gt(t){this.jt.Ct(t)}Rt(t){this.jt.Lt(t)}At(t){this.jt.kt(t)}Et(){this.jt.$t()}}class Kp{constructor(t){this.jt=t}gt(t){this.jt.xt(t)}Rt(t){this.jt.Bt(t)}At(t){this.jt.Kt(t)}Et(){this.jt.Wt()}}class Er{constructor(){this.jt=new jp,this.Ht=new Gp(this.jt),this.Jt=new Kp(this.jt)}seed(t){this.jt.seed(t)}Yt(t){return t===0?this.Ht:this.Jt}zt(){return this.jt.zt()}reset(){this.jt.reset()}}/**
|
|
1317
|
-
* @license
|
|
1318
|
-
* Copyright 2022 Google LLC
|
|
1319
|
-
*
|
|
1320
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1321
|
-
* you may not use this file except in compliance with the License.
|
|
1322
|
-
* You may obtain a copy of the License at
|
|
1323
|
-
*
|
|
1324
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1325
|
-
*
|
|
1326
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1327
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1328
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1329
|
-
* See the License for the specific language governing permissions and
|
|
1330
|
-
* limitations under the License.
|
|
1331
|
-
*/class Qe{constructor(t,e,n,i){this.indexId=t,this.documentKey=e,this.arrayValue=n,this.directionalValue=i}Zt(){const t=this.directionalValue.length,e=t===0||this.directionalValue[t-1]===255?t+1:t,n=new Uint8Array(e);return n.set(this.directionalValue,0),e!==t?n.set([0],this.directionalValue.length):++n[n.length-1],new Qe(this.indexId,this.documentKey,this.arrayValue,n)}}function de(r,t){let e=r.indexId-t.indexId;return e!==0?e:(e=bc(r.arrayValue,t.arrayValue),e!==0?e:(e=bc(r.directionalValue,t.directionalValue),e!==0?e:M.comparator(r.documentKey,t.documentKey)))}function bc(r,t){for(let e=0;e<r.length&&e<t.length;++e){const n=r[e]-t[e];if(n!==0)return n}return r.length-t.length}/**
|
|
1332
|
-
* @license
|
|
1333
|
-
* Copyright 2022 Google LLC
|
|
1334
|
-
*
|
|
1335
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1336
|
-
* you may not use this file except in compliance with the License.
|
|
1337
|
-
* You may obtain a copy of the License at
|
|
1338
|
-
*
|
|
1339
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1340
|
-
*
|
|
1341
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1342
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1343
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1344
|
-
* See the License for the specific language governing permissions and
|
|
1345
|
-
* limitations under the License.
|
|
1346
|
-
*/class Pc{constructor(t){this.Xt=new et((e,n)=>at.comparator(e.field,n.field)),this.collectionId=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment(),this.en=t.orderBy,this.tn=[];for(const e of t.filters){const n=e;n.isInequality()?this.Xt=this.Xt.add(n):this.tn.push(n)}}get nn(){return this.Xt.size>1}rn(t){if(L(t.collectionGroup===this.collectionId),this.nn)return!1;const e=go(t);if(e!==void 0&&!this.sn(e))return!1;const n=je(t);let i=new Set,s=0,a=0;for(;s<n.length&&this.sn(n[s]);++s)i=i.add(n[s].fieldPath.canonicalString());if(s===n.length)return!0;if(this.Xt.size>0){const u=this.Xt.getIterator().getNext();if(!i.has(u.field.canonicalString())){const c=n[s];if(!this.on(u,c)||!this._n(this.en[a++],c))return!1}++s}for(;s<n.length;++s){const u=n[s];if(a>=this.en.length||!this._n(this.en[a++],u))return!1}return!0}an(){if(this.nn)return null;let t=new et(at.comparator);const e=[];for(const n of this.tn)if(!n.field.isKeyField())if(n.op==="array-contains"||n.op==="array-contains-any")e.push(new Je(n.field,2));else{if(t.has(n.field))continue;t=t.add(n.field),e.push(new Je(n.field,0))}for(const n of this.en)n.field.isKeyField()||t.has(n.field)||(t=t.add(n.field),e.push(new Je(n.field,n.dir==="asc"?0:1)));return new Cn(Cn.UNKNOWN_ID,this.collectionId,e,Dn.empty())}sn(t){for(const e of this.tn)if(this.on(e,t))return!0;return!1}on(t,e){if(t===void 0||!t.field.isEqual(e.fieldPath))return!1;const n=t.op==="array-contains"||t.op==="array-contains-any";return e.kind===2===n}_n(t,e){return!!t.field.isEqual(e.fieldPath)&&(e.kind===0&&t.dir==="asc"||e.kind===1&&t.dir==="desc")}}/**
|
|
1347
|
-
* @license
|
|
1348
|
-
* Copyright 2022 Google LLC
|
|
1349
|
-
*
|
|
1350
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1351
|
-
* you may not use this file except in compliance with the License.
|
|
1352
|
-
* You may obtain a copy of the License at
|
|
1353
|
-
*
|
|
1354
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1355
|
-
*
|
|
1356
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1357
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1358
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1359
|
-
* See the License for the specific language governing permissions and
|
|
1360
|
-
* limitations under the License.
|
|
1361
|
-
*/function Gh(r){var t,e;if(L(r instanceof H||r instanceof tt),r instanceof H){if(r instanceof oh){const i=((e=(t=r.value.arrayValue)===null||t===void 0?void 0:t.values)===null||e===void 0?void 0:e.map(s=>H.create(r.field,"==",s)))||[];return tt.create(i,"or")}return r}const n=r.filters.map(i=>Gh(i));return tt.create(n,r.op)}function $p(r){if(r.getFilters().length===0)return[];const t=Vo(Gh(r));return L(Kh(t)),Po(t)||So(t)?[t]:t.getFilters()}function Po(r){return r instanceof H}function So(r){return r instanceof tt&&jo(r)}function Kh(r){return Po(r)||So(r)||function(e){if(e instanceof tt&&Io(e)){for(const n of e.getFilters())if(!Po(n)&&!So(n))return!1;return!0}return!1}(r)}function Vo(r){if(L(r instanceof H||r instanceof tt),r instanceof H)return r;if(r.filters.length===1)return Vo(r.filters[0]);const t=r.filters.map(n=>Vo(n));let e=tt.create(t,r.op);return e=Xi(e),Kh(e)?e:(L(e instanceof tt),L(Nn(e)),L(e.filters.length>1),e.filters.reduce((n,i)=>ta(n,i)))}function ta(r,t){let e;return L(r instanceof H||r instanceof tt),L(t instanceof H||t instanceof tt),e=r instanceof H?t instanceof H?function(i,s){return tt.create([i,s],"and")}(r,t):Sc(r,t):t instanceof H?Sc(t,r):function(i,s){if(L(i.filters.length>0&&s.filters.length>0),Nn(i)&&Nn(s))return rh(i,s.getFilters());const a=Io(i)?i:s,u=Io(i)?s:i,c=a.filters.map(h=>ta(h,u));return tt.create(c,"or")}(r,t),Xi(e)}function Sc(r,t){if(Nn(t))return rh(t,r.getFilters());{const e=t.filters.map(n=>ta(r,n));return tt.create(e,"or")}}function Xi(r){if(L(r instanceof H||r instanceof tt),r instanceof H)return r;const t=r.getFilters();if(t.length===1)return Xi(t[0]);if(eh(r))return r;const e=t.map(i=>Xi(i)),n=[];return e.forEach(i=>{i instanceof H?n.push(i):i instanceof tt&&(i.op===r.op?n.push(...i.filters):n.push(i))}),n.length===1?n[0]:tt.create(n,r.op)}/**
|
|
1362
|
-
* @license
|
|
1363
|
-
* Copyright 2019 Google LLC
|
|
1364
|
-
*
|
|
1365
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1366
|
-
* you may not use this file except in compliance with the License.
|
|
1367
|
-
* You may obtain a copy of the License at
|
|
1368
|
-
*
|
|
1369
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1370
|
-
*
|
|
1371
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1372
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1373
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1374
|
-
* See the License for the specific language governing permissions and
|
|
1375
|
-
* limitations under the License.
|
|
1376
|
-
*/class Qp{constructor(){this.un=new ea}addToCollectionParentIndex(t,e){return this.un.add(e),w.resolve()}getCollectionParents(t,e){return w.resolve(this.un.getEntries(e))}addFieldIndex(t,e){return w.resolve()}deleteFieldIndex(t,e){return w.resolve()}deleteAllFieldIndexes(t){return w.resolve()}createTargetIndexes(t,e){return w.resolve()}getDocumentsMatchingTarget(t,e){return w.resolve(null)}getIndexType(t,e){return w.resolve(0)}getFieldIndexes(t,e){return w.resolve([])}getNextCollectionGroupToUpdate(t){return w.resolve(null)}getMinOffset(t,e){return w.resolve(zt.min())}getMinOffsetFromCollectionGroup(t,e){return w.resolve(zt.min())}updateCollectionGroup(t,e,n){return w.resolve()}updateIndexEntries(t,e){return w.resolve()}}class ea{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),i=this.index[e]||new et(W.comparator),s=!i.has(n);return this.index[e]=i.add(n),s}has(t){const e=t.lastSegment(),n=t.popLast(),i=this.index[e];return i&&i.has(n)}getEntries(t){return(this.index[t]||new et(W.comparator)).toArray()}}/**
|
|
1377
|
-
* @license
|
|
1378
|
-
* Copyright 2019 Google LLC
|
|
1379
|
-
*
|
|
1380
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1381
|
-
* you may not use this file except in compliance with the License.
|
|
1382
|
-
* You may obtain a copy of the License at
|
|
1383
|
-
*
|
|
1384
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1385
|
-
*
|
|
1386
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1387
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1388
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1389
|
-
* See the License for the specific language governing permissions and
|
|
1390
|
-
* limitations under the License.
|
|
1391
|
-
*/const Di=new Uint8Array(0);class Wp{constructor(t,e){this.databaseId=e,this.cn=new ea,this.ln=new se(n=>Ze(n),(n,i)=>Hr(n,i)),this.uid=t.uid||""}addToCollectionParentIndex(t,e){if(!this.cn.has(e)){const n=e.lastSegment(),i=e.popLast();t.addOnCommittedListener(()=>{this.cn.add(e)});const s={collectionId:n,parent:Nt(i)};return Vc(t).put(s)}return w.resolve()}getCollectionParents(t,e){const n=[],i=IDBKeyRange.bound([e,""],[Ol(e),""],!1,!0);return Vc(t).U(i).next(s=>{for(const a of s){if(a.collectionId!==e)break;n.push($t(a.parent))}return n})}addFieldIndex(t,e){const n=Tr(t),i=function(u){return{indexId:u.indexId,collectionGroup:u.collectionGroup,fields:u.fields.map(c=>[c.fieldPath.canonicalString(),c.kind])}}(e);delete i.indexId;const s=n.add(i);if(e.indexState){const a=yn(t);return s.next(u=>{a.put(vc(u,this.uid,e.indexState.sequenceNumber,e.indexState.offset))})}return s.next()}deleteFieldIndex(t,e){const n=Tr(t),i=yn(t),s=_n(t);return n.delete(e.indexId).next(()=>i.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0))).next(()=>s.delete(IDBKeyRange.bound([e.indexId],[e.indexId+1],!1,!0)))}deleteAllFieldIndexes(t){const e=Tr(t),n=_n(t),i=yn(t);return e.j().next(()=>n.j()).next(()=>i.j())}createTargetIndexes(t,e){return w.forEach(this.hn(e),n=>this.getIndexType(t,n).next(i=>{if(i===0||i===1){const s=new Pc(n).an();if(s!=null)return this.addFieldIndex(t,s)}}))}getDocumentsMatchingTarget(t,e){const n=_n(t);let i=!0;const s=new Map;return w.forEach(this.hn(e),a=>this.Pn(t,a).next(u=>{i&&(i=!!u),s.set(a,u)})).next(()=>{if(i){let a=G();const u=[];return w.forEach(s,(c,h)=>{x("IndexedDbIndexManager",`Using index ${function(B){return`id=${B.indexId}|cg=${B.collectionGroup}|f=${B.fields.map($=>`${$.fieldPath}:${$.kind}`).join(",")}`}(c)} to execute ${Ze(e)}`);const f=function(B,$){const Z=go($);if(Z===void 0)return null;for(const K of Wi(B,Z.fieldPath))switch(K.op){case"array-contains-any":return K.value.arrayValue.values||[];case"array-contains":return[K.value]}return null}(h,c),g=function(B,$){const Z=new Map;for(const K of je($))for(const E of Wi(B,K.fieldPath))switch(E.op){case"==":case"in":Z.set(K.fieldPath.canonicalString(),E.value);break;case"not-in":case"!=":return Z.set(K.fieldPath.canonicalString(),E.value),Array.from(Z.values())}return null}(h,c),_=function(B,$){const Z=[];let K=!0;for(const E of je($)){const p=E.kind===0?ac(B,E.fieldPath,B.startAt):uc(B,E.fieldPath,B.startAt);Z.push(p.value),K&&(K=p.inclusive)}return new Re(Z,K)}(h,c),R=function(B,$){const Z=[];let K=!0;for(const E of je($)){const p=E.kind===0?uc(B,E.fieldPath,B.endAt):ac(B,E.fieldPath,B.endAt);Z.push(p.value),K&&(K=p.inclusive)}return new Re(Z,K)}(h,c),C=this.In(c,h,_),N=this.In(c,h,R),V=this.Tn(c,h,g),q=this.En(c.indexId,f,C,_.inclusive,N,R.inclusive,V);return w.forEach(q,z=>n.G(z,e.limit).next(B=>{B.forEach($=>{const Z=M.fromSegments($.documentKey);a.has(Z)||(a=a.add(Z),u.push(Z))})}))}).next(()=>u)}return w.resolve(null)})}hn(t){let e=this.ln.get(t);return e||(t.filters.length===0?e=[t]:e=$p(tt.create(t.filters,"and")).map(n=>To(t.path,t.collectionGroup,t.orderBy,n.getFilters(),t.limit,t.startAt,t.endAt)),this.ln.set(t,e),e)}En(t,e,n,i,s,a,u){const c=(e!=null?e.length:1)*Math.max(n.length,s.length),h=c/(e!=null?e.length:1),f=[];for(let g=0;g<c;++g){const _=e?this.dn(e[g/h]):Di,R=this.An(t,_,n[g%h],i),C=this.Rn(t,_,s[g%h],a),N=u.map(V=>this.An(t,_,V,!0));f.push(...this.createRange(R,C,N))}return f}An(t,e,n,i){const s=new Qe(t,M.empty(),e,n);return i?s:s.Zt()}Rn(t,e,n,i){const s=new Qe(t,M.empty(),e,n);return i?s.Zt():s}Pn(t,e){const n=new Pc(e),i=e.collectionGroup!=null?e.collectionGroup:e.path.lastSegment();return this.getFieldIndexes(t,i).next(s=>{let a=null;for(const u of s)n.rn(u)&&(!a||u.fields.length>a.fields.length)&&(a=u);return a})}getIndexType(t,e){let n=2;const i=this.hn(e);return w.forEach(i,s=>this.Pn(t,s).next(a=>{a?n!==0&&a.fields.length<function(c){let h=new et(at.comparator),f=!1;for(const g of c.filters)for(const _ of g.getFlattenedFilters())_.field.isKeyField()||(_.op==="array-contains"||_.op==="array-contains-any"?f=!0:h=h.add(_.field));for(const g of c.orderBy)g.field.isKeyField()||(h=h.add(g.field));return h.size+(f?1:0)}(s)&&(n=1):n=0})).next(()=>function(a){return a.limit!==null}(e)&&i.length>1&&n===2?1:n)}Vn(t,e){const n=new Er;for(const i of je(t)){const s=e.data.field(i.fieldPath);if(s==null)return null;const a=n.Yt(i.kind);$e.vt.It(s,a)}return n.zt()}dn(t){const e=new Er;return $e.vt.It(t,e.Yt(0)),e.zt()}mn(t,e){const n=new Er;return $e.vt.It(Xe(this.databaseId,e),n.Yt(function(s){const a=je(s);return a.length===0?0:a[a.length-1].kind}(t))),n.zt()}Tn(t,e,n){if(n===null)return[];let i=[];i.push(new Er);let s=0;for(const a of je(t)){const u=n[s++];for(const c of i)if(this.fn(e,a.fieldPath)&&qr(u))i=this.gn(i,a,u);else{const h=c.Yt(a.kind);$e.vt.It(u,h)}}return this.pn(i)}In(t,e,n){return this.Tn(t,e,n.position)}pn(t){const e=[];for(let n=0;n<t.length;++n)e[n]=t[n].zt();return e}gn(t,e,n){const i=[...t],s=[];for(const a of n.arrayValue.values||[])for(const u of i){const c=new Er;c.seed(u.zt()),$e.vt.It(a,c.Yt(e.kind)),s.push(c)}return s}fn(t,e){return!!t.filters.find(n=>n instanceof H&&n.field.isEqual(e)&&(n.op==="in"||n.op==="not-in"))}getFieldIndexes(t,e){const n=Tr(t),i=yn(t);return(e?n.U("collectionGroupIndex",IDBKeyRange.bound(e,e)):n.U()).next(s=>{const a=[];return w.forEach(s,u=>i.get([u.indexId,this.uid]).next(c=>{a.push(function(f,g){const _=g?new Dn(g.sequenceNumber,new zt(rn(g.readTime),new M($t(g.documentKey)),g.largestBatchId)):Dn.empty(),R=f.fields.map(([C,N])=>new Je(at.fromServerFormat(C),N));return new Cn(f.indexId,f.collectionGroup,R,_)}(u,c))})).next(()=>a)})}getNextCollectionGroupToUpdate(t){return this.getFieldIndexes(t).next(e=>e.length===0?null:(e.sort((n,i)=>{const s=n.indexState.sequenceNumber-i.indexState.sequenceNumber;return s!==0?s:j(n.collectionGroup,i.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(t,e,n){const i=Tr(t),s=yn(t);return this.yn(t).next(a=>i.U("collectionGroupIndex",IDBKeyRange.bound(e,e)).next(u=>w.forEach(u,c=>s.put(vc(c.indexId,this.uid,a,n)))))}updateIndexEntries(t,e){const n=new Map;return w.forEach(e,(i,s)=>{const a=n.get(i.collectionGroup);return(a?w.resolve(a):this.getFieldIndexes(t,i.collectionGroup)).next(u=>(n.set(i.collectionGroup,u),w.forEach(u,c=>this.wn(t,i,c).next(h=>{const f=this.Sn(s,c);return h.isEqual(f)?w.resolve():this.bn(t,s,c,h,f)}))))})}Dn(t,e,n,i){return _n(t).put({indexId:i.indexId,uid:this.uid,arrayValue:i.arrayValue,directionalValue:i.directionalValue,orderedDocumentKey:this.mn(n,e.key),documentKey:e.key.path.toArray()})}vn(t,e,n,i){return _n(t).delete([i.indexId,this.uid,i.arrayValue,i.directionalValue,this.mn(n,e.key),e.key.path.toArray()])}wn(t,e,n){const i=_n(t);let s=new et(de);return i.J({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.mn(n,e)])},(a,u)=>{s=s.add(new Qe(n.indexId,e,u.arrayValue,u.directionalValue))}).next(()=>s)}Sn(t,e){let n=new et(de);const i=this.Vn(e,t);if(i==null)return n;const s=go(e);if(s!=null){const a=t.data.field(s.fieldPath);if(qr(a))for(const u of a.arrayValue.values||[])n=n.add(new Qe(e.indexId,t.key,this.dn(u),i))}else n=n.add(new Qe(e.indexId,t.key,Di,i));return n}bn(t,e,n,i,s){x("IndexedDbIndexManager","Updating index entries for document '%s'",e.key);const a=[];return function(c,h,f,g,_){const R=c.getIterator(),C=h.getIterator();let N=pn(R),V=pn(C);for(;N||V;){let q=!1,z=!1;if(N&&V){const B=f(N,V);B<0?z=!0:B>0&&(q=!0)}else N!=null?z=!0:q=!0;q?(g(V),V=pn(C)):z?(_(N),N=pn(R)):(N=pn(R),V=pn(C))}}(i,s,de,u=>{a.push(this.Dn(t,e,n,u))},u=>{a.push(this.vn(t,e,n,u))}),w.waitFor(a)}yn(t){let e=1;return yn(t).J({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(n,i,s)=>{s.done(),e=i.sequenceNumber+1}).next(()=>e)}createRange(t,e,n){n=n.sort((a,u)=>de(a,u)).filter((a,u,c)=>!u||de(a,c[u-1])!==0);const i=[];i.push(t);for(const a of n){const u=de(a,t),c=de(a,e);if(u===0)i[0]=t.Zt();else if(u>0&&c<0)i.push(a),i.push(a.Zt());else if(c>0)break}i.push(e);const s=[];for(let a=0;a<i.length;a+=2){if(this.Cn(i[a],i[a+1]))return[];const u=[i[a].indexId,this.uid,i[a].arrayValue,i[a].directionalValue,Di,[]],c=[i[a+1].indexId,this.uid,i[a+1].arrayValue,i[a+1].directionalValue,Di,[]];s.push(IDBKeyRange.bound(u,c))}return s}Cn(t,e){return de(t,e)>0}getMinOffsetFromCollectionGroup(t,e){return this.getFieldIndexes(t,e).next(Cc)}getMinOffset(t,e){return w.mapArray(this.hn(e),n=>this.Pn(t,n).next(i=>i||O())).next(Cc)}}function Vc(r){return It(r,"collectionParents")}function _n(r){return It(r,"indexEntries")}function Tr(r){return It(r,"indexConfiguration")}function yn(r){return It(r,"indexState")}function Cc(r){L(r.length!==0);let t=r[0].indexState.offset,e=t.largestBatchId;for(let n=1;n<r.length;n++){const i=r[n].indexState.offset;Uo(i,t)<0&&(t=i),e<i.largestBatchId&&(e=i.largestBatchId)}return new zt(t.readTime,t.documentKey,e)}/**
|
|
1392
|
-
* @license
|
|
1393
|
-
* Copyright 2018 Google LLC
|
|
1394
|
-
*
|
|
1395
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1396
|
-
* you may not use this file except in compliance with the License.
|
|
1397
|
-
* You may obtain a copy of the License at
|
|
1398
|
-
*
|
|
1399
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1400
|
-
*
|
|
1401
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1402
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1403
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1404
|
-
* See the License for the specific language governing permissions and
|
|
1405
|
-
* limitations under the License.
|
|
1406
|
-
*/const Dc={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class xt{constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}static withCacheSize(t){return new xt(t,xt.DEFAULT_COLLECTION_PERCENTILE,xt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}/**
|
|
1407
|
-
* @license
|
|
1408
|
-
* Copyright 2020 Google LLC
|
|
1409
|
-
*
|
|
1410
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1411
|
-
* you may not use this file except in compliance with the License.
|
|
1412
|
-
* You may obtain a copy of the License at
|
|
1413
|
-
*
|
|
1414
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1415
|
-
*
|
|
1416
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1417
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1418
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1419
|
-
* See the License for the specific language governing permissions and
|
|
1420
|
-
* limitations under the License.
|
|
1421
|
-
*/function $h(r,t,e){const n=r.store("mutations"),i=r.store("documentMutations"),s=[],a=IDBKeyRange.only(e.batchId);let u=0;const c=n.J({range:a},(f,g,_)=>(u++,_.delete()));s.push(c.next(()=>{L(u===1)}));const h=[];for(const f of e.mutations){const g=Gl(t,f.key.path,e.batchId);s.push(i.delete(g)),h.push(f.key)}return w.waitFor(s).next(()=>h)}function Zi(r){if(!r)return 0;let t;if(r.document)t=r.document;else if(r.unknownDocument)t=r.unknownDocument;else{if(!r.noDocument)throw O();t=r.noDocument}return JSON.stringify(t).length}/**
|
|
1422
|
-
* @license
|
|
1423
|
-
* Copyright 2017 Google LLC
|
|
1424
|
-
*
|
|
1425
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1426
|
-
* you may not use this file except in compliance with the License.
|
|
1427
|
-
* You may obtain a copy of the License at
|
|
1428
|
-
*
|
|
1429
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1430
|
-
*
|
|
1431
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1432
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1433
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1434
|
-
* See the License for the specific language governing permissions and
|
|
1435
|
-
* limitations under the License.
|
|
1436
|
-
*/xt.DEFAULT_COLLECTION_PERCENTILE=10,xt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,xt.DEFAULT=new xt(41943040,xt.DEFAULT_COLLECTION_PERCENTILE,xt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),xt.DISABLED=new xt(-1,0,0);class gs{constructor(t,e,n,i){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=i,this.Fn={}}static lt(t,e,n,i){L(t.uid!=="");const s=t.isAuthenticated()?t.uid:"";return new gs(s,e,n,i)}checkEmpty(t){let e=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return fe(t).J({index:"userMutationsIndex",range:n},(i,s,a)=>{e=!1,a.done()}).next(()=>e)}addMutationBatch(t,e,n,i){const s=wn(t),a=fe(t);return a.add({}).next(u=>{L(typeof u=="number");const c=new Wo(u,e,n,i),h=function(R,C,N){const V=N.baseMutations.map(z=>Gr(R.ct,z)),q=N.mutations.map(z=>Gr(R.ct,z));return{userId:C,batchId:N.batchId,localWriteTimeMs:N.localWriteTime.toMillis(),baseMutations:V,mutations:q}}(this.serializer,this.userId,c),f=[];let g=new et((_,R)=>j(_.canonicalString(),R.canonicalString()));for(const _ of i){const R=Gl(this.userId,_.key.path,u);g=g.add(_.key.path.popLast()),f.push(a.put(h)),f.push(s.put(R,Fg))}return g.forEach(_=>{f.push(this.indexManager.addToCollectionParentIndex(t,_))}),t.addOnCommittedListener(()=>{this.Fn[u]=c.keys()}),w.waitFor(f).next(()=>c)})}lookupMutationBatch(t,e){return fe(t).get(e).next(n=>n?(L(n.userId===this.userId),Ke(this.serializer,n)):null)}Mn(t,e){return this.Fn[e]?w.resolve(this.Fn[e]):this.lookupMutationBatch(t,e).next(n=>{if(n){const i=n.keys();return this.Fn[e]=i,i}return null})}getNextMutationBatchAfterBatchId(t,e){const n=e+1,i=IDBKeyRange.lowerBound([this.userId,n]);let s=null;return fe(t).J({index:"userMutationsIndex",range:i},(a,u,c)=>{u.userId===this.userId&&(L(u.batchId>=n),s=Ke(this.serializer,u)),c.done()}).next(()=>s)}getHighestUnacknowledgedBatchId(t){const e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return fe(t).J({index:"userMutationsIndex",range:e,reverse:!0},(i,s,a)=>{n=s.batchId,a.done()}).next(()=>n)}getAllMutationBatches(t){const e=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return fe(t).U("userMutationsIndex",e).next(n=>n.map(i=>Ke(this.serializer,i)))}getAllMutationBatchesAffectingDocumentKey(t,e){const n=Oi(this.userId,e.path),i=IDBKeyRange.lowerBound(n),s=[];return wn(t).J({range:i},(a,u,c)=>{const[h,f,g]=a,_=$t(f);if(h===this.userId&&e.path.isEqual(_))return fe(t).get(g).next(R=>{if(!R)throw O();L(R.userId===this.userId),s.push(Ke(this.serializer,R))});c.done()}).next(()=>s)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new et(j);const i=[];return e.forEach(s=>{const a=Oi(this.userId,s.path),u=IDBKeyRange.lowerBound(a),c=wn(t).J({range:u},(h,f,g)=>{const[_,R,C]=h,N=$t(R);_===this.userId&&s.path.isEqual(N)?n=n.add(C):g.done()});i.push(c)}),w.waitFor(i).next(()=>this.xn(t,n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,i=n.length+1,s=Oi(this.userId,n),a=IDBKeyRange.lowerBound(s);let u=new et(j);return wn(t).J({range:a},(c,h,f)=>{const[g,_,R]=c,C=$t(_);g===this.userId&&n.isPrefixOf(C)?C.length===i&&(u=u.add(R)):f.done()}).next(()=>this.xn(t,u))}xn(t,e){const n=[],i=[];return e.forEach(s=>{i.push(fe(t).get(s).next(a=>{if(a===null)throw O();L(a.userId===this.userId),n.push(Ke(this.serializer,a))}))}),w.waitFor(i).next(()=>n)}removeMutationBatch(t,e){return $h(t._e,this.userId,e).next(n=>(t.addOnCommittedListener(()=>{this.On(e.batchId)}),w.forEach(n,i=>this.referenceDelegate.markPotentiallyOrphaned(t,i))))}On(t){delete this.Fn[t]}performConsistencyCheck(t){return this.checkEmpty(t).next(e=>{if(!e)return w.resolve();const n=IDBKeyRange.lowerBound(function(a){return[a]}(this.userId)),i=[];return wn(t).J({range:n},(s,a,u)=>{if(s[0]===this.userId){const c=$t(s[1]);i.push(c)}else u.done()}).next(()=>{L(i.length===0)})})}containsKey(t,e){return Qh(t,this.userId,e)}Nn(t){return Wh(t).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function Qh(r,t,e){const n=Oi(t,e.path),i=n[1],s=IDBKeyRange.lowerBound(n);let a=!1;return wn(r).J({range:s,H:!0},(u,c,h)=>{const[f,g,_]=u;f===t&&g===i&&(a=!0),h.done()}).next(()=>a)}function fe(r){return It(r,"mutations")}function wn(r){return It(r,"documentMutations")}function Wh(r){return It(r,"mutationQueues")}/**
|
|
1437
|
-
* @license
|
|
1438
|
-
* Copyright 2017 Google LLC
|
|
1439
|
-
*
|
|
1440
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1441
|
-
* you may not use this file except in compliance with the License.
|
|
1442
|
-
* You may obtain a copy of the License at
|
|
1443
|
-
*
|
|
1444
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1445
|
-
*
|
|
1446
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1447
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1448
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1449
|
-
* See the License for the specific language governing permissions and
|
|
1450
|
-
* limitations under the License.
|
|
1451
|
-
*/class sn{constructor(t){this.Ln=t}next(){return this.Ln+=2,this.Ln}static Bn(){return new sn(0)}static kn(){return new sn(-1)}}/**
|
|
1452
|
-
* @license
|
|
1453
|
-
* Copyright 2017 Google LLC
|
|
1454
|
-
*
|
|
1455
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1456
|
-
* you may not use this file except in compliance with the License.
|
|
1457
|
-
* You may obtain a copy of the License at
|
|
1458
|
-
*
|
|
1459
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1460
|
-
*
|
|
1461
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1462
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1463
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1464
|
-
* See the License for the specific language governing permissions and
|
|
1465
|
-
* limitations under the License.
|
|
1466
|
-
*/class Hp{constructor(t,e){this.referenceDelegate=t,this.serializer=e}allocateTargetId(t){return this.qn(t).next(e=>{const n=new sn(e.highestTargetId);return e.highestTargetId=n.next(),this.Qn(t,e).next(()=>e.highestTargetId)})}getLastRemoteSnapshotVersion(t){return this.qn(t).next(e=>U.fromTimestamp(new lt(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(t){return this.qn(t).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(t,e,n){return this.qn(t).next(i=>(i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),this.Qn(t,i)))}addTargetData(t,e){return this.Kn(t,e).next(()=>this.qn(t).next(n=>(n.targetCount+=1,this.$n(e,n),this.Qn(t,n))))}updateTargetData(t,e){return this.Kn(t,e)}removeTargetData(t,e){return this.removeMatchingKeysForTargetId(t,e.targetId).next(()=>In(t).delete(e.targetId)).next(()=>this.qn(t)).next(n=>(L(n.targetCount>0),n.targetCount-=1,this.Qn(t,n)))}removeTargets(t,e,n){let i=0;const s=[];return In(t).J((a,u)=>{const c=Pr(u);c.sequenceNumber<=e&&n.get(c.targetId)===null&&(i++,s.push(this.removeTargetData(t,c)))}).next(()=>w.waitFor(s)).next(()=>i)}forEachTarget(t,e){return In(t).J((n,i)=>{const s=Pr(i);e(s)})}qn(t){return xc(t).get("targetGlobalKey").next(e=>(L(e!==null),e))}Qn(t,e){return xc(t).put("targetGlobalKey",e)}Kn(t,e){return In(t).put(jh(this.serializer,e))}$n(t,e){let n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n}getTargetCount(t){return this.qn(t).next(e=>e.targetCount)}getTargetData(t,e){const n=Ze(e),i=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let s=null;return In(t).J({range:i,index:"queryTargetsIndex"},(a,u,c)=>{const h=Pr(u);Hr(e,h.target)&&(s=h,c.done())}).next(()=>s)}addMatchingKeys(t,e,n){const i=[],s=ge(t);return e.forEach(a=>{const u=Nt(a.path);i.push(s.put({targetId:n,path:u})),i.push(this.referenceDelegate.addReference(t,n,a))}),w.waitFor(i)}removeMatchingKeys(t,e,n){const i=ge(t);return w.forEach(e,s=>{const a=Nt(s.path);return w.waitFor([i.delete([n,a]),this.referenceDelegate.removeReference(t,n,s)])})}removeMatchingKeysForTargetId(t,e){const n=ge(t),i=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(i)}getMatchingKeysForTargetId(t,e){const n=IDBKeyRange.bound([e],[e+1],!1,!0),i=ge(t);let s=G();return i.J({range:n,H:!0},(a,u,c)=>{const h=$t(a[1]),f=new M(h);s=s.add(f)}).next(()=>s)}containsKey(t,e){const n=Nt(e.path),i=IDBKeyRange.bound([n],[Ol(n)],!1,!0);let s=0;return ge(t).J({index:"documentTargetsIndex",H:!0,range:i},([a,u],c,h)=>{a!==0&&(s++,h.done())}).next(()=>s>0)}ot(t,e){return In(t).get(e).next(n=>n?Pr(n):null)}}function In(r){return It(r,"targets")}function xc(r){return It(r,"targetGlobal")}function ge(r){return It(r,"targetDocuments")}/**
|
|
1467
|
-
* @license
|
|
1468
|
-
* Copyright 2020 Google LLC
|
|
1469
|
-
*
|
|
1470
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1471
|
-
* you may not use this file except in compliance with the License.
|
|
1472
|
-
* You may obtain a copy of the License at
|
|
1473
|
-
*
|
|
1474
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1475
|
-
*
|
|
1476
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1477
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1478
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1479
|
-
* See the License for the specific language governing permissions and
|
|
1480
|
-
* limitations under the License.
|
|
1481
|
-
*/function Nc([r,t],[e,n]){const i=j(r,e);return i===0?j(t,n):i}class Jp{constructor(t){this.Un=t,this.buffer=new et(Nc),this.Wn=0}Gn(){return++this.Wn}zn(t){const e=[t,this.Gn()];if(this.buffer.size<this.Un)this.buffer=this.buffer.add(e);else{const n=this.buffer.last();Nc(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}}get maxValue(){return this.buffer.last()[0]}}class Hh{constructor(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.jn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Hn(6e4)}stop(){this.jn&&(this.jn.cancel(),this.jn=null)}get started(){return this.jn!==null}Hn(t){x("LruGarbageCollector",`Garbage collection scheduled in ${t}ms`),this.jn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,async()=>{this.jn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){De(e)?x("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await Ce(e)}await this.Hn(3e5)})}}class Yp{constructor(t,e){this.Jn=t,this.params=e}calculateTargetCount(t,e){return this.Jn.Yn(t).next(n=>Math.floor(e/100*n))}nthSequenceNumber(t,e){if(e===0)return w.resolve(Ot.oe);const n=new Jp(e);return this.Jn.forEachTarget(t,i=>n.zn(i.sequenceNumber)).next(()=>this.Jn.Zn(t,i=>n.zn(i))).next(()=>n.maxValue)}removeTargets(t,e,n){return this.Jn.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.Jn.removeOrphanedDocuments(t,e)}collect(t,e){return this.params.cacheSizeCollectionThreshold===-1?(x("LruGarbageCollector","Garbage collection skipped; disabled"),w.resolve(Dc)):this.getCacheSize(t).next(n=>n<this.params.cacheSizeCollectionThreshold?(x("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Dc):this.Xn(t,e))}getCacheSize(t){return this.Jn.getCacheSize(t)}Xn(t,e){let n,i,s,a,u,c,h;const f=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(g=>(g>this.params.maximumSequenceNumbersToCollect?(x("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${g}`),i=this.params.maximumSequenceNumbersToCollect):i=g,a=Date.now(),this.nthSequenceNumber(t,i))).next(g=>(n=g,u=Date.now(),this.removeTargets(t,n,e))).next(g=>(s=g,c=Date.now(),this.removeOrphanedDocuments(t,n))).next(g=>(h=Date.now(),En()<=J.DEBUG&&x("LruGarbageCollector",`LRU Garbage Collection
|
|
1482
|
-
Counted targets in ${a-f}ms
|
|
1483
|
-
Determined least recently used ${i} in `+(u-a)+`ms
|
|
1484
|
-
Removed ${s} targets in `+(c-u)+`ms
|
|
1485
|
-
Removed ${g} documents in `+(h-c)+`ms
|
|
1486
|
-
Total Duration: ${h-f}ms`),w.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:s,documentsRemoved:g})))}}function Jh(r,t){return new Yp(r,t)}/**
|
|
1487
|
-
* @license
|
|
1488
|
-
* Copyright 2020 Google LLC
|
|
1489
|
-
*
|
|
1490
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1491
|
-
* you may not use this file except in compliance with the License.
|
|
1492
|
-
* You may obtain a copy of the License at
|
|
1493
|
-
*
|
|
1494
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1495
|
-
*
|
|
1496
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1497
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1498
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1499
|
-
* See the License for the specific language governing permissions and
|
|
1500
|
-
* limitations under the License.
|
|
1501
|
-
*/class Xp{constructor(t,e){this.db=t,this.garbageCollector=Jh(this,e)}Yn(t){const e=this.er(t);return this.db.getTargetCache().getTargetCount(t).next(n=>e.next(i=>n+i))}er(t){let e=0;return this.Zn(t,n=>{e++}).next(()=>e)}forEachTarget(t,e){return this.db.getTargetCache().forEachTarget(t,e)}Zn(t,e){return this.tr(t,(n,i)=>e(i))}addReference(t,e,n){return xi(t,n)}removeReference(t,e,n){return xi(t,n)}removeTargets(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)}markPotentiallyOrphaned(t,e){return xi(t,e)}nr(t,e){return function(i,s){let a=!1;return Wh(i).Y(u=>Qh(i,u,s).next(c=>(c&&(a=!0),w.resolve(!c)))).next(()=>a)}(t,e)}removeOrphanedDocuments(t,e){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[];let s=0;return this.tr(t,(a,u)=>{if(u<=e){const c=this.nr(t,a).next(h=>{if(!h)return s++,n.getEntry(t,a).next(()=>(n.removeEntry(a,U.min()),ge(t).delete(function(g){return[0,Nt(g.path)]}(a))))});i.push(c)}}).next(()=>w.waitFor(i)).next(()=>n.apply(t)).next(()=>s)}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)}updateLimboDocument(t,e){return xi(t,e)}tr(t,e){const n=ge(t);let i,s=Ot.oe;return n.J({index:"documentTargetsIndex"},([a,u],{path:c,sequenceNumber:h})=>{a===0?(s!==Ot.oe&&e(new M($t(i)),s),s=h,i=c):s=Ot.oe}).next(()=>{s!==Ot.oe&&e(new M($t(i)),s)})}getCacheSize(t){return this.db.getRemoteDocumentCache().getSize(t)}}function xi(r,t){return ge(r).put(function(n,i){return{targetId:0,path:Nt(n.path),sequenceNumber:i}}(t,r.currentSequenceNumber))}/**
|
|
1502
|
-
* @license
|
|
1503
|
-
* Copyright 2017 Google LLC
|
|
1504
|
-
*
|
|
1505
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1506
|
-
* you may not use this file except in compliance with the License.
|
|
1507
|
-
* You may obtain a copy of the License at
|
|
1508
|
-
*
|
|
1509
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1510
|
-
*
|
|
1511
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1512
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1513
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1514
|
-
* See the License for the specific language governing permissions and
|
|
1515
|
-
* limitations under the License.
|
|
1516
|
-
*/class Yh{constructor(){this.changes=new se(t=>t.toString(),(t,e)=>t.isEqual(e)),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,ot.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return n!==void 0?w.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}/**
|
|
1517
|
-
* @license
|
|
1518
|
-
* Copyright 2017 Google LLC
|
|
1519
|
-
*
|
|
1520
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1521
|
-
* you may not use this file except in compliance with the License.
|
|
1522
|
-
* You may obtain a copy of the License at
|
|
1523
|
-
*
|
|
1524
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1525
|
-
*
|
|
1526
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1527
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1528
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1529
|
-
* See the License for the specific language governing permissions and
|
|
1530
|
-
* limitations under the License.
|
|
1531
|
-
*/class Zp{constructor(t){this.serializer=t}setIndexManager(t){this.indexManager=t}addEntry(t,e,n){return qe(t).put(n)}removeEntry(t,e,n){return qe(t).delete(function(s,a){const u=s.path.toArray();return[u.slice(0,u.length-2),u[u.length-2],Yi(a),u[u.length-1]]}(e,n))}updateMetadata(t,e){return this.getMetadata(t).next(n=>(n.byteSize+=e,this.rr(t,n)))}getEntry(t,e){let n=ot.newInvalidDocument(e);return qe(t).J({index:"documentKeyIndex",range:IDBKeyRange.only(vr(e))},(i,s)=>{n=this.ir(e,s)}).next(()=>n)}sr(t,e){let n={size:0,document:ot.newInvalidDocument(e)};return qe(t).J({index:"documentKeyIndex",range:IDBKeyRange.only(vr(e))},(i,s)=>{n={document:this.ir(e,s),size:Zi(s)}}).next(()=>n)}getEntries(t,e){let n=Bt();return this._r(t,e,(i,s)=>{const a=this.ir(i,s);n=n.insert(i,a)}).next(()=>n)}ar(t,e){let n=Bt(),i=new it(M.comparator);return this._r(t,e,(s,a)=>{const u=this.ir(s,a);n=n.insert(s,u),i=i.insert(s,Zi(a))}).next(()=>({documents:n,ur:i}))}_r(t,e,n){if(e.isEmpty())return w.resolve();let i=new et(Mc);e.forEach(c=>i=i.add(c));const s=IDBKeyRange.bound(vr(i.first()),vr(i.last())),a=i.getIterator();let u=a.getNext();return qe(t).J({index:"documentKeyIndex",range:s},(c,h,f)=>{const g=M.fromSegments([...h.prefixPath,h.collectionGroup,h.documentId]);for(;u&&Mc(u,g)<0;)n(u,null),u=a.getNext();u&&u.isEqual(g)&&(n(u,h),u=a.hasNext()?a.getNext():null),u?f.$(vr(u)):f.done()}).next(()=>{for(;u;)n(u,null),u=a.hasNext()?a.getNext():null})}getDocumentsMatchingQuery(t,e,n,i,s){const a=e.path,u=[a.popLast().toArray(),a.lastSegment(),Yi(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],c=[a.popLast().toArray(),a.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return qe(t).U(IDBKeyRange.bound(u,c,!0)).next(h=>{s==null||s.incrementDocumentReadCount(h.length);let f=Bt();for(const g of h){const _=this.ir(M.fromSegments(g.prefixPath.concat(g.collectionGroup,g.documentId)),g);_.isFoundDocument()&&(Yr(e,_)||i.has(_.key))&&(f=f.insert(_.key,_))}return f})}getAllFromCollectionGroup(t,e,n,i){let s=Bt();const a=Fc(e,n),u=Fc(e,zt.max());return qe(t).J({index:"collectionGroupIndex",range:IDBKeyRange.bound(a,u,!0)},(c,h,f)=>{const g=this.ir(M.fromSegments(h.prefixPath.concat(h.collectionGroup,h.documentId)),h);s=s.insert(g.key,g),s.size===i&&f.done()}).next(()=>s)}newChangeBuffer(t){return new t_(this,!!t&&t.trackRemovals)}getSize(t){return this.getMetadata(t).next(e=>e.byteSize)}getMetadata(t){return kc(t).get("remoteDocumentGlobalKey").next(e=>(L(!!e),e))}rr(t,e){return kc(t).put("remoteDocumentGlobalKey",e)}ir(t,e){if(e){const n=Bp(this.serializer,e);if(!(n.isNoDocument()&&n.version.isEqual(U.min())))return n}return ot.newInvalidDocument(t)}}function Xh(r){return new Zp(r)}class t_ extends Yh{constructor(t,e){super(),this.cr=t,this.trackRemovals=e,this.lr=new se(n=>n.toString(),(n,i)=>n.isEqual(i))}applyChanges(t){const e=[];let n=0,i=new et((s,a)=>j(s.canonicalString(),a.canonicalString()));return this.changes.forEach((s,a)=>{const u=this.lr.get(s);if(e.push(this.cr.removeEntry(t,s,u.readTime)),a.isValidDocument()){const c=Ec(this.cr.serializer,a);i=i.add(s.path.popLast());const h=Zi(c);n+=h-u.size,e.push(this.cr.addEntry(t,s,c))}else if(n-=u.size,this.trackRemovals){const c=Ec(this.cr.serializer,a.convertToNoDocument(U.min()));e.push(this.cr.addEntry(t,s,c))}}),i.forEach(s=>{e.push(this.cr.indexManager.addToCollectionParentIndex(t,s))}),e.push(this.cr.updateMetadata(t,n)),w.waitFor(e)}getFromCache(t,e){return this.cr.sr(t,e).next(n=>(this.lr.set(e,{size:n.size,readTime:n.document.readTime}),n.document))}getAllFromCache(t,e){return this.cr.ar(t,e).next(({documents:n,ur:i})=>(i.forEach((s,a)=>{this.lr.set(s,{size:a,readTime:n.get(s).readTime})}),n))}}function kc(r){return It(r,"remoteDocumentGlobal")}function qe(r){return It(r,"remoteDocumentsV14")}function vr(r){const t=r.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function Fc(r,t){const e=t.documentKey.path.toArray();return[r,Yi(t.readTime),e.slice(0,e.length-2),e.length>0?e[e.length-1]:""]}function Mc(r,t){const e=r.path.toArray(),n=t.path.toArray();let i=0;for(let s=0;s<e.length-2&&s<n.length-2;++s)if(i=j(e[s],n[s]),i)return i;return i=j(e.length,n.length),i||(i=j(e[e.length-2],n[n.length-2]),i||j(e[e.length-1],n[n.length-1]))}/**
|
|
1532
|
-
* @license
|
|
1533
|
-
* Copyright 2017 Google LLC
|
|
1534
|
-
*
|
|
1535
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1536
|
-
* you may not use this file except in compliance with the License.
|
|
1537
|
-
* You may obtain a copy of the License at
|
|
1538
|
-
*
|
|
1539
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1540
|
-
*
|
|
1541
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1542
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1543
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1544
|
-
* See the License for the specific language governing permissions and
|
|
1545
|
-
* limitations under the License.
|
|
1546
|
-
*//**
|
|
1547
|
-
* @license
|
|
1548
|
-
* Copyright 2022 Google LLC
|
|
1549
|
-
*
|
|
1550
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1551
|
-
* you may not use this file except in compliance with the License.
|
|
1552
|
-
* You may obtain a copy of the License at
|
|
1553
|
-
*
|
|
1554
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1555
|
-
*
|
|
1556
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1557
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1558
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1559
|
-
* See the License for the specific language governing permissions and
|
|
1560
|
-
* limitations under the License.
|
|
1561
|
-
*/class e_{constructor(t,e){this.overlayedDocument=t,this.mutatedFields=e}}/**
|
|
1562
|
-
* @license
|
|
1563
|
-
* Copyright 2017 Google LLC
|
|
1564
|
-
*
|
|
1565
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1566
|
-
* you may not use this file except in compliance with the License.
|
|
1567
|
-
* You may obtain a copy of the License at
|
|
1568
|
-
*
|
|
1569
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1570
|
-
*
|
|
1571
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1572
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1573
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1574
|
-
* See the License for the specific language governing permissions and
|
|
1575
|
-
* limitations under the License.
|
|
1576
|
-
*/class Zh{constructor(t,e,n,i){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=n,this.indexManager=i}getDocument(t,e){let n=null;return this.documentOverlayCache.getOverlay(t,e).next(i=>(n=i,this.remoteDocumentCache.getEntry(t,e))).next(i=>(n!==null&&Dr(n.mutation,i,Lt.empty(),lt.now()),i))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.getLocalViewOfDocuments(t,n,G()).next(()=>n))}getLocalViewOfDocuments(t,e,n=G()){const i=Qt();return this.populateOverlays(t,i,e).next(()=>this.computeViews(t,e,i,n).next(s=>{let a=Rr();return s.forEach((u,c)=>{a=a.insert(u,c.overlayedDocument)}),a}))}getOverlayedDocuments(t,e){const n=Qt();return this.populateOverlays(t,n,e).next(()=>this.computeViews(t,e,n,G()))}populateOverlays(t,e,n){const i=[];return n.forEach(s=>{e.has(s)||i.push(s)}),this.documentOverlayCache.getOverlays(t,i).next(s=>{s.forEach((a,u)=>{e.set(a,u)})})}computeViews(t,e,n,i){let s=Bt();const a=Cr(),u=function(){return Cr()}();return e.forEach((c,h)=>{const f=n.get(h.key);i.has(h.key)&&(f===void 0||f.mutation instanceof oe)?s=s.insert(h.key,h):f!==void 0?(a.set(h.key,f.mutation.getFieldMask()),Dr(f.mutation,h,f.mutation.getFieldMask(),lt.now())):a.set(h.key,Lt.empty())}),this.recalculateAndSaveOverlays(t,s).next(c=>(c.forEach((h,f)=>a.set(h,f)),e.forEach((h,f)=>{var g;return u.set(h,new e_(f,(g=a.get(h))!==null&&g!==void 0?g:null))}),u))}recalculateAndSaveOverlays(t,e){const n=Cr();let i=new it((a,u)=>a-u),s=G();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next(a=>{for(const u of a)u.keys().forEach(c=>{const h=e.get(c);if(h===null)return;let f=n.get(c)||Lt.empty();f=u.applyToLocalView(h,f),n.set(c,f);const g=(i.get(u.batchId)||G()).add(c);i=i.insert(u.batchId,g)})}).next(()=>{const a=[],u=i.getReverseIterator();for(;u.hasNext();){const c=u.getNext(),h=c.key,f=c.value,g=gh();f.forEach(_=>{if(!s.has(_)){const R=vh(e.get(_),n.get(_));R!==null&&g.set(_,R),s=s.add(_)}}),a.push(this.documentOverlayCache.saveOverlays(t,h,g))}return w.waitFor(a)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(n=>this.recalculateAndSaveOverlays(t,n))}getDocumentsMatchingQuery(t,e,n,i){return function(a){return M.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):Go(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n,i):this.getDocumentsMatchingCollectionQuery(t,e,n,i)}getNextDocuments(t,e,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,i).next(s=>{const a=i-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,i-s.size):w.resolve(Qt());let u=-1,c=s;return a.next(h=>w.forEach(h,(f,g)=>(u<g.largestBatchId&&(u=g.largestBatchId),s.get(f)?w.resolve():this.remoteDocumentCache.getEntry(t,f).next(_=>{c=c.insert(f,_)}))).next(()=>this.populateOverlays(t,h,s)).next(()=>this.computeViews(t,c,h,G())).next(f=>({batchId:u,changes:mh(f)})))})}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new M(e)).next(n=>{let i=Rr();return n.isFoundDocument()&&(i=i.insert(n.key,n)),i})}getDocumentsMatchingCollectionGroupQuery(t,e,n,i){const s=e.collectionGroup;let a=Rr();return this.indexManager.getCollectionParents(t,s).next(u=>w.forEach(u,c=>{const h=function(g,_){return new ie(_,null,g.explicitOrderBy.slice(),g.filters.slice(),g.limit,g.limitType,g.startAt,g.endAt)}(e,c.child(s));return this.getDocumentsMatchingCollectionQuery(t,h,n,i).next(f=>{f.forEach((g,_)=>{a=a.insert(g,_)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(t,e,n,i){let s;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId).next(a=>(s=a,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n,s,i))).next(a=>{s.forEach((c,h)=>{const f=h.getKey();a.get(f)===null&&(a=a.insert(f,ot.newInvalidDocument(f)))});let u=Rr();return a.forEach((c,h)=>{const f=s.get(c);f!==void 0&&Dr(f.mutation,h,Lt.empty(),lt.now()),Yr(e,h)&&(u=u.insert(c,h))}),u})}}/**
|
|
1577
|
-
* @license
|
|
1578
|
-
* Copyright 2020 Google LLC
|
|
1579
|
-
*
|
|
1580
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1581
|
-
* you may not use this file except in compliance with the License.
|
|
1582
|
-
* You may obtain a copy of the License at
|
|
1583
|
-
*
|
|
1584
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1585
|
-
*
|
|
1586
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1587
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1588
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1589
|
-
* See the License for the specific language governing permissions and
|
|
1590
|
-
* limitations under the License.
|
|
1591
|
-
*/class n_{constructor(t){this.serializer=t,this.hr=new Map,this.Pr=new Map}getBundleMetadata(t,e){return w.resolve(this.hr.get(e))}saveBundleMetadata(t,e){return this.hr.set(e.id,function(i){return{id:i.id,version:i.version,createTime:pt(i.createTime)}}(e)),w.resolve()}getNamedQuery(t,e){return w.resolve(this.Pr.get(e))}saveNamedQuery(t,e){return this.Pr.set(e.name,function(i){return{name:i.name,query:Zo(i.bundledQuery),readTime:pt(i.readTime)}}(e)),w.resolve()}}/**
|
|
1592
|
-
* @license
|
|
1593
|
-
* Copyright 2022 Google LLC
|
|
1594
|
-
*
|
|
1595
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1596
|
-
* you may not use this file except in compliance with the License.
|
|
1597
|
-
* You may obtain a copy of the License at
|
|
1598
|
-
*
|
|
1599
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1600
|
-
*
|
|
1601
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1602
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1603
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1604
|
-
* See the License for the specific language governing permissions and
|
|
1605
|
-
* limitations under the License.
|
|
1606
|
-
*/class r_{constructor(){this.overlays=new it(M.comparator),this.Ir=new Map}getOverlay(t,e){return w.resolve(this.overlays.get(e))}getOverlays(t,e){const n=Qt();return w.forEach(e,i=>this.getOverlay(t,i).next(s=>{s!==null&&n.set(i,s)})).next(()=>n)}saveOverlays(t,e,n){return n.forEach((i,s)=>{this.ht(t,e,s)}),w.resolve()}removeOverlaysForBatchId(t,e,n){const i=this.Ir.get(n);return i!==void 0&&(i.forEach(s=>this.overlays=this.overlays.remove(s)),this.Ir.delete(n)),w.resolve()}getOverlaysForCollection(t,e,n){const i=Qt(),s=e.length+1,a=new M(e.child("")),u=this.overlays.getIteratorFrom(a);for(;u.hasNext();){const c=u.getNext().value,h=c.getKey();if(!e.isPrefixOf(h.path))break;h.path.length===s&&c.largestBatchId>n&&i.set(c.getKey(),c)}return w.resolve(i)}getOverlaysForCollectionGroup(t,e,n,i){let s=new it((h,f)=>h-f);const a=this.overlays.getIterator();for(;a.hasNext();){const h=a.getNext().value;if(h.getKey().getCollectionGroup()===e&&h.largestBatchId>n){let f=s.get(h.largestBatchId);f===null&&(f=Qt(),s=s.insert(h.largestBatchId,f)),f.set(h.getKey(),h)}}const u=Qt(),c=s.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((h,f)=>u.set(h,f)),!(u.size()>=i)););return w.resolve(u)}ht(t,e,n){const i=this.overlays.get(n.key);if(i!==null){const a=this.Ir.get(i.largestBatchId).delete(n.key);this.Ir.set(i.largestBatchId,a)}this.overlays=this.overlays.insert(n.key,new Jo(e,n));let s=this.Ir.get(e);s===void 0&&(s=G(),this.Ir.set(e,s)),this.Ir.set(e,s.add(n.key))}}/**
|
|
1607
|
-
* @license
|
|
1608
|
-
* Copyright 2024 Google LLC
|
|
1609
|
-
*
|
|
1610
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1611
|
-
* you may not use this file except in compliance with the License.
|
|
1612
|
-
* You may obtain a copy of the License at
|
|
1613
|
-
*
|
|
1614
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1615
|
-
*
|
|
1616
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1617
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1618
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1619
|
-
* See the License for the specific language governing permissions and
|
|
1620
|
-
* limitations under the License.
|
|
1621
|
-
*/class i_{constructor(){this.sessionToken=dt.EMPTY_BYTE_STRING}getSessionToken(t){return w.resolve(this.sessionToken)}setSessionToken(t,e){return this.sessionToken=e,w.resolve()}}/**
|
|
1622
|
-
* @license
|
|
1623
|
-
* Copyright 2017 Google LLC
|
|
1624
|
-
*
|
|
1625
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1626
|
-
* you may not use this file except in compliance with the License.
|
|
1627
|
-
* You may obtain a copy of the License at
|
|
1628
|
-
*
|
|
1629
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1630
|
-
*
|
|
1631
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1632
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1633
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1634
|
-
* See the License for the specific language governing permissions and
|
|
1635
|
-
* limitations under the License.
|
|
1636
|
-
*/class na{constructor(){this.Tr=new et(Et.Er),this.dr=new et(Et.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(t,e){const n=new Et(t,e);this.Tr=this.Tr.add(n),this.dr=this.dr.add(n)}Rr(t,e){t.forEach(n=>this.addReference(n,e))}removeReference(t,e){this.Vr(new Et(t,e))}mr(t,e){t.forEach(n=>this.removeReference(n,e))}gr(t){const e=new M(new W([])),n=new Et(e,t),i=new Et(e,t+1),s=[];return this.dr.forEachInRange([n,i],a=>{this.Vr(a),s.push(a.key)}),s}pr(){this.Tr.forEach(t=>this.Vr(t))}Vr(t){this.Tr=this.Tr.delete(t),this.dr=this.dr.delete(t)}yr(t){const e=new M(new W([])),n=new Et(e,t),i=new Et(e,t+1);let s=G();return this.dr.forEachInRange([n,i],a=>{s=s.add(a.key)}),s}containsKey(t){const e=new Et(t,0),n=this.Tr.firstAfterOrEqual(e);return n!==null&&t.isEqual(n.key)}}class Et{constructor(t,e){this.key=t,this.wr=e}static Er(t,e){return M.comparator(t.key,e.key)||j(t.wr,e.wr)}static Ar(t,e){return j(t.wr,e.wr)||M.comparator(t.key,e.key)}}/**
|
|
1637
|
-
* @license
|
|
1638
|
-
* Copyright 2017 Google LLC
|
|
1639
|
-
*
|
|
1640
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1641
|
-
* you may not use this file except in compliance with the License.
|
|
1642
|
-
* You may obtain a copy of the License at
|
|
1643
|
-
*
|
|
1644
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1645
|
-
*
|
|
1646
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1647
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1648
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1649
|
-
* See the License for the specific language governing permissions and
|
|
1650
|
-
* limitations under the License.
|
|
1651
|
-
*/class s_{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.Sr=1,this.br=new et(Et.Er)}checkEmpty(t){return w.resolve(this.mutationQueue.length===0)}addMutationBatch(t,e,n,i){const s=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new Wo(s,e,n,i);this.mutationQueue.push(a);for(const u of i)this.br=this.br.add(new Et(u.key,s)),this.indexManager.addToCollectionParentIndex(t,u.key.path.popLast());return w.resolve(a)}lookupMutationBatch(t,e){return w.resolve(this.Dr(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,i=this.vr(n),s=i<0?0:i;return w.resolve(this.mutationQueue.length>s?this.mutationQueue[s]:null)}getHighestUnacknowledgedBatchId(){return w.resolve(this.mutationQueue.length===0?-1:this.Sr-1)}getAllMutationBatches(t){return w.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new Et(e,0),i=new Et(e,Number.POSITIVE_INFINITY),s=[];return this.br.forEachInRange([n,i],a=>{const u=this.Dr(a.wr);s.push(u)}),w.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new et(j);return e.forEach(i=>{const s=new Et(i,0),a=new Et(i,Number.POSITIVE_INFINITY);this.br.forEachInRange([s,a],u=>{n=n.add(u.wr)})}),w.resolve(this.Cr(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,i=n.length+1;let s=n;M.isDocumentKey(s)||(s=s.child(""));const a=new Et(new M(s),0);let u=new et(j);return this.br.forEachWhile(c=>{const h=c.key.path;return!!n.isPrefixOf(h)&&(h.length===i&&(u=u.add(c.wr)),!0)},a),w.resolve(this.Cr(u))}Cr(t){const e=[];return t.forEach(n=>{const i=this.Dr(n);i!==null&&e.push(i)}),e}removeMutationBatch(t,e){L(this.Fr(e.batchId,"removed")===0),this.mutationQueue.shift();let n=this.br;return w.forEach(e.mutations,i=>{const s=new Et(i.key,e.batchId);return n=n.delete(s),this.referenceDelegate.markPotentiallyOrphaned(t,i.key)}).next(()=>{this.br=n})}On(t){}containsKey(t,e){const n=new Et(e,0),i=this.br.firstAfterOrEqual(n);return w.resolve(e.isEqual(i&&i.key))}performConsistencyCheck(t){return this.mutationQueue.length,w.resolve()}Fr(t,e){return this.vr(t)}vr(t){return this.mutationQueue.length===0?0:t-this.mutationQueue[0].batchId}Dr(t){const e=this.vr(t);return e<0||e>=this.mutationQueue.length?null:this.mutationQueue[e]}}/**
|
|
1652
|
-
* @license
|
|
1653
|
-
* Copyright 2017 Google LLC
|
|
1654
|
-
*
|
|
1655
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1656
|
-
* you may not use this file except in compliance with the License.
|
|
1657
|
-
* You may obtain a copy of the License at
|
|
1658
|
-
*
|
|
1659
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1660
|
-
*
|
|
1661
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1662
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1663
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1664
|
-
* See the License for the specific language governing permissions and
|
|
1665
|
-
* limitations under the License.
|
|
1666
|
-
*/class o_{constructor(t){this.Mr=t,this.docs=function(){return new it(M.comparator)}(),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){const n=e.key,i=this.docs.get(n),s=i?i.size:0,a=this.Mr(e);return this.docs=this.docs.insert(n,{document:e.mutableCopy(),size:a}),this.size+=a-s,this.indexManager.addToCollectionParentIndex(t,n.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const n=this.docs.get(e);return w.resolve(n?n.document.mutableCopy():ot.newInvalidDocument(e))}getEntries(t,e){let n=Bt();return e.forEach(i=>{const s=this.docs.get(i);n=n.insert(i,s?s.document.mutableCopy():ot.newInvalidDocument(i))}),w.resolve(n)}getDocumentsMatchingQuery(t,e,n,i){let s=Bt();const a=e.path,u=new M(a.child("")),c=this.docs.getIteratorFrom(u);for(;c.hasNext();){const{key:h,value:{document:f}}=c.getNext();if(!a.isPrefixOf(h.path))break;h.path.length>a.length+1||Uo(Bl(f),n)<=0||(i.has(f.key)||Yr(e,f))&&(s=s.insert(f.key,f.mutableCopy()))}return w.resolve(s)}getAllFromCollectionGroup(t,e,n,i){O()}Or(t,e){return w.forEach(this.docs,n=>e(n))}newChangeBuffer(t){return new a_(this)}getSize(t){return w.resolve(this.size)}}class a_ extends Yh{constructor(t){super(),this.cr=t}applyChanges(t){const e=[];return this.changes.forEach((n,i)=>{i.isValidDocument()?e.push(this.cr.addEntry(t,i)):this.cr.removeEntry(n)}),w.waitFor(e)}getFromCache(t,e){return this.cr.getEntry(t,e)}getAllFromCache(t,e){return this.cr.getEntries(t,e)}}/**
|
|
1667
|
-
* @license
|
|
1668
|
-
* Copyright 2017 Google LLC
|
|
1669
|
-
*
|
|
1670
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1671
|
-
* you may not use this file except in compliance with the License.
|
|
1672
|
-
* You may obtain a copy of the License at
|
|
1673
|
-
*
|
|
1674
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1675
|
-
*
|
|
1676
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1677
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1678
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1679
|
-
* See the License for the specific language governing permissions and
|
|
1680
|
-
* limitations under the License.
|
|
1681
|
-
*/class u_{constructor(t){this.persistence=t,this.Nr=new se(e=>Ze(e),Hr),this.lastRemoteSnapshotVersion=U.min(),this.highestTargetId=0,this.Lr=0,this.Br=new na,this.targetCount=0,this.kr=sn.Bn()}forEachTarget(t,e){return this.Nr.forEach((n,i)=>e(i)),w.resolve()}getLastRemoteSnapshotVersion(t){return w.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return w.resolve(this.Lr)}allocateTargetId(t){return this.highestTargetId=this.kr.next(),w.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Lr&&(this.Lr=e),w.resolve()}Kn(t){this.Nr.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.kr=new sn(e),this.highestTargetId=e),t.sequenceNumber>this.Lr&&(this.Lr=t.sequenceNumber)}addTargetData(t,e){return this.Kn(e),this.targetCount+=1,w.resolve()}updateTargetData(t,e){return this.Kn(e),w.resolve()}removeTargetData(t,e){return this.Nr.delete(e.target),this.Br.gr(e.targetId),this.targetCount-=1,w.resolve()}removeTargets(t,e,n){let i=0;const s=[];return this.Nr.forEach((a,u)=>{u.sequenceNumber<=e&&n.get(u.targetId)===null&&(this.Nr.delete(a),s.push(this.removeMatchingKeysForTargetId(t,u.targetId)),i++)}),w.waitFor(s).next(()=>i)}getTargetCount(t){return w.resolve(this.targetCount)}getTargetData(t,e){const n=this.Nr.get(e)||null;return w.resolve(n)}addMatchingKeys(t,e,n){return this.Br.Rr(e,n),w.resolve()}removeMatchingKeys(t,e,n){this.Br.mr(e,n);const i=this.persistence.referenceDelegate,s=[];return i&&e.forEach(a=>{s.push(i.markPotentiallyOrphaned(t,a))}),w.waitFor(s)}removeMatchingKeysForTargetId(t,e){return this.Br.gr(e),w.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Br.yr(e);return w.resolve(n)}containsKey(t,e){return w.resolve(this.Br.containsKey(e))}}/**
|
|
1682
|
-
* @license
|
|
1683
|
-
* Copyright 2017 Google LLC
|
|
1684
|
-
*
|
|
1685
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1686
|
-
* you may not use this file except in compliance with the License.
|
|
1687
|
-
* You may obtain a copy of the License at
|
|
1688
|
-
*
|
|
1689
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1690
|
-
*
|
|
1691
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1692
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1693
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1694
|
-
* See the License for the specific language governing permissions and
|
|
1695
|
-
* limitations under the License.
|
|
1696
|
-
*/class ra{constructor(t,e){this.qr={},this.overlays={},this.Qr=new Ot(0),this.Kr=!1,this.Kr=!0,this.$r=new i_,this.referenceDelegate=t(this),this.Ur=new u_(this),this.indexManager=new Qp,this.remoteDocumentCache=function(i){return new o_(i)}(n=>this.referenceDelegate.Wr(n)),this.serializer=new zh(e),this.Gr=new n_(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new r_,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let n=this.qr[t.toKey()];return n||(n=new s_(e,this.referenceDelegate),this.qr[t.toKey()]=n),n}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(t,e,n){x("MemoryPersistence","Starting transaction:",t);const i=new c_(this.Qr.next());return this.referenceDelegate.zr(),n(i).next(s=>this.referenceDelegate.jr(i).next(()=>s)).toPromise().then(s=>(i.raiseOnCommittedEvent(),s))}Hr(t,e){return w.or(Object.values(this.qr).map(n=>()=>n.containsKey(t,e)))}}class c_ extends ql{constructor(t){super(),this.currentSequenceNumber=t}}class ps{constructor(t){this.persistence=t,this.Jr=new na,this.Yr=null}static Zr(t){return new ps(t)}get Xr(){if(this.Yr)return this.Yr;throw O()}addReference(t,e,n){return this.Jr.addReference(n,e),this.Xr.delete(n.toString()),w.resolve()}removeReference(t,e,n){return this.Jr.removeReference(n,e),this.Xr.add(n.toString()),w.resolve()}markPotentiallyOrphaned(t,e){return this.Xr.add(e.toString()),w.resolve()}removeTarget(t,e){this.Jr.gr(e.targetId).forEach(i=>this.Xr.add(i.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next(i=>{i.forEach(s=>this.Xr.add(s.toString()))}).next(()=>n.removeTargetData(t,e))}zr(){this.Yr=new Set}jr(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return w.forEach(this.Xr,n=>{const i=M.fromPath(n);return this.ei(t,i).next(s=>{s||e.removeEntry(i,U.min())})}).next(()=>(this.Yr=null,e.apply(t)))}updateLimboDocument(t,e){return this.ei(t,e).next(n=>{n?this.Xr.delete(e.toString()):this.Xr.add(e.toString())})}Wr(t){return 0}ei(t,e){return w.or([()=>w.resolve(this.Jr.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Hr(t,e)])}}class ts{constructor(t,e){this.persistence=t,this.ti=new se(n=>Nt(n.path),(n,i)=>n.isEqual(i)),this.garbageCollector=Jh(this,e)}static Zr(t,e){return new ts(t,e)}zr(){}jr(t){return w.resolve()}forEachTarget(t,e){return this.persistence.getTargetCache().forEachTarget(t,e)}Yn(t){const e=this.er(t);return this.persistence.getTargetCache().getTargetCount(t).next(n=>e.next(i=>n+i))}er(t){let e=0;return this.Zn(t,n=>{e++}).next(()=>e)}Zn(t,e){return w.forEach(this.ti,(n,i)=>this.nr(t,n,i).next(s=>s?w.resolve():e(i)))}removeTargets(t,e,n){return this.persistence.getTargetCache().removeTargets(t,e,n)}removeOrphanedDocuments(t,e){let n=0;const i=this.persistence.getRemoteDocumentCache(),s=i.newChangeBuffer();return i.Or(t,a=>this.nr(t,a,e).next(u=>{u||(n++,s.removeEntry(a,U.min()))})).next(()=>s.apply(t)).next(()=>n)}markPotentiallyOrphaned(t,e){return this.ti.set(e,t.currentSequenceNumber),w.resolve()}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,n)}addReference(t,e,n){return this.ti.set(n,t.currentSequenceNumber),w.resolve()}removeReference(t,e,n){return this.ti.set(n,t.currentSequenceNumber),w.resolve()}updateLimboDocument(t,e){return this.ti.set(e,t.currentSequenceNumber),w.resolve()}Wr(t){let e=t.key.toString().length;return t.isFoundDocument()&&(e+=Bi(t.data.value)),e}nr(t,e,n){return w.or([()=>this.persistence.Hr(t,e),()=>this.persistence.getTargetCache().containsKey(t,e),()=>{const i=this.ti.get(e);return w.resolve(i!==void 0&&i>n)}])}getCacheSize(t){return this.persistence.getRemoteDocumentCache().getSize(t)}}/**
|
|
1697
|
-
* @license
|
|
1698
|
-
* Copyright 2020 Google LLC
|
|
1699
|
-
*
|
|
1700
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1701
|
-
* you may not use this file except in compliance with the License.
|
|
1702
|
-
* You may obtain a copy of the License at
|
|
1703
|
-
*
|
|
1704
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1705
|
-
*
|
|
1706
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1707
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1708
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1709
|
-
* See the License for the specific language governing permissions and
|
|
1710
|
-
* limitations under the License.
|
|
1711
|
-
*/class l_{constructor(t){this.serializer=t}O(t,e,n,i){const s=new as("createOrUpgrade",e);n<1&&i>=1&&(function(c){c.createObjectStore("owner")}(t),function(c){c.createObjectStore("mutationQueues",{keyPath:"userId"}),c.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Ju,{unique:!0}),c.createObjectStore("documentMutations")}(t),Oc(t),function(c){c.createObjectStore("remoteDocuments")}(t));let a=w.resolve();return n<3&&i>=3&&(n!==0&&(function(c){c.deleteObjectStore("targetDocuments"),c.deleteObjectStore("targets"),c.deleteObjectStore("targetGlobal")}(t),Oc(t)),a=a.next(()=>function(c){const h=c.store("targetGlobal"),f={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:U.min().toTimestamp(),targetCount:0};return h.put("targetGlobalKey",f)}(s))),n<4&&i>=4&&(n!==0&&(a=a.next(()=>function(c,h){return h.store("mutations").U().next(f=>{c.deleteObjectStore("mutations"),c.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Ju,{unique:!0});const g=h.store("mutations"),_=f.map(R=>g.put(R));return w.waitFor(_)})}(t,s))),a=a.next(()=>{(function(c){c.createObjectStore("clientMetadata",{keyPath:"clientId"})})(t)})),n<5&&i>=5&&(a=a.next(()=>this.ni(s))),n<6&&i>=6&&(a=a.next(()=>(function(c){c.createObjectStore("remoteDocumentGlobal")}(t),this.ri(s)))),n<7&&i>=7&&(a=a.next(()=>this.ii(s))),n<8&&i>=8&&(a=a.next(()=>this.si(t,s))),n<9&&i>=9&&(a=a.next(()=>{(function(c){c.objectStoreNames.contains("remoteDocumentChanges")&&c.deleteObjectStore("remoteDocumentChanges")})(t)})),n<10&&i>=10&&(a=a.next(()=>this.oi(s))),n<11&&i>=11&&(a=a.next(()=>{(function(c){c.createObjectStore("bundles",{keyPath:"bundleId"})})(t),function(c){c.createObjectStore("namedQueries",{keyPath:"name"})}(t)})),n<12&&i>=12&&(a=a.next(()=>{(function(c){const h=c.createObjectStore("documentOverlays",{keyPath:Qg});h.createIndex("collectionPathOverlayIndex",Wg,{unique:!1}),h.createIndex("collectionGroupOverlayIndex",Hg,{unique:!1})})(t)})),n<13&&i>=13&&(a=a.next(()=>function(c){const h=c.createObjectStore("remoteDocumentsV14",{keyPath:Mg});h.createIndex("documentKeyIndex",Og),h.createIndex("collectionGroupIndex",Lg)}(t)).next(()=>this._i(t,s)).next(()=>t.deleteObjectStore("remoteDocuments"))),n<14&&i>=14&&(a=a.next(()=>this.ai(t,s))),n<15&&i>=15&&(a=a.next(()=>function(c){c.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),c.createObjectStore("indexState",{keyPath:jg}).createIndex("sequenceNumberIndex",Gg,{unique:!1}),c.createObjectStore("indexEntries",{keyPath:Kg}).createIndex("documentKeyIndex",$g,{unique:!1})}(t))),n<16&&i>=16&&(a=a.next(()=>{e.objectStore("indexState").clear()}).next(()=>{e.objectStore("indexEntries").clear()})),n<17&&i>=17&&(a=a.next(()=>{(function(c){c.createObjectStore("globals",{keyPath:"name"})})(t)})),a}ri(t){let e=0;return t.store("remoteDocuments").J((n,i)=>{e+=Zi(i)}).next(()=>{const n={byteSize:e};return t.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)})}ni(t){const e=t.store("mutationQueues"),n=t.store("mutations");return e.U().next(i=>w.forEach(i,s=>{const a=IDBKeyRange.bound([s.userId,-1],[s.userId,s.lastAcknowledgedBatchId]);return n.U("userMutationsIndex",a).next(u=>w.forEach(u,c=>{L(c.userId===s.userId);const h=Ke(this.serializer,c);return $h(t,s.userId,h).next(()=>{})}))}))}ii(t){const e=t.store("targetDocuments"),n=t.store("remoteDocuments");return t.store("targetGlobal").get("targetGlobalKey").next(i=>{const s=[];return n.J((a,u)=>{const c=new W(a),h=function(g){return[0,Nt(g)]}(c);s.push(e.get(h).next(f=>f?w.resolve():(g=>e.put({targetId:0,path:Nt(g),sequenceNumber:i.highestListenSequenceNumber}))(c)))}).next(()=>w.waitFor(s))})}si(t,e){t.createObjectStore("collectionParents",{keyPath:zg});const n=e.store("collectionParents"),i=new ea,s=a=>{if(i.add(a)){const u=a.lastSegment(),c=a.popLast();return n.put({collectionId:u,parent:Nt(c)})}};return e.store("remoteDocuments").J({H:!0},(a,u)=>{const c=new W(a);return s(c.popLast())}).next(()=>e.store("documentMutations").J({H:!0},([a,u,c],h)=>{const f=$t(u);return s(f.popLast())}))}oi(t){const e=t.store("targets");return e.J((n,i)=>{const s=Pr(i),a=jh(this.serializer,s);return e.put(a)})}_i(t,e){const n=e.store("remoteDocuments"),i=[];return n.J((s,a)=>{const u=e.store("remoteDocumentsV14"),c=function(g){return g.document?new M(W.fromString(g.document.name).popFirst(5)):g.noDocument?M.fromSegments(g.noDocument.path):g.unknownDocument?M.fromSegments(g.unknownDocument.path):O()}(a).path.toArray(),h={prefixPath:c.slice(0,c.length-2),collectionGroup:c[c.length-2],documentId:c[c.length-1],readTime:a.readTime||[0,0],unknownDocument:a.unknownDocument,noDocument:a.noDocument,document:a.document,hasCommittedMutations:!!a.hasCommittedMutations};i.push(u.put(h))}).next(()=>w.waitFor(i))}ai(t,e){const n=e.store("mutations"),i=Xh(this.serializer),s=new ra(ps.Zr,this.serializer.ct);return n.U().next(a=>{const u=new Map;return a.forEach(c=>{var h;let f=(h=u.get(c.userId))!==null&&h!==void 0?h:G();Ke(this.serializer,c).keys().forEach(g=>f=f.add(g)),u.set(c.userId,f)}),w.forEach(u,(c,h)=>{const f=new Tt(h),g=ms.lt(this.serializer,f),_=s.getIndexManager(f),R=gs.lt(f,this.serializer,_,s.referenceDelegate);return new Zh(i,R,g,_).recalculateAndSaveOverlaysForDocumentKeys(new po(e,Ot.oe),c).next()})})}}function Oc(r){r.createObjectStore("targetDocuments",{keyPath:Ug}).createIndex("documentTargetsIndex",qg,{unique:!0}),r.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",Bg,{unique:!0}),r.createObjectStore("targetGlobal")}const io="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.";class ia{constructor(t,e,n,i,s,a,u,c,h,f,g=17){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.ui=s,this.window=a,this.document=u,this.ci=h,this.li=f,this.hi=g,this.Qr=null,this.Kr=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Pi=null,this.inForeground=!1,this.Ii=null,this.Ti=null,this.Ei=Number.NEGATIVE_INFINITY,this.di=_=>Promise.resolve(),!ia.D())throw new D(P.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new Xp(this,i),this.Ai=e+"main",this.serializer=new zh(c),this.Ri=new Wt(this.Ai,this.hi,new l_(this.serializer)),this.$r=new qp,this.Ur=new Hp(this.referenceDelegate,this.serializer),this.remoteDocumentCache=Xh(this.serializer),this.Gr=new Up,this.window&&this.window.localStorage?this.Vi=this.window.localStorage:(this.Vi=null,f===!1&>("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.mi().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new D(P.FAILED_PRECONDITION,io);return this.fi(),this.gi(),this.pi(),this.runTransaction("getHighestListenSequenceNumber","readonly",t=>this.Ur.getHighestSequenceNumber(t))}).then(t=>{this.Qr=new Ot(t,this.ci)}).then(()=>{this.Kr=!0}).catch(t=>(this.Ri&&this.Ri.close(),Promise.reject(t)))}yi(t){return this.di=async e=>{if(this.started)return t(e)},t(this.isPrimary)}setDatabaseDeletedListener(t){this.Ri.L(async e=>{e.newVersion===null&&await t()})}setNetworkEnabled(t){this.networkEnabled!==t&&(this.networkEnabled=t,this.ui.enqueueAndForget(async()=>{this.started&&await this.mi()}))}mi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",t=>Ni(t).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.wi(t).next(e=>{e||(this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)))})}).next(()=>this.Si(t)).next(e=>this.isPrimary&&!e?this.bi(t).next(()=>!1):!!e&&this.Di(t).next(()=>!0))).catch(t=>{if(De(t))return x("IndexedDbPersistence","Failed to extend owner lease: ",t),this.isPrimary;if(!this.allowTabSynchronization)throw t;return x("IndexedDbPersistence","Releasing owner lease after error during lease refresh",t),!1}).then(t=>{this.isPrimary!==t&&this.ui.enqueueRetryable(()=>this.di(t)),this.isPrimary=t})}wi(t){return wr(t).get("owner").next(e=>w.resolve(this.vi(e)))}Ci(t){return Ni(t).delete(this.clientId)}async Fi(){if(this.isPrimary&&!this.Mi(this.Ei,18e5)){this.Ei=Date.now();const t=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{const n=It(e,"clientMetadata");return n.U().next(i=>{const s=this.xi(i,18e5),a=i.filter(u=>s.indexOf(u)===-1);return w.forEach(a,u=>n.delete(u.clientId)).next(()=>a)})}).catch(()=>[]);if(this.Vi)for(const e of t)this.Vi.removeItem(this.Oi(e.clientId))}}pi(){this.Ti=this.ui.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.mi().then(()=>this.Fi()).then(()=>this.pi()))}vi(t){return!!t&&t.ownerId===this.clientId}Si(t){return this.li?w.resolve(!0):wr(t).get("owner").next(e=>{if(e!==null&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)){if(this.vi(e)&&this.networkEnabled)return!0;if(!this.vi(e)){if(!e.allowTabSynchronization)throw new D(P.FAILED_PRECONDITION,io);return!1}}return!(!this.networkEnabled||!this.inForeground)||Ni(t).U().next(n=>this.xi(n,5e3).find(i=>{if(this.clientId!==i.clientId){const s=!this.networkEnabled&&i.networkEnabled,a=!this.inForeground&&i.inForeground,u=this.networkEnabled===i.networkEnabled;if(s||a&&u)return!0}return!1})===void 0)}).next(e=>(this.isPrimary!==e&&x("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.Kr=!1,this.Li(),this.Ti&&(this.Ti.cancel(),this.Ti=null),this.Bi(),this.ki(),await this.Ri.runTransaction("shutdown","readwrite",["owner","clientMetadata"],t=>{const e=new po(t,Ot.oe);return this.bi(e).next(()=>this.Ci(e))}),this.Ri.close(),this.qi()}xi(t,e){return t.filter(n=>this.Mi(n.updateTimeMs,e)&&!this.Ni(n.clientId))}Qi(){return this.runTransaction("getActiveClients","readonly",t=>Ni(t).U().next(e=>this.xi(e,18e5).map(n=>n.clientId)))}get started(){return this.Kr}getGlobalsCache(){return this.$r}getMutationQueue(t,e){return gs.lt(t,this.serializer,e,this.referenceDelegate)}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(t){return new Wp(t,this.serializer.ct.databaseId)}getDocumentOverlayCache(t){return ms.lt(this.serializer,t)}getBundleCache(){return this.Gr}runTransaction(t,e,n){x("IndexedDbPersistence","Starting transaction:",t);const i=e==="readonly"?"readonly":"readwrite",s=function(c){return c===17?Xg:c===16?Yg:c===15?zo:c===14?Ql:c===13?$l:c===12?Jg:c===11?Kl:void O()}(this.hi);let a;return this.Ri.runTransaction(t,i,s,u=>(a=new po(u,this.Qr?this.Qr.next():Ot.oe),e==="readwrite-primary"?this.wi(a).next(c=>!!c||this.Si(a)).next(c=>{if(!c)throw gt(`Failed to obtain primary lease for action '${t}'.`),this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)),new D(P.FAILED_PRECONDITION,Ul);return n(a)}).next(c=>this.Di(a).next(()=>c)):this.Ki(a).next(()=>n(a)))).then(u=>(a.raiseOnCommittedEvent(),u))}Ki(t){return wr(t).get("owner").next(e=>{if(e!==null&&this.Mi(e.leaseTimestampMs,5e3)&&!this.Ni(e.ownerId)&&!this.vi(e)&&!(this.li||this.allowTabSynchronization&&e.allowTabSynchronization))throw new D(P.FAILED_PRECONDITION,io)})}Di(t){const e={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return wr(t).put("owner",e)}static D(){return Wt.D()}bi(t){const e=wr(t);return e.get("owner").next(n=>this.vi(n)?(x("IndexedDbPersistence","Releasing primary lease."),e.delete("owner")):w.resolve())}Mi(t,e){const n=Date.now();return!(t<n-e)&&(!(t>n)||(gt(`Detected an update time that is in the future: ${t} > ${n}`),!1))}fi(){this.document!==null&&typeof this.document.addEventListener=="function"&&(this.Ii=()=>{this.ui.enqueueAndForget(()=>(this.inForeground=this.document.visibilityState==="visible",this.mi()))},this.document.addEventListener("visibilitychange",this.Ii),this.inForeground=this.document.visibilityState==="visible")}Bi(){this.Ii&&(this.document.removeEventListener("visibilitychange",this.Ii),this.Ii=null)}gi(){var t;typeof((t=this.window)===null||t===void 0?void 0:t.addEventListener)=="function"&&(this.Pi=()=>{this.Li();const e=/(?:Version|Mobile)\/1[456]/;hl()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.ui.enterRestrictedMode(!0),this.ui.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Pi))}ki(){this.Pi&&(this.window.removeEventListener("pagehide",this.Pi),this.Pi=null)}Ni(t){var e;try{const n=((e=this.Vi)===null||e===void 0?void 0:e.getItem(this.Oi(t)))!==null;return x("IndexedDbPersistence",`Client '${t}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(n){return gt("IndexedDbPersistence","Failed to get zombied client id.",n),!1}}Li(){if(this.Vi)try{this.Vi.setItem(this.Oi(this.clientId),String(Date.now()))}catch(t){gt("Failed to set zombie client id.",t)}}qi(){if(this.Vi)try{this.Vi.removeItem(this.Oi(this.clientId))}catch{}}Oi(t){return`firestore_zombie_${this.persistenceKey}_${t}`}}function wr(r){return It(r,"owner")}function Ni(r){return It(r,"clientMetadata")}function sa(r,t){let e=r.projectId;return r.isDefaultDatabase||(e+="."+r.database),"firestore/"+t+"/"+e+"/"}/**
|
|
1712
|
-
* @license
|
|
1713
|
-
* Copyright 2017 Google LLC
|
|
1714
|
-
*
|
|
1715
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1716
|
-
* you may not use this file except in compliance with the License.
|
|
1717
|
-
* You may obtain a copy of the License at
|
|
1718
|
-
*
|
|
1719
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1720
|
-
*
|
|
1721
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1722
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1723
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1724
|
-
* See the License for the specific language governing permissions and
|
|
1725
|
-
* limitations under the License.
|
|
1726
|
-
*/class oa{constructor(t,e,n,i){this.targetId=t,this.fromCache=e,this.$i=n,this.Ui=i}static Wi(t,e){let n=G(),i=G();for(const s of e.docChanges)switch(s.type){case 0:n=n.add(s.doc.key);break;case 1:i=i.add(s.doc.key)}return new oa(t,e.fromCache,n,i)}}/**
|
|
1727
|
-
* @license
|
|
1728
|
-
* Copyright 2023 Google LLC
|
|
1729
|
-
*
|
|
1730
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1731
|
-
* you may not use this file except in compliance with the License.
|
|
1732
|
-
* You may obtain a copy of the License at
|
|
1733
|
-
*
|
|
1734
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1735
|
-
*
|
|
1736
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1737
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1738
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1739
|
-
* See the License for the specific language governing permissions and
|
|
1740
|
-
* limitations under the License.
|
|
1741
|
-
*/class h_{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(t){this._documentReadCount+=t}}/**
|
|
1742
|
-
* @license
|
|
1743
|
-
* Copyright 2019 Google LLC
|
|
1744
|
-
*
|
|
1745
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1746
|
-
* you may not use this file except in compliance with the License.
|
|
1747
|
-
* You may obtain a copy of the License at
|
|
1748
|
-
*
|
|
1749
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1750
|
-
*
|
|
1751
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1752
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1753
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1754
|
-
* See the License for the specific language governing permissions and
|
|
1755
|
-
* limitations under the License.
|
|
1756
|
-
*/class td{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return hl()?8:zl(Ki())>0?6:4}()}initialize(t,e){this.Ji=t,this.indexManager=e,this.Gi=!0}getDocumentsMatchingQuery(t,e,n,i){const s={result:null};return this.Yi(t,e).next(a=>{s.result=a}).next(()=>{if(!s.result)return this.Zi(t,e,i,n).next(a=>{s.result=a})}).next(()=>{if(s.result)return;const a=new h_;return this.Xi(t,e,a).next(u=>{if(s.result=u,this.zi)return this.es(t,e,a,u.size)})}).next(()=>s.result)}es(t,e,n,i){return n.documentReadCount<this.ji?(En()<=J.DEBUG&&x("QueryEngine","SDK will not create cache indexes for query:",Tn(e),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),w.resolve()):(En()<=J.DEBUG&&x("QueryEngine","Query:",Tn(e),"scans",n.documentReadCount,"local documents and returns",i,"documents as results."),n.documentReadCount>this.Hi*i?(En()<=J.DEBUG&&x("QueryEngine","The SDK decides to create cache indexes for query:",Tn(e),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,kt(e))):w.resolve())}Yi(t,e){if(cc(e))return w.resolve(null);let n=kt(e);return this.indexManager.getIndexType(t,n).next(i=>i===0?null:(e.limit!==null&&i===1&&(e=Hi(e,null,"F"),n=kt(e)),this.indexManager.getDocumentsMatchingTarget(t,n).next(s=>{const a=G(...s);return this.Ji.getDocuments(t,a).next(u=>this.indexManager.getMinOffset(t,n).next(c=>{const h=this.ts(e,u);return this.ns(e,h,a,c.readTime)?this.Yi(t,Hi(e,null,"F")):this.rs(t,h,e,c)}))})))}Zi(t,e,n,i){return cc(e)||i.isEqual(U.min())?w.resolve(null):this.Ji.getDocuments(t,n).next(s=>{const a=this.ts(e,s);return this.ns(e,a,n,i)?w.resolve(null):(En()<=J.DEBUG&&x("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),Tn(e)),this.rs(t,a,e,Ll(i,-1)).next(u=>u))})}ts(t,e){let n=new et(dh(t));return e.forEach((i,s)=>{Yr(t,s)&&(n=n.add(s))}),n}ns(t,e,n,i){if(t.limit===null)return!1;if(n.size!==e.size)return!0;const s=t.limitType==="F"?e.last():e.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(i)>0)}Xi(t,e,n){return En()<=J.DEBUG&&x("QueryEngine","Using full collection scan to execute query:",Tn(e)),this.Ji.getDocumentsMatchingQuery(t,e,zt.min(),n)}rs(t,e,n,i){return this.Ji.getDocumentsMatchingQuery(t,n,i).next(s=>(e.forEach(a=>{s=s.insert(a.key,a)}),s))}}/**
|
|
1757
|
-
* @license
|
|
1758
|
-
* Copyright 2020 Google LLC
|
|
1759
|
-
*
|
|
1760
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1761
|
-
* you may not use this file except in compliance with the License.
|
|
1762
|
-
* You may obtain a copy of the License at
|
|
1763
|
-
*
|
|
1764
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1765
|
-
*
|
|
1766
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1767
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1768
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1769
|
-
* See the License for the specific language governing permissions and
|
|
1770
|
-
* limitations under the License.
|
|
1771
|
-
*/class d_{constructor(t,e,n,i){this.persistence=t,this.ss=e,this.serializer=i,this.os=new it(j),this._s=new se(s=>Ze(s),Hr),this.us=new Map,this.cs=t.getRemoteDocumentCache(),this.Ur=t.getTargetCache(),this.Gr=t.getBundleCache(),this.ls(n)}ls(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Zh(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.os))}}function ed(r,t,e,n){return new d_(r,t,e,n)}async function nd(r,t){const e=k(r);return await e.persistence.runTransaction("Handle user change","readonly",n=>{let i;return e.mutationQueue.getAllMutationBatches(n).next(s=>(i=s,e.ls(t),e.mutationQueue.getAllMutationBatches(n))).next(s=>{const a=[],u=[];let c=G();for(const h of i){a.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}for(const h of s){u.push(h.batchId);for(const f of h.mutations)c=c.add(f.key)}return e.localDocuments.getDocuments(n,c).next(h=>({hs:h,removedBatchIds:a,addedBatchIds:u}))})})}function f_(r,t){const e=k(r);return e.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{const i=t.batch.keys(),s=e.cs.newChangeBuffer({trackRemovals:!0});return function(u,c,h,f){const g=h.batch,_=g.keys();let R=w.resolve();return _.forEach(C=>{R=R.next(()=>f.getEntry(c,C)).next(N=>{const V=h.docVersions.get(C);L(V!==null),N.version.compareTo(V)<0&&(g.applyToRemoteDocument(N,h),N.isValidDocument()&&(N.setReadTime(h.commitVersion),f.addEntry(N)))})}),R.next(()=>u.mutationQueue.removeMutationBatch(c,g))}(e,n,t,s).next(()=>s.apply(n)).next(()=>e.mutationQueue.performConsistencyCheck(n)).next(()=>e.documentOverlayCache.removeOverlaysForBatchId(n,i,t.batch.batchId)).next(()=>e.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(u){let c=G();for(let h=0;h<u.mutationResults.length;++h)u.mutationResults[h].transformResults.length>0&&(c=c.add(u.batch.mutations[h].key));return c}(t))).next(()=>e.localDocuments.getDocuments(n,i))})}function rd(r){const t=k(r);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.Ur.getLastRemoteSnapshotVersion(e))}function m_(r,t){const e=k(r),n=t.snapshotVersion;let i=e.os;return e.persistence.runTransaction("Apply remote event","readwrite-primary",s=>{const a=e.cs.newChangeBuffer({trackRemovals:!0});i=e.os;const u=[];t.targetChanges.forEach((f,g)=>{const _=i.get(g);if(!_)return;u.push(e.Ur.removeMatchingKeys(s,f.removedDocuments,g).next(()=>e.Ur.addMatchingKeys(s,f.addedDocuments,g)));let R=_.withSequenceNumber(s.currentSequenceNumber);t.targetMismatches.get(g)!==null?R=R.withResumeToken(dt.EMPTY_BYTE_STRING,U.min()).withLastLimboFreeSnapshotVersion(U.min()):f.resumeToken.approximateByteSize()>0&&(R=R.withResumeToken(f.resumeToken,n)),i=i.insert(g,R),function(N,V,q){return N.resumeToken.approximateByteSize()===0||V.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=3e8?!0:q.addedDocuments.size+q.modifiedDocuments.size+q.removedDocuments.size>0}(_,R,f)&&u.push(e.Ur.updateTargetData(s,R))});let c=Bt(),h=G();if(t.documentUpdates.forEach(f=>{t.resolvedLimboDocuments.has(f)&&u.push(e.persistence.referenceDelegate.updateLimboDocument(s,f))}),u.push(id(s,a,t.documentUpdates).next(f=>{c=f.Ps,h=f.Is})),!n.isEqual(U.min())){const f=e.Ur.getLastRemoteSnapshotVersion(s).next(g=>e.Ur.setTargetsMetadata(s,s.currentSequenceNumber,n));u.push(f)}return w.waitFor(u).next(()=>a.apply(s)).next(()=>e.localDocuments.getLocalViewOfDocuments(s,c,h)).next(()=>c)}).then(s=>(e.os=i,s))}function id(r,t,e){let n=G(),i=G();return e.forEach(s=>n=n.add(s)),t.getEntries(r,n).next(s=>{let a=Bt();return e.forEach((u,c)=>{const h=s.get(u);c.isFoundDocument()!==h.isFoundDocument()&&(i=i.add(u)),c.isNoDocument()&&c.version.isEqual(U.min())?(t.removeEntry(u,c.readTime),a=a.insert(u,c)):!h.isValidDocument()||c.version.compareTo(h.version)>0||c.version.compareTo(h.version)===0&&h.hasPendingWrites?(t.addEntry(c),a=a.insert(u,c)):x("LocalStore","Ignoring outdated watch update for ",u,". Current version:",h.version," Watch version:",c.version)}),{Ps:a,Is:i}})}function g_(r,t){const e=k(r);return e.persistence.runTransaction("Get next mutation batch","readonly",n=>(t===void 0&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t)))}function On(r,t){const e=k(r);return e.persistence.runTransaction("Allocate target","readwrite",n=>{let i;return e.Ur.getTargetData(n,t).next(s=>s?(i=s,w.resolve(i)):e.Ur.allocateTargetId(n).next(a=>(i=new te(t,a,"TargetPurposeListen",n.currentSequenceNumber),e.Ur.addTargetData(n,i).next(()=>i))))}).then(n=>{const i=e.os.get(n.targetId);return(i===null||n.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(e.os=e.os.insert(n.targetId,n),e._s.set(t,n.targetId)),n})}async function Ln(r,t,e){const n=k(r),i=n.os.get(t),s=e?"readwrite":"readwrite-primary";try{e||await n.persistence.runTransaction("Release target",s,a=>n.persistence.referenceDelegate.removeTarget(a,i))}catch(a){if(!De(a))throw a;x("LocalStore",`Failed to update sequence numbers for target ${t}: ${a}`)}n.os=n.os.remove(t),n._s.delete(i.target)}function es(r,t,e){const n=k(r);let i=U.min(),s=G();return n.persistence.runTransaction("Execute query","readwrite",a=>function(c,h,f){const g=k(c),_=g._s.get(f);return _!==void 0?w.resolve(g.os.get(_)):g.Ur.getTargetData(h,f)}(n,a,kt(t)).next(u=>{if(u)return i=u.lastLimboFreeSnapshotVersion,n.Ur.getMatchingKeysForTargetId(a,u.targetId).next(c=>{s=c})}).next(()=>n.ss.getDocumentsMatchingQuery(a,t,e?i:U.min(),e?s:G())).next(u=>(ad(n,hh(t),u),{documents:u,Ts:s})))}function sd(r,t){const e=k(r),n=k(e.Ur),i=e.os.get(t);return i?Promise.resolve(i.target):e.persistence.runTransaction("Get target data","readonly",s=>n.ot(s,t).next(a=>a?a.target:null))}function od(r,t){const e=k(r),n=e.us.get(t)||U.min();return e.persistence.runTransaction("Get new document changes","readonly",i=>e.cs.getAllFromCollectionGroup(i,t,Ll(n,-1),Number.MAX_SAFE_INTEGER)).then(i=>(ad(e,t,i),i))}function ad(r,t,e){let n=r.us.get(t)||U.min();e.forEach((i,s)=>{s.readTime.compareTo(n)>0&&(n=s.readTime)}),r.us.set(t,n)}async function p_(r,t,e,n){const i=k(r);let s=G(),a=Bt();for(const h of e){const f=t.Es(h.metadata.name);h.document&&(s=s.add(f));const g=t.ds(h);g.setReadTime(t.As(h.metadata.readTime)),a=a.insert(f,g)}const u=i.cs.newChangeBuffer({trackRemovals:!0}),c=await On(i,function(f){return kt(Kn(W.fromString(`__bundle__/docs/${f}`)))}(n));return i.persistence.runTransaction("Apply bundle documents","readwrite",h=>id(h,u,a).next(f=>(u.apply(h),f)).next(f=>i.Ur.removeMatchingKeysForTargetId(h,c.targetId).next(()=>i.Ur.addMatchingKeys(h,s,c.targetId)).next(()=>i.localDocuments.getLocalViewOfDocuments(h,f.Ps,f.Is)).next(()=>f.Ps)))}async function __(r,t,e=G()){const n=await On(r,kt(Zo(t.bundledQuery))),i=k(r);return i.persistence.runTransaction("Save named query","readwrite",s=>{const a=pt(t.readTime);if(n.snapshotVersion.compareTo(a)>=0)return i.Gr.saveNamedQuery(s,t);const u=n.withResumeToken(dt.EMPTY_BYTE_STRING,a);return i.os=i.os.insert(u.targetId,u),i.Ur.updateTargetData(s,u).next(()=>i.Ur.removeMatchingKeysForTargetId(s,n.targetId)).next(()=>i.Ur.addMatchingKeys(s,e,n.targetId)).next(()=>i.Gr.saveNamedQuery(s,t))})}function Lc(r,t){return`firestore_clients_${r}_${t}`}function Bc(r,t,e){let n=`firestore_mutations_${r}_${e}`;return t.isAuthenticated()&&(n+=`_${t.uid}`),n}function so(r,t){return`firestore_targets_${r}_${t}`}class ns{constructor(t,e,n,i){this.user=t,this.batchId=e,this.state=n,this.error=i}static Rs(t,e,n){const i=JSON.parse(n);let s,a=typeof i=="object"&&["pending","acknowledged","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return a&&i.error&&(a=typeof i.error.message=="string"&&typeof i.error.code=="string",a&&(s=new D(i.error.code,i.error.message))),a?new ns(t,e,i.state,s):(gt("SharedClientState",`Failed to parse mutation state for ID '${e}': ${n}`),null)}Vs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class xr{constructor(t,e,n){this.targetId=t,this.state=e,this.error=n}static Rs(t,e){const n=JSON.parse(e);let i,s=typeof n=="object"&&["not-current","current","rejected"].indexOf(n.state)!==-1&&(n.error===void 0||typeof n.error=="object");return s&&n.error&&(s=typeof n.error.message=="string"&&typeof n.error.code=="string",s&&(i=new D(n.error.code,n.error.message))),s?new xr(t,n.state,i):(gt("SharedClientState",`Failed to parse target state for ID '${t}': ${e}`),null)}Vs(){const t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)}}class rs{constructor(t,e){this.clientId=t,this.activeTargetIds=e}static Rs(t,e){const n=JSON.parse(e);let i=typeof n=="object"&&n.activeTargetIds instanceof Array,s=Ko();for(let a=0;i&&a<n.activeTargetIds.length;++a)i=jl(n.activeTargetIds[a]),s=s.add(n.activeTargetIds[a]);return i?new rs(t,s):(gt("SharedClientState",`Failed to parse client data for instance '${t}': ${e}`),null)}}class aa{constructor(t,e){this.clientId=t,this.onlineState=e}static Rs(t){const e=JSON.parse(t);return typeof e=="object"&&["Unknown","Online","Offline"].indexOf(e.onlineState)!==-1&&typeof e.clientId=="string"?new aa(e.clientId,e.onlineState):(gt("SharedClientState",`Failed to parse online state: ${t}`),null)}}class Co{constructor(){this.activeTargetIds=Ko()}fs(t){this.activeTargetIds=this.activeTargetIds.add(t)}gs(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Vs(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class oo{constructor(t,e,n,i,s){this.window=t,this.ui=e,this.persistenceKey=n,this.ps=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.ys=this.ws.bind(this),this.Ss=new it(j),this.started=!1,this.bs=[];const a=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=s,this.Ds=Lc(this.persistenceKey,this.ps),this.vs=function(c){return`firestore_sequence_number_${c}`}(this.persistenceKey),this.Ss=this.Ss.insert(this.ps,new Co),this.Cs=new RegExp(`^firestore_clients_${a}_([^_]*)$`),this.Fs=new RegExp(`^firestore_mutations_${a}_(\\d+)(?:_(.*))?$`),this.Ms=new RegExp(`^firestore_targets_${a}_(\\d+)$`),this.xs=function(c){return`firestore_online_state_${c}`}(this.persistenceKey),this.Os=function(c){return`firestore_bundle_loaded_v2_${c}`}(this.persistenceKey),this.window.addEventListener("storage",this.ys)}static D(t){return!(!t||!t.localStorage)}async start(){const t=await this.syncEngine.Qi();for(const n of t){if(n===this.ps)continue;const i=this.getItem(Lc(this.persistenceKey,n));if(i){const s=rs.Rs(n,i);s&&(this.Ss=this.Ss.insert(s.clientId,s))}}this.Ns();const e=this.storage.getItem(this.xs);if(e){const n=this.Ls(e);n&&this.Bs(n)}for(const n of this.bs)this.ws(n);this.bs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(t){this.setItem(this.vs,JSON.stringify(t))}getAllActiveQueryTargets(){return this.ks(this.Ss)}isActiveQueryTarget(t){let e=!1;return this.Ss.forEach((n,i)=>{i.activeTargetIds.has(t)&&(e=!0)}),e}addPendingMutation(t){this.qs(t,"pending")}updateMutationState(t,e,n){this.qs(t,e,n),this.Qs(t)}addLocalQueryTarget(t,e=!0){let n="not-current";if(this.isActiveQueryTarget(t)){const i=this.storage.getItem(so(this.persistenceKey,t));if(i){const s=xr.Rs(t,i);s&&(n=s.state)}}return e&&this.Ks.fs(t),this.Ns(),n}removeLocalQueryTarget(t){this.Ks.gs(t),this.Ns()}isLocalQueryTarget(t){return this.Ks.activeTargetIds.has(t)}clearQueryState(t){this.removeItem(so(this.persistenceKey,t))}updateQueryState(t,e,n){this.$s(t,e,n)}handleUserChange(t,e,n){e.forEach(i=>{this.Qs(i)}),this.currentUser=t,n.forEach(i=>{this.addPendingMutation(i)})}setOnlineState(t){this.Us(t)}notifyBundleLoaded(t){this.Ws(t)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.ys),this.removeItem(this.Ds),this.started=!1)}getItem(t){const e=this.storage.getItem(t);return x("SharedClientState","READ",t,e),e}setItem(t,e){x("SharedClientState","SET",t,e),this.storage.setItem(t,e)}removeItem(t){x("SharedClientState","REMOVE",t),this.storage.removeItem(t)}ws(t){const e=t;if(e.storageArea===this.storage){if(x("SharedClientState","EVENT",e.key,e.newValue),e.key===this.Ds)return void gt("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.ui.enqueueRetryable(async()=>{if(this.started){if(e.key!==null){if(this.Cs.test(e.key)){if(e.newValue==null){const n=this.Gs(e.key);return this.zs(n,null)}{const n=this.js(e.key,e.newValue);if(n)return this.zs(n.clientId,n)}}else if(this.Fs.test(e.key)){if(e.newValue!==null){const n=this.Hs(e.key,e.newValue);if(n)return this.Js(n)}}else if(this.Ms.test(e.key)){if(e.newValue!==null){const n=this.Ys(e.key,e.newValue);if(n)return this.Zs(n)}}else if(e.key===this.xs){if(e.newValue!==null){const n=this.Ls(e.newValue);if(n)return this.Bs(n)}}else if(e.key===this.vs){const n=function(s){let a=Ot.oe;if(s!=null)try{const u=JSON.parse(s);L(typeof u=="number"),a=u}catch(u){gt("SharedClientState","Failed to read sequence number from WebStorage",u)}return a}(e.newValue);n!==Ot.oe&&this.sequenceNumberHandler(n)}else if(e.key===this.Os){const n=this.Xs(e.newValue);await Promise.all(n.map(i=>this.syncEngine.eo(i)))}}}else this.bs.push(e)})}}get Ks(){return this.Ss.get(this.ps)}Ns(){this.setItem(this.Ds,this.Ks.Vs())}qs(t,e,n){const i=new ns(this.currentUser,t,e,n),s=Bc(this.persistenceKey,this.currentUser,t);this.setItem(s,i.Vs())}Qs(t){const e=Bc(this.persistenceKey,this.currentUser,t);this.removeItem(e)}Us(t){const e={clientId:this.ps,onlineState:t};this.storage.setItem(this.xs,JSON.stringify(e))}$s(t,e,n){const i=so(this.persistenceKey,t),s=new xr(t,e,n);this.setItem(i,s.Vs())}Ws(t){const e=JSON.stringify(Array.from(t));this.setItem(this.Os,e)}Gs(t){const e=this.Cs.exec(t);return e?e[1]:null}js(t,e){const n=this.Gs(t);return rs.Rs(n,e)}Hs(t,e){const n=this.Fs.exec(t),i=Number(n[1]),s=n[2]!==void 0?n[2]:null;return ns.Rs(new Tt(s),i,e)}Ys(t,e){const n=this.Ms.exec(t),i=Number(n[1]);return xr.Rs(i,e)}Ls(t){return aa.Rs(t)}Xs(t){return JSON.parse(t)}async Js(t){if(t.user.uid===this.currentUser.uid)return this.syncEngine.no(t.batchId,t.state,t.error);x("SharedClientState",`Ignoring mutation for non-active user ${t.user.uid}`)}Zs(t){return this.syncEngine.ro(t.targetId,t.state,t.error)}zs(t,e){const n=e?this.Ss.insert(t,e):this.Ss.remove(t),i=this.ks(this.Ss),s=this.ks(n),a=[],u=[];return s.forEach(c=>{i.has(c)||a.push(c)}),i.forEach(c=>{s.has(c)||u.push(c)}),this.syncEngine.io(a,u).then(()=>{this.Ss=n})}Bs(t){this.Ss.get(t.clientId)&&this.onlineStateHandler(t.onlineState)}ks(t){let e=Ko();return t.forEach((n,i)=>{e=e.unionWith(i.activeTargetIds)}),e}}class ud{constructor(){this.so=new Co,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t,e=!0){return e&&this.so.fs(t),this.oo[t]||"not-current"}updateQueryState(t,e,n){this.oo[t]=e}removeLocalQueryTarget(t){this.so.gs(t)}isLocalQueryTarget(t){return this.so.activeTargetIds.has(t)}clearQueryState(t){delete this.oo[t]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(t){return this.so.activeTargetIds.has(t)}start(){return this.so=new Co,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/**
|
|
1772
|
-
* @license
|
|
1773
|
-
* Copyright 2019 Google LLC
|
|
1774
|
-
*
|
|
1775
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1776
|
-
* you may not use this file except in compliance with the License.
|
|
1777
|
-
* You may obtain a copy of the License at
|
|
1778
|
-
*
|
|
1779
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1780
|
-
*
|
|
1781
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1782
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1783
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1784
|
-
* See the License for the specific language governing permissions and
|
|
1785
|
-
* limitations under the License.
|
|
1786
|
-
*/class y_{_o(t){}shutdown(){}}/**
|
|
1787
|
-
* @license
|
|
1788
|
-
* Copyright 2019 Google LLC
|
|
1789
|
-
*
|
|
1790
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1791
|
-
* you may not use this file except in compliance with the License.
|
|
1792
|
-
* You may obtain a copy of the License at
|
|
1793
|
-
*
|
|
1794
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1795
|
-
*
|
|
1796
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1797
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1798
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1799
|
-
* See the License for the specific language governing permissions and
|
|
1800
|
-
* limitations under the License.
|
|
1801
|
-
*/class Uc{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(t){this.ho.push(t)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){x("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const t of this.ho)t(0)}lo(){x("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const t of this.ho)t(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
|
|
1802
|
-
* @license
|
|
1803
|
-
* Copyright 2023 Google LLC
|
|
1804
|
-
*
|
|
1805
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1806
|
-
* you may not use this file except in compliance with the License.
|
|
1807
|
-
* You may obtain a copy of the License at
|
|
1808
|
-
*
|
|
1809
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1810
|
-
*
|
|
1811
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1812
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1813
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1814
|
-
* See the License for the specific language governing permissions and
|
|
1815
|
-
* limitations under the License.
|
|
1816
|
-
*/let ki=null;function ao(){return ki===null?ki=function(){return 268435456+Math.round(2147483648*Math.random())}():ki++,"0x"+ki.toString(16)}/**
|
|
1817
|
-
* @license
|
|
1818
|
-
* Copyright 2020 Google LLC
|
|
1819
|
-
*
|
|
1820
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1821
|
-
* you may not use this file except in compliance with the License.
|
|
1822
|
-
* You may obtain a copy of the License at
|
|
1823
|
-
*
|
|
1824
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1825
|
-
*
|
|
1826
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1827
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1828
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1829
|
-
* See the License for the specific language governing permissions and
|
|
1830
|
-
* limitations under the License.
|
|
1831
|
-
*/const I_={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};/**
|
|
1832
|
-
* @license
|
|
1833
|
-
* Copyright 2017 Google LLC
|
|
1834
|
-
*
|
|
1835
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1836
|
-
* you may not use this file except in compliance with the License.
|
|
1837
|
-
* You may obtain a copy of the License at
|
|
1838
|
-
*
|
|
1839
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1840
|
-
*
|
|
1841
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1842
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1843
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1844
|
-
* See the License for the specific language governing permissions and
|
|
1845
|
-
* limitations under the License.
|
|
1846
|
-
*/class E_{constructor(t){this.Io=t.Io,this.To=t.To}Eo(t){this.Ao=t}Ro(t){this.Vo=t}mo(t){this.fo=t}onMessage(t){this.po=t}close(){this.To()}send(t){this.Io(t)}yo(){this.Ao()}wo(){this.Vo()}So(t){this.fo(t)}bo(t){this.po(t)}}/**
|
|
1847
|
-
* @license
|
|
1848
|
-
* Copyright 2017 Google LLC
|
|
1849
|
-
*
|
|
1850
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1851
|
-
* you may not use this file except in compliance with the License.
|
|
1852
|
-
* You may obtain a copy of the License at
|
|
1853
|
-
*
|
|
1854
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1855
|
-
*
|
|
1856
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1857
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1858
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1859
|
-
* See the License for the specific language governing permissions and
|
|
1860
|
-
* limitations under the License.
|
|
1861
|
-
*/const Dt="WebChannelConnection";class T_ extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const n=e.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Do=n+"://"+e.host,this.vo=`projects/${i}/databases/${s}`,this.Co=this.databaseId.database==="(default)"?`project_id=${i}`:`project_id=${i}&database_id=${s}`}get Fo(){return!1}Mo(e,n,i,s,a){const u=ao(),c=this.xo(e,n.toUriEncodedString());x("RestConnection",`Sending RPC '${e}' ${u}:`,c,i);const h={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(h,s,a),this.No(e,c,h,i).then(f=>(x("RestConnection",`Received RPC '${e}' ${u}: `,f),f),f=>{throw qt("RestConnection",`RPC '${e}' ${u} failed with error: `,f,"url: ",c,"request:",i),f})}Lo(e,n,i,s,a,u){return this.Mo(e,n,i,s,a)}Oo(e,n,i){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Gn}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach((s,a)=>e[a]=s),i&&i.headers.forEach((s,a)=>e[a]=s)}xo(e,n){const i=I_[e];return`${this.Do}/v1/${n}:${i}`}terminate(){}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}No(t,e,n,i){const s=ao();return new Promise((a,u)=>{const c=new Vl;c.setWithCredentials(!0),c.listenOnce(Cl.COMPLETE,()=>{try{switch(c.getLastErrorCode()){case Mi.NO_ERROR:const f=c.getResponseJson();x(Dt,`XHR for RPC '${t}' ${s} received:`,JSON.stringify(f)),a(f);break;case Mi.TIMEOUT:x(Dt,`RPC '${t}' ${s} timed out`),u(new D(P.DEADLINE_EXCEEDED,"Request time out"));break;case Mi.HTTP_ERROR:const g=c.getStatus();if(x(Dt,`RPC '${t}' ${s} failed with status:`,g,"response text:",c.getResponseText()),g>0){let _=c.getResponseJson();Array.isArray(_)&&(_=_[0]);const R=_==null?void 0:_.error;if(R&&R.status&&R.message){const C=function(V){const q=V.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(q)>=0?q:P.UNKNOWN}(R.status);u(new D(C,R.message))}else u(new D(P.UNKNOWN,"Server responded with status "+c.getStatus()))}else u(new D(P.UNAVAILABLE,"Connection failed."));break;default:O()}}finally{x(Dt,`RPC '${t}' ${s} completed.`)}});const h=JSON.stringify(i);x(Dt,`RPC '${t}' ${s} sending request:`,i),c.send(e,"POST",h,n,15)})}Bo(t,e,n){const i=ao(),s=[this.Do,"/","google.firestore.v1.Firestore","/",t,"/channel"],a=Nl(),u=xl(),c={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},h=this.longPollingOptions.timeoutSeconds;h!==void 0&&(c.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Oo(c.initMessageHeaders,e,n),c.encodeInitMessageHeaders=!0;const f=s.join("");x(Dt,`Creating RPC '${t}' stream ${i}: ${f}`,c);const g=a.createWebChannel(f,c);let _=!1,R=!1;const C=new E_({Io:V=>{R?x(Dt,`Not sending because RPC '${t}' stream ${i} is closed:`,V):(_||(x(Dt,`Opening RPC '${t}' stream ${i} transport.`),g.open(),_=!0),x(Dt,`RPC '${t}' stream ${i} sending:`,V),g.send(V))},To:()=>g.close()}),N=(V,q,z)=>{V.listen(q,B=>{try{z(B)}catch($){setTimeout(()=>{throw $},0)}})};return N(g,Ar.EventType.OPEN,()=>{R||(x(Dt,`RPC '${t}' stream ${i} transport opened.`),C.yo())}),N(g,Ar.EventType.CLOSE,()=>{R||(R=!0,x(Dt,`RPC '${t}' stream ${i} transport closed`),C.So())}),N(g,Ar.EventType.ERROR,V=>{R||(R=!0,qt(Dt,`RPC '${t}' stream ${i} transport errored:`,V),C.So(new D(P.UNAVAILABLE,"The operation could not be completed")))}),N(g,Ar.EventType.MESSAGE,V=>{var q;if(!R){const z=V.data[0];L(!!z);const B=z,$=B.error||((q=B[0])===null||q===void 0?void 0:q.error);if($){x(Dt,`RPC '${t}' stream ${i} received error:`,$);const Z=$.status;let K=function(I){const T=_t[I];if(T!==void 0)return bh(T)}(Z),E=$.message;K===void 0&&(K=P.INTERNAL,E="Unknown error status: "+Z+" with message "+$.message),R=!0,C.So(new D(K,E)),g.close()}else x(Dt,`RPC '${t}' stream ${i} received:`,z),C.bo(z)}}),N(u,Dl.STAT_EVENT,V=>{V.stat===mo.PROXY?x(Dt,`RPC '${t}' stream ${i} detected buffering proxy`):V.stat===mo.NOPROXY&&x(Dt,`RPC '${t}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{C.wo()},0),C}}/**
|
|
1862
|
-
* @license
|
|
1863
|
-
* Copyright 2020 Google LLC
|
|
1864
|
-
*
|
|
1865
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1866
|
-
* you may not use this file except in compliance with the License.
|
|
1867
|
-
* You may obtain a copy of the License at
|
|
1868
|
-
*
|
|
1869
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1870
|
-
*
|
|
1871
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1872
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1873
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1874
|
-
* See the License for the specific language governing permissions and
|
|
1875
|
-
* limitations under the License.
|
|
1876
|
-
*//**
|
|
1877
|
-
* @license
|
|
1878
|
-
* Copyright 2020 Google LLC
|
|
1879
|
-
*
|
|
1880
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1881
|
-
* you may not use this file except in compliance with the License.
|
|
1882
|
-
* You may obtain a copy of the License at
|
|
1883
|
-
*
|
|
1884
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1885
|
-
*
|
|
1886
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1887
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1888
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1889
|
-
* See the License for the specific language governing permissions and
|
|
1890
|
-
* limitations under the License.
|
|
1891
|
-
*/function cd(){return typeof window<"u"?window:null}function ji(){return typeof document<"u"?document:null}/**
|
|
1892
|
-
* @license
|
|
1893
|
-
* Copyright 2020 Google LLC
|
|
1894
|
-
*
|
|
1895
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1896
|
-
* you may not use this file except in compliance with the License.
|
|
1897
|
-
* You may obtain a copy of the License at
|
|
1898
|
-
*
|
|
1899
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1900
|
-
*
|
|
1901
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1902
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1903
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1904
|
-
* See the License for the specific language governing permissions and
|
|
1905
|
-
* limitations under the License.
|
|
1906
|
-
*/function ei(r){return new Vp(r,!0)}/**
|
|
1907
|
-
* @license
|
|
1908
|
-
* Copyright 2017 Google LLC
|
|
1909
|
-
*
|
|
1910
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1911
|
-
* you may not use this file except in compliance with the License.
|
|
1912
|
-
* You may obtain a copy of the License at
|
|
1913
|
-
*
|
|
1914
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1915
|
-
*
|
|
1916
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1917
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1918
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1919
|
-
* See the License for the specific language governing permissions and
|
|
1920
|
-
* limitations under the License.
|
|
1921
|
-
*/class ua{constructor(t,e,n=1e3,i=1.5,s=6e4){this.ui=t,this.timerId=e,this.ko=n,this.qo=i,this.Qo=s,this.Ko=0,this.$o=null,this.Uo=Date.now(),this.reset()}reset(){this.Ko=0}Wo(){this.Ko=this.Qo}Go(t){this.cancel();const e=Math.floor(this.Ko+this.zo()),n=Math.max(0,Date.now()-this.Uo),i=Math.max(0,e-n);i>0&&x("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.Ko} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,i,()=>(this.Uo=Date.now(),t())),this.Ko*=this.qo,this.Ko<this.ko&&(this.Ko=this.ko),this.Ko>this.Qo&&(this.Ko=this.Qo)}jo(){this.$o!==null&&(this.$o.skipDelay(),this.$o=null)}cancel(){this.$o!==null&&(this.$o.cancel(),this.$o=null)}zo(){return(Math.random()-.5)*this.Ko}}/**
|
|
1922
|
-
* @license
|
|
1923
|
-
* Copyright 2017 Google LLC
|
|
1924
|
-
*
|
|
1925
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1926
|
-
* you may not use this file except in compliance with the License.
|
|
1927
|
-
* You may obtain a copy of the License at
|
|
1928
|
-
*
|
|
1929
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1930
|
-
*
|
|
1931
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1932
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1933
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1934
|
-
* See the License for the specific language governing permissions and
|
|
1935
|
-
* limitations under the License.
|
|
1936
|
-
*/class ld{constructor(t,e,n,i,s,a,u,c){this.ui=t,this.Ho=n,this.Jo=i,this.connection=s,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=u,this.listener=c,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new ua(t,e)}n_(){return this.state===1||this.state===5||this.r_()}r_(){return this.state===2||this.state===3}start(){this.e_=0,this.state!==4?this.auth():this.i_()}async stop(){this.n_()&&await this.close(0)}s_(){this.state=0,this.t_.reset()}o_(){this.r_()&&this.Zo===null&&(this.Zo=this.ui.enqueueAfterDelay(this.Ho,6e4,()=>this.__()))}a_(t){this.u_(),this.stream.send(t)}async __(){if(this.r_())return this.close(0)}u_(){this.Zo&&(this.Zo.cancel(),this.Zo=null)}c_(){this.Xo&&(this.Xo.cancel(),this.Xo=null)}async close(t,e){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,t!==4?this.t_.reset():e&&e.code===P.RESOURCE_EXHAUSTED?(gt(e.toString()),gt("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):e&&e.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.l_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.mo(e)}l_(){}auth(){this.state=1;const t=this.h_(this.Yo),e=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,i])=>{this.Yo===e&&this.P_(n,i)},n=>{t(()=>{const i=new D(P.UNKNOWN,"Fetching auth token failed: "+n.message);return this.I_(i)})})}P_(t,e){const n=this.h_(this.Yo);this.stream=this.T_(t,e),this.stream.Eo(()=>{n(()=>this.listener.Eo())}),this.stream.Ro(()=>{n(()=>(this.state=2,this.Xo=this.ui.enqueueAfterDelay(this.Jo,1e4,()=>(this.r_()&&(this.state=3),Promise.resolve())),this.listener.Ro()))}),this.stream.mo(i=>{n(()=>this.I_(i))}),this.stream.onMessage(i=>{n(()=>++this.e_==1?this.E_(i):this.onNext(i))})}i_(){this.state=5,this.t_.Go(async()=>{this.state=0,this.start()})}I_(t){return x("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}h_(t){return e=>{this.ui.enqueueAndForget(()=>this.Yo===t?e():(x("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class v_ extends ld{constructor(t,e,n,i,s,a){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,i,a),this.serializer=s}T_(t,e){return this.connection.Bo("Listen",t,e)}E_(t){return this.onNext(t)}onNext(t){this.t_.reset();const e=xp(this.serializer,t),n=function(s){if(!("targetChange"in s))return U.min();const a=s.targetChange;return a.targetIds&&a.targetIds.length?U.min():a.readTime?pt(a.readTime):U.min()}(t);return this.listener.d_(e,n)}A_(t){const e={};e.database=Ro(this.serializer),e.addTarget=function(s,a){let u;const c=a.target;if(u=Qi(c)?{documents:Mh(s,c)}:{query:fs(s,c)._t},u.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){u.resumeToken=Ch(s,a.resumeToken);const h=wo(s,a.expectedCount);h!==null&&(u.expectedCount=h)}else if(a.snapshotVersion.compareTo(U.min())>0){u.readTime=Mn(s,a.snapshotVersion.toTimestamp());const h=wo(s,a.expectedCount);h!==null&&(u.expectedCount=h)}return u}(this.serializer,t);const n=kp(this.serializer,t);n&&(e.labels=n),this.a_(e)}R_(t){const e={};e.database=Ro(this.serializer),e.removeTarget=t,this.a_(e)}}class w_ extends ld{constructor(t,e,n,i,s,a){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,i,a),this.serializer=s}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(t,e){return this.connection.Bo("Write",t,e)}E_(t){return L(!!t.streamToken),this.lastStreamToken=t.streamToken,L(!t.writeResults||t.writeResults.length===0),this.listener.f_()}onNext(t){L(!!t.streamToken),this.lastStreamToken=t.streamToken,this.t_.reset();const e=Np(t.writeResults,t.commitTime),n=pt(t.commitTime);return this.listener.g_(n,e)}p_(){const t={};t.database=Ro(this.serializer),this.a_(t)}m_(t){const e={streamToken:this.lastStreamToken,writes:t.map(n=>Gr(this.serializer,n))};this.a_(e)}}/**
|
|
1937
|
-
* @license
|
|
1938
|
-
* Copyright 2017 Google LLC
|
|
1939
|
-
*
|
|
1940
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1941
|
-
* you may not use this file except in compliance with the License.
|
|
1942
|
-
* You may obtain a copy of the License at
|
|
1943
|
-
*
|
|
1944
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1945
|
-
*
|
|
1946
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1947
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1948
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1949
|
-
* See the License for the specific language governing permissions and
|
|
1950
|
-
* limitations under the License.
|
|
1951
|
-
*/class A_ extends class{}{constructor(t,e,n,i){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=n,this.serializer=i,this.y_=!1}w_(){if(this.y_)throw new D(P.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(t,e,n,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.connection.Mo(t,Ao(e,n),i,s,a)).catch(s=>{throw s.name==="FirebaseError"?(s.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),s):new D(P.UNKNOWN,s.toString())})}Lo(t,e,n,i,s){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,u])=>this.connection.Lo(t,Ao(e,n),i,a,u,s)).catch(a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new D(P.UNKNOWN,a.toString())})}terminate(){this.y_=!0,this.connection.terminate()}}class R_{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.S_=0,this.b_=null,this.D_=!0}v_(){this.S_===0&&(this.C_("Unknown"),this.b_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.b_=null,this.F_("Backend didn't respond within 10 seconds."),this.C_("Offline"),Promise.resolve())))}M_(t){this.state==="Online"?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.C_("Offline")))}set(t){this.x_(),this.S_=0,t==="Online"&&(this.D_=!1),this.C_(t)}C_(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}F_(t){const e=`Could not reach Cloud Firestore backend. ${t}
|
|
1952
|
-
This 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.`;this.D_?(gt(e),this.D_=!1):x("OnlineStateTracker",e)}x_(){this.b_!==null&&(this.b_.cancel(),this.b_=null)}}/**
|
|
1953
|
-
* @license
|
|
1954
|
-
* Copyright 2017 Google LLC
|
|
1955
|
-
*
|
|
1956
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1957
|
-
* you may not use this file except in compliance with the License.
|
|
1958
|
-
* You may obtain a copy of the License at
|
|
1959
|
-
*
|
|
1960
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1961
|
-
*
|
|
1962
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1963
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1964
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1965
|
-
* See the License for the specific language governing permissions and
|
|
1966
|
-
* limitations under the License.
|
|
1967
|
-
*/class b_{constructor(t,e,n,i,s){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=s,this.k_._o(a=>{n.enqueueAndForget(async()=>{Ne(this)&&(x("RemoteStore","Restarting streams for network reachability change."),await async function(c){const h=k(c);h.L_.add(4),await Wn(h),h.q_.set("Unknown"),h.L_.delete(4),await ni(h)}(this))})}),this.q_=new R_(n,i)}}async function ni(r){if(Ne(r))for(const t of r.B_)await t(!0)}async function Wn(r){for(const t of r.B_)await t(!1)}function _s(r,t){const e=k(r);e.N_.has(t.targetId)||(e.N_.set(t.targetId,t),ha(e)?la(e):Jn(e).r_()&&ca(e,t))}function Bn(r,t){const e=k(r),n=Jn(e);e.N_.delete(t),n.r_()&&hd(e,t),e.N_.size===0&&(n.r_()?n.o_():Ne(e)&&e.q_.set("Unknown"))}function ca(r,t){if(r.Q_.xe(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(U.min())>0){const e=r.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(e)}Jn(r).A_(t)}function hd(r,t){r.Q_.xe(t),Jn(r).R_(t)}function la(r){r.Q_=new Rp({getRemoteKeysForTarget:t=>r.remoteSyncer.getRemoteKeysForTarget(t),ot:t=>r.N_.get(t)||null,tt:()=>r.datastore.serializer.databaseId}),Jn(r).start(),r.q_.v_()}function ha(r){return Ne(r)&&!Jn(r).n_()&&r.N_.size>0}function Ne(r){return k(r).L_.size===0}function dd(r){r.Q_=void 0}async function P_(r){r.q_.set("Online")}async function S_(r){r.N_.forEach((t,e)=>{ca(r,t)})}async function V_(r,t){dd(r),ha(r)?(r.q_.M_(t),la(r)):r.q_.set("Unknown")}async function C_(r,t,e){if(r.q_.set("Online"),t instanceof Vh&&t.state===2&&t.cause)try{await async function(i,s){const a=s.cause;for(const u of s.targetIds)i.N_.has(u)&&(await i.remoteSyncer.rejectListen(u,a),i.N_.delete(u),i.Q_.removeTarget(u))}(r,t)}catch(n){x("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),await is(r,n)}else if(t instanceof zi?r.Q_.Ke(t):t instanceof Sh?r.Q_.He(t):r.Q_.We(t),!e.isEqual(U.min()))try{const n=await rd(r.localStore);e.compareTo(n)>=0&&await function(s,a){const u=s.Q_.rt(a);return u.targetChanges.forEach((c,h)=>{if(c.resumeToken.approximateByteSize()>0){const f=s.N_.get(h);f&&s.N_.set(h,f.withResumeToken(c.resumeToken,a))}}),u.targetMismatches.forEach((c,h)=>{const f=s.N_.get(c);if(!f)return;s.N_.set(c,f.withResumeToken(dt.EMPTY_BYTE_STRING,f.snapshotVersion)),hd(s,c);const g=new te(f.target,c,h,f.sequenceNumber);ca(s,g)}),s.remoteSyncer.applyRemoteEvent(u)}(r,e)}catch(n){x("RemoteStore","Failed to raise snapshot:",n),await is(r,n)}}async function is(r,t,e){if(!De(t))throw t;r.L_.add(1),await Wn(r),r.q_.set("Offline"),e||(e=()=>rd(r.localStore)),r.asyncQueue.enqueueRetryable(async()=>{x("RemoteStore","Retrying IndexedDB access"),await e(),r.L_.delete(1),await ni(r)})}function fd(r,t){return t().catch(e=>is(r,e,t))}async function Hn(r){const t=k(r),e=be(t);let n=t.O_.length>0?t.O_[t.O_.length-1].batchId:-1;for(;D_(t);)try{const i=await g_(t.localStore,n);if(i===null){t.O_.length===0&&e.o_();break}n=i.batchId,x_(t,i)}catch(i){await is(t,i)}md(t)&&gd(t)}function D_(r){return Ne(r)&&r.O_.length<10}function x_(r,t){r.O_.push(t);const e=be(r);e.r_()&&e.V_&&e.m_(t.mutations)}function md(r){return Ne(r)&&!be(r).n_()&&r.O_.length>0}function gd(r){be(r).start()}async function N_(r){be(r).p_()}async function k_(r){const t=be(r);for(const e of r.O_)t.m_(e.mutations)}async function F_(r,t,e){const n=r.O_.shift(),i=Ho.from(n,t,e);await fd(r,()=>r.remoteSyncer.applySuccessfulWrite(i)),await Hn(r)}async function M_(r,t){t&&be(r).V_&&await async function(n,i){if(function(a){return Rh(a)&&a!==P.ABORTED}(i.code)){const s=n.O_.shift();be(n).s_(),await fd(n,()=>n.remoteSyncer.rejectFailedWrite(s.batchId,i)),await Hn(n)}}(r,t),md(r)&&gd(r)}async function qc(r,t){const e=k(r);e.asyncQueue.verifyOperationInProgress(),x("RemoteStore","RemoteStore received new credentials");const n=Ne(e);e.L_.add(3),await Wn(e),n&&e.q_.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.L_.delete(3),await ni(e)}async function Do(r,t){const e=k(r);t?(e.L_.delete(2),await ni(e)):t||(e.L_.add(2),await Wn(e),e.q_.set("Unknown"))}function Jn(r){return r.K_||(r.K_=function(e,n,i){const s=k(e);return s.w_(),new v_(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:P_.bind(null,r),Ro:S_.bind(null,r),mo:V_.bind(null,r),d_:C_.bind(null,r)}),r.B_.push(async t=>{t?(r.K_.s_(),ha(r)?la(r):r.q_.set("Unknown")):(await r.K_.stop(),dd(r))})),r.K_}function be(r){return r.U_||(r.U_=function(e,n,i){const s=k(e);return s.w_(),new w_(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:()=>Promise.resolve(),Ro:N_.bind(null,r),mo:M_.bind(null,r),f_:k_.bind(null,r),g_:F_.bind(null,r)}),r.B_.push(async t=>{t?(r.U_.s_(),await Hn(r)):(await r.U_.stop(),r.O_.length>0&&(x("RemoteStore",`Stopping write stream with ${r.O_.length} pending writes`),r.O_=[]))})),r.U_}/**
|
|
1968
|
-
* @license
|
|
1969
|
-
* Copyright 2017 Google LLC
|
|
1970
|
-
*
|
|
1971
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1972
|
-
* you may not use this file except in compliance with the License.
|
|
1973
|
-
* You may obtain a copy of the License at
|
|
1974
|
-
*
|
|
1975
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1976
|
-
*
|
|
1977
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1978
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1979
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1980
|
-
* See the License for the specific language governing permissions and
|
|
1981
|
-
* limitations under the License.
|
|
1982
|
-
*/class da{constructor(t,e,n,i,s){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=i,this.removalCallback=s,this.deferred=new vt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(t,e,n,i,s){const a=Date.now()+n,u=new da(t,e,a,i,s);return u.start(n),u}start(t){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new D(P.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(t=>this.deferred.resolve(t))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Yn(r,t){if(gt("AsyncQueue",`${t}: ${r}`),De(r))return new D(P.UNAVAILABLE,`${t}: ${r}`);throw r}/**
|
|
1983
|
-
* @license
|
|
1984
|
-
* Copyright 2017 Google LLC
|
|
1985
|
-
*
|
|
1986
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1987
|
-
* you may not use this file except in compliance with the License.
|
|
1988
|
-
* You may obtain a copy of the License at
|
|
1989
|
-
*
|
|
1990
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1991
|
-
*
|
|
1992
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1993
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1994
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1995
|
-
* See the License for the specific language governing permissions and
|
|
1996
|
-
* limitations under the License.
|
|
1997
|
-
*/class Rn{constructor(t){this.comparator=t?(e,n)=>t(e,n)||M.comparator(e.key,n.key):(e,n)=>M.comparator(e.key,n.key),this.keyedMap=Rr(),this.sortedSet=new it(this.comparator)}static emptySet(t){return new Rn(t.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal((e,n)=>(t(e),!1))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof Rn)||this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const i=e.getNext().key,s=n.getNext().key;if(!i.isEqual(s))return!1}return!0}toString(){const t=[];return this.forEach(e=>{t.push(e.toString())}),t.length===0?"DocumentSet ()":`DocumentSet (
|
|
1998
|
-
`+t.join(`
|
|
1999
|
-
`)+`
|
|
2000
|
-
)`}copy(t,e){const n=new Rn;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}/**
|
|
2001
|
-
* @license
|
|
2002
|
-
* Copyright 2017 Google LLC
|
|
2003
|
-
*
|
|
2004
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2005
|
-
* you may not use this file except in compliance with the License.
|
|
2006
|
-
* You may obtain a copy of the License at
|
|
2007
|
-
*
|
|
2008
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2009
|
-
*
|
|
2010
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2011
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2012
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2013
|
-
* See the License for the specific language governing permissions and
|
|
2014
|
-
* limitations under the License.
|
|
2015
|
-
*/class zc{constructor(){this.W_=new it(M.comparator)}track(t){const e=t.doc.key,n=this.W_.get(e);n?t.type!==0&&n.type===3?this.W_=this.W_.insert(e,t):t.type===3&&n.type!==1?this.W_=this.W_.insert(e,{type:n.type,doc:t.doc}):t.type===2&&n.type===2?this.W_=this.W_.insert(e,{type:2,doc:t.doc}):t.type===2&&n.type===0?this.W_=this.W_.insert(e,{type:0,doc:t.doc}):t.type===1&&n.type===0?this.W_=this.W_.remove(e):t.type===1&&n.type===2?this.W_=this.W_.insert(e,{type:1,doc:n.doc}):t.type===0&&n.type===1?this.W_=this.W_.insert(e,{type:2,doc:t.doc}):O():this.W_=this.W_.insert(e,t)}G_(){const t=[];return this.W_.inorderTraversal((e,n)=>{t.push(n)}),t}}class Un{constructor(t,e,n,i,s,a,u,c,h){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=i,this.mutatedKeys=s,this.fromCache=a,this.syncStateChanged=u,this.excludesMetadataChanges=c,this.hasCachedResults=h}static fromInitialDocuments(t,e,n,i,s){const a=[];return e.forEach(u=>{a.push({type:0,doc:u})}),new Un(t,e,Rn.emptySet(e),a,n,i,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Jr(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i].type!==n[i].type||!e[i].doc.isEqual(n[i].doc))return!1;return!0}}/**
|
|
2016
|
-
* @license
|
|
2017
|
-
* Copyright 2017 Google LLC
|
|
2018
|
-
*
|
|
2019
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2020
|
-
* you may not use this file except in compliance with the License.
|
|
2021
|
-
* You may obtain a copy of the License at
|
|
2022
|
-
*
|
|
2023
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2024
|
-
*
|
|
2025
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2026
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2027
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2028
|
-
* See the License for the specific language governing permissions and
|
|
2029
|
-
* limitations under the License.
|
|
2030
|
-
*/class O_{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some(t=>t.J_())}}class L_{constructor(){this.queries=jc(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(e,n){const i=k(e),s=i.queries;i.queries=jc(),s.forEach((a,u)=>{for(const c of u.j_)c.onError(n)})})(this,new D(P.ABORTED,"Firestore shutting down"))}}function jc(){return new se(r=>lh(r),Jr)}async function fa(r,t){const e=k(r);let n=3;const i=t.query;let s=e.queries.get(i);s?!s.H_()&&t.J_()&&(n=2):(s=new O_,n=t.J_()?0:1);try{switch(n){case 0:s.z_=await e.onListen(i,!0);break;case 1:s.z_=await e.onListen(i,!1);break;case 2:await e.onFirstRemoteStoreListen(i)}}catch(a){const u=Yn(a,`Initialization of query '${Tn(t.query)}' failed`);return void t.onError(u)}e.queries.set(i,s),s.j_.push(t),t.Z_(e.onlineState),s.z_&&t.X_(s.z_)&&ga(e)}async function ma(r,t){const e=k(r),n=t.query;let i=3;const s=e.queries.get(n);if(s){const a=s.j_.indexOf(t);a>=0&&(s.j_.splice(a,1),s.j_.length===0?i=t.J_()?0:1:!s.H_()&&t.J_()&&(i=2))}switch(i){case 0:return e.queries.delete(n),e.onUnlisten(n,!0);case 1:return e.queries.delete(n),e.onUnlisten(n,!1);case 2:return e.onLastRemoteStoreUnlisten(n);default:return}}function B_(r,t){const e=k(r);let n=!1;for(const i of t){const s=i.query,a=e.queries.get(s);if(a){for(const u of a.j_)u.X_(i)&&(n=!0);a.z_=i}}n&&ga(e)}function U_(r,t,e){const n=k(r),i=n.queries.get(t);if(i)for(const s of i.j_)s.onError(e);n.queries.delete(t)}function ga(r){r.Y_.forEach(t=>{t.next()})}var xo,Gc;(Gc=xo||(xo={})).ea="default",Gc.Cache="cache";class pa{constructor(t,e,n){this.query=t,this.ta=e,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=n||{}}X_(t){if(!this.options.includeMetadataChanges){const n=[];for(const i of t.docChanges)i.type!==3&&n.push(i);t=new Un(t.query,t.docs,t.oldDocs,n,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.na?this.ia(t)&&(this.ta.next(t),e=!0):this.sa(t,this.onlineState)&&(this.oa(t),e=!0),this.ra=t,e}onError(t){this.ta.error(t)}Z_(t){this.onlineState=t;let e=!1;return this.ra&&!this.na&&this.sa(this.ra,t)&&(this.oa(this.ra),e=!0),e}sa(t,e){if(!t.fromCache||!this.J_())return!0;const n=e!=="Offline";return(!this.options._a||!n)&&(!t.docs.isEmpty()||t.hasCachedResults||e==="Offline")}ia(t){if(t.docChanges.length>0)return!0;const e=this.ra&&this.ra.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&this.options.includeMetadataChanges===!0}oa(t){t=Un.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.na=!0,this.ta.next(t)}J_(){return this.options.source!==xo.Cache}}/**
|
|
2031
|
-
* @license
|
|
2032
|
-
* Copyright 2020 Google LLC
|
|
2033
|
-
*
|
|
2034
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2035
|
-
* you may not use this file except in compliance with the License.
|
|
2036
|
-
* You may obtain a copy of the License at
|
|
2037
|
-
*
|
|
2038
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2039
|
-
*
|
|
2040
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2041
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2042
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2043
|
-
* See the License for the specific language governing permissions and
|
|
2044
|
-
* limitations under the License.
|
|
2045
|
-
*/class q_{constructor(t,e){this.aa=t,this.byteLength=e}ua(){return"metadata"in this.aa}}/**
|
|
2046
|
-
* @license
|
|
2047
|
-
* Copyright 2020 Google LLC
|
|
2048
|
-
*
|
|
2049
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2050
|
-
* you may not use this file except in compliance with the License.
|
|
2051
|
-
* You may obtain a copy of the License at
|
|
2052
|
-
*
|
|
2053
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2054
|
-
*
|
|
2055
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2056
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2057
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2058
|
-
* See the License for the specific language governing permissions and
|
|
2059
|
-
* limitations under the License.
|
|
2060
|
-
*/class Kc{constructor(t){this.serializer=t}Es(t){return Ht(this.serializer,t)}ds(t){return t.metadata.exists?Fh(this.serializer,t.document,!1):ot.newNoDocument(this.Es(t.metadata.name),this.As(t.metadata.readTime))}As(t){return pt(t)}}class z_{constructor(t,e,n){this.ca=t,this.localStore=e,this.serializer=n,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=pd(t)}la(t){this.progress.bytesLoaded+=t.byteLength;let e=this.progress.documentsLoaded;if(t.aa.namedQuery)this.queries.push(t.aa.namedQuery);else if(t.aa.documentMetadata){this.documents.push({metadata:t.aa.documentMetadata}),t.aa.documentMetadata.exists||++e;const n=W.fromString(t.aa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else t.aa.document&&(this.documents[this.documents.length-1].document=t.aa.document,++e);return e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null}ha(t){const e=new Map,n=new Kc(this.serializer);for(const i of t)if(i.metadata.queries){const s=n.Es(i.metadata.name);for(const a of i.metadata.queries){const u=(e.get(a)||G()).add(s);e.set(a,u)}}return e}async complete(){const t=await p_(this.localStore,new Kc(this.serializer),this.documents,this.ca.id),e=this.ha(this.documents);for(const n of this.queries)await __(this.localStore,n,e.get(n.name));return this.progress.taskState="Success",{progress:this.progress,Pa:this.collectionGroups,Ia:t}}}function pd(r){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:r.totalDocuments,totalBytes:r.totalBytes}}/**
|
|
2061
|
-
* @license
|
|
2062
|
-
* Copyright 2017 Google LLC
|
|
2063
|
-
*
|
|
2064
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2065
|
-
* you may not use this file except in compliance with the License.
|
|
2066
|
-
* You may obtain a copy of the License at
|
|
2067
|
-
*
|
|
2068
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2069
|
-
*
|
|
2070
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2071
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2072
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2073
|
-
* See the License for the specific language governing permissions and
|
|
2074
|
-
* limitations under the License.
|
|
2075
|
-
*/class _d{constructor(t){this.key=t}}class yd{constructor(t){this.key=t}}class Id{constructor(t,e){this.query=t,this.Ta=e,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=G(),this.mutatedKeys=G(),this.Aa=dh(t),this.Ra=new Rn(this.Aa)}get Va(){return this.Ta}ma(t,e){const n=e?e.fa:new zc,i=e?e.Ra:this.Ra;let s=e?e.mutatedKeys:this.mutatedKeys,a=i,u=!1;const c=this.query.limitType==="F"&&i.size===this.query.limit?i.last():null,h=this.query.limitType==="L"&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal((f,g)=>{const _=i.get(f),R=Yr(this.query,g)?g:null,C=!!_&&this.mutatedKeys.has(_.key),N=!!R&&(R.hasLocalMutations||this.mutatedKeys.has(R.key)&&R.hasCommittedMutations);let V=!1;_&&R?_.data.isEqual(R.data)?C!==N&&(n.track({type:3,doc:R}),V=!0):this.ga(_,R)||(n.track({type:2,doc:R}),V=!0,(c&&this.Aa(R,c)>0||h&&this.Aa(R,h)<0)&&(u=!0)):!_&&R?(n.track({type:0,doc:R}),V=!0):_&&!R&&(n.track({type:1,doc:_}),V=!0,(c||h)&&(u=!0)),V&&(R?(a=a.add(R),s=N?s.add(f):s.delete(f)):(a=a.delete(f),s=s.delete(f)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),s=s.delete(f.key),n.track({type:1,doc:f})}return{Ra:a,fa:n,ns:u,mutatedKeys:s}}ga(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n,i){const s=this.Ra;this.Ra=t.Ra,this.mutatedKeys=t.mutatedKeys;const a=t.fa.G_();a.sort((f,g)=>function(R,C){const N=V=>{switch(V){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return O()}};return N(R)-N(C)}(f.type,g.type)||this.Aa(f.doc,g.doc)),this.pa(n),i=i!=null&&i;const u=e&&!i?this.ya():[],c=this.da.size===0&&this.current&&!i?1:0,h=c!==this.Ea;return this.Ea=c,a.length!==0||h?{snapshot:new Un(this.query,t.Ra,s,a,t.mutatedKeys,c===0,h,!1,!!n&&n.resumeToken.approximateByteSize()>0),wa:u}:{wa:u}}Z_(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new zc,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(t){return!this.Ta.has(t)&&!!this.Ra.has(t)&&!this.Ra.get(t).hasLocalMutations}pa(t){t&&(t.addedDocuments.forEach(e=>this.Ta=this.Ta.add(e)),t.modifiedDocuments.forEach(e=>{}),t.removedDocuments.forEach(e=>this.Ta=this.Ta.delete(e)),this.current=t.current)}ya(){if(!this.current)return[];const t=this.da;this.da=G(),this.Ra.forEach(n=>{this.Sa(n.key)&&(this.da=this.da.add(n.key))});const e=[];return t.forEach(n=>{this.da.has(n)||e.push(new yd(n))}),this.da.forEach(n=>{t.has(n)||e.push(new _d(n))}),e}ba(t){this.Ta=t.Ts,this.da=G();const e=this.ma(t.documents);return this.applyChanges(e,!0)}Da(){return Un.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}}class j_{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class G_{constructor(t){this.key=t,this.va=!1}}class K_{constructor(t,e,n,i,s,a){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=i,this.currentUser=s,this.maxConcurrentLimboResolutions=a,this.Ca={},this.Fa=new se(u=>lh(u),Jr),this.Ma=new Map,this.xa=new Set,this.Oa=new it(M.comparator),this.Na=new Map,this.La=new na,this.Ba={},this.ka=new Map,this.qa=sn.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}}async function $_(r,t,e=!0){const n=ys(r);let i;const s=n.Fa.get(t);return s?(n.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.Da()):i=await Ed(n,t,e,!0),i}async function Q_(r,t){const e=ys(r);await Ed(e,t,!0,!1)}async function Ed(r,t,e,n){const i=await On(r.localStore,kt(t)),s=i.targetId,a=r.sharedClientState.addLocalQueryTarget(s,e);let u;return n&&(u=await _a(r,t,s,a==="current",i.resumeToken)),r.isPrimaryClient&&e&&_s(r.remoteStore,i),u}async function _a(r,t,e,n,i){r.Ka=(g,_,R)=>async function(N,V,q,z){let B=V.view.ma(q);B.ns&&(B=await es(N.localStore,V.query,!1).then(({documents:E})=>V.view.ma(E,B)));const $=z&&z.targetChanges.get(V.targetId),Z=z&&z.targetMismatches.get(V.targetId)!=null,K=V.view.applyChanges(B,N.isPrimaryClient,$,Z);return No(N,V.targetId,K.wa),K.snapshot}(r,g,_,R);const s=await es(r.localStore,t,!0),a=new Id(t,s.Ts),u=a.ma(s.documents),c=ti.createSynthesizedTargetChangeForCurrentChange(e,n&&r.onlineState!=="Offline",i),h=a.applyChanges(u,r.isPrimaryClient,c);No(r,e,h.wa);const f=new j_(t,e,a);return r.Fa.set(t,f),r.Ma.has(e)?r.Ma.get(e).push(t):r.Ma.set(e,[t]),h.snapshot}async function W_(r,t,e){const n=k(r),i=n.Fa.get(t),s=n.Ma.get(i.targetId);if(s.length>1)return n.Ma.set(i.targetId,s.filter(a=>!Jr(a,t))),void n.Fa.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)||await Ln(n.localStore,i.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(i.targetId),e&&Bn(n.remoteStore,i.targetId),qn(n,i.targetId)}).catch(Ce)):(qn(n,i.targetId),await Ln(n.localStore,i.targetId,!0))}async function H_(r,t){const e=k(r),n=e.Fa.get(t),i=e.Ma.get(n.targetId);e.isPrimaryClient&&i.length===1&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),Bn(e.remoteStore,n.targetId))}async function J_(r,t,e){const n=Ta(r);try{const i=await function(a,u){const c=k(a),h=lt.now(),f=u.reduce((R,C)=>R.add(C.key),G());let g,_;return c.persistence.runTransaction("Locally write mutations","readwrite",R=>{let C=Bt(),N=G();return c.cs.getEntries(R,f).next(V=>{C=V,C.forEach((q,z)=>{z.isValidDocument()||(N=N.add(q))})}).next(()=>c.localDocuments.getOverlayedDocuments(R,C)).next(V=>{g=V;const q=[];for(const z of u){const B=vp(z,g.get(z.key).overlayedDocument);B!=null&&q.push(new oe(z.key,B,Zl(B.value.mapValue),ct.exists(!0)))}return c.mutationQueue.addMutationBatch(R,h,q,u)}).next(V=>{_=V;const q=V.applyToLocalDocumentSet(g,N);return c.documentOverlayCache.saveOverlays(R,V.batchId,q)})}).then(()=>({batchId:_.batchId,changes:mh(g)}))}(n.localStore,t);n.sharedClientState.addPendingMutation(i.batchId),function(a,u,c){let h=a.Ba[a.currentUser.toKey()];h||(h=new it(j)),h=h.insert(u,c),a.Ba[a.currentUser.toKey()]=h}(n,i.batchId,e),await ae(n,i.changes),await Hn(n.remoteStore)}catch(i){const s=Yn(i,"Failed to persist write");e.reject(s)}}async function Td(r,t){const e=k(r);try{const n=await m_(e.localStore,t);t.targetChanges.forEach((i,s)=>{const a=e.Na.get(s);a&&(L(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1),i.addedDocuments.size>0?a.va=!0:i.modifiedDocuments.size>0?L(a.va):i.removedDocuments.size>0&&(L(a.va),a.va=!1))}),await ae(e,n,t)}catch(n){await Ce(n)}}function $c(r,t,e){const n=k(r);if(n.isPrimaryClient&&e===0||!n.isPrimaryClient&&e===1){const i=[];n.Fa.forEach((s,a)=>{const u=a.view.Z_(t);u.snapshot&&i.push(u.snapshot)}),function(a,u){const c=k(a);c.onlineState=u;let h=!1;c.queries.forEach((f,g)=>{for(const _ of g.j_)_.Z_(u)&&(h=!0)}),h&&ga(c)}(n.eventManager,t),i.length&&n.Ca.d_(i),n.onlineState=t,n.isPrimaryClient&&n.sharedClientState.setOnlineState(t)}}async function Y_(r,t,e){const n=k(r);n.sharedClientState.updateQueryState(t,"rejected",e);const i=n.Na.get(t),s=i&&i.key;if(s){let a=new it(M.comparator);a=a.insert(s,ot.newNoDocument(s,U.min()));const u=G().add(s),c=new Zr(U.min(),new Map,new it(j),a,u);await Td(n,c),n.Oa=n.Oa.remove(s),n.Na.delete(t),Ea(n)}else await Ln(n.localStore,t,!1).then(()=>qn(n,t,e)).catch(Ce)}async function X_(r,t){const e=k(r),n=t.batch.batchId;try{const i=await f_(e.localStore,t);Ia(e,n,null),ya(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await ae(e,i)}catch(i){await Ce(i)}}async function Z_(r,t,e){const n=k(r);try{const i=await function(a,u){const c=k(a);return c.persistence.runTransaction("Reject batch","readwrite-primary",h=>{let f;return c.mutationQueue.lookupMutationBatch(h,u).next(g=>(L(g!==null),f=g.keys(),c.mutationQueue.removeMutationBatch(h,g))).next(()=>c.mutationQueue.performConsistencyCheck(h)).next(()=>c.documentOverlayCache.removeOverlaysForBatchId(h,f,u)).next(()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f)).next(()=>c.localDocuments.getDocuments(h,f))})}(n.localStore,t);Ia(n,t,e),ya(n,t),n.sharedClientState.updateMutationState(t,"rejected",e),await ae(n,i)}catch(i){await Ce(i)}}async function ty(r,t){const e=k(r);Ne(e.remoteStore)||x("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const n=await function(a){const u=k(a);return u.persistence.runTransaction("Get highest unacknowledged batch id","readonly",c=>u.mutationQueue.getHighestUnacknowledgedBatchId(c))}(e.localStore);if(n===-1)return void t.resolve();const i=e.ka.get(n)||[];i.push(t),e.ka.set(n,i)}catch(n){const i=Yn(n,"Initialization of waitForPendingWrites() operation failed");t.reject(i)}}function ya(r,t){(r.ka.get(t)||[]).forEach(e=>{e.resolve()}),r.ka.delete(t)}function Ia(r,t,e){const n=k(r);let i=n.Ba[n.currentUser.toKey()];if(i){const s=i.get(t);s&&(e?s.reject(e):s.resolve(),i=i.remove(t)),n.Ba[n.currentUser.toKey()]=i}}function qn(r,t,e=null){r.sharedClientState.removeLocalQueryTarget(t);for(const n of r.Ma.get(t))r.Fa.delete(n),e&&r.Ca.$a(n,e);r.Ma.delete(t),r.isPrimaryClient&&r.La.gr(t).forEach(n=>{r.La.containsKey(n)||vd(r,n)})}function vd(r,t){r.xa.delete(t.path.canonicalString());const e=r.Oa.get(t);e!==null&&(Bn(r.remoteStore,e),r.Oa=r.Oa.remove(t),r.Na.delete(e),Ea(r))}function No(r,t,e){for(const n of e)n instanceof _d?(r.La.addReference(n.key,t),ey(r,n)):n instanceof yd?(x("SyncEngine","Document no longer in limbo: "+n.key),r.La.removeReference(n.key,t),r.La.containsKey(n.key)||vd(r,n.key)):O()}function ey(r,t){const e=t.key,n=e.path.canonicalString();r.Oa.get(e)||r.xa.has(n)||(x("SyncEngine","New document in limbo: "+e),r.xa.add(n),Ea(r))}function Ea(r){for(;r.xa.size>0&&r.Oa.size<r.maxConcurrentLimboResolutions;){const t=r.xa.values().next().value;r.xa.delete(t);const e=new M(W.fromString(t)),n=r.qa.next();r.Na.set(n,new G_(e)),r.Oa=r.Oa.insert(e,n),_s(r.remoteStore,new te(kt(Kn(e.path)),n,"TargetPurposeLimboResolution",Ot.oe))}}async function ae(r,t,e){const n=k(r),i=[],s=[],a=[];n.Fa.isEmpty()||(n.Fa.forEach((u,c)=>{a.push(n.Ka(c,t,e).then(h=>{var f;if((h||e)&&n.isPrimaryClient){const g=h?!h.fromCache:(f=e==null?void 0:e.targetChanges.get(c.targetId))===null||f===void 0?void 0:f.current;n.sharedClientState.updateQueryState(c.targetId,g?"current":"not-current")}if(h){i.push(h);const g=oa.Wi(c.targetId,h);s.push(g)}}))}),await Promise.all(a),n.Ca.d_(i),await async function(c,h){const f=k(c);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",g=>w.forEach(h,_=>w.forEach(_.$i,R=>f.persistence.referenceDelegate.addReference(g,_.targetId,R)).next(()=>w.forEach(_.Ui,R=>f.persistence.referenceDelegate.removeReference(g,_.targetId,R)))))}catch(g){if(!De(g))throw g;x("LocalStore","Failed to update sequence numbers: "+g)}for(const g of h){const _=g.targetId;if(!g.fromCache){const R=f.os.get(_),C=R.snapshotVersion,N=R.withLastLimboFreeSnapshotVersion(C);f.os=f.os.insert(_,N)}}}(n.localStore,s))}async function ny(r,t){const e=k(r);if(!e.currentUser.isEqual(t)){x("SyncEngine","User change. New user:",t.toKey());const n=await nd(e.localStore,t);e.currentUser=t,function(s,a){s.ka.forEach(u=>{u.forEach(c=>{c.reject(new D(P.CANCELLED,a))})}),s.ka.clear()}(e,"'waitForPendingWrites' promise is rejected due to a user change."),e.sharedClientState.handleUserChange(t,n.removedBatchIds,n.addedBatchIds),await ae(e,n.hs)}}function ry(r,t){const e=k(r),n=e.Na.get(t);if(n&&n.va)return G().add(n.key);{let i=G();const s=e.Ma.get(t);if(!s)return i;for(const a of s){const u=e.Fa.get(a);i=i.unionWith(u.view.Va)}return i}}async function iy(r,t){const e=k(r),n=await es(e.localStore,t.query,!0),i=t.view.ba(n);return e.isPrimaryClient&&No(e,t.targetId,i.wa),i}async function sy(r,t){const e=k(r);return od(e.localStore,t).then(n=>ae(e,n))}async function oy(r,t,e,n){const i=k(r),s=await function(u,c){const h=k(u),f=k(h.mutationQueue);return h.persistence.runTransaction("Lookup mutation documents","readonly",g=>f.Mn(g,c).next(_=>_?h.localDocuments.getDocuments(g,_):w.resolve(null)))}(i.localStore,t);s!==null?(e==="pending"?await Hn(i.remoteStore):e==="acknowledged"||e==="rejected"?(Ia(i,t,n||null),ya(i,t),function(u,c){k(k(u).mutationQueue).On(c)}(i.localStore,t)):O(),await ae(i,s)):x("SyncEngine","Cannot apply mutation batch with id: "+t)}async function ay(r,t){const e=k(r);if(ys(e),Ta(e),t===!0&&e.Qa!==!0){const n=e.sharedClientState.getAllActiveQueryTargets(),i=await Qc(e,n.toArray());e.Qa=!0,await Do(e.remoteStore,!0);for(const s of i)_s(e.remoteStore,s)}else if(t===!1&&e.Qa!==!1){const n=[];let i=Promise.resolve();e.Ma.forEach((s,a)=>{e.sharedClientState.isLocalQueryTarget(a)?n.push(a):i=i.then(()=>(qn(e,a),Ln(e.localStore,a,!0))),Bn(e.remoteStore,a)}),await i,await Qc(e,n),function(a){const u=k(a);u.Na.forEach((c,h)=>{Bn(u.remoteStore,h)}),u.La.pr(),u.Na=new Map,u.Oa=new it(M.comparator)}(e),e.Qa=!1,await Do(e.remoteStore,!1)}}async function Qc(r,t,e){const n=k(r),i=[],s=[];for(const a of t){let u;const c=n.Ma.get(a);if(c&&c.length!==0){u=await On(n.localStore,kt(c[0]));for(const h of c){const f=n.Fa.get(h),g=await iy(n,f);g.snapshot&&s.push(g.snapshot)}}else{const h=await sd(n.localStore,a);u=await On(n.localStore,h),await _a(n,wd(h),a,!1,u.resumeToken)}i.push(u)}return n.Ca.d_(s),i}function wd(r){return ah(r.path,r.collectionGroup,r.orderBy,r.filters,r.limit,"F",r.startAt,r.endAt)}function uy(r){return function(e){return k(k(e).persistence).Qi()}(k(r).localStore)}async function cy(r,t,e,n){const i=k(r);if(i.Qa)return void x("SyncEngine","Ignoring unexpected query state notification.");const s=i.Ma.get(t);if(s&&s.length>0)switch(e){case"current":case"not-current":{const a=await od(i.localStore,hh(s[0])),u=Zr.createSynthesizedRemoteEventForCurrentChange(t,e==="current",dt.EMPTY_BYTE_STRING);await ae(i,a,u);break}case"rejected":await Ln(i.localStore,t,!0),qn(i,t,n);break;default:O()}}async function ly(r,t,e){const n=ys(r);if(n.Qa){for(const i of t){if(n.Ma.has(i)&&n.sharedClientState.isActiveQueryTarget(i)){x("SyncEngine","Adding an already active target "+i);continue}const s=await sd(n.localStore,i),a=await On(n.localStore,s);await _a(n,wd(s),a.targetId,!1,a.resumeToken),_s(n.remoteStore,a)}for(const i of e)n.Ma.has(i)&&await Ln(n.localStore,i,!1).then(()=>{Bn(n.remoteStore,i),qn(n,i)}).catch(Ce)}}function ys(r){const t=k(r);return t.remoteStore.remoteSyncer.applyRemoteEvent=Td.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=ry.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Y_.bind(null,t),t.Ca.d_=B_.bind(null,t.eventManager),t.Ca.$a=U_.bind(null,t.eventManager),t}function Ta(r){const t=k(r);return t.remoteStore.remoteSyncer.applySuccessfulWrite=X_.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Z_.bind(null,t),t}function hy(r,t,e){const n=k(r);(async function(s,a,u){try{const c=await a.getMetadata();if(await function(R,C){const N=k(R),V=pt(C.createTime);return N.persistence.runTransaction("hasNewerBundle","readonly",q=>N.Gr.getBundleMetadata(q,C.id)).then(q=>!!q&&q.createTime.compareTo(V)>=0)}(s.localStore,c))return await a.close(),u._completeWith(function(R){return{taskState:"Success",documentsLoaded:R.totalDocuments,bytesLoaded:R.totalBytes,totalDocuments:R.totalDocuments,totalBytes:R.totalBytes}}(c)),Promise.resolve(new Set);u._updateProgress(pd(c));const h=new z_(c,s.localStore,a.serializer);let f=await a.Ua();for(;f;){const _=await h.la(f);_&&u._updateProgress(_),f=await a.Ua()}const g=await h.complete();return await ae(s,g.Ia,void 0),await function(R,C){const N=k(R);return N.persistence.runTransaction("Save bundle","readwrite",V=>N.Gr.saveBundleMetadata(V,C))}(s.localStore,c),u._completeWith(g.progress),Promise.resolve(g.Pa)}catch(c){return qt("SyncEngine",`Loading bundle failed with ${c}`),u._failWith(c),Promise.resolve(new Set)}})(n,t,e).then(i=>{n.sharedClientState.notifyBundleLoaded(i)})}class Pe{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=ei(t.databaseInfo.databaseId),this.sharedClientState=this.Wa(t),this.persistence=this.Ga(t),await this.persistence.start(),this.localStore=this.za(t),this.gcScheduler=this.ja(t,this.localStore),this.indexBackfillerScheduler=this.Ha(t,this.localStore)}ja(t,e){return null}Ha(t,e){return null}za(t){return ed(this.persistence,new td,t.initialUser,this.serializer)}Ga(t){return new ra(ps.Zr,this.serializer)}Wa(t){return new ud}async terminate(){var t,e;(t=this.gcScheduler)===null||t===void 0||t.stop(),(e=this.indexBackfillerScheduler)===null||e===void 0||e.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Pe.provider={build:()=>new Pe};class dy extends Pe{constructor(t){super(),this.cacheSizeBytes=t}ja(t,e){L(this.persistence.referenceDelegate instanceof ts);const n=this.persistence.referenceDelegate.garbageCollector;return new Hh(n,t.asyncQueue,e)}Ga(t){const e=this.cacheSizeBytes!==void 0?xt.withCacheSize(this.cacheSizeBytes):xt.DEFAULT;return new ra(n=>ts.Zr(n,e),this.serializer)}}class va extends Pe{constructor(t,e,n){super(),this.Ja=t,this.cacheSizeBytes=e,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(t){await super.initialize(t),await this.Ja.initialize(this,t),await Ta(this.Ja.syncEngine),await Hn(this.Ja.remoteStore),await this.persistence.yi(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}za(t){return ed(this.persistence,new td,t.initialUser,this.serializer)}ja(t,e){const n=this.persistence.referenceDelegate.garbageCollector;return new Hh(n,t.asyncQueue,e)}Ha(t,e){const n=new Ng(e,this.persistence);return new xg(t.asyncQueue,n)}Ga(t){const e=sa(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=this.cacheSizeBytes!==void 0?xt.withCacheSize(this.cacheSizeBytes):xt.DEFAULT;return new ia(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,cd(),ji(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Wa(t){return new ud}}class Ad extends va{constructor(t,e){super(t,e,!1),this.Ja=t,this.cacheSizeBytes=e,this.synchronizeTabs=!0}async initialize(t){await super.initialize(t);const e=this.Ja.syncEngine;this.sharedClientState instanceof oo&&(this.sharedClientState.syncEngine={no:oy.bind(null,e),ro:cy.bind(null,e),io:ly.bind(null,e),Qi:uy.bind(null,e),eo:sy.bind(null,e)},await this.sharedClientState.start()),await this.persistence.yi(async n=>{await ay(this.Ja.syncEngine,n),this.gcScheduler&&(n&&!this.gcScheduler.started?this.gcScheduler.start():n||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(n&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():n||this.indexBackfillerScheduler.stop())})}Wa(t){const e=cd();if(!oo.D(e))throw new D(P.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=sa(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new oo(e,t.asyncQueue,n,t.clientId,t.initialUser)}}class Se{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>$c(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=ny.bind(null,this.syncEngine),await Do(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return function(){return new L_}()}createDatastore(t){const e=ei(t.databaseInfo.databaseId),n=function(s){return new T_(s)}(t.databaseInfo);return function(s,a,u,c){return new A_(s,a,u,c)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return function(n,i,s,a,u){return new b_(n,i,s,a,u)}(this.localStore,this.datastore,t.asyncQueue,e=>$c(this.syncEngine,e,0),function(){return Uc.D()?new Uc:new y_}())}createSyncEngine(t,e){return function(i,s,a,u,c,h,f){const g=new K_(i,s,a,u,c,h);return f&&(g.Qa=!0),g}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}async terminate(){var t,e;await async function(i){const s=k(i);x("RemoteStore","RemoteStore shutting down."),s.L_.add(5),await Wn(s),s.k_.shutdown(),s.q_.set("Unknown")}(this.remoteStore),(t=this.datastore)===null||t===void 0||t.terminate(),(e=this.eventManager)===null||e===void 0||e.terminate()}}Se.provider={build:()=>new Se};function Wc(r,t=10240){let e=0;return{async read(){if(e<r.byteLength){const n={value:r.slice(e,e+t),done:!1};return e+=t,n}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}/**
|
|
2076
|
-
* @license
|
|
2077
|
-
* Copyright 2020 Google LLC
|
|
2078
|
-
*
|
|
2079
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2080
|
-
* you may not use this file except in compliance with the License.
|
|
2081
|
-
* You may obtain a copy of the License at
|
|
2082
|
-
*
|
|
2083
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2084
|
-
*
|
|
2085
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2086
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2087
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2088
|
-
* See the License for the specific language governing permissions and
|
|
2089
|
-
* limitations under the License.
|
|
2090
|
-
*//**
|
|
2091
|
-
* @license
|
|
2092
|
-
* Copyright 2017 Google LLC
|
|
2093
|
-
*
|
|
2094
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2095
|
-
* you may not use this file except in compliance with the License.
|
|
2096
|
-
* You may obtain a copy of the License at
|
|
2097
|
-
*
|
|
2098
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2099
|
-
*
|
|
2100
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2101
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2102
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2103
|
-
* See the License for the specific language governing permissions and
|
|
2104
|
-
* limitations under the License.
|
|
2105
|
-
*/class Is{constructor(t){this.observer=t,this.muted=!1}next(t){this.muted||this.observer.next&&this.Ya(this.observer.next,t)}error(t){this.muted||(this.observer.error?this.Ya(this.observer.error,t):gt("Uncaught Error in snapshot listener:",t.toString()))}Za(){this.muted=!0}Ya(t,e){setTimeout(()=>{this.muted||t(e)},0)}}/**
|
|
2106
|
-
* @license
|
|
2107
|
-
* Copyright 2020 Google LLC
|
|
2108
|
-
*
|
|
2109
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2110
|
-
* you may not use this file except in compliance with the License.
|
|
2111
|
-
* You may obtain a copy of the License at
|
|
2112
|
-
*
|
|
2113
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2114
|
-
*
|
|
2115
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2116
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2117
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2118
|
-
* See the License for the specific language governing permissions and
|
|
2119
|
-
* limitations under the License.
|
|
2120
|
-
*/class fy{constructor(t,e){this.Xa=t,this.serializer=e,this.metadata=new vt,this.buffer=new Uint8Array,this.eu=function(){return new TextDecoder("utf-8")}(),this.tu().then(n=>{n&&n.ua()?this.metadata.resolve(n.aa.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is
|
|
2121
|
-
${JSON.stringify(n==null?void 0:n.aa)}`))},n=>this.metadata.reject(n))}close(){return this.Xa.cancel()}async getMetadata(){return this.metadata.promise}async Ua(){return await this.getMetadata(),this.tu()}async tu(){const t=await this.nu();if(t===null)return null;const e=this.eu.decode(t),n=Number(e);isNaN(n)&&this.ru(`length string (${e}) is not valid number`);const i=await this.iu(n);return new q_(JSON.parse(i),t.length+n)}su(){return this.buffer.findIndex(t=>t===123)}async nu(){for(;this.su()<0&&!await this.ou(););if(this.buffer.length===0)return null;const t=this.su();t<0&&this.ru("Reached the end of bundle when a length string is expected.");const e=this.buffer.slice(0,t);return this.buffer=this.buffer.slice(t),e}async iu(t){for(;this.buffer.length<t;)await this.ou()&&this.ru("Reached the end of bundle when more is expected.");const e=this.eu.decode(this.buffer.slice(0,t));return this.buffer=this.buffer.slice(t),e}ru(t){throw this.Xa.cancel(),new Error(`Invalid bundle format: ${t}`)}async ou(){const t=await this.Xa.read();if(!t.done){const e=new Uint8Array(this.buffer.length+t.value.length);e.set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e}return t.done}}/**
|
|
2122
|
-
* @license
|
|
2123
|
-
* Copyright 2017 Google LLC
|
|
2124
|
-
*
|
|
2125
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2126
|
-
* you may not use this file except in compliance with the License.
|
|
2127
|
-
* You may obtain a copy of the License at
|
|
2128
|
-
*
|
|
2129
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2130
|
-
*
|
|
2131
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2132
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2133
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2134
|
-
* See the License for the specific language governing permissions and
|
|
2135
|
-
* limitations under the License.
|
|
2136
|
-
*/class my{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new D(P.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const e=await async function(i,s){const a=k(i),u={documents:s.map(g=>jr(a.serializer,g))},c=await a.Lo("BatchGetDocuments",a.serializer.databaseId,W.emptyPath(),u,s.length),h=new Map;c.forEach(g=>{const _=Dp(a.serializer,g);h.set(_.key.toString(),_)});const f=[];return s.forEach(g=>{const _=h.get(g.toString());L(!!_),f.push(_)}),f}(this.datastore,t);return e.forEach(n=>this.recordVersion(n)),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(n){this.lastTransactionError=n}this.writtenDocs.add(t.toString())}delete(t){this.write(new Qn(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const t=this.readVersions;this.mutations.forEach(e=>{t.delete(e.key.toString())}),t.forEach((e,n)=>{const i=M.fromPath(n);this.mutations.push(new Qo(i,this.precondition(i)))}),await async function(n,i){const s=k(n),a={writes:i.map(u=>Gr(s.serializer,u))};await s.Mo("Commit",s.serializer.databaseId,W.emptyPath(),a)}(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw O();e=U.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new D(P.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(U.min())?ct.exists(!1):ct.updateTime(e):ct.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(U.min()))throw new D(P.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ct.updateTime(e)}return ct.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}/**
|
|
2137
|
-
* @license
|
|
2138
|
-
* Copyright 2019 Google LLC
|
|
2139
|
-
*
|
|
2140
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2141
|
-
* you may not use this file except in compliance with the License.
|
|
2142
|
-
* You may obtain a copy of the License at
|
|
2143
|
-
*
|
|
2144
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2145
|
-
*
|
|
2146
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2147
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2148
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2149
|
-
* See the License for the specific language governing permissions and
|
|
2150
|
-
* limitations under the License.
|
|
2151
|
-
*/class gy{constructor(t,e,n,i,s){this.asyncQueue=t,this.datastore=e,this.options=n,this.updateFunction=i,this.deferred=s,this._u=n.maxAttempts,this.t_=new ua(this.asyncQueue,"transaction_retry")}au(){this._u-=1,this.uu()}uu(){this.t_.Go(async()=>{const t=new my(this.datastore),e=this.cu(t);e&&e.then(n=>{this.asyncQueue.enqueueAndForget(()=>t.commit().then(()=>{this.deferred.resolve(n)}).catch(i=>{this.lu(i)}))}).catch(n=>{this.lu(n)})})}cu(t){try{const e=this.updateFunction(t);return!Wr(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}lu(t){this._u>0&&this.hu(t)?(this._u-=1,this.asyncQueue.enqueueAndForget(()=>(this.uu(),Promise.resolve()))):this.deferred.reject(t)}hu(t){if(t.name==="FirebaseError"){const e=t.code;return e==="aborted"||e==="failed-precondition"||e==="already-exists"||!Rh(e)}return!1}}/**
|
|
2152
|
-
* @license
|
|
2153
|
-
* Copyright 2017 Google LLC
|
|
2154
|
-
*
|
|
2155
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2156
|
-
* you may not use this file except in compliance with the License.
|
|
2157
|
-
* You may obtain a copy of the License at
|
|
2158
|
-
*
|
|
2159
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2160
|
-
*
|
|
2161
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2162
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2163
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2164
|
-
* See the License for the specific language governing permissions and
|
|
2165
|
-
* limitations under the License.
|
|
2166
|
-
*/class py{constructor(t,e,n,i,s){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=i,this.user=Tt.UNAUTHENTICATED,this.clientId=Bo.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=s,this.authCredentials.start(n,async a=>{x("FirestoreClient","Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(n,a=>(x("FirestoreClient","Received new app check token=",a),this.appCheckCredentialListener(a,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new vt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=Yn(e,"Failed to shutdown persistence");t.reject(n)}}),t.promise}}async function uo(r,t){r.asyncQueue.verifyOperationInProgress(),x("FirestoreClient","Initializing OfflineComponentProvider");const e=r.configuration;await t.initialize(e);let n=e.initialUser;r.setCredentialChangeListener(async i=>{n.isEqual(i)||(await nd(t.localStore,i),n=i)}),t.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=t}async function Hc(r,t){r.asyncQueue.verifyOperationInProgress();const e=await wa(r);x("FirestoreClient","Initializing OnlineComponentProvider"),await t.initialize(e,r.configuration),r.setCredentialChangeListener(n=>qc(t.remoteStore,n)),r.setAppCheckTokenChangeListener((n,i)=>qc(t.remoteStore,i)),r._onlineComponents=t}async function wa(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){x("FirestoreClient","Using user provided OfflineComponentProvider");try{await uo(r,r._uninitializedComponentsProvider._offline)}catch(t){const e=t;if(!function(i){return i.name==="FirebaseError"?i.code===P.FAILED_PRECONDITION||i.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11}(e))throw e;qt("Error using user provided cache. Falling back to memory cache: "+e),await uo(r,new Pe)}}else x("FirestoreClient","Using default OfflineComponentProvider"),await uo(r,new Pe);return r._offlineComponents}async function Es(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(x("FirestoreClient","Using user provided OnlineComponentProvider"),await Hc(r,r._uninitializedComponentsProvider._online)):(x("FirestoreClient","Using default OnlineComponentProvider"),await Hc(r,new Se))),r._onlineComponents}function Rd(r){return wa(r).then(t=>t.persistence)}function Xn(r){return wa(r).then(t=>t.localStore)}function bd(r){return Es(r).then(t=>t.remoteStore)}function Aa(r){return Es(r).then(t=>t.syncEngine)}function Pd(r){return Es(r).then(t=>t.datastore)}async function zn(r){const t=await Es(r),e=t.eventManager;return e.onListen=$_.bind(null,t.syncEngine),e.onUnlisten=W_.bind(null,t.syncEngine),e.onFirstRemoteStoreListen=Q_.bind(null,t.syncEngine),e.onLastRemoteStoreUnlisten=H_.bind(null,t.syncEngine),e}function _y(r){return r.asyncQueue.enqueue(async()=>{const t=await Rd(r),e=await bd(r);return t.setNetworkEnabled(!0),function(i){const s=k(i);return s.L_.delete(0),ni(s)}(e)})}function yy(r){return r.asyncQueue.enqueue(async()=>{const t=await Rd(r),e=await bd(r);return t.setNetworkEnabled(!1),async function(i){const s=k(i);s.L_.add(0),await Wn(s),s.q_.set("Offline")}(e)})}function Iy(r,t){const e=new vt;return r.asyncQueue.enqueueAndForget(async()=>async function(i,s,a){try{const u=await function(h,f){const g=k(h);return g.persistence.runTransaction("read document","readonly",_=>g.localDocuments.getDocument(_,f))}(i,s);u.isFoundDocument()?a.resolve(u):u.isNoDocument()?a.resolve(null):a.reject(new D(P.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.)"))}catch(u){const c=Yn(u,`Failed to get document '${s} from cache`);a.reject(c)}}(await Xn(r),t,e)),e.promise}function Sd(r,t,e={}){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>function(s,a,u,c,h){const f=new Is({next:_=>{f.Za(),a.enqueueAndForget(()=>ma(s,g));const R=_.docs.has(u);!R&&_.fromCache?h.reject(new D(P.UNAVAILABLE,"Failed to get document because the client is offline.")):R&&_.fromCache&&c&&c.source==="server"?h.reject(new D(P.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.)')):h.resolve(_)},error:_=>h.reject(_)}),g=new pa(Kn(u.path),f,{includeMetadataChanges:!0,_a:!0});return fa(s,g)}(await zn(r),r.asyncQueue,t,e,n)),n.promise}function Ey(r,t){const e=new vt;return r.asyncQueue.enqueueAndForget(async()=>async function(i,s,a){try{const u=await es(i,s,!0),c=new Id(s,u.Ts),h=c.ma(u.documents),f=c.applyChanges(h,!1);a.resolve(f.snapshot)}catch(u){const c=Yn(u,`Failed to execute query '${s} against cache`);a.reject(c)}}(await Xn(r),t,e)),e.promise}function Vd(r,t,e={}){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>function(s,a,u,c,h){const f=new Is({next:_=>{f.Za(),a.enqueueAndForget(()=>ma(s,g)),_.fromCache&&c.source==="server"?h.reject(new D(P.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.)')):h.resolve(_)},error:_=>h.reject(_)}),g=new pa(u,f,{includeMetadataChanges:!0,_a:!0});return fa(s,g)}(await zn(r),r.asyncQueue,t,e,n)),n.promise}function Ty(r,t,e){const n=new vt;return r.asyncQueue.enqueueAndForget(async()=>{try{const i=await Pd(r);n.resolve(async function(a,u,c){var h;const f=k(a),{request:g,ut:_,parent:R}=Oh(f.serializer,uh(u),c);f.connection.Fo||delete g.parent;const C=(await f.Lo("RunAggregationQuery",f.serializer.databaseId,R,g,1)).filter(V=>!!V.result);L(C.length===1);const N=(h=C[0].result)===null||h===void 0?void 0:h.aggregateFields;return Object.keys(N).reduce((V,q)=>(V[_[q]]=N[q],V),{})}(i,t,e))}catch(i){n.reject(i)}}),n.promise}function vy(r,t){const e=new Is(t);return r.asyncQueue.enqueueAndForget(async()=>function(i,s){k(i).Y_.add(s),s.next()}(await zn(r),e)),()=>{e.Za(),r.asyncQueue.enqueueAndForget(async()=>function(i,s){k(i).Y_.delete(s)}(await zn(r),e))}}function wy(r,t,e,n){const i=function(a,u){let c;return c=typeof a=="string"?Ph().encode(a):a,function(f,g){return new fy(f,g)}(function(f,g){if(f instanceof Uint8Array)return Wc(f,g);if(f instanceof ArrayBuffer)return Wc(new Uint8Array(f),g);if(f instanceof ReadableStream)return f.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(c),u)}(e,ei(t));r.asyncQueue.enqueueAndForget(async()=>{hy(await Aa(r),i,n)})}function Ay(r,t){return r.asyncQueue.enqueue(async()=>function(n,i){const s=k(n);return s.persistence.runTransaction("Get named query","readonly",a=>s.Gr.getNamedQuery(a,i))}(await Xn(r),t))}function Ry(r,t){return r.asyncQueue.enqueue(async()=>async function(n,i){const s=k(n),a=s.indexManager,u=[];return s.persistence.runTransaction("Configure indexes","readwrite",c=>a.getFieldIndexes(c).next(h=>function(g,_,R,C,N){g=[...g],_=[..._],g.sort(R),_.sort(R);const V=g.length,q=_.length;let z=0,B=0;for(;z<q&&B<V;){const $=R(g[B],_[z]);$<0?N(g[B++]):$>0?C(_[z++]):(z++,B++)}for(;z<q;)C(_[z++]);for(;B<V;)N(g[B++])}(h,i,Sg,f=>{u.push(a.addFieldIndex(c,f))},f=>{u.push(a.deleteFieldIndex(c,f))})).next(()=>w.waitFor(u)))}(await Xn(r),t))}function by(r,t){return r.asyncQueue.enqueue(async()=>function(n,i){k(n).ss.zi=i}(await Xn(r),t))}function Py(r){return r.asyncQueue.enqueue(async()=>function(e){const n=k(e),i=n.indexManager;return n.persistence.runTransaction("Delete All Indexes","readwrite",s=>i.deleteAllFieldIndexes(s))}(await Xn(r)))}/**
|
|
2167
|
-
* @license
|
|
2168
|
-
* Copyright 2023 Google LLC
|
|
2169
|
-
*
|
|
2170
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2171
|
-
* you may not use this file except in compliance with the License.
|
|
2172
|
-
* You may obtain a copy of the License at
|
|
2173
|
-
*
|
|
2174
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2175
|
-
*
|
|
2176
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2177
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2178
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2179
|
-
* See the License for the specific language governing permissions and
|
|
2180
|
-
* limitations under the License.
|
|
2181
|
-
*/function Cd(r){const t={};return r.timeoutSeconds!==void 0&&(t.timeoutSeconds=r.timeoutSeconds),t}/**
|
|
2182
|
-
* @license
|
|
2183
|
-
* Copyright 2020 Google LLC
|
|
2184
|
-
*
|
|
2185
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2186
|
-
* you may not use this file except in compliance with the License.
|
|
2187
|
-
* You may obtain a copy of the License at
|
|
2188
|
-
*
|
|
2189
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2190
|
-
*
|
|
2191
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2192
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2193
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2194
|
-
* See the License for the specific language governing permissions and
|
|
2195
|
-
* limitations under the License.
|
|
2196
|
-
*/const Jc=new Map;/**
|
|
2197
|
-
* @license
|
|
2198
|
-
* Copyright 2017 Google LLC
|
|
2199
|
-
*
|
|
2200
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2201
|
-
* you may not use this file except in compliance with the License.
|
|
2202
|
-
* You may obtain a copy of the License at
|
|
2203
|
-
*
|
|
2204
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2205
|
-
*
|
|
2206
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2207
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2208
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2209
|
-
* See the License for the specific language governing permissions and
|
|
2210
|
-
* limitations under the License.
|
|
2211
|
-
*/function Ra(r,t,e){if(!e)throw new D(P.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${t}.`)}function Dd(r,t,e,n){if(t===!0&&n===!0)throw new D(P.INVALID_ARGUMENT,`${r} and ${e} cannot be used together.`)}function Yc(r){if(!M.isDocumentKey(r))throw new D(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function Xc(r){if(M.isDocumentKey(r))throw new D(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${r} has ${r.length}.`)}function Ts(r){if(r===void 0)return"undefined";if(r===null)return"null";if(typeof r=="string")return r.length>20&&(r=`${r.substring(0,20)}...`),JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean")return""+r;if(typeof r=="object"){if(r instanceof Array)return"an array";{const t=function(n){return n.constructor?n.constructor.name:null}(r);return t?`a custom ${t} object`:"an object"}}return typeof r=="function"?"a function":O()}function Q(r,t){if("_delegate"in r&&(r=r._delegate),!(r instanceof t)){if(t.name===r.constructor.name)throw new D(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const e=Ts(r);throw new D(P.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${e}`)}}return r}function xd(r,t){if(t<=0)throw new D(P.INVALID_ARGUMENT,`Function ${r}() requires a positive number, but it was: ${t}.`)}/**
|
|
2212
|
-
* @license
|
|
2213
|
-
* Copyright 2020 Google LLC
|
|
2214
|
-
*
|
|
2215
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2216
|
-
* you may not use this file except in compliance with the License.
|
|
2217
|
-
* You may obtain a copy of the License at
|
|
2218
|
-
*
|
|
2219
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2220
|
-
*
|
|
2221
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2222
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2223
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2224
|
-
* See the License for the specific language governing permissions and
|
|
2225
|
-
* limitations under the License.
|
|
2226
|
-
*/class Zc{constructor(t){var e,n;if(t.host===void 0){if(t.ssl!==void 0)throw new D(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=(e=t.ssl)===null||e===void 0||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,t.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<1048576)throw new D(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}Dd("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:t.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Cd((n=t.experimentalLongPollingOptions)!==null&&n!==void 0?n:{}),function(s){if(s.timeoutSeconds!==void 0){if(isNaN(s.timeoutSeconds))throw new D(P.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (must not be NaN)`);if(s.timeoutSeconds<5)throw new D(P.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (minimum allowed value is 5)`);if(s.timeoutSeconds>30)throw new D(P.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&function(n,i){return n.timeoutSeconds===i.timeoutSeconds}(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class ri{constructor(t,e,n,i){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Zc({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new D(P.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(t){if(this._settingsFrozen)throw new D(P.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.");this._settings=new Zc(t),t.credentials!==void 0&&(this._authCredentials=function(n){if(!n)return new Fl;switch(n.type){case"firstParty":return new wg(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new D(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const n=Jc.get(e);n&&(x("ComponentProvider","Removing Datastore"),Jc.delete(e),n.terminate())}(this),Promise.resolve()}}function Nd(r,t,e,n={}){var i;const s=(r=Q(r,ri))._getSettings(),a=`${t}:${e}`;if(s.host!=="firestore.googleapis.com"&&s.host!==a&&qt("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),r._setSettings(Object.assign(Object.assign({},s),{host:a,ssl:!1})),n.mockUserToken){let u,c;if(typeof n.mockUserToken=="string")u=n.mockUserToken,c=Tt.MOCK_USER;else{u=cl(n.mockUserToken,(i=r._app)===null||i===void 0?void 0:i.options.projectId);const h=n.mockUserToken.sub||n.mockUserToken.user_id;if(!h)throw new D(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");c=new Tt(h)}r._authCredentials=new Eg(new kl(u,c))}}/**
|
|
2227
|
-
* @license
|
|
2228
|
-
* Copyright 2020 Google LLC
|
|
2229
|
-
*
|
|
2230
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2231
|
-
* you may not use this file except in compliance with the License.
|
|
2232
|
-
* You may obtain a copy of the License at
|
|
2233
|
-
*
|
|
2234
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2235
|
-
*
|
|
2236
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2237
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2238
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2239
|
-
* See the License for the specific language governing permissions and
|
|
2240
|
-
* limitations under the License.
|
|
2241
|
-
*/class wt{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new wt(this.firestore,t,this._query)}}class mt{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Kt(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new mt(this.firestore,t,this._key)}}class Kt extends wt{constructor(t,e,n){super(t,e,Kn(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new mt(this.firestore,null,new M(t))}withConverter(t){return new Kt(this.firestore,t,this._path)}}function ba(r,t,...e){if(r=yt(r),Ra("collection","path",t),r instanceof ri){const n=W.fromString(t,...e);return Xc(n),new Kt(r,null,n)}{if(!(r instanceof mt||r instanceof Kt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(W.fromString(t,...e));return Xc(n),new Kt(r.firestore,null,n)}}function Sy(r,t){if(r=Q(r,ri),Ra("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new D(P.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new wt(r,null,function(n){return new ie(W.emptyPath(),n)}(t))}function ii(r,t,...e){if(r=yt(r),arguments.length===1&&(t=Bo.newId()),Ra("doc","path",t),r instanceof ri){const n=W.fromString(t,...e);return Yc(n),new mt(r,null,new M(n))}{if(!(r instanceof mt||r instanceof Kt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(W.fromString(t,...e));return Yc(n),new mt(r.firestore,r instanceof Kt?r.converter:null,new M(n))}}function Vy(r,t){return r=yt(r),t=yt(t),(r instanceof mt||r instanceof Kt)&&(t instanceof mt||t instanceof Kt)&&r.firestore===t.firestore&&r.path===t.path&&r.converter===t.converter}function Pa(r,t){return r=yt(r),t=yt(t),r instanceof wt&&t instanceof wt&&r.firestore===t.firestore&&Jr(r._query,t._query)&&r.converter===t.converter}/**
|
|
2242
|
-
* @license
|
|
2243
|
-
* Copyright 2020 Google LLC
|
|
2244
|
-
*
|
|
2245
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2246
|
-
* you may not use this file except in compliance with the License.
|
|
2247
|
-
* You may obtain a copy of the License at
|
|
2248
|
-
*
|
|
2249
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2250
|
-
*
|
|
2251
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2252
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2253
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2254
|
-
* See the License for the specific language governing permissions and
|
|
2255
|
-
* limitations under the License.
|
|
2256
|
-
*/class tl{constructor(t=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new ua(this,"async_queue_retry"),this.Vu=()=>{const n=ji();n&&x("AsyncQueue","Visibility state changed to "+n.visibilityState),this.t_.jo()},this.mu=t;const e=ji();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.fu(),this.gu(t)}enterRestrictedMode(t){if(!this.Iu){this.Iu=!0,this.Au=t||!1;const e=ji();e&&typeof e.removeEventListener=="function"&&e.removeEventListener("visibilitychange",this.Vu)}}enqueue(t){if(this.fu(),this.Iu)return new Promise(()=>{});const e=new vt;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(t().then(e.resolve,e.reject),e.promise)).then(()=>e.promise)}enqueueRetryable(t){this.enqueueAndForget(()=>(this.Pu.push(t),this.pu()))}async pu(){if(this.Pu.length!==0){try{await this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(t){if(!De(t))throw t;x("AsyncQueue","Operation failed with retryable error: "+t)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}}gu(t){const e=this.mu.then(()=>(this.du=!0,t().catch(n=>{this.Eu=n,this.du=!1;const i=function(a){let u=a.message||"";return a.stack&&(u=a.stack.includes(a.message)?a.stack:a.message+`
|
|
2257
|
-
`+a.stack),u}(n);throw gt("INTERNAL UNHANDLED ERROR: ",i),n}).then(n=>(this.du=!1,n))));return this.mu=e,e}enqueueAfterDelay(t,e,n){this.fu(),this.Ru.indexOf(t)>-1&&(e=0);const i=da.createAndSchedule(this,t,e,n,s=>this.yu(s));return this.Tu.push(i),i}fu(){this.Eu&&O()}verifyOperationInProgress(){}async wu(){let t;do t=this.mu,await t;while(t!==this.mu)}Su(t){for(const e of this.Tu)if(e.timerId===t)return!0;return!1}bu(t){return this.wu().then(()=>{this.Tu.sort((e,n)=>e.targetTimeMs-n.targetTimeMs);for(const e of this.Tu)if(e.skipDelay(),t!=="all"&&e.timerId===t)break;return this.wu()})}Du(t){this.Ru.push(t)}yu(t){const e=this.Tu.indexOf(t);this.Tu.splice(e,1)}}function ko(r){return function(e,n){if(typeof e!="object"||e===null)return!1;const i=e;for(const s of n)if(s in i&&typeof i[s]=="function")return!0;return!1}(r,["next","error","complete"])}class kd{constructor(){this._progressObserver={},this._taskCompletionResolver=new vt,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(t,e,n){this._progressObserver={next:t,error:e,complete:n}}catch(t){return this._taskCompletionResolver.promise.catch(t)}then(t,e){return this._taskCompletionResolver.promise.then(t,e)}_completeWith(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)}_failWith(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)}_updateProgress(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}/**
|
|
2258
|
-
* @license
|
|
2259
|
-
* Copyright 2020 Google LLC
|
|
2260
|
-
*
|
|
2261
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2262
|
-
* you may not use this file except in compliance with the License.
|
|
2263
|
-
* You may obtain a copy of the License at
|
|
2264
|
-
*
|
|
2265
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2266
|
-
*
|
|
2267
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2268
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2269
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2270
|
-
* See the License for the specific language governing permissions and
|
|
2271
|
-
* limitations under the License.
|
|
2272
|
-
*/const Cy=-1;class nt extends ri{constructor(t,e,n,i){super(t,e,n,i),this.type="firestore",this._queue=new tl,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new tl(t),this._firestoreClient=void 0,await t}}}function Dy(r,t,e){e||(e="(default)");const n=os(r,"firestore");if(n.isInitialized(e)){const i=n.getImmediate({identifier:e}),s=n.getOptions(e);if(Ye(s,t))return i;throw new D(P.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.")}if(t.cacheSizeBytes!==void 0&&t.localCache!==void 0)throw new D(P.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");if(t.cacheSizeBytes!==void 0&&t.cacheSizeBytes!==-1&&t.cacheSizeBytes<1048576)throw new D(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return n.initialize({options:t,instanceIdentifier:e})}function xy(r,t){const e=typeof r=="object"?r:Al(),n=typeof r=="string"?r:t||"(default)",i=os(e,"firestore").getImmediate({identifier:n});if(!i._initialized){const s=al("firestore");s&&Nd(i,...s)}return i}function ht(r){if(r._terminated)throw new D(P.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||Fd(r),r._firestoreClient}function Fd(r){var t,e,n;const i=r._freezeSettings(),s=function(u,c,h,f){return new ep(u,c,h,f.host,f.ssl,f.experimentalForceLongPolling,f.experimentalAutoDetectLongPolling,Cd(f.experimentalLongPollingOptions),f.useFetchStreams)}(r._databaseId,((t=r._app)===null||t===void 0?void 0:t.options.appId)||"",r._persistenceKey,i);r._componentsProvider||!((e=i.localCache)===null||e===void 0)&&e._offlineComponentProvider&&(!((n=i.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),r._firestoreClient=new py(r._authCredentials,r._appCheckCredentials,r._queue,s,r._componentsProvider&&function(u){const c=u==null?void 0:u._online.build();return{_offline:u==null?void 0:u._offline.build(c),_online:c}}(r._componentsProvider))}function Ny(r,t){qt("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const e=r._freezeSettings();return Md(r,Se.provider,{build:n=>new va(n,e.cacheSizeBytes,t==null?void 0:t.forceOwnership)}),Promise.resolve()}async function ky(r){qt("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const t=r._freezeSettings();Md(r,Se.provider,{build:e=>new Ad(e,t.cacheSizeBytes)})}function Md(r,t,e){if((r=Q(r,nt))._firestoreClient||r._terminated)throw new D(P.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.");if(r._componentsProvider||r._getSettings().localCache)throw new D(P.FAILED_PRECONDITION,"SDK cache is already specified.");r._componentsProvider={_online:t,_offline:e},Fd(r)}function Fy(r){if(r._initialized&&!r._terminated)throw new D(P.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new vt;return r._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(n){if(!Wt.D())return Promise.resolve();const i=n+"main";await Wt.delete(i)}(sa(r._databaseId,r._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}function My(r){return function(e){const n=new vt;return e.asyncQueue.enqueueAndForget(async()=>ty(await Aa(e),n)),n.promise}(ht(r=Q(r,nt)))}function Oy(r){return _y(ht(r=Q(r,nt)))}function Ly(r){return yy(ht(r=Q(r,nt)))}function By(r){return Il(r.app,"firestore",r._databaseId.database),r._delete()}function Uy(r,t){const e=ht(r=Q(r,nt)),n=new kd;return wy(e,r._databaseId,t,n),n}function qy(r,t){return Ay(ht(r=Q(r,nt)),t).then(e=>e?new wt(r,null,e.query):null)}/**
|
|
2273
|
-
* @license
|
|
2274
|
-
* Copyright 2020 Google LLC
|
|
2275
|
-
*
|
|
2276
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2277
|
-
* you may not use this file except in compliance with the License.
|
|
2278
|
-
* You may obtain a copy of the License at
|
|
2279
|
-
*
|
|
2280
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2281
|
-
*
|
|
2282
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2283
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2284
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2285
|
-
* See the License for the specific language governing permissions and
|
|
2286
|
-
* limitations under the License.
|
|
2287
|
-
*//**
|
|
2288
|
-
* @license
|
|
2289
|
-
* Copyright 2022 Google LLC
|
|
2290
|
-
*
|
|
2291
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2292
|
-
* you may not use this file except in compliance with the License.
|
|
2293
|
-
* You may obtain a copy of the License at
|
|
2294
|
-
*
|
|
2295
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2296
|
-
*
|
|
2297
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2298
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2299
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2300
|
-
* See the License for the specific language governing permissions and
|
|
2301
|
-
* limitations under the License.
|
|
2302
|
-
*/class jn{constructor(t="count",e){this._internalFieldPath=e,this.type="AggregateField",this.aggregateType=t}}class Od{constructor(t,e,n){this._userDataWriter=e,this._data=n,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._userDataWriter.convertObjectMap(this._data)}}/**
|
|
2303
|
-
* @license
|
|
2304
|
-
* Copyright 2020 Google LLC
|
|
2305
|
-
*
|
|
2306
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2307
|
-
* you may not use this file except in compliance with the License.
|
|
2308
|
-
* You may obtain a copy of the License at
|
|
2309
|
-
*
|
|
2310
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2311
|
-
*
|
|
2312
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2313
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2314
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2315
|
-
* See the License for the specific language governing permissions and
|
|
2316
|
-
* limitations under the License.
|
|
2317
|
-
*/class Ve{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Ve(dt.fromBase64String(t))}catch(e){throw new D(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(t){return new Ve(dt.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}/**
|
|
2318
|
-
* @license
|
|
2319
|
-
* Copyright 2020 Google LLC
|
|
2320
|
-
*
|
|
2321
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2322
|
-
* you may not use this file except in compliance with the License.
|
|
2323
|
-
* You may obtain a copy of the License at
|
|
2324
|
-
*
|
|
2325
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2326
|
-
*
|
|
2327
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2328
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2329
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2330
|
-
* See the License for the specific language governing permissions and
|
|
2331
|
-
* limitations under the License.
|
|
2332
|
-
*/class ke{constructor(...t){for(let e=0;e<t.length;++e)if(t[e].length===0)throw new D(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new at(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function zy(){return new ke("__name__")}/**
|
|
2333
|
-
* @license
|
|
2334
|
-
* Copyright 2020 Google LLC
|
|
2335
|
-
*
|
|
2336
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2337
|
-
* you may not use this file except in compliance with the License.
|
|
2338
|
-
* You may obtain a copy of the License at
|
|
2339
|
-
*
|
|
2340
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2341
|
-
*
|
|
2342
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2343
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2344
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2345
|
-
* See the License for the specific language governing permissions and
|
|
2346
|
-
* limitations under the License.
|
|
2347
|
-
*/class Fe{constructor(t){this._methodName=t}}/**
|
|
2348
|
-
* @license
|
|
2349
|
-
* Copyright 2017 Google LLC
|
|
2350
|
-
*
|
|
2351
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2352
|
-
* you may not use this file except in compliance with the License.
|
|
2353
|
-
* You may obtain a copy of the License at
|
|
2354
|
-
*
|
|
2355
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2356
|
-
*
|
|
2357
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2358
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2359
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2360
|
-
* See the License for the specific language governing permissions and
|
|
2361
|
-
* limitations under the License.
|
|
2362
|
-
*/class vs{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new D(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new D(P.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return j(this._lat,t._lat)||j(this._long,t._long)}}/**
|
|
2363
|
-
* @license
|
|
2364
|
-
* Copyright 2024 Google LLC
|
|
2365
|
-
*
|
|
2366
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2367
|
-
* you may not use this file except in compliance with the License.
|
|
2368
|
-
* You may obtain a copy of the License at
|
|
2369
|
-
*
|
|
2370
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2371
|
-
*
|
|
2372
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2373
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2374
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2375
|
-
* See the License for the specific language governing permissions and
|
|
2376
|
-
* limitations under the License.
|
|
2377
|
-
*/class si{constructor(t){this._values=(t||[]).map(e=>e)}toArray(){return this._values.map(t=>t)}isEqual(t){return function(n,i){if(n.length!==i.length)return!1;for(let s=0;s<n.length;++s)if(n[s]!==i[s])return!1;return!0}(this._values,t._values)}}/**
|
|
2378
|
-
* @license
|
|
2379
|
-
* Copyright 2017 Google LLC
|
|
2380
|
-
*
|
|
2381
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2382
|
-
* you may not use this file except in compliance with the License.
|
|
2383
|
-
* You may obtain a copy of the License at
|
|
2384
|
-
*
|
|
2385
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2386
|
-
*
|
|
2387
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2388
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2389
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2390
|
-
* See the License for the specific language governing permissions and
|
|
2391
|
-
* limitations under the License.
|
|
2392
|
-
*/const jy=/^__.*__$/;class Gy{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return this.fieldMask!==null?new oe(t,this.data,this.fieldMask,e,this.fieldTransforms):new $n(t,this.data,e,this.fieldTransforms)}}class Ld{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new oe(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function Bd(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw O()}}class ws{constructor(t,e,n,i,s,a){this.settings=t,this.databaseId=e,this.serializer=n,this.ignoreUndefinedProperties=i,s===void 0&&this.vu(),this.fieldTransforms=s||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Cu(){return this.settings.Cu}Fu(t){return new ws(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Mu(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Fu({path:n,xu:!1});return i.Ou(t),i}Nu(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Fu({path:n,xu:!1});return i.vu(),i}Lu(t){return this.Fu({path:void 0,xu:!0})}Bu(t){return ss(t,this.settings.methodName,this.settings.ku||!1,this.path,this.settings.qu)}contains(t){return this.fieldMask.find(e=>t.isPrefixOf(e))!==void 0||this.fieldTransforms.find(e=>t.isPrefixOf(e.field))!==void 0}vu(){if(this.path)for(let t=0;t<this.path.length;t++)this.Ou(this.path.get(t))}Ou(t){if(t.length===0)throw this.Bu("Document fields must not be empty");if(Bd(this.Cu)&&jy.test(t))throw this.Bu('Document fields cannot begin and end with "__"')}}class Ky{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer=n||ei(t)}Qu(t,e,n,i=!1){return new ws({Cu:t,methodName:e,qu:n,path:at.emptyPath(),xu:!1,ku:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function cn(r){const t=r._freezeSettings(),e=ei(r._databaseId);return new Ky(r._databaseId,!!t.ignoreUndefinedProperties,e)}function As(r,t,e,n,i,s={}){const a=r.Qu(s.merge||s.mergeFields?2:0,t,e,i);ka("Data must be an object, but it was:",a,n);const u=zd(n,a);let c,h;if(s.merge)c=new Lt(a.fieldMask),h=a.fieldTransforms;else if(s.mergeFields){const f=[];for(const g of s.mergeFields){const _=Kr(t,g,e);if(!a.contains(_))throw new D(P.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);Gd(f,_)||f.push(_)}c=new Lt(f),h=a.fieldTransforms.filter(g=>c.covers(g.field))}else c=null,h=a.fieldTransforms;return new Gy(new bt(u),c,h)}class oi extends Fe{_toFieldTransform(t){if(t.Cu!==2)throw t.Cu===1?t.Bu(`${this._methodName}() can only appear at the top level of your update data`):t.Bu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof oi}}function Ud(r,t,e){return new ws({Cu:3,qu:t.settings.qu,methodName:r._methodName,xu:e},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class Sa extends Fe{_toFieldTransform(t){return new Xr(t.path,new kn)}isEqual(t){return t instanceof Sa}}class Va extends Fe{constructor(t,e){super(t),this.Ku=e}_toFieldTransform(t){const e=Ud(this,t,!0),n=this.Ku.map(s=>ln(s,e)),i=new tn(n);return new Xr(t.path,i)}isEqual(t){return t instanceof Va&&Ye(this.Ku,t.Ku)}}class Ca extends Fe{constructor(t,e){super(t),this.Ku=e}_toFieldTransform(t){const e=Ud(this,t,!0),n=this.Ku.map(s=>ln(s,e)),i=new en(n);return new Xr(t.path,i)}isEqual(t){return t instanceof Ca&&Ye(this.Ku,t.Ku)}}class Da extends Fe{constructor(t,e){super(t),this.$u=e}_toFieldTransform(t){const e=new Fn(t.serializer,_h(t.serializer,this.$u));return new Xr(t.path,e)}isEqual(t){return t instanceof Da&&this.$u===t.$u}}function xa(r,t,e,n){const i=r.Qu(1,t,e);ka("Data must be an object, but it was:",i,n);const s=[],a=bt.empty();xe(n,(c,h)=>{const f=Rs(t,c,e);h=yt(h);const g=i.Nu(f);if(h instanceof oi)s.push(f);else{const _=ln(h,g);_!=null&&(s.push(f),a.set(f,_))}});const u=new Lt(s);return new Ld(a,u,i.fieldTransforms)}function Na(r,t,e,n,i,s){const a=r.Qu(1,t,e),u=[Kr(t,n,e)],c=[i];if(s.length%2!=0)throw new D(P.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let _=0;_<s.length;_+=2)u.push(Kr(t,s[_])),c.push(s[_+1]);const h=[],f=bt.empty();for(let _=u.length-1;_>=0;--_)if(!Gd(h,u[_])){const R=u[_];let C=c[_];C=yt(C);const N=a.Nu(R);if(C instanceof oi)h.push(R);else{const V=ln(C,N);V!=null&&(h.push(R),f.set(R,V))}}const g=new Lt(h);return new Ld(f,g,a.fieldTransforms)}function qd(r,t,e,n=!1){return ln(e,r.Qu(n?4:3,t))}function ln(r,t){if(jd(r=yt(r)))return ka("Unsupported field value:",t,r),zd(r,t);if(r instanceof Fe)return function(n,i){if(!Bd(i.Cu))throw i.Bu(`${n._methodName}() can only be used with update() and set()`);if(!i.path)throw i.Bu(`${n._methodName}() is not currently supported inside arrays`);const s=n._toFieldTransform(i);s&&i.fieldTransforms.push(s)}(r,t),null;if(r===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),r instanceof Array){if(t.settings.xu&&t.Cu!==4)throw t.Bu("Nested arrays are not supported");return function(n,i){const s=[];let a=0;for(const u of n){let c=ln(u,i.Lu(a));c==null&&(c={nullValue:"NULL_VALUE"}),s.push(c),a++}return{arrayValue:{values:s}}}(r,t)}return function(n,i){if((n=yt(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return _h(i.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const s=lt.fromDate(n);return{timestampValue:Mn(i.serializer,s)}}if(n instanceof lt){const s=new lt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:Mn(i.serializer,s)}}if(n instanceof vs)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Ve)return{bytesValue:Ch(i.serializer,n._byteString)};if(n instanceof mt){const s=i.databaseId,a=n.firestore._databaseId;if(!a.isEqual(s))throw i.Bu(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:Xo(n.firestore._databaseId||i.databaseId,n._key.path)}}if(n instanceof si)return function(a,u){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:a.toArray().map(c=>{if(typeof c!="number")throw u.Bu("VectorValues must only contain numeric values.");return $o(u.serializer,c)})}}}}}}(n,i);throw i.Bu(`Unsupported field value: ${Ts(n)}`)}(r,t)}function zd(r,t){const e={};return Hl(r)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):xe(r,(n,i)=>{const s=ln(i,t.Mu(n));s!=null&&(e[n]=s)}),{mapValue:{fields:e}}}function jd(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof lt||r instanceof vs||r instanceof Ve||r instanceof mt||r instanceof Fe||r instanceof si)}function ka(r,t,e){if(!jd(e)||!function(i){return typeof i=="object"&&i!==null&&(Object.getPrototypeOf(i)===Object.prototype||Object.getPrototypeOf(i)===null)}(e)){const n=Ts(e);throw n==="an object"?t.Bu(r+" a custom object"):t.Bu(r+" "+n)}}function Kr(r,t,e){if((t=yt(t))instanceof ke)return t._internalPath;if(typeof t=="string")return Rs(r,t);throw ss("Field path arguments must be of type string or ",r,!1,void 0,e)}const $y=new RegExp("[~\\*/\\[\\]]");function Rs(r,t,e){if(t.search($y)>=0)throw ss(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,e);try{return new ke(...t.split("."))._internalPath}catch{throw ss(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,e)}}function ss(r,t,e,n,i){const s=n&&!n.isEmpty(),a=i!==void 0;let u=`Function ${t}() called with invalid data`;e&&(u+=" (via `toFirestore()`)"),u+=". ";let c="";return(s||a)&&(c+=" (found",s&&(c+=` in field ${n}`),a&&(c+=` in document ${i}`),c+=")"),new D(P.INVALID_ARGUMENT,u+r+c)}function Gd(r,t){return r.some(e=>e.isEqual(t))}/**
|
|
2393
|
-
* @license
|
|
2394
|
-
* Copyright 2020 Google LLC
|
|
2395
|
-
*
|
|
2396
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2397
|
-
* you may not use this file except in compliance with the License.
|
|
2398
|
-
* You may obtain a copy of the License at
|
|
2399
|
-
*
|
|
2400
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2401
|
-
*
|
|
2402
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2403
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2404
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2405
|
-
* See the License for the specific language governing permissions and
|
|
2406
|
-
* limitations under the License.
|
|
2407
|
-
*/class $r{constructor(t,e,n,i,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new mt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new Qy(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(bs("DocumentSnapshot.get",t));if(e!==null)return this._userDataWriter.convertValue(e)}}}class Qy extends $r{data(){return super.data()}}function bs(r,t){return typeof t=="string"?Rs(r,t):t instanceof ke?t._internalPath:t._delegate._internalPath}/**
|
|
2408
|
-
* @license
|
|
2409
|
-
* Copyright 2020 Google LLC
|
|
2410
|
-
*
|
|
2411
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2412
|
-
* you may not use this file except in compliance with the License.
|
|
2413
|
-
* You may obtain a copy of the License at
|
|
2414
|
-
*
|
|
2415
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2416
|
-
*
|
|
2417
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2418
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2419
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2420
|
-
* See the License for the specific language governing permissions and
|
|
2421
|
-
* limitations under the License.
|
|
2422
|
-
*/function Kd(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new D(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Fa{}class Zn extends Fa{}function Wy(r,t,...e){let n=[];t instanceof Fa&&n.push(t),n=n.concat(e),function(s){const a=s.filter(c=>c instanceof hn).length,u=s.filter(c=>c instanceof tr).length;if(a>1||a>0&&u>0)throw new D(P.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);for(const i of n)r=i._apply(r);return r}class tr extends Zn{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new tr(t,e,n)}_apply(t){const e=this._parse(t);return Qd(t._query,e),new wt(t.firestore,t.converter,vo(t._query,e))}_parse(t){const e=cn(t.firestore);return function(s,a,u,c,h,f,g){let _;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new D(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){nl(g,f);const R=[];for(const C of g)R.push(el(c,s,C));_={arrayValue:{values:R}}}else _=el(c,s,g)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||nl(g,f),_=qd(u,a,g,f==="in"||f==="not-in");return H.create(h,f,_)}(t._query,"where",e,t.firestore._databaseId,this._field,this._op,this._value)}}function Hy(r,t,e){const n=t,i=bs("where",r);return tr._create(i,n,e)}class hn extends Fa{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new hn(t,e)}_parse(t){const e=this._queryConstraints.map(n=>n._parse(t)).filter(n=>n.getFilters().length>0);return e.length===1?e[0]:tt.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return e.getFilters().length===0?t:(function(i,s){let a=i;const u=s.getFlattenedFilters();for(const c of u)Qd(a,c),a=vo(a,c)}(t._query,e),new wt(t.firestore,t.converter,vo(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}function Jy(...r){return r.forEach(t=>Wd("or",t)),hn._create("or",r)}function Yy(...r){return r.forEach(t=>Wd("and",t)),hn._create("and",r)}class Ps extends Zn{constructor(t,e){super(),this._field=t,this._direction=e,this.type="orderBy"}static _create(t,e){return new Ps(t,e)}_apply(t){const e=function(i,s,a){if(i.startAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new zr(s,a)}(t._query,this._field,this._direction);return new wt(t.firestore,t.converter,function(i,s){const a=i.explicitOrderBy.concat([s]);return new ie(i.path,i.collectionGroup,a,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)}(t._query,e))}}function Xy(r,t="asc"){const e=t,n=bs("orderBy",r);return Ps._create(n,e)}class ai extends Zn{constructor(t,e,n){super(),this.type=t,this._limit=e,this._limitType=n}static _create(t,e,n){return new ai(t,e,n)}_apply(t){return new wt(t.firestore,t.converter,Hi(t._query,this._limit,this._limitType))}}function Zy(r){return xd("limit",r),ai._create("limit",r,"F")}function tI(r){return xd("limitToLast",r),ai._create("limitToLast",r,"L")}class ui extends Zn{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ui(t,e,n)}_apply(t){const e=$d(t,this.type,this._docOrFields,this._inclusive);return new wt(t.firestore,t.converter,function(i,s){return new ie(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,s,i.endAt)}(t._query,e))}}function eI(...r){return ui._create("startAt",r,!0)}function nI(...r){return ui._create("startAfter",r,!1)}class ci extends Zn{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ci(t,e,n)}_apply(t){const e=$d(t,this.type,this._docOrFields,this._inclusive);return new wt(t.firestore,t.converter,function(i,s){return new ie(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,i.startAt,s)}(t._query,e))}}function rI(...r){return ci._create("endBefore",r,!1)}function iI(...r){return ci._create("endAt",r,!0)}function $d(r,t,e,n){if(e[0]=yt(e[0]),e[0]instanceof $r)return function(s,a,u,c,h){if(!c)throw new D(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${u}().`);const f=[];for(const g of An(s))if(g.field.isKeyField())f.push(Xe(a,c.key));else{const _=c.data.field(g.field);if(us(_))throw new D(P.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+g.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(_===null){const R=g.field.canonicalString();throw new D(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${R}' (used as the orderBy) does not exist.`)}f.push(_)}return new Re(f,h)}(r._query,r.firestore._databaseId,t,e[0]._document,n);{const i=cn(r.firestore);return function(a,u,c,h,f,g){const _=a.explicitOrderBy;if(f.length>_.length)throw new D(P.INVALID_ARGUMENT,`Too many arguments provided to ${h}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const R=[];for(let C=0;C<f.length;C++){const N=f[C];if(_[C].field.isKeyField()){if(typeof N!="string")throw new D(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${h}(), but got a ${typeof N}`);if(!Go(a)&&N.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${h}() must be a plain document ID, but '${N}' contains a slash.`);const V=a.path.child(W.fromString(N));if(!M.isDocumentKey(V))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${h}() must result in a valid document path, but '${V}' is not because it contains an odd number of segments.`);const q=new M(V);R.push(Xe(u,q))}else{const V=qd(c,h,N);R.push(V)}}return new Re(R,g)}(r._query,r.firestore._databaseId,i,t,e,n)}}function el(r,t,e){if(typeof(e=yt(e))=="string"){if(e==="")throw new D(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Go(t)&&e.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);const n=t.path.child(W.fromString(e));if(!M.isDocumentKey(n))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);return Xe(r,new M(n))}if(e instanceof mt)return Xe(r,e._key);throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ts(e)}.`)}function nl(r,t){if(!Array.isArray(r)||r.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Qd(r,t){const e=function(i,s){for(const a of i)for(const u of a.getFlattenedFilters())if(s.indexOf(u.op)>=0)return u.op;return null}(r.filters,function(i){switch(i){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(e!==null)throw e===t.op?new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${e.toString()}' filters.`)}function Wd(r,t){if(!(t instanceof tr||t instanceof hn))throw new D(P.INVALID_ARGUMENT,`Function ${r}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class Ma{convertValue(t,e="none"){switch(we(t)){case 0:return null;case 1:return t.booleanValue;case 2:return ut(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(re(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 11:return this.convertObject(t.mapValue,e);case 10:return this.convertVectorValue(t.mapValue);default:throw O()}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){const n={};return xe(t,(i,s)=>{n[i]=this.convertValue(s,e)}),n}convertVectorValue(t){var e,n,i;const s=(i=(n=(e=t.fields)===null||e===void 0?void 0:e.value.arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.map(a=>ut(a.doubleValue));return new si(s)}convertGeoPoint(t){return new vs(ut(t.latitude),ut(t.longitude))}convertArray(t,e){return(t.values||[]).map(n=>this.convertValue(n,e))}convertServerTimestamp(t,e){switch(e){case"previous":const n=cs(t);return n==null?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Br(t));default:return null}}convertTimestamp(t){const e=ne(t);return new lt(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=W.fromString(t);L(qh(n));const i=new ve(n.get(1),n.get(3)),s=new M(n.popFirst(5));return i.isEqual(e)||gt(`Document ${s} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),s}}/**
|
|
2423
|
-
* @license
|
|
2424
|
-
* Copyright 2020 Google LLC
|
|
2425
|
-
*
|
|
2426
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2427
|
-
* you may not use this file except in compliance with the License.
|
|
2428
|
-
* You may obtain a copy of the License at
|
|
2429
|
-
*
|
|
2430
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2431
|
-
*
|
|
2432
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2433
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2434
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2435
|
-
* See the License for the specific language governing permissions and
|
|
2436
|
-
* limitations under the License.
|
|
2437
|
-
*/function Ss(r,t,e){let n;return n=r?e&&(e.merge||e.mergeFields)?r.toFirestore(t,e):r.toFirestore(t):t,n}class sI extends Ma{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ve(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new mt(this.firestore,null,e)}}/**
|
|
2438
|
-
* @license
|
|
2439
|
-
* Copyright 2022 Google LLC
|
|
2440
|
-
*
|
|
2441
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2442
|
-
* you may not use this file except in compliance with the License.
|
|
2443
|
-
* You may obtain a copy of the License at
|
|
2444
|
-
*
|
|
2445
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2446
|
-
*
|
|
2447
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2448
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2449
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2450
|
-
* See the License for the specific language governing permissions and
|
|
2451
|
-
* limitations under the License.
|
|
2452
|
-
*/function oI(r){return new jn("sum",Kr("sum",r))}function aI(r){return new jn("avg",Kr("average",r))}function Hd(){return new jn("count")}function uI(r,t){var e,n;return r instanceof jn&&t instanceof jn&&r.aggregateType===t.aggregateType&&((e=r._internalFieldPath)===null||e===void 0?void 0:e.canonicalString())===((n=t._internalFieldPath)===null||n===void 0?void 0:n.canonicalString())}function cI(r,t){return Pa(r.query,t.query)&&Ye(r.data(),t.data())}/**
|
|
2453
|
-
* @license
|
|
2454
|
-
* Copyright 2020 Google LLC
|
|
2455
|
-
*
|
|
2456
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2457
|
-
* you may not use this file except in compliance with the License.
|
|
2458
|
-
* You may obtain a copy of the License at
|
|
2459
|
-
*
|
|
2460
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2461
|
-
*
|
|
2462
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2463
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2464
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2465
|
-
* See the License for the specific language governing permissions and
|
|
2466
|
-
* limitations under the License.
|
|
2467
|
-
*/class ye{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class on extends $r{constructor(t,e,n,i,s,a){super(t,e,n,i,a),this._firestore=t,this._firestoreImpl=t,this.metadata=s}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new Nr(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(bs("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class Nr extends on{data(t={}){return super.data(t)}}class an{constructor(t,e,n,i){this._firestore=t,this._userDataWriter=e,this._snapshot=i,this.metadata=new ye(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){const t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,e){this._snapshot.docs.forEach(n=>{t.call(e,new Nr(this._firestore,this._userDataWriter,n.key,n,new ye(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new D(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(i,s){if(i._snapshot.oldDocs.isEmpty()){let a=0;return i._snapshot.docChanges.map(u=>{const c=new Nr(i._firestore,i._userDataWriter,u.doc.key,u.doc,new ye(i._snapshot.mutatedKeys.has(u.doc.key),i._snapshot.fromCache),i.query.converter);return u.doc,{type:"added",doc:c,oldIndex:-1,newIndex:a++}})}{let a=i._snapshot.oldDocs;return i._snapshot.docChanges.filter(u=>s||u.type!==3).map(u=>{const c=new Nr(i._firestore,i._userDataWriter,u.doc.key,u.doc,new ye(i._snapshot.mutatedKeys.has(u.doc.key),i._snapshot.fromCache),i.query.converter);let h=-1,f=-1;return u.type!==0&&(h=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),f=a.indexOf(u.doc.key)),{type:lI(u.type),doc:c,oldIndex:h,newIndex:f}})}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function lI(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return O()}}function hI(r,t){return r instanceof on&&t instanceof on?r._firestore===t._firestore&&r._key.isEqual(t._key)&&(r._document===null?t._document===null:r._document.isEqual(t._document))&&r._converter===t._converter:r instanceof an&&t instanceof an&&r._firestore===t._firestore&&Pa(r.query,t.query)&&r.metadata.isEqual(t.metadata)&&r._snapshot.isEqual(t._snapshot)}/**
|
|
2468
|
-
* @license
|
|
2469
|
-
* Copyright 2020 Google LLC
|
|
2470
|
-
*
|
|
2471
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2472
|
-
* you may not use this file except in compliance with the License.
|
|
2473
|
-
* You may obtain a copy of the License at
|
|
2474
|
-
*
|
|
2475
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2476
|
-
*
|
|
2477
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2478
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2479
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2480
|
-
* See the License for the specific language governing permissions and
|
|
2481
|
-
* limitations under the License.
|
|
2482
|
-
*/function Jd(r){r=Q(r,mt);const t=Q(r.firestore,nt);return Sd(ht(t),r._key).then(e=>Oa(t,r,e))}class Me extends Ma{constructor(t){super(),this.firestore=t}convertBytes(t){return new Ve(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new mt(this.firestore,null,e)}}function dI(r){r=Q(r,mt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Iy(e,r._key).then(i=>new on(t,n,r._key,i,new ye(i!==null&&i.hasLocalMutations,!0),r.converter))}function fI(r){r=Q(r,mt);const t=Q(r.firestore,nt);return Sd(ht(t),r._key,{source:"server"}).then(e=>Oa(t,r,e))}function Yd(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Kd(r._query),Vd(e,r._query).then(i=>new an(t,n,r,i))}function mI(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Ey(e,r._query).then(i=>new an(t,n,r,i))}function gI(r){r=Q(r,wt);const t=Q(r.firestore,nt),e=ht(t),n=new Me(t);return Vd(e,r._query,{source:"server"}).then(i=>new an(t,n,r,i))}function Xd(r,t,e){r=Q(r,mt);const n=Q(r.firestore,nt),i=Ss(r.converter,t,e);return er(n,[As(cn(n),"setDoc",r._key,i,r.converter!==null,e).toMutation(r._key,ct.none())])}function pI(r,t,e,...n){r=Q(r,mt);const i=Q(r.firestore,nt),s=cn(i);let a;return a=typeof(t=yt(t))=="string"||t instanceof ke?Na(s,"updateDoc",r._key,t,e,n):xa(s,"updateDoc",r._key,t),er(i,[a.toMutation(r._key,ct.exists(!0))])}function Zd(r){return er(Q(r.firestore,nt),[new Qn(r._key,ct.none())])}function tf(r,t){const e=Q(r.firestore,nt),n=ii(r),i=Ss(r.converter,t);return er(e,[As(cn(r.firestore),"addDoc",n._key,i,r.converter!==null,{}).toMutation(n._key,ct.exists(!1))]).then(()=>n)}function _I(r,...t){var e,n,i;r=yt(r);let s={includeMetadataChanges:!1,source:"default"},a=0;typeof t[a]!="object"||ko(t[a])||(s=t[a],a++);const u={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(ko(t[a])){const g=t[a];t[a]=(e=g.next)===null||e===void 0?void 0:e.bind(g),t[a+1]=(n=g.error)===null||n===void 0?void 0:n.bind(g),t[a+2]=(i=g.complete)===null||i===void 0?void 0:i.bind(g)}let c,h,f;if(r instanceof mt)h=Q(r.firestore,nt),f=Kn(r._key.path),c={next:g=>{t[a]&&t[a](Oa(h,r,g))},error:t[a+1],complete:t[a+2]};else{const g=Q(r,wt);h=Q(g.firestore,nt),f=g._query;const _=new Me(h);c={next:R=>{t[a]&&t[a](new an(h,_,g,R))},error:t[a+1],complete:t[a+2]},Kd(r._query)}return function(_,R,C,N){const V=new Is(N),q=new pa(R,V,C);return _.asyncQueue.enqueueAndForget(async()=>fa(await zn(_),q)),()=>{V.Za(),_.asyncQueue.enqueueAndForget(async()=>ma(await zn(_),q))}}(ht(h),f,u,c)}function yI(r,t){return vy(ht(r=Q(r,nt)),ko(t)?t:{next:t})}function er(r,t){return function(n,i){const s=new vt;return n.asyncQueue.enqueueAndForget(async()=>J_(await Aa(n),i,s)),s.promise}(ht(r),t)}function Oa(r,t,e){const n=e.docs.get(t._key),i=new Me(r);return new on(r,i,t._key,n,new ye(e.hasPendingWrites,e.fromCache),t.converter)}/**
|
|
2483
|
-
* @license
|
|
2484
|
-
* Copyright 2022 Google LLC
|
|
2485
|
-
*
|
|
2486
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2487
|
-
* you may not use this file except in compliance with the License.
|
|
2488
|
-
* You may obtain a copy of the License at
|
|
2489
|
-
*
|
|
2490
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2491
|
-
*
|
|
2492
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2493
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2494
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2495
|
-
* See the License for the specific language governing permissions and
|
|
2496
|
-
* limitations under the License.
|
|
2497
|
-
*/function II(r){return ef(r,{count:Hd()})}function ef(r,t){const e=Q(r.firestore,nt),n=ht(e),i=Wl(t,(s,a)=>new Ah(a,s.aggregateType,s._internalFieldPath));return Ty(n,r._query,i).then(s=>function(u,c,h){const f=new Me(u);return new Od(c,f,h)}(e,r,s))}class EI{constructor(t){this.kind="memory",this._onlineComponentProvider=Se.provider,t!=null&&t.garbageCollector?this._offlineComponentProvider=t.garbageCollector._offlineComponentProvider:this._offlineComponentProvider=Pe.provider}toJSON(){return{kind:this.kind}}}class TI{constructor(t){let e;this.kind="persistent",t!=null&&t.tabManager?(t.tabManager._initialize(t),e=t.tabManager):(e=nf(void 0),e._initialize(t)),this._onlineComponentProvider=e._onlineComponentProvider,this._offlineComponentProvider=e._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class vI{constructor(){this.kind="memoryEager",this._offlineComponentProvider=Pe.provider}toJSON(){return{kind:this.kind}}}class wI{constructor(t){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new dy(t)}}toJSON(){return{kind:this.kind}}}function AI(){return new vI}function RI(r){return new wI(r==null?void 0:r.cacheSizeBytes)}function bI(r){return new EI(r)}function PI(r){return new TI(r)}class SI{constructor(t){this.forceOwnership=t,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Se.provider,this._offlineComponentProvider={build:e=>new va(e,t==null?void 0:t.cacheSizeBytes,this.forceOwnership)}}}class VI{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(t){this._onlineComponentProvider=Se.provider,this._offlineComponentProvider={build:e=>new Ad(e,t==null?void 0:t.cacheSizeBytes)}}}function nf(r){return new SI(r==null?void 0:r.forceOwnership)}function CI(){return new VI}/**
|
|
2498
|
-
* @license
|
|
2499
|
-
* Copyright 2022 Google LLC
|
|
2500
|
-
*
|
|
2501
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2502
|
-
* you may not use this file except in compliance with the License.
|
|
2503
|
-
* You may obtain a copy of the License at
|
|
2504
|
-
*
|
|
2505
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2506
|
-
*
|
|
2507
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2508
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2509
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2510
|
-
* See the License for the specific language governing permissions and
|
|
2511
|
-
* limitations under the License.
|
|
2512
|
-
*/const DI={maxAttempts:5};/**
|
|
2513
|
-
* @license
|
|
2514
|
-
* Copyright 2020 Google LLC
|
|
2515
|
-
*
|
|
2516
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2517
|
-
* you may not use this file except in compliance with the License.
|
|
2518
|
-
* You may obtain a copy of the License at
|
|
2519
|
-
*
|
|
2520
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2521
|
-
*
|
|
2522
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2523
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2524
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2525
|
-
* See the License for the specific language governing permissions and
|
|
2526
|
-
* limitations under the License.
|
|
2527
|
-
*/class rf{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=cn(t)}set(t,e,n){this._verifyNotCommitted();const i=pe(t,this._firestore),s=Ss(i.converter,e,n),a=As(this._dataReader,"WriteBatch.set",i._key,s,i.converter!==null,n);return this._mutations.push(a.toMutation(i._key,ct.none())),this}update(t,e,n,...i){this._verifyNotCommitted();const s=pe(t,this._firestore);let a;return a=typeof(e=yt(e))=="string"||e instanceof ke?Na(this._dataReader,"WriteBatch.update",s._key,e,n,i):xa(this._dataReader,"WriteBatch.update",s._key,e),this._mutations.push(a.toMutation(s._key,ct.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=pe(t,this._firestore);return this._mutations=this._mutations.concat(new Qn(e._key,ct.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new D(P.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function pe(r,t){if((r=yt(r)).firestore!==t)throw new D(P.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return r}/**
|
|
2528
|
-
* @license
|
|
2529
|
-
* Copyright 2020 Google LLC
|
|
2530
|
-
*
|
|
2531
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2532
|
-
* you may not use this file except in compliance with the License.
|
|
2533
|
-
* You may obtain a copy of the License at
|
|
2534
|
-
*
|
|
2535
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2536
|
-
*
|
|
2537
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2538
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2539
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2540
|
-
* See the License for the specific language governing permissions and
|
|
2541
|
-
* limitations under the License.
|
|
2542
|
-
*//**
|
|
2543
|
-
* @license
|
|
2544
|
-
* Copyright 2020 Google LLC
|
|
2545
|
-
*
|
|
2546
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2547
|
-
* you may not use this file except in compliance with the License.
|
|
2548
|
-
* You may obtain a copy of the License at
|
|
2549
|
-
*
|
|
2550
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2551
|
-
*
|
|
2552
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2553
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2554
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2555
|
-
* See the License for the specific language governing permissions and
|
|
2556
|
-
* limitations under the License.
|
|
2557
|
-
*/class sf extends class{constructor(e,n){this._firestore=e,this._transaction=n,this._dataReader=cn(e)}get(e){const n=pe(e,this._firestore),i=new sI(this._firestore);return this._transaction.lookup([n._key]).then(s=>{if(!s||s.length!==1)return O();const a=s[0];if(a.isFoundDocument())return new $r(this._firestore,i,a.key,a,n.converter);if(a.isNoDocument())return new $r(this._firestore,i,n._key,null,n.converter);throw O()})}set(e,n,i){const s=pe(e,this._firestore),a=Ss(s.converter,n,i),u=As(this._dataReader,"Transaction.set",s._key,a,s.converter!==null,i);return this._transaction.set(s._key,u),this}update(e,n,i,...s){const a=pe(e,this._firestore);let u;return u=typeof(n=yt(n))=="string"||n instanceof ke?Na(this._dataReader,"Transaction.update",a._key,n,i,s):xa(this._dataReader,"Transaction.update",a._key,n),this._transaction.update(a._key,u),this}delete(e){const n=pe(e,this._firestore);return this._transaction.delete(n._key),this}}{constructor(t,e){super(t,e),this._firestore=t}get(t){const e=pe(t,this._firestore),n=new Me(this._firestore);return super.get(t).then(i=>new on(this._firestore,n,e._key,i._document,new ye(!1,!1),e.converter))}}function xI(r,t,e){r=Q(r,nt);const n=Object.assign(Object.assign({},DI),e);return function(s){if(s.maxAttempts<1)throw new D(P.INVALID_ARGUMENT,"Max attempts must be at least 1")}(n),function(s,a,u){const c=new vt;return s.asyncQueue.enqueueAndForget(async()=>{const h=await Pd(s);new gy(s.asyncQueue,h,u,a,c).au()}),c.promise}(ht(r),i=>t(new sf(r,i)),n)}/**
|
|
2558
|
-
* @license
|
|
2559
|
-
* Copyright 2020 Google LLC
|
|
2560
|
-
*
|
|
2561
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2562
|
-
* you may not use this file except in compliance with the License.
|
|
2563
|
-
* You may obtain a copy of the License at
|
|
2564
|
-
*
|
|
2565
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2566
|
-
*
|
|
2567
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2568
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2569
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2570
|
-
* See the License for the specific language governing permissions and
|
|
2571
|
-
* limitations under the License.
|
|
2572
|
-
*/function NI(){return new oi("deleteField")}function kI(){return new Sa("serverTimestamp")}function FI(...r){return new Va("arrayUnion",r)}function MI(...r){return new Ca("arrayRemove",r)}function OI(r){return new Da("increment",r)}function LI(r){return new si(r)}/**
|
|
2573
|
-
* @license
|
|
2574
|
-
* Copyright 2020 Google LLC
|
|
2575
|
-
*
|
|
2576
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2577
|
-
* you may not use this file except in compliance with the License.
|
|
2578
|
-
* You may obtain a copy of the License at
|
|
2579
|
-
*
|
|
2580
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2581
|
-
*
|
|
2582
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2583
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2584
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2585
|
-
* See the License for the specific language governing permissions and
|
|
2586
|
-
* limitations under the License.
|
|
2587
|
-
*/function BI(r){return ht(r=Q(r,nt)),new rf(r,t=>er(r,t))}/**
|
|
2588
|
-
* @license
|
|
2589
|
-
* Copyright 2021 Google LLC
|
|
2590
|
-
*
|
|
2591
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2592
|
-
* you may not use this file except in compliance with the License.
|
|
2593
|
-
* You may obtain a copy of the License at
|
|
2594
|
-
*
|
|
2595
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2596
|
-
*
|
|
2597
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2598
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2599
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2600
|
-
* See the License for the specific language governing permissions and
|
|
2601
|
-
* limitations under the License.
|
|
2602
|
-
*/function UI(r,t){const e=ht(r=Q(r,nt));if(!e._uninitializedComponentsProvider||e._uninitializedComponentsProvider._offline.kind==="memory")return qt("Cannot enable indexes when persistence is disabled"),Promise.resolve();const n=function(s){const a=typeof s=="string"?function(h){try{return JSON.parse(h)}catch(f){throw new D(P.INVALID_ARGUMENT,"Failed to parse JSON: "+(f==null?void 0:f.message))}}(s):s,u=[];if(Array.isArray(a.indexes))for(const c of a.indexes){const h=rl(c,"collectionGroup"),f=[];if(Array.isArray(c.fields))for(const g of c.fields){const _=Rs("setIndexConfiguration",rl(g,"fieldPath"));g.arrayConfig==="CONTAINS"?f.push(new Je(_,2)):g.order==="ASCENDING"?f.push(new Je(_,0)):g.order==="DESCENDING"&&f.push(new Je(_,1))}u.push(new Cn(Cn.UNKNOWN_ID,h,f,Dn.empty()))}return u}(t);return Ry(e,n)}function rl(r,t){if(typeof r[t]!="string")throw new D(P.INVALID_ARGUMENT,"Missing string value for: "+t);return r[t]}/**
|
|
2603
|
-
* @license
|
|
2604
|
-
* Copyright 2023 Google LLC
|
|
2605
|
-
*
|
|
2606
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2607
|
-
* you may not use this file except in compliance with the License.
|
|
2608
|
-
* You may obtain a copy of the License at
|
|
2609
|
-
*
|
|
2610
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2611
|
-
*
|
|
2612
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2613
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2614
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2615
|
-
* See the License for the specific language governing permissions and
|
|
2616
|
-
* limitations under the License.
|
|
2617
|
-
*/class of{constructor(t){this._firestore=t,this.type="PersistentCacheIndexManager"}}function qI(r){var t;r=Q(r,nt);const e=il.get(r);if(e)return e;if(((t=ht(r)._uninitializedComponentsProvider)===null||t===void 0?void 0:t._offline.kind)!=="persistent")return null;const n=new of(r);return il.set(r,n),n}function zI(r){af(r,!0)}function jI(r){af(r,!1)}function GI(r){Py(ht(r._firestore)).then(t=>x("deleting all persistent cache indexes succeeded")).catch(t=>qt("deleting all persistent cache indexes failed",t))}function af(r,t){by(ht(r._firestore),t).then(e=>x(`setting persistent cache index auto creation isEnabled=${t} succeeded`)).catch(e=>qt(`setting persistent cache index auto creation isEnabled=${t} failed`,e))}const il=new WeakMap;/**
|
|
2618
|
-
* @license
|
|
2619
|
-
* Copyright 2017 Google LLC
|
|
2620
|
-
*
|
|
2621
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2622
|
-
* you may not use this file except in compliance with the License.
|
|
2623
|
-
* You may obtain a copy of the License at
|
|
2624
|
-
*
|
|
2625
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2626
|
-
*
|
|
2627
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2628
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2629
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2630
|
-
* See the License for the specific language governing permissions and
|
|
2631
|
-
* limitations under the License.
|
|
2632
|
-
*/function KI(r){var t;const e=(t=ht(Q(r.firestore,nt))._onlineComponents)===null||t===void 0?void 0:t.datastore.serializer;return e===void 0?null:fs(e,kt(r._query))._t}function $I(r,t){var e;const n=Wl(t,(s,a)=>new Ah(a,s.aggregateType,s._internalFieldPath)),i=(e=ht(Q(r.firestore,nt))._onlineComponents)===null||e===void 0?void 0:e.datastore.serializer;return i===void 0?null:Oh(i,uh(r._query),n,!0).request}/**
|
|
2633
|
-
* @license
|
|
2634
|
-
* Copyright 2023 Google LLC
|
|
2635
|
-
*
|
|
2636
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2637
|
-
* you may not use this file except in compliance with the License.
|
|
2638
|
-
* You may obtain a copy of the License at
|
|
2639
|
-
*
|
|
2640
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2641
|
-
*
|
|
2642
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2643
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2644
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2645
|
-
* See the License for the specific language governing permissions and
|
|
2646
|
-
* limitations under the License.
|
|
2647
|
-
*/class QI{constructor(){throw new Error("instances of this class should not be created")}static onExistenceFilterMismatch(t){return La.instance.onExistenceFilterMismatch(t)}}class La{constructor(){this.Uu=new Map}static get instance(){return Fi||(Fi=new La,function(e){if(Ji)throw new Error("a TestingHooksSpi instance is already set");Ji=e}(Fi)),Fi}et(t){this.Uu.forEach(e=>e(t))}onExistenceFilterMismatch(t){const e=Symbol(),n=this.Uu;return n.set(e,t),()=>n.delete(e)}}let Fi=null;(function(t,e=!0){(function(i){Gn=i})(vl),Fr(new bn("firestore",(n,{instanceIdentifier:i,options:s})=>{const a=n.getProvider("app").getImmediate(),u=new nt(new Tg(n.getProvider("auth-internal")),new Ag(n.getProvider("app-check-internal")),function(h,f){if(!Object.prototype.hasOwnProperty.apply(h.options,["projectId"]))throw new D(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ve(h.options.projectId,f)}(a,i),a);return s=Object.assign({useFetchStreams:e},s),u._setSettings(s),u},"PUBLIC").setMultipleInstances(!0)),We(Qu,"4.7.3",t),We(Qu,"4.7.3","esm2017")})();const WI=async(r,t)=>{var a,u;const e=ba(r,t),{error:n,result:i}=await Qr.tryDo(Yd(e)),s=(u=(a=i==null?void 0:i.docs)==null?void 0:a.map)==null?void 0:u.call(a,c=>({...c.data(),id:c.id}));return n&&console.error(n),{error:n,result:s}},HI=async(r,t,e)=>{const n=ii(r,t,e),{error:i,result:s}=await Qr.tryDo(Jd(n));return i&&console.error(i),{error:i,result:s==null?void 0:s.data()}},JI=async(r,t,e)=>{const n=ba(r,t),{error:i,result:s}=await Qr.tryDo(tf(n,e));return i&&console.error(i),{error:i,result:s}},YI=async(r,t,e)=>{const n=ii(r,t,e.id),{error:i,result:s}=await Qr.tryDo(Xd(n,e,{merge:!0}));return i&&console.error(i),{error:i,result:s}},XI=async(r,t,e)=>{const n=ii(r,t,e),{error:i,result:s}=await Qr.tryDo(Zd(n));return i&&console.error(i),{error:i,result:s}},ZI=async r=>(await Promise.resolve().then(()=>require("./index.esm-Bng7WOuv.cjs")).then(e=>e.default.initializeApp))(r),tE=async r=>(await Promise.resolve().then(()=>require("./index.esm-DS_RlbEp.cjs")).then(e=>e.default.getFirestore))(r),eE=async r=>(await Promise.resolve().then(()=>require("./index.esm-CASCXGKx.cjs")).then(e=>e.default.getStorage))(r);exports.AbstractUserDataWriter=Ma;exports.AggregateField=jn;exports.AggregateQuerySnapshot=Od;exports.ByteString=dt;exports.Bytes=Ve;exports.CollectionReference=Kt;exports.Component=bn;exports.DEFAULT_ENTRY_NAME=kr;exports.DatabaseId=ve;exports.DocumentKey=M;exports.DocumentReference=mt;exports.DocumentSnapshot=on;exports.FieldPath=ke;exports.FieldPath$1=at;exports.FieldValue=Fe;exports.FirebaseError=un;exports.Firestore=nt;exports.FirestoreError=D;exports.GeoPoint=vs;exports.LoadBundleTask=kd;exports.PersistentCacheIndexManager=of;exports.Query=wt;exports.QueryCompositeFilterConstraint=hn;exports.QueryConstraint=Zn;exports.QueryDocumentSnapshot=Nr;exports.QueryEndAtConstraint=ci;exports.QueryFieldFilterConstraint=tr;exports.QueryLimitConstraint=ai;exports.QueryOrderByConstraint=Ps;exports.QuerySnapshot=an;exports.QueryStartAtConstraint=ui;exports.SDK_VERSION=vl;exports.Se=Cy;exports.SnapshotMetadata=ye;exports.TestingHooks=QI;exports.Timestamp=lt;exports.Transaction=sf;exports.VectorValue=si;exports.WriteBatch=rf;exports.__PRIVATE_AutoId=Bo;exports.__PRIVATE_EmptyAppCheckTokenProvider=Rg;exports.__PRIVATE_EmptyAuthCredentialsProvider=Fl;exports.__PRIVATE_cast=Q;exports.__PRIVATE_debugAssert=Ig;exports.__PRIVATE_isBase64Available=Zg;exports.__PRIVATE_logWarn=qt;exports.__PRIVATE_validateIsNotUsedTogether=Dd;exports._addComponent=fo;exports._addOrOverwriteComponent=tg;exports._apps=Ee;exports._clearComponents=ng;exports._components=Sn;exports._getProvider=os;exports._internalAggregationQueryToProtoRunAggregationQueryRequest=$I;exports._internalQueryToProtoQueryTarget=KI;exports._isFirebaseApp=El;exports._isFirebaseServerApp=eg;exports._registerComponent=Fr;exports._removeServiceInstance=Il;exports._serverApps=Pn;exports.addDoc=tf;exports.addDocument=JI;exports.aggregateFieldEqual=uI;exports.aggregateQuerySnapshotEqual=cI;exports.and=Yy;exports.arrayRemove=MI;exports.arrayUnion=FI;exports.average=aI;exports.clearIndexedDbPersistence=Fy;exports.collection=ba;exports.collectionGroup=Sy;exports.connectFirestoreEmulator=Nd;exports.count=Hd;exports.createMockUserToken=cl;exports.deleteAllPersistentCacheIndexes=GI;exports.deleteApp=Rl;exports.deleteDoc=Zd;exports.deleteDocument=XI;exports.deleteField=NI;exports.disableNetwork=Ly;exports.disablePersistentCacheIndexAutoCreation=jI;exports.doc=ii;exports.documentId=zy;exports.enableIndexedDbPersistence=Ny;exports.enableMultiTabIndexedDbPersistence=ky;exports.enableNetwork=Oy;exports.enablePersistentCacheIndexAutoCreation=zI;exports.endAt=iI;exports.endBefore=rI;exports.ensureFirestoreConfigured=ht;exports.executeWrite=er;exports.getAggregateFromServer=ef;exports.getAllDocuments=WI;exports.getApp=Al;exports.getApps=og;exports.getCountFromServer=II;exports.getDefaultEmulatorHostnameAndPort=al;exports.getDoc=Jd;exports.getDocFromCache=dI;exports.getDocFromServer=fI;exports.getDocs=Yd;exports.getDocsFromCache=mI;exports.getDocsFromServer=gI;exports.getDocumentById=HI;exports.getFireStorage=eE;exports.getFireStore=tE;exports.getFirestore=xy;exports.getModularInstance=yt;exports.getPersistentCacheIndexManager=qI;exports.increment=OI;exports.initFirebaseApp=ZI;exports.initializeApp=wl;exports.initializeFirestore=Dy;exports.initializeServerApp=sg;exports.limit=Zy;exports.limitToLast=tI;exports.loadBundle=Uy;exports.memoryEagerGarbageCollector=AI;exports.memoryLocalCache=bI;exports.memoryLruGarbageCollector=RI;exports.namedQuery=qy;exports.onLog=ag;exports.onSnapshot=_I;exports.onSnapshotsInSync=yI;exports.or=Jy;exports.orderBy=Xy;exports.persistentLocalCache=PI;exports.persistentMultipleTabManager=CI;exports.persistentSingleTabManager=nf;exports.query=Wy;exports.queryEqual=Pa;exports.refEqual=Vy;exports.registerVersion=We;exports.runTransaction=xI;exports.serverTimestamp=kI;exports.setDoc=Xd;exports.setDocument=YI;exports.setIndexConfiguration=UI;exports.setLogLevel=yg;exports.setLogLevel$1=ug;exports.snapshotEqual=hI;exports.startAfter=nI;exports.startAt=eI;exports.sum=oI;exports.terminate=By;exports.updateDoc=pI;exports.vector=LI;exports.waitForPendingWrites=My;exports.where=Hy;exports.writeBatch=BI;
|