PageSourceSearch

https://eventory-i.netlify.app/assets/firebase-CMvjtFvi.js

js eventory-i.netlify.app collected 2026-10-03 10:42:47 UTC 616,008 bytes, 4,133 lines download raw bytes

1var Qu={};/**
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 */const Wh=function(r){const e=[];let t=0;for(let n=0;n<r.length;n++){let i=r.charCodeAt(n);i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=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),e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128)}return e},tg=function(r){const e=[];let t=0,n=0;for(;t<r.length;){const i=r[t++];if(i<128)e[n++]=String.fromCharCode(i);else if(i>191&&i<224){const s=r[t++];e[n++]=String.fromCharCode((i&31)<<6|s&63)}else if(i>239&&i<365){const s=r[t++],o=r[t++],c=r[t++],u=((i&7)<<18|(s&63)<<12|(o&63)<<6|c&63)-65536;e[n++]=String.fromCharCode(55296+(u>>10)),e[n++]=String.fromCharCode(56320+(u&1023))}else{const s=r[t++],o=r[t++];e[n++]=String.fromCharCode((i&15)<<12|(s&63)<<6|o&63)}}return e.join("")},Hh={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,e){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let i=0;i<r.length;i+=3){const s=r[i],o=i+1<r.length,c=o?r[i+1]:0,u=i+2<r.length,h=u?r[i+2]:0,f=s>>2,m=(s&3)<<4|c>>4;let _=(c&15)<<2|h>>6,b=h&63;u||(b=64,o||(_=64)),n.push(t[f],t[m],t[_],t[b])}return n.join("")},encodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(r):this.encodeByteArray(Wh(r),e)},decodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(r):tg(this.decodeStringToByteArray(r,e))},decodeStringToByteArray(r,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let i=0;i<r.length;){const s=t[r.charAt(i++)],c=i<r.length?t[r.charAt(i)]:0;++i;const h=i<r.length?t[r.charAt(i)]:64;++i;const m=i<r.length?t[r.charAt(i)]:64;if(++i,s==null||c==null||h==null||m==null)throw new ng;const _=s<<2|c>>4;if(n.push(_),h!==64){const b=c<<4&240|h>>2;if(n.push(b),m!==64){const V=h<<6&192|m;n.push(V)}}}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 ng extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const rg=function(r){const e=Wh(r);return Hh.encodeByteArray(e,!0)},ds=function(r){return rg(r).replace(/\./g,"")},Qh=function(r){try{return Hh.decodeString(r,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
17 * @license
18 * Copyright 2022 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 */function ig(){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.")}/**
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 */const sg=()=>ig().__FIREBASE_DEFAULTS__,og=()=>{if(typeof process>"u"||typeof Qu>"u")return;const r=Qu.__FIREBASE_DEFAULTS__;if(r)return JSON.parse(r)},ag=()=>{if(typeof document>"u")return;let r;try{r=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=r&&Qh(r[1]);return e&&JSON.parse(e)},xs=()=>{try{return sg()||og()||ag()}catch(r){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${r}`);return}},Jh=r=>{var e,t;return(t=(e=xs())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[r]},cg=r=>{const e=Jh(r);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const n=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),n]:[e.substring(0,t),n]},Yh=()=>{var r;return(r=xs())===null||r===void 0?void 0:r.config},Xh=r=>{var e;return(e=xs())===null||e===void 0?void 0:e[`_${r}`]};/**
47 * @license
48 * Copyright 2017 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 */class ug{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,n))}}}/**
62 * @license
63 * Copyright 2021 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 */function lg(r,e){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 t={alg:"none",type:"JWT"},n=e||"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 o=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[ds(JSON.stringify(t)),ds(JSON.stringify(o)),""].join(".")}/**
77 * @license
78 * Copyright 2017 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 me(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function hg(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(me())}function dg(){var r;const e=(r=xs())===null||r===void 0?void 0:r.forceEnvironment;if(e==="node")return!0;
91if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function fg(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Da(){const r=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof r=="object"&&r.id!==void 0}function pg(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function mg(){const r=me();return r.indexOf("MSIE ")>=0||r.indexOf("Trident/")>=0}function Zh(){return!dg()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Os(){try{return typeof indexedDB=="object"}catch{return!1}}function Va(){return new Promise((r,e)=>{try{let t=!0;const n="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(n);i.onsuccess=()=>{i.result.close(),t||self.indexedDB.deleteDatabase(n),r(!0)},i.onupgradeneeded=()=>{t=!1},i.onerror=()=>{var s;e(((s=i.error)===null||s===void 0?void 0:s.message)||"")}}catch(t){e(t)}})}function ed(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}/**
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 */const gg="FirebaseError";class He extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name=gg,Object.setPrototypeOf(this,He.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,vn.prototype.create)}}class vn{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},i=`${this.service}/${e}`,s=this.errors[e],o=s?_g(s,n):"Error",c=`${this.serviceName}: ${o} (${i}).`;return new He(i,c,n)}}function _g(r,e){return r.replace(yg,(t,n)=>{const i=e[n];return i!=null?String(i):`<${n}?>`})}const yg=/\{\$([^}]+)}/g;function Ig(r){for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e))return!1;return!0}function zn(r,e){if(r===e)return!0;const t=Object.keys(r),n=Object.keys(e);for(const i of t){if(!n.includes(i))return!1;const s=r[i],o=e[i];if(Ju(s)&&Ju(o)){if(!zn(s,o))return!1}else if(s!==o)return!1}for(const i of n)if(!t.includes(i))return!1;return!0}function Ju(r){return r!==null&&typeof r=="object"}/**
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 */function li(r){const e=[];for(const[t,n]of Object.entries(r))Array.isArray(n)?n.forEach(i=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(i))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(n));return e.length?"&"+e.join("&"):""}function Or(r){const e={};return r.replace(/^\?/,"").split("&").forEach(n=>{if(n){const[i,s]=n.split("=");e[decodeURIComponent(i)]=decodeURIComponent(s)}}),e}function Mr(r){const e=r.indexOf("?");if(!e)return"";const t=r.indexOf("#",e);return r.substring(e,t>0?t:void 0)}function Tg(r,e){const t=new Eg(r,e);return t.subscribe.bind(t)}class Eg{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(n=>{this.error(n)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,n){let i;if(e===void 0&&t===void 0&&n===void 0)throw new Error("Missing Observer.");vg(e,["next","error","complete"])?i=e:i={next:e,error:t,complete:n},i.next===void 0&&(i.next=No),i.error===void 0&&(i.error=No),i.complete===void 0&&(i.complete=No);const s=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),s}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>
121{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(n){typeof console<"u"&&console.error&&console.error(n)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function vg(r,e){if(typeof r!="object"||r===null)return!1;for(const t of e)if(t in r&&typeof r[t]=="function")return!0;return!1}function No(){}/**
122 * @license
123 * Copyright 2019 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 */const wg=1e3,Ag=2,Rg=4*60*60*1e3,bg=.5;function Yu(r,e=wg,t=Ag){const n=e*Math.pow(t,r),i=Math.round(bg*n*(Math.random()-.5)*2);return Math.min(Rg,n+i)}/**
137 * @license
138 * Copyright 2021 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 */function re(r){return r&&r._delegate?r._delegate:r}class Ke{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/**
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 */const Xt="[DEFAULT]";/**
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 Sg{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const n=new ug;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:t});i&&n.resolve(i)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const n=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),i=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!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(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(Cg(e))try{this.getOrInitializeService({instanceIdentifier:Xt})}catch{}for(const[t,n]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(t);try{const s=this.getOrInitializeService({instanceIdentifier:i});n.resolve(s)}catch{}}}}clearInstance(e=Xt){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Xt){return this.instances.has(e)}getOptions(e=Xt){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.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:t});for(const[s,o]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(s);n===c&&o.resolve(i)}return i}onInit(e,t){var n;const i=this.normalizeInstanceIdentifier(t),s=(n=this.onInitCallbacks.get(i))!==null&&n!==void 0?n:new Set;s.add(e),this.onInitCallbacks.set(i,s);const o=this.instances.get(i);return o&&e(o,i),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const i of n)try{i(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:Pg(e),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}return n||null}normalizeInstanceIdentifier(e=Xt){return this.component?this.component.multipleInstances?e:Xt:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Pg(r){return r===Xt?void 0:r}function Cg(r){return r.instantiationMode==="EAGER"}/**
182 * @license
183 * Copyright 2019 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 */class Dg{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new Sg(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
197 * @license
198 * Copyright 2017 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 */var H;(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"})(H||(H={}));const Vg={debug:H.DEBUG,verbose:H.VERBOSE,info:H.INFO,warn:H.WARN,error:H.ERROR,silent:H.SILENT},kg=H.INFO,Ng={[H.DEBUG]:"log",[H.VERBOSE]:"log",[H.INFO]:"info",[H.WARN]:"warn",[H.ERROR]:"error"},xg=(r,e,...t)=>{if(e<r.logLevel)return;const n=new Date().toISOString(),i=Ng[e];if(i)console[i](`[${n}]  ${r.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Ms{constructor(e){this.name=e,this._logLevel=kg,this._logHandler=xg,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in H))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Vg[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,H.DEBUG,...e),this._logHandler(this,H.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,H.VERBOSE,...e),this._logHandler(this,H.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,H.INFO,...e),this._logHandler(this,H.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,H.WARN,...e),this._logHandler(this,H.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,H.ERROR,...e),this._logHandler(this,H.ERROR,...e)}}const Og=(r,e)=>e.some(t=>r instanceof t);let Xu,Zu;function Mg(){return Xu||(Xu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Lg(){return Zu||(Zu=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const td=new WeakMap,Jo=new WeakMap,nd=new WeakMap,xo=new WeakMap,ka=new WeakMap;function Fg(r){const e=new Promise((t,n)=>{const i=()=>{r.removeEventListener("success",s),r.removeEventListener("error",o)},s=()=>{t(kt(r.result)),i()},o=()=>{n(r.error),i()};r.addEventListener("success",s),r.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&td.set(t,r)}).catch(()=>{}),ka.set(e,r),e}function Ug(r){if(Jo.has(r))return;const e=new Promise((t,n)=>{const i=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",o),r.removeEventListener("abort",o)},s=()=>{t(),i()},o=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",s),r.addEventListener("error",o),r.addEventListener("abort",o)});Jo.set(r,e)}let Yo={get(r,e,t){if(r instanceof IDBTransaction){if(e==="done")return Jo.get(r);if(e==="objectStoreNames")return r.objectStoreNames||nd.get(r);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return kt(r[e])},set(r,e,t){return r[e]=t,!0},has(r,e){return r instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in r}};function Bg(r){Yo=r(Yo)}function qg(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=r.call(Oo(this),e,...t);return nd.set(n,e.sort?e.sort():[e]),kt(n)}:Lg().includes(r)?function(...e){return r.apply(Oo(this),e),kt(td.get(this))}:function(...e){return kt(r.apply(Oo(this),e))}}function jg(r){return typeof r=="function"?qg(r):(r instanceof IDBTransaction&&Ug(r),Og(r,Mg())?new Proxy(r,Yo):r)}function kt(r){if(r instanceof IDBRequest)return Fg(r);if(xo.has(r))return xo.get(r);const e=jg(r);return e!==r&&(xo.set(r,e),ka.set(e,r)),e}const Oo=r=>ka.get(r);function rd(r,e,{blocked:t,upgrade:n,blocking:i,terminated:s}={}
211){const o=indexedDB.open(r,e),c=kt(o);return n&&o.addEventListener("upgradeneeded",u=>{n(kt(o.result),u.oldVersion,u.newVersion,kt(o.transaction),u)}),t&&o.addEventListener("blocked",u=>t(u.oldVersion,u.newVersion,u)),c.then(u=>{s&&u.addEventListener("close",()=>s()),i&&u.addEventListener("versionchange",h=>i(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}const $g=["get","getKey","getAll","getAllKeys","count"],zg=["put","add","delete","clear"],Mo=new Map;function el(r,e){if(!(r instanceof IDBDatabase&&!(e in r)&&typeof e=="string"))return;if(Mo.get(e))return Mo.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,i=zg.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(i||$g.includes(t)))return;const s=async function(o,...c){const u=this.transaction(o,i?"readwrite":"readonly");let h=u.store;return n&&(h=h.index(c.shift())),(await Promise.all([h[t](...c),i&&u.done]))[0]};return Mo.set(e,s),s}Bg(r=>({...r,get:(e,t,n)=>el(e,t)||r.get(e,t,n),has:(e,t)=>!!el(e,t)||r.has(e,t)}));/**
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 */class Gg{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Kg(t)){const n=t.getImmediate();return`${n.library}/${n.version}`}else return null}).filter(t=>t).join(" ")}}function Kg(r){const e=r.getComponent();return(e==null?void 0:e.type)==="VERSION"}const Xo="@firebase/app",tl="0.10.13";/**
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 pt=new Ms("@firebase/app"),Wg="@firebase/app-compat",Hg="@firebase/analytics-compat",Qg="@firebase/analytics",Jg="@firebase/app-check-compat",Yg="@firebase/app-check",Xg="@firebase/auth",Zg="@firebase/auth-compat",e_="@firebase/database",t_="@firebase/data-connect",n_="@firebase/database-compat",r_="@firebase/functions",i_="@firebase/functions-compat",s_="@firebase/installations",o_="@firebase/installations-compat",a_="@firebase/messaging",c_="@firebase/messaging-compat",u_="@firebase/performance",l_="@firebase/performance-compat",h_="@firebase/remote-config",d_="@firebase/remote-config-compat",f_="@firebase/storage",p_="@firebase/storage-compat",m_="@firebase/firestore",g_="@firebase/vertexai-preview",__="@firebase/firestore-compat",y_="firebase",I_="10.14.1";/**
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 Zo="[DEFAULT]",T_={[Xo]:"fire-core",[Wg]:"fire-core-compat",[Qg]:"fire-analytics",[Hg]:"fire-analytics-compat",[Yg]:"fire-app-check",[Jg]:"fire-app-check-compat",[Xg]:"fire-auth",[Zg]:"fire-auth-compat",[e_]:"fire-rtdb",[t_]:"fire-data-connect",[n_]:"fire-rtdb-compat",[r_]:"fire-fn",[i_]:"fire-fn-compat",[s_]:"fire-iid",[o_]:"fire-iid-compat",[a_]:"fire-fcm",[c_]:"fire-fcm-compat",[u_]:"fire-perf",[l_]:"fire-perf-compat",[h_]:"fire-rc",[d_]:"fire-rc-compat",[f_]:"fire-g
256cs",[p_]:"fire-gcs-compat",[m_]:"fire-fst",[__]:"fire-fst-compat",[g_]:"fire-vertex","fire-js":"fire-js",[y_]:"fire-js-all"};/**
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 fs=new Map,E_=new Map,ea=new Map;function nl(r,e){try{r.container.addComponent(e)}catch(t){pt.debug(`Component ${e.name} failed to register with FirebaseApp ${r.name}`,t)}}function Xe(r){const e=r.name;if(ea.has(e))return pt.debug(`There were multiple attempts to register component ${e}.`),!1;ea.set(e,r);for(const t of fs.values())nl(t,r);for(const t of E_.values())nl(t,r);return!0}function Ut(r,e){const t=r.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),r.container.getProvider(e)}function ze(r){return r.settings!==void 0}/**
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 */const v_={"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.","invali
286d-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."},Nt=new vn("app","Firebase",v_);/**
287 * @license
288 * Copyright 2019 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 w_{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new Ke("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}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(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Nt.create("app-deleted",{appName:this._name})}}/**
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 wn=I_;function A_(r,e={}){let t=r;typeof e!="object"&&(e={name:e});const n=Object.assign({name:Zo,automaticDataCollectionEnabled:!1},e),i=n.name;if(typeof i!="string"||!i)throw Nt.create("bad-app-name",{appName:String(i)});if(t||(t=Yh()),!t)throw Nt.create("no-options");const s=fs.get(i);if(s){if(zn(t,s.options)&&zn(n,s.config))return s;throw Nt.create("duplicate-app",{appName:i})}const o=new Dg(i);for(const u of ea.values())o.addComponent(u);const c=new w_(t,n,o);return fs.set(i,c),c}function Na(r=Zo){const e=fs.get(r);if(!e&&r===Zo&&Yh())return A_();if(!e)throw Nt.create("no-app",{appName:r});return e}function Le(r,e,t){var n;let i=(n=T_[r])!==null&&n!==void 0?n:r;t&&(i+=`-${t}`);const s=i.match(/\s|\//),o=e.match(/\s|\//);if(s||o){const c=[`Unable to register library "${i}" with version "${e}":`];s&&c.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&o&&c.push("and"),o&&c.push(`version name "${e}" contains illegal characters (whitespace or "/")`),pt.warn(c.join(" "));return}Xe(new Ke(`${i}-version`,()=>({library:i,version:e}),"VERSION"))}/**
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, softw
326are
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 R_="firebase-heartbeat-database",b_=1,Qr="firebase-heartbeat-store";let Lo=null;function id(){return Lo||(Lo=rd(R_,b_,{upgrade:(r,e)=>{switch(e){case 0:try{r.createObjectStore(Qr)}catch(t){console.warn(t)}}}}).catch(r=>{throw Nt.create("idb-open",{originalErrorMessage:r.message})})),Lo}async function S_(r){try{const t=(await id()).transaction(Qr),n=await t.objectStore(Qr).get(sd(r));return await t.done,n}catch(e){if(e instanceof He)pt.warn(e.message);else{const t=Nt.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});pt.warn(t.message)}}}async function rl(r,e){try{const n=(await id()).transaction(Qr,"readwrite");await n.objectStore(Qr).put(e,sd(r)),await n.done}catch(t){if(t instanceof He)pt.warn(t.message);else{const n=Nt.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});pt.warn(n.message)}}}function sd(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 P_=1024,C_=30*24*60*60*1e3;class D_{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new k_(t),this._heartbeatsCachePromise=this._storage.read().then(n=>(this._heartbeatsCache=n,n))}async triggerHeartbeat(){var e,t;try{const i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=il();return((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===s||this._heartbeatsCache.heartbeats.some(o=>o.date===s)?void 0:(this._heartbeatsCache.heartbeats.push({date:s,agent:i}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(o=>{const c=new Date(o.date).valueOf();return Date.now()-c<=C_}),this._storage.overwrite(this._heartbeatsCache))}catch(n){pt.warn(n)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=il(),{heartbeatsToSend:n,unsentEntries:i}=V_(this._heartbeatsCache.heartbeats),s=ds(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(t){return pt.warn(t),""}}}function il(){return new Date().toISOString().substring(0,10)}function V_(r,e=P_){const t=[];let n=r.slice();for(const i of r){const s=t.find(o=>o.agent===i.agent);if(s){if(s.dates.push(i.date),sl(t)>e){s.dates.pop();break}}else if(t.push({agent:i.agent,dates:[i.date]}),sl(t)>e){t.pop();break}n=n.slice(1)}return{heartbeatsToSend:t,unsentEntries:n}}class k_{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Os()?Va().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await S_(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const i=await this.read();return rl(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:i.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const i=await this.read();return rl(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...e.heartbeats]})}else return}}function sl(r){return ds(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 N_(r){Xe(new Ke("platform-logger",e=>new Gg(e),"PRIVATE")),Xe(new Ke("heartbeat",e=>new D_(e),"PRIVATE")),Le(Xo,tl,r),Le(Xo,tl,"esm2017"),Le("fire-js","")}N_("");var ta=function(r,e){return ta=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},ta(r,e)};function TR(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ta(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var ol=function(){return ol=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},ol.apply(this,arguments)};function xa(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function ER(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))}function od(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const x_=od,ad=new vn("auth","Firebase",od());/**
362 * @license
363 * Copyright 2020 Google LLC
364 *
365 * Licensed under the Apache License, Version 2.0 (the "License");
366 * you may not use this file except in compliance with the License.
367 * You may obtain a copy of the License at
368 *
369 *   http://www.apache.org/licenses/LICENSE-2.0
370 *
371 * Unless required by applicable law or agreed to in writing, software
372 * distributed under the License is distributed on an "AS IS" BASIS,
373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374 * See the License for the specific language governing permissions and
375 * limitations under the License.
376 */const ps=new Ms("@firebase/auth");function O_(r,...e){ps.logLevel<=H.WARN&&ps.warn(`Auth (${wn}): ${r}`,...e)}function Zi(r,...e){ps.logLevel<=H.ERROR&&ps.error(`Auth (${wn}): ${r}`,...e)}/**
377 * @license
378 * Copyright 2020 Google LLC
379 *
380 * Licensed under the Apache License, Version 2.0 (the "License");
381 * you may not use this file except in compliance with the License.
382 * You may obtain a copy of the License at
383 *
384 *   http://www.apache.org/licenses/LICENSE-2.0
385 *
386 * Unless required by applicable law or agreed to in writing, software
387 * distributed under the License is distributed on an "AS IS" BASIS,
388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
389 * See the License for the specific language governing permissions and
390 * limitations under the License.
391 */function We(r,...e){throw Ma(r,...e)}function Je(r,...e){return Ma(r,...e)}function Oa(r,e,t){const n=Object.assign(Object.assign({},x_()),{[e]:t});return new vn("auth","Firebase",n).create(e,{appName:r.name})}function nt(r){return Oa(r,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function cd(r,e,t){const n=t;if(!(e instanceof n))throw n.name!==e.constructor.name&&We(r,"argument-error"),Oa(r,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function Ma(r,...e){if(typeof r!="string"){const t=e[0],n=[...e.slice(1)];return n[0]&&(n[0].appName=r.name),r._errorFactory.create(t,...n)}return ad.create(r,...e)}function j(r,e,...t){if(!r)throw Ma(e,...t)}function ut(r){const e="INTERNAL ASSERTION FAILED: "+r;throw Zi(e),new Error(e)}function mt(r,e){r||ut(e)}/**
392 * @license
393 * Copyright 2020 Google LLC
394 *
395 * Licensed under the Apache License, Version 2.0 (the "License");
396 * you may not use this file except in compliance with the License.
397 * You may obtain a copy of the License at
398 *
399 *   http://www.apache.org/licenses/LICENSE-2.0
400 *
401 * Unless required by applicable law or agreed to in writing, software
402 * distributed under the License is distributed on an "AS IS" BASIS,
403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404 * See the License for the specific language governing permissions and
405 * limitations under the License.
406 */function na(){var r;return typeof self<"u"&&((r=self.location)===null||r===void 0?void 0:r.href)||""}function M_(){return al()==="http:"||al()==="https:"}function al(){var r;return typeof self<"u"&&((r=self.location)===null||r===void 0?void 0:r.protocol)||null}/**
407 * @license
408 * Copyright 2020 Google LLC
409 *
410 * Licensed under the Apache License, Version 2.0 (the "License");
411 * you may not use this file except in compliance with the License.
412 * You may obtain a copy of the License at
413 *
414 *   http://www.apache.org/licenses/LICENSE-2.0
415 *
416 * Unless required by applicable law or agreed to in writing, software
417 * distributed under the License is distributed on an "AS IS" BASIS,
418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419 * See the License for the specific language governing permissions and
420 * limitations under the License.
421 */function L_(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(M_()||Da()||"connection"in navigator)?navigator.onLine:!0}function F_(){if(typeof navigator>"u")return null;const r=navigator;return r.languages&&r.languages[0]||r.language||null}/**
422 * @license
423 * Copyright 2020 Google LLC
424 *
425 * Licensed under the Apache License, Version 2.0 (the "License");
426 * you may not use this file except in compliance with the License.
427 * You may obtain a copy of the License at
428 *
429 *   http://www.apache.org/licenses/LICENSE-2.0
430 *
431 * Unless required by applicable law or agreed to in writing, software
432 * distributed under the License is distributed on an "AS IS" BASIS,
433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
434 * See the License for the specific language governing permissions and
435 * limitations under the License.
436 */class hi{constructor(e,t){this.shortDelay=e,this.longDelay=t,mt(t>e,"Short delay should be less than long delay!"),this.isMobile=hg()||pg()}get(){return L_()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
437 * @license
438 * Copyright 2020 Google LLC
439 *
440 * Licensed under the Apache License, Version 2.0 (the "License");
441 * you may not use this file except in compliance with the License.
442 * You may obtain a copy of the License at
443 *
444 *   http://www.apache.org/licenses/LICENSE-2.0
445 *
446 * Unless required by applicable law or agreed to in writing, software
447 * distributed under the License is distributed on an "AS IS" BASIS,
448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
449 * See the License for the specific language governing permissions and
450 * limitations under the License.
451 */function La(r,e){mt(r.emulator,"Emulator should always be set here");const{url:t}=r.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/**
452 * @license
453 * Copyright 2020 Google LLC
454 *
455 * Licensed under the Apache License, Version 2.0 (the "License");
456 * you may not use this file except in compliance with the License.
457 * You may obtain a copy of the License at
458 *
459 *   http://www.apache.org/licenses/LICENSE-2.0
460 *
461 * Unless required by applicable law or agreed to in writing, software
462 * distributed under the License is distributed on an "AS IS" BASIS,
463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464 * See the License for the specific language governing permissions and
465 * limitations under the License.
466 */class ud{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;ut("Could not find fetch implementation, make sure you call FetchProvi
466der.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;ut("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;ut("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
467 * @license
468 * Copyright 2020 Google LLC
469 *
470 * Licensed under the Apache License, Version 2.0 (the "License");
471 * you may not use this file except in compliance with the License.
472 * You may obtain a copy of the License at
473 *
474 *   http://www.apache.org/licenses/LICENSE-2.0
475 *
476 * Unless required by applicable law or agreed to in writing, software
477 * distributed under the License is distributed on an "AS IS" BASIS,
478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
479 * See the License for the specific language governing permissions and
480 * limitations under the License.
481 */const U_={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/**
482 * @license
483 * Copyright 2020 Google LLC
484 *
485 * Licensed under the Apache License, Version 2.0 (the "License");
486 * you may not use this file except in compliance with the License.
487 * You may obtain a copy of the License at
488 *
489 *   http://www.apache.org/licenses/LICENSE-2.0
490 *
491 * Unless required by applicable law or agreed to in writing, software
492 * distributed under the License is distributed on an "AS IS" BASIS,
493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494 * See the License for the specific language governing permissions and
495 * limitations under the License.
496 */const B_=new hi(3e4,6e4);function Bt(r,e){return r.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:r.tenantId}):e}async function _t(r,e,t,n,i={}){return ld(r,i,async()=>{let s={},o={};n&&(e==="GET"?o=n:s={body:JSON.stringify(n)});const c=li(Object.assign({key:r.config.apiKey},o)).slice(1),u=await r._getAdditionalHeaders();u["Content-Type"]="application/json",r.languageCode&&(u["X-Firebase-Locale"]=r.languageCode);const h=Object.assign({method:e,headers:u},s);return fg()||(h.referrerPolicy="no-referrer"),ud.fetch()(hd(r,r.config.apiHost,t,c),h)})}async function ld(r,e,t){r._canInitEmulator=!1;const n=Object.assign(Object.assign({},U_),e);try{const i=new j_(r),s=await Promise.race([t(),i.promise]);i.clearNetworkTimeout();const o=await s.json();if("needConfirmation"in o)throw Gi(r,"account-exists-with-different-credential",o);if(s.ok&&!("errorMessage"in o))return o;{const c=s.ok?o.errorMessage:o.error.message,[u,h]=c.split(" : ");if(u==="FEDERATED_USER_ID_ALREADY_LINKED")throw Gi(r,"credential-already-in-use",o);if(u==="EMAIL_EXISTS")throw Gi(r,"email-already-in-use",o);if(u==="USER_DISABLED")throw Gi(r,"user-disabled",o);const f=n[u]||u.toLowerCase().replace(/[_\s]+/g,"-");if(h)throw Oa(r,f,h);We(r,f)}}catch(i){if(i instanceof He)throw i;We(r,"network-request-failed",{message:String(i)})}}async function di(r,e,t,n,i={}){const s=await _t(r,e,t,n,i);return"mfaPendingCredential"in s&&We(r,"multi-factor-auth-required",{_serverResponse:s}),s}function hd(r,e,t,n){const i=`${e}${t}?${n}`;return r.config.emulator?La(r.config,i):`${r.config.apiScheme}://${i}`}function q_(r){switch(r){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class j_{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,n)=>{this.timer=setTimeout(()=>n(Je(this.auth,"network-request-failed")),B_.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function Gi(r,e,t){const n={appName:r.name};t.email&&(n.email=t.email),t.phoneNumber&&(n.phoneNumber=t.phoneNumber);const i=Je(r,e,n);return i.customData._tokenResponse=t,i}function cl(r){return r!==void 0&&r.enterprise!==void 0}class $_{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return q_(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}}async function z_(r,e){return _t(r,"GET","/v2/recaptchaConfig",Bt(r,e))}/**
497 * @license
498 * Copyright 2020 Google LLC
499 *
500 * Licensed under the Apache License, Version 2.0 (the "License");
501 * you may not use this file except in compliance with the License.
502 * You may obtain a copy of the License at
503 *
504 *   http://www.apache.org/licenses/LICENSE-2.0
505 *
506 * Unless required by applicable law or agreed to in writing, software
507 * distributed under the License is distributed on an "AS IS" BASIS,
508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509 * See the License for the specific language governing permissions and
510 * limitations under the License.
511 */async function G_(r,e){return _t(r,"POST","/v1/accounts:delete",e)}async function dd(r,e){return _t(r,"POST","/v1/accounts:lookup",e)}/**
512 * @license
513 * Copyright 2020 Google LLC
514 *
515 * Licensed under the Apache License, Version 2.0 (the "License");
516 * you may not use this file except in compliance with the License.
517 * You may obtain a copy of the License at
518 *
519 *   http://www.apache.org/licenses/LICENSE-2.0
520 *
521 * Unless required by applicable law or agreed to in writing, software
522 * distributed under the License is distributed on an "AS IS" BASIS,
523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524 * See the License for the specific language governing permissions and
525 * limitations under the License.
526 */function qr(r){if(r)try{const e=new Date(Number(r));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function K_(r,e=!1){const t=re(r),n=await t.getIdToken(e),i=Fa(n);j(i&&i.exp&&i.auth_time&&i.iat,t.auth,"internal-error");const s=typeof i.firebase=="object"?i.firebase:void 0,o=s==null?void 0:s.sign_in_provider;return{claims:i,token:n,authTime:qr(Fo(i.auth_time)),issuedAtTime:qr(Fo(i.iat)),expirationTime:qr(Fo(i.exp)),signInProvider:o||null,signInSecondFactor:(s==null?void 0:s.sign_in_second_factor)||null}}function Fo(r){return Number(r)*1e3}function Fa(r){const[e,t,n]=r.split(".");if(e===void 0||t===void 0||n===void 0)return Zi("JWT malformed, contained fewer than 3 sections"),null;try{const i=Qh(t);return i?JSON.parse(i):(Zi("Failed to decode base64 JWT payload"),null)}catch(i){return Zi("Caught error parsing JWT payload as JSON",i==null?void 0:i.toString()),null}}function ul(r){const e=Fa(r);return j(e,"internal-error"),j(typeof e.exp<"u","internal-error"),j(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
527 * @license
528 * Copyright 2020 Google LLC
529 *
530 * Licensed under the Apache License, Version 2.0 (the "License");
531 * you may not use this file except in compliance with the License.
532 * You may obtain a copy of the License at
533 *
534 *   http://www.apache.org/licenses/LICENSE-2.0
535 *
536 * Unless required by applicable law or agreed to in writing, software
537 * distributed under the License is distributed on an "AS IS" BASIS,
538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539 * See the License for the specific language governing permissions and
540 * limitations under the License.
541 */async function Gn(r,e,t=!1){if(t)return e;try{return await e}catch(n){throw n instanceof He&&W_(n)&&r.auth.currentUser===r&&await r.auth.signOut(),n}}function W_({code:r}){return r==="auth/user-disabled"||r==="auth/user-token-expired"}/**
542 * @license
543 * Copyright 2020 Google LLC
544 *
545 * Licensed under the Apache License, Version 2.0 (the "License");
546 * you may not use this file except in compliance with the License.
547 * You may obtain a copy of the License at
548 *
549 *   http://www.apache.org/licenses/LICENSE-2.0
550 *
551 * Unless required by applicable law or agreed to in writing, software
552 * distributed under the License is distributed on an "AS IS" BASIS,
553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
554 * See the License for the specific language governing permissions and
555 * limitations under the License.
556 */class H_{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const n=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),n}else{this.errorBackoff=3e4;const i=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,i)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/**
557 * @license
558 * Copyright 2020 Google LLC
559 *
560 * Licensed under the Apache License, Version 2.0 (the "License");
561 * you may not use this file except in compliance with the License.
562 * You may obtain a copy of the License at
563 *
564 *   http://www.apache.org/licenses/LICENSE-2.0
565 *
566 * Unless required by applicable law or agreed to in writing, software
567 * distributed under the License is distributed on an "AS IS" BASIS,
568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
569 * See the License for the specific language governing permissions and
570 * limitations under the License.
571 */class ra{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=qr(this.lastLoginAt),this.creationTime=qr(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
572 * @license
573 * Copyright 2019 Google LLC
574 *
575 * Licensed under the Apache License, Version 2.0 (the "License");
576 * you may not use this file except in compliance with the License.
577 * You may obtain a copy of the License at
578 *
579 *   http://www.apache.org/licenses/LICENSE-2.0
580 *
581 * Unless required by applicable law or agreed to in writing, software
582 * distributed under the License is distributed on an "AS IS" BASIS,
583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
584 * See the License for the specific language governing permissions and
585 * limitations under the License.
586 */async function ms(r){var e;const t=r.auth,n=await r.getIdToken(),i=await Gn(r,dd(t,{idToken:n}));j(i==null?void 0:i.users.length,t,"internal-error");const s=i.users[0];r._notifyReloadListener(s);const o=!((e=s.providerUserInfo)===null||e===void 0)&&e.length?fd(s.providerUserInfo):[],c=J_(r.providerData,o),u=r.isAnonymous,h=!(r.email&&s.passwordHash)&&!(c!=null&&c.length),f=u?h:!1,m={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:c,metadata:new ra(s.createdAt,s.lastLoginAt),isAnonymous:f};Object.assign(r,m)}async function Q_(r){const e=re(r);await ms(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function J_(r,e){return[...r.filter(n=>!e.some(i=>i.providerId===n.providerId)),...e]}function fd(r){return r.map(e=>{var{providerId:t}=e,n=xa(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})}/**
587 * @license
588 * Copyright 2020 Google LLC
589 *
590 * Licensed under the Apache License, Version 2.0 (the "License");
591 * you may not use this file except in compliance with the License.
592 * You may obtain a copy of the License at
593 *
594 *   http://www.apache.org/licenses/LICENSE-2.0
595 *
596 * Unless required by applicable law or agreed to in writing, software
597 * distributed under the License is distributed on an "AS IS" BASIS,
598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599 * See the License for the specific language governing permissions and
600 * limitations under the License.
601 */async function Y_(r,e){const t=await ld(r,{},async()=>{const n=li({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:s}=r.config,o=hd(r,i,"/v1/token",`key=${s}`),c=await r._getAdditionalHeaders();return c["Content-Type"]="application/x-www-form-urlencoded",ud.fetch()(o,{method:"POST",headers:c,body:n})});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function X_(r,e){return _t(r,"POST","/v2/accounts:revokeToken",Bt(r,e))}/**
602 * @license
603 * Copyright 2020 Google LLC
604 *
605 * Licensed under the Apache License, Version 2.0 (the "License");
606 * you may not use this file except in compliance with the License.
607 * You may obtain a copy of the License at
608 *
609 *   http://www.apache.org/licenses/LICENSE-2.0
610 *
611 * Unless required by applicable law or agreed to in writing, software
612 * distributed under the License is distributed on an "AS IS" BASIS,
613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
614 * See the License for the specific language governing permissions and
615 * limitations under the License.
616 */class Bn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){j(e.idToken,"internal-error"),j(typeof e.idToken<"u","internal-error"),j(typeof e.refreshToken<"u","internal-error");
616const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):ul(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){j(e.length!==0,"internal-error");const t=ul(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(j(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:n,refreshToken:i,expiresIn:s}=await Y_(e,t);this.updateTokensAndExpiration(n,i,Number(s))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+n*1e3}static fromJSON(e,t){const{refreshToken:n,accessToken:i,expirationTime:s}=t,o=new Bn;return n&&(j(typeof n=="string","internal-error",{appName:e}),o.refreshToken=n),i&&(j(typeof i=="string","internal-error",{appName:e}),o.accessToken=i),s&&(j(typeof s=="number","internal-error",{appName:e}),o.expirationTime=s),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Bn,this.toJSON())}_performRefresh(){return ut("not implemented")}}/**
617 * @license
618 * Copyright 2020 Google LLC
619 *
620 * Licensed under the Apache License, Version 2.0 (the "License");
621 * you may not use this file except in compliance with the License.
622 * You may obtain a copy of the License at
623 *
624 *   http://www.apache.org/licenses/LICENSE-2.0
625 *
626 * Unless required by applicable law or agreed to in writing, software
627 * distributed under the License is distributed on an "AS IS" BASIS,
628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629 * See the License for the specific language governing permissions and
630 * limitations under the License.
631 */function wt(r,e){j(typeof r=="string"||typeof r>"u","internal-error",{appName:e})}class lt{constructor(e){var{uid:t,auth:n,stsTokenManager:i}=e,s=xa(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new H_(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new ra(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Gn(this,this.stsTokenManager.getToken(this.auth,e));return j(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return K_(this,e)}reload(){return Q_(this)}_assign(e){this!==e&&(j(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new lt(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){j(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await ms(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(ze(this.auth.app))return Promise.reject(nt(this.auth));const e=await this.getIdToken();return await Gn(this,G_(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isA
631nonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n,i,s,o,c,u,h,f;const m=(n=t.displayName)!==null&&n!==void 0?n:void 0,_=(i=t.email)!==null&&i!==void 0?i:void 0,b=(s=t.phoneNumber)!==null&&s!==void 0?s:void 0,V=(o=t.photoURL)!==null&&o!==void 0?o:void 0,N=(c=t.tenantId)!==null&&c!==void 0?c:void 0,D=(u=t._redirectEventId)!==null&&u!==void 0?u:void 0,z=(h=t.createdAt)!==null&&h!==void 0?h:void 0,q=(f=t.lastLoginAt)!==null&&f!==void 0?f:void 0,{uid:U,emailVerified:$,isAnonymous:J,providerData:K,stsTokenManager:T}=t;j(U&&T,e,"internal-error");const g=Bn.fromJSON(this.name,T);j(typeof U=="string",e,"internal-error"),wt(m,e.name),wt(_,e.name),j(typeof $=="boolean",e,"internal-error"),j(typeof J=="boolean",e,"internal-error"),wt(b,e.name),wt(V,e.name),wt(N,e.name),wt(D,e.name),wt(z,e.name),wt(q,e.name);const I=new lt({uid:U,auth:e,email:_,emailVerified:$,displayName:m,isAnonymous:J,photoURL:V,phoneNumber:b,tenantId:N,stsTokenManager:g,createdAt:z,lastLoginAt:q});return K&&Array.isArray(K)&&(I.providerData=K.map(E=>Object.assign({},E))),D&&(I._redirectEventId=D),I}static async _fromIdTokenResponse(e,t,n=!1){const i=new Bn;i.updateFromServerResponse(t);const s=new lt({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:n});return await ms(s),s}static async _fromGetAccountInfoResponse(e,t,n){const i=t.users[0];j(i.localId!==void 0,"internal-error");const s=i.providerUserInfo!==void 0?fd(i.providerUserInfo):[],o=!(i.email&&i.passwordHash)&&!(s!=null&&s.length),c=new Bn;c.updateFromIdToken(n);const u=new lt({uid:i.localId,auth:e,stsTokenManager:c,isAnonymous:o}),h={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:s,metadata:new ra(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!(s!=null&&s.length)};return Object.assign(u,h),u}}/**
632 * @license
633 * Copyright 2020 Google LLC
634 *
635 * Licensed under the Apache License, Version 2.0 (the "License");
636 * you may not use this file except in compliance with the License.
637 * You may obtain a copy of the License at
638 *
639 *   http://www.apache.org/licenses/LICENSE-2.0
640 *
641 * Unless required by applicable law or agreed to in writing, software
642 * distributed under the License is distributed on an "AS IS" BASIS,
643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
644 * See the License for the specific language governing permissions and
645 * limitations under the License.
646 */const ll=new Map;function ht(r){mt(r instanceof Function,"Expected a class definition");let e=ll.get(r);return e?(mt(e instanceof r,"Instance stored in cache mismatched with class"),e):(e=new r,ll.set(r,e),e)}/**
647 * @license
648 * Copyright 2019 Google LLC
649 *
650 * Licensed under the Apache License, Version 2.0 (the "License");
651 * you may not use this file except in compliance with the License.
652 * You may obtain a copy of the License at
653 *
654 *   http://www.apache.org/licenses/LICENSE-2.0
655 *
656 * Unless required by applicable law or agreed to in writing, software
657 * distributed under the License is distributed on an "AS IS" BASIS,
658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
659 * See the License for the specific language governing permissions and
660 * limitations under the License.
661 */class pd{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}pd.type="NONE";const hl=pd;/**
662 * @license
663 * Copyright 2019 Google LLC
664 *
665 * Licensed under the Apache License, Version 2.0 (the "License");
666 * you may not use this file except in compliance with the License.
667 * You may obtain a copy of the License at
668 *
669 *   http://www.apache.org/licenses/LICENSE-2.0
670 *
671 * Unless required by applicable law or agreed to in writing, software
672 * distributed under the License is distributed on an "AS IS" BASIS,
673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
674 * See the License for the specific language governing permissions and
675 * limitations under the License.
676 */function es(r,e,t){return`firebase:${r}:${e}:${t}`}class qn{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;const{config:i,name:s}=this.auth;this.fullUserKey=es(this.userKey,i.apiKey,s),this.fullPersistenceKey=es("persistence",i.apiKey,s),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?lt._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new qn(ht(hl),e,n);const i=(await Promise.all(t.map(async h=>{if(await h._isAvailable())return h}))).filter(h=>h);let s=i[0]||ht(hl);const o=es(n,e.config.apiKey,e.name);let c=null;for(const h of t)try{const f=await h._get(o);if(f){const m=lt._fromJSON(e,f);h!==s&&(c=m),s=h;break}}catch{}const u=i.filter(h=>h._shouldAllowMigration);return!s._shouldAllowMigration||!u.length?new qn(s,e,n):(s=u[0],c&&await s._set(o,c.toJSON()),await Promise.all(t.map(async h=>{if(h!==s)try{await h._remove(o)}catch{}})),new qn(s,e,n))}}/**
677 * @license
678 * Copyright 2020 Google LLC
679 *
680 * Licensed under the Apache License, Version 2.0 (the "License");
681 * you may not use this file except in compliance with the License.
682 * You may obtain a copy of the License at
683 *
684 *   http://www.apache.org/licenses/LICENSE-2.0
685 *
686 * Unless required by applicable law or agreed to in writing, software
687 * distributed under the License is distributed on an "AS IS" BASIS,
688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
689 * See the License for the specific language governing permissions and
690 * limitations under the License.
691 */function dl(r){const e=r.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(yd(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(md(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Td(e))return"Blackberry";if(Ed(e))return"Webos";if(gd(e))return"Safari";if((e.includes("chrome/")||_d(e))&&!e.includes("edge/"))return"Chrome";if(Id(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=r.match(t);if((n==null?void 0:n.length)===2)return n[1]}return"Other"}function md(r=me()){return/firefox\//i.test(r)}function gd(r=me()){const e=r.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function _d(r=me()){return/crios\//i.test(r)}function yd(r=me()){return/iemobile/i.test(r)}function Id(r=me()){return/android/i.test(r)}function Td(r=me()){return/blackberry/i.test(r)}function Ed(r=me()){return/webos/i.test(r)}function Ua(r=me()){return/iphone|ipad|ipod/i.test(r)||/macintosh/i.test(r)&&/mobile/i.test(r)}function Z_(r=me()){var e;return Ua(r)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function ey(){return mg()&&document.documentMode===10}function vd(r=me()){return Ua(r)||Id(r)||Ed(r)||Td(r)||/windows phone/i.test(r)||yd(r)}/**
692 * @license
693 * Copyright 2020 Google LLC
694 *
695 * Licensed under the Apache License, Version 2.0 (the "License");
696 * you may not use this file except in compliance with the License.
697 * You may obtain a copy of the License at
698 *
699 *   http://www.apache.org/licenses/LICENSE-2.0
700 *
701 * Unless required by applicable law or agreed to in writing, software
702 * distributed under the License is distributed on an "AS IS" BASIS,
703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
704 * See the License for the specific language governing permissions and
705 * limitations under the License.
706 */function wd(r,e=[]){let t;switch(r){case"Browser":t=dl(me());break;case"Worker":t=`${dl(me())}-${r}`;break;default:t=r}const n=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${wn}/${n}`}/**
707 * @license
708 * Copyright 2022 Google LLC
709 *
710 * Licensed under the Apache License, Version 2.0 (the "License");
711 * you may not use this file except in compliance with the License.
712 * You may obtain a copy of the License at
713 *
714 *   http://www.apache.org/licenses/LICENSE-2.0
715 *
716 * Unless required by applicable law or agreed to in writing, software
717 * distributed under the License is distributed on an "AS IS" BASIS,
718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
719 * See the License for the specific language governing permissions and
720 * limitations under the License.
721 */class ty{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const n=s=>new Promise((o,c)=>{try{const u=e(s);o(u)}catch(u){c(u)}});n.onAbort=t,this.queue.push(n);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(n){t.reverse();for(const i of t)try{i()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:n==null?void 0:n.message})}}}/**
722 * @license
723 * Copyright 2023 Google LLC
724 *
725 * Licensed under the Apache License, Version 2.0 (the "License");
726 * you may not use this file except in compliance with the License.
727 * You may obtain a copy of the License at
728 *
729 *   http://www.apache.org/licenses/LICENSE-2.0
730 *
731 * Unless required by applicable law or agreed to in writing, software
732 * distributed under the License is distributed on an "AS IS" BASIS,
733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
734 * See the License for the specific language governing permissions and
735 * limitations under the License.
736 */async function ny(r,e={}){return _t(r,"GET","/v2/passwordPolicy",Bt(r,e))}/**
737 * @license
738 * Copyright 2023 Google LLC
739 *
740 * Licensed under the Apache License, Version 2.0 (the "License");
741 * you may not use this file except in compliance with the License.
742 * You may obtain a copy of the License at
743 *
744 *   http://www.apache.org/licenses/LICENSE-2.0
745 *
746 * Unless required by applicable law or agreed to in writing, software
747 * distributed under the License is distributed on an "AS IS" BASIS,
748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
749 * See the License for the specific language governing permissions and
750 * limitations under the License.
751 */const ry=6;class iy{constructor(e){var t,n,i,s;const o=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(t=o.minPasswordLength)!==null&&t!==void 0?t:ry,o.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=o.maxPasswordLength),o.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=o.containsLowercaseCharacter),o.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=o.containsUppercaseCharacter),o.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=o.containsNumericCharacter),o.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=o.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(i=(n=e.allowedNonAlphanumericCharacters)===null||n===void 0?void 0:n.join(""))!==null&&i!==void 0?i:"",this.forceUpgradeOnSignin=(s=e.forceUpgradeOnSignin)!==null&&s!==void 0?s:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,n,i,s,o,c;const u={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,u),this.validatePasswordCharacterOptions(e,u),u.isValid&&
751(u.isValid=(t=u.meetsMinPasswordLength)!==null&&t!==void 0?t:!0),u.isValid&&(u.isValid=(n=u.meetsMaxPasswordLength)!==null&&n!==void 0?n:!0),u.isValid&&(u.isValid=(i=u.containsLowercaseLetter)!==null&&i!==void 0?i:!0),u.isValid&&(u.isValid=(s=u.containsUppercaseLetter)!==null&&s!==void 0?s:!0),u.isValid&&(u.isValid=(o=u.containsNumericCharacter)!==null&&o!==void 0?o:!0),u.isValid&&(u.isValid=(c=u.containsNonAlphanumericCharacter)!==null&&c!==void 0?c:!0),u}validatePasswordLengthOptions(e,t){const n=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let n;for(let i=0;i<e.length;i++)n=e.charAt(i),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,i,s){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=s))}}/**
752 * @license
753 * Copyright 2020 Google LLC
754 *
755 * Licensed under the Apache License, Version 2.0 (the "License");
756 * you may not use this file except in compliance with the License.
757 * You may obtain a copy of the License at
758 *
759 *   http://www.apache.org/licenses/LICENSE-2.0
760 *
761 * Unless required by applicable law or agreed to in writing, software
762 * distributed under the License is distributed on an "AS IS" BASIS,
763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
764 * See the License for the specific language governing permissions and
765 * limitations under the License.
766 */class sy{constructor(e,t,n,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new fl(this),this.idTokenSubscription=new fl(this),this.beforeStateQueue=new ty(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=ad,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=i.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=ht(t)),this._initializationPromise=this.queue(async()=>{var n,i;if(!this._deleted&&(this.persistenceManager=await qn.create(this,e),!this._deleted)){if(!((n=this._popupRedirectResolver)===null||n===void 0)&&n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((i=this.currentUser)===null||i===void 0?void 0:i.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await dd(this,{idToken:e}),n=await lt._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(ze(this.app)){const o=this.app.settings.authIdToken;return o?new Promise(c=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(o).then(c,c))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let i=n,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,c=i==null?void 0:i._redirectEventId,u=await this.tryRedirectSignIn(e);(!o||o===c)&&(u!=null&&u.user)&&(i=u.user,s=!0)}if(!i)return this.directlySetCurrentUser(null);
766if(!i._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(i)}catch(o){i=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return j(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await ms(e)}catch(t){if((t==null?void 0:t.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=F_()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(ze(this.app))return Promise.reject(nt(this));const t=e?re(e):null;return t&&j(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&j(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return ze(this.app)?Promise.reject(nt(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return ze(this.app)?Promise.reject(nt(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(ht(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await ny(this),t=new iy(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new vn("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),n={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(n.tenantId=this.tenantId),await X_(this,n)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return e===null?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&ht(e)||this._popupRedirectResolver;j(t,this,"argument-error"),this.redirectPersistenceManager=await qn.create(this,[ht(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((n=this.redirectUser)===null||n===void 0?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,i){if(this._deleted)return()=>{};const s=typeof t=="function"?t:t.next.bind(t);let o=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(j(c,this,"internal-error"),c.then(()=>{o||s(this.currentUser)}),typeof t=="function"){const u=e.addObserver(t,n,i);return()=>{o=!0,u()}}else{const u=e.addObserver(t);return()=>{o=!0,u()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return j(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=wd(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);const i=await this._getAppCheckToken();return i&&(t["X-Firebase-AppCheck"]=i),t}async _getAppCheckToken(){var e;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t!=null&&t.error&&O_(`Error while retrieving App Check token: ${t.error}`),t==null?void 0:t.token}}function st(r){return re(r)}class fl{constructor(e){this.auth=e,this.observer=null,this.addObserver=Tg(t=>this.observer=t)}get next(){return j(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
767 * @license
768 * Copyright 2020 Google LLC
769 *
770 * Licensed under the Apache License, Version 2.0 (the "License");
771 * you may not use this file except in compliance with the License.
772 * You may obtain a copy of the License at
773 *
774 *   http://www.apache.org/licenses/LICENSE-2.0
775 *
776 * Unless required by applicable law or agreed to in writing, software
777 * distributed under the License is distributed on an "AS IS" BASIS,
778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
779 * See the License for the specific language governing permissions and
780 * limitations under the License.
781 */let Ls={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function oy(r){Ls=r}function Ad(r){return Ls.loadJS(r)}function ay(){return Ls.recaptchaEnterpriseScript}function cy(){return Ls.gapiScript}function uy(r){return`__${r}${Math.floor(Math.random()*1e6)}`}const ly="recaptcha-enterprise",hy="NO_RECAPTCHA";class dy{constructor(e){this.type=ly,this.auth=st(e)}async verify(e="verify",t=!1){async function n(s){if(!t){if(s.tenantId==null&&s._agentRecaptchaConfig!=null)return s._agentRecaptchaConfig.siteKey;if(s.tenantId!=null&&s._tenantRecaptchaConfigs[s.tenantId]!==void 0)return s._tenantRecaptchaConfigs[s.tenantId].siteKey}return new Promise(async(o,c)=>{z_(s,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(u=>{if(u.recaptchaKey===void 0)c(new Error("recaptcha Enterprise site key undefined"));else{const h=new $_(u);return s.tenantId==null?s._agentRecaptchaConfig=h:s._tenantRecaptchaConfigs[s.tenantId]=h,o(h.siteKey)}}).catch(u=>{c(u)})})}function i(s,o,c){const u=window.grecaptcha;cl(u)?u.enterprise.ready(()=>{u.enterprise.execute(s,{action:e}).then(h=>{o(h)}).catch(()=>{o(hy)})}):c(Error("No reCAPTCHA enterprise script loaded."))}return new Promise((s,o)=>{n(this.auth).then(c=>{if(!t&&cl(window.grecaptcha))i(c,s,o);else{if(typeof window>"u"){o(new Error("RecaptchaVerifier is only supported in browser"));return}let u=ay();u.length!==0&&(u+=c),Ad(u).then(()=>{i(c,s,o)}).catch(h=>{o(h)})}}).catch(c=>{o(c)})})}}async function pl(r,e,t,n=!1){const i=new dy(r);let s;try{s=await i.verify(t)}catch{s=await i.verify(t,!0)}const o=Object.assign({},e);return n?Object.assign(o,{captchaResp:s}):Object.assign(o,{captchaResponse:s}),Object.assign(o,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(o,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),o}async function ia(r,e,t,n){var i;if(!((i=r._getRecaptchaConfig())===null||i===void 0)&&i.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const s=await pl(r,e,t,t==="getOobCode");return n(r,s)}else return n(r,e).catch(async s=>{if(s.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const o=await pl(r,e,t,t==="getOobCode");return n(r,o)}else return Promise.reject(s)})}/**
782 * @license
783 * Copyright 2020 Google LLC
784 *
785 * Licensed under the Apache License, Version 2.0 (the "License");
786 * you may not use this file except in compliance with the License.
787 * You may obtain a copy of the License at
788 *
789 *   http://www.apache.org/licenses/LICENSE-2.0
790 *
791 * Unless required by applicable law or agreed to in writing, software
792 * distributed under the License is distributed on an "AS IS" BASIS,
793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
794 * See the License for the specific language governing permissions and
795 * limitations under the License.
796 */function fy(r,e){const t=Ut(r,"auth");if(t.isInitialized()){const i=t.getImmediate(),s=t.getOptions();if(zn(s,e??{}))return i;We(i,"already-initialized")}return t.initialize({options:e})}function py(r,e){const t=(e==null?void 0:e.persistence)||[],n=(Array.isArray(t)?t:[t]).map(ht);e!=null&&e.errorMap&&r._updateErrorMap(e.errorMap),r._initializeWithPersistence(n,e==null?void 0:e.popupRedirectResolver)}function my(r,e,t){const n=st(r);j(n._canInitEmulator,n,"emulator-config-failed"),j(/^https?:\/\//.test(e),n,"invalid-emulator-scheme");const i=!1,s=Rd(e),{host:o,port:c}=gy(e),u=c===null?"":`:${c}`;n.config.emulator={url:`${s}//${o}${u}/`},n.settings.appVerificationDisabledForTesting=!0,n.emulatorConfig=Object.freeze({host:o,port:c,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})}),_y()}function Rd(r){const e=r.indexOf(":");return e<0?"":r.substr(0,e+1)}function gy(r){const e=Rd(r),t=/(\/\/)?([^?#/]+)/.exec(r.substr(e.length));if(!t)return{host:"",port:null};const n=t[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(n);if(i){const s=i[1];return{host:s,port:ml(n.substr(s.length+1))}}else{const[s,o]=n.split(":");return{host:s,port:ml(o)}}}function ml(r){if(!r)return null;const e=Number(r);return isNaN(e)?null:e}function _y(){function r(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only.  Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",r):r())}/**
797 * @license
798 * Copyright 2020 Google LLC
799 *
800 * Licensed under the Apache License, Version 2.0 (the "License");
801 * you may not use this file except in compliance with the License.
802 * You may obtain a copy of the License at
803 *
804 *   http://www.apache.org/licenses/LICENSE-2.0
805 *
806 * Unless required by applicable law or agreed to in writing, software
807 * distributed under the License is distributed on an "AS IS" BASIS,
808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
809 * See the License for the specific language governing permissions and
810 * limitations under the License.
811 */class Ba{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return ut("not implemented")}_getIdTokenResponse(e){return ut("not implemented")}_linkToIdToken(e,t){return ut("not implemented")}_getReauthenticationResolver(e){return ut("not implemented")}}async function yy(r,e){return _t(r,"POST","/v1/accounts:signUp",e)}/**
812 * @license
813 * Copyright 2020 Google LLC
814 *
815 * Licensed under the Apache License, Version 2.0 (the "License");
816 * you may not use this file except in compliance with the License.
817 * You may obtain a copy of the License at
818 *
819 *   http://www.apache.org/licenses/LICENSE-2.0
820 *
821 * Unless required by applicable law or agreed to in writing, software
822 * distributed under the License is distributed on an "AS IS" BASIS,
823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
824 * See the License for the specific language governing permissions and
825 * limitations under the License.
826 */async function Iy(r,e){return di(r,"POST","/v1/accounts:signInWithPassword",Bt(r,e))}/**
827 * @license
828 * Copyright 2020 Google LLC
829 *
830 * Licensed under the Apache License, Version 2.0 (the "License");
831 * you may not use this file except in compliance with the License.
832 * You may obtain a copy of the License at
833 *
834 *   http://www.apache.org/licenses/LICENSE-2.0
835 *
836 * Unless required by applicable law or agreed to in writing, software
837 * distributed under the License is distributed on an "AS IS" BASIS,
838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
839 * See the License for the specific language governing permissions and
840 * limitations under the License.
841 */async function Ty(r,e){return di(r,"POST","/v1/accounts:signInWithEmailLink",Bt(r,e))}async function Ey(r,e){return di(r,"POST","/v1/accounts:signInWithEmailLink",Bt(r,e))}/**
842 * @license
843 * Copyright 2020 Google LLC
844 *
845 * Licensed under the Apache License, Version 2.0 (the "License");
846 * you may not use this file except in compliance with the License.
847 * You may obtain a copy of the License at
848 *
849 *   http://www.apache.org/licenses/LICENSE-2.0
850 *
851 * Unless required by applicable law or agreed to in writing, software
852 * distributed under the License is distributed on an "AS IS" BASIS,
853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
854 * See the License for the specific language governing permissions and
855 * limitations under the License.
856 */class Jr extends Ba{constructor(e,t,n,i=null){super("password",n),this._email=e,this._password=t,this._tenantId=i}static _fromEmailAndPassword(e,t){return new Jr(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Jr(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t!=null&&t.email&&(t!=null&&t.password)){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return ia(e,t,"signInWithPassword",Iy);case"emailLink":return Ty(e,{email:this._email,oobCode:this._password});default:We(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const n={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return ia(e,n,"signUpPassword",yy);case"emailLink":return Ey(e,{idToken:t,email:this._email,oobCode:this._password});default:We(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/**
857 * @license
858 * Copyright 2020 Google LLC
859 *
860 * Licensed under the Apache License, Version 2.0 (the "License");
861 * you may not use this file except in compliance with the License.
862 * You may obtain a copy of the License at
863 *
864 *   http://www.apache.org/licenses/LICENSE-2.0
865 *
866 * Unless required by applicable law or agreed to in writing, software
867 * distributed under the License is distributed on an "AS IS" BASIS,
868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
869 * See the License for the specific language governing permissions and
870 * limitations under the License.
871 */async function jn(r,e){return di(r,"POST","/v1/accounts:signInWithIdp",Bt(r,e))}/**
872 * @license
873 * Copyright 2020 Google LLC
874 *
875 * Licensed under the Apache License, Version 2.0 (the "License");
876 * you may not use this file except in compliance with the License.
877 * You may obtain a copy of the License at
878 *
879 *   http://www.apache.org/licenses/LICENSE-2.0
880 *
881 * Unless required by applicable law or agreed to in writing, software
882 * distributed under the License is distributed on an "AS IS" BASIS,
883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
884 * See the License for the specific language governing permissions and
885 * limitations under the License.
886 */const vy="http://localhost";class un extends Ba{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new un(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):We("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
886once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:n,signInMethod:i}=t,s=xa(t,["providerId","signInMethod"]);if(!n||!i)return null;const o=new un(n,i);return o.idToken=s.idToken||void 0,o.accessToken=s.accessToken||void 0,o.secret=s.secret,o.nonce=s.nonce,o.pendingToken=s.pendingToken||null,o}_getIdTokenResponse(e){const t=this.buildRequest();return jn(e,t)}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,jn(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,jn(e,t)}buildRequest(){const e={requestUri:vy,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=li(t)}return e}}/**
887 * @license
888 * Copyright 2020 Google LLC
889 *
890 * Licensed under the Apache License, Version 2.0 (the "License");
891 * you may not use this file except in compliance with the License.
892 * You may obtain a copy of the License at
893 *
894 *   http://www.apache.org/licenses/LICENSE-2.0
895 *
896 * Unless required by applicable law or agreed to in writing, software
897 * distributed under the License is distributed on an "AS IS" BASIS,
898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
899 * See the License for the specific language governing permissions and
900 * limitations under the License.
901 */function wy(r){switch(r){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function Ay(r){const e=Or(Mr(r)).link,t=e?Or(Mr(e)).deep_link_id:null,n=Or(Mr(r)).deep_link_id;return(n?Or(Mr(n)).link:null)||n||t||e||r}class qa{constructor(e){var t,n,i,s,o,c;const u=Or(Mr(e)),h=(t=u.apiKey)!==null&&t!==void 0?t:null,f=(n=u.oobCode)!==null&&n!==void 0?n:null,m=wy((i=u.mode)!==null&&i!==void 0?i:null);j(h&&f&&m,"argument-error"),this.apiKey=h,this.operation=m,this.code=f,this.continueUrl=(s=u.continueUrl)!==null&&s!==void 0?s:null,this.languageCode=(o=u.languageCode)!==null&&o!==void 0?o:null,this.tenantId=(c=u.tenantId)!==null&&c!==void 0?c:null}static parseLink(e){const t=Ay(e);try{return new qa(t)}catch{return null}}}/**
902 * @license
903 * Copyright 2020 Google LLC
904 *
905 * Licensed under the Apache License, Version 2.0 (the "License");
906 * you may not use this file except in compliance with the License.
907 * You may obtain a copy of the License at
908 *
909 *   http://www.apache.org/licenses/LICENSE-2.0
910 *
911 * Unless required by applicable law or agreed to in writing, software
912 * distributed under the License is distributed on an "AS IS" BASIS,
913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
914 * See the License for the specific language governing permissions and
915 * limitations under the License.
916 */class sr{constructor(){this.providerId=sr.PROVIDER_ID}static credential(e,t){return Jr._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const n=qa.parseLink(t);return j(n,"argument-error"),Jr._fromEmailAndCode(e,n.code,n.tenantId)}}sr.PROVIDER_ID="password";sr.EMAIL_PASSWORD_SIGN_IN_METHOD="password";sr.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/**
917 * @license
918 * Copyright 2020 Google LLC
919 *
920 * Licensed under the Apache License, Version 2.0 (the "License");
921 * you may not use this file except in compliance with the License.
922 * You may obtain a copy of the License at
923 *
924 *   http://www.apache.org/licenses/LICENSE-2.0
925 *
926 * Unless required by applicable law or agreed to in writing, software
927 * distributed under the License is distributed on an "AS IS" BASIS,
928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
929 * See the License for the specific language governing permissions and
930 * limitations under the License.
931 */class Fs{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/**
932 * @license
933 * Copyright 2019 Google LLC
934 *
935 * Licensed under the Apache License, Version 2.0 (the "License");
936 * you may not use this file except in compliance with the License.
937 * You may obtain a copy of the License at
938 *
939 *   http://www.apache.org/licenses/LICENSE-2.0
940 *
941 * Unless required by applicable law or agreed to in writing, software
942 * distributed under the License is distributed on an "AS IS" BASIS,
943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
944 * See the License for the specific language governing permissions and
945 * limitations under the License.
946 */class fi extends Fs{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
947 * @license
948 * Copyright 2020 Google LLC
949 *
950 * Licensed under the Apache License, Version 2.0 (the "License");
951 * you may not use this file except in compliance with the License.
952 * You may obtain a copy of the License at
953 *
954 *   http://www.apache.org/licenses/LICENSE-2.0
955 *
956 * Unless required by applicable law or agreed to in writing, software
957 * distributed under the License is distributed on an "AS IS" BASIS,
958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
959 * See the License for the specific language governing permissions and
960 * limitations under the License.
961 */class bt extends fi{constructor(){super("facebook.com")}static credential(e){return un._fromParams({providerId:bt.PROVIDER_ID,signInMethod:bt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return bt.credentialFromTaggedObject(e)}static credentialFromError(e){return bt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return bt.credential(e.oauthAccessToken)}catch{return null}}}bt.FACEBOOK_SIGN_IN_METHOD="facebook.com";bt.PROVIDER_ID="facebook.com";/**
962 * @license
963 * Copyright 2020 Google LLC
964 *
965 * Licensed under the Apache License, Version 2.0 (the "License");
966 * you may not use this file except in compliance with the License.
967 * You may obtain a copy of the License at
968 *
969 *   http://www.apache.org/licenses/LICENSE-2.0
970 *
971 * Unless required by applicable law or agreed to in writing, software
972 * distributed under the License is distributed on an "AS IS" BASIS,
973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
974 * See the License for the specific language governing permissions and
975 * limitations under the License.
976 */class St extends fi{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return un._fromParams({providerId:St.PROVIDER_ID,signInMethod:St.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return St.credentialFromTaggedObject(e)}static credentialFromError(e){return St.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return St.credential(t,n)}catch{return null}}}St.GOOGLE_SIGN_IN_METHOD="google.com";St.PROVIDER_ID="google.com";/**
977 * @license
978 * Copyright 2020 Google LLC
979 *
980 * Licensed under the Apache License, Version 2.0 (the "License");
981 * you may not use this file except in compliance with the License.
982 * You may obtain a copy of the License at
983 *
984 *   http://www.apache.org/licenses/LICENSE-2.0
985 *
986 * Unless required by applicable law or agreed to in writing, software
987 * distributed under the License is distributed on an "AS IS" BASIS,
988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989 * See the License for the specific language governing permissions and
990 * limitations under the License.
991 */class Pt extends fi{constructor(){super("github.com")}static credential(e){return un._fromParams({providerId:Pt.PROVIDER_ID,signInMethod:Pt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Pt.credentialFromTaggedObject(e)}static credentialFromError(e){return Pt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Pt.credential(e.oauthAccessToken)}catch{return null}}}Pt.GITHUB_SIGN_IN_METHOD="github.com";Pt.PROVIDER_ID="github.com";/**
992 * @license
993 * Copyright 2020 Google LLC
994 *
995 * Licensed under the Apache License, Version 2.0 (the "License");
996 * you may not use this file except in compliance with the License.
997 * You may obtain a copy of the License at
998 *
999 *   http://www.apache.org/licenses/LICENSE-2.0
1000 *
1001 * Unless required by applicable law or agreed to in writing, software
1002 * distributed under the License is distributed on an "AS IS" BASIS,
1003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1004 * See the License for the specific language governing permissions and
1005 * limitations under the License.
1006 */class Ct extends fi{constructor(){super("twitter.com")}static credential(e,t){return un._fromParams({providerId:Ct.PROVIDER_ID,signInMethod:Ct.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Ct.credentialFromTaggedObject(e)}static credentialFromError(e){return Ct.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return Ct.credential(t,n)}catch{return null}}}Ct.TWITTER_SIGN_IN_METHOD="twitter.com";Ct.PROVIDER_ID="twitter.com";/**
1007 * @license
1008 * Copyright 2020 Google LLC
1009 *
1010 * Licensed under the Apache License, Version 2.0 (the "License");
1011 * you may not use this file except in compliance with the License.
1012 * You may obtain a copy of the License at
1013 *
1014 *   http://www.apache.org/licenses/LICENSE-2.0
1015 *
1016 * Unless required by applicable law or agreed to in writing, software
1017 * distributed under the License is distributed on an "AS IS" BASIS,
1018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1019 * See the License for the specific language governing permissions and
1020 * limitations under the License.
1021 */async function Ry(r,e){return di(r,"POST","/v1/accounts:signUp",Bt(r,e))}/**
1022 * @license
1023 * Copyright 2020 Google LLC
1024 *
1025 * Licensed under the Apache License, Version 2.0 (the "License");
1026 * you may not use this file except in compliance with the License.
1027 * You may obtain a copy of the License at
1028 *
1029 *   http://www.apache.org/licenses/LICENSE-2.0
1030 *
1031 * Unless required by applicable law or agreed to in writing, software
1032 * distributed under the License is distributed on an "AS IS" BASIS,
1033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1034 * See the License for the specific language governing permissions and
1035 * limitations under the License.
1036 */class ln{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,i=!1){const s=await lt._fromIdTokenResponse(e,n,i),o=gl(n);return new ln({user:s,providerId:o,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const i=gl(n);return new ln({user:e,providerId:i,_tokenResponse:n,operationType:t})}}function gl(r){return r.providerId?r.providerId:"phoneNumber"in r?"phone":null}/**
1037 * @license
1038 * Copyright 2020 Google LLC
1039 *
1040 * Licensed under the Apache License, Version 2.0 (the "License");
1041 * you may not use this file except in compliance with the License.
1042 * You may obtain a copy of the License at
1043 *
1044 *   http://www.apache.org/licenses/LICENSE-2.0
1045 *
1046 * Unless required by applicable law or agreed to in writing, software
1047 * distributed under the License is distributed on an "AS IS" BASIS,
1048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1049 * See the License for the specific language governing permissions and
1050 * limitations under the License.
1051 */class gs extends He{constructor(e,t,n,i){var s;super(t.code,t.message),this.operationType=n,this.user=i,Object.setPrototypeOf(this,gs.prototype),this.customData={appName:e.name,tenantId:(s=e.tenantId)!==null&&s!==void 0?s:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,i){return new gs(e,t,n,i)}}function bd(r,e,t,n){return(e==="reauthenticate"?t._getReauthenticationResolver(r):t._getIdTokenResponse(r)).catch(s=>{throw s.code==="auth/multi-factor-auth-required"?gs._fromErrorAndOperation(r,s,e,n):s})}async function by(r,e,t=!1){const n=await Gn(r,e._linkToIdToken(r.auth,await r.getIdToken()),t);return ln._forOperation(r,"link",n)}/**
1052 * @license
1053 * Copyright 2019 Google LLC
1054 *
1055 * Licensed under the Apache License, Version 2.0 (the "License");
1056 * you may not use this file except in compliance with the License.
1057 * You may obtain a copy of the License at
1058 *
1059 *   http://www.apache.org/licenses/LICENSE-2.0
1060 *
1061 * Unless required by applicable law or agreed to in writing, software
1062 * distributed under the License is distributed on an "AS IS" BASIS,
1063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1064 * See the License for the specific language governing permissions and
1065 * limitations under the License.
1066 */async function Sy(r,e,t=!1){const{auth:n}=r;if(ze(n.app))return Promise.reject(nt(n));const i="reauthenticate";try{const s=await Gn(r,bd(n,i,e,r),t);j(s.idToken,n,"internal-error");const o=Fa(s.idToken);j(o,n,"internal-error");const{sub:c}=o;return j(r.uid===c,n,"user-mismatch"),ln._forOperation(r,i,s)}catch(s){throw(s==null?void 0:s.code)==="auth/user-not-found"&&We(n,"user-mismatch"),s}}/**
1067 * @license
1068 * Copyright 2020 Google LLC
1069 *
1070 * Licensed under the Apache License, Version 2.0 (the "License");
1071 * you may not use this file except in compliance with the License.
1072 * You may obtain a copy of the License at
1073 *
1074 *   http://www.apache.org/licenses/LICENSE-2.0
1075 *
1076 * Unless required by applicable law or agreed to in writing, software
1077 * distributed under the License is distributed on an "AS IS" BASIS,
1078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1079 * See the License for the specific language governing permissions and
1080 * limitations under the License.
1081 */async function Sd(r,e,t=!1){if(ze(r.app))return Promise.reject(nt(r));const n="signIn",i=await bd(r,n,e),s=await ln._fromIdTokenResponse(r,n,i);return t||await r._updateCurrentUser(s.user),s}async function Py(r,e){return Sd(st(r),e)}/**
1082 * @license
1083 * Copyright 2020 Google LLC
1084 *
1085 * Licensed under the Apache License, Version 2.0 (the "License");
1086 * you may not use this file except in compliance with the License.
1087 * You may obtain a copy of the License at
1088 *
1089 *   http://www.apache.org/licenses/LICENSE-2.0
1090 *
1091 * Unless required by applicable law or agreed to in writing, software
1092 * distributed under the License is distributed on an "AS IS" BASIS,
1093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1094 * See the License for the specific language governing permissions and
1095 * limitations under the License.
1096 */async function Pd(r){const e=st(r);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function vR(r,e,t){if(ze(r.app))return Promise.reject(nt(r));const n=st(r),o=await ia(n,{returnSecureToken:!0,email:e,password:t,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",Ry).catch(u=>{throw u.code==="auth/password-does-not-meet-requirements"&&Pd(r),u}),c=await ln._fromIdTokenResponse(n,"signIn",o);return await n._updateCurrentUser(c.user),c}function wR(r,e,t){return ze(r.app)?Promise.reject(nt(r)):Py(re(r),sr.credential(e,t)).catch(async n=>{throw n.code==="auth/password-does-not-meet-requirements"&&Pd(r),n})}/**
1097 * @license
1098 * Copyright 2020 Google LLC
1099 *
1100 * Licensed under the Apache License, Version 2.0 (the "License");
1101 * you may not use this file except in compliance with the License.
1102 * You may obtain a copy of the License at
1103 *
1104 *   http://www.apache.org/licenses/LICENSE-2.0
1105 *
1106 * Unless required by applicable law or agreed to in writing, software
1107 * distributed under the License is distributed on an "AS IS" BASIS,
1108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1109 * See the License for the specific language governing permissions and
1110 * limitations under the License.
1111 */async function Cy(r,e){return _t(r,"POST","/v1/accounts:update",e)}/**
1112 * @license
1113 * Copyright 2020 Google LLC
1114 *
1115 * Licensed under the Apache License, Version 2.0 (the "License");
1116 * you may not use this file except in compliance with the License.
1117 * You may obtain a copy of the License at
1118 *
1119 *   http://www.apache.org/licenses/LICENSE-2.0
1120 *
1121 * Unless required by applicable law or agreed to in writing, software
1122 * distributed under the License is distributed on an "AS IS" BASIS,
1123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1124 * See the License for the specific language governing permissions and
1125 * limitations under the License.
1126 */async function AR(r,{displayName:e,photoURL:t}){if(e===void 0&&t===void 0)return;const n=re(r),s={idToken:await n.getIdToken(),displayName:e,photoUrl:t,returnSecureToken:!0},o=await Gn(n,Cy(n.auth,s));n.displayName=o.displayName||null,n.photoURL=o.photoUrl||null;const c=n.providerData.find(({providerId:u})=>u==="password");c&&(c.displayName=n.displayName,c.photoURL=n.photoURL),await n._updateTokensIfNecessary(o)}/**
1127 * @license
1128 * Copyright 2020 Google LLC
1129 *
1130 * Licensed under the Apache License, Version 2.0 (the "License");
1131 * you may not use this file except in compliance with the License.
1132 * You may obtain a copy of the License at
1133 *
1134 *   http://www.apache.org/licenses/LICENSE-2.0
1135 *
1136 * Unless required by applicable law or agreed to in writing, software
1137 * distributed under the License is distributed on an "AS IS" BASIS,
1138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1139 * See the License for the specific language governing permissions and
1140 * limitations under the License.
1141 */function RR(r,e){return re(r).setPersistence(e)}function Dy(r,e,t,n){return re(r).onIdTokenChanged(e,t,n)}function Vy(r,e,t){return re(r).beforeAuthStateChanged(e,t)}function bR(r,e,t,n){return re(r).onAuthStateChanged(e,t,n)}function SR(r){return re(r).signOut()}const _s="__sak";/**
1142 * @license
1143 * Copyright 2019 Google LLC
1144 *
1145 * Licensed under the Apache License, Version 2.0 (the "License");
1146 * you may not use this file except in compliance with the License.
1147 * You may obtain a copy of the License at
1148 *
1149 *   http://www.apache.org/licenses/LICENSE-2.0
1150 *
1151 * Unless required by applicable law or agreed to in writing, software
1152 * distributed under the License is distributed on an "AS IS" BASIS,
1153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1154 * See the License for the specific language governing permissions and
1155 * limitations under the License.
1156 */class Cd{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(_s,"1"),this.storage.removeItem(_s),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/**
1157 * @license
1158 * Copyright 2020 Google LLC
1159 *
1160 * Licensed under the Apache License, Version 2.0 (the "License");
1161 * you may not use this file except in compliance with the License.
1162 * You may obtain a copy of the License at
1163 *
1164 *   http://www.apache.org/licenses/LICENSE-2.0
1165 *
1166 * Unless required by applicable law or agreed to in writing, software
1167 * distributed under the License is distributed on an "AS IS" BASIS,
1168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1169 * See the License for the specific language governing permissions and
1170 * limitations under the License.
1171 */const ky=1e3,Ny=10;class Dd extends Cd{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=vd(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const n=this.storage.getItem(t),i=this.localCache[t];n!==i&&e(t,i,n)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((o,c,u)=>{this.notifyListeners(o,u)});return}const n=e.key;t?this.detachListener():this.stopPolling();const i=()=>{const o=this.storage.getItem(n);!t&&this.localCache[n]===o||this.notifyListeners(n,o)},s=this.storage.getItem(n);ey()&&s!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,Ny):i()}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const i of Array.from(n))i(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},ky)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1171ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Dd.type="LOCAL";const xy=Dd;/**
1172 * @license
1173 * Copyright 2020 Google LLC
1174 *
1175 * Licensed under the Apache License, Version 2.0 (the "License");
1176 * you may not use this file except in compliance with the License.
1177 * You may obtain a copy of the License at
1178 *
1179 *   http://www.apache.org/licenses/LICENSE-2.0
1180 *
1181 * Unless required by applicable law or agreed to in writing, software
1182 * distributed under the License is distributed on an "AS IS" BASIS,
1183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1184 * See the License for the specific language governing permissions and
1185 * limitations under the License.
1186 */class Vd extends Cd{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Vd.type="SESSION";const kd=Vd;/**
1187 * @license
1188 * Copyright 2019 Google LLC
1189 *
1190 * Licensed under the Apache License, Version 2.0 (the "License");
1191 * you may not use this file except in compliance with the License.
1192 * You may obtain a copy of the License at
1193 *
1194 *   http://www.apache.org/licenses/LICENSE-2.0
1195 *
1196 * Unless required by applicable law or agreed to in writing, software
1197 * distributed under the License is distributed on an "AS IS" BASIS,
1198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1199 * See the License for the specific language governing permissions and
1200 * limitations under the License.
1201 */function Oy(r){return Promise.all(r.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/**
1202 * @license
1203 * Copyright 2019 Google LLC
1204 *
1205 * Licensed under the Apache License, Version 2.0 (the "License");
1206 * you may not use this file except in compliance with the License.
1207 * You may obtain a copy of the License at
1208 *
1209 *   http://www.apache.org/licenses/LICENSE-2.0
1210 *
1211 * Unless required by applicable law or agreed to in writing, software
1212 * distributed under the License is distributed on an "AS IS" BASIS,
1213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214 * See the License for the specific language governing permissions and
1215 * limitations under the License.
1216 */class Us{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(i=>i.isListeningto(e));if(t)return t;const n=new Us(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:i,data:s}=t.data,o=this.handlersMap[i];if(!(o!=null&&o.size))return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:i});const c=Array.from(o).map(async h=>h(t.origin,s)),u=await Oy(c);t.ports[0].postMessage({status:"done",eventId:n,eventType:i,response:u})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}Us.receivers=[];/**
1217 * @license
1218 * Copyright 2020 Google LLC
1219 *
1220 * Licensed under the Apache License, Version 2.0 (the "License");
1221 * you may not use this file except in compliance with the License.
1222 * You may obtain a copy of the License at
1223 *
1224 *   http://www.apache.org/licenses/LICENSE-2.0
1225 *
1226 * Unless required by applicable law or agreed to in writing, software
1227 * distributed under the License is distributed on an "AS IS" BASIS,
1228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1229 * See the License for the specific language governing permissions and
1230 * limitations under the License.
1231 */function ja(r="",e=10){let t="";for(let n=0;n<e;n++)t+=Math.floor(Math.random()*10);return r+t}/**
1232 * @license
1233 * Copyright 2019 Google LLC
1234 *
1235 * Licensed under the Apache License, Version 2.0 (the "License");
1236 * you may not use this file except in compliance with the License.
1237 * You may obtain a copy of the License at
1238 *
1239 *   http://www.apache.org/licenses/LICENSE-2.0
1240 *
1241 * Unless required by applicable law or agreed to in writing, software
1242 * distributed under the License is distributed on an "AS IS" BASIS,
1243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1244 * See the License for the specific language governing permissions and
1245 * limitations under the License.
1246 */class My{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,n=50){const i=typeof MessageChannel<"u"?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let s,o;return new Promise((c,u)=>{const h=ja("",20);i.port1.start();const f=setTimeout(()=>{u(new Error("unsupported_event"))},n);o={messageChannel:i,onMessage(m){const _=m;if(_.data.eventId===h)switch(_.data.status){case"ack":clearTimeout(f),s=setTimeout(()=>{u(new Error("timeout"))},3e3);break;case"done":clearTimeout(s),c(_.data.response);break;default:clearTimeout(f),clearTimeout(s),u(new Error("invalid_response"));break}}},this.handlers.add(o),i.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:h,data:t},[i.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}/**
1247 * @license
1248 * Copyright 2020 Google LLC
1249 *
1250 * Licensed under the Apache License, Version 2.0 (the "License");
1251 * you may not use this file except in compliance with the License.
1252 * You may obtain a copy of the License at
1253 *
1254 *   http://www.apache.org/licenses/LICENSE-2.0
1255 *
1256 * Unless required by applicable law or agreed to in writing, software
1257 * distributed under the License is distributed on an "AS IS" BASIS,
1258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1259 * See the License for the specific language governing permissions and
1260 * limitations under the License.
1261 */function rt(){return window}function Ly(r){rt().location.href=r}/**
1262 * @license
1263 * Copyright 2020 Google LLC.
1264 *
1265 * Licensed under the Apache License, Version 2.0 (the "License");
1266 * you may not use this file except in compliance with the License.
1267 * You may obtain a copy of the License at
1268 *
1269 *   http://www.apache.org/licenses/LICENSE-2.0
1270 *
1271 * Unless required by applicable law or agreed to in writing, software
1272 * distributed under the License is distributed on an "AS IS" BASIS,
1273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1274 * See the License for the specific language governing permissions and
1275 * limitations under the License.
1276 */function Nd(){return typeof rt().WorkerGlobalScope<"u"&&typeof rt().importScripts=="function"}async function Fy(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function Uy(){var r;return((r=navigator==null?void 0:navigator.serviceWorker)===null||r===void 0?void 0:r.controller)||null}function By(){return Nd()?self:null}/**
1277 * @license
1278 * Copyright 2019 Google LLC
1279 *
1280 * Licensed under the Apache License, Version 2.0 (the "License");
1281 * you may not use this file except in compliance with the License.
1282 * You may obtain a copy of the License at
1283 *
1284 *   http://www.apache.org/licenses/LICENSE-2.0
1285 *
1286 * Unless required by applicable law or agreed to in writing, software
1287 * distributed under the License is distributed on an "AS IS" BASIS,
1288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1289 * See the License for the specific language governing permissions and
1290 * limitations under the License.
1291 */const xd="firebaseLocalStorageDb",qy=1,ys="firebaseLocalStorage",Od="fbase_key";class pi{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function Bs(r,e){return r.transaction([ys],e?"readwrite":"readonly").objectStore(ys)}function jy(){const r=indexedDB.deleteDatabase(xd);
1291return new pi(r).toPromise()}function sa(){const r=indexedDB.open(xd,qy);return new Promise((e,t)=>{r.addEventListener("error",()=>{t(r.error)}),r.addEventListener("upgradeneeded",()=>{const n=r.result;try{n.createObjectStore(ys,{keyPath:Od})}catch(i){t(i)}}),r.addEventListener("success",async()=>{const n=r.result;n.objectStoreNames.contains(ys)?e(n):(n.close(),await jy(),e(await sa()))})})}async function _l(r,e,t){const n=Bs(r,!0).put({[Od]:e,value:t});return new pi(n).toPromise()}async function $y(r,e){const t=Bs(r,!1).get(e),n=await new pi(t).toPromise();return n===void 0?null:n.value}function yl(r,e){const t=Bs(r,!0).delete(e);return new pi(t).toPromise()}const zy=800,Gy=3;class Md{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await sa(),this.db)}async _withRetries(e){let t=0;for(;;)try{const n=await this._openDb();return await e(n)}catch(n){if(t++>Gy)throw n;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Nd()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Us._getInstance(By()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await Fy(),!this.activeServiceWorker)return;this.sender=new My(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&!((e=n[0])===null||e===void 0)&&e.fulfilled&&!((t=n[0])===null||t===void 0)&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||Uy()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await sa();return await _l(e,_s,"1"),await yl(e,_s),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>_l(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(n=>$y(n,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>yl(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(i=>{const s=Bs(i,!1).getAll();return new pi(s).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],n=new Set;if(e.length!==0)for(const{fbase_key:i,value:s}of e)n.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(s)&&(this.notifyListeners(i,s),t.push(i));for(const i of Object.keys(this.localCache))this.localCache[i]&&!n.has(i)&&(this.notifyListeners(i,null),t.push(i));return t}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const i of Array.from(n))i(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),zy)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
1291ject.keys(this.listeners).length===0&&this.stopPolling()}}Md.type="LOCAL";const Ky=Md;new hi(3e4,6e4);/**
1292 * @license
1293 * Copyright 2021 Google LLC
1294 *
1295 * Licensed under the Apache License, Version 2.0 (the "License");
1296 * you may not use this file except in compliance with the License.
1297 * You may obtain a copy of the License at
1298 *
1299 *   http://www.apache.org/licenses/LICENSE-2.0
1300 *
1301 * Unless required by applicable law or agreed to in writing, software
1302 * distributed under the License is distributed on an "AS IS" BASIS,
1303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304 * See the License for the specific language governing permissions and
1305 * limitations under the License.
1306 */function $a(r,e){return e?ht(e):(j(r._popupRedirectResolver,r,"argument-error"),r._popupRedirectResolver)}/**
1307 * @license
1308 * Copyright 2019 Google LLC
1309 *
1310 * Licensed under the Apache License, Version 2.0 (the "License");
1311 * you may not use this file except in compliance with the License.
1312 * You may obtain a copy of the License at
1313 *
1314 *   http://www.apache.org/licenses/LICENSE-2.0
1315 *
1316 * Unless required by applicable law or agreed to in writing, software
1317 * distributed under the License is distributed on an "AS IS" BASIS,
1318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319 * See the License for the specific language governing permissions and
1320 * limitations under the License.
1321 */class za extends Ba{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return jn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return jn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return jn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Wy(r){return Sd(r.auth,new za(r),r.bypassAuthState)}function Hy(r){const{auth:e,user:t}=r;return j(t,e,"internal-error"),Sy(t,new za(r),r.bypassAuthState)}async function Qy(r){const{auth:e,user:t}=r;return j(t,e,"internal-error"),by(t,new za(r),r.bypassAuthState)}/**
1322 * @license
1323 * Copyright 2020 Google LLC
1324 *
1325 * Licensed under the Apache License, Version 2.0 (the "License");
1326 * you may not use this file except in compliance with the License.
1327 * You may obtain a copy of the License at
1328 *
1329 *   http://www.apache.org/licenses/LICENSE-2.0
1330 *
1331 * Unless required by applicable law or agreed to in writing, software
1332 * distributed under the License is distributed on an "AS IS" BASIS,
1333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1334 * See the License for the specific language governing permissions and
1335 * limitations under the License.
1336 */class Ld{constructor(e,t,n,i,s=!1){this.auth=e,this.resolver=n,this.user=i,this.bypassAuthState=s,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(n){this.reject(n)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:n,postBody:i,tenantId:s,error:o,type:c}=e;if(o){this.reject(o);return}const u={auth:this.auth,requestUri:t,sessionId:n,tenantId:s||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(u))}catch(h){this.reject(h)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Wy;case"linkViaPopup":case"linkViaRedirect":return Qy;case"reauthViaPopup":case"reauthViaRedirect":return Hy;default:We(this.auth,"internal-error")}}resolve(e){mt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){mt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/**
1337 * @license
1338 * Copyright 2020 Google LLC
1339 *
1340 * Licensed under the Apache License, Version 2.0 (the "License");
1341 * you may not use this file except in compliance with the License.
1342 * You may obtain a copy of the License at
1343 *
1344 *   http://www.apache.org/licenses/LICENSE-2.0
1345 *
1346 * Unless required by applicable law or agreed to in writing, software
1347 * distributed under the License is distributed on an "AS IS" BASIS,
1348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1349 * See the License for the specific language governing permissions and
1350 * limitations under the License.
1351 */const Jy=new hi(2e3,1e4);async function PR(r,e,t){if(ze(r.app))return Promise.reject(Je(r,"operation-not-supported-in-this-environment"));const n=st(r);cd(r,e,Fs);const i=$a(n,t);return new sn(n,"signInViaPopup",e,i).executeNotNull()}class sn extends Ld{constructor(e,t,n,i,s){super(e,t,i,s),this.provider=n,this.authWindow=null,this.pollId=null,sn.currentPopupAction&&sn.currentPopupAction.cancel(),sn.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return j(e,this.auth,"internal-error"),e}async onExecution(){mt(this.filter.length===1,"Popup operations only handle one event");const e=ja();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Je(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(Je(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,sn.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,n;if(!((n=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||n===void 0)&&n.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Je(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,Jy.get())};e()}}sn.currentPopupAction=null;/**
1352 * @license
1353 * Copyright 2020 Google LLC
1354 *
1355 * Licensed under the Apache License, Version 2.0 (the "License");
1356 * you may not use this file except in compliance with the License.
1357 * You may obtain a copy of the License at
1358 *
1359 *   http://www.apache.org/licenses/LICENSE-2.0
1360 *
1361 * Unless required by applicable law or agreed to in writing, software
1362 * distributed under the License is distributed on an "AS IS" BASIS,
1363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1364 * See the License for the specific language governing permissions and
1365 * limitations under the License.
1366 */const Yy="pendingRedirect",ts=new Map;class Xy extends Ld{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=ts.get(this.auth._key());if(!e){try{const n=await Zy(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(n)}catch(t){e=()=>Promise.reject(t)}ts.set(this.auth._key(),e)}return this.bypassAuthState||ts.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function Zy(r,e){const t=Ud(e),n=Fd(r);if(!await n._isAvailable())return!1;const i=await n._get(t)==="true";return await n._remove(t),i}async function eI(r,e){return Fd(r)._set(Ud(e),"true")}function tI(r,e){ts.set(r._key(),e)}function Fd(r){return ht(r._redirectPersistence)}function Ud(r){return es(Yy,r.config.apiKey,r.name)}/**
1367 * @license
1368 * Copyright 2020 Google LLC
1369 *
1370 * Licensed under the Apache License, Version 2.0 (the "License");
1371 * you may not use this file except in compliance with the License.
1372 * You may obtain a copy of the License at
1373 *
1374 *   http://www.apache.org/licenses/LICENSE-2.0
1375 *
1376 * Unless required by applicable law or agreed to in writing, softw
1376are
1377 * distributed under the License is distributed on an "AS IS" BASIS,
1378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1379 * See the License for the specific language governing permissions and
1380 * limitations under the License.
1381 */function CR(r,e,t){return nI(r,e,t)}async function nI(r,e,t){if(ze(r.app))return Promise.reject(nt(r));const n=st(r);cd(r,e,Fs),await n._initializationPromise;const i=$a(n,t);return await eI(i,n),i._openRedirect(n,e,"signInViaRedirect")}async function DR(r,e){return await st(r)._initializationPromise,Bd(r,e,!1)}async function Bd(r,e,t=!1){if(ze(r.app))return Promise.reject(nt(r));const n=st(r),i=$a(n,e),o=await new Xy(n,i,t).execute();return o&&!t&&(delete o.user._redirectEventId,await n._persistUserIfCurrent(o.user),await n._setRedirectUser(null,e)),o}/**
1382 * @license
1383 * Copyright 2020 Google LLC
1384 *
1385 * Licensed under the Apache License, Version 2.0 (the "License");
1386 * you may not use this file except in compliance with the License.
1387 * You may obtain a copy of the License at
1388 *
1389 *   http://www.apache.org/licenses/LICENSE-2.0
1390 *
1391 * Unless required by applicable law or agreed to in writing, software
1392 * distributed under the License is distributed on an "AS IS" BASIS,
1393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1394 * See the License for the specific language governing permissions and
1395 * limitations under the License.
1396 */const rI=10*60*1e3;class iI{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!sI(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!qd(e)){const i=((n=e.error.code)===null||n===void 0?void 0:n.split("auth/")[1])||"internal-error";t.onError(Je(this.auth,i))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const n=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=rI&&this.cachedEventUids.clear(),this.cachedEventUids.has(Il(e))}saveEventToCache(e){this.cachedEventUids.add(Il(e)),this.lastProcessedEventTime=Date.now()}}function Il(r){return[r.type,r.eventId,r.sessionId,r.tenantId].filter(e=>e).join("-")}function qd({type:r,error:e}){return r==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function sI(r){switch(r.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return qd(r);default:return!1}}/**
1397 * @license
1398 * Copyright 2020 Google LLC
1399 *
1400 * Licensed under the Apache License, Version 2.0 (the "License");
1401 * you may not use this file except in compliance with the License.
1402 * You may obtain a copy of the License at
1403 *
1404 *   http://www.apache.org/licenses/LICENSE-2.0
1405 *
1406 * Unless required by applicable law or agreed to in writing, software
1407 * distributed under the License is distributed on an "AS IS" BASIS,
1408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1409 * See the License for the specific language governing permissions and
1410 * limitations under the License.
1411 */async function oI(r,e={}){return _t(r,"GET","/v1/projects",e)}/**
1412 * @license
1413 * Copyright 2020 Google LLC
1414 *
1415 * Licensed under the Apache License, Version 2.0 (the "License");
1416 * you may not use this file except in compliance with the License.
1417 * You may obtain a copy of the License at
1418 *
1419 *   http://www.apache.org/licenses/LICENSE-2.0
1420 *
1421 * Unless required by applicable law or agreed to in writing, softw
1421are
1422 * distributed under the License is distributed on an "AS IS" BASIS,
1423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1424 * See the License for the specific language governing permissions and
1425 * limitations under the License.
1426 */const aI=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,cI=/^https?/;async function uI(r){if(r.config.emulator)return;const{authorizedDomains:e}=await oI(r);for(const t of e)try{if(lI(t))return}catch{}We(r,"unauthorized-domain")}function lI(r){const e=na(),{protocol:t,hostname:n}=new URL(e);if(r.startsWith("chrome-extension://")){const o=new URL(r);return o.hostname===""&&n===""?t==="chrome-extension:"&&r.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&o.hostname===n}if(!cI.test(t))return!1;if(aI.test(r))return n===r;const i=r.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(n)}/**
1427 * @license
1428 * Copyright 2020 Google LLC.
1429 *
1430 * Licensed under the Apache License, Version 2.0 (the "License");
1431 * you may not use this file except in compliance with the License.
1432 * You may obtain a copy of the License at
1433 *
1434 *   http://www.apache.org/licenses/LICENSE-2.0
1435 *
1436 * Unless required by applicable law or agreed to in writing, software
1437 * distributed under the License is distributed on an "AS IS" BASIS,
1438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1439 * See the License for the specific language governing permissions and
1440 * limitations under the License.
1441 */const hI=new hi(3e4,6e4);function Tl(){const r=rt().___jsl;if(r!=null&&r.H){for(const e of Object.keys(r.H))if(r.H[e].r=r.H[e].r||[],r.H[e].L=r.H[e].L||[],r.H[e].r=[...r.H[e].L],r.CP)for(let t=0;t<r.CP.length;t++)r.CP[t]=null}}function dI(r){return new Promise((e,t)=>{var n,i,s;function o(){Tl(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Tl(),t(Je(r,"network-request-failed"))},timeout:hI.get()})}if(!((i=(n=rt().gapi)===null||n===void 0?void 0:n.iframes)===null||i===void 0)&&i.Iframe)e(gapi.iframes.getContext());else if(!((s=rt().gapi)===null||s===void 0)&&s.load)o();else{const c=uy("iframefcb");return rt()[c]=()=>{gapi.load?o():t(Je(r,"network-request-failed"))},Ad(`${cy()}?onload=${c}`).catch(u=>t(u))}}).catch(e=>{throw ns=null,e})}let ns=null;function fI(r){return ns=ns||dI(r),ns}/**
1442 * @license
1443 * Copyright 2020 Google LLC.
1444 *
1445 * Licensed under the Apache License, Version 2.0 (the "License");
1446 * you may not use this file except in compliance with the License.
1447 * You may obtain a copy of the License at
1448 *
1449 *   http://www.apache.org/licenses/LICENSE-2.0
1450 *
1451 * Unless required by applicable law or agreed to in writing, software
1452 * distributed under the License is distributed on an "AS IS" BASIS,
1453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1454 * See the License for the specific language governing permissions and
1455 * limitations under the License.
1456 */const pI=new hi(5e3,15e3),mI="__/auth/iframe",gI="emulator/auth/iframe",_I={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},yI=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function II(r){const e=r.config;j(e.authDomain,r,"auth-domain-config-required");const t=e.emulator?La(e,gI):`https://${r.config.authDomain}/${mI}`,n={apiKey:e.apiKey,appName:r.name,v:wn},i=yI.get(r.config.apiHost);i&&(n.eid=i);const s=r._getFrameworks();return s.length&&(n.fw=s.join(",")),`${t}?${li(n).slice(1)}`}async function TI(r){const e=await fI(r),t=rt().gapi;return j(t,r,"internal-error"),e.open({where:document.body,url:II(r),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:_I,dontclear:!0},n=>new Promise(async(i,s)=>{await n.restyle({setHideOnLeave:!1});const o=Je(r,"network-request-failed"),c=rt().setTimeout(()=>{s(o)},pI.get());function u(){rt().clearTimeout(c),i(n)}n.ping(u).then(u,()=>{s(o)})}))}/**
1457 * @license
1458 * Copyright 2020 Google LLC.
1459 *
1460 * Licensed under the Apache License, Version 2.0 (the "License");
1461 * you may not use this file except in compliance with the License.
1462 * You may obtain a copy of the License at
1463 *
1464 *   http://www.apache.org/licenses/LICENSE-2.0
1465 *
1466 * Unless required by applicable law or agreed to in writing, software
1467 * distributed under the License is distributed on an "AS IS" BASIS,
1468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1469 * See the License for the specific language governing permissions and
1470 * limitations under the License.
1471 */const EI={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},vI=500,wI=600,AI="_blank",RI="http://localhost";class El{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function bI(r,e,t,n=vI,i=wI){const s=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-n)/2,0).toString();let c="";const u=Object.assign(Object.assign({},EI),{width:n.toString(),height:i.toString(),top:s,left:o}),h=me().toLowerCase();t&&(c=_d(h)?AI:t),md(h)&&(e=e||RI,u.scrollbars="yes");const f=Object.entries(u).reduce((_,[b,V])=>`${_}${b}=${V},`,"");if(Z_(h)&&c!=="_self")return SI(e||"",c),new El(null);const m=window.open(e||"",c,f);j(m,r,"popup-blocked");try{m.focus()}catch{}return new El(m)}function SI(r,e){const t=document.createElement("a");t.href=r,t.target=e;const n=document.createEvent("MouseEvent");n.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(n)}/**
1472 * @license
1473 * Copyright 2021 Google LLC
1474 *
1475 * Licensed under the Apache License, Version 2.0 (the "License");
1476 * you may not use this file except in compliance with the License.
1477 * You may obtain a copy of the License at
1478 *
1479 *   http://www.apache.org/licenses/LICENSE-2.0
1480 *
1481 * Unless required by applicable law or agreed to in writing, software
1482 * distributed under the License is distributed on an "AS IS" BASIS,
1483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1484 * See the License for the specific language governing permissions and
1485 * limitations under the License.
1486 */const PI="__/auth/handler",CI="emulator/auth/handler",DI=encodeURIComponent("fac");async function vl(r,e,t,n,i,s){j(r.config.authDomain,r,"auth-domain-config-required"),j(r.config.apiKey,r,"invalid-api-key");const o={apiKey:r.config.apiKey,appName:r.name,authType:t,redirectUrl:n,v:wn,eventId:i};if(e instanceof Fs){e.setDefaultLanguage(r.languageCode),o.providerId=e.providerId||"",Ig(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,m]of Object.entries({}))o[f]=m}if(e instanceof fi){const f=e.getScopes().filter(m=>m!=="");f.length>0&&(o.scopes=f.join(","))}r.tenantId&&(o.tid=r.tenantId);const c=o;for(const f of Object.keys(c))c[f]===void 0&&delete c[f];const u=await r._getAppCheckToken(),h=u?`#${DI}=${encodeURIComponent(u)}`:"";return`${VI(r)}?${li(c).slice(1)}${h}`}function VI({config:r}){return r.emulator?La(r,CI):`https://${r.authDomain}/${PI}`}/**
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 */const Uo="webStorageSupport";class kI{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=kd,this._completeRedirectFn=Bd,this._overrideRedirectResult=tI}async _openPopup(e,t,n,i){var s;mt((s=this.eventManagers[e._key()])===null||s===void 0?void 0:s.manager,"_initialize() not called before _openPopup()");const o=await vl(e,t,n,na(),i);return bI(e,o,ja())}async _openRedirect(e,t,n,i){await this._originValidation(e);const s=await vl(e,t,n,na(),i);return Ly(s),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:i,promise:s}=this.eventManagers[t];return i?Promise.resolve(i):(mt(s,"If manager is not set, promise should be"),s)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){const t=await TI(e),n=new iI(e);return t.register("authEvent",i=>
1501(j(i==null?void 0:i.authEvent,e,"invalid-auth-event"),{status:n.onEvent(i.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Uo,{type:Uo},i=>{var s;const o=(s=i==null?void 0:i[0])===null||s===void 0?void 0:s[Uo];o!==void 0&&t(!!o),We(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=uI(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return vd()||gd()||Ua()}}const NI=kI;var wl="@firebase/auth",Al="1.7.9";/**
1502 * @license
1503 * Copyright 2020 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 xI{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(n=>{e((n==null?void 0:n.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){j(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
1517 * @license
1518 * Copyright 2020 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 */function OI(r){switch(r){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function MI(r){Xe(new Ke("auth",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),s=e.getProvider("app-check-internal"),{apiKey:o,authDomain:c}=n.options;j(o&&!o.includes(":"),"invalid-api-key",{appName:n.name});const u={apiKey:o,authDomain:c,clientPlatform:r,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:wd(r)},h=new sy(n,i,s,u);return py(h,t),h},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),Xe(new Ke("auth-internal",e=>{const t=st(e.getProvider("auth").getImmediate());return(n=>new xI(n))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),Le(wl,Al,OI(r)),Le(wl,Al,"esm2017")}/**
1532 * @license
1533 * Copyright 2021 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, softw
vendor: 50,874 bytes, lines 1541-1568
1541are
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 */const LI=5*60,FI=Xh("authIdTokenMaxAge")||LI;let Rl=null;const UI=r=>async e=>{const t=e&&await e.getIdTokenResult(),n=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>FI)return;const i=t==null?void 0:t.token;Rl!==i&&(Rl=i,await fetch(r,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function VR(r=Na()){const e=Ut(r,"auth");if(e.isInitialized())return e.getImmediate();const t=fy(r,{popupRedirectResolver:NI,persistence:[Ky,xy,kd]}),n=Xh("authTokenSyncURL");if(n&&typeof isSecureContext=="boolean"&&isSecureContext){const s=new URL(n,location.origin);if(location.origin===s.origin){const o=UI(s.toString());Vy(t,o,()=>o(t.currentUser)),Dy(t,c=>o(c))}}const i=Jh("auth");return i&&my(t,`http://${i}`),t}function BI(){var r,e;return(e=(r=document.getElementsByTagName("head"))===null||r===void 0?void 0:r[0])!==null&&e!==void 0?e:document}oy({loadJS(r){return new Promise((e,t)=>{const n=document.createElement("script");n.setAttribute("src",r),n.onload=e,n.onerror=i=>{const s=Je("internal-error");s.customData=i,t(s)},n.type="text/javascript",n.charset="UTF-8",BI().appendChild(n)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});MI("Browser");var bl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1547Copyright The Closure Library Authors.
1548SPDX-License-Identifier: Apache-2.0
1549*/var an,jd;(function(){var r;/** @license
1550
1551 Copyright The Closure Library Authors.
1552 SPDX-License-Identifier: Apache-2.0
1553*/function e(T,g){function I(){}I.prototype=g.prototype,T.D=g.prototype,T.prototype=new I,T.prototype.constructor=T,T.C=function(E,v,R){for(var y=Array(arguments.length-2),ot=2;ot<arguments.length;ot++)y[ot-2]=arguments[ot];return g.prototype[v].apply(E,y)}}function t(){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()}e(n,t),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(T,g,I){I||(I=0);var E=Array(16);if(typeof g=="string")for(var v=0;16>v;++v)E[v]=g.charCodeAt(I++)|g.charCodeAt(I++)<<8|g.charCodeAt(I++)<<16|g.charCodeAt(I++)<<24;else for(v=0;16>v;++v)E[v]=g[I++]|g[I++]<<8|g[I++]<<16|g[I++]<<24;g=T.g[0],I=T.g[1],v=T.g[2];var R=T.g[3],y=g+(R^I&(v^R))+E[0]+3614090360&4294967295;g=I+(y<<7&4294967295|y>>>25),y=R+(v^g&(I^v))+E[1]+3905402710&4294967295,R=g+(y<<12&4294967295|y>>>20),y=v+(I^R&(g^I))+E[2]+606105819&4294967295,v=R+(y<<17&4294967295|y>>>15),y=I+(g^v&(R^g))+E[3]+3250441966&4294967295,I=v+(y<<22&4294967295|y>>>10),y=g+(R^I&(v^R))+E[4]+4118548399&4294967295,g=I+(y<<7&4294967295|y>>>25),y=R+(v^g&(I^v))+E[5]+1200080426&4294967295,R=g+(y<<12&4294967295|y>>>20),y=v+(I^R&(g^I))+E[6]+2821735955&4294967295,v=R+(y<<17&4294967295|y>>>15),y=I+(g^v&(R^g))+E[7]+4249261313&4294967295,I=v+(y<<22&4294967295|y>>>10),y=g+(R^I&(v^R))+E[8]+1770035416&4294967295,g=I+(y<<7&4294967295|y>>>25),y=R+(v^g&(I^v))+E[9]+2336552879&4294967295,R=g+(y<<12&4294967295|y>>>20),y=v+(I^R&(g^I))+E[10]+4294925233&4294967295,v=R+(y<<17&4294967295|y>>>15),y=I+(g^v&(R^g))+E[11]+2304563134&4294967295,I=v+(y<<22&4294967295|y>>>10),y=g+(R^I&(v^R))+E[12]+1804603682&4294967295,g=I+(y<<7&4294967295|y>>>25),y=R+(v^g&(I^v))+E[13]+4254626195&4294967295,R=g+(y<<12&4294967295|y>>>20),y=v+(I^R&(g^I))+E[14]+2792965006&4294967295,v=R+(y<<17&4294967295|y>>>15),y=I+(g^v&(R^g))+E[15]+1236535329&4294967295,I=v+(y<<22&4294967295|y>>>10),y=g+(v^R&(I^v))+E[1]+4129170786&4294967295,g=I+(y<<5&4294967295|y>>>27),y=R+(I^v&(g^I))+E[6]+3225465664&4294967295,R=g+(y<<9&4294967295|y>>>23),y=v+(g^I&(R^g))+E[11]+643717713&4294967295,v=R+(y<<14&4294967295|y>>>18),y=I+(R^g&(v^R))+E[0]+3921069994&4294967295,I=v+(y<<20&4294967295|y>>>12),y=g+(v^R&(I^v))+E[5]+3593408605&4294967295,g=I+(y<<5&4294967295|y>>>27),y=R+(I^v&(g^I))+E[10]+38016083&4294967295,R=g+(y<<9&4294967295|y>>>23),y=v+(g^I&(R^g))+E[15]+3634488961&4294967295,v=R+(y<<14&4294967295|y>>>18),y=I+(R^g&(v^R))+E[4]+3889429448&4294967295,I=v+(y<<20&4294967295|y>>>12),y=g+(v^R&(I^v))+E[9]+568446438&4294967295,g=I+(y<<5&4294967295|y>>>27),y=R+(I^v&(g^I))+E[14]+3275163606&4294967295,R=g+(y<<9&4294967295|y>>>23),y=v+(g^I&(R^g))+E[3]+4107603335&4294967295,v=R+(y<<14&4294967295|y>>>18),y=I+(R^g&(v^R))+E[8]+1163531501&4294967295,I=v+(y<<20&4294967295|y>>>12),y=g+(v^R&(I^v))+E[13]+2850285829&4294967295,g=I+(y<<5&4294967295|y>>>27),y=R+(I^v&(g^I))+E[2]+4243563512&4294967295,R=g+(y<<9&4294967295|y>>>23),y=v+(g^I&(R^g))+E[7]+1735328473&4294967295,v=R+(y<<14&4294967295|y>>>18),y=I+(R^g&(v^R))+E[12]+2368359562&4294967295,I=v+(y<<20&4294967295|y>>>12),y=g+(I^v^R)+E[5]+4294588738&4294967295,g=I+(y<<4&4294967295|y>>>28),y=R+(g^I^v)+E[8]+2272392833&4294967295,R=g+(y<<11&4294967295|y>>>21),y=v+(R^g^I)+E[11]+1839030562&4294967295,v=R+(y<<16&4294967295|y>>>16),y=I+(v^R^g)+E[14]+4259657740&4294967295,I=v+(y<<23&4294967295|y>>>9),y=g+(I^v^R)+E[1]+2763975236&4294967295,g=I+(y<<4&4294967295|y>>>28),y=R+(g^I^v)+E[4]+1272893353&4294967295,R=g+(y<<11&4294967295|y>>>21),y=v+(R^g^I)+E[7]+4139469664&4294967295,v=R+(y<<16&4294967295|y>>>16),y=I+(v^R^g)+E[10]+3200236656&4294967295,I=v+(y<<23&4294967295|y>>>9),y=g+(I^v^R)+E[13]+681279174&4294967295,g=I+(y<<4&4294967295|y>>>28),y=R+(g^I^v)+E[0]+3936430074&4294967295,R=g+(y<<11&4294967295|y>>>21),y=v+(R^g^I)+E[3]+3572445317&4294967295,v=R+(y<<16&4294967295|y>>>16),y=I+(v^R^g)+E[6]+76029189&4294967295,I=v+(y<<23&4294967295|y>>>9),y=g+(I^v^R)+E[9]+3654602809&4294967295,g=I+(y<<4&4294967295|y>>>28),y=R+(g^I^v)+E[12]+3873151461&4294967295,R=g+(y<<11&4294967295|y>>>21),y=v+(R^g^I)+E[15]+530742520&4294967295,v=R+(y<<16&4294967295|y>>>16),y=I+(v^R^g)+E[2]+3299628645&4294967295,I=v+(y<<23&4294967295|y>>>9),y=g+(v^(I|~R))+E[0]+4096336452&4294967295,g=I+(y<<6&4294967295|y>>>26),y=R+(I^(g|~v))+E[7]+1126891415&4294967295,R=g+(y<<10&4294967295|y>>>22),y=v+(g^(R|~I))+E[14]+2878612391&4294967295,v=R+(y<<15&4294967295|y>>>17),y=I+(R^(v|~g))+E[5]+4237533241&4294967295,I=v+(y<<21&4294967295|y>>>11),y=g+(v^(I|~R))+E[12]+1700485571&4294967295,g=I+(y<<6&4294967295|y>>>26),y=R+(I^(g|~v))+E[3]+2399980690&4294967295,R=g+(y<<10&4294967295|y>>>22),y=v+(g^(R|~I))+E[10]+4293915773&4294967295,v=R+(y<<15&4294967295|y>>>17),y=I+(R^(v|~g))+E[1]+2240044497&4294967295,I=v+(y<<21&4294967295|y>>>11),y=g+(v^(I|~R))+E[8]+1873313359&4294967295,g=I+(y<<6&4294967295|y>>>26),y=R+(I^(g|~v))+E[15]+4264355552&4294967295,R=g+(y<<10&4294967295|y>>>22),y=v+(g^(R|~I))+E[6]+2734768916&4294967295,v=R+(y<<15&4294967295|y>>>17),y=I+(R^(v|~g))+E[13]+1309151649&4294967295,I=v+(y<<21&4294967295|y>>>11),y=g+(v^(I|~R))+E[4]+4149444226&4294967295,g=I+(y<<6&4294967295|y>>>26),y=R+(I^(g|~v))+E[11]+3174756917&4294967295,R=g+(y<<10&4294967295|y>>>22),y=v+(g^(R|~I))+E[2]+718787259&4294967295,v=R+(y<<15&4294967295|y>>>17),y=I+(R^(v|~g))+E[9]+3951481745&4294967295,T.g[0]=T.g[0]+g&4294967295,T.g[1]=T.g[1]+(v+(y<<21&4294967295|y>>>11))&4294967295,T.g[2]=T.g[2]+v&4294967295,T.g[3]=T.g[3]+R&4294967295}n.prototype.u=function(T,g){g===void 0&&(g=T.length);for(var I=g-this.blockSize,E=this.B,v=this.h,R=0;R<g;){if(v==0)for(;R<=I;)i(this,T,R),R+=this.blockSize;if(typeof T=="string"){for(;R<g;)if(E[v++]=T.charCodeAt(R++),v==this.blockSize){i(this,E),v=0;break}}else for(;R<g;)if(E[v++]=T[R++],v==this.blockSize){i(this,E),v=0;break}}this.h=v,this.o+=g},n.prototype.v=function(){var T=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);T[0]=128;for(var g=1;g<T.length-8;++g)T[g]=0;var I=8*this.o;for(g=T.length-8;g<T.length;++g)T[g]=I&255,I/=256;for(this.u(T),T=Array(16),g=I=0;4>g;++g)for(var E=0;32>E;E+=8)T[I++]=this.g[g]>>>E&255;return T};function s(T,g){var I=c;return Object.prototype.hasOwnProperty.call(I,T)?I[T]:I[T]=g(T)}function o(T,g){this.h=g;for(var I=[],E=!0,v=T.length-1;0<=v;v--){var R=T[v]|0;E&&R==g||(I[v]=R,E=!1)}this.g=I}var c={};function u(T){return-128<=T&&128>T?s(T,function(g){return new o([g|0],0>g?-1:0)}):new o([T|0],0>T?-1:0)}function h(T){if(isNaN(T)||!isFinite(T))return m;if(0>T)return D(h(-T));for(var g=[],I=1,E=0;T>=I;E++)g[E]=T/I|0,I*=4294967296;return new o(g,0)}function f(T,g){if(T.length==0)throw Error("number format error: empty string");if(g=g||10,2>g||36<g)throw Error("radix out of range: "+g);if(T.charAt(0)=="-")return D(f(T.substring(1),g));if(0<=T.indexOf("-"))throw Error('number format error: interior "-" character');for(var I=h(Math.pow(g,8)),E=m,v=0;v<T.length;v+=8){var R=Math.min(8,T.length-v),y=parseInt(T.substring(v,v+R),g);8>R?(R=h(Math.pow(g,R)),E=E.j(R).add(h(y))):(E=E.j(I),E=E.add(h(y)))}return E}var m=u(0),_=u(1),b=u(16777216);r=o.prototype,r.m=function(){if(N(this))return-D(this).m();for(var T=0,g=1,I=0;I<this.g.length;I++){var E=this.i(I);T+=(0<=E?E:4294967296+E)*g,g*=4294967296}return T},r.toString=function(T){if(T=T||10,2>T||36<T)throw Error("radix out of range: "+T);if(V(this))return"0";if(N(this))return"-"+D(this).toString(T);for(var g=h(Math.pow(T,6)),I=this,E="";;){var v=$(I,g).g;I=z(I,v.j(g));var R=((0<I.g.length?I.g[0]:I.h)>>>0).toString(T);if(I=v,V(I))return R+E;for(;6>R.length;)R="0"+R;E=R+E}},r.i=function(T){return 0>T?0:T<this.g.length?this.g[T]:this.h};function V(T){if(T.h!=0)return!1;for(var g=0;g<T.g.length;g++)if(T.g[g]!=0)return!1;return!0}function N(T){return T.h==-1}r.l=function(T){return T=z(this,T),N(T)?-1:V(T)?0:1};function D(T){for(var g=T.g.length,I=[],E=0;E<g;E++)I[E]=~T.g[E];return new o(I,~T.h).add(_)}r.abs=function(){return N(this)?D(this):this},r.add=function(T){for(var g=Math.max(this.g.length,T.g.length),I=[],E=0,v=0;v<=g;v++){var R=E+(this.i(v)&65535)+(T.i(v)&65535),y=(R>>>16)+(this.i(v)>>>16)+(T.i(v)>>>16);E=y>>>16,R&=65535,y&=65535,I[v]=y<<16|R}return new o(I,I[I.length-1]&-2147483648?-1:0)};function z(T,g){return T.add(D(g))}r.j=function(T){if(V(this)||V(T))return m;if(N(this))return N(T)?D(this).j(D(T)):D(D(this).j(T));if(N(T))return D(this.j(D(T)));if(0>this.l(b)&&0>T.l(b))return h(this.m()*T.m());for(var g=this.g.length+T.g.length,I=[],E=0;E<2*g;E++)I[E]=0;for(E=0;E<this.g.length;E++)for(var v=0;v<T.g.length;v++){var R=this.i(E)>>>16,y=this.i(E)&65535,ot=T.i(v)>>>16,hr=T.i(v)&65535;I[2*E+2*v]+=y*hr,q(I,2*E+2*v),I[2*E+2*v+1]+=R*hr,q(I,2*E+2*v+1),I[2*E+2*v+1]+=y*ot,q(I,2*E+2*v+1),I[2*E+2*v+2]+=R*ot,q(I,2*E+2*v+2)}for(E=0;E<g;E++)I[E]=I[2*E+1]<<16|I[2*E];for(E=g;E<2*g;E++)I[E]=0;return new o(I,0)};function q(T,g){for(;(T[g]&65535)!=T[g];)T[g+1]+=T[g]>>>16,T[g]&=65535,g++}function U(T,g){this.g=T,this.h=g}function $(T,g){if(V(g))throw Error("division by zero");if(V(T))return new U(m,m);if(N(T))return g=$(D(T),g),new U(D(g.g),D(g.h));if(N(g))return g=$(T,D(g)),new U(D(g.g),g.h);if(30<T.g.length){if(N(T)||N(g))throw Error("slowDivide_ only works with positive integers.");for(var I=_,E=g;0>=E.l(T);)I=J(I),E=J(E);var v=K(I,1),R=K(E,1);for(E=K(E,2),I=K(I,2);!V(E);){var y=R.add(E);0>=y.l(T)&&(v=v.add(I),R=y),E=K(E,1),I=K(I,1)}return g=z(T,v.j(g)),new U(v,g)}for(v=m;0<=T.l(g);){for(I=Math.max(1,Math.floor(T.m()/g.m())),E=Math.ceil(Math.log(I)/Math.LN2),E=48>=E?1:Math.pow(2,E-48),R=h(I),y=R.j(g);N(y)||0<y.l(T);)I-=E,R=h(I),y=R.j(g);V(R)&&(R=_),v=v.add(R),T=z(T,y)}return new U(v,T)}r.A=function(T){return $(this,T).h},r.and=function(T){for(var g=Math.max(this.g.length,T.g.length),I=[],E=0;E<g;E++)I[E]=this.i(E)&T.i(E);return new o(I,this.h&T.h)},r.or=function(T){for(var g=Math.max(this.g.length,T.g.length),I=[],E=0;E<g;E++)I[E]=this.i(E)|T.i(E);return new o(I,this.h|T.h)},r.xor=function(T){for(var g=Math.max(this.g.length,T.g.length),I=[],E=0;E<g;E++)I[E]=this.i(E)^T.i(E);return new o(I,this.h^T.h)};function J(T){for(var g=T.g.length+1,I=[],E=0;E<g;E++)I[E]=T.i(E)<<1|T.i(E-1)>>>31;return new o(I,T.h)}function K(T,g){var I=g>>5;g%=32;for(var E=T.g.length-I,v=[],R=0;R<E;R++)v[R]=0<g?T.i(R+I)>>>g|T.i(R+I+1)<<32-g:T.i(R+I);return new o(v,T.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,jd=n,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.A,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=h,o.fromString=f,an=o}).apply(typeof bl<"u"?bl:typeof self<"u"?self:typeof window<"u"?window:{});var Ki=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1554Copyright The Closure Library Authors.
1555SPDX-License-Identifier: Apache-2.0
1556*/var $d,Lr,zd,rs,oa,Gd,Kd,Wd;(function(){var r,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(a,l,d){return a==Array.prototype||a==Object.prototype||(a[l]=d.value),a};function t(a){a=[typeof globalThis=="object"&&globalThis,a,typeof window=="object"&&window,typeof self=="object"&&self,typeof Ki=="object"&&Ki];for(var l=0;l<a.length;++l){var d=a[l];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var n=t(this);function i(a,l){if(l)e:{var d=n;a=a.split(".");for(var p=0;p<a.length-1;p++){var w=a[p];if(!(w in d))break e;d=d[w]}a=a[a.length-1],p=d[a],l=l(p),l!=p&&l!=null&&e(d,a,{configurable:!0,writable:!0,value:l})}}function s(a,l){a instanceof String&&(a+="");var d=0,p=!1,w={next:function(){if(!p&&d<a.length){var S=d++;return{value:l(S,a[S]),done:!1}}return p=!0,{done:!0,value:void 0}}};return w[Symbol.iterator]=function(){return w},w}i("Array.prototype.values",function(a){return a||function(){return s(this,function(l,d){return d})}});/** @license
1557
1558 Copyright The Closure Library Authors.
1559 SPDX-License-Identifier: Apache-2.0
1560*/var o=o||{},c=this||self;function u(a){var l=typeof a;return l=l!="object"?l:a?Array.isArray(a)?"array":l:"null",l=="array"||l=="object"&&typeof a.length=="number"}function h(a){var l=typeof a;return l=="object"&&a!=null||l=="function"}function f(a,l,d){return a.call.apply(a.bind,arguments)}function m(a,l,d){if(!a)throw Error();if(2<arguments.length){var p=Array.prototype.slice.call(arguments,2);return function(){var w=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(w,p),a.apply(l,w)}}return function(){return a.apply(l,arguments)}}function _(a,l,d){return _=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?f:m,_.apply(null,arguments)}function b(a,l){var d=Array.prototype.slice.call(arguments,1);return function(){var p=d.slice();return p.push.apply(p,arguments),a.apply(this,p)}}function V(a,l){function d(){}d.prototype=l.prototype,a.aa=l.prototype,a.prototype=new d,a.prototype.constructor=a,a.Qb=function(p,w,S){for(var x=Array(arguments.length-2),ne=2;ne<arguments.length;ne++)x[ne-2]=arguments[ne];return l.prototype[w].apply(p,x)}}function N(a){const l=a.length;if(0<l){const d=Array(l);for(let p=0;p<l;p++)d[p]=a[p];return d}return[]}function D(a,l){for(let d=1;d<arguments.length;d++){const p=arguments[d];if(u(p)){const w=a.length||0,S=p.length||0;a.length=w+S;for(let x=0;x<S;x++)a[w+x]=p[x]}else a.push(p)}}class z{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 q(a){return/^[\s\xa0]*$/.test(a)}function U(){var a=c.navigator;return a&&(a=a.userAgent)?a:""}function $(a){return $[" "](a),a}$[" "]=function(){};var J=U().indexOf("Gecko")!=-1&&!(U().toLowerCase().indexOf("webkit")!=-1&&U().indexOf("Edge")==-1)&&!(U().indexOf("Trident")!=-1||U().indexOf("MSIE")!=-1)&&U().indexOf("Edge")==-1;function K(a,l,d){for(const p in a)l.call(d,a[p],p,a)}function T(a,l){for(const d in a)l.call(void 0,a[d],d,a)}function g(a){const l={};for(const d in a)l[d]=a[d];return l}const I="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function E(a,l){let d,p;for(let w=1;w<arguments.length;w++){p=arguments[w];for(d in p)a[d]=p[d];for(let S=0;S<I.length;S++)d=I[S],Object.prototype.hasOwnProperty.call(p,d)&&(a[d]=p[d])}}function v(a){var l=1;a=a.split(":");const d=[];for(;0<l&&a.length;)d.push(a.shift()),l--;return a.length&&d.push(a.join(":")),d}function R(a){c.setTimeout(()=>{throw a},0)}function y(){var a=co;let l=null;return a.g&&(l=a.g,a.g=a.g.next,a.g||(a.h=null),l.next=null),l}class ot{constructor(){this.h=this.g=null}add(l,d){const p=hr.get();p.set(l,d),this.h?this.h.next=p:this.g=p,this.h=p}}var hr=new z(()=>new Tm,a=>a.reset());class Tm{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 dr,fr=!1,co=new ot,Qc=()=>{const a=c.Promise.resolve(void 0);dr=()=>{a.then(Em)}};var Em=()=>{for(var a;a=y();){try{a.h.call(a.g)}catch(d){R(d)}var l=hr;l.j(a),100>l.h&&(l.h++,a.next=l.g,l.g=a)}fr=!1};function It(){this.s=this.s,this.C=this.C}It.prototype.s=!1,It.prototype.ma=function(){this.s||(this.s=!0,this.N())},It.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Ae(a,l){this.type=a,this.g=this.target=l,this.defaultPrevented=!1}Ae.prototype.h=function(){this.defaultPrevented=!0};var vm=function(){if(!c.addEventListener||!Object.defineProperty)return!1;var a=!1,l=Object.defineProperty({},"passive",{get:function(){a=!0}});try{const d=()=>{};c.addEventListener("test",d,l),c.removeEventListener("test",d,l)}catch{}return a}();function pr(a,l){if(Ae.call(this,a?a.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,a){var d=this.type=a.type,p=a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:null;if(this.target=a.target||a.srcElement,this.g=l,l=a.relatedTarget){if(J){e:{try{$(l.nodeName);var w=!0;break e}catch{}w=!1}w||(l=null)}}else d=="mouseover"?l=a.fromElement:d=="mouseout"&&(l=a.toElement);this.relatedTarget=l,p?(this.clientX=p.clientX!==void 0?p.clientX:p.pageX,this.clientY=p.clientY!==void 0?p.clientY:p.pageY,this.screenX=p.screenX||0,this.screenY=p.screenY||0):(this.clientX=a.clientX!==void 0?a.clientX:a.pageX,this.clientY=a.clientY!==void 0?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0),this.button=a.button,this.key=a.key||"",this.ctrlKey=a.ctrlKey,this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.metaKey=a.metaKey,this.pointerId=a.pointerId||0,this.pointerType=typeof a.pointerType=="string"?a.pointerType:wm[a.pointerType]||"",this.state=a.state,this.i=a,a.defaultPrevented&&pr.aa.h.call(this)}}V(pr,Ae);var wm={2:"touch",3:"pen",4:"mouse"};pr.prototype.h=function(){pr.aa.h.call(this);var a=this.i;a.preventDefault?a.preventDefault():a.returnValue=!1};var bi="closure_listenable_"+(1e6*Math.random()|0),Am=0;function Rm(a,l,d,p,w){this.listener=a,this.proxy=null,this.src=l,this.type=d,this.capture=!!p,this.ha=w,this.key=++Am,this.da=this.fa=!1}function Si(a){a.da=!0,a.listener=null,a.proxy=null,a.src=null,a.ha=null}function Pi(a){this.src=a,this.g={},this.h=0}Pi.prototype.add=function(a,l,d,p,w){var S=a.toString();a=this.g[S],a||(a=this.g[S]=[],this.h++);var x=lo(a,l,p,w);return-1<x?(l=a[x],d||(l.fa=!1)):(l=new Rm(l,this.src,S,!!p,w),l.fa=d,a.push(l)),l};function uo(a,l){var d=l.type;if(d in a.g){var p=a.g[d],w=Array.prototype.indexOf.call(p,l,void 0),S;(S=0<=w)&&Array.prototype.splice.call(p,w,1),S&&(Si(l),a.g[d].length==0&&(delete a.g[d],a.h--))}}function lo(a,l,d,p){for(var w=0;w<a.length;++w){var S=a[w];if(!S.da&&S.listener==l&&S.capture==!!d&&S.ha==p)return w}return-1}var ho="closure_lm_"+(1e6*Math.random()|0),fo={};function Jc(a,l,d,p,w){if(Array.isArray(l)){for(var S=0;S<l.length;S++)Jc(a,l[S],d,p,w);return null}return d=Zc(d),a&&a[bi]?a.K(l,d,h(p)?!!p.capture:!1,w):bm(a,l,d,!1,p,w)}function bm(a,l,d,p,w,S){if(!l)throw Error("Invalid event type");var x=h(w)?!!w.capture:!!w,ne=mo(a);if(ne||(a[ho]=ne=new Pi(a)),d=ne.add(l,d,p,x,S),d.proxy)return d;if(p=Sm(),d.proxy=p,p.src=a,p.listener=d,a.addEventListener)vm||(w=x),w===void 0&&(w=!1),a.addEventListener(l.toString(),p,w);else if(a.attachEvent)a.attachEvent(Xc(l.toString()),p);else if(a.addListener&&a.removeListener)a.addListener(p);else throw Error("addEventListener and attachEvent are unavailable.");return d}function Sm(){function a(d){return l.call(a.src,a.listener,d)}const l=Pm;return a}function Yc(a,l,d,p,w){if(Array.isArray(l))for(var S=0;S<l.length;S++)Yc(a,l[S],d,p,w);else p=h(p)?!!p.capture:!!p,d=Zc(d),a&&a[bi]?(a=a.i,l=String(l).toString(),l in a.g&&(S=a.g[l],d=lo(S,d,p,w),-1<d&&(Si(S[d]),Array.prototype.splice.call(S,d,1),S.length==0&&(delete a.g[l],a.h--)))):a&&(a=mo(a))&&(l=a.g[l.toString()],a=-1,l&&(a=lo(l,d,p,w)),(d=-1<a?l[a]:null)&&po(d))}function po(a){if(typeof a!="number"&&a&&!a.da){var l=a.src;if(l&&l[bi])uo(l.i,a);else{var d=a.type,p=a.proxy;l.removeEventListener?l.removeEventListener(d,p,a.capture):l.detachEvent?l.detachEvent(Xc(d),p):l.addListener&&l.removeListener&&l.removeListener(p),(d=mo(l))?(uo(d,a),d.h==0&&(d.src=null,l[ho]=null)):Si(a)}}}function Xc(a){return a in fo?fo[a]:fo[a]="on"+a}function Pm(a,l){if(a.da)a=!0;else{l=new pr(l,this);var d=a.listener,p=a.ha||a.src;a.fa&&po(a),a=d.call(p,l)}return a}function mo(a){return a=a[ho],a instanceof Pi?a:null}var go="__closure_events_fn_"+(1e9*Math.random()>>>0);function Zc(a){return typeof a=="function"?a:(a[go]||(a[go]=function(l){return a.handleEvent(l)}),a[go])}function Re(){It.call(this),this.i=new Pi(this),this.M=this,this.F=null}V(Re,It),Re.prototype[bi]=!0,Re.prototype.removeEventListener=function(a,l,d,p){Yc(this,a,l,d,p)};function Ve(a,l){var d,p=a.F;if(p)for(d=[];p;p=p.F)d.push(p);if(a=a.M,p=l.type||l,typeof l=="string")l=new Ae(l,a);else if(l instanceof Ae)l.target=l.target||a;else{var w=l;l=new Ae(p,a),E(l,w)}if(w=!0,d)for(var S=d.length-1;0<=S;S--){var x=l.g=d[S];w=Ci(x,p,!0,l)&&w}if(x=l.g=a,w=Ci(x,p,!0,l)&&w,w=Ci(x,p,!1,l)&&w,d)for(S=0;S<d.length;S++)x=l.g=d[S],w=Ci(x,p,!1,l)&&w}Re.prototype.N=function(){if(Re.aa.N.call(this),this.i){var a=this.i,l;for(l in a.g){for(var d=a.g[l],p=0;p<d.length;p++)Si(d[p]);delete a.g[l],a.h--}}this.F=null},Re.prototype.K=function(a,l,d,p){return this.i.add(String(a),l,!1,d,p)},Re.prototype.L=function(a,l,d,p){return this.i.add(String(a),l,!0,d,p)};function Ci(a,l,d,p){if(l=a.i.g[String(l)],!l)return!0;l=l.concat();for(var w=!0,S=0;S<l.length;++S){var x=l[S];if(x&&!x.da&&x.capture==d){var ne=x.listener,Ie=x.ha||x.src;x.fa&&uo(a.i,x),w=ne.call(Ie,p)!==!1&&w}}return w&&!p.defaultPrevented}function eu(a,l,d){if(typeof a=="function")d&&(a=_(a,d));else if(a&&typeof a.handleEvent=="function")a=_(a.handleEvent,a);else throw Error("Invalid listener argument");return 2147483647<Number(l)?-1:c.setTimeout(a,l||0)}function tu(a){a.g=eu(()=>{a.g=null,a.i&&(a.i=!1,tu(a))},a.l);const l=a.h;a.h=null,a.m.apply(null,l)}class Cm extends It{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:tu(this)}N(){super.N(),this.g&&(c.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function mr(a){It.call(this),this.h=a,this.g={}}V(mr,It);var nu=[];function ru(a){K(a.g,function(l,d){this.g.hasOwnProperty(d)&&po(l)},a),a.g={}}mr.prototype.N=function(){mr.aa.N.call(this),ru(this)},mr.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var _o=c.JSON.stringify,Dm=c.JSON.parse,Vm=class{stringify(a){return c.JSON.stringify(a,void 0)}parse(a){return c.JSON.parse(a,void 0)}};function yo(){}yo.prototype.h=null;function iu(a){return a.h||(a.h=a.i())}function su(){}var gr={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Io(){Ae.call(this,"d")}V(Io,Ae);function To(){Ae.call(this,"c")}V(To,Ae);var Wt={},ou=null;function Di(){return ou=ou||new Re}Wt.La="serverreachability";function au(a){Ae.call(this,Wt.La,a)}V(au,Ae);function _r(a){const l=Di();Ve(l,new au(l))}Wt.STAT_EVENT="statevent";function cu(a,l){Ae.call(this,Wt.STAT_EVENT,a),this.stat=l}V(cu,Ae);function ke(a){const l=Di();Ve(l,new cu(l,a))}Wt.Ma="timingevent";function uu(a,l){Ae.call(this,Wt.Ma,a),this.size=l}V(uu,Ae);function yr(a,l){if(typeof a!="function")throw Error("Fn must not be null and must be a function");return c.setTimeout(function(){a()},l)}function Ir(){this.g=!0}Ir.prototype.xa=function(){this.g=!1};function km(a,l,d,p,w,S){a.info(function(){if(a.g)if(S)for(var x="",ne=S.split("&"),Ie=0;Ie<ne.length;Ie++){var X=ne[Ie].split("=");if(1<X.length){var be=X[0];X=X[1];var Se=be.split("_");x=2<=Se.length&&Se[1]=="type"?x+(be+"="+X+"&"):x+(be+"=redacted&")}}else x=null;else x=S;return"XMLHTTP REQ ("+p+") [attempt "+w+"]: "+l+`
1561`+d+`
1562`+x})}function Nm(a,l,d,p,w,S,x){a.info(function(){return"XMLHTTP RESP ("+p+") [ attempt "+w+"]: "+l+`
1563`+d+`
1564`+S+" "+x})}function bn(a,l,d,p){a.info(function(){return"XMLHTTP TEXT ("+l+"): "+Om(a,d)+(p?" "+p:"")})}function xm(a,l){a.info(function(){return"TIMEOUT: "+l})}Ir.prototype.info=function(){};function Om(a,l){if(!a.g)return l;if(!l)return null;try{var d=JSON.parse(l);if(d){for(a=0;a<d.length;a++)if(Array.isArray(d[a])){var p=d[a];if(!(2>p.length)){var w=p[1];if(Array.isArray(w)&&!(1>w.length)){var S=w[0];if(S!="noop"&&S!="stop"&&S!="close")for(var x=1;x<w.length;x++)w[x]=""}}}}return _o(d)}catch{return l}}var Vi={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},lu={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Eo;function ki(){}V(ki,yo),ki.prototype.g=function(){return new XMLHttpRequest},ki.prototype.i=function(){return{}},Eo=new ki;function Tt(a,l,d,p){this.j=a,this.i=l,this.l=d,this.R=p||1,this.U=new mr(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 hu}function hu(){this.i=null,this.g="",this.h=!1}var du={},vo={};function wo(a,l,d){a.L=1,a.v=Mi(at(l)),a.m=d,a.P=!0,fu(a,null)}function fu(a,l){a.F=Date.now(),Ni(a),a.A=at(a.v);var d=a.A,p=a.R;Array.isArray(p)||(p=[String(p)]),Su(d.i,"t",p),a.C=0,d=a.j.J,a.h=new hu,a.g=Gu(a.j,d?l:null,!a.m),0<a.O&&(a.M=new Cm(_(a.Y,a,a.g),a.O)),l=a.U,d=a.g,p=a.ca;var w="readystatechange";Array.isArray(w)||(w&&(nu[0]=w.toString()),w=nu);for(var S=0;S<w.length;S++){var x=Jc(d,w[S],p||l.handleEvent,!1,l.h||l);if(!x)break;l.g[x.key]=x}l=a.H?g(a.H):{},a.m?(a.u||(a.u="POST"),l["Content-Type"]="application/x-www-form-urlencoded",a.g.ea(a.A,a.u,a.m,l)):(a.u="GET",a.g.ea(a.A,a.u,null,l)),_r(),km(a.i,a.u,a.A,a.l,a.R,a.m)}Tt.prototype.ca=function(a){a=a.target;const l=this.M;l&&ct(a)==3?l.j():this.Y(a)},Tt.prototype.Y=function(a){try{if(a==this.g)e:{const Se=ct(this.g);var l=this.g.Ba();const Cn=this.g.Z();if(!(3>Se)&&(Se!=3||this.g&&(this.h.h||this.g.oa()||xu(this.g)))){this.J||Se!=4||l==7||(l==8||0>=Cn?_r(3):_r(2)),Ao(this);var d=this.g.Z();this.X=d;t:if(pu(this)){var p=xu(this.g);a="";var w=p.length,S=ct(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){Ht(this),Tr(this);var x="";break t}this.h.i=new c.TextDecoder}for(l=0;l<w;l++)this.h.h=!0,a+=this.h.i.decode(p[l],{stream:!(S&&l==w-1)});p.length=0,this.h.g+=a,this.C=0,x=this.h.g}else x=this.g.oa();if(this.o=d==200,Nm(this.i,this.u,this.A,this.l,this.R,Se,d),this.o){if(this.T&&!this.K){t:{if(this.g){var ne,Ie=this.g;if((ne=Ie.g?Ie.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!q(ne)){var X=ne;break t}}X=null}if(d=X)bn(this.i,this.l,d,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Ro(this,d);else{this.o=!1,this.s=3,ke(12),Ht(this),Tr(this);break e}}if(this.P){d=!0;let Qe;for(;!this.J&&this.C<x.length;)if(Qe=Mm(this,x),Qe==vo){Se==4&&(this.s=4,ke(14),d=!1),bn(this.i,this.l,null,"[Incomplete Response]");break}else if(Qe==du){this.s=4,ke(15),bn(this.i,this.l,x,"[Invalid Chunk]"),d=!1;break}else bn(this.i,this.l,Qe,null),Ro(this,Qe);if(pu(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Se!=4||x.length!=0||this.h.h||(this.s=1,ke(16),d=!1),this.o=this.o&&d,!d)bn(this.i,this.l,x,"[Invalid Chunked Response]"),Ht(this),Tr(this);else if(0<x.length&&!this.W){this.W=!0;var be=this.j;be.g==this&&be.ba&&!be.M&&(be.j.info("Great, no buffering proxy detected. Bytes received: "+x.length),Vo(be),be.M=!0,ke(11))}}else bn(this.i,this.l,x,null),Ro(this,x);Se==4&&Ht(this),this.o&&!this.J&&(Se==4?qu(this.j,this):(this.o=!1,Ni(this)))}else Zm(this.g),d==400&&0<x.indexOf("Unknown SID")?(this.s=3,ke(12)):(this.s=0,ke(13)),Ht(this),Tr(this)}}}catch{}finally{}};function pu(a){return a.g?a.u=="GET"&&a.L!=2&&a.j.Ca:!1}function Mm(a,l){var d=a.C,p=l.indexOf(`
1565`,d);return p==-1?vo:(d=Number(l.substring(d,p)),isNaN(d)?du:(p+=1,p+d>l.length?vo:(l=l.slice(p,p+d),a.C=p+d,l)))}Tt.prototype.cancel=function(){this.J=!0,Ht(this)};function Ni(a){a.S=Date.now()+a.I,mu(a,a.I)}function mu(a,l){if(a.B!=null)throw Error("WatchDog timer not null");a.B=yr(_(a.ba,a),l)}function Ao(a){a.B&&(c.clearTimeout(a.B),a.B=null)}Tt.prototype.ba=function(){this.B=null;const a=Date.now();0<=a-this.S?(xm(this.i,this.A),this.L!=2&&(_r(),ke(17)),Ht(this),this.s=2,Tr(this)):mu(this,this.S-a)};function Tr(a){a.j.G==0||a.J||qu(a.j,a)}function Ht(a){Ao(a);var l=a.M;l&&typeof l.ma=="function"&&l.ma(),a.M=null,ru(a.U),a.g&&(l=a.g,a.g=null,l.abort(),l.ma())}function Ro(a,l){try{var d=a.j;if(d.G!=0&&(d.g==a||bo(d.h,a))){if(!a.K&&bo(d.h,a)&&d.G==3){try{var p=d.Da.g.parse(l)}catch{p=null}if(Array.isArray(p)&&p.length==3){var w=p;if(w[0]==0){e:if(!d.u){if(d.g)if(d.g.F+3e3<a.F)ji(d),Bi(d);else break e;Do(d),ke(18)}}else d.za=w[1],0<d.za-d.T&&37500>w[2]&&d.F&&d.v==0&&!d.C&&(d.C=yr(_(d.Za,d),6e3));if(1>=yu(d.h)&&d.ca){try{d.ca()}catch{}d.ca=void 0}}else Jt(d,11)}else if((a.K||d.g==a)&&ji(d),!q(l))for(w=d.Da.g.parse(l),l=0;l<w.length;l++){let X=w[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 be=X[3];be!=null&&(d.la=be,d.j.info("VER="+d.la));const Se=X[4];Se!=null&&(d.Aa=Se,d.j.info("SVER="+d.Aa));const Cn=X[5];Cn!=null&&typeof Cn=="number"&&0<Cn&&(p=1.5*Cn,d.L=p,d.j.info("backChannelRequestTimeoutMs_="+p)),p=d;const Qe=a.g;if(Qe){const zi=Qe.g?Qe.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(zi){var S=p.h;S.g||zi.indexOf("spdy")==-1&&zi.indexOf("quic")==-1&&zi.indexOf("h2")==-1||(S.j=S.l,S.g=new Set,S.h&&(So(S,S.h),S.h=null))}if(p.D){const ko=Qe.g?Qe.g.getResponseHeader("X-HTTP-Session-Id"):null;ko&&(p.ya=ko,se(p.I,p.D,ko))}}d.G=3,d.l&&d.l.ua(),d.ba&&(d.R=Date.now()-a.F,d.j.info("Handshake RTT: "+d.R+"ms")),p=d;var x=a;if(p.qa=zu(p,p.J?p.ia:null,p.W),x.K){Iu(p.h,x);var ne=x,Ie=p.L;Ie&&(ne.I=Ie),ne.B&&(Ao(ne),Ni(ne)),p.g=x}else Uu(p);0<d.i.length&&qi(d)}else X[0]!="stop"&&X[0]!="close"||Jt(d,7);else d.G==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?Jt(d,7):Co(d):X[0]!="noop"&&d.l&&d.l.ta(X),d.v=0)}}_r(4)}catch{}}var Lm=class{constructor(a,l){this.g=a,this.map=l}};function gu(a){this.l=a||10,c.PerformanceNavigationTiming?(a=c.performance.getEntriesByType("navigation"),a=0<a.length&&(a[0].nextHopProtocol=="hq"||a[0].nextHopProtocol=="h2")):a=!!(c.chrome&&c.chrome.loadTimes&&c.chrome.loadTimes()&&c.chrome.loadTimes().wasFetchedViaSpdy),this.j=a?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function _u(a){return a.h?!0:a.g?a.g.size>=a.j:!1}function yu(a){return a.h?1:a.g?a.g.size:0}function bo(a,l){return a.h?a.h==l:a.g?a.g.has(l):!1}function So(a,l){a.g?a.g.add(l):a.h=l}function Iu(a,l){a.h&&a.h==l?a.h=null:a.g&&a.g.has(l)&&a.g.delete(l)}gu.prototype.cancel=function(){if(this.i=Tu(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const a of this.g.values())a.cancel();this.g.clear()}};function Tu(a){if(a.h!=null)return a.i.concat(a.h.D);if(a.g!=null&&a.g.size!==0){let l=a.i;for(const d of a.g.values())l=l.concat(d.D);return l}return N(a.i)}function Fm(a){if(a.V&&typeof a.V=="function")return a.V();if(typeof Map<"u"&&a instanceof Map||typeof Set<"u"&&a instanceof Set)return Array.from(a.values());if(typeof a=="string")return a.split("");if(u(a)){for(var l=[],d=a.length,p=0;p<d;p++)l.push(a[p]);return l}l=[],d=0;for(p in a)l[d++]=a[p];return l}function Um(a){if(a.na&&typeof a.na=="function")return a.na();if(!a.V||typeof a.V!="function"){if(typeof Map<"u"&&a instanceof Map)return Array.from(a.keys());if(!(typeof Set<"u"&&a instanceof Set)){if(u(a)||typeof a=="string"){var l=[];a=a.length;for(var d=0;d<a;d++)l.push(d);return l}l=[],d=0;for(const p in a)l[d++]=p;return l}}}function Eu(a,l){if(a.forEach&&typeof a.forEach=="function")a.forEach(l,void 0);else if(u(a)||typeof a=="string")Array.prototype.forEach.call(a,l,void 0);else for(var d=Um(a),p=Fm(a),w=p.length,S=0;S<w;S++)l.call(void 0,p[S],d&&d[S],a)}var vu=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Bm(a,l){if(a){a=a.split("&");for(var d=0;d<a.length;d++){var p=a[d].indexOf("="),w=null;if(0<=p){var S=a[d].substring(0,p);w=a[d].substring(p+1)}else S=a[d];l(S,w?decodeURIComponent(w.replace(/\+/g," ")):"")}}}function Qt(a){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,a instanceof Qt){this.h=a.h,xi(this,a.j),this.o=a.o,this.g=a.g,Oi(this,a.s),this.l=a.l;var l=a.i,d=new wr;d.i=l.i,l.g&&(d.g=new Map(l.g),d.h=l.h),wu(this,d),this.m=a.m}else a&&(l=String(a).match(vu))?(this.h=!1,xi(this,l[1]||"",!0),this.o=Er(l[2]||""),this.g=Er(l[3]||"",!0),Oi(this,l[4]),this.l=Er(l[5]||"",!0),wu(this,l[6]||"",!0),this.m=Er(l[7]||"")):(this.h=!1,this.i=new wr(null,this.h))}Qt.prototype.toString=function(){var a=[],l=this.j;l&&a.push(vr(l,Au,!0),":");var d=this.g;return(d||l=="file")&&(a.push("//"),(l=this.o)&&a.push(vr(l,Au,!0),"@"),a.push(encodeURIComponent(String(d)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.s,d!=null&&a.push(":",String(d))),(d=this.l)&&(this.g&&d.charAt(0)!="/"&&a.push("/"),a.push(vr(d,d.charAt(0)=="/"?$m:jm,!0))),(d=this.i.toString())&&a.push("?",d),(d=this.m)&&a.push("#",vr(d,Gm)),a.join("")};function at(a){return new Qt(a)}function xi(a,l,d){a.j=d?Er(l,!0):l,a.j&&(a.j=a.j.replace(/:$/,""))}function Oi(a,l){if(l){if(l=Number(l),isNaN(l)||0>l)throw Error("Bad port number "+l);a.s=l}else a.s=null}function wu(a,l,d){l instanceof wr?(a.i=l,Km(a.i,a.h)):(d||(l=vr(l,zm)),a.i=new wr(l,a.h))}function se(a,l,d){a.i.set(l,d)}function Mi(a){return se(a,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),a}function Er(a,l){return a?l?decodeURI(a.replace(/%25/g,"%2525")):decodeURIComponent(a):""}function vr(a,l,d){return typeof a=="string"?(a=encodeURI(a).replace(l,qm),d&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null}function qm(a){return a=a.charCodeAt(0),"%"+(a>>4&15).toString(16)+(a&15).toString(16)}var Au=/[#\/\?@]/g,jm=/[#\?:]/g,$m=/[#\?]/g,zm=/[#\?@]/g,Gm=/#/g;function wr(a,l){this.h=this.g=null,this.i=a||null,this.j=!!l}function Et(a){a.g||(a.g=new Map,a.h=0,a.i&&Bm(a.i,function(l,d){a.add(decodeURIComponent(l.replace(/\+/g," ")),d)}))}r=wr.prototype,r.add=function(a,l){Et(this),this.i=null,a=Sn(this,a);var d=this.g.get(a);return d||this.g.set(a,d=[]),d.push(l),this.h+=1,this};function Ru(a,l){Et(a),l=Sn(a,l),a.g.has(l)&&(a.i=null,a.h-=a.g.get(l).length,a.g.delete(l))}function bu(a,l){return Et(a),l=Sn(a,l),a.g.has(l)}r.forEach=function(a,l){Et(this),this.g.forEach(function(d,p){d.forEach(function(w){a.call(l,w,p,this)},this)},this)},r.na=function(){Et(this);const a=Array.from(this.g.values()),l=Array.from(this.g.keys()),d=[];for(let p=0;p<l.length;p++){const w=a[p];for(let S=0;S<w.length;S++)d.push(l[p])}return d},r.V=function(a){Et(this);let l=[];if(typeof a=="string")bu(this,a)&&(l=l.concat(this.g.get(Sn(this,a))));else{a=Array.from(this.g.values());for(let d=0;d<a.length;d++)l=l.concat(a[d])}return l},r.set=function(a,l){return Et(this),this.i=null,a=Sn(this,a),bu(this,a)&&(this.h-=this.g.get(a).length),this.g.set(a,[l]),this.h+=1,this},r.get=function(a,l){return a?(a=this.V(a),0<a.length?String(a[0]):l):l};function Su(a,l,d){Ru(a,l),0<d.length&&(a.i=null,a.g.set(Sn(a,l),N(d)),a.h+=d.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";const a=[],l=Array.from(this.g.keys());for(var d=0;d<l.length;d++){var p=l[d];const S=encodeURIComponent(String(p)),x=this.V(p);for(p=0;p<x.length;p++){var w=S;x[p]!==""&&(w+="="+encodeURIComponent(String(x[p]))),a.push(w)}}return this.i=a.join("&")};function Sn(a,l){return l=String(l),a.j&&(l=l.toLowerCase()),l}function Km(a,l){l&&!a.j&&(Et(a),a.i=null,a.g.forEach(function(d,p){var w=p.toLowerCase();p!=w&&(Ru(this,p),Su(this,w,d))},a)),a.j=l}function Wm(a,l){const d=new Ir;if(c.Image){const p=new Image;p.onload=b(vt,d,"TestLoadImage: loaded",!0,l,p),p.onerror=b(vt,d,"TestLoadImage: error",!1,l,p),p.onabort=b(vt,d,"TestLoadImage: abort",!1,l,p),p.ontimeout=b(vt,d,"TestLoadImage: timeout",!1,l,p),c.setTimeout(function(){p.ontimeout&&p.ontimeout()},1e4),p.src=a}else l(!1)}function Hm(a,l){const d=new Ir,p=new AbortController,w=setTimeout(()=>{p.abort(),vt(d,"TestPingServer: timeout",!1,l)},1e4);fetch(a,{signal:p.signal}).then(S=>{clearTimeout(w),S.ok?vt(d,"TestPingServer: ok",!0,l):vt(d,"TestPingServer: server error",!1,l)}).catch(()=>{clearTimeout(w),vt(d,"TestPingServer: error",!1,l)})}function vt(a,l,d,p,w){try{w&&(w.onload=null,w.onerror=null,w.onabort=null,w.ontimeout=null),p(d)}catch{}}function Qm(){this.g=new Vm}function Jm(a,l,d){const p=d||"";try{Eu(a,function(w,S){let x=w;h(w)&&(x=_o(w)),l.push(p+S+"="+encodeURIComponent(x))})}catch(w){throw l.push(p+"type="+encodeURIComponent("_badmap")),w}}function Li(a){this.l=a.Ub||null,this.j=a.eb||!1}V(Li,yo),Li.prototype.g=function(){return new Fi(this.l,this.j)},Li.prototype.i=function(a){return function(){return a}}({});function Fi(a,l){Re.call(this),this.D=a,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}V(Fi,Re),r=Fi.prototype,r.open=function(a,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=a,this.A=l,this.readyState=1,Rr(this)},r.send=function(a){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};a&&(l.body=a),(this.D||c).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,Ar(this)),this.readyState=0},r.Sa=function(a){if(this.g&&(this.l=a,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=a.headers,this.readyState=2,Rr(this)),this.g&&(this.readyState=3,Rr(this),this.g)))if(this.responseType==="arraybuffer")a.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof c.ReadableStream<"u"&&"body"in a){if(this.j=a.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;Pu(this)}else a.text().then(this.Ra.bind(this),this.ga.bind(this))};function Pu(a){a.j.read().then(a.Pa.bind(a)).catch(a.ga.bind(a))}r.Pa=function(a){if(this.g){if(this.o&&a.value)this.response.push(a.value);else if(!this.o){var l=a.value?a.value:new Uint8Array(0);(l=this.v.decode(l,{stream:!a.done}))&&(this.response=this.responseText+=l)}a.done?Ar(this):Rr(this),this.readyState==3&&Pu(this)}},r.Ra=function(a){this.g&&(this.response=this.responseText=a,Ar(this))},r.Qa=function(a){this.g&&(this.response=a,Ar(this))},r.ga=function(){this.g&&Ar(this)};function Ar(a){a.readyState=4,a.l=null,a.j=null,a.v=null,Rr(a)}r.setRequestHeader=function(a,l){this.u.append(a,l)},r.getResponseHeader=function(a){return this.h&&this.h.get(a.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const a=[],l=this.h.entries();for(var d=l.next();!d.done;)d=d.value,a.push(d[0]+": "+d[1]),d=l.next();return a.join(`\r
1566`)};function Rr(a){a.onreadystatechange&&a.onreadystatechange.call(a)}Object.defineProperty(Fi.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(a){this.m=a?"include":"same-origin"}});function Cu(a){let l="";return K(a,function(d,p){l+=p,l+=":",l+=d,l+=`\r
1567`}),l}function Po(a,l,d){e:{for(p in d){var p=!1;break e}p=!0}p||(d=Cu(d),typeof a=="string"?d!=null&&encodeURIComponent(String(d)):se(a,l,d))}function le(a){Re.call(this),this.headers=new Map,this.o=a||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}V(le,Re);var Ym=/^https?$/i,Xm=["POST","PUT"];r=le.prototype,r.Ha=function(a){this.J=a},r.ea=function(a,l,d,p){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+a);l=l?l.toUpperCase():"GET",this.D=a,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Eo.g(),this.v=this.o?iu(this.o):iu(Eo),this.g.onreadystatechange=_(this.Ea,this);try{this.B=!0,this.g.open(l,String(a),!0),this.B=!1}catch(S){Du(this,S);return}if(a=d||"",d=new Map(this.headers),p)if(Object.getPrototypeOf(p)===Object.prototype)for(var w in p)d.set(w,p[w]);else if(typeof p.keys=="function"&&typeof p.get=="function")for(const S of p.keys())d.set(S,p.get(S));else throw Error("Unknown input type for opt_headers: "+String(p));p=Array.from(d.keys()).find(S=>S.toLowerCase()=="content-type"),w=c.FormData&&a instanceof c.FormData,!(0<=Array.prototype.indexOf.call(Xm,l,void 0))||p||w||d.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[S,x]of d)this.g.setRequestHeader(S,x);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Nu(this),this.u=!0,this.g.send(a),this.u=!1}catch(S){Du(this,S)}};function Du(a,l){a.h=!1,a.g&&(a.j=!0,a.g.abort(),a.j=!1),a.l=l,a.m=5,Vu(a),Ui(a)}function Vu(a){a.A||(a.A=!0,Ve(a,"complete"),Ve(a,"error"))}r.abort=function(a){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=a||7,Ve(this,"complete"),Ve(this,"abort"),Ui(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Ui(this,!0)),le.aa.N.call(this)},r.Ea=function(){this.s||(this.B||this.u||this.j?ku(this):this.bb())},r.bb=function(){ku(this)};function ku(a){if(a.h&&typeof o<"u"&&(!a.v[1]||ct(a)!=4||a.Z()!=2)){if(a.u&&ct(a)==4)eu(a.Ea,0,a);else if(Ve(a,"readystatechange"),ct(a)==4){a.h=!1;try{const x=a.Z();e:switch(x){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var l=!0;break e;default:l=!1}var d;if(!(d=l)){var p;if(p=x===0){var w=String(a.D).match(vu)[1]||null;!w&&c.self&&c.self.location&&(w=c.self.location.protocol.slice(0,-1)),p=!Ym.test(w?w.toLowerCase():"")}d=p}if(d)Ve(a,"complete"),Ve(a,"success");else{a.m=6;try{var S=2<ct(a)?a.g.statusText:""}catch{S=""}a.l=S+" ["+a.Z()+"]",Vu(a)}}finally{Ui(a)}}}}function Ui(a,l){if(a.g){Nu(a);const d=a.g,p=a.v[0]?()=>{}:null;a.g=null,a.v=null,l||Ve(a,"ready");try{d.onreadystatechange=p}catch{}}}function Nu(a){a.I&&(c.clearTimeout(a.I),a.I=null)}r.isActive=function(){return!!this.g};function ct(a){return a.g?a.g.readyState:0}r.Z=function(){try{return 2<ct(this)?this.g.status:-1}catch{return-1}},r.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},r.Oa=function(a){if(this.g){var l=this.g.responseText;return a&&l.indexOf(a)==0&&(l=l.substring(a.length)),Dm(l)}};function xu(a){try{if(!a.g)return null;if("response"in a.g)return a.g.response;switch(a.H){case"":case"text":return a.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in a.g)return a.g.mozResponseArrayBuffer}return null}catch{return null}}function Zm(a){const l={};a=(a.g&&2<=ct(a)&&a.g.getAllResponseHeaders()||"").split(`\r
1568`);for(let p=0;p<a.length;p++){if(q(a[p]))continue;var d=v(a[p]);const w=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const S=l[w]||[];l[w]=S,S.push(d)}T(l,function(p){return p.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function br(a,l,d){return d&&d.internalChannelParams&&d.internalChannelParams[a]||l}function Ou(a){this.Aa=0,this.i=[],this.j=new Ir,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=br("failFast",!1,a),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=br("baseRetryDelayMs",5e3,a),this.cb=br("retryDelaySeedMs",1e4,a),this.Wa=br("forwardChannelMaxRetries",2,a),this.wa=br("forwardChannelRequestTimeoutMs",2e4,a),this.pa=a&&a.xmlHttpFactory||void 0,this.Xa=a&&a.Tb||void 0,this.Ca=a&&a.useFetchStreams||!1,this.L=void 0,this.J=a&&a.supportsCrossDomainXhr||!1,this.K="",this.h=new gu(a&&a.concurrentRequestLimit),this.Da=new Qm,this.P=a&&a.fastHandshake||!1,this.O=a&&a.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=a&&a.Rb||!1,a&&a.xa&&this.j.xa(),a&&a.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&a&&a.detectBufferingProxy||!1,this.ja=void 0,a&&a.longPollingTimeout&&0<a.longPollingTimeout&&(this.ja=a.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=Ou.prototype,r.la=8,r.G=1,r.connect=function(a,l,d,p){ke(0),this.W=a,this.H=l||{},d&&p!==void 0&&(this.H.OSID=d,this.H.OAID=p),this.F=this.X,this.I=zu(this,null,this.W),qi(this)};function Co(a){if(Mu(a),a.G==3){var l=a.U++,d=at(a.I);if(se(d,"SID",a.K),se(d,"RID",l),se(d,"TYPE","terminate"),Sr(a,d),l=new Tt(a,a.j,l),l.L=2,l.v=Mi(at(d)),d=!1,c.navigator&&c.navigator.sendBeacon)try{d=c.navigator.sendBeacon(l.v.toString(),"")}catch{}!d&&c.Image&&(new Image().src=l.v,d=!0),d||(l.g=Gu(l.j,null),l.g.ea(l.v)),l.F=Date.now(),Ni(l)}$u(a)}function Bi(a){a.g&&(Vo(a),a.g.cancel(),a.g=null)}function Mu(a){Bi(a),a.u&&(c.clearTimeout(a.u),a.u=null),ji(a),a.h.cancel(),a.s&&(typeof a.s=="number"&&c.clearTimeout(a.s),a.s=null)}function qi(a){if(!_u(a.h)&&!a.s){a.s=!0;var l=a.Ga;dr||Qc(),fr||(dr(),fr=!0),co.add(l,a),a.B=0}}function eg(a,l){return yu(a.h)>=a.h.j-(a.s?1:0)?!1:a.s?(a.i=l.D.concat(a.i),!0):a.G==1||a.G==2||a.B>=(a.Va?0:a.Wa)?!1:(a.s=yr(_(a.Ga,a,l),ju(a,a.B)),a.B++,!0)}r.Ga=function(a){if(this.s)if(this.s=null,this.G==1){if(!a){this.U=Math.floor(1e5*Math.random()),a=this.U++;const w=new Tt(this,this.j,a);let S=this.o;if(this.S&&(S?(S=g(S),E(S,this.S)):S=this.S),this.m!==null||this.O||(w.H=S,S=null),this.P)e:{for(var l=0,d=0;d<this.i.length;d++){t:{var p=this.i[d];if("__data__"in p.map&&(p=p.map.__data__,typeof p=="string")){p=p.length;break t}p=void 0}if(p===void 0)break;if(l+=p,4096<l){l=d;break e}if(l===4096||d===this.i.length-1){l=d+1;break e}}l=1e3}else l=1e3;l=Fu(this,w,l),d=at(this.I),se(d,"RID",a),se(d,"CVER",22),this.D&&se(d,"X-HTTP-Session-Id",this.D),Sr(this,d),S&&(this.O?l="headers="+encodeURIComponent(String(Cu(S)))+"&"+l:this.m&&Po(d,this.m,S)),So(this.h,w),this.Ua&&se(d,"TYPE","init"),this.P?(se(d,"$req",l),se(d,"SID","null"),w.T=!0,wo(w,d,null)):wo(w,d,l),this.G=2}}else this.G==3&&(a?Lu(this,a):this.i.length==0||_u(this.h)||Lu(this))};function Lu(a,l){var d;l?d=l.l:d=a.U++;const p=at(a.I);se(p,"SID",a.K),se(p,"RID",d),se(p,"AID",a.T),Sr(a,p),a.m&&a.o&&Po(p,a.m,a.o),d=new Tt(a,a.j,d,a.B+1),a.m===null&&(d.H=a.o),l&&(a.i=l.D.concat(a.i)),l=Fu(a,d,1e3),d.I=Math.round(.5*a.wa)+Math.round(.5*a.wa*Math.random()),So(a.h,d),wo(d,p,l)}function Sr(a,l){a.H&&K(a.H,function(d,p){se(l,p,d)}),a.l&&Eu({},function(d,p){se(l,p,d)})}function Fu(a,l,d){d=Math.min(a.i.length,d);var p=a.l?_(a.l.Na,a.l,a):null;e:{var w=a.i;let S=-1;for(;;){const x=["count="+d];S==-1?0<d?(S=w[0].g,x.push("ofs="+S)):S=0:x.push("ofs="+S);let ne=!0;for(let Ie=0;Ie<d;Ie++){let X=w[Ie].g;const be=w[Ie].map;if(X-=S,0>X)S=Math.max(0,w[Ie].g-100),ne=!1;else try{Jm(be,x,"req"+X+"_")}catch{p&&p(be)}}if(ne){p=x.join("&");break e}}}return a=a.i.splice(0,d),l.D=a,p}function Uu(a){if(!a.g&&!a.u){a.Y=1;var l=a.Fa;dr||Qc(),fr||(dr(),fr=!0),co.add(l,a),a.v=0}}function Do(a){return a.g||a.u||3<=a.v?!1:(a.Y++,a.u=yr(_(a.Fa,a),ju(a,a.v)),a.v++,!0)}r.Fa=function(){if(this.u=null,Bu(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var a=2*this.R;this.j.info("BP detection timer enabled: "+a),this.A=yr(_(this.ab,this),a)}},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,ke(10),Bi(this),Bu(this))};function Vo(a){a.A!=null&&(c.clearTimeout(a.A),a.A=null)}function Bu(a){a.g=new Tt(a,a.j,"rpc",a.Y),a.m===null&&(a.g.H=a.o),a.g.O=0;var l=at(a.qa);se(l,"RID","rpc"),se(l,"SID",a.K),se(l,"AID",a.T),se(l,"CI",a.F?"0":"1"),!a.F&&a.ja&&se(l,"TO",a.ja),se(l,"TYPE","xmlhttp"),Sr(a,l),a.m&&a.o&&Po(l,a.m,a.o),a.L&&(a.g.I=a.L);var d=a.g;a=a.ia,d.L=1,d.v=Mi(at(l)),d.m=null,d.P=!0,fu(d,a)}r.Za=function(){this.C!=null&&(this.C=null,Bi(this),Do(this),ke(19))};function ji(a){a.C!=null&&(c.clearTimeout(a.C),a.C=null)}function qu(a,l){var d=null;if(a.g==l){ji(a),Vo(a),a.g=null;var p=2}else if(bo(a.h,l))d=l.D,Iu(a.h,l),p=1;else return;if(a.G!=0){if(l.o)if(p==1){d=l.m?l.m.length:0,l=Date.now()-l.F;var w=a.B;p=Di(),Ve(p,new uu(p,d)),qi(a)}else Uu(a);else if(w=l.s,w==3||w==0&&0<l.X||!(p==1&&eg(a,l)||p==2&&Do(a)))switch(d&&0<d.length&&(l=a.h,l.i=l.i.concat(d)),w){case 1:Jt(a,5);break;case 4:Jt(a,10);break;case 3:Jt(a,6);break;default:Jt(a,2)}}}function ju(a,l){let d=a.Ta+Math.floor(Math.random()*a.cb);return a.isActive()||(d*=2),d*l}function Jt(a,l){if(a.j.info("Error code "+l),l==2){var d=_(a.fb,a),p=a.Xa;const w=!p;p=new Qt(p||"//www.google.com/images/cleardot.gif"),c.location&&c.location.protocol=="http"||xi(p,"https"),Mi(p),w?Wm(p.toString(),d):Hm(p.toString(),d)}else ke(2);a.G=0,a.l&&a.l.sa(l),$u(a),Mu(a)}r.fb=function(a){a?(this.j.info("Successfully pinged google.com"),ke(2)):(this.j.info("Failed to ping google.com"),ke(1))};function $u(a){if(a.G=0,a.ka=[],a.l){const l=Tu(a.h);(l.length!=0||a.i.length!=0)&&(D(a.ka,l),D(a.ka,a.i),a.h.i.length=0,N(a.i),a.i.length=0),a.l.ra()}}function zu(a,l,d){var p=d instanceof Qt?at(d):new Qt(d);if(p.g!="")l&&(p.g=l+"."+p.g),Oi(p,p.s);else{var w=c.location;p=w.protocol,l=l?l+"."+w.hostname:w.hostname,w=+w.port;var S=new Qt(null);p&&xi(S,p),l&&(S.g=l),w&&Oi(S,w),d&&(S.l=d),p=S}return d=a.D,l=a.ya,d&&l&&se(p,d,l),se(p,"VER",a.la),Sr(a,p),p}
1568function Gu(a,l,d){if(l&&!a.J)throw Error("Can't create secondary domain capable XhrIo object.");return l=a.Ca&&!a.pa?new le(new Li({eb:d})):new le(a.pa),l.Ha(a.J),l}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function Ku(){}r=Ku.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function $i(){}$i.prototype.g=function(a,l){return new Ue(a,l)};function Ue(a,l){Re.call(this),this.g=new Ou(l),this.l=a,this.h=l&&l.messageUrlParams||null,a=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(a?a["X-Client-Protocol"]="webchannel":a={"X-Client-Protocol":"webchannel"}),this.g.o=a,a=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(a?a["X-WebChannel-Content-Type"]=l.messageContentType:a={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.va&&(a?a["X-WebChannel-Client-Profile"]=l.va:a={"X-WebChannel-Client-Profile":l.va}),this.g.S=a,(a=l&&l.Sb)&&!q(a)&&(this.g.m=a),this.v=l&&l.supportsCrossDomainXhr||!1,this.u=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!q(l)&&(this.g.D=l,a=this.h,a!==null&&l in a&&(a=this.h,l in a&&delete a[l])),this.j=new Pn(this)}V(Ue,Re),Ue.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ue.prototype.close=function(){Co(this.g)},Ue.prototype.o=function(a){var l=this.g;if(typeof a=="string"){var d={};d.__data__=a,a=d}else this.u&&(d={},d.__data__=_o(a),a=d);l.i.push(new Lm(l.Ya++,a)),l.G==3&&qi(l)},Ue.prototype.N=function(){this.g.l=null,delete this.j,Co(this.g),delete this.g,Ue.aa.N.call(this)};function Wu(a){Io.call(this),a.__headers__&&(this.headers=a.__headers__,this.statusCode=a.__status__,delete a.__headers__,delete a.__status__);var l=a.__sm__;if(l){e:{for(const d in l){a=d;break e}a=void 0}(this.i=a)&&(a=this.i,l=l!==null&&a in l?l[a]:void 0),this.data=l}else this.data=a}V(Wu,Io);function Hu(){To.call(this),this.status=1}V(Hu,To);function Pn(a){this.g=a}V(Pn,Ku),Pn.prototype.ua=function(){Ve(this.g,"a")},Pn.prototype.ta=function(a){Ve(this.g,new Wu(a))},Pn.prototype.sa=function(a){Ve(this.g,new Hu)},Pn.prototype.ra=function(){Ve(this.g,"b")},$i.prototype.createWebChannel=$i.prototype.g,Ue.prototype.send=Ue.prototype.o,Ue.prototype.open=Ue.prototype.m,Ue.prototype.close=Ue.prototype.close,Wd=function(){return new $i},Kd=function(){return Di()},Gd=Wt,oa={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},Vi.NO_ERROR=0,Vi.TIMEOUT=8,Vi.HTTP_ERROR=6,rs=Vi,lu.COMPLETE="complete",zd=lu,su.EventType=gr,gr.OPEN="a",gr.CLOSE="b",gr.ERROR="c",gr.MESSAGE="d",Re.prototype.listen=Re.prototype.K,Lr=su,le.prototype.listenOnce=le.prototype.L,le.prototype.getLastError=le.prototype.Ka,le.prototype.getLastErrorCode=le.prototype.Ba,le.prototype.getStatus=le.prototype.Z,le.prototype.getResponseJson=le.prototype.Oa,le.prototype.getResponseText=le.prototype.oa,le.prototype.send=le.prototype.ea,le.prototype.setWithCredentials=le.prototype.Ha,$d=le}).apply(typeof Ki<"u"?Ki:typeof self<"u"?self:typeof window<"u"?window:{});const Sl="@firebase/firestore";/**
1569 * @license
1570 * Copyright 2017 Google LLC
1571 *
1572 * Licensed under the Apache License, Version 2.0 (the "License");
1573 * you may not use this file except in compliance with the License.
1574 * You may obtain a copy of the License at
1575 *
1576 *   http://www.apache.org/licenses/LICENSE-2.0
1577 *
1578 * Unless required by applicable law or agreed to in writing, software
1579 * distributed under the License is distributed on an "AS IS" BASIS,
1580 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1581 * See the License for the specific language governing permissions and
1582 * limitations under the License.
1583 */class Ce{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Ce.UNAUTHENTICATED=new Ce(null),Ce.GOOGLE_CREDENTIALS=new Ce("google-credentials-uid"),Ce.FIRST_PARTY=new Ce("first-party-uid"),Ce.MOCK_USER=new Ce("mock-user");/**
1584 * @license
1585 * Copyright 2017 Google LLC
1586 *
1587 * Licensed under the Apache License, Version 2.0 (the "License");
1588 * you may not use this file except in compliance with the License.
1589 * You may obtain a copy of the License at
1590 *
1591 *   http://www.apache.org/licenses/LICENSE-2.0
1592 *
1593 * Unless required by applicable law or agreed to in writing, software
1594 * distributed under the License is distributed on an "AS IS" BASIS,
1595 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1596 * See the License for the specific language governing permissions and
1597 * limitations under the License.
1598 */let or="10.14.0";/**
1599 * @license
1600 * Copyright 2017 Google LLC
1601 *
1602 * Licensed under the Apache License, Version 2.0 (the "License");
1603 * you may not use this file except in compliance with the License.
1604 * You may obtain a copy of the License at
1605 *
1606 *   http://www.apache.org/licenses/LICENSE-2.0
1607 *
1608 * Unless required by applicable law or agreed to in writing, software
1609 * distributed under the License is distributed on an "AS IS" BASIS,
1610 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1611 * See the License for the specific language governing permissions and
1612 * limitations under the License.
1613 */const hn=new Ms("@firebase/firestore");function xn(){return hn.logLevel}function C(r,...e){if(hn.logLevel<=H.DEBUG){const t=e.map(Ga);hn.debug(`Firestore (${or}): ${r}`,...t)}}function he(r,...e){if(hn.logLevel<=H.ERROR){const t=e.map(Ga);hn.error(`Firestore (${or}): ${r}`,...t)}}function Yr(r,...e){if(hn.logLevel<=H.WARN){const t=e.map(Ga);hn.warn(`Firestore (${or}): ${r}`,...t)}}function Ga(r){if(typeof r=="string")return r;try{/**
1614* @license
1615* Copyright 2020 Google LLC
1616*
1617* Licensed under the Apache License, Version 2.0 (the "License");
1618* you may not use this file except in compliance with the License.
1619* You may obtain a copy of the License at
1620*
1621*   http://www.apache.org/licenses/LICENSE-2.0
1622*
1623* Unless required by applicable law or agreed to in writing, software
1624* distributed under the License is distributed on an "AS IS" BASIS,
1625* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1626* See the License for the specific language governing permissions and
1627* limitations under the License.
1628*/return function(t){return JSON.stringify(t)}(r)}catch{return r}}/**
1629 * @license
1630 * Copyright 2017 Google LLC
1631 *
1632 * Licensed under the Apache License, Version 2.0 (the "License");
1633 * you may not use this file except in compliance with the License.
1634 * You may obtain a copy of the License at
1635 *
1636 *   http://www.apache.org/licenses/LICENSE-2.0
1637 *
1638 * Unless required by applicable law or agreed to in writing, software
1639 * distributed under the License is distributed on an "AS IS" BASIS,
1640 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1641 * See the License for the specific language governing permissions and
1642 * limitations under the License.
1643 */function M(r="Unexpected state"){const e=`FIRESTORE (${or}) INTERNAL ASSERTION FAILED: `+r;throw he(e),new Error(e)}function F(r,e){r||M()}function L(r,e){return r}/**
1644 * @license
1645 * Copyright 2017 Google LLC
1646 *
1647 * Licensed under the Apache License, Version 2.0 (the "License");
1648 * you may not use this file except in compliance with the License.
1649 * You may obtain a copy of the License at
1650 *
1651 *   http://www.apache.org/licenses/LICENSE-2.0
1652 *
1653 * Unless required by applicable law or agreed to in writing, software
1654 * distributed under the License is distributed on an "AS IS" BASIS,
1655 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1656 * See the License for the specific language governing permissions and
1657 * limitations under the License.
1658 */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 k extends He{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
1659 * @license
1660 * Copyright 2017 Google LLC
1661 *
1662 * Licensed under the Apache License, Version 2.0 (the "License");
1663 * you may not use this file except in compliance with the License.
1664 * You may obtain a copy of the License at
1665 *
1666 *   http://www.apache.org/licenses/LICENSE-2.0
1667 *
1668 * Unless required by applicable law or agreed to in writing, software
1669 * distributed under the License is distributed on an "AS IS" BASIS,
1670 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1671 * See the License for the specific language governing permissions and
1672 * limitations under the License.
1673 */class Ye{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/**
1674 * @license
1675 * Copyright 2017 Google LLC
1676 *
1677 * Licensed under the Apache License, Version 2.0 (the "License");
1678 * you may not use this file except in compliance with the License.
1679 * You may obtain a copy of the License at
1680 *
1681 *   http://www.apache.org/licenses/LICENSE-2.0
1682 *
1683 * Unless required by applicable law or agreed to in writing, software
1684 * distributed under the License is distributed on an "AS IS" BASIS,
1685 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1686 * See the License for the specific language governing permissions and
1687 * limitations under the License.
1688 */class qI{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class jI{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(Ce.UNAUTHENTICATED))}shutdown(){}}class $I{constructor(e){this.t=e,this.currentUser=Ce.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){F(this.o===void 0);let n=this.i;const i=u=>this.i!==n?(n=this.i,t(u)):Promise.resolve();let s=new Ye;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new Ye,e.enqueueRetryable(()=>i(this.currentUser))};const o=()=>{const u=s;e.enqueueRetryable(async()=>{await u.promise,await i(this.currentUser)})},c=u=>{C("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=u,this.o&&(this.auth.addAuthTokenListener(this.o),o())};this.t.onInit(u=>c(u)),setTimeout(()=>{if(!this.auth){const u=this.t.getImmediate({optional:!0});u?c(u):(C("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new Ye)}},0),o()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(n=>this.i!==e?(C("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):n?(F(typeof n.accessToken=="string"),new qI(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 e=this.auth&&this.auth.getUid();return F(e===null||typeof e=="string"),new Ce(e)}}class zI{constructor(e,t,n){this.l=e,this.h=t,this.P=n,this.type="FirstParty",this.user=Ce.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class GI{constructor(e,t,n){this.l=e,this.h=t,this.P=n}getToken(){return Promise.resolve(new zI(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(Ce.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class KI{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class WI{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,t){F(this.o===void 0);const n=s=>{s.error!=null&&C("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${s.error.message}`);const o=s.token!==this.R;return this.R=s.token,C("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?t(s.token):Promise.resolve()};this.o=s=>{e.enqueueRetryable(()=>n(s))};const i=s=>{C("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):C("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(F(typeof t.token=="string"),this.R=t.token,new KI(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
1689 * @license
1690 * Copyright 2020 Google LLC
1691 *
1692 * Licensed under the Apache License, Version 2.0 (the "License");
1693 * you may not use this file except in compliance with the License.
1694 * You may obtain a copy of the License at
1695 *
1696 *   http://www.apache.org/licenses/LICENSE-2.0
1697 *
1698 * Unless required by applicable law or agreed to in writing, software
1699 * distributed under the License is distributed on an "AS IS" BASIS,
1700 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1701 * See the License for the specific language governing permissions and
1702 * limitations under the License.
1703 */function HI(r){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(r);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let n=0;n<r;n++)t[n]=Math.floor(256*Math.random());return t}/**
1704 * @license
1705 * Copyright 2017 Google LLC
1706 *
1707 * Licensed under the Apache License, Version 2.0 (the "License");
1708 * you may not use this file except in compliance with the License.
1709 * You may obtain a copy of the License at
1710 *
1711 *   http://www.apache.org/licenses/LICENSE-2.0
1712 *
1713 * Unless required by applicable law or agreed to in writing, software
1714 * distributed under the License is distributed on an "AS IS" BASIS,
1715 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1716 * See the License for the specific language governing permissions and
1717 * limitations under the License.
1718 */class Hd{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=Math.floor(256/e.length)*e.length;let n="";for(;n.length<20;){const i=HI(40);for(let s=0;s<i.length;++s)n.length<20&&i[s]<t&&(n+=e.charAt(i[s]%e.length))}return n}}function G(r,e){return r<e?-1:r>e?1:0}function Kn(r,e,t){return r.length===e.length&&r.every((n,i)=>t(n,e[i]))}function Qd(r){return r+"\0"}/**
1719 * @license
1720 * Copyright 2017 Google LLC
1721 *
1722 * Licensed under the Apache License, Version 2.0 (the "License");
1723 * you may not use this file except in compliance with the License.
1724 * You may obtain a copy of the License at
1725 *
1726 *   http://www.apache.org/licenses/LICENSE-2.0
1727 *
1728 * Unless required by applicable law or agreed to in writing, software
1729 * distributed under the License is distributed on an "AS IS" BASIS,
1730 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1731 * See the License for the specific language governing permissions and
1732 * limitations under the License.
1733 */class ue{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new k(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new k(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new k(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new k(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return ue.fromMillis(Date.now())}static fromDate(e){return ue.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new ue(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?G(this.nanoseconds,e.nanoseconds):G(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/**
1734 * @license
1735 * Copyright 2017 Google LLC
1736 *
1737 * Licensed under the Apache License, Version 2.0 (the "License");
1738 * you may not use this file except in compliance with the License.
1739 * You may obtain a copy of the License at
1740 *
1741 *   http://www.apache.org/licenses/LICENSE-2.0
1742 *
1743 * Unless required by applicable law or agreed to in writing, software
1744 * distributed under the License is distributed on an "AS IS" BASIS,
1745 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1746 * See the License for the specific language governing permissions and
1747 * limitations under the License.
1748 */class B{constructor(e){this.timestamp=e}static fromTimestamp(e){return new B(e)}static min(){return new B(new ue(0,0))}static max(){return new B(new ue(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
1749 * @license
1750 * Copyright 2017 Google LLC
1751 *
1752 * Licensed under the Apache License, Version 2.0 (the "License");
1753 * you may not use this file except in compliance with the License.
1754 * You may obtain a copy of the License at
1755 *
1756 *   http://www.apache.org/licenses/LICENSE-2.0
1757 *
1758 * Unless required by applicable law or agreed to in writing, software
1759 * distributed under the License is distributed on an "AS IS" BASIS,
1760 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1761 * See the License for the specific language governing permissions and
1762 * limitations under the License.
1763 */class Xr{constructor(e,t,n){t===void 0?t=0:t>e.length&&M(),n===void 0?n=e.length-t:n>e.length-t&&M(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return Xr.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Xr?e.forEach(n=>{t.push(n)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}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(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const n=Math.min(e.length,t.length);for(let i=0;i<n;i++){const s=e.get(i),o=t.get(i);if(s<o)return-1;if(s>o)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class Z extends Xr{construct(e,t,n){return new Z(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const n of e){if(n.indexOf("//")>=0)throw new k(P.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(i=>i.length>0))}return new Z(t)}static emptyPath(){return new Z([])}}const QI=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ce extends Xr{construct(e,t,n){return new ce(e,t,n)}static isValidIdentifier(e){return QI.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ce.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new ce(["__name__"])}static fromServerFormat(e){const t=[];let n="",i=0;const s=()=>
1763{if(n.length===0)throw new k(P.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let o=!1;for(;i<e.length;){const c=e[i];if(c==="\\"){if(i+1===e.length)throw new k(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const u=e[i+1];if(u!=="\\"&&u!=="."&&u!=="`")throw new k(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=u,i+=2}else c==="`"?(o=!o,i++):c!=="."||o?(n+=c,i++):(s(),i++)}if(s(),o)throw new k(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new ce(t)}static emptyPath(){return new ce([])}}/**
1764 * @license
1765 * Copyright 2017 Google LLC
1766 *
1767 * Licensed under the Apache License, Version 2.0 (the "License");
1768 * you may not use this file except in compliance with the License.
1769 * You may obtain a copy of the License at
1770 *
1771 *   http://www.apache.org/licenses/LICENSE-2.0
1772 *
1773 * Unless required by applicable law or agreed to in writing, software
1774 * distributed under the License is distributed on an "AS IS" BASIS,
1775 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1776 * See the License for the specific language governing permissions and
1777 * limitations under the License.
1778 */class O{constructor(e){this.path=e}static fromPath(e){return new O(Z.fromString(e))}static fromName(e){return new O(Z.fromString(e).popFirst(5))}static empty(){return new O(Z.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&Z.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Z.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new O(new Z(e.slice()))}}/**
1779 * @license
1780 * Copyright 2021 Google LLC
1781 *
1782 * Licensed under the Apache License, Version 2.0 (the "License");
1783 * you may not use this file except in compliance with the License.
1784 * You may obtain a copy of the License at
1785 *
1786 *   http://www.apache.org/licenses/LICENSE-2.0
1787 *
1788 * Unless required by applicable law or agreed to in writing, software
1789 * distributed under the License is distributed on an "AS IS" BASIS,
1790 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1791 * See the License for the specific language governing permissions and
1792 * limitations under the License.
1793 */class Is{constructor(e,t,n,i){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=i}}function aa(r){return r.fields.find(e=>e.kind===2)}function Zt(r){return r.fields.filter(e=>e.kind!==2)}Is.UNKNOWN_ID=-1;class is{constructor(e,t){this.fieldPath=e,this.kind=t}}class Zr{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new Zr(0,$e.min())}}function Jd(r,e){const t=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,i=B.fromTimestamp(n===1e9?new ue(t+1,0):new ue(t,n));return new $e(i,O.empty(),e)}function Yd(r){return new $e(r.readTime,r.key,-1)}class $e{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new $e(B.min(),O.empty(),-1)}static max(){return new $e(B.max(),O.empty(),-1)}}function Ka(r,e){let t=r.readTime.compareTo(e.readTime);return t!==0?t:(t=O.comparator(r.documentKey,e.documentKey),t!==0?t:G(r.largestBatchId,e.largestBatchId))}/**
1794 * @license
1795 * Copyright 2020 Google LLC
1796 *
1797 * Licensed under the Apache License, Version 2.0 (the "License");
1798 * you may not use this file except in compliance with the License.
1799 * You may obtain a copy of the License at
1800 *
1801 *   http://www.apache.org/licenses/LICENSE-2.0
1802 *
1803 * Unless required by applicable law or agreed to in writing, software
1804 * distributed under the License is distributed on an "AS IS" BASIS,
1805 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1806 * See the License for the specific language governing permissions and
1807 * limitations under the License.
1808 */const Xd="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Zd{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}
1808raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/**
1809 * @license
1810 * Copyright 2017 Google LLC
1811 *
1812 * Licensed under the Apache License, Version 2.0 (the "License");
1813 * you may not use this file except in compliance with the License.
1814 * You may obtain a copy of the License at
1815 *
1816 *   http://www.apache.org/licenses/LICENSE-2.0
1817 *
1818 * Unless required by applicable law or agreed to in writing, software
1819 * distributed under the License is distributed on an "AS IS" BASIS,
1820 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1821 * See the License for the specific language governing permissions and
1822 * limitations under the License.
1823 */async function qt(r){if(r.code!==P.FAILED_PRECONDITION||r.message!==Xd)throw r;C("LocalStore","Unexpectedly lost primary lease")}/**
1824 * @license
1825 * Copyright 2017 Google LLC
1826 *
1827 * Licensed under the Apache License, Version 2.0 (the "License");
1828 * you may not use this file except in compliance with the License.
1829 * You may obtain a copy of the License at
1830 *
1831 *   http://www.apache.org/licenses/LICENSE-2.0
1832 *
1833 * Unless required by applicable law or agreed to in writing, software
1834 * distributed under the License is distributed on an "AS IS" BASIS,
1835 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1836 * See the License for the specific language governing permissions and
1837 * limitations under the License.
1838 */class A{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&M(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new A((n,i)=>{this.nextCallback=s=>{this.wrapSuccess(e,s).next(n,i)},this.catchCallback=s=>{this.wrapFailure(t,s).next(n,i)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof A?t:A.resolve(t)}catch(t){return A.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):A.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):A.reject(t)}static resolve(e){return new A((t,n)=>{t(e)})}static reject(e){return new A((t,n)=>{n(e)})}static waitFor(e){return new A((t,n)=>{let i=0,s=0,o=!1;e.forEach(c=>{++i,c.next(()=>{++s,o&&s===i&&t()},u=>n(u))}),o=!0,s===i&&t()})}static or(e){let t=A.resolve(!1);for(const n of e)t=t.next(i=>i?A.resolve(i):n());return t}static forEach(e,t){const n=[];return e.forEach((i,s)=>{n.push(t.call(this,i,s))}),this.waitFor(n)}static mapArray(e,t){return new A((n,i)=>{const s=e.length,o=new Array(s);let c=0;for(let u=0;u<s;u++){const h=u;t(e[h]).next(f=>{o[h]=f,++c,c===s&&n(o)},f=>i(f))}})}static doWhile(e,t){return new A((n,i)=>{const s=()=>{e()===!0?t().next(()=>{s()},i):n()};s()})}}/**
1839 * @license
1840 * Copyright 2017 Google LLC
1841 *
1842 * Licensed under the Apache License, Version 2.0 (the "License");
1843 * you may not use this file except in compliance with the License.
1844 * You may obtain a copy of the License at
1845 *
1846 *   http://www.apache.org/licenses/LICENSE-2.0
1847 *
1848 * Unless required by applicable law or agreed to in writing, software
1849 * distributed under the License is distributed on an "AS IS" BASIS,
1850 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1851 * See the License for the specific language governing permissions and
1852 * limitations under the License.
1853 */class qs{constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.V=new Ye,this.transaction.oncomplete=()=>{this.V.resolve()},this.transaction.onabort=()=>{t.error?this.V.reject(new jr(e,t.error)):this.V.resolve()},this.transaction.onerror=n=>{const i=Wa(n.target.error);this.V.reject(new jr(e,i))}}static open(e,t,n,i){try{return new qs(t,e.transaction(i,n))}catch(s){throw new jr(t,s)}}get m(){return this.V.promise}abort(e){e&&this.V.reject(e),this.aborted||(C("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}g(){const e=this.transaction;this.aborted||typeof e.commit!="function"||e.commit()}store(e){const t=this.transaction.objectStore(e);return new YI(t)}}class xt{constructor(e,t,n){this.name=e,this.version=t,this.p=n,xt.S(me())===12.2&&he("Firestore persistence suffers from a bug in 
1853iOS 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(e){return C("SimpleDb","Removing database:",e),en(window.indexedDB.deleteDatabase(e)).toPromise()}static D(){if(!Os())return!1;if(xt.v())return!0;const e=me(),t=xt.S(e),n=0<t&&t<10,i=ef(e),s=0<i&&i<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||n||s)}static v(){var e;return typeof process<"u"&&((e=process.__PRIVATE_env)===null||e===void 0?void 0:e.C)==="YES"}static F(e,t){return e.store(t)}static S(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}async M(e){return this.db||(C("SimpleDb","Opening database:",this.name),this.db=await new Promise((t,n)=>{const i=indexedDB.open(this.name,this.version);i.onsuccess=s=>{const o=s.target.result;t(o)},i.onblocked=()=>{n(new jr(e,"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 o=s.target.error;o.name==="VersionError"?n(new k(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.")):o.name==="InvalidStateError"?n(new k(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: "+o)):n(new jr(e,o))},i.onupgradeneeded=s=>{C("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',s.oldVersion);const o=s.target.result;this.p.O(o,i.transaction,s.oldVersion,this.version).next(()=>{C("SimpleDb","Database upgrade to version "+this.version+" complete")})}})),this.N&&(this.db.onversionchange=t=>this.N(t)),this.db}L(e){this.N=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,i){const s=t==="readonly";let o=0;for(;;){++o;try{this.db=await this.M(e);const c=qs.open(this.db,e,s?"readonly":"readwrite",n),u=i(c).next(h=>(c.g(),h)).catch(h=>(c.abort(h),A.reject(h))).toPromise();return u.catch(()=>{}),await c.m,u}catch(c){const u=c,h=u.name!=="FirebaseError"&&o<3;if(C("SimpleDb","Transaction failed with error:",u.message,"Retrying:",h),this.close(),!h)return Promise.reject(u)}}}close(){this.db&&this.db.close(),this.db=void 0}}function ef(r){const e=r.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}class JI{constructor(e){this.B=e,this.k=!1,this.q=null}get isDone(){return this.k}get K(){return this.q}set cursor(e){this.B=e}done(){this.k=!0}$(e){this.q=e}delete(){return en(this.B.delete())}}class jr extends k{constructor(e,t){super(P.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function jt(r){return r.name==="IndexedDbTransactionError"}class YI{constructor(e){this.store=e}put(e,t){let n;return t!==void 0?(C("SimpleDb","PUT",this.store.name,e,t),n=this.store.put(t,e)):(C("SimpleDb","PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),en(n)}add(e){return C("SimpleDb","ADD",this.store.name,e,e),en(this.store.add(e))}get(e){return en(this.store.get(e)).next(t=>(t===void 0&&(t=null),C("SimpleDb","GET",this.store.name,e,t),t))}delete(e){return C("SimpleDb","DELETE",this.store.name,e),en(this.store.delete(e))}count(){return C("SimpleDb","COUNT",this.store.name),en(this.store.count())}U(e,t){const n=this.options(e,t),i=n.index?this.store.index(n.index):this.store;if(typeof i.getAll=="function"){const s=i.getAll(n.range);return new A((o,c)=>{s.onerror=u=>{c(u.target.error)},s.onsuccess=u=>{o(u.target.result)}})}{const s=this.cursor(n),o=[];return this.W(s,(c,u)=>{o.push(u)}).next(()=>o)}}G(e,t){const n=this.store.getAll(e,t===null?void 0:t);return new A((i,s)=>{n.onerror=o=>{s(o.target.error)},n.onsuccess=o=>{i(o.target.result)}})}j(e,t){C("SimpleDb","DELETE ALL",this.store.name);const n=this.options(e,t);n.H=!1;const i=this.cursor(n);return this.W(i,(s,o,c)=>c.delete())}J(e,t){let n;t?n=e:(n={},t=e);const i=this.cursor(n);return this.W(i,t)}Y(e){const t=this.cursor({});return new A((n,i)=>{t.onerror=s=>{const o=Wa(s.target.error);i(o)},t.onsuccess=s=>{const o=s.target.result;o?e(o.primaryKey,o.value).next(c=>{c?o.continue():n()}):n()}})}W(e,t){const n=[];return new A((i,s)=>{e.onerror=o=>{s(o.target.error)},e.onsuccess=o=>{const c=o.target.result;if(!c)return void i();const u=new JI(c),h=t(c.primaryKey,c.value,u);if(h instanceof A){const f=h.catch(m=>(u.done(),A.reject(m)));n.push(f)}u.isDone?i():u.K===null?c.continue():c.continue(u.K)}}).next(()=>A.waitFor(n))}options(e,t){let n;return e!==void 0&&(typeof e=="string"?n=e:t=e),{index:n,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){const n=this.store.index(e.index);return e.H?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function en(r){return new A((e,t)=>{r.onsuccess=n=>{const i=n.target.result;e(i)},r.onerror=n=>{const i=Wa(n.target.error);t(i)}})}let Pl=!1;function Wa(r){const e=xt.S(me());if(e>=12.2&&e<13){const t="An internal error was encountered in the Indexed Database server";if(r.message.indexOf(t)>=0){const n=new k("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Pl||(Pl=!0,setTimeout(()=>{throw n},0)),n}}return r}class XI{constructor(e,t){this.asyncQueue=e,this.Z=t,this.task=null}start(){this.X(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}X(e){C("IndexBackfiller",`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{C("IndexBackfiller",`Documents written: ${await this.Z.ee()}`)}catch(t){jt(t)?C("IndexBackfiller","Ignoring IndexedDB error during index backfill: ",t):await qt(t)}await this.X(6e4)})}}class ZI{constructor(e,t){this.localStore=e,this.persistence=t}async ee(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",t=>this.te(t,e))}te(e,t){const n=new Set;let i=t,s=!0;return A.doWhile(()=>s===!0&&i>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(o=>{if(o!==null&&!n.has(o))return C("IndexBackfiller",`Processing collection: ${o}`),this.ne(e,o,i).next(c=>{i-=c,n.add(o)});s=!1})).next(()=>t-i)}ne(e,t,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(i=>this.localStore.localDocuments.getNextDocuments(e,t,i,n).next(s=>{const o=s.changes;return this.localStore.indexManager.updateIndexEntries(e,o).next(()=>this.re(i,s)).next(c=>(C("IndexBackfiller",`Updating offset: ${c}`),this.localStore.indexManager.updateCollectionGroup(e,t,c))).next(()=>o.size)}))}re(e,t){let n=e;
1853return t.changes.forEach((i,s)=>{const o=Yd(s);Ka(o,n)>0&&(n=o)}),new $e(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}/**
1854 * @license
1855 * Copyright 2018 Google LLC
1856 *
1857 * Licensed under the Apache License, Version 2.0 (the "License");
1858 * you may not use this file except in compliance with the License.
1859 * You may obtain a copy of the License at
1860 *
1861 *   http://www.apache.org/licenses/LICENSE-2.0
1862 *
1863 * Unless required by applicable law or agreed to in writing, software
1864 * distributed under the License is distributed on an "AS IS" BASIS,
1865 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1866 * See the License for the specific language governing permissions and
1867 * limitations under the License.
1868 */class Oe{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=n=>this.ie(n),this.se=n=>t.writeSequenceNumber(n))}ie(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.se&&this.se(e),e}}Oe.oe=-1;function mi(r){return r==null}function ei(r){return r===0&&1/r==-1/0}function tf(r){return typeof r=="number"&&Number.isInteger(r)&&!ei(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}/**
1869 * @license
1870 * Copyright 2017 Google LLC
1871 *
1872 * Licensed under the Apache License, Version 2.0 (the "License");
1873 * you may not use this file except in compliance with the License.
1874 * You may obtain a copy of the License at
1875 *
1876 *   http://www.apache.org/licenses/LICENSE-2.0
1877 *
1878 * Unless required by applicable law or agreed to in writing, software
1879 * distributed under the License is distributed on an "AS IS" BASIS,
1880 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1881 * See the License for the specific language governing permissions and
1882 * limitations under the License.
1883 */function Ne(r){let e="";for(let t=0;t<r.length;t++)e.length>0&&(e=Cl(e)),e=eT(r.get(t),e);return Cl(e)}function eT(r,e){let t=e;const n=r.length;for(let i=0;i<n;i++){const s=r.charAt(i);switch(s){case"\0":t+="��";break;case"�":t+="��";break;default:t+=s}}return t}function Cl(r){return r+"��"}function et(r){const e=r.length;if(F(e>=2),e===2)return F(r.charAt(0)==="�"&&r.charAt(1)==="�"),Z.emptyPath();const t=e-2,n=[];let i="";for(let s=0;s<e;){const o=r.indexOf("�",s);switch((o<0||o>t)&&M(),r.charAt(o+1)){case"�":const c=r.substring(s,o);let u;i.length===0?u=c:(i+=c,u=i,i=""),n.push(u);break;case"�":i+=r.substring(s,o),i+="\0";break;case"�":i+=r.substring(s,o+1);break;default:M()}s=o+2}return new Z(n)}/**
1884 * @license
1885 * Copyright 2022 Google LLC
1886 *
1887 * Licensed under the Apache License, Version 2.0 (the "License");
1888 * you may not use this file except in compliance with the License.
1889 * You may obtain a copy of the License at
1890 *
1891 *   http://www.apache.org/licenses/LICENSE-2.0
1892 *
1893 * Unless required by applicable law or agreed to in writing, software
1894 * distributed under the License is distributed on an "AS IS" BASIS,
1895 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1896 * See the License for the specific language governing permissions and
1897 * limitations under the License.
1898 */const Dl=["userId","batchId"];/**
1899 * @license
1900 * Copyright 2022 Google LLC
1901 *
1902 * Licensed under the Apache License, Version 2.0 (the "License");
1903 * you may not use this file except in compliance with the License.
1904 * You may obtain a copy of the License at
1905 *
1906 *   http://www.apache.org/licenses/LICENSE-2.0
1907 *
1908 * Unless required by applicable law or agreed to in writing, software
1909 * distributed under the License is distributed on an "AS IS" BASIS,
1910 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1911 * See the License for the specific language governing permissions and
1912 * limitations under the License.
1913 */function ss(r,e){return[r,Ne(e)]}function nf(r,e,t){return[r,Ne(e),t]}const tT={},nT=["prefixPath","collectionGroup","readTime","documentId"],rT=["prefixPath","collectionGroup","documentId"],iT=["collectionGroup","readTime","prefixPath","documentId"],sT=["canonicalId","targetId"],oT=["targetId","path"],aT=["path","targetId"],cT=["collectionId","parent"],uT=["indexId","uid"],lT=["uid","sequenceNumber"],hT=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],dT=["indexId","uid","orderedDocumentKey"],fT=["userId","collectionPath","documentId"],pT=["userId","collectionPath","largestBatchId"],mT=["userId","collectionGroup","largestBatchId"],rf=["mutation
1913Queues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],gT=[...rf,"documentOverlays"],sf=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],of=sf,Ha=[...of,"indexConfiguration","indexState","indexEntries"],_T=Ha,yT=[...Ha,"globals"];/**
1914 * @license
1915 * Copyright 2020 Google LLC
1916 *
1917 * Licensed under the Apache License, Version 2.0 (the "License");
1918 * you may not use this file except in compliance with the License.
1919 * You may obtain a copy of the License at
1920 *
1921 *   http://www.apache.org/licenses/LICENSE-2.0
1922 *
1923 * Unless required by applicable law or agreed to in writing, software
1924 * distributed under the License is distributed on an "AS IS" BASIS,
1925 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1926 * See the License for the specific language governing permissions and
1927 * limitations under the License.
1928 */class ca extends Zd{constructor(e,t){super(),this._e=e,this.currentSequenceNumber=t}}function ge(r,e){const t=L(r);return xt.F(t._e,e)}/**
1929 * @license
1930 * Copyright 2017 Google LLC
1931 *
1932 * Licensed under the Apache License, Version 2.0 (the "License");
1933 * you may not use this file except in compliance with the License.
1934 * You may obtain a copy of the License at
1935 *
1936 *   http://www.apache.org/licenses/LICENSE-2.0
1937 *
1938 * Unless required by applicable law or agreed to in writing, software
1939 * distributed under the License is distributed on an "AS IS" BASIS,
1940 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1941 * See the License for the specific language governing permissions and
1942 * limitations under the License.
1943 */function Vl(r){let e=0;for(const t in r)Object.prototype.hasOwnProperty.call(r,t)&&e++;return e}function An(r,e){for(const t in r)Object.prototype.hasOwnProperty.call(r,t)&&e(t,r[t])}function af(r){for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e))return!1;return!0}/**
1944 * @license
1945 * Copyright 2017 Google LLC
1946 *
1947 * Licensed under the Apache License, Version 2.0 (the "License");
1948 * you may not use this file except in compliance with the License.
1949 * You may obtain a copy of the License at
1950 *
1951 *   http://www.apache.org/licenses/LICENSE-2.0
1952 *
1953 * Unless required by applicable law or agreed to in writing, software
1954 * distributed under the License is distributed on an "AS IS" BASIS,
1955 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1956 * See the License for the specific language governing permissions and
1957 * limitations under the License.
1958 */class ie{constructor(e,t){this.comparator=e,this.root=t||Te.EMPTY}insert(e,t){return new ie(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Te.BLACK,null,null))}remove(e){return new ie(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Te.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const n=this.comparator(e,t.key);if(n===0)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){const i=this.comparator(e,n.key);if(i===0)return t+n.left.size;i<0?n=n.left:(t+=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(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,n)=>(e(t,n),!1))}toString(){const e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Wi(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Wi(this.root,e,this.comparator,!1)}getReverseIterator(){return new Wi(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Wi(this.root,e,this.comparator,!0)}}class Wi{constructor(e,t,n,i){this.isReverse=i,this.nodeStack=[];let s=1;for(;!e.isEmpty();)if(s=t?n(e.key,t):1,t&&i&&(s*=-1),s<0)e=this.isReverse?e.left:e.right;else{if(s===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class Te{constructor(e,t,n,i,s){this.key=e,this.value=t,this.color=n??Te.RED,this.left=i??Te.EMPTY,this.right=s??Te.EMPTY,this.size=this.left.size+1+this.right.size}
1958copy(e,t,n,i,s){return new Te(e??this.key,t??this.value,n??this.color,i??this.left,s??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}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(e,t,n){let i=this;const s=n(e,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(e,t,n),null):s===0?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,n)),i.fixUp()}removeMin(){if(this.left.isEmpty())return Te.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,i=this;if(t(e,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(e,t),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),t(e,i.key)===0){if(i.right.isEmpty())return Te.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(e,t))}return i.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,Te.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,Te.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw M();const e=this.left.check();if(e!==this.right.check())throw M();return e+(this.isRed()?0:1)}}Te.EMPTY=null,Te.RED=!0,Te.BLACK=!1;Te.EMPTY=new class{constructor(){this.size=0}get key(){throw M()}get value(){throw M()}get color(){throw M()}get left(){throw M()}get right(){throw M()}copy(e,t,n,i,s){return this}insert(e,t,n){return new Te(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
1959 * @license
1960 * Copyright 2017 Google LLC
1961 *
1962 * Licensed under the Apache License, Version 2.0 (the "License");
1963 * you may not use this file except in compliance with the License.
1964 * You may obtain a copy of the License at
1965 *
1966 *   http://www.apache.org/licenses/LICENSE-2.0
1967 *
1968 * Unless required by applicable law or agreed to in writing, software
1969 * distributed under the License is distributed on an "AS IS" BASIS,
1970 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1971 * See the License for the specific language governing permissions and
1972 * limitations under the License.
1973 */class te{constructor(e){this.comparator=e,this.data=new ie(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,e[1])>=0)return;t(i.key)}}forEachWhile(e,t){let n;for(n=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new kl(this.data.getIterator())}getIteratorFrom(e){return new kl(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(n=>{t=t.add(n)}),t}isEqual(e){if(!(e instanceof te)||this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const i=t.getNext().key,s=n.getNext().key;if(this.comparator(i,s)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new te(this.comparator);return t.data=e,t}}
1973class kl{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function Dn(r){return r.hasNext()?r.getNext():void 0}/**
1974 * @license
1975 * Copyright 2020 Google LLC
1976 *
1977 * Licensed under the Apache License, Version 2.0 (the "License");
1978 * you may not use this file except in compliance with the License.
1979 * You may obtain a copy of the License at
1980 *
1981 *   http://www.apache.org/licenses/LICENSE-2.0
1982 *
1983 * Unless required by applicable law or agreed to in writing, software
1984 * distributed under the License is distributed on an "AS IS" BASIS,
1985 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1986 * See the License for the specific language governing permissions and
1987 * limitations under the License.
1988 */class Me{constructor(e){this.fields=e,e.sort(ce.comparator)}static empty(){return new Me([])}unionWith(e){let t=new te(ce.comparator);for(const n of this.fields)t=t.add(n);for(const n of e)t=t.add(n);return new Me(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Kn(this.fields,e.fields,(t,n)=>t.isEqual(n))}}/**
1989 * @license
1990 * Copyright 2023 Google LLC
1991 *
1992 * Licensed under the Apache License, Version 2.0 (the "License");
1993 * you may not use this file except in compliance with the License.
1994 * You may obtain a copy of the License at
1995 *
1996 *   http://www.apache.org/licenses/LICENSE-2.0
1997 *
1998 * Unless required by applicable law or agreed to in writing, software
1999 * distributed under the License is distributed on an "AS IS" BASIS,
2000 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2001 * See the License for the specific language governing permissions and
2002 * limitations under the License.
2003 */class cf extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
2004 * @license
2005 * Copyright 2020 Google LLC
2006 *
2007 * Licensed under the Apache License, Version 2.0 (the "License");
2008 * you may not use this file except in compliance with the License.
2009 * You may obtain a copy of the License at
2010 *
2011 *   http://www.apache.org/licenses/LICENSE-2.0
2012 *
2013 * Unless required by applicable law or agreed to in writing, software
2014 * distributed under the License is distributed on an "AS IS" BASIS,
2015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2016 * See the License for the specific language governing permissions and
2017 * limitations under the License.
2018 */class fe{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(i){try{return atob(i)}catch(s){throw typeof DOMException<"u"&&s instanceof DOMException?new cf("Invalid base64 string: "+s):s}}(e);return new fe(t)}static fromUint8Array(e){const t=function(i){let s="";for(let o=0;o<i.length;++o)s+=String.fromCharCode(i[o]);return s}(e);return new fe(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){const n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return G(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}fe.EMPTY_BYTE_STRING=new fe("");const IT=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function gt(r){if(F(!!r),typeof r=="string"){let e=0;const t=IT.exec(r);if(F(!!t),t[1]){let i=t[1];i=(i+"000000000").substr(0,9),e=Number(i)}const n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:e}}return{seconds:oe(r.seconds),nanos:oe(r.nanos)}}function oe(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function Mt(r){return typeof r=="string"?fe.fromBase64String(r):fe.fromUint8Array(r)}/**
2019 * @license
2020 * Copyright 2020 Google LLC
2021 *
2022 * Licensed under the Apache License, Version 2.0 (the "License");
2023 * you may not use this file except in compliance with the License.
2024 * You may obtain a copy of the License at
2025 *
2026 *   http://www.apache.org/licenses/LICENSE-2.0
2027 *
2028 * Unless required by applicable law or agreed to in writing, softw
2028are
2029 * distributed under the License is distributed on an "AS IS" BASIS,
2030 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2031 * See the License for the specific language governing permissions and
2032 * limitations under the License.
2033 */function Qa(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="server_timestamp"}function Ja(r){const e=r.mapValue.fields.__previous_value__;return Qa(e)?Ja(e):e}function ti(r){const e=gt(r.mapValue.fields.__local_write_time__.timestampValue);return new ue(e.seconds,e.nanos)}/**
2034 * @license
2035 * Copyright 2017 Google LLC
2036 *
2037 * Licensed under the Apache License, Version 2.0 (the "License");
2038 * you may not use this file except in compliance with the License.
2039 * You may obtain a copy of the License at
2040 *
2041 *   http://www.apache.org/licenses/LICENSE-2.0
2042 *
2043 * Unless required by applicable law or agreed to in writing, software
2044 * distributed under the License is distributed on an "AS IS" BASIS,
2045 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2046 * See the License for the specific language governing permissions and
2047 * limitations under the License.
2048 */class TT{constructor(e,t,n,i,s,o,c,u,h){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=i,this.ssl=s,this.forceLongPolling=o,this.autoDetectLongPolling=c,this.longPollingOptions=u,this.useFetchStreams=h}}class dn{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new dn("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(e){return e instanceof dn&&e.projectId===this.projectId&&e.database===this.database}}/**
2049 * @license
2050 * Copyright 2020 Google LLC
2051 *
2052 * Licensed under the Apache License, Version 2.0 (the "License");
2053 * you may not use this file except in compliance with the License.
2054 * You may obtain a copy of the License at
2055 *
2056 *   http://www.apache.org/licenses/LICENSE-2.0
2057 *
2058 * Unless required by applicable law or agreed to in writing, software
2059 * distributed under the License is distributed on an "AS IS" BASIS,
2060 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2061 * See the License for the specific language governing permissions and
2062 * limitations under the License.
2063 */const Vt={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},os={nullValue:"NULL_VALUE"};function fn(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?Qa(r)?4:uf(r)?9007199254740991:js(r)?10:11:M()}function it(r,e){if(r===e)return!0;const t=fn(r);if(t!==fn(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===e.booleanValue;case 4:return ti(r).isEqual(ti(e));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 o=gt(i.timestampValue),c=gt(s.timestampValue);return o.seconds===c.seconds&&o.nanos===c.nanos}(r,e);case 5:return r.stringValue===e.stringValue;case 6:return function(i,s){return Mt(i.bytesValue).isEqual(Mt(s.bytesValue))}(r,e);case 7:return r.referenceValue===e.referenceValue;case 8:return function(i,s){return oe(i.geoPointValue.latitude)===oe(s.geoPointValue.latitude)&&oe(i.geoPointValue.longitude)===oe(s.geoPointValue.longitude)}(r,e);case 2:return function(i,s){if("integerValue"in i&&"integerValue"in s)return oe(i.integerValue)===oe(s.integerValue);if("doubleValue"in i&&"doubleValue"in s){const o=oe(i.doubleValue),c=oe(s.doubleValue);return o===c?ei(o)===ei(c):isNaN(o)&&isNaN(c)}return!1}(r,e);case 9:return Kn(r.arrayValue.values||[],e.arrayValue.values||[],it);case 10:case 11:return function(i,s){const o=i.mapValue.fields||{},c=s.mapValue.fields||{};if(Vl(o)!==Vl(c))return!1;for(const u in o)if(o.hasOwnProperty(u)&&(c[u]===void 0||!it(o[u],c[u])))return!1;return!0}(r,e);default:return M()}}function ni(r,e){return(r.values||[]).find(t=>it(t,e))!==void 0}function Lt(r,e){if(r===e)return 0;const t=fn(r),n=fn(e);if(t!==n)return G(t,n);switch(t){case 0:case 9007199254740991:return 0;case 1:return G(r.booleanValue,e.booleanValue);case 2:return function(s,o){const c=oe(s.integerValue||s.doubleValue),u=oe(o.integerValue||o.doubleValue);return c<u?-1:c>u?1:c===u?0:isNaN(c)?isNaN(u)?0:-1:1}(r,e);case 3:return Nl(r.timestampValue,e.timestampValue);case 4:return Nl(ti(r),ti(e));case 5:return G(r.stringValue,e.stringValue);case 6:return function(s,o){const c=Mt(s),u=Mt(o);return c.compareTo(u)}(r.bytesValue,e.bytesValue);case 7:return function(s,o){const c=s.split("/"),u=o.split("/");for(let h=0;h<c.length&&h<u.length;h++){const f=G(c[h],u[h]);if(f!==0)return f}return G(c.length,u.length)}(r.referenceValue,e.referenceValue);case 8:return function(s,o){const c=G(oe(s.latitude),oe(o.latitude));return c!==0?c:G(oe(s.longitude),oe(o.longitude))}(r.geoPointValue,e.geoPointValue);case 9:return xl(r.arrayValue,e.arrayValue);case 10:return function(s,o){var c,u,h,f;const m=s.fields||{},_=o.fields||{},b=(c=m.value)===null||c===void 0?void 0:c.arrayValue,V=(u=_.value)===null||u===void 0?void 0:u.arrayValue,N=G(((h=b==null?void 0:b.values)===null||h===void 0?void 0:h.length)||0,((f=V==null?void 0:V.values)===null||f===void 0?void 0:f.length)||0);return N!==0?N:xl(b,V)}(r.mapValue,e.mapValue);case 11:return function(s,o){if(s===Vt.mapValue&&o===Vt.mapValue)return 0;if(s===Vt.mapValue)return 1;if(o===Vt.mapValue)return-1;const c=s.fields||{},u=Object.keys(c),h=o.fields||{},f=Object.keys(h);u.sort(),f.sort();for(let m=0;m<u.length&&m<f.length;++m){const _=G(u[m],f[m]);if(_!==0)return _;const b=Lt(c[u[m]],h[f[m]]);if(b!==0)return b}return G(u.length,f.length)}(r.mapValue,e.mapValue);default:throw M()}}function Nl(r,e){if(typeof r=="string"&&typeof e=="string"&&r.length===e.length)return G(r,e);const t=gt(r),n=gt(e),i=G(t.seconds,n.seconds);return i!==0?i:G(t.nanos,n.nanos)}function xl(r,e){const t=r.values||[],n=e.values||[];for(let i=0;i<t.length&&i<n.length;++i){const s=Lt(t[i],n[i]);if(s)return s}return G(t.length,n.length)}function Wn(r){return ua(r)}function ua(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(t){const n=gt(t);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(t){return Mt(t).toBase64()}(r.bytesValue):"referenceValue"in r?function(t){return O.fromName(t).toString()}(r.referenceValue):"geoPointValue"in r?function(t){return`geo(${t.latitude},${t.longitude})`}(r.geoPointValue):"arrayValue"in r?function(t){let n="[",i=!0;for(const s of t.values||[])i?i=!1:n+=",",n+=ua(s);return n+"]"}(r.arrayValue):"mapValue"in r?function(t){const n=Object.keys(t.fields||{}).sort();let i="{",s=!0;for(const o of n)s?s=!1:i+=",",i+=`${o}:${ua(t.fields[o])}`;return i+"}"}(r.mapValue):M()}function ri(r,e){return{referenceValue:`projects/${r.projectId}/databases/${r.database}/documents/${e.path.canonicalString()}`}}function la(r){return!!r&&"integerValue"in r}function ii(r){return!!r&&"arrayValue"in r}function Ol(r){return!!r&&"nullValue"in r}function Ml(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function as(r){return!!r&&"mapValue"in r}function js(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="__vector__"}function $r(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 e={mapValue:{fields:{}}};return An(r.mapValue.fields,(t,n)=>e.mapValue.fields[t]=$r(n)),e}if(r.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(r.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=$r(r.arrayValue.values[t]);return e}return Object.assign({},r)}function uf(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}const lf={mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{}}}}};function ET(r){return"nullValue"in r?os:"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:""}
2063:"bytesValue"in r?{bytesValue:""}:"referenceValue"in r?ri(dn.empty(),O.empty()):"geoPointValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in r?{arrayValue:{}}:"mapValue"in r?js(r)?lf:{mapValue:{}}:M()}function vT(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?ri(dn.empty(),O.empty()):"referenceValue"in r?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in r?{arrayValue:{}}:"arrayValue"in r?lf:"mapValue"in r?js(r)?{mapValue:{}}:Vt:M()}function Ll(r,e){const t=Lt(r.value,e.value);return t!==0?t:r.inclusive&&!e.inclusive?-1:!r.inclusive&&e.inclusive?1:0}function Fl(r,e){const t=Lt(r.value,e.value);return t!==0?t:r.inclusive&&!e.inclusive?1:!r.inclusive&&e.inclusive?-1:0}/**
2064 * @license
2065 * Copyright 2017 Google LLC
2066 *
2067 * Licensed under the Apache License, Version 2.0 (the "License");
2068 * you may not use this file except in compliance with the License.
2069 * You may obtain a copy of the License at
2070 *
2071 *   http://www.apache.org/licenses/LICENSE-2.0
2072 *
2073 * Unless required by applicable law or agreed to in writing, software
2074 * distributed under the License is distributed on an "AS IS" BASIS,
2075 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2076 * See the License for the specific language governing permissions and
2077 * limitations under the License.
2078 */class Ee{constructor(e){this.value=e}static empty(){return new Ee({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!as(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=$r(t)}setAll(e){let t=ce.emptyPath(),n={},i=[];e.forEach((o,c)=>{if(!t.isImmediateParentOf(c)){const u=this.getFieldsMap(t);this.applyChanges(u,n,i),n={},i=[],t=c.popLast()}o?n[c.lastSegment()]=$r(o):i.push(c.lastSegment())});const s=this.getFieldsMap(t);this.applyChanges(s,n,i)}delete(e){const t=this.field(e.popLast());as(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return it(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let i=t.mapValue.fields[e.get(n)];as(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=i),t=i}return t.mapValue.fields}applyChanges(e,t,n){An(t,(i,s)=>e[i]=s);for(const i of n)delete e[i]}clone(){return new Ee($r(this.value))}}function hf(r){const e=[];return An(r.fields,(t,n)=>{const i=new ce([t]);if(as(n)){const s=hf(n.mapValue).fields;
2078if(s.length===0)e.push(i);else for(const o of s)e.push(i.child(o))}else e.push(i)}),new Me(e)}/**
2079 * @license
2080 * Copyright 2017 Google LLC
2081 *
2082 * Licensed under the Apache License, Version 2.0 (the "License");
2083 * you may not use this file except in compliance with the License.
2084 * You may obtain a copy of the License at
2085 *
2086 *   http://www.apache.org/licenses/LICENSE-2.0
2087 *
2088 * Unless required by applicable law or agreed to in writing, software
2089 * distributed under the License is distributed on an "AS IS" BASIS,
2090 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2091 * See the License for the specific language governing permissions and
2092 * limitations under the License.
2093 */class ae{constructor(e,t,n,i,s,o,c){this.key=e,this.documentType=t,this.version=n,this.readTime=i,this.createTime=s,this.data=o,this.documentState=c}static newInvalidDocument(e){return new ae(e,0,B.min(),B.min(),B.min(),Ee.empty(),0)}static newFoundDocument(e,t,n,i){return new ae(e,1,t,B.min(),n,i,0)}static newNoDocument(e,t){return new ae(e,2,t,B.min(),B.min(),Ee.empty(),0)}static newUnknownDocument(e,t){return new ae(e,3,t,B.min(),B.min(),Ee.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(B.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Ee.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Ee.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=B.min(),this}setReadTime(e){return this.readTime=e,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(e){return e instanceof ae&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new ae(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}})`}}/**
2094 * @license
2095 * Copyright 2022 Google LLC
2096 *
2097 * Licensed under the Apache License, Version 2.0 (the "License");
2098 * you may not use this file except in compliance with the License.
2099 * You may obtain a copy of the License at
2100 *
2101 *   http://www.apache.org/licenses/LICENSE-2.0
2102 *
2103 * Unless required by applicable law or agreed to in writing, software
2104 * distributed under the License is distributed on an "AS IS" BASIS,
2105 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2106 * See the License for the specific language governing permissions and
2107 * limitations under the License.
2108 */class Hn{constructor(e,t){this.position=e,this.inclusive=t}}function Ul(r,e,t){let n=0;for(let i=0;i<r.position.length;i++){const s=e[i],o=r.position[i];if(s.field.isKeyField()?n=O.comparator(O.fromName(o.referenceValue),t.key):n=Lt(o,t.data.field(s.field)),s.dir==="desc"&&(n*=-1),n!==0)break}return n}function Bl(r,e){if(r===null)return e===null;if(e===null||r.inclusive!==e.inclusive||r.position.length!==e.position.length)return!1;for(let t=0;t<r.position.length;t++)if(!it(r.position[t],e.position[t]))return!1;return!0}/**
2109 * @license
2110 * Copyright 2022 Google LLC
2111 *
2112 * Licensed under the Apache License, Version 2.0 (the "License");
2113 * you may not use this file except in compliance with the License.
2114 * You may obtain a copy of the License at
2115 *
2116 *   http://www.apache.org/licenses/LICENSE-2.0
2117 *
2118 * Unless required by applicable law or agreed to in writing, softw
2118are
2119 * distributed under the License is distributed on an "AS IS" BASIS,
2120 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2121 * See the License for the specific language governing permissions and
2122 * limitations under the License.
2123 */class si{constructor(e,t="asc"){this.field=e,this.dir=t}}function wT(r,e){return r.dir===e.dir&&r.field.isEqual(e.field)}/**
2124 * @license
2125 * Copyright 2022 Google LLC
2126 *
2127 * Licensed under the Apache License, Version 2.0 (the "License");
2128 * you may not use this file except in compliance with the License.
2129 * You may obtain a copy of the License at
2130 *
2131 *   http://www.apache.org/licenses/LICENSE-2.0
2132 *
2133 * Unless required by applicable law or agreed to in writing, software
2134 * distributed under the License is distributed on an "AS IS" BASIS,
2135 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2136 * See the License for the specific language governing permissions and
2137 * limitations under the License.
2138 */class df{}class Q extends df{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,n):new AT(e,t,n):t==="array-contains"?new ST(e,n):t==="in"?new yf(e,n):t==="not-in"?new PT(e,n):t==="array-contains-any"?new CT(e,n):new Q(e,t,n)}static createKeyFieldInFilter(e,t,n){return t==="in"?new RT(e,n):new bT(e,n)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(Lt(t,this.value)):t!==null&&fn(this.value)===fn(t)&&this.matchesComparison(Lt(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return M()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class ee extends df{constructor(e,t){super(),this.filters=e,this.op=t,this.ae=null}static create(e,t){return new ee(e,t)}matches(e){return Qn(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ae!==null||(this.ae=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ae}getFilters(){return Object.assign([],this.filters)}}function Qn(r){return r.op==="and"}function ha(r){return r.op==="or"}function Ya(r){return ff(r)&&Qn(r)}function ff(r){for(const e of r.filters)if(e instanceof ee)return!1;return!0}function da(r){if(r instanceof Q)return r.field.canonicalString()+r.op.toString()+Wn(r.value);if(Ya(r))return r.filters.map(e=>da(e)).join(",");{const e=r.filters.map(t=>da(t)).join(",");return`${r.op}(${e})`}}function pf(r,e){return r instanceof Q?function(n,i){return i instanceof Q&&n.op===i.op&&n.field.isEqual(i.field)&&it(n.value,i.value)}(r,e):r instanceof ee?function(n,i){return i instanceof ee&&n.op===i.op&&n.filters.length===i.filters.length?n.filters.reduce((s,o,c)=>s&&pf(o,i.filters[c]),!0):!1}(r,e):void M()}function mf(r,e){const t=r.filters.concat(e);return ee.create(t,r.op)}function gf(r){return r instanceof Q?function(t){return`${t.field.canonicalString()} ${t.op} ${Wn(t.value)}`}(r):r instanceof ee?function(t){return t.op.toString()+" {"+t.getFilters().map(gf).join(" ,")+"}"}(r):"Filter"}class AT extends Q{constructor(e,t,n){super(e,t,n),this.key=O.fromName(n.referenceValue)}matches(e){const t=O.comparator(e.key,this.key);return this.matchesComparison(t)}}class RT extends Q{constructor(e,t){super(e,"in",t),this.keys=_f("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class bT extends Q{constructor(e,t){super(e,"not-in",t),this.keys=_f("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function _f(r,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(n=>O.fromName(n.referenceValue))}class ST extends Q{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return ii(t)&&ni(t.arrayValue,this.value)}}class yf extends Q{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&ni(this.value.arrayValue,t)}}class PT extends Q{constructor(e,t){super(e,"not-in",t)}matches(e){if(ni(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&!ni(this.value.arrayValue,t)}}class CT extends Q{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!ii(t)||!t.arrayValue.values)&&t.arrayValue.values.some(n=>ni(this.value.arrayValue,n))}}/**
2139 * @license
2140 * Copyright 2019 Google LLC
2141 *
2142 * Licensed under the Apache License, Version 2.0 (the "License");
2143 * you may not use this file except in compliance with the License.
2144 * You may obtain a copy of the License at
2145 *
2146 *   http://www.apache.org/licenses/LICENSE-2.0
2147 *
2148 * Unless required by applicable law or agreed to in writing, software
2149 * distributed under the License is distributed on an "AS IS" BASIS,
2150 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2151 * See the License for the specific language governing permissions and
2152 * limitations under the License.
2153 */class DT{constructor(e,t=null,n=[],i=[],s=null,o=null,c=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=i,this.limit=s,this.startAt=o,this.endAt=c,this.ue=null}}function fa(r,e=null,t=[],n=[],i=null,s=null,o=null){return new DT(r,e,t,n,i,s,o)}function pn(r){const e=L(r);if(e.ue===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(n=>da(n)).join(","),t+="|ob:",t+=e.orderBy.map(n=>function(s){return s.field.canonicalString()+s.dir}(n)).join(","),mi(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(n=>Wn(n)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(n=>Wn(n)).join(",")),e.ue=t}return e.ue}function gi(r,e){if(r.limit!==e.limit||r.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<r.orderBy.length;t++)if(!wT(r.orderBy[t],e.orderBy[t]))return!1;if(r.filters.length!==e.filters.length)return!1;for(let t=0;t<r.filters.length;t++)if(!pf(r.filters[t],e.filters[t]))return!1;return r.collectionGroup===e.collectionGroup&&!!r.path.isEqual(e.path)&&!!Bl(r.startAt,e.startAt)&&Bl(r.endAt,e.endAt)}function Ts(r){return O.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}function Es(r,e){return r.filters.filter(t=>t instanceof Q&&t.field.isEqual(e))}function ql(r,e,t){let n=os,i=!0;for(const s of Es(r,e)){let o=os,c=!0;switch(s.op){case"<":case"<=":o=ET(s.value);break;case"==":case"in":case">=":o=s.value;break;case">":o=s.value,c=!1;break;case"!=":case"not-in":o=os}Ll({value:n,inclusive:i},{value:o,inclusive:c})<0&&(n=o,i=c)}if(t!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(e)){const o=t.position[s];Ll({value:n,inclusive:i},{value:o,inclusive:t.inclusive})<0&&(n=o,i=t.inclusive);break}}return{value:n,inclusive:i}}function jl(r,e,t){let n=Vt,i=!0;for(const s of Es(r,e)){let o=Vt,c=!0;switch(s.op){case">=":case">":o=vT(s.value),c=!1;break;case"==":case"in":case"<=":o=s.value;break;case"<":o=s.value,c=!1;break;case"!=":case"not-in":o=Vt}Fl({value:n,inclusive:i},{value:o,inclusive:c})>0&&(n=o,i=c)}if(t!==null){for(let s=0;s<r.orderBy.length;++s)if(r.orderBy[s].field.isEqual(e)){const o=t.position[s];Fl({value:n,inclusive:i},{value:o,inclusive:t.inclusive})>0&&(n=o,i=t.inclusive);break}}return{value:n,inclusive:i}}/**
2154 * @license
2155 * Copyright 2017 Google LLC
2156 *
2157 * Licensed under the Apache License, Version 2.0 (the "License");
2158 * you may not use this file except in compliance with the License.
2159 * You may obtain a copy of the License at
2160 *
2161 *   http://www.apache.org/licenses/LICENSE-2.0
2162 *
2163 * Unless required by applicable law or agreed to in writing, software
2164 * distributed under the License is distributed on an "AS IS" BASIS,
2165 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2166 * See the License for the specific language governing permissions and
2167 * limitations under the License.
2168 */class ar{constructor(e,t=null,n=[],i=[],s=null,o="F",c=null,u=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=i,this.limit=s,this.limitType=o,this.startAt=c,this.endAt=u,this.ce=null,this.le=null,this.he=null,this.startAt,this.endAt}}function If(r,e,t,n,i,s,o,c){return new ar(r,e,t,n,i,s,o,c)}function $s(r){return new ar(r)}function $l(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 Tf(r){return r.collectionGroup!==null}function zr(r){const e=L(r);if(e.ce===null){e.ce=[];const t=new Set;for(const s of e.explicitOrderBy)e.ce.push(s),t.add(s.field.canonicalString());const n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(o){let c=new te(ce.comparator);
2168return o.filters.forEach(u=>{u.getFlattenedFilters().forEach(h=>{h.isInequality()&&(c=c.add(h.field))})}),c})(e).forEach(s=>{t.has(s.canonicalString())||s.isKeyField()||e.ce.push(new si(s,n))}),t.has(ce.keyField().canonicalString())||e.ce.push(new si(ce.keyField(),n))}return e.ce}function qe(r){const e=L(r);return e.le||(e.le=VT(e,zr(r))),e.le}function VT(r,e){if(r.limitType==="F")return fa(r.path,r.collectionGroup,e,r.filters,r.limit,r.startAt,r.endAt);{e=e.map(i=>{const s=i.dir==="desc"?"asc":"desc";return new si(i.field,s)});const t=r.endAt?new Hn(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new Hn(r.startAt.position,r.startAt.inclusive):null;return fa(r.path,r.collectionGroup,e,r.filters,r.limit,t,n)}}function pa(r,e){const t=r.filters.concat([e]);return new ar(r.path,r.collectionGroup,r.explicitOrderBy.slice(),t,r.limit,r.limitType,r.startAt,r.endAt)}function vs(r,e,t){return new ar(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),e,t,r.startAt,r.endAt)}function zs(r,e){return gi(qe(r),qe(e))&&r.limitType===e.limitType}function Ef(r){return`${pn(qe(r))}|lt:${r.limitType}`}function On(r){return`Query(target=${function(t){let n=t.path.canonicalString();return t.collectionGroup!==null&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=`, filters: [${t.filters.map(i=>gf(i)).join(", ")}]`),mi(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=`, orderBy: [${t.orderBy.map(i=>function(o){return`${o.field.canonicalString()} (${o.dir})`}(i)).join(", ")}]`),t.startAt&&(n+=", startAt: ",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map(i=>Wn(i)).join(",")),t.endAt&&(n+=", endAt: ",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(i=>Wn(i)).join(",")),`Target(${n})`}(qe(r))}; limitType=${r.limitType})`}function _i(r,e){return e.isFoundDocument()&&function(n,i){const s=i.key.path;return n.collectionGroup!==null?i.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(s):O.isDocumentKey(n.path)?n.path.isEqual(s):n.path.isImmediateParentOf(s)}(r,e)&&function(n,i){for(const s of zr(n))if(!s.field.isKeyField()&&i.data.field(s.field)===null)return!1;return!0}(r,e)&&function(n,i){for(const s of n.filters)if(!s.matches(i))return!1;return!0}(r,e)&&function(n,i){return!(n.startAt&&!function(o,c,u){const h=Ul(o,c,u);return o.inclusive?h<=0:h<0}(n.startAt,zr(n),i)||n.endAt&&!function(o,c,u){const h=Ul(o,c,u);return o.inclusive?h>=0:h>0}(n.endAt,zr(n),i))}(r,e)}function vf(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function wf(r){return(e,t)=>{let n=!1;for(const i of zr(r)){const s=kT(i,e,t);if(s!==0)return s;n=n||i.field.isKeyField()}return 0}}function kT(r,e,t){const n=r.field.isKeyField()?O.comparator(e.key,t.key):function(s,o,c){const u=o.data.field(s),h=c.data.field(s);return u!==null&&h!==null?Lt(u,h):M()}(r.field,e,t);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return M()}}/**
2169 * @license
2170 * Copyright 2017 Google LLC
2171 *
2172 * Licensed under the Apache License, Version 2.0 (the "License");
2173 * you may not use this file except in compliance with the License.
2174 * You may obtain a copy of the License at
2175 *
2176 *   http://www.apache.org/licenses/LICENSE-2.0
2177 *
2178 * Unless required by applicable law or agreed to in writing, software
2179 * distributed under the License is distributed on an "AS IS" BASIS,
2180 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2181 * See the License for the specific language governing permissions and
2182 * limitations under the License.
2183 */class $t{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(n!==void 0){for(const[i,s]of n)if(this.equalsFn(i,e))return s}}has(e){return this.get(e)!==void 0}set(e,t){const n=this.mapKeyFn(e),i=this.inner[n];if(i===void 0)return this.inner[n]=[[e,t]],void this.innerSize++;for(let s=0;s<i.length;s++)if(this.equalsFn(i[s][0],e))return void(i[s]=[e,t]);i.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),n=this.inner[t];if(n===void 0)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],e))return n.length===1?delete this.inner[t]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(e){An(this.inner,(t,n)=>{for(const[i,s]of n)e(i,s)})}isEmpty(){return af(this.inner)}size(){return this.innerSize}}/**
2184 * @license
2185 * Copyright 2017 Google LLC
2186 *
2187 * Licensed under the Apache License, Version 2.0 (the "License");
2188 * you may not use this file except in compliance with the License.
2189 * You may obtain a copy of the License at
2190 *
2191 *   http://www.apache.org/licenses/LICENSE-2.0
2192 *
2193 * Unless required by applicable law or agreed to in writing, software
2194 * distributed under the License is distributed on an "AS IS" BASIS,
2195 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2196 * See the License for the specific language governing permissions and
2197 * limitations under the License.
2198 */const NT=new ie(O.comparator);function Be(){return NT}const Af=new ie(O.comparator);function Fr(...r){let e=Af;for(const t of r)e=e.insert(t.key,t);return e}function Rf(r){let e=Af;return r.forEach((t,n)=>e=e.insert(t,n.overlayedDocument)),e}function tt(){return Gr()}function bf(){return Gr()}function Gr(){return new $t(r=>r.toString(),(r,e)=>r.isEqual(e))}const xT=new ie(O.comparator),OT=new te(O.comparator);function W(...r){let e=OT;for(const t of r)e=e.add(t);return e}const MT=new te(G);function Xa(){return MT}/**
2199 * @license
2200 * Copyright 2020 Google LLC
2201 *
2202 * Licensed under the Apache License, Version 2.0 (the "License");
2203 * you may not use this file except in compliance with the License.
2204 * You may obtain a copy of the License at
2205 *
2206 *   http://www.apache.org/licenses/LICENSE-2.0
2207 *
2208 * Unless required by applicable law or agreed to in writing, software
2209 * distributed under the License is distributed on an "AS IS" BASIS,
2210 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2211 * See the License for the specific language governing permissions and
2212 * limitations under the License.
2213 */function Za(r,e){if(r.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:ei(e)?"-0":e}}function Sf(r){return{integerValue:""+r}}function Pf(r,e){return tf(e)?Sf(e):Za(r,e)}/**
2214 * @license
2215 * Copyright 2018 Google LLC
2216 *
2217 * Licensed under the Apache License, Version 2.0 (the "License");
2218 * you may not use this file except in compliance with the License.
2219 * You may obtain a copy of the License at
2220 *
2221 *   http://www.apache.org/licenses/LICENSE-2.0
2222 *
2223 * Unless required by applicable law or agreed to in writing, software
2224 * distributed under the License is distributed on an "AS IS" BASIS,
2225 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2226 * See the License for the specific language governing permissions and
2227 * limitations under the License.
2228 */class Gs{constructor(){this._=void 0}}function LT(r,e,t){return r instanceof Jn?function(i,s){const o={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return s&&Qa(s)&&(s=Ja(s)),s&&(o.fields.__previous_value__=s),{mapValue:o}}(t,e):r instanceof Yn?Df(r,e):r instanceof Xn?Vf(r,e):function(i,s){const o=Cf(i,s),c=zl(o)+zl(i.Pe);return la(o)&&la(i.Pe)?Sf(c):Za(i.serializer,c)}(r,e)}function FT(r,e,t){return r instanceof Yn?Df(r,e):r instanceof Xn?Vf(r,e):t}function Cf(r,e){return r instanceof Zn?function(n){return la(n)||function(s){return!!s&&"doubleValue"in s}(n)}(e)?e:{integerValue:0}:null}class Jn extends Gs{}class Yn extends Gs{constructor(e){super(),this.elements=e}}function Df(r,e){const t=kf(e);for(const n of r.elements)t.some(i=>it(i,n))||t.push(n);return{arrayValue:{values:t}}}class Xn extends Gs{constructor(e){super(),this.elements=e}}function Vf(r,e){let t=kf(e);for(const n of r.elements)t=t.filter(i=>!it(i,n));return{arrayValue:{values:t}}}class Zn extends Gs{constructor(e,t){super(),this.serializer=e,this.Pe=t}}function zl(r){return oe(r.integerValue||r.doubleValue)}function kf(r){return ii(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}/**
2229 * @license
2230 * Copyright 2017 Google LLC
2231 *
2232 * Licensed under the Apache License, Version 2.0 (the "License");
2233 * you may not use this file except in compliance with the License.
2234 * You may obtain a copy of the License at
2235 *
2236 *   http://www.apache.org/licenses/LICENSE-2.0
2237 *
2238 * Unless required by applicable law or agreed to in writing, softw
2238are
2239 * distributed under the License is distributed on an "AS IS" BASIS,
2240 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2241 * See the License for the specific language governing permissions and
2242 * limitations under the License.
2243 */class ec{constructor(e,t){this.field=e,this.transform=t}}function UT(r,e){return r.field.isEqual(e.field)&&function(n,i){return n instanceof Yn&&i instanceof Yn||n instanceof Xn&&i instanceof Xn?Kn(n.elements,i.elements,it):n instanceof Zn&&i instanceof Zn?it(n.Pe,i.Pe):n instanceof Jn&&i instanceof Jn}(r.transform,e.transform)}class BT{constructor(e,t){this.version=e,this.transformResults=t}}class de{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new de}static exists(e){return new de(void 0,e)}static updateTime(e){return new de(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function cs(r,e){return r.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(r.updateTime):r.exists===void 0||r.exists===e.isFoundDocument()}class Ks{}function Nf(r,e){if(!r.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return r.isNoDocument()?new yi(r.key,de.none()):new cr(r.key,r.data,de.none());{const t=r.data,n=Ee.empty();let i=new te(ce.comparator);for(let s of e.fields)if(!i.has(s)){let o=t.field(s);o===null&&s.length>1&&(s=s.popLast(),o=t.field(s)),o===null?n.delete(s):n.set(s,o),i=i.add(s)}return new yt(r.key,n,new Me(i.toArray()),de.none())}}function qT(r,e,t){r instanceof cr?function(i,s,o){const c=i.value.clone(),u=Kl(i.fieldTransforms,s,o.transformResults);c.setAll(u),s.convertToFoundDocument(o.version,c).setHasCommittedMutations()}(r,e,t):r instanceof yt?function(i,s,o){if(!cs(i.precondition,s))return void s.convertToUnknownDocument(o.version);const c=Kl(i.fieldTransforms,s,o.transformResults),u=s.data;u.setAll(xf(i)),u.setAll(c),s.convertToFoundDocument(o.version,u).setHasCommittedMutations()}(r,e,t):function(i,s,o){s.convertToNoDocument(o.version).setHasCommittedMutations()}(0,e,t)}function Kr(r,e,t,n){return r instanceof cr?function(s,o,c,u){if(!cs(s.precondition,o))return c;const h=s.value.clone(),f=Wl(s.fieldTransforms,u,o);return h.setAll(f),o.convertToFoundDocument(o.version,h).setHasLocalMutations(),null}(r,e,t,n):r instanceof yt?function(s,o,c,u){if(!cs(s.precondition,o))return c;const h=Wl(s.fieldTransforms,u,o),f=o.data;return f.setAll(xf(s)),f.setAll(h),o.convertToFoundDocument(o.version,f).setHasLocalMutations(),c===null?null:c.unionWith(s.fieldMask.fields).unionWith(s.fieldTransforms.map(m=>m.field))}(r,e,t,n):function(s,o,c){return cs(s.precondition,o)?(o.convertToNoDocument(o.version).setHasLocalMutations(),null):c}(r,e,t)}function jT(r,e){let t=null;for(const n of r.fieldTransforms){const i=e.data.field(n.field),s=Cf(n.transform,i||null);s!=null&&(t===null&&(t=Ee.empty()),t.set(n.field,s))}return t||null}function Gl(r,e){return r.type===e.type&&!!r.key.isEqual(e.key)&&!!r.precondition.isEqual(e.precondition)&&!!function(n,i){return n===void 0&&i===void 0||!(!n||!i)&&Kn(n,i,(s,o)=>UT(s,o))}(r.fieldTransforms,e.fieldTransforms)&&(r.type===0?r.value.isEqual(e.value):r.type!==1||r.data.isEqual(e.data)&&r.fieldMask.isEqual(e.fieldMask))}class cr extends Ks{constructor(e,t,n,i=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class yt extends Ks{constructor(e,t,n,i,s=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=i,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function xf(r){const e=new Map;return r.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const n=r.data.field(t);e.set(t,n)}}),e}function Kl(r,e,t){const n=new Map;F(r.length===t.length);for(let i=0;i<t.length;i++){const s=r[i],o=s.transform,c=e.data.field(s.field);n.set(s.field,FT(o,c,t[i]))}return n}function Wl(r,e,t){const n=new Map;for(const i of r){const s=i.transform,o=t.data.field(i.field);n.set(i.field,LT(s,o,e))}return n}class yi extends Ks{constructor(e,t){super(),this.key=e,this.prec
2243ondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class tc extends Ks{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
2244 * @license
2245 * Copyright 2017 Google LLC
2246 *
2247 * Licensed under the Apache License, Version 2.0 (the "License");
2248 * you may not use this file except in compliance with the License.
2249 * You may obtain a copy of the License at
2250 *
2251 *   http://www.apache.org/licenses/LICENSE-2.0
2252 *
2253 * Unless required by applicable law or agreed to in writing, software
2254 * distributed under the License is distributed on an "AS IS" BASIS,
2255 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2256 * See the License for the specific language governing permissions and
2257 * limitations under the License.
2258 */class nc{constructor(e,t,n,i){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let i=0;i<this.mutations.length;i++){const s=this.mutations[i];s.key.isEqual(e.key)&&qT(s,e,n[i])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=Kr(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=Kr(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=bf();return this.mutations.forEach(i=>{const s=e.get(i.key),o=s.overlayedDocument;let c=this.applyToLocalView(o,s.mutatedFields);c=t.has(i.key)?null:c;const u=Nf(o,c);u!==null&&n.set(i.key,u),o.isValidDocument()||o.convertToNoDocument(B.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),W())}isEqual(e){return this.batchId===e.batchId&&Kn(this.mutations,e.mutations,(t,n)=>Gl(t,n))&&Kn(this.baseMutations,e.baseMutations,(t,n)=>Gl(t,n))}}class rc{constructor(e,t,n,i){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=i}static from(e,t,n){F(e.mutations.length===n.length);let i=function(){return xT}();const s=e.mutations;for(let o=0;o<s.length;o++)i=i.insert(s[o].key,n[o].version);return new rc(e,t,n,i)}}/**
2259 * @license
2260 * Copyright 2022 Google LLC
2261 *
2262 * Licensed under the Apache License, Version 2.0 (the "License");
2263 * you may not use this file except in compliance with the License.
2264 * You may obtain a copy of the License at
2265 *
2266 *   http://www.apache.org/licenses/LICENSE-2.0
2267 *
2268 * Unless required by applicable law or agreed to in writing, software
2269 * distributed under the License is distributed on an "AS IS" BASIS,
2270 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2271 * See the License for the specific language governing permissions and
2272 * limitations under the License.
2273 */class ic{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
2274      largestBatchId: ${this.largestBatchId},
2275      mutation: ${this.mutation.toString()}
2276    }`}}/**
2277 * @license
2278 * Copyright 2017 Google LLC
2279 *
2280 * Licensed under the Apache License, Version 2.0 (the "License");
2281 * you may not use this file except in compliance with the License.
2282 * You may obtain a copy of the License at
2283 *
2284 *   http://www.apache.org/licenses/LICENSE-2.0
2285 *
2286 * Unless required by applicable law or agreed to in writing, software
2287 * distributed under the License is distributed on an "AS IS" BASIS,
2288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2289 * See the License for the specific language governing permissions and
2290 * limitations under the License.
2291 */class $T{constructor(e,t){this.count=e,this.unchangedNames=t}}/**
2292 * @license
2293 * Copyright 2017 Google LLC
2294 *
2295 * Licensed under the Apache License, Version 2.0 (the "License");
2296 * you may not use this file except in compliance with the License.
2297 * You may obtain a copy of the License at
2298 *
2299 *   http://www.apache.org/licenses/LICENSE-2.0
2300 *
2301 * Unless required by applicable law or agreed to in writing, software
2302 * distributed under the License is distributed on an "AS IS" BASIS,
2303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2304 * See the License for the specific language governing permissions and
2305 * limitations under the License.
2306 */var pe,Y;function Of(r){switch(r){default:return M();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.UNIMPLEMENT
2306ED:case P.DATA_LOSS:return!0}}function Mf(r){if(r===void 0)return he("GRPC error has no .code"),P.UNKNOWN;switch(r){case pe.OK:return P.OK;case pe.CANCELLED:return P.CANCELLED;case pe.UNKNOWN:return P.UNKNOWN;case pe.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case pe.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case pe.INTERNAL:return P.INTERNAL;case pe.UNAVAILABLE:return P.UNAVAILABLE;case pe.UNAUTHENTICATED:return P.UNAUTHENTICATED;case pe.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case pe.NOT_FOUND:return P.NOT_FOUND;case pe.ALREADY_EXISTS:return P.ALREADY_EXISTS;case pe.PERMISSION_DENIED:return P.PERMISSION_DENIED;case pe.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case pe.ABORTED:return P.ABORTED;case pe.OUT_OF_RANGE:return P.OUT_OF_RANGE;case pe.UNIMPLEMENTED:return P.UNIMPLEMENTED;case pe.DATA_LOSS:return P.DATA_LOSS;default:return M()}}(Y=pe||(pe={}))[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";/**
2307 * @license
2308 * Copyright 2023 Google LLC
2309 *
2310 * Licensed under the Apache License, Version 2.0 (the "License");
2311 * you may not use this file except in compliance with the License.
2312 * You may obtain a copy of the License at
2313 *
2314 *   http://www.apache.org/licenses/LICENSE-2.0
2315 *
2316 * Unless required by applicable law or agreed to in writing, software
2317 * distributed under the License is distributed on an "AS IS" BASIS,
2318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2319 * See the License for the specific language governing permissions and
2320 * limitations under the License.
2321 */function zT(){return new TextEncoder}/**
2322 * @license
2323 * Copyright 2022 Google LLC
2324 *
2325 * Licensed under the Apache License, Version 2.0 (the "License");
2326 * you may not use this file except in compliance with the License.
2327 * You may obtain a copy of the License at
2328 *
2329 *   http://www.apache.org/licenses/LICENSE-2.0
2330 *
2331 * Unless required by applicable law or agreed to in writing, software
2332 * distributed under the License is distributed on an "AS IS" BASIS,
2333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2334 * See the License for the specific language governing permissions and
2335 * limitations under the License.
2336 */const GT=new an([4294967295,4294967295],0);function Hl(r){const e=zT().encode(r),t=new jd;return t.update(e),new Uint8Array(t.digest())}function Ql(r){const e=new DataView(r.buffer),t=e.getUint32(0,!0),n=e.getUint32(4,!0),i=e.getUint32(8,!0),s=e.getUint32(12,!0);return[new an([t,n],0),new an([i,s],0)]}class sc{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new Ur(`Invalid padding: ${t}`);if(n<0)throw new Ur(`Invalid hash count: ${n}`);if(e.length>0&&this.hashCount===0)throw new Ur(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new Ur(`Invalid padding when bitmap length is 0: ${t}`);this.Ie=8*e.length-t,this.Te=an.fromNumber(this.Ie)}Ee(e,t,n){let i=e.add(t.multiply(an.fromNumber(n)));return i.compare(GT)===1&&(i=new an([i.getBits(0),i.getBits(1)],0)),i.modulo(this.Te).toNumber()}de(e){return(this.bitmap[Math.floor(e/8)]&1<<e%8)!=0}mightContain(e){if(this.Ie===0)return!1;const t=Hl(e),[n,i]=Ql(t);for(let s=0;s<this.hashCount;s++){const o=this.Ee(n,i,s);if(!this.de(o))return!1}return!0}static create(e,t,n){const i=e%8==0?0:8-e%8,s=new Uint8Array(Math.ceil(e/8)),o=new sc(s,i,t);return n.forEach(c=>o.insert(c)),o}insert(e){if(this.Ie===0)return;const t=Hl(e),[n,i]=Ql(t);for(let s=0;s<this.hashCount;s++){const o=this.Ee(n,i,s);this.Ae(o)}}Ae(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}}
2336class Ur extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
2337 * @license
2338 * Copyright 2017 Google LLC
2339 *
2340 * Licensed under the Apache License, Version 2.0 (the "License");
2341 * you may not use this file except in compliance with the License.
2342 * You may obtain a copy of the License at
2343 *
2344 *   http://www.apache.org/licenses/LICENSE-2.0
2345 *
2346 * Unless required by applicable law or agreed to in writing, software
2347 * distributed under the License is distributed on an "AS IS" BASIS,
2348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2349 * See the License for the specific language governing permissions and
2350 * limitations under the License.
2351 */class Ii{constructor(e,t,n,i,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=i,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const i=new Map;return i.set(e,Ti.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new Ii(B.min(),i,new ie(G),Be(),W())}}class Ti{constructor(e,t,n,i,s){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=i,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new Ti(n,t,W(),W(),W())}}/**
2352 * @license
2353 * Copyright 2017 Google LLC
2354 *
2355 * Licensed under the Apache License, Version 2.0 (the "License");
2356 * you may not use this file except in compliance with the License.
2357 * You may obtain a copy of the License at
2358 *
2359 *   http://www.apache.org/licenses/LICENSE-2.0
2360 *
2361 * Unless required by applicable law or agreed to in writing, software
2362 * distributed under the License is distributed on an "AS IS" BASIS,
2363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2364 * See the License for the specific language governing permissions and
2365 * limitations under the License.
2366 */class us{constructor(e,t,n,i){this.Re=e,this.removedTargetIds=t,this.key=n,this.Ve=i}}class Lf{constructor(e,t){this.targetId=e,this.me=t}}class Ff{constructor(e,t,n=fe.EMPTY_BYTE_STRING,i=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=i}}class Jl{constructor(){this.fe=0,this.ge=Xl(),this.pe=fe.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(e){e.approximateByteSize()>0&&(this.we=!0,this.pe=e)}ve(){let e=W(),t=W(),n=W();return this.ge.forEach((i,s)=>{switch(s){case 0:e=e.add(i);break;case 2:t=t.add(i);break;case 1:n=n.add(i);break;default:M()}}),new Ti(this.pe,this.ye,e,t,n)}Ce(){this.we=!1,this.ge=Xl()}Fe(e,t){this.we=!0,this.ge=this.ge.insert(e,t)}Me(e){this.we=!0,this.ge=this.ge.remove(e)}xe(){this.fe+=1}Oe(){this.fe-=1,F(this.fe>=0)}Ne(){this.we=!0,this.ye=!0}}class KT{constructor(e){this.Le=e,this.Be=new Map,this.ke=Be(),this.qe=Yl(),this.Qe=new ie(G)}Ke(e){for(const t of e.Re)e.Ve&&e.Ve.isFoundDocument()?this.$e(t,e.Ve):this.Ue(t,e.key,e.Ve);for(const t of e.removedTargetIds)this.Ue(t,e.key,e.Ve)}We(e){this.forEachTarget(e,t=>{const n=this.Ge(t);switch(e.state){case 0:this.ze(t)&&n.De(e.resumeToken);break;case 1:n.Oe(),n.Se||n.Ce(),n.De(e.resumeToken);break;case 2:n.Oe(),n.Se||this.removeTarget(t);break;case 3:this.ze(t)&&(n.Ne(),n.De(e.resumeToken));break;case 4:this.ze(t)&&(this.je(t),n.De(e.resumeToken));break;default:M()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Be.forEach((n,i)=>{this.ze(i)&&t(i)})}He(e){const t=e.targetId,n=e.me.count,i=this.Je(t);if(i){const s=i.target;if(Ts(s))if(n===0){const o=new O(s.path);this.Ue(t,o,ae.newNoDocument(o,B.min()))}else F(n===1);else{const o=this.Ye(t);if(o!==n){const c=this.Ze(e),u=c?this.Xe(c,e,o):1;if(u!==0){this.je(t);const h=u===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Qe=this.Qe.insert(t,h)}}}}}Ze(e){const t=e.me.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:n="",padding:i=0},hashCount:s=0}=t;let o,c;try{o=Mt(n).toUint8Array()}catch(u){if(u instanceof cf)return Yr("Decoding the base64 bloom filter in existence filter failed ("+u.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw u}try{c=new sc(o,i,s)}catch(u){return Yr(u instanceof Ur?"BloomFilter error: ":"Applying bloom filter failed: ",u),null}return c.Ie===0?null:c}Xe(e,t,n){return t.me.count===n-this.nt(e,t.targetId)?0:2}nt(e,t){const n=this.Le.getRemoteKeysForTarget(t);let i=0;
2366return n.forEach(s=>{const o=this.Le.tt(),c=`projects/${o.projectId}/databases/${o.database}/documents/${s.path.canonicalString()}`;e.mightContain(c)||(this.Ue(t,s,null),i++)}),i}rt(e){const t=new Map;this.Be.forEach((s,o)=>{const c=this.Je(o);if(c){if(s.current&&Ts(c.target)){const u=new O(c.target.path);this.ke.get(u)!==null||this.it(o,u)||this.Ue(o,u,ae.newNoDocument(u,e))}s.be&&(t.set(o,s.ve()),s.Ce())}});let n=W();this.qe.forEach((s,o)=>{let c=!0;o.forEachWhile(u=>{const h=this.Je(u);return!h||h.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)}),c&&(n=n.add(s))}),this.ke.forEach((s,o)=>o.setReadTime(e));const i=new Ii(e,t,this.Qe,this.ke,n);return this.ke=Be(),this.qe=Yl(),this.Qe=new ie(G),i}$e(e,t){if(!this.ze(e))return;const n=this.it(e,t.key)?2:0;this.Ge(e).Fe(t.key,n),this.ke=this.ke.insert(t.key,t),this.qe=this.qe.insert(t.key,this.st(t.key).add(e))}Ue(e,t,n){if(!this.ze(e))return;const i=this.Ge(e);this.it(e,t)?i.Fe(t,1):i.Me(t),this.qe=this.qe.insert(t,this.st(t).delete(e)),n&&(this.ke=this.ke.insert(t,n))}removeTarget(e){this.Be.delete(e)}Ye(e){const t=this.Ge(e).ve();return this.Le.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}xe(e){this.Ge(e).xe()}Ge(e){let t=this.Be.get(e);return t||(t=new Jl,this.Be.set(e,t)),t}st(e){let t=this.qe.get(e);return t||(t=new te(G),this.qe=this.qe.insert(e,t)),t}ze(e){const t=this.Je(e)!==null;return t||C("WatchChangeAggregator","Detected inactive target",e),t}Je(e){const t=this.Be.get(e);return t&&t.Se?null:this.Le.ot(e)}je(e){this.Be.set(e,new Jl),this.Le.getRemoteKeysForTarget(e).forEach(t=>{this.Ue(e,t,null)})}it(e,t){return this.Le.getRemoteKeysForTarget(e).has(t)}}function Yl(){return new ie(O.comparator)}function Xl(){return new ie(O.comparator)}const WT={asc:"ASCENDING",desc:"DESCENDING"},HT={"<":"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"},QT={and:"AND",or:"OR"};class JT{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function ma(r,e){return r.useProto3Json||mi(e)?e:{value:e}}function er(r,e){return r.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Uf(r,e){return r.useProto3Json?e.toBase64():e.toUint8Array()}function YT(r,e){return er(r,e.toTimestamp())}function ye(r){return F(!!r),B.fromTimestamp(function(t){const n=gt(t);return new ue(n.seconds,n.nanos)}(r))}function oc(r,e){return ga(r,e).canonicalString()}function ga(r,e){const t=function(i){return new Z(["projects",i.projectId,"databases",i.database])}(r).child("documents");return e===void 0?t:t.child(e)}function Bf(r){const e=Z.fromString(r);return F(Qf(e)),e}function oi(r,e){return oc(r.databaseId,e.path)}function ft(r,e){const t=Bf(e);
2366if(t.get(1)!==r.databaseId.projectId)throw new k(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+r.databaseId.projectId);if(t.get(3)!==r.databaseId.database)throw new k(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+r.databaseId.database);return new O($f(t))}function qf(r,e){return oc(r.databaseId,e)}function jf(r){const e=Bf(r);return e.length===4?Z.emptyPath():$f(e)}function _a(r){return new Z(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function $f(r){return F(r.length>4&&r.get(4)==="documents"),r.popFirst(5)}function Zl(r,e,t){return{name:oi(r,e),fields:t.value.mapValue.fields}}function XT(r,e,t){const n=ft(r,e.name),i=ye(e.updateTime),s=e.createTime?ye(e.createTime):B.min(),o=new Ee({mapValue:{fields:e.fields}}),c=ae.newFoundDocument(n,i,s,o);return t&&c.setHasCommittedMutations(),t?c.setHasCommittedMutations():c}function ZT(r,e){return"found"in e?function(n,i){F(!!i.found),i.found.name,i.found.updateTime;const s=ft(n,i.found.name),o=ye(i.found.updateTime),c=i.found.createTime?ye(i.found.createTime):B.min(),u=new Ee({mapValue:{fields:i.found.fields}});return ae.newFoundDocument(s,o,c,u)}(r,e):"missing"in e?function(n,i){F(!!i.missing),F(!!i.readTime);const s=ft(n,i.missing),o=ye(i.readTime);return ae.newNoDocument(s,o)}(r,e):M()}function eE(r,e){let t;if("targetChange"in e){e.targetChange;const n=function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:M()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(h,f){return h.useProto3Json?(F(f===void 0||typeof f=="string"),fe.fromBase64String(f||"")):(F(f===void 0||f instanceof Buffer||f instanceof Uint8Array),fe.fromUint8Array(f||new Uint8Array))}(r,e.targetChange.resumeToken),o=e.targetChange.cause,c=o&&function(h){const f=h.code===void 0?P.UNKNOWN:Mf(h.code);return new k(f,h.message||"")}(o);t=new Ff(n,i,s,c||null)}else if("documentChange"in e){e.documentChange;const n=e.documentChange;n.document,n.document.name,n.document.updateTime;const i=ft(r,n.document.name),s=ye(n.document.updateTime),o=n.document.createTime?ye(n.document.createTime):B.min(),c=new Ee({mapValue:{fields:n.document.fields}}),u=ae.newFoundDocument(i,s,o,c),h=n.targetIds||[],f=n.removedTargetIds||[];t=new us(h,f,u.key,u)}else if("documentDelete"in e){e.documentDelete;const n=e.documentDelete;n.document;const i=ft(r,n.document),s=n.readTime?ye(n.readTime):B.min(),o=ae.newNoDocument(i,s),c=n.removedTargetIds||[];t=new us([],c,o.key,o)}else if("documentRemove"in e){e.documentRemove;const n=e.documentRemove;n.document;const i=ft(r,n.document),s=n.removedTargetIds||[];t=new us([],s,i,null)}else{if(!("filter"in e))return M();{e.filter;const n=e.filter;n.targetId;const{count:i=0,unchangedNames:s}=n,o=new $T(i,s),c=n.targetId;t=new Lf(c,o)}}return t}function ai(r,e){let t;if(e instanceof cr)t={update:Zl(r,e.key,e.value)};else if(e instanceof yi)t={delete:oi(r,e.key)};else if(e instanceof yt)t={update:Zl(r,e.key,e.data),updateMask:oE(e.f
2366ieldMask)};else{if(!(e instanceof tc))return M();t={verify:oi(r,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(n=>function(s,o){const c=o.transform;if(c instanceof Jn)return{fieldPath:o.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof Yn)return{fieldPath:o.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof Xn)return{fieldPath:o.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof Zn)return{fieldPath:o.field.canonicalString(),increment:c.Pe};throw M()}(0,n))),e.precondition.isNone||(t.currentDocument=function(i,s){return s.updateTime!==void 0?{updateTime:YT(i,s.updateTime)}:s.exists!==void 0?{exists:s.exists}:M()}(r,e.precondition)),t}function ya(r,e){const t=e.currentDocument?function(s){return s.updateTime!==void 0?de.updateTime(ye(s.updateTime)):s.exists!==void 0?de.exists(s.exists):de.none()}(e.currentDocument):de.none(),n=e.updateTransforms?e.updateTransforms.map(i=>function(o,c){let u=null;if("setToServerValue"in c)F(c.setToServerValue==="REQUEST_TIME"),u=new Jn;else if("appendMissingElements"in c){const f=c.appendMissingElements.values||[];u=new Yn(f)}else if("removeAllFromArray"in c){const f=c.removeAllFromArray.values||[];u=new Xn(f)}else"increment"in c?u=new Zn(o,c.increment):M();const h=ce.fromServerFormat(c.fieldPath);return new ec(h,u)}(r,i)):[];if(e.update){e.update.name;const i=ft(r,e.update.name),s=new Ee({mapValue:{fields:e.update.fields}});if(e.updateMask){const o=function(u){const h=u.fieldPaths||[];return new Me(h.map(f=>ce.fromServerFormat(f)))}(e.updateMask);return new yt(i,s,o,t,n)}return new cr(i,s,t,n)}if(e.delete){const i=ft(r,e.delete);return new yi(i,t)}if(e.verify){const i=ft(r,e.verify);return new tc(i,t)}return M()}function tE(r,e){return r&&r.length>0?(F(e!==void 0),r.map(t=>function(i,s){let o=i.updateTime?ye(i.updateTime):ye(s);return o.isEqual(B.min())&&(o=ye(s)),new BT(o,i.transformResults||[])}(t,e))):[]}function zf(r,e){return{documents:[qf(r,e.path)]}}function Gf(r,e){const t={structuredQuery:{}},n=e.path;let i;e.collectionGroup!==null?(i=n,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(i=n.popLast(),t.structuredQuery.from=[{collectionId:n.lastSegment()}]),t.parent=qf(r,i);const s=function(h){if(h.length!==0)return Hf(ee.create(h,"and"))}(e.filters);s&&(t.structuredQuery.where=s);const o=function(h){if(h.length!==0)return h.map(f=>function(_){return{field:Mn(_.field),direction:rE(_.dir)}}(f))}(e.orderBy);o&&(t.structuredQuery.orderBy=o);const c=ma(r,e.limit);return c!==null&&(t.structuredQuery.limit=c),e.startAt&&(t.structuredQuery.startAt=function(h){return{before:h.inclusive,values:h.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(h){return{before:!h.inclusive,values:h.position}}(e.endAt)),{_t:t,parent:i}}function Kf(r){let e=jf(r.parent);const t=r.structuredQuery,n=t.from?t.from.length:0;let i=null;if(n>0){F(n===1);const f=t.from[0];f.allDescendants?i=f.collectionId:e=e.child(f.collectionId)}let s=[];t.where&&(s=function(m){const _=Wf(m);return _ instanceof ee&&Ya(_)?_.getFilters():[_]}(t.where));let o=[];t.orderBy&&(o=function(m){return m.map(_=>function(V){return new si(Ln(V.field),function(D){switch(D){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(V.direction))}(_))}(t.orderBy));let c=null;t.limit&&(c=function(m){let _;return _=typeof m=="object"?m.value:m,mi(_)?null:_}(t.limit));let u=null;t.startAt&&(u=function(m){const _=!!m.before,b=m.values||[];return new Hn(b,_)}(t.startAt));let h=null;return t.endAt&&(h=function(m){const _=!m.before,b=m.values||[];return new Hn(b,_)}(t.endAt)),If(e,i,o,s,c,"F",u,h)}function nE(r,e){const t=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 M()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function Wf(r){return r.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":const n=Ln(t.unaryFilter.field);return Q.create(n,"==",{doubleValue:NaN});case"IS_NULL":const i=Ln(t.unaryFilter.field);return Q.create(i,"==",{nullValue:"NULL_VALUE"});
2366case"IS_NOT_NAN":const s=Ln(t.unaryFilter.field);return Q.create(s,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const o=Ln(t.unaryFilter.field);return Q.create(o,"!=",{nullValue:"NULL_VALUE"});default:return M()}}(r):r.fieldFilter!==void 0?function(t){return Q.create(Ln(t.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 M()}}(t.fieldFilter.op),t.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(t){return ee.create(t.compositeFilter.filters.map(n=>Wf(n)),function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return M()}}(t.compositeFilter.op))}(r):M()}function rE(r){return WT[r]}function iE(r){return HT[r]}function sE(r){return QT[r]}function Mn(r){return{fieldPath:r.canonicalString()}}function Ln(r){return ce.fromServerFormat(r.fieldPath)}function Hf(r){return r instanceof Q?function(t){if(t.op==="=="){if(Ml(t.value))return{unaryFilter:{field:Mn(t.field),op:"IS_NAN"}};if(Ol(t.value))return{unaryFilter:{field:Mn(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Ml(t.value))return{unaryFilter:{field:Mn(t.field),op:"IS_NOT_NAN"}};if(Ol(t.value))return{unaryFilter:{field:Mn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Mn(t.field),op:iE(t.op),value:t.value}}}(r):r instanceof ee?function(t){const n=t.getFilters().map(i=>Hf(i));return n.length===1?n[0]:{compositeFilter:{op:sE(t.op),filters:n}}}(r):M()}function oE(r){const e=[];return r.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function Qf(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}/**
2367 * @license
2368 * Copyright 2017 Google LLC
2369 *
2370 * Licensed under the Apache License, Version 2.0 (the "License");
2371 * you may not use this file except in compliance with the License.
2372 * You may obtain a copy of the License at
2373 *
2374 *   http://www.apache.org/licenses/LICENSE-2.0
2375 *
2376 * Unless required by applicable law or agreed to in writing, software
2377 * distributed under the License is distributed on an "AS IS" BASIS,
2378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2379 * See the License for the specific language governing permissions and
2380 * limitations under the License.
2381 */class dt{constructor(e,t,n,i,s=B.min(),o=B.min(),c=fe.EMPTY_BYTE_STRING,u=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=i,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=c,this.expectedCount=u}withSequenceNumber(e){return new dt(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new dt(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new dt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new dt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
2382 * @license
2383 * Copyright 2017 Google LLC
2384 *
2385 * Licensed under the Apache License, Version 2.0 (the "License");
2386 * you may not use this file except in compliance with the License.
2387 * You may obtain a copy of the License at
2388 *
2389 *   http://www.apache.org/licenses/LICENSE-2.0
2390 *
2391 * Unless required by applicable law or agreed to in writing, software
2392 * distributed under the License is distributed on an "AS IS" BASIS,
2393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2394 * See the License for the specific language governing permissions and
2395 * limitations under the License.
2396 */class Jf{constructor(e){this.ct=e}}function aE(r,e){let t;if(e.document)t=XT(r.ct,e.document,!!e.hasCommittedMutations);else if(e.noDocument){const n=O.fromSegments(e.noDocument.path),i=gn(e.noDocument.readTime);t=ae.newNoDocument(n,i),e.hasCommittedMutations&&t.setHasCommittedMutations()}else{if(!e.unknownDocument)return M();{const n=O.fromSegments(e.unknownDocument.path),i=gn(e.unknownDocument.version);t=ae.newUnknownDocument(n,i)}}return e.readTime&&t.setReadTime(function(i){const s=new ue(i[0],i[1]);return B.fromTimestamp(s)}(e.readTime)),t}function eh(r,e){const t=e.key,n={prefixPath:t.getCollectionPath().popLast().toArray(),collectionGroup:t.collectionGroup,documentId:t.path.lastSegment(),readTime:ws(e.readTime),hasCommittedMutations:e.hasCommittedMutations};if(e.isFoundDocument())n.document=function(s,o){return{name:oi(s,o.key),fields:o.data.value.mapValue.fields,updateTime:er(s,o.version.toTimestamp()),createTime:er(s,o.createTime.toTimestamp())}}(r.ct,e);else if(e.isNoDocument())n.noDocument={path:t.path.toArray(),readTime:mn(e.version)};else{if(!e.isUnknownDocument())return M();n.unknownDocument={path:t.path.toArray(),version:mn(e.version)}}return n}function ws(r){const e=r.toTimestamp();return[e.seconds,e.nanoseconds]}function mn(r){const e=r.toTimestamp();return{seconds:e.seconds,nanoseconds:e.nanoseconds}}function gn(r){const e=new ue(r.seconds,r.nanoseconds);return B.fromTimestamp(e)}function tn(r,e){const t=(e.baseMutations||[]).map(s=>ya(r.ct,s));for(let s=0;s<e.mutations.length-1;++s){const o=e.mutations[s];if(s+1<e.mutations.length&&e.mutations[s+1].transform!==void 0){const c=e.mutations[s+1];o.updateTransforms=c.transform.fieldTransforms,e.mutations.splice(s+1,1),++s}}const n=e.mutations.map(s=>ya(r.ct,s)),i=ue.fromMillis(e.localWriteTimeMs);return new nc(e.batchId,i,t,n)}function Br(r){const e=gn(r.readTime),t=r.lastLimboFreeSnapshotVersion!==void 0?gn(r.lastLimboFreeSnapshotVersion):B.min();let n;return n=function(s){return s.documents!==void 0}(r.query)?function(s){return F(s.documents.length===1),qe($s(jf(s.documents[0])))}(r.query):function(s){return qe(Kf(s))}(r.query),new dt(n,r.targetId,"TargetPurposeListen",r.lastListenSequenceNumber,e,t,fe.fromBase64String(r.resumeToken))}function Yf(r,e){const t=mn(e.snapshotVersion),n=mn(e.lastLimboFreeSnapshotVersion);let i;i=Ts(e.target)?zf(r.ct,e.target):Gf(r.ct,e.target)._t;const s=e.resumeToken.toBase64();return{targetId:e.targetId,canonicalId:pn(e.target),readTime:t,resumeToken:s,lastListenSequenceNumber:e.sequenceNumber,lastLimboFreeSnapshotVersion:n,query:i}}function Xf(r){const e=Kf({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?vs(e,e.limit,"L"):e}function Bo(r,e){return new ic(e.largestBatchId,ya(r.ct,e.overlayMutation))}function th(r,e){const t=e.path.lastSegment();return[r,Ne(e.path.popLast()),t]}function nh(r,e,t,n){return{indexId:r,uid:e,sequenceNumber:t,readTime:mn(n.readTime),documentKey:Ne(n.documentKey.path),largestBatchId:n.largestBatchId}}/**
2397 * @license
2398 * Copyright 2020 Google LLC
2399 *
2400 * Licensed under the Apache License, Version 2.0 (the "License");
2401 * you may not use this file except in compliance with the License.
2402 * You may obtain a copy of the License at
2403 *
2404 *   http://www.apache.org/licenses/LICENSE-2.0
2405 *
2406 * Unless required by applicable law or agreed to in writing, software
2407 * distributed under the License is distributed on an "AS IS" BASIS,
2408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2409 * See the License for the specific language governing permissions and
2410 * limitations under the License.
2411 */class cE{getBundleMetadata(e,t){return rh(e).get(t).next(n=>{if(n)return function(s){return{id:s.bundleId,createTime:gn(s.createTime),version:s.version}}(n)})}saveBundleMetadata(e,t){return rh(e).put(function(i){return{bundleId:i.id,createTime:mn(ye(i.createTime)),version:i.version}}(t))}getNamedQuery(e,t){return ih(e).get(t).next(n=>{if(n)return function(s){return{name:s.name,query:Xf(s.bundledQuery),readTime:gn(s.readTime)}}(n)})}saveNamedQuery(e,t){return ih(e).put(function(i){return{name:i.name,readTime:mn(ye(i.readTime)),bundledQuery:i.bundledQuery}}(t))}}function rh(r){return ge(r,"bundles")}function ih(r){return ge(r,"namedQueries")}/**
2412 * @license
2413 * Copyright 2022 Google LLC
2414 *
2415 * Licensed under the Apache License, Version 2.0 (the "License");
2416 * you may not use this file except in compliance with the License.
2417 * You may obtain a copy of the License at
2418 *
2419 *   http://www.apache.org/licenses/LICENSE-2.0
2420 *
2421 * Unless required by applicable law or agreed to in writing, software
2422 * distributed under the License is distributed on an "AS IS" BASIS,
2423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2424 * See the License for the specific language governing permissions and
2425 * limitations under the License.
2426 */class Ws{constructor(e,t){this.serializer=e,this.userId=t}static lt(e,t){const n=t.uid||"";return new Ws(e,n)}getOverlay(e,t){return Pr(e).get(th(this.userId,t)).next(n=>n?Bo(this.serializer,n):null)}getOverlays(e,t){const n=tt();return A.forEach(t,i=>this.getOverlay(e,i).next(s=>{s!==null&&n.set(i,s)})).next(()=>n)}saveOverlays(e,t,n){const i=[];return n.forEach((s,o)=>{const c=new ic(t,o);i.push(this.ht(e,c))}),A.waitFor(i)}removeOverlaysForBatchId(e,t,n){const i=new Set;t.forEach(o=>i.add(Ne(o.getCollectionPath())));const s=[];return i.forEach(o=>{const c=IDBKeyRange.bound([this.userId,o,n],[this.userId,o,n+1],!1,!0);s.push(Pr(e).j("collectionPathOverlayIndex",c))}),A.waitFor(s)}getOverlaysForCollection(e,t,n){const i=tt(),s=Ne(t),o=IDBKeyRange.bound([this.userId,s,n],[this.userId,s,Number.POSITIVE_INFINITY],!0);return Pr(e).U("collectionPathOverlayIndex",o).next(c=>{for(const u of c){const h=Bo(this.serializer,u);i.set(h.getKey(),h)}return i})}getOverlaysForCollectionGroup(e,t,n,i){const s=tt();let o;const c=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,Number.POSITIVE_INFINITY],!0);return Pr(e).J({index:"collectionGroupOverlayIndex",range:c},(u,h,f)=>{const m=Bo(this.serializer,h);s.size()<i||m.largestBatchId===o?(s.set(m.getKey(),m),o=m.largestBatchId):f.done()}).next(()=>s)}ht(e,t){return Pr(e).put(function(i,s,o){const[c,u,h]=th(s,o.mutation.key);return{userId:s,collectionPath:u,documentId:h,collectionGroup:o.mutation.key.getCollectionGroup(),largestBatchId:o.largestBatchId,overlayMutation:ai(i.ct,o.mutation)}}(this.serializer,this.userId,t))}}function Pr(r){return ge(r,"documentOverlays")}/**
2427 * @license
2428 * Copyright 2024 Google LLC
2429 *
2430 * Licensed under the Apache License, Version 2.0 (the "License");
2431 * you may not use this file except in compliance with the License.
2432 * You may obtain a copy of the License at
2433 *
2434 *   http://www.apache.org/licenses/LICENSE-2.0
2435 *
2436 * Unless required by applicable law or agreed to in writing, software
2437 * distributed under the License is distributed on an "AS IS" BASIS,
2438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2439 * See the License for the specific language governing permissions and
2440 * limitations under the License.
2441 */class uE{Pt(e){return ge(e,"globals")}getSessionToken(e){return this.Pt(e).get("sessionToken").next(t=>{const n=t==null?void 0:t.value;return n?fe.fromUint8Array(n):fe.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.Pt(e).put({name:"sessionToken",value:t.toUint8Array()})}}/**
2442 * @license
2443 * Copyright 2021 Google LLC
2444 *
2445 * Licensed under the Apache License, Version 2.0 (the "License");
2446 * you may not use this file except in compliance with the License.
2447 * You may obtain a copy of the License at
2448 *
2449 *   http://www.apache.org/licenses/LICENSE-2.0
2450 *
2451 * Unless required by applicable law or agreed to in writing, software
2452 * distributed under the License is distributed on an "AS IS" BASIS,
2453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2454 * See the License for the specific language governing permissions and
2455 * limitations under the License.
2456 */class nn{constructor(){}It(e,t){this.Tt(e,t),t.Et()}Tt(e,t){if("nullValue"in e)this.dt(t,5);else if("booleanValue"in e)this.dt(t,10),t.At(e.booleanValue?1:0);else if("integerValue"in e)this.dt(t,15),t.At(oe(e.integerValue));else if("doubleValue"in e){const n=oe(e.doubleValue);isNaN(n)?this.dt(t,13):(this.dt(t,15),ei(n)?t.At(0):t.At(n))}else if("timestampValue"in e){let n=e.timestampValue;this.dt(t,20),typeof n=="string"&&(n=gt(n)),t.Rt(`${n.seconds||""}`),t.At(n.nanos||0)}else if("stringValue"in e)this.Vt(e.stringValue,t),this.ft(t);else if("bytesValue"in e)this.dt(t,30),t.gt(Mt(e.bytesValue)),this.ft(t);else if("referenceValue"in e)this.yt(e.referenceValue,t);else if("geoPointValue"in e){const n=e.geoPointValue;this.dt(t,45),t.At(n.latitude||0),t.At(n.longitude||0)}else"mapValue"in e?uf(e)?this.dt(t,Number.MAX_SAFE_INTEGER):js(e)?this.wt(e.mapValue,t):(this.St(e.mapValue,t),this.ft(t)):"arrayValue"in e?(this.bt(e.arrayValue,t),this.ft(t)):M()}Vt(e,t){this.dt(t,25),this.Dt(e,t)}Dt(e,t){t.Rt(e)}St(e,t){const n=e.fields||{};this.dt(t,55);for(const i of Object.keys(n))this.Vt(i,t),this.Tt(n[i],t)}wt(e,t){var n,i;const s=e.fields||{};this.dt(t,53);const o="value",c=((i=(n=s[o].arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.length)||0;this.dt(t,15),t.At(oe(c)),this.Vt(o,t),this.Tt(s[o],t)}bt(e,t){const n=e.values||[];this.dt(t,50);for(const i of n)this.Tt(i,t)}yt(e,t){this.dt(t,37),O.fromName(e).path.forEach(n=>{this.dt(t,60),this.Dt(n,t)})}dt(e,t){e.At(t)}ft(e){e.At(2)}}nn.vt=new nn;function lE(r){if(r===0)return 8;let e=0;return!(r>>4)&&(e+=4,r<<=4),!(r>>6)&&(e+=2,r<<=2),!(r>>7)&&(e+=1),e}function sh(r){const e=64-function(n){let i=0;for(let s=0;s<8;++s){const o=lE(255&n[s]);if(i+=o,o!==8)break}return i}(r);return Math.ceil(e/8)}class hE{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ct(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Ft(n.value),n=t.next();this.Mt()}xt(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Ot(n.value),n=t.next();this.Nt()}Lt(e){for(const t of e){const n=t.charCodeAt(0);if(n<128)this.Ft(n);else if(n<2048)this.Ft(960|n>>>6),this.Ft(128|63&n);else if(t<"\uD800"||"\uDBFF"<t)this.Ft(480|n>>>12),this.Ft(128|63&n>>>6),this.Ft(128|63&n);else{const i=t.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(e){for(const t of e){const n=t.charCodeAt(0);if(n<128)this.Ot(n);else if(n<2048)this.Ot(960|n>>>6),this.Ot(128|63&n);else if(t<"\uD800"||"\uDBFF"<t)this.Ot(480|n>>>12),this.Ot(128|63&n>>>6),this.Ot(128|63&n);else{const i=t.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(e){const t=this.qt(e),n=sh(t);this.Qt(1+n),this.buffer[this.position++]=255&n;for(let i=t.length-n;i<t.length;++i)this.buffer[this.position++]=255&t[i]}Kt(e){const t=this.qt(e),n=sh(t);this.Qt(1+n),this.buffer[this.position++]=~(255&n);for(let i=t.length-n;i<t.length;++i)this.buffer[this.position++]=~(255&t[i])}$t(){this.Ut(255),this.Ut(255)}Wt(){this.Gt(255),this.Gt(255)}reset(){this.position=0}seed(e){this.Qt(e.length),this.buffer.set(e,this.position),this.position+=e.length}zt(){return this.buffer.slice(0,this.position)}qt(e){const t=function(s){const o=new DataView(new ArrayBuffer(8));return o.setFloat64(0,s,!1),new Uint8Array(o.buffer)}(e),n=(128&t[0])!=0;t[0]^=n?255:128;for(let i=1;i<t.length;++i)t[i]^=n?255:0;return t}Ft(e){const t=255&e;t===0?(this.Ut(0),this.Ut(255)):t===255?(this.Ut(255),this.Ut(0)):this.Ut(t)}Ot(e){const t=255&e;t===0?(this.Gt(0),this.Gt(255)):t===255?(this.Gt(255),this.Gt(0)):this.Gt(e)}Mt(){this.Ut(0),this.Ut(1)}Nt(){this.Gt(0),this.Gt(1)}Ut(e){this.Qt(1),this.buffer[this.position++]=e}Gt(e){this.Qt(1),this.buffer[this.position++]=~e}Qt(e){const t=e+this.position;if(t<=this.buffer.length)return;let n=2*this.buffer.length;n<t&&(n=t);const i=new Uint8Array(n);i.set(this.buffer),this.buffer=i}}class dE{constructor(e){this.jt=e}gt(e){this.jt.Ct(e)}Rt(e){this.jt.Lt(e)}At(e){this.jt.kt(e)}Et(){this.jt.$t()}}class fE{constructor(e){this.jt=e}gt(e){this.jt.xt(e)}Rt(e){this.jt.Bt(e)}At(e){this.jt.Kt(e)}Et(){this.jt.Wt()}}
2456class Cr{constructor(){this.jt=new hE,this.Ht=new dE(this.jt),this.Jt=new fE(this.jt)}seed(e){this.jt.seed(e)}Yt(e){return e===0?this.Ht:this.Jt}zt(){return this.jt.zt()}reset(){this.jt.reset()}}/**
2457 * @license
2458 * Copyright 2022 Google LLC
2459 *
2460 * Licensed under the Apache License, Version 2.0 (the "License");
2461 * you may not use this file except in compliance with the License.
2462 * You may obtain a copy of the License at
2463 *
2464 *   http://www.apache.org/licenses/LICENSE-2.0
2465 *
2466 * Unless required by applicable law or agreed to in writing, software
2467 * distributed under the License is distributed on an "AS IS" BASIS,
2468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2469 * See the License for the specific language governing permissions and
2470 * limitations under the License.
2471 */class rn{constructor(e,t,n,i){this.indexId=e,this.documentKey=t,this.arrayValue=n,this.directionalValue=i}Zt(){const e=this.directionalValue.length,t=e===0||this.directionalValue[e-1]===255?e+1:e,n=new Uint8Array(t);return n.set(this.directionalValue,0),t!==e?n.set([0],this.directionalValue.length):++n[n.length-1],new rn(this.indexId,this.documentKey,this.arrayValue,n)}}function At(r,e){let t=r.indexId-e.indexId;return t!==0?t:(t=oh(r.arrayValue,e.arrayValue),t!==0?t:(t=oh(r.directionalValue,e.directionalValue),t!==0?t:O.comparator(r.documentKey,e.documentKey)))}function oh(r,e){for(let t=0;t<r.length&&t<e.length;++t){const n=r[t]-e[t];if(n!==0)return n}return r.length-e.length}/**
2472 * @license
2473 * Copyright 2022 Google LLC
2474 *
2475 * Licensed under the Apache License, Version 2.0 (the "License");
2476 * you may not use this file except in compliance with the License.
2477 * You may obtain a copy of the License at
2478 *
2479 *   http://www.apache.org/licenses/LICENSE-2.0
2480 *
2481 * Unless required by applicable law or agreed to in writing, software
2482 * distributed under the License is distributed on an "AS IS" BASIS,
2483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2484 * See the License for the specific language governing permissions and
2485 * limitations under the License.
2486 */class ah{constructor(e){this.Xt=new te((t,n)=>ce.comparator(t.field,n.field)),this.collectionId=e.collectionGroup!=null?e.collectionGroup:e.path.lastSegment(),this.en=e.orderBy,this.tn=[];for(const t of e.filters){const n=t;
2486n.isInequality()?this.Xt=this.Xt.add(n):this.tn.push(n)}}get nn(){return this.Xt.size>1}rn(e){if(F(e.collectionGroup===this.collectionId),this.nn)return!1;const t=aa(e);if(t!==void 0&&!this.sn(t))return!1;const n=Zt(e);let i=new Set,s=0,o=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 c=this.Xt.getIterator().getNext();if(!i.has(c.field.canonicalString())){const u=n[s];if(!this.on(c,u)||!this._n(this.en[o++],u))return!1}++s}for(;s<n.length;++s){const c=n[s];if(o>=this.en.length||!this._n(this.en[o++],c))return!1}return!0}an(){if(this.nn)return null;let e=new te(ce.comparator);const t=[];for(const n of this.tn)if(!n.field.isKeyField())if(n.op==="array-contains"||n.op==="array-contains-any")t.push(new is(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new is(n.field,0))}for(const n of this.en)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new is(n.field,n.dir==="asc"?0:1)));return new Is(Is.UNKNOWN_ID,this.collectionId,t,Zr.empty())}sn(e){for(const t of this.tn)if(this.on(t,e))return!0;return!1}on(e,t){if(e===void 0||!e.field.isEqual(t.fieldPath))return!1;const n=e.op==="array-contains"||e.op==="array-contains-any";return t.kind===2===n}_n(e,t){return!!e.field.isEqual(t.fieldPath)&&(t.kind===0&&e.dir==="asc"||t.kind===1&&e.dir==="desc")}}/**
2487 * @license
2488 * Copyright 2022 Google LLC
2489 *
2490 * Licensed under the Apache License, Version 2.0 (the "License");
2491 * you may not use this file except in compliance with the License.
2492 * You may obtain a copy of the License at
2493 *
2494 *   http://www.apache.org/licenses/LICENSE-2.0
2495 *
2496 * Unless required by applicable law or agreed to in writing, software
2497 * distributed under the License is distributed on an "AS IS" BASIS,
2498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2499 * See the License for the specific language governing permissions and
2500 * limitations under the License.
2501 */function Zf(r){var e,t;if(F(r instanceof Q||r instanceof ee),r instanceof Q){if(r instanceof yf){const i=((t=(e=r.value.arrayValue)===null||e===void 0?void 0:e.values)===null||t===void 0?void 0:t.map(s=>Q.create(r.field,"==",s)))||[];return ee.create(i,"or")}return r}const n=r.filters.map(i=>Zf(i));return ee.create(n,r.op)}function pE(r){if(r.getFilters().length===0)return[];const e=Ea(Zf(r));return F(ep(e)),Ia(e)||Ta(e)?[e]:e.getFilters()}function Ia(r){return r instanceof Q}function Ta(r){return r instanceof ee&&Ya(r)}function ep(r){return Ia(r)||Ta(r)||function(t){if(t instanceof ee&&ha(t)){for(const n of t.getFilters())if(!Ia(n)&&!Ta(n))return!1;return!0}return!1}(r)}function Ea(r){if(F(r instanceof Q||r instanceof ee),r instanceof Q)return r;if(r.filters.length===1)return Ea(r.filters[0]);const e=r.filters.map(n=>Ea(n));let t=ee.create(e,r.op);return t=As(t),ep(t)?t:(F(t instanceof ee),F(Qn(t)),F(t.filters.length>1),t.filters.reduce((n,i)=>ac(n,i)))}function ac(r,e){let t;return F(r instanceof Q||r instanceof ee),F(e instanceof Q||e instanceof ee),t=r instanceof Q?e instanceof Q?function(i,s){return ee.create([i,s],"and")}(r,e):ch(r,e):e instanceof Q?ch(e,r):function(i,s){if(F(i.filters.length>0&&s.filters.length>0),Qn(i)&&Qn(s))return mf(i,s.getFilters());const o=ha(i)?i:s,c=ha(i)?s:i,u=o.filters.map(h=>ac(h,c));return ee.create(u,"or")}(r,e),As(t)}function ch(r,e){if(Qn(e))return mf(e,r.getFilters());{const t=e.filters.map(n=>ac(r,n));return ee.create(t,"or")}}function As(r){if(F(r instanceof Q||r instanceof ee),r instanceof Q)return r;const e=r.getFilters();if(e.length===1)return As(e[0]);if(ff(r))return r;const t=e.map(i=>As(i)),n=[];return t.forEach(i=>{i instanceof Q?n.push(i):i instanceof ee&&(i.op===r.op?n.push(...i.filters):n.push(i))}),n.length===1?n[0]:ee.create(n,r.op)}/**
2502 * @license
2503 * Copyright 2019 Google LLC
2504 *
2505 * Licensed under the Apache License, Version 2.0 (the "License");
2506 * you may not use this file except in compliance with the License.
2507 * You may obtain a copy of the License at
2508 *
2509 *   http://www.apache.org/licenses/LICENSE-2.0
2510 *
2511 * Unless required by applicable law or agreed to in writing, softw
2511are
2512 * distributed under the License is distributed on an "AS IS" BASIS,
2513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2514 * See the License for the specific language governing permissions and
2515 * limitations under the License.
2516 */class mE{constructor(){this.un=new cc}addToCollectionParentIndex(e,t){return this.un.add(t),A.resolve()}getCollectionParents(e,t){return A.resolve(this.un.getEntries(t))}addFieldIndex(e,t){return A.resolve()}deleteFieldIndex(e,t){return A.resolve()}deleteAllFieldIndexes(e){return A.resolve()}createTargetIndexes(e,t){return A.resolve()}getDocumentsMatchingTarget(e,t){return A.resolve(null)}getIndexType(e,t){return A.resolve(0)}getFieldIndexes(e,t){return A.resolve([])}getNextCollectionGroupToUpdate(e){return A.resolve(null)}getMinOffset(e,t){return A.resolve($e.min())}getMinOffsetFromCollectionGroup(e,t){return A.resolve($e.min())}updateCollectionGroup(e,t,n){return A.resolve()}updateIndexEntries(e,t){return A.resolve()}}class cc{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),i=this.index[t]||new te(Z.comparator),s=!i.has(n);return this.index[t]=i.add(n),s}has(e){const t=e.lastSegment(),n=e.popLast(),i=this.index[t];return i&&i.has(n)}getEntries(e){return(this.index[e]||new te(Z.comparator)).toArray()}}/**
2517 * @license
2518 * Copyright 2019 Google LLC
2519 *
2520 * Licensed under the Apache License, Version 2.0 (the "License");
2521 * you may not use this file except in compliance with the License.
2522 * You may obtain a copy of the License at
2523 *
2524 *   http://www.apache.org/licenses/LICENSE-2.0
2525 *
2526 * Unless required by applicable law or agreed to in writing, software
2527 * distributed under the License is distributed on an "AS IS" BASIS,
2528 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2529 * See the License for the specific language governing permissions and
2530 * limitations under the License.
2531 */const Hi=new Uint8Array(0);class gE{constructor(e,t){this.databaseId=t,this.cn=new cc,this.ln=new $t(n=>pn(n),(n,i)=>gi(n,i)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.cn.has(t)){const n=t.lastSegment(),i=t.popLast();e.addOnCommittedListener(()=>{this.cn.add(t)});const s={collectionId:n,parent:Ne(i)};return uh(e).put(s)}return A.resolve()}getCollectionParents(e,t){const n=[],i=IDBKeyRange.bound([t,""],[Qd(t),""],!1,!0);return uh(e).U(i).next(s=>{for(const o of s){if(o.collectionId!==t)break;n.push(et(o.parent))}return n})}addFieldIndex(e,t){const n=Dr(e),i=function(c){return{indexId:c.indexId,collectionGroup:c.collectionGroup,fields:c.fields.map(u=>[u.fieldPath.canonicalString(),u.kind])}}(t);delete i.indexId;const s=n.add(i);if(t.indexState){const o=kn(e);return s.next(c=>{o.put(nh(c,this.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return s.next()}deleteFieldIndex(e,t){const n=Dr(e),i=kn(e),s=Vn(e);return n.delete(t.indexId).next(()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))).next(()=>s.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))}deleteAllFieldIndexes(e){const t=Dr(e),n=Vn(e),i=kn(e);return t.j().next(()=>n.j()).next(()=>i.j())}createTargetIndexes(e,t){return A.forEach(this.hn(t),n=>this.getIndexType(e,n).next(i=>{if(i===0||i===1){const s=new ah(n).an();if(s!=null)return this.addFieldIndex(e,s)}}))}getDocumentsMatchingTarget(e,t){const n=Vn(e);let i=!0;const s=new Map;return A.forEach(this.hn(t),o=>this.Pn(e,o).next(c=>{i&&(i=!!c),s.set(o,c)})).next(()=>{if(i){let o=W();const c=[];return A.forEach(s,(u,h)=>{C("IndexedDbIndexManager",`Using index ${function(U){return`id=${U.indexId}|cg=${U.collectionGroup}|f=${U.fields.map($=>`${$.fieldPath}:${$.kind}`).join(",")}`}(u)} to execute ${pn(t)}`);const f=function(U,$){const J=aa($);if(J===void 0)return null;for(const K of Es(U,J.fieldPath))switch(K.op){case"array-contains-any":return K.value.arrayValue.values||[];case"array-contains":return[K.value]}return null}(h,u),m=function(U,$){const J=new Map;for(const K of Zt($))for(const T of Es(U,K.fieldPath))switch(T.op){case"==":case"in":J.set(K.fieldPath.canonicalString(),T.value);break;case"not-in":case"!=":return J.set(K.fieldPath.canonicalString(),T.value),Array.from(J.values())}return null}(h,u),_=function(U,$){const J=[];let K=!0;for(const T of Zt($)){const g=T.kind===0?ql(U,T.fieldPath,U.startAt):jl(U,T.fieldPath,U.startAt);J.push(g.value),K&&(K=g.inclusive)}return new Hn(J,K)}(h,u),b=function(U,$){const J=[];let K=!0;for(const T of Zt($)){const g=T.kind===0?jl(U,T.fieldPath,U.endAt):ql(U,T.fieldPath,U.endAt);J.push(g.value),K&&(K=g.inclusive)}return new Hn(J,K)}(h,u),V=this.In(u,h,_),N=this.In(u,h,b),D=this.Tn(u,h,m),z=this.En(u.indexId,f,V,_.inclusive,N,b.inclusive,D);return A.forEach(z,q=>n.G(q,t.limit).next(U=>
2531{U.forEach($=>{const J=O.fromSegments($.documentKey);o.has(J)||(o=o.add(J),c.push(J))})}))}).next(()=>c)}return A.resolve(null)})}hn(e){let t=this.ln.get(e);return t||(e.filters.length===0?t=[e]:t=pE(ee.create(e.filters,"and")).map(n=>fa(e.path,e.collectionGroup,e.orderBy,n.getFilters(),e.limit,e.startAt,e.endAt)),this.ln.set(e,t),t)}En(e,t,n,i,s,o,c){const u=(t!=null?t.length:1)*Math.max(n.length,s.length),h=u/(t!=null?t.length:1),f=[];for(let m=0;m<u;++m){const _=t?this.dn(t[m/h]):Hi,b=this.An(e,_,n[m%h],i),V=this.Rn(e,_,s[m%h],o),N=c.map(D=>this.An(e,_,D,!0));f.push(...this.createRange(b,V,N))}return f}An(e,t,n,i){const s=new rn(e,O.empty(),t,n);return i?s:s.Zt()}Rn(e,t,n,i){const s=new rn(e,O.empty(),t,n);return i?s.Zt():s}Pn(e,t){const n=new ah(t),i=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,i).next(s=>{let o=null;for(const c of s)n.rn(c)&&(!o||c.fields.length>o.fields.length)&&(o=c);return o})}getIndexType(e,t){let n=2;const i=this.hn(t);return A.forEach(i,s=>this.Pn(e,s).next(o=>{o?n!==0&&o.fields.length<function(u){let h=new te(ce.comparator),f=!1;for(const m of u.filters)for(const _ of m.getFlattenedFilters())_.field.isKeyField()||(_.op==="array-contains"||_.op==="array-contains-any"?f=!0:h=h.add(_.field));for(const m of u.orderBy)m.field.isKeyField()||(h=h.add(m.field));return h.size+(f?1:0)}(s)&&(n=1):n=0})).next(()=>function(o){return o.limit!==null}(t)&&i.length>1&&n===2?1:n)}Vn(e,t){const n=new Cr;for(const i of Zt(e)){const s=t.data.field(i.fieldPath);if(s==null)return null;const o=n.Yt(i.kind);nn.vt.It(s,o)}return n.zt()}dn(e){const t=new Cr;return nn.vt.It(e,t.Yt(0)),t.zt()}mn(e,t){const n=new Cr;return nn.vt.It(ri(this.databaseId,t),n.Yt(function(s){const o=Zt(s);return o.length===0?0:o[o.length-1].kind}(e))),n.zt()}Tn(e,t,n){if(n===null)return[];let i=[];i.push(new Cr);let s=0;for(const o of Zt(e)){const c=n[s++];for(const u of i)if(this.fn(t,o.fieldPath)&&ii(c))i=this.gn(i,o,c);else{const h=u.Yt(o.kind);nn.vt.It(c,h)}}return this.pn(i)}In(e,t,n){return this.Tn(e,t,n.position)}pn(e){const t=[];for(let n=0;n<e.length;++n)t[n]=e[n].zt();return t}gn(e,t,n){const i=[...e],s=[];for(const o of n.arrayValue.values||[])for(const c of i){const u=new Cr;u.seed(c.zt()),nn.vt.It(o,u.Yt(t.kind)),s.push(u)}return s}fn(e,t){return!!e.filters.find(n=>n instanceof Q&&n.field.isEqual(t)&&(n.op==="in"||n.op==="not-in"))}getFieldIndexes(e,t){const n=Dr(e),i=kn(e);return(t?n.U("collectionGroupIndex",IDBKeyRange.bound(t,t)):n.U()).next(s=>{const o=[];return A.forEach(s,c=>i.get([c.indexId,this.uid]).next(u=>{o.push(function(f,m){const _=m?new Zr(m.sequenceNumber,new $e(gn(m.readTime),new O(et(m.documentKey)),m.largestBatchId)):Zr.empty(),b=f.fields.map(([V,N])=>new is(ce.fromServerFormat(V),N));return new Is(f.indexId,f.collectionGroup,b,_)}(c,u))})).next(()=>o)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(t=>t.length===0?null:(t.sort((n,i)=>{const s=n.indexState.sequenceNumber-i.indexState.sequenceNumber;return s!==0?s:G(n.collectionGroup,i.collectionGroup)}),t[0].collectionGroup))}updateCollectionGroup(e,t,n){const i=Dr(e),s=kn(e);return this.yn(e).next(o=>i.U("collectionGroupIndex",IDBKeyRange.bound(t,t)).next(c=>A.forEach(c,u=>s.put(nh(u.indexId,this.uid,o,n)))))}updateIndexEntries(e,t){const n=new Map;return A.forEach(t,(i,s)=>{const o=n.get(i.collectionGroup);return(o?A.resolve(o):this.getFieldIndexes(e,i.collectionGroup)).next(c=>(n.set(i.collectionGroup,c),A.forEach(c,u=>this.wn(e,i,u).next(h=>{const f=this.Sn(s,u);return h.isEqual(f)?A.resolve():this.bn(e,s,u,h,f)}))))})}Dn(e,t,n,i){return Vn(e).put({indexId:i.indexId,uid:this.uid,arrayValue:i.arrayValue,directionalValue:i.directionalValue,orderedDocumentKey:this.mn(n,t.key),documentKey:t.key.path.toArray()})}vn(e,t,n,i){return Vn(e).delete([i.indexId,this.uid,i.arrayValue,i.directionalValue,this.mn(n,t.key),t.key.path.toArray()])}wn(e,t,n){const i=Vn(e);let s=new te(At);return i.J({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.mn(n,t)])},(o,c)=>{s=s.add(new rn(n.indexId,t,c.arrayValue,c.directionalValue))}).next(()=>s)}Sn(e,t){let n=new te(At);const i=this.Vn(t,e);if(i==null)return n;const s=aa(t);if(s!=null){const o=e.data.field(s.fieldPath);if(ii(o))for(const c of o.arrayValue.values||[])n=n.add(new rn(t.indexId,e.key,this.dn(c),i))}else n=n.add(new rn(t.indexId,e.key,Hi,i));return n}bn(e,t,n,i,s){C("IndexedDbIndexManager","Updating index entries for document '%s'",t.key);const o=[];return function(u,h,f,m,_){const b=u.getIterator(),V=h.getIterator();let N=Dn(b),D=Dn(V);for(;N||D;){let z=!1,q=!1;if(N&&D){const U=f(N,D);U<0?q=!0:U>0&&(z=!0)}else N!=null?q=!0:z=!0;z?(m(D),D=Dn(V)):q?(_(N),N=Dn(b)):(N=Dn(b),D=Dn(V))}}(i,s,At,c=>{o.push(this.Dn(e,t,n,c))},c=>{o.push(this.vn(e,t,n,c))}),A.waitFor(o)}yn(e){let t=1;return kn(e).J({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(n,i,s)=>{s.done(),t=i.sequenceNumber+1}
2531).next(()=>t)}createRange(e,t,n){n=n.sort((o,c)=>At(o,c)).filter((o,c,u)=>!c||At(o,u[c-1])!==0);const i=[];i.push(e);for(const o of n){const c=At(o,e),u=At(o,t);if(c===0)i[0]=e.Zt();else if(c>0&&u<0)i.push(o),i.push(o.Zt());else if(u>0)break}i.push(t);const s=[];for(let o=0;o<i.length;o+=2){if(this.Cn(i[o],i[o+1]))return[];const c=[i[o].indexId,this.uid,i[o].arrayValue,i[o].directionalValue,Hi,[]],u=[i[o+1].indexId,this.uid,i[o+1].arrayValue,i[o+1].directionalValue,Hi,[]];s.push(IDBKeyRange.bound(c,u))}return s}Cn(e,t){return At(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(lh)}getMinOffset(e,t){return A.mapArray(this.hn(t),n=>this.Pn(e,n).next(i=>i||M())).next(lh)}}function uh(r){return ge(r,"collectionParents")}function Vn(r){return ge(r,"indexEntries")}function Dr(r){return ge(r,"indexConfiguration")}function kn(r){return ge(r,"indexState")}function lh(r){F(r.length!==0);let e=r[0].indexState.offset,t=e.largestBatchId;for(let n=1;n<r.length;n++){const i=r[n].indexState.offset;Ka(i,e)<0&&(e=i),t<i.largestBatchId&&(t=i.largestBatchId)}return new $e(e.readTime,e.documentKey,t)}/**
2532 * @license
2533 * Copyright 2018 Google LLC
2534 *
2535 * Licensed under the Apache License, Version 2.0 (the "License");
2536 * you may not use this file except in compliance with the License.
2537 * You may obtain a copy of the License at
2538 *
2539 *   http://www.apache.org/licenses/LICENSE-2.0
2540 *
2541 * Unless required by applicable law or agreed to in writing, software
2542 * distributed under the License is distributed on an "AS IS" BASIS,
2543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2544 * See the License for the specific language governing permissions and
2545 * limitations under the License.
2546 */const hh={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class xe{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new xe(e,xe.DEFAULT_COLLECTION_PERCENTILE,xe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}/**
2547 * @license
2548 * Copyright 2020 Google LLC
2549 *
2550 * Licensed under the Apache License, Version 2.0 (the "License");
2551 * you may not use this file except in compliance with the License.
2552 * You may obtain a copy of the License at
2553 *
2554 *   http://www.apache.org/licenses/LICENSE-2.0
2555 *
2556 * Unless required by applicable law or agreed to in writing, software
2557 * distributed under the License is distributed on an "AS IS" BASIS,
2558 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2559 * See the License for the specific language governing permissions and
2560 * limitations under the License.
2561 */function tp(r,e,t){const n=r.store("mutations"),i=r.store("documentMutations"),s=[],o=IDBKeyRange.only(t.batchId);let c=0;const u=n.J({range:o},(f,m,_)=>(c++,_.delete()));s.push(u.next(()=>{F(c===1)}));const h=[];for(const f of t.mutations){const m=nf(e,f.key.path,t.batchId);s.push(i.delete(m)),h.push(f.key)}return A.waitFor(s).next(()=>h)}function Rs(r){if(!r)return 0;let e;if(r.document)e=r.document;else if(r.unknownDocument)e=r.unknownDocument;else{if(!r.noDocument)throw M();e=r.noDocument}return JSON.stringify(e).length}/**
2562 * @license
2563 * Copyright 2017 Google LLC
2564 *
2565 * Licensed under the Apache License, Version 2.0 (the "License");
2566 * you may not use this file except in compliance with the License.
2567 * You may obtain a copy of the License at
2568 *
2569 *   http://www.apache.org/licenses/LICENSE-2.0
2570 *
2571 * Unless required by applicable law or agreed to in writing, software
2572 * distributed under the License is distributed on an "AS IS" BASIS,
2573 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2574 * See the License for the specific language governing permissions and
2575 * limitations under the License.
2576 */xe.DEFAULT_COLLECTION_PERCENTILE=10,xe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,xe.DEFAULT=new xe(41943040,xe.DEFAULT_COLLECTION_PERCENTILE,xe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),xe.DISABLED=new xe(-1,0,0);class Hs{constructor(e,t,n,i){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=i,this.Fn={}}static lt(e,t,n,i){F(e.uid!=="");const s=e.isAuthenticated()?e.uid:"";return new Hs(s,t,n,i)}checkEmpty(e){let t=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Rt(e).J({index:"userMutationsIndex",range:n},(i,s,o)=>{t=!1,o.done()}).next(()=>t)}addMutationBatch(e,t,n,i){const s=Fn(e),o=Rt(e);return o.add({}).next(c=>{F(typeof c=="number");const u=new nc(c,t,n,i),h=function(b,V,N){const D=N.baseMutations.map(q=>ai(b.ct,q)),z=N.mutations.map(q=>ai(b.ct,q));return{userId:V,batchId:N.batchId,localWriteTimeMs:N.localWriteTime.toMillis(),baseMutations:D,mutations:z}}(this.serializer,this.userId,u),f=[];let m=new te((_,b)=>G(_.canonicalString(),b.canonicalString()));for(const _ of i){const b=nf(this.userId,_.key.path,c);
2576m=m.add(_.key.path.popLast()),f.push(o.put(h)),f.push(s.put(b,tT))}return m.forEach(_=>{f.push(this.indexManager.addToCollectionParentIndex(e,_))}),e.addOnCommittedListener(()=>{this.Fn[c]=u.keys()}),A.waitFor(f).next(()=>u)})}lookupMutationBatch(e,t){return Rt(e).get(t).next(n=>n?(F(n.userId===this.userId),tn(this.serializer,n)):null)}Mn(e,t){return this.Fn[t]?A.resolve(this.Fn[t]):this.lookupMutationBatch(e,t).next(n=>{if(n){const i=n.keys();return this.Fn[t]=i,i}return null})}getNextMutationBatchAfterBatchId(e,t){const n=t+1,i=IDBKeyRange.lowerBound([this.userId,n]);let s=null;return Rt(e).J({index:"userMutationsIndex",range:i},(o,c,u)=>{c.userId===this.userId&&(F(c.batchId>=n),s=tn(this.serializer,c)),u.done()}).next(()=>s)}getHighestUnacknowledgedBatchId(e){const t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return Rt(e).J({index:"userMutationsIndex",range:t,reverse:!0},(i,s,o)=>{n=s.batchId,o.done()}).next(()=>n)}getAllMutationBatches(e){const t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Rt(e).U("userMutationsIndex",t).next(n=>n.map(i=>tn(this.serializer,i)))}getAllMutationBatchesAffectingDocumentKey(e,t){const n=ss(this.userId,t.path),i=IDBKeyRange.lowerBound(n),s=[];return Fn(e).J({range:i},(o,c,u)=>{const[h,f,m]=o,_=et(f);if(h===this.userId&&t.path.isEqual(_))return Rt(e).get(m).next(b=>{if(!b)throw M();F(b.userId===this.userId),s.push(tn(this.serializer,b))});u.done()}).next(()=>s)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new te(G);const i=[];return t.forEach(s=>{const o=ss(this.userId,s.path),c=IDBKeyRange.lowerBound(o),u=Fn(e).J({range:c},(h,f,m)=>{const[_,b,V]=h,N=et(b);_===this.userId&&s.path.isEqual(N)?n=n.add(V):m.done()});i.push(u)}),A.waitFor(i).next(()=>this.xn(e,n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,i=n.length+1,s=ss(this.userId,n),o=IDBKeyRange.lowerBound(s);let c=new te(G);return Fn(e).J({range:o},(u,h,f)=>{const[m,_,b]=u,V=et(_);m===this.userId&&n.isPrefixOf(V)?V.length===i&&(c=c.add(b)):f.done()}).next(()=>this.xn(e,c))}xn(e,t){const n=[],i=[];return t.forEach(s=>{i.push(Rt(e).get(s).next(o=>{if(o===null)throw M();F(o.userId===this.userId),n.push(tn(this.serializer,o))}))}),A.waitFor(i).next(()=>n)}removeMutationBatch(e,t){return tp(e._e,this.userId,t).next(n=>(e.addOnCommittedListener(()=>{this.On(t.batchId)}),A.forEach(n,i=>this.referenceDelegate.markPotentiallyOrphaned(e,i))))}On(e){delete this.Fn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>{if(!t)return A.resolve();const n=IDBKeyRange.lowerBound(function(o){return[o]}(this.userId)),i=[];return Fn(e).J({range:n},(s,o,c)=>{if(s[0]===this.userId){const u=et(s[1]);i.push(u)}else c.done()}).next(()=>{F(i.length===0)})})}containsKey(e,t){return np(e,this.userId,t)}Nn(e){return rp(e).get(this.userId).next(t=>t||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function np(r,e,t){const n=ss(e,t.path),i=n[1],s=IDBKeyRange.lowerBound(n);let o=!1;return Fn(r).J({range:s,H:!0},(c,u,h)=>{const[f,m,_]=c;f===e&&m===i&&(o=!0),h.done()}).next(()=>o)}function Rt(r){return ge(r,"mutations")}function Fn(r){return ge(r,"documentMutations")}function rp(r){return ge(r,"mutationQueues")}/**
2577 * @license
2578 * Copyright 2017 Google LLC
2579 *
2580 * Licensed under the Apache License, Version 2.0 (the "License");
2581 * you may not use this file except in compliance with the License.
2582 * You may obtain a copy of the License at
2583 *
2584 *   http://www.apache.org/licenses/LICENSE-2.0
2585 *
2586 * Unless required by applicable law or agreed to in writing, software
2587 * distributed under the License is distributed on an "AS IS" BASIS,
2588 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2589 * See the License for the specific language governing permissions and
2590 * limitations under the License.
2591 */class _n{constructor(e){this.Ln=e}next(){return this.Ln+=2,this.Ln}static Bn(){return new _n(0)}static kn(){return new _n(-1)}}/**
2592 * @license
2593 * Copyright 2017 Google LLC
2594 *
2595 * Licensed under the Apache License, Version 2.0 (the "License");
2596 * you may not use this file except in compliance with the License.
2597 * You may obtain a copy of the License at
2598 *
2599 *   http://www.apache.org/licenses/LICENSE-2.0
2600 *
2601 * Unless required by applicable law or agreed to in writing, softw
2601are
2602 * distributed under the License is distributed on an "AS IS" BASIS,
2603 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2604 * See the License for the specific language governing permissions and
2605 * limitations under the License.
2606 */class _E{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.qn(e).next(t=>{const n=new _n(t.highestTargetId);return t.highestTargetId=n.next(),this.Qn(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.qn(e).next(t=>B.fromTimestamp(new ue(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.qn(e).next(t=>t.highestListenSequenceNumber)}setTargetsMetadata(e,t,n){return this.qn(e).next(i=>(i.highestListenSequenceNumber=t,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),t>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=t),this.Qn(e,i)))}addTargetData(e,t){return this.Kn(e,t).next(()=>this.qn(e).next(n=>(n.targetCount+=1,this.$n(t,n),this.Qn(e,n))))}updateTargetData(e,t){return this.Kn(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>Nn(e).delete(t.targetId)).next(()=>this.qn(e)).next(n=>(F(n.targetCount>0),n.targetCount-=1,this.Qn(e,n)))}removeTargets(e,t,n){let i=0;const s=[];return Nn(e).J((o,c)=>{const u=Br(c);u.sequenceNumber<=t&&n.get(u.targetId)===null&&(i++,s.push(this.removeTargetData(e,u)))}).next(()=>A.waitFor(s)).next(()=>i)}forEachTarget(e,t){return Nn(e).J((n,i)=>{const s=Br(i);t(s)})}qn(e){return dh(e).get("targetGlobalKey").next(t=>(F(t!==null),t))}Qn(e,t){return dh(e).put("targetGlobalKey",t)}Kn(e,t){return Nn(e).put(Yf(this.serializer,t))}$n(e,t){let n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}getTargetCount(e){return this.qn(e).next(t=>t.targetCount)}getTargetData(e,t){const n=pn(t),i=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let s=null;return Nn(e).J({range:i,index:"queryTargetsIndex"},(o,c,u)=>{const h=Br(c);gi(t,h.target)&&(s=h,u.done())}).next(()=>s)}addMatchingKeys(e,t,n){const i=[],s=Dt(e);return t.forEach(o=>{const c=Ne(o.path);i.push(s.put({targetId:n,path:c})),i.push(this.referenceDelegate.addReference(e,n,o))}),A.waitFor(i)}removeMatchingKeys(e,t,n){const i=Dt(e);return A.forEach(t,s=>{const o=Ne(s.path);return A.waitFor([i.delete([n,o]),this.referenceDelegate.removeReference(e,n,s)])})}removeMatchingKeysForTargetId(e,t){const n=Dt(e),i=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(i)}getMatchingKeysForTargetId(e,t){const n=IDBKeyRange.bound([t],[t+1],!1,!0),i=Dt(e);let s=W();return i.J({range:n,H:!0},(o,c,u)=>{const h=et(o[1]),f=new O(h);s=s.add(f)}).next(()=>s)}containsKey(e,t){const n=Ne(t.path),i=IDBKeyRange.bound([n],[Qd(n)],!1,!0);let s=0;return Dt(e).J({index:"documentTargetsIndex",H:!0,range:i},([o,c],u,h)=>{o!==0&&(s++,h.done())}).next(()=>s>0)}ot(e,t){return Nn(e).get(t).next(n=>n?Br(n):null)}}function Nn(r){return ge(r,"targets")}function dh(r){return ge(r,"targetGlobal")}function Dt(r){return ge(r,"targetDocuments")}/**
2607 * @license
2608 * Copyright 2020 Google LLC
2609 *
2610 * Licensed under the Apache License, Version 2.0 (the "License");
2611 * you may not use this file except in compliance with the License.
2612 * You may obtain a copy of the License at
2613 *
2614 *   http://www.apache.org/licenses/LICENSE-2.0
2615 *
2616 * Unless required by applicable law or agreed to in writing, software
2617 * distributed under the License is distributed on an "AS IS" BASIS,
2618 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2619 * See the License for the specific language governing permissions and
2620 * limitations under the License.
2621 */function fh([r,e],[t,n]){const i=G(r,t);return i===0?G(e,n):i}class yE{constructor(e){this.Un=e,this.buffer=new te(fh),this.Wn=0}Gn(){return++this.Wn}zn(e){const t=[e,this.Gn()];if(this.buffer.size<this.Un)this.buffer=this.buffer.add(t);else{const n=this.buffer.last();fh(t,n)<0&&(this.buffer=this.buffer.delete(n).add(t))}}get maxValue(){return this.buffer.last()[0]}}class IE{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,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(e){C("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this.jn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.jn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){jt(t)?C("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",t):await qt(t)}await this.Hn(3e5)})}}class TE{constructor(e,t){this.Jn=e,this.params=t}calculateTargetCount(e,t){return this.Jn.Yn(e).next(n=>Math.floor(t/100*n))}nthSequenceNumber(e,t){if(t===0)return A.resolve(Oe.oe);const n=new yE(t);
2621return this.Jn.forEachTarget(e,i=>n.zn(i.sequenceNumber)).next(()=>this.Jn.Zn(e,i=>n.zn(i))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.Jn.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Jn.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(C("LruGarbageCollector","Garbage collection skipped; disabled"),A.resolve(hh)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(C("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),hh):this.Xn(e,t))}getCacheSize(e){return this.Jn.getCacheSize(e)}Xn(e,t){let n,i,s,o,c,u,h;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(m=>(m>this.params.maximumSequenceNumbersToCollect?(C("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${m}`),i=this.params.maximumSequenceNumbersToCollect):i=m,o=Date.now(),this.nthSequenceNumber(e,i))).next(m=>(n=m,c=Date.now(),this.removeTargets(e,n,t))).next(m=>(s=m,u=Date.now(),this.removeOrphanedDocuments(e,n))).next(m=>(h=Date.now(),xn()<=H.DEBUG&&C("LruGarbageCollector",`LRU Garbage Collection
2622	Counted targets in ${o-f}ms
2623	Determined least recently used ${i} in `+(c-o)+`ms
2624	Removed ${s} targets in `+(u-c)+`ms
2625	Removed ${m} documents in `+(h-u)+`ms
2626Total Duration: ${h-f}ms`),A.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:s,documentsRemoved:m})))}}function EE(r,e){return new TE(r,e)}/**
2627 * @license
2628 * Copyright 2020 Google LLC
2629 *
2630 * Licensed under the Apache License, Version 2.0 (the "License");
2631 * you may not use this file except in compliance with the License.
2632 * You may obtain a copy of the License at
2633 *
2634 *   http://www.apache.org/licenses/LICENSE-2.0
2635 *
2636 * Unless required by applicable law or agreed to in writing, software
2637 * distributed under the License is distributed on an "AS IS" BASIS,
2638 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2639 * See the License for the specific language governing permissions and
2640 * limitations under the License.
2641 */class vE{constructor(e,t){this.db=e,this.garbageCollector=EE(this,t)}Yn(e){const t=this.er(e);return this.db.getTargetCache().getTargetCount(e).next(n=>t.next(i=>n+i))}er(e){let t=0;return this.Zn(e,n=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}Zn(e,t){return this.tr(e,(n,i)=>t(i))}addReference(e,t,n){return Qi(e,n)}removeReference(e,t,n){return Qi(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return Qi(e,t)}nr(e,t){return function(i,s){let o=!1;return rp(i).Y(c=>np(i,c,s).next(u=>(u&&(o=!0),A.resolve(!u)))).next(()=>o)}(e,t)}removeOrphanedDocuments(e,t){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[];let s=0;return this.tr(e,(o,c)=>{if(c<=t){const u=this.nr(e,o).next(h=>{if(!h)return s++,n.getEntry(e,o).next(()=>(n.removeEntry(o,B.min()),Dt(e).delete(function(m){return[0,Ne(m.path)]}(o))))});i.push(u)}}).next(()=>A.waitFor(i)).next(()=>n.apply(e)).next(()=>s)}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return Qi(e,t)}tr(e,t){const n=Dt(e);let i,s=Oe.oe;return n.J({index:"documentTargetsIndex"},([o,c],{path:u,sequenceNumber:h})=>{o===0?(s!==Oe.oe&&t(new O(et(i)),s),s=h,i=u):s=Oe.oe}).next(()=>{s!==Oe.oe&&t(new O(et(i)),s)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function Qi(r,e){return Dt(r).put(function(n,i){return{targetId:0,path:Ne(n.path),sequenceNumber:i}}(e,r.currentSequenceNumber))}/**
2642 * @license
2643 * Copyright 2017 Google LLC
2644 *
2645 * Licensed under the Apache License, Version 2.0 (the "License");
2646 * you may not use this file except in compliance with the License.
2647 * You may obtain a copy of the License at
2648 *
2649 *   http://www.apache.org/licenses/LICENSE-2.0
2650 *
2651 * Unless required by applicable law or agreed to in writing, softw
2651are
2652 * distributed under the License is distributed on an "AS IS" BASIS,
2653 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2654 * See the License for the specific language governing permissions and
2655 * limitations under the License.
2656 */class ip{constructor(){this.changes=new $t(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,ae.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return n!==void 0?A.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/**
2657 * @license
2658 * Copyright 2017 Google LLC
2659 *
2660 * Licensed under the Apache License, Version 2.0 (the "License");
2661 * you may not use this file except in compliance with the License.
2662 * You may obtain a copy of the License at
2663 *
2664 *   http://www.apache.org/licenses/LICENSE-2.0
2665 *
2666 * Unless required by applicable law or agreed to in writing, software
2667 * distributed under the License is distributed on an "AS IS" BASIS,
2668 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2669 * See the License for the specific language governing permissions and
2670 * limitations under the License.
2671 */class wE{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return Yt(e).put(n)}removeEntry(e,t,n){return Yt(e).delete(function(s,o){const c=s.path.toArray();return[c.slice(0,c.length-2),c[c.length-2],ws(o),c[c.length-1]]}(t,n))}updateMetadata(e,t){return this.getMetadata(e).next(n=>(n.byteSize+=t,this.rr(e,n)))}getEntry(e,t){let n=ae.newInvalidDocument(t);return Yt(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(Vr(t))},(i,s)=>{n=this.ir(t,s)}).next(()=>n)}sr(e,t){let n={size:0,document:ae.newInvalidDocument(t)};return Yt(e).J({index:"documentKeyIndex",range:IDBKeyRange.only(Vr(t))},(i,s)=>{n={document:this.ir(t,s),size:Rs(s)}}).next(()=>n)}getEntries(e,t){let n=Be();return this._r(e,t,(i,s)=>{const o=this.ir(i,s);n=n.insert(i,o)}).next(()=>n)}ar(e,t){let n=Be(),i=new ie(O.comparator);return this._r(e,t,(s,o)=>{const c=this.ir(s,o);n=n.insert(s,c),i=i.insert(s,Rs(o))}).next(()=>({documents:n,ur:i}))}_r(e,t,n){if(t.isEmpty())return A.resolve();let i=new te(gh);t.forEach(u=>i=i.add(u));const s=IDBKeyRange.bound(Vr(i.first()),Vr(i.last())),o=i.getIterator();let c=o.getNext();return Yt(e).J({index:"documentKeyIndex",range:s},(u,h,f)=>{const m=O.fromSegments([...h.prefixPath,h.collectionGroup,h.documentId]);for(;c&&gh(c,m)<0;)n(c,null),c=o.getNext();c&&c.isEqual(m)&&(n(c,h),c=o.hasNext()?o.getNext():null),c?f.$(Vr(c)):f.done()}).next(()=>{for(;c;)n(c,null),c=o.hasNext()?o.getNext():null})}getDocumentsMatchingQuery(e,t,n,i,s){const o=t.path,c=[o.popLast().toArray(),o.lastSegment(),ws(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],u=[o.popLast().toArray(),o.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return Yt(e).U(IDBKeyRange.bound(c,u,!0)).next(h=>{s==null||s.incrementDocumentReadCount(h.length);let f=Be();for(const m of h){const _=this.ir(O.fromSegments(m.prefixPath.concat(m.collectionGroup,m.documentId)),m);_.isFoundDocument()&&(_i(t,_)||i.has(_.key))&&(f=f.insert(_.key,_))}return f})}getAllFromCollectionGroup(e,t,n,i){let s=Be();const o=mh(t,n),c=mh(t,$e.max());return Yt(e).J({index:"collectionGroupIndex",range:IDBKeyRange.bound(o,c,!0)},(u,h,f)=>{const m=this.ir(O.fromSegments(h.prefixPath.concat(h.collectionGroup,h.documentId)),h);s=s.insert(m.key,m),s.size===i&&f.done()}).next(()=>s)}
2671newChangeBuffer(e){return new AE(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(t=>t.byteSize)}getMetadata(e){return ph(e).get("remoteDocumentGlobalKey").next(t=>(F(!!t),t))}rr(e,t){return ph(e).put("remoteDocumentGlobalKey",t)}ir(e,t){if(t){const n=aE(this.serializer,t);if(!(n.isNoDocument()&&n.version.isEqual(B.min())))return n}return ae.newInvalidDocument(e)}}function sp(r){return new wE(r)}class AE extends ip{constructor(e,t){super(),this.cr=e,this.trackRemovals=t,this.lr=new $t(n=>n.toString(),(n,i)=>n.isEqual(i))}applyChanges(e){const t=[];let n=0,i=new te((s,o)=>G(s.canonicalString(),o.canonicalString()));return this.changes.forEach((s,o)=>{const c=this.lr.get(s);if(t.push(this.cr.removeEntry(e,s,c.readTime)),o.isValidDocument()){const u=eh(this.cr.serializer,o);i=i.add(s.path.popLast());const h=Rs(u);n+=h-c.size,t.push(this.cr.addEntry(e,s,u))}else if(n-=c.size,this.trackRemovals){const u=eh(this.cr.serializer,o.convertToNoDocument(B.min()));t.push(this.cr.addEntry(e,s,u))}}),i.forEach(s=>{t.push(this.cr.indexManager.addToCollectionParentIndex(e,s))}),t.push(this.cr.updateMetadata(e,n)),A.waitFor(t)}getFromCache(e,t){return this.cr.sr(e,t).next(n=>(this.lr.set(t,{size:n.size,readTime:n.document.readTime}),n.document))}getAllFromCache(e,t){return this.cr.ar(e,t).next(({documents:n,ur:i})=>(i.forEach((s,o)=>{this.lr.set(s,{size:o,readTime:n.get(s).readTime})}),n))}}function ph(r){return ge(r,"remoteDocumentGlobal")}function Yt(r){return ge(r,"remoteDocumentsV14")}function Vr(r){const e=r.path.toArray();return[e.slice(0,e.length-2),e[e.length-2],e[e.length-1]]}function mh(r,e){const t=e.documentKey.path.toArray();return[r,ws(e.readTime),t.slice(0,t.length-2),t.length>0?t[t.length-1]:""]}function gh(r,e){const t=r.path.toArray(),n=e.path.toArray();let i=0;for(let s=0;s<t.length-2&&s<n.length-2;++s)if(i=G(t[s],n[s]),i)return i;return i=G(t.length,n.length),i||(i=G(t[t.length-2],n[n.length-2]),i||G(t[t.length-1],n[n.length-1]))}/**
2672 * @license
2673 * Copyright 2017 Google LLC
2674 *
2675 * Licensed under the Apache License, Version 2.0 (the "License");
2676 * you may not use this file except in compliance with the License.
2677 * You may obtain a copy of the License at
2678 *
2679 *   http://www.apache.org/licenses/LICENSE-2.0
2680 *
2681 * Unless required by applicable law or agreed to in writing, software
2682 * distributed under the License is distributed on an "AS IS" BASIS,
2683 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2684 * See the License for the specific language governing permissions and
2685 * limitations under the License.
2686 *//**
2687 * @license
2688 * Copyright 2022 Google LLC
2689 *
2690 * Licensed under the Apache License, Version 2.0 (the "License");
2691 * you may not use this file except in compliance with the License.
2692 * You may obtain a copy of the License at
2693 *
2694 *   http://www.apache.org/licenses/LICENSE-2.0
2695 *
2696 * Unless required by applicable law or agreed to in writing, software
2697 * distributed under the License is distributed on an "AS IS" BASIS,
2698 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2699 * See the License for the specific language governing permissions and
2700 * limitations under the License.
2701 */class RE{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
2702 * @license
2703 * Copyright 2017 Google LLC
2704 *
2705 * Licensed under the Apache License, Version 2.0 (the "License");
2706 * you may not use this file except in compliance with the License.
2707 * You may obtain a copy of the License at
2708 *
2709 *   http://www.apache.org/licenses/LICENSE-2.0
2710 *
2711 * Unless required by applicable law or agreed to in writing, software
2712 * distributed under the License is distributed on an "AS IS" BASIS,
2713 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2714 * See the License for the specific language governing permissions and
2715 * limitations under the License.
2716 */class op{constructor(e,t,n,i){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=i}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next(i=>(n=i,this.remoteDocumentCache.getEntry(e,t))).next(i=>
2716(n!==null&&Kr(n.mutation,i,Me.empty(),ue.now()),i))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.getLocalViewOfDocuments(e,n,W()).next(()=>n))}getLocalViewOfDocuments(e,t,n=W()){const i=tt();return this.populateOverlays(e,i,t).next(()=>this.computeViews(e,t,i,n).next(s=>{let o=Fr();return s.forEach((c,u)=>{o=o.insert(c,u.overlayedDocument)}),o}))}getOverlayedDocuments(e,t){const n=tt();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,W()))}populateOverlays(e,t,n){const i=[];return n.forEach(s=>{t.has(s)||i.push(s)}),this.documentOverlayCache.getOverlays(e,i).next(s=>{s.forEach((o,c)=>{t.set(o,c)})})}computeViews(e,t,n,i){let s=Be();const o=Gr(),c=function(){return Gr()}();return t.forEach((u,h)=>{const f=n.get(h.key);i.has(h.key)&&(f===void 0||f.mutation instanceof yt)?s=s.insert(h.key,h):f!==void 0?(o.set(h.key,f.mutation.getFieldMask()),Kr(f.mutation,h,f.mutation.getFieldMask(),ue.now())):o.set(h.key,Me.empty())}),this.recalculateAndSaveOverlays(e,s).next(u=>(u.forEach((h,f)=>o.set(h,f)),t.forEach((h,f)=>{var m;return c.set(h,new RE(f,(m=o.get(h))!==null&&m!==void 0?m:null))}),c))}recalculateAndSaveOverlays(e,t){const n=Gr();let i=new ie((o,c)=>o-c),s=W();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(o=>{for(const c of o)c.keys().forEach(u=>{const h=t.get(u);if(h===null)return;let f=n.get(u)||Me.empty();f=c.applyToLocalView(h,f),n.set(u,f);const m=(i.get(c.batchId)||W()).add(u);i=i.insert(c.batchId,m)})}).next(()=>{const o=[],c=i.getReverseIterator();for(;c.hasNext();){const u=c.getNext(),h=u.key,f=u.value,m=bf();f.forEach(_=>{if(!s.has(_)){const b=Nf(t.get(_),n.get(_));b!==null&&m.set(_,b),s=s.add(_)}}),o.push(this.documentOverlayCache.saveOverlays(e,h,m))}return A.waitFor(o)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.recalculateAndSaveOverlays(e,n))}getDocumentsMatchingQuery(e,t,n,i){return function(o){return O.isDocumentKey(o.path)&&o.collectionGroup===null&&o.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Tf(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,i):this.getDocumentsMatchingCollectionQuery(e,t,n,i)}getNextDocuments(e,t,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,i).next(s=>{const o=i-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,i-s.size):A.resolve(tt());let c=-1,u=s;return o.next(h=>A.forEach(h,(f,m)=>(c<m.largestBatchId&&(c=m.largestBatchId),s.get(f)?A.resolve():this.remoteDocumentCache.getEntry(e,f).next(_=>{u=u.insert(f,_)}))).next(()=>this.populateOverlays(e,h,s)).next(()=>this.computeViews(e,u,h,W())).next(f=>({batchId:c,changes:Rf(f)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new O(t)).next(n=>{let i=Fr();return n.isFoundDocument()&&(i=i.insert(n.key,n)),i})}getDocumentsMatchingCollectionGroupQuery(e,t,n,i){const s=t.collectionGroup;let o=Fr();return this.indexManager.getCollectionParents(e,s).next(c=>A.forEach(c,u=>{const h=function(m,_){return new ar(_,null,m.explicitOrderBy.slice(),m.filters.slice(),m.limit,m.limitType,m.startAt,m.endAt)}(t,u.child(s));return this.getDocumentsMatchingCollectionQuery(e,h,n,i).next(f=>{f.forEach((m,_)=>{o=o.insert(m,_)})})}).next(()=>o))}getDocumentsMatchingCollectionQuery(e,t,n,i){let s;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(o=>(s=o,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,s,i))).next(o=>{s.forEach((u,h)=>{const f=h.getKey();o.get(f)===null&&(o=o.insert(f,ae.newInvalidDocument(f)))});let c=Fr();return o.forEach((u,h)=>{const f=s.get(u);f!==void 0&&Kr(f.mutation,h,Me.empty(),ue.now()),_i(t,h)&&(c=c.insert(u,h))}),c})}}/**
2717 * @license
2718 * Copyright 2020 Google LLC
2719 *
2720 * Licensed under the Apache License, Version 2.0 (the "License");
2721 * you may not use this file except in compliance with the License.
2722 * You may obtain a copy of the License at
2723 *
2724 *   http://www.apache.org/licenses/LICENSE-2.0
2725 *
2726 * Unless required by applicable law or agreed to in writing, softw
2726are
2727 * distributed under the License is distributed on an "AS IS" BASIS,
2728 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2729 * See the License for the specific language governing permissions and
2730 * limitations under the License.
2731 */class bE{constructor(e){this.serializer=e,this.hr=new Map,this.Pr=new Map}getBundleMetadata(e,t){return A.resolve(this.hr.get(t))}saveBundleMetadata(e,t){return this.hr.set(t.id,function(i){return{id:i.id,version:i.version,createTime:ye(i.createTime)}}(t)),A.resolve()}getNamedQuery(e,t){return A.resolve(this.Pr.get(t))}saveNamedQuery(e,t){return this.Pr.set(t.name,function(i){return{name:i.name,query:Xf(i.bundledQuery),readTime:ye(i.readTime)}}(t)),A.resolve()}}/**
2732 * @license
2733 * Copyright 2022 Google LLC
2734 *
2735 * Licensed under the Apache License, Version 2.0 (the "License");
2736 * you may not use this file except in compliance with the License.
2737 * You may obtain a copy of the License at
2738 *
2739 *   http://www.apache.org/licenses/LICENSE-2.0
2740 *
2741 * Unless required by applicable law or agreed to in writing, software
2742 * distributed under the License is distributed on an "AS IS" BASIS,
2743 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2744 * See the License for the specific language governing permissions and
2745 * limitations under the License.
2746 */class SE{constructor(){this.overlays=new ie(O.comparator),this.Ir=new Map}getOverlay(e,t){return A.resolve(this.overlays.get(t))}getOverlays(e,t){const n=tt();return A.forEach(t,i=>this.getOverlay(e,i).next(s=>{s!==null&&n.set(i,s)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((i,s)=>{this.ht(e,t,s)}),A.resolve()}removeOverlaysForBatchId(e,t,n){const i=this.Ir.get(n);return i!==void 0&&(i.forEach(s=>this.overlays=this.overlays.remove(s)),this.Ir.delete(n)),A.resolve()}getOverlaysForCollection(e,t,n){const i=tt(),s=t.length+1,o=new O(t.child("")),c=this.overlays.getIteratorFrom(o);for(;c.hasNext();){const u=c.getNext().value,h=u.getKey();if(!t.isPrefixOf(h.path))break;h.path.length===s&&u.largestBatchId>n&&i.set(u.getKey(),u)}return A.resolve(i)}getOverlaysForCollectionGroup(e,t,n,i){let s=new ie((h,f)=>h-f);const o=this.overlays.getIterator();for(;o.hasNext();){const h=o.getNext().value;if(h.getKey().getCollectionGroup()===t&&h.largestBatchId>n){let f=s.get(h.largestBatchId);f===null&&(f=tt(),s=s.insert(h.largestBatchId,f)),f.set(h.getKey(),h)}}const c=tt(),u=s.getIterator();for(;u.hasNext()&&(u.getNext().value.forEach((h,f)=>c.set(h,f)),!(c.size()>=i)););return A.resolve(c)}ht(e,t,n){const i=this.overlays.get(n.key);if(i!==null){const o=this.Ir.get(i.largestBatchId).delete(n.key);this.Ir.set(i.largestBatchId,o)}this.overlays=this.overlays.insert(n.key,new ic(t,n));let s=this.Ir.get(t);s===void 0&&(s=W(),this.Ir.set(t,s)),this.Ir.set(t,s.add(n.key))}}/**
2747 * @license
2748 * Copyright 2024 Google LLC
2749 *
2750 * Licensed under the Apache License, Version 2.0 (the "License");
2751 * you may not use this file except in compliance with the License.
2752 * You may obtain a copy of the License at
2753 *
2754 *   http://www.apache.org/licenses/LICENSE-2.0
2755 *
2756 * Unless required by applicable law or agreed to in writing, software
2757 * distributed under the License is distributed on an "AS IS" BASIS,
2758 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2759 * See the License for the specific language governing permissions and
2760 * limitations under the License.
2761 */class PE{constructor(){this.sessionToken=fe.EMPTY_BYTE_STRING}getSessionToken(e){return A.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,A.resolve()}}/**
2762 * @license
2763 * Copyright 2017 Google LLC
2764 *
2765 * Licensed under the Apache License, Version 2.0 (the "License");
2766 * you may not use this file except in compliance with the License.
2767 * You may obtain a copy of the License at
2768 *
2769 *   http://www.apache.org/licenses/LICENSE-2.0
2770 *
2771 * Unless required by applicable law or agreed to in writing, software
2772 * distributed under the License is distributed on an "AS IS" BASIS,
2773 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2774 * See the License for the specific language governing permissions and
2775 * limitations under the License.
2776 */class uc{constructor(){this.Tr=new te(_e.Er),this.dr=new te(_e.Ar)}isEmpty(){return this.Tr.isEmpty()}addReference(e,t){const n=new _e(e,t);this.Tr=this.Tr.add(n),this.dr=this.dr.add(n)}Rr(e,t){e.forEach(n=>this.addReference(n,t))}removeReference(e,t){this.Vr(new _e(e,t))}mr(e,t){e.forEach(n=>this.removeReference(n,t))}gr(e){const t=new O(new Z([])),n=new _e(t,e),i=new _e(t,e+1),s=[];return this.dr.forEachInRange([n,i],o=>{this.Vr(o),s.push(o.key)}),s}
2776pr(){this.Tr.forEach(e=>this.Vr(e))}Vr(e){this.Tr=this.Tr.delete(e),this.dr=this.dr.delete(e)}yr(e){const t=new O(new Z([])),n=new _e(t,e),i=new _e(t,e+1);let s=W();return this.dr.forEachInRange([n,i],o=>{s=s.add(o.key)}),s}containsKey(e){const t=new _e(e,0),n=this.Tr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}}class _e{constructor(e,t){this.key=e,this.wr=t}static Er(e,t){return O.comparator(e.key,t.key)||G(e.wr,t.wr)}static Ar(e,t){return G(e.wr,t.wr)||O.comparator(e.key,t.key)}}/**
2777 * @license
2778 * Copyright 2017 Google LLC
2779 *
2780 * Licensed under the Apache License, Version 2.0 (the "License");
2781 * you may not use this file except in compliance with the License.
2782 * You may obtain a copy of the License at
2783 *
2784 *   http://www.apache.org/licenses/LICENSE-2.0
2785 *
2786 * Unless required by applicable law or agreed to in writing, software
2787 * distributed under the License is distributed on an "AS IS" BASIS,
2788 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2789 * See the License for the specific language governing permissions and
2790 * limitations under the License.
2791 */class CE{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Sr=1,this.br=new te(_e.Er)}checkEmpty(e){return A.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,i){const s=this.Sr;this.Sr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new nc(s,t,n,i);this.mutationQueue.push(o);for(const c of i)this.br=this.br.add(new _e(c.key,s)),this.indexManager.addToCollectionParentIndex(e,c.key.path.popLast());return A.resolve(o)}lookupMutationBatch(e,t){return A.resolve(this.Dr(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,i=this.vr(n),s=i<0?0:i;return A.resolve(this.mutationQueue.length>s?this.mutationQueue[s]:null)}getHighestUnacknowledgedBatchId(){return A.resolve(this.mutationQueue.length===0?-1:this.Sr-1)}getAllMutationBatches(e){return A.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new _e(t,0),i=new _e(t,Number.POSITIVE_INFINITY),s=[];return this.br.forEachInRange([n,i],o=>{const c=this.Dr(o.wr);s.push(c)}),A.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new te(G);return t.forEach(i=>{const s=new _e(i,0),o=new _e(i,Number.POSITIVE_INFINITY);this.br.forEachInRange([s,o],c=>{n=n.add(c.wr)})}),A.resolve(this.Cr(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,i=n.length+1;let s=n;O.isDocumentKey(s)||(s=s.child(""));const o=new _e(new O(s),0);let c=new te(G);return this.br.forEachWhile(u=>{const h=u.key.path;return!!n.isPrefixOf(h)&&(h.length===i&&(c=c.add(u.wr)),!0)},o),A.resolve(this.Cr(c))}Cr(e){const t=[];return e.forEach(n=>{const i=this.Dr(n);i!==null&&t.push(i)}),t}removeMutationBatch(e,t){F(this.Fr(t.batchId,"removed")===0),this.mutationQueue.shift();let n=this.br;return A.forEach(t.mutations,i=>{const s=new _e(i.key,t.batchId);return n=n.delete(s),this.referenceDelegate.markPotentiallyOrphaned(e,i.key)}).next(()=>{this.br=n})}On(e){}containsKey(e,t){const n=new _e(t,0),i=this.br.firstAfterOrEqual(n);return A.resolve(t.isEqual(i&&i.key))}performConsistencyCheck(e){return this.mutationQueue.length,A.resolve()}Fr(e,t){return this.vr(e)}vr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Dr(e){const t=this.vr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
2792 * @license
2793 * Copyright 2017 Google LLC
2794 *
2795 * Licensed under the Apache License, Version 2.0 (the "License");
2796 * you may not use this file except in compliance with the License.
2797 * You may obtain a copy of the License at
2798 *
2799 *   http://www.apache.org/licenses/LICENSE-2.0
2800 *
2801 * Unless required by applicable law or agreed to in writing, software
2802 * distributed under the License is distributed on an "AS IS" BASIS,
2803 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2804 * See the License for the specific language governing permissions and
2805 * limitations under the License.
2806 */class DE{constructor(e){this.Mr=e,this.docs=function(){return new ie(O.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,i=this.docs.get(n),s=i?i.size:0,o=this.Mr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:o}),this.size+=o-s,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return A.resolve(n?n.document.mutableCopy():ae.newInvalidDocument(t))}getEntries(e,t){let n=Be();return t.forEach(i=>
2806{const s=this.docs.get(i);n=n.insert(i,s?s.document.mutableCopy():ae.newInvalidDocument(i))}),A.resolve(n)}getDocumentsMatchingQuery(e,t,n,i){let s=Be();const o=t.path,c=new O(o.child("")),u=this.docs.getIteratorFrom(c);for(;u.hasNext();){const{key:h,value:{document:f}}=u.getNext();if(!o.isPrefixOf(h.path))break;h.path.length>o.length+1||Ka(Yd(f),n)<=0||(i.has(f.key)||_i(t,f))&&(s=s.insert(f.key,f.mutableCopy()))}return A.resolve(s)}getAllFromCollectionGroup(e,t,n,i){M()}Or(e,t){return A.forEach(this.docs,n=>t(n))}newChangeBuffer(e){return new VE(this)}getSize(e){return A.resolve(this.size)}}class VE extends ip{constructor(e){super(),this.cr=e}applyChanges(e){const t=[];return this.changes.forEach((n,i)=>{i.isValidDocument()?t.push(this.cr.addEntry(e,i)):this.cr.removeEntry(n)}),A.waitFor(t)}getFromCache(e,t){return this.cr.getEntry(e,t)}getAllFromCache(e,t){return this.cr.getEntries(e,t)}}/**
2807 * @license
2808 * Copyright 2017 Google LLC
2809 *
2810 * Licensed under the Apache License, Version 2.0 (the "License");
2811 * you may not use this file except in compliance with the License.
2812 * You may obtain a copy of the License at
2813 *
2814 *   http://www.apache.org/licenses/LICENSE-2.0
2815 *
2816 * Unless required by applicable law or agreed to in writing, software
2817 * distributed under the License is distributed on an "AS IS" BASIS,
2818 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2819 * See the License for the specific language governing permissions and
2820 * limitations under the License.
2821 */class kE{constructor(e){this.persistence=e,this.Nr=new $t(t=>pn(t),gi),this.lastRemoteSnapshotVersion=B.min(),this.highestTargetId=0,this.Lr=0,this.Br=new uc,this.targetCount=0,this.kr=_n.Bn()}forEachTarget(e,t){return this.Nr.forEach((n,i)=>t(i)),A.resolve()}getLastRemoteSnapshotVersion(e){return A.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return A.resolve(this.Lr)}allocateTargetId(e){return this.highestTargetId=this.kr.next(),A.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.Lr&&(this.Lr=t),A.resolve()}Kn(e){this.Nr.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.kr=new _n(t),this.highestTargetId=t),e.sequenceNumber>this.Lr&&(this.Lr=e.sequenceNumber)}addTargetData(e,t){return this.Kn(t),this.targetCount+=1,A.resolve()}updateTargetData(e,t){return this.Kn(t),A.resolve()}removeTargetData(e,t){return this.Nr.delete(t.target),this.Br.gr(t.targetId),this.targetCount-=1,A.resolve()}removeTargets(e,t,n){let i=0;const s=[];return this.Nr.forEach((o,c)=>{c.sequenceNumber<=t&&n.get(c.targetId)===null&&(this.Nr.delete(o),s.push(this.removeMatchingKeysForTargetId(e,c.targetId)),i++)}),A.waitFor(s).next(()=>i)}getTargetCount(e){return A.resolve(this.targetCount)}getTargetData(e,t){const n=this.Nr.get(t)||null;return A.resolve(n)}addMatchingKeys(e,t,n){return this.Br.Rr(t,n),A.resolve()}removeMatchingKeys(e,t,n){this.Br.mr(t,n);const i=this.persistence.referenceDelegate,s=[];return i&&t.forEach(o=>{s.push(i.markPotentiallyOrphaned(e,o))}),A.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.Br.gr(t),A.resolve()}getMatchingKeysForTargetId(e,t){const n=this.Br.yr(t);return A.resolve(n)}containsKey(e,t){return A.resolve(this.Br.containsKey(t))}}/**
2822 * @license
2823 * Copyright 2017 Google LLC
2824 *
2825 * Licensed under the Apache License, Version 2.0 (the "License");
2826 * you may not use this file except in compliance with the License.
2827 * You may obtain a copy of the License at
2828 *
2829 *   http://www.apache.org/licenses/LICENSE-2.0
2830 *
2831 * Unless required by applicable law or agreed to in writing, software
2832 * distributed under the License is distributed on an "AS IS" BASIS,
2833 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2834 * See the License for the specific language governing permissions and
2835 * limitations under the License.
2836 */class ap{constructor(e,t){this.qr={},this.overlays={},this.Qr=new Oe(0),this.Kr=!1,this.Kr=!0,this.$r=new PE,this.referenceDelegate=e(this),this.Ur=new kE(this),this.indexManager=new mE,this.remoteDocumentCache=function(i){return new DE(i)}(n=>
2836this.referenceDelegate.Wr(n)),this.serializer=new Jf(t),this.Gr=new bE(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Kr=!1,Promise.resolve()}get started(){return this.Kr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new SE,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.qr[e.toKey()];return n||(n=new CE(t,this.referenceDelegate),this.qr[e.toKey()]=n),n}getGlobalsCache(){return this.$r}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Gr}runTransaction(e,t,n){C("MemoryPersistence","Starting transaction:",e);const i=new NE(this.Qr.next());return this.referenceDelegate.zr(),n(i).next(s=>this.referenceDelegate.jr(i).next(()=>s)).toPromise().then(s=>(i.raiseOnCommittedEvent(),s))}Hr(e,t){return A.or(Object.values(this.qr).map(n=>()=>n.containsKey(e,t)))}}class NE extends Zd{constructor(e){super(),this.currentSequenceNumber=e}}class Qs{constructor(e){this.persistence=e,this.Jr=new uc,this.Yr=null}static Zr(e){return new Qs(e)}get Xr(){if(this.Yr)return this.Yr;throw M()}addReference(e,t,n){return this.Jr.addReference(n,t),this.Xr.delete(n.toString()),A.resolve()}removeReference(e,t,n){return this.Jr.removeReference(n,t),this.Xr.add(n.toString()),A.resolve()}markPotentiallyOrphaned(e,t){return this.Xr.add(t.toString()),A.resolve()}removeTarget(e,t){this.Jr.gr(t.targetId).forEach(i=>this.Xr.add(i.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(i=>{i.forEach(s=>this.Xr.add(s.toString()))}).next(()=>n.removeTargetData(e,t))}zr(){this.Yr=new Set}jr(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return A.forEach(this.Xr,n=>{const i=O.fromPath(n);return this.ei(e,i).next(s=>{s||t.removeEntry(i,B.min())})}).next(()=>(this.Yr=null,t.apply(e)))}updateLimboDocument(e,t){return this.ei(e,t).next(n=>{n?this.Xr.delete(t.toString()):this.Xr.add(t.toString())})}Wr(e){return 0}ei(e,t){return A.or([()=>A.resolve(this.Jr.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Hr(e,t)])}}/**
2837 * @license
2838 * Copyright 2020 Google LLC
2839 *
2840 * Licensed under the Apache License, Version 2.0 (the "License");
2841 * you may not use this file except in compliance with the License.
2842 * You may obtain a copy of the License at
2843 *
2844 *   http://www.apache.org/licenses/LICENSE-2.0
2845 *
2846 * Unless required by applicable law or agreed to in writing, software
2847 * distributed under the License is distributed on an "AS IS" BASIS,
2848 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2849 * See the License for the specific language governing permissions and
2850 * limitations under the License.
2851 */class xE{constructor(e){this.serializer=e}O(e,t,n,i){const s=new qs("createOrUpgrade",t);n<1&&i>=1&&(function(u){u.createObjectStore("owner")}(e),function(u){u.createObjectStore("mutationQueues",{keyPath:"userId"}),u.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Dl,{unique:!0}),u.createObjectStore("documentMutations")}(e),_h(e),function(u){u.createObjectStore("remoteDocuments")}(e));let o=A.resolve();return n<3&&i>=3&&(n!==0&&(function(u){u.deleteObjectStore("targetDocuments"),u.deleteObjectStore("targets"),u.deleteObjectStore("targetGlobal")}(e),_h(e)),o=o.next(()=>function(u){const h=u.store("targetGlobal"),f={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:B.min().toTimestamp(),targetCount:0};return h.put("targetGlobalKey",f)}(s))),n<4&&i>=4&&(n!==0&&(o=o.next(()=>function(u,h){return h.store("mutations").U().next(f=>{u.deleteObjectStore("mutations"),u.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Dl,{unique:!0});const m=h.store("mutations"),_=f.map(b=>m.put(b));return A.waitFor(_)})}(e,s))),o=o.next(()=>{(function(u){u.createObjectStore("clientMetadata",{keyPath:"clientId"})})(e)})),n<5&&i>=5&&(o=o.next(()=>this.ni(s))),n<6&&i>=6&&(o=o.next(()=>(function(u){u.createObjectStore("remoteDocumentGlobal")}(e),this.ri(s)))),n<7&&i>=7&&(o=o.next(()=>this.ii(s))),n<8&&i>=8&&(o=o.next(()=>this.si(e,s))),n<9&&i>=9&&(o=o.next(()=>{(function(u){u.objectStoreNames.contains("remoteDocumentChanges")&&u.deleteObjectStore("remoteDocumentChanges")}
2851)(e)})),n<10&&i>=10&&(o=o.next(()=>this.oi(s))),n<11&&i>=11&&(o=o.next(()=>{(function(u){u.createObjectStore("bundles",{keyPath:"bundleId"})})(e),function(u){u.createObjectStore("namedQueries",{keyPath:"name"})}(e)})),n<12&&i>=12&&(o=o.next(()=>{(function(u){const h=u.createObjectStore("documentOverlays",{keyPath:fT});h.createIndex("collectionPathOverlayIndex",pT,{unique:!1}),h.createIndex("collectionGroupOverlayIndex",mT,{unique:!1})})(e)})),n<13&&i>=13&&(o=o.next(()=>function(u){const h=u.createObjectStore("remoteDocumentsV14",{keyPath:nT});h.createIndex("documentKeyIndex",rT),h.createIndex("collectionGroupIndex",iT)}(e)).next(()=>this._i(e,s)).next(()=>e.deleteObjectStore("remoteDocuments"))),n<14&&i>=14&&(o=o.next(()=>this.ai(e,s))),n<15&&i>=15&&(o=o.next(()=>function(u){u.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),u.createObjectStore("indexState",{keyPath:uT}).createIndex("sequenceNumberIndex",lT,{unique:!1}),u.createObjectStore("indexEntries",{keyPath:hT}).createIndex("documentKeyIndex",dT,{unique:!1})}(e))),n<16&&i>=16&&(o=o.next(()=>{t.objectStore("indexState").clear()}).next(()=>{t.objectStore("indexEntries").clear()})),n<17&&i>=17&&(o=o.next(()=>{(function(u){u.createObjectStore("globals",{keyPath:"name"})})(e)})),o}ri(e){let t=0;return e.store("remoteDocuments").J((n,i)=>{t+=Rs(i)}).next(()=>{const n={byteSize:t};return e.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)})}ni(e){const t=e.store("mutationQueues"),n=e.store("mutations");return t.U().next(i=>A.forEach(i,s=>{const o=IDBKeyRange.bound([s.userId,-1],[s.userId,s.lastAcknowledgedBatchId]);return n.U("userMutationsIndex",o).next(c=>A.forEach(c,u=>{F(u.userId===s.userId);const h=tn(this.serializer,u);return tp(e,s.userId,h).next(()=>{})}))}))}ii(e){const t=e.store("targetDocuments"),n=e.store("remoteDocuments");return e.store("targetGlobal").get("targetGlobalKey").next(i=>{const s=[];return n.J((o,c)=>{const u=new Z(o),h=function(m){return[0,Ne(m)]}(u);s.push(t.get(h).next(f=>f?A.resolve():(m=>t.put({targetId:0,path:Ne(m),sequenceNumber:i.highestListenSequenceNumber}))(u)))}).next(()=>A.waitFor(s))})}si(e,t){e.createObjectStore("collectionParents",{keyPath:cT});const n=t.store("collectionParents"),i=new cc,s=o=>{if(i.add(o)){const c=o.lastSegment(),u=o.popLast();return n.put({collectionId:c,parent:Ne(u)})}};return t.store("remoteDocuments").J({H:!0},(o,c)=>{const u=new Z(o);return s(u.popLast())}).next(()=>t.store("documentMutations").J({H:!0},([o,c,u],h)=>{const f=et(c);return s(f.popLast())}))}oi(e){const t=e.store("targets");return t.J((n,i)=>{const s=Br(i),o=Yf(this.serializer,s);return t.put(o)})}_i(e,t){const n=t.store("remoteDocuments"),i=[];return n.J((s,o)=>{const c=t.store("remoteDocumentsV14"),u=function(m){return m.document?new O(Z.fromString(m.document.name).popFirst(5)):m.noDocument?O.fromSegments(m.noDocument.path):m.unknownDocument?O.fromSegments(m.unknownDocument.path):M()}(o).path.toArray(),h={prefixPath:u.slice(0,u.length-2),collectionGroup:u[u.length-2],documentId:u[u.length-1],readTime:o.readTime||[0,0],unknownDocument:o.unknownDocument,noDocument:o.noDocument,document:o.document,hasCommittedMutations:!!o.hasCommittedMutations};i.push(c.put(h))}).next(()=>A.waitFor(i))}ai(e,t){const n=t.store("mutations"),i=sp(this.serializer),s=new ap(Qs.Zr,this.serializer.ct);return n.U().next(o=>{const c=new Map;return o.forEach(u=>{var h;let f=(h=c.get(u.userId))!==null&&h!==void 0?h:W();tn(this.serializer,u).keys().forEach(m=>f=f.add(m)),c.set(u.userId,f)}),A.forEach(c,(u,h)=>{const f=new Ce(h),m=Ws.lt(this.serializer,f),_=s.getIndexManager(f),b=Hs.lt(f,this.serializer,_,s.referenceDelegate);return new op(i,b,m,_).recalculateAndSaveOverlaysForDocumentKeys(new ca(t,Oe.oe),u).next()})})}}function _h(r){r.createObjectStore("targetDocuments",{keyPath:oT}).createIndex("documentTargetsIndex",aT,{unique:!0}),r.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",sT,{unique:!0}),r.createObjectStore("targetGlobal")}const qo="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 lc{constructor(e,t,n,i,s,o,c,u,h,f,m=17){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.ui=s,this.window=o,this.document=c,this.ci=h,this.li=f,this.hi=m,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=_=>
2851Promise.resolve(),!lc.D())throw new k(P.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new vE(this,i),this.Ai=t+"main",this.serializer=new Jf(u),this.Ri=new xt(this.Ai,this.hi,new xE(this.serializer)),this.$r=new uE,this.Ur=new _E(this.referenceDelegate,this.serializer),this.remoteDocumentCache=sp(this.serializer),this.Gr=new cE,this.window&&this.window.localStorage?this.Vi=this.window.localStorage:(this.Vi=null,f===!1&&he("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 k(P.FAILED_PRECONDITION,qo);return this.fi(),this.gi(),this.pi(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.Ur.getHighestSequenceNumber(e))}).then(e=>{this.Qr=new Oe(e,this.ci)}).then(()=>{this.Kr=!0}).catch(e=>(this.Ri&&this.Ri.close(),Promise.reject(e)))}yi(e){return this.di=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.Ri.L(async t=>{t.newVersion===null&&await e()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.ui.enqueueAndForget(async()=>{this.started&&await this.mi()}))}mi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>Ji(e).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.wi(e).next(t=>{t||(this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)))})}).next(()=>this.Si(e)).next(t=>this.isPrimary&&!t?this.bi(e).next(()=>!1):!!t&&this.Di(e).next(()=>!0))).catch(e=>{if(jt(e))return C("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return C("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.ui.enqueueRetryable(()=>this.di(e)),this.isPrimary=e})}wi(e){return kr(e).get("owner").next(t=>A.resolve(this.vi(t)))}Ci(e){return Ji(e).delete(this.clientId)}async Fi(){if(this.isPrimary&&!this.Mi(this.Ei,18e5)){this.Ei=Date.now();const e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",t=>{const n=ge(t,"clientMetadata");return n.U().next(i=>{const s=this.xi(i,18e5),o=i.filter(c=>s.indexOf(c)===-1);return A.forEach(o,c=>n.delete(c.clientId)).next(()=>o)})}).catch(()=>[]);if(this.Vi)for(const t of e)this.Vi.removeItem(this.Oi(t.clientId))}}pi(){this.Ti=this.ui.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.mi().then(()=>this.Fi()).then(()=>this.pi()))}vi(e){return!!e&&e.ownerId===this.clientId}Si(e){return this.li?A.resolve(!0):kr(e).get("owner").next(t=>{if(t!==null&&this.Mi(t.leaseTimestampMs,5e3)&&!this.Ni(t.ownerId)){if(this.vi(t)&&this.networkEnabled)return!0;if(!this.vi(t)){if(!t.allowTabSynchronization)throw new k(P.FAILED_PRECONDITION,qo);return!1}}return!(!this.networkEnabled||!this.inForeground)||Ji(e).U().next(n=>this.xi(n,5e3).find(i=>{if(this.clientId!==i.clientId){const s=!this.networkEnabled&&i.networkEnabled,o=!this.inForeground&&i.inForeground,c=this.networkEnabled===i.networkEnabled;if(s||o&&c)return!0}return!1})===void 0)}).next(t=>(this.isPrimary!==t&&C("IndexedDbPersistence",`Client ${t?"is":"is not"} eligible for a primary lease.`),t))}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"],e=>{const t=new ca(e,Oe.oe);return this.bi(t).next(()=>this.Ci(t))}),this.Ri.close(),this.qi()}xi(e,t){return e.filter(n=>this.Mi(n.updateTimeMs,t)&&!this.Ni(n.clientId))}Qi(){return this.runTransaction("getActiveClients","readonly",e=>Ji(e).U().next(t=>this.xi(t,18e5).map(n=>n.clientId)))}get started(){return this.Kr}getGlobalsCache(){return this.$r}getMutationQueue(e,t){return Hs.lt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.Ur}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new gE(e,this.serializer.ct.databaseId)}getDocumentOverlayCache(e){return Ws.lt(this.serializer,e)}getBundleCache(){return this.Gr}runTransaction(e,t,n){C("IndexedDbPersistence","Starting transaction:",e);const i=t==="readonly"?"readonly":"readwrite",s=function(u){return u===17?yT:u===16?_T:u===15?Ha:u===14?of:u===13?sf:u===12?gT:u===11?rf:void M()}(this.hi);let o;return this.Ri.runTransaction(e,i,s,c=>(o=new ca(c,this.Qr?this.Qr.next():Oe.oe),t==="readwrite-primary"?this.wi(o).next(u=>!!u||this.Si(o)).next(u=>{if(!u)throw he(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.ui.enqueueRetryable(()=>this.di(!1)),new k(P.FAILED_PRECONDITION,Xd);return n(o)}).next(u=>this.Di(o).next(()=>u)):this.Ki(o).next(()=>n(o)))).then(c=>(o.raiseOnCommittedEvent(),c))}Ki(e){return kr(e).get("owner").next(t=>
2851{if(t!==null&&this.Mi(t.leaseTimestampMs,5e3)&&!this.Ni(t.ownerId)&&!this.vi(t)&&!(this.li||this.allowTabSynchronization&&t.allowTabSynchronization))throw new k(P.FAILED_PRECONDITION,qo)})}Di(e){const t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return kr(e).put("owner",t)}static D(){return xt.D()}bi(e){const t=kr(e);return t.get("owner").next(n=>this.vi(n)?(C("IndexedDbPersistence","Releasing primary lease."),t.delete("owner")):A.resolve())}Mi(e,t){const n=Date.now();return!(e<n-t)&&(!(e>n)||(he(`Detected an update time that is in the future: ${e} > ${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 e;typeof((e=this.window)===null||e===void 0?void 0:e.addEventListener)=="function"&&(this.Pi=()=>{this.Li();const t=/(?:Version|Mobile)\/1[456]/;Zh()&&(navigator.appVersion.match(t)||navigator.userAgent.match(t))&&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(e){var t;try{const n=((t=this.Vi)===null||t===void 0?void 0:t.getItem(this.Oi(e)))!==null;return C("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(n){return he("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(e){he("Failed to set zombie client id.",e)}}
2851qi(){if(this.Vi)try{this.Vi.removeItem(this.Oi(this.clientId))}catch{}}Oi(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function kr(r){return ge(r,"owner")}function Ji(r){return ge(r,"clientMetadata")}function cp(r,e){let t=r.projectId;return r.isDefaultDatabase||(t+="."+r.database),"firestore/"+e+"/"+t+"/"}/**
2852 * @license
2853 * Copyright 2017 Google LLC
2854 *
2855 * Licensed under the Apache License, Version 2.0 (the "License");
2856 * you may not use this file except in compliance with the License.
2857 * You may obtain a copy of the License at
2858 *
2859 *   http://www.apache.org/licenses/LICENSE-2.0
2860 *
2861 * Unless required by applicable law or agreed to in writing, software
2862 * distributed under the License is distributed on an "AS IS" BASIS,
2863 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2864 * See the License for the specific language governing permissions and
2865 * limitations under the License.
2866 */class hc{constructor(e,t,n,i){this.targetId=e,this.fromCache=t,this.$i=n,this.Ui=i}static Wi(e,t){let n=W(),i=W();for(const s of t.docChanges)switch(s.type){case 0:n=n.add(s.doc.key);break;case 1:i=i.add(s.doc.key)}return new hc(e,t.fromCache,n,i)}}/**
2867 * @license
2868 * Copyright 2023 Google LLC
2869 *
2870 * Licensed under the Apache License, Version 2.0 (the "License");
2871 * you may not use this file except in compliance with the License.
2872 * You may obtain a copy of the License at
2873 *
2874 *   http://www.apache.org/licenses/LICENSE-2.0
2875 *
2876 * Unless required by applicable law or agreed to in writing, software
2877 * distributed under the License is distributed on an "AS IS" BASIS,
2878 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2879 * See the License for the specific language governing permissions and
2880 * limitations under the License.
2881 */class OE{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
2882 * @license
2883 * Copyright 2019 Google LLC
2884 *
2885 * Licensed under the Apache License, Version 2.0 (the "License");
2886 * you may not use this file except in compliance with the License.
2887 * You may obtain a copy of the License at
2888 *
2889 *   http://www.apache.org/licenses/LICENSE-2.0
2890 *
2891 * Unless required by applicable law or agreed to in writing, software
2892 * distributed under the License is distributed on an "AS IS" BASIS,
2893 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2894 * See the License for the specific language governing permissions and
2895 * limitations under the License.
2896 */class up{constructor(){this.Gi=!1,this.zi=!1,this.ji=100,this.Hi=function(){return Zh()?8:ef(me())>0?6:4}()}initialize(e,t){this.Ji=e,this.indexManager=t,this.Gi=!0}getDocumentsMatchingQuery(e,t,n,i){const s={result:null};return this.Yi(e,t).next(o=>{s.result=o}).next(()=>{if(!s.result)return this.Zi(e,t,i,n).next(o=>{s.result=o})}).next(()=>{if(s.result)return;const o=new OE;return this.Xi(e,t,o).next(c=>{if(s.result=c,this.zi)return this.es(e,t,o,c.size)})}).next(()=>s.result)}es(e,t,n,i){return n.documentReadCount<this.ji?(xn()<=H.DEBUG&&C("QueryEngine","SDK will not create cache indexes for query:",On(t),"since it only creates cache indexes for collection contains","more than or equal to",this.ji,"documents"),A.resolve()):(xn()<=H.DEBUG&&C("QueryEngine","Query:",On(t),"scans",n.documentReadCount,"local documents and returns",i,"documents as results."),n.documentReadCount>this.Hi*i?(xn()<=H.DEBUG&&C("QueryEngine","The SDK decides to create cache indexes for query:",On(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,qe(t))):A.resolve())}Yi(e,t){if($l(t))return A.resolve(null);let n=qe(t);return this.indexManager.getIndexType(e,n).next(i=>i===0?null:(t.limit!==null&&i===1&&(t=vs(t,null,"F"),n=qe(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next(s=>{const o=W(...s);return this.Ji.getDocuments(e,o).next(c=>this.indexManager.getMinOffset(e,n).next(u=>{const h=this.ts(t,c);return this.ns(t,h,o,u.readTime)?this.Yi(e,vs(t,null,"F")):this.rs(e,h,t,u)}))})))}
2896Zi(e,t,n,i){return $l(t)||i.isEqual(B.min())?A.resolve(null):this.Ji.getDocuments(e,n).next(s=>{const o=this.ts(t,s);return this.ns(t,o,n,i)?A.resolve(null):(xn()<=H.DEBUG&&C("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),On(t)),this.rs(e,o,t,Jd(i,-1)).next(c=>c))})}ts(e,t){let n=new te(wf(e));return t.forEach((i,s)=>{_i(e,s)&&(n=n.add(s))}),n}ns(e,t,n,i){if(e.limit===null)return!1;if(n.size!==t.size)return!0;const s=e.limitType==="F"?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(i)>0)}Xi(e,t,n){return xn()<=H.DEBUG&&C("QueryEngine","Using full collection scan to execute query:",On(t)),this.Ji.getDocumentsMatchingQuery(e,t,$e.min(),n)}rs(e,t,n,i){return this.Ji.getDocumentsMatchingQuery(e,n,i).next(s=>(t.forEach(o=>{s=s.insert(o.key,o)}),s))}}/**
2897 * @license
2898 * Copyright 2020 Google LLC
2899 *
2900 * Licensed under the Apache License, Version 2.0 (the "License");
2901 * you may not use this file except in compliance with the License.
2902 * You may obtain a copy of the License at
2903 *
2904 *   http://www.apache.org/licenses/LICENSE-2.0
2905 *
2906 * Unless required by applicable law or agreed to in writing, software
2907 * distributed under the License is distributed on an "AS IS" BASIS,
2908 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2909 * See the License for the specific language governing permissions and
2910 * limitations under the License.
2911 */class ME{constructor(e,t,n,i){this.persistence=e,this.ss=t,this.serializer=i,this.os=new ie(G),this._s=new $t(s=>pn(s),gi),this.us=new Map,this.cs=e.getRemoteDocumentCache(),this.Ur=e.getTargetCache(),this.Gr=e.getBundleCache(),this.ls(n)}ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new op(this.cs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.cs.setIndexManager(this.indexManager),this.ss.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.os))}}function lp(r,e,t,n){return new ME(r,e,t,n)}async function hp(r,e){const t=L(r);return await t.persistence.runTransaction("Handle user change","readonly",n=>{let i;return t.mutationQueue.getAllMutationBatches(n).next(s=>(i=s,t.ls(e),t.mutationQueue.getAllMutationBatches(n))).next(s=>{const o=[],c=[];let u=W();for(const h of i){o.push(h.batchId);for(const f of h.mutations)u=u.add(f.key)}for(const h of s){c.push(h.batchId);for(const f of h.mutations)u=u.add(f.key)}return t.localDocuments.getDocuments(n,u).next(h=>({hs:h,removedBatchIds:o,addedBatchIds:c}))})})}function LE(r,e){const t=L(r);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{const i=e.batch.keys(),s=t.cs.newChangeBuffer({trackRemovals:!0});return function(c,u,h,f){const m=h.batch,_=m.keys();let b=A.resolve();return _.forEach(V=>{b=b.next(()=>f.getEntry(u,V)).next(N=>{const D=h.docVersions.get(V);F(D!==null),N.version.compareTo(D)<0&&(m.applyToRemoteDocument(N,h),N.isValidDocument()&&(N.setReadTime(h.commitVersion),f.addEntry(N)))})}),b.next(()=>c.mutationQueue.removeMutationBatch(u,m))}(t,n,e,s).next(()=>s.apply(n)).next(()=>t.mutationQueue.performConsistencyCheck(n)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(n,i,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(c){let u=W();for(let h=0;h<c.mutationResults.length;++h)c.mutationResults[h].transformResults.length>0&&(u=u.add(c.batch.mutations[h].key));return u}(e))).next(()=>t.localDocuments.getDocuments(n,i))})}function dp(r){const e=L(r);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Ur.getLastRemoteSnapshotVersion(t))}function FE(r,e){const t=L(r),n=e.snapshotVersion;let i=t.os;return t.persistence.runTransaction("Apply remote event","readwrite-primary",s=>{const o=t.cs.newChangeBuffer({trackRemovals:!0});i=t.os;const c=[];
2911e.targetChanges.forEach((f,m)=>{const _=i.get(m);if(!_)return;c.push(t.Ur.removeMatchingKeys(s,f.removedDocuments,m).next(()=>t.Ur.addMatchingKeys(s,f.addedDocuments,m)));let b=_.withSequenceNumber(s.currentSequenceNumber);e.targetMismatches.get(m)!==null?b=b.withResumeToken(fe.EMPTY_BYTE_STRING,B.min()).withLastLimboFreeSnapshotVersion(B.min()):f.resumeToken.approximateByteSize()>0&&(b=b.withResumeToken(f.resumeToken,n)),i=i.insert(m,b),function(N,D,z){return N.resumeToken.approximateByteSize()===0||D.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=3e8?!0:z.addedDocuments.size+z.modifiedDocuments.size+z.removedDocuments.size>0}(_,b,f)&&c.push(t.Ur.updateTargetData(s,b))});let u=Be(),h=W();if(e.documentUpdates.forEach(f=>{e.resolvedLimboDocuments.has(f)&&c.push(t.persistence.referenceDelegate.updateLimboDocument(s,f))}),c.push(UE(s,o,e.documentUpdates).next(f=>{u=f.Ps,h=f.Is})),!n.isEqual(B.min())){const f=t.Ur.getLastRemoteSnapshotVersion(s).next(m=>t.Ur.setTargetsMetadata(s,s.currentSequenceNumber,n));c.push(f)}return A.waitFor(c).next(()=>o.apply(s)).next(()=>t.localDocuments.getLocalViewOfDocuments(s,u,h)).next(()=>u)}).then(s=>(t.os=i,s))}function UE(r,e,t){let n=W(),i=W();return t.forEach(s=>n=n.add(s)),e.getEntries(r,n).next(s=>{let o=Be();return t.forEach((c,u)=>{const h=s.get(c);u.isFoundDocument()!==h.isFoundDocument()&&(i=i.add(c)),u.isNoDocument()&&u.version.isEqual(B.min())?(e.removeEntry(c,u.readTime),o=o.insert(c,u)):!h.isValidDocument()||u.version.compareTo(h.version)>0||u.version.compareTo(h.version)===0&&h.hasPendingWrites?(e.addEntry(u),o=o.insert(c,u)):C("LocalStore","Ignoring outdated watch update for ",c,". Current version:",h.version," Watch version:",u.version)}),{Ps:o,Is:i}})}function BE(r,e){const t=L(r);return t.persistence.runTransaction("Get next mutation batch","readonly",n=>(e===void 0&&(e=-1),t.mutationQueue.getNextMutationBatchAfterBatchId(n,e)))}function bs(r,e){const t=L(r);return t.persistence.runTransaction("Allocate target","readwrite",n=>{let i;return t.Ur.getTargetData(n,e).next(s=>s?(i=s,A.resolve(i)):t.Ur.allocateTargetId(n).next(o=>(i=new dt(e,o,"TargetPurposeListen",n.currentSequenceNumber),t.Ur.addTargetData(n,i).next(()=>i))))}).then(n=>{const i=t.os.get(n.targetId);return(i===null||n.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(t.os=t.os.insert(n.targetId,n),t._s.set(e,n.targetId)),n})}async function tr(r,e,t){const n=L(r),i=n.os.get(e),s=t?"readwrite":"readwrite-primary";try{t||await n.persistence.runTransaction("Release target",s,o=>n.persistence.referenceDelegate.removeTarget(o,i))}catch(o){if(!jt(o))throw o;C("LocalStore",`Failed to update sequence numbers for target ${e}: ${o}`)}n.os=n.os.remove(e),n._s.delete(i.target)}function va(r,e,t){const n=L(r);let i=B.min(),s=W();return n.persistence.runTransaction("Execute query","readwrite",o=>function(u,h,f){const m=L(u),_=m._s.get(f);return _!==void 0?A.resolve(m.os.get(_)):m.Ur.getTargetData(h,f)}(n,o,qe(e)).next(c=>{if(c)return i=c.lastLimboFreeSnapshotVersion,n.Ur.getMatchingKeysForTargetId(o,c.targetId).next(u=>{s=u})}).next(()=>n.ss.getDocumentsMatchingQuery(o,e,t?i:B.min(),t?s:W())).next(c=>(mp(n,vf(e),c),{documents:c,Ts:s})))}function fp(r,e){const t=L(r),n=L(t.Ur),i=t.os.get(e);return i?Promise.resolve(i.target):t.persistence.runTransaction("Get target data","readonly",s=>n.ot(s,e).next(o=>o?o.target:null))}function pp(r,e){const t=L(r),n=t.us.get(e)||B.min();return t.persistence.runTransaction("Get new document changes","readonly",i=>t.cs.getAllFromCollectionGroup(i,e,Jd(n,-1),Number.MAX_SAFE_INTEGER)).then(i=>(mp(t,e,i),i))}function mp(r,e,t){let n=r.us.get(e)||B.min();t.forEach((i,s)=>{s.readTime.compareTo(n)>0&&(n=s.readTime)}),r.us.set(e,n)}function yh(r,e){return`firestore_clients_${r}_${e}`}function Ih(r,e,t){let n=`firestore_mutations_${r}_${t}`;return e.isAuthenticated()&&(n+=`_${e.uid}`),n}function jo(r,e){return`firestore_targets_${r}_${e}`}class Ss{constructor(e,t,n,i){this.user=e,this.batchId=t,this.state=n,this.error=i}static Rs(e,t,n){const i=JSON.parse(n);let s,o=typeof i=="object"&&["pending","acknowledged","rejected"].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error=="object");return o&&i.error&&(o=typeof i.error.message=="string"&&typeof i.error.code=="string",o&&(s=new k(i.error.code,i.error.message))),o?new Ss(e,t,i.state,s):(he("SharedCl
2911ientState",`Failed to parse mutation state for ID '${t}': ${n}`),null)}Vs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class Wr{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Rs(e,t){const n=JSON.parse(t);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 k(n.error.code,n.error.message))),s?new Wr(e,n.state,i):(he("SharedClientState",`Failed to parse target state for ID '${e}': ${t}`),null)}Vs(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class Ps{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Rs(e,t){const n=JSON.parse(t);let i=typeof n=="object"&&n.activeTargetIds instanceof Array,s=Xa();for(let o=0;i&&o<n.activeTargetIds.length;++o)i=tf(n.activeTargetIds[o]),s=s.add(n.activeTargetIds[o]);return i?new Ps(e,s):(he("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class dc{constructor(e,t){this.clientId=e,this.onlineState=t}static Rs(e){const t=JSON.parse(e);return typeof t=="object"&&["Unknown","Online","Offline"].indexOf(t.onlineState)!==-1&&typeof t.clientId=="string"?new dc(t.clientId,t.onlineState):(he("SharedClientState",`Failed to parse online state: ${e}`),null)}}class wa{constructor(){this.activeTargetIds=Xa()}fs(e){this.activeTargetIds=this.activeTargetIds.add(e)}gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Vs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class $o{constructor(e,t,n,i,s){this.window=e,this.ui=t,this.persistenceKey=n,this.ps=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.ys=this.ws.bind(this),this.Ss=new ie(G),this.started=!1,this.bs=[];const o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=s,this.Ds=yh(this.persistenceKey,this.ps),this.vs=function(u){return`firestore_sequence_number_${u}`}(this.persistenceKey),this.Ss=this.Ss.insert(this.ps,new wa),this.Cs=new RegExp(`^firestore_clients_${o}_([^_]*)$`),this.Fs=new RegExp(`^firestore_mutations_${o}_(\\d+)(?:_(.*))?$`),this.Ms=new RegExp(`^firestore_targets_${o}_(\\d+)$`),this.xs=function(u){return`firestore_online_state_${u}`}(this.persistenceKey),this.Os=function(u){return`firestore_bundle_loaded_v2_${u}`}(this.persistenceKey),this.window.addEventListener("storage",this.ys)}static D(e){return!(!e||!e.localStorage)}async start(){const e=await this.syncEngine.Qi();for(const n of e){if(n===this.ps)continue;const i=this.getItem(yh(this.persistenceKey,n));if(i){const s=Ps.Rs(n,i);s&&(this.Ss=this.Ss.insert(s.clientId,s))}}this.Ns();const t=this.storage.getItem(this.xs);if(t){const n=this.Ls(t);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(e){this.setItem(this.vs,JSON.stringify(e))}getAllActiveQueryTargets(){return this.ks(this.Ss)}isActiveQueryTarget(e){let t=!1;return this.Ss.forEach((n,i)=>{i.activeTargetIds.has(e)&&(t=!0)}),t}addPendingMutation(e){this.qs(e,"pending")}updateMutationState(e,t,n){this.qs(e,t,n),this.Qs(e)}addLocalQueryTarget(e,t=!0){let n="not-current";if(this.isActiveQueryTarget(e)){const i=this.storage.getItem(jo(this.persistenceKey,e));if(i){const s=Wr.Rs(e,i);s&&(n=s.state)}}return t&&this.Ks.fs(e),this.Ns(),n}removeLocalQueryTarget(e){this.Ks.gs(e),this.Ns()}isLocalQueryTarget(e){return this.Ks.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(jo(this.persistenceKey,e))}updateQueryState(e,t,n){this.$s(e,t,n)}handleUserChange(e,t,n){t.forEach(i=>{this.Qs(i)}),this.currentUser=e,n.forEach(i=>{this.addPendingMutation(i)})}setOnlineState(e){this.Us(e)}notifyBundleLoaded(e){this.Ws(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.ys),this.removeItem(this.Ds),this.started=!1)}getItem(e){const t=this.storage.getItem(e);
2911return C("SharedClientState","READ",e,t),t}setItem(e,t){C("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){C("SharedClientState","REMOVE",e),this.storage.removeItem(e)}ws(e){const t=e;if(t.storageArea===this.storage){if(C("SharedClientState","EVENT",t.key,t.newValue),t.key===this.Ds)return void he("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.ui.enqueueRetryable(async()=>{if(this.started){if(t.key!==null){if(this.Cs.test(t.key)){if(t.newValue==null){const n=this.Gs(t.key);return this.zs(n,null)}{const n=this.js(t.key,t.newValue);if(n)return this.zs(n.clientId,n)}}else if(this.Fs.test(t.key)){if(t.newValue!==null){const n=this.Hs(t.key,t.newValue);if(n)return this.Js(n)}}else if(this.Ms.test(t.key)){if(t.newValue!==null){const n=this.Ys(t.key,t.newValue);if(n)return this.Zs(n)}}else if(t.key===this.xs){if(t.newValue!==null){const n=this.Ls(t.newValue);if(n)return this.Bs(n)}}else if(t.key===this.vs){const n=function(s){let o=Oe.oe;if(s!=null)try{const c=JSON.parse(s);F(typeof c=="number"),o=c}catch(c){he("SharedClientState","Failed to read sequence number from WebStorage",c)}return o}(t.newValue);n!==Oe.oe&&this.sequenceNumberHandler(n)}else if(t.key===this.Os){const n=this.Xs(t.newValue);await Promise.all(n.map(i=>this.syncEngine.eo(i)))}}}else this.bs.push(t)})}}get Ks(){return this.Ss.get(this.ps)}Ns(){this.setItem(this.Ds,this.Ks.Vs())}qs(e,t,n){const i=new Ss(this.currentUser,e,t,n),s=Ih(this.persistenceKey,this.currentUser,e);this.setItem(s,i.Vs())}Qs(e){const t=Ih(this.persistenceKey,this.currentUser,e);this.removeItem(t)}Us(e){const t={clientId:this.ps,onlineState:e};this.storage.setItem(this.xs,JSON.stringify(t))}
2911$s(e,t,n){const i=jo(this.persistenceKey,e),s=new Wr(e,t,n);this.setItem(i,s.Vs())}Ws(e){const t=JSON.stringify(Array.from(e));this.setItem(this.Os,t)}Gs(e){const t=this.Cs.exec(e);return t?t[1]:null}js(e,t){const n=this.Gs(e);return Ps.Rs(n,t)}Hs(e,t){const n=this.Fs.exec(e),i=Number(n[1]),s=n[2]!==void 0?n[2]:null;return Ss.Rs(new Ce(s),i,t)}Ys(e,t){const n=this.Ms.exec(e),i=Number(n[1]);return Wr.Rs(i,t)}Ls(e){return dc.Rs(e)}Xs(e){return JSON.parse(e)}async Js(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.no(e.batchId,e.state,e.error);C("SharedClientState",`Ignoring mutation for non-active user ${e.user.uid}`)}Zs(e){return this.syncEngine.ro(e.targetId,e.state,e.error)}zs(e,t){const n=t?this.Ss.insert(e,t):this.Ss.remove(e),i=this.ks(this.Ss),s=this.ks(n),o=[],c=[];return s.forEach(u=>{i.has(u)||o.push(u)}),i.forEach(u=>{s.has(u)||c.push(u)}),this.syncEngine.io(o,c).then(()=>{this.Ss=n})}Bs(e){this.Ss.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}ks(e){let t=Xa();return e.forEach((n,i)=>{t=t.unionWith(i.activeTargetIds)}),t}}class gp{constructor(){this.so=new wa,this.oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.so.fs(e),this.oo[e]||"not-current"}updateQueryState(e,t,n){this.oo[e]=t}removeLocalQueryTarget(e){this.so.gs(e)}isLocalQueryTarget(e){return this.so.activeTargetIds.has(e)}clearQueryState(e){delete this.oo[e]}getAllActiveQueryTargets(){return this.so.activeTargetIds}isActiveQueryTarget(e){return this.so.activeTargetIds.has(e)}start(){return this.so=new wa,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
2912 * @license
2913 * Copyright 2019 Google LLC
2914 *
2915 * Licensed under the Apache License, Version 2.0 (the "License");
2916 * you may not use this file except in compliance with the License.
2917 * You may obtain a copy of the License at
2918 *
2919 *   http://www.apache.org/licenses/LICENSE-2.0
2920 *
2921 * Unless required by applicable law or agreed to in writing, software
2922 * distributed under the License is distributed on an "AS IS" BASIS,
2923 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2924 * See the License for the specific language governing permissions and
2925 * limitations under the License.
2926 */class qE{_o(e){}shutdown(){}}/**
2927 * @license
2928 * Copyright 2019 Google LLC
2929 *
2930 * Licensed under the Apache License, Version 2.0 (the "License");
2931 * you may not use this file except in compliance with the License.
2932 * You may obtain a copy of the License at
2933 *
2934 *   http://www.apache.org/licenses/LICENSE-2.0
2935 *
2936 * Unless required by applicable law or agreed to in writing, software
2937 * distributed under the License is distributed on an "AS IS" BASIS,
2938 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2939 * See the License for the specific language governing permissions and
2940 * limitations under the License.
2941 */class Th{constructor(){this.ao=()=>this.uo(),this.co=()=>this.lo(),this.ho=[],this.Po()}_o(e){this.ho.push(e)}shutdown(){window.removeEventListener("online",this.ao),window.removeEventListener("offline",this.co)}Po(){window.addEventListener("online",this.ao),window.addEventListener("offline",this.co)}uo(){C("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.ho)e(0)}lo(){C("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.ho)e(1)}static D(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
2942 * @license
2943 * Copyright 2023 Google LLC
2944 *
2945 * Licensed under the Apache License, Version 2.0 (the "License");
2946 * you may not use this file except in compliance with the License.
2947 * You may obtain a copy of the License at
2948 *
2949 *   http://www.apache.org/licenses/LICENSE-2.0
2950 *
2951 * Unless required by applicable law or agreed to in writing, software
2952 * distributed under the License is distributed on an "AS IS" BASIS,
2953 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2954 * See the License for the specific language governing permissions and
2955 * limitations under the License.
2956 */let Yi=null;function zo(){return Yi===null?Yi=function(){return 268435456+Math.round(2147483648*Math.random())}():Yi++,"0x"+Yi.toString(16)}/**
2957 * @license
2958 * Copyright 2020 Google LLC
2959 *
2960 * Licensed under the Apache License, Version 2.0 (the "License");
2961 * you may not use this file except in compliance with the License.
2962 * You may obtain a copy of the License at
2963 *
2964 *   http://www.apache.org/licenses/LICENSE-2.0
2965 *
2966 * Unless required by applicable law or agreed to in writing, software
2967 * distributed under the License is distributed on an "AS IS" BASIS,
2968 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2969 * See the License for the specific language governing permissions and
2970 * limitations under the License.
2971 */const jE={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};/**
2972 * @license
2973 * Copyright 2017 Google LLC
2974 *
2975 * Licensed under the Apache License, Version 2.0 (the "License");
2976 * you may not use this file except in compliance with the License.
2977 * You may obtain a copy of the License at
2978 *
2979 *   http://www.apache.org/licenses/LICENSE-2.0
2980 *
2981 * Unless required by applicable law or agreed to in writing, software
2982 * distributed under the License is distributed on an "AS IS" BASIS,
2983 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2984 * See the License for the specific language governing permissions and
2985 * limitations under the License.
2986 */class $E{constructor(e){this.Io=e.Io,this.To=e.To}Eo(e){this.Ao=e}Ro(e){this.Vo=e}mo(e){this.fo=e}onMessage(e){this.po=e}close(){this.To()}send(e){this.Io(e)}yo(){this.Ao()}wo(){this.Vo()}So(e){this.fo(e)}bo(e){this.po(e)}}/**
2987 * @license
2988 * Copyright 2017 Google LLC
2989 *
2990 * Licensed under the Apache License, Version 2.0 (the "License");
2991 * you may not use this file except in compliance with the License.
2992 * You may obtain a copy of the License at
2993 *
2994 *   http://www.apache.org/licenses/LICENSE-2.0
2995 *
2996 * Unless required by applicable law or agreed to in writing, software
2997 * distributed under the License is distributed on an "AS IS" BASIS,
2998 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2999 * See the License for the specific language governing permissions and
3000 * limitations under the License.
3001 */const Pe="WebChannelConnection";class zE extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const n=t.ssl?"https":"http",i=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Do=n+"://"+t.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(t,n,i,s,o){const c=zo(),u=this.xo(t,n.toUriEncodedString());C("RestConnection",`Sending RPC '${t}' ${c}:`,u,i);const h={"google-cloud-resource-prefix":this.vo,"x-goog-request-params":this.Co};return this.Oo(h,s,o),this.No(t,u,h,i).then(f=>(C("RestConnection",`Received RPC '${t}' ${c}: `,f),f),f=>{throw Yr("RestConnection",`RPC '${t}' ${c} failed with error: `,f,"url: ",u,"request:",i),f})}Lo(t,n,i,s,o,c){return this.Mo(t,n,i,s,o)}Oo(t,n,i){t["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+or}(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),n&&n.headers.forEach((s,o)=>t[o]=s),i&&i.headers.forEach((s,o)=>t[o]=s)}xo(t,n){const i=jE[t];return`${this.Do}/v1/${n}:${i}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}No(e,t,n,i){const s=zo();return new Promise((o,c)=>{const u=new $d;u.setWithCredentials(!0),u.listenOnce(zd.COMPLETE,()=>{try{switch(u.getLastErrorCode()){case rs.NO_ERROR:const f=u.getResponseJson();C(Pe,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(f)),o(f);break;case rs.TIMEOUT:C(Pe,`RPC '${e}' ${s} timed out`),c(new k(P.DEADLINE_EXCEEDED,"Request time out"));break;case rs.HTTP_ERROR:const m=u.getStatus();if(C(Pe,`RPC '${e}' ${s} failed with status:`,m,"response text:",u.getResponseText()),m>0){let _=u.getResponseJson();Array.isArray(_)&&(_=_[0]);const b=_==null?void 0:_.error;if(b&&b.status&&b.message){const V=function(D){const z=D.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(z)>=0?z:P.UNKNOWN}(b.status);c(new k(V,b.message))}else c(new k(P.UNKNOWN,"Server responded with status "+u.getStatus()))}else c(new k(P.UNAVAILABLE,"Connection failed."));break;default:M()}}finally{C(Pe,`RPC '${e}' ${s} completed.`)}});const h=JSON.stringify(i);C(Pe,`RPC '${e}' ${s} sending request:`,i),u.send(t,"POST",h,n,15)})}Bo(e,t,n){const i=zo(),s=[this.Do,"/","google.firestore.v1.Firestore","/",e,"/channel"],o=Wd(),c=Kd(),u={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`}
3001,sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},h=this.longPollingOptions.timeoutSeconds;h!==void 0&&(u.longPollingTimeout=Math.round(1e3*h)),this.useFetchStreams&&(u.useFetchStreams=!0),this.Oo(u.initMessageHeaders,t,n),u.encodeInitMessageHeaders=!0;const f=s.join("");C(Pe,`Creating RPC '${e}' stream ${i}: ${f}`,u);const m=o.createWebChannel(f,u);let _=!1,b=!1;const V=new $E({Io:D=>{b?C(Pe,`Not sending because RPC '${e}' stream ${i} is closed:`,D):(_||(C(Pe,`Opening RPC '${e}' stream ${i} transport.`),m.open(),_=!0),C(Pe,`RPC '${e}' stream ${i} sending:`,D),m.send(D))},To:()=>m.close()}),N=(D,z,q)=>{D.listen(z,U=>{try{q(U)}catch($){setTimeout(()=>{throw $},0)}})};return N(m,Lr.EventType.OPEN,()=>{b||(C(Pe,`RPC '${e}' stream ${i} transport opened.`),V.yo())}),N(m,Lr.EventType.CLOSE,()=>{b||(b=!0,C(Pe,`RPC '${e}' stream ${i} transport closed`),V.So())}),N(m,Lr.EventType.ERROR,D=>{b||(b=!0,Yr(Pe,`RPC '${e}' stream ${i} transport errored:`,D),V.So(new k(P.UNAVAILABLE,"The operation could not be completed")))}),N(m,Lr.EventType.MESSAGE,D=>{var z;if(!b){const q=D.data[0];F(!!q);const U=q,$=U.error||((z=U[0])===null||z===void 0?void 0:z.error);if($){C(Pe,`RPC '${e}' stream ${i} received error:`,$);const J=$.status;let K=function(I){const E=pe[I];if(E!==void 0)return Mf(E)}(J),T=$.message;K===void 0&&(K=P.INTERNAL,T="Unknown error status: "+J+" with message "+$.message),b=!0,V.So(new k(K,T)),m.close()}else C(Pe,`RPC '${e}' stream ${i} received:`,q),V.bo(q)}}),N(c,Gd.STAT_EVENT,D=>{D.stat===oa.PROXY?C(Pe,`RPC '${e}' stream ${i} detected buffering proxy`):D.stat===oa.NOPROXY&&C(Pe,`RPC '${e}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{V.wo()},0),V}}/**
3002 * @license
3003 * Copyright 2020 Google LLC
3004 *
3005 * Licensed under the Apache License, Version 2.0 (the "License");
3006 * you may not use this file except in compliance with the License.
3007 * You may obtain a copy of the License at
3008 *
3009 *   http://www.apache.org/licenses/LICENSE-2.0
3010 *
3011 * Unless required by applicable law or agreed to in writing, software
3012 * distributed under the License is distributed on an "AS IS" BASIS,
3013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3014 * See the License for the specific language governing permissions and
3015 * limitations under the License.
3016 *//**
3017 * @license
3018 * Copyright 2020 Google LLC
3019 *
3020 * Licensed under the Apache License, Version 2.0 (the "License");
3021 * you may not use this file except in compliance with the License.
3022 * You may obtain a copy of the License at
3023 *
3024 *   http://www.apache.org/licenses/LICENSE-2.0
3025 *
3026 * Unless required by applicable law or agreed to in writing, software
3027 * distributed under the License is distributed on an "AS IS" BASIS,
3028 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3029 * See the License for the specific language governing permissions and
3030 * limitations under the License.
3031 */function _p(){return typeof window<"u"?window:null}function ls(){return typeof document<"u"?document:null}/**
3032 * @license
3033 * Copyright 2020 Google LLC
3034 *
3035 * Licensed under the Apache License, Version 2.0 (the "License");
3036 * you may not use this file except in compliance with the License.
3037 * You may obtain a copy of the License at
3038 *
3039 *   http://www.apache.org/licenses/LICENSE-2.0
3040 *
3041 * Unless required by applicable law or agreed to in writing, software
3042 * distributed under the License is distributed on an "AS IS" BASIS,
3043 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3044 * See the License for the specific language governing permissions and
3045 * limitations under the License.
3046 */function Js(r){return new JT(r,!0)}/**
3047 * @license
3048 * Copyright 2017 Google LLC
3049 *
3050 * Licensed under the Apache License, Version 2.0 (the "License");
3051 * you may not use this file except in compliance with the License.
3052 * You may obtain a copy of the License at
3053 *
3054 *   http://www.apache.org/licenses/LICENSE-2.0
3055 *
3056 * Unless required by applicable law or agreed to in writing, softw
3056are
3057 * distributed under the License is distributed on an "AS IS" BASIS,
3058 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3059 * See the License for the specific language governing permissions and
3060 * limitations under the License.
3061 */class fc{constructor(e,t,n=1e3,i=1.5,s=6e4){this.ui=e,this.timerId=t,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(e){this.cancel();const t=Math.floor(this.Ko+this.zo()),n=Math.max(0,Date.now()-this.Uo),i=Math.max(0,t-n);i>0&&C("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.Ko} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.$o=this.ui.enqueueAfterDelay(this.timerId,i,()=>(this.Uo=Date.now(),e())),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}}/**
3062 * @license
3063 * Copyright 2017 Google LLC
3064 *
3065 * Licensed under the Apache License, Version 2.0 (the "License");
3066 * you may not use this file except in compliance with the License.
3067 * You may obtain a copy of the License at
3068 *
3069 *   http://www.apache.org/licenses/LICENSE-2.0
3070 *
3071 * Unless required by applicable law or agreed to in writing, software
3072 * distributed under the License is distributed on an "AS IS" BASIS,
3073 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3074 * See the License for the specific language governing permissions and
3075 * limitations under the License.
3076 */class yp{constructor(e,t,n,i,s,o,c,u){this.ui=e,this.Ho=n,this.Jo=i,this.connection=s,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=c,this.listener=u,this.state=0,this.Yo=0,this.Zo=null,this.Xo=null,this.stream=null,this.e_=0,this.t_=new fc(e,t)}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_(e){this.u_(),this.stream.send(e)}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(e,t){this.u_(),this.c_(),this.t_.cancel(),this.Yo++,e!==4?this.t_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(he(t.toString()),he("Using maximum backoff delay to prevent overloading the backend."),this.t_.Wo()):t&&t.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=e,await this.listener.mo(t)}l_(){}auth(){this.state=1;const e=this.h_(this.Yo),t=this.Yo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,i])=>{this.Yo===t&&this.P_(n,i)},n=>{e(()=>{const i=new k(P.UNKNOWN,"Fetching auth token failed: "+n.message);return this.I_(i)})})}P_(e,t){const n=this.h_(this.Yo);this.stream=this.T_(e,t),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_(e){return C("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}h_(e){return t=>{this.ui.enqueueAndForget(()=>this.Yo===e?t():(C("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class GE extends yp{constructor(e,t,n,i,s,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,i,o),this.serializer=s}T_(e,t){return this.connection.Bo("Listen",e,t)}E_(e){return this.onNext(e)}onNext(e){this.t_.reset();const t=eE(this.serializer,e),n=function(s){if(!("targetChange"in s))return B.min();const o=s.targetChange;return o.targetIds&&o.targetIds.length?B.min():o.readTime?ye(o.readTime):B.min()}(e);return this.listener.d_(t,n)}A_(e){const t={};t.database=_a(this.serializer),t.addTarget=function(s,o){let c;const u=o.target;if(c=Ts(u)?{documents:zf(s,u)}:{query:Gf(s,u)._t},c.targetId=o.targetId,o.resumeToken.approximateByteSize()>0){c.resumeToken=Uf(s,o.resumeToken);const h=ma(s,o.expectedCount);h!==null&&(c.expectedCount=h)}else if(o.snapshotVersion.compareTo(B.min())>0){c.readTime=er(s,o.snapshotVersion.toTimestamp());const h=ma(s,o.expectedCount);h!==null&&(c.expectedCount=h)}return c}(this.serializer,e);const n=nE(this.serializer,e);n&&(t.labels=n),this.a_(t)}R_(e){const t={};t.database=_a(this.serializer),t.removeTarget=e,this.a_(t)}}class KE extends yp{constructor(e,t,n,i,s,o){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,i,o),this.serializer
3076=s}get V_(){return this.e_>0}start(){this.lastStreamToken=void 0,super.start()}l_(){this.V_&&this.m_([])}T_(e,t){return this.connection.Bo("Write",e,t)}E_(e){return F(!!e.streamToken),this.lastStreamToken=e.streamToken,F(!e.writeResults||e.writeResults.length===0),this.listener.f_()}onNext(e){F(!!e.streamToken),this.lastStreamToken=e.streamToken,this.t_.reset();const t=tE(e.writeResults,e.commitTime),n=ye(e.commitTime);return this.listener.g_(n,t)}p_(){const e={};e.database=_a(this.serializer),this.a_(e)}m_(e){const t={streamToken:this.lastStreamToken,writes:e.map(n=>ai(this.serializer,n))};this.a_(t)}}/**
3077 * @license
3078 * Copyright 2017 Google LLC
3079 *
3080 * Licensed under the Apache License, Version 2.0 (the "License");
3081 * you may not use this file except in compliance with the License.
3082 * You may obtain a copy of the License at
3083 *
3084 *   http://www.apache.org/licenses/LICENSE-2.0
3085 *
3086 * Unless required by applicable law or agreed to in writing, software
3087 * distributed under the License is distributed on an "AS IS" BASIS,
3088 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3089 * See the License for the specific language governing permissions and
3090 * limitations under the License.
3091 */class WE extends class{}{constructor(e,t,n,i){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=i,this.y_=!1}w_(){if(this.y_)throw new k(P.FAILED_PRECONDITION,"The client has already been terminated.")}Mo(e,t,n,i){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,o])=>this.connection.Mo(e,ga(t,n),i,s,o)).catch(s=>{throw s.name==="FirebaseError"?(s.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),s):new k(P.UNKNOWN,s.toString())})}Lo(e,t,n,i,s){return this.w_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,c])=>this.connection.Lo(e,ga(t,n),i,o,c,s)).catch(o=>{throw o.name==="FirebaseError"?(o.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new k(P.UNKNOWN,o.toString())})}terminate(){this.y_=!0,this.connection.terminate()}}class HE{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,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_(e){this.state==="Online"?this.C_("Unknown"):(this.S_++,this.S_>=1&&(this.x_(),this.F_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.C_("Offline")))}set(e){this.x_(),this.S_=0,e==="Online"&&(this.D_=!1),this.C_(e)}C_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}F_(e){const t=`Could not reach Cloud Firestore backend. ${e}
3092This 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_?(he(t),this.D_=!1):C("OnlineStateTracker",t)}x_(){this.b_!==null&&(this.b_.cancel(),this.b_=null)}}/**
3093 * @license
3094 * Copyright 2017 Google LLC
3095 *
3096 * Licensed under the Apache License, Version 2.0 (the "License");
3097 * you may not use this file except in compliance with the License.
3098 * You may obtain a copy of the License at
3099 *
3100 *   http://www.apache.org/licenses/LICENSE-2.0
3101 *
3102 * Unless required by applicable law or agreed to in writing, software
3103 * distributed under the License is distributed on an "AS IS" BASIS,
3104 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3105 * See the License for the specific language governing permissions and
3106 * limitations under the License.
3107 */class QE{constructor(e,t,n,i,s){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.O_=[],this.N_=new Map,this.L_=new Set,this.B_=[],this.k_=s,this.k_._o(o=>{n.enqueueAndForget(async()=>{Rn(this)&&(C("RemoteStore","Restarting streams for network reach
3107ability change."),await async function(u){const h=L(u);h.L_.add(4),await Ei(h),h.q_.set("Unknown"),h.L_.delete(4),await Ys(h)}(this))})}),this.q_=new HE(n,i)}}async function Ys(r){if(Rn(r))for(const e of r.B_)await e(!0)}async function Ei(r){for(const e of r.B_)await e(!1)}function Xs(r,e){const t=L(r);t.N_.has(e.targetId)||(t.N_.set(e.targetId,e),gc(t)?mc(t):lr(t).r_()&&pc(t,e))}function nr(r,e){const t=L(r),n=lr(t);t.N_.delete(e),n.r_()&&Ip(t,e),t.N_.size===0&&(n.r_()?n.o_():Rn(t)&&t.q_.set("Unknown"))}function pc(r,e){if(r.Q_.xe(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(B.min())>0){const t=r.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}lr(r).A_(e)}function Ip(r,e){r.Q_.xe(e),lr(r).R_(e)}function mc(r){r.Q_=new KT({getRemoteKeysForTarget:e=>r.remoteSyncer.getRemoteKeysForTarget(e),ot:e=>r.N_.get(e)||null,tt:()=>r.datastore.serializer.databaseId}),lr(r).start(),r.q_.v_()}function gc(r){return Rn(r)&&!lr(r).n_()&&r.N_.size>0}function Rn(r){return L(r).L_.size===0}function Tp(r){r.Q_=void 0}async function JE(r){r.q_.set("Online")}async function YE(r){r.N_.forEach((e,t)=>{pc(r,e)})}async function XE(r,e){Tp(r),gc(r)?(r.q_.M_(e),mc(r)):r.q_.set("Unknown")}async function ZE(r,e,t){if(r.q_.set("Online"),e instanceof Ff&&e.state===2&&e.cause)try{await async function(i,s){const o=s.cause;for(const c of s.targetIds)i.N_.has(c)&&(await i.remoteSyncer.rejectListen(c,o),i.N_.delete(c),i.Q_.removeTarget(c))}(r,e)}catch(n){C("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await Cs(r,n)}else if(e instanceof us?r.Q_.Ke(e):e instanceof Lf?r.Q_.He(e):r.Q_.We(e),!t.isEqual(B.min()))try{const n=await dp(r.localStore);t.compareTo(n)>=0&&await function(s,o){const c=s.Q_.rt(o);
3107return c.targetChanges.forEach((u,h)=>{if(u.resumeToken.approximateByteSize()>0){const f=s.N_.get(h);f&&s.N_.set(h,f.withResumeToken(u.resumeToken,o))}}),c.targetMismatches.forEach((u,h)=>{const f=s.N_.get(u);if(!f)return;s.N_.set(u,f.withResumeToken(fe.EMPTY_BYTE_STRING,f.snapshotVersion)),Ip(s,u);const m=new dt(f.target,u,h,f.sequenceNumber);pc(s,m)}),s.remoteSyncer.applyRemoteEvent(c)}(r,t)}catch(n){C("RemoteStore","Failed to raise snapshot:",n),await Cs(r,n)}}async function Cs(r,e,t){if(!jt(e))throw e;r.L_.add(1),await Ei(r),r.q_.set("Offline"),t||(t=()=>dp(r.localStore)),r.asyncQueue.enqueueRetryable(async()=>{C("RemoteStore","Retrying IndexedDB access"),await t(),r.L_.delete(1),await Ys(r)})}function Ep(r,e){return e().catch(t=>Cs(r,t,e))}async function ur(r){const e=L(r),t=Ft(e);let n=e.O_.length>0?e.O_[e.O_.length-1].batchId:-1;for(;ev(e);)try{const i=await BE(e.localStore,n);if(i===null){e.O_.length===0&&t.o_();break}n=i.batchId,tv(e,i)}catch(i){await Cs(e,i)}vp(e)&&wp(e)}function ev(r){return Rn(r)&&r.O_.length<10}function tv(r,e){r.O_.push(e);const t=Ft(r);t.r_()&&t.V_&&t.m_(e.mutations)}function vp(r){return Rn(r)&&!Ft(r).n_()&&r.O_.length>0}function wp(r){Ft(r).start()}async function nv(r){Ft(r).p_()}async function rv(r){const e=Ft(r);for(const t of r.O_)e.m_(t.mutations)}async function iv(r,e,t){const n=r.O_.shift(),i=rc.from(n,e,t);await Ep(r,()=>r.remoteSyncer.applySuccessfulWrite(i)),await ur(r)}async function sv(r,e){e&&Ft(r).V_&&await async function(n,i){if(function(o){return Of(o)&&o!==P.ABORTED}(i.code)){const s=n.O_.shift();Ft(n).s_(),await Ep(n,()=>n.remoteSyncer.rejectFailedWrite(s.batchId,i)),await ur(n)}}(r,e),vp(r)&&wp(r)}async function Eh(r,e){const t=L(r);t.asyncQueue.verifyOperationInProgress(),C("RemoteStore","RemoteStore received new credentials");const n=Rn(t);t.L_.add(3),await Ei(t),n&&t.q_.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.L_.delete(3),await Ys(t)}async function Aa(r,e){const t=L(r);e?(t.L_.delete(2),await Ys(t)):e||(t.L_.add(2),await Ei(t),t.q_.set("Unknown"))}function lr(r){return r.K_||(r.K_=function(t,n,i){const s=L(t);return s.w_(),new GE(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:JE.bind(null,r),Ro:YE.bind(null,r),mo:XE.bind(null,r),d_:ZE.bind(null,r)}),r.B_.push(async e=>{e?(r.K_.s_(),gc(r)?mc(r):r.q_.set("Unknown")):(await r.K_.stop(),Tp(r))})),r.K_}function Ft(r){return r.U_||(r.U_=function(t,n,i){const s=L(t);return s.w_(),new KE(n,s.connection,s.authCredentials,s.appCheckCredentials,s.serializer,i)}(r.datastore,r.asyncQueue,{Eo:()=>Promise.resolve(),Ro:nv.bind(null,r),mo:sv.bind(null,r),f_:rv.bind(null,r),g_:iv.bind(null,r)}),r.B_.push(async e=>{e?(r.U_.s_(),await ur(r)):(await r.U_.stop(),r.O_.length>0&&(C("RemoteStore",`Stopping write stream with ${r.O_.length} pending writes`),r.O_=[]))})),r.U_}/**
3108 * @license
3109 * Copyright 2017 Google LLC
3110 *
3111 * Licensed under the Apache License, Version 2.0 (the "License");
3112 * you may not use this file except in compliance with the License.
3113 * You may obtain a copy of the License at
3114 *
3115 *   http://www.apache.org/licenses/LICENSE-2.0
3116 *
3117 * Unless required by applicable law or agreed to in writing, software
3118 * distributed under the License is distributed on an "AS IS" BASIS,
3119 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3120 * See the License for the specific language governing permissions and
3121 * limitations under the License.
3122 */class _c{constructor(e,t,n,i,s){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=i,this.removalCallback=s,this.deferred=new Ye,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(o=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,i,s){const o=Date.now()+n,c=new _c(e,t,o,i,s);return c.start(n),c}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new k(P.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function yc(r,e){if(he("AsyncQueue",`${e}: ${r}`),jt(r))return new k(P.UNAVAILABLE,`${e}: ${r}`);throw r}/**
3123 * @license
3124 * Copyright 2017 Google LLC
3125 *
3126 * Licensed under the Apache License, Version 2.0 (the "License");
3127 * you may not use this file except in compliance with the License.
3128 * You may obtain a copy of the License at
3129 *
3130 *   http://www.apache.org/licenses/LICENSE-2.0
3131 *
3132 * Unless required by applicable law or agreed to in writing, software
3133 * distributed under the License is distributed on an "AS IS" BASIS,
3134 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3135 * See the License for the specific language governing permissions and
3136 * limitations under the License.
3137 */class $n{constructor(e){this.comparator=e?(t,n)=>e(t,n)||O.comparator(t.key,n.key):(t,n)=>O.comparator(t.key,n.key),this.keyedMap=Fr(),this.sortedSet=new ie(this.comparator)}static emptySet(e){return new $n(e.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,n)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof $n)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const i=t.getNext().key,s=n.getNext().key;if(!i.isEqual(s))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
3138  `+e.join(`  
3139`)+`
3140)`}copy(e,t){const n=new $n;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}/**
3141 * @license
3142 * Copyright 2017 Google LLC
3143 *
3144 * Licensed under the Apache License, Version 2.0 (the "License");
3145 * you may not use this file except in compliance with the License.
3146 * You may obtain a copy of the License at
3147 *
3148 *   http://www.apache.org/licenses/LICENSE-2.0
3149 *
3150 * Unless required by applicable law or agreed to in writing, software
3151 * distributed under the License is distributed on an "AS IS" BASIS,
3152 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3153 * See the License for the specific language governing permissions and
3154 * limitations under the License.
3155 */class vh{constructor(){this.W_=new ie(O.comparator)}track(e){const t=e.doc.key,n=this.W_.get(t);n?e.type!==0&&n.type===3?this.W_=this.W_.insert(t,e):e.type===3&&n.type!==1?this.W_=this.W_.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.W_=this.W_.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.W_=this.W_.remove(t):e.type===1&&n.type===2?this.W_=this.W_.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.W_=this.W_.insert(t,{type:2,doc:e.doc}):M():this.W_=this.W_.insert(t,e)}G_(){const e=[];return this.W_.inorderTraversal((t,n)=>{e.push(n)}),e}}class rr{constructor(e,t,n,i,s,o,c,u,h){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=i,this.mutatedKeys=s,this.fromCache=o,this.syncStateChanged=c,this.excludesMetadataChanges=u,this.hasCachedResults=h}static fromInitialDocuments(e,t,n,i,s){const o=[];return t.forEach(c=>{o.push({type:0,doc:c})}),new rr(e,t,$n.emptySet(t),o,n,i,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&zs(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let i=0;i<t.length;i++)if(t[i].type!==n[i].type||!t[i].doc.isEqual(n[i].doc))return!1;return!0}}/**
3156 * @license
3157 * Copyright 2017 Google LLC
3158 *
3159 * Licensed under the Apache License, Version 2.0 (the "License");
3160 * you may not use this file except in compliance with the License.
3161 * You may obtain a copy of the License at
3162 *
3163 *   http://www.apache.org/licenses/LICENSE-2.0
3164 *
3165 * Unless required by applicable law or agreed to in writing, softw
3165are
3166 * distributed under the License is distributed on an "AS IS" BASIS,
3167 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3168 * See the License for the specific language governing permissions and
3169 * limitations under the License.
3170 */class ov{constructor(){this.z_=void 0,this.j_=[]}H_(){return this.j_.some(e=>e.J_())}}class av{constructor(){this.queries=wh(),this.onlineState="Unknown",this.Y_=new Set}terminate(){(function(t,n){const i=L(t),s=i.queries;i.queries=wh(),s.forEach((o,c)=>{for(const u of c.j_)u.onError(n)})})(this,new k(P.ABORTED,"Firestore shutting down"))}}function wh(){return new $t(r=>Ef(r),zs)}async function Ap(r,e){const t=L(r);let n=3;const i=e.query;let s=t.queries.get(i);s?!s.H_()&&e.J_()&&(n=2):(s=new ov,n=e.J_()?0:1);try{switch(n){case 0:s.z_=await t.onListen(i,!0);break;case 1:s.z_=await t.onListen(i,!1);break;case 2:await t.onFirstRemoteStoreListen(i)}}catch(o){const c=yc(o,`Initialization of query '${On(e.query)}' failed`);return void e.onError(c)}t.queries.set(i,s),s.j_.push(e),e.Z_(t.onlineState),s.z_&&e.X_(s.z_)&&Ic(t)}async function Rp(r,e){const t=L(r),n=e.query;let i=3;const s=t.queries.get(n);if(s){const o=s.j_.indexOf(e);o>=0&&(s.j_.splice(o,1),s.j_.length===0?i=e.J_()?0:1:!s.H_()&&e.J_()&&(i=2))}switch(i){case 0:return t.queries.delete(n),t.onUnlisten(n,!0);case 1:return t.queries.delete(n),t.onUnlisten(n,!1);case 2:return t.onLastRemoteStoreUnlisten(n);default:return}}function cv(r,e){const t=L(r);let n=!1;for(const i of e){const s=i.query,o=t.queries.get(s);if(o){for(const c of o.j_)c.X_(i)&&(n=!0);o.z_=i}}n&&Ic(t)}function uv(r,e,t){const n=L(r),i=n.queries.get(e);if(i)for(const s of i.j_)s.onError(t);n.queries.delete(e)}function Ic(r){r.Y_.forEach(e=>{e.next()})}var Ra,Ah;(Ah=Ra||(Ra={})).ea="default",Ah.Cache="cache";class bp{constructor(e,t,n){this.query=e,this.ta=t,this.na=!1,this.ra=null,this.onlineState="Unknown",this.options=n||{}}X_(e){if(!this.options.includeMetadataChanges){const n=[];for(const i of e.docChanges)i.type!==3&&n.push(i);e=new rr(e.query,e.docs,e.oldDocs,n,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.na?this.ia(e)&&(this.ta.next(e),t=!0):this.sa(e,this.onlineState)&&(this.oa(e),t=!0),this.ra=e,t}onError(e){this.ta.error(e)}Z_(e){this.onlineState=e;let t=!1;return this.ra&&!this.na&&this.sa(this.ra,e)&&(this.oa(this.ra),t=!0),t}sa(e,t){if(!e.fromCache||!this.J_())return!0;const n=t!=="Offline";return(!this.options._a||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}ia(e){if(e.docChanges.length>0)return!0;const t=this.ra&&this.ra.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}oa(e){e=rr.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.na=!0,this.ta.next(e)}J_(){return this.options.source!==Ra.Cache}}/**
3171 * @license
3172 * Copyright 2017 Google LLC
3173 *
3174 * Licensed under the Apache License, Version 2.0 (the "License");
3175 * you may not use this file except in compliance with the License.
3176 * You may obtain a copy of the License at
3177 *
3178 *   http://www.apache.org/licenses/LICENSE-2.0
3179 *
3180 * Unless required by applicable law or agreed to in writing, software
3181 * distributed under the License is distributed on an "AS IS" BASIS,
3182 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3183 * See the License for the specific language governing permissions and
3184 * limitations under the License.
3185 */class Sp{constructor(e){this.key=e}}class Pp{constructor(e){this.key=e}}class lv{constructor(e,t){this.query=e,this.Ta=t,this.Ea=null,this.hasCachedResults=!1,this.current=!1,this.da=W(),this.mutatedKeys=W(),this.Aa=wf(e),this.Ra=new $n(this.Aa)}get Va(){return this.Ta}ma(e,t){const n=t?t.fa:new vh,i=t?t.Ra:this.Ra;let s=t?t.mutatedKeys:this.mutatedKeys,o=i,c=!1;const u=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(e.inorderTraversal((f,m)=>{const _=i.get(f),b=_i(this.query,m)?m:null,V=!!_&&this.mutatedKeys.has(_.key),N=!!b&&(b.hasLocalMutations||this.mutatedKeys.has(b.key)&&b.hasCommittedMutations);let D=!1;_&&b?_.data.isEqual(b.data)?V!==N&&(n.track({type:3,doc:b}),D=!0):this.ga(_,b)||(n.track({type:2,doc:b}),D=!0,(u&&this.Aa(b,u)>0||h&&this.Aa(b,h)<0)&&(c=!0)):!_&&b?(n.track({type:0,doc:b}),D=!0):_&&!b&&(n.track({type:1,doc:_}),D=!0,(u||h)&&(c=!0)),D&&(b?(o=o.add(b),s=N?s.add(f):s.delete(f)):(o=o.delete(f),s=s.delete(f)))}),this.query.limit!==null)for(;o.size>this.query.limit;){const f=this.query.limitType==="F"?o.last():o.first();o=o.delete(f.key),s=s.delete(f.key),n.track({type:1,doc:f})}return{Ra:o,fa:n,ns:c,mutatedKeys:s}}ga(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}
3185applyChanges(e,t,n,i){const s=this.Ra;this.Ra=e.Ra,this.mutatedKeys=e.mutatedKeys;const o=e.fa.G_();o.sort((f,m)=>function(b,V){const N=D=>{switch(D){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return M()}};return N(b)-N(V)}(f.type,m.type)||this.Aa(f.doc,m.doc)),this.pa(n),i=i!=null&&i;const c=t&&!i?this.ya():[],u=this.da.size===0&&this.current&&!i?1:0,h=u!==this.Ea;return this.Ea=u,o.length!==0||h?{snapshot:new rr(this.query,e.Ra,s,o,e.mutatedKeys,u===0,h,!1,!!n&&n.resumeToken.approximateByteSize()>0),wa:c}:{wa:c}}Z_(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Ra:this.Ra,fa:new vh,mutatedKeys:this.mutatedKeys,ns:!1},!1)):{wa:[]}}Sa(e){return!this.Ta.has(e)&&!!this.Ra.has(e)&&!this.Ra.get(e).hasLocalMutations}pa(e){e&&(e.addedDocuments.forEach(t=>this.Ta=this.Ta.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.Ta=this.Ta.delete(t)),this.current=e.current)}ya(){if(!this.current)return[];const e=this.da;this.da=W(),this.Ra.forEach(n=>{this.Sa(n.key)&&(this.da=this.da.add(n.key))});const t=[];return e.forEach(n=>{this.da.has(n)||t.push(new Pp(n))}),this.da.forEach(n=>{e.has(n)||t.push(new Sp(n))}),t}ba(e){this.Ta=e.Ts,this.da=W();const t=this.ma(e.documents);return this.applyChanges(t,!0)}Da(){return rr.fromInitialDocuments(this.query,this.Ra,this.mutatedKeys,this.Ea===0,this.hasCachedResults)}}class hv{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class dv{constructor(e){this.key=e,this.va=!1}}class fv{constructor(e,t,n,i,s,o){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=i,this.currentUser=s,this.maxConcurrentLimboResolutions=o,this.Ca={},this.Fa=new $t(c=>Ef(c),zs),this.Ma=new Map,this.xa=new Set,this.Oa=new ie(O.comparator),this.Na=new Map,this.La=new uc,this.Ba={},this.ka=new Map,this.qa=_n.kn(),this.onlineState="Unknown",this.Qa=void 0}get isPrimaryClient(){return this.Qa===!0}}async function pv(r,e,t=!0){const n=Zs(r);let i;const s=n.Fa.get(e);return s?(n.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.Da()):i=await Cp(n,e,t,!0),i}async function mv(r,e){const t=Zs(r);await Cp(t,e,!0,!1)}async function Cp(r,e,t,n){const i=await bs(r.localStore,qe(e)),s=i.targetId,o=r.sharedClientState.addLocalQueryTarget(s,t);let c;return n&&(c=await Tc(r,e,s,o==="current",i.resumeToken)),r.isPrimaryClient&&t&&Xs(r.remoteStore,i),c}async function Tc(r,e,t,n,i){r.Ka=(m,_,b)=>async function(N,D,z,q){let U=D.view.ma(z);U.ns&&(U=await va(N.localStore,D.query,!1).then(({documents:T})=>D.view.ma(T,U)));const $=q&&q.targetChanges.get(D.targetId),J=q&&q.targetMismatches.get(D.targetId)!=null,K=D.view.applyChanges(U,N.isPrimaryClient,$,J);return ba(N,D.targetId,K.wa),K.snapshot}(r,m,_,b);const s=await va(r.localStore,e,!0),o=new lv(e,s.Ts),c=o.ma(s.documents),u=Ti.createSynthesizedTargetChangeForCurrentChange(t,n&&r.onlineState!=="Offline",i),h=o.applyChanges(c,r.isPrimaryClient,u);ba(r,t,h.wa);const f=new hv(e,t,o);return r.Fa.set(e,f),r.Ma.has(t)?r.Ma.get(t).push(e):r.Ma.set(t,[e]),h.snapshot}async function gv(r,e,t){const n=L(r),i=n.Fa.get(e),s=n.Ma.get(i.targetId);if(s.length>1)return n.Ma.set(i.targetId,s.filter(o=>!zs(o,e))),void n.Fa.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)||await tr(n.localStore,i.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(i.targetId),t&&nr(n.remoteStore,i.targetId),ir(n,i.targetId)}).catch(qt)):(ir(n,i.targetId),await tr(n.localStore,i.targetId,!0))}async function _v(r,e){const t=L(r),n=t.Fa.get(e),i=t.Ma.get(n.targetId);t.isPrimaryClient&&i.length===1&&(t.sharedClientState.removeLocalQueryTarget(n.targetId),nr(t.remoteStore,n.targetId))}async function yv(r,e,t){const n=Ac(r);try{const i=await function(o,c){const u=L(o),h=ue.now(),f=c.reduce((b,V)=>b.add(V.key),W());let m,_;return u.persistence.runTransaction("Locally write mutations","readwrite",b=>{let V=Be(),N=W();return u.cs.getEntries(b,f).next(D=>{V=D,V.forEach((z,q)=>{q.isValidDocument()||(N=N.add(z))})}).next(()=>u.localDocuments.getOverlayedDocuments(b,V)).next(D=>{m=D;const z=[];for(const q of c){const U=jT(q,m.get(q.key).overlayedDocument);
3185U!=null&&z.push(new yt(q.key,U,hf(U.value.mapValue),de.exists(!0)))}return u.mutationQueue.addMutationBatch(b,h,z,c)}).next(D=>{_=D;const z=D.applyToLocalDocumentSet(m,N);return u.documentOverlayCache.saveOverlays(b,D.batchId,z)})}).then(()=>({batchId:_.batchId,changes:Rf(m)}))}(n.localStore,e);n.sharedClientState.addPendingMutation(i.batchId),function(o,c,u){let h=o.Ba[o.currentUser.toKey()];h||(h=new ie(G)),h=h.insert(c,u),o.Ba[o.currentUser.toKey()]=h}(n,i.batchId,t),await zt(n,i.changes),await ur(n.remoteStore)}catch(i){const s=yc(i,"Failed to persist write");t.reject(s)}}async function Dp(r,e){const t=L(r);try{const n=await FE(t.localStore,e);e.targetChanges.forEach((i,s)=>{const o=t.Na.get(s);o&&(F(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1),i.addedDocuments.size>0?o.va=!0:i.modifiedDocuments.size>0?F(o.va):i.removedDocuments.size>0&&(F(o.va),o.va=!1))}),await zt(t,n,e)}catch(n){await qt(n)}}function Rh(r,e,t){const n=L(r);if(n.isPrimaryClient&&t===0||!n.isPrimaryClient&&t===1){const i=[];
3185n.Fa.forEach((s,o)=>{const c=o.view.Z_(e);c.snapshot&&i.push(c.snapshot)}),function(o,c){const u=L(o);u.onlineState=c;let h=!1;u.queries.forEach((f,m)=>{for(const _ of m.j_)_.Z_(c)&&(h=!0)}),h&&Ic(u)}(n.eventManager,e),i.length&&n.Ca.d_(i),n.onlineState=e,n.isPrimaryClient&&n.sharedClientState.setOnlineState(e)}}async function Iv(r,e,t){const n=L(r);n.sharedClientState.updateQueryState(e,"rejected",t);const i=n.Na.get(e),s=i&&i.key;if(s){let o=new ie(O.comparator);o=o.insert(s,ae.newNoDocument(s,B.min()));const c=W().add(s),u=new Ii(B.min(),new Map,new ie(G),o,c);await Dp(n,u),n.Oa=n.Oa.remove(s),n.Na.delete(e),wc(n)}else await tr(n.localStore,e,!1).then(()=>ir(n,e,t)).catch(qt)}async function Tv(r,e){const t=L(r),n=e.batch.batchId;try{const i=await LE(t.localStore,e);vc(t,n,null),Ec(t,n),t.sharedClientState.updateMutationState(n,"acknowledged"),await zt(t,i)}catch(i){await qt(i)}}async function Ev(r,e,t){const n=L(r);try{const i=await function(o,c){const u=L(o);return u.persistence.runTransaction("Reject batch","readwrite-primary",h=>{let f;return u.mutationQueue.lookupMutationBatch(h,c).next(m=>(F(m!==null),f=m.keys(),u.mutationQueue.removeMutationBatch(h,m))).next(()=>u.mutationQueue.performConsistencyCheck(h)).next(()=>u.documentOverlayCache.removeOverlaysForBatchId(h,f,c)).next(()=>u.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f)).next(()=>u.localDocuments.getDocuments(h,f))})}(n.localStore,e);vc(n,e,t),Ec(n,e),n.sharedClientState.updateMutationState(e,"rejected",t),await zt(n,i)}catch(i){await qt(i)}}function Ec(r,e){(r.ka.get(e)||[]).forEach(t=>{t.resolve()}),r.ka.delete(e)}function vc(r,e,t){const n=L(r);let i=n.Ba[n.currentUser.toKey()];if(i){const s=i.get(e);s&&(t?s.reject(t):s.resolve(),i=i.remove(e)),n.Ba[n.currentUser.toKey()]=i}}function ir(r,e,t=null){r.sharedClientState.removeLocalQueryTarget(e);for(const n of r.Ma.get(e))r.Fa.delete(n),t&&r.Ca.$a(n,t);r.Ma.delete(e),r.isPrimaryClient&&r.La.gr(e).forEach(n=>{r.La.containsKey(n)||Vp(r,n)})}function Vp(r,e){r.xa.delete(e.path.canonicalString());const t=r.Oa.get(e);t!==null&&(nr(r.remoteStore,t),r.Oa=r.Oa.remove(e),r.Na.delete(t),wc(r))}function ba(r,e,t){for(const n of t)n instanceof Sp?(r.La.addReference(n.key,e),vv(r,n)):n instanceof Pp?(C("SyncEngine","Document no longer in limbo: "+n.key),r.La.removeReference(n.key,e),r.La.containsKey(n.key)||Vp(r,n.key)):M()}function vv(r,e){const t=e.key,n=t.path.canonicalString();r.Oa.get(t)||r.xa.has(n)||(C("SyncEngine","New document in limbo: "+t),r.xa.add(n),wc(r))}function wc(r){for(;r.xa.size>0&&r.Oa.size<r.maxConcurrentLimboResolutions;){const e=r.xa.values().next().value;r.xa.delete(e);const t=new O(Z.fromString(e)),n=r.qa.next();r.Na.set(n,new dv(t)),r.Oa=r.Oa.insert(t,n),Xs(r.remoteStore,new dt(qe($s(t.path)),n,"TargetPurposeLimboResolution",Oe.oe))}}async function zt(r,e,t){const n=L(r),i=[],s=[],o=[];n.Fa.isEmpty()||(n.Fa.forEach((c,u)=>{o.push(n.Ka(u,e,t).then(h=>{var f;if((h||t)&&n.isPrimaryClient){const m=h?!h.fromCache:(f=t==null?void 0:t.targetChanges.get(u.targetId))===null||f===void 0?void 0:f.current;n.sharedClientState.updateQueryState(u.targetId,m?"current":"not-current")}if(h){i.push(h);const m=hc.Wi(u.targetId,h);s.push(m)}}))}),await Promise.all(o),n.Ca.d_(i),await async function(u,h){const f=L(u);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",m=>A.forEach(h,_=>A.forEach(_.$i,b=>f.persistence.referenceDelegate.addReference(m,_.targetId,b)).next(()=>A.forEach(_.Ui,b=>f.persistence.referenceDelegate.removeReference(m,_.targetId,b)))))}catch(m){if(!jt(m))throw m;C("LocalStore","Failed to update sequence numbers: "+m)}for(const m of h){const _=m.targetId;if(!m.fromCache){const b=f.os.get(_),V=b.snapshotVersion,N=b.withLastLimboFreeSnapshotVersion(V);f.os=f.os.insert(_,N)}}}(n.localStore,s))}async function wv(r,e){const t=L(r);if(!t.currentUser.isEqual(e)){C("SyncEngine","User change. New user:",e.toKey());const n=await hp(t.localStore,e);t.currentUser=e,function(s,o){s.ka.forEach(c=>{c.forEach(u=>{u.reject(new k(P.CANCELLED,o))})}),s.ka.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedCl
3185ientState.handleUserChange(e,n.removedBatchIds,n.addedBatchIds),await zt(t,n.hs)}}function Av(r,e){const t=L(r),n=t.Na.get(e);if(n&&n.va)return W().add(n.key);{let i=W();const s=t.Ma.get(e);if(!s)return i;for(const o of s){const c=t.Fa.get(o);i=i.unionWith(c.view.Va)}return i}}async function Rv(r,e){const t=L(r),n=await va(t.localStore,e.query,!0),i=e.view.ba(n);return t.isPrimaryClient&&ba(t,e.targetId,i.wa),i}async function bv(r,e){const t=L(r);return pp(t.localStore,e).then(n=>zt(t,n))}async function Sv(r,e,t,n){const i=L(r),s=await function(c,u){const h=L(c),f=L(h.mutationQueue);return h.persistence.runTransaction("Lookup mutation documents","readonly",m=>f.Mn(m,u).next(_=>_?h.localDocuments.getDocuments(m,_):A.resolve(null)))}(i.localStore,e);s!==null?(t==="pending"?await ur(i.remoteStore):t==="acknowledged"||t==="rejected"?(vc(i,e,n||null),Ec(i,e),function(c,u){L(L(c).mutationQueue).On(u)}(i.localStore,e)):M(),await zt(i,s)):C("SyncEngine","Cannot apply mutation batch with id: "+e)}async function Pv(r,e){const t=L(r);if(Zs(t),Ac(t),e===!0&&t.Qa!==!0){const n=t.sharedClientState.getAllActiveQueryTargets(),i=await bh(t,n.toArray());t.Qa=!0,await Aa(t.remoteStore,!0);for(const s of i)Xs(t.remoteStore,s)}else if(e===!1&&t.Qa!==!1){const n=[];let i=Promise.resolve();t.Ma.forEach((s,o)=>{t.sharedClientState.isLocalQueryTarget(o)?n.push(o):i=i.then(()=>(ir(t,o),tr(t.localStore,o,!0))),nr(t.remoteStore,o)}),await i,await bh(t,n),function(o){const c=L(o);c.Na.forEach((u,h)=>{nr(c.remoteStore,h)}),c.La.pr(),c.Na=new Map,c.Oa=new ie(O.comparator)}(t),t.Qa=!1,await Aa(t.remoteStore,!1)}}async function bh(r,e,t){const n=L(r),i=[],s=[];for(const o of e){let c;const u=n.Ma.get(o);if(u&&u.length!==0){c=await bs(n.localStore,qe(u[0]));for(const h of u){const f=n.Fa.get(h),m=await Rv(n,f);m.snapshot&&s.push(m.snapshot)}}else{const h=await fp(n.localStore,o);c=await bs(n.localStore,h),await Tc(n,kp(h),o,!1,c.resumeToken)}i.push(c)}return n.Ca.d_(s),i}function kp(r){return If(r.path,r.collectionGroup,r.orderBy,r.filters,r.limit,"F",r.startAt,r.endAt)}function Cv(r){return function(t){return L(L(t).persistence).Qi()}(L(r).localStore)}async function Dv(r,e,t,n){const i=L(r);if(i.Qa)return void C("SyncEngine","Ignoring unexpected query state notification.");const s=i.Ma.get(e);if(s&&s.length>0)switch(t){case"current":case"not-current":{const o=await pp(i.localStore,vf(s[0])),c=Ii.createSynthesizedRemoteEventForCurrentChange(e,t==="current",fe.EMPTY_BYTE_STRING);await zt(i,o,c);break}case"rejected":await tr(i.localStore,e,!0),ir(i,e,n);break;default:M()}}async function Vv(r,e,t){const n=Zs(r);if(n.Qa){for(const i of e){if(n.Ma.has(i)&&n.sharedClientState.isActiveQueryTarget(i)){C("SyncEngine","Adding an already active target "+i);continue}const s=await fp(n.localStore,i),o=await bs(n.localStore,s);await Tc(n,kp(s),o.targetId,!1,o.resumeToken),Xs(n.remoteStore,o)}for(const i of t)n.Ma.has(i)&&await tr(n.localStore,i,!1).then(()=>{nr(n.remoteStore,i),ir(n,i)}).catch(qt)}}function Zs(r){const e=L(r);return e.remoteStore.remoteSyncer.applyRemoteEvent=Dp.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Av.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=Iv.bind(null,e),e.Ca.d_=cv.bind(null,e.eventManager),e.Ca.$a=uv.bind(null,e.eventManager),e}function Ac(r){const e=L(r);return e.remoteStore.remoteSyncer.applySuccessfulWrite=Tv.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=Ev.bind(null,e),e}class ci{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Js(e.databaseInfo.databaseId),this.sharedClientState=this.Wa(e),this.persistence=this.Ga(e),await this.persistence.start(),this.localStore=this.za(e),this.gcScheduler=this.ja(e,this.localStore),this.indexBackfillerScheduler=this.Ha(e,this.localStore)}ja(e,t){return null}Ha(e,t){return null}za(e){return lp(this.persistence,new up,e.initialUser,this.serializer)}Ga(e){return new ap(Qs.Zr,this.serializer)}Wa(e){return new gp}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedCl
3185ientState.shutdown(),await this.persistence.shutdown()}}ci.provider={build:()=>new ci};class Np extends ci{constructor(e,t,n){super(),this.Ja=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.Ja.initialize(this,e),await Ac(this.Ja.syncEngine),await ur(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(e){return lp(this.persistence,new up,e.initialUser,this.serializer)}ja(e,t){const n=this.persistence.referenceDelegate.garbageCollector;return new IE(n,e.asyncQueue,t)}Ha(e,t){const n=new ZI(t,this.persistence);return new XI(e.asyncQueue,n)}Ga(e){const t=cp(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=this.cacheSizeBytes!==void 0?xe.withCacheSize(this.cacheSizeBytes):xe.DEFAULT;return new lc(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,_p(),ls(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Wa(e){return new gp}}class kv extends Np{constructor(e,t){super(e,t,!1),this.Ja=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);const t=this.Ja.syncEngine;this.sharedClientState instanceof $o&&(this.sharedClientState.syncEngine={no:Sv.bind(null,t),ro:Dv.bind(null,t),io:Vv.bind(null,t),Qi:Cv.bind(null,t),eo:bv.bind(null,t)},await this.sharedClientState.start()),await this.persistence.yi(async n=>{await Pv(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(e){const t=_p();if(!$o.D(t))throw new k(P.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=cp(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new $o(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class ui{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>Rh(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=wv.bind(null,this.syncEngine),await Aa(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new av}()}createDatastore(e){const t=Js(e.databaseInfo.databaseId),n=function(s){return new zE(s)}(e.databaseInfo);return function(s,o,c,u){return new WE(s,o,c,u)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(n,i,s,o,c){return new QE(n,i,s,o,c)}(this.localStore,this.datastore,e.asyncQueue,t=>Rh(this.syncEngine,t,0),function(){return Th.D()?new Th:new qE}())}createSyncEngine(e,t){return function(i,s,o,c,u,h,f){const m=new fv(i,s,o,c,u,h);return f&&(m.Qa=!0),m}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(i){const s=L(i);C("RemoteStore","RemoteStore shutting down."),s.L_.add(5),await Ei(s),s.k_.shutdown(),s.q_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}ui.provider={build:()=>new ui};/**
3186 * @license
3187 * Copyright 2020 Google LLC
3188 *
3189 * Licensed under the Apache License, Version 2.0 (the "License");
3190 * you may not use this file except in compliance with the License.
3191 * You may obtain a copy of the License at
3192 *
3193 *   http://www.apache.org/licenses/LICENSE-2.0
3194 *
3195 * Unless required by applicable law or agreed to in writing, software
3196 * distributed under the License is distributed on an "AS IS" BASIS,
3197 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3198 * See the License for the specific language governing permissions and
3199 * limitations under the License.
3200 *//**
3201 * @license
3202 * Copyright 2017 Google LLC
3203 *
3204 * Licensed under the Apache License, Version 2.0 (the "License");
3205 * you may not use this file except in compliance with the License.
3206 * You may obtain a copy of the License at
3207 *
3208 *   http://www.apache.org/licenses/LICENSE-2.0
3209 *
3210 * Unless required by applicable law or agreed to in writing, software
3211 * distributed under the License is distributed on an "AS IS" BASIS,
3212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3213 * See the License for the specific language governing permissions and
3214 * limitations under the License.
3215 */class xp{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ya(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ya(this.observer.error,e):he("Uncaught Error in snapshot listener:",e.toString()))}Za(){this.muted=!0}Ya(e,t){setTimeout(()=>{this.muted||e(t)},0)}}/**
3216 * @license
3217 * Copyright 2017 Google LLC
3218 *
3219 * Licensed under the Apache License, Version 2.0 (the "License");
3220 * you may not use this file except in compliance with the License.
3221 * You may obtain a copy of the License at
3222 *
3223 *   http://www.apache.org/licenses/LICENSE-2.0
3224 *
3225 * Unless required by applicable law or agreed to in writing, software
3226 * distributed under the License is distributed on an "AS IS" BASIS,
3227 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3228 * See the License for the specific language governing permissions and
3229 * limitations under the License.
3230 */class Nv{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new k(P.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const t=await async function(i,s){const o=L(i),c={documents:s.map(m=>oi(o.serializer,m))},u=await o.Lo("BatchGetDocuments",o.serializer.databaseId,Z.emptyPath(),c,s.length),h=new Map;u.forEach(m=>{const _=ZT(o.serializer,m);h.set(_.key.toString(),_)});const f=[];return s.forEach(m=>{const _=h.get(m.toString());F(!!_),f.push(_)}),f}(this.datastore,e);return t.forEach(n=>this.recordVersion(n)),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(n){this.lastTransactionError=n}this.writtenDocs.add(e.toString())}delete(e){this.write(new yi(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const e=this.readVersions;this.mutations.forEach(t=>{e.delete(t.key.toString())}),e.forEach((t,n)=>{const i=O.fromPath(n);this.mutations.push(new tc(i,this.precondition(i)))}),await async function(n,i){const s=L(n),o={writes:i.map(c=>ai(s.serializer,c))};await s.Mo("Commit",s.serializer.databaseId,Z.emptyPath(),o)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw M();t=B.min()}const n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new k(P.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){const t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(B.min())?de.exists(!1):de.updateTime(t):de.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(B.min()))throw new k(P.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return de.updateTime(t)}return de.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}/**
3231 * @license
3232 * Copyright 2019 Google LLC
3233 *
3234 * Licensed under the Apache License, Version 2.0 (the "License");
3235 * you may not use this file except in compliance with the License.
3236 * You may obtain a copy of the License at
3237 *
3238 *   http://www.apache.org/licenses/LICENSE-2.0
3239 *
3240 * Unless required by applicable law or agreed to in writing, softw
3240are
3241 * distributed under the License is distributed on an "AS IS" BASIS,
3242 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3243 * See the License for the specific language governing permissions and
3244 * limitations under the License.
3245 */class xv{constructor(e,t,n,i,s){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=i,this.deferred=s,this._u=n.maxAttempts,this.t_=new fc(this.asyncQueue,"transaction_retry")}au(){this._u-=1,this.uu()}uu(){this.t_.Go(async()=>{const e=new Nv(this.datastore),t=this.cu(e);t&&t.then(n=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(n)}).catch(i=>{this.lu(i)}))}).catch(n=>{this.lu(n)})})}cu(e){try{const t=this.updateFunction(e);return!mi(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}}lu(e){this._u>0&&this.hu(e)?(this._u-=1,this.asyncQueue.enqueueAndForget(()=>(this.uu(),Promise.resolve()))):this.deferred.reject(e)}hu(e){if(e.name==="FirebaseError"){const t=e.code;return t==="aborted"||t==="failed-precondition"||t==="already-exists"||!Of(t)}return!1}}/**
3246 * @license
3247 * Copyright 2017 Google LLC
3248 *
3249 * Licensed under the Apache License, Version 2.0 (the "License");
3250 * you may not use this file except in compliance with the License.
3251 * You may obtain a copy of the License at
3252 *
3253 *   http://www.apache.org/licenses/LICENSE-2.0
3254 *
3255 * Unless required by applicable law or agreed to in writing, software
3256 * distributed under the License is distributed on an "AS IS" BASIS,
3257 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3258 * See the License for the specific language governing permissions and
3259 * limitations under the License.
3260 */class Ov{constructor(e,t,n,i,s){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=i,this.user=Ce.UNAUTHENTICATED,this.clientId=Hd.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=s,this.authCredentials.start(n,async o=>{C("FirestoreClient","Received user=",o.uid),await this.authCredentialListener(o),this.user=o}),this.appCheckCredentials.start(n,o=>(C("FirestoreClient","Received new app check token=",o),this.appCheckCredentialListener(o,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(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new Ye;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=yc(t,"Failed to shutdown persistence");e.reject(n)}}),e.promise}}async function Go(r,e){r.asyncQueue.verifyOperationInProgress(),C("FirestoreClient","Initializing OfflineComponentProvider");const t=r.configuration;await e.initialize(t);let n=t.initialUser;r.setCredentialChangeListener(async i=>{n.isEqual(i)||(await hp(e.localStore,i),n=i)}),e.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=e}async function Sh(r,e){r.asyncQueue.verifyOperationInProgress();const t=await Mv(r);C("FirestoreClient","Initializing OnlineComponentProvider"),await e.initialize(t,r.configuration),r.setCredentialChangeListener(n=>Eh(e.remoteStore,n)),r.setAppCheckTokenChangeListener((n,i)=>Eh(e.remoteStore,i)),r._onlineComponents=e}async function Mv(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){C("FirestoreClient","Using user provided OfflineComponentProvider");try{await Go(r,r._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!function(i){return i.name==="FirebaseError"?i.code===P.FAILED_PRECONDITION||i.code===P.UNIMPLEMENT
3260ED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11}(t))throw t;Yr("Error using user provided cache. Falling back to memory cache: "+t),await Go(r,new ci)}}else C("FirestoreClient","Using default OfflineComponentProvider"),await Go(r,new ci);return r._offlineComponents}async function Rc(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(C("FirestoreClient","Using user provided OnlineComponentProvider"),await Sh(r,r._uninitializedComponentsProvider._online)):(C("FirestoreClient","Using default OnlineComponentProvider"),await Sh(r,new ui))),r._onlineComponents}function Lv(r){return Rc(r).then(e=>e.syncEngine)}function Fv(r){return Rc(r).then(e=>e.datastore)}async function Op(r){const e=await Rc(r),t=e.eventManager;return t.onListen=pv.bind(null,e.syncEngine),t.onUnlisten=gv.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=mv.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=_v.bind(null,e.syncEngine),t}function Uv(r,e,t={}){const n=new Ye;return r.asyncQueue.enqueueAndForget(async()=>function(s,o,c,u,h){const f=new xp({next:_=>{f.Za(),o.enqueueAndForget(()=>Rp(s,m));const b=_.docs.has(c);!b&&_.fromCache?h.reject(new k(P.UNAVAILABLE,"Failed to get document because the client is offline.")):b&&_.fromCache&&u&&u.source==="server"?h.reject(new k(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(_)}),m=new bp($s(c.path),f,{includeMetadataChanges:!0,_a:!0});return Ap(s,m)}(await Op(r),r.asyncQueue,e,t,n)),n.promise}function Bv(r,e,t={}){const n=new Ye;return r.asyncQueue.enqueueAndForget(async()=>function(s,o,c,u,h){const f=new xp({next:_=>{f.Za(),o.enqueueAndForget(()=>Rp(s,m)),_.fromCache&&u.source==="server"?h.reject(new k(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(_)}),m=new bp(c,f,{includeMetadataChanges:!0,_a:!0});return Ap(s,m)}(await Op(r),r.asyncQueue,e,t,n)),n.promise}/**
3261 * @license
3262 * Copyright 2023 Google LLC
3263 *
3264 * Licensed under the Apache License, Version 2.0 (the "License");
3265 * you may not use this file except in compliance with the License.
3266 * You may obtain a copy of the License at
3267 *
3268 *   http://www.apache.org/licenses/LICENSE-2.0
3269 *
3270 * Unless required by applicable law or agreed to in writing, software
3271 * distributed under the License is distributed on an "AS IS" BASIS,
3272 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3273 * See the License for the specific language governing permissions and
3274 * limitations under the License.
3275 */function Mp(r){const e={};return r.timeoutSeconds!==void 0&&(e.timeoutSeconds=r.timeoutSeconds),e}/**
3276 * @license
3277 * Copyright 2020 Google LLC
3278 *
3279 * Licensed under the Apache License, Version 2.0 (the "License");
3280 * you may not use this file except in compliance with the License.
3281 * You may obtain a copy of the License at
3282 *
3283 *   http://www.apache.org/licenses/LICENSE-2.0
3284 *
3285 * Unless required by applicable law or agreed to in writing, software
3286 * distributed under the License is distributed on an "AS IS" BASIS,
3287 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3288 * See the License for the specific language governing permissions and
3289 * limitations under the License.
3290 */const Ph=new Map;/**
3291 * @license
3292 * Copyright 2017 Google LLC
3293 *
3294 * Licensed under the Apache License, Version 2.0 (the "License");
3295 * you may not use this file except in compliance with the License.
3296 * You may obtain a copy of the License at
3297 *
3298 *   http://www.apache.org/licenses/LICENSE-2.0
3299 *
3300 * Unless required by applicable law or agreed to in writing, software
3301 * distributed under the License is distributed on an "AS IS" BASIS,
3302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3303 * See the License for the specific language governing permissions and
3304 * limitations under the License.
3305 */function Lp(r,e,t){if(!t)throw new k(P.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${e}.`)}function qv(r,e,t,n){if(e===!0&&n===!0)throw new k(P.INVALID_ARGUMENT,`${r} and ${t} cannot be used together.`)}function Ch(r){if(!O.isDocumentKey(r))throw new k(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function Dh(r){if(O.isDocumentKey(r))throw new k(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${r} has ${r.length}.`)}function eo(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 e=function(n){return n.constructor?n.constructor.name:null}(r);return e?`a custom ${e} object`:"an object"}}return typeof r=="function"?"a function":M()}function Ze(r,e){if("_delegate"in r&&(r=r._delegate),!(r instanceof e)){if(e.name===r.constructor.name)throw new k(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=eo(r);throw new k(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return r}function jv(r,e){if(e<=0)throw new k(P.INVALID_ARGUMENT,`Function ${r}() requires a positive number, but it was: ${e}.`)}/**
3306 * @license
3307 * Copyright 2020 Google LLC
3308 *
3309 * Licensed under the Apache License, Version 2.0 (the "License");
3310 * you may not use this file except in compliance with the License.
3311 * You may obtain a copy of the License at
3312 *
3313 *   http://www.apache.org/licenses/LICENSE-2.0
3314 *
3315 * Unless required by applicable law or agreed to in writing, software
3316 * distributed under the License is distributed on an "AS IS" BASIS,
3317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3318 * See the License for the specific language governing permissions and
3319 * limitations under the License.
3320 */class Vh{constructor(e){var t,n;if(e.host===void 0){if(e.ssl!==void 0)throw new k(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=e.host,this.ssl=(t=e.ssl)===null||t===void 0||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new k(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}qv("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Mp((n=e.experimentalLongPollingOptions)!==null&&n!==void 0?n:{}),function(s){if(s.timeoutSeconds!==void 0){if(isNaN(s.timeoutSeconds))throw new k(P.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (must not be NaN)`);if(s.timeoutSeconds<5)throw new k(P.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (minimum allowed value is 5)`);if(s.timeoutSeconds>30)throw new k(P.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(n,i){return n.timeoutSeconds===i.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class bc{constructor(e,t,n,i){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Vh({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new k(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(e){if(this._settingsFrozen)throw new k(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 Vh(e),e.credentials!==void 0&&(this._authCredentials=function(n){if(!n)return new jI;switch(n.type){case"firstParty":return new GI(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new k(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.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(t){const n=Ph.get(t);n&&(C("ComponentProvider","Removing Datastore"),Ph.delete(t),n.terminate())}(this),Promise.resolve()}}/**
3321 * @license
3322 * Copyright 2020 Google LLC
3323 *
3324 * Licensed under the Apache License, Version 2.0 (the "License");
3325 * you may not use this file except in compliance with the License.
3326 * You may obtain a copy of the License at
3327 *
3328 *   http://www.apache.org/licenses/LICENSE-2.0
3329 *
3330 * Unless required by applicable law or agreed to in writing, software
3331 * distributed under the License is distributed on an "AS IS" BASIS,
3332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3333 * See the License for the specific language governing permissions and
3334 * limitations under the License.
3335 */class Gt{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new Gt(this.firestore,e,this._query)}}class De{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Ot(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new De(this.firestore,e,this._key)}}class Ot extends Gt{constructor(e,t,n){super(e,t,$s(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new De(this.firestore,null,new O(e))}withConverter(e){return new Ot(this.firestore,e,this._path)}}function OR(r,e,...t){if(r=re(r),Lp("collection","path",e),r instanceof bc){const n=Z.fromString(e,...t);return Dh(n),new Ot(r,null,n)}{if(!(r instanceof De||r instanceof Ot))throw new k(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(Z.fromString(e,...t));return Dh(n),new Ot(r.firestore,null,n)}}function $v(r,e,...t){if(r=re(r),arguments.length===1&&(e=Hd.newId()),Lp("doc","path",e),r instanceof bc){const n=Z.fromString(e,...t);return Ch(n),new De(r,null,new O(n))}{if(!(r instanceof De||r instanceof Ot))throw new k(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(Z.fromString(e,...t));return Ch(n),new De(r.firestore,r instanceof Ot?r.converter:null,new O(n))}}/**
3336 * @license
3337 * Copyright 2020 Google LLC
3338 *
3339 * Licensed under the Apache License, Version 2.0 (the "License");
3340 * you may not use this file except in compliance with the License.
3341 * You may obtain a copy of the License at
3342 *
3343 *   http://www.apache.org/licenses/LICENSE-2.0
3344 *
3345 * Unless required by applicable law or agreed to in writing, software
3346 * distributed under the License is distributed on an "AS IS" BASIS,
3347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3348 * See the License for the specific language governing permissions and
3349 * limitations under the License.
3350 */class kh{constructor(e=Promise.resolve()){this.Pu=[],this.Iu=!1,this.Tu=[],this.Eu=null,this.du=!1,this.Au=!1,this.Ru=[],this.t_=new fc(this,"async_queue_retry"),this.Vu=()=>{const n=ls();n&&C("AsyncQueue","Visibility state changed to "+n.visibilityState),this.t_.jo()},this.mu=e;const t=ls();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Vu)}get isShuttingDown(){return this.Iu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.fu(),this.gu(e)}enterRestrictedMode(e){if(!this.Iu){this.Iu=!0,this.Au=e||!1;const t=ls();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Vu)}}enqueue(e){if(this.fu(),this.Iu)return new Promise(()=>{});const t=new Ye;return this.gu(()=>this.Iu&&this.Au?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Pu.push(e),this.pu()))}async pu(){if(this.Pu.length!==0){try{await this.Pu[0](),this.Pu.shift(),this.t_.reset()}catch(e){if(!jt(e))throw e;C("AsyncQueue","Operation failed with retryable error: "+e)}this.Pu.length>0&&this.t_.Go(()=>this.pu())}}gu(e){const t=this.mu.then(()=>(this.du=!0,e().catch(n=>{this.Eu=n,this.du=!1;const i=function(o){let c=o.message||"";return o.stack&&(c=o.stack.includes(o.message)?o.stack:o.message+`
3351`+o.stack),c}(n);throw he("INTERNAL UNHANDLED ERROR: ",i),n}).then(n=>(this.du=!1,n))));return this.mu=t,t}enqueueAfterDelay(e,t,n){this.fu(),this.Ru.indexOf(e)>-1&&(t=0);const i=_c.createAndSchedule(this,e,t,n,s=>this.yu(s));return this.Tu.push(i),i}fu(){this.Eu&&M()}verifyOperationInProgress(){}async wu(){let e;do e=this.mu,await e;while(e!==this.mu)}Su(e){for(const t of this.Tu)if(t.timerId===e)return!0;return!1}bu(e){return this.wu().then(()=>{this.Tu.sort((t,n)=>t.targetTimeMs-n.targetTimeMs);for(const t of this.Tu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.wu()})}Du(e){this.Ru.push(e)}yu(e){const t=this.Tu.indexOf(e);this.Tu.splice(t,1)}}/**
3352 * @license
3353 * Copyright 2020 Google LLC
3354 *
3355 * Licensed under the Apache License, Version 2.0 (the "License");
3356 * you may not use this file except in compliance with the License.
3357 * You may obtain a copy of the License at
3358 *
3359 *   http://www.apache.org/licenses/LICENSE-2.0
3360 *
3361 * Unless required by applicable law or agreed to in writing, software
3362 * distributed under the License is distributed on an "AS IS" BASIS,
3363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3364 * See the License for the specific language governing permissions and
3365 * limitations under the License.
3366 */const MR=-1;class Kt extends bc{constructor(e,t,n,i){super(e,t,n,i),this.type="firestore",this._queue=new kh,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new kh(e),this._firestoreClient=void 0,await e}}}function LR(r,e,t){t||(t="(default)");const n=Ut(r,"firestore");if(n.isInitialized(t)){const i=n.getImmediate({identifier:t}),s=n.getOptions(t);if(zn(s,e))return i;throw new k(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(e.cacheSizeBytes!==void 0&&e.localCache!==void 0)throw new k(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(e.cacheSizeBytes!==void 0&&e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new k(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return n.initialize({options:e,instanceIdentifier:t})}function to(r){if(r._terminated)throw new k(P.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||zv(r),r._firestoreClient}function zv(r){var e,t,n;const i=r._freezeSettings(),s=function(c,u,h,f){return new TT(c,u,h,f.host,f.ssl,f.experimentalForceLongPolling,f.experimentalAutoDetectLongPolling,Mp(f.experimentalLongPollingOptions),f.useFetchStreams)}(r._databaseId,((e=r._app)===null||e===void 0?void 0:e.options.appId)||"",r._persistenceKey,i);r._componentsProvider||!((t=i.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((n=i.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),r._firestoreClient=new Ov(r._authCredentials,r._appCheckCredentials,r._queue,s,r._componentsProvider&&function(c){const u=c==null?void 0:c._online.build();return{_offline:c==null?void 0:c._offline.build(u),_online:u}}(r._componentsProvider))}/**
3367 * @license
3368 * Copyright 2020 Google LLC
3369 *
3370 * Licensed under the Apache License, Version 2.0 (the "License");
3371 * you may not use this file except in compliance with the License.
3372 * You may obtain a copy of the License at
3373 *
3374 *   http://www.apache.org/licenses/LICENSE-2.0
3375 *
3376 * Unless required by applicable law or agreed to in writing, software
3377 * distributed under the License is distributed on an "AS IS" BASIS,
3378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3379 * See the License for the specific language governing permissions and
3380 * limitations under the License.
3381 */class yn{constructor(e){this._byteString=e}static fromBase64String(e){try{return new yn(fe.fromBase64String(e))}catch(t){throw new k(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new yn(fe.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}/**
3382 * @license
3383 * Copyright 2020 Google LLC
3384 *
3385 * Licensed under the Apache License, Version 2.0 (the "License");
3386 * you may not use this file except in compliance with the License.
3387 * You may obtain a copy of the License at
3388 *
3389 *   http://www.apache.org/licenses/LICENSE-2.0
3390 *
3391 * Unless required by applicable law or agreed to in writing, softw
3391are
3392 * distributed under the License is distributed on an "AS IS" BASIS,
3393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3394 * See the License for the specific language governing permissions and
3395 * limitations under the License.
3396 */class vi{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new k(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ce(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
3397 * @license
3398 * Copyright 2020 Google LLC
3399 *
3400 * Licensed under the Apache License, Version 2.0 (the "License");
3401 * you may not use this file except in compliance with the License.
3402 * You may obtain a copy of the License at
3403 *
3404 *   http://www.apache.org/licenses/LICENSE-2.0
3405 *
3406 * Unless required by applicable law or agreed to in writing, software
3407 * distributed under the License is distributed on an "AS IS" BASIS,
3408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3409 * See the License for the specific language governing permissions and
3410 * limitations under the License.
3411 */class wi{constructor(e){this._methodName=e}}/**
3412 * @license
3413 * Copyright 2017 Google LLC
3414 *
3415 * Licensed under the Apache License, Version 2.0 (the "License");
3416 * you may not use this file except in compliance with the License.
3417 * You may obtain a copy of the License at
3418 *
3419 *   http://www.apache.org/licenses/LICENSE-2.0
3420 *
3421 * Unless required by applicable law or agreed to in writing, software
3422 * distributed under the License is distributed on an "AS IS" BASIS,
3423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3424 * See the License for the specific language governing permissions and
3425 * limitations under the License.
3426 */class Sc{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new k(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new k(P.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return G(this._lat,e._lat)||G(this._long,e._long)}}/**
3427 * @license
3428 * Copyright 2024 Google LLC
3429 *
3430 * Licensed under the Apache License, Version 2.0 (the "License");
3431 * you may not use this file except in compliance with the License.
3432 * You may obtain a copy of the License at
3433 *
3434 *   http://www.apache.org/licenses/LICENSE-2.0
3435 *
3436 * Unless required by applicable law or agreed to in writing, software
3437 * distributed under the License is distributed on an "AS IS" BASIS,
3438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3439 * See the License for the specific language governing permissions and
3440 * limitations under the License.
3441 */class Pc{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){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,e._values)}}/**
3442 * @license
3443 * Copyright 2017 Google LLC
3444 *
3445 * Licensed under the Apache License, Version 2.0 (the "License");
3446 * you may not use this file except in compliance with the License.
3447 * You may obtain a copy of the License at
3448 *
3449 *   http://www.apache.org/licenses/LICENSE-2.0
3450 *
3451 * Unless required by applicable law or agreed to in writing, software
3452 * distributed under the License is distributed on an "AS IS" BASIS,
3453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3454 * See the License for the specific language governing permissions and
3455 * limitations under the License.
3456 */const Gv=/^__.*__$/;class Kv{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask!==null?new yt(e,this.data,this.fieldMask,t,this.fieldTransforms):new cr(e,this.data,t,this.fieldTransforms)}}class Fp{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new yt(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function Up(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw M()}}class Cc{constructor(e,t,n,i,s,o){this.settings=e,this.databaseId=t,this.serializer
3456=n,this.ignoreUndefinedProperties=i,s===void 0&&this.vu(),this.fieldTransforms=s||[],this.fieldMask=o||[]}get path(){return this.settings.path}get Cu(){return this.settings.Cu}Fu(e){return new Cc(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Mu(e){var t;const n=(t=this.path)===null||t===void 0?void 0:t.child(e),i=this.Fu({path:n,xu:!1});return i.Ou(e),i}Nu(e){var t;const n=(t=this.path)===null||t===void 0?void 0:t.child(e),i=this.Fu({path:n,xu:!1});return i.vu(),i}Lu(e){return this.Fu({path:void 0,xu:!0})}Bu(e){return Ds(e,this.settings.methodName,this.settings.ku||!1,this.path,this.settings.qu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}vu(){if(this.path)for(let e=0;e<this.path.length;e++)this.Ou(this.path.get(e))}Ou(e){if(e.length===0)throw this.Bu("Document fields must not be empty");if(Up(this.Cu)&&Gv.test(e))throw this.Bu('Document fields cannot begin and end with "__"')}}class Wv{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Js(e)}Qu(e,t,n,i=!1){return new Cc({Cu:e,methodName:t,qu:n,path:ce.emptyPath(),xu:!1,ku:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Ai(r){const e=r._freezeSettings(),t=Js(r._databaseId);return new Wv(r._databaseId,!!e.ignoreUndefinedProperties,t)}function Dc(r,e,t,n,i,s={}){const o=r.Qu(s.merge||s.mergeFields?2:0,e,t,i);Nc("Data must be an object, but it was:",o,n);const c=jp(n,o);let u,h;if(s.merge)u=new Me(o.fieldMask),h=o.fieldTransforms;else if(s.mergeFields){const f=[];for(const m of s.mergeFields){const _=Sa(e,m,t);if(!o.contains(_))throw new k(P.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);zp(f,_)||f.push(_)}u=new Me(f),h=o.fieldTransforms.filter(m=>u.covers(m.field))}else u=null,h=o.fieldTransforms;return new Kv(new Ee(c),u,h)}class no extends wi{_toFieldTransform(e){if(e.Cu!==2)throw e.Cu===1?e.Bu(`${this._methodName}() can only appear at the top level of your update data`):e.Bu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof no}}class Vc extends wi{_toFieldTransform(e){return new ec(e.path,new Jn)}isEqual(e){return e instanceof Vc}}class kc extends wi{constructor(e,t){super(e),this.$u=t}_toFieldTransform(e){const t=new Zn(e.serializer,Pf(e.serializer,this.$u));return new ec(e.path,t)}isEqual(e){return e instanceof kc&&this.$u===e.$u}}function Bp(r,e,t,n){const i=r.Qu(1,e,t);Nc("Data must be an object, but it was:",i,n);const s=[],o=Ee.empty();An(n,(u,h)=>{const f=xc(e,u,t);h=re(h);const m=i.Nu(f);if(h instanceof no)s.push(f);else{const _=Ri(h,m);_!=null&&(s.push(f),o.set(f,_))}});const c=new Me(s);return new Fp(o,c,i.fieldTransforms)}function qp(r,e,t,n,i,s){const o=r.Qu(1,e,t),c=[Sa(e,n,t)],u=[i];if(s.length%2!=0)throw new k(P.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let _=0;_<s.length;_+=2)c.push(Sa(e,s[_])),u.push(s[_+1]);const h=[],f=Ee.empty();for(let _=c.length-1;_>=0;--_)if(!zp(h,c[_])){const b=c[_];let V=u[_];V=re(V);const N=o.Nu(b);if(V instanceof no)h.push(b);else{const D=Ri(V,N);D!=null&&(h.push(b),f.set(b,D))}}const m=new Me(h);return new Fp(f,m,o.fieldTransforms)}function Hv(r,e,t,n=!1){return Ri(t,r.Qu(n?4:3,e))}function Ri(r,e){if($p(r=re(r)))return Nc("Unsupported field value:",e,r),jp(r,e);if(r instanceof wi)return function(n,i){if(!Up(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,e),null;if(r===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),r instanceof Array){if(e.settings.xu&&e.Cu!==4)throw e.Bu("Nested arrays are not supported");return function(n,i){const s=[];let o=0;for(const c of n){let u=Ri(c,i.Lu(o));u==null&&(u={nullValue:"NULL_VALUE"}),s.push(u),o++}return{arrayValue:{values:s}}}(r,e)}
3456return function(n,i){if((n=re(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return Pf(i.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const s=ue.fromDate(n);return{timestampValue:er(i.serializer,s)}}if(n instanceof ue){const s=new ue(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:er(i.serializer,s)}}if(n instanceof Sc)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof yn)return{bytesValue:Uf(i.serializer,n._byteString)};if(n instanceof De){const s=i.databaseId,o=n.firestore._databaseId;if(!o.isEqual(s))throw i.Bu(`Document reference is for database ${o.projectId}/${o.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:oc(n.firestore._databaseId||i.databaseId,n._key.path)}}if(n instanceof Pc)return function(o,c){return{mapValue:{fields:{__type__:{stringValue:"__vector__"},value:{arrayValue:{values:o.toArray().map(u=>{if(typeof u!="number")throw c.Bu("VectorValues must only contain numeric values.");return Za(c.serializer,u)})}}}}}}(n,i);throw i.Bu(`Unsupported field value: ${eo(n)}`)}(r,e)}function jp(r,e){const t={};return af(r)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):An(r,(n,i)=>{const s=Ri(i,e.Mu(n));s!=null&&(t[n]=s)}),{mapValue:{fields:t}}}function $p(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof ue||r instanceof Sc||r instanceof yn||r instanceof De||r instanceof wi||r instanceof Pc)}function Nc(r,e,t){if(!$p(t)||!function(i){return typeof i=="object"&&i!==null&&(Object.getPrototypeOf(i)===Object.prototype||Object.getPrototypeOf(i)===null)}(t)){const n=eo(t);throw n==="an object"?e.Bu(r+" a custom object"):e.Bu(r+" "+n)}}function Sa(r,e,t){if((e=re(e))instanceof vi)return e._internalPath;if(typeof e=="string")return xc(r,e);throw Ds("Field path arguments must be of type string or ",r,!1,void 0,t)}const Qv=new RegExp("[~\\*/\\[\\]]");function xc(r,e,t){if(e.search(Qv)>=0)throw Ds(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,t);try{return new vi(...e.split("."))._internalPath}catch{throw Ds(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,t)}}function Ds(r,e,t,n,i){const s=n&&!n.isEmpty(),o=i!==void 0;let c=`Function ${e}() called with invalid data`;t&&(c+=" (via `toFirestore()`)"),c+=". ";let u="";return(s||o)&&(u+=" (found",s&&(u+=` in field ${n}`),o&&(u+=` in document ${i}`),u+=")"),new k(P.INVALID_ARGUMENT,c+r+u)}function zp(r,e){return r.some(t=>t.isEqual(e))}/**
3457 * @license
3458 * Copyright 2020 Google LLC
3459 *
3460 * Licensed under the Apache License, Version 2.0 (the "License");
3461 * you may not use this file except in compliance with the License.
3462 * You may obtain a copy of the License at
3463 *
3464 *   http://www.apache.org/licenses/LICENSE-2.0
3465 *
3466 * Unless required by applicable law or agreed to in writing, software
3467 * distributed under the License is distributed on an "AS IS" BASIS,
3468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3469 * See the License for the specific language governing permissions and
3470 * limitations under the License.
3471 */class Vs{constructor(e,t,n,i,s){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new De(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new Jv(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(ro("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class Jv extends Vs{data(){return super.data()}}function ro(r,e){return typeof e=="string"?xc(r,e):e instanceof vi?e._internalPath:e._delegate._internalPath}/**
3472 * @license
3473 * Copyright 2020 Google LLC
3474 *
3475 * Licensed under the Apache License, Version 2.0 (the "License");
3476 * you may not use this file except in compliance with the License.
3477 * You may obtain a copy of the License at
3478 *
3479 *   http://www.apache.org/licenses/LICENSE-2.0
3480 *
3481 * Unless required by applicable law or agreed to in writing, software
3482 * distributed under the License is distributed on an "AS IS" BASIS,
3483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3484 * See the License for the specific language governing permissions and
3485 * limitations under the License.
3486 */function Yv(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new k(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Oc{}class Mc extends Oc{}function FR(r,e,...t){let n=[];e instanceof Oc&&n.push(e),n=n.concat(t),function(s){const o=s.filter(u=>u instanceof Lc).length,c=s.filter(u=>u instanceof io).length;if(o>1||o>0&&c>0)throw new k(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 io extends Mc{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new io(e,t,n)}_apply(e){const t=this._parse(e);return Gp(e._query,t),new Gt(e.firestore,e.converter,pa(e._query,t))}_parse(e){const t=Ai(e.firestore);return function(s,o,c,u,h,f,m){let _;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new k(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){xh(m,f);const b=[];for(const V of m)b.push(Nh(u,s,V));_={arrayValue:{values:b}}}else _=Nh(u,s,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||xh(m,f),_=Hv(c,o,m,f==="in"||f==="not-in");return Q.create(h,f,_)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function UR(r,e,t){const n=e,i=ro("where",r);return io._create(i,n,t)}class Lc extends Oc{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Lc(e,t)}_parse(e){const t=this._queryConstraints.map(n=>n._parse(e)).filter(n=>n.getFilters().length>0);return t.length===1?t[0]:ee.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:(function(i,s){let o=i;const c=s.getFlattenedFilters();for(const u of c)Gp(o,u),o=pa(o,u)}(e._query,t),new Gt(e.firestore,e.converter,pa(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class Fc extends Mc{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new Fc(e,t)}_apply(e){const t=function(i,s,o){if(i.startAt!==null)throw new k(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new k(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new si(s,o)}(e._query,this._field,this._direction);return new Gt(e.firestore,e.converter,function(i,s){const o=i.explicitOrderBy.concat([s]);return new ar(i.path,i.collectionGroup,o,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)}(e._query,t))}}function BR(r,e="asc"){const t=e,n=ro("orderBy",r);return Fc._create(n,t)}class Uc extends Mc{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new Uc(e,t,n)}_apply(e){return new Gt(e.firestore,e.converter,vs(e._query,this._limit,this._limitType))}}function qR(r){return jv("limit",r),Uc._create("limit",r,"F")}function Nh(r,e,t){if(typeof(t=re(t))=="string"){if(t==="")throw new k(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Tf(e)&&t.indexOf("/")!==-1)throw new k(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const n=e.path.child(Z.fromString(t));if(!O.isDocumentKey(n))throw new k(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 ri(r,new O(n))}if(t instanceof De)return ri(r,t._key);throw new k(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${eo(t)}.`)}function xh(r,e){if(!Array.isArray(r)||r.length===0)throw new k(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function Gp(r,e){const t=function(i,s){for(const o of i)for(const c of o.getFlattenedFilters())if(s.indexOf(c.op)>=0)return c.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[]}}(e.op));if(t!==null)throw t===e.op?new k(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new k(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}class Kp{convertValue(e,t="none"){switch(fn(e)){case 0:return null;case 1:return e.booleanValue;case 2:return oe(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Mt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw M()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return An(e,(i,s)=>{n[i]=this.convertValue(s,t)}),n}convertVectorValue(e){var t,n,i;const s=(i=(n=(t=e.fields)===null||t===void 0?void 0:t.value.arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.map(o=>oe(o.doubleValue));return new Pc(s)}convertGeoPoint(e){return new Sc(oe(e.latitude),oe(e.longitude))}convertArray(e,t){return(e.values||[]).map(n=>this.convertValue(n,t))}convertServerTimestamp(e,t){switch(t){case"previous":const n=Ja(e);return n==null?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(ti(e));default:return null}}convertTimestamp(e){const t=gt(e);return new ue(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=Z.fromString(e);F(Qf(n));const i=new dn(n.get(1),n.get(3)),s=new O(n.popFirst(5));return i.isEqual(t)||he(`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 (${t.projectId}/${t.database}) instead.`),s}}/**
3487 * @license
3488 * Copyright 2020 Google LLC
3489 *
3490 * Licensed under the Apache License, Version 2.0 (the "License");
3491 * you may not use this file except in compliance with the License.
3492 * You may obtain a copy of the License at
3493 *
3494 *   http://www.apache.org/licenses/LICENSE-2.0
3495 *
3496 * Unless required by applicable law or agreed to in writing, software
3497 * distributed under the License is distributed on an "AS IS" BASIS,
3498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3499 * See the License for the specific language governing permissions and
3500 * limitations under the License.
3501 */function Bc(r,e,t){let n;return n=r?t&&(t.merge||t.mergeFields)?r.toFirestore(e,t):r.toFirestore(e):e,n}class Xv extends Kp{constructor(e){super(),this.firestore=e}convertBytes(e){return new yn(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new De(this.firestore,null,t)}}/**
3502 * @license
3503 * Copyright 2020 Google LLC
3504 *
3505 * Licensed under the Apache License, Version 2.0 (the "License");
3506 * you may not use this file except in compliance with the License.
3507 * You may obtain a copy of the License at
3508 *
3509 *   http://www.apache.org/licenses/LICENSE-2.0
3510 *
3511 * Unless required by applicable law or agreed to in writing, software
3512 * distributed under the License is distributed on an "AS IS" BASIS,
3513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3514 * See the License for the specific language governing permissions and
3515 * limitations under the License.
3516 */class Un{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class qc extends Vs{constructor(e,t,n,i,s,o){super(e,t,n,i,o),this._firestore=e,this._firestoreImpl=e,this.metadata=s}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new hs(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const n=this._document.data.field(ro("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class hs extends qc{data(e={}){return super.data(e)}}class Zv{constructor(e,t,n,i){this._firestore=e,this._userDataWriter=t,this._snapshot=i,this.metadata=new Un(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new hs(this._firestore,this._userDataWriter,n.key,n,new Un(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new k(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(i,s){if(i._snapshot.oldDocs.isEmpty()){let o=0;return i._snapshot.docChanges.map(c=>{const u=new hs(i._firestore,i._userDataWriter,c.doc.key,c.doc,new Un(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);return c.doc,{type:"added",doc:u,oldIndex:-1,newIndex:o++}})}{let o=i._snapshot.oldDocs;return i._snapshot.docChanges.filter(c=>s||c.type!==3).map(c=>{const u=new hs(i._firestore,i._userDataWriter,c.doc.key,c.doc,new Un(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);let h=-1,f=-1;return c.type!==0&&(h=o.indexOf(c.doc.key),o=o.delete(c.doc.key)),c.type!==1&&(o=o.add(c.doc),f=o.indexOf(c.doc.key)),{type:ew(c.type),doc:u,oldIndex:h,newIndex:f}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function ew(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return M()}}/**
3517 * @license
3518 * Copyright 2020 Google LLC
3519 *
3520 * Licensed under the Apache License, Version 2.0 (the "License");
3521 * you may not use this file except in compliance with the License.
3522 * You may obtain a copy of the License at
3523 *
3524 *   http://www.apache.org/licenses/LICENSE-2.0
3525 *
3526 * Unless required by applicable law or agreed to in writing, software
3527 * distributed under the License is distributed on an "AS IS" BASIS,
3528 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3529 * See the License for the specific language governing permissions and
3530 * limitations under the License.
3531 */function jR(r){r=Ze(r,De);const e=Ze(r.firestore,Kt);return Uv(to(e),r._key).then(t=>tw(e,r,t))}class jc extends Kp{constructor(e){super(),this.firestore=e}convertBytes(e){return new yn(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new De(this.firestore,null,t)}}function $R(r){r=Ze(r,Gt);const e=Ze(r.firestore,Kt),t=to(e),n=new jc(e);return Yv(r._query),Bv(t,r._query).then(i=>new Zv(e,n,r,i))}function zR(r,e,t){r=Ze(r,De);const n=Ze(r.firestore,Kt),i=Bc(r.converter,e,t);return so(n,[Dc(Ai(n),"setDoc",r._key,i,r.converter!==null,t).toMutation(r._key,de.none())])}function GR(r,e,t,...n){r=Ze(r,De);const i=Ze(r.firestore,Kt),s=Ai(i);let o;return o=typeof(e=re(e))=="string"||e instanceof vi?qp(s,"updateDoc",r._key,e,t,n):Bp(s,"updateDoc",r._key,e),so(i,[o.toMutation(r._key,de.exists(!0))])}function KR(r){return so(Ze(r.firestore,Kt),[new yi(r._key,de.none())])}function WR(r,e){const t=Ze(r.firestore,Kt),n=$v(r),i=Bc(r.converter,e);return so(t,[Dc(Ai(r.firestore),"addDoc",n._key,i,r.converter!==null,{}).toMutation(n._key,de.exists(!1))]).then(()=>n)}function so(r,e){return function(n,i){const s=new Ye;return n.asyncQueue.enqueueAndForget(async()=>yv(await Lv(n),i,s)),s.promise}(to(r),e)}function tw(r,e,t){const n=t.docs.get(e._key),i=new jc(r);return new qc(r,i,e._key,n,new Un(t.hasPendingWrites,t.fromCache),e.converter)}class nw{constructor(e){let t;this.kind="persistent",e!=null&&e.tabManager?(e.tabManager._initialize(e),t=e.tabManager):(t=sw(),t._initialize(e)),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}function HR(r){return new nw(r)}class rw{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=ui.provider,this._offlineComponentProvider={build:t=>new Np(t,e==null?void 0:e.cacheSizeBytes,this.forceOwnership)}}}class iw{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=ui.provider,this._offlineComponentProvider={build:t=>new kv(t,e==null?void 0:e.cacheSizeBytes)}}}function sw(r){return new rw(void 0)}function QR(){return new iw}/**
3532 * @license
3533 * Copyright 2022 Google LLC
3534 *
3535 * Licensed under the Apache License, Version 2.0 (the "License");
3536 * you may not use this file except in compliance with the License.
3537 * You may obtain a copy of the License at
3538 *
3539 *   http://www.apache.org/licenses/LICENSE-2.0
3540 *
3541 * Unless required by applicable law or agreed to in writing, software
3542 * distributed under the License is distributed on an "AS IS" BASIS,
3543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3544 * See the License for the specific language governing permissions and
3545 * limitations under the License.
3546 */const ow={maxAttempts:5};function Nr(r,e){if((r=re(r)).firestore!==e)throw new k(P.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return r}/**
3547 * @license
3548 * Copyright 2020 Google LLC
3549 *
3550 * Licensed under the Apache License, Version 2.0 (the "License");
3551 * you may not use this file except in compliance with the License.
3552 * You may obtain a copy of the License at
3553 *
3554 *   http://www.apache.org/licenses/LICENSE-2.0
3555 *
3556 * Unless required by applicable law or agreed to in writing, software
3557 * distributed under the License is distributed on an "AS IS" BASIS,
3558 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3559 * See the License for the specific language governing permissions and
3560 * limitations under the License.
3561 *//**
3562 * @license
3563 * Copyright 2020 Google LLC
3564 *
3565 * Licensed under the Apache License, Version 2.0 (the "License");
3566 * you may not use this file except in compliance with the License.
3567 * You may obtain a copy of the License at
3568 *
3569 *   http://www.apache.org/licenses/LICENSE-2.0
3570 *
3571 * Unless required by applicable law or agreed to in writing, software
3572 * distributed under the License is distributed on an "AS IS" BASIS,
3573 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3574 * See the License for the specific language governing permissions and
3575 * limitations under the License.
3576 */class aw extends class{constructor(t,n){this._firestore=t,this._transaction=n,this._dataReader=Ai(t)}get(t){const n=Nr(t,this._firestore),i=new Xv(this._firestore);return this._transaction.lookup([n._key]).then(s=>{if(!s||s.length!==1)return M();const o=s[0];if(o.isFoundDocument())return new Vs(this._firestore,i,o.key,o,n.converter);if(o.isNoDocument())return new Vs(this._firestore,i,n._key,null,n.converter);throw M()})}set(t,n,i){const s=Nr(t,this._firestore),o=Bc(s.converter,n,i),c=Dc(this._dataReader,"Transaction.set",s._key,o,s.converter!==null,i);return this._transaction.set(s._key,c),this}update(t,n,i,...s){const o=Nr(t,this._firestore);let c;return c=typeof(n=re(n))=="string"||n instanceof vi?qp(this._dataReader,"Transaction.update",o._key,n,i,s):Bp(this._dataReader,"Transaction.update",o._key,n),this._transaction.update(o._key,c),this}delete(t){const n=Nr(t,this._firestore);return this._transaction.delete(n._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=Nr(e,this._firestore),n=new jc(this._firestore);return super.get(e).then(i=>new qc(this._firestore,n,t._key,i._document,new Un(!1,!1),t.converter))}}function YR(r,e,t){r=Ze(r,Kt);const n=Object.assign(Object.assign({},ow),t);return function(s){if(s.maxAttempts<1)throw new k(P.INVALID_ARGUMENT,"Max attempts must be at least 1")}(n),function(s,o,c){const u=new Ye;return s.asyncQueue.enqueueAndForget(async()=>{const h=await Fv(s);new xv(s.asyncQueue,h,c,o,u).au()}),u.promise}(to(r),i=>e(new aw(r,i)),n)}function XR(){return new Vc("serverTimestamp")}function ZR(r){return new kc("increment",r)}(function(e,t=!0){(function(i){or=i})(wn),Xe(new Ke("firestore",(n,{instanceIdentifier:i,options:s})=>{const o=n.getProvider("app").getImmediate(),c=new Kt(new $I(n.getProvider("auth-internal")),new WI(n.getProvider("app-check-internal")),function(h,f){if(!Object.prototype.hasOwnProperty.apply(h.options,["projectId"]))throw new k(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new dn(h.options.projectId,f)}(o,i),o);return s=Object.assign({useFetchStreams:t},s),c._setSettings(s),c},"PUBLIC").setMultipleInstances(!0)),Le(Sl,"4.7.3",e),Le(Sl,"4.7.3","esm2017")})();var cw="firebase",uw="10.14.1";/**
3577 * @license
3578 * Copyright 2020 Google LLC
3579 *
3580 * Licensed under the Apache License, Version 2.0 (the "License");
3581 * you may not use this file except in compliance with the License.
3582 * You may obtain a copy of the License at
3583 *
3584 *   http://www.apache.org/licenses/LICENSE-2.0
3585 *
3586 * Unless required by applicable law or agreed to in writing, software
3587 * distributed under the License is distributed on an "AS IS" BASIS,
3588 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3589 * See the License for the specific language governing permissions and
3590 * limitations under the License.
3591 */Le(cw,uw,"app");/**
3592 * @license
3593 * Copyright 2017 Google LLC
3594 *
3595 * Licensed under the Apache License, Version 2.0 (the "License");
3596 * you may not use this file except in compliance with the License.
3597 * You may obtain a copy of the License at
3598 *
3599 *   http://www.apache.org/licenses/LICENSE-2.0
3600 *
3601 * Unless required by applicable law or agreed to in writing, software
3602 * distributed under the License is distributed on an "AS IS" BASIS,
3603 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3604 * See the License for the specific language governing permissions and
3605 * limitations under the License.
3606 */const Wp="firebasestorage.googleapis.com",Hp="storageBucket",lw=2*60*1e3,hw=10*60*1e3;/**
3607 * @license
3608 * Copyright 2017 Google LLC
3609 *
3610 * Licensed under the Apache License, Version 2.0 (the "License");
3611 * you may not use this file except in compliance with the License.
3612 * You may obtain a copy of the License at
3613 *
3614 *   http://www.apache.org/licenses/LICENSE-2.0
3615 *
3616 * Unless required by applicable law or agreed to in writing, software
3617 * distributed under the License is distributed on an "AS IS" BASIS,
3618 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3619 * See the License for the specific language governing permissions and
3620 * limitations under the License.
3621 */class we extends He{constructor(e,t,n=0){super(Ko(e),`Firebase Storage: ${t} (${Ko(e)})`),this.status_=n,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,we.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Ko(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
3622${this.customData.serverResponse}`:this.message=this._baseMessage}}var ve;(function(r){r.UNKNOWN="unknown",r.OBJECT_NOT_FOUND="object-not-found",r.BUCKET_NOT_FOUND="bucket-not-found",r.PROJECT_NOT_FOUND="project-not-found",r.QUOTA_EXCEEDED="quota-exceeded",r.UNAUTHENTICATED="unauthenticated",r.UNAUTHORIZED="unauthorized",r.UNAUTHORIZED_APP="unauthorized-app",r.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",r.INVALID_CHECKSUM="invalid-checksum",r.CANCELED="canceled",r.INVALID_EVENT_NAME="invalid-event-name",r.INVALID_URL="invalid-url",r.INVALID_DEFAULT_BUCKET="invalid-default-bucket",r.NO_DEFAULT_BUCKET="no-default-bucket",r.CANNOT_SLICE_BLOB="cannot-slice-blob",r.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",r.NO_DOWNLOAD_URL="no-download-url",r.INVALID_ARGUMENT="invalid-argument",r.INVALID_ARGUMENT_COUNT="invalid-argument-count",r.APP_DELETED="app-deleted",r.INVALID_ROOT_OPERATION="invalid-root-operation",r.INVALID_FORMAT="invalid-format",r.INTERNAL_ERROR="internal-error",r.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(ve||(ve={}));function Ko(r){return"storage/"+r}function dw(){const r="An unknown error occurred, please check the error payload for server response.";return new we(ve.UNKNOWN,r)}function fw(r){return new we(ve.OBJECT_NOT_FOUND,"Object '"+r+"' does not exist.")}function pw(r){return new we(ve.QUOTA_EXCEEDED,"Quota for bucket '"+r+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function mw(){const r="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new we(ve.UNAUTHENTICATED,r)}function gw(){return new we(ve.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function _w(r){return new we(ve.UNAUTHORIZED,"User does not have permission to access '"+r+"'.")}function yw(){return new we(ve.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function Iw(){return new we(ve.CANCELED,"User canceled the upload/download.")}function Tw(r){return new we(ve.INVALID_URL,"Invalid URL '"+r+"'.")}function Ew(r){return new we(ve.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+r+"'.")}function vw(){return new we(ve.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Hp+"' property when initializing the app?")}function Pa(r){return new we(ve.INVALID_ARGUMENT,r)}function Qp(){return new we(ve.APP_DELETED,"The Firebase app was deleted.")}function ww(r){return new we(ve.INVALID_ROOT_OPERATION,"The operation '"+r+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function xr(r){throw new we(ve.INTERNAL_ERROR,"Internal error: "+r)}/**
3623 * @license
3624 * Copyright 2017 Google LLC
3625 *
3626 * Licensed under the Apache License, Version 2.0 (the "License");
3627 * you may not use this file except in compliance with the License.
3628 * You may obtain a copy of the License at
3629 *
3630 *   http://www.apache.org/licenses/LICENSE-2.0
3631 *
3632 * Unless required by applicable law or agreed to in writing, software
3633 * distributed under the License is distributed on an "AS IS" BASIS,
3634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3635 * See the License for the specific language governing permissions and
3636 * limitations under the License.
3637 */class Ge{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let n;try{n=Ge.makeFromUrl(e,t)}catch{return new Ge(e,"")}if(n.path==="")return n;throw Ew(e)}static makeFromUrl(e,t){let n=null;const i="([A-Za-z0-9.\\-_]+)";function s($){$.path.charAt($.path.length-1)==="/"&&($.path_=$.path_.slice(0,-1))}const o="(/(.*))?$",c=new RegExp("^gs://"+i+o,"i"),u={bucket:1,path:3};function h($){$.path_=decodeURIComponent($.path)}const f="v[A-Za-z0-9_]+",m=t.replace(/[.]/g,"\\."),_="(/([^?#]*).*)?$",b=new RegExp(`^https?://${m}/${f}/b/${i}/o${_}`,"i"),V={bucket:1,path:3},N=t===Wp?"(?:storage.googleapis.com|storage.cloud.google.com)":t,D="([^?#]*)",z=new RegExp(`^https?://${N}/${i}/${D}`,"i"),U=[{regex:c,indices:u,postModify:s},{regex:b,indices:V,postModify:h},{regex:z,indices:{bucket:1,path:2},postModify:h}];for(let $=0;$<U.length;$++){const J=U[$],K=J.regex.exec(e);if(K){const T=K[J.indices.bucket];let g=K[J.indices.path];g||(g=""),n=new Ge(T,g),J.postModify(n);break}}if(n==null)throw Tw(e);return n}}class Aw{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/**
3638 * @license
3639 * Copyright 2017 Google LLC
3640 *
3641 * Licensed under the Apache License, Version 2.0 (the "License");
3642 * you may not use this file except in compliance with the License.
3643 * You may obtain a copy of the License at
3644 *
3645 *   http://www.apache.org/licenses/LICENSE-2.0
3646 *
3647 * Unless required by applicable law or agreed to in writing, software
3648 * distributed under the License is distributed on an "AS IS" BASIS,
3649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3650 * See the License for the specific language governing permissions and
3651 * limitations under the License.
3652 */function Rw(r,e,t){let n=1,i=null,s=null,o=!1,c=0;function u(){return c===2}let h=!1;function f(...D){h||(h=!0,e.apply(null,D))}function m(D){i=setTimeout(()=>{i=null,r(b,u())},D)}function _(){s&&clearTimeout(s)}function b(D,...z){if(h){_();return}if(D){_(),f.call(null,D,...z);return}if(u()||o){_(),f.call(null,D,...z);return}n<64&&(n*=2);let U;c===1?(c=2,U=0):U=(n+Math.random())*1e3,m(U)}let V=!1;function N(D){V||(V=!0,_(),!h&&(i!==null?(D||(c=2),clearTimeout(i),m(0)):D||(c=1)))}return m(0),s=setTimeout(()=>{o=!0,N(!0)},t),N}function bw(r){r(!1)}/**
3653 * @license
3654 * Copyright 2017 Google LLC
3655 *
3656 * Licensed under the Apache License, Version 2.0 (the "License");
3657 * you may not use this file except in compliance with the License.
3658 * You may obtain a copy of the License at
3659 *
3660 *   http://www.apache.org/licenses/LICENSE-2.0
3661 *
3662 * Unless required by applicable law or agreed to in writing, software
3663 * distributed under the License is distributed on an "AS IS" BASIS,
3664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3665 * See the License for the specific language governing permissions and
3666 * limitations under the License.
3667 */function Sw(r){return r!==void 0}function Oh(r,e,t,n){if(n<e)throw Pa(`Invalid value for '${r}'. Expected ${e} or greater.`);if(n>t)throw Pa(`Invalid value for '${r}'. Expected ${t} or less.`)}/**
3668 * @license
3669 * Copyright 2017 Google LLC
3670 *
3671 * Licensed under the Apache License, Version 2.0 (the "License");
3672 * you may not use this file except in compliance with the License.
3673 * You may obtain a copy of the License at
3674 *
3675 *   http://www.apache.org/licenses/LICENSE-2.0
3676 *
3677 * Unless required by applicable law or agreed to in writing, software
3678 * distributed under the License is distributed on an "AS IS" BASIS,
3679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3680 * See the License for the specific language governing permissions and
3681 * limitations under the License.
3682 */function Pw(r,e,t){let n=e;return t==null&&(n=`https://${e}`),`${t}://${n}/v0${r}`}function Cw(r){const e=encodeURIComponent;let t="?";for(const n in r)if(r.hasOwnProperty(n)){const i=e(n)+"="+e(r[n]);t=t+i+"&"}return t=t.slice(0,-1),t}var cn;(function(r){r[r.NO_ERROR=0]="NO_ERROR",r[r.NETWORK_ERROR=1]="NETWORK_ERROR",r[r.ABORT=2]="ABORT"})(cn||(cn={}));/**
3683 * @license
3684 * Copyright 2022 Google LLC
3685 *
3686 * Licensed under the Apache License, Version 2.0 (the "License");
3687 * you may not use this file except in compliance with the License.
3688 * You may obtain a copy of the License at
3689 *
3690 *   http://www.apache.org/licenses/LICENSE-2.0
3691 *
3692 * Unless required by applicable law or agreed to in writing, software
3693 * distributed under the License is distributed on an "AS IS" BASIS,
3694 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3695 * See the License for the specific language governing permissions and
3696 * limitations under the License.
3697 */function Dw(r,e){const t=r>=500&&r<600,i=[408,429].indexOf(r)!==-1,s=e.indexOf(r)!==-1;return t||i||s}/**
3698 * @license
3699 * Copyright 2017 Google LLC
3700 *
3701 * Licensed under the Apache License, Version 2.0 (the "License");
3702 * you may not use this file except in compliance with the License.
3703 * You may obtain a copy of the License at
3704 *
3705 *   http://www.apache.org/licenses/LICENSE-2.0
3706 *
3707 * Unless required by applicable law or agreed to in writing, software
3708 * distributed under the License is distributed on an "AS IS" BASIS,
3709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3710 * See the License for the specific language governing permissions and
3711 * limitations under the License.
3712 */class Vw{constructor(e,t,n,i,s,o,c,u,h,f,m,_=!0){this.url_=e,this.method_=t,this.headers_=n,this.body_=i,this.successCodes_=s,this.additionalRetryCodes_=o,this.callback_=c,this.errorCallback_=u,this.timeout_=h,this.progressCallback_=f,this.connectionFactory_=m,this.retry=_,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((b,V)=>{this.resolve_=b,this.reject_=V,this.start_()})}start_(){const e=(n,i)=>{if(i){n(!1,new Xi(!1,null,!0));return}const s=this.connectionFactory_();this.pendingConnection_=s;const o=c=>{const u=c.loaded,h=c.lengthComputable?c.total:-1;this.progressCallback_!==null&&this.progressCallback_(u,h)};this.progressCallback_!==null&&s.addUploadProgressListener(o),s.send(this.url_,this.method_,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&s.removeUploadProgressListener(o),this.pendingConnection_=null;const c=s.getErrorCode()===cn.NO_ERROR,u=s.getStatus();if(!c||Dw(u,this.additionalRetryCodes_)&&this.retry){const f=s.getErrorCode()===cn.ABORT;n(!1,new Xi(!1,null,f));return}const h=this.successCodes_.indexOf(u)!==-1;n(!0,new Xi(h,s))})},t=(n,i)=>{const s=this.resolve_,o=this.reject_,c=i.connection;if(i.wasSuccessCode)try{const u=this.callback_(c,c.getResponse());Sw(u)?s(u):s()}catch(u){o(u)}else if(c!==null){const u=dw();u.serverResponse=c.getErrorText(),this.errorCallback_?o(this.errorCallback_(c,u)):o(u)}else if(i.canceled){const u=this.appDelete_?Qp():Iw();o(u)}else{const u=yw();o(u)}};this.canceled_?t(!1,new Xi(!1,null,!0)):this.backoffId_=Rw(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&bw(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class Xi{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}}function kw(r,e){e!==null&&e.length>0&&(r.Authorization="Firebase "+e)}function Nw(r,e){r["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function xw(r,e){e&&(r["X-Firebase-GMPID"]=e)}function Ow(r,e){e!==null&&(r["X-Firebase-AppCheck"]=e)}
3712function Mw(r,e,t,n,i,s,o=!0){const c=Cw(r.urlParams),u=r.url+c,h=Object.assign({},r.headers);return xw(h,e),kw(h,t),Nw(h,s),Ow(h,n),new Vw(u,r.method,h,r.body,r.successCodes,r.additionalRetryCodes,r.handler,r.errorHandler,r.timeout,r.progressCallback,i,o)}/**
3713 * @license
3714 * Copyright 2017 Google LLC
3715 *
3716 * Licensed under the Apache License, Version 2.0 (the "License");
3717 * you may not use this file except in compliance with the License.
3718 * You may obtain a copy of the License at
3719 *
3720 *   http://www.apache.org/licenses/LICENSE-2.0
3721 *
3722 * Unless required by applicable law or agreed to in writing, software
3723 * distributed under the License is distributed on an "AS IS" BASIS,
3724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3725 * See the License for the specific language governing permissions and
3726 * limitations under the License.
3727 */function Lw(r){if(r.length===0)return null;const e=r.lastIndexOf("/");return e===-1?"":r.slice(0,e)}function Fw(r,e){const t=e.split("/").filter(n=>n.length>0).join("/");return r.length===0?t:r+"/"+t}function Uw(r){const e=r.lastIndexOf("/",r.length-2);return e===-1?r:r.slice(e+1)}class Bw{constructor(e,t,n,i){this.url=e,this.method=t,this.handler=n,this.timeout=i,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function qw(r){function e(t,n){let i;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?i=gw():i=mw():t.getStatus()===402?i=pw(r.bucket):t.getStatus()===403?i=_w(r.path):i=n,i.status=t.getStatus(),i.serverResponse=n.serverResponse,i}return e}function jw(r){const e=qw(r);function t(n,i){let s=e(n,i);return n.getStatus()===404&&(s=fw(r.path)),s.serverResponse=i.serverResponse,s}return t}function $w(r,e){const t=e.fullServerUrl(),n=Pw(t,r.host,r._protocol),i="DELETE",s=r.maxOperationRetryTime;function o(u,h){}const c=new Bw(n,i,o,s);return c.successCodes=[200,204],c.errorHandler=jw(e),c}class zw{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=cn.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=cn.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=cn.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,n,i){if(this.sent_)throw xr("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(const s in i)i.hasOwnProperty(s)&&this.xhr_.setRequestHeader(s,i[s].toString());return n!==void 0?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw xr("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw xr("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw xr("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw xr("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class Gw extends zw{initXhr(){this.xhr_.responseType="text"}}function Kw(){return new Gw}/**
3728 * @license
3729 * Copyright 2019 Google LLC
3730 *
3731 * Licensed under the Apache License, Version 2.0 (the "License");
3732 * you may not use this file except in compliance with the License.
3733 * You may obtain a copy of the License at
3734 *
3735 *   http://www.apache.org/licenses/LICENSE-2.0
3736 *
3737 * Unless required by applicable law or agreed to in writing, software
3738 * distributed under the License is distributed on an "AS IS" BASIS,
3739 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3740 * See the License for the specific language governing permissions and
3741 * limitations under the License.
3742 */class In{constructor(e,t){this._service=e,t instanceof Ge?this._location=t:this._location=Ge.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new In(e,t)}get root(){const e=new Ge(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return Uw(this._location.path)}get storage(){return this._service}get parent(){const e=Lw(this._location.path);if(e===null)return null;const t=new Ge(this._location.bucket,e);return new In(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw ww(e)}}function Ww(r){r._throwIfRoot("deleteObject");const e=$w(r.storage,r._location);return r.storage.makeRequestWithTokens(e,Kw)}function Hw(r,e){const t=Fw(r._location.path,e),n=new Ge(r._location.bucket,t);return new In(r.storage,n)}/**
3743 * @license
3744 * Copyright 2017 Google LLC
3745 *
3746 * Licensed under the Apache License, Version 2.0 (the "License");
3747 * you may not use this file except in compliance with the License.
3748 * You may obtain a copy of the License at
3749 *
3750 *   http://www.apache.org/licenses/LICENSE-2.0
3751 *
3752 * Unless required by applicable law or agreed to in writing, software
3753 * distributed under the License is distributed on an "AS IS" BASIS,
3754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3755 * See the License for the specific language governing permissions and
3756 * limitations under the License.
3757 */function Qw(r){return/^[A-Za-z]+:\/\//.test(r)}function Jw(r,e){return new In(r,e)}function Jp(r,e){if(r instanceof $c){const t=r;if(t._bucket==null)throw vw();const n=new In(t,t._bucket);return e!=null?Jp(n,e):n}else return e!==void 0?Hw(r,e):r}function Yw(r,e){if(e&&Qw(e)){if(r instanceof $c)return Jw(r,e);throw Pa("To use ref(service, url), the first argument must be a Storage instance.")}else return Jp(r,e)}function Mh(r,e){const t=e==null?void 0:e[Hp];return t==null?null:Ge.makeFromBucketSpec(t,r)}function Xw(r,e,t,n={}){r.host=`${e}:${t}`,r._protocol="http";const{mockUserToken:i}=n;i&&(r._overrideAuthToken=typeof i=="string"?i:lg(i,r.app.options.projectId))}class $c{constructor(e,t,n,i,s){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=i,this._firebaseVersion=s,this._bucket=null,this._host=Wp,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=lw,this._maxUploadRetryTime=hw,this._requests=new Set,i!=null?this._bucket=Ge.makeFromBucketSpec(i,this._host):this._bucket=Mh(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Ge.makeFromBucketSpec(this._url,e):this._bucket=Mh(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){Oh("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){Oh("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new In(this,e)}_makeRequest(e,t,n,i,s=!0){if(this._deleted)return new Aw(Qp());{const o=Mw(e,this._appId,n,i,t,this._firebaseVersion,s);return this._requests.add(o),o.getPromise().then(()=>this._requests.delete(o),()=>this._requests.delete(o)),o}}async makeRequestWithTokens(e,t){const[n,i]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,n,i).getPromise()}}const Lh="@firebase/storage",Fh="0.13.2";/**
3758 * @license
3759 * Copyright 2020 Google LLC
3760 *
3761 * Licensed under the Apache License, Version 2.0 (the "License");
3762 * you may not use this file except in compliance with the License.
3763 * You may obtain a copy of the License at
3764 *
3765 *   http://www.apache.org/licenses/LICENSE-2.0
3766 *
3767 * Unless required by applicable law or agreed to in writing, software
3768 * distributed under the License is distributed on an "AS IS" BASIS,
3769 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3770 * See the License for the specific language governing permissions and
3771 * limitations under the License.
3772 */const Yp="storage";function eb(r){return r=re(r),Ww(r)}function tb(r,e){return r=re(r),Yw(r,e)}function nb(r=Na(),e){r=re(r);const n=Ut(r,Yp).getImmediate({identifier:e}),i=cg("storage");return i&&Zw(n,...i),n}function Zw(r,e,t,n={}){Xw(r,e,t,n)}function eA(r,{instanceIdentifier:e}){const t=r.getProvider("app").getImmediate(),n=r.getProvider("auth-internal"),i=r.getProvider("app-check-internal");return new $c(t,n,i,e,wn)}function tA(){Xe(new Ke(Yp,eA,"PUBLIC").setMultipleInstances(!0)),Le(Lh,Fh,""),Le(Lh,Fh,"esm2017")}tA();const Xp="@firebase/installations",zc="0.6.9";/**
3773 * @license
3774 * Copyright 2019 Google LLC
3775 *
3776 * Licensed under the Apache License, Version 2.0 (the "License");
3777 * you may not use this file except in compliance with the License.
3778 * You may obtain a copy of the License at
3779 *
3780 *   http://www.apache.org/licenses/LICENSE-2.0
3781 *
3782 * Unless required by applicable law or agreed to in writing, software
3783 * distributed under the License is distributed on an "AS IS" BASIS,
3784 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3785 * See the License for the specific language governing permissions and
3786 * limitations under the License.
3787 */const Zp=1e4,em=`w:${zc}`,tm="FIS_v2",nA="https://firebaseinstallations.googleapis.com/v1",rA=60*60*1e3,iA="installations",sA="Installations";/**
3788 * @license
3789 * Copyright 2019 Google LLC
3790 *
3791 * Licensed under the Apache License, Version 2.0 (the "License");
3792 * you may not use this file except in compliance with the License.
3793 * You may obtain a copy of the License at
3794 *
3795 *   http://www.apache.org/licenses/LICENSE-2.0
3796 *
3797 * Unless required by applicable law or agreed to in writing, software
3798 * distributed under the License is distributed on an "AS IS" BASIS,
3799 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3800 * See the License for the specific language governing permissions and
3801 * limitations under the License.
3802 */const oA={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."},Tn=new vn(iA,sA,oA);function nm(r){return r instanceof He&&r.code.includes("request-failed")}/**
3803 * @license
3804 * Copyright 2019 Google LLC
3805 *
3806 * Licensed under the Apache License, Version 2.0 (the "License");
3807 * you may not use this file except in compliance with the License.
3808 * You may obtain a copy of the License at
3809 *
3810 *   http://www.apache.org/licenses/LICENSE-2.0
3811 *
3812 * Unless required by applicable law or agreed to in writing, software
3813 * distributed under the License is distributed on an "AS IS" BASIS,
3814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3815 * See the License for the specific language governing permissions and
3816 * limitations under the License.
3817 */function rm({projectId:r}){return`${nA}/projects/${r}/installations`}function im(r){return{token:r.token,requestStatus:2,expiresIn:cA(r.expiresIn),creationTime:Date.now()}}async function sm(r,e){const n=(await e.json()).error;return Tn.create("request-failed",{requestName:r,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function om({apiKey:r}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":r})}function aA(r,{refreshToken:e}){const t=om(r);return t.append("Authorization",uA(e)),t}async function am(r){const e=await r();return e.status>=500&&e.status<600?r():e}function cA(r){return Number(r.replace("s","000"))}function uA(r){return`${tm} ${r}`}/**
3818 * @license
3819 * Copyright 2019 Google LLC
3820 *
3821 * Licensed under the Apache License, Version 2.0 (the "License");
3822 * you may not use this file except in compliance with the License.
3823 * You may obtain a copy of the License at
3824 *
3825 *   http://www.apache.org/licenses/LICENSE-2.0
3826 *
3827 * Unless required by applicable law or agreed to in writing, software
3828 * distributed under the License is distributed on an "AS IS" BASIS,
3829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3830 * See the License for the specific language governing permissions and
3831 * limitations under the License.
3832 */async function lA({appConfig:r,heartbeatServiceProvider:e},{fid:t}){const n=rm(r),i=om(r),s=e.getImmediate({optional:!0});if(s){const h=await s.getHeartbeatsHeader();h&&i.append("x-firebase-client",h)}const o={fid:t,authVersion:tm,appId:r.appId,sdkVersion:em},c={method:"POST",headers:i,body:JSON.stringify(o)},u=await am(()=>fetch(n,c));if(u.ok){const h=await u.json();return{fid:h.fid||t,registrationStatus:2,refreshToken:h.refreshToken,authToken:im(h.authToken)}}else throw await sm("Create Installation",u)}/**
3833 * @license
3834 * Copyright 2019 Google LLC
3835 *
3836 * Licensed under the Apache License, Version 2.0 (the "License");
3837 * you may not use this file except in compliance with the License.
3838 * You may obtain a copy of the License at
3839 *
3840 *   http://www.apache.org/licenses/LICENSE-2.0
3841 *
3842 * Unless required by applicable law or agreed to in writing, software
3843 * distributed under the License is distributed on an "AS IS" BASIS,
3844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3845 * See the License for the specific language governing permissions and
3846 * limitations under the License.
3847 */function cm(r){return new Promise(e=>{setTimeout(e,r)})}/**
3848 * @license
3849 * Copyright 2019 Google LLC
3850 *
3851 * Licensed under the Apache License, Version 2.0 (the "License");
3852 * you may not use this file except in compliance with the License.
3853 * You may obtain a copy of the License at
3854 *
3855 *   http://www.apache.org/licenses/LICENSE-2.0
3856 *
3857 * Unless required by applicable law or agreed to in writing, software
3858 * distributed under the License is distributed on an "AS IS" BASIS,
3859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3860 * See the License for the specific language governing permissions and
3861 * limitations under the License.
3862 */function hA(r){return btoa(String.fromCharCode(...r)).replace(/\+/g,"-").replace(/\//g,"_")}/**
3863 * @license
3864 * Copyright 2019 Google LLC
3865 *
3866 * Licensed under the Apache License, Version 2.0 (the "License");
3867 * you may not use this file except in compliance with the License.
3868 * You may obtain a copy of the License at
3869 *
3870 *   http://www.apache.org/licenses/LICENSE-2.0
3871 *
3872 * Unless required by applicable law or agreed to in writing, software
3873 * distributed under the License is distributed on an "AS IS" BASIS,
3874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3875 * See the License for the specific language governing permissions and
3876 * limitations under the License.
3877 */const dA=/^[cdef][\w-]{21}$/,Ca="";function fA(){try{const r=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(r),r[0]=112+r[0]%16;const t=pA(r);return dA.test(t)?t:Ca}catch{return Ca}}function pA(r){return hA(r).substr(0,22)}/**
3878 * @license
3879 * Copyright 2019 Google LLC
3880 *
3881 * Licensed under the Apache License, Version 2.0 (the "License");
3882 * you may not use this file except in compliance with the License.
3883 * You may obtain a copy of the License at
3884 *
3885 *   http://www.apache.org/licenses/LICENSE-2.0
3886 *
3887 * Unless required by applicable law or agreed to in writing, software
3888 * distributed under the License is distributed on an "AS IS" BASIS,
3889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3890 * See the License for the specific language governing permissions and
3891 * limitations under the License.
3892 */function oo(r){return`${r.appName}!${r.appId}`}/**
3893 * @license
3894 * Copyright 2019 Google LLC
3895 *
3896 * Licensed under the Apache License, Version 2.0 (the "License");
3897 * you may not use this file except in compliance with the License.
3898 * You may obtain a copy of the License at
3899 *
3900 *   http://www.apache.org/licenses/LICENSE-2.0
3901 *
3902 * Unless required by applicable law or agreed to in writing, software
3903 * distributed under the License is distributed on an "AS IS" BASIS,
3904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3905 * See the License for the specific language governing permissions and
3906 * limitations under the License.
3907 */const um=new Map;function lm(r,e){const t=oo(r);hm(t,e),mA(t,e)}function hm(r,e){const t=um.get(r);if(t)for(const n of t)n(e)}function mA(r,e){const t=gA();t&&t.postMessage({key:r,fid:e}),_A()}let on=null;function gA(){return!on&&"BroadcastChannel"in self&&(on=new BroadcastChannel("[Firebase] FID Change"),on.onmessage=r=>{hm(r.data.key,r.data.fid)}),on}function _A(){um.size===0&&on&&(on.close(),on=null)}/**
3908 * @license
3909 * Copyright 2019 Google LLC
3910 *
3911 * Licensed under the Apache License, Version 2.0 (the "License");
3912 * you may not use this file except in compliance with the License.
3913 * You may obtain a copy of the License at
3914 *
3915 *   http://www.apache.org/licenses/LICENSE-2.0
3916 *
3917 * Unless required by applicable law or agreed to in writing, software
3918 * distributed under the License is distributed on an "AS IS" BASIS,
3919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3920 * See the License for the specific language governing permissions and
3921 * limitations under the License.
3922 */const yA="firebase-installations-database",IA=1,En="firebase-installations-store";let Wo=null;function Gc(){return Wo||(Wo=rd(yA,IA,{upgrade:(r,e)=>{switch(e){case 0:r.createObjectStore(En)}}})),Wo}async function ks(r,e){const t=oo(r),i=(await Gc()).transaction(En,"readwrite"),s=i.objectStore(En),o=await s.get(t);return await s.put(e,t),await i.done,(!o||o.fid!==e.fid)&&lm(r,e.fi
3922d),e}async function dm(r){const e=oo(r),n=(await Gc()).transaction(En,"readwrite");await n.objectStore(En).delete(e),await n.done}async function ao(r,e){const t=oo(r),i=(await Gc()).transaction(En,"readwrite"),s=i.objectStore(En),o=await s.get(t),c=e(o);return c===void 0?await s.delete(t):await s.put(c,t),await i.done,c&&(!o||o.fid!==c.fid)&&lm(r,c.fid),c}/**
3923 * @license
3924 * Copyright 2019 Google LLC
3925 *
3926 * Licensed under the Apache License, Version 2.0 (the "License");
3927 * you may not use this file except in compliance with the License.
3928 * You may obtain a copy of the License at
3929 *
3930 *   http://www.apache.org/licenses/LICENSE-2.0
3931 *
3932 * Unless required by applicable law or agreed to in writing, software
3933 * distributed under the License is distributed on an "AS IS" BASIS,
3934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3935 * See the License for the specific language governing permissions and
3936 * limitations under the License.
3937 */async function Kc(r){let e;const t=await ao(r.appConfig,n=>{const i=TA(n),s=EA(r,i);return e=s.registrationPromise,s.installationEntry});return t.fid===Ca?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function TA(r){const e=r||{fid:fA(),registrationStatus:0};return fm(e)}function EA(r,e){if(e.registrationStatus===0){if(!navigator.onLine){const i=Promise.reject(Tn.create("app-offline"));return{installationEntry:e,registrationPromise:i}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},n=vA(r,t);return{installationEntry:t,registrationPromise:n}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:wA(r)}:{installationEntry:e}}async function vA(r,e){try{const t=await lA(r,e);return ks(r.appConfig,t)}catch(t){throw nm(t)&&t.customData.serverCode===409?await dm(r.appConfig):await ks(r.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function wA(r){let e=await Uh(r.appConfig);for(;e.registrationStatus===1;)await cm(100),e=await Uh(r.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:n}=await Kc(r);return n||t}return e}function Uh(r){return ao(r,e=>{if(!e)throw Tn.create("installation-not-found");return fm(e)})}function fm(r){return AA(r)?{fid:r.fid,registrationStatus:0}:r}function AA(r){return r.registrationStatus===1&&r.registrationTime+Zp<Date.now()}/**
3938 * @license
3939 * Copyright 2019 Google LLC
3940 *
3941 * Licensed under the Apache License, Version 2.0 (the "License");
3942 * you may not use this file except in compliance with the License.
3943 * You may obtain a copy of the License at
3944 *
3945 *   http://www.apache.org/licenses/LICENSE-2.0
3946 *
3947 * Unless required by applicable law or agreed to in writing, software
3948 * distributed under the License is distributed on an "AS IS" BASIS,
3949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3950 * See the License for the specific language governing permissions and
3951 * limitations under the License.
3952 */async function RA({appConfig:r,heartbeatServiceProvider:e},t){const n=bA(r,t),i=aA(r,t),s=e.getImmediate({optional:!0});if(s){const h=await s.getHeartbeatsHeader();h&&i.append("x-firebase-client",h)}const o={installation:{sdkVersion:em,appId:r.appId}},c={method:"POST",headers:i,body:JSON.stringify(o)},u=await am(()=>fetch(n,c));if(u.ok){const h=await u.json();return im(h)}else throw await sm("Generate Auth Token",u)}function bA(r,{fid:e}){return`${rm(r)}/${e}/authTokens:generate`}/**
3953 * @license
3954 * Copyright 2019 Google LLC
3955 *
3956 * Licensed under the Apache License, Version 2.0 (the "License");
3957 * you may not use this file except in compliance with the License.
3958 * You may obtain a copy of the License at
3959 *
3960 *   http://www.apache.org/licenses/LICENSE-2.0
3961 *
3962 * Unless required by applicable law or agreed to in writing, software
3963 * distributed under the License is distributed on an "AS IS" BASIS,
3964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3965 * See the License for the specific language governing permissions and
3966 * limitations under the License.
3967 */async function Wc(r,e=!1){let t;const n=await ao(r.appConfig,s=>{if(!pm(s))throw Tn.create("not-registered");const o=s.authToken;if(!e&&CA(o))return s;if(o.requestStatus===1)return t=SA(r,e),s;{if(!navigator.onLine)throw Tn.create("app-offline");const c=VA(s);return t=PA(r,c),c}});return t?await t:n.authToken}async function SA(r,e){let t=await Bh(r.appConfig);for(;t.authToken.requestStatus===1;)await cm(100),t=await Bh(r.appConfig);const n=t.authToken;return n.requestStatus===0?Wc(r,e):n}function Bh(r){return ao(r,e=>{if(!pm(e))throw Tn.create("not-registered");const t=e.authToken;return kA(t)?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}async function PA(r,e){try{const t=await RA(r,e),n=Object.assign(Object.assign({},e),{authToken:t});return await ks(r.appConfig,n),t}catch(t){if(nm(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await dm(r.appConfig);else{const n=Object.assign(Object.assign({},e),{authToken:{requestStatus:0}});await ks(r.appConfig,n)}throw t}}function pm(r){return r!==void 0&&r.registrationStatus===2}function CA(r){return r.requestStatus===2&&!DA(r)}function DA(r){const e=Date.now();
3967return e<r.creationTime||r.creationTime+r.expiresIn<e+rA}function VA(r){const e={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},r),{authToken:e})}function kA(r){return r.requestStatus===1&&r.requestTime+Zp<Date.now()}/**
3968 * @license
3969 * Copyright 2019 Google LLC
3970 *
3971 * Licensed under the Apache License, Version 2.0 (the "License");
3972 * you may not use this file except in compliance with the License.
3973 * You may obtain a copy of the License at
3974 *
3975 *   http://www.apache.org/licenses/LICENSE-2.0
3976 *
3977 * Unless required by applicable law or agreed to in writing, software
3978 * distributed under the License is distributed on an "AS IS" BASIS,
3979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3980 * See the License for the specific language governing permissions and
3981 * limitations under the License.
3982 */async function NA(r){const e=r,{installationEntry:t,registrationPromise:n}=await Kc(e);return n?n.catch(console.error):Wc(e).catch(console.error),t.fid}/**
3983 * @license
3984 * Copyright 2019 Google LLC
3985 *
3986 * Licensed under the Apache License, Version 2.0 (the "License");
3987 * you may not use this file except in compliance with the License.
3988 * You may obtain a copy of the License at
3989 *
3990 *   http://www.apache.org/licenses/LICENSE-2.0
3991 *
3992 * Unless required by applicable law or agreed to in writing, software
3993 * distributed under the License is distributed on an "AS IS" BASIS,
3994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3995 * See the License for the specific language governing permissions and
3996 * limitations under the License.
3997 */async function xA(r,e=!1){const t=r;return await OA(t),(await Wc(t,e)).token}async function OA(r){const{registrationPromise:e}=await Kc(r);e&&await e}/**
3998 * @license
3999 * Copyright 2019 Google LLC
4000 *
4001 * Licensed under the Apache License, Version 2.0 (the "License");
4002 * you may not use this file except in compliance with the License.
4003 * You may obtain a copy of the License at
4004 *
4005 *   http://www.apache.org/licenses/LICENSE-2.0
4006 *
4007 * Unless required by applicable law or agreed to in writing, software
4008 * distributed under the License is distributed on an "AS IS" BASIS,
4009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4010 * See the License for the specific language governing permissions and
4011 * limitations under the License.
4012 */function MA(r){if(!r||!r.options)throw Ho("App Configuration");if(!r.name)throw Ho("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!r.options[t])throw Ho(t);return{appName:r.name,projectId:r.options.projectId,apiKey:r.options.apiKey,appId:r.options.appId}}function Ho(r){return Tn.create("missing-app-config-values",{valueName:r})}/**
4013 * @license
4014 * Copyright 2020 Google LLC
4015 *
4016 * Licensed under the Apache License, Version 2.0 (the "License");
4017 * you may not use this file except in compliance with the License.
4018 * You may obtain a copy of the License at
4019 *
4020 *   http://www.apache.org/licenses/LICENSE-2.0
4021 *
4022 * Unless required by applicable law or agreed to in writing, software
4023 * distributed under the License is distributed on an "AS IS" BASIS,
4024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4025 * See the License for the specific language governing permissions and
4026 * limitations under the License.
4027 */const mm="installations",LA="installations-internal",FA=r=>{const e=r.getProvider("app").getImmediate(),t=MA(e),n=Ut(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:n,_delete:()=>Promise.resolve()}},UA=r=>{const e=r.getProvider("app").getImmediate(),t=Ut(e,mm).getImmediate();return{getId:()=>NA(t),getToken:i=>xA(t,i)}};function BA(){Xe(new Ke(mm,FA,"PUBLIC")),Xe(new Ke(LA,UA,"PRIVATE"))}BA();Le(Xp,zc);Le(Xp,zc,"esm2017");/**
4028 * @license
4029 * Copyright 2019 Google LLC
4030 *
4031 * Licensed under the Apache License, Version 2.0 (the "License");
4032 * you may not use this file except in compliance with the License.
4033 * You may obtain a copy of the License at
4034 *
4035 *   http://www.apache.org/licenses/LICENSE-2.0
4036 *
4037 * Unless required by applicable law or agreed to in writing, softw
4037are
4038 * distributed under the License is distributed on an "AS IS" BASIS,
4039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4040 * See the License for the specific language governing permissions and
4041 * limitations under the License.
4042 */const Ns="analytics",qA="firebase_id",jA="origin",$A=60*1e3,zA="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Hc="https://www.googletagmanager.com/gtag/js";/**
4043 * @license
4044 * Copyright 2019 Google LLC
4045 *
4046 * Licensed under the Apache License, Version 2.0 (the "License");
4047 * you may not use this file except in compliance with the License.
4048 * You may obtain a copy of the License at
4049 *
4050 *   http://www.apache.org/licenses/LICENSE-2.0
4051 *
4052 * Unless required by applicable law or agreed to in writing, software
4053 * distributed under the License is distributed on an "AS IS" BASIS,
4054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4055 * See the License for the specific language governing permissions and
4056 * limitations under the License.
4057 */const Fe=new Ms("@firebase/analytics");/**
4058 * @license
4059 * Copyright 2019 Google LLC
4060 *
4061 * Licensed under the Apache License, Version 2.0 (the "License");
4062 * you may not use this file except in compliance with the License.
4063 * You may obtain a copy of the License at
4064 *
4065 *   http://www.apache.org/licenses/LICENSE-2.0
4066 *
4067 * Unless required by applicable law or agreed to in writing, software
4068 * distributed under the License is distributed on an "AS IS" BASIS,
4069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4070 * See the License for the specific language governing permissions and
4071 * limitations under the License.
4072 */const GA={"already-exists":"A Firebase Analytics instance with the appId {$id}  already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."},je=new vn("analytics","Analytics",GA);/**
4073 * @license
4074 * Copyright 2019 Google LLC
4075 *
4076 * Licensed under the Apache License, Version 2.0 (the "License");
4077 * you may not use this file except in compliance with the License.
4078 * You may obtain a copy of the License at
4079 *
4080 *   http://www.apache.org/licenses/LICENSE-2.0
4081 *
4082 * Unless required by applicable law or agreed to in writing, software
4083 * distributed under the License is distributed on an "AS IS" BASIS,
4084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4085 * See the License for the specific language governing permissions and
4086 * limitations under the License.
4087 */function KA(r){if(!r.startsWith(Hc)){const e=je.create("invalid-gtag-resource",{gtagURL:r});return Fe.warn(e.message),""}return r}function gm(r){return Promise.all(r.map(e=>e.catch(t=>t)))}function WA(r,e){let t;return window.trustedTypes&&(t=window.trustedTypes.createPolicy(r,e)),t}function HA(r,e){const t=WA("firebase-js-sdk-policy",{createScriptURL:KA}),n=document.createElement("script"),i=`${Hc}?l=${r}&id=${e}`;n.src=t?t==null?void 0:t.createScriptURL(i):i,n.async=!0,document.head.appendChild(n)}function QA(r){let e=[];return Array.isArray(window[r])?e=window[r]:window[r]=e,e}async function JA(r,e,t,n,i,s){const o=n[i];try{if(o)await e[o];else{const u=(await gm(t)).find(h=>h.measurementId===i);u&&await e[u.appId]}}catch(c){Fe.error(c)}r("config",i,s)}async function YA(r,e,t,n,i){try{let s=[];if(i&&i.send_to){let o=i.send_to;Array.isArray(o)||(o=[o]);const c=await gm(t);for(const u of o){const h=c.find(m=>m.measurementId===u),f=h&&e[h.appId];if(f)s.push(f);else{s=[];break}}}s.length===0&&(s=Object.values(e)),await Promise.all(s),r("event",n,i||{})}catch(s){Fe.error(s)}}function XA(r,e,t,n){async function i(s,...o){try{if(s==="event"){const[c,u]=o;await YA(r,e,t,c,u)}else if(s==="config"){const[c,u]=o;await JA(r,e,t,n,c,u)}else if(s==="consent"){const[c,u]=o;r("consent",c,u)}else if(s==="get"){const[c,u,h]=o;r("get",c,u,h)}else if(s==="set"){const[c]=o;r("set",c)}else r(s,...o)}catch(c){Fe.error(c)}}return i}function ZA(r,e,t,n,i){let s=function(...o){window[n].push(arguments)};return window[i]&&typeof window[i]=="function"&&(s=window[i]),window[i]=XA(s,r,e,t),{gtagCore:s,wrappedGtag:window[i]}}function eR(r){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(Hc)&&t.src.includes(r))return t;return null}/**
4088 * @license
4089 * Copyright 2020 Google LLC
4090 *
4091 * Licensed under the Apache License, Version 2.0 (the "License");
4092 * you may not use this file except in compliance with the License.
4093 * You may obtain a copy of the License at
4094 *
4095 *   http://www.apache.org/licenses/LICENSE-2.0
4096 *
4097 * Unless required by applicable law or agreed to in writing, software
4098 * distributed under the License is distributed on an "AS IS" BASIS,
4099 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4100 * See the License for the specific language governing permissions and
4101 * limitations under the License.
4102 */const tR=30,nR=1e3;class rR{constructor(e={},t=nR){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}const _m=new rR;function iR(r){return new Headers({Accept:"application/json","x-goog-api-key":r})}async function sR(r){var e;const{appId:t,apiKey:n}=r,i={method:"GET",headers:iR(n)},s=zA.replace("{app-id}",t),o=await fetch(s,i);if(o.status!==200&&o.status!==304){let c="";try{const u=await o.json();!((e=u.error)===null||e===void 0)&&e.message&&(c=u.error.message)}catch{}throw je.create("config-fetch-failed",{httpStatus:o.status,responseMessage:c})}return o.json()}async function oR(r,e=_m,t){const{appId:n,apiKey:i,measurementId:s}=r.options;if(!n)throw je.create("no-app-id");if(!i){if(s)return{measurementId:s,appId:n};throw je.create("no-api-key")}const o=e.getThrottleMetadata(n)||{backoffCount:0,throttleEndTimeMillis:Date.now()},c=new uR;return setTimeout(async()=>{c.abort()},$A),ym({appId:n,apiKey:i,measurementId:s},o,c,e)}async function ym(r,{throttleEndTimeMillis:e,backoffCount:t},n,i=_m){var s;const{appId:o,measurementId:c}=r;try{await aR(n,e)}catch(u){if(c)return Fe.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${c} provided in the "measurementId" field in the local Firebase config. [${u==null?void 0:u.message}]`),{appId:o,measurementId:c};throw u}try{const u=await sR(r);return i.deleteThrottleMetadata(o),u}catch(u){const h=u;if(!cR(h)){if(i.deleteThrottleMetadata(o),c)return Fe.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${c} provided in the "measurementId" field in the local Firebase config. [${h==null?void 0:h.message}]`),{appId:o,measurementId:c};throw u}const f=Number((s=h==null?void 0:h.customData)===null||s===void 0?void 0:s.httpStatus)===503?Yu(t,i.intervalMillis,tR):Yu(t,i.intervalMillis),m={throttleEndTimeMillis:Date.now()+f,backoffCount:t+1};return i.setThrottleMetadata(o,m),Fe.debug(`Calling attemptFetch again in ${f} millis`),ym(r,m,n,i)}}function aR(r,e){return new Promise((t,n)=>{const i=Math.max(e-Date.now(),0),s=setTimeout(t,i);r.addEventListener(()=>{clearTimeout(s),n(je.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function cR(r){if(!(r instanceof He)||!r.customData)return!1;const e=Number(r.customData.httpStatus);return e===429||e===500||e===503||e===504}class uR{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function lR(r,e,t,n,i){if(i&&i.global){r("event",t,n);return}else{const s=await e,o=Object.assign(Object.assign({},n),{send_to:s});r("event",t,o)}}/**
4103 * @license
4104 * Copyright 2020 Google LLC
4105 *
4106 * Licensed under the Apache License, Version 2.0 (the "License");
4107 * you may not use this file except in compliance with the License.
4108 * You may obtain a copy of the License at
4109 *
4110 *   http://www.apache.org/licenses/LICENSE-2.0
4111 *
4112 * Unless required by applicable law or agreed to in writing, software
4113 * distributed under the License is distributed on an "AS IS" BASIS,
4114 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4115 * See the License for the specific language governing permissions and
4116 * limitations under the License.
4117 */async function hR(){if(Os())try{await Va()}catch(r){return Fe.warn(je.create("indexeddb-unavailable",{errorInfo:r==null?void 0:r.toString()}).message),!1}else return Fe.warn(je.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function dR(r,e,t,n,i,s,o){var c;const u=oR(r);u.then(b=>{t[b.measurementId]=b.appId,r.options.measurementId&&b.measurementId!==r.options.measurementId&&Fe.warn(`The measurement ID in the local Firebase config (${r.options.measurementId}) does not match the measurement ID fetched from the server (${b.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(b=>Fe.error(b)),e.push(u);const h=hR().then(b=>{if(b)return n.getId()}),[f,m]=await Promise.all([u,h]);eR(s)||HA(s,f.measurementId),i("js",new Date);const _=(c=o==null?void 0:o.config)!==null&&c!==void 0?c:{};return _[jA]="firebase",_.update=!0,m!=null&&(_[qA]=m),i("config",f.measurementId,_),f.measurementId}/**
4118 * @license
4119 * Copyright 2019 Google LLC
4120 *
4121 * Licensed under the Apache License, Version 2.0 (the "License");
4122 * you may not use this file except in compliance with the License.
4123 * You may obtain a copy of the License at
4124 *
4125 *   http://www.apache.org/licenses/LICENSE-2.0
4126 *
4127 * Unless required by applicable law or agreed to in writing, software
4128 * distributed under the License is distributed on an "AS IS" BASIS,
4129 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4130 * See the License for the specific language governing permissions and
4131 * limitations under the License.
4132 */class fR{constructor(e){this.app=e}_delete(){return delete Hr[this.app.options.appId],Promise.resolve()}}let Hr={},qh=[];const jh={};let Qo="dataLayer",pR="gtag",$h,Im,zh=!1;function mR(){const r=[];if(Da()&&r.push("This is a browser extension environment."),ed()||r.push("Cookies are not available."),r.length>0){const e=r.map((n,i)=>`(${i+1}) ${n}`).join(" "),t=je.create("invalid-analytics-context",{errorInfo:e});Fe.warn(t.message)}}function gR(r,e,t){mR();const n=r.options.appId;if(!n)throw je.create("no-app-id");if(!r.options.apiKey)if(r.options.measurementId)Fe.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${r.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw je.create("no-api-key");if(Hr[n]!=null)throw je.create("already-exists",{id:n});if(!zh){QA(Qo);const{wrappedGtag:s,gtagCore:o}=ZA(Hr,qh,jh,Qo,pR);Im=s,$h=o,zh=!0}return Hr[n]=dR(r,qh,jh,e,$h,Qo,t),new fR(r)}function rb(r=Na()){r=re(r);const e=Ut(r,Ns);return e.isInitialized()?e.getImmediate():_R(r)}function _R(r,e={}){const t=Ut(r,Ns);if(t.isInitialized()){const i=t.getImmediate();if(zn(e,t.getOptions()))return i;throw je.create("already-initialized")}return t.initialize({options:e})}async function ib(){if(Da()||!ed()||!Os())return!1;try{return await Va()}catch{return!1}}function yR(r,e,t,n){r=re(r),lR(Im,Hr[r.app.options.appId],e,t,n).catch(i=>Fe.error(i))}const Gh="@firebase/analytics",Kh="0.10.8";function IR(){Xe(new Ke(Ns,(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),i=e.getProvider("installations-internal").getImmediate();return gR(n,i,t)},"PUBLIC")),Xe(new Ke("analytics-internal",r,"PRIVATE")),Le(Gh,Kh),Le(Gh,Kh,"esm2017");function r(e){try{const t=e.getProvider(Ns).getImmediate();return{logEvent:(n,i,s)=>yR(t,n,i,s)}}catch(t){throw je.create("interop-component-reg-failed",{reason:t})}}}IR();export{$R as A,tb as B,eb as C,KR as D,BR as E,qR as F,St as G,xa as H,ER as I,WR as J,YR as K,ZR as L,TR as M,MR as S,ue as T,ol as _,nb as a,LR as b,xy as c,ib as d,rb as e,QR as f,VR as g,DR as h,A_ as i,PR as j,CR as k,$v as l,jR as m,zR as n,wR as o,HR as p,vR as q,SR as r,RR as s,bR as t,AR as u,GR as v,XR as w,FR as x,OR as y,UR as z};
4133//# sourceMappingURL=firebase-CMvjtFvi.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.