PageSourceSearch

https://www.itweb.co.za/_nuxt/BpbiSsEN.js

js itweb.co.za collected 2026-09-24 08:26:38 UTC 350,298 bytes, 2,060 lines download raw bytes

1const vl=()=>{};var Mo={};/**
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 Ha=function(n){const t=[];let e=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128)}return t},Il=function(n){const t=[];let e=0,r=0;for(;e<n.length;){const s=n[e++];if(s<128)t[r++]=String.fromCharCode(s);else if(s>191&&s<224){const o=n[e++];t[r++]=String.fromCharCode((s&31)<<6|o&63)}else if(s>239&&s<365){const o=n[e++],a=n[e++],l=n[e++],h=((s&7)<<18|(o&63)<<12|(a&63)<<6|l&63)-65536;t[r++]=String.fromCharCode(55296+(h>>10)),t[r++]=String.fromCharCode(56320+(h&1023))}else{const o=n[e++],a=n[e++];t[r++]=String.fromCharCode((s&15)<<12|(o&63)<<6|a&63)}}return t.join("")},Ka={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(n,t){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const e=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){const o=n[s],a=s+1<n.length,l=a?n[s+1]:0,h=s+2<n.length,f=h?n[s+2]:0,m=o>>2,E=(o&3)<<4|l>>4;let T=(l&15)<<2|f>>6,P=f&63;h||(P=64,a||(T=64)),r.push(e[m],e[E],e[T],e[P])}return r.join("")},encodeString(n,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(n):this.encodeByteArray(Ha(n),t)},decodeString(n,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(n):Il(this.decodeStringToByteArray(n,t))},decodeStringToByteArray(n,t){this.init_();const e=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const o=e[n.charAt(s++)],l=s<n.length?e[n.charAt(s)]:0;++s;const f=s<n.length?e[n.charAt(s)]:64;++s;const E=s<n.length?e[n.charAt(s)]:64;if(++s,o==null||l==null||f==null||E==null)throw new Al;const T=o<<2|l>>4;if(r.push(T),f!==64){const P=l<<4&240|f>>2;if(r.push(P),E!==64){const b=f<<6&192|E;
16r.push(b)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class Al extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const wl=function(n){const t=Ha(n);return Ka.encodeByteArray(t,!0)},pr=function(n){return wl(n).replace(/\./g,"")},Rl=function(n){try{return Ka.decodeString(n,!0)}catch(t){console.error("base64Decode failed: ",t)}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 Sl(){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 Cl=()=>Sl().__FIREBASE_DEFAULTS__,Pl=()=>{if(typeof process>"u"||typeof Mo>"u")return;const n=Mo.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},Vl=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const t=n&&Rl(n[1]);return t&&JSON.parse(t)},Vr=()=>{try{return vl()||Cl()||Pl()||Vl()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},bl=n=>{var t,e;return(e=(t=Vr())==null?void 0:t.emulatorHosts)==null?void 0:e[n]},Dl=n=>{const t=bl(n);if(!t)return;const e=t.lastIndexOf(":");if(e<=0||e+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const r=parseInt(t.substring(e+1),10);return t[0]==="["?[t.substring(1,e-1),r]:[t.substring(0,e),r]},Qa=()=>{var n;return(n=Vr())==null?void 0:n.config},Ap=n=>{var t;return(t=Vr())==null?void 0:t[`_${n}`]};/**
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 Nl{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}wrapCallback(t){return(e,r)=>{e?this.reject(e):this.resolve(r),typeof t=="function"&&(this.promise.catch(()=>{}),t.length===1?t(e):t(e,r))}}}/**
62 * @license
63 * Copyright 2025 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 ni(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function kl(n){return(await fetch(n,{credentials:"include"})).ok}/**
77 * @license
78 * Copyright 2021 Google LLC
79 *
80 * Licensed under the Apache License, Version 2.0 (the "License");
81 * you may not use this file except in compliance with the License.
82 * You may obtain a copy of the License at
83 *
84 *   http://www.apache.org/licenses/LICENSE-2.0
85 *
86 * Unless required by applicable law or agreed to in writing, software
87 * distributed under the License is distributed on an "AS IS" BASIS,
88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89 * See the License for the specific language governing permissions and
90 * limitations under the License.
91 */function Ol(n,t){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const e={alg:"none",type:"JWT"},r=t||"demo-project",s=n.iat||0,o=n.sub||n.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a={iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}},...n};return[pr(JSON.stringify(e)),pr(JSON.stringify(a)),""].join(".")}const fn={};function Ml(){const n={prod:[],emulator:[]};for(const t of Object.keys(fn))fn[t]?n.emulator.push(t):n.prod.push(t);return n}function xl(n){let t=document.getElementById(n),e=!1;return t||(t=document.createElement("div"),t.setAttribute("id",n),e=!0),{created:e,element:t}}let xo=!1;function Ll(n,t){if(typeof window>"u"||typeof document>"u"||!ni(window.location.host)||fn[n]===t||fn[n]||xo)return;fn[n]=t;function e(T){return`__firebase__banner__${T}`}const r="__firebase__banner",o=Ml().prod.length>0;function a(){const T=document.getElementById(r);T&&T.remove()}function l(T){T.style.display="flex",T.style.background="#7faaf0",T.style.position="fixed",T.style.bottom="5px",T.style.left="5px",T.style.padding=".5em",T.style.borderRadius="5px",T.style.alignItems="center"}function h(T,P){T.setAttribute("width","24"),T.setAttribute("id",P),T.setAttribute("height","24"),T.setAttribute("viewBox","0 0 24 24"),T.setAttribute("fill","none"),T.style.marginLeft="-6px"}function f(){const T=document.createElement("span");return T.style.cursor="pointer",T.style.marginLeft="16px",T.style.fontSize="24px",T.innerHTML=" &times;",T.onclick=()=>{xo=!0,a()},T}function m(T,P){T.setAttribute("id",P),T.innerText="Learn more",T.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",T.setAttribute("target","__blank"),T.style.paddingLeft="5px",T.style.textDecoration="underline"}function E(){const T=xl(r),P=e("text"),b=document.getElementById(P)||document.createElement("span"),O=e("learnmore"),D=document.getElementById(O)||document.createElement("a"),G=e("preprendIcon"),U=document.getElementById(G)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(T.created){const z=T.element;l(z),m(D,O);const nt=f();h(U,G),z.append(U,b,D,nt),document.body.appendChild(z)}o?(b.innerText="Preview backend disconnected.",U.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
92<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
93</g>
94<defs>
95<clipPath id="clip0_6013_33858">
96<rect width="24" height="24" fill="white"/>
97</clipPath>
98</defs>`):(U.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
99<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 
9912.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
100</g>
101<defs>
102<clipPath id="clip0_6083_34804">
103<rect width="24" height="24" fill="white"/>
104</clipPath>
105</defs>`,b.innerText="Preview backend running in this workspace."),b.setAttribute("id",P)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",E):E()}/**
106 * @license
107 * Copyright 2017 Google LLC
108 *
109 * Licensed under the Apache License, Version 2.0 (the "License");
110 * you may not use this file except in compliance with the License.
111 * You may obtain a copy of the License at
112 *
113 *   http://www.apache.org/licenses/LICENSE-2.0
114 *
115 * Unless required by applicable law or agreed to in writing, software
116 * distributed under the License is distributed on an "AS IS" BASIS,
117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118 * See the License for the specific language governing permissions and
119 * limitations under the License.
120 */function ri(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function wp(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(ri())}function Fl(){var t;const n=(t=Vr())==null?void 0:t.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(globalThis.process)==="[object process]"}catch{return!1}}function Rp(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Sp(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function Cp(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Pp(){const n=ri();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function Ul(){return!Fl()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Bl(){try{return typeof indexedDB=="object"}catch{return!1}}function ql(){return new Promise((n,t)=>{try{let e=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),e||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{e=!1},s.onerror=()=>{var o;t(((o=s.error)==null?void 0:o.message)||"")}}catch(e){t(e)}})}/**
121 * @license
122 * Copyright 2017 Google LLC
123 *
124 * Licensed under the Apache License, Version 2.0 (the "License");
125 * you may not use this file except in compliance with the License.
126 * You may obtain a copy of the License at
127 *
128 *   http://www.apache.org/licenses/LICENSE-2.0
129 *
130 * Unless required by applicable law or agreed to in writing, software
131 * distributed under the License is distributed on an "AS IS" BASIS,
132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133 * See the License for the specific language governing permissions and
134 * limitations under the License.
135 */const jl="FirebaseError";
135class Be extends Error{constructor(t,e,r){super(e),this.code=t,this.customData=r,this.name=jl,Object.setPrototypeOf(this,Be.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Wa.prototype.create)}}class Wa{constructor(t,e,r){this.service=t,this.serviceName=e,this.errors=r}create(t,...e){const r=e[0]||{},s=`${this.service}/${t}`,o=this.errors[t],a=o?$l(o,r):"Error",l=`${this.serviceName}: ${a} (${s}).`;return new Be(s,l,r)}}function $l(n,t){return n.replace(zl,(e,r)=>{const s=t[r];return s!=null?String(s):`<${r}?>`})}const zl=/\{\$([^}]+)}/g;function Vp(n){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0}function gr(n,t){if(n===t)return!0;const e=Object.keys(n),r=Object.keys(t);for(const s of e){if(!r.includes(s))return!1;const o=n[s],a=t[s];if(Lo(o)&&Lo(a)){if(!gr(o,a))return!1}else if(o!==a)return!1}for(const s of r)if(!e.includes(s))return!1;return!0}function Lo(n){return n!==null&&typeof n=="object"}/**
136 * @license
137 * Copyright 2017 Google LLC
138 *
139 * Licensed under the Apache License, Version 2.0 (the "License");
140 * you may not use this file except in compliance with the License.
141 * You may obtain a copy of the License at
142 *
143 *   http://www.apache.org/licenses/LICENSE-2.0
144 *
145 * Unless required by applicable law or agreed to in writing, software
146 * distributed under the License is distributed on an "AS IS" BASIS,
147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148 * See the License for the specific language governing permissions and
149 * limitations under the License.
150 */function bp(n){const t=[];for(const[e,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{t.push(encodeURIComponent(e)+"="+encodeURIComponent(s))}):t.push(encodeURIComponent(e)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""}function Dp(n,t){const e=new Gl(n,t);return e.subscribe.bind(e)}class Gl{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(()=>{t(this)}).catch(r=>{this.error(r)})}next(t){this.forEachObserver(e=>{e.next(t)})}error(t){this.forEachObserver(e=>{e.error(t)}),this.close(t)}complete(){this.forEachObserver(t=>{t.complete()}),this.close()}subscribe(t,e,r){let s;if(t===void 0&&e===void 0&&r===void 0)throw new Error("Missing Observer.");Hl(t,["next","error","complete"])?s=t:s={next:t,error:e,complete:r},s.next===void 0&&(s.next=As),s.error===void 0&&(s.error=As),s.complete===void 0&&(s.complete=As);const o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),o}unsubscribeOne(t){this.observers===void 0||this.observers[t]===void 0||(delete this.observers[t],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then(()=>{if(this.observers!==void 0&&this.observers[t]!==void 0)try{e(this.observers[t])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(t){this.finalized||(this.finalized=!0,t!==void 0&&(this.finalError=t),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Hl(n,t){if(typeof n!="object"||n===null)return!1;for(const e of t)if(e in n&&typeof n[e]=="function")return!0;return!1}function As(){}/**
151 * @license
152 * Copyright 2021 Google LLC
153 *
154 * Licensed under the Apache License, Version 2.0 (the "License");
155 * you may not use this file except in compliance with the License.
156 * You may obtain a copy of the License at
157 *
158 *   http://www.apache.org/licenses/LICENSE-2.0
159 *
160 * Unless required by applicable law or agreed to in writing, software
161 * distributed under the License is distributed on an "AS IS" BASIS,
162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163 * See the License for the specific language governing permissions and
164 * limitations under the License.
165 */function xt(n){return n&&n._delegate?n._delegate:n}class Tn{constructor(t,e,r){this.name=t,this.instanceFactory=e,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}/**
166 * @license
167 * Copyright 2019 Google LLC
168 *
169 * Licensed under the Apache License, Version 2.0 (the "License");
170 * you may not use this file except in compliance with the License.
171 * You may obtain a copy of the License at
172 *
173 *   http://www.apache.org/licenses/LICENSE-2.0
174 *
175 * Unless required by applicable law or agreed to in writing, software
176 * distributed under the License is distributed on an "AS IS" BASIS,
177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
178 * See the License for the specific language governing permissions and
179 * limitations under the License.
180 */const ge="[DEFAULT]";/**
181 * @license
182 * Copyright 2019 Google LLC
183 *
184 * Licensed under the Apache License, Version 2.0 (the "License");
185 * you may not use this file except in compliance with the License.
186 * You may obtain a copy of the License at
187 *
188 *   http://www.apache.org/licenses/LICENSE-2.0
189 *
190 * Unless required by applicable law or agreed to in writing, software
191 * distributed under the License is distributed on an "AS IS" BASIS,
192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193 * See the License for the specific language governing permissions and
194 * limitations under the License.
195 */class Kl{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const r=new Nl;if(this.instancesDeferred.set(e,r),this.isInitialized(e)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:e});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(e).promise}getImmediate(t){const e=this.normalizeInstanceIdentifier(t==null?void 0:t.identifier),r=(t==null?void 0:t.optional)??!1;if(this.isInitialized(e)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:e})}catch(s){if(r)return null;throw s}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,!!this.shouldAutoInitialize()){if(Wl(t))try{this.getOrInitializeService({instanceIdentifier:ge})}catch{}for(const[e,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(e);try{const o=this.getOrInitializeService({instanceIdentifier:s});r.resolve(o)}catch{}}}}clearInstance(t=ge){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...t.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(t=ge){return this.instances.has(t)}getOptions(t=ge){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,r=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:e});for(const[o,a]of this.instancesDeferred.entries()){const l=this.normalizeInstanceIdentifier(o);r===l&&a.resolve(s)}return s}onInit(t,e){const r=this.normalizeInstanceIdentifier(e),s=this.onInitCallbacks.get(r)??new Set;s.add(t),this.onInitCallbacks.set(r,s);const o=this.instances.get(r);return o&&t(o,r),()=>{s.delete(t)}}invokeOnInitCallbacks(t,e){const r=this.onInitCallbacks.get(e);if(r)for(const s of r)try{s(t,e)}catch{}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let r=this.instances.get(t);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Ql(t),options:e}),this.instances.set(t,r),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(r,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,r)}catch{}return r||null}normalizeInstanceIdentifier(t=ge){return this.component?this.component.multipleInstances?t:ge:t}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Ql(n){return n===ge?void 0:n}function Wl(n){return n.instantiationMode==="EAGER"}/**
196 * @license
197 * Copyright 2019 Google LLC
198 *
199 * Licensed under the Apache License, Version 2.0 (the "License");
200 * you may not use this file except in compliance with the License.
201 * You may obtain a copy of the License at
202 *
203 *   http://www.apache.org/licenses/LICENSE-2.0
204 *
205 * Unless required by applicable law or agreed to in writing, software
206 * distributed under the License is distributed on an "AS IS" BASIS,
207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208 * See the License for the specific language governing permissions and
209 * limitations under the License.
210 */class Xl{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new Kl(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}/**
211 * @license
212 * Copyright 2017 Google LLC
213 *
214 * Licensed under the Apache License, Version 2.0 (the "License");
215 * you may not use this file except in compliance with the License.
216 * You may obtain a copy of the License at
217 *
218 *   http://www.apache.org/licenses/LICENSE-2.0
219 *
220 * Unless required by applicable law or agreed to in writing, software
221 * distributed under the License is distributed on an "AS IS" BASIS,
222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
223 * See the License for the specific language governing permissions and
224 * limitations under the License.
225 */var $;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})($||($={}));const Yl={debug:$.DEBUG,verbose:$.VERBOSE,info:$.INFO,warn:$.WARN,error:$.ERROR,silent:$.SILENT},Jl=$.INFO,Zl={[$.DEBUG]:"log",[$.VERBOSE]:"log",[$.INFO]:"info",[$.WARN]:"warn",[$.ERROR]:"error"},th=(n,t,...e)=>{if(t<n.logLevel)return;const r=new Date().toISOString(),s=Zl[t];if(s)console[s](`[${r}]  ${n.name}:`,...e);else throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`)};class Xa{constructor(t){this.name=t,this._logLevel=Jl,this._logHandler=th,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in $))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel=typeof t=="string"?Yl[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if(typeof t!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,$.DEBUG,...t),this._logHandler(this,$.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,$.VERBOSE,...t),this._logHandler(this,$.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,$.INFO,...t),this._logHandler(this,$.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,$.WARN,...t),this._logHandler(this,$.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,$.ERROR,...t),this._logHandler(this,$.ERROR,...t)}}const eh=(n,t)=>t.some(e=>n instanceof e);let Fo,Uo;function nh(){return Fo||(Fo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function rh(){return Uo||(Uo=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Ya=new WeakMap,ks=new WeakMap,Ja=new WeakMap,ws=new WeakMap,si=new WeakMap;function sh(n){const t=new Promise((e,r)=>{const s=()=>{n.removeEventListener("success",o),n.removeEventListener("error",a)},o=()=>{e(Zt(n.result)),s()},a=()=>{r(n.error),s()};n.addEventListener("success",o),n.addEventListener("error",a)});return t.then(e=>{e instanceof IDBCursor&&Ya.set(e,n)}).catch(()=>{}),si.set(t,n),t}function ih(n){if(ks.has(n))return;const t=new Promise((e,r)=>{const s=()=>{n.removeEventListener("complete",o),n.removeEventListener("error",a),n.removeEventListener("abort",a)},o=()=>{e(),s()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",o),n.addEventListener("error",a),n.addEventListener("abort",a)});ks.set(n,t)}let Os={get(n,t,e){if(n instanceof IDBTransaction){if(t==="done")return ks.get(n);if(t==="objectStoreNames")return n.objectStoreNames||Ja.get(n);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return Zt(n[t])},set(n,t,e){return n[t]=e,!0},has(n,t){return n instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in n}};function oh(n){Os=n(Os)}
225function ah(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...e){const r=n.call(Rs(this),t,...e);return Ja.set(r,t.sort?t.sort():[t]),Zt(r)}:rh().includes(n)?function(...t){return n.apply(Rs(this),t),Zt(Ya.get(this))}:function(...t){return Zt(n.apply(Rs(this),t))}}function ch(n){return typeof n=="function"?ah(n):(n instanceof IDBTransaction&&ih(n),eh(n,nh())?new Proxy(n,Os):n)}function Zt(n){if(n instanceof IDBRequest)return sh(n);if(ws.has(n))return ws.get(n);const t=ch(n);return t!==n&&(ws.set(n,t),si.set(t,n)),t}const Rs=n=>si.get(n);function uh(n,t,{blocked:e,upgrade:r,blocking:s,terminated:o}={}){const a=indexedDB.open(n,t),l=Zt(a);return r&&a.addEventListener("upgradeneeded",h=>{r(Zt(a.result),h.oldVersion,h.newVersion,Zt(a.transaction),h)}),e&&a.addEventListener("blocked",h=>e(h.oldVersion,h.newVersion,h)),l.then(h=>{o&&h.addEventListener("close",()=>o()),s&&h.addEventListener("versionchange",f=>s(f.oldVersion,f.newVersion,f))}).catch(()=>{}),l}const lh=["get","getKey","getAll","getAllKeys","count"],hh=["put","add","delete","clear"],Ss=new Map;function Bo(n,t){if(!(n instanceof IDBDatabase&&!(t in n)&&typeof t=="string"))return;if(Ss.get(t))return Ss.get(t);const e=t.replace(/FromIndex$/,""),r=t!==e,s=hh.includes(e);if(!(e in(r?IDBIndex:IDBObjectStore).prototype)||!(s||lh.includes(e)))return;const o=async function(a,...l){const h=this.transaction(a,s?"readwrite":"readonly");let f=h.store;return r&&(f=f.index(l.shift())),(await Promise.all([f[e](...l),s&&h.done]))[0]};return Ss.set(t,o),o}oh(n=>({...n,get:(t,e,r)=>Bo(t,e)||n.get(t,e,r),has:(t,e)=>!!Bo(t,e)||n.has(t,e)}));/**
226 * @license
227 * Copyright 2019 Google LLC
228 *
229 * Licensed under the Apache License, Version 2.0 (the "License");
230 * you may not use this file except in compliance with the License.
231 * You may obtain a copy of the License at
232 *
233 *   http://www.apache.org/licenses/LICENSE-2.0
234 *
235 * Unless required by applicable law or agreed to in writing, software
236 * distributed under the License is distributed on an "AS IS" BASIS,
237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
238 * See the License for the specific language governing permissions and
239 * limitations under the License.
240 */class dh{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(fh(e)){const r=e.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(e=>e).join(" ")}}function fh(n){const t=n.getComponent();return(t==null?void 0:t.type)==="VERSION"}const Ms="@firebase/app",qo="0.14.2";/**
241 * @license
242 * Copyright 2019 Google LLC
243 *
244 * Licensed under the Apache License, Version 2.0 (the "License");
245 * you may not use this file except in compliance with the License.
246 * You may obtain a copy of the License at
247 *
248 *   http://www.apache.org/licenses/LICENSE-2.0
249 *
250 * Unless required by applicable law or agreed to in writing, software
251 * distributed under the License is distributed on an "AS IS" BASIS,
252 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
253 * See the License for the specific language governing permissions and
254 * limitations under the License.
255 */const $t=new Xa("@firebase/app"),mh="@firebase/app-compat",ph="@firebase/analytics-compat",gh="@firebase/analytics",_h="@firebase/app-check-compat",yh="@firebase/app-check",Eh="@f
255irebase/auth",Th="@firebase/auth-compat",vh="@firebase/database",Ih="@firebase/data-connect",Ah="@firebase/database-compat",wh="@firebase/functions",Rh="@firebase/functions-compat",Sh="@firebase/installations",Ch="@firebase/installations-compat",Ph="@firebase/messaging",Vh="@firebase/messaging-compat",bh="@firebase/performance",Dh="@firebase/performance-compat",Nh="@firebase/remote-config",kh="@firebase/remote-config-compat",Oh="@firebase/storage",Mh="@firebase/storage-compat",xh="@firebase/firestore",Lh="@firebase/ai",Fh="@firebase/firestore-compat",Uh="firebase",Bh="12.2.0";/**
256 * @license
257 * Copyright 2019 Google LLC
258 *
259 * Licensed under the Apache License, Version 2.0 (the "License");
260 * you may not use this file except in compliance with the License.
261 * You may obtain a copy of the License at
262 *
263 *   http://www.apache.org/licenses/LICENSE-2.0
264 *
265 * Unless required by applicable law or agreed to in writing, software
266 * distributed under the License is distributed on an "AS IS" BASIS,
267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
268 * See the License for the specific language governing permissions and
269 * limitations under the License.
270 */const xs="[DEFAULT]",qh={[Ms]:"fire-core",[mh]:"fire-core-compat",[gh]:"fire-analytics",[ph]:"fire-analytics-compat",[yh]:"fire-app-check",[_h]:"fire-app-check-compat",[Eh]:"fire-auth",[Th]:"fire-auth-compat",[vh]:"fire-rtdb",[Ih]:"fire-data-connect",[Ah]:"fire-rtdb-compat",[wh]:"fire-fn",[Rh]:"fire-fn-compat",[Sh]:"fire-iid",[Ch]:"fire-iid-compat",[Ph]:"fire-fcm",[Vh]:"fire-fcm-compat",[bh]:"fire-perf",[Dh]:"fire-perf-compat",[Nh]:"fire-rc",[kh]:"fire-rc-compat",[Oh]:"fire-gcs",[Mh]:"fire-gcs-compat",[xh]:"fire-fst",[Fh]:"fire-fst-compat",[Lh]:"fire-vertex","fire-js":"fire-js",[Uh]:"fire-js-all"};/**
271 * @license
272 * Copyright 2019 Google LLC
273 *
274 * Licensed under the Apache License, Version 2.0 (the "License");
275 * you may not use this file except in compliance with the License.
276 * You may obtain a copy of the License at
277 *
278 *   http://www.apache.org/licenses/LICENSE-2.0
279 *
280 * Unless required by applicable law or agreed to in writing, software
281 * distributed under the License is distributed on an "AS IS" BASIS,
282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
283 * See the License for the specific language governing permissions and
284 * limitations under the License.
285 */const vn=new Map,jh=new Map,Ls=new Map;function jo(n,t){try{n.container.addComponent(t)}catch(e){$t.debug(`Component ${t.name} failed to register with FirebaseApp ${n.name}`,e)}}function _r(n){const t=n.name;if(Ls.has(t))return $t.debug(`There were multiple attempts to register component ${t}.`),!1;Ls.set(t,n);for(const e of vn.values())jo(e,n);for(const e of jh.values())jo(e,n);return!0}function $h(n,t){const e=n.container.getProvider("heartbeat").getImmediate({optional:!0});return e&&e.triggerHeartbeat(),n.container.getProvider(t)}function zh(n){return n==null?!1:n.settings!==void 0}/**
286 * @license
287 * Copyright 2019 Google LLC
288 *
289 * Licensed under the Apache License, Version 2.0 (the "License");
290 * you may not use this file except in compliance with the License.
291 * You may obtain a copy of the License at
292 *
293 *   http://www.apache.org/licenses/LICENSE-2.0
294 *
295 * Unless required by applicable law or agreed to in writing, software
296 * distributed under the License is distributed on an "AS IS" BASIS,
297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
298 * See the License for the specific language governing permissions and
299 * limitations under the License.
300 */const Gh={"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
300d-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."},te=new Wa("app","Firebase",Gh);/**
301 * @license
302 * Copyright 2019 Google LLC
303 *
304 * Licensed under the Apache License, Version 2.0 (the "License");
305 * you may not use this file except in compliance with the License.
306 * You may obtain a copy of the License at
307 *
308 *   http://www.apache.org/licenses/LICENSE-2.0
309 *
310 * Unless required by applicable law or agreed to in writing, software
311 * distributed under the License is distributed on an "AS IS" BASIS,
312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
313 * See the License for the specific language governing permissions and
314 * limitations under the License.
315 */class Hh{constructor(t,e,r){this._isDeleted=!1,this._options={...t},this._config={...e},this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Tn("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw te.create("app-deleted",{appName:this._name})}}/**
316 * @license
317 * Copyright 2019 Google LLC
318 *
319 * Licensed under the Apache License, Version 2.0 (the "License");
320 * you may not use this file except in compliance with the License.
321 * You may obtain a copy of the License at
322 *
323 *   http://www.apache.org/licenses/LICENSE-2.0
324 *
325 * Unless required by applicable law or agreed to in writing, software
326 * distributed under the License is distributed on an "AS IS" BASIS,
327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
328 * See the License for the specific language governing permissions and
329 * limitations under the License.
330 */const Kh=Bh;function Qh(n,t={}){let e=n;typeof t!="object"&&(t={name:t});const r={name:xs,automaticDataCollectionEnabled:!0,...t},s=r.name;if(typeof s!="string"||!s)throw te.create("bad-app-name",{appName:String(s)});if(e||(e=Qa()),!e)throw te.create("no-options");const o=vn.get(s);if(o){if(gr(e,o.options)&&gr(r,o.config))return o;throw te.create("duplicate-app",{appName:s})}const a=new Xl(s);for(const h of Ls.values())a.addComponent(h);const l=new Hh(e,r,a);return vn.set(s,l),l}function Wh(n=xs){const t=vn.get(n);if(!t&&n===xs&&Qa())return Qh();if(!t)throw te.create("no-app",{appName:n});return t}function Np(){return Array.from(vn.values())}function mn(n,t,e){let r=qh[n]??n;e&&(r+=`-${e}`);const s=r.match(/\s|\//),o=t.match(/\s|\//);if(s||o){const a=[`Unable to register library "${r}" with version "${t}":`];s&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&o&&a.push("and"),o&&a.push(`version name "${t}" contains illegal characters (whitespace or "/")`),$t.warn(a.join(" "));return}_r(new Tn(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}/**
331 * @license
332 * Copyright 2021 Google LLC
333 *
334 * Licensed under the Apache License, Version 2.0 (the "License");
335 * you may not use this file except in compliance with the License.
336 * You may obtain a copy of the License at
337 *
338 *   http://www.apache.org/licenses/LICENSE-2.0
339 *
340 * Unless required by applicable law or agreed to in writing, softw
340are
341 * distributed under the License is distributed on an "AS IS" BASIS,
342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
343 * See the License for the specific language governing permissions and
344 * limitations under the License.
345 */const Xh="firebase-heartbeat-database",Yh=1,In="firebase-heartbeat-store";let Cs=null;function Za(){return Cs||(Cs=uh(Xh,Yh,{upgrade:(n,t)=>{switch(t){case 0:try{n.createObjectStore(In)}catch(e){console.warn(e)}}}}).catch(n=>{throw te.create("idb-open",{originalErrorMessage:n.message})})),Cs}async function Jh(n){try{const e=(await Za()).transaction(In),r=await e.objectStore(In).get(tc(n));return await e.done,r}catch(t){if(t instanceof Be)$t.warn(t.message);else{const e=te.create("idb-get",{originalErrorMessage:t==null?void 0:t.message});$t.warn(e.message)}}}async function $o(n,t){try{const r=(await Za()).transaction(In,"readwrite");await r.objectStore(In).put(t,tc(n)),await r.done}catch(e){if(e instanceof Be)$t.warn(e.message);else{const r=te.create("idb-set",{originalErrorMessage:e==null?void 0:e.message});$t.warn(r.message)}}}function tc(n){return`${n.name}!${n.options.appId}`}/**
346 * @license
347 * Copyright 2021 Google LLC
348 *
349 * Licensed under the Apache License, Version 2.0 (the "License");
350 * you may not use this file except in compliance with the License.
351 * You may obtain a copy of the License at
352 *
353 *   http://www.apache.org/licenses/LICENSE-2.0
354 *
355 * Unless required by applicable law or agreed to in writing, software
356 * distributed under the License is distributed on an "AS IS" BASIS,
357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
358 * See the License for the specific language governing permissions and
359 * limitations under the License.
360 */const Zh=1024,td=30;class ed{constructor(t){this.container=t,this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new rd(e),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var t,e;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),o=zo();if(((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((e=this._heartbeatsCache)==null?void 0:e.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===o||this._heartbeatsCache.heartbeats.some(a=>a.date===o))return;if(this._heartbeatsCache.heartbeats.push({date:o,agent:s}),this._heartbeatsCache.heartbeats.length>td){const a=sd(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(a,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){$t.warn(r)}}async getHeartbeatsHeader(){var t;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((t=this._heartbeatsCache)==null?void 0:t.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=zo(),{heartbeatsToSend:r,unsentEntries:s}=nd(this._heartbeatsCache.heartbeats),o=pr(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=e,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),o}catch(e){return $t.warn(e),""}}}function zo(){return new Date().toISOString().substring(0,10)}function nd(n,t=Zh){const e=[];let r=n.slice();for(const s of n){const o=e.find(a=>a.agent===s.agent);if(o){if(o.dates.push(s.date),Go(e)>t){o.dates.pop();break}}else if(e.push({agent:s.agent,dates:[s.date]}),Go(e)>t){e.pop();break}r=r.slice(1)}return{heartbeatsToSend:e,unsentEntries:r}}class rd{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Bl()?ql().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const e=await Jh(this.app);return e!=null&&e.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(t){if(await this._canUseIndexedDBPromise){const r=await this.read();return $o(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:t.heartbeats})}else return}async add(t){if(await this._canUseIndexedDBPromise){const r=await this.read();return $o(this.app,{lastSentHeartbeatDate:t.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...t.heartbeats]})}else return}}function Go(n){return pr(JSON.stringify({version:2,heartbeats:n})).length}function sd(n){if(n.length===0)return-1;let t=0,e=n[0].date;for(let r=1;r<n.length;r++)n[r].date<e&&(e=n[r].date,t=r);return t}/**
361 * @license
362 * Copyright 2019 Google LLC
363 *
364 * Licensed under the Apache License, Version 2.0 (the "License");
365 * you may not use this file except in compliance with the License.
366 * You may obtain a copy of the License at
367 *
368 *   http://www.apache.org/licenses/LICENSE-2.0
369 *
370 * Unless required by applicable law or agreed to in writing, software
371 * distributed under the License is distributed on an "AS IS" BASIS,
372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
373 * See the License for the specific language governing permissions and
374 * limitations under the License.
375 */function id(n){_r(new Tn("platform-logger",t=>new dh(t),"PRIVATE")),_r(new Tn("heartbeat",t=>new ed(t),"PRIVATE")),mn(Ms,qo,n),mn(Ms,qo,"esm2020"),mn("fire-js","")}id("");var Ho=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
376Copyright The Closure Library Authors.
377SPDX-License-Identifier: Apache-2.0
378*/var ee,ec;(function(){var n;/** @license
379
380 Copyright The Closure Library Authors.
381 SPDX-License-Identifier: Apache-2.0
382*/function t(I,p){function _(){}_.prototype=p.prototype,I.D=p.prototype,I.prototype=new _,I.prototype.constructor=I,I.C=function(y,v,w){for(var g=Array(arguments.length-2),Ut=2;Ut<arguments.length;Ut++)g[Ut-2]=arguments[Ut];return p.prototype[v].apply(y,g)}}function e(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}t(r,e),r.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 s(I,p,_){_||(_=0);var y=Array(16);if(typeof p=="string")for(var v=0;16>v;++v)y[v]=p.charCodeAt(_++)|p.charCodeAt(_++)<<8|p.charCodeAt(_++)<<16|p.charCodeAt(_++)<<24;else for(v=0;16>v;++v)y[v]=p[_++]|p[_++]<<8|p[_++]<<16|p[_++]<<24;p=I.g[0],_=I.g[1],v=I.g[2];var w=I.g[3],g=p+(w^_&(v^w))+y[0]+3614090360&4294967295;p=_+(g<<7&4294967295|g>>>25),g=w+(v^p&(_^v))+y[1]+3905402710&4294967295,w=p+(g<<12&4294967295|g>>>20),g=v+(_^w&(p^_))+y[2]+606105819&4294967295,v=w+(g<<17&4294967295|g>>>15),g=_+(p^v&(w^p))+y[3]+3250441966&4294967295,_=v+(g<<22&4294967295|g>>>10),g=p+(w^_&(v^w))+y[4]+4118548399&4294967295,p=_+(g<<7&4294967295|g>>>25),g=w+(v^p&(_^v))+y[5]+1200080426&4294967295,w=p+(g<<12&4294967295|g>>>20),g=v+(_^w&(p^_))+y[6]+2821735955&4294967295,v=w+(g<<17&4294967295|g>>>15),g=_+(p^v&(w^p))+y[7]+4249261313&4294967295,_=v+(g<<22&4294967295|g>>>10),g=p+(w^_&(v^w))+y[8]+1770035416&4294967295,p=_+(g<<7&4294967295|g>>>25),g=w+(v^p&(_^v))+y[9]+2336552879&4294967295,w=p+(g<<12&4294967295|g>>>20),g=v+(_^w&(p^_))+y[10]+4294925233&4294967295,v=w+(g<<17&4294967295|g>>>15),g=_+(p^v&(w^p))+y[11]+2304563134&4294967295,_=v+(g<<22&4294967295|g>>>10),g=p+(w^_&(v^w))+y[12]+1804603682&4294967295,p=_+(g<<7&4294967295|g>>>25),g=w+(v^p&(_^v))+y[13]+4254626195&4294967295,w=p+(g<<12&4294967295|g>>>20),g=v+(_^w&(p^_))+y[14]+2792965006&4294967295,v=w+(g<<17&4294967295|g>>>15),g=_+(p^v&(w^p))+y[15]+1236535329&4294967295,_=v+(g<<22&4294967295|g>>>10),g=p+(v^w&(_^v))+y[1]+4129170786&4294967295,p=_+(g<<5&4294967295|g>>>27),g=w+(_^v&(p^_))+y[6]+3225465664&4294967295,w=p+(g<<9&4294967295|g>>>23),g=v+(p^_&(w^p))+y[11]+643717713&4294967295,v=w+(g<<14&4294967295|g>>>18),g=_+(w^p&(v^w))+y[0]+3921069994&4294967295,_=v+(g<<20&4294967295|g>>>12),g=p+(v^w&(_^v))+y[5]+3593408605&4294967295,p=_+(g<<5&4294967295|g>>>27),g=w+(_^v&(p^_))+y[10]+38016083&4294967295,w=p+(g<<9&4294967295|g>>>23),g=v+(p^_&(w^p))+y[15]+3634488961&4294967295,v=w+(g<<14&4294967295|g>>>18),g=_+(w^p&(v^w))+y[4]+3889429448&4294967295,_=v+(g<<20&4294967295|g>>>12),g=p+(v^w&(_^v))+y[9]+568446438&4294967295,p=_+(g<<5&4294967295|g>>>27),g=w+(_^v&(p^_))+y[14]+3275163606&4294967295,w=p+(g<<9&4294967295|g>>>23),g=v+(p^_&(w^p))+y[3]+4107603335&4294967295,v=w+(g<<14&4294967295|g>>>18),g=_+(w^p&(v^w))+y[8]+1163531501&4294967295,_=v+(g<<20&4294967295|g>>>12),g=p+(v^w&(_^v))+y[13]+2850285829&4294967295,p=_+(g<<5&4294967295|g>>>27),g=w+(_^v&(p^_))+y[2]+4243563512&4294967295,w=p+(g<<9&4294967295|g>>>23),g=v+(p^_&(w^p))+y[7]+1735328473&4294967295,v=w+(g<<14&4294967295|g>>>18),g=_+(w^p&(v^w))+y[12]+2368359562&4294967295,_=v+(g<<20&4294967295|g>>>12),g=p+(_^v^w)+y[5]+4294588738&4294967295,p=_+(g<<4&4294967295|g>>>28),g=w+(p^_^v)+y[8]+2272392833&4294967295,w=p+(g<<11&4294967295|g>>>21),g=v+(w^p^_)+y[11]+1839030562&4294967295,v=w+(g<<16&4294967295|g>>>16),g=_+(v^w^p)+y[14]+4259657740&4294967295,_=v+(g<<23&4294967295|g>>>9),g=p+(_^v^w)+y[1]+2763975236&4294967295,p=_+(g<<4&4294967295|g>>>28),g=w+(p^_^v)+y[4]+1272893353&4294967295,w=p+(g<<11&4294967295|g>>>21),g=v+(w^p^_)+y[7]+4139469664&4294967295,v=w+(g<<16&4294967295|g>>>16),g=_+(v^w^p)+y[10]+3200236656&4294967295,_=v+(g<<23&4294967295|g>>>9),g=p+(_^v^w)+y[13]+681279174&4294967295,p=_+(g<<4&4294967295|g>>>28),g=w+(p^_^v)+y[0]+3936430074&4294967295,w=p+(g<<11&4294967295|g>>>21),g=v+(w^p^_)+y[3]+3572445317&4294967295,v=w+(g<<16&4294967295|g>>>16),g=_+(v^w^p)+y[6]+76029189&4294967295,_=v+(g<<23&4294967295|g>>>9),g=p+(_^v^w)+y[9]+3654602809&4294967295,p=_+(g<<4&4294967295|g>>>28),g=w+(p^_^v)+y[12]+3873151461&4294967295,w=p+(g<<11&4294967295|g>>>21),g=v+(w^p^_)+y[15]+530742520&4294967295,v=w+(g<<16&4294967295|g>>>16),g=_+(v^w^p)+y[2]+3299628645&4294967295,_=v+(g<<23&4294967295|g>>>9),g=p+(v^(_|~w))+y[0]+4096336452&4294967295,p=_+(g<<6&4294967295|g>>>26),g=w+(_^(p|~v))+y[7]+1126891415&4294967295,w=p+(g<<10&4294967295|g>>>22),g=v+(p^(w|~_))+y[14]+2878612391&4294967295,v=w+(g<<15&4294967295|g>>>17),g=_+(w^(v|~p))+y[5]+4237533241&4294967295,_=v+(g<<21&4294967295|g>>>11),g=p+(v^(_|~w))+y[12]+1700485571&4294967295,p=_+(g<<6&4294967295|g>>>26),g=w+(_^(p|~v))+y[3]+2399980690&4294967295,w=p+(g<<10&4294967295|g>>>22),g=v+(p^(w|~_))+y[10]+4293915773&4294967295,v=w+(g<<15&4294967295|g>>>17),g=_+(w^(v|~p))+y[1]+2240044497&4294967295,_=v+(g<<21&4294967295|g>>>11),g=p+(v^(_|~w))+y[8]+1873313359&4294967295,p=_+(g<<6&4294967295|g>>>26),g=w+(_^(p|~v))+y[15]+4264355552&4294967295,w=p+(g<<10&4294967295|g>>>22),g=v+(p^(w|~_))+y[6]+2734768916&4294967295,v=w+(g<<15&4294967295|g>>>17),g=_+(w^(v|~p))+y[13]+1309151649&4294967295,_=v+(g<<21&4294967295|g>>>11),g=p+(v^(_|~w))+y[4]+4149444226&4294967295,p=_+(g<<6&4294967295|g>>>26),g=w+(_^(p|~v))+y[11]+3174756917&4294967295,w=p+(g<<10&4294967295|g>>>22),g=v+(p^(w|~_))+y[2]+718787259&4294967295,v=w+(g<<15&4294967295|g>>>17),g=_+(w^(v|~p))+y[9]+3951481745&4294967295,I.g[0]=I.g[0]+p&4294967295,I.g[1]=I.g[1]+(v+(g<<21&4294967295|g>>>11))&4294967295,I.g[2]=I.g[2]+v&4294967295,I.g[3]=I.g[3]+w&4294967295}r.prototype.u=function(I,p){p===void 0&&(p=I.length);for(var _=p-this.blockSize,y=this.B,v=this.h,w=0;w<p;){if(v==0)for(;w<=_;)s(this,I,w),w+=this.blockSize;
vendor: 8,538 bytes, lines 382-389
382if(typeof I=="string"){for(;w<p;)if(y[v++]=I.charCodeAt(w++),v==this.blockSize){s(this,y),v=0;break}}else for(;w<p;)if(y[v++]=I[w++],v==this.blockSize){s(this,y),v=0;break}}this.h=v,this.o+=p},r.prototype.v=function(){var I=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);I[0]=128;for(var p=1;p<I.length-8;++p)I[p]=0;var _=8*this.o;for(p=I.length-8;p<I.length;++p)I[p]=_&255,_/=256;for(this.u(I),I=Array(16),p=_=0;4>p;++p)for(var y=0;32>y;y+=8)I[_++]=this.g[p]>>>y&255;return I};function o(I,p){var _=l;return Object.prototype.hasOwnProperty.call(_,I)?_[I]:_[I]=p(I)}function a(I,p){this.h=p;for(var _=[],y=!0,v=I.length-1;0<=v;v--){var w=I[v]|0;y&&w==p||(_[v]=w,y=!1)}this.g=_}var l={};function h(I){return-128<=I&&128>I?o(I,function(p){return new a([p|0],0>p?-1:0)}):new a([I|0],0>I?-1:0)}function f(I){if(isNaN(I)||!isFinite(I))return E;if(0>I)return D(f(-I));for(var p=[],_=1,y=0;I>=_;y++)p[y]=I/_|0,_*=4294967296;return new a(p,0)}function m(I,p){if(I.length==0)throw Error("number format error: empty string");if(p=p||10,2>p||36<p)throw Error("radix out of range: "+p);if(I.charAt(0)=="-")return D(m(I.substring(1),p));if(0<=I.indexOf("-"))throw Error('number format error: interior "-" character');for(var _=f(Math.pow(p,8)),y=E,v=0;v<I.length;v+=8){var w=Math.min(8,I.length-v),g=parseInt(I.substring(v,v+w),p);8>w?(w=f(Math.pow(p,w)),y=y.j(w).add(f(g))):(y=y.j(_),y=y.add(f(g)))}return y}var E=h(0),T=h(1),P=h(16777216);n=a.prototype,n.m=function(){if(O(this))return-D(this).m();for(var I=0,p=1,_=0;_<this.g.length;_++){var y=this.i(_);I+=(0<=y?y:4294967296+y)*p,p*=4294967296}return I},n.toString=function(I){if(I=I||10,2>I||36<I)throw Error("radix out of range: "+I);if(b(this))return"0";if(O(this))return"-"+D(this).toString(I);for(var p=f(Math.pow(I,6)),_=this,y="";;){var v=nt(_,p).g;_=G(_,v.j(p));var w=((0<_.g.length?_.g[0]:_.h)>>>0).toString(I);if(_=v,b(_))return w+y;for(;6>w.length;)w="0"+w;y=w+y}},n.i=function(I){return 0>I?0:I<this.g.length?this.g[I]:this.h};function b(I){if(I.h!=0)return!1;for(var p=0;p<I.g.length;p++)if(I.g[p]!=0)return!1;return!0}function O(I){return I.h==-1}n.l=function(I){return I=G(this,I),O(I)?-1:b(I)?0:1};function D(I){for(var p=I.g.length,_=[],y=0;y<p;y++)_[y]=~I.g[y];return new a(_,~I.h).add(T)}n.abs=function(){return O(this)?D(this):this},n.add=function(I){for(var p=Math.max(this.g.length,I.g.length),_=[],y=0,v=0;v<=p;v++){var w=y+(this.i(v)&65535)+(I.i(v)&65535),g=(w>>>16)+(this.i(v)>>>16)+(I.i(v)>>>16);y=g>>>16,w&=65535,g&=65535,_[v]=g<<16|w}return new a(_,_[_.length-1]&-2147483648?-1:0)};function G(I,p){return I.add(D(p))}n.j=function(I){if(b(this)||b(I))return E;if(O(this))return O(I)?D(this).j(D(I)):D(D(this).j(I));if(O(I))return D(this.j(D(I)));if(0>this.l(P)&&0>I.l(P))return f(this.m()*I.m());for(var p=this.g.length+I.g.length,_=[],y=0;y<2*p;y++)_[y]=0;for(y=0;y<this.g.length;y++)for(var v=0;v<I.g.length;v++){var w=this.i(y)>>>16,g=this.i(y)&65535,Ut=I.i(v)>>>16,He=I.i(v)&65535;_[2*y+2*v]+=g*He,U(_,2*y+2*v),_[2*y+2*v+1]+=w*He,U(_,2*y+2*v+1),_[2*y+2*v+1]+=g*Ut,U(_,2*y+2*v+1),_[2*y+2*v+2]+=w*Ut,U(_,2*y+2*v+2)}for(y=0;y<p;y++)_[y]=_[2*y+1]<<16|_[2*y];for(y=p;y<2*p;y++)_[y]=0;return new a(_,0)};function U(I,p){for(;(I[p]&65535)!=I[p];)I[p+1]+=I[p]>>>16,I[p]&=65535,p++}function z(I,p){this.g=I,this.h=p}function nt(I,p){if(b(p))throw Error("division by zero");if(b(I))return new z(E,E);if(O(I))return p=nt(D(I),p),new z(D(p.g),D(p.h));if(O(p))return p=nt(I,D(p)),new z(D(p.g),p.h);if(30<I.g.length){if(O(I)||O(p))throw Error("slowDivide_ only works with positive integers.");for(var _=T,y=p;0>=y.l(I);)_=Ft(_),y=Ft(y);var v=lt(_,1),w=lt(y,1);for(y=lt(y,2),_=lt(_,2);!b(y);){var g=w.add(y);0>=g.l(I)&&(v=v.add(_),w=g),y=lt(y,1),_=lt(_,1)}return p=G(I,v.j(p)),new z(v,p)}for(v=E;0<=I.l(p);){for(_=Math.max(1,Math.floor(I.m()/p.m())),y=Math.ceil(Math.log(_)/Math.LN2),y=48>=y?1:Math.pow(2,y-48),w=f(_),g=w.j(p);O(g)||0<g.l(I);)_-=y,w=f(_),g=w.j(p);b(w)&&(w=T),v=v.add(w),I=G(I,g)}return new z(v,I)}n.A=function(I){return nt(this,I).h},n.and=function(I){for(var p=Math.max(this.g.length,I.g.length),_=[],y=0;y<p;y++)_[y]=this.i(y)&I.i(y);return new a(_,this.h&I.h)},n.or=function(I){for(var p=Math.max(this.g.length,I.g.length),_=[],y=0;y<p;y++)_[y]=this.i(y)|I.i(y);return new a(_,this.h|I.h)},n.xor=function(I){for(var p=Math.max(this.g.length,I.g.length),_=[],y=0;y<p;y++)_[y]=this.i(y)^I.i(y);return new a(_,this.h^I.h)};function Ft(I){for(var p=I.g.length+1,_=[],y=0;y<p;y++)_[y]=I.i(y)<<1|I.i(y-1)>>>31;return new a(_,I.h)}function lt(I,p){var _=p>>5;p%=32;for(var y=I.g.length-_,v=[],w=0;w<y;w++)v[w]=0<p?I.i(w+_)>>>p|I.i(w+_+1)<<32-p:I.i(w+_);return new a(v,I.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,ec=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=f,a.fromString=m,ee=a}).apply(typeof Ho<"u"?Ho:typeof self<"u"?self:typeof window<"u"?window:{});var ir=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
383Copyright The Closure Library Authors.
384SPDX-License-Identifier: Apache-2.0
385*/var nc,ln,rc,lr,Fs,sc,ic,oc;(function(){var n,t=typeof Object.defineProperties=="function"?Object.defineProperty:function(i,c,u){return i==Array.prototype||i==Object.prototype||(i[c]=u.value),i};function e(i){i=[typeof globalThis=="object"&&globalThis,i,typeof window=="object"&&window,typeof self=="object"&&self,typeof ir=="object"&&ir];for(var c=0;c<i.length;++c){var u=i[c];if(u&&u.Math==Math)return u}throw Error("Cannot find global object")}var r=e(this);function s(i,c){if(c)t:{var u=r;i=i.split(".");for(var d=0;d<i.length-1;d++){var A=i[d];if(!(A in u))break t;u=u[A]}i=i[i.length-1],d=u[i],c=c(d),c!=d&&c!=null&&t(u,i,{configurable:!0,writable:!0,value:c})}}function o(i,c){i instanceof String&&(i+="");var u=0,d=!1,A={next:function(){if(!d&&u<i.length){var R=u++;return{value:c(R,i[R]),done:!1}}return d=!0,{done:!0,value:void 0}}};return A[Symbol.iterator]=function(){return A},A}s("Array.prototype.values",function(i){return i||function(){return o(this,function(c,u){return u})}});/** @license
386
387 Copyright The Closure Library Authors.
388 SPDX-License-Identifier: Apache-2.0
389*/var a=a||{},l=this||self;function h(i){var c=typeof i;return c=c!="object"?c:i?Array.isArray(i)?"array":c:"null",c=="array"||c=="object"&&typeof i.length=="number"}function f(i){var c=typeof i;return c=="object"&&i!=null||c=="function"}function m(i,c,u){return i.call.apply(i.bind,arguments)}function E(i,c,u){if(!i)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var A=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(A,d),i.apply(c,A)}}return function(){return i.apply(c,arguments)}}function T(i,c,u){return T=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?m:E,T.apply(null,arguments)}function P(i,c){var u=Array.prototype.slice.call(arguments,1);return function(){var d=u.slice();return d.push.apply(d,arguments),i.apply(this,d)}}function b(i,c){function u(){}u.prototype=c.prototype,i.aa=c.prototype,i.prototype=new u,i.prototype.constructor=i,i.Qb=function(d,A,R){for(var V=Array(arguments.length-2),Q=2;Q<arguments.length;Q++)V[Q-2]=arguments[Q];return c.prototype[A].apply(d,V)}}function O(i){const c=i.length;if(0<c){const u=Array(c);for(let d=0;d<c;d++)u[d]=i[d];return u}return[]}function D(i,c){for(let u=1;u<arguments.length;u++){const d=arguments[u];if(h(d)){const A=i.length||0,R=d.length||0;i.length=A+R;for(let V=0;V<R;V++)i[A+V]=d[V]}else i.push(d)}}class G{constructor(c,u){this.i=c,this.j=u,this.h=0,this.g=null}get(){let c;return 0<this.h?(this.h--,c=this.g,this.g=c.next,c.next=null):c=this.i(),c}}function U(i){return/^[\s\xa0]*$/.test(i)}function z(){var i=l.navigator;return i&&(i=i.userAgent)?i:""}function nt(i){return nt[" "](i),i}nt[" "]=function(){};var Ft=z().indexOf("Gecko")!=-1&&!(z().toLowerCase().indexOf("webkit")!=-1&&z().indexOf("Edge")==-1)&&!(z().indexOf("Trident")!=-1||z().indexOf("MSIE")!=-1)&&z().indexOf("Edge")==-1;function lt(i,c,u){for(const d in i)c.call(u,i[d],d,i)}function I(i,c){for(const u in i)c.call(void 0,i[u],u,i)}function p(i){const c={};for(const u in i)c[u]=i[u];return c}const _="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleStr
389ing toString valueOf".split(" ");function y(i,c){let u,d;for(let A=1;A<arguments.length;A++){d=arguments[A];for(u in d)i[u]=d[u];for(let R=0;R<_.length;R++)u=_[R],Object.prototype.hasOwnProperty.call(d,u)&&(i[u]=d[u])}}function v(i){var c=1;i=i.split(":");const u=[];for(;0<c&&i.length;)u.push(i.shift()),c--;return i.length&&u.push(i.join(":")),u}function w(i){l.setTimeout(()=>{throw i},0)}function g(){var i=Zr;let c=null;return i.g&&(c=i.g,i.g=i.g.next,i.g||(i.h=null),c.next=null),c}class Ut{constructor(){this.h=this.g=null}add(c,u){const d=He.get();d.set(c,u),this.h?this.h.next=d:this.g=d,this.h=d}}var He=new G(()=>new Bu,i=>i.reset());class Bu{constructor(){this.next=this.g=this.h=null}set(c,u){this.h=c,this.g=u,this.next=null}reset(){this.next=this.g=this.h=null}}let Ke,Qe=!1,Zr=new Ut,Oi=()=>{const i=l.Promise.resolve(void 0);Ke=()=>{i.then(qu)}};var qu=()=>{for(var i;i=g();){try{i.h.call(i.g)}catch(u){w(u)}var c=He;c.j(i),100>c.h&&(c.h++,i.next=c.g,c.g=i)}Qe=!1};function Qt(){this.s=this.s,this.C=this.C}Qt.prototype.s=!1,Qt.prototype.ma=function(){this.s||(this.s=!0,this.N())},Qt.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function ft(i,c){this.type=i,this.g=this.target=c,this.defaultPrevented=!1}ft.prototype.h=function(){this.defaultPrevented=!0};var ju=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var i=!1,c=Object.defineProperty({},"passive",{get:function(){i=!0}});try{const u=()=>{};l.addEventListener("test",u,c),l.removeEventListener("test",u,c)}catch{}return i}();function We(i,c){if(ft.call(this,i?i.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,i){var u=this.type=i.type,d=i.changedTouches&&i.changedTouches.length?i.changedTouches[0]:null;if(this.target=i.target||i.srcElement,this.g=c,c=i.relatedTarget){if(Ft){t:{try{nt(c.nodeName);var A=!0;break t}catch{}A=!1}A||(c=null)}}else u=="mouseover"?c=i.fromElement:u=="mouseout"&&(c=i.toElement);this.relatedTarget=c,d?(this.clientX=d.clientX!==void 0?d.clientX:d.pageX,this.clientY=d.clientY!==void 0?d.clientY:d.pageY,this.screenX=d.screenX||0,this.screenY=d.screenY||0):(this.clientX=i.clientX!==void 0?i.clientX:i.pageX,this.clientY=i.clientY!==void 0?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0),this.button=i.button,this.key=i.key||"",this.ctrlKey=i.ctrlKey,this.altKey=i.altKey,this.shiftKey=i.shiftKey,this.metaKey=i.metaKey,this.pointerId=i.pointerId||0,this.pointerType=typeof i.pointerType=="string"?i.pointerType:$u[i.pointerType]||"",this.state=i.state,this.i=i,i.defaultPrevented&&We.aa.h.call(this)}}b(We,ft);var $u={2:"touch",3:"pen",4:"mouse"};We.prototype.h=function(){We.aa.h.call(this);var i=this.i;i.preventDefault?i.preventDefault():i.returnValue=!1};var Bn="closure_listenable_"+(1e6*Math.random()|0),zu=0;function Gu(i,c,u,d,A){this.listener=i,this.proxy=null,this.src=c,this.type=u,this.capture=!!d,this.ha=A,this.key=++zu,this.da=this.fa=!1}function qn(i){i.da=!0,i.listener=null,i.proxy=null,i.src=null,i.ha=null}function jn(i){this.src=i,this.g={},this.h=0}jn.prototype.add=function(i,c,u,d,A){var R=i.toString();i=this.g[R],i||(i=this.g[R]=[],this.h++);var V=es(i,c,d,A);return-1<V?(c=i[V],u||(c.fa=!1)):(c=new Gu(c,this.src,R,!!d,A),c.fa=u,i.push(c)),c};function ts(i,c){var u=c.type;if(u in i.g){var d=i.g[u],A=Array.prototype.indexOf.call(d,c,void 0),R;(R=0<=A)&&Array.prototype.splice.call(d,A,1),R&&(qn(c),i.g[u].length==0&&(delete i.g[u],i.h--))}}function es(i,c,u,d){for(var A=0;A<i.length;++A){var R=i[A];if(!R.da&&R.listener==c&&R.capture==!!u&&R.ha==d)return A}return-1}var ns="closure_lm_"+(1e6*Math.random()|0),rs={};function Mi(i,c,u,d,A){if(Array.isArray(c)){for(var R=0;R<c.length;R++)Mi(i,c[R],u,d,A);return null}return u=Fi(u),i&&i[Bn]?i.K(c,u,f(d)?!!d.capture:!!d,A):Hu(i,c,u,!1,d,A)}function Hu(i,c,u,d,A,R){if(!c)throw Error("Invalid event type");var V=f(A)?!!A.capture:!!A,Q=is(i);if(Q||(i[ns]=Q=new jn(i)),u=Q.add(c,u,d,V,R),u.proxy)return u;if(d=Ku(),u.proxy=d,d.src=i,d.listener=u,i.addEventListener)ju||(A=V),A===void 0&&(A=!1),i.addEventListener(c.toString(),d,A);else if(i.attachEvent)i.attachEvent(Li(c.toString()),d);else if(i.addListener&&i.removeListener)i.addListener(d);else throw Error("addEventListener and attachEvent are unavailable.");return u}function Ku(){function i(u){return c.call(i.src,i.listener,u)}const c=Qu;return i}function xi(i,c,u,d,A){if(Array.isArray(c))for(var R=0;R<c.length;R++)xi(i,c[R],u,d,A);else d=f(d)?!!d.capture:!!d,u=Fi(u),i&&i[Bn]?(i=i.i,c=String(c).toString(),c in i.g&&(R=i.g[c],u=es(R,u,d,A),-1<u&&(qn(R[u]),Array.prototype.splice.call(R,u,1),R.length==0&&(delete i.g[c],i.h--)))):i&&(i=is(i))&&(c=i.g[c.toString()],i=-1,c&&(i=es(c,u,d,A)),(u=-1<i?c[i]:null)&&ss(u))}function ss(i){if(typeof i!="number"&&i&&!i.da){var c=i.src;if(c&&c[Bn])ts(c.i,i);else{var u=i.type,d=i.proxy;c.removeEventListener?c.removeEventListener(u,d,i.capture):c.detachEvent?c.detachEvent(Li(u),d):c.addListener&&c.removeListener&&c.removeListener(d),(u=is(c))?(ts(u,i),u.h==0&&(u.src=null,c[ns]=null)):qn(i)}}}function Li(i){return i in rs?rs[i]:rs[i]="on"+i}function Qu(i,c){if(i.da)i=!0;else{c=new We(c,this);var u=i.listener,d=i.ha||i.src;i.fa&&ss(i),i=u.call(d,c)}return i}function is(i){return i=i[ns],i instanceof jn?i:null}var os="__closure_events_fn_"+(1e9*Math.random()>>>0);
vendor: 32,717 bytes, lines 389-407
389function Fi(i){return typeof i=="function"?i:(i[os]||(i[os]=function(c){return i.handleEvent(c)}),i[os])}function mt(){Qt.call(this),this.i=new jn(this),this.M=this,this.F=null}b(mt,Qt),mt.prototype[Bn]=!0,mt.prototype.removeEventListener=function(i,c,u,d){xi(this,i,c,u,d)};function Tt(i,c){var u,d=i.F;if(d)for(u=[];d;d=d.F)u.push(d);if(i=i.M,d=c.type||c,typeof c=="string")c=new ft(c,i);else if(c instanceof ft)c.target=c.target||i;else{var A=c;c=new ft(d,i),y(c,A)}if(A=!0,u)for(var R=u.length-1;0<=R;R--){var V=c.g=u[R];A=$n(V,d,!0,c)&&A}if(V=c.g=i,A=$n(V,d,!0,c)&&A,A=$n(V,d,!1,c)&&A,u)for(R=0;R<u.length;R++)V=c.g=u[R],A=$n(V,d,!1,c)&&A}mt.prototype.N=function(){if(mt.aa.N.call(this),this.i){var i=this.i,c;for(c in i.g){for(var u=i.g[c],d=0;d<u.length;d++)qn(u[d]);delete i.g[c],i.h--}}this.F=null},mt.prototype.K=function(i,c,u,d){return this.i.add(String(i),c,!1,u,d)},mt.prototype.L=function(i,c,u,d){return this.i.add(String(i),c,!0,u,d)};function $n(i,c,u,d){if(c=i.i.g[String(c)],!c)return!0;c=c.concat();for(var A=!0,R=0;R<c.length;++R){var V=c[R];if(V&&!V.da&&V.capture==u){var Q=V.listener,ht=V.ha||V.src;V.fa&&ts(i.i,V),A=Q.call(ht,d)!==!1&&A}}return A&&!d.defaultPrevented}function Ui(i,c,u){if(typeof i=="function")u&&(i=T(i,u));else if(i&&typeof i.handleEvent=="function")i=T(i.handleEvent,i);else throw Error("Invalid listener argument");return 2147483647<Number(c)?-1:l.setTimeout(i,c||0)}function Bi(i){i.g=Ui(()=>{i.g=null,i.i&&(i.i=!1,Bi(i))},i.l);const c=i.h;i.h=null,i.m.apply(null,c)}class Wu extends Qt{constructor(c,u){super(),this.m=c,this.l=u,this.h=null,this.i=!1,this.g=null}j(c){this.h=arguments,this.g?this.i=!0:Bi(this)}N(){super.N(),this.g&&(l.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Xe(i){Qt.call(this),this.h=i,this.g={}}b(Xe,Qt);var qi=[];function ji(i){lt(i.g,function(c,u){this.g.hasOwnProperty(u)&&ss(c)},i),i.g={}}Xe.prototype.N=function(){Xe.aa.N.call(this),ji(this)},Xe.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var as=l.JSON.stringify,Xu=l.JSON.parse,Yu=class{stringify(i){return l.JSON.stringify(i,void 0)}parse(i){return l.JSON.parse(i,void 0)}};function cs(){}cs.prototype.h=null;function $i(i){return i.h||(i.h=i.i())}function zi(){}var Ye={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function us(){ft.call(this,"d")}b(us,ft);function ls(){ft.call(this,"c")}b(ls,ft);var de={},Gi=null;function zn(){return Gi=Gi||new mt}de.La="serverreachability";function Hi(i){ft.call(this,de.La,i)}b(Hi,ft);function Je(i){const c=zn();Tt(c,new Hi(c))}de.STAT_EVENT="statevent";function Ki(i,c){ft.call(this,de.STAT_EVENT,i),this.stat=c}b(Ki,ft);function vt(i){const c=zn();Tt(c,new Ki(c,i))}de.Ma="timingevent";function Qi(i,c){ft.call(this,de.Ma,i),this.size=c}b(Qi,ft);function Ze(i,c){if(typeof i!="function")throw Error("Fn must not be null and must be a function");return l.setTimeout(function(){i()},c)}function tn(){this.g=!0}tn.prototype.xa=function(){this.g=!1};function Ju(i,c,u,d,A,R){i.info(function(){if(i.g)if(R)for(var V="",Q=R.split("&"),ht=0;ht<Q.length;ht++){var H=Q[ht].split("=");if(1<H.length){var pt=H[0];H=H[1];var gt=pt.split("_");V=2<=gt.length&&gt[1]=="type"?V+(pt+"="+H+"&"):V+(pt+"=redacted&")}}else V=null;else V=R;return"XMLHTTP REQ ("+d+") [attempt "+A+"]: "+c+`
390`+u+`
391`+V})}function Zu(i,c,u,d,A,R,V){i.info(function(){return"XMLHTTP RESP ("+d+") [ attempt "+A+"]: "+c+`
392`+u+`
393`+R+" "+V})}function we(i,c,u,d){i.info(function(){return"XMLHTTP TEXT ("+c+"): "+el(i,u)+(d?" "+d:"")})}function tl(i,c){i.info(function(){return"TIMEOUT: "+c})}tn.prototype.info=function(){};function el(i,c){if(!i.g)return c;if(!c)return null;try{var u=JSON.parse(c);if(u){for(i=0;i<u.length;i++)if(Array.isArray(u[i])){var d=u[i];if(!(2>d.length)){var A=d[1];if(Array.isArray(A)&&!(1>A.length)){var R=A[0];if(R!="noop"&&R!="stop"&&R!="close")for(var V=1;V<A.length;V++)A[V]=""}}}}return as(u)}catch{return c}}var Gn={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Wi={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},hs;function Hn(){}b(Hn,cs),Hn.prototype.g=function(){return new XMLHttpRequest},Hn.prototype.i=function(){return{}},hs=new Hn;function Wt(i,c,u,d){this.j=i,this.i=c,this.l=u,this.R=d||1,this.U=new Xe(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 Xi}function Xi(){this.i=null,this.g="",this.h=!1}var Yi={},ds={};function fs(i,c,u){i.L=1,i.v=Xn(Bt(c)),i.m=u,i.P=!0,Ji(i,null)}function Ji(i,c){i.F=Date.now(),Kn(i),i.A=Bt(i.v);var u=i.A,d=i.R;Array.isArray(d)||(d=[String(d)]),fo(u.i,"t",d),i.C=0,u=i.j.J,i.h=new Xi,i.g=Do(i.j,u?c:null,!i.m),0<i.O&&(i.M=new Wu(T(i.Y,i,i.g),i.O)),c=i.U,u=i.g,d=i.ca;var A="readystatechange";Array.isArray(A)||(A&&(qi[0]=A.toString()),A=qi);for(var R=0;R<A.length;R++){var V=Mi(u,A[R],d||c.handleEvent,!1,c.h||c);if(!V)break;c.g[V.key]=V}c=i.H?p(i.H):{},i.m?(i.u||(i.u="POST"),c["Content-Type"]="application/x-www-form-urlencoded",i.g.ea(i.A,i.u,i.m,c)):(i.u="GET",i.g.ea(i.A,i.u,null,c)),Je(),Ju(i.i,i.u,i.A,i.l,i.R,i.m)}Wt.prototype.ca=function(i){i=i.target;const c=this.M;c&&qt(i)==3?c.j():this.Y(i)},Wt.prototype.Y=function(i){try{if(i==this.g)t:{const gt=qt(this.g);var c=this.g.Ba();const Ce=this.g.Z();if(!(3>gt)&&(gt!=3||this.g&&(this.h.h||this.g.oa()||To(this.g)))){this.J||gt!=4||c==7||(c==8||0>=Ce?Je(3):Je(2)),ms(this);var u=this.g.Z();this.X=u;e:if(Zi(this)){var d=To(this.g);i="";var A=d.length,R=qt(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){fe(this),en(this);var V="";break e}this.h.i=new l.TextDecoder}for(c=0;c<A;c++)this.h.h=!0,i+=this.h.i.decode(d[c],{stream:!(R&&c==A-1)});d.length=0,this.h.g+=i,this.C=0,V=this.h.g}else V=this.g.oa();if(this.o=u==200,Zu(this.i,this.u,this.A,this.l,this.R,gt,u),this.o){if(this.T&&!this.K){e:{if(this.g){var Q,ht=this.g;if((Q=ht.g?ht.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!U(Q)){var H=Q;break e}}H=null}if(u=H)we(this.i,this.l,u,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,ps(this,u);else{this.o=!1,this.s=3,vt(12),fe(this),en(this);break t}}if(this.P){u=!0;let Vt;for(;!this.J&&this.C<V.length;)if(Vt=nl(this,V),Vt==ds){gt==4&&(this.s=4,vt(14),u=!1),we(this.i,this.l,null,"[Incomplete Response]");break}else if(Vt==Yi){this.s=4,vt(15),we(this.i,this.l,V,"[Invalid Chunk]"),u=!1;break}else we(this.i,this.l,Vt,null),ps(this,Vt);if(Zi(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),gt!=4||V.length!=0||this.h.h||(this.s=1,vt(16),u=!1),this.o=this.o&&u,!u)we(this.i,this.l,V,"[Invalid Chunked Response]"),fe(this),en(this);else if(0<V.length&&!this.W){this.W=!0;var pt=this.j;pt.g==this&&pt.ba&&!pt.M&&(pt.j.info("Great, no buffering proxy detected. Bytes received: "+V.length),vs(pt),pt.M=!0,vt(11))}}else we(this.i,this.l,V,null),ps(this,V);gt==4&&fe(this),this.o&&!this.J&&(gt==4?Co(this.j,this):(this.o=!1,Kn(this)))}else El(this.g),u==400&&0<V.indexOf("Unknown SID")?(this.s=3,vt(12)):(this.s=0,vt(13)),fe(this),en(this)}}}catch{}finally{}};function Zi(i){return i.g?i.u=="GET"&&i.L!=2&&i.j.Ca:!1}function nl(i,c){var u=i.C,d=c.indexOf(`
394`,u);return d==-1?ds:(u=Number(c.substring(u,d)),isNaN(u)?Yi:(d+=1,d+u>c.length?ds:(c=c.slice(d,d+u),i.C=d+u,c)))}Wt.prototype.cancel=function(){this.J=!0,fe(this)};function Kn(i){i.S=Date.now()+i.I,to(i,i.I)}function to(i,c){if(i.B!=null)throw Error("WatchDog timer not null");i.B=Ze(T(i.ba,i),c)}function ms(i){i.B&&(l.clearTimeout(i.B),i.B=null)}Wt.prototype.ba=function(){this.B=null;const i=Date.now();0<=i-this.S?(tl(this.i,this.A),this.L!=2&&(Je(),vt(17)),fe(this),this.s=2,en(this)):to(this,this.S-i)};function en(i){i.j.G==0||i.J||Co(i.j,i)}function fe(i){ms(i);var c=i.M;c&&typeof c.ma=="function"&&c.ma(),i.M=null,ji(i.U),i.g&&(c=i.g,i.g=null,c.abort(),c.ma())}function ps(i,c){try{var u=i.j;if(u.G!=0&&(u.g==i||gs(u.h,i))){if(!i.K&&gs(u.h,i)&&u.G==3){try{var d=u.Da.g.parse(c)}catch{d=null}if(Array.isArray(d)&&d.length==3){var A=d;if(A[0]==0){t:if(!u.u){if(u.g)if(u.g.F+3e3<i.F)nr(u),tr(u);else break t;Ts(u),vt(18)}}else u.za=A[1],0<u.za-u.T&&37500>A[2]&&u.F&&u.v==0&&!u.C&&(u.C=Ze(T(u.Za,u),6e3));if(1>=ro(u.h)&&u.ca){try{u.ca()}catch{}u.ca=void 0}}else pe(u,11)}else if((i.K||u.g==i)&&nr(u),!U(c))for(A=u.Da.g.parse(c),c=0;c<A.length;c++){let H=A[c];if(u.T=H[0],H=H[1],u.G==2)if(H[0]=="c"){u.K=H[1],u.ia=H[2];const pt=H[3];pt!=null&&(u.la=pt,u.j.info("VER="+u.la));const gt=H[4];gt!=null&&(u.Aa=gt,u.j.info("SVER="+u.Aa));const Ce=H[5];Ce!=null&&typeof Ce=="number"&&0<Ce&&(d=1.5*Ce,u.L=d,u.j.info("backChannelRequestTimeoutMs_="+d)),d=u;const Vt=i.g;if(Vt){const sr=Vt.g?Vt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(sr){var R=d.h;R.g||sr.indexOf("spdy")==-1&&sr.indexOf("quic")==-1&&sr.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(_s(R,R.h),R.h=null))}if(d.D){const Is=Vt.g?Vt.g.getResponseHeader("X-HTTP-Session-Id"):null;Is&&(d.ya=Is,Y(d.I,d.D,Is))}}u.G=3,u.l&&u.l.ua(),u.ba&&(u.R=Date.now()-i.F,u.j.info("Handshake RTT: "+u.R+"ms")),d=u;var V=i;if(d.qa=bo(d,d.J?d.ia:null,d.W),V.K){so(d.h,V);var Q=V,ht=d.L;ht&&(Q.I=ht),Q.B&&(ms(Q),Kn(Q)),d.g=V}else Ro(d);0<u.i.length&&er(u)}else H[0]!="stop"&&H[0]!="close"||pe(u,7);else u.G==3&&(H[0]=="stop"||H[0]=="close"?H[0]=="stop"?pe(u,7):Es(u):H[0]!="noop"&&u.l&&u.l.ta(H),u.v=0)}}Je(4)}catch{}}var rl=class{constructor(i,c){this.g=i,this.map=c}};function eo(i){this.l=i||10,l.PerformanceNavigationTiming?(i=l.performance.getEntriesByType("navigation"),i=0<i.length&&(i[0].nextHopProtocol=="hq"||i[0].nextHopProtocol=="h2")):i=!!(l.chrome&&l.chrome.loadTimes&&l.chrome.loadTimes()&&l.chrome.loadTimes().wasFetchedViaSpdy),this.j=i?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function no(i){return i.h?!0:i.g?i.g.size>=i.j:!1}function ro(i){return i.h?1:i.g?i.g.size:0}function gs(i,c){return i.h?i.h==c:i.g?i.g.has(c):!1}function _s(i,c){i.g?i.g.add(c):i.h=c}function so(i,c){i.h&&i.h==c?i.h=null:i.g&&i.g.has(c)&&i.g.delete(c)}eo.prototype.cancel=function(){if(this.i=io(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const i of this.g.values())i.cancel();this.g.clear()}};function io(i){if(i.h!=null)return i.i.concat(i.h.D);if(i.g!=null&&i.g.size!==0){let c=i.i;for(const u of i.g.values())c=c.concat(u.D);return c}return O(i.i)}function sl(i){if(i.V&&typeof i.V=="function")return i.V();if(typeof Map<"u"&&i instanceof Map||typeof Set<"u"&&i instanceof Set)return Array.from(i.values());if(typeof i=="string")return i.split("");if(h(i)){for(var c=[],u=i.length,d=0;d<u;d++)c.push(i[d]);return c}c=[],u=0;for(d in i)c[u++]=i[d];return c}function il(i){if(i.na&&typeof i.na=="function")return i.na();if(!i.V||typeof i.V!="function"){if(typeof Map<"u"&&i instanceof Map)return Array.from(i.keys());if(!(typeof Set<"u"&&i instanceof Set)){if(h(i)||typeof i=="string"){var c=[];i=i.length;for(var u=0;u<i;u++)c.push(u);return c}c=[],u=0;for(const d in i)c[u++]=d;return c}}}function oo(i,c){if(i.forEach&&typeof i.forEach=="function")i.forEach(c,void 0);else if(h(i)||typeof i=="string")Array.prototype.forEach.call(i,c,void 0);else for(var u=il(i),d=sl(i),A=d.length,R=0;R<A;R++)c.call(void 0,d[R],u&&u[R],i)}var ao=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function ol(i,c){if(i){i=i.split("&");for(var u=0;u<i.length;u++){var d=i[u].indexOf("="),A=null;if(0<=d){var R=i[u].substring(0,d);A=i[u].substring(d+1)}else R=i[u];c(R,A?decodeURIComponent(A.replace(/\+/g," ")):"")}}}function me(i){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,i instanceof me){this.h=i.h,Qn(this,i.j),this.o=i.o,this.g=i.g,Wn(this,i.s),this.l=i.l;var c=i.i,u=new sn;u.i=c.i,c.g&&(u.g=new Map(c.g),u.h=c.h),co(this,u),this.m=i.m}else i&&(c=String(i).match(ao))?(this.h=!1,Qn(this,c[1]||"",!0),this.o=nn(c[2]||""),this.g=nn(c[3]||"",!0),Wn(this,c[4]),this.l=nn(c[5]||"",!0),co(this,c[6]||"",!0),this.m=nn(c[7]||"")):(this.h=!1,this.i=new sn(null,this.h))}me.prototype.toString=function(){var i=[],c=this.j;c&&i.push(rn(c,uo,!0),":");var u=this.g;return(u||c=="file")&&(i.push("//"),(c=this.o)&&i.push(rn(c,uo,!0),"@"),i.push(encodeURIComponent(String(u)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),u=this.s,u!=null&&i.push(":",String(u))),(u=this.l)&&(this.g&&u.charAt(0)!="/"&&i.push("/"),i.push(rn(u,u.charAt(0)=="/"?ul:cl,!0))),(u=this.i.toString())&&i.push("?",u),(u=this.m)&&i.push("#",rn(u,hl)),i.join("")};function Bt(i){return new me(i)}function Qn(i,c,u){i.j=u?nn(c,!0):c,i.j&&(i.j=i.j.replace(/:$/,""))}function Wn(i,c){if(c){if(c=Number(c),isNaN(c)||0>c)throw Error("Bad port number "+c);i.s=c}else i.s=null}function co(i,c,u){c instanceof sn?(i.i=c,dl(i.i,i.h)):(u||(c=rn(c,ll)),i.i=new sn(c,i.h))}function Y(i,c,u){i.i.set(c,u)}function Xn(i){return Y(i,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),i}function nn(i,c){return i?c?decodeURI(i.replace(/%25/g,"%2525")):decodeURIComponent(i):""}function rn(i,c,u){return typeof i=="string"?(i=encodeURI(i).replace(c,al),u&&(i=i.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),i):null}function al(i){return i=i.charCodeAt(0),"%"+(i>>4&15).toString(16)+(i&15).toString(16)}var uo=/[#\/\?@]/g,cl=/[#\?:]/g,ul=/[#\?]/g,ll=/[#\?@]/g,hl=/#/g;function sn(i,c){this.h=this.g=null,this.i=i||null,this.j=!!c}function Xt(i){i.g||(i.g=new Map,i.h=0,i.i&&ol(i.i,function(c,u){i.add(decodeURIComponent(c.replace(/\+/g," ")),u)}))}n=sn.prototype,n.add=function(i,c){Xt(this),this.i=null,i=Re(this,i);var u=this.g.get(i);return u||this.g.set(i,u=[]),u.push(c),this.h+=1,this};function lo(i,c){Xt(i),c=Re(i,c),i.g.has(c)&&(i.i=null,i.h-=i.g.get(c).length,i.g.delete(c))}function ho(i,c){return Xt(i),c=Re(i,c),i.g.has(c)}n.forEach=function(i,c){Xt(this),this.g.forEach(function(u,d){u.forEach(function(A){i.call(c,A,d,this)},this)},this)},n.na=function(){Xt(this);const i=Array.from(this.g.values()),c=Array.from(this.g.keys()),u=[];for(let d=0;d<c.length;d++){const A=i[d];for(let R=0;R<A.length;R++)u.push(c[d])}return u},n.V=function(i){Xt(this);let c=[];if(typeof i=="string")ho(this,i)&&(c=c.concat(this.g.get(Re(this,i))));else{i=Array.from(this.g.values());for(let u=0;u<i.length;u++)c=c.concat(i[u])}return c},n.set=function(i,c){return Xt(this),this.i=null,i=Re(this,i),ho(this,i)&&(this.h-=this.g.get(i).length),this.g.set(i,[c]),this.h+=1,this},n.get=function(i,c){return i?(i=this.V(i),0<i.length?String(i[0]):c):c};function fo(i,c,u){lo(i,c),0<u.length&&(i.i=null,i.g.set(Re(i,c),O(u)),i.h+=u.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const i=[],c=Array.from(this.g.keys());for(var u=0;u<c.length;u++){var d=c[u];const R=encodeURIComponent(String(d)),V=this.V(d);for(d=0;d<V.length;d++){var A=R;V[d]!==""&&(A+="="+encodeURIComponent(String(V[d]))),i.push(A)}}return this.i=i.join("&")};function Re(i,c){return c=String(c),i.j&&(c=c.toLowerCase()),c}function dl(i,c){c&&!i.j&&(Xt(i),i.i=null,i.g.forEach(function(u,d){var A=d.toLowerCase();d!=A&&(lo(this,d),fo(this,A,u))},i)),i.j=c}function fl(i,c){const u=new tn;if(l.Image){const d=new Image;d.onload=P(Yt,u,"TestLoadImage: loaded",!0,c,d),d.onerror=P(Yt,u,"TestLoadImage: error",!1,c,d),d.onabort=P(Yt,u,"TestLoadImage: abort",!1,c,d),d.ontimeout=P(Yt,u,"TestLoadImage: timeout",!1,c,d),l.setTimeout(function(){d.ontimeout&&d.ontimeout()},1e4),d.src=i}else c(!1)}function ml(i,c){const u=new tn,d=new AbortController,A=setTimeout(()=>{d.abort(),Yt(u,"TestPingServer: timeout",!1,c)},1e4);fetch(i,{signal:d.signal}).then(R=>{clearTimeout(A),R.ok?Yt(u,"TestPingServer: ok",!0,c):Yt(u,"TestPingServer: server error",!1,c)}).catch(()=>{clearTimeout(A),Yt(u,"TestPingServer: error",!1,c)})}function Yt(i,c,u,d,A){try{A&&(A.onload=null,A.onerror=null,A.onabort=null,A.ontimeout=null),d(u)}catch{}}function pl(){this.g=new Yu}function gl(i,c,u){const d=u||"";try{oo(i,function(A,R){let V=A;f(A)&&(V=as(A)),c.push(d+R+"="+encodeURIComponent(V))})}catch(A){throw c.push(d+"type="+encodeURIComponent("_badmap")),A}}function Yn(i){this.l=i.Ub||null,this.j=i.eb||!1}b(Yn,cs),Yn.prototype.g=function(){return new Jn(this.l,this.j)},Yn.prototype.i=function(i){return function(){return i}}({});function Jn(i,c){mt.call(this),this.D=i,this.o=c,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}b(Jn,mt),n=Jn.prototype,n.open=function(i,c){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=i,this.A=c,this.readyState=1,an(this)},n.send=function(i){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const c={headers:this.u,method:this.B,credentials:this.m,cache:void 0};i&&(c.body=i),(this.D||l).fetch(new Request(this.A,c)).then(this.Sa.bind(this),this.ga.bind(this))},n.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,on(this)),this.readyState=0},n.Sa=function(i){if(this.g&&(this.l=i,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=i.headers,this.readyState=2,an(this)),this.g&&(this.readyState=3,an(this),this.g)))if(this.responseType==="arraybuffer")i.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof l.ReadableStream<"u"&&"body"in i){if(this.j=i.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;mo(this)}else i.text().then(this.Ra.bind(this),this.ga.bind(this))};function mo(i){i.j.read().then(i.Pa.bind(i)).catch(i.ga.bind(i))}n.Pa=function(i){if(this.g){if(this.o&&i.value)this.response.push(i.value);else if(!this.o){var c=i.value?i.value:new Uint8Array(0);(c=this.v.decode(c,{stream:!i.done}))&&(this.response=this.responseText+=c)}i.done?on(this):an(this),this.readyState==3&&mo(this)}},n.Ra=function(i){this.g&&(this.response=this.responseText=i,on(this))},n.Qa=function(i){this.g&&(this.response=i,on(this))},n.ga=function(){this.g&&on(this)};function on(i){i.readyState=4,i.l=null,i.j=null,i.v=null,an(i)}n.setRequestHeader=function(i,c){this.u.append(i,c)},n.getResponseHeader=function(i){return this.h&&this.h.get(i.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const i=[],c=this.h.entries();for(var u=c.next();!u.done;)u=u.value,i.push(u[0]+": "+u[1]),u=c.next();return i.join(`\r
395`)};function an(i){i.onreadystatechange&&i.onreadystatechange.call(i)}Object.defineProperty(Jn.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(i){this.m=i?"include":"same-origin"}});function po(i){let c="";return lt(i,function(u,d){c+=d,c+=":",c+=u,c+=`\r
396`}),c}function ys(i,c,u){t:{for(d in u){var d=!1;break t}d=!0}d||(u=po(u),typeof i=="string"?u!=null&&encodeURIComponent(String(u)):Y(i,c,u))}function tt(i){mt.call(this),this.headers=new Map,this.o=i||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}b(tt,mt);var _l=/^https?$/i,yl=["POST","PUT"];n=tt.prototype,n.Ha=function(i){this.J=i},n.ea=function(i,c,u,d){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+i);c=c?c.toUpperCase():"GET",this.D=i,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():hs.g(),this.v=this.o?$i(this.o):$i(hs),this.g.onreadystatechange=T(this.Ea,this);try{this.B=!0,this.g.open(c,String(i),!0),this.B=!1}catch(R){go(this,R);return}if(i=u||"",u=new Map(this.headers),d)if(Object.getPrototypeOf(d)===Object.prototype)for(var A in d)u.set(A,d[A]);else if(typeof d.keys=="function"&&typeof d.get=="function")for(const R of d.keys())u.set(R,d.get(R));else throw Error("Unknown input type for opt_headers: "+String(d));d=Array.from(u.keys()).find(R=>R.toLowerCase()=="content-type"),A=l.FormData&&i instanceof l.FormData,!(0<=Array.prototype.indexOf.call(yl,c,void 0))||d||A||u.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,V]of u)this.g.setRequestHeader(R,V);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Eo(this),this.u=!0,this.g.send(i),this.u=!1}catch(R){go(this,R)}};function go(i,c){i.h=!1,i.g&&(i.j=!0,i.g.abort(),i.j=!1),i.l=c,i.m=5,_o(i),Zn(i)}function _o(i){i.A||(i.A=!0,Tt(i,"complete"),Tt(i,"error"))}n.abort=function(i){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=i||7,Tt(this,"complete"),Tt(this,"abort"),Zn(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Zn(this,!0)),tt.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?yo(this):this.bb())},n.bb=function(){yo(this)};function yo(i){if(i.h&&typeof a<"u"&&(!i.v[1]||qt(i)!=4||i.Z()!=2)){if(i.u&&qt(i)==4)Ui(i.Ea,0,i);else if(Tt(i,"readystatechange"),qt(i)==4){i.h=!1;try{const V=i.Z();t:switch(V){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var c=!0;break t;default:c=!1}var u;if(!(u=c)){var d;if(d=V===0){var A=String(i.D).match(ao)[1]||null;!A&&l.self&&l.self.location&&(A=l.self.location.protocol.slice(0,-1)),d=!_l.test(A?A.toLowerCase():"")}u=d}if(u)Tt(i,"complete"),Tt(i,"success");else{i.m=6;try{var R=2<qt(i)?i.g.statusText:""}catch{R=""}i.l=R+" ["+i.Z()+"]",_o(i)}}finally{Zn(i)}}}}function Zn(i,c){if(i.g){Eo(i);const u=i.g,d=i.v[0]?()=>{}:null;i.g=null,i.v=null,c||Tt(i,"ready");try{u.onreadystatechange=d}catch{}}}function Eo(i){i.I&&(l.clearTimeout(i.I),i.I=null)}n.isActive=function(){return!!this.g};function qt(i){return i.g?i.g.readyState:0}n.Z=function(){try{return 2<qt(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(i){if(this.g){var c=this.g.responseText;return i&&c.indexOf(i)==0&&(c=c.substring(i.length)),Xu(c)}};function To(i){try{if(!i.g)return null;if("response"in i.g)return i.g.response;switch(i.H){case"":case"text":return i.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in i.g)return i.g.mozResponseArrayBuffer}return null}catch{return null}}function El(i){const c={};i=(i.g&&2<=qt(i)&&i.g.getAllResponseHeaders()||"").split(`\r
397`);for(let d=0;d<i.length;d++){if(U(i[d]))continue;var u=v(i[d]);const A=u[0];if(u=u[1],typeof u!="string")continue;u=u.trim();const R=c[A]||[];c[A]=R,R.push(u)}I(c,function(d){return d.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function cn(i,c,u){return u&&u.internalChannelParams&&u.internalChannelParams[i]||c}function vo(i){this.Aa=0,this.i=[],this.j=new tn,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=cn("failFast",!1,i),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=cn("baseRetryDelayMs",5e3,i),this.cb=cn("retryDelaySeedMs",1e4,i),this.Wa=cn("forwardChannelMaxRetries",2,i),this.wa=cn("forwardChannelRequestTimeoutMs",2e4,i),this.pa=i&&i.xmlHttpFactory||void 0,this.Xa=i&&i.Tb||void 0,this.Ca=i&&i.useFetchStreams||!1,this.L=void 0,this.J=i&&i.supportsCrossDomainXhr||!1,this.K="",this.h=new eo(i&&i.concurrentRequestLimit),this.Da=new pl,this.P=i&&i.fastHandshake||!1,this.O=i&&i.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=i&&i.Rb||!1,i&&i.xa&&this.j.xa(),i&&i.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&i&&i.detectBufferingProxy||!1,this.ja=void 0,i&&i.longPollingTimeout&&0<i.longPollingTimeout&&(this.ja=i.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=vo.prototype,n.la=8,n.G=1,n.connect=function(i,c,u,d){vt(0),this.W=i,this.H=c||{},u&&d!==void 0&&(this.H.OSID=u,this.H.OAID=d),this.F=this.X,this.I=bo(this,null,this.W),er(this)};function Es(i){if(Io(i),i.G==3){var c=i.U++,u=Bt(i.I);if(Y(u,"SID",i.K),Y(u,"RID",c),Y(u,"TYPE","terminate"),un(i,u),c=new Wt(i,i.j,c),c.L=2,c.v=Xn(Bt(u)),u=!1,l.navigator&&l.navigator.sendBeacon)try{u=l.navigator.sendBeacon(c.v.toString(),"")}catch{}!u&&l.Image&&(new Image().src=c.v,u=!0),u||(c.g=Do(c.j,null),c.g.ea(c.v)),c.F=Date.now(),Kn(c)}Vo(i)}function tr(i){i.g&&(vs(i),i.g.cancel(),i.g=null)}function Io(i){tr(i),i.u&&(l.clearTimeout(i.u),i.u=null),nr(i),i.h.cancel(),i.s&&(typeof i.s=="number"&&l.clearTimeout(i.s),i.s=null)}function er(i){if(!no(i.h)&&!i.s){i.s=!0;var c=i.Ga;Ke||Oi(),Qe||(Ke(),Qe=!0),Zr.add(c,i),i.B=0}}function Tl(i,c){return ro(i.h)>=i.h.j-(i.s?1:0)?!1:i.s?(i.i=c.D.concat(i.i),!0):i.G==1||i.G==2||i.B>=(i.Va?0:i.Wa)?!1:(i.s=Ze(T(i.Ga,i,c),Po(i,i.B)),i.B++,!0)}n.Ga=function(i){if(this.s)if(this.s=null,this.G==1){if(!i){this.U=Math.floor(1e5*Math.random()),i=this.U++;const A=new Wt(this,this.j,i);let R=this.o;if(this.S&&(R?(R=p(R),y(R,this.S)):R=this.S),this.m!==null||this.O||(A.H=R,R=null),this.P)t:{for(var c=0,u=0;u<this.i.length;u++){e:{var d=this.i[u];if("__data__"in d.map&&(d=d.map.__data__,typeof d=="string")){d=d.length;break e}d=void 0}if(d===void 0)break;if(c+=d,4096<c){c=u;break t}if(c===4096||u===this.i.length-1){c=u+1;break t}}c=1e3}else c=1e3;c=wo(this,A,c),u=Bt(this.I),Y(u,"RID",i),Y(u,"CVER",22),this.D&&Y(u,"X-HTTP-Session-Id",this.D),un(this,u),R&&(this.O?c="headers="+encodeURIComponent(String(po(R)))+"&"+c:this.m&&ys(u,this.m,R)),_s(this.h,A),this.Ua&&Y(u,"TYPE","init"),this.P?(Y(u,"$req",c),Y(u,"SID","null"),A.T=!0,fs(A,u,null)):fs(A,u,c),this.G=2}}else this.G==3&&(i?Ao(this,i):this.i.length==0||no(this.h)||Ao(this))};function Ao(i,c){var u;c?u=c.l:u=i.U++;const d=Bt(i.I);Y(d,"SID",i.K),Y(d,"RID",u),Y(d,"AID",i.T),un(i,d),i.m&&i.o&&ys(d,i.m,i.o),u=new Wt(i,i.j,u,i.B+1),i.m===null&&(u.H=i.o),c&&(i.i=c.D.concat(i.i)),c=wo(i,u,1e3),u.I=Math.round(.5*i.wa)+Math.round(.5*i.wa*Math.random()),_s(i.h,u),fs(u,d,c)}function un(i,c){i.H&&lt(i.H,function(u,d){Y(c,d,u)}),i.l&&oo({},function(u,d){Y(c,d,u)})}function wo(i,c,u){u=Math.min(i.i.length,u);var d=i.l?T(i.l.Na,i.l,i):null;t:{var A=i.i;let R=-1;for(;;){const V=["count="+u];R==-1?0<u?(R=A[0].g,V.push("ofs="+R)):R=0:V.push("ofs="+R);let Q=!0;for(let ht=0;ht<u;ht++){let H=A[ht].g;const pt=A[ht].map;if(H-=R,0>H)R=Math.max(0,A[ht].g-100),Q=!1;else try{gl(pt,V,"req"+H+"_")}catch{d&&d(pt)}}if(Q){d=V.join("&");break t}}}return i=i.i.splice(0,u),c.D=i,d}function Ro(i){if(!i.g&&!i.u){i.Y=1;var c=i.Fa;Ke||Oi(),Qe||(Ke(),Qe=!0),Zr.add(c,i),i.v=0}}function Ts(i){return i.g||i.u||3<=i.v?!1:(i.Y++,i.u=Ze(T(i.Fa,i),Po(i,i.v)),i.v++,!0)}n.Fa=function(){if(this.u=null,So(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var i=2*this.R;this.j.info("BP detection timer enabled: "+i),this.A=Ze(T(this.ab,this),i)}},n.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,vt(10),tr(this),So(this))};function vs(i){i.A!=null&&(l.clearTimeout(i.A),i.A=null)}function So(i){i.g=new Wt(i,i.j,"rpc",i.Y),i.m===null&&(i.g.H=i.o),i.g.O=0;var c=Bt(i.qa);Y(c,"RID","rpc"),Y(c,"SID",i.K),Y(c,"AID",i.T),Y(c,"CI",i.F?"0":"1"),!i.F&&i.ja&&Y(c,"TO",i.ja),Y(c,"TYPE","xmlhttp"),un(i,c),i.m&&i.o&&ys(c,i.m,i.o),i.L&&(i.g.I=i.L);var u=i.g;i=i.ia,u.L=1,u.v=Xn(Bt(c)),u.m=null,u.P=!0,Ji(u,i)}n.Za=function(){this.C!=null&&(this.C=null,tr(this),Ts(this),vt(19))};function nr(i){i.C!=null&&(l.clearTimeout(i.C),i.C=null)}function Co(i,c){var u=null;if(i.g==c){nr(i),vs(i),i.g=null;var d=2}else if(gs(i.h,c))u=c.D,so(i.h,c),d=1;else return;if(i.G!=0){if(c.o)if(d==1){u=c.m?c.m.length:0,c=Date.now()-c.F;var A=i.B;d=zn(),Tt(d,new Qi(d,u)),er(i)}else Ro(i);else if(A=c.s,A==3||A==0&&0<c.X||!(d==1&&Tl(i,c)||d==2&&Ts(i)))switch(u&&0<u.length&&(c=i.h,c.i=c.i.concat(u)),A){case 1:pe(i,5);break;case 4:pe(i,10);break;case 3:pe(i,6);break;default:pe(i,2)}}}function Po(i,c){let u=i.Ta+Math.floor(Math.random()*i.cb);return i.isActive()||(u*=2),u*c}function pe(i,c){if(i.j.info("Error code "+c),c==2){var u=T(i.fb,i),d=i.Xa;const A=!d;d=new me(d||"//www.google.com/images/cleardot.gif"),l.location&&l.location.protocol=="http"||Qn(d,"https"),Xn(d),A?fl(d.toString(),u):ml(d.toString(),u)}else vt(2);i.G=0,i.l&&i.l.sa(c),Vo(i),Io(i)}n.fb=function(i){i?(this.j.info("Successfully pinged google.com"),vt(2)):(this.j.info("Failed to ping google.com"),vt(1))};function Vo(i){if(i.G=0,i.ka=[],i.l){const c=io(i.h);(c.length!=0||i.i.length!=0)&&(D(i.ka,c),D(i.ka,i.i),i.h.i.length=0,O(i.i),i.i.length=0),i.l.ra()}}function bo(i,c,u){var d=u instanceof me?Bt(u):new me(u);if(d.g!="")c&&(d.g=c+"."+d.g),Wn(d,d.s);else{var A=l.location;d=A.protocol,c=c?c+"."+A.hostname:A.hostname,A=+A.port;var R=new me(null);d&&Qn(R,d),c&&(R.g=c),A&&Wn(R,A),u&&(R.l=u),d=R}return u=i.D,c=i.ya,u&&c&&Y(d,u,c),Y(d,"VER",i.la),un(i,d),d}function Do(i,c,u){if(c&&!i.J)throw Error("Can't create secondary domain capable XhrIo object.");return c=i.Ca&&!i.pa?new tt(new Yn({eb:u})):new tt(i.pa),c.Ha(i.J),c}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function No(){}n=No.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function rr(){}rr.prototype.g=function(i,c){return new wt(i,c)};function wt(i,c){mt.call(this),this.g=new vo(c),this.l=i,this.h=c&&c.messageUrlParams||null,i=c&&c.messageHeaders||null,c&&c.clientProtocolHeaderRequired&&(i?i["X-Client-Protocol"]="webchannel":i={"X-Client-Protocol":"webchannel"}),this.g.o=i,i=c&&c.initMessageHeaders||null,c&&c.messageContentType&&(i?i["X-WebChannel-Content-Type"]=c.messageContentType:i={"X-WebChannel-Content-Type":c.messageContentType}),c&&c.va&&(i?i["X-WebChannel-Client-Profile"]=c.va:i={"X-WebChannel-Client-Profile":c.va}),this.g.S=i,(i=c&&c.Sb)&&!U(i)&&(this.g.m=i),this.v=c&&c.supportsCrossDomainXhr||!1,this.u=c&&c.sendRawJson||!1,(c=c&&c.httpSessionIdParam)&&!U(c)&&(this.g.D=c,i=this.h,i!==null&&c in i&&(i=this.h,c in i&&delete i[c])),this.j=new Se(this)}b(wt,mt),wt.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},wt.prototype.close=function(){Es(this.g)},wt.prototype.o=function(i){var c=this.g;if(typeof i=="string"){var u={};u.__data__=i,i=u}else this.u&&(u={},u.__data__=as(i),i=u);c.i.push(new rl(c.Ya++,i)),c.G==3&&er(c)},wt.prototype.N=function(){this.g.l=null,delete this.j,Es(this.g),delete this.g,wt.aa.N.call(this)};function ko(i){us.call(this),i.__headers__&&(this.headers=i.__headers__,this.statusCode=i.__status__,delete i.__headers__,delete i.__status__);var c=i.__sm__;if(c){t:{for(const u in c){i=u;break t}i=void 0}(this.i=i)&&(i=this.i,c=c!==null&&i in c?c[i]:void 0),this.data=c}else this.data=i}b(ko,us);function Oo(){ls.call(this),this.status=1}b(Oo,ls);function Se(i){this.g=i}b(Se,No),Se.prototype.ua=function(){Tt(this.g,"a")},Se.prototype.ta=function(i){Tt(this.g,new ko(i))},Se.prototype.sa=function(i){Tt(this.g,new Oo)},Se.prototype.ra=function(){Tt(this.g,"b")},rr.prototype.createWebChannel=rr.prototype.g,wt.prototype.send=wt.prototype.o,wt.prototype.open=wt.prototype.m,wt.prototype.close=wt.prototype.close,oc=function(){return new rr},ic=function(){return zn()},sc=de,Fs={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},Gn.NO_ERROR=0,Gn.TIMEOUT=8,Gn.HTTP_ERROR=6,lr=Gn,Wi.COMPLETE="complete",rc=Wi,zi.EventType=Ye,Ye.OPEN="a",Ye.CLOSE="b",Ye.ERROR="c",Ye.MESSAGE="d",mt.prototype.listen=mt.prototype.K,ln=zi,tt.prototype.listenOnce=tt.prototype.L,tt.prototype.getLastError=tt.prototype.Ka,tt.prototype.getLastErrorCode=tt.prototype.Ba,tt.prototype.getStatus=tt.prototype.Z,tt.prototype.getResponseJson=tt.prototype.Oa,tt.prototype.getResponseText=tt.prototype.oa,tt.prototype.send=tt.prototype.ea,tt.prototype.setWithCredentials=tt.prototype.Ha,nc=tt}).apply(typeof ir<"u"?ir:typeof self<"u"?self:typeof window<"u"?window:{});const Ko="@firebase/firestore",Qo="4.9.1";/**
398 * @license
399 * Copyright 2017 Google LLC
400 *
401 * Licensed under the Apache License, Version 2.0 (the "License");
402 * you may not use this file except in compliance with the License.
403 * You may obtain a copy of the License at
404 *
405 *   http://www.apache.org/licenses/LICENSE-2.0
406 *
407 * Unless required by applicable law or agreed to in writing, softw
407are
408 * distributed under the License is distributed on an "AS IS" BASIS,
409 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
410 * See the License for the specific language governing permissions and
411 * limitations under the License.
412 */class yt{constructor(t){this.uid=t}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}yt.UNAUTHENTICATED=new yt(null),yt.GOOGLE_CREDENTIALS=new yt("google-credentials-uid"),yt.FIRST_PARTY=new yt("first-party-uid"),yt.MOCK_USER=new yt("mock-user");/**
413 * @license
414 * Copyright 2017 Google LLC
415 *
416 * Licensed under the Apache License, Version 2.0 (the "License");
417 * you may not use this file except in compliance with the License.
418 * You may obtain a copy of the License at
419 *
420 *   http://www.apache.org/licenses/LICENSE-2.0
421 *
422 * Unless required by applicable law or agreed to in writing, software
423 * distributed under the License is distributed on an "AS IS" BASIS,
424 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
425 * See the License for the specific language governing permissions and
426 * limitations under the License.
427 */let qe="12.2.0";/**
428 * @license
429 * Copyright 2017 Google LLC
430 *
431 * Licensed under the Apache License, Version 2.0 (the "License");
432 * you may not use this file except in compliance with the License.
433 * You may obtain a copy of the License at
434 *
435 *   http://www.apache.org/licenses/LICENSE-2.0
436 *
437 * Unless required by applicable law or agreed to in writing, software
438 * distributed under the License is distributed on an "AS IS" BASIS,
439 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440 * See the License for the specific language governing permissions and
441 * limitations under the License.
442 */const Ee=new Xa("@firebase/firestore");function Pe(){return Ee.logLevel}function k(n,...t){if(Ee.logLevel<=$.DEBUG){const e=t.map(ii);Ee.debug(`Firestore (${qe}): ${n}`,...e)}}function zt(n,...t){if(Ee.logLevel<=$.ERROR){const e=t.map(ii);Ee.error(`Firestore (${qe}): ${n}`,...e)}}function Te(n,...t){if(Ee.logLevel<=$.WARN){const e=t.map(ii);Ee.warn(`Firestore (${qe}): ${n}`,...e)}}function ii(n){if(typeof n=="string")return n;try{/**
443* @license
444* Copyright 2020 Google LLC
445*
446* Licensed under the Apache License, Version 2.0 (the "License");
447* you may not use this file except in compliance with the License.
448* You may obtain a copy of the License at
449*
450*   http://www.apache.org/licenses/LICENSE-2.0
451*
452* Unless required by applicable law or agreed to in writing, software
453* distributed under the License is distributed on an "AS IS" BASIS,
454* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
455* See the License for the specific language governing permissions and
456* limitations under the License.
457*/return function(e){return JSON.stringify(e)}(n)}catch{return n}}/**
458 * @license
459 * Copyright 2017 Google LLC
460 *
461 * Licensed under the Apache License, Version 2.0 (the "License");
462 * you may not use this file except in compliance with the License.
463 * You may obtain a copy of the License at
464 *
465 *   http://www.apache.org/licenses/LICENSE-2.0
466 *
467 * Unless required by applicable law or agreed to in writing, software
468 * distributed under the License is distributed on an "AS IS" BASIS,
469 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
470 * See the License for the specific language governing permissions and
471 * limitations under the License.
472 */function x(n,t,e){let r="Unexpected state";typeof t=="string"?r=t:e=t,ac(n,r,e)}function ac(n,t,e){let r=`FIRESTORE (${qe}) INTERNAL ASSERTION FAILED: ${t} (ID: ${n.toString(16)})`;if(e!==void 0)try{r+=" CONTEXT: "+JSON.stringify(e)}catch{r+=" CONTEXT: "+e}throw zt(r),new Error(r)}function K(n,t,e,r){let s="Unexpected state";typeof e=="string"?s=e:r=e,n||ac(t,s,r)}function F(n,t){return n}/**
473 * @license
474 * Copyright 2017 Google LLC
475 *
476 * Licensed under the Apache License, Version 2.0 (the "License");
477 * you may not use this file except in compliance with the License.
478 * You may obtain a copy of the License at
479 *
480 *   http://www.apache.org/licenses/LICENSE-2.0
481 *
482 * Unless required by applicable law or agreed to in writing, softw
482are
483 * distributed under the License is distributed on an "AS IS" BASIS,
484 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
485 * See the License for the specific language governing permissions and
486 * limitations under the License.
487 */const S={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 N extends Be{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
488 * @license
489 * Copyright 2017 Google LLC
490 *
491 * Licensed under the Apache License, Version 2.0 (the "License");
492 * you may not use this file except in compliance with the License.
493 * You may obtain a copy of the License at
494 *
495 *   http://www.apache.org/licenses/LICENSE-2.0
496 *
497 * Unless required by applicable law or agreed to in writing, software
498 * distributed under the License is distributed on an "AS IS" BASIS,
499 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
500 * See the License for the specific language governing permissions and
501 * limitations under the License.
502 */class ne{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}/**
503 * @license
504 * Copyright 2017 Google LLC
505 *
506 * Licensed under the Apache License, Version 2.0 (the "License");
507 * you may not use this file except in compliance with the License.
508 * You may obtain a copy of the License at
509 *
510 *   http://www.apache.org/licenses/LICENSE-2.0
511 *
512 * Unless required by applicable law or agreed to in writing, software
513 * distributed under the License is distributed on an "AS IS" BASIS,
514 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
515 * See the License for the specific language governing permissions and
516 * limitations under the License.
517 */class cc{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class uc{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable(()=>e(yt.UNAUTHENTICATED))}shutdown(){}}class od{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable(()=>e(this.token.user))}shutdown(){this.changeListener=null}}class ad{constructor(t){this.t=t,this.currentUser=yt.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){K(this.o===void 0,42304);let r=this.i;const s=h=>this.i!==r?(r=this.i,e(h)):Promise.resolve();let o=new ne;this.o=()=>{this.i++,this.currentUser=this.u(),o.resolve(),o=new ne,t.enqueueRetryable(()=>s(this.currentUser))};const a=()=>{const h=o;t.enqueueRetryable(async()=>{await h.promise,await s(this.currentUser)})},l=h=>{k("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=h,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(h=>l(h)),setTimeout(()=>{if(!this.auth){const h=this.t.getImmediate({optional:!0});h?l(h):(k("FirebaseAuthCredentialsProvider","Auth not yet detected"),o.resolve(),o=new ne)}},0),a()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(r=>this.i!==t?(k("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(K(typeof r.accessToken=="string",31837,{l:r}),new cc(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const t=this.auth&&this.auth.getUid();return K(t===null||typeof t=="string",2055,{h:t}),new yt(t)}}class cd{constructor(t,e,r){this.P=t,this.T=e,this.I=r,this.type="FirstParty",this.user=yt.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const t=this.R();return t&&this.A.set("Authorization",t),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class ud{constructor(t,e,r){this.P=t,this.T=e,this.I=r}getToken(){return Promise.resolve(new cd(this.P,this.T,this.I))}start(t,e){t.enqueueRetryable(()=>e(yt.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class Wo{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class ld{constructor(t,e){this.V=e,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,zh(t)&&t.settings.appCheckToken&&(this.p=t.settings.appCheckToken)}start(t,e){K(this.o===void 0,3512);const r=o=>{o.error!=null&&k("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${o.error.message}`);const a=o.token!==this.m;return this.m=o.token,k("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?e(o.token):Promise.resolve()};this.o=o=>{t.enqueueRetryable(()=>r(o))};const s=o=>{k("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=o,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(o=>s(o)),setTimeout(()=>{if(!this.appCheck){const o=this.V.getImmediate({optional:!0});o?s(o):k("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new Wo(this.p));const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then(e=>e?(K(typeof e.token=="string",44558,{tokenResult:e}),this.m=e.token,new Wo(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
518 * @license
519 * Copyright 2020 Google LLC
520 *
521 * Licensed under the Apache License, Version 2.0 (the "License");
522 * you may not use this file except in compliance with the License.
523 * You may obtain a copy of the License at
524 *
525 *   http://www.apache.org/licenses/LICENSE-2.0
526 *
527 * Unless required by applicable law or agreed to in writing, software
528 * distributed under the License is distributed on an "AS IS" BASIS,
529 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
530 * See the License for the specific language governing permissions and
531 * limitations under the License.
532 */function hd(n){const t=typeof self<"u"&&(self.crypto||self.msCrypto),e=new Uint8Array(n);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(e);else for(let r=0;r<n;r++)e[r]=Math.floor(256*Math.random());return e}/**
533 * @license
534 * Copyright 2017 Google LLC
535 *
536 * Licensed under the Apache License, Version 2.0 (the "License");
537 * you may not use this file except in compliance with the License.
538 * You may obtain a copy of the License at
539 *
540 *   http://www.apache.org/licenses/LICENSE-2.0
541 *
542 * Unless required by applicable law or agreed to in writing, software
543 * distributed under the License is distributed on an "AS IS" BASIS,
544 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
545 * See the License for the specific language governing permissions and
546 * limitations under the License.
547 */class br{static newId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=hd(40);for(let o=0;o<s.length;++o)r.length<20&&s[o]<e&&(r+=t.charAt(s[o]%62))}return r}}function B(n,t){return n<t?-1:n>t?1:0}function Us(n,t){const e=Math.min(n.length,t.length);for(let r=0;r<e;r++){const s=n.charAt(r),o=t.charAt(r);if(s!==o)return Ps(s)===Ps(o)?B(s,o):Ps(s)?1:-1}return B(n.length,t.length)}const dd=55296,fd=57343;function Ps(n){const t=n.charCodeAt(0);return t>=dd&&t<=fd}function Oe(n,t,e){return n.length===t.length&&n.every((r,s)=>e(r,t[s]))}/**
548 * @license
549 * Copyright 2017 Google LLC
550 *
551 * Licensed under the Apache License, Version 2.0 (the "License");
552 * you may not use this file except in compliance with the License.
553 * You may obtain a copy of the License at
554 *
555 *   http://www.apache.org/licenses/LICENSE-2.0
556 *
557 * Unless required by applicable law or agreed to in writing, software
558 * distributed under the License is distributed on an "AS IS" BASIS,
559 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
560 * See the License for the specific language governing permissions and
561 * limitations under the License.
562 */const Xo="__name__";class kt{constructor(t,e,r){e===void 0?e=0:e>t.length&&x(637,{offset:e,range:t.length}),r===void 0?r=t.length-e:r>t.length-e&&x(1746,{length:r,range:t.length-e}),this.segments=t,this.offset=e,this.len=r}get length(){return this.len}isEqual(t){return kt.comparator(this,t)===0}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof kt?t.forEach(r=>{e.push(r)}):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,r=this.limit();e<r;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const r=Math.min(t.length,e.length);for(let s=0;s<r;s++){const o=kt.compareSegments(t.get(s),e.get(s));if(o!==0)return o}return B(t.length,e.length)}static compareSegments(t,e){const r=kt.isNumericId(t),s=kt.isNumericId(e);return r&&!s?-1:!r&&s?1:r&&s?kt.extractNumericId(t).compare(kt.extractNumericId(e)):Us(t,e)}static isNumericId(t){return t.startsWith("__id")&&t.endsWith("__")}static extractNumericId(t){return ee.fromString(t.substring(4,t.length-2))}}class W extends kt{construct(t,e,r){return new W(t,e,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
562toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...t){const e=[];for(const r of t){if(r.indexOf("//")>=0)throw new N(S.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);e.push(...r.split("/").filter(s=>s.length>0))}return new W(e)}static emptyPath(){return new W([])}}const md=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ct extends kt{construct(t,e,r){return new ct(t,e,r)}static isValidIdentifier(t){return md.test(t)}canonicalString(){return this.toArray().map(t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ct.isValidIdentifier(t)||(t="`"+t+"`"),t)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Xo}static keyField(){return new ct([Xo])}static fromServerFormat(t){const e=[];let r="",s=0;const o=()=>{if(r.length===0)throw new N(S.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(r),r=""};let a=!1;for(;s<t.length;){const l=t[s];if(l==="\\"){if(s+1===t.length)throw new N(S.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const h=t[s+1];if(h!=="\\"&&h!=="."&&h!=="`")throw new N(S.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);r+=h,s+=2}else l==="`"?(a=!a,s++):l!=="."||a?(r+=l,s++):(o(),s++)}if(o(),a)throw new N(S.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new ct(e)}static emptyPath(){return new ct([])}}/**
563 * @license
564 * Copyright 2017 Google LLC
565 *
566 * Licensed under the Apache License, Version 2.0 (the "License");
567 * you may not use this file except in compliance with the License.
568 * You may obtain a copy of the License at
569 *
570 *   http://www.apache.org/licenses/LICENSE-2.0
571 *
572 * Unless required by applicable law or agreed to in writing, software
573 * distributed under the License is distributed on an "AS IS" BASIS,
574 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
575 * See the License for the specific language governing permissions and
576 * limitations under the License.
577 */class M{constructor(t){this.path=t}static fromPath(t){return new M(W.fromString(t))}static fromName(t){return new M(W.fromString(t).popFirst(5))}static empty(){return new M(W.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return t!==null&&W.comparator(this.path,t.path)===0}toString(){return this.path.toString()}static comparator(t,e){return W.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new M(new W(t.slice()))}}/**
578 * @license
579 * Copyright 2017 Google LLC
580 *
581 * Licensed under the Apache License, Version 2.0 (the "License");
582 * you may not use this file except in compliance with the License.
583 * You may obtain a copy of the License at
584 *
585 *   http://www.apache.org/licenses/LICENSE-2.0
586 *
587 * Unless required by applicable law or agreed to in writing, software
588 * distributed under the License is distributed on an "AS IS" BASIS,
589 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
590 * See the License for the specific language governing permissions and
591 * limitations under the License.
592 */function lc(n,t,e){if(!e)throw new N(S.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${t}.`)}function hc(n,t,e,r){if(t===!0&&r===!0)throw new N(S.INVALID_ARGUMENT,`${n} and ${e} cannot be used together.`)}function Yo(n){if(!M.isDocumentKey(n))throw new N(S.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function Jo(n){if(M.isDocumentKey(n))throw new N(S.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function dc(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function Dr(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const t=function(r){return r.constructor?r.constructor.name:null}(n);return t?`a custom ${t} object`:"an object"}}return typeof n=="function"?"a function":x(12329,{type:typeof n})}function Ct(n,t){if("_delegate"in n&&(n=n._delegate),!(n instanceof t)){if(t.name===n.constructor.name)throw new N(S.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const e=Dr(n);throw new N(S.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${e}`)}}return n}/**
593 * @license
594 * Copyright 2025 Google LLC
595 *
596 * Licensed under the Apache License, Version 2.0 (the "License");
597 * you may not use this file except in compliance with the License.
598 * You may obtain a copy of the License at
599 *
600 *   http://www.apache.org/licenses/LICENSE-2.0
601 *
602 * Unless required by applicable law or agreed to in writing, software
603 * distributed under the License is distributed on an "AS IS" BASIS,
604 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
605 * See the License for the specific language governing permissions and
606 * limitations under the License.
607 */function it(n,t){const e={typeString:n};return t&&(e.value=t),e}function bn(n,t){if(!dc(n))throw new N(S.INVALID_ARGUMENT,"JSON must be an object");let e;for(const r in t)if(t[r]){const s=t[r].typeString,o="value"in t[r]?{value:t[r].value}:void 0;if(!(r in n)){e=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){e=`JSON field '${r}' must be a ${s}.`;break}if(o!==void 0&&a!==o.value){e=`Expected '${r}' field to equal '${o.value}'`;break}}if(e)throw new N(S.INVALID_ARGUMENT,e);return!0}/**
608 * @license
609 * Copyright 2017 Google LLC
610 *
611 * Licensed under the Apache License, Version 2.0 (the "License");
612 * you may not use this file except in compliance with the License.
613 * You may obtain a copy of the License at
614 *
615 *   http://www.apache.org/licenses/LICENSE-2.0
616 *
617 * Unless required by applicable law or agreed to in writing, software
618 * distributed under the License is distributed on an "AS IS" BASIS,
619 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
620 * See the License for the specific language governing permissions and
621 * limitations under the License.
622 */const Zo=-62135596800,ta=1e6;class X{static now(){return X.fromMillis(Date.now())}static fromDate(t){return X.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),r=Math.floor((t-1e3*e)*ta);return new X(e,r)}constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new N(S.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new N(S.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<Zo)throw new N(S.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new N(S.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/ta}_compareTo(t){return this.seconds===t.seconds?B(this.nanoseconds,t.nanoseconds):B(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:X._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(bn(t,X._jsonSchema))return new X(t.seconds,t.nanoseconds)}valueOf(){const t=this.seconds-Zo;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}X._jsonSchemaVersion="firestore/timestamp/1.0",X._jsonSchema={type:it("string",X._jsonSchemaVersion),seconds:it("number"),nanoseconds:it("number")};/**
623 * @license
624 * Copyright 2017 Google LLC
625 *
626 * Licensed under the Apache License, Version 2.0 (the "License");
627 * you may not use this file except in compliance with the License.
628 * You may obtain a copy of the License at
629 *
630 *   http://www.apache.org/licenses/LICENSE-2.0
631 *
632 * Unless required by applicable law or agreed to in writing, software
633 * distributed under the License is distributed on an "AS IS" BASIS,
634 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
635 * See the License for the specific language governing permissions and
636 * limitations under the License.
637 */class L{static fromTimestamp(t){return new L(t)}static min(){return new L(new X(0,0))}static max(){return new L(new X(253402300799,999999999))}constructor(t){this.timestamp=t}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
638 * @license
639 * Copyright 2021 Google LLC
640 *
641 * Licensed under the Apache License, Version 2.0 (the "License");
642 * you may not use this file except in compliance with the License.
643 * You may obtain a copy of the License at
644 *
645 *   http://www.apache.org/licenses/LICENSE-2.0
646 *
647 * Unless required by applicable law or agreed to in writing, software
648 * distributed under the License is distributed on an "AS IS" BASIS,
649 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
650 * See the License for the specific language governing permissions and
651 * limitations under the License.
652 */const An=-1;function pd(n,t){const e=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=L.fromTimestamp(r===1e9?new X(e+1,0):new X(e,r));return new se(s,M.empty(),t)}function gd(n){return new se(n.readTime,n.key,An)}class se{constructor(t,e,r){this.readTime=t,this.documentKey=e,this.largestBatchId=r}static min(){return new se(L.min(),M.empty(),An)}static max(){return new se(L.max(),M.empty(),An)}}function _d(n,t){let e=n.readTime.compareTo(t.readTime);return e!==0?e:(e=M.comparator(n.documentKey,t.documentKey),e!==0?e:B(n.largestBatchId,t.largestBatchId))}/**
653 * @license
654 * Copyright 2020 Google LLC
655 *
656 * Licensed under the Apache License, Version 2.0 (the "License");
657 * you may not use this file except in compliance with the License.
658 * You may obtain a copy of the License at
659 *
660 *   http://www.apache.org/licenses/LICENSE-2.0
661 *
662 * Unless required by applicable law or agreed to in writing, software
663 * distributed under the License is distributed on an "AS IS" BASIS,
664 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
665 * See the License for the specific language governing permissions and
666 * limitations under the License.
667 */const yd="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Ed{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(t=>t())}}/**
668 * @license
669 * Copyright 2017 Google LLC
670 *
671 * Licensed under the Apache License, Version 2.0 (the "License");
672 * you may not use this file except in compliance with the License.
673 * You may obtain a copy of the License at
674 *
675 *   http://www.apache.org/licenses/LICENSE-2.0
676 *
677 * Unless required by applicable law or agreed to in writing, software
678 * distributed under the License is distributed on an "AS IS" BASIS,
679 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
680 * See the License for the specific language governing permissions and
681 * limitations under the License.
682 */async function je(n){if(n.code!==S.FAILED_PRECONDITION||n.message!==yd)throw n;k("LocalStore","Unexpectedly lost primary lease")}/**
683 * @license
684 * Copyright 2017 Google LLC
685 *
686 * Licensed under the Apache License, Version 2.0 (the "License");
687 * you may not use this file except in compliance with the License.
688 * You may obtain a copy of the License at
689 *
690 *   http://www.apache.org/licenses/LICENSE-2.0
691 *
692 * Unless required by applicable law or agreed to in writing, software
693 * distributed under the License is distributed on an "AS IS" BASIS,
694 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
695 * See the License for the specific language governing permissions and
696 * limitations under the License.
697 */class C{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&x(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new C((r,s)=>{this.nextCallback=o=>{this.wrapSuccess(t,o).next(r,s)},this.catchCallback=o=>{this.wrapFailure(e,o).next(r,s)}})}toPromise(){return new Promise((t,e)=>{this.next(t,e)})}wrapUserFunction(t){try{const e=t();return e instanceof C?e:C.resolve(e)}catch(e){return C.reject(e)}}wrapSuccess(t,e){return t?this.wrapUserFunction(()=>t(e)):C.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction(()=>t(e)):C.reject(e)}static resolve(t){return new C((e,r)=>{e(t)})}static reject(t){return new C((e,r)=>{r(t)})}static waitFor(t){return new C((e,r)=>{let s=0,o=0,a=!1;t.forEach(l=>{++s,l.next(()=>{++o,a&&o===s&&e()},h=>r(h))}),a=!0,o===s&&e()})}static or(t){let e=C.resolve(!1);for(const r of t)e=e.next(s=>s?C.resolve(s):r());return e}static forEach(t,e){const r=[];return t.forEach((s,o)=>{r.push(e.call(this,s,o))}),this.waitFor(r)}static mapArray(t,e){return new C((r,s)=>{const o=t.length,a=new Array(o);let l=0;for(let h=0;h<o;h++){const f=h;e(t[f]).next(m=>{a[f]=m,++l,l===o&&r(a)},m=>s(m))}})}static doWhile(t,e){return new C((r,s)=>{const o=()=>{t()===!0?e().next(()=>{o()},s):r()};o()})}}function Td(n){const t=n.match(/Android ([\d.]+)/i),e=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(e)}function $e(n){return n.name==="IndexedDbTransactionError"}/**
698 * @license
699 * Copyright 2018 Google LLC
700 *
701 * Licensed under the Apache License, Version 2.0 (the "License");
702 * you may not use this file except in compliance with the License.
703 * You may obtain a copy of the License at
704 *
705 *   http://www.apache.org/licenses/LICENSE-2.0
706 *
707 * Unless required by applicable law or agreed to in writing, software
708 * distributed under the License is distributed on an "AS IS" BASIS,
709 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
710 * See the License for the specific language governing permissions and
711 * limitations under the License.
712 */class Nr{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>e.writeSequenceNumber(r))}ae(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.ue&&this.ue(t),t}}Nr.ce=-1;/**
713 * @license
714 * Copyright 2017 Google LLC
715 *
716 * Licensed under the Apache License, Version 2.0 (the "License");
717 * you may not use this file except in compliance with the License.
718 * You may obtain a copy of the License at
719 *
720 *   http://www.apache.org/licenses/LICENSE-2.0
721 *
722 * Unless required by applicable law or agreed to in writing, software
723 * distributed under the License is distributed on an "AS IS" BASIS,
724 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
725 * See the License for the specific language governing permissions and
726 * limitations under the License.
727 */const oi=-1;function kr(n){return n==null}function yr(n){return n===0&&1/n==-1/0}function vd(n){return typeof n=="number"&&Number.isInteger(n)&&!yr(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}/**
728 * @license
729 * Copyright 2017 Google LLC
730 *
731 * Licensed under the Apache License, Version 2.0 (the "License");
732 * you may not use this file except in compliance with the License.
733 * You may obtain a copy of the License at
734 *
735 *   http://www.apache.org/licenses/LICENSE-2.0
736 *
737 * Unless required by applicable law or agreed to in writing, software
738 * distributed under the License is distributed on an "AS IS" BASIS,
739 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
740 * See the License for the specific language governing permissions and
741 * limitations under the License.
742 */const fc="�";function Id(n){let t="";for(let e=0;e<n.length;e++)t.length>0&&(t=ea(t)),t=Ad(n.get(e),t);return ea(t)}function Ad(n,t){let e=t;const r=n.length;for(let s=0;s<r;s++){const o=n.charAt(s);switch(o){case"\0":e+="��";break;case fc:e+="��";break;default:e+=o}}return e}function ea(n){return n+fc+"�"}/**
743 * @license
744 * Copyright 2017 Google LLC
745 *
746 * Licensed under the Apache License, Version 2.0 (the "License");
747 * you may not use this file except in compliance with the License.
748 * You may obtain a copy of the License at
749 *
750 *   http://www.apache.org/licenses/LICENSE-2.0
751 *
752 * Unless required by applicable law or agreed to in writing, software
753 * distributed under the License is distributed on an "AS IS" BASIS,
754 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
755 * See the License for the specific language governing permissions and
756 * limitations under the License.
757 */function na(n){let t=0;for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&t++;return t}function le(n,t){for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&t(e,n[e])}function mc(n){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0}/**
758 * @license
759 * Copyright 2017 Google LLC
760 *
761 * Licensed under the Apache License, Version 2.0 (the "License");
762 * you may not use this file except in compliance with the License.
763 * You may obtain a copy of the License at
764 *
765 *   http://www.apache.org/licenses/LICENSE-2.0
766 *
767 * Unless required by applicable law or agreed to in writing, software
768 * distributed under the License is distributed on an "AS IS" BASIS,
769 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
770 * See the License for the specific language governing permissions and
771 * limitations under the License.
772 */class Z{constructor(t,e){this.comparator=t,this.root=e||dt.EMPTY}insert(t,e){return new Z(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,dt.BLACK,null,
772null))}remove(t){return new Z(this.comparator,this.root.remove(t,this.comparator).copy(null,null,dt.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const r=this.comparator(t,e.key);if(r===0)return e.value;r<0?e=e.left:r>0&&(e=e.right)}return null}indexOf(t){let e=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(t,r.key);if(s===0)return e+r.left.size;s<0?r=r.left:(e+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal((e,r)=>(t(e,r),!1))}toString(){const t=[];return this.inorderTraversal((e,r)=>(t.push(`${e}:${r}`),!1)),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new or(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new or(this.root,t,this.comparator,!1)}getReverseIterator(){return new or(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new or(this.root,t,this.comparator,!0)}}class or{constructor(t,e,r,s){this.isReverse=s,this.nodeStack=[];let o=1;for(;!t.isEmpty();)if(o=e?r(t.key,e):1,e&&s&&(o*=-1),o<0)t=this.isReverse?t.left:t.right;else{if(o===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class dt{constructor(t,e,r,s,o){this.key=t,this.value=e,this.color=r??dt.RED,this.left=s??dt.EMPTY,this.right=o??dt.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,r,s,o){return new dt(t??this.key,e??this.value,r??this.color,s??this.left,o??this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,r){let s=this;const o=r(t,s.key);return s=o<0?s.copy(null,null,null,s.left.insert(t,e,r),null):o===0?s.copy(null,e,null,null,null):s.copy(null,null,null,null,s.right.insert(t,e,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return dt.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let r,s=this;if(e(t,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(t,e),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),e(t,s.key)===0){if(s.right.isEmpty())return dt.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(t,e))}return s.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,dt.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,dt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw x(43730,{key:this.key,value:this.value});if(this.right.isRed())throw x(14113,{key:this.key,value:this.value});const t=this.left.check();if(t!==this.right.check())throw x(27949);return t+(this.isRed()?0:1)}}dt.EMPTY=null,dt.RED=!0,dt.BLACK=!1;
772dt.EMPTY=new class{constructor(){this.size=0}get key(){throw x(57766)}get value(){throw x(16141)}get color(){throw x(16727)}get left(){throw x(29726)}get right(){throw x(36894)}copy(t,e,r,s,o){return this}insert(t,e,r){return new dt(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
773 * @license
774 * Copyright 2017 Google LLC
775 *
776 * Licensed under the Apache License, Version 2.0 (the "License");
777 * you may not use this file except in compliance with the License.
778 * You may obtain a copy of the License at
779 *
780 *   http://www.apache.org/licenses/LICENSE-2.0
781 *
782 * Unless required by applicable law or agreed to in writing, software
783 * distributed under the License is distributed on an "AS IS" BASIS,
784 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
785 * See the License for the specific language governing permissions and
786 * limitations under the License.
787 */class ot{constructor(t){this.comparator=t,this.data=new Z(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal((e,r)=>(t(e),!1))}forEachInRange(t,e){const r=this.data.getIteratorFrom(t[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,t[1])>=0)return;e(s.key)}}forEachWhile(t,e){let r;for(r=e!==void 0?this.data.getIteratorFrom(e):this.data.getIterator();r.hasNext();)if(!t(r.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new ra(this.data.getIterator())}getIteratorFrom(t){return new ra(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach(r=>{e=e.add(r)}),e}isEqual(t){if(!(t instanceof ot)||this.size!==t.size)return!1;const e=this.data.getIterator(),r=t.data.getIterator();for(;e.hasNext();){const s=e.getNext().key,o=r.getNext().key;if(this.comparator(s,o)!==0)return!1}return!0}toArray(){const t=[];return this.forEach(e=>{t.push(e)}),t}toString(){const t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(t){const e=new ot(this.comparator);return e.data=t,e}}class ra{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
788 * @license
789 * Copyright 2020 Google LLC
790 *
791 * Licensed under the Apache License, Version 2.0 (the "License");
792 * you may not use this file except in compliance with the License.
793 * You may obtain a copy of the License at
794 *
795 *   http://www.apache.org/licenses/LICENSE-2.0
796 *
797 * Unless required by applicable law or agreed to in writing, software
798 * distributed under the License is distributed on an "AS IS" BASIS,
799 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
800 * See the License for the specific language governing permissions and
801 * limitations under the License.
802 */class St{constructor(t){this.fields=t,t.sort(ct.comparator)}static empty(){return new St([])}unionWith(t){let e=new ot(ct.comparator);for(const r of this.fields)e=e.add(r);for(const r of t)e=e.add(r);return new St(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Oe(this.fields,t.fields,(e,r)=>e.isEqual(r))}}/**
803 * @license
804 * Copyright 2023 Google LLC
805 *
806 * Licensed under the Apache License, Version 2.0 (the "License");
807 * you may not use this file except in compliance with the License.
808 * You may obtain a copy of the License at
809 *
810 *   http://www.apache.org/licenses/LICENSE-2.0
811 *
812 * Unless required by applicable law or agreed to in writing, software
813 * distributed under the License is distributed on an "AS IS" BASIS,
814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
815 * See the License for the specific language governing permissions and
816 * limitations under the License.
817 */class pc extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
818 * @license
819 * Copyright 2020 Google LLC
820 *
821 * Licensed under the Apache License, Version 2.0 (the "License");
822 * you may not use this file except in compliance with the License.
823 * You may obtain a copy of the License at
824 *
825 *   http://www.apache.org/licenses/LICENSE-2.0
826 *
827 * Unless required by applicable law or agreed to in writing, software
828 * distributed under the License is distributed on an "AS IS" BASIS,
829 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
830 * See the License for the specific language governing permissions and
831 * limitations under the License.
832 */class ut{constructor(t){this.binaryString=t}static fromBase64String(t){const e=function(s){try{return atob(s)}catch(o){throw typeof DOMException<"u"&&o instanceof DOMException?new pc("Invalid base64 string: "+o):o}}(t);return new ut(e)}static fromUint8Array(t){const e=function(s){let o="";for(let a=0;a<s.length;++a)o+=String.fromCharCode(s[a]);return o}(t);return new ut(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function(e){const r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return B(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}ut.EMPTY_BYTE_STRING=new ut("");const wd=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ie(n){if(K(!!n,39018),typeof n=="string"){let t=0;const e=wd.exec(n);if(K(!!e,46558,{timestamp:n}),e[1]){let s=e[1];s=(s+"000000000").substr(0,9),t=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:et(n.seconds),nanos:et(n.nanos)}}function et(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function oe(n){return typeof n=="string"?ut.fromBase64String(n):ut.fromUint8Array(n)}/**
833 * @license
834 * Copyright 2020 Google LLC
835 *
836 * Licensed under the Apache License, Version 2.0 (the "License");
837 * you may not use this file except in compliance with the License.
838 * You may obtain a copy of the License at
839 *
840 *   http://www.apache.org/licenses/LICENSE-2.0
841 *
842 * Unless required by applicable law or agreed to in writing, software
843 * distributed under the License is distributed on an "AS IS" BASIS,
844 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
845 * See the License for the specific language governing permissions and
846 * limitations under the License.
847 */const gc="server_timestamp",_c="__type__",yc="__previous_value__",Ec="__local_write_time__";function ai(n){var e,r;return((r=(((e=n==null?void 0:n.mapValue)==null?void 0:e.fields)||{})[_c])==null?void 0:r.stringValue)===gc}function Or(n){const t=n.mapValue.fields[yc];return ai(t)?Or(t):t}function wn(n){const t=ie(n.mapValue.fields[Ec].timestampValue);return new X(t.seconds,t.nanos)}/**
848 * @license
849 * Copyright 2017 Google LLC
850 *
851 * Licensed under the Apache License, Version 2.0 (the "License");
852 * you may not use this file except in compliance with the License.
853 * You may obtain a copy of the License at
854 *
855 *   http://www.apache.org/licenses/LICENSE-2.0
856 *
857 * Unless required by applicable law or agreed to in writing, software
858 * distributed under the License is distributed on an "AS IS" BASIS,
859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
860 * See the License for the specific language governing permissions and
861 * limitations under the License.
862 */class Rd{constructor(t,e,r,s,o,a,l,h,f,m){this.databaseId=t,this.appId=e,this.persistenceKey=r,this.host=s,this.ssl=o,this.forceLongPolling=a,this.autoDetectLongPolling=l,this.longPollingOptions=h,this.useFetchStreams=f,this.isUsingEmulator=m}}const Er="(default)";class Me{constructor(t,e){this.projectId=t,this.database=e||Er}static empty(){return new Me("","")}get isDefaultDatabase(){return this.database===Er}isEqual(t){return t instanceof Me&&t.projectId===this.projectId&&t.database===this.database}}/**
863 * @license
864 * Copyright 2020 Google LLC
865 *
866 * Licensed under the Apache License, Version 2.0 (the "License");
867 * you may not use this file except in compliance with the License.
868 * You may obtain a copy of the License at
869 *
870 *   http://www.apache.org/licenses/LICENSE-2.0
871 *
872 * Unless required by applicable law or agreed to in writing, software
873 * distributed under the License is distributed on an "AS IS" BASIS,
874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
875 * See the License for the specific language governing permissions and
876 * limitations under the License.
877 */const Tc="__type__",vc="__max__",ar={mapValue:{fields:{__type__:{stringValue:vc}}}},Ic="__vector__",Tr="value";function ae(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?ai(n)?4:Cd(n)?9007199254740991:Sd(n)?10:11:x(28295,{value:n})}function Lt(n,t){if(n===t)return!0;const e=ae(n);if(e!==ae(t))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===t.booleanValue;case 4:return wn(n).isEqual(wn(t));case 3:return function(s,o){if(typeof s.timestampValue=="string"&&typeof o.timestampValue=="string"&&s.timestampValue.length===o.timestampValue.length)return s.timestampValue===o.timestampValue;const a=ie(s.timestampValue),l=ie(o.timestampValue);return a.seconds===l.seconds&&a.nanos===l.nanos}(n,t);case 5:return n.stringValue===t.stringValue;case 6:return function(s,o){return oe(s.bytesValue).isEqual(oe(o.bytesValue))}(n,t);case 7:return n.referenceValue===t.referenceValue;case 8:return function(s,o){return et(s.geoPointValue.latitude)===et(o.geoPointValue.latitude)&&et(s.geoPointValue.longitude)===et(o.geoPointValue.longitude)}(n,t);case 2:return function(s,o){if("integerValue"in s&&"integerValue"in o)return et(s.integerValue)===et(o.integerValue);if("doubleValue"in s&&"doubleValue"in o){const a=et(s.doubleValue),l=et(o.doubleValue);return a===l?yr(a)===yr(l):isNaN(a)&&isNaN(l)}return!1}(n,t);case 9:return Oe(n.arrayValue.values||[],t.arrayValue.values||[],Lt);case 10:case 11:return function(s,o){const a=s.mapValue.fields||{},l=o.mapValue.fields||{};if(na(a)!==na(l))return!1;for(const h in a)if(a.hasOwnProperty(h)&&(l[h]===void 0||!Lt(a[h],l[h])))return!1;return!0}(n,t);default:return x(52216,{left:n})}}function Rn(n,t){return(n.values||[]).find(e=>Lt(e,t))!==void 0}function xe(n,t){if(n===t)return 0;const e=ae(n),r=ae(t);if(e!==r)return B(e,r);switch(e){case 0:case 9007199254740991:return 0;case 1:return B(n.booleanValue,t.booleanValue);case 2:return function(o,a){const l=et(o.integerValue||o.doubleValue),h=et(a.integerValue||a.doubleValue);return l<h?-1:l>h?1:l===h?0:isNaN(l)?isNaN(h)?0:-1:1}(n,t);case 3:return sa(n.timestampValue,t.timestampValue);case 4:return sa(wn(n),wn(t));case 5:return Us(n.stringValue,t.stringValue);case 6:return function(o,a){const l=oe(o),h=oe(a);return l.compareTo(h)}(n.bytesValue,t.bytesValue);case 7:return function(o,a){const l=o.split("/"),h=a.split("/");for(let f=0;f<l.length&&f<h.length;f++){const m=B(l[f],h[f]);if(m!==0)return m}return B(l.length,h.length)}(n.referenceValue,t.referenceValue);case 8:return function(o,a){const l=B(et(o.latitude),et(a.latitude));return l!==0?l:B(et(o.longitude),et(a.longitude))}(n.geoPointValue,t.geoPointValue);case 9:return ia(n.arrayValue,t.arrayValue);case 10:return function(o,a){var T,P,b,O;const l=o.fields||{},h=a.fields||{},f=(T=l[Tr])==null?void 0:T.arrayValue,m=(P=h[Tr])==null?void 0:P.arrayValue,E=B(((b=f==null?void 0:f.values)==null?void 0:b.length)||0,((O=m==null?void 0:m.values)==null?void 0:O.length)||0);return E!==0?E:ia(f,m)}(n.mapValue,t.mapValue);case 11:return function(o,a){if(o===ar.mapValue&&a===ar.mapValue)return 0;if(o===ar.mapValue)return 1;if(a===ar.mapValue)return-1;const l=o.fields||{},h=Object.keys(l),f=a.fields||{},m=Object.keys(f);h.sort(),m.sort();for(let E=0;E<h.length&&E<m.length;++E){const T=Us(h[E],m[E]);if(T!==0)return T;const P=xe(l[h[E]],f[m[E]]);if(P!==0)return P}return B(h.length,m.length)}(n.mapValue,t.mapValue);default:throw x(23264,{he:e})}}function sa(n,t){if(typeof n=="string"&&typeof t=="string"&&n.length===t.length)return B(n,t);const e=ie(n),r=ie(t),s=B(e.seconds,r.seconds);return s!==0?s:B(e.nanos,r.nanos)}function ia(n,t){const e=n.values||[],r=t.values||[];for(let s=0;s<e.length&&s<r.length;++s){const o=xe(e[s],r[s]);if(o)return o}return B(e.length,r.length)}function Le(n){return Bs(n)}function Bs(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(e){const r=ie(e);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(e){return oe(e).toBase64()}
877(n.bytesValue):"referenceValue"in n?function(e){return M.fromName(e).toString()}(n.referenceValue):"geoPointValue"in n?function(e){return`geo(${e.latitude},${e.longitude})`}(n.geoPointValue):"arrayValue"in n?function(e){let r="[",s=!0;for(const o of e.values||[])s?s=!1:r+=",",r+=Bs(o);return r+"]"}(n.arrayValue):"mapValue"in n?function(e){const r=Object.keys(e.fields||{}).sort();let s="{",o=!0;for(const a of r)o?o=!1:s+=",",s+=`${a}:${Bs(e.fields[a])}`;return s+"}"}(n.mapValue):x(61005,{value:n})}function hr(n){switch(ae(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=Or(n);return t?16+hr(t):16;case 5:return 2*n.stringValue.length;case 6:return oe(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return function(r){return(r.values||[]).reduce((s,o)=>s+hr(o),0)}(n.arrayValue);case 10:case 11:return function(r){let s=0;return le(r.fields,(o,a)=>{s+=o.length+hr(a)}),s}(n.mapValue);default:throw x(13486,{value:n})}}function oa(n,t){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${t.path.canonicalString()}`}}function qs(n){return!!n&&"integerValue"in n}function ci(n){return!!n&&"arrayValue"in n}function aa(n){return!!n&&"nullValue"in n}function ca(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function dr(n){return!!n&&"mapValue"in n}function Sd(n){var e,r;return((r=(((e=n==null?void 0:n.mapValue)==null?void 0:e.fields)||{})[Tc])==null?void 0:r.stringValue)===Ic}function pn(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const t={mapValue:{fields:{}}};return le(n.mapValue.fields,(e,r)=>t.mapValue.fields[e]=pn(r)),t}if(n.arrayValue){const t={arrayValue:{values:[]}};for(let e=0;e<(n.arrayValue.values||[]).length;++e)t.arrayValue.values[e]=pn(n.arrayValue.values[e]);return t}return{...n}}function Cd(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===vc}/**
878 * @license
879 * Copyright 2017 Google LLC
880 *
881 * Licensed under the Apache License, Version 2.0 (the "License");
882 * you may not use this file except in compliance with the License.
883 * You may obtain a copy of the License at
884 *
885 *   http://www.apache.org/licenses/LICENSE-2.0
886 *
887 * Unless required by applicable law or agreed to in writing, software
888 * distributed under the License is distributed on an "AS IS" BASIS,
889 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
890 * See the License for the specific language governing permissions and
891 * limitations under the License.
892 */class At{constructor(t){this.value=t}static empty(){return new At({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let r=0;r<t.length-1;++r)if(e=(e.mapValue.fields||{})[t.get(r)],!dr(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=pn(e)}setAll(t){let e=ct.emptyPath(),r={},s=[];t.forEach((a,l)=>{if(!e.isImmediateParentOf(l)){const h=this.getFieldsMap(e);this.applyChanges(h,r,s),r={},s=[],e=l.popLast()}a?r[l.lastSegment()]=pn(a):s.push(l.lastSegment())});const o=this.getFieldsMap(e);this.applyChanges(o,r,s)}delete(t){const e=this.field(t.popLast());dr(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Lt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let r=0;r<t.length;++r){let s=e.mapValue.fields[t.get(r)];dr(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},e.mapValue.fields[t.get(r)]=s),e=s}return e.mapValue.fields}applyChanges(t,e,r){le(e,(s,o)=>t[s]=o);for(const s of r)delete t[s]}clone(){return new At(pn(this.value))}}function Ac(n){const t=[];return le(n.fields,(e,r)=>{const s=new ct([e]);if(dr(r)){const o=Ac(r.mapValue).fields;if(o.length===0)t.push(s);else for(const a of o)t.push(s.child(a))}else t.push(s)}),new St(t)}/**
893 * @license
894 * Copyright 2017 Google LLC
895 *
896 * Licensed under the Apache License, Version 2.0 (the "License");
897 * you may not use this file except in compliance with the License.
898 * You may obtain a copy of the License at
899 *
900 *   http://www.apache.org/licenses/LICENSE-2.0
901 *
902 * Unless required by applicable law or agreed to in writing, software
903 * distributed under the License is distributed on an "AS IS" BASIS,
904 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
905 * See the License for the specific language governing permissions and
906 * limitations under the License.
907 */class Et{constructor(t,e,r,s,o,a,l){this.key=t,this.documentType=e,this.version=r,this.readTime=s,this.createTime=o,this.data=a,this.documentState=l}static newInvalidDocument(t){return new Et(t,0,L.min(),L.min(),L.min(),At.empty(),0)}static newFoundDocument(t,e,r,s){return new Et(t,1,e,L.min(),r,s,0)}static newNoDocument(t,e){return new Et(t,2,e,L.min(),L.min(),At.empty(),0)}static newUnknownDocument(t,e){return new Et(t,3,e,L.min(),L.min(),At.empty(),2)}convertToFoundDocument(t,e){return!this.createTime.isEqual(L.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=t),this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=At.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=At.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=L.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof Et&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new Et(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}})`}}/**
908 * @license
909 * Copyright 2022 Google LLC
910 *
911 * Licensed under the Apache License, Version 2.0 (the "License");
912 * you may not use this file except in compliance with the License.
913 * You may obtain a copy of the License at
914 *
915 *   http://www.apache.org/licenses/LICENSE-2.0
916 *
917 * Unless required by applicable law or agreed to in writing, software
918 * distributed under the License is distributed on an "AS IS" BASIS,
919 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
920 * See the License for the specific language governing permissions and
921 * limitations under the License.
922 */class vr{constructor(t,e){this.position=t,this.inclusive=e}}function ua(n,t,e){let r=0;for(let s=0;s<n.position.length;s++){const o=t[s],a=n.position[s];if(o.field.isKeyField()?r=M.comparator(M.fromName(a.referenceValue),e.key):r=xe(a,e.data.field(o.field)),o.dir==="desc"&&(r*=-1),r!==0)break}return r}function la(n,t){if(n===null)return t===null;if(t===null||n.inclusive!==t.inclusive||n.position.length!==t.position.length)return!1;for(let e=0;e<n.position.length;e++)if(!Lt(n.position[e],t.position[e]))return!1;return!0}/**
923 * @license
924 * Copyright 2022 Google LLC
925 *
926 * Licensed under the Apache License, Version 2.0 (the "License");
927 * you may not use this file except in compliance with the License.
928 * You may obtain a copy of the License at
929 *
930 *   http://www.apache.org/licenses/LICENSE-2.0
931 *
932 * Unless required by applicable law or agreed to in writing, software
933 * distributed under the License is distributed on an "AS IS" BASIS,
934 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
935 * See the License for the specific language governing permissions and
936 * limitations under the License.
937 */class Sn{constructor(t,e="asc"){this.field=t,this.dir=e}}function Pd(n,t){return n.dir===t.dir&&n.field.isEqual(t.field)}/**
938 * @license
939 * Copyright 2022 Google LLC
940 *
941 * Licensed under the Apache License, Version 2.0 (the "License");
942 * you may not use this file except in compliance with the License.
943 * You may obtain a copy of the License at
944 *
945 *   http://www.apache.org/licenses/LICENSE-2.0
946 *
947 * Unless required by applicable law or agreed to in writing, software
948 * distributed under the License is distributed on an "AS IS" BASIS,
949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
950 * See the License for the specific language governing permissions and
951 * limitations under the License.
952 */class wc{}class st extends wc{constructor(t,e,r){super(),this.field=t,this.op=e,this.value=r}static create(t,e,r){return t.isKeyField()?e==="in"||e==="not-in"?this.createKeyFieldInFilter(t,e,r):new bd(t,e,r):e==="array-contains"?new kd(t,r):e==="in"?new Od(t,r):e==="not-in"?new Md(t,r):e==="array-contains-any"?new xd(t,r):new st(t,e,r)}static createKeyFieldInFilter(t,e,r){return e==="in"?new Dd(t,r):new Nd(t,r)}matches(t){const e=t.data.field(this.field);return this.op==="!="?e!==null&&e.nullValue===void 0&&this.matchesComparison(xe(e,this.value)):e!==null&&ae(this.value)===ae(e)&&this.matchesComparison(xe(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return t===0;case"!=":return t!==0;case">":return t>0;case">=":return t>=0;default:return x(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Nt extends wc{constructor(t,e){super(),this.filters=t,this.op=e,this.Pe=null}static create(t,e){return new Nt(t,e)}matches(t){return Rc(this)?this.filters.find(e=>!e.matches(t))===void 0:this.filters.find(e=>e.matches(t))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce((t,e)=>t.concat(e.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function Rc(n){return n.op==="and"}function Sc(n){return Vd(n)&&Rc(n)}function Vd(n){for(const t of n.filters)if(t instanceof Nt)return!1;return!0}function js(n){if(n instanceof st)return n.field.canonicalString()+n.op.toString()+Le(n.value);if(Sc(n))return n.filters.map(t=>js(t)).join(",");{const t=n.filters.map(e=>js(e)).join(",");return`${n.op}(${t})`}}function Cc(n,t){return n instanceof st?function(r,s){return s instanceof st&&r.op===s.op&&r.field.isEqual(s.field)&&Lt(r.value,s.value)}(n,t):n instanceof Nt?function(r,s){return s instanceof Nt&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((o,a,l)=>o&&Cc(a,s.filters[l]),!0):!1}(n,t):void x(19439)}function Pc(n){return n instanceof st?function(e){return`${e.field.canonicalString()} ${e.op} ${Le(e.value)}`}(n):n instanceof Nt?function(e){return e.op.toString()+" {"+e.getFilters().map(Pc).join(" ,")+"}"}(n):"Filter"}class bd extends st{constructor(t,e,r){super(t,e,r),this.key=M.fromName(r.referenceValue)}matches(t){const e=M.comparator(t.key,this.key);return this.matchesComparison(e)}}class Dd extends st{constructor(t,e){super(t,"in",e),this.keys=Vc("in",e)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class Nd extends st{constructor(t,e){super(t,"not-in",e),this.keys=Vc("not-in",e)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function Vc(n,t){var e;return(((e=t.arrayValue)==null?void 0:e.values)||[]).map(r=>M.fromName(r.referenceValue))}class kd extends st{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return ci(e)&&Rn(e.arrayValue,this.value)}}class Od extends st{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return e!==null&&Rn(this.value.arrayValue,e)}}class Md extends st{constructor(t,e){super(t,"not-in",e)}matches(t){if(Rn(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return e!==null&&e.nullValue===void 0&&!Rn(this.value.arrayValue,e)}}class xd extends st{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!ci(e)||!e.arrayValue.values)&&e.arrayValue.values.some(r=>Rn(this.value.arrayValue,r))}}/**
953 * @license
954 * Copyright 2019 Google LLC
955 *
956 * Licensed under the Apache License, Version 2.0 (the "License");
957 * you may not use this file except in compliance with the License.
958 * You may obtain a copy of the License at
959 *
960 *   http://www.apache.org/licenses/LICENSE-2.0
961 *
962 * Unless required by applicable law or agreed to in writing, software
963 * distributed under the License is distributed on an "AS IS" BASIS,
964 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
965 * See the License for the specific language governing permissions and
966 * limitations under the License.
967 */class Ld{constructor(t,e=null,r=[],s=[],o=null,a=null,l=null){this.path=t,this.collectionGroup=e,this.orderBy=r,this.filters=s,this.limit=o,this.startAt=a,this.endAt=l,this.Te=null}}function ha(n,t=null,e=[],r=[],s=null,o=null,a=null){return new Ld(n,t,e,r,s,o,a)}function ui(n){const t=F(n);if(t.Te===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(r=>js(r)).join(","),e+="|ob:",e+=t.orderBy.map(r=>function(o){return o.field.canonicalString()+o.dir}(r)).join(","),kr(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(r=>Le(r)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(r=>Le(r)).join(",")),t.Te=e}return t.Te}function li(n,t){if(n.limit!==t.limit||n.orderBy.length!==t.orderBy.length)return!1;for(let e=0;e<n.orderBy.length;e++)if(!Pd(n.orderBy[e],t.orderBy[e]))return!1;if(n.filters.length!==t.filters.length)return!1;for(let e=0;e<n.filters.length;e++)if(!Cc(n.filters[e],t.filters[e]))return!1;return n.collectionGroup===t.collectionGroup&&!!n.path.isEqual(t.path)&&!!la(n.startAt,t.startAt)&&la(n.endAt,t.endAt)}function $s(n){return M.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
968 * @license
969 * Copyright 2017 Google LLC
970 *
971 * Licensed under the Apache License, Version 2.0 (the "License");
972 * you may not use this file except in compliance with the License.
973 * You may obtain a copy of the License at
974 *
975 *   http://www.apache.org/licenses/LICENSE-2.0
976 *
977 * Unless required by applicable law or agreed to in writing, software
978 * distributed under the License is distributed on an "AS IS" BASIS,
979 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
980 * See the License for the specific language governing permissions and
981 * limitations under the License.
982 */class ze{constructor(t,e=null,r=[],s=[],o=null,a="F",l=null,h=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=r,this.filters=s,this.limit=o,this.limitType=a,this.startAt=l,this.endAt=h,this.Ie=null,this.Ee=null,this.de=null,this.startAt,this.endAt}}function Fd(n,t,e,r,s,o,a,l){return new ze(n,t,e,r,s,o,a,l)}function Mr(n){return new ze(n)}function da(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function bc(n){return n.collectionGroup!==null}function gn(n){const t=F(n);if(t.Ie===null){t.Ie=[];const e=new Set;for(const o of t.explicitOrderBy)t.Ie.push(o),e.add(o.field.canonicalString());const r=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(a){let l=new ot(ct.comparator);return a.filters.forEach(h=>{h.getFlattenedFilters().forEach(f=>{f.isInequality()&&(l=l.add(f.field))})}),l})(t).forEach(o=>{e.has(o.canonicalString())||o.isKeyField()||t.Ie.push(new Sn(o,r))}),e.has(ct.keyField().canonicalString())||t.Ie.push(new Sn(ct.keyField(),r))}return t.Ie}function Ot(n){const t=F(n);return t.Ee||(t.Ee=Ud(t,gn(n))),t.Ee}function Ud(n,t){if(n.limitType==="F")return ha(n.path,n.collectionGroup,t,n.filters,n.limit,n.startAt,n.endAt);{t=t.map(s=>{const o=s.dir==="desc"?"asc":"desc";return new Sn(s.field,o)});const e=n.endAt?new vr(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new vr(n.startAt.position,n.startAt.inclusive):null;return ha(n.path,n.collectionGroup,t,n.filters,n.limit,e,r)}}function zs(n,t){const e=n.filters.concat([t]);return new ze(n.path,n.collectionGroup,n.explicitOrderBy.slice(),e,n.limit,n.limitType,n.startAt,n.endAt)}function Ir(n,t,e){return new ze(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),t,e,n.startAt,n.endAt)}function xr(n,t){return li(Ot(n),Ot(t))&&n.limitType===t.limitType}function Dc(n){return`${ui(Ot(n))}|lt:${n.limitType}`}function Ve(n){return`Query(target=${function(e){let r=e.path.canonicalString();return e.collectionGroup!==null&&(r+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(r+=`, filters: [${e.filters.map(s=>Pc(s)).join(", ")}]`),kr(e.limit)||(r+=", limit: "+e.limit),e.orderBy.length>0&&(r+=`, orderBy: [${e.orderBy.map(s=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(s)).join(", ")}]`),e.startAt&&(r+=", startAt: ",r+=e.startAt.inclusive?"b:":"a:",r+=e.startAt.position.map(s=>Le(s)).join(",")),e.endAt&&(r+=", endAt: ",r+=e.endAt.inclusive?"a:":"b:",r+=e.endAt.position.map(s=>Le(s)).join(",")),`Target(${r})`}(Ot(n))}; limitType=${n.limitType})`}function Lr(n,t){return t.isFoundDocument()&&function(r,s){const o=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(o):M.isDocumentKey(r.path)?r.path.isEqual(o):r.path.isImmediateParentOf(o)}(n,t)&&function(r,s){for(const o of gn(r))if(!o.field.isKeyField()&&s.data.field(o.field)===null)return!1;return!0}(n,t)&&function(r,s){for(const o of r.filters)if(!o.matches(s))return!1;return!0}(n,t)&&function(r,s){return!(r.startAt&&!function(a,l,h){const f=ua(a,l,h);return a.inclusive?f<=0:f<0}(r.startAt,gn(r),s)||r.endAt&&!function(a,l,h){const f=ua(a,l,h);return a.inclusive?f>=0:f>0}(r.endAt,gn(r),s))}(n,t)}function Bd(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function Nc(n){return(t,e)=>{let r=!1;for(const s of gn(n)){const o=qd(s,t,e);if(o!==0)return o;r=r||s.field.isKeyField()}return 0}}function qd(n,t,e){const r=n.field.isKeyField()?M.comparator(t.key,e.key):function(o,a,l){const h=a.data.field(o),f=l.data.field(o);return h!==null&&f!==null?xe(h,f):x(42886)}(n.field,t,e);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return x(19790,{direction:n.dir})}}/**
983 * @license
984 * Copyright 2017 Google LLC
985 *
986 * Licensed under the Apache License, Version 2.0 (the "License");
987 * you may not use this file except in compliance with the License.
988 * You may obtain a copy of the License at
989 *
990 *   http://www.apache.org/licenses/LICENSE-2.0
991 *
992 * Unless required by applicable law or agreed to in writing, software
993 * distributed under the License is distributed on an "AS IS" BASIS,
994 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
995 * See the License for the specific language governing permissions and
996 * limitations under the License.
997 */class Ie{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),r=this.inner[e];if(r!==void 0){for(const[s,o]of r)if(this.equalsFn(s,t))return o}}has(t){return this.get(t)!==void 0}set(t,e){const r=this.mapKeyFn(t),s=this.inner[r];if(s===void 0)return this.inner[r]=[[t,e]],void this.innerSize++;for(let o=0;o<s.length;o++)if(this.equalsFn(s[o][0],t))return void(s[o]=[t,e]);s.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),r=this.inner[e];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],t))return r.length===1?delete this.inner[e]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(t){le(this.inner,(e,r)=>{for(const[s,o]of r)t(s,o)})}isEmpty(){return mc(this.inner)}size(){return this.innerSize}}/**
998 * @license
999 * Copyright 2017 Google LLC
1000 *
1001 * Licensed under the Apache License, Version 2.0 (the "License");
1002 * you may not use this file except in compliance with the License.
1003 * You may obtain a copy of the License at
1004 *
1005 *   http://www.apache.org/licenses/LICENSE-2.0
1006 *
1007 * Unless required by applicable law or agreed to in writing, software
1008 * distributed under the License is distributed on an "AS IS" BASIS,
1009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010 * See the License for the specific language governing permissions and
1011 * limitations under the License.
1012 */const jd=new Z(M.comparator);function Gt(){return jd}const kc=new Z(M.comparator);function hn(...n){let t=kc;for(const e of n)t=t.insert(e.key,e);return t}function Oc(n){let t=kc;return n.forEach((e,r)=>t=t.insert(e,r.overlayedDocument)),t}function _e(){return _n()}function Mc(){return _n()}function _n(){return new Ie(n=>n.toString(),(n,t)=>n.isEqual(t))}const $d=new Z(M.comparator),zd=new ot(M.comparator);function q(...n){let t=zd;for(const e of n)t=t.add(e);return t}const Gd=new ot(B);function Hd(){return Gd}/**
1013 * @license
1014 * Copyright 2020 Google LLC
1015 *
1016 * Licensed under the Apache License, Version 2.0 (the "License");
1017 * you may not use this file except in compliance with the License.
1018 * You may obtain a copy of the License at
1019 *
1020 *   http://www.apache.org/licenses/LICENSE-2.0
1021 *
1022 * Unless required by applicable law or agreed to in writing, software
1023 * distributed under the License is distributed on an "AS IS" BASIS,
1024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1025 * See the License for the specific language governing permissions and
1026 * limitations under the License.
1027 */function hi(n,t){if(n.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:yr(t)?"-0":t}}function xc(n){return{integerValue:""+n}}function Kd(n,t){return vd(t)?xc(t):hi(n,t)}/**
1028 * @license
1029 * Copyright 2018 Google LLC
1030 *
1031 * Licensed under the Apache License, Version 2.0 (the "License");
1032 * you may not use this file except in compliance with the License.
1033 * You may obtain a copy of the License at
1034 *
1035 *   http://www.apache.org/licenses/LICENSE-2.0
1036 *
1037 * Unless required by applicable law or agreed to in writing, software
1038 * distributed under the License is distributed on an "AS IS" BASIS,
1039 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1040 * See the License for the specific language governing permissions and
1041 * limitations under the License.
1042 */class Fr{constructor(){this._=void 0}}function Qd(n,t,e){return n instanceof Cn?function(s,o){const a={fields:{[_c]:{stringValue:gc},[Ec]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return o&&ai(o)&&(o=Or(o)),o&&(a.fields[yc]=o),{mapValue:a}}(e,t):n instanceof Pn?Fc(n,t):n instanceof Vn?Uc(n,t):function(s,o){const a=Lc(s,o),l=fa(a)+fa(s.Ae);return qs(a)&&qs(s.Ae)?xc(l):hi(s.serializer,l)}(n,t)}function Wd(n,t,e){return n instanceof Pn?Fc(n,t):n instanceof Vn?Uc(n,t):e}function Lc(n,t){return n instanceof Ar?function(r){return qs(r)||function(o){return!!o&&"doubleValue"in o}(r)}(t)?t:{integerValue:0}:null}class Cn extends Fr{}class Pn extends Fr{constructor(t){super(),this.elements=t}}function Fc(n,t){const e=Bc(t);for(const r of n.elements)e.some(s=>Lt(s,r))||e.push(r);return{arrayValue:{values:e}}}class Vn extends Fr{constructor(t){super(),this.elements=t}}function Uc(n,t){let e=Bc(t);for(const r of n.elements)e=e.filter(s=>!Lt(s,r));return{arrayValue:{values:e}}}
1042class Ar extends Fr{constructor(t,e){super(),this.serializer=t,this.Ae=e}}function fa(n){return et(n.integerValue||n.doubleValue)}function Bc(n){return ci(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}/**
1043 * @license
1044 * Copyright 2017 Google LLC
1045 *
1046 * Licensed under the Apache License, Version 2.0 (the "License");
1047 * you may not use this file except in compliance with the License.
1048 * You may obtain a copy of the License at
1049 *
1050 *   http://www.apache.org/licenses/LICENSE-2.0
1051 *
1052 * Unless required by applicable law or agreed to in writing, software
1053 * distributed under the License is distributed on an "AS IS" BASIS,
1054 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1055 * See the License for the specific language governing permissions and
1056 * limitations under the License.
1057 */class Xd{constructor(t,e){this.field=t,this.transform=e}}function Yd(n,t){return n.field.isEqual(t.field)&&function(r,s){return r instanceof Pn&&s instanceof Pn||r instanceof Vn&&s instanceof Vn?Oe(r.elements,s.elements,Lt):r instanceof Ar&&s instanceof Ar?Lt(r.Ae,s.Ae):r instanceof Cn&&s instanceof Cn}(n.transform,t.transform)}class Jd{constructor(t,e){this.version=t,this.transformResults=e}}class Pt{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new Pt}static exists(t){return new Pt(void 0,t)}static updateTime(t){return new Pt(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function fr(n,t){return n.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(n.updateTime):n.exists===void 0||n.exists===t.isFoundDocument()}class Ur{}function qc(n,t){if(!n.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return n.isNoDocument()?new di(n.key,Pt.none()):new Dn(n.key,n.data,Pt.none());{const e=n.data,r=At.empty();let s=new ot(ct.comparator);for(let o of t.fields)if(!s.has(o)){let a=e.field(o);a===null&&o.length>1&&(o=o.popLast(),a=e.field(o)),a===null?r.delete(o):r.set(o,a),s=s.add(o)}return new he(n.key,r,new St(s.toArray()),Pt.none())}}function Zd(n,t,e){n instanceof Dn?function(s,o,a){const l=s.value.clone(),h=pa(s.fieldTransforms,o,a.transformResults);l.setAll(h),o.convertToFoundDocument(a.version,l).setHasCommittedMutations()}(n,t,e):n instanceof he?function(s,o,a){if(!fr(s.precondition,o))return void o.convertToUnknownDocument(a.version);const l=pa(s.fieldTransforms,o,a.transformResults),h=o.data;h.setAll(jc(s)),h.setAll(l),o.convertToFoundDocument(a.version,h).setHasCommittedMutations()}(n,t,e):function(s,o,a){o.convertToNoDocument(a.version).setHasCommittedMutations()}(0,t,e)}function yn(n,t,e,r){return n instanceof Dn?function(o,a,l,h){if(!fr(o.precondition,a))return l;const f=o.value.clone(),m=ga(o.fieldTransforms,h,a);return f.setAll(m),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),null}(n,t,e,r):n instanceof he?function(o,a,l,h){if(!fr(o.precondition,a))return l;const f=ga(o.fieldTransforms,h,a),m=a.data;return m.setAll(jc(o)),m.setAll(f),a.convertToFoundDocument(a.version,m).setHasLocalMutations(),l===null?null:l.unionWith(o.fieldMask.fields).unionWith(o.fieldTransforms.map(E=>E.field))}(n,t,e,r):function(o,a,l){return fr(o.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):l}(n,t,e)}function tf(n,t){let e=null;for(const r of n.fieldTransforms){const s=t.data.field(r.field),o=Lc(r.transform,s||null);o!=null&&(e===null&&(e=At.empty()),e.set(r.field,o))}return e||null}function ma(n,t){return n.type===t.type&&!!n.key.isEqual(t.key)&&!!n.precondition.isEqual(t.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Oe(r,s,(o,a)=>Yd(o,a))}(n.fieldTransforms,t.fieldTransforms)&&(n.type===0?n.value.isEqual(t.value):n.type!==1||n.data.isEqual(t.data)&&n.fieldMask.isEqual(t.fieldMask))}class Dn extends Ur{constructor(t,e,r,s=[]){super(),this.key=t,this.value=e,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class he extends Ur{constructor(t,e,r,s,o=[]){super(),this.key=t,this.data=e,this.fieldMask=r,this.prec
1057ondition=s,this.fieldTransforms=o,this.type=1}getFieldMask(){return this.fieldMask}}function jc(n){const t=new Map;return n.fieldMask.fields.forEach(e=>{if(!e.isEmpty()){const r=n.data.field(e);t.set(e,r)}}),t}function pa(n,t,e){const r=new Map;K(n.length===e.length,32656,{Re:e.length,Ve:n.length});for(let s=0;s<e.length;s++){const o=n[s],a=o.transform,l=t.data.field(o.field);r.set(o.field,Wd(a,l,e[s]))}return r}function ga(n,t,e){const r=new Map;for(const s of n){const o=s.transform,a=e.data.field(s.field);r.set(s.field,Qd(o,a,t))}return r}class di extends Ur{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class ef extends Ur{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
1058 * @license
1059 * Copyright 2017 Google LLC
1060 *
1061 * Licensed under the Apache License, Version 2.0 (the "License");
1062 * you may not use this file except in compliance with the License.
1063 * You may obtain a copy of the License at
1064 *
1065 *   http://www.apache.org/licenses/LICENSE-2.0
1066 *
1067 * Unless required by applicable law or agreed to in writing, software
1068 * distributed under the License is distributed on an "AS IS" BASIS,
1069 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1070 * See the License for the specific language governing permissions and
1071 * limitations under the License.
1072 */class nf{constructor(t,e,r,s){this.batchId=t,this.localWriteTime=e,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(t,e){const r=e.mutationResults;for(let s=0;s<this.mutations.length;s++){const o=this.mutations[s];o.key.isEqual(t.key)&&Zd(o,t,r[s])}}applyToLocalView(t,e){for(const r of this.baseMutations)r.key.isEqual(t.key)&&(e=yn(r,t,e,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(t.key)&&(e=yn(r,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){const r=Mc();return this.mutations.forEach(s=>{const o=t.get(s.key),a=o.overlayedDocument;let l=this.applyToLocalView(a,o.mutatedFields);l=e.has(s.key)?null:l;const h=qc(a,l);h!==null&&r.set(s.key,h),a.isValidDocument()||a.convertToNoDocument(L.min())}),r}keys(){return this.mutations.reduce((t,e)=>t.add(e.key),q())}isEqual(t){return this.batchId===t.batchId&&Oe(this.mutations,t.mutations,(e,r)=>ma(e,r))&&Oe(this.baseMutations,t.baseMutations,(e,r)=>ma(e,r))}}class fi{constructor(t,e,r,s){this.batch=t,this.commitVersion=e,this.mutationResults=r,this.docVersions=s}static from(t,e,r){K(t.mutations.length===r.length,58842,{me:t.mutations.length,fe:r.length});let s=function(){return $d}();const o=t.mutations;for(let a=0;a<o.length;a++)s=s.insert(o[a].key,r[a].version);return new fi(t,e,r,s)}}/**
1073 * @license
1074 * Copyright 2022 Google LLC
1075 *
1076 * Licensed under the Apache License, Version 2.0 (the "License");
1077 * you may not use this file except in compliance with the License.
1078 * You may obtain a copy of the License at
1079 *
1080 *   http://www.apache.org/licenses/LICENSE-2.0
1081 *
1082 * Unless required by applicable law or agreed to in writing, software
1083 * distributed under the License is distributed on an "AS IS" BASIS,
1084 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1085 * See the License for the specific language governing permissions and
1086 * limitations under the License.
1087 */class rf{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return t!==null&&this.mutation===t.mutation}toString(){return`Overlay{
1088      largestBatchId: ${this.largestBatchId},
1089      mutation: ${this.mutation.toString()}
1090    }`}}/**
1091 * @license
1092 * Copyright 2017 Google LLC
1093 *
1094 * Licensed under the Apache License, Version 2.0 (the "License");
1095 * you may not use this file except in compliance with the License.
1096 * You may obtain a copy of the License at
1097 *
1098 *   http://www.apache.org/licenses/LICENSE-2.0
1099 *
1100 * Unless required by applicable law or agreed to in writing, software
1101 * distributed under the License is distributed on an "AS IS" BASIS,
1102 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1103 * See the License for the specific language governing permissions and
1104 * limitations under the License.
1105 */class sf{constructor(t,e){this.count=t,this.unchangedNames=e}}/**
1106 * @license
1107 * Copyright 2017 Google LLC
1108 *
1109 * Licensed under the Apache License, Version 2.0 (the "License");
1110 * you may not use this file except in compliance with the License.
1111 * You may obtain a copy of the License at
1112 *
1113 *   http://www.apache.org/licenses/LICENSE-2.0
1114 *
1115 * Unless required by applicable law or agreed to in writing, software
1116 * distributed under the License is distributed on an "AS IS" BASIS,
1117 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1118 * See the License for the specific language governing permissions and
1119 * limitations under the License.
1120 */var rt,j;function of(n){switch(n){case S.OK:return x(64938);case S.CANCELLED:case S.UNKNOWN:case S.DEADLINE_EXCEEDED:case S.RESOURCE_EXHAUSTED:case S.INTERNAL:case S.UNAVAILABLE:case S.UNAUTHENTICATED:return!1;case S.INVALID_ARGUMENT:case S.NOT_FOUND:case S.ALREADY_EXISTS:case S.PERMISSION_DENIED:case S.FAILED_PRECONDITION:case S.ABORTED:case S.OUT_OF_RANGE:case S.UNIMPLEMENTED:case S.DATA_LOSS:return!0;default:return x(15467,{code:n})}}function $c(n){if(n===void 0)return zt("GRPC error has no .code"),S.UNKNOWN;switch(n){case rt.OK:return S.OK;case rt.CANCELLED:return S.CANCELLED;case rt.UNKNOWN:return S.UNKNOWN;case rt.DEADLINE_EXCEEDED:return S.DEADLINE_EXCEEDED;case rt.RESOURCE_EXHAUSTED:return S.RESOURCE_EXHAUSTED;case rt.INTERNAL:return S.INTERNAL;case rt.UNAVAILABLE:return S.UNAVAILABLE;case rt.UNAUTHENTICATED:return S.UNAUTHENTICATED;case rt.INVALID_ARGUMENT:return S.INVALID_ARGUMENT;case rt.NOT_FOUND:return S.NOT_FOUND;case rt.ALREADY_EXISTS:return S.ALREADY_EXISTS;case rt.PERMISSION_DENIED:return S.PERMISSION_DENIED;case rt.FAILED_PRECONDITION:return S.FAILED_PRECONDITION;case rt.ABORTED:return S.ABORTED;case rt.OUT_OF_RANGE:return S.OUT_OF_RANGE;case rt.UNIMPLEMENTED:return S.UNIMPLEMENTED;case rt.DATA_LOSS:return S.DATA_LOSS;default:return x(39323,{code:n})}}(j=rt||(rt={}))[j.OK=0]="OK",j[j.CANCELLED=1]="CANCELLED",j[j.UNKNOWN=2]="UNKNOWN",j[j.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",j[j.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",j[j.NOT_FOUND=5]="NOT_FOUND",j[j.ALREADY_EXISTS=6]="ALREADY_EXISTS",j[j.PERMISSION_DENIED=7]="PERMISSION_DENIED",j[j.UNAUTHENTICATED=16]="UNAUTHENTICATED",j[j.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",j[j.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",j[j.ABORTED=10]="ABORTED",j[j.OUT_OF_RANGE=11]="OUT_OF_RANGE",j[j.UNIMPLEMENTED=12]="UNIMPLEMENTED",j[j.INTERNAL=13]="INTERNAL",j[j.UNAVAILABLE=14]="UNAVAILABLE",j[j.DATA_LOSS=15]="DATA_LOSS";/**
1121 * @license
1122 * Copyright 2023 Google LLC
1123 *
1124 * Licensed under the Apache License, Version 2.0 (the "License");
1125 * you may not use this file except in compliance with the License.
1126 * You may obtain a copy of the License at
1127 *
1128 *   http://www.apache.org/licenses/LICENSE-2.0
1129 *
1130 * Unless required by applicable law or agreed to in writing, software
1131 * distributed under the License is distributed on an "AS IS" BASIS,
1132 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1133 * See the License for the specific language governing permissions and
1134 * limitations under the License.
1135 */function af(){return new TextEncoder}/**
1136 * @license
1137 * Copyright 2022 Google LLC
1138 *
1139 * Licensed under the Apache License, Version 2.0 (the "License");
1140 * you may not use this file except in compliance with the License.
1141 * You may obtain a copy of the License at
1142 *
1143 *   http://www.apache.org/licenses/LICENSE-2.0
1144 *
1145 * Unless required by applicable law or agreed to in writing, software
1146 * distributed under the License is distributed on an "AS IS" BASIS,
1147 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1148 * See the License for the specific language governing permissions and
1149 * limitations under the License.
1150 */const cf=new ee([4294967295,4294967295],0);function _a(n){const t=af().encode(n),e=new ec;return e.update(t),new Uint8Array(e.digest())}function ya(n){const t=new DataView(n.buffer),e=t.getUint32(0,!0),r=t.getUint32(4,!0),s=t.getUint32(8,!0),o=t.getUint32(12,!0);return[new ee([e,r],0),new ee([s,o],0)]}class mi{constructor(t,e,r){if(this.bitmap=t,this.padding=e,this.hashCount=r,e<0||e>=8)throw new dn(`Invalid padding: ${e}`);if(r<0)throw new dn(`Invalid hash count: ${r}`);if(t.length>0&&this.hashCount===0)throw new dn(`Invalid hash count: ${r}`);if(t.length===0&&e!==0)throw new dn(`Invalid padding when bitmap length is 0: ${e}`);this.ge=8*t.length-e,this.pe=ee.fromNumber(this.ge)}ye(t,e,r){let s=t.add(e.multiply(ee.fromNumber(r)));return s.compare(cf)===1&&(s=new ee([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(t){return!!(this.bitmap[Math.floor(t/8)]&1<<t%8)}mightContain(t){if(this.ge===0)return!1;const e=_a(t),[r,s]=ya(e);for(let o=0;o<this.hashCount;o++){const a=this.ye(r,s,o);if(!this.we(a))return!1}return!0}static create(t,e,r){const s=t%8==0?0:8-t%8,o=new Uint8Array(Math.ceil(t/8)),a=new mi(o,s,e);return r.forEach(l=>a.insert(l)),a}insert(t){if(this.ge===0)return;const e=_a(t),[r,s]=ya(e);for(let o=0;o<this.hashCount;o++){const a=this.ye(r,s,o);this.Se(a)}}Se(t){const e=Math.floor(t/8),r=t%8;this.bitmap[e]|=1<<r}}
1150class dn extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
1151 * @license
1152 * Copyright 2017 Google LLC
1153 *
1154 * Licensed under the Apache License, Version 2.0 (the "License");
1155 * you may not use this file except in compliance with the License.
1156 * You may obtain a copy of the License at
1157 *
1158 *   http://www.apache.org/licenses/LICENSE-2.0
1159 *
1160 * Unless required by applicable law or agreed to in writing, software
1161 * distributed under the License is distributed on an "AS IS" BASIS,
1162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1163 * See the License for the specific language governing permissions and
1164 * limitations under the License.
1165 */class Br{constructor(t,e,r,s,o){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=o}static createSynthesizedRemoteEventForCurrentChange(t,e,r){const s=new Map;return s.set(t,Nn.createSynthesizedTargetChangeForCurrentChange(t,e,r)),new Br(L.min(),s,new Z(B),Gt(),q())}}class Nn{constructor(t,e,r,s,o){this.resumeToken=t,this.current=e,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=o}static createSynthesizedTargetChangeForCurrentChange(t,e,r){return new Nn(r,e,q(),q(),q())}}/**
1166 * @license
1167 * Copyright 2017 Google LLC
1168 *
1169 * Licensed under the Apache License, Version 2.0 (the "License");
1170 * you may not use this file except in compliance with the License.
1171 * You may obtain a copy of the License at
1172 *
1173 *   http://www.apache.org/licenses/LICENSE-2.0
1174 *
1175 * Unless required by applicable law or agreed to in writing, software
1176 * distributed under the License is distributed on an "AS IS" BASIS,
1177 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1178 * See the License for the specific language governing permissions and
1179 * limitations under the License.
1180 */class mr{constructor(t,e,r,s){this.be=t,this.removedTargetIds=e,this.key=r,this.De=s}}class zc{constructor(t,e){this.targetId=t,this.Ce=e}}class Gc{constructor(t,e,r=ut.EMPTY_BYTE_STRING,s=null){this.state=t,this.targetIds=e,this.resumeToken=r,this.cause=s}}class Ea{constructor(){this.ve=0,this.Fe=Ta(),this.Me=ut.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(t){t.approximateByteSize()>0&&(this.Oe=!0,this.Me=t)}ke(){let t=q(),e=q(),r=q();return this.Fe.forEach((s,o)=>{switch(o){case 0:t=t.add(s);break;case 2:e=e.add(s);break;case 1:r=r.add(s);break;default:x(38017,{changeType:o})}}),new Nn(this.Me,this.xe,t,e,r)}qe(){this.Oe=!1,this.Fe=Ta()}Qe(t,e){this.Oe=!0,this.Fe=this.Fe.insert(t,e)}$e(t){this.Oe=!0,this.Fe=this.Fe.remove(t)}Ue(){this.ve+=1}Ke(){this.ve-=1,K(this.ve>=0,3241,{ve:this.ve})}We(){this.Oe=!0,this.xe=!0}}class uf{constructor(t){this.Ge=t,this.ze=new Map,this.je=Gt(),this.Je=cr(),this.He=cr(),this.Ye=new Z(B)}Ze(t){for(const e of t.be)t.De&&t.De.isFoundDocument()?this.Xe(e,t.De):this.et(e,t.key,t.De);for(const e of t.removedTargetIds)this.et(e,t.key,t.De)}tt(t){this.forEachTarget(t,e=>{const r=this.nt(e);switch(t.state){case 0:this.rt(e)&&r.Le(t.resumeToken);break;case 1:r.Ke(),r.Ne||r.qe(),r.Le(t.resumeToken);break;case 2:r.Ke(),r.Ne||this.removeTarget(e);break;case 3:this.rt(e)&&(r.We(),r.Le(t.resumeToken));break;case 4:this.rt(e)&&(this.it(e),r.Le(t.resumeToken));break;default:x(56790,{state:t.state})}})}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.ze.forEach((r,s)=>{this.rt(s)&&e(s)})}st(t){const e=t.targetId,r=t.Ce.count,s=this.ot(e);if(s){const o=s.target;if($s(o))if(r===0){const a=new M(o.path);this.et(e,a,Et.newNoDocument(a,L.min()))}else K(r===1,20013,{expectedCount:r});else{const a=this._t(e);if(a!==r){const l=this.ut(t),h=l?this.ct(l,t,a):1;if(h!==0){this.it(e);const f=h===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ye=this.Ye.insert(e,f)}}}}}ut(t){const e=t.Ce.unchangedNames;if(!e||!e.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:o=0}=e;let a,l;try{a=oe(r).toUint8Array()}catch(h){if(h instanceof pc)return Te("Decoding the base64 bloom filter in existence filter failed ("+h.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw h}try{l=new mi(a,s,o)}catch(h){return Te(h instanceof dn?"BloomFilter error: ":"Applying bloom filter failed: ",h),null}return l.ge===0?null:l}ct(t,e,r){return e.Ce.count===r-this.Pt(t,e.targetId)?0:2}Pt(t,e){const r=this.Ge.getRemoteKeysForTarget(e);let s=0;return r.forEach(o=>{const a=this.Ge.ht(),l=`projects/${a.projectId}/databases/${a.database}/documents/${o.path.canonicalString()}`;t.mightContain(l)||(this.et(e,o,null),s++)}),s}Tt(t){const e=new Map;this.ze.forEach((o,a)=>{const l=this.ot(a);if(l){if(o.current&&$s(l.target)){const h=new M(l.target.path);this.It(h).has(a)||this.Et(a,h)||this.et(a,h,Et.newNoDocument(h,t))}o.Be&&(e.set(a,o.ke()),o.qe())}});let r=q();this.He.forEach((o,a)=>{let l=!0;a.forEachWhile(h=>{const f=this.ot(h);return!f||f.purpose==="TargetPurposeLimboResolution"||(l=!1,!1)}),l&&(r=r.add(o))}),this.je.forEach((o,a)=>a.setReadTime(t));const s=new Br(t,e,this.Ye,this.je,r);return this.je=Gt(),this.Je=cr(),this.He=cr(),this.Ye=new Z(B),s}Xe(t,e){if(!this.rt(t))return;const r=this.Et(t,e.key)?2:0;this.nt(t).Qe(e.key,r),this.je=this.je.insert(e.key,e),this.Je=this.Je.insert(e.key,this.It(e.key).add(t)),this.He=this.He.insert(e.key,this.dt(e.key).add(t))}et(t,e,r){if(!this.rt(t))return;const s=this.nt(t);this.Et(t,e)?s.Qe(e,1):s.$e(e),this.He=this.He.insert(e,this.dt(e).delete(t)),this.He=this.He.insert(e,this.dt(e).add(t)),r&&(this.je=this.je.insert(e,r))}removeTarget(t){this.ze.delete(t)}_t(t){const e=this.nt(t).ke();return this.Ge.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}Ue(t){this.nt(t).Ue()}nt(t){let e=this.ze.get(t);return e||(e=new Ea,this.ze.set(t,e)),e}dt(t){let e=this.He.get(t);return e||(e=new ot(B),this.He=this.He.insert(t,e)),e}It(t){let e=this.Je.get(t);return e||(e=new ot(B),this.Je=this.Je.insert(t,e)),e}rt(t){const e=this.ot(t)!==null;return e||k("WatchChangeAggregator","Detected inactive target",t),e}
1180ot(t){const e=this.ze.get(t);return e&&e.Ne?null:this.Ge.At(t)}it(t){this.ze.set(t,new Ea),this.Ge.getRemoteKeysForTarget(t).forEach(e=>{this.et(t,e,null)})}Et(t,e){return this.Ge.getRemoteKeysForTarget(t).has(e)}}function cr(){return new Z(M.comparator)}function Ta(){return new Z(M.comparator)}const lf={asc:"ASCENDING",desc:"DESCENDING"},hf={"<":"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"},df={and:"AND",or:"OR"};class ff{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function Gs(n,t){return n.useProto3Json||kr(t)?t:{value:t}}function wr(n,t){return n.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function Hc(n,t){return n.useProto3Json?t.toBase64():t.toUint8Array()}function mf(n,t){return wr(n,t.toTimestamp())}function Mt(n){return K(!!n,49232),L.fromTimestamp(function(e){const r=ie(e);return new X(r.seconds,r.nanos)}(n))}function pi(n,t){return Hs(n,t).canonicalString()}function Hs(n,t){const e=function(s){return new W(["projects",s.projectId,"databases",s.database])}(n).child("documents");return t===void 0?e:e.child(t)}function Kc(n){const t=W.fromString(n);return K(Jc(t),10190,{key:t.toString()}),t}function Ks(n,t){return pi(n.databaseId,t.path)}function Vs(n,t){const e=Kc(t);if(e.get(1)!==n.databaseId.projectId)throw new N(S.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+n.databaseId.projectId);if(e.get(3)!==n.databaseId.database)throw new N(S.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+n.databaseId.database);return new M(Wc(e))}function Qc(n,t){return pi(n.databaseId,t)}function pf(n){const t=Kc(n);return t.length===4?W.emptyPath():Wc(t)}function Qs(n){return new W(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function Wc(n){return K(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function va(n,t,e){return{name:Ks(n,t),fields:e.value.mapValue.fields}}function gf(n,t){let e;if("targetChange"in t){t.targetChange;const r=function(f){return f==="NO_CHANGE"?0:f==="ADD"?1:f==="REMOVE"?2:f==="CURRENT"?3:f==="RESET"?4:x(39313,{state:f})}(t.targetChange.targetChangeType||"NO_CHANGE"),s=t.targetChange.targetIds||[],o=function(f,m){return f.useProto3Json?(K(m===void 0||typeof m=="string",58123),ut.fromBase64String(m||"")):(K(m===void 0||m instanceof Buffer||m instanceof Uint8Array,16193),ut.fromUint8Array(m||new Uint8Array))}(n,t.targetChange.resumeToken),a=t.targetChange.cause,l=a&&function(f){const m=f.code===void 0?S.UNKNOWN:$c(f.code);return new N(m,f.message||"")}(a);e=new Gc(r,s,o,l||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const s=Vs(n,r.document.name),o=Mt(r.document.updateTime),a=r.document.createTime?Mt(r.document.createTime):L.min(),l=new At({mapValue:{fields:r.document.fields}}),h=Et.newFoundDocument(s,o,a,l),f=r.targetIds||[],m=r.removedTargetIds||[];e=new mr(f,m,h.key,h)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const s=Vs(n,r.document),o=r.readTime?Mt(r.readTime):L.min(),a=Et.newNoDocument(s,o),l=r.removedTargetIds||[];e=new mr([],l,a.key,a)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const s=Vs(n,r.document),o=r.removedTargetIds||[];e=new mr([],o,s,null)}else{if(!("filter"in t))return x(11601,{Rt:t});{t.filter;const r=t.filter;r.targetId;const{count:s=0,unchangedNames:o}=r,a=new sf(s,o),l=r.targetId;e=new zc(l,a)}}return e}function _f(n,t){let e;if(t instanceof Dn)e={update:va(n,t.key,t.value)};else if(t instanceof di)e={delete:Ks(n,t.key)};else if(t instanceof he)e={update:va(n,t.key,t.data),updateMask:Sf(t.fieldMask)};else{if(!(t instanceof ef))return x(16599,{Vt:t.type});e={verify:Ks(n,t.key)}}return t.fieldTransforms.length>0&&(e.updateTransforms=t.fieldTransforms.map(r=>function(o,a){const l=a.transform;if(l instanceof Cn)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};
1180if(l instanceof Pn)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:l.elements}};if(l instanceof Vn)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:l.elements}};if(l instanceof Ar)return{fieldPath:a.field.canonicalString(),increment:l.Ae};throw x(20930,{transform:a.transform})}(0,r))),t.precondition.isNone||(e.currentDocument=function(s,o){return o.updateTime!==void 0?{updateTime:mf(s,o.updateTime)}:o.exists!==void 0?{exists:o.exists}:x(27497)}(n,t.precondition)),e}function yf(n,t){return n&&n.length>0?(K(t!==void 0,14353),n.map(e=>function(s,o){let a=s.updateTime?Mt(s.updateTime):Mt(o);return a.isEqual(L.min())&&(a=Mt(o)),new Jd(a,s.transformResults||[])}(e,t))):[]}function Ef(n,t){return{documents:[Qc(n,t.path)]}}function Tf(n,t){const e={structuredQuery:{}},r=t.path;let s;t.collectionGroup!==null?(s=r,e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(s=r.popLast(),e.structuredQuery.from=[{collectionId:r.lastSegment()}]),e.parent=Qc(n,s);const o=function(f){if(f.length!==0)return Yc(Nt.create(f,"and"))}(t.filters);o&&(e.structuredQuery.where=o);const a=function(f){if(f.length!==0)return f.map(m=>function(T){return{field:be(T.field),direction:Af(T.dir)}}(m))}(t.orderBy);a&&(e.structuredQuery.orderBy=a);const l=Gs(n,t.limit);return l!==null&&(e.structuredQuery.limit=l),t.startAt&&(e.structuredQuery.startAt=function(f){return{before:f.inclusive,values:f.position}}(t.startAt)),t.endAt&&(e.structuredQuery.endAt=function(f){return{before:!f.inclusive,values:f.position}}(t.endAt)),{ft:e,parent:s}}function vf(n){let t=pf(n.parent);const e=n.structuredQuery,r=e.from?e.from.length:0;let s=null;if(r>0){K(r===1,65062);const m=e.from[0];m.allDescendants?s=m.collectionId:t=t.child(m.collectionId)}let o=[];e.where&&(o=function(E){const T=Xc(E);return T instanceof Nt&&Sc(T)?T.getFilters():[T]}(e.where));let a=[];e.orderBy&&(a=function(E){return E.map(T=>function(b){return new Sn(De(b.field),function(D){switch(D){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(b.direction))}(T))}(e.orderBy));let l=null;e.limit&&(l=function(E){let T;return T=typeof E=="object"?E.value:E,kr(T)?null:T}(e.limit));let h=null;e.startAt&&(h=function(E){const T=!!E.before,P=E.values||[];return new vr(P,T)}(e.startAt));let f=null;return e.endAt&&(f=function(E){const T=!E.before,P=E.values||[];return new vr(P,T)}(e.endAt)),Fd(t,s,a,o,l,"F",h,f)}function If(n,t){const e=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return x(28987,{purpose:s})}}(t.purpose);return e==null?null:{"goog-listen-tags":e}}function Xc(n){return n.unaryFilter!==void 0?function(e){switch(e.unaryFilter.op){case"IS_NAN":const r=De(e.unaryFilter.field);return st.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=De(e.unaryFilter.field);return st.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const o=De(e.unaryFilter.field);return st.create(o,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=De(e.unaryFilter.field);return st.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return x(61313);default:return x(60726)}}(n):n.fieldFilter!==void 0?function(e){return st.create(De(e.fieldFilter.field),function(s){switch(s){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";case"OPERATOR_UNSPECIFIED":return x(58110);default:return x(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(e){return Nt.create(e.compositeFilter.filters.map(r=>Xc(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return x(1026)}}(e.compositeFilter.op))}(n):x(30097,{filter:n})}function Af(n){return lf[n]}function wf(n){return hf[n]}function Rf(n){return df[n]}function be(n){return{fieldPath:n.canonicalString()}}function De(n){return ct.fromServerFormat(n.fieldPath)}function Yc(n){return n instanceof st?function(e){if(e.op==="=="){if(ca(e.value))return{unaryFilter:{field:be(e.field),op:"IS_NAN"}};if(aa(e.value))return{unaryFilter:{field:be(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(ca(e.value))return{unaryFilter:{field:be(e.field),op:"IS_NOT_NA
1180N"}};if(aa(e.value))return{unaryFilter:{field:be(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:be(e.field),op:wf(e.op),value:e.value}}}(n):n instanceof Nt?function(e){const r=e.getFilters().map(s=>Yc(s));return r.length===1?r[0]:{compositeFilter:{op:Rf(e.op),filters:r}}}(n):x(54877,{filter:n})}function Sf(n){const t=[];return n.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function Jc(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
1181 * @license
1182 * Copyright 2017 Google LLC
1183 *
1184 * Licensed under the Apache License, Version 2.0 (the "License");
1185 * you may not use this file except in compliance with the License.
1186 * You may obtain a copy of the License at
1187 *
1188 *   http://www.apache.org/licenses/LICENSE-2.0
1189 *
1190 * Unless required by applicable law or agreed to in writing, software
1191 * distributed under the License is distributed on an "AS IS" BASIS,
1192 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1193 * See the License for the specific language governing permissions and
1194 * limitations under the License.
1195 */class Jt{constructor(t,e,r,s,o=L.min(),a=L.min(),l=ut.EMPTY_BYTE_STRING,h=null){this.target=t,this.targetId=e,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=o,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=l,this.expectedCount=h}withSequenceNumber(t){return new Jt(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,e){return new Jt(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new Jt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new Jt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}/**
1196 * @license
1197 * Copyright 2017 Google LLC
1198 *
1199 * Licensed under the Apache License, Version 2.0 (the "License");
1200 * you may not use this file except in compliance with the License.
1201 * You may obtain a copy of the License at
1202 *
1203 *   http://www.apache.org/licenses/LICENSE-2.0
1204 *
1205 * Unless required by applicable law or agreed to in writing, software
1206 * distributed under the License is distributed on an "AS IS" BASIS,
1207 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1208 * See the License for the specific language governing permissions and
1209 * limitations under the License.
1210 */class Cf{constructor(t){this.yt=t}}function Pf(n){const t=vf({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Ir(t,t.limit,"L"):t}/**
1211 * @license
1212 * Copyright 2019 Google LLC
1213 *
1214 * Licensed under the Apache License, Version 2.0 (the "License");
1215 * you may not use this file except in compliance with the License.
1216 * You may obtain a copy of the License at
1217 *
1218 *   http://www.apache.org/licenses/LICENSE-2.0
1219 *
1220 * Unless required by applicable law or agreed to in writing, software
1221 * distributed under the License is distributed on an "AS IS" BASIS,
1222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223 * See the License for the specific language governing permissions and
1224 * limitations under the License.
1225 */class Vf{constructor(){this.Cn=new bf}addToCollectionParentIndex(t,e){return this.Cn.add(e),C.resolve()}getCollectionParents(t,e){return C.resolve(this.Cn.getEntries(e))}addFieldIndex(t,e){return C.resolve()}deleteFieldIndex(t,e){return C.resolve()}deleteAllFieldIndexes(t){return C.resolve()}createTargetIndexes(t,e){return C.resolve()}getDocumentsMatchingTarget(t,e){return C.resolve(null)}getIndexType(t,e){return C.resolve(0)}getFieldIndexes(t,e){return C.resolve([])}getNextCollectionGroupToUpdate(t){return C.resolve(null)}getMinOffset(t,e){return C.resolve(se.min())}getMinOffsetFromCollectionGroup(t,e){return C.resolve(se.min())}updateCollectionGroup(t,e,r){return C.resolve()}updateIndexEntries(t,e){return C.resolve()}}class bf{constructor(){this.index={}}add(t){const e=t.lastSegment(),r=t.popLast(),s=this.index[e]||new ot(W.comparator),o=!s.has(r);return this.index[e]=s.add(r),o}has(t){const e=t.lastSegment(),r=t.popLast(),s=this.index[e];return s&&s.has(r)}getEntries(t){return(this.index[t]||new ot(W.comparator)).toArray()}}/**
1226 * @license
1227 * Copyright 2018 Google LLC
1228 *
1229 * Licensed under the Apache License, Version 2.0 (the "License");
1230 * you may not use this file except in compliance with the License.
1231 * You may obtain a copy of the License at
1232 *
1233 *   http://www.apache.org/licenses/LICENSE-2.0
1234 *
1235 * Unless required by applicable law or agreed to in writing, software
1236 * distributed under the License is distributed on an "AS IS" BASIS,
1237 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1238 * See the License for the specific language governing permissions and
1239 * limitations under the License.
1240 */const Ia={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Zc=41943040;class It{static withCacheSize(t){return new It(t,It.DEFAULT_COLLECTION_PERCENTILE,It.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(t,e,r){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=r}}/**
1241 * @license
1242 * Copyright 2017 Google LLC
1243 *
1244 * Licensed under the Apache License, Version 2.0 (the "License");
1245 * you may not use this file except in compliance with the License.
1246 * You may obtain a copy of the License at
1247 *
1248 *   http://www.apache.org/licenses/LICENSE-2.0
1249 *
1250 * Unless required by applicable law or agreed to in writing, software
1251 * distributed under the License is distributed on an "AS IS" BASIS,
1252 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1253 * See the License for the specific language governing permissions and
1254 * limitations under the License.
1255 */It.DEFAULT_COLLECTION_PERCENTILE=10,It.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,It.DEFAULT=new It(Zc,It.DEFAULT_COLLECTION_PERCENTILE,It.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),It.DISABLED=new It(-1,0,0);/**
1256 * @license
1257 * Copyright 2017 Google LLC
1258 *
1259 * Licensed under the Apache License, Version 2.0 (the "License");
1260 * you may not use this file except in compliance with the License.
1261 * You may obtain a copy of the License at
1262 *
1263 *   http://www.apache.org/licenses/LICENSE-2.0
1264 *
1265 * Unless required by applicable law or agreed to in writing, software
1266 * distributed under the License is distributed on an "AS IS" BASIS,
1267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1268 * See the License for the specific language governing permissions and
1269 * limitations under the License.
1270 */class Fe{constructor(t){this.ar=t}next(){return this.ar+=2,this.ar}static ur(){return new Fe(0)}static cr(){return new Fe(-1)}}/**
1271 * @license
1272 * Copyright 2020 Google LLC
1273 *
1274 * Licensed under the Apache License, Version 2.0 (the "License");
1275 * you may not use this file except in compliance with the License.
1276 * You may obtain a copy of the License at
1277 *
1278 *   http://www.apache.org/licenses/LICENSE-2.0
1279 *
1280 * Unless required by applicable law or agreed to in writing, software
1281 * distributed under the License is distributed on an "AS IS" BASIS,
1282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1283 * See the License for the specific language governing permissions and
1284 * limitations under the License.
1285 */const Aa="LruGarbageCollector",Df=1048576;function wa([n,t],[e,r]){const s=B(n,e);return s===0?B(t,r):s}class Nf{constructor(t){this.Ir=t,this.buffer=new ot(wa),this.Er=0}dr(){return++this.Er}Ar(t){const e=[t,this.dr()];if(this.buffer.size<this.Ir)this.buffer=this.buffer.add(e);else{const r=this.buffer.last();wa(e,r)<0&&(this.buffer=this.buffer.delete(r).add(e))}}get maxValue(){return this.buffer.last()[0]}}class kf{constructor(t,e,r){this.garbageCollector=t,this.asyncQueue=e,this.localStore=r,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Vr(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Vr(t){k(Aa,`Garbage collection scheduled in ${t}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){$e(e)?k(Aa,"Ignoring IndexedDB error during garbage collection: ",e):await je(e)}await this.Vr(3e5)})}}class Of{constructor(t,e){this.mr=t,this.params=e}calculateTargetCount(t,e){return this.mr.gr(t).next(r=>Math.floor(e/100*r))}nthSequenceNumber(t,e){if(e===0)return C.resolve(Nr.ce);const r=new Nf(e);return this.mr.forEachTarget(t,s=>r.Ar(s.sequenceNumber)).next(()=>this.mr.pr(t,s=>r.Ar(s))).next(()=>r.maxValue)}removeTargets(t,e,r){return this.mr.removeTargets(t,e,r)}removeOrphanedDocuments(t,e){return this.mr.removeOrphanedDocuments(t,e)}collect(t,e){return this.params.cacheSizeCollectionThreshold===-1?(k("LruGarbageCollector","Garbage collection skipped; disabled"),C.resolve(Ia)):this.getCacheSize(t).next(r=>r<this.params.cacheSizeCollectionThreshold?(k("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Ia):this.yr(t,e))}getCacheSize(t){return this.mr.getCacheSize(t)}
1285yr(t,e){let r,s,o,a,l,h,f;const m=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(E=>(E>this.params.maximumSequenceNumbersToCollect?(k("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${E}`),s=this.params.maximumSequenceNumbersToCollect):s=E,a=Date.now(),this.nthSequenceNumber(t,s))).next(E=>(r=E,l=Date.now(),this.removeTargets(t,r,e))).next(E=>(o=E,h=Date.now(),this.removeOrphanedDocuments(t,r))).next(E=>(f=Date.now(),Pe()<=$.DEBUG&&k("LruGarbageCollector",`LRU Garbage Collection
1286	Counted targets in ${a-m}ms
1287	Determined least recently used ${s} in `+(l-a)+`ms
1288	Removed ${o} targets in `+(h-l)+`ms
1289	Removed ${E} documents in `+(f-h)+`ms
1290Total Duration: ${f-m}ms`),C.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:o,documentsRemoved:E})))}}function Mf(n,t){return new Of(n,t)}/**
1291 * @license
1292 * Copyright 2017 Google LLC
1293 *
1294 * Licensed under the Apache License, Version 2.0 (the "License");
1295 * you may not use this file except in compliance with the License.
1296 * You may obtain a copy of the License at
1297 *
1298 *   http://www.apache.org/licenses/LICENSE-2.0
1299 *
1300 * Unless required by applicable law or agreed to in writing, software
1301 * distributed under the License is distributed on an "AS IS" BASIS,
1302 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1303 * See the License for the specific language governing permissions and
1304 * limitations under the License.
1305 */class xf{constructor(){this.changes=new Ie(t=>t.toString(),(t,e)=>t.isEqual(e)),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,Et.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const r=this.changes.get(e);return r!==void 0?C.resolve(r):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}/**
1306 * @license
1307 * Copyright 2017 Google LLC
1308 *
1309 * Licensed under the Apache License, Version 2.0 (the "License");
1310 * you may not use this file except in compliance with the License.
1311 * You may obtain a copy of the License at
1312 *
1313 *   http://www.apache.org/licenses/LICENSE-2.0
1314 *
1315 * Unless required by applicable law or agreed to in writing, software
1316 * distributed under the License is distributed on an "AS IS" BASIS,
1317 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1318 * See the License for the specific language governing permissions and
1319 * limitations under the License.
1320 *//**
1321 * @license
1322 * Copyright 2022 Google LLC
1323 *
1324 * Licensed under the Apache License, Version 2.0 (the "License");
1325 * you may not use this file except in compliance with the License.
1326 * You may obtain a copy of the License at
1327 *
1328 *   http://www.apache.org/licenses/LICENSE-2.0
1329 *
1330 * Unless required by applicable law or agreed to in writing, software
1331 * distributed under the License is distributed on an "AS IS" BASIS,
1332 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1333 * See the License for the specific language governing permissions and
1334 * limitations under the License.
1335 */class Lf{constructor(t,e){this.overlayedDocument=t,this.mutatedFields=e}}/**
1336 * @license
1337 * Copyright 2017 Google LLC
1338 *
1339 * Licensed under the Apache License, Version 2.0 (the "License");
1340 * you may not use this file except in compliance with the License.
1341 * You may obtain a copy of the License at
1342 *
1343 *   http://www.apache.org/licenses/LICENSE-2.0
1344 *
1345 * Unless required by applicable law or agreed to in writing, software
1346 * distributed under the License is distributed on an "AS IS" BASIS,
1347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1348 * See the License for the specific language governing permissions and
1349 * limitations under the License.
1350 */class Ff{constructor(t,e,r,s){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=r,this.indexManager=s}getDocument(t,e){let r=null;return this.documentOverlayCache.getOverlay(t,e).next(s=>(r=s,this.remoteDocumentCache.getEntry(t,e))).next(s=>(r!==null&&yn(r.mutation,s,St.empty(),X.now()),s))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(r=>this.getLocalViewOfDocuments(t,r,q()).next(()=>r))}getLocalViewOfDocuments(t,e,r=q()){const s=_e();return this.populateOverlays(t,s,e).next(()=>this.computeViews(t,e,s,r).next(o=>{let a=hn();return o.forEach((l,h)=>{a=a.insert(l,h.overlayedDocument)}),a}))}getOverlayedDocuments(t,e){const r=_e();return this.populateOverlays(t,r,e).next(()=>this.computeViews(t,e,r,q()))}populateOverlays(t,e,r){const s=[];return r.forEach(o=>{e.has(o)||s.push(o)}),this.documentOverlayCache.getOverlays(t,s).next(o=>{o.forEach((a,l)=>{e.set(a,l)})})}computeViews(t,e,r,s){let o=Gt();const a=_n(),l=function(){return _n()}();return e.forEach((h,f)=>{const m=r.get(f.key);s.has(f.key)&&(m===void 0||m.mutation instanceof he)?o=o.insert(f.key,f):m!==void 0?(a.set(f.key,m.mutation.getFieldMask()),yn(m.mutation,f,m.mutation.getFieldMask(),X.now())):a.set(f.key,St.empty())}),this.recalculateAndSaveOverlays(t,o).next(h=>
1350(h.forEach((f,m)=>a.set(f,m)),e.forEach((f,m)=>l.set(f,new Lf(m,a.get(f)??null))),l))}recalculateAndSaveOverlays(t,e){const r=_n();let s=new Z((a,l)=>a-l),o=q();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next(a=>{for(const l of a)l.keys().forEach(h=>{const f=e.get(h);if(f===null)return;let m=r.get(h)||St.empty();m=l.applyToLocalView(f,m),r.set(h,m);const E=(s.get(l.batchId)||q()).add(h);s=s.insert(l.batchId,E)})}).next(()=>{const a=[],l=s.getReverseIterator();for(;l.hasNext();){const h=l.getNext(),f=h.key,m=h.value,E=Mc();m.forEach(T=>{if(!o.has(T)){const P=qc(e.get(T),r.get(T));P!==null&&E.set(T,P),o=o.add(T)}}),a.push(this.documentOverlayCache.saveOverlays(t,f,E))}return C.waitFor(a)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(r=>this.recalculateAndSaveOverlays(t,r))}getDocumentsMatchingQuery(t,e,r,s){return function(a){return M.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):bc(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,r,s):this.getDocumentsMatchingCollectionQuery(t,e,r,s)}getNextDocuments(t,e,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,r,s).next(o=>{const a=s-o.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,r.largestBatchId,s-o.size):C.resolve(_e());let l=An,h=o;return a.next(f=>C.forEach(f,(m,E)=>(l<E.largestBatchId&&(l=E.largestBatchId),o.get(m)?C.resolve():this.remoteDocumentCache.getEntry(t,m).next(T=>{h=h.insert(m,T)}))).next(()=>this.populateOverlays(t,f,o)).next(()=>this.computeViews(t,h,f,q())).next(m=>({batchId:l,changes:Oc(m)})))})}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new M(e)).next(r=>{let s=hn();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(t,e,r,s){const o=e.collectionGroup;let a=hn();return this.indexManager.getCollectionParents(t,o).next(l=>C.forEach(l,h=>{const f=function(E,T){return new ze(T,null,E.explicitOrderBy.slice(),E.filters.slice(),E.limit,E.limitType,E.startAt,E.endAt)}(e,h.child(o));return this.getDocumentsMatchingCollectionQuery(t,f,r,s).next(m=>{m.forEach((E,T)=>{a=a.insert(E,T)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(t,e,r,s){let o;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,r.largestBatchId).next(a=>(o=a,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,r,o,s))).next(a=>{o.forEach((h,f)=>{const m=f.getKey();a.get(m)===null&&(a=a.insert(m,Et.newInvalidDocument(m)))});let l=hn();return a.forEach((h,f)=>{const m=o.get(h);m!==void 0&&yn(m.mutation,f,St.empty(),X.now()),Lr(e,f)&&(l=l.insert(h,f))}),l})}}/**
1351 * @license
1352 * Copyright 2020 Google LLC
1353 *
1354 * Licensed under the Apache License, Version 2.0 (the "License");
1355 * you may not use this file except in compliance with the License.
1356 * You may obtain a copy of the License at
1357 *
1358 *   http://www.apache.org/licenses/LICENSE-2.0
1359 *
1360 * Unless required by applicable law or agreed to in writing, software
1361 * distributed under the License is distributed on an "AS IS" BASIS,
1362 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1363 * See the License for the specific language governing permissions and
1364 * limitations under the License.
1365 */class Uf{constructor(t){this.serializer=t,this.Lr=new Map,this.kr=new Map}getBundleMetadata(t,e){return C.resolve(this.Lr.get(e))}saveBundleMetadata(t,e){return this.Lr.set(e.id,function(s){return{id:s.id,version:s.version,createTime:Mt(s.createTime)}}(e)),C.resolve()}getNamedQuery(t,e){return C.resolve(this.kr.get(e))}saveNamedQuery(t,e){return this.kr.set(e.name,function(s){return{name:s.name,query:Pf(s.bundledQuery),readTime:Mt(s.readTime)}}(e)),C.resolve()}}/**
1366 * @license
1367 * Copyright 2022 Google LLC
1368 *
1369 * Licensed under the Apache License, Version 2.0 (the "License");
1370 * you may not use this file except in compliance with the License.
1371 * You may obtain a copy of the License at
1372 *
1373 *   http://www.apache.org/licenses/LICENSE-2.0
1374 *
1375 * Unless required by applicable law or agreed to in writing, softw
1375are
1376 * distributed under the License is distributed on an "AS IS" BASIS,
1377 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1378 * See the License for the specific language governing permissions and
1379 * limitations under the License.
1380 */class Bf{constructor(){this.overlays=new Z(M.comparator),this.qr=new Map}getOverlay(t,e){return C.resolve(this.overlays.get(e))}getOverlays(t,e){const r=_e();return C.forEach(e,s=>this.getOverlay(t,s).next(o=>{o!==null&&r.set(s,o)})).next(()=>r)}saveOverlays(t,e,r){return r.forEach((s,o)=>{this.St(t,e,o)}),C.resolve()}removeOverlaysForBatchId(t,e,r){const s=this.qr.get(r);return s!==void 0&&(s.forEach(o=>this.overlays=this.overlays.remove(o)),this.qr.delete(r)),C.resolve()}getOverlaysForCollection(t,e,r){const s=_e(),o=e.length+1,a=new M(e.child("")),l=this.overlays.getIteratorFrom(a);for(;l.hasNext();){const h=l.getNext().value,f=h.getKey();if(!e.isPrefixOf(f.path))break;f.path.length===o&&h.largestBatchId>r&&s.set(h.getKey(),h)}return C.resolve(s)}getOverlaysForCollectionGroup(t,e,r,s){let o=new Z((f,m)=>f-m);const a=this.overlays.getIterator();for(;a.hasNext();){const f=a.getNext().value;if(f.getKey().getCollectionGroup()===e&&f.largestBatchId>r){let m=o.get(f.largestBatchId);m===null&&(m=_e(),o=o.insert(f.largestBatchId,m)),m.set(f.getKey(),f)}}const l=_e(),h=o.getIterator();for(;h.hasNext()&&(h.getNext().value.forEach((f,m)=>l.set(f,m)),!(l.size()>=s)););return C.resolve(l)}St(t,e,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.qr.get(s.largestBatchId).delete(r.key);this.qr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new rf(e,r));let o=this.qr.get(e);o===void 0&&(o=q(),this.qr.set(e,o)),this.qr.set(e,o.add(r.key))}}/**
1381 * @license
1382 * Copyright 2024 Google LLC
1383 *
1384 * Licensed under the Apache License, Version 2.0 (the "License");
1385 * you may not use this file except in compliance with the License.
1386 * You may obtain a copy of the License at
1387 *
1388 *   http://www.apache.org/licenses/LICENSE-2.0
1389 *
1390 * Unless required by applicable law or agreed to in writing, software
1391 * distributed under the License is distributed on an "AS IS" BASIS,
1392 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1393 * See the License for the specific language governing permissions and
1394 * limitations under the License.
1395 */class qf{constructor(){this.sessionToken=ut.EMPTY_BYTE_STRING}getSessionToken(t){return C.resolve(this.sessionToken)}setSessionToken(t,e){return this.sessionToken=e,C.resolve()}}/**
1396 * @license
1397 * Copyright 2017 Google LLC
1398 *
1399 * Licensed under the Apache License, Version 2.0 (the "License");
1400 * you may not use this file except in compliance with the License.
1401 * You may obtain a copy of the License at
1402 *
1403 *   http://www.apache.org/licenses/LICENSE-2.0
1404 *
1405 * Unless required by applicable law or agreed to in writing, software
1406 * distributed under the License is distributed on an "AS IS" BASIS,
1407 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1408 * See the License for the specific language governing permissions and
1409 * limitations under the License.
1410 */class gi{constructor(){this.Qr=new ot(at.$r),this.Ur=new ot(at.Kr)}isEmpty(){return this.Qr.isEmpty()}addReference(t,e){const r=new at(t,e);this.Qr=this.Qr.add(r),this.Ur=this.Ur.add(r)}Wr(t,e){t.forEach(r=>this.addReference(r,e))}removeReference(t,e){this.Gr(new at(t,e))}zr(t,e){t.forEach(r=>this.removeReference(r,e))}jr(t){const e=new M(new W([])),r=new at(e,t),s=new at(e,t+1),o=[];return this.Ur.forEachInRange([r,s],a=>{this.Gr(a),o.push(a.key)}),o}Jr(){this.Qr.forEach(t=>this.Gr(t))}Gr(t){this.Qr=this.Qr.delete(t),this.Ur=this.Ur.delete(t)}Hr(t){const e=new M(new W([])),r=new at(e,t),s=new at(e,t+1);let o=q();return this.Ur.forEachInRange([r,s],a=>{o=o.add(a.key)}),o}containsKey(t){const e=new at(t,0),r=this.Qr.firstAfterOrEqual(e);return r!==null&&t.isEqual(r.key)}}class at{constructor(t,e){this.key=t,this.Yr=e}static $r(t,e){return M.comparator(t.key,e.key)||B(t.Yr,e.Yr)}static Kr(t,e){return B(t.Yr,e.Yr)||M.comparator(t.key,e.key)}}/**
1411 * @license
1412 * Copyright 2017 Google LLC
1413 *
1414 * Licensed under the Apache License, Version 2.0 (the "License");
1415 * you may not use this file except in compliance with the License.
1416 * You may obtain a copy of the License at
1417 *
1418 *   http://www.apache.org/licenses/LICENSE-2.0
1419 *
1420 * Unless required by applicable law or agreed to in writing, software
1421 * distributed under the License is distributed on an "AS IS" BASIS,
1422 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1423 * See the License for the specific language governing permissions and
1424 * limitations under the License.
1425 */class jf{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.tr=1,this.Zr=new ot(at.$r)}checkEmpty(t){return C.resolve(this.mutationQueue.length===0)}addMutationBatch(t,e,r,s){const o=this.tr;this.tr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new nf(o,e,r,s);this.mutationQueue.push(a);for(const l of s)this.Zr=this.Zr.add(new at(l.key,o)),this.indexManager.addToCollectionParentIndex(t,l.key.path.popLast());return C.resolve(a)}lookupMutationBatch(t,e){return C.resolve(this.Xr(e))}getNextMutationBatchAfterBatchId(t,e){const r=e+1,s=this.ei(r),o=s<0?0:s;return C.resolve(this.mutationQueue.length>o?this.mutationQueue[o]:null)}getHighestUnacknowledgedBatchId(){return C.resolve(this.mutationQueue.length===0?oi:this.tr-1)}getAllMutationBatches(t){return C.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const r=new at(e,0),s=new at(e,Number.POSITIVE_INFINITY),o=[];return this.Zr.forEachInRange([r,s],a=>{const l=this.Xr(a.Yr);o.push(l)}),C.resolve(o)}getAllMutationBatchesAffectingDocumentKeys(t,e){let r=new ot(B);return e.forEach(s=>{const o=new at(s,0),a=new at(s,Number.POSITIVE_INFINITY);this.Zr.forEachInRange([o,a],l=>{r=r.add(l.Yr)})}),C.resolve(this.ti(r))}getAllMutationBatchesAffectingQuery(t,e){const r=e.path,s=r.length+1;let o=r;M.isDocumentKey(o)||(o=o.child(""));const a=new at(new M(o),0);let l=new ot(B);return this.Zr.forEachWhile(h=>{const f=h.key.path;return!!r.isPrefixOf(f)&&(f.length===s&&(l=l.add(h.Yr)),!0)},a),C.resolve(this.ti(l))}ti(t){const e=[];return t.forEach(r=>{const s=this.Xr(r);s!==null&&e.push(s)}),e}removeMutationBatch(t,e){K(this.ni(e.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Zr;
1425return C.forEach(e.mutations,s=>{const o=new at(s.key,e.batchId);return r=r.delete(o),this.referenceDelegate.markPotentiallyOrphaned(t,s.key)}).next(()=>{this.Zr=r})}ir(t){}containsKey(t,e){const r=new at(e,0),s=this.Zr.firstAfterOrEqual(r);return C.resolve(e.isEqual(s&&s.key))}performConsistencyCheck(t){return this.mutationQueue.length,C.resolve()}ni(t,e){return this.ei(t)}ei(t){return this.mutationQueue.length===0?0:t-this.mutationQueue[0].batchId}Xr(t){const e=this.ei(t);return e<0||e>=this.mutationQueue.length?null:this.mutationQueue[e]}}/**
1426 * @license
1427 * Copyright 2017 Google LLC
1428 *
1429 * Licensed under the Apache License, Version 2.0 (the "License");
1430 * you may not use this file except in compliance with the License.
1431 * You may obtain a copy of the License at
1432 *
1433 *   http://www.apache.org/licenses/LICENSE-2.0
1434 *
1435 * Unless required by applicable law or agreed to in writing, software
1436 * distributed under the License is distributed on an "AS IS" BASIS,
1437 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1438 * See the License for the specific language governing permissions and
1439 * limitations under the License.
1440 */class $f{constructor(t){this.ri=t,this.docs=function(){return new Z(M.comparator)}(),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){const r=e.key,s=this.docs.get(r),o=s?s.size:0,a=this.ri(e);return this.docs=this.docs.insert(r,{document:e.mutableCopy(),size:a}),this.size+=a-o,this.indexManager.addToCollectionParentIndex(t,r.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const r=this.docs.get(e);return C.resolve(r?r.document.mutableCopy():Et.newInvalidDocument(e))}getEntries(t,e){let r=Gt();return e.forEach(s=>{const o=this.docs.get(s);r=r.insert(s,o?o.document.mutableCopy():Et.newInvalidDocument(s))}),C.resolve(r)}getDocumentsMatchingQuery(t,e,r,s){let o=Gt();const a=e.path,l=new M(a.child("__id-9223372036854775808__")),h=this.docs.getIteratorFrom(l);for(;h.hasNext();){const{key:f,value:{document:m}}=h.getNext();if(!a.isPrefixOf(f.path))break;f.path.length>a.length+1||_d(gd(m),r)<=0||(s.has(m.key)||Lr(e,m))&&(o=o.insert(m.key,m.mutableCopy()))}return C.resolve(o)}getAllFromCollectionGroup(t,e,r,s){x(9500)}
1440ii(t,e){return C.forEach(this.docs,r=>e(r))}newChangeBuffer(t){return new zf(this)}getSize(t){return C.resolve(this.size)}}class zf extends xf{constructor(t){super(),this.Nr=t}applyChanges(t){const e=[];return this.changes.forEach((r,s)=>{s.isValidDocument()?e.push(this.Nr.addEntry(t,s)):this.Nr.removeEntry(r)}),C.waitFor(e)}getFromCache(t,e){return this.Nr.getEntry(t,e)}getAllFromCache(t,e){return this.Nr.getEntries(t,e)}}/**
1441 * @license
1442 * Copyright 2017 Google LLC
1443 *
1444 * Licensed under the Apache License, Version 2.0 (the "License");
1445 * you may not use this file except in compliance with the License.
1446 * You may obtain a copy of the License at
1447 *
1448 *   http://www.apache.org/licenses/LICENSE-2.0
1449 *
1450 * Unless required by applicable law or agreed to in writing, software
1451 * distributed under the License is distributed on an "AS IS" BASIS,
1452 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1453 * See the License for the specific language governing permissions and
1454 * limitations under the License.
1455 */class Gf{constructor(t){this.persistence=t,this.si=new Ie(e=>ui(e),li),this.lastRemoteSnapshotVersion=L.min(),this.highestTargetId=0,this.oi=0,this._i=new gi,this.targetCount=0,this.ai=Fe.ur()}forEachTarget(t,e){return this.si.forEach((r,s)=>e(s)),C.resolve()}getLastRemoteSnapshotVersion(t){return C.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return C.resolve(this.oi)}allocateTargetId(t){return this.highestTargetId=this.ai.next(),C.resolve(this.highestTargetId)}setTargetsMetadata(t,e,r){return r&&(this.lastRemoteSnapshotVersion=r),e>this.oi&&(this.oi=e),C.resolve()}Pr(t){this.si.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.ai=new Fe(e),this.highestTargetId=e),t.sequenceNumber>this.oi&&(this.oi=t.sequenceNumber)}addTargetData(t,e){return this.Pr(e),this.targetCount+=1,C.resolve()}updateTargetData(t,e){return this.Pr(e),C.resolve()}removeTargetData(t,e){return this.si.delete(e.target),this._i.jr(e.targetId),this.targetCount-=1,C.resolve()}removeTargets(t,e,r){let s=0;const o=[];return this.si.forEach((a,l)=>{l.sequenceNumber<=e&&r.get(l.targetId)===null&&(this.si.delete(a),o.push(this.removeMatchingKeysForTargetId(t,l.targetId)),s++)}),C.waitFor(o).next(()=>s)}getTargetCount(t){return C.resolve(this.targetCount)}getTargetData(t,e){const r=this.si.get(e)||null;return C.resolve(r)}addMatchingKeys(t,e,r){return this._i.Wr(e,r),C.resolve()}removeMatchingKeys(t,e,r){this._i.zr(e,r);const s=this.persistence.referenceDelegate,o=[];return s&&e.forEach(a=>{o.push(s.markPotentiallyOrphaned(t,a))}),C.waitFor(o)}removeMatchingKeysForTargetId(t,e){return this._i.jr(e),C.resolve()}getMatchingKeysForTargetId(t,e){const r=this._i.Hr(e);return C.resolve(r)}containsKey(t,e){return C.resolve(this._i.containsKey(e))}}/**
1456 * @license
1457 * Copyright 2017 Google LLC
1458 *
1459 * Licensed under the Apache License, Version 2.0 (the "License");
1460 * you may not use this file except in compliance with the License.
1461 * You may obtain a copy of the License at
1462 *
1463 *   http://www.apache.org/licenses/LICENSE-2.0
1464 *
1465 * Unless required by applicable law or agreed to in writing, software
1466 * distributed under the License is distributed on an "AS IS" BASIS,
1467 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1468 * See the License for the specific language governing permissions and
1469 * limitations under the License.
1470 */class tu{constructor(t,e){this.ui={},this.overlays={},this.ci=new Nr(0),this.li=!1,this.li=!0,this.hi=new qf,this.referenceDelegate=t(this),this.Pi=new Gf(this),this.indexManager=new Vf,this.remoteDocumentCache=function(s){return new $f(s)}(r=>this.referenceDelegate.Ti(r)),this.serializer=new Cf(e),this.Ii=new Uf(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.li=!1,Promise.resolve()}get started(){return this.li}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new Bf,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let r=this.ui[t.toKey()];return r||(r=new jf(e,this.referenceDelegate),this.ui[t.toKey()]=r),r}getGlobalsCache(){return this.hi}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ii}runTransaction(t,e,r){k("MemoryPersistence","Starting transaction:",t);const s=new Hf(this.ci.next());return this.referenceDelegate.Ei(),r(s).next(o=>this.referenceDelegate.di(s).next(()=>o)).toPromise().then(o=>(s.raiseOnCommittedEvent(),o))}Ai(t,e){return C.or(Object.values(this.ui).map(r=>()=>r.containsKey(t,e)))}}
vendor: 1,695 bytes, line 1470
1470class Hf extends Ed{constructor(t){super(),this.currentSequenceNumber=t}}class _i{constructor(t){this.persistence=t,this.Ri=new gi,this.Vi=null}static mi(t){return new _i(t)}get fi(){if(this.Vi)return this.Vi;throw x(60996)}addReference(t,e,r){return this.Ri.addReference(r,e),this.fi.delete(r.toString()),C.resolve()}removeReference(t,e,r){return this.Ri.removeReference(r,e),this.fi.add(r.toString()),C.resolve()}markPotentiallyOrphaned(t,e){return this.fi.add(e.toString()),C.resolve()}removeTarget(t,e){this.Ri.jr(e.targetId).forEach(s=>this.fi.add(s.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next(s=>{s.forEach(o=>this.fi.add(o.toString()))}).next(()=>r.removeTargetData(t,e))}Ei(){this.Vi=new Set}di(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return C.forEach(this.fi,r=>{const s=M.fromPath(r);return this.gi(t,s).next(o=>{o||e.removeEntry(s,L.min())})}).next(()=>(this.Vi=null,e.apply(t)))}updateLimboDocument(t,e){return this.gi(t,e).next(r=>{r?this.fi.delete(e.toString()):this.fi.add(e.toString())})}Ti(t){return 0}gi(t,e){return C.or([()=>C.resolve(this.Ri.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Ai(t,e)])}}class Rr{constructor(t,e){this.persistence=t,this.pi=new Ie(r=>Id(r.path),(r,s)=>r.isEqual(s)),this.garbageCollector=Mf(this,e)}static mi(t,e){return new Rr(t,e)}Ei(){}di(t){return C.resolve()}forEachTarget(t,e){return this.persistence.getTargetCache().forEachTarget(t,e)}gr(t){const e=this.wr(t);return this.persistence.getTargetCache().getTargetCount(t).next(r=>e.next(s=>r+s))}wr(t){let e=0;return this.pr(t,r=>{e++}).next(()=>e)}
1470pr(t,e){return C.forEach(this.pi,(r,s)=>this.br(t,r,s).next(o=>o?C.resolve():e(s)))}removeTargets(t,e,r){return this.persistence.getTargetCache().removeTargets(t,e,r)}removeOrphanedDocuments(t,e){let r=0;const s=this.persistence.getRemoteDocumentCache(),o=s.newChangeBuffer();return s.ii(t,a=>this.br(t,a,e).next(l=>{l||(r++,o.removeEntry(a,L.min()))})).next(()=>o.apply(t)).next(()=>r)}markPotentiallyOrphaned(t,e){return this.pi.set(e,t.currentSequenceNumber),C.resolve()}removeTarget(t,e){const r=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,r)}addReference(t,e,r){return this.pi.set(r,t.currentSequenceNumber),C.resolve()}removeReference(t,e,r){return this.pi.set(r,t.currentSequenceNumber),C.resolve()}updateLimboDocument(t,e){return this.pi.set(e,t.currentSequenceNumber),C.resolve()}Ti(t){let e=t.key.toString().length;return t.isFoundDocument()&&(e+=hr(t.data.value)),e}br(t,e,r){return C.or([()=>this.persistence.Ai(t,e),()=>this.persistence.getTargetCache().containsKey(t,e),()=>{const s=this.pi.get(e);return C.resolve(s!==void 0&&s>r)}])}getCacheSize(t){return this.persistence.getRemoteDocumentCache().getSize(t)}}/**
1471 * @license
1472 * Copyright 2017 Google LLC
1473 *
1474 * Licensed under the Apache License, Version 2.0 (the "License");
1475 * you may not use this file except in compliance with the License.
1476 * You may obtain a copy of the License at
1477 *
1478 *   http://www.apache.org/licenses/LICENSE-2.0
1479 *
1480 * Unless required by applicable law or agreed to in writing, software
1481 * distributed under the License is distributed on an "AS IS" BASIS,
1482 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1483 * See the License for the specific language governing permissions and
1484 * limitations under the License.
1485 */class yi{constructor(t,e,r,s){this.targetId=t,this.fromCache=e,this.Es=r,this.ds=s}static As(t,e){let r=q(),s=q();for(const o of e.docChanges)switch(o.type){case 0:r=r.add(o.doc.key);break;case 1:s=s.add(o.doc.key)}return new yi(t,e.fromCache,r,s)}}/**
1486 * @license
1487 * Copyright 2023 Google LLC
1488 *
1489 * Licensed under the Apache License, Version 2.0 (the "License");
1490 * you may not use this file except in compliance with the License.
1491 * You may obtain a copy of the License at
1492 *
1493 *   http://www.apache.org/licenses/LICENSE-2.0
1494 *
1495 * Unless required by applicable law or agreed to in writing, software
1496 * distributed under the License is distributed on an "AS IS" BASIS,
1497 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1498 * See the License for the specific language governing permissions and
1499 * limitations under the License.
1500 */class Kf{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(t){this._documentReadCount+=t}}/**
1501 * @license
1502 * Copyright 2019 Google LLC
1503 *
1504 * Licensed under the Apache License, Version 2.0 (the "License");
1505 * you may not use this file except in compliance with the License.
1506 * You may obtain a copy of the License at
1507 *
1508 *   http://www.apache.org/licenses/LICENSE-2.0
1509 *
1510 * Unless required by applicable law or agreed to in writing, software
1511 * distributed under the License is distributed on an "AS IS" BASIS,
1512 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1513 * See the License for the specific language governing permissions and
1514 * limitations under the License.
1515 */class Qf{constructor(){this.Rs=!1,this.Vs=!1,this.fs=100,this.gs=function(){return Ul()?8:Td(ri())>0?6:4}()}initialize(t,e){this.ps=t,this.indexManager=e,this.Rs=!0}getDocumentsMatchingQuery(t,e,r,s){const o={result:null};return this.ys(t,e).next(a=>{o.result=a}).next(()=>{if(!o.result)return this.ws(t,e,s,r).next(a=>{o.result=a})}).next(()=>{if(o.result)return;const a=new Kf;return this.Ss(t,e,a).next(l=>{if(o.result=l,this.Vs)return this.bs(t,e,a,l.size)})}).next(()=>o.result)}bs(t,e,r,s){return r.documentReadCount<this.fs?(Pe()<=$.DEBUG&&k("QueryEngine","SDK will not create cache indexes for query:",Ve(e),"since it only creates cache indexes for collection contains","more than or equal to",this.fs,"documents"),C.resolve()):(Pe()<=$.DEBUG&&k("QueryEngine","Query:",Ve(e),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.gs*s?(Pe()<=$.DEBUG&&k("QueryEngine","The SDK decides to create cache indexes for query:",Ve(e),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,Ot(e))):C.resolve())}ys(t,e){if(da(e))return C.resolve(null);let r=Ot(e);return this.indexManager.getIndexType(t,r).next(s=>s===0?null:(e.limit!==null&&s===1&&(e=Ir(e,null,"F"),r=Ot(e)),this.indexManager.getDocumentsMatchingTarget(t,r).next(o=>{const a=q(...o);return this.ps.getDocuments(t,a).next(l=>this.indexManager.getMinOffset(t,r).next(h=>{const f=this.Ds(e,l);return this.Cs(e,f,a,h.readTime)?this.ys(t,Ir(e,null,"F")):this.vs(t,f,e,h)}))})))}ws(t,e,r,s){return da(e)||s.isEqual(L.min())?C.resolve(null):this.ps.getDocuments(t,r).next(o=>{const a=this.Ds(e,o);return this.Cs(e,a,r,s)?C.resolve(null):(Pe()<=$.DEBUG&&k("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Ve(e)),this.vs(t,a,e,pd(s,An)
1515).next(l=>l))})}Ds(t,e){let r=new ot(Nc(t));return e.forEach((s,o)=>{Lr(t,o)&&(r=r.add(o))}),r}Cs(t,e,r,s){if(t.limit===null)return!1;if(r.size!==e.size)return!0;const o=t.limitType==="F"?e.last():e.first();return!!o&&(o.hasPendingWrites||o.version.compareTo(s)>0)}Ss(t,e,r){return Pe()<=$.DEBUG&&k("QueryEngine","Using full collection scan to execute query:",Ve(e)),this.ps.getDocumentsMatchingQuery(t,e,se.min(),r)}vs(t,e,r,s){return this.ps.getDocumentsMatchingQuery(t,r,s).next(o=>(e.forEach(a=>{o=o.insert(a.key,a)}),o))}}/**
1516 * @license
1517 * Copyright 2020 Google LLC
1518 *
1519 * Licensed under the Apache License, Version 2.0 (the "License");
1520 * you may not use this file except in compliance with the License.
1521 * You may obtain a copy of the License at
1522 *
1523 *   http://www.apache.org/licenses/LICENSE-2.0
1524 *
1525 * Unless required by applicable law or agreed to in writing, software
1526 * distributed under the License is distributed on an "AS IS" BASIS,
1527 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1528 * See the License for the specific language governing permissions and
1529 * limitations under the License.
1530 */const Ei="LocalStore",Wf=3e8;class Xf{constructor(t,e,r,s){this.persistence=t,this.Fs=e,this.serializer=s,this.Ms=new Z(B),this.xs=new Ie(o=>ui(o),li),this.Os=new Map,this.Ns=t.getRemoteDocumentCache(),this.Pi=t.getTargetCache(),this.Ii=t.getBundleCache(),this.Bs(r)}Bs(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Ff(this.Ns,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ns.setIndexManager(this.indexManager),this.Fs.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.Ms))}}function Yf(n,t,e,r){return new Xf(n,t,e,r)}async function eu(n,t){const e=F(n);return await e.persistence.runTransaction("Handle user change","readonly",r=>{let s;return e.mutationQueue.getAllMutationBatches(r).next(o=>(s=o,e.Bs(t),e.mutationQueue.getAllMutationBatches(r))).next(o=>{const a=[],l=[];let h=q();for(const f of s){a.push(f.batchId);for(const m of f.mutations)h=h.add(m.key)}for(const f of o){l.push(f.batchId);for(const m of f.mutations)h=h.add(m.key)}return e.localDocuments.getDocuments(r,h).next(f=>({Ls:f,removedBatchIds:a,addedBatchIds:l}))})})}function Jf(n,t){const e=F(n);return e.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const s=t.batch.keys(),o=e.Ns.newChangeBuffer({trackRemovals:!0});return function(l,h,f,m){const E=f.batch,T=E.keys();let P=C.resolve();return T.forEach(b=>{P=P.next(()=>m.getEntry(h,b)).next(O=>{const D=f.docVersions.get(b);K(D!==null,48541),O.version.compareTo(D)<0&&(E.applyToRemoteDocument(O,f),O.isValidDocument()&&(O.setReadTime(f.commitVersion),m.addEntry(O)))})}),P.next(()=>l.mutationQueue.removeMutationBatch(h,E))}(e,r,t,o).next(()=>o.apply(r)).next(()=>e.mutationQueue.performConsistencyCheck(r)).next(()=>e.documentOverlayCache.removeOverlaysForBatchId(r,s,t.batch.batchId)).next(()=>e.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(l){let h=q();for(let f=0;f<l.mutationResults.length;++f)l.mutationResults[f].transformResults.length>0&&(h=h.add(l.batch.mutations[f].key));return h}(t))).next(()=>e.localDocuments.getDocuments(r,s))})}function nu(n){const t=F(n);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.Pi.getLastRemoteSnapshotVersion(e))}function Zf(n,t){const e=F(n),r=t.snapshotVersion;let s=e.Ms;return e.persistence.runTransaction("Apply remote event","readwrite-primary",o=>{const a=e.Ns.newChangeBuffer({trackRemovals:!0});s=e.Ms;const l=[];
1530t.targetChanges.forEach((m,E)=>{const T=s.get(E);if(!T)return;l.push(e.Pi.removeMatchingKeys(o,m.removedDocuments,E).next(()=>e.Pi.addMatchingKeys(o,m.addedDocuments,E)));let P=T.withSequenceNumber(o.currentSequenceNumber);t.targetMismatches.get(E)!==null?P=P.withResumeToken(ut.EMPTY_BYTE_STRING,L.min()).withLastLimboFreeSnapshotVersion(L.min()):m.resumeToken.approximateByteSize()>0&&(P=P.withResumeToken(m.resumeToken,r)),s=s.insert(E,P),function(O,D,G){return O.resumeToken.approximateByteSize()===0||D.snapshotVersion.toMicroseconds()-O.snapshotVersion.toMicroseconds()>=Wf?!0:G.addedDocuments.size+G.modifiedDocuments.size+G.removedDocuments.size>0}(T,P,m)&&l.push(e.Pi.updateTargetData(o,P))});let h=Gt(),f=q();if(t.documentUpdates.forEach(m=>{t.resolvedLimboDocuments.has(m)&&l.push(e.persistence.referenceDelegate.updateLimboDocument(o,m))}),l.push(tm(o,a,t.documentUpdates).next(m=>{h=m.ks,f=m.qs})),!r.isEqual(L.min())){const m=e.Pi.getLastRemoteSnapshotVersion(o).next(E=>e.Pi.setTargetsMetadata(o,o.currentSequenceNumber,r));l.push(m)}return C.waitFor(l).next(()=>a.apply(o)).next(()=>e.localDocuments.getLocalViewOfDocuments(o,h,f)).next(()=>h)}).then(o=>(e.Ms=s,o))}function tm(n,t,e){let r=q(),s=q();return e.forEach(o=>r=r.add(o)),t.getEntries(n,r).next(o=>{let a=Gt();return e.forEach((l,h)=>{const f=o.get(l);h.isFoundDocument()!==f.isFoundDocument()&&(s=s.add(l)),h.isNoDocument()&&h.version.isEqual(L.min())?(t.removeEntry(l,h.readTime),a=a.insert(l,h)):!f.isValidDocument()||h.version.compareTo(f.version)>0||h.version.compareTo(f.version)===0&&f.hasPendingWrites?(t.addEntry(h),a=a.insert(l,h)):k(Ei,"Ignoring outdated watch update for ",l,". Current version:",f.version," Watch version:",h.version)}),{ks:a,qs:s}})}function em(n,t){const e=F(n);return e.persistence.runTransaction("Get next mutation batch","readonly",r=>(t===void 0&&(t=oi),e.mutationQueue.getNextMutationBatchAfterBatchId(r,t)))}function nm(n,t){const e=F(n);return e.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return e.Pi.getTargetData(r,t).next(o=>o?(s=o,C.resolve(s)):e.Pi.allocateTargetId(r).next(a=>(s=new Jt(t,a,"TargetPurposeListen",r.currentSequenceNumber),e.Pi.addTargetData(r,s).next(()=>s))))}).then(r=>{const s=e.Ms.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(e.Ms=e.Ms.insert(r.targetId,r),e.xs.set(t,r.targetId)),r})}async function Ws(n,t,e){const r=F(n),s=r.Ms.get(t),o=e?"readwrite":"readwrite-primary";try{e||await r.persistence.runTransaction("Release target",o,a=>r.persistence.referenceDelegate.removeTarget(a,s))}catch(a){if(!$e(a))throw a;k(Ei,`Failed to update sequence numbers for target ${t}: ${a}`)}r.Ms=r.Ms.remove(t),r.xs.delete(s.target)}function Ra(n,t,e){const r=F(n);let s=L.min(),o=q();return r.persistence.runTransaction("Execute query","readwrite",a=>function(h,f,m){const E=F(h),T=E.xs.get(m);return T!==void 0?C.resolve(E.Ms.get(T)):E.Pi.getTargetData(f,m)}(r,a,Ot(t)).next(l=>{if(l)return s=l.lastLimboFreeSnapshotVersion,r.Pi.getMatchingKeysForTargetId(a,l.targetId).next(h=>{o=h})}).next(()=>r.Fs.getDocumentsMatchingQuery(a,t,e?s:L.min(),e?o:q())).next(l=>(rm(r,Bd(t),l),{documents:l,Qs:o})))}function rm(n,t,e){let r=n.Os.get(t)||L.min();e.forEach((s,o)=>{o.readTime.compareTo(r)>0&&(r=o.readTime)}),n.Os.set(t,r)}class Sa{constructor(){this.activeTargetIds=Hd()}zs(t){this.activeTargetIds=this.activeTargetIds.add(t)}js(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Gs(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class sm{constructor(){this.Mo=new Sa,this.xo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,r){}addLocalQueryTarget(t,e=!0){return e&&this.Mo.zs(t),this.xo[t]||"not-current"}updateQueryState(t,e,r){this.xo[t]=e}removeLocalQueryTarget(t){this.Mo.js(t)}isLocalQueryTarget(t){return this.Mo.activeTargetIds.has(t)}clearQueryState(t){delete this.xo[t]}getAllActiveQueryTargets(){return this.Mo.activeTargetIds}isActiveQueryTarget(t){return this.Mo.activeTargetIds.has(t)}start(){return this.Mo=new Sa,Promise.resolve()}handleUserChange(t,e,r){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/**
1531 * @license
1532 * Copyright 2019 Google LLC
1533 *
1534 * Licensed under the Apache License, Version 2.0 (the "License");
1535 * you may not use this file except in compliance with the License.
1536 * You may obtain a copy of the License at
1537 *
1538 *   http://www.apache.org/licenses/LICENSE-2.0
1539 *
1540 * Unless required by applicable law or agreed to in writing, software
1541 * distributed under the License is distributed on an "AS IS" BASIS,
1542 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1543 * See the License for the specific language governing permissions and
1544 * limitations under the License.
1545 */class im{Oo(t){}shutdown(){}}/**
1546 * @license
1547 * Copyright 2019 Google LLC
1548 *
1549 * Licensed under the Apache License, Version 2.0 (the "License");
1550 * you may not use this file except in compliance with the License.
1551 * You may obtain a copy of the License at
1552 *
1553 *   http://www.apache.org/licenses/LICENSE-2.0
1554 *
1555 * Unless required by applicable law or agreed to in writing, software
1556 * distributed under the License is distributed on an "AS IS" BASIS,
1557 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1558 * See the License for the specific language governing permissions and
1559 * limitations under the License.
1560 */const Ca="ConnectivityMonitor";class Pa{constructor(){this.No=()=>this.Bo(),this.Lo=()=>this.ko(),this.qo=[],this.Qo()}Oo(t){this.qo.push(t)}shutdown(){window.removeEventListener("online",this.No),window.removeEventListener("offline",this.Lo)}Qo(){window.addEventListener("online",this.No),window.addEventListener("offline",this.Lo)}Bo(){k(Ca,"Network connectivity changed: AVAILABLE");for(const t of this.qo)t(0)}ko(){k(Ca,"Network connectivity changed: UNAVAILABLE");for(const t of this.qo)t(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
1561 * @license
1562 * Copyright 2023 Google LLC
1563 *
1564 * Licensed under the Apache License, Version 2.0 (the "License");
1565 * you may not use this file except in compliance with the License.
1566 * You may obtain a copy of the License at
1567 *
1568 *   http://www.apache.org/licenses/LICENSE-2.0
1569 *
1570 * Unless required by applicable law or agreed to in writing, software
1571 * distributed under the License is distributed on an "AS IS" BASIS,
1572 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1573 * See the License for the specific language governing permissions and
1574 * limitations under the License.
1575 */let ur=null;function Xs(){return ur===null?ur=function(){return 268435456+Math.round(2147483648*Math.random())}():ur++,"0x"+ur.toString(16)}/**
1576 * @license
1577 * Copyright 2020 Google LLC
1578 *
1579 * Licensed under the Apache License, Version 2.0 (the "License");
1580 * you may not use this file except in compliance with the License.
1581 * You may obtain a copy of the License at
1582 *
1583 *   http://www.apache.org/licenses/LICENSE-2.0
1584 *
1585 * Unless required by applicable law or agreed to in writing, software
1586 * distributed under the License is distributed on an "AS IS" BASIS,
1587 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1588 * See the License for the specific language governing permissions and
1589 * limitations under the License.
1590 */const bs="RestConnection",om={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class am{get $o(){return!1}constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Uo=e+"://"+t.host,this.Ko=`projects/${r}/databases/${s}`,this.Wo=this.databaseId.database===Er?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Go(t,e,r,s,o){const a=Xs(),l=this.zo(t,e.toUriEncodedString());k(bs,`Sending RPC '${t}' ${a}:`,l,r);const h={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Wo};this.jo(h,s,o);const{host:f}=new URL(l),m=ni(f);return this.Jo(t,l,h,r,m).then(E=>(k(bs,`Received RPC '${t}' ${a}: `,E),E),E=>{throw Te(bs,`RPC '${t}' ${a} failed with error: `,E,"url: ",l,"request:",r),E})}Ho(t,e,r,s,o,a){return this.Go(t,e,r,s,o)}jo(t,e,r){t["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+qe}(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEac
1590h((s,o)=>t[o]=s),r&&r.headers.forEach((s,o)=>t[o]=s)}zo(t,e){const r=om[t];return`${this.Uo}/v1/${e}:${r}`}terminate(){}}/**
1591 * @license
1592 * Copyright 2017 Google LLC
1593 *
1594 * Licensed under the Apache License, Version 2.0 (the "License");
1595 * you may not use this file except in compliance with the License.
1596 * You may obtain a copy of the License at
1597 *
1598 *   http://www.apache.org/licenses/LICENSE-2.0
1599 *
1600 * Unless required by applicable law or agreed to in writing, software
1601 * distributed under the License is distributed on an "AS IS" BASIS,
1602 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1603 * See the License for the specific language governing permissions and
1604 * limitations under the License.
1605 */class cm{constructor(t){this.Yo=t.Yo,this.Zo=t.Zo}Xo(t){this.e_=t}t_(t){this.n_=t}r_(t){this.i_=t}onMessage(t){this.s_=t}close(){this.Zo()}send(t){this.Yo(t)}o_(){this.e_()}__(){this.n_()}a_(t){this.i_(t)}u_(t){this.s_(t)}}/**
1606 * @license
1607 * Copyright 2017 Google LLC
1608 *
1609 * Licensed under the Apache License, Version 2.0 (the "License");
1610 * you may not use this file except in compliance with the License.
1611 * You may obtain a copy of the License at
1612 *
1613 *   http://www.apache.org/licenses/LICENSE-2.0
1614 *
1615 * Unless required by applicable law or agreed to in writing, software
1616 * distributed under the License is distributed on an "AS IS" BASIS,
1617 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1618 * See the License for the specific language governing permissions and
1619 * limitations under the License.
1620 */const _t="WebChannelConnection";class um extends am{constructor(t){super(t),this.c_=[],this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}Jo(t,e,r,s,o){const a=Xs();return new Promise((l,h)=>{const f=new nc;f.setWithCredentials(!0),f.listenOnce(rc.COMPLETE,()=>{try{switch(f.getLastErrorCode()){case lr.NO_ERROR:const E=f.getResponseJson();k(_t,`XHR for RPC '${t}' ${a} received:`,JSON.stringify(E)),l(E);break;case lr.TIMEOUT:k(_t,`RPC '${t}' ${a} timed out`),h(new N(S.DEADLINE_EXCEEDED,"Request time out"));break;case lr.HTTP_ERROR:const T=f.getStatus();if(k(_t,`RPC '${t}' ${a} failed with status:`,T,"response text:",f.getResponseText()),T>0){let P=f.getResponseJson();Array.isArray(P)&&(P=P[0]);const b=P==null?void 0:P.error;if(b&&b.status&&b.message){const O=function(G){const U=G.toLowerCase().replace(/_/g,"-");return Object.values(S).indexOf(U)>=0?U:S.UNKNOWN}(b.status);h(new N(O,b.message))}else h(new N(S.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new N(S.UNAVAILABLE,"Connection failed."));break;default:x(9055,{l_:t,streamId:a,h_:f.getLastErrorCode(),P_:f.getLastError()})}}finally{k(_t,`RPC '${t}' ${a} completed.`)}});const m=JSON.stringify(s);k(_t,`RPC '${t}' ${a} sending request:`,s),f.send(e,"POST",m,r,15)})}T_(t,e,r){const s=Xs(),o=[this.Uo,"/","google.firestore.v1.Firestore","/",t,"/channel"],a=oc(),l=ic(),h={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},f=this.longPollingOptions.timeoutSeconds;f!==void 0&&(h.longPollingTimeout=Math.round(1e3*f)),this.useFetchStreams&&(h.useFetchStreams=!0),this.jo(h.initMessageHeaders,e,r),h.encodeInitMessageHeaders=!0;const m=o.join("");k(_t,`Creating RPC '${t}' stream ${s}: ${m}`,h);const E=a.createWebChannel(m,h);this.I_(E);let T=!1,P=!1;const b=new cm({Yo:D=>{P?k(_t,`Not sending because RPC '${t}' stream ${s} is closed:`,D):(T||(k(_t,`Opening RPC '${t}' stream ${s} transport.`),E.open(),T=!0),k(_t,`RPC '${t}' stream ${s} sending:`,D),E.send(D))},Zo:()=>E.close()}),O=(D,G,U)=>{D.listen(G,z=>{try{U(z)}catch(nt){setTimeout(()=>{throw nt},0)}})};return O(E,ln.EventType.OPEN,()=>{P||(k(_t,`RPC '${t}' stream ${s} transport opened.`),b.o_())}),O(E,ln.EventType.CLOSE,()=>{P||(P=!0,k(_t,`RPC '${t}' stream ${s} transport closed`),b.a_(),this.E_(E))}
1620),O(E,ln.EventType.ERROR,D=>{P||(P=!0,Te(_t,`RPC '${t}' stream ${s} transport errored. Name:`,D.name,"Message:",D.message),b.a_(new N(S.UNAVAILABLE,"The operation could not be completed")))}),O(E,ln.EventType.MESSAGE,D=>{var G;if(!P){const U=D.data[0];K(!!U,16349);const z=U,nt=(z==null?void 0:z.error)||((G=z[0])==null?void 0:G.error);if(nt){k(_t,`RPC '${t}' stream ${s} received error:`,nt);const Ft=nt.status;let lt=function(_){const y=rt[_];if(y!==void 0)return $c(y)}(Ft),I=nt.message;lt===void 0&&(lt=S.INTERNAL,I="Unknown error status: "+Ft+" with message "+nt.message),P=!0,b.a_(new N(lt,I)),E.close()}else k(_t,`RPC '${t}' stream ${s} received:`,U),b.u_(U)}}),O(l,sc.STAT_EVENT,D=>{D.stat===Fs.PROXY?k(_t,`RPC '${t}' stream ${s} detected buffering proxy`):D.stat===Fs.NOPROXY&&k(_t,`RPC '${t}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{b.__()},0),b}terminate(){this.c_.forEach(t=>t.close()),this.c_=[]}I_(t){this.c_.push(t)}E_(t){this.c_=this.c_.filter(e=>e===t)}}function Ds(){return typeof document<"u"?document:null}/**
1621 * @license
1622 * Copyright 2020 Google LLC
1623 *
1624 * Licensed under the Apache License, Version 2.0 (the "License");
1625 * you may not use this file except in compliance with the License.
1626 * You may obtain a copy of the License at
1627 *
1628 *   http://www.apache.org/licenses/LICENSE-2.0
1629 *
1630 * Unless required by applicable law or agreed to in writing, software
1631 * distributed under the License is distributed on an "AS IS" BASIS,
1632 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1633 * See the License for the specific language governing permissions and
1634 * limitations under the License.
1635 */function qr(n){return new ff(n,!0)}/**
1636 * @license
1637 * Copyright 2017 Google LLC
1638 *
1639 * Licensed under the Apache License, Version 2.0 (the "License");
1640 * you may not use this file except in compliance with the License.
1641 * You may obtain a copy of the License at
1642 *
1643 *   http://www.apache.org/licenses/LICENSE-2.0
1644 *
1645 * Unless required by applicable law or agreed to in writing, software
1646 * distributed under the License is distributed on an "AS IS" BASIS,
1647 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1648 * See the License for the specific language governing permissions and
1649 * limitations under the License.
1650 */class ru{constructor(t,e,r=1e3,s=1.5,o=6e4){this.Mi=t,this.timerId=e,this.d_=r,this.A_=s,this.R_=o,this.V_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.V_=0}g_(){this.V_=this.R_}p_(t){this.cancel();const e=Math.floor(this.V_+this.y_()),r=Math.max(0,Date.now()-this.f_),s=Math.max(0,e-r);s>0&&k("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.V_} ms, delay with jitter: ${e} ms, last attempt: ${r} ms ago)`),this.m_=this.Mi.enqueueAfterDelay(this.timerId,s,()=>(this.f_=Date.now(),t())),this.V_*=this.A_,this.V_<this.d_&&(this.V_=this.d_),this.V_>this.R_&&(this.V_=this.R_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.V_}}/**
1651 * @license
1652 * Copyright 2017 Google LLC
1653 *
1654 * Licensed under the Apache License, Version 2.0 (the "License");
1655 * you may not use this file except in compliance with the License.
1656 * You may obtain a copy of the License at
1657 *
1658 *   http://www.apache.org/licenses/LICENSE-2.0
1659 *
1660 * Unless required by applicable law or agreed to in writing, software
1661 * distributed under the License is distributed on an "AS IS" BASIS,
1662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1663 * See the License for the specific language governing permissions and
1664 * limitations under the License.
1665 */const Va="PersistentStream";class su{constructor(t,e,r,s,o,a,l,h){this.Mi=t,this.S_=r,this.b_=s,this.connection=o,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=l,this.listener=h,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new ru(t,e)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Mi.enqueueAfterDelay(this.S_,6e4,()=>this.k_()))}q_(t){this.Q_(),this.stream.send(t)}
1665async k_(){if(this.O_())return this.close(0)}Q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(t,e){this.Q_(),this.U_(),this.M_.cancel(),this.D_++,t!==4?this.M_.reset():e&&e.code===S.RESOURCE_EXHAUSTED?(zt(e.toString()),zt("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):e&&e.code===S.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.K_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.r_(e)}K_(){}auth(){this.state=1;const t=this.W_(this.D_),e=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.D_===e&&this.G_(r,s)},r=>{t(()=>{const s=new N(S.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(s)})})}G_(t,e){const r=this.W_(this.D_);this.stream=this.j_(t,e),this.stream.Xo(()=>{r(()=>this.listener.Xo())}),this.stream.t_(()=>{r(()=>(this.state=2,this.v_=this.Mi.enqueueAfterDelay(this.b_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.t_()))}),this.stream.r_(s=>{r(()=>this.z_(s))}),this.stream.onMessage(s=>{r(()=>++this.F_==1?this.J_(s):this.onNext(s))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(t){return k(Va,`close with error: ${t}`),this.stream=null,this.close(4,t)}W_(t){return e=>{this.Mi.enqueueAndForget(()=>this.D_===t?e():(k(Va,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class lm extends su{constructor(t,e,r,s,o,a){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,r,s,a),this.serializer=o}j_(t,e){return this.connection.T_("Listen",t,e)}J_(t){return this.onNext(t)}onNext(t){this.M_.reset();const e=gf(this.serializer,t),r=function(o){if(!("targetChange"in o))return L.min();const a=o.targetChange;return a.targetIds&&a.targetIds.length?L.min():a.readTime?Mt(a.readTime):L.min()}(t);return this.listener.H_(e,r)}Y_(t){const e={};e.database=Qs(this.serializer),e.addTarget=function(o,a){let l;const h=a.target;if(l=$s(h)?{documents:Ef(o,h)}:{query:Tf(o,h).ft},l.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){l.resumeToken=Hc(o,a.resumeToken);const f=Gs(o,a.expectedCount);f!==null&&(l.expectedCount=f)}else if(a.snapshotVersion.compareTo(L.min())>0){l.readTime=wr(o,a.snapshotVersion.toTimestamp());const f=Gs(o,a.expectedCount);f!==null&&(l.expectedCount=f)}return l}(this.serializer,t);const r=If(this.serializer,t);r&&(e.labels=r),this.q_(e)}Z_(t){const e={};e.database=Qs(this.serializer),e.removeTarget=t,this.q_(e)}}class hm extends su{constructor(t,e,r,s,o,a){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,r,s,a),this.serializer=o}get X_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}K_(){this.X_&&this.ea([])}j_(t,e){return this.connection.T_("Write",t,e)}J_(t){return K(!!t.streamToken,31322),this.lastStreamToken=t.streamToken,K(!t.writeResults||t.writeResults.length===0,55816),this.listener.ta()}onNext(t){K(!!t.streamToken,12678),this.lastStreamToken=t.streamToken,this.M_.reset();const e=yf(t.writeResults,t.commitTime),r=Mt(t.commitTime);return this.listener.na(r,e)}ra(){const t={};t.database=Qs(this.serializer),this.q_(t)}ea(t){const e={streamToken:this.lastStreamToken,writes:t.map(r=>_f(this.serializer,r))};this.q_(e)}}/**
1666 * @license
1667 * Copyright 2017 Google LLC
1668 *
1669 * Licensed under the Apache License, Version 2.0 (the "License");
1670 * you may not use this file except in compliance with the License.
1671 * You may obtain a copy of the License at
1672 *
1673 *   http://www.apache.org/licenses/LICENSE-2.0
1674 *
1675 * Unless required by applicable law or agreed to in writing, software
1676 * distributed under the License is distributed on an "AS IS" BASIS,
1677 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1678 * See the License for the specific language governing permissions and
1679 * limitations under the License.
1680 */class dm{}class fm extends dm{constructor(t,e,r,s){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=r,this.serializer
1680=s,this.ia=!1}sa(){if(this.ia)throw new N(S.FAILED_PRECONDITION,"The client has already been terminated.")}Go(t,e,r,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([o,a])=>this.connection.Go(t,Hs(e,r),s,o,a)).catch(o=>{throw o.name==="FirebaseError"?(o.code===S.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new N(S.UNKNOWN,o.toString())})}Ho(t,e,r,s,o){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,l])=>this.connection.Ho(t,Hs(e,r),s,a,l,o)).catch(a=>{throw a.name==="FirebaseError"?(a.code===S.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new N(S.UNKNOWN,a.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}class mm{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(t){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.ca("Offline")))}set(t){this.Pa(),this.oa=0,t==="Online"&&(this.aa=!1),this.ca(t)}ca(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}la(t){const e=`Could not reach Cloud Firestore backend. ${t}
1681This 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.aa?(zt(e),this.aa=!1):k("OnlineStateTracker",e)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}/**
1682 * @license
1683 * Copyright 2017 Google LLC
1684 *
1685 * Licensed under the Apache License, Version 2.0 (the "License");
1686 * you may not use this file except in compliance with the License.
1687 * You may obtain a copy of the License at
1688 *
1689 *   http://www.apache.org/licenses/LICENSE-2.0
1690 *
1691 * Unless required by applicable law or agreed to in writing, software
1692 * distributed under the License is distributed on an "AS IS" BASIS,
1693 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1694 * See the License for the specific language governing permissions and
1695 * limitations under the License.
1696 */const ve="RemoteStore";class pm{constructor(t,e,r,s,o){this.localStore=t,this.datastore=e,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.da=[],this.Aa=o,this.Aa.Oo(a=>{r.enqueueAndForget(async()=>{Ae(this)&&(k(ve,"Restarting streams for network reachability change."),await async function(h){const f=F(h);f.Ea.add(4),await kn(f),f.Ra.set("Unknown"),f.Ea.delete(4),await jr(f)}(this))})}),this.Ra=new mm(r,s)}}async function jr(n){if(Ae(n))for(const t of n.da)await t(!0)}async function kn(n){for(const t of n.da)await t(!1)}function iu(n,t){const e=F(n);e.Ia.has(t.targetId)||(e.Ia.set(t.targetId,t),Ai(e)?Ii(e):Ge(e).O_()&&vi(e,t))}function Ti(n,t){const e=F(n),r=Ge(e);e.Ia.delete(t),r.O_()&&ou(e,t),e.Ia.size===0&&(r.O_()?r.L_():Ae(e)&&e.Ra.set("Unknown"))}function vi(n,t){if(n.Va.Ue(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(L.min())>0){const e=n.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(e)}Ge(n).Y_(t)}function ou(n,t){n.Va.Ue(t),Ge(n).Z_(t)}function Ii(n){n.Va=new uf({getRemoteKeysForTarget:t=>n.remoteSyncer.getRemoteKeysForTarget(t),At:t=>n.Ia.get(t)||null,ht:()=>n.datastore.serializer.databaseId}),Ge(n).start(),n.Ra.ua()}function Ai(n){return Ae(n)&&!Ge(n).x_()&&n.Ia.size>0}function Ae(n){return F(n).Ea.size===0}function au(n){n.Va=void 0}async function gm(n){n.Ra.set("Online")}async function _m(n){n.Ia.forEach((t,e)=>{vi(n,t)})}async function ym(n,t){au(n),Ai(n)?(n.Ra.ha(t),Ii(n)):n.Ra.set("Unknown")}async function Em(n,t,e){if(n.Ra.set("Online"),t instanceof Gc&&t.state===2&&t.cause)try{await async function(s,o){const a=o.cause;for(const l of o.targetIds)s.Ia.has(l)&&(await s.remoteSyncer.rejectListen(l,a),s.Ia.delete(l),s.Va.removeTarget(l))}(n,t)}catch(r){k(ve,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await Sr(n,r)}else if(t instanceof mr?n.Va.Ze(t):t instanceof zc?n.Va.st(t):n.Va.tt(t),!e.isEqual(L.min()))try{const r=await nu(n.localStore);e.compareTo(r)>=0&&await function(o,a){const l=o.Va.Tt(a);
1696return l.targetChanges.forEach((h,f)=>{if(h.resumeToken.approximateByteSize()>0){const m=o.Ia.get(f);m&&o.Ia.set(f,m.withResumeToken(h.resumeToken,a))}}),l.targetMismatches.forEach((h,f)=>{const m=o.Ia.get(h);if(!m)return;o.Ia.set(h,m.withResumeToken(ut.EMPTY_BYTE_STRING,m.snapshotVersion)),ou(o,h);const E=new Jt(m.target,h,f,m.sequenceNumber);vi(o,E)}),o.remoteSyncer.applyRemoteEvent(l)}(n,e)}catch(r){k(ve,"Failed to raise snapshot:",r),await Sr(n,r)}}async function Sr(n,t,e){if(!$e(t))throw t;n.Ea.add(1),await kn(n),n.Ra.set("Offline"),e||(e=()=>nu(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{k(ve,"Retrying IndexedDB access"),await e(),n.Ea.delete(1),await jr(n)})}function cu(n,t){return t().catch(e=>Sr(n,e,t))}async function $r(n){const t=F(n),e=ce(t);let r=t.Ta.length>0?t.Ta[t.Ta.length-1].batchId:oi;for(;Tm(t);)try{const s=await em(t.localStore,r);if(s===null){t.Ta.length===0&&e.L_();break}r=s.batchId,vm(t,s)}catch(s){await Sr(t,s)}uu(t)&&lu(t)}function Tm(n){return Ae(n)&&n.Ta.length<10}function vm(n,t){n.Ta.push(t);const e=ce(n);e.O_()&&e.X_&&e.ea(t.mutations)}function uu(n){return Ae(n)&&!ce(n).x_()&&n.Ta.length>0}function lu(n){ce(n).start()}async function Im(n){ce(n).ra()}async function Am(n){const t=ce(n);for(const e of n.Ta)t.ea(e.mutations)}async function wm(n,t,e){const r=n.Ta.shift(),s=fi.from(r,t,e);await cu(n,()=>n.remoteSyncer.applySuccessfulWrite(s)),await $r(n)}async function Rm(n,t){t&&ce(n).X_&&await async function(r,s){if(function(a){return of(a)&&a!==S.ABORTED}(s.code)){const o=r.Ta.shift();ce(r).B_(),await cu(r,()=>r.remoteSyncer.rejectFailedWrite(o.batchId,s)),await $r(r)}}(n,t),uu(n)&&lu(n)}async function ba(n,t){const e=F(n);e.asyncQueue.verifyOperationInProgress(),k(ve,"RemoteStore received new credentials");const r=Ae(e);e.Ea.add(3),await kn(e),r&&e.Ra.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ea.delete(3),await jr(e)}async function Sm(n,t){const e=F(n);t?(e.Ea.delete(2),await jr(e)):t||(e.Ea.add(2),await kn(e),e.Ra.set("Unknown"))}function Ge(n){return n.ma||(n.ma=function(e,r,s){const o=F(e);return o.sa(),new lm(r,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,s)}(n.datastore,n.asyncQueue,{Xo:gm.bind(null,n),t_:_m.bind(null,n),r_:ym.bind(null,n),H_:Em.bind(null,n)}),n.da.push(async t=>{t?(n.ma.B_(),Ai(n)?Ii(n):n.Ra.set("Unknown")):(await n.ma.stop(),au(n))})),n.ma}function ce(n){return n.fa||(n.fa=function(e,r,s){const o=F(e);return o.sa(),new hm(r,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,s)}(n.datastore,n.asyncQueue,{Xo:()=>Promise.resolve(),t_:Im.bind(null,n),r_:Rm.bind(null,n),ta:Am.bind(null,n),na:wm.bind(null,n)}),n.da.push(async t=>{t?(n.fa.B_(),await $r(n)):(await n.fa.stop(),n.Ta.length>0&&(k(ve,`Stopping write stream with ${n.Ta.length} pending writes`),n.Ta=[]))})),n.fa}/**
1697 * @license
1698 * Copyright 2017 Google LLC
1699 *
1700 * Licensed under the Apache License, Version 2.0 (the "License");
1701 * you may not use this file except in compliance with the License.
1702 * You may obtain a copy of the License at
1703 *
1704 *   http://www.apache.org/licenses/LICENSE-2.0
1705 *
1706 * Unless required by applicable law or agreed to in writing, software
1707 * distributed under the License is distributed on an "AS IS" BASIS,
1708 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1709 * See the License for the specific language governing permissions and
1710 * limitations under the License.
1711 */class wi{constructor(t,e,r,s,o){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=r,this.op=s,this.removalCallback=o,this.deferred=new ne,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(t,e,r,s,o){const a=Date.now()+r,l=new wi(t,e,a,s,o);return l.start(r),l}start(t){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new N(S.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
1711)}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(t=>this.deferred.resolve(t))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Ri(n,t){if(zt("AsyncQueue",`${t}: ${n}`),$e(n))return new N(S.UNAVAILABLE,`${t}: ${n}`);throw n}/**
1712 * @license
1713 * Copyright 2017 Google LLC
1714 *
1715 * Licensed under the Apache License, Version 2.0 (the "License");
1716 * you may not use this file except in compliance with the License.
1717 * You may obtain a copy of the License at
1718 *
1719 *   http://www.apache.org/licenses/LICENSE-2.0
1720 *
1721 * Unless required by applicable law or agreed to in writing, software
1722 * distributed under the License is distributed on an "AS IS" BASIS,
1723 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1724 * See the License for the specific language governing permissions and
1725 * limitations under the License.
1726 */class ke{static emptySet(t){return new ke(t.comparator)}constructor(t){this.comparator=t?(e,r)=>t(e,r)||M.comparator(e.key,r.key):(e,r)=>M.comparator(e.key,r.key),this.keyedMap=hn(),this.sortedSet=new Z(this.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal((e,r)=>(t(e),!1))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof ke)||this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();for(;e.hasNext();){const s=e.getNext().key,o=r.getNext().key;if(!s.isEqual(o))return!1}return!0}toString(){const t=[];return this.forEach(e=>{t.push(e.toString())}),t.length===0?"DocumentSet ()":`DocumentSet (
1727  `+t.join(`  
1728`)+`
1729)`}copy(t,e){const r=new ke;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=e,r}}/**
1730 * @license
1731 * Copyright 2017 Google LLC
1732 *
1733 * Licensed under the Apache License, Version 2.0 (the "License");
1734 * you may not use this file except in compliance with the License.
1735 * You may obtain a copy of the License at
1736 *
1737 *   http://www.apache.org/licenses/LICENSE-2.0
1738 *
1739 * Unless required by applicable law or agreed to in writing, software
1740 * distributed under the License is distributed on an "AS IS" BASIS,
1741 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1742 * See the License for the specific language governing permissions and
1743 * limitations under the License.
1744 */class Da{constructor(){this.ga=new Z(M.comparator)}track(t){const e=t.doc.key,r=this.ga.get(e);r?t.type!==0&&r.type===3?this.ga=this.ga.insert(e,t):t.type===3&&r.type!==1?this.ga=this.ga.insert(e,{type:r.type,doc:t.doc}):t.type===2&&r.type===2?this.ga=this.ga.insert(e,{type:2,doc:t.doc}):t.type===2&&r.type===0?this.ga=this.ga.insert(e,{type:0,doc:t.doc}):t.type===1&&r.type===0?this.ga=this.ga.remove(e):t.type===1&&r.type===2?this.ga=this.ga.insert(e,{type:1,doc:r.doc}):t.type===0&&r.type===1?this.ga=this.ga.insert(e,{type:2,doc:t.doc}):x(63341,{Rt:t,pa:r}):this.ga=this.ga.insert(e,t)}ya(){const t=[];return this.ga.inorderTraversal((e,r)=>{t.push(r)}),t}}
1744class Ue{constructor(t,e,r,s,o,a,l,h,f){this.query=t,this.docs=e,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=o,this.fromCache=a,this.syncStateChanged=l,this.excludesMetadataChanges=h,this.hasCachedResults=f}static fromInitialDocuments(t,e,r,s,o){const a=[];return e.forEach(l=>{a.push({type:0,doc:l})}),new Ue(t,e,ke.emptySet(e),a,r,s,!0,!1,o)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&xr(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,r=t.docChanges;if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s].type!==r[s].type||!e[s].doc.isEqual(r[s].doc))return!1;return!0}}/**
1745 * @license
1746 * Copyright 2017 Google LLC
1747 *
1748 * Licensed under the Apache License, Version 2.0 (the "License");
1749 * you may not use this file except in compliance with the License.
1750 * You may obtain a copy of the License at
1751 *
1752 *   http://www.apache.org/licenses/LICENSE-2.0
1753 *
1754 * Unless required by applicable law or agreed to in writing, software
1755 * distributed under the License is distributed on an "AS IS" BASIS,
1756 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1757 * See the License for the specific language governing permissions and
1758 * limitations under the License.
1759 */class Cm{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some(t=>t.Da())}}class Pm{constructor(){this.queries=Na(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(e,r){const s=F(e),o=s.queries;s.queries=Na(),o.forEach((a,l)=>{for(const h of l.Sa)h.onError(r)})})(this,new N(S.ABORTED,"Firestore shutting down"))}}function Na(){return new Ie(n=>Dc(n),xr)}async function hu(n,t){const e=F(n);let r=3;const s=t.query;let o=e.queries.get(s);o?!o.ba()&&t.Da()&&(r=2):(o=new Cm,r=t.Da()?0:1);try{switch(r){case 0:o.wa=await e.onListen(s,!0);break;case 1:o.wa=await e.onListen(s,!1);break;case 2:await e.onFirstRemoteStoreListen(s)}}catch(a){const l=Ri(a,`Initialization of query '${Ve(t.query)}' failed`);return void t.onError(l)}e.queries.set(s,o),o.Sa.push(t),t.va(e.onlineState),o.wa&&t.Fa(o.wa)&&Si(e)}async function du(n,t){const e=F(n),r=t.query;let s=3;const o=e.queries.get(r);if(o){const a=o.Sa.indexOf(t);a>=0&&(o.Sa.splice(a,1),o.Sa.length===0?s=t.Da()?0:1:!o.ba()&&t.Da()&&(s=2))}switch(s){case 0:return e.queries.delete(r),e.onUnlisten(r,!0);case 1:return e.queries.delete(r),e.onUnlisten(r,!1);case 2:return e.onLastRemoteStoreUnlisten(r);default:return}}function Vm(n,t){const e=F(n);let r=!1;for(const s of t){const o=s.query,a=e.queries.get(o);if(a){for(const l of a.Sa)l.Fa(s)&&(r=!0);a.wa=s}}r&&Si(e)}function bm(n,t,e){const r=F(n),s=r.queries.get(t);if(s)for(const o of s.Sa)o.onError(e);r.queries.delete(t)}function Si(n){n.Ca.forEach(t=>{t.next()})}var Ys,ka;(ka=Ys||(Ys={})).Ma="default",ka.Cache="cache";class fu{constructor(t,e,r){this.query=t,this.xa=e,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(t){if(!this.options.includeMetadataChanges){const r=[];for(const s of t.docChanges)s.type!==3&&r.push(s);t=new Ue(t.query,t.docs,t.oldDocs,r,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.Oa?this.Ba(t)&&(this.xa.next(t),e=!0):this.La(t,this.onlineState)&&(this.ka(t),e=!0),this.Na=t,e}onError(t){this.xa.error(t)}va(t){this.onlineState=t;let e=!1;return this.Na&&!this.Oa&&this.La(this.Na,t)&&(this.ka(this.Na),e=!0),e}La(t,e){if(!t.fromCache||!this.Da())return!0;const r=e!=="Offline";return(!this.options.qa||!r)&&(!t.docs.isEmpty()||t.hasCachedResults||e==="Offline")}Ba(t){if(t.docChanges.length>0)return!0;const e=this.Na&&this.Na.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&this.options.includeMetadataChanges===!0}ka(t){t=Ue.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.Oa=!0,this.xa.next(t)}Da(){return this.options.source!==Ys.Cache}}/**
1760 * @license
1761 * Copyright 2017 Google LLC
1762 *
1763 * Licensed under the Apache License, Version 2.0 (the "License");
1764 * you may not use this file except in compliance with the License.
1765 * You may obtain a copy of the License at
1766 *
1767 *   http://www.apache.org/licenses/LICENSE-2.0
1768 *
1769 * Unless required by applicable law or agreed to in writing, software
1770 * distributed under the License is distributed on an "AS IS" BASIS,
1771 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1772 * See the License for the specific language governing permissions and
1773 * limitations under the License.
1774 */class mu{constructor(t){this.key=t}}class pu{constructor(t){this.key=t}}class Dm{constructor(t,e){this.query=t,this.Ya=e,this.Za=null,this.hasCachedResults=!1,this.current=!1,this.Xa=q(),this.mutatedKeys=q(),this.eu=Nc(t),this.tu=new ke(this.eu)}get nu(){return this.Ya}ru(t,e){const r=e?e.iu:new Da,s=e?e.tu:this.tu;let o=e?e.mutatedKeys:this.mutatedKeys,a=s,l=!1;const h=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,f=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(t.inorderTraversal((m,E)=>{const T=s.get(m),P=Lr(this.query,E)?E:null,b=!!T&&this.mutatedKeys.has(T.key),O=!!P&&(P.hasLocalMutations||this.mutatedKeys.has(P.key)&&P.hasCommittedMutations);let D=!1;T&&P?T.data.isEqual(P.data)?b!==O&&(r.track({type:3,doc:P}),D=!0):this.su(T,P)||(r.track({type:2,doc:P}),D=!0,(h&&this.eu(P,h)>0||f&&this.eu(P,f)<0)&&(l=!0)):!T&&P?(r.track({type:0,doc:P}),D=!0):T&&!P&&(r.track({type:1,doc:T}),D=!0,(h||f)&&(l=!0)),D&&(P?(a=a.add(P),o=O?o.add(m):o.delete(m)):(a=a.delete(m),o=o.delete(m)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const m=this.query.limitType==="F"?a.last():a.first();a=a.delete(m.key),o=o.delete(m.key),r.track({type:1,doc:m})}return{tu:a,iu:r,Cs:l,mutatedKeys:o}}su(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,r,s){const o=this.tu;this.tu=t.tu,this.mutatedKeys=t.mutatedKeys;const a=t.iu.ya();a.sort((m,E)=>function(P,b){const O=D=>{switch(D){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return x(20277,{Rt:D})}};return O(P)-O(b)}(m.type,E.type)||this.eu(m.doc,E.doc)),this.ou(r),s=s??!1;const l=e&&!s?this._u():[],h=this.Xa.size===0&&this.current&&!s?1:0,f=h!==this.Za;return this.Za=h,a.length!==0||f?{snapshot:new Ue(this.query,t.tu,o,a,t.mutatedKeys,h===0,f,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:l}:{au:l}}va(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Da,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{au:[]}}uu(t){return!this.Ya.has(t)&&!!this.tu.has(t)&&!this.tu.get(t).hasLocalMutations}ou(t){t&&(t.addedDocuments.forEach(e=>this.Ya=this.Ya.add(e)),t.modifiedDocuments.forEach(e=>{}),t.removedDocuments.forEach(e=>this.Ya=this.Ya.delete(e)),this.current=t.current)}_u(){if(!this.current)return[];const t=this.Xa;this.Xa=q(),this.tu.forEach(r=>{this.uu(r.key)&&(this.Xa=this.Xa.add(r.key))});const e=[];return t.forEach(r=>{this.Xa.has(r)||e.push(new pu(r))}),this.Xa.forEach(r=>{t.has(r)||e.push(new mu(r))}),e}cu(t){this.Ya=t.Qs,this.Xa=q();const e=this.ru(t.documents);return this.applyChanges(e,!0)}lu(){return Ue.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Za===0,this.hasCachedResults)}}const Ci="SyncEngine";class Nm{constructor(t,e,r){this.query=t,this.targetId=e,this.view=r}}class km{constructor(t){this.key=t,this.hu=!1}}class Om{constructor(t,e,r,s,o,a){this.localStore=t,this.remoteStore=e,this.eventManager=r,this.sharedClientState=s,this.currentUser=o,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new Ie(l=>Dc(l),xr),this.Iu=new Map,this.Eu=new Set,this.du=new Z(M.comparator),this.Au=new Map,this.Ru=new gi,this.Vu={},this.mu=new Map,this.fu=Fe.cr(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function Mm(n,t,e=!0){const r=vu(n);let s;const o=r.Tu.get(t);return o?(r.sharedClientState.addLocalQueryTarget(o.targetId),s=o.view.lu()):s=await gu(r,t,e,!0),s}async function xm(n,t){const e=vu(n);await gu(e,t,!0,!1)}async function gu(n,t,e,r){const s=await nm(n.localStore,Ot(t)),o=s.targetId,a=n.sharedClientState.addLocalQueryTarget(o,e);let l;return r&&(l=await Lm(n,t,o,a==="current",s.resumeToken)),n.isPrimaryClient&&e&&iu(n.remoteStore,s),l}async function Lm(n,t,e,r,s){n.pu=(E,T,P)=>async function(O,D,G,U){let z=D.view.ru(G);z.Cs&&(z=await Ra(O.localStore,D.query,!1).then(({documents:I})=>D.view.ru(I,z)));const nt=U&&U.targetChanges.get(D.targetId),Ft=U&&U.targetMismatches.get(D.targetId)!=null,lt=D.view.applyChanges(z,O.isPrimaryClient,nt,Ft);return Ma(O,D.targetId,lt.au),lt.snapshot}(n,E,T,P);const o=await Ra(n.localStore,t,!0),a=new Dm(t,o.Qs),l=a.ru(o.documents),h=Nn.createSynthesizedTargetChangeForCurrentChange(e,r&&n.onlineState!=="Offline",s),f=a.applyChanges(l,n.isPrimaryClient,h);Ma(n,e,f.au);const m=new Nm(t,e,a);return n.Tu.set(t,m),n.Iu.has(e)?n.Iu.get(e).push(t):n.Iu.set(e,[t]),f.snapshot}async function Fm(n,t,e){const r=F(n),s=r.Tu.get(t),o=r.Iu.get(s.targetId);if(o.length>1)return r.Iu.set(s.targetId,o.filter(a=>!xr(a,t))),void r.Tu.delete(t);
1774r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Ws(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),e&&Ti(r.remoteStore,s.targetId),Js(r,s.targetId)}).catch(je)):(Js(r,s.targetId),await Ws(r.localStore,s.targetId,!0))}async function Um(n,t){const e=F(n),r=e.Tu.get(t),s=e.Iu.get(r.targetId);e.isPrimaryClient&&s.length===1&&(e.sharedClientState.removeLocalQueryTarget(r.targetId),Ti(e.remoteStore,r.targetId))}async function Bm(n,t,e){const r=Km(n);try{const s=await function(a,l){const h=F(a),f=X.now(),m=l.reduce((P,b)=>P.add(b.key),q());let E,T;return h.persistence.runTransaction("Locally write mutations","readwrite",P=>{let b=Gt(),O=q();return h.Ns.getEntries(P,m).next(D=>{b=D,b.forEach((G,U)=>{U.isValidDocument()||(O=O.add(G))})}).next(()=>h.localDocuments.getOverlayedDocuments(P,b)).next(D=>{E=D;const G=[];for(const U of l){const z=tf(U,E.get(U.key).overlayedDocument);z!=null&&G.push(new he(U.key,z,Ac(z.value.mapValue),Pt.exists(!0)))}return h.mutationQueue.addMutationBatch(P,f,G,l)}).next(D=>{T=D;const G=D.applyToLocalDocumentSet(E,O);return h.documentOverlayCache.saveOverlays(P,D.batchId,G)})}).then(()=>({batchId:T.batchId,changes:Oc(E)}))}(r.localStore,t);r.sharedClientState.addPendingMutation(s.batchId),function(a,l,h){let f=a.Vu[a.currentUser.toKey()];f||(f=new Z(B)),f=f.insert(l,h),a.Vu[a.currentUser.toKey()]=f}(r,s.batchId,e),await On(r,s.changes),await $r(r.remoteStore)}catch(s){const o=Ri(s,"Failed to persist write");e.reject(o)}}async function _u(n,t){const e=F(n);try{const r=await Zf(e.localStore,t);
1774t.targetChanges.forEach((s,o)=>{const a=e.Au.get(o);a&&(K(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.hu=!0:s.modifiedDocuments.size>0?K(a.hu,14607):s.removedDocuments.size>0&&(K(a.hu,42227),a.hu=!1))}),await On(e,r,t)}catch(r){await je(r)}}function Oa(n,t,e){const r=F(n);if(r.isPrimaryClient&&e===0||!r.isPrimaryClient&&e===1){const s=[];r.Tu.forEach((o,a)=>{const l=a.view.va(t);l.snapshot&&s.push(l.snapshot)}),function(a,l){const h=F(a);h.onlineState=l;let f=!1;h.queries.forEach((m,E)=>{for(const T of E.Sa)T.va(l)&&(f=!0)}),f&&Si(h)}(r.eventManager,t),s.length&&r.Pu.H_(s),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function qm(n,t,e){const r=F(n);r.sharedClientState.updateQueryState(t,"rejected",e);const s=r.Au.get(t),o=s&&s.key;if(o){let a=new Z(M.comparator);a=a.insert(o,Et.newNoDocument(o,L.min()));const l=q().add(o),h=new Br(L.min(),new Map,new Z(B),a,l);await _u(r,h),r.du=r.du.remove(o),r.Au.delete(t),Pi(r)}else await Ws(r.localStore,t,!1).then(()=>Js(r,t,e)).catch(je)}async function jm(n,t){const e=F(n),r=t.batch.batchId;try{const s=await Jf(e.localStore,t);Eu(e,r,null),yu(e,r),e.sharedClientState.updateMutationState(r,"acknowledged"),await On(e,s)}catch(s){await je(s)}}async function $m(n,t,e){const r=F(n);try{const s=await function(a,l){const h=F(a);return h.persistence.runTransaction("Reject batch","readwrite-primary",f=>{let m;return h.mutationQueue.lookupMutationBatch(f,l).next(E=>(K(E!==null,37113),m=E.keys(),h.mutationQueue.removeMutationBatch(f,E))).next(()=>h.mutationQueue.performConsistencyCheck(f)).next(()=>h.documentOverlayCache.removeOverlaysForBatchId(f,m,l)).next(()=>h.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(f,m)).next(()=>h.localDocuments.getDocuments(f,m))})}(r.localStore,t);Eu(r,t,e),yu(r,t),r.sharedClientState.updateMutationState(t,"rejected",e),await On(r,s)}catch(s){await je(s)}}function yu(n,t){(n.mu.get(t)||[]).forEach(e=>{e.resolve()}),n.mu.delete(t)}function Eu(n,t,e){const r=F(n);let s=r.Vu[r.currentUser.toKey()];if(s){const o=s.get(t);o&&(e?o.reject(e):o.resolve(),s=s.remove(t)),r.Vu[r.currentUser.toKey()]=s}}function Js(n,t,e=null){n.sharedClientState.removeLocalQueryTarget(t);for(const r of n.Iu.get(t))n.Tu.delete(r),e&&n.Pu.yu(r,e);n.Iu.delete(t),n.isPrimaryClient&&n.Ru.jr(t).forEach(r=>{n.Ru.containsKey(r)||Tu(n,r)})}function Tu(n,t){n.Eu.delete(t.path.canonicalString());const e=n.du.get(t);e!==null&&(Ti(n.remoteStore,e),n.du=n.du.remove(t),n.Au.delete(e),Pi(n))}function Ma(n,t,e){for(const r of e)r instanceof mu?(n.Ru.addReference(r.key,t),zm(n,r)):r instanceof pu?(k(Ci,"Document no longer in limbo: "+r.key),n.Ru.removeReference(r.key,t),n.Ru.containsKey(r.key)||Tu(n,r.key)):x(19791,{wu:r})}function zm(n,t){const e=t.key,r=e.path.canonicalString();n.du.get(e)||n.Eu.has(r)||(k(Ci,"New document in limbo: "+e),n.Eu.add(r),Pi(n))}function Pi(n){for(;n.Eu.size>0&&n.du.size<n.maxConcurrentLimboResolutions;){const t=n.Eu.values().next().value;n.Eu.delete(t);const e=new M(W.fromString(t)),r=n.fu.next();n.Au.set(r,new km(e)),n.du=n.du.insert(e,r),iu(n.remoteStore,new Jt(Ot(Mr(e.path)),r,"TargetPurposeLimboResolution",Nr.ce))}}async function On(n,t,e){const r=F(n),s=[],o=[],a=[];r.Tu.isEmpty()||(r.Tu.forEach((l,h)=>{a.push(r.pu(h,t,e).then(f=>{var m;if((f||e)&&r.isPrimaryClient){const E=f?!f.fromCache:(m=e==null?void 0:e.targetChanges.get(h.targetId))==null?void 0:m.current;
1774r.sharedClientState.updateQueryState(h.targetId,E?"current":"not-current")}if(f){s.push(f);const E=yi.As(h.targetId,f);o.push(E)}}))}),await Promise.all(a),r.Pu.H_(s),await async function(h,f){const m=F(h);try{await m.persistence.runTransaction("notifyLocalViewChanges","readwrite",E=>C.forEach(f,T=>C.forEach(T.Es,P=>m.persistence.referenceDelegate.addReference(E,T.targetId,P)).next(()=>C.forEach(T.ds,P=>m.persistence.referenceDelegate.removeReference(E,T.targetId,P)))))}catch(E){if(!$e(E))throw E;k(Ei,"Failed to update sequence numbers: "+E)}for(const E of f){const T=E.targetId;if(!E.fromCache){const P=m.Ms.get(T),b=P.snapshotVersion,O=P.withLastLimboFreeSnapshotVersion(b);m.Ms=m.Ms.insert(T,O)}}}(r.localStore,o))}async function Gm(n,t){const e=F(n);if(!e.currentUser.isEqual(t)){k(Ci,"User change. New user:",t.toKey());const r=await eu(e.localStore,t);e.currentUser=t,function(o,a){o.mu.forEach(l=>{l.forEach(h=>{h.reject(new N(S.CANCELLED,a))})}),o.mu.clear()}(e,"'waitForPendingWrites' promise is rejected due to a user change."),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await On(e,r.Ls)}}function Hm(n,t){const e=F(n),r=e.Au.get(t);if(r&&r.hu)return q().add(r.key);{let s=q();const o=e.Iu.get(t);if(!o)return s;for(const a of o){const l=e.Tu.get(a);s=s.unionWith(l.view.nu)}return s}}function vu(n){const t=F(n);return t.remoteStore.remoteSyncer.applyRemoteEvent=_u.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Hm.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=qm.bind(null,t),t.Pu.H_=Vm.bind(null,t.eventManager),t.Pu.yu=bm.bind(null,t.eventManager),t}function Km(n){const t=F(n);return t.remoteStore.remoteSyncer.applySuccessfulWrite=jm.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=$m.bind(null,t),t}class Cr{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=qr(t.databaseInfo.databaseId),this.sharedClientState=this.Du(t),this.persistence=this.Cu(t),await this.persistence.start(),this.localStore=this.vu(t),this.gcScheduler=this.Fu(t,this.localStore),this.indexBackfillerScheduler=this.Mu(t,this.localStore)}Fu(t,e){return null}Mu(t,e){return null}vu(t){return Yf(this.persistence,new Qf,t.initialUser,this.serializer)}Cu(t){return new tu(_i.mi,this.serializer)}Du(t){return new sm}async terminate(){var t,e;(t=this.gcScheduler)==null||t.stop(),(e=this.indexBackfillerScheduler)==null||e.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Cr.provider={build:()=>new Cr};class Qm extends Cr{constructor(t){super(),this.cacheSizeBytes=t}Fu(t,e){K(this.persistence.referenceDelegate instanceof Rr,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new kf(r,t.asyncQueue,e)}Cu(t){const e=this.cacheSizeBytes!==void 0?It.withCacheSize(this.cacheSizeBytes):It.DEFAULT;return new tu(r=>Rr.mi(r,e),this.serializer)}}class Zs{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>Oa(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=Gm.bind(null,this.syncEngine),await Sm(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return function(){return new Pm}()}createDatastore(t){const e=qr(t.databaseInfo.databaseId),r=function(o){return new um(o)}(t.databaseInfo);return function(o,a,l,h){return new fm(o,a,l,h)}(t.authCredentials,t.appCheckCredentials,r,e)}createRemoteStore(t){return function(r,s,o,a,l){return new pm(r,s,o,a,l)}(this.localStore,this.datastore,t.asyncQueue,e=>Oa(this.syncEngine,e,0),function(){return Pa.v()?new Pa:new im}())}createSyncEngine(t,e){return function(s,o,a,l,h,f,m){const E=new Om(s,o,a,l,h,f);return m&&(E.gu=!0),E}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}async terminate(){var t,e;await async function(s){const o=F(s);k(ve,"RemoteStore shutting down."),o.Ea.add(5),await kn(o),o.Aa.shutdown(),o.Ra.set("Unknown")}(this.remoteStore),(t=this.datastore)==null||t.terminate(),(e=this.eventManager)==null||e.terminate()}}Zs.provider={build:()=>new Zs};/**
1775 * @license
1776 * Copyright 2020 Google LLC
1777 *
1778 * Licensed under the Apache License, Version 2.0 (the "License");
1779 * you may not use this file except in compliance with the License.
1780 * You may obtain a copy of the License at
1781 *
1782 *   http://www.apache.org/licenses/LICENSE-2.0
1783 *
1784 * Unless required by applicable law or agreed to in writing, software
1785 * distributed under the License is distributed on an "AS IS" BASIS,
1786 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1787 * See the License for the specific language governing permissions and
1788 * limitations under the License.
1789 *//**
1790 * @license
1791 * Copyright 2017 Google LLC
1792 *
1793 * Licensed under the Apache License, Version 2.0 (the "License");
1794 * you may not use this file except in compliance with the License.
1795 * You may obtain a copy of the License at
1796 *
1797 *   http://www.apache.org/licenses/LICENSE-2.0
1798 *
1799 * Unless required by applicable law or agreed to in writing, software
1800 * distributed under the License is distributed on an "AS IS" BASIS,
1801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1802 * See the License for the specific language governing permissions and
1803 * limitations under the License.
1804 */class Iu{constructor(t){this.observer=t,this.muted=!1}next(t){this.muted||this.observer.next&&this.Ou(this.observer.next,t)}error(t){this.muted||(this.observer.error?this.Ou(this.observer.error,t):zt("Uncaught Error in snapshot listener:",t.toString()))}Nu(){this.muted=!0}Ou(t,e){setTimeout(()=>{this.muted||t(e)},0)}}/**
1805 * @license
1806 * Copyright 2017 Google LLC
1807 *
1808 * Licensed under the Apache License, Version 2.0 (the "License");
1809 * you may not use this file except in compliance with the License.
1810 * You may obtain a copy of the License at
1811 *
1812 *   http://www.apache.org/licenses/LICENSE-2.0
1813 *
1814 * Unless required by applicable law or agreed to in writing, software
1815 * distributed under the License is distributed on an "AS IS" BASIS,
1816 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1817 * See the License for the specific language governing permissions and
1818 * limitations under the License.
1819 */const ue="FirestoreClient";class Wm{constructor(t,e,r,s,o){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=r,this.databaseInfo=s,this.user=yt.UNAUTHENTICATED,this.clientId=br.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=o,this.authCredentials.start(r,async a=>{k(ue,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(r,a=>(k(ue,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new ne;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const r=Ri(e,"Failed to shutdown persistence");t.reject(r)}}),t.promise}}async function Ns(n,t){n.asyncQueue.verifyOperationInProgress(),k(ue,"Initializing OfflineComponentProvider");const e=n.configuration;await t.initialize(e);let r=e.initialUser;n.setCredentialChangeListener(async s=>{r.isEqual(s)||(await eu(t.localStore,s),r=s)}),t.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=t}async function xa(n,t){n.asyncQueue.verifyOperationInProgress();const e=await Xm(n);k(ue,"Initializing OnlineComponentProvider"),await t.initialize(e,n.configuration),n.setCredentialChangeListener(r=>ba(t.remoteStore,r)),n.setAppCheckTokenChangeListener((r,s)=>ba(t.remoteStore,s)),n._onlineComponents=t}async function Xm(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){k(ue,"Using user provided OfflineComponentProvider");try{await Ns(n,n._uninitializedComponentsProvider._offline)}catch(t){const e=t;if(!function(s){return s.name==="FirebaseError"?s.code===S.FAILED_PRECONDITION||s.code===S.UNIMPLEMENT
1819ED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(e))throw e;Te("Error using user provided cache. Falling back to memory cache: "+e),await Ns(n,new Cr)}}else k(ue,"Using default OfflineComponentProvider"),await Ns(n,new Qm(void 0));return n._offlineComponents}async function Au(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(k(ue,"Using user provided OnlineComponentProvider"),await xa(n,n._uninitializedComponentsProvider._online)):(k(ue,"Using default OnlineComponentProvider"),await xa(n,new Zs))),n._onlineComponents}function Ym(n){return Au(n).then(t=>t.syncEngine)}async function ti(n){const t=await Au(n),e=t.eventManager;return e.onListen=Mm.bind(null,t.syncEngine),e.onUnlisten=Fm.bind(null,t.syncEngine),e.onFirstRemoteStoreListen=xm.bind(null,t.syncEngine),e.onLastRemoteStoreUnlisten=Um.bind(null,t.syncEngine),e}function Jm(n,t,e={}){const r=new ne;return n.asyncQueue.enqueueAndForget(async()=>function(o,a,l,h,f){const m=new Iu({next:T=>{m.Nu(),a.enqueueAndForget(()=>du(o,E));const P=T.docs.has(l);!P&&T.fromCache?f.reject(new N(S.UNAVAILABLE,"Failed to get document because the client is offline.")):P&&T.fromCache&&h&&h.source==="server"?f.reject(new N(S.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.)')):f.resolve(T)},error:T=>f.reject(T)}),E=new fu(Mr(l.path),m,{includeMetadataChanges:!0,qa:!0});return hu(o,E)}(await ti(n),n.asyncQueue,t,e,r)),r.promise}/**
1820 * @license
1821 * Copyright 2023 Google LLC
1822 *
1823 * Licensed under the Apache License, Version 2.0 (the "License");
1824 * you may not use this file except in compliance with the License.
1825 * You may obtain a copy of the License at
1826 *
1827 *   http://www.apache.org/licenses/LICENSE-2.0
1828 *
1829 * Unless required by applicable law or agreed to in writing, software
1830 * distributed under the License is distributed on an "AS IS" BASIS,
1831 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1832 * See the License for the specific language governing permissions and
1833 * limitations under the License.
1834 */function wu(n){const t={};return n.timeoutSeconds!==void 0&&(t.timeoutSeconds=n.timeoutSeconds),t}/**
1835 * @license
1836 * Copyright 2020 Google LLC
1837 *
1838 * Licensed under the Apache License, Version 2.0 (the "License");
1839 * you may not use this file except in compliance with the License.
1840 * You may obtain a copy of the License at
1841 *
1842 *   http://www.apache.org/licenses/LICENSE-2.0
1843 *
1844 * Unless required by applicable law or agreed to in writing, software
1845 * distributed under the License is distributed on an "AS IS" BASIS,
1846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1847 * See the License for the specific language governing permissions and
1848 * limitations under the License.
1849 */const La=new Map;/**
1850 * @license
1851 * Copyright 2020 Google LLC
1852 *
1853 * Licensed under the Apache License, Version 2.0 (the "License");
1854 * you may not use this file except in compliance with the License.
1855 * You may obtain a copy of the License at
1856 *
1857 *   http://www.apache.org/licenses/LICENSE-2.0
1858 *
1859 * Unless required by applicable law or agreed to in writing, software
1860 * distributed under the License is distributed on an "AS IS" BASIS,
1861 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1862 * See the License for the specific language governing permissions and
1863 * limitations under the License.
1864 */const Ru="firestore.googleapis.com",Fa=!0;class Ua{constructor(t){if(t.host===void 0){if(t.ssl!==void 0)throw new N(S.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Ru,this.ssl=Fa}else this.host=t.host,this.ssl=t.ssl??Fa;if(this.isUsingEmulator=t.emulatorOptions!==void 0,this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,t.cacheSizeBytes===void 0)this.cacheSizeBytes=Zc;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<Df)throw new N(S.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}hc("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:t.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=wu(t.experimentalLongPollingOptions??{}),function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new N(S.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new N(S.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new N(S.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}
1864class zr{constructor(t,e,r,s){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Ua({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new N(S.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(t){if(this._settingsFrozen)throw new N(S.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 Ua(t),this._emulatorOptions=t.emulatorOptions||{},t.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new uc;switch(r.type){case"firstParty":return new ud(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new N(S.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const r=La.get(e);r&&(k("ComponentProvider","Removing Datastore"),La.delete(e),r.terminate())}(this),Promise.resolve()}}function Su(n,t,e,r={}){var f;n=Ct(n,zr);const s=ni(t),o=n._getSettings(),a={...o,emulatorOptions:n._getEmulatorOptions()},l=`${t}:${e}`;s&&(kl(`https://${l}`),Ll("Firestore",!0)),o.host!==Ru&&o.host!==l&&Te("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const h={...o,host:l,ssl:s,emulatorOptions:r};if(!gr(h,a)&&(n._setSettings(h),r.mockUserToken)){let m,E;if(typeof r.mockUserToken=="string")m=r.mockUserToken,E=yt.MOCK_USER;else{m=Ol(r.mockUserToken,(f=n._app)==null?void 0:f.options.projectId);const T=r.mockUserToken.sub||r.mockUserToken.user_id;if(!T)throw new N(S.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");E=new yt(T)}n._authCredentials=new od(new cc(m,E))}}/**
1865 * @license
1866 * Copyright 2020 Google LLC
1867 *
1868 * Licensed under the Apache License, Version 2.0 (the "License");
1869 * you may not use this file except in compliance with the License.
1870 * You may obtain a copy of the License at
1871 *
1872 *   http://www.apache.org/licenses/LICENSE-2.0
1873 *
1874 * Unless required by applicable law or agreed to in writing, software
1875 * distributed under the License is distributed on an "AS IS" BASIS,
1876 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1877 * See the License for the specific language governing permissions and
1878 * limitations under the License.
1879 */class Kt{constructor(t,e,r){this.converter=e,this._query=r,this.type="query",this.firestore=t}withConverter(t){return new Kt(this.firestore,t,this._query)}}class J{constructor(t,e,r){this.converter=e,this._key=r,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new jt(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new J(this.firestore,t,this._key)}toJSON(){return{type:J._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,e,r){if(bn(e,J._jsonSchema))return new J(t,r||null,new M(W.fromString(e.referencePath)))}}J._jsonSchemaVersion="firestore/documentReference/1.0",J._jsonSchema={type:it("string",J._jsonSchemaVersion),referencePath:it("string")};class jt extends Kt{constructor(t,e,r){super(t,e,Mr(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}
1879get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new J(this.firestore,null,new M(t))}withConverter(t){return new jt(this.firestore,t,this._path)}}function Zm(n,t,...e){if(n=xt(n),lc("collection","path",t),n instanceof zr){const r=W.fromString(t,...e);return Jo(r),new jt(n,null,r)}{if(!(n instanceof J||n instanceof jt))throw new N(S.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(W.fromString(t,...e));return Jo(r),new jt(n.firestore,null,r)}}function Cu(n,t,...e){if(n=xt(n),arguments.length===1&&(t=br.newId()),lc("doc","path",t),n instanceof zr){const r=W.fromString(t,...e);return Yo(r),new J(n,null,new M(r))}{if(!(n instanceof J||n instanceof jt))throw new N(S.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(W.fromString(t,...e));return Yo(r),new J(n.firestore,n instanceof jt?n.converter:null,new M(r))}}/**
1880 * @license
1881 * Copyright 2020 Google LLC
1882 *
1883 * Licensed under the Apache License, Version 2.0 (the "License");
1884 * you may not use this file except in compliance with the License.
1885 * You may obtain a copy of the License at
1886 *
1887 *   http://www.apache.org/licenses/LICENSE-2.0
1888 *
1889 * Unless required by applicable law or agreed to in writing, software
1890 * distributed under the License is distributed on an "AS IS" BASIS,
1891 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1892 * See the License for the specific language governing permissions and
1893 * limitations under the License.
1894 */const Ba="AsyncQueue";class qa{constructor(t=Promise.resolve()){this.Xu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new ru(this,"async_queue_retry"),this._c=()=>{const r=Ds();r&&k(Ba,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=t;const e=Ds();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.uc(),this.cc(t)}enterRestrictedMode(t){if(!this.ec){this.ec=!0,this.sc=t||!1;const e=Ds();e&&typeof e.removeEventListener=="function"&&e.removeEventListener("visibilitychange",this._c)}}enqueue(t){if(this.uc(),this.ec)return new Promise(()=>{});const e=new ne;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(t().then(e.resolve,e.reject),e.promise)).then(()=>e.promise)}enqueueRetryable(t){this.enqueueAndForget(()=>(this.Xu.push(t),this.lc()))}async lc(){if(this.Xu.length!==0){try{await this.Xu[0](),this.Xu.shift(),this.M_.reset()}catch(t){if(!$e(t))throw t;k(Ba,"Operation failed with retryable error: "+t)}this.Xu.length>0&&this.M_.p_(()=>this.lc())}}cc(t){const e=this.ac.then(()=>(this.rc=!0,t().catch(r=>{throw this.nc=r,this.rc=!1,zt("INTERNAL UNHANDLED ERROR: ",ja(r)),r}).then(r=>(this.rc=!1,r))));return this.ac=e,e}enqueueAfterDelay(t,e,r){this.uc(),this.oc.indexOf(t)>-1&&(e=0);const s=wi.createAndSchedule(this,t,e,r,o=>this.hc(o));return this.tc.push(s),s}uc(){this.nc&&x(47125,{Pc:ja(this.nc)})}verifyOperationInProgress(){}async Tc(){let t;do t=this.ac,await t;while(t!==this.ac)}Ic(t){for(const e of this.tc)if(e.timerId===t)return!0;return!1}Ec(t){return this.Tc().then(()=>{this.tc.sort((e,r)=>e.targetTimeMs-r.targetTimeMs);for(const e of this.tc)if(e.skipDelay(),t!=="all"&&e.timerId===t)break;return this.Tc()})}dc(t){this.oc.push(t)}hc(t){const e=this.tc.indexOf(t);this.tc.splice(e,1)}}function ja(n){let t=n.message||"";return n.stack&&(t=n.stack.includes(n.message)?n.stack:n.message+`
1895`+n.stack),t}/**
1896 * @license
1897 * Copyright 2017 Google LLC
1898 *
1899 * Licensed under the Apache License, Version 2.0 (the "License");
1900 * you may not use this file except in compliance with the License.
1901 * You may obtain a copy of the License at
1902 *
1903 *   http://www.apache.org/licenses/LICENSE-2.0
1904 *
1905 * Unless required by applicable law or agreed to in writing, software
1906 * distributed under the License is distributed on an "AS IS" BASIS,
1907 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1908 * See the License for the specific language governing permissions and
1909 * limitations under the License.
1910 */function $a(n){return function(e,r){if(typeof e!="object"||e===null)return!1;const s=e;for(const o of r)if(o in s&&typeof s[o]=="function")return!0;return!1}(n,["next","error","complete"])}class Ht extends zr{constructor(t,e,r,s){super(t,e,r,s),this.type="firestore",this._queue=new qa,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new qa(t),this._firestoreClient=void 0,await t}}}function tp(n,t){const e=typeof n=="object"?n:Wh(),r=typeof n=="string"?n:Er,s=$h(e,"firestore").getImmediate({identifier:r});if(!s._initialized){const o=Dl("firestore");o&&Su(s,...o)}return s}function Gr(n){if(n._terminated)throw new N(S.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||ep(n),n._firestoreClient}function ep(n){var r,s,o;const t=n._freezeSettings(),e=function(l,h,f,m){return new Rd(l,h,f,m.host,m.ssl,m.experimentalForceLongPolling,m.experimentalAutoDetectLongPolling,wu(m.experimentalLongPollingOptions),m.useFetchStreams,m.isUsingEmulator)}(n._databaseId,((r=n._app)==null?void 0:r.options.appId)||"",n._persistenceKey,t);n._componentsProvider||(s=t.localCache)!=null&&s._offlineComponentProvider&&((o=t.localCache)!=null&&o._onlineComponentProvider)&&(n._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),n._firestoreClient=new Wm(n._authCredentials,n._appCheckCredentials,n._queue,e,n._componentsProvider&&function(l){const h=l==null?void 0:l._online.build();return{_offline:l==null?void 0:l._offline.build(h),_online:h}}(n._componentsProvider))}/**
1911 * @license
1912 * Copyright 2020 Google LLC
1913 *
1914 * Licensed under the Apache License, Version 2.0 (the "License");
1915 * you may not use this file except in compliance with the License.
1916 * You may obtain a copy of the License at
1917 *
1918 *   http://www.apache.org/licenses/LICENSE-2.0
1919 *
1920 * Unless required by applicable law or agreed to in writing, software
1921 * distributed under the License is distributed on an "AS IS" BASIS,
1922 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1923 * See the License for the specific language governing permissions and
1924 * limitations under the License.
1925 */class Rt{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Rt(ut.fromBase64String(t))}catch(e){throw new N(S.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(t){return new Rt(ut.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}toJSON(){return{type:Rt._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(bn(t,Rt._jsonSchema))return Rt.fromBase64String(t.bytes)}}Rt._jsonSchemaVersion="firestore/bytes/1.0",Rt._jsonSchema={type:it("string",Rt._jsonSchemaVersion),bytes:it("string")};/**
1926 * @license
1927 * Copyright 2020 Google LLC
1928 *
1929 * Licensed under the Apache License, Version 2.0 (the "License");
1930 * you may not use this file except in compliance with the License.
1931 * You may obtain a copy of the License at
1932 *
1933 *   http://www.apache.org/licenses/LICENSE-2.0
1934 *
1935 * Unless required by applicable law or agreed to in writing, software
1936 * distributed under the License is distributed on an "AS IS" BASIS,
1937 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1938 * See the License for the specific language governing permissions and
1939 * limitations under the License.
1940 */class Mn{constructor(...t){for(let e=0;e<t.length;++e)if(t[e].length===0)throw new N(S.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ct(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}/**
1941 * @license
1942 * Copyright 2020 Google LLC
1943 *
1944 * Licensed under the Apache License, Version 2.0 (the "License");
1945 * you may not use this file except in compliance with the License.
1946 * You may obtain a copy of the License at
1947 *
1948 *   http://www.apache.org/licenses/LICENSE-2.0
1949 *
1950 * Unless required by applicable law or agreed to in writing, software
1951 * distributed under the License is distributed on an "AS IS" BASIS,
1952 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1953 * See the License for the specific language governing permissions and
1954 * limitations under the License.
1955 */class xn{constructor(t){this._methodName=t}}/**
1956 * @license
1957 * Copyright 2017 Google LLC
1958 *
1959 * Licensed under the Apache License, Version 2.0 (the "License");
1960 * you may not use this file except in compliance with the License.
1961 * You may obtain a copy of the License at
1962 *
1963 *   http://www.apache.org/licenses/LICENSE-2.0
1964 *
1965 * Unless required by applicable law or agreed to in writing, software
1966 * distributed under the License is distributed on an "AS IS" BASIS,
1967 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1968 * See the License for the specific language governing permissions and
1969 * limitations under the License.
1970 */class bt{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new N(S.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new N(S.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}_compareTo(t){return B(this._lat,t._lat)||B(this._long,t._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:bt._jsonSchemaVersion}}static fromJSON(t){if(bn(t,bt._jsonSchema))return new bt(t.latitude,t.longitude)}}bt._jsonSchemaVersion="firestore/geoPoint/1.0",bt._jsonSchema={type:it("string",bt._jsonSchemaVersion),latitude:it("number"),longitude:it("number")};/**
1971 * @license
1972 * Copyright 2024 Google LLC
1973 *
1974 * Licensed under the Apache License, Version 2.0 (the "License");
1975 * you may not use this file except in compliance with the License.
1976 * You may obtain a copy of the License at
1977 *
1978 *   http://www.apache.org/licenses/LICENSE-2.0
1979 *
1980 * Unless required by applicable law or agreed to in writing, software
1981 * distributed under the License is distributed on an "AS IS" BASIS,
1982 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1983 * See the License for the specific language governing permissions and
1984 * limitations under the License.
1985 */class Dt{constructor(t){this._values=(t||[]).map(e=>e)}toArray(){return this._values.map(t=>t)}isEqual(t){return function(r,s){if(r.length!==s.length)return!1;for(let o=0;o<r.length;++o)if(r[o]!==s[o])return!1;return!0}(this._values,t._values)}toJSON(){return{type:Dt._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(bn(t,Dt._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every(e=>typeof e=="number"))return new Dt(t.vectorValues);throw new N(S.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Dt._jsonSchemaVersion="firestore/vectorValue/1.0",Dt._jsonSchema={type:it("string",Dt._jsonSchemaVersion),vectorValues:it("object")};/**
1986 * @license
1987 * Copyright 2017 Google LLC
1988 *
1989 * Licensed under the Apache License, Version 2.0 (the "License");
1990 * you may not use this file except in compliance with the License.
1991 * You may obtain a copy of the License at
1992 *
1993 *   http://www.apache.org/licenses/LICENSE-2.0
1994 *
1995 * Unless required by applicable law or agreed to in writing, software
1996 * distributed under the License is distributed on an "AS IS" BASIS,
1997 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1998 * See the License for the specific language governing permissions and
1999 * limitations under the License.
2000 */const np=/^__.*__$/;class rp{constructor(t,e,r){this.data=t,this.fieldMask=e,this.fieldTransforms=r}toMutation(t,e){return this.fieldMask!==null?new he(t,this.data,this.fieldMask,e,this.fieldTransforms):new Dn(t,this.data,e,this.fieldTransforms)}}class Pu{constructor(t,e,r){this.data=t,this.fieldMask=e,this.fieldTransforms=r}toMutation(t,e){return new he(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function Vu(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw x(40011,{Ac:n})}}class Vi{constructor(t,e,r,s,o,a){this.settings=t,this.databaseId=e,this.serializer=r,this.ignoreUndefinedProperties=s,o===void 0&&this.Rc(),this.fieldTransforms=o||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Ac(){return this.settings.Ac}Vc(t){return new Vi({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}mc(t){var s;const e=(s=this.path)==null?void 0:s.child(t),r=this.Vc({path:e,fc:!1});return r.gc(t),r}yc(t){var s;const e=(s=this.path)==null?void 0:s.child(t),r=this.Vc({path:e,fc:!1});return r.Rc(),r}wc(t){return this.Vc({path:void 0,fc:!0})}Sc(t){return Pr(t,this.settings.methodName,this.settings.bc||!1,this.path,this.settings.Dc)}contains(t){return this.fieldMask.find(e=>t.isPrefixOf(e))!==void 0||this.fieldTransforms.find(e=>t.isPrefixOf(e.field))!==void 0}Rc(){if(this.path)for(let t=0;t<this.path.length;t++)this.gc(this.path.get(t))}gc(t){if(t.length===0)throw this.Sc("Document fields must not be empty");if(Vu(this.Ac)&&np.test(t))throw this.Sc('Document fields cannot begin and end with "__"')}}class sp{constructor(t,e,r){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer=r||qr(t)}Cc(t,e,r,s=!1){return new Vi({Ac:t,methodName:e,Dc:r,path:ct.emptyPath(),fc:!1,bc:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Hr(n){const t=n._freezeSettings(),e=qr(n._databaseId);return new sp(n._databaseId,!!t.ignoreUndefinedProperties,e)}function bu(n,t,e,r,s,o={}){const a=n.Cc(o.merge||o.mergeFields?2:0,t,e,s);Di("Data must be an object, but it was:",a,r);const l=Du(r,a);let h,f;if(o.merge)h=new St(a.fieldMask),f=a.fieldTransforms;else if(o.mergeFields){const m=[];for(const E of o.mergeFields){const T=ei(t,E,e);if(!a.contains(T))throw new N(S.INVALID_ARGUMENT,`Field '${T}' is specified in your field mask but missing from your input data.`);ku(m,T)||m.push(T)}h=new St(m),f=a.fieldTransforms.filter(E=>h.covers(E.field))}else h=null,f=a.fieldTransforms;return new rp(new At(l),h,f)}class Kr extends xn{_toFieldTransform(t){if(t.Ac!==2)throw t.Ac===1?t.Sc(`${this._methodName}() can only appear at the top level of your update data`):t.Sc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Kr}}class bi extends xn{_toFieldTransform(t){return new Xd(t.path,new Cn)}isEqual(t){return t instanceof bi}}function ip(n,t,e,r){const s=n.Cc(1,t,e);Di("Data must be an object, but it was:",s,r);const o=[],a=At.empty();le(r,(h,f)=>{const m=Ni(t,h,e);f=xt(f);const E=s.yc(m);if(f instanceof Kr)o.push(m);else{const T=Ln(f,E);T!=null&&(o.push(m),a.set(m,T))}});const l=new St(o);return new Pu(a,l,s.fieldTransforms)}function op(n,t,e,r,s,o){const a=n.Cc(1,t,e),l=[ei(t,r,e)],h=[s];if(o.length%2!=0)throw new N(S.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let T=0;T<o.length;T+=2)l.push(ei(t,o[T])),h.push(o[T+1]);const f=[],m=At.empty();for(let T=l.length-1;T>=0;--T)if(!ku(f,l[T])){const P=l[T];let b=h[T];b=xt(b);const O=a.yc(P);if(b instanceof Kr)f.push(P);else{const D=Ln(b,O);D!=null&&(f.push(P),m.set(P,D))}}const E=new St(f);return new Pu(m,E,a.fieldTransforms)}function ap(n,t,e,r=!1){return Ln(e,n.Cc(r?4:3,t))}function Ln(n,t){if(Nu(n=xt(n)))return Di("Unsupported field value:",t,n),Du(n,t);if(n instanceof xn)return function(r,s){if(!Vu(s.Ac))throw s.Sc(`${r._methodName}
2000() can only be used with update() and set()`);if(!s.path)throw s.Sc(`${r._methodName}() is not currently supported inside arrays`);const o=r._toFieldTransform(s);o&&s.fieldTransforms.push(o)}(n,t),null;if(n===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),n instanceof Array){if(t.settings.fc&&t.Ac!==4)throw t.Sc("Nested arrays are not supported");return function(r,s){const o=[];let a=0;for(const l of r){let h=Ln(l,s.wc(a));h==null&&(h={nullValue:"NULL_VALUE"}),o.push(h),a++}return{arrayValue:{values:o}}}(n,t)}return function(r,s){if((r=xt(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return Kd(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const o=X.fromDate(r);return{timestampValue:wr(s.serializer,o)}}if(r instanceof X){const o=new X(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:wr(s.serializer,o)}}if(r instanceof bt)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof Rt)return{bytesValue:Hc(s.serializer,r._byteString)};if(r instanceof J){const o=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(o))throw s.Sc(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${o.projectId}/${o.database}`);return{referenceValue:pi(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof Dt)return function(a,l){return{mapValue:{fields:{[Tc]:{stringValue:Ic},[Tr]:{arrayValue:{values:a.toArray().map(f=>{if(typeof f!="number")throw l.Sc("VectorValues must only contain numeric values.");return hi(l.serializer,f)})}}}}}}(r,s);throw s.Sc(`Unsupported field value: ${Dr(r)}`)}(n,t)}function Du(n,t){const e={};return mc(n)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):le(n,(r,s)=>{const o=Ln(s,t.mc(r));o!=null&&(e[r]=o)}),{mapValue:{fields:e}}}function Nu(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof X||n instanceof bt||n instanceof Rt||n instanceof J||n instanceof xn||n instanceof Dt)}function Di(n,t,e){if(!Nu(e)||!dc(e)){const r=Dr(e);throw r==="an object"?t.Sc(n+" a custom object"):t.Sc(n+" "+r)}}function ei(n,t,e){if((t=xt(t))instanceof Mn)return t._internalPath;if(typeof t=="string")return Ni(n,t);throw Pr("Field path arguments must be of type string or ",n,!1,void 0,e)}const cp=new RegExp("[~\\*/\\[\\]]");function Ni(n,t,e){if(t.search(cp)>=0)throw Pr(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,e);try{return new Mn(...t.split("."))._internalPath}catch{throw Pr(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,e)}}function Pr(n,t,e,r,s){const o=r&&!r.isEmpty(),a=s!==void 0;let l=`Function ${t}() called with invalid data`;e&&(l+=" (via `toFirestore()`)"),l+=". ";let h="";return(o||a)&&(h+=" (found",o&&(h+=` in field ${r}`),a&&(h+=` in document ${s}`),h+=")"),new N(S.INVALID_ARGUMENT,l+n+h)}function ku(n,t){return n.some(e=>e.isEqual(t))}/**
2001 * @license
2002 * Copyright 2020 Google LLC
2003 *
2004 * Licensed under the Apache License, Version 2.0 (the "License");
2005 * you may not use this file except in compliance with the License.
2006 * You may obtain a copy of the License at
2007 *
2008 *   http://www.apache.org/licenses/LICENSE-2.0
2009 *
2010 * Unless required by applicable law or agreed to in writing, software
2011 * distributed under the License is distributed on an "AS IS" BASIS,
2012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2013 * See the License for the specific language governing permissions and
2014 * limitations under the License.
2015 */class Ou{constructor(t,e,r,s,o){this._firestore=t,this._userDataWriter=e,this._key=r,this._document=s,this._converter=o}get id(){return this._key.path.lastSegment()}get ref(){return new J(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new up(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(Qr("DocumentSnapshot.get",t));if(e!==null)return this._userDataWriter.convertValue(e)}}}class up extends Ou{data(){return super.data()}}function Qr(n,t){return typeof t=="string"?Ni(n,t):t instanceof Mn?t._internalPath:t._delegate._internalPath}/**
2016 * @license
2017 * Copyright 2020 Google LLC
2018 *
2019 * Licensed under the Apache License, Version 2.0 (the "License");
2020 * you may not use this file except in compliance with the License.
2021 * You may obtain a copy of the License at
2022 *
2023 *   http://www.apache.org/licenses/LICENSE-2.0
2024 *
2025 * Unless required by applicable law or agreed to in writing, software
2026 * distributed under the License is distributed on an "AS IS" BASIS,
2027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2028 * See the License for the specific language governing permissions and
2029 * limitations under the License.
2030 */function lp(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new N(S.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class ki{}class Wr extends ki{}function hp(n,t,...e){let r=[];t instanceof ki&&r.push(t),r=r.concat(e),function(o){const a=o.filter(h=>h instanceof Xr).length,l=o.filter(h=>h instanceof Fn).length;if(a>1||a>0&&l>0)throw new N(S.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(...)))`.")}(r);for(const s of r)n=s._apply(n);return n}class Fn extends Wr{constructor(t,e,r){super(),this._field=t,this._op=e,this._value=r,this.type="where"}static _create(t,e,r){return new Fn(t,e,r)}_apply(t){const e=this._parse(t);return Mu(t._query,e),new Kt(t.firestore,t.converter,zs(t._query,e))}_parse(t){const e=Hr(t.firestore);return function(o,a,l,h,f,m,E){let T;if(f.isKeyField()){if(m==="array-contains"||m==="array-contains-any")throw new N(S.INVALID_ARGUMENT,`Invalid Query. You can't perform '${m}' queries on documentId().`);if(m==="in"||m==="not-in"){Ga(E,m);const b=[];for(const O of E)b.push(za(h,o,O));T={arrayValue:{values:b}}}else T=za(h,o,E)}else m!=="in"&&m!=="not-in"&&m!=="array-contains-any"||Ga(E,m),T=ap(l,a,E,m==="in"||m==="not-in");return st.create(f,m,T)}(t._query,"where",e,t.firestore._databaseId,this._field,this._op,this._value)}}function dp(n,t,e){const r=t,s=Qr("where",n);return Fn._create(s,r,e)}class Xr extends ki{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new Xr(t,e)}_parse(t){const e=this._queryConstraints.map(r=>r._parse(t)).filter(r=>r.getFilters().length>0);return e.length===1?e[0]:Nt.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return e.getFilters().length===0?t:(function(s,o){let a=s;const l=o.getFlattenedFilters();for(const h of l)Mu(a,h),a=zs(a,h)}(t._query,e),new Kt(t.firestore,t.converter,zs(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class Yr extends Wr{constructor(t,e){super(),this._field=t,this._direction=e,this.type="orderBy"}static _create(t,e){return new Yr(t,e)}_apply(t){const e=function(s,o,a){if(s.startAt!==null)throw new N(S.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new N(S.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Sn(o,a)}(t._query,this._field,this._direction);return new Kt(t.firestore,t.converter,function(s,o){const a=s.explicitOrderBy.concat([o]);return new ze(s.path,s.collectionGroup,a,s.filters.slice(),s.limit,s.limitType,s.startAt,s.endAt)}(t._query,e))}}function fp(n,t="asc"){const e=t,r=Qr("orderBy",n);return Yr._create(r,e)}class Jr extends Wr{constructor(t,e,r){super(),this.type=t,this._limit=e,this._limitType=r}static _create(t,e,r){return new Jr(t,e,r)}_apply(t){return new Kt(t.firestore,t.converter,Ir(t._query,this._limit,this._limitType))}}function mp(n){return Jr._create("limit",n,"F")}function za(n,t,e){if(typeof(e=xt(e))=="string"){if(e==="")throw new N(S.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!bc(t)&&e.indexOf("/")!==-1)throw new N(S.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);const r=t.path.child(W.fromString(e));if(!M.isDocumentKey(r))throw new N(S.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return oa(n,new M(r))}if(e instanceof J)return oa(n,e._key);throw new N(S.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Dr(e)}.`)}function Ga(n,t){if(!Array.isArray(n)||n.length===0)throw new N(S.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Mu(n,t){const e=function(s,o){for(const a of s)for(const l of a.getFlattenedFilters())if(o.indexOf(l.op)>=0)return l.op;return null}(n.filters,function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(e!==null)throw e===t.op?new N(S.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new N(S.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${e.toString()}' filters.`)}class xu{convertValue(t,e="none"){switch(ae(t)){case 0:return null;case 1:return t.booleanValue;case 2:return et(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(oe(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 11:return this.convertObject(t.mapValue,e);case 10:return this.convertVectorValue(t.mapValue);default:throw x(62114,{value:t})}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){const r={};return le(t,(s,o)=>{r[s]=this.convertValue(o,e)}),r}convertVectorValue(t){var r,s,o;const e=(o=(s=(r=t.fields)==null?void 0:r[Tr].arrayValue)==null?void 0:s.values)==null?void 0:o.map(a=>et(a.doubleValue));return new Dt(e)}convertGeoPoint(t){return new bt(et(t.latitude),et(t.longitude))}convertArray(t,e){return(t.values||[]).map(r=>this.convertValue(r,e))}convertServerTimestamp(t,e){switch(e){case"previous":const r=Or(t);return r==null?null:this.convertValue(r,e);case"estimate":return this.convertTimestamp(wn(t));default:return null}}convertTimestamp(t){const e=ie(t);return new X(e.seconds,e.nanos)}convertDocumentKey(t,e){const r=W.fromString(t);K(Jc(r),9688,{name:t});const s=new Me(r.get(1),r.get(3)),o=new M(r.popFirst(5));return s.isEqual(e)||zt(`Document ${o} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),o}}/**
2031 * @license
2032 * Copyright 2020 Google LLC
2033 *
2034 * Licensed under the Apache License, Version 2.0 (the "License");
2035 * you may not use this file except in compliance with the License.
2036 * You may obtain a copy of the License at
2037 *
2038 *   http://www.apache.org/licenses/LICENSE-2.0
2039 *
2040 * Unless required by applicable law or agreed to in writing, software
2041 * distributed under the License is distributed on an "AS IS" BASIS,
2042 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2043 * See the License for the specific language governing permissions and
2044 * limitations under the License.
2045 */function Lu(n,t,e){let r;return r=n?e&&(e.merge||e.mergeFields)?n.toFirestore(t,e):n.toFirestore(t):t,r}class Ne{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class re extends Ou{constructor(t,e,r,s,o,a){super(t,e,r,s,a),this._firestore=t,this._firestoreImpl=t,this.metadata=o}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new En(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const r=this._document.data.field(Qr("DocumentSnapshot.get",t));if(r!==null)return this._userDataWriter.convertValue(r,e.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new N(S.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t=this._document,e={};return e.type=re._jsonSchemaVersion,e.bundle="",e.bundleSource="DocumentSnapshot",e.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?e:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,"previous"),e.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),e)}}re._jsonSchemaVersion="firestore/documentSnapshot/1.0",re._jsonSchema={type:it("string",re._jsonSchemaVersion),bundleSource:it("string","DocumentSnapshot"),bundleName:it("string"),bundle:it("string")};class En extends re{data(t={}){return super.data(t)}}class ye{constructor(t,e,r,s){this._firestore=t,this._userDataWriter=e,this._snapshot=s,this.metadata=new Ne(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,e){this._snapshot.docs.forEach(r=>{t.call(e,new En(this._firestore,this._userDataWriter,r.key,r,new Ne(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new N(S.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(s,o){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map(l=>{const h=new En(s._firestore,s._userDataWriter,l.doc.key,l.doc,new Ne(s._snapshot.mutatedKeys.has(l.doc.key),s._snapshot.fromCache),s.query.converter);return l.doc,{type:"added",doc:h,oldIndex:-1,newIndex:a++}})}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(l=>o||l.type!==3).map(l=>{const h=new En(s._firestore,s._userDataWriter,l.doc.key,l.doc,new Ne(s._snapshot.mutatedKeys.has(l.doc.key),s._snapshot.fromCache),s.query.converter);let f=-1,m=-1;return l.type!==0&&(f=a.indexOf(l.doc.key),a=a.delete(l.doc.key)),l.type!==1&&(a=a.add(l.doc),m=a.indexOf(l.doc.key)),{type:pp(l.type),doc:h,oldIndex:f,newIndex:m}})}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new N(S.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t={};t.type=ye._jsonSchemaVersion,t.bundleSource="QuerySnapshot",t.bundleName=br.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const e=[],r=[],s=[];return this.docs.forEach(o=>{o._document!==null&&(e.push(o._document),r.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),s.push(o.ref.path))}),t.bundle=(this._firestore,this.query._query,t.bundleName,"NOT SUPPORTED"),t}}function pp(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return x(61501,{type:n})}}/**
2046 * @license
2047 * Copyright 2020 Google LLC
2048 *
2049 * Licensed under the Apache License, Version 2.0 (the "License");
2050 * you may not use this file except in compliance with the License.
2051 * You may obtain a copy of the License at
2052 *
2053 *   http://www.apache.org/licenses/LICENSE-2.0
2054 *
2055 * Unless required by applicable law or agreed to in writing, software
2056 * distributed under the License is distributed on an "AS IS" BASIS,
2057 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2058 * See the License for the specific language governing permissions and
2059 * limitations under the License.
2060 */function gp(n){n=Ct(n,J);const t=Ct(n.firestore,Ht);return Jm(Gr(t),n._key).then(e=>Uu(t,n,e))}ye._jsonSchemaVersion="firestore/querySnapshot/1.0",ye._jsonSchema={type:it("string",ye._jsonSchemaVersion),bundleSource:it("string","QuerySnapshot"),bundleName:it("string"),bundle:it("string")};class Fu extends xu{constructor(t){super(),this.firestore=t}convertBytes(t){return new Rt(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new J(this.firestore,null,e)}}function _p(n,t,e){n=Ct(n,J);const r=Ct(n.firestore,Ht),s=Lu(n.converter,t,e);return Un(r,[bu(Hr(r),"setDoc",n._key,s,n.converter!==null,e).toMutation(n._key,Pt.none())])}function yp(n,t,e,...r){n=Ct(n,J);const s=Ct(n.firestore,Ht),o=Hr(s);let a;return a=typeof(t=xt(t))=="string"||t instanceof Mn?op(o,"updateDoc",n._key,t,e,r):ip(o,"updateDoc",n._key,t),Un(s,[a.toMutation(n._key,Pt.exists(!0))])}function Ep(n){return Un(Ct(n.firestore,Ht),[new di(n._key,Pt.none())])}function Tp(n,t){const e=Ct(n.firestore,Ht),r=Cu(n),s=Lu(n.converter,t);return Un(e,[bu(Hr(n.firestore),"addDoc",r._key,s,n.converter!==null,{}).toMutation(r._key,Pt.exists(!1))]).then(()=>r)}function vp(n,...t){var h,f,m;n=xt(n);let e={includeMetadataChanges:!1,source:"default"},r=0;typeof t[r]!="object"||$a(t[r])||(e=t[r++]);const s={includeMetadataChanges:e.includeMetadataChanges,source:e.source};if($a(t[r])){const E=t[r];t[r]=(h=E.next)==null?void 0:h.bind(E),t[r+1]=(f=E.error)==null?void 0:f.bind(E),t[r+2]=(m=E.complete)==null?void 0:m.bind(E)}let o,a,l;if(n instanceof J)a=Ct(n.firestore,Ht),l=Mr(n._key.path),o={next:E=>{t[r]&&t[r](Uu(a,n,E))},error:t[r+1],complete:t[r+2]};else{const E=Ct(n,Kt);a=Ct(E.firestore,Ht),l=E._query;const T=new Fu(a);o={next:P=>{t[r]&&t[r](new ye(a,T,E,P))},error:t[r+1],complete:t[r+2]},lp(n._query)}return function(T,P,b,O){const D=new Iu(O),G=new fu(P,D,b);return T.asyncQueue.enqueueAndForget(async()=>hu(await ti(T),G)),()=>{D.Nu(),T.asyncQueue.enqueueAndForget(async()=>du(await ti(T),G))}}(Gr(a),l,s,o)}function Un(n,t){return function(r,s){const o=new ne;return r.asyncQueue.enqueueAndForget(async()=>Bm(await Ym(r),s,o)),o.promise}(Gr(n),t)}function Uu(n,t,e){const r=e.docs.get(t._key),s=new Fu(n);return new re(n,s,t._key,r,new Ne(e.hasPendingWrites,e.fromCache),t.converter)}function Ip(){return new bi("serverTimestamp")}(function(t,e=!0){(function(s){qe=s})(Kh),_r(new Tn("firestore",(r,{instanceIdentifier:s,options:o})=>{const a=r.getProvider("app").getImmediate(),l=new Ht(new ad(r.getProvider("auth-internal")),new ld(a,r.getProvider("app-check-internal")),function(f,m){if(!Object.prototype.hasOwnProperty.apply(f.options,["projectId"]))throw new N(S.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Me(f.options.projectId,m)}(a,s),a);return o={useFetchStreams:e,...o},l._setSettings(o),l},"PUBLIC").setMultipleInstances(!0)),mn(Ko,Qo,t),mn(Ko,Qo,"esm2020")})();const Op=Object.freeze(Object.defineProperty({__proto__:null,AbstractUserDataWriter:xu,Bytes:Rt,CollectionReference:jt,DocumentReference:J,DocumentSnapshot:re,FieldPath:Mn,FieldValue:xn,Firestore:Ht,FirestoreError:N,GeoPoint:bt,Query:Kt,QueryCompositeFilterConstraint:Xr,QueryConstraint:Wr,QueryDocumentSnapshot:En,QueryFieldFilterConstraint:Fn,QueryLimitConstraint:Jr,QueryOrderByConstraint:Yr,QuerySnapshot:ye,SnapshotMetadata:Ne,Timestamp:X,VectorValue:Dt,_AutoId:br,_ByteString:ut,_DatabaseId:Me,_DocumentKey:M,_EmptyAuthCredentialsProvider:uc,_FieldPath:ct,_cast:Ct,_logWarn:Te,_validateIsNotUsedTogether:hc,addDoc:Tp,collection:Zm,connectFirestoreEmulator:Su,deleteDoc:Ep,doc:Cu,ensureFirestoreConfigured:Gr,executeWrite:Un,getDoc:gp,getFirestore:tp,limit:mp,onSnapshot:vp,orderBy:fp,query:hp,serverTimestamp:Ip,setDoc:_p,updateDoc:yp,where:dp},Symbol.toStringTag,{value:"Module"}));
2060export{bl as A,Wh as B,Tn as C,gr as D,Wa as E,Be as F,kl as G,Ll as H,Pp as I,Vp as J,Dl as K,Xa as L,Ol as M,Np as N,Qh as O,tp as P,Op as Q,Kh as S,_r as _,vp as a,Tp as b,Zm as c,Cu as d,Ap as e,Cp as f,gp as g,Sp as h,wp as i,zh as j,xt as k,mp as l,Dp as m,$ as n,fp as o,ri as p,hp as q,mn as r,Ip as s,Rl as t,yp as u,bp as v,dp as w,Rp as x,ni as y,$h as z};

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.